简体   繁体   English

堆栈调试已调试的进程

[英]Stack Walking a debugged process

I'm opened opening a process (with C++/Windows) using 我打开了一个进程(使用C ++ / Windows)

if( CreateProcessA( NULL,   // No module name (use command line)
   (LPSTR)path, //argv[1],        // Command line
    NULL,           // Process handle not inheritable
    NULL,           // Thread handle not inheritable
    FALSE,          // Set handle inheritance to FALSE
    creationFlags,              // No creation flags
    NULL,           // Use parent's environment block
    NULL,           // Use parent's starting directory 
    &startInfo,            // Pointer to STARTUPINFO structure
    &processInfo )           // Pointer to PROCESS_INFORMATION structure

where 哪里

DWORD creationFlags = DEBUG_PROCESS | DEBUG_ONLY_THIS_PROCESS;  

and then I'm trying to stackwalk it with 然后我试着用它来堆积它

bool ok = StackWalk64(IMAGE_FILE_MACHINE_I386,m_ps.Handle ,m_th.Handle, 
    &m_stackframe, &m_threadContext,
    0, NULL, NULL, 0); 

but stackwalk just gives me the top address and the next one is 0, while I know there are more addresses in the stack. 但是stackwalk只给我顶部地址,下一个是0,而我知道堆栈中有更多的地址。

Does anybody know what's the problem? 有人知道这是什么问题吗?
thanks :) 谢谢 :)

It's impossible to tell based on this snippet. 根据这个片段不可能分辨出来。 There's so much you have to set up correctly in order for this to work. 你需要正确设置才能使其正常工作。 Check out the logic at this detailed blog post . 这篇详细的博客文章中查看逻辑。

Post more code if you can post a bigger but not too big sample. 如果您可以发布更大但不太大的样本,请发布更多代码。 How are you setting up the STACKFRAME and CONTEXT structures? 你是如何设置STACKFRAME和CONTEXT结构的? Are you looping on StackWalk64 ? 你在StackWalk64循环吗? Any given call only returns one stack frame. 任何给定的调用只返回一个堆栈帧。

oops... I forget to call "ContinueDebugEvent" after receiving events from the debugged process - so it stayed paused and the StackWalk was infact correct. oops ...我在调试过程中收到事件后忘记调用“ContinueDebugEvent” - 因此它保持暂停状态,StackWalk实际上是正确的。 :) :)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM