From: Yao Qi <yao@codesourcery.com>
To: <gdb-patches@sourceware.org>
Subject: [PATCH 3/3] Fix fail in mi-var-child.exp and mi-var-display.exp
Date: Mon, 01 Sep 2014 01:04:00 -0000 [thread overview]
Message-ID: <1409533072-6152-4-git-send-email-yao@codesourcery.com> (raw)
In-Reply-To: <1409533072-6152-1-git-send-email-yao@codesourcery.com>
Hi,
I see the following fails on arm-none-eabi target,
-var-list-children --simple-values struct_declarations ^M
^done,numchild="11",children=[...,child={name="struct_declarations.func_ptr_struct",exp="func_ptr_struct",numchild="0",value="0x0 <_ftext>",type="struct _struct_decl (*)(int, char *, long)",thread-id="1"},child={name="struct_declarations.func_ptr_ptr",exp="func_ptr_ptr",numchild="0",value="0x0 <_ftext>",type="struct _struct_decl *(*)(int, char *, long)",thread-id="1"},...
(gdb) ^M
FAIL: gdb.mi/mi-var-child.exp: listing of children, simple types: names, type and values, complex types: names and types
-var-set-format weird.func_ptr_ptr natural^M
^done,format="natural",value="0x0 <_ftext>"^M
(gdb) ^M
FAIL: gdb.mi/mi-var-display.exp: set format variable weird.func_ptr_ptr in natural
In the test, "0x0" is expected, but "0x0 <_ftext>" is in the output.
Function pointers point to address zero, and tests assume there is no
symbol on address zero. However, on my arm-none-eabi target, there is
a code symbol _ftext on address zero, and test fails. Note that "set
print symbol off" doesn't take effect for function pointer.
int (*f) (void);
f = main;
(gdb) p f
$1 = (int (*)(void)) 0x8048400 <main>
(gdb) set print symbol off
(gdb) p f
$2 = (int (*)(void)) 0x8048400 <main>
In order to erase the difference, we can assign some function address
explicitly to function pointer, so the test behaves in a unique way.
In this patch, we assign nothing1 and nothing2 to function pointers
func_ptr_struct and func_ptr_ptr respectively, and update test as the
source file is changed.
gdb/testsuite:
2014-09-01 Yao Qi <yao@codesourcery.com>
* gdb.mi/mi-var-child.c (nothing1): New function.
(nothing2): New function.
(do_children_tests): Set function pointers by nothing1 and
nothing2.
* gdb.mi/mi-var-child.exp: Step over new added statements.
Update test to match the new output.
* gdb.mi/var-cmd.c (nothing1): New function.
(nothing2): New function.
(do_children_tests): Set function pointers by nothing1 and
nothing2.
* gdb.mi/mi-var-display.exp: Update test to match output.
Step to the line specified by $line_dct_nothing.
Increase the number of lines to step.
---
gdb/testsuite/gdb.mi/mi-var-child.c | 16 ++++++++++++++++
gdb/testsuite/gdb.mi/mi-var-child.exp | 22 +++++++++++++++++-----
gdb/testsuite/gdb.mi/mi-var-display.exp | 2 +-
gdb/testsuite/gdb.mi/mi2-var-child.exp | 7 +++----
gdb/testsuite/gdb.mi/var-cmd.c | 16 ++++++++++++++++
5 files changed, 53 insertions(+), 10 deletions(-)
diff --git a/gdb/testsuite/gdb.mi/mi-var-child.c b/gdb/testsuite/gdb.mi/mi-var-child.c
index bde668e..689fe55 100644
--- a/gdb/testsuite/gdb.mi/mi-var-child.c
+++ b/gdb/testsuite/gdb.mi/mi-var-child.c
@@ -160,6 +160,20 @@ nothing ()
{
}
+struct _struct_decl
+nothing1 (int a, char *b, long c)
+{
+ struct _struct_decl foo;
+
+ return foo;
+}
+
+struct _struct_decl *
+nothing2 (int a, char *b, long c)
+{
+ return (struct _struct_decl *) 0;
+}
+
void
subroutine1 (int i, long *l)
{
@@ -231,6 +245,8 @@ do_children_tests (void)
struct_declarations.long_array[9] = 1234;
weird->func_ptr = nothing;
+ weird->func_ptr_struct = nothing1;
+ weird->func_ptr_ptr = nothing2;
struct_declarations.long_array[10] = 3456;
struct_declarations.long_array[11] = 5678;
diff --git a/gdb/testsuite/gdb.mi/mi-var-child.exp b/gdb/testsuite/gdb.mi/mi-var-child.exp
index 1f547ba..88be094 100644
--- a/gdb/testsuite/gdb.mi/mi-var-child.exp
+++ b/gdb/testsuite/gdb.mi/mi-var-child.exp
@@ -766,9 +766,21 @@ mi_step_to do_children_tests {} ".*${srcfile}" \
mi_varobj_update * {struct_declarations.func_ptr} \
"update all vars struct_declarations.func_ptr changed"
-# Step over "struct_declarations.long_array[10] = 3456";
+# Step over "weird->func_ptr_struct = nothing1"
mi_step_to do_children_tests {} ".*${srcfile}" \
[expr $line_dct_nothing + 2] "step \$line_dct_nothing + 2"
+mi_varobj_update * {struct_declarations.func_ptr_struct} \
+ "update all vars struct_declarations.func_ptr_struct changed"
+
+# Step over "weird->func_ptr_ptr = nothing2"
+mi_step_to do_children_tests {} ".*${srcfile}" \
+ [expr $line_dct_nothing + 3] "step \$line_dct_nothing + 3"
+mi_varobj_update * {struct_declarations.func_ptr_ptr} \
+ "update all vars struct_declarations.func_ptr_ptr changed"
+
+# Step over "struct_declarations.long_array[10] = 3456";
+mi_step_to do_children_tests {} ".*${srcfile}" \
+ [expr $line_dct_nothing + 4] "step \$line_dct_nothing + 4"
mi_gdb_test "-var-update --no-values *" \
"\\^done,changelist=\\\[\{name=\"struct_declarations.long_array.10\",in_scope=\"true\",type_changed=\"false\",has_more=\"0\"\}\\\]" \
@@ -807,10 +819,10 @@ mi_list_varobj_children {struct_declarations --simple-values} \
[list struct_declarations.int_ptr_ptr int_ptr_ptr 1 "int \\*\\*" "$hex"] \
{struct_declarations.long_array long_array 12 "long \\[12\\]"} \
[list struct_declarations.func_ptr func_ptr 0 "void \\(\\*\\)\\((void)?\\)" "(@$hex: |)$hex <nothing>"] \
- {struct_declarations.func_ptr_struct func_ptr_struct 0 \
- "struct _struct_decl \\(\\*\\)(\\(int, char \\*, long\\))?" 0x0} \
- {struct_declarations.func_ptr_ptr func_ptr_ptr 0 \
- "struct _struct_decl \\*\\(\\*\\)\\((int, char \\*, long)?\\)" 0x0} \
+ [list struct_declarations.func_ptr_struct func_ptr_struct 0 \
+ "struct _struct_decl \\(\\*\\)(\\(int, char \\*, long\\))?" "$hex <nothing1>"] \
+ [list struct_declarations.func_ptr_ptr func_ptr_ptr 0 \
+ "struct _struct_decl \\*\\(\\*\\)\\((int, char \\*, long)?\\)" "$hex <nothing2>"] \
{struct_declarations.u1 u1 4 "union \\{\\.\\.\\.\\}"} \
{struct_declarations.s2 s2 4 "struct \\{\\.\\.\\.\\}"} \
] "listing of children, simple types: names, type and values, complex types: names and types"
diff --git a/gdb/testsuite/gdb.mi/mi-var-display.exp b/gdb/testsuite/gdb.mi/mi-var-display.exp
index 02c2212..9f0ade5 100644
--- a/gdb/testsuite/gdb.mi/mi-var-display.exp
+++ b/gdb/testsuite/gdb.mi/mi-var-display.exp
@@ -290,7 +290,7 @@ mi_gdb_test "-var-set-format weird.func_ptr_struct hexadecimal" \
"set format variable weird.func_ptr_struct"
mi_gdb_test "-var-set-format weird.func_ptr_ptr natural" \
- "\\^done,format=\"natural\",value=\"0x0\"" \
+ "\\^done,format=\"natural\",value=\"$hex <nothing2>\"" \
"set format variable weird.func_ptr_ptr in natural"
mi_gdb_test "-var-set-format weird.u1 natural" \
diff --git a/gdb/testsuite/gdb.mi/mi2-var-child.exp b/gdb/testsuite/gdb.mi/mi2-var-child.exp
index 6ae3e0c..fffc1f1 100644
--- a/gdb/testsuite/gdb.mi/mi2-var-child.exp
+++ b/gdb/testsuite/gdb.mi/mi2-var-child.exp
@@ -759,9 +759,8 @@ mi_varobj_update * {struct_declarations.long_array.3
# Step over "weird->func_ptr = nothing;"
-set line_dct_a0_0 [gdb_get_line_number "a0\[0\] = '0';"]
-mi_step_to do_children_tests {} {.*var-cmd.c} \
- $line_dct_a0_0 "step \$line_dct_a0_0"
+mi_step_to do_children_tests {} ".*${srcfile}" \
+ [expr $line_dct_nothing + 1] "step \$line_dct_nothing + 1"
# Test: c_variable-5.9
# Desc: check that func_ptr changed
@@ -782,7 +781,7 @@ mi_gdb_test "-var-delete weird->int_ptr_ptr" \
# psnp = &snp0;
set line_dct_snp0 [gdb_get_line_number "psnp = &snp0;"]
-mi_execute_to "exec-step 43" "end-stepping-range" do_children_tests {} {.*var-cmd.c} \
+mi_execute_to "exec-step 45" "end-stepping-range" do_children_tests {} {.*var-cmd.c} \
[expr $line_dct_snp0 + 1] {} "step \$line_dct_snp0 + 1"
# Test: c_variable-5.10
diff --git a/gdb/testsuite/gdb.mi/var-cmd.c b/gdb/testsuite/gdb.mi/var-cmd.c
index 4bb2746..bbfbc34 100644
--- a/gdb/testsuite/gdb.mi/var-cmd.c
+++ b/gdb/testsuite/gdb.mi/var-cmd.c
@@ -182,6 +182,20 @@ nothing ()
{
}
+struct _struct_decl
+nothing1 (int a, char *b, long c)
+{
+ struct _struct_decl foo;
+
+ return foo;
+}
+
+struct _struct_decl *
+nothing2 (int a, char *b, long c)
+{
+ return (struct _struct_decl *) 0;
+}
+
void
subroutine1 (int i, long *l)
{
@@ -253,6 +267,8 @@ do_children_tests (void)
struct_declarations.long_array[9] = 1234;
weird->func_ptr = nothing;
+ weird->func_ptr_struct = nothing1;
+ weird->func_ptr_ptr = nothing2;
/* Struct/pointer/array tests */
a0[0] = '0';
--
1.9.3
next prev parent reply other threads:[~2014-09-01 1:04 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-09-01 1:02 [PATCH 0/3] Fix fails in gdb.mi on arm-none-eabi Yao Qi
2014-09-01 1:03 ` [PATCH 1/3] Set print symbol off in mi-var-display.exp Yao Qi
2014-09-09 2:12 ` Yao Qi
2014-09-01 1:03 ` [PATCH 2/3] Use mi_varobj_update in mi-var-child.exp and mi2-var-child.exp Yao Qi
2014-10-14 11:48 ` Yao Qi
2014-09-01 1:04 ` Yao Qi [this message]
2014-10-14 11:49 ` [PATCH 3/3] Fix fail in mi-var-child.exp and mi-var-display.exp Yao Qi
2014-09-18 1:05 ` [PATCH 0/3] Fix fails in gdb.mi on arm-none-eabi Yao Qi
2014-09-30 14:04 ` Yao Qi
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=1409533072-6152-4-git-send-email-yao@codesourcery.com \
--to=yao@codesourcery.com \
--cc=gdb-patches@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).