Path: blob/master/debugtools/DDR_VM/testsrc/PrintBlob.java
6000 views
/*******************************************************************************1* Copyright (c) 2010, 2018 IBM Corp. and others2*3* This program and the accompanying materials are made available under4* the terms of the Eclipse Public License 2.0 which accompanies this5* distribution and is available at https://www.eclipse.org/legal/epl-2.0/6* or the Apache License, Version 2.0 which accompanies this distribution and7* is available at https://www.apache.org/licenses/LICENSE-2.0.8*9* This Source Code may also be made available under the following10* Secondary Licenses when the conditions for such availability set11* forth in the Eclipse Public License, v. 2.0 are satisfied: GNU12* General Public License, version 2 with the GNU Classpath13* Exception [1] and GNU General Public License, version 2 with the14* OpenJDK Assembly Exception [2].15*16* [1] https://www.gnu.org/software/classpath/license.html17* [2] http://openjdk.java.net/legal/assembly-exception.html18*19* SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 OR LicenseRef-GPL-2.0 WITH Assembly-exception20*******************************************************************************/2122import java.io.File;23import java.nio.ByteOrder;24import java.util.ArrayList;25import java.util.Collections;26import java.util.Comparator;27import java.util.List;2829import javax.imageio.stream.FileImageInputStream;30import javax.imageio.stream.ImageInputStream;3132import com.ibm.j9ddr.StructureReader;33import com.ibm.j9ddr.StructureReader.StructureDescriptor;3435/**36* @author andhall37*38*/39public class PrintBlob40{4142/**43* @param args44*/45public static void main(String[] args) throws Exception46{47if (args.length != 1) {48System.err.println("Expected 1 argument. Got " + args.length);49System.exit(1);50}5152File blobFile = new File(args[0]);5354ImageInputStream iis = new FileImageInputStream(blobFile);55iis.setByteOrder(ByteOrder.LITTLE_ENDIAN);5657StructureReader structReader = new StructureReader(iis);5859List<StructureDescriptor> structures = new ArrayList<StructureDescriptor>(structReader.getStructures());6061Collections.sort(structures, new Comparator<StructureDescriptor>(){6263public int compare(StructureDescriptor o1, StructureDescriptor o2)64{65return o1.getName().compareTo(o2.getName());66}});6768for (StructureDescriptor thisStruct : structures)69{70String superClass = thisStruct.getSuperName();71if (superClass != null && superClass.length() > 0) {72System.out.println("Structure: " + thisStruct.getName() + " extends " + superClass);73} else {74System.out.println("Structure: " + thisStruct.getName());75}767778// List<FieldDescriptor> fields = new ArrayList<FieldDescriptor>(thisStruct.getFields());79//80// Collections.sort(fields, new Comparator<FieldDescriptor>(){81//82// public int compare(FieldDescriptor o1, FieldDescriptor o2)83// {84// return o1.getName().compareTo(o2.getName());85// }});86//87// System.out.println("\tFields");88//89// for (FieldDescriptor thisField : fields) {90// System.out.println("\t\t" + thisField.getName() + " - " + thisField.getType());91// }92//93// List<ConstantDescriptor> constants = new ArrayList<ConstantDescriptor>(thisStruct.getConstants());94//95// Collections.sort(constants, new Comparator<ConstantDescriptor>(){96//97// public int compare(ConstantDescriptor o1, ConstantDescriptor o2)98// {99// return o1.getName().compareTo(o2.getName());100// }});101//102// System.out.println("\tConstants:");103// for (ConstantDescriptor thisConstant : constants) {104// System.out.println("\t\t" + thisConstant.getName());105// }106}107}108109}110111112