Make use of dbg.args on *nix and macos (#17846)

As with the windbg implementation of fork_and_ptraceme, this checks for
the presence io->args and appends them to the child command before
invoking it.

The primary purpose of this fix is to make argument-passing possible
when using Cutter to debug programs, as Cutter sets dbg.args in order to
pass user-provided arguments to the child task. Presently, this does not
do anything on *nix platforms, greatly limiting Cutter's usefulness
insofar as debugging.
This commit is contained in:
Roman Hargrave 2020-10-26 00:56:59 -05:00 committed by GitHub
parent 5e9fd04843
commit 5aff070b0f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -432,15 +432,18 @@ static int fork_and_ptraceme_for_unix(RIO *io, int bits, const char *cmd) {
#endif
static int fork_and_ptraceme(RIO *io, int bits, const char *cmd) {
#if __APPLE__
# if __POWERPC__
return fork_and_ptraceme_for_unix (io, bits, cmd);
# else
return fork_and_ptraceme_for_mac (io, bits, cmd);
# endif
// Before calling the platform implementation, append arguments to the command if they have been provided
char *_eff_cmd = io->args ? r_str_appendf (strdup (cmd), " %s", io->args) : strdup(cmd);
int r = 0;
#if __APPLE__ && !__POWERPC__
r = fork_and_ptraceme_for_mac (io, bits, _eff_cmd);
#else
return fork_and_ptraceme_for_unix (io, bits, cmd);
r = fork_and_ptraceme_for_unix (io, bits, _eff_cmd);
#endif
free (_eff_cmd);
return r;
}
#endif