* [RFC] patch to make GDB open a new terminal window for the inferior
@ 2009-05-20 0:18 Thiago Jung Bauermann
2009-05-20 17:48 ` Eli Zaretskii
0 siblings, 1 reply; 2+ messages in thread
From: Thiago Jung Bauermann @ 2009-05-20 0:18 UTC (permalink / raw)
To: gdb-patches ml
Hi,
I have this patch sitting in my hard disk for the past 1 year now, and I
still don't think I'll have the chance to work on it anytime soon:
It makes GDB open a new terminal window for each run of the inferior.
It's very rough at this point, and supports only urxvt terminal windows
because it was the only terminal program which seemed to accept being
given a master pty to use. I was meaning to modify the patch and GNU
screen to enable GDB to open a new screen window too, but still didn't
get around to that. It could also be integrated with the Python support
(e.g, call a python function which will return the master pty to use).
It's already functional though, and I believe it still applies cleanly.
To use the feature:
(gdb) tty urxvt
(gdb) run
I'm posting it to see what people think of it, and if anyone want to
adopt it for further development. Doug Evans already expressed interest
on IRC...
--
[]'s
Thiago Jung Bauermann
IBM Linux Technology Center
2009-05-29 Thiago Jung Bauermann <bauerman@br.ibm.com>
* inflow.c (new_tty_prefork): Open new pty and urxvt instance
for each run of the inferior.
=== modified file 'gdb/inflow.c'
--- gdb/inflow.c 2008-01-04 03:27:45 +0000
+++ gdb/inflow.c 2008-01-20 20:44:52 +0000
@@ -504,9 +504,58 @@ child_terminal_info (char *args, int fro
void
new_tty_prefork (const char *ttyname)
{
- /* Save the name for later, for determining whether we and the child
- are sharing a tty. */
- inferior_thisrun_terminal = ttyname;
+ if (ttyname && strcmp (ttyname, "urxvt") == 0)
+ {
+ int master, res;
+ char *pty_fd;
+
+ master = open ("/dev/ptmx", O_RDWR | O_NOCTTY);
+ if (master == -1)
+ {
+ print_sys_errmsg ("/dev/ptmx", errno);
+ _exit (1);
+ }
+
+ res = asprintf (&pty_fd, "%d", master);
+ if (res < 0)
+ error ("Can't allocate memory for starting the terminal emulator.\n");
+
+ /* FIXME: check if SIGCHLD must be unset before call. */
+ res = grantpt (master);
+ if (res < 0)
+ error ("Error setting up terminal emulator: grantpt: %s",
+ safe_strerror (errno));
+
+ res = unlockpt (master);
+ if (res < 0)
+ error ("Error setting up terminal emulator: unlockpt: %s",
+ safe_strerror (errno));
+
+ /* FIXME: change to point to more permanent string? */
+ inferior_thisrun_terminal = ptsname (master);
+
+#if defined (CANT_FORK) || (!defined (HAVE_WORKING_VFORK) && \
+ !defined (HAVE_WORKING_FORK))
+ /* FIXME: provide alternative to CANT_FORK case. */
+ internal_error (__FILE__, __LINE__, "Can't fork out terminal emulator.");
+#else
+ /* fire up the terminal emulator */
+ if (vfork () == 0)
+ {
+ execlp ("urxvt", "urxvt", "--hold", "-pty-fd", pty_fd, (char *) NULL);
+
+ _exit (EXIT_FAILURE);
+ }
+#endif /* CANT_FORK etc. */
+
+ free (pty_fd);
+
+ sleep (5);
+ }
+ else
+ /* Save the name for later, for determining whether we and the child
+ are sharing a tty. */
+ inferior_thisrun_terminal = ttyname;
}
void
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [RFC] patch to make GDB open a new terminal window for the inferior
2009-05-20 0:18 [RFC] patch to make GDB open a new terminal window for the inferior Thiago Jung Bauermann
@ 2009-05-20 17:48 ` Eli Zaretskii
0 siblings, 0 replies; 2+ messages in thread
From: Eli Zaretskii @ 2009-05-20 17:48 UTC (permalink / raw)
To: Thiago Jung Bauermann; +Cc: gdb-patches
> From: Thiago Jung Bauermann <bauerman@br.ibm.com>
> Date: Tue, 19 May 2009 21:18:01 -0300
>
> I'm posting it to see what people think of it, and if anyone want to
> adopt it for further development.
This code needs to be carefully ifdef'ed for platforms that don't
support features it relies upon, such as O_NOCTTY, "/dev/ptmx", and
`grantpt'.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2009-05-20 17:48 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-05-20 0:18 [RFC] patch to make GDB open a new terminal window for the inferior Thiago Jung Bauermann
2009-05-20 17:48 ` Eli Zaretskii
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox