winedbg: Search default debuggee dir for symbol information.

This commit is contained in:
Eric Pouech 2008-08-30 08:44:48 +02:00 committed by Alexandre Julliard
parent 07baf69080
commit 6986975816
6 changed files with 44 additions and 4 deletions

View File

@ -446,6 +446,7 @@ extern void dbg_del_process(struct dbg_process* p);
struct dbg_thread* dbg_add_thread(struct dbg_process* p, DWORD tid, HANDLE h, void* teb);
extern struct dbg_thread* dbg_get_thread(struct dbg_process* p, DWORD tid);
extern void dbg_del_thread(struct dbg_thread* t);
extern BOOL dbg_init(HANDLE hProc, const char* in, BOOL invade);
extern BOOL dbg_get_debuggee_info(HANDLE hProcess, IMAGEHLP_MODULE* imh_mod);
/* gdbproxy.c */

View File

@ -505,7 +505,7 @@ static void handle_debug_event(struct gdb_context* gdbctx, DEBUG_EVENT* de)
de->u.CreateProcessInfo.nDebugInfoSize);
/* de->u.CreateProcessInfo.lpStartAddress; */
if (!SymInitialize(gdbctx->process->handle, NULL, TRUE))
if (!dbg_init(gdbctx->process->handle, buffer, TRUE))
fprintf(stderr, "Couldn't initiate DbgHelp\n");
if (gdbctx->trace & GDBPXY_TRC_WIN32_EVENT)

View File

@ -509,7 +509,7 @@ static unsigned dbg_handle_debug_event(DEBUG_EVENT* de)
de->u.CreateProcessInfo.nDebugInfoSize);
dbg_set_process_name(dbg_curr_process, buffer);
if (!SymInitialize(dbg_curr_process->handle, NULL, FALSE))
if (!dbg_init(dbg_curr_process->handle, buffer, FALSE))
dbg_printf("Couldn't initiate DbgHelp\n");
if (!SymLoadModule(dbg_curr_process->handle, de->u.CreateProcessInfo.hFile, buffer, NULL,
(unsigned long)de->u.CreateProcessInfo.lpBaseOfImage, 0))

View File

@ -304,7 +304,7 @@ static enum dbg_start minidump_do_reload(struct tgt_process_minidump_data* data)
dbg_curr_process->pio_data = data;
dbg_set_process_name(dbg_curr_process, exec_name);
SymInitialize(hProc, NULL, FALSE);
dbg_init(hProc, NULL, FALSE);
if (MiniDumpReadDumpStream(data->mapping, ThreadListStream, &dir, &stream, &size))
{

View File

@ -55,7 +55,7 @@ enum dbg_start tgt_module_load(const char* name, BOOL keep)
SymSetOptions((opts & ~(SYMOPT_UNDNAME|SYMOPT_DEFERRED_LOADS)) |
SYMOPT_LOAD_LINES | SYMOPT_AUTO_PUBLICS | 0x40000000);
if (!SymInitialize(hDummy, NULL, FALSE))
if (!dbg_init(hDummy, NULL, FALSE))
return start_error_init;
if (!SymLoadModule(hDummy, NULL, name, NULL, 0, 0))
{

View File

@ -346,6 +346,45 @@ void dbg_del_process(struct dbg_process* p)
HeapFree(GetProcessHeap(), 0, p);
}
/******************************************************************
* dbg_init
*
* Initializes the dbghelp library, and also sets the application directory
* as a place holder for symbol searches.
*/
BOOL dbg_init(HANDLE hProc, const char* in, BOOL invade)
{
BOOL ret;
ret = SymInitialize(hProc, NULL, invade);
if (ret && in)
{
const char* last;
for (last = in + strlen(in) - 1; last >= in; last--)
{
if (*last == '/' || *last == '\\')
{
char* tmp;
tmp = HeapAlloc(GetProcessHeap(), 0, 1024 + 1 + (last - in) + 1);
if (tmp && SymGetSearchPath(hProc, tmp, 1024))
{
char* x = tmp + strlen(tmp);
*x++ = ';';
memcpy(x, in, last - in);
x[last - in] = '\0';
ret = SymSetSearchPath(hProc, tmp);
}
else ret = FALSE;
HeapFree(GetProcessHeap(), 0, tmp);
break;
}
}
}
return ret;
}
struct mod_loader_info
{
HANDLE handle;