incubator-kato-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From monte...@apache.org
Subject svn commit: r883384 [47/47] - in /incubator/kato/trunk/org.apache.kato: ./ kato.anttasks/src/main/java/org/apache/kato/anttasks/ kato.anttasks/src/main/java/org/apache/kato/anttasks/sitebuilder/ kato.anttasks/src/main/java/org/apache/kato/anttasks/tck/...
Date Mon, 23 Nov 2009 15:54:15 GMT
Modified: incubator/kato/trunk/org.apache.kato/kato.tools.katoview/src/main/java/org/apache/kato/katoview/commands/xcommands/XKCommand.java
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/org.apache.kato/kato.tools.katoview/src/main/java/org/apache/kato/katoview/commands/xcommands/XKCommand.java?rev=883384&r1=883383&r2=883384&view=diff
==============================================================================
--- incubator/kato/trunk/org.apache.kato/kato.tools.katoview/src/main/java/org/apache/kato/katoview/commands/xcommands/XKCommand.java (original)
+++ incubator/kato/trunk/org.apache.kato/kato.tools.katoview/src/main/java/org/apache/kato/katoview/commands/xcommands/XKCommand.java Mon Nov 23 15:53:48 2009
@@ -1,235 +1,235 @@
-/*******************************************************************************
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * 
- *   http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- ******************************************************************************/
-package org.apache.kato.katoview.commands.xcommands;
-
-import java.util.HashMap;
-import java.util.Stack;
-import java.util.Iterator;
-
-import javax.tools.diagnostics.image.CorruptData;
-import javax.tools.diagnostics.image.CorruptDataException;
-import javax.tools.diagnostics.image.DataUnavailable;
-import javax.tools.diagnostics.image.Image;
-import javax.tools.diagnostics.image.ImageAddressSpace;
-import javax.tools.diagnostics.image.ImageModule;
-import javax.tools.diagnostics.image.ImagePointer;
-import javax.tools.diagnostics.image.ImageProcess;
-import javax.tools.diagnostics.image.ImageSection;
-import javax.tools.diagnostics.image.ImageSymbol;
-import javax.tools.diagnostics.image.MemoryAccessException;
-
-import org.apache.kato.katoview.Output;
-import org.apache.kato.katoview.commands.Command;
-import org.apache.kato.katoview.commands.helpers.Exceptions;
-import org.apache.kato.katoview.commands.helpers.Utils;
-
-
-public class XKCommand extends Command {
-
-	public XKCommand(Output o){
-		super(o, "k", "displays the specified memory section as if it were a stack frame",
-				"parameters: 0x<addr>\n\n" +
-				"Displays the value of each section (whose size is defined by the " +
-				"pointer size of this architecture) of memory, adjusted for the " +
-				"endianness of the architecture this dump file is from, starting at the " +
-				"specified address.  It also displays a module with a module section " +
-				"and an offset from the start of that module section in memory if the " +
-				"pointer points to that module section.  " +
-				"If no symbol is found, it displays a \"*\" and an offset from the " +
-				"current address if the pointer points to an address within 4KB (4096 " +
-				"bytes) of the current address.\n\n" +
-				"While this command can work on an arbitrary section of memory, it is " +
-				"probably most useful when used on a section of memory that refers to a " +
-				"stack frame.  To find the memory section of a thread's stack frame, use " +
-				"the \"info thread\" command.\n\n" +
-				"Note: This command uses the number of items passed to " +
-				"it by the \"x/\" command, but ignores the unit size.\n");
-		child_commands = null;
-	}
-	
-	public void doCommand(Stack args, Image loadedImage, HashMap properties)
-	{
-		int numUnits = ((Integer)args.pop()).intValue();
-		args.pop();	// pop and discard unitSize; we ignore this value
-		
-		if (args.isEmpty())
-		{
-			out.error("\"x/k\" command takes exactly one parameter");
-			return;
-		}
-
-		String param = (String)args.pop();
-		if (!args.isEmpty())
-		{
-			out.error("\"x/k\" only takes one parameter");
-			return;
-		}
-		
-		Long address = Utils.longFromStringWithPrefix(param);
-		
-		if (null == address)
-		{
-			out.error("invalid hex address specified; address must be specified as "
-					+ "\"0x<hex_address>\"");
-			return;
-		}
-		
-		ImageAddressSpace ias = (ImageAddressSpace)properties.get("current_address_space");
-		int pointerSize = getIASPointerSize(ias);
-		int unitSize;
-		
-		if (pointerSize > 32)
-			unitSize = 8;
-		else
-			unitSize = 4;
-		
-		out.print("\n");
-		
-		for (int index = 0; index < numUnits; index++)
-		{
-			boolean found = false;
-			long currAddr = address.longValue() + (index * unitSize);
-			ImagePointer ip = ias.getPointer(currAddr);
-			
-			out.print("\t");
-			out.print(Utils.toHex(currAddr));
-			out.print("   ");
-
-			long l = 0;
-			try {
-				l = ip.getPointerAt(0).getAddress();
-				found = true;
-			} catch (CorruptDataException e) {
-				found = false;
-			} catch (MemoryAccessException e) {
-				found = false;
-			}
-
-			if (found) {
-				long pointer = l;
-				
-				out.print(toAdjustedHex(l, pointerSize));
-				out.print("   ");
-
-				if (31 == pointerSize) {
-					pointer = (int)(pointer & (((long)1) << pointerSize) - 1);
-				}
-				
-				if (printSymbol(pointer, l - currAddr, pointerSize, ias)) {
-				} else if (printStackPointer(pointer, l - currAddr, pointerSize, ias)) {
-				}
-				out.print("\n");
-			} else {
-				out.print("<address not found in any address space or exception occurred>\n");
-			}
-		}
-		
-		out.print("\n");
-	}
-	
-	private boolean printSymbol(long pointer, long diff, int pointerSize, ImageAddressSpace ias)
-	{
-		Iterator itProcess = ias.getProcesses().iterator();
-		while (itProcess.hasNext()) {
-			ImageProcess ip = (ImageProcess)itProcess.next();
-			Iterator itModule;
-			try {
-				itModule = ip.getLibraries().iterator();
-			} catch (CorruptDataException e) {
-				// FIXME
-				itModule = null;
-			} catch (DataUnavailable e) {
-				// FIXME
-				itModule = null;
-			}
-			while (null != itModule && itModule.hasNext()) {
-				ImageModule im = (ImageModule)itModule.next();
-				Iterator itImageSection = im.getSections().iterator();
-				while (itImageSection.hasNext()) {
-					ImageSection is = (ImageSection)itImageSection.next();
-					long startAddr = is.getBaseAddress().getAddress();
-					long endAddr = startAddr + is.getSize();
-					
-					if (pointer >= startAddr && pointer < endAddr) {
-						/* can we find a matching symbol? */
-						long maxDifference = pointer - startAddr;
-						ImageSymbol bestSymbol = null;
-						for (Iterator iter = im.getSymbols().iterator(); iter.hasNext();) {
-							Object next = iter.next();
-							if (next instanceof CorruptData)
-								continue;
-							ImageSymbol symbol = (ImageSymbol) next;
-							long symbolAddress = symbol.getAddress().getAddress();
-							if (symbolAddress <= pointer && pointer - symbolAddress < maxDifference) {
-								maxDifference = pointer - symbolAddress;
-								bestSymbol = symbol;
-							}
-						}
-
-						try {
-							out.print(im.getName());
-						} catch (CorruptDataException e) {
-							out.print(Exceptions.getCorruptDataExceptionString());
-						}
-						out.print("::");
-						if (bestSymbol == null) {
-							out.print(is.getName());
-						} else {
-							out.print(bestSymbol.getName());
-						}
-						out.print("+");
-						out.print(Long.toString(maxDifference));
-						
-						// if we find the address in the symbols, there's no need to continue
-						//  trying to find it elsewhere in the address space
-						return true;
-					}
-				}
-			}
-		}
-		
-		return false;
-	}
-	
-	private boolean printStackPointer(long pointer, long diff, int pointerSize, ImageAddressSpace ias)
-	{
-		if (Math.abs(diff) <= 4096) {	
-			if (diff < 0) {
-				out.print(" .");
-				out.print(Long.toString(diff));
-			} else {
-				out.print(" .+");
-				out.print(Long.toString(diff));
-			}
-			return true;
-		}
-		return false;
-	}
-	
-	private int getIASPointerSize(ImageAddressSpace ias)
-	{
-		return ((ImageProcess)ias.getProcesses().iterator().next()).getPointerSize();
-	}
-
-	private String toAdjustedHex(long l, int pointerSize)
-	{
-		if (pointerSize > 32) {
-			return Utils.toFixedWidthHex(l);
-		} else if (31 == pointerSize) {
-			return Utils.toFixedWidthHex((int)(l & (((long)1) << pointerSize) - 1));
-		} else {
-			return Utils.toFixedWidthHex((int)l);
-		}
-	}
-}
+/*******************************************************************************
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+package org.apache.kato.katoview.commands.xcommands;
+
+import java.util.HashMap;
+import java.util.Stack;
+import java.util.Iterator;
+
+import javax.tools.diagnostics.image.CorruptData;
+import javax.tools.diagnostics.image.CorruptDataException;
+import javax.tools.diagnostics.image.DataUnavailable;
+import javax.tools.diagnostics.image.Image;
+import javax.tools.diagnostics.image.ImageAddressSpace;
+import javax.tools.diagnostics.image.ImageModule;
+import javax.tools.diagnostics.image.ImagePointer;
+import javax.tools.diagnostics.image.ImageProcess;
+import javax.tools.diagnostics.image.ImageSection;
+import javax.tools.diagnostics.image.ImageSymbol;
+import javax.tools.diagnostics.image.MemoryAccessException;
+
+import org.apache.kato.katoview.Output;
+import org.apache.kato.katoview.commands.Command;
+import org.apache.kato.katoview.commands.helpers.Exceptions;
+import org.apache.kato.katoview.commands.helpers.Utils;
+
+
+public class XKCommand extends Command {
+
+	public XKCommand(Output o){
+		super(o, "k", "displays the specified memory section as if it were a stack frame",
+				"parameters: 0x<addr>\n\n" +
+				"Displays the value of each section (whose size is defined by the " +
+				"pointer size of this architecture) of memory, adjusted for the " +
+				"endianness of the architecture this dump file is from, starting at the " +
+				"specified address.  It also displays a module with a module section " +
+				"and an offset from the start of that module section in memory if the " +
+				"pointer points to that module section.  " +
+				"If no symbol is found, it displays a \"*\" and an offset from the " +
+				"current address if the pointer points to an address within 4KB (4096 " +
+				"bytes) of the current address.\n\n" +
+				"While this command can work on an arbitrary section of memory, it is " +
+				"probably most useful when used on a section of memory that refers to a " +
+				"stack frame.  To find the memory section of a thread's stack frame, use " +
+				"the \"info thread\" command.\n\n" +
+				"Note: This command uses the number of items passed to " +
+				"it by the \"x/\" command, but ignores the unit size.\n");
+		child_commands = null;
+	}
+	
+	public void doCommand(Stack args, Image loadedImage, HashMap properties)
+	{
+		int numUnits = ((Integer)args.pop()).intValue();
+		args.pop();	// pop and discard unitSize; we ignore this value
+		
+		if (args.isEmpty())
+		{
+			out.error("\"x/k\" command takes exactly one parameter");
+			return;
+		}
+
+		String param = (String)args.pop();
+		if (!args.isEmpty())
+		{
+			out.error("\"x/k\" only takes one parameter");
+			return;
+		}
+		
+		Long address = Utils.longFromStringWithPrefix(param);
+		
+		if (null == address)
+		{
+			out.error("invalid hex address specified; address must be specified as "
+					+ "\"0x<hex_address>\"");
+			return;
+		}
+		
+		ImageAddressSpace ias = (ImageAddressSpace)properties.get("current_address_space");
+		int pointerSize = getIASPointerSize(ias);
+		int unitSize;
+		
+		if (pointerSize > 32)
+			unitSize = 8;
+		else
+			unitSize = 4;
+		
+		out.print("\n");
+		
+		for (int index = 0; index < numUnits; index++)
+		{
+			boolean found = false;
+			long currAddr = address.longValue() + (index * unitSize);
+			ImagePointer ip = ias.getPointer(currAddr);
+			
+			out.print("\t");
+			out.print(Utils.toHex(currAddr));
+			out.print("   ");
+
+			long l = 0;
+			try {
+				l = ip.getPointerAt(0).getAddress();
+				found = true;
+			} catch (CorruptDataException e) {
+				found = false;
+			} catch (MemoryAccessException e) {
+				found = false;
+			}
+
+			if (found) {
+				long pointer = l;
+				
+				out.print(toAdjustedHex(l, pointerSize));
+				out.print("   ");
+
+				if (31 == pointerSize) {
+					pointer = (int)(pointer & (((long)1) << pointerSize) - 1);
+				}
+				
+				if (printSymbol(pointer, l - currAddr, pointerSize, ias)) {
+				} else if (printStackPointer(pointer, l - currAddr, pointerSize, ias)) {
+				}
+				out.print("\n");
+			} else {
+				out.print("<address not found in any address space or exception occurred>\n");
+			}
+		}
+		
+		out.print("\n");
+	}
+	
+	private boolean printSymbol(long pointer, long diff, int pointerSize, ImageAddressSpace ias)
+	{
+		Iterator itProcess = ias.getProcesses().iterator();
+		while (itProcess.hasNext()) {
+			ImageProcess ip = (ImageProcess)itProcess.next();
+			Iterator itModule;
+			try {
+				itModule = ip.getLibraries().iterator();
+			} catch (CorruptDataException e) {
+				// FIXME
+				itModule = null;
+			} catch (DataUnavailable e) {
+				// FIXME
+				itModule = null;
+			}
+			while (null != itModule && itModule.hasNext()) {
+				ImageModule im = (ImageModule)itModule.next();
+				Iterator itImageSection = im.getSections().iterator();
+				while (itImageSection.hasNext()) {
+					ImageSection is = (ImageSection)itImageSection.next();
+					long startAddr = is.getBaseAddress().getAddress();
+					long endAddr = startAddr + is.getSize();
+					
+					if (pointer >= startAddr && pointer < endAddr) {
+						/* can we find a matching symbol? */
+						long maxDifference = pointer - startAddr;
+						ImageSymbol bestSymbol = null;
+						for (Iterator iter = im.getSymbols().iterator(); iter.hasNext();) {
+							Object next = iter.next();
+							if (next instanceof CorruptData)
+								continue;
+							ImageSymbol symbol = (ImageSymbol) next;
+							long symbolAddress = symbol.getAddress().getAddress();
+							if (symbolAddress <= pointer && pointer - symbolAddress < maxDifference) {
+								maxDifference = pointer - symbolAddress;
+								bestSymbol = symbol;
+							}
+						}
+
+						try {
+							out.print(im.getName());
+						} catch (CorruptDataException e) {
+							out.print(Exceptions.getCorruptDataExceptionString());
+						}
+						out.print("::");
+						if (bestSymbol == null) {
+							out.print(is.getName());
+						} else {
+							out.print(bestSymbol.getName());
+						}
+						out.print("+");
+						out.print(Long.toString(maxDifference));
+						
+						// if we find the address in the symbols, there's no need to continue
+						//  trying to find it elsewhere in the address space
+						return true;
+					}
+				}
+			}
+		}
+		
+		return false;
+	}
+	
+	private boolean printStackPointer(long pointer, long diff, int pointerSize, ImageAddressSpace ias)
+	{
+		if (Math.abs(diff) <= 4096) {	
+			if (diff < 0) {
+				out.print(" .");
+				out.print(Long.toString(diff));
+			} else {
+				out.print(" .+");
+				out.print(Long.toString(diff));
+			}
+			return true;
+		}
+		return false;
+	}
+	
+	private int getIASPointerSize(ImageAddressSpace ias)
+	{
+		return ((ImageProcess)ias.getProcesses().iterator().next()).getPointerSize();
+	}
+
+	private String toAdjustedHex(long l, int pointerSize)
+	{
+		if (pointerSize > 32) {
+			return Utils.toFixedWidthHex(l);
+		} else if (31 == pointerSize) {
+			return Utils.toFixedWidthHex((int)(l & (((long)1) << pointerSize) - 1));
+		} else {
+			return Utils.toFixedWidthHex((int)l);
+		}
+	}
+}

