]> git.pld-linux.org Git - packages/gdb.git/blame - gdb-6.5-bz185337-resolve-tls-without-debuginfo-v2.patch
- updated (performance fixes).
[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
6ed6bacf
AM
35--- a/gdb/printcmd.c
36+++ b/gdb/printcmd.c
37@@ -967,6 +967,8 @@ print_command_1 (char *exp, int inspect, int voidprint)
7566401a 38
e5178960
PS
39 if (exp && *exp)
40 {
6ed6bacf
AM
41+ if (strcmp (exp, "errno") == 0)
42+ exp = "*((int *(*) (void)) __errno_location) ()";
e5178960 43 expr = parse_expression (exp);
6ed6bacf 44 old_chain = make_cleanup (free_current_contents, &expr);
e5178960 45 cleanup = 1;
e5178960 46Index: gdb-7.2/gdb/testsuite/gdb.dwarf2/dw2-errno.c
3a58abaf
AM
47===================================================================
48--- /dev/null 1970-01-01 00:00:00.000000000 +0000
e5178960 49+++ gdb-7.2/gdb/testsuite/gdb.dwarf2/dw2-errno.c 2011-03-29 10:55:35.000000000 +0200
3a58abaf
AM
50@@ -0,0 +1,28 @@
51+/* This testcase is part of GDB, the GNU debugger.
52+
53+ Copyright 2005, 2007 Free Software Foundation, Inc.
54+
55+ This program is free software; you can redistribute it and/or modify
56+ it under the terms of the GNU General Public License as published by
57+ the Free Software Foundation; either version 3 of the License, or
58+ (at your option) any later version.
59+
60+ This program is distributed in the hope that it will be useful,
61+ but WITHOUT ANY WARRANTY; without even the implied warranty of
62+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
63+ GNU General Public License for more details.
64+
65+ You should have received a copy of the GNU General Public License
66+ along with this program. If not, see <http://www.gnu.org/licenses/>.
67+
68+ Please email any bugs, comments, and/or additions to this file to:
69+ bug-gdb@prep.ai.mit.edu */
70+
71+#include <errno.h>
72+
73+int main()
74+{
75+ errno = 42;
76+
77+ return 0; /* breakpoint */
78+}
e5178960 79Index: gdb-7.2/gdb/testsuite/gdb.dwarf2/dw2-errno.exp
3a58abaf
AM
80===================================================================
81--- /dev/null 1970-01-01 00:00:00.000000000 +0000
e5178960 82+++ gdb-7.2/gdb/testsuite/gdb.dwarf2/dw2-errno.exp 2011-03-29 10:55:35.000000000 +0200
51a5ef0f 83@@ -0,0 +1,60 @@
3a58abaf
AM
84+# Copyright 2007 Free Software Foundation, Inc.
85+
86+# This program is free software; you can redistribute it and/or modify
87+# it under the terms of the GNU General Public License as published by
88+# the Free Software Foundation; either version 3 of the License, or
89+# (at your option) any later version.
90+#
91+# This program is distributed in the hope that it will be useful,
92+# but WITHOUT ANY WARRANTY; without even the implied warranty of
93+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
94+# GNU General Public License for more details.
95+#
96+# You should have received a copy of the GNU General Public License
97+# along with this program. If not, see <http://www.gnu.org/licenses/>.
98+
3a58abaf
AM
99+set testfile dw2-errno
100+set srcfile ${testfile}.c
101+set binfile ${objdir}/${subdir}/${testfile}
102+
103+proc prep {} {
104+ global srcdir subdir binfile
105+ gdb_exit
106+ gdb_start
107+ gdb_reinitialize_dir $srcdir/$subdir
108+ gdb_load ${binfile}
109+
110+ runto_main
111+
112+ gdb_breakpoint [gdb_get_line_number "breakpoint"]
113+ gdb_continue_to_breakpoint "breakpoint"
114+}
115+
116+if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable "additional_flags=-g2"] != "" } {
117+ untested "Couldn't compile test program"
118+ return -1
119+}
120+prep
121+gdb_test "print errno" ".* = 42" "errno with macros=N threads=N"
122+
123+if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable "additional_flags=-g3"] != "" } {
124+ untested "Couldn't compile test program"
125+ return -1
126+}
127+prep
128+gdb_test "print errno" ".* = 42" "errno with macros=Y threads=N"
129+
130+if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable "additional_flags=-g2"] != "" } {
131+ return -1
132+}
133+prep
134+gdb_test "print errno" ".* = 42" "errno with macros=N threads=Y"
135+
136+if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable "additional_flags=-g3"] != "" } {
137+ return -1
138+}
139+prep
140+gdb_test "print errno" ".* = 42" "errno with macros=Y threads=Y"
141+
142+# TODO: Test the error on resolving ERRNO with only libc loaded.
143+# Just how to find the current libc filename?
This page took 0.11681 seconds and 4 git commands to generate.