1 https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=185337
3 2008-02-24 Jan Kratochvil <jan.kratochvil@redhat.com>
7 currently for trivial nonthreaded helloworld with no debug info up to -ggdb2 you
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
19 Attached suggestion patch how to deal with the most common "errno" symbol
20 for the most common under-ggdb3 compiled programs.
22 Original patch hooked into target_translate_tls_address. But its inferior
23 call invalidates `struct frame *' in the callers - RH BZ 690908.
26 2007-11-03 Jan Kratochvil <jan.kratochvil@redhat.com>
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.
31 glibc-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
37 @@ -967,6 +967,8 @@ print_command_1 (char *exp, int inspect, int voidprint)
41 + if (strcmp (exp, "errno") == 0)
42 + exp = "*((int *(*) (void)) __errno_location) ()";
43 expr = parse_expression (exp);
44 old_chain = make_cleanup (free_current_contents, &expr);
46 Index: gdb-7.2/gdb/testsuite/gdb.dwarf2/dw2-errno.c
47 ===================================================================
48 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
49 +++ gdb-7.2/gdb/testsuite/gdb.dwarf2/dw2-errno.c 2011-03-29 10:55:35.000000000 +0200
51 +/* This testcase is part of GDB, the GNU debugger.
53 + Copyright 2005, 2007 Free Software Foundation, Inc.
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.
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.
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/>.
68 + Please email any bugs, comments, and/or additions to this file to:
69 + bug-gdb@prep.ai.mit.edu */
77 + return 0; /* breakpoint */
79 Index: gdb-7.2/gdb/testsuite/gdb.dwarf2/dw2-errno.exp
80 ===================================================================
81 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
82 +++ gdb-7.2/gdb/testsuite/gdb.dwarf2/dw2-errno.exp 2011-03-29 10:55:35.000000000 +0200
84 +# Copyright 2007 Free Software Foundation, Inc.
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.
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.
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/>.
99 +set testfile dw2-errno
100 +set srcfile ${testfile}.c
101 +set binfile ${objdir}/${subdir}/${testfile}
104 + global srcdir subdir binfile
107 + gdb_reinitialize_dir $srcdir/$subdir
108 + gdb_load ${binfile}
112 + gdb_breakpoint [gdb_get_line_number "breakpoint"]
113 + gdb_continue_to_breakpoint "breakpoint"
116 +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable "additional_flags=-g2"] != "" } {
117 + untested "Couldn't compile test program"
121 +gdb_test "print errno" ".* = 42" "errno with macros=N threads=N"
123 +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable "additional_flags=-g3"] != "" } {
124 + untested "Couldn't compile test program"
128 +gdb_test "print errno" ".* = 42" "errno with macros=Y threads=N"
130 +if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable "additional_flags=-g2"] != "" } {
134 +gdb_test "print errno" ".* = 42" "errno with macros=N threads=Y"
136 +if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable "additional_flags=-g3"] != "" } {
140 +gdb_test "print errno" ".* = 42" "errno with macros=Y threads=Y"
142 +# TODO: Test the error on resolving ERRNO with only libc loaded.
143 +# Just how to find the current libc filename?