0

Currently I could get all the objects that are present in heap using the below code using ClrMD. Is it posible to get only the set of objects that are used in the target process(i.e only the objects that are WITHIN to the souce code of the target process).

var types = heap.EnumerateObjectAddresses()
           .GroupBy(obj => heap.GetObjectType(obj).Name)
           .Select(group => new { Key = group.Key, Count = group.Count() })
           .OrderBy(type => type.Count);

foreach (var type in types)
Console.WriteLine("{0} {1}", type.Key, type.Count);
Console.ReadLine();
GANESH GANI
  • 101
  • 11

1 Answers1

1

As far as I know, VS profile tool has the feature to collect the all callers (objects, functions) of a function while the program is running. is it what you want to get?

Reference:

How to list all calls of a function at runtime?

Update:

CLrMD does have classes for enumerating the PDB information. I suggest you try using the DataTarget class to enumerate the parameters/locals of a stack frame. They’ll have to add code to the DataTarget class to do so, as it doesn’t look like it currently supports it.

Jack Zhai
  • 6,230
  • 1
  • 12
  • 20
  • Thankyou for your consideration, but I actually want to travel across the clrstackframe and get the method body and get the variable values in it. – GANESH GANI Aug 08 '17 at 09:41
  • @GANESH GANI, What does it mean "travel across the clrstackframe"? Do you mean you want to get something using Microsoft.Diagnostics.Runtime?like http://techqa.info/programming/question/40255009/How-do-I-get-information-about-the-methods-in-StackTrace-using-Microsoft-Diagnostics-Runtime- and https://blog.maartenballiauw.be/post/2017/01/03/exploring-.net-managed-heap-with-clrmd.html – Jack Zhai Aug 09 '17 at 05:49
  • i could get all methods that are present in the stack frame but i could not get access to the local variables that are present in those methods – GANESH GANI Aug 09 '17 at 05:53
  • Zhai , I belive that the stackframe we use in clrmd is of type ClrStackFrame, I do want to know by any chanches, could we use it as System.Diagnostics.StackFrame, using which we could get access to the lcal variables and properties of that. – GANESH GANI Aug 09 '17 at 06:07
  • @GANESH GANI, I edit the answer and provide the information. If possible, you could refer to it. – Jack Zhai Aug 10 '17 at 01:24
  • Zhai Thankyou, so can I come to a conclusion that we cannot access the process local variables information using another process unless I use a memory profiler. – GANESH GANI Aug 10 '17 at 04:23