From patchwork Fri May 20 15:12:36 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yao Qi X-Patchwork-Id: 12416 Received: (qmail 68065 invoked by alias); 20 May 2016 15:13: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 67865 invoked by uid 89); 20 May 2016 15:13:04 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.5 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 spammy=141, 8 X-HELO: mail-pf0-f195.google.com Received: from mail-pf0-f195.google.com (HELO mail-pf0-f195.google.com) (209.85.192.195) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Fri, 20 May 2016 15:12:58 +0000 Received: by mail-pf0-f195.google.com with SMTP id 145so11659276pfz.1 for ; Fri, 20 May 2016 08:12:58 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=bFUDX1sQmO/wiwxb2G1deIycQcAX90g3seZA2Usgv9c=; b=LYg2eDdzAzTiiQ675HGBeygTdfpSTXeaEgz27/fBRakXKKDjGqbcnGWzoQaFBnoj7W gJXBybmh46dSWsDUe0i+hi/yXHdiK1dCO76mG1nGt+DR1rSOru6lYl1u4PuK+11nz5Cl N+VqrKSPc0wzlzTYVdY7n9Tb26xbQpMPlkvnRKDuljC81m9ybecyyU8mzeIX8K7b5QZq nWUIkPsvKRtg7JBW4dxyJyYi+XTRjM32OF7fDo+4i7zAYXmUWPx7dNQC33IUyA89N2t0 P6Q9gqA/+ZFcS+21oPPKcfrs9wMs6uHK74CxRKlvBy9TcFeCIPwzsnjRsfmj3jso8NSe d+KA== X-Gm-Message-State: AOPr4FWtT+e2taGQESzW7f3SMpgjfsvhdPXntMDKwyi1oavXWZb4skFhyqLAkT5LyckLQA== X-Received: by 10.98.25.74 with SMTP id 71mr5578138pfz.94.1463757175286; Fri, 20 May 2016 08:12:55 -0700 (PDT) Received: from E107787-LIN.cambridge.arm.com (gcc113.osuosl.org. [140.211.9.71]) by smtp.gmail.com with ESMTPSA id p80sm27985272pfj.58.2016.05.20.08.12.53 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 20 May 2016 08:12:54 -0700 (PDT) From: Yao Qi X-Google-Original-From: Yao Qi To: gdb-patches@sourceware.org Subject: [PATCH 3/8] Pass breakpoint type in set_breakpoint_at Date: Fri, 20 May 2016 16:12:36 +0100 Message-Id: <1463757161-25850-4-git-send-email-yao.qi@linaro.org> In-Reply-To: <1463757161-25850-1-git-send-email-yao.qi@linaro.org> References: <1463757161-25850-1-git-send-email-yao.qi@linaro.org> X-IsSubscribed: yes Nowadays, set_breakpoint_at creates breakpoint of type other_breakpoint, but we also use set_breakpoint_at in set_reinsert_breakpoint to create breakpoint, so that we have to overwrite the breakpoint type like this, bp = set_breakpoint_at (stop_at, NULL); bp->type = reinsert_breakpoint; which looks not very good. This patch changes set_breakpoint_at to receive breakpoint type. Since set_breakpoint_at is used in many places, I rename it to set_breakpoint_at_1, and wrap it with set_breakpoint_at, and pass other_breakpoint. In this way, we can call set_breakpoint_at_1 with reinsert_breakpoint in set_reinsert_breakpoint too, and code looks cleaner. gdb/gdbserver: 2016-05-20 Yao Qi * mem-break.c (set_breakpoint_at): Rename it to ... (set_breakpoint_at_1): ... it. (set_breakpoint_at): Call set_breakpoint_at_1. (set_reinsert_breakpoint): Call set_breakpoint_at_1. * mem-break.h (set_breakpoint_at): Update comments. --- gdb/gdbserver/mem-break.c | 20 ++++++++++++++------ gdb/gdbserver/mem-break.h | 3 ++- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/gdb/gdbserver/mem-break.c b/gdb/gdbserver/mem-break.c index 3313459..3e3be8b 100644 --- a/gdb/gdbserver/mem-break.c +++ b/gdb/gdbserver/mem-break.c @@ -785,20 +785,29 @@ set_breakpoint (enum bkpt_type type, enum raw_bkpt_type raw_type, return bp; } -/* See mem-break.h */ +/* Set breakpoint of TYPE on address WHERE with handler HANDLER. */ -struct breakpoint * -set_breakpoint_at (CORE_ADDR where, int (*handler) (CORE_ADDR)) +static struct breakpoint * +set_breakpoint_at_1 (enum bkpt_type type, CORE_ADDR where, + int (*handler) (CORE_ADDR)) { int err_ignored; CORE_ADDR placed_address = where; int breakpoint_kind = target_breakpoint_kind_from_pc (&placed_address); - return set_breakpoint (other_breakpoint, raw_bkpt_type_sw, + return set_breakpoint (type, raw_bkpt_type_sw, placed_address, breakpoint_kind, handler, &err_ignored); } +/* See mem-break.h */ + +struct breakpoint * +set_breakpoint_at (CORE_ADDR where, int (*handler) (CORE_ADDR)) +{ + return set_breakpoint_at_1 (other_breakpoint, where, handler); +} + static int delete_raw_breakpoint (struct process_info *proc, struct raw_breakpoint *todel) @@ -1411,8 +1420,7 @@ set_reinsert_breakpoint (CORE_ADDR stop_at) { struct breakpoint *bp; - bp = set_breakpoint_at (stop_at, NULL); - bp->type = reinsert_breakpoint; + bp = set_breakpoint_at_1 (reinsert_breakpoint, stop_at, NULL); } void diff --git a/gdb/gdbserver/mem-break.h b/gdb/gdbserver/mem-break.h index b84dc1e..f6c9631 100644 --- a/gdb/gdbserver/mem-break.h +++ b/gdb/gdbserver/mem-break.h @@ -141,7 +141,8 @@ int gdb_breakpoint_here (CORE_ADDR where); /* Create a new breakpoint at WHERE, and call HANDLER when it is hit. HANDLER should return 1 if the breakpoint - should be deleted, 0 otherwise. */ + should be deleted, 0 otherwise. The type of the created + breakpoint is other_breakpoint. */ struct breakpoint *set_breakpoint_at (CORE_ADDR where, int (*handler) (CORE_ADDR));