From patchwork Fri Feb 7 14:59:56 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shahab Vahedi X-Patchwork-Id: 37732 Received: (qmail 81563 invoked by alias); 7 Feb 2020 15:01:03 -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 81433 invoked by uid 89); 7 Feb 2020 15:00:56 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, FREEMAIL_FROM, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.1 spammy=Initialise X-HELO: mail-lf1-f67.google.com Received: from mail-lf1-f67.google.com (HELO mail-lf1-f67.google.com) (209.85.167.67) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 07 Feb 2020 15:00:53 +0000 Received: by mail-lf1-f67.google.com with SMTP id b15so1726695lfc.4 for ; Fri, 07 Feb 2020 07:00:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=VDqmbf9Nv/DbljeiYpEdyPsfBVwSOKV232qCYtv7As8=; b=qxk3959V5ZB38eUw3G5R2u0bcyx2Y9GJ1T3dnydEn2dZJRV0OuIf9XG7p9YT2TlGxn 6uTuT6TlKC3PUPSiNPjrwWS4jVdULyE5Rt1S86UjoS7wcGfWwdnMvmdQhoFHZNL4JbWM Di43VvtnAX5VGkUINOuMfR+/pw+7iQoUVyHWq9pIU9klj0YceZQT00/bwS9k9szfTClU 2gSbCvbP9f30Ziom9sZ8AAjjS4q/uPy4+rzcDOawsxrVWNNRnjdtnwpQPv3YvEmxQBBf jd0c6pdzTCjVp9joQPE7jYTy7SWGTI9gK2Furfn458MakC1XG7e9JTTuQ6CVKOpsoY+b ot2g== Return-Path: Received: from archie.internal.synopsys.com ([2a03:1b20:6:f011::2d]) by smtp.gmail.com with ESMTPSA id p136sm1184412lfa.8.2020.02.07.07.00.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Feb 2020 07:00:49 -0800 (PST) From: Shahab Vahedi To: gdb-patches@sourceware.org Cc: Shahab Vahedi , Shahab Vahedi , Francois Bedard , Anton Kolesov Subject: [PATCH 07/14] gdb/testsuite: Fix invalid watchpoint test in mi suite Date: Fri, 7 Feb 2020 15:59:56 +0100 Message-Id: <20200207150003.8383-8-shahab.vahedi@gmail.com> In-Reply-To: <20200207150003.8383-1-shahab.vahedi@gmail.com> References: <20200207150003.8383-1-shahab.vahedi@gmail.com> MIME-Version: 1.0 From: Anton Kolesov GDB's watchpoints are triggered only if expression value has changed, so memory at variable address already contained assigned value - watchpoint is not triggered. Therefore it is not reliable to check watchpoints triggering by checking first assignment - variable might already had that assigned value, so GDB would ignore that new assignment. This can happen in real life when same test case is run over an over again on baremetal - stack addresses for local variables are constant and memory is persistent across runs. So this code: void callee4() { int A = 1; int B = 2; int C; C = A + B; } might trigger watchpoint on C at the first execution, but not on subsequent runs - memory address of C retained value 3 from first execution. Therefore all watchpoint tests must have an initial assignment to some value, so that variable contain a known value, and only then create a watchpoint, so that this watchpoint would trigger reliably. gdb/testsuite/ChangeLog: 2016-07-15 Anton Kolesov Shahab Vahedi * gdb.mi/basics.c (callee4): Initialise "C" to 0. * gdb.mi/mi-cli.exp: Handle the introduced initialisation. Signed-off-by: Anton Kolesov --- gdb/testsuite/gdb.mi/basics.c | 2 +- gdb/testsuite/gdb.mi/mi-cli.exp | 15 +++++++++------ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/gdb/testsuite/gdb.mi/basics.c b/gdb/testsuite/gdb.mi/basics.c index 7e7a74823afa..b3000a8020d3 100644 --- a/gdb/testsuite/gdb.mi/basics.c +++ b/gdb/testsuite/gdb.mi/basics.c @@ -26,7 +26,7 @@ int callee4 (void) { int A=1; int B=2; - int C; + int C=0; C = A + B; return 0; diff --git a/gdb/testsuite/gdb.mi/mi-cli.exp b/gdb/testsuite/gdb.mi/mi-cli.exp index 214cc8a479e6..82f050a83c32 100644 --- a/gdb/testsuite/gdb.mi/mi-cli.exp +++ b/gdb/testsuite/gdb.mi/mi-cli.exp @@ -68,8 +68,9 @@ set line_main_return [expr $line_main_hello + 2] set line_main_callme_2 [expr $line_main_return + 1] set line_callee4_head [gdb_get_line_number "callee4 ("] set line_callee4_body [expr $line_callee4_head + 2] -set line_callee4_next [expr $line_callee4_body + 1] -set line_callee4_next_step [expr $line_callee4_next + 3] +set line_callee4_first_next [expr $line_callee4_body + 1] +set line_callee4_second_next [expr $line_callee4_first_next + 1] +set line_callee4_third_next [expr $line_callee4_second_next + 2] mi_gdb_test "-interpreter-exec console \"set args foobar\"" \ ".*=cmd-param-changed,param=\"args\",value=\"foobar\".*\\^done" \ @@ -136,10 +137,12 @@ mi_gdb_test "500-stack-select-frame 0" \ {500\^done} \ "-stack-select-frame 0" -mi_execute_to "interpreter-exec console step" "end-stepping-range" "callee4" "" ".*basics.c" $line_callee4_next \ +mi_execute_to "interpreter-exec console step" "end-stepping-range" "callee4" "" ".*basics.c" $line_callee4_first_next \ "" "check *stopped from CLI command" -mi_send_resuming_command "exec-step" "-exec-step to line \$line_callee4_next_step" +mi_step_to "callee4" "" ".*basics.c" $line_callee4_second_next "step over B's initialization" + +mi_send_resuming_command "exec-step" "-exec-step to line $line_callee4_third_next" # Test that the new current source line is _not_ output, given we # executed MI's -exec-next, not CLI's 'next' command. @@ -153,8 +156,8 @@ if {[regexp "A + B" "$output"]} { pass $test } -mi_expect_stop "end-stepping-range" "callee4" "" ".*basics.c" $line_callee4_next_step \ - "" "check *stopped from CLI command 2" +mi_expect_stop "end-stepping-range" "callee4" "" ".*basics.c" $line_callee4_third_next \ + "" "check *stopped from CLI command 3" # Test that CLI's "finish" command prints the function's return value # to both the CLI and MI streams, and that the same result variable is