Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / CLR / October 2003

Tip: Looking for answers? Try searching our database.

Profiling Method Arguments; CORDBG_E_IL_VAR_NOT_AVAILABLE

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Wolfinger Reinhard - 16 Oct 2003 09:29 GMT
My CLR Profiler watches Function Entry
and Exit with COR_PRF_MONITOR_ENTERLEAVE
and logs Method Arguments with
ICorDebugILFrame::GetArgument API.

What works:
* in, out, ref Arguments on
FunctionEntry (for void functions)

Doesn`t work:
* Any arguments for non-void functions
* Any arguments on FunctionLeave
* Return Value

Question:
(1) Why does Error
CORDBG_E_IL_VAR_NOT_AVAILABLE occur?
(2) When exactly does mscorwks.dll call
my Enter/Leave-Stubs? Are arguments and
return value already accessible then?
(3) Why the difference in behaviour for
void and non-void functions?

My test methods in a C#-Program:
* static void InParam(int param)
* static int ReturnValue(int param)

Output from CLR Profiler (shortened):
FuncEnter TestSimple.TestSimple:InParam
  arg0=333
FuncLeave TestSimple.TestSimple:InParam
  arg0=CORDBG_E_IL_VAR_NOT_AVAILABLE
FuncEnter TestSimple.TestSimple:ReturnValue
  arg0=CORDBG_E_IL_VAR_NOT_AVAILABLE
FuncLeave TestSimple.TestSimple:ReturnValue
  arg0=CORDBG_E_IL_VAR_NOT_AVAILABLE

Help anybody? MSFT?
Per Larsen - 17 Oct 2003 11:37 GMT
> 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

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.