Interrupting target execution on Linux using GDB/MI

James Milne jamesm@filmlight.ltd.uk
Wed Apr 1 16:37:00 GMT 2009


Hi,

I'm writing a debugger for an interpreted language, and I'm using GDB  
as the underlying mechanism for instrumenting the interpreter process.

I have my debugger application process which fork()/execs() gdb and  
uses the GDB/MI interface to communicate with it.

I then instruct GDB to load my target executable, set a breakpoint on  
main(), specify the arguments I want to pass to the executable using "- 
exec-arguments", and then start the executable using "-exec-run". The  
executable is the interpreter for the language I'm working with.

Once my breakpoint is hit, I can set further breakpoints within the  
interpreter which I use to trace its execution. I can then resume  
execution of the target by sending "-exec-continue".

This is all fine, and works correctly. The problem occurs when I want  
to interrupt the execution of the target process.

I trap the PID of the inferior process by analysing the stream records  
returned from GDB, specifically looking for the first "[New Thread  
<blah> (LWP <pid>)]" style response.

On OS X 10.5.6 using Apple's gdb (GNU gdb 6.3.50-20050815 (Apple  
version gdb-962)), I have to interrupt the target process by sending a  
SIGINT signal directly to the inferior process. This works correctly  
and causes GDB to interrupt the execution of the inferior.

However, if I send SIGINT to the inferior using GDB 6.3 or 6.8 on  
Linux (CentOS 4.3), GDB returns the following:

&"Quit\n"
^error,msg="Quit"

If I send SIGINT to the gdb process itself, it ignores it.

What is the correct procedure when using GDB/MI to interrupt the  
execution of the inferior process?

Regards
James Milne
FilmLight Ltd.



More information about the Gdb mailing list