Commit 348067a9 authored by Eric Pouech's avatar Eric Pouech Committed by Alexandre Julliard

winedbg: Add ability to reload a minidump.

- now recognize winedbg foo.mdmp on command line - fleshed out tgt_minidump to reload information from minidump
parent c918e80e
...@@ -202,6 +202,7 @@ struct dbg_process ...@@ -202,6 +202,7 @@ struct dbg_process
HANDLE handle; HANDLE handle;
DWORD pid; DWORD pid;
const struct be_process_io* process_io; const struct be_process_io* process_io;
void* pio_data;
const char* imageName; const char* imageName;
struct dbg_thread* threads; struct dbg_thread* threads;
unsigned continue_on_first_exception; unsigned continue_on_first_exception;
...@@ -379,6 +380,7 @@ extern BOOL dbg_attach_debuggee(DWORD pid, BOOL cofe, BOOL wfe); ...@@ -379,6 +380,7 @@ extern BOOL dbg_attach_debuggee(DWORD pid, BOOL cofe, BOOL wfe);
/* tgt_minidump.c */ /* tgt_minidump.c */
extern void minidump_write(const char*, const EXCEPTION_RECORD*); extern void minidump_write(const char*, const EXCEPTION_RECORD*);
extern enum dbg_start minidump_reload(int argc, char* argv[]);
/* types.c */ /* types.c */
extern void print_value(const struct dbg_lvalue* addr, char format, int level); extern void print_value(const struct dbg_lvalue* addr, char format, int level);
...@@ -406,6 +408,7 @@ extern BOOL dbg_interrupt_debuggee(void); ...@@ -406,6 +408,7 @@ extern BOOL dbg_interrupt_debuggee(void);
extern struct dbg_process* dbg_add_process(const struct be_process_io* pio, DWORD pid, HANDLE h); extern struct dbg_process* dbg_add_process(const struct be_process_io* pio, DWORD pid, HANDLE h);
extern void dbg_set_process_name(struct dbg_process* p, const char* name); extern void dbg_set_process_name(struct dbg_process* p, const char* name);
extern struct dbg_process* dbg_get_process(DWORD pid); extern struct dbg_process* dbg_get_process(DWORD pid);
extern struct dbg_process* dbg_get_process_h(HANDLE handle);
extern void dbg_del_process(struct dbg_process* p); 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); 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 struct dbg_thread* dbg_get_thread(struct dbg_process* p, DWORD tid);
......
...@@ -123,6 +123,15 @@ BOOL stack_get_current_symbol(SYMBOL_INFO* symbol) ...@@ -123,6 +123,15 @@ BOOL stack_get_current_symbol(SYMBOL_INFO* symbol)
return SymFromAddr(dbg_curr_process->handle, ihsf.InstructionOffset, return SymFromAddr(dbg_curr_process->handle, ihsf.InstructionOffset,
&disp, symbol); &disp, symbol);
} }
static BOOL CALLBACK stack_read_mem(HANDLE hProc, DWORD addr,
PVOID buffer, DWORD size, PDWORD written)
{
struct dbg_process* pcs = dbg_get_process_h(hProc);
if (!pcs) return FALSE;
return pcs->process_io->read(hProc, (const void*)addr, buffer, size, written);
}
/****************************************************************** /******************************************************************
* stack_fetch_frames * stack_fetch_frames
* *
...@@ -148,7 +157,7 @@ unsigned stack_fetch_frames(void) ...@@ -148,7 +157,7 @@ unsigned stack_fetch_frames(void)
} }
while (StackWalk(IMAGE_FILE_MACHINE_I386, dbg_curr_process->handle, while (StackWalk(IMAGE_FILE_MACHINE_I386, dbg_curr_process->handle,
dbg_curr_thread->handle, &sf, &dbg_context, NULL, dbg_curr_thread->handle, &sf, &dbg_context, stack_read_mem,
SymFunctionTableAccess, SymGetModuleBase, NULL)) SymFunctionTableAccess, SymGetModuleBase, NULL))
{ {
dbg_curr_thread->frames = dbg_heap_realloc(dbg_curr_thread->frames, dbg_curr_thread->frames = dbg_heap_realloc(dbg_curr_thread->frames,
......
...@@ -34,7 +34,8 @@ ...@@ -34,7 +34,8 @@
/* TODO list: /* TODO list:
* *
* - minidump * - minidump
* + set a mode where winedbg would start (postmortem debugging) from a minidump * + ensure that all commands work as expected in minidump reload function
* (and reenable parser usager)
* - CPU adherence * - CPU adherence
* + we always assume the stack grows as on i386 (ie downwards) * + we always assume the stack grows as on i386 (ie downwards)
* - UI * - UI
...@@ -250,6 +251,15 @@ struct dbg_process* dbg_get_process(DWORD pid) ...@@ -250,6 +251,15 @@ struct dbg_process* dbg_get_process(DWORD pid)
return p; return p;
} }
struct dbg_process* dbg_get_process_h(HANDLE h)
{
struct dbg_process* p;
for (p = dbg_process_list; p; p = p->next)
if (p->handle == h) break;
return p;
}
struct dbg_process* dbg_add_process(const struct be_process_io* pio, DWORD pid, HANDLE h) struct dbg_process* dbg_add_process(const struct be_process_io* pio, DWORD pid, HANDLE h)
{ {
struct dbg_process* p; struct dbg_process* p;
...@@ -273,6 +283,7 @@ struct dbg_process* dbg_add_process(const struct be_process_io* pio, DWORD pid, ...@@ -273,6 +283,7 @@ struct dbg_process* dbg_add_process(const struct be_process_io* pio, DWORD pid,
p->handle = h; p->handle = h;
p->pid = pid; p->pid = pid;
p->process_io = pio; p->process_io = pio;
p->pio_data = NULL;
p->imageName = NULL; p->imageName = NULL;
p->threads = NULL; p->threads = NULL;
p->continue_on_first_exception = FALSE; p->continue_on_first_exception = FALSE;
...@@ -539,7 +550,8 @@ int main(int argc, char** argv) ...@@ -539,7 +550,8 @@ int main(int argc, char** argv)
return dbg_winedbg_usage(); return dbg_winedbg_usage();
} }
if (!argc) ds = start_ok; if (!argc) ds = start_ok;
else if ((ds = dbg_active_attach(argc, argv)) == start_error_parse) else if ((ds = dbg_active_attach(argc, argv)) == start_error_parse &&
(ds = minidump_reload(argc, argv)) == start_error_parse)
ds = dbg_active_launch(argc, argv); ds = dbg_active_launch(argc, argv);
switch (ds) switch (ds)
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment