diff --git a/programs/winedbg/debugger.h b/programs/winedbg/debugger.h index 9c72916cdb7..0ad654fbc0b 100644 --- a/programs/winedbg/debugger.h +++ b/programs/winedbg/debugger.h @@ -255,6 +255,7 @@ extern struct dbg_thread* dbg_curr_thread; extern DWORD_PTR dbg_curr_tid; extern CONTEXT dbg_context; extern BOOL dbg_interactiveP; +extern HANDLE dbg_houtput; struct dbg_internal_var { @@ -419,6 +420,7 @@ extern void dbg_wait_next_exception(DWORD cont, int count, int mode) extern enum dbg_start dbg_active_attach(int argc, char* argv[]); extern enum dbg_start dbg_active_launch(int argc, char* argv[]); extern enum dbg_start dbg_active_auto(int argc, char* argv[]); +extern enum dbg_start dbg_active_minidump(int argc, char* argv[]); extern void dbg_active_wait_for_first_exception(void); extern BOOL dbg_attach_debuggee(DWORD pid, BOOL cofe); diff --git a/programs/winedbg/tgt_active.c b/programs/winedbg/tgt_active.c index 8302e8ef87b..e7f223eb313 100644 --- a/programs/winedbg/tgt_active.c +++ b/programs/winedbg/tgt_active.c @@ -757,75 +757,95 @@ enum dbg_start dbg_active_auto(int argc, char* argv[]) HANDLE hFile; enum dbg_start ds = start_error_parse; - if (!strcmp(argv[0], "--auto")) - { - /* auto mode */ - argc--; argv++; - ds = dbg_active_attach(argc, argv); - if (ds != start_ok) { - msgbox_res_id(NULL, IDS_INVALID_PARAMS, IDS_AUTO_CAPTION, MB_OK); - return ds; - } - if (!display_crash_dialog()) { - dbg_init_console(); - dbg_start_interactive(INVALID_HANDLE_VALUE); - return start_ok; - } + DBG_IVAR(BreakOnDllLoad) = 0; - hFile = parser_generate_command_file("echo Modules:", "info share", - "echo Threads:", "info threads", - "kill", NULL); + /* auto mode */ + argc--; argv++; + ds = dbg_active_attach(argc, argv); + if (ds != start_ok) { + msgbox_res_id(NULL, IDS_INVALID_PARAMS, IDS_AUTO_CAPTION, MB_OK); + return ds; + } + if (!display_crash_dialog()) { + dbg_init_console(); + dbg_start_interactive(INVALID_HANDLE_VALUE); + return start_ok; } - else if (!strcmp(argv[0], "--minidump")) - { - const char* file = NULL; - char tmp[8 + 1 + MAX_PATH]; /* minidump */ - argc--; argv++; - /* hard stuff now ; we can get things like: - * --minidump 1 arg - * --minidump 2 args - * --minidump 2 args - * --minidump 3 args - */ - switch (argc) + hFile = parser_generate_command_file("echo Modules:", "info share", + "echo Threads:", "info threads", + "kill", NULL); + if (hFile == INVALID_HANDLE_VALUE) return start_error_parse; + + dbg_houtput = GetStdHandle(STD_ERROR_HANDLE); + + if (dbg_curr_process->active_debuggee) + dbg_active_wait_for_first_exception(); + + dbg_interactiveP = TRUE; + parser_handle(hFile); + + return start_ok; +} + +/****************************************************************** + * dbg_active_minidump + * + * Starts ( or ) in minidump mode + */ +enum dbg_start dbg_active_minidump(int argc, char* argv[]) +{ + HANDLE hFile; + enum dbg_start ds = start_error_parse; + const char* file = NULL; + char tmp[8 + 1 + MAX_PATH]; /* minidump */ + + dbg_houtput = GetStdHandle(STD_ERROR_HANDLE); + DBG_IVAR(BreakOnDllLoad) = 0; + + argc--; argv++; + /* hard stuff now ; we can get things like: + * --minidump 1 arg + * --minidump 2 args + * --minidump 2 args + * --minidump 3 args + */ + switch (argc) + { + case 1: + ds = dbg_active_attach(argc, argv); + break; + case 2: + if ((ds = dbg_active_attach(argc, argv)) != start_ok) { - case 1: - ds = dbg_active_attach(argc, argv); - break; - case 2: - if ((ds = dbg_active_attach(argc, argv)) != start_ok) - { - file = argv[0]; - ds = dbg_active_attach(argc - 1, argv + 1); - } - break; - case 3: file = argv[0]; ds = dbg_active_attach(argc - 1, argv + 1); - break; - default: - return start_error_parse; } - if (ds != start_ok) return ds; - memcpy(tmp, "minidump \"", 10); - if (!file) - { - char path[MAX_PATH]; - - GetTempPathA(sizeof(path), path); - GetTempFileNameA(path, "WD", 0, tmp + 10); - } - else strcpy(tmp + 10, file); - strcat(tmp, "\""); - if (!file) - { - /* FIXME: should generate unix name as well */ - dbg_printf("Capturing program state in %s\n", tmp + 9); - } - hFile = parser_generate_command_file(tmp, "detach", NULL); + break; + case 3: + file = argv[0]; + ds = dbg_active_attach(argc - 1, argv + 1); + break; + default: + return start_error_parse; } - else return start_error_parse; + if (ds != start_ok) return ds; + memcpy(tmp, "minidump \"", 10); + if (!file) + { + char path[MAX_PATH]; + + GetTempPathA(sizeof(path), path); + GetTempFileNameA(path, "WD", 0, tmp + 10); + } + else strcpy(tmp + 10, file); + strcat(tmp, "\""); + if (!file) + { + /* FIXME: should generate unix name as well */ + dbg_printf("Capturing program state in %s\n", tmp + 9); + } + hFile = parser_generate_command_file(tmp, "detach", NULL); if (hFile == INVALID_HANDLE_VALUE) return start_error_parse; if (dbg_curr_process->active_debuggee) diff --git a/programs/winedbg/winedbg.c b/programs/winedbg/winedbg.c index a3a9f1608ae..c5f44485243 100644 --- a/programs/winedbg/winedbg.c +++ b/programs/winedbg/winedbg.c @@ -89,11 +89,11 @@ DWORD_PTR dbg_curr_tid = 0; DWORD_PTR dbg_curr_pid = 0; CONTEXT dbg_context; BOOL dbg_interactiveP = FALSE; +HANDLE dbg_houtput = 0; static struct list dbg_process_list = LIST_INIT(dbg_process_list); struct dbg_internal_var dbg_internal_vars[DBG_IV_LAST]; -static HANDLE dbg_houtput; static void dbg_outputA(const char* buffer, int len) { @@ -668,11 +668,8 @@ int main(int argc, char** argv) SymSetOptions((SymGetOptions() & ~(SYMOPT_UNDNAME)) | SYMOPT_LOAD_LINES | SYMOPT_DEFERRED_LOADS | SYMOPT_AUTO_PUBLICS); - if (argc && (!strcmp(argv[0], "--auto") || !strcmp(argv[0], "--minidump"))) + if (argc && !strcmp(argv[0], "--auto")) { - /* force some internal variables */ - DBG_IVAR(BreakOnDllLoad) = 0; - dbg_houtput = GetStdHandle(STD_ERROR_HANDLE); switch (dbg_active_auto(argc, argv)) { case start_ok: return 0; @@ -680,6 +677,15 @@ int main(int argc, char** argv) case start_error_init: return -1; } } + if (argc && !strcmp(argv[0], "--minidump")) + { + switch (dbg_active_minidump(argc, argv)) + { + case start_ok: return 0; + case start_error_parse: return dbg_winedbg_usage(FALSE); + case start_error_init: return -1; + } + } /* parse options */ while (argc > 0 && argv[0][0] == '-') {