Module: wine Branch: master Commit: 8a65cdd13d431ed47f778639decc6d345d1a99f5 URL: https://gitlab.winehq.org/wine/wine/-/commit/8a65cdd13d431ed47f778639decc6d3...
Author: Eric Pouech epouech@codeweavers.com Date: Wed Mar 20 10:21:28 2024 +0100
winedbg: Add ability to set executable name.
Either from command line option, or as a command. Mostly handy for scripting.
Signed-off-by: Eric Pouech epouech@codeweavers.com
---
programs/winedbg/dbg.y | 3 ++- programs/winedbg/debug.l | 1 + programs/winedbg/debugger.h | 1 + programs/winedbg/tgt_active.c | 7 +++++++ programs/winedbg/winedbg.c | 14 +++++++++----- programs/winedbg/winedbg.man.in | 2 ++ 6 files changed, 22 insertions(+), 6 deletions(-)
diff --git a/programs/winedbg/dbg.y b/programs/winedbg/dbg.y index fc9a2977041..6e71d310c22 100644 --- a/programs/winedbg/dbg.y +++ b/programs/winedbg/dbg.y @@ -58,7 +58,7 @@ static void parser(const char*); %token <string> tPATH tIDENTIFIER tSTRING tINTVAR %token <integer> tNUM tFORMAT %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
/* can be prefixed by module name */ @@ -146,6 +146,7 @@ command: | 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);} | tECHO tSTRING { dbg_printf("%s\n", $2); } + | tEXECFILE pathname { dbg_set_exec_file($2); } | run_command | list_command | disassemble_command diff --git a/programs/winedbg/debug.l b/programs/winedbg/debug.l index dd7fb0db76f..a05a27dfc79 100644 --- a/programs/winedbg/debug.l +++ b/programs/winedbg/debug.l @@ -224,6 +224,7 @@ STRING "(\[^\n]|[^\"\n])*" <INITIAL>rwatch|rwatc|rwat { BEGIN(NOCMD); return tRWATCH; } <INITIAL>whatis|whati|what { BEGIN(NOCMD); return tWHATIS; } <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>kill|kil|ki|k { BEGIN(NOCMD); return tKILL; } <INITIAL,NOPROCESS>maintenance|maint { BEGIN(MAINT_CMD); return tMAINTENANCE; } diff --git a/programs/winedbg/debugger.h b/programs/winedbg/debugger.h index c65b9bfae67..49cab156df1 100644 --- a/programs/winedbg/debugger.h +++ b/programs/winedbg/debugger.h @@ -474,6 +474,7 @@ struct list_string char* string; 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_wait_next_exception(DWORD cont, int count, int mode); extern enum dbg_start dbg_active_attach(int argc, char* argv[]); diff --git a/programs/winedbg/tgt_active.c b/programs/winedbg/tgt_active.c index 9587ef450d2..209d82374c6 100644 --- a/programs/winedbg/tgt_active.c +++ b/programs/winedbg/tgt_active.c @@ -87,6 +87,7 @@ BOOL dbg_attach_debuggee(DWORD pid) SetEnvironmentVariableA("DBGHELP_NOLIVE", NULL);
dbg_curr_process->active_debuggee = TRUE; + dbg_printf("WineDbg attached to pid %04lx\n", dbg_curr_pid); return TRUE; }
@@ -670,6 +671,7 @@ static BOOL dbg_start_debuggee(LPSTR cmdLine) free(dbg_last_cmd_line); dbg_last_cmd_line = cmdLine; } + dbg_printf("WineDbg starting on pid %04lx\n", dbg_curr_pid);
return TRUE; } @@ -755,6 +757,11 @@ static char *dbg_build_command_line( char **argv ) 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) { diff --git a/programs/winedbg/winedbg.c b/programs/winedbg/winedbg.c index 39ce6cbf8a9..b642284f73b 100644 --- a/programs/winedbg/winedbg.c +++ b/programs/winedbg/winedbg.c @@ -637,11 +637,8 @@ void dbg_start_interactive(const char* filename, HANDLE hFile) struct dbg_process* p; struct dbg_process* p2;
- if (dbg_curr_process) - { - dbg_printf("WineDbg starting on pid %04lx\n", dbg_curr_pid); - if (dbg_curr_process->active_debuggee) dbg_active_wait_for_first_exception(); - } + if (dbg_curr_process && dbg_curr_process->active_debuggee) + dbg_active_wait_for_first_exception();
dbg_interactiveP = TRUE; parser_handle(filename, hFile); @@ -759,6 +756,13 @@ int main(int argc, char** argv) argc--; argv++; 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) { argc--; argv++; diff --git a/programs/winedbg/winedbg.man.in b/programs/winedbg/winedbg.man.in index c58696ba1c9..1380832537f 100644 --- a/programs/winedbg/winedbg.man.in +++ b/programs/winedbg/winedbg.man.in @@ -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 winedbg command line, and then will exit. This can be handy for 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 \fBwinedbg\fR will execute the list of commands contained in file filename as if they were keyed on winedbg command line, and then