Commit 8a65cdd1 authored by Eric Pouech's avatar Eric Pouech Committed by Alexandre Julliard

winedbg: Add ability to set executable name.

Either from command line option, or as a command. Mostly handy for scripting. Signed-off-by: 's avatarEric Pouech <epouech@codeweavers.com>
parent 5d91ab65
...@@ -58,7 +58,7 @@ static void parser(const char*); ...@@ -58,7 +58,7 @@ static void parser(const char*);
%token <string> tPATH tIDENTIFIER tSTRING tINTVAR %token <string> tPATH tIDENTIFIER tSTRING tINTVAR
%token <integer> tNUM tFORMAT %token <integer> tNUM tFORMAT
%token <type> tTYPEDEF %token <type> tTYPEDEF
%token tSYMBOLFILE tRUN tATTACH tDETACH tKILL tMAINTENANCE tTYPE tMINIDUMP %token tSYMBOLFILE tEXECFILE tRUN tATTACH tDETACH tKILL tMAINTENANCE tTYPE tMINIDUMP
%token tNOPROCESS tWOW %token tNOPROCESS tWOW
/* can be prefixed by module name */ /* can be prefixed by module name */
...@@ -146,6 +146,7 @@ command: ...@@ -146,6 +146,7 @@ command:
| tKILL { dbg_curr_process->process_io->close_process(dbg_curr_process, TRUE); } | tKILL { dbg_curr_process->process_io->close_process(dbg_curr_process, TRUE); }
| tMINIDUMP pathname { minidump_write($2, (dbg_curr_thread && dbg_curr_thread->in_exception) ? &dbg_curr_thread->excpt_record : NULL);} | tMINIDUMP pathname { minidump_write($2, (dbg_curr_thread && dbg_curr_thread->in_exception) ? &dbg_curr_thread->excpt_record : NULL);}
| tECHO tSTRING { dbg_printf("%s\n", $2); } | tECHO tSTRING { dbg_printf("%s\n", $2); }
| tEXECFILE pathname { dbg_set_exec_file($2); }
| run_command | run_command
| list_command | list_command
| disassemble_command | disassemble_command
......
...@@ -224,6 +224,7 @@ STRING \"(\\[^\n]|[^\\"\n])*\" ...@@ -224,6 +224,7 @@ STRING \"(\\[^\n]|[^\\"\n])*\"
<INITIAL>rwatch|rwatc|rwat { BEGIN(NOCMD); return tRWATCH; } <INITIAL>rwatch|rwatc|rwat { BEGIN(NOCMD); return tRWATCH; }
<INITIAL>whatis|whati|what { BEGIN(NOCMD); return tWHATIS; } <INITIAL>whatis|whati|what { BEGIN(NOCMD); return tWHATIS; }
<INITIAL,NOPROCESS>run|ru|r { BEGIN(AWORD_EXPECTED); return tRUN;} <INITIAL,NOPROCESS>run|ru|r { BEGIN(AWORD_EXPECTED); return tRUN;}
<INITIAL,NOPROCESS>exec-file { BEGIN(PATH_EXPECTED); return tEXECFILE;}
<INITIAL>detach|detac|deta|det { BEGIN(NOCMD); return tDETACH; } <INITIAL>detach|detac|deta|det { BEGIN(NOCMD); return tDETACH; }
<INITIAL>kill|kil|ki|k { BEGIN(NOCMD); return tKILL; } <INITIAL>kill|kil|ki|k { BEGIN(NOCMD); return tKILL; }
<INITIAL,NOPROCESS>maintenance|maint { BEGIN(MAINT_CMD); return tMAINTENANCE; } <INITIAL,NOPROCESS>maintenance|maint { BEGIN(MAINT_CMD); return tMAINTENANCE; }
......
...@@ -474,6 +474,7 @@ struct list_string ...@@ -474,6 +474,7 @@ struct list_string
char* string; char* string;
struct list_string* next; struct list_string* next;
}; };
extern void dbg_set_exec_file(const char *path);
extern void dbg_run_debuggee(struct list_string* ls); extern void dbg_run_debuggee(struct list_string* ls);
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[]);
......
...@@ -87,6 +87,7 @@ BOOL dbg_attach_debuggee(DWORD pid) ...@@ -87,6 +87,7 @@ BOOL dbg_attach_debuggee(DWORD pid)
SetEnvironmentVariableA("DBGHELP_NOLIVE", NULL); SetEnvironmentVariableA("DBGHELP_NOLIVE", NULL);
dbg_curr_process->active_debuggee = TRUE; dbg_curr_process->active_debuggee = TRUE;
dbg_printf("WineDbg attached to pid %04lx\n", dbg_curr_pid);
return TRUE; return TRUE;
} }
...@@ -670,6 +671,7 @@ static BOOL dbg_start_debuggee(LPSTR cmdLine) ...@@ -670,6 +671,7 @@ static BOOL dbg_start_debuggee(LPSTR cmdLine)
free(dbg_last_cmd_line); free(dbg_last_cmd_line);
dbg_last_cmd_line = cmdLine; dbg_last_cmd_line = cmdLine;
} }
dbg_printf("WineDbg starting on pid %04lx\n", dbg_curr_pid);
return TRUE; return TRUE;
} }
...@@ -755,6 +757,11 @@ static char *dbg_build_command_line( char **argv ) ...@@ -755,6 +757,11 @@ static char *dbg_build_command_line( char **argv )
return ret; return ret;
} }
void dbg_set_exec_file(const char *path)
{
free(dbg_executable);
dbg_executable = strdup(path);
}
void dbg_run_debuggee(struct list_string* ls) void dbg_run_debuggee(struct list_string* ls)
{ {
......
...@@ -637,11 +637,8 @@ void dbg_start_interactive(const char* filename, HANDLE hFile) ...@@ -637,11 +637,8 @@ void dbg_start_interactive(const char* filename, HANDLE hFile)
struct dbg_process* p; struct dbg_process* p;
struct dbg_process* p2; struct dbg_process* p2;
if (dbg_curr_process) if (dbg_curr_process && dbg_curr_process->active_debuggee)
{ dbg_active_wait_for_first_exception();
dbg_printf("WineDbg starting on pid %04lx\n", dbg_curr_pid);
if (dbg_curr_process->active_debuggee) dbg_active_wait_for_first_exception();
}
dbg_interactiveP = TRUE; dbg_interactiveP = TRUE;
parser_handle(filename, hFile); parser_handle(filename, hFile);
...@@ -759,6 +756,13 @@ int main(int argc, char** argv) ...@@ -759,6 +756,13 @@ int main(int argc, char** argv)
argc--; argv++; argc--; argv++;
continue; continue;
} }
if (!strcmp(argv[0], "--exec") && argc > 1)
{
argc--; argv++;
dbg_set_exec_file(argv[0]);
argc--; argv++;
continue;
}
if (!strcmp(argv[0], "--file") && argc > 1) if (!strcmp(argv[0], "--file") && argc > 1)
{ {
argc--; argv++; argc--; argv++;
......
...@@ -61,6 +61,8 @@ When in \fBdefault\fR mode, the following options are available: ...@@ -61,6 +61,8 @@ When in \fBdefault\fR mode, the following options are available:
\fBwinedbg\fR will execute the command \fIstring\fR as if it was keyed on \fBwinedbg\fR will execute the command \fIstring\fR as if it was keyed on
winedbg command line, and then will exit. This can be handy for winedbg command line, and then will exit. This can be handy for
getting the pid of running processes (winedbg --command "info proc"). getting the pid of running processes (winedbg --command "info proc").
.IP \fB--exec\ \fIfilename\fR
Sets the executable name, without starting the executable.
.IP \fB--file\ \fIfilename\fR .IP \fB--file\ \fIfilename\fR
\fBwinedbg\fR will execute the list of commands contained in file \fBwinedbg\fR will execute the list of commands contained in file
filename as if they were keyed on winedbg command line, and then filename as if they were keyed on winedbg command line, and then
......
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