public inbox for gdb-cvs@sourceware.org
help / color / mirror / Atom feed
From: Tom de Vries <vries@sourceware.org>
To: gdb-cvs@sourceware.org
Subject: [binutils-gdb] [gdb/testsuite] Detect change instead of init in gdb.mi/mi-var-block.exp
Date: Thu,  2 Jun 2022 18:40:10 +0000 (GMT)	[thread overview]
Message-ID: <20220602184010.7F1203959CA7@sourceware.org> (raw)

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=bb785a92a88b538831d72e36f2d0fce76e0a32b1

commit bb785a92a88b538831d72e36f2d0fce76e0a32b1
Author: Tom de Vries <tdevries@suse.de>
Date:   Thu Jun 2 20:40:06 2022 +0200

    [gdb/testsuite] Detect change instead of init in gdb.mi/mi-var-block.exp
    
    On openSUSE Tumbleweed with target board unix/-m32, I run into:
    ...
    PASS: gdb.mi/mi-var-block.exp: step at do_block_test 2
    Expecting: ^(-var-update \*[^M
    ]+)?(\^done,changelist=\[{name="foo",in_scope="true",type_changed="false",has_more="0"},
    {name="cb",in_scope="true",type_changed="false",has_more="0"}\][^M
    ]+[(]gdb[)] ^M
    [ ]*)
    -var-update *^M
    ^done,changelist=[{name="foo",in_scope="true",type_changed="false",has_more="0"}]^M
    (gdb) ^M
    FAIL: gdb.mi/mi-var-block.exp: update all vars: cb foo changed (unexpected output)
    ...
    
    The problem is that the test-case attempts to detect a change in the cb
    variable caused by this initialization:
    ...
    void
    do_block_tests ()
    {
      int cb = 12;
    ...
    but that only works if the stack location happens to be unequal to 12 before
    the initialization.
    
    Fix this by first initializing to 0, and then changing the value to 12:
    ...
    -  int cb = 12;
    +  int cb = 0;
    +  cb = 12;
    ...
    and detecting that change.
    
    Tested on x86_64-linux.
    
    Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=29195

Diff:
---
 gdb/testsuite/gdb.mi/mi-var-block.exp | 5 +++++
 gdb/testsuite/gdb.mi/var-cmd.c        | 3 ++-
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/gdb/testsuite/gdb.mi/mi-var-block.exp b/gdb/testsuite/gdb.mi/mi-var-block.exp
index 2f8d39a6acd..a1ef2d1ad52 100644
--- a/gdb/testsuite/gdb.mi/mi-var-block.exp
+++ b/gdb/testsuite/gdb.mi/mi-var-block.exp
@@ -40,6 +40,11 @@ mi_gdb_load ${binfile}
 
 mi_runto do_block_tests
 
+# step to "cb = 12;"
+mi_step_to "do_block_tests" "" "var-cmd.c" \
+    [gdb_get_line_number "cb = 12;"] \
+    "step at do_block_test 0"
+
 # Test: c_variable-3.2
 # Desc: create cb and foo
 mi_create_varobj "cb" "cb" "create local variable cb"
diff --git a/gdb/testsuite/gdb.mi/var-cmd.c b/gdb/testsuite/gdb.mi/var-cmd.c
index fddb0d39a5e..f3312788a80 100644
--- a/gdb/testsuite/gdb.mi/var-cmd.c
+++ b/gdb/testsuite/gdb.mi/var-cmd.c
@@ -207,7 +207,8 @@ subroutine1 (int i, long *l)
 void
 do_block_tests ()
 {
-  int cb = 12;
+  int cb = 0;
+  cb = 12;
 
   {
     int foo;


                 reply	other threads:[~2022-06-02 18:40 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220602184010.7F1203959CA7@sourceware.org \
    --to=vries@sourceware.org \
    --cc=gdb-cvs@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).