Propchange: incubator/kato/trunk/org.apache.kato/kato.tools.katoview/src/main/java/org/apache/kato/katoview/commands/xcommands/XKCommand.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/kato/trunk/org.apache.kato/kato.tools.katoview/src/main/java/org/apache/kato/katoview/commands/xcommands/XXCommand.java
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/org.apache.kato/kato.tools.katoview/src/main/java/org/apache/kato/katoview/commands/xcommands/XXCommand.java?rev=883384&r1=883383&r2=883384&view=diff
==============================================================================
--- incubator/kato/trunk/org.apache.kato/kato.tools.katoview/src/main/java/org/apache/kato/katoview/commands/xcommands/XXCommand.java (original)
+++ incubator/kato/trunk/org.apache.kato/kato.tools.katoview/src/main/java/org/apache/kato/katoview/commands/xcommands/XXCommand.java Mon Nov 23 15:53:48 2009
@@ -1,147 +1,147 @@
-/*******************************************************************************
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * 
- *   http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- ******************************************************************************/
-package org.apache.kato.katoview.commands.xcommands;
-
-import java.util.HashMap;
-import java.util.Stack;
-import java.util.Iterator;
-
-import javax.tools.diagnostics.image.CorruptDataException;
-import javax.tools.diagnostics.image.Image;
-import javax.tools.diagnostics.image.ImageAddressSpace;
-import javax.tools.diagnostics.image.ImagePointer;
-import javax.tools.diagnostics.image.MemoryAccessException;
-
-import org.apache.kato.katoview.Output;
-import org.apache.kato.katoview.commands.Command;
-import org.apache.kato.katoview.commands.helpers.Utils;
-
-
-public class XXCommand extends Command {
-
-	public XXCommand(Output o){
-		super(o, "x", "displays the hex value of the bytes at the specified address",
-				"parameters: 0x<addr>\n\n" +
-				"Displays the hex value of the bytes at the specified address, " +
-				"adjusted for the endianness of the architecture this dump file is " +
-				"from.\n\n" +
-				"Note: This command uses the number of items and unit size passed to " +
-				"it by the \"x/\" command.\n"
-		);
-		child_commands = null;
-	}
-	
-	public void doCommand(Stack args, Image loadedImage, HashMap properties)
-	{
-		int numUnits = ((Integer)args.pop()).intValue();
-		int unitSize = ((Integer)args.pop()).intValue();
-		
-		if (args.isEmpty())
-		{
-			out.error("\"x/x\" command takes exactly one parameter");
-			return;
-		}
-
-		String param = (String)args.pop();
-		if (!args.isEmpty())
-		{
-			out.error("\"x/x\" only takes one parameter");
-			return;
-		}
-		Long address;
-		
-		address = Utils.longFromStringWithPrefix(param);
-		if (null == address)
-		{
-			out.error("invalid hex address specify; address must be specified as "
-					+ "\"0x<hex_address>\"");
-			return;
-		}
-
-		out.print("\n");
-		
-		for (int index = 0; index < numUnits; index++)
-		{
-			boolean found = false;
-			Iterator itImageAddressSpace = loadedImage.getAddressSpaces().iterator();
-			long currAddr = address.longValue() + (index * unitSize);
-			
-			out.print("\t");
-			out.print(Utils.toHex(currAddr));
-			out.print(": ");
-			
-			while (itImageAddressSpace.hasNext() && !found)
-			{
-				ImageAddressSpace ias = (ImageAddressSpace)itImageAddressSpace.next();
-				ImagePointer ip = ias.getPointer(currAddr);
-				
-				byte b = 0;
-				short s = 0;
-				int i = 0;
-				long l = 0;
-				try {
-					switch (unitSize)
-					{
-					case 1:
-						b = ip.getByteAt(0);
-						break;
-					case 2:
-						s = ip.getShortAt(0);
-						break;
-					case 4:
-						i = ip.getIntAt(0);
-						break;
-					case 8:
-						l = ip.getLongAt(0);
-						break;
-					}
-					
-					found = true;
-				} catch (CorruptDataException e) {
-					found = false;
-				} catch (MemoryAccessException e) {
-					found = false;
-				}
-
-				if (found)
-				{
-					switch (unitSize)
-					{
-					case 1:
-						out.print(Utils.toFixedWidthHex(b));
-						break;
-					case 2:
-						out.print(Utils.toFixedWidthHex(s));
-						break;
-					case 4:
-						out.print(Utils.toFixedWidthHex(i));
-						break;
-					case 8:
-						out.print(Utils.toFixedWidthHex(l));
-						break;
-					}
-				}
-			}
-			
-			if (!found)
-			{
-				out.print("<address not found in any address space>");
-			}
-			out.print("\n");
-		}
-		
-		out.print("\n");
-	}
-	
-}
+/*******************************************************************************
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+package org.apache.kato.katoview.commands.xcommands;
+
+import java.util.HashMap;
+import java.util.Stack;
+import java.util.Iterator;
+
+import javax.tools.diagnostics.image.CorruptDataException;
+import javax.tools.diagnostics.image.Image;
+import javax.tools.diagnostics.image.ImageAddressSpace;
+import javax.tools.diagnostics.image.ImagePointer;
+import javax.tools.diagnostics.image.MemoryAccessException;
+
+import org.apache.kato.katoview.Output;
+import org.apache.kato.katoview.commands.Command;
+import org.apache.kato.katoview.commands.helpers.Utils;
+
+
+public class XXCommand extends Command {
+
+	public XXCommand(Output o){
+		super(o, "x", "displays the hex value of the bytes at the specified address",
+				"parameters: 0x<addr>\n\n" +
+				"Displays the hex value of the bytes at the specified address, " +
+				"adjusted for the endianness of the architecture this dump file is " +
+				"from.\n\n" +
+				"Note: This command uses the number of items and unit size passed to " +
+				"it by the \"x/\" command.\n"
+		);
+		child_commands = null;
+	}
+	
+	public void doCommand(Stack args, Image loadedImage, HashMap properties)
+	{
+		int numUnits = ((Integer)args.pop()).intValue();
+		int unitSize = ((Integer)args.pop()).intValue();
+		
+		if (args.isEmpty())
+		{
+			out.error("\"x/x\" command takes exactly one parameter");
+			return;
+		}
+
+		String param = (String)args.pop();
+		if (!args.isEmpty())
+		{
+			out.error("\"x/x\" only takes one parameter");
+			return;
+		}
+		Long address;
+		
+		address = Utils.longFromStringWithPrefix(param);
+		if (null == address)
+		{
+			out.error("invalid hex address specify; address must be specified as "
+					+ "\"0x<hex_address>\"");
+			return;
+		}
+
+		out.print("\n");
+		
+		for (int index = 0; index < numUnits; index++)
+		{
+			boolean found = false;
+			Iterator itImageAddressSpace = loadedImage.getAddressSpaces().iterator();
+			long currAddr = address.longValue() + (index * unitSize);
+			
+			out.print("\t");
+			out.print(Utils.toHex(currAddr));
+			out.print(": ");
+			
+			while (itImageAddressSpace.hasNext() && !found)
+			{
+				ImageAddressSpace ias = (ImageAddressSpace)itImageAddressSpace.next();
+				ImagePointer ip = ias.getPointer(currAddr);
+				
+				byte b = 0;
+				short s = 0;
+				int i = 0;
+				long l = 0;
+				try {
+					switch (unitSize)
+					{
+					case 1:
+						b = ip.getByteAt(0);
+						break;
+					case 2:
+						s = ip.getShortAt(0);
+						break;
+					case 4:
+						i = ip.getIntAt(0);
+						break;
+					case 8:
+						l = ip.getLongAt(0);
+						break;
+					}
+					
+					found = true;
+				} catch (CorruptDataException e) {
+					found = false;
+				} catch (MemoryAccessException e) {
+					found = false;
+				}
+
+				if (found)
+				{
+					switch (unitSize)
+					{
+					case 1:
+						out.print(Utils.toFixedWidthHex(b));
+						break;
+					case 2:
+						out.print(Utils.toFixedWidthHex(s));
+						break;
+					case 4:
+						out.print(Utils.toFixedWidthHex(i));
+						break;
+					case 8:
+						out.print(Utils.toFixedWidthHex(l));
+						break;
+					}
+				}
+			}
+			
+			if (!found)
+			{
+				out.print("<address not found in any address space>");
+			}
+			out.print("\n");
+		}
+		
+		out.print("\n");
+	}
+	
+}

Propchange: incubator/kato/trunk/org.apache.kato/kato.tools.katoview/src/main/java/org/apache/kato/katoview/commands/xcommands/XXCommand.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/kato/trunk/org.apache.kato/kato.tools.katoview/src/main/java/org/apache/kato/katoview/heapdump/HeapDumpFormatter.java
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/org.apache.kato/kato.tools.katoview/src/main/java/org/apache/kato/katoview/heapdump/HeapDumpFormatter.java?rev=883384&r1=883383&r2=883384&view=diff
==============================================================================
--- incubator/kato/trunk/org.apache.kato/kato.tools.katoview/src/main/java/org/apache/kato/katoview/heapdump/HeapDumpFormatter.java (original)
+++ incubator/kato/trunk/org.apache.kato/kato.tools.katoview/src/main/java/org/apache/kato/katoview/heapdump/HeapDumpFormatter.java Mon Nov 23 15:53:48 2009
@@ -1,144 +1,144 @@
-/*******************************************************************************
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * 
- *   http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- ******************************************************************************/
-package org.apache.kato.katoview.heapdump;
-
-import java.io.IOException;
-
-/**
- * Abstract class to decouple the formatting of heapdumps from the walking of
- * the internal data structures that hold the source data.
- * 
- */
-public abstract class HeapDumpFormatter
-{
-	protected final String _version;   
-	protected final boolean _is64Bit;
-
-	/**
-	 * Constructor
-	 * 
-	 * @param version JVM version information to be included in heapdump header
-	 * @param is64Bit True if we are dumping a 64 bit image, false otherwise
-	 */
-	protected HeapDumpFormatter(String version,boolean is64Bit)
-	{
-		this._version = version;
-		this._is64Bit = is64Bit;
-	}
-
-	/**
-	 * Adds a class to the heapdump.
-	 * 
-	 * @param address
-	 *            Address of class
-	 * @param name
-	 *            Name of class
-	 * @param superClassAddress
-	 *            Address of superclass
-	 * @param size
-	 *            Size of class, bytes
-	 * @param instanceSize
-	 *            Size of objects of this class
-	 * @param hashCode
-	 *            Hashcode
-	 * @param references
-	 *            Iterator of Long addresses (some of which may be null)
-	 * @throws IOException
-	 */
-	public abstract void addClass(long address, String name,
-			long superClassAddress, int size, int instanceSize, int hashCode, ReferenceIterator references)
-			throws IOException;
-
-	/**
-	 * Adds an object to the heapdump.
-	 * 
-	 * @param address
-	 *            Address of object
-	 * @param classAddress
-	 *            Address of class of object
-	 * @param className
-	 *            Name of class of object
-	 * @param size
-	 *            Size of object, bytes
-	 * @param hashCode
-	 *            Hashcode of object
-	 * @param references
-	 *            Iterator of Long addresses (some of which may be null)
-	 * @throws IOException
-	 */
-	public abstract void addObject(long address, long classAddress,
-			String className, int size, int hashCode, ReferenceIterator references)
-			throws IOException;
-
-	/**
-	 * Adds a primitive array object to the heapdump
-	 * 
-	 * Type code is: 0 - bool, 1 - char, 2 - float, 3 - double, 4 - byte, 5 - short, 6 -
-	 * int, 7 - long
-	 * 
-	 * @param address
-	 *            Address of object
-	 * @param arrayClassAddress
-	 *           Address of primitive array class
-	 * @param type
-	 *            Type code - see above
-	 * @param size
-	 *            Size of object, bytes.
-	 * @param hashCode
-	 *            Hashcode of object
-	 * @param numberOfElements
-	 *            Number of elements in the array
-	 * @throws IOException
-	 * @throws IllegalArgumentException
-	 *             if invalid type is supplied
-	 */
-	public abstract void addPrimitiveArray(long address, long arrayClassAddress, int type, int size,
-			int hashCode, int numberOfElements) throws IOException,
-			IllegalArgumentException;
-
-	/**
-	 * Adds an object array to the heapdump.
-	 * 
-	 * @param address
-	 *            Address of object
-	 * @param arrayClassAddress
-	 *            Address of class of array object
-	 * @param arrayClassName
-	 *            Name of class of array object
-	 * @param elementClassAddress
-	 *            Address of class of elements
-	 * @param elementClassName
-	 *            Name of class of elements
-	 * @param size
-	 *            Size of object, bytes
-	 * @param numberOfElements
-	 *            number of elements in the array
-	 * @param hashCode
-	 *            Hashcode of object
-	 * @param references
-	 *            Iterator of Long addresses (some of which may be null)
-	 * @throws IOException
-	 */
-	public abstract void addObjectArray(long address, long arrayClassAddress,
-			String arrayClassName, long elementClassAddress,
-			String elementClassName, int size, int numberOfElements,
-			int hashCode, ReferenceIterator references) throws IOException;
-	
-	/**
-	 * Closes the heapdump
-	 * 
-	 * @throws IOException
-	 */
-	public abstract void close() throws IOException;
-}
+/*******************************************************************************
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+package org.apache.kato.katoview.heapdump;
+
+import java.io.IOException;
+
+/**
+ * Abstract class to decouple the formatting of heapdumps from the walking of
+ * the internal data structures that hold the source data.
+ * 
+ */
+public abstract class HeapDumpFormatter
+{
+	protected final String _version;   
+	protected final boolean _is64Bit;
+
+	/**
+	 * Constructor
+	 * 
+	 * @param version JVM version information to be included in heapdump header
+	 * @param is64Bit True if we are dumping a 64 bit image, false otherwise
+	 */
+	protected HeapDumpFormatter(String version,boolean is64Bit)
+	{
+		this._version = version;
+		this._is64Bit = is64Bit;
+	}
+
+	/**
+	 * Adds a class to the heapdump.
+	 * 
+	 * @param address
+	 *            Address of class
+	 * @param name
+	 *            Name of class
+	 * @param superClassAddress
+	 *            Address of superclass
+	 * @param size
+	 *            Size of class, bytes
+	 * @param instanceSize
+	 *            Size of objects of this class
+	 * @param hashCode
+	 *            Hashcode
+	 * @param references
+	 *            Iterator of Long addresses (some of which may be null)
+	 * @throws IOException
+	 */
+	public abstract void addClass(long address, String name,
+			long superClassAddress, int size, int instanceSize, int hashCode, ReferenceIterator references)
+			throws IOException;
+
+	/**
+	 * Adds an object to the heapdump.
+	 * 
+	 * @param address
+	 *            Address of object
+	 * @param classAddress
+	 *            Address of class of object
+	 * @param className
+	 *            Name of class of object
+	 * @param size
+	 *            Size of object, bytes
+	 * @param hashCode
+	 *            Hashcode of object
+	 * @param references
+	 *            Iterator of Long addresses (some of which may be null)
+	 * @throws IOException
+	 */
+	public abstract void addObject(long address, long classAddress,
+			String className, int size, int hashCode, ReferenceIterator references)
+			throws IOException;
+
+	/**
+	 * Adds a primitive array object to the heapdump
+	 * 
+	 * Type code is: 0 - bool, 1 - char, 2 - float, 3 - double, 4 - byte, 5 - short, 6 -
+	 * int, 7 - long
+	 * 
+	 * @param address
+	 *            Address of object
+	 * @param arrayClassAddress
+	 *           Address of primitive array class
+	 * @param type
+	 *            Type code - see above
+	 * @param size
+	 *            Size of object, bytes.
+	 * @param hashCode
+	 *            Hashcode of object
+	 * @param numberOfElements
+	 *            Number of elements in the array
+	 * @throws IOException
+	 * @throws IllegalArgumentException
+	 *             if invalid type is supplied
+	 */
+	public abstract void addPrimitiveArray(long address, long arrayClassAddress, int type, int size,
+			int hashCode, int numberOfElements) throws IOException,
+			IllegalArgumentException;
+
+	/**
+	 * Adds an object array to the heapdump.
+	 * 
+	 * @param address
+	 *            Address of object
+	 * @param arrayClassAddress
+	 *            Address of class of array object
+	 * @param arrayClassName
+	 *            Name of class of array object
+	 * @param elementClassAddress
+	 *            Address of class of elements
+	 * @param elementClassName
+	 *            Name of class of elements
+	 * @param size
+	 *            Size of object, bytes
+	 * @param numberOfElements
+	 *            number of elements in the array
+	 * @param hashCode
+	 *            Hashcode of object
+	 * @param references
+	 *            Iterator of Long addresses (some of which may be null)
+	 * @throws IOException
+	 */
+	public abstract void addObjectArray(long address, long arrayClassAddress,
+			String arrayClassName, long elementClassAddress,
+			String elementClassName, int size, int numberOfElements,
+			int hashCode, ReferenceIterator references) throws IOException;
+	
+	/**
+	 * Closes the heapdump
+	 * 
+	 * @throws IOException
+	 */
+	public abstract void close() throws IOException;
+}

