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