]> git.pld-linux.org Git - packages/gdb.git/blame - gdb-6.5-bz185337-resolve-tls-without-debuginfo-v2.patch
- update some patches from gdb-7.2-51.fc14 (this fixes at least artifical arrays...
[packages/gdb.git] / gdb-6.5-bz185337-resolve-tls-without-debuginfo-v2.patch
CommitLineData
3a58abaf
AM
1https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=185337
2
32008-02-24 Jan Kratochvil <jan.kratochvil@redhat.com>
4
5 Port to GDB-6.8pre.
6
7currently for trivial nonthreaded helloworld with no debug info up to -ggdb2 you
8will get:
9 (gdb) p errno
10 [some error]
11
12* with -ggdb2 and less "errno" in fact does not exist anywhere as it was
13 compiled to "(*__errno_location ())" and the macro definition is not present.
14 Unfortunately gdb will find the TLS symbol and it will try to access it but
15 as the program has been compiled without -lpthread the TLS base register
16 (%gs on i386) is not setup and it will result in:
17 Cannot access memory at address 0x8
18
19Attached suggestion patch how to deal with the most common "errno" symbol
20for the most common under-ggdb3 compiled programs.
21
e5178960
PS
22Original patch hooked into target_translate_tls_address. But its inferior
23call invalidates `struct frame *' in the callers - RH BZ 690908.
3a58abaf
AM
24
25
262007-11-03 Jan Kratochvil <jan.kratochvil@redhat.com>
27
28 * ./gdb/dwarf2read.c (read_partial_die, dwarf2_linkage_name): Prefer
29 DW_AT_MIPS_linkage_name over DW_AT_name now only for non-C.
30
31glibc-debuginfo-2.7-2.x86_64: /usr/lib/debug/lib64/libc.so.6.debug:
32 <81a2> DW_AT_name : (indirect string, offset: 0x280e): __errno_location
33 <81a8> DW_AT_MIPS_linkage_name: (indirect string, offset: 0x2808): *__GI___errno_location
34
e5178960 35Index: gdb-7.2/gdb/printcmd.c
3a58abaf 36===================================================================
e5178960
PS
37--- gdb-7.2.orig/gdb/printcmd.c 2011-03-29 10:55:32.000000000 +0200
38+++ gdb-7.2/gdb/printcmd.c 2011-03-29 10:56:00.000000000 +0200
39@@ -947,10 +947,10 @@ validate_format (struct format_data fmt,
40 static void
41 print_command_1 (char *exp, int inspect, int voidprint)
42 {
43- struct expression *expr;
44 struct cleanup *old_chain = 0;
45 char format = 0;
46- struct value *val;
47+ /* False GCC warning due to the TRY_CATCH. */
48+ struct value *val = NULL;
49 struct format_data fmt;
50 int cleanup = 0;
7566401a 51
e5178960 52@@ -971,10 +971,25 @@ print_command_1 (char *exp, int inspect,
7566401a 53
e5178960
PS
54 if (exp && *exp)
55 {
56+ struct expression *expr;
57+ volatile struct gdb_exception except;
3a58abaf 58+
e5178960
PS
59 expr = parse_expression (exp);
60- old_chain = make_cleanup (free_current_contents, &expr);
61+ old_chain = make_cleanup (xfree, expr);
62 cleanup = 1;
63- val = evaluate_expression (expr);
64+ TRY_CATCH (except, RETURN_MASK_ERROR)
3a58abaf 65+ {
e5178960 66+ val = evaluate_expression (expr);
3a58abaf 67+ }
e5178960
PS
68+ if (except.reason < 0)
69+ {
70+ if (strcmp (exp, "errno") != 0)
71+ throw_exception (except);
72+
73+ expr = parse_expression ("*((int *(*) (void)) __errno_location) ()");
74+ make_cleanup (xfree, expr);
75+ val = evaluate_expression (expr);
76+ }
77 }
78 else
79 val = access_value_history (0);
80Index: gdb-7.2/gdb/testsuite/gdb.dwarf2/dw2-errno.c
3a58abaf
AM
81===================================================================
82--- /dev/null 1970-01-01 00:00:00.000000000 +0000
e5178960 83+++ gdb-7.2/gdb/testsuite/gdb.dwarf2/dw2-errno.c 2011-03-29 10:55:35.000000000 +0200
3a58abaf
AM
84@@ -0,0 +1,28 @@
85+/* This testcase is part of GDB, the GNU debugger.
86+
87+ Copyright 2005, 2007 Free Software Foundation, Inc.
88+
89+ This program is free software; you can redistribute it and/or modify
90+ it under the terms of the GNU General Public License as published by
91+ the Free Software Foundation; either version 3 of the License, or
92+ (at your option) any later version.
93+
94+ This program is distributed in the hope that it will be useful,
95+ but WITHOUT ANY WARRANTY; without even the implied warranty of
96+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
97+ GNU General Public License for more details.
98+
99+ You should have received a copy of the GNU General Public License
100+ along with this program. If not, see <http://www.gnu.org/licenses/>.
101+
102+ Please email any bugs, comments, and/or additions to this file to:
103+ bug-gdb@prep.ai.mit.edu */
104+
105+#include <errno.h>
106+
107+int main()
108+{
109+ errno = 42;
110+
111+ return 0; /* breakpoint */
112+}
e5178960 113Index: gdb-7.2/gdb/testsuite/gdb.dwarf2/dw2-errno.exp
3a58abaf
AM
114===================================================================
115--- /dev/null 1970-01-01 00:00:00.000000000 +0000
e5178960 116+++ gdb-7.2/gdb/testsuite/gdb.dwarf2/dw2-errno.exp 2011-03-29 10:55:35.000000000 +0200
51a5ef0f 117@@ -0,0 +1,60 @@
3a58abaf
AM
118+# Copyright 2007 Free Software Foundation, Inc.
119+
120+# This program is free software; you can redistribute it and/or modify
121+# it under the terms of the GNU General Public License as published by
122+# the Free Software Foundation; either version 3 of the License, or
123+# (at your option) any later version.
124+#
125+# This program is distributed in the hope that it will be useful,
126+# but WITHOUT ANY WARRANTY; without even the implied warranty of
127+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
128+# GNU General Public License for more details.
129+#
130+# You should have received a copy of the GNU General Public License
131+# along with this program. If not, see <http://www.gnu.org/licenses/>.
132+
3a58abaf
AM
133+set testfile dw2-errno
134+set srcfile ${testfile}.c
135+set binfile ${objdir}/${subdir}/${testfile}
136+
137+proc prep {} {
138+ global srcdir subdir binfile
139+ gdb_exit
140+ gdb_start
141+ gdb_reinitialize_dir $srcdir/$subdir
142+ gdb_load ${binfile}
143+
144+ runto_main
145+
146+ gdb_breakpoint [gdb_get_line_number "breakpoint"]
147+ gdb_continue_to_breakpoint "breakpoint"
148+}
149+
150+if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable "additional_flags=-g2"] != "" } {
151+ untested "Couldn't compile test program"
152+ return -1
153+}
154+prep
155+gdb_test "print errno" ".* = 42" "errno with macros=N threads=N"
156+
157+if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable "additional_flags=-g3"] != "" } {
158+ untested "Couldn't compile test program"
159+ return -1
160+}
161+prep
162+gdb_test "print errno" ".* = 42" "errno with macros=Y threads=N"
163+
164+if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable "additional_flags=-g2"] != "" } {
165+ return -1
166+}
167+prep
168+gdb_test "print errno" ".* = 42" "errno with macros=N threads=Y"
169+
170+if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable "additional_flags=-g3"] != "" } {
171+ return -1
172+}
173+prep
174+gdb_test "print errno" ".* = 42" "errno with macros=Y threads=Y"
175+
176+# TODO: Test the error on resolving ERRNO with only libc loaded.
177+# Just how to find the current libc filename?
This page took 1.007006 seconds and 4 git commands to generate.