Propchange: incubator/kato/trunk/org.apache.kato/kato.tools.katoview/src/main/java/org/apache/kato/katoview/heapdump/HeapDumpFormatter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/kato/trunk/org.apache.kato/kato.tools.katoview/src/main/java/org/apache/kato/katoview/heapdump/HeapDumpSettings.java
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/org.apache.kato/kato.tools.katoview/src/main/java/org/apache/kato/katoview/heapdump/HeapDumpSettings.java?rev=883384&r1=883383&r2=883384&view=diff
==============================================================================
--- incubator/kato/trunk/org.apache.kato/kato.tools.katoview/src/main/java/org/apache/kato/katoview/heapdump/HeapDumpSettings.java (original)
+++ incubator/kato/trunk/org.apache.kato/kato.tools.katoview/src/main/java/org/apache/kato/katoview/heapdump/HeapDumpSettings.java Mon Nov 23 15:53:48 2009
@@ -1,105 +1,105 @@
-/*******************************************************************************
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * 
- *   http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- ******************************************************************************/
-package org.apache.kato.katoview.heapdump;
-
-import java.util.Map;
-
-import org.apache.kato.katoview.Session;
-
-
-/**
- * Encapsulates the marshalling and unmarshalling of heapdump
- * settings through the properties map.
- * 
- */
-public class HeapDumpSettings
-{
-	public static final String HEAP_DUMP_FILE_PROPERTY = "heap_dump_file";
-	public static final String HEAP_DUMP_FORMAT_PROPERTY = "heap_dump_format"; 
-	public static final String MULTIPLE_HEAPS_MULTIPLE_FILES_PROPERTY = "heap_dump_multiple_heaps_multiple_files";
-	
-	public static void setFileName(String fileName,Map properties) 
-	{
-		properties.put(HEAP_DUMP_FILE_PROPERTY, fileName);
-	}
-	
-	/**
-	 * Returns the filename to use for writing out a heap dump, either based
-	 * on what the user has set or by generating the default name based on the 
-	 * image name
-	 */
-	public static String getFileName(Map properties)
-	{
-		String propertyFileName = (String) properties.get(HEAP_DUMP_FILE_PROPERTY);
-		
-		if(propertyFileName != null) {
-			return propertyFileName;
-		} else {
-			return getDefaultHeapDumpFileName(properties);
-		}
-	}
-	
-	private static String getDefaultHeapDumpFileName(Map properties)
-	{
-		String baseFileName = (String) properties.get(Session.DUMP_FILE_PATH_PROPERTY);
-		
-		if(areHeapDumpsPHD(properties)) {
-			return baseFileName + ".phd";
-		} else {
-			return baseFileName + ".txt";
-		}
-	}
-	
-	public static void setClassicHeapDumps(Map properties)
-	{
-		properties.put(HEAP_DUMP_FORMAT_PROPERTY, "classic");
-	}
-	
-	public static boolean areHeapDumpsPHD(Map properties) 
-	{
-		Object formatValue = properties.get(HEAP_DUMP_FORMAT_PROPERTY);
-		
-		if(formatValue != null && formatValue.equals("classic")) {
-			return false;
-		} else {
-			return true;
-		}
-	}
-	
-	public static void setPHDHeapDumps(Map properties)
-	{
-		properties.put(HEAP_DUMP_FORMAT_PROPERTY, "phd");
-	}
-
-	public static void setMultipleHeapsMultipleFiles(Map properties)
-	{
-		properties.put(MULTIPLE_HEAPS_MULTIPLE_FILES_PROPERTY, "true");
-	}
-	
-	public static void setMultipleHeapsSingleFile(Map properties)
-	{
-		properties.put(MULTIPLE_HEAPS_MULTIPLE_FILES_PROPERTY, "false");
-	}
-	
-	public static boolean multipleHeapsInMultipleFiles(Map properties)
-	{
-		Object multipleFilesValue = properties.get(MULTIPLE_HEAPS_MULTIPLE_FILES_PROPERTY);
-		
-		if(multipleFilesValue == null) {
-			return false;
-		} else {
-			return multipleFilesValue.equals("true");
-		}
-	}
-}
+/*******************************************************************************
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+package org.apache.kato.katoview.heapdump;
+
+import java.util.Map;
+
+import org.apache.kato.katoview.Session;
+
+
+/**
+ * Encapsulates the marshalling and unmarshalling of heapdump
+ * settings through the properties map.
+ * 
+ */
+public class HeapDumpSettings
+{
+	public static final String HEAP_DUMP_FILE_PROPERTY = "heap_dump_file";
+	public static final String HEAP_DUMP_FORMAT_PROPERTY = "heap_dump_format"; 
+	public static final String MULTIPLE_HEAPS_MULTIPLE_FILES_PROPERTY = "heap_dump_multiple_heaps_multiple_files";
+	
+	public static void setFileName(String fileName,Map properties) 
+	{
+		properties.put(HEAP_DUMP_FILE_PROPERTY, fileName);
+	}
+	
+	/**
+	 * Returns the filename to use for writing out a heap dump, either based
+	 * on what the user has set or by generating the default name based on the 
+	 * image name
+	 */
+	public static String getFileName(Map properties)
+	{
+		String propertyFileName = (String) properties.get(HEAP_DUMP_FILE_PROPERTY);
+		
+		if(propertyFileName != null) {
+			return propertyFileName;
+		} else {
+			return getDefaultHeapDumpFileName(properties);
+		}
+	}
+	
+	private static String getDefaultHeapDumpFileName(Map properties)
+	{
+		String baseFileName = (String) properties.get(Session.DUMP_FILE_PATH_PROPERTY);
+		
+		if(areHeapDumpsPHD(properties)) {
+			return baseFileName + ".phd";
+		} else {
+			return baseFileName + ".txt";
+		}
+	}
+	
+	public static void setClassicHeapDumps(Map properties)
+	{
+		properties.put(HEAP_DUMP_FORMAT_PROPERTY, "classic");
+	}
+	
+	public static boolean areHeapDumpsPHD(Map properties) 
+	{
+		Object formatValue = properties.get(HEAP_DUMP_FORMAT_PROPERTY);
+		
+		if(formatValue != null && formatValue.equals("classic")) {
+			return false;
+		} else {
+			return true;
+		}
+	}
+	
+	public static void setPHDHeapDumps(Map properties)
+	{
+		properties.put(HEAP_DUMP_FORMAT_PROPERTY, "phd");
+	}
+
+	public static void setMultipleHeapsMultipleFiles(Map properties)
+	{
+		properties.put(MULTIPLE_HEAPS_MULTIPLE_FILES_PROPERTY, "true");
+	}
+	
+	public static void setMultipleHeapsSingleFile(Map properties)
+	{
+		properties.put(MULTIPLE_HEAPS_MULTIPLE_FILES_PROPERTY, "false");
+	}
+	
+	public static boolean multipleHeapsInMultipleFiles(Map properties)
+	{
+		Object multipleFilesValue = properties.get(MULTIPLE_HEAPS_MULTIPLE_FILES_PROPERTY);
+		
+		if(multipleFilesValue == null) {
+			return false;
+		} else {
+			return multipleFilesValue.equals("true");
+		}
+	}
+}

