asmlabel.exp revision 1.1.1.3
12061Sjkh# Copyright (C) 2015-2019 Free Software Foundation, Inc.
27171Sats
32061Sjkh# This program is free software; you can redistribute it and/or modify
42061Sjkh# it under the terms of the GNU General Public License as published by
52061Sjkh# the Free Software Foundation; either version 3 of the License, or
62061Sjkh# (at your option) any later version.
72061Sjkh#
83197Scsgr# This program is distributed in the hope that it will be useful,
93197Scsgr# but WITHOUT ANY WARRANTY; without even the implied warranty of
102061Sjkh# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
112160Scsgr# GNU General Public License for more details.
122834Swollman#
132061Sjkh# You should have received a copy of the GNU General Public License
142061Sjkh# along with this program.  If not, see <http://www.gnu.org/licenses/>.
152160Scsgr
161594Srgrimes# Test to see that GDB reports the correct function name when stopping
172061Sjkh# in a function with several assembly-defined labels; see the test
182061Sjkh# case asmlabel.c.
191594Srgrimes#
207108Sphk# When setting and then continuing to a breakpoint at either location
217108Sphk# L1 or L2 - again, see the code - we want to make sure that GDB
227108Sphk# correctly reports that it's in main, like this:
237108Sphk#
247108Sphk# Breakpoint 2, main (argc=1, argv=0x7fffffffe408) at asmlabel.c:26
252061Sjkh# 26        v = 1;                /* set L1 breakpoint here */
262061Sjkh#
272061Sjkh# This test case was written to test for a bug in which GDB printed
282061Sjkh# the following instead:
292061Sjkh#
302061Sjkh# Breakpoint 2, L1 () at asmlabel.c:26
312061Sjkh# 26        v = 1;                /* set L1 breakpoint here */
322061Sjkh#
332061Sjkh
342061Sjkhstandard_testfile
352061Sjkh
362061Sjkhif {[prepare_for_testing "failed to prepare" $testfile $srcfile debug]} {
372061Sjkh    return -1
382061Sjkh}
392061Sjkh
403197Scsgrif ![runto_main] {
412626Scsgr    fail "can't run to main"
422626Scsgr    return 0
432061Sjkh}
442061Sjkh
452061Sjkhset L1_bploc [gdb_get_line_number "set L1 breakpoint here" $srcfile]
462061Sjkhset L2_bploc [gdb_get_line_number "set L2 breakpoint here" $srcfile]
472061Sjkh
482061Sjkhgdb_test "break $srcfile:$L1_bploc" \
492061Sjkh    "Breakpoint.*at.* file .*$srcfile, line $L1_bploc\\." \
502061Sjkh    "breakpoint at L1"
512061Sjkh
522061Sjkhgdb_test "break $L2_bploc" \
532061Sjkh    "Breakpoint.*at.* file .*$srcfile, line $L2_bploc\\." \
542061Sjkh    "breakpoint at L2"
552061Sjkh
562061Sjkhgdb_test "continue" \
572061Sjkh    "Continuing.*Breakpoint \[0-9\]+, main .* at .*$srcfile:$L1_bploc.*" \
582061Sjkh    "continue to L1"
592061Sjkh
602061Sjkhgdb_test "continue" \
612834Swollman    "Continuing.*Breakpoint \[0-9\]+, main .* at .*$srcfile:$L2_bploc.*" \
622834Swollman    "continue to L2"
632834Swollman
642834Swollmangdb_test "print v" "= 1" "check value of v at L2"
652834Swollman