[PATCH 07/12] [WineDbg]: extend auto mode with minidump
Eric Pouech
eric.pouech at wanadoo.fr
Fri Feb 24 15:16:11 CST 2006
- added -minidump and -minidump <file> options to command line
Those options are to be used in remplacement of --auto to create a minidump
In the form --minidump <file>, the minidump will be created in <file>,
otherwise the filename will be automatically generated
A+
---
programs/winedbg/tgt_active.c | 67 +++++++++++++++++++++++++++++++++++++----
programs/winedbg/winedbg.c | 4 +-
2 files changed, 62 insertions(+), 9 deletions(-)
diff --git a/programs/winedbg/tgt_active.c b/programs/winedbg/tgt_active.c
index 53d3a4d..a035553 100644
--- a/programs/winedbg/tgt_active.c
+++ b/programs/winedbg/tgt_active.c
@@ -863,12 +863,67 @@ enum dbg_start dbg_active_auto(int argc,
{
HANDLE hFile;
- argc--; argv++;
- hFile = parser_generate_command_file("echo Modules:", "info share",
- "echo Threads:", "info threads",
- NULL);
- if (hFile == INVALID_HANDLE_VALUE || !dbg_active_attach(argc, argv))
- return FALSE;
+ if (!strcmp(argv[0], "--auto"))
+ {
+ /* auto mode */
+ argc--; argv++;
+ if (!dbg_active_attach(argc, argv)) return FALSE;
+ hFile = parser_generate_command_file("echo Modules:", "info share",
+ "echo Threads:", "info threads",
+ NULL);
+ }
+ else if (!strcmp(argv[0], "--minidump"))
+ {
+ const char* file = NULL;
+ BOOL ret;
+ char tmp[8 + 1 + MAX_PATH]; /* minidump <file> */
+
+ argc--; argv++;
+ /* hard stuff now ; we can get things like:
+ * --minidump <pid> 1 arg
+ * --minidump <pid> <evt> 2 args
+ * --minidump <file> <pid> 2 args
+ * --minidump <file> <pid> <evt> 3 args
+ */
+ switch (argc)
+ {
+ case 1:
+ ret = dbg_active_attach(argc, argv);
+ break;
+ case 2:
+ if (!(ret = dbg_active_attach(argc, argv)))
+ {
+ file = argv[0];
+ ret = dbg_active_attach(argc - 1, argv + 1);
+ }
+ break;
+ case 3:
+ file = argv[0];
+ ret = dbg_active_attach(argc - 1, argv + 1);
+ break;
+ default:
+ return FALSE;
+ }
+ if (!ret) return FALSE;
+ 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 FALSE;
+ if (hFile == INVALID_HANDLE_VALUE) return FALSE;
dbg_main_loop(hFile);
return TRUE;
}
diff --git a/programs/winedbg/winedbg.c b/programs/winedbg/winedbg.c
index 40eee6c..7cd7695 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;
More information about the wine-patches
mailing list