Propchange: incubator/kato/trunk/org.apache.kato/kato.tools.katoview/src/main/java/org/apache/kato/katoview/heapdump/HeapDumpSettings.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/kato/trunk/org.apache.kato/kato.tools.katoview/src/main/java/org/apache/kato/katoview/heapdump/LongArrayReferenceIterator.java
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/org.apache.kato/kato.tools.katoview/src/main/java/org/apache/kato/katoview/heapdump/LongArrayReferenceIterator.java?rev=883384&r1=883383&r2=883384&view=diff
==============================================================================
--- incubator/kato/trunk/org.apache.kato/kato.tools.katoview/src/main/java/org/apache/kato/katoview/heapdump/LongArrayReferenceIterator.java (original)
+++ incubator/kato/trunk/org.apache.kato/kato.tools.katoview/src/main/java/org/apache/kato/katoview/heapdump/LongArrayReferenceIterator.java Mon Nov 23 15:53:48 2009
@@ -1,49 +1,49 @@
-/*******************************************************************************
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * 
- *   http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- ******************************************************************************/
-package org.apache.kato.katoview.heapdump;
-
-
-public class LongArrayReferenceIterator implements ReferenceIterator 
-{
-	private final long _fields[];
-	private int _index = 0;
-	
-	public LongArrayReferenceIterator(long[] fields) {
-		if(fields != null) {
-			_fields = fields;
-		} else {
-			_fields = new long[0];
-		}
-	}
-	
-	public boolean hasNext()
-	{
-		return _index < (_fields.length);
-	}
-
-	public Long next()
-	{
-		Long toReturn = new Long(_fields[_index]);
-		
-		_index++;
-		
-		return toReturn;
-	}
-
-	public void reset()
-	{
-		_index = 0;
-	}
-	
-}
+/*******************************************************************************
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+package org.apache.kato.katoview.heapdump;
+
+
+public class LongArrayReferenceIterator implements ReferenceIterator 
+{
+	private final long _fields[];
+	private int _index = 0;
+	
+	public LongArrayReferenceIterator(long[] fields) {
+		if(fields != null) {
+			_fields = fields;
+		} else {
+			_fields = new long[0];
+		}
+	}
+	
+	public boolean hasNext()
+	{
+		return _index < (_fields.length);
+	}
+
+	public Long next()
+	{
+		Long toReturn = new Long(_fields[_index]);
+		
+		_index++;
+		
+		return toReturn;
+	}
+
+	public void reset()
+	{
+		_index = 0;
+	}
+	
+}

Propchange: incubator/kato/trunk/org.apache.kato/kato.tools.katoview/src/main/java/org/apache/kato/katoview/heapdump/LongArrayReferenceIterator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/kato/trunk/org.apache.kato/kato.tools.katoview/src/main/java/org/apache/kato/katoview/heapdump/LongListReferenceIterator.java
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/org.apache.kato/kato.tools.katoview/src/main/java/org/apache/kato/katoview/heapdump/LongListReferenceIterator.java?rev=883384&r1=883383&r2=883384&view=diff
==============================================================================
--- incubator/kato/trunk/org.apache.kato/kato.tools.katoview/src/main/java/org/apache/kato/katoview/heapdump/LongListReferenceIterator.java (original)
+++ incubator/kato/trunk/org.apache.kato/kato.tools.katoview/src/main/java/org/apache/kato/katoview/heapdump/LongListReferenceIterator.java Mon Nov 23 15:53:48 2009
@@ -1,50 +1,50 @@
-/*******************************************************************************
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * 
- *   http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- ******************************************************************************/
-package org.apache.kato.katoview.heapdump;
-
-import java.util.Iterator;
-import java.util.List;
-
-
-/**
- * Reference iterator based on a list of Longs.
- * 
- */
-public class LongListReferenceIterator implements ReferenceIterator
-{
-	private final List _data;
-	private Iterator _currentIterator;
-	
-	public LongListReferenceIterator(List data) 
-	{
-		_data = data;
-		reset();
-	}
-	
-	public boolean hasNext()
-	{
-		return _currentIterator.hasNext();
-	}
-
-	public Long next()
-	{
-		return (Long) _currentIterator.next();
-	}
-
-	public void reset()
-	{
-		_currentIterator = _data.iterator();
-	}
-	
-}
+/*******************************************************************************
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+package org.apache.kato.katoview.heapdump;
+
+import java.util.Iterator;
+import java.util.List;
+
+
+/**
+ * Reference iterator based on a list of Longs.
+ * 
+ */
+public class LongListReferenceIterator implements ReferenceIterator
+{
+	private final List _data;
+	private Iterator _currentIterator;
+	
+	public LongListReferenceIterator(List data) 
+	{
+		_data = data;
+		reset();
+	}
+	
+	public boolean hasNext()
+	{
+		return _currentIterator.hasNext();
+	}
+
+	public Long next()
+	{
+		return (Long) _currentIterator.next();
+	}
+
+	public void reset()
+	{
+		_currentIterator = _data.iterator();
+	}
+	
+}

