From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 96844 invoked by alias); 14 Feb 2016 18:37:56 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 96751 invoked by uid 89); 14 Feb 2016 18:37:55 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=watchpoints, Hx-languages-length:2990, sk:command, detach 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; Sun, 14 Feb 2016 18:37:54 +0000 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id 4D6115A42 for ; Sun, 14 Feb 2016 18:37:53 +0000 (UTC) Received: from brno.lan (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u1EIboCn009649 for ; Sun, 14 Feb 2016 13:37:52 -0500 From: Pedro Alves To: gdb-patches@sourceware.org Subject: [PATCH 2/4] Introduce 'enum remove_bp_reason' Date: Sun, 14 Feb 2016 18:37:00 -0000 Message-Id: <1455475070-17797-3-git-send-email-palves@redhat.com> In-Reply-To: <1455475070-17797-1-git-send-email-palves@redhat.com> References: <1455475070-17797-1-git-send-email-palves@redhat.com> X-SW-Source: 2016-02/txt/msg00449.txt.bz2 Makes the code more obvious. gdb/ChangeLog: 2016-02-14 Pedro Alves * breakpoint.c (insertion_state_t): Delete. (enum remove_bp_reason): New. (detach_breakpoints, remove_breakpoint_1, remove_breakpoint): Adjust to use enum remove_bp_reason instead of insertion_state_t. --- gdb/breakpoint.c | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index 05da8ed..9b37508 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -194,15 +194,20 @@ static void commands_command (char *, int); static void condition_command (char *, int); -typedef enum - { - mark_inserted, - mark_uninserted - } -insertion_state_t; +/* Why are we removing the breakpoint from the target? */ + +enum remove_bp_reason +{ + /* A regular remove. Remove the breakpoint and forget everything + about it. */ + REMOVE_BREAKPOINT, + + /* Detach the breakpoints from a fork child. */ + DETACH_BREAKPOINT, +}; static int remove_breakpoint (struct bp_location *); -static int remove_breakpoint_1 (struct bp_location *, insertion_state_t); +static int remove_breakpoint_1 (struct bp_location *, enum remove_bp_reason); static enum print_stop_action print_bp_stop_message (bpstat bs); @@ -3922,7 +3927,7 @@ detach_breakpoints (ptid_t ptid) continue; if (bl->inserted) - val |= remove_breakpoint_1 (bl, mark_inserted); + val |= remove_breakpoint_1 (bl, DETACH_BREAKPOINT); } do_cleanups (old_chain); @@ -3936,7 +3941,7 @@ detach_breakpoints (ptid_t ptid) *not* look at bl->pspace->aspace here. */ static int -remove_breakpoint_1 (struct bp_location *bl, insertion_state_t is) +remove_breakpoint_1 (struct bp_location *bl, enum remove_bp_reason reason) { int val; @@ -4048,18 +4053,18 @@ remove_breakpoint_1 (struct bp_location *bl, insertion_state_t is) if (val) return val; - bl->inserted = (is == mark_inserted); + bl->inserted = (reason == DETACH_BREAKPOINT); } else if (bl->loc_type == bp_loc_hardware_watchpoint) { gdb_assert (bl->owner->ops != NULL && bl->owner->ops->remove_location != NULL); - bl->inserted = (is == mark_inserted); + bl->inserted = (reason == DETACH_BREAKPOINT); bl->owner->ops->remove_location (bl); /* Failure to remove any of the hardware watchpoints comes here. */ - if ((is == mark_uninserted) && (bl->inserted)) + if (reason == REMOVE_BREAKPOINT && bl->inserted) warning (_("Could not remove hardware watchpoint %d."), bl->owner->number); } @@ -4074,7 +4079,7 @@ remove_breakpoint_1 (struct bp_location *bl, insertion_state_t is) if (val) return val; - bl->inserted = (is == mark_inserted); + bl->inserted = (reason == DETACH_BREAKPOINT); } return 0; @@ -4097,7 +4102,7 @@ remove_breakpoint (struct bp_location *bl) switch_to_program_space_and_thread (bl->pspace); - ret = remove_breakpoint_1 (bl, mark_uninserted); + ret = remove_breakpoint_1 (bl, REMOVE_BREAKPOINT); do_cleanups (old_chain); return ret; -- 1.9.3