[gnome-builder] plugins/debugger: add runtime warnings for unexpeted streams



commit 34c3e4d2c2d9e430d8fcc7ea70d2871044d6e64d
Author: Christian Hergert <chergert redhat com>
Date:   Tue Sep 27 17:11:49 2022 -0700

    plugins/debugger: add runtime warnings for unexpeted streams

 src/plugins/gdb/gbp-gdb-debugger.c | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)
---
diff --git a/src/plugins/gdb/gbp-gdb-debugger.c b/src/plugins/gdb/gbp-gdb-debugger.c
index 0cef71a1f..38a62171b 100644
--- a/src/plugins/gdb/gbp-gdb-debugger.c
+++ b/src/plugins/gdb/gbp-gdb-debugger.c
@@ -20,9 +20,16 @@
 
 #define G_LOG_DOMAIN "gbp-gdb-debugger"
 
+#include "config.h"
+
+#include <string.h>
+#include <unistd.h>
+
+#include <gio/gunixinputstream.h>
+#include <gio/gunixoutputstream.h>
+
 #include <libide-io.h>
 #include <libide-terminal.h>
-#include <string.h>
 
 #include "gbp-gdb-debugger.h"
 
@@ -2373,6 +2380,7 @@ gbp_gdb_debugger_run_context_handler_cb (IdeRunContext       *run_context,
    */
   pty_source_fd = ide_unix_fd_map_steal_stdout (unix_fd_map);
   g_warn_if_fail (pty_source_fd != -1);
+  g_warn_if_fail (isatty (pty_source_fd));
 
   /* Save the PTY fd around to attach after spawning */
   pty_dest_fd = ide_unix_fd_map_get_max_dest_fd (unix_fd_map) + 1;
@@ -2386,6 +2394,10 @@ gbp_gdb_debugger_run_context_handler_cb (IdeRunContext       *run_context,
                                                    error)))
     IDE_RETURN (FALSE);
 
+  /* Make sure we don't have a PTY for our in/out stream */
+  g_warn_if_fail (!isatty (g_unix_input_stream_get_fd (G_UNIX_INPUT_STREAM (g_io_stream_get_input_stream 
(io_stream)))));
+  g_warn_if_fail (!isatty (g_unix_output_stream_get_fd (G_UNIX_OUTPUT_STREAM (g_io_stream_get_output_stream 
(io_stream)))));
+
   /* Now merge the FD map down a layer */
   if (!ide_run_context_merge_unix_fd_map (run_context, unix_fd_map, error))
     IDE_RETURN (FALSE);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]