Go to file
Tom de Vries be6a2dca15 [gdb/cli] Make quit really quit after remote connection closed
Consider a hello world a.out, started using gdbserver:
...
$ gdbserver --once 127.0.0.1:2345 ./a.out
Process ./a.out created; pid = 15743
Listening on port 2345
...
that we can connect to using gdb:
...
$ gdb -ex "target remote 127.0.0.1:2345"
Remote debugging using 127.0.0.1:2345
Reading /home/vries/a.out from remote target...
  ...
0x00007ffff7dd4550 in _start () from target:/lib64/ld-linux-x86-64.so.2
(gdb)
...

After that, we can for instance quit with confirmation:
...
(gdb) quit
A debugging session is active.

        Inferior 1 [process 16691] will be killed.

Quit anyway? (y or n) y
$
...

Or, kill with confirmation and quit:
...
(gdb) kill
Kill the program being debugged? (y or n) y
[Inferior 1 (process 16829) killed]
(gdb) quit
$
...

Or, monitor exit, kill with confirmation, and quit:
...
(gdb) monitor exit
(gdb) kill
Kill the program being debugged? (y or n) y
Remote connection closed
(gdb) quit
$
...

But when doing monitor exit followed by quit with confirmation, we get the gdb
prompt back, requiring us to do quit once more:
...
(gdb) monitor exit
(gdb) quit
A debugging session is active.

        Inferior 1 [process 16944] will be killed.

Quit anyway? (y or n) y
Remote connection closed
(gdb) quit
$
...

So, the first quit didn't quit.  This happens as follows:
- quit_command calls query_if_trace_running
- a TARGET_CLOSE_ERROR is thrown
- it's caught in remote_target::get_trace_status, but then
  rethrown because it's TARGET_CLOSE_ERROR
- catch_command_errors catches the error, at which point the quit command
  has been aborted.

The TARGET_CLOSE_ERROR is defined as:
...
  /* Target throwing an error has been closed.  Current command should be
     aborted as the inferior state is no longer valid.  */
  TARGET_CLOSE_ERROR,
...
so in a way this is expected behaviour.  But aborting quit because the inferior
state (which we've already confirmed we're not interested in) is no longer
valid, and having to type quit again seems pointless.

Furthermore, the purpose of not catching errors thrown by
query_if_trace_running as per commit 2f9d54cfce ("make -gdb-exit call
disconnect_tracing too, and don't lose history if the target errors on
"quit""), was to make sure that error (_("Not confirmed.") had effect.

Fix this in quit_command by catching only the TARGET_CLOSE_ERROR exception
during query_if_trace_running and reporting it:
...
(gdb) monitor exit
(gdb) quit
A debugging session is active.

        Inferior 1 [process 19219] will be killed.

Quit anyway? (y or n) y
Remote connection closed
$
...

Tested on x86_64-linux.

PR server/15746
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=15746
Approved-By: Tom Tromey <tom@tromey.com>
2022-11-08 18:47:24 +01:00
bfd Automatic date update in version.in 2022-11-08 00:00:30 +00:00
binutils configure: require libzstd >= 1.4.0 2022-11-07 14:32:10 +01:00
config configure: require libzstd >= 1.4.0 2022-11-07 14:32:10 +01:00
contrib
cpu
elfcpp
etc
gas Support Intel RAO-INT 2022-11-08 10:24:59 +08:00
gdb [gdb/cli] Make quit really quit after remote connection closed 2022-11-08 18:47:24 +01:00
gdbserver internal_error: remove need to pass __FILE__/__LINE__ 2022-10-19 15:32:36 +01:00
gdbsupport internal_error: remove need to pass __FILE__/__LINE__ 2022-10-19 15:32:36 +01:00
gnulib
gold egrep in binutils 2022-09-28 13:37:31 +09:30
gprof Updated Hungarian translation for the gprof sub-directory. 2022-10-21 10:55:57 +01:00
gprofng gprofng: no need to build version.texi 2022-10-11 00:14:06 -07:00
include sim: drop unused CORE_ADDR_TYPE 2022-11-08 14:09:06 +07:00
intl egrep in binutils 2022-09-28 13:37:31 +09:30
ld configure: require libzstd >= 1.4.0 2022-11-07 14:32:10 +01:00
libbacktrace
libctf configure: require libzstd >= 1.4.0 2022-11-07 14:32:10 +01:00
libdecnumber
libiberty
opcodes x86: Correct wrong comments in vex_w_table 2022-11-08 10:42:42 +08:00
readline
sim sim: mips: call Unpredictable instead of setting bogus values [PR sim/29276] 2022-11-08 14:55:50 +07:00
texinfo
zlib
.cvsignore
.editorconfig
.gitattributes
.gitignore
ar-lib
ChangeLog Add ability to create reproducible source tarballs. 2022-10-10 11:28:45 +01:00
compile
config-ml.in
config.guess
config.rpath
config.sub
configure Reapply "Don't build readline/libreadline.a, when --with-system-readline is supplied" 2022-10-20 17:05:04 +02:00
configure.ac Reapply "Don't build readline/libreadline.a, when --with-system-readline is supplied" 2022-10-20 17:05:04 +02:00
COPYING
COPYING3
COPYING3.LIB
COPYING.LIB
COPYING.LIBGLOSS
COPYING.NEWLIB
depcomp
djunpack.bat
install-sh
libtool.m4
lt~obsolete.m4
ltgcc.m4
ltmain.sh
ltoptions.m4
ltsugar.m4
ltversion.m4
MAINTAINERS
Makefile.def
Makefile.in
Makefile.tpl
makefile.vms
missing
mkdep
mkinstalldirs
move-if-change
multilib.am
README
README-maintainer-mode Note that at least dejagnu version 1.5.3 is required in order to be ale to run the testsuites. 2022-10-04 10:54:19 +01:00
setup.com
src-release.sh Add ability to create reproducible source tarballs. 2022-10-10 11:28:45 +01:00
symlink-tree
test-driver
ylwrap

		   README for GNU development tools

This directory contains various GNU compilers, assemblers, linkers, 
debuggers, etc., plus their support routines, definitions, and documentation.

If you are receiving this as part of a GDB release, see the file gdb/README.
If with a binutils release, see binutils/README;  if with a libg++ release,
see libg++/README, etc.  That'll give you info about this
package -- supported targets, how to use it, how to report bugs, etc.

It is now possible to automatically configure and build a variety of
tools with one command.  To build all of the tools contained herein,
run the ``configure'' script here, e.g.:

	./configure 
	make

To install them (by default in /usr/local/bin, /usr/local/lib, etc),
then do:
	make install

(If the configure script can't determine your type of computer, give it
the name as an argument, for instance ``./configure sun4''.  You can
use the script ``config.sub'' to test whether a name is recognized; if
it is, config.sub translates it to a triplet specifying CPU, vendor,
and OS.)

If you have more than one compiler on your system, it is often best to
explicitly set CC in the environment before running configure, and to
also set CC when running make.  For example (assuming sh/bash/ksh):

	CC=gcc ./configure
	make

A similar example using csh:

	setenv CC gcc
	./configure
	make

Much of the code and documentation enclosed is copyright by
the Free Software Foundation, Inc.  See the file COPYING or
COPYING.LIB in the various directories, for a description of the
GNU General Public License terms under which you can copy the files.

REPORTING BUGS: Again, see gdb/README, binutils/README, etc., for info
on where and how to report problems.