From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 521FE386EC78 for ; Wed, 23 Mar 2022 12:00:06 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 521FE386EC78 Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-256-w1_PitSuP8KXsQemh5GRcw-1; Wed, 23 Mar 2022 08:00:04 -0400 X-MC-Unique: w1_PitSuP8KXsQemh5GRcw-1 Received: by mail-wm1-f69.google.com with SMTP id 9-20020a05600c240900b0038c99b98f6fso543060wmp.0 for ; Wed, 23 Mar 2022 05:00:04 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=MRpHDjtWf1g6jBYPSTn1PGmORS4lzKcnrcXltSEmF8M=; b=JY0EWZKQel09Vp+e58LKxDf4t+iCxC9Hvpo00DF/V/b5kv9lSoNRpIUlv25tVOfgee KBEhr34q6MccvEw1CHevIzVJOiSLgWhXzinbCRgebeDImN2MrVzjo/+q8kgu70B1ABkf EC/8vdj6j2kNKZRl+lKBtcWDTp+6PRC8t6n7F4+I+LidwXFJ5eRWXP059gy002lO+VCB p6ms5HGGiHy4UqDnQ6AgyghH8gKmfZh6RllaPIYXOjhcKosr+whmJk402tImLVePmxXM m9byCv0Mea0morGN5yrvhWGdDZwAH+2YyappkG+siOSaP52ja1KSW30MNi0JSS1UANu7 vHOw== X-Gm-Message-State: AOAM532s4+k7oZB00XI12qZBv9LXI4gYBOV3LKA6fz4oMLgyBQCBOvbL SaCbaP38/fOGCUcDTH7NyAzNZGaAGthrkDyWJe0s1ftS/man8C7/lEH2i2OHtRaSIfRrsxKbZ55 /gj6CgeKhCDXWUS/w//tsEb+co7t9V28nSHFxVdHinABxyLYiSoj/3jlfEGY/pKabf2jUCgc75g == X-Received: by 2002:adf:a4ce:0:b0:203:fcdb:9d2d with SMTP id h14-20020adfa4ce000000b00203fcdb9d2dmr18943255wrb.191.1648036803414; Wed, 23 Mar 2022 05:00:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy1hmRjLl++Z5mzXqGbYq1yRoP+2MoMu8VuWYR/z/mOOWrT5ouyVbtaG9o6kl4RDYJCNaHZpA== X-Received: by 2002:adf:a4ce:0:b0:203:fcdb:9d2d with SMTP id h14-20020adfa4ce000000b00203fcdb9d2dmr18943231wrb.191.1648036803148; Wed, 23 Mar 2022 05:00:03 -0700 (PDT) Received: from localhost (host109-158-45-15.range109-158.btcentralplus.com. [109.158.45.15]) by smtp.gmail.com with ESMTPSA id q8-20020a056000136800b00203e740c7desm15771758wrz.71.2022.03.23.05.00.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Mar 2022 05:00:02 -0700 (PDT) From: Andrew Burgess To: gdb-patches@sourceware.org Cc: Andrew Burgess Subject: [PATCH 1/3] gdb: small simplification in dwarf2_locexpr_baton_eval Date: Wed, 23 Mar 2022 11:59:56 +0000 Message-Id: X-Mailer: git-send-email 2.25.4 In-Reply-To: References: <20220323115809.GT1212730@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true X-Spam-Status: No, score=-12.3 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, RCVD_IN_MSPIKE_H5, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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-List-Received-Date: Wed, 23 Mar 2022 12:00:07 -0000 While examining the dwarf expression evaluator, I noticed that in dwarf2_locexpr_baton_eval, whenever push_initial_value is true, the addr_stack will never be nullptr. This allows for a small cleanup, replacing an if/then/else with an assertion. There should be no user visible changes after this commit. --- gdb/dwarf2/loc.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/gdb/dwarf2/loc.c b/gdb/dwarf2/loc.c index d7863841a69..4c3d04b3226 100644 --- a/gdb/dwarf2/loc.c +++ b/gdb/dwarf2/loc.c @@ -1535,11 +1535,13 @@ dwarf2_evaluate_loc_desc (struct type *type, struct frame_info *frame, CORE_ADDR. FRAME is the frame in which the expression is evaluated. ADDR_STACK is a context (location of a variable) and might be needed to evaluate the location expression. - PUSH_INITIAL_VALUE is true if the address (either from ADDR_STACK, - or the default of 0) should be pushed on the DWARF expression - evaluation stack before evaluating the expression; this is required - by certain forms of DWARF expression. Returns 1 on success, 0 - otherwise. */ + + PUSH_INITIAL_VALUE is true if the first address from ADDR_STACK, should + be pushed on the DWARF expression evaluation stack before evaluating the + expression; this is required by certain forms of DWARF expression. When + PUSH_INITIAL_VALUE is true ADDR_STACK can't be nullptr. + + Returns 1 on success, 0 otherwise. */ static int dwarf2_locexpr_baton_eval (const struct dwarf2_locexpr_baton *dlbaton, @@ -1561,10 +1563,8 @@ dwarf2_locexpr_baton_eval (const struct dwarf2_locexpr_baton *dlbaton, if (push_initial_value) { - if (addr_stack != nullptr) - ctx.push_address (addr_stack->addr, false); - else - ctx.push_address (0, false); + gdb_assert (addr_stack != nullptr); + ctx.push_address (addr_stack->addr, false); } try -- 2.25.4