From patchwork Sat Dec 16 14:56:51 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Marchi X-Patchwork-Id: 24977 Received: (qmail 109498 invoked by alias); 16 Dec 2017 14:57:33 -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 109476 invoked by uid 89); 16 Dec 2017 14:57:32 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.2 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_SOFTFAIL autolearn=ham version=3.3.2 spammy=H*RU:sk:barracu, Hx-spam-relays-external:sk:barracu, HX-HELO:sk:barracu, H*r:sk:barracu X-HELO: barracuda.ebox.ca Received: from barracuda.ebox.ca (HELO barracuda.ebox.ca) (96.127.255.19) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sat, 16 Dec 2017 14:57:30 +0000 X-ASG-Debug-ID: 1513436213-0c856e65d5406f940001-fS2M51 Received: from smtp.ebox.ca (smtp.electronicbox.net [96.127.255.82]) by barracuda.ebox.ca with ESMTP id o1xmavPJdu1ajX07 (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Sat, 16 Dec 2017 09:56:53 -0500 (EST) X-Barracuda-Envelope-From: simon.marchi@polymtl.ca X-Barracuda-RBL-Trusted-Forwarder: 96.127.255.82 Received: from simark.lan (192-222-251-162.qc.cable.ebox.net [192.222.251.162]) by smtp.ebox.ca (Postfix) with ESMTP id 1FCAA441D64; Sat, 16 Dec 2017 09:56:53 -0500 (EST) From: Simon Marchi X-Barracuda-Effective-Source-IP: 192-222-251-162.qc.cable.ebox.net[192.222.251.162] X-Barracuda-Apparent-Source-IP: 192.222.251.162 X-Barracuda-RBL-IP: 192.222.251.162 To: gdb-patches@sourceware.org Cc: Simon Marchi Subject: [PATCH 2/2] Fix gdb.mi/mi-stack.exp when gcc generates a stack protector Date: Sat, 16 Dec 2017 09:56:51 -0500 X-ASG-Orig-Subj: [PATCH 2/2] Fix gdb.mi/mi-stack.exp when gcc generates a stack protector Message-Id: <20171216145651.13936-2-simon.marchi@polymtl.ca> In-Reply-To: <20171216145651.13936-1-simon.marchi@polymtl.ca> References: <20171216145651.13936-1-simon.marchi@polymtl.ca> X-Barracuda-Connect: smtp.electronicbox.net[96.127.255.82] X-Barracuda-Start-Time: 1513436213 X-Barracuda-Encrypted: DHE-RSA-AES256-SHA X-Barracuda-URL: https://96.127.255.19:443/cgi-mod/mark.cgi X-Barracuda-Scan-Msg-Size: 4157 X-Barracuda-BRTS-Status: 1 X-Barracuda-Spam-Score: 0.00 X-Barracuda-Spam-Status: No, SCORE=0.00 using global scores of TAG_LEVEL=1000.0 QUARANTINE_LEVEL=1000.0 KILL_LEVEL=8.0 tests= X-Barracuda-Spam-Report: Code version 3.2, rules version 3.2.3.45946 Rule breakdown below pts rule name description ---- ---------------------- -------------------------------------------------- X-IsSubscribed: yes 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" \