Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ public enum ReadyToRunSectionType
AttributePresence = 113, // Added in V3.1
InliningInfo2 = 114, // Added in 4.1
ComponentAssemblies = 115, // Added in 4.1
OwnerCompositeExecutable = 116, // Added in 4.1

//
// CoreRT ReadyToRun sections
Expand Down
1 change: 1 addition & 0 deletions src/coreclr/src/tools/r2rdump/CommandLineOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public static RootCommand RootCommand()
command.AddOption(new Option(new[] { "--sectionContents", "--sc" }, "Dump section contents", new Argument<bool>()));
command.AddOption(new Option(new[] { "--entrypoints", "-e" }, "Dump list of method / instance entrypoints in the R2R file", new Argument<bool>()));
command.AddOption(new Option(new[] { "--normalize", "-n" }, "Normalize dump by sorting the various tables and methods (default = unsorted i.e. file order)", new Argument<bool>()));
command.AddOption(new Option(new[] { "--hide-transitions", "--ht" }, "Don't include GC transitions in disassembly output", new Argument<bool>()));
command.AddOption(new Option(new[] { "--verbose", "-v" }, "Dump disassembly, unwindInfo, gcInfo and sectionContents", new Argument<bool>()));
command.AddOption(new Option(new[] { "--diff" }, "Compare two R2R images", new Argument<bool>()));
command.AddOption(new Option(new[] { "--diff-hide-same-disasm" }, "In matching method diff dump, hide functions with identical disassembly", new Argument<bool>()));
Expand Down
1 change: 1 addition & 0 deletions src/coreclr/src/tools/r2rdump/R2RDump.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public class DumpOptions : IAssemblyResolver
public bool SectionContents { get; set; }
public bool EntryPoints { get; set; }
public bool Normalize { get; set; }
public bool HideTransitions { get; set; }
public bool Verbose { get; set; }
public bool Diff { get; set; }
public bool DiffHideSameDisasm { get; set; }
Expand Down
23 changes: 21 additions & 2 deletions src/coreclr/src/tools/r2rdump/TextDumper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
using System.Reflection.Metadata;
using System.Reflection.Metadata.Ecma335;
using System.Reflection.PortableExecutable;
using System.Text;

using ILCompiler.Reflection.ReadyToRun;
using Internal.Runtime;
Expand Down Expand Up @@ -212,9 +213,18 @@ internal override void DumpDisasm(RuntimeFunction rtf, int imageOffset)
}
}

if (rtf.Method.GcInfo?.Transitions != null && rtf.Method.GcInfo.Transitions.ContainsKey(codeOffset))
if (!_options.HideTransitions && rtf.Method.GcInfo?.Transitions != null && rtf.Method.GcInfo.Transitions.TryGetValue(codeOffset, out List<BaseGcTransition> transitionsForOffset))
{
foreach (BaseGcTransition transition in rtf.Method.GcInfo.Transitions[codeOffset])
string[] formattedTransitions = new string[transitionsForOffset.Count];
for (int transitionIndex = 0; transitionIndex < formattedTransitions.Length; transitionIndex++)
{
formattedTransitions[transitionIndex] = transitionsForOffset[transitionIndex].ToString();
}
if (_options.Normalize)
{
Array.Sort(formattedTransitions);
}
foreach (string transition in formattedTransitions)
{
_writer.WriteLine($"{indentString}{transition}");
}
Expand Down Expand Up @@ -408,6 +418,15 @@ internal override void DumpSectionContents(ReadyToRunSection section)
InliningInfoSection2 inliningInfoSection2 = new InliningInfoSection2(_r2r, ii2Offset, ii2EndOffset);
_writer.WriteLine(inliningInfoSection2.ToString());
break;
case ReadyToRunSectionType.OwnerCompositeExecutable:
int oceOffset = _r2r.GetOffset(section.RelativeVirtualAddress);
Decoder decoder = Encoding.UTF8.GetDecoder();
int charLength = decoder.GetCharCount(_r2r.Image, oceOffset, section.Size);
char[] charArray = new char[charLength];
decoder.GetChars(_r2r.Image, oceOffset, section.Size, charArray, 0, flush: true);
string ownerCompositeExecutable = new string(charArray);
_writer.WriteLine("Composite executable: {0}", ownerCompositeExecutable);
break;
}
}

Expand Down