IonicWind Software

Aurora Compiler => Coding Help - Aurora 101 => Topic started by: sapero on October 10, 2009, 04:12:43 AM

Title: Stack walk - SymFromAddr failing
Post by: sapero on October 10, 2009, 04:12:43 AM
I have started with dbghelp, have all the required symbols installed and updated, and the _NT_SYMBOL_PATH variable is set correctly. All the debuggers I have are showing me the correct symbols, but this small project - fails even to get the name of SendMessage. Symbols manually added by SymAddSymbol (loaded from .map file) are shown.
My trace looks like this:1 test.exe WorkspaceDlgProc + 6051
2  test.exe WorkspaceDlgProc + 1308
3  USER32.DLL 0x7E368734 // this should be _InternalCallWinProc@20
4  USER32.DLL 0x7E373CE4 // this should be _UserCallDlgProcCheckWow@32
5  USER32.DLL 0x7E373B30 // this should be _DefDlgProcWorker@20
6  USER32.DLL 0x7E37309B // this should be _SendMessageWorker@20
7  USER32.DLL 0x7E3792E3 // this should be _SendMessageW@16
8  test.exe ApplicationSimulateResize + 97
9  test.exe BuildDockUndock + 52
10 test.exe main + 1020
11 test.exe _main + 67


As the trigger for exception, I have sent WM_NOTIFY with invalid lParam to one of my windows. The code uses the .map file to load all global symbols used to build current executable (LoadSymbols subroutine), and the stack trace executes in CallStackThread subroutine.

Debughelp dll is loaded from Aurora/bin, because the one from /system32 does not have SymAddSymbol, and the newest version from /ProgramFiles does not find any symbols (listview is empty).

What I'm doing wrong? Calling SymFromAddr for user32.dll address space, Im getting ERROR_INVALID_ADDRESS error, but after calling SymGetModuleInfo I see that user32.pdb is loaded.

EDIT: found invalid frame.*.Mode initialization, fixed, and still addresses instead names.
Title: Re: Stack walk - SymFromAddr failing
Post by: sapero on October 10, 2009, 06:31:43 AM
I have it working. After fixing the STACKFRAME structure, I've changed dbghelp.dll location to /ProgramFiles/Debugging Tools for Windows:
#include "shlobj.inc" // added

global sub InitializeUnhandledExceptionFilter()
{
dstring path[MAX_PATH];
// remove cchMax and SHGetValue
SHGetSpecialFolderPath(0, path, CSIDL_PROGRAM_FILES, FALSE);
path += "\\Debugging Tools for Windows\\dbghelp.dll";

HMODULE hMod = LoadLibrary(path);
...
}

sub CallStackThread(THREAD_DATA *data)
{
...
frame.AddrPC.Offset    = data->ExceptionInfo->ContextRecord->Eip;
frame.AddrPC.Mode      = AddrModeFlat;
frame.AddrStack.Offset = data->ExceptionInfo->ContextRecord->Esp;
frame.AddrStack.Mode   = AddrModeFlat; // fix
frame.AddrFrame.Offset = data->ExceptionInfo->ContextRecord->Ebp;
frame.AddrFrame.Mode   = AddrModeFlat; // fix
...
}