Mirror of the gdb mailing list
 help / color / mirror / Atom feed
* 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
* 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