summaryrefslogtreecommitdiff
path: root/src/tools/r2rdump
AgeCommit message (Collapse)AuthorFilesLines
2019-06-25Remove the Crossgen-specific VSD flag from R2RDump (#25391)Tomáš Rylek2-8/+1
Based on JanK's advice I have removed the VSD flag from R2RDump. The flag should get never observed by the dump tool as it's just an intermediate contract internal to the Crossgen ZAP logic. Thanks Tomas
2019-06-03Avoid moving the bitOffset twice when enumerating safepointsAndrew Au1-2/+0
2019-05-30Add build-tools.cmd (#24817)Jan Vorlicek1-0/+1
* Add build-tools.cmd This script builds selected tools in the src/tools directory (for the time being, it builds just the runincontext tool). This is a preparation step to enable nightly runs with unloadability tests. The build-tools.cmd should build helper tools needed during test runs. * Remove the build-tools.cmd * Build the tools as part of the managed runtime build. * Update the R2RDump project to put binaries into the bin/Product/... * Update runincontext.cmd/sh scripts Reflect the new location of the runincontext binary
2019-05-30Implement R2R helpers for synchronized methods (#24646)Michal Strehovský1-0/+4
Synchronized methods show up when `Console` is used and the missing helper mapping would cause us not to AOT compile them.
2019-05-28Fixing the epilog size decodingAndrew Au3-14/+3
2019-05-23Fewer ilstubs in corelib from reflection apis (#24708)David Wrighton1-1/+5
Rework use of marshalling for RuntimeTypeHandle, RuntimeModule, RuntimeAssembly, and IRuntimeMethodInfo as used by QCalls - Remove special QCall only used marshallers for RuntimeAssembly, RuntimeModule and IRuntimeMethodInfo - Following the pattern of ObjectHandleOnStack, implement QCall handle types for RuntimeAssembly/Module/TypeHandle. Use these in all QCalls that once passed the types directly. - For uses of IRuntimeMethodInfo, follow the existing RuntimeMethodHandleInternal pattern Also perform some replacement of bool marshalling with use of Interop.BOOL, and a few cases of using pointers instead of byref arguments. Fix delivers a relatively small win on startup, and small throughput gains around reflection as IL stubs are no longer necessary for many functions in reflection that once needed them. Reduces methods jitted on powershell startup from 422 to 399, (About 5%) but performance win is only about 5ms on ~400ms as the methods removed are simple.
2019-05-20Cuckoo metadata (#24498)David Wrighton4-0/+69
* Basic infra for cuckoo filter of attributes - Implement cuckoo filter lookup logic - Implement new ready to run section - Add dumper to R2RDump - Parse section on load into data structure - Implement function to query filter - Add concept of enum of well known attributes - So that attribute name hashes themselves may be cached * Wrap all even vaguely perf critical uses of attribute by name parsing with use of R2R data * Update emmintrin.h in the PAL header to contain the needed SSE2 intrinsics for the feature - Disable the presence table for non Corelib cases. Current performance data does not warrant the size increase in other generated binaries
2019-05-14Further improvements for R2RDump robustness in the presence of bugs (#24429)Tomáš Rylek2-2/+23
Based on JanV's suggestion I have added checks for token ranges to MetadataNameFormatter to make it resilient towards invalid tokens. Thanks Tomas
2019-05-06Improve R2RDump resiliency towards invalid tokens (#24379)Tomáš Rylek2-23/+54
This change adds a bunch of try blocks that make R2RDump survive partially corrupted input. Thanks Tomas
2019-05-06Port all managed product binaries to use SDK style projects (#24285)Aaron Robinson1-5/+2
Convert managed product binary to use SDK project system. - Uses Arcade for versions strings - Overrides Arcade defined output paths - should change in the future
2019-05-03New options --sb / --isb for binary signature dump (#24375)Tomáš Rylek3-56/+161
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-05-02Bug fix in R2RDump signature decoder w.r.t. large version bubbles (#24352)Tomáš Rylek1-6/+14
JanV discovered a complex signature where the generic type argument got decoded in an incorrect module context by R2RDump. Investigating the issue I found out that the problem was caused by my slight misunderstanding - all module override indices within a signature are relative to the global signature context module, not to the current context module that may change during descent into the signature tree. Thanks Tomas
2019-04-30Support for larger version bubbles in R2RDump (#24277)Tomáš Rylek8-132/+343
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-04-01Enable R2R compilation/inlining of PInvoke stubs where no marshalling is ↵Fadi Hanna2-0/+19
required (#22560) * These changes enable the inlining of some PInvokes that do not require any marshalling. With inlined pinvokes, R2R performance should become slightly better, since we'll avoid jitting some of the pinvoke IL stubs that we jit today for S.P.CoreLib. Performance gains not yet measured. * Added JIT_PInvokeBegin/End helpers for all architectures. Linux stubs not yet implemented * Add INLINE_GETTHREAD for arm/arm64 * Set CORJIT_FLAG_USE_PINVOKE_HELPERS jit flag for ReadyToRun compilations * Updating R2RDump tool to handle pinvokes
2019-03-25Miscellaneous R2RDump improvements (#23215)Tomáš Rylek4-70/+42
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
2019-02-22R2RDump - Gracefully handle inability to parse GC InfoSimon Nattress1-1/+9
The Amd64 GC Info parser is not complete in its implementation and sometimes will index to a location beyond the size of the image. If we fail to parse the GC info for a method, continue dumping the rest of the image. Emit a warning when this happens so we don't forget about this.
2019-02-22Store information about partial ngen in R2R images (#22680)Michal Strehovský1-1/+2
2019-02-01Support for dumping GC info in R2RDump (#22216)Tomáš Rylek1-1/+44
Thanks to tons of help from Jan Vorlicek I found out that a huge failure bucket in the CoreCLR Pri#1 tests is caused by incorrect GC info for generic methods causing failures in catch clauses where the exception type is a generic referring to a generic parameter of the method. As part of investigation of this issue I'm adding provisions for dumping the GC info alongside methods to make the differences between CPAOT and Crossgen easier to analyze. For now I have only implemented the AMD64 variant of the GC info. Thankfully it turns out that the same GC info is used by both ARM32 and ARM64 so that the only remaining debt is supplying a variant of the new code for X86. Thanks Tomas
2019-01-07Fix incorrect assignment of READYTORUN_HELPER_[Dbl|Flt][Rem/Round] (#21836)Tomáš Rylek1-4/+4
Turns out there's a long-standing typo in CoreCLR that reverses the helper enumeration values for DBL and FLT. This doesn't seem to be a problem in the CoreCLR repo as such because it solely uses the legacy identifiers CORINFO_HELP_DBLREM et al. We have however ported the incorrect helper enumeration values into R2RDump and ILCompiler. This change immediately fixes R2RDump as it resides in the same repo, I'll send out the ILCompiler change in a separate PR.
2018-12-24Add Module Override Recognition to R2RDump (#21617)Andon Andonov2-4/+32
This was added to help debug work with large version bubbles. The changes should allow R2RDump to have some rudimentary understanding of ENCODE_METHOD_OVERRIDE. The big TODO here is allow loading of external dependency assemblies to be able to resolve the tokens coming after the override.
2018-12-18Add support for parsing field signatures (#21573)Tomáš Rylek1-16/+62
This change adds basic field signature parsing support to R2RDump and it improves parsing of two fixup types (FIELD_ADDRESS and CCTOR_TRIGGER). Thanks Tomas
2018-12-15Implement GC ref map parsing and display in R2RDump (#21509)Tomáš Rylek9-74/+553
As part of my work on CPAOT implementation of GC ref map info I have implemented decoder of the info so that it can be displayed next to the import cell signatures. This also uncovered one possible cause of R2RDump GcInfo-related crashes that were observed by Andon and myself. It looks like Amy in her initial implementation confused the various GC encodings and used GC info to parse the import section auxiliary data which actually contains the GC ref map info. Thanks Tomas
2018-12-03Improvements for naked R2RDump output (#21317)Tomáš Rylek5-83/+78
The initial impulse for this change was removing native offsets from debug info that caused noise in naked R2R comparisons. Fixing this required propagation of DumpOptions to some more call sites prompting me to unify dumping logic to always use TextWriter as the output medium. I have also fixed some minor bugs I noticed around the naked disassembly. Thanks Tomas
2018-11-13Initial support for normalized 'naked' R2RDump output (#20875)Tomáš Rylek7-70/+271
* 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-16Structured dump of instance entrypoints and decoding generic lookups (#20433)Tomáš Rylek3-13/+44
1) Dump method signatures in the INSTANCE_METHOD_ENTRYPOINTS section; 2) Add logic for decoding generic lookups; 3) Add previously missing support for dumping MVAR index. Thanks Tomas
2018-10-10Minor dump improvements in R2RDump (#20344)Tomáš Rylek4-23/+22
* 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áš Rylek6-216/+278
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-10-03Fix X86 disassembly and a bug regarding ExportedTypes in R2RDump (#20230)Tomáš Rylek2-50/+138
1) X86 CoreDisTools disassembler has a bug in decoding absolute indirections, interpreting them as RIP-relative offsets. I have reused the logic that's already in place for patching X64 RIP-relative addresses to take care of this additional case. 2) the CoreDisTools disassembly apparently only produces newline (0A) characters that don't work well in Notepad and other viewers; I have forcibly replaced them with the platform newline separator. 3) I hit a bug in available type decoding - the logic wasn't properly checking whether the type is exported or not. Thanks Tomas
2018-09-20Fix decoding bug in r2rdump's native format readerSimon Nattress1-1/+2
Sign extension is done based on a 32-bit int. We were incorrectly basing it off the size of a byte.
2018-09-20Make EH table optional in R2RDumpSimon Nattress1-3/+6
Ready-to-run binaries don't always have an EH table. Fix r2rdump so it doesn't crash if the table isn't present.
2018-09-18Add EH info support to R2RDump (#20000)Tomáš Rylek3-2/+309
* Add EH info support to R2RDump This change expands runtime function dump to include the exception handling info looked up via the EXCEPTION_INFO R2R header table. * Address Zach's PR feedback 1) Base EHClause.Length on sizeof(uint) instead of sizeof(int) for consistency with the asctual data types in the class. 2) Fix my overlooking that Zach spotted - in the EHLookupTable ctor, we need to assign rva2 and eh2 to rva1 and eh1 at the end of the loop block as we need to traverse consecutive pairs of CORCOMPILE_EXCEPTION_LOOKUP_TABLE_ENTRY elements. * Addressed Bruce Forstall's PR feedback 1) I modified the EH info method ctors to accept the R2RReader instead of the raw byte[] image as the reader can be used to provide textual representations of metadata tokens. 2) I changed the mask test to a switch that throws an exception if multiple of the three lowest bits are set which is illegal according to Bruce. * Addressed additional Bruce Forstall's PR feedback Remove interpretation of ClassTokenOrFilterOffset as it's not applicable in the FINALLY and FAULT cases. Thanks Tomas
2018-09-08Add DebugInfo dumping support to r2rdumpSimon Nattress5-2/+386
Display formatted debug info for each runtime function
2018-09-07Import signature parsing and general improvements in R2RDump (#19813)Tomáš Rylek12-175/+1832
* 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-28Merge pull request #19053 from riverar/riverar/r2r_size_unavailSimon Nattress1-0/+4
Set function size to -1 if sizing info unavailable
2018-08-28Add architectures supported tableAmy Yu1-2/+19
2018-08-25R2RDump - Non-Windows machine code (#19638)Amy2-4/+29
* Get machine architecture for non-Windows images * Update readme * Throw exception if machine is invalid, output OS * Capitalization
2018-08-25R2RDump - Fix errors caused by ExportedTypes rids in AvailableTypes section ↵Amy2-6/+62
(#19647) * Fix error caused by exportedType in AvailableTypes section * TypeDef and ExportedType can both have the same rid * Use HashSet instead of Dictionary
2018-08-25R2RDump - Check disassembler support (#19664)Amy3-22/+15
* Determine if disasm is supported on architectures instead of match * Readme changes
2018-08-24R2RDump - ARM and ARM64 UnwindInfo (#19618)Amy12-23/+530
* UnwindInfo for Arm * ARM64 unwindInfo, change Machine.Arm to Machine.ArmThumb2 * Fix incorrect location of UnwindCode and GcTransition in the disasm * Use x64 GcInfo for Arm and Arm64 * Cleanup, update readme
2018-08-23Two R2RDump fixes for Crossgen output (#19585)Tomáš Rylek1-2/+20
1) In some situations, Crossgen emits a section with EntrySize = 0. Apparently the engine defaults to size_t in such case. 2) Similarly, Crossgen sometimes emits a section with the UNKNOWN kind. I have relaxed the section kind check to just treat all non-eager section kinds the same. Thanks Tomas
2018-08-21R2RDump - Interweave x64 unwind codes into disasm (#19577)Amy6-77/+108
* Interweave unwind codes into disasm, fix incorrect x64 register names * Fix xml dump errors
2018-08-20R2RDump - Add image describing R2R format (#19528)Amy3-3/+7
* 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 Montoya3-13/+41
* 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áš Rylek3-17/+246
* 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)Amy23-34/+322
* Add comments * Add README * Use href links, disable disasm
2018-08-15R2RDump - GcInfo for x86Amy Yu19-129/+1888
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áš Rylek4-19/+106
* 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)Amy2-3/+27
* Ignore sensitive properties in tests * Enable for JIT stress * Keep logic for ignoreSensitive in XmlDumper * Only ignoreSensitive when option is set
2018-07-31R2RDump - Fix and update R2RDumpTests (#19039)Amy4-27/+49
* Fix GenericFunctions and MultipleRuntimeFunctions tests, x86 nwindInfo tests * Fix tests * Avoid using rva as index * Update expected xml * Add count as an attribute * Clean up and move rebaseline script to r2rdump test directory * Remove R2RDumpTest warnings * Use original test framework instead of netcoreapp2.0
2018-07-23R2RDump - UnwindInfo for x86 (#18994)Amy5-5/+65
* UnwindInfo for x86 * Update tests