From patchwork Fri Jul 11 16:37:55 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 2038 Received: (qmail 22370 invoked by alias); 11 Jul 2014 16:38:12 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 22155 invoked by uid 89); 11 Jul 2014 16:38:07 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.1 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD, SPF_HELO_PASS, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Fri, 11 Jul 2014 16:38:01 +0000 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s6BGc0Mc026238 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 11 Jul 2014 12:38:00 -0400 Received: from barimba.redhat.com (ovpn-113-95.phx2.redhat.com [10.3.113.95]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s6BGbwgS030792; Fri, 11 Jul 2014 12:37:59 -0400 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 2/3] partially fix PR gdb/17130 Date: Fri, 11 Jul 2014 10:37:55 -0600 Message-Id: <1405096676-22681-3-git-send-email-tromey@redhat.com> In-Reply-To: <1405096676-22681-1-git-send-email-tromey@redhat.com> References: <1405096676-22681-1-git-send-email-tromey@redhat.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 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)");