Propchange: incubator/kato/trunk/org.apache.kato/kato.tools.katoview/src/main/java/org/apache/kato/katoview/heapdump/LongListReferenceIterator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/kato/trunk/org.apache.kato/kato.tools.katoview/src/main/java/org/apache/kato/katoview/heapdump/ReferenceIterator.java
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/org.apache.kato/kato.tools.katoview/src/main/java/org/apache/kato/katoview/heapdump/ReferenceIterator.java?rev=883384&r1=883383&r2=883384&view=diff
==============================================================================
--- incubator/kato/trunk/org.apache.kato/kato.tools.katoview/src/main/java/org/apache/kato/katoview/heapdump/ReferenceIterator.java (original)
+++ incubator/kato/trunk/org.apache.kato/kato.tools.katoview/src/main/java/org/apache/kato/katoview/heapdump/ReferenceIterator.java Mon Nov 23 15:53:48 2009
@@ -1,42 +1,42 @@
-/*******************************************************************************
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * 
- *   http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- ******************************************************************************/
-package org.apache.kato.katoview.heapdump;
-
-/**
- * Type-safe, resettable iterator for references.
- * 
- */
-public interface ReferenceIterator
-{
-
-	/**
-	 * 
-	 * @return True if next() will return non-null,
-	 * false otherwise.
-	 */
-	public boolean hasNext();
-	
-	/**
-	 * 
-	 * @return Next reference
-	 */
-	public Long next();
-	
-	/**
-	 * Resets the iterator back to the start of the 
-	 * structure it is iterating. Iterator will behave
-	 * as if it has just been constructed
-	 */
-	public void reset();
-}
+/*******************************************************************************
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+package org.apache.kato.katoview.heapdump;
+
+/**
+ * Type-safe, resettable iterator for references.
+ * 
+ */
+public interface ReferenceIterator
+{
+
+	/**
+	 * 
+	 * @return True if next() will return non-null,
+	 * false otherwise.
+	 */
+	public boolean hasNext();
+	
+	/**
+	 * 
+	 * @return Next reference
+	 */
+	public Long next();
+	
+	/**
+	 * Resets the iterator back to the start of the 
+	 * structure it is iterating. Iterator will behave
+	 * as if it has just been constructed
+	 */
+	public void reset();
+}

