[gnome-builder] gdb: work around gdb issue with zsh/fish
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] gdb: work around gdb issue with zsh/fish
- Date: Fri, 30 Apr 2021 18:52:40 +0000 (UTC)
commit 568662b3f15b2bdc8457c67309545cfb9d4f18d9
Author: Christian Hergert <chergert redhat com>
Date: Fri Apr 30 11:52:27 2021 -0700
gdb: work around gdb issue with zsh/fish
gdb appears to be running commands when --args is used with something like:
'$SHELL -c "exec binary"'
and that can cause issues with some shells such as Fish or ZSH.
Fixes #1447
src/plugins/gdb/gbp-gdb-debugger.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
---
diff --git a/src/plugins/gdb/gbp-gdb-debugger.c b/src/plugins/gdb/gbp-gdb-debugger.c
index 060e435a8..8b6cc44e1 100644
--- a/src/plugins/gdb/gbp-gdb-debugger.c
+++ b/src/plugins/gdb/gbp-gdb-debugger.c
@@ -22,6 +22,7 @@
#include <dazzle.h>
#include <libide-io.h>
+#include <libide-terminal.h>
#include <string.h>
#include "gbp-gdb-debugger.h"
@@ -2345,7 +2346,9 @@ gbp_gdb_debugger_prepare (IdeDebugger *debugger,
IdeRunner *runner)
{
static const gchar *prepend_argv[] = { "gdb", "--interpreter=mi2", "--args" };
+ const char *shell;
GbpGdbDebugger *self = (GbpGdbDebugger *)debugger;
+ IdeEnvironment *env;
VtePty *pty;
IDE_ENTRY;
@@ -2353,10 +2356,19 @@ gbp_gdb_debugger_prepare (IdeDebugger *debugger,
g_assert (GBP_IS_GDB_DEBUGGER (self));
g_assert (IDE_IS_RUNNER (runner));
+ env = ide_runner_get_environment (runner);
+
/* Prepend arguments in reverse to preserve ordering */
for (guint i = G_N_ELEMENTS (prepend_argv); i > 0; i--)
ide_runner_prepend_argv (runner, prepend_argv [i-1]);
+ /* Override $SHELL unless it's sh or bash as that tends to break things
+ * like '$SHELL -c "exec $APP"' in gdb.
+ */
+ shell = ide_get_user_shell ();
+ if (!ide_str_equal0 (shell, "sh") && !ide_str_equal0 (shell, "bash"))
+ ide_environment_setenv (env, "SHELL", "sh");
+
/* Connect to all our important signals */
dzl_signal_group_set_target (self->runner_signals, runner);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]