Commit dea7ced7 authored by Alexandre Julliard's avatar Alexandre Julliard

winedbg: Split minidump option handling to a separate function.

parent adad80f4
......@@ -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);
......
......@@ -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;
}
hFile = parser_generate_command_file("echo Modules:", "info share",
"echo Threads:", "info threads",
"kill", NULL);
DBG_IVAR(BreakOnDllLoad) = 0;
/* 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"))
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 (<pid> or <pid> <evt>) 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 <file> */
dbg_houtput = GetStdHandle(STD_ERROR_HANDLE);
DBG_IVAR(BreakOnDllLoad) = 0;
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)
{
const char* file = NULL;
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:
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];
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);
GetTempPathA(sizeof(path), path);
GetTempFileNameA(path, "WD", 0, tmp + 10);
}
else return start_error_parse;
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)
......
......@@ -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] == '-')
{
......
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