summaryrefslogtreecommitdiff
path: root/src/tools/r2rdump/R2RDump.cs
AgeCommit message (Collapse)AuthorFilesLines
2019-05-06Improve R2RDump resiliency towards invalid tokens (#24379)Tomáš Rylek1-1/+1
This change adds a bunch of try blocks that make R2RDump survive partially corrupted input. Thanks Tomas
2019-05-03New options --sb / --isb for binary signature dump (#24375)Tomáš Rylek1-0/+4
Based on JanV's suggestion I have added two new options to R2RDump: "--sb" (SignatureBinary) appends the binary signature representation at the end of the parsed textual signature; "--isb" (InlineSignatureBinary) inlines the signature bytes into the parsed textual signature and makes it (somewhat) easy to correlate the binary bytes with individual parts of the signature. Thanks Tomas
2019-04-30Support for larger version bubbles in R2RDump (#24277)Tomáš Rylek1-1/+46
After JanV fixed basically all test failures related to larger version bubbles originally implemented by Andon, it's high time to fix R2RDump for its support as a prerequisite to enabling larger version bubbles in CPAOT. This change implements this support via the following particular changes: 1) In DumpOptions, I added a list of explicit assembly references, another list of reference paths that are used for resolving assembly references, a cache for repeated assembly lookups and a new method FindAssembly for file resolution of a given simple assembly name. 2) I have moved ECMA metadata-related logic from R2RReader to its new base class EcmaMetadataReader. This class can represent both R2R and MSIL binaries and adds the logic for reference assembly lookup. 3) Large version bubble R2R PE exe's contain a special R2R header table READYTORUN_SECTION_MANIFEST_METADATA that contains ECMA metadata with a list of extra AssemblyRef's on top of those stored in the original MSIL. I have added support for parsing this table to the R2RReader constructor. 4) I have modified R2RSignature to be based off the new EcmaMetadataReader instead of R2RReader which cannot represent arbitrary reference assemblies. I have patched the two places dealing with module overrides to use the new logic to temporarily switch to a "remote module" SignatureDecoder for the purpose of parsing an external entity. 5) I have removed temporary hacks Andon put in place to keep R2RDump alive in some cases with larger version bubbles without proper support for parsing module overrides. 6) I have added logic for dumping the contents of the manifest metadata along with the standard AssemblyRef table to the header dump as I fought with recalculation of the indices when debugging larger version bubble code for quite some time. 7) As an extra half-forgotten bit from the past I added dumping of unboxing and instantiation stubs. I have noticed that the MSIL AssemblyRef count was off by one. I have also found out that XML output has bitrotten over time. This additional delta fixes both issues. [That forced me to add a bunch of empty ctors even though in practice we don't actually serialize anything into the dumper, we only use the XML serializer to emit the XML output file. Thanks Tomas
2019-03-25Miscellaneous R2RDump improvements (#23215)Tomáš Rylek1-1/+1
1) In Naked mode, hide the distinction amongst METHOD_ENTRY vs. METHOD_ENTRY_REF_TOKEN vs. METHOD_ENTRY_DEF_TOKEN as it's not important for correctness and causes undesirable churn in diffs. This required propagating the DumpOptions around in a couple of places. 2) For historical reasons, the DisassemblingTypeProvider had its own implementations of metadata formatting that is now provided by MetadataNameFormatter. I have removed at least a part of this duplication in this change. [It was causing undesirable diffs as one version used to output type owner assemblies whereas the other did not.] Thanks Tomas
2018-11-13Initial support for normalized 'naked' R2RDump output (#20875)Tomáš Rylek1-5/+23
* Initial support for normalized 'naked' R2RDump output This change introduces a new option "--naked" that takes output normalization even further - it intentionally leaves out any position information to make the output easier to diff between CPAOT and Crossgen. One other new option is "--entrypoints" which dumps a plain list of JITted methods in the R2R executable. This can be used for comparisons between CPAOT and Crossgen and / or for static analysis of what methods were actually emitted by the compiler. * Addressed Zach's PR feedback 1) Added argument consistency check for the invalid combination "--naked" + "--raw". 2) Added dump of multi-dimensional array lower bounds and sizes when available. Thanks Tomas
2018-10-10Minor dump improvements in R2RDump (#20344)Tomáš Rylek1-1/+1
* Minor dump improvements in R2RDump 1) Don't silently unify available types; 2) Display RVA's for import cells to enable searching the cell by RVA in the dump; 3) Display cell signatures for method precodes.
2018-10-04R2RDump fixes for dumping method instance entrypoint table (#20243)Tomáš Rylek1-32/+64
R2RDump fixes for dumping method instance entrypoint table While investigating Michal's unit test demonstrating a bug in the CPAOT compiler I found out that R2RDump is broken in multiple aspects w.r.t. instantiated methods. Parsing of the method signatures in the instance entrypoint table was just broken and the R2RMethod was duplicating parts of the signature decoding and name formatting process. I created a new flag "normalize" that requests normalization of various R2R tables in the dump aimed at improving diff quality. I have also noticed and fixed somewhat weird formatting of method signatures. As a slight cleanup I have lumped the various dump flags into a helper class DumpOptions. Last but not least I have renamed "Canon" to "__Canon". Thanks Tomas
2018-09-07Import signature parsing and general improvements in R2RDump (#19813)Tomáš Rylek1-1/+1
* Import signature parsing and general improvements in R2RDump GcInfo - fixed a bug where the machine architecture was stored in the instance field later than it was used in the calculation of SlotTable which subsequently ended up with the wrong register set (ARM64 instead of AMD64). GcTransition - changed register set selector to a switch as the previous implementation was incorrect for AMD64. UnwindInfo - bug fix: the 4-alignment padding should come before the personality routine, not after it. I have also slightly simplified the calculation of the padding size. CoreDisTools - added support for annotating indirect calls with symbol information for the import cells; fixed formatting of short relative jumps and added some code comments. DisassemblingTypeProvider - bumped up some visibilities and made a few generalizations letting me use this helper in the general signature parser. R2RImportSection - replaced binary signature samples with the actual parsed representation. R2RReader - I removed special-casing for eager import signatures that seems wrong - I don't see any equivalent code in the CoreCLR runtime. Please let me know if anyone is aware of a reason why this was put here in the first place. TextDumper and elsewhere - I have removed all tabs from the R2RDump tool output. R2RConstants - I have merged the various CoreCLR and R2R constants in this file - previously they were interspersed in multiple classes - and I added a bunch of new stuff needed by the signature parser. R2RSignature - comprises the newly added R2R signature parser. Thanks Tomas * Slight modification in signature formatting to make it easier to read I have swapped the ordering of the signature content with the signature name - based on analyzing actual disassembly produced by the code I came to the conclusion that the parsed signature is generally more important than the cell fixup type which is often obvious just based on the code context. Thanks Tomas * Add dump of unwind info and RVA translation for near jumps / calls * Add code comment on GetInstruction return value per PR feedback
2018-08-25R2RDump - Check disassembler support (#19664)Amy1-5/+2
* Determine if disasm is supported on architectures instead of match * Readme changes
2018-08-20R2RDump - Add image describing R2R format (#19528)Amy1-1/+1
* Add image describing R2R format * Remove help message stating -v option dumps raw bytes
2018-08-20Update Microsoft.NETCore.CoreDisTools to version 1.0.1-prerelease-00005 (#19520)Zach Montoya1-3/+11
* Update Microsoft.NETCore.CoreDisTools to version 1.0.1-prerelease-00005. Temporarily add a direct reference to the win-x64 and win-x86 runtime packages * Change Microsoft.NETCore.CoreDisTools package references to the identity package. Improve formatting of R2RDump.csproj properties. * Add an ArgumentException to explain the currently faulty behavior where disassembling an R2R image whose architecture is different than the coredistools.dll architecture. * Add Issue #19564 to the R2RDump.cs Disassembler comment
2018-08-18Initial support for R2R image diff (#19533)Tomáš Rylek1-3/+17
* Initial support for R2R image diff In this first cut I'm adding just three size diff statistics - PE section size diff, R2R section size diff and method size diffs. I assume we'll add more statistics as needed in the course of various size investigations. Thanks Tomas
2018-08-16R2RDump - Documentation (#19497)Amy1-0/+2
* Add comments * Add README * Use href links, disable disasm
2018-08-15R2RDump - GcInfo for x86Amy Yu1-7/+23
x86 GcInfo headers x86 GcSlotTable x86 GcTransitions Update expected xml for R2RDumpTests Add license headers Allow multiple GcTransitions with same codeOffset Add index property in GcSlot, make GcSlot a class instead of struct, add missing spaces, update tests Remove placeholder functions for parsing partially interruptible pointer tables Implement partially interruptible GcInfo Example GcInfo output: CodeLength: 22 bytes InfoHdr: PrologSize: 7 EpilogSize: 4 EpilogCount: 1 EpilogAtEnd: yes Callee-saved regs = EBP EbpFrame: yes Fully Interruptible: yes DoubleAlign: no Arguments Size: 0 DWORDs Stack Frame Size: 1 DWORDs UntrackedCnt: 1 VarPtrTableSize: 0 GenericsContext: 0 GenericsContextIsMethodDesc: 0 ReturnKind: RT_Scalar RevPInvokeOffset: 0 Epilogs: 18 GcSlots: ------------------------- [EBP-4] Flags: GC_SLOT_UNTRACKED LowBits: ------------------------- 28fc: 55 push ebp 28fd: 8b ec mov ebp, esp 28ff: 50 push eax 2900: 89 4d fc mov dword ptr [ebp - 4], ecx 2903: 8b 4d fc mov ecx, dword ptr [ebp - 4] 2906: ff 15 10 10 01 10 call dword ptr [268505104] reg ECX becoming live 290c: 90 nop reg ECX becoming dead 290d: 90 nop 290e: 8b e5 mov esp, ebp 2910: 5d pop ebp 2911: c3 ret
2018-08-14Translate [rip +- offset] to absolute RVA's in R2RDump (#19219)Tomáš Rylek1-11/+11
* Translate [rip +- offset] to absoluate RVA's in R2RDump The existing logic for displaying rip-relative addressed on X64 make it very hard to calculate the final addresses. I have added a horrendous hack using textual analysis of the disassembled instruction to translate this notation to absolute RVA's. As part of this effort I have also encapsulated the CorDisTools helper in a new class Disassembler that also contains customizable provisions for handling special assembly cases on the individual architectures. Thanks Tomas * Temporarily block out disassembly to make tests pass In my initial commit I removed the line blocking out disassembly however this ends up failing several lab tests so I'm putting the line back. Thanks Tomas
2018-08-06R2RDump - Ignore sensitive properties to pass tests (#19155)Amy1-1/+3
* Ignore sensitive properties in tests * Enable for JIT stress * Keep logic for ignoreSensitive in XmlDumper * Only ignoreSensitive when option is set
2018-07-18R2RDump - Test infrastructure (#18745)Amy1-5/+22
* Test infrastructure for R2RDump, compare xml and output diff * Add R2RDumpTest to build-tests * Fix errors causing tests to fail * Create XUnitWrapper for R2RDumpTest * Generate readytorun binaries from source code, copy expected xml output files to executable's directory * Test R2RDump through commandline instead of calling R2RDump functions * Fix errors * Prevent duplicate xml tags * Read test xml from string instead of file * Fix test bugs * Call dotnet r2rdump from msbuild * Fix errors * Use right slash for paths in bash * Use different expected xml for different architectures * R2RDumpTests for non-Windows * Add more test cases * Fix errors * Supress warnings, avoid error when parsing x86 images * Add license headers
2018-06-26Dump disasm line by line, changes to dumping bytes to xml, fixAmy Yu1-1/+2
compilerIdentifier typo
2018-06-26Refactor into TextDumper and XmlDumper classesAmy Yu1-522/+60
2018-06-26Xml serialize section contents and gcinfo transitionsAmy Yu1-12/+28
2018-06-26XMLSerialize gc transitions and section contentsAmy Yu1-38/+83
2018-06-26Output in xml format with XmlSerializerAmy Yu1-81/+297
2018-06-22Move Amd64 specific class to it's own folder and subnamespaceAmy Yu1-1/+1
2018-06-19Make unwind info specific to amd64Amy Yu1-1/+1
2018-06-19Parse entries of import sectionAmy Yu1-1/+25
2018-06-19Dump bytes with offset instead of rvaAmy Yu1-3/+5
2018-06-19Parse and dump compiler identifier and import sections, move dump section ↵Amy Yu1-36/+46
contents to own function
2018-06-19Dump contents of NativeArray and NativeHashtableAmy Yu1-10/+37
2018-06-19Output formatting changes for unwindInfo and section contentsAmy Yu1-7/+11
2018-06-15Interweave gcslot liveness with disasmAmy Yu1-6/+3
2018-06-15Use IntPtr instead of long for pointersAmy Yu1-1/+1
2018-06-08Use buffered disassembler to get disassembly as stringAmy Yu1-1/+1
2018-06-07GcInfo belongs to method, not runtime functionAmy Yu1-9/+10
2018-06-06Refactoring gcInfo, added verbose option to cliAmy Yu1-2/+13
2018-06-06Fix unwindInfo bug caused by missing alignmentPad, dump raw byes of ↵Amy Yu1-0/+8
unwindInfo and gcInfo
2018-06-06Read slot table, dump GcInfoAmy Yu1-7/+14
2018-06-06R2RDump - Unwind Info (#18248)Amy1-0/+9
* Extract unwind info from image * Use typeDef.Namespace to get full namespace, move to separate function * Avoid passing R2RReader to R2RMethod and RuntimeFunction constructors * Dump unwind info * Changes to unwindInfo output format
2018-06-04R2RDump - Dump AvailableTypes section contents (#18227)Amy1-2/+23
* Move R2RReader constructor to separate functions, parse READYTORUN_SECTION_AVAILABLE_TYPES * Fix bug from merging, output formatting changes * Rename availableTypes variables, save availableTypes as string instead of tuple
2018-06-01Added disassembler CoreDisTools to dump runtime functions (#18180)Amy1-3/+22
Remove obsolete targets Remove unused NewDiffer function, fix error with uninitialized declaringTypeHandle
2018-06-01R2RDump - Commandline interface (#18136)Amy1-19/+434
* Use ReadCompressedData for NativeHashTable, fix ref signature types, save array dimension, use AppendLine to avoid line-ending problems * Include System.CommandLine, arg parsing, read/write file * Add commandline options to search sections/methods/runtimeFunctions, option to dump raw data * Added comments, save cli options in global variables, renamed some functions * Add DumpByte function to R2RSection and R2RHeader, indent raw bytes * Change some cli option names, use DumpRuntimeFunction, return list of query matches, changes to ArgStringToInt * Move DumpBytes to R2RDump, print method of runtime function * Use writer object instead of Console * Use TextWriter instead of own writer class * Handle jagged arrays and other cases using MethodDefinition.DecodeSignature with a slightly modified DisassemblingTypeProvider * Close the _writer in finally block
2018-05-23R2RDump - Dump generic method instances (#18080)acmyu1-2/+2
* R2RDump - dump generic method instances * Added comments * Move read functions to own class, changes to NativeHashtable to make it similar to NativeFormatReader * Get type name for struct generic instances * Emit # of runtimeFunctions and size:unavailable, add [Flags] to enum and NONE flag * Throw exception when method entrypoint id is out of bounds * Type name instead of var * Get full classname including namespace * Get parent types of nested types * Save DeclaringType as string, rename variables, use 1 constructor * Check generic param indices not out of bounds
2018-05-17R2RDump - Runtime function RVAs and method signatures (#17994)acmyu1-3/+16
* R2RDump - Runtime function RVAs and sizes * Change hard error to warning, GetInt64,32,16 helper functions * Method signatures from metadata, GetUnsigned functions, arbitrary sections for GetOffset * Use methodDefEntryPoints to match method metadata to native code, make runtime function endAddress conditional on machine type * Get object arg and return types of method signature from TypeDef, use ReadUInt * Iterate all rids, added NativeArray class * Handle multiple runtime functions in a method, use ReadByte, make rid unsigned * Use MethodDefinitionHandle(rid) instead of dictionary, make ReadByte signature similar to other Read methods * Changes to getting runtime functions, increment the start index in ReadByte, added comments * Use List for R2RMethods instead of array, fixed nits
2018-05-14R2RDump - Print ReadyToRun image headers (#17942)acmyu1-0/+45
* R2RDump - Outputing ReadyToRun header from PE image * R2RDump - Comments, follow coding guidelines, use enum for section types and flags * R2RDump - Use utf8 encoding, rva from ManagedNativeHeader, return exit code