Java Code Examples for sun.jvm.hotspot.debugger.Address#getAddressAt()
The following examples show how to use
sun.jvm.hotspot.debugger.Address#getAddressAt() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GenericArray.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
protected Address getAddressAt(int index) { if (index < 0 || index >= length()) throw new ArrayIndexOutOfBoundsException(index); Type elemType = getElemType(); if (getElemType().isCIntegerType()) throw new RuntimeException("elemType must not be of CInteger type"); Address data = getAddress().addOffsetTo(dataFieldOffset); long elemSize = elemType.getSize(); return data.getAddressAt(index * elemSize); }
Example 2
Source File: GenericArray.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
protected Address getAddressAt(int index) { if (index < 0 || index >= length()) throw new ArrayIndexOutOfBoundsException(index); Type elemType = getElemType(); if (getElemType().isCIntegerType()) throw new RuntimeException("elemType must not be of CInteger type"); Address data = getAddress().addOffsetTo(dataFieldOffset); long elemSize = elemType.getSize(); return data.getAddressAt(index * elemSize); }
Example 3
Source File: G1HeapRegionTable.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
private HeapRegion at(long index) { Address arrayAddr = baseField.getValue(addr); // Offset of &_base[index] long offset = index * VM.getVM().getAddressSize(); Address regionAddr = arrayAddr.getAddressAt(offset); return (HeapRegion) VMObjectFactory.newObject(HeapRegion.class, regionAddr); }
Example 4
Source File: GenericArray.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
protected Address getAddressAt(int index) { if (index < 0 || index >= length()) throw new ArrayIndexOutOfBoundsException(index); Type elemType = getElemType(); if (getElemType().isCIntegerType()) throw new RuntimeException("elemType must not be of CInteger type"); Address data = getAddress().addOffsetTo(dataFieldOffset); long elemSize = elemType.getSize(); return data.getAddressAt(index * elemSize); }
Example 5
Source File: GenericArray.java From hottub with GNU General Public License v2.0 | 5 votes |
protected Address getAddressAt(int index) { if (index < 0 || index >= length()) throw new ArrayIndexOutOfBoundsException(index); Type elemType = getElemType(); if (getElemType().isCIntegerType()) throw new RuntimeException("elemType must not be of CInteger type"); Address data = getAddress().addOffsetTo(dataFieldOffset); long elemSize = elemType.getSize(); return data.getAddressAt(index * elemSize); }
Example 6
Source File: G1HeapRegionTable.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
private HeapRegion at(long index) { Address arrayAddr = baseField.getValue(addr); // Offset of &_base[index] long offset = index * VM.getVM().getAddressSize(); Address regionAddr = arrayAddr.getAddressAt(offset); return (HeapRegion) VMObjectFactory.newObject(HeapRegion.class, regionAddr); }
Example 7
Source File: GenericArray.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
protected Address getAddressAt(int index) { if (index < 0 || index >= length()) throw new ArrayIndexOutOfBoundsException(index); Type elemType = getElemType(); if (getElemType().isCIntegerType()) throw new RuntimeException("elemType must not be of CInteger type"); Address data = getAddress().addOffsetTo(dataFieldOffset); long elemSize = elemType.getSize(); return data.getAddressAt(index * elemSize); }
Example 8
Source File: BasicTypeDataBase.java From openjdk-jdk8u with GNU General Public License v2.0 | 4 votes |
public Type findDynamicTypeForAddress(Address addr, Type baseType) { // This implementation should be suitably platform-independent; we // search nearby memory for the vtbl value of the given type. if (vtblForType(baseType) == null) { // Type was not polymorphic which is an error of some sort throw new InternalError(baseType + " does not appear to be polymorphic"); } // This is a more restricted version of guessTypeForAddress since // that function has some limitations since it doesn't really know // where in the hierarchy a virtual type starts and just poking // around in memory is likely to trip over some vtable address, // resulting in false positives. Eventually all uses should // switch to this logic but in the interests of stability it will // be separate for the moment. // Assuming that the base type is truly the first polymorphic type // then the vtbl for all subclasss should be at several defined // locations so only those locations will be checked. It's also // required that the caller knows that the static type is at least // baseType. See the notes in guessTypeForAddress for the logic of // the locations searched. Address loc1 = addr.getAddressAt(0); Address loc2 = null; Address loc3 = null; long offset2 = baseType.getSize(); // I don't think this should be misaligned under any // circumstances, but I'm not sure (FIXME: also not sure which // way to go here, up or down -- assuming down) offset2 = offset2 - (offset2 % getAddressSize()) - getAddressSize(); if (offset2 > 0) { loc2 = addr.getAddressAt(offset2); } long offset3 = offset2 - getAddressSize(); if (offset3 > 0) { loc3 = addr.getAddressAt(offset3); } Type loc2Match = null; Type loc3Match = null; for (Iterator iter = getTypes(); iter.hasNext(); ) { Type type = (Type) iter.next(); Type superClass = type; while (superClass != baseType && superClass != null) { superClass = superClass.getSuperclass(); } if (superClass == null) continue; Address vtblAddr = vtblForType(type); if (vtblAddr == null) { // This occurs sometimes for intermediate types that are never // instantiated. if (DEBUG) { System.err.println("null vtbl for " + type); } continue; } // Prefer loc1 match if (vtblAddr.equals(loc1)) return type; if (loc2 != null && loc2Match == null && vtblAddr.equals(loc2)) { loc2Match = type; } if (loc3 != null && loc3Match == null && vtblAddr.equals(loc3)) { loc3Match = type; } } if (loc2Match != null) return loc2Match; if (loc3Match != null) return loc3Match; return null; }
Example 9
Source File: BasicTypeDataBase.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
public Type findDynamicTypeForAddress(Address addr, Type baseType) { // This implementation should be suitably platform-independent; we // search nearby memory for the vtbl value of the given type. if (vtblForType(baseType) == null) { // Type was not polymorphic which is an error of some sort throw new InternalError(baseType + " does not appear to be polymorphic"); } // This is a more restricted version of guessTypeForAddress since // that function has some limitations since it doesn't really know // where in the hierarchy a virtual type starts and just poking // around in memory is likely to trip over some vtable address, // resulting in false positives. Eventually all uses should // switch to this logic but in the interests of stability it will // be separate for the moment. // Assuming that the base type is truly the first polymorphic type // then the vtbl for all subclasss should be at several defined // locations so only those locations will be checked. It's also // required that the caller knows that the static type is at least // baseType. See the notes in guessTypeForAddress for the logic of // the locations searched. Address loc1 = addr.getAddressAt(0); Address loc2 = null; Address loc3 = null; long offset2 = baseType.getSize(); // I don't think this should be misaligned under any // circumstances, but I'm not sure (FIXME: also not sure which // way to go here, up or down -- assuming down) offset2 = offset2 - (offset2 % getAddressSize()) - getAddressSize(); if (offset2 > 0) { loc2 = addr.getAddressAt(offset2); } long offset3 = offset2 - getAddressSize(); if (offset3 > 0) { loc3 = addr.getAddressAt(offset3); } Type loc2Match = null; Type loc3Match = null; for (Iterator iter = getTypes(); iter.hasNext(); ) { Type type = (Type) iter.next(); Type superClass = type; while (superClass != baseType && superClass != null) { superClass = superClass.getSuperclass(); } if (superClass == null) continue; Address vtblAddr = vtblForType(type); if (vtblAddr == null) { // This occurs sometimes for intermediate types that are never // instantiated. if (DEBUG) { System.err.println("null vtbl for " + type); } continue; } // Prefer loc1 match if (vtblAddr.equals(loc1)) return type; if (loc2 != null && loc2Match == null && vtblAddr.equals(loc2)) { loc2Match = type; } if (loc3 != null && loc3Match == null && vtblAddr.equals(loc3)) { loc3Match = type; } } if (loc2Match != null) return loc2Match; if (loc3Match != null) return loc3Match; return null; }
Example 10
Source File: CommandProcessor.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
public void doit(Tokens t) { if (t.countTokens() != 1) { usage(); } else { String arg = t.nextToken(); Matcher m1 = args1.matcher(arg); Matcher m2 = args2.matcher(arg); Address start = null; Address end = null; String format = ""; int formatSize = (int)VM.getVM().getAddressSize(); if (m1.matches()) { start = VM.getVM().getDebugger().parseAddress(m1.group(1)); int count = 1; if (m1.group(2) != null) { count = Integer.parseInt(m1.group(3)); } end = start.addOffsetTo(count * formatSize); } else if (m2.matches()) { start = VM.getVM().getDebugger().parseAddress(m2.group(1)); end = VM.getVM().getDebugger().parseAddress(m2.group(2)); } else { usage(); return; } int line = 80; int formatWidth = formatSize * 8 / 4 + 2; out.print(fill(start, formatWidth)); out.print(": "); int width = line - formatWidth - 2; boolean needsPrintln = true; while (start != null && start.lessThan(end)) { Address val = start.getAddressAt(0); out.print(fill(val, formatWidth)); needsPrintln = true; width -= formatWidth; start = start.addOffsetTo(formatSize); if (width <= formatWidth) { out.println(); needsPrintln = false; if (start.lessThan(end)) { out.print(fill(start, formatWidth)); out.print(": "); width = line - formatWidth - 2; } } else { out.print(" "); width -= 1; } } if (needsPrintln) { out.println(); } } }
Example 11
Source File: BasicTypeDataBase.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 4 votes |
public Type findDynamicTypeForAddress(Address addr, Type baseType) { // This implementation should be suitably platform-independent; we // search nearby memory for the vtbl value of the given type. if (vtblForType(baseType) == null) { // Type was not polymorphic which is an error of some sort throw new InternalError(baseType + " does not appear to be polymorphic"); } // This is a more restricted version of guessTypeForAddress since // that function has some limitations since it doesn't really know // where in the hierarchy a virtual type starts and just poking // around in memory is likely to trip over some vtable address, // resulting in false positives. Eventually all uses should // switch to this logic but in the interests of stability it will // be separate for the moment. // Assuming that the base type is truly the first polymorphic type // then the vtbl for all subclasss should be at several defined // locations so only those locations will be checked. It's also // required that the caller knows that the static type is at least // baseType. See the notes in guessTypeForAddress for the logic of // the locations searched. Address loc1 = addr.getAddressAt(0); Address loc2 = null; Address loc3 = null; long offset2 = baseType.getSize(); // I don't think this should be misaligned under any // circumstances, but I'm not sure (FIXME: also not sure which // way to go here, up or down -- assuming down) offset2 = offset2 - (offset2 % getAddressSize()) - getAddressSize(); if (offset2 > 0) { loc2 = addr.getAddressAt(offset2); } long offset3 = offset2 - getAddressSize(); if (offset3 > 0) { loc3 = addr.getAddressAt(offset3); } Type loc2Match = null; Type loc3Match = null; for (Iterator iter = getTypes(); iter.hasNext(); ) { Type type = (Type) iter.next(); Type superClass = type; while (superClass != baseType && superClass != null) { superClass = superClass.getSuperclass(); } if (superClass == null) continue; Address vtblAddr = vtblForType(type); if (vtblAddr == null) { // This occurs sometimes for intermediate types that are never // instantiated. if (DEBUG) { System.err.println("null vtbl for " + type); } continue; } // Prefer loc1 match if (vtblAddr.equals(loc1)) return type; if (loc2 != null && loc2Match == null && vtblAddr.equals(loc2)) { loc2Match = type; } if (loc3 != null && loc3Match == null && vtblAddr.equals(loc3)) { loc3Match = type; } } if (loc2Match != null) return loc2Match; if (loc3Match != null) return loc3Match; return null; }
Example 12
Source File: CommandProcessor.java From openjdk-8-source with GNU General Public License v2.0 | 4 votes |
public void doit(Tokens t) { if (t.countTokens() != 1) { usage(); } else { String arg = t.nextToken(); Matcher m1 = args1.matcher(arg); Matcher m2 = args2.matcher(arg); Address start = null; Address end = null; String format = ""; int formatSize = (int)VM.getVM().getAddressSize(); if (m1.matches()) { start = VM.getVM().getDebugger().parseAddress(m1.group(1)); int count = 1; if (m1.group(2) != null) { count = Integer.parseInt(m1.group(3)); } end = start.addOffsetTo(count * formatSize); } else if (m2.matches()) { start = VM.getVM().getDebugger().parseAddress(m2.group(1)); end = VM.getVM().getDebugger().parseAddress(m2.group(2)); } else { usage(); return; } int line = 80; int formatWidth = formatSize * 8 / 4 + 2; out.print(fill(start, formatWidth)); out.print(": "); int width = line - formatWidth - 2; boolean needsPrintln = true; while (start != null && start.lessThan(end)) { Address val = start.getAddressAt(0); out.print(fill(val, formatWidth)); needsPrintln = true; width -= formatWidth; start = start.addOffsetTo(formatSize); if (width <= formatWidth) { out.println(); needsPrintln = false; if (start.lessThan(end)) { out.print(fill(start, formatWidth)); out.print(": "); width = line - formatWidth - 2; } } else { out.print(" "); width -= 1; } } if (needsPrintln) { out.println(); } } }
Example 13
Source File: BasicTypeDataBase.java From openjdk-8-source with GNU General Public License v2.0 | 4 votes |
public Type findDynamicTypeForAddress(Address addr, Type baseType) { // This implementation should be suitably platform-independent; we // search nearby memory for the vtbl value of the given type. if (vtblForType(baseType) == null) { // Type was not polymorphic which is an error of some sort throw new InternalError(baseType + " does not appear to be polymorphic"); } // This is a more restricted version of guessTypeForAddress since // that function has some limitations since it doesn't really know // where in the hierarchy a virtual type starts and just poking // around in memory is likely to trip over some vtable address, // resulting in false positives. Eventually all uses should // switch to this logic but in the interests of stability it will // be separate for the moment. // Assuming that the base type is truly the first polymorphic type // then the vtbl for all subclasss should be at several defined // locations so only those locations will be checked. It's also // required that the caller knows that the static type is at least // baseType. See the notes in guessTypeForAddress for the logic of // the locations searched. Address loc1 = addr.getAddressAt(0); Address loc2 = null; Address loc3 = null; long offset2 = baseType.getSize(); // I don't think this should be misaligned under any // circumstances, but I'm not sure (FIXME: also not sure which // way to go here, up or down -- assuming down) offset2 = offset2 - (offset2 % getAddressSize()) - getAddressSize(); if (offset2 > 0) { loc2 = addr.getAddressAt(offset2); } long offset3 = offset2 - getAddressSize(); if (offset3 > 0) { loc3 = addr.getAddressAt(offset3); } Type loc2Match = null; Type loc3Match = null; for (Iterator iter = getTypes(); iter.hasNext(); ) { Type type = (Type) iter.next(); Type superClass = type; while (superClass != baseType && superClass != null) { superClass = superClass.getSuperclass(); } if (superClass == null) continue; Address vtblAddr = vtblForType(type); if (vtblAddr == null) { // This occurs sometimes for intermediate types that are never // instantiated. if (DEBUG) { System.err.println("null vtbl for " + type); } continue; } // Prefer loc1 match if (vtblAddr.equals(loc1)) return type; if (loc2 != null && loc2Match == null && vtblAddr.equals(loc2)) { loc2Match = type; } if (loc3 != null && loc3Match == null && vtblAddr.equals(loc3)) { loc3Match = type; } } if (loc2Match != null) return loc2Match; if (loc3Match != null) return loc3Match; return null; }
Example 14
Source File: CommandProcessor.java From openjdk-jdk8u with GNU General Public License v2.0 | 4 votes |
public void doit(Tokens t) { if (t.countTokens() != 1) { usage(); } else { String arg = t.nextToken(); Matcher m1 = args1.matcher(arg); Matcher m2 = args2.matcher(arg); Address start = null; Address end = null; String format = ""; int formatSize = (int)VM.getVM().getAddressSize(); if (m1.matches()) { start = VM.getVM().getDebugger().parseAddress(m1.group(1)); int count = 1; if (m1.group(2) != null) { count = Integer.parseInt(m1.group(3)); } end = start.addOffsetTo(count * formatSize); } else if (m2.matches()) { start = VM.getVM().getDebugger().parseAddress(m2.group(1)); end = VM.getVM().getDebugger().parseAddress(m2.group(2)); } else { usage(); return; } int line = 80; int formatWidth = formatSize * 8 / 4 + 2; out.print(fill(start, formatWidth)); out.print(": "); int width = line - formatWidth - 2; boolean needsPrintln = true; while (start != null && start.lessThan(end)) { Address val = start.getAddressAt(0); out.print(fill(val, formatWidth)); needsPrintln = true; width -= formatWidth; start = start.addOffsetTo(formatSize); if (width <= formatWidth) { out.println(); needsPrintln = false; if (start.lessThan(end)) { out.print(fill(start, formatWidth)); out.print(": "); width = line - formatWidth - 2; } } else { out.print(" "); width -= 1; } } if (needsPrintln) { out.println(); } } }
Example 15
Source File: CommandProcessor.java From openjdk-8 with GNU General Public License v2.0 | 4 votes |
public void doit(Tokens t) { if (t.countTokens() != 1) { usage(); } else { String arg = t.nextToken(); Matcher m1 = args1.matcher(arg); Matcher m2 = args2.matcher(arg); Address start = null; Address end = null; String format = ""; int formatSize = (int)VM.getVM().getAddressSize(); if (m1.matches()) { start = VM.getVM().getDebugger().parseAddress(m1.group(1)); int count = 1; if (m1.group(2) != null) { count = Integer.parseInt(m1.group(3)); } end = start.addOffsetTo(count * formatSize); } else if (m2.matches()) { start = VM.getVM().getDebugger().parseAddress(m2.group(1)); end = VM.getVM().getDebugger().parseAddress(m2.group(2)); } else { usage(); return; } int line = 80; int formatWidth = formatSize * 8 / 4 + 2; out.print(fill(start, formatWidth)); out.print(": "); int width = line - formatWidth - 2; boolean needsPrintln = true; while (start != null && start.lessThan(end)) { Address val = start.getAddressAt(0); out.print(fill(val, formatWidth)); needsPrintln = true; width -= formatWidth; start = start.addOffsetTo(formatSize); if (width <= formatWidth) { out.println(); needsPrintln = false; if (start.lessThan(end)) { out.print(fill(start, formatWidth)); out.print(": "); width = line - formatWidth - 2; } } else { out.print(" "); width -= 1; } } if (needsPrintln) { out.println(); } } }
Example 16
Source File: CommandProcessor.java From hottub with GNU General Public License v2.0 | 4 votes |
public void doit(Tokens t) { if (t.countTokens() != 1) { usage(); } else { String arg = t.nextToken(); Matcher m1 = args1.matcher(arg); Matcher m2 = args2.matcher(arg); Address start = null; Address end = null; String format = ""; int formatSize = (int)VM.getVM().getAddressSize(); if (m1.matches()) { start = VM.getVM().getDebugger().parseAddress(m1.group(1)); int count = 1; if (m1.group(2) != null) { count = Integer.parseInt(m1.group(3)); } end = start.addOffsetTo(count * formatSize); } else if (m2.matches()) { start = VM.getVM().getDebugger().parseAddress(m2.group(1)); end = VM.getVM().getDebugger().parseAddress(m2.group(2)); } else { usage(); return; } int line = 80; int formatWidth = formatSize * 8 / 4 + 2; out.print(fill(start, formatWidth)); out.print(": "); int width = line - formatWidth - 2; boolean needsPrintln = true; while (start != null && start.lessThan(end)) { Address val = start.getAddressAt(0); out.print(fill(val, formatWidth)); needsPrintln = true; width -= formatWidth; start = start.addOffsetTo(formatSize); if (width <= formatWidth) { out.println(); needsPrintln = false; if (start.lessThan(end)) { out.print(fill(start, formatWidth)); out.print(": "); width = line - formatWidth - 2; } } else { out.print(" "); width -= 1; } } if (needsPrintln) { out.println(); } } }
Example 17
Source File: CommandProcessor.java From jdk8u60 with GNU General Public License v2.0 | 4 votes |
public void doit(Tokens t) { if (t.countTokens() != 1) { usage(); } else { String arg = t.nextToken(); Matcher m1 = args1.matcher(arg); Matcher m2 = args2.matcher(arg); Address start = null; Address end = null; String format = ""; int formatSize = (int)VM.getVM().getAddressSize(); if (m1.matches()) { start = VM.getVM().getDebugger().parseAddress(m1.group(1)); int count = 1; if (m1.group(2) != null) { count = Integer.parseInt(m1.group(3)); } end = start.addOffsetTo(count * formatSize); } else if (m2.matches()) { start = VM.getVM().getDebugger().parseAddress(m2.group(1)); end = VM.getVM().getDebugger().parseAddress(m2.group(2)); } else { usage(); return; } int line = 80; int formatWidth = formatSize * 8 / 4 + 2; out.print(fill(start, formatWidth)); out.print(": "); int width = line - formatWidth - 2; boolean needsPrintln = true; while (start != null && start.lessThan(end)) { Address val = start.getAddressAt(0); out.print(fill(val, formatWidth)); needsPrintln = true; width -= formatWidth; start = start.addOffsetTo(formatSize); if (width <= formatWidth) { out.println(); needsPrintln = false; if (start.lessThan(end)) { out.print(fill(start, formatWidth)); out.print(": "); width = line - formatWidth - 2; } } else { out.print(" "); width -= 1; } } if (needsPrintln) { out.println(); } } }
Example 18
Source File: BasicTypeDataBase.java From hottub with GNU General Public License v2.0 | 4 votes |
public Type findDynamicTypeForAddress(Address addr, Type baseType) { // This implementation should be suitably platform-independent; we // search nearby memory for the vtbl value of the given type. if (vtblForType(baseType) == null) { // Type was not polymorphic which is an error of some sort throw new InternalError(baseType + " does not appear to be polymorphic"); } // This is a more restricted version of guessTypeForAddress since // that function has some limitations since it doesn't really know // where in the hierarchy a virtual type starts and just poking // around in memory is likely to trip over some vtable address, // resulting in false positives. Eventually all uses should // switch to this logic but in the interests of stability it will // be separate for the moment. // Assuming that the base type is truly the first polymorphic type // then the vtbl for all subclasss should be at several defined // locations so only those locations will be checked. It's also // required that the caller knows that the static type is at least // baseType. See the notes in guessTypeForAddress for the logic of // the locations searched. Address loc1 = addr.getAddressAt(0); Address loc2 = null; Address loc3 = null; long offset2 = baseType.getSize(); // I don't think this should be misaligned under any // circumstances, but I'm not sure (FIXME: also not sure which // way to go here, up or down -- assuming down) offset2 = offset2 - (offset2 % getAddressSize()) - getAddressSize(); if (offset2 > 0) { loc2 = addr.getAddressAt(offset2); } long offset3 = offset2 - getAddressSize(); if (offset3 > 0) { loc3 = addr.getAddressAt(offset3); } Type loc2Match = null; Type loc3Match = null; for (Iterator iter = getTypes(); iter.hasNext(); ) { Type type = (Type) iter.next(); Type superClass = type; while (superClass != baseType && superClass != null) { superClass = superClass.getSuperclass(); } if (superClass == null) continue; Address vtblAddr = vtblForType(type); if (vtblAddr == null) { // This occurs sometimes for intermediate types that are never // instantiated. if (DEBUG) { System.err.println("null vtbl for " + type); } continue; } // Prefer loc1 match if (vtblAddr.equals(loc1)) return type; if (loc2 != null && loc2Match == null && vtblAddr.equals(loc2)) { loc2Match = type; } if (loc3 != null && loc3Match == null && vtblAddr.equals(loc3)) { loc3Match = type; } } if (loc2Match != null) return loc2Match; if (loc3Match != null) return loc3Match; return null; }
Example 19
Source File: BasicTypeDataBase.java From TencentKona-8 with GNU General Public License v2.0 | 4 votes |
public Type findDynamicTypeForAddress(Address addr, Type baseType) { // This implementation should be suitably platform-independent; we // search nearby memory for the vtbl value of the given type. if (vtblForType(baseType) == null) { // Type was not polymorphic which is an error of some sort throw new InternalError(baseType + " does not appear to be polymorphic"); } // This is a more restricted version of guessTypeForAddress since // that function has some limitations since it doesn't really know // where in the hierarchy a virtual type starts and just poking // around in memory is likely to trip over some vtable address, // resulting in false positives. Eventually all uses should // switch to this logic but in the interests of stability it will // be separate for the moment. // Assuming that the base type is truly the first polymorphic type // then the vtbl for all subclasss should be at several defined // locations so only those locations will be checked. It's also // required that the caller knows that the static type is at least // baseType. See the notes in guessTypeForAddress for the logic of // the locations searched. Address loc1 = addr.getAddressAt(0); Address loc2 = null; Address loc3 = null; long offset2 = baseType.getSize(); // I don't think this should be misaligned under any // circumstances, but I'm not sure (FIXME: also not sure which // way to go here, up or down -- assuming down) offset2 = offset2 - (offset2 % getAddressSize()) - getAddressSize(); if (offset2 > 0) { loc2 = addr.getAddressAt(offset2); } long offset3 = offset2 - getAddressSize(); if (offset3 > 0) { loc3 = addr.getAddressAt(offset3); } Type loc2Match = null; Type loc3Match = null; for (Iterator iter = getTypes(); iter.hasNext(); ) { Type type = (Type) iter.next(); Type superClass = type; while (superClass != baseType && superClass != null) { superClass = superClass.getSuperclass(); } if (superClass == null) continue; Address vtblAddr = vtblForType(type); if (vtblAddr == null) { // This occurs sometimes for intermediate types that are never // instantiated. if (DEBUG) { System.err.println("null vtbl for " + type); } continue; } // Prefer loc1 match if (vtblAddr.equals(loc1)) return type; if (loc2 != null && loc2Match == null && vtblAddr.equals(loc2)) { loc2Match = type; } if (loc3 != null && loc3Match == null && vtblAddr.equals(loc3)) { loc3Match = type; } } if (loc2Match != null) return loc2Match; if (loc3Match != null) return loc3Match; return null; }
Example 20
Source File: CommandProcessor.java From TencentKona-8 with GNU General Public License v2.0 | 4 votes |
public void doit(Tokens t) { if (t.countTokens() != 1) { usage(); } else { String arg = t.nextToken(); Matcher m1 = args1.matcher(arg); Matcher m2 = args2.matcher(arg); Address start = null; Address end = null; String format = ""; int formatSize = (int)VM.getVM().getAddressSize(); if (m1.matches()) { start = VM.getVM().getDebugger().parseAddress(m1.group(1)); int count = 1; if (m1.group(2) != null) { count = Integer.parseInt(m1.group(3)); } end = start.addOffsetTo(count * formatSize); } else if (m2.matches()) { start = VM.getVM().getDebugger().parseAddress(m2.group(1)); end = VM.getVM().getDebugger().parseAddress(m2.group(2)); } else { usage(); return; } int line = 80; int formatWidth = formatSize * 8 / 4 + 2; out.print(fill(start, formatWidth)); out.print(": "); int width = line - formatWidth - 2; boolean needsPrintln = true; while (start != null && start.lessThan(end)) { Address val = start.getAddressAt(0); out.print(fill(val, formatWidth)); needsPrintln = true; width -= formatWidth; start = start.addOffsetTo(formatSize); if (width <= formatWidth) { out.println(); needsPrintln = false; if (start.lessThan(end)) { out.print(fill(start, formatWidth)); out.print(": "); width = line - formatWidth - 2; } } else { out.print(" "); width -= 1; } } if (needsPrintln) { out.println(); } } }