开发者

SymFromAddr returns "The specified module could not be found."

开发者 https://www.devze.com 2023-01-26 06:14 出处:网络
I\'m trying to get symbols from addresses I got from my stack, but SymFromAddr keeps failingwith system error 126 (The specified module could not be found.)

I'm trying to get symbols from addresses I got from my stack, but SymFromAddr keeps failing with system error 126 (The specified module could not be found.)

I'm initializing the symboling thing with

SymInitialize(m_processHa开发者_高级运维ndle, NULL, TRUE);

(the last parameter == true ==> It loads the PDB automatically)

and I use SymFromAddr like this:

SYMBOL_INFO_PACKAGE sym = { sizeof(sym) };
sym.si.MaxNameLen = MAX_SYM_NAME; 
DWORD64 displacement = 0;
bool ok = SymFromAddr(m_processHandle, address, &displacement, &sym.si);

The code is in C++ on windows. and the PDB FILE IS IN THE DIRECTORY OF THE EXE! What am I doing wrong? thanks :)


SymFromAddr is a little bit capricious.

  1. If any LoadLibrary occur between SymInitialize and SymFromAddr it may not work. If SymFromAddr you can perfom a SymInitialize again (hint: you can cache address to avoid a lot of SymInitialize which is a huge CPU consummer)
  2. 64 bits implementation of SymFromAddr (ie. SymFromAddr64) works better
  3. If code is not optimized it'll work better
  4. VC9 generated pdb works better than older version.

You can find some idea in the following code http://code.google.com/p/nprof/source/browse/0.11/Hook/StackWalker.cpp?r=281

0

精彩评论

暂无评论...
验证码 换一张
取 消