public inbox for gdb@sourceware.org
 help / color / mirror / Atom feed
* proper usage of "-exec-interrupt"
@ 2011-09-17  7:17 Alexander Petukhov
  2011-09-17 19:06 ` Joel Brobecker
  0 siblings, 1 reply; 3+ messages in thread
From: Alexander Petukhov @ 2011-09-17  7:17 UTC (permalink / raw)
  To: gdb

Hi,
I'm writing a GDB plugin for an IDE and I'm using async target in MI mode
to allow user to alter breakpoints while debugging.
As I learned I have to use "-exec-interrupt" command to stop a debugger but
when I'm doing so a process that spawns GDB, i.e. an IDE receives SIGINT 
and exits accordingly.
Unfortunately I wasn't able to intercept a signal in IDE as it's written 
with GTK and signal functions do not work for some reason.
The other way I've found is to send SIGINT directly to a GDB process and 
it worked for me but
recently another developer reported that he has problem with finishing 
the whole X session when trying to interrupt GDB in this way, looks like 
SIGINT reached X session manager...

Whay does this signal come to parent process and can I avoid this somehow?

Thanks, Alexander

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

* Re: proper usage of "-exec-interrupt"
  2011-09-17  7:17 proper usage of "-exec-interrupt" Alexander Petukhov
@ 2011-09-17 19:06 ` Joel Brobecker
  2011-09-19 14:13   ` Alexander Petukhov
  0 siblings, 1 reply; 3+ messages in thread
From: Joel Brobecker @ 2011-09-17 19:06 UTC (permalink / raw)
  To: Alexander Petukhov; +Cc: gdb

> Whay does this signal come to parent process and can I avoid this
> somehow?

This is a bit of a guess, since I don't remember all the details,
but I think it might be a question of process group. To implement
the interrupt, many targets simply send a SIGINT signal to the
inferior process group. If you spawned GDB within the same process
group as GDB, and both GDB and the program being debugged share
the same process group as well, the interrupt will cause SIGINT
to be received by your IDE as well. So, try spawning GDB in its
own process group.

-- 
Joel

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

* Re: proper usage of "-exec-interrupt"
  2011-09-17 19:06 ` Joel Brobecker
@ 2011-09-19 14:13   ` Alexander Petukhov
  0 siblings, 0 replies; 3+ messages in thread
From: Alexander Petukhov @ 2011-09-19 14:13 UTC (permalink / raw)
  To: Joel Brobecker; +Cc: gdb

On 9/17/11 11:06 PM, Joel Brobecker wrote:
>> Whay does this signal come to parent process and can I avoid this
>> somehow?
> This is a bit of a guess, since I don't remember all the details,
> but I think it might be a question of process group. To implement
> the interrupt, many targets simply send a SIGINT signal to the
> inferior process group. If you spawned GDB within the same process
> group as GDB, and both GDB and the program being debugged share
> the same process group as well, the interrupt will cause SIGINT
> to be received by your IDE as well. So, try spawning GDB in its
> own process group.
>
I tried to move gdb into a distinct group with "setpgid(gdb_pid, 0)", 
right after spawning it with "g_spawn_async_with_pipes".
If I do so SIGINT doesn't come to IDE but a program being debugged quits 
right after executing "-exec-interrupt".
The gdb output is:

^done
(gdb)
&"Quit\n"
=thread-exited, .....
=thread-group-exited,....
*stopped,reason="exited-normally"

I also tried to do all this executing gdb from a terminal window and a 
program had stopped correctly with stop reason="signal-received", no 
quits...

Can't it be a bug, I've found several discussions with suggestions to 
send SIGINT or SIGTSTP directly to a process being debugged instead of 
using "-exec-interrupt" ?

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

end of thread, other threads:[~2011-09-19 14:13 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-09-17  7:17 proper usage of "-exec-interrupt" Alexander Petukhov
2011-09-17 19:06 ` Joel Brobecker
2011-09-19 14:13   ` Alexander Petukhov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).