1
0
Fork 0
mirror of synced 2025-03-07 03:53:26 +01:00

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>
This commit is contained in:
Eric Pouech 2024-03-20 10:21:28 +01:00 committed by Alexandre Julliard
parent 5d91ab65fa
commit 8a65cdd13d
6 changed files with 22 additions and 6 deletions

View file

@ -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

View file

@ -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; }

View file

@ -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[]);

View file

@ -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)
{

View file

@ -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++;

View file

@ -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