From patchwork Thu Oct 22 15:56:54 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Antoine Tremblay X-Patchwork-Id: 9327 Received: (qmail 72864 invoked by alias); 22 Oct 2015 15:57:07 -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 72852 invoked by uid 89); 22 Oct 2015 15:57:06 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.7 required=5.0 tests=AWL, BAYES_00, SPF_PASS autolearn=ham version=3.3.2 X-HELO: usevmg20.ericsson.net Received: from usevmg20.ericsson.net (HELO usevmg20.ericsson.net) (198.24.6.45) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Thu, 22 Oct 2015 15:57:05 +0000 Received: from EUSAAHC001.ericsson.se (Unknown_Domain [147.117.188.75]) by usevmg20.ericsson.net (Symantec Mail Security) with SMTP id 42.51.32596.8A6A8265; Thu, 22 Oct 2015 11:04:40 +0200 (CEST) Received: from elxa4wqvvz1.dyn.mo.ca.am.ericsson.se (147.117.188.8) by smtps-am.internal.ericsson.com (147.117.188.75) with Microsoft SMTP Server (TLS) id 14.3.248.2; Thu, 22 Oct 2015 11:56:59 -0400 From: Antoine Tremblay To: , CC: Antoine Tremblay Subject: [PATCH v2] Fix inconsistent breakpoint kinds between breakpoints and tracepoints in GDBServer. Date: Thu, 22 Oct 2015 11:56:54 -0400 Message-ID: <1445529414-11581-1-git-send-email-antoine.tremblay@ericsson.com> In-Reply-To: <5628FE0C.5090309@redhat.com> References: <5628FE0C.5090309@redhat.com> MIME-Version: 1.0 X-IsSubscribed: yes This patch fixes a regression introduced by : https://sourceware.org/ml/gdb-patches/2015-10/msg00369.html Tests : gdb.trace/trace-break.exp and gdb.trace/trace-mt.exp would fail on x86 with gdbserver-{native,extended}. Before this patch, the breakpoint kind set by GDB with a Z packet and the one set in the case of a tracepoint would be inconsistent on targets that did not implement breakpoint_kind_from_pc. On x86 for example a breakpoint set by GDB would have a kind of 1 but a breakpoint set by a tracepoint would have a kind of 0. This created a missmatch when trying to insert a tracepoint and a breakpoint at the same location. One of the two breakpoints would be removed with debug message : "Inconsistent breakpoint kind". This patch fixes the issue by changing the default 0 breakpoint kind to be the size of the breakpoint according to sw_breakpoint_from_kind. The default breakpoint kind must be the breakpoint length to keep consistency between breakpoints set via GDB and the ones set internally by GDBServer. No regression on Ubuntu 14.04 x86-64 with gdbserver-{native-extended} gdb/gdbserver/ChangeLog: * linux-low.c (default_breakpoint_kind_from_pc): New function. (linux_breakpoint_kind_from_pc): Use default_breakpoint_kind_from_pc for the default breakpoint kind. --- gdb/gdbserver/linux-low.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/gdb/gdbserver/linux-low.c b/gdb/gdbserver/linux-low.c index c20e257..8d1730b 100644 --- a/gdb/gdbserver/linux-low.c +++ b/gdb/gdbserver/linux-low.c @@ -6937,6 +6937,19 @@ current_lwp_ptid (void) return ptid_of (current_thread); } +/* Return the default breakpoint kind as the size of the breakpoint. */ + +int +default_breakpoint_kind_from_pc (CORE_ADDR *pcptr) +{ + int size = 0; + + gdb_assert (the_low_target.sw_breakpoint_from_kind != NULL); + + (*the_low_target.sw_breakpoint_from_kind) (0, &size); + return size; +} + /* Implementation of the target_ops method "breakpoint_kind_from_pc". */ static int @@ -6945,8 +6958,7 @@ linux_breakpoint_kind_from_pc (CORE_ADDR *pcptr) if (the_low_target.breakpoint_kind_from_pc != NULL) return (*the_low_target.breakpoint_kind_from_pc) (pcptr); else - /* Default breakpoint kind value. */ - return 0; + return default_breakpoint_kind_from_pc (pcptr); } /* Implementation of the target_ops method "sw_breakpoint_from_kind". */