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