diff options
author | Amy <amycmyu@gmail.com> | 2018-08-06 10:29:08 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-08-06 10:29:08 -0700 |
commit | c056fe7375c61b952d7f40d7d09800ea1ae0bdc1 (patch) | |
tree | 78db4541a5d814d56c232973f24e307149d2a87b /src/tools/r2rdump | |
parent | ac8f8e52c49b0ffa712d68730a41883d281bea01 (diff) | |
download | coreclr-c056fe7375c61b952d7f40d7d09800ea1ae0bdc1.tar.gz coreclr-c056fe7375c61b952d7f40d7d09800ea1ae0bdc1.tar.bz2 coreclr-c056fe7375c61b952d7f40d7d09800ea1ae0bdc1.zip |
R2RDump - Ignore sensitive properties to pass tests (#19155)
* Ignore sensitive properties in tests
* Enable for JIT stress
* Keep logic for ignoreSensitive in XmlDumper
* Only ignoreSensitive when option is set
Diffstat (limited to 'src/tools/r2rdump')
-rw-r--r-- | src/tools/r2rdump/R2RDump.cs | 4 | ||||
-rw-r--r-- | src/tools/r2rdump/XmlDumper.cs | 26 |
2 files changed, 27 insertions, 3 deletions
diff --git a/src/tools/r2rdump/R2RDump.cs b/src/tools/r2rdump/R2RDump.cs index aa9413160a..2391de0a0b 100644 --- a/src/tools/r2rdump/R2RDump.cs +++ b/src/tools/r2rdump/R2RDump.cs @@ -61,6 +61,7 @@ namespace R2RDump private TextWriter _writer; private Dictionary<R2RSection.SectionType, bool> _selectedSections = new Dictionary<R2RSection.SectionType, bool>(); private Dumper _dumper; + private bool _ignoreSensitive; private R2RDump() { @@ -91,6 +92,7 @@ namespace R2RDump syntax.DefineOption("sc", ref _sectionContents, "Dump section contents"); syntax.DefineOption("v|verbose", ref verbose, "Dump raw bytes, disassembly, unwindInfo, gcInfo and section contents"); syntax.DefineOption("diff", ref _diff, "Compare two R2R images (not yet implemented)"); + syntax.DefineOption("ignoreSensitive", ref _ignoreSensitive, "Ignores sensitive properties in xml dump to avoid failing tests"); }); if (verbose) @@ -385,7 +387,7 @@ namespace R2RDump if (_xml) { - _dumper = new XmlDumper(r2r, _writer, _raw, _header, _disasm, _disassembler, _unwind, _gc, _sectionContents); + _dumper = new XmlDumper(_ignoreSensitive, r2r, _writer, _raw, _header, _disasm, _disassembler, _unwind, _gc, _sectionContents); } else { diff --git a/src/tools/r2rdump/XmlDumper.cs b/src/tools/r2rdump/XmlDumper.cs index c7ef734dee..f724d7bb2d 100644 --- a/src/tools/r2rdump/XmlDumper.cs +++ b/src/tools/r2rdump/XmlDumper.cs @@ -11,9 +11,12 @@ namespace R2RDump { public XmlDocument XmlDocument { get; } private XmlNode _rootNode; + private bool _ignoreSensitive; + private XmlAttributeOverrides _ignoredProperties; - public XmlDumper(R2RReader r2r, TextWriter writer, bool raw, bool header, bool disasm, IntPtr disassembler, bool unwind, bool gc, bool sectionContents) + public XmlDumper(bool ignoreSensitive, R2RReader r2r, TextWriter writer, bool raw, bool header, bool disasm, IntPtr disassembler, bool unwind, bool gc, bool sectionContents) { + _ignoreSensitive = ignoreSensitive; _r2r = r2r; _writer = writer; XmlDocument = new XmlDocument(); @@ -25,6 +28,23 @@ namespace R2RDump _unwind = unwind; _gc = gc; _sectionContents = sectionContents; + + _ignoredProperties = new XmlAttributeOverrides(); + XmlAttributes attrs = new XmlAttributes(); + attrs.XmlIgnore = _ignoreSensitive; + _ignoredProperties.Add(typeof(R2RHeader), "RelativeVirtualAddress", attrs); + _ignoredProperties.Add(typeof(R2RHeader), "Size", attrs); + _ignoredProperties.Add(typeof(R2RImportSection), "SectionRVA", attrs); + _ignoredProperties.Add(typeof(R2RImportSection), "SectionSize", attrs); + _ignoredProperties.Add(typeof(R2RImportSection), "EntrySize", attrs); + _ignoredProperties.Add(typeof(R2RImportSection), "SignatureRVA", attrs); + _ignoredProperties.Add(typeof(R2RImportSection), "AuxiliaryDataRVA", attrs); + _ignoredProperties.Add(typeof(R2RImportSection.ImportSectionEntry), "SignatureSample", attrs); + _ignoredProperties.Add(typeof(R2RImportSection.ImportSectionEntry), "SignatureRVA", attrs); + _ignoredProperties.Add(typeof(RuntimeFunction), "StartAddress", attrs); + _ignoredProperties.Add(typeof(RuntimeFunction), "UnwindRVA", attrs); + _ignoredProperties.Add(typeof(R2RSection), "RelativeVirtualAddress", attrs); + _ignoredProperties.Add(typeof(R2RSection), "Size", attrs); } public XmlDocument GetXmlDocument() @@ -255,6 +275,8 @@ namespace R2RDump } break; case R2RSection.SectionType.READYTORUN_SECTION_RUNTIME_FUNCTIONS: + if (_ignoreSensitive) + break; int rtfOffset = _r2r.GetOffset(section.RelativeVirtualAddress); int rtfEndOffset = rtfOffset + section.Size; int rtfIndex = 0; @@ -314,7 +336,7 @@ namespace R2RDump using (XmlWriter xmlWriter = node.CreateNavigator().AppendChild()) { xmlWriter.WriteWhitespace(""); - XmlSerializer Serializer = new XmlSerializer(obj.GetType()); + XmlSerializer Serializer = new XmlSerializer(obj.GetType(), _ignoredProperties); Serializer.Serialize(xmlWriter, obj); } } |