use of com.ibm.j9ddr.vm29.pointer.generated.J9ROMClassPointer in project openj9 by eclipse.
the class MethodForNameCommand method dbgGetMethodsForName.
int dbgGetMethodsForName(PrintStream out, String pattern) throws CorruptDataException {
int matchCount = 0;
// J9ClassWalkState walkState;
String classNeedle, methodNeedle, sigNeedle;
long classMatchFlags, methodMatchFlags, sigMatchFlags;
String classStart, nameStart, sigStart;
if (pattern.indexOf('.') != -1) {
// skip the .
nameStart = pattern.substring(pattern.indexOf('.') + 1);
classStart = pattern.substring(0, pattern.indexOf('.'));
} else {
classStart = "*";
nameStart = pattern;
}
if (pattern.indexOf('(') != -1) {
sigStart = pattern.substring(pattern.indexOf('('));
} else {
sigStart = "*";
}
StringBuffer needleBuffer = new StringBuffer();
classMatchFlags = WildCard.parseWildcard(classStart, needleBuffer);
classNeedle = needleBuffer.toString();
if (classMatchFlags == -1) {
CommandUtils.dbgError(out, "Invalid wildcards in class name\n");
return 0;
}
needleBuffer = new StringBuffer();
methodMatchFlags = WildCard.parseWildcard(nameStart, needleBuffer);
methodNeedle = needleBuffer.toString();
if (methodMatchFlags == -1) {
CommandUtils.dbgError(out, "Invalid wildcards in method name\n");
return 0;
}
needleBuffer = new StringBuffer();
sigMatchFlags = WildCard.parseWildcard(sigStart, needleBuffer);
sigNeedle = needleBuffer.toString();
if (methodMatchFlags == -1) {
CommandUtils.dbgError(out, "Invalid wildcards in method name\n");
return 0;
}
Hashtable<String, J9ClassPointer> loadedClasses = new Hashtable<String, J9ClassPointer>();
GCClassLoaderIterator classLoaderIterator = GCClassLoaderIterator.from();
while (classLoaderIterator.hasNext()) {
J9ClassLoaderPointer loader = classLoaderIterator.next();
Iterator<J9ClassPointer> classItterator = ClassIterator.fromJ9Classloader(loader);
while (classItterator.hasNext()) {
J9ClassPointer clazz = classItterator.next();
J9ROMClassPointer romClazz = clazz.romClass();
String className = J9UTF8Helper.stringValue(romClazz.className());
if (loadedClasses.containsValue(clazz)) {
continue;
} else {
loadedClasses.put(clazz.toString(), clazz);
}
if (WildCard.wildcardMatch(classMatchFlags, classNeedle, className)) {
J9MethodPointer methodCursor = clazz.ramMethods();
for (long count = romClazz.romMethodCount().longValue(); count > 0; count--, methodCursor = methodCursor.add(1)) {
J9ROMMethodPointer romMethod = J9MethodHelper.romMethod(methodCursor);
J9ROMNameAndSignaturePointer nameAndSignature = romMethod.nameAndSignature();
String nameUTF = J9UTF8Helper.stringValue(nameAndSignature.name());
if (WildCard.wildcardMatch(methodMatchFlags, methodNeedle, nameUTF)) {
String sigUTF = J9UTF8Helper.stringValue(nameAndSignature.signature());
if (WildCard.wildcardMatch(sigMatchFlags, sigNeedle, sigUTF)) {
matchCount++;
CommandUtils.dbgPrint(out, String.format("!j9method %s --> %s.%s%s\n", methodCursor.getHexAddress(), className, nameUTF, sigUTF));
}
}
}
}
}
}
return matchCount;
}
use of com.ibm.j9ddr.vm29.pointer.generated.J9ROMClassPointer in project openj9 by eclipse.
the class J9BCUtil method dumpStaticSplitSideTable.
/**
* This method is Java implementation of rdump.c#dumpStaticSplitSideTable function.
* This method is called when dumping a ROMClass.
*
* @param out PrintStream to print the user info to the console
* @param romClass ROMClass address in the dump file.
*
* @throws CorruptDataException
*/
private static void dumpStaticSplitSideTable(PrintStream out, J9ROMClassPointer romClass) throws CorruptDataException {
int splitTableCount = romClass.staticSplitMethodRefCount().intValue();
if (splitTableCount > 0) {
out.println(String.format("Static Split Table (%d):\n", splitTableCount));
out.println(" SplitTable Index -> CP Index");
U16Pointer cursor = romClass.staticSplitMethodRefIndexes();
for (int i = 0; i < splitTableCount; i++) {
cursor.add(i);
out.println(String.format(" %16d -> %d", i, cursor.at(i).intValue()));
}
}
}
use of com.ibm.j9ddr.vm29.pointer.generated.J9ROMClassPointer in project openj9 by eclipse.
the class J9BCUtil method dumpSpecialSplitSideTable.
/**
* This method is Java implementation of rdump.c#dumpSpecialSplitSideTable function.
* This method is called when dumping a ROMClass.
*
* @param out PrintStream to print the user info to the console
* @param romClass ROMClass address in the dump file.
*
* @throws CorruptDataException
*/
private static void dumpSpecialSplitSideTable(PrintStream out, J9ROMClassPointer romClass) throws CorruptDataException {
int splitTableCount = romClass.specialSplitMethodRefCount().intValue();
if (splitTableCount > 0) {
out.println(String.format("Special Split Table (%d):\n", splitTableCount));
out.println(" SplitTable Index -> CP Index");
U16Pointer cursor = romClass.specialSplitMethodRefIndexes();
for (int i = 0; i < splitTableCount; i++) {
cursor.add(i);
out.println(String.format(" %16d -> %d", i, cursor.at(i).intValue()));
}
}
}
use of com.ibm.j9ddr.vm29.pointer.generated.J9ROMClassPointer in project openj9 by eclipse.
the class RomClassForNameCommand method run.
public void run(String command, String[] args, Context context, PrintStream out) throws DDRInteractiveCommandException {
if (args.length == 0) {
printUsage(out);
return;
}
try {
J9JavaVMPointer vm = J9RASHelper.getVM(DataType.getJ9RASPointer());
ROMClassesIterator iterator = new ROMClassesIterator(out, vm.classMemorySegments());
int hitCount = 0;
String searchClassName = args[0];
PatternString pattern = new PatternString(searchClassName);
out.println(String.format("Searching for ROMClasses named '%1$s' in VM=%2$s", searchClassName, Long.toHexString(vm.getAddress())));
while (iterator.hasNext()) {
J9ROMClassPointer romClassPointer = iterator.next();
String javaName = J9UTF8Helper.stringValue(romClassPointer.className());
if (pattern.isMatch(javaName)) {
hitCount++;
String hexString = romClassPointer.getHexAddress();
out.println(String.format("!j9romclass %1$s named %2$s", hexString, javaName));
}
}
out.println(String.format("Found %1$d ROMClass(es) named %2$s", hitCount, searchClassName));
} catch (CorruptDataException e) {
throw new DDRInteractiveCommandException(e);
}
}
use of com.ibm.j9ddr.vm29.pointer.generated.J9ROMClassPointer in project openj9 by eclipse.
the class RomClassSummaryCommand method run.
public void run(String command, String[] args, Context context, PrintStream out) throws DDRInteractiveCommandException {
try {
boolean requiredLocal = false;
boolean requiredShared = false;
boolean required16bitnas = false;
J9SharedClassConfigPointer sc = J9SharedClassConfigPointer.NULL;
J9JavaVMPointer vm = J9RASHelper.getVM(DataType.getJ9RASPointer());
long startAddress = 0, endAddress = 0;
if ((args != null) && (args.length >= 1)) {
if (args[0].equals("shared")) {
requiredShared = true;
} else if (args[0].equals("local")) {
requiredLocal = true;
} else if (args[0].equals("16bitnas")) {
required16bitnas = true;
} else {
out.println("USAGE: !romclasssummary [local|shared] [16bitnas]");
return;
}
if ((args.length >= 2) && (args[1].equals("16bitnas"))) {
required16bitnas = true;
}
if (requiredShared || requiredLocal) {
sc = vm.sharedClassConfig();
if (requiredShared && sc.isNull()) {
out.println("The request for '" + args[0] + " classes' failed, because " + "shared classes were not enabled on that dump file.");
return;
}
if (sc.notNull()) {
startAddress = UDATA.cast(sc.cacheDescriptorList().romclassStartAddress()).longValue();
J9SharedCacheHeaderPointer header = sc.cacheDescriptorList().cacheStartAddress();
endAddress = UDATA.cast(header).add(header.segmentSRP()).longValue();
}
}
}
ClassSummaryHelper classSummaryHelper = new ClassSummaryHelper(preferredOrder);
Statistics statistics = new Statistics();
ROMClassesIterator classSegmentIterator = new ROMClassesIterator(out, vm.classMemorySegments());
while (classSegmentIterator.hasNext()) {
J9ROMClassPointer classPointer = (J9ROMClassPointer) classSegmentIterator.next();
if (requiredShared || requiredLocal) {
boolean isShared;
if (sc.notNull()) {
long classAddress = classPointer.getAddress();
isShared = classAddress >= startAddress && classAddress < endAddress;
} else {
isShared = false;
}
if (requiredShared && !isShared)
continue;
if (requiredLocal && isShared)
continue;
}
ClassWalker classWalker = new RomClassWalker(classPointer, context);
LinearDumper linearDumper = new LinearDumper();
J9ClassRegionNode allRegionsNode = linearDumper.getAllRegions(classWalker);
classSummaryHelper.addRegionsForClass(allRegionsNode);
if (required16bitnas) {
statistics.add(allRegionsNode);
}
}
classSummaryHelper.printStatistics(out);
if (statistics.nameAndSignatureSRP16bitSize != -1) {
out.println();
out.println("<Total 16bit nameAndSignatureSRPs Size>");
out.println(statistics.nameAndSignatureSRP16bitSize);
}
if (statistics.nameAndSignatureSRPCount != -1 && statistics.cpFieldNASCount != -1) {
out.println();
out.println("<Shared nameAndSignatureSRPs>");
// nameAndSignatureSRPCount is divided by 2, because there is a name and a signature per NAS field
out.println(statistics.cpFieldNASCount - statistics.nameAndSignatureSRPCount / 2);
}
} catch (CorruptDataException e) {
throw new DDRInteractiveCommandException(e);
}
}
Aggregations