From patchwork Wed Oct 5 09:32:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Burgess X-Patchwork-Id: 58378 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id CA8713857005 for ; Wed, 5 Oct 2022 09:34:06 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org CA8713857005 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1664962446; bh=W/sMV71BkO4sXhc1glgR4sYueQsAc/fUyHc+J6qjh2g=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=Qy3A2FVEjOAZO1X5A3n5T24TGoT4cDj0I1m4vxdmDHgVJSJ9wj7M500rTeRhWuv0L SLYUIbEPTdrMTqNR1ZB5z3bxIwSDa2+0XN19wCJLdf3XBLq52LiB0dMnQDLMw1Ngh1 ifXeqxiJwd7Hxul7nDE0QHYc4PMO5pjswLsP/Ln0= X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 8FB5B385782F for ; Wed, 5 Oct 2022 09:33:07 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 8FB5B385782F Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-260-QA4rkkjOPS6p-fHLiqdfqA-1; Wed, 05 Oct 2022 05:32:58 -0400 X-MC-Unique: QA4rkkjOPS6p-fHLiqdfqA-1 Received: by mail-wm1-f72.google.com with SMTP id c2-20020a1c3502000000b003b535aacc0bso712076wma.2 for ; Wed, 05 Oct 2022 02:32:57 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=W/sMV71BkO4sXhc1glgR4sYueQsAc/fUyHc+J6qjh2g=; b=Q6AOFmWYmYAkPEg41hB+srdoV1w6OFvr5oVXxXZOjQtsN8ZlReX3+fYQHJfJMgwHaP 37R6bD9e34F8wdu33FuS4sqskAV44wh8C9eHDOIjL3O21VJFI6Y6hUdQkDTS5jViZFNc iZT8VlmyP2184ra2s1bSJiKunPTTrifyEQpB45FU3IQohXeUzjzDhripZBQeTnyWgg5s NV1tSAkLF+JXWpkeJtybLI92J6dsjOo7gsE99Ko0PR660l5tQBfky0CFFiaby4iSnjXc ohrpxYR3WPUzOxnXWO5SpLPMpou6n0tqbXpEDAvJXfKqokP7oS7v9bt+L8SWS4xOLN2B WerA== X-Gm-Message-State: ACrzQf1wVJbP2w86lbCpe6D7v3eDIuACGaD0Vm91JkG8VOOqPyD3/qO0 lWuG9AjJHlSBm70PnIG7Ka6jEjKdbaByTciXlG0h7nsmnJT54+AS8lZBd2FaWcyvoTNjK7uyZA/ J2ylspCIg1f8EOgDgFGbR0x4YwGWtmxedE5dFZDD9Lo3LNoa9zs+4Q1kq8U+NviTY50xAG4jhpg == X-Received: by 2002:adf:e641:0:b0:22c:fb86:4d9f with SMTP id b1-20020adfe641000000b0022cfb864d9fmr15331269wrn.348.1664962376703; Wed, 05 Oct 2022 02:32:56 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6ktQei6hbn79H+2uEja2+eRr358n9oMpXG17TIDd6AZkWxiLRn65amCSHnW2mcxuANA3pQ+g== X-Received: by 2002:adf:e641:0:b0:22c:fb86:4d9f with SMTP id b1-20020adfe641000000b0022cfb864d9fmr15331251wrn.348.1664962376463; Wed, 05 Oct 2022 02:32:56 -0700 (PDT) Received: from localhost (52.72.115.87.dyn.plus.net. [87.115.72.52]) by smtp.gmail.com with ESMTPSA id bi26-20020a05600c3d9a00b003b476cabf1csm1378728wmb.26.2022.10.05.02.32.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Oct 2022 02:32:55 -0700 (PDT) To: gdb-patches@sourceware.org Subject: [PATCH 1/4] gdb: make some bp_location arguments const in breakpoint.c Date: Wed, 5 Oct 2022 10:32:49 +0100 Message-Id: <0c8a73fc82f77704a4a065b0b251911aebae1322.1664962269.git.aburgess@redhat.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: References: MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-11.9 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Andrew Burgess via Gdb-patches From: Andrew Burgess Reply-To: Andrew Burgess Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Sender: "Gdb-patches" I spotted a few places where I could make some 'bp_location *' arguments constant in breakpoint.c. There should be no user visible changes after this commit. Reviewed-By: Bruno Larsen --- gdb/breakpoint.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index 002f4a935b1..6e1a15e4f1b 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -125,11 +125,11 @@ static CORE_ADDR adjust_breakpoint_address (struct gdbarch *gdbarch, enum bptype bptype, struct program_space *pspace); -static int watchpoint_locations_match (struct bp_location *loc1, - struct bp_location *loc2); +static int watchpoint_locations_match (const struct bp_location *loc1, + const struct bp_location *loc2); -static int breakpoint_locations_match (struct bp_location *loc1, - struct bp_location *loc2, +static int breakpoint_locations_match (const struct bp_location *loc1, + const struct bp_location *loc2, bool sw_hw_bps_match = false); static int breakpoint_location_address_match (struct bp_location *bl, @@ -2643,7 +2643,7 @@ build_target_command_list (struct bp_location *bl) registers state. */ static int -breakpoint_kind (struct bp_location *bl, CORE_ADDR *addr) +breakpoint_kind (const struct bp_location *bl, CORE_ADDR *addr) { if (bl->owner->type == bp_single_step) { @@ -4229,7 +4229,7 @@ moribund_breakpoint_here_p (const address_space *aspace, CORE_ADDR pc) ASPACE. */ static int -bp_location_inserted_here_p (struct bp_location *bl, +bp_location_inserted_here_p (const struct bp_location *bl, const address_space *aspace, CORE_ADDR pc) { if (bl->inserted @@ -5440,7 +5440,7 @@ bpstat_check_breakpoint_conditions (bpstat *bs, thread_info *thread) on the current target. */ static int -need_moribund_for_location_type (struct bp_location *loc) +need_moribund_for_location_type (const struct bp_location *loc) { return ((loc->loc_type == bp_loc_software_breakpoint && !target_supports_stopped_by_sw_breakpoint ()) @@ -5974,7 +5974,7 @@ bp_condition_evaluator (const breakpoint *b) similar to bp_condition_evaluator, but for locations. */ static const char * -bp_location_condition_evaluator (struct bp_location *bl) +bp_location_condition_evaluator (const struct bp_location *bl) { if (bl && !is_breakpoint (bl->owner)) return NULL; @@ -6933,8 +6933,8 @@ bl_address_is_meaningful (bp_location *loc) true if LOC1 and LOC2 represent the same watchpoint location. */ static int -watchpoint_locations_match (struct bp_location *loc1, - struct bp_location *loc2) +watchpoint_locations_match (const struct bp_location *loc1, + const struct bp_location *loc2) { struct watchpoint *w1 = (struct watchpoint *) loc1->owner; struct watchpoint *w2 = (struct watchpoint *) loc2->owner; @@ -7045,8 +7045,8 @@ breakpoint_location_address_range_overlap (struct bp_location *bl, true, otherwise returns false. */ static int -tracepoint_locations_match (struct bp_location *loc1, - struct bp_location *loc2) +tracepoint_locations_match (const struct bp_location *loc1, + const struct bp_location *loc2) { if (is_tracepoint (loc1->owner) && is_tracepoint (loc2->owner)) /* Since tracepoint locations are never duplicated with others', tracepoint @@ -7064,8 +7064,8 @@ tracepoint_locations_match (struct bp_location *loc1, otherwise they don't. */ static int -breakpoint_locations_match (struct bp_location *loc1, - struct bp_location *loc2, +breakpoint_locations_match (const struct bp_location *loc1, + const struct bp_location *loc2, bool sw_hw_bps_match) { int hw_point1, hw_point2; @@ -13157,7 +13157,7 @@ enable_disable_bp_num_loc (int bp_num, int loc_num, bool enable) owner. 1-based indexing. -1 signals NOT FOUND. */ static int -find_loc_num_by_location (bp_location *loc) +find_loc_num_by_location (const bp_location *loc) { if (loc != nullptr && loc->owner != nullptr) { From patchwork Wed Oct 5 09:32:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Burgess X-Patchwork-Id: 58375 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 8C6D33857367 for ; Wed, 5 Oct 2022 09:33:25 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8C6D33857367 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1664962405; bh=EL7zQHA/K3Jq+XO51ihOXX/g7obP8Z0HuSn3V3S3ouM=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=xVUKkxrlG8ug+YWrJDDXjbSQ8UwTAOzsPl4EQjXS1rvlEMG7g9imyjl0JfkmdgI8Q qT/zt4qt4frFX/pglAkzkS+0iLxgg7DMfYY0tB0s8IodJfjoNxl7p4ZRF9KWniswwi cN24/VURs1tjUInUFlLTY28dtfLDzP0jtISSQCjM= X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 9F5A03857C4E for ; Wed, 5 Oct 2022 09:33:00 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 9F5A03857C4E Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-665-cLbI5_y_NoGuONMebDg7zQ-1; Wed, 05 Oct 2022 05:32:59 -0400 X-MC-Unique: cLbI5_y_NoGuONMebDg7zQ-1 Received: by mail-wm1-f72.google.com with SMTP id y7-20020a05600c20c700b003bf90b54edbso163563wmm.1 for ; Wed, 05 Oct 2022 02:32:59 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=EL7zQHA/K3Jq+XO51ihOXX/g7obP8Z0HuSn3V3S3ouM=; b=Va7fuhLzjtXedR4Qgml5SV25E/tisht4S6GqlLBEoelmaJQtrH1NtpFCQmroq3DCUV NgyD7VEv2NgcCRPcUcBM9FTt+kZabrjkg3afJ8GvU8OezRFyIy5o0+i7ZtjA5hCJrzkD PvJhMDMnvb9wxL0zQC6mcIeMGdAYoBDHUZ0JRS/PEsruwLEI3iwG+Xv/+w2j/zbtwqDO whljq7Y2wxsKNXSbAPV0pKgs4SoyB5q8SbWRWQdoLZxQ0xPapOFNgLuBFrr2em2mRe2O d1PuYfLQyG3O/MAU7kihJy7Q7NVuijGPhBs63wdiIaCPYKTgm5mDU0cbC5akT9c0WOo8 jjRA== X-Gm-Message-State: ACrzQf1u3t25Me/O5oyRDkZSJCrknSkZhd55Y11CqG8LpFkO6/B+wKvc vt2hsqR83Ml2cAPNRY3URufEbznPSyzw+e+mgRzBcr0RcOOAVGfLcTtO+G2ctQQ4txqHiRHqpxc GuTOvJNCRuutCmFY6nTHYJZLCV4blETAIDoRl/HB+oiMq2sWUE32XT9DOympZ1+63P3ilRxaGQA == X-Received: by 2002:adf:ef4b:0:b0:22e:5c0c:f5f with SMTP id c11-20020adfef4b000000b0022e5c0c0f5fmr2494844wrp.9.1664962377937; Wed, 05 Oct 2022 02:32:57 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6nC6lOTcTvmOethYatXeVEmE7LEwfsjdP5BAFuRB1hIMatPayRdaa/QiirsusP3MkBFLuSTA== X-Received: by 2002:adf:ef4b:0:b0:22e:5c0c:f5f with SMTP id c11-20020adfef4b000000b0022e5c0c0f5fmr2494825wrp.9.1664962377681; Wed, 05 Oct 2022 02:32:57 -0700 (PDT) Received: from localhost (52.72.115.87.dyn.plus.net. [87.115.72.52]) by smtp.gmail.com with ESMTPSA id a14-20020adfed0e000000b0022ae4f8395dsm14413378wro.96.2022.10.05.02.32.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Oct 2022 02:32:57 -0700 (PDT) To: gdb-patches@sourceware.org Subject: [PATCH 2/4] gdb: used scoped_restore_frame in update_watchpoint Date: Wed, 5 Oct 2022 10:32:50 +0100 Message-Id: <56902b3d9d93987a9d3573eb80a0a5afbe86be0a.1664962269.git.aburgess@redhat.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: References: MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-12.2 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Andrew Burgess via Gdb-patches From: Andrew Burgess Reply-To: Andrew Burgess Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Sender: "Gdb-patches" I was doing some int to bool cleanup in update_watchpoint, and I noticed a manual version of scoped_restore_selected_frame. As always when these things are done manually, there is the chance that, in an error case, we might leave the wrong frame selected. This commit updates things to use scoped_restore_selected_frame, and also converts a local variable from int to bool. The only user visible change after this commit is in the case where update_watchpoint throws an error - we should now correctly restore the previously selected frame. Otherwise, this commit should be invisible to the user. --- gdb/breakpoint.c | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index 6e1a15e4f1b..57281a199b0 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -1926,9 +1926,7 @@ add_dummy_location (struct breakpoint *b, static void update_watchpoint (struct watchpoint *b, int reparse) { - int within_current_scope; - struct frame_id saved_frame_id; - int frame_saved; + bool within_current_scope; /* If this is a local watchpoint, we only want to check if the watchpoint frame is in scope if the current thread is the thread @@ -1938,12 +1936,12 @@ update_watchpoint (struct watchpoint *b, int reparse) if (b->disposition == disp_del_at_next_stop) return; - - frame_saved = 0; + + gdb::optional restore_frame; /* Determine if the watchpoint is within scope. */ if (b->exp_valid_block == NULL) - within_current_scope = 1; + within_current_scope = true; else { struct frame_info *fi = get_current_frame (); @@ -1962,8 +1960,7 @@ update_watchpoint (struct watchpoint *b, int reparse) /* FIXME drow/2003-09-09: It would be nice if evaluate_expression took a frame parameter, so that we didn't have to change the selected frame. */ - frame_saved = 1; - saved_frame_id = get_frame_id (get_selected_frame (NULL)); + restore_frame.emplace (); fi = frame_find_by_id (b->watchpoint_frame); within_current_scope = (fi != NULL); @@ -2229,10 +2226,6 @@ in which its expression is valid.\n"), b->number); watchpoint_del_at_next_stop (b); } - - /* Restore the selected frame. */ - if (frame_saved) - select_frame (frame_find_by_id (saved_frame_id)); } From patchwork Wed Oct 5 09:32:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Burgess X-Patchwork-Id: 58377 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 2F512385AC2F for ; Wed, 5 Oct 2022 09:33:53 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2F512385AC2F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1664962433; bh=ThUupYlZWcvJFf5HCqNYyHu+TvqZeyazoMMbW1YFKL0=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=geZPowBftD4hKr26YPGzBLqZlNkx/YKk3+dHAXTYr707inYR43Td+CLysRZhSEmdt 7L+O238DgmA+qBJ9STTDtNo2Hx6DXMO+bHkoR+gzCLXws0BWnZ5lrGjXOCmo2TX762 JL2GKZARxwXhxopJNJ4MeqnOMUk3CihuNoScGhx8= X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 134C33857C72 for ; Wed, 5 Oct 2022 09:33:02 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 134C33857C72 Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-17-VP_Fm2LCOLuuVVK5Z2uaGg-1; Wed, 05 Oct 2022 05:33:00 -0400 X-MC-Unique: VP_Fm2LCOLuuVVK5Z2uaGg-1 Received: by mail-wr1-f69.google.com with SMTP id j8-20020adfa548000000b0022e2bf8f48fso3428259wrb.23 for ; Wed, 05 Oct 2022 02:33:00 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ThUupYlZWcvJFf5HCqNYyHu+TvqZeyazoMMbW1YFKL0=; b=GdgnZo57Onwci5tq0hfBmnSrwu9PqU8l+Rqz59sHI70gC8TvEfgNdP6vEj0Jr5q6Ds TTsKSEnz4r7O3HshrUkSH2olrjPS9THJgQWBGm85+lFmFwmc/iON9CrTWok8+PtvDv9x Zv7r4IeNeLzgBj8joOCth87Kz/wj0h7V1ls87+B45GzCt1UzM663UZOvtSaWKkpKB7Fr 44D0LjbWsa4rmtMIYGZFaW267qM2ycspdsQhqK/7jk7+ZAf5tnqweN7JWfkhmrObazhY tCMTMnzL2RJ8O0P3s6lT3FFOSbkiPtBw0XjWpIoT1zqFlLz+NwvuPX8yymLDcmdnh4HW +zSw== X-Gm-Message-State: ACrzQf39P/udGOVpdJoG23pnhnNdheUIPqwcOprt3jkKS3VBnnrl72Tx 8g8IN0qlY5ZUrxCSmdweefObNQCLtdGUep8iXHwiXlgJElkRlF4xg46ODTVUgtmAiDZjMC7/LXj hxYXwc/0VL4fRdEA3mQ1xrIr6jOkbHrXmxnTWVzlxjmfFEgx+xBqP29HcVT+1sotEqG9IfLN0iw == X-Received: by 2002:a5d:4cd0:0:b0:22e:4982:6fbe with SMTP id c16-20020a5d4cd0000000b0022e49826fbemr6318632wrt.591.1664962379116; Wed, 05 Oct 2022 02:32:59 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5sK1ZzLeKVRjJweUBcHzCvBKkTPmYFWoU9rbyBuLSVDCYgxrj9AvmbhSs5S8nytMDhWYCuqg== X-Received: by 2002:a5d:4cd0:0:b0:22e:4982:6fbe with SMTP id c16-20020a5d4cd0000000b0022e49826fbemr6318618wrt.591.1664962378911; Wed, 05 Oct 2022 02:32:58 -0700 (PDT) Received: from localhost (52.72.115.87.dyn.plus.net. [87.115.72.52]) by smtp.gmail.com with ESMTPSA id w10-20020a05600c474a00b003a5f54e3bbbsm1419918wmo.38.2022.10.05.02.32.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Oct 2022 02:32:58 -0700 (PDT) To: gdb-patches@sourceware.org Subject: [PATCH 3/4] gdb: make use of scoped_restore in unduplicated_should_be_inserted Date: Wed, 5 Oct 2022 10:32:51 +0100 Message-Id: <90be6d987ae6043fdb8c25a0706397ab06eaf437.1664962269.git.aburgess@redhat.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: References: MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-12.2 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Andrew Burgess via Gdb-patches From: Andrew Burgess Reply-To: Andrew Burgess Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Sender: "Gdb-patches" I noticed that we could make use of a scoped_restore in the function unduplicated_should_be_inserted. I've also converted the function return type from int to bool. This change shouldn't make any difference, as I don't think anything within should_be_inserted could throw an exception, but the change doesn't hurt, and will help keep us safe if anything ever changes in the future. --- gdb/breakpoint.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index 57281a199b0..e3f3ba3efa6 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -2301,16 +2301,13 @@ should_be_inserted (struct bp_location *bl) /* Same as should_be_inserted but does the check assuming that the location is not duplicated. */ -static int +static bool unduplicated_should_be_inserted (struct bp_location *bl) { - int result; - const int save_duplicate = bl->duplicate; + scoped_restore restore_bl_duplicate + = make_scoped_restore (&bl->duplicate, 0); - bl->duplicate = 0; - result = should_be_inserted (bl); - bl->duplicate = save_duplicate; - return result; + return should_be_inserted (bl); } /* Parses a conditional described by an expression COND into an From patchwork Wed Oct 5 09:32:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Burgess X-Patchwork-Id: 58376 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id CB515385AC31 for ; Wed, 5 Oct 2022 09:33:37 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org CB515385AC31 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1664962417; bh=zIgw+Tbcw6jnOcDZUHrYyt5dM2KAU5slQLAUyTQ4tqE=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=YfKFCvseasGW5fX3Z2beJ7ruLSjAoVkQ+kCQ/a5lPQdPG7YrgvxESJ/qUwBKdjDms vROhLzEIiHWOvUEtpQSAmYDnappUC4bbyxOzSFMgA03m+l43/uG+JJPjX54Qh7p2X4 WhrzkQrrTQXwYkzTcOWWn3UPaMAN4qg8ZSsXiccw= X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 0DF1A385740B for ; Wed, 5 Oct 2022 09:33:05 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 0DF1A385740B Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-303-kgvzQwzhNjydTDUwMYYImw-1; Wed, 05 Oct 2022 05:33:03 -0400 X-MC-Unique: kgvzQwzhNjydTDUwMYYImw-1 Received: by mail-wr1-f70.google.com with SMTP id i1-20020adfa501000000b0022cd1e1137bso4997828wrb.0 for ; Wed, 05 Oct 2022 02:33:03 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=zIgw+Tbcw6jnOcDZUHrYyt5dM2KAU5slQLAUyTQ4tqE=; b=kJi75oyZ/1OcFbURsN7EikSNirLBr82RAAcGzS24xCMrFvTCcYX5HGf5tKIHFf8T1q jhvlZyf45Knm10qnTY+EJ/8DQWKJ2pBjVT3aZmviIDeb5PZLptGsRAnZpTgpks7G/QRK qVArBKgh/6rUozKesSdZMTd/obBkmNRaVI/txoaqmd5lAqJIrqkRRaF4DigBdw+P/zRr PjGyKJKQ1UjTtFtvcJclTypfQ9E1ixgkRvvLgGuFk7VC3VyAI+wSUcVGOcuNfDRbKXeY cavusq20BeNfyBpt1DT3X+2p3VZsz6vTejaJQoQ0NxV7Ey0nxGSy9D2QdNiAI8o/3387 TtQw== X-Gm-Message-State: ACrzQf3Lno2FfJznEwaPmuP6bLKLbvriJc5DNeZ22e1q/oJmf0G/BYSk DNG4wH/qNXDr7SMP6SjVy50rrH+JHMXXc21gv4oYB1DV2LeiUTKYqH/1tybnNwUqPVQWp8Ly59E OwP2fvM+7mUtXGC4lANpo1UA8tSdNJUJWbg2tK/NZCTvsg/NoranW0hGZ20OP5uaDwx3AgGasIw == X-Received: by 2002:a05:600c:6d2:b0:3b4:8361:6154 with SMTP id b18-20020a05600c06d200b003b483616154mr2739229wmn.89.1664962380980; Wed, 05 Oct 2022 02:33:00 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7KpKPQd/XeKOlkK0CbB7ZqELuzDj4tKUo/+4kG9UpinPpVoNvCvVNUvT+BU0Z0SM0Awon0Ow== X-Received: by 2002:a05:600c:6d2:b0:3b4:8361:6154 with SMTP id b18-20020a05600c06d200b003b483616154mr2739188wmn.89.1664962380194; Wed, 05 Oct 2022 02:33:00 -0700 (PDT) Received: from localhost (52.72.115.87.dyn.plus.net. [87.115.72.52]) by smtp.gmail.com with ESMTPSA id f15-20020a05600c4e8f00b003b51a4c61aasm1520050wmq.40.2022.10.05.02.32.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Oct 2022 02:32:59 -0700 (PDT) To: gdb-patches@sourceware.org Subject: [PATCH 4/4] gdb: some int to bool conversion in breakpoint.c Date: Wed, 5 Oct 2022 10:32:52 +0100 Message-Id: X-Mailer: git-send-email 2.25.4 In-Reply-To: References: MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-12.2 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Andrew Burgess via Gdb-patches From: Andrew Burgess Reply-To: Andrew Burgess Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Sender: "Gdb-patches" Some int to bool conversion in breakpoint.c. I've only updated the function signatures of static functions, but I've updated some function local variables throughout the file. The most interesting change is in unduplicated_should_be_inserted, where I've made use of make_scoped_restore to temporarily change the bl->duplicate flag. There should be no user visible changes after this commit. --- gdb/breakpoint.c | 271 +++++++++++++++++++++++------------------------ 1 file changed, 133 insertions(+), 138 deletions(-) diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index e3f3ba3efa6..8e219221780 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -118,27 +118,27 @@ static struct breakpoint * enum bptype type, int loc_enabled, int thread); -static void breakpoint_adjustment_warning (CORE_ADDR, CORE_ADDR, int, int); +static void breakpoint_adjustment_warning (CORE_ADDR, CORE_ADDR, int, bool); static CORE_ADDR adjust_breakpoint_address (struct gdbarch *gdbarch, CORE_ADDR bpaddr, enum bptype bptype, struct program_space *pspace); -static int watchpoint_locations_match (const struct bp_location *loc1, - const struct bp_location *loc2); +static bool watchpoint_locations_match (const struct bp_location *loc1, + const struct bp_location *loc2); -static int breakpoint_locations_match (const struct bp_location *loc1, - const struct bp_location *loc2, - bool sw_hw_bps_match = false); +static bool breakpoint_locations_match (const struct bp_location *loc1, + const struct bp_location *loc2, + bool sw_hw_bps_match = false); -static int breakpoint_location_address_match (struct bp_location *bl, - const struct address_space *aspace, - CORE_ADDR addr); +static bool breakpoint_location_address_match (struct bp_location *bl, + const struct address_space *aspace, + CORE_ADDR addr); -static int breakpoint_location_address_range_overlap (struct bp_location *, - const address_space *, - CORE_ADDR, int); +static bool breakpoint_location_address_range_overlap (struct bp_location *, + const address_space *, + CORE_ADDR, int); static int remove_breakpoint (struct bp_location *); static int remove_breakpoint_1 (struct bp_location *, enum remove_bp_reason); @@ -212,10 +212,10 @@ static void set_tracepoint_count (int num); static bool is_masked_watchpoint (const struct breakpoint *b); -/* Return 1 if B refers to a static tracepoint set by marker ("-m"), zero - otherwise. */ +/* Return true if B refers to a static tracepoint set by marker ("-m"), + zero otherwise. */ -static int strace_marker_p (struct breakpoint *b); +static bool strace_marker_p (struct breakpoint *b); static void bkpt_probe_create_sals_from_location_spec (location_spec *locspec, @@ -595,7 +595,7 @@ breakpoint_condition_evaluation_mode (void) /* Return true if GDB should evaluate breakpoint conditions or false otherwise. */ -static int +static bool gdb_evaluates_breakpoint_condition_p (void) { const char *mode = breakpoint_condition_evaluation_mode (); @@ -760,7 +760,7 @@ static struct cmd_list_element *breakpoint_show_cmdlist; struct cmd_list_element *save_cmdlist; /* Return whether a breakpoint is an active enabled breakpoint. */ -static int +static bool breakpoint_enabled (struct breakpoint *b) { return (b->enable_state == bp_enabled); @@ -1558,19 +1558,19 @@ commands_from_control_command (const char *arg, struct command_line *cmd) return simple_control; } -/* Return non-zero if BL->TARGET_INFO contains valid information. */ +/* Return true if BL->TARGET_INFO contains valid information. */ -static int +static bool bp_location_has_shadow (struct bp_location *bl) { if (bl->loc_type != bp_loc_software_breakpoint) - return 0; + return false; if (!bl->inserted) - return 0; + return false; if (bl->target_info.shadow_len == 0) /* BL isn't valid, or doesn't shadow memory. */ - return 0; - return 1; + return false; + return true; } /* Update BUF, which is LEN bytes read from the target address @@ -1808,7 +1808,7 @@ is_watchpoint (const struct breakpoint *bpt) and in any state. It is presently left to the target allowing memory accesses when threads are running. */ -static int +static bool watchpoint_in_thread_scope (struct watchpoint *b) { return (b->pspace == current_program_space @@ -1924,7 +1924,7 @@ add_dummy_location (struct breakpoint *b, watchpoint removal from inferior. */ static void -update_watchpoint (struct watchpoint *b, int reparse) +update_watchpoint (struct watchpoint *b, bool reparse) { bool within_current_scope; @@ -2228,27 +2228,27 @@ in which its expression is valid.\n"), } } - -/* Returns 1 iff breakpoint location should be +/* Returns true iff breakpoint location should be inserted in the inferior. We don't differentiate the type of BL's owner (breakpoint vs. tracepoint), although insert_location in tracepoint's breakpoint_ops is not defined, because in insert_bp_location, tracepoint's insert_location will not be called. */ -static int + +static bool should_be_inserted (struct bp_location *bl) { if (bl->owner == NULL || !breakpoint_enabled (bl->owner)) - return 0; + return false; if (bl->owner->disposition == disp_del_at_next_stop) - return 0; + return false; if (!bl->enabled || bl->disabled_by_cond || bl->shlib_disabled || bl->duplicate) - return 0; + return false; if (user_breakpoint_p (bl->owner) && bl->pspace->executing_startup) - return 0; + return false; /* This is set for example, when we're attached to the parent of a vfork, and have detached from the child. The child is running @@ -2259,7 +2259,7 @@ should_be_inserted (struct bp_location *bl) the child could still trip on the parent's breakpoints. Since the parent is blocked anyway, it won't miss any breakpoint. */ if (bl->pspace->breakpoints_not_allowed) - return 0; + return false; /* Don't insert a breakpoint if we're trying to step past its location, except if the breakpoint is a single-step breakpoint, @@ -2281,7 +2281,7 @@ should_be_inserted (struct bp_location *bl) { infrun_debug_printf ("skipping breakpoint: stepping past insn at: %s", paddress (bl->gdbarch, bl->address)); - return 0; + return false; } /* Don't insert watchpoints if we're trying to step past the @@ -2292,10 +2292,10 @@ should_be_inserted (struct bp_location *bl) infrun_debug_printf ("stepping past non-steppable watchpoint. " "skipping watchpoint at %s:%d", paddress (bl->gdbarch, bl->address), bl->length); - return 0; + return false; } - return 1; + return true; } /* Same as should_be_inserted but does the check assuming @@ -2350,7 +2350,7 @@ parse_cond_to_aexpr (CORE_ADDR scope, struct expression *cond) static void build_target_condition_list (struct bp_location *bl) { - int null_condition_or_parse_error = 0; + bool null_condition_or_parse_error = false; int modified = bl->needs_update; /* Release conditions left over from a previous insert. */ @@ -2393,7 +2393,7 @@ build_target_condition_list (struct bp_location *bl) went wrong or we have a null condition expression. */ if (!loc->cond_bytecode) { - null_condition_or_parse_error = 1; + null_condition_or_parse_error = true; break; } } @@ -2527,7 +2527,7 @@ parse_cmd_to_aexpr (CORE_ADDR scope, char *cmd) static void build_target_command_list (struct bp_location *bl) { - int null_command_or_parse_error = 0; + bool null_command_or_parse_error = false; int modified = bl->needs_update; /* Clear commands left over from a previous insert. */ @@ -2576,7 +2576,7 @@ build_target_command_list (struct bp_location *bl) went wrong or we have a null command expression. */ if (!loc->cmd_bytecode) { - null_command_or_parse_error = 1; + null_command_or_parse_error = true; break; } } @@ -3021,7 +3021,7 @@ insert_breakpoints (void) { struct watchpoint *w = (struct watchpoint *) bpt; - update_watchpoint (w, 0 /* don't reparse. */); + update_watchpoint (w, false /* don't reparse. */); } /* Updating watchpoints creates new locations, so update the global @@ -3142,7 +3142,7 @@ insert_breakpoint_locations (void) them, as half-inserted watchpoint is of limited use. */ for (breakpoint *bpt : all_breakpoints ()) { - int some_failed = 0; + bool some_failed = false; if (!is_hardware_watchpoint (bpt)) continue; @@ -3156,7 +3156,7 @@ insert_breakpoint_locations (void) for (bp_location *loc : bpt->locations ()) if (!loc->inserted && should_be_inserted (loc)) { - some_failed = 1; + some_failed = true; break; } @@ -3323,7 +3323,7 @@ static struct minimal_symbol msym_not_found; /* Returns TRUE if MSYM point to the "not found" sentinel. */ -static int +static bool msym_not_found_p (const struct minimal_symbol *msym) { return msym == &msym_not_found; @@ -3685,7 +3685,7 @@ create_exception_master_breakpoint (void) /* Does B have a location spec? */ -static int +static bool breakpoint_location_spec_empty_p (const struct breakpoint *b) { return (b->locspec != nullptr && b->locspec->empty_p ()); @@ -4144,7 +4144,7 @@ breakpoint_init_inferior (enum inf_context context) enum breakpoint_here breakpoint_here_p (const address_space *aspace, CORE_ADDR pc) { - int any_breakpoint_here = 0; + bool any_breakpoint_here = false; for (bp_location *bl : all_bp_locations ()) { @@ -4164,7 +4164,7 @@ breakpoint_here_p (const address_space *aspace, CORE_ADDR pc) else if (bl->permanent) return permanent_breakpoint_here; else - any_breakpoint_here = 1; + any_breakpoint_here = true; } } @@ -4218,7 +4218,7 @@ moribund_breakpoint_here_p (const address_space *aspace, CORE_ADDR pc) /* Returns non-zero iff BL is inserted at PC, in address space ASPACE. */ -static int +static bool bp_location_inserted_here_p (const struct bp_location *bl, const address_space *aspace, CORE_ADDR pc) { @@ -4226,14 +4226,12 @@ bp_location_inserted_here_p (const struct bp_location *bl, && breakpoint_address_match (bl->pspace->aspace, bl->address, aspace, pc)) { - if (overlay_debugging - && section_is_overlay (bl->section) - && !section_is_mapped (bl->section)) - return 0; /* unmapped overlay -- can't be a match */ - else - return 1; + /* An unmapped overlay can't be a match. */ + return !(overlay_debugging + && section_is_overlay (bl->section) + && !section_is_mapped (bl->section)); } - return 0; + return false; } /* Returns non-zero iff there's a breakpoint inserted at PC. */ @@ -4496,10 +4494,10 @@ breakpoint_about_to_proceed (void) breakpoint_proceeded = 1; } -/* Return non-zero iff CMD as the first line of a command sequence is `silent' +/* Return true iff CMD as the first line of a command sequence is `silent' or its equivalent. */ -static int +static bool command_line_is_silent (struct command_line *cmd) { return cmd && (strcmp ("silent", cmd->line) == 0); @@ -4514,16 +4512,16 @@ command_line_is_silent (struct command_line *cmd) case, it is the caller's responsibility to recall it again with the bpstat of the current thread. */ -static int +static bool bpstat_do_actions_1 (bpstat **bsp) { bpstat *bs; - int again = 0; + bool again = false; /* Avoid endless recursion if a `source' command is contained in bs->commands. */ if (executing_breakpoint_commands) - return 0; + return false; scoped_restore save_executing = make_scoped_restore (&executing_breakpoint_commands, 1); @@ -4589,7 +4587,7 @@ bpstat_do_actions_1 (bpstat **bsp) command, and can easily blow up GDB stack. Instead, we return true, which will trigger the caller to recall us with the new stop_bpstat. */ - again = 1; + again = true; break; } } @@ -4964,7 +4962,7 @@ watchpoint_check (bpstat *bs) { struct watchpoint *b; struct frame_info *fr; - int within_current_scope; + bool within_current_scope; /* BS is built from an existing struct breakpoint. */ gdb_assert (bs->breakpoint_at != NULL); @@ -4977,7 +4975,7 @@ watchpoint_check (bpstat *bs) return WP_IGNORE; if (b->exp_valid_block == NULL) - within_current_scope = 1; + within_current_scope = true; else { struct frame_info *frame = get_current_frame (); @@ -5008,7 +5006,7 @@ watchpoint_check (bpstat *bs) function = get_frame_function (fr); if (function == NULL || !contained_in (b->exp_valid_block, function->value_block ())) - within_current_scope = 0; + within_current_scope = false; } if (within_current_scope) @@ -5104,7 +5102,7 @@ watchpoint_check (bpstat *bs) breakpoint location BL. This function does not check if we should stop, only if BL explains the stop. */ -static int +static bool bpstat_check_location (const struct bp_location *bl, const address_space *aspace, CORE_ADDR bp_addr, const target_waitstatus &ws) @@ -5133,24 +5131,24 @@ bpstat_check_watchpoint (bpstat *bs) gdb_assert (b != NULL); { - int must_check_value = 0; - + bool must_check_value = false; + if (b->type == bp_watchpoint) /* For a software watchpoint, we must always check the watched value. */ - must_check_value = 1; + must_check_value = true; else if (b->watchpoint_triggered == watch_triggered_yes) /* We have a hardware watchpoint (read, write, or access) and the target earlier reported an address watched by this watchpoint. */ - must_check_value = 1; + must_check_value = true; else if (b->watchpoint_triggered == watch_triggered_unknown && b->type == bp_hardware_watchpoint) /* We were stopped by a hardware watchpoint, but the target could not report the data address. We must check the watchpoint's value. Access and read watchpoints are out of luck; without a data address, we can't figure it out. */ - must_check_value = 1; + must_check_value = true; if (must_check_value) { @@ -5272,7 +5270,7 @@ bpstat_check_watchpoint (bpstat *bs) break; } } - else /* must_check_value == 0 */ + else /* !must_check_value */ { /* This is a case where some watchpoint(s) triggered, but not at the address of this watchpoint, or else no @@ -5342,7 +5340,7 @@ bpstat_check_breakpoint_conditions (bpstat *bs, thread_info *thread) if (cond && b->disposition != disp_del_at_next_stop) { - int within_current_scope = 1; + bool within_current_scope = true; struct watchpoint * w; /* We use value_mark and value_free_to_mark because it could @@ -5387,7 +5385,7 @@ bpstat_check_breakpoint_conditions (bpstat *bs, thread_info *thread) if (frame != NULL) select_frame (frame); else - within_current_scope = 0; + within_current_scope = false; } if (within_current_scope) { @@ -5429,7 +5427,7 @@ bpstat_check_breakpoint_conditions (bpstat *bs, thread_info *thread) /* Returns true if we need to track moribund locations of LOC's type on the current target. */ -static int +static bool need_moribund_for_location_type (const struct bp_location *loc) { return ((loc->loc_type == bp_loc_software_breakpoint @@ -5611,7 +5609,7 @@ bpstat_stop_status (const address_space *aspace, { struct watchpoint *w = (struct watchpoint *) bs->breakpoint_at; - update_watchpoint (w, 0 /* don't reparse. */); + update_watchpoint (w, false /* don't reparse. */); need_remove_insert = 1; } @@ -6172,8 +6170,8 @@ print_one_breakpoint_location (struct breakpoint *b, static char bpenables[] = "nynny"; struct ui_out *uiout = current_uiout; - int header_of_multiple = 0; - int part_of_multiple = (loc != NULL); + bool header_of_multiple = false; + bool part_of_multiple = (loc != NULL); struct value_print_options opts; get_user_print_options (&opts); @@ -6185,7 +6183,7 @@ print_one_breakpoint_location (struct breakpoint *b, && (b->loc != NULL && (b->loc->next != NULL || !b->loc->enabled || b->loc->disabled_by_cond))) - header_of_multiple = 1; + header_of_multiple = true; if (loc == NULL) loc = b->loc; @@ -6844,7 +6842,7 @@ maintenance_info_breakpoints (const char *args, int from_tty) default_collect_info (); } -static int +static bool breakpoint_has_pc (struct breakpoint *b, struct program_space *pspace, CORE_ADDR pc, struct obj_section *section) @@ -6854,9 +6852,9 @@ breakpoint_has_pc (struct breakpoint *b, if (bl->pspace == pspace && bl->address == pc && (!overlay_debugging || bl->section == section)) - return 1; + return true; } - return 0; + return false; } /* See breakpoint.h. */ @@ -6922,7 +6920,7 @@ bl_address_is_meaningful (bp_location *loc) /* Assuming LOC1 and LOC2's owners are hardware watchpoints, returns true if LOC1 and LOC2 represent the same watchpoint location. */ -static int +static bool watchpoint_locations_match (const struct bp_location *loc1, const struct bp_location *loc2) { @@ -6949,7 +6947,7 @@ watchpoint_locations_match (const struct bp_location *loc1, loc2->length, loc2->watchpoint_type, w2->cond_exp.get ()))) - return 0; + return false; /* Note that this checks the owner's type, not the location's. In case the target does not support read watchpoints, but does @@ -6979,7 +6977,7 @@ breakpoint_address_match (const address_space *aspace1, CORE_ADDR addr1, matches ASPACE2. On targets that have global breakpoints, the address space doesn't really matter. */ -static int +static bool breakpoint_address_match_range (const address_space *aspace1, CORE_ADDR addr1, int len1, const address_space *aspace2, @@ -6995,7 +6993,7 @@ breakpoint_address_match_range (const address_space *aspace1, matches the breakpoint's address space. On targets that have global breakpoints, the address space doesn't really matter. */ -static int +static bool breakpoint_location_address_match (struct bp_location *bl, const address_space *aspace, CORE_ADDR addr) @@ -7014,7 +7012,7 @@ breakpoint_location_address_match (struct bp_location *bl, space. On targets that have global breakpoints, the address space doesn't really matter. */ -static int +static bool breakpoint_location_address_range_overlap (struct bp_location *bl, const address_space *aspace, CORE_ADDR addr, int len) @@ -7034,7 +7032,7 @@ breakpoint_location_address_range_overlap (struct bp_location *bl, Then, if LOC1 and LOC2 represent the same tracepoint location, returns true, otherwise returns false. */ -static int +static bool tracepoint_locations_match (const struct bp_location *loc1, const struct bp_location *loc2) { @@ -7044,7 +7042,7 @@ tracepoint_locations_match (const struct bp_location *loc1, different locations. */ return (loc1->address == loc2->address && loc1->owner == loc2->owner); else - return 0; + return false; } /* Assuming LOC1 and LOC2's types' have meaningful target addresses @@ -7053,7 +7051,7 @@ tracepoint_locations_match (const struct bp_location *loc1, breakpoint locations and hardware breakpoint locations match, otherwise they don't. */ -static int +static bool breakpoint_locations_match (const struct bp_location *loc1, const struct bp_location *loc2, bool sw_hw_bps_match) @@ -7068,7 +7066,7 @@ breakpoint_locations_match (const struct bp_location *loc1, hw_point2 = is_hardware_watchpoint (loc2->owner); if (hw_point1 != hw_point2) - return 0; + return false; else if (hw_point1) return watchpoint_locations_match (loc1, loc2); else if (is_tracepoint (loc1->owner) || is_tracepoint (loc2->owner)) @@ -7085,7 +7083,7 @@ breakpoint_locations_match (const struct bp_location *loc1, static void breakpoint_adjustment_warning (CORE_ADDR from_addr, CORE_ADDR to_addr, - int bnum, int have_bnum) + int bnum, bool have_bnum) { /* The longest string possibly returned by hex_string_custom is 50 chars. These must be at least that big for safety. */ @@ -7157,7 +7155,7 @@ adjust_breakpoint_address (struct gdbarch *gdbarch, a user's expectations. Print a warning if an adjustment is required. */ if (adjusted_bpaddr != bpaddr) - breakpoint_adjustment_warning (bpaddr, adjusted_bpaddr, 0, 0); + breakpoint_adjustment_warning (bpaddr, adjusted_bpaddr, 0, false); return adjusted_bpaddr; } @@ -7667,7 +7665,7 @@ disable_breakpoints_in_shlibs (void) static void disable_breakpoints_in_unloaded_shlib (struct so_list *solib) { - int disabled_shlib_breaks = 0; + bool disabled_shlib_breaks = false; for (bp_location *loc : all_bp_locations ()) { @@ -7700,7 +7698,7 @@ disable_breakpoints_in_unloaded_shlib (struct so_list *solib) "for unloaded shared library \"%s\""), solib->so_name); } - disabled_shlib_breaks = 1; + disabled_shlib_breaks = true; } } } @@ -7732,7 +7730,7 @@ disable_breakpoints_in_freed_objfile (struct objfile *objfile) for (breakpoint *b : all_breakpoints ()) { - int bp_modified = 0; + bool bp_modified = false; if (!is_breakpoint (b) && !is_tracepoint (b)) continue; @@ -7766,7 +7764,7 @@ disable_breakpoints_in_freed_objfile (struct objfile *objfile) mark_breakpoint_location_modified (loc); - bp_modified = 1; + bp_modified = true; } } @@ -8802,7 +8800,7 @@ create_breakpoint (struct gdbarch *gdbarch, unsigned flags) { struct linespec_result canonical; - int pending = 0; + bool pending = false; int task = 0; int prev_bkpt_count = breakpoint_count; @@ -8841,7 +8839,7 @@ create_breakpoint (struct gdbarch *gdbarch, a pending breakpoint and selected yes, or pending breakpoint behavior is on and thus a pending breakpoint is defaulted on behalf of the user. */ - pending = 1; + pending = true; } else throw; @@ -9435,7 +9433,7 @@ watchpoint::re_set () Don't do anything about disabled watchpoints, since they will be reevaluated again when enabled. */ - update_watchpoint (this, 1 /* reparse */); + update_watchpoint (this, true /* reparse */); } /* Implement the "insert" method for hardware watchpoints. */ @@ -10178,7 +10176,7 @@ watch_command_1 (const char *arg, int accessflag, int from_tty, /* Finally update the new watchpoint. This creates the locations that should be inserted. */ - update_watchpoint (w.get (), 1); + update_watchpoint (w.get (), true /* reparse */); install_breakpoint (internal, std::move (w), 1); } @@ -10829,7 +10827,7 @@ download_tracepoint_locations (void) for (breakpoint *b : all_tracepoints ()) { struct tracepoint *t; - int bp_location_downloaded = 0; + bool bp_location_downloaded = false; if ((b->type == bp_fast_tracepoint ? !may_insert_fast_tracepoints @@ -10860,7 +10858,7 @@ download_tracepoint_locations (void) target_download_tracepoint (bl); bl->inserted = 1; - bp_location_downloaded = 1; + bp_location_downloaded = true; } t = (struct tracepoint *) b; t->number_on_target = b->number; @@ -11004,10 +11002,10 @@ update_global_location_list (enum ugll_insert_mode insert_mode) { /* Tells if 'old_loc' is found among the new locations. If not, we have to free it. */ - int found_object = 0; + bool found_object = false; /* Tells if the location should remain inserted in the target. */ - int keep_in_target = 0; - int removed = 0; + bool keep_in_target = false; + bool removed = false; /* Skip LOCP entries which will definitely never be needed. Stop either at or being the one matching OLD_LOC. */ @@ -11033,7 +11031,7 @@ update_global_location_list (enum ugll_insert_mode insert_mode) } if (bp_locations[loc2_i] == old_loc) - found_object = 1; + found_object = true; } /* We have already handled this address, update it so that we don't @@ -11059,7 +11057,7 @@ update_global_location_list (enum ugll_insert_mode insert_mode) { /* The location is still present in the location list, and still should be inserted. Don't do anything. */ - keep_in_target = 1; + keep_in_target = true; } else { @@ -11102,7 +11100,7 @@ update_global_location_list (enum ugll_insert_mode insert_mode) if (unduplicated_should_be_inserted (loc2)) { swap_insertion (old_loc, loc2); - keep_in_target = 1; + keep_in_target = true; break; } } @@ -11126,7 +11124,7 @@ update_global_location_list (enum ugll_insert_mode insert_mode) "breakpoint %d\n"), old_loc->owner->number); } - removed = 1; + removed = true; } } @@ -11600,7 +11598,7 @@ ordinary_breakpoint::print_it (const bpstat *bs) const if (bl->address != bl->requested_address) breakpoint_adjustment_warning (bl->requested_address, bl->address, - number, 1); + number, true); annotate_breakpoint (number); maybe_print_thread_hit_breakpoint (uiout); @@ -12082,7 +12080,7 @@ static struct breakpoint_ops strace_marker_breakpoint_ops = strace_marker_create_breakpoints_sal, }; -static int +static bool strace_marker_p (struct breakpoint *b) { return b->type == bp_static_marker_tracepoint; @@ -12254,7 +12252,7 @@ delete_command (const char *arg, int from_tty) PSPACE is NULL, all locations of all program spaces are considered. */ -static int +static bool all_locations_are_pending (struct breakpoint *b, struct program_space *pspace) { for (bp_location *loc : b->locations ()) @@ -12262,15 +12260,15 @@ all_locations_are_pending (struct breakpoint *b, struct program_space *pspace) || loc->pspace == pspace) && !loc->shlib_disabled && !loc->pspace->executing_startup) - return 0; - return 1; + return false; + return true; } /* Subroutine of update_breakpoint_locations to simplify it. - Return non-zero if multiple fns in list LOC have the same name. + Return true if multiple fns in list LOC have the same name. Null names are ignored. */ -static int +static bool ambiguous_names_p (struct bp_location *loc) { struct bp_location *l; @@ -12291,11 +12289,11 @@ ambiguous_names_p (struct bp_location *loc) /* NOTE: We can assume slot != NULL here because xcalloc never returns NULL. */ if (*slot != NULL) - return 1; + return true; *slot = name; } - return 0; + return false; } /* When symbols change, it probably means the sources changed as well, @@ -12422,34 +12420,34 @@ update_static_tracepoint (struct breakpoint *b, struct symtab_and_line sal) return sal; } -/* Returns 1 iff locations A and B are sufficiently same that +/* Returns true iff locations A and B are sufficiently same that we don't need to report breakpoint as changed. */ -static int +static bool locations_are_equal (struct bp_location *a, struct bp_location *b) { while (a && b) { if (a->address != b->address) - return 0; + return false; if (a->shlib_disabled != b->shlib_disabled) - return 0; + return false; if (a->enabled != b->enabled) - return 0; + return false; if (a->disabled_by_cond != b->disabled_by_cond) - return 0; + return false; a = a->next; b = b->next; } if ((a == NULL) != (b == NULL)) - return 0; + return false; - return 1; + return true; } /* Split all locations of B that are bound to PSPACE out of B's @@ -12634,7 +12632,7 @@ code_breakpoint::location_spec_to_sals (location_spec *locspec, } catch (gdb_exception_error &e) { - int not_found_and_ok = 0; + int not_found_and_ok = false; /* For pending breakpoints, it's expected that parsing will fail until the right shared library is loaded. User has @@ -12651,7 +12649,7 @@ code_breakpoint::location_spec_to_sals (location_spec *locspec, || (loc && loc->shlib_disabled) || (loc && loc->pspace->executing_startup) || enable_state == bp_disabled)) - not_found_and_ok = 1; + not_found_and_ok = true; if (!not_found_and_ok) { @@ -13336,7 +13334,7 @@ enable_breakpoint_disp (struct breakpoint *bpt, enum bpdisp disposition, orig_enable_state = bpt->enable_state; bpt->enable_state = bp_enabled; - update_watchpoint (w, 1 /* reparse */); + update_watchpoint (w, true /* reparse */); } catch (const gdb_exception &e) { @@ -13977,7 +13975,7 @@ static void save_breakpoints (const char *filename, int from_tty, bool (*filter) (const struct breakpoint *)) { - int any = 0; + bool any = false; int extra_trace_bits = 0; if (filename == 0 || *filename == 0) @@ -13994,7 +13992,7 @@ save_breakpoints (const char *filename, int from_tty, if (filter && !filter (tp)) continue; - any = 1; + any = true; if (is_tracepoint (tp)) { @@ -14182,18 +14180,15 @@ add_catch_command (const char *name, const char *docstring, set_cmd_completer (command, completer); } -/* Zero if any of the breakpoint's locations could be a location where - functions have been inlined, nonzero otherwise. */ +/* False if any of the breakpoint's locations could be a location where + functions have been inlined, true otherwise. */ -static int +static bool is_non_inline_function (struct breakpoint *b) { /* The shared library event breakpoint is set on the address of a non-inline function. */ - if (b->type == bp_shlib_event) - return 1; - - return 0; + return (b->type == bp_shlib_event); } /* Nonzero if the specified PC cannot be a location where functions