]> git.pld-linux.org Git - packages/gdb.git/blob - gdb-lineno-makeup-test.patch
- updated (performance fixes).
[packages/gdb.git] / gdb-lineno-makeup-test.patch
1 New testcase for:
2 https://bugzilla.redhat.com/show_bug.cgi?id=466222
3         (for the first / customer recommended fix)
4 and the upstream fix:
5 http://sourceware.org/ml/gdb-patches/2006-11/msg00253.html
6         [rfc] Do not make up line information
7 http://sourceware.org/ml/gdb-cvs/2006-11/msg00127.html
8
9 --- /dev/null
10 +++ b/gdb/testsuite/gdb.base/lineno-makeup-func.c
11 @@ -0,0 +1,21 @@
12 +/* This testcase is part of GDB, the GNU debugger.
13 +
14 +   Copyright 2009 Free Software Foundation, Inc.
15 +
16 +   This program is free software; you can redistribute it and/or modify
17 +   it under the terms of the GNU General Public License as published by
18 +   the Free Software Foundation; either version 3 of the License, or
19 +   (at your option) any later version.
20 +
21 +   This program is distributed in the hope that it will be useful,
22 +   but WITHOUT ANY WARRANTY; without even the implied warranty of
23 +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
24 +   GNU General Public License for more details.
25 +
26 +   You should have received a copy of the GNU General Public License
27 +   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
28 +
29 +void
30 +func (void)
31 +{
32 +}
33 --- /dev/null
34 +++ b/gdb/testsuite/gdb.base/lineno-makeup.c
35 @@ -0,0 +1,35 @@
36 +/* This testcase is part of GDB, the GNU debugger.
37 +
38 +   Copyright 2009 Free Software Foundation, Inc.
39 +
40 +   This program is free software; you can redistribute it and/or modify
41 +   it under the terms of the GNU General Public License as published by
42 +   the Free Software Foundation; either version 3 of the License, or
43 +   (at your option) any later version.
44 +
45 +   This program is distributed in the hope that it will be useful,
46 +   but WITHOUT ANY WARRANTY; without even the implied warranty of
47 +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
48 +   GNU General Public License for more details.
49 +
50 +   You should have received a copy of the GNU General Public License
51 +   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
52 +
53 +/* DW_AT_low_pc-DW_AT_high_pc should cover the function without line number
54 +   information (.debug_line) so we cannot use an external object file.
55 +   
56 +   It must not be just a label as it would alias on the next function even for
57 +   correct GDB.  Therefore some stub data must be placed there.
58 +   
59 +   We need to provide a real stub function body as at least s390
60 +   (s390_analyze_prologue) would skip the whole body till reaching `main'.  */
61 +
62 +extern void func (void);
63 +asm ("func: .incbin \"gdb.base/lineno-makeup-func.bin\"");
64 +
65 +int
66 +main (void)
67 +{
68 +  func ();
69 +  return 0;
70 +}
71 --- /dev/null
72 +++ b/gdb/testsuite/gdb.base/lineno-makeup.exp
73 @@ -0,0 +1,78 @@
74 +# Copyright 2009 Free Software Foundation, Inc.
75 +
76 +# This program is free software; you can redistribute it and/or modify
77 +# it under the terms of the GNU General Public License as published by
78 +# the Free Software Foundation; either version 3 of the License, or
79 +# (at your option) any later version.
80 +#
81 +# This program is distributed in the hope that it will be useful,
82 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
83 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
84 +# GNU General Public License for more details.
85 +#
86 +# You should have received a copy of the GNU General Public License
87 +# along with this program.  If not, see <http://www.gnu.org/licenses/>.
88 +
89 +set testfile "lineno-makeup"
90 +set srcfuncfile ${testfile}-func.c
91 +set srcfile ${testfile}.c
92 +set objfuncfile ${objdir}/${subdir}/${testfile}-func.o
93 +set binfuncfile ${objdir}/${subdir}/${testfile}-func.bin
94 +set binfile ${objdir}/${subdir}/${testfile}
95 +
96 +if { [gdb_compile "${srcdir}/${subdir}/${srcfuncfile}" "${objfuncfile}" object {}] != "" } {
97 +    gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
98 +}
99 +
100 +set objcopy [catch "exec objcopy -O binary --only-section .text ${objfuncfile} ${binfuncfile}" output]
101 +verbose -log "objcopy=$objcopy: $output"
102 +if { $objcopy != 0 } {
103 +    gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
104 +}
105 +set binfuncfilesize [file size $binfuncfile]
106 +verbose -log "file size $binfuncfile = $binfuncfilesize"
107 +
108 +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
109 +    gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
110 +}
111 +
112 +gdb_exit
113 +gdb_start
114 +gdb_reinitialize_dir $srcdir/$subdir
115 +gdb_load ${binfile}
116 +
117 +set b_addr ""
118 +set test "break func"
119 +gdb_test_multiple $test $test {
120 +    -re "Breakpoint \[0-9\]+ at (0x\[0-9a-f\]+)\r\n$gdb_prompt $" {
121 +       set b_addr $expect_out(1,string)
122 +       pass $test
123 +    }
124 +    -re "Breakpoint \[0-9\]+ at (0x\[0-9a-f\]+): .*\r\n$gdb_prompt $" {
125 +       set b_addr $expect_out(1,string)
126 +       fail $test
127 +    }
128 +}
129 +verbose -log "b_addr=<$b_addr>"
130 +
131 +set p_addr ""
132 +set test "print func"
133 +gdb_test_multiple $test $test {
134 +    -re "\\$\[0-9\]+ = {<text variable, no debug info>} (0x\[0-9a-f\]+) <func>\r\n$gdb_prompt $" {
135 +       set p_addr $expect_out(1,string)
136 +       pass $test
137 +    }
138 +}
139 +verbose -log "p_addr=<$p_addr>"
140 +
141 +set test "break address belongs to func"
142 +if {$b_addr == $p_addr} {
143 +    pass "$test (exact match)"
144 +} else {
145 +    set skip [expr $b_addr - $p_addr]
146 +    if {$skip > 0 && $skip < $binfuncfilesize} {
147 +       pass "$test (prologue skip by $skip bytes)"
148 +    } else {
149 +       fail $test
150 +    }
151 +}
This page took 0.138573 seconds and 3 git commands to generate.