winedbg: Auto mode.
- rewrite auto mode startup - move part of auto handling to tgt_active.c
This commit is contained in:
parent
a67f8e862e
commit
893d7524c7
@ -372,8 +372,9 @@ extern void dbg_run_debuggee(const char* args);
|
|||||||
extern void dbg_wait_next_exception(DWORD cont, int count, int mode);
|
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_attach(int argc, char* argv[]);
|
||||||
extern enum dbg_start dbg_active_launch(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[]);
|
||||||
/* temporary for tgt_active.c */
|
/* temporary for tgt_active.c */
|
||||||
extern enum dbg_action_mode {none_mode = 0, winedbg_mode, automatic_mode} dbg_action_mode;
|
extern enum dbg_action_mode {winedbg_mode, automatic_mode} dbg_action_mode;
|
||||||
extern unsigned dbg_main_loop(HANDLE);
|
extern unsigned dbg_main_loop(HANDLE);
|
||||||
|
|
||||||
/* tgt_minidump.c */
|
/* tgt_minidump.c */
|
||||||
|
@ -872,3 +872,15 @@ enum dbg_start dbg_active_launch(int argc, char* argv[])
|
|||||||
dbg_last_cmd_line = cmd_line;
|
dbg_last_cmd_line = cmd_line;
|
||||||
return start_ok;
|
return start_ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/******************************************************************
|
||||||
|
* dbg_active_auto
|
||||||
|
*
|
||||||
|
* Starts (<pid> or <pid> <evt>) in automatic mode
|
||||||
|
*/
|
||||||
|
enum dbg_start dbg_active_auto(int argc, char* argv[])
|
||||||
|
{
|
||||||
|
argc--; argv++;
|
||||||
|
dbg_action_mode = automatic_mode;
|
||||||
|
return dbg_active_attach(argc, argv);
|
||||||
|
}
|
||||||
|
@ -462,8 +462,9 @@ extern struct backend_cpu be_alpha;
|
|||||||
|
|
||||||
int main(int argc, char** argv)
|
int main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
int retv = 0;
|
int retv = 0;
|
||||||
HANDLE hFile = INVALID_HANDLE_VALUE;
|
HANDLE hFile = INVALID_HANDLE_VALUE;
|
||||||
|
enum dbg_start ds;
|
||||||
|
|
||||||
#ifdef __i386__
|
#ifdef __i386__
|
||||||
be_cpu = &be_i386;
|
be_cpu = &be_i386;
|
||||||
@ -489,71 +490,74 @@ int main(int argc, char** argv)
|
|||||||
if (retv == -1) dbg_winedbg_usage();
|
if (retv == -1) dbg_winedbg_usage();
|
||||||
return retv;
|
return retv;
|
||||||
}
|
}
|
||||||
|
dbg_init_console();
|
||||||
|
dbg_action_mode = winedbg_mode;
|
||||||
|
|
||||||
/* parse options */
|
SymSetOptions((SymGetOptions() & ~(SYMOPT_UNDNAME)) |
|
||||||
while (argc > 0 && argv[0][0] == '-')
|
SYMOPT_LOAD_LINES | SYMOPT_DEFERRED_LOADS | SYMOPT_AUTO_PUBLICS);
|
||||||
|
|
||||||
|
if (argc && !strcmp(argv[0], "--auto"))
|
||||||
{
|
{
|
||||||
if (!strcmp(argv[0], "--command"))
|
/* force some internal variables */
|
||||||
{
|
DBG_IVAR(BreakOnDllLoad) = 0;
|
||||||
char path[MAX_PATH], file[MAX_PATH];
|
dbg_houtput = GetStdHandle(STD_ERROR_HANDLE);
|
||||||
DWORD w;
|
ds = dbg_active_auto(argc, argv);
|
||||||
|
|
||||||
GetTempPath(sizeof(path), path);
|
|
||||||
GetTempFileName(path, "WD", 0, file);
|
|
||||||
argc--; argv++;
|
|
||||||
hFile = CreateFileA(file, GENERIC_READ|GENERIC_WRITE|DELETE, FILE_SHARE_DELETE,
|
|
||||||
NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_DELETE_ON_CLOSE, 0);
|
|
||||||
if (hFile == INVALID_HANDLE_VALUE)
|
|
||||||
{
|
|
||||||
dbg_printf("Couldn't open temp file %s (%lu)\n", file, GetLastError());
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
WriteFile(hFile, argv[0], strlen(argv[0]), &w, 0);
|
|
||||||
WriteFile(hFile, "\nquit\n", 6, &w, 0);
|
|
||||||
SetFilePointer(hFile, 0, NULL, FILE_BEGIN);
|
|
||||||
|
|
||||||
argc--; argv++;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (!strcmp(argv[0], "--file"))
|
|
||||||
{
|
|
||||||
argc--; argv++;
|
|
||||||
hFile = CreateFileA(argv[0], GENERIC_READ|DELETE, 0,
|
|
||||||
NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0);
|
|
||||||
if (hFile == INVALID_HANDLE_VALUE)
|
|
||||||
{
|
|
||||||
dbg_printf("Couldn't open file %s (%lu)\n", argv[0], GetLastError());
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
argc--; argv++;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (!strcmp(argv[0], "--auto"))
|
|
||||||
{
|
|
||||||
if (dbg_action_mode != none_mode) return dbg_winedbg_usage();
|
|
||||||
dbg_action_mode = automatic_mode;
|
|
||||||
/* force some internal variables */
|
|
||||||
DBG_IVAR(BreakOnDllLoad) = 0;
|
|
||||||
argc--; argv++;
|
|
||||||
dbg_houtput = GetStdHandle(STD_ERROR_HANDLE);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
return dbg_winedbg_usage();
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
if (dbg_action_mode == none_mode) dbg_action_mode = winedbg_mode;
|
|
||||||
if (!argc || dbg_active_attach(argc, argv) == start_ok ||
|
|
||||||
dbg_active_launch(argc, argv) == start_ok)
|
|
||||||
{
|
{
|
||||||
dbg_init_console();
|
/* parse options */
|
||||||
|
while (argc > 0 && argv[0][0] == '-')
|
||||||
|
{
|
||||||
|
if (!strcmp(argv[0], "--command"))
|
||||||
|
{
|
||||||
|
char path[MAX_PATH], file[MAX_PATH];
|
||||||
|
DWORD w;
|
||||||
|
|
||||||
SymSetOptions((SymGetOptions() & ~(SYMOPT_UNDNAME)) |
|
GetTempPath(sizeof(path), path);
|
||||||
SYMOPT_LOAD_LINES | SYMOPT_DEFERRED_LOADS | SYMOPT_AUTO_PUBLICS);
|
GetTempFileName(path, "WD", 0, file);
|
||||||
|
argc--; argv++;
|
||||||
|
hFile = CreateFileA(file, GENERIC_READ|GENERIC_WRITE|DELETE, FILE_SHARE_DELETE,
|
||||||
|
NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_DELETE_ON_CLOSE, 0);
|
||||||
|
if (hFile == INVALID_HANDLE_VALUE)
|
||||||
|
{
|
||||||
|
dbg_printf("Couldn't open temp file %s (%lu)\n", file, GetLastError());
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
WriteFile(hFile, argv[0], strlen(argv[0]), &w, 0);
|
||||||
|
WriteFile(hFile, "\nquit\n", 6, &w, 0);
|
||||||
|
SetFilePointer(hFile, 0, NULL, FILE_BEGIN);
|
||||||
|
|
||||||
retv = dbg_main_loop(hFile);
|
argc--; argv++;
|
||||||
/* don't save modified variables in auto mode */
|
continue;
|
||||||
if (dbg_action_mode != automatic_mode) dbg_save_internal_vars();
|
}
|
||||||
|
if (!strcmp(argv[0], "--file"))
|
||||||
|
{
|
||||||
|
argc--; argv++;
|
||||||
|
hFile = CreateFileA(argv[0], GENERIC_READ|DELETE, 0,
|
||||||
|
NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0);
|
||||||
|
if (hFile == INVALID_HANDLE_VALUE)
|
||||||
|
{
|
||||||
|
dbg_printf("Couldn't open file %s (%lu)\n", argv[0], GetLastError());
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
argc--; argv++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
return dbg_winedbg_usage();
|
||||||
|
}
|
||||||
|
if (!argc) ds = start_ok;
|
||||||
|
else if ((ds = dbg_active_attach(argc, argv)) == start_error_parse)
|
||||||
|
ds = dbg_active_launch(argc, argv);
|
||||||
}
|
}
|
||||||
|
switch (ds)
|
||||||
|
{
|
||||||
|
case start_ok: break;
|
||||||
|
case start_error_parse: return dbg_winedbg_usage();
|
||||||
|
case start_error_init: return -1;
|
||||||
|
}
|
||||||
|
retv = dbg_main_loop(hFile);
|
||||||
|
/* don't save modified variables in auto mode */
|
||||||
|
if (dbg_action_mode != automatic_mode) dbg_save_internal_vars();
|
||||||
|
|
||||||
return retv;
|
return retv;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user