From patchwork Wed Aug 6 15:58:04 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gary Benson X-Patchwork-Id: 2326 Received: (qmail 18538 invoked by alias); 6 Aug 2014 15:58:14 -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 18512 invoked by uid 89); 6 Aug 2014 15:58:13 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.4 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; Wed, 06 Aug 2014 15:58:12 +0000 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s76FwBER006612 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 6 Aug 2014 11:58:11 -0400 Received: from blade.nx (ovpn-116-90.ams2.redhat.com [10.36.116.90]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s76FwAS4028089 for ; Wed, 6 Aug 2014 11:58:11 -0400 Received: from blade.nx (localhost [127.0.0.1]) by blade.nx (Postfix) with ESMTP id 5295D2640E4 for ; Wed, 6 Aug 2014 16:58:10 +0100 (BST) From: Gary Benson To: gdb-patches@sourceware.org Subject: [PATCH 2/6] Convert fatal to gdb_assert in both i386_dr_low_set_addr Date: Wed, 6 Aug 2014 16:58:04 +0100 Message-Id: <1407340688-13721-3-git-send-email-gbenson@redhat.com> In-Reply-To: <1407340688-13721-1-git-send-email-gbenson@redhat.com> References: <1407340688-13721-1-git-send-email-gbenson@redhat.com> X-IsSubscribed: yes This commit converts if..fatal checks in both i386_dr_low_set_addr implementations to gdb_asserts. It's not obvious from the context, but the conditional in both cases is changed to match the equivalent conditional in the i386_dr_low_get_addr implementations. Nothing fundamental has changed because DR_FIRSTADDR is zero. This commit also removes a vague comment in Linux i386_dr_low_get_addr. I could have reworded the comment (and replicated it three times for the other identical assertions) but I think the existence of specific functions for the status and control registers makes it fairly obvious what is going on. gdb/gdbserver/ 2014-08-06 Gary Benson * linux-x86-low.c (i386_dr_low_set_addr): Replace check with gdb_assert. (i386_dr_low_get_addr): Remove vague comment. (win32-i386-low.c): Replace check with gdb_assert. --- gdb/gdbserver/ChangeLog | 7 +++++++ gdb/gdbserver/linux-x86-low.c | 4 +--- gdb/gdbserver/win32-i386-low.c | 3 +-- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/gdb/gdbserver/linux-x86-low.c b/gdb/gdbserver/linux-x86-low.c index 7f32ea3..7e07522 100644 --- a/gdb/gdbserver/linux-x86-low.c +++ b/gdb/gdbserver/linux-x86-low.c @@ -593,8 +593,7 @@ i386_dr_low_set_addr (int regnum, CORE_ADDR addr) /* Only update the threads of this process. */ int pid = pid_of (current_inferior); - if (! (regnum >= 0 && regnum <= DR_LASTADDR - DR_FIRSTADDR)) - fatal ("Invalid debug register %d", regnum); + gdb_assert (DR_FIRSTADDR <= regnum && regnum <= DR_LASTADDR); find_inferior (&all_threads, update_debug_registers_callback, &pid); } @@ -606,7 +605,6 @@ i386_dr_low_get_addr (int regnum) { ptid_t ptid = ptid_of (current_inferior); - /* DR6 and DR7 are retrieved with some other way. */ gdb_assert (DR_FIRSTADDR <= regnum && regnum <= DR_LASTADDR); return x86_linux_dr_get (ptid, regnum); diff --git a/gdb/gdbserver/win32-i386-low.c b/gdb/gdbserver/win32-i386-low.c index e894677..39149f3 100644 --- a/gdb/gdbserver/win32-i386-low.c +++ b/gdb/gdbserver/win32-i386-low.c @@ -48,8 +48,7 @@ static int debug_registers_used = 0; static void i386_dr_low_set_addr (int regnum, CORE_ADDR addr) { - if (! (regnum >= 0 && regnum <= DR_LASTADDR - DR_FIRSTADDR)) - fatal ("Invalid debug register %d", regnum); + gdb_assert (DR_FIRSTADDR <= regnum && regnum <= DR_LASTADDR); /* debug_reg_state.dr_mirror is already set. Just notify i386_set_thread_context, i386_thread_added