Mirror of the gdb mailing list
 help / color / mirror / Atom feed
* Interrupting target execution on Linux using GDB/MI
@ 2009-04-01 16:37 James Milne
  2009-04-01 16:42 ` Joel Brobecker
  0 siblings, 1 reply; 4+ messages in thread
From: James Milne @ 2009-04-01 16:37 UTC (permalink / raw)
  To: gdb

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.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Interrupting target execution on Linux using GDB/MI
  2009-04-01 16:37 Interrupting target execution on Linux using GDB/MI James Milne
@ 2009-04-01 16:42 ` Joel Brobecker
  2009-04-01 16:45   ` James Milne
  0 siblings, 1 reply; 4+ messages in thread
From: Joel Brobecker @ 2009-04-01 16:42 UTC (permalink / raw)
  To: James Milne; +Cc: gdb

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

There is a GDB/MI command to interrupt the execution of your program.

-- 
Joel


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Interrupting target execution on Linux using GDB/MI
  2009-04-01 16:42 ` Joel Brobecker
@ 2009-04-01 16:45   ` James Milne
  2009-04-01 17:14     ` Marc Khouzam
  0 siblings, 1 reply; 4+ messages in thread
From: James Milne @ 2009-04-01 16:45 UTC (permalink / raw)
  To: Joel Brobecker; +Cc: gdb

On 1 Apr 2009, at 17:41, Joel Brobecker wrote:
>> What is the correct procedure when using GDB/MI to interrupt the
>> execution of the inferior process?
>
> There is a GDB/MI command to interrupt the execution of your program.

I attempted to use that, but it does not work when GDB is being used  
synchronously. It only works when you are connecting to a gdbserver  
and GDB itself is running "asynchronously".

Certainly it doesn't work on OS X when I originally tried it, which  
lead me to issuing SIGINT myself.

Regards
James Milne
FilmLight Ltd.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* RE: Interrupting target execution on Linux using GDB/MI
  2009-04-01 16:45   ` James Milne
@ 2009-04-01 17:14     ` Marc Khouzam
  0 siblings, 0 replies; 4+ messages in thread
From: Marc Khouzam @ 2009-04-01 17:14 UTC (permalink / raw)
  To: James Milne, Joel Brobecker; +Cc: gdb

We've just had a discussion about this as a bug to Eclipse CDT.
You may find some of the information useful.

https://bugs.eclipse.org/bugs/show_bug.cgi?id=265483
 

> -----Original Message-----
> From: gdb-owner@sourceware.org 
> [mailto:gdb-owner@sourceware.org] On Behalf Of James Milne
> Sent: Wednesday, April 01, 2009 12:45 PM
> To: Joel Brobecker
> Cc: gdb@sourceware.org
> Subject: Re: Interrupting target execution on Linux using GDB/MI
> 
> On 1 Apr 2009, at 17:41, Joel Brobecker wrote:
> >> What is the correct procedure when using GDB/MI to interrupt the
> >> execution of the inferior process?
> >
> > There is a GDB/MI command to interrupt the execution of 
> your program.
> 
> I attempted to use that, but it does not work when GDB is being used  
> synchronously. It only works when you are connecting to a gdbserver  
> and GDB itself is running "asynchronously".
> 
> Certainly it doesn't work on OS X when I originally tried it, which  
> lead me to issuing SIGINT myself.
> 
> Regards
> James Milne
> FilmLight Ltd.
> 


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2009-04-01 17:14 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-04-01 16:37 Interrupting target execution on Linux using GDB/MI James Milne
2009-04-01 16:42 ` Joel Brobecker
2009-04-01 16:45   ` James Milne
2009-04-01 17:14     ` Marc Khouzam

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox