gdb/gdb-upstream.patch
Jan Kratochvil a749ba7e1c - Fix crash on /proc/PID/stat race during inferior exit (BZ 596751).
- testsuite: gdb.threads/watchthreads-reorder.exp kernel-2.6.33 compat.
    fix.
2010-06-01 21:40:13 +00:00

1180 lines
39 KiB
Diff

http://sourceware.org/ml/gdb-cvs/2010-03/msg00104.html
5855954454f19a801f76bbf7baafd11a693c5d33
Imported to sync gdb.base/break-interp.exp for gdb-pie-rerun.patch.
### src/gdb/ChangeLog 2010/03/11 03:45:48 1.11469
### src/gdb/ChangeLog 2010/03/11 22:07:00 1.11470
## -1,3 +1,9 @@
+2010-03-11 Jan Kratochvil <jan.kratochvil@redhat.com>
+
+ * solib-svr4.c (LM_ADDR_CHECK) <info_verbose>: Use printf_unfiltered
+ for the PIC displacement, print also the displacement value.
+ (svr4_exec_displacement): Print DISPLACEMENT if INFO_VERBOSE.
+
2010-03-10 Kevin Buettner <kevinb@redhat.com>
* remote-mips.c (close_ports, mips_initialize_cleanups)
--- src/gdb/solib-svr4.c 2010/03/10 20:55:44 1.129
+++ src/gdb/solib-svr4.c 2010/03/11 22:07:02 1.130
@@ -243,12 +243,10 @@
l_addr = l_dynaddr - dynaddr;
if (info_verbose)
- {
- warning (_(".dynamic section for \"%s\" "
- "is not at the expected address"), so->so_name);
- warning (_("difference appears to be caused by prelink, "
- "adjusting expectations"));
- }
+ printf_unfiltered (_("Using PIC (Position Independent Code) "
+ "prelink displacement %s for \"%s\".\n"),
+ paddress (target_gdbarch, l_addr),
+ so->so_name);
}
else
warning (_(".dynamic section for \"%s\" "
@@ -1767,6 +1765,18 @@
return 0;
}
+ if (info_verbose)
+ {
+ /* It can be printed repeatedly as there is no easy way to check
+ the executable symbols/file has been already relocated to
+ displacement. */
+
+ printf_unfiltered (_("Using PIE (Position Independent Executable) "
+ "displacement %s for \"%s\".\n"),
+ paddress (target_gdbarch, displacement),
+ bfd_get_filename (exec_bfd));
+ }
+
*displacementp = displacement;
return 1;
}
### src/gdb/testsuite/ChangeLog 2010/03/11 00:20:29 1.2168
### src/gdb/testsuite/ChangeLog 2010/03/11 22:07:02 1.2169
## -1,3 +1,20 @@
+2010-03-11 Jan Kratochvil <jan.kratochvil@redhat.com>
+
+ * gdb.base/break-interp.exp: Create new displacement parameter value
+ for the test_ld calls.
+ (reach): New parameter displacement, verify its content. New push of
+ pf_prefix "reach-$func:". Import global expect_out.
+ (test_core): New parameter displacement, verify its content. New push
+ of pf_prefix "core:". New command "set verbose on". Import global
+ expect_out.
+ (test_attach): New parameter displacement, verify its content. New
+ push of pf_prefix "attach:". New command "set verbose on". Import
+ global expect_out.
+ (test_ld): New parameter displacement, pass it to the reach, test_core
+ and test_attach calls and verify its content in the "ld.so exit" test.
+ * gdb.base/prelink.exp: Remove gdb_exit and final return.
+ (prelink): Update expected text, use gdb_test.
+
2010-03-10 Doug Evans <dje@google.com>
* gdb.base/checkpoint.exp: Fix comment.
--- src/gdb/testsuite/gdb.base/break-interp.exp 2010/01/27 20:53:22 1.6
+++ src/gdb/testsuite/gdb.base/break-interp.exp 2010/03/11 22:07:03 1.7
@@ -221,30 +221,61 @@
}
# `runto' does not check we stopped really at the function we specified.
-proc reach {func command} {
- global gdb_prompt
+# DISPLACEMENT can be "NONE", "ZERO" or "NONZERO"
+proc reach {func command displacement} {
+ global gdb_prompt expect_out
+
+ global pf_prefix
+ set old_ldprefix $pf_prefix
+ lappend pf_prefix "reach-$func:"
if [gdb_breakpoint $func allow-pending] {
- set test "reach $func"
+ set test "reach"
+ set test_displacement "seen displacement message as $displacement"
gdb_test_multiple $command $test {
+ -re "Using PIE \\(Position Independent Executable\\) displacement (0x\[0-9a-f\]+) " {
+ # Missing "$gdb_prompt $" is intentional.
+ if {$expect_out(1,string) == "0x0"} {
+ set case "ZERO"
+ } else {
+ set case "NONZERO"
+ }
+ if {$displacement == $case} {
+ pass $test_displacement
+ # Permit multiple such messages.
+ set displacement "FOUND-$displacement"
+ } elseif {$displacement != "FOUND-$case"} {
+ fail $test_displacement
+ }
+ exp_continue
+ }
-re "Breakpoint \[0-9\]+, $func \\(.*\\) at .*:\[0-9\]+\r\n.*$gdb_prompt $" {
pass $test
}
- -re "Breakpoint \[0-9\]+, \[0-9xa-f\]+ in $func \\(\\)( from .*)?\r\n$gdb_prompt $" {
+ -re "Breakpoint \[0-9\]+, \[0-9xa-f\]+ in $func \\(\\)( from .*)?\r\n$gdb_prompt $" {
pass $test
}
}
+ if ![regexp {^(NONE|FOUND-.*)$} $displacement] {
+ fail $test_displacement
+ }
}
+
+ set pf_prefix $old_ldprefix
}
-proc test_core {file} {
- global srcdir subdir gdb_prompt
+proc test_core {file displacement} {
+ global srcdir subdir gdb_prompt expect_out
set corefile [core_find $file {} "segv"]
if {$corefile == ""} {
return
}
+ global pf_prefix
+ set old_ldprefix $pf_prefix
+ lappend pf_prefix "core:"
+
gdb_exit
gdb_start
# Clear it to never find any separate debug infos in $debug_root.
@@ -252,14 +283,44 @@
gdb_reinitialize_dir $srcdir/$subdir
gdb_load $file
- # Do not check the binary filename as it may be truncated.
- gdb_test "core-file $corefile" "Core was generated by .*\r\n#0 .*" "core loaded"
+ # Print the "PIE (Position Independent Executable) displacement" message.
+ gdb_test "set verbose on"
+
+ set test "core loaded"
+ set test_displacement "seen displacement message"
+ gdb_test_multiple "core-file $corefile" $test {
+ -re "Using PIE \\(Position Independent Executable\\) displacement (0x\[0-9a-f\]+) " {
+ # Missing "$gdb_prompt $" is intentional.
+ if {$expect_out(1,string) == "0x0"} {
+ set case "ZERO"
+ } else {
+ set case "NONZERO"
+ }
+ if {$displacement == $case} {
+ pass $test_displacement
+ # Permit multiple such messages.
+ set displacement "FOUND-$displacement"
+ } elseif {$displacement != "FOUND-$case"} {
+ fail $test_displacement
+ }
+ exp_continue
+ }
+ -re "Core was generated by .*\r\n#0 .*$gdb_prompt $" {
+ # Do not check the binary filename as it may be truncated.
+ pass $test
+ }
+ }
+ if ![regexp {^(NONE|FOUND-.*)$} $displacement] {
+ fail $test_displacement
+ }
gdb_test "bt" "#\[0-9\]+ +\[^\r\n\]*\\mlibfunc\\M\[^\r\n\]*\r\n#\[0-9\]+ +\[^\r\n\]*\\mmain\\M.*" "core main bt"
+
+ set pf_prefix $old_ldprefix
}
-proc test_attach {file} {
- global board_info
+proc test_attach {file displacement} {
+ global board_info gdb_prompt expect_out
gdb_exit
@@ -287,17 +348,61 @@
}
}
+ global pf_prefix
+ set old_ldprefix $pf_prefix
+ lappend pf_prefix "attach:"
+
gdb_exit
gdb_start
- gdb_test "attach $pid" "Attaching to process $pid\r\n.*" "attach"
+
+ # Print the "PIE (Position Independent Executable) displacement" message.
+ gdb_test "set verbose on"
+
+ set test "attach"
+ gdb_test_multiple "attach $pid" $test {
+ -re "Attaching to process $pid\r\n" {
+ # Missing "$gdb_prompt $" is intentional.
+ pass $test
+ }
+ }
+
+ set test "attach final prompt"
+ set test_displacement "seen displacement message"
+ gdb_test_multiple "" $test {
+ -re "Using PIE \\(Position Independent Executable\\) displacement (0x\[0-9a-f\]+) " {
+ # Missing "$gdb_prompt $" is intentional.
+ if {$expect_out(1,string) == "0x0"} {
+ set case "ZERO"
+ } else {
+ set case "NONZERO"
+ }
+ if {$displacement == $case} {
+ pass $test_displacement
+ # Permit multiple such messages.
+ set displacement "FOUND-$displacement"
+ } elseif {$displacement != "FOUND-$case"} {
+ fail $test_displacement
+ }
+ exp_continue
+ }
+ -re "$gdb_prompt $" {
+ pass $test
+ }
+ }
+ if ![regexp {^(NONE|FOUND-.*)$} $displacement] {
+ fail $test_displacement
+ }
+
gdb_test "bt" "#\[0-9\]+ +\[^\r\n\]*\\mlibfunc\\M\[^\r\n\]*\r\n#\[0-9\]+ +\[^\r\n\]*\\mmain\\M.*" "attach main bt"
gdb_exit
remote_exec host "kill -9 $pid"
+
+ set pf_prefix $old_ldprefix
}
-proc test_ld {file ifmain trynosym} {
- global srcdir subdir gdb_prompt
+proc test_ld {file ifmain trynosym displacement} {
+ global srcdir subdir gdb_prompt expect_out
# First test normal `file'-command loaded $FILE with symbols.
@@ -308,20 +413,31 @@
gdb_reinitialize_dir $srcdir/$subdir
gdb_load $file
- reach "dl_main" "run segv"
+ # Print the "PIE (Position Independent Executable) displacement" message.
+ gdb_test "set verbose on"
+
+ reach "dl_main" "run segv" $displacement
gdb_test "bt" "#0 +\[^\r\n\]*\\mdl_main\\M.*" "dl bt"
if $ifmain {
- reach "main" continue
+ # Displacement message will be printed the second time on initializing
+ # the linker from svr4_special_symbol_handling. If any ANOFFSET has
+ # been already set as non-zero the detection will no longer be run.
+ if {$displacement == "NONZERO"} {
+ set displacement_main "NONE"
+ } else {
+ set displacement_main $displacement
+ }
+ reach "main" continue $displacement_main
- reach "libfunc" continue
+ reach "libfunc" continue "NONE"
gdb_test "bt" "#0 +\[^\r\n\]*\\mlibfunc\\M\[^\r\n\]*\r\n#1 +\[^\r\n\]*\\mmain\\M.*" "main bt"
- test_core $file
+ test_core $file $displacement
- test_attach $file
+ test_attach $file $displacement
}
if !$trynosym {
@@ -341,18 +457,21 @@
gdb_test "set debug-file-directory"
gdb_reinitialize_dir $srcdir/$subdir
+ # Print the "PIE (Position Independent Executable) displacement" message.
+ gdb_test "set verbose on"
+
# Test no (error) message has been printed by `exec-file'.
set escapedfile [string_to_regexp $file]
gdb_test "exec-file $file" "exec-file $escapedfile" "load"
if $ifmain {
- reach "dl_main" run
+ reach "dl_main" run $displacement
set test "info files"
set entrynohex ""
gdb_test_multiple $test $test {
-re "\r\n\[\t \]*Entry point:\[\t \]*0x(\[0-9a-f\]+)\r\n.*$gdb_prompt $" {
- set entrynohex $expect_out(1,string)
+ set entrynohex $expect_out(1,string)
pass $test
}
}
@@ -363,7 +482,34 @@
} else {
# There is no symbol to break at ld.so. Moreover it can exit with an
# error code.
- gdb_test "run" "Program exited (normally|with code \[0-9\]+)\\." "ld.so exit"
+
+ set test "ld.so exit"
+ set test_displacement "seen displacement message"
+ gdb_test_multiple "run" $test {
+ -re "Using PIE \\(Position Independent Executable\\) displacement (0x\[0-9a-f\]+) " {
+ # Missing "$gdb_prompt $" is intentional.
+ if {$expect_out(1,string) == "0x0"} {
+ set case "ZERO"
+ } else {
+ set case "NONZERO"
+ }
+ if {$displacement == $case} {
+ pass $test_displacement
+ # Permit multiple such messages.
+ set displacement "FOUND-$displacement"
+ } elseif {$displacement != "FOUND-$case"} {
+ fail $test_displacement
+ }
+ exp_continue
+ }
+ -re "Program exited (normally|with code \[0-9\]+)\\.\r\n$gdb_prompt $" {
+ # Do not check the binary filename as it may be truncated.
+ pass $test
+ }
+ }
+ if ![regexp {^(NONE|FOUND-.*)$} $displacement] {
+ fail $test_displacement
+ }
}
set pf_prefix $old_ldprefix
@@ -450,7 +596,12 @@
if ![prelink$ldprelink $interp] {
continue
}
- test_ld $interp 0 [expr {$ldsepdebug == "NO"}]
+ if {$ldprelink == "NO"} {
+ set displacement "NONZERO"
+ } else {
+ set displacement "ZERO"
+ }
+ test_ld $interp 0 [expr {$ldsepdebug == "NO"}] $displacement
if ![copy $interp $interp_saved] {
continue
@@ -531,7 +682,14 @@
if {[prelink$binprelink "--dynamic-linker=$interp --ld-library-path=$dir $exec $interp [concat $dests]" [file tail $exec]]
&& [copy $interp_saved $interp]} {
- test_ld $exec 1 [expr {$binsepdebug == "NO"}]
+ if {$binpie == "NO"} {
+ set displacement "NONE"
+ } elseif {$binprelink == "NO"} {
+ set displacement "NONZERO"
+ } else {
+ set displacement "ZERO"
+ }
+ test_ld $exec 1 [expr {$binsepdebug == "NO"}] $displacement
}
}
}
--- src/gdb/testsuite/gdb.base/prelink.exp 2010/02/13 12:02:29 1.11
+++ src/gdb/testsuite/gdb.base/prelink.exp 2010/03/11 22:07:03 1.12
@@ -112,15 +112,4 @@
# Print the "adjusting expectations" message.
gdb_test "set verbose on"
-set test "prelink"
-global gdb_prompt
-gdb_test_multiple "core-file $objdir/$subdir/prelink.core" "$test" {
- -re "warning: \.dynamic section.*not at the expected address.*warning: difference.*caused by prelink, adjusting expectations.*$gdb_prompt $" {
- pass "$test"
- }
-}
-
-gdb_exit
-
-return 0
-
+gdb_test "core-file $objdir/$subdir/prelink.core" {Using PIC \(Position Independent Code\) prelink displacement.*} "prelink"
http://sourceware.org/ml/gdb-cvs/2010-03/msg00066.html
16558457783d71e2856ff2b9ceaa83199d2d9811
### src/gdb/ChangeLog 2010/03/08 07:45:49 1.11442
### src/gdb/ChangeLog 2010/03/08 08:32:49 1.11443
## -1,3 +1,8 @@
+2010-03-08 Jan Kratochvil <jan.kratochvil@redhat.com>
+
+ * symfile.c (addr_info_make_relative): New variable sect_name, use it.
+ Do not warn on ".gnu.liblist" and ".gnu.conflict".
+
2010-03-08 Joel Brobecker <brobecker@adacore.com>
Memory error when reading wrong core file.
--- src/gdb/symfile.c 2010/03/05 19:32:44 1.275
+++ src/gdb/symfile.c 2010/03/08 08:32:49 1.276
@@ -592,7 +592,8 @@
for (i = 0; i < addrs->num_sections && addrs->other[i].name; i++)
{
- asection *sect = bfd_get_section_by_name (abfd, addrs->other[i].name);
+ const char *sect_name = addrs->other[i].name;
+ asection *sect = bfd_get_section_by_name (abfd, sect_name);
if (sect)
{
@@ -609,8 +610,22 @@
}
else
{
- warning (_("section %s not found in %s"), addrs->other[i].name,
- bfd_get_filename (abfd));
+ /* This section does not exist in ABFD, which is normally
+ unexpected and we want to issue a warning.
+
+ However, the ELF prelinker does create a couple of sections
+ (".gnu.liblist" and ".gnu.conflict") which are marked in the main
+ executable as loadable (they are loaded in memory from the
+ DYNAMIC segment) and yet are not present in separate debug info
+ files. This is fine, and should not cause a warning. Shared
+ libraries contain just the section ".gnu.liblist" but it is not
+ marked as loadable there. */
+
+ if (!(strcmp (sect_name, ".gnu.liblist") == 0
+ || strcmp (sect_name, ".gnu.conflict") == 0))
+ warning (_("section %s not found in %s"), sect_name,
+ bfd_get_filename (abfd));
+
addrs->other[i].addr = 0;
/* SECTINDEX is invalid if ADDR is zero. */
http://sourceware.org/ml/gdb-cvs/2010-03/msg00138.html
http://sourceware.org/ml/gdb-patches/2010-03/msg00535.html
cc3e71651e2fd0168a2d3dd4efc2d3e15fd508dd
### src/gdb/ChangeLog 2010/03/15 03:48:46 1.11479
### src/gdb/ChangeLog 2010/03/15 09:31:30 1.11480
## -1,3 +1,8 @@
+2010-03-15 Jan Kratochvil <jan.kratochvil@redhat.com>
+
+ * symfile.c (addr_info_make_relative): Ignore also missing ".dynbss"
+ and ".sdynbss". Update the comment.
+
2010-03-15 Jie Zhang <jie@codesourcery.com>
* MAINTAINERS: Update my email address.
--- src/gdb/symfile.c 2010/03/10 18:20:07 1.277
+++ src/gdb/symfile.c 2010/03/15 09:31:34 1.278
@@ -576,16 +576,19 @@
/* This section does not exist in ABFD, which is normally
unexpected and we want to issue a warning.
- However, the ELF prelinker does create a couple of sections
- (".gnu.liblist" and ".gnu.conflict") which are marked in the main
- executable as loadable (they are loaded in memory from the
- DYNAMIC segment) and yet are not present in separate debug info
- files. This is fine, and should not cause a warning. Shared
- libraries contain just the section ".gnu.liblist" but it is not
- marked as loadable there. */
+ However, the ELF prelinker does create a few sections which are
+ marked in the main executable as loadable (they are loaded in
+ memory from the DYNAMIC segment) and yet are not present in
+ separate debug info files. This is fine, and should not cause
+ a warning. Shared libraries contain just the section
+ ".gnu.liblist" but it is not marked as loadable there. There is
+ no other way to identify them than by their name as the sections
+ created by prelink have no special flags. */
if (!(strcmp (sect_name, ".gnu.liblist") == 0
- || strcmp (sect_name, ".gnu.conflict") == 0))
+ || strcmp (sect_name, ".gnu.conflict") == 0
+ || strcmp (sect_name, ".dynbss") == 0
+ || strcmp (sect_name, ".sdynbss") == 0))
warning (_("section %s not found in %s"), sect_name,
bfd_get_filename (abfd));
http://sourceware.org/ml/gdb-patches/2010-03/msg00799.html
Subject: [patch] Fix separate-debug with non-unique section names (PR 11409)
A different version was checked-in but they are interchangeable:
http://sourceware.org/ml/gdb-patches/2010-03/msg00799.html
http://sourceware.org/ml/gdb-cvs/2010-03/msg00241.html
Hi,
gdb-7.1 is now broken for example for debugging /usr/bin/emacs due to:
http://sourceware.org/bugzilla/show_bug.cgi?id=11409
[22] .data PROGBITS 00000000007fe8a0 1fe8a0 215068 00 WA 0 0 32
[23] .data PROGBITS 0000000000a13920 413920 68c6e0 00 WA 0 0 32
It is in fact a regression against gdb-7.0 by me due to:
commit 71d0069a9f238a11f7f455bf6ad2adfc25683521
Author: Jan Kratochvil <jan.kratochvil@redhat.com>
Date: Tue Jan 5 15:51:01 2010 +0000
gdb/
* symfile.c (syms_from_objfile): Remove the !MAINLINE conditional.
as while the code was broken even before the broken relocation was not applied
to mainline binary (before PIE+OSX patches went in).
No regressions on {x86_64,x86_64-m32,i686}-fedora12-linux-gnu.
OK to check-in also for gdb-7.1 (7.1.1)?
Thanks,
Jan
gdb/
2010-03-23 Jan Kratochvil <jan.kratochvil@redhat.com>
* symfile.c (addr_info_make_relative): Move sect declaration to the
outer block. Initialize it to NULL. Prefer SECT->next more than
bfd_get_section_by_name.
gdb/testsuite/
2010-03-23 Jan Kratochvil <jan.kratochvil@redhat.com>
* gdb.base/dup-sect.exp, gdb.base/dup-sect.S: New.
--- a/gdb/symfile.c
+++ b/gdb/symfile.c
@@ -529,6 +529,7 @@ addr_info_make_relative (struct section_addr_info *addrs, bfd *abfd)
asection *lower_sect;
CORE_ADDR lower_offset;
int i;
+ asection *sect;
/* Find lowest loadable section to be used as starting point for
continguous sections. */
@@ -553,11 +554,23 @@ addr_info_make_relative (struct section_addr_info *addrs, bfd *abfd)
(the loadable section directly below it in memory).
this_offset = lower_offset = lower_addr - lower_orig_addr */
+ sect = NULL;
for (i = 0; i < addrs->num_sections && addrs->other[i].name; i++)
{
const char *sect_name = addrs->other[i].name;
- asection *sect = bfd_get_section_by_name (abfd, sect_name);
+ /* Prefer the next section of that we have found last. The separate
+ debug info files have either the same section layout or just a few
+ sections are missing there. On the other hand the section name is not
+ unique and we could find an inappropraite section by its name. */
+
+ if (sect)
+ sect = sect->next;
+ if (sect && strcmp (sect_name, bfd_get_section_name (abfd, sect)) != 0)
+ sect = NULL;
+
+ if (sect == NULL)
+ sect = bfd_get_section_by_name (abfd, sect_name);
if (sect)
{
/* This is the index used by BFD. */
--- /dev/null
+++ b/gdb/testsuite/gdb.base/dup-sect.S
@@ -0,0 +1,22 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+ Copyright 2010 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+ .section sect1, "a"
+var1: .byte 1
+
+ .section sect2, "a"
+var2: .byte 2
--- /dev/null
+++ b/gdb/testsuite/gdb.base/dup-sect.exp
@@ -0,0 +1,79 @@
+# This testcase is part of GDB, the GNU debugger.
+
+# Copyright 2010 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# Test inappropriate offseting of multiple sections with the same name.
+# When kept in object file (before final executable link) it still works.
+# When separate debug info file is not used it still works.
+# When the ELF symbol table is kept in the main binary it still works.
+# Used .S file as in .c file we would need __attriute__((section)) which is
+# a GCC extension.
+
+# This test can only be run on targets which support ELF and use gas.
+# For now pick a sampling of likely targets.
+if {![istarget *-*-linux*]
+ && ![istarget *-*-gnu*]
+ && ![istarget *-*-elf*]
+ && ![istarget arm-*-eabi*]
+ && ![istarget powerpc-*-eabi*]} {
+ return 0
+}
+
+set testfile dup-sect
+set srcfile ${testfile}.S
+set srcmainfile start.c
+set executable ${testfile}
+set binfile ${objdir}/${subdir}/${executable}
+
+if {[build_executable ${testfile}.exp $executable [list ${srcfile} ${srcmainfile}] {}] == -1} {
+ return -1
+}
+
+set test "rename section"
+set objcopy_program [transform objcopy]
+set result [catch "exec $objcopy_program --rename-section sect2=sect1 $binfile" output]
+verbose "result is $result"
+verbose "output is $output"
+if {$result != 0} {
+ fail $test
+ return
+}
+pass $test
+
+set test "split"
+if {[gdb_gnu_strip_debug $binfile] != 0} {
+ fail $test
+} else {
+ pass $test
+}
+
+# gdb_gnu_strip_debug uses only --strip-debug and keeps the ELF symbol table
+# in $binfile.
+set test "strip"
+set strip_program [transform strip]
+set result [catch "exec $strip_program $binfile" output]
+verbose "result is $result"
+verbose "output is $output"
+if {$result != 0} {
+ fail $test
+ return
+}
+pass $test
+
+clean_restart $executable
+
+gdb_test "p/d *(const char *) &var1" " = 1" "var1 after strip"
+gdb_test "p/d *(const char *) &var2" " = 2" "var2 after strip"
[patch] Fix breakpoint at *_start
http://sourceware.org/ml/gdb-patches/2010-04/msg00059.html
http://sourceware.org/ml/gdb-cvs/2010-04/msg00029.html
### src/gdb/ChangeLog 2010/04/04 13:54:42 1.11568
### src/gdb/ChangeLog 2010/04/04 22:12:04 1.11569
## -1,5 +1,10 @@
2010-04-04 Jan Kratochvil <jan.kratochvil@redhat.com>
+ * infcmd.c (run_command_1): Call proceed with regcache_read_pc address.
+ * config/djgpp/fnchange.lst: Add translation for break-entry.exp.
+
+2010-04-04 Jan Kratochvil <jan.kratochvil@redhat.com>
+
* breakpoint.c (bpstat_find_step_resume_breakpoint): Remove.
* breakpoint.h (bpstat_find_step_resume_breakpoint): Remove.
--- src/gdb/infcmd.c 2010/03/25 20:48:53 1.263
+++ src/gdb/infcmd.c 2010/04/04 22:12:04 1.264
@@ -580,8 +580,9 @@
has done its thing; now we are setting up the running program. */
post_create_inferior (&current_target, 0);
- /* Start the target running. */
- proceed ((CORE_ADDR) -1, TARGET_SIGNAL_0, 0);
+ /* Start the target running. Do not use -1 continuation as it would skip
+ breakpoint right at the entry point. */
+ proceed (regcache_read_pc (get_current_regcache ()), TARGET_SIGNAL_0, 0);
/* Since there was no error, there's no need to finish the thread
states here. */
--- src/gdb/config/djgpp/fnchange.lst 2010/02/01 19:27:55 1.108
+++ src/gdb/config/djgpp/fnchange.lst 2010/04/04 22:12:07 1.109
@@ -371,6 +371,7 @@
@V@/gdb/testsuite/gdb.arch/powerpc-prologue.exp @V@/gdb/testsuite/gdb.arch/ppc-prologue.exp
@V@/gdb/testsuite/gdb.base/bitfields2.c @V@/gdb/testsuite/gdb.base/bitfiel2.c
@V@/gdb/testsuite/gdb.base/bitfields2.exp @V@/gdb/testsuite/gdb.base/bitfiel2.exp
+@V@/gdb/testsuite/gdb.base/break-entry.exp @V@/gdb/testsuite/gdb.base/brkentry.exp
@V@/gdb/testsuite/gdb.base/coremaker2.c @V@/gdb/testsuite/gdb.base/core2maker.c
@V@/gdb/testsuite/gdb.base/hashline1.exp @V@/gdb/testsuite/gdb.base/hash1line.exp
@V@/gdb/testsuite/gdb.base/hashline2.exp @V@/gdb/testsuite/gdb.base/hash2line.exp
### src/gdb/testsuite/ChangeLog 2010/04/02 05:13:07 1.2218
### src/gdb/testsuite/ChangeLog 2010/04/04 22:12:09 1.2219
## -1,3 +1,7 @@
+2010-04-04 Jan Kratochvil <jan.kratochvil@redhat.com>
+
+ * gdb.base/break-entry.exp: New.
+
2010-04-02 Hui Zhu <teawater@gmail.com>
Michael Snyder <msnyder@vmware.com>
--- src/gdb/testsuite/gdb.base/break-entry.exp
+++ src/gdb/testsuite/gdb.base/break-entry.exp 2010-04-05 20:17:39.234684000 +0000
@@ -0,0 +1,43 @@
+# Copyright (C) 2010 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# Test inferior can stop at its very first instruction, usually "_start".
+# Dynamic executables have first instruction in ld.so.
+
+set testfile break-entry
+if { [prepare_for_testing ${testfile}.exp ${testfile} start.c {additional_flags=-static}] } {
+ return -1
+}
+
+set test "info files"
+set entry ""
+gdb_test_multiple $test $test {
+ -re "\r\n\[\t \]*Entry point:\[\t \]*(0x\[0-9a-f\]+)\r\n.*$gdb_prompt $" {
+ set entry $expect_out(1,string)
+ pass $test
+ }
+}
+if {$entry == ""} {
+ untested ${testfile}.exp
+ return
+}
+
+if ![runto "*$entry"] {
+ return
+}
+gdb_test {p/x $pc} " = $entry"
+
+gdb_breakpoint "main"
+gdb_continue_to_breakpoint "main" "main.*"
https://bugzilla.redhat.com/show_bug.cgi?id=590648
Re: [rfc] Work around invalid G++ DWARF for unnamed aggregates
http://sourceware.org/ml/gdb-patches/2010-03/msg00909.html
commit 5e40af195bd74a66d300d8f481cab1f2ba533f3a
[ cut only a part of it ]
--- a/gdb/completer.c
+++ b/gdb/completer.c
@@ -401,7 +401,7 @@ add_struct_fields (struct type *type, int *nextp, char **output,
computed_type_name = 1;
}
/* Omit constructors from the completion list. */
- if (type_name && strcmp (type_name, name))
+ if (!type_name || strcmp (type_name, name))
{
output[*nextp] = xstrdup (name);
++*nextp;
https://bugzilla.redhat.com/show_bug.cgi?id=578136
https://bugzilla.redhat.com/show_bug.cgi?id=593926
http://sourceware.org/ml/gdb-patches/2010-04/msg00820.html
http://sourceware.org/ml/gdb-cvs/2010-04/msg00240.html
### src/gdb/ChangeLog 2010/04/23 18:09:16 1.11678
### src/gdb/ChangeLog 2010/04/23 21:44:19 1.11679
## -1,3 +1,14 @@
+2010-04-23 Daniel Jacobowitz <dan@codesourcery.com>
+ Paul Pluzhnikov <ppluzhnikov@google.com>
+ Jan Kratochvil <jan.kratochvil@redhat.com>
+
+ Fix deadlock on looped list of loaded shared objects.
+ * solib-svr4.c (LM_PREV): New function.
+ (IGNORE_FIRST_LINK_MAP_ENTRY): Use it.
+ (svr4_current_sos): Check for correct l_prev. New variables prev_lm
+ and next_lm. Clear prev_lm for solib_svr4_r_ldsomap.
+ * config/djgpp/fnchange.lst: Add translation for solib-corrupted.exp.
+
2010-04-23 Doug Evans <dje@google.com>
* configure.ac (CONFIG_SRCS): Add py-auto-load.o even if not using
--- src/gdb/solib-svr4.c 2010/03/11 22:07:02 1.130
+++ src/gdb/solib-svr4.c 2010/04/23 21:44:19 1.131
@@ -272,6 +272,16 @@
}
static CORE_ADDR
+LM_PREV (struct so_list *so)
+{
+ struct link_map_offsets *lmo = svr4_fetch_link_map_offsets ();
+ struct type *ptr_type = builtin_type (target_gdbarch)->builtin_data_ptr;
+
+ return extract_typed_address (so->lm_info->lm + lmo->l_prev_offset,
+ ptr_type);
+}
+
+static CORE_ADDR
LM_NAME (struct so_list *so)
{
struct link_map_offsets *lmo = svr4_fetch_link_map_offsets ();
@@ -284,16 +294,12 @@
static int
IGNORE_FIRST_LINK_MAP_ENTRY (struct so_list *so)
{
- struct link_map_offsets *lmo = svr4_fetch_link_map_offsets ();
- struct type *ptr_type = builtin_type (target_gdbarch)->builtin_data_ptr;
-
/* Assume that everything is a library if the dynamic loader was loaded
late by a static executable. */
if (exec_bfd && bfd_get_section_by_name (exec_bfd, ".dynamic") == NULL)
return 0;
- return extract_typed_address (so->lm_info->lm + lmo->l_prev_offset,
- ptr_type) == 0;
+ return LM_PREV (so) == 0;
}
/* Per pspace SVR4 specific data. */
@@ -1101,7 +1107,7 @@
static struct so_list *
svr4_current_sos (void)
{
- CORE_ADDR lm;
+ CORE_ADDR lm, prev_lm;
struct so_list *head = 0;
struct so_list **link_ptr = &head;
CORE_ADDR ldsomap = 0;
@@ -1120,6 +1126,7 @@
/* Walk the inferior's link map list, and build our list of
`struct so_list' nodes. */
+ prev_lm = 0;
lm = solib_svr4_r_map (info);
while (lm)
@@ -1127,6 +1134,7 @@
struct link_map_offsets *lmo = svr4_fetch_link_map_offsets ();
struct so_list *new = XZALLOC (struct so_list);
struct cleanup *old_chain = make_cleanup (xfree, new);
+ CORE_ADDR next_lm;
new->lm_info = xmalloc (sizeof (struct lm_info));
make_cleanup (xfree, new->lm_info);
@@ -1138,14 +1146,21 @@
read_memory (lm, new->lm_info->lm, lmo->link_map_size);
- lm = LM_NEXT (new);
+ next_lm = LM_NEXT (new);
+
+ if (LM_PREV (new) != prev_lm)
+ {
+ warning (_("Corrupted shared library list"));
+ free_so (new);
+ next_lm = 0;
+ }
/* For SVR4 versions, the first entry in the link map is for the
inferior executable, so we must ignore it. For some versions of
SVR4, it has no name. For others (Solaris 2.3 for example), it
does have a name, so we can no longer use a missing name to
decide when to ignore it. */
- if (IGNORE_FIRST_LINK_MAP_ENTRY (new) && ldsomap == 0)
+ else if (IGNORE_FIRST_LINK_MAP_ENTRY (new) && ldsomap == 0)
{
info->main_lm_addr = new->lm_info->lm_addr;
free_so (new);
@@ -1182,12 +1197,18 @@
}
}
+ prev_lm = lm;
+ lm = next_lm;
+
/* On Solaris, the dynamic linker is not in the normal list of
shared objects, so make sure we pick it up too. Having
symbol information for the dynamic linker is quite crucial
for skipping dynamic linker resolver code. */
if (lm == 0 && ldsomap == 0)
- lm = ldsomap = solib_svr4_r_ldsomap (info);
+ {
+ lm = ldsomap = solib_svr4_r_ldsomap (info);
+ prev_lm = 0;
+ }
discard_cleanups (old_chain);
}
--- src/gdb/config/djgpp/fnchange.lst 2010/04/09 15:15:05 1.112
+++ src/gdb/config/djgpp/fnchange.lst 2010/04/23 21:44:19 1.113
@@ -397,6 +397,7 @@
@V@/gdb/testsuite/gdb.base/siginfo-obj.c @V@/gdb/testsuite/gdb.base/si-obj.c
@V@/gdb/testsuite/gdb.base/siginfo-addr.exp @V@/gdb/testsuite/gdb.base/si-addr.exp
@V@/gdb/testsuite/gdb.base/siginfo-obj.exp @V@/gdb/testsuite/gdb.base/si-obj.exp
+@V@/gdb/testsuite/gdb.base/solib-corrupted.exp @V@/gdb/testsuite/gdb.base/so-crptd.exp
@V@/gdb/testsuite/gdb.base/solib-disc.c @V@/gdb/testsuite/gdb.base/so-disc.c
@V@/gdb/testsuite/gdb.base/solib-display-lib.c @V@/gdb/testsuite/gdb.base/so-displib.c
@V@/gdb/testsuite/gdb.base/solib-display-main.c @V@/gdb/testsuite/gdb.base/so-dispmain.c
### src/gdb/testsuite/ChangeLog 2010/04/23 18:03:31 1.2252
### src/gdb/testsuite/ChangeLog 2010/04/23 21:44:20 1.2253
## -1,3 +1,8 @@
+2010-04-23 Jan Kratochvil <jan.kratochvil@redhat.com>
+
+ Fix deadlock on looped list of loaded shared objects.
+ * gdb.base/solib-corrupted.exp: New.
+
2010-04-23 Doug Evans <dje@google.com>
* gdb.python/py-section-script.c: New file.
--- src/gdb/testsuite/gdb.base/solib-corrupted.exp
+++ src/gdb/testsuite/gdb.base/solib-corrupted.exp 2010-05-24 18:00:52.057995000 +0000
@@ -0,0 +1,46 @@
+# Copyright 2010 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+set testfile "solib-corrupted"
+set srcfile start.c
+
+if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile}] } {
+ untested ${testfile}.exp
+ return -1
+}
+
+if ![runto_main] {
+ fail "Can't run to main"
+ return
+}
+
+gdb_test "info sharedlibrary" "" "normal list"
+
+# GDB checks there for matching L_PREV.
+set test "make solibs looping"
+gdb_test_multiple "p/x _r_debug->r_map->l_next = _r_debug->r_map" $test {
+ -re "(No symbol \"_r_debug\" in current context\\.|Attempt to extract a component of a value that is not a structure pointer\\.)\r\n$gdb_prompt $" {
+ # glibc debug info is not available and it is too difficult to find and
+ # parse it from this testcase without the gdb supporting functions.
+ verbose -log "no _r_debug symbol has been found"
+ xfail $test
+ untested ${testfile}.exp
+ return
+ }
+ -re " = 0x\[0-9a-f\]+\r\n$gdb_prompt $" {
+ pass $test
+ }
+}
+gdb_test "info sharedlibrary" "warning: Corrupted shared library list\r\n.*" "corrupted list"
Re: [patch] Fix crash on /proc/PID/stat race
http://sourceware.org/ml/gdb-patches/2010-05/msg00685.html
http://sourceware.org/ml/gdb-cvs/2010-05/msg00244.html
### src/gdb/ChangeLog 2010/05/28 18:00:41 1.11855
### src/gdb/ChangeLog 2010/05/28 18:23:13 1.11856
## -1,5 +1,10 @@
2010-05-28 Jan Kratochvil <jan.kratochvil@redhat.com>
+ * linux-nat.c (linux_nat_core_of_thread_1): Fix crash on invalid
+ CONTENT.
+
+2010-05-28 Jan Kratochvil <jan.kratochvil@redhat.com>
+
* linux-nat.c (linux_nat_wait_1): Do not call
linux_nat_core_of_thread_1 on TARGET_WAITKIND_EXITED or
TARGET_WAITKIND_SIGNALLED.
--- src/gdb/linux-nat.c 2010/05/28 18:00:46 1.169
+++ src/gdb/linux-nat.c 2010/05/28 18:23:15 1.170
@@ -5509,15 +5509,21 @@
make_cleanup (xfree, content);
p = strchr (content, '(');
- p = strchr (p, ')') + 2; /* skip ")" and a whitespace. */
+
+ /* Skip ")". */
+ if (p != NULL)
+ p = strchr (p, ')');
+ if (p != NULL)
+ p++;
/* If the first field after program name has index 0, then core number is
the field with index 36. There's no constant for that anywhere. */
- p = strtok_r (p, " ", &ts);
- for (i = 0; i != 36; ++i)
+ if (p != NULL)
+ p = strtok_r (p, " ", &ts);
+ for (i = 0; p != NULL && i != 36; ++i)
p = strtok_r (NULL, " ", &ts);
- if (sscanf (p, "%d", &core) == 0)
+ if (p == NULL || sscanf (p, "%d", &core) == 0)
core = -1;
do_cleanups (back_to);
### src/gdb/gdbserver/ChangeLog 2010/05/26 22:40:22 1.386
### src/gdb/gdbserver/ChangeLog 2010/05/28 18:23:15 1.387
## -1,3 +1,8 @@
+2010-05-28 Jan Kratochvil <jan.kratochvil@redhat.com>
+
+ * linux-low.c (linux_core_of_thread): Fix crash on invalid CONTENT.
+ New comment.
+
2010-05-26 Ozkan Sezer <sezeroz@gmail.com>
* gdbreplay.c (remote_open): Check error return from socket() call by
--- src/gdb/gdbserver/linux-low.c 2010/05/03 04:02:20 1.148
+++ src/gdb/gdbserver/linux-low.c 2010/05/28 18:23:15 1.149
@@ -4346,13 +4346,21 @@
}
p = strchr (content, '(');
- p = strchr (p, ')') + 2; /* skip ")" and a whitespace. */
- p = strtok_r (p, " ", &ts);
- for (i = 0; i != 36; ++i)
+ /* Skip ")". */
+ if (p != NULL)
+ p = strchr (p, ')');
+ if (p != NULL)
+ p++;
+
+ /* If the first field after program name has index 0, then core number is
+ the field with index 36. There's no constant for that anywhere. */
+ if (p != NULL)
+ p = strtok_r (p, " ", &ts);
+ for (i = 0; p != NULL && i != 36; ++i)
p = strtok_r (NULL, " ", &ts);
- if (sscanf (p, "%d", &core) == 0)
+ if (p == NULL || sscanf (p, "%d", &core) == 0)
core = -1;
free (content);
Re: [patch] testsuite: watchthreads-reorder: Linux kernel compat.
http://sourceware.org/ml/gdb-patches/2010-05/msg00696.html
http://sourceware.org/ml/gdb-cvs/2010-05/msg00255.html
### src/gdb/testsuite/ChangeLog 2010/05/28 23:47:40 1.2293
### src/gdb/testsuite/ChangeLog 2010/05/31 03:31:16 1.2294
## -1,3 +1,11 @@
+2010-05-31 Jan Kratochvil <jan.kratochvil@redhat.com>
+
+ Accept the new Linux kernel "t (tracing stop)" string.
+ * gdb.threads/watchthreads-reorder.c (thread1_func, thread2_func):
+ Update comment.
+ (state_wait) <T (tracing stop)>: New.
+ (main): Update the state_wait expect string.
+
2010-05-28 Pedro Alves <pedro@codesourcery.com>
* limits.c, limits.exp: Delete files.
--- src/gdb/testsuite/gdb.threads/watchthreads-reorder.c 2010/01/20 21:09:30 1.3
+++ src/gdb/testsuite/gdb.threads/watchthreads-reorder.c 2010/05/31 03:31:17 1.4
@@ -99,7 +99,7 @@
rwatch_store = thread1_rwatch;
- /* Be sure the "T (tracing stop)" test can proceed for both threads. */
+ /* Be sure the "t (tracing stop)" test can proceed for both threads. */
timed_mutex_lock (&terminate_mutex);
i = pthread_mutex_unlock (&terminate_mutex);
assert (i == 0);
@@ -125,7 +125,7 @@
rwatch_store = thread2_rwatch;
- /* Be sure the "T (tracing stop)" test can proceed for both threads. */
+ /* Be sure the "t (tracing stop)" test can proceed for both threads. */
timed_mutex_lock (&terminate_mutex);
i = pthread_mutex_unlock (&terminate_mutex);
assert (i == 0);
@@ -211,6 +211,13 @@
do
{
state = proc_string (filename, "State:\t");
+
+ /* torvalds/linux-2.6.git 464763cf1c6df632dccc8f2f4c7e50163154a2c0
+ has changed "T (tracing stop)" to "t (tracing stop)". Make the GDB
+ testcase backward compatible with older Linux kernels. */
+ if (strcmp (state, "T (tracing stop)") == 0)
+ state = "t (tracing stop)";
+
if (strcmp (state, wanted) == 0)
{
free (filename);
@@ -336,9 +343,9 @@
{
/* s390x-unknown-linux-gnu will fail with "R (running)". */
- state_wait (thread1_tid, "T (tracing stop)");
+ state_wait (thread1_tid, "t (tracing stop)");
- state_wait (thread2_tid, "T (tracing stop)");
+ state_wait (thread2_tid, "t (tracing stop)");
}
cleanup ();