New testcase for: https://bugzilla.redhat.com/show_bug.cgi?id=466222 (for the first / customer recommended fix) and the upstream fix: http://sourceware.org/ml/gdb-patches/2006-11/msg00253.html [rfc] Do not make up line information http://sourceware.org/ml/gdb-cvs/2006-11/msg00127.html Index: gdb-7.10.90.20160211/gdb/testsuite/gdb.base/lineno-makeup-func.c =================================================================== --- /dev/null 1970-01-01 00:00:00.000000000 +0000 +++ gdb-7.10.90.20160211/gdb/testsuite/gdb.base/lineno-makeup-func.c 2016-02-15 23:29:16.595161971 +0100 @@ -0,0 +1,21 @@ +/* This testcase is part of GDB, the GNU debugger. + + Copyright 2009 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +void +func (void) +{ +} Index: gdb-7.10.90.20160211/gdb/testsuite/gdb.base/lineno-makeup.c =================================================================== --- /dev/null 1970-01-01 00:00:00.000000000 +0000 +++ gdb-7.10.90.20160211/gdb/testsuite/gdb.base/lineno-makeup.c 2016-02-15 23:29:23.873213646 +0100 @@ -0,0 +1,35 @@ +/* This testcase is part of GDB, the GNU debugger. + + Copyright 2009 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +/* DW_AT_low_pc-DW_AT_high_pc should cover the function without line number + information (.debug_line) so we cannot use an external object file. + + It must not be just a label as it would alias on the next function even for + correct GDB. Therefore some stub data must be placed there. + + We need to provide a real stub function body as at least s390 + (s390_analyze_prologue) would skip the whole body till reaching `main'. */ + +extern void func (void); +asm ("func: .incbin \"" BINFILENAME "\""); + +int +main (void) +{ + func (); + return 0; +} Index: gdb-7.10.90.20160211/gdb/testsuite/gdb.base/lineno-makeup.exp =================================================================== --- /dev/null 1970-01-01 00:00:00.000000000 +0000 +++ gdb-7.10.90.20160211/gdb/testsuite/gdb.base/lineno-makeup.exp 2016-02-15 23:29:23.873213646 +0100 @@ -0,0 +1,78 @@ +# Copyright 2009 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +set testfile "lineno-makeup" +set srcfuncfile ${testfile}-func.c +set srcfile ${testfile}.c +set objfuncfile [standard_output_file ${testfile}-func.o] +set binfuncfile [standard_output_file ${testfile}-func.bin] +set binfile [standard_output_file ${testfile}] + +if { [gdb_compile "${srcdir}/${subdir}/${srcfuncfile}" "${objfuncfile}" object {}] != "" } { + gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." +} + +set objcopy [catch "exec objcopy -O binary --only-section .text ${objfuncfile} ${binfuncfile}" output] +verbose -log "objcopy=$objcopy: $output" +if { $objcopy != 0 } { + gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." +} +set binfuncfilesize [file size $binfuncfile] +verbose -log "file size $binfuncfile = $binfuncfilesize" + +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable [list debug additional_flags=-DBINFILENAME=\"$binfuncfile\"]] != "" } { + gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." +} + +gdb_exit +gdb_start +gdb_reinitialize_dir $srcdir/$subdir +gdb_load ${binfile} + +set b_addr "" +set test "break func" +gdb_test_multiple $test $test { + -re "Breakpoint \[0-9\]+ at (0x\[0-9a-f\]+)\r\n$gdb_prompt $" { + set b_addr $expect_out(1,string) + pass $test + } + -re "Breakpoint \[0-9\]+ at (0x\[0-9a-f\]+): .*\r\n$gdb_prompt $" { + set b_addr $expect_out(1,string) + fail $test + } +} +verbose -log "b_addr=<$b_addr>" + +set p_addr "" +set test "print func" +gdb_test_multiple $test $test { + -re "\\$\[0-9\]+ = {} (0x\[0-9a-f\]+) \r\n$gdb_prompt $" { + set p_addr $expect_out(1,string) + pass $test + } +} +verbose -log "p_addr=<$p_addr>" + +set test "break address belongs to func" +if {$b_addr == $p_addr} { + pass "$test (exact match)" +} else { + set skip [expr $b_addr - $p_addr] + if {$skip > 0 && $skip < $binfuncfilesize} { + pass "$test (prologue skip by $skip bytes)" + } else { + fail $test + } +}