This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[PATCH 2/2] Fix gdb.mi/mi-stack.exp when gcc generates a stack protector
- From: Simon Marchi <simon dot marchi at polymtl dot ca>
- To: gdb-patches at sourceware dot org
- Cc: Simon Marchi <simon dot marchi at polymtl dot ca>
- Date: Sat, 16 Dec 2017 09:56:51 -0500
- Subject: [PATCH 2/2] Fix gdb.mi/mi-stack.exp when gcc generates a stack protector
- Authentication-results: sourceware.org; auth=none
- References: <20171216145651.13936-1-simon.marchi@polymtl.ca>
I see some failures in the gdb.mi/mi-stack.exp test. The test runs to
the callee4 function:
int callee4 (void)
{
int A=1;
int B=2;
int C;
int D[3] = {0, 1, 2};
C = A + B;
return 0;
}
and expects to be stopped at the A=1 line. However, when gcc generates
some stack protection code, it will stop at the { instead, as shown by
this disassembly (after I did "break callee4" and "run"):
(gdb) disassemble /s
Dump of assembler code for function callee4:
/home/simark/src/binutils-gdb/gdb/testsuite/gdb.mi/mi-stack.c:
26 {
0x00005555555546ca <+0>: push %rbp
0x00005555555546cb <+1>: mov %rsp,%rbp
0x00005555555546ce <+4>: sub $0x20,%rsp
=> 0x00005555555546d2 <+8>: mov %fs:0x28,%rax
0x00005555555546db <+17>: mov %rax,-0x8(%rbp)
0x00005555555546df <+21>: xor %eax,%eax
27 int A=1; /* callee4 begin */
0x00005555555546e1 <+23>: movl $0x1,-0x20(%rbp)
28 int B=2;
0x00005555555546e8 <+30>: movl $0x2,-0x1c(%rbp)
The rest of the test relies on execution stopping on the A=1, so many things
fail after that. This patch uses mi_continue_to_line instead, to stop at the
A=1 line precisely.
gdb/testsuite/ChangeLog:
* gdb.mi/mi-stack.exp (test_stack_frame_listing): Use
mi_continue_to_line.
* gdb.mi/mi-stack.exp (callee4): Add comment.
---
gdb/testsuite/gdb.mi/mi-stack.c | 2 +-
gdb/testsuite/gdb.mi/mi-stack.exp | 8 ++++----
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/gdb/testsuite/gdb.mi/mi-stack.c b/gdb/testsuite/gdb.mi/mi-stack.c
index 30dce8b9f6..dc239f0e7b 100644
--- a/gdb/testsuite/gdb.mi/mi-stack.c
+++ b/gdb/testsuite/gdb.mi/mi-stack.c
@@ -24,7 +24,7 @@
int callee4 (void)
{
- int A=1;
+ int A=1; /* callee4 begin */
int B=2;
int C;
int D[3] = {0, 1, 2};
diff --git a/gdb/testsuite/gdb.mi/mi-stack.exp b/gdb/testsuite/gdb.mi/mi-stack.exp
index cd7c6d4c38..b88032c73e 100644
--- a/gdb/testsuite/gdb.mi/mi-stack.exp
+++ b/gdb/testsuite/gdb.mi/mi-stack.exp
@@ -46,8 +46,8 @@ proc test_stack_frame_listing {} {
global mi_gdb_prompt
global hex fullname_syntax srcfile
- set line_callee4_head [gdb_get_line_number "callee4 ("]
- set line_callee4_body [expr $line_callee4_head + 2]
+ set callee4_begin [gdb_get_line_number "callee4 begin"]
+ mi_continue_to_line $callee4_begin "continue to callee4 begin"
# Obtain a stack trace
# Tests:
@@ -56,7 +56,7 @@ proc test_stack_frame_listing {} {
# -stack-list-frames 1 3
# -stack-info-frame
mi_gdb_test "231-stack-list-frames" \
- "231\\^done,stack=\\\[frame=\{level=\"0\",addr=\"$hex\",func=\"callee4\",file=\".*${srcfile}\",fullname=\"${fullname_syntax}${srcfile}\",line=\"$line_callee4_body\"\},frame=\{level=\"1\",addr=\"$hex\",func=\"callee3\",.*\},frame=\{level=\"2\",addr=\"$hex\",func=\"callee2\",.*\},frame=\{level=\"3\",addr=\"$hex\",func=\"callee1\",.*\},frame=\{level=\"4\",addr=\"$hex\",func=\"main\",.*\}\\\]" \
+ "231\\^done,stack=\\\[frame=\{level=\"0\",addr=\"$hex\",func=\"callee4\",file=\".*${srcfile}\",fullname=\"${fullname_syntax}${srcfile}\",line=\"$callee4_begin\"\},frame=\{level=\"1\",addr=\"$hex\",func=\"callee3\",.*\},frame=\{level=\"2\",addr=\"$hex\",func=\"callee2\",.*\},frame=\{level=\"3\",addr=\"$hex\",func=\"callee1\",.*\},frame=\{level=\"4\",addr=\"$hex\",func=\"main\",.*\}\\\]" \
"stack frame listing"
mi_gdb_test "232-stack-list-frames 1 1" \
"232\\^done,stack=\\\[frame=\{level=\"1\",addr=\"$hex\",func=\"callee3\",.*\}\\\]" \
@@ -70,7 +70,7 @@ proc test_stack_frame_listing {} {
"stack frame listing wrong"
mi_gdb_test "235-stack-info-frame" \
- "235\\^done,frame=\{level=\"0\",addr=\"$hex\",func=\"callee4\",file=\".*${srcfile}\",fullname=\"${fullname_syntax}${srcfile}\",line=\"$line_callee4_body\"\}" \
+ "235\\^done,frame=\{level=\"0\",addr=\"$hex\",func=\"callee4\",file=\".*${srcfile}\",fullname=\"${fullname_syntax}${srcfile}\",line=\"$callee4_begin\"\}" \
"selected frame listing"
mi_gdb_test "236-stack-list-frames 1 300" \
--
2.15.1