This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[PATCH 2/3] partially fix PR gdb/17130
- From: Tom Tromey <tromey at redhat dot com>
- To: gdb-patches at sourceware dot org
- Cc: Tom Tromey <tromey at redhat dot com>
- Date: Fri, 11 Jul 2014 10:37:55 -0600
- Subject: [PATCH 2/3] partially fix PR gdb/17130
- Authentication-results: sourceware.org; auth=none
- References: <1405096676-22681-1-git-send-email-tromey at redhat dot com>
This is a partial fix for PR gdb/17130.
The bug is that some code in utils.c was not updated during the target
delegation change:
if (job_control
/* If there is no terminal switching for this target, then we can't
possibly get screwed by the lack of job control. */
|| current_target.to_terminal_ours == NULL)
fatal ("Quit");
else
fatal ("Quit (expect signal SIGINT when the program is resumed)");
After the delegation change, to_terminal_ours will never be NULL.
I think this bug can be seen before the target delegation change by
enabling target debugging -- this would also cause to_terminal_ours to
be non-NULL.
The fix is to introduce a new target_supports_terminal_ours function,
that properly checks the target stack. This is not perhaps ideal, but
I think is a reasonable-enough approach, and in keeping with some
other existing code of the same form.
This patch also fixes a similar bug in target_supports_delete_record.
Unfortunately this patch doesn't actually fix the PR, because now
windows-nat.c is using the native target code, which installs
child_terminal_ours. Pedro is looking into this.
2014-07-11 Tom Tromey <tromey@redhat.com>
PR gdb/17130:
* utils.c (quit): Use target_supports_terminal_ours.
* target.h (target_supports_terminal_ours): Declare.
* target.c (target_supports_delete_record): Don't check
to_delete_record against NULL.
(target_supports_terminal_ours): New function.
---
gdb/ChangeLog | 9 +++++++++
gdb/target.c | 20 +++++++++++++++++++-
gdb/target.h | 5 +++++
gdb/utils.c | 2 +-
4 files changed, 34 insertions(+), 2 deletions(-)
diff --git a/gdb/target.c b/gdb/target.c
index c9c5e4b..93fc003 100644
--- a/gdb/target.c
+++ b/gdb/target.c
@@ -499,6 +499,23 @@ target_terminal_inferior (void)
(*current_target.to_terminal_inferior) (¤t_target);
}
+/* See target.h. */
+
+int
+target_supports_terminal_ours (void)
+{
+ struct target_ops *t;
+
+ for (t = current_target.beneath; t != NULL; t = t->beneath)
+ {
+ if (t->to_terminal_ours != delegate_terminal_ours
+ && t->to_terminal_ours != tdefault_terminal_ours)
+ return 1;
+ }
+
+ return 0;
+}
+
static void
tcomplain (void)
{
@@ -3456,7 +3473,8 @@ target_supports_delete_record (void)
struct target_ops *t;
for (t = current_target.beneath; t != NULL; t = t->beneath)
- if (t->to_delete_record != NULL)
+ if (t->to_delete_record != delegate_delete_record
+ && t->to_delete_record != tdefault_delete_record)
return 1;
return 0;
diff --git a/gdb/target.h b/gdb/target.h
index 8bf160c..d6e1516 100644
--- a/gdb/target.h
+++ b/gdb/target.h
@@ -1396,6 +1396,11 @@ extern void target_terminal_inferior (void);
#define target_terminal_ours() \
(*current_target.to_terminal_ours) (¤t_target)
+/* Return true if the target stack has a non-default
+ "to_terminal_ours" method. */
+
+extern int target_supports_terminal_ours (void);
+
/* Save our terminal settings.
This is called from TUI after entering or leaving the curses
mode. Since curses modifies our terminal this call is here
diff --git a/gdb/utils.c b/gdb/utils.c
index 6f47cb0..f99843c 100644
--- a/gdb/utils.c
+++ b/gdb/utils.c
@@ -1095,7 +1095,7 @@ quit (void)
if (job_control
/* If there is no terminal switching for this target, then we can't
possibly get screwed by the lack of job control. */
- || current_target.to_terminal_ours == NULL)
+ || !target_supports_terminal_ours ())
fatal ("Quit");
else
fatal ("Quit (expect signal SIGINT when the program is resumed)");
--
1.9.3