You should try ICorDebugOLFrame->EnumerateArguments

This is code  for this :
ICorDebugFrame *frame;//frame for this function

ICorDebugChain *chain;//chain including this frame

ICorDebugModule *module;//module where the function is defined

//---------------------

{

ICorDebugValueEnum *valueEnum=0;HRESULT hr;ICorDebugILFrame *ILFrame=0;

if (frame!=0){

frame->QueryInterface(IID_ICorDebugILFrame,(void **)&ILFrame);

}

if (ILFrame!=0){

hr=ILFrame->EnumerateArguments(&valueEnum);

}

ULONG cArguments;

if (valueEnum!=0){

valueEnum->GetCount(&cArguments);

valueEnum->Reset();

} 

//remember that first argument for nonstatic function is "this" value

ICorDebugRegisterSet *registers=0;ICorDebugNativeFrame *nativeFrame=0;

if (frame!=0){

hr=frame->QueryInterface(IID_ICorDebugNativeFrame,(void**)&nativeFrame);

}


ICorDebugProcess *process=0;

if (module!=0){

module->GetProcess(&process);

}

if (ILFrame!=0){

ILFrame->Release();

}

if (nativeFrame!=0){

nativeFrame->GetRegisterSet(&registers);

nativeFrame->Release();

}

for (unsigned int j=0;j<cArguments;j++)

{

ULONG32 valsize=0;ULONG retrieved;ICorDebugValue *argValue=0;CORDB_ADDRESS addr=0;

DWORD bytesRetrieved=0;BYTE *val=0;

if (valueEnum!=0){

hr=valueEnum->Next(1,(ICorDebugValue **)&argValue,&retrieved);

argValue->GetSize(&valsize);

hr=argValue->GetAddress(&addr);

if (addr==0){

//some of arguments may be stored in registers

//try nativeFrame->GetRegisterSet 

}

else

{

val = new BYTE[valsize];

process->ReadMemory(addr,valsize,val,&bytesRetrieved);

}

}

----- Original Message ----- 
From: "John Keeney" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Friday, April 12, 2002 5:31 PM
Subject: [DOTNET] InProc Profiler/Debugger ICorDebugILFrame::GetArgument


> Hi All,
> 
> Im trying to access the parameters to a function call in the Inproc
> debugger.
> 
> In a profiler when I catch function entry, I get access to the inproc
> debugger interfaces and from that I get access to the current thread's
> ICorDebugILFrame interface with ICorDebugThread::GetActiveFrame.
> Then call ICorDebugILFrame::GetArgument.
> 
> I think this is the best way to get access to the parameter values of a
> function call in this profiler callback. (If not please tell me. I haven't
> tried IMetaDataImport fully yet)
> 
> When I call the GetArgument method it sometimes fails with
> CORDBG_E_IL_VAR_NOT_AVAILABLE, but not always!
> Even if ICorDebugILFrame::EnumerateArguments indicates that there are
> arguments available, i can't access them with GetArgument!
> (ICorDebugValueEnum::Next also fails with the same error)
> 
> Note this works fine for some methods, but not for others even of the same
> class. I really have no idea why.
> eg
> OK for: .ctor, Set_Property etc
> Not OK for: ToString (overridden), ordinary public methods with standard
> value type params, etc
> 
> Has anyone any ideas?
> 
> Thanks
> John
> 
> 
> #define CORDBG_E_IL_VAR_NOT_AVAILABLE                   EMAKEHR(0x1304)
> // An IL variable is not available at the current native IP.
> 
> You can read messages from the DOTNET archive, unsubscribe from DOTNET, or
> subscribe to other DevelopMentor lists at http://discuss.develop.com.

You can read messages from the DOTNET archive, unsubscribe from DOTNET, or
subscribe to other DevelopMentor lists at http://discuss.develop.com.

Reply via email to