views:

249

answers:

1

I have a process suspended at breakpoint under visual studio debugger. I can attach as many as cdb (Microsoft's console debugger) in non-invasive mode as

cdb -p pid -pvr

How to achieve the same using my own program which uses Debug Engine API.

 IDebugClient* debugClient = 0;
(DebugCreate( __uuidof(IDebugClient), (void **)&debugClient );
 debugClient->AttachProcess(0,id,DEBUG_ATTACH_NONINVASIVE
                |DEBUG_ATTACH_NONINVASIVE_NO_SUSPEND);

This code causes E_INVALIDARG. Is this combination is not allowed ? The one below works, but when it calls GetStackTrace, it returns E_UNEXPECTED.

debugClient->AttachProcess(0,id,DEBUG_ATTACH_NONINVASIVE);
debugControl->GetStackTrace(0, 0, 0, pStackFrames, maxFrames, &framesFilled);

I am interested to attach to a process already at debug break noninvasive way , and get a few local variable from its current stack & some global variable value.

Secondly, can someone point me the function used to dump the content of memory for a symbol iteratively like !stl does. I need to write a plugin to dump one of my vector like structure.

Thanks

+2  A: 
I got it to work as you suggested. The combination DEBUG_ATTACH_NONINVASIVE|DEBUG_ATTACH_NONINVASIVE_NO_SUSPEND doesn't work when the process is already suspended by another debugger, but DEBUG_ATTACH_NONINVASIVE works. And problem to get call stack was related to WaitForEvent call. ExtRemoteTyped along with many other classes from engextcpp.hpp are surprisingly good, and solves most of the problem
abir