|
|
861f93 |
https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=185337
|
|
|
861f93 |
|
|
|
861f93 |
2008-02-24 Jan Kratochvil <jan.kratochvil@redhat.com>
|
|
|
861f93 |
|
|
|
861f93 |
Port to GDB-6.8pre.
|
|
|
861f93 |
|
|
|
861f93 |
currently for trivial nonthreaded helloworld with no debug info up to -ggdb2 you
|
|
|
861f93 |
will get:
|
|
|
861f93 |
(gdb) p errno
|
|
|
861f93 |
[some error]
|
|
|
861f93 |
|
|
|
861f93 |
* with -ggdb2 and less "errno" in fact does not exist anywhere as it was
|
|
|
861f93 |
compiled to "(*__errno_location ())" and the macro definition is not present.
|
|
|
861f93 |
Unfortunately gdb will find the TLS symbol and it will try to access it but
|
|
|
861f93 |
as the program has been compiled without -lpthread the TLS base register
|
|
|
861f93 |
(%gs on i386) is not setup and it will result in:
|
|
|
861f93 |
Cannot access memory at address 0x8
|
|
|
861f93 |
|
|
|
861f93 |
Attached suggestion patch how to deal with the most common "errno" symbol
|
|
|
861f93 |
for the most common under-ggdb3 compiled programs.
|
|
|
861f93 |
|
|
|
861f93 |
Original patch hooked into target_translate_tls_address. But its inferior
|
|
|
861f93 |
call invalidates `struct frame *' in the callers - RH BZ 690908.
|
|
|
861f93 |
|
|
|
861f93 |
|
|
|
861f93 |
2007-11-03 Jan Kratochvil <jan.kratochvil@redhat.com>
|
|
|
861f93 |
|
|
|
861f93 |
* ./gdb/dwarf2read.c (read_partial_die, dwarf2_linkage_name): Prefer
|
|
|
861f93 |
DW_AT_MIPS_linkage_name over DW_AT_name now only for non-C.
|
|
|
861f93 |
|
|
|
861f93 |
glibc-debuginfo-2.7-2.x86_64: /usr/lib/debug/lib64/libc.so.6.debug:
|
|
|
861f93 |
<81a2> DW_AT_name : (indirect string, offset: 0x280e): __errno_location
|
|
|
861f93 |
<81a8> DW_AT_MIPS_linkage_name: (indirect string, offset: 0x2808): *__GI___errno_location
|
|
|
861f93 |
|
|
|
861f93 |
--- a/gdb/printcmd.c
|
|
|
861f93 |
+++ b/gdb/printcmd.c
|
|
|
861f93 |
@@ -967,6 +967,8 @@ print_command_1 (char *exp, int inspect, int voidprint)
|
|
|
861f93 |
|
|
|
861f93 |
if (exp && *exp)
|
|
|
861f93 |
{
|
|
|
861f93 |
+ if (strcmp (exp, "errno") == 0)
|
|
|
861f93 |
+ exp = "*((int *(*) (void)) __errno_location) ()";
|
|
|
861f93 |
expr = parse_expression (exp);
|
|
|
861f93 |
old_chain = make_cleanup (free_current_contents, &expr;;
|
|
|
861f93 |
cleanup = 1;
|
|
|
861f93 |
Index: gdb-7.2/gdb/testsuite/gdb.dwarf2/dw2-errno.c
|
|
|
861f93 |
===================================================================
|
|
|
861f93 |
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
|
|
|
861f93 |
+++ gdb-7.2/gdb/testsuite/gdb.dwarf2/dw2-errno.c 2011-03-29 10:55:35.000000000 +0200
|
|
|
861f93 |
@@ -0,0 +1,28 @@
|
|
|
861f93 |
+/* This testcase is part of GDB, the GNU debugger.
|
|
|
861f93 |
+
|
|
|
861f93 |
+ Copyright 2005, 2007 Free Software Foundation, Inc.
|
|
|
861f93 |
+
|
|
|
861f93 |
+ This program is free software; you can redistribute it and/or modify
|
|
|
861f93 |
+ it under the terms of the GNU General Public License as published by
|
|
|
861f93 |
+ the Free Software Foundation; either version 3 of the License, or
|
|
|
861f93 |
+ (at your option) any later version.
|
|
|
861f93 |
+
|
|
|
861f93 |
+ This program is distributed in the hope that it will be useful,
|
|
|
861f93 |
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
861f93 |
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
861f93 |
+ GNU General Public License for more details.
|
|
|
861f93 |
+
|
|
|
861f93 |
+ You should have received a copy of the GNU General Public License
|
|
|
861f93 |
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
861f93 |
+
|
|
|
861f93 |
+ Please email any bugs, comments, and/or additions to this file to:
|
|
|
861f93 |
+ bug-gdb@prep.ai.mit.edu */
|
|
|
861f93 |
+
|
|
|
861f93 |
+#include <errno.h>
|
|
|
861f93 |
+
|
|
|
861f93 |
+int main()
|
|
|
861f93 |
+{
|
|
|
861f93 |
+ errno = 42;
|
|
|
861f93 |
+
|
|
|
861f93 |
+ return 0; /* breakpoint */
|
|
|
861f93 |
+}
|
|
|
861f93 |
Index: gdb-7.2/gdb/testsuite/gdb.dwarf2/dw2-errno.exp
|
|
|
861f93 |
===================================================================
|
|
|
861f93 |
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
|
|
|
861f93 |
+++ gdb-7.2/gdb/testsuite/gdb.dwarf2/dw2-errno.exp 2011-03-29 10:55:35.000000000 +0200
|
|
|
861f93 |
@@ -0,0 +1,60 @@
|
|
|
861f93 |
+# Copyright 2007 Free Software Foundation, Inc.
|
|
|
861f93 |
+
|
|
|
861f93 |
+# This program is free software; you can redistribute it and/or modify
|
|
|
861f93 |
+# it under the terms of the GNU General Public License as published by
|
|
|
861f93 |
+# the Free Software Foundation; either version 3 of the License, or
|
|
|
861f93 |
+# (at your option) any later version.
|
|
|
861f93 |
+#
|
|
|
861f93 |
+# This program is distributed in the hope that it will be useful,
|
|
|
861f93 |
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
861f93 |
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
861f93 |
+# GNU General Public License for more details.
|
|
|
861f93 |
+#
|
|
|
861f93 |
+# You should have received a copy of the GNU General Public License
|
|
|
861f93 |
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
861f93 |
+
|
|
|
861f93 |
+set testfile dw2-errno
|
|
|
861f93 |
+set srcfile ${testfile}.c
|
|
|
861f93 |
+set binfile ${objdir}/${subdir}/${testfile}
|
|
|
861f93 |
+
|
|
|
861f93 |
+proc prep {} {
|
|
|
861f93 |
+ global srcdir subdir binfile
|
|
|
861f93 |
+ gdb_exit
|
|
|
861f93 |
+ gdb_start
|
|
|
861f93 |
+ gdb_reinitialize_dir $srcdir/$subdir
|
|
|
861f93 |
+ gdb_load ${binfile}
|
|
|
861f93 |
+
|
|
|
861f93 |
+ runto_main
|
|
|
861f93 |
+
|
|
|
861f93 |
+ gdb_breakpoint [gdb_get_line_number "breakpoint"]
|
|
|
861f93 |
+ gdb_continue_to_breakpoint "breakpoint"
|
|
|
861f93 |
+}
|
|
|
861f93 |
+
|
|
|
861f93 |
+if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable "additional_flags=-g2"] != "" } {
|
|
|
861f93 |
+ untested "Couldn't compile test program"
|
|
|
861f93 |
+ return -1
|
|
|
861f93 |
+}
|
|
|
861f93 |
+prep
|
|
|
861f93 |
+gdb_test "print errno" ".* = 42" "errno with macros=N threads=N"
|
|
|
861f93 |
+
|
|
|
861f93 |
+if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable "additional_flags=-g3"] != "" } {
|
|
|
861f93 |
+ untested "Couldn't compile test program"
|
|
|
861f93 |
+ return -1
|
|
|
861f93 |
+}
|
|
|
861f93 |
+prep
|
|
|
861f93 |
+gdb_test "print errno" ".* = 42" "errno with macros=Y threads=N"
|
|
|
861f93 |
+
|
|
|
861f93 |
+if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable "additional_flags=-g2"] != "" } {
|
|
|
861f93 |
+ return -1
|
|
|
861f93 |
+}
|
|
|
861f93 |
+prep
|
|
|
861f93 |
+gdb_test "print errno" ".* = 42" "errno with macros=N threads=Y"
|
|
|
861f93 |
+
|
|
|
861f93 |
+if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable "additional_flags=-g3"] != "" } {
|
|
|
861f93 |
+ return -1
|
|
|
861f93 |
+}
|
|
|
861f93 |
+prep
|
|
|
861f93 |
+gdb_test "print errno" ".* = 42" "errno with macros=Y threads=Y"
|
|
|
861f93 |
+
|
|
|
861f93 |
+# TODO: Test the error on resolving ERRNO with only libc loaded.
|
|
|
861f93 |
+# Just how to find the current libc filename?
|