This is the mail archive of the gdb@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: How to interrupt GDB from outside?


This is how I made it work. It may not be the only way, and may not even be
the best way to do it, but it worked for me. Disclaimer: I don't know
whether this will work on Cygwin or not - I used the mingw gdb on Windows
and that has to be handled differently.

You need to create a pseudo-tty and connect gdb's I/O to the slave side of
it. Your program will attach to the master side. You also need to use the
tty command (or the -tty command-line option) to set the terminal for the
inferior to the pseudo-tty. You may need to set some terminal options via
tcsetattr() to get everything to work right. For one, you'll probably want
to disable echoing of input. Before execing gdb, the child part of your
fork() will need to set up the pseudo-tty as the controlling terminal for
the process, and become the process group leader.

See the xemacs sources (process-unix.c) for more details.

Regards
Arnab

> From: Marco Zandonadi
> Subject: How to interrupt GDB from outside?
>
> Hello,
> I'm writing a C program that drives GDB 5.3 under
> Linux and Cygwin. I succesfully execv'd GDB and
> redirected its I/O using dup2 (): my program can now
> send commands to GDB and parse their output.

> My problem is that I didn't succeed in having my
> program interrupt GDB (like a human would with ^C). I
> tried sending a SIGINT signal from my program to GDB
> with kill () but it didn't help: GDB does not stop
> running the debugged program, it simply ignores the
> SIGINT. The behavior is the same under Linux and
> Cygwin.



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]