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
HANDLE handle;
DWORD pid;
const struct be_process_io* process_io;
void* pio_data;
const char* imageName;
struct dbg_thread* threads;
unsigned continue_on_first_exception;
......@@ -379,6 +380,7 @@ extern BOOL dbg_attach_debuggee(DWORD pid, BOOL cofe, BOOL wfe);
/* tgt_minidump.c */
extern void minidump_write(const char*, const EXCEPTION_RECORD*);
extern enum dbg_start minidump_reload(int argc, char* argv[]);
/* types.c */
extern void print_value(const struct dbg_lvalue* addr, char format, int level);
......@@ -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 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_h(HANDLE handle);
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);
......
......@@ -123,6 +123,15 @@ BOOL stack_get_current_symbol(SYMBOL_INFO* symbol)
return SymFromAddr(dbg_curr_process->handle, ihsf.InstructionOffset,
&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
*
......@@ -148,7 +157,7 @@ unsigned stack_fetch_frames(void)
}
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))
{
dbg_curr_thread->frames = dbg_heap_realloc(dbg_curr_thread->frames,
......
......@@ -34,7 +34,8 @@
/* TODO list:
*
* - 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
* + we always assume the stack grows as on i386 (ie downwards)
* - UI
......@@ -250,6 +251,15 @@ struct dbg_process* dbg_get_process(DWORD pid)
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* p;
......@@ -273,6 +283,7 @@ struct dbg_process* dbg_add_process(const struct be_process_io* pio, DWORD pid,
p->handle = h;
p->pid = pid;
p->process_io = pio;
p->pio_data = NULL;
p->imageName = NULL;
p->threads = NULL;
p->continue_on_first_exception = FALSE;
......@@ -539,7 +550,8 @@ int main(int argc, char** argv)
return dbg_winedbg_usage();
}
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);
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