From a30b29253390982c526c8847e52d73fd2fb4658e Mon Sep 17 00:00:00 2001 From: Jan Kratochvil Date: Jan 02 2011 04:04:50 +0000 Subject: - Backport gdb.base/break-interp.exp test (+prelink fix) on PPC (BZ 663449). - Backport gdb.cp/infcall-dlopen.exp test (BZ 639645). - New testcase py-prettyprint.exp:print hint_error (for BZ 611569, BZ 629236). - New test gdb.arch/x86_64-pid0-core.exp for kernel PID 0 cores (BZ 611435). --- diff --git a/gdb-ppc-test-break-interp-1of6.patch b/gdb-ppc-test-break-interp-1of6.patch new file mode 100644 index 0000000..210b136 --- /dev/null +++ b/gdb-ppc-test-break-interp-1of6.patch @@ -0,0 +1,126 @@ +http://sourceware.org/ml/gdb-cvs/2010-07/msg00070.html + +[ Left only lib/gdb.exp. ] + +### src/gdb/testsuite/ChangeLog 2010/07/07 18:49:50 1.2377 +### src/gdb/testsuite/ChangeLog 2010/07/12 17:33:14 1.2378 +## -1,3 +1,33 @@ ++2010-07-12 Ulrich Weigand ++ H.J. Lu ++ ++ * lib/gdb.exp (is_ilp32_target): New. ++ (is_lp64_target): Likewise. ++ ++ * gdb.arch/amd64-byte.exp: Use is_lp64_target to check 64bit ++ target. ++ * gdb.arch/amd64-disp-step.exp: Likewise. ++ * gdb.arch/amd64-dword.exp: Likewise. ++ * gdb.arch/amd64-i386-address.exp: Likewise. ++ * gdb.arch/amd64-word.exp: Likewise. ++ ++ * gdb.arch/i386-avx.exp: Use is_ilp32_target to check for 32bit ++ target. ++ * gdb.arch/i386-bp_permanent.exp: Likewise. ++ * gdb.arch/i386-byte.exp: Likewise. ++ * gdb.arch/i386-disp-step.exp: Likewise. ++ * gdb.arch/i386-gnu-cfi.exp: Likewise. ++ * gdb.arch/i386-prologue.exp: Likewise. ++ * gdb.arch/i386-size-overlap.exp: Likewise. ++ * gdb.arch/i386-size.exp: Likewise. ++ * gdb.arch/i386-sse.exp: Likewise. ++ * gdb.arch/i386-unwind.exp: Likewise. ++ * gdb.arch/i386-word.exp: Likewise. ++ ++ * gdb.arch/ppc64-atomic-inst.exp: Use is_lp64_target to execute ++ test only when building 64-bit executables. Do not hard-code ++ -m64 option. ++ + 2010-07-07 Doug Evans + + * lib/gdb.exp (gdb_test_list_exact): New function. +--- src/gdb/testsuite/lib/gdb.exp 2010/07/07 18:49:51 1.153 ++++ src/gdb/testsuite/lib/gdb.exp 2010/07/12 17:33:15 1.154 +@@ -1454,6 +1454,83 @@ + return 1 + } + ++# Return 1 if target is ILP32. ++# This cannot be decided simply from looking at the target string, ++# as it might depend on externally passed compiler options like -m64. ++proc is_ilp32_target {} { ++ global is_ilp32_target_saved ++ ++ # Use the cached value, if it exists. Cache value per "board" to handle ++ # runs with multiple options (e.g. unix/{-m32,-64}) correctly. ++ set me "is_ilp32_target" ++ set board [target_info name] ++ if [info exists is_ilp32_target_saved($board)] { ++ verbose "$me: returning saved $is_ilp32_target_saved($board)" 2 ++ return $is_ilp32_target_saved($board) ++ } ++ ++ ++ set src ilp32[pid].c ++ set obj ilp32[pid].o ++ ++ set f [open $src "w"] ++ puts $f "int dummy\[sizeof (int) == 4" ++ puts $f " && sizeof (void *) == 4" ++ puts $f " && sizeof (long) == 4 ? 1 : -1\];" ++ close $f ++ ++ verbose "$me: compiling testfile $src" 2 ++ set lines [gdb_compile $src $obj object {quiet}] ++ file delete $src ++ file delete $obj ++ ++ if ![string match "" $lines] then { ++ verbose "$me: testfile compilation failed, returning 0" 2 ++ return [set is_ilp32_target_saved($board) 0] ++ } ++ ++ verbose "$me: returning 1" 2 ++ return [set is_ilp32_target_saved($board) 1] ++} ++ ++# Return 1 if target is LP64. ++# This cannot be decided simply from looking at the target string, ++# as it might depend on externally passed compiler options like -m64. ++proc is_lp64_target {} { ++ global is_lp64_target_saved ++ ++ # Use the cached value, if it exists. Cache value per "board" to handle ++ # runs with multiple options (e.g. unix/{-m32,-64}) correctly. ++ set me "is_lp64_target" ++ set board [target_info name] ++ if [info exists is_lp64_target_saved($board)] { ++ verbose "$me: returning saved $is_lp64_target_saved($board)" 2 ++ return $is_lp64_target_saved($board) ++ } ++ ++ set src lp64[pid].c ++ set obj lp64[pid].o ++ ++ set f [open $src "w"] ++ puts $f "int dummy\[sizeof (int) == 4" ++ puts $f " && sizeof (void *) == 8" ++ puts $f " && sizeof (long) == 8 ? 1 : -1\];" ++ close $f ++ ++ verbose "$me: compiling testfile $src" 2 ++ set lines [gdb_compile $src $obj object {quiet}] ++ file delete $src ++ file delete $obj ++ ++ if ![string match "" $lines] then { ++ verbose "$me: testfile compilation failed, returning 0" 2 ++ return [set is_lp64_target_saved($board) 0] ++ } ++ ++ verbose "$me: returning 1" 2 ++ return [set is_lp64_target_saved($board) 1] ++} ++ + # Run a test on the target to see if it supports vmx hardware. Return 0 if so, + # 1 if it does not. Based on 'check_vmx_hw_available' from the GCC testsuite. + diff --git a/gdb-ppc-test-break-interp-2of6.patch b/gdb-ppc-test-break-interp-2of6.patch new file mode 100644 index 0000000..226203d --- /dev/null +++ b/gdb-ppc-test-break-interp-2of6.patch @@ -0,0 +1,46 @@ +http://sourceware.org/ml/gdb-cvs/2010-09/msg00070.html + +### src/gdb/testsuite/ChangeLog 2010/09/08 23:41:39 1.2442 +### src/gdb/testsuite/ChangeLog 2010/09/09 20:00:48 1.2443 +## -1,3 +1,8 @@ ++2010-09-09 Jan Kratochvil ++ ++ * gdb.base/break-interp.exp (reach): Permit leading . for ppc64. ++ (test_ld) : New. ++ + 2010-09-08 Daniel Jacobowitz + + * gdb.cp/templates.exp (test_template_args): Allow "struct". +--- src/gdb/testsuite/gdb.base/break-interp.exp 2010/07/05 18:04:33 1.18 ++++ src/gdb/testsuite/gdb.base/break-interp.exp 2010/09/09 20:00:49 1.19 +@@ -136,10 +136,10 @@ + } + exp_continue + } +- -re "Breakpoint \[0-9\]+, $func \\(.*\\) at .*:\[0-9\]+\r\n.*$gdb_prompt $" { ++ -re "Breakpoint \[0-9\]+, \\.?$func \\(.*\\) at .*:\[0-9\]+\r\n.*$gdb_prompt $" { + pass $test + } +- -re "Breakpoint \[0-9\]+, \[0-9xa-f\]+ in $func \\(\\).*\r\n$gdb_prompt $" { ++ -re "Breakpoint \[0-9\]+, \[0-9xa-f\]+ in \\.?$func \\(\\).*\r\n$gdb_prompt $" { + pass $test + } + } +@@ -399,6 +399,17 @@ + pass $test + } + } ++ # `info sym' cannot be tested for .opd as the binary may not have ++ # symbols. ++ if [istarget powerpc64-*] { ++ set test "convert entry point" ++ gdb_test_multiple "p *(void(*)(void) *) 0x$entrynohex" $test { ++ -re " =( \\(\[^0-9\]*\\))? 0x(\[0-9a-f\]+)( < \[^\r\n\]*)?\r\n$gdb_prompt $" { ++ set entrynohex $expect_out(2,string) ++ pass $test ++ } ++ } ++ } + if {$entrynohex != ""} { + gdb_test "break *0x$entrynohex" "" "break at entry point" + gdb_test "continue" "\r\nBreakpoint \[0-9\]+, 0x0*$entrynohex in .*" "entry point reached" diff --git a/gdb-ppc-test-break-interp-3of6.patch b/gdb-ppc-test-break-interp-3of6.patch new file mode 100644 index 0000000..b45bd8f --- /dev/null +++ b/gdb-ppc-test-break-interp-3of6.patch @@ -0,0 +1,24 @@ +http://sourceware.org/ml/gdb-cvs/2010-09/msg00077.html + +### src/gdb/testsuite/ChangeLog 2010/09/09 20:00:48 1.2443 +### src/gdb/testsuite/ChangeLog 2010/09/10 20:29:25 1.2444 +## -1,3 +1,8 @@ ++2010-09-10 Edjunior Barbosa Machado ++ ++ * gdb.base/break-interp.exp (test_ld) : Add ++ is_lp64_target to check 64bit target. ++ + 2010-09-09 Jan Kratochvil + + * gdb.base/break-interp.exp (reach): Permit leading . for ppc64. +--- src/gdb/testsuite/gdb.base/break-interp.exp 2010/09/09 20:00:49 1.19 ++++ src/gdb/testsuite/gdb.base/break-interp.exp 2010/09/10 20:29:25 1.20 +@@ -401,7 +401,7 @@ + } + # `info sym' cannot be tested for .opd as the binary may not have + # symbols. +- if [istarget powerpc64-*] { ++ if {[istarget powerpc64-*] && [is_lp64_target]} { + set test "convert entry point" + gdb_test_multiple "p *(void(*)(void) *) 0x$entrynohex" $test { + -re " =( \\(\[^0-9\]*\\))? 0x(\[0-9a-f\]+)( < \[^\r\n\]*)?\r\n$gdb_prompt $" { diff --git a/gdb-ppc-test-break-interp-4of6.patch b/gdb-ppc-test-break-interp-4of6.patch new file mode 100644 index 0000000..58e6d8d --- /dev/null +++ b/gdb-ppc-test-break-interp-4of6.patch @@ -0,0 +1,89 @@ +http://sourceware.org/ml/gdb-cvs/2010-10/msg00065.html + +### src/gdb/testsuite/ChangeLog 2010/10/08 18:28:46 1.2471 +### src/gdb/testsuite/ChangeLog 2010/10/11 08:45:11 1.2472 +## -1,3 +1,10 @@ ++2010-10-11 Jan Kratochvil ++ ++ Fix results of prelinked PIEs on ppc*. ++ * gdb.base/break-interp.exp (reach, test_core, test_attach_gdb): ++ Accept also DISPLACEMENT "PRESENT". ++ (main): Replace "ZERO" displacements by "PRESENT". ++ + 2010-10-08 Sami Wagiaalla + + * gdb.cp/oranking.exp: New test. +--- src/gdb/testsuite/gdb.base/break-interp.exp 2010/09/10 20:29:25 1.20 ++++ src/gdb/testsuite/gdb.base/break-interp.exp 2010/10/11 08:45:12 1.21 +@@ -109,7 +109,9 @@ + } + + # `runto' does not check we stopped really at the function we specified. +-# DISPLACEMENT can be "NONE", "ZERO" or "NONZERO" ++# DISPLACEMENT can be "NONE" for no message to be present, "ZERO" for ++# displacement of 0 bytes to be present, "NONZERO" for displacement of non-0 ++# bytes to be present and "PRESENT" if both "ZERO" and "NONZERO" are valid. + proc reach {func command displacement} { + global gdb_prompt expect_out + +@@ -128,7 +130,7 @@ + } else { + set case "NONZERO" + } +- if {$displacement == $case} { ++ if {$displacement == $case || $displacement == "PRESENT"} { + pass $test_displacement + set displacement "FOUND-$displacement" + } else { +@@ -184,7 +186,7 @@ + } else { + set case "NONZERO" + } +- if {$displacement == $case} { ++ if {$displacement == $case || $displacement == "PRESENT"} { + pass $test_displacement + set displacement "FOUND-$displacement" + } else { +@@ -241,7 +243,7 @@ + } else { + set case "NONZERO" + } +- if {$displacement == $case} { ++ if {$displacement == $case || $displacement == "PRESENT"} { + pass $test_displacement + set displacement "FOUND-$displacement" + } else { +@@ -428,7 +430,7 @@ + } else { + set case "NONZERO" + } +- if {$displacement == $case} { ++ if {$displacement == $case || $displacement == "PRESENT"} { + pass $test_displacement + set displacement "FOUND-$displacement" + } else { +@@ -533,7 +535,10 @@ + if {$ldprelink == "NO"} { + set displacement "NONZERO" + } else { +- set displacement "ZERO" ++ # x86* kernel loads prelinked PIE binary at its prelinked address ++ # but ppc* kernel loads it at a random address. prelink normally ++ # skips PIE binaries during the system scan. ++ set displacement "PRESENT" + } + test_ld $interp 0 [expr {$ldsepdebug == "NO"}] $displacement + +@@ -582,7 +587,11 @@ + } elseif {$binprelink == "NO"} { + set displacement "NONZERO" + } else { +- set displacement "ZERO" ++ # x86* kernel loads prelinked PIE binary at its ++ # prelinked address but ppc* kernel loads it at ++ # a random address. prelink normally skips PIE ++ # binaries during the system scan. ++ set displacement "PRESENT" + } + + if {[prelink$binprelink $relink_args [file tail $exec]] diff --git a/gdb-ppc-test-break-interp-5of6.patch b/gdb-ppc-test-break-interp-5of6.patch new file mode 100644 index 0000000..cbb1b2b --- /dev/null +++ b/gdb-ppc-test-break-interp-5of6.patch @@ -0,0 +1,177 @@ +http://sourceware.org/ml/gdb-cvs/2010-10/msg00066.html + +### src/gdb/testsuite/ChangeLog 2010/10/11 08:45:11 1.2472 +### src/gdb/testsuite/ChangeLog 2010/10/11 08:47:47 1.2473 +## -1,5 +1,13 @@ + 2010-10-11 Jan Kratochvil + ++ Fix missing _start PIE relocation on ppc64 due to stop on dl_main. ++ * break-interp.exp (reach): Move the core body ... ++ (reach_1): ... here. Use stop-on-solib-events for _dl_debug_state. ++ (test_ld): Provide always real argument, even to the linker. Replace ++ dl_main by _dl_debug_state. ++ ++2010-10-11 Jan Kratochvil ++ + Fix results of prelinked PIEs on ppc*. + * gdb.base/break-interp.exp (reach, test_core, test_attach_gdb): + Accept also DISPLACEMENT "PRESENT". +--- src/gdb/testsuite/gdb.base/break-interp.exp 2010/10/11 08:45:12 1.21 ++++ src/gdb/testsuite/gdb.base/break-interp.exp 2010/10/11 08:47:47 1.22 +@@ -108,47 +108,87 @@ + } + } + +-# `runto' does not check we stopped really at the function we specified. +-# DISPLACEMENT can be "NONE" for no message to be present, "ZERO" for +-# displacement of 0 bytes to be present, "NONZERO" for displacement of non-0 +-# bytes to be present and "PRESENT" if both "ZERO" and "NONZERO" are valid. +-proc reach {func command displacement} { ++# Implementation of reach. ++ ++proc reach_1 {func command displacement} { + global gdb_prompt expect_out + +- global pf_prefix +- set old_ldprefix $pf_prefix +- lappend pf_prefix "reach-$func:" ++ if {$func == "_dl_debug_state"} { ++ # Breakpoint on _dl_debug_state can have problems due to its overlap ++ # with the existing internal breakpoint from GDB. ++ gdb_test_no_output "set stop-on-solib-events 1" ++ } elseif {! [gdb_breakpoint $func allow-pending]} { ++ return ++ } + +- if [gdb_breakpoint $func allow-pending] { +- 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 || $displacement == "PRESENT"} { +- pass $test_displacement +- set displacement "FOUND-$displacement" +- } else { +- fail $test_displacement +- } +- exp_continue ++ set test "reach" ++ set test_displacement "seen displacement message as $displacement" ++ set debug_state_count 0 ++ 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" + } +- -re "Breakpoint \[0-9\]+, \\.?$func \\(.*\\) at .*:\[0-9\]+\r\n.*$gdb_prompt $" { ++ if {$displacement == $case || $displacement == "PRESENT"} { ++ pass $test_displacement ++ set displacement "FOUND-$displacement" ++ } else { ++ fail $test_displacement ++ } ++ exp_continue ++ } ++ -re "Breakpoint \[0-9\]+, \\.?$func \\(.*\\) at .*:\[0-9\]+\r\n.*$gdb_prompt $" { ++ if {$func == "_dl_debug_state"} { ++ fail $test ++ } else { + pass $test + } +- -re "Breakpoint \[0-9\]+, \[0-9xa-f\]+ in \\.?$func \\(\\).*\r\n$gdb_prompt $" { ++ } ++ -re "Breakpoint \[0-9\]+, \[0-9xa-f\]+ in \\.?$func \\(\\).*\r\n$gdb_prompt $" { ++ if {$func == "_dl_debug_state"} { ++ fail $test ++ } else { + pass $test + } + } +- if ![regexp {^(NONE|FOUND-.*)$} $displacement] { +- fail $test_displacement ++ -re "Stopped due to shared library event\r\n$gdb_prompt $" { ++ if {$func == "_dl_debug_state"} { ++ if {$debug_state_count == 0} { ++ # First stop does not yet relocate the _start function ++ # descriptor on ppc64. ++ set debug_state_count 1 ++ send_gdb "continue\n" ++ exp_continue ++ } else { ++ pass $test ++ } ++ } else { ++ fail $test ++ } + } + } ++ if ![regexp {^(NONE|FOUND-.*)$} $displacement] { ++ fail $test_displacement ++ } ++ ++ if {$func == "_dl_debug_state"} { ++ gdb_test_no_output "set stop-on-solib-events 0" ++ } ++} ++ ++# `runto' does not check we stopped really at the function we specified. ++# DISPLACEMENT can be "NONE" for no message to be present, "ZERO" for ++# displacement of 0 bytes to be present, "NONZERO" for displacement of non-0 ++# bytes to be present and "PRESENT" if both "ZERO" and "NONZERO" are valid. ++proc reach {func command displacement} { ++ global pf_prefix ++ set old_ldprefix $pf_prefix ++ lappend pf_prefix "reach-$func:" ++ ++ reach_1 $func $command $displacement + + set pf_prefix $old_ldprefix + } +@@ -344,9 +384,18 @@ + # prevents that from happening. So turn it off. + gdb_test "set disable-randomization off" + +- reach "dl_main" "run segv" $displacement ++ if $ifmain { ++ gdb_test_no_output "set args segv" ++ } else { ++ global objdir binfile_test ++ ++ # ld.so needs some executable to run to reach _dl_debug_state. ++ gdb_test_no_output "set args ${objdir}/${subdir}/$binfile_test" ++ } ++ ++ reach "_dl_debug_state" "run" $displacement + +- gdb_test "bt" "#0 +\[^\r\n\]*\\mdl_main\\M.*" "dl bt" ++ gdb_test "bt" "#0 +\[^\r\n\]*\\m_dl_debug_state\\M.*" "dl bt" + + if $ifmain { + reach "main" continue "NONE" +@@ -358,7 +407,7 @@ + + # Try re-run if the new PIE displacement takes effect. + gdb_test "kill" "" "kill" {Kill the program being debugged\? \(y or n\) } "y" +- reach "dl_main" "run segv" $displacement ++ reach "_dl_debug_state" "run" $displacement + + if $ifmain { + test_core $file $displacement +@@ -391,7 +440,7 @@ + gdb_test "exec-file $file" "exec-file $escapedfile" "load" + + if $ifmain { +- reach "dl_main" run $displacement ++ reach "_dl_debug_state" run $displacement + + set test "info files" + set entrynohex "" diff --git a/gdb-ppc-test-break-interp-6of6.patch b/gdb-ppc-test-break-interp-6of6.patch new file mode 100644 index 0000000..f48b0f1 --- /dev/null +++ b/gdb-ppc-test-break-interp-6of6.patch @@ -0,0 +1,102 @@ +http://sourceware.org/ml/gdb-cvs/2010-10/msg00067.html + +### src/gdb/ChangeLog 2010/10/08 20:45:20 1.12248 +### src/gdb/ChangeLog 2010/10/11 08:50:28 1.12249 +## -1,3 +1,9 @@ ++2010-10-11 Jan Kratochvil ++ ++ Fix attaching to re-prelinked executables on ppc64. ++ * solib-svr4.c (svr4_exec_displacement): New variable plt2_asect, ++ initialize it, try to adjust FILESZ field by it. ++ + 2010-10-08 Daniel Jacobowitz + + * tracepoint.c (merge_uploaded_trace_state_variables): Only print +--- src/gdb/solib-svr4.c 2010/08/03 22:35:41 1.138 ++++ src/gdb/solib-svr4.c 2010/10/11 08:50:33 1.139 +@@ -1844,6 +1844,7 @@ + Elf32_External_Phdr *phdr2p; + gdb_byte *buf_vaddr_p, *buf_paddr_p; + CORE_ADDR vaddr, paddr; ++ asection *plt2_asect; + + phdrp = &((Elf32_External_Phdr *) buf)[i]; + buf_vaddr_p = (gdb_byte *) &phdrp->p_vaddr; +@@ -1869,6 +1870,34 @@ + if (memcmp (phdrp, phdr2p, sizeof (*phdrp)) == 0) + continue; + ++ /* prelink can convert .plt SHT_NOBITS to SHT_PROGBITS. */ ++ plt2_asect = bfd_get_section_by_name (exec_bfd, ".plt"); ++ if (plt2_asect) ++ { ++ int content2; ++ gdb_byte *buf_filesz_p = (gdb_byte *) &phdrp->p_filesz; ++ CORE_ADDR filesz; ++ ++ content2 = (bfd_get_section_flags (exec_bfd, plt2_asect) ++ & SEC_HAS_CONTENTS) != 0; ++ ++ filesz = extract_unsigned_integer (buf_filesz_p, 4, ++ byte_order); ++ ++ /* PLT2_ASECT is from on-disk file (exec_bfd) while ++ FILESZ is from the in-memory image. */ ++ if (content2) ++ filesz += bfd_get_section_size (plt2_asect); ++ else ++ filesz -= bfd_get_section_size (plt2_asect); ++ ++ store_unsigned_integer (buf_filesz_p, 4, byte_order, ++ filesz); ++ ++ if (memcmp (phdrp, phdr2p, sizeof (*phdrp)) == 0) ++ continue; ++ } ++ + ok = 0; + break; + } +@@ -1921,6 +1950,7 @@ + Elf64_External_Phdr *phdr2p; + gdb_byte *buf_vaddr_p, *buf_paddr_p; + CORE_ADDR vaddr, paddr; ++ asection *plt2_asect; + + phdrp = &((Elf64_External_Phdr *) buf)[i]; + buf_vaddr_p = (gdb_byte *) &phdrp->p_vaddr; +@@ -1946,6 +1976,34 @@ + if (memcmp (phdrp, phdr2p, sizeof (*phdrp)) == 0) + continue; + ++ /* prelink can convert .plt SHT_NOBITS to SHT_PROGBITS. */ ++ plt2_asect = bfd_get_section_by_name (exec_bfd, ".plt"); ++ if (plt2_asect) ++ { ++ int content2; ++ gdb_byte *buf_filesz_p = (gdb_byte *) &phdrp->p_filesz; ++ CORE_ADDR filesz; ++ ++ content2 = (bfd_get_section_flags (exec_bfd, plt2_asect) ++ & SEC_HAS_CONTENTS) != 0; ++ ++ filesz = extract_unsigned_integer (buf_filesz_p, 8, ++ byte_order); ++ ++ /* PLT2_ASECT is from on-disk file (exec_bfd) while ++ FILESZ is from the in-memory image. */ ++ if (content2) ++ filesz += bfd_get_section_size (plt2_asect); ++ else ++ filesz -= bfd_get_section_size (plt2_asect); ++ ++ store_unsigned_integer (buf_filesz_p, 8, byte_order, ++ filesz); ++ ++ if (memcmp (phdrp, phdr2p, sizeof (*phdrp)) == 0) ++ continue; ++ } ++ + ok = 0; + break; + } diff --git a/gdb-test-infcall-dlopen-1of2.patch b/gdb-test-infcall-dlopen-1of2.patch new file mode 100644 index 0000000..34ee3be --- /dev/null +++ b/gdb-test-infcall-dlopen-1of2.patch @@ -0,0 +1,123 @@ +http://sourceware.org/ml/gdb-cvs/2010-08/msg00090.html + +### src/gdb/testsuite/ChangeLog 2010/08/17 20:59:03 1.2412 +### src/gdb/testsuite/ChangeLog 2010/08/17 21:31:12 1.2413 +## -1,4 +1,10 @@ + 2010-08-17 Jan Kratochvil ++ ++ * gdb.cp/infcall-dlopen.exp: New file. ++ * gdb.cp/infcall-dlopen.cc: New file. ++ * gdb.cp/infcall-dlopen-lib.cc: New file. ++ ++2010-08-17 Jan Kratochvil + Pedro Alves + + PR breakpoints/11371 +--- src/gdb/testsuite/gdb.cp/infcall-dlopen-lib.cc ++++ src/gdb/testsuite/gdb.cp/infcall-dlopen-lib.cc 2011-01-01 12:52:07.599598000 +0000 +@@ -0,0 +1,16 @@ ++/* 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 . */ +--- src/gdb/testsuite/gdb.cp/infcall-dlopen.cc ++++ src/gdb/testsuite/gdb.cp/infcall-dlopen.cc 2011-01-01 12:52:07.883051000 +0000 +@@ -0,0 +1,37 @@ ++/* 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 . */ ++ ++#include ++#include ++ ++static int ++openlib (const char *filename) ++{ ++ void *h = dlopen (filename, RTLD_LAZY); ++ ++ if (h == NULL) ++ return 0; ++ if (dlclose (h) != 0) ++ return 0; ++ return 1; ++} ++ ++int ++main (void) ++{ ++ return 0; ++} +--- src/gdb/testsuite/gdb.cp/infcall-dlopen.exp ++++ src/gdb/testsuite/gdb.cp/infcall-dlopen.exp 2011-01-01 12:52:08.166496000 +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 . ++ ++if {[skip_shlib_tests]} { ++ return 0 ++} ++ ++if [get_compiler_info not-used] { ++ return -1 ++} ++ ++set testfile "infcall-dlopen" ++set srcmainfile ${testfile}.cc ++set srclibfile ${testfile}-lib.cc ++set executable ${testfile} ++set libfile ${objdir}/${subdir}/${executable}.so ++set binfile ${objdir}/${subdir}/${executable} ++ ++# Use completely arbitrary file for $libfile source. ++if { [gdb_compile_shlib ${srcdir}/${subdir}/${srclibfile} ${libfile} {debug c++}] != "" ++ || [prepare_for_testing ${testfile}.exp ${executable} ${srcmainfile} {debug c++ shlib_load}] } { ++ return -1 ++} ++ ++if { ![runto_main] } { ++ return -1 ++} ++ ++for {set i 0} {$i < 10} {incr i} { ++ gdb_test "p openlib (\"${libfile}\")" " = 1" "test $i" ++ # Try to exploit the GDB trashed memory. ++ gdb_test "b openlib" {Breakpoint [0-9]+ at .*} "test $i stub 1" ++ gdb_test_no_output {delete $bpnum} "test $i stub 2" ++} diff --git a/gdb-test-infcall-dlopen-2of2.patch b/gdb-test-infcall-dlopen-2of2.patch new file mode 100644 index 0000000..2248437 --- /dev/null +++ b/gdb-test-infcall-dlopen-2of2.patch @@ -0,0 +1,36 @@ +http://sourceware.org/ml/gdb-cvs/2010-10/msg00070.html + +### src/gdb/testsuite/ChangeLog 2010/10/11 08:47:47 1.2473 +### src/gdb/testsuite/ChangeLog 2010/10/11 21:36:25 1.2474 +## -1,5 +1,10 @@ + 2010-10-11 Jan Kratochvil + ++ * gdb.cp/infcall-dlopen.cc (openlib): Support NULL FILENAME. ++ (main): Make openlib dummy call. ++ ++2010-10-11 Jan Kratochvil ++ + Fix missing _start PIE relocation on ppc64 due to stop on dl_main. + * break-interp.exp (reach): Move the core body ... + (reach_1): ... here. Use stop-on-solib-events for _dl_debug_state. +--- src/gdb/testsuite/gdb.cp/infcall-dlopen.cc 2010/08/17 21:31:13 1.1 ++++ src/gdb/testsuite/gdb.cp/infcall-dlopen.cc 2010/10/11 21:36:26 1.2 +@@ -23,6 +23,9 @@ + { + void *h = dlopen (filename, RTLD_LAZY); + ++ if (filename == NULL) ++ return 0; ++ + if (h == NULL) + return 0; + if (dlclose (h) != 0) +@@ -33,5 +36,8 @@ + int + main (void) + { ++ /* Dummy call to get the function always compiled in. */ ++ openlib (NULL); ++ + return 0; + } diff --git a/gdb-test-pid0-core.patch b/gdb-test-pid0-core.patch new file mode 100644 index 0000000..1bc221b --- /dev/null +++ b/gdb-test-pid0-core.patch @@ -0,0 +1,80 @@ +https://bugzilla.redhat.com/show_bug.cgi?id=611435 + +Fix: +Re: [RFA]corelow.c: Add tid to add_to_thread_list +http://sourceware.org/ml/gdb-patches/2010-08/msg00085.html +http://sourceware.org/ml/gdb-cvs/2010-08/msg00026.html +2e5bcfdef1ec3883d48c3f87a4be5c0dff25e17e + +--- /dev/null ++++ b/gdb/testsuite/gdb.arch/x86_64-pid0-core.core.bz2.uu +@@ -0,0 +1,20 @@ ++begin 600 x86_64-pid0-core.core.bz2 ++M0EIH.3%!629362,CA>P!$/'_____^*#EZ-A!SP36P&_:G0#=14``04A&8,'U ++M2*9`>$$)P`*RN"#*;#4R()IJ8C$TT&FC3$&@`T`#:C1H8C0T,@,FC,D"4T2! ++M"/2CU'B90]31ZAD#U`&AZF@/4:``!HT&F@!H<`#0-`-#0``#3$-&F@```#0R ++M``#")2FD]2>4]0TTT-!HTT--,0,"#$`R!I@AD`#1H,3&GZT.4TO$#H40/`0C ++M2$IRXS,<55!8T,&&,R.Z441"?J9I%G6GUA2!.[]Z"C5S[&19,%VS7E6[3"60 ++M@`-*2G)QEQ(;?0Y<=MK]/U?Q)LB%+F37TJ9BI*46)H'*Z@V"`"$"P7]&XZ:JE0E<*:#1M$P3G]>VCI)(A!O$64`5$4`E$$-.``7&(09`8HO`B6K!Q^& ++M562%N)2+0@*HB@%D@5$%!*0!L1&0D4D6\:-$A`)`+<6D82PP*H(J(H!?F;0$ ++M%PXB7N!2D4!44`W7"ADEQM6O9TBO5,_]1) ++M($Q2))#),UE,QQK)E$,3D\W.>!4)QO8A_@^Z_SXS4;Q8=HV6[:&$@2$@$R29IBW)K%3"O` ++M9^Y0YJ&BXY1U2HTZ5)2H-V\_(.DZHWE+C#WS($(!I"3CUH2#(+(OWUV"*<<9 ++MJ%A!J[%O.P&V%GI.`L7<1@0>,^1F\MY=V5UT,&NOG%7TTZ[03!@BHB@&)P` ++` ++end +--- /dev/null ++++ b/gdb/testsuite/gdb.arch/x86_64-pid0-core.exp +@@ -0,0 +1,46 @@ ++# 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 2 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, write to the Free Software ++# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ++ ++# Some kernel core files have PID 0 - for the idle task. ++ ++if ![istarget "x86_64-*-*"] { ++ verbose "Skipping x86_64-pid0-core test." ++ return ++} ++ ++set testfile "x86_64-pid0-core" ++set corebz2uufile ${srcdir}/${subdir}/${testfile}.core.bz2.uu ++set corefile ${objdir}/${subdir}/${testfile}.core ++ ++if {[catch "system \"uudecode -o - ${corebz2uufile} | bzip2 -dc >${corefile}\""] != 0} { ++ untested "failed uudecode or bzip2" ++ return -1 ++} ++file stat ${corefile} corestat ++if {$corestat(size) != 8798208} { ++ untested "uudecode or bzip2 produce invalid result" ++ return -1 ++} ++ ++gdb_exit ++gdb_start ++gdb_reinitialize_dir $srcdir/$subdir ++ ++# Former crash was: ++# thread.c:884: internal-error: switch_to_thread: Assertion `inf != NULL' failed. ++gdb_test "core-file ${corefile}" "Program terminated with signal 11, Segmentation fault\\.\r\n.*" diff --git a/gdb-test-pp-hint-error.patch b/gdb-test-pp-hint-error.patch new file mode 100644 index 0000000..9e64646 --- /dev/null +++ b/gdb-test-pp-hint-error.patch @@ -0,0 +1,99 @@ +http://sourceware.org/ml/gdb-patches/2011-01/msg00016.html +Subject: [patch] New testcase: py-prettyprint.exp: print hint_error + +Hi, + +PASS: gdb.python/py-prettyprint.exp: print hint_error +for + FYI: fix buglet in gdbpy_get_display_hint + http://sourceware.org/ml/gdb-patches/2010-07/msg00190.html + http://sourceware.org/ml/gdb-cvs/2010-07/msg00061.html + +I would check it in as obvious but the 2011 ChangeLog move process has to be +done first. So to be checked in later. + + +Thanks, +Jan + + +gdb/testsuite/ +2011-01-01 Jan Kratochvil + + * gdb.python/py-prettyprint.c (struct hint_error): New. + (main): New variable hint_error. + * gdb.python/py-prettyprint.exp (run_lang_tests): New testcase + "print hint_error". + * gdb.python/py-prettyprint.py (class pp_hint_error): New. + (register_pretty_printers): Register it. + +Index: gdb-7.2/gdb/testsuite/gdb.python/py-prettyprint.c +=================================================================== +--- gdb-7.2.orig/gdb/testsuite/gdb.python/py-prettyprint.c 2010-07-14 16:18:04.000000000 +0200 ++++ gdb-7.2/gdb/testsuite/gdb.python/py-prettyprint.c 2011-01-01 17:41:24.000000000 +0100 +@@ -44,6 +44,10 @@ struct lazystring { + const char *lazy_str; + }; + ++struct hint_error { ++ int x; ++}; ++ + #ifdef __cplusplus + struct S : public s { + int zs; +@@ -232,6 +236,8 @@ main () + struct lazystring estring; + estring.lazy_str = "embedded x\201\202\203\204" ; + ++ struct hint_error hint_error; ++ + #ifdef __cplusplus + S cps; + +Index: gdb-7.2/gdb/testsuite/gdb.python/py-prettyprint.exp +=================================================================== +--- gdb-7.2.orig/gdb/testsuite/gdb.python/py-prettyprint.exp 2011-01-01 17:40:07.000000000 +0100 ++++ gdb-7.2/gdb/testsuite/gdb.python/py-prettyprint.exp 2011-01-01 17:40:52.000000000 +0100 +@@ -102,6 +102,8 @@ proc run_lang_tests {lang} { + gdb_test "print estring" "\"embedded x\\\\201\\\\202\\\\203\\\\204\"" + gdb_test "print c" " = container \"container\" with 2 elements = {$nl *.0. = 23,$nl *.1. = 72$nl}" + ++ gdb_test "print hint_error" "Exception: hint failed\r\nhint_error_val" ++ + gdb_test "print nullstr" "RuntimeError: Error reading string from inferior.*" + + gdb_test "print nstype" " = {$nl *.0. = 7,$nl *.1. = 42$nl}" +Index: gdb-7.2/gdb/testsuite/gdb.python/py-prettyprint.py +=================================================================== +--- gdb-7.2.orig/gdb/testsuite/gdb.python/py-prettyprint.py 2010-06-04 20:18:28.000000000 +0200 ++++ gdb-7.2/gdb/testsuite/gdb.python/py-prettyprint.py 2011-01-01 17:40:23.000000000 +0100 +@@ -151,6 +151,18 @@ class pp_ls: + def display_hint (self): + return 'string' + ++class pp_hint_error: ++ "Throw error from display_hint" ++ ++ def __init__(self, val): ++ self.val = val ++ ++ def to_string(self): ++ return 'hint_error_val' ++ ++ def display_hint (self): ++ raise Exception("hint failed") ++ + class pp_outer: + "Print struct outer" + +@@ -236,6 +248,9 @@ def register_pretty_printers (): + pretty_printers_dict[re.compile ('^struct outerstruct$')] = pp_outer + pretty_printers_dict[re.compile ('^outerstruct$')] = pp_outer + ++ pretty_printers_dict[re.compile ('^struct hint_error$')] = pp_hint_error ++ pretty_printers_dict[re.compile ('^hint_error$')] = pp_hint_error ++ + pretty_printers_dict = {} + + register_pretty_printers () diff --git a/gdb.spec b/gdb.spec index 7d767c2..9bc6ef4 100644 --- a/gdb.spec +++ b/gdb.spec @@ -27,7 +27,7 @@ Version: 7.2 # The release always contains a leading reserved number, start it at 1. # `upstream' is not a part of `name' to stay fully rpm dependencies compatible for the testing. -Release: 27%{?_with_upstream:.upstream}%{dist} +Release: 28%{?_with_upstream:.upstream}%{dist} License: GPLv3+ and GPLv3+ with exceptions and GPLv2+ and GPLv2+ with exceptions and GPL+ and LGPLv2+ and GFDL and BSD and Public Domain Group: Development/Debuggers @@ -634,6 +634,34 @@ Patch520: gdb-bz642879-elfread-sigint-stale.patch #=drop Patch527: gdb-bz653644-gdbindex-double-free.patch +# Backport gdb.base/break-interp.exp test (+prelink fix) on PPC (BZ 663449). +#=drop +Patch533: gdb-ppc-test-break-interp-1of6.patch +#=drop +Patch534: gdb-ppc-test-break-interp-2of6.patch +#=drop +Patch535: gdb-ppc-test-break-interp-3of6.patch +#=drop +Patch536: gdb-ppc-test-break-interp-4of6.patch +#=drop +Patch537: gdb-ppc-test-break-interp-5of6.patch +#=drop +Patch538: gdb-ppc-test-break-interp-6of6.patch + +# Backport gdb.cp/infcall-dlopen.exp test (BZ 639645). +#=drop +Patch539: gdb-test-infcall-dlopen-1of2.patch +#=drop +Patch540: gdb-test-infcall-dlopen-2of2.patch + +# New testcase py-prettyprint.exp:print hint_error (for BZ 611569, BZ 629236). +#=fedoratest +Patch541: gdb-test-pp-hint-error.patch + +# New test gdb.arch/x86_64-pid0-core.exp for kernel PID 0 cores (BZ 611435). +#=fedoratest +Patch542: gdb-test-pid0-core.patch + BuildRequires: ncurses-devel%{?_isa} texinfo gettext flex bison expat-devel%{?_isa} Requires: readline%{?_isa} BuildRequires: readline-devel%{?_isa} @@ -908,6 +936,16 @@ rm -f gdb/jv-exp.c gdb/m2-exp.c gdb/objc-exp.c gdb/p-exp.c %patch518 -p1 %patch520 -p1 %patch527 -p1 +%patch533 -p1 +%patch534 -p1 +%patch535 -p1 +%patch536 -p1 +%patch537 -p1 +%patch538 -p1 +%patch539 -p1 +%patch540 -p1 +%patch541 -p1 +%patch542 -p1 %patch393 -p1 %patch335 -p1 @@ -1278,6 +1316,12 @@ fi %endif %changelog +* Sat Jan 2 2011 Jan Kratochvil - 7.2-28.fc14 +- Backport gdb.base/break-interp.exp test (+prelink fix) on PPC (BZ 663449). +- Backport gdb.cp/infcall-dlopen.exp test (BZ 639645). +- New testcase py-prettyprint.exp:print hint_error (for BZ 611569, BZ 629236). +- New test gdb.arch/x86_64-pid0-core.exp for kernel PID 0 cores (BZ 611435). + * Sat Jan 1 2011 Jan Kratochvil - 7.2-27.fc14 - Fix ppc* compilation of PRPSINFO in the core files (BZ 662995, for BZ 254229). - Fix (disable) non-x86* compilation of libinproctrace.so (for BZ 662995).