From 4202c752d30dbca633839a59ad40cdfaf69276af Mon Sep 17 00:00:00 2001 From: Eric Pouech Date: Mon, 27 Feb 2006 21:50:39 +0100 Subject: [PATCH] winedbg: Extend auto mode with minidump. - added -minidump and -minidump options to command line Those options are to be used in remplacement of --auto to create a minidump In the form --minidump , the minidump will be created in , otherwise the filename will be automatically generated. --- programs/winedbg/tgt_active.c | 68 +++++++++++++++++++++++++++++++---- programs/winedbg/winedbg.c | 4 +-- 2 files changed, 62 insertions(+), 10 deletions(-) diff --git a/programs/winedbg/tgt_active.c b/programs/winedbg/tgt_active.c index ac2faaa983f..406c551ef63 100644 --- a/programs/winedbg/tgt_active.c +++ b/programs/winedbg/tgt_active.c @@ -864,13 +864,67 @@ enum dbg_start dbg_active_auto(int argc, char* argv[]) HANDLE hFile; enum dbg_start ds = start_error_parse; - argc--; argv++; - hFile = parser_generate_command_file("echo Modules:", "info share", - "echo Threads:", "info threads", - NULL); - if (hFile == INVALID_HANDLE_VALUE || - (ds = dbg_active_attach(argc, argv)) != start_ok) - return ds; + if (!strcmp(argv[0], "--auto")) + { + /* auto mode */ + argc--; argv++; + ds = dbg_active_attach(argc, argv); + if (ds != start_ok) return ds; + hFile = parser_generate_command_file("echo Modules:", "info share", + "echo Threads:", "info threads", + NULL); + } + 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) + { + 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]; + + GetTempPath(sizeof(path), path); + GetTempFileName(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, NULL); + } + else return start_error_parse; + if (hFile == INVALID_HANDLE_VALUE) return start_error_parse; dbg_main_loop(hFile); return start_ok; } diff --git a/programs/winedbg/winedbg.c b/programs/winedbg/winedbg.c index 40eee6c10e2..7cd7695eaeb 100644 --- a/programs/winedbg/winedbg.c +++ b/programs/winedbg/winedbg.c @@ -34,8 +34,6 @@ /* TODO list: * * - minidump - * + allow winedbg in automatic mode to create a minidump (or add another option - * for that) * + set a mode where winedbg would start (postmortem debugging) from a minidump * - CPU adherence * + we always assume the stack grows as on i386 (ie downwards) @@ -495,7 +493,7 @@ 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")) + if (argc && (!strcmp(argv[0], "--auto") || !strcmp(argv[0], "--minidump"))) { /* force some internal variables */ DBG_IVAR(BreakOnDllLoad) = 0;