From patchwork Thu Apr 9 08:45:12 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yao Qi X-Patchwork-Id: 46919 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f198.google.com (mail-wi0-f198.google.com [209.85.212.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 31050218D6 for ; Thu, 9 Apr 2015 08:45:32 +0000 (UTC) Received: by wibgr10 with SMTP id gr10sf15789924wib.2 for ; Thu, 09 Apr 2015 01:45:31 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:mailing-list :precedence:list-id:list-unsubscribe:list-subscribe:list-archive :list-post:list-help:sender:delivered-to:from:to:subject:date :message-id:x-original-sender:x-original-authentication-results; bh=R6NNukM3OGLVnnGmgXVUc0ralmozQGSvS1p2OlvStG8=; b=MYMBTN0YmUitxoV+r2d2a0pHsotFWM9A3uRdsue6+JUq06fQUp/gxT/SpAhCSlGzbM navNwE7m1QbsUWzhEIFmRP4Ye5xLpDUUQ5yQueWtakRqDhfWb1SanDj+8uJm1bQnMwDQ Gugvw0gyo9yhmMLLIUByniwbrZHvcxYfbHn/G5IICfb90mmebhlDVkJDcpYaDklxku1Z m26GVkP7dWi1m/bRUw9CuLMws6S5IU4KfTaa+JGbyBqhcWgqbXUP8m8bvODFPpsKGRYO CPlJSuNKPiNJMaxJT6xJB0gZPI9DHCE60pw1yAUFD5ZdX6pGo0vA77zR9lf+6X1MTWCC HfTQ== X-Gm-Message-State: ALoCoQlsMTiLFirARQueTsDFv35I5UcdfSXohwAaDWJGCmx2aPc/wauGgDV1Ouo5tISNqsv//3N3 X-Received: by 10.194.53.225 with SMTP id e1mr5731034wjp.4.1428569131501; Thu, 09 Apr 2015 01:45:31 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.234.236 with SMTP id uh12ls296988lac.54.gmail; Thu, 09 Apr 2015 01:45:31 -0700 (PDT) X-Received: by 10.152.207.105 with SMTP id lv9mr3448828lac.10.1428569131332; Thu, 09 Apr 2015 01:45:31 -0700 (PDT) Received: from mail-la0-x233.google.com (mail-la0-x233.google.com. [2a00:1450:4010:c03::233]) by mx.google.com with ESMTPS id lk5si10880914lac.170.2015.04.09.01.45.31 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 09 Apr 2015 01:45:31 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 2a00:1450:4010:c03::233 as permitted sender) client-ip=2a00:1450:4010:c03::233; Received: by labbd9 with SMTP id bd9so72946015lab.2 for ; Thu, 09 Apr 2015 01:45:31 -0700 (PDT) X-Received: by 10.152.4.72 with SMTP id i8mr3439559lai.29.1428569131234; Thu, 09 Apr 2015 01:45:31 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.67.65 with SMTP id l1csp337627lbt; Thu, 9 Apr 2015 01:45:30 -0700 (PDT) X-Received: by 10.67.4.195 with SMTP id cg3mr54598915pad.106.1428569129470; Thu, 09 Apr 2015 01:45:29 -0700 (PDT) Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id ok14si20532064pdb.36.2015.04.09.01.45.28 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 09 Apr 2015 01:45:29 -0700 (PDT) Received-SPF: pass (google.com: domain of gdb-patches-return-121727-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Received: (qmail 92997 invoked by alias); 9 Apr 2015 08:45:21 -0000 Mailing-List: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org Precedence: list 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 92986 invoked by uid 89); 9 Apr 2015 08:45:20 -0000 X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.6 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-pa0-f41.google.com Received: from mail-pa0-f41.google.com (HELO mail-pa0-f41.google.com) (209.85.220.41) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Thu, 09 Apr 2015 08:45:19 +0000 Received: by pabsx10 with SMTP id sx10so143038523pab.3 for ; Thu, 09 Apr 2015 01:45:17 -0700 (PDT) X-Received: by 10.66.237.35 with SMTP id uz3mr54549396pac.46.1428569117668; Thu, 09 Apr 2015 01:45:17 -0700 (PDT) Received: from E107787-LIN.cambridge.arm.com (gcc1-power7.osuosl.org. [140.211.15.137]) by mx.google.com with ESMTPSA id c16sm13733326pdl.61.2015.04.09.01.45.16 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 09 Apr 2015 01:45:16 -0700 (PDT) From: Yao Qi To: gdb-patches@sourceware.org Subject: [PATCH] gdbserver gnu/linux: stepping over breakpoint Date: Thu, 9 Apr 2015 09:45:12 +0100 Message-Id: <1428569112-18004-1-git-send-email-qiyaoltc@gmail.com> X-IsSubscribed: yes X-Original-Sender: qiyaoltc@gmail.com X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 2a00:1450:4010:c03::233 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org; dkim=pass header.i=@sourceware.org; dmarc=fail (p=NONE dis=NONE) header.from=gmail.com X-Google-Group-Id: 836684582541 From: Yao Qi Hi, I see the following error on arm linux gdbserver, continue^M Continuing.^M ../../../binutils-gdb/gdb/gdbserver/linux-arm-low.c:458: A problem internal to GDBserver has been detected.^M raw_bkpt_type_to_arm_hwbp_type: unhandled raw type^M Remote connection closed^M (gdb) FAIL: gdb.base/cond-eval-mode.exp: hbreak: continue After we make GDBserver handling Zx/zx packet idempotent, [PATCH 3/3] [GDBserver] Make Zx/zx packet handling idempotent. https://sourceware.org/ml/gdb-patches/2014-04/msg00480.html > Now removal/insertion of all kinds of breakpoints/watchpoints, either > internal, or from GDB, always go through the target methods. GDBserver handles all kinds of breakpoints/watchpoints through target methods. However, some target backends, such as arm, don't support Z0 packet but need software breakpoint to do breakpoint stepping over in linux-low.c:start_step_over, if (can_hardware_single_step ()) { step = 1; } else { CORE_ADDR raddr = (*the_low_target.breakpoint_reinsert_addr) (); set_reinsert_breakpoint (raddr); step = 0; } a software breakpoint is requested to the backend, and the error is triggered. This problem should affect targets having breakpoint_reinsert_addr hooked. Instead of handling memory breakpoint in these affected linux backend, this patch handles memory breakpoint in linux_{insert,remove}_point, that, if memory breakpoint is requested, call {insert,remove}_memory_breakpoint respectively. Then, it becomes unnecessary to handle memory breakpoint for linux x86 backend, so this patch removes the code there. This patch is tested with GDBserver on x86_64-linux and arm-linux (-marm, -mthumb). Testing this patch on mips, nios2, bfin, and sparc is welcome. Note that there are still some fails in gdb.base/cond-eval-mode.exp with -mthumb, because GDBserver doesn't know how to select the correct breakpoint instruction according to the arm-or-thumb-mode of requested address. This is a separate issue, anyway. gdb/gdbserver: 2015-04-09 Yao Qi * linux-low.c (linux_insert_point): Call insert_memory_breakpoint if TYPE is raw_bkpt_type_sw. (linux_remove_point): Call remove_memory_breakpoint if type is raw_bkpt_type_sw. * linux-x86-low.c (x86_insert_point): Don't call insert_memory_breakpoint. (x86_remove_point): Don't call remove_memory_breakpoint. --- gdb/gdbserver/linux-low.c | 8 ++++++-- gdb/gdbserver/linux-x86-low.c | 6 ------ 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/gdb/gdbserver/linux-low.c b/gdb/gdbserver/linux-low.c index e4c5420..6dd9224 100644 --- a/gdb/gdbserver/linux-low.c +++ b/gdb/gdbserver/linux-low.c @@ -5115,7 +5115,9 @@ static int linux_insert_point (enum raw_bkpt_type type, CORE_ADDR addr, int size, struct raw_breakpoint *bp) { - if (the_low_target.insert_point != NULL) + if (type == raw_bkpt_type_sw) + return insert_memory_breakpoint (bp); + else if (the_low_target.insert_point != NULL) return the_low_target.insert_point (type, addr, size, bp); else /* Unsupported (see target.h). */ @@ -5126,7 +5128,9 @@ static int linux_remove_point (enum raw_bkpt_type type, CORE_ADDR addr, int size, struct raw_breakpoint *bp) { - if (the_low_target.remove_point != NULL) + if (type == raw_bkpt_type_sw) + return remove_memory_breakpoint (bp); + else if (the_low_target.remove_point != NULL) return the_low_target.remove_point (type, addr, size, bp); else /* Unsupported (see target.h). */ diff --git a/gdb/gdbserver/linux-x86-low.c b/gdb/gdbserver/linux-x86-low.c index e293ba4..763df08 100644 --- a/gdb/gdbserver/linux-x86-low.c +++ b/gdb/gdbserver/linux-x86-low.c @@ -561,9 +561,6 @@ x86_insert_point (enum raw_bkpt_type type, CORE_ADDR addr, switch (type) { - case raw_bkpt_type_sw: - return insert_memory_breakpoint (bp); - case raw_bkpt_type_hw: case raw_bkpt_type_write_wp: case raw_bkpt_type_access_wp: @@ -590,9 +587,6 @@ x86_remove_point (enum raw_bkpt_type type, CORE_ADDR addr, switch (type) { - case raw_bkpt_type_sw: - return remove_memory_breakpoint (bp); - case raw_bkpt_type_hw: case raw_bkpt_type_write_wp: case raw_bkpt_type_access_wp: