summaryrefslogtreecommitdiff
path: root/gdb/testsuite/gdb.mi/mi-logging.exp
diff options
context:
space:
mode:
authorPedro Alves <palves@redhat.com>2017-01-23 14:27:07 +0000
committerPedro Alves <palves@redhat.com>2017-01-23 23:16:46 +0000
commitde2b3baadeb83db0b1db3e93361393f5e736568b (patch)
tree31cf279e91fb2652b1afe1c4d650808c07a65f63 /gdb/testsuite/gdb.mi/mi-logging.exp
parente37532ee527255494dbd7c7d40442d000b91ee3c (diff)
downloadbinutils-gdb-users/palves/ui_file_v2.tar.gz
Fix "-gdb-set logging redirect on" crashusers/palves/ui_file_v2
By not handling "logging redirect on" on the fly. Code for handling "logging redirect on" on the fly was added here: https://sourceware.org/ml/gdb-patches/2010-08/msg00202.html Meanwhile, MI gained support for logging, but flipping redirect on on the fly was not considered, and the result is that this sequence of events crashes GDB: -gdb-set logging on -gdb-set logging redirect on Program received signal SIGSEGV, Segmentation fault. 0x00000000008dd7bc in gdb_flush (file=0x2a097f0) at /home/pedro/gdb/mygit/cxx-convertion/src/gdb/ui-file.c:194 194 file->to_flush (file); (top-gdb) bt #0 0x00000000008dd7bc in gdb_flush(ui_file*) (file=0x2a097f0) at /home/pedro/gdb/mygit/cxx-convertion/src/gdb/ui-file.c:194 #1 0x00000000007b5f34 in gdb_wait_for_event(int) (block=0) at /home/pedro/gdb/mygit/cxx-convertion/src/gdb/event-loop.c:752 #2 0x00000000007b52b6 in gdb_do_one_event() () at /home/pedro/gdb/mygit/cxx-convertion/src/gdb/event-loop.c:322 #3 0x00000000007b5362 in start_event_loop() () at /home/pedro/gdb/mygit/cxx-convertion/src/gdb/event-loop.c:371 #4 0x000000000082704a in captured_command_loop(void*) (data=0x0) at /home/pedro/gdb/mygit/cxx-convertion/src/gdb/main.c:325 #5 0x00000000007b8d7c in catch_errors(int (*)(void*), void*, char*, return_mask) (func=0x827008 <captured_command_loop(void*)>, func_args=0x0, errstring=0x11dee51 "", mask=RETURN_MASK_ALL) at /home/pedro/gdb/mygit/cxx-convertion/src/gdb/exceptions.c:236 #6 0x000000000082839b in captured_main(void*) (data=0x7fffffffd820) at /home/pedro/gdb/mygit/cxx-convertion/src/gdb/main.c:1148 During symbol reading, cannot get low and high bounds for subprogram DIE at 24065. #7 0x00000000008283c4 in gdb_main(captured_main_args*) (args=0x7fffffffd820) at /home/pedro/gdb/mygit/cxx-convertion/src/gdb/main.c:1158 #8 0x0000000000412d4d in main(int, char**) (argc=4, argv=0x7fffffffd928) at /home/pedro/gdb/mygit/cxx-convertion/src/gdb/gdb.c:32 The handling of redirect on the fly is not really a use case we need to handle, IMO, its inconsistent (other "set logging foo" commands aren't handled on the fly), and complicates the code significantly. Instead of complicating it further for MI, go back to the original idea of warning, only: https://sourceware.org/ml/gdb-patches/2010-08/msg00083.html New test included. gdb/ChangeLog: 2017-01-23 Pedro Alves <palves@redhat.com> * cli/cli-logging.c (maybe_warn_already_logging): New factored out from ... (set_logging_overwrite): ... here. (logging_no_redirect_file): Delete. (set_logging_redirect): Don't handle redirection on the fly. Instead warn that "logging off" / "logging on" is necessary. (pop_output_files): Delete references to logging_no_redirect_file. (show_logging_command): Always speak in terms of what will happen once logging is reenabled. gdb/testsuite/ChangeLog: 2017-01-23 Pedro Alves <palves@redhat.com> * gdb.mi/mi-logging.exp: Add "redirect while already logging" tests.
Diffstat (limited to 'gdb/testsuite/gdb.mi/mi-logging.exp')
-rw-r--r--gdb/testsuite/gdb.mi/mi-logging.exp14
1 files changed, 14 insertions, 0 deletions
diff --git a/gdb/testsuite/gdb.mi/mi-logging.exp b/gdb/testsuite/gdb.mi/mi-logging.exp
index 788a9bf6647..07eaff90d14 100644
--- a/gdb/testsuite/gdb.mi/mi-logging.exp
+++ b/gdb/testsuite/gdb.mi/mi-logging.exp
@@ -82,6 +82,20 @@ if [regexp "1001\\^done\[\r\n\]+$mi_log_prompt.*1002\\^running\[\r\n\]+\\*runnin
fail "redirect log file contents"
}
+# Now try enabling a redirect while GDB is already logging. This used
+# to crash GDB.
+with_test_prefix "redirect while already logging" {
+ mi_gdb_test "-gdb-set logging redirect off" ".*" \
+ "logging redirect off"
+ mi_gdb_test "-gdb-set logging on" ".*" \
+ "logging on"
+ mi_gdb_test "-gdb-set logging redirect on" \
+ ".*warning: Currently logging .*Turn the logging off and on to make the new setting effective.*" \
+ "logging redirect on"
+ mi_gdb_test "-gdb-set logging off" ".*" \
+ "logging off"
+}
+
mi_gdb_exit
remote_file host delete $milogfile