> My CLR Profiler watches Function Entry
> and Exit with COR_PRF_MONITOR_ENTERLEAVE
> and logs Method Arguments with
> ICorDebugILFrame::GetArgument API.
Sounds very interesting. I've written a couple of profilers a while back. I
wanted to try this aspect also but haven't gotten to it yet, so I can't
really offer any authoritative help - just a few pointers.
> What works:
> * in, out, ref Arguments on
> FunctionEntry (for void functions)
>
> Doesn`t work:
> * Any arguments for non-void functions
In what way does it fail, do you get a non-zero HResult, or is the returned
ICorDebugValue interface NULL, or what?
Have you tried using EnumerateArguments instead?
> * Any arguments on FunctionLeave
> * Return Value
It's possible that the arguments are no longer present/viewed as such after
the entry code has executed. What do you get with
GetLocalVariable/EnumerateLocalVariables?
> (2) When exactly does mscorwks.dll call
> my Enter/Leave-Stubs? Are arguments and
> return value already accessible then?
They should be. Actually, it's not mscorwks.dll calling your profiler - it's
the raw JIT'ed code. Here's an excerpt from a profiled routine
// set up stack frame for parameter and locals
push ebp
mov ebp, esp
sub esp, 028h ; '('
push edi
push esi
push ebx
push 036184B0h // <- method cookie
call 0AABDB7Ch // <- enter stub call
// actual code body starts here
mov esi, ecx
lea edi, [ebp-028h]
.....
mov ecx, [ebx+0F4h]
cmp [ecx], ecx
call [03613584h]
// actual code body ends here
push 036184B0h // <- method cookie
call 0AABDBA8h // <- exit stub call
// remove stack frame & return to caller
pop ebx
pop esi
pop edi
mov esp, ebp
pop ebp
ret 04h
My profiler DLL happens to have a preferred load address of 0xAAA00000 as
you can see from the stub call addresses.
- Per
Wolfinger Reinhard - 17 Oct 2003 12:18 GMT
> In what way does it fail, do you get a non-zero HResult, or is the returned
> ICorDebugValue interface NULL, or what?
GetArgument returns CORDBG_E_IL_VAR_NOT_AVAILABLE.
> Have you tried using EnumerateArguments instead?
Yes I have tried both. EnumerateArguments returns the Enum with the correct
number of arguments. But when I try to access the enum with ->Next() it
returns CORDBG_E_IL_VAR_NOT_AVAILABLE. Same thing.
> It's possible that the arguments are no longer present/viewed as such after
> the entry code has executed. What do you get with
> GetLocalVariable/EnumerateLocalVariables?
I used both APIs to access the return value which for C# is a local variable
with a generated name prefixed CS$. When Arguments cannot be accessed,
GetLocalVariable/EnumerateLocalVariable also fails. Same HRESULT.
Reinhard
K_Lee - 19 Oct 2003 16:37 GMT
Check this links to the sscli code and see if it helps.
http://www.slink-software.com/W/SrcDoc_Top/sscli/sscli.sdoc/N_41
sscli.sdoc
Source Code Roadmap:
App Domain
Profiler
ProfToEEInterface - proftoeeinterfaceimpl.h:34
COR_PRF_MONITOR_ENTERLEAVE - profilepriv.h:134
CORDBG_E_IL_VAR_NOT_AVAILABLE - common.cpp:394
CorProfInfo - profile.h:64
ICorProfilerInfo - corprof.h:1889
> > My CLR Profiler watches Function Entry
> > and Exit with COR_PRF_MONITOR_ENTERLEAVE
[quoted text clipped - 62 lines]
>
> - Per