[gnome-builder/wip/chergert/debugger: 62/106] gdb: use /proc/self/fd/$fdnum to share inferior TTY
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder/wip/chergert/debugger: 62/106] gdb: use /proc/self/fd/$fdnum to share inferior TTY
- Date: Sat, 8 Apr 2017 02:31:18 +0000 (UTC)
commit f01c3fe2a2f40c93d837dea5dab828f114acdb3d
Author: Christian Hergert <chergert redhat com>
Date: Fri Mar 24 04:38:16 2017 -0700
gdb: use /proc/self/fd/$fdnum to share inferior TTY
We need to do something (slightly) tricky here because we don't have a
way to access /dev/pts/$pty, as gdb will possibly in another sandbox.
But we can pass in the PTY and get access to it as a FD.
plugins/gdb/gdb_plugin.py | 10 ++++------
1 files changed, 4 insertions(+), 6 deletions(-)
---
diff --git a/plugins/gdb/gdb_plugin.py b/plugins/gdb/gdb_plugin.py
index bd87bdc..dc8c8b3 100644
--- a/plugins/gdb/gdb_plugin.py
+++ b/plugins/gdb/gdb_plugin.py
@@ -42,8 +42,6 @@ class GdbDebugger(Ide.Object, Ide.Debugger):
client = None
def __del__(self):
- if self.inferior_pty is not None:
- os.close(self.inferior_pty)
if self.client:
self.client.stop_listening()
@@ -68,8 +66,9 @@ class GdbDebugger(Ide.Object, Ide.Debugger):
# We need to steal the TTY from the runner (if there is one) so
# that we can tell GDB to use it. But we need our own access to
- # gdb over a regular stdin/stdout pipe.
- self.inferior_pty = runner.steal_tty()
+ # gdb over a regular stdin/stdout pipe. We remap the TTY in as
+ # a different FD so that we can use it later from gdb.
+ self.inferior_pty = runner.take_fd(runner.steal_tty(), -1)
# We need access to stdin/stdout so that we can communicate with
# the gdb process.
@@ -94,8 +93,7 @@ class GdbDebugger(Ide.Object, Ide.Debugger):
# We stole the pty from the runner so that we could pass it to gdb
# instead. This will ensure that gdb re-opens that pty. Since gdb is
# in the same sandbox as the application, this should Just Workâ˘.
- ttyname = os.ttyname(self.inferior_pty)
- command = '-gdb-set inferior-tty {}'.format(ttyname)
+ command = '-gdb-set inferior-tty /proc/self/fd/{}'.format(self.inferior_pty)
self.client.exec_async(command, None, self.on_client_exec_cb, command)
# Add a breakpoint at main()
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]