|
View:
New views
1 Messages
—
Rating Filter:
Alert me
|
|
|
SF.net SVN: jikesrvm:[15754] rvmroot/trunk/MMTk/harnessRevision: 15754
http://jikesrvm.svn.sourceforge.net/jikesrvm/?rev=15754&view=rev Author: rgarner Date: 2009-07-31 05:27:17 +0000 (Fri, 31 Jul 2009) Log Message: ----------- RVM-846, command-line option to allow tracing of memory addresses. Modified Paths: -------------- rvmroot/trunk/MMTk/harness/src/org/mmtk/harness/Harness.java rvmroot/trunk/MMTk/harness/src/org/mmtk/harness/options/HarnessOptionSet.java rvmroot/trunk/MMTk/harness/vmmagic/org/vmmagic/unboxed/Word.java Added Paths: ----------- rvmroot/trunk/MMTk/harness/src/org/mmtk/harness/options/WatchAddress.java rvmroot/trunk/MMTk/harness/src/org/mmtk/harness/options/WordSetOption.java rvmroot/trunk/MMTk/harness/vmmagic/org/vmmagic/unboxed/harness/WordComparator.java Modified: rvmroot/trunk/MMTk/harness/src/org/mmtk/harness/Harness.java =================================================================== --- rvmroot/trunk/MMTk/harness/src/org/mmtk/harness/Harness.java 2009-07-30 02:08:30 UTC (rev 15753) +++ rvmroot/trunk/MMTk/harness/src/org/mmtk/harness/Harness.java 2009-07-31 05:27:17 UTC (rev 15754) @@ -22,7 +22,9 @@ import org.mmtk.utility.Log; import org.mmtk.utility.heap.HeapGrowthManager; import org.mmtk.utility.options.Options; +import org.vmmagic.unboxed.Address; import org.vmmagic.unboxed.harness.ArchitecturalWord; +import org.vmmagic.unboxed.harness.SimulatedMemory; import org.vmutil.options.BooleanOption; /** @@ -82,9 +84,13 @@ /** A set of objects to watch */ public static final WatchObject watchObject = new WatchObject(); + /** A set of addresses to watch */ + public static final WatchAddress watchAddress = new WatchAddress(); + /** Timeout on unreasonably long GC */ public static final Timeout timeout = new Timeout(); + /** Whether the Harness sanity checker uses the read barrier */ public static final BooleanOption sanityUsesReadBarrier = new SanityUsesReadBarrier(); private static boolean isInitialized = false; @@ -114,7 +120,7 @@ options.process(arg); } } - ArchitecturalWord.init(Harness.bits.getValue()); // Reads 'bits' + ArchitecturalWord.init(Harness.bits.getValue()); for(String arg: args) { if (!options.process(arg)) newArgs.add(arg); } @@ -122,6 +128,11 @@ gcEvery.apply(); org.mmtk.harness.scheduler.Scheduler.init(); + for (Address watchAddr : watchAddress.getAddresses()) { + System.err.printf("Setting watch at %s%n",watchAddr); + SimulatedMemory.addWatch(watchAddr); + } + /* * Perform MMTk initialization in a minimal environment, specifically to * give it a per-thread 'Log' object Modified: rvmroot/trunk/MMTk/harness/src/org/mmtk/harness/options/HarnessOptionSet.java =================================================================== --- rvmroot/trunk/MMTk/harness/src/org/mmtk/harness/options/HarnessOptionSet.java 2009-07-30 02:08:30 UTC (rev 15753) +++ rvmroot/trunk/MMTk/harness/src/org/mmtk/harness/options/HarnessOptionSet.java 2009-07-31 05:27:17 UTC (rev 15754) @@ -18,6 +18,7 @@ import org.vmmagic.unboxed.Extent; import org.vmmagic.unboxed.Word; import org.vmmagic.unboxed.harness.MemoryConstants; +import org.vmmagic.unboxed.harness.WordComparator; import org.vmutil.options.AddressOption; import org.vmutil.options.BooleanOption; import org.vmutil.options.EnumOption; @@ -34,15 +35,18 @@ public final class HarnessOptionSet extends org.vmutil.options.OptionSet { /* - * The following 2 option types are used only by the MMTk Harness, + * The following option types are used only by the MMTk Harness, * since they are hard to implement without allocating. */ /** A Set<Enum> valued option */ public static final int ENUM_SET_OPTION = 1001; /** A multi-valued integer valued option */ - public static final int INT_SET_OPTION = 1011; + public static final int INT_SET_OPTION = 1002; + /** A multi-valued integer valued option */ + public static final int WORD_SET_OPTION = 1003; + /** * Take a string (most likely a command-line argument) and try to proccess it * as an option command. Return true if the string was understood, false @@ -153,24 +157,45 @@ return false; } return true; + case WORD_SET_OPTION: + ((WordSetOption)o).setValue(parseWordSet(value)); + return true; } // None of the above tests matched, so this wasn't an option return false; } - private int[] parseIntSet(String value) { - TreeSet<Integer> intSetValues = new TreeSet<Integer>(); - for (String element : value.split(",")) { - intSetValues.add(Integer.valueOf(element)); + private int[] parseIntSet(String str) { + TreeSet<Integer> values = new TreeSet<Integer>(); + for (String element : str.split(",")) { + values.add(Integer.valueOf(element)); } - int[] intValues = new int[intSetValues.size()]; - for (int i=0; i < intValues.length; i++) { - intValues[i] = intSetValues.pollFirst(); + int[] result = new int[values.size()]; + for (int i=0; i < result.length; i++) { + result[i] = values.pollFirst(); } - return intValues; + return result; } + private Word[] parseWordSet(String str) { + TreeSet<Word> values = new TreeSet<Word>(new WordComparator()); + for (String element : str.split(",")) { + Long value; + if (element.startsWith("0x")) { + value = Long.valueOf(element.substring(2),16); + } else { + value = Long.valueOf(element); + } + values.add(Word.fromLong(value)); + } + Word[] result = new Word[values.size()]; + for (int i=0; i < result.length; i++) { + result[i] = values.pollFirst(); + } + return result; + } + /** * Print a short description of every option */ Added: rvmroot/trunk/MMTk/harness/src/org/mmtk/harness/options/WatchAddress.java =================================================================== --- rvmroot/trunk/MMTk/harness/src/org/mmtk/harness/options/WatchAddress.java (rev 0) +++ rvmroot/trunk/MMTk/harness/src/org/mmtk/harness/options/WatchAddress.java 2009-07-31 05:27:17 UTC (rev 15754) @@ -0,0 +1,28 @@ +/* + * This file is part of the Jikes RVM project (http://jikesrvm.org). + * + * This file is licensed to You under the Eclipse Public License (EPL); + * You may not use this file except in compliance with the License. You + * may obtain a copy of the License at + * + * http://www.opensource.org/licenses/eclipse-1.0.php + * + * See the COPYRIGHT.txt file distributed with this work for information + * regarding copyright ownership. + */ +package org.mmtk.harness.options; + +import org.mmtk.harness.Harness; +import org.vmmagic.unboxed.Word; + +/** + * A set of addresses to watch + */ +public class WatchAddress extends WordSetOption { + + /** + */ + public WatchAddress() { + super(Harness.options, "Watch Address", "A list of addresses to watch", new Word[0]); + } +} Added: rvmroot/trunk/MMTk/harness/src/org/mmtk/harness/options/WordSetOption.java =================================================================== --- rvmroot/trunk/MMTk/harness/src/org/mmtk/harness/options/WordSetOption.java (rev 0) +++ rvmroot/trunk/MMTk/harness/src/org/mmtk/harness/options/WordSetOption.java 2009-07-31 05:27:17 UTC (rev 15754) @@ -0,0 +1,90 @@ +/* + * This file is part of the Jikes RVM project (http://jikesrvm.org). + * + * This file is licensed to You under the Eclipse Public License (EPL); + * You may not use this file except in compliance with the License. You + * may obtain a copy of the License at + * + * http://www.opensource.org/licenses/eclipse-1.0.php + * + * See the COPYRIGHT.txt file distributed with this work for information + * regarding copyright ownership. + */ +package org.mmtk.harness.options; + +import static org.mmtk.harness.options.HarnessOptionSet.WORD_SET_OPTION; + +import org.vmmagic.pragma.Uninterruptible; +import org.vmmagic.unboxed.Address; +import org.vmmagic.unboxed.Word; +import org.vmutil.options.Option; +import org.vmutil.options.OptionSet; + +/** + * A set-valued option, eg opt=v1,v2,v3 + * The values of the set are Words + */ +public class WordSetOption extends Option { + + // values + protected Word[] defaultValues; + protected Word[] values; + + /** + * Create a new multivalued word option. + * + * @param set The option set this option belongs to. + * @param name The space separated name for the option. + * @param description The purpose of the option. + * @param defaultValues The default value of the option. + */ + protected WordSetOption(OptionSet set, String name, String description, Word[] defaultValues) { + super(set, WORD_SET_OPTION, name, description); + this.values = this.defaultValues = defaultValues; + } + + /** + * Read the current value of the option. + * + * @return The option value. + */ + @Uninterruptible + public Word[] getValue() { + return this.values; + } + + /** + * @return The values of the option, as Addresses + */ + public Address[] getAddresses() { + Word[] words = getValue(); + Address[] result = new Address[words.length]; + for (int i=0; i < words.length; i++) { + result[i] = words[i].toAddress(); + } + return result; + } + + /** + * Read the default value of the option. + * + * @return The default value. + */ + @Uninterruptible + public Word[] getDefaultValue() { + return this.defaultValues; + } + + /** + * Update the value of the option, echoing the change if the echoOptions + * option is set. This method also calls the validate method to allow + * subclasses to perform any required validation. + * + * @param values The new value for the option. + */ + public void setValue(Word[] values) { + this.values = values; + validate(); + set.logChange(this); + } +} Modified: rvmroot/trunk/MMTk/harness/vmmagic/org/vmmagic/unboxed/Word.java =================================================================== --- rvmroot/trunk/MMTk/harness/vmmagic/org/vmmagic/unboxed/Word.java 2009-07-30 02:08:30 UTC (rev 15753) +++ rvmroot/trunk/MMTk/harness/vmmagic/org/vmmagic/unboxed/Word.java 2009-07-31 05:27:17 UTC (rev 15754) @@ -12,6 +12,7 @@ */ package org.vmmagic.unboxed; + import org.vmmagic.Unboxed; import org.vmmagic.pragma.RawStorage; import org.vmmagic.unboxed.harness.ArchitecturalWord; @@ -328,6 +329,10 @@ return new Word(value.rsha(amt)); } + /** + * The natural string representation of a word, a series of hex digits. + */ + @Override public String toString() { return value.toString(); } Added: rvmroot/trunk/MMTk/harness/vmmagic/org/vmmagic/unboxed/harness/WordComparator.java =================================================================== --- rvmroot/trunk/MMTk/harness/vmmagic/org/vmmagic/unboxed/harness/WordComparator.java (rev 0) +++ rvmroot/trunk/MMTk/harness/vmmagic/org/vmmagic/unboxed/harness/WordComparator.java 2009-07-31 05:27:17 UTC (rev 15754) @@ -0,0 +1,32 @@ +/* + * This file is part of the Jikes RVM project (http://jikesrvm.org). + * + * This file is licensed to You under the Eclipse Public License (EPL); + * You may not use this file except in compliance with the License. You + * may obtain a copy of the License at + * + * http://www.opensource.org/licenses/eclipse-1.0.php + * + * See the COPYRIGHT.txt file distributed with this work for information + * regarding copyright ownership. + */ +package org.vmmagic.unboxed.harness; + +import java.util.Comparator; + +import org.vmmagic.unboxed.Word; + +/** + * A comparator so that we can use a Word in java.util sets etc. + */ +public class WordComparator implements Comparator<Word> { + + /** + * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object) + */ + @Override + public int compare(Word arg0, Word arg1) { + return arg0.LT(arg1) ? -1 : (arg0.EQ(arg1) ? 0 : 1); + } + +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ Jikesrvm-commits mailing list Jikesrvm-commits@... https://lists.sourceforge.net/lists/listinfo/jikesrvm-commits |
| Free embeddable forum powered by Nabble | Forum Help |