* Can I use -exec-interrupt to stop the inferior program?
@ 2006-05-15 21:51 Nikolay Molchanov
2006-05-16 11:35 ` Nick Roberts
2006-05-18 16:19 ` Carlos Eduardo Rodrigues de Almeida
0 siblings, 2 replies; 6+ messages in thread
From: Nikolay Molchanov @ 2006-05-15 21:51 UTC (permalink / raw)
To: gdb
Hello!
I'm looking for a solution how to stop the inferior program,
which is running under gdb. I can stop it using ^C, but I
need a solution, that will work for the following case:
Java application
| ^
stdin | | stdout
v |
GDB debugger (gdb --i mi --tty /dev/pts/2 ...)
| ^
v |
Inferior program <--> External terminal (/dev/pts/28)
The action to stop the program is initiated by
Java application, which cannot send ^C to the
external terminal. So I have to use stdin to
tell gdb to stop the inferior program. But gdb
does not read the "-exec-interrupt" command,
until the program is stopped
sside-linux nikm/t1-exec-interrupt> gdb --i mi --tty /dev/pts/2 t2pl
~"GNU gdb 6.1\n"
~"Copyright 2004 Free Software Foundation, Inc.\n"
~"GDB is free software, covered by the GNU General Public License, and
you are\n"
~"welcome to change it and/or distribute copies of it under certain
conditions.\n"
~"Type \"show copying\" to see the conditions.\n"
~"There is absolutely no warranty for GDB. Type \"show warranty\" for
details.\n"
~"This GDB was configured as \"x86_64-suse-linux\"..."
~"Using host libthread_db library \"/lib64/tls/libthread_db.so.1\".\n"
~"\n"
(gdb)
run
&"run\n"
-exec-interrupt
^done,reason="exited",exit-code="0100"
(gdb)
^error,msg="mi_cmd_exec_interrupt: Inferior not executing."
(gdb)
Perhaps "-exec-interrupt" does not work in gdb 6.1?
If that's correct, can you tell me which version supports
"-exec-interrupt"?
Thanks in advance,
Nikolay Molchanov
^ permalink raw reply [flat|nested] 6+ messages in thread
* Can I use -exec-interrupt to stop the inferior program?
2006-05-15 21:51 Can I use -exec-interrupt to stop the inferior program? Nikolay Molchanov
@ 2006-05-16 11:35 ` Nick Roberts
2006-05-18 16:19 ` Carlos Eduardo Rodrigues de Almeida
1 sibling, 0 replies; 6+ messages in thread
From: Nick Roberts @ 2006-05-16 11:35 UTC (permalink / raw)
To: Nikolay Molchanov; +Cc: gdb
> (gdb)
> run
> &"run\n"
> -exec-interrupt
> ^done,reason="exited",exit-code="0100"
> (gdb)
> ^error,msg="mi_cmd_exec_interrupt: Inferior not executing."
> (gdb)
>
>
> Perhaps "-exec-interrupt" does not work in gdb 6.1?
> If that's correct, can you tell me which version supports
> "-exec-interrupt"?
It doesn't currently works as you would like i.e. asynchronously, even in
CVS.
Can you get around the problem by using SIGTSTP instead of SIGINT to stop
the program? Thats what Emacs does.
--
Nick http://www.inet.net.nz/~nickrob
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Can I use -exec-interrupt to stop the inferior program?
2006-05-15 21:51 Can I use -exec-interrupt to stop the inferior program? Nikolay Molchanov
2006-05-16 11:35 ` Nick Roberts
@ 2006-05-18 16:19 ` Carlos Eduardo Rodrigues de Almeida
1 sibling, 0 replies; 6+ messages in thread
From: Carlos Eduardo Rodrigues de Almeida @ 2006-05-18 16:19 UTC (permalink / raw)
To: gdb
I had the same problem a while ago..
I wrote a driver in, C, that received "commands" from the java
application and performed actions in the GDB. There was only 2
"commands" CMD and SIG.
Explaining by example
If I send CMDlist my driver will remove the CMD and send list to GDB,
if I send SIG my driver will send a SIGINT to GDB... it should be
SIGsigno where signo is the number of the signal but not implemented
yet.
In java I have a class that encapsulate the driver and has 2 methods:
sendCommand(String command)
sendSignal(int signo)
If you want I can send you the driver and my java code.
The driver only work in linux
Eduardo
On 5/15/06, Nikolay Molchanov <Nikolay.Molchanov@sun.com> wrote:
> Hello!
>
> I'm looking for a solution how to stop the inferior program,
> which is running under gdb. I can stop it using ^C, but I
> need a solution, that will work for the following case:
>
> Java application
> | ^
> stdin | | stdout
> v |
> GDB debugger (gdb --i mi --tty /dev/pts/2 ...)
> | ^
> v |
> Inferior program <--> External terminal (/dev/pts/28)
>
>
> The action to stop the program is initiated by
> Java application, which cannot send ^C to the
> external terminal. So I have to use stdin to
> tell gdb to stop the inferior program. But gdb
> does not read the "-exec-interrupt" command,
> until the program is stopped
>
>
> sside-linux nikm/t1-exec-interrupt> gdb --i mi --tty /dev/pts/2 t2pl
> ~"GNU gdb 6.1\n"
> ~"Copyright 2004 Free Software Foundation, Inc.\n"
> ~"GDB is free software, covered by the GNU General Public License, and
> you are\n"
> ~"welcome to change it and/or distribute copies of it under certain
> conditions.\n"
> ~"Type \"show copying\" to see the conditions.\n"
> ~"There is absolutely no warranty for GDB. Type \"show warranty\" for
> details.\n"
> ~"This GDB was configured as \"x86_64-suse-linux\"..."
> ~"Using host libthread_db library \"/lib64/tls/libthread_db.so.1\".\n"
> ~"\n"
> (gdb)
> run
> &"run\n"
> -exec-interrupt
> ^done,reason="exited",exit-code="0100"
> (gdb)
> ^error,msg="mi_cmd_exec_interrupt: Inferior not executing."
> (gdb)
>
>
> Perhaps "-exec-interrupt" does not work in gdb 6.1?
> If that's correct, can you tell me which version supports
> "-exec-interrupt"?
>
> Thanks in advance,
> Nikolay Molchanov
>
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Can I use -exec-interrupt to stop the inferior program?
2006-10-11 13:49 ` Daniel Jacobowitz
@ 2006-10-11 17:32 ` Eli Zaretskii
0 siblings, 0 replies; 6+ messages in thread
From: Eli Zaretskii @ 2006-10-11 17:32 UTC (permalink / raw)
To: Daniel Jacobowitz; +Cc: Nikolay.Molchanov, gdb
> Date: Wed, 11 Oct 2006 09:49:16 -0400
> From: Daniel Jacobowitz <drow@false.org>
> Cc: gdb@sourceware.org
>
> Eventually, you'll be able to do this properly in GDB. Nick has been
> working hard on asynchronous operation, and once that's ready, we can
> implement the -exec-interrupt operation using Windows API calls.
Yes, I think the best idea is to have a Windows-specific
implementation (alongside with a Posix one). Signals is one of the
few areas where Windows is so different from Posix that no matter how
hard you try to disguise it, that difference will eventually stick
out.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Can I use -exec-interrupt to stop the inferior program?
2006-10-11 6:47 Nikolay Molchanov
@ 2006-10-11 13:49 ` Daniel Jacobowitz
2006-10-11 17:32 ` Eli Zaretskii
0 siblings, 1 reply; 6+ messages in thread
From: Daniel Jacobowitz @ 2006-10-11 13:49 UTC (permalink / raw)
To: Nikolay Molchanov; +Cc: gdb
On Tue, Oct 10, 2006 at 11:47:11PM -0700, Nikolay Molchanov wrote:
> Nick Roberts suggested to use signals to implement "interrupt" action,
> and it really works very well on Unix (Solaris and Linux), but unfortunately
> it does not work properly on Windows. If I send SIGTSTP, gdb does not
> show that the program is stopped (and it really does not stop), so it looks
> like this signal is ignored. If I send SIGINT, the program is really
> interrupted,
> but it seems to cause SIGSEGV (Segmentation Fault), and there is no way
> to continue the debugging. Here is a scenario (I use Cygwin):
You should be using SIGINT for this, yes. Windows SIGINT is funny, but
if you're dealing with Cygwin, it should be OK - in theory. It doesn't
work for me either; I get the program exiting with code 01000, instead
of a segfault, but the result is equally useless.
Maybe this is a bug in Cygwin?
Eventually, you'll be able to do this properly in GDB. Nick has been
working hard on asynchronous operation, and once that's ready, we can
implement the -exec-interrupt operation using Windows API calls. In
the mean time, I have no idea.
--
Daniel Jacobowitz
CodeSourcery
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Can I use -exec-interrupt to stop the inferior program?
@ 2006-10-11 6:47 Nikolay Molchanov
2006-10-11 13:49 ` Daniel Jacobowitz
0 siblings, 1 reply; 6+ messages in thread
From: Nikolay Molchanov @ 2006-10-11 6:47 UTC (permalink / raw)
To: gdb; +Cc: Nikolay Molchanov
Hello GDB developers and users!
I asked this question some time ago (in May 2006), and I implemented a
solution
for Unix (it is based on signal), but I still cannot find a good
solution for Windows.
Here is my original question:
I'm looking for a solution how to stop the inferior program,
which is running under gdb. I can stop it using ^C, but I
need a solution, that will work for the following case
on Windows (Cygwin):
Java application
| ^
stdin | | stdout
v |
GDB debugger (gdb --i mi --tty /dev/pts/2 ...)
| ^
v |
Inferior program <--> External terminal (/dev/pts/28)
The action to stop the program is initiated by
Java application, which cannot send ^C to the
external terminal.
Nick Roberts suggested to use signals to implement "interrupt" action,
and it really works very well on Unix (Solaris and Linux), but unfortunately
it does not work properly on Windows. If I send SIGTSTP, gdb does not
show that the program is stopped (and it really does not stop), so it looks
like this signal is ignored. If I send SIGINT, the program is really
interrupted,
but it seems to cause SIGSEGV (Segmentation Fault), and there is no way
to continue the debugging. Here is a scenario (I use Cygwin):
Window 1: start debugging, set breakpoint, continue
===================================
$ gdb --i mi
~"GNU gdb 6.5.50.20060706-cvs (cygwin-special)\n"
~"Copyright (C) 2006 Free Software Foundation, Inc.\n"
~"GDB is free software, covered by the GNU General Public License, and
you are\n"
~"welcome to change it and/or distribute copies of it under certain
conditions.\n"
~"Type \"show copying\" to see the conditions.\n"
~"There is absolutely no warranty for GDB. Type \"show warranty\" for
details.\n"
~"This GDB was configured as \"i686-pc-cygwin\"."
~"\n"
(gdb)
-file-exec-and-symbols
C:/tmp/nikm/samples/LongLoop1/dist/Debug/GNU-Windows/longloop1
^done
(gdb)
-break-insert main
^done,bkpt={number="1",type="breakpoint",disp="keep",enabled="y",addr="0x004011b
5",func="main",file="main.cc",fullname="/cygdrive/c/tmp/nikm/samples/LongLoop1/m
ain.cc",line="33",times="0"}
(gdb)
-exec-run
^running
(gdb)
*stopped,reason="breakpoint-hit",bkptno="1",thread-id="1",frame={addr="0x004011b
5",func="main",args=[{name="argc",value="1"},{name="argv",value="0x6c1f50"}],fil
e="main.cc",fullname="/cygdrive/c/tmp/nikm/samples/LongLoop1/main.cc",line="33"}
(gdb)
-exec-continue
^running
(gdb)
Window 2: send signal
===============
$ ps
PID PPID PGID WINPID TTY UID STIME COMMAND
1520 1 1520 1520 con 1005 23:22:26 /usr/bin/bash
884 1 884 884 con 1005 23:23:47 /usr/bin/bash
1832 1520 1832 3880 con 1005 23:24:17 /usr/bin/gdb
4036 1 4036 4036 con 1005 23:27:14
/cygdrive/c/tmp/nikm/sam
ples/LongLoop1/dist/Debug/GNU-Windows/longloop1
2380 884 2380 2336 con 1005 23:27:16 /usr/bin/ps
$ kill -INT 4036
Window 1: caught signal
=================
~"\n"
~"[Switching to thread 4036.0x784]\n"
*stopped,reason="signal-received",signal-name="SIGSEGV",signal-meaning="Segmenta
tion fault",thread-id="2",frame={addr="0x000007d4",func="??",args=[]}
(gdb)
After that there is no way to continue:
=========================
-exec-continue
^running
(gdb)
*stopped,reason="signal-received",signal-name="SIGSEGV",signal-meaning="Segmenta
tion fault",thread-id="2",frame={addr="0x000007d4",func="??",args=[]}
(gdb)
Could you please tell me if there any other way to interrupt program on
Windows,
so that gdb will show where it is stopped, and will allow to continue?
Thanks in advance,
Nikolay Molchanov
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2006-10-11 17:32 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-05-15 21:51 Can I use -exec-interrupt to stop the inferior program? Nikolay Molchanov
2006-05-16 11:35 ` Nick Roberts
2006-05-18 16:19 ` Carlos Eduardo Rodrigues de Almeida
2006-10-11 6:47 Nikolay Molchanov
2006-10-11 13:49 ` Daniel Jacobowitz
2006-10-11 17:32 ` Eli Zaretskii
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox