GP-4067 - PDB - Add cancellation to PDB dumps

This commit is contained in:
ghizard 2023-11-26 15:04:14 -05:00
parent 2e5b4fc22a
commit e2862d7c82
18 changed files with 236 additions and 142 deletions

View file

@ -88,19 +88,22 @@ public class AbstractC13Lines extends C13Section {
* Dumps this class to a Writer
* @param writer {@link Writer} to which to dump the information
* @throws IOException Upon IOException writing to the {@link Writer}
* @throws CancelledException upon user cancellation
*/
@Override
void dump(Writer writer) throws IOException {
void dump(Writer writer, TaskMonitor monitor) throws IOException, CancelledException {
writer.write("C13Lines----------------------------------------------------\n");
dumpInternal(writer);
dumpInternal(writer, monitor);
writer.write("End C13Lines------------------------------------------------\n");
}
protected void dumpInternal(Writer writer) throws IOException {
protected void dumpInternal(Writer writer, TaskMonitor monitor)
throws IOException, CancelledException {
writer.write(String.format("offCon: 0x%08x segCon: %d flags: 0x%08x lenCon: 0x%08x\n",
offCon, segCon, flags, lenCon));
for (FileRecord record : fileRecords) {
monitor.checkCancelled();
record.dump(writer, offCon);
}
}
@ -167,8 +170,8 @@ public class AbstractC13Lines extends C13Section {
}
void dump(Writer writer, long offCon) throws IOException {
writer.write(String.format("fileId: %06x, nLines: %d, lenFileBlock: %d\n",
getFileId(), getNLines(), getLenFileBlock()));
writer.write(String.format("fileId: %06x, nLines: %d, lenFileBlock: %d\n", getFileId(),
getNLines(), getLenFileBlock()));
for (int i = 0; i < getNLines(); i++) {
List<LineRecord> records = getLineRecords();
records.get(i).dump(writer, offCon);

View file

@ -658,13 +658,13 @@ public abstract class AbstractPdb implements AutoCloseable {
nameTable.deserializeDirectory(reader);
// Read the parameters.
while (reader.hasMore()) {
getMonitor().checkCancelled();
checkCancelled();
int val = reader.parseInt();
parameters.add(val);
}
// Check the parameters for IDs
for (int param : parameters) {
getMonitor().checkCancelled();
checkCancelled();
if (param == MINIMAL_DEBUG_INFO_PARAM) {
minimalDebugInfo = true;
}

View file

@ -40,7 +40,7 @@ abstract class AbstractUnimplementedC13Section extends C13Section {
}
@Override
void dump(Writer writer) throws IOException {
void dump(Writer writer, TaskMonitor monitor) throws IOException {
String n = getClass().getSimpleName();
int len = n.length();
writer.write(n + dashes.substring(len));

View file

@ -28,6 +28,7 @@ import ghidra.util.exception.CancelledException;
*/
public class C11Lines {
private AbstractPdb pdb;
private int cFile; // unsigned short
private int cSeg; // unsigned short
// array of (Windows C) unsigned long values (which is 32-bit int); we are limiting to java int.
@ -54,6 +55,7 @@ public class C11Lines {
private C11Lines(AbstractPdb pdb, PdbByteReader reader)
throws PdbException, CancelledException {
this.pdb = pdb;
if (reader.numRemaining() < 4) {
return;
}
@ -138,25 +140,34 @@ public class C11Lines {
@Override
public String toString() {
return dump();
try {
return dump();
}
catch (CancelledException e) {
return "";
}
}
/**
* Dumps this class. This package-protected method is for debugging only.
* @return the {@link String} output.
* @throws CancelledException upon user cancellation
*/
String dump() {
String dump() throws CancelledException {
StringBuilder builder = new StringBuilder();
builder.append("Lines-------------------------------------------------------\n");
builder.append("cFile: " + cFile + " cSeg: " + cSeg + "\n");
for (int i = 0; i < cFile; i++) {
pdb.checkCancelled();
builder.append("baseSrcFile[" + i + "]: " + baseSrcFile.get(i) + "\n");
}
for (int i = 0; i < cSeg; i++) {
pdb.checkCancelled();
builder.append(i + ": start:" + startEnd.get(i).getStart() + " end: " +
startEnd.get(i).getEnd() + " seg: " + seg.get(i) + "\n");
}
for (int i = 0; i < cFile; i++) {
pdb.checkCancelled();
builder.append(
" file[" + i + "]: cSeg: " + ccSegs.get(i) + " name: " + names.get(i) + "\n");
List<Integer> myBaseSrcLn = baseSrcLines.get(i);
@ -170,6 +181,7 @@ public class C11Lines {
List<List<Long>> fileSegOffsets = offsets.get(i);
List<List<Integer>> fileSegLineNums = lineNumbers.get(i);
for (int j = 0; j < fileSegOffsets.size(); j++) {
pdb.checkCancelled();
List<Long> segOffsets = fileSegOffsets.get(j);
List<Integer> segLineNums = fileSegLineNums.get(j);
builder.append(" seg[" + j + "]: Seg: " + segNums.get(j) + " cPair: " +

View file

@ -73,11 +73,13 @@ public class C13CrossScopeExports extends C13Section {
* Dumps this class to a Writer
* @param writer {@link Writer} to which to dump the information
* @throws IOException Upon IOException writing to the {@link Writer}
* @throws CancelledException upon user cancellation
*/
@Override
void dump(Writer writer) throws IOException {
void dump(Writer writer, TaskMonitor monitor) throws IOException, CancelledException {
writer.write("C13CrossScopeExports----------------------------------------\n");
for (CrossScopeExport crossScopeExport : crossScopeExports) {
monitor.checkCancelled();
writer.write(crossScopeExport.toString());
writer.write('\n');
}

View file

@ -73,11 +73,13 @@ public class C13CrossScopeImports extends C13Section {
* Dumps this class to a Writer
* @param writer {@link Writer} to which to dump the information
* @throws IOException Upon IOException writing to the {@link Writer}
* @throws CancelledException upon user cancellation
*/
@Override
void dump(Writer writer) throws IOException {
void dump(Writer writer, TaskMonitor monitor) throws IOException, CancelledException {
writer.write("C13CrossScopeImports----------------------------------------\n");
for (CrossScopeImport crossScopeImport : crossScopeImports) {
monitor.checkCancelled();
writer.write(crossScopeImport.toString());
writer.write('\n');
}

View file

@ -65,19 +65,21 @@ public class C13FileChecksums extends C13Section {
@Override
public String toString() {
return String.format(
"%s: num checksums = %d", getClass().getSimpleName(), fileChecksums.size());
return String.format("%s: num checksums = %d", getClass().getSimpleName(),
fileChecksums.size());
}
/**
* Dumps this class to a Writer
* @param writer {@link Writer} to which to dump the information
* @throws IOException Upon IOException writing to the {@link Writer}
* @throws CancelledException upon user cancellation
*/
@Override
void dump(Writer writer) throws IOException {
void dump(Writer writer, TaskMonitor monitor) throws IOException, CancelledException {
writer.write("C13FileChecksums--------------------------------------------\n");
for (FileChecksum checksum : fileChecksums) {
monitor.checkCancelled();
writer.write(checksum.toString());
writer.write('\n');
}

View file

@ -51,11 +51,12 @@ public class C13IlLines extends AbstractC13Lines {
* Dumps this class to a Writer
* @param writer {@link Writer} to which to dump the information
* @throws IOException Upon IOException writing to the {@link Writer}
* @throws CancelledException upon user cancellation
*/
@Override
void dump(Writer writer) throws IOException {
void dump(Writer writer, TaskMonitor monitor) throws IOException, CancelledException {
writer.write("C13IlLines--------------------------------------------------\n");
dumpInternal(writer);
dumpInternal(writer, monitor);
writer.write("End C13IlLines----------------------------------------------\n");
}
}

View file

@ -99,20 +99,22 @@ public class C13InlineeLines extends C13Section {
@Override
public String toString() {
return String.format(
"%s: num inlinee lines = %d", getClass().getSimpleName(), inlineeLines.size());
return String.format("%s: num inlinee lines = %d", getClass().getSimpleName(),
inlineeLines.size());
}
/**
* Dumps this class to a Writer
* @param writer {@link Writer} to which to dump the information
* @throws IOException Upon IOException writing to the {@link Writer}
* @throws CancelledException upon user cancellation
*/
@Override
void dump(Writer writer) throws IOException {
void dump(Writer writer, TaskMonitor monitor) throws IOException, CancelledException {
writer.write("C13InlineeLines---------------------------------------------\n");
writer.write(String.format("Signature: 0x%03x\n", signature));
for (InlineeSourceLine line : inlineeLines) {
monitor.checkCancelled();
writer.write(line.toString());
writer.write('\n');
}

View file

@ -52,11 +52,12 @@ public class C13Lines extends AbstractC13Lines {
* Dumps this class to a Writer
* @param writer {@link Writer} to which to dump the information
* @throws IOException Upon IOException writing to the {@link Writer}
* @throws CancelledException upon user cancellation
*/
@Override
void dump(Writer writer) throws IOException {
void dump(Writer writer, TaskMonitor monitor) throws IOException, CancelledException {
writer.write("C13Lines----------------------------------------------------\n");
dumpInternal(writer);
dumpInternal(writer, monitor);
writer.write("End C13Lines------------------------------------------------\n");
}

View file

@ -38,7 +38,7 @@ abstract class C13Section {
return ignore;
}
void dump(Writer writer) throws IOException {
void dump(Writer writer, TaskMonitor monitor) throws IOException, CancelledException {
String n = getClass().getSimpleName();
int len = n.length();
writer.write(n + dashes.substring(len));

View file

@ -104,8 +104,7 @@ public class Module {
* @throws CancelledException upon user cancellation
* @throws PdbException upon issue reading this Module's stream
*/
public C11Lines getLineInformation()
throws CancelledException, PdbException {
public C11Lines getLineInformation() throws CancelledException, PdbException {
if (sizeLines == 0) {
return null;
}
@ -245,8 +244,7 @@ public class Module {
public GlobalReferenceIterator getGlobalReferenceIterator()
throws CancelledException, PdbException {
PdbByteReader globalRefsReader = getGlobalRefsReader();
GlobalReferenceIterator iterator =
new GlobalReferenceIterator(pdb, globalRefsReader);
GlobalReferenceIterator iterator = new GlobalReferenceIterator(pdb, globalRefsReader);
return iterator;
}
@ -262,8 +260,7 @@ public class Module {
}
private PdbByteReader getC13LinesReader() throws CancelledException {
return getReader(offsetC13Lines, sizeC13Lines,
"C13Lines");
return getReader(offsetC13Lines, sizeC13Lines, "C13Lines");
}
private PdbByteReader getGlobalRefsReader() throws CancelledException {
@ -313,8 +310,7 @@ public class Module {
* @throws CancelledException upon user cancellation
* @throws IOException upon IOException writing to the {@link Writer}
*/
void dump(Writer writer)
throws CancelledException, PdbException, IOException {
void dump(Writer writer) throws CancelledException, PdbException, IOException {
writer.write("Module------------------------------------------------------\n");
@ -331,8 +327,7 @@ public class Module {
writer.write("End Module--------------------------------------------------\n");
}
private void dumpSymbols(Writer writer)
throws IOException, CancelledException, PdbException {
private void dumpSymbols(Writer writer) throws IOException, CancelledException, PdbException {
writer.write("Symbols-----------------------------------------------------");
MsSymbolIterator symbolIter = iterator();
while (symbolIter.hasNext()) {
@ -345,8 +340,7 @@ public class Module {
writer.write("End Symbols-------------------------------------------------\n");
}
private void dumpC11Lines(Writer writer)
throws IOException, CancelledException, PdbException {
private void dumpC11Lines(Writer writer) throws IOException, CancelledException, PdbException {
// Need to confirm C11 parsing and then convert it to an Iterator model; would be very
// helpful to find some real data
writer.write("C11Lines----------------------------------------------------\n");
@ -365,7 +359,7 @@ public class Module {
while (c13Iterator.hasNext()) {
pdb.checkCancelled();
C13Section c13Section = c13Iterator.next();
c13Section.dump(writer);
c13Section.dump(writer, pdb.getMonitor());
}
writer.write("End C13Sections---------------------------------------------\n");
@ -393,8 +387,7 @@ public class Module {
throws IOException, CancelledException, PdbException {
writer.write("GlobalReferenceSymbolOffsets--------------------------------\n");
List<Long> tmp = new ArrayList<>();
GlobalReferenceOffsetIterator globalRefsOffsetIterator =
getGlobalReferenceOffsetIterator();
GlobalReferenceOffsetIterator globalRefsOffsetIterator = getGlobalReferenceOffsetIterator();
while (globalRefsOffsetIterator.hasNext()) {
pdb.checkCancelled();
Long val = globalRefsOffsetIterator.next();
@ -405,6 +398,7 @@ public class Module {
GlobalReferenceOffsetIterator globalReferenceOffsetIterator =
getGlobalReferenceOffsetIterator();
while (globalReferenceOffsetIterator.hasNext()) {
pdb.checkCancelled();
long val = globalReferenceOffsetIterator.next();
long val2 = tmp.get(cnt++);
if (val != val2) {
@ -419,8 +413,7 @@ public class Module {
private void dumpGlobalReferences(Writer writer)
throws IOException, CancelledException, PdbException {
writer.write("GlobalReferenceSymbols--------------------------------------\n");
GlobalReferenceIterator globalReferenceIterator =
getGlobalReferenceIterator();
GlobalReferenceIterator globalReferenceIterator = getGlobalReferenceIterator();
while (globalReferenceIterator.hasNext()) {
pdb.checkCancelled();
MsSymbolIterator symIter = globalReferenceIterator.next();

View file

@ -53,8 +53,7 @@ public class Pdb700 extends AbstractPdb {
// Abstract Methods
//==============================================================================================
@Override
void deserializeDirectory()
throws IOException, PdbException, CancelledException {
void deserializeDirectory() throws IOException, PdbException, CancelledException {
PdbByteReader reader = getDirectoryReader();
deserializeVersionSignatureAge(reader);
guid = reader.parseGUID();

View file

@ -602,11 +602,11 @@ public abstract class PdbDebugInfo {
}
private void dumpSymbols(Writer writer) throws CancelledException, IOException, PdbException {
MsSymbolIterator iteratorx = getSymbolIterator();
MsSymbolIterator iterator = getSymbolIterator();
List<AbstractMsSymbol> symbols = new ArrayList<>();
while (iteratorx.hasNext()) {
while (iterator.hasNext()) {
pdb.checkCancelled();
symbols.add(iteratorx.next());
symbols.add(iterator.next());
}
}

View file

@ -313,8 +313,8 @@ public class PdbNewDebugInfo extends PdbDebugInfo {
pdb.checkCancelled();
int offset = substreamReader.parseInt();
bufferReader.setIndex(offset);
String name = bufferReader.parseNullTerminatedString(
pdb.getPdbReaderOptions().getOneByteCharset());
String name = bufferReader
.parseNullTerminatedString(pdb.getPdbReaderOptions().getOneByteCharset());
//if (name != null) {
if (name.length() != 0) {
realEntryCount++;
@ -336,9 +336,12 @@ public class PdbNewDebugInfo extends PdbDebugInfo {
* Dumps the EditAndContinueNameList. This package-protected method is for debugging only.
* @param writer {@link Writer} to which to write the debug dump
* @throws IOException on issue writing to the {@link Writer}
* @throws CancelledException upon user cancellation
*/
protected void dumpEditAndContinueNameList(Writer writer) throws IOException {
protected void dumpEditAndContinueNameList(Writer writer)
throws IOException, CancelledException {
for (String name : editAndContinueNameList) {
pdb.checkCancelled();
writer.write(String.format("Name: %s\n", name));
}
}

View file

@ -252,6 +252,7 @@ public class PublicSymbolInformation extends AbstractSymbolInformation {
builder.append("numAddressMapSymbolOffsets: " + myAddressMapSymbolOffsets.size() + "\n");
int num = 0;
for (Long val : myAddressMapSymbolOffsets) {
pdb.checkCancelled();
builder.append(String.format("0X%08X: 0X%012X\n", num++, val));
}
builder.append("\nEnd AddressMapSymbolOffsets---------------------------------\n");
@ -292,6 +293,7 @@ public class PublicSymbolInformation extends AbstractSymbolInformation {
builder.append("numThunkTargetOffsetsByTableOffset: " +
myThunkTargetOffsetsByTableOffset.size() + "\n");
for (Map.Entry<Integer, Integer> entry : myThunkTargetOffsetsByTableOffset.entrySet()) {
pdb.checkCancelled();
builder.append(String.format("0X%08X 0X%08X\n", entry.getKey(), entry.getValue()));
}
builder.append("\nEnd ThunkMap------------------------------------------------\n");

View file

@ -204,8 +204,9 @@ public abstract class TypeProgramInterface implements TPI {
* Dumps this class. This package-protected method is for debugging only
* @param writer {@link Writer} to which to write the debug dump
* @throws IOException on issue writing to the {@link Writer}
* @throws CancelledException upon user cancellation
*/
void dump(Writer writer) throws IOException {
void dump(Writer writer) throws IOException, CancelledException {
writer.write("TypeProgramInterfaceHeader----------------------------------\n");
dumpHeader(writer);
writer.write("\nEnd TypeProgramInterfaceHeader------------------------------\n");
@ -272,9 +273,11 @@ public abstract class TypeProgramInterface implements TPI {
* Dumps the Type Records. This method is for debugging only
* @param writer {@link Writer} to which to dump the records
* @throws IOException on issue writing to the {@link Writer}
* @throws CancelledException upon user cancellation
*/
protected void dumpTypeRecords(Writer writer) throws IOException {
protected void dumpTypeRecords(Writer writer) throws IOException, CancelledException {
for (int recordNum = typeIndexMin; recordNum < typeIndexMaxExclusive; recordNum++) {
pdb.checkCancelled();
AbstractMsType type = getRandomAccessRecord(recordNum);
StringBuilder builder = new StringBuilder();
builder.append("------------------------------------------------------------\n");

View file

@ -173,10 +173,13 @@ public class C13SectionsTest extends AbstractGenericTest {
PdbByteReader reader = new PdbByteReader(bytes);
FileChecksum fileChecksum = new FileChecksum(reader);
String result = fileChecksum.toString();
assertEquals("0x00001030, 0x40 Sha256ChecksumType(03): " +
//@formatter:off
assertEquals(
"0x00001030, 0x40 Sha256ChecksumType(03): " +
"00225566002255660022556600225566002255660022556600225566002255660022556600225566" +
"002255660022556600225566002255660022556600225566",
result);
//@formatter:on
}
@Test
@ -206,8 +209,10 @@ public class C13SectionsTest extends AbstractGenericTest {
C13Section section = C13Section.parse(reader, TaskMonitor.DUMMY);
assertTrue(section instanceof C13FileChecksums);
StringWriter writer = new StringWriter();
section.dump(writer);
assertEquals("C13FileChecksums--------------------------------------------\n" +
section.dump(writer, TaskMonitor.DUMMY);
//@formatter:off
assertEquals(
"C13FileChecksums--------------------------------------------\n" +
"0x00002000, 0x00 NoneChecksumType(00): \n" +
"0x00002010, 0x00 NoneChecksumType(00): \n" +
"0x00002020, 0x10 Md5ChecksumType(01): 554433221100ffeeddccbbaa99887766\n" +
@ -222,7 +227,9 @@ public class C13SectionsTest extends AbstractGenericTest {
"0x00002070, 0x40 Sha256ChecksumType(03): 00225566002255660022556600225566" +
"002255660022556600225566002255660022556600225566002255660022556600225566" +
"002255660022556600225566\n" +
"End C13FileChecksums----------------------------------------\n", writer.toString());
"End C13FileChecksums----------------------------------------\n",
writer.toString());
//@formatter:on
}
//==============================================================================================
@ -254,9 +261,9 @@ public class C13SectionsTest extends AbstractGenericTest {
* @return final byte array of checksum data
*/
private byte[] createC13Md5FileChecksumBytes(long offsetFilename) {
return createC13FileChecksumBytes(offsetFilename, 0x01, new byte[] { 0x55, 0x44, 0x33, 0x22,
0x11, 0x00, (byte) 0xff, (byte) 0xee, (byte) 0xdd, (byte) 0xcc, (byte) 0xbb,
(byte) 0xaa, (byte) 0x99, (byte) 0x88, 0x77, 0x66 });
return createC13FileChecksumBytes(offsetFilename, 0x01,
new byte[] { 0x55, 0x44, 0x33, 0x22, 0x11, 0x00, (byte) 0xff, (byte) 0xee, (byte) 0xdd,
(byte) 0xcc, (byte) 0xbb, (byte) 0xaa, (byte) 0x99, (byte) 0x88, 0x77, 0x66 });
}
/**
@ -336,8 +343,10 @@ public class C13SectionsTest extends AbstractGenericTest {
C13Section section = C13Section.parse(reader, TaskMonitor.DUMMY);
assertTrue(section instanceof C13Lines);
StringWriter writer = new StringWriter();
section.dump(writer);
assertEquals("C13Lines----------------------------------------------------\n" +
section.dump(writer, TaskMonitor.DUMMY);
//@formatter:off
assertEquals(
"C13Lines----------------------------------------------------\n" +
"offCon: 0x00004000 segCon: 1 flags: 0x00000000 lenCon: 0x00000010\n" +
"fileId: 001000, nLines: 3, lenFileBlock: 36\n" +
"16 0x00004100 Statement\n" +
@ -346,7 +355,9 @@ public class C13SectionsTest extends AbstractGenericTest {
"fileId: 002000, nLines: 2, lenFileBlock: 28\n" +
"32 0x00004200 Expression\n" +
"33 0x00004201 Expression\n" +
"End C13Lines------------------------------------------------\n", writer.toString());
"End C13Lines------------------------------------------------\n",
writer.toString());
//@formatter:on
}
@Test
@ -356,8 +367,10 @@ public class C13SectionsTest extends AbstractGenericTest {
C13Section section = C13Section.parse(reader, TaskMonitor.DUMMY);
assertTrue(section instanceof C13Lines);
StringWriter writer = new StringWriter();
section.dump(writer);
assertEquals("C13Lines----------------------------------------------------\n" +
section.dump(writer, TaskMonitor.DUMMY);
//@formatter:off
assertEquals(
"C13Lines----------------------------------------------------\n" +
"offCon: 0x00004000 segCon: 1 flags: 0x00000001 lenCon: 0x00000010\n" +
"fileId: 001000, nLines: 3, lenFileBlock: 48\n" +
" 16: 0- 16- 1 0x00004100 Statement\n" +
@ -366,7 +379,9 @@ public class C13SectionsTest extends AbstractGenericTest {
"fileId: 002000, nLines: 2, lenFileBlock: 36\n" +
" 32: 0- 32- 1 0x00004200 Expression\n" +
" 33: 2- 34- 3 0x00004201 Expression\n" +
"End C13Lines------------------------------------------------\n", writer.toString());
"End C13Lines------------------------------------------------\n",
writer.toString());
//@formatter:on
}
@Test
@ -376,8 +391,10 @@ public class C13SectionsTest extends AbstractGenericTest {
C13Section section = C13Section.parse(reader, TaskMonitor.DUMMY);
assertTrue(section instanceof C13IlLines);
StringWriter writer = new StringWriter();
section.dump(writer);
assertEquals("C13IlLines--------------------------------------------------\n" +
section.dump(writer, TaskMonitor.DUMMY);
//@formatter:off
assertEquals(
"C13IlLines--------------------------------------------------\n" +
"offCon: 0x00004000 segCon: 1 flags: 0x00000000 lenCon: 0x00000010\n" +
"fileId: 001000, nLines: 3, lenFileBlock: 36\n" +
"16 0x00004100 Statement\n" +
@ -386,7 +403,9 @@ public class C13SectionsTest extends AbstractGenericTest {
"fileId: 002000, nLines: 2, lenFileBlock: 28\n" +
"32 0x00004200 Expression\n" +
"33 0x00004201 Expression\n" +
"End C13IlLines----------------------------------------------\n", writer.toString());
"End C13IlLines----------------------------------------------\n",
writer.toString());
//@formatter:on
}
@Test
@ -396,8 +415,10 @@ public class C13SectionsTest extends AbstractGenericTest {
C13Section section = C13Section.parse(reader, TaskMonitor.DUMMY);
assertTrue(section instanceof C13IlLines);
StringWriter writer = new StringWriter();
section.dump(writer);
assertEquals("C13IlLines--------------------------------------------------\n" +
section.dump(writer, TaskMonitor.DUMMY);
//@formatter:off
assertEquals(
"C13IlLines--------------------------------------------------\n" +
"offCon: 0x00004000 segCon: 1 flags: 0x00000001 lenCon: 0x00000010\n" +
"fileId: 001000, nLines: 3, lenFileBlock: 48\n" +
" 16: 0- 16- 1 0x00004100 Statement\n" +
@ -406,7 +427,9 @@ public class C13SectionsTest extends AbstractGenericTest {
"fileId: 002000, nLines: 2, lenFileBlock: 36\n" +
" 32: 0- 32- 1 0x00004200 Expression\n" +
" 33: 2- 34- 3 0x00004201 Expression\n" +
"End C13IlLines----------------------------------------------\n", writer.toString());
"End C13IlLines----------------------------------------------\n",
writer.toString());
//@formatter:on
}
//==============================================================================================
@ -542,8 +565,7 @@ public class C13SectionsTest extends AbstractGenericTest {
return writer.get();
}
private byte[] createC13LinesColumnRecord(int offsetColumnStart,
int offsetColumnEnd) {
private byte[] createC13LinesColumnRecord(int offsetColumnStart, int offsetColumnEnd) {
PdbByteWriter writer = new PdbByteWriter();
writer.putUnsignedShort(offsetColumnStart);
writer.putUnsignedShort(offsetColumnEnd);
@ -572,11 +594,15 @@ public class C13SectionsTest extends AbstractGenericTest {
C13Section section = C13Section.parse(reader, TaskMonitor.DUMMY);
assertTrue(section instanceof C13CrossScopeExports);
StringWriter writer = new StringWriter();
section.dump(writer);
assertEquals("C13CrossScopeExports----------------------------------------\n" +
section.dump(writer, TaskMonitor.DUMMY);
//@formatter:off
assertEquals(
"C13CrossScopeExports----------------------------------------\n" +
"0x00000100, 0x00001000\n" +
"0x00000101, 0x00001001\n" +
"End C13CrossScopeExports------------------------------------\n", writer.toString());
"End C13CrossScopeExports------------------------------------\n",
writer.toString());
//@formatter:on
}
//==============================================================================================
@ -602,11 +628,15 @@ public class C13SectionsTest extends AbstractGenericTest {
C13Section section = C13Section.parse(reader, TaskMonitor.DUMMY);
assertTrue(section instanceof C13CrossScopeImports);
StringWriter writer = new StringWriter();
section.dump(writer);
assertEquals("C13CrossScopeImports----------------------------------------\n" +
section.dump(writer, TaskMonitor.DUMMY);
//@formatter:off
assertEquals(
"C13CrossScopeImports----------------------------------------\n" +
"0x00000100, 1 0x00001000\n" +
"0x00000101, 2 0x00002000 0x00002001\n" +
"End C13CrossScopeImports------------------------------------\n", writer.toString());
"End C13CrossScopeImports------------------------------------\n",
writer.toString());
//@formatter:on
}
//==============================================================================================
@ -636,12 +666,16 @@ public class C13SectionsTest extends AbstractGenericTest {
C13Section section = C13Section.parse(reader, TaskMonitor.DUMMY);
assertTrue(section instanceof C13InlineeLines);
StringWriter writer = new StringWriter();
section.dump(writer);
assertEquals("C13InlineeLines---------------------------------------------\n" +
section.dump(writer, TaskMonitor.DUMMY);
//@formatter:off
assertEquals(
"C13InlineeLines---------------------------------------------\n" +
"Signature: 0x000\n" +
"0x000001000, 0x000001, 256\n" +
"0x000002000, 0x000002, 512\n" +
"End C13InlineeLines-----------------------------------------\n", writer.toString());
"End C13InlineeLines-----------------------------------------\n",
writer.toString());
//@formatter:on
}
@Test
@ -651,12 +685,16 @@ public class C13SectionsTest extends AbstractGenericTest {
C13Section section = C13Section.parse(reader, TaskMonitor.DUMMY);
assertTrue(section instanceof C13InlineeLines);
StringWriter writer = new StringWriter();
section.dump(writer);
assertEquals("C13InlineeLines---------------------------------------------\n" +
section.dump(writer, TaskMonitor.DUMMY);
//@formatter:off
assertEquals(
"C13InlineeLines---------------------------------------------\n" +
"Signature: 0x001\n" +
"0x000001000, 0x000001, 256\n" +
"0x000002000, 0x000002, 512 0x000003 0x000004\n" +
"End C13InlineeLines-----------------------------------------\n", writer.toString());
"End C13InlineeLines-----------------------------------------\n",
writer.toString());
//@formatter:on
}
//==============================================================================================
@ -665,8 +703,7 @@ public class C13SectionsTest extends AbstractGenericTest {
recordsWriter.putInt(0x00); // InlineeLines signature
recordsWriter.putBytes(createC13InlineeLinesRecord(0x1000L + twiddle, 0x1, 0x100));
recordsWriter.putBytes(createC13InlineeLinesRecord(0x2000L + twiddle, 0x2, 0x200));
byte[] C13InlineeBytes =
createC13SectionBytes(C13Type.INLINEE_LINES, recordsWriter.get());
byte[] C13InlineeBytes = createC13SectionBytes(C13Type.INLINEE_LINES, recordsWriter.get());
return C13InlineeBytes;
}
@ -677,8 +714,7 @@ public class C13SectionsTest extends AbstractGenericTest {
.putBytes(createC13ExtendedInlineeLinesRecord(0x1000L, 0x1, 0x100, new int[] {}));
recordsWriter.putBytes(
createC13ExtendedInlineeLinesRecord(0x2000L, 0x2, 0x200, new int[] { 0x3, 0x4 }));
byte[] C13InlineeBytes =
createC13SectionBytes(C13Type.INLINEE_LINES, recordsWriter.get());
byte[] C13InlineeBytes = createC13SectionBytes(C13Type.INLINEE_LINES, recordsWriter.get());
return C13InlineeBytes;
}
@ -709,13 +745,14 @@ public class C13SectionsTest extends AbstractGenericTest {
PdbByteReader reader = new PdbByteReader(c13SectionsBytes);
StringWriter writer = new StringWriter();
C13SectionIterator<C13StringTable> iterator =
new C13SectionIterator<>(reader, C13StringTable.class, true,
TaskMonitor.DUMMY);
new C13SectionIterator<>(reader, C13StringTable.class, true, TaskMonitor.DUMMY);
while (iterator.hasNext()) {
C13Section c13Section = iterator.next();
c13Section.dump(writer);
c13Section.dump(writer, TaskMonitor.DUMMY);
}
assertEquals("C13StringTable----------------------------------------------\n" +
//@formatter:off
assertEquals(
"C13StringTable----------------------------------------------\n" +
"***NOT IMPLEMENTED*** Bytes follow...\n" +
"limit: 1\n" +
"index: 0\n" +
@ -746,7 +783,9 @@ public class C13SectionsTest extends AbstractGenericTest {
"first: 0\n" +
"last: 2\n" +
"000000 33 33\n" +
"End C13StringTable------------------------------------------\n", writer.toString());
"End C13StringTable------------------------------------------\n",
writer.toString());
//@formatter:on
}
@Test
@ -754,13 +793,14 @@ public class C13SectionsTest extends AbstractGenericTest {
PdbByteReader reader = new PdbByteReader(c13SectionsBytes);
StringWriter writer = new StringWriter();
C13SectionIterator<C13FileChecksums> iterator =
new C13SectionIterator<>(reader, C13FileChecksums.class, true,
TaskMonitor.DUMMY);
new C13SectionIterator<>(reader, C13FileChecksums.class, true, TaskMonitor.DUMMY);
while (iterator.hasNext()) {
C13Section c13Section = iterator.next();
c13Section.dump(writer);
c13Section.dump(writer, TaskMonitor.DUMMY);
}
assertEquals("C13FileChecksums--------------------------------------------\n" +
//@formatter:off
assertEquals(
"C13FileChecksums--------------------------------------------\n" +
"0x00002000, 0x00 NoneChecksumType(00): \n" +
"0x00002010, 0x00 NoneChecksumType(00): \n" +
"0x00002020, 0x10 Md5ChecksumType(01): 554433221100ffeeddccbbaa99887766\n" +
@ -823,7 +863,9 @@ public class C13SectionsTest extends AbstractGenericTest {
"0x00002073, 0x40 Sha256ChecksumType(03): 00225566002255660022556600225566" +
"002255660022556600225566002255660022556600225566002255660022556600225566" +
"002255660022556600225566\n" +
"End C13FileChecksums----------------------------------------\n", writer.toString());
"End C13FileChecksums----------------------------------------\n",
writer.toString());
//@formatter:on
}
@Test
@ -831,13 +873,14 @@ public class C13SectionsTest extends AbstractGenericTest {
PdbByteReader reader = new PdbByteReader(c13SectionsBytes);
StringWriter writer = new StringWriter();
C13SectionIterator<C13FrameData> iterator =
new C13SectionIterator<>(reader, C13FrameData.class, true,
TaskMonitor.DUMMY);
new C13SectionIterator<>(reader, C13FrameData.class, true, TaskMonitor.DUMMY);
while (iterator.hasNext()) {
C13Section c13Section = iterator.next();
c13Section.dump(writer);
c13Section.dump(writer, TaskMonitor.DUMMY);
}
assertEquals("C13FrameData------------------------------------------------\n" +
//@formatter:off
assertEquals(
"C13FrameData------------------------------------------------\n" +
"***NOT IMPLEMENTED*** Bytes follow...\n" +
"limit: 1\n" +
"index: 0\n" +
@ -868,7 +911,9 @@ public class C13SectionsTest extends AbstractGenericTest {
"first: 0\n" +
"last: 2\n" +
"000000 33 33\n" +
"End C13FrameData--------------------------------------------\n", writer.toString());
"End C13FrameData--------------------------------------------\n",
writer.toString());
//@formatter:on
}
@Test
@ -876,13 +921,14 @@ public class C13SectionsTest extends AbstractGenericTest {
PdbByteReader reader = new PdbByteReader(c13SectionsBytes);
StringWriter writer = new StringWriter();
C13SectionIterator<C13InlineeLines> iterator =
new C13SectionIterator<>(reader, C13InlineeLines.class, true,
TaskMonitor.DUMMY);
new C13SectionIterator<>(reader, C13InlineeLines.class, true, TaskMonitor.DUMMY);
while (iterator.hasNext()) {
C13Section c13Section = iterator.next();
c13Section.dump(writer);
c13Section.dump(writer, TaskMonitor.DUMMY);
}
assertEquals("C13InlineeLines---------------------------------------------\n" +
//@formatter:off
assertEquals(
"C13InlineeLines---------------------------------------------\n" +
"Signature: 0x000\n" +
"0x000001000, 0x000001, 256\n" +
"0x000002000, 0x000002, 512\n" +
@ -901,7 +947,9 @@ public class C13SectionsTest extends AbstractGenericTest {
"Signature: 0x000\n" +
"0x000001003, 0x000001, 256\n" +
"0x000002003, 0x000002, 512\n" +
"End C13InlineeLines-----------------------------------------\n", writer.toString());
"End C13InlineeLines-----------------------------------------\n",
writer.toString());
//@formatter:on
}
@Test
@ -909,13 +957,14 @@ public class C13SectionsTest extends AbstractGenericTest {
PdbByteReader reader = new PdbByteReader(c13SectionsBytes);
StringWriter writer = new StringWriter();
C13SectionIterator<C13CrossScopeImports> iterator =
new C13SectionIterator<>(reader, C13CrossScopeImports.class, true,
TaskMonitor.DUMMY);
new C13SectionIterator<>(reader, C13CrossScopeImports.class, true, TaskMonitor.DUMMY);
while (iterator.hasNext()) {
C13Section c13Section = iterator.next();
c13Section.dump(writer);
c13Section.dump(writer, TaskMonitor.DUMMY);
}
assertEquals("C13CrossScopeImports----------------------------------------\n" +
//@formatter:off
assertEquals(
"C13CrossScopeImports----------------------------------------\n" +
"0x00000100, 1 0x00001000\n" +
"0x00000101, 2 0x00002000 0x00002001\n" +
"End C13CrossScopeImports------------------------------------\n" +
@ -930,7 +979,9 @@ public class C13SectionsTest extends AbstractGenericTest {
"C13CrossScopeImports----------------------------------------\n" +
"0x00000103, 1 0x00001000\n" +
"0x00000104, 2 0x00002000 0x00002001\n" +
"End C13CrossScopeImports------------------------------------\n", writer.toString());
"End C13CrossScopeImports------------------------------------\n",
writer.toString());
//@formatter:on
}
@Test
@ -938,13 +989,14 @@ public class C13SectionsTest extends AbstractGenericTest {
PdbByteReader reader = new PdbByteReader(c13SectionsBytes);
StringWriter writer = new StringWriter();
C13SectionIterator<C13CrossScopeExports> iterator =
new C13SectionIterator<>(reader, C13CrossScopeExports.class, true,
TaskMonitor.DUMMY);
new C13SectionIterator<>(reader, C13CrossScopeExports.class, true, TaskMonitor.DUMMY);
while (iterator.hasNext()) {
C13Section c13Section = iterator.next();
c13Section.dump(writer);
c13Section.dump(writer, TaskMonitor.DUMMY);
}
assertEquals("C13CrossScopeExports----------------------------------------\n" +
//@formatter:off
assertEquals(
"C13CrossScopeExports----------------------------------------\n" +
"0x00000100, 0x00001000\n" +
"0x00000101, 0x00001001\n" +
"End C13CrossScopeExports------------------------------------\n" +
@ -959,7 +1011,9 @@ public class C13SectionsTest extends AbstractGenericTest {
"C13CrossScopeExports----------------------------------------\n" +
"0x00000103, 0x00001000\n" +
"0x00000104, 0x00001001\n" +
"End C13CrossScopeExports------------------------------------\n", writer.toString());
"End C13CrossScopeExports------------------------------------\n",
writer.toString());
//@formatter:on
}
@Test
@ -967,13 +1021,14 @@ public class C13SectionsTest extends AbstractGenericTest {
PdbByteReader reader = new PdbByteReader(c13SectionsBytes);
StringWriter writer = new StringWriter();
C13SectionIterator<C13IlLines> iterator =
new C13SectionIterator<>(reader, C13IlLines.class, true,
TaskMonitor.DUMMY);
new C13SectionIterator<>(reader, C13IlLines.class, true, TaskMonitor.DUMMY);
while (iterator.hasNext()) {
C13Section c13Section = iterator.next();
c13Section.dump(writer);
c13Section.dump(writer, TaskMonitor.DUMMY);
}
assertEquals("C13IlLines--------------------------------------------------\n" +
//@formatter:off
assertEquals(
"C13IlLines--------------------------------------------------\n" +
"offCon: 0x00004000 segCon: 1 flags: 0x00000000 lenCon: 0x00000010\n" +
"fileId: 001000, nLines: 3, lenFileBlock: 36\n" +
"16 0x00004100 Statement\n" +
@ -1012,7 +1067,9 @@ public class C13SectionsTest extends AbstractGenericTest {
"fileId: 002000, nLines: 2, lenFileBlock: 28\n" +
"32 0x00004200 Expression\n" +
"33 0x00004201 Expression\n" +
"End C13IlLines----------------------------------------------\n", writer.toString());
"End C13IlLines----------------------------------------------\n",
writer.toString());
//@formatter:on
}
@Test
@ -1020,13 +1077,14 @@ public class C13SectionsTest extends AbstractGenericTest {
PdbByteReader reader = new PdbByteReader(c13SectionsBytes);
StringWriter writer = new StringWriter();
C13SectionIterator<C13FuncMdTokenMap> iterator =
new C13SectionIterator<>(reader, C13FuncMdTokenMap.class, true,
TaskMonitor.DUMMY);
new C13SectionIterator<>(reader, C13FuncMdTokenMap.class, true, TaskMonitor.DUMMY);
while (iterator.hasNext()) {
C13Section c13Section = iterator.next();
c13Section.dump(writer);
c13Section.dump(writer, TaskMonitor.DUMMY);
}
assertEquals("C13FuncMdTokenMap-------------------------------------------\n" +
//@formatter:off
assertEquals(
"C13FuncMdTokenMap-------------------------------------------\n" +
"***NOT IMPLEMENTED*** Bytes follow...\n" +
"limit: 1\n" +
"index: 0\n" +
@ -1057,7 +1115,9 @@ public class C13SectionsTest extends AbstractGenericTest {
"first: 0\n" +
"last: 2\n" +
"000000 33 33\n" +
"End C13FuncMdTokenMap---------------------------------------\n", writer.toString());
"End C13FuncMdTokenMap---------------------------------------\n",
writer.toString());
//@formatter:on
}
@Test
@ -1065,13 +1125,14 @@ public class C13SectionsTest extends AbstractGenericTest {
PdbByteReader reader = new PdbByteReader(c13SectionsBytes);
StringWriter writer = new StringWriter();
C13SectionIterator<C13TypeMdTokenMap> iterator =
new C13SectionIterator<>(reader, C13TypeMdTokenMap.class, true,
TaskMonitor.DUMMY);
new C13SectionIterator<>(reader, C13TypeMdTokenMap.class, true, TaskMonitor.DUMMY);
while (iterator.hasNext()) {
C13Section c13Section = iterator.next();
c13Section.dump(writer);
c13Section.dump(writer, TaskMonitor.DUMMY);
}
assertEquals("C13TypeMdTokenMap-------------------------------------------\n" +
//@formatter:off
assertEquals(
"C13TypeMdTokenMap-------------------------------------------\n" +
"***NOT IMPLEMENTED*** Bytes follow...\n" +
"limit: 1\n" +
"index: 0\n" +
@ -1102,7 +1163,9 @@ public class C13SectionsTest extends AbstractGenericTest {
"first: 0\n" +
"last: 2\n" +
"000000 33 33\n" +
"End C13TypeMdTokenMap---------------------------------------\n", writer.toString());
"End C13TypeMdTokenMap---------------------------------------\n",
writer.toString());
//@formatter:on
}
@Test
@ -1110,13 +1173,14 @@ public class C13SectionsTest extends AbstractGenericTest {
PdbByteReader reader = new PdbByteReader(c13SectionsBytes);
StringWriter writer = new StringWriter();
C13SectionIterator<C13MergedAssemblyInput> iterator =
new C13SectionIterator<>(reader, C13MergedAssemblyInput.class, true,
TaskMonitor.DUMMY);
new C13SectionIterator<>(reader, C13MergedAssemblyInput.class, true, TaskMonitor.DUMMY);
while (iterator.hasNext()) {
C13Section c13Section = iterator.next();
c13Section.dump(writer);
c13Section.dump(writer, TaskMonitor.DUMMY);
}
assertEquals("C13MergedAssemblyInput--------------------------------------\n" +
//@formatter:off
assertEquals(
"C13MergedAssemblyInput--------------------------------------\n" +
"***NOT IMPLEMENTED*** Bytes follow...\n" +
"limit: 1\n" +
"index: 0\n" +
@ -1147,7 +1211,9 @@ public class C13SectionsTest extends AbstractGenericTest {
"first: 0\n" +
"last: 2\n" +
"000000 33 33\n" +
"End C13MergedAssemblyInput----------------------------------\n", writer.toString());
"End C13MergedAssemblyInput----------------------------------\n",
writer.toString());
//@formatter:on
}
@Test
@ -1155,13 +1221,14 @@ public class C13SectionsTest extends AbstractGenericTest {
PdbByteReader reader = new PdbByteReader(c13SectionsBytes);
StringWriter writer = new StringWriter();
C13SectionIterator<C13CoffSymbolRva> iterator =
new C13SectionIterator<>(reader, C13CoffSymbolRva.class, true,
TaskMonitor.DUMMY);
new C13SectionIterator<>(reader, C13CoffSymbolRva.class, true, TaskMonitor.DUMMY);
while (iterator.hasNext()) {
C13Section c13Section = iterator.next();
c13Section.dump(writer);
c13Section.dump(writer, TaskMonitor.DUMMY);
}
assertEquals("C13CoffSymbolRva--------------------------------------------\n" +
//@formatter:off
assertEquals(
"C13CoffSymbolRva--------------------------------------------\n" +
"***NOT IMPLEMENTED*** Bytes follow...\n" +
"limit: 1\n" +
"index: 0\n" +
@ -1192,7 +1259,9 @@ public class C13SectionsTest extends AbstractGenericTest {
"first: 0\n" +
"last: 2\n" +
"000000 33 33\n" +
"End C13CoffSymbolRva----------------------------------------\n", writer.toString());
"End C13CoffSymbolRva----------------------------------------\n",
writer.toString());
//@formatter:on
}
@Test