c++ - Getting pointer to bottom of the call stack and resolving symbol by address (like dladdr) under Windows? -
For example, to add this information to an exception, I want to apply an analogue of backcountage utility under Windows.
I need to capture the return addresses and then translate it into the names of symbols.
I know about StackWalk 64 and about this but unfortunately there are many important drawbacks in it:
- It is very slow (StackWalk 64) and I have collected trace I do not want to waste too much time to do it, it can be done as fast as possible on the linked list.
- Function StackWalk64 is known
I only want to support x86 and x86_64 architecture possible
I have the basic idea:
- Go on the stack using SEP / EBP, in the same way from GCC's
__Biltin_reature_address (x)
/__Biltin_frame_address (x)
Unless I reach the bottom of the stack (this is what glibc does). - Translate the address to symbols
- Take a nap for them.
Problems / Questions:
- How do I know if I reach the stack? For example glibc implementation has
__ libc_stack_end
, so it's easy to stop what is such an analog under Windows? How can I find the address under the stack? - What are the analog functionality of the dlader functionality? I now know that unlike the ELF platform, which holds most symbol names, the PE format is not. So anyway it should read debug info in any way?
- Capturing stack trace:
-
Receiving symbols: Using the DBG Support Library (MSVC only). Main function:
// start hprrocess = getcurrentProcess () SymSetOptions (SYMOPT_DEFERRED_LOADS) SymInitialize (hProcess, NULL, TRUE) // fetching symbol SymFromAddr (...)
The implementation can be found
Comments
Post a Comment