summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Marchi <simon.marchi@polymtl.ca>2018-04-07 14:08:56 -0400
committerSimon Marchi <simon.marchi@polymtl.ca>2018-04-07 14:09:14 -0400
commita0be7a3671e6252c0f3353d128f84c641005fa06 (patch)
tree6a76e262f06437856fbf18f53f8979443b078193
parent9b73db36739a72d216eb14d35edac2acfca7faa3 (diff)
downloadbinutils-gdb-a0be7a3671e6252c0f3353d128f84c641005fa06.tar.gz
Fix gdb.mi/mi-stack.exp when gcc generates a stack protector
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.c (callee4): Add comment.
-rw-r--r--gdb/testsuite/ChangeLog6
-rw-r--r--gdb/testsuite/gdb.mi/mi-stack.c2
-rw-r--r--gdb/testsuite/gdb.mi/mi-stack.exp8
3 files changed, 11 insertions, 5 deletions
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index a049ac31ab2..d123a3a3f3a 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,5 +1,11 @@
2018-04-07 Simon Marchi <simon.marchi@polymtl.ca>
+ * gdb.mi/mi-stack.exp (test_stack_frame_listing): Use
+ mi_continue_to_line.
+ * gdb.mi/mi-stack.c (callee4): Add comment.
+
+2018-04-07 Simon Marchi <simon.marchi@polymtl.ca>
+
* gdb.mi/mi-stack.exp: Fix indentation.
2018-04-07 Simon Marchi <simon.marchi@ericsson.com>
diff --git a/gdb/testsuite/gdb.mi/mi-stack.c b/gdb/testsuite/gdb.mi/mi-stack.c
index e45fee6ebf9..9bc118e2ab0 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 315b4ac9a8f..fcb74e26104 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" \