Propchange: incubator/kato/trunk/org.apache.kato/kato.tools.katoview/src/main/java/org/apache/kato/katoview/heapdump/ReferenceIterator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/kato/trunk/org.apache.kato/kato.tools.katoview/src/main/java/org/apache/kato/katoview/heapdump/classic/ClassicHeapDumpFormatter.java
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/org.apache.kato/kato.tools.katoview/src/main/java/org/apache/kato/katoview/heapdump/classic/ClassicHeapDumpFormatter.java?rev=883384&r1=883383&r2=883384&view=diff
==============================================================================
--- incubator/kato/trunk/org.apache.kato/kato.tools.katoview/src/main/java/org/apache/kato/katoview/heapdump/classic/ClassicHeapDumpFormatter.java (original)
+++ incubator/kato/trunk/org.apache.kato/kato.tools.katoview/src/main/java/org/apache/kato/katoview/heapdump/classic/ClassicHeapDumpFormatter.java Mon Nov 23 15:53:48 2009
@@ -1,283 +1,283 @@
-/*******************************************************************************
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * 
- *   http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- ******************************************************************************/
-package org.apache.kato.katoview.heapdump.classic;
-
-import java.io.BufferedWriter;
-import java.io.IOException;
-import java.io.Writer;
-
-import org.apache.kato.katoview.heapdump.HeapDumpFormatter;
-import org.apache.kato.katoview.heapdump.LongArrayReferenceIterator;
-import org.apache.kato.katoview.heapdump.ReferenceIterator;
-
-
-/**
- * A formatter for classic heap dumps.
- * 
- * Format specification is in the diagnostic guide.
- * 
- */
-public class ClassicHeapDumpFormatter extends HeapDumpFormatter
-{
-	private static final String EOF_HEADER = "// EOF: Total 'Objects',Refs(null) :";
-	private static final String BREAKDOWN_HEADER = "// Breakdown - Classes:";
-	private static final String VERSION_HEADER = "// Version: ";
-	
-	// Using a BufferedWriter rather than a PrintWriter because a BufferedWriter preserves IOExceptions while providing newLine().
-	private final BufferedWriter _out;
-	private int _classCount = 0;
-	//This includes objects + objectArrays + primitiveArrays + classes
-	private int _allObjectCount = 0;
-	private int _objectArraysCount = 0;
-	private int _primitiveArraysCount = 0;
-	private int _referenceCount = 0;
-	private int _nullReferenceCount = 0;
-	private boolean _closed = false;
-	
-	public ClassicHeapDumpFormatter(Writer out,String version,boolean is64bit) throws IOException
-	{
-		super(version,is64bit);
-		_out = new BufferedWriter(out);
-		
-		writeHeader();
-	}
-	
-	private void writeHeader() throws IOException
-	{
-		_out.write(VERSION_HEADER + _version);
-		_out.newLine();
-	}
-
-	private void writeReferences(ReferenceIterator references) throws IOException
-	{
-		if(references == null) {
-			return;
-		}
-		references.reset();
-		if(! references.hasNext()) {
-			return;
-		}
-		
-		StringBuffer referenceString = new StringBuffer();
-		
-		boolean first = true;
-		
-		while(references.hasNext()) {
-			Long thisRef = references.next();
-			
-			if(first) {
-				first = false;
-			} else {
-				referenceString.append(" ");
-			}
-			
-			referenceString.append(toHexString(thisRef.longValue()));
-			
-			_referenceCount++;
-			if(thisRef.longValue() == 0) {
-				_nullReferenceCount++;
-			}
-		}
-		
-		_out.write(referenceString.toString());
-		_out.newLine();
-	}
-	
-	private static String toHexString(long value)
-	{
-		//Fast-path for 0
-		if(value == 0) {
-			return "0x0";
-		}
-		
-		return "0x" + Long.toHexString(value);
-	}
-	
-	public void addClass(long address, String name, long superClassAddress,
-			int size, int instanceSize, int hashCode, ReferenceIterator references)
-			throws IOException
-	{
-		checkClosed();
-		
-		_out.write(toHexString(address) + " [" + size + "] CLS " + name);
-		_out.newLine();
-		
-		writeReferences(references);
-		
-		_classCount++;
-		_allObjectCount++;
-	}
-
-	private void checkClosed()
-	{
-		if(_closed) {
-			throw new UnsupportedOperationException("This dump has been closed");
-		}
-	}
-
-	private void writeEntry(long address,int size,String className,ReferenceIterator references) throws IOException
-	{
-		_out.write(toHexString(address) + " [" + size + "] OBJ " + className);
-		_out.newLine();
-
-		writeReferences(references);
-		
-		_allObjectCount++;
-	}
-	
-	public void addObject(long address, long classAddress, String className,
-			int size, int hashCode, ReferenceIterator references)
-			throws IOException
-	{
-		checkClosed();
-		
-		//Add an artificial link between the object and its class
-		references = addReference(references,classAddress);
-		
-		writeEntry(address,size,className,references);
-	}
-
-	/**
-	 * Wraps the original reference iterator to add an artificial reference to the list.
-	 */
-	private static ReferenceIterator addReference(final ReferenceIterator original,
-			final long extra)
-	{   
-		return new ReferenceIterator(){
-
-			private boolean _returnedExtra = false;
-			
-			public boolean hasNext()
-			{
-				if(_returnedExtra) {
-					return original.hasNext();
-				} else {
-					return true;
-				}
-			}
-
-			public Long next()
-			{
-				if(_returnedExtra) {
-					return original.next();
-				} else {
-					_returnedExtra = true;
-					return new Long(extra);
-				}
-			}
-
-			public void reset()
-			{
-				original.reset();
-				_returnedExtra = false;
-			}};
-	}
-
-	public void addObjectArray(long address, long arrayClassAddress,
-			String arrayClassName, long elementClassAddress,
-			String elementClassName, int size, int numberOfElements,
-			int hashCode, ReferenceIterator references) throws IOException
-	{
-		checkClosed();
-		
-		writeEntry(address,size,arrayClassName,references);
-		
-		_objectArraysCount++;
-	}
-
-	public void addPrimitiveArray(long address, long arrayClassAddress, int type, int size,
-			int hashCode, int numberOfElements) throws IOException,
-			IllegalArgumentException
-	{
-		checkClosed();
-		
-		//Add an artificial reference to the object class:
-		ReferenceIterator references = new LongArrayReferenceIterator(new long[]{arrayClassAddress});
-		
-		writeEntry(address,size,getPrimitiveArrayName(type),references);
-		
-		_primitiveArraysCount++;
-	}
-
-	private String getPrimitiveArrayName(int type)
-	{
-		switch(type) {
-		case 0:
-			return "[Z";
-		case 1:
-			return "[C";
-		case 2:
-			return "[F";
-		case 3:
-			return "[D";
-		case 4:
-			return "[B";
-		case 5:
-			return "[S";
-		case 6:
-			return "[I";
-		case 7:
-			return "[J";
-		default:
-			throw new IllegalArgumentException("Unknown primitive type code: " + type);
-		}
-	}
-
-	public void close() throws IOException
-	{        
-		printBreakdown();
-		
-		printEOFSummary();
-		
-		_out.close();
-		
-		_closed = true;
-	}
-
-	private void printEOFSummary() throws IOException
-	{
-		StringBuffer buffer = new StringBuffer(EOF_HEADER);
-		
-		buffer.append(_allObjectCount);
-		buffer.append(",");
-		buffer.append(_referenceCount);
-		buffer.append("(");
-		buffer.append(_nullReferenceCount);
-		buffer.append(")");
-		
-		_out.write(buffer.toString());
-		_out.newLine();
-	}
-
-	private void printBreakdown() throws IOException
-	{
-		int objectsCount = ((_allObjectCount - _primitiveArraysCount) - _objectArraysCount) - _classCount;
-		
-		StringBuffer buffer = new StringBuffer(BREAKDOWN_HEADER);
-		buffer.append(_classCount);
-		
-		buffer.append(", Objects:");
-		buffer.append(objectsCount);
-		
-		buffer.append(", ObjectArrays:");
-		buffer.append(_objectArraysCount);
-		
-		buffer.append(", PrimitiveArrays:");
-		buffer.append(_primitiveArraysCount);
-		
-		_out.write(buffer.toString());
-		_out.newLine();
-	}
-
-}
+/*******************************************************************************
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+package org.apache.kato.katoview.heapdump.classic;
+
+import java.io.BufferedWriter;
+import java.io.IOException;
+import java.io.Writer;
+
+import org.apache.kato.katoview.heapdump.HeapDumpFormatter;
+import org.apache.kato.katoview.heapdump.LongArrayReferenceIterator;
+import org.apache.kato.katoview.heapdump.ReferenceIterator;
+
+
+/**
+ * A formatter for classic heap dumps.
+ * 
+ * Format specification is in the diagnostic guide.
+ * 
+ */
+public class ClassicHeapDumpFormatter extends HeapDumpFormatter
+{
+	private static final String EOF_HEADER = "// EOF: Total 'Objects',Refs(null) :";
+	private static final String BREAKDOWN_HEADER = "// Breakdown - Classes:";
+	private static final String VERSION_HEADER = "// Version: ";
+	
+	// Using a BufferedWriter rather than a PrintWriter because a BufferedWriter preserves IOExceptions while providing newLine().
+	private final BufferedWriter _out;
+	private int _classCount = 0;
+	//This includes objects + objectArrays + primitiveArrays + classes
+	private int _allObjectCount = 0;
+	private int _objectArraysCount = 0;
+	private int _primitiveArraysCount = 0;
+	private int _referenceCount = 0;
+	private int _nullReferenceCount = 0;
+	private boolean _closed = false;
+	
+	public ClassicHeapDumpFormatter(Writer out,String version,boolean is64bit) throws IOException
+	{
+		super(version,is64bit);
+		_out = new BufferedWriter(out);
+		
+		writeHeader();
+	}
+	
+	private void writeHeader() throws IOException
+	{
+		_out.write(VERSION_HEADER + _version);
+		_out.newLine();
+	}
+
+	private void writeReferences(ReferenceIterator references) throws IOException
+	{
+		if(references == null) {
+			return;
+		}
+		references.reset();
+		if(! references.hasNext()) {
+			return;
+		}
+		
+		StringBuffer referenceString = new StringBuffer();
+		
+		boolean first = true;
+		
+		while(references.hasNext()) {
+			Long thisRef = references.next();
+			
+			if(first) {
+				first = false;
+			} else {
+				referenceString.append(" ");
+			}
+			
+			referenceString.append(toHexString(thisRef.longValue()));
+			
+			_referenceCount++;
+			if(thisRef.longValue() == 0) {
+				_nullReferenceCount++;
+			}
+		}
+		
+		_out.write(referenceString.toString());
+		_out.newLine();
+	}
+	
+	private static String toHexString(long value)
+	{
+		//Fast-path for 0
+		if(value == 0) {
+			return "0x0";
+		}
+		
+		return "0x" + Long.toHexString(value);
+	}
+	
+	public void addClass(long address, String name, long superClassAddress,
+			int size, int instanceSize, int hashCode, ReferenceIterator references)
+			throws IOException
+	{
+		checkClosed();
+		
+		_out.write(toHexString(address) + " [" + size + "] CLS " + name);
+		_out.newLine();
+		
+		writeReferences(references);
+		
+		_classCount++;
+		_allObjectCount++;
+	}
+
+	private void checkClosed()
+	{
+		if(_closed) {
+			throw new UnsupportedOperationException("This dump has been closed");
+		}
+	}
+
+	private void writeEntry(long address,int size,String className,ReferenceIterator references) throws IOException
+	{
+		_out.write(toHexString(address) + " [" + size + "] OBJ " + className);
+		_out.newLine();
+
+		writeReferences(references);
+		
+		_allObjectCount++;
+	}
+	
+	public void addObject(long address, long classAddress, String className,
+			int size, int hashCode, ReferenceIterator references)
+			throws IOException
+	{
+		checkClosed();
+		
+		//Add an artificial link between the object and its class
+		references = addReference(references,classAddress);
+		
+		writeEntry(address,size,className,references);
+	}
+
+	/**
+	 * Wraps the original reference iterator to add an artificial reference to the list.
+	 */
+	private static ReferenceIterator addReference(final ReferenceIterator original,
+			final long extra)
+	{   
+		return new ReferenceIterator(){
+
+			private boolean _returnedExtra = false;
+			
+			public boolean hasNext()
+			{
+				if(_returnedExtra) {
+					return original.hasNext();
+				} else {
+					return true;
+				}
+			}
+
+			public Long next()
+			{
+				if(_returnedExtra) {
+					return original.next();
+				} else {
+					_returnedExtra = true;
+					return new Long(extra);
+				}
+			}
+
+			public void reset()
+			{
+				original.reset();
+				_returnedExtra = false;
+			}};
+	}
+
+	public void addObjectArray(long address, long arrayClassAddress,
+			String arrayClassName, long elementClassAddress,
+			String elementClassName, int size, int numberOfElements,
+			int hashCode, ReferenceIterator references) throws IOException
+	{
+		checkClosed();
+		
+		writeEntry(address,size,arrayClassName,references);
+		
+		_objectArraysCount++;
+	}
+
+	public void addPrimitiveArray(long address, long arrayClassAddress, int type, int size,
+			int hashCode, int numberOfElements) throws IOException,
+			IllegalArgumentException
+	{
+		checkClosed();
+		
+		//Add an artificial reference to the object class:
+		ReferenceIterator references = new LongArrayReferenceIterator(new long[]{arrayClassAddress});
+		
+		writeEntry(address,size,getPrimitiveArrayName(type),references);
+		
+		_primitiveArraysCount++;
+	}
+
+	private String getPrimitiveArrayName(int type)
+	{
+		switch(type) {
+		case 0:
+			return "[Z";
+		case 1:
+			return "[C";
+		case 2:
+			return "[F";
+		case 3:
+			return "[D";
+		case 4:
+			return "[B";
+		case 5:
+			return "[S";
+		case 6:
+			return "[I";
+		case 7:
+			return "[J";
+		default:
+			throw new IllegalArgumentException("Unknown primitive type code: " + type);
+		}
+	}
+
+	public void close() throws IOException
+	{        
+		printBreakdown();
+		
+		printEOFSummary();
+		
+		_out.close();
+		
+		_closed = true;
+	}
+
+	private void printEOFSummary() throws IOException
+	{
+		StringBuffer buffer = new StringBuffer(EOF_HEADER);
+		
+		buffer.append(_allObjectCount);
+		buffer.append(",");
+		buffer.append(_referenceCount);
+		buffer.append("(");
+		buffer.append(_nullReferenceCount);
+		buffer.append(")");
+		
+		_out.write(buffer.toString());
+		_out.newLine();
+	}
+
+	private void printBreakdown() throws IOException
+	{
+		int objectsCount = ((_allObjectCount - _primitiveArraysCount) - _objectArraysCount) - _classCount;
+		
+		StringBuffer buffer = new StringBuffer(BREAKDOWN_HEADER);
+		buffer.append(_classCount);
+		
+		buffer.append(", Objects:");
+		buffer.append(objectsCount);
+		
+		buffer.append(", ObjectArrays:");
+		buffer.append(_objectArraysCount);
+		
+		buffer.append(", PrimitiveArrays:");
+		buffer.append(_primitiveArraysCount);
+		
+		_out.write(buffer.toString());
+		_out.newLine();
+	}
+
+}

Propchange: incubator/kato/trunk/org.apache.kato/kato.tools.katoview/src/main/java/org/apache/kato/katoview/heapdump/classic/ClassicHeapDumpFormatter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/kato/trunk/org.apache.kato/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message