Reputation: 125
Code:
using System.Diagnostics;
using System.Linq;
using Microsoft.Diagnostics.Runtime;
using Microsoft.Diagnostics.Runtime.Utilities;
using Microsoft.Diagnostics.Runtime.Utilities.Pdb;
namespace myDiagnostics
{
public class myStackTraceInfo
{
public void Atach()
{
using (DataTarget target = DataTarget.AttachToProcess(Process.GetCurrentProcess().Id, 5000, AttachFlag.Passive))
{
ClrRuntime runtime = target.ClrVersions.First().CreateRuntime();
foreach (ClrThread thread in runtime.Threads)
{
foreach (ClrStackFrame frame in thread.StackTrace)
Console.Write(frame.Method.ToString());
}
}
}
}
}
As a result, I get instead of method names - "UNKNOWN". But the in method is the field "InstructionPointer", maybe it will give more information?
Upvotes: 4
Views: 906
Reputation: 2984
The UNKNOWN indicates that the method does not have a managed method associated with it. Try to attach it to other process, also walk on all frames in all stacks, I'm sure you will find something.
Here you can find a working example of dump the stack including the stack objects.
Upvotes: 1