Skip to content

Implementing the SOS -u command #34

Description

@mattwarren

I'm trying to use ClrMD to print out the assembly code of a method, as part of a Benchmarking library I'm working on

At the moment I use code similar to the Machine Code sample to get the memory address, then I use code like this to get the assembly code (where debugControl is of type IDebugControl from IDebugControl.cs):

var bufferSize = 500; // per-line
var lineOfAssembly = new StringBuilder(bufferSize);
ulong startOffset = startAddress, endOffset;
uint disassemblySize;
do
{
    var flags = DEBUG_DISASM.EFFECTIVE_ADDRESS; // DEBUG_DISASM.SOURCE_FILE_NAME | DEBUG_DISASM.SOURCE_LINE_NUMBER;
    var result = debugControl.Disassemble(startOffset, flags, lineOfAssembly, bufferSize, out disassemblySize, out endOffset);
    startOffset = endOffset;
    Console.WriteLine(lineOfAssembly.ToString());
} while (disassemblySize > 0 && endOffset <= endAddress);

That works okay and I get an output like so, but the call instructions aren't resolved to a method name, they just have the memory address:

image

However if I run the -u command in WinDbg, it's able to resolve the method name of the call instruction, even with JIT methods such as mscorwks!JIT_Throw.

Is there a way I can replicate this with ClrMD?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions