summaryrefslogtreecommitdiff
path: root/src/tools
diff options
context:
space:
mode:
authorAmy <amycmyu@gmail.com>2018-07-31 12:21:07 -0700
committerGitHub <noreply@github.com>2018-07-31 12:21:07 -0700
commitc7abc0df8f22233b7974971c26ae48a93cfea7fa (patch)
treeb14c579a162bb03a67c800b45233ed0234344869 /src/tools
parentf37ac492ea66ad59bb6da1be58c24c5d275c1fd5 (diff)
downloadcoreclr-c7abc0df8f22233b7974971c26ae48a93cfea7fa.tar.gz
coreclr-c7abc0df8f22233b7974971c26ae48a93cfea7fa.tar.bz2
coreclr-c7abc0df8f22233b7974971c26ae48a93cfea7fa.zip
R2RDump - Fix and update R2RDumpTests (#19039)
* 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
Diffstat (limited to 'src/tools')
-rw-r--r--src/tools/r2rdump/R2RImportSection.cs13
-rw-r--r--src/tools/r2rdump/R2RMethod.cs10
-rw-r--r--src/tools/r2rdump/R2RReader.cs19
-rw-r--r--src/tools/r2rdump/XmlDumper.cs34
4 files changed, 49 insertions, 27 deletions
diff --git a/src/tools/r2rdump/R2RImportSection.cs b/src/tools/r2rdump/R2RImportSection.cs
index bf7a056d74..1029d73893 100644
--- a/src/tools/r2rdump/R2RImportSection.cs
+++ b/src/tools/r2rdump/R2RImportSection.cs
@@ -33,13 +33,15 @@ namespace R2RDump
public struct ImportSectionEntry
{
+ [XmlAttribute("Index")]
+ public int Index { get; set; }
public int StartOffset { get; set; }
public long Section { get; set; }
- [XmlAttribute("Index")]
public uint SignatureRVA { get; set; }
public byte[] SignatureSample { get; set; }
- public ImportSectionEntry(int startOffset, long section, uint signatureRVA, byte[] signatureSample)
+ public ImportSectionEntry(int index, int startOffset, long section, uint signatureRVA, byte[] signatureSample)
{
+ Index = index;
StartOffset = startOffset;
Section = section;
SignatureRVA = signatureRVA;
@@ -59,10 +61,12 @@ namespace R2RDump
}
}
+ [XmlAttribute("Index")]
+ public int Index { get; set; }
+
/// <summary>
/// Section containing values to be fixed up
/// </summary>
- [XmlAttribute("Index")]
public int SectionRVA { get; set; }
public int SectionSize { get; set; }
@@ -93,8 +97,9 @@ namespace R2RDump
public int AuxiliaryDataRVA { get; set; }
public GcInfo AuxiliaryData { get; set; }
- public R2RImportSection(byte[] image, int rva, int size, CorCompileImportFlags flags, byte type, byte entrySize, int signatureRVA, List<ImportSectionEntry> entries, int auxDataRVA, int auxDataOffset, Machine machine, ushort majorVersion)
+ public R2RImportSection(int index, byte[] image, int rva, int size, CorCompileImportFlags flags, byte type, byte entrySize, int signatureRVA, List<ImportSectionEntry> entries, int auxDataRVA, int auxDataOffset, Machine machine, ushort majorVersion)
{
+ Index = index;
SectionRVA = rva;
SectionSize = size;
Flags = flags;
diff --git a/src/tools/r2rdump/R2RMethod.cs b/src/tools/r2rdump/R2RMethod.cs
index 788ebbb2e8..fa8ba27c04 100644
--- a/src/tools/r2rdump/R2RMethod.cs
+++ b/src/tools/r2rdump/R2RMethod.cs
@@ -107,6 +107,12 @@ namespace R2RDump
MethodDefinition _methodDef;
/// <summary>
+ /// An unique index for the method
+ /// </summary>
+ [XmlAttribute("Index")]
+ public int Index { get; set; }
+
+ /// <summary>
/// The name of the method
/// </summary>
public string Name { get; set; }
@@ -133,7 +139,6 @@ namespace R2RDump
/// <summary>
/// The row id of the method
/// </summary>
- [XmlAttribute("Index")]
public uint Rid { get; set; }
/// <summary>
@@ -196,8 +201,9 @@ namespace R2RDump
/// <summary>
/// Extracts the method signature from the metadata by rid
/// </summary>
- public R2RMethod(MetadataReader mdReader, uint rid, int entryPointId, GenericElementTypes[] instanceArgs, uint[] tok, FixupCell[] fixups)
+ public R2RMethod(int index, MetadataReader mdReader, uint rid, int entryPointId, GenericElementTypes[] instanceArgs, uint[] tok, FixupCell[] fixups)
{
+ Index = index;
Token = _mdtMethodDef | rid;
Rid = rid;
EntryPointRuntimeFunctionId = entryPointId;
diff --git a/src/tools/r2rdump/R2RReader.cs b/src/tools/r2rdump/R2RReader.cs
index 25568b0999..a2a1754fe6 100644
--- a/src/tools/r2rdump/R2RReader.cs
+++ b/src/tools/r2rdump/R2RReader.cs
@@ -9,6 +9,7 @@ using System.Reflection.Metadata;
using System.Reflection.Metadata.Ecma335;
using System.Reflection.PortableExecutable;
using System.Text;
+using System.Xml.Serialization;
namespace R2RDump
{
@@ -40,6 +41,9 @@ namespace R2RDump
/// </summary>
public struct FixupCell
{
+ [XmlAttribute("Index")]
+ public int Index { get; set; }
+
/// <summary>
/// Zero-based index of the import table within the import tables section.
/// </summary>
@@ -51,8 +55,9 @@ namespace R2RDump
/// </summary>
public uint CellOffset;
- public FixupCell(uint tableIndex, uint cellOffset)
+ public FixupCell(int index, uint tableIndex, uint cellOffset)
{
+ Index = index;
TableIndex = tableIndex;
CellOffset = cellOffset;
}
@@ -215,7 +220,7 @@ namespace R2RDump
int runtimeFunctionId;
FixupCell[] fixups;
GetEntryPointInfoFromOffset(offset, out runtimeFunctionId, out fixups);
- R2RMethod method = new R2RMethod(_mdReader, rid, runtimeFunctionId, null, null, fixups);
+ R2RMethod method = new R2RMethod(R2RMethods.Count, _mdReader, rid, runtimeFunctionId, null, null, fixups);
if (method.EntryPointRuntimeFunctionId < 0 || method.EntryPointRuntimeFunctionId >= isEntryPoint.Length)
{
@@ -264,7 +269,7 @@ namespace R2RDump
int runtimeFunctionId;
FixupCell[] fixups;
GetEntryPointInfoFromOffset((int)curParser.Offset, out runtimeFunctionId, out fixups);
- R2RMethod method = new R2RMethod(_mdReader, rid, runtimeFunctionId, args, tokens, fixups);
+ R2RMethod method = new R2RMethod(R2RMethods.Count, _mdReader, rid, runtimeFunctionId, args, tokens, fixups);
if (method.EntryPointRuntimeFunctionId >= 0 && method.EntryPointRuntimeFunctionId < isEntryPoint.Length)
{
isEntryPoint[method.EntryPointRuntimeFunctionId] = true;
@@ -409,7 +414,7 @@ namespace R2RDump
int sigSampleLength = Math.Min(8, Image.Length - sigOff);
byte[] signatureSample = new byte[sigSampleLength];
Array.Copy(Image, sigOff, signatureSample, 0, sigSampleLength);
- entries.Add(new R2RImportSection.ImportSectionEntry(entryOffset, section, sigRva, signatureSample));
+ entries.Add(new R2RImportSection.ImportSectionEntry(entries.Count, entryOffset, section, sigRva, signatureSample));
}
}
break;
@@ -424,7 +429,7 @@ namespace R2RDump
int sigSampleLength = Math.Min(8, Image.Length - sigOff);
byte[] signatureSample = new byte[sigSampleLength];
Array.Copy(Image, sigOff, signatureSample, 0, sigSampleLength);
- entries.Add(new R2RImportSection.ImportSectionEntry(entryOffset, section, sigRva, signatureSample));
+ entries.Add(new R2RImportSection.ImportSectionEntry(entries.Count, entryOffset, section, sigRva, signatureSample));
}
break;
}
@@ -435,7 +440,7 @@ namespace R2RDump
{
auxDataOffset = GetOffset(auxDataRVA);
}
- ImportSections.Add(new R2RImportSection(Image, rva, size, flags, type, entrySize, signatureRVA, entries, auxDataRVA, auxDataOffset, Machine, R2RHeader.MajorVersion));
+ ImportSections.Add(new R2RImportSection(ImportSections.Count, Image, rva, size, flags, type, entrySize, signatureRVA, entries, auxDataRVA, auxDataOffset, Machine, R2RHeader.MajorVersion));
}
}
@@ -518,7 +523,7 @@ namespace R2RDump
while (true)
{
- cells.Add(new FixupCell(curTableIndex, fixupIndex));
+ cells.Add(new FixupCell(cells.Count, curTableIndex, fixupIndex));
uint delta = reader.ReadUInt();
diff --git a/src/tools/r2rdump/XmlDumper.cs b/src/tools/r2rdump/XmlDumper.cs
index 913a8be1ee..c7ef734dee 100644
--- a/src/tools/r2rdump/XmlDumper.cs
+++ b/src/tools/r2rdump/XmlDumper.cs
@@ -94,7 +94,8 @@ namespace R2RDump
internal override void DumpSection(R2RSection section, XmlNode parentNode)
{
XmlNode sectionNode = XmlDocument.CreateNode("element", "Section", "");
- AddIndexAttribute(sectionNode, $"{section.Type}");
+ AddXMLAttribute(sectionNode, "Index", $"{section.Type}");
+
parentNode.AppendChild(sectionNode);
Serialize(section, sectionNode);
@@ -112,7 +113,7 @@ namespace R2RDump
{
XmlNode methodsNode = XmlDocument.CreateNode("element", "Methods", "");
_rootNode.AppendChild(methodsNode);
- AddXMLNode("Count", _r2r.R2RMethods.Count.ToString(), methodsNode);
+ AddXMLAttribute(methodsNode, "Count", _r2r.R2RMethods.Count.ToString());
foreach (R2RMethod method in _r2r.R2RMethods)
{
DumpMethod(method, methodsNode);
@@ -125,7 +126,7 @@ namespace R2RDump
internal override void DumpMethod(R2RMethod method, XmlNode parentNode)
{
XmlNode methodNode = XmlDocument.CreateNode("element", "Method", "");
- AddIndexAttribute(methodNode, $"{method.Rid}");
+ AddXMLAttribute(methodNode, "Index", $"{method.Index}");
parentNode.AppendChild(methodNode);
Serialize(method, methodNode);
@@ -162,6 +163,7 @@ namespace R2RDump
internal override void DumpRuntimeFunction(RuntimeFunction rtf, XmlNode parentNode)
{
XmlNode rtfNode = XmlDocument.CreateNode("element", "RuntimeFunction", "");
+ AddXMLAttribute(rtfNode, "Index", $"{rtf.Id}");
parentNode.AppendChild(rtfNode);
AddXMLNode("MethodRid", rtf.Method.Rid.ToString(), rtfNode);
Serialize(rtf, rtfNode);
@@ -269,25 +271,29 @@ namespace R2RDump
case R2RSection.SectionType.READYTORUN_SECTION_IMPORT_SECTIONS:
foreach (R2RImportSection importSection in _r2r.ImportSections)
{
- Serialize(importSection, contentsNode);
+ XmlNode importSectionsNode = XmlDocument.CreateNode("element", "ImportSection", "");
+ AddXMLAttribute(importSectionsNode, "Index", $"{importSection.Index}");
+ contentsNode.AppendChild(importSectionsNode);
+
+ Serialize(importSection, importSectionsNode);
if (_raw && importSection.Entries.Count != 0)
{
if (importSection.SectionRVA != 0)
{
- DumpBytes(importSection.SectionRVA, (uint)importSection.SectionSize, contentsNode, "SectionBytes");
+ DumpBytes(importSection.SectionRVA, (uint)importSection.SectionSize, importSectionsNode, "SectionBytes");
}
if (importSection.SignatureRVA != 0)
{
- DumpBytes(importSection.SignatureRVA, (uint)importSection.Entries.Count * sizeof(int), contentsNode, "SignatureBytes");
+ DumpBytes(importSection.SignatureRVA, (uint)importSection.Entries.Count * sizeof(int), importSectionsNode, "SignatureBytes");
}
if (importSection.AuxiliaryDataRVA != 0)
{
- DumpBytes(importSection.AuxiliaryDataRVA, (uint)importSection.AuxiliaryData.Size, contentsNode, "AuxiliaryDataBytes");
+ DumpBytes(importSection.AuxiliaryDataRVA, (uint)importSection.AuxiliaryData.Size, importSectionsNode, "AuxiliaryDataBytes");
}
}
foreach (R2RImportSection.ImportSectionEntry entry in importSection.Entries)
{
- Serialize(entry, contentsNode);
+ Serialize(entry, importSectionsNode);
}
}
break;
@@ -298,8 +304,8 @@ namespace R2RDump
{
XmlNode queryNode = XmlDocument.CreateNode("element", title, "");
_rootNode.AppendChild(queryNode);
- AddXMLNode("Query", q, queryNode);
- AddXMLNode("Count", count.ToString(), queryNode);
+ AddXMLAttribute(queryNode, "Query", q);
+ AddXMLAttribute(queryNode, "Count", count.ToString());
return queryNode;
}
@@ -318,17 +324,17 @@ namespace R2RDump
XmlNode node = XmlDocument.CreateNode("element", name, "");
if (!index.Equals(""))
{
- AddIndexAttribute(node, index);
+ AddXMLAttribute(node, "Index", index);
}
parentNode.AppendChild(node);
node.InnerText = contents;
return node;
}
- private void AddIndexAttribute(XmlNode node, string index)
+ private void AddXMLAttribute(XmlNode node, string name, string value)
{
- XmlAttribute attr = XmlDocument.CreateAttribute("Index");
- attr.Value = index;
+ XmlAttribute attr = XmlDocument.CreateAttribute(name);
+ attr.Value = value;
node.Attributes.SetNamedItem(attr);
}
}