aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gdb/ChangeLog7
-rw-r--r--gdb/cli/cli-interp.c8
-rw-r--r--gdb/testsuite/ChangeLog7
-rw-r--r--gdb/testsuite/gdb.base/ui-redirect.exp8
4 files changed, 30 insertions, 0 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 087e204..6cf6d40 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,10 @@
+2021-01-27 Lancelot SIX <lsix@lancelotsix.com>
+
+ PR gdb/27133
+ * cli/cli-interp.c (cli_interp_base::set_logging): Ensure the
+ unique_ptr is released when the wrapped pointer is kept for later
+ use.
+
2021-01-27 Matthew Malcomson <matthew.malcomson@arm.com>
* aarch64-tdep.c (aarch64_displaced_step_others): Account for
diff --git a/gdb/cli/cli-interp.c b/gdb/cli/cli-interp.c
index 424264a..882384e 100644
--- a/gdb/cli/cli-interp.c
+++ b/gdb/cli/cli-interp.c
@@ -430,6 +430,14 @@ cli_interp_base::set_logging (ui_file_up logfile, bool logging_redirect,
saved_output.file_to_delete = tee;
}
+ /* Make sure that the call to logfile's dtor does not delete the
+ underlying pointer if we still keep a reference to it. If
+ logfile_p is not referenced as the file_to_delete, then either
+ the logfile is not used (no redirection) and it should be
+ deleted, or a tee took ownership of the pointer. */
+ if (logfile_p != nullptr && saved_output.file_to_delete == logfile_p)
+ logfile.release ();
+
gdb_stdout = logging_redirect ? logfile_p : tee;
gdb_stdlog = debug_redirect ? logfile_p : tee;
gdb_stderr = logging_redirect ? logfile_p : tee;
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index f20f041..814c6de 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,10 @@
+2021-01-27 Lancelot SIX <lsix@lancelotsix.com>
+
+ PR gdb/27133
+ * gdb.base/ui-redirect.exp: Add test case that ensures that
+ redirecting both logging and debug does not cause gdb to crash.
+
+
2021-01-27 Matthew Malcomson <matthew.malcomson@arm.com>
* gdb.arch/insn-reloc.c: Add tests for BR and BLR.
diff --git a/gdb/testsuite/gdb.base/ui-redirect.exp b/gdb/testsuite/gdb.base/ui-redirect.exp
index af42800..cb0749b 100644
--- a/gdb/testsuite/gdb.base/ui-redirect.exp
+++ b/gdb/testsuite/gdb.base/ui-redirect.exp
@@ -140,3 +140,11 @@ with_test_prefix "redirect debugging" {
gdb_test "set logging off" "Done logging to /dev/null\\."
gdb_test "help" "List of classes of commands:.*"
}
+
+with_test_prefix "redirect logging and debuging" {
+ gdb_test_no_output "set logging redirect on"
+ gdb_test_no_output "set logging debugredirect on"
+ gdb_test "set logging on" \
+ "Redirecting output to /dev/null.*Redirecting debug output to /dev/null\\."
+ gdb_test "set logging off" "Done logging to /dev/null\\."
+}