From 51a5ef0fcc85578604905ccfa8d198db5dd6d324 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Pawe=C5=82=20Sikora?= Date: Fri, 15 Oct 2010 17:16:36 +0000 Subject: [PATCH] - updated to 7.2 with fedora patchset w/o rhel compat fixes. - python pretty printers dropped (bcond temporary inverted). we'll original sources from gcc tarball. - release 0.1. Changed files: gdb-6.3-attach-see-vdso-test.patch -> 1.2 gdb-6.3-bt-past-zero-20051201.patch -> 1.2 gdb-6.3-bz140532-ppc-unwinding-test.patch -> 1.2 gdb-6.3-gstack-20050411.patch -> 1.3 gdb-6.3-gstack-without-path-20060414.patch -> 1.3 gdb-6.3-ia64-info-frame-fix-20050725.patch -> 1.2 gdb-6.3-ia64-sigill-20051115.patch -> 1.2 gdb-6.3-ia64-sigtramp-frame-20050708.patch -> 1.2 gdb-6.3-inferior-notification-20050721.patch -> 1.2 gdb-6.3-inheritancetest-20050726.patch -> 1.3 gdb-6.3-large-core-20051206.patch -> 1.3 gdb-6.3-readnever-20050907.patch -> 1.3 gdb-6.3-rh-testversion-20041202.patch -> 1.2 gdb-6.3-security-errata-20050610.patch -> 1.2 gdb-6.3-step-thread-exit-20050211-test.patch -> 1.2 gdb-6.3-test-dtorfix-20050121.patch -> 1.2 gdb-6.3-test-movedir-20050125.patch -> 1.2 gdb-6.3-test-pie-20050107.patch -> 1.4 gdb-6.3-threaded-watchpoints2-20050225.patch -> 1.3 gdb-6.3-watchpoint-cond-gone-test.patch -> 1.2 gdb-6.5-bz185337-resolve-tls-without-debuginfo-v2.patch -> 1.3 gdb-6.5-bz203661-emit-relocs.patch -> 1.3 gdb-6.5-bz216711-clone-is-outermost.patch -> 1.3 gdb-6.5-bz218379-ppc-solib-trampoline-fix.patch -> 1.2 gdb-6.5-bz243845-stale-testing-zombie-test.patch -> 1.2 gdb-6.5-dwarf-stack-overflow.patch -> 1.2 gdb-6.5-gcore-buffer-limit-test.patch -> 1.2 gdb-6.5-gcore-i386-on-amd64.patch -> 1.3 gdb-6.5-ia64-libunwind-leak-test.patch -> 1.2 gdb-6.5-missed-trap-on-step-test.patch -> 1.2 gdb-6.5-tls-of-separate-debuginfo.patch -> 1.2 gdb-6.6-buildid-locate-core-as-arg.patch -> 1.1 gdb-6.6-buildid-locate-rpm.patch -> 1.5 gdb-6.6-buildid-locate.patch -> 1.5 gdb-6.6-bz225783-prelink-path.patch -> 1.2 gdb-6.6-bz229517-gcore-without-terminal.patch -> 1.2 gdb-6.6-bz235197-fork-detach-info.patch -> 1.2 gdb-6.6-gcore32-test.patch -> 1.2 gdb-6.6-scheduler_locking-step-is-default.patch -> 1.3 gdb-6.6-scheduler_locking-step-sw-watchpoints2.patch -> 1.3 gdb-6.6-threads-static-test.patch -> 1.2 gdb-6.7-bz426600-DW_TAG_interface_type-test.patch -> 1.2 gdb-6.7-charsign-test.patch -> 1.2 gdb-6.7-ppc-clobbered-registers-O2-test.patch -> 1.2 gdb-6.7-testsuite-stable-results.patch -> 1.3 gdb-6.8-attach-signalled-detach-stopped.patch -> 1.3 gdb-6.8-bz254229-gcore-prpsinfo.patch -> 1.3 gdb-6.8-bz457187-largefile-test.patch -> 1.2 gdb-6.8-bz457187-largefile.patch -> 1.3 gdb-6.8-bz466901-backtrace-full-prelinked.patch -> 1.3 gdb-6.8-constant-watchpoints.patch -> 1.3 gdb-6.8-fortran-tag-constant.patch -> 1.3 gdb-6.8-inlining-addon.patch -> 1.3 gdb-6.8-inlining-by-name.patch -> 1.2 gdb-7.0-upstream.patch -> 1.2 gdb-archer-ada.patch -> 1.1 gdb-archer-next-over-throw-cxx-exec.patch -> 1.1 gdb-archer-pie-addons-keep-disabled.patch -> 1.1 gdb-archer-pie-addons.patch -> 1.2 gdb-archer-pie.patch -> 1.2 gdb-archer.patch -> 1.5 gdb-bz528668-symfile-cleanup.patch -> 1.2 gdb-bz528668-symfile-multi.patch -> 1.2 gdb-bz528668-symfile-sepcrc.patch -> 1.2 gdb-bz533176-fortran-omp-step.patch -> 1.1 gdb-bz538626-bp_location-accel-bp-cond.patch -> 1.2 gdb-bz539590-gnu-ifunc-fix-cond.patch -> 1.1 gdb-bz539590-gnu-ifunc.patch -> 1.2 gdb-bz541866-rwatch-before-run.patch -> 1.1 gdb-bz555076-gcore-small-height.patch -> 1.1 gdb-bz562763-pretty-print-2d-vectors.patch -> 1.1 gdb-bz568248-oom-is-error.patch -> 1.1 gdb-bz575292-delayed-physname.patch -> 1.1 gdb-bz592031-siginfo-lost-1of5.patch -> 1.1 gdb-bz592031-siginfo-lost-2of5.patch -> 1.1 gdb-bz592031-siginfo-lost-3of5.patch -> 1.1 gdb-bz592031-siginfo-lost-4of5.patch -> 1.1 gdb-bz592031-siginfo-lost-5of5.patch -> 1.1 gdb-bz594560-core-vs-process.patch -> 1.1 gdb-bz601887-dwarf4-rh-test.patch -> 1.1 gdb-bz614659-prelink-dynbss.patch -> 1.1 gdb-bz623749-gcore-relro.patch -> 1.1 gdb-bz627432-loop-static-self-class.patch -> 1.1 gdb-bz631158-cxx-this-lookup.patch -> 1.1 gdb-bz631575-gdb-index-nobits.patch -> 1.1 gdb-bz634660-gdbpy-load-on-attach.patch -> 1.1 gdb-bz637770-ifunc-watchpoint-delete.patch -> 1.1 gdb-ccache-workaround.patch -> 1.1 gdb-core-open-vdso-warning.patch -> 1.2 gdb-false-gcc-warning.patch -> 1.1 gdb-follow-child-stale-parent.patch -> 1.1 gdb-fortran-common-reduce.patch -> 1.1 gdb-fortran-common.patch -> 1.1 gdb-gdb-add-index-script.patch -> 1.1 gdb-gdbindex-ada-regression.patch -> 1.1 gdb-gdbindex-bigendian.patch -> 1.1 gdb-info.patch -> 1.10 gdb-lineno-makeup-test.patch -> 1.1 gdb-moribund-utrace-workaround.patch -> 1.1 gdb-ppc-power7-test.patch -> 1.1 gdb-pr12028-double-free.patch -> 1.1 gdb-python.patch -> 1.2 gdb-readline-6.0-signal.patch -> 1.2 gdb-readline-6.0.patch -> 1.2 gdb-unused-revert.patch -> 1.1 gdb-upstream.patch -> 1.1 gdb.spec -> 1.130 libstdc++-v3-python-common-prefix.patch -> 1.2 --- gdb-6.3-attach-see-vdso-test.patch | 9 +- gdb-6.3-bt-past-zero-20051201.patch | 22 +- gdb-6.3-bz140532-ppc-unwinding-test.patch | 9 +- gdb-6.3-gstack-20050411.patch | 161 +- gdb-6.3-gstack-without-path-20060414.patch | 34 - gdb-6.3-ia64-info-frame-fix-20050725.patch | 23 +- gdb-6.3-ia64-sigill-20051115.patch | 12 +- gdb-6.3-ia64-sigtramp-frame-20050708.patch | 18 +- gdb-6.3-inferior-notification-20050721.patch | 9 +- gdb-6.3-inheritancetest-20050726.patch | 9 +- gdb-6.3-large-core-20051206.patch | 106 +- gdb-6.3-readnever-20050907.patch | 60 +- gdb-6.3-rh-testversion-20041202.patch | 16 +- gdb-6.3-security-errata-20050610.patch | 126 +- gdb-6.3-step-thread-exit-20050211-test.patch | 9 +- gdb-6.3-test-dtorfix-20050121.patch | 29 +- gdb-6.3-test-movedir-20050125.patch | 12 +- gdb-6.3-test-pie-20050107.patch | 97 +- gdb-6.3-threaded-watchpoints2-20050225.patch | 9 +- gdb-6.3-watchpoint-cond-gone-test.patch | 128 - ...337-resolve-tls-without-debuginfo-v2.patch | 53 +- gdb-6.5-bz203661-emit-relocs.patch | 12 +- gdb-6.5-bz216711-clone-is-outermost.patch | 141 - ....5-bz218379-ppc-solib-trampoline-fix.patch | 19 - ...5-bz243845-stale-testing-zombie-test.patch | 9 +- gdb-6.5-dwarf-stack-overflow.patch | 14 +- gdb-6.5-gcore-buffer-limit-test.patch | 9 +- gdb-6.5-gcore-i386-on-amd64.patch | 847 - gdb-6.5-ia64-libunwind-leak-test.patch | 9 +- gdb-6.5-missed-trap-on-step-test.patch | 9 +- gdb-6.5-tls-of-separate-debuginfo.patch | 24 - gdb-6.6-buildid-locate-core-as-arg.patch | 196 + gdb-6.6-buildid-locate-rpm.patch | 423 +- gdb-6.6-buildid-locate.patch | 206 +- gdb-6.6-bz225783-prelink-path.patch | 27 - gdb-6.6-bz229517-gcore-without-terminal.patch | 9 +- gdb-6.6-bz235197-fork-detach-info.patch | 31 +- gdb-6.6-gcore32-test.patch | 216 - ....6-scheduler_locking-step-is-default.patch | 32 +- ...heduler_locking-step-sw-watchpoints2.patch | 52 +- gdb-6.6-threads-static-test.patch | 16 +- ...-bz426600-DW_TAG_interface_type-test.patch | 9 +- gdb-6.7-charsign-test.patch | 9 +- gdb-6.7-ppc-clobbered-registers-O2-test.patch | 9 +- gdb-6.7-testsuite-stable-results.patch | 22 +- gdb-6.8-attach-signalled-detach-stopped.patch | 40 +- gdb-6.8-bz254229-gcore-prpsinfo.patch | 321 +- gdb-6.8-bz457187-largefile-test.patch | 2 +- gdb-6.8-bz457187-largefile.patch | 265 - ....8-bz466901-backtrace-full-prelinked.patch | 15 - gdb-6.8-constant-watchpoints.patch | 236 - gdb-6.8-fortran-tag-constant.patch | 32 +- gdb-6.8-inlining-addon.patch | 571 - gdb-6.8-inlining-by-name.patch | 104 - gdb-7.0-upstream.patch | 627 - gdb-archer-ada.patch | 23 + gdb-archer-next-over-throw-cxx-exec.patch | 85 + gdb-archer-pie-addons-keep-disabled.patch | 83 + gdb-archer-pie-addons.patch | 263 +- gdb-archer-pie.patch | 2647 -- gdb-archer.patch | 33020 +++++----------- gdb-bz528668-symfile-cleanup.patch | 137 - gdb-bz528668-symfile-multi.patch | 271 - gdb-bz528668-symfile-sepcrc.patch | 151 - gdb-bz533176-fortran-omp-step.patch | 115 + gdb-bz538626-bp_location-accel-bp-cond.patch | 134 - gdb-bz539590-gnu-ifunc-fix-cond.patch | 14 + gdb-bz539590-gnu-ifunc.patch | 511 - gdb-bz541866-rwatch-before-run.patch | 106 + gdb-bz555076-gcore-small-height.patch | 12 + gdb-bz562763-pretty-print-2d-vectors.patch | 404 + gdb-bz568248-oom-is-error.patch | 69 + gdb-bz575292-delayed-physname.patch | 630 + gdb-bz592031-siginfo-lost-1of5.patch | 87 + gdb-bz592031-siginfo-lost-2of5.patch | 139 + gdb-bz592031-siginfo-lost-3of5.patch | 259 + gdb-bz592031-siginfo-lost-4of5.patch | 992 + gdb-bz592031-siginfo-lost-5of5.patch | 141 + gdb-bz594560-core-vs-process.patch | 164 + gdb-bz601887-dwarf4-rh-test.patch | 240 + gdb-bz614659-prelink-dynbss.patch | 217 + gdb-bz623749-gcore-relro.patch | 169 + gdb-bz627432-loop-static-self-class.patch | 280 + gdb-bz631158-cxx-this-lookup.patch | 14 + gdb-bz631575-gdb-index-nobits.patch | 61 + gdb-bz634660-gdbpy-load-on-attach.patch | 61 + gdb-bz637770-ifunc-watchpoint-delete.patch | 111 + gdb-ccache-workaround.patch | 17 + gdb-core-open-vdso-warning.patch | 35 +- gdb-false-gcc-warning.patch | 11 + gdb-follow-child-stale-parent.patch | 27 + gdb-fortran-common-reduce.patch | 507 + gdb-fortran-common.patch | 580 + gdb-gdb-add-index-script.patch | 122 + gdb-gdbindex-ada-regression.patch | 50 + gdb-gdbindex-bigendian.patch | 96 + gdb-info.patch | 20 +- gdb-lineno-makeup-test.patch | 151 + gdb-moribund-utrace-workaround.patch | 16 + gdb-ppc-power7-test.patch | 295 + gdb-pr12028-double-free.patch | 99 + gdb-python.patch | 27 - gdb-readline-6.0-signal.patch | 312 - gdb-readline-6.0.patch | 123 - gdb-unused-revert.patch | 44 + gdb-upstream.patch | 467 + gdb.spec | 146 +- libstdc++-v3-python-common-prefix.patch | 18 - 108 files changed, 18302 insertions(+), 31985 deletions(-) delete mode 100644 gdb-6.3-gstack-without-path-20060414.patch delete mode 100644 gdb-6.3-watchpoint-cond-gone-test.patch delete mode 100644 gdb-6.5-bz218379-ppc-solib-trampoline-fix.patch delete mode 100644 gdb-6.5-gcore-i386-on-amd64.patch delete mode 100644 gdb-6.5-tls-of-separate-debuginfo.patch create mode 100644 gdb-6.6-buildid-locate-core-as-arg.patch delete mode 100644 gdb-6.6-bz225783-prelink-path.patch delete mode 100644 gdb-6.6-gcore32-test.patch delete mode 100644 gdb-6.8-bz457187-largefile.patch delete mode 100644 gdb-6.8-constant-watchpoints.patch delete mode 100644 gdb-6.8-inlining-addon.patch delete mode 100644 gdb-6.8-inlining-by-name.patch delete mode 100644 gdb-7.0-upstream.patch create mode 100644 gdb-archer-ada.patch create mode 100644 gdb-archer-next-over-throw-cxx-exec.patch create mode 100644 gdb-archer-pie-addons-keep-disabled.patch delete mode 100644 gdb-archer-pie.patch delete mode 100644 gdb-bz528668-symfile-cleanup.patch delete mode 100644 gdb-bz528668-symfile-multi.patch delete mode 100644 gdb-bz528668-symfile-sepcrc.patch create mode 100644 gdb-bz533176-fortran-omp-step.patch delete mode 100644 gdb-bz538626-bp_location-accel-bp-cond.patch create mode 100644 gdb-bz539590-gnu-ifunc-fix-cond.patch delete mode 100644 gdb-bz539590-gnu-ifunc.patch create mode 100644 gdb-bz541866-rwatch-before-run.patch create mode 100644 gdb-bz555076-gcore-small-height.patch create mode 100644 gdb-bz562763-pretty-print-2d-vectors.patch create mode 100644 gdb-bz568248-oom-is-error.patch create mode 100644 gdb-bz575292-delayed-physname.patch create mode 100644 gdb-bz592031-siginfo-lost-1of5.patch create mode 100644 gdb-bz592031-siginfo-lost-2of5.patch create mode 100644 gdb-bz592031-siginfo-lost-3of5.patch create mode 100644 gdb-bz592031-siginfo-lost-4of5.patch create mode 100644 gdb-bz592031-siginfo-lost-5of5.patch create mode 100644 gdb-bz594560-core-vs-process.patch create mode 100644 gdb-bz601887-dwarf4-rh-test.patch create mode 100644 gdb-bz614659-prelink-dynbss.patch create mode 100644 gdb-bz623749-gcore-relro.patch create mode 100644 gdb-bz627432-loop-static-self-class.patch create mode 100644 gdb-bz631158-cxx-this-lookup.patch create mode 100644 gdb-bz631575-gdb-index-nobits.patch create mode 100644 gdb-bz634660-gdbpy-load-on-attach.patch create mode 100644 gdb-bz637770-ifunc-watchpoint-delete.patch create mode 100644 gdb-ccache-workaround.patch create mode 100644 gdb-false-gcc-warning.patch create mode 100644 gdb-follow-child-stale-parent.patch create mode 100644 gdb-fortran-common-reduce.patch create mode 100644 gdb-fortran-common.patch create mode 100644 gdb-gdb-add-index-script.patch create mode 100644 gdb-gdbindex-ada-regression.patch create mode 100644 gdb-gdbindex-bigendian.patch create mode 100644 gdb-lineno-makeup-test.patch create mode 100644 gdb-moribund-utrace-workaround.patch create mode 100644 gdb-ppc-power7-test.patch create mode 100644 gdb-pr12028-double-free.patch delete mode 100644 gdb-python.patch delete mode 100644 gdb-readline-6.0-signal.patch delete mode 100644 gdb-readline-6.0.patch create mode 100644 gdb-unused-revert.patch create mode 100644 gdb-upstream.patch delete mode 100644 libstdc++-v3-python-common-prefix.patch diff --git a/gdb-6.3-attach-see-vdso-test.patch b/gdb-6.3-attach-see-vdso-test.patch index 58a15db..a0923f8 100644 --- a/gdb-6.3-attach-see-vdso-test.patch +++ b/gdb-6.3-attach-see-vdso-test.patch @@ -28,7 +28,7 @@ +} --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ ./gdb/testsuite/gdb.base/attach-see-vdso.exp 6 Jul 2007 14:14:44 -0000 -@@ -0,0 +1,79 @@ +@@ -0,0 +1,72 @@ +# Copyright 2007 + +# This program is free software; you can redistribute it and/or modify @@ -47,13 +47,6 @@ + +# This file was created by Jan Kratochvil . + -+if $tracelevel then { -+ strace $tracelevel -+} -+ -+set prms_id 0 -+set bug_id 0 -+ +# This test only works on Linux +if { ![istarget "*-*-linux-gnu*"] } { + return 0 diff --git a/gdb-6.3-bt-past-zero-20051201.patch b/gdb-6.3-bt-past-zero-20051201.patch index 4d6e2d8..11b946d 100644 --- a/gdb-6.3-bt-past-zero-20051201.patch +++ b/gdb-6.3-bt-past-zero-20051201.patch @@ -15,11 +15,11 @@ testsuite/gdb.base: Port to GDB-6.7. -Index: gdb-6.7/gdb/testsuite/gdb.base/setshow.exp +Index: gdb-7.1.90.20100711/gdb/testsuite/gdb.base/setshow.exp =================================================================== ---- gdb-6.7.orig/gdb/testsuite/gdb.base/setshow.exp 2007-08-23 20:14:17.000000000 +0200 -+++ gdb-6.7/gdb/testsuite/gdb.base/setshow.exp 2007-10-15 21:34:52.000000000 +0200 -@@ -106,6 +106,16 @@ if { ![target_info exists use_gdb_stub] +--- gdb-7.1.90.20100711.orig/gdb/testsuite/gdb.base/setshow.exp 2010-06-11 22:56:06.000000000 +0200 ++++ gdb-7.1.90.20100711/gdb/testsuite/gdb.base/setshow.exp 2010-07-12 10:46:06.000000000 +0200 +@@ -96,6 +96,16 @@ if { ![target_info exists use_gdb_stub] delete_breakpoints gdb_test "run" "Starting program:.*foo bar blup baz bubble.*" "passing args" } @@ -34,13 +34,13 @@ Index: gdb-6.7/gdb/testsuite/gdb.base/setshow.exp +#test show backtrace past-zero-pc +gdb_test "show backtrace past-zero-pc" "Whether backtraces should continue past a zero pc value is off." "show backtrace past-zero-pc (off)" #test set check range on - gdb_test "set check range on" "" "set check range on" + gdb_test "set check range on" ".*" "set check range on" #test show check range on -Index: gdb-6.7/gdb/frame.c +Index: gdb-7.1.90.20100711/gdb/frame.c =================================================================== ---- gdb-6.7.orig/gdb/frame.c 2007-10-12 22:35:58.000000000 +0200 -+++ gdb-6.7/gdb/frame.c 2007-10-15 21:34:52.000000000 +0200 -@@ -133,6 +133,16 @@ Whether backtraces should continue past +--- gdb-7.1.90.20100711.orig/gdb/frame.c 2010-07-12 10:00:56.000000000 +0200 ++++ gdb-7.1.90.20100711/gdb/frame.c 2010-07-12 10:45:18.000000000 +0200 +@@ -185,6 +185,16 @@ Whether backtraces should continue past value); } @@ -57,7 +57,7 @@ Index: gdb-6.7/gdb/frame.c static int backtrace_past_entry; static void show_backtrace_past_entry (struct ui_file *file, int from_tty, -@@ -1483,9 +1493,7 @@ get_prev_frame (struct frame_info *this_ +@@ -1784,9 +1794,7 @@ get_prev_frame (struct frame_info *this_ } if (this_frame->level > 0 @@ -68,7 +68,7 @@ Index: gdb-6.7/gdb/frame.c && get_frame_type (this_frame) == NORMAL_FRAME && get_frame_type (get_next_frame (this_frame)) == NORMAL_FRAME && get_frame_pc (this_frame) == 0) -@@ -1850,6 +1858,17 @@ the rest of the stack trace."), +@@ -2271,6 +2279,17 @@ the rest of the stack trace."), &set_backtrace_cmdlist, &show_backtrace_cmdlist); diff --git a/gdb-6.3-bz140532-ppc-unwinding-test.patch b/gdb-6.3-bz140532-ppc-unwinding-test.patch index d325ee3..6494cde 100644 --- a/gdb-6.3-bz140532-ppc-unwinding-test.patch +++ b/gdb-6.3-bz140532-ppc-unwinding-test.patch @@ -218,7 +218,7 @@ diff -u -ruNp gdb-6.3-unpatched/gdb/testsuite/gdb.arch/powerpc-bcl-prologue.c gd diff -u -ruNp gdb-6.3-unpatched/gdb/testsuite/gdb.arch/powerpc-bcl-prologue.exp gdb-6.3/gdb/testsuite/gdb.arch/powerpc-bcl-prologue.exp --- gdb-6.3-unpatched/gdb/testsuite/gdb.arch/powerpc-bcl-prologue.exp 1969-12-31 19:00:00.000000000 -0500 +++ gdb-6.3/gdb/testsuite/gdb.arch/powerpc-bcl-prologue.exp 2007-08-02 14:21:29.000000000 -0400 -@@ -0,0 +1,79 @@ +@@ -0,0 +1,72 @@ +# Copyright 2006, 2007 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify @@ -238,13 +238,6 @@ diff -u -ruNp gdb-6.3-unpatched/gdb/testsuite/gdb.arch/powerpc-bcl-prologue.exp +# Test unwinding fixes of the PPC platform, specifically on the coping with BCL +# jump of the PIE code. + -+if $tracelevel then { -+ strace $tracelevel -+} -+ -+set prms_id 0 -+set bug_id 0 -+ +if ![istarget "powerpc*-*-linux*"] then { + verbose "Skipping powerpc-linux prologue tests." + return diff --git a/gdb-6.3-gstack-20050411.patch b/gdb-6.3-gstack-20050411.patch index 0aa6426..2d99428 100644 --- a/gdb-6.3-gstack-20050411.patch +++ b/gdb-6.3-gstack-20050411.patch @@ -4,11 +4,11 @@ to install and uninstall. * gstack.sh, gstack.1: New files. -Index: gdb-6.8.91.20090917/gdb/Makefile.in +Index: gdb-7.2/gdb/Makefile.in =================================================================== ---- gdb-6.8.91.20090917.orig/gdb/Makefile.in 2009-09-17 12:47:07.000000000 +0200 -+++ gdb-6.8.91.20090917/gdb/Makefile.in 2009-09-17 12:47:38.000000000 +0200 -@@ -989,7 +989,7 @@ install: all install-only +--- gdb-7.2.orig/gdb/Makefile.in 2010-09-03 09:37:55.000000000 +0200 ++++ gdb-7.2/gdb/Makefile.in 2010-09-03 09:38:45.000000000 +0200 +@@ -1010,7 +1010,7 @@ install: all install-only # The "install-only" target also installs the syscalls' XML files in # the system. @@ -17,10 +17,11 @@ Index: gdb-6.8.91.20090917/gdb/Makefile.in transformed_name=`t='$(program_transform_name)'; \ echo gdb | sed -e "$$t"` ; \ if test "x$$transformed_name" = x; then \ -@@ -1021,9 +1021,26 @@ install-tui: - $(DESTDIR)$(man1dir) ; \ - $(INSTALL_DATA) $(srcdir)/gdb.1 \ - $(DESTDIR)$(man1dir)/$$transformed_name.1 +@@ -1046,7 +1046,25 @@ install-tui: + install-python: + $(SHELL) $(srcdir)/../mkinstalldirs $(DESTDIR)$(GDB_DATADIR)/python/gdb + +-uninstall: force $(CONFIG_UNINSTALL) +GSTACK=gstack +.PHONY: install-gstack +install-gstack: @@ -38,14 +39,12 @@ Index: gdb-6.8.91.20090917/gdb/Makefile.in + $(DESTDIR)$(man1dir) ; \ + : $(INSTALL_DATA) $(srcdir)/gstack.1 \ + $(DESTDIR)$(man1dir)/$$transformed_name.1 - - --uninstall: force $(CONFIG_UNINSTALL) ++ +uninstall: force uninstall-gstack $(CONFIG_UNINSTALL) transformed_name=`t='$(program_transform_name)'; \ echo gdb | sed -e $$t` ; \ if test "x$$transformed_name" = x; then \ -@@ -1045,6 +1062,17 @@ uninstall-tui: +@@ -1068,6 +1086,17 @@ uninstall-tui: fi ; \ rm -f $(DESTDIR)$(bindir)/$$transformed_name$(EXEEXT) \ $(DESTDIR)$(man1dir)/$$transformed_name.1 @@ -63,10 +62,10 @@ Index: gdb-6.8.91.20090917/gdb/Makefile.in # The C++ name parser can be built standalone for testing. test-cp-name-parser.o: cp-name-parser.c -Index: gdb-6.8.91.20090917/gdb/gstack.sh +Index: gdb-7.2/gdb/gstack.sh =================================================================== --- /dev/null 1970-01-01 00:00:00.000000000 +0000 -+++ gdb-6.8.91.20090917/gdb/gstack.sh 2009-09-17 12:47:14.000000000 +0200 ++++ gdb-7.2/gdb/gstack.sh 2010-09-03 09:38:12.000000000 +0200 @@ -0,0 +1,48 @@ +#!/bin/sh + @@ -87,17 +86,17 @@ Index: gdb-6.8.91.20090917/gdb/gstack.sh +backtrace="bt" +if test -d /proc/$1/task ; then + # Newer kernel; has a task/ directory. -+ if test `ls /proc/$1/task | wc -l` -gt 1 2>/dev/null ; then ++ if test `/bin/ls /proc/$1/task | /usr/bin/wc -l` -gt 1 2>/dev/null ; then + backtrace="thread apply all bt" + fi +elif test -f /proc/$1/maps ; then + # Older kernel; go by it loading libpthread. -+ if grep -e libpthread /proc/$1/maps > /dev/null 2>&1 ; then ++ if /bin/grep -e libpthread /proc/$1/maps > /dev/null 2>&1 ; then + backtrace="thread apply all bt" + fi +fi + -+GDB=${GDB:-gdb} ++GDB=${GDB:-/usr/bin/gdb} + +if $GDB -nx --quiet --batch --readnever > /dev/null 2>&1; then + readnever=--readnever @@ -112,7 +111,131 @@ Index: gdb-6.8.91.20090917/gdb/gstack.sh +set pagination no +$backtrace +EOF -+sed -n \ -+ -e 's/^(gdb) //' \ ++/bin/sed -n \ ++ -e 's/^\((gdb) \)*//' \ + -e '/^#/p' \ + -e '/^Thread/p' +Index: gdb-7.2/gdb/testsuite/gdb.base/gstack.exp +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ gdb-7.2/gdb/testsuite/gdb.base/gstack.exp 2010-09-03 09:38:12.000000000 +0200 +@@ -0,0 +1,71 @@ ++# 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 . ++ ++set testfile gstack ++set executable ${testfile} ++set binfile ${objdir}/${subdir}/$executable ++if {[build_executable ${testfile} ${executable} "" {debug}] == -1} { ++ return -1 ++} ++ ++set test "spawn inferior" ++set command "${binfile}" ++set res [remote_spawn host $command]; ++if { $res < 0 || $res == "" } { ++ perror "Spawning $command failed." ++ fail $test ++ return ++} ++set pid [exp_pid -i $res] ++gdb_expect { ++ -re "looping\r\n" { ++ pass $test ++ } ++ eof { ++ fail "$test (eof)" ++ return ++ } ++ timeout { ++ fail "$test (timeout)" ++ return ++ } ++} ++gdb_exit ++ ++# Testcase uses the most simple notification not to get caught by attach on ++# exiting the function. Still we could retry the gstack command if we fail. ++ ++set test "spawn gstack" ++set command "sh -c GDB=$GDB\\ sh\\ ${srcdir}/../gstack.sh\\ $pid\\;echo\\ GSTACK-END" ++set res [remote_spawn host $command]; ++if { $res < 0 || $res == "" } { ++ perror "Spawning $command failed." ++ fail $test ++} ++set pid [exp_pid -i $res] ++gdb_expect { ++ -re {^#0 +0x[0-9a-f]+ in \.?func \(\)\r\n#1 +0x[0-9a-f]+ in \.?main \(\)\r\nGSTACK-END\r\n$} { ++ pass $test ++ } ++ eof { ++ fail "$test (eof)" ++ } ++ timeout { ++ fail "$test (timeout)" ++ } ++} ++gdb_exit ++ ++remote_exec host "kill -9 $pid" +Index: gdb-7.2/gdb/testsuite/gdb.base/gstack.c +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ gdb-7.2/gdb/testsuite/gdb.base/gstack.c 2010-09-03 09:38:12.000000000 +0200 +@@ -0,0 +1,43 @@ ++/* This testcase is part of GDB, the GNU debugger. ++ ++ Copyright 2005, 2007, 2008, 2009 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 ++#include ++ ++void ++func (void) ++{ ++ const char msg[] = "looping\n"; ++ ++ /* Use the most simple notification not to get caught by attach on exiting ++ the function. */ ++ write (1, msg, strlen (msg)); ++ ++ for (;;); ++} ++ ++int ++main (void) ++{ ++ alarm (60); ++ nice (100); ++ ++ func (); ++ ++ return 0; ++} diff --git a/gdb-6.3-gstack-without-path-20060414.patch b/gdb-6.3-gstack-without-path-20060414.patch deleted file mode 100644 index 677f934..0000000 --- a/gdb-6.3-gstack-without-path-20060414.patch +++ /dev/null @@ -1,34 +0,0 @@ -Index: gdb-6.3/gdb/gstack.sh -=================================================================== ---- gdb-6.3.orig/gdb/gstack.sh 2006-02-14 17:21:05.000000000 -0200 -+++ gdb-6.3/gdb/gstack.sh 2006-04-14 03:17:12.000000000 -0300 -@@ -17,17 +17,17 @@ fi - backtrace="bt" - if test -d /proc/$1/task ; then - # Newer kernel; has a task/ directory. -- if test `ls /proc/$1/task | wc -l` -gt 1 2>/dev/null ; then -+ if test `/bin/ls /proc/$1/task | /usr/bin/wc -l` -gt 1 2>/dev/null ; then - backtrace="thread apply all bt" - fi - elif test -f /proc/$1/maps ; then - # Older kernel; go by it loading libpthread. -- if grep -e libpthread /proc/$1/maps > /dev/null 2>&1 ; then -+ if /bin/grep -e libpthread /proc/$1/maps > /dev/null 2>&1 ; then - backtrace="thread apply all bt" - fi - fi - --GDB=${GDB:-gdb} -+GDB=${GDB:-/usr/bin/gdb} - - if $GDB -nx --quiet --batch --readnever > /dev/null 2>&1; then - readnever=--readnever -@@ -39,7 +39,7 @@ fi - set pagination no - $backtrace - EOF --sed -n \ -+/bin/sed -n \ - -e 's/^(gdb) //' \ - -e '/^#/p' \ - -e '/^Thread/p' diff --git a/gdb-6.3-ia64-info-frame-fix-20050725.patch b/gdb-6.3-ia64-info-frame-fix-20050725.patch index 3b2bd9a..2ebab9e 100644 --- a/gdb-6.3-ia64-info-frame-fix-20050725.patch +++ b/gdb-6.3-ia64-info-frame-fix-20050725.patch @@ -41,7 +41,7 @@ testsuite: + --- gdb-6.3/gdb/testsuite/gdb.arch/ia64-sigtramp.exp.fix 2005-07-25 16:42:50.000000000 -0400 +++ gdb-6.3/gdb/testsuite/gdb.arch/ia64-sigtramp.exp 2005-07-25 16:42:01.000000000 -0400 -@@ -0,0 +1,66 @@ +@@ -0,0 +1,63 @@ +# Copyright 2005 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify @@ -63,16 +63,6 @@ testsuite: + +# This file was written by Jeff Johnston (jjohnstn@redhat.com) + -+if $tracelevel then { -+ strace $tracelevel -+} -+ -+# -+# test running programs -+# -+set prms_id 0 -+set bug_id 0 -+ +if ![istarget "ia64-*-*"] then { + return +} @@ -90,7 +80,10 @@ testsuite: +} + +gdb_exit ++set match_max_old [match_max] ++match_max -d 1000000 +gdb_start ++match_max -d $match_max_old +gdb_reinitialize_dir $srcdir/$subdir +gdb_load ${binfile} + @@ -106,5 +99,9 @@ testsuite: +gdb_test "continue" "Breakpoint.*x.*" "continue to x" + +gdb_test "f 1" ".*signal handler called.*" "frame 1" -+gdb_test "info frame" "Stack level 1.*p63 at .*" "info sigtramp frame" -+ ++ ++# gdb-7.0+ no longer prints the pseudo registers as they are computed. ++# frame_info says: /* For moment, only display registers that were saved on the ++# stack. */ ++gdb_test "set debug frame 1" ++gdb_test "info frame" "Stack level 1, .*frame_unwind_register_value \\(frame=1,regnum=750\\(p63\\),\[^\r\n\]*\r\n\[^\r\n\]*-> computed bytes=.*" "info sigtramp frame" diff --git a/gdb-6.3-ia64-sigill-20051115.patch b/gdb-6.3-ia64-sigill-20051115.patch index 5c94160..07a6b46 100644 --- a/gdb-6.3-ia64-sigill-20051115.patch +++ b/gdb-6.3-ia64-sigill-20051115.patch @@ -16,7 +16,7 @@ Index: gdb-6.8.50.20081128/gdb/testsuite/gdb.arch/ia64-sigill.exp =================================================================== --- /dev/null 1970-01-01 00:00:00.000000000 +0000 +++ gdb-6.8.50.20081128/gdb/testsuite/gdb.arch/ia64-sigill.exp 2008-12-02 21:10:57.000000000 +0100 -@@ -0,0 +1,59 @@ +@@ -0,0 +1,49 @@ +# Copyright 2005 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify @@ -38,16 +38,6 @@ Index: gdb-6.8.50.20081128/gdb/testsuite/gdb.arch/ia64-sigill.exp + +# This file was written by Jeff Johnston (jjohnstn@redhat.com) + -+if $tracelevel then { -+ strace $tracelevel -+} -+ -+# -+# test running programs -+# -+set prms_id 0 -+set bug_id 0 -+ +if ![istarget "ia64-*-*"] then { + return +} diff --git a/gdb-6.3-ia64-sigtramp-frame-20050708.patch b/gdb-6.3-ia64-sigtramp-frame-20050708.patch index 1862f97..c6a7789 100644 --- a/gdb-6.3-ia64-sigtramp-frame-20050708.patch +++ b/gdb-6.3-ia64-sigtramp-frame-20050708.patch @@ -29,7 +29,7 @@ Index: gdb-6.8.50.20081128/gdb/ia64-tdep.c + ULONGEST unatN_val; + ULONGEST unat; + read_memory (cache->saved_regs[IA64_UNAT_REGNUM], (char *) &unat, -+ register_size (current_gdbarch, IA64_UNAT_REGNUM)); ++ register_size (target_gdbarch, IA64_UNAT_REGNUM)); + unatN_val = (unat & (1LL << (regnum - IA64_NAT0_REGNUM))) != 0; + return frame_unwind_got_constant (this_frame, regnum, unatN_val); + } @@ -45,9 +45,9 @@ Index: gdb-6.8.50.20081128/gdb/ia64-tdep.c + CORE_ADDR gr_addr = 0, nat_addr = 0; + + read_memory (cache->saved_regs[IA64_BSP_REGNUM], (char *) &bsp, -+ register_size (current_gdbarch, IA64_BSP_REGNUM)); ++ register_size (target_gdbarch, IA64_BSP_REGNUM)); + read_memory (cache->saved_regs[IA64_CFM_REGNUM], (char *) &cfm, -+ register_size (current_gdbarch, IA64_CFM_REGNUM)); ++ register_size (target_gdbarch, IA64_CFM_REGNUM)); + + /* The bsp points at the end of the register frame so we + subtract the size of frame from it to get start of register frame. */ @@ -71,10 +71,10 @@ Index: gdb-6.8.50.20081128/gdb/ia64-tdep.c + nat_addr = cache->saved_regs[IA64_RNAT_REGNUM]; + if (nat_addr != 0) + read_memory (nat_addr, (char *) &nat_collection, -+ register_size (current_gdbarch, IA64_RNAT_REGNUM)); ++ register_size (target_gdbarch, IA64_RNAT_REGNUM)); + } + else -+ nat_collection = read_memory_integer (nat_addr, 8); ++ nat_collection = read_memory_integer (nat_addr, 8, BFD_ENDIAN_LITTLE); + if (nat_addr != 0) + { + nat_bit = (gr_addr >> 3) & 0x3f; @@ -97,9 +97,9 @@ Index: gdb-6.8.50.20081128/gdb/ia64-tdep.c + ULONGEST bof; + + read_memory (cache->saved_regs[IA64_BSP_REGNUM], (char *) &bsp, -+ register_size (current_gdbarch, IA64_BSP_REGNUM)); ++ register_size (target_gdbarch, IA64_BSP_REGNUM)); + read_memory (cache->saved_regs[IA64_CFM_REGNUM], (char *) &cfm, -+ register_size (current_gdbarch, IA64_CFM_REGNUM)); ++ register_size (target_gdbarch, IA64_CFM_REGNUM)); + + /* The bsp points at the end of the register frame so we + subtract the size of frame from it to get beginning of frame. */ @@ -133,9 +133,9 @@ Index: gdb-6.8.50.20081128/gdb/ia64-tdep.c + ULONGEST cfm; + ULONGEST prN_val; + read_memory (pr_addr, (char *) &pr, -+ register_size (current_gdbarch, IA64_PR_REGNUM)); ++ register_size (target_gdbarch, IA64_PR_REGNUM)); + read_memory (cache->saved_regs[IA64_CFM_REGNUM], (char *) &cfm, -+ register_size (current_gdbarch, IA64_CFM_REGNUM)); ++ register_size (target_gdbarch, IA64_CFM_REGNUM)); + + /* Get the register rename base for this frame and adjust the + * register name to take rotation into account. */ diff --git a/gdb-6.3-inferior-notification-20050721.patch b/gdb-6.3-inferior-notification-20050721.patch index 5a014ff..a789b1b 100644 --- a/gdb-6.3-inferior-notification-20050721.patch +++ b/gdb-6.3-inferior-notification-20050721.patch @@ -38,7 +38,7 @@ Index: gdb-6.8.50.20081128/gdb/testsuite/gdb.base/attach-32.exp =================================================================== --- /dev/null 1970-01-01 00:00:00.000000000 +0000 +++ gdb-6.8.50.20081128/gdb/testsuite/gdb.base/attach-32.exp 2008-12-07 10:08:52.000000000 +0100 -@@ -0,0 +1,252 @@ +@@ -0,0 +1,245 @@ +# Copyright 2005 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify @@ -57,13 +57,6 @@ Index: gdb-6.8.50.20081128/gdb/testsuite/gdb.base/attach-32.exp +# +# This test was based on attach.exp and modified for 32/64 bit Linux systems. */ + -+if $tracelevel then { -+ strace $tracelevel -+} -+ -+set prms_id 0 -+set bug_id 0 -+ +# On HP-UX 11.0, this test is causing a process running the program +# "attach" to be left around spinning. Until we figure out why, I am +# commenting out the test to avoid polluting tiamat (our 11.0 nightly diff --git a/gdb-6.3-inheritancetest-20050726.patch b/gdb-6.3-inheritancetest-20050726.patch index 5f33571..ab81976 100644 --- a/gdb-6.3-inheritancetest-20050726.patch +++ b/gdb-6.3-inheritancetest-20050726.patch @@ -62,7 +62,7 @@ Index: gdb-6.8.50.20090811/gdb/testsuite/gdb.cp/b146835.exp =================================================================== --- /dev/null 1970-01-01 00:00:00.000000000 +0000 +++ gdb-6.8.50.20090811/gdb/testsuite/gdb.cp/b146835.exp 2009-08-12 06:58:28.000000000 +0200 -@@ -0,0 +1,54 @@ +@@ -0,0 +1,47 @@ +# This testcase is part of GDB, the GNU debugger. + +# Copyright 2005 Free Software Foundation, Inc. @@ -84,13 +84,6 @@ Index: gdb-6.8.50.20090811/gdb/testsuite/gdb.cp/b146835.exp +# Check that GDB can properly print an inherited member variable +# (Bugzilla 146835) + -+if $tracelevel { -+ strace $tracelevel -+} -+ -+set prms_id 0 -+set bug_id 0 -+ +set testfile "b146835" +set srcfile ${testfile}.cc +set srcfile2 ${testfile}b.cc diff --git a/gdb-6.3-large-core-20051206.patch b/gdb-6.3-large-core-20051206.patch index 2876b75..8789a6a 100644 --- a/gdb-6.3-large-core-20051206.patch +++ b/gdb-6.3-large-core-20051206.patch @@ -25,11 +25,11 @@ Port to GDB-6.7. -Index: gdb-6.8.50.20090909/gdb/symfile-mem.c +Index: gdb-7.1.90.20100711/gdb/symfile-mem.c =================================================================== ---- gdb-6.8.50.20090909.orig/gdb/symfile-mem.c 2009-07-02 19:21:06.000000000 +0200 -+++ gdb-6.8.50.20090909/gdb/symfile-mem.c 2009-09-09 19:06:57.000000000 +0200 -@@ -56,6 +56,14 @@ +--- gdb-7.1.90.20100711.orig/gdb/symfile-mem.c 2010-01-01 08:31:42.000000000 +0100 ++++ gdb-7.1.90.20100711/gdb/symfile-mem.c 2010-07-12 10:46:24.000000000 +0200 +@@ -57,6 +57,14 @@ #include "elf/common.h" @@ -44,7 +44,7 @@ Index: gdb-6.8.50.20090909/gdb/symfile-mem.c /* Read inferior memory at ADDR to find the header of a loaded object file and read its in-core symbols out of inferior memory. TEMPL is a bfd representing the target's format. NAME is the name to use for this -@@ -76,7 +84,7 @@ symbol_file_add_from_memory (struct bfd +@@ -77,7 +85,7 @@ symbol_file_add_from_memory (struct bfd error (_("add-symbol-file-from-memory not supported for this target")); nbfd = bfd_elf_bfd_from_remote_memory (templ, addr, &loadbase, @@ -53,20 +53,20 @@ Index: gdb-6.8.50.20090909/gdb/symfile-mem.c if (nbfd == NULL) error (_("Failed to read a valid object file image from memory.")); -Index: gdb-6.8.50.20090909/gdb/target.c +Index: gdb-7.1.90.20100711/gdb/target.c =================================================================== ---- gdb-6.8.50.20090909.orig/gdb/target.c 2009-09-09 19:05:56.000000000 +0200 -+++ gdb-6.8.50.20090909/gdb/target.c 2009-09-09 19:08:11.000000000 +0200 -@@ -59,7 +59,7 @@ static int nosymbol (char *, CORE_ADDR * +--- gdb-7.1.90.20100711.orig/gdb/target.c 2010-07-12 10:00:56.000000000 +0200 ++++ gdb-7.1.90.20100711/gdb/target.c 2010-07-12 10:47:04.000000000 +0200 +@@ -58,7 +58,7 @@ static int nosymbol (char *, CORE_ADDR * - static void tcomplain (void) ATTR_NORETURN; + static void tcomplain (void) ATTRIBUTE_NORETURN; -static int nomemory (CORE_ADDR, char *, int, int, struct target_ops *); +static LONGEST nomemory (CORE_ADDR, char *, int, int, struct target_ops *); static int return_zero (void); -@@ -492,7 +492,7 @@ target_terminal_inferior (void) +@@ -513,7 +513,7 @@ target_terminal_inferior (void) (*current_target.to_terminal_inferior) (); } @@ -75,7 +75,7 @@ Index: gdb-6.8.50.20090909/gdb/target.c nomemory (CORE_ADDR memaddr, char *myaddr, int len, int write, struct target_ops *t) { -@@ -711,7 +711,7 @@ update_current_target (void) +@@ -718,7 +718,7 @@ update_current_target (void) (void (*) (struct regcache *)) noprocess); de_fault (deprecated_xfer_memory, @@ -84,7 +84,7 @@ Index: gdb-6.8.50.20090909/gdb/target.c nomemory); de_fault (to_files_info, (void (*) (struct target_ops *)) -@@ -1443,7 +1443,7 @@ target_xfer_partial (struct target_ops * +@@ -1526,7 +1526,7 @@ target_xfer_partial (struct target_ops * it makes no progress, and then return how much was transferred). */ int @@ -93,7 +93,7 @@ Index: gdb-6.8.50.20090909/gdb/target.c { /* Dispatch to the topmost target, not the flattened current_target. Memory accesses check target->to_has_(all_)memory, and the -@@ -1459,7 +1459,7 @@ target_read_memory (CORE_ADDR memaddr, g +@@ -1542,7 +1542,7 @@ target_read_memory (CORE_ADDR memaddr, g the target's stack. This may trigger different cache behavior. */ int @@ -102,8 +102,8 @@ Index: gdb-6.8.50.20090909/gdb/target.c { /* Dispatch to the topmost target, not the flattened current_target. Memory accesses check target->to_has_(all_)memory, and the -@@ -1473,7 +1473,7 @@ target_read_stack (CORE_ADDR memaddr, gd - } +@@ -1561,7 +1561,7 @@ target_read_stack (CORE_ADDR memaddr, gd + Callers that can deal with partial writes should call target_write. */ int -target_write_memory (CORE_ADDR memaddr, const gdb_byte *myaddr, int len) @@ -111,7 +111,7 @@ Index: gdb-6.8.50.20090909/gdb/target.c { /* Dispatch to the topmost target, not the flattened current_target. Memory accesses check target->to_has_(all_)memory, and the -@@ -2964,8 +2964,8 @@ debug_to_prepare_to_store (struct regcac +@@ -3218,8 +3218,8 @@ debug_to_prepare_to_store (struct regcac fprintf_unfiltered (gdb_stdlog, "target_prepare_to_store ()\n"); } @@ -122,7 +122,7 @@ Index: gdb-6.8.50.20090909/gdb/target.c int write, struct mem_attrib *attrib, struct target_ops *target) { -@@ -2975,8 +2975,8 @@ deprecated_debug_xfer_memory (CORE_ADDR +@@ -3229,8 +3229,8 @@ deprecated_debug_xfer_memory (CORE_ADDR attrib, target); fprintf_unfiltered (gdb_stdlog, @@ -133,11 +133,11 @@ Index: gdb-6.8.50.20090909/gdb/target.c write ? "write" : "read", retval); if (retval > 0) -Index: gdb-6.8.50.20090909/gdb/target.h +Index: gdb-7.1.90.20100711/gdb/target.h =================================================================== ---- gdb-6.8.50.20090909.orig/gdb/target.h 2009-09-09 19:05:56.000000000 +0200 -+++ gdb-6.8.50.20090909/gdb/target.h 2009-09-09 19:07:36.000000000 +0200 -@@ -366,10 +366,10 @@ struct target_ops +--- gdb-7.1.90.20100711.orig/gdb/target.h 2010-07-12 10:00:56.000000000 +0200 ++++ gdb-7.1.90.20100711/gdb/target.h 2010-07-12 10:46:24.000000000 +0200 +@@ -417,10 +417,10 @@ struct target_ops NOTE: cagney/2004-10-01: This has been entirely superseeded by to_xfer_partial and inferior inheritance. */ @@ -152,7 +152,7 @@ Index: gdb-6.8.50.20090909/gdb/target.h void (*to_files_info) (struct target_ops *); int (*to_insert_breakpoint) (struct gdbarch *, struct bp_target_info *); -@@ -680,12 +680,12 @@ extern void target_dcache_invalidate (vo +@@ -838,12 +838,12 @@ extern void target_dcache_invalidate (vo extern int target_read_string (CORE_ADDR, char **, int, int *); @@ -168,13 +168,13 @@ Index: gdb-6.8.50.20090909/gdb/target.h /* Fetches the target's memory map. If one is found it is sorted and returned, after some consistency checking. Otherwise, NULL -Index: gdb-6.8.50.20090909/gdb/dcache.c +Index: gdb-7.1.90.20100711/gdb/dcache.c =================================================================== ---- gdb-6.8.50.20090909.orig/gdb/dcache.c 2009-08-31 22:18:45.000000000 +0200 -+++ gdb-6.8.50.20090909/gdb/dcache.c 2009-09-09 19:09:21.000000000 +0200 -@@ -390,10 +390,10 @@ dcache_free (DCACHE *dcache) - - The meaning of the result is the same as for target_write. */ +--- gdb-7.1.90.20100711.orig/gdb/dcache.c 2010-05-14 19:53:15.000000000 +0200 ++++ gdb-7.1.90.20100711/gdb/dcache.c 2010-07-12 10:46:24.000000000 +0200 +@@ -465,10 +465,10 @@ dcache_free (DCACHE *dcache) + NOTE: This is different than the to_xfer_partial interface, in which + positive values less than LEN mean further transfers may be possible. */ -int +LONGEST @@ -185,10 +185,10 @@ Index: gdb-6.8.50.20090909/gdb/dcache.c { int i; int res; -Index: gdb-6.8.50.20090909/gdb/dcache.h +Index: gdb-7.1.90.20100711/gdb/dcache.h =================================================================== ---- gdb-6.8.50.20090909.orig/gdb/dcache.h 2009-08-31 22:18:45.000000000 +0200 -+++ gdb-6.8.50.20090909/gdb/dcache.h 2009-09-09 19:08:54.000000000 +0200 +--- gdb-7.1.90.20100711.orig/gdb/dcache.h 2010-01-01 08:31:30.000000000 +0100 ++++ gdb-7.1.90.20100711/gdb/dcache.h 2010-07-12 10:46:24.000000000 +0200 @@ -35,8 +35,8 @@ void dcache_free (DCACHE *); /* Simple to call from _xfer_memory */ @@ -200,11 +200,11 @@ Index: gdb-6.8.50.20090909/gdb/dcache.h void dcache_update (DCACHE *dcache, CORE_ADDR memaddr, gdb_byte *myaddr, int len); -Index: gdb-6.8.50.20090909/gdb/exec.c +Index: gdb-7.1.90.20100711/gdb/exec.c =================================================================== ---- gdb-6.8.50.20090909.orig/gdb/exec.c 2009-07-02 19:21:06.000000000 +0200 -+++ gdb-6.8.50.20090909/gdb/exec.c 2009-09-09 19:06:57.000000000 +0200 -@@ -560,7 +560,7 @@ map_vmap (bfd *abfd, bfd *arch) +--- gdb-7.1.90.20100711.orig/gdb/exec.c 2010-05-14 20:35:11.000000000 +0200 ++++ gdb-7.1.90.20100711/gdb/exec.c 2010-07-12 10:46:24.000000000 +0200 +@@ -571,7 +571,7 @@ map_vmap (bfd *abfd, bfd *arch) } @@ -213,11 +213,11 @@ Index: gdb-6.8.50.20090909/gdb/exec.c section_table_xfer_memory_partial (gdb_byte *readbuf, const gdb_byte *writebuf, ULONGEST offset, LONGEST len, struct target_section *sections, -Index: gdb-6.8.50.20090909/gdb/linux-nat.c +Index: gdb-7.1.90.20100711/gdb/linux-nat.c =================================================================== ---- gdb-6.8.50.20090909.orig/gdb/linux-nat.c 2009-09-09 19:06:46.000000000 +0200 -+++ gdb-6.8.50.20090909/gdb/linux-nat.c 2009-09-09 19:06:57.000000000 +0200 -@@ -4622,7 +4622,7 @@ linux_xfer_partial (struct target_ops *o +--- gdb-7.1.90.20100711.orig/gdb/linux-nat.c 2010-07-12 10:44:36.000000000 +0200 ++++ gdb-7.1.90.20100711/gdb/linux-nat.c 2010-07-12 10:46:24.000000000 +0200 +@@ -5197,7 +5197,7 @@ linux_xfer_partial (struct target_ops *o #endif if (iterate_over_lwps (ia64_linux_check_stack_region, &range) != NULL) { /* This region contains ia64 rse registers, we have to re-read. */ @@ -226,10 +226,10 @@ Index: gdb-6.8.50.20090909/gdb/linux-nat.c /* Re-read register stack area. */ xxfer = super_xfer_partial (ops, object, annex, -Index: gdb-6.8.50.20090909/gdb/remote.c +Index: gdb-7.1.90.20100711/gdb/remote.c =================================================================== ---- gdb-6.8.50.20090909.orig/gdb/remote.c 2009-08-18 18:17:16.000000000 +0200 -+++ gdb-6.8.50.20090909/gdb/remote.c 2009-09-09 19:06:57.000000000 +0200 +--- gdb-7.1.90.20100711.orig/gdb/remote.c 2010-07-07 18:15:16.000000000 +0200 ++++ gdb-7.1.90.20100711/gdb/remote.c 2010-07-12 10:46:24.000000000 +0200 @@ -25,6 +25,7 @@ #include "gdb_string.h" #include @@ -238,7 +238,7 @@ Index: gdb-6.8.50.20090909/gdb/remote.c #include "inferior.h" #include "bfd.h" #include "symfile.h" -@@ -5764,12 +5765,19 @@ handle_notification (char *buf, size_t l +@@ -6515,12 +6516,19 @@ handle_notification (char *buf, size_t l if SHOULD_WRITE is nonzero. Returns length of data written or read; 0 for error. TARGET is unused. */ @@ -260,7 +260,7 @@ Index: gdb-6.8.50.20090909/gdb/remote.c set_general_thread (inferior_ptid); -@@ -5778,7 +5786,7 @@ remote_xfer_memory (CORE_ADDR mem_addr, +@@ -6529,7 +6537,7 @@ remote_xfer_memory (CORE_ADDR mem_addr, else res = remote_read_bytes (mem_addr, buffer, mem_len); @@ -269,11 +269,11 @@ Index: gdb-6.8.50.20090909/gdb/remote.c } /* Sends a packet with content determined by the printf format string -Index: gdb-6.8.50.20090909/gdb/remote-sim.c +Index: gdb-7.1.90.20100711/gdb/remote-sim.c =================================================================== ---- gdb-6.8.50.20090909.orig/gdb/remote-sim.c 2009-07-02 19:21:06.000000000 +0200 -+++ gdb-6.8.50.20090909/gdb/remote-sim.c 2009-09-09 19:06:57.000000000 +0200 -@@ -752,11 +752,14 @@ gdbsim_prepare_to_store (struct regcache +--- gdb-7.1.90.20100711.orig/gdb/remote-sim.c 2010-05-16 23:11:14.000000000 +0200 ++++ gdb-7.1.90.20100711/gdb/remote-sim.c 2010-07-12 10:46:24.000000000 +0200 +@@ -759,11 +759,14 @@ gdbsim_prepare_to_store (struct regcache Returns the number of bytes transferred. */ @@ -290,11 +290,11 @@ Index: gdb-6.8.50.20090909/gdb/remote-sim.c /* If no program is running yet, then ignore the simulator for memory. Pass the request down to the next target, hopefully an exec file. */ -Index: gdb-6.8.50.20090909/gdb/exec.h +Index: gdb-7.1.90.20100711/gdb/exec.h =================================================================== ---- gdb-6.8.50.20090909.orig/gdb/exec.h 2009-06-12 20:38:36.000000000 +0200 -+++ gdb-6.8.50.20090909/gdb/exec.h 2009-09-09 19:06:57.000000000 +0200 -@@ -56,7 +56,7 @@ extern int resize_section_table (struct +--- gdb-7.1.90.20100711.orig/gdb/exec.h 2010-01-01 08:31:31.000000000 +0100 ++++ gdb-7.1.90.20100711/gdb/exec.h 2010-07-12 10:46:24.000000000 +0200 +@@ -60,7 +60,7 @@ extern int resize_section_table (struct One, and only one, of readbuf or writebuf must be non-NULL. */ diff --git a/gdb-6.3-readnever-20050907.patch b/gdb-6.3-readnever-20050907.patch index 823c38f..7cdc0f7 100644 --- a/gdb-6.3-readnever-20050907.patch +++ b/gdb-6.3-readnever-20050907.patch @@ -11,11 +11,11 @@ * gdb.texinfo (File Options): Document --readnever. -Index: gdb-6.8.50.20090811/gdb/doc/gdb.texinfo +Index: gdb-7.1.90.20100721/gdb/doc/gdb.texinfo =================================================================== ---- gdb-6.8.50.20090811.orig/gdb/doc/gdb.texinfo 2009-08-13 10:14:15.000000000 +0200 -+++ gdb-6.8.50.20090811/gdb/doc/gdb.texinfo 2009-08-13 10:14:18.000000000 +0200 -@@ -991,6 +991,12 @@ Read each symbol file's entire symbol ta +--- gdb-7.1.90.20100721.orig/gdb/doc/gdb.texinfo 2010-07-23 20:58:52.000000000 +0200 ++++ gdb-7.1.90.20100721/gdb/doc/gdb.texinfo 2010-07-23 20:59:15.000000000 +0200 +@@ -998,6 +998,12 @@ Read each symbol file's entire symbol ta the default, which is to read it incrementally as it is needed. This makes startup slower, but makes future operations faster. @@ -28,11 +28,11 @@ Index: gdb-6.8.50.20090811/gdb/doc/gdb.texinfo @end table @node Mode Options -Index: gdb-6.8.50.20090811/gdb/main.c +Index: gdb-7.1.90.20100721/gdb/main.c =================================================================== ---- gdb-6.8.50.20090811.orig/gdb/main.c 2009-08-13 10:14:15.000000000 +0200 -+++ gdb-6.8.50.20090811/gdb/main.c 2009-08-13 10:14:18.000000000 +0200 -@@ -382,6 +382,7 @@ captured_main (void *data) +--- gdb-7.1.90.20100721.orig/gdb/main.c 2010-07-23 20:58:55.000000000 +0200 ++++ gdb-7.1.90.20100721/gdb/main.c 2010-07-23 20:59:15.000000000 +0200 +@@ -391,6 +391,7 @@ captured_main (void *data) {"xdb", no_argument, &xdb_commands, 1}, {"dbx", no_argument, &dbx_commands, 1}, {"readnow", no_argument, &readnow_symbol_files, 1}, @@ -40,7 +40,7 @@ Index: gdb-6.8.50.20090811/gdb/main.c {"r", no_argument, &readnow_symbol_files, 1}, {"quiet", no_argument, &quiet, 1}, {"q", no_argument, &quiet, 1}, -@@ -1030,6 +1031,7 @@ Options:\n\n\ +@@ -1038,6 +1039,7 @@ Options:\n\n\ fputs_unfiltered (_("\ --quiet Do not print version number on startup.\n\ --readnow Fully read symbol files on first access.\n\ @@ -48,11 +48,11 @@ Index: gdb-6.8.50.20090811/gdb/main.c "), stream); fputs_unfiltered (_("\ --se=FILE Use FILE as symbol file and executable file.\n\ -Index: gdb-6.8.50.20090811/gdb/symfile.c +Index: gdb-7.1.90.20100721/gdb/symfile.c =================================================================== ---- gdb-6.8.50.20090811.orig/gdb/symfile.c 2009-08-13 10:14:15.000000000 +0200 -+++ gdb-6.8.50.20090811/gdb/symfile.c 2009-08-13 10:14:18.000000000 +0200 -@@ -79,6 +79,7 @@ static void clear_symtab_users_cleanup ( +--- gdb-7.1.90.20100721.orig/gdb/symfile.c 2010-07-23 20:58:52.000000000 +0200 ++++ gdb-7.1.90.20100721/gdb/symfile.c 2010-07-23 20:59:15.000000000 +0200 +@@ -80,6 +80,7 @@ static void clear_symtab_users_cleanup ( /* Global variables owned by this file */ int readnow_symbol_files; /* Read full symbols immediately */ @@ -60,33 +60,35 @@ Index: gdb-6.8.50.20090811/gdb/symfile.c /* External variables and functions referenced. */ -Index: gdb-6.8.50.20090811/gdb/dwarf2read.c +Index: gdb-7.1.90.20100721/gdb/dwarf2read.c =================================================================== ---- gdb-6.8.50.20090811.orig/gdb/dwarf2read.c 2009-08-13 10:14:15.000000000 +0200 -+++ gdb-6.8.50.20090811/gdb/dwarf2read.c 2009-08-13 10:14:29.000000000 +0200 -@@ -53,6 +53,7 @@ - #include "jv-lang.h" - #include "vec.h" - #include "block.h" +--- gdb-7.1.90.20100721.orig/gdb/dwarf2read.c 2010-07-23 20:58:53.000000000 +0200 ++++ gdb-7.1.90.20100721/gdb/dwarf2read.c 2010-07-23 20:59:26.000000000 +0200 +@@ -54,6 +54,7 @@ + #include "exceptions.h" + #include "gdb_stat.h" + #include "completer.h" +#include "top.h" #include #include "gdb_string.h" -@@ -1245,7 +1246,8 @@ dwarf2_has_info (struct objfile *objfile - +@@ -1283,8 +1284,9 @@ dwarf2_has_info (struct objfile *objfile bfd_map_over_sections (objfile->obfd, dwarf2_locate_sections, NULL); + dwarf2_per_objfile->objfile = objfile; } - return (dwarf2_per_objfile->info.asection != NULL -+ return !readnever_symbol_files -+ && (dwarf2_per_objfile->info.asection != NULL - && dwarf2_per_objfile->abbrev.asection != NULL); +- && dwarf2_per_objfile->abbrev.asection != NULL); ++ return (! readnever_symbol_files ++ && (dwarf2_per_objfile->info.asection != NULL ++ && dwarf2_per_objfile->abbrev.asection != NULL)); } -Index: gdb-6.8.50.20090811/gdb/top.h + /* When loading sections, we can either look for ".", or for +Index: gdb-7.1.90.20100721/gdb/top.h =================================================================== ---- gdb-6.8.50.20090811.orig/gdb/top.h 2009-01-03 06:57:53.000000000 +0100 -+++ gdb-6.8.50.20090811/gdb/top.h 2009-08-13 10:14:18.000000000 +0200 -@@ -59,6 +59,7 @@ extern void set_prompt (char *); +--- gdb-7.1.90.20100721.orig/gdb/top.h 2010-04-07 18:54:39.000000000 +0200 ++++ gdb-7.1.90.20100721/gdb/top.h 2010-07-23 20:59:15.000000000 +0200 +@@ -61,6 +61,7 @@ extern void set_prompt (char *); /* From random places. */ extern int readnow_symbol_files; diff --git a/gdb-6.3-rh-testversion-20041202.patch b/gdb-6.3-rh-testversion-20041202.patch index cf25bcd..7839200 100644 --- a/gdb-6.3-rh-testversion-20041202.patch +++ b/gdb-6.3-rh-testversion-20041202.patch @@ -3,17 +3,17 @@ * gdb.gdb/selftest.exp: Add matching on specific Red Hat only version string. -Index: gdb-6.8/gdb/testsuite/gdb.gdb/selftest.exp +Index: gdb-7.1.90.20100711/gdb/testsuite/gdb.gdb/selftest.exp =================================================================== ---- gdb-6.8.orig/gdb/testsuite/gdb.gdb/selftest.exp 2008-01-26 14:56:37.000000000 +0100 -+++ gdb-6.8/gdb/testsuite/gdb.gdb/selftest.exp 2008-07-14 10:23:50.000000000 +0200 -@@ -354,6 +354,9 @@ proc test_with_self { executable } { +--- gdb-7.1.90.20100711.orig/gdb/testsuite/gdb.gdb/selftest.exp 2010-06-26 08:44:47.000000000 +0200 ++++ gdb-7.1.90.20100711/gdb/testsuite/gdb.gdb/selftest.exp 2010-07-12 09:59:42.000000000 +0200 +@@ -342,6 +342,9 @@ proc test_with_self { executable } { -re ".\[0-9\]+ = +.+ +0x.*\[0-9.\]+.*$gdb_prompt $" { pass "printed version with cast" } -+ -re ".\[0-9\]+ = .Fedora \[\\(\\)0-9.a-z\\-\]+.*$gdb_prompt $" { -+ pass "printed version Fedora only" ++ -re ".\[0-9\]+ = .(Fedora|Red Hat Enterprise Linux) \[\\(\\)0-9.a-z\\-\]+.*$gdb_prompt $" { ++ pass "printed version Fedora or Red Hat Enterprise Linux only" + } - -re ".*$gdb_prompt $" { fail "printed version" } - timeout { fail "(timeout) printed version" } } + + do_steps_and_nexts diff --git a/gdb-6.3-security-errata-20050610.patch b/gdb-6.3-security-errata-20050610.patch index 1092c31..37765f9 100644 --- a/gdb-6.3-security-errata-20050610.patch +++ b/gdb-6.3-security-errata-20050610.patch @@ -19,29 +19,29 @@ Proposed upstream but never committed upstream. (source_command): Update documentation. Check permissions if FROM_TTY is -1. -Index: gdb-6.8.50.20090226/gdb/cli/cli-cmds.c +Index: gdb-7.1.90.20100720/gdb/cli/cli-cmds.c =================================================================== ---- gdb-6.8.50.20090226.orig/gdb/cli/cli-cmds.c 2009-02-27 00:04:32.000000000 +0100 -+++ gdb-6.8.50.20090226/gdb/cli/cli-cmds.c 2009-02-28 07:17:49.000000000 +0100 -@@ -36,6 +36,7 @@ - #include "objfiles.h" +--- gdb-7.1.90.20100720.orig/gdb/cli/cli-cmds.c 2010-05-17 21:28:12.000000000 +0200 ++++ gdb-7.1.90.20100720/gdb/cli/cli-cmds.c 2010-07-21 20:30:30.000000000 +0200 +@@ -39,6 +39,7 @@ #include "source.h" #include "disasm.h" + #include "tracepoint.h" +#include "gdb_stat.h" #include "ui-out.h" -@@ -466,7 +467,7 @@ source_script (char *file, int from_tty) +@@ -487,7 +488,7 @@ Script filename extension recognition is - if (fd == -1) - { -- if (from_tty) -+ if (from_tty > 0) - perror_with_name (file); - else - { -@@ -475,6 +476,29 @@ source_script (char *file, int from_tty) - } + int + find_and_open_script (const char *script_file, int search_path, +- FILE **streamp, char **full_pathp) ++ FILE **streamp, char **full_pathp, int from_tty) + { + char *file; + int fd; +@@ -513,6 +514,32 @@ find_and_open_script (const char *script + return 0; } +#ifdef HAVE_GETUID @@ -51,10 +51,12 @@ Index: gdb-6.8.50.20090226/gdb/cli/cli-cmds.c + + if (fstat (fd, &statbuf) < 0) + { ++ int save_errno = errno; ++ + close (fd); -+ /* Do not do_cleanups (old_cleanups) as FILE is allocated there. -+ perror_with_name calls error which should call the cleanups. */ -+ perror_with_name (file); ++ do_cleanups (old_cleanups); ++ errno = save_errno; ++ return 0; + } + if (statbuf.st_uid != getuid () || (statbuf.st_mode & S_IWOTH)) + { @@ -62,27 +64,37 @@ Index: gdb-6.8.50.20090226/gdb/cli/cli-cmds.c + warning (_("not using untrusted file \"%s\""), file); + close (fd); + do_cleanups (old_cleanups); -+ return; ++ errno = EPERM; ++ return 0; + } + } +#endif + - is_python = source_python; - if (strlen (file) > 3 && !strcmp (&file[strlen (file) - 3], ".py")) - is_python = 1; -@@ -486,6 +510,7 @@ source_script (char *file, int from_tty) - else - script_from_file (stream, file); - -+ /* FILE gets freed by do_cleanups (old_cleanups). */ do_cleanups (old_cleanups); - } -Index: gdb-6.8.50.20090226/gdb/testsuite/gdb.base/gdbinit.exp + *streamp = fdopen (fd, FOPEN_RT); +@@ -572,13 +599,14 @@ source_script_with_search (const char *f + if (file == NULL || *file == 0) + error (_("source command requires file name of file to source.")); + +- if (!find_and_open_script (file, search_path, &stream, &full_path)) ++ if (!find_and_open_script (file, search_path, &stream, &full_path, ++ from_tty)) + { + /* The script wasn't found, or was otherwise inaccessible. + If the source command was invoked interactively, throw an error. + Otherwise (e.g. if it was invoked by a script), silently ignore + the error. */ +- if (from_tty) ++ if (from_tty > 0) + perror_with_name (file); + else + return; +Index: gdb-7.1.90.20100720/gdb/testsuite/gdb.base/gdbinit.exp =================================================================== --- /dev/null 1970-01-01 00:00:00.000000000 +0000 -+++ gdb-6.8.50.20090226/gdb/testsuite/gdb.base/gdbinit.exp 2009-02-28 07:15:57.000000000 +0100 -@@ -0,0 +1,98 @@ ++++ gdb-7.1.90.20100720/gdb/testsuite/gdb.base/gdbinit.exp 2010-07-20 22:25:40.000000000 +0200 +@@ -0,0 +1,91 @@ +# Copyright 2005 +# Free Software Foundation, Inc. + @@ -105,13 +117,6 @@ Index: gdb-6.8.50.20090226/gdb/testsuite/gdb.base/gdbinit.exp + +# This file was written by Jeff Johnston . + -+if $tracelevel then { -+ strace $tracelevel -+} -+ -+set prms_id 0 -+set bug_id 0 -+ +# are we on a target board +if [is_remote target] { + return @@ -181,17 +186,17 @@ Index: gdb-6.8.50.20090226/gdb/testsuite/gdb.base/gdbinit.exp +} + +remote_exec build "rm .gdbinit" -Index: gdb-6.8.50.20090226/gdb/testsuite/gdb.base/gdbinit.sample +Index: gdb-7.1.90.20100720/gdb/testsuite/gdb.base/gdbinit.sample =================================================================== --- /dev/null 1970-01-01 00:00:00.000000000 +0000 -+++ gdb-6.8.50.20090226/gdb/testsuite/gdb.base/gdbinit.sample 2009-02-28 07:15:57.000000000 +0100 ++++ gdb-7.1.90.20100720/gdb/testsuite/gdb.base/gdbinit.sample 2010-07-20 22:25:40.000000000 +0200 @@ -0,0 +1 @@ +echo "\nin gdbinit" -Index: gdb-6.8.50.20090226/gdb/main.c +Index: gdb-7.1.90.20100720/gdb/main.c =================================================================== ---- gdb-6.8.50.20090226.orig/gdb/main.c 2009-02-27 00:04:32.000000000 +0100 -+++ gdb-6.8.50.20090226/gdb/main.c 2009-02-28 07:15:57.000000000 +0100 -@@ -855,7 +855,7 @@ Excess command line arguments ignored. ( +--- gdb-7.1.90.20100720.orig/gdb/main.c 2010-06-26 08:44:47.000000000 +0200 ++++ gdb-7.1.90.20100720/gdb/main.c 2010-07-21 20:09:03.000000000 +0200 +@@ -794,7 +794,7 @@ Excess command line arguments ignored. ( debugging or what directory you are in. */ if (home_gdbinit && !inhibit_gdbinit) @@ -200,12 +205,39 @@ Index: gdb-6.8.50.20090226/gdb/main.c /* Now perform all the actions indicated by the arguments. */ if (cdarg != NULL) -@@ -924,7 +924,7 @@ Can't attach to process and specify a co +@@ -868,7 +868,7 @@ Can't attach to process and specify a co /* Read the .gdbinit file in the current directory, *if* it isn't the same as the $HOME/.gdbinit file (it should exist, also). */ if (local_gdbinit && !inhibit_gdbinit) - catch_command_errors (source_script, local_gdbinit, 0, RETURN_MASK_ALL); + catch_command_errors (source_script, local_gdbinit, -1, RETURN_MASK_ALL); - for (i = 0; i < ncmd; i++) - { + /* Now that all .gdbinit's have been read and all -d options have been + processed, we can read any scripts mentioned in SYMARG. +Index: gdb-7.1.90.20100720/gdb/python/py-auto-load.c +=================================================================== +--- gdb-7.1.90.20100720.orig/gdb/python/py-auto-load.c 2010-05-17 23:23:25.000000000 +0200 ++++ gdb-7.1.90.20100720/gdb/python/py-auto-load.c 2010-07-20 22:25:40.000000000 +0200 +@@ -219,7 +219,7 @@ source_section_scripts (struct objfile * + } + + opened = find_and_open_script (file, 1 /*search_path*/, +- &stream, &full_path); ++ &stream, &full_path, 1 /* from_tty */); + + /* If the file is not found, we still record the file in the hash table, + we only want to print an error message once. +Index: gdb-7.1.90.20100720/gdb/cli/cli-cmds.h +=================================================================== +--- gdb-7.1.90.20100720.orig/gdb/cli/cli-cmds.h 2010-05-03 01:52:14.000000000 +0200 ++++ gdb-7.1.90.20100720/gdb/cli/cli-cmds.h 2010-07-20 22:25:40.000000000 +0200 +@@ -126,7 +126,8 @@ extern void source_script (char *, int); + /* Exported to objfiles.c. */ + + extern int find_and_open_script (const char *file, int search_path, +- FILE **streamp, char **full_path); ++ FILE **streamp, char **full_path, ++ int from_tty); + + /* Command tracing state. */ + diff --git a/gdb-6.3-step-thread-exit-20050211-test.patch b/gdb-6.3-step-thread-exit-20050211-test.patch index fc73d9f..11c2a44 100644 --- a/gdb-6.3-step-thread-exit-20050211-test.patch +++ b/gdb-6.3-step-thread-exit-20050211-test.patch @@ -62,7 +62,7 @@ Index: gdb-6.8.50.20081128/gdb/testsuite/gdb.threads/step-thread-exit.exp =================================================================== --- /dev/null 1970-01-01 00:00:00.000000000 +0000 +++ gdb-6.8.50.20081128/gdb/testsuite/gdb.threads/step-thread-exit.exp 2008-12-08 22:22:14.000000000 +0100 -@@ -0,0 +1,130 @@ +@@ -0,0 +1,123 @@ +# This testcase is part of GDB, the GNU debugger. + +# Copyright 2005 Free Software Foundation, Inc. @@ -83,13 +83,6 @@ Index: gdb-6.8.50.20081128/gdb/testsuite/gdb.threads/step-thread-exit.exp + +# Check that GDB can step over a thread exit. + -+if $tracelevel { -+ strace $tracelevel -+} -+ -+set prms_id 0 -+set bug_id 0 -+ +set testfile "step-thread-exit" +set srcfile ${testfile}.c +set binfile ${objdir}/${subdir}/${testfile} diff --git a/gdb-6.3-test-dtorfix-20050121.patch b/gdb-6.3-test-dtorfix-20050121.patch index df46859..51308bc 100644 --- a/gdb-6.3-test-dtorfix-20050121.patch +++ b/gdb-6.3-test-dtorfix-20050121.patch @@ -129,7 +129,7 @@ Index: gdb/testsuite/ChangeLog +} --- gdb-6.3/gdb/testsuite/gdb.cp/constructortest.exp.fix Fri Jan 21 17:07:02 2005 +++ gdb-6.3/gdb/testsuite/gdb.cp/constructortest.exp Fri Jan 21 17:05:29 2005 -@@ -0,0 +1,131 @@ +@@ -0,0 +1,130 @@ +# This testcase is part of GDB, the GNU debugger. + +# Copyright 2005, 2007 Free Software Foundation, Inc. @@ -150,13 +150,6 @@ Index: gdb/testsuite/ChangeLog + +# Check that GDB can break at multiple forms of constructors. + -+if $tracelevel { -+ strace $tracelevel -+} -+ -+set prms_id 0 -+set bug_id 0 -+ +set testfile "constructortest" +set srcfile ${testfile}.cc +set binfile ${objdir}/${subdir}/${testfile} @@ -179,8 +172,9 @@ Index: gdb/testsuite/ChangeLog + gdb_suppress_tests +} + -+# Break on the various forms of the A::A constructor -+gdb_test "break A\:\:A" "Breakpoint 2 at .* \\(2 locations\\)" "breaking on A::A" ++# Break on the various forms of the A::A constructor. ++# " (2 locations)" is displayed depending on G++ version. ++gdb_test "break A\:\:A" "Breakpoint 2 at .*" "breaking on A::A" + +# Verify that we break for the A constructor two times +# Once for new A and once for new B @@ -206,7 +200,8 @@ Index: gdb/testsuite/ChangeLog +gdb_test "break 'A::A()'" "" "break in constructor A 2" +gdb_continue_to_breakpoint "First line A" +set second_line [gdb_get_line_number "Second line A"] -+gdb_test "break $second_line" "Breakpoint .*, line $second_line. \\(2 locations\\)" "break by line in constructor" ++# " (2 locations)" is displayed depending on G++ version. ++gdb_test "break $second_line" "Breakpoint .*, line $second_line\\..*" "break by line in constructor" +gdb_continue_to_breakpoint "Second line A" +gdb_test "bt" "#0.*A.*#1.*main.*" "Verify in in-charge A::A second line" +gdb_continue_to_breakpoint "Second line A" @@ -217,7 +212,8 @@ Index: gdb/testsuite/ChangeLog +gdb_test "break 'A::~A()'" "" "break in constructor ~A 2" +gdb_continue_to_breakpoint "First line ~A" +set second_line_dtor [gdb_get_line_number "Second line ~A"] -+gdb_test "break $second_line_dtor" "Breakpoint .*, line $second_line_dtor. \\(2 locations\\)" "break by line in destructor" ++# " (2 locations)" is displayed depending on G++ version. ++gdb_test "break $second_line_dtor" "Breakpoint .*, line $second_line_dtor\\..*" "break by line in destructor" +gdb_continue_to_breakpoint "Second line ~A" +gdb_test "bt" "#0.*A.*#1.*main.*" "Verify in in-charge A::~A second line" +# FIXME: Analyse this case better. @@ -232,8 +228,11 @@ Index: gdb/testsuite/ChangeLog +gdb_load ${binfile} +runto_main + ++set first_line_dtor [gdb_get_line_number "First line ~C"] ++set define_line_dtor [gdb_get_line_number "Destructor C"] +# Break on the various forms of the C::~C destructor -+gdb_test "break C\:\:~C" "Breakpoint .* \\(3 locations\\)" "breaking on C::~C" ++# " ([23] locations)" is displayed depending on G++ version. ++gdb_test "break C\:\:~C" "Breakpoint .*, line ($define_line_dtor|$define_line_dtor)\\..*" "breaking on C::~C" +gdb_continue_to_breakpoint "First line ~C" + +# Verify that we can break by line number in a destructor and find @@ -242,8 +241,8 @@ Index: gdb/testsuite/ChangeLog +gdb_load ${binfile} +delete_breakpoints + -+set first_line_dtor [gdb_get_line_number "First line ~C"] -+gdb_test "break $first_line_dtor" "Breakpoint .*, line $first_line_dtor. \\(3 locations\\)" "break by line in destructor" ++# " (3 locations)" is displayed depending on G++ version. ++gdb_test "break $first_line_dtor" "Breakpoint .*, line $first_line_dtor\\..*" "break by line in destructor" + +# Run to `main' where we begin our tests. +# Set the breakpoints first to test PIE multiple-PC BREAKPOINT_RE_SET. diff --git a/gdb-6.3-test-movedir-20050125.patch b/gdb-6.3-test-movedir-20050125.patch index eb3cf73..4b05c13 100644 --- a/gdb-6.3-test-movedir-20050125.patch +++ b/gdb-6.3-test-movedir-20050125.patch @@ -23,7 +23,7 @@ Index: gdb-6.8.50.20081128/gdb/testsuite/gdb.base/move-dir.exp =================================================================== --- /dev/null 1970-01-01 00:00:00.000000000 +0000 +++ gdb-6.8.50.20081128/gdb/testsuite/gdb.base/move-dir.exp 2008-12-07 10:13:01.000000000 +0100 -@@ -0,0 +1,67 @@ +@@ -0,0 +1,57 @@ +# Copyright 2005 +# Free Software Foundation, Inc. + @@ -41,16 +41,6 @@ Index: gdb-6.8.50.20081128/gdb/testsuite/gdb.base/move-dir.exp +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + -+# Please email any bugs, comments, and/or additions to this file to: -+# bug-gdb@prep.ai.mit.edu -+ -+if $tracelevel then { -+ strace $tracelevel -+} -+ -+set prms_id 0 -+set bug_id 0 -+ +set testfile "move-dir" +set srcfile ${testfile}.c +set incfile ${testfile}.h diff --git a/gdb-6.3-test-pie-20050107.patch b/gdb-6.3-test-pie-20050107.patch index 9208981..440b283 100644 --- a/gdb-6.3-test-pie-20050107.patch +++ b/gdb-6.3-test-pie-20050107.patch @@ -1,29 +1,29 @@ -Index: gdb-6.8.50.20090909/gdb/testsuite/configure.ac +Index: gdb-7.0.90.20100306/gdb/testsuite/configure.ac =================================================================== ---- gdb-6.8.50.20090909.orig/gdb/testsuite/configure.ac 2009-07-31 17:38:16.000000000 +0200 -+++ gdb-6.8.50.20090909/gdb/testsuite/configure.ac 2009-09-09 19:06:01.000000000 +0200 +--- gdb-7.0.90.20100306.orig/gdb/testsuite/configure.ac 2010-02-19 20:16:36.000000000 +0100 ++++ gdb-7.0.90.20100306/gdb/testsuite/configure.ac 2010-03-06 23:19:56.000000000 +0100 @@ -144,6 +144,6 @@ AC_OUTPUT([Makefile \ gdb.cp/Makefile gdb.disasm/Makefile gdb.dwarf2/Makefile \ - gdb.fortran/Makefile gdb.server/Makefile \ - gdb.java/Makefile gdb.mi/Makefile gdb.modula2/Makefile \ + gdb.fortran/Makefile gdb.server/Makefile gdb.java/Makefile \ + gdb.mi/Makefile gdb.modula2/Makefile gdb.multi/Makefile \ - gdb.objc/Makefile gdb.opt/Makefile gdb.pascal/Makefile \ + gdb.objc/Makefile gdb.opt/Makefile gdb.pascal/Makefile gdb.pie/Makefile \ gdb.python/Makefile gdb.reverse/Makefile \ gdb.threads/Makefile gdb.trace/Makefile gdb.xml/Makefile]) -Index: gdb-6.8.50.20090909/gdb/testsuite/configure +Index: gdb-7.0.90.20100306/gdb/testsuite/configure =================================================================== ---- gdb-6.8.50.20090909.orig/gdb/testsuite/configure 2009-08-22 18:56:43.000000000 +0200 -+++ gdb-6.8.50.20090909/gdb/testsuite/configure 2009-09-09 19:06:27.000000000 +0200 +--- gdb-7.0.90.20100306.orig/gdb/testsuite/configure 2010-02-19 20:16:36.000000000 +0100 ++++ gdb-7.0.90.20100306/gdb/testsuite/configure 2010-03-06 23:20:12.000000000 +0100 @@ -3515,7 +3515,7 @@ done --ac_config_files="$ac_config_files Makefile gdb.ada/Makefile gdb.arch/Makefile gdb.asm/Makefile gdb.base/Makefile gdb.cp/Makefile gdb.disasm/Makefile gdb.dwarf2/Makefile gdb.fortran/Makefile gdb.server/Makefile gdb.java/Makefile gdb.mi/Makefile gdb.modula2/Makefile gdb.objc/Makefile gdb.opt/Makefile gdb.pascal/Makefile gdb.python/Makefile gdb.reverse/Makefile gdb.threads/Makefile gdb.trace/Makefile gdb.xml/Makefile" -+ac_config_files="$ac_config_files Makefile gdb.ada/Makefile gdb.arch/Makefile gdb.asm/Makefile gdb.base/Makefile gdb.cp/Makefile gdb.disasm/Makefile gdb.dwarf2/Makefile gdb.fortran/Makefile gdb.server/Makefile gdb.java/Makefile gdb.mi/Makefile gdb.modula2/Makefile gdb.objc/Makefile gdb.opt/Makefile gdb.pascal/Makefile gdb.pie/Makefile gdb.python/Makefile gdb.reverse/Makefile gdb.threads/Makefile gdb.trace/Makefile gdb.xml/Makefile" +-ac_config_files="$ac_config_files Makefile gdb.ada/Makefile gdb.arch/Makefile gdb.asm/Makefile gdb.base/Makefile gdb.cp/Makefile gdb.disasm/Makefile gdb.dwarf2/Makefile gdb.fortran/Makefile gdb.server/Makefile gdb.java/Makefile gdb.mi/Makefile gdb.modula2/Makefile gdb.multi/Makefile gdb.objc/Makefile gdb.opt/Makefile gdb.pascal/Makefile gdb.python/Makefile gdb.reverse/Makefile gdb.threads/Makefile gdb.trace/Makefile gdb.xml/Makefile" ++ac_config_files="$ac_config_files Makefile gdb.ada/Makefile gdb.arch/Makefile gdb.asm/Makefile gdb.base/Makefile gdb.cp/Makefile gdb.disasm/Makefile gdb.dwarf2/Makefile gdb.fortran/Makefile gdb.server/Makefile gdb.java/Makefile gdb.mi/Makefile gdb.modula2/Makefile gdb.multi/Makefile gdb.objc/Makefile gdb.opt/Makefile gdb.pascal/Makefile gdb.pie/Makefile gdb.python/Makefile gdb.reverse/Makefile gdb.threads/Makefile gdb.trace/Makefile gdb.xml/Makefile" cat >confcache <<\_ACEOF # This file is a shell script that caches the results of configure -@@ -4231,6 +4231,7 @@ do +@@ -4232,6 +4232,7 @@ do "gdb.objc/Makefile") CONFIG_FILES="$CONFIG_FILES gdb.objc/Makefile" ;; "gdb.opt/Makefile") CONFIG_FILES="$CONFIG_FILES gdb.opt/Makefile" ;; "gdb.pascal/Makefile") CONFIG_FILES="$CONFIG_FILES gdb.pascal/Makefile" ;; @@ -31,10 +31,10 @@ Index: gdb-6.8.50.20090909/gdb/testsuite/configure "gdb.python/Makefile") CONFIG_FILES="$CONFIG_FILES gdb.python/Makefile" ;; "gdb.reverse/Makefile") CONFIG_FILES="$CONFIG_FILES gdb.reverse/Makefile" ;; "gdb.threads/Makefile") CONFIG_FILES="$CONFIG_FILES gdb.threads/Makefile" ;; -Index: gdb-6.8.50.20090909/gdb/testsuite/gdb.pie/attach.c +Index: gdb-7.0.90.20100306/gdb/testsuite/gdb.pie/attach.c =================================================================== --- /dev/null 1970-01-01 00:00:00.000000000 +0000 -+++ gdb-6.8.50.20090909/gdb/testsuite/gdb.pie/attach.c 2009-09-09 19:06:01.000000000 +0200 ++++ gdb-7.0.90.20100306/gdb/testsuite/gdb.pie/attach.c 2010-03-06 23:19:31.000000000 +0100 @@ -0,0 +1,20 @@ +/* This program is intended to be started outside of gdb, and then + attached to by gdb. Thus, it simply spins in a loop. The loop @@ -56,10 +56,10 @@ Index: gdb-6.8.50.20090909/gdb/testsuite/gdb.pie/attach.c + } + return 0; +} -Index: gdb-6.8.50.20090909/gdb/testsuite/gdb.pie/attach2.c +Index: gdb-7.0.90.20100306/gdb/testsuite/gdb.pie/attach2.c =================================================================== --- /dev/null 1970-01-01 00:00:00.000000000 +0000 -+++ gdb-6.8.50.20090909/gdb/testsuite/gdb.pie/attach2.c 2009-09-09 19:06:01.000000000 +0200 ++++ gdb-7.0.90.20100306/gdb/testsuite/gdb.pie/attach2.c 2010-03-06 23:19:31.000000000 +0100 @@ -0,0 +1,24 @@ +/* This program is intended to be started outside of gdb, and then + attached to by gdb. Thus, it simply spins in a loop. The loop @@ -85,10 +85,10 @@ Index: gdb-6.8.50.20090909/gdb/testsuite/gdb.pie/attach2.c + } + return (0); +} -Index: gdb-6.8.50.20090909/gdb/testsuite/gdb.pie/break.c +Index: gdb-7.0.90.20100306/gdb/testsuite/gdb.pie/break.c =================================================================== --- /dev/null 1970-01-01 00:00:00.000000000 +0000 -+++ gdb-6.8.50.20090909/gdb/testsuite/gdb.pie/break.c 2009-09-09 19:06:01.000000000 +0200 ++++ gdb-7.0.90.20100306/gdb/testsuite/gdb.pie/break.c 2010-03-06 23:19:31.000000000 +0100 @@ -0,0 +1,146 @@ +/* This testcase is part of GDB, the GNU debugger. + @@ -236,10 +236,10 @@ Index: gdb-6.8.50.20090909/gdb/testsuite/gdb.pie/break.c + } + return 0; +} -Index: gdb-6.8.50.20090909/gdb/testsuite/gdb.pie/break1.c +Index: gdb-7.0.90.20100306/gdb/testsuite/gdb.pie/break1.c =================================================================== --- /dev/null 1970-01-01 00:00:00.000000000 +0000 -+++ gdb-6.8.50.20090909/gdb/testsuite/gdb.pie/break1.c 2009-09-09 19:06:01.000000000 +0200 ++++ gdb-7.0.90.20100306/gdb/testsuite/gdb.pie/break1.c 2010-03-06 23:19:31.000000000 +0100 @@ -0,0 +1,44 @@ +/* This testcase is part of GDB, the GNU debugger. + @@ -285,10 +285,10 @@ Index: gdb-6.8.50.20090909/gdb/testsuite/gdb.pie/break1.c +void marker3 (a, b) char *a, *b; {} /* set breakpoint 18 here */ +void marker4 (d) long d; {} /* set breakpoint 13 here */ +#endif -Index: gdb-6.8.50.20090909/gdb/testsuite/gdb.pie/coremaker.c +Index: gdb-7.0.90.20100306/gdb/testsuite/gdb.pie/coremaker.c =================================================================== --- /dev/null 1970-01-01 00:00:00.000000000 +0000 -+++ gdb-6.8.50.20090909/gdb/testsuite/gdb.pie/coremaker.c 2009-09-09 19:06:01.000000000 +0200 ++++ gdb-7.0.90.20100306/gdb/testsuite/gdb.pie/coremaker.c 2010-03-06 23:19:31.000000000 +0100 @@ -0,0 +1,142 @@ +/* Copyright 1992, 1993, 1994, 1995, 1996, 1999 + Free Software Foundation, Inc. @@ -432,11 +432,11 @@ Index: gdb-6.8.50.20090909/gdb/testsuite/gdb.pie/coremaker.c + return 0; +} + -Index: gdb-6.8.50.20090909/gdb/testsuite/gdb.pie/attach.exp +Index: gdb-7.0.90.20100306/gdb/testsuite/gdb.pie/attach.exp =================================================================== --- /dev/null 1970-01-01 00:00:00.000000000 +0000 -+++ gdb-6.8.50.20090909/gdb/testsuite/gdb.pie/attach.exp 2009-09-09 19:06:01.000000000 +0200 -@@ -0,0 +1,433 @@ ++++ gdb-7.0.90.20100306/gdb/testsuite/gdb.pie/attach.exp 2010-03-06 23:19:31.000000000 +0100 +@@ -0,0 +1,423 @@ +# Copyright 1997, 1999, 2002 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify @@ -453,16 +453,6 @@ Index: gdb-6.8.50.20090909/gdb/testsuite/gdb.pie/attach.exp +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + -+# Please email any bugs, comments, and/or additions to this file to: -+# bug-gdb@prep.ai.mit.edu -+ -+if $tracelevel then { -+ strace $tracelevel -+ } -+ -+set prms_id 0 -+set bug_id 0 -+ +# On HP-UX 11.0, this test is causing a process running the program +# "attach" to be left around spinning. Until we figure out why, I am +# commenting out the test to avoid polluting tiamat (our 11.0 nightly @@ -870,11 +860,11 @@ Index: gdb-6.8.50.20090909/gdb/testsuite/gdb.pie/attach.exp +do_call_attach_tests + +return 0 -Index: gdb-6.8.50.20090909/gdb/testsuite/gdb.pie/break.exp +Index: gdb-7.0.90.20100306/gdb/testsuite/gdb.pie/break.exp =================================================================== --- /dev/null 1970-01-01 00:00:00.000000000 +0000 -+++ gdb-6.8.50.20090909/gdb/testsuite/gdb.pie/break.exp 2009-09-09 19:06:01.000000000 +0200 -@@ -0,0 +1,977 @@ ++++ gdb-7.0.90.20100306/gdb/testsuite/gdb.pie/break.exp 2010-03-06 23:19:31.000000000 +0100 +@@ -0,0 +1,966 @@ +# Copyright 1988, 1990, 1991, 1992, 1994, 1995, 1996, 1997, 1998, 1999, +# 2000, 2002, 2003, 2004 +# Free Software Foundation, Inc. @@ -900,17 +890,6 @@ Index: gdb-6.8.50.20090909/gdb/testsuite/gdb.pie/break.exp + +# Test the same stuff but with PIE executables + -+if $tracelevel then { -+ strace $tracelevel -+} -+ -+ -+# -+# test running programs -+# -+set prms_id 0 -+set bug_id 0 -+ +set testfile "break" +set srcfile ${testfile}.c +set srcfile1 ${testfile}1.c @@ -1852,11 +1831,11 @@ Index: gdb-6.8.50.20090909/gdb/testsuite/gdb.pie/break.exp + send_gdb "set args main\n" + gdb_expect -re ".*$gdb_prompt $" {} +} -Index: gdb-6.8.50.20090909/gdb/testsuite/gdb.pie/corefile.exp +Index: gdb-7.0.90.20100306/gdb/testsuite/gdb.pie/corefile.exp =================================================================== --- /dev/null 1970-01-01 00:00:00.000000000 +0000 -+++ gdb-6.8.50.20090909/gdb/testsuite/gdb.pie/corefile.exp 2009-09-09 19:06:01.000000000 +0200 -@@ -0,0 +1,243 @@ ++++ gdb-7.0.90.20100306/gdb/testsuite/gdb.pie/corefile.exp 2010-03-06 23:19:31.000000000 +0100 +@@ -0,0 +1,233 @@ +# Copyright 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000 +# Free Software Foundation, Inc. + @@ -1874,18 +1853,8 @@ Index: gdb-6.8.50.20090909/gdb/testsuite/gdb.pie/corefile.exp +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + -+# Please email any bugs, comments, and/or additions to this file to: -+# bug-gdb@prep.ai.mit.edu -+ +# This file was written by Fred Fish. (fnf@cygnus.com) + -+if $tracelevel then { -+ strace $tracelevel -+} -+ -+set prms_id 0 -+set bug_id 0 -+ +# are we on a target board +if ![isnative] then { + return @@ -2097,13 +2066,13 @@ Index: gdb-6.8.50.20090909/gdb/testsuite/gdb.pie/corefile.exp +# test reinit_frame_cache + +gdb_load ${binfile} -+gdb_test "up" "#\[0-9\]* *\[0-9xa-fH'\]* in .* \\(\\).*" "up in corefile.exp (reinit)" ++gdb_test "up" "#\[0-9\]* *\[0-9xa-fH'\]* in .* \\(.*\\).*" "up in corefile.exp (reinit)" + +gdb_test "core" "No core file now." -Index: gdb-6.8.50.20090909/gdb/testsuite/gdb.pie/Makefile.in +Index: gdb-7.0.90.20100306/gdb/testsuite/gdb.pie/Makefile.in =================================================================== --- /dev/null 1970-01-01 00:00:00.000000000 +0000 -+++ gdb-6.8.50.20090909/gdb/testsuite/gdb.pie/Makefile.in 2009-09-09 19:06:01.000000000 +0200 ++++ gdb-7.0.90.20100306/gdb/testsuite/gdb.pie/Makefile.in 2010-03-06 23:19:31.000000000 +0100 @@ -0,0 +1,19 @@ +VPATH = @srcdir@ +srcdir = @srcdir@ diff --git a/gdb-6.3-threaded-watchpoints2-20050225.patch b/gdb-6.3-threaded-watchpoints2-20050225.patch index 859638d..187a33e 100644 --- a/gdb-6.3-threaded-watchpoints2-20050225.patch +++ b/gdb-6.3-threaded-watchpoints2-20050225.patch @@ -114,7 +114,7 @@ Index: gdb-6.5/gdb/testsuite/gdb.threads/watchthreads2.exp =================================================================== --- /dev/null 1970-01-01 00:00:00.000000000 +0000 +++ gdb-6.5/gdb/testsuite/gdb.threads/watchthreads-threaded.exp 2006-07-12 01:54:29.000000000 -0300 -@@ -0,0 +1,133 @@ +@@ -0,0 +1,126 @@ +# This testcase is part of GDB, the GNU debugger. + +# Copyright 2005 Free Software Foundation, Inc. @@ -135,13 +135,6 @@ Index: gdb-6.5/gdb/testsuite/gdb.threads/watchthreads2.exp + +# Check that GDB can support multiple watchpoints across threads. + -+if $tracelevel { -+ strace $tracelevel -+} -+ -+set prms_id 0 -+set bug_id 0 -+ +# This test verifies that a watchpoint is detected in the proper thread +# so the test is only meaningful on a system with hardware watchpoints. +if [target_info exists gdb,no_hardware_watchpoints] { diff --git a/gdb-6.3-watchpoint-cond-gone-test.patch b/gdb-6.3-watchpoint-cond-gone-test.patch deleted file mode 100644 index cd8a237..0000000 --- a/gdb-6.3-watchpoint-cond-gone-test.patch +++ /dev/null @@ -1,128 +0,0 @@ ---- /dev/null 2008-04-03 00:39:30.714021604 +0200 -+++ gdb-6.3/gdb/testsuite/gdb.base/watchpoint-cond-gone-stripped.c 2008-04-05 20:26:29.000000000 +0200 -@@ -0,0 +1,23 @@ -+/* This testcase is part of GDB, the GNU debugger. -+ -+ Copyright 2008 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. */ -+ -+void -+jumper (void (*jumpto) (void)) -+{ -+ (*jumpto) (); -+} ---- /dev/null 2008-04-03 00:39:30.714021604 +0200 -+++ gdb-6.3/gdb/testsuite/gdb.base/watchpoint-cond-gone.c 2008-04-05 20:26:48.000000000 +0200 -@@ -0,0 +1,37 @@ -+/* This testcase is part of GDB, the GNU debugger. -+ -+ Copyright 2008 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. */ -+ -+extern void jumper (void (*jumpto) (void)); -+ -+void -+func () -+{ -+ int a, b, c; -+ -+ a = b = c = 5; -+ a = b = c = 10; /* watchpoint-here */ -+ c = a + b; -+} -+ -+int -+main () -+{ -+ jumper (func); -+ -+ return 0; -+} ---- /dev/null 2008-04-03 00:39:30.714021604 +0200 -+++ gdb-6.3/gdb/testsuite/gdb.base/watchpoint-cond-gone.exp 2008-04-05 20:33:19.000000000 +0200 -@@ -0,0 +1,59 @@ -+# Copyright 2008 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. -+ -+if $tracelevel then { -+ strace $tracelevel -+} -+ -+set testfile "watchpoint-cond-gone" -+set srcfile ${testfile}.c -+set srcfilestripped ${testfile}-stripped.c -+set objfilestripped ${objdir}/${subdir}/${testfile}-stripped.o -+set binfile ${objdir}/${subdir}/${testfile} -+ -+# We need to generate a function without DWARF to crash older GDB. -+# Stepping into a dynamic function trampoline or stepping out of MAIN may work -+# but it is not a reliable FAIL case. -+ -+if { [gdb_compile "${srcdir}/${subdir}/${srcfilestripped}" "${objfilestripped}" object {}] != "" } { -+ gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." -+} -+ -+if { [gdb_compile "${srcdir}/${subdir}/${srcfile} ${objfilestripped}" "${binfile}" executable {debug}] != "" } { -+ gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." -+} -+ -+gdb_exit -+gdb_start -+gdb_reinitialize_dir $srcdir/$subdir -+gdb_load ${binfile} -+ -+# Problem does not occur otherwise. -+gdb_test "set can-use-hw-watchpoints 0" -+ -+runto_main -+gdb_breakpoint [gdb_get_line_number "watchpoint-here"] -+gdb_continue_to_breakpoint "Place to set the watchpoint" -+ -+# The condition `c == 30' is the tested culprit. -+gdb_test "watch c if c == 30" "" "Place the watchpoint" -+ -+# No functionality, just to check the state. -+gdb_test "backtrace" -+ -+gdb_test "finish" \ -+ "Watchpoint .* deleted because the program has left the block in.*which its expression is valid..*in (jumper|func).*" \ -+ "Catch the no longer valid watchpoint" diff --git a/gdb-6.5-bz185337-resolve-tls-without-debuginfo-v2.patch b/gdb-6.5-bz185337-resolve-tls-without-debuginfo-v2.patch index 9dd75d4..94c0072 100644 --- a/gdb-6.5-bz185337-resolve-tls-without-debuginfo-v2.patch +++ b/gdb-6.5-bz185337-resolve-tls-without-debuginfo-v2.patch @@ -30,11 +30,11 @@ glibc-debuginfo-2.7-2.x86_64: /usr/lib/debug/lib64/libc.so.6.debug: <81a2> DW_AT_name : (indirect string, offset: 0x280e): __errno_location <81a8> DW_AT_MIPS_linkage_name: (indirect string, offset: 0x2808): *__GI___errno_location -Index: gdb-6.8.50.20090802/gdb/gdbtypes.c +Index: gdb-7.0.50.20100128/gdb/gdbtypes.c =================================================================== ---- gdb-6.8.50.20090802.orig/gdb/gdbtypes.c 2009-08-03 09:50:57.000000000 +0200 -+++ gdb-6.8.50.20090802/gdb/gdbtypes.c 2009-08-03 15:42:51.000000000 +0200 -@@ -3769,6 +3769,9 @@ gdbtypes_post_init (struct gdbarch *gdba +--- gdb-7.0.50.20100128.orig/gdb/gdbtypes.c 2010-01-28 12:52:17.000000000 +0100 ++++ gdb-7.0.50.20100128/gdb/gdbtypes.c 2010-01-28 12:52:48.000000000 +0100 +@@ -3978,6 +3978,9 @@ gdbtypes_post_init (struct gdbarch *gdba = arch_type (gdbarch, TYPE_CODE_INTERNAL_FUNCTION, 0, ""); @@ -44,11 +44,11 @@ Index: gdb-6.8.50.20090802/gdb/gdbtypes.c return builtin_type; } -Index: gdb-6.8.50.20090802/gdb/gdbtypes.h +Index: gdb-7.0.50.20100128/gdb/gdbtypes.h =================================================================== ---- gdb-6.8.50.20090802.orig/gdb/gdbtypes.h 2009-08-03 09:50:57.000000000 +0200 -+++ gdb-6.8.50.20090802/gdb/gdbtypes.h 2009-08-03 15:40:02.000000000 +0200 -@@ -1128,6 +1128,8 @@ struct builtin_type +--- gdb-7.0.50.20100128.orig/gdb/gdbtypes.h 2010-01-28 12:52:17.000000000 +0100 ++++ gdb-7.0.50.20100128/gdb/gdbtypes.h 2010-01-28 12:52:48.000000000 +0100 +@@ -1245,6 +1245,8 @@ struct builtin_type /* This type is used to represent a GDB internal function. */ struct type *internal_fn; @@ -57,11 +57,11 @@ Index: gdb-6.8.50.20090802/gdb/gdbtypes.h }; /* Return the type table for the specified architecture. */ -Index: gdb-6.8.50.20090802/gdb/parse.c +Index: gdb-7.0.50.20100128/gdb/parse.c =================================================================== ---- gdb-6.8.50.20090802.orig/gdb/parse.c 2009-08-03 09:50:57.000000000 +0200 -+++ gdb-6.8.50.20090802/gdb/parse.c 2009-08-03 15:41:54.000000000 +0200 -@@ -510,7 +510,11 @@ write_exp_msymbol (struct minimal_symbol +--- gdb-7.0.50.20100128.orig/gdb/parse.c 2010-01-28 12:52:19.000000000 +0100 ++++ gdb-7.0.50.20100128/gdb/parse.c 2010-01-28 12:53:20.000000000 +0100 +@@ -509,7 +509,11 @@ write_exp_msymbol (struct minimal_symbol case mst_text: case mst_file_text: case mst_solib_trampoline: @@ -73,12 +73,12 @@ Index: gdb-6.8.50.20090802/gdb/parse.c + write_exp_elt_type (objfile_type (objfile)->nodebug_text_symbol); break; - case mst_data: -Index: gdb-6.8.50.20090802/gdb/target.c + case mst_text_gnu_ifunc: +Index: gdb-7.0.50.20100128/gdb/target.c =================================================================== ---- gdb-6.8.50.20090802.orig/gdb/target.c 2009-08-03 12:38:47.000000000 +0200 -+++ gdb-6.8.50.20090802/gdb/target.c 2009-08-03 12:49:33.000000000 +0200 -@@ -933,6 +933,25 @@ pop_all_targets (int quitting) +--- gdb-7.0.50.20100128.orig/gdb/target.c 2010-01-28 12:52:29.000000000 +0100 ++++ gdb-7.0.50.20100128/gdb/target.c 2010-01-28 12:52:48.000000000 +0100 +@@ -1000,6 +1000,25 @@ pop_all_targets (int quitting) pop_all_targets_above (dummy_stratum, quitting); } @@ -104,7 +104,7 @@ Index: gdb-6.8.50.20090802/gdb/target.c /* Using the objfile specified in OBJFILE, find the address for the current thread's thread-local storage with offset OFFSET. */ CORE_ADDR -@@ -1023,7 +1042,28 @@ target_translate_tls_address (struct obj +@@ -1090,7 +1109,28 @@ target_translate_tls_address (struct obj /* It wouldn't be wrong here to try a gdbarch method, too; finding TLS is an ABI-specific thing. But we don't do that yet. */ else @@ -134,10 +134,10 @@ Index: gdb-6.8.50.20090802/gdb/target.c return addr; } -Index: gdb-6.8.50.20090802/gdb/testsuite/gdb.dwarf2/dw2-errno.c +Index: gdb-7.0.50.20100128/gdb/testsuite/gdb.dwarf2/dw2-errno.c =================================================================== --- /dev/null 1970-01-01 00:00:00.000000000 +0000 -+++ gdb-6.8.50.20090802/gdb/testsuite/gdb.dwarf2/dw2-errno.c 2009-08-03 12:49:33.000000000 +0200 ++++ gdb-7.0.50.20100128/gdb/testsuite/gdb.dwarf2/dw2-errno.c 2010-01-28 12:52:48.000000000 +0100 @@ -0,0 +1,28 @@ +/* This testcase is part of GDB, the GNU debugger. + @@ -167,11 +167,11 @@ Index: gdb-6.8.50.20090802/gdb/testsuite/gdb.dwarf2/dw2-errno.c + + return 0; /* breakpoint */ +} -Index: gdb-6.8.50.20090802/gdb/testsuite/gdb.dwarf2/dw2-errno.exp +Index: gdb-7.0.50.20100128/gdb/testsuite/gdb.dwarf2/dw2-errno.exp =================================================================== --- /dev/null 1970-01-01 00:00:00.000000000 +0000 -+++ gdb-6.8.50.20090802/gdb/testsuite/gdb.dwarf2/dw2-errno.exp 2009-08-03 12:49:33.000000000 +0200 -@@ -0,0 +1,67 @@ ++++ gdb-7.0.50.20100128/gdb/testsuite/gdb.dwarf2/dw2-errno.exp 2010-01-28 12:52:48.000000000 +0100 +@@ -0,0 +1,60 @@ +# Copyright 2007 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify @@ -187,13 +187,6 @@ Index: gdb-6.8.50.20090802/gdb/testsuite/gdb.dwarf2/dw2-errno.exp +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + -+if $tracelevel then { -+ strace $tracelevel -+} -+ -+set prms_id 0 -+set bug_id 0 -+ +set testfile dw2-errno +set srcfile ${testfile}.c +set binfile ${objdir}/${subdir}/${testfile} diff --git a/gdb-6.5-bz203661-emit-relocs.patch b/gdb-6.5-bz203661-emit-relocs.patch index f58cc9e..61e0d56 100644 --- a/gdb-6.5-bz203661-emit-relocs.patch +++ b/gdb-6.5-bz203661-emit-relocs.patch @@ -1,11 +1,11 @@ -Index: gdb-6.8.50.20090802/gdb/symfile.c +Index: gdb-7.0.90.20100306/gdb/symfile.c =================================================================== ---- gdb-6.8.50.20090802.orig/gdb/symfile.c 2009-08-03 12:29:58.000000000 +0200 -+++ gdb-6.8.50.20090802/gdb/symfile.c 2009-08-03 12:40:58.000000000 +0200 -@@ -4012,6 +4012,12 @@ symfile_dummy_outputs (bfd *abfd, asecti - bfd_byte * - symfile_relocate_debug_section (bfd *abfd, asection *sectp, bfd_byte *buf) +--- gdb-7.0.90.20100306.orig/gdb/symfile.c 2010-03-06 23:20:35.000000000 +0100 ++++ gdb-7.0.90.20100306/gdb/symfile.c 2010-03-06 23:26:25.000000000 +0100 +@@ -3642,6 +3642,12 @@ default_symfile_relocate (struct objfile { + bfd *abfd = objfile->obfd; + + /* Executable files have all the relocations already resolved. + * Handle files linked with --emit-relocs. + * http://sources.redhat.com/ml/gdb/2006-08/msg00137.html */ diff --git a/gdb-6.5-bz216711-clone-is-outermost.patch b/gdb-6.5-bz216711-clone-is-outermost.patch index b2dc451..bb7038f 100644 --- a/gdb-6.5-bz216711-clone-is-outermost.patch +++ b/gdb-6.5-bz216711-clone-is-outermost.patch @@ -23,147 +23,6 @@ instead. Port to GDB-6.7. -Index: gdb-6.8.50.20090802/gdb/amd64-linux-tdep.c -=================================================================== ---- gdb-6.8.50.20090802.orig/gdb/amd64-linux-tdep.c 2009-07-02 19:25:52.000000000 +0200 -+++ gdb-6.8.50.20090802/gdb/amd64-linux-tdep.c 2009-08-03 15:50:08.000000000 +0200 -@@ -238,6 +238,80 @@ amd64_linux_register_reggroup_p (struct - - /* Set the program counter for process PTID to PC. */ - -+/* Detect the outermost frame; during unwind of -+ #5 0x000000305cec68c3 in clone () from /lib64/tls/libc.so.6 -+ avoid the additional bogus frame -+ #6 0x0000000000000000 in ?? -+ We compare if the `linux_clone_code' block is _before_ unwound PC. */ -+ -+static const unsigned char linux_clone_code[] = -+{ -+/* libc/sysdeps/unix/sysv/linux/x86_64/clone.S */ -+/* #ifdef RESET_PID */ -+/* ... */ -+/* mov $SYS_ify(getpid), %eax */ -+/* 0xb8, 0x27, 0x00, 0x00, 0x00 */ -+/* OR */ -+/* mov $SYS_ify(getpid), %rax */ -+/* 0x48, 0xc7, 0xc0, 0x27, 0x00, 0x00, 0x00 */ -+/* so just: */ -+ 0x27, 0x00, 0x00, 0x00, -+/* syscall */ -+ 0x0f, 0x05, -+/* movl %eax, %fs:PID */ -+ 0x64, 0x89, 0x04, 0x25, 0x94, 0x00, 0x00, 0x00, -+/* movl %eax, %fs:TID */ -+ 0x64, 0x89, 0x04, 0x25, 0x90, 0x00, 0x00, 0x00, -+/* #endif */ -+/* |* Set up arguments for the function call. *| */ -+/* popq %rax |* Function to call. *| */ -+ 0x58, -+/* popq %rdi |* Argument. *| */ -+ 0x5f, -+/* call *%rax$ */ -+ 0xff, 0xd0 -+}; -+ -+#define LINUX_CLONE_LEN (sizeof linux_clone_code) -+ -+static int -+amd64_linux_clone_running (struct frame_info *this_frame) -+{ -+ CORE_ADDR pc = get_frame_pc (this_frame); -+ unsigned char buf[LINUX_CLONE_LEN]; -+ -+ if (!safe_frame_unwind_memory (this_frame, pc - LINUX_CLONE_LEN, buf, -+ LINUX_CLONE_LEN)) -+ return 0; -+ -+ if (memcmp (buf, linux_clone_code, LINUX_CLONE_LEN) != 0) -+ return 0; -+ -+ return 1; -+} -+ -+static int -+amd64_linux_outermost_frame (struct frame_info *this_frame) -+{ -+ CORE_ADDR pc = get_frame_pc (this_frame); -+ char *name; -+ -+ find_pc_partial_function (pc, &name, NULL, NULL); -+ -+ /* If we have NAME, we can optimize the search. -+ `clone' NAME still needs to have the code checked as its name may be -+ present in the user code. -+ `__clone' NAME should not be present in the user code but in the initial -+ parts of the `__clone' implementation the unwind still makes sense. -+ More detailed unwinding decision would be too much sensitive to possible -+ subtle changes in specific glibc revisions. */ -+ if (name == NULL || strcmp (name, "clone") == 0 -+ || strcmp ("__clone", name) == 0) -+ return (amd64_linux_clone_running (this_frame) != 0); -+ -+ return 0; -+} -+ - static void - amd64_linux_write_pc (struct regcache *regcache, CORE_ADDR pc) - { -@@ -276,6 +350,8 @@ amd64_linux_init_abi (struct gdbarch_inf - tdep->sc_reg_offset = amd64_linux_sc_reg_offset; - tdep->sc_num_regs = ARRAY_SIZE (amd64_linux_sc_reg_offset); - -+ tdep->outermost_frame_p = amd64_linux_outermost_frame; -+ - /* GNU/Linux uses SVR4-style shared libraries. */ - set_solib_svr4_fetch_link_map_offsets - (gdbarch, svr4_lp64_fetch_link_map_offsets); -Index: gdb-6.8.50.20090802/gdb/amd64-tdep.c -=================================================================== ---- gdb-6.8.50.20090802.orig/gdb/amd64-tdep.c 2009-07-02 19:25:52.000000000 +0200 -+++ gdb-6.8.50.20090802/gdb/amd64-tdep.c 2009-08-03 15:50:08.000000000 +0200 -@@ -1736,11 +1736,16 @@ amd64_frame_this_id (struct frame_info * - { - struct amd64_frame_cache *cache = - amd64_frame_cache (this_frame, this_cache); -+ struct gdbarch_tdep *tdep = gdbarch_tdep (get_frame_arch (this_frame)); - - /* This marks the outermost frame. */ - if (cache->base == 0) - return; - -+ /* Detect OS dependent outermost frames; such as `clone'. */ -+ if (tdep->outermost_frame_p && tdep->outermost_frame_p (this_frame)) -+ return; -+ - (*this_id) = frame_id_build (cache->base + 16, cache->pc); - } - ---- gdb-6.8.50.20090811/gdb/i386-tdep.c.orig 2009-08-10 05:02:39.000000000 +0200 -+++ gdb-6.8.50.20090811/gdb/i386-tdep.c 2009-08-11 16:33:51.000000000 +0200 -@@ -5432,6 +5432,9 @@ i386_gdbarch_init (struct gdbarch_info i - tdep->sc_pc_offset = -1; - tdep->sc_sp_offset = -1; - -+ /* Unwinding stops on i386 automatically. */ -+ tdep->outermost_frame_p = NULL; -+ - tdep->record_regmap = i386_record_regmap; - - /* The format used for `long double' on almost all i386 targets is ---- gdb-6.8.50.20090811/gdb/i386-tdep.h.orig 2009-08-10 05:02:39.000000000 +0200 -+++ gdb-6.8.50.20090811/gdb/i386-tdep.h 2009-08-11 16:34:08.000000000 +0200 -@@ -120,6 +120,9 @@ struct gdbarch_tdep - int (*i386_sysenter_record) (struct regcache *regcache); - /* Parse syscall args. */ - int (*i386_syscall_record) (struct regcache *regcache); -+ -+ /* Detect OS dependent outermost frames; such as `clone'. */ -+ int (*outermost_frame_p) (struct frame_info *this_frame); - }; - - /* Floating-point registers. */ -Index: gdb-6.8.50.20090802/gdb/testsuite/gdb.threads/bt-clone-stop.c -=================================================================== --- /dev/null 1970-01-01 00:00:00.000000000 +0000 +++ gdb-6.8.50.20090802/gdb/testsuite/gdb.threads/bt-clone-stop.c 2009-08-03 15:50:08.000000000 +0200 @@ -0,0 +1,39 @@ diff --git a/gdb-6.5-bz218379-ppc-solib-trampoline-fix.patch b/gdb-6.5-bz218379-ppc-solib-trampoline-fix.patch deleted file mode 100644 index 4fb26b0..0000000 --- a/gdb-6.5-bz218379-ppc-solib-trampoline-fix.patch +++ /dev/null @@ -1,19 +0,0 @@ -https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=218379 - - -Index: gdb-6.8.50.20081128/gdb/minsyms.c -=================================================================== ---- gdb-6.8.50.20081128.orig/gdb/minsyms.c 2008-10-01 18:56:52.000000000 +0200 -+++ gdb-6.8.50.20081128/gdb/minsyms.c 2008-12-02 23:24:27.000000000 +0100 -@@ -544,6 +544,11 @@ lookup_minimal_symbol_by_pc_section_1 (C - don't fill the bfd_section member, so don't - throw away symbols on those platforms. */ - && SYMBOL_OBJ_SECTION (&msymbol[hi]) != NULL -+ /* Don't ignore symbols for solib trampolines. -+ Limit its sideeffects - only for non-0 sized trampolines. -+ Red Hat Bug 200533 with its regression Bug 218379. */ -+ && (MSYMBOL_TYPE (&msymbol[hi]) != mst_solib_trampoline -+ || MSYMBOL_SIZE (&msymbol[hi])) - && (!matching_obj_sections - (SYMBOL_OBJ_SECTION (&msymbol[hi]), section))) - { diff --git a/gdb-6.5-bz243845-stale-testing-zombie-test.patch b/gdb-6.5-bz243845-stale-testing-zombie-test.patch index aa514c2..1c9b1f2 100644 --- a/gdb-6.5-bz243845-stale-testing-zombie-test.patch +++ b/gdb-6.5-bz243845-stale-testing-zombie-test.patch @@ -1,7 +1,7 @@ diff -u -ruNp gdb-6.3-unpatched/gdb/testsuite/gdb.base/tracefork-zombie.exp gdb-6.3/gdb/testsuite/gdb.base/tracefork-zombie.exp --- gdb-6.3-unpatched/gdb/testsuite/gdb.base/tracefork-zombie.exp 1969-12-31 19:00:00.000000000 -0500 +++ gdb-6.3/gdb/testsuite/gdb.base/tracefork-zombie.exp 2007-07-31 13:04:12.000000000 -0400 -@@ -0,0 +1,82 @@ +@@ -0,0 +1,75 @@ +# Copyright 2007 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify @@ -18,13 +18,6 @@ diff -u -ruNp gdb-6.3-unpatched/gdb/testsuite/gdb.base/tracefork-zombie.exp gdb- +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + -+if $tracelevel then { -+ strace $tracelevel -+} -+ -+set prms_id 0 -+set bug_id 0 -+ +# are we on a target board +if [is_remote target] then { + return 0 diff --git a/gdb-6.5-dwarf-stack-overflow.patch b/gdb-6.5-dwarf-stack-overflow.patch index 476bac2..0d107b3 100644 --- a/gdb-6.5-dwarf-stack-overflow.patch +++ b/gdb-6.5-dwarf-stack-overflow.patch @@ -10,11 +10,11 @@ for gdb/ChangeLog: Port to GDB-6.7. -Index: gdb-6.7/gdb/dwarf2read.c +Index: gdb-7.1.90.20100711/gdb/dwarf2read.c =================================================================== ---- gdb-6.7.orig/gdb/dwarf2read.c 2007-10-15 00:08:30.000000000 +0200 -+++ gdb-6.7/gdb/dwarf2read.c 2007-10-15 21:42:43.000000000 +0200 -@@ -9070,8 +9070,7 @@ dwarf2_fundamental_type (struct objfile +--- gdb-7.1.90.20100711.orig/gdb/dwarf2read.c 2010-07-12 10:43:53.000000000 +0200 ++++ gdb-7.1.90.20100711/gdb/dwarf2read.c 2010-07-12 10:49:32.000000000 +0200 +@@ -11382,8 +11382,7 @@ read_signatured_type (struct objfile *ob callers will only want a very basic result and this can become a complaint. @@ -24,7 +24,7 @@ Index: gdb-6.7/gdb/dwarf2read.c static CORE_ADDR decode_locdesc (struct dwarf_block *blk, struct dwarf2_cu *cu) -@@ -9088,7 +9087,7 @@ decode_locdesc (struct dwarf_block *blk, +@@ -11399,7 +11398,7 @@ decode_locdesc (struct dwarf_block *blk, i = 0; stacki = 0; @@ -33,8 +33,8 @@ Index: gdb-6.7/gdb/dwarf2read.c while (i < size) { -@@ -9270,6 +9269,16 @@ decode_locdesc (struct dwarf_block *blk, - dwarf_stack_op_name (op)); +@@ -11581,6 +11580,16 @@ decode_locdesc (struct dwarf_block *blk, + dwarf_stack_op_name (op, 1)); return (stack[stacki]); } + /* Enforce maximum stack depth of size-1 to avoid ++stacki writing diff --git a/gdb-6.5-gcore-buffer-limit-test.patch b/gdb-6.5-gcore-buffer-limit-test.patch index 9442198..dad4833 100644 --- a/gdb-6.5-gcore-buffer-limit-test.patch +++ b/gdb-6.5-gcore-buffer-limit-test.patch @@ -42,7 +42,7 @@ diff -u -X /home/jkratoch/.diffi.list -ruNp gdb-6.5/gdb/testsuite/gdb.base/gcore diff -u -X /home/jkratoch/.diffi.list -ruNp gdb-6.5/gdb/testsuite/gdb.base/gcore-excessive-memory.exp gdb-6.5-unknown/gdb/testsuite/gdb.base/gcore-excessive-memory.exp --- gdb-6.5/gdb/testsuite/gdb.base/gcore-excessive-memory.exp 1970-01-01 01:00:00.000000000 +0100 +++ gdb-6.5-unknown/gdb/testsuite/gdb.base/gcore-excessive-memory.exp 2008-01-08 11:47:32.000000000 +0100 -@@ -0,0 +1,101 @@ +@@ -0,0 +1,94 @@ +# Copyright 2008 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify @@ -59,13 +59,6 @@ diff -u -X /home/jkratoch/.diffi.list -ruNp gdb-6.5/gdb/testsuite/gdb.base/gcore +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + -+if $tracelevel then { -+ strace $tracelevel -+} -+ -+set prms_id 0 -+set bug_id 0 -+ +set testfile gcore-excessive-memory +set srcfile ${testfile}.c +set shfile ${objdir}/${subdir}/${testfile}-gdb.sh diff --git a/gdb-6.5-gcore-i386-on-amd64.patch b/gdb-6.5-gcore-i386-on-amd64.patch deleted file mode 100644 index 7dae330..0000000 --- a/gdb-6.5-gcore-i386-on-amd64.patch +++ /dev/null @@ -1,847 +0,0 @@ -2006-10-01 Jan Kratochvil - Fujitsu - - * amd64-linux-nat.c: Support new linux_elfcore_write_prpsinfo, - linux_elfcore_write_prstatus, linux_elfcore_write_prfpreg. - (i386_linux_gregset32_reg_offset): New mapping for i386 on amd64. - * gcore.c (gcore_create_callback): Comment vdso Linux kernel bug. - * configure.ac: Check for , . - * configure, config.in: Regenerated. - * gdb_user32.h, gdb_procfs32.h: Define 32-bit core files even for - 64-bit gdb, provide fallbacks for and . - * linux-nat.c: Virtualize `elfcore_*' by (*`linux_elfcore_*'). - (linux_nat_do_thread_registers): Likewise. - (linux_nat_make_corefile_notes): Likewise. - * linux-nat.h: Likewise. - * Makefile.in: Dependencies updated. - -2007-10-16 Jan Kratochvil - - Port to GDB-6.7. - -2008-02-24 Jan Kratochvil - - Port to GDB-6.8pre. - -Index: gdb-6.8.50.20090802/gdb/amd64-linux-nat.c -=================================================================== ---- gdb-6.8.50.20090802.orig/gdb/amd64-linux-nat.c 2009-06-17 20:44:23.000000000 +0200 -+++ gdb-6.8.50.20090802/gdb/amd64-linux-nat.c 2009-08-03 15:49:33.000000000 +0200 -@@ -51,6 +51,9 @@ - #include "i386-linux-tdep.h" - #include "amd64-nat.h" - #include "i386-nat.h" -+#include "i387-tdep.h" -+#include "elf-bfd.h" -+#include "gdb_procfs32.h" - - /* Mapping between the general-purpose registers in GNU/Linux x86-64 - `struct user' format and GDB's register cache layout. */ -@@ -85,6 +88,35 @@ static int amd64_linux_gregset64_reg_off - GNU/Linux i386 registers are all 32-bit, but since we're - little-endian we get away with that. */ - -+/* This info is not reusable from "i386-linux-nat.c" as gdb itself runs in -+ 64-bit mode and so ptrace(2) has 64-bit structure layout. -+ Just the corefile being generated has 32-bit layout so we need to do -+ a conversion specific to the i386-on-amd64 compatibility mode. */ -+static int i386_linux_gregset32_reg_offset[] = -+{ -+ 6 * 4, /* %eax */ -+ 1 * 4, /* %ecx */ -+ 2 * 4, /* %edx */ -+ 0 * 4, /* %ebx */ -+ 15 * 4, /* %esp */ -+ 5 * 4, /* %ebp */ -+ 3 * 4, /* %esi */ -+ 4 * 4, /* %edi */ -+ 12 * 4, /* %eip */ -+ 14 * 4, /* %eflags */ -+ 13 * 4, /* %cs */ -+ 16 * 4, /* %ss */ -+ 7 * 4, /* %ds */ -+ 8 * 4, /* %es */ -+ 9 * 4, /* %fs */ -+ 10 * 4, /* %gs */ -+ -1, -1, -1, -1, -1, -1, -1, -1, -+ -1, -1, -1, -1, -1, -1, -1, -1, -+ -1, -1, -1, -1, -1, -1, -1, -1, -+ -1, -+ 11 * 4 /* "orig_eax" */ -+}; -+ - /* From on GNU/Linux i386. */ - static int amd64_linux_gregset32_reg_offset[] = - { -@@ -103,6 +135,96 @@ static int amd64_linux_gregset32_reg_off - }; - - -+/* This functions make ELF32 32-bit elfcore note sections -+ on amd64 environment. */ -+ -+static char * -+amd64_linux_elfcore_write_prpsinfo (bfd *abfd, char *buf, int *bufsiz, -+ const char *fname, const char *psargs) -+{ -+ if (gdbarch_ptr_bit (target_gdbarch) == 32) -+ { -+ int note_type; -+ char *note_name = "CORE"; -+ struct elf_prpsinfo32 data; -+ note_type = NT_PRPSINFO; -+ -+ memset (&data, 0, sizeof (data)); -+ strncpy (data.pr_fname, fname, sizeof (data.pr_fname)); -+ strncpy (data.pr_psargs, psargs, sizeof (data.pr_psargs)); -+ return elfcore_write_note (abfd, buf, bufsiz, -+ note_name, note_type, &data, sizeof (data)); -+ } -+ else -+ return elfcore_write_prpsinfo (abfd, buf, bufsiz, fname, psargs); -+} -+ -+static void -+amd64_linux_set_registers (const gdb_byte *gregs, gdb_byte *buf) -+{ -+ int i; -+ /* Copy the i386 registers in the amd64 layout into i386 layout. */ -+ for (i = 0; i < I386_NUM_GREGS; i++) -+ memcpy(buf + i386_linux_gregset32_reg_offset[i], -+ gregs + amd64_linux_gregset32_reg_offset[i], 4); -+ for (i = I386_CS_REGNUM; i <= I386_GS_REGNUM; i++) -+ memcpy(buf + i386_linux_gregset32_reg_offset[i], -+ gregs + amd64_linux_gregset32_reg_offset[i], 4); -+} -+ -+static char * -+amd64_linux_elfcore_write_prstatus (bfd *abfd, char *buf, int *bufsiz, -+ long pid, int cursig, const void *gregs) -+{ -+ if (gdbarch_ptr_bit (target_gdbarch) == 32) -+ { -+ char *note_name = "CORE"; -+ struct elf_prstatus32 prstat; -+ memset (&prstat, 0, sizeof (prstat)); -+ prstat.pr_pid = pid; -+ prstat.pr_cursig = cursig; -+ amd64_linux_set_registers (gregs, (gdb_byte *) &prstat.pr_reg); -+ return elfcore_write_note (abfd, buf, bufsiz, note_name, -+ NT_PRSTATUS, &prstat, sizeof (prstat)); -+ } -+ else -+ return elfcore_write_prstatus (abfd, buf, bufsiz, pid, cursig, gregs); -+} -+ -+static char * -+amd64_elfcore_write_prxfpreg32 (bfd *abfd, char *buf, int *bufsiz, -+ struct regcache *regcache) -+{ -+ char *note_name = "LINUX"; -+ elf_fpxregset32_t fpxregs32; -+ -+ i387_collect_fxsave (regcache, -1, &fpxregs32); -+ return elfcore_write_note(abfd, buf, bufsiz, -+ note_name, NT_PRXFPREG, &fpxregs32, -+ sizeof(fpxregs32)); -+} -+ -+static char * -+amd64_linux_elfcore_write_prfpreg (bfd *abfd, char *buf, -+ int *bufsiz, const void *fpregs, int size, -+ struct regcache *regcache) -+{ -+ if (gdbarch_ptr_bit (target_gdbarch) == 32) -+ { -+ char *note_name = "CORE"; -+ elf_fpregset32_t fpregs32; -+ -+ i387_collect_fsave (regcache, -1, &fpregs32); -+ buf = elfcore_write_note(abfd, buf, bufsiz, note_name, -+ NT_FPREGSET, &fpregs32, sizeof(fpregs32)); -+ -+ return amd64_elfcore_write_prxfpreg32 (abfd, buf, bufsiz, regcache); -+ } -+ else -+ return elfcore_write_prfpreg (abfd, buf, bufsiz, fpregs, size); -+} -+ -+ - /* Transfering the general-purpose registers between GDB, inferiors - and core files. */ - -@@ -682,6 +804,11 @@ _initialize_amd64_linux_nat (void) - t->to_fetch_registers = amd64_linux_fetch_inferior_registers; - t->to_store_registers = amd64_linux_store_inferior_registers; - -+ /* This functions make elfcore note sections. */ -+ linux_elfcore_write_prpsinfo = amd64_linux_elfcore_write_prpsinfo; -+ linux_elfcore_write_prstatus = amd64_linux_elfcore_write_prstatus; -+ linux_elfcore_write_prfpreg = amd64_linux_elfcore_write_prfpreg; -+ - /* Register the target. */ - linux_nat_add_target (t); - linux_nat_set_new_thread (t, amd64_linux_new_thread); -Index: gdb-6.8.50.20090802/gdb/config.in -=================================================================== ---- gdb-6.8.50.20090802.orig/gdb/config.in 2009-08-03 09:50:57.000000000 +0200 -+++ gdb-6.8.50.20090802/gdb/config.in 2009-08-03 15:48:31.000000000 +0200 -@@ -146,6 +146,9 @@ - /* Define to 1 if you have the header file. */ - #undef HAVE_ELF_HP_H - -+/* Define if struct elf_prstatus32 is available. */ -+#undef HAVE_ELF_PRSTATUS32 -+ - /* Define to 1 if your system has the etext variable. */ - #undef HAVE_ETEXT - -@@ -487,6 +490,9 @@ - /* Define to 1 if you have the header file. */ - #undef HAVE_SYS_POLL_H - -+/* Define to 1 if you have the header file. */ -+#undef HAVE_SYS_PROCFS32_H -+ - /* Define to 1 if you have the header file. */ - #undef HAVE_SYS_PROCFS_H - -@@ -514,6 +520,9 @@ - /* Define to 1 if you have the header file. */ - #undef HAVE_SYS_TYPES_H - -+/* Define to 1 if you have the header file. */ -+#undef HAVE_SYS_USER32_H -+ - /* Define to 1 if you have the header file. */ - #undef HAVE_SYS_USER_H - -Index: gdb-6.8.50.20090802/gdb/configure -=================================================================== ---- gdb-6.8.50.20090802.orig/gdb/configure 2009-08-03 09:50:57.000000000 +0200 -+++ gdb-6.8.50.20090802/gdb/configure 2009-08-03 15:48:31.000000000 +0200 -@@ -12545,6 +12545,268 @@ _ACEOF - - fi - -+ -+ -+for ac_header in sys/user32.h sys/procfs32.h -+do -+as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` -+if eval "test \"\${$as_ac_Header+set}\" = set"; then -+ echo "$as_me:$LINENO: checking for $ac_header" >&5 -+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 -+if eval "test \"\${$as_ac_Header+set}\" = set"; then -+ echo $ECHO_N "(cached) $ECHO_C" >&6 -+fi -+echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 -+echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 -+else -+ # Is the header compilable? -+echo "$as_me:$LINENO: checking $ac_header usability" >&5 -+echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6 -+cat >conftest.$ac_ext <<_ACEOF -+/* confdefs.h. */ -+_ACEOF -+cat confdefs.h >>conftest.$ac_ext -+cat >>conftest.$ac_ext <<_ACEOF -+/* end confdefs.h. */ -+$ac_includes_default -+#include <$ac_header> -+_ACEOF -+rm -f conftest.$ac_objext -+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 -+ (eval $ac_compile) 2>conftest.er1 -+ ac_status=$? -+ grep -v '^ *+' conftest.er1 >conftest.err -+ rm -f conftest.er1 -+ cat conftest.err >&5 -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); } && -+ { ac_try='test -z "$ac_c_werror_flag" -+ || test ! -s conftest.err' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; } && -+ { ac_try='test -s conftest.$ac_objext' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; }; then -+ ac_header_compiler=yes -+else -+ echo "$as_me: failed program was:" >&5 -+sed 's/^/| /' conftest.$ac_ext >&5 -+ -+ac_header_compiler=no -+fi -+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext -+echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 -+echo "${ECHO_T}$ac_header_compiler" >&6 -+ -+# Is the header present? -+echo "$as_me:$LINENO: checking $ac_header presence" >&5 -+echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6 -+cat >conftest.$ac_ext <<_ACEOF -+/* confdefs.h. */ -+_ACEOF -+cat confdefs.h >>conftest.$ac_ext -+cat >>conftest.$ac_ext <<_ACEOF -+/* end confdefs.h. */ -+#include <$ac_header> -+_ACEOF -+if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 -+ (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 -+ ac_status=$? -+ grep -v '^ *+' conftest.er1 >conftest.err -+ rm -f conftest.er1 -+ cat conftest.err >&5 -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); } >/dev/null; then -+ if test -s conftest.err; then -+ ac_cpp_err=$ac_c_preproc_warn_flag -+ ac_cpp_err=$ac_cpp_err$ac_c_werror_flag -+ else -+ ac_cpp_err= -+ fi -+else -+ ac_cpp_err=yes -+fi -+if test -z "$ac_cpp_err"; then -+ ac_header_preproc=yes -+else -+ echo "$as_me: failed program was:" >&5 -+sed 's/^/| /' conftest.$ac_ext >&5 -+ -+ ac_header_preproc=no -+fi -+rm -f conftest.err conftest.$ac_ext -+echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 -+echo "${ECHO_T}$ac_header_preproc" >&6 -+ -+# So? What about this header? -+case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in -+ yes:no: ) -+ { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 -+echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} -+ { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 -+echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} -+ ac_header_preproc=yes -+ ;; -+ no:yes:* ) -+ { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 -+echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} -+ { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 -+echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} -+ { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 -+echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} -+ { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 -+echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} -+ { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 -+echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} -+ { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 -+echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} -+ ( -+ cat <<\_ASBOX -+## ------------------------------------------ ## -+## Report this to the AC_PACKAGE_NAME lists. ## -+## ------------------------------------------ ## -+_ASBOX -+ ) | -+ sed "s/^/$as_me: WARNING: /" >&2 -+ ;; -+esac -+echo "$as_me:$LINENO: checking for $ac_header" >&5 -+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 -+if eval "test \"\${$as_ac_Header+set}\" = set"; then -+ echo $ECHO_N "(cached) $ECHO_C" >&6 -+else -+ eval "$as_ac_Header=\$ac_header_preproc" -+fi -+echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 -+echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 -+ -+fi -+if test `eval echo '${'$as_ac_Header'}'` = yes; then -+ cat >>confdefs.h <<_ACEOF -+#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 -+_ACEOF -+ -+fi -+ -+done -+ -+echo "$as_me:$LINENO: checking for struct elf_prstatus32.pr_reg" >&5 -+echo $ECHO_N "checking for struct elf_prstatus32.pr_reg... $ECHO_C" >&6 -+if test "${ac_cv_member_struct_elf_prstatus32_pr_reg+set}" = set; then -+ echo $ECHO_N "(cached) $ECHO_C" >&6 -+else -+ cat >conftest.$ac_ext <<_ACEOF -+/* confdefs.h. */ -+_ACEOF -+cat confdefs.h >>conftest.$ac_ext -+cat >>conftest.$ac_ext <<_ACEOF -+/* end confdefs.h. */ -+#include -+ -+int -+main () -+{ -+static struct elf_prstatus32 ac_aggr; -+if (ac_aggr.pr_reg) -+return 0; -+ ; -+ return 0; -+} -+_ACEOF -+rm -f conftest.$ac_objext -+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 -+ (eval $ac_compile) 2>conftest.er1 -+ ac_status=$? -+ grep -v '^ *+' conftest.er1 >conftest.err -+ rm -f conftest.er1 -+ cat conftest.err >&5 -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); } && -+ { ac_try='test -z "$ac_c_werror_flag" -+ || test ! -s conftest.err' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; } && -+ { ac_try='test -s conftest.$ac_objext' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; }; then -+ ac_cv_member_struct_elf_prstatus32_pr_reg=yes -+else -+ echo "$as_me: failed program was:" >&5 -+sed 's/^/| /' conftest.$ac_ext >&5 -+ -+cat >conftest.$ac_ext <<_ACEOF -+/* confdefs.h. */ -+_ACEOF -+cat confdefs.h >>conftest.$ac_ext -+cat >>conftest.$ac_ext <<_ACEOF -+/* end confdefs.h. */ -+#include -+ -+int -+main () -+{ -+static struct elf_prstatus32 ac_aggr; -+if (sizeof ac_aggr.pr_reg) -+return 0; -+ ; -+ return 0; -+} -+_ACEOF -+rm -f conftest.$ac_objext -+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 -+ (eval $ac_compile) 2>conftest.er1 -+ ac_status=$? -+ grep -v '^ *+' conftest.er1 >conftest.err -+ rm -f conftest.er1 -+ cat conftest.err >&5 -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); } && -+ { ac_try='test -z "$ac_c_werror_flag" -+ || test ! -s conftest.err' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; } && -+ { ac_try='test -s conftest.$ac_objext' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; }; then -+ ac_cv_member_struct_elf_prstatus32_pr_reg=yes -+else -+ echo "$as_me: failed program was:" >&5 -+sed 's/^/| /' conftest.$ac_ext >&5 -+ -+ac_cv_member_struct_elf_prstatus32_pr_reg=no -+fi -+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext -+fi -+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext -+fi -+echo "$as_me:$LINENO: result: $ac_cv_member_struct_elf_prstatus32_pr_reg" >&5 -+echo "${ECHO_T}$ac_cv_member_struct_elf_prstatus32_pr_reg" >&6 -+if test $ac_cv_member_struct_elf_prstatus32_pr_reg = yes; then -+ -+cat >>confdefs.h <<\_ACEOF -+#define HAVE_ELF_PRSTATUS32 1 -+_ACEOF -+ -+fi -+ - # elf_hp.h is for HP/UX 64-bit shared library support. - # FIXME: kettenis/20030102: In most cases we include these (ctype.h, time.h) - # unconditionally, so what's the point in checking these? -Index: gdb-6.8.50.20090802/gdb/configure.ac -=================================================================== ---- gdb-6.8.50.20090802.orig/gdb/configure.ac 2009-08-03 09:50:57.000000000 +0200 -+++ gdb-6.8.50.20090802/gdb/configure.ac 2009-08-03 15:48:31.000000000 +0200 -@@ -744,6 +744,11 @@ AC_SUBST(PYTHON_CFLAGS) - AC_HEADER_DIRENT - AC_HEADER_STAT - AC_HEADER_STDC -+AC_CHECK_HEADERS([sys/user32.h sys/procfs32.h]) -+AC_CHECK_MEMBER([struct elf_prstatus32.pr_reg], -+ [AC_DEFINE(HAVE_ELF_PRSTATUS32, 1, -+ [Define if struct elf_prstatus32 is available. ])], -+ [], [#include ]) - # elf_hp.h is for HP/UX 64-bit shared library support. - # FIXME: kettenis/20030102: In most cases we include these (ctype.h, time.h) - # unconditionally, so what's the point in checking these? -Index: gdb-6.8.50.20090802/gdb/gcore.c -=================================================================== ---- gdb-6.8.50.20090802.orig/gdb/gcore.c 2009-08-03 12:28:56.000000000 +0200 -+++ gdb-6.8.50.20090802/gdb/gcore.c 2009-08-03 15:48:31.000000000 +0200 -@@ -324,6 +324,11 @@ gcore_create_callback (CORE_ADDR vaddr, - asection *osec; - flagword flags = SEC_ALLOC | SEC_HAS_CONTENTS | SEC_LOAD; - -+ /* Some Linux kernel versions around 2.6.17 have for i386 inferiors running -+ in compatibility mode on amd64 kernel their VSYSCALL page (at 0xffffe000) -+ protected as RWX==000 by default and gdb fails to read the library header -+ upon loading the core. This is a Linux kernel bug being fixed. */ -+ - /* If the memory segment has no permissions set, ignore it, otherwise - when we later try to access it for read/write, we'll get an error - or jam the kernel. */ -Index: gdb-6.8.50.20090802/gdb/gdb_procfs32.h -=================================================================== ---- /dev/null 1970-01-01 00:00:00.000000000 +0000 -+++ gdb-6.8.50.20090802/gdb/gdb_procfs32.h 2009-08-03 15:48:31.000000000 +0200 -@@ -0,0 +1,128 @@ -+#ifdef HAVE_SYS_PROCFS32_H -+#include -+#elif !defined HAVE_ELF_PRSTATUS32 -+ -+/* Copyright (C) 2006 Free Software Foundation, Inc. -+ This file is part of the GNU C Library. -+ -+ The GNU C Library is free software; you can redistribute it and/or -+ modify it under the terms of the GNU Lesser General Public -+ License as published by the Free Software Foundation; either -+ version 2.1 of the License, or (at your option) any later version. -+ -+ The GNU C Library 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 -+ Lesser General Public License for more details. -+ -+ You should have received a copy of the GNU Lesser General Public -+ License along with the GNU C Library; if not, write to the Free -+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA -+ 02111-1307 USA. */ -+ -+#ifndef _SYS_PROCFS32_H -+#define _SYS_PROCFS32_H 1 -+ -+/* This is somewhat modelled after the file of the same name on SVR4 -+ systems. It provides a definition of the core file format for ELF -+ used on Linux. It doesn't have anything to do with the /proc file -+ system, even though Linux has one. -+ -+ Anyway, the whole purpose of this file is for GDB and GDB only. -+ Don't read too much into it. Don't use it for anything other than -+ GDB unless you know what you are doing. */ -+ -+#include -+#include -+#include -+#include "gdb_user32.h" -+ -+/* We define here only the symbols differing from their 64-bit variant. */ -+#include -+ -+__BEGIN_DECLS -+ -+/* Type for a general-purpose register. */ -+typedef unsigned int elf_greg32_t; -+ -+/* And the whole bunch of them. We could have used `struct -+ user_regs_struct' directly in the typedef, but tradition says that -+ the register set is an array, which does have some peculiar -+ semantics, so leave it that way. */ -+#define ELF_NGREG32 (sizeof (struct user_regs32_struct) / sizeof(elf_greg32_t)) -+typedef elf_greg32_t elf_gregset32_t[ELF_NGREG32]; -+ -+/* Register set for the floating-point registers. */ -+typedef struct user_fpregs32_struct elf_fpregset32_t; -+ -+/* Register set for the extended floating-point registers. Includes -+ the Pentium III SSE registers in addition to the classic -+ floating-point stuff. */ -+typedef struct user_fpxregs32_struct elf_fpxregset32_t; -+ -+ -+/* Definitions to generate Intel SVR4-like core files. These mostly -+ have the same names as the SVR4 types with "elf_" tacked on the -+ front to prevent clashes with Linux definitions, and the typedef -+ forms have been avoided. This is mostly like the SVR4 structure, -+ but more Linuxy, with things that Linux does not support and which -+ GDB doesn't really use excluded. */ -+ -+struct prstatus32_timeval -+ { -+ int tv_sec; -+ int tv_usec; -+ }; -+ -+struct elf_prstatus32 -+ { -+ struct elf_siginfo pr_info; /* Info associated with signal. */ -+ short int pr_cursig; /* Current signal. */ -+ unsigned int pr_sigpend; /* Set of pending signals. */ -+ unsigned int pr_sighold; /* Set of held signals. */ -+ __pid_t pr_pid; -+ __pid_t pr_ppid; -+ __pid_t pr_pgrp; -+ __pid_t pr_sid; -+ struct prstatus32_timeval pr_utime; /* User time. */ -+ struct prstatus32_timeval pr_stime; /* System time. */ -+ struct prstatus32_timeval pr_cutime; /* Cumulative user time. */ -+ struct prstatus32_timeval pr_cstime; /* Cumulative system time. */ -+ elf_gregset32_t pr_reg; /* GP registers. */ -+ int pr_fpvalid; /* True if math copro being used. */ -+ }; -+ -+ -+struct elf_prpsinfo32 -+ { -+ char pr_state; /* Numeric process state. */ -+ char pr_sname; /* Char for pr_state. */ -+ char pr_zomb; /* Zombie. */ -+ char pr_nice; /* Nice val. */ -+ unsigned int pr_flag; /* Flags. */ -+ unsigned short int pr_uid; -+ unsigned short int pr_gid; -+ int pr_pid, pr_ppid, pr_pgrp, pr_sid; -+ /* Lots missing */ -+ char pr_fname[16]; /* Filename of executable. */ -+ char pr_psargs[ELF_PRARGSZ]; /* Initial part of arg list. */ -+ }; -+ -+ -+/* The rest of this file provides the types for emulation of the -+ Solaris interfaces that should be implemented by -+ users of libthread_db. */ -+ -+/* Register sets. Linux has different names. */ -+typedef elf_gregset_t prgregset32_t; -+typedef elf_fpregset_t prfpregset32_t; -+ -+/* Process status and info. In the end we do provide typedefs for them. */ -+typedef struct elf_prstatus32 prstatus32_t; -+typedef struct elf_prpsinfo32 prpsinfo32_t; -+ -+__END_DECLS -+ -+#endif /* _SYS_PROCFS32_H */ -+ -+#endif /* HAVE_SYS_PROCFS32_H */ -Index: gdb-6.8.50.20090802/gdb/gdb_user32.h -=================================================================== ---- /dev/null 1970-01-01 00:00:00.000000000 +0000 -+++ gdb-6.8.50.20090802/gdb/gdb_user32.h 2009-08-03 15:48:31.000000000 +0200 -@@ -0,0 +1,108 @@ -+#ifdef HAVE_SYS_USER32_H -+#include -+#else -+ -+#ifdef HAVE_STDINT_H -+#include -+typedef int32_t gdb_int32_t; -+typedef uint32_t gdb_uint32_t; -+#else -+typedef signed int gdb_uint32_t; -+typedef unsigned int gdb_uint32_t; -+#endif -+ -+/* Copyright (C) 2006 Free Software Foundation, Inc. -+ This file is part of the GNU C Library. -+ -+ The GNU C Library is free software; you can redistribute it and/or -+ modify it under the terms of the GNU Lesser General Public -+ License as published by the Free Software Foundation; either -+ version 2.1 of the License, or (at your option) any later version. -+ -+ The GNU C Library 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 -+ Lesser General Public License for more details. -+ -+ You should have received a copy of the GNU Lesser General Public -+ License along with the GNU C Library; if not, write to the Free -+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA -+ 02111-1307 USA. */ -+ -+#ifndef _SYS_USER32_H -+#define _SYS_USER32_H 1 -+ -+/* These are the 32-bit x86 structures. */ -+ -+struct user_fpregs32_struct -+{ -+ int32_t cwd; -+ int32_t swd; -+ int32_t twd; -+ int32_t fip; -+ int32_t fcs; -+ int32_t foo; -+ int32_t fos; -+ int32_t st_space [20]; -+}; -+ -+struct user_fpxregs32_struct -+{ -+ unsigned short int cwd; -+ unsigned short int swd; -+ unsigned short int twd; -+ unsigned short int fop; -+ int32_t fip; -+ int32_t fcs; -+ int32_t foo; -+ int32_t fos; -+ int32_t mxcsr; -+ int32_t reserved; -+ int32_t st_space[32]; /* 8*16 bytes for each FP-reg = 128 bytes */ -+ int32_t xmm_space[32]; /* 8*16 bytes for each XMM-reg = 128 bytes */ -+ int32_t padding[56]; -+}; -+ -+struct user_regs32_struct -+{ -+ int32_t ebx; -+ int32_t ecx; -+ int32_t edx; -+ int32_t esi; -+ int32_t edi; -+ int32_t ebp; -+ int32_t eax; -+ int32_t xds; -+ int32_t xes; -+ int32_t xfs; -+ int32_t xgs; -+ int32_t orig_eax; -+ int32_t eip; -+ int32_t xcs; -+ int32_t eflags; -+ int32_t esp; -+ int32_t xss; -+}; -+ -+struct user32 -+{ -+ struct user_regs32_struct regs; -+ int u_fpvalid; -+ struct user_fpregs32_struct i387; -+ uint32_t u_tsize; -+ uint32_t u_dsize; -+ uint32_t u_ssize; -+ uint32_t start_code; -+ uint32_t start_stack; -+ int32_t signal; -+ int reserved; -+ struct user_regs32_struct* u_ar0; -+ struct user_fpregs32_struct* u_fpstate; -+ uint32_t magic; -+ char u_comm [32]; -+ int u_debugreg [8]; -+}; -+ -+#endif /* _SYS_USER32_H */ -+ -+#endif /* HAVE_SYS_USER32_H */ -Index: gdb-6.8.50.20090802/gdb/linux-nat.c -=================================================================== ---- gdb-6.8.50.20090802.orig/gdb/linux-nat.c 2009-08-03 12:31:26.000000000 +0200 -+++ gdb-6.8.50.20090802/gdb/linux-nat.c 2009-08-03 15:48:31.000000000 +0200 -@@ -219,6 +219,21 @@ static LONGEST (*super_xfer_partial) (st - const gdb_byte *, - ULONGEST, LONGEST); - -+/* This functions make elfcore note sections. -+ They may get overriden by code adjusting data for multi-target builds. */ -+char *(*linux_elfcore_write_prpsinfo) -+ (bfd *, char *, int *, const char *, const char *) = elfcore_write_prpsinfo; -+char *(*linux_elfcore_write_prstatus) -+ (bfd *, char *, int *, long, int, const void *) = elfcore_write_prstatus; -+static char * -+linux_elfcore_write_prfpreg_bfd (bfd *abfd, char *buf, int *bufsiz, -+ const void *fpregs, int size, struct regcache *regcache) -+{ -+ return elfcore_write_prfpreg (abfd, buf, bufsiz, fpregs, size); -+} -+char *(*linux_elfcore_write_prfpreg) (bfd *, char *, int *, const void *, int, -+ struct regcache *) = linux_elfcore_write_prfpreg_bfd; -+ - static int debug_linux_nat; - static void - show_debug_linux_nat (struct ui_file *file, int from_tty, -@@ -3586,7 +3601,7 @@ linux_nat_do_thread_registers (bfd *obfd - else - fill_gregset (regcache, &gregs, -1); - -- note_data = (char *) elfcore_write_prstatus (obfd, -+ note_data = (char *) linux_elfcore_write_prstatus (obfd, - note_data, - note_size, - lwp, -@@ -3636,10 +3651,10 @@ linux_nat_do_thread_registers (bfd *obfd - else - fill_fpregset (regcache, &fpregs, -1); - -- note_data = (char *) elfcore_write_prfpreg (obfd, -+ note_data = (char *) linux_elfcore_write_prfpreg (obfd, - note_data, - note_size, -- &fpregs, sizeof (fpregs)); -+ &fpregs, sizeof (fpregs), regcache); - } - - return note_data; -@@ -3822,9 +3837,9 @@ linux_nat_make_corefile_notes (bfd *obfd - psargs_end - string_end); - } - } -- note_data = (char *) elfcore_write_prpsinfo (obfd, -- note_data, -- note_size, fname, psargs); -+ note_data = (char *) linux_elfcore_write_prpsinfo (obfd, note_data, -+ note_size, fname, -+ psargs); - } - - /* Dump information for threads. */ -Index: gdb-6.8.50.20090802/gdb/linux-nat.h -=================================================================== ---- gdb-6.8.50.20090802.orig/gdb/linux-nat.h 2009-08-03 10:52:00.000000000 +0200 -+++ gdb-6.8.50.20090802/gdb/linux-nat.h 2009-08-03 15:48:31.000000000 +0200 -@@ -144,3 +144,12 @@ void linux_nat_switch_fork (ptid_t new_p - - /* Return the saved siginfo associated with PTID. */ - struct siginfo *linux_nat_get_siginfo (ptid_t ptid); -+ -+/* These functions make elfcore note sections. -+ They may get overriden by code adjusting data for multi-target builds. */ -+extern char *(*linux_elfcore_write_prpsinfo) -+ (bfd *, char *, int *, const char *, const char *); -+extern char *(*linux_elfcore_write_prstatus) -+ (bfd *, char *, int *, long, int, const void *); -+extern char *(*linux_elfcore_write_prfpreg) -+ (bfd *, char *, int *, const void *, int, struct regcache *); diff --git a/gdb-6.5-ia64-libunwind-leak-test.patch b/gdb-6.5-ia64-libunwind-leak-test.patch index 79a4753..c77c677 100644 --- a/gdb-6.5-ia64-libunwind-leak-test.patch +++ b/gdb-6.5-ia64-libunwind-leak-test.patch @@ -34,7 +34,7 @@ diff -u -rup gdb-6.3-orig/gdb/testsuite/gdb.base/unwind-leak.c gdb-6.3/gdb/tests diff -u -rup gdb-6.3-orig/gdb/testsuite/gdb.base/unwind-leak.exp gdb-6.3/gdb/testsuite/gdb.base/unwind-leak.exp --- gdb-6.3-orig/gdb/testsuite/gdb.base/unwind-leak.exp 2007-12-19 15:12:53.000000000 -0500 +++ gdb-6.3/gdb/testsuite/gdb.base/unwind-leak.exp 2007-12-19 15:11:35.000000000 -0500 -@@ -0,0 +1,90 @@ +@@ -0,0 +1,83 @@ +# Copyright 2007 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify @@ -51,13 +51,6 @@ diff -u -rup gdb-6.3-orig/gdb/testsuite/gdb.base/unwind-leak.exp gdb-6.3/gdb/tes +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + -+if $tracelevel then { -+ strace $tracelevel -+} -+ -+set prms_id 0 -+set bug_id 0 -+ +set testfile unwind-leak +set srcfile ${testfile}.c +set shfile ${objdir}/${subdir}/${testfile}-gdb.sh diff --git a/gdb-6.5-missed-trap-on-step-test.patch b/gdb-6.5-missed-trap-on-step-test.patch index cb55193..2f4436d 100644 --- a/gdb-6.5-missed-trap-on-step-test.patch +++ b/gdb-6.5-missed-trap-on-step-test.patch @@ -3,7 +3,7 @@ Fix has been committed to: --- /dev/null 2007-12-14 20:45:09.113039517 +0100 +++ gdb-6.5/gdb/testsuite/gdb.base/watchpoint-during-step.exp 2007-12-24 19:42:00.000000000 +0100 -@@ -0,0 +1,51 @@ +@@ -0,0 +1,44 @@ +# Copyright 2007 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify @@ -20,13 +20,6 @@ Fix has been committed to: +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + -+if $tracelevel then { -+ strace $tracelevel -+} -+ -+set prms_id 0 -+set bug_id 0 -+ +set testfile watchpoint-during-step +set srcfile ${testfile}.c +set binfile ${objdir}/${subdir}/${testfile} diff --git a/gdb-6.5-tls-of-separate-debuginfo.patch b/gdb-6.5-tls-of-separate-debuginfo.patch deleted file mode 100644 index b838081..0000000 --- a/gdb-6.5-tls-of-separate-debuginfo.patch +++ /dev/null @@ -1,24 +0,0 @@ -Dependency on: gdb-6.5-bz185337-resolve-tls-without-debuginfo-v2.patch - - -2006-09-01 Jan Kratochvil - - * target.c (target_translate_tls_address): Fix for separate debuginfo. - - -diff -rup gdb-6.5.orig/gdb/target.c gdb-6.5/gdb/target.c ---- gdb-6.5.orig/gdb/target.c 2006-09-20 17:13:35.000000000 -0400 -+++ gdb-6.5/gdb/target.c 2006-09-20 17:15:53.000000000 -0400 -@@ -769,6 +769,12 @@ target_translate_tls_address (struct obj - ptid_t ptid = inferior_ptid; - volatile struct gdb_exception ex; - -+ /* Resolve: Cannot find shared library -+ `/usr/lib/debug/lib/lib....so.debug' in dynamic linker's load -+ module list */ -+ if (objfile->separate_debug_objfile_backlink != NULL) -+ objfile = objfile->separate_debug_objfile_backlink; -+ - TRY_CATCH (ex, RETURN_MASK_ALL) - { - CORE_ADDR lm_addr; diff --git a/gdb-6.6-buildid-locate-core-as-arg.patch b/gdb-6.6-buildid-locate-core-as-arg.patch new file mode 100644 index 0000000..a430667 --- /dev/null +++ b/gdb-6.6-buildid-locate-core-as-arg.patch @@ -0,0 +1,196 @@ +http://sourceware.org/ml/gdb-patches/2010-01/msg00558.html +Subject: Re: [patch] print a more useful error message for "gdb core" + +[ Fixed up since the mail. ] + +On Thu, 21 Jan 2010 18:17:15 +0100, Doug Evans wrote: +> Not an exhaustive list, but if we go down the path of converting "gdb +> corefile" to "gdb -c corefile", then we also need to think about "file +> corefile" being converted to "core corefile" [or "target core +> corefile", "core" is apparently deprecated in favor of "target core"] +> and "target exec corefile" -> "target core corefile". Presumably +> "file corefile" (and "target exec corefile") would discard the +> currently selected executable. But maybe not. Will that be confusing +> for users? I don't know. + +While thinking about it overriding some GDB _commands_ was not my intention. + +There is a general assumption if I have a shell COMMAND and some FILE I can do +$ COMMAND FILE +and COMMAND will appropriately load the FILE. + +FSF GDB currently needs to specify also the executable file for core files +which already inhibits this intuitive expectation. OTOH with the build-id +locating patch which could allow such intuitive start notneeding the +executable file. Still it currently did not work due to the required "-c": +$ COMMAND -c COREFILE + +Entering "file", "core-file" or "attach" commands is already explicit enough +so that it IMO should do what the command name says without any +autodetections. The second command line argument +(captured_main->pid_or_core_arg) is also autodetected (for PID or CORE) but +neither "attach" accepts a core file nor "core-file" accepts a PID. + + +The patch makes sense only with the build-id patchset so this is not submit +for FSF GDB inclusion yet. I am fine with your patch (+/- Hui Zhu's pending +bfd_check_format_matches) as the patch below is its natural extension. + + +Sorry for the delay, +Jan + + +2010-01-25 Jan Kratochvil + + * exceptions.h (enum errors ): New. + * exec.c: Include exceptions.h. + (exec_file_attach ): Call throw_error (IS_CORE_ERROR, ...). + * main.c (exec_or_core_file_attach): New. + (captured_main ): Set also corearg. + (captured_main ): New variable func. + Call exec_or_core_file_attach if COREARG matches EXECARG. Call + symbol_file_add_main only if CORE_BFD remained NULL. + +Http://sourceware.org/ml/gdb-patches/2010-01/msg00517.html +2010-01-20 Doug Evans + + * exec.c (exec_file_attach): Print a more useful error message if the + user did "gdb core". + +Index: gdb-7.1.90.20100711/gdb/exceptions.h +=================================================================== +--- gdb-7.1.90.20100711.orig/gdb/exceptions.h 2010-05-03 01:52:14.000000000 +0200 ++++ gdb-7.1.90.20100711/gdb/exceptions.h 2010-07-13 22:56:29.000000000 +0200 +@@ -78,6 +78,9 @@ enum errors { + /* Feature is not supported in this copy of GDB. */ + UNSUPPORTED_ERROR, + ++ /* Attempt to load a core file as executable. */ ++ IS_CORE_ERROR, ++ + /* Add more errors here. */ + NR_ERRORS + }; +Index: gdb-7.1.90.20100711/gdb/exec.c +=================================================================== +--- gdb-7.1.90.20100711.orig/gdb/exec.c 2010-07-12 23:07:34.000000000 +0200 ++++ gdb-7.1.90.20100711/gdb/exec.c 2010-07-13 22:56:29.000000000 +0200 +@@ -34,6 +34,7 @@ + #include "arch-utils.h" + #include "gdbthread.h" + #include "progspace.h" ++#include "exceptions.h" + + #include + #include "readline/readline.h" +@@ -253,12 +254,27 @@ exec_file_attach (char *filename, int fr + + if (!bfd_check_format_matches (exec_bfd, bfd_object, &matching)) + { ++ int is_core; ++ ++ /* If the user accidentally did "gdb core", print a useful ++ error message. Check it only after bfd_object has been checked as ++ a valid executable may get recognized for example also as ++ "trad-core". */ ++ is_core = bfd_check_format (exec_bfd, bfd_core); ++ + /* Make sure to close exec_bfd, or else "run" might try to use + it. */ + exec_close (); +- error (_("\"%s\": not in executable format: %s"), +- scratch_pathname, +- gdb_bfd_errmsg (bfd_get_error (), matching)); ++ ++ if (is_core != 0) ++ throw_error (IS_CORE_ERROR, ++ _("\"%s\" is a core file.\n" ++ "Please specify an executable to debug."), ++ scratch_pathname); ++ else ++ error (_("\"%s\": not in executable format: %s"), ++ scratch_pathname, ++ gdb_bfd_errmsg (bfd_get_error (), matching)); + } + + /* FIXME - This should only be run for RS6000, but the ifdef is a poor +Index: gdb-7.1.90.20100711/gdb/main.c +=================================================================== +--- gdb-7.1.90.20100711.orig/gdb/main.c 2010-07-12 23:07:34.000000000 +0200 ++++ gdb-7.1.90.20100711/gdb/main.c 2010-07-13 22:58:20.000000000 +0200 +@@ -241,6 +241,36 @@ captured_command_loop (void *data) + return 1; + } + ++/* Call exec_file_attach. If it detected FILENAME is a core file call ++ core_file_command. Print the original exec_file_attach error only if ++ core_file_command failed to find a matching executable. */ ++ ++static void ++exec_or_core_file_attach (char *filename, int from_tty) ++{ ++ volatile struct gdb_exception e; ++ ++ gdb_assert (exec_bfd == NULL); ++ ++ TRY_CATCH (e, RETURN_MASK_ALL) ++ { ++ exec_file_attach (filename, from_tty); ++ } ++ if (e.reason < 0) ++ { ++ if (e.error == IS_CORE_ERROR) ++ { ++ core_file_command (filename, from_tty); ++ ++ /* Iff the core file found its executable suppress the error message ++ from exec_file_attach. */ ++ if (exec_bfd != NULL) ++ return; ++ } ++ throw_exception (e); ++ } ++} ++ + static int + captured_main (void *data) + { +@@ -678,6 +708,8 @@ extern int gdbtk_test (char *); + { + symarg = argv[optind]; + execarg = argv[optind]; ++ if (optind + 1 == argc && corearg == NULL) ++ corearg = argv[optind]; + optind++; + } + +@@ -816,10 +848,25 @@ Excess command line arguments ignored. ( + && symarg != NULL + && strcmp (execarg, symarg) == 0) + { ++ catch_command_errors_ftype *func; ++ ++ /* Call exec_or_core_file_attach only if the file was specified as ++ a command line argument (and not an a command line option). */ ++ if (corearg != NULL && strcmp (corearg, execarg) == 0) ++ { ++ func = exec_or_core_file_attach; ++ corearg = NULL; ++ } ++ else ++ func = exec_file_attach; ++ + /* The exec file and the symbol-file are the same. If we can't +- open it, better only print one error message. +- catch_command_errors returns non-zero on success! */ +- if (catch_command_errors (exec_file_attach, execarg, !batch_flag, RETURN_MASK_ALL)) ++ open it, better only print one error message. ++ catch_command_errors returns non-zero on success! ++ Do not load EXECARG as a symbol file if it has been already processed ++ as a core file. */ ++ if (catch_command_errors (func, execarg, !batch_flag, RETURN_MASK_ALL) ++ && core_bfd == NULL) + catch_command_errors (symbol_file_add_main, symarg, !batch_flag, RETURN_MASK_ALL); + } + else diff --git a/gdb-6.6-buildid-locate-rpm.patch b/gdb-6.6-buildid-locate-rpm.patch index 32cbca3..fc820d5 100644 --- a/gdb-6.6-buildid-locate-rpm.patch +++ b/gdb-6.6-buildid-locate-rpm.patch @@ -1,7 +1,7 @@ -Index: gdb-6.8.50.20090909/gdb/event-top.c +Index: gdb-7.1.90.20100806/gdb/event-top.c =================================================================== ---- gdb-6.8.50.20090909.orig/gdb/event-top.c 2009-09-09 20:05:48.000000000 +0200 -+++ gdb-6.8.50.20090909/gdb/event-top.c 2009-09-09 20:08:04.000000000 +0200 +--- gdb-7.1.90.20100806.orig/gdb/event-top.c 2010-08-06 17:42:01.000000000 +0200 ++++ gdb-7.1.90.20100806/gdb/event-top.c 2010-08-06 17:42:05.000000000 +0200 @@ -33,6 +33,7 @@ #include "cli/cli-script.h" /* for reset_command_nest_depth */ #include "main.h" @@ -28,27 +28,19 @@ Index: gdb-6.8.50.20090909/gdb/event-top.c /* Each interpreter has its own rules on displaying the command prompt. */ if (!current_interp_display_prompt_p ()) -Index: gdb-6.8.50.20090909/gdb/symfile.c +Index: gdb-7.1.90.20100806/gdb/elfread.c =================================================================== ---- gdb-6.8.50.20090909.orig/gdb/symfile.c 2009-09-09 20:08:04.000000000 +0200 -+++ gdb-6.8.50.20090909/gdb/symfile.c 2009-09-09 20:08:04.000000000 +0200 -@@ -57,6 +57,7 @@ - #include "solib.h" - #include "remote.h" - #include "libbfd.h" +--- gdb-7.1.90.20100806.orig/gdb/elfread.c 2010-08-06 17:42:01.000000000 +0200 ++++ gdb-7.1.90.20100806/gdb/elfread.c 2010-08-06 18:11:49.000000000 +0200 +@@ -42,6 +42,7 @@ + #include "gdbcore.h" + #include "gdbcmd.h" + #include "observer.h" +#include "elf/external.h" - #include - #include -@@ -65,6 +66,7 @@ - #include - #include - #include -+#include - + extern void _initialize_elfread (void); - int (*deprecated_ui_load_progress_hook) (const char *section, unsigned long num); -@@ -1673,8 +1675,352 @@ build_id_to_filename (struct build_id *b +@@ -1371,8 +1372,357 @@ build_id_to_filename (struct build_id *b return retval; } @@ -121,8 +113,12 @@ Index: gdb-6.8.50.20090909/gdb/symfile.c +# define rpmtsInitIterator_p rpmtsInitIterator +#endif /* !DLOPEN_LIBRPM */ + -+ if (filename == NULL) -+ return 0; ++ gdb_assert (filename != NULL); ++ if (filename[0] != '/') ++ { ++ warning (_("Ignoring non-absolute filename: <%s>"), filename); ++ return 0; ++ } + + if (!rpm_init_done) + { @@ -258,7 +254,8 @@ Index: gdb-6.8.50.20090909/gdb/symfile.c + + /* Base package name for `debuginfo-install'. We do not use the + `yum' command directly as the line -+ yum --enablerepo='*-debuginfo' install NAME-debuginfo.ARCH ++ yum --disablerepo='*' --enablerepo='*-debuginfo' \ ++ install NAME-debuginfo.ARCH + would be more complicated than just: + debuginfo-install NAME-VERSION-RELEASE.ARCH + Do not supply the rpm base name (derived from .src.rpm name) as @@ -398,11 +395,11 @@ Index: gdb-6.8.50.20090909/gdb/symfile.c + /* This MISSING_FILEPAIR_HASH tracker is used only for the duplicite messages - Try to install the hash file ... -+ yum --enablerepo='*-debuginfo' install ... ++ yum --disablerepo='*' --enablerepo='*-debuginfo' install ... avoidance. */ struct missing_filepair -@@ -1728,11 +2074,17 @@ missing_filepair_change (void) +@@ -1426,11 +1776,17 @@ missing_filepair_change (void) /* All their memory came just from missing_filepair_OBSTACK. */ missing_filepair_hash = NULL; } @@ -420,7 +417,7 @@ Index: gdb-6.8.50.20090909/gdb/symfile.c missing_filepair_change (); } -@@ -1799,14 +2151,33 @@ debug_print_missing (const char *binary, +@@ -1497,14 +1853,35 @@ debug_print_missing (const char *binary, *slot = missing_filepair; @@ -446,7 +443,8 @@ Index: gdb-6.8.50.20090909/gdb/symfile.c + } + } + if (missing_exec != MISSING_EXEC_ENLISTED) -+ if (missing_rpm_enlist (binary) == 0 && missing_rpm_enlist (debug) == 0) ++ if ((binary[0] == 0 || missing_rpm_enlist (binary) == 0) ++ && (debug == NULL || missing_rpm_enlist (debug) == 0)) +#endif /* HAVE_LIBRPM */ + { + /* We do not collect and flush these messages as each such message @@ -456,16 +454,17 @@ Index: gdb-6.8.50.20090909/gdb/symfile.c + _("Missing separate debuginfo for %s\n"), binary); + if (debug != NULL) + fprintf_unfiltered (gdb_stdlog, _("Try: %s %s\n"), -+ "yum --enablerepo='*-debuginfo' install", debug); ++ "yum --disablerepo='*' --enablerepo='*-debuginfo'" ++ " install", debug); + } } static char * -Index: gdb-6.8.50.20090909/gdb/symfile.h +Index: gdb-7.1.90.20100806/gdb/symfile.h =================================================================== ---- gdb-6.8.50.20090909.orig/gdb/symfile.h 2009-09-09 20:08:04.000000000 +0200 -+++ gdb-6.8.50.20090909/gdb/symfile.h 2009-09-09 20:08:04.000000000 +0200 -@@ -387,6 +387,7 @@ extern struct build_id *build_id_addr_ge +--- gdb-7.1.90.20100806.orig/gdb/symfile.h 2010-08-06 17:42:01.000000000 +0200 ++++ gdb-7.1.90.20100806/gdb/symfile.h 2010-08-06 17:42:05.000000000 +0200 +@@ -577,6 +577,7 @@ extern struct build_id *build_id_addr_ge extern char *build_id_to_filename (struct build_id *build_id, char **link_return, int add_debug_suffix); extern void debug_print_missing (const char *binary, const char *debug); @@ -473,11 +472,11 @@ Index: gdb-6.8.50.20090909/gdb/symfile.h /* From dwarf2read.c */ -Index: gdb-6.8.50.20090909/gdb/testsuite/lib/gdb.exp +Index: gdb-7.1.90.20100806/gdb/testsuite/lib/gdb.exp =================================================================== ---- gdb-6.8.50.20090909.orig/gdb/testsuite/lib/gdb.exp 2009-09-09 20:08:04.000000000 +0200 -+++ gdb-6.8.50.20090909/gdb/testsuite/lib/gdb.exp 2009-09-09 20:08:04.000000000 +0200 -@@ -1248,7 +1248,7 @@ proc default_gdb_start { } { +--- gdb-7.1.90.20100806.orig/gdb/testsuite/lib/gdb.exp 2010-08-06 17:42:01.000000000 +0200 ++++ gdb-7.1.90.20100806/gdb/testsuite/lib/gdb.exp 2010-08-06 17:42:05.000000000 +0200 +@@ -1359,7 +1359,7 @@ proc default_gdb_start { } { warning "Couldn't set the width to 0." } } @@ -486,10 +485,10 @@ Index: gdb-6.8.50.20090909/gdb/testsuite/lib/gdb.exp send_gdb "set build-id-verbose 0\n" gdb_expect 10 { -re "$gdb_prompt $" { -Index: gdb-6.8.50.20090909/gdb/testsuite/lib/mi-support.exp +Index: gdb-7.1.90.20100806/gdb/testsuite/lib/mi-support.exp =================================================================== ---- gdb-6.8.50.20090909.orig/gdb/testsuite/lib/mi-support.exp 2009-09-09 20:08:04.000000000 +0200 -+++ gdb-6.8.50.20090909/gdb/testsuite/lib/mi-support.exp 2009-09-09 20:08:04.000000000 +0200 +--- gdb-7.1.90.20100806.orig/gdb/testsuite/lib/mi-support.exp 2010-08-06 17:42:01.000000000 +0200 ++++ gdb-7.1.90.20100806/gdb/testsuite/lib/mi-support.exp 2010-08-06 17:42:05.000000000 +0200 @@ -221,7 +221,7 @@ proc default_mi_gdb_start { args } { } } @@ -499,10 +498,10 @@ Index: gdb-6.8.50.20090909/gdb/testsuite/lib/mi-support.exp send_gdb "190-gdb-set build-id-verbose 0\n" gdb_expect 10 { -re ".*190-gdb-set build-id-verbose 0\r\n190\\\^done\r\n$mi_gdb_prompt$" { -Index: gdb-6.8.50.20090909/gdb/tui/tui-interp.c +Index: gdb-7.1.90.20100806/gdb/tui/tui-interp.c =================================================================== ---- gdb-6.8.50.20090909.orig/gdb/tui/tui-interp.c 2009-09-09 20:05:48.000000000 +0200 -+++ gdb-6.8.50.20090909/gdb/tui/tui-interp.c 2009-09-09 20:08:04.000000000 +0200 +--- gdb-7.1.90.20100806.orig/gdb/tui/tui-interp.c 2010-08-06 17:42:01.000000000 +0200 ++++ gdb-7.1.90.20100806/gdb/tui/tui-interp.c 2010-08-06 17:42:05.000000000 +0200 @@ -30,6 +30,7 @@ #include "tui/tui.h" #include "tui/tui-io.h" @@ -511,7 +510,7 @@ Index: gdb-6.8.50.20090909/gdb/tui/tui-interp.c /* Set to 1 when the TUI mode must be activated when we first start gdb. */ -@@ -128,6 +129,8 @@ tui_command_loop (void *data) +@@ -146,6 +147,8 @@ tui_command_loop (void *data) char *a_prompt; char *gdb_prompt = get_prompt (); @@ -520,10 +519,10 @@ Index: gdb-6.8.50.20090909/gdb/tui/tui-interp.c /* Tell readline what the prompt to display is and what function it will need to call after a whole line is read. This also displays the first prompt. */ -Index: gdb-6.8.50.20090909/gdb/aclocal.m4 +Index: gdb-7.1.90.20100806/gdb/aclocal.m4 =================================================================== ---- gdb-6.8.50.20090909.orig/gdb/aclocal.m4 2009-09-09 20:05:48.000000000 +0200 -+++ gdb-6.8.50.20090909/gdb/aclocal.m4 2009-09-09 20:09:32.000000000 +0200 +--- gdb-7.1.90.20100806.orig/gdb/aclocal.m4 2010-08-06 17:42:01.000000000 +0200 ++++ gdb-7.1.90.20100806/gdb/aclocal.m4 2010-08-06 17:42:05.000000000 +0200 @@ -19,6 +19,162 @@ You have another version of autoconf. I If you have problems, you may need to regenerate the build system entirely. To do so, use the procedure documented by the package, typically `autoreconf'.])]) @@ -687,11 +686,11 @@ Index: gdb-6.8.50.20090909/gdb/aclocal.m4 # Copyright (C) 2002, 2003, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation -Index: gdb-6.8.50.20090909/gdb/config.in +Index: gdb-7.1.90.20100806/gdb/config.in =================================================================== ---- gdb-6.8.50.20090909.orig/gdb/config.in 2009-09-09 20:08:04.000000000 +0200 -+++ gdb-6.8.50.20090909/gdb/config.in 2009-09-09 20:08:04.000000000 +0200 -@@ -42,6 +42,9 @@ +--- gdb-7.1.90.20100806.orig/gdb/config.in 2010-08-06 17:42:01.000000000 +0200 ++++ gdb-7.1.90.20100806/gdb/config.in 2010-08-06 17:42:05.000000000 +0200 +@@ -46,6 +46,9 @@ /* Define to BFD's default target vector. */ #undef DEFAULT_BFD_VEC @@ -701,9 +700,9 @@ Index: gdb-6.8.50.20090909/gdb/config.in /* Define to 1 if translation of program messages to the user's native language is requested. */ #undef ENABLE_NLS -@@ -221,6 +224,9 @@ - /* Define if Python 2.6 is being used. */ - #undef HAVE_LIBPYTHON2_6 +@@ -231,6 +234,9 @@ + /* Define if Python 2.7 is being used. */ + #undef HAVE_LIBPYTHON2_7 +/* Define if librpm library is being used. */ +#undef HAVE_LIBRPM @@ -711,11 +710,11 @@ Index: gdb-6.8.50.20090909/gdb/config.in /* Define if libunwind library is being used. */ #undef HAVE_LIBUNWIND -Index: gdb-6.8.50.20090909/gdb/configure +Index: gdb-7.1.90.20100806/gdb/configure =================================================================== ---- gdb-6.8.50.20090909.orig/gdb/configure 2009-09-09 20:08:04.000000000 +0200 -+++ gdb-6.8.50.20090909/gdb/configure 2009-09-09 20:09:35.000000000 +0200 -@@ -676,6 +676,9 @@ REPORT_BUGS_TO +--- gdb-7.1.90.20100806.orig/gdb/configure 2010-08-06 17:42:01.000000000 +0200 ++++ gdb-7.1.90.20100806/gdb/configure 2010-08-06 17:42:05.000000000 +0200 +@@ -679,6 +679,9 @@ REPORT_BUGS_TO PKGVERSION TARGET_OBS subdirs @@ -725,7 +724,7 @@ Index: gdb-6.8.50.20090909/gdb/configure pythondir GDB_DATADIR_PATH GDB_DATADIR -@@ -886,6 +889,7 @@ with_separate_debug_dir +@@ -948,6 +951,7 @@ with_separate_debug_dir with_gdb_datadir with_relocated_sources with_pythondir @@ -733,7 +732,7 @@ Index: gdb-6.8.50.20090909/gdb/configure enable_targets enable_64_bit_bfd enable_gdbcli -@@ -925,6 +929,9 @@ LDFLAGS +@@ -988,6 +992,9 @@ LDFLAGS LIBS CPPFLAGS CPP @@ -743,7 +742,7 @@ Index: gdb-6.8.50.20090909/gdb/configure YACC YFLAGS XMKMF' -@@ -1588,6 +1595,8 @@ Optional Packages: +@@ -1653,6 +1660,8 @@ Optional Packages: [DATADIR/gdb] --with-pythondir install Python data files in this path [DATADIR/gdb/python] @@ -752,7 +751,7 @@ Index: gdb-6.8.50.20090909/gdb/configure --with-libunwind use libunwind frame unwinding support --with-curses use the curses library instead of the termcap library -@@ -1621,6 +1630,9 @@ Some influential environment variables: +@@ -1688,6 +1697,9 @@ Some influential environment variables: CPPFLAGS C/C++/Objective C preprocessor flags, e.g. -I if you have headers in a nonstandard directory CPP C preprocessor @@ -762,7 +761,7 @@ Index: gdb-6.8.50.20090909/gdb/configure YACC The `Yet Another C Compiler' implementation to use. Defaults to the first program found out of: `bison -y', `byacc', `yacc'. YFLAGS The list of arguments that will be passed by default to $YACC. -@@ -6675,6 +6687,486 @@ _ACEOF +@@ -7951,6 +7963,485 @@ _ACEOF fi @@ -931,7 +930,7 @@ Index: gdb-6.8.50.20090909/gdb/configure + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + -+/* Duplicate here the declarations to verify they match "symfile.c". */ ++/* Duplicate here the declarations to verify they match "elfread.c". */ +#include +#include +#include @@ -1185,7 +1184,7 @@ Index: gdb-6.8.50.20090909/gdb/configure + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + -+/* Duplicate here the declarations to verify they match "symfile.c". */ ++/* Duplicate here the declarations to verify they match "elfread.c". */ +#include +#include +#include @@ -1245,291 +1244,14 @@ Index: gdb-6.8.50.20090909/gdb/configure + fi + fi +fi -+ - - - -@@ -9721,265 +10213,25 @@ $as_echo "#define STDC_HEADERS 1" >>conf - - fi - -- -- - for ac_header in sys/user32.h sys/procfs32.h --do --as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` --if eval "test \"\${$as_ac_Header+set}\" = set"; then -- echo "$as_me:$LINENO: checking for $ac_header" >&5 --echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 --if eval "test \"\${$as_ac_Header+set}\" = set"; then -- echo $ECHO_N "(cached) $ECHO_C" >&6 --fi --echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 --echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 --else -- # Is the header compilable? --echo "$as_me:$LINENO: checking $ac_header usability" >&5 --echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6 --cat >conftest.$ac_ext <<_ACEOF --/* confdefs.h. */ --_ACEOF --cat confdefs.h >>conftest.$ac_ext --cat >>conftest.$ac_ext <<_ACEOF --/* end confdefs.h. */ --$ac_includes_default --#include <$ac_header> --_ACEOF --rm -f conftest.$ac_objext --if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 -- (eval $ac_compile) 2>conftest.er1 -- ac_status=$? -- grep -v '^ *+' conftest.er1 >conftest.err -- rm -f conftest.er1 -- cat conftest.err >&5 -- echo "$as_me:$LINENO: \$? = $ac_status" >&5 -- (exit $ac_status); } && -- { ac_try='test -z "$ac_c_werror_flag" -- || test ! -s conftest.err' -- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -- (eval $ac_try) 2>&5 -- ac_status=$? -- echo "$as_me:$LINENO: \$? = $ac_status" >&5 -- (exit $ac_status); }; } && -- { ac_try='test -s conftest.$ac_objext' -- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -- (eval $ac_try) 2>&5 -- ac_status=$? -- echo "$as_me:$LINENO: \$? = $ac_status" >&5 -- (exit $ac_status); }; }; then -- ac_header_compiler=yes --else -- echo "$as_me: failed program was:" >&5 --sed 's/^/| /' conftest.$ac_ext >&5 -- --ac_header_compiler=no --fi --rm -f conftest.err conftest.$ac_objext conftest.$ac_ext --echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 --echo "${ECHO_T}$ac_header_compiler" >&6 -- --# Is the header present? --echo "$as_me:$LINENO: checking $ac_header presence" >&5 --echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6 --cat >conftest.$ac_ext <<_ACEOF --/* confdefs.h. */ --_ACEOF --cat confdefs.h >>conftest.$ac_ext --cat >>conftest.$ac_ext <<_ACEOF --/* end confdefs.h. */ --#include <$ac_header> --_ACEOF --if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 -- (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 -- ac_status=$? -- grep -v '^ *+' conftest.er1 >conftest.err -- rm -f conftest.er1 -- cat conftest.err >&5 -- echo "$as_me:$LINENO: \$? = $ac_status" >&5 -- (exit $ac_status); } >/dev/null; then -- if test -s conftest.err; then -- ac_cpp_err=$ac_c_preproc_warn_flag -- ac_cpp_err=$ac_cpp_err$ac_c_werror_flag -- else -- ac_cpp_err= -- fi --else -- ac_cpp_err=yes --fi --if test -z "$ac_cpp_err"; then -- ac_header_preproc=yes --else -- echo "$as_me: failed program was:" >&5 --sed 's/^/| /' conftest.$ac_ext >&5 -- -- ac_header_preproc=no --fi --rm -f conftest.err conftest.$ac_ext --echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 --echo "${ECHO_T}$ac_header_preproc" >&6 -- --# So? What about this header? --case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in -- yes:no: ) -- { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 --echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} -- { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 --echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} -- ac_header_preproc=yes -- ;; -- no:yes:* ) -- { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 --echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} -- { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 --echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} -- { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 --echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} -- { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 --echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} -- { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 --echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} -- { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 --echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} -- ( -- cat <<\_ASBOX --## ------------------------------------------ ## --## Report this to the AC_PACKAGE_NAME lists. ## --## ------------------------------------------ ## --_ASBOX -- ) | -- sed "s/^/$as_me: WARNING: /" >&2 -- ;; --esac --echo "$as_me:$LINENO: checking for $ac_header" >&5 --echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 --if eval "test \"\${$as_ac_Header+set}\" = set"; then -- echo $ECHO_N "(cached) $ECHO_C" >&6 --else -- eval "$as_ac_Header=\$ac_header_preproc" --fi --echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 --echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 -- --fi --if test `eval echo '${'$as_ac_Header'}'` = yes; then -+do : -+ as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` -+ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" -+eval as_val=\$$as_ac_Header -+ if test "x$as_val" = x""yes; then : - cat >>confdefs.h <<_ACEOF --#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 -+#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 - _ACEOF - - fi - - done --echo "$as_me:$LINENO: checking for struct elf_prstatus32.pr_reg" >&5 --echo $ECHO_N "checking for struct elf_prstatus32.pr_reg... $ECHO_C" >&6 --if test "${ac_cv_member_struct_elf_prstatus32_pr_reg+set}" = set; then -- echo $ECHO_N "(cached) $ECHO_C" >&6 --else -- cat >conftest.$ac_ext <<_ACEOF --/* confdefs.h. */ --_ACEOF --cat confdefs.h >>conftest.$ac_ext --cat >>conftest.$ac_ext <<_ACEOF --/* end confdefs.h. */ --#include -- --int --main () --{ --static struct elf_prstatus32 ac_aggr; --if (ac_aggr.pr_reg) --return 0; -- ; -- return 0; --} --_ACEOF --rm -f conftest.$ac_objext --if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 -- (eval $ac_compile) 2>conftest.er1 -- ac_status=$? -- grep -v '^ *+' conftest.er1 >conftest.err -- rm -f conftest.er1 -- cat conftest.err >&5 -- echo "$as_me:$LINENO: \$? = $ac_status" >&5 -- (exit $ac_status); } && -- { ac_try='test -z "$ac_c_werror_flag" -- || test ! -s conftest.err' -- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -- (eval $ac_try) 2>&5 -- ac_status=$? -- echo "$as_me:$LINENO: \$? = $ac_status" >&5 -- (exit $ac_status); }; } && -- { ac_try='test -s conftest.$ac_objext' -- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -- (eval $ac_try) 2>&5 -- ac_status=$? -- echo "$as_me:$LINENO: \$? = $ac_status" >&5 -- (exit $ac_status); }; }; then -- ac_cv_member_struct_elf_prstatus32_pr_reg=yes --else -- echo "$as_me: failed program was:" >&5 --sed 's/^/| /' conftest.$ac_ext >&5 -- --cat >conftest.$ac_ext <<_ACEOF --/* confdefs.h. */ --_ACEOF --cat confdefs.h >>conftest.$ac_ext --cat >>conftest.$ac_ext <<_ACEOF --/* end confdefs.h. */ --#include -- --int --main () --{ --static struct elf_prstatus32 ac_aggr; --if (sizeof ac_aggr.pr_reg) --return 0; -- ; -- return 0; --} --_ACEOF --rm -f conftest.$ac_objext --if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 -- (eval $ac_compile) 2>conftest.er1 -- ac_status=$? -- grep -v '^ *+' conftest.er1 >conftest.err -- rm -f conftest.er1 -- cat conftest.err >&5 -- echo "$as_me:$LINENO: \$? = $ac_status" >&5 -- (exit $ac_status); } && -- { ac_try='test -z "$ac_c_werror_flag" -- || test ! -s conftest.err' -- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -- (eval $ac_try) 2>&5 -- ac_status=$? -- echo "$as_me:$LINENO: \$? = $ac_status" >&5 -- (exit $ac_status); }; } && -- { ac_try='test -s conftest.$ac_objext' -- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -- (eval $ac_try) 2>&5 -- ac_status=$? -- echo "$as_me:$LINENO: \$? = $ac_status" >&5 -- (exit $ac_status); }; }; then -- ac_cv_member_struct_elf_prstatus32_pr_reg=yes --else -- echo "$as_me: failed program was:" >&5 --sed 's/^/| /' conftest.$ac_ext >&5 -- --ac_cv_member_struct_elf_prstatus32_pr_reg=no --fi --rm -f conftest.err conftest.$ac_objext conftest.$ac_ext --fi --rm -f conftest.err conftest.$ac_objext conftest.$ac_ext --fi --echo "$as_me:$LINENO: result: $ac_cv_member_struct_elf_prstatus32_pr_reg" >&5 --echo "${ECHO_T}$ac_cv_member_struct_elf_prstatus32_pr_reg" >&6 --if test $ac_cv_member_struct_elf_prstatus32_pr_reg = yes; then -+ac_fn_c_check_member "$LINENO" "struct elf_prstatus32" "pr_reg" "ac_cv_member_struct_elf_prstatus32_pr_reg" "#include -+" -+if test "x$ac_cv_member_struct_elf_prstatus32_pr_reg" = x""yes; then : --cat >>confdefs.h <<\_ACEOF --#define HAVE_ELF_PRSTATUS32 1 --_ACEOF -+$as_echo "#define HAVE_ELF_PRSTATUS32 1" >>confdefs.h - fi - -Index: gdb-6.8.50.20090909/gdb/configure.ac +Index: gdb-7.1.90.20100806/gdb/configure.ac =================================================================== ---- gdb-6.8.50.20090909.orig/gdb/configure.ac 2009-09-09 20:08:04.000000000 +0200 -+++ gdb-6.8.50.20090909/gdb/configure.ac 2009-09-09 20:08:04.000000000 +0200 -@@ -151,6 +151,199 @@ else +--- gdb-7.1.90.20100806.orig/gdb/configure.ac 2010-08-06 17:42:01.000000000 +0200 ++++ gdb-7.1.90.20100806/gdb/configure.ac 2010-08-06 17:42:05.000000000 +0200 +@@ -152,6 +152,198 @@ else fi AC_SUBST(pythondir) @@ -1662,7 +1384,7 @@ Index: gdb-6.8.50.20090909/gdb/configure.ac + save_CFLAGS="$CFLAGS" + CFLAGS="$CFLAGS -Werror" + AC_COMPILE_IFELSE(AC_LANG_PROGRAM([[ -+/* Duplicate here the declarations to verify they match "symfile.c". */ ++/* Duplicate here the declarations to verify they match "elfread.c". */ +#include +#include +#include @@ -1725,21 +1447,20 @@ Index: gdb-6.8.50.20090909/gdb/configure.ac + fi + fi +fi -+ AC_CONFIG_SUBDIRS(doc testsuite) -Index: gdb-6.8.50.20090909/gdb/acinclude.m4 +Index: gdb-7.1.90.20100806/gdb/acinclude.m4 =================================================================== ---- gdb-6.8.50.20090909.orig/gdb/acinclude.m4 2009-09-09 20:05:48.000000000 +0200 -+++ gdb-6.8.50.20090909/gdb/acinclude.m4 2009-09-09 20:08:04.000000000 +0200 +--- gdb-7.1.90.20100806.orig/gdb/acinclude.m4 2010-08-06 17:42:01.000000000 +0200 ++++ gdb-7.1.90.20100806/gdb/acinclude.m4 2010-08-06 17:42:05.000000000 +0200 @@ -1,3 +1,5 @@ +# serial 1 + dnl written by Rob Savoye for Cygnus Support dnl major rewriting for Tcl 7.5 by Don Libes -@@ -79,8 +81,6 @@ AC_MSG_RESULT(yes) +@@ -81,8 +83,6 @@ AC_MSG_RESULT(yes) # Foundation, Inc., 51 Franklin Street, Fifth Floor, # Boston, MA 02110-1301, USA. diff --git a/gdb-6.6-buildid-locate.patch b/gdb-6.6-buildid-locate.patch index 5f2679c..ff134f1 100644 --- a/gdb-6.6-buildid-locate.patch +++ b/gdb-6.6-buildid-locate.patch @@ -1,19 +1,18 @@ -Index: gdb-7.0/gdb/corelow.c +Index: gdb-7.1.90.20100711/gdb/corelow.c =================================================================== ---- gdb-7.0.orig/gdb/corelow.c 2009-07-31 17:25:21.000000000 +0200 -+++ gdb-7.0/gdb/corelow.c 2009-10-23 00:17:29.000000000 +0200 -@@ -45,6 +45,10 @@ - #include "exceptions.h" - #include "solib.h" +--- gdb-7.1.90.20100711.orig/gdb/corelow.c 2010-05-14 01:53:32.000000000 +0200 ++++ gdb-7.1.90.20100711/gdb/corelow.c 2010-07-12 11:07:33.000000000 +0200 +@@ -47,6 +47,9 @@ #include "filenames.h" + #include "progspace.h" + #include "objfiles.h" +#include "auxv.h" +#include "elf/common.h" -+#include "objfiles.h" +#include "gdbcmd.h" #ifndef O_LARGEFILE -@@ -273,6 +277,52 @@ add_to_thread_list (bfd *abfd, asection +@@ -289,6 +292,52 @@ add_to_thread_list (bfd *abfd, asection inferior_ptid = ptid; /* Yes, make it current */ } @@ -66,7 +65,7 @@ Index: gdb-7.0/gdb/corelow.c /* This routine opens and sets up the core file bfd. */ static void -@@ -371,6 +421,12 @@ core_open (char *filename, int from_tty) +@@ -386,6 +435,12 @@ core_open (char *filename, int from_tty) push_target (&core_ops); discard_cleanups (old_chain); @@ -76,10 +75,10 @@ Index: gdb-7.0/gdb/corelow.c + if (build_id_core_loads != 0) + build_id_locate_exec (from_tty); + - add_inferior_silent (corelow_pid); - /* Do this before acknowledging the inferior, so if -@@ -878,4 +934,11 @@ _initialize_corelow (void) + post_create_inferior throws (can happen easilly if you're loading + a core file with the wrong exec), we aren't left with threads +@@ -924,4 +979,11 @@ _initialize_corelow (void) init_core_ops (); add_target (&core_ops); @@ -91,11 +90,11 @@ Index: gdb-7.0/gdb/corelow.c + NULL, NULL, NULL, + &setlist, &showlist); } -Index: gdb-7.0/gdb/doc/gdb.texinfo +Index: gdb-7.1.90.20100711/gdb/doc/gdb.texinfo =================================================================== ---- gdb-7.0.orig/gdb/doc/gdb.texinfo 2009-10-23 00:12:39.000000000 +0200 -+++ gdb-7.0/gdb/doc/gdb.texinfo 2009-10-23 00:17:29.000000000 +0200 -@@ -13896,6 +13896,27 @@ information files. +--- gdb-7.1.90.20100711.orig/gdb/doc/gdb.texinfo 2010-07-12 10:59:30.000000000 +0200 ++++ gdb-7.1.90.20100711/gdb/doc/gdb.texinfo 2010-07-12 11:05:57.000000000 +0200 +@@ -14980,6 +14980,27 @@ information files. @end table @@ -123,11 +122,11 @@ Index: gdb-7.0/gdb/doc/gdb.texinfo @cindex @code{.gnu_debuglink} sections @cindex debug link sections A debug link is a special section of the executable file named -Index: gdb-7.0/gdb/solib-svr4.c +Index: gdb-7.1.90.20100711/gdb/solib-svr4.c =================================================================== ---- gdb-7.0.orig/gdb/solib-svr4.c 2009-10-23 00:12:38.000000000 +0200 -+++ gdb-7.0/gdb/solib-svr4.c 2009-10-23 00:17:29.000000000 +0200 -@@ -1101,9 +1101,49 @@ svr4_current_sos (void) +--- gdb-7.1.90.20100711.orig/gdb/solib-svr4.c 2010-07-12 10:00:56.000000000 +0200 ++++ gdb-7.1.90.20100711/gdb/solib-svr4.c 2010-07-12 11:05:57.000000000 +0200 +@@ -1181,9 +1181,49 @@ svr4_current_sos (void) safe_strerror (errcode)); else { @@ -180,20 +179,23 @@ Index: gdb-7.0/gdb/solib-svr4.c } xfree (buffer); -Index: gdb-7.0/gdb/symfile.c +Index: gdb-7.1.90.20100711/gdb/elfread.c =================================================================== ---- gdb-7.0.orig/gdb/symfile.c 2009-10-23 00:12:38.000000000 +0200 -+++ gdb-7.0/gdb/symfile.c 2009-10-23 00:43:28.000000000 +0200 -@@ -56,6 +56,7 @@ - #include "elf-bfd.h" - #include "solib.h" - #include "remote.h" +--- gdb-7.1.90.20100711.orig/gdb/elfread.c 2010-07-12 10:00:56.000000000 +0200 ++++ gdb-7.1.90.20100711/gdb/elfread.c 2010-07-12 11:30:30.000000000 +0200 +@@ -38,6 +38,10 @@ + #include "demangle.h" + #include "psympriv.h" + #include "gdbtypes.h" +#include "libbfd.h" ++#include "gdbcore.h" ++#include "gdbcmd.h" ++#include "observer.h" - #include - #include -@@ -1173,16 +1174,65 @@ symbol_file_clear (int from_tty) - printf_unfiltered (_("No symbol file now.\n")); + extern void _initialize_elfread (void); + +@@ -818,16 +822,65 @@ resolve_gnu_ifunc (const char *function_ + return 0; } +/* Locate NT_GNU_BUILD_ID and return its matching debug filename. @@ -260,7 +262,7 @@ Index: gdb-7.0/gdb/symfile.c { struct build_id *retval; -@@ -1198,6 +1248,348 @@ build_id_bfd_get (bfd *abfd) +@@ -843,6 +896,348 @@ build_id_bfd_get (bfd *abfd) return retval; } @@ -609,7 +611,7 @@ Index: gdb-7.0/gdb/symfile.c /* Return if FILENAME has NT_GNU_BUILD_ID matching the CHECK value. */ static int -@@ -1215,7 +1607,7 @@ build_id_verify (const char *filename, s +@@ -857,7 +1252,7 @@ build_id_verify (const char *filename, s if (abfd == NULL) return 0; @@ -618,7 +620,7 @@ Index: gdb-7.0/gdb/symfile.c if (found == NULL) warning (_("File \"%s\" has no build-id, file skipped"), filename); -@@ -1234,14 +1626,16 @@ build_id_verify (const char *filename, s +@@ -874,14 +1269,16 @@ build_id_verify (const char *filename, s return retval; } @@ -639,7 +641,7 @@ Index: gdb-7.0/gdb/symfile.c /* Keep backward compatibility so that DEBUG_FILE_DIRECTORY being "" will cause "/.build-id/..." lookups. */ -@@ -1272,7 +1666,10 @@ build_id_to_debug_filename (struct build +@@ -912,7 +1309,10 @@ build_id_to_debug_filename (struct build *s++ = '/'; while (size-- > 0) s += sprintf (s, "%02x", (unsigned) *data++); @@ -651,7 +653,7 @@ Index: gdb-7.0/gdb/symfile.c /* lrealpath() is expensive even for the usually non-existent files. */ if (access (link, F_OK) == 0) -@@ -1285,15 +1682,185 @@ build_id_to_debug_filename (struct build +@@ -925,26 +1325,201 @@ build_id_to_debug_filename (struct build } if (retval != NULL) @@ -836,72 +838,86 @@ Index: gdb-7.0/gdb/symfile.c +} + static char * - get_debug_link_info (struct objfile *objfile, unsigned long *crc32_out) +-find_separate_debug_file_by_buildid (struct objfile *objfile) ++find_separate_debug_file_by_buildid (struct objfile *objfile, ++ char **build_id_filename_return) { -@@ -1384,13 +1951,14 @@ find_separate_debug_file (struct objfile - unsigned long crc32; - int i; struct build_id *build_id; -+ char *build_id_filename = NULL; - build_id = build_id_bfd_get (objfile->obfd); ++ if (build_id_filename_return) ++ *build_id_filename_return = NULL; ++ + build_id = build_id_bfd_shdr_get (objfile->obfd); if (build_id != NULL) { char *build_id_name; - build_id_name = build_id_to_debug_filename (build_id); -+ build_id_name = build_id_to_filename (build_id, &build_id_filename, 1); ++ build_id_name = build_id_to_filename (build_id, build_id_filename_return, ++ 1); xfree (build_id); /* Prevent looping on a stripped .debug file. */ if (build_id_name != NULL && strcmp (build_id_name, objfile->name) == 0) -@@ -1400,7 +1968,10 @@ find_separate_debug_file (struct objfile +@@ -954,7 +1529,7 @@ find_separate_debug_file_by_buildid (str xfree (build_id_name); } else if (build_id_name != NULL) - return build_id_name; -+ { -+ xfree (build_id_filename); -+ return build_id_name; -+ } ++ return build_id_name; + } + return NULL; + } +@@ -1131,9 +1706,10 @@ elf_symfile_read (struct objfile *objfil + `.gnu_debuglink' may no longer be present with `.note.gnu.build-id'. */ + if (!objfile_has_partial_symbols (objfile)) + { +- char *debugfile; ++ char *debugfile, *build_id_filename; + +- debugfile = find_separate_debug_file_by_buildid (objfile); ++ debugfile = find_separate_debug_file_by_buildid (objfile, ++ &build_id_filename); + + if (debugfile == NULL) + debugfile = find_separate_debug_file_by_debuglink (objfile); +@@ -1145,6 +1721,12 @@ elf_symfile_read (struct objfile *objfil + symbol_file_add_separate (abfd, symfile_flags, objfile); + xfree (debugfile); + } ++ /* Check if any separate debug info has been extracted out. */ ++ else if (bfd_get_section_by_name (objfile->obfd, ".gnu_debuglink") ++ != NULL) ++ debug_print_missing (objfile->name, build_id_filename); ++ ++ xfree (build_id_filename); } + } - basename = get_debug_link_info (objfile, &crc32); -@@ -1501,8 +2072,10 @@ find_separate_debug_file (struct objfile - - xfree (debugfile); - debugfile = NULL; -+ debug_print_missing (objfile->name, build_id_filename); - - cleanup_return_debugfile: -+ xfree (build_id_filename); - xfree (canon_name); - xfree (basename); - xfree (dir); -@@ -4256,4 +4829,16 @@ each global debug-file-directory compone - NULL, - show_debug_file_directory, - &setlist, &showlist); -+ -+ add_setshow_zinteger_cmd ("build-id-verbose", no_class, &build_id_verbose, -+ _("\ -+ Set debugging level of the build-id locator."), _("\ -+ Show debugging level of the build-id locator."), _("\ -+ Level 1 (default) enables printing the missing debug filenames,\n\ -+ level 2 also prints the parsing of binaries to find the identificators."), -+ NULL, -+ show_build_id_verbose, -+ &setlist, &showlist); -+ -+ observer_attach_executable_changed (debug_print_executable_changed); +@@ -1304,4 +1886,16 @@ void + _initialize_elfread (void) + { + add_symtab_fns (&elf_sym_fns); ++ ++ add_setshow_zinteger_cmd ("build-id-verbose", no_class, &build_id_verbose, ++ _("\ ++Set debugging level of the build-id locator."), _("\ ++Show debugging level of the build-id locator."), _("\ ++Level 1 (default) enables printing the missing debug filenames,\n\ ++level 2 also prints the parsing of binaries to find the identificators."), ++ NULL, ++ show_build_id_verbose, ++ &setlist, &showlist); ++ ++ observer_attach_executable_changed (debug_print_executable_changed); } -Index: gdb-7.0/gdb/symfile.h +Index: gdb-7.1.90.20100711/gdb/symfile.h =================================================================== ---- gdb-7.0.orig/gdb/symfile.h 2009-10-23 00:12:38.000000000 +0200 -+++ gdb-7.0/gdb/symfile.h 2009-10-23 00:17:29.000000000 +0200 -@@ -381,6 +381,13 @@ extern int symfile_map_offsets_to_segmen - struct symfile_segment_data *get_symfile_segment_data (bfd *abfd); - void free_symfile_segment_data (struct symfile_segment_data *data); +--- gdb-7.1.90.20100711.orig/gdb/symfile.h 2010-05-08 06:58:45.000000000 +0200 ++++ gdb-7.1.90.20100711/gdb/symfile.h 2010-07-12 11:06:18.000000000 +0200 +@@ -562,6 +562,13 @@ void free_symfile_segment_data (struct s + + extern struct cleanup *increment_reading_symtab (void); +/* build-id support. */ +struct build_id; @@ -913,11 +929,11 @@ Index: gdb-7.0/gdb/symfile.h /* From dwarf2read.c */ extern int dwarf2_has_info (struct objfile *); -Index: gdb-7.0/gdb/testsuite/lib/gdb.exp +Index: gdb-7.1.90.20100711/gdb/testsuite/lib/gdb.exp =================================================================== ---- gdb-7.0.orig/gdb/testsuite/lib/gdb.exp 2009-10-23 00:12:38.000000000 +0200 -+++ gdb-7.0/gdb/testsuite/lib/gdb.exp 2009-10-23 00:17:29.000000000 +0200 -@@ -1248,6 +1248,16 @@ proc default_gdb_start { } { +--- gdb-7.1.90.20100711.orig/gdb/testsuite/lib/gdb.exp 2010-07-12 10:00:56.000000000 +0200 ++++ gdb-7.1.90.20100711/gdb/testsuite/lib/gdb.exp 2010-07-12 11:05:57.000000000 +0200 +@@ -1353,6 +1353,16 @@ proc default_gdb_start { } { warning "Couldn't set the width to 0." } } @@ -934,10 +950,10 @@ Index: gdb-7.0/gdb/testsuite/lib/gdb.exp return 0; } -Index: gdb-7.0/gdb/testsuite/lib/mi-support.exp +Index: gdb-7.1.90.20100711/gdb/testsuite/lib/mi-support.exp =================================================================== ---- gdb-7.0.orig/gdb/testsuite/lib/mi-support.exp 2009-09-15 20:51:26.000000000 +0200 -+++ gdb-7.0/gdb/testsuite/lib/mi-support.exp 2009-10-23 00:17:29.000000000 +0200 +--- gdb-7.1.90.20100711.orig/gdb/testsuite/lib/mi-support.exp 2010-03-15 04:43:13.000000000 +0100 ++++ gdb-7.1.90.20100711/gdb/testsuite/lib/mi-support.exp 2010-07-12 11:05:57.000000000 +0200 @@ -221,6 +221,16 @@ proc default_mi_gdb_start { args } { } } @@ -955,18 +971,18 @@ Index: gdb-7.0/gdb/testsuite/lib/mi-support.exp detect_async -Index: gdb-7.0/gdb/objfiles.h +Index: gdb-7.1.90.20100711/gdb/objfiles.h =================================================================== ---- gdb-7.0.orig/gdb/objfiles.h 2009-10-23 00:12:38.000000000 +0200 -+++ gdb-7.0/gdb/objfiles.h 2009-10-23 00:17:29.000000000 +0200 -@@ -428,6 +428,10 @@ struct objfile +--- gdb-7.1.90.20100711.orig/gdb/objfiles.h 2010-04-14 19:26:11.000000000 +0200 ++++ gdb-7.1.90.20100711/gdb/objfiles.h 2010-07-12 11:07:08.000000000 +0200 +@@ -426,6 +426,10 @@ struct objfile - #define OBJF_MAIN (1 << 7) + #define OBJF_USERLOADED (1 << 3) /* User loaded */ +/* This file was loaded according to the BUILD_ID_CORE_LOADS rules. */ + +#define OBJF_BUILD_ID_CORE_LOADED (1 << 12) + - /* The object file that the main symbol table was loaded from (e.g. the - argument to the "symbol-file" or "file" command). */ + /* The object file that contains the runtime common minimal symbols + for SunOS4. Note that this objfile has no associated BFD. */ diff --git a/gdb-6.6-bz225783-prelink-path.patch b/gdb-6.6-bz225783-prelink-path.patch deleted file mode 100644 index 22c8829..0000000 --- a/gdb-6.6-bz225783-prelink-path.patch +++ /dev/null @@ -1,27 +0,0 @@ -https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=225783 - ---- gdb-6.8/gdb/testsuite/gdb.base/prelink.exp.orig 2008-07-12 08:56:43.000000000 +0200 -+++ gdb-6.8/gdb/testsuite/gdb.base/prelink.exp 2008-07-12 08:59:59.000000000 +0200 -@@ -55,7 +55,7 @@ if { [gdb_compile "${srcdir}/${subdir}/$ - # single new unprelinked library address without wasting the first one/two - # memory areas. We do not care of the efficiency of loading such resulting - # exec-shield unfriendly prelinked library. --if {[catch "system \"prelink -qNR --no-exec-shield ${libfile}\""] != 0} { -+if {[catch "system \"/usr/sbin/prelink -qNR --no-exec-shield ${libfile}\""] != 0} { - # Maybe we don't have prelink. - return -1 - } -@@ -96,11 +96,11 @@ if { $found == 0 } { - return 0 - } - --if {[catch "system \"prelink -uN ${libfile}\""] != 0} { -+if {[catch "system \"/usr/sbin/prelink -uN ${libfile}\""] != 0} { - untested "${testfile}.so was not prelinked, maybe system libraries are not prelinked?" - return 0 - } --catch "system \"prelink -qNR --no-exec-shield ${libfile}\"" -+catch "system \"/usr/sbin/prelink -qNR --no-exec-shield ${libfile}\"" - - # Start with a fresh gdb - diff --git a/gdb-6.6-bz229517-gcore-without-terminal.patch b/gdb-6.6-bz229517-gcore-without-terminal.patch index de34ed5..686bb9d 100644 --- a/gdb-6.6-bz229517-gcore-without-terminal.patch +++ b/gdb-6.6-bz229517-gcore-without-terminal.patch @@ -68,7 +68,7 @@ +} --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ ./gdb/testsuite/gdb.base/gcorebg.exp 25 Feb 2007 12:21:20 -0000 -@@ -0,0 +1,120 @@ +@@ -0,0 +1,113 @@ +# Copyright 2007 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify @@ -93,13 +93,6 @@ +# It also tests a regression with `gdb_gcore.sh' being run without its +# accessible terminal. + -+if $tracelevel then { -+ strace $tracelevel -+} -+ -+set prms_id 0 -+set bug_id 0 -+ +if ![info exists GCORE] { + set GCORE "${srcdir}/../gdb_gcore.sh" +} diff --git a/gdb-6.6-bz235197-fork-detach-info.patch b/gdb-6.6-bz235197-fork-detach-info.patch index 9d17778..64bc686 100644 --- a/gdb-6.6-bz235197-fork-detach-info.patch +++ b/gdb-6.6-bz235197-fork-detach-info.patch @@ -3,23 +3,23 @@ Port to GDB-6.8pre. Remove the `[' character from the GDB-6.8 default message. -Index: gdb-6.7.50.20080227/gdb/linux-nat.c +Index: gdb-7.0.50.20100115/gdb/linux-nat.c =================================================================== ---- gdb-6.7.50.20080227.orig/gdb/linux-nat.c 2008-03-01 10:30:48.000000000 +0100 -+++ gdb-6.7.50.20080227/gdb/linux-nat.c 2008-03-01 10:48:25.000000000 +0100 -@@ -415,7 +415,7 @@ linux_child_follow_fork (struct target_o - /* Detach new forked process? */ - if (detach_fork) - { +--- gdb-7.0.50.20100115.orig/gdb/linux-nat.c 2010-01-15 03:22:31.000000000 +0100 ++++ gdb-7.0.50.20100115/gdb/linux-nat.c 2010-01-15 03:23:28.000000000 +0100 +@@ -724,7 +724,7 @@ holding the child stopped. Try \"set de + remove_breakpoints_pid (GET_PID (inferior_ptid)); + } + - if (info_verbose || debug_linux_nat) + if (1 /* Fedora Bug 235197 */ || info_verbose || debug_linux_nat) { target_terminal_ours (); fprintf_filtered (gdb_stdlog, -Index: gdb-6.7.50.20080227/gdb/testsuite/gdb.base/fork-detach.c +Index: gdb-7.0.50.20100115/gdb/testsuite/gdb.base/fork-detach.c =================================================================== --- /dev/null 1970-01-01 00:00:00.000000000 +0000 -+++ gdb-6.7.50.20080227/gdb/testsuite/gdb.base/fork-detach.c 2008-03-01 10:30:49.000000000 +0100 ++++ gdb-7.0.50.20100115/gdb/testsuite/gdb.base/fork-detach.c 2010-01-15 03:22:52.000000000 +0100 @@ -0,0 +1,57 @@ +/* This testcase is part of GDB, the GNU debugger. + @@ -78,11 +78,11 @@ Index: gdb-6.7.50.20080227/gdb/testsuite/gdb.base/fork-detach.c + } + return 0; +} -Index: gdb-6.7.50.20080227/gdb/testsuite/gdb.base/fork-detach.exp +Index: gdb-7.0.50.20100115/gdb/testsuite/gdb.base/fork-detach.exp =================================================================== --- /dev/null 1970-01-01 00:00:00.000000000 +0000 -+++ gdb-6.7.50.20080227/gdb/testsuite/gdb.base/fork-detach.exp 2008-03-01 10:49:36.000000000 +0100 -@@ -0,0 +1,43 @@ ++++ gdb-7.0.50.20100115/gdb/testsuite/gdb.base/fork-detach.exp 2010-01-15 03:22:52.000000000 +0100 +@@ -0,0 +1,36 @@ +# Copyright 2007 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify @@ -99,13 +99,6 @@ Index: gdb-6.7.50.20080227/gdb/testsuite/gdb.base/fork-detach.exp +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + -+if $tracelevel then { -+ strace $tracelevel -+} -+ -+set prms_id 0 -+set bug_id 0 -+ +set testfile fork-detach +set srcfile ${testfile}.c +set binfile ${objdir}/${subdir}/${testfile} diff --git a/gdb-6.6-gcore32-test.patch b/gdb-6.6-gcore32-test.patch deleted file mode 100644 index 4ebfbeb..0000000 --- a/gdb-6.6-gcore32-test.patch +++ /dev/null @@ -1,216 +0,0 @@ -Test GCORE on 32bit inferiors on 64bit platforms. - -UNSUPPORTED results are valid for `-m64' on 32bit targets. - - -Index: gdb-6.8/gdb/testsuite/gdb.base/gcore.exp -=================================================================== ---- gdb-6.8.orig/gdb/testsuite/gdb.base/gcore.exp 2008-01-01 23:53:19.000000000 +0100 -+++ gdb-6.8/gdb/testsuite/gdb.base/gcore.exp 2008-07-14 10:28:05.000000000 +0200 -@@ -30,9 +30,14 @@ set testfile "gcore" - set srcfile ${testfile}.c - set binfile ${objdir}/${subdir}/${testfile} - --if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } { -- untested gcore.exp -- return -1 -+# `-static-libgcc' to avoid dependency on `libgcc.{i386,ppc}'. -+foreach additional_flags {{} {-m32 -static-libgcc} {-m64 -static-libgcc}} { -+ -+set prefix "arch{$additional_flags}:" -+ -+if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable [list debug additional_flags=$additional_flags]] != "" } { -+ unsupported "${prefix} gcore.exp" -+ continue - } - - # Start with a fresh gdb. -@@ -47,23 +52,23 @@ send_gdb "help gcore\n" - gdb_expect { - -re "Undefined command: .gcore.*$gdb_prompt $" { - # gcore command not supported -- nothing to test here. -- unsupported "gdb does not support gcore on this target" -- return -1; -+ unsupported "${prefix} gdb does not support gcore on this target" -+ continue - } - -re "Save a core file .*$gdb_prompt $" { -- pass "help gcore" -+ pass "${prefix} help gcore" - } - -re ".*$gdb_prompt $" { -- fail "help gcore" -+ fail "${prefix} help gcore" - } - timeout { -- fail "help gcore (timeout)" -+ fail "${prefix} help gcore (timeout)" - } - } - - if { ! [ runto_main ] } then { -- untested gcore.exp -- return -1 -+ untested "${prefix} gcore.exp" -+ continue - } - - proc capture_command_output { command prefix } { -@@ -77,7 +82,7 @@ proc capture_command_output { command pr - set output_string $expect_out(1,string) - } - default { -- fail "capture_command_output failed on $command." -+ fail "${prefix} capture_command_output failed on $command." - } - } - return $output_string -@@ -109,22 +114,22 @@ set escapedfilename [string_to_regexp ${ - - set core_supported 0 - gdb_test_multiple "gcore ${objdir}/${subdir}/gcore.test" \ -- "save a corefile" \ -+ "${prefix} save a corefile" \ - { - -re "Saved corefile ${escapedfilename}\[\r\n\]+$gdb_prompt $" { -- pass "save a corefile" -+ pass "${prefix} save a corefile" - global core_supported - set core_supported 1 - } - -re "Can't create a corefile\[\r\n\]+$gdb_prompt $" { -- unsupported "save a corefile" -+ unsupported "${prefix} save a corefile" - global core_supported - set core_supported 0 - } - } - - if {!$core_supported} { -- return -1 -+ continue - } - - # Now restart gdb and load the corefile. -@@ -136,31 +141,31 @@ gdb_load ${binfile} - send_gdb "core ${objdir}/${subdir}/gcore.test\n" - gdb_expect { - -re ".* is not a core dump:.*$gdb_prompt $" { -- fail "re-load generated corefile (bad file format)" -+ fail "${prefix} re-load generated corefile (bad file format)" - # No use proceeding from here. -- return; -+ continue - } - -re ".*: No such file or directory.*$gdb_prompt $" { -- fail "re-load generated corefile (file not found)" -+ fail "${prefix} re-load generated corefile (file not found)" - # No use proceeding from here. -- return; -+ continue - } - -re ".*Couldn't find .* registers in core file.*$gdb_prompt $" { -- fail "re-load generated corefile (incomplete note section)" -+ fail "${prefix} re-load generated corefile (incomplete note section)" - } - -re "Core was generated by .*$gdb_prompt $" { -- pass "re-load generated corefile" -+ pass "${prefix} re-load generated corefile" - } - -re ".*$gdb_prompt $" { -- fail "re-load generated corefile" -+ fail "${prefix} re-load generated corefile" - } - timeout { -- fail "re-load generated corefile (timeout)" -+ fail "${prefix} re-load generated corefile (timeout)" - } - } - - send_gdb "where\n" --gdb_expect_list "where in corefile" ".*$gdb_prompt $" { -+gdb_expect_list "${prefix} where in corefile" ".*$gdb_prompt $" { - ".*\[\r\n\]+#0 .* terminal_func \\(\\) at " - ".*\[\r\n\]+#1 .* array_func \\(\\) at " - ".*\[\r\n\]+#2 .* factorial_func \\(value=1\\) at " -@@ -174,61 +179,64 @@ gdb_expect_list "where in corefile" ".*$ - - set post_corefile_regs [capture_command_output "info registers" ""] - if ![string compare $pre_corefile_regs $post_corefile_regs] then { -- pass "corefile restored general registers" -+ pass "${prefix} corefile restored general registers" - } else { -- fail "corefile restored general registers" -+ fail "${prefix} corefile restored general registers" - } - - set post_corefile_allregs [capture_command_output "info all-reg" ""] - if ![string compare $pre_corefile_allregs $post_corefile_allregs] then { -- pass "corefile restored all registers" -+ pass "${prefix} corefile restored all registers" - } else { -- fail "corefile restored all registers" -+ fail "${prefix} corefile restored all registers" - } - - set post_corefile_extern_array \ - [capture_command_output "print extern_array" "$print_prefix"] - if ![string compare $pre_corefile_extern_array $post_corefile_extern_array] { -- pass "corefile restored extern array" -+ pass "${prefix} corefile restored extern array" - } else { -- fail "corefile restored extern array" -+ fail "${prefix} corefile restored extern array" - } - - set post_corefile_static_array \ - [capture_command_output "print static_array" "$print_prefix"] - if ![string compare $pre_corefile_static_array $post_corefile_static_array] { -- pass "corefile restored static array" -+ pass "${prefix} corefile restored static array" - } else { -- fail "corefile restored static array" -+ fail "${prefix} corefile restored static array" - } - - set post_corefile_uninit_array \ - [capture_command_output "print un_initialized_array" "$print_prefix"] - if ![string compare $pre_corefile_uninit_array $post_corefile_uninit_array] { -- pass "corefile restored un-initialized array" -+ pass "${prefix} corefile restored un-initialized array" - } else { -- fail "corefile restored un-initialized array" -+ fail "${prefix} corefile restored un-initialized array" - } - - set post_corefile_heap_string \ - [capture_command_output "print heap_string" "$print_prefix"] - if ![string compare $pre_corefile_heap_string $post_corefile_heap_string] { -- pass "corefile restored heap array" -+ pass "${prefix} corefile restored heap array" - } else { -- fail "corefile restored heap array" -+ fail "${prefix} corefile restored heap array" - } - - set post_corefile_local_array \ - [capture_command_output "print array_func::local_array" "$print_prefix"] - if ![string compare $pre_corefile_local_array $post_corefile_local_array] { -- pass "corefile restored stack array" -+ pass "${prefix} corefile restored stack array" - } else { -- fail "corefile restored stack array" -+ fail "${prefix} corefile restored stack array" - } - - set post_corefile_backtrace [capture_command_output "backtrace" ""] - if ![string compare $pre_corefile_backtrace $post_corefile_backtrace] { -- pass "corefile restored backtrace" -+ pass "${prefix} corefile restored backtrace" - } else { -- fail "corefile restored backtrace" -+ fail "${prefix} corefile restored backtrace" -+} -+ -+# $additional_flags: - } diff --git a/gdb-6.6-scheduler_locking-step-is-default.patch b/gdb-6.6-scheduler_locking-step-is-default.patch index 44e0314..428102c 100644 --- a/gdb-6.6-scheduler_locking-step-is-default.patch +++ b/gdb-6.6-scheduler_locking-step-is-default.patch @@ -1,8 +1,8 @@ -Index: gdb-6.8.50.20090811/gdb/infrun.c +Index: gdb-7.1.90.20100711/gdb/infrun.c =================================================================== ---- gdb-6.8.50.20090811.orig/gdb/infrun.c 2009-08-12 06:56:29.000000000 +0200 -+++ gdb-6.8.50.20090811/gdb/infrun.c 2009-08-12 07:13:08.000000000 +0200 -@@ -1075,7 +1075,7 @@ static const char *scheduler_enums[] = { +--- gdb-7.1.90.20100711.orig/gdb/infrun.c 2010-07-12 10:05:26.000000000 +0200 ++++ gdb-7.1.90.20100711/gdb/infrun.c 2010-07-12 10:58:56.000000000 +0200 +@@ -1491,7 +1491,7 @@ static const char *scheduler_enums[] = { schedlock_step, NULL }; @@ -11,10 +11,10 @@ Index: gdb-6.8.50.20090811/gdb/infrun.c static void show_scheduler_mode (struct ui_file *file, int from_tty, struct cmd_list_element *c, const char *value) -Index: gdb-6.8.50.20090811/gdb/testsuite/gdb.mi/mi-console.exp +Index: gdb-7.1.90.20100711/gdb/testsuite/gdb.mi/mi-console.exp =================================================================== ---- gdb-6.8.50.20090811.orig/gdb/testsuite/gdb.mi/mi-console.exp 2009-08-12 06:56:29.000000000 +0200 -+++ gdb-6.8.50.20090811/gdb/testsuite/gdb.mi/mi-console.exp 2009-08-12 06:58:45.000000000 +0200 +--- gdb-7.1.90.20100711.orig/gdb/testsuite/gdb.mi/mi-console.exp 2010-01-01 08:32:03.000000000 +0100 ++++ gdb-7.1.90.20100711/gdb/testsuite/gdb.mi/mi-console.exp 2010-07-12 10:58:56.000000000 +0200 @@ -47,6 +47,9 @@ if { [gdb_compile "${srcdir}/${subdir}/ mi_run_to_main @@ -25,10 +25,10 @@ Index: gdb-6.8.50.20090811/gdb/testsuite/gdb.mi/mi-console.exp # Next over the hello() call which will produce lots of output mi_gdb_test "220-exec-next" \ "220\\^running(\r\n\\*running,thread-id=\"all\")?" \ -Index: gdb-6.8.50.20090811/gdb/testsuite/gdb.mi/mi2-console.exp +Index: gdb-7.1.90.20100711/gdb/testsuite/gdb.mi/mi2-console.exp =================================================================== ---- gdb-6.8.50.20090811.orig/gdb/testsuite/gdb.mi/mi2-console.exp 2009-08-12 06:56:29.000000000 +0200 -+++ gdb-6.8.50.20090811/gdb/testsuite/gdb.mi/mi2-console.exp 2009-08-12 06:58:45.000000000 +0200 +--- gdb-7.1.90.20100711.orig/gdb/testsuite/gdb.mi/mi2-console.exp 2010-05-26 20:12:13.000000000 +0200 ++++ gdb-7.1.90.20100711/gdb/testsuite/gdb.mi/mi2-console.exp 2010-07-12 10:59:14.000000000 +0200 @@ -47,6 +47,9 @@ if { [gdb_compile "${srcdir}/${subdir}/ mi_run_to_main @@ -37,13 +37,13 @@ Index: gdb-6.8.50.20090811/gdb/testsuite/gdb.mi/mi2-console.exp +mi_gdb_test "210-gdb-set scheduler-locking off" "210\\^done" "set scheduler-locking off" + # Next over the hello() call which will produce lots of output - send_gdb "220-exec-next\n" - gdb_expect { -Index: gdb-6.8.50.20090811/gdb/testsuite/gdb.mi/mi-cli.exp + gdb_test_multiple "220-exec-next" "Started step over hello" { + -re "220\\^running\r\n(\\*running,thread-id=\"all\"\r\n)?$mi_gdb_prompt" { +Index: gdb-7.1.90.20100711/gdb/testsuite/gdb.mi/mi-cli.exp =================================================================== ---- gdb-6.8.50.20090811.orig/gdb/testsuite/gdb.mi/mi-cli.exp 2009-06-09 19:12:42.000000000 +0200 -+++ gdb-6.8.50.20090811/gdb/testsuite/gdb.mi/mi-cli.exp 2009-08-12 07:13:32.000000000 +0200 -@@ -173,7 +173,7 @@ mi_execute_to "exec-continue" "breakpoin +--- gdb-7.1.90.20100711.orig/gdb/testsuite/gdb.mi/mi-cli.exp 2010-01-19 09:00:39.000000000 +0100 ++++ gdb-7.1.90.20100711/gdb/testsuite/gdb.mi/mi-cli.exp 2010-07-12 10:58:56.000000000 +0200 +@@ -176,7 +176,7 @@ mi_execute_to "exec-continue" "breakpoin # Test that the token is output even for CLI commands # Also test that *stopped includes frame information. mi_gdb_test "34 next" \ diff --git a/gdb-6.6-scheduler_locking-step-sw-watchpoints2.patch b/gdb-6.6-scheduler_locking-step-sw-watchpoints2.patch index 5b5917d..0eb8a44 100644 --- a/gdb-6.6-scheduler_locking-step-sw-watchpoints2.patch +++ b/gdb-6.6-scheduler_locking-step-sw-watchpoints2.patch @@ -21,11 +21,11 @@ Port to GDB-6.8pre. -Index: gdb-6.8.50.20090803/gdb/inferior.h +Index: gdb-7.1.90.20100711/gdb/inferior.h =================================================================== ---- gdb-6.8.50.20090803.orig/gdb/inferior.h 2009-06-28 02:20:22.000000000 +0200 -+++ gdb-6.8.50.20090803/gdb/inferior.h 2009-08-03 17:19:56.000000000 +0200 -@@ -181,7 +181,15 @@ extern void reopen_exec_file (void); +--- gdb-7.1.90.20100711.orig/gdb/inferior.h 2010-07-12 10:00:56.000000000 +0200 ++++ gdb-7.1.90.20100711/gdb/inferior.h 2010-07-12 10:04:25.000000000 +0200 +@@ -198,7 +198,15 @@ extern void reopen_exec_file (void); /* The `resume' routine should only be called in special circumstances. Normally, use `proceed', which handles a lot of bookkeeping. */ @@ -42,11 +42,11 @@ Index: gdb-6.8.50.20090803/gdb/inferior.h /* From misc files */ -Index: gdb-6.8.50.20090803/gdb/infrun.c +Index: gdb-7.1.90.20100711/gdb/infrun.c =================================================================== ---- gdb-6.8.50.20090803.orig/gdb/infrun.c 2009-07-31 01:01:27.000000000 +0200 -+++ gdb-6.8.50.20090803/gdb/infrun.c 2009-08-03 21:39:28.000000000 +0200 -@@ -74,7 +74,7 @@ static int follow_fork (void); +--- gdb-7.1.90.20100711.orig/gdb/infrun.c 2010-07-12 10:00:56.000000000 +0200 ++++ gdb-7.1.90.20100711/gdb/infrun.c 2010-07-12 10:05:26.000000000 +0200 +@@ -76,7 +76,7 @@ static int follow_fork (void); static void set_schedlock_func (char *args, int from_tty, struct cmd_list_element *c); @@ -55,7 +55,7 @@ Index: gdb-6.8.50.20090803/gdb/infrun.c static int currently_stepping_or_nexting_callback (struct thread_info *tp, void *data); -@@ -1137,7 +1137,7 @@ maybe_software_singlestep (struct gdbarc +@@ -1549,7 +1549,7 @@ maybe_software_singlestep (struct gdbarc STEP nonzero if we should step (zero to continue instead). SIG is the signal to give the inferior (zero for none). */ void @@ -64,7 +64,7 @@ Index: gdb-6.8.50.20090803/gdb/infrun.c { int should_resume = 1; struct cleanup *old_cleanups = make_cleanup (resume_cleanups, 0); -@@ -1149,10 +1149,12 @@ resume (int step, enum target_signal sig +@@ -1562,10 +1562,12 @@ resume (int step, enum target_signal sig QUIT; if (debug_infrun) @@ -79,9 +79,9 @@ Index: gdb-6.8.50.20090803/gdb/infrun.c + : "RESUME_STEP_NEEDED")), + sig, tp->trap_expected); - /* Some targets (e.g. Solaris x86) have a kernel bug when stepping - over an instruction that causes a page fault without triggering -@@ -1271,9 +1273,10 @@ a command like `return' or `jump' to con + /* Normally, by the time we reach `resume', the breakpoints are either + removed or inserted, as appropriate. The exception is if we're sitting +@@ -1678,9 +1680,10 @@ a command like `return' or `jump' to con individually. */ resume_ptid = inferior_ptid; } @@ -94,16 +94,16 @@ Index: gdb-6.8.50.20090803/gdb/infrun.c { /* User-settable 'scheduler' mode requires solo thread resume. */ resume_ptid = inferior_ptid; -@@ -1474,7 +1477,7 @@ proceed (CORE_ADDR addr, enum target_sig - struct gdbarch *gdbarch; +@@ -1889,7 +1892,7 @@ proceed (CORE_ADDR addr, enum target_sig struct thread_info *tp; CORE_ADDR pc; + struct address_space *aspace; - int oneproc = 0; + enum resume_step resume_step = RESUME_STEP_CONTINUE; /* If we're stopped at a fork/vfork, follow the branch set by the "set follow-fork-mode" command; otherwise, we'll just proceed -@@ -1508,13 +1511,13 @@ proceed (CORE_ADDR addr, enum target_sig +@@ -1924,13 +1927,13 @@ proceed (CORE_ADDR addr, enum target_sig actually be executing the breakpoint insn anyway. We'll be (un-)executing the previous instruction. */ @@ -119,7 +119,7 @@ Index: gdb-6.8.50.20090803/gdb/infrun.c } else { -@@ -1545,13 +1548,13 @@ proceed (CORE_ADDR addr, enum target_sig +@@ -1971,13 +1974,13 @@ proceed (CORE_ADDR addr, enum target_sig is required it returns TRUE and sets the current thread to the old thread. */ if (prepare_to_proceed (step)) @@ -135,7 +135,7 @@ Index: gdb-6.8.50.20090803/gdb/infrun.c { tp->trap_expected = 1; /* If displaced stepping is enabled, we can step over the -@@ -1637,8 +1640,13 @@ proceed (CORE_ADDR addr, enum target_sig +@@ -2064,8 +2067,13 @@ proceed (CORE_ADDR addr, enum target_sig /* Reset to normal state. */ init_infwait_state (); @@ -150,7 +150,7 @@ Index: gdb-6.8.50.20090803/gdb/infrun.c /* Wait for it to stop (if not standalone) and in any case decode why it stopped, and act accordingly. */ -@@ -4171,13 +4179,18 @@ infrun: not switching back to stepped th +@@ -4903,13 +4911,18 @@ infrun: not switching back to stepped th /* Is thread TP in the middle of single-stepping? */ @@ -174,11 +174,11 @@ Index: gdb-6.8.50.20090803/gdb/infrun.c } /* Returns true if any thread *but* the one passed in "data" is in the -Index: gdb-6.8.50.20090803/gdb/linux-nat.c +Index: gdb-7.1.90.20100711/gdb/linux-nat.c =================================================================== ---- gdb-6.8.50.20090803.orig/gdb/linux-nat.c 2009-07-31 17:25:21.000000000 +0200 -+++ gdb-6.8.50.20090803/gdb/linux-nat.c 2009-08-03 21:39:10.000000000 +0200 -@@ -2351,7 +2351,10 @@ count_events_callback (struct lwp_info * +--- gdb-7.1.90.20100711.orig/gdb/linux-nat.c 2010-07-12 10:00:56.000000000 +0200 ++++ gdb-7.1.90.20100711/gdb/linux-nat.c 2010-07-12 10:04:25.000000000 +0200 +@@ -2827,7 +2827,10 @@ count_events_callback (struct lwp_info * static int select_singlestep_lwp_callback (struct lwp_info *lp, void *data) { @@ -190,10 +190,10 @@ Index: gdb-6.8.50.20090803/gdb/linux-nat.c return 1; else return 0; -Index: gdb-6.8.50.20090803/gdb/linux-nat.h +Index: gdb-7.1.90.20100711/gdb/linux-nat.h =================================================================== ---- gdb-6.8.50.20090803.orig/gdb/linux-nat.h 2009-05-18 19:11:25.000000000 +0200 -+++ gdb-6.8.50.20090803/gdb/linux-nat.h 2009-08-03 21:39:09.000000000 +0200 +--- gdb-7.1.90.20100711.orig/gdb/linux-nat.h 2010-06-11 14:10:12.000000000 +0200 ++++ gdb-7.1.90.20100711/gdb/linux-nat.h 2010-07-12 10:04:25.000000000 +0200 @@ -55,8 +55,8 @@ struct lwp_info /* If non-zero, a pending wait status. */ int status; diff --git a/gdb-6.6-threads-static-test.patch b/gdb-6.6-threads-static-test.patch index e8741a8..2bac722 100644 --- a/gdb-6.6-threads-static-test.patch +++ b/gdb-6.6-threads-static-test.patch @@ -1,10 +1,11 @@ ---- gdb-6.6/gdb/testsuite/gdb.threads/staticthreads.exp-orig 2005-04-30 21:56:47.000000000 +0200 -+++ gdb-6.6/gdb/testsuite/gdb.threads/staticthreads.exp 2008-01-11 14:30:15.000000000 +0100 -@@ -44,9 +44,21 @@ gdb_load ${binfile} - gdb_test "set print sevenbit-strings" "" - +Index: gdb-7.1.90.20100711/gdb/testsuite/gdb.threads/staticthreads.exp +=================================================================== +--- gdb-7.1.90.20100711.orig/gdb/testsuite/gdb.threads/staticthreads.exp 2010-06-02 23:53:28.000000000 +0200 ++++ gdb-7.1.90.20100711/gdb/testsuite/gdb.threads/staticthreads.exp 2010-07-12 11:43:26.000000000 +0200 +@@ -44,6 +44,18 @@ gdb_test_no_output "set print sevenbit-s + # See if the static multi-threaded program runs. -+runto_main + runto_main + +# See if we get excessive LWP there (patched glibc with unpatched GDB): +# * 2 Thread 135661664 (LWP 3856) main () at threadloop.c:41 @@ -17,9 +18,6 @@ + } +} + - # See if the static multi-threaded program runs. - --runto_main gdb_test "break sem_post" set test "Continue to main's call of sem_post" gdb_test_multiple "continue" "$test" { diff --git a/gdb-6.7-bz426600-DW_TAG_interface_type-test.patch b/gdb-6.7-bz426600-DW_TAG_interface_type-test.patch index 2e344ca..9dc8a7b 100644 --- a/gdb-6.7-bz426600-DW_TAG_interface_type-test.patch +++ b/gdb-6.7-bz426600-DW_TAG_interface_type-test.patch @@ -641,7 +641,7 @@ http://sourceware.org/ml/gdb-patches/2007-12/msg00397.html + .section .note.GNU-stack,"",@progbits --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ ./gdb/testsuite/gdb.arch/i386-interface.exp 22 Dec 2007 19:07:28 -0000 -@@ -0,0 +1,66 @@ +@@ -0,0 +1,59 @@ +# Copyright 2007 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify @@ -665,13 +665,6 @@ http://sourceware.org/ml/gdb-patches/2007-12/msg00397.html +# Test basis recognization of DW_TAG_interface_type. +# GCC java_classify_record() produces it if returns RECORD_IS_INTERFACE. + -+if $tracelevel { -+ strace $tracelevel -+} -+ -+set prms_id 0 -+set bug_id 0 -+ +if {![istarget "i?86-*-*"] && ![istarget "x86_64-*-*"]} then { + verbose "Skipping i386 Java DW_TAG_interface_type test." + return diff --git a/gdb-6.7-charsign-test.patch b/gdb-6.7-charsign-test.patch index 2e289ac..793ff8a 100644 --- a/gdb-6.7-charsign-test.patch +++ b/gdb-6.7-charsign-test.patch @@ -52,7 +52,7 @@ https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=224128 +char_u u_typed[]="A"; --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ ./gdb/testsuite/gdb.base/charsign.exp 26 Jan 2007 10:32:00 -0000 -@@ -0,0 +1,70 @@ +@@ -0,0 +1,63 @@ +# Copyright 2007 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify @@ -69,13 +69,6 @@ https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=224128 +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + -+if $tracelevel then { -+ strace $tracelevel -+} -+ -+set prms_id 0 -+set bug_id 0 -+ +set testfile charsign +set srcfile ${testfile}.c +set binfile ${objdir}/${subdir}/${testfile} diff --git a/gdb-6.7-ppc-clobbered-registers-O2-test.patch b/gdb-6.7-ppc-clobbered-registers-O2-test.patch index b8ba5b0..761d10f 100644 --- a/gdb-6.7-ppc-clobbered-registers-O2-test.patch +++ b/gdb-6.7-ppc-clobbered-registers-O2-test.patch @@ -39,7 +39,7 @@ http://sourceware.org/ml/gdb-patches/2007-09/msg00228.html +} --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ ./gdb/testsuite/gdb.arch/ppc-clobbered-registers-O2.exp 3 Nov 2007 22:22:28 -0000 -@@ -0,0 +1,61 @@ +@@ -0,0 +1,54 @@ +# Copyright 2006 Free Software Foundation, Inc. +# +# This program is free software; you can redistribute it and/or modify @@ -58,16 +58,9 @@ http://sourceware.org/ml/gdb-patches/2007-09/msg00228.html +# +# This file is part of the gdb testsuite. + -+if $tracelevel { -+ strace $tracelevel -+} -+ +# Test displaying call clobbered registers in optimized binaries for ppc. +# GDB should not show incorrect values. + -+set prms_id 0 -+set bug_id 0 -+ +if ![istarget "powerpc*-*"] then { + verbose "Skipping powerpc* call clobbered registers testing." + return diff --git a/gdb-6.7-testsuite-stable-results.patch b/gdb-6.7-testsuite-stable-results.patch index 75f68b3..a4c195c 100644 --- a/gdb-6.7-testsuite-stable-results.patch +++ b/gdb-6.7-testsuite-stable-results.patch @@ -20,8 +20,10 @@ random FAIL: gdb.base/auxv.exp: matching auxv data from live and gcore gdb-6.8.50.20090209/gdb/testsuite/gdb.base/annota1.exp: frames-invalid can happen asynchronously. ---- ./gdb/testsuite/gdb.base/fileio.c 13 Jun 2006 08:55:22 -0000 1.10 -+++ ./gdb/testsuite/gdb.base/fileio.c 8 Dec 2007 16:04:10 -0000 +Index: gdb-7.1.90.20100711/gdb/testsuite/gdb.base/fileio.c +=================================================================== +--- gdb-7.1.90.20100711.orig/gdb/testsuite/gdb.base/fileio.c 2009-10-01 17:39:13.000000000 +0200 ++++ gdb-7.1.90.20100711/gdb/testsuite/gdb.base/fileio.c 2010-07-12 11:41:43.000000000 +0200 @@ -58,6 +58,8 @@ system (const char * string); 1) Invalid string/command. - returns 127. */ static const char *strerrno (int err); @@ -69,9 +71,11 @@ frames-invalid can happen asynchronously. /* Don't change the order of the calls. They partly depend on each other */ test_open (); test_write (); ---- ./gdb/testsuite/gdb.base/fileio.exp 23 Aug 2007 18:14:16 -0000 1.12 -+++ ./gdb/testsuite/gdb.base/fileio.exp 8 Dec 2007 16:04:10 -0000 -@@ -46,8 +46,8 @@ if [get_compiler_info ${binfile}] { +Index: gdb-7.1.90.20100711/gdb/testsuite/gdb.base/fileio.exp +=================================================================== +--- gdb-7.1.90.20100711.orig/gdb/testsuite/gdb.base/fileio.exp 2010-06-09 00:58:03.000000000 +0200 ++++ gdb-7.1.90.20100711/gdb/testsuite/gdb.base/fileio.exp 2010-07-12 11:42:07.000000000 +0200 +@@ -42,8 +42,8 @@ if [get_compiler_info ${binfile}] { return -1; } @@ -82,16 +86,16 @@ frames-invalid can happen asynchronously. set oldtimeout $timeout set timeout [expr "$timeout + 60"] -@@ -88,7 +88,7 @@ gdb_test continue \ - "Opening nonexistant file returns ENOENT" +@@ -85,7 +85,7 @@ gdb_test continue \ + + gdb_test "continue" ".*" "" - send_gdb "continue\n" ; gdb_expect -re "$gdb_prompt $" -catch "system \"chmod -f -w nowrt.fileio.test\"" +catch "system \"chmod -f -w fileio.dir/nowrt.fileio.test\"" gdb_test continue \ "Continuing\\..*open 5:.*EACCES$stop_msg" \ -@@ -252,8 +252,8 @@ gdb_test continue \ +@@ -250,8 +250,8 @@ gdb_test continue \ send_gdb "quit\n" send_gdb "y\n" diff --git a/gdb-6.8-attach-signalled-detach-stopped.patch b/gdb-6.8-attach-signalled-detach-stopped.patch index 4c462e1..a518122 100644 --- a/gdb-6.8-attach-signalled-detach-stopped.patch +++ b/gdb-6.8-attach-signalled-detach-stopped.patch @@ -1,8 +1,8 @@ -Index: gdb-6.8.50.20090803/gdb/linux-nat.c +Index: gdb-7.0.50.20100115/gdb/linux-nat.c =================================================================== ---- gdb-6.8.50.20090803.orig/gdb/linux-nat.c 2009-08-03 17:24:03.000000000 +0200 -+++ gdb-6.8.50.20090803/gdb/linux-nat.c 2009-08-03 17:27:23.000000000 +0200 -@@ -202,6 +202,9 @@ blocked. */ +--- gdb-7.0.50.20100115.orig/gdb/linux-nat.c 2010-01-15 11:53:34.000000000 +0100 ++++ gdb-7.0.50.20100115/gdb/linux-nat.c 2010-01-15 12:13:53.000000000 +0100 +@@ -208,6 +208,9 @@ blocked. */ static struct target_ops *linux_ops; static struct target_ops linux_ops_saved; @@ -12,8 +12,8 @@ Index: gdb-6.8.50.20090803/gdb/linux-nat.c /* The method to call, if any, when a new thread is attached. */ static void (*linux_nat_new_thread) (ptid_t); -@@ -790,7 +793,14 @@ linux_child_follow_fork (struct target_o - linux_parent_pid = parent_pid; +@@ -933,7 +936,14 @@ Attaching after process %d fork to child + parent_inf->waiting_for_vfork_done = 0; } else if (detach_fork) - target_detach (NULL, 0); @@ -26,9 +26,9 @@ Index: gdb-6.8.50.20090803/gdb/linux-nat.c + target_detach (NULL, 0); + } - inferior_ptid = ptid_build (child_pid, child_pid, 0); - add_thread (inferior_ptid); -@@ -1231,6 +1241,7 @@ linux_nat_post_attach_wait (ptid_t ptid, + /* Note that the detach above makes PARENT_INF dangling. */ + +@@ -1427,6 +1437,7 @@ linux_nat_post_attach_wait (ptid_t ptid, if (debug_linux_nat) fprintf_unfiltered (gdb_stdlog, "LNPAW: Attaching to a stopped process\n"); @@ -36,8 +36,8 @@ Index: gdb-6.8.50.20090803/gdb/linux-nat.c /* The process is definitely stopped. It is in a job control stop, unless the kernel predates the TASK_STOPPED / -@@ -1512,6 +1523,9 @@ GPT: lwp %s had signal %s, but it is in - *status = lp->status; +@@ -1757,6 +1768,9 @@ GPT: lwp %s had signal %s, but it is in + target_signal_to_string (signo)); } + if (*status == 0 && GET_PID (lp->ptid) == pid_was_stopped) @@ -46,7 +46,7 @@ Index: gdb-6.8.50.20090803/gdb/linux-nat.c return 0; } -@@ -1621,6 +1635,8 @@ linux_nat_detach (struct target_ops *ops +@@ -1866,6 +1880,8 @@ linux_nat_detach (struct target_ops *ops } else linux_ops->to_detach (ops, args, from_tty); @@ -55,7 +55,7 @@ Index: gdb-6.8.50.20090803/gdb/linux-nat.c } /* Resume LP. */ -@@ -1774,6 +1790,14 @@ linux_nat_resume (struct target_ops *ops +@@ -2031,6 +2047,14 @@ linux_nat_resume (struct target_ops *ops resume_callback. */ lp->stopped = 0; @@ -70,7 +70,7 @@ Index: gdb-6.8.50.20090803/gdb/linux-nat.c if (resume_many) iterate_over_lwps (ptid, resume_callback, NULL); -@@ -3322,6 +3346,8 @@ linux_nat_mourn_inferior (struct target_ +@@ -3923,6 +3947,8 @@ linux_nat_mourn_inferior (struct target_ there are other viable forks to debug. Delete the exiting one and context-switch to the first available. */ linux_fork_mourn_inferior (); @@ -79,10 +79,10 @@ Index: gdb-6.8.50.20090803/gdb/linux-nat.c } /* Convert a native/host siginfo object, into/from the siginfo in the -Index: gdb-6.8.50.20090803/gdb/testsuite/gdb.threads/attach-stopped.exp +Index: gdb-7.0.50.20100115/gdb/testsuite/gdb.threads/attach-stopped.exp =================================================================== ---- gdb-6.8.50.20090803.orig/gdb/testsuite/gdb.threads/attach-stopped.exp 2009-01-03 06:58:07.000000000 +0100 -+++ gdb-6.8.50.20090803/gdb/testsuite/gdb.threads/attach-stopped.exp 2009-08-03 17:26:22.000000000 +0200 +--- gdb-7.0.50.20100115.orig/gdb/testsuite/gdb.threads/attach-stopped.exp 2010-01-01 08:32:06.000000000 +0100 ++++ gdb-7.0.50.20100115/gdb/testsuite/gdb.threads/attach-stopped.exp 2010-01-15 11:54:57.000000000 +0100 @@ -62,7 +62,65 @@ proc corefunc { threadtype } { gdb_reinitialize_dir $srcdir/$subdir gdb_load ${binfile} @@ -150,10 +150,10 @@ Index: gdb-6.8.50.20090803/gdb/testsuite/gdb.threads/attach-stopped.exp set test "$threadtype: attach2 to stopped, after setting file" gdb_test_multiple "attach $testpid" "$test" { -Index: gdb-6.8.50.20090803/gdb/testsuite/gdb.threads/attachstop-mt.exp +Index: gdb-7.0.50.20100115/gdb/testsuite/gdb.threads/attachstop-mt.exp =================================================================== ---- gdb-6.8.50.20090803.orig/gdb/testsuite/gdb.threads/attachstop-mt.exp 2009-01-03 06:58:07.000000000 +0100 -+++ gdb-6.8.50.20090803/gdb/testsuite/gdb.threads/attachstop-mt.exp 2009-08-03 17:26:22.000000000 +0200 +--- gdb-7.0.50.20100115.orig/gdb/testsuite/gdb.threads/attachstop-mt.exp 2010-01-01 08:32:06.000000000 +0100 ++++ gdb-7.0.50.20100115/gdb/testsuite/gdb.threads/attachstop-mt.exp 2010-01-15 11:54:57.000000000 +0100 @@ -176,12 +176,23 @@ gdb_test "bt" ".*sleep.*(func|main).*" " # Exit and detach the process. gdb_exit diff --git a/gdb-6.8-bz254229-gcore-prpsinfo.patch b/gdb-6.8-bz254229-gcore-prpsinfo.patch index 82e64f9..87fd255 100644 --- a/gdb-6.8-bz254229-gcore-prpsinfo.patch +++ b/gdb-6.8-bz254229-gcore-prpsinfo.patch @@ -1,137 +1,118 @@ -Index: gdb-6.8.50.20090910/bfd/elf-bfd.h +Index: gdb-7.1.90.20100711/bfd/elf-bfd.h =================================================================== ---- gdb-6.8.50.20090910.orig/bfd/elf-bfd.h 2009-09-09 23:38:57.000000000 +0200 -+++ gdb-6.8.50.20090910/bfd/elf-bfd.h 2009-09-10 23:01:15.000000000 +0200 -@@ -2121,7 +2121,7 @@ extern Elf_Internal_Phdr * _bfd_elf_find +--- gdb-7.1.90.20100711.orig/bfd/elf-bfd.h 2010-06-27 06:07:51.000000000 +0200 ++++ gdb-7.1.90.20100711/bfd/elf-bfd.h 2010-07-12 23:00:04.000000000 +0200 +@@ -2171,8 +2171,9 @@ extern Elf_Internal_Phdr * _bfd_elf_find + /* Exported interface for writing elf corefile notes. */ extern char *elfcore_write_note (bfd *, char *, int *, const char *, int, const void *, int); ++#include extern char *elfcore_write_prpsinfo - (bfd *, char *, int *, const char *, const char *); -+ (bfd *, char *, int *, void *, const char *, const char *); ++ (bfd *, char *, int *, const prpsinfo_t *); extern char *elfcore_write_prstatus (bfd *, char *, int *, long, int, const void *); extern char * elfcore_write_pstatus -Index: gdb-6.8.50.20090910/bfd/elf.c +Index: gdb-7.1.90.20100711/bfd/elf.c =================================================================== ---- gdb-6.8.50.20090910.orig/bfd/elf.c 2009-09-09 23:38:57.000000000 +0200 -+++ gdb-6.8.50.20090910/bfd/elf.c 2009-09-10 23:04:17.000000000 +0200 -@@ -8398,6 +8398,7 @@ char * +--- gdb-7.1.90.20100711.orig/bfd/elf.c 2010-05-18 05:31:05.000000000 +0200 ++++ gdb-7.1.90.20100711/bfd/elf.c 2010-07-12 22:51:17.000000000 +0200 +@@ -8582,13 +8582,12 @@ elfcore_write_note (bfd *abfd, + return buf; + } + +-#if defined (HAVE_PRPSINFO_T) || defined (HAVE_PSINFO_T) ++#if defined (HAVE_PRPSINFO_T) + char * elfcore_write_prpsinfo (bfd *abfd, char *buf, int *bufsiz, -+ void *info, - const char *fname, - const char *psargs) +- const char *fname, +- const char *psargs) ++ const prpsinfo_t *input) { -@@ -8424,9 +8425,15 @@ elfcore_write_prpsinfo (bfd *abfd, - int note_type = NT_PRPSINFO; - #endif - -- memset (&data, 0, sizeof (data)); -- strncpy (data.pr_fname, fname, sizeof (data.pr_fname)); -- strncpy (data.pr_psargs, psargs, sizeof (data.pr_psargs)); -+ if (info) -+ memcpy (&data, info, sizeof (data)); -+ else -+ { -+ memset (&data, 0, sizeof (data)); -+ strncpy (data.pr_fname, fname, sizeof (data.pr_fname)); -+ strncpy (data.pr_psargs, psargs, sizeof (data.pr_psargs)); -+ } + const char *note_name = "CORE"; + const struct elf_backend_data *bed = get_elf_backend_data (abfd); +@@ -8596,48 +8595,55 @@ elfcore_write_prpsinfo (bfd *abfd, + if (bed->elf_backend_write_core_note != NULL) + { + char *ret; ++ char fname[sizeof (input->pr_fname) + 1]; ++ char psargs[sizeof (input->pr_psargs) + 1]; + - return elfcore_write_note (abfd, buf, bufsiz, - note_name, note_type, &data, sizeof (data)); ++ strncpy (fname, input->pr_fname, sizeof (input->pr_fname)); ++ fname[sizeof (input->pr_fname)] = 0; ++ strncpy (psargs, input->pr_psargs, sizeof (input->pr_psargs)); ++ psargs[sizeof (input->pr_psargs)] = 0; ++ + ret = (*bed->elf_backend_write_core_note) (abfd, buf, bufsiz, + NT_PRPSINFO, fname, psargs); + if (ret != NULL) + return ret; } -@@ -8441,9 +8448,15 @@ elfcore_write_prpsinfo (bfd *abfd, + +-#if defined (HAVE_PRPSINFO32_T) || defined (HAVE_PSINFO32_T) ++#if defined (HAVE_PRPSINFO32_T) + if (bed->s->elfclass == ELFCLASS32) + { +-#if defined (HAVE_PSINFO32_T) +- psinfo32_t data; +- int note_type = NT_PSINFO; +-#else + prpsinfo32_t data; int note_type = NT_PRPSINFO; - #endif +-#endif -- memset (&data, 0, sizeof (data)); + memset (&data, 0, sizeof (data)); - strncpy (data.pr_fname, fname, sizeof (data.pr_fname)); - strncpy (data.pr_psargs, psargs, sizeof (data.pr_psargs)); -+ if (info) -+ memcpy (&data, info, sizeof (data)); -+ else -+ { -+ memset (&data, 0, sizeof (data)); -+ strncpy (data.pr_fname, fname, sizeof (data.pr_fname)); -+ strncpy (data.pr_psargs, psargs, sizeof (data.pr_psargs)); -+ } -+ ++ data.pr_state = input->pr_state; ++ data.pr_sname = input->pr_sname; ++ data.pr_zomb = input->pr_zomb; ++ data.pr_nice = input->pr_nice; ++ data.pr_flag = input->pr_flag; ++ data.pr_uid = input->pr_uid; ++ data.pr_gid = input->pr_gid; ++ data.pr_pid = input->pr_pid; ++ data.pr_ppid = input->pr_ppid; ++ data.pr_pgrp = input->pr_pgrp; ++ data.pr_sid = input->pr_sid; ++ BFD_ASSERT (sizeof (data.pr_fname) == sizeof (input->pr_fname)); ++ memcpy (data.pr_fname, input->pr_fname, sizeof (data.pr_fname)); ++ BFD_ASSERT (sizeof (data.pr_psargs) == sizeof (input->pr_psargs)); ++ memcpy (data.pr_psargs, input->pr_psargs, sizeof (data.pr_psargs)); return elfcore_write_note (abfd, buf, bufsiz, note_name, note_type, &data, sizeof (data)); } -Index: gdb-6.8.50.20090910/gdb/amd64-linux-nat.c -=================================================================== ---- gdb-6.8.50.20090910.orig/gdb/amd64-linux-nat.c 2009-09-10 23:01:07.000000000 +0200 -+++ gdb-6.8.50.20090910/gdb/amd64-linux-nat.c 2009-09-10 23:01:15.000000000 +0200 -@@ -140,6 +140,7 @@ static int amd64_linux_gregset32_reg_off - - static char * - amd64_linux_elfcore_write_prpsinfo (bfd *abfd, char *buf, int *bufsiz, -+ void *info, - const char *fname, const char *psargs) - { - if (gdbarch_ptr_bit (target_gdbarch) == 32) -@@ -149,14 +150,20 @@ amd64_linux_elfcore_write_prpsinfo (bfd - struct elf_prpsinfo32 data; - note_type = NT_PRPSINFO; + else + #endif + { +-#if defined (HAVE_PSINFO_T) +- psinfo_t data; +- int note_type = NT_PSINFO; +-#else +- prpsinfo_t data; + int note_type = NT_PRPSINFO; +-#endif - memset (&data, 0, sizeof (data)); - strncpy (data.pr_fname, fname, sizeof (data.pr_fname)); - strncpy (data.pr_psargs, psargs, sizeof (data.pr_psargs)); -+ if (info) -+ memcpy (&data, info, sizeof (data)); -+ else -+ { -+ memset (&data, 0, sizeof (data)); -+ strncpy (data.pr_fname, fname, sizeof (data.pr_fname)); -+ strncpy (data.pr_psargs, psargs, sizeof (data.pr_psargs)); -+ } -+ return elfcore_write_note (abfd, buf, bufsiz, - note_name, note_type, &data, sizeof (data)); +- note_name, note_type, &data, sizeof (data)); ++ note_name, note_type, input, sizeof (*input)); } - else -- return elfcore_write_prpsinfo (abfd, buf, bufsiz, fname, psargs); -+ return elfcore_write_prpsinfo (abfd, buf, bufsiz, info, fname, psargs); } +-#endif /* PSINFO_T or PRPSINFO_T */ ++#endif /* PRPSINFO_T */ - static void -Index: gdb-6.8.50.20090910/gdb/fbsd-nat.c -=================================================================== ---- gdb-6.8.50.20090910.orig/gdb/fbsd-nat.c 2009-07-02 19:21:06.000000000 +0200 -+++ gdb-6.8.50.20090910/gdb/fbsd-nat.c 2009-09-10 23:01:15.000000000 +0200 -@@ -211,6 +211,7 @@ fbsd_make_corefile_notes (bfd *obfd, int - psargs = reconcat (psargs, psargs, " ", get_inferior_args (), NULL); - - note_data = elfcore_write_prpsinfo (obfd, note_data, note_size, -+ NULL, - fname, psargs); - } - -Index: gdb-6.8.50.20090910/gdb/linux-nat.c + #if defined (HAVE_PRSTATUS_T) + char * +Index: gdb-7.1.90.20100711/gdb/linux-nat.c =================================================================== ---- gdb-6.8.50.20090910.orig/gdb/linux-nat.c 2009-09-10 23:01:06.000000000 +0200 -+++ gdb-6.8.50.20090910/gdb/linux-nat.c 2009-09-10 23:01:15.000000000 +0200 -@@ -55,6 +55,7 @@ - #include "xml-support.h" - #include "terminal.h" - #include -+#include "gdb_procfs32.h" /* for struct elf_prpsinfo32 */ - - #ifndef SPUFS_MAGIC - #define SPUFS_MAGIC 0x23c9b64e -@@ -222,7 +223,7 @@ static LONGEST (*super_xfer_partial) (st - /* This functions make elfcore note sections. - They may get overriden by code adjusting data for multi-target builds. */ - char *(*linux_elfcore_write_prpsinfo) -- (bfd *, char *, int *, const char *, const char *) = elfcore_write_prpsinfo; -+ (bfd *, char *, int *, void *, const char *, const char *) = elfcore_write_prpsinfo; - char *(*linux_elfcore_write_prstatus) - (bfd *, char *, int *, long, int, const void *) = elfcore_write_prstatus; - static char * -@@ -3946,6 +3947,159 @@ linux_spu_make_corefile_notes (bfd *obfd +--- gdb-7.1.90.20100711.orig/gdb/linux-nat.c 2010-07-12 23:05:22.000000000 +0200 ++++ gdb-7.1.90.20100711/gdb/linux-nat.c 2010-07-12 22:57:34.000000000 +0200 +@@ -4466,6 +4466,131 @@ linux_spu_make_corefile_notes (bfd *obfd return args.note_data; } @@ -144,7 +125,7 @@ Index: gdb-6.8.50.20090910/gdb/linux-nat.c + binfmt_elf.c. Unknown values are filled with zeroes. The structure is + malloced. */ + -+static void* ++static const prpsinfo_t * +fill_prpsinfo (void) +{ + struct stat sb; @@ -164,6 +145,7 @@ Index: gdb-6.8.50.20090910/gdb/linux-nat.c + obsolete there to TASK_* constants. */ + const char state_string[] = "RSDTZW"; + int state_num; ++ static prpsinfo_t retval; + + /* Get /proc/$PID/stat. */ + pid = ptid_get_pid (inferior_ptid); @@ -240,108 +222,63 @@ Index: gdb-6.8.50.20090910/gdb/linux-nat.c + state_num = 0; + } + -+#if ULONG_MAX > 0xffffffffU -+ /* We skip this code on 32-bit gdb. */ -+ if (gdbarch_ptr_bit (target_gdbarch) == 64) -+ { -+ struct elf_prpsinfo *info = xzalloc (sizeof (*info)); -+ -+ info->pr_state = state_num; -+ info->pr_sname = proc_state[0]; -+ info->pr_zomb = (proc_state[0] == 'Z'); -+ info->pr_nice = proc_nice; -+ info->pr_flag = flags; -+ info->pr_uid = sb.st_uid; -+ info->pr_gid = sb.st_gid; -+ info->pr_pid = pid; -+ info->pr_ppid = proc_ppid; -+ info->pr_pgrp = proc_pgid; -+ info->pr_sid = proc_sid; -+ strncpy (info->pr_fname, proc_comm, sizeof (info->pr_fname)); -+ strncpy (info->pr_psargs, proc_cmdline, sizeof (info->pr_psargs)); ++ memset (&retval, 0, sizeof (retval)); ++ retval.pr_state = state_num; ++ retval.pr_sname = proc_state[0]; ++ retval.pr_zomb = (proc_state[0] == 'Z'); ++ retval.pr_nice = proc_nice; ++ retval.pr_flag = flags; ++ retval.pr_uid = sb.st_uid; ++ retval.pr_gid = sb.st_gid; ++ retval.pr_pid = pid; ++ retval.pr_ppid = proc_ppid; ++ retval.pr_pgrp = proc_pgid; ++ retval.pr_sid = proc_sid; ++ strncpy (retval.pr_fname, proc_comm, sizeof (retval.pr_fname)); ++ strncpy (retval.pr_psargs, proc_cmdline, sizeof (retval.pr_psargs)); + -+ return info; -+ } -+#endif -+ if (gdbarch_ptr_bit (target_gdbarch) == 32) -+ { -+ struct elf_prpsinfo32 *info = xzalloc (sizeof (*info)); -+ -+ info->pr_state = state_num; -+ info->pr_sname = proc_state[0]; -+ info->pr_zomb = (proc_state[0] == 'Z'); -+ info->pr_nice = proc_nice; -+ info->pr_flag = flags; -+ info->pr_uid = sb.st_uid; -+ info->pr_gid = sb.st_gid; -+ info->pr_pid = pid; -+ info->pr_ppid = proc_ppid; -+ info->pr_pgrp = proc_pgid; -+ info->pr_sid = proc_sid; -+ strncpy (info->pr_fname, proc_comm, sizeof (info->pr_fname)); -+ strncpy (info->pr_psargs, proc_cmdline, sizeof (info->pr_psargs)); -+ -+ return info; -+ } -+ -+ return NULL; ++ return &retval; +} +#endif + /* Fills the "to_make_corefile_note" target vector. Builds the note section for a corefile, and returns it in a malloc buffer. */ -@@ -3966,8 +4120,14 @@ linux_nat_make_corefile_notes (bfd *obfd +@@ -4484,26 +4609,11 @@ linux_nat_make_corefile_notes (bfd *obfd if (get_exec_file (0)) { -+#if defined (HAVE_PRPSINFO_T) -+ void *data = fill_prpsinfo (); -+#define DATAPTR data -+#else -+#define DATAPTR NULL - strncpy (fname, strrchr (get_exec_file (0), '/') + 1, sizeof (fname)); - strncpy (psargs, get_exec_file (0), sizeof (psargs)); -+#endif - if (get_inferior_args ()) - { - char *string_end; -@@ -3983,9 +4143,15 @@ linux_nat_make_corefile_notes (bfd *obfd - psargs_end - string_end); - } - } -- note_data = (char *) linux_elfcore_write_prpsinfo (obfd, note_data, -- note_size, fname, -+ note_data = (char *) linux_elfcore_write_prpsinfo (obfd, -+ note_data, note_size, -+ DATAPTR, -+ fname, - psargs); -+#if defined (HAVE_PRPSINFO_T) -+ xfree (DATAPTR); -+#endif -+#undef DATAPTR +- strncpy (fname, strrchr (get_exec_file (0), '/') + 1, sizeof (fname)); +- strncpy (psargs, get_exec_file (0), sizeof (psargs)); +- if (get_inferior_args ()) +- { +- char *string_end; +- char *psargs_end = psargs + sizeof (psargs); +- +- /* linux_elfcore_write_prpsinfo () handles zero unterminated +- strings fine. */ +- string_end = memchr (psargs, 0, sizeof (psargs)); +- if (string_end != NULL) +- { +- *string_end++ = ' '; +- strncpy (string_end, get_inferior_args (), +- psargs_end - string_end); +- } +- } ++ const prpsinfo_t *data = fill_prpsinfo (); ++ + note_data = (char *) elfcore_write_prpsinfo (obfd, + note_data, +- note_size, fname, psargs); ++ note_size, data); } /* Dump information for threads. */ -Index: gdb-6.8.50.20090910/gdb/linux-nat.h -=================================================================== ---- gdb-6.8.50.20090910.orig/gdb/linux-nat.h 2009-09-10 23:01:06.000000000 +0200 -+++ gdb-6.8.50.20090910/gdb/linux-nat.h 2009-09-10 23:01:15.000000000 +0200 -@@ -154,7 +154,7 @@ struct siginfo *linux_nat_get_siginfo (p - /* These functions make elfcore note sections. - They may get overriden by code adjusting data for multi-target builds. */ - extern char *(*linux_elfcore_write_prpsinfo) -- (bfd *, char *, int *, const char *, const char *); -+ (bfd *, char *, int *, void *, const char *, const char *); - extern char *(*linux_elfcore_write_prstatus) - (bfd *, char *, int *, long, int, const void *); - extern char *(*linux_elfcore_write_prfpreg) -Index: gdb-6.8.50.20090910/gdb/procfs.c +Index: gdb-7.1.90.20100711/gdb/procfs.c =================================================================== ---- gdb-6.8.50.20090910.orig/gdb/procfs.c 2009-08-01 02:02:04.000000000 +0200 -+++ gdb-6.8.50.20090910/gdb/procfs.c 2009-09-10 23:01:15.000000000 +0200 -@@ -6147,6 +6147,7 @@ procfs_make_note_section (bfd *obfd, int +--- gdb-7.1.90.20100711.orig/gdb/procfs.c 2010-07-07 18:15:16.000000000 +0200 ++++ gdb-7.1.90.20100711/gdb/procfs.c 2010-07-12 23:05:23.000000000 +0200 +@@ -5770,6 +5770,7 @@ procfs_make_note_section (bfd *obfd, int note_data = (char *) elfcore_write_prpsinfo (obfd, note_data, note_size, diff --git a/gdb-6.8-bz457187-largefile-test.patch b/gdb-6.8-bz457187-largefile-test.patch index 86f8fdf..d2d6cf8 100644 --- a/gdb-6.8-bz457187-largefile-test.patch +++ b/gdb-6.8-bz457187-largefile-test.patch @@ -61,7 +61,7 @@ +# "\r\nCore was generated by `\[^\r\n\]*'\\.\r\nProgram terminated with signal 11, Segmentation fault\\.\r\n.*" +gdb_test "core-file ${corefile}" + -+gdb_test "x/i $address" "\r\n$address:\[ \t\]*hlt\[ \t\]*" ".text is readable" ++gdb_test "x/i $address" "\r\n\[ \t\]*$address:\[ \t\]*hlt\[ \t\]*" ".text is readable" --- /dev/null 2009-04-19 14:49:00.974648389 +0200 +++ gdb-6.8/gdb/testsuite/gdb.arch/i386-biarch-core.S 2009-04-19 14:52:28.000000000 +0200 @@ -0,0 +1,22 @@ diff --git a/gdb-6.8-bz457187-largefile.patch b/gdb-6.8-bz457187-largefile.patch deleted file mode 100644 index 199d7a2..0000000 --- a/gdb-6.8-bz457187-largefile.patch +++ /dev/null @@ -1,265 +0,0 @@ -gdb/ -2009-03-02 Jan Kratochvil - - * configure.ac: Call AC_SYS_LARGEFILE. - * config.in: Regenerate. - * configure: Regenerate. - -Index: gdb-6.8.50.20090909/gdb/configure.ac -=================================================================== ---- gdb-6.8.50.20090909.orig/gdb/configure.ac 2009-09-09 20:08:04.000000000 +0200 -+++ gdb-6.8.50.20090909/gdb/configure.ac 2009-09-09 20:11:04.000000000 +0200 -@@ -28,6 +28,7 @@ AM_MAINTAINER_MODE - AC_PROG_CC - AC_USE_SYSTEM_EXTENSIONS - gl_EARLY -+AC_SYS_LARGEFILE - AM_PROG_CC_STDC - - AC_CONFIG_AUX_DIR(..) -Index: gdb-6.8.50.20090909/gdb/config.in -=================================================================== ---- gdb-6.8.50.20090909.orig/gdb/config.in 2009-09-09 20:08:04.000000000 +0200 -+++ gdb-6.8.50.20090909/gdb/config.in 2009-09-09 20:11:33.000000000 +0200 -@@ -751,10 +751,16 @@ - # endif - #endif - -+/* Number of bits in a file offset, on hosts where this is settable. */ -+#undef _FILE_OFFSET_BITS -+ - /* Define to 1 so gets a definition of anon_hdl. Works around a - problem on IRIX 5. */ - #undef _KMEMUSER - -+/* Define for large files, on AIX-style hosts. */ -+#undef _LARGE_FILES -+ - /* Define to 1 if on MINIX. */ - #undef _MINIX - -Index: gdb-6.8.50.20090909/gdb/configure -=================================================================== ---- gdb-6.8.50.20090909.orig/gdb/configure 2009-09-09 20:10:45.000000000 +0200 -+++ gdb-6.8.50.20090909/gdb/configure 2009-09-09 20:11:07.000000000 +0200 -@@ -884,6 +884,7 @@ ac_subst_files='host_makefile_frag' - ac_user_opts=' - enable_option_checking - enable_maintainer_mode -+enable_largefile - enable_dependency_tracking - with_separate_debug_dir - with_gdb_datadir -@@ -1562,6 +1563,7 @@ Optional Features: - --enable-FEATURE[=ARG] include FEATURE [ARG=yes] - --enable-maintainer-mode enable make rules and dependencies not useful - (and sometimes confusing) to the casual installer -+ --disable-largefile omit support for large files - --disable-dependency-tracking speeds up one-time build - --enable-dependency-tracking do not reject slow dependency extractors - --enable-targets=TARGETS -@@ -4100,6 +4102,204 @@ fi - - - -+# Check whether --enable-largefile was given. -+if test "${enable_largefile+set}" = set; then : -+ enableval=$enable_largefile; -+fi -+ -+if test "$enable_largefile" != no; then -+ -+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for special C compiler options needed for large files" >&5 -+$as_echo_n "checking for special C compiler options needed for large files... " >&6; } -+if test "${ac_cv_sys_largefile_CC+set}" = set; then : -+ $as_echo_n "(cached) " >&6 -+else -+ ac_cv_sys_largefile_CC=no -+ if test "$GCC" != yes; then -+ ac_save_CC=$CC -+ while :; do -+ # IRIX 6.2 and later do not support large files by default, -+ # so use the C compiler's -n32 option if that helps. -+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext -+/* end confdefs.h. */ -+#include -+ /* Check that off_t can represent 2**63 - 1 correctly. -+ We can't simply define LARGE_OFF_T to be 9223372036854775807, -+ since some C++ compilers masquerading as C compilers -+ incorrectly reject 9223372036854775807. */ -+#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) -+ int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 -+ && LARGE_OFF_T % 2147483647 == 1) -+ ? 1 : -1]; -+int -+main () -+{ -+ -+ ; -+ return 0; -+} -+_ACEOF -+ if ac_fn_c_try_compile "$LINENO"; then : -+ break -+fi -+rm -f core conftest.err conftest.$ac_objext -+ CC="$CC -n32" -+ if ac_fn_c_try_compile "$LINENO"; then : -+ ac_cv_sys_largefile_CC=' -n32'; break -+fi -+rm -f core conftest.err conftest.$ac_objext -+ break -+ done -+ CC=$ac_save_CC -+ rm -f conftest.$ac_ext -+ fi -+fi -+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sys_largefile_CC" >&5 -+$as_echo "$ac_cv_sys_largefile_CC" >&6; } -+ if test "$ac_cv_sys_largefile_CC" != no; then -+ CC=$CC$ac_cv_sys_largefile_CC -+ fi -+ -+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for _FILE_OFFSET_BITS value needed for large files" >&5 -+$as_echo_n "checking for _FILE_OFFSET_BITS value needed for large files... " >&6; } -+if test "${ac_cv_sys_file_offset_bits+set}" = set; then : -+ $as_echo_n "(cached) " >&6 -+else -+ while :; do -+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext -+/* end confdefs.h. */ -+#include -+ /* Check that off_t can represent 2**63 - 1 correctly. -+ We can't simply define LARGE_OFF_T to be 9223372036854775807, -+ since some C++ compilers masquerading as C compilers -+ incorrectly reject 9223372036854775807. */ -+#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) -+ int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 -+ && LARGE_OFF_T % 2147483647 == 1) -+ ? 1 : -1]; -+int -+main () -+{ -+ -+ ; -+ return 0; -+} -+_ACEOF -+if ac_fn_c_try_compile "$LINENO"; then : -+ ac_cv_sys_file_offset_bits=no; break -+fi -+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext -+/* end confdefs.h. */ -+#define _FILE_OFFSET_BITS 64 -+#include -+ /* Check that off_t can represent 2**63 - 1 correctly. -+ We can't simply define LARGE_OFF_T to be 9223372036854775807, -+ since some C++ compilers masquerading as C compilers -+ incorrectly reject 9223372036854775807. */ -+#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) -+ int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 -+ && LARGE_OFF_T % 2147483647 == 1) -+ ? 1 : -1]; -+int -+main () -+{ -+ -+ ; -+ return 0; -+} -+_ACEOF -+if ac_fn_c_try_compile "$LINENO"; then : -+ ac_cv_sys_file_offset_bits=64; break -+fi -+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -+ ac_cv_sys_file_offset_bits=unknown -+ break -+done -+fi -+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sys_file_offset_bits" >&5 -+$as_echo "$ac_cv_sys_file_offset_bits" >&6; } -+case $ac_cv_sys_file_offset_bits in #( -+ no | unknown) ;; -+ *) -+cat >>confdefs.h <<_ACEOF -+#define _FILE_OFFSET_BITS $ac_cv_sys_file_offset_bits -+_ACEOF -+;; -+esac -+rm -rf conftest* -+ if test $ac_cv_sys_file_offset_bits = unknown; then -+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for _LARGE_FILES value needed for large files" >&5 -+$as_echo_n "checking for _LARGE_FILES value needed for large files... " >&6; } -+if test "${ac_cv_sys_large_files+set}" = set; then : -+ $as_echo_n "(cached) " >&6 -+else -+ while :; do -+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext -+/* end confdefs.h. */ -+#include -+ /* Check that off_t can represent 2**63 - 1 correctly. -+ We can't simply define LARGE_OFF_T to be 9223372036854775807, -+ since some C++ compilers masquerading as C compilers -+ incorrectly reject 9223372036854775807. */ -+#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) -+ int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 -+ && LARGE_OFF_T % 2147483647 == 1) -+ ? 1 : -1]; -+int -+main () -+{ -+ -+ ; -+ return 0; -+} -+_ACEOF -+if ac_fn_c_try_compile "$LINENO"; then : -+ ac_cv_sys_large_files=no; break -+fi -+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext -+/* end confdefs.h. */ -+#define _LARGE_FILES 1 -+#include -+ /* Check that off_t can represent 2**63 - 1 correctly. -+ We can't simply define LARGE_OFF_T to be 9223372036854775807, -+ since some C++ compilers masquerading as C compilers -+ incorrectly reject 9223372036854775807. */ -+#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) -+ int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 -+ && LARGE_OFF_T % 2147483647 == 1) -+ ? 1 : -1]; -+int -+main () -+{ -+ -+ ; -+ return 0; -+} -+_ACEOF -+if ac_fn_c_try_compile "$LINENO"; then : -+ ac_cv_sys_large_files=1; break -+fi -+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -+ ac_cv_sys_large_files=unknown -+ break -+done -+fi -+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sys_large_files" >&5 -+$as_echo "$ac_cv_sys_large_files" >&6; } -+case $ac_cv_sys_large_files in #( -+ no | unknown) ;; -+ *) -+cat >>confdefs.h <<_ACEOF -+#define _LARGE_FILES $ac_cv_sys_large_files -+_ACEOF -+;; -+esac -+rm -rf conftest* -+ fi -+fi -+ - - - diff --git a/gdb-6.8-bz466901-backtrace-full-prelinked.patch b/gdb-6.8-bz466901-backtrace-full-prelinked.patch index f9ec349..2211fa3 100644 --- a/gdb-6.8-bz466901-backtrace-full-prelinked.patch +++ b/gdb-6.8-bz466901-backtrace-full-prelinked.patch @@ -1,20 +1,5 @@ Fix resolving of variables at locations lists in prelinked libs (BZ 466901). -Index: gdb-6.8.50.20090909/gdb/dwarf2loc.c -=================================================================== ---- gdb-6.8.50.20090909.orig/gdb/dwarf2loc.c 2009-09-09 20:08:03.000000000 +0200 -+++ gdb-6.8.50.20090909/gdb/dwarf2loc.c 2009-09-09 20:10:35.000000000 +0200 -@@ -56,7 +56,9 @@ find_location_expression (struct dwarf2_ - CORE_ADDR low, high; - gdb_byte *loc_ptr, *buf_end; - int length; -- struct objfile *objfile = dwarf2_per_cu_objfile (baton->per_cu); -+ struct objfile *objfile1 = dwarf2_per_cu_objfile (baton->per_cu); -+ struct objfile *objfile = objfile1->separate_debug_objfile -+ ? objfile1->separate_debug_objfile : objfile1; - struct gdbarch *gdbarch = get_objfile_arch (objfile); - enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); - unsigned int addr_size = dwarf2_per_cu_addr_size (baton->per_cu); Index: gdb-6.8.50.20090909/gdb/testsuite/gdb.dwarf2/dw2-loclist-prelinked.exp =================================================================== --- /dev/null 1970-01-01 00:00:00.000000000 +0000 diff --git a/gdb-6.8-constant-watchpoints.patch b/gdb-6.8-constant-watchpoints.patch deleted file mode 100644 index df29d8d..0000000 --- a/gdb-6.8-constant-watchpoints.patch +++ /dev/null @@ -1,236 +0,0 @@ -2008-07-10 Jan Kratochvil - - * breakpoint.c (fetch_watchpoint_value): New comment on unreachable - values. - (watch_command_1): New variable VAL_CHAIN. Refuse constant watchpoints. - * gdbtypes.h (TYPE_CODE_FUNC): New comment regarding pointers to it. - -2008-07-10 Jan Kratochvil - - * gdb.texinfo (Set Watchpoints): Document constant value watchpoints. - -2008-07-10 Jan Kratochvil - - * gdb.base/watchpoint.exp: Call TEST_CONSTANT_WATCHPOINT. - (test_constant_watchpoint): New function. - (test_inaccessible_watchpoint): Cleanup (delete) the watchpoint. - Test also a double-indirection watchpoint. - gdb.base/watchpoint.c (global_ptr_ptr): New variable. - (func4): New testing code for GLOBAL_PTR_PTR. - -Index: gdb-6.8.50.20090803/gdb/breakpoint.c -=================================================================== ---- gdb-6.8.50.20090803.orig/gdb/breakpoint.c 2009-08-04 06:29:47.000000000 +0200 -+++ gdb-6.8.50.20090803/gdb/breakpoint.c 2009-08-04 06:32:50.000000000 +0200 -@@ -823,7 +823,15 @@ is_hardware_watchpoint (struct breakpoin - If VAL_CHAIN is non-NULL, *VAL_CHAIN will be released from the - value chain. The caller must free the values individually. If - VAL_CHAIN is NULL, all generated values will be left on the value -- chain. */ -+ chain. -+ -+ Inferior unreachable values return: -+ Inferior `int *intp = NULL;' with `watch *intp': -+ *VALP is NULL, *RESULTP contains lazy LVAL_MEMORY address 0, *VAL_CHAIN -+ contains the *RESULTP element and also INTP as LVAL_MEMORY. -+ Inferior `int **intpp = NULL;' with `watch **intpp': -+ *VALP is NULL, *RESULTP is NULL, *VAL_CHAIN contains lazy LVAL_MEMORY -+ address 0 and also INTPP as LVAL_MEMORY. */ - - static void - fetch_watchpoint_value (struct expression *exp, struct value **valp, -@@ -6301,7 +6309,7 @@ watch_command_1 (char *arg, int accessfl - struct symtab_and_line sal; - struct expression *exp; - struct block *exp_valid_block; -- struct value *val, *mark; -+ struct value *val, *mark, *val_chain; - struct frame_info *frame; - char *exp_start = NULL; - char *exp_end = NULL; -@@ -6392,6 +6400,27 @@ watch_command_1 (char *arg, int accessfl - exp_valid_block = innermost_block; - mark = value_mark (); - fetch_watchpoint_value (exp, &val, NULL, NULL); -+ -+ /* VALUE_MARK gets us the same value as FETCH_WATCHPOINT_VALUE's VAL_CHAIN -+ parameter. Just this way we do not have to VALUE_FREE the chained VALUEs -+ ourselves. */ -+ for (val_chain = value_mark (); -+ val_chain != mark; -+ val_chain = value_next (val_chain)) -+ if ((VALUE_LVAL (val_chain) == lval_memory -+ && TYPE_CODE (value_type (val_chain)) != TYPE_CODE_FUNC) -+ || VALUE_LVAL (val_chain) == lval_register) -+ break; -+ if (val_chain == mark) -+ { -+ int len; -+ -+ len = exp_end - exp_start; -+ while (len > 0 && isspace (exp_start[len - 1])) -+ len--; -+ error (_("Cannot watch constant value %.*s."), len, exp_start); -+ } -+ /* Break the values chain only after its check above. */ - if (val != NULL) - release_value (val); - -Index: gdb-6.8.50.20090803/gdb/gdbtypes.h -=================================================================== ---- gdb-6.8.50.20090803.orig/gdb/gdbtypes.h 2009-08-04 06:31:58.000000000 +0200 -+++ gdb-6.8.50.20090803/gdb/gdbtypes.h 2009-08-04 06:32:50.000000000 +0200 -@@ -71,7 +71,22 @@ enum type_code - TYPE_CODE_UNION, /* C union or Pascal variant part */ - TYPE_CODE_ENUM, /* Enumeration type */ - TYPE_CODE_FLAGS, /* Bit flags type */ -- TYPE_CODE_FUNC, /* Function type */ -+ -+ /* Function type. It is not a pointer to a function. Function reference -+ by its name (such as `printf') has this type. C automatically converts -+ this function type to a pointer to function for any operation except -+ `sizeof (function_type)' or `&function_type' (unary &). -+ `sizeof (function_type)' is undefined in C. But GCC provides extension -+ (info '(gcc)Pointer Arith') defining its size as 1 byte. DWARF does not -+ define its size but GDB defines the size the GCC compatible way - GDB -+ function MAKE_FUNCTION_TYPE. The address itself is not modifiable. -+ As the function type has size 1 but its real value has `sizeof -+ (CORE_ADDR)' we cannot use NOT_LVAL category because the address would -+ not fit in the VALUE_CONTENTS_RAW container of its VALUE. We use -+ LVAL_MEMORY (and its VALUE_ADDRESS field) for it but we must be careful -+ it is not lvalue, it is the only non-modifiable LVAL_MEMORY. */ -+ TYPE_CODE_FUNC, -+ - TYPE_CODE_INT, /* Integer type */ - - /* Floating type. This is *NOT* a complex type. Beware, there are parts -Index: gdb-6.8.50.20090803/gdb/doc/gdb.texinfo -=================================================================== ---- gdb-6.8.50.20090803.orig/gdb/doc/gdb.texinfo 2009-08-04 06:32:39.000000000 +0200 -+++ gdb-6.8.50.20090803/gdb/doc/gdb.texinfo 2009-08-04 06:32:50.000000000 +0200 -@@ -3517,6 +3517,18 @@ This command prints a list of watchpoint - it is the same as @code{info break} (@pxref{Set Breaks}). - @end table - -+If you watch for a change in a numerically entered address you need to -+dereference it as the address itself is just a constant number which will never -+change. @value{GDBN} refuses to create a watchpoint that watches -+a never-changing value: -+ -+@smallexample -+(@value{GDBP}) watch 0x600850 -+Cannot watch constant value 0x600850. -+(@value{GDBP}) watch *(int *) 0x600850 -+Watchpoint 1: *(int *) 6293584 -+@end smallexample -+ - @value{GDBN} sets a @dfn{hardware watchpoint} if possible. Hardware - watchpoints execute very quickly, and the debugger reports a change in - value at the exact instruction where the change occurs. If @value{GDBN} -Index: gdb-6.8.50.20090803/gdb/testsuite/gdb.base/watchpoint.c -=================================================================== ---- gdb-6.8.50.20090803.orig/gdb/testsuite/gdb.base/watchpoint.c 2008-03-03 14:24:12.000000000 +0100 -+++ gdb-6.8.50.20090803/gdb/testsuite/gdb.base/watchpoint.c 2009-08-04 06:32:50.000000000 +0200 -@@ -40,6 +40,7 @@ struct foo struct1, struct2, *ptr1, *ptr - int doread = 0; - - char *global_ptr; -+char **global_ptr_ptr; - - void marker1 () - { -@@ -118,6 +119,10 @@ func4 () - buf[0] = 3; - global_ptr = buf; - buf[0] = 7; -+ buf[1] = 5; -+ global_ptr_ptr = &global_ptr; -+ buf[0] = 9; -+ global_ptr++; - } - - int main () -Index: gdb-6.8.50.20090803/gdb/testsuite/gdb.base/watchpoint.exp -=================================================================== ---- gdb-6.8.50.20090803.orig/gdb/testsuite/gdb.base/watchpoint.exp 2009-01-03 06:58:03.000000000 +0100 -+++ gdb-6.8.50.20090803/gdb/testsuite/gdb.base/watchpoint.exp 2009-08-04 06:32:50.000000000 +0200 -@@ -641,7 +641,21 @@ proc test_watchpoint_and_breakpoint {} { - } - } - } -- -+ -+proc test_constant_watchpoint {} { -+ global gdb_prompt -+ -+ gdb_test "watch 5" "Cannot watch constant value 5." "number is constant" -+ gdb_test "watch marker1" "Cannot watch constant value marker1." \ -+ "marker1 is constant" -+ gdb_test "watch count + 6" ".*atchpoint \[0-9\]+: count \\+ 6" -+ gdb_test "set \$expr_breakpoint_number = \$bpnum" "" -+ gdb_test "delete \$expr_breakpoint_number" "" -+ gdb_test "watch 7 + count" ".*atchpoint \[0-9\]+: 7 \\+ count" -+ gdb_test "set \$expr_breakpoint_number = \$bpnum" "" -+ gdb_test "delete \$expr_breakpoint_number" "" -+} -+ - proc test_inaccessible_watchpoint {} { - global gdb_prompt - -@@ -662,7 +676,8 @@ proc test_inaccessible_watchpoint {} { - } - - gdb_test "watch *global_ptr" ".*atchpoint \[0-9\]+: \\*global_ptr" -- gdb_test "next" ".*global_ptr = buf.*" -+ gdb_test "set \$global_ptr_breakpoint_number = \$bpnum" "" -+ gdb_test "next" ".*global_ptr = buf.*" "global_ptr next" - gdb_test_multiple "next" "next over ptr init" { - -re ".*atchpoint \[0-9\]+: \\*global_ptr\r\n\r\nOld value = .*\r\nNew value = 3 .*\r\n.*$gdb_prompt $" { - # We can not test for here because NULL may be readable. -@@ -675,6 +690,28 @@ proc test_inaccessible_watchpoint {} { - pass "next over buffer set" - } - } -+ gdb_test "delete \$global_ptr_breakpoint_number" "" -+ gdb_test "watch **global_ptr_ptr" ".*atchpoint \[0-9\]+: \\*\\*global_ptr_ptr" -+ gdb_test "set \$global_ptr_ptr_breakpoint_number = \$bpnum" "" -+ gdb_test "next" ".*global_ptr_ptr = &global_ptr.*" "gloabl_ptr_ptr next" -+ gdb_test_multiple "next" "next over global_ptr_ptr init" { -+ -re ".*atchpoint \[0-9\]+: \\*\\*global_ptr_ptr\r\n\r\nOld value = .*\r\nNew value = 7 .*\r\n.*$gdb_prompt $" { -+ # We can not test for here because NULL may be readable. -+ # This test does rely on *NULL != 7. -+ pass "next over global_ptr_ptr init" -+ } -+ } -+ gdb_test_multiple "next" "next over global_ptr_ptr buffer set" { -+ -re ".*atchpoint \[0-9\]+: \\*\\*global_ptr_ptr\r\n\r\nOld value = 7 .*\r\nNew value = 9 .*\r\n.*$gdb_prompt $" { -+ pass "next over global_ptr_ptr buffer set" -+ } -+ } -+ gdb_test_multiple "next" "next over global_ptr_ptr pointer advance" { -+ -re ".*atchpoint \[0-9\]+: \\*\\*global_ptr_ptr\r\n\r\nOld value = 9 .*\r\nNew value = 5 .*\r\n.*$gdb_prompt $" { -+ pass "next over global_ptr_ptr pointer advance" -+ } -+ } -+ gdb_test "delete \$global_ptr_ptr_breakpoint_number" "" - } - } - -@@ -842,6 +879,17 @@ if [initialize] then { - } - - test_watchpoint_and_breakpoint -+ -+ # See above. -+ if [istarget "mips-idt-*"] then { -+ gdb_exit -+ gdb_start -+ gdb_reinitialize_dir $srcdir/$subdir -+ gdb_load $binfile -+ initialize -+ } -+ -+ test_constant_watchpoint - } - - # Restore old timeout diff --git a/gdb-6.8-fortran-tag-constant.patch b/gdb-6.8-fortran-tag-constant.patch index a7cc1dd..3283984 100644 --- a/gdb-6.8-fortran-tag-constant.patch +++ b/gdb-6.8-fortran-tag-constant.patch @@ -1,8 +1,8 @@ -Index: gdb-6.8.50.20090811/gdb/dwarf2read.c +Index: gdb-7.1.90.20100711/gdb/dwarf2read.c =================================================================== ---- gdb-6.8.50.20090811.orig/gdb/dwarf2read.c 2009-08-13 10:14:45.000000000 +0200 -+++ gdb-6.8.50.20090811/gdb/dwarf2read.c 2009-08-13 10:22:36.000000000 +0200 -@@ -2480,6 +2480,7 @@ scan_partial_symbols (struct partial_die +--- gdb-7.1.90.20100711.orig/gdb/dwarf2read.c 2010-07-12 23:07:35.000000000 +0200 ++++ gdb-7.1.90.20100711/gdb/dwarf2read.c 2010-07-13 00:13:02.000000000 +0200 +@@ -2251,6 +2251,7 @@ scan_partial_symbols (struct partial_die add_partial_subprogram (pdi, lowpc, highpc, need_pc, cu); break; case DW_TAG_variable: @@ -10,7 +10,7 @@ Index: gdb-6.8.50.20090811/gdb/dwarf2read.c case DW_TAG_typedef: case DW_TAG_union_type: if (!pdi->is_declaration) -@@ -2675,6 +2676,7 @@ add_partial_symbol (struct partial_die_i +@@ -2452,6 +2453,7 @@ add_partial_symbol (struct partial_die_i } break; case DW_TAG_variable: @@ -18,15 +18,15 @@ Index: gdb-6.8.50.20090811/gdb/dwarf2read.c if (pdi->is_external) { /* Global Variable. -@@ -2805,6 +2807,7 @@ die_needs_namespace (struct die_info *di +@@ -3289,6 +3291,7 @@ die_needs_namespace (struct die_info *di return 1; case DW_TAG_variable: + case DW_TAG_constant: - { - struct attribute *attr; - attr = dwarf2_attr (die, DW_AT_specification, cu); -@@ -4741,7 +4744,8 @@ dwarf2_add_field (struct field_info *fip + /* We only need to prefix "globally" visible variables. These include + any variable marked with DW_AT_external or any variable that + lives in a namespace. [Variables in anonymous namespaces +@@ -4638,7 +4641,8 @@ dwarf2_add_field (struct field_info *fip fip->non_public_fields = 1; } } @@ -36,7 +36,7 @@ Index: gdb-6.8.50.20090811/gdb/dwarf2read.c { /* C++ static member. */ -@@ -5233,7 +5237,8 @@ read_structure_type (struct die_info *di +@@ -5250,7 +5254,8 @@ read_structure_type (struct die_info *di while (child_die && child_die->tag) { if (child_die->tag == DW_TAG_member @@ -46,7 +46,7 @@ Index: gdb-6.8.50.20090811/gdb/dwarf2read.c { /* NOTE: carlton/2002-11-05: A C++ static data member should be a DW_TAG_member that is a declaration, but -@@ -5352,6 +5357,7 @@ process_structure_scope (struct die_info +@@ -5396,6 +5401,7 @@ process_structure_scope (struct die_info { if (child_die->tag == DW_TAG_member || child_die->tag == DW_TAG_variable @@ -54,7 +54,7 @@ Index: gdb-6.8.50.20090811/gdb/dwarf2read.c || child_die->tag == DW_TAG_inheritance) { /* Do nothing. */ -@@ -6980,6 +6986,7 @@ load_partial_dies (bfd *abfd, gdb_byte * +@@ -7109,6 +7115,7 @@ load_partial_dies (bfd *abfd, gdb_byte * && abbrev->tag != DW_TAG_subprogram && abbrev->tag != DW_TAG_lexical_block && abbrev->tag != DW_TAG_variable @@ -62,7 +62,7 @@ Index: gdb-6.8.50.20090811/gdb/dwarf2read.c && abbrev->tag != DW_TAG_namespace && abbrev->tag != DW_TAG_module && abbrev->tag != DW_TAG_member) -@@ -7088,6 +7095,7 @@ load_partial_dies (bfd *abfd, gdb_byte * +@@ -7217,6 +7224,7 @@ load_partial_dies (bfd *abfd, gdb_byte * if (load_all || abbrev->tag == DW_TAG_subprogram || abbrev->tag == DW_TAG_variable @@ -70,7 +70,7 @@ Index: gdb-6.8.50.20090811/gdb/dwarf2read.c || abbrev->tag == DW_TAG_namespace || part_die->is_declaration) { -@@ -8901,6 +8909,11 @@ new_symbol (struct die_info *die, struct +@@ -9059,6 +9067,11 @@ new_symbol (struct die_info *die, struct /* Do not add the symbol to any lists. It will be found via BLOCK_FUNCTION from the blockvector. */ break; @@ -80,5 +80,5 @@ Index: gdb-6.8.50.20090811/gdb/dwarf2read.c + SYMBOL_TYPE (sym), NULL); + /* PASSTHRU */ case DW_TAG_variable: + case DW_TAG_member: /* Compilation with minimal debug info may result in variables - with missing type entries. Change the misleading `void' type diff --git a/gdb-6.8-inlining-addon.patch b/gdb-6.8-inlining-addon.patch deleted file mode 100644 index 4edcd1a..0000000 --- a/gdb-6.8-inlining-addon.patch +++ /dev/null @@ -1,571 +0,0 @@ -infcall.c : -Revert the change of: gdb-6.8-inlining.patch -causing: FAIL: gdb.base/unwindonsignal.exp: unwindonsignal, stack unwound - -resume() -> target_resume() move of clear_inline_frame_state() is for: -gdb.mi/mi-nsmoribund.exp - -Index: gdb-6.8.91.20090917/gdb/testsuite/gdb.opt/inline-bt.c -=================================================================== ---- gdb-6.8.91.20090917.orig/gdb/testsuite/gdb.opt/inline-bt.c 2009-06-28 02:20:24.000000000 +0200 -+++ gdb-6.8.91.20090917/gdb/testsuite/gdb.opt/inline-bt.c 2009-09-17 12:49:01.000000000 +0200 -@@ -13,10 +13,16 @@ - You should have received a copy of the GNU General Public License - along with this program. If not, see . */ - --int x, y; -+/* VOLATILE forces all the inlining to happen as otherwise the whole program -+ gets optimized by CSE to just simple assignments of the results. */ -+volatile int x, y; - volatile int result; - --void bar(void); -+inline void bar(void) -+{ -+ x += y; /* set breakpoint 1 here */ -+} -+ - - inline int func1(void) - { -Index: gdb-6.8.91.20090917/gdb/testsuite/gdb.opt/inline-cmds.c -=================================================================== ---- gdb-6.8.91.20090917.orig/gdb/testsuite/gdb.opt/inline-cmds.c 2009-06-28 02:20:24.000000000 +0200 -+++ gdb-6.8.91.20090917/gdb/testsuite/gdb.opt/inline-cmds.c 2009-09-17 12:49:01.000000000 +0200 -@@ -13,13 +13,19 @@ - You should have received a copy of the GNU General Public License - along with this program. If not, see . */ - --int x, y; -+/* VOLATILE forces all the inlining to happen as otherwise the whole program -+ gets optimized by CSE to just simple assignments of the results. */ -+volatile int x, y; - volatile int result; - --void bar(void); - void marker(void); - void noinline(void); - -+inline void bar(void) -+{ -+ x += y; /* set breakpoint 1 here */ -+} -+ - inline int func1(void) - { - bar (); -Index: gdb-6.8.91.20090917/gdb/testsuite/gdb.opt/inline-cmds.exp -=================================================================== ---- gdb-6.8.91.20090917.orig/gdb/testsuite/gdb.opt/inline-cmds.exp 2009-06-28 02:20:24.000000000 +0200 -+++ gdb-6.8.91.20090917/gdb/testsuite/gdb.opt/inline-cmds.exp 2009-09-17 12:49:01.000000000 +0200 -@@ -230,7 +230,7 @@ set line3 [gdb_get_line_number "set brea - gdb_breakpoint $line3 - gdb_continue_to_breakpoint "consecutive func1" - --gdb_test "next" ".*func1 .*first call.*" "next to first func1" -+gdb_test "next" "func1 .*first call.*" "next to first func1" - set msg "next to second func1" - gdb_test_multiple "next" $msg { - -re ".*func1 .*second call.*$gdb_prompt $" { -@@ -253,16 +253,16 @@ set line4 [gdb_get_line_number "set brea - gdb_breakpoint $line4 - gdb_continue_to_breakpoint "func1 then func3" - --gdb_test "next" ".*func1 \\\(\\\);" "next to func1 before func3" --gdb_test "next" ".*func3 \\\(\\\);" "next to func3" -+gdb_test "next" "func1 \\\(\\\);" "next to func1 before func3" -+gdb_test "next" "func3 \\\(\\\);" "next to func3" - - # Test finishing out of one thing and into another. - set line5 [gdb_get_line_number "set breakpoint 5 here"] - gdb_breakpoint $line5 - gdb_continue_to_breakpoint "finish into func1" - --gdb_test "next" ".*marker \\\(\\\);" "next to finish marker" --gdb_test "step" ".*set breakpoint 2 here.*" "step into finish marker" -+gdb_test "next" "marker \\\(\\\);" "next to finish marker" -+gdb_test "step" "set breakpoint 2 here.*" "step into finish marker" - gdb_test "finish" "func1 \\\(\\\);" "finish from marker to func1" - - gdb_test "step" "bar \\\(\\\);" "step into func1 for finish" -@@ -297,12 +297,12 @@ gdb_test "step" "noinline \\\(\\\) at .* - gdb_test "bt" "#0 noinline.*#1 .*outer_inline1.*#2 .*outer_inline2.*#3 main.*" "backtrace at noinline from outer_inline1" - gdb_test "step" "inlined_fn \\\(\\\) at .*" "enter inlined_fn from noinline" - gdb_test "bt" "#0 inlined_fn.*#1 noinline.*#2 .*outer_inline1.*#3 .*outer_inline2.*#4 main.*" "backtrace at inlined_fn from noinline" --gdb_test "info frame" ".*inlined into frame.*" "inlined_fn from noinline inlined" --gdb_test "up" "#1 noinline.*" "up to noinline" --gdb_test "info frame" ".*\n called by frame.*" "noinline from outer_inline1 not inlined" --gdb_test "up" "#2 .*outer_inline1.*" "up to outer_inline1" --gdb_test "info frame" ".*inlined into frame.*" "outer_inline1 inlined" --gdb_test "up" "#3 .*outer_inline2.*" "up to outer_inline2" --gdb_test "info frame" ".*inlined into frame.*" "outer_inline2 inlined" --gdb_test "up" "#4 main.*" "up from outer_inline2" --gdb_test "info frame" ".*\n caller of frame.*" "main not inlined" -+gdb_test "info frame" "inlined into frame.*" "inlined_fn from noinline inlined" -+gdb_test "fini" "" "up to noinline" -+gdb_test "info frame" "\n called by frame.*" "noinline from outer_inline1 not inlined" -+gdb_test "fini" "" "up to outer_inline1" -+gdb_test "info frame" "inlined into frame.*" "outer_inline1 inlined" -+gdb_test "fini" "" "up to outer_inline2" -+gdb_test "info frame" "inlined into frame.*" "outer_inline2 inlined" -+gdb_test "fini" "" "up from outer_inline2" -+gdb_test "info frame" " in main \[^\n\]*\n source language.*" "main not inlined" -Index: gdb-6.8.91.20090917/gdb/testsuite/gdb.opt/inline-locals.c -=================================================================== ---- gdb-6.8.91.20090917.orig/gdb/testsuite/gdb.opt/inline-locals.c 2009-06-28 02:20:24.000000000 +0200 -+++ gdb-6.8.91.20090917/gdb/testsuite/gdb.opt/inline-locals.c 2009-09-17 12:49:01.000000000 +0200 -@@ -13,11 +13,16 @@ - You should have received a copy of the GNU General Public License - along with this program. If not, see . */ - --int x, y; -+/* VOLATILE forces all the inlining to happen as otherwise the whole program -+ gets optimized by CSE to just simple assignments of the results. */ -+volatile int x, y; - volatile int result; - volatile int *array_p; - --void bar(void); -+inline void bar(void) -+{ -+ x += y; /* set breakpoint 1 here */ -+} - - inline int func1(int arg1) - { -Index: gdb-6.8.91.20090917/gdb/testsuite/gdb.opt/inline-locals.exp -=================================================================== ---- gdb-6.8.91.20090917.orig/gdb/testsuite/gdb.opt/inline-locals.exp 2009-06-30 17:50:27.000000000 +0200 -+++ gdb-6.8.91.20090917/gdb/testsuite/gdb.opt/inline-locals.exp 2009-09-17 12:49:01.000000000 +0200 -@@ -77,6 +77,9 @@ if { ! $no_frames } { - - # Make sure that locals on the stack are found. This is an array to - # prevent it from living in a register. -+if [test_compiler_info "gcc-4-3-*"] { -+ setup_kfail *-*-* "gcc/debug.optimization" -+} - gdb_test "print array\[0\]" "\\\$$decimal = 0" "print local (2)" - - if { ! $no_frames } { -@@ -115,4 +118,7 @@ if { ! $no_frames } { - gdb_test "info locals" ".*arg2 = 184.*" "info locals above bar (3b)" - } - -+if [test_compiler_info "gcc-4-3-*"] { -+ setup_kfail *-*-* "gcc/debug.optimization" -+} - gdb_test "print array\[0\]" "\\\$$decimal = 184" "print local (3)" -Index: gdb-6.8.91.20090917/gdb/frame.c -=================================================================== ---- gdb-6.8.91.20090917.orig/gdb/frame.c 2009-09-17 12:48:49.000000000 +0200 -+++ gdb-6.8.91.20090917/gdb/frame.c 2009-09-17 12:49:01.000000000 +0200 -@@ -310,7 +310,7 @@ fprint_frame (struct ui_file *file, stru - static struct frame_info * - skip_inlined_frames (struct frame_info *frame) - { -- while (get_frame_type (frame) == INLINE_FRAME) -+ while (frame && get_frame_type (frame) == INLINE_FRAME) - frame = get_prev_frame (frame); - - return frame; -@@ -1778,6 +1778,7 @@ get_frame_address_in_block (struct frame - { - /* A draft address. */ - CORE_ADDR pc = get_frame_pc (this_frame); -+ struct thread_info *tp = inferior_thread (); - - struct frame_info *next_frame = this_frame->next; - -@@ -1820,6 +1821,9 @@ get_frame_address_in_block (struct frame - while in an inlined function, then the code address of the - "calling" normal function should not be adjusted either. */ - -+ if (tp->current_pc_is_notcurrent) -+ return pc - 1; -+ - while (get_frame_type (next_frame) == INLINE_FRAME) - next_frame = next_frame->next; - -@@ -1851,7 +1855,7 @@ find_frame_sal (struct frame_info *frame - sym = inline_skipped_symbol (inferior_ptid); - - init_sal (sal); -- if (SYMBOL_LINE (sym) != 0) -+ if (sym != NULL && SYMBOL_LINE (sym) != 0) - { - sal->symtab = SYMBOL_SYMTAB (sym); - sal->line = SYMBOL_LINE (sym); -Index: gdb-6.8.91.20090917/gdb/breakpoint.c -=================================================================== ---- gdb-6.8.91.20090917.orig/gdb/breakpoint.c 2009-09-17 12:48:51.000000000 +0200 -+++ gdb-6.8.91.20090917/gdb/breakpoint.c 2009-09-17 12:49:12.000000000 +0200 -@@ -62,6 +62,7 @@ - #include "jit.h" - #include "xml-syscall.h" - #include "parser-defs.h" -+#include "inline-frame.h" - - /* readline include files */ - #include "readline/readline.h" -@@ -3220,10 +3221,24 @@ bpstat_check_breakpoint_conditions (bpst - const struct bp_location *bl = bs->breakpoint_at; - struct breakpoint *b = bl->owner; - -- if (frame_id_p (b->frame_id) -- && !frame_id_eq (b->frame_id, get_stack_frame_id (get_current_frame ()))) -- bs->stop = 0; -- else if (bs->stop) -+ if (frame_id_p (b->frame_id)) -+ { -+ struct frame_info *b_frame, *frame; -+ struct frame_id b_frame_id, current_frame_id; -+ -+ b_frame = frame_find_by_id (b->frame_id); -+ -+ /* get_stack_frame_id normalizes the id to the real non-inlined function -+ by skip_inlined_frames. */ -+ b_frame_id = get_stack_frame_id (b_frame); -+ current_frame_id = get_stack_frame_id (get_current_frame ()); -+ -+ /* Completely different (inlining notwithstanding) frames? */ -+ if (!frame_id_eq (b_frame_id, current_frame_id)) -+ bs->stop = 0; -+ } -+ -+ if (bs->stop) - { - int value_is_zero = 0; - -@@ -3383,6 +3398,12 @@ bpstat_stop_status (CORE_ADDR bp_addr, p - bs->print = 0; - } - bs->commands = copy_command_lines (bs->commands); -+ -+ /* Display the innermost inlined frame at a breakpont as it gives to -+ most of the available information. */ -+ if (b->type != bp_until && b->type != bp_finish) -+ while (inline_skipped_frames (ptid)) -+ step_into_inline_frame (ptid); - } - - /* Print nothing for this entry if we dont stop or if we dont print. */ -@@ -5572,9 +5593,9 @@ set_momentary_breakpoint (struct gdbarch - { - struct breakpoint *b; - -- /* If FRAME_ID is valid, it should be a real frame, not an inlined -- one. */ -- gdb_assert (!frame_id_inlined_p (frame_id)); -+ /* We can be returning even into an inline frame. While finish_command will -+ shortcut the case of returning _from_ an inline frame we still may be -+ returning from non-inlined frame _to_ an inlined frame. */ - - b = set_raw_breakpoint (gdbarch, sal, type); - b->enable_state = bp_enabled; -Index: gdb-6.8.91.20090917/gdb/inline-frame.c -=================================================================== ---- gdb-6.8.91.20090917.orig/gdb/inline-frame.c 2009-09-13 18:28:28.000000000 +0200 -+++ gdb-6.8.91.20090917/gdb/inline-frame.c 2009-09-17 12:49:01.000000000 +0200 -@@ -199,6 +199,12 @@ inline_frame_sniffer (const struct frame - if (frame_block == NULL) - return 0; - -+ /* For >=2 inlined functions SKIPPED_SYMBOL needs to be different after each -+ step_into_inline_frame call. But skip_inline_frames is called only once -+ and thus SKIPPED_SYMBOL needs to be calculated by INLINE_FRAME_SNIFFER. */ -+ if (state) -+ state->skipped_symbol = NULL; -+ - /* Calculate DEPTH, the number of inlined functions at this - location. */ - depth = 0; -@@ -208,6 +214,10 @@ inline_frame_sniffer (const struct frame - if (block_inlined_p (cur_block)) - depth++; - -+ if (state && depth == state->skipped_frames -+ && state->skipped_symbol == NULL) -+ state->skipped_symbol = BLOCK_FUNCTION (cur_block); -+ - cur_block = BLOCK_SUPERBLOCK (cur_block); - } - -@@ -291,7 +301,6 @@ skip_inline_frames (ptid_t ptid) - { - CORE_ADDR this_pc; - struct block *frame_block, *cur_block; -- struct symbol *last_sym = NULL; - int skip_count = 0; - struct inline_state *state; - -@@ -312,10 +321,7 @@ skip_inline_frames (ptid_t ptid) - of BLOCK_START. */ - if (BLOCK_START (cur_block) == this_pc - || block_starting_point_at (this_pc, cur_block)) -- { -- skip_count++; -- last_sym = BLOCK_FUNCTION (cur_block); -- } -+ skip_count++; - else - break; - } -@@ -327,7 +333,6 @@ skip_inline_frames (ptid_t ptid) - state = allocate_inline_frame_state (ptid); - state->skipped_frames = skip_count; - state->saved_pc = this_pc; -- state->skipped_symbol = last_sym; - - if (skip_count != 0) - reinit_frame_cache (); -@@ -345,6 +350,23 @@ step_into_inline_frame (ptid_t ptid) - reinit_frame_cache (); - } - -+/* Step out of an inlined function by hiding it. */ -+ -+void -+step_out_of_inline_frame (ptid_t ptid) -+{ -+ struct inline_state *state = find_inline_frame_state (ptid); -+ -+ gdb_assert (state != NULL); -+ -+ /* Simulate the caller adjustment. */ -+ if (state->skipped_frames == 0) -+ state->saved_pc--; -+ -+ state->skipped_frames++; -+ reinit_frame_cache (); -+} -+ - /* Return the number of hidden functions inlined into the current - frame. */ - -Index: gdb-6.8.91.20090917/gdb/testsuite/gdb.opt/inline-markers.c -=================================================================== ---- gdb-6.8.91.20090917.orig/gdb/testsuite/gdb.opt/inline-markers.c 2009-06-28 02:20:24.000000000 +0200 -+++ gdb-6.8.91.20090917/gdb/testsuite/gdb.opt/inline-markers.c 2009-09-17 12:49:01.000000000 +0200 -@@ -15,11 +15,6 @@ - - extern int x, y; - --void bar(void) --{ -- x += y; /* set breakpoint 1 here */ --} -- - void marker(void) - { - x += y; /* set breakpoint 2 here */ -Index: gdb-6.8.91.20090917/gdb/gdbthread.h -=================================================================== ---- gdb-6.8.91.20090917.orig/gdb/gdbthread.h 2009-09-17 12:47:07.000000000 +0200 -+++ gdb-6.8.91.20090917/gdb/gdbthread.h 2009-09-17 12:49:01.000000000 +0200 -@@ -191,6 +191,12 @@ struct thread_info - - /* Private data used by the target vector implementation. */ - struct private_thread_info *private; -+ -+ /* Nonzero if the current frame PC should be unwound as the caller. It is -+ used to keep the backtrace upper levels existing after finish_command into -+ an inlined frame if the current inlined function/block was ending at the -+ current PC. */ -+ int current_pc_is_notcurrent; - }; - - /* Create an empty thread list, or empty the existing one. */ -Index: gdb-6.8.91.20090917/gdb/infcmd.c -=================================================================== ---- gdb-6.8.91.20090917.orig/gdb/infcmd.c 2009-09-17 12:47:07.000000000 +0200 -+++ gdb-6.8.91.20090917/gdb/infcmd.c 2009-09-17 12:49:01.000000000 +0200 -@@ -1434,11 +1434,11 @@ finish_command_continuation (void *arg) - struct type *value_type; - - value_type = TYPE_TARGET_TYPE (SYMBOL_TYPE (a->function)); -- if (!value_type) -+ if (!SYMBOL_INLINED (a->function) && !value_type) - internal_error (__FILE__, __LINE__, - _("finish_command: function has no target type")); - -- if (TYPE_CODE (value_type) != TYPE_CODE_VOID) -+ if (value_type && TYPE_CODE (value_type) != TYPE_CODE_VOID) - print_return_value (SYMBOL_TYPE (a->function), value_type); - } - -@@ -1546,6 +1546,16 @@ finish_forward (struct symbol *function, - tp->initiating_frame = get_frame_id (frame); - make_cleanup (delete_longjmp_breakpoint_cleanup, &thread); - -+ /* We should _always_ set CURRENT_PC_IS_NOTCURRENT here to always see the -+ calling line with the message `Value returned is ...'. Currently it is -+ seen only if at least one instruction is on that source line after the -+ call instruction. We would also need to hook step_once and only clear -+ CURRENT_PC_IS_NOTCURRENT on the first step. But it would be a change of -+ general non-inlining behavior against upstream. */ -+ -+ if (get_frame_type (frame) == INLINE_FRAME) -+ tp->current_pc_is_notcurrent = 1; -+ - tp->proceed_to_finish = 1; /* We want stop_registers, please... */ - proceed ((CORE_ADDR) -1, TARGET_SIGNAL_DEFAULT, 0); - -@@ -1567,7 +1577,9 @@ finish_forward (struct symbol *function, - static void - finish_command (char *arg, int from_tty) - { -- struct frame_info *frame; -+ /* FIXME: Rename `current_frame' to `frame' upon a merge. */ -+ struct frame_info *current_frame, *prev_frame; -+ CORE_ADDR frame_pc; - struct symbol *function; - - int async_exec = 0; -@@ -1598,45 +1610,63 @@ finish_command (char *arg, int from_tty) - if (!target_has_execution) - error (_("The program is not running.")); - -- frame = get_prev_frame (get_selected_frame (_("No selected frame."))); -- if (frame == 0) -+ current_frame = get_selected_frame (_("No selected frame.")); -+ frame_pc = get_frame_pc (current_frame); -+ prev_frame = get_prev_frame (current_frame); -+ if (prev_frame == 0) - error (_("\"finish\" not meaningful in the outermost frame.")); - -- clear_proceed_status (); -- - /* Finishing from an inline frame is completely different. We don't - try to show the "return value" - no way to locate it. So we do - not need a completion. */ -- if (get_frame_type (get_selected_frame (_("No selected frame."))) -- == INLINE_FRAME) -+ if (get_frame_type (current_frame) == INLINE_FRAME) - { -- /* Claim we are stepping in the calling frame. An empty step -- range means that we will stop once we aren't in a function -- called by that frame. We don't use the magic "1" value for -- step_range_end, because then infrun will think this is nexti, -- and not step over the rest of this inlined function call. */ - struct thread_info *tp = inferior_thread (); - struct symtab_and_line empty_sal; -- init_sal (&empty_sal); -- set_step_info (frame, empty_sal); -- tp->step_range_start = tp->step_range_end = get_frame_pc (frame); -- tp->step_over_calls = STEP_OVER_ALL; -+ struct block *frame_block; - - /* Print info on the selected frame, including level number but not - source. */ - if (from_tty) - { - printf_filtered (_("Run till exit from ")); -- print_stack_frame (get_selected_frame (NULL), 1, LOCATION); -+ print_stack_frame (current_frame, 1, LOCATION); -+ } -+ -+ /* Even just a single stepi would get us out of the caller function PC -+ range. */ -+ -+ frame_block = get_frame_block (current_frame, NULL); -+ -+ /* FRAME_BLOCK must be initialized and also the frame printing above must -+ be done still with the original CURRENT_PC_IS_NOTCURRENT setting. */ -+ clear_proceed_status (); -+ -+ if (frame_block && BLOCK_END (frame_block) == frame_pc) -+ { -+ step_out_of_inline_frame (tp->ptid); -+ tp->current_pc_is_notcurrent = 1; -+ normal_stop (); -+ return; - } - -+ /* Claim we are stepping in the calling frame. An empty step -+ range means that we will stop once we aren't in a function -+ called by that frame. We don't use the magic "1" value for -+ step_range_end, because then infrun will think this is nexti, -+ and not step over the rest of this inlined function call. */ -+ init_sal (&empty_sal); -+ set_step_info (prev_frame, empty_sal); -+ tp->step_range_start = tp->step_range_end = get_frame_pc (prev_frame); -+ tp->step_over_calls = STEP_OVER_ALL; -+ - proceed ((CORE_ADDR) -1, TARGET_SIGNAL_DEFAULT, 1); - return; - } - - /* Find the function we will return from. */ - -- function = find_pc_function (get_frame_pc (get_selected_frame (NULL))); -+ function = find_pc_function (frame_pc); - - /* Print info on the selected frame, including level number but not - source. */ -@@ -1650,10 +1680,14 @@ finish_command (char *arg, int from_tty) - print_stack_frame (get_selected_frame (NULL), 1, LOCATION); - } - -+ /* Frames printing above must be done still with the original -+ CURRENT_PC_IS_NOTCURRENT setting. */ -+ clear_proceed_status (); -+ - if (execution_direction == EXEC_REVERSE) - finish_backward (function); - else -- finish_forward (function, frame); -+ finish_forward (function, prev_frame); - } - - -Index: gdb-6.8.91.20090917/gdb/target.c -=================================================================== ---- gdb-6.8.91.20090917.orig/gdb/target.c 2009-09-17 12:48:49.000000000 +0200 -+++ gdb-6.8.91.20090917/gdb/target.c 2009-09-17 12:49:01.000000000 +0200 -@@ -2187,6 +2187,7 @@ target_resume (ptid_t ptid, int step, en - { - struct target_ops *t; - -+ clear_inline_frame_state (ptid); - target_dcache_invalidate (); - - for (t = current_target.beneath; t != NULL; t = t->beneath) -Index: gdb-6.8.91.20090917/gdb/inline-frame.h -=================================================================== ---- gdb-6.8.91.20090917.orig/gdb/inline-frame.h 2009-06-28 02:20:22.000000000 +0200 -+++ gdb-6.8.91.20090917/gdb/inline-frame.h 2009-09-17 12:49:01.000000000 +0200 -@@ -43,6 +43,10 @@ void clear_inline_frame_state (ptid_t pt - - void step_into_inline_frame (ptid_t ptid); - -+/* Step out of an inlined function by hiding it. */ -+ -+void step_out_of_inline_frame (ptid_t ptid); -+ - /* Return the number of hidden functions inlined into the current - frame. */ - -Index: gdb-6.8.91.20090917/gdb/dwarf2read.c -=================================================================== ---- gdb-6.8.91.20090917.orig/gdb/dwarf2read.c 2009-09-17 12:48:51.000000000 +0200 -+++ gdb-6.8.91.20090917/gdb/dwarf2read.c 2009-09-17 12:49:01.000000000 +0200 -@@ -4128,6 +4128,7 @@ read_func_scope (struct die_info *die, s - struct block *block; - unsigned die_children = 0; - int inlined_func = (die->tag == DW_TAG_inlined_subroutine); -+ struct type *type; - - if (inlined_func) - { -@@ -4169,7 +4170,10 @@ read_func_scope (struct die_info *die, s - add_to_cu_func_list (name, lowpc, highpc, cu); - - new = push_context (0, lowpc); -- new->name = new_symbol (die, read_type_die (die, cu), cu); -+ type = read_type_die (die, cu); -+ gdb_assert (type != NULL); -+ new->name = new_symbol (die, type, cu); -+ gdb_assert (TYPE_CODE (SYMBOL_TYPE (new->name)) == TYPE_CODE_FUNC); - - /* If there is a location expression for DW_AT_frame_base, record - it. */ diff --git a/gdb-6.8-inlining-by-name.patch b/gdb-6.8-inlining-by-name.patch deleted file mode 100644 index 6096247..0000000 --- a/gdb-6.8-inlining-by-name.patch +++ /dev/null @@ -1,104 +0,0 @@ -Implement `b ' for with concete inlined instances by -a multiple-PC breakpoint. - -Index: gdb-6.8.50.20081128/gdb/ada-lang.c -=================================================================== ---- gdb-6.8.50.20081128.orig/gdb/ada-lang.c 2008-11-25 00:21:15.000000000 +0100 -+++ gdb-6.8.50.20081128/gdb/ada-lang.c 2008-12-06 21:39:56.000000000 +0100 -@@ -4614,7 +4614,7 @@ remove_irrelevant_renamings (struct ada_ - if (current_block == NULL) - return nsyms; - -- current_function = block_linkage_function (current_block); -+ current_function = block_function (current_block); - if (current_function == NULL) - return nsyms; - -@@ -6625,7 +6625,7 @@ ada_find_renaming_symbol (const char *na - static struct symbol * - find_old_style_renaming_symbol (const char *name, struct block *block) - { -- const struct symbol *function_sym = block_linkage_function (block); -+ const struct symbol *function_sym = block_function (block); - char *rename; - - if (function_sym != NULL) -Index: gdb-6.8.50.20081128/gdb/block.c -=================================================================== ---- gdb-6.8.50.20081128.orig/gdb/block.c 2008-12-06 14:06:16.000000000 +0100 -+++ gdb-6.8.50.20081128/gdb/block.c 2008-12-06 21:40:29.000000000 +0100 -@@ -75,6 +75,19 @@ block_linkage_function (const struct blo - return BLOCK_FUNCTION (bl); - } - -+/* Return the symbol for the function which contains a specified -+ lexical block, described by a struct block BL. Inlined functions -+ can be returned. */ -+ -+struct symbol * -+block_function (const struct block *bl) -+{ -+ while (BLOCK_FUNCTION (bl) == NULL && BLOCK_SUPERBLOCK (bl) != NULL) -+ bl = BLOCK_SUPERBLOCK (bl); -+ -+ return BLOCK_FUNCTION (bl); -+} -+ - /* Return one if BL represents an inlined function. */ - - int -Index: gdb-6.8.50.20081128/gdb/block.h -=================================================================== ---- gdb-6.8.50.20081128.orig/gdb/block.h 2008-12-06 14:06:16.000000000 +0100 -+++ gdb-6.8.50.20081128/gdb/block.h 2008-12-06 21:39:56.000000000 +0100 -@@ -133,6 +133,7 @@ struct blockvector - enum { GLOBAL_BLOCK = 0, STATIC_BLOCK = 1, FIRST_LOCAL_BLOCK = 2 }; - - extern struct symbol *block_linkage_function (const struct block *); -+extern struct symbol *block_function (const struct block *bl); - - extern int block_inlined_p (const struct block *block); - -Index: gdb-6.8.50.20081128/gdb/blockframe.c -=================================================================== ---- gdb-6.8.50.20081128.orig/gdb/blockframe.c 2008-12-06 14:06:16.000000000 +0100 -+++ gdb-6.8.50.20081128/gdb/blockframe.c 2008-12-06 21:39:56.000000000 +0100 -@@ -143,7 +143,7 @@ find_pc_sect_function (CORE_ADDR pc, str - struct block *b = block_for_pc_sect (pc, section); - if (b == 0) - return 0; -- return block_linkage_function (b); -+ return block_function (b); - } - - /* Return the function containing pc value PC. -Index: gdb-6.8.50.20081128/gdb/breakpoint.c -=================================================================== ---- gdb-6.8.50.20081128.orig/gdb/breakpoint.c 2008-12-06 14:06:17.000000000 +0100 -+++ gdb-6.8.50.20081128/gdb/breakpoint.c 2008-12-06 21:39:56.000000000 +0100 -@@ -5712,7 +5712,7 @@ resolve_sal_pc (struct symtab_and_line * - bv = blockvector_for_pc_sect (sal->pc, 0, &b, sal->symtab); - if (bv != NULL) - { -- sym = block_linkage_function (b); -+ sym = block_function (b); - if (sym != NULL) - { - fixup_symbol_section (sym, sal->symtab->objfile); -Index: gdb-6.8.50.20081128/gdb/testsuite/gdb.opt/inline-cmds.exp -=================================================================== ---- gdb-6.8.50.20081128.orig/gdb/testsuite/gdb.opt/inline-cmds.exp 2008-12-06 21:37:27.000000000 +0100 -+++ gdb-6.8.50.20081128/gdb/testsuite/gdb.opt/inline-cmds.exp 2008-12-06 21:41:37.000000000 +0100 -@@ -45,8 +45,10 @@ if { [skip_inline_frame_tests] } { - - # First, check that the things we expected to be inlined really were, - # and those that shouldn't be weren't. --set line1 [gdb_get_line_number "set breakpoint 1 here" ${srcfile2}] --gdb_breakpoint $srcfile2:$line1 -+# We test also inlining by the function name, otherwise we would use: -+# set line1 [gdb_get_line_number "set breakpoint 1 here" ${srcfile2}] -+# gdb_breakpoint $srcfile2:$line1 -+gdb_breakpoint "bar" - set line2 [gdb_get_line_number "set breakpoint 2 here" ${srcfile2}] - gdb_breakpoint $srcfile2:$line2 - diff --git a/gdb-7.0-upstream.patch b/gdb-7.0-upstream.patch deleted file mode 100644 index 4f466c7..0000000 --- a/gdb-7.0-upstream.patch +++ /dev/null @@ -1,627 +0,0 @@ -### ./gdb/ChangeLog 6 Oct 2009 16:32:30 -0000 1.10874.2.46 -### ./gdb/ChangeLog 22 Oct 2009 20:31:36 -0000 1.10874.2.52 -## -1,3 +1,33 @@ -+2009-10-22 Paul Pluzhnikov -+ -+ PR gdb/10819 -+ * dwarf2-frame.c (find_cie): Don't call bsearch on empty cie_table. -+ * objfiles.c (find_pc_section): Likewise. -+ (update_section_map): Don't allocate empty table. -+ -+2009-10-19 Don Lee -+ -+ * score-tdep.c: Delete some simulator dependent codes. -+ * score-tdep.h: Delete some simulator dependent macro definitions. -+ -+2008-10-16 Steven G. Kargl (tiny patch) -+ -+ * amd64fbsd-nat.c (amd64fbsd_supply_pcb): Conditionally compile in -+ support for pcb->pcb_{fs,ds,es,gs} on FreeBSD older than 8.0. -+ -+2009-10-08 Paul Pluzhnikov -+ -+ PR gdb/10457 -+ * elfread.c (elf_symtab_read): Don't use alloca in a loop. -+ -+2009-10-06 Joel Brobecker -+ -+ * version.in: Set version to 7.0.0.20091006-cvs. -+ -+2009-10-06 Joel Brobecker -+ -+ GDB 7.0 released. -+ - 2009-10-06 Joel Brobecker - - * NEWS: Change "Changes since GDB 6.8" into "Changes in GDB 7.0". ---- ./gdb/amd64fbsd-nat.c 3 Jan 2009 05:57:50 -0000 1.22 -+++ ./gdb/amd64fbsd-nat.c 17 Oct 2009 04:19:19 -0000 1.22.4.1 -@@ -95,6 +95,7 @@ static int amd64fbsd32_r_reg_offset[I386 - - #include - #include -+#include - - #include "bsd-kvm.h" - -@@ -123,10 +124,12 @@ amd64fbsd_supply_pcb (struct regcache *r - regcache_raw_supply (regcache, 13, &pcb->pcb_r13); - regcache_raw_supply (regcache, 14, &pcb->pcb_r14); - regcache_raw_supply (regcache, 15, &pcb->pcb_r15); -+#if (__FreeBSD_version < 800075) - regcache_raw_supply (regcache, AMD64_DS_REGNUM, &pcb->pcb_ds); - regcache_raw_supply (regcache, AMD64_ES_REGNUM, &pcb->pcb_es); - regcache_raw_supply (regcache, AMD64_FS_REGNUM, &pcb->pcb_fs); - regcache_raw_supply (regcache, AMD64_GS_REGNUM, &pcb->pcb_gs); -+#endif - - return 1; - } ---- ./gdb/dwarf2-frame.c 15 Sep 2009 16:20:53 -0000 1.99 -+++ ./gdb/dwarf2-frame.c 22 Oct 2009 20:31:36 -0000 1.99.2.1 -@@ -1525,6 +1525,14 @@ find_cie (struct dwarf2_cie_table *cie_t - { - struct dwarf2_cie **p_cie; - -+ /* The C standard (ISO/IEC 9899:TC2) requires the BASE argument to -+ bsearch be non-NULL. */ -+ if (cie_table->entries == NULL) -+ { -+ gdb_assert (cie_table->num_entries == 0); -+ return NULL; -+ } -+ - p_cie = bsearch (&cie_pointer, cie_table->entries, cie_table->num_entries, - sizeof (cie_table->entries[0]), bsearch_cie_cmp); - if (p_cie != NULL) ---- ./gdb/elfread.c 30 Apr 2009 21:59:03 -0000 1.77 -+++ ./gdb/elfread.c 8 Oct 2009 17:42:10 -0000 1.77.4.1 -@@ -535,7 +535,7 @@ elf_symtab_read (struct objfile *objfile - - if (len > 4 && strcmp (sym->name + len - 4, "@plt") == 0) - { -- char *base_name = alloca (len - 4 + 1); -+ char *base_name = xmalloc (len - 4 + 1); - struct minimal_symbol *mtramp; - - memcpy (base_name, sym->name, len - 4); -@@ -543,6 +543,7 @@ elf_symtab_read (struct objfile *objfile - mtramp = record_minimal_symbol (base_name, symaddr, - mst_solib_trampoline, - sym->section, objfile); -+ xfree (base_name); - if (mtramp) - { - MSYMBOL_SIZE (mtramp) = MSYMBOL_SIZE (msym); ---- ./gdb/objfiles.c 18 Sep 2009 17:39:36 -0000 1.96.2.1 -+++ ./gdb/objfiles.c 22 Oct 2009 20:31:36 -0000 1.96.2.2 -@@ -1045,6 +1045,14 @@ update_section_map (struct obj_section * - if (insert_section_p (objfile->obfd, s->the_bfd_section)) - alloc_size += 1; - -+ /* This happens on detach/attach (e.g. in gdb.base/attach.exp). */ -+ if (alloc_size == 0) -+ { -+ *pmap = NULL; -+ *pmap_size = 0; -+ return; -+ } -+ - map = xmalloc (alloc_size * sizeof (*map)); - - i = 0; -@@ -1105,6 +1113,14 @@ find_pc_section (CORE_ADDR pc) - objfiles_changed_p = 0; - } - -+ /* The C standard (ISO/IEC 9899:TC2) requires the BASE argument to -+ bsearch be non-NULL. */ -+ if (sections == NULL) -+ { -+ gdb_assert (num_sections == 0); -+ return NULL; -+ } -+ - sp = (struct obj_section **) bsearch (&pc, sections, num_sections, - sizeof (*sections), bsearch_cmp); - if (sp != NULL) ---- ./gdb/score-tdep.c 6 Aug 2009 10:28:38 -0000 1.21 -+++ ./gdb/score-tdep.c 19 Oct 2009 09:02:18 -0000 1.21.2.1 -@@ -56,58 +56,6 @@ struct score_frame_cache - - static int target_mach = bfd_mach_score7; - --#if WITH_SIM --int --score_target_can_use_watch (int type, int cnt, int othertype) --{ -- if (strcmp (current_target.to_shortname, "sim") == 0) -- return soc_gh_can_use_watch (type, cnt); -- return (*current_target.to_can_use_hw_breakpoint) (type, cnt, othertype); --} -- --int --score_stopped_by_watch (void) --{ -- if (strcmp (current_target.to_shortname, "sim") == 0) -- return soc_gh_stopped_by_watch (); -- return (*current_target.to_stopped_by_watchpoint) (); --} -- --int --score_target_insert_watchpoint (CORE_ADDR addr, int len, int type) --{ -- if (strcmp (current_target.to_shortname, "sim") == 0) -- return soc_gh_add_watch (addr, len, type); -- return (*current_target.to_insert_watchpoint) (addr, len, type); --} -- --int --score_target_remove_watchpoint (CORE_ADDR addr, int len, int type) --{ -- if (strcmp (current_target.to_shortname, "sim") == 0) -- return soc_gh_del_watch (addr, len, type); -- return (*current_target.to_remove_watchpoint) (addr, len, type); --} -- --int --score_target_insert_hw_breakpoint (struct gdbarch *gdbarch, -- struct bp_target_info * bp_tgt) --{ -- if (strcmp (current_target.to_shortname, "sim") == 0) -- return soc_gh_add_hardbp (bp_tgt->placed_address); -- return (*current_target.to_insert_hw_breakpoint) (gdbarch, bp_tgt); --} -- --int --score_target_remove_hw_breakpoint (struct gdbarch *gdbarch, -- struct bp_target_info * bp_tgt) --{ -- if (strcmp (current_target.to_shortname, "sim") == 0) -- return soc_gh_del_hardbp (bp_tgt->placed_address); -- return (*current_target.to_remove_hw_breakpoint) (gdbarch, bp_tgt); --} --#endif -- - static struct type * - score_register_type (struct gdbarch *gdbarch, int regnum) - { ---- ./gdb/score-tdep.h 6 Aug 2009 10:28:38 -0000 1.6 -+++ ./gdb/score-tdep.h 19 Oct 2009 09:02:18 -0000 1.6.2.1 -@@ -85,68 +85,4 @@ struct pt_regs { - - typedef struct pt_regs elf_gregset_t; - --#ifdef WITH_SIM -- --#include -- --int soc_gh_can_use_watch(int type, int cnt); --int soc_gh_add_watch(unsigned int addr, int len, int type); --int soc_gh_del_watch(unsigned int addr, int len, int type); --int soc_gh_stopped_by_watch(void); --int soc_gh_add_hardbp(unsigned int addr); --int soc_gh_del_hardbp(unsigned int addr); -- --int score_target_can_use_watch(int type, int cnt, int ot); --int score_stopped_by_watch(void); --int score_target_insert_watchpoint (CORE_ADDR addr, int len, int type); --int score_target_remove_watchpoint (CORE_ADDR addr, int len, int type); --int score_target_insert_hw_breakpoint (struct gdbarch *gdbarch, struct bp_target_info * bp_tgt); --int score_target_remove_hw_breakpoint (struct gdbarch *gdbarch, struct bp_target_info * bp_tgt); -- --#define TARGET_HAS_HARDWARE_WATCHPOINTS -- --#ifdef TARGET_CAN_USE_HARDWARE_WATCHPOINT --#undef TARGET_CAN_USE_HARDWARE_WATCHPOINT -- --#define TARGET_CAN_USE_HARDWARE_WATCHPOINT(type, cnt, ot) \ -- score_target_can_use_watch(type, cnt, ot) --#endif -- --#ifdef STOPPED_BY_WATCHPOINT --#undef STOPPED_BY_WATCHPOINT -- --#define STOPPED_BY_WATCHPOINT(w) \ -- score_stopped_by_watch() --#endif -- --#ifdef target_insert_watchpoint --#undef target_insert_watchpoint -- --#define target_insert_watchpoint(addr, len, type) \ -- score_target_insert_watchpoint (addr, len, type) --#endif -- --#ifdef target_remove_watchpoint --#undef target_remove_watchpoint -- --#define target_remove_watchpoint(addr, len, type) \ -- score_target_remove_watchpoint (addr, len, type) --#endif -- --#ifdef target_insert_hw_breakpoint --#undef target_insert_hw_breakpoint -- --#define target_insert_hw_breakpoint(gdbarch, bp_tgt) \ -- score_target_insert_hw_breakpoint (gdbarch, bp_tgt) --#endif -- --#ifdef target_remove_hw_breakpoint --#undef target_remove_hw_breakpoint -- --#define target_remove_hw_breakpoint(gdbarch, bp_tgt) \ -- score_target_remove_hw_breakpoint (gdbarch, bp_tgt) --#endif -- --#endif /* WITH_SIM */ -- - #endif /* SCORE_TDEP_H */ -### ./gdb/version.in 6 Oct 2009 16:25:13 -0000 1.2997.2.26 -### ./gdb/version.in 30 Oct 2009 00:00:33 -0000 1.2997.2.51 -## -1 +1 @@ --7.0 -+7.0.0.20091030-cvs - - - -http://sourceware.org/ml/gdb-patches/2009-11/msg00594.html -http://sourceware.org/ml/gdb-cvs/2009-11/msg00233.html -Subject: [patch] testsuite: bigcore.exp fuzzy PASS message fix - -Hi, - -seen needlessly fuzzy results: - -PASS: gdb.base/bigcore.exp: extract next heap (stop at 50) - -PASS: gdb.base/bigcore.exp: extract prev heap (stop at 50) - +PASS: gdb.base/bigcore.exp: extract next heap - +PASS: gdb.base/bigcore.exp: extract prev heap - -but the .exp file just is not patient enough: - -Total of 4292375328 (0xffd87320) bytes bytes 53 chunks - +Total of 4292422432 (0xffd92b20) bytes bytes 41 chunks - -Increased to 200. Tested on {x86_64,x86_64-m32}-fedora12-linux-gnu. - - -Thanks, -Jan - - -gdb/testsuite/ -2009-11-29 Jan Kratochvil - - * gdb.base/bigcore.exp (extract_heap): Set $lim limit to 200. - ---- a/gdb/testsuite/gdb.base/bigcore.exp -+++ b/gdb/testsuite/gdb.base/bigcore.exp -@@ -96,7 +96,7 @@ proc extract_heap { dir } { - } - -re " = \\(struct list \\*\\) (0x\[0-9a-f\]*).*$gdb_prompt $" { - set heap [concat $heap $expect_out(1,string)] -- if { $lim >= 50 } { -+ if { $lim >= 200 } { - pass "$test (stop at $lim)" - } else { - incr lim - - - -http://sourceware.org/ml/gdb-patches/2009-11/msg00593.html -http://sourceware.org/ml/gdb-cvs/2009-12/msg00013.html -Subject: [patch] testcase: Fix spurious structs.exp FAILs - -Hi, - -There were some rare unreproducible fuzzy FAILs seen on i386 (32-bit) inferiors: - - return foo2 - The location at which to store the function's return value is unknown. - If you continue, the return value that you specified will be ignored. - Make fun2 return now? (y or n) y - #0 main () at /rpmbuild/BUILD/gdb-7.0/gdb/testsuite/gdb.base/structs.c:435 - 435 L2 = fun2(); - (gdb) next - 436 L3 = fun3(); - (gdb) PASS: gdb.base/structs.exp: return foo; return 2 structs-tf-td - p/c L2 --$4 = {a = -16 '\360', b = 0 '\000'} --(gdb) PASS: gdb.base/structs.exp: value foo returned; return 2 structs-tf-td -+$4 = {a = 44 ',', b = 0 '\000'} -+(gdb) FAIL: gdb.base/structs.exp: value foo returned; return 2 structs-tf-td - -Apparently - a = 44 ',', -does not match - a = \[^,\}\]*, -which is needed for cases where L2 (L*) remains uninitialized with random -content. - -Alternative patch would just use regex `.*' and the whole new `chartest' and -`anychar_re' parts can be dropped. - -Formerly 9s, now 11s, without the $first optimization it would cost 47s. - -Testcase has been run on {x86_64,x86_64-m32}-fedora12-linux-gnu. - - -Thanks, -Jan - - -gdb/testsuite/ -2009-11-29 Jan Kratochvil - - Fix spurious false FAILs. - * gdb.base/structs.c (chartest): New. - (main): Fill-in chartest. - * gdb.base/structs.exp (anychar_re, first): New. - (start_structs_test): Import global anychar_re and first. - New gdb_test call "set print elements 300; ${testfile}" - (start_structs_test <$first>): New block. - (any): Import global anychar_re. New variable ac. Use ${ac}. - ---- a/gdb/testsuite/gdb.base/structs.c -+++ b/gdb/testsuite/gdb.base/structs.c -@@ -396,6 +396,8 @@ zed () - L18.r = 'Z'; - } - -+static struct { char c; } chartest[256]; -+ - int main() - { - #ifdef usestubs -@@ -404,6 +406,10 @@ int main() - #endif - int i; - -+ for (i = 0; i < 256; i++) -+ chartest[i].c = i; -+ chartest[0].c = 0; /* chartest-done */ -+ - Fun1(foo1); - Fun2(foo2); - Fun3(foo3); ---- a/gdb/testsuite/gdb.base/structs.exp -+++ b/gdb/testsuite/gdb.base/structs.exp -@@ -36,6 +36,9 @@ set testfile "structs" - set srcfile ${testfile}.c - set binfile ${objdir}/${subdir}/${testfile} - -+# Regex matching any value of `char' type like: a = 65 'A' -+set anychar_re {-?[0-9]{1,3} '(.|\\([0-7]{3}|[a-z]|\\|'))'} -+ - # Create and source the file that provides information about the - # compiler used to compile the test case. - -@@ -48,6 +51,7 @@ if [get_compiler_info ${binfile}] { - # the last TYPES field). Run the compmiled program up to "main". - # Also updates the global "testfile" to reflect the most recent build. - -+set first 1 - proc start_structs_test { types } { - global testfile - global srcfile -@@ -56,6 +60,8 @@ proc start_structs_test { types } { - global subdir - global srcdir - global gdb_prompt -+ global anychar_re -+ global first - - # Create the additional flags - set flags "debug" -@@ -91,6 +97,8 @@ proc start_structs_test { types } { - "set print address off; ${testfile}" - gdb_test "set width 0" "" \ - "set width 0; ${testfile}" -+ gdb_test "set print elements 300" "" \ -+ "set print elements 300; ${testfile}" - - # Advance to main - if { ![runto_main] } then { -@@ -100,6 +108,16 @@ proc start_structs_test { types } { - # Get the debug format - get_debug_format - -+ # Limit the slow $anychar_re{256} matching for better performance. -+ if $first { -+ set first 0 -+ -+ # Verify $anychar_re can match all the values of `char' type. -+ gdb_breakpoint [gdb_get_line_number "chartest-done"] -+ gdb_continue_to_breakpoint "chartest-done" ".*chartest-done.*" -+ gdb_test "p chartest" "= {({c = ${anychar_re}}, ){255}{c = ${anychar_re}}}" -+ } -+ - # check that at the struct containing all the relevant types is correct - set foo_t "type = struct struct[llength ${types}] \{" - for {set n 0} {$n<[llength ${types}]} {incr n} { -@@ -161,26 +179,28 @@ proc zed { n } { - } - - proc any { n } { -- return [lindex { -- "{}" -- "{a = \[^,\}\]*}" -- "{a = \[^,\}\]*, b = \[^,\}\]*}" -- "{a = \[^,\}\]*, b = \[^,\}\]*, c = \[^,\}\]*}" -- "{a = \[^,\}\]*, b = \[^,\}\]*, c = \[^,\}\]*, d = \[^,\}\]*}" -- "{a = \[^,\}\]*, b = \[^,\}\]*, c = \[^,\}\]*, d = \[^,\}\]*, e = \[^,\}\]*}" -- "{a = \[^,\}\]*, b = \[^,\}\]*, c = \[^,\}\]*, d = \[^,\}\]*, e = \[^,\}\]*, f = \[^,\}\]*}" -- "{a = \[^,\}\]*, b = \[^,\}\]*, c = \[^,\}\]*, d = \[^,\}\]*, e = \[^,\}\]*, f = \[^,\}\]*, g = \[^,\}\]*}" -- "{a = \[^,\}\]*, b = \[^,\}\]*, c = \[^,\}\]*, d = \[^,\}\]*, e = \[^,\}\]*, f = \[^,\}\]*, g = \[^,\}\]*, h = \[^,\}\]*}" -- "{a = \[^,\}\]*, b = \[^,\}\]*, c = \[^,\}\]*, d = \[^,\}\]*, e = \[^,\}\]*, f = \[^,\}\]*, g = \[^,\}\]*, h = \[^,\}\]*, i = \[^,\}\]*}" -- "{a = \[^,\}\]*, b = \[^,\}\]*, c = \[^,\}\]*, d = \[^,\}\]*, e = \[^,\}\]*, f = \[^,\}\]*, g = \[^,\}\]*, h = \[^,\}\]*, i = \[^,\}\]*, j = \[^,\}\]*}" -- "{a = \[^,\}\]*, b = \[^,\}\]*, c = \[^,\}\]*, d = \[^,\}\]*, e = \[^,\}\]*, f = \[^,\}\]*, g = \[^,\}\]*, h = \[^,\}\]*, i = \[^,\}\]*, j = \[^,\}\]*, k = \[^,\}\]*}" -- "{a = \[^,\}\]*, b = \[^,\}\]*, c = \[^,\}\]*, d = \[^,\}\]*, e = \[^,\}\]*, f = \[^,\}\]*, g = \[^,\}\]*, h = \[^,\}\]*, i = \[^,\}\]*, j = \[^,\}\]*, k = \[^,\}\]*, l = \[^,\}\]*}" -- "{a = \[^,\}\]*, b = \[^,\}\]*, c = \[^,\}\]*, d = \[^,\}\]*, e = \[^,\}\]*, f = \[^,\}\]*, g = \[^,\}\]*, h = \[^,\}\]*, i = \[^,\}\]*, j = \[^,\}\]*, k = \[^,\}\]*, l = \[^,\}\]*, m = \[^,\}\]*}" -- "{a = \[^,\}\]*, b = \[^,\}\]*, c = \[^,\}\]*, d = \[^,\}\]*, e = \[^,\}\]*, f = \[^,\}\]*, g = \[^,\}\]*, h = \[^,\}\]*, i = \[^,\}\]*, j = \[^,\}\]*, k = \[^,\}\]*, l = \[^,\}\]*, m = \[^,\}\]*, n = \[^,\}\]*}" -- "{a = \[^,\}\]*, b = \[^,\}\]*, c = \[^,\}\]*, d = \[^,\}\]*, e = \[^,\}\]*, f = \[^,\}\]*, g = \[^,\}\]*, h = \[^,\}\]*, i = \[^,\}\]*, j = \[^,\}\]*, k = \[^,\}\]*, l = \[^,\}\]*, m = \[^,\}\]*, n = \[^,\}\]*, o = \[^,\}\]*}" -- "{a = \[^,\}\]*, b = \[^,\}\]*, c = \[^,\}\]*, d = \[^,\}\]*, e = \[^,\}\]*, f = \[^,\}\]*, g = \[^,\}\]*, h = \[^,\}\]*, i = \[^,\}\]*, j = \[^,\}\]*, k = \[^,\}\]*, l = \[^,\}\]*, m = \[^,\}\]*, n = \[^,\}\]*, o = \[^,\}\]*, p = \[^,\}\]*}" -- "{a = \[^,\}\]*, b = \[^,\}\]*, c = \[^,\}\]*, d = \[^,\}\]*, e = \[^,\}\]*, f = \[^,\}\]*, g = \[^,\}\]*, h = \[^,\}\]*, i = \[^,\}\]*, j = \[^,\}\]*, k = \[^,\}\]*, l = \[^,\}\]*, m = \[^,\}\]*, n = \[^,\}\]*, o = \[^,\}\]*, p = \[^,\}\]*, q = \[^,\}\]*}" -- } $n] -+ global anychar_re -+ set ac $anychar_re -+ return [lindex [list \ -+ "{}" \ -+ "{a = ${ac}}" \ -+ "{a = ${ac}, b = ${ac}}" \ -+ "{a = ${ac}, b = ${ac}, c = ${ac}}" \ -+ "{a = ${ac}, b = ${ac}, c = ${ac}, d = ${ac}}" \ -+ "{a = ${ac}, b = ${ac}, c = ${ac}, d = ${ac}, e = ${ac}}" \ -+ "{a = ${ac}, b = ${ac}, c = ${ac}, d = ${ac}, e = ${ac}, f = ${ac}}" \ -+ "{a = ${ac}, b = ${ac}, c = ${ac}, d = ${ac}, e = ${ac}, f = ${ac}, g = ${ac}}" \ -+ "{a = ${ac}, b = ${ac}, c = ${ac}, d = ${ac}, e = ${ac}, f = ${ac}, g = ${ac}, h = ${ac}}" \ -+ "{a = ${ac}, b = ${ac}, c = ${ac}, d = ${ac}, e = ${ac}, f = ${ac}, g = ${ac}, h = ${ac}, i = ${ac}}" \ -+ "{a = ${ac}, b = ${ac}, c = ${ac}, d = ${ac}, e = ${ac}, f = ${ac}, g = ${ac}, h = ${ac}, i = ${ac}, j = ${ac}}" \ -+ "{a = ${ac}, b = ${ac}, c = ${ac}, d = ${ac}, e = ${ac}, f = ${ac}, g = ${ac}, h = ${ac}, i = ${ac}, j = ${ac}, k = ${ac}}" \ -+ "{a = ${ac}, b = ${ac}, c = ${ac}, d = ${ac}, e = ${ac}, f = ${ac}, g = ${ac}, h = ${ac}, i = ${ac}, j = ${ac}, k = ${ac}, l = ${ac}}" \ -+ "{a = ${ac}, b = ${ac}, c = ${ac}, d = ${ac}, e = ${ac}, f = ${ac}, g = ${ac}, h = ${ac}, i = ${ac}, j = ${ac}, k = ${ac}, l = ${ac}, m = ${ac}}" \ -+ "{a = ${ac}, b = ${ac}, c = ${ac}, d = ${ac}, e = ${ac}, f = ${ac}, g = ${ac}, h = ${ac}, i = ${ac}, j = ${ac}, k = ${ac}, l = ${ac}, m = ${ac}, n = ${ac}}" \ -+ "{a = ${ac}, b = ${ac}, c = ${ac}, d = ${ac}, e = ${ac}, f = ${ac}, g = ${ac}, h = ${ac}, i = ${ac}, j = ${ac}, k = ${ac}, l = ${ac}, m = ${ac}, n = ${ac}, o = ${ac}}" \ -+ "{a = ${ac}, b = ${ac}, c = ${ac}, d = ${ac}, e = ${ac}, f = ${ac}, g = ${ac}, h = ${ac}, i = ${ac}, j = ${ac}, k = ${ac}, l = ${ac}, m = ${ac}, n = ${ac}, o = ${ac}, p = ${ac}}" \ -+ "{a = ${ac}, b = ${ac}, c = ${ac}, d = ${ac}, e = ${ac}, f = ${ac}, g = ${ac}, h = ${ac}, i = ${ac}, j = ${ac}, k = ${ac}, l = ${ac}, m = ${ac}, n = ${ac}, o = ${ac}, p = ${ac}, q = ${ac}}" \ -+ ] $n] - } - - # Given N (0..25), return the corresponding alphabetic letter in lower - - - -http://sourceware.org/ml/gdb-patches/2009-11/msg00573.html -http://sourceware.org/ml/gdb-cvs/2009-11/msg00232.html -Subject: [patch] testsuite fuzzy results fixup: foll-fork.exp - -Hi, - -one occasional timeout: - - (gdb) PASS: gdb.base/foll-fork.exp: default show parent follow, no catchpoints - next 2 --callee: 9949 - 25 if (pid == 0) /* set breakpoint here */ --(gdb) PASS: gdb.base/foll-fork.exp: default parent follow, no catchpoints -+(gdb) callee: 18747 -+FAIL: gdb.base/foll-fork.exp: (timeout) default parent follow, no catchpoints - -Dropped the strings as there is no "callee" string expectation in -foll-fork.exp. - - -and with glibc-debuginfo installed one gets: - -(gdb) break 39 -Reading in symbols for ../nptl/sysdeps/unix/sysv/linux/fork.c...done. -Breakpoint 12 at 0x3ad22a4876: file ../nptl/sysdeps/unix/sysv/linux/fork.c, line 39. -(gdb) FAIL: gdb.base/foll-fork.exp: unpatch child, breakpoint at exit call -+ -Breakpoint 12, __libc_fork () at ../nptl/sysdeps/unix/sysv/linux/fork.c:158 -158 fresetlockfiles (); -(gdb) FAIL: gdb.base/foll-fork.exp: unpatch child, unpatched parent breakpoints from child (unknown output) - - -Thanks, -Jan - - -gdb/testsuite/ -2009-11-26 Jan Kratochvil - - * gdb.base/foll-fork.exp (unpatch child, breakpoint at exit call): - Force $srcfile file. - * gdb.base/foll-fork.c (callee): Comment out the printf call. - ---- a/gdb/testsuite/gdb.base/foll-fork.c -+++ b/gdb/testsuite/gdb.base/foll-fork.c -@@ -9,7 +9,8 @@ void callee (i) - int i; - #endif - { -- printf("callee: %d\n", i); -+ /* Any output corrupts GDB CLI expect strings. -+ printf("callee: %d\n", i); */ - } - - #ifdef PROTOTYPES ---- a/gdb/testsuite/gdb.base/foll-fork.exp -+++ b/gdb/testsuite/gdb.base/foll-fork.exp -@@ -240,7 +240,8 @@ proc catch_fork_unpatch_child {} { - # Delete all breakpoints and catchpoints. - delete_breakpoints - -- gdb_test "break $bp_exit" \ -+ # Force $srcfile as the current GDB source can be in glibc sourcetree. -+ gdb_test "break $srcfile:$bp_exit" \ - "Breakpoint .*file .*$srcfile, line .*" \ - "unpatch child, breakpoint at exit call" - - - - -http://sourceware.org/ml/gdb-patches/2009-11/msg00388.html -http://sourceware.org/ml/gdb-cvs/2009-11/msg00156.html -Subject: [patch] Fix crash on reading stabs - -Hi, - -there is a crash on reading stabs fpc binary: - https://bugzilla.redhat.com/show_bug.cgi?id=537837 - -Program received signal SIGSEGV, Segmentation fault. -0x000000000069db3d in read_dbx_symtab (objfile=0x1daf5f0) at dbxread.c:1369 -1369 if ((namestring[0] == '-' && namestring[1] == 'l') - -(gdb) p/x nlist.n_strx -$7 = 0xfffffff8 -(gdb) p sizeof(nlist.n_strx) -$10 = 8 - -Below the patch context is: - namestring = (nlist->n_strx + file_string_table_offset - + DBX_STRINGTAB (objfile)); - -so IMO the `(unsigned)' cast is excessive as it does not match the expression -below. Such cast is there since the GDB "Initial revision" (1999). - -`n_strx' type: -struct internal_nlist -{ - unsigned long n_strx; /* Index into string table of name. */ -... -}; - -Regression tested on {x86_64,x86_64-m32,i686}-fedora12-linux-gnu which does not -mean anything with the default DWARF debug info. It was hanging for stabs so -tried just a large part of gdb.base/*.exp on x86_64-m32 - `unix/-gstabs+/-m32'. - -If it isn't obviously approved please feel free to drop it as one should not -use STABS in the first place. - - -Regards, -Jan - - -gdb/ -2009-11-17 Jan Kratochvil - - * dbxread.c (set_namestring): Remove cast to unsigned. Check N_STRX - overflow. - ---- a/gdb/dbxread.c -+++ b/gdb/dbxread.c -@@ -965,8 +965,9 @@ set_namestring (struct objfile *objfile, const struct internal_nlist *nlist) - { - char *namestring; - -- if (((unsigned) nlist->n_strx + file_string_table_offset) -- >= DBX_STRINGTAB_SIZE (objfile)) -+ if (nlist->n_strx + file_string_table_offset -+ >= DBX_STRINGTAB_SIZE (objfile) -+ || nlist->n_strx + file_string_table_offset < nlist->n_strx) - { - complaint (&symfile_complaints, _("bad string table offset in symbol %d"), - symnum); - diff --git a/gdb-archer-ada.patch b/gdb-archer-ada.patch new file mode 100644 index 0000000..128112b --- /dev/null +++ b/gdb-archer-ada.patch @@ -0,0 +1,23 @@ +From: Keith Seitz +Message-ID: <4B7F207A.7020102@redhat.com> + +[ read_partial_die part dropped in the port to Rawhide ] + +--- gdb-7.0.1-orig/gdb/dwarf2read.c 2010-02-20 01:06:44.000000000 +0100 ++++ gdb-7.0.1/gdb/dwarf2read.c 2010-02-20 01:08:28.000000000 +0100 +@@ -9924,9 +9928,13 @@ dwarf2_canonicalize_name (char *name, st + static char * + dwarf2_name (struct die_info *die, struct dwarf2_cu *cu) + { +- struct attribute *attr; ++ struct attribute *attr = NULL; ++ ++ if (cu->language == language_ada) ++ attr = dwarf2_attr (die, DW_AT_MIPS_linkage_name, cu); + +- attr = dwarf2_attr (die, DW_AT_name, cu); ++ if (!attr) ++ attr = dwarf2_attr (die, DW_AT_name, cu); + if (!attr || !DW_STRING (attr)) + return NULL; + diff --git a/gdb-archer-next-over-throw-cxx-exec.patch b/gdb-archer-next-over-throw-cxx-exec.patch new file mode 100644 index 0000000..cbd9a36 --- /dev/null +++ b/gdb-archer-next-over-throw-cxx-exec.patch @@ -0,0 +1,85 @@ +Archer-upstreamed: +http://sourceware.org/ml/archer/2010-q2/msg00031.html + +--- ./gdb/testsuite/gdb.cp/cxxexec.cc 1970-01-01 01:00:00.000000000 +0100 ++++ ./gdb/testsuite/gdb.cp/cxxexec.cc 2010-05-29 01:18:56.000000000 +0200 +@@ -0,0 +1,25 @@ ++/* This test script 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 ++ ++int ++main() ++{ ++ execlp ("true", "true", NULL); ++ return 1; ++} +--- ./gdb/testsuite/gdb.cp/cxxexec.exp 1970-01-01 01:00:00.000000000 +0100 ++++ ./gdb/testsuite/gdb.cp/cxxexec.exp 2010-05-29 01:29:25.000000000 +0200 +@@ -0,0 +1,51 @@ ++# 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_cplus_tests] } { continue } ++ ++set testfile cxxexec ++if { [prepare_for_testing ${testfile}.exp ${testfile} ${testfile}.cc {c++ debug}] } { ++ return -1 ++} ++ ++runto_main ++ ++# We could stop after `continue' again at `main'. ++delete_breakpoints ++ ++set test "p _Unwind_DebugHook" ++gdb_test_multiple $test $test { ++ -re " = .* 0x\[0-9a-f\].*\r\n$gdb_prompt $" { ++ pass $test ++ } ++ -re "\r\nNo symbol .*\r\n$gdb_prompt $" { ++ xfail $test ++ untested ${testfile}.exp ++ return -1 ++ } ++} ++ ++set test continue ++gdb_test_multiple $test $test { ++ -re "Cannot access memory at address 0x\[0-9a-f\]+\r\n$gdb_prompt $" { ++ fail $test ++ } ++ -re "\r\n$gdb_prompt $" { ++ pass $test ++ } ++} ++ ++# `info inferiors' can show on older GDBs. ++gdb_test "info threads" "info threads" "program finished" diff --git a/gdb-archer-pie-addons-keep-disabled.patch b/gdb-archer-pie-addons-keep-disabled.patch new file mode 100644 index 0000000..e81a8dd --- /dev/null +++ b/gdb-archer-pie-addons-keep-disabled.patch @@ -0,0 +1,83 @@ +Index: gdb-7.1.90.20100711/gdb/breakpoint.c +=================================================================== +--- gdb-7.1.90.20100711.orig/gdb/breakpoint.c 2010-07-12 23:07:33.000000000 +0200 ++++ gdb-7.1.90.20100711/gdb/breakpoint.c 2010-07-13 00:38:04.000000000 +0200 +@@ -10159,6 +10159,50 @@ update_breakpoint_locations (struct brea + update_global_location_list (1); + } + ++void ++breakpoints_relocate (struct objfile *objfile, struct section_offsets *delta) ++{ ++ struct bp_location *bl, **blp_tmp; ++ int changed = 0; ++ ++ gdb_assert (objfile->separate_debug_objfile_backlink == NULL); ++ ++ ALL_BP_LOCATIONS (bl, blp_tmp) ++ { ++ struct obj_section *osect; ++ ++ /* BL->SECTION can be correctly NULL for breakpoints with multiple ++ locations expanded through symtab. */ ++ ++ ALL_OBJFILE_OSECTIONS (objfile, osect) ++ { ++ CORE_ADDR relocated_address; ++ CORE_ADDR delta_offset; ++ ++ delta_offset = ANOFFSET (delta, osect->the_bfd_section->index); ++ if (delta_offset == 0) ++ continue; ++ relocated_address = bl->address + delta_offset; ++ ++ if (obj_section_addr (osect) <= relocated_address ++ && relocated_address < obj_section_endaddr (osect)) ++ { ++ if (bl->inserted) ++ remove_breakpoint (bl, mark_uninserted); ++ ++ bl->address += delta_offset; ++ bl->requested_address += delta_offset; ++ ++ changed = 1; ++ } ++ } ++ } ++ ++ if (changed) ++ qsort (bp_location, bp_location_count, sizeof (*bp_location), ++ bp_location_compare); ++} ++ + /* Reset a breakpoint given it's struct breakpoint * BINT. + The value we return ends up being the return value from catch_errors. + Unused in this case. */ +Index: gdb-7.1.90.20100711/gdb/breakpoint.h +=================================================================== +--- gdb-7.1.90.20100711.orig/gdb/breakpoint.h 2010-07-12 23:07:33.000000000 +0200 ++++ gdb-7.1.90.20100711/gdb/breakpoint.h 2010-07-13 00:37:34.000000000 +0200 +@@ -1088,4 +1088,7 @@ extern void check_tracepoint_command (ch + extern void start_rbreak_breakpoints (void); + extern void end_rbreak_breakpoints (void); + ++extern void breakpoints_relocate (struct objfile *objfile, ++ struct section_offsets *delta); ++ + #endif /* !defined (BREAKPOINT_H) */ +Index: gdb-7.1.90.20100711/gdb/objfiles.c +=================================================================== +--- gdb-7.1.90.20100711.orig/gdb/objfiles.c 2010-05-16 02:46:46.000000000 +0200 ++++ gdb-7.1.90.20100711/gdb/objfiles.c 2010-07-13 00:37:19.000000000 +0200 +@@ -834,6 +834,11 @@ objfile_relocate1 (struct objfile *objfi + obj_section_addr (s)); + } + ++ /* Final call of breakpoint_re_set can keep breakpoint locations disabled if ++ their addresses match. */ ++ if (objfile->separate_debug_objfile_backlink == NULL) ++ breakpoints_relocate (objfile, delta); ++ + /* Data changed. */ + return 1; + } diff --git a/gdb-archer-pie-addons.patch b/gdb-archer-pie-addons.patch index 387dfc1..4bcc4b4 100644 --- a/gdb-archer-pie-addons.patch +++ b/gdb-archer-pie-addons.patch @@ -1,6 +1,8 @@ ---- a/gdb/dwarf2read.c -+++ b/gdb/dwarf2read.c -@@ -5754,7 +5754,12 @@ read_common_block (struct die_info *die, struct dwarf2_cu *cu) +Index: gdb-7.1.90.20100711/gdb/dwarf2read.c +=================================================================== +--- gdb-7.1.90.20100711.orig/gdb/dwarf2read.c 2010-07-13 00:26:25.000000000 +0200 ++++ gdb-7.1.90.20100711/gdb/dwarf2read.c 2010-07-13 00:34:00.000000000 +0200 +@@ -5737,7 +5737,12 @@ read_common_block (struct die_info *die, { struct attribute *attr; struct symbol *sym; @@ -14,15 +16,15 @@ attr = dwarf2_attr (die, DW_AT_location, cu); if (attr) -@@ -5763,6 +5768,7 @@ read_common_block (struct die_info *die, struct dwarf2_cu *cu) +@@ -5746,6 +5751,7 @@ read_common_block (struct die_info *die, if (attr_form_is_block (attr)) - { - base = decode_locdesc (DW_BLOCK (attr), cu); + { + base = decode_locdesc (DW_BLOCK (attr), cu); + base_p = 1; - } + } else if (attr_form_is_section_offset (attr)) - { -@@ -5824,12 +5830,15 @@ read_common_block (struct die_info *die, struct dwarf2_cu *cu) + { +@@ -5807,12 +5813,15 @@ read_common_block (struct die_info *die, else dwarf2_complex_location_expr_complaint (); @@ -40,7 +42,7 @@ else SET_FIELD_PHYSNAME (*field, SYMBOL_LINKAGE_NAME (sym)); FIELD_TYPE (*field) = SYMBOL_TYPE (sym); -@@ -5843,7 +5852,7 @@ read_common_block (struct die_info *die, struct dwarf2_cu *cu) +@@ -5826,7 +5835,7 @@ read_common_block (struct die_info *die, sym = new_symbol (die, type, cu); /* SYMBOL_VALUE_ADDRESS never gets used as all its fields are static. */ @@ -49,64 +51,35 @@ set_die_type (die, type, cu); } ---- a/gdb/exec.c -+++ b/gdb/exec.c -@@ -32,6 +32,7 @@ - #include "exec.h" - #include "observer.h" - #include "arch-utils.h" -+#include "solib.h" - - #include - #include "readline/readline.h" -@@ -220,6 +221,10 @@ exec_file_attach (char *filename, int from_tty) - char *scratch_pathname; - int scratch_chan; - struct target_section *sections = NULL, *sections_end = NULL; -+ struct target_section *p; -+ int addr_bit; -+ CORE_ADDR mask = CORE_ADDR_MAX; -+ CORE_ADDR displacement; - - scratch_chan = openp (getenv ("PATH"), OPF_TRY_CWD_FIRST, filename, - write_files ? O_RDWR | O_BINARY : O_RDONLY | O_BINARY, -@@ -288,12 +293,23 @@ exec_file_attach (char *filename, int from_tty) - scratch_pathname, bfd_errmsg (bfd_get_error ())); - } - -+ set_gdbarch_from_file (exec_bfd); -+ -+ addr_bit = gdbarch_addr_bit (target_gdbarch); -+ if (addr_bit < (sizeof (CORE_ADDR) * HOST_CHAR_BIT)) -+ mask = ((CORE_ADDR) 1 << addr_bit) - 1; -+ -+ displacement = solib_exec_displacement (); -+ for (p = sections; p < sections_end; p++) -+ { -+ p->addr = (p->addr + displacement) & mask; -+ p->endaddr = (p->endaddr + displacement) & mask; -+ } -+ - exec_bfd_mtime = bfd_get_mtime (exec_bfd); - - validate_files (); - -- set_gdbarch_from_file (exec_bfd); -- - /* Add the executable's sections to the current address spaces' - list of sections. */ - add_target_sections (sections, sections_end); ---- a/gdb/gdbtypes.h -+++ b/gdb/gdbtypes.h -@@ -966,6 +966,7 @@ extern void allocate_cplus_struct_type (struct type *); +Index: gdb-7.1.90.20100711/gdb/gdbtypes.h +=================================================================== +--- gdb-7.1.90.20100711.orig/gdb/gdbtypes.h 2010-07-12 23:07:34.000000000 +0200 ++++ gdb-7.1.90.20100711/gdb/gdbtypes.h 2010-07-13 00:34:00.000000000 +0200 +@@ -395,6 +395,7 @@ enum type_instance_flag_value + enum field_loc_kind + { + FIELD_LOC_KIND_BITPOS, /* bitpos */ ++ /* This address is unrelocated by the objfile's ANOFFSET. */ + FIELD_LOC_KIND_PHYSADDR, /* physaddr */ + FIELD_LOC_KIND_PHYSNAME /* physname */ + }; +@@ -577,6 +578,7 @@ struct main_type + is the location (in the target) of the static field. + Otherwise, physname is the mangled label of the static field. */ + ++ /* This address is unrelocated by the objfile's ANOFFSET. */ + CORE_ADDR physaddr; + char *physname; + } +@@ -1073,6 +1075,7 @@ extern void allocate_gnat_aux_type (stru #define FIELD_LOC_KIND(thisfld) ((thisfld).loc_kind) #define FIELD_BITPOS(thisfld) ((thisfld).loc.bitpos) #define FIELD_STATIC_PHYSNAME(thisfld) ((thisfld).loc.physname) +/* This address is unrelocated by the objfile's ANOFFSET. */ #define FIELD_STATIC_PHYSADDR(thisfld) ((thisfld).loc.physaddr) - #define FIELD_DWARF_BLOCK(thisfld) ((thisfld).loc.dwarf_block) #define SET_FIELD_BITPOS(thisfld, bitpos) \ -@@ -974,6 +975,7 @@ extern void allocate_cplus_struct_type (struct type *); + (FIELD_LOC_KIND (thisfld) = FIELD_LOC_KIND_BITPOS, \ +@@ -1080,6 +1083,7 @@ extern void allocate_gnat_aux_type (stru #define SET_FIELD_PHYSNAME(thisfld, name) \ (FIELD_LOC_KIND (thisfld) = FIELD_LOC_KIND_PHYSNAME, \ FIELD_STATIC_PHYSNAME (thisfld) = (name)) @@ -114,17 +87,19 @@ #define SET_FIELD_PHYSADDR(thisfld, addr) \ (FIELD_LOC_KIND (thisfld) = FIELD_LOC_KIND_PHYSADDR, \ FIELD_STATIC_PHYSADDR (thisfld) = (addr)) -@@ -989,6 +991,7 @@ extern void allocate_cplus_struct_type (struct type *); +@@ -1092,6 +1096,7 @@ extern void allocate_gnat_aux_type (stru #define TYPE_FIELD_LOC_KIND(thistype, n) FIELD_LOC_KIND (TYPE_FIELD (thistype, n)) #define TYPE_FIELD_BITPOS(thistype, n) FIELD_BITPOS (TYPE_FIELD (thistype, n)) #define TYPE_FIELD_STATIC_PHYSNAME(thistype, n) FIELD_STATIC_PHYSNAME (TYPE_FIELD (thistype, n)) +/* This address is unrelocated by the objfile's ANOFFSET. */ #define TYPE_FIELD_STATIC_PHYSADDR(thistype, n) FIELD_STATIC_PHYSADDR (TYPE_FIELD (thistype, n)) - #define TYPE_FIELD_DWARF_BLOCK(thistype, n) FIELD_DWARF_BLOCK (TYPE_FIELD (thistype, n)) #define TYPE_FIELD_ARTIFICIAL(thistype, n) FIELD_ARTIFICIAL(TYPE_FIELD(thistype,n)) ---- a/gdb/jv-lang.c -+++ b/gdb/jv-lang.c -@@ -416,7 +416,8 @@ java_link_class_type (struct gdbarch *gdbarch, + #define TYPE_FIELD_BITSIZE(thistype, n) FIELD_BITSIZE(TYPE_FIELD(thistype,n)) +Index: gdb-7.1.90.20100711/gdb/jv-lang.c +=================================================================== +--- gdb-7.1.90.20100711.orig/gdb/jv-lang.c 2010-05-17 19:18:39.000000000 +0200 ++++ gdb-7.1.90.20100711/gdb/jv-lang.c 2010-07-13 00:34:00.000000000 +0200 +@@ -409,7 +409,8 @@ java_link_class_type (struct gdbarch *gd fields = NULL; nfields--; /* First set up dummy "class" field. */ @@ -134,7 +109,7 @@ TYPE_FIELD_NAME (type, nfields) = "class"; TYPE_FIELD_TYPE (type, nfields) = value_type (clas); SET_TYPE_FIELD_PRIVATE (type, nfields); -@@ -462,7 +463,8 @@ java_link_class_type (struct gdbarch *gdbarch, +@@ -457,7 +458,8 @@ java_link_class_type (struct gdbarch *gd SET_TYPE_FIELD_PROTECTED (type, i); } if (accflags & 0x0008) /* ACC_STATIC */ @@ -144,147 +119,27 @@ else TYPE_FIELD_BITPOS (type, i) = 8 * boffset; if (accflags & 0x8000) /* FIELD_UNRESOLVED_FLAG */ ---- a/gdb/solib-svr4.c -+++ b/gdb/solib-svr4.c -@@ -1621,7 +1621,10 @@ svr4_exec_displacement (void) - if (target_auxv_search (¤t_target, AT_ENTRY, &entry_point) == 1) - return entry_point - exec_entry_point (exec_bfd, ¤t_target); - -- return svr4_static_exec_displacement (); -+ if (!ptid_equal (inferior_ptid, null_ptid)) -+ return svr4_static_exec_displacement (); -+ -+ return 0; - } - - /* Relocate the main executable. This function should be called upon -@@ -1632,7 +1635,7 @@ svr4_exec_displacement (void) - static void - svr4_relocate_main_executable (void) - { -- CORE_ADDR displacement = svr4_exec_displacement (); -+ CORE_ADDR displacement = solib_exec_displacement (); - - /* Even if DISPLACEMENT is 0 still try to relocate it as this is a new - difference of in-memory vs. in-file addresses and we could already -@@ -1975,6 +1978,7 @@ _initialize_svr4_solib (void) - svr4_so_ops.free_so = svr4_free_so; - svr4_so_ops.clear_solib = svr4_clear_solib; - svr4_so_ops.solib_create_inferior_hook = svr4_solib_create_inferior_hook; -+ svr4_so_ops.exec_displacement = svr4_exec_displacement; - svr4_so_ops.special_symbol_handling = svr4_special_symbol_handling; - svr4_so_ops.current_sos = svr4_current_sos; - svr4_so_ops.open_symbol_file_object = open_symbol_file_object; ---- a/gdb/solib.c -+++ b/gdb/solib.c -@@ -1014,6 +1014,19 @@ solib_create_inferior_hook (int from_tty) - ops->solib_create_inferior_hook (from_tty); - } - -+/* Query the difference of in-memory VMA addresses vs. exec_bfd VMAs. */ -+ -+CORE_ADDR -+solib_exec_displacement (void) -+{ -+ struct target_so_ops *ops = solib_ops (target_gdbarch); -+ -+ if (ops->exec_displacement != NULL) -+ return (*ops->exec_displacement) (); -+ else -+ return 0; -+} -+ - /* GLOBAL FUNCTION - - in_solib_dynsym_resolve_code -- check to see if an address is in ---- a/gdb/solib.h -+++ b/gdb/solib.h -@@ -43,6 +43,8 @@ extern int solib_read_symbols (struct so_list *, int); - - extern void solib_create_inferior_hook (int from_tty); - -+extern CORE_ADDR solib_exec_displacement (void); -+ - /* If ADDR lies in a shared library, return its name. */ - - extern char *solib_name_from_address (CORE_ADDR); ---- a/gdb/solist.h -+++ b/gdb/solist.h -@@ -89,6 +89,9 @@ struct target_so_ops - /* Target dependent code to run after child process fork. */ - void (*solib_create_inferior_hook) (int from_tty); - -+ /* Query the difference of in-memory VMA addresses vs. exec_bfd VMAs. */ -+ CORE_ADDR (*exec_displacement) (void); -+ - /* Do additional symbol handling, lookup, etc. after symbols - for a shared object have been loaded. */ - void (*special_symbol_handling) (void); ---- a/gdb/symfile.c -+++ b/gdb/symfile.c -@@ -873,15 +873,36 @@ syms_from_objfile (struct objfile *objfile, - if an error occurs during symbol reading. */ - old_chain = make_cleanup_free_objfile (objfile); - -- /* If ADDRS and OFFSETS are both NULL, put together a dummy address -- list. We now establish the convention that an addr of zero means -- no load address was specified. */ -+ /* If ADDRS and OFFSETS are both NULL, put together a dummy offset list. */ -+ - if (! addrs && ! offsets) +Index: gdb-7.1.90.20100711/gdb/value.c +=================================================================== +--- gdb-7.1.90.20100711.orig/gdb/value.c 2010-07-12 23:07:33.000000000 +0200 ++++ gdb-7.1.90.20100711/gdb/value.c 2010-07-13 00:35:21.000000000 +0200 +@@ -1943,7 +1943,8 @@ value_static_field (struct type *type, i { -- local_addr -- = alloc_section_addr_info (bfd_count_sections (objfile->obfd)); -- make_cleanup (xfree, local_addr); -- addrs = local_addr; -+ /* Relocateble files have an exception in default_symfile_offsets which -+ applies only for ADDRS. But calling solib_exec_displacement is more -+ suitable for OFFSETS. Fortunately we never need the both -+ functionalities simultaneously and in other cases zeroed ADDRS and -+ zeroed OFFSETS are equivalent. */ -+ -+ if ((bfd_get_file_flags (objfile->obfd) & (EXEC_P | DYNAMIC)) == 0) -+ { -+ local_addr -+ = alloc_section_addr_info (bfd_count_sections (objfile->obfd)); -+ make_cleanup (xfree, local_addr); -+ addrs = local_addr; -+ } -+ else -+ { -+ CORE_ADDR displacement = 0; -+ int i; -+ -+ if (mainline) -+ displacement = solib_exec_displacement (); -+ -+ num_offsets = bfd_count_sections (objfile->obfd); -+ offsets = alloca (SIZEOF_N_SECTION_OFFSETS (num_offsets)); -+ for (i = 0; i < num_offsets; i++) -+ offsets->offsets[i] = displacement; -+ } - } - - /* Now either addrs or offsets is non-zero. */ ---- a/gdb/value.c -+++ b/gdb/value.c -@@ -1890,7 +1890,8 @@ value_static_field (struct type *type, int fieldno) - if (TYPE_FIELD_LOC_KIND (type, fieldno) == FIELD_LOC_KIND_PHYSADDR) - { - retval = value_at (TYPE_FIELD_TYPE (type, fieldno), -- TYPE_FIELD_STATIC_PHYSADDR (type, fieldno)); -+ TYPE_FIELD_STATIC_PHYSADDR (type, fieldno) -+ + (TYPE_OBJFILE (type) == NULL ? 0 : ANOFFSET (TYPE_OBJFILE (type)->section_offsets, SECT_OFF_TEXT (TYPE_OBJFILE (type))))); - } - else + case FIELD_LOC_KIND_PHYSADDR: + retval = value_at_lazy (TYPE_FIELD_TYPE (type, fieldno), +- TYPE_FIELD_STATIC_PHYSADDR (type, fieldno)); ++ TYPE_FIELD_STATIC_PHYSADDR (type, fieldno) ++ + (TYPE_OBJFILE (type) == NULL ? 0 : ANOFFSET (TYPE_OBJFILE (type)->section_offsets, SECT_OFF_TEXT (TYPE_OBJFILE (type))))); + break; + case FIELD_LOC_KIND_PHYSNAME: { -@@ -1920,7 +1921,8 @@ value_static_field (struct type *type, int fieldno) +@@ -1977,7 +1978,8 @@ value_static_field (struct type *type, i } if (retval && VALUE_LVAL (retval) == lval_memory) SET_FIELD_PHYSADDR (TYPE_FIELD (type, fieldno), - value_address (retval)); + value_address (retval) -+ - (TYPE_OBJFILE (type) == NULL ? 0 : ANOFFSET (TYPE_OBJFILE (type)->section_offsets, SECT_OFF_TEXT (TYPE_OBJFILE (type))))); ++ - (TYPE_OBJFILE (type) == NULL ? 0 : ANOFFSET (TYPE_OBJFILE (type)->section_offsets, SECT_OFF_TEXT (TYPE_OBJFILE (type))))); + break; } - return retval; - } + default: diff --git a/gdb-archer-pie.patch b/gdb-archer-pie.patch deleted file mode 100644 index 0c8aabb..0000000 --- a/gdb-archer-pie.patch +++ /dev/null @@ -1,2647 +0,0 @@ -http://sourceware.org/gdb/wiki/ProjectArcher -http://sourceware.org/gdb/wiki/ArcherBranchManagement - -archer-jankratochvil-pie-fedora12 -GIT snapshot: -commit 2ae60b5156d43aabfe5757940eaf7b4370fb05d2 - - -diff --git a/gdb/auxv.c b/gdb/auxv.c -index 7b4ecbe..7df8eb5 100644 ---- a/gdb/auxv.c -+++ b/gdb/auxv.c -@@ -25,6 +25,7 @@ - #include "inferior.h" - #include "valprint.h" - #include "gdb_assert.h" -+#include "gdbcore.h" - - #include "auxv.h" - #include "elf/common.h" -@@ -33,15 +34,11 @@ - #include - - --/* This function is called like a to_xfer_partial hook, but must be -- called with TARGET_OBJECT_AUXV. It handles access via -- /proc/PID/auxv, which is a common method for native targets. */ -+/* This function handles access via /proc/PID/auxv, which is a common method -+ for native targets. */ - --LONGEST --procfs_xfer_auxv (struct target_ops *ops, -- enum target_object object, -- const char *annex, -- gdb_byte *readbuf, -+static LONGEST -+procfs_xfer_auxv (gdb_byte *readbuf, - const gdb_byte *writebuf, - ULONGEST offset, - LONGEST len) -@@ -50,9 +47,6 @@ procfs_xfer_auxv (struct target_ops *ops, - int fd; - LONGEST n; - -- gdb_assert (object == TARGET_OBJECT_AUXV); -- gdb_assert (readbuf || writebuf); -- - pathname = xstrprintf ("/proc/%d/auxv", PIDGET (inferior_ptid)); - fd = open (pathname, writebuf != NULL ? O_WRONLY : O_RDONLY); - xfree (pathname); -@@ -72,6 +66,152 @@ procfs_xfer_auxv (struct target_ops *ops, - return n; - } - -+/* This function handles access via ld.so's symbol `_dl_auxv'. */ -+ -+static LONGEST -+ld_so_xfer_auxv (gdb_byte *readbuf, -+ const gdb_byte *writebuf, -+ ULONGEST offset, -+ LONGEST len) -+{ -+ struct minimal_symbol *msym; -+ CORE_ADDR data_address, pointer_address; -+ struct type *ptr_type = builtin_type (target_gdbarch)->builtin_data_ptr; -+ size_t ptr_size = TYPE_LENGTH (ptr_type); -+ size_t auxv_pair_size = 2 * ptr_size; -+ gdb_byte *ptr_buf = alloca (ptr_size); -+ LONGEST retval; -+ size_t block; -+ -+ msym = lookup_minimal_symbol ("_dl_auxv", NULL, NULL); -+ if (msym == NULL) -+ return -1; -+ -+ if (MSYMBOL_SIZE (msym) != ptr_size) -+ return -1; -+ -+ /* POINTER_ADDRESS is a location where the `_dl_auxv' variable resides. -+ DATA_ADDRESS is the inferior value present in `_dl_auxv', therefore the -+ real inferior AUXV address. */ -+ -+ pointer_address = SYMBOL_VALUE_ADDRESS (msym); -+ -+ data_address = read_memory_typed_address (pointer_address, ptr_type); -+ -+ /* Possibly still not initialized such as during an inferior startup. */ -+ if (data_address == 0) -+ return -1; -+ -+ data_address += offset; -+ -+ if (writebuf != NULL) -+ { -+ if (target_write_memory (data_address, writebuf, len) == 0) -+ return len; -+ else -+ return -1; -+ } -+ -+ /* Stop if trying to read past the existing AUXV block. The final AT_NULL -+ was already returned before. */ -+ -+ if (offset >= auxv_pair_size) -+ { -+ if (target_read_memory (data_address - auxv_pair_size, ptr_buf, -+ ptr_size) != 0) -+ return -1; -+ -+ if (extract_typed_address (ptr_buf, ptr_type) == AT_NULL) -+ return 0; -+ } -+ -+ retval = 0; -+ block = 0x400; -+ gdb_assert (block % auxv_pair_size == 0); -+ -+ while (len > 0) -+ { -+ if (block > len) -+ block = len; -+ -+ /* Reading sizes smaller than AUXV_PAIR_SIZE is not supported. Tails -+ unaligned to AUXV_PAIR_SIZE will not be read during a call (they -+ should be completed during next read with new/extended buffer). */ -+ -+ block &= -auxv_pair_size; -+ if (block == 0) -+ return retval; -+ -+ if (target_read_memory (data_address, readbuf, block) != 0) -+ { -+ if (block <= auxv_pair_size) -+ return retval; -+ -+ block = auxv_pair_size; -+ continue; -+ } -+ -+ data_address += block; -+ len -= block; -+ -+ /* Check terminal AT_NULL. This function is being called indefinitely -+ being extended its READBUF until it returns EOF (0). */ -+ -+ while (block >= auxv_pair_size) -+ { -+ retval += auxv_pair_size; -+ -+ if (extract_typed_address (readbuf, ptr_type) == AT_NULL) -+ return retval; -+ -+ readbuf += auxv_pair_size; -+ block -= auxv_pair_size; -+ } -+ } -+ -+ return retval; -+} -+ -+/* This function is called like a to_xfer_partial hook, but must be -+ called with TARGET_OBJECT_AUXV. It handles access to AUXV. */ -+ -+LONGEST -+memory_xfer_auxv (struct target_ops *ops, -+ enum target_object object, -+ const char *annex, -+ gdb_byte *readbuf, -+ const gdb_byte *writebuf, -+ ULONGEST offset, -+ LONGEST len) -+{ -+ /* Workaround gdb-7.0 bug where linux_nat_xfer_partial() does -+ inferior_ptid = pid_to_ptid (GET_LWP (inferior_ptid)); -+ and current_inferior() assertion fails not finding the LWP->PID. -+ It got fixed post-gdb-7.0 by: -+ Add base multi-executable/process support to GDB. -+ 40ff0a289e6165aa930af284df5c52162cb0cd5f -+ by introducing `current_inferior_'. */ -+ struct inferior *inf = find_inferior_pid (ptid_get_pid (inferior_ptid)); -+ -+ gdb_assert (object == TARGET_OBJECT_AUXV); -+ gdb_assert (readbuf || writebuf); -+ -+ /* ld_so_xfer_auxv is the only function safe for virtual executables being -+ executed by valgrind's memcheck. As using ld_so_xfer_auxv is problematic -+ during inferior startup GDB does call it only for attached processes. */ -+ -+ if (inf == NULL || inf->attach_flag != 0) -+ { -+ LONGEST retval; -+ -+ retval = ld_so_xfer_auxv (readbuf, writebuf, offset, len); -+ if (retval != -1) -+ return retval; -+ } -+ -+ return procfs_xfer_auxv (readbuf, writebuf, offset, len); -+} -+ - /* Read one auxv entry from *READPTR, not reading locations >= ENDPTR. - Return 0 if *READPTR is already at the end of the buffer. - Return -1 if there is insufficient buffer for a whole entry. -diff --git a/gdb/auxv.h b/gdb/auxv.h -index 71e6562..87c24ae 100644 ---- a/gdb/auxv.h -+++ b/gdb/auxv.h -@@ -43,11 +43,7 @@ extern int target_auxv_search (struct target_ops *ops, - /* Print the contents of the target's AUXV on the specified file. */ - extern int fprint_target_auxv (struct ui_file *file, struct target_ops *ops); - --/* This function is called like a to_xfer_partial hook, but must be -- called with TARGET_OBJECT_AUXV. It handles access via -- /proc/PID/auxv, which is a common method for native targets. */ -- --extern LONGEST procfs_xfer_auxv (struct target_ops *ops, -+extern LONGEST memory_xfer_auxv (struct target_ops *ops, - enum target_object object, - const char *annex, - gdb_byte *readbuf, -diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c -index 0f35101..bffc5a6 100644 ---- a/gdb/breakpoint.c -+++ b/gdb/breakpoint.c -@@ -4805,7 +4805,8 @@ disable_breakpoints_in_shlibs (void) - to insert those breakpoints and fail. */ - if (((b->type == bp_breakpoint) - || (b->type == bp_hardware_breakpoint) -- || (b->type == bp_tracepoint)) -+ || (b->type == bp_tracepoint) -+ || b->type == bp_shlib_event) - && !loc->shlib_disabled - #ifdef PC_SOLIB - && PC_SOLIB (loc->address) -diff --git a/gdb/defs.h b/gdb/defs.h -index 94674dc..57aaae2 100644 ---- a/gdb/defs.h -+++ b/gdb/defs.h -@@ -98,7 +98,20 @@ - /* A byte from the program being debugged. */ - typedef bfd_byte gdb_byte; - --/* An address in the program being debugged. Host byte order. */ -+/* An address in the program being debugged. Host byte order. -+ -+ Its width is the maximum width of all the supported targets. That means -+ 32-bit target will run on such GDB using 64-bit CORE_ADDR cluttering the -+ bits 32...63 with random data from internal GDB calculations. GDB currently -+ in general truncates the address width only when it is being presented/used -+ externally (such as by the paddress function). -+ -+ FIXME: This is still not right as any GDB internal comparisons (such as >=) -+ of CORE_ADDR do not use the properly truncated width. As converting all the -+ CORE_ADDR operations to width-aware functions is not feasible the way out -+ could be a width-aware C++ class CORE_ADDR referencing gdbarch as its -+ constructor parameter. */ -+ - typedef bfd_vma CORE_ADDR; - - /* The largest CORE_ADDR value. */ -diff --git a/gdb/exec.c b/gdb/exec.c -index 455151e..67f40d9 100644 ---- a/gdb/exec.c -+++ b/gdb/exec.c -@@ -656,8 +656,33 @@ print_section_info (struct target_section_table *t, bfd *abfd) - wrap_here (" "); - printf_filtered (_("file type %s.\n"), bfd_get_target (abfd)); - if (abfd == exec_bfd) -- printf_filtered (_("\tEntry point: %s\n"), -- paddress (gdbarch, bfd_get_start_address (abfd))); -+ { -+ bfd_vma displacement = 0; -+ -+ for (p = t->sections; p < t->sections_end; p++) -+ { -+ asection *asect = p->the_bfd_section; -+ -+ if ((bfd_get_section_flags (abfd, asect) & (SEC_ALLOC | SEC_LOAD)) -+ != (SEC_ALLOC | SEC_LOAD)) -+ continue; -+ -+ if (bfd_get_section_vma (abfd, asect) <= abfd->start_address -+ && abfd->start_address < bfd_get_section_vma (abfd, asect) -+ + bfd_get_section_size (asect)) -+ { -+ displacement = p->addr - bfd_get_section_vma (abfd, asect); -+ break; -+ } -+ } -+ if (p == t->sections_end) -+ warning (_("Cannot find section for the entry point of %s.\n"), -+ bfd_get_filename (abfd)); -+ -+ printf_filtered (_("\tEntry point: %s\n"), -+ paddress (gdbarch, bfd_get_start_address (abfd) -+ + displacement)); -+ } - for (p = t->sections; p < t->sections_end; p++) - { - printf_filtered ("\t%s", hex_string_custom (p->addr, wid)); -diff --git a/gdb/infcmd.c b/gdb/infcmd.c -index fab1892..fc0f05d 100644 ---- a/gdb/infcmd.c -+++ b/gdb/infcmd.c -@@ -395,22 +395,6 @@ post_create_inferior (struct target_ops *target, int from_tty) - /* Now that we know the register layout, retrieve current PC. */ - stop_pc = regcache_read_pc (get_current_regcache ()); - -- /* If the solist is global across processes, there's no need to -- refetch it here. */ -- if (exec_bfd && !gdbarch_has_global_solist (target_gdbarch)) -- { -- /* Sometimes the platform-specific hook loads initial shared -- libraries, and sometimes it doesn't. Try to do so first, so -- that we can add them with the correct value for FROM_TTY. -- If we made all the inferior hook methods consistent, -- this call could be removed. */ --#ifdef SOLIB_ADD -- SOLIB_ADD (NULL, from_tty, target, auto_solib_add); --#else -- solib_add (NULL, from_tty, target, auto_solib_add); --#endif -- } -- - if (exec_bfd) - { - /* Create the hooks to handle shared library load and unload -@@ -418,7 +402,25 @@ post_create_inferior (struct target_ops *target, int from_tty) - #ifdef SOLIB_CREATE_INFERIOR_HOOK - SOLIB_CREATE_INFERIOR_HOOK (PIDGET (inferior_ptid)); - #else -- solib_create_inferior_hook (); -+ solib_create_inferior_hook (from_tty); -+#endif -+ } -+ -+ /* If the solist is global across processes, there's no need to -+ refetch it here. */ -+ if (exec_bfd && !gdbarch_has_global_solist (target_gdbarch)) -+ { -+ /* Sometimes the platform-specific hook loads initial shared -+ libraries, and sometimes it doesn't. If it doesn't FROM_TTY will be -+ incorrectly 0 but such solib targets should be fixed anyway. If we -+ made all the inferior hook methods consistent, this call could be -+ removed. Call it only after the solib target has been initialized by -+ solib_create_inferior_hook. */ -+ -+#ifdef SOLIB_ADD -+ SOLIB_ADD (NULL, 0, target, auto_solib_add); -+#else -+ solib_add (NULL, 0, target, auto_solib_add); - #endif - } - -diff --git a/gdb/infrun.c b/gdb/infrun.c -index 9d29b15..ed451d5 100644 ---- a/gdb/infrun.c -+++ b/gdb/infrun.c -@@ -544,7 +544,7 @@ follow_exec (ptid_t pid, char *execd_pathname) - #ifdef SOLIB_CREATE_INFERIOR_HOOK - SOLIB_CREATE_INFERIOR_HOOK (PIDGET (inferior_ptid)); - #else -- solib_create_inferior_hook (); -+ solib_create_inferior_hook (0); - #endif - - jit_inferior_created_hook (); -diff --git a/gdb/linux-nat.c b/gdb/linux-nat.c -index 0907f03..1c18782 100644 ---- a/gdb/linux-nat.c -+++ b/gdb/linux-nat.c -@@ -4674,7 +4674,7 @@ linux_xfer_partial (struct target_ops *ops, enum target_object object, - LONGEST xfer; - - if (object == TARGET_OBJECT_AUXV) -- return procfs_xfer_auxv (ops, object, annex, readbuf, writebuf, -+ return memory_xfer_auxv (ops, object, annex, readbuf, writebuf, - offset, len); - - if (object == TARGET_OBJECT_OSDATA) -diff --git a/gdb/linux-tdep.c b/gdb/linux-tdep.c -index 6634703..37770f5 100644 ---- a/gdb/linux-tdep.c -+++ b/gdb/linux-tdep.c -@@ -18,12 +18,8 @@ - along with this program. If not, see . */ - - #include "defs.h" --#include "gdbcore.h" - #include "gdbtypes.h" - #include "linux-tdep.h" --#include "observer.h" -- --#include "elf-bfd.h" - - /* This function is suitable for architectures that don't - extend/override the standard siginfo structure. */ -@@ -138,30 +134,3 @@ linux_get_siginfo_type (struct gdbarch *gdbarch) - - return siginfo_type; - } -- --/* Observer for the executable_changed event, to check whether the new -- exec binary is a PIE (Position Independent Executable) specimen, which -- is currently unsupported. */ -- --static void --check_is_pie_binary (void) --{ -- Elf_Internal_Ehdr *elf_hdr; -- -- if (!exec_bfd) -- return; -- else if (bfd_get_flavour (exec_bfd) != bfd_target_elf_flavour) -- return; -- -- if (elf_tdata (exec_bfd)->elf_header->e_type == ET_DYN) -- warning (_("\ --The current binary is a PIE (Position Independent Executable), which\n\ --GDB does NOT currently support. Most debugger features will fail if used\n\ --in this session.\n")); --} -- --void --_initialize_linux_tdep (void) --{ -- observer_attach_executable_changed (check_is_pie_binary); --} -diff --git a/gdb/nto-procfs.c b/gdb/nto-procfs.c -index 0adb045..ea89331 100644 ---- a/gdb/nto-procfs.c -+++ b/gdb/nto-procfs.c -@@ -652,7 +652,7 @@ static void - procfs_post_attach (pid_t pid) - { - if (exec_bfd) -- solib_create_inferior_hook (); -+ solib_create_inferior_hook (0); - } - - static ptid_t -@@ -1212,7 +1212,7 @@ procfs_create_inferior (struct target_ops *ops, char *exec_file, - - if (exec_bfd != NULL - || (symfile_objfile != NULL && symfile_objfile->obfd != NULL)) -- solib_create_inferior_hook (); -+ solib_create_inferior_hook (0); - } - - static void -diff --git a/gdb/objfiles.c b/gdb/objfiles.c -index e5442ca..fb0cea9 100644 ---- a/gdb/objfiles.c -+++ b/gdb/objfiles.c -@@ -544,9 +544,10 @@ free_all_objfiles (void) - } - - /* Relocate OBJFILE to NEW_OFFSETS. There should be OBJFILE->NUM_SECTIONS -- entries in new_offsets. */ --void --objfile_relocate (struct objfile *objfile, struct section_offsets *new_offsets) -+ entries in new_offsets. SEPARATE_DEBUG_OBJFILE is not touched here. */ -+ -+static void -+objfile_relocate1 (struct objfile *objfile, struct section_offsets *new_offsets) - { - struct obj_section *s; - struct section_offsets *delta = -@@ -624,6 +625,10 @@ objfile_relocate (struct objfile *objfile, struct section_offsets *new_offsets) - } - } - -+ if (objfile->psymtabs_addrmap) -+ addrmap_relocate (objfile->psymtabs_addrmap, -+ ANOFFSET (delta, SECT_OFF_TEXT (objfile))); -+ - { - struct partial_symtab *p; - -@@ -701,6 +706,49 @@ objfile_relocate (struct objfile *objfile, struct section_offsets *new_offsets) - exec_set_section_address (bfd_get_filename (objfile->obfd), idx, - obj_section_addr (s)); - } -+} -+ -+/* Relocate OBJFILE to NEW_OFFSETS. There should be OBJFILE->NUM_SECTIONS -+ entries in new_offsets. Process also OBJFILE's SEPARATE_DEBUG_OBJFILE. -+ -+ The number and ordering of sections does differ between the two objfiles. -+ Only their names match. Also the file offsets will differ (objfile being -+ possibly prelinked but separate_debug_objfile is probably not prelinked) but -+ the in-memory absolute address as specified by NEW_OFFSETS must match both -+ files. */ -+ -+void -+objfile_relocate (struct objfile *objfile, struct section_offsets *new_offsets) -+{ -+ objfile_relocate1 (objfile, new_offsets); -+ -+ if (objfile->separate_debug_objfile != NULL) -+ { -+ struct objfile *debug_objfile = objfile->separate_debug_objfile; -+ struct section_addr_info *objfile_addrs; -+ struct section_offsets *new_debug_offsets; -+ int new_debug_num_sections; -+ struct cleanup *my_cleanups; -+ -+ objfile_addrs = build_section_addr_info_from_objfile (objfile); -+ my_cleanups = make_cleanup (xfree, objfile_addrs); -+ -+ /* Here OBJFILE_ADDRS contain the correct absolute addresses, the -+ relative ones must be already created according to debug_objfile. */ -+ -+ addr_info_make_relative (objfile_addrs, debug_objfile->obfd); -+ -+ gdb_assert (debug_objfile->num_sections -+ == bfd_count_sections (debug_objfile->obfd)); -+ new_debug_offsets = alloca (SIZEOF_N_SECTION_OFFSETS -+ (debug_objfile->num_sections)); -+ relative_addr_info_to_section_offsets (new_debug_offsets, -+ debug_objfile->num_sections, -+ objfile_addrs); -+ do_cleanups (my_cleanups); -+ -+ objfile_relocate1 (debug_objfile, new_debug_offsets); -+ } - - /* Relocate breakpoints as necessary, after things are relocated. */ - breakpoint_re_set (); -diff --git a/gdb/procfs.c b/gdb/procfs.c -index b569bac..15829c2 100644 ---- a/gdb/procfs.c -+++ b/gdb/procfs.c -@@ -4376,7 +4376,7 @@ procfs_xfer_partial (struct target_ops *ops, enum target_object object, - - #ifdef NEW_PROC_API - case TARGET_OBJECT_AUXV: -- return procfs_xfer_auxv (ops, object, annex, readbuf, writebuf, -+ return memory_xfer_auxv (ops, object, annex, readbuf, writebuf, - offset, len); - #endif - -diff --git a/gdb/solib-darwin.c b/gdb/solib-darwin.c -index 9428d92..3591168 100644 ---- a/gdb/solib-darwin.c -+++ b/gdb/solib-darwin.c -@@ -277,7 +277,7 @@ darwin_special_symbol_handling (void) - - /* Shared library startup support. See documentation in solib-svr4.c */ - static void --darwin_solib_create_inferior_hook (void) -+darwin_solib_create_inferior_hook (int from_tty) - { - struct minimal_symbol *msymbol; - char **bkpt_namep; -diff --git a/gdb/solib-frv.c b/gdb/solib-frv.c -index b8d5528..002c589 100644 ---- a/gdb/solib-frv.c -+++ b/gdb/solib-frv.c -@@ -971,7 +971,7 @@ frv_relocate_main_executable (void) - */ - - static void --frv_solib_create_inferior_hook (void) -+frv_solib_create_inferior_hook (int from_tty) - { - /* Relocate main executable. */ - frv_relocate_main_executable (); -diff --git a/gdb/solib-irix.c b/gdb/solib-irix.c -index a0c1cd2..f94f7dc 100644 ---- a/gdb/solib-irix.c -+++ b/gdb/solib-irix.c -@@ -386,7 +386,7 @@ enable_break (void) - - SYNOPSIS - -- void solib_create_inferior_hook () -+ void solib_create_inferior_hook (int from_tty) - - DESCRIPTION - -@@ -431,7 +431,7 @@ enable_break (void) - */ - - static void --irix_solib_create_inferior_hook (void) -+irix_solib_create_inferior_hook (int from_tty) - { - struct inferior *inf; - struct thread_info *tp; -diff --git a/gdb/solib-null.c b/gdb/solib-null.c -index b39ccdb..87f7848 100644 ---- a/gdb/solib-null.c -+++ b/gdb/solib-null.c -@@ -32,7 +32,7 @@ null_special_symbol_handling (void) - } - - static void --null_solib_create_inferior_hook (void) -+null_solib_create_inferior_hook (int from_tty) - { - } - -diff --git a/gdb/solib-osf.c b/gdb/solib-osf.c -index c295335..0acc7fb 100644 ---- a/gdb/solib-osf.c -+++ b/gdb/solib-osf.c -@@ -306,7 +306,7 @@ osf_clear_solib (void) - Also, what if child has exit()ed? Must exit loop somehow. */ - - static void --osf_solib_create_inferior_hook (void) -+osf_solib_create_inferior_hook (int from_tty) - { - struct inferior *inf; - struct thread_info *tp; -diff --git a/gdb/solib-pa64.c b/gdb/solib-pa64.c -index 637fc1a..16d4010 100644 ---- a/gdb/solib-pa64.c -+++ b/gdb/solib-pa64.c -@@ -329,7 +329,7 @@ bfd_lookup_symbol (bfd *abfd, char *symname) - with shared libraries mapped shareable. */ - - static void --pa64_solib_create_inferior_hook (void) -+pa64_solib_create_inferior_hook (int from_tty) - { - struct minimal_symbol *msymbol; - unsigned int dld_flags, status; -diff --git a/gdb/solib-som.c b/gdb/solib-som.c -index 16f00a3..37ac8cd 100644 ---- a/gdb/solib-som.c -+++ b/gdb/solib-som.c -@@ -182,7 +182,7 @@ struct { - means running until the "_start" is called. */ - - static void --som_solib_create_inferior_hook (void) -+som_solib_create_inferior_hook (int from_tty) - { - enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch); - struct minimal_symbol *msymbol; -diff --git a/gdb/solib-spu.c b/gdb/solib-spu.c -index 9f06fa9..45e7e69 100644 ---- a/gdb/solib-spu.c -+++ b/gdb/solib-spu.c -@@ -52,25 +52,19 @@ - static void - spu_relocate_main_executable (int spufs_fd) - { -- struct objfile *objfile; -- struct cleanup *old_chain; - struct section_offsets *new_offsets; - int i; - -- for (objfile = symfile_objfile; -- objfile; -- objfile = objfile->separate_debug_objfile) -- { -- new_offsets = xcalloc (objfile->num_sections, -- sizeof (struct section_offsets)); -- old_chain = make_cleanup (xfree, new_offsets); -+ if (symfile_objfile == NULL) -+ return; - -- for (i = 0; i < objfile->num_sections; i++) -- new_offsets->offsets[i] = SPUADDR (spufs_fd, 0); -+ new_offsets = alloca (symfile_objfile->num_sections -+ * sizeof (struct section_offsets)); - -- objfile_relocate (objfile, new_offsets); -- do_cleanups (old_chain); -- } -+ for (i = 0; i < symfile_objfile->num_sections; i++) -+ new_offsets->offsets[i] = SPUADDR (spufs_fd, 0); -+ -+ objfile_relocate (symfile_objfile, new_offsets); - } - - /* When running a stand-alone SPE executable, we may need to skip one more -@@ -370,7 +364,7 @@ spu_enable_break (struct objfile *objfile) - - /* Create inferior hook. */ - static void --spu_solib_create_inferior_hook (void) -+spu_solib_create_inferior_hook (int from_tty) - { - /* Remove all previously installed solib breakpoints. Both the SVR4 - code and us will re-install all required breakpoints. */ -@@ -401,7 +395,7 @@ spu_solib_create_inferior_hook (void) - } - - /* Call SVR4 hook -- this will re-insert the SVR4 solib breakpoints. */ -- svr4_so_ops.solib_create_inferior_hook (); -+ svr4_so_ops.solib_create_inferior_hook (from_tty); - - /* If the inferior is statically linked against libspe, we need to install - our own solib breakpoint right now. Otherwise, it will be installed by -diff --git a/gdb/solib-sunos.c b/gdb/solib-sunos.c -index 9b2a470..b2a147d 100644 ---- a/gdb/solib-sunos.c -+++ b/gdb/solib-sunos.c -@@ -740,7 +740,7 @@ sunos_special_symbol_handling (void) - */ - - static void --sunos_solib_create_inferior_hook (void) -+sunos_solib_create_inferior_hook (int from_tty) - { - struct thread_info *tp; - struct inferior *inf; -diff --git a/gdb/solib-svr4.c b/gdb/solib-svr4.c -index 68aadc0..efbe717 100644 ---- a/gdb/solib-svr4.c -+++ b/gdb/solib-svr4.c -@@ -50,6 +50,7 @@ - - static struct link_map_offsets *svr4_fetch_link_map_offsets (void); - static int svr4_have_link_map_offsets (void); -+static void svr4_relocate_main_executable (void); - - /* Link map info to include in an allocated so_list entry */ - -@@ -599,11 +600,12 @@ scan_dyntag (int dyntag, bfd *abfd, CORE_ADDR *ptr) - { - int arch_size, step, sect_size; - long dyn_tag; -- CORE_ADDR dyn_ptr, dyn_addr; -+ CORE_ADDR dyn_ptr; - gdb_byte *bufend, *bufstart, *buf; - Elf32_External_Dyn *x_dynp_32; - Elf64_External_Dyn *x_dynp_64; - struct bfd_section *sect; -+ struct target_section *target_section; - - if (abfd == NULL) - return 0; -@@ -619,7 +621,13 @@ scan_dyntag (int dyntag, bfd *abfd, CORE_ADDR *ptr) - sect = bfd_get_section_by_name (abfd, ".dynamic"); - if (sect == NULL) - return 0; -- dyn_addr = bfd_section_vma (abfd, sect); -+ -+ for (target_section = target_get_section_table (&exec_ops)->sections; -+ target_section < target_get_section_table (&exec_ops)->sections_end; -+ target_section++) -+ if (sect == target_section->the_bfd_section) -+ break; -+ gdb_assert (target_section < target_get_section_table (&exec_ops)->sections_end); - - /* Read in .dynamic from the BFD. We will get the actual value - from memory later. */ -@@ -661,7 +669,7 @@ scan_dyntag (int dyntag, bfd *abfd, CORE_ADDR *ptr) - CORE_ADDR ptr_addr; - - ptr_type = builtin_type (target_gdbarch)->builtin_data_ptr; -- ptr_addr = dyn_addr + (buf - bufstart) + arch_size / 8; -+ ptr_addr = target_section->addr + (buf - bufstart) + arch_size / 8; - if (target_read_memory (ptr_addr, ptr_buf, arch_size / 8) == 0) - dyn_ptr = extract_typed_address (ptr_buf, ptr_type); - *ptr = dyn_ptr; -@@ -1258,7 +1266,7 @@ exec_entry_point (struct bfd *abfd, struct target_ops *targ) - */ - - static int --enable_break (struct svr4_info *info) -+enable_break (struct svr4_info *info, int from_tty) - { - struct minimal_symbol *msymbol; - char **bkpt_namep; -@@ -1279,7 +1287,7 @@ enable_break (struct svr4_info *info) - mean r_brk has already been relocated. Assume the dynamic linker - is the object containing r_brk. */ - -- solib_add (NULL, 0, ¤t_target, auto_solib_add); -+ solib_add (NULL, from_tty, ¤t_target, auto_solib_add); - sym_addr = 0; - if (info->debug_base && solib_svr4_r_map (info) != 0) - sym_addr = solib_svr4_r_brk (info); -@@ -1339,6 +1347,11 @@ enable_break (struct svr4_info *info) - bfd *tmp_bfd = NULL; - struct target_ops *tmp_bfd_target; - volatile struct gdb_exception ex; -+ int addr_bit = gdbarch_addr_bit (target_gdbarch); -+ CORE_ADDR mask = CORE_ADDR_MAX; -+ -+ if (addr_bit < (sizeof (CORE_ADDR) * HOST_CHAR_BIT)) -+ mask = ((CORE_ADDR) 1 << addr_bit) - 1; - - sym_addr = 0; - -@@ -1404,7 +1417,7 @@ enable_break (struct svr4_info *info) - info->debug_loader_name = xstrdup (interp_name); - info->debug_loader_offset_p = 1; - info->debug_loader_offset = load_addr; -- solib_add (NULL, 0, ¤t_target, auto_solib_add); -+ solib_add (NULL, from_tty, ¤t_target, auto_solib_add); - } - - /* Record the relocated start and end address of the dynamic linker -@@ -1414,16 +1427,20 @@ enable_break (struct svr4_info *info) - { - interp_text_sect_low = - bfd_section_vma (tmp_bfd, interp_sect) + load_addr; -+ interp_text_sect_low &= mask; - interp_text_sect_high = - interp_text_sect_low + bfd_section_size (tmp_bfd, interp_sect); -+ interp_text_sect_high &= mask; - } - interp_sect = bfd_get_section_by_name (tmp_bfd, ".plt"); - if (interp_sect) - { - interp_plt_sect_low = - bfd_section_vma (tmp_bfd, interp_sect) + load_addr; -+ interp_text_sect_low &= mask; - interp_plt_sect_high = - interp_plt_sect_low + bfd_section_size (tmp_bfd, interp_sect); -+ interp_text_sect_high &= mask; - } - - /* Now try to set a breakpoint in the dynamic linker. */ -@@ -1448,7 +1465,7 @@ enable_break (struct svr4_info *info) - - if (sym_addr != 0) - { -- create_solib_event_breakpoint (target_gdbarch, load_addr + sym_addr); -+ create_solib_event_breakpoint (target_gdbarch, (load_addr + sym_addr) & mask); - xfree (interp_name); - return 1; - } -@@ -1517,113 +1534,131 @@ enable_break (struct svr4_info *info) - static void - svr4_special_symbol_handling (void) - { -+ svr4_relocate_main_executable (); - } - --/* Relocate the main executable. This function should be called upon -- stopping the inferior process at the entry point to the program. -- The entry point from BFD is compared to the PC and if they are -- different, the main executable is relocated by the proper amount. -+/* Decide if the objfile needs to be relocated. As indicated above, -+ we will only be here when execution is stopped at the beginning -+ of the program. Relocation is necessary if the address at which -+ we are presently stopped differs from the start address stored in -+ the executable AND there's no interpreter section. The condition -+ regarding the interpreter section is very important because if -+ there *is* an interpreter section, execution will begin there -+ instead. When there is an interpreter section, the start address -+ is (presumably) used by the interpreter at some point to start -+ execution of the program. -+ -+ If there is an interpreter, it is normal for it to be set to an -+ arbitrary address at the outset. The job of finding it is -+ handled in enable_break(). -+ -+ So, to summarize, relocations are necessary when there is no -+ interpreter section and the start address obtained from the -+ executable is different from the address at which GDB is -+ currently stopped. - -- As written it will only attempt to relocate executables which -- lack interpreter sections. It seems likely that only dynamic -- linker executables will get relocated, though it should work -- properly for a position-independent static executable as well. */ -+ [ The astute reader will note that we also test to make sure that -+ the executable in question has the DYNAMIC flag set. It is my -+ opinion that this test is unnecessary (undesirable even). It -+ was added to avoid inadvertent relocation of an executable -+ whose e_type member in the ELF header is not ET_DYN. There may -+ be a time in the future when it is desirable to do relocations -+ on other types of files as well in which case this condition -+ should either be removed or modified to accomodate the new file -+ type. (E.g, an ET_EXEC executable which has been built to be -+ position-independent could safely be relocated by the OS if -+ desired. It is true that this violates the ABI, but the ABI -+ has been known to be bent from time to time.) - Kevin, Nov 2000. ] -+ */ - --static void --svr4_relocate_main_executable (void) -+static CORE_ADDR -+svr4_static_exec_displacement (void) - { - asection *interp_sect; - struct regcache *regcache - = get_thread_arch_regcache (inferior_ptid, target_gdbarch); - CORE_ADDR pc = regcache_read_pc (regcache); - -- /* Decide if the objfile needs to be relocated. As indicated above, -- we will only be here when execution is stopped at the beginning -- of the program. Relocation is necessary if the address at which -- we are presently stopped differs from the start address stored in -- the executable AND there's no interpreter section. The condition -- regarding the interpreter section is very important because if -- there *is* an interpreter section, execution will begin there -- instead. When there is an interpreter section, the start address -- is (presumably) used by the interpreter at some point to start -- execution of the program. -- -- If there is an interpreter, it is normal for it to be set to an -- arbitrary address at the outset. The job of finding it is -- handled in enable_break(). -- -- So, to summarize, relocations are necessary when there is no -- interpreter section and the start address obtained from the -- executable is different from the address at which GDB is -- currently stopped. -- -- [ The astute reader will note that we also test to make sure that -- the executable in question has the DYNAMIC flag set. It is my -- opinion that this test is unnecessary (undesirable even). It -- was added to avoid inadvertent relocation of an executable -- whose e_type member in the ELF header is not ET_DYN. There may -- be a time in the future when it is desirable to do relocations -- on other types of files as well in which case this condition -- should either be removed or modified to accomodate the new file -- type. (E.g, an ET_EXEC executable which has been built to be -- position-independent could safely be relocated by the OS if -- desired. It is true that this violates the ABI, but the ABI -- has been known to be bent from time to time.) - Kevin, Nov 2000. ] -- */ -- - interp_sect = bfd_get_section_by_name (exec_bfd, ".interp"); - if (interp_sect == NULL - && (bfd_get_file_flags (exec_bfd) & DYNAMIC) != 0 - && (exec_entry_point (exec_bfd, &exec_ops) != pc)) -+ return pc - exec_entry_point (exec_bfd, &exec_ops); -+ -+ return 0; -+} -+ -+/* We relocate all of the sections by the same amount. This -+ behavior is mandated by recent editions of the System V ABI. -+ According to the System V Application Binary Interface, -+ Edition 4.1, page 5-5: -+ -+ ... Though the system chooses virtual addresses for -+ individual processes, it maintains the segments' relative -+ positions. Because position-independent code uses relative -+ addressesing between segments, the difference between -+ virtual addresses in memory must match the difference -+ between virtual addresses in the file. The difference -+ between the virtual address of any segment in memory and -+ the corresponding virtual address in the file is thus a -+ single constant value for any one executable or shared -+ object in a given process. This difference is the base -+ address. One use of the base address is to relocate the -+ memory image of the program during dynamic linking. -+ -+ The same language also appears in Edition 4.0 of the System V -+ ABI and is left unspecified in some of the earlier editions. */ -+ -+static CORE_ADDR -+svr4_exec_displacement (void) -+{ -+ int found; -+ CORE_ADDR entry_point; -+ -+ if (exec_bfd == NULL) -+ return 0; -+ -+ if (target_auxv_search (¤t_target, AT_ENTRY, &entry_point) == 1) -+ return entry_point - exec_entry_point (exec_bfd, ¤t_target); -+ -+ return svr4_static_exec_displacement (); -+} -+ -+/* Relocate the main executable. This function should be called upon -+ stopping the inferior process at the entry point to the program. -+ The entry point from BFD is compared to the AT_ENTRY of AUXV and if they are -+ different, the main executable is relocated by the proper amount. */ -+ -+static void -+svr4_relocate_main_executable (void) -+{ -+ CORE_ADDR displacement = svr4_exec_displacement (); -+ -+ /* Even if DISPLACEMENT is 0 still try to relocate it as this is a new -+ difference of in-memory vs. in-file addresses and we could already -+ relocate the executable at this function to improper address before. */ -+ -+ if (symfile_objfile) - { -- struct cleanup *old_chain; - struct section_offsets *new_offsets; -- int i, changed; -- CORE_ADDR displacement; -- -- /* It is necessary to relocate the objfile. The amount to -- relocate by is simply the address at which we are stopped -- minus the starting address from the executable. -- -- We relocate all of the sections by the same amount. This -- behavior is mandated by recent editions of the System V ABI. -- According to the System V Application Binary Interface, -- Edition 4.1, page 5-5: -- -- ... Though the system chooses virtual addresses for -- individual processes, it maintains the segments' relative -- positions. Because position-independent code uses relative -- addressesing between segments, the difference between -- virtual addresses in memory must match the difference -- between virtual addresses in the file. The difference -- between the virtual address of any segment in memory and -- the corresponding virtual address in the file is thus a -- single constant value for any one executable or shared -- object in a given process. This difference is the base -- address. One use of the base address is to relocate the -- memory image of the program during dynamic linking. -- -- The same language also appears in Edition 4.0 of the System V -- ABI and is left unspecified in some of the earlier editions. */ -- -- displacement = pc - exec_entry_point (exec_bfd, &exec_ops); -- changed = 0; -- -- new_offsets = xcalloc (symfile_objfile->num_sections, -- sizeof (struct section_offsets)); -- old_chain = make_cleanup (xfree, new_offsets); -+ int i; -+ -+ new_offsets = alloca (symfile_objfile->num_sections -+ * sizeof (*new_offsets)); - - for (i = 0; i < symfile_objfile->num_sections; i++) -- { -- if (displacement != ANOFFSET (symfile_objfile->section_offsets, i)) -- changed = 1; -- new_offsets->offsets[i] = displacement; -- } -+ new_offsets->offsets[i] = displacement; - -- if (changed) -- objfile_relocate (symfile_objfile, new_offsets); -+ objfile_relocate (symfile_objfile, new_offsets); -+ } -+ else if (exec_bfd) -+ { -+ asection *asect; - -- do_cleanups (old_chain); -+ for (asect = exec_bfd->sections; asect != NULL; asect = asect->next) -+ exec_set_section_address (bfd_get_filename (exec_bfd), asect->index, -+ bfd_section_vma (exec_bfd, asect) -+ + displacement); - } - } - -@@ -1635,7 +1670,7 @@ svr4_relocate_main_executable (void) - - SYNOPSIS - -- void svr4_solib_create_inferior_hook () -+ void svr4_solib_create_inferior_hook (int from_tty) - - DESCRIPTION - -@@ -1680,7 +1715,7 @@ svr4_relocate_main_executable (void) - */ - - static void --svr4_solib_create_inferior_hook (void) -+svr4_solib_create_inferior_hook (int from_tty) - { - struct inferior *inf; - struct thread_info *tp; -@@ -1689,12 +1724,13 @@ svr4_solib_create_inferior_hook (void) - info = get_svr4_info (PIDGET (inferior_ptid)); - - /* Relocate the main executable if necessary. */ -- svr4_relocate_main_executable (); -+ if (current_inferior ()->attach_flag == 0) -+ svr4_relocate_main_executable (); - - if (!svr4_have_link_map_offsets ()) - return; - -- if (!enable_break (info)) -+ if (!enable_break (info, from_tty)) - return; - - #if defined(_SCO_DS) -@@ -1910,8 +1946,19 @@ elf_lookup_lib_symbol (const struct objfile *objfile, - const char *name, - const domain_enum domain) - { -- if (objfile->obfd == NULL -- || scan_dyntag (DT_SYMBOLIC, objfile->obfd, NULL) != 1) -+ bfd *abfd; -+ -+ if (objfile == symfile_objfile) -+ abfd = exec_bfd; -+ else -+ { -+ /* OBJFILE should have been passed as the non-debug one. */ -+ gdb_assert (objfile->separate_debug_objfile_backlink == NULL); -+ -+ abfd = objfile->obfd; -+ } -+ -+ if (abfd == NULL || scan_dyntag (DT_SYMBOLIC, abfd, NULL) != 1) - return NULL; - - return lookup_global_symbol_from_objfile (objfile, name, domain); -diff --git a/gdb/solib-target.c b/gdb/solib-target.c -index 07415e4..d160a70 100644 ---- a/gdb/solib-target.c -+++ b/gdb/solib-target.c -@@ -306,7 +306,7 @@ solib_target_special_symbol_handling (void) - } - - static void --solib_target_solib_create_inferior_hook (void) -+solib_target_solib_create_inferior_hook (int from_tty) - { - /* Nothing needed. */ - } -diff --git a/gdb/solib.c b/gdb/solib.c -index 3574e62..7ea3663 100644 ---- a/gdb/solib.c -+++ b/gdb/solib.c -@@ -998,7 +998,7 @@ clear_solib (void) - - SYNOPSIS - -- void solib_create_inferior_hook () -+ void solib_create_inferior_hook (int from_tty) - - DESCRIPTION - -@@ -1008,10 +1008,10 @@ clear_solib (void) - SOLIB_CREATE_INFERIOR_HOOK. */ - - void --solib_create_inferior_hook (void) -+solib_create_inferior_hook (int from_tty) - { - struct target_so_ops *ops = solib_ops (target_gdbarch); -- ops->solib_create_inferior_hook(); -+ ops->solib_create_inferior_hook (from_tty); - } - - /* GLOBAL FUNCTION -@@ -1087,7 +1087,6 @@ reload_shared_libraries (char *ignored, int from_tty, - struct cmd_list_element *e) - { - no_shared_libraries (NULL, from_tty); -- solib_add (NULL, from_tty, NULL, auto_solib_add); - /* Creating inferior hooks here has two purposes. First, if we reload - shared libraries then the address of solib breakpoint we've computed - previously might be no longer valid. For example, if we forgot to set -@@ -1102,9 +1101,19 @@ reload_shared_libraries (char *ignored, int from_tty, - #ifdef SOLIB_CREATE_INFERIOR_HOOK - SOLIB_CREATE_INFERIOR_HOOK (PIDGET (inferior_ptid)); - #else -- solib_create_inferior_hook (); -+ solib_create_inferior_hook (from_tty); - #endif - } -+ -+ /* Sometimes the platform-specific hook loads initial shared -+ libraries, and sometimes it doesn't. If it doesn't FROM_TTY will be -+ incorrectly 0 but such solib targets should be fixed anyway. If we -+ made all the inferior hook methods consistent, this call could be -+ removed. Call it only after the solib target has been initialized by -+ solib_create_inferior_hook. */ -+ -+ solib_add (NULL, 0, NULL, auto_solib_add); -+ - /* We have unloaded and then reloaded debug info for all shared libraries. - However, frames may still reference them, for example a frame's - unwinder might still point of DWARF FDE structures that are now freed. -diff --git a/gdb/solib.h b/gdb/solib.h -index ccc5b63..abe5e19 100644 ---- a/gdb/solib.h -+++ b/gdb/solib.h -@@ -41,7 +41,7 @@ extern int solib_read_symbols (struct so_list *, int); - addresses to which they are linked, and sufficient information to - read in their symbols at a later time. */ - --extern void solib_create_inferior_hook (void); -+extern void solib_create_inferior_hook (int from_tty); - - /* If ADDR lies in a shared library, return its name. */ - -diff --git a/gdb/solist.h b/gdb/solist.h -index 005e8f7..9724fe7 100644 ---- a/gdb/solist.h -+++ b/gdb/solist.h -@@ -87,7 +87,7 @@ struct target_so_ops - void (*clear_solib) (void); - - /* Target dependent code to run after child process fork. */ -- void (*solib_create_inferior_hook) (void); -+ void (*solib_create_inferior_hook) (int from_tty); - - /* Do additional symbol handling, lookup, etc. after symbols - for a shared object have been loaded. */ -diff --git a/gdb/symfile.c b/gdb/symfile.c -index c31b72a..6d7fa10 100644 ---- a/gdb/symfile.c -+++ b/gdb/symfile.c -@@ -536,40 +536,151 @@ place_section (bfd *abfd, asection *sect, void *obj) - arg->lowest = start_addr + bfd_get_section_size (sect); - } - --/* Parse the user's idea of an offset for dynamic linking, into our idea -- of how to represent it for fast symbol reading. This is the default -- version of the sym_fns.sym_offsets function for symbol readers that -- don't need to do anything special. It allocates a section_offsets table -- for the objectfile OBJFILE and stuffs ADDR into all of the offsets. */ -+/* Build (allocate and populate) struct section_addr_info with absolute -+ addresses from OBJFILE->OBFD and OBJFILE->SECTION_OFFSETS. */ -+ -+struct section_addr_info * -+build_section_addr_info_from_objfile (struct objfile *objfile) -+{ -+ struct target_section *sections = NULL, *sections_end; -+ struct target_section *p; -+ int addr_bit = gdbarch_addr_bit (objfile->gdbarch); -+ CORE_ADDR mask = CORE_ADDR_MAX; -+ struct section_addr_info *retval; -+ struct cleanup *my_cleanups; -+ -+ if (build_section_table (objfile->obfd, §ions, §ions_end)) -+ error (_("Can't find the file sections in `%s': %s"), -+ bfd_get_filename (objfile->obfd), bfd_errmsg (bfd_get_error ())); -+ my_cleanups = make_cleanup (xfree, sections); -+ -+ if (addr_bit < (sizeof (CORE_ADDR) * HOST_CHAR_BIT)) -+ mask = ((CORE_ADDR) 1 << addr_bit) - 1; -+ -+ for (p = sections; p < sections_end; p++) -+ { -+ CORE_ADDR baseaddr; -+ -+ gdb_assert (p->the_bfd_section->index < objfile->num_sections); -+ baseaddr = ANOFFSET (objfile->section_offsets, -+ p->the_bfd_section->index); -+ -+ p->addr = (p->addr + baseaddr) & mask; -+ p->endaddr = (p->endaddr + baseaddr) & mask; -+ } -+ -+ retval = build_section_addr_info_from_section_table (sections, sections_end); -+ -+ do_cleanups (my_cleanups); -+ -+ return retval; -+} -+ -+/* Store struct section_addr_info as prepared (made relative and with SECTINDEX -+ filled-in) by addr_info_make_relative into SECTION_OFFSETS of NUM_SECTIONS -+ entries. */ - - void --default_symfile_offsets (struct objfile *objfile, -- struct section_addr_info *addrs) -+relative_addr_info_to_section_offsets (struct section_offsets *section_offsets, -+ int num_sections, -+ struct section_addr_info *addrs) - { - int i; - -- objfile->num_sections = bfd_count_sections (objfile->obfd); -- objfile->section_offsets = (struct section_offsets *) -- obstack_alloc (&objfile->objfile_obstack, -- SIZEOF_N_SECTION_OFFSETS (objfile->num_sections)); -- memset (objfile->section_offsets, 0, -- SIZEOF_N_SECTION_OFFSETS (objfile->num_sections)); -+ memset (section_offsets, 0, SIZEOF_N_SECTION_OFFSETS (num_sections)); - -- /* Now calculate offsets for section that were specified by the -- caller. */ -+ /* Now calculate offsets for section that were specified by the caller. */ - for (i = 0; i < addrs->num_sections && addrs->other[i].name; i++) - { -- struct other_sections *osp ; -+ struct other_sections *osp; - -- osp = &addrs->other[i] ; -+ osp = &addrs->other[i]; - if (osp->addr == 0) - continue; - - /* Record all sections in offsets */ - /* The section_offsets in the objfile are here filled in using - the BFD index. */ -- (objfile->section_offsets)->offsets[osp->sectindex] = osp->addr; -+ section_offsets->offsets[osp->sectindex] = osp->addr; -+ } -+} -+ -+/* Relativize absolute addresses in ADDRS into offsets based on ABFD. Fill-in -+ also SECTINDEXes there. */ -+ -+void -+addr_info_make_relative (struct section_addr_info *addrs, bfd *abfd) -+{ -+ asection *lower_sect; -+ asection *sect; -+ CORE_ADDR lower_offset; -+ int i; -+ -+ /* Find lowest loadable section to be used as starting point for -+ continguous sections. FIXME!! won't work without call to find -+ .text first, but this assumes text is lowest section. */ -+ lower_sect = bfd_get_section_by_name (abfd, ".text"); -+ if (lower_sect == NULL) -+ bfd_map_over_sections (abfd, find_lowest_section, &lower_sect); -+ if (lower_sect == NULL) -+ { -+ warning (_("no loadable sections found in added symbol-file %s"), -+ bfd_get_filename (abfd)); -+ lower_offset = 0; -+ } -+ else -+ lower_offset = bfd_section_vma (bfd_get_filename (abfd), lower_sect); -+ -+ /* Calculate offsets for the loadable sections. -+ FIXME! Sections must be in order of increasing loadable section -+ so that contiguous sections can use the lower-offset!!! -+ -+ Adjust offsets if the segments are not contiguous. -+ If the section is contiguous, its offset should be set to -+ the offset of the highest loadable section lower than it -+ (the loadable section directly below it in memory). -+ this_offset = lower_offset = lower_addr - lower_orig_addr */ -+ -+ for (i = 0; i < addrs->num_sections && addrs->other[i].name; i++) -+ { -+ if (addrs->other[i].addr != 0) -+ { -+ sect = bfd_get_section_by_name (abfd, addrs->other[i].name); -+ if (sect) -+ { -+ addrs->other[i].addr -= bfd_section_vma (abfd, sect); -+ lower_offset = addrs->other[i].addr; -+ /* This is the index used by BFD. */ -+ addrs->other[i].sectindex = sect->index; -+ } -+ else -+ { -+ warning (_("section %s not found in %s"), addrs->other[i].name, -+ bfd_get_filename (abfd)); -+ addrs->other[i].addr = 0; -+ } -+ } -+ else -+ addrs->other[i].addr = lower_offset; - } -+} -+ -+/* Parse the user's idea of an offset for dynamic linking, into our idea -+ of how to represent it for fast symbol reading. This is the default -+ version of the sym_fns.sym_offsets function for symbol readers that -+ don't need to do anything special. It allocates a section_offsets table -+ for the objectfile OBJFILE and stuffs ADDR into all of the offsets. */ -+ -+void -+default_symfile_offsets (struct objfile *objfile, -+ struct section_addr_info *addrs) -+{ -+ objfile->num_sections = bfd_count_sections (objfile->obfd); -+ objfile->section_offsets = (struct section_offsets *) -+ obstack_alloc (&objfile->objfile_obstack, -+ SIZEOF_N_SECTION_OFFSETS (objfile->num_sections)); -+ relative_addr_info_to_section_offsets (objfile->section_offsets, -+ objfile->num_sections, addrs); - - /* For relocatable files, all loadable sections will start at zero. - The zero is meaningless, so try to pick arbitrary addresses such -@@ -803,65 +914,8 @@ syms_from_objfile (struct objfile *objfile, - - We no longer warn if the lowest section is not a text segment (as - happens for the PA64 port. */ -- if (!mainline && addrs && addrs->other[0].name) -- { -- asection *lower_sect; -- asection *sect; -- CORE_ADDR lower_offset; -- int i; -- -- /* Find lowest loadable section to be used as starting point for -- continguous sections. FIXME!! won't work without call to find -- .text first, but this assumes text is lowest section. */ -- lower_sect = bfd_get_section_by_name (objfile->obfd, ".text"); -- if (lower_sect == NULL) -- bfd_map_over_sections (objfile->obfd, find_lowest_section, -- &lower_sect); -- if (lower_sect == NULL) -- { -- warning (_("no loadable sections found in added symbol-file %s"), -- objfile->name); -- lower_offset = 0; -- } -- else -- lower_offset = bfd_section_vma (objfile->obfd, lower_sect); -- -- /* Calculate offsets for the loadable sections. -- FIXME! Sections must be in order of increasing loadable section -- so that contiguous sections can use the lower-offset!!! -- -- Adjust offsets if the segments are not contiguous. -- If the section is contiguous, its offset should be set to -- the offset of the highest loadable section lower than it -- (the loadable section directly below it in memory). -- this_offset = lower_offset = lower_addr - lower_orig_addr */ -- -- for (i = 0; i < addrs->num_sections && addrs->other[i].name; i++) -- { -- if (addrs->other[i].addr != 0) -- { -- sect = bfd_get_section_by_name (objfile->obfd, -- addrs->other[i].name); -- if (sect) -- { -- addrs->other[i].addr -- -= bfd_section_vma (objfile->obfd, sect); -- lower_offset = addrs->other[i].addr; -- /* This is the index used by BFD. */ -- addrs->other[i].sectindex = sect->index ; -- } -- else -- { -- warning (_("section %s not found in %s"), -- addrs->other[i].name, -- objfile->name); -- addrs->other[i].addr = 0; -- } -- } -- else -- addrs->other[i].addr = lower_offset; -- } -- } -+ if (addrs && addrs->other[0].name) -+ addr_info_make_relative (addrs, objfile->obfd); - - /* Initialize symbol reading routines for this objfile, allow complaints to - appear for this new file, and record how verbose to be, then do the -@@ -959,7 +1013,6 @@ symbol_file_add_with_addrs_or_offsets (bfd *abfd, - struct objfile *objfile; - struct partial_symtab *psymtab; - char *debugfile = NULL; -- struct section_addr_info *orig_addrs = NULL; - struct cleanup *my_cleanups; - const char *name = bfd_get_filename (abfd); - const int from_tty = add_flags & SYMFILE_VERBOSE; -@@ -981,12 +1034,6 @@ symbol_file_add_with_addrs_or_offsets (bfd *abfd, - objfile->flags |= OBJF_MAIN; - discard_cleanups (my_cleanups); - -- if (addrs) -- { -- orig_addrs = copy_section_addr_info (addrs); -- make_cleanup_free_section_addr_info (orig_addrs); -- } -- - /* We either created a new mapped symbol table, mapped an existing - symbol table file which has not had initial symbol reading - performed, or need to read an unmapped symbol table. */ -@@ -1033,18 +1080,17 @@ symbol_file_add_with_addrs_or_offsets (bfd *abfd, - `.gnu_debuglink' may no longer be present with `.note.gnu.build-id'. */ - if (!has_any_debug_symbols (objfile)) - debugfile = find_separate_debug_file (objfile); -+ - if (debugfile) - { -- if (addrs != NULL) -- { -- objfile->separate_debug_objfile -- = symbol_file_add (debugfile, add_flags, orig_addrs, flags); -- } -- else -- { -- objfile->separate_debug_objfile -- = symbol_file_add (debugfile, add_flags, NULL, flags); -- } -+ struct section_addr_info *objfile_addrs; -+ -+ objfile_addrs = build_section_addr_info_from_objfile (objfile); -+ make_cleanup (xfree, objfile_addrs); -+ -+ objfile->separate_debug_objfile = symbol_file_add (debugfile, add_flags, -+ objfile_addrs, flags); -+ - objfile->separate_debug_objfile->separate_debug_objfile_backlink - = objfile; - -diff --git a/gdb/symfile.h b/gdb/symfile.h -index bf9d9e7..bff6bd8 100644 ---- a/gdb/symfile.h -+++ b/gdb/symfile.h -@@ -181,6 +181,16 @@ struct sym_fns - - }; - -+extern struct section_addr_info * -+ build_section_addr_info_from_objfile (struct objfile *objfile); -+ -+extern void relative_addr_info_to_section_offsets -+ (struct section_offsets *section_offsets, int num_sections, -+ struct section_addr_info *addrs); -+ -+extern void addr_info_make_relative (struct section_addr_info *addrs, -+ bfd *abfd); -+ - /* The default version of sym_fns.sym_offsets for readers that don't - do anything special. */ - -diff --git a/gdb/symtab.c b/gdb/symtab.c -index 82e0163..01117e3 100644 ---- a/gdb/symtab.c -+++ b/gdb/symtab.c -@@ -1449,7 +1449,12 @@ lookup_objfile_from_block (const struct block *block) - /* Go through SYMTABS. */ - ALL_SYMTABS (obj, s) - if (block == BLOCKVECTOR_BLOCK (BLOCKVECTOR (s), GLOBAL_BLOCK)) -- return obj; -+ { -+ if (obj->separate_debug_objfile_backlink) -+ obj = obj->separate_debug_objfile_backlink; -+ -+ return obj; -+ } - - return NULL; - } -diff --git a/gdb/testsuite/gdb.base/break-interp-lib.c b/gdb/testsuite/gdb.base/break-interp-lib.c -new file mode 100644 -index 0000000..9ca943e ---- /dev/null -+++ b/gdb/testsuite/gdb.base/break-interp-lib.c -@@ -0,0 +1,40 @@ -+/* This testcase is part of GDB, the GNU debugger. -+ -+ Copyright 2009 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 -+#include -+#include -+ -+void -+libfunc (const char *action) -+{ -+ assert (action != NULL); -+ -+ if (strcmp (action, "segv") == 0) -+ raise (SIGSEGV); -+ -+ if (strcmp (action, "sleep") == 0) -+ { -+ puts ("sleeping"); -+ fflush (stdout); -+ -+ sleep (60); -+ } -+ -+ assert (0); -+} -diff --git a/gdb/testsuite/gdb.base/break-interp-main.c b/gdb/testsuite/gdb.base/break-interp-main.c -new file mode 100644 -index 0000000..e12ec2b ---- /dev/null -+++ b/gdb/testsuite/gdb.base/break-interp-main.c -@@ -0,0 +1,30 @@ -+/* This testcase is part of GDB, the GNU debugger. -+ -+ Copyright 2009 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 -+ -+extern void libfunc (const char *action); -+ -+int -+main (int argc, char **argv) -+{ -+ assert (argc == 2); -+ -+ libfunc (argv[1]); -+ -+ return 0; -+} -diff --git a/gdb/testsuite/gdb.base/break-interp.exp b/gdb/testsuite/gdb.base/break-interp.exp -new file mode 100644 -index 0000000..52f460c ---- /dev/null -+++ b/gdb/testsuite/gdb.base/break-interp.exp -@@ -0,0 +1,545 @@ -+# Copyright 2009 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 . -+ -+# This test only works on GNU/Linux. -+if { ![isnative] || [is_remote host] || ![istarget *-linux*] || [skip_shlib_tests]} { -+ continue -+} -+ -+set test "break-interp" -+set binprefix ${objdir}/${subdir}/${test} -+# Only to get the $interp_system name. -+set srcfile_test "start.c" -+set binfile_test ${test}-test -+set binfile_lib ${objdir}/${subdir}/${test}.so -+set srcfile "${test}-main.c" -+set srcfile_lib "${test}-lib.c" -+ -+if [get_compiler_info ${binfile_lib}] { -+ return -1 -+} -+ -+# Use -soname so that it is listed with " => " by ldd and this testcase makes -+# a copy of ${binfile_lib} for each prelink variant. -+ -+if {[gdb_compile_shlib ${srcdir}/${subdir}/${srcfile_lib} ${binfile_lib} [list debug additional_flags=-Wl,-soname,${test}.so]] != ""} { -+ return -1 -+} -+ -+if {[build_executable ${test}.exp $binfile_test ${srcfile_test} {}] == -1} { -+ return -1 -+} -+ -+# Return the interpreter filename string. -+# Return "" if no interpreter was found. -+proc section_get {exec section} { -+ global objdir -+ global subdir -+ set tmp "${objdir}/${subdir}/break-interp.interp" -+ set objcopy_program [transform objcopy] -+ -+ set command "exec $objcopy_program -O binary --set-section-flags $section=A --change-section-address $section=0 -j $section $exec $tmp" -+ verbose -log "command is $command" -+ set result [catch $command output] -+ verbose -log "result is $result" -+ verbose -log "output is $output" -+ if {$result == 1} { -+ return "" -+ } -+ set fi [open $tmp] -+ fconfigure $fi -translation binary -+ set data [read $fi] -+ close $fi -+ #file delete $tmp -+ # .interp has size $len + 1 but .gnu_debuglink contains garbage after \000. -+ set len [string first \000 $data] -+ if {$len < 0} { -+ verbose -log "section $section not found" -+ return "" -+ } -+ set retval [string range $data 0 [expr $len - 1]] -+ verbose -log "section $section is <$retval>" -+ return $retval -+} -+ -+# Note: The separate debug info file content build-id/crc32 are not verified -+# contrary to the GDB search algorithm skipping non-matching ones. -+proc system_debug_get {exec} { -+ global debug_root -+ -+ set exec_build_id_debug [build_id_debug_filename_get $exec] -+ set debug_base "[file tail $exec].debug" -+ set exec_dir [file dirname $exec] -+ -+ # isfile returns 1 even for symlinks to files. -+ set retval $debug_root/$exec_build_id_debug -+ if [file isfile $retval] { -+ return $retval -+ } -+ set retval $exec_dir/$debug_base -+ if [file isfile $retval] { -+ return $retval -+ } -+ set retval $exec_dir/.debug/$debug_base -+ if [file isfile $retval] { -+ return $retval -+ } -+ set retval $debug_root/$exec_dir/$debug_base -+ if [file isfile $retval] { -+ return $retval -+ } -+ return "" -+} -+ -+gdb_exit -+gdb_start -+set debug_root "" -+set test "show debug-file-directory" -+gdb_test_multiple $test $test { -+ -re "The directory where separate debug symbols are searched for is \"(.*)\".\r\n$gdb_prompt $" { -+ set debug_root $expect_out(1,string) -+ } -+} -+ -+set interp_system [section_get ${objdir}/${subdir}/$binfile_test .interp] -+set interp_system_debug [system_debug_get $interp_system] -+verbose -log "$interp_system has debug $interp_system_debug" -+ -+proc prelinkNO_run {arg} { -+ set command "exec /usr/sbin/prelink -uN $arg" -+ verbose -log "command is $command" -+ set result [catch $command output] -+ verbose -log "result is $result" -+ verbose -log "output is $output" -+ return [list $result $output] -+} -+ -+proc prelinkNO {arg {name {}}} { -+ if {$name == ""} { -+ set name [file tail $arg] -+ } -+ set test "unprelink $name" -+ set run [prelinkNO_run $arg] -+ set result [lindex $run 0] -+ set output [lindex $run 1] -+ if {$result == 0 && $output == ""} { -+ verbose -log "$name has been now unprelinked" -+ set run [prelinkNO_run $arg] -+ set result [lindex $run 0] -+ set output [lindex $run 1] -+ } -+ # Last line does miss the trailing \n. -+ if {$result == 1 && [regexp {^(/usr/sbin/prelink: [^ ]* does not have .gnu.prelink_undo section\n?)*$} $output]} { -+ pass $test -+ return 1 -+ } else { -+ fail $test -+ return 0 -+ } -+} -+ -+proc prelinkYES {arg {name ""}} { -+ if {$name == ""} { -+ set name [file tail $arg] -+ } -+ set test "prelink $name" -+ set command "exec /usr/sbin/prelink -qNR --no-exec-shield $arg" -+ verbose -log "command is $command" -+ set result [catch $command output] -+ verbose -log "result is $result" -+ verbose -log "output is $output" -+ if {$result == 0 && $output == ""} { -+ pass $test -+ return 1 -+ } else { -+ fail $test -+ return 0 -+ } -+} -+ -+# Resolve symlinks. -+proc symlink_resolve {file} { -+ set loop 0 -+ while {[file type $file] == "link"} { -+ set target [file readlink $file] -+ if {[file pathtype $target] == "relative"} { -+ set src2 [file dirname $file]/$target -+ } else { -+ set src2 $target -+ } -+ verbose -log "Resolved symlink $file targetting $target as $src2" -+ set file $src2 -+ -+ set loop [expr $loop + 1] -+ if {$loop > 30} { -+ fail "Looping symlink resolution for $file" -+ return "" -+ } -+ } -+ return $file -+} -+ -+proc copy {src dest} { -+ set src [symlink_resolve $src] -+ # Test name would contain build-id hash for symlink-unresolved $src. -+ set test "copy [file tail $src] to [file tail $dest]" -+ set command "file copy -force $src $dest" -+ verbose -log "command is $command" -+ if [catch $command] { -+ fail $test -+ return 0 -+ } else { -+ pass $test -+ return 1 -+ } -+} -+ -+proc strip_debug {dest} { -+ set test "strip [file tail $dest]" -+ set strip_program [transform strip] -+ set command "exec $strip_program --strip-debug $dest" -+ verbose -log "command is $command" -+ if [catch $command] { -+ fail $test -+ return 0 -+ } else { -+ pass $test -+ return 1 -+ } -+} -+ -+# `runto' does not check we stopped really at the function we specified. -+proc reach {func command} { -+ global gdb_prompt -+ -+ if [gdb_breakpoint $func allow-pending] { -+ set test "reach $func" -+ gdb_test_multiple $command $test { -+ -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 $" { -+ pass $test -+ } -+ } -+ } -+} -+ -+proc test_core {file} { -+ global srcdir subdir gdb_prompt -+ -+ set corefile [core_find $file {} "segv"] -+ if {$corefile == ""} { -+ return -+ } -+ -+ gdb_exit -+ gdb_start -+ # Clear it to never find any separate debug infos in $debug_root. -+ gdb_test "set debug-file-directory" "" "set debug-file-directory for core" -+ 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" -+ -+ # Check there is no "argc=can't compute CFA for this frame". -+ gdb_test "bt" "#\[0-9\]+ +\[^\r\n\]*\\mlibfunc\\M\[^\r\n\]*\r\n#\[0-9\]+ +\[^\r\n\]*\\mmain \\((argc=2,.*)?\\).*" "core main bt" -+} -+ -+proc test_attach {file} { -+ global board_info -+ -+ gdb_exit -+ -+ set test "sleep function started" -+ -+ set command "${file} sleep" -+ set res [remote_spawn host $command]; -+ if { $res < 0 || $res == "" } { -+ perror "Spawning $command failed." -+ fail $test -+ return -+ } -+ set pid [exp_pid -i $res] -+ gdb_expect { -+ -re "sleeping\r\n" { -+ pass $test -+ } -+ eof { -+ fail "$test (eof)" -+ return -+ } -+ timeout { -+ fail "$test (timeout)" -+ return -+ } -+ } -+ -+ gdb_exit -+ gdb_start -+ gdb_test "attach $pid" "Attaching to process $pid\r\n.*" "attach" -+ # Check there is no "argc=can't compute CFA for this frame". -+ gdb_test "bt" "#\[0-9\]+ +\[^\r\n\]*\\mlibfunc\\M\[^\r\n\]*\r\n#\[0-9\]+ +\[^\r\n\]*\\mmain \\((argc=2,.*)?\\).*" "attach main bt" -+ gdb_exit -+ -+ remote_exec host "kill -9 $pid" -+} -+ -+proc test_ld {file ifmain trynosym} { -+ global srcdir subdir gdb_prompt -+ -+ # First test normal `file'-command loaded $FILE with symbols. -+ -+ gdb_exit -+ gdb_start -+ # Clear it to never find any separate debug infos in $debug_root. -+ gdb_test "set debug-file-directory" -+ gdb_reinitialize_dir $srcdir/$subdir -+ gdb_load $file -+ -+ reach "dl_main" "run segv" -+ -+ gdb_test "bt" "#0 +\[^\r\n\]*\\mdl_main\\M.*" "dl bt" -+ -+ if $ifmain { -+ reach "main" continue -+ -+ reach "libfunc" continue -+ -+ # Check there is no "argc=can't compute CFA for this frame". -+ gdb_test "bt" "#0 +\[^\r\n\]*\\mlibfunc\\M\[^\r\n\]*\r\n#1 +\[^\r\n\]*\\mmain \\((argc=2,.*)?\\).*" "main bt" -+ -+ test_core $file -+ -+ test_attach $file -+ } -+ -+ if !$trynosym { -+ return -+ } -+ -+ global pf_prefix -+ set old_ldprefix $pf_prefix -+ lappend pf_prefix "symbol-less:" -+ -+ # Test also `exec-file'-command loaded $FILE - therefore without symbols. -+ # SYMBOL_OBJFILE is not available and only EXEC_BFD must be used. -+ -+ gdb_exit -+ gdb_start -+ # Clear it to never find any separate debug infos in $debug_root. -+ gdb_test "set debug-file-directory" -+ gdb_reinitialize_dir $srcdir/$subdir -+ -+ # 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 -+ -+ 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) -+ 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" -+ } -+ } 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 pf_prefix $old_ldprefix -+} -+ -+# Create separate binaries for each testcase - to make the possible reported -+# problem reproducible after the whole test run finishes. -+ -+set old_ldprefix $pf_prefix -+foreach ldprelink {NO YES} { -+ foreach ldsepdebug {NO IN SEP} { -+ # Skip running the ldsepdebug test if we do not have system separate -+ # debug info available. -+ if {$interp_system_debug == "" && $ldsepdebug == "SEP"} { -+ continue -+ } -+ -+ set ldname "LDprelink${ldprelink}debug${ldsepdebug}" -+ set interp $binprefix-$ldname -+ -+ # prelink needs to always prelink all the dependencies to do any file -+ # modifications of its files. ld.so also needs all the dependencies to -+ # be prelinked to omit the relocation process. In-memory file offsets -+ # are not dependent whether ld.so went the prelink way or through the -+ # relocation process. -+ # -+ # For GDB we are not interested whether prelink succeeds as it is -+ # transparent to GDB. GDB is being tested for differences of file -+ # offsets vs. in-memory offsets. So we have to prelink even ld.so for -+ # the BIN modification to happen but we need to restore the original -+ # possibly unprelinked ld.so to test all the combinations for GDB. -+ set interp_saved ${interp}-saved -+ -+ set pf_prefix $old_ldprefix -+ lappend pf_prefix "$ldname:" -+ -+ if {$ldsepdebug == "NO"} { -+ copy $interp_system $interp -+ # Never call strip-debug before unprelink: -+ # prelink: ...: Section .note.gnu.build-id created after prelinking -+ if ![prelinkNO $interp] { -+ continue -+ } -+ strip_debug $interp -+ } elseif {$ldsepdebug == "IN" && $interp_system_debug == ""} { -+ copy $interp_system $interp -+ } elseif {$ldsepdebug == "IN" && $interp_system_debug != ""} { -+ copy $interp_system $interp -+ copy $interp_system_debug "${interp}.debug" -+ # eu-unstrip: DWARF data in '...' not adjusted for prelinking bias; consider prelink -u -+ if {![prelinkNO $interp] || ![prelinkNO "${interp}.debug"]} { -+ continue -+ } -+ set test "eu-unstrip unprelinked:[file tail $interp_system] + [file tail $interp_system_debug] to [file tail $interp]" -+ set command "exec eu-unstrip -o $interp $interp ${interp}.debug" -+ verbose -log "command is $command" -+ if [catch $command] { -+ setup_xfail *-*-* -+ fail $test -+ continue -+ } else { -+ pass $test -+ } -+ } elseif {$ldsepdebug == "SEP" && $interp_system_debug == ""} { -+ copy $interp_system $interp -+ # eu-unstrip: DWARF data in '...' not adjusted for prelinking bias; consider prelink -u -+ if ![prelinkNO $interp] { -+ continue -+ } -+ gdb_gnu_strip_debug $interp -+ } elseif {$ldsepdebug == "SEP" && $interp_system_debug != ""} { -+ copy $interp_system $interp -+ copy $interp_system_debug "${interp}.debug" -+ } -+ -+ if {$ldsepdebug == "SEP"} { -+ if ![prelinkNO "${interp}.debug"] { -+ continue -+ } -+ } else { -+ file delete "${interp}.debug" -+ } -+ -+ if ![prelink$ldprelink $interp] { -+ continue -+ } -+ test_ld $interp 0 [expr {$ldsepdebug == "NO"}] -+ -+ if ![copy $interp $interp_saved] { -+ continue -+ } -+ set old_binprefix $pf_prefix -+ foreach binprelink {NO YES} { -+ foreach binsepdebug {NO IN SEP} { -+ foreach binpie {NO YES} { -+ # This combination is not possible, non-PIE (fixed address) -+ # binary cannot be prelinked to any (other) address. -+ if {$binprelink == "YES" && $binpie == "NO"} { -+ continue -+ } -+ -+ set binname "BINprelink${binprelink}debug${binsepdebug}pie${binpie}" -+ set exec $binprefix-$binname -+ set dir ${exec}.d -+ -+ set pf_prefix $old_binprefix -+ lappend pf_prefix "$binname:" -+ -+ set opts "additional_flags=-Wl,--dynamic-linker,$interp,-rpath,$dir" -+ lappend opts "additional_flags=-Wl,$binfile_lib,-rpath,[file dirname $binfile_lib]" -+ if {$binsepdebug != "NO"} { -+ lappend opts {debug} -+ } -+ if {$binpie == "YES"} { -+ lappend opts {additional_flags=-fPIE -pie} -+ } -+ if {[build_executable ${test}.exp [file tail $exec] $srcfile $opts] == -1} { -+ continue; -+ } -+ if {$binsepdebug == "SEP"} { -+ gdb_gnu_strip_debug $exec -+ # Just a sanity check. As gdb_gnu_strip_debug uses the -+ # "[file dirname $exec]/.debug/[file tail $exec].debug" -+ # variant delete the higher-priority exec.debug file. -+ file delete "$exec.debug" -+ } -+ -+ # Supply a self-sufficent directory $dir with the required -+ # libraries. To make an executable properly prelinked all -+ # its dependencies on libraries must be also prelinked. If -+ # some of the system libraries is currently not prelinked -+ # we have no right to prelink (modify it) at its current -+ # system place. -+ -+ file delete -force $dir -+ file mkdir $dir -+ -+ set command "ldd $exec" -+ set result [catch "exec $command" output] -+ verbose -log "result of $command is $result" -+ verbose -log "output of $command is $output" -+ if {$result != 0 || $output == ""} { -+ fail $command -+ } else { -+ pass $command -+ } -+ -+ # gdb testsuite will put there also needless -lm. -+ set test "$command output contains libc" -+ set libc [regexp -all -inline -line {^.* => (/[^ ]+).*$} $output] -+ if {[llength $libc] == 0} { -+ fail $test -+ } else { -+ pass $test -+ } -+ -+ set dests {} -+ for {set i 1} {$i < [llength $libc]} {incr i 2} { -+ set abspath [lindex $libc $i] -+ set dest "$dir/[file tail $abspath]" -+ copy $abspath $dest -+ lappend dests $dest -+ } -+ -+ if {[prelink$binprelink "--dynamic-linker=$interp --ld-library-path=$dir $exec $interp [concat $dests]" $exec] -+ && [copy $interp_saved $interp]} { -+ test_ld $exec 1 [expr {$binsepdebug == "NO"}] -+ } -+ } -+ } -+ } -+ -+ file delete $interp_saved -+ } -+} -+set pf_prefix $old_ldprefix -diff --git a/gdb/testsuite/gdb.base/corefile.exp b/gdb/testsuite/gdb.base/corefile.exp -index a1003e1..547a898 100644 ---- a/gdb/testsuite/gdb.base/corefile.exp -+++ b/gdb/testsuite/gdb.base/corefile.exp -@@ -42,65 +42,12 @@ if [get_compiler_info ${binfile}] { - return -1; - } - --# Create a core file named "corefile" rather than just "core", to --# avoid problems with sys admin types that like to regularly prune all --# files named "core" from the system. --# --# Arbitrarily try setting the core size limit to "unlimited" since --# this does not hurt on systems where the command does not work and --# allows us to generate a core on systems where it does. --# --# Some systems append "core" to the name of the program; others append --# the name of the program to "core"; still others (like Linux, as of --# May 2003) create cores named "core.PID". In the latter case, we --# could have many core files lying around, and it may be difficult to --# tell which one is ours, so let's run the program in a subdirectory. --set found 0 --set coredir "${objdir}/${subdir}/coredir.[getpid]" --file mkdir $coredir --catch "system \"(cd ${coredir}; ulimit -c unlimited; ${binfile}; true) >/dev/null 2>&1\"" --# remote_exec host "${binfile}" --foreach i "${coredir}/core ${coredir}/core.coremaker.c ${binfile}.core" { -- if [remote_file build exists $i] { -- remote_exec build "mv $i ${objdir}/${subdir}/corefile" -- set found 1 -- } --} --# Check for "core.PID". --if { $found == 0 } { -- set names [glob -nocomplain -directory $coredir core.*] -- if {[llength $names] == 1} { -- set corefile [file join $coredir [lindex $names 0]] -- remote_exec build "mv $corefile ${objdir}/${subdir}/corefile" -- set found 1 -- } --} --if { $found == 0 } { -- # The braindamaged HPUX shell quits after the ulimit -c above -- # without executing ${binfile}. So we try again without the -- # ulimit here if we didn't find a core file above. -- # Oh, I should mention that any "braindamaged" non-Unix system has -- # the same problem. I like the cd bit too, it's really neat'n stuff. -- catch "system \"(cd ${objdir}/${subdir}; ${binfile}; true) >/dev/null 2>&1\"" -- foreach i "${objdir}/${subdir}/core ${objdir}/${subdir}/core.coremaker.c ${binfile}.core" { -- if [remote_file build exists $i] { -- remote_exec build "mv $i ${objdir}/${subdir}/corefile" -- set found 1 -- } -- } -+set corefile [core_find $binfile {coremmap.data}] -+if {$corefile == ""} { -+ return 0; - } - --# Try to clean up after ourselves. --remote_file build delete [file join $coredir coremmap.data] --remote_exec build "rmdir $coredir" -- --if { $found == 0 } { -- warning "can't generate a core file - core tests suppressed - check ulimit -c" -- return 0 --} -- --# --# Test that we can simply startup with a "-core=corefile" command line arg -+# Test that we can simply startup with a "-core=$corefile" command line arg - # and recognize that the core file is a valid, usable core file. - # To do this, we must shutdown the currently running gdb and restart - # with the -core args. We can't use gdb_start because it looks for -@@ -114,27 +61,27 @@ if { $found == 0 } { - - gdb_exit - if $verbose>1 then { -- send_user "Spawning $GDB $INTERNAL_GDBFLAGS $GDBFLAGS -core=$objdir/$subdir/corefile\n" -+ send_user "Spawning $GDB $INTERNAL_GDBFLAGS $GDBFLAGS -core=$corefile\n" - } - - set oldtimeout $timeout - set timeout [expr "$timeout + 60"] - verbose "Timeout is now $timeout seconds" 2 --eval "spawn $GDB $INTERNAL_GDBFLAGS $GDBFLAGS -core=$objdir/$subdir/corefile" -+eval "spawn $GDB $INTERNAL_GDBFLAGS $GDBFLAGS -core=$corefile" - expect { - -re "Couldn't find .* registers in core file.*$gdb_prompt $" { -- fail "args: -core=corefile (couldn't find regs)" -+ fail "args: -core=[file tail $corefile] (couldn't find regs)" - } - -re "Core was generated by .*coremaker.*\r\n\#0 .*\(\).*\r\n$gdb_prompt $" { -- pass "args: -core=corefile" -+ pass "args: -core=[file tail $corefile]" - } - -re "Core was generated by .*\r\n\#0 .*\(\).*\r\n$gdb_prompt $" { -- pass "args: -core=corefile (with bad program name)" -+ pass "args: -core=[file tail $corefile] (with bad program name)" - } - -re ".*registers from core file: File in wrong format.* $" { -- fail "args: -core=corefile (could not read registers from core file)" -+ fail "args: -core=[file tail $corefile] (could not read registers from core file)" - } -- -re ".*$gdb_prompt $" { fail "args: -core=corefile" } -+ -re ".*$gdb_prompt $" { fail "args: -core=[file tail $corefile]" } - timeout { fail "(timeout) starting with -core" } - } - -@@ -147,22 +94,22 @@ expect { - close; - - if $verbose>1 then { -- send_user "Spawning $GDB $INTERNAL_GDBFLAGS $GDBFLAGS $binfile -core=$objdir/$subdir/corefile\n" -+ send_user "Spawning $GDB $INTERNAL_GDBFLAGS $GDBFLAGS $binfile -core=$corefile\n" - } - - --eval "spawn $GDB $INTERNAL_GDBFLAGS $GDBFLAGS $binfile -core=$objdir/$subdir/corefile"; -+eval "spawn $GDB $INTERNAL_GDBFLAGS $GDBFLAGS $binfile -core=$corefile"; - expect { - -re "Core was generated by .*coremaker.*\r\n\#0 .*\(\).*\r\n$gdb_prompt $" { -- pass "args: execfile -core=corefile" -+ pass "args: execfile -core=[file tail $corefile]" - } - -re "Core was generated by .*\r\n\#0 .*\(\).*\r\n$gdb_prompt $" { -- pass "args: execfile -core=corefile (with bad program name)" -+ pass "args: execfile -core=[file tail $corefile] (with bad program name)" - } - -re ".*registers from core file: File in wrong format.* $" { -- fail "args: execfile -core=corefile (could not read registers from core file)" -+ fail "args: execfile -core=[file tail $corefile] (could not read registers from core file)" - } -- -re ".*$gdb_prompt $" { fail "args: execfile -core=corefile" } -+ -re ".*$gdb_prompt $" { fail "args: execfile -core=[file tail $corefile]" } - timeout { fail "(timeout) starting with -core" } - } - set timeout $oldtimeout -@@ -178,7 +125,7 @@ gdb_load ${binfile} - - # Test basic corefile recognition via core-file command. - --send_gdb "core-file $objdir/$subdir/corefile\n" -+send_gdb "core-file $corefile\n" - gdb_expect { - -re ".* program is being debugged already.*y or n. $" { - # gdb_load may connect us to a gdbserver. -diff --git a/gdb/testsuite/gdb.base/pie-support.c b/gdb/testsuite/gdb.base/pie-support.c -deleted file mode 100644 -index 63768b9..0000000 ---- a/gdb/testsuite/gdb.base/pie-support.c -+++ /dev/null -@@ -1,34 +0,0 @@ --/* This testcase is part of GDB, the GNU debugger. -- -- Copyright 2009 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 -- --void --f1 (int a) --{ -- printf ("a = %d\n", a); --} -- --int --main (int argc, char *argv[]) --{ -- f1 (1); -- -- return 0; --} -diff --git a/gdb/testsuite/gdb.base/pie-support.exp b/gdb/testsuite/gdb.base/pie-support.exp -deleted file mode 100644 -index 7d118c0..0000000 ---- a/gdb/testsuite/gdb.base/pie-support.exp -+++ /dev/null -@@ -1,58 +0,0 @@ --# Copyright 2009 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 . -- --set testfile pie-support --set srcfile ${testfile}.c --set objfile ${objdir}/${subdir}/${testfile}.o --set binfile ${objdir}/${subdir}/${testfile} -- --if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${objfile}" object {quiet debug additional_flags=-fpie}] != "" } { -- untested "Couldn't compile test PIE object file." -- return -1 --} --if { [gdb_compile "${objfile}" "${binfile}" executable {quiet debug additional_flags=-pie}] != "" } { -- untested "Couldn't compile test PIE binary." -- return -1 --} -- --# Get things started. -- --gdb_exit --gdb_start --gdb_reinitialize_dir $srcdir/$subdir -- --if [is_remote host] { -- set binfile [remote_download host $binfile] -- if { $binfile == "" } { -- untested "Couldn't download remote test binary." -- return -1 -- } --} -- --# The file command used to kill the remote target. For the benefit --# of the testsuite, preserve this behavior. --send_gdb "kill\n" --gdb_expect 120 { -- -re "Kill the program being debugged. .y or n. $" { -- send_gdb "y\n" -- verbose "\t\tKilling previous program being debugged" -- exp_continue -- } -- -re "$gdb_prompt $" { -- # OK. -- } --} -- --gdb_test "file $binfile" "current binary is a PIE.*" "correctly detected PIE binary" -diff --git a/gdb/testsuite/gdb.base/valgrind-db-attach.c b/gdb/testsuite/gdb.base/valgrind-db-attach.c -new file mode 100644 -index 0000000..5faaaac ---- /dev/null -+++ b/gdb/testsuite/gdb.base/valgrind-db-attach.c -@@ -0,0 +1,30 @@ -+/* This testcase is part of GDB, the GNU debugger. -+ -+ Copyright 2009 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 -+ -+int main() -+{ -+ void *p; -+ -+ p = malloc (1); -+ if (p == NULL) -+ return 1; -+ free (p); -+ free (p); /* double-free */ -+ return 0; -+} -diff --git a/gdb/testsuite/gdb.base/valgrind-db-attach.exp b/gdb/testsuite/gdb.base/valgrind-db-attach.exp -new file mode 100644 -index 0000000..ac06fd3 ---- /dev/null -+++ b/gdb/testsuite/gdb.base/valgrind-db-attach.exp -@@ -0,0 +1,74 @@ -+# Copyright 2009 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 . -+ -+set test valgrind-db-attach -+set srcfile $test.c -+set executable $test -+set binfile ${objdir}/${subdir}/${executable} -+if {[build_executable $test.exp $executable $srcfile {debug}] == -1} { -+ return -1 -+} -+ -+gdb_exit -+ -+# remote_spawn breaks the command on each whitespace despite possible quoting. -+# Use backslash-escaped whitespace there instead: -+ -+set db_command "--db-command=$GDB $INTERNAL_GDBFLAGS $GDBFLAGS [host_info gdb_opts] %f %p" -+regsub -all " " $db_command "\\ " db_command -+ -+set test "spawn valgrind" -+set cmd "valgrind --db-attach=yes $db_command $binfile" -+set res [remote_spawn host $cmd]; -+if { $res < 0 || $res == "" } { -+ verbose -log "Spawning $cmd failed." -+ setup_xfail *-*-* -+ fail $test -+ return -1 -+} -+pass $test -+# Declare GDB now as running. -+set gdb_spawn_id -1 -+ -+set test "valgrind started" -+# The trailing '.' differs for different memcheck versions. -+gdb_test_multiple "" $test { -+ -re "Memcheck, a memory error detector\\.?\r\n" { -+ pass $test -+ } -+ -re "valgrind: failed to start tool 'memcheck' for platform '.*': No such file or directory" { -+ setup_xfail *-*-* -+ fail $test -+ return -1 -+ } -+} -+ -+set double_free [gdb_get_line_number "double-free"] -+ -+gdb_test_multiple "" $test { -+ -re "Invalid free\\(\\) / delete / delete\\\[\\\]\r\n.*: main \\(${srcfile}:$double_free\\)\r\n.*---- Attach to debugger \\? --- \[^\r\n\]* ---- " { -+ send_gdb "y\r" -+ } -+ -re "---- Attach to debugger \\? --- \[^\r\n\]* ---- " { -+ send_gdb "n\r" -+ exp_continue -+ } -+} -+ -+# Initialization from default_gdb_start. -+gdb_test "set height 0" -+gdb_test "set width 0" -+ -+gdb_test "bt" "in main \\(.*\\) at .*${srcfile}:$double_free" -diff --git a/gdb/testsuite/gdb.dwarf2/dw2-ranges.exp b/gdb/testsuite/gdb.dwarf2/dw2-ranges.exp -index 61e1fe4..9109030 100644 ---- a/gdb/testsuite/gdb.dwarf2/dw2-ranges.exp -+++ b/gdb/testsuite/gdb.dwarf2/dw2-ranges.exp -@@ -55,6 +55,12 @@ gdb_start - gdb_reinitialize_dir $srcdir/$subdir - gdb_load ${binfile} - -+# Test also objfile->psymtabs_addrmap relocations for -fPIE -pie builds below. -+# On some targets it may possibly fail but the program is being started only -+# for the PIE build so try it anyway. -+ -+runto_main -+ - # Correct output: - # Line 39 of "../.././gdb/testsuite/gdb.dwarf2/dw2-ranges.S" starts at address 0x4 and ends at 0x8. - # Wrong output: -diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp -index d0c3493..fbf9124 100644 ---- a/gdb/testsuite/lib/gdb.exp -+++ b/gdb/testsuite/lib/gdb.exp -@@ -2778,6 +2778,11 @@ proc gdb_gnu_strip_debug { dest args } { - return 1 - } - -+ # Workaround PR binutils/10802: -+ # Preserve the 'x' bit also for PIEs (Position Independent Executables). -+ set perm [file attributes ${dest} -permissions] -+ file attributes ${stripped_file} -permissions $perm -+ - # Get rid of everything but the debug info, and store result in debug_file - # This will be in the .debug subdirectory, see above. - set result [catch "exec $strip_to_file_program --only-keep-debug ${dest} -o ${debug_file}" output] -@@ -2814,7 +2819,12 @@ proc gdb_gnu_strip_debug { dest args } { - return 1 - } - -- return 0 -+ # Workaround PR binutils/10802: -+ # Preserve the 'x' bit also for PIEs (Position Independent Executables). -+ set perm [file attributes ${stripped_file} -permissions] -+ file attributes ${dest} -permissions $perm -+ -+ return 0 - } - - # Test the output of GDB_COMMAND matches the pattern obtained -@@ -3043,3 +3053,70 @@ if {[info exists TRANSCRIPT]} { - return [uplevel real_send_gdb $args] - } - } -+ -+proc core_find {binfile {deletefiles {}} {arg ""}} { -+ global objdir subdir -+ -+ set destcore "$binfile.core" -+ file delete $destcore -+ -+ # Create a core file named "$destcore" rather than just "core", to -+ # avoid problems with sys admin types that like to regularly prune all -+ # files named "core" from the system. -+ # -+ # Arbitrarily try setting the core size limit to "unlimited" since -+ # this does not hurt on systems where the command does not work and -+ # allows us to generate a core on systems where it does. -+ # -+ # Some systems append "core" to the name of the program; others append -+ # the name of the program to "core"; still others (like Linux, as of -+ # May 2003) create cores named "core.PID". In the latter case, we -+ # could have many core files lying around, and it may be difficult to -+ # tell which one is ours, so let's run the program in a subdirectory. -+ set found 0 -+ set coredir "${objdir}/${subdir}/coredir.[getpid]" -+ file mkdir $coredir -+ catch "system \"(cd ${coredir}; ulimit -c unlimited; ${binfile} ${arg}; true) >/dev/null 2>&1\"" -+ # remote_exec host "${binfile}" -+ foreach i "${coredir}/core ${coredir}/core.coremaker.c ${binfile}.core" { -+ if [remote_file build exists $i] { -+ remote_exec build "mv $i $destcore" -+ set found 1 -+ } -+ } -+ # Check for "core.PID". -+ if { $found == 0 } { -+ set names [glob -nocomplain -directory $coredir core.*] -+ if {[llength $names] == 1} { -+ set corefile [file join $coredir [lindex $names 0]] -+ remote_exec build "mv $corefile $destcore" -+ set found 1 -+ } -+ } -+ if { $found == 0 } { -+ # The braindamaged HPUX shell quits after the ulimit -c above -+ # without executing ${binfile}. So we try again without the -+ # ulimit here if we didn't find a core file above. -+ # Oh, I should mention that any "braindamaged" non-Unix system has -+ # the same problem. I like the cd bit too, it's really neat'n stuff. -+ catch "system \"(cd ${objdir}/${subdir}; ${binfile}; true) >/dev/null 2>&1\"" -+ foreach i "${objdir}/${subdir}/core ${objdir}/${subdir}/core.coremaker.c ${binfile}.core" { -+ if [remote_file build exists $i] { -+ remote_exec build "mv $i $destcore" -+ set found 1 -+ } -+ } -+ } -+ -+ # Try to clean up after ourselves. -+ foreach deletefile $deletefiles { -+ remote_file build delete [file join $coredir $deletefile] -+ } -+ remote_exec build "rmdir $coredir" -+ -+ if { $found == 0 } { -+ warning "can't generate a core file - core tests suppressed - check ulimit -c" -+ return "" -+ } -+ return $destcore -+} diff --git a/gdb-archer.patch b/gdb-archer.patch index 330c50d..43fda9e 100644 --- a/gdb-archer.patch +++ b/gdb-archer.patch @@ -2,94 +2,62 @@ http://sourceware.org/gdb/wiki/ProjectArcher http://sourceware.org/gdb/wiki/ArcherBranchManagement GIT snapshot: -commit 16276c1aad1366b92e687c72cab30192280e1906 +commit 74fff58d0076fe97c6c99d65fa58126315266646 branch `archer' - the merge of branches: -archer-tromey-call-frame-cfa -archer-tromey-delayed-symfile -archer-tromey-dw-op-value archer-jankratochvil-vla -archer-jankratochvil-misc -archer-keiths-expr-cumulative -archer-tromey-python -archer-jankratochvil-fortran-module -archer-jankratochvil-watchpoint -archer-jankratochvil-bp_location-accel -archer-pmuldoon-next-over-throw +archer-jankratochvil-watchpoint3 +archer-jankratochvil-ifunc +archer-pmuldoon-next-over-throw2 +archer-tromey-python (not a merge) +archer-tromey-optional-psymtab (cherry-picked from post-7.2 master) +#TODO:archer-tromey-threaded-dwarf diff --git a/gdb/Makefile.in b/gdb/Makefile.in -index 7d53205..319fac4 100644 +index f07bc8b..3703dca 100644 --- a/gdb/Makefile.in +++ b/gdb/Makefile.in -@@ -169,6 +169,10 @@ TARGET_SYSTEM_ROOT_DEFINE = @TARGET_SYSTEM_ROOT_DEFINE@ - # Did the user give us a --with-gdb-datadir option? - GDB_DATADIR = @GDB_DATADIR@ +@@ -169,6 +169,12 @@ TARGET_SYSTEM_ROOT = @TARGET_SYSTEM_ROOT@ + TARGET_SYSTEM_ROOT_DEFINE = @TARGET_SYSTEM_ROOT_DEFINE@ + # Did the user give us a --with-gdb-datadir option? ++GDB_DATADIR_PATH = @GDB_DATADIR_PATH@ ++ +# The argument to --with-pythondir. If not given, this is +# GDB_DATADIR_PATH/python. +pythondir = @pythondir@ + + GDB_DATADIR = @GDB_DATADIR@ + # Helper code from gnulib. - LIBGNU = gnulib/libgnu.a - INCGNU = -I$(srcdir)/gnulib -Ignulib -@@ -267,21 +271,37 @@ SUBDIR_TUI_CFLAGS= \ - # - SUBDIR_PYTHON_OBS = \ - python.o \ -+ py-block.o \ -+ py-breakpoint.o \ - py-cmd.o \ - py-frame.o \ - py-function.o \ -+ py-hooks.o \ -+ py-inferior.o \ -+ py-infthread.o \ - py-objfile.o \ -+ py-param.o \ - py-prettyprint.o \ -+ py-symbol.o \ -+ py-symtab.o \ - py-type.o \ - py-utils.o \ - py-value.o - SUBDIR_PYTHON_SRCS = \ - python/python.c \ -+ python/py-block.c \ -+ python/py-breakpoint.c \ +@@ -295,13 +301,13 @@ SUBDIR_PYTHON_SRCS = \ python/py-cmd.c \ python/py-frame.c \ python/py-function.c \ + python/py-hooks.c \ -+ python/py-inferior.c \ -+ python/py-infthread.c \ + python/py-inferior.c \ + python/py-infthread.c \ + python/py-lazy-string.c \ python/py-objfile.c \ -+ python/py-param.c \ + python/py-param.c \ python/py-prettyprint.c \ -+ python/py-symbol.c \ -+ python/py-symtab.c \ +- python/py-progspace.c \ + python/py-symbol.c \ + python/py-symtab.c \ python/py-type.c \ - python/py-utils.c \ - python/py-value.c -@@ -750,7 +770,7 @@ config/rs6000/nm-rs6000.h top.h bsd-kvm.h gdb-stabs.h reggroups.h \ +@@ -780,8 +786,8 @@ config/rs6000/nm-rs6000.h top.h bsd-kvm.h gdb-stabs.h reggroups.h \ annotate.h sim-regno.h dictionary.h dfp.h main.h frame-unwind.h \ remote-fileio.h i386-linux-tdep.h vax-tdep.h objc-lang.h \ sentinel-frame.h bcache.h symfile.h windows-tdep.h linux-tdep.h \ --gdb_usleep.h jit.h xml-syscall.h ada-operator.inc -+gdb_usleep.h jit.h xml-syscall.h ada-operator.inc python/python.h python/python-internal.h +-gdb_usleep.h jit.h xml-syscall.h ada-operator.inc microblaze-tdep.h \ +-psymtab.h psympriv.h ++gdb_usleep.h jit.h python/python.h python/python-internal.h \ ++xml-syscall.h ada-operator.inc microblaze-tdep.h # Header files that already have srcdir in them, or which are in objdir. -@@ -874,7 +894,7 @@ generated_files = config.h observer.h observer.inc ada-lex.c \ - $(COMPILE) $< - $(POSTCOMPILE) - --all: gdb$(EXEEXT) $(CONFIG_ALL) xml-syscall-copy -+all: gdb$(EXEEXT) $(CONFIG_ALL) xml-syscall-copy .gdbinit - @$(MAKE) $(FLAGS_TO_PASS) DO=all "DODIRS=`echo $(SUBDIRS) | sed 's/testsuite//'`" subdir_do - .PHONY: all-tui - all-tui: $(TUI)$(EXEEXT) -@@ -1264,6 +1284,12 @@ stamp-h: $(srcdir)/config.in config.status +@@ -1301,6 +1307,12 @@ stamp-h: $(srcdir)/config.in config.status CONFIG_LINKS= \ $(SHELL) config.status @@ -102,22 +70,7 @@ index 7d53205..319fac4 100644 config.status: $(srcdir)/configure configure.tgt configure.host $(SHELL) config.status --recheck -@@ -1963,6 +1989,14 @@ python.o: $(srcdir)/python/python.c - $(COMPILE) $(PYTHON_CFLAGS) $(srcdir)/python/python.c - $(POSTCOMPILE) - -+py-block.o: $(srcdir)/python/py-block.c -+ $(COMPILE) $(PYTHON_CFLAGS) $(srcdir)/python/py-block.c -+ $(POSTCOMPILE) -+ -+py-breakpoint.o: $(srcdir)/python/py-breakpoint.c -+ $(COMPILE) $(PYTHON_CFLAGS) $(srcdir)/python/py-breakpoint.c -+ $(POSTCOMPILE) -+ - py-cmd.o: $(srcdir)/python/py-cmd.c - $(COMPILE) $(PYTHON_CFLAGS) $(srcdir)/python/py-cmd.c - $(POSTCOMPILE) -@@ -1975,14 +2009,38 @@ py-function.o: $(srcdir)/python/py-function.c +@@ -2024,6 +2036,10 @@ py-function.o: $(srcdir)/python/py-function.c $(COMPILE) $(PYTHON_CFLAGS) $(srcdir)/python/py-function.c $(POSTCOMPILE) @@ -125,38 +78,10 @@ index 7d53205..319fac4 100644 + $(COMPILE) $(PYTHON_CFLAGS) $(srcdir)/python/py-hooks.c + $(POSTCOMPILE) + -+py-inferior.o: $(srcdir)/python/py-inferior.c -+ $(COMPILE) $(PYTHON_CFLAGS) $(srcdir)/python/py-inferior.c -+ $(POSTCOMPILE) -+ -+py-infthread.o: $(srcdir)/python/py-infthread.c -+ $(COMPILE) $(PYTHON_CFLAGS) $(srcdir)/python/py-infthread.c -+ $(POSTCOMPILE) -+ - py-objfile.o: $(srcdir)/python/py-objfile.c - $(COMPILE) $(PYTHON_CFLAGS) $(srcdir)/python/py-objfile.c - $(POSTCOMPILE) - -+py-param.o: $(srcdir)/python/py-param.c -+ $(COMPILE) $(PYTHON_CFLAGS) $(srcdir)/python/py-param.c -+ $(POSTCOMPILE) -+ - py-prettyprint.o: $(srcdir)/python/py-prettyprint.c - $(COMPILE) $(PYTHON_CFLAGS) $(srcdir)/python/py-prettyprint.c + py-inferior.o: $(srcdir)/python/py-inferior.c + $(COMPILE) $(PYTHON_CFLAGS) $(srcdir)/python/py-inferior.c $(POSTCOMPILE) - -+py-symbol.o: $(srcdir)/python/py-symbol.c -+ $(COMPILE) $(PYTHON_CFLAGS) $(srcdir)/python/py-symbol.c -+ $(POSTCOMPILE) -+ -+py-symtab.o: $(srcdir)/python/py-symtab.c -+ $(COMPILE) $(PYTHON_CFLAGS) $(srcdir)/python/py-symtab.c -+ $(POSTCOMPILE) -+ - py-type.o: $(srcdir)/python/py-type.c - $(COMPILE) $(PYTHON_CFLAGS) $(srcdir)/python/py-type.c - $(POSTCOMPILE) -@@ -1995,6 +2053,36 @@ py-value.o: $(srcdir)/python/py-value.c +@@ -2072,6 +2088,36 @@ py-value.o: $(srcdir)/python/py-value.c $(COMPILE) $(PYTHON_CFLAGS) $(srcdir)/python/py-value.c $(POSTCOMPILE) @@ -193,171 +118,44 @@ index 7d53205..319fac4 100644 # # Dependency tracking. Most of this is conditional on GNU Make being # found by configure; if GNU Make is not found, we fall back to a -diff --git a/gdb/NEWS b/gdb/NEWS -index 8d32c34..f7ea21b 100644 ---- a/gdb/NEWS -+++ b/gdb/NEWS -@@ -476,6 +476,13 @@ x86/x86_64 Darwin i[34567]86-*-darwin* - - x86_64 MinGW x86_64-*-mingw* - -+* New native configurations -+ -+x86/x86_64 Darwin i[34567]86-*-darwin* -+ -+info os processes -+ Show operating system information about processes. -+ - * New targets - - Lattice Mico32 lm32-* diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c -index 9b5d2c6..61676a9 100644 +index 1d4c38b..cafb88e 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c -@@ -1621,7 +1621,7 @@ ada_type_of_array (struct value *arr, int bounds) - return NULL; - while (arity > 0) - { -- struct type *range_type = alloc_type_copy (value_type (arr)); -+ struct type *range_type = alloc_type_copy (value_type (arr)); - struct type *array_type = alloc_type_copy (value_type (arr)); - struct value *low = desc_one_bound (descriptor, arity, 0); - struct value *high = desc_one_bound (descriptor, arity, 1); -@@ -4727,14 +4727,10 @@ ada_lookup_symbol (const char *name, const struct block *block0, - - static struct symbol * - ada_lookup_symbol_nonlocal (const char *name, -- const char *linkage_name, - const struct block *block, - const domain_enum domain) - { -- if (linkage_name == NULL) -- linkage_name = name; -- return ada_lookup_symbol (linkage_name, block_static_block (block), domain, -- NULL); -+ return ada_lookup_symbol (name, block_static_block (block), domain, NULL); - } - - -@@ -10839,6 +10835,40 @@ ada_operator_length (struct expression *exp, int pc, int *oplenp, int *argsp) - } - } +@@ -11114,6 +11114,7 @@ ada_operator_length (const struct expression *exp, int pc, int *oplenp, -+/* Implementation of the exp_descriptor method operator_check. */ -+ -+static int -+ada_operator_check (struct expression *exp, int pos, + static int + ada_operator_check (struct expression *exp, int pos, + int (*type_func) (struct type *type, void *data), -+ int (*objfile_func) (struct objfile *objfile, void *data), -+ void *data) -+{ -+ const union exp_element *const elts = exp->elts; -+ struct type *type = NULL; -+ -+ switch (elts[pos].opcode) -+ { -+ case UNOP_IN_RANGE: -+ case UNOP_QUAL: -+ type = elts[pos + 1].type; -+ break; -+ -+ default: + int (*objfile_func) (struct objfile *objfile, void *data), + void *data) + { +@@ -11128,12 +11129,15 @@ ada_operator_check (struct expression *exp, int pos, + break; + + default: +- return operator_check_standard (exp, pos, objfile_func, data); + return operator_check_standard (exp, pos, type_func, objfile_func, + data); -+ } -+ -+ /* Invoke callbacks for TYPE and OBJFILE if they were set as non-NULL. */ -+ + } + + /* Invoke callbacks for TYPE and OBJFILE if they were set as non-NULL. */ + +- if (type && TYPE_OBJFILE (type) + if (type && type_func && (*type_func) (type, data)) + return 1; + if (type && TYPE_OBJFILE (type) && objfile_func -+ && (*objfile_func) (TYPE_OBJFILE (type), data)) -+ return 1; -+ -+ return 0; -+} -+ - static char * - ada_op_name (enum exp_opcode opcode) - { -@@ -11227,6 +11257,7 @@ parse (void) - static const struct exp_descriptor ada_exp_descriptor = { - ada_print_subexp, - ada_operator_length, -+ ada_operator_check, - ada_op_name, - ada_dump_subexp_body, - ada_evaluate_subexp + && (*objfile_func) (TYPE_OBJFILE (type), data)) + return 1; + diff --git a/gdb/amd64-linux-nat.c b/gdb/amd64-linux-nat.c -index 7d8461c..fc4b3e0 100644 +index c0edc10..17d36b5 100644 --- a/gdb/amd64-linux-nat.c +++ b/gdb/amd64-linux-nat.c -@@ -270,6 +270,8 @@ amd64_linux_dr_get (ptid_t ptid, int regnum) - return value; - } - -+/* Set debug register REGNUM to VALUE in only the one LWP of PTID. */ -+ - static void - amd64_linux_dr_set (ptid_t ptid, int regnum, unsigned long value) - { -@@ -286,6 +288,8 @@ amd64_linux_dr_set (ptid_t ptid, int regnum, unsigned long value) - perror_with_name (_("Couldn't write debug register")); - } - -+/* Set DR_CONTROL to ADDR in all LWPs of LWP_LIST. */ -+ - static void - amd64_linux_dr_set_control (unsigned long control) - { -@@ -297,6 +301,8 @@ amd64_linux_dr_set_control (unsigned long control) - amd64_linux_dr_set (ptid, DR_CONTROL, control); - } - -+/* Set address REGNUM (zero based) to ADDR in all LWPs of LWP_LIST. */ -+ - static void - amd64_linux_dr_set_addr (int regnum, CORE_ADDR addr) - { -@@ -310,18 +316,55 @@ amd64_linux_dr_set_addr (int regnum, CORE_ADDR addr) - amd64_linux_dr_set (ptid, DR_FIRSTADDR + regnum, addr); - } - -+/* Set address REGNUM (zero based) to zero in all LWPs of LWP_LIST. */ -+ - static void - amd64_linux_dr_reset_addr (int regnum) - { - amd64_linux_dr_set_addr (regnum, 0); - } - -+/* Get DR_STATUS from only the one LWP of INFERIOR_PTID. */ -+ - static unsigned long - amd64_linux_dr_get_status (void) - { - return amd64_linux_dr_get (inferior_ptid, DR_STATUS); +@@ -375,6 +375,20 @@ amd64_linux_dr_unset_status (unsigned long mask) + } } -+/* Unset MASK bits in DR_STATUS in all LWPs of LWP_LIST. */ -+ -+static void -+amd64_linux_dr_unset_status (unsigned long mask) -+{ -+ struct lwp_info *lp; -+ ptid_t ptid; -+ -+ ALL_LWPS (lp, ptid) -+ { -+ unsigned long value; -+ -+ value = amd64_linux_dr_get (ptid, DR_STATUS); -+ value &= ~mask; -+ amd64_linux_dr_set (ptid, DR_STATUS, value); -+ } -+} -+ +/* See i386_dr_low_type.detach. Do not use wrappers amd64_linux_dr_set_control + or amd64_linux_dr_reset_addr as they would modify the register cache + (amd64_linux_dr). */ @@ -372,40 +170,22 @@ index 7d8461c..fc4b3e0 100644 + for (regnum = DR_FIRSTADDR; regnum <= DR_LASTADDR; regnum++) + amd64_linux_dr_set (inferior_ptid, regnum, 0); +} -+ + static void amd64_linux_new_thread (ptid_t ptid) - { -@@ -672,6 +715,8 @@ _initialize_amd64_linux_nat (void) - i386_dr_low.set_addr = amd64_linux_dr_set_addr; +@@ -796,6 +810,7 @@ _initialize_amd64_linux_nat (void) i386_dr_low.reset_addr = amd64_linux_dr_reset_addr; i386_dr_low.get_status = amd64_linux_dr_get_status; -+ i386_dr_low.unset_status = amd64_linux_dr_unset_status; + i386_dr_low.unset_status = amd64_linux_dr_unset_status; + i386_dr_low.detach = amd64_linux_dr_detach; i386_set_debug_register_length (8); /* Override the GNU/Linux inferior startup hook. */ diff --git a/gdb/block.c b/gdb/block.c -index 97ea67a..b20beeb 100644 +index 48ac21b..ffcc97f 100644 --- a/gdb/block.c +++ b/gdb/block.c -@@ -227,8 +227,9 @@ block_set_scope (struct block *block, const char *scope, - BLOCK_NAMESPACE (block)->scope = scope; - } - --/* This returns the using directives list associated with BLOCK, if -- any. */ -+/* This returns the first using directives associated with BLOCK, if -+ any. Each BLOCK_NAMESPACE()->USING already contains all the namespaces -+ imported at that code point - even those from its parent blocks. */ - - struct using_direct * - block_using (const struct block *block) -@@ -318,6 +319,25 @@ allocate_block (struct obstack *obstack) - BLOCK_SUPERBLOCK (bl) = NULL; - BLOCK_DICT (bl) = NULL; - BLOCK_NAMESPACE (bl) = NULL; -+ BLOCK_FORTRAN_USE (bl) = NULL; +@@ -321,3 +321,21 @@ allocate_block (struct obstack *obstack) return bl; } @@ -428,390 +208,187 @@ index 97ea67a..b20beeb 100644 + return SYMBOL_SYMTAB (func)->objfile; +} diff --git a/gdb/block.h b/gdb/block.h -index 53e7371..d373f8a 100644 +index 7eedb6c..a517e80 100644 --- a/gdb/block.h +++ b/gdb/block.h -@@ -96,6 +96,15 @@ struct block - cplus_specific; - } - language_specific; -+ -+ /* FIXME: It should be in the LANGUAGE_SPECIFIC region but the -+ BLOCK_NAMESPACE accessor is not protected by the C language check. */ -+ -+ struct -+ { -+ struct fortran_using *use; -+ } -+ fortran_specific; - }; - - #define BLOCK_START(bl) (bl)->startaddr -@@ -104,6 +113,7 @@ struct block - #define BLOCK_SUPERBLOCK(bl) (bl)->superblock - #define BLOCK_DICT(bl) (bl)->dict - #define BLOCK_NAMESPACE(bl) (bl)->language_specific.cplus_specific.namespace -+#define BLOCK_FORTRAN_USE(bl) (bl)->fortran_specific.use - - /* Macro to loop through all symbols in a block BL, in no particular - order. ITER helps keep track of the iteration, and should be a -@@ -166,4 +176,6 @@ extern const struct block *block_global_block (const struct block *block); +@@ -166,4 +166,6 @@ extern const struct block *block_global_block (const struct block *block); extern struct block *allocate_block (struct obstack *obstack); +extern struct objfile *block_objfile (const struct block *block); + #endif /* BLOCK_H */ +diff --git a/gdb/blockframe.c b/gdb/blockframe.c +index 0348bf4..f01d0ee 100644 +--- a/gdb/blockframe.c ++++ b/gdb/blockframe.c +@@ -38,6 +38,7 @@ + #include "block.h" + #include "inline-frame.h" + #include "psymtab.h" ++#include "elf-bfd.h" + + /* Return the innermost lexical block in execution + in a specified stack frame. The frame address is assumed valid. +@@ -159,6 +160,7 @@ static CORE_ADDR cache_pc_function_low = 0; + static CORE_ADDR cache_pc_function_high = 0; + static char *cache_pc_function_name = 0; + static struct obj_section *cache_pc_function_section = NULL; ++static int cache_pc_function_is_gnu_ifunc = 0; + + /* Clear cache, e.g. when symbol table is discarded. */ + +@@ -169,6 +171,7 @@ clear_pc_function_cache (void) + cache_pc_function_high = 0; + cache_pc_function_name = (char *) 0; + cache_pc_function_section = NULL; ++ cache_pc_function_is_gnu_ifunc = 0; + } + + /* Finds the "function" (text symbol) that is smaller than PC but +@@ -184,7 +187,7 @@ clear_pc_function_cache (void) + + /* Backward compatibility, no section argument. */ + +-int ++enum find_pc_partial_function_type + find_pc_partial_function (CORE_ADDR pc, char **name, CORE_ADDR *address, + CORE_ADDR *endaddr) + { +@@ -236,6 +239,7 @@ find_pc_partial_function (CORE_ADDR pc, char **name, CORE_ADDR *address, + cache_pc_function_high = BLOCK_END (SYMBOL_BLOCK_VALUE (f)); + cache_pc_function_name = SYMBOL_LINKAGE_NAME (f); + cache_pc_function_section = section; ++ cache_pc_function_is_gnu_ifunc = TYPE_GNU_IFUNC (SYMBOL_TYPE (f)); + goto return_cached_value; + } + } +@@ -258,12 +262,13 @@ find_pc_partial_function (CORE_ADDR pc, char **name, CORE_ADDR *address, + *address = 0; + if (endaddr != NULL) + *endaddr = 0; +- return 0; ++ return FIND_PC_PARTIAL_FUNCTION_NOT_FOUND; + } + + cache_pc_function_low = SYMBOL_VALUE_ADDRESS (msymbol); + cache_pc_function_name = SYMBOL_LINKAGE_NAME (msymbol); + cache_pc_function_section = section; ++ cache_pc_function_is_gnu_ifunc = MSYMBOL_TYPE (msymbol) == mst_text_gnu_ifunc; + + /* If the minimal symbol has a size, use it for the cache. + Otherwise use the lesser of the next minimal symbol in the same +@@ -323,7 +328,8 @@ find_pc_partial_function (CORE_ADDR pc, char **name, CORE_ADDR *address, + *endaddr = cache_pc_function_high; + } + +- return 1; ++ return cache_pc_function_is_gnu_ifunc ? FIND_PC_PARTIAL_FUNCTION_GNU_IFUNC ++ : FIND_PC_PARTIAL_FUNCTION_NORMAL; + } + + /* Return the innermost stack frame executing inside of BLOCK, diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c -index 811cdfb..0f35101 100644 +index 6a6864c..5df336d 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c -@@ -61,6 +61,7 @@ - #include "valprint.h" +@@ -62,6 +62,7 @@ #include "jit.h" #include "xml-syscall.h" -+#include "parser-defs.h" + #include "parser-defs.h" ++#include "regcache.h" /* readline include files */ #include "readline/readline.h" -@@ -112,8 +113,6 @@ struct breakpoint *set_raw_breakpoint (struct gdbarch *gdbarch, - struct symtab_and_line, - enum bptype); - --static void check_duplicates (struct breakpoint *); -- - static void breakpoint_adjustment_warning (CORE_ADDR, CORE_ADDR, int, int); +@@ -92,6 +93,9 @@ static void map_breakpoint_numbers (char *, void (*) (struct breakpoint *, - static CORE_ADDR adjust_breakpoint_address (struct gdbarch *gdbarch, -@@ -337,14 +336,14 @@ static int executing_startup; - B ? (TMP=B->next, 1): 0; \ - B = TMP) + static void ignore_command (char *, int); --/* Similar iterators for the low-level breakpoints. */ -- --#define ALL_BP_LOCATIONS(B) for (B = bp_location_chain; B; B = B->global_next) -+/* Similar iterator for the low-level breakpoints. SAFE variant is not -+ provided so update_global_location_list must not be called while executing -+ the block of ALL_BP_LOCATIONS. */ ++static void update_breakpoint_locations (struct breakpoint *b, ++ struct symtabs_and_lines sals); ++ + static int breakpoint_re_set_one (void *); --#define ALL_BP_LOCATIONS_SAFE(B,TMP) \ -- for (B = bp_location_chain; \ -- B ? (TMP=B->global_next, 1): 0; \ -- B = TMP) -+#define ALL_BP_LOCATIONS(B,BP_TMP) \ -+ for (BP_TMP = bp_location; \ -+ BP_TMP < bp_location + bp_location_count && (B = *BP_TMP); \ -+ BP_TMP++) + static void clear_command (char *, int); +@@ -106,6 +110,9 @@ static void break_command_1 (char *, int, int); - /* Iterator for tracepoints only. */ + static void mention (struct breakpoint *); -@@ -356,10 +355,31 @@ static int executing_startup; ++static struct bp_location *add_location_to_breakpoint (struct breakpoint *b, ++ const struct symtab_and_line *sal); ++ + /* This function is used in gdbtk sources and thus can not be made static. */ + struct breakpoint *set_raw_breakpoint (struct gdbarch *gdbarch, + struct symtab_and_line, +@@ -230,6 +237,10 @@ static void disable_trace_command (char *, int); - struct breakpoint *breakpoint_chain; + static void trace_pass_command (char *, int); --struct bp_location *bp_location_chain; -+/* Array is sorted by bp_location_compare - primarily by the ADDRESS. */ -+ -+static struct bp_location **bp_location; -+ -+/* Number of elements of BP_LOCATION. */ -+ -+static unsigned bp_location_count; ++static void gnu_ifunc_resolver_stop (struct breakpoint *b); + -+/* Maximum alignment offset between bp_target_info.PLACED_ADDRESS and ADDRESS -+ for the current elements of BP_LOCATION which get a valid result from -+ bp_location_has_shadow. You can use it for roughly limiting the subrange of -+ BP_LOCATION to scan for shadow bytes for an address you need to read. */ ++static void gnu_ifunc_resolver_return_stop (struct breakpoint *b); + -+static CORE_ADDR bp_location_placed_address_before_address_max; -+ -+/* Maximum offset plus alignment between -+ bp_target_info.PLACED_ADDRESS + bp_target_info.SHADOW_LEN and ADDRESS for -+ the current elements of BP_LOCATION which get a valid result from -+ bp_location_has_shadow. You can use it for roughly limiting the subrange of -+ BP_LOCATION to scan for shadow bytes for an address you need to read. */ -+ -+static CORE_ADDR bp_location_shadow_len_after_address_max; + /* Assuming we're creating a static tracepoint, does S look like a + static tracepoint marker spec ("-m MARKER_ID")? */ + #define is_marker_spec(s) \ +@@ -430,7 +441,7 @@ static int tracepoint_count; - /* The locations that no longer correspond to any breakpoint, -- unlinked from bp_location_chain, but for which a hit -+ unlinked from bp_location array, but for which a hit - may still be reported by a target. */ - VEC(bp_location_p) *moribund_locations = NULL; + static struct cmd_list_element *breakpoint_set_cmdlist; + static struct cmd_list_element *breakpoint_show_cmdlist; +-static struct cmd_list_element *save_cmdlist; ++struct cmd_list_element *save_cmdlist; -@@ -582,6 +602,53 @@ get_breakpoint (int num) + /* Return whether a breakpoint is an active enabled breakpoint. */ + static int +@@ -1252,6 +1263,22 @@ watchpoint_in_thread_scope (struct breakpoint *b) + && !is_executing (inferior_ptid))); } - -+/* Set break condition of breakpoint B to EXP. */ -+ -+void -+set_breakpoint_condition (struct breakpoint *b, char *exp, int from_tty) ++static void ++watchpoint_del_at_next_stop (struct breakpoint *b) +{ -+ struct bp_location *loc = b->loc; -+ -+ for (; loc; loc = loc->next) -+ { -+ if (loc->cond) -+ { -+ xfree (loc->cond); -+ loc->cond = 0; -+ } -+ } ++ gdb_assert (is_watchpoint (b)); + -+ if (b->cond_string != NULL) -+ xfree (b->cond_string); -+ -+ if (*exp == 0) -+ { -+ b->cond_string = NULL; -+ if (from_tty) -+ printf_filtered (_("Breakpoint %d now unconditional.\n"), b->number); -+ } -+ else ++ if (b->related_breakpoint != b) + { -+ char *arg = exp; -+ -+ /* I don't know if it matters whether this is the string the user -+ typed in or the decompiled expression. */ -+ b->cond_string = xstrdup (arg); -+ b->condition_not_parsed = 0; -+ for (loc = b->loc; loc; loc = loc->next) -+ { -+ arg = exp; -+ loc->cond = -+ parse_exp_1 (&arg, block_for_pc (loc->address), 0); -+ if (*arg) -+ error (_("Junk at end of expression")); -+ } ++ gdb_assert (b->related_breakpoint->type == bp_watchpoint_scope); ++ gdb_assert (b->related_breakpoint->related_breakpoint == b); ++ b->related_breakpoint->disposition = disp_del_at_next_stop; ++ b->related_breakpoint->related_breakpoint = b->related_breakpoint; ++ b->related_breakpoint = b; + } -+ -+ breakpoints_changed (); -+ observer_notify_breakpoint_modified (b->number); ++ b->disposition = disp_del_at_next_stop; +} + - /* condition N EXP -- set break condition of breakpoint N to EXP. */ + /* Assuming that B is a watchpoint: + - Reparse watchpoint expression, if REPARSE is non-zero + - Evaluate expression and store the result in B->val +@@ -1307,6 +1334,8 @@ update_watchpoint (struct breakpoint *b, int reparse) + struct frame_id saved_frame_id; + int frame_saved; - static void -@@ -602,42 +669,7 @@ condition_command (char *arg, int from_tty) - ALL_BREAKPOINTS (b) - if (b->number == bnum) - { -- struct bp_location *loc = b->loc; -- for (; loc; loc = loc->next) -- { -- if (loc->cond) -- { -- xfree (loc->cond); -- loc->cond = 0; -- } -- } -- if (b->cond_string != NULL) -- xfree (b->cond_string); -- -- if (*p == 0) -- { -- b->cond_string = NULL; -- if (from_tty) -- printf_filtered (_("Breakpoint %d now unconditional.\n"), bnum); -- } -- else -- { -- arg = p; -- /* I don't know if it matters whether this is the string the user -- typed in or the decompiled expression. */ -- b->cond_string = xstrdup (arg); -- b->condition_not_parsed = 0; -- for (loc = b->loc; loc; loc = loc->next) -- { -- arg = p; -- loc->cond = -- parse_exp_1 (&arg, block_for_pc (loc->address), 0); -- if (*arg) -- error (_("Junk at end of expression")); -- } -- } -- breakpoints_changed (); -- observer_notify_breakpoint_modified (b->number); -+ set_breakpoint_condition (b, p, from_tty); - return; - } - -@@ -735,35 +767,88 @@ commands_from_control_command (char *arg, struct command_line *cmd) - } - error (_("No breakpoint number %d."), bnum); - } -- -+ -+/* Return non-zero if BL->TARGET_INFO contains valid information. */ -+ -+static int -+bp_location_has_shadow (struct bp_location *bl) -+{ -+ if (bl->loc_type != bp_loc_software_breakpoint) -+ return 0; -+ if (!bl->inserted) -+ return 0; -+ if (bl->target_info.shadow_len == 0) -+ /* bp isn't valid, or doesn't shadow memory. */ -+ return 0; -+ return 1; -+} -+ - /* Update BUF, which is LEN bytes read from the target address MEMADDR, -- by replacing any memory breakpoints with their shadowed contents. */ -+ by replacing any memory breakpoints with their shadowed contents. -+ -+ The range of shadowed area by each bp_location is: -+ b->address - bp_location_placed_address_before_address_max -+ up to b->address + bp_location_shadow_len_after_address_max -+ The range we were requested to resolve shadows for is: -+ memaddr ... memaddr + le -+ Thus the safe cutoff boundaries for performance optimization are -+ memaddr + len <= b->address - bp_location_placed_address_before_address_max -+ and: -+ b->address + bp_location_shadow_len_after_address_max <= memaddr */ - - void - breakpoint_restore_shadows (gdb_byte *buf, ULONGEST memaddr, LONGEST len) - { -- struct bp_location *b; -- CORE_ADDR bp_addr = 0; -- int bp_size = 0; -- int bptoffset = 0; -+ /* Left boundary, right boundary and media element of our binary search. */ -+ unsigned bc_l, bc_r, bc; -+ -+ /* Find BC_L which is a leftmost element which may affect BUF content. It is -+ safe to report lower value but a failure to report higher one. */ - -- ALL_BP_LOCATIONS (b) -+ bc_l = 0; -+ bc_r = bp_location_count; -+ while (bc_l + 1 < bc_r) -+ { -+ struct bp_location *b; -+ -+ bc = (bc_l + bc_r) / 2; -+ b = bp_location[bc]; -+ -+ if (b->address + bp_location_shadow_len_after_address_max >= b->address -+ && b->address + bp_location_shadow_len_after_address_max <= memaddr) -+ bc_l = bc; -+ else -+ bc_r = bc; -+ } -+ -+ /* Now do full processing of the found relevant range of elements. */ -+ -+ for (bc = bc_l; bc < bp_location_count; bc++) - { -+ struct bp_location *b = bp_location[bc]; -+ CORE_ADDR bp_addr = 0; -+ int bp_size = 0; -+ int bptoffset = 0; -+ - if (b->owner->type == bp_none) - warning (_("reading through apparently deleted breakpoint #%d?"), - b->owner->number); - -- if (b->loc_type != bp_loc_software_breakpoint) -- continue; -- if (!b->inserted) -+ /* Performance optimization: any futher element can no longer affect BUF -+ content. */ -+ -+ if (b->address >= bp_location_placed_address_before_address_max -+ && memaddr + len <= b->address -+ - bp_location_placed_address_before_address_max) -+ break; -+ -+ if (!bp_location_has_shadow (b)) - continue; ++ gdb_assert (is_watchpoint (b)); + - /* Addresses and length of the part of the breakpoint that - we need to copy. */ - bp_addr = b->target_info.placed_address; - bp_size = b->target_info.shadow_len; -- if (bp_size == 0) -- /* bp isn't valid, or doesn't shadow memory. */ -- continue; - - if (bp_addr + bp_size <= memaddr) - /* The breakpoint is entirely before the chunk of memory we -@@ -912,7 +997,7 @@ update_watchpoint (struct breakpoint *b, int reparse) - struct bp_location *loc; - bpstat bs; - -- /* We don't free locations. They are stored in bp_location_chain and -+ /* We don't free locations. They are stored in bp_location array and - update_global_locations will eventually delete them and remove - breakpoints if needed. */ - b->loc = NULL; -@@ -1347,7 +1432,7 @@ static void - insert_breakpoint_locations (void) - { - struct breakpoint *bpt; -- struct bp_location *b, *temp; -+ struct bp_location *b, **bp_tmp; - int error = 0; - int val = 0; - int disabled_breaks = 0; -@@ -1360,7 +1445,7 @@ insert_breakpoint_locations (void) - there was an error. */ - fprintf_unfiltered (tmp_error_stream, "Warning:\n"); - -- ALL_BP_LOCATIONS_SAFE (b, temp) -+ ALL_BP_LOCATIONS (b, bp_tmp) - { - if (!should_be_inserted (b) || b->inserted) - continue; -@@ -1434,10 +1519,10 @@ You may have requested too many hardware breakpoints/watchpoints.\n"); - int - remove_breakpoints (void) - { -- struct bp_location *b; -+ struct bp_location *b, **bp_tmp; - int val = 0; - -- ALL_BP_LOCATIONS (b) -+ ALL_BP_LOCATIONS (b, bp_tmp) - { - if (b->inserted) - val |= remove_breakpoint (b, mark_uninserted); -@@ -1448,10 +1533,10 @@ remove_breakpoints (void) - int - remove_hw_watchpoints (void) - { -- struct bp_location *b; -+ struct bp_location *b, **bp_tmp; - int val = 0; + /* If this is a local watchpoint, we only want to check if the + watchpoint frame is in scope if the current thread is the thread + that was used to create the watchpoint. */ +@@ -1510,13 +1539,7 @@ update_watchpoint (struct breakpoint *b, int reparse) + Watchpoint %d deleted because the program has left the block\n\ + in which its expression is valid.\n"), + b->number); +- if (b->related_breakpoint) +- { +- b->related_breakpoint->disposition = disp_del_at_next_stop; +- b->related_breakpoint->related_breakpoint = NULL; +- b->related_breakpoint= NULL; +- } +- b->disposition = disp_del_at_next_stop; ++ watchpoint_del_at_next_stop (b); + } -- ALL_BP_LOCATIONS (b) -+ ALL_BP_LOCATIONS (b, bp_tmp) - { - if (b->inserted && b->loc_type == bp_loc_hardware_watchpoint) - val |= remove_breakpoint (b, mark_uninserted); -@@ -1462,7 +1547,7 @@ remove_hw_watchpoints (void) - int - reattach_breakpoints (int pid) - { -- struct bp_location *b; -+ struct bp_location *b, **bp_tmp; - int val; - struct cleanup *old_chain = save_inferior_ptid (); - struct ui_file *tmp_error_stream = mem_fileopen (); -@@ -1471,7 +1556,7 @@ reattach_breakpoints (int pid) - make_cleanup_ui_file_delete (tmp_error_stream); - - inferior_ptid = pid_to_ptid (pid); -- ALL_BP_LOCATIONS (b) -+ ALL_BP_LOCATIONS (b, bp_tmp) - { - if (b->inserted) - { -@@ -1569,12 +1654,42 @@ create_longjmp_master_breakpoint (char *func_name) - update_global_location_list (1); + /* Restore the selected frame. */ +@@ -2201,6 +2224,33 @@ create_std_terminate_master_breakpoint (const char *func_name) + do_cleanups (old_chain); } +/* Install a master breakpoint on the unwinder's debug hook. */ @@ -828,14 +405,11 @@ index 811cdfb..0f35101 100644 + debug_hook = lookup_minimal_symbol_text ("_Unwind_DebugHook", objfile); + if (debug_hook != NULL) + { -+ CORE_ADDR pc; + struct breakpoint *b; + -+ pc = find_function_start_pc (get_objfile_arch (objfile), -+ SYMBOL_VALUE_ADDRESS (debug_hook), -+ SYMBOL_OBJ_SECTION (debug_hook)); + b = create_internal_breakpoint (get_objfile_arch (objfile), -+ pc, bp_exception_master); ++ SYMBOL_VALUE_ADDRESS (debug_hook), ++ bp_exception_master); + b->addr_string = xstrdup ("_Unwind_DebugHook"); + b->enable_state = bp_disabled; + } @@ -847,32 +421,17 @@ index 811cdfb..0f35101 100644 void update_breakpoints_after_exec (void) { - struct breakpoint *b; - struct breakpoint *temp; -- struct bp_location *bploc; -+ struct bp_location *bploc, **bplocp_tmp; - - /* We're about to delete breakpoints from GDB's lists. If the - INSERTED flag is true, GDB will try to lift the breakpoints by -@@ -1584,7 +1699,7 @@ update_breakpoints_after_exec (void) - breakpoints out as soon as it detects an exec. We don't do that - here instead, because there may be other attempts to delete - breakpoints after detecting an exec and before reaching here. */ -- ALL_BP_LOCATIONS (bploc) -+ ALL_BP_LOCATIONS (bploc, bplocp_tmp) - gdb_assert (!bploc->inserted); - - ALL_BREAKPOINTS_SAFE (b, temp) -@@ -1606,7 +1721,7 @@ update_breakpoints_after_exec (void) +@@ -2242,7 +2292,8 @@ update_breakpoints_after_exec (void) /* Thread event breakpoints must be set anew after an exec(), as must overlay event and longjmp master breakpoints. */ if (b->type == bp_thread_event || b->type == bp_overlay_event -- || b->type == bp_longjmp_master) -+ || b->type == bp_longjmp_master || b->type == bp_exception_master) +- || b->type == bp_longjmp_master || b->type == bp_std_terminate_master) ++ || b->type == bp_longjmp_master || b->type == bp_std_terminate_master ++ || b->type == bp_exception_master) { delete_breakpoint (b); continue; -@@ -1621,7 +1736,8 @@ update_breakpoints_after_exec (void) +@@ -2257,7 +2308,8 @@ update_breakpoints_after_exec (void) /* Longjmp and longjmp-resume breakpoints are also meaningless after an exec. */ @@ -882,36 +441,24 @@ index 811cdfb..0f35101 100644 { delete_breakpoint (b); continue; -@@ -1682,12 +1798,13 @@ update_breakpoints_after_exec (void) - create_longjmp_master_breakpoint ("_longjmp"); +@@ -2319,6 +2371,7 @@ update_breakpoints_after_exec (void) create_longjmp_master_breakpoint ("siglongjmp"); create_longjmp_master_breakpoint ("_siglongjmp"); + create_std_terminate_master_breakpoint ("std::terminate()"); + create_exception_master_breakpoint (); } int - detach_breakpoints (int pid) - { -- struct bp_location *b; -+ struct bp_location *b, **bp_tmp; - int val = 0; - struct cleanup *old_chain = save_inferior_ptid (); - -@@ -1696,11 +1813,12 @@ detach_breakpoints (int pid) +@@ -2346,6 +2399,8 @@ detach_breakpoints (int pid) + /* Detach single-step breakpoints as well. */ + detach_single_step_breakpoints (); - /* Set inferior_ptid; remove_breakpoint uses this global. */ - inferior_ptid = pid_to_ptid (pid); -- ALL_BP_LOCATIONS (b) -+ ALL_BP_LOCATIONS (b, bp_tmp) - { - if (b->inserted) - val |= remove_breakpoint (b, mark_inserted); - } + val |= target_detach_watchpoints (); ++ do_cleanups (old_chain); return val; } -@@ -1793,12 +1911,14 @@ remove_breakpoint (struct bp_location *b, insertion_state_t is) +@@ -2447,9 +2502,11 @@ remove_breakpoint_1 (struct bp_location *b, insertion_state_t is) return val; b->inserted = (is == mark_inserted); } @@ -920,106 +467,12 @@ index 811cdfb..0f35101 100644 + target_detach_watchpoints. */ + else if (b->loc_type == bp_loc_hardware_watchpoint && is == mark_uninserted) { - struct value *v; - struct value *n; - - b->inserted = (is == mark_inserted); + b->inserted = 0; - val = target_remove_watchpoint (b->address, b->length, - b->watchpoint_type); + val = target_remove_watchpoint (b->address, b->length, + b->watchpoint_type, b->owner->cond_exp); -@@ -1827,9 +1947,9 @@ remove_breakpoint (struct bp_location *b, insertion_state_t is) - void - mark_breakpoints_out (void) - { -- struct bp_location *bpt; -+ struct bp_location *bpt, **bptp_tmp; - -- ALL_BP_LOCATIONS (bpt) -+ ALL_BP_LOCATIONS (bpt, bptp_tmp) - bpt->inserted = 0; - } - -@@ -1849,7 +1969,7 @@ void - breakpoint_init_inferior (enum inf_context context) - { - struct breakpoint *b, *temp; -- struct bp_location *bpt; -+ struct bp_location *bpt, **bptp_tmp; - int ix; - - /* If breakpoint locations are shared across processes, then there's -@@ -1857,7 +1977,7 @@ breakpoint_init_inferior (enum inf_context context) - if (gdbarch_has_global_breakpoints (target_gdbarch)) - return; - -- ALL_BP_LOCATIONS (bpt) -+ ALL_BP_LOCATIONS (bpt, bptp_tmp) - if (bpt->owner->enable_state != bp_permanent) - bpt->inserted = 0; - -@@ -1918,10 +2038,10 @@ breakpoint_init_inferior (enum inf_context context) - enum breakpoint_here - breakpoint_here_p (CORE_ADDR pc) - { -- const struct bp_location *bpt; -+ struct bp_location *bpt, **bptp_tmp; - int any_breakpoint_here = 0; - -- ALL_BP_LOCATIONS (bpt) -+ ALL_BP_LOCATIONS (bpt, bptp_tmp) - { - if (bpt->loc_type != bp_loc_software_breakpoint - && bpt->loc_type != bp_loc_hardware_breakpoint) -@@ -1961,16 +2081,16 @@ moribund_breakpoint_here_p (CORE_ADDR pc) - } - - /* Returns non-zero if there's a breakpoint inserted at PC, which is -- inserted using regular breakpoint_chain/bp_location_chain mechanism. -+ inserted using regular breakpoint_chain / bp_location array mechanism. - This does not check for single-step breakpoints, which are - inserted and removed using direct target manipulation. */ - - int - regular_breakpoint_inserted_here_p (CORE_ADDR pc) - { -- const struct bp_location *bpt; -+ struct bp_location *bpt, **bptp_tmp; - -- ALL_BP_LOCATIONS (bpt) -+ ALL_BP_LOCATIONS (bpt, bptp_tmp) - { - if (bpt->loc_type != bp_loc_software_breakpoint - && bpt->loc_type != bp_loc_hardware_breakpoint) -@@ -2011,10 +2131,10 @@ breakpoint_inserted_here_p (CORE_ADDR pc) - int - software_breakpoint_inserted_here_p (CORE_ADDR pc) - { -- const struct bp_location *bpt; -+ struct bp_location *bpt, **bptp_tmp; - int any_breakpoint_here = 0; - -- ALL_BP_LOCATIONS (bpt) -+ ALL_BP_LOCATIONS (bpt, bptp_tmp) - { - if (bpt->loc_type != bp_loc_software_breakpoint) - continue; -@@ -2044,12 +2164,12 @@ software_breakpoint_inserted_here_p (CORE_ADDR pc) - int - breakpoint_thread_match (CORE_ADDR pc, ptid_t ptid) - { -- const struct bp_location *bpt; -+ struct bp_location *bpt, **bptp_tmp; - /* The thread and task IDs associated to PTID, computed lazily. */ - int thread = -1; - int task = 0; - -- ALL_BP_LOCATIONS (bpt) -+ ALL_BP_LOCATIONS (bpt, bptp_tmp) - { - if (bpt->loc_type != bp_loc_software_breakpoint - && bpt->loc_type != bp_loc_hardware_breakpoint) -@@ -2503,6 +2623,12 @@ print_it_typical (bpstat bs) +@@ -3237,6 +3294,12 @@ print_it_typical (bpstat bs) result = PRINT_NOTHING; break; @@ -1032,7 +485,7 @@ index 811cdfb..0f35101 100644 case bp_watchpoint: case bp_hardware_watchpoint: annotate_watchpoint (b->number); -@@ -2590,6 +2716,8 @@ print_it_typical (bpstat bs) +@@ -3324,6 +3387,8 @@ print_it_typical (bpstat bs) case bp_none: case bp_longjmp: case bp_longjmp_resume: @@ -1041,9 +494,42 @@ index 811cdfb..0f35101 100644 case bp_step_resume: case bp_watchpoint_scope: case bp_call_dummy: -@@ -2973,8 +3101,12 @@ bpstat_check_location (const struct bp_location *bl, CORE_ADDR bp_addr) - - /* If BS refers to a watchpoint, determine if the watched values +@@ -3331,6 +3396,8 @@ print_it_typical (bpstat bs) + case bp_tracepoint: + case bp_fast_tracepoint: + case bp_jit_event: ++ case bp_gnu_ifunc_resolver: ++ case bp_gnu_ifunc_resolver_return: + default: + result = PRINT_UNKNOWN; + break; +@@ -3549,6 +3616,8 @@ watchpoint_check (void *p) + gdb_assert (bs->breakpoint_at->owner != NULL); + b = bs->breakpoint_at->owner; + ++ gdb_assert (is_watchpoint (b)); ++ + /* If this is a local watchpoint, we only want to check if the + watchpoint frame is in scope if the current thread is the thread + that was used to create the watchpoint. */ +@@ -3655,13 +3724,7 @@ watchpoint_check (void *p) + ui_out_text (uiout, " deleted because the program has left the block in\n\ + which its expression is valid.\n"); + +- if (b->related_breakpoint) +- { +- b->related_breakpoint->disposition = disp_del_at_next_stop; +- b->related_breakpoint->related_breakpoint = NULL; +- b->related_breakpoint = NULL; +- } +- b->disposition = disp_del_at_next_stop; ++ watchpoint_del_at_next_stop (b); + + return WP_DELETED; + } +@@ -3730,8 +3793,12 @@ bpstat_check_location (const struct bp_location *bl, + + /* If BS refers to a watchpoint, determine if the watched values has actually changed, and we should stop. If not, set BS->stop - to 0. */ -static void @@ -1055,8 +541,19 @@ index 811cdfb..0f35101 100644 +static int bpstat_check_watchpoint (bpstat bs) { - const struct bp_location *bl = bs->breakpoint_at; -@@ -3063,8 +3195,10 @@ bpstat_check_watchpoint (bpstat bs) + const struct bp_location *bl; +@@ -3865,9 +3932,7 @@ bpstat_check_watchpoint (bpstat bs) + case 0: + /* Error from catch_errors. */ + printf_filtered (_("Watchpoint %d deleted.\n"), b->number); +- if (b->related_breakpoint) +- b->related_breakpoint->disposition = disp_del_at_next_stop; +- b->disposition = disp_del_at_next_stop; ++ watchpoint_del_at_next_stop (b); + /* We've already printed what needs to be printed. */ + bs->print_it = print_it_done; + break; +@@ -3881,8 +3946,10 @@ bpstat_check_watchpoint (bpstat bs) anything for this watchpoint. */ bs->print_it = print_it_noop; bs->stop = 0; @@ -1067,125 +564,154 @@ index 811cdfb..0f35101 100644 } -@@ -3157,17 +3291,19 @@ bpstat - bpstat_stop_status (CORE_ADDR bp_addr, ptid_t ptid) - { - struct breakpoint *b = NULL; -- const struct bp_location *bl; -+ struct bp_location *bl, **blp_tmp; - struct bp_location *loc; - /* Root of the chain of bpstat's */ - struct bpstats root_bs[1]; - /* Pointer to the last thing in the chain currently. */ - bpstat bs = root_bs; - int ix; -- int need_remove_insert; -+ int need_remove_insert, update_locations = 0; - -- ALL_BP_LOCATIONS (bl) -+ ALL_BP_LOCATIONS (bl, blp_tmp) - { -+ bpstat bs_prev = bs; -+ - b = bl->owner; - gdb_assert (b); - if (!breakpoint_enabled (b) && b->enable_state != bp_permanent) -@@ -3188,6 +3324,7 @@ bpstat_stop_status (CORE_ADDR bp_addr, ptid_t ptid) - /* Come here if it's a watchpoint, or if the break address matches */ - - bs = bpstat_alloc (bl, bs); /* Alloc a bpstat to explain stop */ -+ gdb_assert (bs_prev->next == bs); - - /* Assume we stop. Should we find watchpoint that is not actually - triggered, or if condition of breakpoint is false, we'll reset -@@ -3195,12 +3332,21 @@ bpstat_stop_status (CORE_ADDR bp_addr, ptid_t ptid) - bs->stop = 1; - bs->print = 1; - -- bpstat_check_watchpoint (bs); -- if (!bs->stop) -- continue; -+ if (!bpstat_check_watchpoint (bs)) -+ { -+ /* Ensure bpstat_explains_signal stays false if this BL could not be -+ the cause of this trap. */ -+ -+ gdb_assert (bs->print_it == print_it_noop); -+ gdb_assert (!bs->stop); -+ xfree (bs); -+ bs = bs_prev; -+ bs->next = NULL; -+ continue; -+ } +@@ -3914,7 +3981,7 @@ bpstat_check_breakpoint_conditions (bpstat bs, ptid_t ptid) + watchpoint as triggered so that we will handle the + out-of-scope event. We'll get to the watchpoint next + iteration. */ +- if (b->type == bp_watchpoint_scope) ++ if (b->type == bp_watchpoint_scope && b->related_breakpoint != b) + b->related_breakpoint->watchpoint_triggered = watch_triggered_yes; - if (b->type == bp_thread_event || b->type == bp_overlay_event -- || b->type == bp_longjmp_master) -+ || b->type == bp_longjmp_master || b->type == bp_exception_master) - /* We do not stop for these. */ - bs->stop = 0; - else -@@ -3208,14 +3354,15 @@ bpstat_stop_status (CORE_ADDR bp_addr, ptid_t ptid) - - if (bs->stop) - { -- ++(b->hit_count); -+ if (b->enable_state != bp_disabled) -+ ++(b->hit_count); + if (is_watchpoint (b)) +@@ -4045,6 +4112,8 @@ bpstat_stop_status (struct address_space *aspace, - /* We will stop here */ - if (b->disposition == disp_disable) - { - if (b->enable_state != bp_permanent) - b->enable_state = bp_disabled; -- update_global_location_list (0); -+ update_locations = 1; - } - if (b->silent) - bs->print = 0; -@@ -3235,6 +3382,10 @@ bpstat_stop_status (CORE_ADDR bp_addr, ptid_t ptid) - bs->print_it = print_it_noop; - } + for (bl = b->loc; bl != NULL; bl = bl->next) + { ++ bpstat bs_prev = bs; ++ + /* For hardware watchpoints, we look only at the first location. + The watchpoint_check function will work on the entire expression, + not the individual locations. For read watchpoints, the +@@ -4062,6 +4131,7 @@ bpstat_stop_status (struct address_space *aspace, + /* Come here if it's a watchpoint, or if the break address matches */ + + bs = bpstat_alloc (bl, bs); /* Alloc a bpstat to explain stop */ ++ gdb_assert (bs_prev->next == bs); + + /* Assume we stop. Should we find watchpoint that is not actually + triggered, or if condition of breakpoint is false, we'll reset +@@ -4069,13 +4139,23 @@ bpstat_stop_status (struct address_space *aspace, + bs->stop = 1; + bs->print = 1; + +- bpstat_check_watchpoint (bs); +- if (!bs->stop) +- continue; ++ if (!bpstat_check_watchpoint (bs)) ++ { ++ /* Ensure bpstat_explains_signal stays false if this BL could not be ++ the cause of this trap. */ ++ ++ gdb_assert (bs->print_it == print_it_noop); ++ gdb_assert (!bs->stop); ++ xfree (bs); ++ bs = bs_prev; ++ bs->next = NULL; ++ continue; ++ } -+ /* Delay this call which would break the ALL_BP_LOCATIONS iteration above. */ -+ if (update_locations) -+ update_global_location_list (0); -+ - for (ix = 0; VEC_iterate (bp_location_p, moribund_locations, ix, loc); ++ix) - { - if (loc->address == bp_addr) -@@ -3412,6 +3563,7 @@ bpstat_what (bpstat bs) - struct bpstat_what retval; + if (b->type == bp_thread_event || b->type == bp_overlay_event + || b->type == bp_longjmp_master +- || b->type == bp_std_terminate_master) ++ || b->type == bp_std_terminate_master ++ || b->type == bp_exception_master) + /* We do not stop for these. */ + bs->stop = 0; + else +@@ -4176,7 +4256,7 @@ handle_jit_event (void) + /* Decide what infrun needs to do with this bpstat. */ - retval.call_dummy = 0; + struct bpstat_what +-bpstat_what (bpstat bs) ++bpstat_what (bpstat bs_head) + { + struct bpstat_what retval; + /* We need to defer calling `solib_add', as adding new symbols +@@ -4184,11 +4264,13 @@ bpstat_what (bpstat bs) + and hence may clear unprocessed entries in the BS chain. */ + int shlib_event = 0; + int jit_event = 0; ++ bpstat bs; + + retval.main_action = BPSTAT_WHAT_KEEP_CHECKING; + retval.call_dummy = STOP_NONE; + retval.is_longjmp = 0; - for (; bs != NULL; bs = bs->next) + +- for (; bs != NULL; bs = bs->next) ++ for (bs = bs_head; bs != NULL; bs = bs->next) { - enum class bs_class = no_effect; -@@ -3458,10 +3610,15 @@ bpstat_what (bpstat bs) - bs_class = no_effect; + /* Extract this BS's action. After processing each BS, we check + if its action overrides all we've seem so far. */ +@@ -4242,10 +4324,15 @@ bpstat_what (bpstat bs) + } break; case bp_longjmp: + case bp_exception: - bs_class = long_jump; + this_action = BPSTAT_WHAT_SET_LONGJMP_RESUME; + retval.is_longjmp = bs->breakpoint_at->owner->type == bp_longjmp; break; case bp_longjmp_resume: + case bp_exception_resume: - bs_class = long_resume; + this_action = BPSTAT_WHAT_CLEAR_LONGJMP_RESUME; + retval.is_longjmp + = bs->breakpoint_at->owner->type == bp_longjmp_resume; break; case bp_step_resume: if (bs->stop) -@@ -3484,6 +3641,7 @@ bpstat_what (bpstat bs) - case bp_thread_event: +@@ -4261,6 +4348,7 @@ bpstat_what (bpstat bs) case bp_overlay_event: case bp_longjmp_master: + case bp_std_terminate_master: + case bp_exception_master: - bs_class = bp_nostop; + this_action = BPSTAT_WHAT_SINGLE; break; case bp_catchpoint: -@@ -3605,6 +3763,8 @@ print_one_breakpoint_location (struct breakpoint *b, +@@ -4313,6 +4401,20 @@ bpstat_what (bpstat bs) + out already. */ + internal_error (__FILE__, __LINE__, + _("bpstat_what: tracepoint encountered")); ++ break; ++ case bp_gnu_ifunc_resolver: ++ /* Skip the current breakpoint but otherwise nothing happens. GDB is ++ inserting new bp_gnu_ifunc_resolver_return at this point but ++ bp_gnu_ifunc_resolver is being kept there as another ++ bp_gnu_ifunc_resolver_return may be inserted in the meantime. */ ++ this_action = BPSTAT_WHAT_SINGLE; ++ break; ++ case bp_gnu_ifunc_resolver_return: ++ /* The whole bp_gnu_ifunc_resolver with its associated ++ bp_gnu_ifunc_resolver_return related_breakpoint's has been ++ resolved now, all these helper breakpoints are being removed and ++ new final bp_breakpoint is being put at the target location. */ ++ break; + default: + internal_error (__FILE__, __LINE__, + _("bpstat_what: unhandled bptype %d"), (int) bptype); +@@ -4350,6 +4452,23 @@ bpstat_what (bpstat bs) + handle_jit_event (); + } + ++ for (bs = bs_head; bs != NULL; bs = bs->next) ++ { ++ if (bs->breakpoint_at == NULL) ++ continue; ++ if (bs->breakpoint_at->owner == NULL) ++ continue; ++ switch (bs->breakpoint_at->owner->type) ++ { ++ case bp_gnu_ifunc_resolver: ++ gnu_ifunc_resolver_stop (bs->breakpoint_at->owner); ++ break; ++ case bp_gnu_ifunc_resolver_return: ++ gnu_ifunc_resolver_return_stop (bs->breakpoint_at->owner); ++ break; ++ } ++ } ++ + return retval; + } + +@@ -4461,6 +4580,8 @@ print_one_breakpoint_location (struct breakpoint *b, {bp_access_watchpoint, "acc watchpoint"}, {bp_longjmp, "longjmp"}, {bp_longjmp_resume, "longjmp resume"}, @@ -1194,15 +720,22 @@ index 811cdfb..0f35101 100644 {bp_step_resume, "step resume"}, {bp_watchpoint_scope, "watchpoint scope"}, {bp_call_dummy, "call dummy"}, -@@ -3612,6 +3772,7 @@ print_one_breakpoint_location (struct breakpoint *b, - {bp_thread_event, "thread events"}, +@@ -4470,11 +4591,14 @@ print_one_breakpoint_location (struct breakpoint *b, {bp_overlay_event, "overlay events"}, {bp_longjmp_master, "longjmp master"}, + {bp_std_terminate_master, "std::terminate master"}, + {bp_exception_master, "exception master"}, {bp_catchpoint, "catchpoint"}, {bp_tracepoint, "tracepoint"}, + {bp_fast_tracepoint, "fast tracepoint"}, + {bp_static_tracepoint, "static tracepoint"}, {bp_jit_event, "jit events"}, -@@ -3735,6 +3896,8 @@ print_one_breakpoint_location (struct breakpoint *b, ++ {bp_gnu_ifunc_resolver, "gnu-ifunc resolver"}, ++ {bp_gnu_ifunc_resolver_return, "gnu-func resolver return"}, + }; + + static char bpenables[] = "nynny"; +@@ -4595,6 +4719,8 @@ print_one_breakpoint_location (struct breakpoint *b, case bp_finish: case bp_longjmp: case bp_longjmp_resume: @@ -1211,116 +744,31 @@ index 811cdfb..0f35101 100644 case bp_step_resume: case bp_watchpoint_scope: case bp_call_dummy: -@@ -3742,6 +3905,7 @@ print_one_breakpoint_location (struct breakpoint *b, - case bp_thread_event: +@@ -4604,10 +4730,13 @@ print_one_breakpoint_location (struct breakpoint *b, case bp_overlay_event: case bp_longjmp_master: + case bp_std_terminate_master: + case bp_exception_master: case bp_tracepoint: + case bp_fast_tracepoint: + case bp_static_tracepoint: case bp_jit_event: ++ case bp_gnu_ifunc_resolver: ++ case bp_gnu_ifunc_resolver_return: if (opts.addressprint) -@@ -4197,9 +4361,8 @@ set_default_breakpoint (int valid, CORE_ADDR addr, struct symtab *symtab, - (or use it for any other purpose either). - - More specifically, each of the following breakpoint types will always -- have a zero valued address and we don't want check_duplicates() to mark -- breakpoints of any of these types to be a duplicate of an actual -- breakpoint at address zero: -+ have a zero valued address and we don't want to mark breakpoints of any of -+ these types to be a duplicate of an actual breakpoint at address zero: - - bp_watchpoint - bp_hardware_watchpoint -@@ -4219,88 +4382,6 @@ breakpoint_address_is_meaningful (struct breakpoint *bpt) - && type != bp_catchpoint); + { + annotate_field (4); +@@ -4888,7 +5017,8 @@ user_settable_breakpoint (const struct breakpoint *b) + || b->type == bp_catchpoint + || b->type == bp_hardware_breakpoint + || is_tracepoint (b) +- || is_watchpoint (b)); ++ || is_watchpoint (b) ++ || b->type == bp_gnu_ifunc_resolver); } - --/* Rescan breakpoints at the same address and section as BPT, -- marking the first one as "first" and any others as "duplicates". -- This is so that the bpt instruction is only inserted once. -- If we have a permanent breakpoint at the same place as BPT, make -- that one the official one, and the rest as duplicates. */ -- --static void --check_duplicates_for (CORE_ADDR address, struct obj_section *section) --{ -- struct bp_location *b; -- int count = 0; -- struct bp_location *perm_bp = 0; -- -- ALL_BP_LOCATIONS (b) -- if (b->owner->enable_state != bp_disabled -- && b->owner->enable_state != bp_call_disabled -- && b->owner->enable_state != bp_startup_disabled -- && b->enabled -- && !b->shlib_disabled -- && b->address == address /* address / overlay match */ -- && (!overlay_debugging || b->section == section) -- && breakpoint_address_is_meaningful (b->owner)) -- { -- /* Have we found a permanent breakpoint? */ -- if (b->owner->enable_state == bp_permanent) -- { -- perm_bp = b; -- break; -- } -- -- count++; -- b->duplicate = count > 1; -- } -- -- /* If we found a permanent breakpoint at this address, go over the -- list again and declare all the other breakpoints there (except -- other permanent breakpoints) to be the duplicates. */ -- if (perm_bp) -- { -- perm_bp->duplicate = 0; -- -- /* Permanent breakpoint should always be inserted. */ -- if (! perm_bp->inserted) -- internal_error (__FILE__, __LINE__, -- _("allegedly permanent breakpoint is not " -- "actually inserted")); -- -- ALL_BP_LOCATIONS (b) -- if (b != perm_bp) -- { -- if (b->owner->enable_state != bp_permanent -- && b->owner->enable_state != bp_disabled -- && b->owner->enable_state != bp_call_disabled -- && b->owner->enable_state != bp_startup_disabled -- && b->enabled && !b->shlib_disabled -- && b->address == address /* address / overlay match */ -- && (!overlay_debugging || b->section == section) -- && breakpoint_address_is_meaningful (b->owner)) -- { -- if (b->inserted) -- internal_error (__FILE__, __LINE__, -- _("another breakpoint was inserted on top of " -- "a permanent breakpoint")); -- -- b->duplicate = 1; -- } -- } -- } --} -- --static void --check_duplicates (struct breakpoint *bpt) --{ -- struct bp_location *bl = bpt->loc; -- -- if (! breakpoint_address_is_meaningful (bpt)) -- return; -- -- for (; bl; bl = bl->next) -- check_duplicates_for (bl->address, bl->section); --} -- - static void - breakpoint_adjustment_warning (CORE_ADDR from_addr, CORE_ADDR to_addr, - int bnum, int have_bnum) -@@ -4382,6 +4463,8 @@ allocate_bp_location (struct breakpoint *bpt) + + /* Print information on user settable breakpoint (watchpoint, etc) +@@ -5334,6 +5464,8 @@ allocate_bp_location (struct breakpoint *bpt) case bp_finish: case bp_longjmp: case bp_longjmp_resume: @@ -1329,15 +777,76 @@ index 811cdfb..0f35101 100644 case bp_step_resume: case bp_watchpoint_scope: case bp_call_dummy: -@@ -4390,6 +4473,7 @@ allocate_bp_location (struct breakpoint *bpt) - case bp_overlay_event: +@@ -5344,6 +5476,9 @@ allocate_bp_location (struct breakpoint *bpt) case bp_jit_event: case bp_longjmp_master: + case bp_std_terminate_master: ++ case bp_gnu_ifunc_resolver: ++ case bp_gnu_ifunc_resolver_return: + case bp_exception_master: loc->loc_type = bp_loc_software_breakpoint; break; case bp_hardware_breakpoint: -@@ -4568,8 +4652,7 @@ make_breakpoint_permanent (struct breakpoint *b) +@@ -5420,6 +5555,7 @@ set_raw_breakpoint_without_location (struct gdbarch *gdbarch, + b->syscalls_to_be_caught = NULL; + b->ops = NULL; + b->condition_not_parsed = 0; ++ b->related_breakpoint = b; + + /* Add this breakpoint to the end of the chain + so that a list of breakpoints will come out in order +@@ -5439,7 +5575,7 @@ set_raw_breakpoint_without_location (struct gdbarch *gdbarch, + + /* Initialize loc->function_name. */ + static void +-set_breakpoint_location_function (struct bp_location *loc) ++set_breakpoint_location_function (struct bp_location *loc, int explicit_loc) + { + gdb_assert (loc->owner != NULL); + +@@ -5447,8 +5583,29 @@ set_breakpoint_location_function (struct bp_location *loc) + || loc->owner->type == bp_hardware_breakpoint + || is_tracepoint (loc->owner)) + { +- find_pc_partial_function (loc->address, &(loc->function_name), +- NULL, NULL); ++ if (find_pc_partial_function (loc->address, &(loc->function_name), NULL, ++ NULL) == FIND_PC_PARTIAL_FUNCTION_GNU_IFUNC ++ && !explicit_loc) ++ { ++ struct breakpoint *b = loc->owner; ++ ++ gdb_assert (loc->pspace == current_program_space); ++ if (resolve_gnu_ifunc (loc->function_name, &loc->requested_address)) ++ { ++ /* Recalculate ADDRESS based on new REQUESTED_ADDRESS. */ ++ loc->address = adjust_breakpoint_address (loc->gdbarch, ++ loc->requested_address, ++ b->type); ++ } ++ else if (b->type == bp_breakpoint && b->loc == loc ++ && loc->next == NULL && b->related_breakpoint == b) ++ { ++ /* Create only the whole new breakpoint of this type but do not ++ mess more complicated breakpoints with multiple locations. */ ++ b->type = bp_gnu_ifunc_resolver; ++ } ++ } ++ + if (loc->function_name) + loc->function_name = xstrdup (loc->function_name); + } +@@ -5521,7 +5678,8 @@ set_raw_breakpoint (struct gdbarch *gdbarch, + b->loc->section = sal.section; + b->line_number = sal.line; + +- set_breakpoint_location_function (b->loc); ++ set_breakpoint_location_function (b->loc, ++ sal.explicit_pc || sal.explicit_line); + + breakpoints_changed (); + +@@ -5548,8 +5706,7 @@ make_breakpoint_permanent (struct breakpoint *b) } /* Call this routine when stepping and nexting to enable a breakpoint @@ -1347,20 +856,22 @@ index 811cdfb..0f35101 100644 void set_longjmp_breakpoint (int thread) -@@ -4581,10 +4664,10 @@ set_longjmp_breakpoint (int thread) - longjmp "master" breakpoints. Here, we simply create momentary +@@ -5562,11 +5719,12 @@ set_longjmp_breakpoint (int thread) clones of those and enable them for the requested thread. */ ALL_BREAKPOINTS_SAFE (b, temp) -- if (b->type == bp_longjmp_master) -+ if (b->type == bp_longjmp_master || b->type == bp_exception_master) + if (b->pspace == current_program_space +- && b->type == bp_longjmp_master) ++ && (b->type == bp_longjmp_master ++ || b->type == bp_exception_master)) { struct breakpoint *clone = clone_momentary_breakpoint (b); + - clone->type = bp_longjmp; + clone->type = b->type == bp_longjmp_master ? bp_longjmp : bp_exception; clone->thread = thread; } } -@@ -4596,7 +4679,7 @@ delete_longjmp_breakpoint (int thread) +@@ -5578,7 +5736,7 @@ delete_longjmp_breakpoint (int thread) struct breakpoint *b, *temp; ALL_BREAKPOINTS_SAFE (b, temp) @@ -1369,37 +880,33 @@ index 811cdfb..0f35101 100644 { if (b->thread == thread) delete_breakpoint (b); -@@ -4710,9 +4793,9 @@ create_solib_event_breakpoint (struct gdbarch *gdbarch, CORE_ADDR address) - void - disable_breakpoints_in_shlibs (void) - { -- struct bp_location *loc; -+ struct bp_location *loc, **locp_tmp; +@@ -6595,7 +6753,7 @@ clone_momentary_breakpoint (struct breakpoint *orig) -- ALL_BP_LOCATIONS (loc) -+ ALL_BP_LOCATIONS (loc, locp_tmp) - { - struct breakpoint *b = loc->owner; - /* We apply the check to all breakpoints, including disabled -@@ -4742,7 +4825,7 @@ disable_breakpoints_in_shlibs (void) - static void - disable_breakpoints_in_unloaded_shlib (struct so_list *solib) - { -- struct bp_location *loc; -+ struct bp_location *loc, **locp_tmp; - int disabled_shlib_breaks = 0; - - /* SunOS a.out shared libraries are always mapped, so do not -@@ -4753,7 +4836,7 @@ disable_breakpoints_in_unloaded_shlib (struct so_list *solib) - && bfd_get_flavour (exec_bfd) == bfd_target_aout_flavour) - return; + copy = set_raw_breakpoint_without_location (orig->gdbarch, orig->type); + copy->loc = allocate_bp_location (copy); +- set_breakpoint_location_function (copy->loc); ++ set_breakpoint_location_function (copy->loc, 1); -- ALL_BP_LOCATIONS (loc) -+ ALL_BP_LOCATIONS (loc, locp_tmp) - { - struct breakpoint *b = loc->owner; - if ((loc->loc_type == bp_loc_hardware_breakpoint -@@ -5648,6 +5731,8 @@ mention (struct breakpoint *b) + copy->loc->gdbarch = orig->loc->gdbarch; + copy->loc->requested_address = orig->loc->requested_address; +@@ -6694,6 +6852,7 @@ mention (struct breakpoint *b) + do_cleanups (ui_out_chain); + break; + case bp_breakpoint: ++ case bp_gnu_ifunc_resolver: + if (ui_out_is_mi_like_p (uiout)) + { + say_where = 0; +@@ -6704,6 +6863,8 @@ mention (struct breakpoint *b) + else + printf_filtered (_("Breakpoint")); + printf_filtered (_(" %d"), b->number); ++ if (b->type == bp_gnu_ifunc_resolver) ++ printf_filtered (_(" at gnu-indirect-function resolver")); + say_where = 1; + break; + case bp_hardware_breakpoint: +@@ -6750,6 +6911,8 @@ mention (struct breakpoint *b) case bp_finish: case bp_longjmp: case bp_longjmp_resume: @@ -1407,16 +914,27 @@ index 811cdfb..0f35101 100644 + case bp_exception_resume: case bp_step_resume: case bp_call_dummy: - case bp_watchpoint_scope: -@@ -5656,6 +5741,7 @@ mention (struct breakpoint *b) - case bp_overlay_event: + case bp_std_terminate: +@@ -6760,6 +6923,8 @@ mention (struct breakpoint *b) case bp_jit_event: case bp_longjmp_master: + case bp_std_terminate_master: ++ case bp_gnu_ifunc_resolver_return: + case bp_exception_master: break; } -@@ -6958,6 +7044,7 @@ struct until_break_command_continuation_args +@@ -6820,7 +6985,8 @@ add_location_to_breakpoint (struct breakpoint *b, + gdb_assert (loc->pspace != NULL); + loc->section = sal->section; + +- set_breakpoint_location_function (loc); ++ set_breakpoint_location_function (loc, ++ sal->explicit_pc || sal->explicit_line); + return loc; + } + +@@ -8346,6 +8512,7 @@ struct until_break_command_continuation_args { struct breakpoint *breakpoint; struct breakpoint *breakpoint2; @@ -1424,7 +942,7 @@ index 811cdfb..0f35101 100644 }; /* This function is called by fetch_inferior_event via the -@@ -6972,6 +7059,7 @@ until_break_command_continuation (void *arg) +@@ -8360,6 +8527,7 @@ until_break_command_continuation (void *arg) delete_breakpoint (a->breakpoint); if (a->breakpoint2) delete_breakpoint (a->breakpoint2); @@ -1432,7 +950,7 @@ index 811cdfb..0f35101 100644 } void -@@ -6983,6 +7071,8 @@ until_break_command (char *arg, int from_tty, int anywhere) +@@ -8371,6 +8539,8 @@ until_break_command (char *arg, int from_tty, int anywhere) struct breakpoint *breakpoint; struct breakpoint *breakpoint2 = NULL; struct cleanup *old_chain; @@ -1441,7 +959,7 @@ index 811cdfb..0f35101 100644 clear_proceed_status (); -@@ -7021,6 +7111,9 @@ until_break_command (char *arg, int from_tty, int anywhere) +@@ -8409,6 +8579,9 @@ until_break_command (char *arg, int from_tty, int anywhere) old_chain = make_cleanup_delete_breakpoint (breakpoint); @@ -1451,7 +969,7 @@ index 811cdfb..0f35101 100644 /* Keep within the current frame, or in frames called by the current one. */ -@@ -7033,6 +7126,10 @@ until_break_command (char *arg, int from_tty, int anywhere) +@@ -8421,6 +8594,10 @@ until_break_command (char *arg, int from_tty, int anywhere) frame_unwind_caller_id (frame), bp_until); make_cleanup_delete_breakpoint (breakpoint2); @@ -1462,7 +980,7 @@ index 811cdfb..0f35101 100644 } proceed (-1, TARGET_SIGNAL_DEFAULT, 0); -@@ -7049,6 +7146,7 @@ until_break_command (char *arg, int from_tty, int anywhere) +@@ -8437,6 +8614,7 @@ until_break_command (char *arg, int from_tty, int anywhere) args->breakpoint = breakpoint; args->breakpoint2 = breakpoint2; @@ -1470,383 +988,134 @@ index 811cdfb..0f35101 100644 discard_cleanups (old_chain); add_continuation (inferior_thread (), -@@ -7758,6 +7856,82 @@ do_vec_free (void *p) - VEC_free (bp_location_p, *vec); - } +@@ -9564,12 +9742,22 @@ delete_breakpoint (struct breakpoint *bpt) -+/* A comparison function for bp_location A and B being interfaced to qsort. -+ Sort elements primarily by their ADDRESS (no matter what does -+ breakpoint_address_is_meaningful say for its OWNER), secondarily by ordering -+ first bp_permanent OWNERed elements and terciarily just ensuring the array -+ is sorted stable way despite qsort being an instable algorithm. */ -+ -+static int -+bp_location_compare (struct bp_location *a, struct bp_location *b) -+{ -+ int a_perm = a->owner->enable_state == bp_permanent; -+ int b_perm = b->owner->enable_state == bp_permanent; -+ -+ if (a->address != b->address) -+ return (a->address > b->address) - (a->address < b->address); -+ -+ /* Sort permanent breakpoints first. */ -+ if (a_perm != b_perm) -+ return (a_perm < b_perm) - (a_perm > b_perm); -+ -+ /* Make the user-visible order stable across GDB runs. Locations of the same -+ breakpoint can be sorted in arbitrary order. */ -+ -+ if (a->owner->number != b->owner->number) -+ return (a->owner->number > b->owner->number) -+ - (a->owner->number < b->owner->number); -+ -+ return (a > b) - (a < b); -+} -+ -+/* Interface bp_location_compare as the COMPAR parameter of qsort function. */ -+ -+static int -+bp_location_compare_for_qsort (const void *ap, const void *bp) -+{ -+ struct bp_location *a = *(void **) ap; -+ struct bp_location *b = *(void **) bp; -+ -+ return bp_location_compare (a, b); -+} -+ -+/* Set bp_location_placed_address_before_address_max and -+ bp_location_shadow_len_after_address_max according to the current content of -+ the bp_location array. */ -+ -+static void -+bp_location_target_extensions_update (void) -+{ -+ struct bp_location *bl, **blp_tmp; -+ -+ bp_location_placed_address_before_address_max = 0; -+ bp_location_shadow_len_after_address_max = 0; -+ -+ ALL_BP_LOCATIONS (bl, blp_tmp) -+ { -+ CORE_ADDR start, end, addr; -+ -+ if (!bp_location_has_shadow (bl)) -+ continue; -+ -+ start = bl->target_info.placed_address; -+ end = start + bl->target_info.shadow_len; -+ -+ gdb_assert (bl->address >= start); -+ addr = bl->address - start; -+ if (addr > bp_location_placed_address_before_address_max) -+ bp_location_placed_address_before_address_max = addr; -+ -+ /* Zero SHADOW_LEN would not pass bp_location_has_shadow. */ -+ -+ gdb_assert (bl->address < end); -+ addr = end - bl->address; -+ if (addr > bp_location_shadow_len_after_address_max) -+ bp_location_shadow_len_after_address_max = addr; -+ } -+} -+ - /* If SHOULD_INSERT is false, do not insert any breakpoint locations - into the inferior, only remove already-inserted locations that no - longer should be inserted. Functions that delete a breakpoint or -@@ -7777,49 +7951,78 @@ static void - update_global_location_list (int should_insert) - { - struct breakpoint *b; -- struct bp_location **next = &bp_location_chain; -- struct bp_location *loc; -- struct bp_location *loc2; -- VEC(bp_location_p) *old_locations = NULL; -- int ret; -- int ix; -+ struct bp_location **locp, *loc; - struct cleanup *cleanups; - -- cleanups = make_cleanup (do_vec_free, &old_locations); -- /* Store old locations for future reference. */ -- for (loc = bp_location_chain; loc; loc = loc->global_next) -- VEC_safe_push (bp_location_p, old_locations, loc); -+ /* The first bp_location being the only one non-DUPLICATE for the current run -+ of the same ADDRESS. */ -+ struct bp_location *loc_first; -+ -+ /* Saved former bp_location array which we compare against the newly built -+ bp_location from the current state of ALL_BREAKPOINTS. */ -+ struct bp_location **old_location, **old_locp; -+ unsigned old_location_count; -+ -+ old_location = bp_location; -+ old_location_count = bp_location_count; -+ bp_location = NULL; -+ bp_location_count = 0; -+ cleanups = make_cleanup (xfree, old_location); - -- bp_location_chain = NULL; - ALL_BREAKPOINTS (b) -- { -- for (loc = b->loc; loc; loc = loc->next) -- { -- *next = loc; -- next = &(loc->global_next); -- *next = NULL; -- } -- } -+ for (loc = b->loc; loc; loc = loc->next) -+ bp_location_count++; -+ -+ bp_location = xmalloc (sizeof (*bp_location) * bp_location_count); -+ locp = bp_location; -+ ALL_BREAKPOINTS (b) -+ for (loc = b->loc; loc; loc = loc->next) -+ *locp++ = loc; -+ qsort (bp_location, bp_location_count, sizeof (*bp_location), -+ bp_location_compare_for_qsort); -+ -+ bp_location_target_extensions_update (); - - /* Identify bp_location instances that are no longer present in the new - list, and therefore should be freed. Note that it's not necessary that - those locations should be removed from inferior -- if there's another - location at the same address (previously marked as duplicate), -- we don't need to remove/insert the location. */ -- for (ix = 0; VEC_iterate(bp_location_p, old_locations, ix, loc); ++ix) -+ we don't need to remove/insert the location. -+ -+ LOCP is kept in sync with OLD_LOCP, each pointing to the current and -+ former bp_location array state respectively. */ -+ -+ locp = bp_location; -+ for (old_locp = old_location; old_locp < old_location + old_location_count; -+ old_locp++) + /* At least avoid this stale reference until the reference counting of + breakpoints gets resolved. */ +- if (bpt->related_breakpoint != NULL) ++ if (bpt->related_breakpoint != bpt) { -- /* Tells if 'loc' is found amoung the new locations. If not, we -+ struct bp_location *old_loc = *old_locp; -+ struct bp_location **loc2p; -+ -+ /* Tells if 'old_loc' is found amoung the new locations. If not, we - have to free it. */ - int found_object = 0; - /* Tells if the location should remain inserted in the target. */ - int keep_in_target = 0; - int removed = 0; -- for (loc2 = bp_location_chain; loc2; loc2 = loc2->global_next) -- if (loc2 == loc) -- { -- found_object = 1; -- break; -- } -+ -+ /* Skip LOCP entries which will definitely never be needed. Stop either -+ at or being the one matching OLD_LOC. */ -+ while (locp < bp_location + bp_location_count -+ && (*locp)->address < old_loc->address) -+ locp++; -+ -+ for (loc2p = locp; -+ (loc2p < bp_location + bp_location_count -+ && (*loc2p)->address == old_loc->address); -+ loc2p++) +- gdb_assert (bpt->related_breakpoint->related_breakpoint == bpt); +- bpt->related_breakpoint->disposition = disp_del_at_next_stop; +- bpt->related_breakpoint->related_breakpoint = NULL; +- bpt->related_breakpoint = NULL; ++ if (bpt->type == bp_watchpoint_scope) ++ watchpoint_del_at_next_stop (bpt->related_breakpoint); ++ else if (bpt->related_breakpoint->type == bp_watchpoint_scope) ++ watchpoint_del_at_next_stop (bpt); ++ else + { -+ if (*loc2p == old_loc) -+ { -+ found_object = 1; -+ break; -+ } -+ } - - /* If this location is no longer present, and inserted, look if there's - maybe a new location at the same address. If so, mark that one -@@ -7827,11 +8030,11 @@ update_global_location_list (int should_insert) - don't have a time window where a breakpoint at certain location is not - inserted. */ - -- if (loc->inserted) -+ if (old_loc->inserted) - { - /* If the location is inserted now, we might have to remove it. */ - -- if (found_object && should_be_inserted (loc)) -+ if (found_object && should_be_inserted (old_loc)) - { - /* The location is still present in the location list, and still - should be inserted. Don't do anything. */ -@@ -7842,37 +8045,46 @@ update_global_location_list (int should_insert) - /* The location is either no longer present, or got disabled. - See if there's another location at the same address, in which - case we don't need to remove this one from the target. */ -- if (breakpoint_address_is_meaningful (loc->owner)) -- for (loc2 = bp_location_chain; loc2; loc2 = loc2->global_next) -- { -- /* For the sake of should_insert_location. The -- call to check_duplicates will fix up this later. */ -- loc2->duplicate = 0; -- if (should_be_inserted (loc2) -- && loc2 != loc && loc2->address == loc->address) -- { -- loc2->inserted = 1; -- loc2->target_info = loc->target_info; -- keep_in_target = 1; -- break; -- } -- } -+ -+ if (breakpoint_address_is_meaningful (old_loc->owner)) -+ { -+ for (loc2p = locp; -+ (loc2p < bp_location + bp_location_count -+ && (*loc2p)->address == old_loc->address); -+ loc2p++) -+ { -+ struct bp_location *loc2 = *loc2p; -+ -+ { -+ /* For the sake of should_be_inserted. -+ Duplicates check below will fix up this later. */ -+ loc2->duplicate = 0; -+ if (loc2 != old_loc && should_be_inserted (loc2)) -+ { -+ loc2->inserted = 1; -+ loc2->target_info = old_loc->target_info; -+ keep_in_target = 1; -+ break; -+ } -+ } -+ } -+ } - } - - if (!keep_in_target) - { -- if (remove_breakpoint (loc, mark_uninserted)) -+ if (remove_breakpoint (old_loc, mark_uninserted)) - { - /* This is just about all we can do. We could keep this - location on the global list, and try to remove it next - time, but there's no particular reason why we will - succeed next time. - -- Note that at this point, loc->owner is still valid, -+ Note that at this point, old_loc->owner is still valid, - as delete_breakpoint frees the breakpoint only - after calling us. */ - printf_filtered (_("warning: Error removing breakpoint %d\n"), -- loc->owner->number); -+ old_loc->owner->number); - } - removed = 1; - } -@@ -7894,19 +8106,59 @@ update_global_location_list (int should_insert) - longer need to keep this breakpoint. This is just a - heuristic, but if it's wrong, we'll report unexpected SIGTRAP, - which is usability issue, but not a correctness problem. */ -- loc->events_till_retirement = 3 * (thread_count () + 1); -- loc->owner = NULL; -+ old_loc->events_till_retirement = 3 * (thread_count () + 1); -+ old_loc->owner = NULL; - -- VEC_safe_push (bp_location_p, moribund_locations, loc); -+ VEC_safe_push (bp_location_p, moribund_locations, old_loc); - } - else -- free_bp_location (loc); -+ free_bp_location (old_loc); - } - } - -- ALL_BREAKPOINTS (b) -+ /* Rescan breakpoints at the same address and section, -+ marking the first one as "first" and any others as "duplicates". -+ This is so that the bpt instruction is only inserted once. -+ If we have a permanent breakpoint at the same place as BPT, make -+ that one the official one, and the rest as duplicates. Permanent -+ breakpoints are sorted first for the same address. */ -+ -+ loc_first = NULL; -+ ALL_BP_LOCATIONS (loc, locp) - { -- check_duplicates (b); -+ struct breakpoint *b = loc->owner; -+ -+ if (b->enable_state == bp_disabled -+ || b->enable_state == bp_call_disabled -+ || b->enable_state == bp_startup_disabled -+ || !loc->enabled -+ || loc->shlib_disabled -+ || !breakpoint_address_is_meaningful (b)) -+ continue; -+ -+ /* Permanent breakpoint should always be inserted. */ -+ if (b->enable_state == bp_permanent && ! loc->inserted) -+ internal_error (__FILE__, __LINE__, -+ _("allegedly permanent breakpoint is not " -+ "actually inserted")); ++ struct breakpoint *related; + -+ if (loc_first == NULL -+ /* address / overlay match */ -+ || loc->address != loc_first->address -+ || (overlay_debugging && loc->section != loc_first->section)) -+ { -+ loc_first = loc; -+ loc->duplicate = 0; -+ continue; ++ /* Unlink bpt from the bpt->related_breakpoint ring. */ ++ for (related = bpt; related->related_breakpoint != bpt; ++ related = related->related_breakpoint); ++ related->related_breakpoint = bpt->related_breakpoint; ++ bpt->related_breakpoint = bpt; + } -+ -+ loc->duplicate = 1; -+ -+ if (loc_first->owner->enable_state == bp_permanent && loc->inserted -+ && b->enable_state != bp_permanent) -+ internal_error (__FILE__, __LINE__, -+ _("another breakpoint was inserted on top of " -+ "a permanent breakpoint")); } - if (breakpoints_always_inserted_mode () && should_insert -@@ -8083,6 +8335,7 @@ delete_command (char *arg, int from_tty) - && b->type != bp_thread_event + observer_notify_breakpoint_deleted (bpt->number); +@@ -9658,6 +9846,7 @@ delete_command (char *arg, int from_tty) && b->type != bp_overlay_event && b->type != bp_longjmp_master + && b->type != bp_std_terminate_master + && b->type != bp_exception_master && b->number >= 0) { breaks_to_delete = 1; -@@ -8102,6 +8355,7 @@ delete_command (char *arg, int from_tty) - && b->type != bp_jit_event +@@ -9679,6 +9868,7 @@ delete_command (char *arg, int from_tty) && b->type != bp_overlay_event && b->type != bp_longjmp_master + && b->type != bp_std_terminate_master + && b->type != bp_exception_master && b->number >= 0) delete_breakpoint (b); } -@@ -8404,6 +8658,7 @@ breakpoint_re_set_one (void *bint) - reset later by breakpoint_re_set. */ +@@ -9887,6 +10077,9 @@ update_breakpoint_locations (struct breakpoint *b, + return; + + b->loc = NULL; ++ xfree (b->source_file); ++ b->source_file = NULL; ++ b->line_number = 0; + + for (i = 0; i < sals.nelts; ++i) + { +@@ -9913,11 +10106,7 @@ update_breakpoint_locations (struct breakpoint *b, + } + } + +- if (b->source_file != NULL) +- xfree (b->source_file); +- if (sals.sals[i].symtab == NULL) +- b->source_file = NULL; +- else ++ if (sals.sals[i].symtab != NULL && b->source_file == NULL) + b->source_file = xstrdup (sals.sals[i].symtab->filename); + + if (b->line_number == 0) +@@ -9999,6 +10188,7 @@ breakpoint_re_set_one (void *bint) + case bp_tracepoint: + case bp_fast_tracepoint: + case bp_static_tracepoint: ++ case bp_gnu_ifunc_resolver: + /* Do not attempt to re-set breakpoints disabled during startup. */ + if (b->enable_state == bp_startup_disabled) + return 0; +@@ -10139,6 +10329,7 @@ breakpoint_re_set_one (void *bint) case bp_overlay_event: case bp_longjmp_master: + case bp_std_terminate_master: + case bp_exception_master: delete_breakpoint (b); break; -@@ -8427,6 +8682,8 @@ breakpoint_re_set_one (void *bint) +@@ -10162,7 +10353,10 @@ breakpoint_re_set_one (void *bint) + case bp_step_resume: case bp_longjmp: case bp_longjmp_resume: - case bp_jit_event: + case bp_exception: + case bp_exception_resume: + case bp_jit_event: ++ case bp_gnu_ifunc_resolver_return: break; } -@@ -8462,6 +8719,7 @@ breakpoint_re_set (void) - create_longjmp_master_breakpoint ("_longjmp"); +@@ -10205,6 +10399,7 @@ breakpoint_re_set (void) create_longjmp_master_breakpoint ("siglongjmp"); create_longjmp_master_breakpoint ("_siglongjmp"); + create_std_terminate_master_breakpoint ("std::terminate()"); + create_exception_master_breakpoint (); } /* Reset the thread number of this breakpoint: -@@ -9327,6 +9585,22 @@ all_tracepoints () +@@ -10334,11 +10529,20 @@ map_breakpoint_numbers (char *args, void (*function) (struct breakpoint *, + ALL_BREAKPOINTS_SAFE (b, tmp) + if (b->number == num) + { +- struct breakpoint *related_breakpoint = b->related_breakpoint; ++ struct breakpoint *related_breakpoint; ++ + match = 1; +- function (b, data); +- if (related_breakpoint) +- function (related_breakpoint, data); ++ related_breakpoint = b; ++ do ++ { ++ struct breakpoint *next_related_b; ++ ++ /* FUNCTION can be also delete_breakpoint. */ ++ next_related_b = related_breakpoint->related_breakpoint; ++ function (related_breakpoint, data); ++ related_breakpoint = next_related_b; ++ } ++ while (related_breakpoint != b); + break; + } + if (match == 0) +@@ -11428,6 +11632,22 @@ all_tracepoints () return tp_vec; } @@ -1869,14 +1138,122 @@ index 811cdfb..0f35101 100644 /* This help string is used for the break, hbreak, tbreak and thbreak commands. It is defined as a macro to prevent duplication. -@@ -9850,4 +10124,5 @@ inferior in all-stop mode, gdb behaves as if always-inserted mode is off."), +@@ -11497,6 +11717,107 @@ save_command (char *arg, int from_tty) + help_list (save_cmdlist, "save ", -1, gdb_stdout); + } + ++static void ++gnu_ifunc_resolver_stop (struct breakpoint *b) ++{ ++ struct breakpoint *b_return; ++ struct frame_info *prev_frame = get_prev_frame (get_current_frame ()); ++ struct frame_id prev_frame_id = get_stack_frame_id (prev_frame); ++ CORE_ADDR prev_pc = get_frame_pc (prev_frame); ++ int thread_id = pid_to_thread_id (inferior_ptid); ++ ++ gdb_assert (b->type == bp_gnu_ifunc_resolver); ++ ++ for (b_return = b->related_breakpoint; b_return != b; ++ b_return = b_return->related_breakpoint) ++ { ++ gdb_assert (b_return->type == bp_gnu_ifunc_resolver_return); ++ gdb_assert (b_return->loc != NULL && b_return->loc->next == NULL); ++ gdb_assert (frame_id_p (b_return->frame_id)); ++ ++ if (b_return->thread == thread_id ++ && b_return->loc->requested_address == prev_pc ++ && frame_id_eq (b_return->frame_id, prev_frame_id)) ++ break; ++ } ++ ++ if (b_return == b) ++ { ++ struct symtab_and_line sal; ++ ++ /* No need to call find_pc_line for symbols resolving as this is only ++ a helper breakpointer never shown to the user. */ ++ ++ init_sal (&sal); ++ sal.pspace = current_inferior ()->pspace; ++ sal.pc = prev_pc; ++ sal.section = find_pc_overlay (sal.pc); ++ sal.explicit_pc = 1; ++ b_return = set_momentary_breakpoint (get_frame_arch (prev_frame), sal, ++ prev_frame_id, ++ bp_gnu_ifunc_resolver_return); ++ ++ /* Add new b_return to the ring list b->related_breakpoint. */ ++ gdb_assert (b_return->related_breakpoint == b_return); ++ b_return->related_breakpoint = b->related_breakpoint; ++ b->related_breakpoint = b_return; ++ } ++} ++ ++static void ++gnu_ifunc_resolver_return_stop (struct breakpoint *b) ++{ ++ struct gdbarch *gdbarch = get_frame_arch (get_current_frame ()); ++ struct type *func_func_type = builtin_type (gdbarch)->builtin_func_func; ++ struct type *value_type = TYPE_TARGET_TYPE (func_func_type); ++ struct regcache *regcache = get_thread_regcache (inferior_ptid); ++ struct value *value; ++ CORE_ADDR resolved_address, resolved_pc; ++ struct symtab_and_line sal; ++ struct symtabs_and_lines sals; ++ ++ gdb_assert (b->type == bp_gnu_ifunc_resolver_return); ++ ++ value = allocate_value (value_type); ++ gdbarch_return_value (gdbarch, func_func_type, value_type, regcache, ++ value_contents_raw (value), NULL); ++ resolved_address = value_as_address (value); ++ resolved_pc = gdbarch_convert_from_func_ptr_addr (gdbarch, ++ resolved_address, ++ ¤t_target); ++ ++ while (b->related_breakpoint != b) ++ { ++ struct breakpoint *b_next = b->related_breakpoint; ++ ++ switch (b->type) ++ { ++ case bp_gnu_ifunc_resolver: ++ break; ++ case bp_gnu_ifunc_resolver_return: ++ delete_breakpoint (b); ++ break; ++ default: ++ internal_error (__FILE__, __LINE__, ++ _("handle_inferior_event: Invalid " ++ "gnu-indirect-function breakpoint type %d"), ++ (int) b->type); ++ } ++ b = b_next; ++ } ++ gdb_assert (b->type == bp_gnu_ifunc_resolver); ++ ++ gdb_assert (current_program_space == b->pspace); ++ gnu_ifunc_record_cache (gdbarch, b->addr_string, resolved_pc); ++ ++ sal = find_pc_line (resolved_pc, 0); ++ sals.nelts = 1; ++ sals.sals = &sal; ++ ++ b->type = bp_breakpoint; ++ update_breakpoint_locations (b, sals); ++} ++ + void + _initialize_breakpoint (void) + { +@@ -12022,4 +12343,5 @@ inferior in all-stop mode, gdb behaves as if always-inserted mode is off."), automatic_hardware_breakpoints = 1; observer_attach_about_to_proceed (breakpoint_about_to_proceed); + observer_attach_mark_used (breakpoint_types_mark_used); } diff --git a/gdb/breakpoint.h b/gdb/breakpoint.h -index ba499c6..80f702f 100644 +index 6f5d050..d0c3cc1 100644 --- a/gdb/breakpoint.h +++ b/gdb/breakpoint.h @@ -56,6 +56,13 @@ enum bptype @@ -1893,9 +1270,9 @@ index ba499c6..80f702f 100644 /* Used by wait_for_inferior for stepping over subroutine calls, for stepping over signal handlers, and for skipping prologues. */ bp_step_resume, -@@ -118,6 +125,9 @@ enum bptype - - bp_longjmp_master, +@@ -125,6 +132,9 @@ enum bptype + /* Master copies of std::terminate breakpoints. */ + bp_std_terminate_master, + /* Like bp_longjmp_master, but for exceptions. */ + bp_exception_master, @@ -1903,21 +1280,20 @@ index ba499c6..80f702f 100644 bp_catchpoint, bp_tracepoint, -@@ -228,10 +238,6 @@ struct bp_location - the same parent breakpoint. */ - struct bp_location *next; - -- /* Pointer to the next breakpoint location, in a global -- list of all breakpoint locations. */ -- struct bp_location *global_next; -- - /* Type of this breakpoint location. */ - enum bp_loc_type loc_type; - -@@ -583,6 +589,10 @@ struct bpstat_what +@@ -133,6 +143,9 @@ enum bptype + + /* Event for JIT compiled code generation or deletion. */ + bp_jit_event, ++ ++ bp_gnu_ifunc_resolver, ++ bp_gnu_ifunc_resolver_return, + }; + + /* States of enablement of breakpoint. */ +@@ -653,6 +666,10 @@ struct bpstat_what continuing from a call dummy without popping the frame is not a useful one). */ - int call_dummy; + enum stop_stack_kind call_dummy; + + /* Used for BPSTAT_WHAT_SET_LONGJMP_RESUME. True if we are + handling a longjmp, false if we are handling an exception. */ @@ -1925,549 +1301,17 @@ index ba499c6..80f702f 100644 }; /* The possible return values for print_bpstat, print_it_normal, -@@ -946,6 +956,9 @@ extern int catching_syscall_number (int syscall_number); - /* Tell a breakpoint to be quiet. */ - extern void make_breakpoint_silent (struct breakpoint *); - -+/* Set break condition of breakpoint B to EXP. */ -+extern void set_breakpoint_condition (struct breakpoint *b, char *exp, int from_tty); -+ - /* Return a tracepoint with the given number if found. */ - extern struct breakpoint *get_tracepoint (int num); - -diff --git a/gdb/c-exp.y b/gdb/c-exp.y -index f8e4f12..5b47e2e 100644 ---- a/gdb/c-exp.y -+++ b/gdb/c-exp.y -@@ -117,6 +117,8 @@ static int yylex (void); - - void yyerror (char *); - -+/* Cleanup for 'nonempty_typelist' */ -+static struct cleanup *typelist_cleanup; - %} - - /* Although the yacc "value" of an expression is not used, -@@ -157,6 +159,7 @@ void yyerror (char *); - %{ - /* YYSTYPE gets defined by %union */ - static int parse_number (char *, int, int, YYSTYPE *); -+static struct stoken operator_stoken (const char *); - %} - - %type exp exp1 type_exp start variable qualified_name lcurly -@@ -199,9 +202,12 @@ static int parse_number (char *, int, int, YYSTYPE *); - - %token NAME_OR_INT - -+%token OPERATOR - %token STRUCT CLASS UNION ENUM SIZEOF UNSIGNED COLONCOLON - %token TEMPLATE - %token ERROR -+%token NEW DELETE -+%type operator - - /* Special type cases, put in to allow the parser to distinguish different - legal basetypes. */ -@@ -401,6 +407,36 @@ arglist : arglist ',' exp %prec ABOVE_COMMA - { arglist_len++; } - ; - -+exp : exp '(' nonempty_typelist ')' const_or_volatile -+ { int i; -+ write_exp_elt_opcode (TYPE_INSTANCE); -+ write_exp_elt_longcst ((LONGEST) $3[0]); -+ for (i = 0; i < $3[0]; ++i) -+ write_exp_elt_type ($3[i + 1]); -+ write_exp_elt_longcst((LONGEST) $3[0]); -+ write_exp_elt_opcode (TYPE_INSTANCE); -+ do_cleanups (typelist_cleanup); -+ } -+ ; -+ -+/* -+exp : BLOCKNAME '(' nonempty_typelist ')' -+ { int i; -+ write_exp_elt_opcode (TYPE_INSTANCE_LOOKUP); -+ write_exp_elt_sym ($1.sym); -+ write_exp_elt_opcode (TYPE_INSTANCE_LOOKUP); -+ -+ write_exp_elt_opcode (TYPE_INSTANCE); -+ write_exp_elt_longcst ((LONGEST) $3[0]); -+ for (i = 0; i < $3[0]; ++i) -+ write_exp_elt_type ($3[i + 1]); -+ write_exp_elt_longcst((LONGEST) $3[0]); -+ write_exp_elt_opcode (TYPE_INSTANCE); -+ do_cleanups (typelist_cleanup); -+ } -+ ; -+*/ -+ - rcurly : '}' - { $$ = end_arglist () - 1; } - ; -@@ -703,6 +739,7 @@ variable: block COLONCOLON name - qualified_name: typebase COLONCOLON name - { - struct type *type = $1; -+ CHECK_TYPEDEF (type); - if (TYPE_CODE (type) != TYPE_CODE_STRUCT - && TYPE_CODE (type) != TYPE_CODE_UNION - && TYPE_CODE (type) != TYPE_CODE_NAMESPACE) -@@ -718,6 +755,7 @@ qualified_name: typebase COLONCOLON name - { - struct type *type = $1; - struct stoken tmp_token; -+ CHECK_TYPEDEF (type); - if (TYPE_CODE (type) != TYPE_CODE_STRUCT - && TYPE_CODE (type) != TYPE_CODE_UNION - && TYPE_CODE (type) != TYPE_CODE_NAMESPACE) -@@ -740,12 +778,13 @@ qualified_name: typebase COLONCOLON name - ; - - variable: qualified_name -+ | COLONCOLON qualified_name - | COLONCOLON name - { - char *name = copy_name ($2); - struct symbol *sym; - struct minimal_symbol *msymbol; -- -+ - sym = - lookup_symbol (name, (const struct block *) NULL, - VAR_DOMAIN, (int *) NULL); -@@ -883,7 +922,7 @@ array_mod: '[' ']' - func_mod: '(' ')' - { $$ = 0; } - | '(' nonempty_typelist ')' -- { free ($2); $$ = 0; } -+ { do_cleanups (typelist_cleanup); $$ = 0; } - ; - - /* We used to try to recognize pointer to member types here, but -@@ -1088,12 +1127,15 @@ typename: TYPENAME - nonempty_typelist - : type - { $$ = (struct type **) malloc (sizeof (struct type *) * 2); -+ typelist_cleanup = make_cleanup (free, $$); - $$[0] = 1; /* Number of types in vector */ - $$[1] = $1; - } - | nonempty_typelist ',' type - { int len = sizeof (struct type *) * (++($1[0]) + 1); - $$ = (struct type **) realloc ((char *) $1, len); -+ discard_cleanups (typelist_cleanup); -+ typelist_cleanup = make_cleanup (free, $$); - $$[$$[0]] = $3; - } - ; -@@ -1117,10 +1159,135 @@ const_or_volatile_noopt: const_and_volatile - { push_type (tp_volatile); } - ; - -+operator: OPERATOR NEW -+ { $$ = operator_stoken (" new"); } -+ | OPERATOR DELETE -+ { $$ = operator_stoken (" delete"); } -+ | OPERATOR NEW '[' ']' -+ { $$ = operator_stoken (" new[]"); } -+ | OPERATOR DELETE '[' ']' -+ { $$ = operator_stoken (" delete[]"); } -+ | OPERATOR '+' -+ { $$ = operator_stoken ("+"); } -+ | OPERATOR '-' -+ { $$ = operator_stoken ("-"); } -+ | OPERATOR '*' -+ { $$ = operator_stoken ("*"); } -+ | OPERATOR '/' -+ { $$ = operator_stoken ("/"); } -+ | OPERATOR '%' -+ { $$ = operator_stoken ("%"); } -+ | OPERATOR '^' -+ { $$ = operator_stoken ("^"); } -+ | OPERATOR '&' -+ { $$ = operator_stoken ("&"); } -+ | OPERATOR '|' -+ { $$ = operator_stoken ("|"); } -+ | OPERATOR '~' -+ { $$ = operator_stoken ("~"); } -+ | OPERATOR '!' -+ { $$ = operator_stoken ("!"); } -+ | OPERATOR '=' -+ { $$ = operator_stoken ("="); } -+ | OPERATOR '<' -+ { $$ = operator_stoken ("<"); } -+ | OPERATOR '>' -+ { $$ = operator_stoken (">"); } -+ | OPERATOR ASSIGN_MODIFY -+ { const char *op = "unknown"; -+ switch ($2) -+ { -+ case BINOP_RSH: -+ op = ">>="; -+ break; -+ case BINOP_LSH: -+ op = "<<="; -+ break; -+ case BINOP_ADD: -+ op = "+="; -+ break; -+ case BINOP_SUB: -+ op = "-="; -+ break; -+ case BINOP_MUL: -+ op = "*="; -+ break; -+ case BINOP_DIV: -+ op = "/="; -+ break; -+ case BINOP_REM: -+ op = "%="; -+ break; -+ case BINOP_BITWISE_IOR: -+ op = "|="; -+ break; -+ case BINOP_BITWISE_AND: -+ op = "&="; -+ break; -+ case BINOP_BITWISE_XOR: -+ op = "^="; -+ break; -+ default: -+ break; -+ } -+ -+ $$ = operator_stoken (op); -+ } -+ | OPERATOR LSH -+ { $$ = operator_stoken ("<<"); } -+ | OPERATOR RSH -+ { $$ = operator_stoken (">>"); } -+ | OPERATOR EQUAL -+ { $$ = operator_stoken ("=="); } -+ | OPERATOR NOTEQUAL -+ { $$ = operator_stoken ("!="); } -+ | OPERATOR LEQ -+ { $$ = operator_stoken ("<="); } -+ | OPERATOR GEQ -+ { $$ = operator_stoken (">="); } -+ | OPERATOR ANDAND -+ { $$ = operator_stoken ("&&"); } -+ | OPERATOR OROR -+ { $$ = operator_stoken ("||"); } -+ | OPERATOR INCREMENT -+ { $$ = operator_stoken ("++"); } -+ | OPERATOR DECREMENT -+ { $$ = operator_stoken ("--"); } -+ | OPERATOR ',' -+ { $$ = operator_stoken (","); } -+ | OPERATOR ARROW_STAR -+ { $$ = operator_stoken ("->*"); } -+ | OPERATOR ARROW -+ { $$ = operator_stoken ("->"); } -+ | OPERATOR '(' ')' -+ { $$ = operator_stoken ("()"); } -+ | OPERATOR '[' ']' -+ { $$ = operator_stoken ("[]"); } -+ | OPERATOR ptype -+ { char *name, *canon; -+ long length; -+ struct ui_file *buf = mem_fileopen (); -+ -+ c_print_type ($2, NULL, buf, -1, 0); -+ name = ui_file_xstrdup (buf, &length); -+ canon = cp_canonicalize_string (name); -+ if (canon != NULL) -+ { -+ xfree (name); -+ name = canon; -+ } -+ ui_file_delete (buf); -+ $$ = operator_stoken (name); -+ } -+ ; -+ -+ -+ - name : NAME { $$ = $1.stoken; } - | BLOCKNAME { $$ = $1.stoken; } - | TYPENAME { $$ = $1.stoken; } - | NAME_OR_INT { $$ = $1.stoken; } -+ | operator { $$ = $1; } - ; - - name_not_typename : NAME -@@ -1136,6 +1303,20 @@ name_not_typename : NAME - - %% - -+/* Returns a stoken of the operator name given by OP (which does not -+ include the string "operator"). The result is xmalloc'd. */ -+static struct stoken -+operator_stoken (const char *op) -+{ -+ static const char *operator_string = "operator"; -+ struct stoken st = { NULL, 0 }; -+ st.length = strlen (operator_string) + strlen (op); -+ st.ptr = xmalloc (st.length + 1); -+ strcpy (st.ptr, operator_string); -+ strcat (st.ptr, op); -+ return st; -+}; -+ - /* Take care of parsing a number (anything that starts with a digit). - Set yylval and return the token type; update lexptr. - LEN is the number of characters in it. */ -@@ -1714,6 +1895,9 @@ static const struct token ident_tokens[] = - {"long", LONG, OP_NULL, 0}, - {"true", TRUEKEYWORD, OP_NULL, 1}, - {"int", INT_KEYWORD, OP_NULL, 0}, -+ {"new", NEW, OP_NULL, 1}, -+ {"delete", DELETE, OP_NULL, 1}, -+ {"operator", OPERATOR, OP_NULL, 1}, - - {"and", ANDAND, BINOP_END, 1}, - {"and_eq", ASSIGN_MODIFY, BINOP_BITWISE_AND, 1}, -@@ -1822,6 +2006,13 @@ static int last_was_structop; - static int - yylex (void) - { -+ /* name_prefix stores the full qualification of a variable that is -+ specified in the expression. It is used to eleminate confusion -+ during lookup.*/ -+ static char *name_prefix = NULL; -+ static int name_prefix_len = 0; -+ static int terminate_prefix = 0; -+ - int c; - int namelen; - unsigned int i; -@@ -1830,9 +2021,19 @@ yylex (void) - char *copy; - - last_was_structop = 0; -- -+ - retry: -- -+ -+ if (terminate_prefix -+ || lexptr != name_prefix + name_prefix_len) -+ { -+ /* Some token was skipped, so clear name_prefix. */ -+ name_prefix = NULL; -+ name_prefix_len = 0; -+ } -+ -+ terminate_prefix = 1; -+ - /* Check if this is a macro invocation that we need to expand. */ - if (! scanning_macro_expansion ()) - { -@@ -1868,10 +2069,19 @@ yylex (void) - && parse_language->la_language != language_cplus) - break; - -+ if (tokentab2[i].token == COLONCOLON) -+ { -+ name_prefix_len += 2; -+ terminate_prefix = 0; -+ if (name_prefix == NULL) -+ name_prefix = lexptr; -+ } -+ - lexptr += 2; - yylval.opcode = tokentab2[i].opcode; - if (in_parse_field && tokentab2[i].token == ARROW) - last_was_structop = 1; -+ - return tokentab2[i].token; - } - -@@ -1900,6 +2110,8 @@ yylex (void) - return 0; - - case ' ': -+ name_prefix_len++; -+ terminate_prefix = 0; - case '\t': - case '\n': - lexptr++; -@@ -2057,11 +2269,13 @@ yylex (void) - error ("Invalid character '%c' in expression.", c); - - /* It's a name. See how long it is. */ -+ - namelen = 0; - for (c = tokstart[namelen]; - (c == '_' || c == '$' || (c >= '0' && c <= '9') - || (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || c == '<');) - { -+ - /* Template parameter lists are part of the name. - FIXME: This mishandles `print $a<4&&$a>3'. */ - -@@ -2125,14 +2339,29 @@ yylex (void) - currently as names of types; NAME for other symbols. - The caller is not constrained to care about the distinction. */ - { -+ char *tmp = copy; - struct symbol *sym; - int is_a_field_of_this = 0; - int hextype; - -- sym = lookup_symbol (copy, expression_context_block, -+ if (name_prefix != NULL) -+ tmp = savestring (name_prefix, name_prefix_len+namelen); -+ -+ sym = lookup_symbol (tmp, expression_context_block, - VAR_DOMAIN, - parse_language->la_language == language_cplus - ? &is_a_field_of_this : (int *) NULL); -+ -+ /* Keep this name as the prefix for the next name. */ -+ if (sym) -+ { -+ if (name_prefix == NULL) -+ name_prefix = tokstart; -+ -+ name_prefix_len += namelen; -+ terminate_prefix = 0; -+ } -+ - /* Call lookup_symtab, not lookup_partial_symtab, in case there are - no psymtabs (coff, xcoff, or some future change to blow away the - psymtabs once once symbols are read). */ -@@ -2191,6 +2420,7 @@ yylex (void) - yylval.ssym.is_a_field_of_this = is_a_field_of_this; - if (in_parse_field && *lexptr == '\0') - saw_name_at_eof = 1; -+ - return NAME; - } - } -diff --git a/gdb/c-lang.c b/gdb/c-lang.c -index d01490c..bc35a3e 100644 ---- a/gdb/c-lang.c -+++ b/gdb/c-lang.c -@@ -715,7 +715,7 @@ c_get_string (struct value *value, gdb_byte **buffer, int *length, - If length returned from read_string was > 0, return the number of - characters read by dividing the number of bytes by width. */ - if (*length != 0) -- *length = *length / width; -+ *length = *length / width; - - *charset = target_charset (); - -@@ -1038,6 +1038,9 @@ evaluate_subexp_c (struct type *expect_type, struct expression *exp, - return evaluate_subexp_standard (expect_type, exp, pos, noside); - } - -+ -+/* Preprocessing and parsing C and C++ expressions. */ -+ - - - /* Table mapping opcodes into strings for printing operators -@@ -1138,6 +1141,7 @@ static const struct exp_descriptor exp_descriptor_c = - { - print_subexp_standard, - operator_length_standard, -+ operator_check_standard, - op_name_standard, - dump_subexp_body_standard, - evaluate_subexp_c diff --git a/gdb/c-typeprint.c b/gdb/c-typeprint.c -index b193080..04cf3bc 100644 +index 926ae2f..a59b965 100644 --- a/gdb/c-typeprint.c +++ b/gdb/c-typeprint.c -@@ -32,6 +32,7 @@ - #include "c-lang.h" - #include "typeprint.h" - #include "cp-abi.h" -+#include "jv-lang.h" - - #include "gdb_string.h" - #include -@@ -40,8 +41,6 @@ static void cp_type_print_method_args (struct type *mtype, char *prefix, - char *varstring, int staticp, - struct ui_file *stream); - --static void c_type_print_args (struct type *, struct ui_file *); -- - static void cp_type_print_derivation_info (struct ui_file *, struct type *); - - static void c_type_print_varspec_prefix (struct type *, struct ui_file *, int, -@@ -199,6 +198,23 @@ cp_type_print_method_args (struct type *mtype, char *prefix, char *varstring, - fprintf_filtered (stream, "void"); - - fprintf_filtered (stream, ")"); -+ -+ /* For non-static methods, read qualifiers from the type of -+ THIS. */ -+ if (!staticp) -+ { -+ struct type *domain; -+ -+ gdb_assert (nargs > 0); -+ gdb_assert (TYPE_CODE (args[0].type) == TYPE_CODE_PTR); -+ domain = TYPE_TARGET_TYPE (args[0].type); -+ -+ if (TYPE_CONST (domain)) -+ fprintf_filtered (stream, " const"); -+ -+ if (TYPE_VOLATILE (domain)) -+ fprintf_filtered (stream, " volatile"); -+ } - } - - -@@ -355,10 +371,14 @@ c_type_print_modifier (struct type *type, struct ui_file *stream, - - /* Print out the arguments of TYPE, which should have TYPE_CODE_METHOD - or TYPE_CODE_FUNC, to STREAM. Artificial arguments, such as "this" -- in non-static methods, are displayed. */ -+ in non-static methods, are displayed if SHOW_ARTIFICIAL is -+ non-zero. LANGUAGE is the language in which TYPE was defined. This is -+ a necessary evil since this code is used by the C, C++, and Java -+ backends. */ - --static void --c_type_print_args (struct type *type, struct ui_file *stream) -+void -+c_type_print_args (struct type *type, struct ui_file *stream, -+ int show_artificial, enum language language) - { - int i, len; - struct field *args; -@@ -370,13 +390,19 @@ c_type_print_args (struct type *type, struct ui_file *stream) - - for (i = 0; i < TYPE_NFIELDS (type); i++) - { -+ if (TYPE_FIELD_ARTIFICIAL (type, i) && !show_artificial) -+ continue; -+ - if (printed_any) - { - fprintf_filtered (stream, ", "); - wrap_here (" "); - } - -- c_print_type (TYPE_FIELD_TYPE (type, i), "", stream, -1, 0); -+ if (language == language_java) -+ java_print_type (TYPE_FIELD_TYPE (type, i), "", stream, -1, 0); -+ else -+ c_print_type (TYPE_FIELD_TYPE (type, i), "", stream, -1, 0); - printed_any = 1; - } - -@@ -560,7 +586,12 @@ c_type_print_varspec_suffix (struct type *type, struct ui_file *stream, +@@ -585,7 +585,13 @@ c_type_print_varspec_suffix (struct type *type, struct ui_file *stream, fprintf_filtered (stream, ")"); fprintf_filtered (stream, "["); - if (TYPE_LENGTH (TYPE_TARGET_TYPE (type)) > 0 -+ if (TYPE_ARRAY_BOUND_IS_DWARF_BLOCK (type, 1)) ++ if (TYPE_RANGE_DATA (TYPE_INDEX_TYPE (type))->high.kind ++ != RANGE_BOUND_KIND_CONSTANT) + { + /* No _() - printed sources should not be locale dependent. */ + fprintf_filtered (stream, "variable"); @@ -2476,176 +1320,11 @@ index b193080..04cf3bc 100644 && !TYPE_ARRAY_UPPER_BOUND_IS_UNDEFINED (type)) fprintf_filtered (stream, "%d", (TYPE_LENGTH (type) -@@ -593,7 +624,7 @@ c_type_print_varspec_suffix (struct type *type, struct ui_file *stream, - if (passed_a_ptr) - fprintf_filtered (stream, ")"); - if (!demangled_args) -- c_type_print_args (type, stream); -+ c_type_print_args (type, stream, 1, language_c); - c_type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream, show, - passed_a_ptr, 0); - break; -diff --git a/gdb/cli/cli-cmds.c b/gdb/cli/cli-cmds.c -index ce7c2a6..6380fec 100644 ---- a/gdb/cli/cli-cmds.c -+++ b/gdb/cli/cli-cmds.c -@@ -46,6 +46,8 @@ - #include "cli/cli-setshow.h" - #include "cli/cli-cmds.h" - -+#include "python/python.h" -+ - #ifdef TUI - #include "tui/tui.h" /* For tui_active et.al. */ - #endif -@@ -183,6 +185,7 @@ struct cmd_list_element *showchecklist; - - /* Command tracing state. */ - -+static int source_python = 0; - int source_verbose = 0; - int trace_commands = 0; - -@@ -444,6 +447,7 @@ source_script (char *file, int from_tty) - struct cleanup *old_cleanups; - char *full_pathname = NULL; - int fd; -+ int is_python; - - if (file == NULL || *file == 0) - { -@@ -476,8 +480,16 @@ source_script (char *file, int from_tty) - } - } - -+ is_python = source_python; -+ if (strlen (file) > 3 && !strcmp (&file[strlen (file) - 3], ".py")) -+ is_python = 1; -+ - stream = fdopen (fd, FOPEN_RT); -- script_from_file (stream, file); -+ -+ if (is_python) -+ source_python_script (stream, file); -+ else -+ script_from_file (stream, file); - - do_cleanups (old_cleanups); - } -@@ -491,15 +503,30 @@ source_verbose_cleanup (void *old_value) - xfree (old_value); - } - -+/* A helper for source_command. Look for an argument in *ARGS. -+ Update *ARGS by stripping leading whitespace. If an argument is -+ found, return it (a character). Otherwise, return 0. */ -+static int -+find_argument (char **args) -+{ -+ int result = 0; -+ while (isspace ((*args)[0])) -+ ++*args; -+ if ((*args)[0] == '-' && isalpha ((*args)[1])) -+ { -+ result = (*args)[1]; -+ *args += 3; -+ } -+ return result; -+} -+ - static void - source_command (char *args, int from_tty) - { - struct cleanup *old_cleanups; -- char *file = args; -- int *old_source_verbose = xmalloc (sizeof(int)); - -- *old_source_verbose = source_verbose; -- old_cleanups = make_cleanup (source_verbose_cleanup, old_source_verbose); -+ old_cleanups = make_cleanup_restore_integer (&source_verbose); -+ make_cleanup_restore_integer (&source_python); - - /* -v causes the source command to run in verbose mode. - We still have to be able to handle filenames with spaces in a -@@ -507,23 +534,28 @@ source_command (char *args, int from_tty) - - if (args) - { -- /* Make sure leading white space does not break the comparisons. */ -- while (isspace(args[0])) -- args++; -- -- /* Is -v the first thing in the string? */ -- if (args[0] == '-' && args[1] == 'v' && isspace (args[2])) -+ while (1) - { -- source_verbose = 1; -- -- /* Trim -v and whitespace from the filename. */ -- file = &args[3]; -- while (isspace (file[0])) -- file++; -+ int arg = find_argument (&args); -+ if (!arg) -+ break; -+ switch (arg) -+ { -+ case 'v': -+ source_verbose = 1; -+ break; -+ case 'p': -+ source_python = 1; -+ break; -+ default: -+ error (_("unrecognized option -%c"), arg); -+ } - } - } - -- source_script (file, from_tty); -+ source_script (args, from_tty); -+ -+ do_cleanups (old_cleanups); - } - - -@@ -1307,7 +1339,9 @@ Read commands from a file named FILE.\n\ - Optional -v switch (before the filename) causes each command in\n\ - FILE to be echoed as it is executed.\n\ - Note that the file \"%s\" is read automatically in this way\n\ --when GDB is started."), gdbinit); -+when GDB is started.\n\ -+Optional -p switch (before the filename) causes FILE to be evaluated\n\ -+as Python code."), gdbinit); - c = add_cmd ("source", class_support, source_command, - source_help_text, &cmdlist); - set_cmd_completer (c, filename_completer); -diff --git a/gdb/coffread.c b/gdb/coffread.c -index 888f8b4..65494b8 100644 ---- a/gdb/coffread.c -+++ b/gdb/coffread.c -@@ -346,7 +346,7 @@ coff_alloc_type (int index) - We will fill it in later if we find out how. */ - if (type == NULL) - { -- type = alloc_type (current_objfile); -+ type = alloc_type (current_objfile, NULL); - *type_addr = type; - } - return type; -@@ -2121,6 +2121,7 @@ static struct sym_fns coff_sym_fns = - coff_new_init, /* sym_new_init: init anything gbl to entire symtab */ - coff_symfile_init, /* sym_init: read initial info, setup for sym_read() */ - coff_symfile_read, /* sym_read: read a symbol file into symtab */ -+ NULL, /* sym_read_psymbols */ - coff_symfile_finish, /* sym_finish: finished with file, cleanup */ - default_symfile_offsets, /* sym_offsets: xlate external to internal form */ - default_symfile_segments, /* sym_segments: Get segment information from diff --git a/gdb/config.in b/gdb/config.in -index 4716524..0745c65 100644 +index 1fc457d..f4c846a 100644 --- a/gdb/config.in +++ b/gdb/config.in -@@ -46,11 +46,10 @@ +@@ -50,11 +50,10 @@ language is requested. */ #undef ENABLE_NLS @@ -2659,262 +1338,21 @@ index 4716524..0745c65 100644 #undef GDB_DATADIR_RELOCATABLE /* Define to be a string naming the default host character set. */ -@@ -647,6 +646,9 @@ +@@ -769,6 +768,9 @@ 'ptrdiff_t'. */ #undef PTRDIFF_T_SUFFIX +/* Define to install path for Python sources */ +#undef PYTHONDIR + - /* Relocated directory for source files. */ - #undef RELOC_SRCDIR + /* Define if the python directory should be relocated when GDB is moved. */ + #undef PYTHON_PATH_RELOCATABLE -diff --git a/gdb/config/i386/nm-i386.h b/gdb/config/i386/nm-i386.h -new file mode 100644 -index 0000000..5f237cc ---- /dev/null -+++ b/gdb/config/i386/nm-i386.h -@@ -0,0 +1,125 @@ -+/* Native macro definitions for GDB on an Intel i[3456]86. -+ Copyright 2001, 2004, 2007, 2008, 2009 Free Software Foundation, Inc. -+ -+ This file is part of GDB. -+ -+ 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 . */ -+ -+#ifndef NM_I386_H -+#define NM_I386_H 1 -+ -+/* Hardware-assisted breakpoints and watchpoints. */ -+ -+/* Targets should define this to use the generic x86 watchpoint support. */ -+#ifdef I386_USE_GENERIC_WATCHPOINTS -+ -+/* Add watchpoint methods to the provided target_ops. Targets which call -+ this should also define I386_WATCHPOINTS_IN_TARGET_VECTOR. */ -+struct target_ops; -+void i386_use_watchpoints (struct target_ops *); -+ -+/* Clear the reference counts and forget everything we knew about DRi. */ -+extern void i386_cleanup_dregs (void); -+ -+/* Insert a watchpoint to watch a memory region which starts at -+ address ADDR and whose length is LEN bytes. Watch memory accesses -+ of the type TYPE. Return 0 on success, -1 on failure. */ -+extern int i386_insert_watchpoint (CORE_ADDR addr, int len, int type); -+ -+/* Remove a watchpoint that watched the memory region which starts at -+ address ADDR, whose length is LEN bytes, and for accesses of the -+ type TYPE. Return 0 on success, -1 on failure. */ -+extern int i386_remove_watchpoint (CORE_ADDR addr, int len, int type); -+ -+/* Return non-zero if we can watch a memory region that starts at -+ address ADDR and whose length is LEN bytes. */ -+extern int i386_region_ok_for_watchpoint (CORE_ADDR addr, int len); -+ -+/* Return non-zero if the inferior has some break/watchpoint that -+ triggered. */ -+extern int i386_stopped_by_hwbp (void); -+ -+/* If the inferior has some break/watchpoint that triggered, set -+ the address associated with that break/watchpoint and return -+ true. Otherwise, return false. */ -+extern int i386_stopped_data_address (struct target_ops *, CORE_ADDR *); -+ -+/* Insert a hardware-assisted breakpoint at BP_TGT->placed_address. -+ Return 0 on success, EBUSY on failure. */ -+struct bp_target_info; -+extern int i386_insert_hw_breakpoint (struct bp_target_info *bp_tgt); -+ -+/* Remove a hardware-assisted breakpoint at BP_TGT->placed_address. -+ Return 0 on success, -1 on failure. */ -+extern int i386_remove_hw_breakpoint (struct bp_target_info *bp_tgt); -+ -+extern int i386_stopped_by_watchpoint (void); -+ -+#ifndef I386_WATCHPOINTS_IN_TARGET_VECTOR -+ -+/* Returns the number of hardware watchpoints of type TYPE that we can -+ set. Value is positive if we can set CNT watchpoints, zero if -+ setting watchpoints of type TYPE is not supported, and negative if -+ CNT is more than the maximum number of watchpoints of type TYPE -+ that we can support. TYPE is one of bp_hardware_watchpoint, -+ bp_read_watchpoint, bp_write_watchpoint, or bp_hardware_breakpoint. -+ CNT is the number of such watchpoints used so far (including this -+ one). OTHERTYPE is non-zero if other types of watchpoints are -+ currently enabled. -+ -+ We always return 1 here because we don't have enough information -+ about possible overlap of addresses that they want to watch. As an -+ extreme example, consider the case where all the watchpoints watch -+ the same address and the same region length: then we can handle a -+ virtually unlimited number of watchpoints, due to debug register -+ sharing implemented via reference counts in i386-nat.c. */ -+ -+#define TARGET_CAN_USE_HARDWARE_WATCHPOINT(type, cnt, ot) 1 -+ -+/* Returns non-zero if we can use hardware watchpoints to watch a -+ region whose address is ADDR and whose length is LEN. */ -+ -+#define TARGET_REGION_OK_FOR_HW_WATCHPOINT(addr, len) \ -+ i386_region_ok_for_watchpoint (addr, len) -+ -+/* After a watchpoint trap, the PC points to the instruction after the -+ one that caused the trap. Therefore we don't need to step over it. -+ But we do need to reset the status register to avoid another trap. */ -+ -+#define HAVE_CONTINUABLE_WATCHPOINT 1 -+ -+#define STOPPED_BY_WATCHPOINT(W) (i386_stopped_by_watchpoint () != 0) -+ -+#define target_stopped_data_address(target, x) \ -+ i386_stopped_data_address(target, x) -+ -+/* Use these macros for watchpoint insertion/removal. */ -+ -+#define target_insert_watchpoint(addr, len, type) \ -+ i386_insert_watchpoint (addr, len, type) -+ -+#define target_remove_watchpoint(addr, len, type) \ -+ i386_remove_watchpoint (addr, len, type) -+ -+#define target_insert_hw_breakpoint(bp_tgt) \ -+ i386_insert_hw_breakpoint (bp_tgt) -+ -+#define target_remove_hw_breakpoint(bp_tgt) \ -+ i386_remove_hw_breakpoint (bp_tgt) -+ -+#endif /* I386_WATCHPOINTS_IN_TARGET_VECTOR */ -+ -+#endif /* I386_USE_GENERIC_WATCHPOINTS */ -+ -+#endif /* NM_I386_H */ -diff --git a/gdb/config/i386/nm-linux64.h b/gdb/config/i386/nm-linux64.h -new file mode 100644 -index 0000000..19d710a ---- /dev/null -+++ b/gdb/config/i386/nm-linux64.h -@@ -0,0 +1,54 @@ -+/* Native support for GNU/Linux x86-64. -+ -+ Copyright 2001, 2002, 2003, 2004, 2005, 2007, 2008, 2009 -+ Free Software Foundation, Inc. -+ -+ Contributed by Jiri Smid, SuSE Labs. -+ -+ This file is part of GDB. -+ -+ 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 . */ -+ -+#ifndef NM_LINUX64_H -+#define NM_LINUX64_H -+ -+/* GNU/Linux supports the i386 hardware debugging registers. */ -+#define I386_USE_GENERIC_WATCHPOINTS -+#define I386_WATCHPOINTS_IN_TARGET_VECTOR -+ -+#include "i386/nm-i386.h" -+#include "config/nm-linux.h" -+ -+/* Support for 8-byte wide hardware watchpoints. */ -+#define TARGET_HAS_DR_LEN_8 1 -+ -+/* Provide access to the i386 hardware debugging registers. */ -+ -+extern void amd64_linux_dr_set_control (unsigned long control); -+#define I386_DR_LOW_SET_CONTROL(control) \ -+ amd64_linux_dr_set_control (control) -+ -+extern void amd64_linux_dr_set_addr (int regnum, CORE_ADDR addr); -+#define I386_DR_LOW_SET_ADDR(regnum, addr) \ -+ amd64_linux_dr_set_addr (regnum, addr) -+ -+extern void amd64_linux_dr_reset_addr (int regnum); -+#define I386_DR_LOW_RESET_ADDR(regnum) \ -+ amd64_linux_dr_reset_addr (regnum) -+ -+extern unsigned long amd64_linux_dr_get_status (void); -+#define I386_DR_LOW_GET_STATUS() \ -+ amd64_linux_dr_get_status () -+ -+#endif /* nm-linux64.h */ -diff --git a/gdb/config/mips/nm-irix5.h b/gdb/config/mips/nm-irix5.h -new file mode 100644 -index 0000000..49ac420 ---- /dev/null -+++ b/gdb/config/mips/nm-irix5.h -@@ -0,0 +1,44 @@ -+/* Definitions for native support of irix5. -+ -+ Copyright 1993, 1996, 1998, 1999, 2000, 2007, 2008, 2009 -+ Free Software Foundation, Inc. -+ -+ This file is part of GDB. -+ -+ 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 . */ -+ -+#define TARGET_HAS_HARDWARE_WATCHPOINTS -+ -+/* TARGET_CAN_USE_HARDWARE_WATCHPOINT is now defined to go through -+ the target vector. For Irix5, procfs_can_use_hw_watchpoint() -+ should be invoked. */ -+ -+/* When a hardware watchpoint fires off the PC will be left at the -+ instruction which caused the watchpoint. It will be necessary for -+ GDB to step over the watchpoint. */ -+ -+#define STOPPED_BY_WATCHPOINT(W) \ -+ procfs_stopped_by_watchpoint(inferior_ptid) -+extern int procfs_stopped_by_watchpoint (ptid_t); -+ -+/* Use these macros for watchpoint insertion/deletion. */ -+/* type can be 0: write watch, 1: read watch, 2: access watch (read/write) */ -+#define target_insert_watchpoint(ADDR, LEN, TYPE) \ -+ procfs_set_watchpoint (inferior_ptid, ADDR, LEN, TYPE, 0) -+#define target_remove_watchpoint(ADDR, LEN, TYPE) \ -+ procfs_set_watchpoint (inferior_ptid, ADDR, 0, 0, 0) -+extern int procfs_set_watchpoint (ptid_t, CORE_ADDR, int, int, int); -+ -+#define TARGET_REGION_SIZE_OK_FOR_HW_WATCHPOINT(SIZE) 1 -+ diff --git a/gdb/configure b/gdb/configure -index 46e7bfe..ea667f0 100755 +index 041ffc1..8243abb 100755 --- a/gdb/configure +++ b/gdb/configure -@@ -676,6 +676,8 @@ REPORT_BUGS_TO +@@ -679,6 +679,8 @@ REPORT_BUGS_TO PKGVERSION TARGET_OBS subdirs @@ -2923,7 +1361,7 @@ index 46e7bfe..ea667f0 100755 GDB_DATADIR DEBUGDIR am__fastdepCC_FALSE -@@ -883,6 +885,7 @@ enable_dependency_tracking +@@ -945,6 +947,7 @@ enable_dependency_tracking with_separate_debug_dir with_gdb_datadir with_relocated_sources @@ -2931,7 +1369,7 @@ index 46e7bfe..ea667f0 100755 enable_targets enable_64_bit_bfd enable_gdbcli -@@ -1581,6 +1584,10 @@ Optional Packages: +@@ -1646,6 +1649,10 @@ Optional Packages: [DATADIR/gdb] --with-relocated-sources=PATH automatically relocate this path for source files @@ -2942,7 +1380,7 @@ index 46e7bfe..ea667f0 100755 --with-libunwind use libunwind frame unwinding support --with-curses use the curses library instead of the termcap library -@@ -6602,6 +6609,73 @@ _ACEOF +@@ -7878,6 +7885,73 @@ _ACEOF fi @@ -3016,20 +1454,19 @@ index 46e7bfe..ea667f0 100755 subdirs="$subdirs doc testsuite" -@@ -9282,6 +9356,8 @@ $as_echo "#define HAVE_PYTHON 1" >>confdefs.h - CONFIG_OBS="$CONFIG_OBS \$(SUBDIR_PYTHON_OBS)" +@@ -10919,6 +10993,7 @@ $as_echo "#define HAVE_PYTHON 1" >>confdefs.h CONFIG_DEPS="$CONFIG_DEPS \$(SUBDIR_PYTHON_DEPS)" CONFIG_SRCS="$CONFIG_SRCS \$(SUBDIR_PYTHON_SRCS)" -+ CONFIG_INSTALL="$CONFIG_INSTALL install-python" + CONFIG_INSTALL="$CONFIG_INSTALL install-python" + CONFIG_UNINSTALL="$CONFIG_UNINSTALL uninstall-python" ENABLE_CFLAGS="$ENABLE_CFLAGS \$(SUBDIR_PYTHON_CFLAGS)" # Flags needed to compile Python code (taken from python-config --cflags). diff --git a/gdb/configure.ac b/gdb/configure.ac -index 0e42182..e7f97cf 100644 +index b69c3b6..4e89558 100644 --- a/gdb/configure.ac +++ b/gdb/configure.ac -@@ -107,6 +107,51 @@ AS_HELP_STRING([--with-relocated-sources=PATH], [automatically relocate this pat +@@ -108,6 +108,51 @@ AS_HELP_STRING([--with-relocated-sources=PATH], [automatically relocate this pat [Relocated directory for source files. ]) ]) @@ -3081,801 +1518,21 @@ index 0e42182..e7f97cf 100644 AC_CONFIG_SUBDIRS(doc testsuite) # Check whether to support alternative target configurations -@@ -658,6 +703,8 @@ if test "${have_libpython}" = yes; then - CONFIG_OBS="$CONFIG_OBS \$(SUBDIR_PYTHON_OBS)" +@@ -833,6 +878,7 @@ if test "${have_libpython}" != no; then CONFIG_DEPS="$CONFIG_DEPS \$(SUBDIR_PYTHON_DEPS)" CONFIG_SRCS="$CONFIG_SRCS \$(SUBDIR_PYTHON_SRCS)" -+ CONFIG_INSTALL="$CONFIG_INSTALL install-python" + CONFIG_INSTALL="$CONFIG_INSTALL install-python" + CONFIG_UNINSTALL="$CONFIG_UNINSTALL uninstall-python" ENABLE_CFLAGS="$ENABLE_CFLAGS \$(SUBDIR_PYTHON_CFLAGS)" # Flags needed to compile Python code (taken from python-config --cflags). -diff --git a/gdb/cp-name-parser.y b/gdb/cp-name-parser.y -index 62800b8..97d587b 100644 ---- a/gdb/cp-name-parser.y -+++ b/gdb/cp-name-parser.y -@@ -1,7 +1,6 @@ - /* YACC parser for C++ names, for GDB. - -- Copyright (C) 2003, 2004, 2005, 2007, 2008, 2009 -- Free Software Foundation, Inc. -+ Copyright (C) 2003, 2004, 2005, 2007, 2008, 2009 Free Software Foundation, Inc. - - Parts of the lexer are based on c-exp.y from GDB. - -@@ -389,7 +388,7 @@ function - | colon_ext_only function_arglist start_opt - { $$ = fill_comp (DEMANGLE_COMPONENT_TYPED_NAME, $1, $2.comp); - if ($3) $$ = fill_comp (DEMANGLE_COMPONENT_LOCAL_NAME, $$, $3); } -- -+ | colon_ext_only - | conversion_op_name start_opt - { $$ = $1.comp; - if ($2) $$ = fill_comp (DEMANGLE_COMPONENT_LOCAL_NAME, $$, $2); } -diff --git a/gdb/cp-namespace.c b/gdb/cp-namespace.c -index d2d8f2e..db26a01 100644 ---- a/gdb/cp-namespace.c -+++ b/gdb/cp-namespace.c -@@ -36,14 +36,17 @@ static struct using_direct *cp_copy_usings (struct using_direct *using, - struct obstack *obstack); - - static struct symbol *lookup_namespace_scope (const char *name, -- const char *linkage_name, - const struct block *block, - const domain_enum domain, - const char *scope, - int scope_len); - -+static struct symbol *cp_lookup_symbol_in_namespace (const char *namespace, -+ const char *name, -+ const struct block *block, -+ const domain_enum domain); -+ - static struct symbol *lookup_symbol_file (const char *name, -- const char *linkage_name, - const struct block *block, - const domain_enum domain, - int anonymous_namespace); -@@ -119,7 +122,7 @@ cp_scan_for_anonymous_namespaces (const struct symbol *symbol) - anonymous namespace. So add symbols in it to the - namespace given by the previous component if there is - one, or to the global namespace if there isn't. */ -- cp_add_using_directive (dest, src); -+ cp_add_using_directive (dest, src, "", "", 0); - } - /* The "+ 2" is for the "::". */ - previous_component = next_component + 2; -@@ -134,7 +137,8 @@ cp_scan_for_anonymous_namespaces (const struct symbol *symbol) - has already been added, don't add it twice. */ - - void --cp_add_using_directive (const char *dest, const char *src) -+cp_add_using_directive (const char *dest, const char *src, const char* alias, -+ const char *declaration, const int line_number) - { - struct using_direct *current; - struct using_direct *new; -@@ -148,7 +152,8 @@ cp_add_using_directive (const char *dest, const char *src) - return; - } - -- using_directives = cp_add_using (dest, src, using_directives); -+ using_directives = cp_add_using (dest, src, alias, declaration, -+ line_number, using_directives); - - } - -@@ -201,7 +206,10 @@ cp_is_anonymous (const char *namespace) - } - - /* Create a new struct using direct which imports the namespace SRC -- into the scope DEST. -+ into the scope DEST. ALIAS is the name of the imported namespace -+ in the current scope. If ALIAS is an empty string then the -+ namespace is known by its original name. -+ - Set its next member in the linked list to NEXT; allocate all memory - using xmalloc. It copies the strings, so NAME can be a temporary - string. */ -@@ -209,14 +217,21 @@ cp_is_anonymous (const char *namespace) - struct using_direct * - cp_add_using (const char *dest, - const char *src, -+ const char *alias, -+ const char *declaration, -+ const int line_number, - struct using_direct *next) - { - struct using_direct *retval; - - retval = xmalloc (sizeof (struct using_direct)); -- retval->import_src = savestring (src, strlen(src)); -- retval->import_dest = savestring (dest, strlen(dest)); -+ retval->import_src = savestring (src, strlen (src)); -+ retval->import_dest = savestring (dest, strlen (dest)); -+ retval->alias = savestring (alias, strlen (alias)); -+ retval->declaration = savestring (declaration, strlen (declaration)); -+ retval->line_number = line_number; - retval->next = next; -+ retval->searched = 0; - - return retval; - } -@@ -241,10 +256,18 @@ cp_copy_usings (struct using_direct *using, - obstack); - retval->import_dest = obsavestring (using->import_dest, strlen (using->import_dest), - obstack); -+ retval->alias = obsavestring (using->alias, strlen (using->alias), -+ obstack); -+ retval->declaration = obsavestring (using->declaration, strlen (using->declaration), -+ obstack); - retval->next = cp_copy_usings (using->next, obstack); - -+ retval->searched = using->searched; -+ - xfree (using->import_src); - xfree (using->import_dest); -+ xfree (using->alias); -+ xfree (using->declaration); - xfree (using); - - return retval; -@@ -261,12 +284,48 @@ cp_copy_usings (struct using_direct *using, - - struct symbol * - cp_lookup_symbol_nonlocal (const char *name, -- const char *linkage_name, - const struct block *block, - const domain_enum domain) - { -- return lookup_namespace_scope (name, linkage_name, block, domain, -- block_scope (block), 0); -+ struct symbol *sym; -+ const char *scope = block_scope (block); -+ -+ sym = lookup_namespace_scope (name, block, domain, scope, 0); -+ if (sym != NULL) -+ return sym; -+ -+ return cp_lookup_symbol_namespace(scope, name, block, domain); -+} -+ -+/* Searches for NAME in the current namespace, and by applying relevant import -+ statements belonging to BLOCK and its parents. SCOPE is the namespace -+ scope of the context in which the search is being evaluated. */ -+ -+struct symbol* -+cp_lookup_symbol_namespace (const char *scope, -+ const char *name, -+ const struct block *block, -+ const domain_enum domain) -+{ -+ struct symbol *sym; -+ -+ /* First, try to find the symbol in the given namespace. */ -+ sym = cp_lookup_symbol_in_namespace (scope, name, block, domain); -+ if ( sym != NULL) -+ return sym; -+ -+ /* Search for name in namespaces imported to this and parent blocks. */ -+ while (block != NULL) -+ { -+ sym = cp_lookup_symbol_imports(scope,name, block, domain,0,1); -+ -+ if (sym) -+ return sym; -+ -+ block = BLOCK_SUPERBLOCK(block); -+ } -+ -+ return NULL; - } - - /* Lookup NAME at namespace scope (or, in C terms, in static and -@@ -284,9 +343,8 @@ cp_lookup_symbol_nonlocal (const char *name, - "A::x", and if that call fails, then the first call looks for - "x". */ - --static struct symbol * -+struct symbol * - lookup_namespace_scope (const char *name, -- const char *linkage_name, - const struct block *block, - const domain_enum domain, - const char *scope, -@@ -308,8 +366,7 @@ lookup_namespace_scope (const char *name, - new_scope_len += 2; - } - new_scope_len += cp_find_first_component (scope + new_scope_len); -- sym = lookup_namespace_scope (name, linkage_name, block, -- domain, scope, new_scope_len); -+ sym = lookup_namespace_scope (name, block, domain, scope, new_scope_len); - if (sym != NULL) - return sym; - } -@@ -320,25 +377,98 @@ lookup_namespace_scope (const char *name, - namespace = alloca (scope_len + 1); - strncpy (namespace, scope, scope_len); - namespace[scope_len] = '\0'; -- return cp_lookup_symbol_namespace (namespace, name, linkage_name, -- block, domain); -+ return cp_lookup_symbol_in_namespace (namespace, name,block, domain); - } - --/* Look up NAME in the C++ namespace NAMESPACE, applying the using -- directives that are active in BLOCK. Other arguments are as in -+/* Look up NAME in the C++ namespace NAMESPACE. Other arguments are as in - cp_lookup_symbol_nonlocal. */ - -+static struct symbol * -+cp_lookup_symbol_in_namespace (const char *namespace, -+ const char *name, -+ const struct block *block, -+ const domain_enum domain) -+{ -+ -+ if (namespace[0] == '\0') -+ { -+ return lookup_symbol_file (name, block,domain, 0); -+ } -+ else -+ { -+ char *concatenated_name -+ = alloca (strlen (namespace) + 2 + strlen (name) + 1); -+ strcpy (concatenated_name, namespace); -+ strcat (concatenated_name, "::"); -+ strcat (concatenated_name, name); -+ return lookup_symbol_file (concatenated_name, block, domain, -+ cp_is_anonymous (namespace)); -+ } -+} -+ -+/* Used for cleanups to reset the "searched" flag incase -+ of an error. */ -+ -+static void -+reset_directive_searched (void *data) -+{ -+ struct using_direct *direct = data; -+ direct->searched = 0; -+} -+ -+/* Search for NAME by applying all import statements belonging -+ to BLOCK which are applicable in SCOPE. If DECLARATION_ONLY the search -+ is restricted to using declarations. -+ Example: -+ -+ namespace A{ -+ int x; -+ } -+ using A::x; -+ -+ If SEARCH_PARENTS the search will include imports which are applicable in -+ parents of scopes. -+ Example: -+ -+ namespace A{ -+ using namespace X; -+ namespace B{ -+ using namespace Y; -+ } -+ } -+ -+ If SCOPE is "A::B" and SEARCH_PARENTS is true the imports of namespaces X -+ and Y will be considered. If SEARCH_PARENTS is false only the import of Y -+ is considered. */ -+ - struct symbol * --cp_lookup_symbol_namespace (const char *namespace, -- const char *name, -- const char *linkage_name, -- const struct block *block, -- const domain_enum domain) -+cp_lookup_symbol_imports (const char *scope, -+ const char *name, -+ const struct block *block, -+ const domain_enum domain, -+ int declaration_only, -+ int search_parents) - { -- const struct using_direct *current; -- struct symbol *sym; -+ struct using_direct *current; -+ struct symbol *sym = NULL; -+ int directive_match; -+ int current_line; -+ struct cleanup *searched_cleanup; -+ -+ if(!declaration_only) -+ /* First, try to find the symbol in the given namespace. */ -+ sym = cp_lookup_symbol_in_namespace (scope, name, block, domain); - -- /* First, go through the using directives. If any of them add new -+ if ( sym != NULL) -+ return sym; -+ -+ if (has_stack_frames ()) -+ current_line = find_pc_line (get_frame_pc (get_selected_frame (NULL)), -+ 0).line; -+ else -+ current_line = 0; -+ -+ /* Go through the using directives. If any of them add new - names to the namespace we're searching in, see if we can find a - match by applying them. */ - -@@ -346,39 +476,78 @@ cp_lookup_symbol_namespace (const char *namespace, - current != NULL; - current = current->next) - { -- if (strcmp (namespace, current->import_dest) == 0) -+ -+ /* If the import destination is the current scope or one of its ancestors then -+ it is applicable. */ -+ directive_match = search_parents ? -+ strncmp (scope, current->import_dest, -+ strlen(current->import_dest)) == 0 : -+ strcmp (scope, current->import_dest) == 0; -+ -+ if (directive_match && -+ current->line_number < current_line && -+ !current->searched) - { -- sym = cp_lookup_symbol_namespace (current->import_src, -- name, -- linkage_name, -- block, -- domain); -+ current->searched = 1; -+ searched_cleanup = make_cleanup (reset_directive_searched, current); -+ -+ /* If there is an import of a single declaration, compare the imported -+ declaration with the sought out name. If there is a match pass -+ current->import_src as NAMESPACE to direct the search towards the -+ imported namespace. */ -+ if (strcmp ("", current->declaration) != 0) -+ { -+ if (strcmp (name, current->declaration) == 0) -+ { -+ sym = cp_lookup_symbol_in_namespace (current->import_src, -+ name, -+ block, -+ domain); -+ } -+ -+ current->searched = 0; -+ if (sym) -+ return sym; -+ -+ continue; -+ } -+ -+ if (declaration_only) -+ { -+ current->searched = 0; -+ discard_cleanups (searched_cleanup); -+ continue; -+ } -+ -+ if (strcmp (name, current->alias) == 0) -+ /* If the import is creating an alias and the alias matches the -+ sought name. Pass current->inner as the NAME to direct the -+ search towards the aliased namespace */ -+ { -+ sym = cp_lookup_symbol_in_namespace (scope, -+ current->import_src, -+ block, -+ domain); -+ } else if (strcmp ("", current->alias) == 0){ -+ /* If this import statement creates no alias, pass current->inner as -+ NAMESPACE to direct the search towards the imported namespace. */ -+ sym = cp_lookup_symbol_imports (current->import_src, -+ name, -+ block, -+ domain, -+ 0, -+ 0); -+ } -+ -+ current->searched = 0; -+ discard_cleanups (searched_cleanup); -+ - if (sym != NULL) - return sym; - } - } - -- /* We didn't find anything by applying any of the using directives -- that are still applicable; so let's see if we've got a match -- using the current namespace. */ -- -- if (namespace[0] == '\0') -- { -- return lookup_symbol_file (name, linkage_name, block, -- domain, 0); -- } -- else -- { -- char *concatenated_name -- = alloca (strlen (namespace) + 2 + strlen (name) + 1); -- strcpy (concatenated_name, namespace); -- strcat (concatenated_name, "::"); -- strcat (concatenated_name, name); -- sym = lookup_symbol_file (concatenated_name, linkage_name, -- block, domain, -- cp_is_anonymous (namespace)); -- return sym; -- } -+ return NULL; - } - - /* Look up NAME in BLOCK's static block and in global blocks. If -@@ -388,17 +557,15 @@ cp_lookup_symbol_namespace (const char *namespace, - - static struct symbol * - lookup_symbol_file (const char *name, -- const char *linkage_name, - const struct block *block, - const domain_enum domain, - int anonymous_namespace) - { - struct symbol *sym = NULL; - -- sym = lookup_symbol_static (name, linkage_name, block, domain); -+ sym = lookup_symbol_static (name, block, domain); - if (sym != NULL) - return sym; -- - if (anonymous_namespace) - { - /* Symbols defined in anonymous namespaces have external linkage -@@ -408,12 +575,11 @@ lookup_symbol_file (const char *name, - const struct block *global_block = block_global_block (block); - - if (global_block != NULL) -- sym = lookup_symbol_aux_block (name, linkage_name, global_block, -- domain); -+ sym = lookup_symbol_aux_block (name, global_block, domain); - } - else - { -- sym = lookup_symbol_global (name, linkage_name, block, domain); -+ sym = lookup_symbol_global (name, block, domain); - } - - if (sym != NULL) -@@ -434,6 +600,7 @@ lookup_symbol_file (const char *name, - sym = lookup_possible_namespace_symbol (name); - if (sym != NULL) - return sym; -+ - } - - return NULL; -@@ -461,9 +628,8 @@ cp_lookup_nested_type (struct type *parent_type, - lookup_symbol_namespace works when looking them up. */ - - const char *parent_name = TYPE_TAG_NAME (parent_type); -- struct symbol *sym = cp_lookup_symbol_namespace (parent_name, -+ struct symbol *sym = cp_lookup_symbol_in_namespace (parent_name, - nested_name, -- NULL, - block, - VAR_DOMAIN); - if (sym == NULL || SYMBOL_CLASS (sym) != LOC_TYPEDEF) -@@ -709,7 +875,7 @@ check_one_possible_namespace_symbol (const char *name, int len, - - memcpy (name_copy, name, len); - name_copy[len] = '\0'; -- sym = lookup_block_symbol (block, name_copy, NULL, VAR_DOMAIN); -+ sym = lookup_block_symbol (block, name_copy, VAR_DOMAIN); - - if (sym == NULL) - { -@@ -749,7 +915,7 @@ lookup_possible_namespace_symbol (const char *name) - struct symbol *sym; - - sym = lookup_block_symbol (get_possible_namespace_block (objfile), -- name, NULL, VAR_DOMAIN); -+ name, VAR_DOMAIN); - - if (sym != NULL) - return sym; -diff --git a/gdb/cp-support.c b/gdb/cp-support.c -index f12d785..23b34c1 100644 ---- a/gdb/cp-support.c -+++ b/gdb/cp-support.c -@@ -32,6 +32,9 @@ - #include "block.h" - #include "complaints.h" - #include "gdbtypes.h" -+#include "exceptions.h" -+#include "expression.h" -+#include "value.h" - - #include "safe-ctype.h" - -@@ -70,6 +73,18 @@ struct cmd_list_element *maint_cplus_cmd_list = NULL; - static void maint_cplus_command (char *arg, int from_tty); - static void first_component_command (char *arg, int from_tty); - -+/* Operator validation. -+ NOTE: Multi-byte operators (usually the assignment variety operator) -+ must appear before the single byte version, i.e., "+=" before "+". */ -+static const char *operator_tokens[] = -+ { -+ "++", "+=", "+", "->*", "->", "--", "-=", "-", "*=", "*", "/=", "/", -+ "%=", "%", "!=", "==", "!", "&&", "<<=", "<<", ">>=", ">>", -+ "<=", "<", ">=", ">", "~", "&=", "&", "|=", "||", "|", "^=", "^", -+ "=", "()", "[]", ",", "new", "delete" -+ /* new[] and delete[] require special whitespace handling */ -+ }; -+ - /* Return 1 if STRING is clearly already in canonical form. This - function is conservative; things which it does not recognize are - assumed to be non-canonical, and the parser will sort them out -@@ -175,7 +190,8 @@ mangled_name_to_comp (const char *mangled_name, int options, - return ret; - } - --/* Return the name of the class containing method PHYSNAME. */ -+/* Return the name of the class or namespace containing -+ function, method, or variable PHYSNAME. */ - - char * - cp_class_name_from_physname (const char *physname) -@@ -825,9 +841,9 @@ read_in_psymtabs (const char *func_name) - if (ps->readin) - continue; - -- if ((lookup_partial_symbol (ps, func_name, NULL, 1, VAR_DOMAIN) -+ if ((lookup_partial_symbol (ps, func_name, 1, VAR_DOMAIN) - != NULL) -- || (lookup_partial_symbol (ps, func_name, NULL, 0, VAR_DOMAIN) -+ || (lookup_partial_symbol (ps, func_name, 0, VAR_DOMAIN) - != NULL)) - psymtab_to_symtab (ps); - } -@@ -909,6 +925,107 @@ first_component_command (char *arg, int from_tty) - - extern initialize_file_ftype _initialize_cp_support; /* -Wmissing-prototypes */ - -+#define SKIP_SPACE(P) \ -+ do \ -+ { \ -+ while (*(P) == ' ' || *(P) == '\t') \ -+ ++(P); \ -+ } \ -+ while (0) -+ -+/* Returns the length of the operator name or 0 if INPUT does not -+ point to a valid C++ operator. INPUT should start with "operator". */ -+int -+cp_validate_operator (const char *input) -+{ -+ int i; -+ char *copy; -+ const char *p; -+ struct expression *expr; -+ struct value *val; -+ struct gdb_exception except; -+ struct cleanup *old_chain; -+ -+ p = input; -+ -+ if (strncmp (p, "operator", 8) == 0) -+ { -+ int valid = 0; -+ p += 8; -+ -+ SKIP_SPACE (p); -+ for (i = 0; i < sizeof (operator_tokens) / sizeof (operator_tokens[0]); -+ ++i) -+ { -+ int length = strlen (operator_tokens[i]); -+ /* By using strncmp here, we MUST have operator_tokens ordered! -+ See additional notes where operator_tokens is defined above. */ -+ if (strncmp (p, operator_tokens[i], length) == 0) -+ { -+ const char *op = p; -+ valid = 1; -+ p += length; -+ -+ if (strncmp (op, "new", 3) == 0 -+ || strncmp (op, "delete", 6) == 0) -+ { -+ -+ /* Special case: new[] and delete[]. We must be careful -+ to swallow whitespace before/in "[]". */ -+ SKIP_SPACE (p); -+ -+ if (*p == '[') -+ { -+ ++p; -+ SKIP_SPACE (p); -+ if (*p == ']') -+ ++p; -+ else -+ valid = 0; -+ } -+ } -+ -+ if (valid) -+ return (p - input); -+ } -+ } -+ -+ /* Check input for a conversion operator. */ -+ -+ /* Skip past base typename */ -+ while (*p != '*' && *p != '&' && *p != 0 && *p != ' ') -+ ++p; -+ SKIP_SPACE (p); -+ -+ /* Add modifiers '*'/'&' */ -+ while (*p == '*' || *p == '&') -+ { -+ ++p; -+ SKIP_SPACE (p); -+ } -+ -+ /* Check for valid type. [Remember: input starts with -+ "operator".] */ -+ copy = savestring (input + 8, p - input - 8); -+ expr = NULL; -+ val = NULL; -+ TRY_CATCH (except, RETURN_MASK_ALL) -+ { -+ expr = parse_expression (copy); -+ val = evaluate_type (expr); -+ } -+ -+ xfree (copy); -+ if (expr) -+ xfree (expr); -+ -+ if (val != NULL && value_type (val) != NULL) -+ return (p - input); -+ } -+ -+ return 0; -+} -+ - void - _initialize_cp_support (void) - { -diff --git a/gdb/cp-support.h b/gdb/cp-support.h -index b5a5c5f..3f48f98 100644 ---- a/gdb/cp-support.h -+++ b/gdb/cp-support.h -@@ -38,15 +38,33 @@ struct demangle_component; - - /* This struct is designed to store data from using directives. It - says that names from namespace IMPORT_SRC should be visible within -- namespace IMPORT_DEST. IMPORT_DEST should always be a strict initial -- substring of IMPORT_SRC. These form a linked list; NEXT is the next element -- of the list. */ -+ namespace IMPORT_DEST. IMPORT_DEST should always be a strict initial -+ substring of IMPORT_SRC. These form a linked list; NEXT is the next -+ element of the list. ALIAS is set to a non empty string if the imported -+ namespace has been aliased.Eg: -+ namespace C=A::B; -+ ALIAS = "C" -+ DECLARATION is the name of the imported declaration, if this import -+ statement represents one. Eg: -+ using A::x; -+ Where x is variable in namespace A. declaration is set to x. -+*/ - - struct using_direct - { - char *import_src; - char *import_dest; -+ -+ char *alias; -+ -+ char *declaration; -+ -+ int line_number; -+ - struct using_direct *next; -+ -+ /* Used during import search to temporarly mark this node as searced. */ -+ int searched; - }; - - -@@ -54,6 +72,7 @@ struct using_direct - - extern char *cp_canonicalize_string (const char *string); - -+ - extern char *cp_class_name_from_physname (const char *physname); - - extern char *method_name_from_physname (const char *physname); -@@ -72,15 +91,23 @@ extern struct symbol **make_symbol_overload_list (const char *, - extern struct type *cp_lookup_rtti_type (const char *name, - struct block *block); - -+extern int cp_validate_operator (const char *input); -+ - /* Functions/variables from cp-namespace.c. */ - - extern int cp_is_anonymous (const char *namespace); - - extern void cp_add_using_directive (const char *dest, -- const char *src); -+ const char *src, -+ const char *alias, -+ const char *declaration, -+ const int line_number); - - extern struct using_direct *cp_add_using (const char *dest, - const char *src, -+ const char *alias, -+ const char *declaration, -+ const int line_number, - struct using_direct *next); - - extern void cp_initialize_namespace (void); -@@ -97,15 +124,20 @@ extern void cp_set_block_scope (const struct symbol *symbol, - extern void cp_scan_for_anonymous_namespaces (const struct symbol *symbol); - - extern struct symbol *cp_lookup_symbol_nonlocal (const char *name, -- const char *linkage_name, - const struct block *block, - const domain_enum domain); - -+struct symbol *cp_lookup_symbol_imports (const char *scope, -+ const char *name, -+ const struct block *block, -+ const domain_enum domain, -+ int declaration_only, -+ int search_parents); -+ - extern struct symbol *cp_lookup_symbol_namespace (const char *namespace, -- const char *name, -- const char *linkage_name, -- const struct block *block, -- const domain_enum domain); -+ const char *name, -+ const struct block *block, -+ const domain_enum domain); - - extern struct type *cp_lookup_nested_type (struct type *parent_type, - const char *nested_name, -diff --git a/gdb/dbxread.c b/gdb/dbxread.c -index 7cb016d..bb9e35a 100644 ---- a/gdb/dbxread.c -+++ b/gdb/dbxread.c -@@ -3581,6 +3581,7 @@ static struct sym_fns aout_sym_fns = - dbx_new_init, /* sym_new_init: init anything gbl to entire symtab */ - dbx_symfile_init, /* sym_init: read initial info, setup for sym_read() */ - dbx_symfile_read, /* sym_read: read a symbol file into symtab */ -+ NULL, /* sym_read_psymbols */ - dbx_symfile_finish, /* sym_finish: finished with file, cleanup */ - default_symfile_offsets, /* sym_offsets: parse user's offsets to - internal form */ -diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo -index 1f98fa5..9e24482 100644 ---- a/gdb/doc/gdb.texinfo -+++ b/gdb/doc/gdb.texinfo -@@ -959,8 +959,10 @@ Connect to process ID @var{number}, as with the @code{attach} command. - @itemx -x @var{file} - @cindex @code{--command} - @cindex @code{-x} --Execute @value{GDBN} commands from file @var{file}. @xref{Command --Files,, Command files}. -+Execute commands from file @var{file}. If @var{file} ends in -+@samp{.py}, then the file is evaluated as Python code. If Python -+support is not enabled in this @value{GDBN}, then an error occurs. -+@xref{Command Files,, Command files}. - - @item -eval-command @var{command} - @itemx -ex @var{command} -@@ -1152,6 +1154,16 @@ for remote debugging. - Run using @var{device} for your program's standard input and output. - @c FIXME: kingdon thinks there is more to -tty. Investigate. +diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo +index 65d4899..96767b0 100644 +--- a/gdb/doc/gdb.texinfo ++++ b/gdb/doc/gdb.texinfo +@@ -1162,6 +1162,16 @@ for remote debugging. + Run using @var{device} for your program's standard input and output. + @c FIXME: kingdon thinks there is more to -tty. Investigate. +@item -P +@cindex @code{-P} @@ -3890,28 +1547,62 @@ index 1f98fa5..9e24482 100644 @c resolve the situation of these eventually @item -tui @cindex @code{--tui} -@@ -18660,7 +18672,7 @@ command: - @table @code - @kindex source - @cindex execute commands from a file --@item source [@code{-v}] @var{filename} -+@item source [@code{-v}] [@code{-p}] @var{filename} - Execute the command file @var{filename}. - @end table +@@ -14308,6 +14318,7 @@ program. To debug a core dump of a previous run, you must also tell + @menu + * Files:: Commands to specify files + * Separate Debug Files:: Debugging information in separate files ++* Index Files:: Index files speed up GDB + * Symbol Errors:: Errors reading symbol files + * Data Files:: GDB data files + @end menu +@@ -15197,6 +15208,46 @@ gnu_debuglink_crc32 (unsigned long crc, + This computation does not apply to the ``build ID'' method. -@@ -18677,6 +18689,11 @@ If @code{-v}, for verbose mode, is given then @value{GDBN} displays - each command as it is executed. The option must be given before - @var{filename}, and is interpreted as part of the filename anywhere else. -+If @var{filename} ends in @samp{.py}, or if @code{-p}, for Python, is -+given then @value{GDBN} evaluates the contents of the file as Python -+code. If Python support is not compiled in to @value{GDBN}, then an -+error occurs. ++@node Index Files ++@section Index Files Speed Up @value{GDBN} ++@cindex index files ++@cindex @samp{.gdb_index} section ++ ++When @value{GDBN} finds a symbol file, it scans the symbols in the ++file in order to construct an internal symbol table. This lets most ++@value{GDBN} operations work quickly---at the cost of a delay early ++on. For large programs, this delay can be quite lengthy, so ++@value{GDBN} provides a way to build an index, which speeds up ++startup. + - Commands that would ask for confirmation if used interactively proceed - without asking when used in a command file. Many @value{GDBN} commands that - normally print messages to say what they are doing omit the messages -@@ -18938,8 +18955,6 @@ containing @code{end}. For example: ++The index is stored as a section in the symbol file. @value{GDBN} can ++write the index to a file, then you can put it into the symbol file ++using @command{objcopy}. ++ ++To create an index file, use the @code{save gdb-index} command: ++ ++@table @code ++@item save gdb-index @var{directory} ++@kindex save gdb-index ++Create an index file for each symbol file currently known by ++@value{GDBN}. Each file is named after its corresponding symbol file, ++with @samp{.gdb-index} appended, and is written into the given ++@var{directory}. ++@end table ++ ++Once you have created an index file you can merge it into your symbol ++file, here named @file{symfile}, using @command{objcopy}: ++ ++@smallexample ++$ objcopy --add-section .gdb_index=symfile.gdb-index \ ++ --set-section-flags .gdb_index=readonly symfile symfile ++@end smallexample ++ ++There are currently some limitation on indices. They only work when ++for DWARF debugging information, not stabs. And, they do not ++currently work for programs using Ada. ++ ++ + @node Symbol Errors + @section Errors Reading Symbol Files + +@@ -20349,8 +20400,6 @@ containing @code{end}. For example: @smallexample (@value{GDBP}) python @@ -3920,7 +1611,7 @@ index 1f98fa5..9e24482 100644 >print 23 >end 23 -@@ -18952,6 +18967,14 @@ in a Python script. This can be controlled using @code{maint set +@@ -20363,6 +20412,14 @@ in a Python script. This can be controlled using @code{maint set python print-stack}: if @code{on}, the default, then Python stack printing is enabled; if @code{off}, then Python stack printing is disabled. @@ -3934,8 +1625,8 @@ index 1f98fa5..9e24482 100644 +auto-loading is disabled. @end table - @node Python API -@@ -18959,6 +18982,14 @@ disabled. + It is also possible to execute a Python script from the @value{GDBN} +@@ -20384,6 +20441,14 @@ and thus is always available. @cindex python api @cindex programming in python @@ -3950,27 +1641,17 @@ index 1f98fa5..9e24482 100644 @cindex python stdout @cindex python pagination At startup, @value{GDBN} overrides Python's @code{sys.stdout} and -@@ -18971,13 +19002,17 @@ situation, a Python @code{KeyboardInterrupt} exception is thrown. +@@ -20395,7 +20460,7 @@ situation, a Python @code{KeyboardInterrupt} exception is thrown. + @menu * Basic Python:: Basic Python Functions. * Exception Handling:: - * Auto-loading:: Automatically loading Python code. -* Values From Inferior:: +* Values From Inferior:: Python representation of values. - * Types In Python:: Python representation of types. - * Pretty Printing:: Pretty-printing values. + * Types In Python:: Python representation of types. + * Pretty Printing API:: Pretty-printing values. * Selecting Pretty-Printers:: How GDB chooses a pretty-printer. -+* Inferiors In Python:: Python representation of inferiors (processes) -+* Threads In Python:: Accessing inferior threads from Python. - * Commands In Python:: Implementing new commands in Python. -+* Parameters In Python:: Adding new @value{GDBN} parameters. - * Functions In Python:: Writing new convenience functions. - * Objfiles In Python:: Object files. -+* Breakpoints In Python:: Manipulating breakpoints using Python. - * Frames In Python:: Acessing inferior stack frames from Python. - @end menu - -@@ -19004,6 +19039,12 @@ command as having originated from the user invoking it interactively. - It must be a boolean value. If omitted, it defaults to @code{False}. +@@ -20456,6 +20521,12 @@ Return a sequence holding all of @value{GDBN}'s breakpoints. + @xref{Breakpoints In Python}, for more information. @end defun +@findex gdb.breakpoints @@ -3982,7 +1663,7 @@ index 1f98fa5..9e24482 100644 @findex gdb.parameter @defun parameter parameter Return the value of a @value{GDBN} parameter. @var{parameter} is a -@@ -19020,6 +19061,7 @@ a Python value of the appropriate type, and returned. +@@ -20472,6 +20543,7 @@ a Python value of the appropriate type, and returned. @defun history number Return a value from @value{GDBN}'s value history (@pxref{Value History}). @var{number} indicates which history element to return. @@ -3990,17 +1671,10 @@ index 1f98fa5..9e24482 100644 If @var{number} is negative, then @value{GDBN} will take its absolute value and count backward from the last element (i.e., the most recent element) to find the value to return. If @var{number} is zero, then @value{GDBN} will -@@ -19031,6 +19073,28 @@ If no exception is raised, the return value is always an instance of - @code{gdb.Value} (@pxref{Values From Inferior}). +@@ -20496,6 +20568,21 @@ compute values, for example, it is the only way to get the value of a + convenience variable (@pxref{Convenience Vars}) as a @code{gdb.Value}. @end defun -+@findex gdb.parse_and_eval -+@defun parse_and_eval expression -+Parse @var{expression} as an expression in the current language, -+evaluate it, and return the result as a @code{gdb.Value}. -+@var{expression} must be a string. -+@end defun -+ +@findex gdb.post_event +@defun post_event event +Put @var{event}, a callable object taking no arguments, into @@ -4019,454 +1693,11 @@ index 1f98fa5..9e24482 100644 @findex gdb.write @defun write string Print a string to @value{GDBN}'s paginated standard output stream. -@@ -19045,6 +19109,11 @@ Flush @value{GDBN}'s paginated standard output stream. Flushing - function. - @end defun - -+@findex gdb.solib_address -+@defun solib_address @var{address} -+Return the name of the shared library holding the given address, or None. -+@end defun -+ - @node Exception Handling - @subsubsection Exception Handling - @cindex python exceptions -@@ -19181,6 +19250,13 @@ The type of this @code{gdb.Value}. The value of this attribute is a - The following methods are provided: - - @table @code -+@defmethod Value cast type -+Cast the @code{gdb.Value} to the type represented by @var{type}, and -+return a new @code{gdb.Value}. @var{type} must be a @code{gdb.Type} -+object. If the cast cannot be performed for some reason, an exception -+is thrown. -+@end defmethod -+ - @defmethod Value dereference - For pointer data types, this method returns a new @code{gdb.Value} object - whose contents is the object pointed to by the pointer. For example, if -@@ -19252,6 +19328,9 @@ module: - This function looks up a type by name. @var{name} is the name of the - type to look up. It must be a string. - -+If @var{block} is given, then @var{name} is looked up in that scope. -+Otherwise, it is searched for globally. -+ - Ordinarily, this function will return an instance of @code{gdb.Type}. - If the named type cannot be found, it will throw an exception. - @end defun -@@ -19304,6 +19383,12 @@ This is @code{True} if the field is artificial, usually meaning that - it was provided by the compiler and not the user. This attribute is - always provided, and is @code{False} if the field is not artificial. - -+@item is_base_class -+This is @code{True} if the field represents a base class of a C@t{++} -+structure. This attribute is always provided, and is @code{False} -+if the field is not a base class of the type on which @code{fields} was -+called, or if that type was not a C@t{++} class. -+ - @item bitsize - If the field is packed, or is a bitfield, then this will have a - non-zero value, which is the size of the field in bits. Otherwise, -@@ -19356,7 +19441,7 @@ If the type does not have a target, this method will throw an - exception. - @end defmethod - --@defmethod Type template_argument n -+@defmethod Type template_argument n [block] - If this @code{gdb.Type} is an instantiation of a template, this will - return a new @code{gdb.Type} which represents the type of the - @var{n}th template argument. -@@ -19364,7 +19449,8 @@ return a new @code{gdb.Type} which represents the type of the - If this @code{gdb.Type} is not a template type, this will throw an - exception. Ordinarily, only C@t{++} code will have template types. - --@var{name} is searched for globally. -+If @var{block} is given, then @var{name} is looked up in that scope. -+Otherwise, it is searched for globally. - @end defmethod - @end table - -@@ -19718,6 +19804,121 @@ import gdb.libstdcxx.v6 - gdb.libstdcxx.v6.register_printers (gdb.current_objfile ()) - @end smallexample - -+@node Inferiors In Python -+@subsubsection Inferiors In Python -+ -+Programs which are being run under @value{GDBN} are called inferiors -+(@pxref{Inferiors}). Python scripts can access information about and -+manipulate inferiors controlled by @value{GDBN} via objects of the -+@code{gdb.Inferior} class. -+ -+The following inferior-related functions are available in the @code{gdb} -+module: -+ -+@defun inferiors -+Return a tuple containing all inferior objects. -+@end defun -+ -+A @code{gdb.Inferior} object has the following attributes: -+ -+@table @code -+@defivar Inferior num -+ID of inferior, as assigned by GDB. -+@end defivar -+ -+@defivar Inferior pid -+Process ID of the inferior, assigned by the underlying OS. -+@end defivar -+ -+@defivar Inferior was_attached -+Boolean signaling whether the inferior was created using `attach', or -+started by @value{GDBN} itself. -+@end defivar -+@end table -+ -+A @code{gdb.Inferior} object has the following methods: -+ -+@table @code -+@defmethod Inferior threads -+This method returns a tuple holding all the threads which are valid -+when it is called. If there are no valid threads, the method will -+return an empty list. -+@end defmethod -+ -+@findex gdb.read_memory -+@defmethod Inferior read_memory @var{address} @var{length} -+Read @var{length} bytes of memory from the inferior, starting at -+@var{address}. Returns a buffer object, which behaves much like an array -+or a string. It can be modified and given to the @code{gdb.write_memory} -+function. -+@end defmethod -+ -+@findex gdb.write_memory -+@defmethod Inferior write_memory @var{address} @var{buffer} @r{[}@var{length}@r{]} -+Write the contents of @var{buffer} (a Python object which supports the -+buffer protocol, i.e., a string, an array or the object returned from -+@code{gdb.read_memory}) to the inferior, starting at @var{address}. -+If given, @var{length} determines the number of bytes from @var{buffer} to -+be written. -+@end defmethod -+ -+@findex gdb.search_memory -+@defmethod Inferior search_memory @var{address} @var{length} @var{pattern} @r{[}@var{size}@r{]} @r{[}@var{max_count}@r{]} -+Search a region of the inferior memory starting at @var{address} with the -+given @var{length}. @var{pattern} can be a string, a byte array, a buffer -+object, a number, a @code{gdb.Value} object (@pxref{Values From Inferior}) -+or a list or tuple with elements in any combination of those types. If -+@var{size} is given and is non-zero, it specifies the size in bytes of a -+Python scalar or @code{gdb.Value} in the search pattern. If @var{size} is -+zero or not specified, it is taken from the value's type in the current -+language. This is useful when one wants to specify the search pattern as -+a mixture of types. Note that this means, for example, that in the case of -+C-like languages a search for an untyped 0x42 will search for -+@samp{(int) 0x42} which is typically four bytes. @var{max_count} is the -+highest number of matches to search for. -+@end defmethod -+@end table -+ -+@node Threads In Python -+@subsubsection Threads In Python -+ -+Python scripts can access information about and manipulate inferior threads -+controlled by @value{GDBN} via objects of the @code{gdb.InferiorThread} class. -+ -+The following inferior-related functions are available in the @code{gdb} -+module: -+ -+@findex gdb.selected_thread -+@defun selected_thread -+This function returns the thread object for the selected thread. If there -+is no selected thread, this will return @code{None}. -+@end defun -+ -+A @code{gdb.InferiorThread} object has the following attributes: -+ -+@table @code -+@defivar InferiorThread num -+ID of the thread, as assigned by GDB. -+@end defivar -+@end table -+ -+A @code{gdb.InferiorThread} object has the following methods: -+ -+@table @code -+@defmethod InferiorThread frames -+Return a tuple containing all frames in the thread. -+@end defmethod -+ -+@defmethod InferiorThread newest_frame -+Return the newest frame thread's stack. -+@end defmethod -+ -+@defmethod InferiorThread switch_to_thread -+This changes @value{GDBN}'s currently selected thread to the one represented -+by this object. -+@end defmethod -+@end table -+ - @node Commands In Python - @subsubsection Commands In Python - -@@ -19970,6 +20171,135 @@ registration of the command with @value{GDBN}. Depending on how the - Python code is read into @value{GDBN}, you may need to import the - @code{gdb} module explicitly. - -+@node Parameters In Python -+@subsubsection Parameters In Python -+ -+@cindex parameters in python -+@cindex python parameters -+@tindex gdb.Parameter -+@tindex Parameter -+You can implement new @value{GDBN} parameters using Python. A new -+parameter is implemented as an instance of the @code{gdb.Parameter} -+class. Parameters are exposed to the user via the @code{set} and -+@code{show} commands. -+ -+@defmethod Parameter __init__ name @var{command-class} @var{parameter-class} @r{[}@var{enum-sequence}@r{]} -+The object initializer for @code{Parameter} registers the new -+parameter with @value{GDBN}. This initializer is normally invoked -+from the subclass' own @code{__init__} method. -+ -+@var{name} is the name of the new parameter. If @var{name} consists -+of multiple words, then the initial words are looked for as prefix -+commands. In this case, if one of the prefix commands does not exist, -+an exception is raised. -+ -+@var{command-class} should be one of the @samp{COMMAND_} constants -+(@pxref{Commands In Python}). This argument tells @value{GDBN} how to -+categorize the new parameter in the help system. -+ -+@var{parameter-class} should be one of the @samp{PARAM_} constants -+defined below. This argument tells @value{GDBN} the type of the new -+parameter; this information is used for input validation and -+completion. -+ -+If @var{parameter-class} is @code{PARAM_ENUM}, then -+@var{enum-sequence} must be a sequence of strings. These strings -+represent the possible values for the parameter. -+ -+If @var{parameter-class} is not @code{PARAM_ENUM}, then the presence -+of a fourth argument will cause an exception to be thrown. -+ -+The help text for the new parameter is taken from the Python -+documentation string for the parameter's class, if there is one. If -+there is no documentation string, a default value is used. -+@end defmethod -+ -+@defivar Parameter set_doc -+If this attribute exists, and is a string, then its value is used as -+the help text for this parameter's @code{set} command. The value is -+examined when @code{Parameter.__init__} is invoked; subsequent changes -+have no effect. -+@end defivar -+ -+@defivar Parameter show_doc -+If this attribute exists, and is a string, then its value is used as -+the help text for this parameter's @code{show} command. The value is -+examined when @code{Parameter.__init__} is invoked; subsequent changes -+have no effect. -+@end defivar -+ -+@defivar Parameter value -+The @code{value} attribute holds the underlying value of the -+parameter. It can be read and assigned to just as any other -+attribute. @value{GDBN} does validation when assignments are made. -+@end defivar -+ -+ -+When a new parameter is defined, its type must be specified. The -+available types are represented by constants defined in the @code{gdb} -+module: -+ -+@table @code -+@findex PARAM_BOOLEAN -+@findex gdb.PARAM_BOOLEAN -+@item PARAM_BOOLEAN -+The value is a plain boolean. The Python boolean values, @code{True} -+and @code{False} are the only valid values. -+ -+@findex PARAM_AUTO_BOOLEAN -+@findex gdb.PARAM_AUTO_BOOLEAN -+@item PARAM_AUTO_BOOLEAN -+The value has three possible states: true, false, and @samp{auto}. In -+Python, true and false are represented using boolean constants, and -+@samp{auto} is represented using @code{None}. -+ -+@findex PARAM_UINTEGER -+@findex gdb.PARAM_UINTEGER -+@item PARAM_UINTEGER -+The value is an unsigned integer. The value of 0 should be -+interpreted to mean ``unlimited''. -+ -+@findex PARAM_INTEGER -+@findex gdb.PARAM_INTEGER -+@item PARAM_INTEGER -+The value is a signed integer. The value of 0 should be interpreted -+to mean ``unlimited''. -+ -+@findex PARAM_STRING -+@findex gdb.PARAM_STRING -+@item PARAM_STRING -+The value is a string. When the user modifies the string, escapes are -+translated. -+ -+@findex PARAM_STRING_NOESCAPE -+@findex gdb.PARAM_STRING_NOESCAPE -+@item PARAM_STRING_NOESCAPE -+The value is a string. When the user modifies the string, escapes are -+passed through untranslated. -+ -+@findex PARAM_OPTIONAL_FILENAME -+@findex gdb.PARAM_OPTIONAL_FILENAME -+@item PARAM_OPTIONAL_FILENAME -+The value is a either a filename (a string), or @code{None}. -+ -+@findex PARAM_FILENAME -+@findex gdb.PARAM_FILENAME -+@item PARAM_FILENAME -+The value is a filename (a string). -+ -+@findex PARAM_ZINTEGER -+@findex gdb.PARAM_ZINTEGER -+@item PARAM_ZINTEGER -+The value is an integer. This is like @code{PARAM_INTEGER}, except 0 -+is interpreted as itself. -+ -+@findex PARAM_ENUM -+@findex gdb.PARAM_ENUM -+@item PARAM_ENUM -+The value is a string, which must be one of a collection string -+constants provided when the parameter is created. -+@end table -+ - @node Functions In Python - @subsubsection Writing new convenience functions - -@@ -20074,6 +20404,82 @@ which is used to format the value. @xref{Pretty Printing}, for more - information. - @end defivar - -+@node Breakpoints In Python -+@subsubsection Manipulating breakpoints using Python -+ -+@cindex breakpoints in python -+@cindex python breakpoints -+@tindex gdb.Breakpoint -+@tindex Breakpoint -+Python code can manipulate breakpoints via the @code{gdb.Breakpoint} -+class. -+ -+@defmethod Breakpoint __init__ location -+Create a new breakpoint. @var{location} is a string naming the -+location of the breakpoint. The contents can be any location -+recognized by the @code{break} command. -+@end defmethod -+ -+@defmethod Breakpoint is_valid -+Return @code{True} if this @code{Breakpoint} object is valid, -+@code{False} otherwise. A @code{Breakpoint} object can become invalid -+if the user deletes the breakpoint. In this case, the object still -+exists, but the underlying breakpoint does not. -+@end defmethod -+ -+@defivar Breakpoint enabled -+This attribute is @code{True} if the breakpoint is enabled, and -+@code{False} otherwise. This attribute is writable. -+@end defivar -+ -+@defivar Breakpoint silent -+This attribute is @code{True} if the breakpoint is silent, and -+@code{False} otherwise. This attribute is writable. -+ -+Note that a breakpoint can also be silent if it has commands and the -+first command is @code{silent}. This is not reported by the -+@code{silent} attribute. -+@end defivar -+ -+@defivar Breakpoint thread -+If the breakpoint is thread-specific, this attribute holds the thread -+id. If the breakpoint is not thread-specific, this attribute is -+@code{None}. This attribute is writable. -+@end defivar -+ -+@defivar Breakpoint ignore_count -+This attribute holds the ignore count for the breakpoint, an integer. -+This attribute is writable. -+@end defivar -+ -+@defivar Breakpoint number -+This attribute holds the breakpoint's number -- the identifier used by -+the user to manipulate the breakpoint. This attribute is not writable. -+@end defivar -+ -+@defivar Breakpoint hit_count -+This attribute holds the hit count for the breakpoint, an integer. -+This attribute is writable, but currently it can only be set to zero. -+@end defivar -+ -+@defivar Breakpoint location -+This attribute holds the location of the breakpoint, as specified by -+the user. It is a string. This attribute is not writable. -+@end defivar -+ -+@defivar Breakpoint condition -+This attribute holds the condition of the breakpoint, as specified by -+the user. It is a string. If there is no condition, this attribute's -+value is @code{None}. This attribute is writable. -+@end defivar -+ -+@defivar Breakpoint commands -+This attribute holds the commands attached to the breakpoint. If -+there are commands, this returns a string holding all the commands, -+separated by newlines. If there are no commands, this attribute is -+@code{None}. This attribute is not writable. -+@end defivar -+ - @node Frames In Python - @subsubsection Acessing inferior stack frames from Python. - -@@ -20138,6 +20544,14 @@ function to a string. - Returns the frame's resume address. - @end defmethod - -+@defmethod Frame block -+Returns the frame's code block. @c (@pxref{Block,,Code Blocks and Scopes}). -+@end defmethod -+ -+@defmethod Frame function -+Returns the symbol for the function corresponding to this frame. @c (@pxref{Symbols In Python}). -+@end defmethod -+ - @defmethod Frame older - Return the frame that called this frame. - @end defmethod -@@ -20146,10 +20560,18 @@ Return the frame that called this frame. - Return the frame called by this frame. - @end defmethod - -+@defmethod Frame find_sal -+Return the frame's symtab and line object. @c (@pxref{Symtab_and_line,, Symtab and line}). -+@end defmethod -+ - @defmethod Frame read_var variable - Return the value of the given variable in this frame. @var{variable} must - be a string. - @end defmethod -+ -+@defmethod Frame select -+Set this frame to be the user's selected frame. -+@end defmethod - @end table - - @node Interpreters diff --git a/gdb/doc/gdbint.texinfo b/gdb/doc/gdbint.texinfo -index c2be3f7..a7811ab 100644 +index 54187dd..320b501 100644 --- a/gdb/doc/gdbint.texinfo +++ b/gdb/doc/gdbint.texinfo -@@ -2114,6 +2114,18 @@ time, and so we attempt to handle symbols incrementally. For instance, +@@ -2102,6 +2102,18 @@ time, and so we attempt to handle symbols incrementally. For instance, we create @dfn{partial symbol tables} consisting of only selected symbols, and only expand them to full symbol tables when necessary. @@ -4485,7 +1716,7 @@ index c2be3f7..a7811ab 100644 @section Symbol Reading @cindex symbol reading -@@ -2206,6 +2218,7 @@ symtab. Upon return, @code{pst->readin} should have been set to 1, and +@@ -2194,6 +2206,7 @@ symtab. Upon return, @code{pst->readin} should have been set to 1, and zero if there were no symbols in that part of the symbol file. @end table @@ -4493,15 +1724,15 @@ index c2be3f7..a7811ab 100644 @section Partial Symbol Tables @value{GDBN} has three types of symbol tables: -@@ -2301,6 +2314,7 @@ and all the psymbols themselves are allocated in a pair of large arrays - on an obstack, so there is little to be gained by trying to free them - unless you want to do a lot more work. +@@ -2295,6 +2308,7 @@ and partial symbol tables behind a set of function pointers known as + the @dfn{quick symbol functions}. These are documented in + @file{symfile.h}. +@node Types @section Types @unnumberedsubsec Fundamental Types (e.g., @code{FT_VOID}, @code{FT_BOOLEAN}). -@@ -2323,6 +2337,7 @@ types map to one @code{TYPE_CODE_*} type, and are distinguished by +@@ -2317,6 +2331,7 @@ types map to one @code{TYPE_CODE_*} type, and are distinguished by other members of the type struct, such as whether the type is signed or unsigned, and how many bits it uses. @@ -4509,7 +1740,7 @@ index c2be3f7..a7811ab 100644 @unnumberedsubsec Builtin Types (e.g., @code{builtin_type_void}, @code{builtin_type_char}). These are instances of type structs that roughly correspond to -@@ -2337,6 +2352,7 @@ only one instance exists, while @file{c-lang.c} builds as many +@@ -2331,6 +2346,7 @@ only one instance exists, while @file{c-lang.c} builds as many @code{TYPE_CODE_INT} types as needed, with each one associated with some particular objfile. @@ -4517,7 +1748,7 @@ index c2be3f7..a7811ab 100644 @section Object File Formats @cindex object file formats -@@ -2422,6 +2438,7 @@ SOM, which is a cross-language ABI). +@@ -2416,6 +2432,7 @@ SOM, which is a cross-language ABI). The SOM reader is in @file{somread.c}. @@ -4525,7 +1756,7 @@ index c2be3f7..a7811ab 100644 @section Debugging File Formats This section describes characteristics of debugging information that -@@ -2493,6 +2510,7 @@ DWARF 3 is an improved version of DWARF 2. +@@ -2487,6 +2504,7 @@ DWARF 3 is an improved version of DWARF 2. @cindex SOM debugging info Like COFF, the SOM definition includes debugging information. @@ -4533,7 +1764,7 @@ index c2be3f7..a7811ab 100644 @section Adding a New Symbol Reader to @value{GDBN} @cindex adding debugging info reader -@@ -2515,6 +2533,7 @@ will only ever be implemented by one object file format may be called +@@ -2509,6 +2527,7 @@ will only ever be implemented by one object file format may be called directly. This interface should be described in a file @file{bfd/lib@var{xyz}.h}, which is included by @value{GDBN}. @@ -4541,7 +1772,7 @@ index c2be3f7..a7811ab 100644 @section Memory Management for Symbol Files Most memory associated with a loaded symbol file is stored on -@@ -2526,10 +2545,45 @@ released when the objfile is unloaded or reloaded. Therefore one +@@ -2520,10 +2539,45 @@ released when the objfile is unloaded or reloaded. Therefore one objfile must not reference symbol or type data from another objfile; they could be unloaded at different times. @@ -4592,11 +1823,11 @@ index c2be3f7..a7811ab 100644 @node Language Support diff --git a/gdb/doc/observer.texi b/gdb/doc/observer.texi -index 4984f31..fcf1b5d 100644 +index e19b8ed..343e160 100644 --- a/gdb/doc/observer.texi +++ b/gdb/doc/observer.texi -@@ -206,6 +206,11 @@ Either @value{GDBN} detached from the inferior, or the inferior - exited. The argument @var{pid} identifies the inferior. +@@ -223,6 +223,11 @@ Bytes from @var{data} to @var{data} + @var{len} have been written + to the current inferior at @var{addr}. @end deftypefun +@deftypefun void mark_used (void) @@ -4604,42 +1835,15 @@ index 4984f31..fcf1b5d 100644 +collector pass. Currently only @code{type_mark_used} marker is supported. +@end deftypefun + - @deftypefun void test_notification (int @var{somearg}) + @deftypefun void test_notification (int @var{somearg}) This observer is used for internal testing. Do not use. See testsuite/gdb.gdb/observer.exp. -diff --git a/gdb/dwarf2-frame.c b/gdb/dwarf2-frame.c -index 668c434..c29c3a5 100644 ---- a/gdb/dwarf2-frame.c -+++ b/gdb/dwarf2-frame.c -@@ -38,6 +38,7 @@ - - #include "complaints.h" - #include "dwarf2-frame.h" -+#include "addrmap.h" - - struct comp_unit; - -@@ -1574,6 +1575,14 @@ dwarf2_frame_find_fde (CORE_ADDR *pc) - CORE_ADDR offset; - CORE_ADDR seek_pc; - -+ if (objfile->quick_addrmap) -+ { -+ if (!addrmap_find (objfile->quick_addrmap, *pc)) -+ continue; -+ } -+ /* FIXME: Read-in only .debug_frame/.eh_frame without .debug_info? */ -+ require_partial_symbols (objfile); -+ - fde_table = objfile_data (objfile, dwarf2_frame_objfile_data); - if (fde_table == NULL) - continue; diff --git a/gdb/dwarf2expr.c b/gdb/dwarf2expr.c -index 46bc9d7..e675575 100644 +index b9ae108..2555908 100644 --- a/gdb/dwarf2expr.c +++ b/gdb/dwarf2expr.c -@@ -848,6 +848,13 @@ execute_stack_op (struct dwarf_expr_context *ctx, - ctx->initialized = 0; +@@ -875,6 +875,13 @@ execute_stack_op (struct dwarf_expr_context *ctx, + ctx->dwarf_call (ctx, result); goto no_push; + case DW_OP_push_object_address: @@ -4653,15 +1857,20 @@ index 46bc9d7..e675575 100644 error (_("Unhandled dwarf expression opcode 0x%x"), op); } diff --git a/gdb/dwarf2expr.h b/gdb/dwarf2expr.h -index a9a8a05..d449012 100644 +index 61b8f00..d94c03c 100644 --- a/gdb/dwarf2expr.h +++ b/gdb/dwarf2expr.h -@@ -102,10 +102,10 @@ struct dwarf_expr_context - The result must be live until the current expression evaluation - is complete. */ - unsigned char *(*get_subr) (void *baton, off_t offset, size_t *length); +@@ -108,9 +108,15 @@ struct dwarf_expr_context + #if 0 + /* Not yet implemented. */ + ++ /* Return the location expression for the dwarf expression ++ subroutine in the die at OFFSET in the current compilation unit. ++ The result must be live until the current expression evaluation ++ is complete. */ ++ unsigned char *(*get_subr) (void *baton, off_t offset, size_t *length); +#endif - ++ /* Return the `object address' for DW_OP_push_object_address. */ CORE_ADDR (*get_object_address) (void *baton); -#endif @@ -4669,28 +1878,41 @@ index a9a8a05..d449012 100644 /* The current depth of dwarf expression recursion, via DW_OP_call*, DW_OP_fbreg, DW_OP_push_object_address, etc., and the maximum diff --git a/gdb/dwarf2loc.c b/gdb/dwarf2loc.c -index 3a81202..85f4487 100644 +index f59bc40..7ff0ef9 100644 --- a/gdb/dwarf2loc.c +++ b/gdb/dwarf2loc.c -@@ -116,6 +116,9 @@ struct dwarf_expr_baton +@@ -48,6 +48,12 @@ static void + dwarf_expr_frame_base_1 (struct symbol *framefunc, CORE_ADDR pc, + const gdb_byte **start, size_t *length); + ++static struct value *dwarf2_evaluate_loc_desc (struct type *type, ++ struct frame_info *frame, ++ const gdb_byte *data, ++ unsigned short size, ++ struct dwarf2_per_cu_data *per_cu); ++ + /* A helper function for dealing with location lists. Given a + symbol baton (BATON) and a pc value (PC), find the appropriate + location expression, set *LOCEXPR_LENGTH, and return a pointer +@@ -127,6 +133,9 @@ struct dwarf_expr_baton { struct frame_info *frame; - struct objfile *objfile; + struct dwarf2_per_cu_data *per_cu; + /* From DW_TAG_variable's DW_AT_location (not DW_TAG_type's + DW_AT_data_location) for DW_OP_push_object_address. */ + CORE_ADDR object_address; }; /* Helper functions for dwarf2_evaluate_loc_desc. */ -@@ -177,22 +180,33 @@ dwarf_expr_frame_base (void *baton, gdb_byte **start, size_t * length) - *start = find_location_expression (symbaton, length, - get_frame_address_in_block (frame)); +@@ -195,23 +204,33 @@ dwarf_expr_frame_base_1 (struct symbol *framefunc, CORE_ADDR pc, + symbaton = SYMBOL_LOCATION_BATON (framefunc); + *start = find_location_expression (symbaton, length, pc); } - else + else if (SYMBOL_COMPUTED_OPS (framefunc) == &dwarf2_locexpr_funcs) { struct dwarf2_locexpr_baton *symbaton; -+ + symbaton = SYMBOL_LOCATION_BATON (framefunc); - if (symbaton != NULL) - { @@ -4725,8 +1947,8 @@ index 3a81202..85f4487 100644 } /* Helper function for dwarf2_evaluate_loc_desc. Computes the CFA for -@@ -215,6 +229,129 @@ dwarf_expr_tls_address (void *baton, CORE_ADDR offset) - return target_translate_tls_address (debaton->objfile, offset); +@@ -263,6 +282,158 @@ dwarf_expr_dwarf_call (struct dwarf_expr_context *ctx, size_t die_offset) + return per_cu_dwarf_call (ctx, die_offset, debaton->per_cu); } +static CORE_ADDR @@ -4785,30 +2007,30 @@ index 3a81202..85f4487 100644 + pushed on the cleanup chain. */ + +static struct dwarf_expr_context * -+dwarf_expr_prep_ctx (struct frame_info *frame, gdb_byte *data, -+ unsigned short size, struct dwarf2_per_cu_data *per_cu) ++dwarf_expr_prep_ctx (struct frame_info *frame, const gdb_byte *data, ++ size_t size, struct dwarf2_per_cu_data *per_cu) +{ + struct dwarf_expr_context *ctx; + struct dwarf_expr_baton baton; -+ -+ if (!frame) -+ frame = get_selected_frame (NULL); ++ struct objfile *objfile = dwarf2_per_cu_objfile (per_cu); + + baton.frame = frame; -+ baton.objfile = dwarf2_per_cu_objfile (per_cu); ++ baton.per_cu = per_cu; + baton.object_address = object_address; + + ctx = new_dwarf_expr_context (); + make_cleanup_free_dwarf_expr_context (ctx); + -+ ctx->gdbarch = get_objfile_arch (baton.objfile); ++ ctx->gdbarch = get_objfile_arch (objfile); + ctx->addr_size = dwarf2_per_cu_addr_size (per_cu); ++ ctx->offset = dwarf2_per_cu_text_offset (per_cu); + ctx->baton = &baton; + ctx->read_reg = dwarf_expr_read_reg; + ctx->read_mem = dwarf_expr_read_mem; + ctx->get_frame_base = dwarf_expr_frame_base; + ctx->get_frame_cfa = dwarf_expr_frame_cfa; + ctx->get_tls_address = dwarf_expr_tls_address; ++ ctx->dwarf_call = dwarf_expr_dwarf_call; + ctx->get_object_address = dwarf_expr_object_address; + + dwarf_expr_eval (ctx, data, size); @@ -4829,8 +2051,8 @@ index 3a81202..85f4487 100644 + CORE_ADDR retval; + struct cleanup *back_to = make_cleanup (null_cleanup, 0); + -+ ctx = dwarf_expr_prep_ctx (NULL, dlbaton->data, dlbaton->size, -+ dlbaton->per_cu); ++ ctx = dwarf_expr_prep_ctx (get_selected_frame (NULL), dlbaton->data, ++ dlbaton->size, dlbaton->per_cu); + if (ctx->num_pieces > 0) + error (_("DW_OP_*piece is unsupported for DW_FORM_block")); + @@ -4851,47 +2073,79 @@ index 3a81202..85f4487 100644 + + return retval; +} ++ ++/* Evaluate DWARF location list at DLLBATON expecting it produces exactly one ++ CORE_ADDR result stored to *ADDRP on the DWARF stack stack. If the result ++ could not be found return zero and keep *ADDRP unchanged. */ ++ ++int ++dwarf_loclist_baton_eval (struct dwarf2_loclist_baton *dllbaton, ++ struct type *type, CORE_ADDR *addrp) ++{ ++ struct frame_info *frame = get_selected_frame (NULL); ++ const gdb_byte *data; ++ size_t size; ++ struct value *val; ++ ++ if (!dllbaton) ++ return 0; ++ ++ data = find_location_expression (dllbaton, &size, ++ get_frame_address_in_block (frame)); ++ if (data == NULL) ++ return 0; ++ ++ val = dwarf2_evaluate_loc_desc (type, frame, data, size, dllbaton->per_cu); ++ if (value_optimized_out (val)) ++ return 0; ++ ++ *addrp = value_as_address (val); ++ return 1; ++} + struct piece_closure { - /* The number of pieces used to describe this variable. */ -@@ -382,9 +519,8 @@ dwarf2_evaluate_loc_desc (struct symbol *var, struct frame_info *frame, + /* Reference count. */ +@@ -887,10 +1058,8 @@ dwarf2_evaluate_loc_desc (struct type *type, struct frame_info *frame, struct dwarf2_per_cu_data *per_cu) { struct value *retval; - struct dwarf_expr_baton baton; struct dwarf_expr_context *ctx; - struct cleanup *old_chain; +- struct objfile *objfile = dwarf2_per_cu_objfile (per_cu); + struct cleanup *old_chain = make_cleanup (null_cleanup, 0); if (size == 0) { -@@ -394,22 +530,8 @@ dwarf2_evaluate_loc_desc (struct symbol *var, struct frame_info *frame, +@@ -900,24 +1069,8 @@ dwarf2_evaluate_loc_desc (struct type *type, struct frame_info *frame, return retval; } - baton.frame = frame; -- baton.objfile = dwarf2_per_cu_objfile (per_cu); +- baton.per_cu = per_cu; + ctx = dwarf_expr_prep_ctx (frame, data, size, per_cu); - ctx = new_dwarf_expr_context (); - old_chain = make_cleanup_free_dwarf_expr_context (ctx); - -- ctx->gdbarch = get_objfile_arch (baton.objfile); +- ctx->gdbarch = get_objfile_arch (objfile); - ctx->addr_size = dwarf2_per_cu_addr_size (per_cu); +- ctx->offset = dwarf2_per_cu_text_offset (per_cu); - ctx->baton = &baton; - ctx->read_reg = dwarf_expr_read_reg; - ctx->read_mem = dwarf_expr_read_mem; - ctx->get_frame_base = dwarf_expr_frame_base; - ctx->get_frame_cfa = dwarf_expr_frame_cfa; - ctx->get_tls_address = dwarf_expr_tls_address; +- ctx->dwarf_call = dwarf_expr_dwarf_call; - - dwarf_expr_eval (ctx, data, size); if (ctx->num_pieces > 0) { struct piece_closure *c; -@@ -439,6 +561,11 @@ dwarf2_evaluate_loc_desc (struct symbol *var, struct frame_info *frame, - CORE_ADDR address = dwarf_expr_fetch (ctx, 0); +@@ -951,6 +1104,11 @@ dwarf2_evaluate_loc_desc (struct type *type, struct frame_info *frame, + CORE_ADDR address = dwarf_expr_fetch_address (ctx, 0); int in_stack_memory = dwarf_expr_fetch_in_stack_memory (ctx, 0); + /* object_address_set called here is required in ALLOCATE_VALUE's @@ -4899,26 +2153,11 @@ index 3a81202..85f4487 100644 + DW_OP_push_object_address. */ + object_address_set (address); + - retval = allocate_value (SYMBOL_TYPE (var)); + retval = allocate_value (type); VALUE_LVAL (retval) = lval_memory; set_value_lazy (retval, 1); -@@ -815,7 +942,7 @@ static int - loclist_describe_location (struct symbol *symbol, struct ui_file *stream) - { - /* FIXME: Could print the entire list of locations. */ -- fprintf_filtered (stream, "a variable with multiple locations"); -+ fprintf_filtered (stream, _("a variable with multiple locations")); - return 1; - } - -@@ -831,16 +958,56 @@ loclist_tracepoint_var_ref (struct symbol *symbol, struct gdbarch *gdbarch, - - data = find_location_expression (dlbaton, &size, ax->scope); - if (data == NULL) -- error (_("Variable \"%s\" is not available."), SYMBOL_NATURAL_NAME (symbol)); -+ error (_("Variable \"%s\" is not available."), SYMBOL_PRINT_NAME (symbol)); - - dwarf2_tracepoint_var_ref (symbol, gdbarch, ax, value, data, size); +@@ -2590,11 +2748,51 @@ loclist_tracepoint_var_ref (struct symbol *symbol, struct gdbarch *gdbarch, + dlbaton->per_cu); } -/* The set of location functions used with the DWARF-2 expression @@ -4946,11 +2185,11 @@ index 3a81202..85f4487 100644 + return 0; +} + -+static int -+missing_describe_location (struct symbol *symbol, struct ui_file *stream) ++static void ++missing_describe_location (struct symbol *symbol, CORE_ADDR addr, ++ struct ui_file *stream) +{ + fprintf_filtered (stream, _("a variable we are unable to resolve")); -+ return 1; +} + +static void @@ -4972,10 +2211,10 @@ index 3a81202..85f4487 100644 + missing_tracepoint_var_ref +}; diff --git a/gdb/dwarf2loc.h b/gdb/dwarf2loc.h -index 0bfcfca..01018d6 100644 +index 826bc45..1e7d8dc 100644 --- a/gdb/dwarf2loc.h +++ b/gdb/dwarf2loc.h -@@ -71,5 +71,11 @@ struct dwarf2_loclist_baton +@@ -86,5 +86,14 @@ struct dwarf2_loclist_baton extern const struct symbol_computed_ops dwarf2_locexpr_funcs; extern const struct symbol_computed_ops dwarf2_loclist_funcs; @@ -4985,184 +2224,158 @@ index 0bfcfca..01018d6 100644 + +extern CORE_ADDR dwarf_locexpr_baton_eval + (struct dwarf2_locexpr_baton *dlbaton); ++ ++extern int dwarf_loclist_baton_eval (struct dwarf2_loclist_baton *dllbaton, ++ struct type *type, CORE_ADDR *addrp); #endif /* dwarf2loc.h */ diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c -index 4cce36b..fb0a693 100644 +index 1e75235..d54e266 100644 --- a/gdb/dwarf2read.c +++ b/gdb/dwarf2read.c -@@ -48,6 +48,12 @@ - #include "gdbcmd.h" - #include "block.h" - #include "addrmap.h" -+#include "f-lang.h" -+#include "c-lang.h" -+#include "typeprint.h" -+#include "jv-lang.h" -+#include "vec.h" -+#include "block.h" +@@ -51,6 +51,9 @@ + #include "typeprint.h" + #include "jv-lang.h" + #include "psympriv.h" ++#include "exceptions.h" ++#include "gdb_stat.h" ++#include "completer.h" #include #include "gdb_string.h" -@@ -93,7 +99,7 @@ typedef struct pubnames_header - _PUBNAMES_HEADER; - #define _ACTUAL_PUBNAMES_HEADER_SIZE 13 - --/* .debug_pubnames header -+/* .debug_aranges header - Because of alignment constraints, this structure has padding and cannot - be mapped directly onto the beginning of the .debug_info section. */ - typedef struct aranges_header -@@ -150,7 +156,10 @@ struct dwarf2_section_info - asection *asection; - gdb_byte *buffer; - bfd_size_type size; -- int was_mmapped; -+ /* A function to call to deallocate BUFFER. If NULL, no -+ deallocation is needed. A pointer to this structure is passed as -+ the only argument. */ -+ void (*destructor) (struct dwarf2_section_info *); +@@ -129,6 +132,33 @@ struct dwarf2_section_info + int readin; }; - struct dwarf2_per_objfile -@@ -336,6 +345,19 @@ struct dwarf2_cu - - /* Field `ranges_offset' is filled in; flag as the value may be zero. */ - unsigned int has_ranges_offset : 1; ++/* All offsets in the index are of this type. It must be ++ architecture-independent. */ ++typedef uint32_t offset_type; ++ ++DEF_VEC_I (offset_type); ++ ++/* A description of the mapped index. The file format is described in ++ a comment by the code that writes the index. */ ++struct mapped_index ++{ ++ /* The total length of the buffer. */ ++ off_t total_size; ++ /* A pointer to the address table data. */ ++ const gdb_byte *address_table; ++ /* Size of the address table data in bytes. */ ++ offset_type address_table_size; ++ /* The hash table. */ ++ const offset_type *index_table; ++ /* Size in slots, each slot is 2 offset_types. */ ++ offset_type index_table_slots; ++ /* A pointer to the constant pool. */ ++ const char *constant_pool; ++}; + -+ /* Fields are valid according to the LANGUAGE field. */ -+ union -+ { -+ /* language_fortran */ -+ struct -+ { -+ /* Module names imported to the block being currently read in. */ -+ struct fortran_using *use; -+ } -+ fortran; -+ } -+ language_specific; - }; - - /* Persistent data held for a compilation unit, even when not -@@ -495,8 +517,7 @@ struct partial_die_info - unsigned int has_byte_size : 1; - - /* The name of this DIE. Normally the value of DW_AT_name, but -- sometimes DW_TAG_MIPS_linkage_name or a string computed in some -- other fashion. */ -+ sometimes a default name for unnamed DIEs. */ - char *name; - char *dirname; - -@@ -689,6 +710,11 @@ struct field_info - int nfnfields; - }; - -+/* A vector used during linkage name generation. */ -+typedef struct die_info *die_info_p; -+DEF_VEC_P (die_info_p); -+static VEC(die_info_p) *die_list; ++typedef struct dwarf2_per_cu_data *dwarf2_per_cu_data_ptr; ++DEF_VEC_P (dwarf2_per_cu_data_ptr); + - /* One item on the queue of compilation units to read in full symbols - for. */ - struct dwarf2_queue_item -@@ -800,7 +826,10 @@ static void scan_partial_symbols (struct partial_die_info *, - static void add_partial_symbol (struct partial_die_info *, - struct dwarf2_cu *); + struct dwarf2_per_objfile + { + struct dwarf2_section_info info; +@@ -141,6 +171,7 @@ struct dwarf2_per_objfile + struct dwarf2_section_info types; + struct dwarf2_section_info frame; + struct dwarf2_section_info eh_frame; ++ struct dwarf2_section_info gdb_index; --static int pdi_needs_namespace (enum dwarf_tag tag); -+static gdb_byte *read_comp_unit_head (struct comp_unit_head *, gdb_byte *, -+ bfd *); + /* Back link. */ + struct objfile *objfile; +@@ -163,6 +194,12 @@ struct dwarf2_per_objfile + /* A flag indicating wether this objfile has a section loaded at a + VMA of 0. */ + int has_section_at_zero; + -+static int die_needs_namespace (struct die_info *, struct dwarf2_cu *); - - static void add_partial_namespace (struct partial_die_info *pdi, - CORE_ADDR *lowpc, CORE_ADDR *highpc, -@@ -825,6 +854,10 @@ static void dwarf2_psymtab_to_symtab (struct partial_symtab *); - - static void psymtab_to_symtab_1 (struct partial_symtab *); - -+static void dwarf2_read_section_1 (struct objfile *objfile, -+ struct obstack *obstack, -+ struct dwarf2_section_info *info); ++ /* True if we are using the mapped index. */ ++ unsigned char using_index; + - static void dwarf2_read_abbrevs (bfd *abfd, struct dwarf2_cu *cu); ++ /* The mapped index. */ ++ struct mapped_index *index_table; + }; - static void dwarf2_free_abbrev_table (void *); -@@ -945,6 +978,11 @@ static struct type *tag_type_to_type (struct die_info *, struct dwarf2_cu *); + static struct dwarf2_per_objfile *dwarf2_per_objfile; +@@ -182,6 +219,7 @@ static struct dwarf2_per_objfile *dwarf2_per_objfile; + #define TYPES_SECTION "debug_types" + #define FRAME_SECTION "debug_frame" + #define EH_FRAME_SECTION "eh_frame" ++#define GDB_INDEX_SECTION "gdb_index" - static struct type *read_type_die (struct die_info *, struct dwarf2_cu *); + /* local data types */ -+static char *physname_prefix (struct die_info *die, struct dwarf2_cu *); +@@ -307,6 +345,32 @@ struct dwarf2_cu + unsigned int has_namespace_info : 1; + }; + ++/* When using the index (and thus not using psymtabs), each CU has an ++ object of this type. This is used to hold information needed by ++ the various "quick" methods. */ ++struct dwarf2_per_cu_quick_data ++{ ++ /* The line table. This can be NULL if there was no line table. */ ++ struct line_header *lines; + -+static void physname_prefix_1 (struct ui_file *, struct die_info *, -+ struct dwarf2_cu *); ++ /* The file names from the line table. */ ++ const char **file_names; ++ /* The file names from the line table after being run through ++ gdb_realpath. */ ++ const char **full_names; + - static char *determine_prefix (struct die_info *die, struct dwarf2_cu *); - - static char *typename_concat (struct obstack *, -@@ -964,7 +1002,8 @@ static int dwarf2_ranges_read (unsigned, CORE_ADDR *, CORE_ADDR *, - struct dwarf2_cu *, struct partial_symtab *); - - static int dwarf2_get_pc_bounds (struct die_info *, -- CORE_ADDR *, CORE_ADDR *, struct dwarf2_cu *); -+ CORE_ADDR *, CORE_ADDR *, struct dwarf2_cu *, -+ struct partial_symtab *pst); - - static void get_scope_pc_bounds (struct die_info *, - CORE_ADDR *, CORE_ADDR *, -@@ -988,17 +1027,25 @@ static void dwarf2_attach_fn_fields_to_type (struct field_info *, - - static void process_structure_scope (struct die_info *, struct dwarf2_cu *); - --static const char *determine_class_name (struct die_info *die, -- struct dwarf2_cu *cu); -- - static void read_common_block (struct die_info *, struct dwarf2_cu *); - - static void read_namespace (struct die_info *die, struct dwarf2_cu *); - -+static void read_import_statement (struct die_info *die, struct dwarf2_cu *); ++ /* The corresponding symbol table. This is NULL if symbols for this ++ CU have not yet been read. */ ++ struct symtab *symtab; + - static void read_module (struct die_info *die, struct dwarf2_cu *cu); - - static void read_import_statement (struct die_info *die, struct dwarf2_cu *); - -+static struct type *read_module_type (struct die_info *die, -+ struct dwarf2_cu *cu); ++ /* A temporary mark bit used when iterating over all CUs in ++ expand_symtabs_matching. */ ++ unsigned int mark : 1; + -+static void read_fortran_imported_module (struct die_info *die, -+ struct dwarf2_cu *cu); ++ /* True if we've tried to read the line table. */ ++ unsigned int read_lines : 1; ++}; + -+static void read_fortran_imported_declaration (struct die_info *die, -+ struct dwarf2_cu *cu); + /* Persistent data held for a compilation unit, even when not + processing it. We put a pointer to this structure in the + read_symtab_private field of the psymtab. If we encounter +@@ -347,10 +411,21 @@ struct dwarf2_per_cu_data + it. */ + htab_t type_hash; + +- /* The partial symbol table associated with this compilation unit, +- or NULL for partial units (which do not have an associated +- symtab). */ +- struct partial_symtab *psymtab; ++ /* The corresponding objfile. */ ++ struct objfile *objfile; + - static const char *namespace_name (struct die_info *die, - int *is_anonymous, struct dwarf2_cu *); ++ /* When using partial symbol tables, the 'psymtab' field is active. ++ Otherwise the 'quick' field is active. */ ++ union ++ { ++ /* The partial symbol table associated with this compilation unit, ++ or NULL for partial units (which do not have an associated ++ symtab). */ ++ struct partial_symtab *psymtab; ++ ++ /* Data needed by the "quick" functions. */ ++ struct dwarf2_per_cu_quick_data *quick; ++ } v; + }; -@@ -1032,7 +1079,10 @@ static gdb_byte *read_full_die (const struct die_reader_specs *reader, + /* Entry in the signatured_types hash table. */ +@@ -1083,6 +1158,9 @@ static int attr_form_is_section_offset (struct attribute *); - static void process_die (struct die_info *, struct dwarf2_cu *); + static int attr_form_is_constant (struct attribute *); --static char *dwarf2_linkage_name (struct die_info *, struct dwarf2_cu *); -+static char *dwarf2_physname (struct die_info *, struct dwarf2_cu *); ++static struct dwarf2_loclist_baton *dwarf2_attr_to_loclist_baton ++ (struct attribute *attr, struct dwarf2_cu *cu); + -+static char *fortran_module_linkage_name (struct die_info *die, -+ struct dwarf2_cu *cu); - - static char *dwarf2_canonicalize_name (char *, struct dwarf2_cu *, - struct obstack *); -@@ -1076,7 +1126,7 @@ static int is_ref_attr (struct attribute *); - - static unsigned int dwarf2_get_ref_die_offset (struct attribute *); - --static int dwarf2_get_attr_constant_value (struct attribute *, int); -+static CORE_ADDR dwarf2_get_attr_constant_value (struct attribute *, CORE_ADDR); - - static struct die_info *follow_die_ref_or_sig (struct die_info *, - struct attribute *, -@@ -1148,6 +1198,9 @@ static void age_cached_comp_units (void); + static void dwarf2_symbol_mark_computed (struct attribute *attr, + struct symbol *sym, + struct dwarf2_cu *cu); +@@ -1113,6 +1191,9 @@ static void age_cached_comp_units (void); static void free_one_cached_comp_unit (void *); @@ -5172,1468 +2385,1442 @@ index 4cce36b..fb0a693 100644 static struct type *set_die_type (struct die_info *, struct type *, struct dwarf2_cu *); -@@ -1167,22 +1220,31 @@ static void dwarf2_clear_marks (struct dwarf2_per_cu_data *); +@@ -1132,6 +1213,56 @@ static void dwarf2_clear_marks (struct dwarf2_per_cu_data *); static struct type *get_die_type (struct die_info *die, struct dwarf2_cu *cu); -+static void destroy_section (struct dwarf2_section_info *info); -+ +static struct dwarf2_locexpr_baton *dwarf2_attr_to_locexpr_baton + (struct attribute *attr, struct dwarf2_cu *cu); ++ ++static void dwarf2_release_queue (void *dummy); ++ ++static void queue_comp_unit (struct dwarf2_per_cu_data *per_cu, ++ struct objfile *objfile); ++ ++static void process_queue (struct objfile *objfile); ++ ++static void find_file_and_directory (struct die_info *die, ++ struct dwarf2_cu *cu, ++ char **name, char **comp_dir); ++ ++static char *file_full_name (int file, struct line_header *lh, ++ const char *comp_dir); ++ ++static gdb_byte *partial_read_comp_unit_head (struct comp_unit_head *header, ++ gdb_byte *info_ptr, ++ gdb_byte *buffer, ++ unsigned int buffer_size, ++ bfd *abfd); ++ ++static void init_cu_die_reader (struct die_reader_specs *reader, ++ struct dwarf2_cu *cu); ++ ++#if WORDS_BIGENDIAN ++ ++/* Convert VALUE between big- and little-endian. */ ++static offset_type ++byte_swap (offset_type value) ++{ ++ offset_type result; ++ ++ result = (value & 0xff) << 24; ++ result |= (value & 0xff00) << 8; ++ result |= (value & 0xff0000) >> 8; ++ result |= (value & 0xff000000) >> 24; ++ return result; ++} ++ ++#define MAYBE_SWAP(V) byte_swap (V) ++ ++#else ++#define MAYBE_SWAP(V) (V) ++#endif /* WORDS_BIGENDIAN */ ++ ++/* The suffix for an index file. */ ++#define INDEX_SUFFIX ".gdb-index" + /* Try to locate the sections we need for DWARF 2 debugging information and return true if we have enough to do something. */ - int - dwarf2_has_info (struct objfile *objfile) - { -- struct dwarf2_per_objfile *data; -- -- /* Initialize per-objfile state. */ -- data = obstack_alloc (&objfile->objfile_obstack, sizeof (*data)); -- memset (data, 0, sizeof (*data)); -- set_objfile_data (objfile, dwarf2_objfile_data_key, data); -- dwarf2_per_objfile = data; -+ dwarf2_per_objfile = objfile_data (objfile, dwarf2_objfile_data_key); -+ if (!dwarf2_per_objfile) +@@ -1230,6 +1361,11 @@ dwarf2_locate_sections (bfd *abfd, asection *sectp, void *ignore_ptr) + dwarf2_per_objfile->types.asection = sectp; + dwarf2_per_objfile->types.size = bfd_get_section_size (sectp); + } ++ else if (section_is_p (sectp->name, GDB_INDEX_SECTION)) + { -+ /* Initialize per-objfile state. */ -+ struct dwarf2_per_objfile *data -+ = obstack_alloc (&objfile->objfile_obstack, sizeof (*data)); -+ memset (data, 0, sizeof (*data)); -+ set_objfile_data (objfile, dwarf2_objfile_data_key, data); -+ dwarf2_per_objfile = data; - -- bfd_map_over_sections (objfile->obfd, dwarf2_locate_sections, NULL); -- return (data->info.asection != NULL && data->abbrev.asection != NULL); -+ bfd_map_over_sections (objfile->obfd, dwarf2_locate_sections, NULL); ++ dwarf2_per_objfile->gdb_index.asection = sectp; ++ dwarf2_per_objfile->gdb_index.size = bfd_get_section_size (sectp); + } -+ return (dwarf2_per_objfile->info.asection != NULL -+ && dwarf2_per_objfile->abbrev.asection != NULL); - } - - /* When loading sections, we can either look for ".", or for -@@ -1275,10 +1337,13 @@ dwarf2_locate_sections (bfd *abfd, asection *sectp, void *ignore_ptr) - } - /* Decompress a section that was compressed using zlib. Store the -- decompressed buffer, and its size, in OUTBUF and OUTSIZE. */ -+ decompressed buffer, and its size, in OUTBUF and OUTSIZE. The -+ result is allocated on OBSTACK; if OBSTACK is NULL, xmalloc is -+ used. */ + if ((bfd_get_section_flags (abfd, sectp) & SEC_LOAD) + && bfd_section_vma (abfd, sectp) == 0) +@@ -1353,87 +1489,940 @@ dwarf2_read_section (struct objfile *objfile, struct dwarf2_section_info *info) + if (pagesize == 0) + pagesize = getpagesize (); - static void --zlib_decompress_section (struct objfile *objfile, asection *sectp, -+zlib_decompress_section (struct objfile *objfile, struct obstack *obstack, -+ asection *sectp, - gdb_byte **outbuf, bfd_size_type *outsize) - { - bfd *abfd = objfile->obfd; -@@ -1295,6 +1360,7 @@ zlib_decompress_section (struct objfile *objfile, asection *sectp, - z_stream strm; - int rc; - int header_size = 12; -+ struct cleanup *old = NULL; - - if (bfd_seek (abfd, sectp->filepos, SEEK_SET) != 0 - || bfd_bread (compressed_buffer, compressed_size, abfd) != compressed_size) -@@ -1324,8 +1390,13 @@ zlib_decompress_section (struct objfile *objfile, asection *sectp, - strm.avail_in = compressed_size - header_size; - strm.next_in = (Bytef*) compressed_buffer + header_size; - strm.avail_out = uncompressed_size; -- uncompressed_buffer = obstack_alloc (&objfile->objfile_obstack, -- uncompressed_size); -+ if (obstack) -+ uncompressed_buffer = obstack_alloc (obstack, uncompressed_size); -+ else +- /* Only try to mmap sections which are large enough: we don't want to +- waste space due to fragmentation. Also, only try mmap for sections +- without relocations. */ ++ /* Only try to mmap sections which are large enough: we don't want to ++ waste space due to fragmentation. Also, only try mmap for sections ++ without relocations. */ ++ ++ if (info->size > 4 * pagesize && (sectp->flags & SEC_RELOC) == 0) + { -+ uncompressed_buffer = xmalloc (uncompressed_size); -+ old = make_cleanup (xfree, uncompressed_buffer); ++ off_t pg_offset = sectp->filepos & ~(pagesize - 1); ++ size_t map_length = info->size + sectp->filepos - pg_offset; ++ caddr_t retbuf = bfd_mmap (abfd, 0, map_length, PROT_READ, ++ MAP_PRIVATE, pg_offset); ++ ++ if (retbuf != MAP_FAILED) ++ { ++ info->was_mmapped = 1; ++ info->buffer = retbuf + (sectp->filepos & (pagesize - 1)) ; ++#if HAVE_POSIX_MADVISE ++ posix_madvise (retbuf, map_length, POSIX_MADV_WILLNEED); ++#endif ++ return; ++ } + } - rc = inflateInit (&strm); - while (strm.avail_in > 0) - { -@@ -1346,26 +1417,176 @@ zlib_decompress_section (struct objfile *objfile, asection *sectp, - error (_("Dwarf Error: concluding DWARF uncompression in '%s': %d"), - bfd_get_filename (abfd), rc); - -+ if (old) -+ discard_cleanups (old); - do_cleanups (cleanup); - *outbuf = uncompressed_buffer; - *outsize = uncompressed_size; - #endif - } - --/* Read the contents of the section SECTP from object file specified by -- OBJFILE, store info about the section into INFO. -- If the section is compressed, uncompress it before returning. */ -+/* A cleanup that calls destroy_section. */ - - static void --dwarf2_read_section (struct objfile *objfile, struct dwarf2_section_info *info) -+destroy_section_cleanup (void *arg) -+{ -+ destroy_section (arg); ++#endif ++ ++ /* If we get here, we are a normal, not-compressed section. */ ++ info->buffer = buf ++ = obstack_alloc (&objfile->objfile_obstack, info->size); ++ ++ /* When debugging .o files, we may need to apply relocations; see ++ http://sourceware.org/ml/gdb-patches/2002-04/msg00136.html . ++ We never compress sections in .o files, so we only need to ++ try this when the section is not compressed. */ ++ retbuf = symfile_relocate_debug_section (objfile, sectp, buf); ++ if (retbuf != NULL) ++ { ++ info->buffer = retbuf; ++ return; ++ } ++ ++ if (bfd_seek (abfd, sectp->filepos, SEEK_SET) != 0 ++ || bfd_bread (buf, info->size, abfd) != info->size) ++ error (_("Dwarf Error: Can't read DWARF data from '%s'"), ++ bfd_get_filename (abfd)); +} + -+/* Read the .debug_aranges section and construct an address map. */ ++/* Fill in SECTP, BUFP and SIZEP with section info, given OBJFILE and ++ SECTION_NAME. */ + +void -+dwarf2_create_quick_addrmap (struct objfile *objfile) ++dwarf2_get_section_info (struct objfile *objfile, const char *section_name, ++ asection **sectp, gdb_byte **bufp, ++ bfd_size_type *sizep) +{ -+ char *aranges_buffer, *aranges_ptr; -+ bfd *abfd = objfile->obfd; -+ CORE_ADDR baseaddr; -+ struct cleanup *old; -+ struct obstack temp_obstack; -+ struct addrmap *mutable_map; ++ struct dwarf2_per_objfile *data ++ = objfile_data (objfile, dwarf2_objfile_data_key); ++ struct dwarf2_section_info *info; + -+ if (!dwarf2_per_objfile->aranges.asection) -+ return; ++ /* We may see an objfile without any DWARF, in which case we just ++ return nothing. */ ++ if (data == NULL) ++ { ++ *sectp = NULL; ++ *bufp = NULL; ++ *sizep = 0; ++ return; ++ } ++ if (section_is_p (section_name, EH_FRAME_SECTION)) ++ info = &data->eh_frame; ++ else if (section_is_p (section_name, FRAME_SECTION)) ++ info = &data->frame; ++ else ++ gdb_assert (0); + -+ baseaddr = ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile)); ++ if (info->asection != NULL && info->size != 0 && info->buffer == NULL) ++ /* We haven't read this section in yet. Do it now. */ ++ dwarf2_read_section (objfile, info); + -+ dwarf2_read_section_1 (objfile, NULL, &dwarf2_per_objfile->aranges); -+ aranges_buffer = dwarf2_per_objfile->aranges.buffer; -+ aranges_ptr = aranges_buffer; -+ old = make_cleanup (destroy_section_cleanup, &dwarf2_per_objfile->aranges); ++ *sectp = info->asection; ++ *bufp = info->buffer; ++ *sizep = info->size; ++} + -+ obstack_init (&temp_obstack); -+ make_cleanup_obstack_free (&temp_obstack); -+ mutable_map = addrmap_create_mutable (&temp_obstack); ++ + -+ while ((aranges_ptr - aranges_buffer) < dwarf2_per_objfile->aranges.size) -+ { -+ struct comp_unit_head cu_header; -+ unsigned int bytes_read, segment_size, delta; -+ LONGEST info_offset; -+ struct dwarf2_cu cu; -+ char *end_ptr; -+ -+ cu_header.initial_length_size = 0; -+ end_ptr = aranges_ptr; -+ aranges_ptr = read_comp_unit_head (&cu_header, aranges_ptr, abfd); -+ end_ptr += cu_header.initial_length_size + cu_header.length; -+ -+ /* Sanity check. */ -+ if (end_ptr - aranges_ptr >= dwarf2_per_objfile->aranges.size) -+ { -+ do_cleanups (old); -+ complaint (&symfile_complaints, -+ _("aranges entry runs off end of `.debug_aranges' section, ignored")); -+ return; -+ } -+ if (cu_header.addr_size == 0) -+ { -+ do_cleanups (old); -+ complaint (&symfile_complaints, -+ _("aranges entry has zero addr_size, ignored")); -+ return; -+ } ++/* Read in the symbols for PER_CU. OBJFILE is the objfile from which ++ this CU came. */ ++static void ++dw2_do_instantiate_symtab (struct objfile *objfile, ++ struct dwarf2_per_cu_data *per_cu) ++{ ++ struct cleanup *back_to; + -+ segment_size = read_1_byte (abfd, aranges_ptr); -+ aranges_ptr += 1; ++ back_to = make_cleanup (dwarf2_release_queue, NULL); + -+ /* Align the pointer to twice the pointer size. I didn't see -+ this in the spec but it appears to be required. */ -+ delta = (aranges_ptr - aranges_buffer) % (2 * cu_header.addr_size); -+ delta = (2 * cu_header.addr_size - delta) % (2 * cu_header.addr_size); -+ aranges_ptr += delta; ++ queue_comp_unit (per_cu, objfile); + -+ memset (&cu, 0, sizeof (cu)); -+ cu.header.addr_size = cu_header.addr_size; ++ if (per_cu->from_debug_types) ++ read_signatured_type_at_offset (objfile, per_cu->offset); ++ else ++ load_full_comp_unit (per_cu, objfile); + -+ while (1) -+ { -+ CORE_ADDR address, length; ++ process_queue (objfile); + -+ address = read_address (abfd, aranges_ptr, &cu, &bytes_read); -+ aranges_ptr += bytes_read; ++ /* Age the cache, releasing compilation units that have not ++ been used recently. */ ++ age_cached_comp_units (); + -+ length = read_address (abfd, aranges_ptr, &cu, &bytes_read); -+ aranges_ptr += bytes_read; ++ do_cleanups (back_to); ++} + -+ if (address == 0 && length == 0) -+ break; ++/* Ensure that the symbols for PER_CU have been read in. OBJFILE is ++ the objfile from which this CU came. Returns the resulting symbol ++ table. */ ++static struct symtab * ++dw2_instantiate_symtab (struct objfile *objfile, ++ struct dwarf2_per_cu_data *per_cu) ++{ ++ if (!per_cu->v.quick->symtab) ++ { ++ struct cleanup *back_to = make_cleanup (free_cached_comp_units, NULL); ++ increment_reading_symtab (); ++ dw2_do_instantiate_symtab (objfile, per_cu); ++ do_cleanups (back_to); ++ } ++ return per_cu->v.quick->symtab; ++} + -+ if (length == 0) -+ { -+ do_cleanups (old); -+ complaint (&symfile_complaints, -+ _("aranges entry has zero length, ignored")); -+ return; -+ } ++/* A helper function that knows how to read a 64-bit value in a way ++ that doesn't make gdb die. Returns 1 if the conversion went ok, 0 ++ otherwise. */ ++static int ++extract_cu_value (const char *bytes, ULONGEST *result) ++{ ++ if (sizeof (ULONGEST) < 8) ++ { ++ int i; + -+ address += baseaddr; ++ /* Ignore the upper 4 bytes if they are all zero. */ ++ for (i = 0; i < 4; ++i) ++ if (bytes[i + 4] != 0) ++ return 0; + -+ addrmap_set_empty (mutable_map, address, address + length - 1, -+ objfile); -+ } ++ *result = extract_unsigned_integer (bytes, 4, BFD_ENDIAN_LITTLE); ++ } ++ else ++ *result = extract_unsigned_integer (bytes, 8, BFD_ENDIAN_LITTLE); ++ return 1; ++} + -+ /* Some older versions of GCC incorrectly started the arange -+ with a (0,0) pair. If we encounter any oddity while reading -+ the section, just abandon the attempt; falling back to the -+ slower code is always safe. */ -+ if (aranges_ptr != end_ptr) -+ { -+ do_cleanups (old); -+ complaint (&symfile_complaints, -+ _("aranges entry ends early, ignored")); -+ return; -+ } ++/* Read the CU list from the mapped index, and use it to create all ++ the CU objects for this objfile. Return 0 if something went wrong, ++ 1 if everything went ok. */ ++static int ++create_cus_from_index (struct objfile *objfile, struct mapped_index *index, ++ const gdb_byte *cu_list, offset_type cu_list_elements) ++{ ++ offset_type i; ++ const char *entry; ++ ++ dwarf2_per_objfile->n_comp_units = cu_list_elements / 2; ++ dwarf2_per_objfile->all_comp_units ++ = obstack_alloc (&objfile->objfile_obstack, ++ dwarf2_per_objfile->n_comp_units ++ * sizeof (struct dwarf2_per_cu_data *)); ++ ++ for (i = 0; i < cu_list_elements; i += 2) ++ { ++ struct dwarf2_per_cu_data *the_cu; ++ ULONGEST offset, length; ++ ++ if (!extract_cu_value (cu_list, &offset) ++ || !extract_cu_value (cu_list + 8, &length)) ++ return 0; ++ cu_list += 2 * 8; ++ ++ the_cu = OBSTACK_ZALLOC (&objfile->objfile_obstack, ++ struct dwarf2_per_cu_data); ++ the_cu->offset = offset; ++ the_cu->length = length; ++ the_cu->objfile = objfile; ++ the_cu->v.quick = OBSTACK_ZALLOC (&objfile->objfile_obstack, ++ struct dwarf2_per_cu_quick_data); ++ dwarf2_per_objfile->all_comp_units[i / 2] = the_cu; + } + -+ objfile->quick_addrmap = addrmap_create_fixed (mutable_map, -+ &objfile->objfile_obstack); -+ do_cleanups (old); ++ return 1; +} + -+/* Free a section buffer allocated with xmalloc. */ -+ ++/* Read the address map data from the mapped index, and use it to ++ populate the objfile's psymtabs_addrmap. */ +static void -+xfree_section_buffer (struct dwarf2_section_info *info) ++create_addrmap_from_index (struct objfile *objfile, struct mapped_index *index) +{ -+ xfree (info->buffer); -+} ++ const gdb_byte *iter, *end; ++ struct obstack temp_obstack; ++ struct addrmap *mutable_map; ++ struct cleanup *cleanup; ++ CORE_ADDR baseaddr; ++ ++ obstack_init (&temp_obstack); ++ cleanup = make_cleanup_obstack_free (&temp_obstack); ++ mutable_map = addrmap_create_mutable (&temp_obstack); + -+/* If section described by INFO was mmapped, munmap it now. */ ++ iter = index->address_table; ++ end = iter + index->address_table_size; + -+static void -+munmap_section_buffer (struct dwarf2_section_info *info) ++ baseaddr = ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile)); ++ ++ while (iter < end) ++ { ++ ULONGEST hi, lo, cu_index; ++ lo = extract_unsigned_integer (iter, 8, BFD_ENDIAN_LITTLE); ++ iter += 8; ++ hi = extract_unsigned_integer (iter, 8, BFD_ENDIAN_LITTLE); ++ iter += 8; ++ cu_index = extract_unsigned_integer (iter, 4, BFD_ENDIAN_LITTLE); ++ iter += 4; ++ ++ addrmap_set_empty (mutable_map, lo + baseaddr, hi + baseaddr - 1, ++ dwarf2_per_objfile->all_comp_units[cu_index]); ++ } ++ ++ objfile->psymtabs_addrmap = addrmap_create_fixed (mutable_map, ++ &objfile->objfile_obstack); ++ do_cleanups (cleanup); ++} ++ ++/* The hash function for strings in the mapped index. This is the ++ same as the hashtab.c hash function, but we keep a separate copy to ++ maintain control over the implementation. This is necessary ++ because the hash function is tied to the format of the mapped index ++ file. */ ++static hashval_t ++mapped_index_string_hash (const void *p) +{ -+#ifdef HAVE_MMAP -+ intptr_t begin = (intptr_t) info->buffer; -+ intptr_t map_begin = begin & ~(pagesize - 1); -+ size_t map_length = info->size + begin - map_begin; -+ gdb_assert (munmap ((void *) map_begin, map_length) == 0); -+#else -+ /* Without HAVE_MMAP, we should never be here to begin with. */ -+ gdb_assert (0); -+#endif ++ const unsigned char *str = (const unsigned char *) p; ++ hashval_t r = 0; ++ unsigned char c; ++ ++ while ((c = *str++) != 0) ++ r = r * 67 + c - 113; ++ ++ return r; +} + -+/* Read the contents of the section at OFFSET and of size SIZE from -+ the object file specified by OBJFILE into OBSTACK and store it into -+ INFO. If OBSTACK is NULL, xmalloc is used instead. If the section -+ is compressed, uncompress it before returning. */ ++/* Find a slot in the mapped index INDEX for the object named NAME. ++ If NAME is found, set *VEC_OUT to point to the CU vector in the ++ constant pool and return 1. If NAME cannot be found, return 0. */ ++static int ++find_slot_in_mapped_hash (struct mapped_index *index, const char *name, ++ offset_type **vec_out) ++{ ++ offset_type hash = mapped_index_string_hash (name); ++ offset_type slot, step; + -+static void -+dwarf2_read_section_1 (struct objfile *objfile, -+ struct obstack *obstack, -+ struct dwarf2_section_info *info) - { - bfd *abfd = objfile->obfd; - asection *sectp = info->asection; - gdb_byte *buf, *retbuf; - unsigned char header[4]; -+ struct cleanup *old = NULL; - - info->buffer = NULL; -- info->was_mmapped = 0; -+ info->destructor = 0; - - if (info->asection == NULL || info->size == 0) - return; -@@ -1378,7 +1599,7 @@ dwarf2_read_section (struct objfile *objfile, struct dwarf2_section_info *info) - /* Upon decompression, update the buffer and its size. */ - if (strncmp (header, "ZLIB", sizeof (header)) == 0) - { -- zlib_decompress_section (objfile, sectp, &info->buffer, -+ zlib_decompress_section (objfile, obstack, sectp, &info->buffer, - &info->size); - return; - } -@@ -1401,7 +1622,7 @@ dwarf2_read_section (struct objfile *objfile, struct dwarf2_section_info *info) - - if (retbuf != MAP_FAILED) - { -- info->was_mmapped = 1; -+ info->destructor = munmap_section_buffer; - info->buffer = retbuf + (sectp->filepos & (pagesize - 1)) ; - return; - } -@@ -1409,8 +1630,15 @@ dwarf2_read_section (struct objfile *objfile, struct dwarf2_section_info *info) - #endif - - /* If we get here, we are a normal, not-compressed section. */ -- info->buffer = buf -- = obstack_alloc (&objfile->objfile_obstack, info->size); -+ if (obstack) -+ buf = obstack_alloc (obstack, info->size); -+ else ++ slot = hash & (index->index_table_slots - 1); ++ step = ((hash * 17) & (index->index_table_slots - 1)) | 1; ++ ++ for (;;) + { -+ buf = xmalloc (info->size); -+ old = make_cleanup (xfree, buf); -+ info->destructor = xfree_section_buffer; -+ } -+ info->buffer = buf; - - /* When debugging .o files, we may need to apply relocations; see - http://sourceware.org/ml/gdb-patches/2002-04/msg00136.html . -@@ -1419,6 +1647,8 @@ dwarf2_read_section (struct objfile *objfile, struct dwarf2_section_info *info) - retbuf = symfile_relocate_debug_section (abfd, sectp, buf); - if (retbuf != NULL) - { -+ if (old) -+ discard_cleanups (old); - info->buffer = retbuf; - return; - } -@@ -1427,6 +1657,19 @@ dwarf2_read_section (struct objfile *objfile, struct dwarf2_section_info *info) - || bfd_bread (buf, info->size, abfd) != info->size) - error (_("Dwarf Error: Can't read DWARF data from '%s'"), - bfd_get_filename (abfd)); ++ /* Convert a slot number to an offset into the table. */ ++ offset_type i = 2 * slot; ++ const char *str; ++ if (index->index_table[i] == 0 && index->index_table[i + 1] == 0) ++ return 0; ++ ++ str = index->constant_pool + MAYBE_SWAP (index->index_table[i]); ++ if (!strcmp (name, str)) ++ { ++ *vec_out = (offset_type *) (index->constant_pool ++ + MAYBE_SWAP (index->index_table[i + 1])); ++ return 1; ++ } + -+ if (old) -+ discard_cleanups (old); ++ slot = (slot + step) & (index->index_table_slots - 1); ++ } +} + -+/* Read the contents of the section SECTP from object file specified by -+ OBJFILE, store info about the section into INFO. -+ If the section is compressed, uncompress it before returning. */ ++/* Read the index file. If everything went ok, initialize the "quick" ++ elements of all the CUs and return 1. Otherwise, return 0. */ ++static int ++dwarf2_read_index (struct objfile *objfile) ++{ ++ char *addr; ++ struct mapped_index *map; ++ offset_type *metadata; ++ const gdb_byte *cu_list; ++ offset_type cu_list_elements; ++ ++ if (dwarf2_per_objfile->gdb_index.asection == NULL ++ || dwarf2_per_objfile->gdb_index.size == 0) ++ return 0; ++ dwarf2_read_section (objfile, &dwarf2_per_objfile->gdb_index); ++ ++ addr = dwarf2_per_objfile->gdb_index.buffer; ++ /* Version check. */ ++ if (MAYBE_SWAP (*(offset_type *) addr) != 1) ++ return 0; ++ ++ map = OBSTACK_ZALLOC (&objfile->objfile_obstack, struct mapped_index); ++ map->total_size = dwarf2_per_objfile->gdb_index.size; ++ ++ metadata = (offset_type *) (addr + sizeof (offset_type)); ++ cu_list = addr + MAYBE_SWAP (metadata[0]); ++ cu_list_elements = ((MAYBE_SWAP (metadata[1]) - MAYBE_SWAP (metadata[0])) ++ / 8); ++ map->address_table = addr + MAYBE_SWAP (metadata[1]); ++ map->address_table_size = (MAYBE_SWAP (metadata[2]) ++ - MAYBE_SWAP (metadata[1])); ++ map->index_table = (offset_type *) (addr + MAYBE_SWAP (metadata[2])); ++ map->index_table_slots = ((MAYBE_SWAP (metadata[3]) ++ - MAYBE_SWAP (metadata[2])) ++ / (2 * sizeof (offset_type))); ++ map->constant_pool = addr + MAYBE_SWAP (metadata[3]); ++ ++ if (!create_cus_from_index (objfile, map, cu_list, cu_list_elements)) ++ return 0; ++ ++ create_addrmap_from_index (objfile, map); ++ ++ dwarf2_per_objfile->index_table = map; ++ dwarf2_per_objfile->using_index = 1; + ++ return 1; ++} ++ ++/* A helper for the "quick" functions which sets the global ++ dwarf2_per_objfile according to OBJFILE. */ +static void -+dwarf2_read_section (struct objfile *objfile, struct dwarf2_section_info *info) ++dw2_setup (struct objfile *objfile) +{ -+ dwarf2_read_section_1 (objfile, &objfile->objfile_obstack, info); - } - - /* Fill in SECTP, BUFP and SIZEP with section info, given OBJFILE and -@@ -1810,6 +2053,37 @@ lookup_signatured_type (struct objfile *objfile, ULONGEST sig) - return entry; - } - -+/* Find the base address of the compilation unit for range lists and -+ location lists. It will normally be specified by DW_AT_low_pc. -+ In DWARF-3 draft 4, the base address could be overridden by -+ DW_AT_entry_pc. It's been removed, but GCC still uses this for -+ compilation units with discontinuous ranges. */ ++ dwarf2_per_objfile = objfile_data (objfile, dwarf2_objfile_data_key); ++ gdb_assert (dwarf2_per_objfile); ++} + ++/* A helper for the "quick" functions which attempts to read the line ++ table for THIS_CU. */ +static void -+dwarf2_find_base_address (struct die_info *die, struct dwarf2_cu *cu) ++dw2_require_line_header (struct objfile *objfile, ++ struct dwarf2_per_cu_data *this_cu) +{ ++ bfd *abfd = objfile->obfd; ++ struct line_header *lh = NULL; + struct attribute *attr; ++ struct cleanup *cleanups; ++ struct die_info *comp_unit_die; ++ gdb_byte *beg_of_comp_unit, *info_ptr, *buffer; ++ int has_children, i; ++ struct dwarf2_cu cu; ++ unsigned int bytes_read, buffer_size; ++ struct die_reader_specs reader_specs; ++ char *name, *comp_dir; ++ ++ if (this_cu->v.quick->read_lines) ++ return; ++ this_cu->v.quick->read_lines = 1; ++ ++ memset (&cu, 0, sizeof (cu)); ++ cu.objfile = objfile; ++ obstack_init (&cu.comp_unit_obstack); ++ ++ cleanups = make_cleanup (free_stack_comp_unit, &cu); ++ ++ dwarf2_read_section (objfile, &dwarf2_per_objfile->info); ++ buffer_size = dwarf2_per_objfile->info.size; ++ buffer = dwarf2_per_objfile->info.buffer; ++ info_ptr = buffer + this_cu->offset; ++ beg_of_comp_unit = info_ptr; ++ ++ info_ptr = partial_read_comp_unit_head (&cu.header, info_ptr, ++ buffer, buffer_size, ++ abfd); + -+ cu->base_known = 0; -+ cu->base_address = 0; ++ /* Complete the cu_header. */ ++ cu.header.offset = beg_of_comp_unit - buffer; ++ cu.header.first_die_offset = info_ptr - beg_of_comp_unit; + -+ attr = dwarf2_attr (die, DW_AT_entry_pc, cu); ++ this_cu->cu = &cu; ++ cu.per_cu = this_cu; ++ ++ dwarf2_read_abbrevs (abfd, &cu); ++ make_cleanup (dwarf2_free_abbrev_table, &cu); ++ ++ if (this_cu->from_debug_types) ++ info_ptr += 8 /*signature*/ + cu.header.offset_size; ++ init_cu_die_reader (&reader_specs, &cu); ++ info_ptr = read_full_die (&reader_specs, &comp_unit_die, info_ptr, ++ &has_children); ++ ++ attr = dwarf2_attr (comp_unit_die, DW_AT_stmt_list, &cu); + if (attr) + { -+ cu->base_address = DW_ADDR (attr); -+ cu->base_known = 1; ++ unsigned int line_offset = DW_UNSND (attr); ++ lh = dwarf_decode_line_header (line_offset, abfd, &cu); + } -+ else ++ if (lh == NULL) + { -+ attr = dwarf2_attr (die, DW_AT_low_pc, cu); -+ if (attr) -+ { -+ cu->base_address = DW_ADDR (attr); -+ cu->base_known = 1; -+ } ++ do_cleanups (cleanups); ++ return; + } -+} + - /* Subroutine of process_type_comp_unit and dwarf2_build_psymtabs_hard - to combine the common parts. - Process a compilation unit for a psymtab. -@@ -2359,7 +2633,7 @@ partial_die_parent_scope (struct partial_die_info *pdi, - ignoring them. */ - complaint (&symfile_complaints, - _("unhandled containing DIE tag %d for DIE at %d"), -- parent->tag, pdi->offset); -+ parent->tag, real_pdi->offset); - parent->scope = grandparent_scope; - } - -@@ -2374,12 +2648,22 @@ partial_die_full_name (struct partial_die_info *pdi, - struct dwarf2_cu *cu) - { - char *parent_scope; -+ struct partial_die_info *real_pdi; - -- parent_scope = partial_die_parent_scope (pdi, cu); -- if (parent_scope == NULL) -- return NULL; -- else -+ /* We need to look at our parent DIE; if we have a DW_AT_specification, -+ then this means the parent of the specification DIE. -+ partial_die_parent_scope does this loop also, but we do it here -+ since we need to examine real_pdi->parent ourselves. */ ++ find_file_and_directory (comp_unit_die, &cu, &name, &comp_dir); + -+ real_pdi = pdi; -+ while (real_pdi->has_specification) -+ real_pdi = find_partial_die (real_pdi->spec_offset, cu); ++ this_cu->v.quick->lines = lh; + -+ parent_scope = partial_die_parent_scope (real_pdi, cu); -+ if (parent_scope != NULL) - return typename_concat (NULL, parent_scope, pdi->name, cu); ++ this_cu->v.quick->file_names ++ = obstack_alloc (&objfile->objfile_obstack, ++ lh->num_file_names * sizeof (char *)); ++ for (i = 0; i < lh->num_file_names; ++i) ++ this_cu->v.quick->file_names[i] = file_full_name (i + 1, lh, comp_dir); + -+ return NULL; - } - - static void -@@ -2395,12 +2679,9 @@ add_partial_symbol (struct partial_die_info *pdi, struct dwarf2_cu *cu) - - baseaddr = ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile)); - -- if (pdi_needs_namespace (pdi->tag)) -- { -- actual_name = partial_die_full_name (pdi, cu); -- if (actual_name) -- built_actual_name = 1; -- } -+ actual_name = partial_die_full_name (pdi, cu); -+ if (actual_name) -+ built_actual_name = 1; - - if (actual_name == NULL) - actual_name = pdi->name; -@@ -2491,6 +2772,12 @@ add_partial_symbol (struct partial_die_info *pdi, struct dwarf2_cu *cu) - &objfile->global_psymbols, - 0, (CORE_ADDR) 0, cu->language, objfile); - break; -+ case DW_TAG_module: -+ add_psymbol_to_list (actual_name, strlen (actual_name), -+ MODULE_DOMAIN, LOC_STATIC, -+ &objfile->global_psymbols, -+ 0, (CORE_ADDR) 0, cu->language, objfile); -+ break; - case DW_TAG_class_type: - case DW_TAG_interface_type: - case DW_TAG_structure_type: -@@ -2532,34 +2819,17 @@ add_partial_symbol (struct partial_die_info *pdi, struct dwarf2_cu *cu) - break; - } - -- /* Check to see if we should scan the name for possible namespace -- info. Only do this if this is C++, if we don't have namespace -- debugging info in the file, if the psym is of an appropriate type -- (otherwise we'll have psym == NULL), and if we actually had a -- mangled name to begin with. */ -- -- /* FIXME drow/2004-02-22: Why don't we do this for classes, i.e. the -- cases which do not set PSYM above? */ -- -- if (cu->language == language_cplus -- && cu->has_namespace_info == 0 -- && psym != NULL -- && SYMBOL_CPLUS_DEMANGLED_NAME (psym) != NULL) -- cp_check_possible_namespace_symbols (SYMBOL_CPLUS_DEMANGLED_NAME (psym), -- objfile); -- - if (built_actual_name) - xfree (actual_name); - } - --/* Determine whether a die of type TAG living in a C++ class or -- namespace needs to have the name of the scope prepended to the -- name listed in the die. */ -+/* Determine whether DIE needs to have the name of the scope prepended -+ to the name listed in the die. */ - - static int --pdi_needs_namespace (enum dwarf_tag tag) -+die_needs_namespace (struct die_info *die, struct dwarf2_cu *cu) - { -- switch (tag) -+ switch (die->tag) - { - case DW_TAG_namespace: - case DW_TAG_typedef: -@@ -2569,7 +2839,23 @@ pdi_needs_namespace (enum dwarf_tag tag) - case DW_TAG_union_type: - case DW_TAG_enumeration_type: - case DW_TAG_enumerator: -+ case DW_TAG_subprogram: -+ case DW_TAG_member: - return 1; -+ -+ case DW_TAG_variable: -+ { -+ struct attribute *attr; -+ attr = dwarf2_attr (die, DW_AT_specification, cu); -+ if (attr) -+ return 1; -+ attr = dwarf2_attr (die, DW_AT_external, cu); -+ if (attr == NULL && die->parent->tag != DW_TAG_namespace) -+ return 0; -+ return 1; -+ } -+ break; ++ do_cleanups (cleanups); ++} + - default: - return 0; - } -@@ -2602,12 +2888,12 @@ static void - add_partial_module (struct partial_die_info *pdi, CORE_ADDR *lowpc, - CORE_ADDR *highpc, int need_pc, struct dwarf2_cu *cu) - { -- /* Now scan partial symbols in that module. -+ /* Add a symbol for the module. */ - -- FIXME: Support the separate Fortran module namespaces. */ -+ add_partial_symbol (pdi, cu); - -- if (pdi->has_children) -- scan_partial_symbols (pdi->die_child, lowpc, highpc, need_pc, cu); -+ /* Partial symbols in that module are not scanned as they are never globally -+ visible. They get imported to the specific scopes on the full read. */ - } - - /* Read a partial die corresponding to a subprogram and create a partial -@@ -2698,27 +2984,6 @@ guess_structure_name (struct partial_die_info *struct_pdi, - - if (real_pdi->die_parent != NULL) - return; -- -- while (child_pdi != NULL) -- { -- if (child_pdi->tag == DW_TAG_subprogram) -- { -- char *actual_class_name -- = language_class_name_from_physname (cu->language_defn, -- child_pdi->name); -- if (actual_class_name != NULL) -- { -- struct_pdi->name -- = obsavestring (actual_class_name, -- strlen (actual_class_name), -- &cu->comp_unit_obstack); -- xfree (actual_class_name); -- } -- break; -- } -- -- child_pdi = child_pdi->die_sibling; -- } - } - } - -@@ -3295,6 +3560,14 @@ process_die (struct die_info *die, struct dwarf2_cu *cu) - case DW_TAG_imported_declaration: - case DW_TAG_imported_module: - processing_has_namespace_info = 1; -+ if (cu->language == language_fortran) ++/* A helper for the "quick" functions which computes and caches the ++ real path for a given file name from the line table. ++ dw2_require_line_header must have been called before this is ++ invoked. */ ++static const char * ++dw2_require_full_path (struct objfile *objfile, ++ struct dwarf2_per_cu_data *cu, ++ int index) ++{ ++ if (!cu->v.quick->full_names) ++ cu->v.quick->full_names ++ = OBSTACK_CALLOC (&objfile->objfile_obstack, ++ cu->v.quick->lines->num_file_names, ++ sizeof (char *)); ++ ++ if (!cu->v.quick->full_names[index]) ++ cu->v.quick->full_names[index] ++ = gdb_realpath (cu->v.quick->file_names[index]); ++ ++ return cu->v.quick->full_names[index]; ++} ++ ++static struct symtab * ++dw2_find_last_source_symtab (struct objfile *objfile) ++{ ++ int index; ++ dw2_setup (objfile); ++ index = dwarf2_per_objfile->n_comp_units - 1; ++ return dw2_instantiate_symtab (objfile, ++ dwarf2_per_objfile->all_comp_units[index]); ++} ++ ++static void ++dw2_forget_cached_source_info (struct objfile *objfile) ++{ ++ int i; ++ ++ dw2_setup (objfile); ++ for (i = 0; i < dwarf2_per_objfile->n_comp_units; ++i) ++ { ++ struct dwarf2_per_cu_data *cu = dwarf2_per_objfile->all_comp_units[i]; ++ ++ if (cu->v.quick->full_names) + { -+ if (die->tag == DW_TAG_imported_declaration) -+ read_fortran_imported_declaration (die, cu); -+ else -+ read_fortran_imported_module (die, cu); -+ break; ++ int j; ++ ++ for (j = 0; j < cu->v.quick->lines->num_file_names; ++j) ++ xfree ((void *) cu->v.quick->full_names[j]); + } - if (die->child != NULL && (die->tag == DW_TAG_imported_declaration - || cu->language != language_fortran)) - complaint (&symfile_complaints, _("Tag '%s' has unexpected children"), -@@ -3310,41 +3583,71 @@ process_die (struct die_info *die, struct dwarf2_cu *cu) - /* Return the fully qualified name of DIE, based on its DW_AT_name. - If scope qualifiers are appropriate they will be added. The result - will be allocated on the objfile_obstack, or NULL if the DIE does -- not have a name. */ -+ not have a name. -+ -+ The output string will be canonicalized (if C++/Java). */ - - static const char * - dwarf2_full_name (struct die_info *die, struct dwarf2_cu *cu) - { -- struct attribute *attr; -- char *prefix, *name; -- struct ui_file *buf = NULL; -+ char *name; - - name = dwarf2_name (die, cu); -- if (!name) -- return NULL; - - /* These are the only languages we know how to qualify names in. */ -- if (cu->language != language_cplus -- && cu->language != language_java) -- return name; -+ if (name != NULL -+ && (cu->language == language_cplus || cu->language == language_java)) ++ } ++} ++ ++static int ++dw2_lookup_symtab (struct objfile *objfile, const char *name, ++ const char *full_path, const char *real_path, ++ struct symtab **result) ++{ ++ int i; ++ int check_basename = lbasename (name) == name; ++ struct dwarf2_per_cu_data *base_cu = NULL; ++ ++ dw2_setup (objfile); ++ for (i = 0; i < dwarf2_per_objfile->n_comp_units; ++i) + { -+ if (die_needs_namespace (die, cu)) ++ int j; ++ struct dwarf2_per_cu_data *cu = dwarf2_per_objfile->all_comp_units[i]; ++ ++ if (cu->v.quick->symtab) ++ continue; ++ ++ dw2_require_line_header (objfile, cu); ++ if (!cu->v.quick->lines) ++ continue; ++ ++ for (j = 0; j < cu->v.quick->lines->num_file_names; ++j) + { -+ long length; -+ char *prefix; -+ struct ui_file *buf; - -- /* If no prefix is necessary for this type of DIE, return the -- unqualified name. The other three tags listed could be handled -- in pdi_needs_namespace, but that requires broader changes. */ -- if (!pdi_needs_namespace (die->tag) -- && die->tag != DW_TAG_subprogram -- && die->tag != DW_TAG_variable -- && die->tag != DW_TAG_member) -- return name; -+ buf = mem_fileopen (); -+ prefix = determine_prefix (die, cu); -+ if (*prefix != '\0') ++ const char *this_name = cu->v.quick->file_names[j]; ++ ++ if (FILENAME_CMP (name, this_name) == 0) + { -+ char *prefixed_name = typename_concat (NULL, prefix, name, cu); -+ fputs_unfiltered (prefixed_name, buf); -+ xfree (prefixed_name); ++ *result = dw2_instantiate_symtab (objfile, cu); ++ return 1; ++ } ++ ++ if (check_basename && ! base_cu ++ && FILENAME_CMP (lbasename (this_name), name) == 0) ++ base_cu = cu; ++ ++ if (full_path != NULL) ++ { ++ const char *this_full_name = dw2_require_full_path (objfile, ++ cu, j); ++ ++ if (this_full_name ++ && FILENAME_CMP (full_path, this_full_name) == 0) ++ { ++ *result = dw2_instantiate_symtab (objfile, cu); ++ return 1; ++ } + } -+ else -+ fputs_unfiltered (name, buf); - -- prefix = determine_prefix (die, cu); -- if (*prefix != '\0') -- name = typename_concat (&cu->objfile->objfile_obstack, prefix, -- name, cu); -+ name = ui_file_obsavestring (buf, &cu->objfile->objfile_obstack, -+ &length); -+ ui_file_delete (buf); + -+ if (cu->language == language_cplus) ++ if (real_path != NULL) + { -+ char *cname -+ = dwarf2_canonicalize_name (name, cu, -+ &cu->objfile->objfile_obstack); -+ if (cname != NULL) -+ name = cname; ++ const char *this_full_name = dw2_require_full_path (objfile, ++ cu, j); ++ ++ if (this_full_name != NULL) ++ { ++ char *rp = gdb_realpath (this_full_name); ++ if (rp != NULL && FILENAME_CMP (real_path, rp) == 0) ++ { ++ xfree (rp); ++ *result = dw2_instantiate_symtab (objfile, cu); ++ return 1; ++ } ++ xfree (rp); ++ } + } + } + } - - return name; - } - -+/* Read the given DIE's DW_AT_decl_line number. Return -1 if in case of an -+ error. */ + -+static int -+dwarf2_read_decl_line (struct die_info *die, struct dwarf2_cu *cu) -+{ -+ struct attribute *line_attr; ++ if (base_cu) ++ { ++ *result = dw2_instantiate_symtab (objfile, base_cu); ++ return 1; ++ } + -+ line_attr = dwarf2_attr (die, DW_AT_decl_line, cu); -+ if (line_attr) -+ return DW_UNSND (line_attr); ++ return 0; ++} + -+ return -1; ++static struct symtab * ++dw2_lookup_symbol (struct objfile *objfile, int block_index, ++ const char *name, domain_enum domain) ++{ ++ /* We do all the work in the pre_expand_symtabs_matching hook ++ instead. */ ++ return NULL; +} + - /* Read the import statement specified by the given die and record it. */ - - static void -@@ -3354,9 +3657,15 @@ read_import_statement (struct die_info *die, struct dwarf2_cu *cu) - struct die_info *imported_die; - const char *imported_name; - const char *imported_name_prefix; -- const char *import_prefix; - char *canonical_name; -- -+ const char *import_alias; -+ const char *imported_declaration = ""; -+ const char *import_prefix; -+ -+ int line_number = -1; -+ -+ int is_anonymous = 0; -+ - import_attr = dwarf2_attr (die, DW_AT_import, cu); - if (import_attr == NULL) - { -@@ -3404,17 +3713,27 @@ read_import_statement (struct die_info *die, struct dwarf2_cu *cu) - return; - } - -- /* FIXME: dwarf2_name (die); for the local name after import. */ -- -- /* Figure out where the statement is being imported to. */ -+ /* Figure out the local name after import. */ -+ import_alias = dwarf2_name(die, cu); -+ if(import_alias == NULL){ -+ import_alias = ""; -+ } -+ -+ /* Determine the line number at which the import was made */ -+ line_number = dwarf2_read_decl_line(die, cu); -+ -+ /* Figure out where the statement is being imported to */ - import_prefix = determine_prefix (die, cu); - - /* Figure out what the scope of the imported die is and prepend it - to the name of the imported die. */ - imported_name_prefix = determine_prefix (imported_die, cu); -- -- if (strlen (imported_name_prefix) > 0) -- { -+ -+ if(imported_die->tag != DW_TAG_namespace){ -+ imported_declaration = imported_name; -+ canonical_name = (char*)imported_name_prefix; -+ }else{ -+ if(strlen (imported_name_prefix) > 0){ - canonical_name = alloca (strlen (imported_name_prefix) + 2 + strlen (imported_name) + 1); - strcpy (canonical_name, imported_name_prefix); - strcat (canonical_name, "::"); -@@ -3425,8 +3744,14 @@ read_import_statement (struct die_info *die, struct dwarf2_cu *cu) - canonical_name = alloca (strlen (imported_name) + 1); - strcpy (canonical_name, imported_name); - } -- -- using_directives = cp_add_using (import_prefix,canonical_name, using_directives); -+ } -+ -+ using_directives = cp_add_using (import_prefix, -+ canonical_name, -+ import_alias, -+ imported_declaration, -+ line_number, -+ using_directives); - } - - static void -@@ -3695,6 +4020,14 @@ inherit_abstract_dies (struct die_info *die, struct dwarf2_cu *cu) - struct attribute *attr; - - attr = dwarf2_attr (die, DW_AT_abstract_origin, cu); -+ -+ /* GCC 4.3 incorrectly uses DW_AT_specification to indicate die inheritence -+ in the case of import statements. The following is to accommodate -+ that. */ -+ if(!attr){ -+ attr = dwarf2_attr (die, DW_AT_specification, cu); -+ } -+ - if (!attr) - return; - -@@ -3793,6 +4126,7 @@ read_func_scope (struct die_info *die, struct dwarf2_cu *cu) - char *name; - CORE_ADDR baseaddr; - struct block *block; -+ unsigned die_children = 0; - int inlined_func = (die->tag == DW_TAG_inlined_subroutine); - - if (inlined_func) -@@ -3811,13 +4145,23 @@ read_func_scope (struct die_info *die, struct dwarf2_cu *cu) - - baseaddr = ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile)); - -- name = dwarf2_linkage_name (die, cu); -+ name = dwarf2_name (die, cu); - - /* Ignore functions with missing or empty names and functions with - missing or invalid low and high pc attributes. */ -- if (name == NULL || !dwarf2_get_pc_bounds (die, &lowpc, &highpc, cu)) -+ if (name == NULL || !dwarf2_get_pc_bounds (die, &lowpc, &highpc, cu, NULL)){ -+ /* explore abstract origins if present. They might contain useful information -+ such as import statements. */ -+ child_die = die->child; -+ while (child_die && child_die->tag) -+ { -+ child_die = sibling_die (child_die); -+ die_children++; -+ } -+ inherit_abstract_dies(die, cu); - return; -- -+ } -+ - lowpc += baseaddr; - highpc += baseaddr; - -@@ -3844,14 +4188,19 @@ read_func_scope (struct die_info *die, struct dwarf2_cu *cu) - - cu->list_in_scope = &local_symbols; - -- if (die->child != NULL) -+ switch (cu->language) - { -- child_die = die->child; -- while (child_die && child_die->tag) -- { -- process_die (child_die, cu); -- child_die = sibling_die (child_die); -- } -+ case language_fortran: -+ cu->language_specific.fortran.use = NULL; -+ break; -+ } ++/* A helper function that expands all symtabs that hold an object ++ named NAME. */ ++static void ++dw2_do_expand_symtabs_matching (struct objfile *objfile, const char *name) ++{ ++ dw2_setup (objfile); + -+ child_die = die->child; -+ while (child_die && child_die->tag) -+ { -+ process_die (child_die, cu); -+ child_die = sibling_die (child_die); -+ die_children++; - } - - inherit_abstract_dies (die, cu); -@@ -3867,6 +4216,13 @@ read_func_scope (struct die_info *die, struct dwarf2_cu *cu) - determine_prefix (die, cu), - processing_has_namespace_info); - -+ switch (cu->language) ++ if (dwarf2_per_objfile->index_table) + { -+ case language_fortran: -+ BLOCK_FORTRAN_USE (block) = cu->language_specific.fortran.use; -+ break; -+ } ++ offset_type *vec; + - /* If we have address ranges, record them. */ - dwarf2_record_block_ranges (die, block, baseaddr, cu); - -@@ -3903,7 +4259,7 @@ read_lexical_block_scope (struct die_info *die, struct dwarf2_cu *cu) - as multiple lexical blocks? Handling children in a sane way would - be nasty. Might be easier to properly extend generic blocks to - describe ranges. */ -- if (!dwarf2_get_pc_bounds (die, &lowpc, &highpc, cu)) -+ if (!dwarf2_get_pc_bounds (die, &lowpc, &highpc, cu, NULL)) - return; - lowpc += baseaddr; - highpc += baseaddr; -@@ -3920,7 +4276,7 @@ read_lexical_block_scope (struct die_info *die, struct dwarf2_cu *cu) - } - new = pop_context (); - -- if (local_symbols != NULL) -+ if (local_symbols != NULL || using_directives != NULL) - { - struct block *block - = finish_block (0, &local_symbols, new->old_blocks, new->start_addr, -@@ -4075,7 +4431,8 @@ dwarf2_ranges_read (unsigned offset, CORE_ADDR *low_return, - discontinuous, i.e. derived from DW_AT_ranges information. */ - static int - dwarf2_get_pc_bounds (struct die_info *die, CORE_ADDR *lowpc, -- CORE_ADDR *highpc, struct dwarf2_cu *cu) -+ CORE_ADDR *highpc, struct dwarf2_cu *cu, -+ struct partial_symtab *pst) - { - struct attribute *attr; - CORE_ADDR low = 0; -@@ -4103,7 +4460,7 @@ dwarf2_get_pc_bounds (struct die_info *die, CORE_ADDR *lowpc, - { - /* Value of the DW_AT_ranges attribute is the offset in the - .debug_ranges section. */ -- if (!dwarf2_ranges_read (DW_UNSND (attr), &low, &high, cu, NULL)) -+ if (!dwarf2_ranges_read (DW_UNSND (attr), &low, &high, cu, pst)) - return 0; - /* Found discontinuous range of addresses. */ - ret = -1; -@@ -4142,7 +4499,7 @@ dwarf2_get_subprogram_pc_bounds (struct die_info *die, - CORE_ADDR low, high; - struct die_info *child = die->child; - -- if (dwarf2_get_pc_bounds (die, &low, &high, cu)) -+ if (dwarf2_get_pc_bounds (die, &low, &high, cu, NULL)) - { - *lowpc = min (*lowpc, low); - *highpc = max (*highpc, high); -@@ -4179,7 +4536,7 @@ get_scope_pc_bounds (struct die_info *die, - CORE_ADDR best_high = (CORE_ADDR) 0; - CORE_ADDR current_low, current_high; - -- if (dwarf2_get_pc_bounds (die, ¤t_low, ¤t_high, cu)) -+ if (dwarf2_get_pc_bounds (die, ¤t_low, ¤t_high, cu, NULL)) - { - best_low = current_low; - best_high = current_high; -@@ -4474,7 +4831,7 @@ dwarf2_add_field (struct field_info *fip, struct die_info *die, - return; - - /* Get physical name. */ -- physname = dwarf2_linkage_name (die, cu); -+ physname = dwarf2_physname (die, cu); - - /* The name is already allocated along with this objfile, so we don't - need to duplicate it for the type. */ -@@ -4617,7 +4974,7 @@ dwarf2_add_member_fn (struct field_info *fip, struct die_info *die, - return; - - /* Get the mangled name. */ -- physname = dwarf2_linkage_name (die, cu); -+ physname = dwarf2_physname (die, cu); - - /* Look up member function name in fieldlist. */ - for (i = 0; i < fip->nfnfields; i++) -@@ -4661,7 +5018,7 @@ dwarf2_add_member_fn (struct field_info *fip, struct die_info *die, - /* The name is already allocated along with this objfile, so we don't - need to duplicate it for the type. */ - fnp->physname = physname ? physname : ""; -- fnp->type = alloc_type (objfile); -+ fnp->type = alloc_type (objfile, NULL); - this_type = read_type_die (die, cu); - if (this_type && TYPE_CODE (this_type) == TYPE_CODE_FUNC) - { -@@ -4721,18 +5078,18 @@ dwarf2_add_member_fn (struct field_info *fip, struct die_info *die, - { - /* Support the .debug_loc offsets */ - if (attr_form_is_block (attr)) -- { -- fnp->voffset = decode_locdesc (DW_BLOCK (attr), cu) + 2; -- } -+ { -+ fnp->voffset = decode_locdesc (DW_BLOCK (attr), cu) + 2; -+ } - else if (attr_form_is_section_offset (attr)) -- { -+ { - dwarf2_complex_location_expr_complaint (); -- } -+ } - else -- { ++ if (find_slot_in_mapped_hash (dwarf2_per_objfile->index_table, ++ name, &vec)) + { - dwarf2_invalid_attrib_class_complaint ("DW_AT_vtable_elem_location", - fieldname); -- } ++ offset_type i, len = MAYBE_SWAP (*vec); ++ for (i = 0; i < len; ++i) ++ { ++ offset_type cu_index = MAYBE_SWAP (vec[i + 1]); ++ struct dwarf2_per_cu_data *cu; ++ cu = dwarf2_per_objfile->all_comp_units[cu_index]; ++ dw2_instantiate_symtab (objfile, cu); ++ } + } - } - } - -@@ -4845,7 +5202,7 @@ quirk_gcc_member_function_pointer (struct die_info *die, struct dwarf2_cu *cu) - return NULL; - - domain_type = TYPE_TARGET_TYPE (TYPE_FIELD_TYPE (pfn_type, 0)); -- type = alloc_type (objfile); -+ type = alloc_type (objfile, NULL); - smash_to_method_type (type, domain_type, TYPE_TARGET_TYPE (pfn_type), - TYPE_FIELDS (pfn_type), TYPE_NFIELDS (pfn_type), - TYPE_VARARGS (pfn_type)); -@@ -4898,7 +5255,7 @@ read_structure_type (struct die_info *die, struct dwarf2_cu *cu) - return set_die_type (die, type, cu); - } - -- type = alloc_type (objfile); -+ type = alloc_type (objfile, NULL); - INIT_CPLUS_SPECIFIC (type); - - name = dwarf2_name (die, cu); -@@ -4907,14 +5264,18 @@ read_structure_type (struct die_info *die, struct dwarf2_cu *cu) - if (cu->language == language_cplus - || cu->language == language_java) - { -- const char *new_prefix = determine_class_name (die, cu); -- TYPE_TAG_NAME (type) = (char *) new_prefix; -+ TYPE_TAG_NAME (type) = (char *) dwarf2_full_name (die, cu); -+ if (die->tag == DW_TAG_structure_type -+ || die->tag == DW_TAG_class_type) -+ TYPE_NAME (type) = TYPE_TAG_NAME (type); - } - else - { - /* The name is already allocated along with this objfile, so - we don't need to duplicate it for the type. */ -- TYPE_TAG_NAME (type) = name; -+ TYPE_TAG_NAME (type) = (char *) name; -+ if (die->tag == DW_TAG_class_type) -+ TYPE_NAME (type) = TYPE_TAG_NAME (type); - } - } - -@@ -5124,7 +5485,7 @@ read_enumeration_type (struct die_info *die, struct dwarf2_cu *cu) - return set_die_type (die, type, cu); - } - -- type = alloc_type (objfile); -+ type = alloc_type (objfile, NULL); - - TYPE_CODE (type) = TYPE_CODE_ENUM; - name = dwarf2_full_name (die, cu); -@@ -5152,51 +5513,6 @@ read_enumeration_type (struct die_info *die, struct dwarf2_cu *cu) - return set_die_type (die, type, cu); - } - --/* Determine the name of the type represented by DIE, which should be -- a named C++ or Java compound type. Return the name in question, -- allocated on the objfile obstack. */ -- --static const char * --determine_class_name (struct die_info *die, struct dwarf2_cu *cu) --{ -- const char *new_prefix = NULL; -- -- /* If we don't have namespace debug info, guess the name by trying -- to demangle the names of members, just like we did in -- guess_structure_name. */ -- if (!processing_has_namespace_info) -- { -- struct die_info *child; -- -- for (child = die->child; -- child != NULL && child->tag != 0; -- child = sibling_die (child)) -- { -- if (child->tag == DW_TAG_subprogram) -- { -- char *phys_prefix -- = language_class_name_from_physname (cu->language_defn, -- dwarf2_linkage_name -- (child, cu)); -- -- if (phys_prefix != NULL) -- { -- new_prefix -- = obsavestring (phys_prefix, strlen (phys_prefix), -- &cu->objfile->objfile_obstack); -- xfree (phys_prefix); -- break; -- } -- } -- } -- } -- -- if (new_prefix == NULL) -- new_prefix = dwarf2_full_name (die, cu); -- -- return new_prefix; --} -- - /* Given a pointer to a die which begins an enumeration, process all - the dies that define the members of the enumeration, and create the - symbol for the enumeration type. -@@ -5274,6 +5590,29 @@ process_enumeration_scope (struct die_info *die, struct dwarf2_cu *cu) - new_symbol (die, this_type, cu); - } - -+/* Create a new array dimension referencing its target type TYPE. -+ -+ Multidimensional arrays are internally represented as a stack of -+ singledimensional arrays being referenced by their TYPE_TARGET_TYPE. */ ++ } ++} + -+static struct type * -+create_single_array_dimension (struct type *type, struct type *range_type, -+ struct die_info *die, struct dwarf2_cu *cu) ++static void ++dw2_pre_expand_symtabs_matching (struct objfile *objfile, ++ int kind, const char *name, ++ domain_enum domain) +{ -+ type = create_array_type (NULL, type, range_type); ++ dw2_do_expand_symtabs_matching (objfile, name); ++} + -+ /* These generic type attributes need to be fetched by -+ evaluate_subexp_standard 's call of -+ value_subscripted_rvalue only for the innermost array type. */ -+ fetch_die_type_attrs (die, type, cu); ++static void ++dw2_print_stats (struct objfile *objfile) ++{ ++ int i, count; + -+ /* These generic type attributes are checked for allocated/associated -+ validity while accessing FIELD_LOC_KIND_DWARF_BLOCK. */ -+ fetch_die_type_attrs (die, range_type, cu); ++ dw2_setup (objfile); ++ count = 0; ++ for (i = 0; i < dwarf2_per_objfile->n_comp_units; ++i) ++ { ++ struct dwarf2_per_cu_data *cu = dwarf2_per_objfile->all_comp_units[i]; + -+ return type; ++ if (!cu->v.quick->symtab) ++ ++count; ++ } ++ printf_filtered (_(" Number of unread CUs: %d\n"), count); +} + - /* Extract all information from a DW_TAG_array_type DIE and put it in - the DIE's type field. For now, this only handles one dimensional - arrays. */ -@@ -5287,7 +5626,7 @@ read_array_type (struct die_info *die, struct dwarf2_cu *cu) - struct type *element_type, *range_type, *index_type; - struct type **range_types = NULL; - struct attribute *attr; -- int ndim = 0; -+ int ndim = 0, i; - struct cleanup *back_to; - char *name; - -@@ -5334,16 +5673,11 @@ read_array_type (struct die_info *die, struct dwarf2_cu *cu) - type = element_type; - - if (read_array_order (die, cu) == DW_ORD_col_major) -- { -- int i = 0; -- while (i < ndim) -- type = create_array_type (NULL, type, range_types[i++]); -- } -- else -- { -- while (ndim-- > 0) -- type = create_array_type (NULL, type, range_types[ndim]); -- } -+ for (i = 0; i < ndim; i++) -+ type = create_single_array_dimension (type, range_types[i], die, cu); -+ else /* (read_array_order (die, cu) == DW_ORD_row_major) */ -+ for (i = ndim - 1; i >= 0; i--) -+ type = create_single_array_dimension (type, range_types[i], die, cu); - - /* Understand Dwarf2 support for vector types (like they occur on - the PowerPC w/ AltiVec). Gcc just adds another attribute to the -@@ -5410,12 +5744,14 @@ read_set_type (struct die_info *die, struct dwarf2_cu *cu) - return set_die_type (die, set_type, cu); - } - --/* First cut: install each common block member as a global variable. */ -+/* Create appropriate locally-scoped variables for all the DW_TAG_common_block -+ entries. Create also TYPE_CODE_STRUCT listing all such variables to be -+ available for `info common'. COMMON_BLOCK_DOMAIN is used to sepate the -+ common blocks name namespace from regular variable names. */ - - static void - read_common_block (struct die_info *die, struct dwarf2_cu *cu) - { -- struct die_info *child_die; - struct attribute *attr; - struct symbol *sym; - CORE_ADDR base = (CORE_ADDR) 0; -@@ -5425,25 +5761,55 @@ read_common_block (struct die_info *die, struct dwarf2_cu *cu) - { - /* Support the .debug_loc offsets */ - if (attr_form_is_block (attr)) -- { -- base = decode_locdesc (DW_BLOCK (attr), cu); -- } -+ { -+ base = decode_locdesc (DW_BLOCK (attr), cu); -+ } - else if (attr_form_is_section_offset (attr)) -- { -+ { - dwarf2_complex_location_expr_complaint (); -- } -+ } - else -- { -+ { - dwarf2_invalid_attrib_class_complaint ("DW_AT_location", - "common block member"); -- } -+ } - } - if (die->child != NULL) - { -+ struct objfile *objfile = cu->objfile; -+ struct die_info *child_die; -+ struct type *type; -+ struct field *field; -+ char *name; -+ struct symbol *sym; -+ -+ type = alloc_type (objfile, NULL); -+ TYPE_CODE (type) = TYPE_CODE_STRUCT; -+ /* Artificial type to be used only by `info common'. */ -+ TYPE_NAME (type) = ""; -+ - child_die = die->child; - while (child_die && child_die->tag) - { -+ TYPE_NFIELDS (type)++; -+ child_die = sibling_die (child_die); -+ } -+ -+ TYPE_FIELDS (type) = obstack_alloc (&objfile->objfile_obstack, -+ sizeof (*TYPE_FIELDS (type)) -+ * TYPE_NFIELDS (type)); -+ memset (TYPE_FIELDS (type), 0, sizeof (*TYPE_FIELDS (type)) -+ * TYPE_NFIELDS (type)); -+ -+ field = TYPE_FIELDS (type); -+ child_die = die->child; -+ while (child_die && child_die->tag) -+ { -+ /* Create the symbol in the DW_TAG_common_block block in the current -+ symbol scope. */ - sym = new_symbol (child_die, NULL, cu); -+ -+ /* Undocumented in DWARF3, when it can be present? */ - attr = dwarf2_attr (child_die, DW_AT_data_member_location, cu); - if (attr) - { -@@ -5461,8 +5827,25 @@ read_common_block (struct die_info *die, struct dwarf2_cu *cu) - SYMBOL_VALUE_ADDRESS (sym) = base + byte_offset; - add_symbol_to_list (sym, &global_symbols); - } -+ -+ if (SYMBOL_CLASS (sym) == LOC_STATIC) -+ SET_FIELD_PHYSADDR (*field, SYMBOL_VALUE_ADDRESS (sym)); -+ else -+ SET_FIELD_PHYSNAME (*field, SYMBOL_LINKAGE_NAME (sym)); -+ FIELD_TYPE (*field) = SYMBOL_TYPE (sym); -+ FIELD_NAME (*field) = SYMBOL_NATURAL_NAME (sym); -+ field++; - child_die = sibling_die (child_die); - } ++static void ++dw2_dump (struct objfile *objfile) ++{ ++ /* Nothing worth printing. */ ++} + -+ /* TYPE_LENGTH (type) is left 0 - it is only a virtual structure even -+ with no consecutive address space. */ ++static void ++dw2_relocate (struct objfile *objfile, struct section_offsets *new_offsets, ++ struct section_offsets *delta) ++{ ++ /* There's nothing to relocate here. */ ++} + -+ sym = new_symbol (die, type, cu); -+ /* SYMBOL_VALUE_ADDRESS never gets used as all its fields are static. */ -+ SYMBOL_VALUE_ADDRESS (sym) = base; ++static void ++dw2_expand_symtabs_for_function (struct objfile *objfile, ++ const char *func_name) ++{ ++ dw2_do_expand_symtabs_matching (objfile, func_name); ++} + -+ set_die_type (die, type, cu); - } - } - -@@ -5530,7 +5913,7 @@ read_namespace (struct die_info *die, struct dwarf2_cu *cu) - if (is_anonymous) - { - const char *previous_prefix = determine_prefix (die, cu); -- cp_add_using_directive (previous_prefix, TYPE_NAME (type)); -+ cp_add_using_directive (previous_prefix, TYPE_NAME (type), "", "", dwarf2_read_decl_line(die, cu)); - } - } - -@@ -5546,20 +5929,155 @@ read_namespace (struct die_info *die, struct dwarf2_cu *cu) - } - } - --/* Read a Fortran module. */ -+/* Read a Fortran module as global symbol which can be later looked up by -+ f_lookup_symbol_nonlocal. */ - - static void - read_module (struct die_info *die, struct dwarf2_cu *cu) - { -- struct die_info *child_die = die->child; -+ struct type *type; ++static void ++dw2_expand_all_symtabs (struct objfile *objfile) ++{ ++ int i; + -+ type = read_module_type (die, cu); ++ dw2_setup (objfile); ++ for (i = 0; i < dwarf2_per_objfile->n_comp_units; ++i) ++ { ++ struct dwarf2_per_cu_data *cu = dwarf2_per_objfile->all_comp_units[i]; + -+ if (type) -+ new_symbol (die, type, cu); ++ dw2_instantiate_symtab (objfile, cu); ++ } +} + -+/* Read a Fortran module as type. -+ -+ Modules present only as declarations - being used only for DW_AT_import of -+ DW_TAG_imported_module - are ignored here. They are read in only in form of -+ the module name by read_fortran_imported_module. */ -+ -+static struct type * -+read_module_type (struct die_info *die, struct dwarf2_cu *cu) ++static void ++dw2_expand_symtabs_with_filename (struct objfile *objfile, ++ const char *filename) +{ -+ struct objfile *objfile = cu->objfile; -+ struct die_info *child_die; -+ struct type *type; -+ char *module_name; -+ struct context_stack *new; -+ struct pending *save_file_symbols; -+ struct pending *save_global_symbols; -+ struct pending **save_list_in_scope; -+ -+ if (die_is_declaration (die, cu)) -+ return NULL; -+ -+ module_name = dwarf2_name (die, cu); -+ if (!module_name) -+ complaint (&symfile_complaints, _("DW_TAG_module has no name, offset 0x%x"), -+ die->offset); -+ type = init_type (TYPE_CODE_MODULE, 0, 0, module_name, objfile); ++ int i; + -+ /* Create a context for reading the module variables. */ - -- /* FIXME: Support the separate Fortran module namespaces. */ -+ new = push_context (0, 0); - -+ save_file_symbols = file_symbols; -+ file_symbols = NULL; -+ save_global_symbols = global_symbols; -+ global_symbols = NULL; -+ save_list_in_scope = cu->list_in_scope; ++ dw2_setup (objfile); ++ for (i = 0; i < dwarf2_per_objfile->n_comp_units; ++i) ++ { ++ int j; ++ struct dwarf2_per_cu_data *cu = dwarf2_per_objfile->all_comp_units[i]; + -+ /* Process the child DIEs. */ ++ if (cu->v.quick->symtab) ++ continue; + -+ child_die = die->child; - while (child_die && child_die->tag) - { -+ /* Any DW_TAG_subprogram will reset LIST_IN_SCOPE to LOCAL_SYMBOLS. */ -+ cu->list_in_scope = &global_symbols; ++ dw2_require_line_header (objfile, cu); ++ if (!cu->v.quick->lines) ++ continue; + - process_die (child_die, cu); - child_die = sibling_die (child_die); - } ++ for (j = 0; j < cu->v.quick->lines->num_file_names; ++j) ++ { ++ const char *this_name = cu->v.quick->file_names[j]; ++ if (strcmp (this_name, filename) == 0) ++ { ++ dw2_instantiate_symtab (objfile, cu); ++ break; ++ } ++ } ++ } ++} + -+ /* Finish this module and restore the context. */ ++static const char * ++dw2_find_symbol_file (struct objfile *objfile, const char *name) ++{ ++ struct dwarf2_per_cu_data *cu; ++ offset_type *vec; + -+ TYPE_MODULE_BLOCK (type) = finish_block (NULL, &global_symbols, -+ new->old_blocks, 0, 0, objfile); ++ dw2_setup (objfile); + -+ if (file_symbols) -+ complaint (&symfile_complaints, _("DW_TAG_module contains static symbols")); -+ if (local_symbols) -+ complaint (&symfile_complaints, _("DW_TAG_module contains local symbols")); -+ if (param_symbols) -+ complaint (&symfile_complaints, _("DW_TAG_module contains function " -+ "parameters")); ++ if (!dwarf2_per_objfile->index_table) ++ return NULL; + -+ file_symbols = save_file_symbols; -+ global_symbols = save_global_symbols; -+ cu->list_in_scope = save_list_in_scope; ++ if (!find_slot_in_mapped_hash (dwarf2_per_objfile->index_table, ++ name, &vec)) ++ return NULL; + -+ pop_context (); ++ /* Note that this just looks at the very first one named NAME -- but ++ actually we are looking for a function. find_main_filename ++ should be rewritten so that it doesn't require a custom hook. It ++ could just use the ordinary symbol tables. */ ++ /* vec[0] is the length, which must always be >0. */ ++ cu = dwarf2_per_objfile->all_comp_units[MAYBE_SWAP (vec[1])]; + -+ set_die_type (die, type, cu); ++ dw2_require_line_header (objfile, cu); ++ if (!cu->v.quick->lines) ++ return NULL; + -+ return type; ++ return cu->v.quick->file_names[cu->v.quick->lines->num_file_names - 1]; +} + -+/* Import a Fortran module. Only store the module name for its later lookup by -+ f_lookup_symbol_nonlocal. */ ++static void ++dw2_map_ada_symtabs (struct objfile *objfile, ++ int (*wild_match) (const char *, int, const char *), ++ int (*is_name_suffix) (const char *), ++ void (*callback) (struct objfile *, ++ struct symtab *, void *), ++ const char *name, int global, ++ domain_enum namespace, int wild, ++ void *data) ++{ ++ /* For now, we don't support Ada, so this function can't be ++ reached. */ ++ internal_error (__FILE__, __LINE__, ++ _("map_ada_symtabs called via index method")); ++} + +static void -+read_fortran_imported_module (struct die_info *die, struct dwarf2_cu *cu) ++dw2_expand_symtabs_matching (struct objfile *objfile, ++ int (*file_matcher) (const char *, void *), ++ int (*name_matcher) (const char *, void *), ++ domain_enum kind, ++ void *data) +{ -+ struct objfile *objfile = cu->objfile; -+ struct attribute *attr; -+ struct die_info *module_die; -+ char *module_name; -+ struct fortran_using *use; ++ int i; ++ offset_type iter; + -+ attr = dwarf2_attr (die, DW_AT_import, cu); -+ if (attr == NULL) ++ dw2_setup (objfile); ++ if (!dwarf2_per_objfile->index_table) + return; + -+ module_die = follow_die_ref (die, attr, &cu); -+ module_name = dwarf2_name (module_die, cu); -+ if (module_name == NULL) ++ for (i = 0; i < dwarf2_per_objfile->n_comp_units; ++i) + { -+ complaint (&symfile_complaints, -+ _("Imported DIE at offset 0x%x has no name"), die->offset); -+ return; -+ } ++ int j; ++ struct dwarf2_per_cu_data *cu = dwarf2_per_objfile->all_comp_units[i]; + -+ /* Fortran does not allow any duplicity between local and any of the imported -+ symbols. Therefore the order of the USE statements is not portant. -+ gfortran prints: -+ Error: Name 'X' at (1) is an ambiguous reference to 'X' from module 'Y' */ -+ -+ use = obstack_alloc (&objfile->objfile_obstack, sizeof (*use) -+ + strlen (module_name)); -+ strcpy (use->module_name, module_name); -+ gdb_assert (cu->language == language_fortran); -+ use->next = cu->language_specific.fortran.use; -+ cu->language_specific.fortran.use = use; -+} ++ cu->v.quick->mark = 0; ++ if (cu->v.quick->symtab) ++ continue; + -+/* Import a single Fortran declaration and possibly rename it. */ ++ dw2_require_line_header (objfile, cu); ++ if (!cu->v.quick->lines) ++ continue; + -+static void -+read_fortran_imported_declaration (struct die_info *die, struct dwarf2_cu *cu) -+{ -+ struct attribute *attr; -+ struct die_info *imported_die; -+ struct symbol *sym; -+ char *rename = dwarf2_name (die, cu); ++ for (j = 0; j < cu->v.quick->lines->num_file_names; ++j) ++ { ++ if (file_matcher (cu->v.quick->file_names[j], data)) ++ { ++ cu->v.quick->mark = 1; ++ break; ++ } ++ } ++ } + -+ attr = dwarf2_attr (die, DW_AT_import, cu); -+ if (attr == NULL) ++ for (iter = 0; ++ iter < dwarf2_per_objfile->index_table->index_table_slots; ++ ++iter) + { -+ complaint (&symfile_complaints, -+ _("Fortran DW_TAG_imported_declaration is missing " -+ "DW_AT_import at offset 0x%x"), die->offset); -+ return; -+ } -+ imported_die = follow_die_ref (die, attr, &cu); ++ offset_type idx = 2 * iter; ++ const char *name; ++ offset_type *vec, vec_len, vec_idx; + -+ sym = new_symbol (imported_die, NULL, cu); ++ if (dwarf2_per_objfile->index_table->index_table[idx] == 0 ++ && dwarf2_per_objfile->index_table->index_table[idx + 1] == 0) ++ continue; + -+ if (sym && rename) -+ (sym)->ginfo.language_specific.cplus_specific.demangled_name = rename; - } - - /* Return the name of the namespace represented by DIE. Set -@@ -5724,29 +6242,113 @@ read_tag_string_type (struct die_info *die, struct dwarf2_cu *cu) - struct gdbarch *gdbarch = get_objfile_arch (objfile); - struct type *type, *range_type, *index_type, *char_type; - struct attribute *attr; -- unsigned int length; -+ int length; ++ name = (dwarf2_per_objfile->index_table->constant_pool ++ + dwarf2_per_objfile->index_table->index_table[idx]); + -+ index_type = objfile_type (objfile)->builtin_int; -+ /* RANGE_TYPE is allocated from OBJFILE, not as a permanent type. */ -+ range_type = alloc_type (objfile, NULL); -+ /* LOW_BOUND and HIGH_BOUND are set for real below. */ -+ range_type = create_range_type (range_type, index_type, 0, -1); ++ if (! (*name_matcher) (name, data)) ++ continue; + -+ /* C/C++ should probably have the low bound 0 but C/C++ does not use -+ DW_TAG_string_type. */ -+ TYPE_LOW_BOUND (range_type) = 1; - - attr = dwarf2_attr (die, DW_AT_string_length, cu); -- if (attr) -- { -- length = DW_UNSND (attr); -+ if (attr && attr_form_is_block (attr)) -+ { -+ /* Security check for a size overflow. */ -+ if (DW_BLOCK (attr)->size + 2 < DW_BLOCK (attr)->size) -+ TYPE_HIGH_BOUND (range_type) = 1; -+ /* Extend the DWARF block by a new DW_OP_deref/DW_OP_deref_size -+ instruction as DW_AT_string_length specifies the length location, not -+ its value. */ -+ else ++ /* The name was matched, now expand corresponding CUs that were ++ marked. */ ++ vec = (offset_type *) (dwarf2_per_objfile->index_table->constant_pool ++ + dwarf2_per_objfile->index_table->index_table[idx + 1]); ++ vec_len = MAYBE_SWAP (vec[0]); ++ for (vec_idx = 0; vec_idx < vec_len; ++vec_idx) + { -+ struct dwarf2_locexpr_baton *length_baton = NULL; -+ struct dwarf_block *blk = DW_BLOCK (attr); ++ struct dwarf2_per_cu_data *cu ++ = dwarf2_per_objfile->all_comp_units[MAYBE_SWAP (vec[vec_idx + 1])]; ++ if (cu->v.quick->mark) ++ dw2_instantiate_symtab (objfile, cu); ++ } ++ } ++} + -+ /* Turn any single DW_OP_reg* into DW_OP_breg*(0) but clearing -+ DW_OP_deref* in such case. */ ++static struct symtab * ++dw2_find_pc_sect_symtab (struct objfile *objfile, ++ struct minimal_symbol *msymbol, ++ CORE_ADDR pc, ++ struct obj_section *section, ++ int warn_if_readin) ++{ ++ struct dwarf2_per_cu_data *data; + -+ if (blk->size == 1 && blk->data[0] >= DW_OP_reg0 -+ && blk->data[0] <= DW_OP_reg31) -+ length_baton = dwarf2_attr_to_locexpr_baton (attr, cu); -+ else if (blk->size > 1 && blk->data[0] == DW_OP_regx) -+ { -+ ULONGEST ulongest; -+ gdb_byte *end; ++ dw2_setup (objfile); + -+ end = read_uleb128 (&blk->data[1], &blk->data[blk->size], -+ &ulongest); -+ if (end == &blk->data[blk->size]) -+ length_baton = dwarf2_attr_to_locexpr_baton (attr, cu); -+ } ++ if (!objfile->psymtabs_addrmap) ++ return NULL; + -+ if (length_baton == NULL) -+ { -+ struct attribute *size_attr; ++ data = addrmap_find (objfile->psymtabs_addrmap, pc); ++ if (!data) ++ return NULL; + -+ length_baton = obstack_alloc (&cu->comp_unit_obstack, -+ sizeof (*length_baton)); -+ length_baton->per_cu = cu->per_cu; -+ length_baton->size = DW_BLOCK (attr)->size + 2; -+ length_baton->data = obstack_alloc (&cu->comp_unit_obstack, -+ length_baton->size); -+ memcpy (length_baton->data, DW_BLOCK (attr)->data, -+ DW_BLOCK (attr)->size); ++ if (warn_if_readin && data->v.quick->symtab) ++ warning (_("(Internal error: pc %s in read in CU, but not in symtab.)\n"), ++ paddress (get_objfile_arch (objfile), pc)); + -+ /* DW_AT_BYTE_SIZE existing together with DW_AT_STRING_LENGTH -+ specifies the size of an integer to fetch. */ -+ size_attr = dwarf2_attr (die, DW_AT_byte_size, cu); -+ if (size_attr) -+ { -+ length_baton->data[DW_BLOCK (attr)->size] = DW_OP_deref_size; -+ length_baton->data[DW_BLOCK (attr)->size + 1] = -+ DW_UNSND (size_attr); -+ if (length_baton->data[DW_BLOCK (attr)->size + 1] -+ != DW_UNSND (size_attr)) -+ complaint (&symfile_complaints, -+ _("DW_AT_string_length's DW_AT_byte_size " -+ "integer exceeds the byte size storage")); -+ } -+ else -+ { -+ length_baton->data[DW_BLOCK (attr)->size] = DW_OP_deref; -+ length_baton->data[DW_BLOCK (attr)->size + 1] = DW_OP_nop; -+ } -+ } ++ return dw2_instantiate_symtab (objfile, data); ++} + -+ TYPE_RANGE_BOUND_SET_DWARF_BLOCK (range_type, 1); -+ TYPE_FIELD_DWARF_BLOCK (range_type, 1) = length_baton; -+ TYPE_DYNAMIC (range_type) = 1; -+ } ++static void ++dw2_map_symbol_names (struct objfile *objfile, ++ void (*fun) (const char *, void *), ++ void *data) ++{ ++ offset_type iter; ++ dw2_setup (objfile); + +- if (info->size > 4 * pagesize && (sectp->flags & SEC_RELOC) == 0) ++ if (!dwarf2_per_objfile->index_table) ++ return; ++ ++ for (iter = 0; ++ iter < dwarf2_per_objfile->index_table->index_table_slots; ++ ++iter) + { +- off_t pg_offset = sectp->filepos & ~(pagesize - 1); +- size_t map_length = info->size + sectp->filepos - pg_offset; +- caddr_t retbuf = bfd_mmap (abfd, 0, map_length, PROT_READ, +- MAP_PRIVATE, pg_offset); ++ offset_type idx = 2 * iter; ++ const char *name; ++ offset_type *vec, vec_len, vec_idx; + +- if (retbuf != MAP_FAILED) +- { +- info->was_mmapped = 1; +- info->buffer = retbuf + (sectp->filepos & (pagesize - 1)) ; +-#if HAVE_POSIX_MADVISE +- posix_madvise (retbuf, map_length, POSIX_MADV_WILLNEED); +-#endif +- return; +- } ++ if (dwarf2_per_objfile->index_table->index_table[idx] == 0 ++ && dwarf2_per_objfile->index_table->index_table[idx + 1] == 0) ++ continue; ++ ++ name = (dwarf2_per_objfile->index_table->constant_pool ++ + dwarf2_per_objfile->index_table->index_table[idx]); ++ ++ (*fun) (name, data); } - else +-#endif ++} + +- /* If we get here, we are a normal, not-compressed section. */ +- info->buffer = buf +- = obstack_alloc (&objfile->objfile_obstack, info->size); ++static void ++dw2_map_symbol_filenames (struct objfile *objfile, ++ void (*fun) (const char *, const char *, void *), ++ void *data) ++{ ++ int i; + +- /* When debugging .o files, we may need to apply relocations; see +- http://sourceware.org/ml/gdb-patches/2002-04/msg00136.html . +- We never compress sections in .o files, so we only need to +- try this when the section is not compressed. */ +- retbuf = symfile_relocate_debug_section (objfile, sectp, buf); +- if (retbuf != NULL) ++ dw2_setup (objfile); ++ for (i = 0; i < dwarf2_per_objfile->n_comp_units; ++i) { -- /* check for the DW_AT_byte_size attribute */ -+ if (attr && attr_form_is_constant (attr)) +- info->buffer = retbuf; +- return; ++ int j; ++ struct dwarf2_per_cu_data *cu = dwarf2_per_objfile->all_comp_units[i]; ++ ++ if (cu->v.quick->symtab) ++ continue; ++ ++ dw2_require_line_header (objfile, cu); ++ if (!cu->v.quick->lines) ++ continue; ++ ++ for (j = 0; j < cu->v.quick->lines->num_file_names; ++j) + { -+ /* We currently do not support a constant address where the location -+ should be read from - attr_form_is_block is expected instead. See -+ DWARF for the DW_AT_STRING_LENGTH vs. DW_AT_BYTE_SIZE difference. -+ */ -+ /* PASSTHRU */ ++ const char *this_full_name = dw2_require_full_path (objfile, cu, j); ++ (*fun) (cu->v.quick->file_names[j], this_full_name, data); + } -+ - attr = dwarf2_attr (die, DW_AT_byte_size, cu); + } ++} + +- if (bfd_seek (abfd, sectp->filepos, SEEK_SET) != 0 +- || bfd_bread (buf, info->size, abfd) != info->size) +- error (_("Dwarf Error: Can't read DWARF data from '%s'"), +- bfd_get_filename (abfd)); ++static int ++dw2_has_symbols (struct objfile *objfile) ++{ ++ return 1; + } + +-/* Fill in SECTP, BUFP and SIZEP with section info, given OBJFILE and +- SECTION_NAME. */ ++const struct quick_symbol_functions dwarf2_gdb_index_functions = ++{ ++ dw2_has_symbols, ++ dw2_find_last_source_symtab, ++ dw2_forget_cached_source_info, ++ dw2_lookup_symtab, ++ dw2_lookup_symbol, ++ dw2_pre_expand_symtabs_matching, ++ dw2_print_stats, ++ dw2_dump, ++ dw2_relocate, ++ dw2_expand_symtabs_for_function, ++ dw2_expand_all_symtabs, ++ dw2_expand_symtabs_with_filename, ++ dw2_find_symbol_file, ++ dw2_map_ada_symtabs, ++ dw2_expand_symtabs_matching, ++ dw2_find_pc_sect_symtab, ++ dw2_map_symbol_names, ++ dw2_map_symbol_filenames ++}; + +-void +-dwarf2_get_section_info (struct objfile *objfile, const char *section_name, +- asection **sectp, gdb_byte **bufp, +- bfd_size_type *sizep) +-{ +- struct dwarf2_per_objfile *data +- = objfile_data (objfile, dwarf2_objfile_data_key); +- struct dwarf2_section_info *info; ++/* Initialize for reading DWARF for this objfile. Return 0 if this ++ file will use psymtabs, or 1 if using the GNU index. */ + +- /* We may see an objfile without any DWARF, in which case we just +- return nothing. */ +- if (data == NULL) ++int ++dwarf2_initialize_objfile (struct objfile *objfile) ++{ ++ /* If we're about to read full symbols, don't bother with the ++ indices. In this case we also don't care if some other debug ++ format is making psymtabs, because they are all about to be ++ expanded anyway. */ ++ if ((objfile->flags & OBJF_READNOW)) + { +- *sectp = NULL; +- *bufp = NULL; +- *sizep = 0; +- return; ++ int i; ++ ++ dwarf2_per_objfile->using_index = 1; ++ create_all_comp_units (objfile); ++ ++ for (i = 0; i < dwarf2_per_objfile->n_comp_units; ++i) ++ { ++ struct dwarf2_per_cu_data *cu = dwarf2_per_objfile->all_comp_units[i]; ++ ++ cu->v.quick = OBSTACK_ZALLOC (&objfile->objfile_obstack, ++ struct dwarf2_per_cu_quick_data); ++ } ++ ++ /* Return 1 so that gdb sees the "quick" functions. However, ++ these functions will be no-ops because we will have expanded ++ all symtabs. */ ++ return 1; + } +- if (section_is_p (section_name, EH_FRAME_SECTION)) +- info = &data->eh_frame; +- else if (section_is_p (section_name, FRAME_SECTION)) +- info = &data->frame; +- else +- gdb_assert (0); + +- if (info->asection != NULL && info->size != 0 && info->buffer == NULL) +- /* We haven't read this section in yet. Do it now. */ +- dwarf2_read_section (objfile, info); ++ if (dwarf2_read_index (objfile)) ++ return 1; + +- *sectp = info->asection; +- *bufp = info->buffer; +- *sizep = info->size; ++ dwarf2_build_psymtabs (objfile); ++ return 0; + } + ++ ++ + /* Build a partial symbol table. */ + + void +@@ -1699,6 +2688,7 @@ create_debug_types_hash_table (struct objfile *objfile) + type_sig->signature = signature; + type_sig->offset = offset; + type_sig->type_offset = type_offset; ++ type_sig->per_cu.objfile = objfile; + + slot = htab_find_slot (types_htab, type_sig, INSERT); + gdb_assert (slot != NULL); +@@ -1897,7 +2887,7 @@ process_psymtab_comp_unit (struct objfile *objfile, + /* Store the function that reads in the rest of the symbol table */ + pst->read_symtab = dwarf2_psymtab_to_symtab; + +- this_cu->psymtab = pst; ++ this_cu->v.psymtab = pst; + + dwarf2_find_base_address (comp_unit_die, &cu); + +@@ -2182,6 +3172,7 @@ create_all_comp_units (struct objfile *objfile) + memset (this_cu, 0, sizeof (*this_cu)); + this_cu->offset = offset; + this_cu->length = length + initial_length_size; ++ this_cu->objfile = objfile; + + if (n_comp_units == n_allocated) + { +@@ -2613,7 +3604,7 @@ add_partial_subprogram (struct partial_die_info *pdi, + addrmap_set_empty (objfile->psymtabs_addrmap, + pdi->lowpc + baseaddr, + pdi->highpc - 1 + baseaddr, +- cu->per_cu->psymtab); ++ cu->per_cu->v.psymtab); + } + if (!pdi->is_declaration) + /* Ignore subprogram DIEs that do not have a name, they are +@@ -2885,7 +3876,6 @@ locate_pdi_sibling (struct partial_die_info *orig_pdi, + static void + dwarf2_psymtab_to_symtab (struct partial_symtab *pst) + { +- /* FIXME: This is barely more than a stub. */ + if (pst != NULL) + { + if (pst->readin) +@@ -2958,7 +3948,9 @@ process_queue (struct objfile *objfile) + may load a new CU, adding it to the end of the queue. */ + for (item = dwarf2_queue; item != NULL; dwarf2_queue = item = next_item) + { +- if (item->per_cu->psymtab && !item->per_cu->psymtab->readin) ++ if (dwarf2_per_objfile->using_index ++ ? !item->per_cu->v.quick->symtab ++ : (item->per_cu->v.psymtab && !item->per_cu->v.psymtab->readin)) + process_full_comp_unit (item->per_cu); + + item->per_cu->queued = 0; +@@ -3035,22 +4027,7 @@ psymtab_to_symtab_1 (struct partial_symtab *pst) + return; + } + +- back_to = make_cleanup (dwarf2_release_queue, NULL); +- +- queue_comp_unit (per_cu, pst->objfile); +- +- if (per_cu->from_debug_types) +- read_signatured_type_at_offset (pst->objfile, per_cu->offset); +- else +- load_full_comp_unit (per_cu, pst->objfile); +- +- process_queue (pst->objfile); +- +- /* Age the cache, releasing compilation units that have not +- been used recently. */ +- age_cached_comp_units (); +- +- do_cleanups (back_to); ++ dw2_do_instantiate_symtab (pst->objfile, per_cu); + } + + /* Load the DIEs associated with PER_CU into memory. */ +@@ -3130,9 +4107,8 @@ load_full_comp_unit (struct dwarf2_per_cu_data *per_cu, struct objfile *objfile) + static void + process_full_comp_unit (struct dwarf2_per_cu_data *per_cu) + { +- struct partial_symtab *pst = per_cu->psymtab; + struct dwarf2_cu *cu = per_cu->cu; +- struct objfile *objfile = pst->objfile; ++ struct objfile *objfile = per_cu->objfile; + CORE_ADDR lowpc, highpc; + struct symtab *symtab; + struct cleanup *back_to; +@@ -3165,8 +4141,15 @@ process_full_comp_unit (struct dwarf2_per_cu_data *per_cu) + { + symtab->language = cu->language; + } +- pst->symtab = symtab; +- pst->readin = 1; ++ ++ if (dwarf2_per_objfile->using_index) ++ per_cu->v.quick->symtab = symtab; ++ else ++ { ++ struct partial_symtab *pst = per_cu->v.psymtab; ++ pst->symtab = symtab; ++ pst->readin = 1; ++ } + + do_cleanups (back_to); + } +@@ -3557,6 +4540,46 @@ free_cu_line_header (void *arg) + } + + static void ++find_file_and_directory (struct die_info *die, struct dwarf2_cu *cu, ++ char **name, char **comp_dir) ++{ ++ struct attribute *attr; ++ ++ *name = NULL; ++ *comp_dir = NULL; ++ ++ /* Find the filename. Do not use dwarf2_name here, since the filename ++ is not a source language identifier. */ ++ attr = dwarf2_attr (die, DW_AT_name, cu); ++ if (attr) ++ { ++ *name = DW_STRING (attr); ++ } ++ ++ attr = dwarf2_attr (die, DW_AT_comp_dir, cu); ++ if (attr) ++ *comp_dir = DW_STRING (attr); ++ else if (*name != NULL && IS_ABSOLUTE_PATH (*name)) ++ { ++ *comp_dir = ldirname (*name); ++ if (*comp_dir != NULL) ++ make_cleanup (xfree, *comp_dir); ++ } ++ if (*comp_dir != NULL) ++ { ++ /* Irix 6.2 native cc prepends .: to the compilation ++ directory, get rid of it. */ ++ char *cp = strchr (*comp_dir, ':'); ++ ++ if (cp && cp != *comp_dir && cp[-1] == '.' && cp[1] == '/') ++ *comp_dir = cp + 1; ++ } ++ ++ if (*name == NULL) ++ *name = ""; ++} ++ ++static void + read_file_scope (struct die_info *die, struct dwarf2_cu *cu) + { + struct objfile *objfile = cu->objfile; +@@ -3582,35 +4605,7 @@ read_file_scope (struct die_info *die, struct dwarf2_cu *cu) + lowpc += baseaddr; + highpc += baseaddr; + +- /* Find the filename. Do not use dwarf2_name here, since the filename +- is not a source language identifier. */ +- attr = dwarf2_attr (die, DW_AT_name, cu); +- if (attr) +- { +- name = DW_STRING (attr); +- } +- +- attr = dwarf2_attr (die, DW_AT_comp_dir, cu); +- if (attr) +- comp_dir = DW_STRING (attr); +- else if (name != NULL && IS_ABSOLUTE_PATH (name)) +- { +- comp_dir = ldirname (name); +- if (comp_dir != NULL) +- make_cleanup (xfree, comp_dir); +- } +- if (comp_dir != NULL) +- { +- /* Irix 6.2 native cc prepends .: to the compilation +- directory, get rid of it. */ +- char *cp = strchr (comp_dir, ':'); +- +- if (cp && cp != comp_dir && cp[-1] == '.' && cp[1] == '/') +- comp_dir = cp + 1; +- } +- +- if (name == NULL) +- name = ""; ++ find_file_and_directory (die, cu, &name, &comp_dir); + + attr = dwarf2_attr (die, DW_AT_language, cu); + if (attr) +@@ -5529,6 +6524,29 @@ process_enumeration_scope (struct die_info *die, struct dwarf2_cu *cu) + new_symbol (die, this_type, cu); + } + ++/* Create a new array dimension referencing its target type TYPE. ++ ++ Multidimensional arrays are internally represented as a stack of ++ singledimensional arrays being referenced by their TYPE_TARGET_TYPE. */ ++ ++static struct type * ++create_single_array_dimension (struct type *type, struct type *range_type, ++ struct die_info *die, struct dwarf2_cu *cu) ++{ ++ type = create_array_type (NULL, type, range_type); ++ ++ /* These generic type attributes need to be fetched by ++ evaluate_subexp_standard 's call of ++ value_subscripted_rvalue only for the innermost array type. */ ++ fetch_die_type_attrs (die, type, cu); ++ ++ /* These generic type attributes are checked for allocated/associated ++ validity while accessing FIELD_LOC_KIND_DWARF_BLOCK. */ ++ fetch_die_type_attrs (die, range_type, cu); ++ ++ return type; ++} ++ + /* Extract all information from a DW_TAG_array_type DIE and put it in + the DIE's type field. For now, this only handles one dimensional + arrays. */ +@@ -5542,7 +6560,7 @@ read_array_type (struct die_info *die, struct dwarf2_cu *cu) + struct type *element_type, *range_type, *index_type; + struct type **range_types = NULL; + struct attribute *attr; +- int ndim = 0; ++ int ndim = 0, i; + struct cleanup *back_to; + char *name; + +@@ -5595,17 +6613,11 @@ read_array_type (struct die_info *die, struct dwarf2_cu *cu) + type = element_type; + + if (read_array_order (die, cu) == DW_ORD_col_major) +- { +- int i = 0; +- +- while (i < ndim) +- type = create_array_type (NULL, type, range_types[i++]); +- } +- else +- { +- while (ndim-- > 0) +- type = create_array_type (NULL, type, range_types[ndim]); +- } ++ for (i = 0; i < ndim; i++) ++ type = create_single_array_dimension (type, range_types[i], die, cu); ++ else /* (read_array_order (die, cu) == DW_ORD_row_major) */ ++ for (i = ndim - 1; i >= 0; i--) ++ type = create_single_array_dimension (type, range_types[i], die, cu); + + /* Understand Dwarf2 support for vector types (like they occur on + the PowerPC w/ AltiVec). Gcc just adds another attribute to the +@@ -6059,29 +7071,114 @@ read_tag_string_type (struct die_info *die, struct dwarf2_cu *cu) + struct gdbarch *gdbarch = get_objfile_arch (objfile); + struct type *type, *range_type, *index_type, *char_type; + struct attribute *attr; +- unsigned int length; ++ int length; ++ ++ index_type = objfile_type (objfile)->builtin_int; ++ /* RANGE_TYPE is allocated from OBJFILE, not as a permanent type. */ ++ range_type = alloc_type (objfile); ++ /* LOW_BOUND and HIGH_BOUND are set for real below. */ ++ range_type = create_range_type (range_type, index_type, 0, -1); ++ ++ /* C/C++ should probably have the low bound 0 but C/C++ does not use ++ DW_TAG_string_type. */ ++ TYPE_LOW_BOUND (range_type) = 1; + + attr = dwarf2_attr (die, DW_AT_string_length, cu); +- if (attr) +- { +- length = DW_UNSND (attr); ++ if (attr && attr_form_is_block (attr)) ++ { ++ /* Security check for a size overflow. */ ++ if (DW_BLOCK (attr)->size + 2 < DW_BLOCK (attr)->size) ++ TYPE_HIGH_BOUND (range_type) = 1; ++ /* Extend the DWARF block by a new DW_OP_deref/DW_OP_deref_size ++ instruction as DW_AT_string_length specifies the length location, not ++ its value. */ ++ else ++ { ++ struct dwarf2_locexpr_baton *length_baton = NULL; ++ struct dwarf_block *blk = DW_BLOCK (attr); ++ ++ /* Turn any single DW_OP_reg* into DW_OP_breg*(0) but clearing ++ DW_OP_deref* in such case. */ ++ ++ if (blk->size == 1 && blk->data[0] >= DW_OP_reg0 ++ && blk->data[0] <= DW_OP_reg31) ++ length_baton = dwarf2_attr_to_locexpr_baton (attr, cu); ++ else if (blk->size > 1 && blk->data[0] == DW_OP_regx) ++ { ++ ULONGEST ulongest; ++ const gdb_byte *end; ++ ++ end = read_uleb128 (&blk->data[1], &blk->data[blk->size], ++ &ulongest); ++ if (end == &blk->data[blk->size]) ++ length_baton = dwarf2_attr_to_locexpr_baton (attr, cu); ++ } ++ ++ if (length_baton == NULL) ++ { ++ struct attribute *size_attr; ++ gdb_byte *data; ++ ++ length_baton = obstack_alloc (&cu->comp_unit_obstack, ++ sizeof (*length_baton)); ++ length_baton->per_cu = cu->per_cu; ++ length_baton->size = DW_BLOCK (attr)->size + 2; ++ data = obstack_alloc (&cu->comp_unit_obstack, ++ length_baton->size); ++ length_baton->data = data; ++ memcpy (data, DW_BLOCK (attr)->data, DW_BLOCK (attr)->size); ++ ++ /* DW_AT_BYTE_SIZE existing together with DW_AT_STRING_LENGTH ++ specifies the size of an integer to fetch. */ ++ size_attr = dwarf2_attr (die, DW_AT_byte_size, cu); ++ if (size_attr) ++ { ++ data[DW_BLOCK (attr)->size] = DW_OP_deref_size; ++ data[DW_BLOCK (attr)->size + 1] = DW_UNSND (size_attr); ++ if (data[DW_BLOCK (attr)->size + 1] != DW_UNSND (size_attr)) ++ complaint (&symfile_complaints, ++ _("DW_AT_string_length's DW_AT_byte_size " ++ "integer exceeds the byte size storage")); ++ } ++ else ++ { ++ data[DW_BLOCK (attr)->size] = DW_OP_deref; ++ data[DW_BLOCK (attr)->size + 1] = DW_OP_nop; ++ } ++ } ++ ++ TYPE_RANGE_DATA (range_type)->high.kind ++ = RANGE_BOUND_KIND_DWARF_BLOCK; ++ TYPE_RANGE_DATA (range_type)->high.u.dwarf_block = length_baton; ++ TYPE_DYNAMIC (range_type) = 1; ++ } + } + else + { +- /* check for the DW_AT_byte_size attribute */ ++ if (attr && attr_form_is_constant (attr)) ++ { ++ /* We currently do not support a constant address where the location ++ should be read from - attr_form_is_block is expected instead. See ++ DWARF for the DW_AT_STRING_LENGTH vs. DW_AT_BYTE_SIZE difference. ++ */ ++ /* PASSTHRU */ ++ } ++ + attr = dwarf2_attr (die, DW_AT_byte_size, cu); - if (attr) - { - length = DW_UNSND (attr); - } + if (attr && attr_form_is_block (attr)) + { -+ TYPE_RANGE_BOUND_SET_DWARF_BLOCK (range_type, 1); -+ TYPE_FIELD_DWARF_BLOCK (range_type, 1) = ++ TYPE_RANGE_DATA (range_type)->high.kind ++ = RANGE_BOUND_KIND_DWARF_BLOCK; ++ TYPE_RANGE_DATA (range_type)->high.u.dwarf_block = + dwarf2_attr_to_locexpr_baton (attr, cu); + TYPE_DYNAMIC (range_type) = 1; + } @@ -6651,35 +3838,40 @@ index 4cce36b..fb0a693 100644 char_type = language_string_char_type (cu->language_defn, gdbarch); type = create_string_type (NULL, char_type, range_type); -@@ -5841,7 +6443,6 @@ static struct type * - read_typedef (struct die_info *die, struct dwarf2_cu *cu) - { - struct objfile *objfile = cu->objfile; -- struct attribute *attr; - const char *name = NULL; - struct type *this_type; - -@@ -5949,8 +6550,7 @@ read_subrange_type (struct die_info *die, struct dwarf2_cu *cu) +@@ -6324,60 +7421,136 @@ read_subrange_type (struct die_info *die, struct dwarf2_cu *cu) struct type *base_type; struct type *range_type; struct attribute *attr; -- int low = 0; -- int high = -1; -+ int low; +- LONGEST low = 0; +- LONGEST high = -1; ++ LONGEST low; char *name; - + LONGEST negative_mask; + base_type = die_type (die, cu); -@@ -5963,42 +6563,89 @@ read_subrange_type (struct die_info *die, struct dwarf2_cu *cu) - 0, NULL, cu->objfile); - } ++ /* Preserve BASE_TYPE's original type, just set its LENGTH. */ ++ check_typedef (base_type); + + /* The die_type call above may have already set the type for this DIE. */ + range_type = get_die_type (die, cu); + if (range_type) + return range_type; - if (cu->language == language_fortran) -- { +- { - /* FORTRAN implies a lower bound of 1, if not given. */ - low = 1; - } + /* LOW_BOUND and HIGH_BOUND are set for real below. */ + range_type = create_range_type (NULL, base_type, 0, -1); ++ ++ negative_mask = ++ (LONGEST) -1 << (TYPE_LENGTH (base_type) * TARGET_CHAR_BIT - 1); ++ ++ /* Exclude language_ada from any TYPE_DYNAMIC constructs below. GDB Ada ++ supports implements the dynamic bounds in a non-DWARF way and the ++ existing DWARF dynamic bounds are invalid, leading to memory access ++ errors. */ - /* FIXME: For variable sized arrays either of these could be - a variable rather than a constant value. We'll allow it, @@ -6687,11 +3879,30 @@ index 4cce36b..fb0a693 100644 attr = dwarf2_attr (die, DW_AT_lower_bound, cu); - if (attr) - low = dwarf2_get_attr_constant_value (attr, 0); -+ if (attr && attr_form_is_block (attr)) ++ if (attr && attr_form_is_block (attr) && cu->language != language_ada) + { -+ TYPE_RANGE_BOUND_SET_DWARF_BLOCK (range_type, 0); -+ TYPE_FIELD_DWARF_BLOCK (range_type, 0) = dwarf2_attr_to_locexpr_baton -+ (attr, cu); ++ TYPE_RANGE_DATA (range_type)->low.kind = RANGE_BOUND_KIND_DWARF_BLOCK; ++ TYPE_RANGE_DATA (range_type)->low.u.dwarf_block = ++ dwarf2_attr_to_locexpr_baton (attr, cu); ++ TYPE_DYNAMIC (range_type) = 1; ++ /* For setting a default if DW_AT_UPPER_BOUND would be missing. */ ++ low = 0; ++ } ++ else if (attr && is_ref_attr (attr) && cu->language != language_ada) ++ { ++ struct die_info *target_die; ++ struct dwarf2_cu *target_cu = cu; ++ struct attribute *target_loc_attr; ++ ++ target_die = follow_die_ref_or_sig (die, attr, &target_cu); ++ gdb_assert (target_cu->objfile == cu->objfile); ++ target_loc_attr = dwarf2_attr (target_die, DW_AT_location, target_cu); ++ ++ TYPE_RANGE_DATA (range_type)->low.kind = RANGE_BOUND_KIND_DWARF_LOCLIST; ++ TYPE_RANGE_DATA (range_type)->low.u.dwarf_loclist.loclist ++ = dwarf2_attr_to_loclist_baton (target_loc_attr, target_cu); ++ TYPE_RANGE_DATA (range_type)->low.u.dwarf_loclist.type ++ = die_type (target_die, target_cu); + TYPE_DYNAMIC (range_type) = 1; + /* For setting a default if DW_AT_UPPER_BOUND would be missing. */ + low = 0; @@ -6714,6 +3925,8 @@ index 4cce36b..fb0a693 100644 + low = 0; + } + } ++ if (!TYPE_UNSIGNED (base_type) && (low & negative_mask)) ++ low |= negative_mask; + TYPE_LOW_BOUND (range_type) = low; + if (low >= 0) + TYPE_UNSIGNED (range_type) = 1; @@ -6721,11 +3934,13 @@ index 4cce36b..fb0a693 100644 attr = dwarf2_attr (die, DW_AT_upper_bound, cu); - if (attr) -- { -- if (attr->form == DW_FORM_block1) ++ if (!attr || (!attr_form_is_block (attr) && !attr_form_is_constant (attr) ++ && !is_ref_attr (attr))) + { +- if (attr->form == DW_FORM_block1 || is_ref_attr (attr)) - { - /* GCC encodes arrays with unspecified or dynamic length -- with a DW_FORM_block1 attribute. +- with a DW_FORM_block1 attribute or a reference attribute. - FIXME: GDB does not yet know how to handle dynamic - arrays properly, treat them as arrays with unspecified - length for now. @@ -6737,8 +3952,8 @@ index 4cce36b..fb0a693 100644 - the lower bound we've computed above. */ - high = low - 1; - } -+ if (!attr || (!attr_form_is_block (attr) && !attr_form_is_constant (attr))) -+ { +- else +- high = dwarf2_get_attr_constant_value (attr, 1); + attr = dwarf2_attr (die, DW_AT_count, cu); + /* It does not hurt but it is needlessly ineffective in check_typedef. */ + if (attr && (attr_form_is_block (attr) || attr_form_is_constant (attr))) @@ -6749,33 +3964,93 @@ index 4cce36b..fb0a693 100644 + /* Pass it now as the regular DW_AT_upper_bound. */ + } + -+ if (attr && attr_form_is_block (attr)) ++ if (attr && attr_form_is_block (attr) && cu->language != language_ada) + { -+ TYPE_RANGE_BOUND_SET_DWARF_BLOCK (range_type, 1); -+ TYPE_FIELD_DWARF_BLOCK (range_type, 1) = dwarf2_attr_to_locexpr_baton -+ (attr, cu); ++ TYPE_RANGE_DATA (range_type)->high.kind = RANGE_BOUND_KIND_DWARF_BLOCK; ++ TYPE_RANGE_DATA (range_type)->high.u.dwarf_block = ++ dwarf2_attr_to_locexpr_baton (attr, cu); + TYPE_DYNAMIC (range_type) = 1; + } -+ else ++ else if (attr && is_ref_attr (attr) && cu->language != language_ada) + { ++ struct die_info *target_die; ++ struct dwarf2_cu *target_cu = cu; ++ struct attribute *target_loc_attr; ++ ++ target_die = follow_die_ref_or_sig (die, attr, &target_cu); ++ gdb_assert (target_cu->objfile == cu->objfile); ++ target_loc_attr = dwarf2_attr (target_die, DW_AT_location, target_cu); ++ ++ TYPE_RANGE_DATA (range_type)->high.kind = RANGE_BOUND_KIND_DWARF_LOCLIST; ++ TYPE_RANGE_DATA (range_type)->high.u.dwarf_loclist.loclist ++ = dwarf2_attr_to_loclist_baton (target_loc_attr, target_cu); ++ TYPE_RANGE_DATA (range_type)->high.u.dwarf_loclist.type ++ = die_type (target_die, target_cu); ++ TYPE_DYNAMIC (range_type) = 1; + } + else + { +- attr = dwarf2_attr (die, DW_AT_count, cu); +- if (attr) ++ LONGEST high; ++ + if (attr && attr_form_is_constant (attr)) -+ TYPE_HIGH_BOUND (range_type) = dwarf2_get_attr_constant_value (attr, 0); - else -- high = dwarf2_get_attr_constant_value (attr, 1); -+ { -+ TYPE_RANGE_UPPER_BOUND_IS_UNDEFINED (range_type) = 1; -+ TYPE_HIGH_BOUND (range_type) = low - 1; -+ } ++ high = dwarf2_get_attr_constant_value (attr, 0); ++ else + { +- int count = dwarf2_get_attr_constant_value (attr, 1); +- high = low + count - 1; ++ TYPE_HIGH_BOUND_UNDEFINED (range_type) = 1; ++ high = low - 1; + } ++ if (!TYPE_UNSIGNED (base_type) && (high & negative_mask)) ++ high |= negative_mask; ++ TYPE_HIGH_BOUND (range_type) = high; } -- range_type = create_range_type (NULL, base_type, low, high); + /* Dwarf-2 specifications explicitly allows to create subrange types +@@ -6419,20 +7592,41 @@ read_subrange_type (struct die_info *die, struct dwarf2_cu *cu) + } + } + +- negative_mask = +- (LONGEST) -1 << (TYPE_LENGTH (base_type) * TARGET_CHAR_BIT - 1); +- if (!TYPE_UNSIGNED (base_type) && (low & negative_mask)) +- low |= negative_mask; +- if (!TYPE_UNSIGNED (base_type) && (high & negative_mask)) +- high |= negative_mask; + /* DW_AT_bit_stride is currently unsupported as we count in bytes. */ + attr = dwarf2_attr (die, DW_AT_byte_stride, cu); -+ if (attr && attr_form_is_block (attr)) ++ if (attr && attr_form_is_block (attr) && cu->language != language_ada) ++ { ++ TYPE_RANGE_DATA (range_type)->byte_stride.kind ++ = RANGE_BOUND_KIND_DWARF_BLOCK; ++ TYPE_RANGE_DATA (range_type)->byte_stride.u.dwarf_block = ++ dwarf2_attr_to_locexpr_baton (attr, cu); ++ TYPE_DYNAMIC (range_type) = 1; ++ } ++ else if (attr && is_ref_attr (attr) && cu->language != language_ada) + { -+ TYPE_RANGE_BOUND_SET_DWARF_BLOCK (range_type, 2); -+ TYPE_FIELD_DWARF_BLOCK (range_type, 2) = dwarf2_attr_to_locexpr_baton -+ (attr, cu); ++ struct die_info *target_die; ++ struct dwarf2_cu *target_cu = cu; ++ struct attribute *target_loc_attr; + +- range_type = create_range_type (NULL, base_type, low, high); ++ target_die = follow_die_ref_or_sig (die, attr, &target_cu); ++ gdb_assert (target_cu->objfile == cu->objfile); ++ target_loc_attr = dwarf2_attr (target_die, DW_AT_location, target_cu); + +- /* Mark arrays with dynamic length at least as an array of unspecified +- length. GDB could check the boundary but before it gets implemented at +- least allow accessing the array elements. */ +- if (attr && attr->form == DW_FORM_block1) +- TYPE_HIGH_BOUND_UNDEFINED (range_type) = 1; ++ TYPE_RANGE_DATA (range_type)->byte_stride.kind ++ = RANGE_BOUND_KIND_DWARF_LOCLIST; ++ TYPE_RANGE_DATA (range_type)->byte_stride.u.dwarf_loclist.loclist ++ = dwarf2_attr_to_loclist_baton (target_loc_attr, target_cu); ++ TYPE_RANGE_DATA (range_type)->byte_stride.u.dwarf_loclist.type ++ = die_type (target_die, target_cu); + TYPE_DYNAMIC (range_type) = 1; + } + else if (attr && attr_form_is_constant (attr)) @@ -6788,35 +4063,7 @@ index 4cce36b..fb0a693 100644 name = dwarf2_name (die, cu); if (name) -@@ -6469,6 +7116,7 @@ load_partial_dies (bfd *abfd, gdb_byte *buffer, gdb_byte *info_ptr, - && abbrev->tag != DW_TAG_lexical_block - && abbrev->tag != DW_TAG_variable - && abbrev->tag != DW_TAG_namespace -+ && abbrev->tag != DW_TAG_module - && abbrev->tag != DW_TAG_member) - { - /* Otherwise we skip to the next sibling, if any. */ -@@ -6689,9 +7337,6 @@ read_partial_die (struct partial_die_info *part_die, - if (part_die->dirname == NULL) - part_die->dirname = DW_STRING (&attr); - break; -- case DW_AT_MIPS_linkage_name: -- part_die->name = DW_STRING (&attr); -- break; - case DW_AT_low_pc: - has_low_pc_attr = 1; - part_die->lowpc = DW_ADDR (&attr); -@@ -6923,7 +7568,8 @@ fixup_partial_die (struct partial_die_info *part_die, - /* If we found a reference attribute and the DIE has no name, try - to find a name in the referred to DIE. */ - -- if (part_die->name == NULL && part_die->has_specification) -+ if (part_die->has_specification -+ && (part_die->name == NULL || !part_die->is_external)) - { - struct partial_die_info *spec_die; - -@@ -8265,10 +8911,12 @@ var_decode_location (struct attribute *attr, struct symbol *sym, +@@ -8712,10 +9906,12 @@ var_decode_location (struct attribute *attr, struct symbol *sym, (i.e. when the value of a register or memory location is referenced, or a thread-local block, etc.). Then again, it might not be worthwhile. I'm assuming that it isn't unless performance @@ -6831,120 +4078,16 @@ index 4cce36b..fb0a693 100644 } /* Given a pointer to a DWARF information entry, figure out if we need -@@ -8290,21 +8938,30 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu) - - baseaddr = ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile)); - -- if (die->tag != DW_TAG_namespace) -- name = dwarf2_linkage_name (die, cu); -- else -- name = TYPE_NAME (type); -- -+ name = dwarf2_name (die, cu); - if (name) - { -+ const char *linkagename; -+ - sym = (struct symbol *) obstack_alloc (&objfile->objfile_obstack, +@@ -8746,6 +9942,8 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu) sizeof (struct symbol)); OBJSTAT (objfile, n_syms++); memset (sym, 0, sizeof (struct symbol)); + /* Some methods are called w/o checking SYMBOL_COMPUTED_OPS validity. */ + SYMBOL_COMPUTED_OPS (sym) = &dwarf2_missing_funcs; -- /* Cache this symbol's name and the name's demangled form (if any). */ + /* Cache this symbol's name and the name's demangled form (if any). */ SYMBOL_LANGUAGE (sym) = cu->language; -- SYMBOL_SET_NAMES (sym, name, strlen (name), objfile); -+ -+ /* Cache this symbol's name and the name's demangled form (if any). */ -+ -+ linkagename = dwarf2_physname (die, cu); -+ SYMBOL_SET_NAMES (sym, linkagename, strlen (linkagename), objfile); -+ if (cu->language == language_fortran) -+ { -+ (sym)->ginfo.language_specific.cplus_specific.demangled_name = -+ SYMBOL_LINKAGE_NAME (sym); -+ SYMBOL_LINKAGE_NAME (sym) = fortran_module_linkage_name (die, cu); -+ } - - /* Default assumptions. - Use the passed type or decode it from the die. */ -@@ -8402,9 +9059,28 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu) - if (attr) - { - var_decode_location (attr, sym, cu); -+ - attr2 = dwarf2_attr (die, DW_AT_external, cu); -+ -+ /* Fortran explicitely imports any global symbols to the local -+ scope by DW_TAG_common_block. */ -+ if (cu->language == language_fortran && die->parent -+ && die->parent->tag == DW_TAG_common_block) -+ attr2 = NULL; -+ - if (attr2 && (DW_UNSND (attr2) != 0)) -- add_symbol_to_list (sym, &global_symbols); -+ { -+ /* Workaround gfortran PR debug/40040 - it uses -+ DW_AT_location for variables in -fPIC libraries which may -+ get overriden by other libraries/executable and get -+ a different address. Resolve it by .dynsym instead. */ -+ -+ if (cu->language == language_fortran && die->parent -+ && die->parent->tag == DW_TAG_module) -+ SYMBOL_CLASS (sym) = LOC_UNRESOLVED; -+ -+ add_symbol_to_list (sym, &global_symbols); -+ } - else - add_symbol_to_list (sym, cu->list_in_scope); - } -@@ -8534,7 +9210,7 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu) - add_symbol_to_list (sym, cu->list_in_scope); - break; - case DW_TAG_enumerator: -- SYMBOL_LINKAGE_NAME (sym) = (char *) dwarf2_full_name (die, cu); -+ SYMBOL_LINKAGE_NAME (sym) = (char *) dwarf2_name (die, cu); - attr = dwarf2_attr (die, DW_AT_const_value, cu); - if (attr) - { -@@ -8558,6 +9234,16 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu) - SYMBOL_CLASS (sym) = LOC_TYPEDEF; - add_symbol_to_list (sym, &global_symbols); - break; -+ case DW_TAG_common_block: -+ SYMBOL_CLASS (sym) = LOC_STATIC; -+ SYMBOL_DOMAIN (sym) = COMMON_BLOCK_DOMAIN; -+ add_symbol_to_list (sym, cu->list_in_scope); -+ break; -+ case DW_TAG_module: -+ SYMBOL_CLASS (sym) = LOC_STATIC; -+ SYMBOL_DOMAIN (sym) = MODULE_DOMAIN; -+ add_symbol_to_list (sym, &global_symbols); -+ break; - default: - /* Not a tag we recognize. Hopefully we aren't processing - trash data, but since we must specifically ignore things -@@ -8571,8 +9257,7 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu) - /* For the benefit of old versions of GCC, check for anonymous - namespaces based on the demangled name. */ - if (!processing_has_namespace_info -- && cu->language == language_cplus -- && dwarf2_attr (die, DW_AT_MIPS_linkage_name, cu) != NULL) -+ && cu->language == language_cplus) - cp_scan_for_anonymous_namespaces (sym); - } - return (sym); -@@ -8823,12 +9508,18 @@ read_type_die (struct die_info *die, struct dwarf2_cu *cu) - case DW_TAG_namespace: - this_type = read_namespace_type (die, cu); - break; -+ case DW_TAG_module: -+ this_type = read_module_type (die, cu); -+ break; - default: - complaint (&symfile_complaints, _("unexpected tag in read_type_die: '%s'"), - dwarf_tag_name (die->tag)); +@@ -9375,6 +10573,9 @@ read_type_die (struct die_info *die, struct dwarf2_cu *cu) break; } @@ -6954,475 +4097,48 @@ index 4cce36b..fb0a693 100644 return this_type; } -@@ -8910,10 +9601,100 @@ determine_prefix (struct die_info *die, struct dwarf2_cu *cu) - So it does not need a prefix. */ - return ""; - default: -- return determine_prefix (parent, cu); -+ return determine_prefix (parent, cu); - } - } - -+/* Determines the prefix for a symbol's physname. Unlike determine_prefix, -+ this method does not simply look at the DIE's immediate parent. -+ It will compute the symbol's physname by scanning through all parent -+ DIEs until it gets to the compilation unit's DIE. */ -+ -+static char * -+physname_prefix (struct die_info *die, struct dwarf2_cu *cu) -+{ -+ long length; -+ struct ui_file *buf; -+ struct die_info *d, *spec_die; -+ struct dwarf2_cu *spec_cu; -+ char *name; -+ -+ /* Construct a stack containing all of the DIE's parents. Caution -+ must be observed for dealing with DW_AT_specification. */ -+ spec_cu = cu; -+ spec_die = die_specification (die, &spec_cu); -+ if (spec_die != NULL) -+ d = spec_die->parent; -+ else -+ d = die->parent; -+ while (d != NULL && d->tag != DW_TAG_compile_unit) -+ { -+ struct attribute *attr; -+ -+ spec_die = die_specification (d, &spec_cu); -+ if (spec_die != NULL) -+ d = spec_die; -+ -+ VEC_quick_push (die_info_p, die_list, d); -+ d = d->parent; -+ } -+ -+ /* Now pop all the elements, printing their names as we go. */ -+ buf = mem_fileopen (); -+ while (!VEC_empty (die_info_p, die_list)) -+ { -+ d = VEC_pop (die_info_p, die_list); -+ physname_prefix_1 (buf, d, cu); -+ -+ if (!VEC_empty (die_info_p, die_list)) -+ { -+ if (cu->language == language_cplus) -+ fputs_unfiltered ("::", buf); -+ else -+ fputs_unfiltered (".", buf); -+ } -+ } -+ -+ name = ui_file_obsavestring (buf, &cu->objfile->objfile_obstack, &length); -+ ui_file_delete (buf); -+ return name; -+} -+ -+static void -+physname_prefix_1 (struct ui_file *buf, struct die_info *die, -+ struct dwarf2_cu *cu) -+{ -+ const char *name = NULL; -+ gdb_assert (buf != NULL); -+ -+ if (die != NULL) -+ { -+ switch (die->tag) -+ { -+ case DW_TAG_namespace: -+ name = dwarf2_name (die, cu); -+ if (name == NULL) -+ name = "(anonymous namespace)"; -+ break; -+ -+ case DW_TAG_class_type: -+ case DW_TAG_structure_type: -+ case DW_TAG_union_type: -+ case DW_TAG_enumeration_type: -+ case DW_TAG_interface_type: -+ case DW_TAG_subprogram: -+ name = dwarf2_name (die, cu); -+ break; -+ -+ default: -+ break; -+ } -+ } -+ -+ if (name != NULL) -+ fputs_unfiltered (name, buf); -+} -+ - /* Return a newly-allocated string formed by concatenating PREFIX and - SUFFIX with appropriate separator. If PREFIX or SUFFIX is NULL or empty, then - simply copy the SUFFIX or PREFIX, respectively. If OBS is non-null, -@@ -8963,17 +9744,111 @@ sibling_die (struct die_info *die) - return die->sibling; - } - --/* Get linkage name of a die, return NULL if not found. */ -+/* Construct a physname for the given DIE in CU. */ - - static char * --dwarf2_linkage_name (struct die_info *die, struct dwarf2_cu *cu) -+dwarf2_physname (struct die_info *die, struct dwarf2_cu *cu) - { - struct attribute *attr; -+ char *name; -+ -+ name = dwarf2_name (die, cu); -+ -+ /* These are the only languages we know how to qualify names in. */ -+ if (cu->language != language_cplus -+ && cu->language != language_java) -+ return name; -+ -+ if (die_needs_namespace (die, cu)) -+ { -+ long length; -+ char *prefix; -+ struct ui_file *buf; -+ -+ prefix = physname_prefix (die, cu); -+ buf = mem_fileopen (); -+ if (*prefix != '\0') -+ { -+ char *prefixed_name = typename_concat (NULL, prefix, name, cu); -+ fputs_unfiltered (prefixed_name, buf); -+ xfree (prefixed_name); -+ } -+ else -+ fputs_unfiltered (name ? name : "", buf); -+ -+ /* For Java and C++ methods, append formal parameter type -+ information. */ -+ if ((cu->language == language_cplus || cu->language == language_java) -+ && die->tag == DW_TAG_subprogram) -+ { -+ struct type *type = read_type_die (die, cu); -+ -+ c_type_print_args (type, buf, 0, cu->language); -+ -+ if (cu->language == language_java) -+ { -+ /* For java, we must append the return type to method names. */ -+ if (die->tag == DW_TAG_subprogram) -+ java_print_type (TYPE_TARGET_TYPE (type), "", buf, 0, 0); -+ } -+ else if (cu->language == language_cplus) -+ { -+ /* c_type_print_args adds argument types, but it does -+ not add any necessary "const". */ -+ if (TYPE_NFIELDS (type) > 0 && TYPE_FIELD_ARTIFICIAL (type, 0) -+ && TYPE_CONST (TYPE_TARGET_TYPE (TYPE_FIELD_TYPE (type, 0)))) -+ fputs_unfiltered (" const", buf); -+ } -+ } -+ -+ name = ui_file_obsavestring (buf, &cu->objfile->objfile_obstack, -+ &length); -+ ui_file_delete (buf); -+ -+ if (cu->language == language_cplus) -+ { -+ char *cname -+ = dwarf2_canonicalize_name (name, cu, -+ &cu->objfile->objfile_obstack); -+ if (cname != NULL) -+ name = cname; -+ } -+ } -+ -+ return name; -+} -+ -+/* Return the fully qualified .symtab name for symbols contained in Fortran -+ modules. Return DWARF2_NAME otherwise. */ -+ -+static char * -+fortran_module_linkage_name (struct die_info *die, struct dwarf2_cu *cu) -+{ -+ char *name; -+ -+ gdb_assert (cu->language == language_fortran); -+ -+ name = dwarf2_name (die, cu); -+ -+ if (name && die->parent && die->parent->tag == DW_TAG_module) -+ { -+ char *module_name = dwarf2_name (die->parent, cu); -+ -+ if (module_name) -+ { -+ char *retval; - -- attr = dwarf2_attr (die, DW_AT_MIPS_linkage_name, cu); -- if (attr && DW_STRING (attr)) -- return DW_STRING (attr); -- return dwarf2_name (die, cu); -+ /* `__modulename_MOD_variablename0'. */ -+ retval = obstack_alloc (&cu->objfile->objfile_obstack, -+ 2 + strlen (module_name) + 5 + strlen (name) -+ + 1); -+ sprintf (retval, "__%s_MOD_%s", module_name, name); -+ -+ return retval; -+ } -+ } -+ -+ return name; - } - - /* Get name of a die, return NULL if not found. */ -@@ -10200,11 +11075,11 @@ dwarf2_get_ref_die_offset (struct attribute *attr) - return 0; - } - --/* Return the constant value held by the given attribute. Return -1 -+/* Return the constant value held by the given attribute. Return DEFAULT_VALUE - if the value held by the attribute is not constant. */ - --static int --dwarf2_get_attr_constant_value (struct attribute *attr, int default_value) -+static CORE_ADDR -+dwarf2_get_attr_constant_value (struct attribute *attr, CORE_ADDR default_value) - { - if (attr->form == DW_FORM_sdata) - return DW_SND (attr); -@@ -11009,8 +11884,6 @@ dwarf_decode_macros (struct line_header *lh, unsigned int offset, - { - gdb_byte *mac_ptr, *mac_end; - struct macro_source_file *current_file = 0; -- enum dwarf_macinfo_record_type macinfo_type; -- int at_commandline; - - if (dwarf2_per_objfile->macinfo.buffer == NULL) - { -@@ -11018,29 +11891,19 @@ dwarf_decode_macros (struct line_header *lh, unsigned int offset, - return; - } - -- /* First pass: Find the name of the base filename. -- This filename is needed in order to process all macros whose definition -- (or undefinition) comes from the command line. These macros are defined -- before the first DW_MACINFO_start_file entry, and yet still need to be -- associated to the base file. -- -- To determine the base file name, we scan the macro definitions until we -- reach the first DW_MACINFO_start_file entry. We then initialize -- CURRENT_FILE accordingly so that any macro definition found before the -- first DW_MACINFO_start_file can still be associated to the base file. */ -- - mac_ptr = dwarf2_per_objfile->macinfo.buffer + offset; - mac_end = dwarf2_per_objfile->macinfo.buffer - + dwarf2_per_objfile->macinfo.size; - -- do -+ for (;;) - { -+ enum dwarf_macinfo_record_type macinfo_type; -+ - /* Do we at least have room for a macinfo type byte? */ - if (mac_ptr >= mac_end) - { -- /* Complaint is printed during the second pass as GDB will probably -- stop the first pass earlier upon finding DW_MACINFO_start_file. */ -- break; -+ dwarf2_macros_too_long_complaint (); -+ return; - } - - macinfo_type = read_1_byte (abfd, mac_ptr); -@@ -11051,92 +11914,7 @@ dwarf_decode_macros (struct line_header *lh, unsigned int offset, - /* A zero macinfo type indicates the end of the macro - information. */ - case 0: -- break; -- -- case DW_MACINFO_define: -- case DW_MACINFO_undef: -- /* Only skip the data by MAC_PTR. */ -- { -- unsigned int bytes_read; -- -- read_unsigned_leb128 (abfd, mac_ptr, &bytes_read); -- mac_ptr += bytes_read; -- read_string (abfd, mac_ptr, &bytes_read); -- mac_ptr += bytes_read; -- } -- break; -- -- case DW_MACINFO_start_file: -- { -- unsigned int bytes_read; -- int line, file; -- -- line = read_unsigned_leb128 (abfd, mac_ptr, &bytes_read); -- mac_ptr += bytes_read; -- file = read_unsigned_leb128 (abfd, mac_ptr, &bytes_read); -- mac_ptr += bytes_read; -- -- current_file = macro_start_file (file, line, current_file, comp_dir, -- lh, cu->objfile); -- } -- break; -- -- case DW_MACINFO_end_file: -- /* No data to skip by MAC_PTR. */ -- break; -- -- case DW_MACINFO_vendor_ext: -- /* Only skip the data by MAC_PTR. */ -- { -- unsigned int bytes_read; -- -- read_unsigned_leb128 (abfd, mac_ptr, &bytes_read); -- mac_ptr += bytes_read; -- read_string (abfd, mac_ptr, &bytes_read); -- mac_ptr += bytes_read; -- } -- break; -- -- default: -- break; -- } -- } while (macinfo_type != 0 && current_file == NULL); -- -- /* Second pass: Process all entries. -- -- Use the AT_COMMAND_LINE flag to determine whether we are still processing -- command-line macro definitions/undefinitions. This flag is unset when we -- reach the first DW_MACINFO_start_file entry. */ -- -- mac_ptr = dwarf2_per_objfile->macinfo.buffer + offset; -- -- /* Determines if GDB is still before first DW_MACINFO_start_file. If true -- GDB is still reading the definitions from command line. First -- DW_MACINFO_start_file will need to be ignored as it was already executed -- to create CURRENT_FILE for the main source holding also the command line -- definitions. On first met DW_MACINFO_start_file this flag is reset to -- normally execute all the remaining DW_MACINFO_start_file macinfos. */ -- -- at_commandline = 1; -- -- do -- { -- /* Do we at least have room for a macinfo type byte? */ -- if (mac_ptr >= mac_end) -- { -- dwarf2_macros_too_long_complaint (); -- break; -- } -- -- macinfo_type = read_1_byte (abfd, mac_ptr); -- mac_ptr++; -- -- switch (macinfo_type) -- { -- /* A zero macinfo type indicates the end of the macro -- information. */ -- case 0: -- break; -+ return; - - case DW_MACINFO_define: - case DW_MACINFO_undef: -@@ -11151,31 +11929,19 @@ dwarf_decode_macros (struct line_header *lh, unsigned int offset, - mac_ptr += bytes_read; - - if (! current_file) -- { -- /* DWARF violation as no main source is present. */ -- complaint (&symfile_complaints, -- _("debug info with no main source gives macro %s " -- "on line %d: %s"), -- macinfo_type == -- DW_MACINFO_define ? _("definition") : macinfo_type == -- DW_MACINFO_undef ? _("undefinition") : -- "something-or-other", line, body); -- break; -- } -- if ((line == 0 && !at_commandline) || (line != 0 && at_commandline)) - complaint (&symfile_complaints, -- _("debug info gives %s macro %s with %s line %d: %s"), -- at_commandline ? _("command-line") : _("in-file"), -+ _("debug info gives macro %s outside of any file: %s"), - macinfo_type == -- DW_MACINFO_define ? _("definition") : macinfo_type == -- DW_MACINFO_undef ? _("undefinition") : -- "something-or-other", -- line == 0 ? _("zero") : _("non-zero"), line, body); -- -- if (macinfo_type == DW_MACINFO_define) -- parse_macro_definition (current_file, line, body); -- else if (macinfo_type == DW_MACINFO_undef) -- macro_undef (current_file, line, body); -+ DW_MACINFO_define ? "definition" : macinfo_type == -+ DW_MACINFO_undef ? "undefinition" : -+ "something-or-other", body); -+ else -+ { -+ if (macinfo_type == DW_MACINFO_define) -+ parse_macro_definition (current_file, line, body); -+ else if (macinfo_type == DW_MACINFO_undef) -+ macro_undef (current_file, line, body); -+ } - } - break; - -@@ -11189,22 +11955,9 @@ dwarf_decode_macros (struct line_header *lh, unsigned int offset, - file = read_unsigned_leb128 (abfd, mac_ptr, &bytes_read); - mac_ptr += bytes_read; - -- if ((line == 0 && !at_commandline) || (line != 0 && at_commandline)) -- complaint (&symfile_complaints, -- _("debug info gives source %d included " -- "from %s at %s line %d"), -- file, at_commandline ? _("command-line") : _("file"), -- line == 0 ? _("zero") : _("non-zero"), line); -- -- if (at_commandline) -- { -- /* This DW_MACINFO_start_file was executed in the pass one. */ -- at_commandline = 0; -- } -- else -- current_file = macro_start_file (file, line, -- current_file, comp_dir, -- lh, cu->objfile); -+ current_file = macro_start_file (file, line, -+ current_file, comp_dir, -+ lh, cu->objfile); - } - break; - -@@ -11258,7 +12011,7 @@ dwarf_decode_macros (struct line_header *lh, unsigned int offset, - } - break; - } -- } while (macinfo_type != 0); -+ } - } - - /* Check if the attribute's form is a DW_FORM_block* -@@ -11318,6 +12071,34 @@ attr_form_is_constant (struct attribute *attr) +@@ -11979,67 +13180,102 @@ attr_form_is_constant (struct attribute *attr) } } +-static void +-dwarf2_symbol_mark_computed (struct attribute *attr, struct symbol *sym, +- struct dwarf2_cu *cu) +/* Convert DW_BLOCK into struct dwarf2_locexpr_baton. ATTR must be a DW_BLOCK + attribute type. */ + +static struct dwarf2_locexpr_baton * +dwarf2_attr_to_locexpr_baton (struct attribute *attr, struct dwarf2_cu *cu) -+{ + { +- if (attr_form_is_section_offset (attr) +- /* ".debug_loc" may not exist at all, or the offset may be outside +- the section. If so, fall through to the complaint in the +- other branch. */ +- && DW_UNSND (attr) < dwarf2_per_objfile->loc.size) +- { +- struct dwarf2_loclist_baton *baton; + struct dwarf2_locexpr_baton *baton; -+ + +- baton = obstack_alloc (&cu->objfile->objfile_obstack, +- sizeof (struct dwarf2_loclist_baton)); +- baton->per_cu = cu->per_cu; +- gdb_assert (baton->per_cu); + gdb_assert (attr_form_is_block (attr)); -+ + +- dwarf2_read_section (dwarf2_per_objfile->objfile, +- &dwarf2_per_objfile->loc); + baton = obstack_alloc (&cu->objfile->objfile_obstack, sizeof (*baton)); + baton->per_cu = cu->per_cu; + gdb_assert (baton->per_cu); -+ + +- /* We don't know how long the location list is, but make sure we +- don't run off the edge of the section. */ +- baton->size = dwarf2_per_objfile->loc.size - DW_UNSND (attr); +- baton->data = dwarf2_per_objfile->loc.buffer + DW_UNSND (attr); +- baton->base_address = cu->base_address; +- if (cu->base_known == 0) +- complaint (&symfile_complaints, +- _("Location list used without specifying the CU base address.")); + /* Note that we're just copying the block's data pointer + here, not the actual data. We're still pointing into the + info_buffer for SYM's objfile; right now we never release @@ -7435,20 +4151,63 @@ index 4cce36b..fb0a693 100644 + return baton; +} + ++static struct dwarf2_loclist_baton * ++dwarf2_attr_to_loclist_baton (struct attribute *attr, struct dwarf2_cu *cu) ++{ ++ struct dwarf2_loclist_baton *baton; ++ ++ /* DW_AT_location of the referenced DIE may be missing if the referenced ++ variable has been optimized out. */ ++ if (!attr) ++ return NULL; ++ ++ dwarf2_read_section (dwarf2_per_objfile->objfile, ++ &dwarf2_per_objfile->loc); ++ ++ if (!(attr_form_is_section_offset (attr) ++ /* ".debug_loc" may not exist at all, or the offset may be outside ++ the section. If so, fall through to the complaint in the ++ other branch. */ ++ && DW_UNSND (attr) < dwarf2_per_objfile->loc.size)) ++ return NULL; ++ ++ baton = obstack_alloc (&cu->objfile->objfile_obstack, ++ sizeof (struct dwarf2_loclist_baton)); ++ baton->per_cu = cu->per_cu; ++ gdb_assert (baton->per_cu); ++ ++ /* We don't know how long the location list is, but make sure we ++ don't run off the edge of the section. */ ++ baton->size = dwarf2_per_objfile->loc.size - DW_UNSND (attr); ++ baton->data = dwarf2_per_objfile->loc.buffer + DW_UNSND (attr); ++ baton->base_address = cu->base_address; ++ if (cu->base_known == 0) ++ complaint (&symfile_complaints, ++ _("Location list used without specifying the CU base address.")); ++ ++ return baton; ++} ++ +/* SYM may get its SYMBOL_CLASS overriden on invalid ATTR content. */ + - static void - dwarf2_symbol_mark_computed (struct attribute *attr, struct symbol *sym, - struct dwarf2_cu *cu) -@@ -11347,35 +12128,25 @@ dwarf2_symbol_mark_computed (struct attribute *attr, struct symbol *sym, ++static void ++dwarf2_symbol_mark_computed (struct attribute *attr, struct symbol *sym, ++ struct dwarf2_cu *cu) ++{ ++ struct dwarf2_loclist_baton *loclist_baton; + ++ loclist_baton = dwarf2_attr_to_loclist_baton (attr, cu); ++ if (loclist_baton) ++ { SYMBOL_COMPUTED_OPS (sym) = &dwarf2_loclist_funcs; - SYMBOL_LOCATION_BATON (sym) = baton; - } +- SYMBOL_LOCATION_BATON (sym) = baton; ++ SYMBOL_LOCATION_BATON (sym) = loclist_baton; ++ } + else if (attr_form_is_block (attr)) + { + SYMBOL_COMPUTED_OPS (sym) = &dwarf2_locexpr_funcs; + SYMBOL_LOCATION_BATON (sym) = dwarf2_attr_to_locexpr_baton (attr, cu); -+ } + } else { - struct dwarf2_locexpr_baton *baton; @@ -7478,12 +4237,11 @@ index 4cce36b..fb0a693 100644 - baton->size = 0; - baton->data = NULL; - } -- -- SYMBOL_COMPUTED_OPS (sym) = &dwarf2_locexpr_funcs; -- SYMBOL_LOCATION_BATON (sym) = baton; + SYMBOL_COMPUTED_OPS (sym) = &dwarf2_missing_funcs; + SYMBOL_LOCATION_BATON (sym) = NULL; -+ + +- SYMBOL_COMPUTED_OPS (sym) = &dwarf2_locexpr_funcs; +- SYMBOL_LOCATION_BATON (sym) = baton; + /* For functions a missing DW_AT_frame_base does not optimize out the + whole function definition, only its frame base resolving. */ + if (attr->name == DW_AT_location) @@ -7491,11 +4249,78 @@ index 4cce36b..fb0a693 100644 } } -@@ -11663,6 +12434,31 @@ offset_and_type_eq (const void *item_lhs, const void *item_rhs) - return ofs_lhs->offset == ofs_rhs->offset; - } +@@ -12050,7 +13286,7 @@ dwarf2_symbol_mark_computed (struct attribute *attr, struct symbol *sym, + struct objfile * + dwarf2_per_cu_objfile (struct dwarf2_per_cu_data *per_cu) + { +- struct objfile *objfile = per_cu->psymtab->objfile; ++ struct objfile *objfile = per_cu->objfile; -+/* Fill in generic attributes applicable for type DIEs. */ + /* Return the master objfile, so that we can report and look up the + correct file containing this variable. */ +@@ -12070,7 +13306,7 @@ dwarf2_per_cu_addr_size (struct dwarf2_per_cu_data *per_cu) + else + { + /* If the CU is not currently read in, we re-read its header. */ +- struct objfile *objfile = per_cu->psymtab->objfile; ++ struct objfile *objfile = per_cu->objfile; + struct dwarf2_per_objfile *per_objfile + = objfile_data (objfile, dwarf2_objfile_data_key); + gdb_byte *info_ptr = per_objfile->info.buffer + per_cu->offset; +@@ -12092,7 +13328,7 @@ dwarf2_per_cu_offset_size (struct dwarf2_per_cu_data *per_cu) + else + { + /* If the CU is not currently read in, we re-read its header. */ +- struct objfile *objfile = per_cu->psymtab->objfile; ++ struct objfile *objfile = per_cu->objfile; + struct dwarf2_per_objfile *per_objfile + = objfile_data (objfile, dwarf2_objfile_data_key); + gdb_byte *info_ptr = per_objfile->info.buffer + per_cu->offset; +@@ -12112,7 +13348,7 @@ dwarf2_per_cu_offset_size (struct dwarf2_per_cu_data *per_cu) + CORE_ADDR + dwarf2_per_cu_text_offset (struct dwarf2_per_cu_data *per_cu) + { +- struct objfile *objfile = per_cu->psymtab->objfile; ++ struct objfile *objfile = per_cu->objfile; + + return ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile)); + } +@@ -12334,6 +13570,30 @@ dwarf2_free_objfile (struct objfile *objfile) + /* Cached DIE trees use xmalloc and the comp_unit_obstack. */ + free_cached_comp_units (NULL); + ++ if (dwarf2_per_objfile->using_index) ++ { ++ int i; ++ ++ for (i = 0; i < dwarf2_per_objfile->n_comp_units; ++i) ++ { ++ int j; ++ struct dwarf2_per_cu_data *cu = dwarf2_per_objfile->all_comp_units[i]; ++ ++ if (!cu->v.quick->lines) ++ continue; ++ ++ for (j = 0; j < cu->v.quick->lines->num_file_names; ++j) ++ { ++ if (cu->v.quick->file_names) ++ xfree ((void *) cu->v.quick->file_names[j]); ++ if (cu->v.quick->full_names) ++ xfree ((void *) cu->v.quick->full_names[j]); ++ } ++ ++ free_line_header (cu->v.quick->lines); ++ } ++ } ++ + /* Everything else should be on the objfile obstack. */ + } + +@@ -12368,6 +13628,31 @@ offset_and_type_eq (const void *item_lhs, const void *item_rhs) + return ofs_lhs->offset == ofs_rhs->offset; + } + ++/* Fill in generic attributes applicable for type DIEs. */ + +static void +fetch_die_type_attrs (struct die_info *die, struct type *type, @@ -7521,1183 +4346,1286 @@ index 4cce36b..fb0a693 100644 +} + /* Set the type associated with DIE to TYPE. Save it in CU's hash - table if necessary. For convenience, return TYPE. */ + table if necessary. For convenience, return TYPE. -@@ -11671,6 +12467,8 @@ set_die_type (struct die_info *die, struct type *type, struct dwarf2_cu *cu) +@@ -12391,6 +13676,8 @@ set_die_type (struct die_info *die, struct type *type, struct dwarf2_cu *cu) { struct dwarf2_offset_and_type **slot, ofs; + fetch_die_type_attrs (die, type, cu); + - if (cu->type_hash == NULL) - { - gdb_assert (cu->per_cu != NULL); -@@ -11813,23 +12611,13 @@ show_dwarf2_cmd (char *args, int from_tty) - cmd_show_list (show_dwarf2_cmdlist, from_tty, ""); - } - --/* If section described by INFO was mmapped, munmap it now. */ -+/* A helper function to destroy a debug section. */ - - static void --munmap_section_buffer (struct dwarf2_section_info *info) -+destroy_section (struct dwarf2_section_info *info) - { -- if (info->was_mmapped) -- { --#ifdef HAVE_MMAP -- intptr_t begin = (intptr_t) info->buffer; -- intptr_t map_begin = begin & ~(pagesize - 1); -- size_t map_length = info->size + begin - map_begin; -- gdb_assert (munmap ((void *) map_begin, map_length) == 0); --#else -- /* Without HAVE_MMAP, we should never be here to begin with. */ -- gdb_assert (0); --#endif -- } -+ if (info->destructor) -+ (*info->destructor) (info); - } - - /* munmap debug sections for OBJFILE, if necessary. */ -@@ -11838,15 +12626,15 @@ static void - dwarf2_per_objfile_free (struct objfile *objfile, void *d) - { - struct dwarf2_per_objfile *data = d; -- munmap_section_buffer (&data->info); -- munmap_section_buffer (&data->abbrev); -- munmap_section_buffer (&data->line); -- munmap_section_buffer (&data->str); -- munmap_section_buffer (&data->macinfo); -- munmap_section_buffer (&data->ranges); -- munmap_section_buffer (&data->loc); -- munmap_section_buffer (&data->frame); -- munmap_section_buffer (&data->eh_frame); -+ destroy_section (&data->info); -+ destroy_section (&data->abbrev); -+ destroy_section (&data->line); -+ destroy_section (&data->str); -+ destroy_section (&data->macinfo); -+ destroy_section (&data->ranges); -+ destroy_section (&data->loc); -+ destroy_section (&data->frame); -+ destroy_section (&data->eh_frame); - } - - void _initialize_dwarf2_read (void); -@@ -11854,6 +12642,7 @@ void _initialize_dwarf2_read (void); - void - _initialize_dwarf2_read (void) - { -+ die_list = VEC_alloc (die_info_p, 32); - dwarf2_objfile_data_key - = register_objfile_data_with_cleanup (NULL, dwarf2_per_objfile_free); - -diff --git a/gdb/elfread.c b/gdb/elfread.c -index 6e79d4a..198bae3 100644 ---- a/gdb/elfread.c -+++ b/gdb/elfread.c -@@ -728,10 +728,18 @@ elf_symfile_read (struct objfile *objfile, int mainline) - str_sect->filepos, - bfd_section_size (abfd, str_sect)); - } + /* For Ada types, make sure that the gnat-specific data is always + initialized (if not already set). There are a few types where + we should not be doing so, because the type-specific area is +@@ -12591,8 +13878,567 @@ dwarf2_per_objfile_free (struct objfile *objfile, void *d) + munmap_section_buffer (&data->types); + munmap_section_buffer (&data->frame); + munmap_section_buffer (&data->eh_frame); ++ munmap_section_buffer (&data->gdb_index); ++} ++ ++ ++ ++/* The contents of the hash table we create when building the string ++ table. */ ++struct strtab_entry ++{ ++ offset_type offset; ++ const char *str; ++}; ++ ++/* Hash function for a strtab_entry. */ ++static hashval_t ++hash_strtab_entry (const void *e) ++{ ++ const struct strtab_entry *entry = e; ++ return mapped_index_string_hash (entry->str); ++} + -+ if (dwarf2_has_info (objfile)) -+ dwarf2_create_quick_addrmap (objfile); ++/* Equality function for a strtab_entry. */ ++static int ++eq_strtab_entry (const void *a, const void *b) ++{ ++ const struct strtab_entry *ea = a; ++ const struct strtab_entry *eb = b; ++ return !strcmp (ea->str, eb->str); ++} ++ ++/* Create a strtab_entry hash table. */ ++static htab_t ++create_strtab (void) ++{ ++ return htab_create_alloc (100, hash_strtab_entry, eq_strtab_entry, ++ xfree, xcalloc, xfree); ++} ++ ++/* Add a string to the constant pool. Return the string's offset in ++ host order. */ ++static offset_type ++add_string (htab_t table, struct obstack *cpool, const char *str) ++{ ++ void **slot; ++ struct strtab_entry entry; ++ struct strtab_entry *result; ++ ++ entry.str = str; ++ slot = htab_find_slot (table, &entry, INSERT); ++ if (*slot) ++ result = *slot; ++ else ++ { ++ result = XNEW (struct strtab_entry); ++ result->offset = obstack_object_size (cpool); ++ result->str = str; ++ obstack_grow_str0 (cpool, str); ++ *slot = result; ++ } ++ return result->offset; ++} ++ ++/* An entry in the symbol table. */ ++struct symtab_index_entry ++{ ++ /* The name of the symbol. */ ++ const char *name; ++ /* The offset of the name in the constant pool. */ ++ offset_type index_offset; ++ /* A sorted vector of the indices of all the CUs that hold an object ++ of this name. */ ++ VEC (offset_type) *cu_indices; ++}; ++ ++/* The symbol table. This is a power-of-2-sized hash table. */ ++struct mapped_symtab ++{ ++ offset_type n_elements; ++ offset_type size; ++ struct symtab_index_entry **data; ++}; ++ ++/* Hash function for a symtab_index_entry. */ ++static hashval_t ++hash_symtab_entry (const void *e) ++{ ++ const struct symtab_index_entry *entry = e; ++ return iterative_hash (VEC_address (offset_type, entry->cu_indices), ++ sizeof (offset_type) * VEC_length (offset_type, ++ entry->cu_indices), ++ 0); +} + ++/* Equality function for a symtab_index_entry. */ ++static int ++eq_symtab_entry (const void *a, const void *b) ++{ ++ const struct symtab_index_entry *ea = a; ++ const struct symtab_index_entry *eb = b; ++ int len = VEC_length (offset_type, ea->cu_indices); ++ if (len != VEC_length (offset_type, eb->cu_indices)) ++ return 0; ++ return !memcmp (VEC_address (offset_type, ea->cu_indices), ++ VEC_address (offset_type, eb->cu_indices), ++ sizeof (offset_type) * len); ++} ++ ++/* Destroy a symtab_index_entry. */ +static void -+read_psyms (struct objfile *objfile) ++delete_symtab_entry (void *p) +{ - if (dwarf2_has_info (objfile)) - { - /* DWARF 2 sections */ -- dwarf2_build_psymtabs (objfile, mainline); -+ dwarf2_build_psymtabs (objfile, 0); - } - - /* FIXME: kettenis/20030504: This still needs to be integrated with -@@ -881,6 +889,7 @@ static struct sym_fns elf_sym_fns = - elf_new_init, /* sym_new_init: init anything gbl to entire symtab */ - elf_symfile_init, /* sym_init: read initial info, setup for sym_read() */ - elf_symfile_read, /* sym_read: read a symbol file into symtab */ -+ read_psyms, /* sym_read_psymbols */ - elf_symfile_finish, /* sym_finish: finished with file, cleanup */ - default_symfile_offsets, /* sym_offsets: Translate ext. to int. relocation */ - elf_symfile_segments, /* sym_segments: Get segment information from -diff --git a/gdb/eval.c b/gdb/eval.c -index 2926465..4c6de78 100644 ---- a/gdb/eval.c -+++ b/gdb/eval.c -@@ -39,8 +39,12 @@ - #include "exceptions.h" - #include "regcache.h" - #include "user-regs.h" -+#include "python/python.h" - #include "valprint.h" -+#include "gdb_obstack.h" -+#include "objfiles.h" - #include "python/python.h" -+#include "dwarf2loc.h" - - #include "gdb_assert.h" - -@@ -651,6 +655,36 @@ ptrmath_type_p (struct type *type) - } ++ struct symtab_index_entry *entry = p; ++ VEC_free (offset_type, entry->cu_indices); ++ xfree (entry); ++} ++ ++/* Create a hash table holding symtab_index_entry objects. */ ++static htab_t ++create_index_table (void) ++{ ++ return htab_create_alloc (100, hash_symtab_entry, eq_symtab_entry, ++ delete_symtab_entry, xcalloc, xfree); ++} ++ ++/* Create a new mapped symtab object. */ ++static struct mapped_symtab * ++create_mapped_symtab (void) ++{ ++ struct mapped_symtab *symtab = XNEW (struct mapped_symtab); ++ symtab->n_elements = 0; ++ symtab->size = 1024; ++ symtab->data = XCNEWVEC (struct symtab_index_entry *, symtab->size); ++ return symtab; ++} ++ ++/* Destroy a mapped_symtab. */ ++static void ++cleanup_mapped_symtab (void *p) ++{ ++ struct mapped_symtab *symtab = p; ++ /* The contents of the array are freed when the other hash table is ++ destroyed. */ ++ xfree (symtab->data); ++ xfree (symtab); ++} ++ ++/* Find a slot in SYMTAB for the symbol NAME. Returns a pointer to ++ the slot. */ ++static struct symtab_index_entry ** ++find_slot (struct mapped_symtab *symtab, const char *name) ++{ ++ offset_type index, step, hash = mapped_index_string_hash (name); ++ ++ index = hash & (symtab->size - 1); ++ step = ((hash * 17) & (symtab->size - 1)) | 1; ++ ++ for (;;) ++ { ++ if (!symtab->data[index] || !strcmp (name, symtab->data[index]->name)) ++ return &symtab->data[index]; ++ index = (index + step) & (symtab->size - 1); ++ } } -+/* Constructs a fake method with the given parameter types. */ ++/* Expand SYMTAB's hash table. */ +static void -+free_param_types (void *arg) ++hash_expand (struct mapped_symtab *symtab) +{ -+ struct type *type = (struct type *) arg; -+ xfree (TYPE_FIELDS (type)); -+ xfree (TYPE_MAIN_TYPE (type)); -+ xfree (type); ++ offset_type old_size = symtab->size; ++ offset_type i; ++ struct symtab_index_entry **old_entries = symtab->data; ++ ++ symtab->size *= 2; ++ symtab->data = XCNEWVEC (struct symtab_index_entry *, symtab->size); ++ ++ for (i = 0; i < old_size; ++i) ++ { ++ if (old_entries[i]) ++ { ++ struct symtab_index_entry **slot = find_slot (symtab, ++ old_entries[i]->name); ++ *slot = old_entries[i]; ++ } ++ } ++ ++ xfree (old_entries); +} + -+static struct type * -+make_params (int num_types, struct type **param_types) ++/* Add an entry to SYMTAB. NAME is the name of the symbol. CU_INDEX ++ is the index of the CU in which the symbol appears. */ ++static void ++add_index_entry (struct mapped_symtab *symtab, const char *name, ++ offset_type cu_index) +{ -+ struct type *type = XZALLOC (struct type); -+ TYPE_MAIN_TYPE (type) = XZALLOC (struct main_type); -+ TYPE_LENGTH (type) = 1; -+ TYPE_CODE (type) = TYPE_CODE_METHOD; -+ TYPE_VPTR_FIELDNO (type) = -1; -+ TYPE_CHAIN (type) = type; -+ TYPE_NFIELDS (type) = num_types; -+ TYPE_FIELDS (type) = (struct field *) -+ TYPE_ZALLOC (type, sizeof (struct field) * num_types); -+ -+ while (num_types-- > 0) -+ TYPE_FIELD_TYPE (type, num_types) = param_types[num_types]; -+ -+ make_cleanup (free_param_types, type); -+ return type; ++ struct symtab_index_entry **slot; ++ ++ ++symtab->n_elements; ++ if (4 * symtab->n_elements / 3 >= symtab->size) ++ hash_expand (symtab); ++ ++ slot = find_slot (symtab, name); ++ if (!*slot) ++ { ++ *slot = XNEW (struct symtab_index_entry); ++ (*slot)->name = name; ++ (*slot)->cu_indices = NULL; ++ } ++ /* Don't push an index twice. Due to how we add entries we only ++ have to check the last one. */ ++ if (VEC_empty (offset_type, (*slot)->cu_indices) ++ || VEC_length (offset_type, (*slot)->cu_indices) != cu_index) ++ VEC_safe_push (offset_type, (*slot)->cu_indices, cu_index); +} + - struct value * - evaluate_subexp_standard (struct type *expect_type, - struct expression *exp, int *pos, -@@ -671,6 +705,7 @@ evaluate_subexp_standard (struct type *expect_type, - long mem_offset; - struct type **arg_types; - int save_pos1; -+ struct cleanup *old_chain; - - pc = (*pos)++; - op = exp->elts[pc].opcode; -@@ -684,7 +719,7 @@ evaluate_subexp_standard (struct type *expect_type, - goto nosideret; - arg1 = value_aggregate_elt (exp->elts[pc + 1].type, - &exp->elts[pc + 3].string, -- 0, noside); -+ expect_type, 0, noside); - if (arg1 == NULL) - error (_("There is no field named %s"), &exp->elts[pc + 3].string); - return arg1; -@@ -1293,7 +1328,6 @@ evaluate_subexp_standard (struct type *expect_type, - argvec = (struct value **) alloca (sizeof (struct value *) * (nargs + 3)); - if (op == STRUCTOP_MEMBER || op == STRUCTOP_MPTR) - { -- nargs++; - /* First, evaluate the structure into arg2 */ - pc2 = (*pos)++; - -@@ -1317,21 +1351,40 @@ evaluate_subexp_standard (struct type *expect_type, - - arg1 = evaluate_subexp (NULL_TYPE, exp, pos, noside); - -- if (TYPE_CODE (check_typedef (value_type (arg1))) -- != TYPE_CODE_METHODPTR) -- error (_("Non-pointer-to-member value used in pointer-to-member " -- "construct")); -- -- if (noside == EVAL_AVOID_SIDE_EFFECTS) -+ type = check_typedef (value_type (arg1)); -+ switch (TYPE_CODE (type)) - { -- struct type *method_type = check_typedef (value_type (arg1)); -- arg1 = value_zero (method_type, not_lval); -+ case TYPE_CODE_METHODPTR: -+ if (noside == EVAL_AVOID_SIDE_EFFECTS) -+ arg1 = value_zero (TYPE_TARGET_TYPE (type), not_lval); -+ else -+ arg1 = cplus_method_ptr_to_value (&arg2, arg1); ++/* Add a vector of indices to the constant pool. */ ++static offset_type ++add_indices_to_cpool (htab_t index_table, struct obstack *cpool, ++ struct symtab_index_entry *entry) ++{ ++ void **slot; + -+ /* Now, say which argument to start evaluating from */ -+ nargs++; -+ tem = 2; -+ argvec[1] = arg2; -+ break; ++ slot = htab_find_slot (index_table, entry, INSERT); ++ if (!*slot) ++ { ++ offset_type len = VEC_length (offset_type, entry->cu_indices); ++ offset_type val = MAYBE_SWAP (len); ++ offset_type iter; ++ int i; + -+ case TYPE_CODE_MEMBERPTR: -+ /* Now, convert these values to an address. */ -+ arg2 = value_cast (lookup_pointer_type (TYPE_DOMAIN_TYPE (type)), -+ arg2); ++ *slot = entry; ++ entry->index_offset = obstack_object_size (cpool); + -+ mem_offset = value_as_long (arg1); ++ obstack_grow (cpool, &val, sizeof (val)); ++ for (i = 0; ++ VEC_iterate (offset_type, entry->cu_indices, i, iter); ++ ++i) ++ { ++ val = MAYBE_SWAP (iter); ++ obstack_grow (cpool, &val, sizeof (val)); ++ } ++ } ++ else ++ { ++ struct symtab_index_entry *old_entry = *slot; ++ entry->index_offset = old_entry->index_offset; ++ entry = old_entry; ++ } ++ return entry->index_offset; ++} + -+ arg1 = value_from_pointer (lookup_pointer_type (TYPE_TARGET_TYPE (type)), -+ value_as_long (arg2) + mem_offset); -+ arg1 = value_ind (arg1); -+ tem = 1; -+ break; ++/* Write the mapped hash table SYMTAB to the obstack OUTPUT, with ++ constant pool entries going into the obstack CPOOL. */ ++static void ++write_hash_table (struct mapped_symtab *symtab, ++ struct obstack *output, struct obstack *cpool) ++{ ++ offset_type i; ++ htab_t index_table; ++ htab_t str_table; + -+ default: -+ error (_("Non-pointer-to-member value used in pointer-to-member " -+ "construct")); - } -- else -- arg1 = cplus_method_ptr_to_value (&arg2, arg1); - -- /* Now, say which argument to start evaluating from */ -- tem = 2; -+ argvec[0] = arg1; - } - else if (op == STRUCTOP_STRUCT || op == STRUCTOP_PTR) - { -@@ -1457,8 +1510,7 @@ evaluate_subexp_standard (struct type *expect_type, - } - else if (op == STRUCTOP_MEMBER || op == STRUCTOP_MPTR) - { -- argvec[1] = arg2; -- argvec[0] = arg1; -+ /* Pointer to member. argvec is already set up. */ - } - else if (op == OP_VAR_VALUE) - { -@@ -1549,7 +1601,10 @@ evaluate_subexp_standard (struct type *expect_type, - - /* First determine the type code we are dealing with. */ - arg1 = evaluate_subexp (NULL_TYPE, exp, pos, noside); -+ old_chain = make_cleanup (null_cleanup, 0); -+ object_address_set (value_raw_address (arg1)); - type = check_typedef (value_type (arg1)); -+ do_cleanups (old_chain); - code = TYPE_CODE (type); - - if (code == TYPE_CODE_PTR) -@@ -1716,6 +1771,37 @@ evaluate_subexp_standard (struct type *expect_type, - error (_("non-pointer-to-member value used in pointer-to-member construct")); - } - -+ case TYPE_INSTANCE: -+ nargs = longest_to_int (exp->elts[pc + 1].longconst); -+ arg_types = (struct type **) alloca (nargs * sizeof (struct type *)); -+ for (ix = 0; ix < nargs; ++ix) -+ arg_types[ix] = exp->elts[pc + 1 + ix + 1].type; ++ index_table = create_index_table (); ++ str_table = create_strtab (); ++ /* We add all the index vectors to the constant pool first, to ++ ensure alignment is ok. */ ++ for (i = 0; i < symtab->size; ++i) ++ { ++ if (symtab->data[i]) ++ add_indices_to_cpool (index_table, cpool, symtab->data[i]); ++ } + -+ expect_type = make_params (nargs, arg_types); -+ *(pos) += 3 + nargs; -+ return evaluate_subexp_standard (expect_type, exp, pos, noside); ++ /* Now write out the hash table. */ ++ for (i = 0; i < symtab->size; ++i) ++ { ++ offset_type str_off, vec_off; + -+ case TYPE_INSTANCE_LOOKUP: -+ { -+ int i; -+ struct symbol *sym; -+ struct type **arg_types; -+ (*pos) += 3; -+ printf ("TYPE_INSTANCE_LOOKUP\n"); -+ arg_types = (struct type **) alloca (TYPE_NFIELDS (expect_type) -+ * sizeof (struct type *)); -+ for (i = 0; i < TYPE_NFIELDS (expect_type); ++i) -+ arg_types[i] = TYPE_FIELD_TYPE (expect_type, i); -+ (void) find_overload_match (arg_types, TYPE_NFIELDS (expect_type), -+ NULL /* no need for name */, -+ 0 /* not method */, -+ 0 /* strict match */, -+ NULL, exp->elts[pc + 1].symbol, NULL, -+ &sym, NULL); -+ i = 0; -+ } -+ break; ++ if (symtab->data[i]) ++ { ++ str_off = add_string (str_table, cpool, symtab->data[i]->name); ++ vec_off = symtab->data[i]->index_offset; ++ } ++ else ++ { ++ /* While 0 is a valid constant pool index, it is not valid ++ to have 0 for both offsets. */ ++ str_off = 0; ++ vec_off = 0; ++ } + - case BINOP_CONCAT: - arg1 = evaluate_subexp_with_coercion (exp, pos, noside); - arg2 = evaluate_subexp_with_coercion (exp, pos, noside); -@@ -1987,13 +2073,19 @@ evaluate_subexp_standard (struct type *expect_type, - { - int subscript_array[MAX_FORTRAN_DIMS]; - int array_size_array[MAX_FORTRAN_DIMS]; -+ int byte_stride_array[MAX_FORTRAN_DIMS]; - int ndimensions = 1, i; - struct type *tmp_type; - int offset_item; /* The array offset where the item lives */ -+ CORE_ADDR offset_byte; /* byte_stride based offset */ -+ unsigned element_size; - - if (nargs > MAX_FORTRAN_DIMS) - error (_("Too many subscripts for F77 (%d Max)"), MAX_FORTRAN_DIMS); - -+ old_chain = make_cleanup (null_cleanup, 0); -+ object_address_set (value_raw_address (arg1)); ++ str_off = MAYBE_SWAP (str_off); ++ vec_off = MAYBE_SWAP (vec_off); + - tmp_type = check_typedef (value_type (arg1)); - ndimensions = calc_f77_array_dims (type); - -@@ -2023,6 +2115,9 @@ evaluate_subexp_standard (struct type *expect_type, - upper = f77_get_upperbound (tmp_type); - lower = f77_get_lowerbound (tmp_type); - -+ byte_stride_array[nargs - i - 1] = -+ TYPE_ARRAY_BYTE_STRIDE_VALUE (tmp_type); ++ obstack_grow (output, &str_off, sizeof (str_off)); ++ obstack_grow (output, &vec_off, sizeof (vec_off)); ++ } + - array_size_array[nargs - i - 1] = upper - lower + 1; - - /* Zero-normalize subscripts so that offsetting will work. */ -@@ -2041,13 +2136,25 @@ evaluate_subexp_standard (struct type *expect_type, - tmp_type = check_typedef (TYPE_TARGET_TYPE (tmp_type)); - } - -+ /* Kept for the f77_get_upperbound / f77_get_lowerbound calls above. */ -+ do_cleanups (old_chain); ++ htab_delete (str_table); ++ htab_delete (index_table); ++} + - /* Now let us calculate the offset for this item */ - -- offset_item = subscript_array[ndimensions - 1]; -+ offset_item = 0; -+ offset_byte = 0; ++/* Write an address entry to ADDR_OBSTACK. The addresses are taken ++ from PST; CU_INDEX is the index of the CU in the vector of all ++ CUs. */ ++static void ++add_address_entry (struct objfile *objfile, ++ struct obstack *addr_obstack, struct partial_symtab *pst, ++ unsigned int cu_index) ++{ ++ offset_type offset; ++ char addr[8]; ++ CORE_ADDR baseaddr; + -+ for (i = ndimensions - 1; i >= 0; --i) -+ { -+ offset_item *= array_size_array[i]; -+ if (byte_stride_array[i] == 0) -+ offset_item += subscript_array[i]; -+ else -+ offset_byte += subscript_array[i] * byte_stride_array[i]; -+ } - -- for (i = ndimensions - 1; i > 0; --i) -- offset_item = -- array_size_array[i - 1] * offset_item + subscript_array[i - 1]; -+ element_size = TYPE_LENGTH (TYPE_TARGET_TYPE (tmp_type)); -+ offset_byte += offset_item * element_size; - - /* Let us now play a dirty trick: we will take arg1 - which is a value node pointing to the topmost level -@@ -2057,7 +2164,7 @@ evaluate_subexp_standard (struct type *expect_type, - returns the correct type value */ - - deprecated_set_value_type (arg1, tmp_type); -- return value_subscripted_rvalue (arg1, offset_item, 0); -+ return value_subscripted_rvalue (arg1, offset_byte); - } ++ baseaddr = ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile)); ++ ++ store_unsigned_integer (addr, 8, BFD_ENDIAN_LITTLE, pst->textlow - baseaddr); ++ obstack_grow (addr_obstack, addr, 8); ++ store_unsigned_integer (addr, 8, BFD_ENDIAN_LITTLE, pst->texthigh - baseaddr); ++ obstack_grow (addr_obstack, addr, 8); ++ offset = MAYBE_SWAP (cu_index); ++ obstack_grow (addr_obstack, &offset, sizeof (offset_type)); ++} ++ ++/* Add a list of partial symbols to SYMTAB. */ ++static void ++write_psymbols (struct mapped_symtab *symtab, ++ struct partial_symbol **psymp, ++ int count, ++ offset_type cu_index) ++{ ++ for (; count-- > 0; ++psymp) ++ { ++ if (SYMBOL_LANGUAGE (*psymp) == language_ada) ++ error (_("Ada is not currently supported by the index")); ++ add_index_entry (symtab, SYMBOL_NATURAL_NAME (*psymp), cu_index); ++ } ++} ++ ++/* Write the contents of an ("unfinished") obstack to FILE. Throw an ++ exception if there is an error. */ ++static void ++write_obstack (FILE *file, struct obstack *obstack) ++{ ++ if (fwrite (obstack_base (obstack), 1, obstack_object_size (obstack), ++ file) ++ != obstack_object_size (obstack)) ++ error (_("couldn't data write to file")); ++} ++ ++/* Unlink a file if the argument is not NULL. */ ++static void ++unlink_if_set (void *p) ++{ ++ char **filename = p; ++ if (*filename) ++ unlink (*filename); ++} ++ ++/* Create an index file for OBJFILE in the directory DIR. */ ++static void ++write_psymtabs_to_index (struct objfile *objfile, const char *dir) ++{ ++ struct cleanup *cleanup; ++ char *filename, *cleanup_filename; ++ struct obstack contents, addr_obstack, constant_pool, symtab_obstack, cu_list; ++ int i; ++ FILE *out_file; ++ struct mapped_symtab *symtab; ++ offset_type val, size_of_contents, total_len; ++ struct stat st; ++ char buf[8]; ++ ++ if (!objfile->psymtabs) ++ return; ++ if (dwarf2_per_objfile->using_index) ++ error (_("Cannot use an index to create the index")); ++ ++ if (stat (objfile->name, &st) < 0) ++ perror_with_name (_("Could not stat")); ++ ++ filename = concat (dir, SLASH_STRING, lbasename (objfile->name), ++ INDEX_SUFFIX, (char *) NULL); ++ cleanup = make_cleanup (xfree, filename); ++ ++ out_file = fopen (filename, "wb"); ++ if (!out_file) ++ error (_("Can't open `%s' for writing"), filename); ++ ++ cleanup_filename = filename; ++ make_cleanup (unlink_if_set, &cleanup_filename); ++ ++ symtab = create_mapped_symtab (); ++ make_cleanup (cleanup_mapped_symtab, symtab); ++ ++ obstack_init (&addr_obstack); ++ make_cleanup_obstack_free (&addr_obstack); ++ ++ obstack_init (&cu_list); ++ make_cleanup_obstack_free (&cu_list); ++ ++ for (i = 0; i < dwarf2_per_objfile->n_comp_units; ++i) ++ { ++ struct dwarf2_per_cu_data *cu = dwarf2_per_objfile->all_comp_units[i]; ++ struct partial_symtab *psymtab = cu->v.psymtab; ++ gdb_byte val[8]; ++ ++ write_psymbols (symtab, ++ objfile->global_psymbols.list + psymtab->globals_offset, ++ psymtab->n_global_syms, i); ++ write_psymbols (symtab, ++ objfile->static_psymbols.list + psymtab->statics_offset, ++ psymtab->n_static_syms, i); ++ ++ add_address_entry (objfile, &addr_obstack, psymtab, i); ++ ++ store_unsigned_integer (val, 8, BFD_ENDIAN_LITTLE, cu->offset); ++ obstack_grow (&cu_list, val, 8); ++ store_unsigned_integer (val, 8, BFD_ENDIAN_LITTLE, cu->length); ++ obstack_grow (&cu_list, val, 8); ++ } ++ ++ obstack_init (&constant_pool); ++ make_cleanup_obstack_free (&constant_pool); ++ obstack_init (&symtab_obstack); ++ make_cleanup_obstack_free (&symtab_obstack); ++ write_hash_table (symtab, &symtab_obstack, &constant_pool); ++ ++ obstack_init (&contents); ++ make_cleanup_obstack_free (&contents); ++ size_of_contents = 5 * sizeof (offset_type); ++ total_len = size_of_contents; ++ ++ /* The version number. */ ++ val = MAYBE_SWAP (1); ++ obstack_grow (&contents, &val, sizeof (val)); ++ ++ /* The offset of the CU list from the start of the file. */ ++ val = MAYBE_SWAP (total_len); ++ obstack_grow (&contents, &val, sizeof (val)); ++ total_len += obstack_object_size (&cu_list); ++ ++ /* The offset of the address table from the start of the file. */ ++ val = MAYBE_SWAP (total_len); ++ obstack_grow (&contents, &val, sizeof (val)); ++ total_len += obstack_object_size (&addr_obstack); ++ ++ /* The offset of the symbol table from the start of the file. */ ++ val = MAYBE_SWAP (total_len); ++ obstack_grow (&contents, &val, sizeof (val)); ++ total_len += obstack_object_size (&symtab_obstack); ++ ++ /* The offset of the constant pool from the start of the file. */ ++ val = MAYBE_SWAP (total_len); ++ obstack_grow (&contents, &val, sizeof (val)); ++ total_len += obstack_object_size (&constant_pool); ++ ++ gdb_assert (obstack_object_size (&contents) == size_of_contents); ++ ++ write_obstack (out_file, &contents); ++ write_obstack (out_file, &cu_list); ++ write_obstack (out_file, &addr_obstack); ++ write_obstack (out_file, &symtab_obstack); ++ write_obstack (out_file, &constant_pool); ++ ++ fclose (out_file); ++ ++ /* We want to keep the file, so we set cleanup_filename to NULL ++ here. See unlink_if_set. */ ++ cleanup_filename = NULL; ++ ++ do_cleanups (cleanup); ++} ++ ++/* The mapped index file format is designed to be directly mmap()able ++ on any architecture. In most cases, a datum is represented using a ++ little-endian 32-bit integer value, called an offset_type. Big ++ endian machines must byte-swap the values before using them. ++ Exceptions to this rule are noted. The data is laid out such that ++ alignment is always respected. ++ ++ A mapped index consists of several sections. ++ ++ 1. The file header. This is a sequence of values, of offset_type ++ unless otherwise noted: ++ [0] The version number. Currently 1. ++ [1] The offset, from the start of the file, of the CU list. ++ [2] The offset, from the start of the file, of the address section. ++ [3] The offset, from the start of the file, of the symbol table. ++ [4] The offset, from the start of the file, of the constant pool. ++ ++ 2. The CU list. This is a sequence of pairs of 64-bit ++ little-endian values. The first element in each pair is the offset ++ of a CU in the .debug_info section. The second element in each ++ pair is the length of that CU. References to a CU elsewhere in the ++ map are done using a CU index, which is just the 0-based index into ++ this table. ++ ++ 3. The address section. The address section consists of a sequence ++ of address entries. Each address entry has three elements. ++ [0] The low address. This is a 64-bit little-endian value. ++ [1] The high address. This is a 64-bit little-endian value. ++ [2] The CU index. This is an offset_type value. ++ ++ 4. The symbol table. This is a hash table. The size of the hash ++ table is always a power of 2. The initial hash and the step are ++ currently defined by the `find_slot' function. ++ ++ Each slot in the hash table consists of a pair of offset_type ++ values. The first value is the offset of the symbol's name in the ++ constant pool. The second value is the offset of the CU vector in ++ the constant pool. ++ ++ If both values are 0, then this slot in the hash table is empty. ++ This is ok because while 0 is a valid constant pool index, it ++ cannot be a valid index for both a string and a CU vector. ++ ++ A string in the constant pool is stored as a \0-terminated string, ++ as you'd expect. ++ ++ A CU vector in the constant pool is a sequence of offset_type ++ values. The first value is the number of CU indices in the vector. ++ Each subsequent value is the index of a CU in the CU list. This ++ element in the hash table is used to indicate which CUs define the ++ symbol. ++ ++ 5. The constant pool. This is simply a bunch of bytes. It is ++ organized so that alignment is correct: CU vectors are stored ++ first, followed by strings. */ ++static void ++save_gdb_index_command (char *arg, int from_tty) ++{ ++ struct objfile *objfile; ++ ++ if (!arg || !*arg) ++ error (_("usage: save gdb-index DIRECTORY")); ++ ++ ALL_OBJFILES (objfile) ++ { ++ struct stat st; ++ ++ /* If the objfile does not correspond to an actual file, skip it. */ ++ if (stat (objfile->name, &st) < 0) ++ continue; ++ ++ dwarf2_per_objfile = objfile_data (objfile, dwarf2_objfile_data_key); ++ if (dwarf2_per_objfile) ++ { ++ volatile struct gdb_exception except; ++ ++ TRY_CATCH (except, RETURN_MASK_ERROR) ++ { ++ write_psymtabs_to_index (objfile, arg); ++ } ++ if (except.reason < 0) ++ exception_fprintf (gdb_stderr, except, ++ _("Error while writing index for `%s': "), ++ objfile->name); ++ } ++ } ++} ++ ++ ++ + int dwarf2_always_disassemble; - case BINOP_LOGICAL_AND: -@@ -2598,7 +2705,7 @@ evaluate_subexp_for_address (struct expression *exp, int *pos, - (*pos) += 5 + BYTES_TO_EXP_ELEM (tem + 1); - x = value_aggregate_elt (exp->elts[pc + 1].type, - &exp->elts[pc + 3].string, -- 1, noside); -+ NULL, 1, noside); - if (x == NULL) - error (_("There is no field named %s"), &exp->elts[pc + 3].string); - return x; -@@ -2643,7 +2750,7 @@ evaluate_subexp_with_coercion (struct expression *exp, + static void +@@ -12609,6 +14455,8 @@ void _initialize_dwarf2_read (void); + void + _initialize_dwarf2_read (void) { - enum exp_opcode op; - int pc; -- struct value *val; -+ struct value *val = NULL; - struct symbol *var; - struct type *type; - -@@ -2654,12 +2761,17 @@ evaluate_subexp_with_coercion (struct expression *exp, - { - case OP_VAR_VALUE: - var = exp->elts[pc + 2].symbol; -+ /* address_of_variable will call object_address_set for check_typedef. -+ Call it only if required as it can error-out on VAR in register. */ -+ if (TYPE_DYNAMIC (SYMBOL_TYPE (var))) -+ val = address_of_variable (var, exp->elts[pc + 1].block); - type = check_typedef (SYMBOL_TYPE (var)); - if (TYPE_CODE (type) == TYPE_CODE_ARRAY - && CAST_IS_CONVERSION) - { - (*pos) += 4; -- val = address_of_variable (var, exp->elts[pc + 1].block); -+ if (!val) -+ val = address_of_variable (var, exp->elts[pc + 1].block); - return value_cast (lookup_pointer_type (TYPE_TARGET_TYPE (type)), - val); - } -@@ -2711,9 +2823,13 @@ evaluate_subexp_for_sizeof (struct expression *exp, int *pos) ++ struct cmd_list_element *c; ++ + dwarf2_objfile_data_key + = register_objfile_data_with_cleanup (NULL, dwarf2_per_objfile_free); - case OP_VAR_VALUE: - (*pos) += 4; -- type = check_typedef (SYMBOL_TYPE (exp->elts[pc + 2].symbol)); -- return -- value_from_longest (size_type, (LONGEST) TYPE_LENGTH (type)); -+ /* We do not need to call read_var_value but the object evaluation may -+ need to have executed object_address_set which needs valid -+ SYMBOL_VALUE_ADDRESS of the symbol. Still VALUE returned by -+ read_var_value we left as lazy. */ -+ type = value_type (read_var_value (exp->elts[pc + 2].symbol, -+ deprecated_safe_get_selected_frame ())); -+ return value_from_longest (size_type, (LONGEST) TYPE_LENGTH (type)); +@@ -12656,4 +14504,9 @@ The value is the maximum depth to print."), + NULL, + NULL, + &setdebuglist, &showdebuglist); ++ ++ c = add_cmd ("gdb-index", class_files, save_gdb_index_command, ++ _("Save a .gdb-index file"), ++ &save_cmdlist); ++ set_cmd_completer (c, filename_completer); + } +diff --git a/gdb/elfread.c b/gdb/elfread.c +index 8c00938..a250c58 100644 +--- a/gdb/elfread.c ++++ b/gdb/elfread.c +@@ -37,9 +37,13 @@ + #include "complaints.h" + #include "demangle.h" + #include "psympriv.h" ++#include "gdbtypes.h" - default: - val = evaluate_subexp (NULL_TYPE, exp, pos, EVAL_AVOID_SIDE_EFFECTS); -diff --git a/gdb/expression.h b/gdb/expression.h -index effe1f0..3e083ca 100644 ---- a/gdb/expression.h -+++ b/gdb/expression.h -@@ -88,6 +88,16 @@ enum exp_opcode - when X is a pointer instead of an aggregate. */ - STRUCTOP_MPTR, - -+ /* TYPE_INSTANCE is used when the user specifies a specific -+ type instantiation for overloaded methods/functions. The format -+ is: TYPE_INSTANCE num_types type0 ... typeN num_types TYPE_INSTANCE*/ -+ TYPE_INSTANCE, -+ -+ /* TYPE_INSTANCE_LOOKUP is used when the user specifies a specific -+ type instantiation of a function (not a method). In this case, -+ we must toss the results of the parser and manually do the lookup. */ -+ TYPE_INSTANCE_LOOKUP, -+ - /* end of C++. */ - - /* For Modula-2 integer division DIV */ -@@ -438,4 +448,5 @@ extern char *op_string (enum exp_opcode); - extern void dump_raw_expression (struct expression *, struct ui_file *, char *); - extern void dump_prefix_expression (struct expression *, struct ui_file *); - -+ - #endif /* !defined (EXPRESSION_H) */ -diff --git a/gdb/f-exp.y b/gdb/f-exp.y -index c04c8f4..ddcd460 100644 ---- a/gdb/f-exp.y -+++ b/gdb/f-exp.y -@@ -196,6 +196,7 @@ static int parse_number (char *, int, int, YYSTYPE *); - /* Special type cases, put in to allow the parser to distinguish different - legal basetypes. */ - %token INT_KEYWORD INT_S2_KEYWORD LOGICAL_S1_KEYWORD LOGICAL_S2_KEYWORD -+%token LOGICAL_S8_KEYWORD - %token LOGICAL_KEYWORD REAL_KEYWORD REAL_S8_KEYWORD REAL_S16_KEYWORD - %token COMPLEX_S8_KEYWORD COMPLEX_S16_KEYWORD COMPLEX_S32_KEYWORD - %token BOOL_AND BOOL_OR BOOL_NOT -@@ -606,6 +607,8 @@ typebase /* Implements (approximately): (type-qualifier)* type-specifier */ - { $$ = parse_f_type->builtin_integer_s2; } - | CHARACTER - { $$ = parse_f_type->builtin_character; } -+ | LOGICAL_S8_KEYWORD -+ { $$ = parse_f_type->builtin_logical_s8;} - | LOGICAL_KEYWORD - { $$ = parse_f_type->builtin_logical; } - | LOGICAL_S2_KEYWORD -@@ -858,6 +861,7 @@ static const struct token f77_keywords[] = - { "integer_2", INT_S2_KEYWORD, BINOP_END }, - { "logical_1", LOGICAL_S1_KEYWORD, BINOP_END }, - { "logical_2", LOGICAL_S2_KEYWORD, BINOP_END }, -+ { "logical_8", LOGICAL_S8_KEYWORD, BINOP_END }, - { "complex_8", COMPLEX_S8_KEYWORD, BINOP_END }, - { "integer", INT_KEYWORD, BINOP_END }, - { "logical", LOGICAL_KEYWORD, BINOP_END }, -diff --git a/gdb/f-lang.c b/gdb/f-lang.c -index 19c1316..4cc2a40 100644 ---- a/gdb/f-lang.c -+++ b/gdb/f-lang.c -@@ -31,6 +31,8 @@ - #include "f-lang.h" - #include "valprint.h" - #include "value.h" -+#include "block.h" -+#include "gdb_assert.h" + extern void _initialize_elfread (void); ++/* Forward declaration. */ ++static struct sym_fns elf_sym_fns_gdb_index; ++ + /* The struct elfinfo is available only during ELF symbol table and + psymtab reading. It is destroyed at the completion of psymtab-reading. + It's local to elf_symfile_read. */ +@@ -180,7 +184,8 @@ record_minimal_symbol (const char *name, int name_len, int copy_name, + { + struct gdbarch *gdbarch = get_objfile_arch (objfile); - /* Following is dubious stuff that had been in the xcoff reader. */ -@@ -55,20 +57,6 @@ typedef struct saved_bf_symnum SAVED_BF, *SAVED_BF_PTR; - /* Local functions */ - - extern void _initialize_f_language (void); --#if 0 --static void clear_function_list (void); --static long get_bf_for_fcn (long); --static void clear_bf_list (void); --static void patch_all_commons_by_name (char *, CORE_ADDR, int); --static SAVED_F77_COMMON_PTR find_first_common_named (char *); --static void add_common_entry (struct symbol *); --static void add_common_block (char *, CORE_ADDR, int, char *); --static SAVED_FUNCTION *allocate_saved_function_node (void); --static SAVED_BF_PTR allocate_saved_bf_node (void); --static COMMON_ENTRY_PTR allocate_common_entry_node (void); --static SAVED_F77_COMMON_PTR allocate_saved_f77_common_node (void); --static void patch_common_entries (SAVED_F77_COMMON_PTR, CORE_ADDR, int); --#endif +- if (ms_type == mst_text || ms_type == mst_file_text) ++ if (ms_type == mst_text || ms_type == mst_file_text ++ || ms_type == mst_text_gnu_ifunc) + address = gdbarch_smash_text_address (gdbarch, address); - static void f_printchar (int c, struct type *type, struct ui_file * stream); - static void f_emit_char (int c, struct type *type, -@@ -259,6 +247,7 @@ enum f_primitive_types { - f_primitive_type_logical, - f_primitive_type_logical_s1, - f_primitive_type_logical_s2, -+ f_primitive_type_logical_s8, - f_primitive_type_integer, - f_primitive_type_integer_s2, - f_primitive_type_real, -@@ -289,6 +278,8 @@ f_language_arch_info (struct gdbarch *gdbarch, - = builtin->builtin_logical_s1; - lai->primitive_type_vector [f_primitive_type_logical_s2] - = builtin->builtin_logical_s2; -+ lai->primitive_type_vector [f_primitive_type_logical_s8] -+ = builtin->builtin_logical_s8; - lai->primitive_type_vector [f_primitive_type_real] - = builtin->builtin_real; - lai->primitive_type_vector [f_primitive_type_real_s8] -@@ -306,6 +297,46 @@ f_language_arch_info (struct gdbarch *gdbarch, - lai->bool_type_default = builtin->builtin_logical_s2; + return prim_record_minimal_symbol_full (name, name_len, copy_name, address, +@@ -388,7 +393,10 @@ elf_symtab_read (struct objfile *objfile, int type, + { + if (sym->flags & (BSF_GLOBAL | BSF_WEAK)) + { +- ms_type = mst_text; ++ if (sym->flags & BSF_GNU_INDIRECT_FUNCTION) ++ ms_type = mst_text_gnu_ifunc; ++ else ++ ms_type = mst_text; + } + else if ((sym->name[0] == '.' && sym->name[1] == 'L') + || ((sym->flags & BSF_LOCAL) +@@ -569,6 +577,250 @@ elf_symtab_read (struct objfile *objfile, int type, + } } -+/* Find if NAME is not contained in any of the Fortran modules imported by the -+ Fortran USE statement. ++/* FIXME: Delay it through elf_sym_fns. */ ++ ++static void ++elf_rel_plt_read (struct objfile *objfile, asymbol **dyn_symbol_table) ++{ ++ bfd *obfd = objfile->obfd; ++ const struct elf_backend_data *bed = get_elf_backend_data (obfd); ++ asection *plt, *relplt, *got_plt; ++ unsigned u; ++ int plt_elf_idx; ++ bfd_size_type reloc_count, reloc; ++ char *string_buffer = NULL; ++ size_t string_buffer_size = 0; ++ struct cleanup *back_to; ++ struct gdbarch *gdbarch = objfile->gdbarch; ++ struct type *ptr_type = builtin_type (gdbarch)->builtin_data_ptr; ++ size_t ptr_size = TYPE_LENGTH (ptr_type); ++ ++ if (objfile->separate_debug_objfile_backlink) ++ return; ++ ++ plt = bfd_get_section_by_name (obfd, ".plt"); ++ if (plt == NULL) ++ return; ++ plt_elf_idx = elf_section_data (plt)->this_idx; ++ ++ got_plt = bfd_get_section_by_name (obfd, ".got.plt"); ++ if (got_plt == NULL) ++ return; ++ ++ /* This search algorithm is from _bfd_elf_canonicalize_dynamic_reloc. */ ++ for (relplt = obfd->sections; relplt != NULL; relplt = relplt->next) ++ if (elf_section_data (relplt)->this_hdr.sh_info == plt_elf_idx ++ && (elf_section_data (relplt)->this_hdr.sh_type == SHT_REL ++ || elf_section_data (relplt)->this_hdr.sh_type == SHT_RELA)) ++ break; ++ if (relplt == NULL) ++ return; ++ ++ if (! bed->s->slurp_reloc_table (obfd, relplt, dyn_symbol_table, TRUE)) ++ return; ++ ++ back_to = make_cleanup (free_current_contents, &string_buffer); ++ ++ reloc_count = relplt->size / elf_section_data (relplt)->this_hdr.sh_entsize; ++ for (reloc = 0; reloc < reloc_count; reloc++) ++ { ++ const char *name, *name_got_plt; ++ struct minimal_symbol *msym; ++ CORE_ADDR address; ++ const char *suffix = "@got.plt"; ++ size_t suffix_len = strlen (suffix); ++ size_t name_len; ++ ++ name = bfd_asymbol_name (*relplt->relocation[reloc].sym_ptr_ptr); ++ name_len = strlen (name); ++ address = relplt->relocation[reloc].address; ++ ++ /* Does the pointer reside in the .got.plt section? */ ++ if (!(bfd_get_section_vma (obfd, got_plt) <= address ++ && address < bfd_get_section_vma (obfd, got_plt) ++ + bfd_get_section_size (got_plt))) ++ continue; ++ ++ /* We cannot check if NAME is a reference to mst_text_gnu_ifunc as in ++ OBJFILE the symbol is undefined and the objfile having NAME defined ++ may not yet have been loaded. */ ++ ++ if (string_buffer_size < name_len + suffix_len) ++ { ++ string_buffer_size = 2 * (name_len + suffix_len); ++ string_buffer = xrealloc (string_buffer, string_buffer_size); ++ } ++ memcpy (string_buffer, name, name_len); ++ memcpy (&string_buffer[name_len], suffix, suffix_len); ++ ++ msym = record_minimal_symbol (string_buffer, name_len + suffix_len, 1, ++ address, mst_slot_got_plt, got_plt, ++ objfile); ++ if (msym) ++ MSYMBOL_SIZE (msym) = ptr_size; ++ } + -+ As Fortran has no nested blocks such lookup can be processed from -+ lookup_symbol_nonlocal - when no local blocks could satisfy the lookup. */ ++ do_cleanups (back_to); ++} + -+static struct symbol * -+f_lookup_symbol_nonlocal (const char *name, -+ const struct block *block, -+ const domain_enum domain) ++/* Function does not check for possibly created duplicities in the cache. ++ Check it by resolve_gnu_ifunc_by_cache first. */ ++ ++static struct minimal_symbol * ++gnu_ifunc_record_cache_unchecked (const char *function_name, ++ CORE_ADDR function_address) +{ -+ struct fortran_using *use; ++ struct minimal_symbol *msym, *msym_new; ++ asection *sect; ++ struct objfile *objfile; ++ char *function_name_gnu_ifunc_tgt; + -+ if (!block) ++ msym = lookup_minimal_symbol_by_pc (function_address); ++ if (msym == NULL) + return NULL; ++ if (SYMBOL_VALUE_ADDRESS (msym) != function_address) ++ return NULL; ++ /* minimal symbols have always SYMBOL_OBJ_SECTION non-NULL. */ ++ sect = SYMBOL_OBJ_SECTION (msym)->the_bfd_section; ++ objfile = SYMBOL_OBJ_SECTION (msym)->objfile; ++ ++ /* If .plt jumps back to .plt the symbol is still deferred for later ++ resolution and it has no use for GDB. Besides ".text" this symbol can ++ reside also in ".opd" for ppc64 function descriptor. */ ++ if (strcmp (bfd_get_section_name (objfile->obfd, sect), ".plt") == 0) ++ return NULL; ++ ++ function_name_gnu_ifunc_tgt = alloca (strlen (function_name) ++ + strlen ("@gnu-ifunc-tgt") + 1); ++ sprintf (function_name_gnu_ifunc_tgt, "%s@gnu-ifunc-tgt", function_name); ++ ++ /* Create new alias "@gnu-ifunc-tgt" for MSYM. */ ++ msym_new = record_minimal_symbol (function_name_gnu_ifunc_tgt, ++ strlen (function_name_gnu_ifunc_tgt), 1, ++ SYMBOL_VALUE_ADDRESS (msym), ++ MSYMBOL_TYPE (msym), sect, objfile); ++ /* Should not happen. */ ++ if (msym_new == NULL) ++ return 0; + -+ for (use = BLOCK_FORTRAN_USE (block); use; use = use->next) ++ /* objfile->msymbols array is already allocated on obstack and it cannot be ++ easily extended. Therefore -completion on symbol names will never ++ show the @gnu-ifunc-tgt symbol. Link it at least to the hash table so ++ that resolve_gnu_ifunc_by_cache can find it. */ ++ add_minsym_to_hash_table (msym_new, objfile->msymbol_hash); ++ ++ MSYMBOL_SIZE (msym_new) = MSYMBOL_SIZE (msym); ++ return msym_new; ++} ++ ++/* Check first the cache if it - unlikely - has not been populated since ++ bp_gnu_ifunc_resolver has been created. gnu_ifunc_record_cache_unchecked ++ could create a duplicate symbol otherwise. */ ++ ++void ++gnu_ifunc_record_cache (struct gdbarch *gdbarch, const char *function_name, ++ CORE_ADDR function_address) ++{ ++ struct minimal_symbol *msym; ++ ++ msym = resolve_gnu_ifunc_by_cache (function_name); ++ if (msym == NULL) ++ gnu_ifunc_record_cache_unchecked (function_name, function_address); ++ else if (SYMBOL_VALUE_ADDRESS (msym) != function_address) + { -+ struct symbol *sym; -+ struct type *type; -+ struct symbol *retval; ++ /* This case indicates buggy inferior program. GDB would need to update ++ its MSYM cache symbol for function_address. Anyway FUNCTION_NAME is ++ never normally found in the case as in such case no ++ bp_gnu_ifunc_resolver would be created in the first place. */ + -+ sym = lookup_symbol_global (use->module_name, block, MODULE_DOMAIN); ++ warning (_("gnu-indirect-function \"%s\" has changed its resolved " ++ "function_address from %s to %s; GDB is using the former one"), ++ function_name, paddress (gdbarch, SYMBOL_VALUE_ADDRESS (msym)), ++ paddress (gdbarch, function_address)); ++ } ++} ++ ++static struct minimal_symbol * ++resolve_gnu_ifunc_by_got (const char *function_name) ++{ ++ char *function_name_got_plt; ++ struct objfile *objfile; ++ ++ function_name_got_plt = alloca (strlen (function_name) + strlen ("@got.plt") ++ + 1); ++ sprintf (function_name_got_plt, "%s@got.plt", function_name); ++ ++ ALL_PSPACE_OBJFILES (current_program_space, objfile) ++ { ++ bfd *obfd = objfile->obfd; ++ struct gdbarch *gdbarch = objfile->gdbarch; ++ struct type *ptr_type = builtin_type (gdbarch)->builtin_data_ptr; ++ size_t ptr_size = TYPE_LENGTH (ptr_type); ++ CORE_ADDR pointer_address, function_address; ++ asection *plt; ++ gdb_byte *buf = alloca (ptr_size); ++ struct minimal_symbol *msym; ++ ++ msym = lookup_minimal_symbol (function_name_got_plt, NULL, objfile); ++ if (msym == NULL) ++ continue; ++ if (MSYMBOL_TYPE (msym) != mst_slot_got_plt) ++ continue; ++ pointer_address = SYMBOL_VALUE_ADDRESS (msym); + -+ /* Module name lookup should not fail with correct debug info. */ -+ if (sym == NULL) ++ plt = bfd_get_section_by_name (obfd, ".plt"); ++ if (plt == NULL) + continue; + -+ type = SYMBOL_TYPE (sym); -+ gdb_assert (TYPE_CODE (type) == TYPE_CODE_MODULE); -+ gdb_assert (TYPE_MODULE_BLOCK (type) != NULL); ++ if (MSYMBOL_SIZE (msym) != ptr_size) ++ continue; ++ if (target_read_memory (pointer_address, buf, ptr_size) != 0) ++ continue; ++ function_address = extract_typed_address (buf, ptr_type); + -+ retval = lookup_block_symbol (TYPE_MODULE_BLOCK (type), name, domain); -+ if (retval) -+ return retval; ++ msym = gnu_ifunc_record_cache_unchecked (function_name, function_address); ++ if (msym == NULL) ++ continue; ++ return msym; + } + + return NULL; +} + - /* This is declared in c-lang.h but it is silly to import that file for what - is already just a hack. */ - extern int c_value_print (struct value *, struct ui_file *, -@@ -333,7 +364,7 @@ const struct language_defn f_language_defn = - c_value_print, /* FIXME */ - NULL, /* Language specific skip_trampoline */ - NULL, /* name_of_this */ -- basic_lookup_symbol_nonlocal, /* lookup_symbol_nonlocal */ -+ f_lookup_symbol_nonlocal, /* lookup_symbol_nonlocal */ - basic_lookup_transparent_type,/* lookup_transparent_type */ - NULL, /* Language specific symbol demangler */ - NULL, /* Language specific class_name_from_physname */ -@@ -372,6 +403,10 @@ build_fortran_types (struct gdbarch *gdbarch) - = arch_boolean_type (gdbarch, gdbarch_short_bit (gdbarch), 1, - "logical*2"); - -+ builtin_f_type->builtin_logical_s8 -+ = arch_boolean_type (gdbarch, gdbarch_long_long_bit (gdbarch), 1, -+ "logical*8"); -+ - builtin_f_type->builtin_integer - = arch_integer_type (gdbarch, gdbarch_int_bit (gdbarch), 0, - "integer"); -@@ -418,395 +453,3 @@ _initialize_f_language (void) - - add_language (&f_language_defn); - } -- --#if 0 --static SAVED_BF_PTR --allocate_saved_bf_node (void) --{ -- SAVED_BF_PTR new; -- -- new = (SAVED_BF_PTR) xmalloc (sizeof (SAVED_BF)); -- return (new); --} -- --static SAVED_FUNCTION * --allocate_saved_function_node (void) --{ -- SAVED_FUNCTION *new; -- -- new = (SAVED_FUNCTION *) xmalloc (sizeof (SAVED_FUNCTION)); -- return (new); --} -- --static SAVED_F77_COMMON_PTR --allocate_saved_f77_common_node (void) --{ -- SAVED_F77_COMMON_PTR new; -- -- new = (SAVED_F77_COMMON_PTR) xmalloc (sizeof (SAVED_F77_COMMON)); -- return (new); --} -- --static COMMON_ENTRY_PTR --allocate_common_entry_node (void) --{ -- COMMON_ENTRY_PTR new; -- -- new = (COMMON_ENTRY_PTR) xmalloc (sizeof (COMMON_ENTRY)); -- return (new); --} --#endif -- --SAVED_F77_COMMON_PTR head_common_list = NULL; /* Ptr to 1st saved COMMON */ --SAVED_F77_COMMON_PTR tail_common_list = NULL; /* Ptr to last saved COMMON */ --SAVED_F77_COMMON_PTR current_common = NULL; /* Ptr to current COMMON */ -- --#if 0 --static SAVED_BF_PTR saved_bf_list = NULL; /* Ptr to (.bf,function) -- list */ --static SAVED_BF_PTR saved_bf_list_end = NULL; /* Ptr to above list's end */ --static SAVED_BF_PTR current_head_bf_list = NULL; /* Current head of above list -- */ -- --static SAVED_BF_PTR tmp_bf_ptr; /* Generic temporary for use -- in macros */ -- --/* The following function simply enters a given common block onto -- the global common block chain */ -- --static void --add_common_block (char *name, CORE_ADDR offset, int secnum, char *func_stab) --{ -- SAVED_F77_COMMON_PTR tmp; -- char *c, *local_copy_func_stab; -- -- /* If the COMMON block we are trying to add has a blank -- name (i.e. "#BLNK_COM") then we set it to __BLANK -- because the darn "#" character makes GDB's input -- parser have fits. */ -- -- -- if (strcmp (name, BLANK_COMMON_NAME_ORIGINAL) == 0 -- || strcmp (name, BLANK_COMMON_NAME_MF77) == 0) -- { -- -- xfree (name); -- name = alloca (strlen (BLANK_COMMON_NAME_LOCAL) + 1); -- strcpy (name, BLANK_COMMON_NAME_LOCAL); -- } -- -- tmp = allocate_saved_f77_common_node (); -- -- local_copy_func_stab = xmalloc (strlen (func_stab) + 1); -- strcpy (local_copy_func_stab, func_stab); -- -- tmp->name = xmalloc (strlen (name) + 1); -- -- /* local_copy_func_stab is a stabstring, let us first extract the -- function name from the stab by NULLing out the ':' character. */ -- -- -- c = NULL; -- c = strchr (local_copy_func_stab, ':'); -- -- if (c) -- *c = '\0'; -- else -- error (_("Malformed function STAB found in add_common_block()")); -- -- -- tmp->owning_function = xmalloc (strlen (local_copy_func_stab) + 1); -- -- strcpy (tmp->owning_function, local_copy_func_stab); -- -- strcpy (tmp->name, name); -- tmp->offset = offset; -- tmp->next = NULL; -- tmp->entries = NULL; -- tmp->secnum = secnum; -- -- current_common = tmp; -- -- if (head_common_list == NULL) -- { -- head_common_list = tail_common_list = tmp; -- } -- else -- { -- tail_common_list->next = tmp; -- tail_common_list = tmp; -- } --} --#endif -- --/* The following function simply enters a given common entry onto -- the "current_common" block that has been saved away. */ -- --#if 0 --static void --add_common_entry (struct symbol *entry_sym_ptr) --{ -- COMMON_ENTRY_PTR tmp; -- -- -- -- /* The order of this list is important, since -- we expect the entries to appear in decl. -- order when we later issue "info common" calls */ -- -- tmp = allocate_common_entry_node (); -- -- tmp->next = NULL; -- tmp->symbol = entry_sym_ptr; -- -- if (current_common == NULL) -- error (_("Attempt to add COMMON entry with no block open!")); -- else -- { -- if (current_common->entries == NULL) -- { -- current_common->entries = tmp; -- current_common->end_of_entries = tmp; -- } -- else -- { -- current_common->end_of_entries->next = tmp; -- current_common->end_of_entries = tmp; -- } -- } --} --#endif -- --/* This routine finds the first encountred COMMON block named "name" */ -- --#if 0 --static SAVED_F77_COMMON_PTR --find_first_common_named (char *name) --{ -- -- SAVED_F77_COMMON_PTR tmp; -- -- tmp = head_common_list; -- -- while (tmp != NULL) -- { -- if (strcmp (tmp->name, name) == 0) -- return (tmp); -- else -- tmp = tmp->next; -- } -- return (NULL); --} --#endif -- --/* This routine finds the first encountred COMMON block named "name" -- that belongs to function funcname */ -- --SAVED_F77_COMMON_PTR --find_common_for_function (char *name, char *funcname) --{ -- -- SAVED_F77_COMMON_PTR tmp; -- -- tmp = head_common_list; -- -- while (tmp != NULL) -- { -- if (strcmp (tmp->name, name) == 0 -- && strcmp (tmp->owning_function, funcname) == 0) -- return (tmp); -- else -- tmp = tmp->next; -- } -- return (NULL); --} -- -- --#if 0 -- --/* The following function is called to patch up the offsets -- for the statics contained in the COMMON block named -- "name." */ -- --static void --patch_common_entries (SAVED_F77_COMMON_PTR blk, CORE_ADDR offset, int secnum) --{ -- COMMON_ENTRY_PTR entry; -- -- blk->offset = offset; /* Keep this around for future use. */ -- -- entry = blk->entries; -- -- while (entry != NULL) -- { -- SYMBOL_VALUE (entry->symbol) += offset; -- SYMBOL_SECTION (entry->symbol) = secnum; -- -- entry = entry->next; -- } -- blk->secnum = secnum; --} -- --/* Patch all commons named "name" that need patching.Since COMMON -- blocks occur with relative infrequency, we simply do a linear scan on -- the name. Eventually, the best way to do this will be a -- hashed-lookup. Secnum is the section number for the .bss section -- (which is where common data lives). */ -- --static void --patch_all_commons_by_name (char *name, CORE_ADDR offset, int secnum) --{ -- -- SAVED_F77_COMMON_PTR tmp; -- -- /* For blank common blocks, change the canonical reprsentation -- of a blank name */ -- -- if (strcmp (name, BLANK_COMMON_NAME_ORIGINAL) == 0 -- || strcmp (name, BLANK_COMMON_NAME_MF77) == 0) -- { -- xfree (name); -- name = alloca (strlen (BLANK_COMMON_NAME_LOCAL) + 1); -- strcpy (name, BLANK_COMMON_NAME_LOCAL); -- } -- -- tmp = head_common_list; -- -- while (tmp != NULL) -- { -- if (COMMON_NEEDS_PATCHING (tmp)) -- if (strcmp (tmp->name, name) == 0) -- patch_common_entries (tmp, offset, secnum); -- -- tmp = tmp->next; -- } --} --#endif -- --/* This macro adds the symbol-number for the start of the function -- (the symbol number of the .bf) referenced by symnum_fcn to a -- list. This list, in reality should be a FIFO queue but since -- #line pragmas sometimes cause line ranges to get messed up -- we simply create a linear list. This list can then be searched -- first by a queueing algorithm and upon failure fall back to -- a linear scan. */ -- --#if 0 --#define ADD_BF_SYMNUM(bf_sym,fcn_sym) \ -- \ -- if (saved_bf_list == NULL) \ --{ \ -- tmp_bf_ptr = allocate_saved_bf_node(); \ -- \ -- tmp_bf_ptr->symnum_bf = (bf_sym); \ -- tmp_bf_ptr->symnum_fcn = (fcn_sym); \ -- tmp_bf_ptr->next = NULL; \ -- \ -- current_head_bf_list = saved_bf_list = tmp_bf_ptr; \ -- saved_bf_list_end = tmp_bf_ptr; \ -- } \ --else \ --{ \ -- tmp_bf_ptr = allocate_saved_bf_node(); \ -- \ -- tmp_bf_ptr->symnum_bf = (bf_sym); \ -- tmp_bf_ptr->symnum_fcn = (fcn_sym); \ -- tmp_bf_ptr->next = NULL; \ -- \ -- saved_bf_list_end->next = tmp_bf_ptr; \ -- saved_bf_list_end = tmp_bf_ptr; \ -- } --#endif -- --/* This function frees the entire (.bf,function) list */ -- --#if 0 --static void --clear_bf_list (void) --{ -- -- SAVED_BF_PTR tmp = saved_bf_list; -- SAVED_BF_PTR next = NULL; -- -- while (tmp != NULL) -- { -- next = tmp->next; -- xfree (tmp); -- tmp = next; -- } -- saved_bf_list = NULL; --} --#endif -- --int global_remote_debug; -- --#if 0 -- --static long --get_bf_for_fcn (long the_function) --{ -- SAVED_BF_PTR tmp; -- int nprobes = 0; -- -- /* First use a simple queuing algorithm (i.e. look and see if the -- item at the head of the queue is the one you want) */ -- -- if (saved_bf_list == NULL) -- internal_error (__FILE__, __LINE__, -- _("cannot get .bf node off empty list")); -- -- if (current_head_bf_list != NULL) -- if (current_head_bf_list->symnum_fcn == the_function) -- { -- if (global_remote_debug) -- fprintf_unfiltered (gdb_stderr, "*"); -- -- tmp = current_head_bf_list; -- current_head_bf_list = current_head_bf_list->next; -- return (tmp->symnum_bf); -- } -- -- /* If the above did not work (probably because #line directives were -- used in the sourcefile and they messed up our internal tables) we now do -- the ugly linear scan */ -- -- if (global_remote_debug) -- fprintf_unfiltered (gdb_stderr, "\ndefaulting to linear scan\n"); -- -- nprobes = 0; -- tmp = saved_bf_list; -- while (tmp != NULL) -- { -- nprobes++; -- if (tmp->symnum_fcn == the_function) -- { -- if (global_remote_debug) -- fprintf_unfiltered (gdb_stderr, "Found in %d probes\n", nprobes); -- current_head_bf_list = tmp->next; -- return (tmp->symnum_bf); -- } -- tmp = tmp->next; -- } -- -- return (-1); --} -- --static SAVED_FUNCTION_PTR saved_function_list = NULL; --static SAVED_FUNCTION_PTR saved_function_list_end = NULL; -- --static void --clear_function_list (void) --{ -- SAVED_FUNCTION_PTR tmp = saved_function_list; -- SAVED_FUNCTION_PTR next = NULL; -- -- while (tmp != NULL) -- { -- next = tmp->next; -- xfree (tmp); -- tmp = next; -- } -- -- saved_function_list = NULL; --} --#endif -diff --git a/gdb/f-lang.h b/gdb/f-lang.h -index 711bdba..9d7d92b 100644 ---- a/gdb/f-lang.h -+++ b/gdb/f-lang.h -@@ -28,6 +28,10 @@ extern void f_error (char *); /* Defined in f-exp.y */ - extern void f_print_type (struct type *, char *, struct ui_file *, int, - int); - -+extern const char *f_object_address_data_valid_print_to_stream -+ (struct type *type, struct ui_file *stream); -+extern void f_object_address_data_valid_or_error (struct type *type); -+ - extern int f_val_print (struct type *, const gdb_byte *, int, CORE_ADDR, - struct ui_file *, int, - const struct value_print_options *); -@@ -47,41 +51,8 @@ enum f90_range_type - NONE_BOUND_DEFAULT /* "(low:high)" */ - }; - --struct common_entry -- { -- struct symbol *symbol; /* The symbol node corresponding -- to this component */ -- struct common_entry *next; /* The next component */ -- }; -- --struct saved_f77_common -- { -- char *name; /* Name of COMMON */ -- char *owning_function; /* Name of parent function */ -- int secnum; /* Section # of .bss */ -- CORE_ADDR offset; /* Offset from .bss for -- this block */ -- struct common_entry *entries; /* List of block's components */ -- struct common_entry *end_of_entries; /* ptr. to end of components */ -- struct saved_f77_common *next; /* Next saved COMMON block */ -- }; -- --typedef struct saved_f77_common SAVED_F77_COMMON, *SAVED_F77_COMMON_PTR; -- --typedef struct common_entry COMMON_ENTRY, *COMMON_ENTRY_PTR; -- --extern SAVED_F77_COMMON_PTR head_common_list; /* Ptr to 1st saved COMMON */ --extern SAVED_F77_COMMON_PTR tail_common_list; /* Ptr to last saved COMMON */ --extern SAVED_F77_COMMON_PTR current_common; /* Ptr to current COMMON */ -- --extern SAVED_F77_COMMON_PTR find_common_for_function (char *, char *); -- --#define UNINITIALIZED_SECNUM -1 --#define COMMON_NEEDS_PATCHING(blk) ((blk)->secnum == UNINITIALIZED_SECNUM) -- - #define BLANK_COMMON_NAME_ORIGINAL "#BLNK_COM" /* XLF assigned */ - #define BLANK_COMMON_NAME_MF77 "__BLNK__" /* MF77 assigned */ --#define BLANK_COMMON_NAME_LOCAL "__BLANK" /* Local GDB */ - - /* When reasonable array bounds cannot be fetched, such as when - you ask to 'mt print symbols' and there is no stack frame and -@@ -113,6 +84,7 @@ struct builtin_f_type - struct type *builtin_logical; - struct type *builtin_logical_s1; - struct type *builtin_logical_s2; -+ struct type *builtin_logical_s8; - struct type *builtin_real; - struct type *builtin_real_s8; - struct type *builtin_real_s16; -@@ -125,3 +97,10 @@ struct builtin_f_type - /* Return the Fortran type table for the specified architecture. */ - extern const struct builtin_f_type *builtin_f_type (struct gdbarch *gdbarch); - -+/* List of module names being imported by a block though BLOCK_FORTRAN_USE. */ -+ -+struct fortran_using -+ { -+ struct fortran_using *next; -+ char module_name[1]; -+ }; -diff --git a/gdb/f-typeprint.c b/gdb/f-typeprint.c -index 6c9668f..852b9a8 100644 ---- a/gdb/f-typeprint.c -+++ b/gdb/f-typeprint.c -@@ -31,7 +31,7 @@ - #include "gdbcore.h" - #include "target.h" - #include "f-lang.h" -- -+#include "dwarf2loc.h" - #include "gdb_string.h" - #include - -@@ -48,6 +48,34 @@ void f_type_print_varspec_prefix (struct type *, struct ui_file *, - void f_type_print_base (struct type *, struct ui_file *, int, int); - - -+const char * -+f_object_address_data_valid_print_to_stream (struct type *type, -+ struct ui_file *stream) ++struct minimal_symbol * ++resolve_gnu_ifunc_by_cache (const char *function_name) +{ -+ const char *msg; ++ char *function_name_gnu_ifunc_tgt; + -+ msg = object_address_data_not_valid (type); -+ if (msg != NULL) -+ { -+ /* Assuming the content printed to STREAM should not be localized. */ -+ fprintf_filtered (stream, "<%s>", msg); -+ } ++ function_name_gnu_ifunc_tgt = alloca (strlen (function_name) ++ + strlen ("@gnu-ifunc-tgt") + 1); ++ sprintf (function_name_gnu_ifunc_tgt, "%s@gnu-ifunc-tgt", function_name); + -+ return msg; ++ return lookup_minimal_symbol (function_name_gnu_ifunc_tgt, NULL, NULL); +} + -+void -+f_object_address_data_valid_or_error (struct type *type) ++int ++resolve_gnu_ifunc (const char *function_name, CORE_ADDR *function_addressp) +{ -+ const char *msg; ++ struct minimal_symbol *msym; + -+ msg = object_address_data_not_valid (type); -+ if (msg != NULL) ++ msym = resolve_gnu_ifunc_by_cache (function_name); ++ if (msym != NULL) + { -+ error (_("Cannot access it because the %s."), _(msg)); ++ *function_addressp = SYMBOL_VALUE_ADDRESS (msym); ++ return 1; ++ } ++ ++ msym = resolve_gnu_ifunc_by_got (function_name); ++ if (msym != NULL) ++ { ++ *function_addressp = SYMBOL_VALUE_ADDRESS (msym); ++ return 1; + } ++ ++ return 0; +} + - /* LEVEL is the depth to indent lines by. */ + struct build_id + { + size_t size; +@@ -797,6 +1049,8 @@ elf_symfile_read (struct objfile *objfile, int symfile_flags) + bfd_errmsg (bfd_get_error ())); - void -@@ -57,6 +85,9 @@ f_print_type (struct type *type, char *varstring, struct ui_file *stream, - enum type_code code; - int demangled_args; + elf_symtab_read (objfile, ST_DYNAMIC, dynsymcount, dyn_symbol_table, 0); ++ ++ elf_rel_plt_read (objfile, dyn_symbol_table); + } -+ if (f_object_address_data_valid_print_to_stream (type, stream) != NULL) -+ return; + /* Add synthetic symbols - for instance, names for any PLT entries. */ +@@ -869,11 +1123,9 @@ elf_symfile_read (struct objfile *objfile, int symfile_flags) + str_sect->filepos, + bfd_section_size (abfd, str_sect)); + } +- if (dwarf2_has_info (objfile)) +- { +- /* DWARF 2 sections */ +- dwarf2_build_psymtabs (objfile); +- } + - f_type_print_base (type, stream, show, level); - code = TYPE_CODE (type); - if ((varstring != NULL && *varstring != '\0') -@@ -166,6 +197,9 @@ f_type_print_varspec_suffix (struct type *type, struct ui_file *stream, ++ if (dwarf2_has_info (objfile) && dwarf2_initialize_objfile (objfile)) ++ objfile->sf = &elf_sym_fns_gdb_index; - QUIT; + /* If the file has its own symbol tables it has no separate debug info. + `.dynsym'/`.symtab' go to MSYMBOLS, `.debug_info' goes to SYMTABS/PSYMTABS. +@@ -1049,6 +1301,24 @@ static struct sym_fns elf_sym_fns = + NULL /* next: pointer to next struct sym_fns */ + }; -+ if (TYPE_CODE (type) != TYPE_CODE_TYPEDEF) -+ CHECK_TYPEDEF (type); ++/* The same as elf_sym_fns, but not registered and uses the ++ DWARF-specific GNU index rather than psymtab. */ ++static struct sym_fns elf_sym_fns_gdb_index = ++{ ++ bfd_target_elf_flavour, ++ elf_new_init, /* sym_new_init: init anything gbl to entire symab */ ++ elf_symfile_init, /* sym_init: read initial info, setup for sym_red() */ ++ elf_symfile_read, /* sym_read: read a symbol file into symtab */ ++ elf_symfile_finish, /* sym_finish: finished with file, cleanup */ ++ default_symfile_offsets, /* sym_offsets: Translate ext. to int. relocatin */ ++ elf_symfile_segments, /* sym_segments: Get segment information from ++ a file. */ ++ NULL, /* sym_read_linetable */ ++ default_symfile_relocate, /* sym_relocate: Relocate a debug section. */ ++ &dwarf2_gdb_index_functions, ++ NULL /* next: pointer to next struct sym_fns */ ++}; + - switch (TYPE_CODE (type)) - { - case TYPE_CODE_ARRAY: -diff --git a/gdb/f-valprint.c b/gdb/f-valprint.c -index 0a57404..a9ccc77 100644 ---- a/gdb/f-valprint.c -+++ b/gdb/f-valprint.c -@@ -34,10 +34,8 @@ - #include "gdbcore.h" - #include "command.h" - #include "block.h" -- --#if 0 --static int there_is_a_visible_common_named (char *); --#endif -+#include "dictionary.h" -+#include "gdb_assert.h" + void + _initialize_elfread (void) + { +diff --git a/gdb/eval.c b/gdb/eval.c +index ff17c34..7b9e871 100644 +--- a/gdb/eval.c ++++ b/gdb/eval.c +@@ -44,6 +44,7 @@ + #include "objfiles.h" + #include "python/python.h" + #include "wrapper.h" ++#include "dwarf2loc.h" - extern void _initialize_f_valprint (void); - static void info_common_command (char *, int); -@@ -54,15 +52,17 @@ int f77_array_offset_tbl[MAX_FORTRAN_DIMS + 1][2]; - /* The following macro gives us the size of the nth dimension, Where - n is 1 based. */ + #include "gdb_assert.h" --#define F77_DIM_SIZE(n) (f77_array_offset_tbl[n][1]) -+#define F77_DIM_COUNT(n) (f77_array_offset_tbl[n][1]) +@@ -788,6 +789,7 @@ evaluate_subexp_standard (struct type *expect_type, + int save_pos1; + struct symbol *function = NULL; + char *function_name = NULL; ++ struct cleanup *old_chain; --/* The following gives us the offset for row n where n is 1-based. */ -+/* The following gives us the element size for row n where n is 1-based. */ + pc = (*pos)++; + op = exp->elts[pc].opcode; +@@ -1772,6 +1774,8 @@ evaluate_subexp_standard (struct type *expect_type, + return value_zero (builtin_type (exp->gdbarch)->builtin_int, + not_lval); + } ++ else if (TYPE_GNU_IFUNC (ftype)) ++ return allocate_value (TYPE_TARGET_TYPE (TYPE_TARGET_TYPE (ftype))); + else if (TYPE_TARGET_TYPE (ftype)) + return allocate_value (TYPE_TARGET_TYPE (ftype)); + else +@@ -1798,6 +1802,8 @@ evaluate_subexp_standard (struct type *expect_type, --#define F77_DIM_OFFSET(n) (f77_array_offset_tbl[n][0]) -+#define F77_DIM_BYTE_STRIDE(n) (f77_array_offset_tbl[n][0]) + /* First determine the type code we are dealing with. */ + arg1 = evaluate_subexp (NULL_TYPE, exp, pos, noside); ++ old_chain = make_cleanup (null_cleanup, 0); ++ object_address_set (value_raw_address (arg1)); + type = check_typedef (value_type (arg1)); + code = TYPE_CODE (type); - int - f77_get_lowerbound (struct type *type) - { -+ f_object_address_data_valid_or_error (type); -+ - if (TYPE_ARRAY_LOWER_BOUND_IS_UNDEFINED (type)) - error (_("Lower bound may not be '*' in F77")); +@@ -1818,6 +1824,7 @@ evaluate_subexp_standard (struct type *expect_type, + code = TYPE_CODE (type); + } + } ++ do_cleanups (old_chain); -@@ -72,14 +72,17 @@ f77_get_lowerbound (struct type *type) - int - f77_get_upperbound (struct type *type) - { -+ f_object_address_data_valid_or_error (type); -+ - if (TYPE_ARRAY_UPPER_BOUND_IS_UNDEFINED (type)) + switch (code) + { +@@ -2254,13 +2261,19 @@ evaluate_subexp_standard (struct type *expect_type, + { + int subscript_array[MAX_FORTRAN_DIMS]; + int array_size_array[MAX_FORTRAN_DIMS]; ++ int byte_stride_array[MAX_FORTRAN_DIMS]; + int ndimensions = 1, i; + struct type *tmp_type; + int offset_item; /* The array offset where the item lives */ ++ CORE_ADDR offset_byte; /* byte_stride based offset */ ++ unsigned element_size; + + if (nargs > MAX_FORTRAN_DIMS) + error (_("Too many subscripts for F77 (%d Max)"), MAX_FORTRAN_DIMS); + ++ old_chain = make_cleanup (null_cleanup, 0); ++ object_address_set (value_raw_address (arg1)); ++ + tmp_type = check_typedef (value_type (arg1)); + ndimensions = calc_f77_array_dims (type); + +@@ -2290,6 +2303,9 @@ evaluate_subexp_standard (struct type *expect_type, + upper = f77_get_upperbound (tmp_type); + lower = f77_get_lowerbound (tmp_type); + ++ byte_stride_array[nargs - i - 1] = ++ TYPE_ARRAY_BYTE_STRIDE_VALUE (tmp_type); ++ + array_size_array[nargs - i - 1] = upper - lower + 1; + + /* Zero-normalize subscripts so that offsetting will work. */ +@@ -2308,13 +2324,25 @@ evaluate_subexp_standard (struct type *expect_type, + tmp_type = check_typedef (TYPE_TARGET_TYPE (tmp_type)); + } + ++ /* Kept for the f77_get_upperbound / f77_get_lowerbound calls above. */ ++ do_cleanups (old_chain); ++ + /* Now let us calculate the offset for this item */ + +- offset_item = subscript_array[ndimensions - 1]; ++ offset_item = 0; ++ offset_byte = 0; ++ ++ for (i = ndimensions - 1; i >= 0; --i) ++ { ++ offset_item *= array_size_array[i]; ++ if (byte_stride_array[i] == 0) ++ offset_item += subscript_array[i]; ++ else ++ offset_byte += subscript_array[i] * byte_stride_array[i]; ++ } + +- for (i = ndimensions - 1; i > 0; --i) +- offset_item = +- array_size_array[i - 1] * offset_item + subscript_array[i - 1]; ++ element_size = TYPE_LENGTH (TYPE_TARGET_TYPE (tmp_type)); ++ offset_byte += offset_item * element_size; + + /* Let us now play a dirty trick: we will take arg1 + which is a value node pointing to the topmost level +@@ -2324,7 +2352,7 @@ evaluate_subexp_standard (struct type *expect_type, + returns the correct type value */ + + deprecated_set_value_type (arg1, tmp_type); +- return value_subscripted_rvalue (arg1, offset_item, 0); ++ return value_subscripted_rvalue (arg1, offset_byte); + } + + case BINOP_LOGICAL_AND: +@@ -2558,14 +2586,22 @@ evaluate_subexp_standard (struct type *expect_type, + if (expect_type && TYPE_CODE (expect_type) == TYPE_CODE_PTR) + expect_type = TYPE_TARGET_TYPE (check_typedef (expect_type)); + arg1 = evaluate_subexp (expect_type, exp, pos, noside); ++ old_chain = make_cleanup (null_cleanup, 0); ++ object_address_set (value_raw_address (arg1)); + type = check_typedef (value_type (arg1)); + if (TYPE_CODE (type) == TYPE_CODE_METHODPTR + || TYPE_CODE (type) == TYPE_CODE_MEMBERPTR) + error (_("Attempt to dereference pointer to member without an object")); + if (noside == EVAL_SKIP) +- goto nosideret; ++ { ++ do_cleanups (old_chain); ++ goto nosideret; ++ } + if (unop_user_defined_p (op, arg1)) +- return value_x_unop (arg1, op, noside); ++ { ++ do_cleanups (old_chain); ++ return value_x_unop (arg1, op, noside); ++ } + else if (noside == EVAL_AVOID_SIDE_EFFECTS) + { + type = check_typedef (value_type (arg1)); +@@ -2574,12 +2610,18 @@ evaluate_subexp_standard (struct type *expect_type, + /* In C you can dereference an array to get the 1st elt. */ + || TYPE_CODE (type) == TYPE_CODE_ARRAY + ) +- return value_zero (TYPE_TARGET_TYPE (type), +- lval_memory); ++ { ++ do_cleanups (old_chain); ++ return value_zero (TYPE_TARGET_TYPE (type), ++ lval_memory); ++ } + else if (TYPE_CODE (type) == TYPE_CODE_INT) +- /* GDB allows dereferencing an int. */ +- return value_zero (builtin_type (exp->gdbarch)->builtin_int, +- lval_memory); ++ { ++ do_cleanups (old_chain); ++ /* GDB allows dereferencing an int. */ ++ return value_zero (builtin_type (exp->gdbarch)->builtin_int, ++ lval_memory); ++ } + else + error (_("Attempt to take contents of a non-pointer value.")); + } +@@ -2589,9 +2631,14 @@ evaluate_subexp_standard (struct type *expect_type, + do. "long long" variables are rare enough that + BUILTIN_TYPE_LONGEST would seem to be a mistake. */ + if (TYPE_CODE (type) == TYPE_CODE_INT) +- return value_at_lazy (builtin_type (exp->gdbarch)->builtin_int, +- (CORE_ADDR) value_as_address (arg1)); +- return value_ind (arg1); ++ { ++ do_cleanups (old_chain); ++ return value_at_lazy (builtin_type (exp->gdbarch)->builtin_int, ++ (CORE_ADDR) value_as_address (arg1)); ++ } ++ arg1 = value_ind (arg1); ++ do_cleanups (old_chain); ++ return arg1; + + case UNOP_ADDR: + /* C++: check for and handle pointer to members. */ +@@ -2933,7 +2980,7 @@ evaluate_subexp_with_coercion (struct expression *exp, + { + enum exp_opcode op; + int pc; +- struct value *val; ++ struct value *val = NULL; + struct symbol *var; + struct type *type; + +@@ -2944,12 +2991,17 @@ evaluate_subexp_with_coercion (struct expression *exp, + { + case OP_VAR_VALUE: + var = exp->elts[pc + 2].symbol; ++ /* address_of_variable will call object_address_set for check_typedef. ++ Call it only if required as it can error-out on VAR in register. */ ++ if (TYPE_DYNAMIC (SYMBOL_TYPE (var))) ++ val = address_of_variable (var, exp->elts[pc + 1].block); + type = check_typedef (SYMBOL_TYPE (var)); + if (TYPE_CODE (type) == TYPE_CODE_ARRAY + && CAST_IS_CONVERSION (exp->language_defn)) + { + (*pos) += 4; +- val = address_of_variable (var, exp->elts[pc + 1].block); ++ if (!val) ++ val = address_of_variable (var, exp->elts[pc + 1].block); + return value_cast (lookup_pointer_type (TYPE_TARGET_TYPE (type)), + val); + } +@@ -3001,9 +3053,13 @@ evaluate_subexp_for_sizeof (struct expression *exp, int *pos) + + case OP_VAR_VALUE: + (*pos) += 4; +- type = check_typedef (SYMBOL_TYPE (exp->elts[pc + 2].symbol)); +- return +- value_from_longest (size_type, (LONGEST) TYPE_LENGTH (type)); ++ /* We do not need to call read_var_value but the object evaluation may ++ need to have executed object_address_set which needs valid ++ SYMBOL_VALUE_ADDRESS of the symbol. Still VALUE returned by ++ read_var_value we left as lazy. */ ++ type = value_type (read_var_value (exp->elts[pc + 2].symbol, ++ deprecated_safe_get_selected_frame ())); ++ return value_from_longest (size_type, (LONGEST) TYPE_LENGTH (type)); + + default: + val = evaluate_subexp (NULL_TYPE, exp, pos, EVAL_AVOID_SIDE_EFFECTS); +diff --git a/gdb/f-lang.h b/gdb/f-lang.h +index f5bb82d..29cf5ba 100644 +--- a/gdb/f-lang.h ++++ b/gdb/f-lang.h +@@ -28,6 +28,10 @@ extern void f_error (char *); /* Defined in f-exp.y */ + extern void f_print_type (struct type *, const char *, struct ui_file *, int, + int); + ++extern const char *f_object_address_data_valid_print_to_stream ++ (struct type *type, struct ui_file *stream); ++extern void f_object_address_data_valid_or_error (struct type *type); ++ + extern int f_val_print (struct type *, const gdb_byte *, int, CORE_ADDR, + struct ui_file *, int, + const struct value *, +diff --git a/gdb/f-typeprint.c b/gdb/f-typeprint.c +index d35a255..dec81d5 100644 +--- a/gdb/f-typeprint.c ++++ b/gdb/f-typeprint.c +@@ -32,7 +32,7 @@ + #include "gdbcore.h" + #include "target.h" + #include "f-lang.h" +- ++#include "dwarf2loc.h" + #include "gdb_string.h" + #include + +@@ -49,6 +49,34 @@ void f_type_print_varspec_prefix (struct type *, struct ui_file *, + void f_type_print_base (struct type *, struct ui_file *, int, int); + + ++const char * ++f_object_address_data_valid_print_to_stream (struct type *type, ++ struct ui_file *stream) ++{ ++ const char *msg; ++ ++ msg = object_address_data_not_valid (type); ++ if (msg != NULL) ++ { ++ /* Assuming the content printed to STREAM should not be localized. */ ++ fprintf_filtered (stream, "<%s>", msg); ++ } ++ ++ return msg; ++} ++ ++void ++f_object_address_data_valid_or_error (struct type *type) ++{ ++ const char *msg; ++ ++ msg = object_address_data_not_valid (type); ++ if (msg != NULL) ++ { ++ error (_("Cannot access it because the %s."), _(msg)); ++ } ++} ++ + /* LEVEL is the depth to indent lines by. */ + + void +@@ -58,6 +86,9 @@ f_print_type (struct type *type, const char *varstring, struct ui_file *stream, + enum type_code code; + int demangled_args; + ++ if (f_object_address_data_valid_print_to_stream (type, stream) != NULL) ++ return; ++ + f_type_print_base (type, stream, show, level); + code = TYPE_CODE (type); + if ((varstring != NULL && *varstring != '\0') +@@ -165,6 +196,9 @@ f_type_print_varspec_suffix (struct type *type, struct ui_file *stream, + + QUIT; + ++ if (TYPE_CODE (type) != TYPE_CODE_TYPEDEF) ++ CHECK_TYPEDEF (type); ++ + switch (TYPE_CODE (type)) + { + case TYPE_CODE_ARRAY: +diff --git a/gdb/f-valprint.c b/gdb/f-valprint.c +index 85f698d..2f72b97 100644 +--- a/gdb/f-valprint.c ++++ b/gdb/f-valprint.c +@@ -54,15 +54,17 @@ int f77_array_offset_tbl[MAX_FORTRAN_DIMS + 1][2]; + /* The following macro gives us the size of the nth dimension, Where + n is 1 based. */ + +-#define F77_DIM_SIZE(n) (f77_array_offset_tbl[n][1]) ++#define F77_DIM_COUNT(n) (f77_array_offset_tbl[n][1]) + +-/* The following gives us the offset for row n where n is 1-based. */ ++/* The following gives us the element size for row n where n is 1-based. */ + +-#define F77_DIM_OFFSET(n) (f77_array_offset_tbl[n][0]) ++#define F77_DIM_BYTE_STRIDE(n) (f77_array_offset_tbl[n][0]) + + int + f77_get_lowerbound (struct type *type) + { ++ f_object_address_data_valid_or_error (type); ++ + if (TYPE_ARRAY_LOWER_BOUND_IS_UNDEFINED (type)) + error (_("Lower bound may not be '*' in F77")); + +@@ -72,14 +74,17 @@ f77_get_lowerbound (struct type *type) + int + f77_get_upperbound (struct type *type) + { ++ f_object_address_data_valid_or_error (type); ++ + if (TYPE_ARRAY_UPPER_BOUND_IS_UNDEFINED (type)) { - /* We have an assumed size array on our hands. Assume that - upper_bound == lower_bound so that we show at least 1 element. @@ -8714,7 +5642,7 @@ index 0a57404..a9ccc77 100644 } return TYPE_ARRAY_UPPER_BOUND_VALUE (type); -@@ -135,24 +138,29 @@ f77_create_arrayprint_offset_tbl (struct type *type, struct ui_file *stream) +@@ -134,24 +139,29 @@ f77_create_arrayprint_offset_tbl (struct type *type, struct ui_file *stream) upper = f77_get_upperbound (tmp_type); lower = f77_get_lowerbound (tmp_type); @@ -8750,7 +5678,7 @@ index 0a57404..a9ccc77 100644 } } -@@ -172,34 +180,34 @@ f77_print_array_1 (int nss, int ndimensions, struct type *type, +@@ -172,34 +182,34 @@ f77_print_array_1 (int nss, int ndimensions, struct type *type, if (nss != ndimensions) { @@ -8763,7 +5691,7 @@ index 0a57404..a9ccc77 100644 - address + i * F77_DIM_OFFSET (nss), + valaddr + i * F77_DIM_BYTE_STRIDE (nss), + address + i * F77_DIM_BYTE_STRIDE (nss), - stream, recurse, options, elts); + stream, recurse, val, options, elts); fprintf_filtered (stream, ") "); } - if (*elts >= options->print_max && i < F77_DIM_SIZE (nss)) @@ -8782,7 +5710,7 @@ index 0a57404..a9ccc77 100644 0, - address + i * F77_DIM_OFFSET (ndimensions), + address + i * F77_DIM_BYTE_STRIDE (ndimensions), - stream, recurse, options, current_language); + stream, recurse, val, options, current_language); - if (i != (F77_DIM_SIZE (nss) - 1)) + if (i != (F77_DIM_COUNT (nss) - 1)) @@ -8794,7 +5722,7 @@ index 0a57404..a9ccc77 100644 fprintf_filtered (stream, "..."); } } -@@ -253,6 +261,9 @@ f_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset, +@@ -256,6 +266,9 @@ f_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset, CORE_ADDR addr; int index; @@ -8804,262 +5732,17 @@ index 0a57404..a9ccc77 100644 CHECK_TYPEDEF (type); switch (TYPE_CODE (type)) { -@@ -467,22 +478,54 @@ f_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset, - return 0; +diff --git a/gdb/findcmd.c b/gdb/findcmd.c +index ac63a9e..e9ba45c 100644 +--- a/gdb/findcmd.c ++++ b/gdb/findcmd.c +@@ -45,6 +45,41 @@ put_bits (bfd_uint64_t data, char *buf, int bits, bfd_boolean big_p) + } } --static void --list_all_visible_commons (char *funname) -+static int -+info_common_command_for_block (struct block *block, struct frame_info *frame, -+ const char *comname) - { -- SAVED_F77_COMMON_PTR tmp; -- -- tmp = head_common_list; -- -- printf_filtered (_("All COMMON blocks visible at this level:\n\n")); -- -- while (tmp != NULL) -- { -- if (strcmp (tmp->owning_function, funname) == 0) -- printf_filtered ("%s\n", tmp->name); -- -- tmp = tmp->next; -- } -+ struct dict_iterator iter; -+ struct symbol *sym; -+ int values_printed = 0; -+ const char *name; -+ struct value_print_options opts; -+ -+ get_user_print_options (&opts); -+ -+ ALL_BLOCK_SYMBOLS (block, iter, sym) -+ if (SYMBOL_DOMAIN (sym) == COMMON_BLOCK_DOMAIN) -+ { -+ struct type *type = SYMBOL_TYPE (sym); -+ int index; -+ -+ gdb_assert (SYMBOL_CLASS (sym) == LOC_STATIC); -+ gdb_assert (TYPE_CODE (type) == TYPE_CODE_STRUCT); -+ -+ if (comname && (!SYMBOL_LINKAGE_NAME (sym) -+ || strcmp (comname, SYMBOL_LINKAGE_NAME (sym)) != 0)) -+ continue; -+ -+ values_printed = 1; -+ if (SYMBOL_PRINT_NAME (sym)) -+ printf_filtered (_("Contents of F77 COMMON block '%s':\n"), -+ SYMBOL_PRINT_NAME (sym)); -+ else -+ printf_filtered (_("Contents of blank COMMON block:\n")); -+ -+ for (index = 0; index < TYPE_NFIELDS (type); index++) -+ { -+ struct value *val; -+ -+ gdb_assert (field_is_static (&TYPE_FIELD (type, index))); -+ val = value_static_field (type, index); -+ -+ printf_filtered ("%s = ", TYPE_FIELD_NAME (type, index)); -+ value_print (val, gdb_stdout, &opts); -+ putchar_filtered ('\n'); -+ } -+ -+ putchar_filtered ('\n'); -+ } -+ -+ return values_printed; - } - - /* This function is used to print out the values in a given COMMON -@@ -492,11 +535,9 @@ list_all_visible_commons (char *funname) - static void - info_common_command (char *comname, int from_tty) - { -- SAVED_F77_COMMON_PTR the_common; -- COMMON_ENTRY_PTR entry; - struct frame_info *fi; -- char *funname = 0; -- struct symbol *func; -+ struct block *block; -+ int values_printed = 0; - - /* We have been told to display the contents of F77 COMMON - block supposedly visible in this function. Let us -@@ -508,136 +549,32 @@ info_common_command (char *comname, int from_tty) - /* The following is generally ripped off from stack.c's routine - print_frame_info() */ - -- func = find_pc_function (get_frame_pc (fi)); -- if (func) -- { -- /* In certain pathological cases, the symtabs give the wrong -- function (when we are in the first function in a file which -- is compiled without debugging symbols, the previous function -- is compiled with debugging symbols, and the "foo.o" symbol -- that is supposed to tell us where the file with debugging symbols -- ends has been truncated by ar because it is longer than 15 -- characters). -- -- So look in the minimal symbol tables as well, and if it comes -- up with a larger address for the function use that instead. -- I don't think this can ever cause any problems; there shouldn't -- be any minimal symbols in the middle of a function. -- FIXME: (Not necessarily true. What about text labels) */ -- -- struct minimal_symbol *msymbol = -- lookup_minimal_symbol_by_pc (get_frame_pc (fi)); -- -- if (msymbol != NULL -- && (SYMBOL_VALUE_ADDRESS (msymbol) -- > BLOCK_START (SYMBOL_BLOCK_VALUE (func)))) -- funname = SYMBOL_LINKAGE_NAME (msymbol); -- else -- funname = SYMBOL_LINKAGE_NAME (func); -- } -- else -- { -- struct minimal_symbol *msymbol = -- lookup_minimal_symbol_by_pc (get_frame_pc (fi)); -- -- if (msymbol != NULL) -- funname = SYMBOL_LINKAGE_NAME (msymbol); -- else /* Got no 'funname', code below will fail. */ -- error (_("No function found for frame.")); -- } -- -- /* If comname is NULL, we assume the user wishes to see the -- which COMMON blocks are visible here and then return */ -- -- if (comname == 0) -+ block = get_frame_block (fi, 0); -+ if (block == NULL) - { -- list_all_visible_commons (funname); -+ printf_filtered (_("No symbol table info available.\n")); - return; - } - -- the_common = find_common_for_function (comname, funname); -- -- if (the_common) -+ while (block) - { -- if (strcmp (comname, BLANK_COMMON_NAME_LOCAL) == 0) -- printf_filtered (_("Contents of blank COMMON block:\n")); -- else -- printf_filtered (_("Contents of F77 COMMON block '%s':\n"), comname); -- -- printf_filtered ("\n"); -- entry = the_common->entries; -- -- while (entry != NULL) -- { -- print_variable_and_value (NULL, entry->symbol, fi, gdb_stdout, 0); -- entry = entry->next; -- } -+ if (info_common_command_for_block (block, fi, comname)) -+ values_printed = 1; -+ /* After handling the function's top-level block, stop. Don't -+ continue to its superblock, the block of per-file symbols. */ -+ if (BLOCK_FUNCTION (block)) -+ break; -+ block = BLOCK_SUPERBLOCK (block); - } -- else -- printf_filtered (_("Cannot locate the common block %s in function '%s'\n"), -- comname, funname); --} -- --/* This function is used to determine whether there is a -- F77 common block visible at the current scope called 'comname'. */ -- --#if 0 --static int --there_is_a_visible_common_named (char *comname) --{ -- SAVED_F77_COMMON_PTR the_common; -- struct frame_info *fi; -- char *funname = 0; -- struct symbol *func; -- -- if (comname == NULL) -- error (_("Cannot deal with NULL common name!")); - -- fi = get_selected_frame (_("No frame selected")); -- -- /* The following is generally ripped off from stack.c's routine -- print_frame_info() */ -- -- func = find_pc_function (fi->pc); -- if (func) -+ if (!values_printed) - { -- /* In certain pathological cases, the symtabs give the wrong -- function (when we are in the first function in a file which -- is compiled without debugging symbols, the previous function -- is compiled with debugging symbols, and the "foo.o" symbol -- that is supposed to tell us where the file with debugging symbols -- ends has been truncated by ar because it is longer than 15 -- characters). -- -- So look in the minimal symbol tables as well, and if it comes -- up with a larger address for the function use that instead. -- I don't think this can ever cause any problems; there shouldn't -- be any minimal symbols in the middle of a function. -- FIXME: (Not necessarily true. What about text labels) */ -- -- struct minimal_symbol *msymbol = lookup_minimal_symbol_by_pc (fi->pc); -- -- if (msymbol != NULL -- && (SYMBOL_VALUE_ADDRESS (msymbol) -- > BLOCK_START (SYMBOL_BLOCK_VALUE (func)))) -- funname = SYMBOL_LINKAGE_NAME (msymbol); -+ if (comname) -+ printf_filtered (_("No common block '%s'.\n"), comname); - else -- funname = SYMBOL_LINKAGE_NAME (func); -+ printf_filtered (_("No common blocks.\n")); - } -- else -- { -- struct minimal_symbol *msymbol = -- lookup_minimal_symbol_by_pc (fi->pc); -- -- if (msymbol != NULL) -- funname = SYMBOL_LINKAGE_NAME (msymbol); -- } -- -- the_common = find_common_for_function (comname, funname); -- -- return (the_common ? 1 : 0); - } --#endif - - void - _initialize_f_valprint (void) -diff --git a/gdb/findcmd.c b/gdb/findcmd.c -index 1d28914..d176341 100644 ---- a/gdb/findcmd.c -+++ b/gdb/findcmd.c -@@ -27,7 +27,7 @@ - - /* Copied from bfd_put_bits. */ - --static void -+void - put_bits (bfd_uint64_t data, char *buf, int bits, bfd_boolean big_p) - { - int i; -@@ -45,6 +45,41 @@ put_bits (bfd_uint64_t data, char *buf, int bits, bfd_boolean big_p) - } - } - -+/* Allocates a buffer in *PATTERN_BUF, with a hard-coded initial size which -+ will be returned in *PATTERN_BUF_SIZE. *PATTERN_BUF_END points to the same -+ place as *PATTERN_BUF, indicating that the buffer is initially empty. */ ++/* Allocates a buffer in *PATTERN_BUF, with a hard-coded initial size which ++ will be returned in *PATTERN_BUF_SIZE. *PATTERN_BUF_END points to the same ++ place as *PATTERN_BUF, indicating that the buffer is initially empty. */ + +void +allocate_pattern_buffer (char **pattern_buf, char **pattern_buf_end, @@ -9115,7 +5798,7 @@ index 1d28914..d176341 100644 old_cleanups = make_cleanup (free_current_contents, &pattern_buf); /* Get search granularity and/or max count if specified. -@@ -173,16 +206,8 @@ parse_find_args (char *args, ULONGEST *max_countp, +@@ -175,17 +208,9 @@ parse_find_args (char *args, ULONGEST *max_countp, v = parse_to_comma_and_eval (&s); val_bytes = TYPE_LENGTH (value_type (v)); @@ -9125,16 +5808,17 @@ index 1d28914..d176341 100644 - > pattern_buf_size) - { - size_t current_offset = pattern_buf_end - pattern_buf; ++ increase_pattern_buffer (&pattern_buf, &pattern_buf_end, ++ &pattern_buf_size, val_bytes); + - pattern_buf_size *= 2; - pattern_buf = xrealloc (pattern_buf, pattern_buf_size); - pattern_buf_end = pattern_buf + current_offset; - } -+ increase_pattern_buffer (&pattern_buf, &pattern_buf_end, -+ &pattern_buf_size, val_bytes); if (size != '\0') { -@@ -237,6 +262,45 @@ parse_find_args (char *args, ULONGEST *max_countp, +@@ -240,6 +265,45 @@ parse_find_args (char *args, ULONGEST *max_countp, discard_cleanups (old_cleanups); } @@ -9180,7 +5864,7 @@ index 1d28914..d176341 100644 static void find_command (char *args, int from_tty) { -@@ -267,12 +331,11 @@ find_command (char *args, int from_tty) +@@ -270,12 +334,11 @@ find_command (char *args, int from_tty) while (search_space_len >= pattern_len && found_count < max_count) { @@ -9196,7 +5880,7 @@ index 1d28914..d176341 100644 if (found <= 0) break; -@@ -280,16 +343,6 @@ find_command (char *args, int from_tty) +@@ -283,16 +346,6 @@ find_command (char *args, int from_tty) printf_filtered ("\n"); ++found_count; last_found_addr = found_addr; @@ -9214,7 +5898,7 @@ index 1d28914..d176341 100644 /* Record and print the results. */ diff --git a/gdb/findvar.c b/gdb/findvar.c -index 8c027c9..d201f76 100644 +index e0ca12c..de6311a 100644 --- a/gdb/findvar.c +++ b/gdb/findvar.c @@ -35,6 +35,7 @@ @@ -9223,9 +5907,9 @@ index 8c027c9..d201f76 100644 #include "objfiles.h" +#include "dwarf2loc.h" - /* Basic byte-swapping routines. GDB has needed these for a long time... - All extract a target-format integer at ADDR which is LEN bytes long. */ -@@ -394,27 +395,16 @@ symbol_read_needs_frame (struct symbol *sym) + /* Basic byte-swapping routines. All 'extract' functions return a + host-format integer from a target-format integer at ADDR which is +@@ -401,27 +402,16 @@ symbol_read_needs_frame (struct symbol *sym) /* Given a struct symbol for a variable, and a stack frame id, read the value of the variable and return a (pointer to a) struct value containing the value. @@ -9257,7 +5941,7 @@ index 8c027c9..d201f76 100644 if (symbol_read_needs_frame (var)) gdb_assert (frame); -@@ -422,32 +412,40 @@ read_var_value (struct symbol *var, struct frame_info *frame) +@@ -429,33 +419,43 @@ read_var_value (struct symbol *var, struct frame_info *frame) switch (SYMBOL_CLASS (var)) { case LOC_CONST: @@ -9284,13 +5968,6 @@ index 8c027c9..d201f76 100644 - CORE_ADDR addr - = symbol_overlayed_address (SYMBOL_VALUE_ADDRESS (var), - SYMBOL_OBJ_SECTION (var)); -- store_typed_address (value_contents_raw (v), type, addr); -- } -- else -- store_typed_address (value_contents_raw (v), type, -- SYMBOL_VALUE_ADDRESS (var)); -- VALUE_LVAL (v) = not_lval; -- return v; + { + /* Put the constant back in target format. */ + struct value *v = allocate_value (type); @@ -9300,6 +5977,14 @@ index 8c027c9..d201f76 100644 + CORE_ADDR addr + = symbol_overlayed_address (SYMBOL_VALUE_ADDRESS (var), + SYMBOL_OBJ_SECTION (var)); + +- store_typed_address (value_contents_raw (v), type, addr); +- } +- else +- store_typed_address (value_contents_raw (v), type, +- SYMBOL_VALUE_ADDRESS (var)); +- VALUE_LVAL (v) = not_lval; +- return v; + store_typed_address (value_contents_raw (v), type, addr); + } + else @@ -9309,16 +5994,20 @@ index 8c027c9..d201f76 100644 + } case LOC_CONST_BYTES: - { -- memcpy (value_contents_raw (v), SYMBOL_VALUE_BYTES (var), len); +- memcpy (value_contents_raw (v), SYMBOL_VALUE_BYTES (var), len); +- VALUE_LVAL (v) = not_lval; +- return v; ++ { + struct value *v = allocate_value (type); - VALUE_LVAL (v) = not_lval; ++ VALUE_LVAL (v) = not_lval; + memcpy (value_contents_raw (v), SYMBOL_VALUE_BYTES (var), + TYPE_LENGTH (type)); - return v; - } ++ return v; ++ } -@@ -489,12 +487,23 @@ read_var_value (struct symbol *var, struct frame_info *frame) + case LOC_STATIC: + if (overlay_debugging) +@@ -496,12 +496,23 @@ read_var_value (struct symbol *var, struct frame_info *frame) break; case LOC_BLOCK: @@ -9348,7 +6037,7 @@ index 8c027c9..d201f76 100644 case LOC_REGISTER: case LOC_REGPARM_ADDR: -@@ -513,7 +522,6 @@ read_var_value (struct symbol *var, struct frame_info *frame) +@@ -520,7 +531,6 @@ read_var_value (struct symbol *var, struct frame_info *frame) error (_("Value of register variable not available.")); addr = value_as_address (regval); @@ -9356,7 +6045,7 @@ index 8c027c9..d201f76 100644 } else { -@@ -556,18 +564,33 @@ read_var_value (struct symbol *var, struct frame_info *frame) +@@ -563,18 +573,33 @@ read_var_value (struct symbol *var, struct frame_info *frame) break; case LOC_OPTIMIZED_OUT: @@ -9396,7 +6085,7 @@ index 8c027c9..d201f76 100644 } /* Install default attributes for register values. */ -@@ -604,10 +627,11 @@ struct value * +@@ -611,10 +636,11 @@ struct value * value_from_register (struct type *type, int regnum, struct frame_info *frame) { struct gdbarch *gdbarch = get_frame_arch (frame); @@ -9410,7 +6099,7 @@ index 8c027c9..d201f76 100644 { /* The ISA/ABI need to something weird when obtaining the specified value from this register. It might need to -@@ -621,7 +645,7 @@ value_from_register (struct type *type, int regnum, struct frame_info *frame) +@@ -628,7 +654,7 @@ value_from_register (struct type *type, int regnum, struct frame_info *frame) VALUE_FRAME_ID (v) = get_frame_id (frame); VALUE_REGNUM (v) = regnum; gdbarch_register_to_value (gdbarch, @@ -9419,25 +6108,21 @@ index 8c027c9..d201f76 100644 } else { -diff --git a/gdb/frame.c b/gdb/frame.c -index 7932b48..4e7c434 100644 ---- a/gdb/frame.c -+++ b/gdb/frame.c -@@ -1171,6 +1171,14 @@ has_stack_frames (void) - if (ptid_equal (inferior_ptid, null_ptid)) - return 0; +diff --git a/gdb/gdbcmd.h b/gdb/gdbcmd.h +index 78151dd..da11686 100644 +--- a/gdb/gdbcmd.h ++++ b/gdb/gdbcmd.h +@@ -124,6 +124,10 @@ extern struct cmd_list_element *setchecklist; -+ /* FIXME: Workaround archer-tromey-python crash in -+ add_inferior_object->get_current_arch on FSF GDB update: -+ is_thread_state would assertion check here as -+ remote_start_remote->add_inferior_silent->observer_notify_new_inferior is -+ before remote_start_remote->add_thread_silent. */ -+ if (find_thread_ptid (inferior_ptid) == NULL) -+ return 0; + extern struct cmd_list_element *showchecklist; + ++/* Chain containing all defined "save" subcommands. */ + - /* Don't try to read from a dead thread. */ - if (is_exited (inferior_ptid)) - return 0; ++extern struct cmd_list_element *save_cmdlist; ++ + extern void execute_command (char *, int); + extern char *execute_command_to_string (char *p, int from_tty); + diff --git a/gdb/gdbinit.in b/gdb/gdbinit.in index ffb7f53..a2e7e94 100644 --- a/gdb/gdbinit.in @@ -9458,534 +6143,108 @@ index ffb7f53..a2e7e94 100644 set complaints 1 b internal_error -diff --git a/gdb/gdbserver/linux-i386-low.c b/gdb/gdbserver/linux-i386-low.c -new file mode 100644 -index 0000000..b95c1b1 ---- /dev/null -+++ b/gdb/gdbserver/linux-i386-low.c -@@ -0,0 +1,210 @@ -+/* GNU/Linux/i386 specific low level interface, for the remote server for GDB. -+ Copyright (C) 1995, 1996, 1998, 1999, 2000, 2001, 2002, 2004, 2005, 2006, -+ 2007, 2008, 2009 Free Software Foundation, Inc. -+ -+ This file is part of GDB. -+ -+ 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 "server.h" -+#include "linux-low.h" -+#include "i387-fp.h" -+ -+#include "gdb_proc_service.h" -+ -+#include -+ -+#ifdef HAVE_SYS_REG_H -+#include -+#endif -+ -+#ifndef PTRACE_GET_THREAD_AREA -+#define PTRACE_GET_THREAD_AREA 25 -+#endif -+ -+/* Defined in auto-generated file reg-i386-linux.c. */ -+void init_registers_i386_linux (void); -+ -+ -+/* This module only supports access to the general purpose registers. */ -+ -+#define i386_num_regs 16 -+ -+/* This stuff comes from i386-linux-nat.c. */ -+ -+/* Mapping between the general-purpose registers in `struct user' -+ format and GDB's register array layout. */ -+static int i386_regmap[] = -+{ -+ EAX * 4, ECX * 4, EDX * 4, EBX * 4, -+ UESP * 4, EBP * 4, ESI * 4, EDI * 4, -+ EIP * 4, EFL * 4, CS * 4, SS * 4, -+ DS * 4, ES * 4, FS * 4, GS * 4 -+}; -+ -+/* Called by libthread_db. */ -+ -+ps_err_e -+ps_get_thread_area (const struct ps_prochandle *ph, -+ lwpid_t lwpid, int idx, void **base) -+{ -+ unsigned int desc[4]; -+ -+ if (ptrace (PTRACE_GET_THREAD_AREA, lwpid, -+ (void *) idx, (unsigned long) &desc) < 0) -+ return PS_ERR; -+ -+ *(int *)base = desc[1]; -+ return PS_OK; -+} -+ -+static int -+i386_cannot_store_register (int regno) -+{ -+ return (regno >= i386_num_regs); -+} -+ -+static int -+i386_cannot_fetch_register (int regno) -+{ -+ return (regno >= i386_num_regs); -+} -+ -+ -+#ifdef HAVE_PTRACE_GETREGS -+#include -+#include -+ -+static void -+i386_fill_gregset (void *buf) -+{ -+ int i; -+ -+ for (i = 0; i < i386_num_regs; i++) -+ collect_register (i, ((char *) buf) + i386_regmap[i]); -+ -+ collect_register_by_name ("orig_eax", ((char *) buf) + ORIG_EAX * 4); -+} -+ -+static void -+i386_store_gregset (const void *buf) -+{ -+ int i; -+ -+ for (i = 0; i < i386_num_regs; i++) -+ supply_register (i, ((char *) buf) + i386_regmap[i]); +diff --git a/gdb/gdbthread.h b/gdb/gdbthread.h +index cd24eaf..9638368 100644 +--- a/gdb/gdbthread.h ++++ b/gdb/gdbthread.h +@@ -66,6 +66,9 @@ struct thread_info + /* Step-resume or longjmp-resume breakpoint. */ + struct breakpoint *step_resume_breakpoint; + ++ /* Exception-resume breakpoint. */ ++ struct breakpoint *exception_resume_breakpoint; + -+ supply_register_by_name ("orig_eax", ((char *) buf) + ORIG_EAX * 4); -+} + /* Range to single step within. + + If this is nonzero, respond to a single-step signal by continuing +@@ -185,6 +188,10 @@ struct thread_info + /* True if this thread has been explicitly requested to stop. */ + int stop_requested; + ++ /* The initiating frame of a nexting operation, used for deciding ++ which exceptions to intercept. */ ++ struct frame_id initiating_frame; + -+static void -+i386_fill_fpregset (void *buf) -+{ -+ i387_cache_to_fsave (buf); -+} + /* Private data used by the target vector implementation. */ + struct private_thread_info *private; + +@@ -221,6 +228,9 @@ extern void delete_thread_silent (ptid_t); + /* Delete a step_resume_breakpoint from the thread database. */ + extern void delete_step_resume_breakpoint (struct thread_info *); + ++/* Delete an exception_resume_breakpoint from the thread database. */ ++extern void delete_exception_resume_breakpoint (struct thread_info *); + -+static void -+i386_store_fpregset (const void *buf) -+{ -+ i387_fsave_to_cache (buf); -+} + /* Translate the integer thread id (GDB's homegrown id, not the system's) + into a "pid" (which may be overloaded with extra thread information). */ + extern ptid_t thread_id_to_pid (int); +diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c +index 443f6f7..d852a14 100644 +--- a/gdb/gdbtypes.c ++++ b/gdb/gdbtypes.c +@@ -39,6 +39,9 @@ + #include "cp-abi.h" + #include "gdb_assert.h" + #include "hashtab.h" ++#include "observer.h" ++#include "dwarf2expr.h" ++#include "dwarf2loc.h" + + + /* Floatformat pairs. */ +@@ -123,6 +126,11 @@ static void print_arg_types (struct field *, int, int); + static void dump_fn_fieldlists (struct type *, int); + static void print_cplus_stuff (struct type *, int); + ++/* The hash table holding all discardable `struct type *' references. */ ++static htab_t type_discardable_table; + -+static void -+i386_fill_fpxregset (void *buf) -+{ -+ i387_cache_to_fxsave (buf); -+} ++/* Current type_discardable_check pass used for TYPE_DISCARDABLE_AGE. */ ++static int type_discardable_age_current; + + /* Allocate a new OBJFILE-associated type structure and fill it + with some defaults. Space for the type structure is allocated +@@ -153,6 +161,39 @@ alloc_type (struct objfile *objfile) + return type; + } + ++/* Declare TYPE as discardable on next garbage collection by free_all_types. ++ You must call type_mark_used during each free_all_types to protect TYPE from ++ being deallocated. */ + +static void -+i386_store_fpxregset (const void *buf) ++set_type_as_discardable (struct type *type) +{ -+ i387_fxsave_to_cache (buf); -+} -+ -+#endif /* HAVE_PTRACE_GETREGS */ -+ -+struct regset_info target_regsets[] = { -+#ifdef HAVE_PTRACE_GETREGS -+ { PTRACE_GETREGS, PTRACE_SETREGS, sizeof (elf_gregset_t), -+ GENERAL_REGS, -+ i386_fill_gregset, i386_store_gregset }, -+# ifdef HAVE_PTRACE_GETFPXREGS -+ { PTRACE_GETFPXREGS, PTRACE_SETFPXREGS, sizeof (elf_fpxregset_t), -+ EXTENDED_REGS, -+ i386_fill_fpxregset, i386_store_fpxregset }, -+# endif -+ { PTRACE_GETFPREGS, PTRACE_SETFPREGS, sizeof (elf_fpregset_t), -+ FP_REGS, -+ i386_fill_fpregset, i386_store_fpregset }, -+#endif /* HAVE_PTRACE_GETREGS */ -+ { 0, 0, -1, -1, NULL, NULL } -+}; -+ -+static const unsigned char i386_breakpoint[] = { 0xCC }; -+#define i386_breakpoint_len 1 -+ -+extern int debug_threads; ++ void **slot; + -+static CORE_ADDR -+i386_get_pc () -+{ -+ unsigned long pc; ++ gdb_assert (!TYPE_DISCARDABLE (type)); + -+ collect_register_by_name ("eip", &pc); ++ TYPE_DISCARDABLE (type) = 1; ++ TYPE_DISCARDABLE_AGE (type) = type_discardable_age_current; + -+ if (debug_threads) -+ fprintf (stderr, "stop pc (before any decrement) is %08lx\n", pc); -+ return pc; ++ slot = htab_find_slot (type_discardable_table, type, INSERT); ++ gdb_assert (!*slot); ++ *slot = type; +} + -+static void -+i386_set_pc (CORE_ADDR newpc) -+{ -+ if (debug_threads) -+ fprintf (stderr, "set pc to %08lx\n", (long) newpc); -+ supply_register_by_name ("eip", &newpc); -+} ++/* Allocate a new type like alloc_type but preserve for it the discardability ++ state of PARENT_TYPE. */ + -+static int -+i386_breakpoint_at (CORE_ADDR pc) ++static struct type * ++alloc_type_as_parent (struct type *parent_type) +{ -+ unsigned char c; ++ struct type *new_type = alloc_type_copy (parent_type); + -+ read_inferior_memory (pc, &c, 1); -+ if (c == 0xCC) -+ return 1; ++ if (TYPE_DISCARDABLE (parent_type)) ++ set_type_as_discardable (new_type); + -+ return 0; -+} -+ -+struct linux_target_ops the_low_target = { -+ init_registers_i386_linux, -+ i386_num_regs, -+ i386_regmap, -+ i386_cannot_fetch_register, -+ i386_cannot_store_register, -+ i386_get_pc, -+ i386_set_pc, -+ i386_breakpoint, -+ i386_breakpoint_len, -+ NULL, -+ 1, -+ i386_breakpoint_at, -+ NULL, -+ NULL, -+ NULL, -+ NULL, -+ NULL, -+ NULL, -+}; -diff --git a/gdb/gdbserver/linux-x86-64-low.c b/gdb/gdbserver/linux-x86-64-low.c -new file mode 100644 -index 0000000..b8213f5 ---- /dev/null -+++ b/gdb/gdbserver/linux-x86-64-low.c -@@ -0,0 +1,184 @@ -+/* GNU/Linux/x86-64 specific low level interface, for the remote server -+ for GDB. -+ Copyright (C) 2002, 2004, 2005, 2006, 2007, 2008, 2009 -+ Free Software Foundation, Inc. -+ -+ This file is part of GDB. -+ -+ 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 "server.h" -+#include "linux-low.h" -+#include "i387-fp.h" -+ -+#include "gdb_proc_service.h" -+ -+/* Defined in auto-generated file reg-x86-64-linux.c. */ -+void init_registers_x86_64_linux (void); -+ -+#include -+#include -+#include -+ -+/* This definition comes from prctl.h, but some kernels may not have it. */ -+#ifndef PTRACE_ARCH_PRCTL -+#define PTRACE_ARCH_PRCTL 30 -+#endif -+ -+/* The following definitions come from prctl.h, but may be absent -+ for certain configurations. */ -+#ifndef ARCH_GET_FS -+#define ARCH_SET_GS 0x1001 -+#define ARCH_SET_FS 0x1002 -+#define ARCH_GET_FS 0x1003 -+#define ARCH_GET_GS 0x1004 -+#endif -+ -+static int x86_64_regmap[] = { -+ RAX * 8, RBX * 8, RCX * 8, RDX * 8, -+ RSI * 8, RDI * 8, RBP * 8, RSP * 8, -+ R8 * 8, R9 * 8, R10 * 8, R11 * 8, -+ R12 * 8, R13 * 8, R14 * 8, R15 * 8, -+ RIP * 8, EFLAGS * 8, CS * 8, SS * 8, -+ DS * 8, ES * 8, FS * 8, GS * 8, -+ -1, -1, -1, -1, -1, -1, -1, -1, -+ -1, -1, -1, -1, -1, -1, -1, -1, -+ -1, -1, -1, -1, -1, -1, -1, -1, -+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -+ ORIG_RAX * 8 -+}; -+ -+#define X86_64_NUM_GREGS (sizeof(x86_64_regmap)/sizeof(int)) -+ -+/* Called by libthread_db. */ -+ -+ps_err_e -+ps_get_thread_area (const struct ps_prochandle *ph, -+ lwpid_t lwpid, int idx, void **base) -+{ -+ switch (idx) -+ { -+ case FS: -+ if (ptrace (PTRACE_ARCH_PRCTL, lwpid, base, ARCH_GET_FS) == 0) -+ return PS_OK; -+ break; -+ case GS: -+ if (ptrace (PTRACE_ARCH_PRCTL, lwpid, base, ARCH_GET_GS) == 0) -+ return PS_OK; -+ break; -+ default: -+ return PS_BADADDR; -+ } -+ return PS_ERR; -+} -+ -+static void -+x86_64_fill_gregset (void *buf) -+{ -+ int i; -+ -+ for (i = 0; i < X86_64_NUM_GREGS; i++) -+ if (x86_64_regmap[i] != -1) -+ collect_register (i, ((char *) buf) + x86_64_regmap[i]); -+} -+ -+static void -+x86_64_store_gregset (const void *buf) -+{ -+ int i; -+ -+ for (i = 0; i < X86_64_NUM_GREGS; i++) -+ if (x86_64_regmap[i] != -1) -+ supply_register (i, ((char *) buf) + x86_64_regmap[i]); -+} -+ -+static void -+x86_64_fill_fpregset (void *buf) -+{ -+ i387_cache_to_fxsave (buf); -+} -+ -+static void -+x86_64_store_fpregset (const void *buf) -+{ -+ i387_fxsave_to_cache (buf); -+} -+ -+struct regset_info target_regsets[] = { -+ { PTRACE_GETREGS, PTRACE_SETREGS, sizeof (elf_gregset_t), -+ GENERAL_REGS, -+ x86_64_fill_gregset, x86_64_store_gregset }, -+ { PTRACE_GETFPREGS, PTRACE_SETFPREGS, sizeof (elf_fpregset_t), -+ FP_REGS, -+ x86_64_fill_fpregset, x86_64_store_fpregset }, -+ { 0, 0, -1, -1, NULL, NULL } -+}; -+ -+static const unsigned char x86_64_breakpoint[] = { 0xCC }; -+#define x86_64_breakpoint_len 1 -+ -+extern int debug_threads; -+ -+static CORE_ADDR -+x86_64_get_pc () -+{ -+ unsigned long pc; -+ -+ collect_register_by_name ("rip", &pc); -+ -+ if (debug_threads) -+ fprintf (stderr, "stop pc (before any decrement) is %08lx\n", pc); -+ return pc; -+} -+ -+static void -+x86_64_set_pc (CORE_ADDR newpc) -+{ -+ if (debug_threads) -+ fprintf (stderr, "set pc to %08lx\n", (long) newpc); -+ supply_register_by_name ("rip", &newpc); -+} -+ -+static int -+x86_64_breakpoint_at (CORE_ADDR pc) -+{ -+ unsigned char c; -+ -+ read_inferior_memory (pc, &c, 1); -+ if (c == 0xCC) -+ return 1; -+ -+ return 0; -+} -+ -+struct linux_target_ops the_low_target = { -+ init_registers_x86_64_linux, -+ -1, -+ NULL, -+ NULL, -+ NULL, -+ x86_64_get_pc, -+ x86_64_set_pc, -+ x86_64_breakpoint, -+ x86_64_breakpoint_len, -+ NULL, -+ 1, -+ x86_64_breakpoint_at, -+ NULL, -+ NULL, -+ NULL, -+ NULL, -+ NULL, -+ NULL, -+}; -diff --git a/gdb/gdbthread.h b/gdb/gdbthread.h -index 79d33fe..d3b4fa1 100644 ---- a/gdb/gdbthread.h -+++ b/gdb/gdbthread.h -@@ -185,6 +185,10 @@ struct thread_info - /* True if this thread has been explicitly requested to stop. */ - int stop_requested; - -+ /* The initiating frame of a nexting operation, used for deciding -+ which exceptions to intercept. */ -+ struct frame_id initiating_frame; -+ - /* Private data used by the target vector implementation. */ - struct private_thread_info *private; - }; -@@ -249,6 +253,9 @@ extern struct thread_info *any_thread_of_process (int pid); - /* Change the ptid of thread OLD_PTID to NEW_PTID. */ - void thread_change_ptid (ptid_t old_ptid, ptid_t new_ptid); - -+/* Prune dead threads from the list of threads. */ -+extern void prune_threads (void); -+ - /* Iterator function to call a user-provided callback function - once for each known thread. */ - typedef int (*thread_callback_func) (struct thread_info *, void *); -diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c -index 2f77dca..90abf2c 100644 ---- a/gdb/gdbtypes.c -+++ b/gdb/gdbtypes.c -@@ -38,6 +38,9 @@ - #include "cp-abi.h" - #include "gdb_assert.h" - #include "hashtab.h" -+#include "observer.h" -+#include "dwarf2expr.h" -+#include "dwarf2loc.h" - - - /* Floatformat pairs. */ -@@ -118,13 +121,31 @@ static void print_arg_types (struct field *, int, int); - static void dump_fn_fieldlists (struct type *, int); - static void print_cplus_stuff (struct type *, int); - -+/* A reference count structure for the type reference count map. Each -+ type in a hierarchy of types is mapped to the same reference -+ count. */ -+struct type_refc_entry -+{ -+ /* One type in the hierarchy. Each type in the hierarchy gets its -+ own slot. */ -+ struct type *type; -+ -+ /* A pointer to the shared reference count. */ -+ int *refc; -+}; -+ -+/* The hash table holding all discardable `struct type *' references. */ -+static htab_t type_discardable_table; -+ -+/* Current type_discardable_check pass used for TYPE_DISCARDABLE_AGE. */ -+static int type_discardable_age_current; - - /* Allocate a new OBJFILE-associated type structure and fill it - with some defaults. Space for the type structure is allocated - on the objfile's objfile_obstack. */ - - struct type * --alloc_type (struct objfile *objfile) -+alloc_type (struct objfile *objfile, struct type *parent) - { - struct type *type; - -@@ -148,6 +169,39 @@ alloc_type (struct objfile *objfile) - return type; - } - -+/* Declare TYPE as discardable on next garbage collection by free_all_types. -+ You must call type_mark_used during each free_all_types to protect TYPE from -+ being deallocated. */ -+ -+static void -+set_type_as_discardable (struct type *type) -+{ -+ void **slot; -+ -+ gdb_assert (!TYPE_DISCARDABLE (type)); -+ -+ TYPE_DISCARDABLE (type) = 1; -+ TYPE_DISCARDABLE_AGE (type) = type_discardable_age_current; -+ -+ slot = htab_find_slot (type_discardable_table, type, INSERT); -+ gdb_assert (!*slot); -+ *slot = type; -+} -+ -+/* Allocate a new type like alloc_type but preserve for it the discardability -+ state of PARENT_TYPE. */ -+ -+static struct type * -+alloc_type_as_parent (struct type *parent_type) -+{ -+ struct type *new_type = alloc_type_copy (parent_type); -+ -+ if (TYPE_DISCARDABLE (parent_type)) -+ set_type_as_discardable (new_type); -+ -+ return new_type; ++ return new_type; +} + /* Allocate a new GDBARCH-associated type structure and fill it with some defaults. Space for the type structure is allocated on the heap. */ -@@ -184,7 +238,7 @@ struct type * - alloc_type_copy (const struct type *type) - { - if (TYPE_OBJFILE_OWNED (type)) -- return alloc_type (TYPE_OWNER (type).objfile); -+ return alloc_type (TYPE_OWNER (type).objfile, (struct type *) type); - else - return alloc_type_arch (TYPE_OWNER (type).gdbarch); - } -@@ -273,7 +327,7 @@ make_pointer_type (struct type *type, struct type **typeptr) +@@ -278,7 +319,7 @@ make_pointer_type (struct type *type, struct type **typeptr) if (typeptr == 0 || *typeptr == 0) /* We'll need to allocate one. */ { @@ -9994,7 +6253,7 @@ index 2f77dca..90abf2c 100644 if (typeptr) *typeptr = ntype; } -@@ -350,7 +404,7 @@ make_reference_type (struct type *type, struct type **typeptr) +@@ -355,7 +396,7 @@ make_reference_type (struct type *type, struct type **typeptr) if (typeptr == 0 || *typeptr == 0) /* We'll need to allocate one. */ { @@ -10003,22 +6262,15 @@ index 2f77dca..90abf2c 100644 if (typeptr) *typeptr = ntype; } -@@ -721,12 +775,13 @@ create_range_type (struct type *result_type, struct type *index_type, - TYPE_TARGET_STUB (result_type) = 1; - else - TYPE_LENGTH (result_type) = TYPE_LENGTH (check_typedef (index_type)); -- TYPE_NFIELDS (result_type) = 2; -+ TYPE_NFIELDS (result_type) = 3; - TYPE_FIELDS (result_type) = TYPE_ZALLOC (result_type, - TYPE_NFIELDS (result_type) - * sizeof (struct field)); +@@ -726,6 +767,7 @@ create_range_type (struct type *result_type, struct type *index_type, + TYPE_ZALLOC (result_type, sizeof (struct range_bounds)); TYPE_LOW_BOUND (result_type) = low_bound; TYPE_HIGH_BOUND (result_type) = high_bound; + TYPE_BYTE_STRIDE (result_type) = 0; if (low_bound >= 0) TYPE_UNSIGNED (result_type) = 1; -@@ -826,26 +881,45 @@ create_array_type (struct type *result_type, +@@ -825,26 +867,45 @@ create_array_type (struct type *result_type, TYPE_CODE (result_type) = TYPE_CODE_ARRAY; TYPE_TARGET_TYPE (result_type) = element_type; @@ -10043,10 +6295,10 @@ index 2f77dca..90abf2c 100644 + /* DWARF blocks may depend on runtime information like + DW_OP_PUSH_OBJECT_ADDRESS not being available during the + CREATE_ARRAY_TYPE time. */ -+ if (TYPE_RANGE_BOUND_IS_DWARF_BLOCK (range_type, 0) -+ || TYPE_RANGE_BOUND_IS_DWARF_BLOCK (range_type, 1) -+ || TYPE_RANGE_UPPER_BOUND_IS_UNDEFINED (range_type) -+ || TYPE_RANGE_LOWER_BOUND_IS_UNDEFINED (range_type) ++ if (TYPE_RANGE_DATA (range_type)->low.kind != RANGE_BOUND_KIND_CONSTANT ++ || TYPE_RANGE_DATA (range_type)->high.kind != RANGE_BOUND_KIND_CONSTANT ++ || TYPE_LOW_BOUND_UNDEFINED (range_type) ++ || TYPE_HIGH_BOUND_UNDEFINED (range_type) + || get_discrete_bounds (range_type, &low_bound, &high_bound) < 0) + { + low_bound = 0; @@ -10077,7 +6329,7 @@ index 2f77dca..90abf2c 100644 return result_type; } -@@ -1331,6 +1405,84 @@ stub_noname_complaint (void) +@@ -1353,6 +1414,105 @@ stub_noname_complaint (void) complaint (&symfile_complaints, _("stub type has NULL name")); } @@ -10089,13 +6341,12 @@ index 2f77dca..90abf2c 100644 + cleared FULL_SPAN return value (the expected SIZEOF) for non-zero + TYPE_BYTE_STRIDE values. */ + -+static CORE_ADDR ++static LONGEST +type_length_get (struct type *type, struct type *target_type, int full_span) +{ + struct type *range_type; -+ int count; -+ CORE_ADDR byte_stride = 0; /* `= 0' for a false GCC warning. */ -+ CORE_ADDR element_size; ++ LONGEST byte_stride = 0; /* `= 0' for a false GCC warning. */ ++ LONGEST count, element_size, retval; + + if (TYPE_CODE (type) != TYPE_CODE_ARRAY + && TYPE_CODE (type) != TYPE_CODE_STRING) @@ -10108,15 +6359,15 @@ index 2f77dca..90abf2c 100644 + return 0; + + range_type = TYPE_INDEX_TYPE (type); -+ if (TYPE_RANGE_LOWER_BOUND_IS_UNDEFINED (range_type) -+ || TYPE_RANGE_UPPER_BOUND_IS_UNDEFINED (range_type)) ++ if (TYPE_LOW_BOUND_UNDEFINED (range_type) ++ || TYPE_HIGH_BOUND_UNDEFINED (range_type)) + return 0; + count = TYPE_HIGH_BOUND (range_type) - TYPE_LOW_BOUND (range_type) + 1; + /* It may happen for wrong DWARF annotations returning garbage data. */ + if (count < 0) -+ warning (_("Range for type %s has invalid bounds %d..%d"), -+ TYPE_NAME (type), TYPE_LOW_BOUND (range_type), -+ TYPE_HIGH_BOUND (range_type)); ++ warning (_("Range for type %s has invalid bounds %s..%s"), ++ TYPE_NAME (type), plongest (TYPE_LOW_BOUND (range_type)), ++ plongest (TYPE_HIGH_BOUND (range_type))); + /* The code below does not handle count == 0 right. */ + if (count <= 0) + return 0; @@ -10132,12 +6383,34 @@ index 2f77dca..90abf2c 100644 + byte_stride = type_length_get (target_type, NULL, 1); + } + } ++ ++ /* For now, we conservatively take the array length to be 0 if its length ++ exceeds UINT_MAX. The code below assumes that for x < 0, ++ (ULONGEST) x == -x + ULONGEST_MAX + 1, which is technically not guaranteed ++ by C, but is usually true (because it would be true if x were unsigned ++ with its high-order bit on). It uses the fact that high_bound-low_bound is ++ always representable in ULONGEST and that if high_bound-low_bound+1 ++ overflows, it overflows to 0. We must change these tests if we decide to ++ increase the representation of TYPE_LENGTH from unsigned int to ULONGEST. ++ */ ++ + if (full_span) -+ return count * byte_stride; ++ { ++ retval = count * byte_stride; ++ if (count == 0 || retval / count != byte_stride || retval > UINT_MAX) ++ retval = 0; ++ return retval; ++ } + if (target_type == NULL) + target_type = check_typedef (TYPE_TARGET_TYPE (type)); + element_size = type_length_get (target_type, NULL, 1); -+ return (count - 1) * byte_stride + element_size; ++ retval = (count - 1) * byte_stride + element_size; ++ if (retval < element_size ++ || (byte_stride != 0 ++ && (retval - element_size) / byte_stride != count - 1) ++ || retval > UINT_MAX) ++ retval = 0; ++ return retval; +} + +/* Prepare TYPE after being read in by the backend. Currently this function @@ -10162,17 +6435,7 @@ index 2f77dca..90abf2c 100644 /* Added by Bryan Boreham, Kewill, Sun Sep 17 18:07:17 1989. If this is a stubbed struct (i.e. declared as struct foo *), see if -@@ -1347,7 +1499,8 @@ stub_noname_complaint (void) - /* Find the real type of TYPE. This function returns the real type, - after removing all layers of typedefs and completing opaque or stub - types. Completion changes the TYPE argument, but stripping of -- typedefs does not. */ -+ typedefs does not. Still original passed TYPE will have TYPE_LENGTH -+ updated. FIXME: Remove this dependency (only ada_to_fixed_type?). */ - - struct type * - check_typedef (struct type *type) -@@ -1457,34 +1610,37 @@ check_typedef (struct type *type) +@@ -1486,52 +1646,36 @@ check_typedef (struct type *type) } } @@ -10191,8 +6454,7 @@ index 2f77dca..90abf2c 100644 + gdb_assert (TYPE_DYNAMIC (type) == 0); + } + -+ if (!currently_reading_symtab -+ && (TYPE_TARGET_STUB (type) || TYPE_DYNAMIC (type))) ++ if (TYPE_TARGET_STUB (type) || TYPE_DYNAMIC (type)) { - struct type *range_type; struct type *target_type = check_typedef (TYPE_TARGET_TYPE (type)); @@ -10212,23 +6474,41 @@ index 2f77dca..90abf2c 100644 /* Now recompute the length of the array type, based on its - number of elements and the target type's length. - Watch out for Ada null Ada arrays where the high bound -- is smaller than the low bound. */ -- const int low_bound = TYPE_LOW_BOUND (range_type); -- const int high_bound = TYPE_HIGH_BOUND (range_type); -- int nb_elements; -- +- is smaller than the low bound. */ +- const LONGEST low_bound = TYPE_LOW_BOUND (range_type); +- const LONGEST high_bound = TYPE_HIGH_BOUND (range_type); +- ULONGEST len; +- - if (high_bound < low_bound) -- nb_elements = 0; +- len = 0; - else -- nb_elements = high_bound - low_bound + 1; -- -- TYPE_LENGTH (type) = nb_elements * TYPE_LENGTH (target_type); +- { +- /* For now, we conservatively take the array length to be 0 +- if its length exceeds UINT_MAX. The code below assumes +- that for x < 0, (ULONGEST) x == -x + ULONGEST_MAX + 1, +- which is technically not guaranteed by C, but is usually true +- (because it would be true if x were unsigned with its +- high-order bit on). It uses the fact that +- high_bound-low_bound is always representable in +- ULONGEST and that if high_bound-low_bound+1 overflows, +- it overflows to 0. We must change these tests if we +- decide to increase the representation of TYPE_LENGTH +- from unsigned int to ULONGEST. */ +- ULONGEST ulow = low_bound, uhigh = high_bound; +- ULONGEST tlen = TYPE_LENGTH (target_type); +- +- len = tlen * (uhigh - ulow + 1); +- if (tlen == 0 || (len / tlen - 1 + ulow) != uhigh +- || len > UINT_MAX) +- len = 0; +- } +- TYPE_LENGTH (type) = len; + number of elements and the target type's length. */ + TYPE_LENGTH (type) = type_length_get (type, target_type, 0); TYPE_TARGET_STUB (type) = 0; } else if (TYPE_CODE (type) == TYPE_CODE_RANGE) -@@ -1492,9 +1648,12 @@ check_typedef (struct type *type) +@@ -1539,9 +1683,12 @@ check_typedef (struct type *type) TYPE_LENGTH (type) = TYPE_LENGTH (target_type); TYPE_TARGET_STUB (type) = 0; } @@ -10241,37 +6521,16 @@ index 2f77dca..90abf2c 100644 return type; } -@@ -1716,7 +1875,7 @@ init_type (enum type_code code, int length, int flags, - { - struct type *type; - -- type = alloc_type (objfile); -+ type = alloc_type (objfile, NULL); - TYPE_CODE (type) = code; - TYPE_LENGTH (type) = length; - -@@ -1760,6 +1919,10 @@ init_type (enum type_code code, int length, int flags, - { - INIT_CPLUS_SPECIFIC (type); - } -+ -+ if (!objfile) -+ type_incref (type); -+ - return type; - } +@@ -1811,6 +1958,8 @@ init_type (enum type_code code, int length, int flags, + TYPE_NOTTEXT (type) = 1; + if (flags & TYPE_FLAG_FIXED_INSTANCE) + TYPE_FIXED_INSTANCE (type) = 1; ++ if (flags & TYPE_FLAG_GNU_IFUNC) ++ TYPE_GNU_IFUNC (type) = 1; -@@ -2004,7 +2167,8 @@ rank_one_type (struct type *parm, struct type *arg) - switch (TYPE_CODE (arg)) - { - case TYPE_CODE_PTR: -- if (TYPE_CODE (TYPE_TARGET_TYPE (parm)) == TYPE_CODE_VOID) -+ if (TYPE_CODE (TYPE_TARGET_TYPE (parm)) == TYPE_CODE_VOID -+ && TYPE_CODE (TYPE_TARGET_TYPE (arg)) != TYPE_CODE_VOID) - return VOID_PTR_CONVERSION_BADNESS; - else - return rank_one_type (TYPE_TARGET_TYPE (parm), -@@ -2820,33 +2984,42 @@ type_pair_eq (const void *item_lhs, const void *item_rhs) + if (name) + TYPE_NAME (type) = obsavestring (name, strlen (name), +@@ -3006,33 +3155,42 @@ type_pair_eq (const void *item_lhs, const void *item_rhs) } /* Allocate the hash table used by copy_type_recursive to walk @@ -10329,7 +6588,7 @@ index 2f77dca..90abf2c 100644 return type; /* This type shouldn't be pointing to any types in other objfiles; -@@ -2861,8 +3034,10 @@ copy_type_recursive (struct objfile *objfile, +@@ -3047,8 +3205,10 @@ copy_type_recursive (struct objfile *objfile, new_type = alloc_type_arch (get_type_arch (type)); /* We must add the new type to the hash table immediately, in case @@ -10342,7 +6601,7 @@ index 2f77dca..90abf2c 100644 stored->old = type; stored->new = new_type; *slot = stored; -@@ -2873,6 +3048,19 @@ copy_type_recursive (struct objfile *objfile, +@@ -3059,6 +3219,19 @@ copy_type_recursive (struct objfile *objfile, TYPE_OBJFILE_OWNED (new_type) = 0; TYPE_OWNER (new_type).gdbarch = get_type_arch (type); @@ -10362,7 +6621,7 @@ index 2f77dca..90abf2c 100644 if (TYPE_NAME (type)) TYPE_NAME (new_type) = xstrdup (TYPE_NAME (type)); if (TYPE_TAG_NAME (type)) -@@ -2881,12 +3069,45 @@ copy_type_recursive (struct objfile *objfile, +@@ -3067,12 +3240,48 @@ copy_type_recursive (struct objfile *objfile, TYPE_INSTANCE_FLAGS (new_type) = TYPE_INSTANCE_FLAGS (type); TYPE_LENGTH (new_type) = TYPE_LENGTH (type); @@ -10403,12 +6662,15 @@ index 2f77dca..90abf2c 100644 { int i, nfields; ++ /* TYPE_CODE_RANGE uses TYPE_RANGE_DATA of the union with TYPE_FIELDS. */ ++ gdb_assert (TYPE_CODE (type) != TYPE_CODE_RANGE); ++ nfields = TYPE_NFIELDS (type); + TYPE_NFIELDS (new_type) = nfields; TYPE_FIELDS (new_type) = XCALLOC (nfields, struct field); for (i = 0; i < nfields; i++) { -@@ -2895,8 +3116,8 @@ copy_type_recursive (struct objfile *objfile, +@@ -3081,8 +3290,8 @@ copy_type_recursive (struct objfile *objfile, TYPE_FIELD_BITSIZE (new_type, i) = TYPE_FIELD_BITSIZE (type, i); if (TYPE_FIELD_TYPE (type, i)) TYPE_FIELD_TYPE (new_type, i) @@ -10419,40 +6681,160 @@ index 2f77dca..90abf2c 100644 if (TYPE_FIELD_NAME (type, i)) TYPE_FIELD_NAME (new_type, i) = xstrdup (TYPE_FIELD_NAME (type, i)); -@@ -2915,6 +3136,16 @@ copy_type_recursive (struct objfile *objfile, - xstrdup (TYPE_FIELD_STATIC_PHYSNAME (type, - i))); - break; -+ case FIELD_LOC_KIND_DWARF_BLOCK: -+ /* `struct dwarf2_locexpr_baton' is too bound to its objfile so -+ it is expected to be made constant by CHECK_TYPEDEF. */ -+ if (TYPE_NOT_ALLOCATED (new_type) -+ || TYPE_NOT_ASSOCIATED (new_type)) -+ SET_FIELD_DWARF_BLOCK (TYPE_FIELD (new_type, i), NULL); -+ else -+ SET_FIELD_BITPOS (TYPE_FIELD (new_type, i), -+ dwarf_locexpr_baton_eval (TYPE_FIELD_DWARF_BLOCK (type, i))); -+ break; - default: - internal_error (__FILE__, __LINE__, - _("Unexpected type field location kind: %d"), -@@ -2923,17 +3154,30 @@ copy_type_recursive (struct objfile *objfile, +@@ -3109,24 +3318,166 @@ copy_type_recursive (struct objfile *objfile, } } -+ /* Convert TYPE_RANGE_HIGH_BOUND_IS_COUNT into a regular bound. */ -+ if (TYPE_CODE (type) == TYPE_CODE_RANGE -+ && TYPE_RANGE_HIGH_BOUND_IS_COUNT (type)) -+ { -+ TYPE_RANGE_HIGH_BOUND_IS_COUNT (new_type) = 0; -+ TYPE_HIGH_BOUND (new_type) = TYPE_LOW_BOUND (type) -+ + TYPE_HIGH_BOUND (type) - 1; -+ } -+ + /* Both FIELD_LOC_KIND_DWARF_BLOCK and TYPE_RANGE_HIGH_BOUND_IS_COUNT were + possibly converted. */ + TYPE_DYNAMIC (new_type) = 0; + + /* For range types, copy the bounds information. */ +- if (TYPE_CODE (type) == TYPE_CODE_RANGE) ++ if (TYPE_CODE (new_type) == TYPE_CODE_RANGE) + { + TYPE_RANGE_DATA (new_type) = xmalloc (sizeof (struct range_bounds)); + *TYPE_RANGE_DATA (new_type) = *TYPE_RANGE_DATA (type); ++ ++ switch (TYPE_RANGE_DATA (new_type)->low.kind) ++ { ++ case RANGE_BOUND_KIND_CONSTANT: ++ break; ++ case RANGE_BOUND_KIND_DWARF_BLOCK: ++ /* `struct dwarf2_locexpr_baton' is too bound to its objfile so ++ it is expected to be made constant by CHECK_TYPEDEF. ++ TYPE_NOT_ALLOCATED and TYPE_NOT_ASSOCIATED are not valid for TYPE. ++ */ ++ if (TYPE_NOT_ALLOCATED (new_type) || TYPE_NOT_ASSOCIATED (new_type) ++ || ! has_stack_frames ()) ++ { ++ /* We should set 1 for Fortran but how to find the language? */ ++ TYPE_LOW_BOUND (new_type) = 0; ++ TYPE_LOW_BOUND_UNDEFINED (new_type) = 1; ++ } ++ else ++ TYPE_LOW_BOUND (new_type) = dwarf_locexpr_baton_eval ++ (TYPE_RANGE_DATA (new_type)->low.u.dwarf_block); ++ TYPE_RANGE_DATA (new_type)->low.kind = RANGE_BOUND_KIND_CONSTANT; ++ break; ++ case RANGE_BOUND_KIND_DWARF_LOCLIST: ++ { ++ CORE_ADDR addr; ++ ++ /* `struct dwarf2_loclist_baton' is too bound to its objfile so ++ it is expected to be made constant by CHECK_TYPEDEF. ++ TYPE_NOT_ALLOCATED and TYPE_NOT_ASSOCIATED are not valid for TYPE. ++ */ ++ if (! TYPE_NOT_ALLOCATED (new_type) ++ && ! TYPE_NOT_ASSOCIATED (new_type) && has_stack_frames () ++ && dwarf_loclist_baton_eval ++ (TYPE_RANGE_DATA (new_type)->low.u.dwarf_loclist.loclist, ++ TYPE_RANGE_DATA (new_type)->low.u.dwarf_loclist.type, &addr)) ++ TYPE_LOW_BOUND (new_type) = addr; ++ else ++ { ++ /* We should set 1 for Fortran but how to find the language? */ ++ TYPE_LOW_BOUND (new_type) = 0; ++ TYPE_LOW_BOUND_UNDEFINED (new_type) = 1; ++ } ++ TYPE_RANGE_DATA (new_type)->low.kind = RANGE_BOUND_KIND_CONSTANT; ++ } ++ break; ++ } ++ ++ switch (TYPE_RANGE_DATA (new_type)->high.kind) ++ { ++ case RANGE_BOUND_KIND_CONSTANT: ++ break; ++ case RANGE_BOUND_KIND_DWARF_BLOCK: ++ /* `struct dwarf2_locexpr_baton' is too bound to its objfile so ++ it is expected to be made constant by CHECK_TYPEDEF. ++ TYPE_NOT_ALLOCATED and TYPE_NOT_ASSOCIATED are not valid for TYPE. ++ */ ++ if (TYPE_NOT_ALLOCATED (new_type) || TYPE_NOT_ASSOCIATED (new_type) ++ || ! has_stack_frames ()) ++ { ++ TYPE_HIGH_BOUND (new_type) = TYPE_LOW_BOUND (new_type) - 1; ++ TYPE_HIGH_BOUND_UNDEFINED (new_type) = 1; ++ } ++ else ++ TYPE_HIGH_BOUND (new_type) = dwarf_locexpr_baton_eval ++ (TYPE_RANGE_DATA (new_type)->high.u.dwarf_block); ++ TYPE_RANGE_DATA (new_type)->high.kind = RANGE_BOUND_KIND_CONSTANT; ++ break; ++ case RANGE_BOUND_KIND_DWARF_LOCLIST: ++ { ++ CORE_ADDR addr; ++ ++ /* `struct dwarf2_loclist_baton' is too bound to its objfile so ++ it is expected to be made constant by CHECK_TYPEDEF. ++ TYPE_NOT_ALLOCATED and TYPE_NOT_ASSOCIATED are not valid for TYPE. ++ */ ++ if (! TYPE_NOT_ALLOCATED (new_type) ++ && ! TYPE_NOT_ASSOCIATED (new_type) && has_stack_frames () ++ && dwarf_loclist_baton_eval ++ (TYPE_RANGE_DATA (new_type)->high.u.dwarf_loclist.loclist, ++ TYPE_RANGE_DATA (new_type)->high.u.dwarf_loclist.type, ++ &addr)) ++ TYPE_HIGH_BOUND (new_type) = addr; ++ else ++ { ++ TYPE_HIGH_BOUND (new_type) = TYPE_LOW_BOUND (new_type) - 1; ++ TYPE_HIGH_BOUND_UNDEFINED (new_type) = 1; ++ } ++ TYPE_RANGE_DATA (new_type)->high.kind = RANGE_BOUND_KIND_CONSTANT; ++ } ++ break; ++ } ++ ++ switch (TYPE_RANGE_DATA (new_type)->byte_stride.kind) ++ { ++ case RANGE_BOUND_KIND_CONSTANT: ++ break; ++ case RANGE_BOUND_KIND_DWARF_BLOCK: ++ /* `struct dwarf2_locexpr_baton' is too bound to its objfile so ++ it is expected to be made constant by CHECK_TYPEDEF. ++ TYPE_NOT_ALLOCATED and TYPE_NOT_ASSOCIATED are not valid for TYPE. ++ */ ++ if (TYPE_NOT_ALLOCATED (new_type) || TYPE_NOT_ASSOCIATED (new_type) ++ || ! has_stack_frames ()) ++ TYPE_BYTE_STRIDE (new_type) = 0; ++ else ++ TYPE_BYTE_STRIDE (new_type) = dwarf_locexpr_baton_eval ++ (TYPE_RANGE_DATA (new_type)->byte_stride.u.dwarf_block); ++ TYPE_RANGE_DATA (new_type)->byte_stride.kind ++ = RANGE_BOUND_KIND_CONSTANT; ++ break; ++ case RANGE_BOUND_KIND_DWARF_LOCLIST: ++ { ++ CORE_ADDR addr = 0; ++ ++ /* `struct dwarf2_loclist_baton' is too bound to its objfile so ++ it is expected to be made constant by CHECK_TYPEDEF. ++ TYPE_NOT_ALLOCATED and TYPE_NOT_ASSOCIATED are not valid for TYPE. ++ */ ++ if (! TYPE_NOT_ALLOCATED (new_type) ++ && ! TYPE_NOT_ASSOCIATED (new_type) && has_stack_frames ()) ++ dwarf_loclist_baton_eval ++ (TYPE_RANGE_DATA (new_type)->byte_stride.u.dwarf_loclist.loclist, ++ TYPE_RANGE_DATA (new_type)->byte_stride.u.dwarf_loclist.type, ++ &addr); ++ TYPE_BYTE_STRIDE (new_type) = addr; ++ TYPE_RANGE_DATA (new_type)->byte_stride.kind ++ = RANGE_BOUND_KIND_CONSTANT; ++ } ++ break; ++ } ++ ++ /* Convert TYPE_RANGE_HIGH_BOUND_IS_COUNT into a regular bound. */ ++ if (TYPE_RANGE_HIGH_BOUND_IS_COUNT (new_type)) ++ { ++ TYPE_HIGH_BOUND (new_type) = TYPE_LOW_BOUND (new_type) ++ + TYPE_HIGH_BOUND (new_type) - 1; ++ TYPE_RANGE_HIGH_BOUND_IS_COUNT (new_type) = 0; ++ } + } + /* Copy pointers to other types. */ if (TYPE_TARGET_TYPE (type)) TYPE_TARGET_TYPE (new_type) = @@ -10473,7 +6855,7 @@ index 2f77dca..90abf2c 100644 /* Maybe copy the type_specific bits. NOTE drow/2005-12-09: We do not copy the C++-specific bits like -@@ -2951,6 +3195,17 @@ copy_type_recursive (struct objfile *objfile, +@@ -3143,6 +3494,17 @@ copy_type_recursive (struct objfile *objfile, return new_type; } @@ -10491,7 +6873,7 @@ index 2f77dca..90abf2c 100644 /* Make a copy of the given TYPE, except that the pointer & reference types are not preserved. -@@ -2973,6 +3228,217 @@ copy_type (const struct type *type) +@@ -3165,6 +3527,199 @@ copy_type (const struct type *type) return new_type; } @@ -10520,7 +6902,7 @@ index 2f77dca..90abf2c 100644 + /* `struct cplus_struct_type' handling is unsupported by this function. */ + gdb_assert ((TYPE_CODE (type) != TYPE_CODE_STRUCT + && TYPE_CODE (type) != TYPE_CODE_UNION) -+ || !HAVE_CPLUS_STRUCT (type) || !TYPE_CPLUS_SPECIFIC (type)); ++ || !HAVE_CPLUS_STRUCT (type)); + + if (!(*iter) (type, data)) + return; @@ -10568,10 +6950,7 @@ index 2f77dca..90abf2c 100644 + } + xfree (TYPE_FIELDS (type)); + -+ /* `struct cplus_struct_type' handling is unsupported by this function. */ -+ gdb_assert ((TYPE_CODE (type) != TYPE_CODE_STRUCT -+ && TYPE_CODE (type) != TYPE_CODE_UNION) -+ || !HAVE_CPLUS_STRUCT (type) || !TYPE_CPLUS_SPECIFIC (type)); ++ gdb_assert (!HAVE_CPLUS_STRUCT (type)); + + xfree (TYPE_MAIN_TYPE (type)); +} @@ -10652,21 +7031,6 @@ index 2f77dca..90abf2c 100644 + main_type_crawl (type, type_mark_used_crawl, NULL); +} + -+/* Increment the reference count for TYPE. */ -+ -+void -+type_incref (struct type *type) -+{ -+} -+ -+/* Decrement the reference count for TYPE. If TYPE has no more -+ references, delete it. */ -+ -+void -+type_decref (struct type *type) -+{ -+} -+ +/* A traverse callback for type_discardable_table which removes any + type_discardable whose reference count is now zero (unused link). */ + @@ -10709,7 +7073,35 @@ index 2f77dca..90abf2c 100644 /* Helper functions to initialize architecture-specific types. */ -@@ -3463,6 +3929,11 @@ void +@@ -3511,6 +4066,8 @@ gdbtypes_post_init (struct gdbarch *gdbarch) + = lookup_pointer_type (builtin_type->builtin_void); + builtin_type->builtin_func_ptr + = lookup_pointer_type (lookup_function_type (builtin_type->builtin_void)); ++ builtin_type->builtin_func_func ++ = lookup_function_type (builtin_type->builtin_func_ptr); + + /* This type represents a GDB internal function. */ + builtin_type->internal_fn +@@ -3624,6 +4181,18 @@ objfile_type (struct objfile *objfile) + "", objfile); + TYPE_TARGET_TYPE (objfile_type->nodebug_text_symbol) + = objfile_type->builtin_int; ++ objfile_type->nodebug_text_gnu_ifunc_symbol ++ = init_type (TYPE_CODE_FUNC, 1, TYPE_FLAG_GNU_IFUNC, ++ "", ++ objfile); ++ TYPE_TARGET_TYPE (objfile_type->nodebug_text_gnu_ifunc_symbol) ++ = objfile_type->nodebug_text_symbol; ++ objfile_type->nodebug_got_plt_symbol ++ = init_type (TYPE_CODE_PTR, gdbarch_addr_bit (gdbarch) / 8, 0, ++ "", ++ objfile); ++ TYPE_TARGET_TYPE (objfile_type->nodebug_got_plt_symbol) ++ = objfile_type->nodebug_text_symbol; + objfile_type->nodebug_data_symbol + = init_type (TYPE_CODE_INT, + gdbarch_int_bit (gdbarch) / HOST_CHAR_BIT, 0, +@@ -3678,6 +4247,11 @@ void _initialize_gdbtypes (void) { gdbtypes_data = gdbarch_data_register_post_init (gdbtypes_post_init); @@ -10722,19 +7114,18 @@ index 2f77dca..90abf2c 100644 add_setshow_zinteger_cmd ("overload", no_class, &overload_debug, _("\ diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h -index be6ed55..6a51a4e 100644 +index 085270e..cb2b88e 100644 --- a/gdb/gdbtypes.h +++ b/gdb/gdbtypes.h -@@ -137,6 +137,8 @@ enum type_code +@@ -171,6 +171,7 @@ enum type_flag_value + TYPE_FLAG_FIXED_INSTANCE = (1 << 15), + TYPE_FLAG_STUB_SUPPORTED = (1 << 16), + TYPE_FLAG_NOTTEXT = (1 << 17), ++ TYPE_FLAG_GNU_IFUNC = (1 << 18), - TYPE_CODE_DECFLOAT, /* Decimal floating point. */ - -+ TYPE_CODE_MODULE, /* Fortran module. */ -+ - /* Internal function type. */ - TYPE_CODE_INTERNAL_FUNCTION - }; -@@ -213,6 +215,11 @@ enum type_instance_flag_value + /* Used for error-checking. */ + TYPE_FLAG_MIN = TYPE_FLAG_UNSIGNED +@@ -214,6 +215,11 @@ enum type_instance_flag_value #define TYPE_TARGET_STUB(t) (TYPE_MAIN_TYPE (t)->flag_target_stub) @@ -10746,9 +7137,22 @@ index be6ed55..6a51a4e 100644 /* Static type. If this is set, the corresponding type had * a static modifier. * Note: This may be unnecessary, since static data members -@@ -278,6 +285,48 @@ enum type_instance_flag_value - #define TYPE_OWNER(t) TYPE_MAIN_TYPE(t)->owner - #define TYPE_OBJFILE(t) (TYPE_OBJFILE_OWNED(t)? TYPE_OWNER(t).objfile : NULL) +@@ -271,6 +277,12 @@ enum type_instance_flag_value + + #define TYPE_NOTTEXT(t) (TYPE_MAIN_TYPE (t)->flag_nottext) + ++/* Used only for TYPE_CODE_FUNC where it specifies the real function ++ address is returned by this function call. TYPE_TARGET_TYPE determines the ++ final returned function type to be presented to user. */ ++ ++#define TYPE_GNU_IFUNC(t) (TYPE_MAIN_TYPE (t)->flag_gnu_ifunc) ++ + /* Type owner. If TYPE_OBJFILE_OWNED is true, the type is owned by + the objfile retrieved as TYPE_OBJFILE. Otherweise, the type is + owned by an architecture; TYPE_OBJFILE is NULL in this case. */ +@@ -285,6 +297,48 @@ enum type_instance_flag_value + + #define TYPE_DECLARED_CLASS(t) (TYPE_MAIN_TYPE (t)->flag_declared_class) +/* Define this type as being reclaimable during free_all_types. Type is + required to be have TYPE_OBJFILE set to NULL. Setting this flag requires @@ -10795,10 +7199,16 @@ index be6ed55..6a51a4e 100644 /* Constant type. If this is set, the corresponding type has a * const modifier. */ -@@ -365,6 +414,13 @@ struct main_type +@@ -389,11 +443,19 @@ struct main_type + unsigned int flag_vector : 1; + unsigned int flag_stub_supported : 1; unsigned int flag_nottext : 1; ++ unsigned int flag_gnu_ifunc : 1; unsigned int flag_fixed_instance : 1; unsigned int flag_objfile_owned : 1; + /* True if this type was declared with "class" rather than + "struct". */ + unsigned int flag_declared_class : 1; + unsigned int flag_discardable : 1; + unsigned int flag_discardable_age : 1; + unsigned int flag_dynamic : 1; @@ -10807,9 +7217,9 @@ index be6ed55..6a51a4e 100644 + unsigned int flag_not_associated : 1; + unsigned int flag_data_location_is_addr : 1; - /* Number of fields described for this type. This field appears at - this location because it packs nicely here. */ -@@ -431,6 +487,20 @@ struct main_type + /* A discriminant telling us which field of the type_specific union + is being used for this type, if any. */ +@@ -467,6 +529,20 @@ struct main_type struct type *target_type; @@ -10830,17 +7240,47 @@ index be6ed55..6a51a4e 100644 /* For structure and union types, a description of each field. For set and pascal array types, there is one "field", whose type is the domain type of the set or array. -@@ -538,6 +608,9 @@ struct main_type - supporting multiple ABIs. Right now this is only fetched from - the Dwarf-2 DW_AT_calling_convention attribute. */ - unsigned calling_convention; -+ -+ /* For TYPE_CODE_MODULE, the list of symbols contained in the module. */ -+ struct block *module_block; - } type_specific; - }; +@@ -540,13 +616,34 @@ struct main_type + + struct range_bounds + { ++ struct ++ { ++ union ++ { ++ LONGEST constant; ++ struct dwarf2_locexpr_baton *dwarf_block; ++ struct ++ { ++ struct dwarf2_loclist_baton *loclist; ++ struct type *type; ++ } ++ dwarf_loclist; ++ } ++ u; ++ enum range_bound_kind ++ { ++ RANGE_BOUND_KIND_CONSTANT, ++ RANGE_BOUND_KIND_DWARF_BLOCK, ++ RANGE_BOUND_KIND_DWARF_LOCLIST ++ } ++ kind; ++ } + /* Low bound of range. */ +- +- LONGEST low; +- ++ low, + /* High bound of range. */ +- +- LONGEST high; ++ high, ++ /* Byte stride of range. */ ++ byte_stride; -@@ -812,9 +885,9 @@ extern void allocate_cplus_struct_type (struct type *); + /* Flags indicating whether the values of low and high are + valid. When true, the respective range value is +@@ -889,9 +986,9 @@ extern void allocate_gnat_aux_type (struct type *); #define TYPE_POINTER_TYPE(thistype) (thistype)->pointer_type #define TYPE_REFERENCE_TYPE(thistype) (thistype)->reference_type #define TYPE_CHAIN(thistype) (thistype)->chain @@ -10853,52 +7293,32 @@ index be6ed55..6a51a4e 100644 calls check_typedef, TYPE_LENGTH (VALUE_TYPE (X)) is safe. */ #define TYPE_LENGTH(thistype) (thistype)->length /* Note that TYPE_CODE can be TYPE_CODE_TYPEDEF, so if you want the real -@@ -823,23 +896,44 @@ extern void allocate_cplus_struct_type (struct type *); +@@ -899,11 +996,16 @@ extern void allocate_gnat_aux_type (struct type *); + #define TYPE_CODE(thistype) TYPE_MAIN_TYPE(thistype)->code #define TYPE_NFIELDS(thistype) TYPE_MAIN_TYPE(thistype)->nfields - #define TYPE_FIELDS(thistype) TYPE_MAIN_TYPE(thistype)->fields - #define TYPE_TEMPLATE_ARGS(thistype) TYPE_CPLUS_SPECIFIC(thistype)->template_args + #define TYPE_FIELDS(thistype) TYPE_MAIN_TYPE(thistype)->flds_bnds.fields +#define TYPE_DATA_LOCATION_DWARF_BLOCK(thistype) TYPE_MAIN_TYPE (thistype)->data_location.dwarf_block +#define TYPE_DATA_LOCATION_ADDR(thistype) TYPE_MAIN_TYPE (thistype)->data_location.addr +#define TYPE_ALLOCATED(thistype) TYPE_MAIN_TYPE (thistype)->allocated +#define TYPE_ASSOCIATED(thistype) TYPE_MAIN_TYPE (thistype)->associated #define TYPE_INDEX_TYPE(type) TYPE_FIELD_TYPE (type, 0) - #define TYPE_LOW_BOUND(range_type) TYPE_FIELD_BITPOS (range_type, 0) - #define TYPE_HIGH_BOUND(range_type) TYPE_FIELD_BITPOS (range_type, 1) -- --/* Moto-specific stuff for FORTRAN arrays */ -- --#define TYPE_ARRAY_UPPER_BOUND_IS_UNDEFINED(arraytype) \ -- (TYPE_FIELD_ARTIFICIAL(TYPE_INDEX_TYPE((arraytype)),1)) -+#define TYPE_BYTE_STRIDE(range_type) TYPE_FIELD_BITPOS (range_type, 2) -+ -+/* Whether we should use TYPE_FIELD_DWARF_BLOCK (and not TYPE_FIELD_BITPOS). */ -+#define TYPE_RANGE_BOUND_IS_DWARF_BLOCK(range_type, fieldno) \ -+ (TYPE_FIELD_LOC_KIND (range_type, fieldno) == FIELD_LOC_KIND_DWARF_BLOCK) -+#define TYPE_RANGE_BOUND_SET_DWARF_BLOCK(range_type, fieldno) \ -+ (TYPE_FIELD_LOC_KIND (range_type, fieldno) = FIELD_LOC_KIND_DWARF_BLOCK) -+#define TYPE_ARRAY_BOUND_IS_DWARF_BLOCK(array_type, fieldno) \ -+ TYPE_RANGE_BOUND_IS_DWARF_BLOCK (TYPE_INDEX_TYPE (array_type), fieldno) -+ -+/* Unbound arrays, such as GCC array[]; at end of struct. */ -+#define TYPE_RANGE_LOWER_BOUND_IS_UNDEFINED(rangetype) \ -+ TYPE_FIELD_ARTIFICIAL((rangetype),0) -+#define TYPE_RANGE_UPPER_BOUND_IS_UNDEFINED(rangetype) \ -+ TYPE_FIELD_ARTIFICIAL((rangetype),1) - #define TYPE_ARRAY_LOWER_BOUND_IS_UNDEFINED(arraytype) \ -- (TYPE_FIELD_ARTIFICIAL(TYPE_INDEX_TYPE((arraytype)),0)) -- --#define TYPE_ARRAY_UPPER_BOUND_VALUE(arraytype) \ -- (TYPE_HIGH_BOUND(TYPE_INDEX_TYPE((arraytype)))) -+ TYPE_RANGE_LOWER_BOUND_IS_UNDEFINED (TYPE_INDEX_TYPE (arraytype)) -+#define TYPE_ARRAY_UPPER_BOUND_IS_UNDEFINED(arraytype) \ -+ TYPE_RANGE_UPPER_BOUND_IS_UNDEFINED (TYPE_INDEX_TYPE (arraytype)) + #define TYPE_RANGE_DATA(thistype) TYPE_MAIN_TYPE(thistype)->flds_bnds.bounds +-#define TYPE_LOW_BOUND(range_type) TYPE_RANGE_DATA(range_type)->low +-#define TYPE_HIGH_BOUND(range_type) TYPE_RANGE_DATA(range_type)->high ++#define TYPE_LOW_BOUND(range_type) TYPE_RANGE_DATA(range_type)->low.u.constant ++#define TYPE_HIGH_BOUND(range_type) TYPE_RANGE_DATA(range_type)->high.u.constant ++#define TYPE_BYTE_STRIDE(range_type) TYPE_RANGE_DATA(range_type)->byte_stride.u.constant + #define TYPE_LOW_BOUND_UNDEFINED(range_type) \ + TYPE_RANGE_DATA(range_type)->low_undefined + #define TYPE_HIGH_BOUND_UNDEFINED(range_type) \ +@@ -920,7 +1022,14 @@ extern void allocate_gnat_aux_type (struct type *); + (TYPE_HIGH_BOUND(TYPE_INDEX_TYPE((arraytype)))) #define TYPE_ARRAY_LOWER_BOUND_VALUE(arraytype) \ - (TYPE_LOW_BOUND(TYPE_INDEX_TYPE((arraytype)))) + TYPE_LOW_BOUND (TYPE_INDEX_TYPE (arraytype)) -+#define TYPE_ARRAY_UPPER_BOUND_VALUE(arraytype) \ -+ TYPE_HIGH_BOUND (TYPE_INDEX_TYPE (arraytype)) ++ +/* TYPE_BYTE_STRIDE (TYPE_INDEX_TYPE (arraytype)) with a fallback to the + element size if no specific stride value is known. */ +#define TYPE_ARRAY_BYTE_STRIDE_VALUE(arraytype) \ @@ -10908,24 +7328,27 @@ index be6ed55..6a51a4e 100644 /* C++ */ -@@ -855,6 +949,7 @@ extern void allocate_cplus_struct_type (struct type *); - #define TYPE_CPLUS_SPECIFIC(thistype) TYPE_MAIN_TYPE(thistype)->type_specific.cplus_stuff - #define TYPE_FLOATFORMAT(thistype) TYPE_MAIN_TYPE(thistype)->type_specific.floatformat - #define TYPE_CALLING_CONVENTION(thistype) TYPE_MAIN_TYPE(thistype)->type_specific.calling_convention -+#define TYPE_MODULE_BLOCK(thistype) TYPE_MAIN_TYPE(thistype)->type_specific.module_block - #define TYPE_BASECLASS(thistype,index) TYPE_MAIN_TYPE(thistype)->fields[index].type - #define TYPE_N_BASECLASSES(thistype) TYPE_CPLUS_SPECIFIC(thistype)->n_baseclasses - #define TYPE_BASECLASS_NAME(thistype,index) TYPE_MAIN_TYPE(thistype)->fields[index].name -@@ -1131,7 +1226,7 @@ extern const struct floatformat *floatformats_ibm_long_double[BFD_ENDIAN_UNKNOWN - Use alloc_type_arch to allocate a type owned by an architecture. - Use alloc_type_copy to allocate a type with the same owner as a - pre-existing template type, no matter whether objfile or gdbarch. */ --extern struct type *alloc_type (struct objfile *); -+extern struct type *alloc_type (struct objfile *, struct type *); - extern struct type *alloc_type_arch (struct gdbarch *); - extern struct type *alloc_type_copy (const struct type *); - -@@ -1226,6 +1321,18 @@ extern struct type *create_array_type (struct type *, struct type *, +@@ -1141,6 +1250,10 @@ struct builtin_type + (*) () can server as a generic function pointer. */ + struct type *builtin_func_ptr; + ++ /* `function returning pointer to function (returning void)' type. ++ The final void return type is not significant for it. */ ++ struct type *builtin_func_func; ++ + + /* Special-purpose types. */ + +@@ -1181,6 +1294,8 @@ struct objfile_type + + /* Types used for symbols with no debug information. */ + struct type *nodebug_text_symbol; ++ struct type *nodebug_text_gnu_ifunc_symbol; ++ struct type *nodebug_got_plt_symbol; + struct type *nodebug_data_symbol; + struct type *nodebug_unknown_symbol; + struct type *nodebug_tls_symbol; +@@ -1328,6 +1443,18 @@ extern struct type *create_array_type (struct type *, struct type *, struct type *); extern struct type *lookup_array_range_type (struct type *, int, int); @@ -10944,16 +7367,16 @@ index be6ed55..6a51a4e 100644 extern struct type *create_string_type (struct type *, struct type *, struct type *); extern struct type *lookup_string_range_type (struct type *, int, int); -@@ -1262,6 +1369,8 @@ extern int get_discrete_bounds (struct type *, LONGEST *, LONGEST *); +@@ -1370,6 +1497,8 @@ extern int is_public_ancestor (struct type *, struct type *); - extern int is_ancestor (struct type *, struct type *); + extern int is_unique_ancestor (struct type *, struct value *); +extern void type_mark_used (struct type *type); + /* Overload resolution */ #define LENGTH_MATCH(bv) ((bv)->rank[0]) -@@ -1324,10 +1433,15 @@ extern void maintenance_print_type (char *, int); +@@ -1432,10 +1561,11 @@ extern void maintenance_print_type (char *, int); extern htab_t create_copied_types_hash (struct objfile *objfile); @@ -10965,141 +7388,16 @@ index be6ed55..6a51a4e 100644 extern struct type *copy_type (const struct type *type); +extern void free_all_types (void); -+ -+extern void type_incref (struct type *type); -+ -+extern void type_decref (struct type *type); + #endif /* GDBTYPES_H */ -diff --git a/gdb/gnu-v3-abi.c b/gdb/gnu-v3-abi.c -index 0f9d44e..c910e88 100644 ---- a/gdb/gnu-v3-abi.c -+++ b/gdb/gnu-v3-abi.c -@@ -26,6 +26,7 @@ - #include "demangle.h" - #include "objfiles.h" - #include "valprint.h" -+#include "c-lang.h" - - #include "gdb_assert.h" - #include "gdb_string.h" -@@ -459,10 +460,8 @@ gnuv3_find_method_in (struct type *domain, CORE_ADDR voffset, - LONGEST adjustment) - { - int i; -- const char *physname; - - /* Search this class first. */ -- physname = NULL; - if (adjustment == 0) - { - int len; -@@ -590,15 +589,24 @@ gnuv3_print_method_ptr (const gdb_byte *contents, - { - char *demangled_name = cplus_demangle (physname, - DMGL_ANSI | DMGL_PARAMS); -- if (demangled_name != NULL) -+ fprintf_filtered (stream, "&virtual "); -+ if (demangled_name == NULL) -+ fputs_filtered (physname, stream); -+ else - { -- fprintf_filtered (stream, "&virtual "); - fputs_filtered (demangled_name, stream); - xfree (demangled_name); -- return; - } -+ return; - } - } -+ else if (ptr_value != 0) -+ { -+ /* Found a non-virtual function: print out the type. */ -+ fputs_filtered ("(", stream); -+ c_print_type (type, "", stream, -1, 0); -+ fputs_filtered (") ", stream); -+ } - - /* We didn't find it; print the raw data. */ - if (vbit) diff --git a/gdb/i386-linux-nat.c b/gdb/i386-linux-nat.c -index fe848ff..905dcc3 100644 +index 4fce1ac..144a899 100644 --- a/gdb/i386-linux-nat.c +++ b/gdb/i386-linux-nat.c -@@ -586,6 +586,8 @@ i386_linux_store_inferior_registers (struct target_ops *ops, - - static unsigned long i386_linux_dr[DR_CONTROL + 1]; - -+/* Get debug register REGNUM value from only the one LWP of PTID. */ -+ - static unsigned long - i386_linux_dr_get (ptid_t ptid, int regnum) - { -@@ -614,6 +616,8 @@ i386_linux_dr_get (ptid_t ptid, int regnum) - return value; - } - -+/* Set debug register REGNUM to VALUE in only the one LWP of PTID. */ -+ - static void - i386_linux_dr_set (ptid_t ptid, int regnum, unsigned long value) - { -@@ -630,6 +634,8 @@ i386_linux_dr_set (ptid_t ptid, int regnum, unsigned long value) - perror_with_name (_("Couldn't write debug register")); - } - -+/* Set DR_CONTROL to ADDR in all LWPs of LWP_LIST. */ -+ - static void - i386_linux_dr_set_control (unsigned long control) - { -@@ -641,6 +647,8 @@ i386_linux_dr_set_control (unsigned long control) - i386_linux_dr_set (ptid, DR_CONTROL, control); - } - -+/* Set address REGNUM (zero based) to ADDR in all LWPs of LWP_LIST. */ -+ - static void - i386_linux_dr_set_addr (int regnum, CORE_ADDR addr) - { -@@ -654,18 +662,55 @@ i386_linux_dr_set_addr (int regnum, CORE_ADDR addr) - i386_linux_dr_set (ptid, DR_FIRSTADDR + regnum, addr); - } - -+/* Set address REGNUM (zero based) to zero in all LWPs of LWP_LIST. */ -+ - static void - i386_linux_dr_reset_addr (int regnum) - { - i386_linux_dr_set_addr (regnum, 0); - } - -+/* Get DR_STATUS from only the one LWP of INFERIOR_PTID. */ -+ - static unsigned long - i386_linux_dr_get_status (void) - { - return i386_linux_dr_get (inferior_ptid, DR_STATUS); +@@ -747,6 +747,21 @@ i386_linux_dr_unset_status (unsigned long mask) + } } -+/* Unset MASK bits in DR_STATUS in all LWPs of LWP_LIST. */ -+ -+static void -+i386_linux_dr_unset_status (unsigned long mask) -+{ -+ struct lwp_info *lp; -+ ptid_t ptid; -+ -+ ALL_LWPS (lp, ptid) -+ { -+ unsigned long value; -+ -+ value = i386_linux_dr_get (ptid, DR_STATUS); -+ value &= ~mask; -+ i386_linux_dr_set (ptid, DR_STATUS, value); -+ } -+} -+ +/* See i386_dr_low_type.detach. Do not use wrappers i386_linux_dr_set_control + or i386_linux_dr_reset_addr as they would modify the register cache + (i386_linux_dr). */ @@ -11118,56 +7416,19 @@ index fe848ff..905dcc3 100644 static void i386_linux_new_thread (ptid_t ptid) { -@@ -837,6 +882,8 @@ _initialize_i386_linux_nat (void) - i386_dr_low.set_addr = i386_linux_dr_set_addr; +@@ -976,6 +991,7 @@ _initialize_i386_linux_nat (void) i386_dr_low.reset_addr = i386_linux_dr_reset_addr; i386_dr_low.get_status = i386_linux_dr_get_status; -+ i386_dr_low.unset_status = i386_linux_dr_unset_status; + i386_dr_low.unset_status = i386_linux_dr_unset_status; + i386_dr_low.detach = i386_linux_dr_detach; i386_set_debug_register_length (4); /* Override the default ptrace resume method. */ diff --git a/gdb/i386-nat.c b/gdb/i386-nat.c -index 325b4df..631ccd6 100644 +index eaa3644..0921c7e 100644 --- a/gdb/i386-nat.c +++ b/gdb/i386-nat.c -@@ -137,8 +137,11 @@ struct i386_dr_low_type i386_dr_low; - #define I386_DR_GET_RW_LEN(i) \ - ((dr_control_mirror >> (DR_CONTROL_SHIFT + DR_CONTROL_SIZE * (i))) & 0x0f) - -+/* Mask that this I'th watchpoint has triggered. */ -+#define I386_DR_WATCH_MASK(i) (1 << (i)) -+ - /* Did the watchpoint whose address is in the I'th register break? */ --#define I386_DR_WATCH_HIT(i) (dr_status_mirror & (1 << (i))) -+#define I386_DR_WATCH_HIT(i) (dr_status_mirror & I386_DR_WATCH_MASK (i)) - - /* A macro to loop over all debug registers. */ - #define ALL_DEBUG_REGISTERS(i) for (i = 0; i < DR_NADDR; i++) -@@ -358,6 +361,10 @@ i386_insert_aligned_watchpoint (CORE_ADDR addr, unsigned len_rw_bits) - i386_dr_low.set_addr (i, addr); - i386_dr_low.set_control (dr_control_mirror); - -+ /* Only a sanity check for leftover bits (set possibly only by inferior). */ -+ if (i386_dr_low.unset_status) -+ i386_dr_low.unset_status (I386_DR_WATCH_MASK (i)); -+ - return 0; - } - -@@ -387,6 +394,11 @@ i386_remove_aligned_watchpoint (CORE_ADDR addr, unsigned len_rw_bits) - i386_dr_low.set_control (dr_control_mirror); - if (i386_dr_low.reset_addr) - i386_dr_low.reset_addr (i); -+ -+ /* Status must be already queried for each LWP. Otherwise it will -+ be lost in all-stop mode + breakpoint always-inserted off. */ -+ if (i386_dr_low.unset_status) -+ i386_dr_low.unset_status (I386_DR_WATCH_MASK (i)); - } - retval = 0; - } -@@ -520,6 +532,17 @@ i386_remove_watchpoint (CORE_ADDR addr, int len, int type) +@@ -533,6 +533,17 @@ i386_remove_watchpoint (CORE_ADDR addr, int len, int type, return retval; } @@ -11185,37 +7446,7 @@ index 325b4df..631ccd6 100644 /* Return non-zero if we can watch a memory region that starts at address ADDR and whose length is LEN bytes. */ -@@ -578,28 +601,7 @@ static int - i386_stopped_by_watchpoint (void) - { - CORE_ADDR addr = 0; -- return i386_stopped_data_address (¤t_target, &addr); --} -- --/* Return non-zero if the inferior has some break/watchpoint that -- triggered. */ -- --static int --i386_stopped_by_hwbp (void) --{ -- int i; -- -- dr_status_mirror = i386_dr_low.get_status (); -- if (maint_show_dr) -- i386_show_dr ("stopped_by_hwbp", 0, 0, hw_execute); -- -- ALL_DEBUG_REGISTERS(i) -- { -- if (I386_DR_WATCH_HIT (i)) -- return 1; -- } -- -- return 0; -+ return target_stopped_data_address (¤t_target, &addr); - } - - /* Insert a hardware-assisted breakpoint at BP_TGT->placed_address. -@@ -693,6 +695,7 @@ i386_use_watchpoints (struct target_ops *t) +@@ -685,6 +696,7 @@ i386_use_watchpoints (struct target_ops *t) t->to_stopped_data_address = i386_stopped_data_address; t->to_insert_watchpoint = i386_insert_watchpoint; t->to_remove_watchpoint = i386_remove_watchpoint; @@ -11224,84 +7455,147 @@ index 325b4df..631ccd6 100644 t->to_remove_hw_breakpoint = i386_remove_hw_breakpoint; } diff --git a/gdb/i386-nat.h b/gdb/i386-nat.h -index f49b9f6..cd31958 100644 +index 7317e7d..ea914a5 100644 --- a/gdb/i386-nat.h +++ b/gdb/i386-nat.h -@@ -49,16 +49,23 @@ extern void i386_use_watchpoints (struct target_ops *); - functions are: - - set_control -- set the debug control (DR7) -- register to a given value -+ register to a given value for all LWPs +@@ -62,6 +62,10 @@ extern void i386_use_watchpoints (struct target_ops *); + unset_status -- unset the specified bits of the debug + status (DR6) register for all LWPs - set_addr -- put an address into one debug -- register -+ register for all LWPs - - reset_addr -- reset the address stored in -- one debug register -+ one debug register for all LWPs - - get_status -- return the value of the debug -- status (DR6) register. -+ status (DR6) register for current LWP -+ -+ unset_status -- unset the specified bits of the debug -+ status (DR6) register for all LWPs -+ + detach -- clear all debug registers of only the + INFERIOR_PTID task without affecting any + register caches. - ++ Additionally, the native file should set the debug_register_length field to 4 or 8 depending on the number of bytes used for -@@ -70,6 +77,8 @@ struct i386_dr_low_type - void (*set_addr) (int, CORE_ADDR); + deubg registers. */ +@@ -73,6 +77,7 @@ struct i386_dr_low_type void (*reset_addr) (int); unsigned long (*get_status) (void); -+ void (*unset_status) (unsigned long); + void (*unset_status) (unsigned long); + void (*detach) (void); int debug_register_length; }; diff --git a/gdb/infcall.c b/gdb/infcall.c -index c9d98cf..277399a 100644 +index 0c9a3af..957ec1d 100644 --- a/gdb/infcall.c +++ b/gdb/infcall.c -@@ -441,6 +441,7 @@ call_function_by_hand (struct value *function, int nargs, struct value **args) - struct gdbarch *gdbarch; - struct breakpoint *terminate_bp = NULL; - struct minimal_symbol *tm; -+ struct cleanup *terminate_bp_cleanup = NULL; - ptid_t call_thread_ptid; - struct gdb_exception e; - const char *name; -@@ -772,7 +773,7 @@ call_function_by_hand (struct value *function, int nargs, struct value **args) - - /* Register a clean-up for unwind_on_terminating_exception_breakpoint. */ - if (terminate_bp) -- make_cleanup_delete_breakpoint (terminate_bp); -+ terminate_bp_cleanup = make_cleanup_delete_breakpoint (terminate_bp); - - /* - SNIP - SNIP - SNIP - SNIP - SNIP - SNIP - SNIP - SNIP - SNIP - - If you're looking to implement asynchronous dummy-frames, then -@@ -987,6 +988,11 @@ When the function is done executing, GDB will silently stop."), - internal_error (__FILE__, __LINE__, _("... should not be here")); - } +@@ -225,6 +225,56 @@ value_arg_coerce (struct gdbarch *gdbarch, struct value *arg, + return value_cast (type, arg); + } -+ /* If we get here and the std::terminate() breakpoint has been set, -+ it has to be cleaned manually. */ -+ if (terminate_bp) -+ do_cleanups (terminate_bp_cleanup); ++/* Call gnu-ifunc (STT_GNU_IFUNC - a function returning addresss of a real ++ function to call). PC is the gnu-ifunc function entry. Function returns ++ function entry of the gnu-ifunc-resolved function to call. If RETVAL_TYPEP ++ is not NULL fill in *RETVAL_TYPEP with return type of the gnu-ifunc-resolved ++ function to call. Keep *RETVAL_TYPEP intact if the return type could not be ++ found. */ ++ ++static CORE_ADDR ++gnu_ifunc_resolve (struct gdbarch *gdbarch, CORE_ADDR pc) ++{ ++ char *name_at_pc; ++ CORE_ADDR start_at_pc, address; ++ struct type *func_func_type = builtin_type (gdbarch)->builtin_func_func; ++ struct value *function, *address_val; ++ ++ if (find_pc_partial_function (pc, &name_at_pc, &start_at_pc, NULL) ++ && start_at_pc == pc) ++ { ++ if (resolve_gnu_ifunc (name_at_pc, &address)) ++ return address; ++ } ++ else ++ name_at_pc = NULL; ++ ++ function = allocate_value (func_func_type); ++ set_value_address (function, pc); ++ ++ /* gnu-ifuncs have no arguments. FUNCTION is the function entry address ++ while ADDRESS is a possible function descriptor.. */ ++ address_val = call_function_by_hand (function, 0, NULL); ++ address = value_as_address (address_val); ++ ++ if (name_at_pc) ++ gnu_ifunc_record_cache (gdbarch, name_at_pc, address); ++ ++ return gdbarch_convert_from_func_ptr_addr (gdbarch, address, ¤t_target); ++} + - /* If we get here the called FUNCTION ran to completion, - and the dummy frame has already been popped. */ ++static struct type * ++find_function_return_type (CORE_ADDR pc) ++{ ++ struct symbol *sym = find_pc_function (pc); ++ ++ if (sym != NULL && BLOCK_START (SYMBOL_BLOCK_VALUE (sym)) == pc ++ && SYMBOL_TYPE (sym) != NULL) ++ return TYPE_TARGET_TYPE (SYMBOL_TYPE (sym)); ++ ++ return NULL; ++} ++ + /* Determine a function's address and its return type from its value. + Calls error() if the function is not valid for calling. */ + +@@ -233,7 +283,6 @@ find_function_addr (struct value *function, struct type **retval_type) + { + struct type *ftype = check_typedef (value_type (function)); + struct gdbarch *gdbarch = get_type_arch (ftype); +- enum type_code code = TYPE_CODE (ftype); + struct type *value_type = NULL; + CORE_ADDR funaddr; + +@@ -241,24 +290,34 @@ find_function_addr (struct value *function, struct type **retval_type) + part of it. */ + /* Determine address to call. */ +- if (code == TYPE_CODE_FUNC || code == TYPE_CODE_METHOD) +- { +- funaddr = value_address (function); +- value_type = TYPE_TARGET_TYPE (ftype); +- } +- else if (code == TYPE_CODE_PTR) ++ if (TYPE_CODE (ftype) == TYPE_CODE_FUNC ++ || TYPE_CODE (ftype) == TYPE_CODE_METHOD) ++ funaddr = value_address (function); ++ else if (TYPE_CODE (ftype) == TYPE_CODE_PTR) + { + funaddr = value_as_address (function); + ftype = check_typedef (TYPE_TARGET_TYPE (ftype)); + if (TYPE_CODE (ftype) == TYPE_CODE_FUNC + || TYPE_CODE (ftype) == TYPE_CODE_METHOD) ++ funaddr = gdbarch_convert_from_func_ptr_addr (gdbarch, funaddr, ++ ¤t_target); ++ } ++ if (TYPE_CODE (ftype) == TYPE_CODE_FUNC ++ || TYPE_CODE (ftype) == TYPE_CODE_METHOD) ++ { ++ value_type = TYPE_TARGET_TYPE (ftype); ++ ++ if (TYPE_GNU_IFUNC (ftype)) + { +- funaddr = gdbarch_convert_from_func_ptr_addr (gdbarch, funaddr, +- ¤t_target); +- value_type = TYPE_TARGET_TYPE (ftype); ++ funaddr = gnu_ifunc_resolve (gdbarch, funaddr); ++ ++ /* Skip querying the function symbol if no RETVAL_TYPE has been ++ asked for. */ ++ if (retval_type) ++ value_type = find_function_return_type (funaddr); + } + } +- else if (code == TYPE_CODE_INT) ++ else if (TYPE_CODE (ftype) == TYPE_CODE_INT) + { + /* Handle the case of functions lacking debugging info. + Their values are characters since their addresses are char */ diff --git a/gdb/infcmd.c b/gdb/infcmd.c -index 9e98290..fab1892 100644 +index c4cdb06..d213f6a 100644 --- a/gdb/infcmd.c +++ b/gdb/infcmd.c -@@ -801,7 +801,7 @@ nexti_command (char *count_string, int from_tty) +@@ -822,7 +822,7 @@ nexti_command (char *count_string, int from_tty) step_1 (1, 1, count_string); } @@ -11310,7 +7604,7 @@ index 9e98290..fab1892 100644 delete_longjmp_breakpoint_cleanup (void *arg) { int thread = * (int *) arg; -@@ -841,10 +841,13 @@ step_1 (int skip_subroutines, int single_inst, char *count_string) +@@ -862,10 +862,13 @@ step_1 (int skip_subroutines, int single_inst, char *count_string) if (!single_inst || skip_subroutines) /* leave si command alone */ { @@ -11324,7 +7618,7 @@ index 9e98290..fab1892 100644 make_cleanup (delete_longjmp_breakpoint_cleanup, &thread); } -@@ -1193,6 +1196,15 @@ signal_command (char *signum_exp, int from_tty) +@@ -1219,6 +1222,15 @@ signal_command (char *signum_exp, int from_tty) proceed ((CORE_ADDR) -1, oursig, 0); } @@ -11340,7 +7634,7 @@ index 9e98290..fab1892 100644 /* Proceed until we reach a different source line with pc greater than our current one or exit the function. We skip calls in both cases. -@@ -1209,6 +1221,8 @@ until_next_command (int from_tty) +@@ -1235,6 +1247,8 @@ until_next_command (int from_tty) struct symbol *func; struct symtab_and_line sal; struct thread_info *tp = inferior_thread (); @@ -11349,7 +7643,7 @@ index 9e98290..fab1892 100644 clear_proceed_status (); set_step_frame (); -@@ -1244,7 +1258,19 @@ until_next_command (int from_tty) +@@ -1270,7 +1284,19 @@ until_next_command (int from_tty) tp->step_multi = 0; /* Only one call to proceed */ @@ -11369,7 +7663,7 @@ index 9e98290..fab1892 100644 } static void -@@ -1421,6 +1447,7 @@ finish_command_continuation (void *arg) +@@ -1463,6 +1489,7 @@ finish_command_continuation (void *arg) if (bs != NULL && tp->proceed_to_finish) observer_notify_normal_stop (bs, 1 /* print frame */); delete_breakpoint (a->breakpoint); @@ -11377,7 +7671,7 @@ index 9e98290..fab1892 100644 } static void -@@ -1504,6 +1531,7 @@ finish_forward (struct symbol *function, struct frame_info *frame) +@@ -1546,6 +1573,7 @@ finish_forward (struct symbol *function, struct frame_info *frame) struct breakpoint *breakpoint; struct cleanup *old_chain; struct finish_command_continuation_args *cargs; @@ -11385,7 +7679,7 @@ index 9e98290..fab1892 100644 sal = find_pc_line (get_frame_pc (frame), 0); sal.pc = get_frame_pc (frame); -@@ -1514,6 +1542,10 @@ finish_forward (struct symbol *function, struct frame_info *frame) +@@ -1556,6 +1584,10 @@ finish_forward (struct symbol *function, struct frame_info *frame) old_chain = make_cleanup_delete_breakpoint (breakpoint); @@ -11394,13 +7688,13 @@ index 9e98290..fab1892 100644 + make_cleanup (delete_longjmp_breakpoint_cleanup, &thread); + tp->proceed_to_finish = 1; /* We want stop_registers, please... */ - proceed ((CORE_ADDR) -1, TARGET_SIGNAL_DEFAULT, 0); + cargs = xmalloc (sizeof (*cargs)); diff --git a/gdb/inferior.h b/gdb/inferior.h -index f1b5d17..31add7d 100644 +index 5abec68..e309277 100644 --- a/gdb/inferior.h +++ b/gdb/inferior.h -@@ -272,6 +272,8 @@ extern void interrupt_target_command (char *args, int from_tty); +@@ -291,6 +291,8 @@ extern void interrupt_target_command (char *args, int from_tty); extern void interrupt_target_1 (int all_threads); @@ -11410,7 +7704,7 @@ index f1b5d17..31add7d 100644 extern void notice_new_inferior (ptid_t, int, int); diff --git a/gdb/infrun.c b/gdb/infrun.c -index ff7c6b9..9d29b15 100644 +index 54b1d9f..58d045a 100644 --- a/gdb/infrun.c +++ b/gdb/infrun.c @@ -45,6 +45,8 @@ @@ -11422,7 +7716,59 @@ index ff7c6b9..9d29b15 100644 #include "gdb_assert.h" #include "mi/mi-common.h" #include "event-top.h" -@@ -1782,6 +1784,8 @@ static void insert_step_resume_breakpoint_at_sal (struct gdbarch *gdbarch, +@@ -367,6 +369,7 @@ follow_fork (void) + parent thread structure's run control related fields, not just these. + Initialized to avoid "may be used uninitialized" warnings from gcc. */ + struct breakpoint *step_resume_breakpoint = NULL; ++ struct breakpoint *exception_resume_breakpoint = NULL; + CORE_ADDR step_range_start = 0; + CORE_ADDR step_range_end = 0; + struct frame_id step_frame_id = { 0 }; +@@ -419,6 +422,8 @@ follow_fork (void) + step_range_start = tp->step_range_start; + step_range_end = tp->step_range_end; + step_frame_id = tp->step_frame_id; ++ exception_resume_breakpoint ++ = clone_momentary_breakpoint (tp->exception_resume_breakpoint); + + /* For now, delete the parent's sr breakpoint, otherwise, + parent/child sr breakpoints are considered duplicates, +@@ -429,6 +434,7 @@ follow_fork (void) + tp->step_range_start = 0; + tp->step_range_end = 0; + tp->step_frame_id = null_frame_id; ++ delete_exception_resume_breakpoint (tp); + } + + parent = inferior_ptid; +@@ -470,6 +476,8 @@ follow_fork (void) + tp->step_range_start = step_range_start; + tp->step_range_end = step_range_end; + tp->step_frame_id = step_frame_id; ++ tp->exception_resume_breakpoint ++ = exception_resume_breakpoint; + } + else + { +@@ -523,6 +531,9 @@ follow_inferior_reset_breakpoints (void) + if (tp->step_resume_breakpoint) + breakpoint_re_set_thread (tp->step_resume_breakpoint); + ++ if (tp->exception_resume_breakpoint) ++ breakpoint_re_set_thread (tp->exception_resume_breakpoint); ++ + /* Reinsert all breakpoints in the child. The user may have set + breakpoints after catching the fork, in which case those + were never set in the child, but only in the parent. This makes +@@ -760,6 +771,7 @@ follow_exec (ptid_t pid, char *execd_pathname) + /* If there was one, it's gone now. We cannot truly step-to-next + statement through an exec(). */ + th->step_resume_breakpoint = NULL; ++ th->exception_resume_breakpoint = NULL; + th->step_range_start = 0; + th->step_range_end = 0; + +@@ -2190,6 +2202,8 @@ static void insert_step_resume_breakpoint_at_sal (struct gdbarch *gdbarch, struct symtab_and_line sr_sal, struct frame_id sr_id); static void insert_longjmp_resume_breakpoint (struct gdbarch *, CORE_ADDR); @@ -11431,7 +7777,23 @@ index ff7c6b9..9d29b15 100644 static void stop_stepping (struct execution_control_state *ecs); static void prepare_to_wait (struct execution_control_state *ecs); -@@ -2687,6 +2691,10 @@ handle_inferior_event (struct execution_control_state *ecs) +@@ -2313,6 +2327,7 @@ delete_step_resume_breakpoint_callback (struct thread_info *info, void *data) + return 0; + + delete_step_resume_breakpoint (info); ++ delete_exception_resume_breakpoint (info); + return 0; + } + +@@ -2337,6 +2352,7 @@ delete_step_thread_step_resume_breakpoint (void) + struct thread_info *tp = inferior_thread (); + + delete_step_resume_breakpoint (tp); ++ delete_exception_resume_breakpoint (tp); + } + else + /* In all-stop mode, delete all step-resume and longjmp-resume +@@ -3241,6 +3257,10 @@ handle_inferior_event (struct execution_control_state *ecs) stop_pc = regcache_read_pc (get_thread_regcache (ecs->ptid)); @@ -11439,10 +7801,10 @@ index ff7c6b9..9d29b15 100644 + confuse bpstat_stop_status and bpstat_explains_signal. */ + watchpoints_triggered (&ecs->ws); + - ecs->event_thread->stop_bpstat = bpstat_stop_status (stop_pc, ecs->ptid); - - ecs->random_signal = !bpstat_explains_signal (ecs->event_thread->stop_bpstat); -@@ -2724,6 +2732,10 @@ handle_inferior_event (struct execution_control_state *ecs) + ecs->event_thread->stop_bpstat + = bpstat_stop_status (get_regcache_aspace (get_current_regcache ()), + stop_pc, ecs->ptid); +@@ -3328,6 +3348,10 @@ handle_inferior_event (struct execution_control_state *ecs) stop_pc = regcache_read_pc (get_thread_regcache (ecs->ptid)); @@ -11450,29 +7812,10 @@ index ff7c6b9..9d29b15 100644 + confuse bpstat_stop_status and bpstat_explains_signal. */ + watchpoints_triggered (&ecs->ws); + - /* This causes the eventpoints and symbol table to be reset. - Must do this now, before trying to determine whether to - stop. */ -@@ -2845,6 +2857,9 @@ targets should add new threads to the thread list themselves in non-stop mode.") - { - struct regcache *regcache = get_thread_regcache (ecs->ptid); - struct gdbarch *gdbarch = get_regcache_arch (regcache); -+ struct cleanup *old_chain = save_inferior_ptid (); -+ -+ inferior_ptid = ecs->ptid; - - fprintf_unfiltered (gdb_stdlog, "infrun: stop_pc = %s\n", - paddress (gdbarch, stop_pc)); -@@ -2861,6 +2876,8 @@ targets should add new threads to the thread list themselves in non-stop mode.") - fprintf_unfiltered (gdb_stdlog, - "infrun: (no data address available)\n"); - } -+ -+ do_cleanups (old_chain); - } + /* Do whatever is necessary to the parent branch of the vfork. */ + handle_vfork_child_exec_or_exit (1); - if (stepping_past_singlestep_breakpoint) -@@ -3468,23 +3485,33 @@ process_event_stop_test: +@@ -4076,23 +4100,33 @@ process_event_stop_test: ecs->event_thread->stepping_over_breakpoint = 1; @@ -11518,31 +7861,37 @@ index ff7c6b9..9d29b15 100644 keep_going (ecs); return; -@@ -3496,6 +3523,53 @@ infrun: BPSTAT_WHAT_SET_LONGJMP_RESUME (!gdbarch_get_longjmp_target)\n"); - gdb_assert (ecs->event_thread->step_resume_breakpoint != NULL); - delete_step_resume_breakpoint (ecs->event_thread); +@@ -4101,8 +4135,52 @@ infrun: BPSTAT_WHAT_SET_LONGJMP_RESUME (!gdbarch_get_longjmp_target)\n"); + fprintf_unfiltered (gdb_stdlog, + "infrun: BPSTAT_WHAT_CLEAR_LONGJMP_RESUME\n"); -+ if (!what.is_longjmp) +- gdb_assert (ecs->event_thread->step_resume_breakpoint != NULL); +- delete_step_resume_breakpoint (ecs->event_thread); ++ if (what.is_longjmp) ++ { ++ gdb_assert (ecs->event_thread->step_resume_breakpoint != NULL); ++ delete_step_resume_breakpoint (ecs->event_thread); ++ } ++ else + { + /* There are several cases to consider. -+ ++ + 1. The initiating frame no longer exists. In this case + we must stop, because the exception has gone too far. -+ ++ + 2. The initiating frame exists, and is the same as the -+ current frame. -+ -+ 2.1. If we are stepping, defer to the stepping logic. -+ -+ 2.2. Otherwise, we are not stepping, so we are doing a -+ "finish" and we have reached the calling frame. So, -+ stop. -+ ++ current frame. We stop, because the exception has been ++ caught. ++ + 3. The initiating frame exists and is different from + the current frame. This means the exception has been + caught beneath the initiating frame, so keep going. */ + struct frame_info *init_frame + = frame_find_by_id (ecs->event_thread->initiating_frame); ++ ++ gdb_assert (ecs->event_thread->exception_resume_breakpoint != NULL); ++ delete_exception_resume_breakpoint (ecs->event_thread); ++ + if (init_frame) + { + struct frame_id current_id @@ -11550,15 +7899,7 @@ index ff7c6b9..9d29b15 100644 + if (frame_id_eq (current_id, + ecs->event_thread->initiating_frame)) + { -+ if (ecs->event_thread->step_range_start) -+ { -+ /* Case 2.1. */ -+ break; -+ } -+ else -+ { -+ /* Case 2.2: fall through. */ -+ } ++ /* Case 2. Fall through. */ + } + else + { @@ -11567,12 +7908,15 @@ index ff7c6b9..9d29b15 100644 + return; + } + } -+ } + ++ /* For Cases 1 and 2, remove the step-resume breakpoint, ++ if it exists. */ ++ delete_step_resume_breakpoint (ecs->event_thread); ++ } + ecs->event_thread->stop_step = 1; print_stop_reason (END_STEPPING_RANGE, 0); - stop_stepping (ecs); -@@ -4500,6 +4574,96 @@ insert_longjmp_resume_breakpoint (struct gdbarch *gdbarch, CORE_ADDR pc) +@@ -5070,6 +5148,97 @@ insert_longjmp_resume_breakpoint (struct gdbarch *gdbarch, CORE_ADDR pc) set_momentary_breakpoint_at_pc (gdbarch, pc, bp_longjmp_resume); } @@ -11600,20 +7944,21 @@ index ff7c6b9..9d29b15 100644 + + vsym = lookup_symbol (SYMBOL_LINKAGE_NAME (sym), b, VAR_DOMAIN, NULL); + value = read_var_value (vsym, frame); -+ handler = value_as_address (value); -+ -+ /* We're going to replace the current step-resume breakpoint -+ with an exception-resume breakpoint. */ -+ delete_step_resume_breakpoint (tp); ++ /* If the value was optimized out, revert to the old behavior. */ ++ if (! value_optimized_out (value)) ++ { ++ handler = value_as_address (value); + -+ if (debug_infrun) -+ fprintf_unfiltered (gdb_stdlog, -+ "infrun: exception resume at %lx\n", -+ (unsigned long) handler); ++ if (debug_infrun) ++ fprintf_unfiltered (gdb_stdlog, ++ "infrun: exception resume at %lx\n", ++ (unsigned long) handler); + -+ bp = set_momentary_breakpoint_at_pc (get_frame_arch (frame), -+ handler, bp_exception_resume); -+ inferior_thread ()->step_resume_breakpoint = bp; ++ bp = set_momentary_breakpoint_at_pc (get_frame_arch (frame), ++ handler, bp_exception_resume); ++ bp->thread = tp->num; ++ inferior_thread ()->exception_resume_breakpoint = bp; ++ } + } +} + @@ -11669,261 +8014,26 @@ index ff7c6b9..9d29b15 100644 static void stop_stepping (struct execution_control_state *ecs) { -@@ -4568,6 +4732,8 @@ keep_going (struct execution_control_state *ecs) - } - if (e.reason < 0) - { -+ if (debug_infrun) -+ exception_fprintf (gdb_stdlog, e, "infrun: exception while inserting breakpoints: "); - stop_stepping (ecs); - return; - } -diff --git a/gdb/jv-lang.c b/gdb/jv-lang.c -index 6b68e7d..5095180 100644 ---- a/gdb/jv-lang.c -+++ b/gdb/jv-lang.c -@@ -1121,6 +1121,7 @@ const struct exp_descriptor exp_descriptor_java = - { - print_subexp_standard, - operator_length_standard, -+ operator_check_standard, - op_name_standard, - dump_subexp_body_standard, - evaluate_subexp_java -diff --git a/gdb/language.h b/gdb/language.h -index c650e07..660fdf6 100644 ---- a/gdb/language.h -+++ b/gdb/language.h -@@ -237,7 +237,6 @@ struct language_defn - variables. */ - - struct symbol *(*la_lookup_symbol_nonlocal) (const char *, -- const char *, - const struct block *, - const domain_enum); - -diff --git a/gdb/linespec.c b/gdb/linespec.c -index 3e943a1..b96d425 100644 ---- a/gdb/linespec.c -+++ b/gdb/linespec.c -@@ -30,6 +30,7 @@ - #include "value.h" - #include "completer.h" - #include "cp-abi.h" -+#include "cp-support.h" - #include "parser-defs.h" - #include "block.h" - #include "objc-lang.h" -@@ -839,13 +840,33 @@ decode_line_1 (char **argptr, int funfirstline, struct symtab *default_symtab, - } - else if (paren_pointer != NULL) - { -- p = paren_pointer + 1; -+ /* We need to deal with method and function overloads -+ with no parameters. Gdb and gcc (and who knows about other -+ compilers) are very inconsistent with the keyword "void". -+ Canonicalizing C++ types is insufficient in this case, since -+ we still need to enforce the presence (or lack thereof) of -+ "void". For simplicity, omit the keyword "void" if present. */ -+ if (strncmp (paren_pointer - 5, "(void)", 6) == 0) -+ { -+ char *a, *b; -+ a = paren_pointer - 4; -+ b = paren_pointer; -+ while ((*(a++) = *(b++)) != '\0') ; -+ *a = '\0'; -+ p = paren_pointer - 3; -+ } -+ else -+ p = paren_pointer + 1; - } - else - { - p = skip_quoted (*argptr); - } - -+ /* Make sure we keep important kewords like "const" */ -+ if (strncmp (p, " const", 6) == 0) -+ p += 6; -+ - /* Keep any template parameters */ - if (*p == '<') - p = find_template_name_end (p); -@@ -1257,6 +1278,9 @@ decode_compound (char **argptr, int funfirstline, char ***canonical, - /* Move pointer ahead to next double-colon. */ - while (*p && (p[0] != ' ') && (p[0] != '\t') && (p[0] != '\'')) - { -+ if (current_language->la_language == language_cplus) -+ p += cp_validate_operator (p); -+ - if (p[0] == '<') - { - temp_end = find_template_name_end (p); -@@ -1334,6 +1358,15 @@ decode_compound (char **argptr, int funfirstline, char ***canonical, - while (*p && *p != ' ' && *p != '\t' && *p != ',' && *p != ':') - p++; - /* At this point p->"". String ended. */ -+ /* Nope, C++ operators could have spaces in them -+ ("foo::operator <" or "foo::operator delete []"). -+ I apologize, this is a bit hacky... */ -+ if (current_language->la_language == language_cplus -+ && *p == ' ' && p - 8 - *argptr + 1 > 0) -+ { -+ /* The above loop has already swallowed "operator". */ -+ p += cp_validate_operator (p - 8) - 8; -+ } - } - - /* Allocate our own copy of the substring between argptr and -@@ -1407,6 +1440,7 @@ lookup_prefix_sym (char **argptr, char *p) - { - char *p1; - char *copy; -+ struct symbol *sym; - - /* Extract the class name. */ - p1 = p; -@@ -1425,7 +1459,26 @@ lookup_prefix_sym (char **argptr, char *p) - /* At this point p1->"::inA::fun", p->"inA::fun" copy->"AAA", - argptr->"inA::fun" */ - -- return lookup_symbol (copy, 0, STRUCT_DOMAIN, 0); -+ sym = lookup_symbol (copy, 0, STRUCT_DOMAIN, 0); -+ if (sym == NULL) -+ { -+ /* Typedefs are in VAR_DOMAIN so the above symbol lookup will -+ fail when the user attempts to lookup a method of a class -+ via a typedef'd name (NOT via the classes name, which is already -+ handled in symbol_matches_domain). So try the lookup again -+ using VAR_DOMAIN (where typedefs live) and double-check that we -+ found a struct/class type. */ -+ struct symbol *s = lookup_symbol (copy, 0, VAR_DOMAIN, 0); -+ if (s != NULL) -+ { -+ struct type *t = SYMBOL_TYPE (s); -+ CHECK_TYPEDEF (t); -+ if (TYPE_CODE (t) == TYPE_CODE_STRUCT) -+ return s; -+ } -+ } -+ -+ return sym; - } - - /* This finds the method COPY in the class whose type is T and whose -@@ -1474,26 +1527,16 @@ find_method (int funfirstline, char ***canonical, char *saved_arg, - } - else - { -- char *tmp; -- -- if (is_operator_name (copy)) -- { -- tmp = (char *) alloca (strlen (copy + 3) + 9); -- strcpy (tmp, "operator "); -- strcat (tmp, copy + 3); -- } -- else -- tmp = copy; - if (not_found_ptr) - *not_found_ptr = 1; -- if (tmp[0] == '~') -+ if (copy[0] == '~') - cplusplus_error (saved_arg, - "the class `%s' does not have destructor defined\n", - SYMBOL_PRINT_NAME (sym_class)); - else - cplusplus_error (saved_arg, - "the class %s does not have any method named %s\n", -- SYMBOL_PRINT_NAME (sym_class), tmp); -+ SYMBOL_PRINT_NAME (sym_class), copy); - } - } - -@@ -1780,7 +1823,7 @@ symbol_found (int funfirstline, char ***canonical, char *copy, - { - struct blockvector *bv = BLOCKVECTOR (SYMBOL_SYMTAB (sym)); - struct block *b = BLOCKVECTOR_BLOCK (bv, STATIC_BLOCK); -- if (lookup_block_symbol (b, copy, NULL, VAR_DOMAIN) != NULL) -+ if (lookup_block_symbol (b, copy, VAR_DOMAIN) != NULL) - build_canonical_line_spec (values.sals, copy, canonical); - } - return values; diff --git a/gdb/linux-nat.c b/gdb/linux-nat.c -index 98f6347..0907f03 100644 +index 93adfcd..34412a6 100644 --- a/gdb/linux-nat.c +++ b/gdb/linux-nat.c -@@ -1710,6 +1710,7 @@ resume_callback (struct lwp_info *lp, void *data) - lp->stopped = 0; - lp->step = 0; - memset (&lp->siginfo, 0, sizeof (lp->siginfo)); -+ lp->watchpoint_hit_set = 0; - } - else if (lp->stopped && debug_linux_nat) - fprintf_unfiltered (gdb_stdlog, "RC: Not resuming sibling %s (has pending)\n", -@@ -1847,6 +1848,7 @@ linux_nat_resume (struct target_ops *ops, - - linux_ops->to_resume (linux_ops, ptid, step, signo); - memset (&lp->siginfo, 0, sizeof (lp->siginfo)); -+ lp->watchpoint_hit_set = 0; - - if (debug_linux_nat) - fprintf_unfiltered (gdb_stdlog, -@@ -2286,6 +2288,78 @@ maybe_clear_ignore_sigint (struct lwp_info *lp) - } +@@ -2587,6 +2587,39 @@ linux_nat_stopped_data_address (struct target_ops *ops, CORE_ADDR *addr_p) + return lp->stopped_data_address_p; } -+/* Fetch the possible triggered data watchpoint info and store it to LP. -+ The hardware data watchpoint trigger gets cleared during this fetch. */ ++/* In `set follow-fork-mode child' with multithreaded parent we need to detach ++ watchpoints from all the LWPs. In such case INFERIOR_PTID will be the ++ non-threaded new child while LWP_LIST will still contain all the threads of ++ the parent being detached. */ + -+static void -+save_sigtrap (struct lwp_info *lp) ++static int ++linux_nat_detach_watchpoints (void) +{ -+ struct cleanup *old_chain; -+ -+ /* linux_nat_stopped_data_address is not even installed in this case. */ -+ if (linux_ops->to_stopped_data_address == NULL) -+ return; -+ -+ old_chain = save_inferior_ptid (); -+ inferior_ptid = lp->ptid; -+ -+ lp->watchpoint_hit_set = -+ linux_ops->to_stopped_data_address (¤t_target, &lp->watchpoint_hit); -+ -+ do_cleanups (old_chain); -+} -+ -+/* Wrap target_stopped_data_address where the GNU/Linux native target may be -+ directed by the watchpoint/debug register number. Base the reported value -+ on the triggered data address instead. During inferior stop the assignment -+ of watchpoint/debug registers may change making the register number specific -+ trigger info stale. */ -+ -+static int -+linux_nat_stopped_data_address (struct target_ops *ops, CORE_ADDR *addr_p) -+{ -+ struct lwp_info *lp = find_lwp_pid (inferior_ptid); -+ -+ gdb_assert (lp != NULL); -+ -+ *addr_p = lp->watchpoint_hit; -+ -+ return lp->watchpoint_hit_set; -+} -+ -+/* In `set follow-fork-mode child' with multithreaded parent we need to detach -+ watchpoints from all the LWPs. In such case INFERIOR_PTID will be the -+ non-threaded new child while LWP_LIST will still contain all the threads of -+ the parent being detached. */ -+ -+static int -+linux_nat_detach_watchpoints (void) -+{ -+ struct lwp_info *lp; -+ int found = 0, retval = 0; -+ ptid_t filter = pid_to_ptid (ptid_get_pid (inferior_ptid)); -+ struct cleanup *old_chain = save_inferior_ptid (); ++ struct lwp_info *lp; ++ int found = 0, retval = 0; ++ ptid_t filter = pid_to_ptid (ptid_get_pid (inferior_ptid)); ++ struct cleanup *old_chain = save_inferior_ptid (); + + for (lp = lwp_list; lp; lp = lp->next) + if (ptid_match (lp->ptid, filter)) @@ -11948,96 +8058,40 @@ index 98f6347..0907f03 100644 /* Wait until LP is stopped. */ static int -@@ -2337,6 +2411,8 @@ stop_wait_callback (struct lwp_info *lp, void *data) - /* Save the trap's siginfo in case we need it later. */ - save_siginfo (lp); - -+ save_sigtrap (lp); -+ - /* Now resume this LWP and get the SIGSTOP event. */ - errno = 0; - ptrace (PTRACE_CONT, GET_LWP (lp->ptid), 0, 0); -@@ -2701,10 +2777,14 @@ linux_nat_filter_event (int lwpid, int status, int options) - add_thread (lp->ptid); - } - -- /* Save the trap's siginfo in case we need it later. */ - if (WIFSTOPPED (status) - && (WSTOPSIG (status) == SIGTRAP || WSTOPSIG (status) == TRAP_IS_SYSCALL)) -- save_siginfo (lp); -+ { -+ /* Save the trap's siginfo in case we need it later. */ -+ save_siginfo (lp); -+ -+ save_sigtrap (lp); -+ } - - /* Handle GNU/Linux's extended waitstatus for trace events. - It is necessary to check if WSTOPSIG is signaling that -@@ -4999,6 +5079,10 @@ linux_nat_add_target (struct target_ops *t) - t->to_thread_alive = linux_nat_thread_alive; - t->to_pid_to_str = linux_nat_pid_to_str; - t->to_has_thread_control = tc_schedlock; -+ if (linux_ops->to_stopped_data_address) -+ t->to_stopped_data_address = linux_nat_stopped_data_address; +@@ -5606,6 +5639,8 @@ linux_nat_add_target (struct target_ops *t) + t->to_thread_address_space = linux_nat_thread_address_space; + t->to_stopped_by_watchpoint = linux_nat_stopped_by_watchpoint; + t->to_stopped_data_address = linux_nat_stopped_data_address; + if (linux_ops->to_detach_watchpoints) + t->to_detach_watchpoints = linux_nat_detach_watchpoints; t->to_can_async_p = linux_nat_can_async_p; t->to_is_async_p = linux_nat_is_async_p; -diff --git a/gdb/linux-nat.h b/gdb/linux-nat.h -index eae74f3..73204fc 100644 ---- a/gdb/linux-nat.h -+++ b/gdb/linux-nat.h -@@ -62,6 +62,12 @@ struct lwp_info - be the address of a hardware watchpoint. */ - struct siginfo siginfo; - -+ /* WATCHPOINT_HIT_SET is non-zero if this LWP stopped with a trap and a data -+ watchpoint has been found as triggered. In such case WATCHPOINT_HIT -+ contains data address of the triggered data watchpoint. */ -+ unsigned watchpoint_hit_set : 1; -+ CORE_ADDR watchpoint_hit; -+ - /* Non-zero if we expect a duplicated SIGINT. */ - int ignore_sigint; - -diff --git a/gdb/m2-lang.c b/gdb/m2-lang.c -index 88c7e5e..2d0b3ca 100644 ---- a/gdb/m2-lang.c -+++ b/gdb/m2-lang.c -@@ -356,6 +356,7 @@ const struct exp_descriptor exp_descriptor_modula2 = - { - print_subexp_standard, - operator_length_standard, -+ operator_check_standard, - op_name_standard, - dump_subexp_body_standard, - evaluate_subexp_modula2 -diff --git a/gdb/machoread.c b/gdb/machoread.c -index 5f9a0fe..66fa067 100644 ---- a/gdb/machoread.c -+++ b/gdb/machoread.c -@@ -681,6 +681,7 @@ static struct sym_fns macho_sym_fns = { - macho_new_init, /* sym_new_init: init anything gbl to entire symtab */ - macho_symfile_init, /* sym_init: read initial info, setup for sym_read() */ - macho_symfile_read, /* sym_read: read a symbol file into symtab */ -+ NULL, /* sym_read_psymbols */ - macho_symfile_finish, /* sym_finish: finished with file, cleanup */ - macho_symfile_offsets, /* sym_offsets: xlate external to internal form */ - NULL /* next: pointer to next struct sym_fns */ +diff --git a/gdb/linux-tdep.c b/gdb/linux-tdep.c +index 07fd67c..2524250 100644 +--- a/gdb/linux-tdep.c ++++ b/gdb/linux-tdep.c +@@ -23,6 +23,8 @@ + #include "auxv.h" + #include "target.h" + #include "elf/common.h" ++#include "value.h" ++#include "infcall.h" + + /* This function is suitable for architectures that don't + extend/override the standard siginfo structure. */ diff --git a/gdb/main.c b/gdb/main.c -index 55411a8..ac9a540 100644 +index bfd1213..72faabd 100644 --- a/gdb/main.c +++ b/gdb/main.c -@@ -40,6 +40,7 @@ +@@ -39,6 +39,7 @@ + #include "interps.h" #include "main.h" - +#include "python/python.h" #include "source.h" - - /* If nonzero, display time usage both at startup and for each command. */ + #include "cli/cli-cmds.h" + #include "python/python.h" @@ -259,6 +260,8 @@ captured_main (void *data) char *cdarg = NULL; char *ttyarg = NULL; @@ -12047,9 +8101,9 @@ index 55411a8..ac9a540 100644 /* These are static so that we can take their address in an initializer. */ static int print_help; static int print_version; -@@ -434,10 +437,14 @@ captured_main (void *data) +@@ -443,10 +446,14 @@ captured_main (void *data) {"args", no_argument, &set_args, 1}, - {"l", required_argument, 0, 'l'}, + {"l", required_argument, 0, 'l'}, {"return-child-result", no_argument, &return_child_result, 1}, +#if HAVE_PYTHON + {"python", no_argument, 0, 'P'}, @@ -12063,7 +8117,7 @@ index 55411a8..ac9a540 100644 { int option_index; -@@ -455,6 +462,9 @@ captured_main (void *data) +@@ -464,6 +471,9 @@ captured_main (void *data) case 0: /* Long option that just sets a flag. */ break; @@ -12073,40 +8127,40 @@ index 55411a8..ac9a540 100644 case OPT_SE: symarg = optarg; execarg = optarg; -@@ -631,7 +641,31 @@ extern int gdbtk_test (char *); - use_windows = 0; - } +@@ -650,7 +660,31 @@ extern int gdbtk_test (char *); -- if (set_args) -+ if (python_script) -+ { -+ /* The first argument is a python script to evaluate, and -+ subsequent arguments are passed to the script for -+ processing there. */ -+ if (optind >= argc) -+ { -+ fprintf_unfiltered (gdb_stderr, -+ _("%s: Python script file name required\n"), -+ argv[0]); -+ exit (1); -+ } + /* Now that gdb_init has created the initial inferior, we're in position + to set args for that inferior. */ +- if (set_args) ++ if (python_script) ++ { ++ /* The first argument is a python script to evaluate, and ++ subsequent arguments are passed to the script for ++ processing there. */ ++ if (optind >= argc) ++ { ++ fprintf_unfiltered (gdb_stderr, ++ _("%s: Python script file name required\n"), ++ argv[0]); ++ exit (1); ++ } + -+ /* FIXME: should handle inferior I/O intelligently here. -+ E.g., should be possible to run gdb in pipeline and have -+ Python (and gdb) output go to stderr or file; and if a -+ prompt is needed, open the tty. */ -+ quiet = 1; -+ /* FIXME: should read .gdbinit if, and only if, a prompt is -+ requested by the script. Though... maybe this is not -+ ideal? */ -+ /* FIXME: likewise, reading in history. */ -+ inhibit_gdbinit = 1; -+ } -+ else if (set_args) - { - /* The remaining options are the command-line options for the - inferior. The first one is the sym/exec file, and the rest -@@ -864,7 +898,8 @@ Can't attach to process and specify a core file at the same time.")); ++ /* FIXME: should handle inferior I/O intelligently here. ++ E.g., should be possible to run gdb in pipeline and have ++ Python (and gdb) output go to stderr or file; and if a ++ prompt is needed, open the tty. */ ++ quiet = 1; ++ /* FIXME: should read .gdbinit if, and only if, a prompt is ++ requested by the script. Though... maybe this is not ++ ideal? */ ++ /* FIXME: likewise, reading in history. */ ++ inhibit_gdbinit = 1; ++ } ++ else if (set_args) + { + /* The remaining options are the command-line options for the + inferior. The first one is the sym/exec file, and the rest +@@ -890,7 +924,8 @@ Can't attach to process and specify a core file at the same time.")); xfree (cmdarg); /* Read in the old history after all the command files have been read. */ @@ -12114,11 +8168,11 @@ index 55411a8..ac9a540 100644 + if (!python_script) + init_history (); - if (batch) + if (batch_flag) { -@@ -893,13 +928,25 @@ Can't attach to process and specify a core file at the same time.")); - #endif - } +@@ -901,13 +936,25 @@ Can't attach to process and specify a core file at the same time.")); + /* Show time and/or space usage. */ + do_cleanups (pre_stat_chain); - /* NOTE: cagney/1999-11-07: There is probably no reason for not - moving this loop and the code found in captured_command_loop() @@ -12148,7 +8202,7 @@ index 55411a8..ac9a540 100644 } /* No exit -- exit is through quit_command. */ } -@@ -931,7 +978,12 @@ print_gdb_help (struct ui_file *stream) +@@ -939,7 +986,12 @@ print_gdb_help (struct ui_file *stream) fputs_unfiltered (_("\ This is the GNU debugger. Usage:\n\n\ gdb [options] [executable-file [core-file or process-id]]\n\ @@ -12162,7 +8216,7 @@ index 55411a8..ac9a540 100644 Options:\n\n\ "), stream); fputs_unfiltered (_("\ -@@ -969,7 +1021,13 @@ Options:\n\n\ +@@ -977,7 +1029,13 @@ Options:\n\n\ --nw Do not use a window interface.\n\ --nx Do not read "), stream); fputs_unfiltered (gdbinit, stream); @@ -12178,10 +8232,10 @@ index 55411a8..ac9a540 100644 --readnow Fully read symbol files on first access.\n\ "), stream); diff --git a/gdb/maint.c b/gdb/maint.c -index ecbae12..80fc36e 100644 +index 28fd610..4e21476 100644 --- a/gdb/maint.c +++ b/gdb/maint.c -@@ -914,4 +914,12 @@ When enabled GDB is profiled."), +@@ -909,4 +909,12 @@ When enabled GDB is profiled."), show_maintenance_profile_p, &maintenance_set_cmdlist, &maintenance_show_cmdlist); @@ -12194,24 +8248,11 @@ index ecbae12..80fc36e 100644 + &maintenance_set_cmdlist, + &maintenance_show_cmdlist); } -diff --git a/gdb/mdebugread.c b/gdb/mdebugread.c -index aac82e9..626292c 100644 ---- a/gdb/mdebugread.c -+++ b/gdb/mdebugread.c -@@ -4802,7 +4802,7 @@ new_type (char *name) - { - struct type *t; - -- t = alloc_type (current_objfile); -+ t = alloc_type (current_objfile, NULL); - TYPE_NAME (t) = name; - TYPE_CPLUS_SPECIFIC (t) = (struct cplus_struct_type *) &cplus_struct_default; - return t; diff --git a/gdb/mi/mi-cmd-var.c b/gdb/mi/mi-cmd-var.c -index 0baaa83..94ebfeb 100644 +index 310ade9..d8710a1 100644 --- a/gdb/mi/mi-cmd-var.c +++ b/gdb/mi/mi-cmd-var.c -@@ -697,7 +697,6 @@ mi_cmd_var_update (char *command, char **argv, int argc) +@@ -702,7 +702,6 @@ mi_cmd_var_update (char *command, char **argv, int argc) } else { @@ -12219,268 +8260,280 @@ index 0baaa83..94ebfeb 100644 struct varobj *var = varobj_get_handle (name); varobj_update_one (var, print_values, 1 /* explicit */); -diff --git a/gdb/mi/mi-main.c b/gdb/mi/mi-main.c -index 857a5d5..6181002 100644 ---- a/gdb/mi/mi-main.c -+++ b/gdb/mi/mi-main.c -@@ -1130,7 +1130,7 @@ mi_cmd_list_features (char *command, char **argv, int argc) - ui_out_field_string (uiout, NULL, "frozen-varobjs"); - ui_out_field_string (uiout, NULL, "pending-breakpoints"); - ui_out_field_string (uiout, NULL, "thread-info"); -- -+ - #if HAVE_PYTHON - ui_out_field_string (uiout, NULL, "python"); - #endif -diff --git a/gdb/mipsread.c b/gdb/mipsread.c -index a84003f..924c1c5 100644 ---- a/gdb/mipsread.c -+++ b/gdb/mipsread.c -@@ -394,6 +394,7 @@ static struct sym_fns ecoff_sym_fns = - mipscoff_new_init, /* sym_new_init: init anything gbl to entire symtab */ - mipscoff_symfile_init, /* sym_init: read initial info, setup for sym_read() */ - mipscoff_symfile_read, /* sym_read: read a symbol file into symtab */ -+ NULL, /* sym_read_psymbols */ - mipscoff_symfile_finish, /* sym_finish: finished with file, cleanup */ - default_symfile_offsets, /* sym_offsets: dummy FIXME til implem sym reloc */ - default_symfile_segments, /* sym_segments: Get segment information from -diff --git a/gdb/objfiles.c b/gdb/objfiles.c -index 8dcca70..e5442ca 100644 ---- a/gdb/objfiles.c -+++ b/gdb/objfiles.c -@@ -634,6 +634,11 @@ objfile_relocate (struct objfile *objfile, struct section_offsets *new_offsets) - } - } - -+ /* Alread QUICK_ADDRMAP tiself assumes all sections have the same offset. */ -+ if (objfile->quick_addrmap) -+ addrmap_relocate (objfile->quick_addrmap, -+ ANOFFSET (delta, SECT_OFF_TEXT (objfile))); -+ - { - struct partial_symbol **psym; - -@@ -731,6 +736,20 @@ have_partial_symbols (void) - if (objfile_has_partial_symbols (ofp)) - return 1; - } -+ -+ /* Try again, after reading partial symbols. We do this in two -+ passes because objfiles are always added to the head of the list, -+ and there might be a later objfile for which we've already read -+ partial symbols. */ -+ ALL_OBJFILES (ofp) -+ { -+ require_partial_symbols (ofp); -+ if (ofp->psymtabs != NULL) -+ { -+ return 1; -+ } -+ } -+ - return 0; +diff --git a/gdb/minsyms.c b/gdb/minsyms.c +index cb4545c..92d4027 100644 +--- a/gdb/minsyms.c ++++ b/gdb/minsyms.c +@@ -337,8 +337,9 @@ lookup_minimal_symbol_text (const char *name, struct objfile *objf) + msymbol = msymbol->hash_next) + { + if (strcmp (SYMBOL_LINKAGE_NAME (msymbol), name) == 0 && +- (MSYMBOL_TYPE (msymbol) == mst_text || +- MSYMBOL_TYPE (msymbol) == mst_file_text)) ++ (MSYMBOL_TYPE (msymbol) == mst_text ++ || MSYMBOL_TYPE (msymbol) == mst_text_gnu_ifunc ++ || MSYMBOL_TYPE (msymbol) == mst_file_text)) + { + switch (MSYMBOL_TYPE (msymbol)) + { +@@ -700,6 +701,16 @@ lookup_minimal_symbol_by_pc (CORE_ADDR pc) + return lookup_minimal_symbol_by_pc_section (pc, NULL); } -diff --git a/gdb/objfiles.h b/gdb/objfiles.h -index 62fa498..1fc9c6a 100644 ---- a/gdb/objfiles.h -+++ b/gdb/objfiles.h -@@ -212,6 +212,11 @@ struct objfile - - struct partial_symtab *psymtabs; - -+ /* An address map that can be used to quickly determine if an -+ address comes from this objfile. This can be NULL. */ ++/* Return non-zero iff PC is in function implementing gnu-ifunc selection. */ + -+ struct addrmap *quick_addrmap; ++int ++in_gnu_ifunc_stub (CORE_ADDR pc) ++{ ++ struct minimal_symbol *msymbol = lookup_minimal_symbol_by_pc (pc); ++ ++ return msymbol && MSYMBOL_TYPE (msymbol) == mst_text_gnu_ifunc; ++} + - /* Map addresses to the entries of PSYMTABS. It would be more efficient to - have a map per the whole process but ADDRMAP cannot selectively remove - its items during FREE_OBJFILE. This mapping is already present even for -@@ -414,6 +419,15 @@ struct objfile + /* Find the minimal symbol named NAME, and return both the minsym + struct and its objfile. This only checks the linkage name. Sets + *OBJFILE_P and returns the minimal symbol, if it is found. If it +@@ -769,6 +780,7 @@ prim_record_minimal_symbol (const char *name, CORE_ADDR address, + switch (ms_type) + { + case mst_text: ++ case mst_text_gnu_ifunc: + case mst_file_text: + case mst_solib_trampoline: + section = SECT_OFF_TEXT (objfile); +@@ -1235,7 +1247,8 @@ find_solib_trampoline_target (struct frame_info *frame, CORE_ADDR pc) + { + ALL_MSYMBOLS (objfile, msymbol) + { +- if (MSYMBOL_TYPE (msymbol) == mst_text ++ if ((MSYMBOL_TYPE (msymbol) == mst_text ++ || MSYMBOL_TYPE (msymbol) == mst_text_gnu_ifunc) + && strcmp (SYMBOL_LINKAGE_NAME (msymbol), + SYMBOL_LINKAGE_NAME (tsymbol)) == 0) + return SYMBOL_VALUE_ADDRESS (msymbol); +diff --git a/gdb/p-lang.c b/gdb/p-lang.c +index 08738ac..64d2e9f 100644 +--- a/gdb/p-lang.c ++++ b/gdb/p-lang.c +@@ -222,7 +222,11 @@ pascal_printstr (struct ui_file *stream, struct type *type, + unsigned int things_printed = 0; + int in_quotes = 0; + int need_comma = 0; +- int width = TYPE_LENGTH (type); ++ int width; ++ ++ /* Preserve TYPE's original type, just set its LENGTH. */ ++ check_typedef (type); ++ width = TYPE_LENGTH (type); + + /* If the string was not truncated due to `set print elements', and + the last byte of it is a null, we don't print that, in traditional C +diff --git a/gdb/p-valprint.c b/gdb/p-valprint.c +index 4d39bed..d0ddebc 100644 +--- a/gdb/p-valprint.c ++++ b/gdb/p-valprint.c +@@ -38,6 +38,7 @@ + #include "p-lang.h" + #include "cp-abi.h" + #include "cp-support.h" ++#include "dwarf2loc.h" + - #define OBJF_USERLOADED (1 << 3) /* User loaded */ -+/* Set if we have tried to read partial symtabs for this objfile. -+ This is used to allow lazy reading of partial symtabs. */ -+ -+#define OBJF_SYMTABS_READ (1 << 6) -+ -+/* This flag is set for the main objfile. */ -+ -+#define OBJF_MAIN (1 << 7) -+ - /* The object file that the main symbol table was loaded from (e.g. the - argument to the "symbol-file" or "file" command). */ +@@ -68,8 +69,27 @@ pascal_val_print (struct type *type, const gdb_byte *valaddr, + struct type *char_type; + LONGEST val; + CORE_ADDR addr; ++ struct cleanup *back_to; ++ struct type *saved_type = type; ++ CORE_ADDR saved_address = address; ++ ++ back_to = make_cleanup (null_cleanup, 0); ++ type = object_address_get_data (type, &address); ++ if (type == NULL) ++ { ++ fputs_filtered (object_address_data_not_valid (saved_type), stream); ++ gdb_flush (stream); ++ do_cleanups (back_to); ++ return 0; ++ } ++ if (address != saved_address) ++ { ++ size_t length = TYPE_LENGTH (type); -@@ -568,6 +582,13 @@ extern void gdb_bfd_unref (struct bfd *abfd); - ALL_OBJFILES (objfile) \ - ALL_OBJFILE_PSYMTABS (objfile, p) +- CHECK_TYPEDEF (type); ++ valaddr = xmalloc (length); ++ make_cleanup (xfree, (gdb_byte *) valaddr); ++ read_memory (address, (gdb_byte *) valaddr, length); ++ } + switch (TYPE_CODE (type)) + { + case TYPE_CODE_ARRAY: +@@ -125,8 +145,9 @@ pascal_val_print (struct type *type, const gdb_byte *valaddr, + { + i = 0; + } +- val_print_array_elements (type, valaddr + embedded_offset, address, stream, +- recurse, original_value, options, i); ++ val_print_array_elements (saved_type, valaddr + embedded_offset, ++ saved_address, stream, recurse, ++ original_value, options, i); + fprintf_filtered (stream, "}"); + } + break; +@@ -164,6 +185,7 @@ pascal_val_print (struct type *type, const gdb_byte *valaddr, + /* Try to print what function it points to. */ + print_address_demangle (gdbarch, addr, stream, demangle); + /* Return value is irrelevant except for string pointers. */ ++ do_cleanups (back_to); + return (0); + } -+/* Like ALL_PSYMTABS, but ensure that partial symbols have been read -+ before examining the objfile. */ -+ -+#define ALL_PSYMTABS_REQUIRED(objfile, p) \ -+ ALL_OBJFILES (objfile) \ -+ ALL_OBJFILE_PSYMTABS (require_partial_symbols (objfile), p) -+ - /* Traverse all minimal symbols in all objfiles. */ +@@ -252,6 +274,7 @@ pascal_val_print (struct type *type, const gdb_byte *valaddr, + /* Return number of characters printed, including the terminating + '\0' if we reached the end. val_print_string takes care including + the terminating '\0' if necessary. */ ++ do_cleanups (back_to); + return i; - #define ALL_MSYMBOLS(objfile, m) \ + break; +@@ -554,6 +577,7 @@ pascal_val_print (struct type *type, const gdb_byte *valaddr, + error (_("Invalid pascal type code %d in symbol table."), TYPE_CODE (type)); + } + gdb_flush (stream); ++ do_cleanups (back_to); + return (0); + } + diff --git a/gdb/parse.c b/gdb/parse.c -index ef938e3..c243bd8 100644 +index c885c6a..cbf9c65 100644 --- a/gdb/parse.c +++ b/gdb/parse.c -@@ -63,6 +63,7 @@ const struct exp_descriptor exp_descriptor_standard = - { - print_subexp_standard, - operator_length_standard, -+ operator_check_standard, - op_name_standard, - dump_subexp_body_standard, - evaluate_subexp_standard -@@ -837,6 +838,15 @@ operator_length_standard (struct expression *expr, int endpos, - args = 1 + longest_to_int (expr->elts[endpos - 2].longconst); +@@ -487,9 +487,21 @@ write_exp_msymbol (struct minimal_symbol *msymbol) + pc = gdbarch_convert_from_func_ptr_addr (gdbarch, addr, ¤t_target); + if (pc != addr) + { ++ struct minimal_symbol *ifunc_msym = lookup_minimal_symbol_by_pc (pc); ++ + /* In this case, assume we have a code symbol instead of + a data symbol. */ +- type = mst_text; ++ ++ if (ifunc_msym != NULL && MSYMBOL_TYPE (ifunc_msym) == mst_text_gnu_ifunc ++ && SYMBOL_VALUE_ADDRESS (ifunc_msym) == pc) ++ { ++ /* A function descriptor has been resolved but PC is still in the ++ gnu-ifunc resolver body (such as because inferior does not run to ++ be able to call it). */ ++ type = mst_text_gnu_ifunc; ++ } ++ else ++ type = mst_text; + section = NULL; + addr = pc; + } +@@ -521,6 +533,11 @@ write_exp_msymbol (struct minimal_symbol *msymbol) + write_exp_elt_type (objfile_type (objfile)->nodebug_text_symbol); break; -+ case TYPE_INSTANCE: -+ oplen = 4 + longest_to_int (expr->elts[endpos - 2].longconst); -+ args = 1; ++ case mst_text_gnu_ifunc: ++ write_exp_elt_type (objfile_type (objfile) ++ ->nodebug_text_gnu_ifunc_symbol); + break; + -+ case TYPE_INSTANCE_LOOKUP: -+ oplen = 3; + case mst_data: + case mst_file_data: + case mst_bss: +@@ -528,6 +545,10 @@ write_exp_msymbol (struct minimal_symbol *msymbol) + write_exp_elt_type (objfile_type (objfile)->nodebug_data_symbol); + break; + ++ case mst_slot_got_plt: ++ write_exp_elt_type (objfile_type (objfile)->nodebug_got_plt_symbol); + break; + - case OP_OBJC_MSGCALL: /* Objective C message (method) call */ - oplen = 4; - args = 1 + longest_to_int (expr->elts[endpos - 2].longconst); -@@ -1355,6 +1365,150 @@ parser_fprintf (FILE *x, const char *y, ...) - va_end (args); - } + default: + write_exp_elt_type (objfile_type (objfile)->nodebug_unknown_symbol); + break; +@@ -1412,6 +1433,7 @@ parser_fprintf (FILE *x, const char *y, ...) -+/* Implementation of the exp_descriptor method operator_check. */ -+ -+int -+operator_check_standard (struct expression *exp, int pos, + int + operator_check_standard (struct expression *exp, int pos, + int (*type_func) (struct type *type, void *data), -+ int (*objfile_func) (struct objfile *objfile, -+ void *data), -+ void *data) -+{ -+ const union exp_element *const elts = exp->elts; -+ struct type *type = NULL; -+ struct objfile *objfile = NULL; -+ -+ /* Extended operators should have been already handled by exp_descriptor -+ iterate method of its specific language. */ -+ gdb_assert (elts[pos].opcode < OP_EXTENDED0); -+ -+ /* Track the callers of write_exp_elt_type for this table. */ -+ -+ switch (elts[pos].opcode) -+ { -+ case BINOP_VAL: -+ case OP_COMPLEX: -+ case OP_DECFLOAT: -+ case OP_DOUBLE: -+ case OP_LONG: -+ case OP_SCOPE: -+ case OP_TYPE: -+ case UNOP_CAST: -+ case UNOP_MAX: -+ case UNOP_MEMVAL: -+ case UNOP_MIN: -+ type = elts[pos + 1].type; -+ break; -+ -+ case UNOP_MEMVAL_TLS: -+ objfile = elts[pos + 1].objfile; -+ type = elts[pos + 2].type; -+ break; -+ -+ case OP_VAR_VALUE: -+ { -+ const struct block *const block = elts[pos + 1].block; -+ const struct symbol *const symbol = elts[pos + 2].symbol; -+ const struct obj_section *const section = SYMBOL_OBJ_SECTION (symbol); -+ -+ /* Check objfile where the variable itself is placed. */ -+ if (section && objfile_func && (*objfile_func) (section->objfile, data)) -+ return 1; -+ -+ /* Check objfile where is placed the code touching the variable. */ -+ objfile = block_objfile (block); -+ -+ type = SYMBOL_TYPE (symbol); -+ } -+ break; -+ } -+ -+ /* Invoke callbacks for TYPE and OBJFILE if they were set as non-NULL. */ -+ + int (*objfile_func) (struct objfile *objfile, + void *data), + void *data) +@@ -1453,7 +1475,7 @@ operator_check_standard (struct expression *exp, int pos, + struct type *type = elts[pos + 2 + arg].type; + struct objfile *objfile = TYPE_OBJFILE (type); + +- if (objfile && (*objfile_func) (objfile, data)) ++ if (objfile && objfile_func && (*objfile_func) (objfile, data)) + return 1; + } + } +@@ -1471,7 +1493,8 @@ operator_check_standard (struct expression *exp, int pos, + + /* Check objfile where the variable itself is placed. + SYMBOL_OBJ_SECTION (symbol) may be NULL. */ +- if ((*objfile_func) (SYMBOL_SYMTAB (symbol)->objfile, data)) ++ if (objfile_func ++ && (*objfile_func) (SYMBOL_SYMTAB (symbol)->objfile, data)) + return 1; + + /* Check objfile where is placed the code touching the variable. */ +@@ -1484,24 +1507,27 @@ operator_check_standard (struct expression *exp, int pos, + + /* Invoke callbacks for TYPE and OBJFILE if they were set as non-NULL. */ + +- if (type && TYPE_OBJFILE (type) + if (type && type_func && (*type_func) (type, data)) + return 1; + if (type && TYPE_OBJFILE (type) && objfile_func -+ && (*objfile_func) (TYPE_OBJFILE (type), data)) -+ return 1; + && (*objfile_func) (TYPE_OBJFILE (type), data)) + return 1; +- if (objfile && (*objfile_func) (objfile, data)) + if (objfile && objfile_func && (*objfile_func) (objfile, data)) -+ return 1; -+ -+ return 0; -+} -+ + return 1; + + return 0; + } + +-/* Call OBJFILE_FUNC for any TYPE and OBJFILE found being referenced by EXP. +- The functions are never called with NULL OBJFILE. Functions get passed an +- arbitrary caller supplied DATA pointer. If any of the functions returns +- non-zero value then (any other) non-zero value is immediately returned to +- the caller. Otherwise zero is returned after iterating through whole EXP. +- */ +/* Call TYPE_FUNC and OBJFILE_FUNC for any TYPE and OBJFILE found being + referenced by EXP. The functions are never called with NULL TYPE or NULL + OBJFILE. Functions get passed an arbitrary caller supplied DATA pointer. + If any of the functions returns non-zero value then (any other) non-zero + value is immediately returned to the caller. Otherwise zero is returned + after iterating through whole EXP. */ -+ -+static int -+exp_iterate (struct expression *exp, + + static int + exp_iterate (struct expression *exp, + int (*type_func) (struct type *type, void *data), -+ int (*objfile_func) (struct objfile *objfile, void *data), -+ void *data) -+{ -+ int endpos; -+ const union exp_element *const elts = exp->elts; -+ -+ for (endpos = exp->nelts; endpos > 0; ) -+ { -+ int pos, args, oplen = 0; -+ -+ exp->language_defn->la_exp_desc->operator_length (exp, endpos, -+ &oplen, &args); -+ gdb_assert (oplen > 0); -+ -+ pos = endpos - oplen; -+ if (exp->language_defn->la_exp_desc->operator_check (exp, pos, type_func, -+ objfile_func, data)) -+ return 1; -+ -+ endpos = pos; -+ } -+ -+ return 0; -+} -+ -+/* Helper for exp_uses_objfile. */ -+ -+static int -+exp_uses_objfile_iter (struct objfile *exp_objfile, void *objfile_voidp) -+{ -+ struct objfile *objfile = objfile_voidp; -+ -+ return exp_objfile == objfile; -+} -+ -+/* Return 1 if EXP uses OBJFILE (and will become dangling when OBJFILE -+ is unloaded), otherwise return 0. */ -+ -+int -+exp_uses_objfile (struct expression *exp, struct objfile *objfile) -+{ + int (*objfile_func) (struct objfile *objfile, void *data), + void *data) + { +@@ -1516,7 +1542,9 @@ exp_iterate (struct expression *exp, + + pos = endpos - oplen; + if (exp->language_defn->la_exp_desc->operator_check (exp, pos, +- objfile_func, data)) ++ type_func, ++ objfile_func, ++ data)) + return 1; + + endpos = pos; +@@ -1547,7 +1575,26 @@ exp_uses_objfile (struct expression *exp, struct objfile *objfile) + { + gdb_assert (objfile->separate_debug_objfile_backlink == NULL); + +- return exp_iterate (exp, exp_uses_objfile_iter, objfile); + return exp_iterate (exp, NULL, exp_uses_objfile_iter, objfile); +} + @@ -12495,59 +8548,39 @@ index ef938e3..c243bd8 100644 + return 0; +} + -+/* Call type_mark_used for any TYPE contained in EXP. */ ++/* Call type_mark_used for any type contained in EXP. */ + +void +exp_types_mark_used (struct expression *exp) +{ + exp_iterate (exp, exp_types_mark_used_iter, NULL, NULL); -+} -+ + } + void - _initialize_parse (void) - { diff --git a/gdb/parser-defs.h b/gdb/parser-defs.h -index cbda9c3..a07e6f2 100644 +index bb79ae1..fbbd600 100644 --- a/gdb/parser-defs.h +++ b/gdb/parser-defs.h -@@ -189,6 +189,13 @@ extern void operator_length (struct expression *, int, int *, int *); - - extern void operator_length_standard (struct expression *, int, int *, int *); +@@ -194,6 +194,8 @@ extern void operator_length_standard (const struct expression *, int, int *, + int *); -+extern int operator_check_standard (struct expression *exp, int pos, + extern int operator_check_standard (struct expression *exp, int pos, + int (*type_func) (struct type *type, + void *data), -+ int (*objfile_func) -+ (struct objfile *objfile, void *data), -+ void *data); -+ - extern char *op_name_standard (enum exp_opcode); - - extern struct type *follow_types (struct type *); -@@ -267,6 +274,20 @@ struct exp_descriptor - the number of subexpressions it takes. */ - void (*operator_length) (struct expression*, int, int*, int *); - -+ /* Call TYPE_FUNC and OBJFILE_FUNC for any TYPE and OBJFILE found being -+ referenced by the single operator of EXP at position POS. Operator -+ parameters are located at positive (POS + number) offsets in EXP. -+ The functions should never be called with NULL TYPE or NULL OBJFILE. -+ Functions should get passed an arbitrary caller supplied DATA pointer. -+ If any of the functions returns non-zero value then (any other) non-zero -+ value should be immediately returned to the caller. Otherwise zero -+ should be returned. */ -+ int (*operator_check) (struct expression *exp, int pos, + int (*objfile_func) + (struct objfile *objfile, void *data), + void *data); +@@ -285,6 +287,7 @@ struct exp_descriptor + value should be immediately returned to the caller. Otherwise zero + should be returned. */ + int (*operator_check) (struct expression *exp, int pos, + int (*type_func) (struct type *type, void *data), -+ int (*objfile_func) (struct objfile *objfile, -+ void *data), -+ void *data); -+ - /* Name of this operator for dumping purposes. */ - char *(*op_name) (enum exp_opcode); - -@@ -299,4 +320,8 @@ extern void print_subexp_standard (struct expression *, int *, + int (*objfile_func) (struct objfile *objfile, + void *data), + void *data); +@@ -323,4 +326,8 @@ extern void parser_fprintf (FILE *, const char *, ...) ATTRIBUTE_PRINTF (2, 3); - extern void parser_fprintf (FILE *, const char *, ...) ATTR_FORMAT (printf, 2 ,3); + extern int exp_uses_objfile (struct expression *exp, struct objfile *objfile); +extern int exp_uses_objfile (struct expression *exp, struct objfile *objfile); + @@ -12555,11 +8588,11 @@ index cbda9c3..a07e6f2 100644 + #endif /* PARSER_DEFS_H */ diff --git a/gdb/ppc-linux-nat.c b/gdb/ppc-linux-nat.c -index 47b74ad..22fb2fc 100644 +index 18ddee7..652b02a 100644 --- a/gdb/ppc-linux-nat.c +++ b/gdb/ppc-linux-nat.c -@@ -1391,6 +1391,24 @@ ppc_linux_remove_watchpoint (CORE_ADDR addr, int len, int rw) - return 0; +@@ -2010,6 +2010,24 @@ ppc_linux_remove_watchpoint (CORE_ADDR addr, int len, int rw, + return ret; } +/* See target_detach_watchpoints. Do not use wrapper @@ -12583,7 +8616,7 @@ index 47b74ad..22fb2fc 100644 static void ppc_linux_new_thread (ptid_t ptid) { -@@ -1648,6 +1666,7 @@ _initialize_ppc_linux_nat (void) +@@ -2349,6 +2367,7 @@ _initialize_ppc_linux_nat (void) t->to_region_ok_for_hw_watchpoint = ppc_linux_region_ok_for_hw_watchpoint; t->to_insert_watchpoint = ppc_linux_insert_watchpoint; t->to_remove_watchpoint = ppc_linux_remove_watchpoint; @@ -12592,18 +8625,10 @@ index 47b74ad..22fb2fc 100644 t->to_stopped_data_address = ppc_linux_stopped_data_address; t->to_watchpoint_addr_within_range = ppc_linux_watchpoint_addr_within_range; diff --git a/gdb/printcmd.c b/gdb/printcmd.c -index 5d8b936..fb0a455 100644 +index 5ffa099..58d9c79 100644 --- a/gdb/printcmd.c +++ b/gdb/printcmd.c -@@ -46,7 +46,6 @@ - #include "exceptions.h" - #include "observer.h" - #include "solist.h" --#include "solib.h" - #include "parser-defs.h" - #include "charset.h" - -@@ -900,6 +899,11 @@ print_command_1 (char *exp, int inspect, int voidprint) +@@ -971,6 +971,11 @@ print_command_1 (char *exp, int inspect, int voidprint) else val = access_value_history (0); @@ -12615,7 +8640,7 @@ index 5d8b936..fb0a455 100644 if (voidprint || (val && value_type (val) && TYPE_CODE (value_type (val)) != TYPE_CODE_VOID)) { -@@ -1396,6 +1400,22 @@ x_command (char *exp, int from_tty) +@@ -1471,6 +1476,22 @@ x_command (char *exp, int from_tty) set_internalvar (lookup_internalvar ("__"), last_examine_value); } } @@ -12638,99 +8663,72 @@ index 5d8b936..fb0a455 100644 /* Add an expression to the auto-display chain. -@@ -1798,50 +1818,6 @@ disable_display_command (char *args, int from_tty) - } - } - --/* Return 1 if D uses SOLIB (and will become dangling when SOLIB -- is unloaded), otherwise return 0. */ -- --static int --display_uses_solib_p (const struct display *d, -- const struct so_list *solib) --{ -- int endpos; -- struct expression *const exp = d->exp; -- const union exp_element *const elts = exp->elts; -- -- if (d->block != NULL -- && solib_contains_address_p (solib, d->block->startaddr)) -- return 1; -- -- for (endpos = exp->nelts; endpos > 0; ) -- { -- int i, args, oplen = 0; -- -- exp->language_defn->la_exp_desc->operator_length (exp, endpos, -- &oplen, &args); -- gdb_assert (oplen > 0); -- -- i = endpos - oplen; -- if (elts[i].opcode == OP_VAR_VALUE) -- { -- const struct block *const block = elts[i + 1].block; -- const struct symbol *const symbol = elts[i + 2].symbol; -- const struct obj_section *const section = -- SYMBOL_OBJ_SECTION (symbol); -- -- if (block != NULL -- && solib_contains_address_p (solib, block->startaddr)) -- return 1; -- -- if (section && section->objfile == solib->objfile) -- return 1; -- } -- endpos -= oplen; -- } -- -- return 0; --} -- - /* display_chain items point to blocks and expressions. Some expressions in - turn may point to symbols. - Both symbols and blocks are obstack_alloc'd on objfile_stack, and are -@@ -1853,18 +1829,20 @@ display_uses_solib_p (const struct display *d, - static void - clear_dangling_display_expressions (struct so_list *solib) - { -+ struct objfile *objfile = solib->objfile; - struct display *d; -- struct objfile *objfile = NULL; - -- for (d = display_chain; d; d = d->next) -- { -- if (d->exp && display_uses_solib_p (d, solib)) -- { -- xfree (d->exp); -- d->exp = NULL; -- d->block = NULL; -- } -- } -+ if (objfile == NULL) -+ return; +@@ -2869,4 +2890,6 @@ Show printing of source filename and line number with ."), NULL, + add_com ("eval", no_class, eval_command, _("\ + Convert \"printf format string\", arg1, arg2, arg3, ..., argn to\n\ + a command line, and call it.")); + -+ for (d = display_chain; d != NULL; d = d->next) -+ if (block_objfile (d->block) == objfile -+ || (d->exp && exp_uses_objfile (d->exp, objfile))) -+ { -+ xfree (d->exp); -+ d->exp = NULL; -+ d->block = NULL; -+ } ++ observer_attach_mark_used (print_types_mark_used); + } +diff --git a/gdb/psymtab.c b/gdb/psymtab.c +index 97a4eec..fce19c9 100644 +--- a/gdb/psymtab.c ++++ b/gdb/psymtab.c +@@ -421,6 +421,14 @@ lookup_symbol_aux_psymtabs (struct objfile *objfile, + return NULL; } - -@@ -2749,4 +2727,6 @@ Show printing of source filename and line number with ."), NULL, - NULL, - show_print_symbol_filename, - &setprintlist, &showprintlist); ++static void ++pre_expand_symtabs_matching_psymtabs (struct objfile *objfile, ++ int kind, const char *name, ++ domain_enum domain) ++{ ++ /* Nothing. */ ++} + -+ observer_attach_mark_used (print_types_mark_used); + /* Look, in partial_symtab PST, for symbol whose natural name is NAME. + Check the global symbols if GLOBAL, the static symbols if not. */ + +@@ -941,7 +949,7 @@ psymtab_to_fullname (struct partial_symtab *ps) + return NULL; } -diff --git a/gdb/python/lib/gdb/FrameIterator.py b/gdb/python/lib/gdb/FrameIterator.py -new file mode 100644 -index 0000000..5654546 ---- /dev/null + +-static char * ++static const char * + find_symbol_file_from_partial (struct objfile *objfile, const char *name) + { + struct partial_symtab *pst; +@@ -1199,6 +1207,7 @@ const struct quick_symbol_functions psym_functions = + forget_cached_source_info_partial, + lookup_symtab_via_partial_symtab, + lookup_symbol_aux_psymtabs, ++ pre_expand_symtabs_matching_psymtabs, + print_psymtab_stats_for_objfile, + dump_psymtabs_for_objfile, + relocate_psymtabs, +diff --git a/gdb/psymtab.h b/gdb/psymtab.h +index 9b8c8df..de8b67e 100644 +--- a/gdb/psymtab.h ++++ b/gdb/psymtab.h +@@ -1,6 +1,6 @@ + /* Public partial symbol table definitions. + +- Copyright (C) 2009 Free Software Foundation, Inc. ++ Copyright (C) 2009, 2010 Free Software Foundation, Inc. + + This file is part of GDB. + +@@ -28,4 +28,6 @@ void map_partial_symbol_filenames (void (*) (const char *, const char *, + + extern const struct quick_symbol_functions psym_functions; + ++extern const struct quick_symbol_functions dwarf2_gdb_index_functions; ++ + #endif /* PSYMTAB_H */ +diff --git a/gdb/python/lib/gdb/FrameIterator.py b/gdb/python/lib/gdb/FrameIterator.py +new file mode 100644 +index 0000000..5654546 +--- /dev/null +++ b/gdb/python/lib/gdb/FrameIterator.py @@ -0,0 +1,33 @@ +# Iterator over frames. @@ -13658,13 +9656,27 @@ index 0000000..debb3bb + return wanted == found + +InScope () -diff --git a/gdb/python/py-block.c b/gdb/python/py-block.c +diff --git a/gdb/python/py-cmd.c b/gdb/python/py-cmd.c +index 2cff4ba..9255336 100644 +--- a/gdb/python/py-cmd.c ++++ b/gdb/python/py-cmd.c +@@ -49,8 +49,7 @@ static struct cmdpy_completer completers[] = + + #define N_COMPLETERS (sizeof (completers) / sizeof (completers[0])) + +-/* A gdb command. For the time being only ordinary commands (not +- set/show commands) are allowed. */ ++/* A gdb command. */ + struct cmdpy_object + { + PyObject_HEAD +diff --git a/gdb/python/py-hooks.c b/gdb/python/py-hooks.c new file mode 100644 -index 0000000..8019e9d +index 0000000..a3140bc --- /dev/null -+++ b/gdb/python/py-block.c -@@ -0,0 +1,265 @@ -+/* Python interface to blocks. ++++ b/gdb/python/py-hooks.c +@@ -0,0 +1,50 @@ ++/* Notifications from gdb to Python + + Copyright (C) 2008 Free Software Foundation, Inc. + @@ -13684,193 +9696,266 @@ index 0000000..8019e9d + along with this program. If not, see . */ + +#include "defs.h" -+#include "block.h" -+#include "dictionary.h" -+#include "symtab.h" ++#include "cli/cli-decode.h" ++#include "charset.h" ++#include "python.h" +#include "python-internal.h" ++#include "observer.h" + -+typedef struct { -+ PyObject_HEAD -+ struct block *block; -+} block_object; -+ -+typedef struct { -+ PyObject_HEAD -+ struct dictionary *dict; -+ struct dict_iterator iter; -+ int initialized_p; -+} block_syms_iterator_object; -+ -+static PyTypeObject block_syms_iterator_object_type; -+ -+static PyObject * -+blpy_iter (PyObject *self) ++PyObject * ++gdbpy_get_hook_function (const char *name) +{ -+ block_syms_iterator_object *block_iter_obj; ++ PyObject *hooks; ++ PyObject *result; + -+ block_iter_obj = PyObject_New (block_syms_iterator_object, -+ &block_syms_iterator_object_type); -+ if (block_iter_obj == NULL) ++ if (! PyObject_HasAttrString (gdb_module, "hooks")) ++ return NULL; ++ hooks = PyObject_GetAttrString (gdb_module, "hooks"); ++ if (! hooks) ++ return NULL; ++ /* The cast is because the Python function doesn't declare const argument. ++ This is a problem in Python version 2.4, but not in 2.5. */ ++ if (! PyObject_HasAttrString (hooks, (char *) name)) + { -+ PyErr_SetString (PyExc_MemoryError, -+ "Could not allocate iterator object."); ++ Py_DECREF (hooks); + return NULL; + } ++ /* The cast is because the Python function doesn't declare const argument. ++ This is a problem in Python version 2.4, but not in 2.5. */ ++ result = PyObject_GetAttrString (hooks, (char *) name); ++ Py_DECREF (hooks); ++ return result; ++} +diff --git a/gdb/python/py-membuf.c b/gdb/python/py-membuf.c +new file mode 100644 +index 0000000..7bc294c +--- /dev/null ++++ b/gdb/python/py-membuf.c +@@ -0,0 +1,268 @@ ++/* Python interface to the inferior memory. + -+ block_iter_obj->dict = BLOCK_DICT (((block_object *) self)->block); -+ block_iter_obj->initialized_p = 0; ++ Copyright (C) 2008, 2009 Free Software Foundation, Inc. + -+ return (PyObject *) block_iter_obj; -+} ++ This file is part of GDB. + -+static PyObject * -+blpy_get_start (PyObject *self, void *closure) -+{ -+ block_object *self_block = (block_object *) self; ++ 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. + -+ return PyLong_FromUnsignedLongLong (BLOCK_START (self_block->block)); -+} ++ 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. + -+static PyObject * -+blpy_get_end (PyObject *self, void *closure) -+{ -+ block_object *self_block = (block_object *) self; ++ You should have received a copy of the GNU General Public License ++ along with this program. If not, see . */ + -+ return PyLong_FromUnsignedLongLong (BLOCK_END (self_block->block)); -+} ++#include "defs.h" ++#include "exceptions.h" ++#include "gdbcore.h" ++#include "python-internal.h" + -+static PyObject * -+blpy_get_function (PyObject *self, void *closure) -+{ -+ block_object *self_block = (block_object *) self; -+ struct symbol *sym; ++typedef struct { ++ PyObject_HEAD ++ void *buffer; + -+ sym = BLOCK_FUNCTION (self_block->block); -+ if (sym) -+ return symbol_to_symbol_object (sym); ++ /* These are kept just for mbpy_str. */ ++ CORE_ADDR addr; ++ CORE_ADDR length; ++} membuf_object; + -+ Py_RETURN_NONE; -+} ++static PyTypeObject membuf_object_type; + -+static PyObject * -+blpy_get_superblock (PyObject *self, void *closure) ++/* Implementation of gdb.read_memory (address, length). ++ Returns a Python buffer object with LENGTH bytes of the inferior's memory ++ at ADDRESS. Both arguments are integers. */ ++ ++PyObject * ++gdbpy_read_memory (PyObject *self, PyObject *args) +{ -+ block_object *self_block = (block_object *) self; -+ struct block *block; ++ int error = 0; ++ CORE_ADDR addr, length; ++ void *buffer = NULL; ++ membuf_object *membuf_obj; ++ PyObject *addr_obj, *length_obj; ++ struct cleanup *cleanups = NULL; ++ volatile struct gdb_exception except; + -+ block = BLOCK_SUPERBLOCK (self_block->block); -+ if (block) -+ return block_to_block_object (block); ++ if (! PyArg_ParseTuple (args, "OO", &addr_obj, &length_obj)) ++ return NULL; + -+ Py_RETURN_NONE; ++ TRY_CATCH (except, RETURN_MASK_ALL) ++ { ++ if (!get_addr_from_python (addr_obj, &addr) ++ || !get_addr_from_python (length_obj, &length)) ++ { ++ error = 1; ++ break; ++ } ++ ++ buffer = xmalloc (length); ++ cleanups = make_cleanup (xfree, buffer); ++ ++ read_memory (addr, buffer, length); ++ } ++ GDB_PY_HANDLE_EXCEPTION (except); ++ ++ if (error) ++ return NULL; ++ ++ discard_cleanups (cleanups); ++ ++ membuf_obj = PyObject_New (membuf_object, &membuf_object_type); ++ if (membuf_obj == NULL) ++ { ++ xfree (buffer); ++ PyErr_SetString (PyExc_MemoryError, ++ "Could not allocate memory buffer object."); ++ return NULL; ++ } ++ ++ membuf_obj->buffer = buffer; ++ membuf_obj->addr = addr; ++ membuf_obj->length = length; ++ ++ return PyBuffer_FromReadWriteObject ((PyObject *) membuf_obj, 0, ++ Py_END_OF_BUFFER); +} + ++/* Implementation of gdb.write_memory (address, buffer [, length]). ++ Writes the contents of BUFFER (a Python object supporting the read buffer ++ protocol) at ADDRESS in the inferior's memory. Write LENGTH bytes from ++ BUFFER, or its entire contents if the argument is not provided. The ++ function returns nothing. */ ++ +PyObject * -+block_to_block_object (struct block *block) ++gdbpy_write_memory (PyObject *self, PyObject *args) +{ -+ block_object *block_obj; ++ int buf_len, error = 0; ++ const char *buffer; ++ CORE_ADDR addr, length; ++ PyObject *addr_obj, *length_obj = NULL; ++ volatile struct gdb_exception except; ++ ++ if (! PyArg_ParseTuple (args, "Os#|O", &addr_obj, &buffer, &buf_len, ++ &length_obj)) ++ return NULL; + -+ block_obj = PyObject_New (block_object, &block_object_type); -+ if (block_obj == NULL) ++ TRY_CATCH (except, RETURN_MASK_ALL) + { -+ PyErr_SetString (PyExc_MemoryError, "Could not allocate block object."); -+ return NULL; ++ if (!get_addr_from_python (addr_obj, &addr)) ++ { ++ error = 1; ++ break; ++ } ++ ++ if (!length_obj) ++ length = buf_len; ++ else if (!get_addr_from_python (length_obj, &length)) ++ { ++ error = 1; ++ break; ++ } ++ ++ write_memory (addr, buffer, length); + } ++ GDB_PY_HANDLE_EXCEPTION (except); + -+ block_obj->block = block; ++ if (error) ++ return NULL; + -+ return (PyObject *) block_obj; ++ Py_RETURN_NONE; +} + -+struct block * -+block_object_to_block (PyObject *obj) ++/* Destructor of Membuf objects. */ ++ ++static void ++mbpy_dealloc (PyObject *self) +{ -+ if (! PyObject_TypeCheck (obj, &block_object_type)) -+ return NULL; -+ return ((block_object *) obj)->block; ++ xfree (((membuf_object *) self)->buffer); ++ self->ob_type->tp_free (self); +} + ++/* Return a description of the Membuf object. */ ++ +static PyObject * -+blpy_block_syms_iter (PyObject *self) ++mbpy_str (PyObject *self) +{ -+ return self; ++ membuf_object *membuf_obj = (membuf_object *) self; ++ ++ return PyString_FromFormat ("memory buffer for address %s, %s bytes long", ++ paddress (membuf_obj->addr), ++ pulongest (membuf_obj->length)); +} + -+static PyObject * -+blpy_block_syms_iternext (PyObject *self) ++static Py_ssize_t ++get_read_buffer (PyObject *self, Py_ssize_t segment, void **ptrptr) +{ -+ block_syms_iterator_object *iter_obj = (block_syms_iterator_object *) self; -+ struct symbol *sym; ++ membuf_object *membuf_obj = (membuf_object *) self; + -+ if (!iter_obj->initialized_p) ++ if (segment) + { -+ sym = dict_iterator_first (iter_obj->dict, &(iter_obj->iter)); -+ iter_obj->initialized_p = 1; ++ PyErr_SetString (PyExc_SystemError, ++ "The memory buffer supports only one segment."); ++ return -1; + } -+ else -+ sym = dict_iterator_next (&(iter_obj->iter)); + -+ return (sym == NULL)? NULL : symbol_to_symbol_object (sym); -+} ++ *ptrptr = membuf_obj->buffer; + -+/* Return the innermost lexical block containing the specified pc value, -+ or 0 if there is none. */ ++ return membuf_obj->length; ++} + -+PyObject * -+gdbpy_block_for_pc (PyObject *self, PyObject *args) ++static Py_ssize_t ++get_write_buffer (PyObject *self, Py_ssize_t segment, void **ptrptr) +{ -+ unsigned PY_LONG_LONG pc; -+ struct block *block; -+ PyObject *sym_obj; -+ -+ if (!PyArg_ParseTuple (args, "K", &pc)) -+ return NULL; ++ return get_read_buffer (self, segment, ptrptr); ++} + -+ block = block_for_pc (pc); -+ if (block) -+ return block_to_block_object (block); ++static Py_ssize_t ++get_seg_count (PyObject *self, Py_ssize_t *lenp) ++{ ++ if (lenp) ++ *lenp = ((membuf_object *) self)->length; + -+ Py_RETURN_NONE; ++ return 1; +} + -+void -+gdbpy_initialize_blocks (void) ++static Py_ssize_t ++get_char_buffer (PyObject *self, Py_ssize_t segment, char **ptrptr) +{ -+ block_object_type.tp_new = PyType_GenericNew; -+ if (PyType_Ready (&block_object_type) < 0) -+ return; -+ -+ block_syms_iterator_object_type.tp_new = PyType_GenericNew; -+ if (PyType_Ready (&block_syms_iterator_object_type) < 0) -+ return; ++ void *ptr = NULL; ++ Py_ssize_t ret; + -+ Py_INCREF (&block_object_type); -+ PyModule_AddObject (gdb_module, "Block", (PyObject *) &block_object_type); ++ ret = get_read_buffer (self, segment, &ptr); ++ *ptrptr = (char *) ptr; + -+ Py_INCREF (&block_syms_iterator_object_type); -+ PyModule_AddObject (gdb_module, "BlockIterator", -+ (PyObject *) &block_syms_iterator_object_type); ++ return ret; +} + -+ -+ -+static PyGetSetDef block_object_getset[] = { -+ { "start", blpy_get_start, NULL, "Start address of the block.", NULL }, -+ { "end", blpy_get_end, NULL, "End address of the block.", NULL }, -+ { "function", blpy_get_function, NULL, -+ "Symbol that names the block, or None.", NULL }, -+ { "superblock", blpy_get_superblock, NULL, -+ "Block containing the block, or None.", NULL }, -+ { NULL } /* Sentinel */ ++/* Python doesn't provide a decent way to get compatibility here. */ ++#if HAVE_LIBPYTHON2_4 ++#define CHARBUFFERPROC_NAME getcharbufferproc ++#else ++#define CHARBUFFERPROC_NAME charbufferproc ++#endif ++ ++static PyBufferProcs buffer_procs = { ++ get_read_buffer, ++ get_write_buffer, ++ get_seg_count, ++ /* The cast here works around a difference between Python 2.4 and ++ Python 2.5. */ ++ (CHARBUFFERPROC_NAME) get_char_buffer +}; + -+PyTypeObject block_object_type = { ++static PyTypeObject membuf_object_type = { + PyObject_HEAD_INIT (NULL) + 0, /*ob_size*/ -+ "gdb.Block", /*tp_name*/ -+ sizeof (block_object), /*tp_basicsize*/ ++ "gdb.Membuf", /*tp_name*/ ++ sizeof (membuf_object), /*tp_basicsize*/ + 0, /*tp_itemsize*/ -+ 0, /*tp_dealloc*/ ++ mbpy_dealloc, /*tp_dealloc*/ + 0, /*tp_print*/ + 0, /*tp_getattr*/ + 0, /*tp_setattr*/ @@ -13881,10770 +9966,1632 @@ index 0000000..8019e9d + 0, /*tp_as_mapping*/ + 0, /*tp_hash */ + 0, /*tp_call*/ -+ 0, /*tp_str*/ ++ mbpy_str, /*tp_str*/ + 0, /*tp_getattro*/ + 0, /*tp_setattro*/ -+ 0, /*tp_as_buffer*/ -+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_ITER, /*tp_flags*/ -+ "GDB block object", /* tp_doc */ ++ &buffer_procs, /*tp_as_buffer*/ ++ Py_TPFLAGS_DEFAULT, /*tp_flags*/ ++ "GDB memory buffer object", /*tp_doc*/ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ -+ blpy_iter, /* tp_iter */ ++ 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ -+ block_object_getset /* tp_getset */ -+}; -+ -+static PyTypeObject block_syms_iterator_object_type = { -+ PyObject_HEAD_INIT (NULL) -+ 0, /*ob_size*/ -+ "gdb.BlockIterator", /*tp_name*/ -+ sizeof (block_syms_iterator_object), /*tp_basicsize*/ -+ 0, /*tp_itemsize*/ -+ 0, /*tp_dealloc*/ -+ 0, /*tp_print*/ -+ 0, /*tp_getattr*/ -+ 0, /*tp_setattr*/ -+ 0, /*tp_compare*/ -+ 0, /*tp_repr*/ -+ 0, /*tp_as_number*/ -+ 0, /*tp_as_sequence*/ -+ 0, /*tp_as_mapping*/ -+ 0, /*tp_hash */ -+ 0, /*tp_call*/ -+ 0, /*tp_str*/ -+ 0, /*tp_getattro*/ -+ 0, /*tp_setattro*/ -+ 0, /*tp_as_buffer*/ -+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_ITER, /*tp_flags*/ -+ "GDB block syms iterator object", /* tp_doc */ -+ 0, /* tp_traverse */ -+ 0, /* tp_clear */ -+ 0, /* tp_richcompare */ -+ 0, /* tp_weaklistoffset */ -+ blpy_block_syms_iter, /* tp_iter */ -+ blpy_block_syms_iternext, /* tp_iternext */ -+ 0 /* tp_methods */ -+}; -diff --git a/gdb/python/py-breakpoint.c b/gdb/python/py-breakpoint.c -new file mode 100644 -index 0000000..afa9526 ---- /dev/null -+++ b/gdb/python/py-breakpoint.c -@@ -0,0 +1,665 @@ -+/* Python interface to breakpoints -+ -+ Copyright (C) 2008, 2009 Free Software Foundation, Inc. -+ -+ This file is part of GDB. -+ -+ 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 "defs.h" -+#include "value.h" -+#include "exceptions.h" -+#include "python-internal.h" -+#include "charset.h" -+#include "breakpoint.h" -+#include "gdbcmd.h" -+#include "gdbthread.h" -+#include "observer.h" -+ -+ -+/* From breakpoint.c. */ -+extern struct breakpoint *breakpoint_chain; -+ -+ -+typedef struct breakpoint_object breakpoint_object; -+ -+static PyTypeObject breakpoint_object_type; -+ -+/* A dynamically allocated vector of breakpoint objects. Each -+ breakpoint has a number. A breakpoint is valid if its slot in this -+ vector is non-null. When a breakpoint is deleted, we drop our -+ reference to it and zero its slot; this is how we let the Python -+ object have a lifetime which is independent from that of the gdb -+ breakpoint. */ -+static breakpoint_object **bppy_breakpoints; -+ -+/* Number of slots in bppy_breakpoints. */ -+static int bppy_slots; -+ -+/* Number of live breakpoints. */ -+static int bppy_live; -+ -+/* Variables used to pass information between the Breakpoint -+ constructor and the breakpoint-created hook function. */ -+static breakpoint_object *bppy_pending_object; -+ -+struct breakpoint_object -+{ -+ PyObject_HEAD -+ -+ /* The breakpoint number according to gdb. */ -+ int number; -+ -+ /* The gdb breakpoint object, or NULL if the breakpoint has been -+ deleted. */ -+ struct breakpoint *bp; ++ 0, /* tp_getset */ ++ 0, /* tp_base */ ++ 0, /* tp_dict */ ++ 0, /* tp_descr_get */ ++ 0, /* tp_descr_set */ ++ 0, /* tp_dictoffset */ ++ 0, /* tp_init */ ++ 0, /* tp_alloc */ ++ PyType_GenericNew /* tp_new */ +}; + -+/* Evaluate to true if the breakpoint NUM is valid, false otherwise. */ -+#define BPPY_VALID_P(Num) \ -+ ((Num) >= 0 \ -+ && (Num) < bppy_slots \ -+ && bppy_breakpoints[Num] != NULL) -+ -+/* Require that BREAKPOINT be a valid breakpoint ID; throw a Python -+ exception if it is invalid. */ -+#define BPPY_REQUIRE_VALID(Breakpoint) \ -+ do { \ -+ if (! BPPY_VALID_P ((Breakpoint)->number)) \ -+ return PyErr_Format (PyExc_RuntimeError, "breakpoint %d is invalid", \ -+ (Breakpoint)->number); \ -+ } while (0) -+ -+/* Require that BREAKPOINT be a valid breakpoint ID; throw a Python -+ exception if it is invalid. This macro is for use in setter functions. */ -+#define BPPY_SET_REQUIRE_VALID(Breakpoint) \ -+ do { \ -+ if (! BPPY_VALID_P ((Breakpoint)->number)) \ -+ { \ -+ PyErr_Format (PyExc_RuntimeError, "breakpoint %d is invalid", \ -+ (Breakpoint)->number); \ -+ return -1; \ -+ } \ -+ } while (0) -+ -+/* Python function which checks the validity of a breakpoint object. */ -+static PyObject * -+bppy_is_valid (PyObject *self, PyObject *args) ++void ++gdbpy_initialize_membuf (void) +{ -+ if (((breakpoint_object *) self)->bp) -+ Py_RETURN_TRUE; -+ Py_RETURN_FALSE; -+} ++ if (PyType_Ready (&membuf_object_type) < 0) ++ return; + -+/* Python function to test whether or not the breakpoint is enabled. */ -+static PyObject * -+bppy_get_enabled (PyObject *self, void *closure) -+{ -+ if (! ((breakpoint_object *) self)->bp) -+ Py_RETURN_FALSE; -+ /* Not clear what we really want here. */ -+ if (((breakpoint_object *) self)->bp->enable_state == bp_enabled) -+ Py_RETURN_TRUE; -+ Py_RETURN_FALSE; ++ Py_INCREF (&membuf_object_type); ++ PyModule_AddObject (gdb_module, "Membuf", (PyObject *) &membuf_object_type); +} +diff --git a/gdb/python/py-prettyprint.c b/gdb/python/py-prettyprint.c +index 434c8a5..b22c557 100644 +--- a/gdb/python/py-prettyprint.c ++++ b/gdb/python/py-prettyprint.c +@@ -204,10 +204,10 @@ pretty_print_one_value (PyObject *printer, struct value **out_value) + && result != Py_None) + { + *out_value = convert_value_from_python (result); +- if (PyErr_Occurred ()) +- *out_value = NULL; +- Py_DECREF (result); +- result = NULL; ++ if (PyErr_Occurred ()) ++ *out_value = NULL; ++ Py_DECREF (result); ++ result = NULL; + } + } + } +@@ -700,14 +700,7 @@ gdbpy_get_varobj_pretty_printer (struct value *value) + { + PyObject *val_obj; + PyObject *pretty_printer = NULL; +- volatile struct gdb_exception except; + +- TRY_CATCH (except, RETURN_MASK_ALL) +- { +- value = value_copy (value); +- } +- GDB_PY_HANDLE_EXCEPTION (except); +- + val_obj = value_to_value_object (value); + if (! val_obj) + return NULL; +diff --git a/gdb/python/py-type.c b/gdb/python/py-type.c +index b901255..4ff18e5 100644 +--- a/gdb/python/py-type.c ++++ b/gdb/python/py-type.c +@@ -27,6 +27,8 @@ + #include "demangle.h" + #include "objfiles.h" + #include "language.h" ++#include "observer.h" ++#include "gdb_assert.h" + + typedef struct pyty_type_object + { +@@ -35,11 +37,17 @@ typedef struct pyty_type_object + + /* If a Type object is associated with an objfile, it is kept on a + doubly-linked list, rooted in the objfile. This lets us copy the +- underlying struct type when the objfile is deleted. */ ++ underlying struct type when the objfile is deleted. + -+/* Python function to test whether or not the breakpoint is silent. */ -+static PyObject * -+bppy_get_silent (PyObject *self, void *closure) -+{ -+ BPPY_REQUIRE_VALID ((breakpoint_object *) self); -+ if (((breakpoint_object *) self)->bp->silent) -+ Py_RETURN_TRUE; -+ Py_RETURN_FALSE; -+} ++ With NULL objfile Type still can be doubly-linked in the list ++ PYTY_OBJECTS_DISCARDABLE. */ + struct pyty_type_object *prev; + struct pyty_type_object *next; + } type_object; + ++/* First element of a doubly-linked list of TYPE_DISCARDABLE Types. */ ++static type_object *pyty_objects_discardable; + -+/* Python function to set the enabled state of a breakpoint. */ -+static int -+bppy_set_enabled (PyObject *self, PyObject *newvalue, void *closure) + static PyTypeObject type_object_type; + + /* A Field object. */ +@@ -618,8 +626,59 @@ typy_str (PyObject *self) + + + ++/* Key associated with each objfile pointing to the first element of ++ a doubly-linked list of Types associated with this objfile. */ + static const struct objfile_data *typy_objfile_data_key; + ++/* Link TYPE_OBJ to its appropriate list. Either to its objfile associated one ++ or at least to the global list for TYPE_DISCARDABLE Types. Permanent types ++ do not get linked anywhere. */ ++static void ++typy_link (type_object *type_obj) +{ -+ breakpoint_object *self_bp = (breakpoint_object *) self; -+ int cmp; -+ -+ BPPY_SET_REQUIRE_VALID (self_bp); ++ type_obj->prev = NULL; + -+ if (newvalue == NULL) -+ { -+ PyErr_SetString (PyExc_TypeError, "cannot delete `enabled' attribute"); -+ return -1; -+ } -+ else if (! PyBool_Check (newvalue)) ++ if (type_obj->type && TYPE_OBJFILE (type_obj->type)) + { -+ PyErr_SetString (PyExc_TypeError, -+ "the value of `enabled' must be a boolean"); -+ return -1; -+ } -+ -+ cmp = PyObject_IsTrue (newvalue); -+ if (cmp < 0) -+ return -1; -+ else if (cmp == 1) -+ enable_breakpoint (self_bp->bp); -+ else -+ disable_breakpoint (self_bp->bp); -+ return 0; -+} -+ -+/* Python function to set the 'silent' state of a breakpoint. */ -+static int -+bppy_set_silent (PyObject *self, PyObject *newvalue, void *closure) -+{ -+ breakpoint_object *self_bp = (breakpoint_object *) self; -+ int cmp; -+ -+ BPPY_SET_REQUIRE_VALID (self_bp); ++ struct objfile *objfile = TYPE_OBJFILE (type_obj->type); + -+ if (newvalue == NULL) -+ { -+ PyErr_SetString (PyExc_TypeError, "cannot delete `silent' attribute"); -+ return -1; ++ type_obj->next = objfile_data (objfile, typy_objfile_data_key); ++ if (type_obj->next) ++ type_obj->next->prev = type_obj; ++ set_objfile_data (objfile, typy_objfile_data_key, type_obj); + } -+ else if (! PyBool_Check (newvalue)) ++ else if (type_obj->type && TYPE_DISCARDABLE (type_obj->type)) + { -+ PyErr_SetString (PyExc_TypeError, -+ "the value of `silent' must be a boolean"); -+ return -1; ++ type_obj->next = pyty_objects_discardable; ++ if (type_obj->next) ++ type_obj->next->prev = type_obj; ++ pyty_objects_discardable = type_obj; + } -+ -+ cmp = PyObject_IsTrue (newvalue); -+ if (cmp < 0) -+ return -1; + else -+ self_bp->bp->silent = cmp; -+ -+ return 0; ++ type_obj->next = NULL; +} + -+/* Python function to set the thread of a breakpoint. */ -+static int -+bppy_set_thread (PyObject *self, PyObject *newvalue, void *closure) ++/* Unlink TYPE_OBJ from its current list. Permanent types are not linked ++ anywhere and this function has no effect on them. */ ++static void ++typy_unlink (type_object *type_obj) +{ -+ breakpoint_object *self_bp = (breakpoint_object *) self; -+ int id; -+ -+ BPPY_SET_REQUIRE_VALID (self_bp); -+ -+ if (newvalue == NULL) -+ { -+ PyErr_SetString (PyExc_TypeError, "cannot delete `thread' attribute"); -+ return -1; -+ } -+ else if (PyInt_Check (newvalue)) -+ { -+ id = (int) PyInt_AsLong (newvalue); -+ if (! valid_thread_id (id)) -+ { -+ PyErr_SetString (PyExc_RuntimeError, "invalid thread id"); -+ return -1; -+ } -+ } -+ else if (newvalue == Py_None) -+ id = -1; -+ else ++ if (type_obj->prev) ++ type_obj->prev->next = type_obj->next; ++ else if (type_obj->type && TYPE_OBJFILE (type_obj->type)) + { -+ PyErr_SetString (PyExc_TypeError, -+ "the value of `thread' must be an integer or None"); -+ return -1; -+ } -+ -+ self_bp->bp->thread = id; -+ -+ return 0; -+} -+ -+/* Python function to set the ignore count of a breakpoint. */ -+static int -+bppy_set_ignore_count (PyObject *self, PyObject *newvalue, void *closure) -+{ -+ breakpoint_object *self_bp = (breakpoint_object *) self; -+ long value; -+ -+ BPPY_SET_REQUIRE_VALID (self_bp); ++ /* Must reset head of list. */ ++ struct objfile *objfile = TYPE_OBJFILE (type_obj->type); + -+ if (newvalue == NULL) -+ { -+ PyErr_SetString (PyExc_TypeError, -+ "cannot delete `ignore_count' attribute"); -+ return -1; -+ } -+ else if (! PyInt_Check (newvalue)) -+ { -+ PyErr_SetString (PyExc_TypeError, -+ "the value of `ignore_count' must be an integer"); -+ return -1; ++ set_objfile_data (objfile, typy_objfile_data_key, type_obj->next); + } ++ else if (pyty_objects_discardable == type_obj) ++ pyty_objects_discardable = type_obj->next; + -+ value = PyInt_AsLong (newvalue); -+ if (value < 0) -+ value = 0; -+ set_ignore_count (self_bp->number, (int) value, 0); -+ -+ return 0; ++ if (type_obj->next) ++ type_obj->next->prev = type_obj->prev; +} + -+/* Python function to set the hit count of a breakpoint. */ -+static int -+bppy_set_hit_count (PyObject *self, PyObject *newvalue, void *closure) -+{ -+ breakpoint_object *self_bp = (breakpoint_object *) self; -+ -+ BPPY_SET_REQUIRE_VALID (self_bp); + static void + save_objfile_types (struct objfile *objfile, void *datum) + { +@@ -637,12 +696,13 @@ save_objfile_types (struct objfile *objfile, void *datum) + { + type_object *next = obj->next; + +- htab_empty (copied_types); ++ gdb_assert (TYPE_OBJFILE (obj->type) == objfile); ++ typy_unlink (obj); + +- obj->type = copy_type_recursive (objfile, obj->type, copied_types); ++ obj->type = copy_type_recursive (obj->type, copied_types); + +- obj->next = NULL; +- obj->prev = NULL; ++ gdb_assert (TYPE_OBJFILE (obj->type) == NULL); ++ typy_link (obj); + + obj = next; + } +@@ -653,42 +713,25 @@ save_objfile_types (struct objfile *objfile, void *datum) + } + + static void +-set_type (type_object *obj, struct type *type) ++typy_dealloc (PyObject *obj) + { +- obj->type = type; +- obj->prev = NULL; +- if (type && TYPE_OBJFILE (type)) +- { +- struct objfile *objfile = TYPE_OBJFILE (type); ++ type_object *type_obj = (type_object *) obj; + +- obj->next = objfile_data (objfile, typy_objfile_data_key); +- if (obj->next) +- obj->next->prev = obj; +- set_objfile_data (objfile, typy_objfile_data_key, obj); +- } +- else +- obj->next = NULL; ++ typy_unlink (type_obj); + -+ if (newvalue == NULL) -+ { -+ PyErr_SetString (PyExc_TypeError, "cannot delete `hit_count' attribute"); -+ return -1; -+ } -+ else if (! PyInt_Check (newvalue) || PyInt_AsLong (newvalue) != 0) ++ type_obj->ob_type->tp_free (obj); + } + ++/* Call type_mark_used for any TYPEs referenced from this GDB source file. */ + static void +-typy_dealloc (PyObject *obj) ++typy_types_mark_used (void) + { +- type_object *type = (type_object *) obj; +- +- if (type->prev) +- type->prev->next = type->next; +- else if (type->type && TYPE_OBJFILE (type->type)) +- { +- /* Must reset head of list. */ +- struct objfile *objfile = TYPE_OBJFILE (type->type); +- +- if (objfile) +- set_objfile_data (objfile, typy_objfile_data_key, type->next); +- } +- if (type->next) +- type->next->prev = type->prev; ++ type_object *type_obj; + +- type->ob_type->tp_free (type); ++ for (type_obj = pyty_objects_discardable; ++ type_obj != NULL; ++ type_obj = type_obj->next) ++ type_mark_used (type_obj->type); + } + + /* Create a new Type referring to TYPE. */ +@@ -699,7 +742,10 @@ type_to_type_object (struct type *type) + + type_obj = PyObject_New (type_object, &type_object_type); + if (type_obj) +- set_type (type_obj, type); + { -+ PyErr_SetString (PyExc_AttributeError, -+ "the value of `hit_count' must be zero"); -+ return -1; ++ type_obj->type = type; ++ typy_link (type_obj); + } + + return (PyObject *) type_obj; + } +@@ -773,6 +819,8 @@ gdbpy_initialize_types (void) + + Py_INCREF (&field_object_type); + PyModule_AddObject (gdb_module, "Field", (PyObject *) &field_object_type); + -+ self_bp->bp->hit_count = 0; -+ -+ return 0; -+} -+ -+/* Python function to get the location of a breakpoint. */ -+static PyObject * -+bppy_get_location (PyObject *self, void *closure) -+{ -+ char *str; -+ -+ BPPY_REQUIRE_VALID ((breakpoint_object *) self); -+ str = ((breakpoint_object *) self)->bp->addr_string; -+ /* FIXME: watchpoints? tracepoints? */ -+ if (! str) -+ str = ""; -+ return PyString_Decode (str, strlen (str), host_charset (), NULL); -+} ++ observer_attach_mark_used (typy_types_mark_used); + } + + +diff --git a/gdb/python/py-value.c b/gdb/python/py-value.c +index 2024021..e8be12d 100644 +--- a/gdb/python/py-value.c ++++ b/gdb/python/py-value.c +@@ -25,6 +25,7 @@ + #include "language.h" + #include "dfp.h" + #include "valprint.h" ++#include "observer.h" + + #ifdef HAVE_PYTHON + +@@ -1067,6 +1068,17 @@ gdbpy_is_value_object (PyObject *obj) + return PyObject_TypeCheck (obj, &value_object_type); + } + ++/* Call type_mark_used for any TYPEs referenced from this GDB source file. */ + -+/* Python function to get the condition expression of a breakpoint. */ -+static PyObject * -+bppy_get_condition (PyObject *self, void *closure) ++static void ++python_types_mark_used (void) +{ -+ char *str; -+ BPPY_REQUIRE_VALID ((breakpoint_object *) self); ++ value_object *iter; + -+ str = ((breakpoint_object *) self)->bp->cond_string; -+ if (! str) -+ Py_RETURN_NONE; -+ return PyString_Decode (str, strlen (str), host_charset (), NULL); ++ for (iter = values_in_python; iter; iter = iter->next) ++ type_mark_used (value_type (iter->value)); +} + -+static int -+bppy_set_condition (PyObject *self, PyObject *newvalue, void *closure) -+{ -+ char *exp; -+ breakpoint_object *self_bp = (breakpoint_object *) self; -+ volatile struct gdb_exception except; + void + gdbpy_initialize_values (void) + { +@@ -1077,6 +1089,8 @@ gdbpy_initialize_values (void) + PyModule_AddObject (gdb_module, "Value", (PyObject *) &value_object_type); + + values_in_python = NULL; + -+ BPPY_SET_REQUIRE_VALID (self_bp); ++ observer_attach_mark_used (python_types_mark_used); + } + + +diff --git a/gdb/python/python-internal.h b/gdb/python/python-internal.h +index 2b8d301..0af99c8 100644 +--- a/gdb/python/python-internal.h ++++ b/gdb/python/python-internal.h +@@ -82,10 +82,11 @@ struct language_defn; + struct program_space; + + extern PyObject *gdb_module; +-extern PyTypeObject value_object_type; + extern PyTypeObject block_object_type; ++extern PyTypeObject value_object_type; + extern PyTypeObject symbol_object_type; + ++/* Used in python-inferior.c. */ + typedef struct + { + PyObject_HEAD +@@ -126,6 +127,10 @@ PyObject *block_to_block_object (struct block *block, struct objfile *objfile); + PyObject *value_to_value_object (struct value *v); + PyObject *type_to_type_object (struct type *); + PyObject *frame_info_to_frame_object (struct frame_info *frame); ++PyObject *frame_info_to_frame_object (struct frame_info *frame); ++thread_object *create_thread_object (struct thread_info *tp); ++thread_object *find_thread_object (ptid_t ptid); ++PyObject *find_inferior_object (int pid); + + PyObject *pspace_to_pspace_object (struct program_space *); + PyObject *pspy_get_printers (PyObject *, void *); +@@ -145,8 +150,11 @@ struct type *type_object_to_type (PyObject *obj); + struct symtab *symtab_object_to_symtab (PyObject *obj); + struct symtab_and_line *sal_object_to_symtab_and_line (PyObject *obj); + ++PyObject *gdbpy_get_hook_function (const char *); + void gdbpy_initialize_auto_load (void); + -+ if (newvalue == NULL) -+ { -+ PyErr_SetString (PyExc_TypeError, "cannot delete `condition' attribute"); -+ return -1; -+ } -+ else if (newvalue == Py_None) -+ exp = ""; -+ else -+ { -+ exp = python_string_to_host_string (newvalue); -+ if (exp == NULL) -+ return -1; -+ } + void gdbpy_initialize_values (void); ++void gdbpy_initialize_breakpoints (void); + void gdbpy_initialize_frames (void); + void gdbpy_initialize_symtabs (void); + void gdbpy_initialize_commands (void); +@@ -154,6 +162,7 @@ void gdbpy_initialize_symbols (void); + void gdbpy_initialize_symtabs (void); + void gdbpy_initialize_blocks (void); + void gdbpy_initialize_types (void); ++void gdbpy_initialize_blocks (void); + void gdbpy_initialize_functions (void); + void gdbpy_initialize_pspace (void); + void gdbpy_initialize_objfile (void); +@@ -171,6 +180,12 @@ struct cleanup *ensure_python_env (struct gdbarch *gdbarch, + extern struct gdbarch *python_gdbarch; + extern const struct language_defn *python_language; + ++char *gdbpy_parse_command_name (char *text, ++ struct cmd_list_element ***base_list, ++ struct cmd_list_element **start_list); + -+ TRY_CATCH (except, RETURN_MASK_ALL) -+ { -+ set_breakpoint_condition (self_bp->bp, exp, 0); -+ } -+ GDB_PY_SET_HANDLE_EXCEPTION (except); ++PyObject *gdbpy_parameter_value (enum var_types, void *); + -+ return 0; -+} + /* Use this after a TRY_EXCEPT to throw the appropriate Python + exception. */ + #define GDB_PY_HANDLE_EXCEPTION(Exception) \ +@@ -221,13 +236,14 @@ int gdbpy_is_value_object (PyObject *obj); + PyObject *apply_varobj_pretty_printer (PyObject *print_obj, + struct value **replacement); + PyObject *gdbpy_get_varobj_pretty_printer (struct value *value); ++PyObject *gdbpy_instantiate_printer (PyObject *cons, PyObject *value); + char *gdbpy_get_display_hint (PyObject *printer); + PyObject *gdbpy_default_visualizer (PyObject *self, PyObject *args); + +-extern PyObject *gdbpy_doc_cst; + extern PyObject *gdbpy_children_cst; + extern PyObject *gdbpy_to_string_cst; + extern PyObject *gdbpy_display_hint_cst; ++extern PyObject *gdbpy_doc_cst; + extern PyObject *gdbpy_enabled_cst; + + extern PyObject *gdbpy_gdberror_exc; +diff --git a/gdb/python/python.c b/gdb/python/python.c +index 7346fba..34708c4 100644 +--- a/gdb/python/python.c ++++ b/gdb/python/python.c +@@ -28,6 +28,7 @@ + #include "value.h" + #include "language.h" + #include "exceptions.h" ++#include "event-loop.h" + + #include + +@@ -42,10 +43,17 @@ static int gdbpy_should_print_stack = 1; + #include "cli/cli-decode.h" + #include "charset.h" + #include "top.h" ++#include "solib.h" + #include "python-internal.h" ++#include "linespec.h" ++#include "symtab.h" ++#include "source.h" + #include "version.h" ++#include "inferior.h" ++#include "gdbthread.h" + #include "target.h" + #include "gdbthread.h" ++#include "event-top.h" + + static PyMethodDef GdbMethods[]; + +@@ -374,6 +382,105 @@ execute_gdb_command (PyObject *self, PyObject *args, PyObject *kw) + Py_RETURN_NONE; + } + ++/* Implementation of gdb.solib_address (Long) -> String. ++ Returns the name of the shared library holding a given address, or None. */ + -+/* Python function to get the commands attached to a breakpoint. */ +static PyObject * -+bppy_get_commands (PyObject *self, void *closure) ++gdbpy_solib_address (PyObject *self, PyObject *args) +{ -+ breakpoint_object *self_bp = (breakpoint_object *) self; -+ long length; -+ volatile struct gdb_exception except; -+ struct ui_file *string_file; -+ struct cleanup *chain; -+ PyObject *result; -+ char *cmdstr; -+ -+ BPPY_REQUIRE_VALID (self_bp); -+ -+ if (! self_bp->bp->commands) -+ Py_RETURN_NONE; ++ unsigned long long pc; ++ char *soname; ++ PyObject *str_obj; + -+ string_file = mem_fileopen (); -+ chain = make_cleanup_ui_file_delete (string_file); ++ if (!PyArg_ParseTuple (args, "K", &pc)) ++ return NULL; + -+ TRY_CATCH (except, RETURN_MASK_ALL) ++ soname = solib_name_from_address (current_program_space, pc); ++ if (soname) ++ str_obj = PyString_Decode (soname, strlen (soname), host_charset (), NULL); ++ else + { -+ /* FIXME: this can fail. Maybe we need to be making a new -+ ui_out object here? */ -+ ui_out_redirect (uiout, string_file); -+ print_command_lines (uiout, self_bp->bp->commands, 0); -+ ui_out_redirect (uiout, NULL); ++ str_obj = Py_None; ++ Py_INCREF (Py_None); + } -+ cmdstr = ui_file_xstrdup (string_file, &length); -+ GDB_PY_HANDLE_EXCEPTION (except); + -+ result = PyString_Decode (cmdstr, strlen (cmdstr), host_charset (), NULL); -+ do_cleanups (chain); -+ xfree (cmdstr); -+ return result; ++ return str_obj; +} + -+/* Python function to get the breakpoint's number. */ -+static PyObject * -+bppy_get_number (PyObject *self, void *closure) -+{ -+ breakpoint_object *self_bp = (breakpoint_object *) self; -+ -+ BPPY_REQUIRE_VALID (self_bp); -+ -+ return PyInt_FromLong (self_bp->number); -+} ++/* A Python function which is a wrapper for decode_line_1. */ + -+/* Python function to get the breakpoint's thread ID. */ +static PyObject * -+bppy_get_thread (PyObject *self, void *closure) ++gdbpy_decode_line (PyObject *self, PyObject *args) +{ -+ breakpoint_object *self_bp = (breakpoint_object *) self; -+ -+ BPPY_REQUIRE_VALID (self_bp); -+ -+ if (self_bp->bp->thread == -1) -+ Py_RETURN_NONE; -+ -+ return PyInt_FromLong (self_bp->bp->thread); -+} -+ -+/* Python function to get the breakpoint's hit count. */ -+static PyObject * -+bppy_get_hit_count (PyObject *self, void *closure) -+{ -+ breakpoint_object *self_bp = (breakpoint_object *) self; -+ -+ BPPY_REQUIRE_VALID (self_bp); -+ -+ return PyInt_FromLong (self_bp->bp->hit_count); -+} -+ -+/* Python function to get the breakpoint's ignore count. */ -+static PyObject * -+bppy_get_ignore_count (PyObject *self, void *closure) -+{ -+ breakpoint_object *self_bp = (breakpoint_object *) self; -+ -+ BPPY_REQUIRE_VALID (self_bp); -+ -+ return PyInt_FromLong (self_bp->bp->ignore_count); -+} -+ -+/* Python function to create a new breakpoint. */ -+static PyObject * -+bppy_new (PyTypeObject *subtype, PyObject *args, PyObject *kwargs) -+{ -+ PyObject *result; -+ char *spec; ++ struct symtabs_and_lines sals = { NULL, 0 }; /* Initialize to appease gcc. */ ++ struct symtab_and_line sal; ++ char *arg = NULL; ++ int free_sals = 0, i; ++ PyObject *result = NULL; + volatile struct gdb_exception except; + -+ /* FIXME: allow condition, thread, temporary, ... ? */ -+ if (! PyArg_ParseTuple (args, "s", &spec)) -+ return NULL; -+ result = subtype->tp_alloc (subtype, 0); -+ if (! result) ++ if (! PyArg_ParseTuple (args, "|s", &arg)) + return NULL; -+ bppy_pending_object = (breakpoint_object *) result; -+ bppy_pending_object->number = -1; -+ bppy_pending_object->bp = NULL; + + TRY_CATCH (except, RETURN_MASK_ALL) + { -+ set_breakpoint (python_gdbarch, spec, NULL, 0, 0, -1, 0, -+ AUTO_BOOLEAN_TRUE, 1); ++ if (arg) ++ { ++ char *copy; ++ ++ arg = strdup (arg); ++ copy = arg; ++ ++ sals = decode_line_1 (©, 0, 0, 0, 0, 0); ++ free_sals = 1; ++ } ++ else ++ { ++ set_default_source_symtab_and_line (); ++ sal = get_current_source_symtab_and_line (); ++ sals.sals = &sal; ++ sals.nelts = 1; ++ } + } ++ if (arg) ++ xfree (arg); ++ + if (except.reason < 0) + { -+ subtype->tp_free (result); -+ return PyErr_Format (except.reason == RETURN_QUIT -+ ? PyExc_KeyboardInterrupt : PyExc_RuntimeError, -+ "%s", except.message); ++ if (free_sals) ++ xfree (sals.sals); ++ /* We know this will always throw. */ ++ GDB_PY_HANDLE_EXCEPTION (except); + } + -+ BPPY_REQUIRE_VALID ((breakpoint_object *) result); -+ return result; -+} -+ -+ ++ if (sals.nelts) ++ { ++ result = PyTuple_New (sals.nelts); ++ for (i = 0; i < sals.nelts; ++i) ++ { ++ PyObject *obj; ++ char *str; + -+/* Static function to return a tuple holding all breakpoints. */ ++ obj = symtab_and_line_to_sal_object (sals.sals[i]); ++ if (! obj) ++ { ++ Py_DECREF (result); ++ result = NULL; ++ break; ++ } + -+PyObject * -+gdbpy_breakpoints (PyObject *self, PyObject *args) -+{ -+ PyObject *result; ++ PyTuple_SetItem (result, i, obj); ++ } ++ } + -+ if (bppy_live == 0) -+ Py_RETURN_NONE; ++ if (free_sals) ++ xfree (sals.sals); + -+ result = PyTuple_New (bppy_live); + if (result) -+ { -+ int i, out = 0; -+ for (i = 0; out < bppy_live; ++i) -+ { -+ if (! bppy_breakpoints[i]) -+ continue; -+ Py_INCREF (bppy_breakpoints[i]); -+ PyTuple_SetItem (result, out, (PyObject *) bppy_breakpoints[i]); -+ ++out; -+ } -+ } -+ return result; ++ return result; ++ Py_RETURN_NONE; +} + -+ + /* Parse a string and evaluate it as an expression. */ + static PyObject * + gdbpy_parse_and_eval (PyObject *self, PyObject *args) +@@ -414,6 +521,114 @@ source_python_script (FILE *stream, const char *file) + + + ++/* Posting and handling events. */ ++ ++/* A single event. */ ++struct gdbpy_event ++{ ++ /* The Python event. This is just a callable object. */ ++ PyObject *event; ++ /* The next event. */ ++ struct gdbpy_event *next; ++}; ++ ++/* All pending events. */ ++static struct gdbpy_event *gdbpy_event_list; ++/* The final link of the event list. */ ++static struct gdbpy_event **gdbpy_event_list_end; + -+/* Event callback functions. */ ++/* We use a file handler, and not an async handler, so that we can ++ wake up the main thread even when it is blocked in poll(). */ ++static int gdbpy_event_fds[2]; + -+/* Callback that is used when a breakpoint is created. This function -+ will create a new Python breakpoint object. */ ++/* The file handler callback. This reads from the internal pipe, and ++ then processes the Python event queue. This will always be run in ++ the main gdb thread. */ +static void -+gdbpy_breakpoint_created (int num) ++gdbpy_run_events (int err, gdb_client_data ignore) +{ -+ breakpoint_object *newbp; -+ struct breakpoint *bp; -+ PyGILState_STATE state; ++ struct cleanup *cleanup; ++ char buffer[100]; ++ int r; + -+ if (num < 0) -+ return; ++ cleanup = ensure_python_env (get_current_arch (), current_language); + -+ for (bp = breakpoint_chain; bp; bp = bp->next) -+ if (bp->number == num) -+ break; -+ if (! bp) -+ return; ++ /* Just read whatever is available on the fd. It is relatively ++ harmless if there are any bytes left over. */ ++ r = read (gdbpy_event_fds[0], buffer, sizeof (buffer)); + -+ if (num >= bppy_slots) ++ while (gdbpy_event_list) + { -+ int old = bppy_slots; -+ bppy_slots = bppy_slots * 2 + 10; -+ bppy_breakpoints -+ = (breakpoint_object **) xrealloc (bppy_breakpoints, -+ (bppy_slots -+ * sizeof (breakpoint_object *))); -+ memset (&bppy_breakpoints[old], 0, -+ (bppy_slots - old) * sizeof (PyObject *)); ++ /* Dispatching the event might push a new element onto the event ++ loop, so we update here "atomically enough". */ ++ struct gdbpy_event *item = gdbpy_event_list; ++ gdbpy_event_list = gdbpy_event_list->next; ++ if (gdbpy_event_list == NULL) ++ gdbpy_event_list_end = &gdbpy_event_list; ++ ++ /* Ignore errors. */ ++ PyObject_CallObject (item->event, NULL); ++ ++ Py_DECREF (item->event); ++ xfree (item); + } + -+ ++bppy_live; ++ do_cleanups (cleanup); ++} ++ ++/* Submit an event to the gdb thread. */ ++static PyObject * ++gdbpy_post_event (PyObject *self, PyObject *args) ++{ ++ struct gdbpy_event *event; ++ PyObject *func; ++ int wakeup; + -+ state = PyGILState_Ensure (); ++ if (!PyArg_ParseTuple (args, "O", &func)) ++ return NULL; + -+ if (bppy_pending_object) ++ if (!PyCallable_Check (func)) + { -+ newbp = bppy_pending_object; -+ bppy_pending_object = NULL; ++ PyErr_SetString (PyExc_RuntimeError, "Posted event is not callable"); ++ return NULL; + } -+ else -+ newbp = PyObject_New (breakpoint_object, &breakpoint_object_type); -+ if (newbp) -+ { -+ PyObject *hookfn; + -+ newbp->number = num; -+ newbp->bp = bp; -+ bppy_breakpoints[num] = newbp; ++ Py_INCREF (func); + -+ hookfn = gdbpy_get_hook_function ("new_breakpoint"); -+ if (hookfn) -+ { -+ PyObject *result; -+ result = PyObject_CallFunctionObjArgs (hookfn, newbp, NULL); -+ if (result) -+ { -+ Py_DECREF (result); -+ } -+ Py_DECREF (hookfn); -+ } -+ } ++ /* From here until the end of the function, we have the GIL, so we ++ can operate on our global data structures without worrying. */ ++ wakeup = gdbpy_event_list == NULL; ++ ++ event = XNEW (struct gdbpy_event); ++ event->event = func; ++ event->next = NULL; ++ *gdbpy_event_list_end = event; ++ gdbpy_event_list_end = &event->next; + -+ /* Just ignore errors here. */ -+ PyErr_Clear (); ++ /* Wake up gdb when needed. */ ++ if (wakeup) ++ { ++ char c = 'q'; /* Anything. */ ++ if (write (gdbpy_event_fds[1], &c, 1) != 1) ++ return PyErr_SetFromErrno (PyExc_IOError); ++ } + -+ PyGILState_Release (state); ++ Py_RETURN_NONE; +} + -+/* Callback that is used when a breakpoint is deleted. This will -+ invalidate the corresponding Python object. */ ++/* Initialize the Python event handler. */ +static void -+gdbpy_breakpoint_deleted (int num) ++gdbpy_initialize_events (void) +{ -+ PyGILState_STATE state; -+ -+ state = PyGILState_Ensure (); -+ if (BPPY_VALID_P (num)) ++ if (!pipe (gdbpy_event_fds)) + { -+ bppy_breakpoints[num]->bp = NULL; -+ Py_DECREF (bppy_breakpoints[num]); -+ bppy_breakpoints[num] = NULL; -+ --bppy_live; ++ gdbpy_event_list_end = &gdbpy_event_list; ++ add_file_handler (gdbpy_event_fds[0], gdbpy_run_events, NULL); + } -+ PyGILState_Release (state); +} + + + -+/* Initialize the Python breakpoint code. */ + /* Printing. */ + + /* A python function to write a single string using gdb's filtered +@@ -459,6 +674,53 @@ gdbpy_print_stack (void) + + /* Return the current Progspace. + There always is one. */ ++/* True if 'gdb -P' was used, false otherwise. */ ++static int running_python_script; ++ ++/* True if we are currently in a call to 'gdb.cli', false otherwise. */ ++static int in_cli; ++ ++/* Enter the command loop. */ ++ ++static PyObject * ++gdbpy_cli (PyObject *unused1, PyObject *unused2) ++{ ++ if (! running_python_script || in_cli) ++ return PyErr_Format (PyExc_RuntimeError, "cannot invoke CLI recursively"); ++ ++ in_cli = 1; ++ cli_command_loop (); ++ in_cli = 0; ++ ++ Py_RETURN_NONE; ++} ++ ++/* Set up the Python argument vector and evaluate a script. This is ++ used to implement 'gdb -P'. */ ++ +void -+gdbpy_initialize_breakpoints (void) ++run_python_script (int argc, char **argv) +{ -+ breakpoint_object_type.tp_new = bppy_new; -+ if (PyType_Ready (&breakpoint_object_type) < 0) -+ return; ++ FILE *input; + -+ Py_INCREF (&breakpoint_object_type); -+ PyModule_AddObject (gdb_module, "Breakpoint", -+ (PyObject *) &breakpoint_object_type); ++ /* We never free this, since we plan to exit at the end. */ ++ ensure_python_env (get_current_arch (), current_language); + -+ observer_attach_breakpoint_created (gdbpy_breakpoint_created); -+ observer_attach_breakpoint_deleted (gdbpy_breakpoint_deleted); ++ running_python_script = 1; ++ PySys_SetArgv (argc - 1, argv + 1); ++ input = fopen (argv[0], "r"); ++ if (! input) ++ { ++ fprintf (stderr, "could not open %s: %s\n", argv[0], strerror (errno)); ++ exit (1); ++ } ++ PyRun_SimpleFile (input, argv[0]); ++ fclose (input); ++ exit (0); +} + + + -+static PyGetSetDef breakpoint_object_getset[] = { -+ { "enabled", bppy_get_enabled, bppy_set_enabled, -+ "Boolean telling whether the breakpoint is enabled.", NULL }, -+ { "silent", bppy_get_silent, bppy_set_silent, -+ "Boolean telling whether the breakpoint is silent.", NULL }, -+ { "thread", bppy_get_thread, bppy_set_thread, -+ "Thread ID for the breakpoint.\n\ -+If the value is a thread ID (integer), then this is a thread-specific breakpoint.\n\ -+If the value is None, then this breakpoint not thread-specific.\n\ -+No other type of value can be used.", NULL }, -+ { "ignore_count", bppy_get_ignore_count, bppy_set_ignore_count, -+ "Number of times this breakpoint should be automatically continued.", -+ NULL }, -+ { "number", bppy_get_number, NULL, -+ "Breakpoint's number assigned by GDB.", NULL }, -+ { "hit_count", bppy_get_hit_count, bppy_set_hit_count, -+ "Number of times the breakpoint has been hit.\n\ -+Can be set to zero to clear the count. No other value is valid\n\ -+when setting this property.", NULL }, -+ { "location", bppy_get_location, NULL, -+ "Location of the breakpoint, as specified by the user.", NULL}, -+ { "condition", bppy_get_condition, bppy_set_condition, -+ "Condition of the breakpoint, as specified by the user,\ -+or None if no condition set."}, -+ { "commands", bppy_get_commands, NULL, -+ "Commands of the breakpoint, as specified by the user."}, -+ { NULL } /* Sentinel. */ -+}; + + static PyObject * + gdbpy_get_current_progspace (PyObject *unused1, PyObject *unused2) +@@ -720,6 +982,7 @@ Enables or disables printing of Python stack traces."), + gdbpy_initialize_lazy_string (); + gdbpy_initialize_thread (); + gdbpy_initialize_inferior (); ++ gdbpy_initialize_events (); + + PyRun_SimpleString ("import gdb"); + PyRun_SimpleString ("gdb.pretty_printers = []"); +@@ -787,6 +1050,8 @@ static PyMethodDef GdbMethods[] = + "Get a value from history" }, + { "execute", (PyCFunction) execute_gdb_command, METH_VARARGS | METH_KEYWORDS, + "Execute a gdb command" }, ++ { "cli", gdbpy_cli, METH_NOARGS, ++ "Enter the gdb CLI" }, + { "parameter", gdbpy_parameter, METH_VARARGS, + "Return a gdb parameter's value" }, + +@@ -825,11 +1090,21 @@ a boolean indicating if name is a field of the current implied argument\n\ + `this' (when the current language is object-oriented)." }, + { "block_for_pc", gdbpy_block_for_pc, METH_VARARGS, + "Return the block containing the given pc value, or None." }, ++ { "solib_address", gdbpy_solib_address, METH_VARARGS, ++ "solib_address (Long) -> String.\n\ ++Return the name of the shared library holding a given address, or None." }, ++ { "decode_line", gdbpy_decode_line, METH_VARARGS, ++ "Decode a string argument the way that 'break' or 'edit' does.\n\ ++Return a tuple holding the file name (or None) and line number (or None).\n\ ++Note: may later change to return an object." }, + { "parse_and_eval", gdbpy_parse_and_eval, METH_VARARGS, + "parse_and_eval (String) -> Value.\n\ + Parse String as an expression, evaluate it, and return the result as a Value." + }, + ++ { "post_event", gdbpy_post_event, METH_VARARGS, ++ "Post an event into gdb's event loop." }, + -+static PyMethodDef breakpoint_object_methods[] = -+{ -+ { "is_valid", bppy_is_valid, METH_NOARGS, -+ "Return true if this breakpoint is valid, false if not." }, -+ { NULL } /* Sentinel. */ -+}; + { "target_charset", gdbpy_target_charset, METH_NOARGS, + "target_charset () -> string.\n\ + Return the name of the current target charset." }, +diff --git a/gdb/python/python.h b/gdb/python/python.h +index affd4a4..5407878 100644 +--- a/gdb/python/python.h ++++ b/gdb/python/python.h +@@ -28,6 +28,8 @@ void eval_python_from_control_command (struct command_line *); + + void source_python_script (FILE *stream, const char *file); + ++void run_python_script (int argc, char **argv); + -+static PyTypeObject breakpoint_object_type = -+{ -+ PyObject_HEAD_INIT (NULL) -+ 0, /*ob_size*/ -+ "gdb.Breakpoint", /*tp_name*/ -+ sizeof (breakpoint_object), /*tp_basicsize*/ -+ 0, /*tp_itemsize*/ -+ 0, /*tp_dealloc*/ -+ 0, /*tp_print*/ -+ 0, /*tp_getattr*/ -+ 0, /*tp_setattr*/ -+ 0, /*tp_compare*/ -+ 0, /*tp_repr*/ -+ 0, /*tp_as_number*/ -+ 0, /*tp_as_sequence*/ -+ 0, /*tp_as_mapping*/ -+ 0, /*tp_hash */ -+ 0, /*tp_call*/ -+ 0, /*tp_str*/ -+ 0, /*tp_getattro*/ -+ 0, /*tp_setattro*/ -+ 0, /*tp_as_buffer*/ -+ Py_TPFLAGS_DEFAULT, /*tp_flags*/ -+ "GDB breakpoint object", /* tp_doc */ -+ 0, /* tp_traverse */ -+ 0, /* tp_clear */ -+ 0, /* tp_richcompare */ -+ 0, /* tp_weaklistoffset */ -+ 0, /* tp_iter */ -+ 0, /* tp_iternext */ -+ breakpoint_object_methods, /* tp_methods */ -+ 0, /* tp_members */ -+ breakpoint_object_getset /* tp_getset */ -+}; -diff --git a/gdb/python/py-cmd.c b/gdb/python/py-cmd.c -index 528aca6..04b3fd1 100644 ---- a/gdb/python/py-cmd.c -+++ b/gdb/python/py-cmd.c -@@ -49,8 +49,7 @@ static struct cmdpy_completer completers[] = + int apply_val_pretty_printer (struct type *type, const gdb_byte *valaddr, + int embedded_offset, CORE_ADDR address, + struct ui_file *stream, int recurse, +diff --git a/gdb/solib-svr4.c b/gdb/solib-svr4.c +index 1f135d4..489838d 100644 +--- a/gdb/solib-svr4.c ++++ b/gdb/solib-svr4.c +@@ -1278,7 +1278,8 @@ svr4_in_dynsym_resolve_code (CORE_ADDR pc) + && pc < info->interp_text_sect_high) + || (pc >= info->interp_plt_sect_low + && pc < info->interp_plt_sect_high) +- || in_plt_section (pc, NULL)); ++ || in_plt_section (pc, NULL) ++ || in_gnu_ifunc_stub (pc)); + } - #define N_COMPLETERS (sizeof (completers) / sizeof (completers[0])) + /* Given an executable's ABFD and target, compute the entry-point +diff --git a/gdb/symfile.c b/gdb/symfile.c +index 42f7ae3..371db0d 100644 +--- a/gdb/symfile.c ++++ b/gdb/symfile.c +@@ -1059,6 +1059,9 @@ symbol_file_add_with_addrs_or_offsets (bfd *abfd, + const char *name = bfd_get_filename (abfd); + const int from_tty = add_flags & SYMFILE_VERBOSE; --/* A gdb command. For the time being only ordinary commands (not -- set/show commands) are allowed. */ -+/* A gdb command. */ - struct cmdpy_object ++ if (readnow_symbol_files) ++ flags |= OBJF_READNOW; ++ + my_cleanups = make_cleanup_bfd_close (abfd); + + /* Give user a chance to burp if we'd be +@@ -1095,7 +1098,7 @@ symbol_file_add_with_addrs_or_offsets (bfd *abfd, + the gdb startup command line or on a per symbol file basis. Expand + all partial symbol tables for this objfile if so. */ + +- if ((flags & OBJF_READNOW) || readnow_symbol_files) ++ if ((flags & OBJF_READNOW)) + { + if (from_tty || info_verbose) + { +@@ -1533,7 +1536,7 @@ symbol_file_command (char *args, int from_tty) + void + set_initial_language (void) { - PyObject_HEAD -@@ -70,7 +69,6 @@ typedef struct cmdpy_object cmdpy_object; +- char *filename; ++ const char *filename; + enum language lang = language_unknown; - static PyTypeObject cmdpy_object_type; + filename = find_main_filename (); +@@ -2660,7 +2663,7 @@ init_filename_language_table (void) + } -- - /* Constants used by this module. */ - static PyObject *invoke_cst; - static PyObject *complete_cst; -@@ -263,10 +261,13 @@ cmdpy_completer (struct cmd_list_element *command, char *text, char *word) - *BASE_LIST is set to the final prefix command's list of - *sub-commands. - -+ START_LIST is the list in which the search starts. -+ - This function returns the xmalloc()d name of the new command. On - error sets the Python error and returns NULL. */ --static char * --parse_command_name (char *text, struct cmd_list_element ***base_list) -+char * -+gdbpy_parse_command_name (char *text, struct cmd_list_element ***base_list, -+ struct cmd_list_element **start_list) + enum language +-deduce_language_from_filename (char *filename) ++deduce_language_from_filename (const char *filename) { - struct cmd_list_element *elt; - int len = strlen (text); -@@ -299,7 +300,7 @@ parse_command_name (char *text, struct cmd_list_element ***base_list) - ; - if (i < 0) - { -- *base_list = &cmdlist; -+ *base_list = start_list; - return result; - } + int i; + char *cp; +diff --git a/gdb/symfile.h b/gdb/symfile.h +index d53c465..5815354 100644 +--- a/gdb/symfile.h ++++ b/gdb/symfile.h +@@ -171,6 +171,15 @@ struct quick_symbol_functions + int kind, const char *name, + domain_enum domain); + ++ /* This is called to expand symbol tables before looking up a ++ symbol. A backend can choose to implement this and then have its ++ `lookup_symbol' hook always return NULL, or the reverse. (It ++ doesn't make sense to implement both.) The arguments are as for ++ `lookup_symbol'. */ ++ void (*pre_expand_symtabs_matching) (struct objfile *objfile, ++ int kind, const char *name, ++ domain_enum domain); ++ + /* Print statistics about any indices loaded for OBJFILE. The + statistics should be printed to gdb_stdout. This is used for + "maint print statistics". */ +@@ -201,7 +210,7 @@ struct quick_symbol_functions + + /* Return the file name of the file holding the symbol in OBJFILE + named NAME. If no such symbol exists in OBJFILE, return NULL. */ +- char *(*find_symbol_file) (struct objfile *objfile, const char *name); ++ const char *(*find_symbol_file) (struct objfile *objfile, const char *name); + + /* This method is specific to Ada. It walks the partial symbol + tables of OBJFILE looking for a name match. WILD_MATCH and +@@ -566,6 +575,7 @@ extern struct cleanup *increment_reading_symtab (void); -@@ -308,7 +309,7 @@ parse_command_name (char *text, struct cmd_list_element ***base_list) - prefix_text[i + 1] = '\0'; + extern int dwarf2_has_info (struct objfile *); - text = prefix_text; -- elt = lookup_cmd_1 (&text, cmdlist, NULL, 1); -+ elt = lookup_cmd_1 (&text, *start_list, NULL, 1); - if (!elt || elt == (struct cmd_list_element *) -1) - { - PyErr_Format (PyExc_RuntimeError, _("could not find command prefix %s"), -@@ -399,7 +400,7 @@ cmdpy_init (PyObject *self, PyObject *args, PyObject *kw) - return -1; - } ++extern int dwarf2_initialize_objfile (struct objfile *); + extern void dwarf2_build_psymtabs (struct objfile *); + extern void dwarf2_build_frame_info (struct objfile *); -- cmd_name = parse_command_name (name, &cmd_list); -+ cmd_name = gdbpy_parse_command_name (name, &cmd_list, &cmdlist); - if (! cmd_name) - return -1; - -diff --git a/gdb/python/py-frame.c b/gdb/python/py-frame.c -index 279415c..5d8ce0a 100644 ---- a/gdb/python/py-frame.c -+++ b/gdb/python/py-frame.c -@@ -202,10 +202,59 @@ frapy_pc (PyObject *self, PyObject *args) - return PyLong_FromUnsignedLongLong (pc); - } +diff --git a/gdb/symmisc.c b/gdb/symmisc.c +index 62e6b97..00dc613 100644 +--- a/gdb/symmisc.c ++++ b/gdb/symmisc.c +@@ -262,6 +262,9 @@ dump_msymbols (struct objfile *objfile, struct ui_file *outfile) + case mst_text: + ms_type = 'T'; + break; ++ case mst_text_gnu_ifunc: ++ ms_type = 'i'; ++ break; + case mst_solib_trampoline: + ms_type = 'S'; + break; +diff --git a/gdb/symtab.c b/gdb/symtab.c +index 2c4c9e4..28f0450 100644 +--- a/gdb/symtab.c ++++ b/gdb/symtab.c +@@ -1295,16 +1295,25 @@ lookup_symbol_aux_symtabs (int block_index, const char *name, + const struct block *block; + struct symtab *s; -+/* Implementation of gdb.Frame.block (self) -> gdb.Block. -+ Returns the frame's code block. */ -+ -+static PyObject * -+frapy_block (PyObject *self, PyObject *args) -+{ -+ struct frame_info *frame; -+ struct block *block = NULL; -+ volatile struct gdb_exception except; -+ -+ TRY_CATCH (except, RETURN_MASK_ALL) -+ { -+ FRAPY_REQUIRE_VALID ((frame_object *) self, frame); -+ -+ block = block_for_pc (get_frame_address_in_block (frame)); -+ } -+ GDB_PY_HANDLE_EXCEPTION (except); -+ -+ if (block) -+ return block_to_block_object (block); -+ -+ Py_RETURN_NONE; -+} -+ +- ALL_PRIMARY_SYMTABS (objfile, s) ++ ALL_OBJFILES (objfile) + { +- bv = BLOCKVECTOR (s); +- block = BLOCKVECTOR_BLOCK (bv, block_index); +- sym = lookup_block_symbol (block, name, domain); +- if (sym) +- { +- block_found = block; +- return fixup_symbol_section (sym, objfile); +- } ++ if (objfile->sf) ++ objfile->sf->qf->pre_expand_symtabs_matching (objfile, ++ block_index, ++ name, domain); + -+/* Implementation of gdb.Frame.function (self) -> gdb.Symbol. -+ Returns the symbol for the function corresponding to this frame. */ ++ ALL_OBJFILE_SYMTABS (objfile, s) ++ if (s->primary) ++ { ++ bv = BLOCKVECTOR (s); ++ block = BLOCKVECTOR_BLOCK (bv, block_index); ++ sym = lookup_block_symbol (block, name, domain); ++ if (sym) ++ { ++ block_found = block; ++ return fixup_symbol_section (sym, objfile); ++ } ++ } + } + + return NULL; +@@ -1547,15 +1556,24 @@ basic_lookup_transparent_type (const char *name) + of the desired name as a global, then do psymtab-to-symtab + conversion on the fly and return the found symbol. */ + +- ALL_PRIMARY_SYMTABS (objfile, s) ++ ALL_OBJFILES (objfile) + { +- bv = BLOCKVECTOR (s); +- block = BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK); +- sym = lookup_block_symbol (block, name, STRUCT_DOMAIN); +- if (sym && !TYPE_IS_OPAQUE (SYMBOL_TYPE (sym))) +- { +- return SYMBOL_TYPE (sym); +- } ++ if (objfile->sf) ++ objfile->sf->qf->pre_expand_symtabs_matching (objfile, ++ GLOBAL_BLOCK, ++ name, STRUCT_DOMAIN); + -+static PyObject * -+frapy_function (PyObject *self, PyObject *args) -+{ -+ struct symbol *sym = NULL; -+ struct frame_info *frame; -+ volatile struct gdb_exception except; ++ ALL_OBJFILE_SYMTABS (objfile, s) ++ if (s->primary) ++ { ++ bv = BLOCKVECTOR (s); ++ block = BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK); ++ sym = lookup_block_symbol (block, name, STRUCT_DOMAIN); ++ if (sym && !TYPE_IS_OPAQUE (SYMBOL_TYPE (sym))) ++ { ++ return SYMBOL_TYPE (sym); ++ } ++ } + } + + ALL_OBJFILES (objfile) +@@ -1599,14 +1617,16 @@ basic_lookup_transparent_type (const char *name) + /* FIXME: What about languages without main() or specially linked + executables that have no main() ? */ + +-char * ++const char * + find_main_filename (void) + { + struct objfile *objfile; +- char *result, *name = main_name (); ++ char *name = main_name (); + + ALL_OBJFILES (objfile) + { ++ const char *result; + -+ TRY_CATCH (except, RETURN_MASK_ALL) -+ { -+ FRAPY_REQUIRE_VALID ((frame_object *) self, frame); + if (!objfile->sf) + continue; + result = objfile->sf->qf->find_symbol_file (objfile, name); +@@ -2914,7 +2934,7 @@ search_symbols (char *regexp, domain_enum kind, int nfiles, char *files[], + static enum minimal_symbol_type types3[] + = {mst_file_data, mst_solib_trampoline, mst_abs, mst_unknown}; + static enum minimal_symbol_type types4[] +- = {mst_file_bss, mst_text, mst_abs, mst_unknown}; ++ = {mst_file_bss, mst_text_gnu_ifunc, mst_abs, mst_unknown}; + enum minimal_symbol_type ourtype; + enum minimal_symbol_type ourtype2; + enum minimal_symbol_type ourtype3; +diff --git a/gdb/symtab.h b/gdb/symtab.h +index bedc10a..dc284e4 100644 +--- a/gdb/symtab.h ++++ b/gdb/symtab.h +@@ -277,6 +277,9 @@ enum minimal_symbol_type + { + mst_unknown = 0, /* Unknown type, the default */ + mst_text, /* Generally executable instructions */ ++ mst_text_gnu_ifunc, /* Executable code returning address ++ of executable code */ ++ mst_slot_got_plt, + mst_data, /* Generally initialized data */ + mst_bss, /* Generally uninitialized data */ + mst_abs, /* Generally absolute (nonrelocatable) */ +@@ -917,11 +920,25 @@ extern struct symbol *find_pc_sect_function (CORE_ADDR, struct obj_section *); + + /* lookup function from address, return name, start addr and end addr */ + +-extern int find_pc_partial_function (CORE_ADDR, char **, CORE_ADDR *, +- CORE_ADDR *); ++extern enum find_pc_partial_function_type ++ { ++ FIND_PC_PARTIAL_FUNCTION_NOT_FOUND = 0, ++ FIND_PC_PARTIAL_FUNCTION_NORMAL, ++ FIND_PC_PARTIAL_FUNCTION_GNU_IFUNC ++ } find_pc_partial_function (CORE_ADDR, char **, CORE_ADDR *, CORE_ADDR *); + + extern void clear_pc_function_cache (void); + ++extern int resolve_gnu_ifunc (const char *function_name, ++ CORE_ADDR *function_addressp); + -+ sym = find_pc_function (get_frame_address_in_block (frame)); -+ } -+ GDB_PY_HANDLE_EXCEPTION (except); ++extern struct minimal_symbol *resolve_gnu_ifunc_by_cache ++ (const char *function_name); + -+ if (sym) -+ return symbol_to_symbol_object (sym); ++extern void gnu_ifunc_record_cache (struct gdbarch *gdbarch, ++ const char *function_name, ++ CORE_ADDR function_address); + -+ Py_RETURN_NONE; -+} + /* lookup partial symbol table by address and section */ + + extern struct symtab *find_pc_sect_symtab_via_partial (CORE_ADDR, +@@ -996,6 +1013,8 @@ extern struct minimal_symbol *lookup_minimal_symbol_by_pc_name + + extern struct minimal_symbol *lookup_minimal_symbol_by_pc (CORE_ADDR); + ++extern int in_gnu_ifunc_stub (CORE_ADDR pc); + - /* Convert a frame_info struct to a Python Frame object. - Sets a Python exception and returns NULL on error. */ + extern struct minimal_symbol * + lookup_minimal_symbol_and_objfile (const char *, + struct objfile **); +@@ -1137,7 +1156,7 @@ extern char **make_source_files_completion_list (char *, char *); --static frame_object * -+PyObject * - frame_info_to_frame_object (struct frame_info *frame) - { - frame_object *frame_obj; -@@ -235,7 +284,7 @@ frame_info_to_frame_object (struct frame_info *frame) + int matching_obj_sections (struct obj_section *, struct obj_section *); - frame_obj->gdbarch = get_frame_arch (frame); +-extern char *find_main_filename (void); ++extern const char *find_main_filename (void); -- return frame_obj; -+ return (PyObject *) frame_obj; - } + extern struct symtab *find_line_symtab (struct symtab *, int, int *, int *); - /* Implementation of gdb.Frame.older (self) -> gdb.Frame. -@@ -296,7 +345,30 @@ frapy_newer (PyObject *self, PyObject *args) - return next_obj; - } +@@ -1150,7 +1169,7 @@ extern void skip_prologue_sal (struct symtab_and_line *); --/* Implementation of gdb.Frame.read_var_value (self, variable) -> gdb.Value. -+/* Implementation of gdb.Frame.find_sal (self) -> gdb.Symtab_and_line. -+ Returns the frame's symtab and line. */ -+ -+static PyObject * -+frapy_find_sal (PyObject *self, PyObject *args) -+{ -+ struct frame_info *frame; -+ struct symtab_and_line sal; -+ volatile struct gdb_exception except; -+ PyObject *sal_obj = NULL; /* Initialize to appease gcc warning. */ -+ -+ TRY_CATCH (except, RETURN_MASK_ALL) -+ { -+ FRAPY_REQUIRE_VALID ((frame_object *) self, frame); -+ -+ find_frame_sal (frame, &sal); -+ sal_obj = symtab_and_line_to_sal_object (sal); -+ } -+ GDB_PY_HANDLE_EXCEPTION (except); -+ -+ return sal_obj; -+} -+ -+/* Implementation of gdb.Frame.read_var (self, variable) -> gdb.Value. - Returns the value of the given variable in this frame. The argument must be - a string. Returns None if GDB can't find the specified variable. */ + extern void clear_symtab_users (void); -@@ -312,7 +384,9 @@ frapy_read_var (PyObject *self, PyObject *args) - if (!PyArg_ParseTuple (args, "O", &sym_obj)) - return NULL; +-extern enum language deduce_language_from_filename (char *); ++extern enum language deduce_language_from_filename (const char *); -- if (gdbpy_is_string (sym_obj)) -+ if (PyObject_TypeCheck (sym_obj, &symbol_object_type)) -+ var = symbol_object_to_symbol (sym_obj); -+ else if (gdbpy_is_string (sym_obj)) - { - char *var_name; - struct block *block = NULL; -@@ -365,6 +439,25 @@ frapy_read_var (PyObject *self, PyObject *args) - Py_RETURN_NONE; - } + /* symtab.c */ -+/* Select this frame. */ +diff --git a/gdb/target.c b/gdb/target.c +index 4cabcbd..34b3b60 100644 +--- a/gdb/target.c ++++ b/gdb/target.c +@@ -123,6 +123,8 @@ static int debug_to_insert_watchpoint (CORE_ADDR, int, int, + static int debug_to_remove_watchpoint (CORE_ADDR, int, int, + struct expression *); + ++static int debug_to_detach_watchpoints (void); + -+static PyObject * -+frapy_select (PyObject *self, PyObject *args) + static int debug_to_stopped_by_watchpoint (void); + + static int debug_to_stopped_data_address (struct target_ops *, CORE_ADDR *); +@@ -606,6 +608,7 @@ update_current_target (void) + INHERIT (to_remove_hw_breakpoint, t); + INHERIT (to_insert_watchpoint, t); + INHERIT (to_remove_watchpoint, t); ++ INHERIT (to_detach_watchpoints, t); + INHERIT (to_stopped_data_address, t); + INHERIT (to_have_steppable_watchpoint, t); + INHERIT (to_have_continuable_watchpoint, t); +@@ -739,6 +742,9 @@ update_current_target (void) + de_fault (to_remove_watchpoint, + (int (*) (CORE_ADDR, int, int, struct expression *)) + return_minus_one); ++ de_fault (to_detach_watchpoints, ++ (int (*) (void)) ++ return_zero); + de_fault (to_stopped_by_watchpoint, + (int (*) (void)) + return_zero); +@@ -3440,6 +3446,19 @@ debug_to_remove_watchpoint (CORE_ADDR addr, int len, int type, + return retval; + } + ++static int ++debug_to_detach_watchpoints (void) +{ -+ struct frame_info *fi; -+ frame_object *frame = (frame_object *) self; -+ volatile struct gdb_exception except; ++ int retval; + -+ TRY_CATCH (except, RETURN_MASK_ALL) -+ { -+ FRAPY_REQUIRE_VALID (frame, fi); -+ select_frame (fi); -+ } -+ GDB_PY_HANDLE_EXCEPTION (except); ++ retval = debug_target.to_detach_watchpoints (); + -+ Py_RETURN_NONE; ++ fprintf_unfiltered (gdb_stdlog, ++ "target_detach_watchpoints () = %ld\n", ++ (unsigned long) retval); ++ return retval; +} + - /* Implementation of gdb.selected_frame () -> gdb.Frame. - Returns the selected frame object. */ - -@@ -372,7 +465,7 @@ PyObject * - gdbpy_selected_frame (PyObject *self, PyObject *args) + static void + debug_to_terminal_init (void) { - struct frame_info *frame; -- frame_object *frame_obj = NULL; /* Initialize to appease gcc warning. */ -+ PyObject *frame_obj = NULL; /* Initialize to appease gcc warning. */ - volatile struct gdb_exception except; +@@ -3687,6 +3706,7 @@ setup_target_debug (void) + current_target.to_remove_hw_breakpoint = debug_to_remove_hw_breakpoint; + current_target.to_insert_watchpoint = debug_to_insert_watchpoint; + current_target.to_remove_watchpoint = debug_to_remove_watchpoint; ++ current_target.to_detach_watchpoints = debug_to_detach_watchpoints; + current_target.to_stopped_by_watchpoint = debug_to_stopped_by_watchpoint; + current_target.to_stopped_data_address = debug_to_stopped_data_address; + current_target.to_watchpoint_addr_within_range = debug_to_watchpoint_addr_within_range; +diff --git a/gdb/target.h b/gdb/target.h +index 3c8c017..608a742 100644 +--- a/gdb/target.h ++++ b/gdb/target.h +@@ -433,6 +433,7 @@ struct target_ops + provided with the corresponding target_* macros. */ + int (*to_remove_watchpoint) (CORE_ADDR, int, int, struct expression *); + int (*to_insert_watchpoint) (CORE_ADDR, int, int, struct expression *); ++ int (*to_detach_watchpoints) (void); - TRY_CATCH (except, RETURN_MASK_ALL) -@@ -382,7 +475,7 @@ gdbpy_selected_frame (PyObject *self, PyObject *args) - } - GDB_PY_HANDLE_EXCEPTION (except); + int (*to_stopped_by_watchpoint) (void); + int to_have_steppable_watchpoint; +@@ -1316,6 +1317,15 @@ extern char *normal_pid_to_str (ptid_t ptid); + #define target_remove_watchpoint(addr, len, type, cond) \ + (*current_target.to_remove_watchpoint) (addr, len, type, cond) -- return (PyObject *) frame_obj; -+ return frame_obj; - } ++/* Clear all debug registers without affecting any register caches. Function ++ acts on INFERIOR_PTID which should be the forked-off process, either the ++ non-threaded child one or the threaded parent one, depending on `set ++ follow-fork-mode'. Both watchpoints and hardware breakpoints get removed. ++ Return 0 on success, -1 on failure. */ ++ ++#define target_detach_watchpoints() \ ++ (*current_target.to_detach_watchpoints) () ++ + #define target_insert_hw_breakpoint(gdbarch, bp_tgt) \ + (*current_target.to_insert_hw_breakpoint) (gdbarch, bp_tgt) - /* Implementation of gdb.stop_reason_string (Integer) -> String. -@@ -484,15 +577,26 @@ Return the reason why it's not possible to find frames older than this." }, - { "pc", frapy_pc, METH_NOARGS, - "pc () -> Long.\n\ - Return the frame's resume address." }, -+ { "block", frapy_block, METH_NOARGS, -+ "block () -> gdb.Block.\n\ -+Return the frame's code block." }, -+ { "function", frapy_function, METH_NOARGS, -+ "function () -> gdb.Symbol.\n\ -+Returns the symbol for the function corresponding to this frame." }, - { "older", frapy_older, METH_NOARGS, - "older () -> gdb.Frame.\n\ - Return the frame that called this frame." }, - { "newer", frapy_newer, METH_NOARGS, - "newer () -> gdb.Frame.\n\ - Return the frame called by this frame." }, -+ { "find_sal", frapy_find_sal, METH_NOARGS, -+ "find_sal () -> gdb.Symtab_and_line.\n\ -+Return the frame's symtab and line." }, - { "read_var", frapy_read_var, METH_VARARGS, - "read_var (variable) -> gdb.Value.\n\ - Return the value of the variable in this frame." }, -+ { "select", frapy_select, METH_NOARGS, -+ "Select this frame as the user's current frame." }, - {NULL} /* Sentinel */ - }; +@@ -1369,6 +1379,18 @@ extern int target_search_memory (CORE_ADDR start_addr, + ULONGEST pattern_len, + CORE_ADDR *found_addrp); -diff --git a/gdb/python/py-hooks.c b/gdb/python/py-hooks.c -new file mode 100644 -index 0000000..a3140bc ---- /dev/null -+++ b/gdb/python/py-hooks.c -@@ -0,0 +1,50 @@ -+/* Notifications from gdb to Python ++/* Utility functions which can be used by search_memory implementations. */ + -+ Copyright (C) 2008 Free Software Foundation, Inc. ++void allocate_pattern_buffer (char **pattern_bufp, char **pattern_buf_end, ++ ULONGEST *pattern_buf_size); + -+ This file is part of GDB. ++void increase_pattern_buffer (char **pattern_bufp, char **pattern_buf_end, ++ ULONGEST *pattern_buf_size, int val_bytes); + -+ 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. ++int search_memory (CORE_ADDR *start_addr, ULONGEST *search_space_len, ++ const char *pattern_buf, ULONGEST pattern_len, ++ CORE_ADDR *found_addr); + -+ 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 "defs.h" -+#include "cli/cli-decode.h" -+#include "charset.h" -+#include "python.h" -+#include "python-internal.h" -+#include "observer.h" -+ -+PyObject * -+gdbpy_get_hook_function (const char *name) -+{ -+ PyObject *hooks; -+ PyObject *result; -+ -+ if (! PyObject_HasAttrString (gdb_module, "hooks")) -+ return NULL; -+ hooks = PyObject_GetAttrString (gdb_module, "hooks"); -+ if (! hooks) -+ return NULL; -+ /* The cast is because the Python function doesn't declare const argument. -+ This is a problem in Python version 2.4, but not in 2.5. */ -+ if (! PyObject_HasAttrString (hooks, (char *) name)) -+ { -+ Py_DECREF (hooks); -+ return NULL; -+ } -+ /* The cast is because the Python function doesn't declare const argument. -+ This is a problem in Python version 2.4, but not in 2.5. */ -+ result = PyObject_GetAttrString (hooks, (char *) name); -+ Py_DECREF (hooks); -+ return result; -+} -diff --git a/gdb/python/py-inferior.c b/gdb/python/py-inferior.c + /* Tracepoint-related operations. */ + + #define target_trace_init() \ +diff --git a/gdb/testsuite/gdb.arch/x86_64-vla-pointer-foo.S b/gdb/testsuite/gdb.arch/x86_64-vla-pointer-foo.S new file mode 100644 -index 0000000..5e90cc2 +index 0000000..83faaf6 --- /dev/null -+++ b/gdb/python/py-inferior.c -@@ -0,0 +1,926 @@ -+/* Python interface to inferiors. -+ -+ Copyright (C) 2009 Free Software Foundation, Inc. -+ -+ This file is part of GDB. -+ -+ 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 "defs.h" -+#include "exceptions.h" -+#include "gdbcore.h" -+#include "gdbthread.h" -+#include "inferior.h" -+#include "observer.h" -+#include "python-internal.h" -+#include "arch-utils.h" -+#include "language.h" -+ -+struct threadlist_entry { -+ thread_object *thread_obj; -+ struct threadlist_entry *next; -+}; -+ -+typedef struct -+{ -+ PyObject_HEAD -+ -+ /* The inferior we represent. */ -+ struct inferior *inferior; -+ -+ /* thread_object instances under this inferior. This list owns a reference -+ to each object it contains. */ -+ struct threadlist_entry *threads; -+ -+ /* Number of threads in the list. */ -+ int nthreads; -+} inferior_object; -+ -+static PyTypeObject inferior_object_type; -+ -+typedef struct { -+ PyObject_HEAD -+ void *buffer; -+ -+ /* These are kept just for mbpy_str. */ -+ CORE_ADDR addr; -+ CORE_ADDR length; -+} membuf_object; -+ -+static PyTypeObject membuf_object_type; -+ -+/* Require that INFERIOR be a valid inferior ID. */ -+#define INFPY_REQUIRE_VALID(Inferior) \ -+ do { \ -+ if (!Inferior->inferior) \ -+ { \ -+ PyErr_SetString (PyExc_RuntimeError, \ -+ "inferior no longer exists"); \ -+ return NULL; \ -+ } \ -+ } while (0) -+ -+struct inflist_entry { -+ inferior_object *inf_obj; -+ struct inflist_entry *next; -+}; -+ -+ -+ -+/* Inferior objects list. */ -+ -+/* List containing inferior_objects. This list owns a reference to each -+ object it contains. */ -+static struct inflist_entry *inferior_list; -+ -+static int ninferiors; -+ -+ -+/* An observer callback function that is called when an inferior has -+ been created. Creates a corresponding Python object for the inferior -+ and adds it to the list. */ -+static void -+add_inferior_object (int pid) -+{ -+ struct inferior *inf = find_inferior_pid (pid); -+ inferior_object *inf_obj; -+ struct inflist_entry *entry; -+ struct cleanup *cleanup; -+ -+ if (!inf) -+ { -+ warning (_("Can't create Python Inferior object.")); -+ return; -+ } -+ -+ cleanup = ensure_python_env (get_current_arch (), current_language); -+ -+ inf_obj = PyObject_New (inferior_object, &inferior_object_type); -+ if (!inf_obj) -+ { -+ warning (_("Can't create Python Inferior object.")); -+ gdbpy_print_stack (); -+ do_cleanups (cleanup); -+ return; -+ } -+ -+ inf_obj->inferior = inf; -+ inf_obj->threads = NULL; -+ inf_obj->nthreads = 0; -+ -+ entry = xmalloc (sizeof (struct inflist_entry)); -+ entry->inf_obj = inf_obj; -+ entry->next = inferior_list; -+ -+ inferior_list = entry; -+ -+ ninferiors++; -+ -+ do_cleanups (cleanup); -+} -+ -+/* An observer callback function that is called when an inferior has -+ been deleted. Removes the corresponding Python object from the -+ inferior list, and removes the list's reference to the object. */ -+static void -+delete_inferior_object (int pid) -+{ -+ PyGILState_STATE state; -+ struct inflist_entry **inf_entry, *inf_tmp; -+ struct threadlist_entry *th_entry, *th_tmp; -+ -+ /* Find inferior_object for the given PID. */ -+ for (inf_entry = &inferior_list; *inf_entry != NULL; -+ inf_entry = &(*inf_entry)->next) -+ if ((*inf_entry)->inf_obj->inferior->pid == pid) -+ break; -+ -+ if (!*inf_entry) -+ return; -+ -+ state = PyGILState_Ensure (); -+ -+ inf_tmp = *inf_entry; -+ inf_tmp->inf_obj->inferior = NULL; -+ -+ /* Deallocate threads list. */ -+ for (th_entry = inf_tmp->inf_obj->threads; th_entry != NULL;) -+ { -+ Py_DECREF (th_entry->thread_obj); -+ -+ th_tmp = th_entry; -+ th_entry = th_entry->next; -+ xfree (th_tmp); -+ } -+ -+ inf_tmp->inf_obj->nthreads = 0; -+ -+ *inf_entry = (*inf_entry)->next; -+ Py_DECREF (inf_tmp->inf_obj); -+ xfree (inf_tmp); -+ -+ ninferiors--; -+ -+ PyGILState_Release (state); -+} -+ -+/* Finds the Python Inferior object for the given pid. Returns a borrowed -+ reference. */ -+PyObject * -+find_inferior_object (int pid) -+{ -+ struct inflist_entry *p; -+ -+ for (p = inferior_list; p != NULL; p = p->next) -+ if (p->inf_obj->inferior->pid == pid) -+ return (PyObject *) p->inf_obj; -+ -+ return NULL; -+} -+ -+/* Finds the Python InferiorThread object for the given ptid. Returns a -+ borrowed reference. */ -+thread_object * -+find_thread_object (ptid_t ptid) -+{ -+ int pid; -+ struct inflist_entry *p; -+ struct threadlist_entry *q; -+ -+ pid = PIDGET (ptid); -+ for (p = inferior_list; p != NULL; p = p->next) -+ if (p->inf_obj->inferior->pid == pid) -+ for (q = p->inf_obj->threads; q != NULL; q = q->next) -+ if (ptid_equal (q->thread_obj->thread->ptid, ptid)) -+ return q->thread_obj; -+ -+ return NULL; -+} -+ -+ -+ -+/* Inferior object. */ -+ -+static void -+add_thread_object (struct thread_info *tp) -+{ -+ PyGILState_STATE state; -+ thread_object *thread_obj; -+ inferior_object *inf_obj; -+ struct threadlist_entry *entry; -+ -+ state = PyGILState_Ensure (); -+ -+ thread_obj = create_thread_object (tp); -+ if (!thread_obj) -+ { -+ warning (_("Can't create Python InferiorThread object.")); -+ gdbpy_print_stack (); -+ PyGILState_Release (state); -+ return; -+ } -+ -+ inf_obj = (inferior_object *) thread_obj->inf_obj; -+ -+ entry = xmalloc (sizeof (struct threadlist_entry)); -+ entry->thread_obj = thread_obj; -+ entry->next = inf_obj->threads; -+ -+ inf_obj->threads = entry; -+ inf_obj->nthreads++; -+ -+ PyGILState_Release (state); -+} -+ -+static void -+delete_thread_object (struct thread_info *tp, int ignore) -+{ -+ PyGILState_STATE state; -+ inferior_object *inf_obj; -+ thread_object *thread_obj; -+ struct threadlist_entry **entry, *tmp; -+ -+ inf_obj = (inferior_object *) find_inferior_object (PIDGET(tp->ptid)); -+ if (!inf_obj) -+ return; -+ -+ /* Find thread entry in its inferior's thread_list. */ -+ for (entry = &inf_obj->threads; *entry != NULL; entry = &(*entry)->next) -+ if ((*entry)->thread_obj->thread == tp) -+ break; -+ -+ if (!*entry) -+ return; -+ -+ state = PyGILState_Ensure (); -+ -+ tmp = *entry; -+ tmp->thread_obj->thread = NULL; -+ -+ *entry = (*entry)->next; -+ inf_obj->nthreads--; -+ -+ Py_DECREF (tmp->thread_obj); -+ xfree (tmp); -+ -+ -+ PyGILState_Release (state); -+} -+ -+static PyObject * -+infpy_threads (PyObject *self, PyObject *args) -+{ -+ int i; -+ struct threadlist_entry *entry; -+ inferior_object *inf_obj = (inferior_object *) self; -+ PyObject *tuple; -+ -+ INFPY_REQUIRE_VALID (inf_obj); -+ -+ -+ tuple = PyTuple_New (inf_obj->nthreads); -+ if (!tuple) -+ return NULL; -+ -+ /* The list is in reverse order of thread age (i.e., newest comes first), -+ is this a problem? */ -+ for (i = 0, entry = inf_obj->threads; i < inf_obj->nthreads; -+ i++, entry = entry->next) -+ { -+ Py_INCREF (entry->thread_obj); -+ PyTuple_SET_ITEM (tuple, i, (PyObject *) entry->thread_obj); -+ } -+ -+ return tuple; -+} -+ -+static PyObject * -+infpy_get_num (PyObject *self, void *closure) -+{ -+ inferior_object *inf = (inferior_object *) self; -+ -+ INFPY_REQUIRE_VALID (inf); -+ -+ return PyLong_FromLong (inf->inferior->num); -+} -+ -+static PyObject * -+infpy_get_pid (PyObject *self, void *closure) -+{ -+ inferior_object *inf = (inferior_object *) self; -+ -+ INFPY_REQUIRE_VALID (inf); -+ -+ return PyLong_FromLong (inf->inferior->pid); -+} -+ -+static PyObject * -+infpy_get_was_attached (PyObject *self, void *closure) -+{ -+ inferior_object *inf = (inferior_object *) self; -+ INFPY_REQUIRE_VALID (inf); -+ if (inf->inferior->attach_flag) -+ Py_RETURN_TRUE; -+ Py_RETURN_FALSE; -+} -+ -+ -+ -+/* Implementation of gdb.inferiors () -> (gdb.Inferior, ...). -+ Returns a list of all inferiors. */ -+ -+PyObject * -+gdbpy_inferiors (PyObject *unused, PyObject *unused2) -+{ -+ int i; -+ struct inflist_entry *entry; -+ PyObject *tuple; -+ -+ tuple = PyTuple_New (ninferiors); -+ if (!tuple) -+ return NULL; -+ -+ /* The list is in reverse order of inferior age (i.e., newest comes first), -+ is this a problem? */ -+ for (i = 0, entry = inferior_list; i < ninferiors; i++, entry = entry->next) -+ { -+ Py_INCREF (entry->inf_obj); -+ PyTuple_SET_ITEM (tuple, i, (PyObject *) entry->inf_obj); -+ } -+ -+ return tuple; -+} -+ -+ -+ -+/* Membuf and memory manipulation. */ -+ -+/* Implementation of gdb.read_memory (address, length). -+ Returns a Python buffer object with LENGTH bytes of the inferior's memory -+ at ADDRESS. Both arguments are integers. */ -+ -+static PyObject * -+infpy_read_memory (PyObject *self, PyObject *args) -+{ -+ int error = 0; -+ CORE_ADDR addr, length; -+ void *buffer = NULL; -+ membuf_object *membuf_obj; -+ PyObject *addr_obj, *length_obj; -+ struct cleanup *cleanups; -+ volatile struct gdb_exception except; -+ -+ if (! PyArg_ParseTuple (args, "OO", &addr_obj, &length_obj)) -+ return NULL; -+ -+ cleanups = make_cleanup (null_cleanup, NULL); -+ -+ TRY_CATCH (except, RETURN_MASK_ALL) -+ { -+ if (!get_addr_from_python (addr_obj, &addr) -+ || !get_addr_from_python (length_obj, &length)) -+ { -+ error = 1; -+ break; -+ } -+ -+ buffer = xmalloc (length); -+ make_cleanup (xfree, buffer); -+ -+ read_memory (addr, buffer, length); -+ } -+ GDB_PY_HANDLE_EXCEPTION (except); -+ -+ if (error) -+ { -+ do_cleanups (cleanups); -+ return NULL; -+ } -+ -+ membuf_obj = PyObject_New (membuf_object, &membuf_object_type); -+ if (membuf_obj == NULL) -+ { -+ PyErr_SetString (PyExc_MemoryError, -+ "Could not allocate memory buffer object."); -+ do_cleanups (cleanups); -+ return NULL; -+ } -+ -+ discard_cleanups (cleanups); -+ -+ membuf_obj->buffer = buffer; -+ membuf_obj->addr = addr; -+ membuf_obj->length = length; -+ -+ return PyBuffer_FromReadWriteObject ((PyObject *) membuf_obj, 0, -+ Py_END_OF_BUFFER); -+} -+ -+/* Implementation of gdb.write_memory (address, buffer [, length]). -+ Writes the contents of BUFFER (a Python object supporting the read buffer -+ protocol) at ADDRESS in the inferior's memory. Write LENGTH bytes from -+ BUFFER, or its entire contents if the argument is not provided. The -+ function returns nothing. */ -+ -+static PyObject * -+infpy_write_memory (PyObject *self, PyObject *args) -+{ -+ int buf_len, error = 0; -+ const char *buffer; -+ CORE_ADDR addr, length; -+ PyObject *addr_obj, *length_obj = NULL; -+ volatile struct gdb_exception except; -+ -+ if (! PyArg_ParseTuple (args, "Os#|O", &addr_obj, &buffer, &buf_len, -+ &length_obj)) -+ return NULL; -+ -+ TRY_CATCH (except, RETURN_MASK_ALL) -+ { -+ if (!get_addr_from_python (addr_obj, &addr)) -+ { -+ error = 1; -+ break; -+ } -+ -+ if (!length_obj) -+ length = buf_len; -+ else if (!get_addr_from_python (length_obj, &length)) -+ { -+ error = 1; -+ break; -+ } -+ -+ write_memory (addr, buffer, length); -+ } -+ GDB_PY_HANDLE_EXCEPTION (except); -+ -+ if (error) -+ return NULL; -+ -+ Py_RETURN_NONE; -+} -+ -+/* Destructor of Membuf objects. */ -+ -+static void -+mbpy_dealloc (PyObject *self) -+{ -+ xfree (((membuf_object *) self)->buffer); -+ self->ob_type->tp_free (self); -+} -+ -+/* Return a description of the Membuf object. */ -+ -+static PyObject * -+mbpy_str (PyObject *self) -+{ -+ membuf_object *membuf_obj = (membuf_object *) self; -+ -+ return PyString_FromFormat ("memory buffer for address %s, %s bytes long", -+ paddress (python_gdbarch, membuf_obj->addr), -+ pulongest (membuf_obj->length)); -+} -+ -+static Py_ssize_t -+get_read_buffer (PyObject *self, Py_ssize_t segment, void **ptrptr) -+{ -+ membuf_object *membuf_obj = (membuf_object *) self; -+ -+ if (segment) -+ { -+ PyErr_SetString (PyExc_SystemError, -+ "The memory buffer supports only one segment."); -+ return -1; -+ } -+ -+ *ptrptr = membuf_obj->buffer; -+ -+ return membuf_obj->length; -+} -+ -+static Py_ssize_t -+get_write_buffer (PyObject *self, Py_ssize_t segment, void **ptrptr) -+{ -+ return get_read_buffer (self, segment, ptrptr); -+} -+ -+static Py_ssize_t -+get_seg_count (PyObject *self, Py_ssize_t *lenp) -+{ -+ if (lenp) -+ *lenp = ((membuf_object *) self)->length; -+ -+ return 1; -+} -+ -+static Py_ssize_t -+get_char_buffer (PyObject *self, Py_ssize_t segment, char **ptrptr) -+{ -+ void *ptr = NULL; -+ Py_ssize_t ret; -+ -+ ret = get_read_buffer (self, segment, &ptr); -+ *ptrptr = (char *) ptr; -+ -+ return ret; -+} -+ -+/* Adds GDB value V to the pattern buffer in *PATTERN_BUF. If SIZE is not zero, -+ it specifies the number of bytes from V to copy to *PATTERN_BUF. The -+ function increases the size of *PATTERN_BUF as necessary, adjusting -+ *PATTERN_BUF_END and *PATTERN_BUF_SIZE in the process. */ -+ -+static void -+add_value_pattern (struct value *v, int size, char **pattern_buf, -+ char **pattern_buf_end, ULONGEST *pattern_buf_size) -+{ -+ int val_bytes; -+ -+ if (size) -+ { -+ LONGEST x = value_as_long (v); -+ -+ if (size == 1) -+ *(*pattern_buf_end)++ = x; -+ else -+ { -+ put_bits (x, *pattern_buf_end, size * 8, -+ gdbarch_byte_order (python_gdbarch) == BFD_ENDIAN_BIG); -+ *pattern_buf_end += size; -+ } -+ } -+ else -+ { -+ val_bytes = TYPE_LENGTH (value_type (v)); -+ -+ increase_pattern_buffer (pattern_buf, pattern_buf_end, -+ pattern_buf_size, val_bytes); -+ -+ memcpy (*pattern_buf_end, value_contents_raw (v), val_bytes); -+ *pattern_buf_end += val_bytes; -+ } -+} -+ -+/* This function does the actual work of constructing the pattern buffer from -+ OBJ. If OBJ is an object which implements the read buffer protocol (such -+ as a string, a byte array or gdb.Membuf), then its contents are directly -+ copied to *PATTERN_BUF. If it is a list, then this function is recursively -+ called for each of its elements. If OBJ is an object which can be converted -+ to a GDB value, then the contents of the value are copied to PATTERN_BUF. -+ If SIZE is different than zero, then it limits the number of bytes which -+ are copied to the buffer in case OBJ is converted to a GDB value. That -+ means that SIZE influences only Python scalars and gdb.Value objects. -+ The function increases the size of *PATTERN_BUF as necessary, adjusting -+ *PATTERN_BUF_END and *PATTERN_BUF_SIZE in the process. -+ -+ Returns 1 on success or 0 on failure, with a Python exception set. This -+ function can also throw GDB exceptions. */ -+ -+static int -+add_pattern_element (PyObject *obj, int size, char **pattern_buf, -+ char **pattern_buf_end, ULONGEST *pattern_buf_size) -+{ -+ if (PyObject_CheckReadBuffer (obj)) -+ { -+ /* Handle string, Unicode string, byte array, gdb.Membuf and any other -+ object implementing the buffer protocol. The SIZE parameter is -+ ignored in this case. */ -+ -+ Py_ssize_t val_bytes; -+ const void *buffer; -+ -+ if (PyObject_AsReadBuffer (obj, &buffer, &val_bytes) == -1) -+ return 0; -+ -+ increase_pattern_buffer (pattern_buf, pattern_buf_end, -+ pattern_buf_size, val_bytes); -+ -+ memcpy (*pattern_buf_end, buffer, val_bytes); -+ *pattern_buf_end += val_bytes; -+ } -+ else if (gdbpy_is_value_object (obj)) -+ add_value_pattern (value_object_to_value (obj), size, pattern_buf, -+ pattern_buf_end, pattern_buf_size); -+ else if (PySequence_Check (obj)) -+ { -+ /* Handle lists and tuples. */ -+ -+ Py_ssize_t i, num_objs; -+ -+ num_objs = PySequence_Size (obj); -+ for (i = 0; i < num_objs; i++) -+ if (!add_pattern_element (PySequence_GetItem (obj, i), size, -+ pattern_buf, pattern_buf_end, -+ pattern_buf_size)) -+ return 0; -+ } -+ else -+ { -+ /* See if we can convert from a Python object to a GDB value. */ -+ -+ struct value *v = convert_value_from_python (obj); -+ -+ if (v) -+ add_value_pattern (v, size, pattern_buf, pattern_buf_end, -+ pattern_buf_size); -+ else -+ return 0; -+ } -+ -+ return 1; -+} -+ -+/* Constructs the search pattern from OBJ, putting it in *PATTERN_BUFP, and its -+ size in *PATTERN_LENP. See the function add_pattern_element to learn how -+ the search pattern is obtained from OBJ. -+ -+ Returns 1 on success or 0 on failure, with a Python exception set. This -+ function can also throw GDB exceptions. */ -+ -+static int -+get_search_pattern (PyObject *obj, int size, char **pattern_bufp, -+ ULONGEST *pattern_lenp) -+{ -+ /* Buffer to hold the search pattern. */ -+ char *pattern_buf; -+ /* Current size of search pattern buffer. -+ We realloc space as needed. */ -+ ULONGEST pattern_buf_size; -+ /* Pointer to one past the last in-use part of pattern_buf. */ -+ char *pattern_buf_end; -+ struct cleanup *old_cleanups; -+ -+ allocate_pattern_buffer (&pattern_buf, &pattern_buf_end, &pattern_buf_size); -+ old_cleanups = make_cleanup (free_current_contents, &pattern_buf); -+ -+ if (!add_pattern_element (obj, size, &pattern_buf, &pattern_buf_end, -+ &pattern_buf_size)) -+ { -+ do_cleanups (old_cleanups); -+ -+ return 0; -+ } -+ -+ *pattern_bufp = pattern_buf; -+ *pattern_lenp = pattern_buf_end - pattern_buf; -+ -+ discard_cleanups (old_cleanups); -+ -+ return 1; -+} -+ -+/* Implementation of -+ gdb.search_memory (address, length, pattern [, size] [, max_count]). -+ The third argument may be either a pattern, or a list or tupple of patterns -+ to be searched. Size is the size in bytes of each search query value, either -+ 1, 2, 4 or 8. Returns a list of the addresses where matches were found. */ -+ -+static PyObject * -+infpy_search_memory (PyObject *self, PyObject *args, PyObject *kw) -+{ -+ int size = 0; -+ unsigned int found_count = 0; -+ long max_count = 0; -+ CORE_ADDR start_addr, length; -+ char *pattern_buf; -+ static char *keywords[] = { "address", "length", "pattern", "size", -+ "max_count", NULL }; -+ ULONGEST pattern_len, search_space_len; -+ PyObject *pattern, *list = NULL, *start_addr_obj, *length_obj; -+ volatile struct gdb_exception except; -+ -+ if (! PyArg_ParseTupleAndKeywords (args, kw, "OOO|il", keywords, -+ &start_addr_obj, &length_obj, &pattern, -+ &size, &max_count)) -+ return NULL; -+ -+ if (!max_count) -+ max_count = LONG_MAX; -+ -+ if (size != 0 && size != 1 && size != 2 && size != 4 && size != 8) -+ { -+ PyErr_SetString (PyExc_ValueError, "invalid pattern size"); -+ return NULL; -+ } -+ -+ TRY_CATCH (except, RETURN_MASK_ALL) -+ { -+ if (get_addr_from_python (start_addr_obj, &start_addr) -+ && get_addr_from_python (length_obj, &length)) -+ { -+ if (!length) -+ { -+ PyErr_SetString (PyExc_ValueError, "empty search range"); -+ break; -+ } -+ /* Watch for overflows. */ -+ else if (length > CORE_ADDR_MAX -+ || (start_addr + length - 1) < start_addr) -+ { -+ PyErr_SetString (PyExc_ValueError, "search range too large"); -+ break; -+ } -+ -+ search_space_len = length; -+ -+ if (get_search_pattern (pattern, size, &pattern_buf, &pattern_len)) -+ { -+ /* Any cleanups get automatically executed on an exception. */ -+ struct cleanup *cleanups = make_cleanup (xfree, pattern_buf); -+ -+ list = PyList_New (0); -+ -+ while (search_space_len >= pattern_len && found_count < max_count) -+ { -+ CORE_ADDR found_addr; -+ int found; -+ -+ found = search_memory (&start_addr, &search_space_len, -+ pattern_buf, pattern_len, &found_addr); -+ if (found <= 0) -+ break; -+ -+ PyList_Append (list, PyLong_FromUnsignedLong (found_addr)); -+ ++found_count; -+ } -+ -+ do_cleanups (cleanups); -+ } -+ } -+ } -+ GDB_PY_HANDLE_EXCEPTION (except); -+ -+ return list; -+} -+ -+ -+ -+void -+gdbpy_initialize_inferior (void) -+{ -+ if (PyType_Ready (&inferior_object_type) < 0) -+ return; -+ -+ Py_INCREF (&inferior_object_type); -+ PyModule_AddObject (gdb_module, "Inferior", -+ (PyObject *) &inferior_object_type); -+ -+ inferior_list = NULL; -+ ninferiors = 0; -+ -+ observer_attach_new_inferior (add_inferior_object); -+ observer_attach_inferior_exit (delete_inferior_object); -+ observer_attach_new_thread (add_thread_object); -+ observer_attach_thread_exit (delete_thread_object); -+ -+ if (PyType_Ready (&membuf_object_type) < 0) -+ return; -+ -+ Py_INCREF (&membuf_object_type); -+ PyModule_AddObject (gdb_module, "Membuf", (PyObject *) &membuf_object_type); -+} -+ -+ -+ -+static PyGetSetDef inferior_object_getset[] = -+{ -+ { "num", infpy_get_num, NULL, "ID of inferior, as assigned by GDB.", NULL }, -+ { "pid", infpy_get_pid, NULL, "PID of inferior, as assigned by the OS.", -+ NULL }, -+ { "was_attached", infpy_get_was_attached, NULL, -+ "True if the inferior was created using 'attach'.", NULL }, -+ -+ { NULL } -+}; -+ -+static PyMethodDef inferior_object_methods[] = -+{ -+ { "threads", infpy_threads, METH_NOARGS, -+ "Return all the threads of this inferior." }, -+ -+ { "read_memory", infpy_read_memory, METH_VARARGS, -+ "read_memory (address, length) -> buffer\n\ -+Return a buffer object for reading from the inferior's memory." }, -+ { "write_memory", infpy_write_memory, METH_VARARGS, -+ "write_memory (address, buffer [, length])\n\ -+Write the given buffer object to the inferior's memory." }, -+ { "search_memory", (PyCFunction) infpy_search_memory, METH_VARARGS | METH_KEYWORDS, -+ "search_memory (address, length, pattern [, size] [, max_count]) -> list\n\ -+Return a list with the addresses where matches were found." }, -+ -+ { NULL } -+}; -+ -+static PyTypeObject inferior_object_type = -+{ -+ PyObject_HEAD_INIT (NULL) -+ 0, /* ob_size */ -+ "gdb.Inferior", /* tp_name */ -+ sizeof (inferior_object), /* tp_basicsize */ -+ 0, /* tp_itemsize */ -+ 0, /* tp_dealloc */ -+ 0, /* tp_print */ -+ 0, /* tp_getattr */ -+ 0, /* tp_setattr */ -+ 0, /* tp_compare */ -+ 0, /* tp_repr */ -+ 0, /* tp_as_number */ -+ 0, /* tp_as_sequence */ -+ 0, /* tp_as_mapping */ -+ 0, /* tp_hash */ -+ 0, /* tp_call */ -+ 0, /* tp_str */ -+ 0, /* tp_getattro */ -+ 0, /* tp_setattro */ -+ 0, /* tp_as_buffer */ -+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_ITER, /* tp_flags */ -+ "GDB inferior object", /* tp_doc */ -+ 0, /* tp_traverse */ -+ 0, /* tp_clear */ -+ 0, /* tp_richcompare */ -+ 0, /* tp_weaklistoffset */ -+ 0, /* tp_iter */ -+ 0, /* tp_iternext */ -+ inferior_object_methods, /* tp_methods */ -+ 0, /* tp_members */ -+ inferior_object_getset, /* tp_getset */ -+ 0, /* tp_base */ -+ 0, /* tp_dict */ -+ 0, /* tp_descr_get */ -+ 0, /* tp_descr_set */ -+ 0, /* tp_dictoffset */ -+ 0, /* tp_init */ -+ 0 /* tp_alloc */ -+}; -+ -+ -+ -+/* Python doesn't provide a decent way to get compatibility here. */ -+#if HAVE_LIBPYTHON2_4 -+#define CHARBUFFERPROC_NAME getcharbufferproc -+#else -+#define CHARBUFFERPROC_NAME charbufferproc -+#endif -+ -+static PyBufferProcs buffer_procs = { -+ get_read_buffer, -+ get_write_buffer, -+ get_seg_count, -+ /* The cast here works around a difference between Python 2.4 and -+ Python 2.5. */ -+ (CHARBUFFERPROC_NAME) get_char_buffer -+}; -+ -+static PyTypeObject membuf_object_type = { -+ PyObject_HEAD_INIT (NULL) -+ 0, /*ob_size*/ -+ "gdb.Membuf", /*tp_name*/ -+ sizeof (membuf_object), /*tp_basicsize*/ -+ 0, /*tp_itemsize*/ -+ mbpy_dealloc, /*tp_dealloc*/ -+ 0, /*tp_print*/ -+ 0, /*tp_getattr*/ -+ 0, /*tp_setattr*/ -+ 0, /*tp_compare*/ -+ 0, /*tp_repr*/ -+ 0, /*tp_as_number*/ -+ 0, /*tp_as_sequence*/ -+ 0, /*tp_as_mapping*/ -+ 0, /*tp_hash */ -+ 0, /*tp_call*/ -+ mbpy_str, /*tp_str*/ -+ 0, /*tp_getattro*/ -+ 0, /*tp_setattro*/ -+ &buffer_procs, /*tp_as_buffer*/ -+ Py_TPFLAGS_DEFAULT, /*tp_flags*/ -+ "GDB memory buffer object", /*tp_doc*/ -+ 0, /* tp_traverse */ -+ 0, /* tp_clear */ -+ 0, /* tp_richcompare */ -+ 0, /* tp_weaklistoffset */ -+ 0, /* tp_iter */ -+ 0, /* tp_iternext */ -+ 0, /* tp_methods */ -+ 0, /* tp_members */ -+ 0, /* tp_getset */ -+ 0, /* tp_base */ -+ 0, /* tp_dict */ -+ 0, /* tp_descr_get */ -+ 0, /* tp_descr_set */ -+ 0, /* tp_dictoffset */ -+ 0, /* tp_init */ -+ 0, /* tp_alloc */ -+ PyType_GenericNew /* tp_new */ -+}; -diff --git a/gdb/python/py-infthread.c b/gdb/python/py-infthread.c -new file mode 100644 -index 0000000..21e4eab ---- /dev/null -+++ b/gdb/python/py-infthread.c -@@ -0,0 +1,285 @@ -+/* Python interface to inferior threads. -+ -+ Copyright (C) 2009 Free Software Foundation, Inc. -+ -+ This file is part of GDB. -+ -+ 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 "defs.h" -+#include "exceptions.h" -+#include "gdbthread.h" -+#include "inferior.h" -+#include "python-internal.h" -+ -+static PyTypeObject thread_object_type; -+ -+/* Require that INFERIOR be a valid inferior ID. */ -+#define THPY_REQUIRE_VALID(Thread) \ -+ do { \ -+ if (!Thread->thread) \ -+ { \ -+ PyErr_SetString (PyExc_RuntimeError, \ -+ "thread no longer exists"); \ -+ return NULL; \ -+ } \ -+ } while (0) -+ -+ -+ -+thread_object * -+create_thread_object (struct thread_info *tp) -+{ -+ thread_object *thread_obj; -+ -+ thread_obj = PyObject_New (thread_object, &thread_object_type); -+ if (!thread_obj) -+ return NULL; -+ -+ thread_obj->thread = tp; -+ thread_obj->inf_obj = find_inferior_object (PIDGET (tp->ptid)); -+ Py_INCREF (thread_obj->inf_obj); -+ -+ return thread_obj; -+} -+ -+ -+ -+static void -+thpy_dealloc (PyObject *self) -+{ -+ Py_DECREF (((thread_object *) self)->inf_obj); -+ self->ob_type->tp_free (self); -+} -+ -+static PyObject * -+thpy_get_num (PyObject *self, void *closure) -+{ -+ thread_object *thread_obj = (thread_object *) self; -+ -+ THPY_REQUIRE_VALID (thread_obj); -+ -+ return PyLong_FromLong (thread_obj->thread->num); -+} -+ -+ -+ -+/* Implementation of Inferior.frames () -> (gdb.Frame, ...). -+ Returns a tuple of all frame objects. */ -+PyObject * -+thpy_frames (PyObject *self, PyObject *args) -+{ -+ int result = 0; -+ struct frame_info *frame; -+ PyObject *frame_obj; -+ PyObject *list, *tuple; -+ thread_object *thread_obj = (thread_object *) self; -+ struct cleanup *cleanup; -+ volatile struct gdb_exception except; -+ -+ THPY_REQUIRE_VALID (thread_obj); -+ -+ list = PyList_New (0); -+ if (list == NULL) -+ { -+ PyErr_SetString (PyExc_MemoryError, "Could not allocate frames list."); -+ return NULL; -+ } -+ -+ cleanup = make_cleanup_restore_current_thread (); -+ -+ TRY_CATCH (except, RETURN_MASK_ALL) -+ { -+ switch_to_thread (thread_obj->thread->ptid); -+ -+ for (frame = get_current_frame (); frame; frame = get_prev_frame (frame)) -+ { -+ frame_obj = frame_info_to_frame_object (frame); -+ if (frame_obj == NULL) -+ { -+ Py_DECREF (list); -+ list = NULL; -+ break; -+ } -+ -+ PyList_Append (list, frame_obj); -+ } -+ } -+ if (except.reason < 0) -+ { -+ Py_DECREF (list); -+ return PyErr_Format (except.reason == RETURN_QUIT -+ ? PyExc_KeyboardInterrupt : PyExc_RuntimeError, -+ "%s", except.message); -+ } -+ -+ do_cleanups (cleanup); -+ -+ if (list) -+ { -+ tuple = PyList_AsTuple (list); -+ Py_DECREF (list); -+ } -+ else -+ tuple = NULL; -+ -+ return tuple; -+} -+ -+/* Implementation of InferiorThread.newest_frame () -> gdb.Frame. -+ Returns the newest frame object. */ -+PyObject * -+thpy_newest_frame (PyObject *self, PyObject *args) -+{ -+ struct frame_info *frame; -+ PyObject *frame_obj = NULL; /* Initialize to appease gcc warning. */ -+ thread_object *thread_obj = (thread_object *) self; -+ struct cleanup *cleanup; -+ volatile struct gdb_exception except; -+ -+ THPY_REQUIRE_VALID (thread_obj); -+ -+ cleanup = make_cleanup_restore_current_thread (); -+ -+ TRY_CATCH (except, RETURN_MASK_ALL) -+ { -+ switch_to_thread (thread_obj->thread->ptid); -+ -+ frame = get_current_frame (); -+ frame_obj = frame_info_to_frame_object (frame); -+ } -+ GDB_PY_HANDLE_EXCEPTION (except); -+ -+ do_cleanups (cleanup); -+ -+ return frame_obj; -+} -+ -+/* Implementation of InferiorThread.switch (). -+ Makes this the GDB selected thread. */ -+static PyObject * -+thpy_switch (PyObject *self, PyObject *args) -+{ -+ thread_object *thread_obj = (thread_object *) self; -+ struct cleanup *cleanup; -+ volatile struct gdb_exception except; -+ -+ THPY_REQUIRE_VALID (thread_obj); -+ -+ TRY_CATCH (except, RETURN_MASK_ALL) -+ { -+ switch_to_thread (thread_obj->thread->ptid); -+ } -+ GDB_PY_HANDLE_EXCEPTION (except); -+ -+ Py_RETURN_NONE; -+} -+ -+ -+ -+/* Implementation of gdb.selected_thread () -> gdb.InferiorThread. -+ Returns the selected thread object. */ -+PyObject * -+gdbpy_selected_thread (PyObject *self, PyObject *args) -+{ -+ PyObject *thread_obj; -+ -+ thread_obj = (PyObject *) find_thread_object (inferior_ptid); -+ if (thread_obj) -+ { -+ Py_INCREF (thread_obj); -+ return thread_obj; -+ } -+ -+ Py_RETURN_NONE; -+} -+ -+ -+ -+void -+gdbpy_initialize_thread (void) -+{ -+ if (PyType_Ready (&thread_object_type) < 0) -+ return; -+ -+ Py_INCREF (&thread_object_type); -+ PyModule_AddObject (gdb_module, "InferiorThread", -+ (PyObject *) &thread_object_type); -+} -+ -+ -+ -+static PyGetSetDef thread_object_getset[] = -+{ -+ { "num", thpy_get_num, NULL, "ID of the thread, as assigned by GDB.", NULL }, -+ -+ { NULL } -+}; -+ -+static PyMethodDef thread_object_methods[] = -+{ -+ { "frames", thpy_frames, METH_NOARGS, -+ "frames () -> (gdb.Frame, ...)\n\ -+Return a tuple containing all frames in the thread." }, -+ { "newest_frame", thpy_newest_frame, METH_NOARGS, -+ "newest_frame () -> gdb.Frame\n\ -+Return the newest frame in the thread." }, -+ { "switch", thpy_switch, METH_NOARGS, -+ "switch ()\n\ -+Makes this the GDB selected thread." }, -+ -+ { NULL } -+}; -+ -+static PyTypeObject thread_object_type = -+{ -+ PyObject_HEAD_INIT (NULL) -+ 0, /*ob_size*/ -+ "gdb.InferiorThread", /*tp_name*/ -+ sizeof (thread_object), /*tp_basicsize*/ -+ 0, /*tp_itemsize*/ -+ thpy_dealloc, /*tp_dealloc*/ -+ 0, /*tp_print*/ -+ 0, /*tp_getattr*/ -+ 0, /*tp_setattr*/ -+ 0, /*tp_compare*/ -+ 0, /*tp_repr*/ -+ 0, /*tp_as_number*/ -+ 0, /*tp_as_sequence*/ -+ 0, /*tp_as_mapping*/ -+ 0, /*tp_hash */ -+ 0, /*tp_call*/ -+ 0, /*tp_str*/ -+ 0, /*tp_getattro*/ -+ 0, /*tp_setattro*/ -+ 0, /*tp_as_buffer*/ -+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_ITER, /*tp_flags*/ -+ "GDB thread object", /* tp_doc */ -+ 0, /* tp_traverse */ -+ 0, /* tp_clear */ -+ 0, /* tp_richcompare */ -+ 0, /* tp_weaklistoffset */ -+ 0, /* tp_iter */ -+ 0, /* tp_iternext */ -+ thread_object_methods, /* tp_methods */ -+ 0, /* tp_members */ -+ thread_object_getset, /* tp_getset */ -+ 0, /* tp_base */ -+ 0, /* tp_dict */ -+ 0, /* tp_descr_get */ -+ 0, /* tp_descr_set */ -+ 0, /* tp_dictoffset */ -+ 0, /* tp_init */ -+ 0 /* tp_alloc */ -+}; -diff --git a/gdb/python/py-membuf.c b/gdb/python/py-membuf.c -new file mode 100644 -index 0000000..7bc294c ---- /dev/null -+++ b/gdb/python/py-membuf.c -@@ -0,0 +1,268 @@ -+/* Python interface to the inferior memory. -+ -+ Copyright (C) 2008, 2009 Free Software Foundation, Inc. -+ -+ This file is part of GDB. -+ -+ 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 "defs.h" -+#include "exceptions.h" -+#include "gdbcore.h" -+#include "python-internal.h" -+ -+typedef struct { -+ PyObject_HEAD -+ void *buffer; -+ -+ /* These are kept just for mbpy_str. */ -+ CORE_ADDR addr; -+ CORE_ADDR length; -+} membuf_object; -+ -+static PyTypeObject membuf_object_type; -+ -+/* Implementation of gdb.read_memory (address, length). -+ Returns a Python buffer object with LENGTH bytes of the inferior's memory -+ at ADDRESS. Both arguments are integers. */ -+ -+PyObject * -+gdbpy_read_memory (PyObject *self, PyObject *args) -+{ -+ int error = 0; -+ CORE_ADDR addr, length; -+ void *buffer = NULL; -+ membuf_object *membuf_obj; -+ PyObject *addr_obj, *length_obj; -+ struct cleanup *cleanups = NULL; -+ volatile struct gdb_exception except; -+ -+ if (! PyArg_ParseTuple (args, "OO", &addr_obj, &length_obj)) -+ return NULL; -+ -+ TRY_CATCH (except, RETURN_MASK_ALL) -+ { -+ if (!get_addr_from_python (addr_obj, &addr) -+ || !get_addr_from_python (length_obj, &length)) -+ { -+ error = 1; -+ break; -+ } -+ -+ buffer = xmalloc (length); -+ cleanups = make_cleanup (xfree, buffer); -+ -+ read_memory (addr, buffer, length); -+ } -+ GDB_PY_HANDLE_EXCEPTION (except); -+ -+ if (error) -+ return NULL; -+ -+ discard_cleanups (cleanups); -+ -+ membuf_obj = PyObject_New (membuf_object, &membuf_object_type); -+ if (membuf_obj == NULL) -+ { -+ xfree (buffer); -+ PyErr_SetString (PyExc_MemoryError, -+ "Could not allocate memory buffer object."); -+ return NULL; -+ } -+ -+ membuf_obj->buffer = buffer; -+ membuf_obj->addr = addr; -+ membuf_obj->length = length; -+ -+ return PyBuffer_FromReadWriteObject ((PyObject *) membuf_obj, 0, -+ Py_END_OF_BUFFER); -+} -+ -+/* Implementation of gdb.write_memory (address, buffer [, length]). -+ Writes the contents of BUFFER (a Python object supporting the read buffer -+ protocol) at ADDRESS in the inferior's memory. Write LENGTH bytes from -+ BUFFER, or its entire contents if the argument is not provided. The -+ function returns nothing. */ -+ -+PyObject * -+gdbpy_write_memory (PyObject *self, PyObject *args) -+{ -+ int buf_len, error = 0; -+ const char *buffer; -+ CORE_ADDR addr, length; -+ PyObject *addr_obj, *length_obj = NULL; -+ volatile struct gdb_exception except; -+ -+ if (! PyArg_ParseTuple (args, "Os#|O", &addr_obj, &buffer, &buf_len, -+ &length_obj)) -+ return NULL; -+ -+ TRY_CATCH (except, RETURN_MASK_ALL) -+ { -+ if (!get_addr_from_python (addr_obj, &addr)) -+ { -+ error = 1; -+ break; -+ } -+ -+ if (!length_obj) -+ length = buf_len; -+ else if (!get_addr_from_python (length_obj, &length)) -+ { -+ error = 1; -+ break; -+ } -+ -+ write_memory (addr, buffer, length); -+ } -+ GDB_PY_HANDLE_EXCEPTION (except); -+ -+ if (error) -+ return NULL; -+ -+ Py_RETURN_NONE; -+} -+ -+/* Destructor of Membuf objects. */ -+ -+static void -+mbpy_dealloc (PyObject *self) -+{ -+ xfree (((membuf_object *) self)->buffer); -+ self->ob_type->tp_free (self); -+} -+ -+/* Return a description of the Membuf object. */ -+ -+static PyObject * -+mbpy_str (PyObject *self) -+{ -+ membuf_object *membuf_obj = (membuf_object *) self; -+ -+ return PyString_FromFormat ("memory buffer for address %s, %s bytes long", -+ paddress (membuf_obj->addr), -+ pulongest (membuf_obj->length)); -+} -+ -+static Py_ssize_t -+get_read_buffer (PyObject *self, Py_ssize_t segment, void **ptrptr) -+{ -+ membuf_object *membuf_obj = (membuf_object *) self; -+ -+ if (segment) -+ { -+ PyErr_SetString (PyExc_SystemError, -+ "The memory buffer supports only one segment."); -+ return -1; -+ } -+ -+ *ptrptr = membuf_obj->buffer; -+ -+ return membuf_obj->length; -+} -+ -+static Py_ssize_t -+get_write_buffer (PyObject *self, Py_ssize_t segment, void **ptrptr) -+{ -+ return get_read_buffer (self, segment, ptrptr); -+} -+ -+static Py_ssize_t -+get_seg_count (PyObject *self, Py_ssize_t *lenp) -+{ -+ if (lenp) -+ *lenp = ((membuf_object *) self)->length; -+ -+ return 1; -+} -+ -+static Py_ssize_t -+get_char_buffer (PyObject *self, Py_ssize_t segment, char **ptrptr) -+{ -+ void *ptr = NULL; -+ Py_ssize_t ret; -+ -+ ret = get_read_buffer (self, segment, &ptr); -+ *ptrptr = (char *) ptr; -+ -+ return ret; -+} -+ -+/* Python doesn't provide a decent way to get compatibility here. */ -+#if HAVE_LIBPYTHON2_4 -+#define CHARBUFFERPROC_NAME getcharbufferproc -+#else -+#define CHARBUFFERPROC_NAME charbufferproc -+#endif -+ -+static PyBufferProcs buffer_procs = { -+ get_read_buffer, -+ get_write_buffer, -+ get_seg_count, -+ /* The cast here works around a difference between Python 2.4 and -+ Python 2.5. */ -+ (CHARBUFFERPROC_NAME) get_char_buffer -+}; -+ -+static PyTypeObject membuf_object_type = { -+ PyObject_HEAD_INIT (NULL) -+ 0, /*ob_size*/ -+ "gdb.Membuf", /*tp_name*/ -+ sizeof (membuf_object), /*tp_basicsize*/ -+ 0, /*tp_itemsize*/ -+ mbpy_dealloc, /*tp_dealloc*/ -+ 0, /*tp_print*/ -+ 0, /*tp_getattr*/ -+ 0, /*tp_setattr*/ -+ 0, /*tp_compare*/ -+ 0, /*tp_repr*/ -+ 0, /*tp_as_number*/ -+ 0, /*tp_as_sequence*/ -+ 0, /*tp_as_mapping*/ -+ 0, /*tp_hash */ -+ 0, /*tp_call*/ -+ mbpy_str, /*tp_str*/ -+ 0, /*tp_getattro*/ -+ 0, /*tp_setattro*/ -+ &buffer_procs, /*tp_as_buffer*/ -+ Py_TPFLAGS_DEFAULT, /*tp_flags*/ -+ "GDB memory buffer object", /*tp_doc*/ -+ 0, /* tp_traverse */ -+ 0, /* tp_clear */ -+ 0, /* tp_richcompare */ -+ 0, /* tp_weaklistoffset */ -+ 0, /* tp_iter */ -+ 0, /* tp_iternext */ -+ 0, /* tp_methods */ -+ 0, /* tp_members */ -+ 0, /* tp_getset */ -+ 0, /* tp_base */ -+ 0, /* tp_dict */ -+ 0, /* tp_descr_get */ -+ 0, /* tp_descr_set */ -+ 0, /* tp_dictoffset */ -+ 0, /* tp_init */ -+ 0, /* tp_alloc */ -+ PyType_GenericNew /* tp_new */ -+}; -+ -+void -+gdbpy_initialize_membuf (void) -+{ -+ if (PyType_Ready (&membuf_object_type) < 0) -+ return; -+ -+ Py_INCREF (&membuf_object_type); -+ PyModule_AddObject (gdb_module, "Membuf", (PyObject *) &membuf_object_type); -+} -diff --git a/gdb/python/py-param.c b/gdb/python/py-param.c -new file mode 100644 -index 0000000..1f591a8 ---- /dev/null -+++ b/gdb/python/py-param.c -@@ -0,0 +1,606 @@ -+/* gdb parameters implemented in Python -+ -+ Copyright (C) 2008, 2009 Free Software Foundation, Inc. -+ -+ This file is part of GDB. -+ -+ 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 "defs.h" -+#include "value.h" -+#include "exceptions.h" -+#include "python-internal.h" -+#include "charset.h" -+#include "gdbcmd.h" -+#include "cli/cli-decode.h" -+#include "completer.h" -+ -+/* Parameter constants and their values. */ -+struct parm_constant -+{ -+ char *name; -+ int value; -+}; -+ -+struct parm_constant parm_constants[] = -+{ -+ { "PARAM_BOOLEAN", var_boolean }, -+ { "PARAM_AUTO_BOOLEAN", var_auto_boolean }, -+ { "PARAM_UINTEGER", var_uinteger }, -+ { "PARAM_INTEGER", var_integer }, -+ { "PARAM_STRING", var_string }, -+ { "PARAM_STRING_NOESCAPE", var_string_noescape }, -+ { "PARAM_OPTIONAL_FILENAME", var_optional_filename }, -+ { "PARAM_FILENAME", var_filename }, -+ { "PARAM_ZINTEGER", var_zinteger }, -+ { "PARAM_ENUM", var_enum }, -+ { NULL, 0 } -+}; -+ -+/* A union that can hold anything described by enum var_types. */ -+union parmpy_variable -+{ -+ /* Hold an integer value, for boolean and integer types. */ -+ int intval; -+ -+ /* Hold an auto_boolean. */ -+ enum auto_boolean autoboolval; -+ -+ /* Hold an unsigned integer value, for uinteger. */ -+ unsigned int uintval; -+ -+ /* Hold a string, for the various string types. */ -+ char *stringval; -+ -+ /* Hold a string, for enums. */ -+ const char *cstringval; -+}; -+ -+/* A gdb parameter. */ -+struct parmpy_object -+{ -+ PyObject_HEAD -+ -+ /* The type of the parameter. */ -+ enum var_types type; -+ -+ /* The value of the parameter. */ -+ union parmpy_variable value; -+ -+ /* For an enum command, the possible values. The vector is -+ allocated with xmalloc, as is each element. It is -+ NULL-terminated. */ -+ const char **enumeration; -+}; -+ -+typedef struct parmpy_object parmpy_object; -+ -+static PyTypeObject parmpy_object_type; -+ -+/* Some handy string constants. */ -+static PyObject *set_doc_cst; -+static PyObject *show_doc_cst; -+ -+ -+ -+/* Get an attribute. */ -+static PyObject * -+get_attr (PyObject *obj, PyObject *attr_name) -+{ -+ if (PyString_Check (attr_name) -+ && ! strcmp (PyString_AsString (attr_name), "value")) -+ { -+ parmpy_object *self = (parmpy_object *) obj; -+ return gdbpy_parameter_value (self->type, &self->value); -+ } -+ -+ return PyObject_GenericGetAttr (obj, attr_name); -+} -+ -+/* Set a parameter value from a Python value. Return 0 on success, -1 -+ on failure. */ -+static int -+set_parameter_value (parmpy_object *self, PyObject *value) -+{ -+ int cmp; -+ -+ switch (self->type) -+ { -+ case var_string: -+ case var_string_noescape: -+ case var_optional_filename: -+ case var_filename: -+ if (! gdbpy_is_string (value) -+ && (self->type == var_filename -+ || value != Py_None)) -+ { -+ PyErr_SetString (PyExc_RuntimeError, "string required"); -+ return -1; -+ } -+ if (self->value.stringval) -+ xfree (self->value.stringval); -+ if (value == Py_None) -+ { -+ if (self->type == var_optional_filename) -+ self->value.stringval = xstrdup (""); -+ else -+ self->value.stringval = NULL; -+ } -+ else -+ self->value.stringval = python_string_to_host_string (value); -+ break; -+ -+ case var_enum: -+ { -+ int i; -+ char *str; -+ -+ if (! gdbpy_is_string (value)) -+ { -+ PyErr_SetString (PyExc_RuntimeError, "string required"); -+ return -1; -+ } -+ -+ str = python_string_to_host_string (value); -+ for (i = 0; self->enumeration[i]; ++i) -+ if (! strcmp (self->enumeration[i], str)) -+ break; -+ xfree (str); -+ if (! self->enumeration[i]) -+ { -+ PyErr_SetString (PyExc_RuntimeError, -+ "value must be member of enumeration"); -+ return -1; -+ } -+ self->value.cstringval = self->enumeration[i]; -+ break; -+ } -+ -+ case var_boolean: -+ if (! PyBool_Check (value)) -+ { -+ PyErr_SetString (PyExc_RuntimeError, "boolean required"); -+ return -1; -+ } -+ cmp = PyObject_IsTrue (value); -+ if (cmp < 0) -+ return -1; -+ self->value.intval = cmp; -+ break; -+ -+ case var_auto_boolean: -+ if (! PyBool_Check (value) && value != Py_None) -+ { -+ PyErr_SetString (PyExc_RuntimeError, -+ "boolean or None required"); -+ return -1; -+ } -+ -+ if (value == Py_None) -+ self->value.autoboolval = AUTO_BOOLEAN_AUTO; -+ else -+ { -+ cmp = PyObject_IsTrue (value); -+ if (cmp < 0 ) -+ return -1; -+ if (cmp == 1) -+ self->value.autoboolval = AUTO_BOOLEAN_TRUE; -+ else -+ self->value.autoboolval = AUTO_BOOLEAN_FALSE; -+ -+ break; -+ } -+ -+ case var_integer: -+ case var_zinteger: -+ case var_uinteger: -+ { -+ long l; -+ int ok; -+ -+ if (! PyInt_Check (value)) -+ { -+ PyErr_SetString (PyExc_RuntimeError, "value must be integer"); -+ return -1; -+ } -+ -+ l = PyInt_AsLong (value); -+ if (self->type == var_uinteger) -+ { -+ ok = (l >= 0 && l <= UINT_MAX); -+ if (l == 0) -+ l = UINT_MAX; -+ } -+ else if (self->type == var_integer) -+ { -+ ok = (l >= INT_MIN && l <= INT_MAX); -+ if (l == 0) -+ l = INT_MAX; -+ } -+ else -+ ok = (l >= INT_MIN && l <= INT_MAX); -+ -+ if (! ok) -+ { -+ PyErr_SetString (PyExc_RuntimeError, "range exceeded"); -+ return -1; -+ } -+ -+ self->value.intval = (int) l; -+ break; -+ } -+ -+ default: -+ PyErr_SetString (PyExc_RuntimeError, "programmer error: unhandled type"); -+ return -1; -+ } -+ -+ return 0; -+} -+ -+/* Set an attribute. */ -+static int -+set_attr (PyObject *obj, PyObject *attr_name, PyObject *val) -+{ -+ if (PyString_Check (attr_name) -+ && ! strcmp (PyString_AsString (attr_name), "value")) -+ { -+ if (!val) -+ { -+ PyErr_SetString (PyExc_RuntimeError, -+ "cannot delete a parameter's value"); -+ return -1; -+ } -+ return set_parameter_value ((parmpy_object *) obj, val); -+ } -+ -+ return PyObject_GenericSetAttr (obj, attr_name, val); -+} -+ -+ -+ -+/* A helper function that dispatches to the appropriate add_setshow -+ function. */ -+static void -+add_setshow_generic (int parmclass, enum command_class cmdclass, -+ char *cmd_name, parmpy_object *self, -+ char *set_doc, char *show_doc, char *help_doc, -+ struct cmd_list_element **set_list, -+ struct cmd_list_element **show_list) -+{ -+ switch (parmclass) -+ { -+ case var_boolean: -+ add_setshow_boolean_cmd (cmd_name, cmdclass, &self->value.intval, -+ set_doc, show_doc, help_doc, -+ NULL, NULL, set_list, show_list); -+ break; -+ -+ case var_auto_boolean: -+ add_setshow_auto_boolean_cmd (cmd_name, cmdclass, -+ &self->value.autoboolval, -+ set_doc, show_doc, help_doc, -+ NULL, NULL, set_list, show_list); -+ break; -+ -+ case var_uinteger: -+ add_setshow_uinteger_cmd (cmd_name, cmdclass, &self->value.uintval, -+ set_doc, show_doc, help_doc, -+ NULL, NULL, set_list, show_list); -+ break; -+ -+ case var_integer: -+ add_setshow_integer_cmd (cmd_name, cmdclass, &self->value.intval, -+ set_doc, show_doc, help_doc, -+ NULL, NULL, set_list, show_list); -+ break; -+ -+ case var_string: -+ add_setshow_string_cmd (cmd_name, cmdclass, &self->value.stringval, -+ set_doc, show_doc, help_doc, -+ NULL, NULL, set_list, show_list); -+ break; -+ -+ case var_string_noescape: -+ add_setshow_string_noescape_cmd (cmd_name, cmdclass, -+ &self->value.stringval, -+ set_doc, show_doc, help_doc, -+ NULL, NULL, set_list, show_list); -+ break; -+ -+ case var_optional_filename: -+ add_setshow_optional_filename_cmd (cmd_name, cmdclass, -+ &self->value.stringval, -+ set_doc, show_doc, help_doc, -+ NULL, NULL, set_list, show_list); -+ break; -+ -+ case var_filename: -+ add_setshow_filename_cmd (cmd_name, cmdclass, &self->value.stringval, -+ set_doc, show_doc, help_doc, -+ NULL, NULL, set_list, show_list); -+ break; -+ -+ case var_zinteger: -+ add_setshow_zinteger_cmd (cmd_name, cmdclass, &self->value.intval, -+ set_doc, show_doc, help_doc, -+ NULL, NULL, set_list, show_list); -+ break; -+ -+ case var_enum: -+ add_setshow_enum_cmd (cmd_name, cmdclass, self->enumeration, -+ &self->value.cstringval, -+ set_doc, show_doc, help_doc, -+ NULL, NULL, set_list, show_list); -+ /* Initialize the value, just in case. */ -+ self->value.cstringval = self->enumeration[0]; -+ break; -+ } -+} -+ -+/* A helper which computes enum values. Returns 1 on success, 0 on -+ error. */ -+static int -+compute_enum_values (parmpy_object *self, PyObject *enum_values) -+{ -+ Py_ssize_t size, i; -+ -+ if (! enum_values) -+ { -+ PyErr_SetString (PyExc_RuntimeError, -+ "enumeration required for PARAM_ENUM"); -+ return 0; -+ } -+ -+ if (! PySequence_Check (enum_values)) -+ { -+ PyErr_SetString (PyExc_RuntimeError, "enumeration is not a sequence"); -+ return 0; -+ } -+ -+ size = PySequence_Size (enum_values); -+ if (size < 0) -+ return 0; -+ if (size == 0) -+ { -+ PyErr_SetString (PyExc_RuntimeError, "empty enumeration"); -+ return 0; -+ } -+ -+ self->enumeration = xmalloc ((size + 1) * sizeof (char *)); -+ memset (self->enumeration, 0, (size + 1) * sizeof (char *)); -+ -+ for (i = 0; i < size; ++i) -+ { -+ PyObject *item = PySequence_GetItem (enum_values, i); -+ if (! item) -+ return 0; -+ if (! gdbpy_is_string (item)) -+ { -+ PyErr_SetString (PyExc_RuntimeError, "enumeration item not a string"); -+ return 0; -+ } -+ self->enumeration[i] = python_string_to_host_string (item); -+ } -+ -+ return 1; -+} -+ -+/* A helper function which returns a documentation string for an -+ object. */ -+static char * -+get_doc_string (PyObject *object, PyObject *attr) -+{ -+ char *result = NULL; -+ if (PyObject_HasAttr (object, attr)) -+ { -+ PyObject *ds_obj = PyObject_GetAttr (object, attr); -+ if (ds_obj && gdbpy_is_string (ds_obj)) -+ result = python_string_to_host_string (ds_obj); -+ } -+ if (! result) -+ result = xstrdup ("This command is not documented."); -+ return result; -+} -+ -+/* Object initializer; sets up gdb-side structures for command. -+ -+ Use: __init__(NAME, CMDCLASS, PARMCLASS, [ENUM]) -+ -+ NAME is the name of the parameter. It may consist of multiple -+ words, in which case the final word is the name of the new command, -+ and earlier words must be prefix commands. -+ -+ CMDCLASS is the kind of command. It should be one of the COMMAND_* -+ constants defined in the gdb module. -+ -+ PARMCLASS is the type of the parameter. It should be one of the -+ PARAM_* constants defined in the gdb module. -+ -+ If PARMCLASS is PARAM_ENUM, then the final argument should be a -+ collection of strings. These strings are the valid values for this -+ parameter. -+ -+ The documentation for the parameter is taken from the doc string -+ for the python class. -+ -+*/ -+static int -+parmpy_init (PyObject *self, PyObject *args, PyObject *kwds) -+{ -+ parmpy_object *obj = (parmpy_object *) self; -+ char *name; -+ char *set_doc, *show_doc, *doc; -+ char *cmd_name; -+ int parmclass, cmdtype; -+ PyObject *enum_values = NULL; -+ struct cmd_list_element *cmd_list; -+ struct cmd_list_element **set_list, **show_list; -+ volatile struct gdb_exception except; -+ -+ if (! PyArg_ParseTuple (args, "sii|O", &name, &cmdtype, &parmclass, -+ &enum_values)) -+ return -1; -+ -+ if (cmdtype != no_class && cmdtype != class_run -+ && cmdtype != class_vars && cmdtype != class_stack -+ && cmdtype != class_files && cmdtype != class_support -+ && cmdtype != class_info && cmdtype != class_breakpoint -+ && cmdtype != class_trace && cmdtype != class_obscure -+ && cmdtype != class_maintenance) -+ { -+ PyErr_Format (PyExc_RuntimeError, "invalid command class argument"); -+ return -1; -+ } -+ -+ if (parmclass != var_boolean && parmclass != var_auto_boolean -+ && parmclass != var_uinteger && parmclass != var_integer -+ && parmclass != var_string && parmclass != var_string_noescape -+ && parmclass != var_optional_filename && parmclass != var_filename -+ && parmclass != var_zinteger && parmclass != var_enum) -+ { -+ PyErr_SetString (PyExc_RuntimeError, "invalid parameter class argument"); -+ return -1; -+ } -+ -+ if (enum_values && parmclass != var_enum) -+ { -+ PyErr_SetString (PyExc_RuntimeError, -+ "only PARAM_ENUM accepts a fourth argument"); -+ return -1; -+ } -+ if (parmclass == var_enum) -+ { -+ if (! compute_enum_values (obj, enum_values)) -+ return -1; -+ } -+ -+ obj->type = (enum var_types) parmclass; -+ memset (&obj->value, 0, sizeof (obj->value)); -+ obj->enumeration = NULL; -+ -+ cmd_name = gdbpy_parse_command_name (name, &set_list, &setlist); -+ if (! cmd_name) -+ return -1; -+ xfree (cmd_name); -+ cmd_name = gdbpy_parse_command_name (name, &show_list, &showlist); -+ if (! cmd_name) -+ return -1; -+ -+ /* FIXME: there is no way to register a destructor function for -+ set/show commands. So, these are leaked. */ -+ set_doc = get_doc_string (self, set_doc_cst); -+ show_doc = get_doc_string (self, show_doc_cst); -+ doc = get_doc_string (self, gdbpy_doc_cst); -+ -+ Py_INCREF (self); -+ -+ TRY_CATCH (except, RETURN_MASK_ALL) -+ { -+ add_setshow_generic (parmclass, (enum command_class) cmdtype, -+ cmd_name, obj, -+ set_doc, show_doc, -+ doc, set_list, show_list); -+ } -+ if (except.reason < 0) -+ { -+ xfree (cmd_name); -+ xfree (set_doc); -+ xfree (show_doc); -+ xfree (doc); -+ Py_DECREF (self); -+ PyErr_Format (except.reason == RETURN_QUIT -+ ? PyExc_KeyboardInterrupt : PyExc_RuntimeError, -+ "%s", except.message); -+ return -1; -+ } -+ return 0; -+} -+ -+ -+ -+/* Initialize the 'parameters' module. */ -+void -+gdbpy_initialize_parameters (void) -+{ -+ int i; -+ -+ if (PyType_Ready (&parmpy_object_type) < 0) -+ return; -+ -+ set_doc_cst = PyString_FromString ("set_doc"); -+ if (! set_doc_cst) -+ return; -+ show_doc_cst = PyString_FromString ("show_doc"); -+ if (! show_doc_cst) -+ return; -+ -+ for (i = 0; parm_constants[i].name; ++i) -+ { -+ if (PyModule_AddIntConstant (gdb_module, -+ parm_constants[i].name, -+ parm_constants[i].value) < 0) -+ return; -+ } -+ -+ Py_INCREF (&parmpy_object_type); -+ PyModule_AddObject (gdb_module, "Parameter", -+ (PyObject *) &parmpy_object_type); -+} -+ -+ -+ -+static PyTypeObject parmpy_object_type = -+{ -+ PyObject_HEAD_INIT (NULL) -+ 0, /*ob_size*/ -+ "gdb.Parameter", /*tp_name*/ -+ sizeof (parmpy_object), /*tp_basicsize*/ -+ 0, /*tp_itemsize*/ -+ 0, /*tp_dealloc*/ -+ 0, /*tp_print*/ -+ 0, /*tp_getattr*/ -+ 0, /*tp_setattr*/ -+ 0, /*tp_compare*/ -+ 0, /*tp_repr*/ -+ 0, /*tp_as_number*/ -+ 0, /*tp_as_sequence*/ -+ 0, /*tp_as_mapping*/ -+ 0, /*tp_hash */ -+ 0, /*tp_call*/ -+ 0, /*tp_str*/ -+ get_attr, /*tp_getattro*/ -+ set_attr, /*tp_setattro*/ -+ 0, /*tp_as_buffer*/ -+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/ -+ "GDB parameter object", /* tp_doc */ -+ 0, /* tp_traverse */ -+ 0, /* tp_clear */ -+ 0, /* tp_richcompare */ -+ 0, /* tp_weaklistoffset */ -+ 0, /* tp_iter */ -+ 0, /* tp_iternext */ -+ 0, /* tp_methods */ -+ 0, /* tp_members */ -+ 0, /* tp_getset */ -+ 0, /* tp_base */ -+ 0, /* tp_dict */ -+ 0, /* tp_descr_get */ -+ 0, /* tp_descr_set */ -+ 0, /* tp_dictoffset */ -+ parmpy_init, /* tp_init */ -+ 0, /* tp_alloc */ -+ PyType_GenericNew /* tp_new */ -+}; -diff --git a/gdb/python/py-prettyprint.c b/gdb/python/py-prettyprint.c -index 5d696c8..a6348ba 100644 ---- a/gdb/python/py-prettyprint.c -+++ b/gdb/python/py-prettyprint.c -@@ -121,6 +121,7 @@ find_pretty_printer (PyObject *value) - - return function; - } -+ - /* Pretty-print a single value, via the printer object PRINTER. - If the function returns a string, a PyObject containing the string - is returned. Otherwise, if the function returns a value, -@@ -141,10 +142,15 @@ pretty_print_one_value (PyObject *printer, struct value **out_value) - if (! gdbpy_is_string (result)) - { - *out_value = convert_value_from_python (result); -- if (PyErr_Occurred ()) -- *out_value = NULL; -- Py_DECREF (result); -- result = NULL; -+ if (PyErr_Occurred ()) -+ *out_value = NULL; -+ else -+ /* We must increment the value's refcount, because we -+ are about to decref RESULT, and this may result in -+ the value being destroyed. */ -+ value_incref (*out_value); -+ Py_DECREF (result); -+ result = NULL; - } - } - } -@@ -556,14 +562,7 @@ gdbpy_get_varobj_pretty_printer (struct value *value) - { - PyObject *val_obj; - PyObject *pretty_printer = NULL; -- volatile struct gdb_exception except; - -- TRY_CATCH (except, RETURN_MASK_ALL) -- { -- value = value_copy (value); -- } -- GDB_PY_HANDLE_EXCEPTION (except); -- - val_obj = value_to_value_object (value); - if (! val_obj) - return NULL; -diff --git a/gdb/python/py-symbol.c b/gdb/python/py-symbol.c -new file mode 100644 -index 0000000..03d43c1 ---- /dev/null -+++ b/gdb/python/py-symbol.c -@@ -0,0 +1,336 @@ -+/* Python interface to symbols. -+ -+ Copyright (C) 2008, 2009 Free Software Foundation, Inc. -+ -+ This file is part of GDB. -+ -+ 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 "defs.h" -+#include "block.h" -+#include "exceptions.h" -+#include "frame.h" -+#include "symtab.h" -+#include "python-internal.h" -+ -+typedef struct { -+ PyObject_HEAD -+ struct symbol *symbol; -+} symbol_object; -+ -+ -+static PyObject * -+sympy_str (PyObject *self) -+{ -+ int ret; -+ char *s; -+ PyObject *result; -+ -+ ret = asprintf (&s, "symbol for %s", -+ SYMBOL_PRINT_NAME (((symbol_object *) self)->symbol)); -+ if (ret < 0) -+ Py_RETURN_NONE; -+ -+ result = PyString_FromString (s); -+ xfree (s); -+ -+ return result; -+} -+ -+static PyObject * -+sympy_get_value (PyObject *self, void *closure) -+{ -+ symbol_object *self_sym = (symbol_object *) self; -+ -+ switch (SYMBOL_CLASS (self_sym->symbol)) -+ { -+ case LOC_BLOCK: -+ return block_to_block_object (SYMBOL_BLOCK_VALUE (self_sym->symbol)); -+ } -+ -+ PyErr_SetString (PyExc_NotImplementedError, -+ "Symbol type not yet supported in Python scripts."); -+ return NULL; -+} -+ -+static PyObject * -+sympy_get_symtab (PyObject *self, void *closure) -+{ -+ symbol_object *self_sym = (symbol_object *) self; -+ -+ return symtab_to_symtab_object (SYMBOL_SYMTAB (self_sym->symbol)); -+} -+ -+static PyObject * -+sympy_get_name (PyObject *self, void *closure) -+{ -+ symbol_object *self_sym = (symbol_object *) self; -+ -+ return PyString_FromString (SYMBOL_NATURAL_NAME (self_sym->symbol)); -+} -+ -+static PyObject * -+sympy_get_linkage_name (PyObject *self, void *closure) -+{ -+ symbol_object *self_sym = (symbol_object *) self; -+ -+ return PyString_FromString (SYMBOL_LINKAGE_NAME (self_sym->symbol)); -+} -+ -+static PyObject * -+sympy_get_print_name (PyObject *self, void *closure) -+{ -+ symbol_object *self_sym = (symbol_object *) self; -+ -+ return PyString_FromString (SYMBOL_PRINT_NAME (self_sym->symbol)); -+} -+ -+static PyObject * -+sympy_get_addr_class (PyObject *self, void *closure) -+{ -+ symbol_object *self_sym = (symbol_object *) self; -+ -+ return PyInt_FromLong (SYMBOL_CLASS (self_sym->symbol)); -+} -+ -+static PyObject * -+sympy_is_argument (PyObject *self, void *closure) -+{ -+ symbol_object *self_sym = (symbol_object *) self; -+ -+ return PyBool_FromLong (SYMBOL_IS_ARGUMENT (self_sym->symbol)); -+} -+ -+static PyObject * -+sympy_is_constant (PyObject *self, void *closure) -+{ -+ symbol_object *self_sym = (symbol_object *) self; -+ enum address_class class = SYMBOL_CLASS (self_sym->symbol); -+ -+ return PyBool_FromLong (class == LOC_CONST || class == LOC_CONST_BYTES); -+} -+ -+static PyObject * -+sympy_is_function (PyObject *self, void *closure) -+{ -+ symbol_object *self_sym = (symbol_object *) self; -+ enum address_class class = SYMBOL_CLASS (self_sym->symbol); -+ -+ return PyBool_FromLong (class == LOC_BLOCK); -+} -+ -+static PyObject * -+sympy_is_variable (PyObject *self, void *closure) -+{ -+ symbol_object *self_sym = (symbol_object *) self; -+ enum address_class class = SYMBOL_CLASS (self_sym->symbol); -+ -+ return PyBool_FromLong (!SYMBOL_IS_ARGUMENT (self_sym->symbol) -+ && (class == LOC_LOCAL || class == LOC_REGISTER || class == LOC_STATIC -+ || class == LOC_COMPUTED || class == LOC_OPTIMIZED_OUT)); -+} -+ -+PyObject * -+symbol_to_symbol_object (struct symbol *sym) -+{ -+ symbol_object *sym_obj; -+ -+ sym_obj = PyObject_New (symbol_object, &symbol_object_type); -+ if (sym_obj == NULL) -+ { -+ PyErr_SetString (PyExc_MemoryError, "Could not allocate symbol object."); -+ return NULL; -+ } -+ -+ sym_obj->symbol = sym; -+ -+ return (PyObject *) sym_obj; -+} -+ -+struct symbol * -+symbol_object_to_symbol (PyObject *obj) -+{ -+ if (! PyObject_TypeCheck (obj, &symbol_object_type)) -+ return NULL; -+ return ((symbol_object *) obj)->symbol; -+} -+ -+/* Implementation of -+ gdb.lookup_symbol (name [, block] [, domain]) -> (symbol, is_field_of_this) -+ A tuple with 2 elements is always returned. The first is the symbol -+ object or None, the second is a boolean with the value of -+ is_a_field_of_this (see comment in lookup_symbol_in_language). */ -+ -+PyObject *gdbpy_lookup_symbol (PyObject *self, PyObject *args, PyObject *kw) -+{ -+ int domain = VAR_DOMAIN, is_a_field_of_this = 0; -+ const char *name; -+ static char *keywords[] = { "name", "block", "domain", NULL }; -+ struct symbol *symbol; -+ PyObject *block_obj = NULL, *ret_tuple, *sym_obj, *bool_obj; -+ struct block *block = NULL; -+ -+ if (! PyArg_ParseTupleAndKeywords (args, kw, "s|O!i", keywords, &name, -+ &block_object_type, &block_obj, &domain)) -+ return NULL; -+ -+ if (block_obj) -+ block = block_object_to_block (block_obj); -+ else -+ { -+ struct frame_info *selected_frame; -+ volatile struct gdb_exception except; -+ -+ TRY_CATCH (except, RETURN_MASK_ALL) -+ { -+ selected_frame = get_selected_frame (_("No frame selected.")); -+ block = block_for_pc (get_frame_address_in_block (selected_frame)); -+ } -+ GDB_PY_HANDLE_EXCEPTION (except); -+ } -+ -+ symbol = lookup_symbol (name, block, domain, &is_a_field_of_this); -+ -+ ret_tuple = PyTuple_New (2); -+ if (!ret_tuple) -+ { -+ PyErr_SetString (PyExc_MemoryError, "Could not allocate tuple object."); -+ return NULL; -+ } -+ -+ if (symbol) -+ { -+ sym_obj = symbol_to_symbol_object (symbol); -+ if (!sym_obj) -+ { -+ Py_DECREF (ret_tuple); -+ return NULL; -+ } -+ } -+ else -+ { -+ sym_obj = Py_None; -+ Py_INCREF (Py_None); -+ } -+ PyTuple_SET_ITEM (ret_tuple, 0, sym_obj); -+ -+ bool_obj = is_a_field_of_this? Py_True : Py_False; -+ Py_INCREF (bool_obj); -+ PyTuple_SET_ITEM (ret_tuple, 1, bool_obj); -+ -+ return ret_tuple; -+} -+ -+void -+gdbpy_initialize_symbols (void) -+{ -+ if (PyType_Ready (&symbol_object_type) < 0) -+ return; -+ -+ /* FIXME: These would probably be best exposed as class attributes of Symbol, -+ but I don't know how to do it except by messing with the type's dictionary. -+ That seems too messy. */ -+ /* FIXME 2: Some of these were removed from GDB since I first wrote this code, -+ so it's probably a good idea not to expose them to Python. */ -+ PyModule_AddIntConstant (gdb_module, "SYMBOL_LOC_UNDEF", LOC_UNDEF); -+ PyModule_AddIntConstant (gdb_module, "SYMBOL_LOC_CONST", LOC_CONST); -+ PyModule_AddIntConstant (gdb_module, "SYMBOL_LOC_STATIC", LOC_STATIC); -+ PyModule_AddIntConstant (gdb_module, "SYMBOL_LOC_REGISTER", LOC_REGISTER); -+ PyModule_AddIntConstant (gdb_module, "SYMBOL_LOC_ARG", LOC_ARG); -+ PyModule_AddIntConstant (gdb_module, "SYMBOL_LOC_REF_ARG", LOC_REF_ARG); -+ PyModule_AddIntConstant (gdb_module, "SYMBOL_LOC_LOCAL", LOC_LOCAL); -+ PyModule_AddIntConstant (gdb_module, "SYMBOL_LOC_TYPEDEF", LOC_TYPEDEF); -+ PyModule_AddIntConstant (gdb_module, "SYMBOL_LOC_LABEL", LOC_LABEL); -+ PyModule_AddIntConstant (gdb_module, "SYMBOL_LOC_BLOCK", LOC_BLOCK); -+ PyModule_AddIntConstant (gdb_module, "SYMBOL_LOC_CONST_BYTES", -+ LOC_CONST_BYTES); -+ PyModule_AddIntConstant (gdb_module, "SYMBOL_LOC_UNRESOLVED", LOC_UNRESOLVED); -+ PyModule_AddIntConstant (gdb_module, "SYMBOL_LOC_OPTIMIZED_OUT", -+ LOC_OPTIMIZED_OUT); -+ PyModule_AddIntConstant (gdb_module, "SYMBOL_LOC_COMPUTED", LOC_COMPUTED); -+ PyModule_AddIntConstant (gdb_module, "SYMBOL_LOC_REGPARM_ADDR", -+ LOC_REGPARM_ADDR); -+ PyModule_AddIntConstant (gdb_module, "SYMBOL_UNDEF_DOMAIN", UNDEF_DOMAIN); -+ PyModule_AddIntConstant (gdb_module, "SYMBOL_VAR_DOMAIN", VAR_DOMAIN); -+ PyModule_AddIntConstant (gdb_module, "SYMBOL_STRUCT_DOMAIN", STRUCT_DOMAIN); -+ PyModule_AddIntConstant (gdb_module, "SYMBOL_LABEL_DOMAIN", LABEL_DOMAIN); -+ PyModule_AddIntConstant (gdb_module, "SYMBOL_VARIABLES_DOMAIN", -+ VARIABLES_DOMAIN); -+ PyModule_AddIntConstant (gdb_module, "SYMBOL_FUNCTIONS_DOMAIN", -+ FUNCTIONS_DOMAIN); -+ PyModule_AddIntConstant (gdb_module, "SYMBOL_TYPES_DOMAIN", TYPES_DOMAIN); -+ -+ Py_INCREF (&symbol_object_type); -+ PyModule_AddObject (gdb_module, "Symbol", (PyObject *) &symbol_object_type); -+} -+ -+ -+ -+static PyGetSetDef symbol_object_getset[] = { -+ { "value", sympy_get_value, NULL, "Value of the symbol.", NULL }, -+ { "symtab", sympy_get_symtab, NULL, -+ "Symbol table in which the symbol appears.", NULL }, -+ { "name", sympy_get_name, NULL, -+ "Name of the symbol, as it appears in the source code.", NULL }, -+ { "linkage_name", sympy_get_linkage_name, NULL, -+ "Name of the symbol, as used by the linker (i.e., may be mangled).", NULL }, -+ { "print_name", sympy_get_print_name, NULL, -+ "Name of the symbol in a form suitable for output.\n\ -+This is either name or linkage_name, depending on whether the user asked GDB\n\ -+to display demangled or mangled names.", NULL }, -+ { "addr_class", sympy_get_addr_class, NULL, "Address class of the symbol." }, -+ { "is_argument", sympy_is_argument, NULL, -+ "True if the symbol is an argument of a function." }, -+ { "is_constant", sympy_is_constant, NULL, -+ "True if the symbol is a constant." }, -+ { "is_function", sympy_is_function, NULL, -+ "True if the symbol is a function or method." }, -+ { "is_variable", sympy_is_variable, NULL, -+ "True if the symbol is a variable." }, -+ { NULL } /* Sentinel */ -+}; -+ -+PyTypeObject symbol_object_type = { -+ PyObject_HEAD_INIT (NULL) -+ 0, /*ob_size*/ -+ "gdb.Symbol", /*tp_name*/ -+ sizeof (symbol_object), /*tp_basicsize*/ -+ 0, /*tp_itemsize*/ -+ 0, /*tp_dealloc*/ -+ 0, /*tp_print*/ -+ 0, /*tp_getattr*/ -+ 0, /*tp_setattr*/ -+ 0, /*tp_compare*/ -+ 0, /*tp_repr*/ -+ 0, /*tp_as_number*/ -+ 0, /*tp_as_sequence*/ -+ 0, /*tp_as_mapping*/ -+ 0, /*tp_hash */ -+ 0, /*tp_call*/ -+ sympy_str, /*tp_str*/ -+ 0, /*tp_getattro*/ -+ 0, /*tp_setattro*/ -+ 0, /*tp_as_buffer*/ -+ Py_TPFLAGS_DEFAULT, /*tp_flags*/ -+ "GDB symbol object", /* tp_doc */ -+ 0, /* tp_traverse */ -+ 0, /* tp_clear */ -+ 0, /* tp_richcompare */ -+ 0, /* tp_weaklistoffset */ -+ 0, /* tp_iter */ -+ 0, /* tp_iternext */ -+ 0, /* tp_methods */ -+ 0, /* tp_members */ -+ symbol_object_getset /* tp_getset */ -+}; -diff --git a/gdb/python/py-symtab.c b/gdb/python/py-symtab.c -new file mode 100644 -index 0000000..830e586 ---- /dev/null -+++ b/gdb/python/py-symtab.c -@@ -0,0 +1,322 @@ -+/* Python interface to symbol tables. -+ -+ Copyright (C) 2008, 2009 Free Software Foundation, Inc. -+ -+ This file is part of GDB. -+ -+ 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 "defs.h" -+#include "charset.h" -+#include "symtab.h" -+#include "source.h" -+#include "python-internal.h" -+ -+typedef struct { -+ PyObject_HEAD -+ struct symtab *symtab; -+} symtab_object; -+ -+static PyTypeObject symtab_object_type; -+ -+typedef struct { -+ PyObject_HEAD -+ symtab_object *symtab; -+ struct symtab_and_line *sal; -+} sal_object; -+ -+static PyTypeObject sal_object_type; -+ -+ -+static PyObject * -+stpy_str (PyObject *self) -+{ -+ int ret; -+ char *s; -+ PyObject *result; -+ -+ ret = asprintf (&s, "symbol table for %s", -+ ((symtab_object *) self)->symtab->filename); -+ if (ret < 0) -+ Py_RETURN_NONE; -+ -+ result = PyString_FromString (s); -+ xfree (s); -+ -+ return result; -+} -+ -+static PyObject * -+stpy_get_filename (PyObject *self, void *closure) -+{ -+ symtab_object *self_symtab = (symtab_object *) self; -+ PyObject *str_obj; -+ -+ /* FIXME: Can symtab->filename really be NULL? */ -+ if (self_symtab->symtab->filename) -+ str_obj = PyString_Decode (self_symtab->symtab->filename, -+ strlen (self_symtab->symtab->filename), -+ host_charset (), NULL); -+ else -+ { -+ str_obj = Py_None; -+ Py_INCREF (Py_None); -+ } -+ -+ return str_obj; -+} -+ -+static PyObject * -+stpy_get_objfile (PyObject *self, void *closure) -+{ -+ symtab_object *self_symtab = (symtab_object *) self; -+ PyObject *result = objfile_to_objfile_object (self_symtab->symtab->objfile); -+ Py_INCREF (result); -+ return result; -+} -+ -+static PyObject * -+stpy_fullname (PyObject *self, PyObject *args) -+{ -+ char *fullname; -+ -+ fullname = symtab_to_fullname (((symtab_object *) self)->symtab); -+ if (fullname) -+ return PyString_Decode (fullname, strlen (fullname), host_charset (), NULL); -+ -+ Py_RETURN_NONE; -+} -+ -+static PyObject * -+salpy_str (PyObject *self) -+{ -+ int ret; -+ char *s, *filename; -+ sal_object *sal_obj; -+ PyObject *result; -+ -+ sal_obj = (sal_object *) self; -+ filename = (sal_obj->symtab == (symtab_object *) Py_None)? "" : -+ sal_obj->symtab->symtab->filename; -+ ret = asprintf (&s, "symbol and line for %s, line %d", filename, -+ sal_obj->sal->line); -+ if (ret < 0) -+ Py_RETURN_NONE; -+ -+ result = PyString_FromString (s); -+ xfree (s); -+ -+ return result; -+} -+ -+static PyObject * -+salpy_get_pc (PyObject *self, void *closure) -+{ -+ return PyLong_FromUnsignedLongLong (((sal_object *) self)->sal->pc); -+} -+ -+static PyObject * -+salpy_get_line (PyObject *self, void *closure) -+{ -+ return PyLong_FromUnsignedLongLong (((sal_object *) self)->sal->line); -+} -+ -+static PyObject * -+salpy_get_symtab (PyObject *self, void *closure) -+{ -+ sal_object *self_sal = (sal_object *) self; -+ -+ Py_INCREF (self_sal->symtab); -+ -+ return (PyObject *) self_sal->symtab; -+} -+ -+static void -+salpy_dealloc (PyObject *self) -+{ -+ sal_object *self_sal = (sal_object *) self; -+ -+ Py_DECREF (self_sal->symtab); -+ xfree (self_sal->sal); -+ self_sal->ob_type->tp_free (self); -+} -+ -+PyObject * -+symtab_and_line_to_sal_object (struct symtab_and_line sal) -+{ -+ sal_object *sal_obj; -+ symtab_object *symtab_obj; -+ -+ sal_obj = PyObject_New (sal_object, &sal_object_type); -+ if (sal_obj == NULL) -+ { -+ PyErr_SetString (PyExc_MemoryError, -+ "Could not allocate Symtab_and_line object."); -+ return NULL; -+ } -+ -+ if (sal.symtab) -+ { -+ symtab_obj = (symtab_object *) symtab_to_symtab_object (sal.symtab); -+ if (symtab_obj == NULL) -+ { -+ Py_DECREF (sal_obj); -+ return NULL; -+ } -+ -+ symtab_obj->symtab = sal.symtab; -+ } -+ else -+ { -+ symtab_obj = (symtab_object *) Py_None; -+ Py_INCREF (Py_None); -+ } -+ -+ sal_obj->sal = (struct symtab_and_line *) -+ xmalloc (sizeof (struct symtab_and_line)); -+ *(sal_obj->sal) = sal; -+ sal_obj->symtab = symtab_obj; -+ -+ return (PyObject *) sal_obj; -+} -+ -+PyObject * -+symtab_to_symtab_object (struct symtab *symtab) -+{ -+ symtab_object *symtab_obj; -+ -+ symtab_obj = PyObject_New (symtab_object, &symtab_object_type); -+ if (symtab_obj == NULL) -+ { -+ PyErr_SetString (PyExc_MemoryError, -+ "Could not allocate Symtab object."); -+ -+ return NULL; -+ } -+ -+ symtab_obj->symtab = symtab; -+ -+ return (PyObject *) symtab_obj; -+} -+ -+void -+gdbpy_initialize_symtabs (void) -+{ -+ symtab_object_type.tp_new = PyType_GenericNew; -+ if (PyType_Ready (&symtab_object_type) < 0) -+ return; -+ -+ sal_object_type.tp_new = PyType_GenericNew; -+ if (PyType_Ready (&sal_object_type) < 0) -+ return; -+ -+ Py_INCREF (&symtab_object_type); -+ PyModule_AddObject (gdb_module, "Symtab", (PyObject *) &symtab_object_type); -+ -+ Py_INCREF (&sal_object_type); -+ PyModule_AddObject (gdb_module, "Symtab_and_line", -+ (PyObject *) &sal_object_type); -+} -+ -+ -+ -+static PyGetSetDef symtab_object_getset[] = { -+ { "filename", stpy_get_filename, NULL, -+ "The symbol table's source filename.", NULL }, -+ { "objfile", stpy_get_objfile, NULL, "The symtab's objfile.", -+ NULL }, -+ {NULL} /* Sentinel */ -+}; -+ -+static PyMethodDef symtab_object_methods[] = { -+ { "fullname", stpy_fullname, METH_NOARGS, -+ "Return the symtab's full source filename." }, -+ {NULL} /* Sentinel */ -+}; -+ -+static PyTypeObject symtab_object_type = { -+ PyObject_HEAD_INIT (NULL) -+ 0, /*ob_size*/ -+ "gdb.Symtab", /*tp_name*/ -+ sizeof (symtab_object), /*tp_basicsize*/ -+ 0, /*tp_itemsize*/ -+ 0, /*tp_dealloc*/ -+ 0, /*tp_print*/ -+ 0, /*tp_getattr*/ -+ 0, /*tp_setattr*/ -+ 0, /*tp_compare*/ -+ 0, /*tp_repr*/ -+ 0, /*tp_as_number*/ -+ 0, /*tp_as_sequence*/ -+ 0, /*tp_as_mapping*/ -+ 0, /*tp_hash */ -+ 0, /*tp_call*/ -+ stpy_str, /*tp_str*/ -+ 0, /*tp_getattro*/ -+ 0, /*tp_setattro*/ -+ 0, /*tp_as_buffer*/ -+ Py_TPFLAGS_DEFAULT, /*tp_flags*/ -+ "GDB symtab object", /* tp_doc */ -+ 0, /* tp_traverse */ -+ 0, /* tp_clear */ -+ 0, /* tp_richcompare */ -+ 0, /* tp_weaklistoffset */ -+ 0, /* tp_iter */ -+ 0, /* tp_iternext */ -+ symtab_object_methods, /* tp_methods */ -+ 0, /* tp_members */ -+ symtab_object_getset /* tp_getset */ -+}; -+ -+static PyGetSetDef sal_object_getset[] = { -+ { "symtab", salpy_get_symtab, NULL, "Symtab object.", NULL }, -+ { "pc", salpy_get_pc, NULL, "Return the symtab_and_line's pc.", NULL }, -+ { "line", salpy_get_line, NULL, -+ "Return the symtab_and_line's line.", NULL }, -+ {NULL} /* Sentinel */ -+}; -+ -+static PyTypeObject sal_object_type = { -+ PyObject_HEAD_INIT (NULL) -+ 0, /*ob_size*/ -+ "gdb.Symtab_and_line", /*tp_name*/ -+ sizeof (sal_object), /*tp_basicsize*/ -+ 0, /*tp_itemsize*/ -+ salpy_dealloc, /*tp_dealloc*/ -+ 0, /*tp_print*/ -+ 0, /*tp_getattr*/ -+ 0, /*tp_setattr*/ -+ 0, /*tp_compare*/ -+ 0, /*tp_repr*/ -+ 0, /*tp_as_number*/ -+ 0, /*tp_as_sequence*/ -+ 0, /*tp_as_mapping*/ -+ 0, /*tp_hash */ -+ 0, /*tp_call*/ -+ salpy_str, /*tp_str*/ -+ 0, /*tp_getattro*/ -+ 0, /*tp_setattro*/ -+ 0, /*tp_as_buffer*/ -+ Py_TPFLAGS_DEFAULT, /*tp_flags*/ -+ "GDB symtab_and_line object", /* tp_doc */ -+ 0, /* tp_traverse */ -+ 0, /* tp_clear */ -+ 0, /* tp_richcompare */ -+ 0, /* tp_weaklistoffset */ -+ 0, /* tp_iter */ -+ 0, /* tp_iternext */ -+ 0, /* tp_methods */ -+ 0, /* tp_members */ -+ sal_object_getset /* tp_getset */ -+}; -diff --git a/gdb/python/py-type.c b/gdb/python/py-type.c -index 590d90a..f512248 100644 ---- a/gdb/python/py-type.c -+++ b/gdb/python/py-type.c -@@ -27,6 +27,8 @@ - #include "demangle.h" - #include "objfiles.h" - #include "language.h" -+#include "observer.h" -+#include "gdb_assert.h" - - typedef struct pyty_type_object - { -@@ -35,11 +37,17 @@ typedef struct pyty_type_object - - /* If a Type object is associated with an objfile, it is kept on a - doubly-linked list, rooted in the objfile. This lets us copy the -- underlying struct type when the objfile is deleted. */ -+ underlying struct type when the objfile is deleted. -+ -+ With NULL objfile Type still can be doubly-linked in the list -+ PYTY_OBJECTS_DISCARDABLE. */ - struct pyty_type_object *prev; - struct pyty_type_object *next; - } type_object; - -+/* First element of a doubly-linked list of TYPE_DISCARDABLE Types. */ -+static type_object *pyty_objects_discardable; -+ - static PyTypeObject type_object_type; - - /* A Field object. */ -@@ -169,6 +177,11 @@ convert_field (struct type *type, int field) - if (PyObject_SetAttrString (result, "artificial", arg) < 0) - goto failarg; - -+ arg = field < TYPE_N_BASECLASSES (type) ? Py_True : Py_False; -+ Py_INCREF (arg); -+ if (PyObject_SetAttrString (result, "is_base_class", arg) < 0) -+ goto failarg; -+ - arg = PyLong_FromLong (TYPE_FIELD_BITSIZE (type, field)); - if (!arg) - goto fail; -@@ -361,7 +374,7 @@ typy_get_sizeof (PyObject *self, void *closure) - } - - static struct type * --typy_lookup_typename (char *type_name) -+typy_lookup_typename (char *type_name, struct block *block) - { - struct type *type = NULL; - volatile struct gdb_exception except; -@@ -375,7 +388,7 @@ typy_lookup_typename (char *type_name) - type = lookup_enum (type_name + 5, NULL); - else - type = lookup_typename (python_language, python_gdbarch, -- type_name, NULL, 0); -+ type_name, block, 0); - } - if (except.reason < 0) - { -@@ -389,7 +402,8 @@ typy_lookup_typename (char *type_name) - } - - static struct type * --typy_lookup_type (struct demangle_component *demangled) -+typy_lookup_type (struct demangle_component *demangled, -+ struct block *block) - { - struct type *type; - char *type_name; -@@ -404,7 +418,7 @@ typy_lookup_type (struct demangle_component *demangled) - || demangled_type == DEMANGLE_COMPONENT_CONST - || demangled_type == DEMANGLE_COMPONENT_VOLATILE) - { -- type = typy_lookup_type (demangled->u.s_binary.left); -+ type = typy_lookup_type (demangled->u.s_binary.left, block); - if (! type) - return NULL; - -@@ -422,7 +436,7 @@ typy_lookup_type (struct demangle_component *demangled) - } - - type_name = cp_comp_to_string (demangled, 10); -- type = typy_lookup_typename (type_name); -+ type = typy_lookup_typename (type_name, block); - xfree (type_name); - - return type; -@@ -436,10 +450,23 @@ typy_template_argument (PyObject *self, PyObject *args) - struct demangle_component *demangled; - const char *err; - struct type *argtype; -+ struct block *block = NULL; -+ PyObject *block_obj = NULL; - -- if (! PyArg_ParseTuple (args, "i", &argno)) -+ if (! PyArg_ParseTuple (args, "i|O", &argno, &block_obj)) - return NULL; - -+ if (block_obj) -+ { -+ block = block_object_to_block (block_obj); -+ if (! block) -+ { -+ PyErr_SetString (PyExc_RuntimeError, -+ "second argument must be block"); -+ return NULL; -+ } -+ } -+ - type = check_typedef (type); - if (TYPE_CODE (type) == TYPE_CODE_REF) - type = check_typedef (TYPE_TARGET_TYPE (type)); -@@ -482,7 +509,7 @@ typy_template_argument (PyObject *self, PyObject *args) - return NULL; - } - -- argtype = typy_lookup_type (demangled->u.s_binary.left); -+ argtype = typy_lookup_type (demangled->u.s_binary.left, block); - if (! argtype) - return NULL; - -@@ -524,8 +551,59 @@ typy_str (PyObject *self) - - - -+/* Key associated with each objfile pointing to the first element of -+ a doubly-linked list of Types associated with this objfile. */ - static const struct objfile_data *typy_objfile_data_key; - -+/* Link TYPE_OBJ to its appropriate list. Either to its objfile associated one -+ or at least to the global list for TYPE_DISCARDABLE Types. Permanent types -+ do not get linked anywhere. */ -+static void -+typy_link (type_object *type_obj) -+{ -+ type_obj->prev = NULL; -+ -+ if (type_obj->type && TYPE_OBJFILE (type_obj->type)) -+ { -+ struct objfile *objfile = TYPE_OBJFILE (type_obj->type); -+ -+ type_obj->next = objfile_data (objfile, typy_objfile_data_key); -+ if (type_obj->next) -+ type_obj->next->prev = type_obj; -+ set_objfile_data (objfile, typy_objfile_data_key, type_obj); -+ } -+ else if (type_obj->type && TYPE_DISCARDABLE (type_obj->type)) -+ { -+ type_obj->next = pyty_objects_discardable; -+ if (type_obj->next) -+ type_obj->next->prev = type_obj; -+ pyty_objects_discardable = type_obj; -+ } -+ else -+ type_obj->next = NULL; -+} -+ -+/* Unlink TYPE_OBJ from its current list. Permanent types are not linked -+ anywhere and this function has no effect on them. */ -+static void -+typy_unlink (type_object *type_obj) -+{ -+ if (type_obj->prev) -+ type_obj->prev->next = type_obj->next; -+ else if (type_obj->type && TYPE_OBJFILE (type_obj->type)) -+ { -+ /* Must reset head of list. */ -+ struct objfile *objfile = TYPE_OBJFILE (type_obj->type); -+ -+ set_objfile_data (objfile, typy_objfile_data_key, type_obj->next); -+ } -+ else if (pyty_objects_discardable == type_obj) -+ pyty_objects_discardable = type_obj->next; -+ -+ if (type_obj->next) -+ type_obj->next->prev = type_obj->prev; -+} -+ - static void - save_objfile_types (struct objfile *objfile, void *datum) - { -@@ -543,12 +621,13 @@ save_objfile_types (struct objfile *objfile, void *datum) - { - type_object *next = obj->next; - -- htab_empty (copied_types); -+ gdb_assert (TYPE_OBJFILE (obj->type) == objfile); -+ typy_unlink (obj); - -- obj->type = copy_type_recursive (objfile, obj->type, copied_types); -+ obj->type = copy_type_recursive (obj->type, copied_types); - -- obj->next = NULL; -- obj->prev = NULL; -+ gdb_assert (TYPE_OBJFILE (obj->type) == NULL); -+ typy_link (obj); - - obj = next; - } -@@ -559,41 +638,25 @@ save_objfile_types (struct objfile *objfile, void *datum) - } - - static void --set_type (type_object *obj, struct type *type) -+typy_dealloc (PyObject *obj) - { -- obj->type = type; -- obj->prev = NULL; -- if (type && TYPE_OBJFILE (type)) -- { -- struct objfile *objfile = TYPE_OBJFILE (type); -+ type_object *type_obj = (type_object *) obj; - -- obj->next = objfile_data (objfile, typy_objfile_data_key); -- if (obj->next) -- obj->next->prev = obj; -- set_objfile_data (objfile, typy_objfile_data_key, obj); -- } -- else -- obj->next = NULL; -+ typy_unlink (type_obj); -+ -+ type_obj->ob_type->tp_free (obj); - } - -+/* Call type_mark_used for any TYPEs referenced from this GDB source file. */ - static void --typy_dealloc (PyObject *obj) -+typy_types_mark_used (void) - { -- type_object *type = (type_object *) obj; -- -- if (type->prev) -- type->prev->next = type->next; -- else if (type->type && TYPE_OBJFILE (type->type)) -- { -- /* Must reset head of list. */ -- struct objfile *objfile = TYPE_OBJFILE (type->type); -- if (objfile) -- set_objfile_data (objfile, typy_objfile_data_key, type->next); -- } -- if (type->next) -- type->next->prev = type->prev; -+ type_object *type_obj; - -- type->ob_type->tp_free (type); -+ for (type_obj = pyty_objects_discardable; -+ type_obj != NULL; -+ type_obj = type_obj->next) -+ type_mark_used (type_obj->type); - } - - /* Create a new Type referring to TYPE. */ -@@ -604,7 +667,10 @@ type_to_type_object (struct type *type) - - type_obj = PyObject_New (type_object, &type_object_type); - if (type_obj) -- set_type (type_obj, type); -+ { -+ type_obj->type = type; -+ typy_link (type_obj); -+ } - - return (PyObject *) type_obj; - } -@@ -623,14 +689,28 @@ type_object_to_type (PyObject *obj) - PyObject * - gdbpy_lookup_type (PyObject *self, PyObject *args, PyObject *kw) - { -- static char *keywords[] = { "name", NULL }; -+ static char *keywords[] = { "name", "block", NULL }; - char *type_name = NULL; - struct type *type = NULL; -+ PyObject *block_obj = NULL; -+ struct block *block = NULL; - -- if (! PyArg_ParseTupleAndKeywords (args, kw, "s", keywords, &type_name)) -+ if (! PyArg_ParseTupleAndKeywords (args, kw, "s|O", keywords, -+ &type_name, &block_obj)) - return NULL; - -- type = typy_lookup_typename (type_name); -+ if (block_obj) -+ { -+ block = block_object_to_block (block_obj); -+ if (! block) -+ { -+ PyErr_SetString (PyExc_RuntimeError, -+ "'block' argument must be a Block"); -+ return NULL; -+ } -+ } -+ -+ type = typy_lookup_typename (type_name, block); - if (! type) - return NULL; - -@@ -664,6 +744,8 @@ gdbpy_initialize_types (void) - - Py_INCREF (&field_object_type); - PyModule_AddObject (gdb_module, "Field", (PyObject *) &field_object_type); -+ -+ observer_attach_mark_used (typy_types_mark_used); - } - - -diff --git a/gdb/python/py-utils.c b/gdb/python/py-utils.c -index 49c0437..84a476e 100644 ---- a/gdb/python/py-utils.c -+++ b/gdb/python/py-utils.c -@@ -19,6 +19,7 @@ - - #include "defs.h" - #include "charset.h" -+#include "value.h" - #include "python-internal.h" - - -@@ -219,3 +220,48 @@ gdbpy_is_string (PyObject *obj) - { - return PyString_Check (obj) || PyUnicode_Check (obj); - } -+ -+/* Converts OBJ to a CORE_ADDR value. -+ -+ Returns 1 on success or 0 on failure, with a Python exception set. This -+ function can also throw GDB exceptions. */ -+ -+int -+get_addr_from_python (PyObject *obj, CORE_ADDR *addr) -+{ -+ if (gdbpy_is_value_object (obj)) -+ *addr = value_as_address (value_object_to_value (obj)); -+ else if (PyLong_Check (obj)) -+ { -+ /* Assume CORE_ADDR corresponds to unsigned long. */ -+ *addr = PyLong_AsUnsignedLong (obj); -+ if (PyErr_Occurred () != NULL) -+ return 0; -+ } -+ else if (PyInt_Check (obj)) -+ { -+ long val; -+ -+ /* Assume CORE_ADDR corresponds to unsigned long. */ -+ val = PyInt_AsLong (obj); -+ -+ if (val >= 0) -+ *addr = val; -+ else -+ { -+ /* If no error ocurred, VAL is indeed negative. */ -+ if (PyErr_Occurred () != NULL) -+ return 0; -+ -+ PyErr_SetString (PyExc_ValueError, "negative address"); -+ return 0; -+ } -+ } -+ else -+ { -+ PyErr_SetString (PyExc_TypeError, "invalid type for address"); -+ return 0; -+ } -+ -+ return 1; -+} -diff --git a/gdb/python/py-value.c b/gdb/python/py-value.c -index 0146593..b82fcb6 100644 ---- a/gdb/python/py-value.c -+++ b/gdb/python/py-value.c -@@ -25,6 +25,7 @@ - #include "language.h" - #include "dfp.h" - #include "valprint.h" -+#include "observer.h" - - #ifdef HAVE_PYTHON - -@@ -43,6 +44,10 @@ - /* Python's long type corresponds to C's long long type. */ - #define builtin_type_pylong builtin_type (python_gdbarch)->builtin_long_long - -+/* Python's long type corresponds to C's long long type. Unsigned version. */ -+#define builtin_type_upylong builtin_type \ -+ (python_gdbarch)->builtin_unsigned_long_long -+ - #define builtin_type_pybool \ - language_bool_type (python_language, python_gdbarch) - -@@ -913,7 +918,34 @@ convert_value_from_python (PyObject *obj) - { - LONGEST l = PyLong_AsLongLong (obj); - -- if (! PyErr_Occurred ()) -+ if (PyErr_Occurred ()) -+ { -+ /* If the error was an overflow, we can try converting to -+ ULONGEST instead. */ -+ if (PyErr_ExceptionMatches (PyExc_OverflowError)) -+ { -+ PyObject *etype, *evalue, *etraceback, *zero; -+ -+ PyErr_Fetch (&etype, &evalue, &etraceback); -+ zero = PyInt_FromLong (0); -+ -+ /* Check whether obj is positive. */ -+ if (PyObject_RichCompareBool (obj, zero, Py_GT) > 0) -+ { -+ ULONGEST ul; -+ -+ ul = PyLong_AsUnsignedLongLong (obj); -+ if (! PyErr_Occurred ()) -+ value = value_from_ulongest (builtin_type_upylong, ul); -+ } -+ else -+ /* There's nothing we can do. */ -+ PyErr_Restore (etype, evalue, etraceback); -+ -+ Py_DECREF (zero); -+ } -+ } -+ else - value = value_from_longest (builtin_type_pylong, l); - } - else if (PyFloat_Check (obj)) -@@ -972,6 +1004,25 @@ gdbpy_history (PyObject *self, PyObject *args) - return value_to_value_object (res_val); - } - -+/* Call type_mark_used for any TYPEs referenced from this GDB source file. */ -+ -+static void -+python_types_mark_used (void) -+{ -+ value_object *iter; -+ -+ for (iter = values_in_python; iter; iter = iter->next) -+ type_mark_used (value_type (iter->value)); -+} -+ -+/* Returns 1 in OBJ is a gdb.Value object, 0 otherwise. */ -+ -+int -+gdbpy_is_value_object (PyObject *obj) -+{ -+ return PyObject_TypeCheck (obj, &value_object_type); -+} -+ - void - gdbpy_initialize_values (void) - { -@@ -982,6 +1033,8 @@ gdbpy_initialize_values (void) - PyModule_AddObject (gdb_module, "Value", (PyObject *) &value_object_type); - - values_in_python = NULL; -+ -+ observer_attach_mark_used (python_types_mark_used); - } - - -diff --git a/gdb/python/python-internal.h b/gdb/python/python-internal.h -index 67a78af..47662d9 100644 ---- a/gdb/python/python-internal.h -+++ b/gdb/python/python-internal.h -@@ -61,33 +61,76 @@ typedef int Py_ssize_t; - #define PyEval_ReleaseLock() 0 - #endif - -+#include "command.h" -+ -+struct block; -+struct symbol; -+struct symtab_and_line; - struct value; - struct language_defn; - - extern PyObject *gdb_module; -+extern PyTypeObject block_object_type; - extern PyTypeObject value_object_type; -+extern PyTypeObject symbol_object_type; -+ -+/* Used in python-inferior.c. */ -+typedef struct -+{ -+ PyObject_HEAD -+ -+ /* The thread we represent. */ -+ struct thread_info *thread; -+ -+ /* The Inferior object to which this thread belongs. */ -+ PyObject *inf_obj; -+} thread_object; - - PyObject *gdbpy_history (PyObject *self, PyObject *args); -+PyObject *gdbpy_breakpoints (PyObject *, PyObject *); - PyObject *gdbpy_frame_stop_reason_string (PyObject *, PyObject *); -+PyObject *gdbpy_lookup_symbol (PyObject *self, PyObject *args, PyObject *kw); - PyObject *gdbpy_selected_frame (PyObject *self, PyObject *args); -+PyObject *gdbpy_block_for_pc (PyObject *self, PyObject *args); - PyObject *gdbpy_lookup_type (PyObject *self, PyObject *args, PyObject *kw); -+PyObject *gdbpy_inferiors (PyObject *unused, PyObject *unused2); -+PyObject *gdbpy_selected_thread (PyObject *self, PyObject *args); - -+PyObject *symtab_and_line_to_sal_object (struct symtab_and_line sal); -+PyObject *symtab_to_symtab_object (struct symtab *symtab); -+PyObject *symbol_to_symbol_object (struct symbol *sym); -+PyObject *block_to_block_object (struct block *block); - PyObject *value_to_value_object (struct value *v); - PyObject *type_to_type_object (struct type *); - PyObject *objfile_to_objfile_object (struct objfile *); -+PyObject *frame_info_to_frame_object (struct frame_info *frame); -+thread_object *create_thread_object (struct thread_info *tp); -+thread_object *find_thread_object (ptid_t ptid); -+PyObject *find_inferior_object (int pid); - - PyObject *objfpy_get_printers (PyObject *, void *); - -+struct block *block_object_to_block (PyObject *obj); -+struct symbol *symbol_object_to_symbol (PyObject *obj); - struct value *value_object_to_value (PyObject *self); - struct value *convert_value_from_python (PyObject *obj); - struct type *type_object_to_type (PyObject *obj); - -+PyObject *gdbpy_get_hook_function (const char *); -+ - void gdbpy_initialize_values (void); -+void gdbpy_initialize_breakpoints (void); - void gdbpy_initialize_frames (void); -+void gdbpy_initialize_symtabs (void); - void gdbpy_initialize_commands (void); -+void gdbpy_initialize_symbols (void); - void gdbpy_initialize_types (void); -+void gdbpy_initialize_blocks (void); - void gdbpy_initialize_functions (void); - void gdbpy_initialize_objfile (void); -+void gdbpy_initialize_parameters (void); -+void gdbpy_initialize_thread (void); -+void gdbpy_initialize_inferior (void); - - struct cleanup *make_cleanup_py_decref (PyObject *py); - -@@ -97,6 +140,12 @@ struct cleanup *ensure_python_env (struct gdbarch *gdbarch, - extern struct gdbarch *python_gdbarch; - extern const struct language_defn *python_language; - -+char *gdbpy_parse_command_name (char *text, -+ struct cmd_list_element ***base_list, -+ struct cmd_list_element **start_list); -+ -+PyObject *gdbpy_parameter_value (enum var_types, void *); -+ - /* Use this after a TRY_EXCEPT to throw the appropriate Python - exception. */ - #define GDB_PY_HANDLE_EXCEPTION(Exception) \ -@@ -107,6 +156,19 @@ extern const struct language_defn *python_language; - "%s", Exception.message); \ - } while (0) - -+/* Use this after a TRY_EXCEPT to throw the appropriate Python -+ exception. This macro is for use inside setter functions. */ -+#define GDB_PY_SET_HANDLE_EXCEPTION(Exception) \ -+ do { \ -+ if (Exception.reason < 0) \ -+ { \ -+ PyErr_Format (Exception.reason == RETURN_QUIT \ -+ ? PyExc_KeyboardInterrupt : PyExc_RuntimeError, \ -+ "%s", Exception.message); \ -+ return -1; \ -+ } \ -+ } while (0) -+ - - void gdbpy_print_stack (void); - -@@ -118,17 +180,22 @@ char *python_string_to_host_string (PyObject *obj); - PyObject *target_string_to_unicode (const gdb_byte *str, int length); - int gdbpy_is_string (PyObject *obj); - -+int gdbpy_is_value_object (PyObject *obj); -+ - /* Note that these are declared here, and not in python.h with the - other pretty-printer functions, because they refer to PyObject. */ - PyObject *apply_varobj_pretty_printer (PyObject *print_obj, - struct value **replacement); - PyObject *gdbpy_get_varobj_pretty_printer (struct value *value); -+PyObject *gdbpy_instantiate_printer (PyObject *cons, PyObject *value); - char *gdbpy_get_display_hint (PyObject *printer); - PyObject *gdbpy_default_visualizer (PyObject *self, PyObject *args); - --extern PyObject *gdbpy_doc_cst; - extern PyObject *gdbpy_children_cst; - extern PyObject *gdbpy_to_string_cst; - extern PyObject *gdbpy_display_hint_cst; -+extern PyObject *gdbpy_doc_cst; -+ -+int get_addr_from_python (PyObject *obj, CORE_ADDR *addr); - - #endif /* GDB_PYTHON_INTERNAL_H */ -diff --git a/gdb/python/python.c b/gdb/python/python.c -index 254bd28..5a2a9ae 100644 ---- a/gdb/python/python.c -+++ b/gdb/python/python.c -@@ -27,6 +27,7 @@ - #include "observer.h" - #include "value.h" - #include "language.h" -+#include "event-loop.h" - - #include - -@@ -45,11 +46,18 @@ static int gdbpy_auto_load = 1; - #include "cli/cli-decode.h" - #include "charset.h" - #include "top.h" -+#include "solib.h" - #include "exceptions.h" - #include "python-internal.h" -+#include "linespec.h" -+#include "symtab.h" -+#include "source.h" - #include "version.h" -+#include "inferior.h" -+#include "gdbthread.h" - #include "target.h" - #include "gdbthread.h" -+#include "event-top.h" - - static PyMethodDef GdbMethods[]; - -@@ -197,10 +205,10 @@ python_command (char *arg, int from_tty) - NULL (and set a Python exception) on error. Helper function for - get_parameter. */ - --static PyObject * --parameter_to_python (struct cmd_list_element *cmd) -+PyObject * -+gdbpy_parameter_value (enum var_types type, void *var) - { -- switch (cmd->var_type) -+ switch (type) - { - case var_string: - case var_string_noescape: -@@ -208,7 +216,7 @@ parameter_to_python (struct cmd_list_element *cmd) - case var_filename: - case var_enum: - { -- char *str = * (char **) cmd->var; -+ char *str = * (char **) var; - if (! str) - str = ""; - return PyString_Decode (str, strlen (str), host_charset (), NULL); -@@ -216,7 +224,7 @@ parameter_to_python (struct cmd_list_element *cmd) - - case var_boolean: - { -- if (* (int *) cmd->var) -+ if (* (int *) var) - Py_RETURN_TRUE; - else - Py_RETURN_FALSE; -@@ -224,7 +232,7 @@ parameter_to_python (struct cmd_list_element *cmd) - - case var_auto_boolean: - { -- enum auto_boolean ab = * (enum auto_boolean *) cmd->var; -+ enum auto_boolean ab = * (enum auto_boolean *) var; - if (ab == AUTO_BOOLEAN_TRUE) - Py_RETURN_TRUE; - else if (ab == AUTO_BOOLEAN_FALSE) -@@ -234,15 +242,15 @@ parameter_to_python (struct cmd_list_element *cmd) - } - - case var_integer: -- if ((* (int *) cmd->var) == INT_MAX) -+ if ((* (int *) var) == INT_MAX) - Py_RETURN_NONE; - /* Fall through. */ - case var_zinteger: -- return PyLong_FromLong (* (int *) cmd->var); -+ return PyLong_FromLong (* (int *) var); - - case var_uinteger: - { -- unsigned int val = * (unsigned int *) cmd->var; -+ unsigned int val = * (unsigned int *) var; - if (val == UINT_MAX) - Py_RETURN_NONE; - return PyLong_FromUnsignedLong (val); -@@ -280,7 +288,7 @@ gdbpy_parameter (PyObject *self, PyObject *args) - - if (! cmd->var) - return PyErr_Format (PyExc_RuntimeError, "`%s' is not a parameter", arg); -- return parameter_to_python (cmd); -+ return gdbpy_parameter_value (cmd->var_type, cmd->var); - } - - /* A Python function which evaluates a string using the gdb CLI. */ -@@ -319,6 +327,233 @@ execute_gdb_command (PyObject *self, PyObject *args) - Py_RETURN_NONE; - } - -+/* Implementation of gdb.solib_address (Long) -> String. -+ Returns the name of the shared library holding a given address, or None. */ -+ -+static PyObject * -+gdbpy_solib_address (PyObject *self, PyObject *args) -+{ -+ unsigned long long pc; -+ char *soname; -+ PyObject *str_obj; -+ -+ if (!PyArg_ParseTuple (args, "K", &pc)) -+ return NULL; -+ -+ soname = solib_name_from_address (pc); -+ if (soname) -+ str_obj = PyString_Decode (soname, strlen (soname), host_charset (), NULL); -+ else -+ { -+ str_obj = Py_None; -+ Py_INCREF (Py_None); -+ } -+ -+ return str_obj; -+} -+ -+/* A Python function which is a wrapper for decode_line_1. */ -+ -+static PyObject * -+gdbpy_decode_line (PyObject *self, PyObject *args) -+{ -+ struct symtabs_and_lines sals = { NULL, 0 }; /* Initialize to appease gcc. */ -+ struct symtab_and_line sal; -+ char *arg = NULL; -+ int free_sals = 0, i; -+ PyObject *result = NULL; -+ volatile struct gdb_exception except; -+ -+ if (! PyArg_ParseTuple (args, "|s", &arg)) -+ return NULL; -+ -+ TRY_CATCH (except, RETURN_MASK_ALL) -+ { -+ if (arg) -+ { -+ char *copy; -+ -+ arg = strdup (arg); -+ copy = arg; -+ -+ sals = decode_line_1 (©, 0, 0, 0, 0, 0); -+ free_sals = 1; -+ } -+ else -+ { -+ set_default_source_symtab_and_line (); -+ sal = get_current_source_symtab_and_line (); -+ sals.sals = &sal; -+ sals.nelts = 1; -+ } -+ } -+ if (arg) -+ xfree (arg); -+ -+ if (except.reason < 0) -+ { -+ if (free_sals) -+ xfree (sals.sals); -+ /* We know this will always throw. */ -+ GDB_PY_HANDLE_EXCEPTION (except); -+ } -+ -+ if (sals.nelts) -+ { -+ result = PyTuple_New (sals.nelts); -+ for (i = 0; i < sals.nelts; ++i) -+ { -+ PyObject *obj; -+ char *str; -+ -+ obj = symtab_and_line_to_sal_object (sals.sals[i]); -+ if (! obj) -+ { -+ Py_DECREF (result); -+ result = NULL; -+ break; -+ } -+ -+ PyTuple_SetItem (result, i, obj); -+ } -+ } -+ -+ if (free_sals) -+ xfree (sals.sals); -+ -+ if (result) -+ return result; -+ Py_RETURN_NONE; -+} -+ -+/* Parse a string and evaluate it as an expression. */ -+static PyObject * -+gdbpy_parse_and_eval (PyObject *self, PyObject *args) -+{ -+ char *expr_str; -+ struct value *result = NULL; -+ volatile struct gdb_exception except; -+ -+ if (!PyArg_ParseTuple (args, "s", &expr_str)) -+ return NULL; -+ -+ TRY_CATCH (except, RETURN_MASK_ALL) -+ { -+ result = parse_and_eval (expr_str); -+ } -+ GDB_PY_HANDLE_EXCEPTION (except); -+ -+ return value_to_value_object (result); -+} -+ -+ -+ -+/* Posting and handling events. */ -+ -+/* A single event. */ -+struct gdbpy_event -+{ -+ /* The Python event. This is just a callable object. */ -+ PyObject *event; -+ /* The next event. */ -+ struct gdbpy_event *next; -+}; -+ -+/* All pending events. */ -+static struct gdbpy_event *gdbpy_event_list; -+/* The final link of the event list. */ -+static struct gdbpy_event **gdbpy_event_list_end; -+ -+/* We use a file handler, and not an async handler, so that we can -+ wake up the main thread even when it is blocked in poll(). */ -+static int gdbpy_event_fds[2]; -+ -+/* The file handler callback. This reads from the internal pipe, and -+ then processes the Python event queue. This will always be run in -+ the main gdb thread. */ -+static void -+gdbpy_run_events (int err, gdb_client_data ignore) -+{ -+ PyGILState_STATE state; -+ char buffer[100]; -+ int r; -+ -+ state = PyGILState_Ensure (); -+ -+ /* Just read whatever is available on the fd. It is relatively -+ harmless if there are any bytes left over. */ -+ r = read (gdbpy_event_fds[0], buffer, sizeof (buffer)); -+ -+ while (gdbpy_event_list) -+ { -+ /* Dispatching the event might push a new element onto the event -+ loop, so we update here "atomically enough". */ -+ struct gdbpy_event *item = gdbpy_event_list; -+ gdbpy_event_list = gdbpy_event_list->next; -+ if (gdbpy_event_list == NULL) -+ gdbpy_event_list_end = &gdbpy_event_list; -+ -+ /* Ignore errors. */ -+ PyObject_CallObject (item->event, NULL); -+ -+ Py_DECREF (item->event); -+ xfree (item); -+ } -+ -+ PyGILState_Release (state); -+} -+ -+/* Submit an event to the gdb thread. */ -+static PyObject * -+gdbpy_post_event (PyObject *self, PyObject *args) -+{ -+ struct gdbpy_event *event; -+ PyObject *func; -+ int wakeup; -+ -+ if (!PyArg_ParseTuple (args, "O", &func)) -+ return NULL; -+ -+ if (!PyCallable_Check (func)) -+ { -+ PyErr_SetString (PyExc_RuntimeError, "Posted event is not callable"); -+ return NULL; -+ } -+ -+ Py_INCREF (func); -+ -+ /* From here until the end of the function, we have the GIL, so we -+ can operate on our global data structures without worrying. */ -+ wakeup = gdbpy_event_list == NULL; -+ -+ event = XNEW (struct gdbpy_event); -+ event->event = func; -+ event->next = NULL; -+ *gdbpy_event_list_end = event; -+ gdbpy_event_list_end = &event->next; -+ -+ /* Wake up gdb when needed. */ -+ if (wakeup) -+ { -+ char c = 'q'; /* Anything. */ -+ if (write (gdbpy_event_fds[1], &c, 1) != 1) -+ return PyErr_SetFromErrno (PyExc_IOError); -+ } -+ -+ Py_RETURN_NONE; -+} -+ -+/* Initialize the Python event handler. */ -+static void -+gdbpy_initialize_events (void) -+{ -+ if (!pipe (gdbpy_event_fds)) -+ { -+ gdbpy_event_list_end = &gdbpy_event_list; -+ add_file_handler (gdbpy_event_fds[0], gdbpy_run_events, NULL); -+ } -+} -+ - - - /* Printing. */ -@@ -357,6 +592,69 @@ gdbpy_print_stack (void) - - - -+/* Script interface. */ -+ -+/* True if 'gdb -P' was used, false otherwise. */ -+static int running_python_script; -+ -+/* True if we are currently in a call to 'gdb.cli', false otherwise. */ -+static int in_cli; -+ -+/* Enter the command loop. */ -+ -+static PyObject * -+gdbpy_cli (PyObject *unused1, PyObject *unused2) -+{ -+ if (! running_python_script || in_cli) -+ return PyErr_Format (PyExc_RuntimeError, "cannot invoke CLI recursively"); -+ -+ in_cli = 1; -+ cli_command_loop (); -+ in_cli = 0; -+ -+ Py_RETURN_NONE; -+} -+ -+/* Set up the Python argument vector and evaluate a script. This is -+ used to implement 'gdb -P'. */ -+ -+void -+run_python_script (int argc, char **argv) -+{ -+ FILE *input; -+ PyGILState_STATE state; -+ -+ /* We never free this, since we plan to exit at the end. */ -+ state = PyGILState_Ensure (); -+ -+ running_python_script = 1; -+ PySys_SetArgv (argc - 1, argv + 1); -+ input = fopen (argv[0], "r"); -+ if (! input) -+ { -+ fprintf (stderr, "could not open %s: %s\n", argv[0], strerror (errno)); -+ exit (1); -+ } -+ PyRun_SimpleFile (input, argv[0]); -+ fclose (input); -+ exit (0); -+} -+ -+void -+source_python_script (FILE *stream, char *file) -+{ -+ PyGILState_STATE state; -+ -+ state = PyGILState_Ensure (); -+ -+ PyRun_SimpleFile (stream, file); -+ -+ fclose (stream); -+ PyGILState_Release (state); -+} -+ -+ -+ - /* The "current" objfile. This is set when gdb detects that a new - objfile has been loaded. It is only set for the duration of a call - to gdbpy_new_objfile; it is NULL at other times. */ -@@ -501,6 +799,13 @@ eval_python_from_control_command (struct command_line *cmd) - error (_("Python scripting is not supported in this copy of GDB.")); - } - -+void -+source_python_script (FILE *stream) -+{ -+ fclose (stream); -+ error (_("Python scripting is not supported in this copy of GDB.")); -+} -+ - #endif /* HAVE_PYTHON */ - - -@@ -592,13 +897,27 @@ Enables or disables auto-loading of Python code when an object is opened."), - PyModule_AddStringConstant (gdb_module, "VERSION", (char*) version); - PyModule_AddStringConstant (gdb_module, "HOST_CONFIG", (char*) host_name); - PyModule_AddStringConstant (gdb_module, "TARGET_CONFIG", (char*) target_name); -+#ifdef PYTHONDIR -+ PyModule_AddStringConstant (gdb_module, "pythondir", PYTHONDIR); -+#else -+ if (gdb_datadir) -+ PyModule_AddStringConstant (gdb_module, "datadir", gdb_datadir); -+#endif - - gdbpy_initialize_values (); -+ gdbpy_initialize_breakpoints (); - gdbpy_initialize_frames (); -+ gdbpy_initialize_symtabs (); - gdbpy_initialize_commands (); -+ gdbpy_initialize_symbols (); -+ gdbpy_initialize_blocks (); - gdbpy_initialize_functions (); - gdbpy_initialize_types (); -+ gdbpy_initialize_parameters (); - gdbpy_initialize_objfile (); -+ gdbpy_initialize_thread (); -+ gdbpy_initialize_inferior (); -+ gdbpy_initialize_events (); - - PyRun_SimpleString ("import gdb"); - PyRun_SimpleString ("gdb.pretty_printers = []"); -@@ -634,6 +953,15 @@ class GdbOutputFile:\n\ - \n\ - sys.stderr = GdbOutputFile()\n\ - sys.stdout = GdbOutputFile()\n\ -+if hasattr (gdb, 'datadir'):\n\ -+ gdb.pythondir = gdb.datadir + '/python'\n\ -+if hasattr (gdb, 'pythondir'):\n\ -+ sys.path.insert(0, gdb.pythondir)\n\ -+ gdb.__path__ = [gdb.pythondir + '/gdb']\n\ -+ from os.path import exists\n\ -+ ipy = gdb.pythondir + '/gdb/__init__.py'\n\ -+ if exists (ipy):\n\ -+ execfile (ipy)\n\ - "); - - /* Release the GIL while gdb runs. */ -@@ -653,9 +981,14 @@ static PyMethodDef GdbMethods[] = - "Get a value from history" }, - { "execute", execute_gdb_command, METH_VARARGS, - "Execute a gdb command" }, -+ { "cli", gdbpy_cli, METH_NOARGS, -+ "Enter the gdb CLI" }, - { "parameter", gdbpy_parameter, METH_VARARGS, - "Return a gdb parameter's value" }, - -+ { "breakpoints", gdbpy_breakpoints, METH_NOARGS, -+ "Return a tuple of all breakpoint objects" }, -+ - { "default_visualizer", gdbpy_default_visualizer, METH_VARARGS, - "Find the default visualizer for a Value." }, - -@@ -676,6 +1009,37 @@ Return a string explaining unwind stop reason." }, - "lookup_type (name [, block]) -> type\n\ - Return a Type corresponding to the given name." }, - -+ { "lookup_symbol", (PyCFunction) gdbpy_lookup_symbol, -+ METH_VARARGS | METH_KEYWORDS, -+ "lookup_symbol (name [, block] [, domain]) -> (symbol, is_field_of_this)\n\ -+Return a tuple with the symbol corresponding to the given name (or None) and\n\ -+a boolean indicating if name is a field of the current implied argument\n\ -+`this' (when the current language is object-oriented)." }, -+ { "solib_address", gdbpy_solib_address, METH_VARARGS, -+ "solib_address (Long) -> String.\n\ -+Return the name of the shared library holding a given address, or None." }, -+ -+ { "block_for_pc", gdbpy_block_for_pc, METH_VARARGS, -+ "Return the block containing the given pc value, or None." }, -+ -+ { "decode_line", gdbpy_decode_line, METH_VARARGS, -+ "Decode a string argument the way that 'break' or 'edit' does.\n\ -+Return a tuple holding the file name (or None) and line number (or None).\n\ -+Note: may later change to return an object." }, -+ -+ { "selected_thread", gdbpy_selected_thread, METH_NOARGS, -+ "selected_thread () -> gdb.InferiorThread.\n\ -+Return the selected thread object." }, -+ { "inferiors", gdbpy_inferiors, METH_NOARGS, -+ "inferiors () -> (gdb.Inferior, ...).\n\ -+Return a tuple containing all inferiors." }, -+ -+ { "parse_and_eval", gdbpy_parse_and_eval, METH_VARARGS, -+ "Parse a string as an expression, evaluate it, and return the result." }, -+ -+ { "post_event", gdbpy_post_event, METH_VARARGS, -+ "Post an event into gdb's event loop." }, -+ - { "write", gdbpy_write, METH_VARARGS, - "Write a string using gdb's filtered stream." }, - { "flush", gdbpy_flush, METH_NOARGS, -diff --git a/gdb/python/python.h b/gdb/python/python.h -index e970180..bbb6184 100644 ---- a/gdb/python/python.h -+++ b/gdb/python/python.h -@@ -24,6 +24,10 @@ - - void eval_python_from_control_command (struct command_line *); - -+void source_python_script (FILE *stream, char *file); -+ -+void run_python_script (int argc, char **argv); -+ - int apply_val_pretty_printer (struct type *type, const gdb_byte *valaddr, - int embedded_offset, CORE_ADDR address, - struct ui_file *stream, int recurse, -diff --git a/gdb/scm-lang.c b/gdb/scm-lang.c -index de34894..07518b0 100644 ---- a/gdb/scm-lang.c -+++ b/gdb/scm-lang.c -@@ -233,6 +233,7 @@ const struct exp_descriptor exp_descriptor_scm = - { - print_subexp_standard, - operator_length_standard, -+ operator_check_standard, - op_name_standard, - dump_subexp_body_standard, - evaluate_exp -diff --git a/gdb/scm-valprint.c b/gdb/scm-valprint.c -index cc3319a..d0d4702 100644 ---- a/gdb/scm-valprint.c -+++ b/gdb/scm-valprint.c -@@ -62,9 +62,9 @@ scm_inferior_print (struct type *type, LONGEST value, struct ui_file *stream, - { - /* XXX: Should we cache these symbols? */ - gdb_output_sym = -- lookup_symbol_global ("gdb_output", NULL, NULL, VAR_DOMAIN); -+ lookup_symbol_global ("gdb_output", NULL, VAR_DOMAIN); - gdb_output_len_sym = -- lookup_symbol_global ("gdb_output_length", NULL, NULL, VAR_DOMAIN); -+ lookup_symbol_global ("gdb_output_length", NULL, VAR_DOMAIN); - - if ((gdb_output_sym == NULL) || (gdb_output_len_sym == NULL)) - ret = -1; -diff --git a/gdb/solib-darwin.c b/gdb/solib-darwin.c -index 8b96a6f..9428d92 100644 ---- a/gdb/solib-darwin.c -+++ b/gdb/solib-darwin.c -@@ -389,7 +389,6 @@ darwin_relocate_section_addresses (struct so_list *so, - static struct symbol * - darwin_lookup_lib_symbol (const struct objfile *objfile, - const char *name, -- const char *linkage_name, - const domain_enum domain) - { - return NULL; -diff --git a/gdb/solib-spu.c b/gdb/solib-spu.c -index 19e3212..9f06fa9 100644 ---- a/gdb/solib-spu.c -+++ b/gdb/solib-spu.c -@@ -334,16 +334,13 @@ spu_bfd_open (char *pathname) - static struct symbol * - spu_lookup_lib_symbol (const struct objfile *objfile, - const char *name, -- const char *linkage_name, - const domain_enum domain) - { - if (bfd_get_arch (objfile->obfd) == bfd_arch_spu) -- return lookup_global_symbol_from_objfile (objfile, name, linkage_name, -- domain); -+ return lookup_global_symbol_from_objfile (objfile, name, domain); - - if (svr4_so_ops.lookup_lib_global_symbol != NULL) -- return svr4_so_ops.lookup_lib_global_symbol (objfile, name, linkage_name, -- domain); -+ return svr4_so_ops.lookup_lib_global_symbol (objfile, name, domain); - return NULL; - } - -diff --git a/gdb/solib-svr4.c b/gdb/solib-svr4.c -index 6cfaa85..68aadc0 100644 ---- a/gdb/solib-svr4.c -+++ b/gdb/solib-svr4.c -@@ -1908,15 +1908,13 @@ struct target_so_ops svr4_so_ops; - static struct symbol * - elf_lookup_lib_symbol (const struct objfile *objfile, - const char *name, -- const char *linkage_name, - const domain_enum domain) - { - if (objfile->obfd == NULL - || scan_dyntag (DT_SYMBOLIC, objfile->obfd, NULL) != 1) - return NULL; - -- return lookup_global_symbol_from_objfile -- (objfile, name, linkage_name, domain); -+ return lookup_global_symbol_from_objfile (objfile, name, domain); - } - - extern initialize_file_ftype _initialize_svr4_solib; /* -Wmissing-prototypes */ -diff --git a/gdb/solib.c b/gdb/solib.c -index a2ad0c4..3574e62 100644 ---- a/gdb/solib.c -+++ b/gdb/solib.c -@@ -1127,13 +1127,12 @@ show_auto_solib_add (struct ui_file *file, int from_tty, - struct symbol * - solib_global_lookup (const struct objfile *objfile, - const char *name, -- const char *linkage_name, - const domain_enum domain) - { - struct target_so_ops *ops = solib_ops (target_gdbarch); - - if (ops->lookup_lib_global_symbol != NULL) -- return ops->lookup_lib_global_symbol (objfile, name, linkage_name, domain); -+ return ops->lookup_lib_global_symbol (objfile, name, domain); - return NULL; - } - -diff --git a/gdb/solist.h b/gdb/solist.h -index 63a6ba0..005e8f7 100644 ---- a/gdb/solist.h -+++ b/gdb/solist.h -@@ -114,7 +114,6 @@ struct target_so_ops - /* Hook for looking up global symbols in a library-specific way. */ - struct symbol * (*lookup_lib_global_symbol) (const struct objfile *objfile, - const char *name, -- const char *linkage_name, - const domain_enum domain); - - /* Given two so_list objects, one from the GDB thread list -@@ -146,7 +145,6 @@ extern struct target_so_ops *current_target_so_ops; - /* Handler for library-specific global symbol lookup in solib.c. */ - struct symbol *solib_global_lookup (const struct objfile *objfile, - const char *name, -- const char *linkage_name, - const domain_enum domain); - - #endif -diff --git a/gdb/somread.c b/gdb/somread.c -index 36a2b28..4d5bda9 100644 ---- a/gdb/somread.c -+++ b/gdb/somread.c -@@ -435,6 +435,7 @@ static struct sym_fns som_sym_fns = - som_new_init, /* sym_new_init: init anything gbl to entire symtab */ - som_symfile_init, /* sym_init: read initial info, setup for sym_read() */ - som_symfile_read, /* sym_read: read a symbol file into symtab */ -+ NULL, /* sym_read_psymbols */ - som_symfile_finish, /* sym_finish: finished with file, cleanup */ - som_symfile_offsets, /* sym_offsets: Translate ext. to int. relocation */ - default_symfile_segments, /* sym_segments: Get segment information from -diff --git a/gdb/spu-tdep.c b/gdb/spu-tdep.c -index 7e7ab9c..a014b7a 100644 ---- a/gdb/spu-tdep.c -+++ b/gdb/spu-tdep.c -@@ -1839,7 +1839,7 @@ spu_catch_start (struct objfile *objfile) - struct symbol *sym; - struct symtab_and_line sal; - -- sym = lookup_block_symbol (block, "main", NULL, VAR_DOMAIN); -+ sym = lookup_block_symbol (block, "main", VAR_DOMAIN); - if (sym) - { - fixup_symbol_section (sym, objfile); -diff --git a/gdb/stabsread.c b/gdb/stabsread.c -index e62bb15..ad6568e 100644 ---- a/gdb/stabsread.c -+++ b/gdb/stabsread.c -@@ -322,7 +322,7 @@ dbx_alloc_type (int typenums[2], struct objfile *objfile) - - if (typenums[0] == -1) - { -- return (alloc_type (objfile)); -+ return (alloc_type (objfile, NULL)); - } - - type_addr = dbx_lookup_type (typenums, objfile); -@@ -332,7 +332,7 @@ dbx_alloc_type (int typenums[2], struct objfile *objfile) - We will fill it in later if we find out how. */ - if (*type_addr == 0) - { -- *type_addr = alloc_type (objfile); -+ *type_addr = alloc_type (objfile, NULL); - } - - return (*type_addr); -diff --git a/gdb/stack.c b/gdb/stack.c -index 1c37801..594eb16 100644 ---- a/gdb/stack.c -+++ b/gdb/stack.c -@@ -1308,24 +1308,24 @@ backtrace_command_1 (char *count_exp, int show_locals, int from_tty) - else - count = -1; - -- if (info_verbose) -- { -- struct partial_symtab *ps; -- -- /* Read in symbols for all of the frames. Need to do this in a -- separate pass so that "Reading in symbols for xxx" messages -- don't screw up the appearance of the backtrace. Also if -- people have strong opinions against reading symbols for -- backtrace this may have to be an option. */ -- i = count; -- for (fi = trailing; fi != NULL && i--; fi = get_prev_frame (fi)) -- { -- QUIT; -- ps = find_pc_psymtab (get_frame_address_in_block (fi)); -- if (ps) -- PSYMTAB_TO_SYMTAB (ps); /* Force syms to come in. */ -- } -- } -+ { -+ struct partial_symtab *ps; -+ -+ /* Read in symbols for all of the frames. Need to do this -+ unconditionally to ensure that psymbols are read. Also need to -+ do this in a separate pass so that "Reading in symbols for xxx" -+ messages don't screw up the appearance of the backtrace. Also -+ if people have strong opinions against reading symbols for -+ backtrace this may have to be an option. */ -+ i = count; -+ for (fi = trailing; fi != NULL && i--; fi = get_prev_frame (fi)) -+ { -+ QUIT; -+ ps = find_pc_psymtab (get_frame_address_in_block (fi)); -+ if (info_verbose && ps) -+ PSYMTAB_TO_SYMTAB (ps); /* Force syms to come in. */ -+ } -+ } - - for (i = 0, fi = trailing; fi && count--; i++, fi = get_prev_frame (fi)) - { -@@ -1473,6 +1473,8 @@ print_block_frame_locals (struct block *b, struct frame_info *frame, - case LOC_COMPUTED: - if (SYMBOL_IS_ARGUMENT (sym)) - break; -+ if (SYMBOL_DOMAIN (sym) == COMMON_BLOCK_DOMAIN) -+ break; - values_printed = 1; - print_variable_and_value (NULL, sym, frame, stream, 4 * num_tabs); - break; -diff --git a/gdb/symfile.c b/gdb/symfile.c -index 2458201..c31b72a 100644 ---- a/gdb/symfile.c -+++ b/gdb/symfile.c -@@ -921,6 +921,17 @@ new_symfile_objfile (struct objfile *objfile, int add_flags) - clear_complaints (&symfile_complaints, 0, add_flags & SYMFILE_VERBOSE); - } - -+/* A helper function which returns true if OBJFILE has any debug -+ symbols, and false otherwise. */ -+static int -+has_any_debug_symbols (struct objfile *objfile) -+{ -+ return (objfile->psymtabs || objfile->quick_addrmap -+ || (objfile->separate_debug_objfile -+ && (objfile->separate_debug_objfile->psymtabs -+ || objfile->separate_debug_objfile->quick_addrmap))); -+} -+ - /* Process a symbol file, as either the main file or as a dynamically - loaded file. - -@@ -958,13 +969,16 @@ symbol_file_add_with_addrs_or_offsets (bfd *abfd, - /* Give user a chance to burp if we'd be - interactively wiping out any existing symbols. */ - -- if ((have_full_symbols () || have_partial_symbols ()) -- && (add_flags & SYMFILE_MAINLINE) -+ if ((add_flags & SYMFILE_MAINLINE) -+ && (have_full_symbols () || have_partial_symbols ()) - && from_tty -+ && (have_full_symbols () || have_partial_symbols ()) - && !query (_("Load new symbol table from \"%s\"? "), name)) - error (_("Not confirmed.")); - - objfile = allocate_objfile (abfd, flags); -+ if (add_flags & SYMFILE_MAINLINE) -+ objfile->flags |= OBJF_MAIN; - discard_cleanups (my_cleanups); - - if (addrs) -@@ -997,6 +1011,8 @@ symbol_file_add_with_addrs_or_offsets (bfd *abfd, - - if ((flags & OBJF_READNOW) || readnow_symbol_files) - { -+ require_partial_symbols (objfile); -+ - if (from_tty || info_verbose) - { - printf_unfiltered (_("expanding to full symbols...")); -@@ -1015,7 +1031,7 @@ symbol_file_add_with_addrs_or_offsets (bfd *abfd, - /* If the file has its own symbol tables it has no separate debug info. - `.dynsym'/`.symtab' go to MSYMBOLS, `.debug_info' goes to SYMTABS/PSYMTABS. - `.gnu_debuglink' may no longer be present with `.note.gnu.build-id'. */ -- if (objfile->psymtabs == NULL) -+ if (!has_any_debug_symbols (objfile)) - debugfile = find_separate_debug_file (objfile); - if (debugfile) - { -@@ -1039,9 +1055,10 @@ symbol_file_add_with_addrs_or_offsets (bfd *abfd, - xfree (debugfile); - } - -+ /* has_any_debug_symbols is not fully compatible with the former calls which -+ would just be needlessly expensive here. */ - if ((from_tty || info_verbose) -- && !objfile_has_partial_symbols (objfile) -- && !objfile_has_full_symbols (objfile)) -+ && !has_any_debug_symbols (objfile)) - { - wrap_here (""); - printf_unfiltered (_("(no debugging symbols found)...")); -@@ -2422,14 +2439,15 @@ reread_symbols (void) - zero is OK since dbxread.c also does what it needs to do if - objfile->global_psymbols.size is 0. */ - (*objfile->sf->sym_read) (objfile, 0); -- if (!objfile_has_partial_symbols (objfile) -- && !objfile_has_full_symbols (objfile)) -+ if (!has_any_debug_symbols (objfile)) - { - wrap_here (""); - printf_unfiltered (_("(no debugging symbols found)\n")); - wrap_here (""); - } - -+ objfile->flags &= ~OBJF_SYMTABS_READ; -+ - /* We're done reading the symbol file; finish off complaints. */ - clear_complaints (&symfile_complaints, 0, 1); - -@@ -2727,7 +2745,7 @@ allocate_symtab (char *filename, struct objfile *objfile) - } - - struct partial_symtab * --allocate_psymtab (char *filename, struct objfile *objfile) -+allocate_psymtab (const char *filename, struct objfile *objfile) - { - struct partial_symtab *psymtab; - -@@ -3041,7 +3059,8 @@ again2: - - struct partial_symtab * - start_psymtab_common (struct objfile *objfile, -- struct section_offsets *section_offsets, char *filename, -+ struct section_offsets *section_offsets, -+ const char *filename, - CORE_ADDR textlow, struct partial_symbol **global_syms, - struct partial_symbol **static_syms) - { -diff --git a/gdb/symfile.h b/gdb/symfile.h -index 8c9249c..bf9d9e7 100644 ---- a/gdb/symfile.h -+++ b/gdb/symfile.h -@@ -140,6 +140,12 @@ struct sym_fns - - void (*sym_read) (struct objfile *, int); - -+ /* Read the partial symbols for an objfile. This may be NULL, in -+ which case gdb assumes that sym_read already read the partial -+ symbols. */ -+ -+ void (*sym_read_psymbols) (struct objfile *); -+ - /* Called when we are finished with an objfile. Should do all - cleanup that is specific to the object file format for the - particular objfile. */ -@@ -266,7 +272,7 @@ extern void free_section_addr_info (struct section_addr_info *); - - extern struct partial_symtab *start_psymtab_common (struct objfile *, - struct section_offsets *, -- char *, CORE_ADDR, -+ const char *, CORE_ADDR, - struct partial_symbol **, - struct partial_symbol **); - -@@ -309,7 +315,7 @@ extern int auto_solib_limit; - - extern void set_initial_language (void); - --extern struct partial_symtab *allocate_psymtab (char *, struct objfile *); -+extern struct partial_symtab *allocate_psymtab (const char *, struct objfile *); - - extern void discard_psymtab (struct partial_symtab *); - -@@ -378,7 +384,7 @@ void free_symfile_segment_data (struct symfile_segment_data *data); - /* From dwarf2read.c */ - - extern int dwarf2_has_info (struct objfile *); -- -+extern void dwarf2_create_quick_addrmap (struct objfile *); - extern void dwarf2_build_psymtabs (struct objfile *, int); - extern void dwarf2_build_frame_info (struct objfile *); - -diff --git a/gdb/symmisc.c b/gdb/symmisc.c -index eb35369..dfd8c8c 100644 ---- a/gdb/symmisc.c -+++ b/gdb/symmisc.c -@@ -1128,7 +1128,7 @@ maintenance_check_symtabs (char *ignore, int from_tty) - while (length--) - { - sym = lookup_block_symbol (b, SYMBOL_LINKAGE_NAME (*psym), -- NULL, SYMBOL_DOMAIN (*psym)); -+ SYMBOL_DOMAIN (*psym)); - if (!sym) - { - printf_filtered ("Static symbol `"); -@@ -1145,7 +1145,7 @@ maintenance_check_symtabs (char *ignore, int from_tty) - while (length--) - { - sym = lookup_block_symbol (b, SYMBOL_LINKAGE_NAME (*psym), -- NULL, SYMBOL_DOMAIN (*psym)); -+ SYMBOL_DOMAIN (*psym)); - if (!sym) - { - printf_filtered ("Global symbol `"); -diff --git a/gdb/symtab.c b/gdb/symtab.c -index 8d9d72c..82e0163 100644 ---- a/gdb/symtab.c -+++ b/gdb/symtab.c -@@ -42,6 +42,7 @@ - #include "ada-lang.h" - #include "p-lang.h" - #include "addrmap.h" -+#include "cp-support.h" - - #include "hashtab.h" - -@@ -85,7 +86,6 @@ static int find_line_common (struct linetable *, int, int *); - char *operator_chars (char *p, char **end); - - static struct symbol *lookup_symbol_aux (const char *name, -- const char *linkage_name, - const struct block *block, - const domain_enum domain, - enum language language, -@@ -93,20 +93,19 @@ static struct symbol *lookup_symbol_aux (const char *name, - - static - struct symbol *lookup_symbol_aux_local (const char *name, -- const char *linkage_name, - const struct block *block, -- const domain_enum domain); -+ const domain_enum domain, -+ enum language language, -+ int *is_a_field_of_this); - - static - struct symbol *lookup_symbol_aux_symtabs (int block_index, - const char *name, -- const char *linkage_name, - const domain_enum domain); - - static - struct symbol *lookup_symbol_aux_psymtabs (int block_index, - const char *name, -- const char *linkage_name, - const domain_enum domain); - - static int file_matches (char *, char **, int); -@@ -271,7 +270,7 @@ lookup_partial_symtab (const char *name) - make_cleanup (xfree, real_path); - } - -- ALL_PSYMTABS (objfile, pst) -+ ALL_PSYMTABS_REQUIRED (objfile, pst) - { - if (FILENAME_CMP (name, pst->filename) == 0) - { -@@ -414,7 +413,8 @@ symbol_init_language_specific (struct general_symbol_info *gsymbol, - gsymbol->language = language; - if (gsymbol->language == language_cplus - || gsymbol->language == language_java -- || gsymbol->language == language_objc) -+ || gsymbol->language == language_objc -+ || gsymbol->language == language_fortran) - { - gsymbol->language_specific.cplus_specific.demangled_name = NULL; - } -@@ -474,7 +474,7 @@ symbol_find_demangled_name (struct general_symbol_info *gsymbol, - || gsymbol->language == language_auto) - { - demangled = -- cplus_demangle (mangled, DMGL_PARAMS | DMGL_ANSI); -+ cplus_demangle (mangled, DMGL_PARAMS | DMGL_ANSI | DMGL_VERBOSE); - if (demangled != NULL) - { - gsymbol->language = language_cplus; -@@ -633,6 +633,7 @@ symbol_natural_name (const struct general_symbol_info *gsymbol) - case language_cplus: - case language_java: - case language_objc: -+ case language_fortran: - if (gsymbol->language_specific.cplus_specific.demangled_name != NULL) - return gsymbol->language_specific.cplus_specific.demangled_name; - break; -@@ -658,6 +659,7 @@ symbol_demangled_name (const struct general_symbol_info *gsymbol) - case language_cplus: - case language_java: - case language_objc: -+ case language_fortran: - if (gsymbol->language_specific.cplus_specific.demangled_name != NULL) - return gsymbol->language_specific.cplus_specific.demangled_name; - break; -@@ -868,7 +870,13 @@ find_pc_sect_psymtab (CORE_ADDR pc, struct obj_section *section) - than the later used TEXTLOW/TEXTHIGH one. */ - - ALL_OBJFILES (objfile) -- if (objfile->psymtabs_addrmap != NULL) -+ { -+ if (objfile->quick_addrmap) -+ { -+ if (!addrmap_find (objfile->quick_addrmap, pc)) -+ continue; -+ } -+ if (require_partial_symbols (objfile)->psymtabs_addrmap != NULL) - { - struct partial_symtab *pst; - -@@ -901,6 +909,7 @@ find_pc_sect_psymtab (CORE_ADDR pc, struct obj_section *section) - return pst; - } - } -+ } - - /* Existing PSYMTABS_ADDRMAP mapping is present even for PARTIAL_SYMTABs - which still have no corresponding full SYMTABs read. But it is not -@@ -1168,6 +1177,22 @@ fixup_psymbol_section (struct partial_symbol *psym, struct objfile *objfile) - return psym; - } - -+/* Ensure that the partial symbols for OBJFILE have been loaded. This -+ function always returns its argument, as a convenience. */ -+ -+struct objfile * -+require_partial_symbols (struct objfile *objfile) -+{ -+ if ((objfile->flags & OBJF_SYMTABS_READ) == 0) -+ { -+ objfile->flags |= OBJF_SYMTABS_READ; -+ -+ if (objfile->sf->sym_read_psymbols) -+ (*objfile->sf->sym_read_psymbols) (objfile); -+ } -+ return objfile; -+} -+ - /* Find the definition for a specified symbol name NAME - in domain DOMAIN, visible from lexical block BLOCK. - Returns the struct symbol pointer, or zero if no symbol is found. -@@ -1194,10 +1219,14 @@ lookup_symbol_in_language (const char *name, const struct block *block, - { - char *demangled_name = NULL; - const char *modified_name = NULL; -- const char *mangled_name = NULL; - struct symbol *returnval; - struct cleanup *cleanup = make_cleanup (null_cleanup, 0); - -+ if(strncmp(name, "::", 2) == 0){/* this must be a global name */ -+ name = name+2; -+ block = NULL; -+ } -+ - modified_name = name; - - /* If we are using C++ or Java, demangle the name before doing a lookup, so -@@ -1207,7 +1236,6 @@ lookup_symbol_in_language (const char *name, const struct block *block, - demangled_name = cplus_demangle (name, DMGL_ANSI | DMGL_PARAMS); - if (demangled_name) - { -- mangled_name = name; - modified_name = demangled_name; - make_cleanup (xfree, demangled_name); - } -@@ -1229,7 +1257,6 @@ lookup_symbol_in_language (const char *name, const struct block *block, - DMGL_ANSI | DMGL_PARAMS | DMGL_JAVA); - if (demangled_name) - { -- mangled_name = name; - modified_name = demangled_name; - make_cleanup (xfree, demangled_name); - } -@@ -1248,8 +1275,8 @@ lookup_symbol_in_language (const char *name, const struct block *block, - modified_name = copy; - } - -- returnval = lookup_symbol_aux (modified_name, mangled_name, block, -- domain, lang, is_a_field_of_this); -+ returnval = lookup_symbol_aux (modified_name, block, domain, lang, -+ is_a_field_of_this); - do_cleanups (cleanup); - - return returnval; -@@ -1273,9 +1300,9 @@ lookup_symbol (const char *name, const struct block *block, - well. */ - - static struct symbol * --lookup_symbol_aux (const char *name, const char *linkage_name, -- const struct block *block, const domain_enum domain, -- enum language language, int *is_a_field_of_this) -+lookup_symbol_aux (const char *name, const struct block *block, -+ const domain_enum domain, enum language language, -+ int *is_a_field_of_this) - { - struct symbol *sym; - const struct language_defn *langdef; -@@ -1291,55 +1318,19 @@ lookup_symbol_aux (const char *name, const char *linkage_name, - /* Search specified block and its superiors. Don't search - STATIC_BLOCK or GLOBAL_BLOCK. */ - -- sym = lookup_symbol_aux_local (name, linkage_name, block, domain); -+ sym = lookup_symbol_aux_local (name, block, domain, language, is_a_field_of_this); - if (sym != NULL) - return sym; - -- /* If requested to do so by the caller and if appropriate for LANGUAGE, -- check to see if NAME is a field of `this'. */ -- -- langdef = language_def (language); -- -- if (langdef->la_name_of_this != NULL && is_a_field_of_this != NULL -- && block != NULL) -- { -- struct symbol *sym = NULL; -- /* 'this' is only defined in the function's block, so find the -- enclosing function block. */ -- for (; block && !BLOCK_FUNCTION (block); -- block = BLOCK_SUPERBLOCK (block)); -- -- if (block && !dict_empty (BLOCK_DICT (block))) -- sym = lookup_block_symbol (block, langdef->la_name_of_this, -- NULL, VAR_DOMAIN); -- if (sym) -- { -- struct type *t = sym->type; -- -- /* I'm not really sure that type of this can ever -- be typedefed; just be safe. */ -- CHECK_TYPEDEF (t); -- if (TYPE_CODE (t) == TYPE_CODE_PTR -- || TYPE_CODE (t) == TYPE_CODE_REF) -- t = TYPE_TARGET_TYPE (t); -- -- if (TYPE_CODE (t) != TYPE_CODE_STRUCT -- && TYPE_CODE (t) != TYPE_CODE_UNION) -- error (_("Internal error: `%s' is not an aggregate"), -- langdef->la_name_of_this); -- -- if (check_field (t, name)) -- { -- *is_a_field_of_this = 1; -- return NULL; -- } -- } -- } -+ /* this symbol was found to be a member variable -+ do not perform the global search. */ -+ if (is_a_field_of_this && *is_a_field_of_this) -+ return NULL; - - /* Now do whatever is appropriate for LANGUAGE to look - up static and global variables. */ -- -- sym = langdef->la_lookup_symbol_nonlocal (name, linkage_name, block, domain); -+ langdef = language_def (language); -+ sym = langdef->la_lookup_symbol_nonlocal (name, block, domain); - if (sym != NULL) - return sym; - -@@ -1349,11 +1340,11 @@ lookup_symbol_aux (const char *name, const char *linkage_name, - desired name as a file-level static, then do psymtab-to-symtab - conversion on the fly and return the found symbol. */ - -- sym = lookup_symbol_aux_symtabs (STATIC_BLOCK, name, linkage_name, domain); -+ sym = lookup_symbol_aux_symtabs (STATIC_BLOCK, name, domain); - if (sym != NULL) - return sym; - -- sym = lookup_symbol_aux_psymtabs (STATIC_BLOCK, name, linkage_name, domain); -+ sym = lookup_symbol_aux_psymtabs (STATIC_BLOCK, name, domain); - if (sym != NULL) - return sym; - -@@ -1364,30 +1355,81 @@ lookup_symbol_aux (const char *name, const char *linkage_name, - Don't search STATIC_BLOCK or GLOBAL_BLOCK. */ - - static struct symbol * --lookup_symbol_aux_local (const char *name, const char *linkage_name, -- const struct block *block, -- const domain_enum domain) -+lookup_symbol_aux_local (const char *name, const struct block *block, -+ const domain_enum domain, enum language language, -+ int *is_a_field_of_this) - { - struct symbol *sym; -- const struct block *static_block = block_static_block (block); -+ const struct block *global_block = block_global_block (block); -+ const struct block *block_iterator = block; -+ const struct language_defn *langdef; -+ -+ langdef = language_def (language); - - /* Check if either no block is specified or it's a global block. */ - -- if (static_block == NULL) -+ if (global_block == NULL) - return NULL; - -- while (block != static_block) -+ while (block_iterator != global_block) - { -- sym = lookup_symbol_aux_block (name, linkage_name, block, domain); -+ -+ sym = lookup_symbol_aux_block (name, block_iterator, domain); -+ - if (sym != NULL) - return sym; -- -- if (BLOCK_FUNCTION (block) != NULL && block_inlined_p (block)) -- break; -- block = BLOCK_SUPERBLOCK (block); -+ -+ if (language == language_cplus ) -+ { -+ sym = cp_lookup_symbol_imports (block_scope (block_iterator), name, -+ block_iterator, domain, 1, 1); -+ -+ if (sym != NULL) -+ return sym; -+ } -+ -+ if (langdef->la_name_of_this != NULL && is_a_field_of_this != NULL -+ && BLOCK_FUNCTION (block_iterator)) -+ { -+ if (!dict_empty (BLOCK_DICT (block_iterator))) -+ { -+ sym = lookup_block_symbol (block_iterator, -+ langdef->la_name_of_this, -+ VAR_DOMAIN); -+ -+ -+ if (sym) -+ { -+ struct type *t = sym->type; -+ -+ /* I'm not really sure that type of this can ever -+ be typedefed; just be safe. */ -+ CHECK_TYPEDEF (t); -+ if (TYPE_CODE (t) == TYPE_CODE_PTR -+ || TYPE_CODE (t) == TYPE_CODE_REF) -+ t = TYPE_TARGET_TYPE (t); -+ -+ if (TYPE_CODE (t) != TYPE_CODE_STRUCT -+ && TYPE_CODE (t) != TYPE_CODE_UNION) -+ error (_("Internal error: `%s' is not an aggregate"), -+ langdef->la_name_of_this); -+ -+ if (check_field (t, name)) -+ { -+ *is_a_field_of_this = 1; -+ return NULL; -+ } -+ } -+ } -+ } -+ -+ if (BLOCK_FUNCTION (block_iterator) != NULL && block_inlined_p (block_iterator)) -+ break; -+ -+ block_iterator = BLOCK_SUPERBLOCK (block_iterator); - } - -- /* We've reached the edge of the function without finding a result. */ -+ /* We've reached the global block without finding a result. */ - - return NULL; - } -@@ -1416,13 +1458,12 @@ lookup_objfile_from_block (const struct block *block) - block_found appropriately. */ - - struct symbol * --lookup_symbol_aux_block (const char *name, const char *linkage_name, -- const struct block *block, -+lookup_symbol_aux_block (const char *name, const struct block *block, - const domain_enum domain) - { - struct symbol *sym; - -- sym = lookup_block_symbol (block, name, linkage_name, domain); -+ sym = lookup_block_symbol (block, name, domain); - if (sym) - { - block_found = block; -@@ -1438,7 +1479,6 @@ lookup_symbol_aux_block (const char *name, const char *linkage_name, - struct symbol * - lookup_global_symbol_from_objfile (const struct objfile *objfile, - const char *name, -- const char *linkage_name, - const domain_enum domain) - { - struct symbol *sym; -@@ -1452,7 +1492,7 @@ lookup_global_symbol_from_objfile (const struct objfile *objfile, - { - bv = BLOCKVECTOR (s); - block = BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK); -- sym = lookup_block_symbol (block, name, linkage_name, domain); -+ sym = lookup_block_symbol (block, name, domain); - if (sym) - { - block_found = block; -@@ -1461,23 +1501,23 @@ lookup_global_symbol_from_objfile (const struct objfile *objfile, - } - - /* Now go through psymtabs. */ -+ require_partial_symbols ((struct objfile *) objfile); - ALL_OBJFILE_PSYMTABS (objfile, ps) - { - if (!ps->readin -- && lookup_partial_symbol (ps, name, linkage_name, -- 1, domain)) -+ && lookup_partial_symbol (ps, name, 1, domain)) - { - s = PSYMTAB_TO_SYMTAB (ps); - bv = BLOCKVECTOR (s); - block = BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK); -- sym = lookup_block_symbol (block, name, linkage_name, domain); -+ sym = lookup_block_symbol (block, name, domain); - return fixup_symbol_section (sym, (struct objfile *)objfile); - } - } - - if (objfile->separate_debug_objfile) - return lookup_global_symbol_from_objfile (objfile->separate_debug_objfile, -- name, linkage_name, domain); -+ name, domain); - - return NULL; - } -@@ -1488,8 +1528,7 @@ lookup_global_symbol_from_objfile (const struct objfile *objfile, - static symbols. */ - - static struct symbol * --lookup_symbol_aux_symtabs (int block_index, -- const char *name, const char *linkage_name, -+lookup_symbol_aux_symtabs (int block_index, const char *name, - const domain_enum domain) - { - struct symbol *sym; -@@ -1502,7 +1541,7 @@ lookup_symbol_aux_symtabs (int block_index, - { - bv = BLOCKVECTOR (s); - block = BLOCKVECTOR_BLOCK (bv, block_index); -- sym = lookup_block_symbol (block, name, linkage_name, domain); -+ sym = lookup_block_symbol (block, name, domain); - if (sym) - { - block_found = block; -@@ -1520,7 +1559,6 @@ lookup_symbol_aux_symtabs (int block_index, - - static struct symbol * - lookup_symbol_aux_psymtabs (int block_index, const char *name, -- const char *linkage_name, - const domain_enum domain) - { - struct symbol *sym; -@@ -1531,16 +1569,15 @@ lookup_symbol_aux_psymtabs (int block_index, const char *name, - struct symtab *s; - const int psymtab_index = (block_index == GLOBAL_BLOCK ? 1 : 0); - -- ALL_PSYMTABS (objfile, ps) -+ ALL_PSYMTABS_REQUIRED (objfile, ps) - { - if (!ps->readin -- && lookup_partial_symbol (ps, name, linkage_name, -- psymtab_index, domain)) -+ && lookup_partial_symbol (ps, name, psymtab_index, domain)) - { - s = PSYMTAB_TO_SYMTAB (ps); - bv = BLOCKVECTOR (s); - block = BLOCKVECTOR_BLOCK (bv, block_index); -- sym = lookup_block_symbol (block, name, linkage_name, domain); -+ sym = lookup_block_symbol (block, name, domain); - if (!sym) - { - /* This shouldn't be necessary, but as a last resort try -@@ -1557,7 +1594,7 @@ lookup_symbol_aux_psymtabs (int block_index, const char *name, - block = BLOCKVECTOR_BLOCK (bv, - block_index == GLOBAL_BLOCK ? - STATIC_BLOCK : GLOBAL_BLOCK); -- sym = lookup_block_symbol (block, name, linkage_name, domain); -+ sym = lookup_block_symbol (block, name, domain); - if (!sym) - error (_("Internal: %s symbol `%s' found in %s psymtab but not in symtab.\n%s may be an inlined function, or may be a template function\n(if a template, try specifying an instantiation: %s)."), - block_index == GLOBAL_BLOCK ? "global" : "static", -@@ -1576,7 +1613,6 @@ lookup_symbol_aux_psymtabs (int block_index, const char *name, - - struct symbol * - basic_lookup_symbol_nonlocal (const char *name, -- const char *linkage_name, - const struct block *block, - const domain_enum domain) - { -@@ -1610,11 +1646,11 @@ basic_lookup_symbol_nonlocal (const char *name, - than that one, so I don't think we should worry about that for - now. */ - -- sym = lookup_symbol_static (name, linkage_name, block, domain); -+ sym = lookup_symbol_static (name, block, domain); - if (sym != NULL) - return sym; - -- return lookup_symbol_global (name, linkage_name, block, domain); -+ return lookup_symbol_global (name, block, domain); - } - - /* Lookup a symbol in the static block associated to BLOCK, if there -@@ -1622,14 +1658,13 @@ basic_lookup_symbol_nonlocal (const char *name, - - struct symbol * - lookup_symbol_static (const char *name, -- const char *linkage_name, - const struct block *block, - const domain_enum domain) - { - const struct block *static_block = block_static_block (block); - - if (static_block != NULL) -- return lookup_symbol_aux_block (name, linkage_name, static_block, domain); -+ return lookup_symbol_aux_block (name, static_block, domain); - else - return NULL; - } -@@ -1639,7 +1674,6 @@ lookup_symbol_static (const char *name, - - struct symbol * - lookup_symbol_global (const char *name, -- const char *linkage_name, - const struct block *block, - const domain_enum domain) - { -@@ -1649,15 +1683,15 @@ lookup_symbol_global (const char *name, - /* Call library-specific lookup procedure. */ - objfile = lookup_objfile_from_block (block); - if (objfile != NULL) -- sym = solib_global_lookup (objfile, name, linkage_name, domain); -+ sym = solib_global_lookup (objfile, name, domain); - if (sym != NULL) - return sym; - -- sym = lookup_symbol_aux_symtabs (GLOBAL_BLOCK, name, linkage_name, domain); -+ sym = lookup_symbol_aux_symtabs (GLOBAL_BLOCK, name, domain); - if (sym != NULL) - return sym; - -- return lookup_symbol_aux_psymtabs (GLOBAL_BLOCK, name, linkage_name, domain); -+ return lookup_symbol_aux_psymtabs (GLOBAL_BLOCK, name, domain); - } - - int -@@ -1681,14 +1715,11 @@ symbol_matches_domain (enum language symbol_language, - } - - /* Look, in partial_symtab PST, for symbol whose natural name is NAME. -- If LINKAGE_NAME is non-NULL, check in addition that the symbol's -- linkage name matches it. Check the global symbols if GLOBAL, the -- static symbols if not */ -+ Check the global symbols if GLOBAL, the static symbols if not. */ - - struct partial_symbol * - lookup_partial_symbol (struct partial_symtab *pst, const char *name, -- const char *linkage_name, int global, -- domain_enum domain) -+ int global, domain_enum domain) - { - struct partial_symbol *temp; - struct partial_symbol **start, **psym; -@@ -1740,9 +1771,7 @@ lookup_partial_symbol (struct partial_symtab *pst, const char *name, - internal_error (__FILE__, __LINE__, _("failed internal consistency check")); - - while (top <= real_top -- && (linkage_name != NULL -- ? strcmp (SYMBOL_LINKAGE_NAME (*top), linkage_name) == 0 -- : SYMBOL_MATCHES_SEARCH_NAME (*top,name))) -+ && SYMBOL_MATCHES_SEARCH_NAME (*top, name)) - { - if (symbol_matches_domain (SYMBOL_LANGUAGE (*top), - SYMBOL_DOMAIN (*top), domain)) -@@ -1759,15 +1788,9 @@ lookup_partial_symbol (struct partial_symtab *pst, const char *name, - for (psym = start; psym < start + length; psym++) - { - if (symbol_matches_domain (SYMBOL_LANGUAGE (*psym), -- SYMBOL_DOMAIN (*psym), domain)) -- { -- if (linkage_name != NULL -- ? strcmp (SYMBOL_LINKAGE_NAME (*psym), linkage_name) == 0 -- : SYMBOL_MATCHES_SEARCH_NAME (*psym, name)) -- { -- return (*psym); -- } -- } -+ SYMBOL_DOMAIN (*psym), domain) -+ && SYMBOL_MATCHES_SEARCH_NAME (*psym, name)) -+ return (*psym); - } - } - -@@ -1809,22 +1832,25 @@ basic_lookup_transparent_type (const char *name) - { - bv = BLOCKVECTOR (s); - block = BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK); -- sym = lookup_block_symbol (block, name, NULL, STRUCT_DOMAIN); -+ sym = lookup_block_symbol (block, name, STRUCT_DOMAIN); - if (sym && !TYPE_IS_OPAQUE (SYMBOL_TYPE (sym))) - { - return SYMBOL_TYPE (sym); - } - } - -- ALL_PSYMTABS (objfile, ps) -+ /* FIXME: .debug_pubnames should be read in. -+ -+ One may also try to the first pass without the require_partial_symbols -+ call but that would behave nondeterministically. */ -+ ALL_PSYMTABS_REQUIRED (objfile, ps) - { -- if (!ps->readin && lookup_partial_symbol (ps, name, NULL, -- 1, STRUCT_DOMAIN)) -+ if (!ps->readin && lookup_partial_symbol (ps, name, 1, STRUCT_DOMAIN)) - { - s = PSYMTAB_TO_SYMTAB (ps); - bv = BLOCKVECTOR (s); - block = BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK); -- sym = lookup_block_symbol (block, name, NULL, STRUCT_DOMAIN); -+ sym = lookup_block_symbol (block, name, STRUCT_DOMAIN); - if (!sym) - { - /* This shouldn't be necessary, but as a last resort -@@ -1833,7 +1859,7 @@ basic_lookup_transparent_type (const char *name) - * the psymtab gets it wrong in some cases. - */ - block = BLOCKVECTOR_BLOCK (bv, STATIC_BLOCK); -- sym = lookup_block_symbol (block, name, NULL, STRUCT_DOMAIN); -+ sym = lookup_block_symbol (block, name, STRUCT_DOMAIN); - if (!sym) - error (_("Internal: global symbol `%s' found in %s psymtab but not in symtab.\n\ - %s may be an inlined function, or may be a template function\n\ -@@ -1857,21 +1883,26 @@ basic_lookup_transparent_type (const char *name) - { - bv = BLOCKVECTOR (s); - block = BLOCKVECTOR_BLOCK (bv, STATIC_BLOCK); -- sym = lookup_block_symbol (block, name, NULL, STRUCT_DOMAIN); -+ sym = lookup_block_symbol (block, name, STRUCT_DOMAIN); - if (sym && !TYPE_IS_OPAQUE (SYMBOL_TYPE (sym))) - { - return SYMBOL_TYPE (sym); - } - } - -- ALL_PSYMTABS (objfile, ps) -+ /* FIXME: Something like .debug_pubnames containing also static symbols -+ should be read in. Compiler needs to be taught to generate it first. -+ -+ One may also try to the first pass without the require_partial_symbols -+ call but that would behave nondeterministically. */ -+ ALL_PSYMTABS_REQUIRED (objfile, ps) - { -- if (!ps->readin && lookup_partial_symbol (ps, name, NULL, 0, STRUCT_DOMAIN)) -+ if (!ps->readin && lookup_partial_symbol (ps, name, 0, STRUCT_DOMAIN)) - { - s = PSYMTAB_TO_SYMTAB (ps); - bv = BLOCKVECTOR (s); - block = BLOCKVECTOR_BLOCK (bv, STATIC_BLOCK); -- sym = lookup_block_symbol (block, name, NULL, STRUCT_DOMAIN); -+ sym = lookup_block_symbol (block, name, STRUCT_DOMAIN); - if (!sym) - { - /* This shouldn't be necessary, but as a last resort -@@ -1880,7 +1911,7 @@ basic_lookup_transparent_type (const char *name) - * the psymtab gets it wrong in some cases. - */ - block = BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK); -- sym = lookup_block_symbol (block, name, NULL, STRUCT_DOMAIN); -+ sym = lookup_block_symbol (block, name, STRUCT_DOMAIN); - if (!sym) - error (_("Internal: static symbol `%s' found in %s psymtab but not in symtab.\n\ - %s may be an inlined function, or may be a template function\n\ -@@ -1905,9 +1936,23 @@ find_main_psymtab (void) - struct partial_symtab *pst; - struct objfile *objfile; - -- ALL_PSYMTABS (objfile, pst) -+ ALL_OBJFILES (objfile) -+ { -+ if ((objfile->flags & OBJF_MAIN) == 0) -+ continue; -+ require_partial_symbols (objfile); -+ ALL_OBJFILE_PSYMTABS (objfile, pst) -+ { -+ if (lookup_partial_symbol (pst, main_name (), 1, VAR_DOMAIN)) -+ { -+ return pst; -+ } -+ } -+ } -+ -+ ALL_PSYMTABS_REQUIRED (objfile, pst) - { -- if (lookup_partial_symbol (pst, main_name (), NULL, 1, VAR_DOMAIN)) -+ if (lookup_partial_symbol (pst, main_name (), 1, VAR_DOMAIN)) - { - return (pst); - } -@@ -1925,14 +1970,10 @@ find_main_psymtab (void) - search on the symbols. Each symbol which is marked as being a ObjC/C++ - symbol (language_cplus or language_objc set) has both the encoded and - non-encoded names tested for a match. -- -- If LINKAGE_NAME is non-NULL, verify that any symbol we find has this -- particular mangled name. - */ - - struct symbol * - lookup_block_symbol (const struct block *block, const char *name, -- const char *linkage_name, - const domain_enum domain) - { - struct dict_iterator iter; -@@ -1945,9 +1986,7 @@ lookup_block_symbol (const struct block *block, const char *name, - sym = dict_iter_name_next (name, &iter)) - { - if (symbol_matches_domain (SYMBOL_LANGUAGE (sym), -- SYMBOL_DOMAIN (sym), domain) -- && (linkage_name != NULL -- ? strcmp (SYMBOL_LINKAGE_NAME (sym), linkage_name) == 0 : 1)) -+ SYMBOL_DOMAIN (sym), domain)) - return sym; - } - return NULL; -@@ -1967,9 +2006,7 @@ lookup_block_symbol (const struct block *block, const char *name, - sym = dict_iter_name_next (name, &iter)) - { - if (symbol_matches_domain (SYMBOL_LANGUAGE (sym), -- SYMBOL_DOMAIN (sym), domain) -- && (linkage_name != NULL -- ? strcmp (SYMBOL_LINKAGE_NAME (sym), linkage_name) == 0 : 1)) -+ SYMBOL_DOMAIN (sym), domain)) - { - sym_found = sym; - if (!SYMBOL_IS_ARGUMENT (sym)) -@@ -3172,7 +3209,7 @@ search_symbols (char *regexp, domain_enum kind, int nfiles, char *files[], - matching the regexp. That way we don't have to reproduce all of - the machinery below. */ - -- ALL_PSYMTABS (objfile, ps) -+ ALL_PSYMTABS_REQUIRED (objfile, ps) - { - struct partial_symbol **bound, **gbound, **sbound; - int keep_going = 1; -diff --git a/gdb/symtab.h b/gdb/symtab.h -index 740d4e0..461ff95 100644 ---- a/gdb/symtab.h -+++ b/gdb/symtab.h -@@ -171,9 +171,6 @@ extern CORE_ADDR symbol_overlayed_address (CORE_ADDR, struct obj_section *); - #define SYMBOL_SECTION(symbol) (symbol)->ginfo.section - #define SYMBOL_OBJ_SECTION(symbol) (symbol)->ginfo.obj_section - --#define SYMBOL_CPLUS_DEMANGLED_NAME(symbol) \ -- (symbol)->ginfo.language_specific.cplus_specific.demangled_name -- - /* Initializes the language dependent portion of a symbol - depending upon the language for the symbol. */ - #define SYMBOL_INIT_LANGUAGE_SPECIFIC(symbol,language) \ -@@ -394,7 +391,13 @@ typedef enum domain_enum_tag - FUNCTIONS_DOMAIN, - - /* All defined types */ -- TYPES_DOMAIN -+ TYPES_DOMAIN, -+ -+ /* Fortran common blocks. Their naming must be separate from VAR_DOMAIN. */ -+ COMMON_BLOCK_DOMAIN, -+ -+ /* Fortran module. Their naming must be separate. */ -+ MODULE_DOMAIN - } - domain_enum; - -@@ -990,7 +993,6 @@ extern struct symbol *lookup_symbol (const char *, const struct block *, - that can't think of anything better to do. */ - - extern struct symbol *basic_lookup_symbol_nonlocal (const char *, -- const char *, - const struct block *, - const domain_enum); - -@@ -1001,7 +1003,6 @@ extern struct symbol *basic_lookup_symbol_nonlocal (const char *, - is one; do nothing if BLOCK is NULL or a global block. */ - - extern struct symbol *lookup_symbol_static (const char *name, -- const char *linkage_name, - const struct block *block, - const domain_enum domain); - -@@ -1009,7 +1010,6 @@ extern struct symbol *lookup_symbol_static (const char *name, - necessary). */ - - extern struct symbol *lookup_symbol_global (const char *name, -- const char *linkage_name, - const struct block *block, - const domain_enum domain); - -@@ -1018,21 +1018,18 @@ extern struct symbol *lookup_symbol_global (const char *name, - will fix up the symbol if necessary. */ - - extern struct symbol *lookup_symbol_aux_block (const char *name, -- const char *linkage_name, - const struct block *block, - const domain_enum domain); - - /* Lookup a partial symbol. */ - - extern struct partial_symbol *lookup_partial_symbol (struct partial_symtab *, -- const char *, - const char *, int, - domain_enum); - - /* lookup a symbol by name, within a specified block */ - - extern struct symbol *lookup_block_symbol (const struct block *, const char *, -- const char *, - const domain_enum); - - /* lookup a [struct, union, enum] by name, within a specified block */ -@@ -1062,6 +1059,8 @@ extern void clear_pc_function_cache (void); - - /* from symtab.c: */ - -+struct objfile *require_partial_symbols (struct objfile *); -+ - /* lookup partial symbol table by filename */ - - extern struct partial_symtab *lookup_partial_symtab (const char *); -@@ -1356,7 +1355,6 @@ extern /*const */ char *main_name (void); - /* Check global symbols in objfile. */ - struct symbol *lookup_global_symbol_from_objfile (const struct objfile *objfile, - const char *name, -- const char *linkage_name, - const domain_enum domain); - - extern struct symtabs_and_lines -diff --git a/gdb/target.c b/gdb/target.c -index e5d14fd..37fab72 100644 ---- a/gdb/target.c -+++ b/gdb/target.c -@@ -124,6 +124,8 @@ static int debug_to_insert_watchpoint (CORE_ADDR, int, int); - - static int debug_to_remove_watchpoint (CORE_ADDR, int, int); - -+static int debug_to_detach_watchpoints (void); -+ - static int debug_to_stopped_by_watchpoint (void); - - static int debug_to_stopped_data_address (struct target_ops *, CORE_ADDR *); -@@ -622,6 +624,7 @@ update_current_target (void) - INHERIT (to_remove_hw_breakpoint, t); - INHERIT (to_insert_watchpoint, t); - INHERIT (to_remove_watchpoint, t); -+ INHERIT (to_detach_watchpoints, t); - INHERIT (to_stopped_data_address, t); - INHERIT (to_have_steppable_watchpoint, t); - INHERIT (to_have_continuable_watchpoint, t); -@@ -733,6 +736,9 @@ update_current_target (void) - de_fault (to_remove_watchpoint, - (int (*) (CORE_ADDR, int, int)) - return_minus_one); -+ de_fault (to_detach_watchpoints, -+ (int (*) (void)) -+ return_zero); - de_fault (to_stopped_by_watchpoint, - (int (*) (void)) - return_zero); -@@ -3173,6 +3179,19 @@ debug_to_remove_watchpoint (CORE_ADDR addr, int len, int type) - return retval; - } - -+static int -+debug_to_detach_watchpoints (void) -+{ -+ int retval; -+ -+ retval = debug_target.to_detach_watchpoints (); -+ -+ fprintf_unfiltered (gdb_stdlog, -+ "target_detach_watchpoints () = %ld\n", -+ (unsigned long) retval); -+ return retval; -+} -+ - static void - debug_to_terminal_init (void) - { -@@ -3420,6 +3439,7 @@ setup_target_debug (void) - current_target.to_remove_hw_breakpoint = debug_to_remove_hw_breakpoint; - current_target.to_insert_watchpoint = debug_to_insert_watchpoint; - current_target.to_remove_watchpoint = debug_to_remove_watchpoint; -+ current_target.to_detach_watchpoints = debug_to_detach_watchpoints; - current_target.to_stopped_by_watchpoint = debug_to_stopped_by_watchpoint; - current_target.to_stopped_data_address = debug_to_stopped_data_address; - current_target.to_watchpoint_addr_within_range = debug_to_watchpoint_addr_within_range; -diff --git a/gdb/target.h b/gdb/target.h -index b1cb852..3c06eba 100644 ---- a/gdb/target.h -+++ b/gdb/target.h -@@ -395,6 +395,7 @@ struct target_ops - int (*to_remove_hw_breakpoint) (struct gdbarch *, struct bp_target_info *); - int (*to_remove_watchpoint) (CORE_ADDR, int, int); - int (*to_insert_watchpoint) (CORE_ADDR, int, int); -+ int (*to_detach_watchpoints) (void); - int (*to_stopped_by_watchpoint) (void); - int to_have_steppable_watchpoint; - int to_have_continuable_watchpoint; -@@ -1124,7 +1125,7 @@ extern char *normal_pid_to_str (ptid_t ptid); - /* Hardware watchpoint interfaces. */ - - /* Returns non-zero if we were stopped by a hardware watchpoint (memory read or -- write). */ -+ write). Only the INFERIOR_PTID task is being queried. */ - - #define target_stopped_by_watchpoint \ - (*current_target.to_stopped_by_watchpoint) -@@ -1166,14 +1167,26 @@ extern char *normal_pid_to_str (ptid_t ptid); - #define target_remove_watchpoint(addr, len, type) \ - (*current_target.to_remove_watchpoint) (addr, len, type) - -+/* Clear all debug registers without affecting any register caches. Function -+ acts on INFERIOR_PTID which should be the forked-off process, either the -+ non-threaded child one or the threaded parent one, depending on `set -+ follow-fork-mode'. Both watchpoints and hardware breakpoints get removed. -+ Return 0 on success, -1 on failure. */ -+ -+#define target_detach_watchpoints() \ -+ (*current_target.to_detach_watchpoints) () -+ - #define target_insert_hw_breakpoint(gdbarch, bp_tgt) \ - (*current_target.to_insert_hw_breakpoint) (gdbarch, bp_tgt) - - #define target_remove_hw_breakpoint(gdbarch, bp_tgt) \ - (*current_target.to_remove_hw_breakpoint) (gdbarch, bp_tgt) - --#define target_stopped_data_address(target, x) \ -- (*target.to_stopped_data_address) (target, x) -+/* Return non-zero if target knows the data address which triggered this -+ target_stopped_by_watchpoint, in such case place it to *ADDR_P. Only the -+ INFERIOR_PTID task is being queried. */ -+#define target_stopped_data_address(target, addr_p) \ -+ (*target.to_stopped_data_address) (target, addr_p) - - #define target_watchpoint_addr_within_range(target, addr, start, length) \ - (*target.to_watchpoint_addr_within_range) (target, addr, start, length) -@@ -1203,6 +1216,20 @@ extern int target_search_memory (CORE_ADDR start_addr, - ULONGEST pattern_len, - CORE_ADDR *found_addrp); - -+/* Utility functions which can be used by search_memory implementations. */ -+ -+void allocate_pattern_buffer (char **pattern_bufp, char **pattern_buf_end, -+ ULONGEST *pattern_buf_size); -+ -+void increase_pattern_buffer (char **pattern_bufp, char **pattern_buf_end, -+ ULONGEST *pattern_buf_size, int val_bytes); -+ -+int search_memory (CORE_ADDR *start_addr, ULONGEST *search_space_len, -+ const char *pattern_buf, ULONGEST pattern_len, -+ CORE_ADDR *found_addr); -+ -+void put_bits (bfd_uint64_t data, char *buf, int bits, bfd_boolean big_p); -+ - /* Command logging facility. */ - - #define target_log_command(p) \ -@@ -1322,6 +1349,14 @@ extern struct target_ops *find_target_beneath (struct target_ops *); - - extern char *target_get_osdata (const char *type); - -+/* Read OS data object of type TYPE from the target, and return it in -+ XML format. The result is NUL-terminated and returned as a string, -+ allocated using xmalloc. If an error occurs or the transfer is -+ unsupported, NULL is returned. Empty objects are returned as -+ allocated but empty strings. */ -+ -+extern char *target_get_osdata (const char *type); -+ - - /* Stuff that should be shared among the various remote targets. */ - -diff --git a/gdb/testsuite/gdb.arch/powerpc-power7.exp b/gdb/testsuite/gdb.arch/powerpc-power7.exp -new file mode 100644 -index 0000000..ae301db ---- /dev/null -+++ b/gdb/testsuite/gdb.arch/powerpc-power7.exp -@@ -0,0 +1,175 @@ -+# Copyright 2009 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. -+ -+# Test PowerPC Power7 instructions disassembly. -+ -+if {![istarget "powerpc*-*-*"]} then { -+ verbose "Skipping PowerPC Power7 instructions disassembly." -+ return -+} -+ -+set testfile "powerpc-power7" -+set srcfile ${testfile}.s -+set objfile ${objdir}/${subdir}/${testfile}.o -+ -+if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${objfile}" object {debug}] != "" } { -+ untested "PowerPC Power7 instructions disassembly" -+ return -1 -+} -+ -+ -+gdb_exit -+gdb_start -+gdb_reinitialize_dir $srcdir/$subdir -+gdb_load ${objfile} -+ -+ -+# Disassemble the function. -+ -+set test "disass func" -+gdb_test_multiple $test $test { -+ -re "\r\nDump of assembler code for function func:(\r\n.*\r\n)End of assembler dump.\r\n$gdb_prompt $" { -+ set func $expect_out(1,string) -+ pass $test -+ } -+} -+ -+proc instr_to_patt {offset instr} { -+ # 0x0000000000000018 : stxvd2x vs43,r4,r5 -+ return ".*\r\n[string map {0x 0x0*} $offset] :\[ \t\]*[string map [list { } "\[ \t\]+" . {\.}] $instr]\[ \t\]*\r\n.*" -+} -+ -+# KFAIL strings would not exist if -Many would print the same as -Mpower7. -+# That means the power7 form should be the preferred one. -+# http://sourceware.org/ml/gdb-patches/2009-03/threads.html#00020 -+ -+proc func_check {offset instr {kfail ""}} { -+ global func -+ -+ set test "Found $offset: $instr" -+ if [regexp -nocase -line [instr_to_patt $offset $instr] $func] { -+ pass $test -+ } elseif {$kfail != "" && [regexp -nocase -line [instr_to_patt $offset $kfail] $func]} { -+ kfail gdb/NNNN $test -+ } else { -+ fail $test -+ } -+} -+ -+func_check 0x0 "lxvd2x vs3,r4,r5" -+func_check 0x4 "lxvd2ux vs3,r4,r5" -+func_check 0x8 "lxvd2x vs43,r4,r5" -+func_check 0xc "lxvd2ux vs43,r4,r5" -+func_check 0x10 "stxvd2x vs3,r4,r5" -+func_check 0x14 "stxvd2ux vs3,r4,r5" -+func_check 0x18 "stxvd2x vs43,r4,r5" -+func_check 0x1c "stxvd2ux vs43,r4,r5" -+func_check 0x20 "xxmrghd vs3,vs4,vs5" -+func_check 0x24 "xxmrghd vs43,vs44,vs45" -+func_check 0x28 "xxmrgld vs3,vs4,vs5" -+func_check 0x2c "xxmrgld vs43,vs44,vs45" -+func_check 0x30 "xxmrghd vs3,vs4,vs5" -+func_check 0x34 "xxmrghd vs43,vs44,vs45" -+func_check 0x38 "xxmrgld vs3,vs4,vs5" -+func_check 0x3c "xxmrgld vs43,vs44,vs45" -+func_check 0x40 "xxpermdi vs3,vs4,vs5,1" -+func_check 0x44 "xxpermdi vs43,vs44,vs45,1" -+func_check 0x48 "xxpermdi vs3,vs4,vs5,2" -+func_check 0x4c "xxpermdi vs43,vs44,vs45,2" -+func_check 0x50 "xvmovdp vs3,vs4" -+func_check 0x54 "xvmovdp vs43,vs44" -+func_check 0x58 "xvmovdp vs3,vs4" -+func_check 0x5c "xvmovdp vs43,vs44" -+func_check 0x60 "xvcpsgndp vs3,vs4,vs5" -+func_check 0x64 "xvcpsgndp vs43,vs44,vs45" -+func_check 0x68 "wait" -+func_check 0x6c "wait" -+func_check 0x70 "waitrsv" -+func_check 0x74 "waitrsv" -+func_check 0x78 "waitimpl" -+func_check 0x7c "waitimpl" -+func_check 0x80 "doze" -+func_check 0x84 "nap" -+func_check 0x88 "sleep" -+func_check 0x8c "rvwinkle" -+func_check 0x90 "prtyw r3,r4" -+func_check 0x94 "prtyd r13,r14" -+func_check 0x98 "mfcfar r10" "mfspr r10,28" -+func_check 0x9c "mtcfar r11" "mtspr 28,r11" -+func_check 0xa0 "cmpb r3,r4,r5" -+func_check 0xa4 "lwzcix r10,r11,r12" -+func_check 0xa8 "dadd f16,f17,f18" -+func_check 0xac "daddq f20,f22,f24" -+func_check 0xb0 "dss 3" -+func_check 0xb4 "dssall" -+func_check 0xb8 "dst r5,r4,1" -+func_check 0xbc "dstt r8,r7,0" -+func_check 0xc0 "dstst r5,r6,3" -+func_check 0xc4 "dststt r4,r5,2" -+func_check 0xc8 "divwe r10,r11,r12" -+func_check 0xcc "divwe. r11,r12,r13" -+func_check 0xd0 "divweo r12,r13,r14" -+func_check 0xd4 "divweo. r13,r14,r15" -+func_check 0xd8 "divweu r10,r11,r12" -+func_check 0xdc "divweu. r11,r12,r13" -+func_check 0xe0 "divweuo r12,r13,r14" -+func_check 0xe4 "divweuo. r13,r14,r15" -+func_check 0xe8 "bpermd r7,r17,r27" -+func_check 0xec "popcntw r10,r20" -+func_check 0xf0 "popcntd r10,r20" -+func_check 0xf4 "ldbrx r20,r21,r22" -+func_check 0xf8 "stdbrx r20,r21,r22" -+func_check 0xfc "lfiwzx f10,0,r10" -+func_check 0x100 "lfiwzx f10,r9,r10" -+func_check 0x104 "fcfids f4,f5" -+func_check 0x108 "fcfids. f4,f5" -+func_check 0x10c "fcfidus f4,f5" -+func_check 0x110 "fcfidus. f4,f5" -+func_check 0x114 "fctiwu f4,f5" -+func_check 0x118 "fctiwu. f4,f5" -+func_check 0x11c "fctiwuz f4,f5" -+func_check 0x120 "fctiwuz. f4,f5" -+func_check 0x124 "fctidu f4,f5" -+func_check 0x128 "fctidu. f4,f5" -+func_check 0x12c "fctiduz f4,f5" -+func_check 0x130 "fctiduz. f4,f5" -+func_check 0x134 "fcfidu f4,f5" -+func_check 0x138 "fcfidu. f4,f5" -+func_check 0x13c "ftdiv cr0,f10,f11" -+func_check 0x140 "ftdiv cr7,f10,f11" -+func_check 0x144 "ftsqrt cr0,f10" -+func_check 0x148 "ftsqrt cr7,f10" -+func_check 0x14c "dcbtt r8,r9" "dcbt 16,r8,r9" -+func_check 0x150 "dcbtstt r8,r9" "dcbtst 16,r8,r9" -+func_check 0x154 "dcffix f10,f12" -+func_check 0x158 "dcffix. f20,f22" -+func_check 0x15c "lbarx r10,r11,r12" -+func_check 0x160 "lbarx r10,r11,r12" -+func_check 0x164 "lbarx r10,r11,r12,1" -+func_check 0x168 "lharx r20,r21,r22" -+func_check 0x16c "lharx r20,r21,r22" -+func_check 0x170 "lharx r20,r21,r22,1" -+func_check 0x174 "stbcx. r10,r11,r12" -+func_check 0x178 "sthcx. r10,r11,r12" -+func_check 0x17c "fre f14,f15" -+func_check 0x180 "fre. f14,f15" -+func_check 0x184 "fres f14,f15" -+func_check 0x188 "fres. f14,f15" -+func_check 0x18c "frsqrte f14,f15" -+func_check 0x190 "frsqrte. f14,f15" -+func_check 0x194 "frsqrtes f14,f15" -+func_check 0x198 "frsqrtes. f14,f15" -+func_check 0x19c "isel r2,r3,r4,28" -diff --git a/gdb/testsuite/gdb.arch/powerpc-power7.s b/gdb/testsuite/gdb.arch/powerpc-power7.s -new file mode 100644 -index 0000000..98b2e79 ---- /dev/null -+++ b/gdb/testsuite/gdb.arch/powerpc-power7.s -@@ -0,0 +1,107 @@ -+ .text -+ .globl func -+func: -+ .long 0x7c642e98 /* 0: lxvd2x vs3,r4,r5 */ -+ .long 0x7c642ed8 /* 4: lxvd2ux vs3,r4,r5 */ -+ .long 0x7d642e99 /* 8: lxvd2x vs43,r4,r5 */ -+ .long 0x7d642ed9 /* c: lxvd2ux vs43,r4,r5 */ -+ .long 0x7c642f98 /* 10: stxvd2x vs3,r4,r5 */ -+ .long 0x7c642fd8 /* 14: stxvd2ux vs3,r4,r5 */ -+ .long 0x7d642f99 /* 18: stxvd2x vs43,r4,r5 */ -+ .long 0x7d642fd9 /* 1c: stxvd2ux vs43,r4,r5 */ -+ .long 0xf0642850 /* 20: xxmrghd vs3,vs4,vs5 */ -+ .long 0xf16c6857 /* 24: xxmrghd vs43,vs44,vs45 */ -+ .long 0xf0642b50 /* 28: xxmrgld vs3,vs4,vs5 */ -+ .long 0xf16c6b57 /* 2c: xxmrgld vs43,vs44,vs45 */ -+ .long 0xf0642850 /* 30: xxmrghd vs3,vs4,vs5 */ -+ .long 0xf16c6857 /* 34: xxmrghd vs43,vs44,vs45 */ -+ .long 0xf0642b50 /* 38: xxmrgld vs3,vs4,vs5 */ -+ .long 0xf16c6b57 /* 3c: xxmrgld vs43,vs44,vs45 */ -+ .long 0xf0642950 /* 40: xxpermdi vs3,vs4,vs5,1 */ -+ .long 0xf16c6957 /* 44: xxpermdi vs43,vs44,vs45,1 */ -+ .long 0xf0642a50 /* 48: xxpermdi vs3,vs4,vs5,2 */ -+ .long 0xf16c6a57 /* 4c: xxpermdi vs43,vs44,vs45,2 */ -+ .long 0xf0642780 /* 50: xvmovdp vs3,vs4 */ -+ .long 0xf16c6787 /* 54: xvmovdp vs43,vs44 */ -+ .long 0xf0642780 /* 58: xvmovdp vs3,vs4 */ -+ .long 0xf16c6787 /* 5c: xvmovdp vs43,vs44 */ -+ .long 0xf0642f80 /* 60: xvcpsgndp vs3,vs4,vs5 */ -+ .long 0xf16c6f87 /* 64: xvcpsgndp vs43,vs44,vs45 */ -+ .long 0x7c00007c /* 68: wait */ -+ .long 0x7c00007c /* 6c: wait */ -+ .long 0x7c20007c /* 70: waitrsv */ -+ .long 0x7c20007c /* 74: waitrsv */ -+ .long 0x7c40007c /* 78: waitimpl */ -+ .long 0x7c40007c /* 7c: waitimpl */ -+ .long 0x4c000324 /* 80: doze */ -+ .long 0x4c000364 /* 84: nap */ -+ .long 0x4c0003a4 /* 88: sleep */ -+ .long 0x4c0003e4 /* 8c: rvwinkle */ -+ .long 0x7c830134 /* 90: prtyw r3,r4 */ -+ .long 0x7dcd0174 /* 94: prtyd r13,r14 */ -+ .long 0x7d5c02a6 /* 98: mfcfar r10 */ -+ .long 0x7d7c03a6 /* 9c: mtcfar r11 */ -+ .long 0x7c832bf8 /* a0: cmpb r3,r4,r5 */ -+ .long 0x7d4b662a /* a4: lwzcix r10,r11,r12 */ -+ .long 0xee119004 /* a8: dadd f16,f17,f18 */ -+ .long 0xfe96c004 /* ac: daddq f20,f22,f24 */ -+ .long 0x7c60066c /* b0: dss 3 */ -+ .long 0x7e00066c /* b4: dssall */ -+ .long 0x7c2522ac /* b8: dst r5,r4,1 */ -+ .long 0x7e083aac /* bc: dstt r8,r7,0 */ -+ .long 0x7c6532ec /* c0: dstst r5,r6,3 */ -+ .long 0x7e442aec /* c4: dststt r4,r5,2 */ -+ .long 0x7d4b6356 /* c8: divwe r10,r11,r12 */ -+ .long 0x7d6c6b57 /* cc: divwe. r11,r12,r13 */ -+ .long 0x7d8d7756 /* d0: divweo r12,r13,r14 */ -+ .long 0x7dae7f57 /* d4: divweo. r13,r14,r15 */ -+ .long 0x7d4b6316 /* d8: divweu r10,r11,r12 */ -+ .long 0x7d6c6b17 /* dc: divweu. r11,r12,r13 */ -+ .long 0x7d8d7716 /* e0: divweuo r12,r13,r14 */ -+ .long 0x7dae7f17 /* e4: divweuo. r13,r14,r15 */ -+ .long 0x7e27d9f8 /* e8: bpermd r7,r17,r27 */ -+ .long 0x7e8a02f4 /* ec: popcntw r10,r20 */ -+ .long 0x7e8a03f4 /* f0: popcntd r10,r20 */ -+ .long 0x7e95b428 /* f4: ldbrx r20,r21,r22 */ -+ .long 0x7e95b528 /* f8: stdbrx r20,r21,r22 */ -+ .long 0x7d4056ee /* fc: lfiwzx f10,0,r10 */ -+ .long 0x7d4956ee /* 100: lfiwzx f10,r9,r10 */ -+ .long 0xec802e9c /* 104: fcfids f4,f5 */ -+ .long 0xec802e9d /* 108: fcfids. f4,f5 */ -+ .long 0xec802f9c /* 10c: fcfidus f4,f5 */ -+ .long 0xec802f9d /* 110: fcfidus. f4,f5 */ -+ .long 0xfc80291c /* 114: fctiwu f4,f5 */ -+ .long 0xfc80291d /* 118: fctiwu. f4,f5 */ -+ .long 0xfc80291e /* 11c: fctiwuz f4,f5 */ -+ .long 0xfc80291f /* 120: fctiwuz. f4,f5 */ -+ .long 0xfc802f5c /* 124: fctidu f4,f5 */ -+ .long 0xfc802f5d /* 128: fctidu. f4,f5 */ -+ .long 0xfc802f5e /* 12c: fctiduz f4,f5 */ -+ .long 0xfc802f5f /* 130: fctiduz. f4,f5 */ -+ .long 0xfc802f9c /* 134: fcfidu f4,f5 */ -+ .long 0xfc802f9d /* 138: fcfidu. f4,f5 */ -+ .long 0xfc0a5900 /* 13c: ftdiv cr0,f10,f11 */ -+ .long 0xff8a5900 /* 140: ftdiv cr7,f10,f11 */ -+ .long 0xfc005140 /* 144: ftsqrt cr0,f10 */ -+ .long 0xff805140 /* 148: ftsqrt cr7,f10 */ -+ .long 0x7e084a2c /* 14c: dcbtt r8,r9 */ -+ .long 0x7e0849ec /* 150: dcbtstt r8,r9 */ -+ .long 0xed406644 /* 154: dcffix f10,f12 */ -+ .long 0xee80b645 /* 158: dcffix. f20,f22 */ -+ .long 0x7d4b6068 /* 15c: lbarx r10,r11,r12 */ -+ .long 0x7d4b6068 /* 160: lbarx r10,r11,r12 */ -+ .long 0x7d4b6069 /* 164: lbarx r10,r11,r12,1 */ -+ .long 0x7e95b0e8 /* 168: lharx r20,r21,r22 */ -+ .long 0x7e95b0e8 /* 16c: lharx r20,r21,r22 */ -+ .long 0x7e95b0e9 /* 170: lharx r20,r21,r22,1 */ -+ .long 0x7d4b656d /* 174: stbcx. r10,r11,r12 */ -+ .long 0x7d4b65ad /* 178: sthcx. r10,r11,r12 */ -+ .long 0xfdc07830 /* 17c: fre f14,f15 */ -+ .long 0xfdc07831 /* 180: fre. f14,f15 */ -+ .long 0xedc07830 /* 184: fres f14,f15 */ -+ .long 0xedc07831 /* 188: fres. f14,f15 */ -+ .long 0xfdc07834 /* 18c: frsqrte f14,f15 */ -+ .long 0xfdc07835 /* 190: frsqrte. f14,f15 */ -+ .long 0xedc07834 /* 194: frsqrtes f14,f15 */ -+ .long 0xedc07835 /* 198: frsqrtes. f14,f15 */ -+ .long 0x7c43271e /* 19c: isel r2,r3,r4,28 */ -diff --git a/gdb/testsuite/gdb.arch/x86_64-vla-typedef-foo.S b/gdb/testsuite/gdb.arch/x86_64-vla-typedef-foo.S -new file mode 100644 -index 0000000..66f7a39 ---- /dev/null -+++ b/gdb/testsuite/gdb.arch/x86_64-vla-typedef-foo.S -@@ -0,0 +1,455 @@ -+ .file "x86_64-vla-typedef.c" -+ .section .debug_abbrev,"",@progbits -+.Ldebug_abbrev0: -+ .section .debug_info,"",@progbits -+.Ldebug_info0: -+ .section .debug_line,"",@progbits -+.Ldebug_line0: -+ .text -+.Ltext0: -+.globl foo -+ .type foo, @function -+foo: -+.LFB2: -+ .file 1 "x86_64-vla-typedef.c" -+ .loc 1 22 0 -+ pushq %rbp -+.LCFI0: -+ movq %rsp, %rbp -+.LCFI1: -+ subq $64, %rsp -+.LCFI2: -+ movl %edi, -36(%rbp) -+ .loc 1 22 0 -+ movq %rsp, %rax -+ movq %rax, -48(%rbp) -+ .loc 1 23 0 -+ movl -36(%rbp), %edx -+ movslq %edx,%rax -+ subq $1, %rax -+ movq %rax, -24(%rbp) -+ .loc 1 24 0 -+ movslq %edx,%rax -+ addq $15, %rax -+ addq $15, %rax -+ shrq $4, %rax -+ salq $4, %rax -+ subq %rax, %rsp -+ movq %rsp, -56(%rbp) -+ movq -56(%rbp), %rax -+ addq $15, %rax -+ shrq $4, %rax -+ salq $4, %rax -+ movq %rax, -56(%rbp) -+ movq -56(%rbp), %rax -+ movq %rax, -16(%rbp) -+ .loc 1 27 0 -+ movl $0, -4(%rbp) -+ jmp .L2 -+.L3: -+ .loc 1 28 0 -+ movl -4(%rbp), %esi -+ movl -4(%rbp), %eax -+ movl %eax, %ecx -+ movq -16(%rbp), %rdx -+ movslq %esi,%rax -+ movb %cl, (%rdx,%rax) -+ .loc 1 27 0 -+ addl $1, -4(%rbp) -+.L2: -+ movl -4(%rbp), %eax -+ cmpl -36(%rbp), %eax -+ jl .L3 -+ .loc 1 30 0 -+ .globl break_here -+break_here: -+ movq -16(%rbp), %rax -+ movb $0, (%rax) -+ movq -48(%rbp), %rsp -+ .loc 1 31 0 -+ leave -+ ret -+.LFE2: -+ .size foo, .-foo -+ .section .debug_frame,"",@progbits -+.Lframe0: -+ .long .LECIE0-.LSCIE0 -+.LSCIE0: -+ .long 0xffffffff -+ .byte 0x1 -+ .string "" -+ .uleb128 0x1 -+ .sleb128 -8 -+ .byte 0x10 -+ .byte 0xc -+ .uleb128 0x7 -+ .uleb128 0x8 -+ .byte 0x90 -+ .uleb128 0x1 -+ .align 8 -+.LECIE0: -+.LSFDE0: -+ .long .LEFDE0-.LASFDE0 -+.LASFDE0: -+ .long .Lframe0 -+ .quad .LFB2 -+ .quad .LFE2-.LFB2 -+ .byte 0x4 -+ .long .LCFI0-.LFB2 -+ .byte 0xe -+ .uleb128 0x10 -+ .byte 0x86 -+ .uleb128 0x2 -+ .byte 0x4 -+ .long .LCFI1-.LCFI0 -+ .byte 0xd -+ .uleb128 0x6 -+ .align 8 -+.LEFDE0: -+ .section .eh_frame,"a",@progbits -+.Lframe1: -+ .long .LECIE1-.LSCIE1 -+.LSCIE1: -+ .long 0x0 -+ .byte 0x1 -+ .string "zR" -+ .uleb128 0x1 -+ .sleb128 -8 -+ .byte 0x10 -+ .uleb128 0x1 -+ .byte 0x3 -+ .byte 0xc -+ .uleb128 0x7 -+ .uleb128 0x8 -+ .byte 0x90 -+ .uleb128 0x1 -+ .align 8 -+.LECIE1: -+.LSFDE1: -+ .long .LEFDE1-.LASFDE1 -+.LASFDE1: -+ .long .LASFDE1-.Lframe1 -+ .long .LFB2 -+ .long .LFE2-.LFB2 -+ .uleb128 0x0 -+ .byte 0x4 -+ .long .LCFI0-.LFB2 -+ .byte 0xe -+ .uleb128 0x10 -+ .byte 0x86 -+ .uleb128 0x2 -+ .byte 0x4 -+ .long .LCFI1-.LCFI0 -+ .byte 0xd -+ .uleb128 0x6 -+ .align 8 -+.LEFDE1: -+ .text -+.Letext0: -+ .section .debug_loc,"",@progbits -+.Ldebug_loc0: -+.LLST0: -+ .quad .LFB2-.Ltext0 -+ .quad .LCFI0-.Ltext0 -+ .value 0x2 -+ .byte 0x77 -+ .sleb128 8 -+ .quad .LCFI0-.Ltext0 -+ .quad .LCFI1-.Ltext0 -+ .value 0x2 -+ .byte 0x77 -+ .sleb128 16 -+ .quad .LCFI1-.Ltext0 -+ .quad .LFE2-.Ltext0 -+ .value 0x2 -+ .byte 0x76 -+ .sleb128 16 -+ .quad 0x0 -+ .quad 0x0 -+ .section .debug_info -+ .long .Ldebug_end - .Ldebug_start -+.Ldebug_start: -+ .value 0x2 -+ .long .Ldebug_abbrev0 -+ .byte 0x8 -+ .uleb128 0x1 -+ .long .LASF2 -+ .byte 0x1 -+ .long .LASF3 -+ .long .LASF4 -+ .quad .Ltext0 -+ .quad .Letext0 -+ .long .Ldebug_line0 -+ .uleb128 0x2 -+ .byte 0x1 -+ .string "foo" -+ .byte 0x1 -+ .byte 0x16 -+ .byte 0x1 -+ .quad .LFB2 -+ .quad .LFE2 -+ .long .LLST0 -+ .long 0x83 -+ .uleb128 0x3 -+ .long .LASF5 -+ .byte 0x1 -+ .byte 0x15 -+ .long 0x83 -+ .byte 0x2 -+ .byte 0x91 -+ .sleb128 -52 -+.Ltag_typedef: -+ .uleb128 0x4 -+ .long .LASF6 -+ .byte 0x1 -+ .byte 0x17 -+ .long .Ltag_array_type - .debug_info -+ .uleb128 0x5 /* Abbrev Number: 5 (DW_TAG_variable) */ -+ .long .LASF0 -+ .byte 0x1 -+ .byte 0x18 -+#if 1 -+ .long .Ltag_typedef - .debug_info -+#else -+ /* Debugging only: Skip the typedef indirection. */ -+ .long .Ltag_array_type - .debug_info -+#endif -+ /* DW_AT_location: DW_FORM_block1: start */ -+ .byte 0x3 -+ .byte 0x91 -+ .sleb128 -32 -+#if 0 -+ .byte 0x6 /* DW_OP_deref */ -+#else -+ .byte 0x96 /* DW_OP_nop */ -+#endif -+ /* DW_AT_location: DW_FORM_block1: end */ -+ .uleb128 0x6 -+ .string "i" -+ .byte 0x1 -+ .byte 0x19 -+ .long 0x83 -+ .byte 0x2 -+ .byte 0x91 -+ .sleb128 -20 -+ .byte 0x0 -+ .uleb128 0x7 -+ .byte 0x4 -+ .byte 0x5 -+ .string "int" -+.Ltag_array_type: -+ .uleb128 0x8 /* Abbrev Number: 8 (DW_TAG_array_type) */ -+ .long 0xa0 + (2f - 1f) /* DW_AT_type: DW_FORM_ref4 */ -+ .long 0x9d + (2f - 1f) /* DW_AT_sibling: DW_FORM_ref4 */ -+1: /* DW_AT_data_location: DW_FORM_block1: start */ -+ .byte 2f - 3f /* length */ -+3: -+ .byte 0x97 /* DW_OP_push_object_address */ -+ .byte 0x6 /* DW_OP_deref */ -+2: /* DW_AT_data_location: DW_FORM_block1: end */ -+ .uleb128 0x9 -+ .long 0x9d + (2b - 1b) /* DW_AT_type: DW_FORM_ref4 */ -+ .byte 0x3 -+ .byte 0x91 -+ .sleb128 -40 -+ .byte 0x6 -+ .byte 0x0 -+ .uleb128 0xa -+ .byte 0x8 -+ .byte 0x7 -+ .uleb128 0xb -+ .byte 0x1 -+ .byte 0x6 -+ .long .LASF1 -+ .byte 0x0 -+.Ldebug_end: -+ .section .debug_abbrev -+ .uleb128 0x1 -+ .uleb128 0x11 -+ .byte 0x1 -+ .uleb128 0x25 -+ .uleb128 0xe -+ .uleb128 0x13 -+ .uleb128 0xb -+ .uleb128 0x3 -+ .uleb128 0xe -+ .uleb128 0x1b -+ .uleb128 0xe -+ .uleb128 0x11 -+ .uleb128 0x1 -+ .uleb128 0x12 -+ .uleb128 0x1 -+ .uleb128 0x10 -+ .uleb128 0x6 -+ .byte 0x0 -+ .byte 0x0 -+ .uleb128 0x2 -+ .uleb128 0x2e -+ .byte 0x1 -+ .uleb128 0x3f -+ .uleb128 0xc -+ .uleb128 0x3 -+ .uleb128 0x8 -+ .uleb128 0x3a -+ .uleb128 0xb -+ .uleb128 0x3b -+ .uleb128 0xb -+ .uleb128 0x27 -+ .uleb128 0xc -+ .uleb128 0x11 -+ .uleb128 0x1 -+ .uleb128 0x12 -+ .uleb128 0x1 -+ .uleb128 0x40 -+ .uleb128 0x6 -+ .uleb128 0x1 -+ .uleb128 0x13 -+ .byte 0x0 -+ .byte 0x0 -+ .uleb128 0x3 -+ .uleb128 0x5 -+ .byte 0x0 -+ .uleb128 0x3 -+ .uleb128 0xe -+ .uleb128 0x3a -+ .uleb128 0xb -+ .uleb128 0x3b -+ .uleb128 0xb -+ .uleb128 0x49 -+ .uleb128 0x13 -+ .uleb128 0x2 -+ .uleb128 0xa -+ .byte 0x0 -+ .byte 0x0 -+ .uleb128 0x4 -+ .uleb128 0x16 -+ .byte 0x0 -+ .uleb128 0x3 -+ .uleb128 0xe -+ .uleb128 0x3a -+ .uleb128 0xb -+ .uleb128 0x3b -+ .uleb128 0xb -+ .uleb128 0x49 -+ .uleb128 0x13 -+ .byte 0x0 -+ .byte 0x0 -+ .uleb128 0x5 -+ .uleb128 0x34 -+ .byte 0x0 -+ .uleb128 0x3 -+ .uleb128 0xe -+ .uleb128 0x3a -+ .uleb128 0xb -+ .uleb128 0x3b -+ .uleb128 0xb -+ .uleb128 0x49 -+ .uleb128 0x13 -+ .uleb128 0x2 -+ .uleb128 0xa -+ .byte 0x0 -+ .byte 0x0 -+ .uleb128 0x6 -+ .uleb128 0x34 -+ .byte 0x0 -+ .uleb128 0x3 -+ .uleb128 0x8 -+ .uleb128 0x3a -+ .uleb128 0xb -+ .uleb128 0x3b -+ .uleb128 0xb -+ .uleb128 0x49 -+ .uleb128 0x13 -+ .uleb128 0x2 -+ .uleb128 0xa -+ .byte 0x0 -+ .byte 0x0 -+ .uleb128 0x7 -+ .uleb128 0x24 -+ .byte 0x0 -+ .uleb128 0xb -+ .uleb128 0xb -+ .uleb128 0x3e -+ .uleb128 0xb -+ .uleb128 0x3 -+ .uleb128 0x8 -+ .byte 0x0 -+ .byte 0x0 -+ .uleb128 0x8 /* Abbrev Number: 8 (DW_TAG_array_type) */ -+ .uleb128 0x1 -+ .byte 0x1 -+ .uleb128 0x49 /* DW_AT_type */ -+ .uleb128 0x13 /* DW_FORM_ref4 */ -+ .uleb128 0x1 /* DW_AT_sibling */ -+ .uleb128 0x13 /* DW_FORM_ref4 */ -+ .uleb128 0x50 /* DW_AT_data_location */ -+ .uleb128 0xa /* DW_FORM_block1 */ -+ .byte 0x0 -+ .byte 0x0 -+ .uleb128 0x9 -+ .uleb128 0x21 -+ .byte 0x0 -+ .uleb128 0x49 /* DW_AT_type */ -+ .uleb128 0x13 /* DW_FORM_ref4 */ -+ .uleb128 0x2f -+ .uleb128 0xa -+ .byte 0x0 -+ .byte 0x0 -+ .uleb128 0xa -+ .uleb128 0x24 -+ .byte 0x0 -+ .uleb128 0xb -+ .uleb128 0xb -+ .uleb128 0x3e -+ .uleb128 0xb -+ .byte 0x0 -+ .byte 0x0 -+ .uleb128 0xb -+ .uleb128 0x24 -+ .byte 0x0 -+ .uleb128 0xb -+ .uleb128 0xb -+ .uleb128 0x3e -+ .uleb128 0xb -+ .uleb128 0x3 -+ .uleb128 0xe -+ .byte 0x0 -+ .byte 0x0 -+ .byte 0x0 -+ .section .debug_pubnames,"",@progbits -+ .long 0x16 -+ .value 0x2 -+ .long .Ldebug_info0 -+ .long 0xa8 -+ .long 0x2d -+ .string "foo" -+ .long 0x0 -+ .section .debug_aranges,"",@progbits -+ .long 0x2c -+ .value 0x2 -+ .long .Ldebug_info0 -+ .byte 0x8 -+ .byte 0x0 -+ .value 0x0 -+ .value 0x0 -+ .quad .Ltext0 -+ .quad .Letext0-.Ltext0 -+ .quad 0x0 -+ .quad 0x0 -+ .section .debug_str,"MS",@progbits,1 -+.LASF0: -+ .string "array" -+.LASF5: -+ .string "size" -+.LASF3: -+ .string "x86_64-vla-typedef.c" -+.LASF6: -+ .string "array_t" -+.LASF1: -+ .string "char" -+.LASF4: -+ .string "gdb.arch" -+.LASF2: -+ .string "GNU C 4.3.2 20081105 (Red Hat 4.3.2-7)" -+ .ident "GCC: (GNU) 4.3.2 20081105 (Red Hat 4.3.2-7)" -+ .section .note.GNU-stack,"",@progbits -diff --git a/gdb/testsuite/gdb.arch/x86_64-vla-typedef.c b/gdb/testsuite/gdb.arch/x86_64-vla-typedef.c -new file mode 100644 -index 0000000..b809c4e ---- /dev/null -+++ b/gdb/testsuite/gdb.arch/x86_64-vla-typedef.c -@@ -0,0 +1,43 @@ -+/* This testcase is part of GDB, the GNU debugger. -+ -+ Copyright 2008 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 0 -+ -+void -+foo (int size) -+{ -+ typedef char array_t[size]; -+ array_t array; -+ int i; -+ -+ for (i = 0; i < size; i++) -+ array[i] = i; -+ -+ array[0] = 0; /* break-here */ -+} -+ -+#else -+ -+int -+main (void) -+{ -+ foo (26); -+ foo (78); -+ return 0; -+} -+ -+#endif -diff --git a/gdb/testsuite/gdb.arch/x86_64-vla-typedef.exp b/gdb/testsuite/gdb.arch/x86_64-vla-typedef.exp -new file mode 100644 -index 0000000..b05411e ---- /dev/null -+++ b/gdb/testsuite/gdb.arch/x86_64-vla-typedef.exp -@@ -0,0 +1,64 @@ -+# Copyright 2009 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 . -+ -+# Test DW_AT_data_location accessed through DW_TAG_typedef intermediate. -+ -+if ![istarget "x86_64-*-*"] then { -+ verbose "Skipping over gdb.arch/x86_64-vla-typedef.exp test made only for x86_64." -+ return -+} -+ -+set testfile x86_64-vla-typedef -+set srcasmfile ${testfile}-foo.S -+set srcfile ${testfile}.c -+set binfile ${objdir}/${subdir}/${testfile} -+set binobjfile ${objdir}/${subdir}/${testfile}-foo.o -+if { [gdb_compile "${srcdir}/${subdir}/${srcasmfile}" "${binobjfile}" object {}] != "" } { -+ untested "Couldn't compile test program" -+ return -1 -+} -+if { [gdb_compile "${srcdir}/${subdir}/${srcfile} ${binobjfile}" "${binfile}" executable {debug}] != "" } { -+ untested "Couldn't compile test program" -+ return -1 -+} -+ -+gdb_exit -+gdb_start -+gdb_reinitialize_dir $srcdir/$subdir -+gdb_load ${binfile} -+ -+if ![runto_main] { -+ untested x86_64-vla-typedef -+ return -1 -+} -+ -+gdb_breakpoint "break_here" -+ -+gdb_continue_to_breakpoint "break_here" -+ -+gdb_test "whatis array" "type = array_t" "first: whatis array" -+ -+gdb_test "ptype array" "type = char \\\[26\\\]" "first: ptype array" -+ -+gdb_test "p array\[1\]" "\\$\[0-9\] = 1 '\\\\001'" -+gdb_test "p array\[2\]" "\\$\[0-9\] = 2 '\\\\002'" -+gdb_test "p array\[3\]" "\\$\[0-9\] = 3 '\\\\003'" -+gdb_test "p array\[4\]" "\\$\[0-9\] = 4 '\\\\004'" -+ -+gdb_continue_to_breakpoint "break_here" -+ -+gdb_test "whatis array" "type = array_t" "second: whatis array" -+ -+gdb_test "ptype array" "type = char \\\[78\\\]" "second: ptype array" -diff --git a/gdb/testsuite/gdb.base/arrayidx.c b/gdb/testsuite/gdb.base/arrayidx.c -index 98d4d35..f98a656 100644 ---- a/gdb/testsuite/gdb.base/arrayidx.c -+++ b/gdb/testsuite/gdb.base/arrayidx.c -@@ -17,6 +17,13 @@ - - int array[] = {1, 2, 3, 4}; - -+#ifdef __GNUC__ -+struct -+ { -+ int a[0]; -+ } unbound; -+#endif -+ - int - main (void) - { -diff --git a/gdb/testsuite/gdb.base/arrayidx.exp b/gdb/testsuite/gdb.base/arrayidx.exp -index 71ce4aa..af0e5f8 100644 ---- a/gdb/testsuite/gdb.base/arrayidx.exp -+++ b/gdb/testsuite/gdb.base/arrayidx.exp -@@ -59,4 +59,12 @@ gdb_test "print array" \ - "\\{\\\[0\\\] = 1, \\\[1\\\] = 2, \\\[2\\\] = 3, \\\[3\\\] = 4\\}" \ - "Print array with array-indexes on" - -- -+set test "p unbound.a == &unbound.a\[0\]" -+gdb_test_multiple $test $test { -+ -re " = 1\r\n$gdb_prompt $" { -+ pass $test -+ } -+ -re "No symbol \"unbound\" in current context.\r\n$gdb_prompt $" { -+ unsupported "$test (no GCC)" -+ } -+} -diff --git a/gdb/testsuite/gdb.base/help.exp b/gdb/testsuite/gdb.base/help.exp -index d76cc36..496ff18 100644 ---- a/gdb/testsuite/gdb.base/help.exp -+++ b/gdb/testsuite/gdb.base/help.exp -@@ -606,7 +606,7 @@ gdb_test "help stepi" "Step one instruction exactly\.\[\r\n\]+Argument N means d - gdb_test "help signal" "Continue program giving it signal.*" "help signal" - # test help source - # vxgdb reads .vxgdbinit --gdb_test "help source" "Read commands from a file named FILE\.\[\r\n\]+Optional -v switch \\(before the filename\\) causes each command in\[\r\n\]+FILE to be echoed as it is executed\.\[\r\n\]+Note that the file \"\[^\"\]*\" is read automatically in this way\[\r\n\]+when GDB is started\." "help source" -+gdb_test "help source" "Read commands from a file named FILE\.\[\r\n\]+Optional -v switch \\(before the filename\\) causes each command in\[\r\n\]+FILE to be echoed as it is executed\.\[\r\n\]+Note that the file \"\[^\"\]*\" is read automatically in this way\[\r\n\]+when GDB is started\.\[\r\n\]+Optional -p switch \\(before the filename\\) causes FILE to be evaluated\[\r\n\]+as Python code\." "help source" - # test help stack - test_class_help "stack" { - "Examining the stack\..*\[\r\n\]+" -diff --git a/gdb/testsuite/gdb.base/lineno-makeup-func.c b/gdb/testsuite/gdb.base/lineno-makeup-func.c -new file mode 100644 -index 0000000..1a0220e ---- /dev/null -+++ b/gdb/testsuite/gdb.base/lineno-makeup-func.c -@@ -0,0 +1,21 @@ -+/* This testcase is part of GDB, the GNU debugger. -+ -+ Copyright 2009 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 . */ -+ -+void -+func (void) -+{ -+} -diff --git a/gdb/testsuite/gdb.base/lineno-makeup.c b/gdb/testsuite/gdb.base/lineno-makeup.c -new file mode 100644 -index 0000000..bb20e98 ---- /dev/null -+++ b/gdb/testsuite/gdb.base/lineno-makeup.c -@@ -0,0 +1,35 @@ -+/* This testcase is part of GDB, the GNU debugger. -+ -+ Copyright 2009 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 . */ -+ -+/* DW_AT_low_pc-DW_AT_high_pc should cover the function without line number -+ information (.debug_line) so we cannot use an external object file. -+ -+ It must not be just a label as it would alias on the next function even for -+ correct GDB. Therefore some stub data must be placed there. -+ -+ We need to provide a real stub function body as at least s390 -+ (s390_analyze_prologue) would skip the whole body till reaching `main'. */ -+ -+extern void func (void); -+asm ("func: .incbin \"gdb.base/lineno-makeup-func.bin\""); -+ -+int -+main (void) -+{ -+ func (); -+ return 0; -+} -diff --git a/gdb/testsuite/gdb.base/lineno-makeup.exp b/gdb/testsuite/gdb.base/lineno-makeup.exp -new file mode 100644 -index 0000000..0c75b84 ---- /dev/null -+++ b/gdb/testsuite/gdb.base/lineno-makeup.exp -@@ -0,0 +1,78 @@ -+# Copyright 2009 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 . -+ -+set testfile "lineno-makeup" -+set srcfuncfile ${testfile}-func.c -+set srcfile ${testfile}.c -+set objfuncfile ${objdir}/${subdir}/${testfile}-func.o -+set binfuncfile ${objdir}/${subdir}/${testfile}-func.bin -+set binfile ${objdir}/${subdir}/${testfile} -+ -+if { [gdb_compile "${srcdir}/${subdir}/${srcfuncfile}" "${objfuncfile}" object {}] != "" } { -+ gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." -+} -+ -+set objcopy [catch "exec objcopy -O binary --only-section .text ${objfuncfile} ${binfuncfile}" output] -+verbose -log "objcopy=$objcopy: $output" -+if { $objcopy != 0 } { -+ gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." -+} -+set binfuncfilesize [file size $binfuncfile] -+verbose -log "file size $binfuncfile = $binfuncfilesize" -+ -+if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } { -+ gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." -+} -+ -+gdb_exit -+gdb_start -+gdb_reinitialize_dir $srcdir/$subdir -+gdb_load ${binfile} -+ -+set b_addr "" -+set test "break func" -+gdb_test_multiple $test $test { -+ -re "Breakpoint \[0-9\]+ at (0x\[0-9a-f\]+)\r\n$gdb_prompt $" { -+ set b_addr $expect_out(1,string) -+ pass $test -+ } -+ -re "Breakpoint \[0-9\]+ at (0x\[0-9a-f\]+): .*\r\n$gdb_prompt $" { -+ set b_addr $expect_out(1,string) -+ fail $test -+ } -+} -+verbose -log "b_addr=<$b_addr>" -+ -+set p_addr "" -+set test "print func" -+gdb_test_multiple $test $test { -+ -re "\\$\[0-9\]+ = {} (0x\[0-9a-f\]+) \r\n$gdb_prompt $" { -+ set p_addr $expect_out(1,string) -+ pass $test -+ } -+} -+verbose -log "p_addr=<$p_addr>" -+ -+set test "break address belongs to func" -+if {$b_addr == $p_addr} { -+ pass "$test (exact match)" -+} else { -+ set skip [expr $b_addr - $p_addr] -+ if {$skip > 0 && $skip < $binfuncfilesize} { -+ pass "$test (prologue skip by $skip bytes)" -+ } else { -+ fail $test -+ } -+} -diff --git a/gdb/testsuite/gdb.base/macscp.exp b/gdb/testsuite/gdb.base/macscp.exp -index 55c4d31..df25d3c 100644 ---- a/gdb/testsuite/gdb.base/macscp.exp -+++ b/gdb/testsuite/gdb.base/macscp.exp -@@ -33,6 +33,14 @@ if [test_compiler_info gcc*] { - lappend options additional_flags=-g3 - } - -+# Workaround ccache making lineno non-zero for command-line definitions. -+if {[find_gcc] == "gcc" && [file executable "/usr/bin/gcc"]} { -+ set result [catch "exec which gcc" output] -+ if {$result == 0 && [string first "/ccache/" $output] >= -1} { -+ lappend options "compiler=/usr/bin/gcc" -+ } -+} -+ - # Generate the intermediate object file. This is required by Darwin to - # have access to the .debug_macinfo section. - if {[gdb_compile "${srcdir}/${subdir}/macscp1.c" "${objfile}" \ -diff --git a/gdb/testsuite/gdb.base/radix.exp b/gdb/testsuite/gdb.base/radix.exp -index 750fd23..dfdb929 100644 ---- a/gdb/testsuite/gdb.base/radix.exp -+++ b/gdb/testsuite/gdb.base/radix.exp -@@ -162,13 +162,6 @@ gdb_test "set radix" \ - "Input and output radices now set to decimal 10, hex a, octal 12\." \ - "Reset radices" - --gdb_test "set input-radix 0" \ -- "Nonsense input radix ``decimal 0''; input radix unchanged\\." \ -- "Reject input-radix 0" --gdb_test "show input-radix" \ -- "Default input radix for entering numbers is 10\\." \ -- "Input radix unchanged after rejecting 0" -- - gdb_test "set input-radix 1" \ - "Nonsense input radix ``decimal 1''; input radix unchanged\\." \ - "Reject input-radix 1" -diff --git a/gdb/testsuite/gdb.base/valgrind-attach.c b/gdb/testsuite/gdb.base/valgrind-attach.c -new file mode 100644 -index 0000000..84b57db ---- /dev/null -+++ b/gdb/testsuite/gdb.base/valgrind-attach.c -@@ -0,0 +1,28 @@ -+/* This testcase is part of GDB, the GNU debugger. -+ -+ Copyright 2009 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 -+ -+int -+main (void) -+{ -+ int *a = malloc (1); -+ -+ a[10] = 0; /* crash-here */ -+ -+ return 0; -+} -diff --git a/gdb/testsuite/gdb.base/valgrind-attach.exp b/gdb/testsuite/gdb.base/valgrind-attach.exp -new file mode 100644 -index 0000000..1f9b26e ---- /dev/null -+++ b/gdb/testsuite/gdb.base/valgrind-attach.exp -@@ -0,0 +1,94 @@ -+# Copyright 2009 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 . -+ -+set testfile valgrind-attach -+set shfile ${testfile}.sh -+set srcfile ${testfile}.c -+set binfile ${objdir}/${subdir}/${testfile} -+if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } { -+ untested "Couldn't compile test program" -+ return -1 -+} -+ -+gdb_exit -+gdb_stop_suppressing_tests; -+ -+set VALGRIND "valgrind" -+ -+# Syntax for ${shfile} is: -+set VALGRIND_SPAWN "sh ${srcdir}/${subdir}/${shfile} $binfile $VALGRIND $GDB $INTERNAL_GDBFLAGS $GDBFLAGS [host_info gdb_opts]" -+ -+set test "spawn valgrind" -+verbose "Spawning $VALGRIND_SPAWN" -+ -+if [info exists gdb_spawn_id] { -+ fail $test -+ return -1 -+} -+ -+if ![is_remote host] { -+ if { [which $VALGRIND] == 0 } then { -+ untested "Couldn't find $VALGRIND" -+ return -1 -+ } -+} -+set res [remote_spawn host "$VALGRIND_SPAWN"] -+if { $res < 0 || $res == "" } { -+ perror "Spawning $VALGRIND_SPAWN failed." -+ return -1 -+} -+set gdb_spawn_id -1; -+ -+gdb_expect { -+ -re "---- Attach to debugger \\? --- \\\[Return/N/n/Y/y/C/c\\\] ---- $" { -+ pass $test -+ } -+ eof { -+ perror "(eof) $VALGRIND never initialized" -+ remote_close host -+ return -1 -+ } -+ timeout { -+ perror "(timeout) $VALGRIND never initialized" -+ remote_close host -+ return -1 -+ } -+} -+send_gdb "y\n" -+ -+set test "spawn gdb" -+set test2 "crash line caught" -+gdb_expect { -+ -re "starting debugger with cmd:.* in main .* crash-here .*\[\r\n\]$gdb_prompt $" { -+ pass $test -+ pass $test2 -+ } -+ -re "starting debugger with cmd:.*\[\r\n\]$gdb_prompt $" { -+ pass $test -+ fail $test2 -+ } -+ eof { -+ perror "(eof) $GDB never initialized" -+ remote_close host -+ return -1 -+ } -+ timeout { -+ perror "(timeout) $GDB never initialized" -+ remote_close host -+ return -1 -+ } -+} -+ -+remote_close host -diff --git a/gdb/testsuite/gdb.base/valgrind-attach.sh b/gdb/testsuite/gdb.base/valgrind-attach.sh -new file mode 100755 -index 0000000..f02c6f7 ---- /dev/null -+++ b/gdb/testsuite/gdb.base/valgrind-attach.sh -@@ -0,0 +1,20 @@ -+#! /bin/sh -+ -+# Copyright 2009 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 . -+ -+BINFILE="$1"; shift -+VALGRIND="$1"; shift -+"$VALGRIND" --db-attach=yes --db-command="$* %f %p" "$BINFILE" -diff --git a/gdb/testsuite/gdb.base/vla-overflow.c b/gdb/testsuite/gdb.base/vla-overflow.c -new file mode 100644 -index 0000000..c5d5ee0 ---- /dev/null -+++ b/gdb/testsuite/gdb.base/vla-overflow.c -@@ -0,0 +1,30 @@ -+/* This testcase is part of GDB, the GNU debugger. -+ -+ Copyright 2008 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 -+ -+int -+main (int argc, char **argv) -+{ -+ int array[argc]; -+ -+ array[0] = array[0]; -+ -+ abort (); -+ -+ return 0; -+} -diff --git a/gdb/testsuite/gdb.base/vla-overflow.exp b/gdb/testsuite/gdb.base/vla-overflow.exp -new file mode 100644 -index 0000000..7203a48 ---- /dev/null -+++ b/gdb/testsuite/gdb.base/vla-overflow.exp -@@ -0,0 +1,108 @@ -+# Copyright 2008 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 . -+ -+# We could crash in: -+# #0 block_linkage_function (bl=0x0) at ../../gdb/block.c:69 -+# #1 in dwarf_block_get_frame_base (...) at ../../gdb/dwarf2block.c:97 -+# 97 framefunc = block_linkage_function (get_frame_block (frame, NULL)); -+# #2 in execute_stack_op (...) at ../../gdb/dwarf2expr.c:496 -+# #3 in dwarf_block_exec_core () at ../../gdb/dwarf2block.c:156 -+# #4 dwarf_block_exec (...) at ../../gdb/dwarf2block.c:206 -+# #5 in range_type_count_bound_internal (...) at ../../gdb/gdbtypes.c:1430 -+# #6 in create_array_type (...) at ../../gdb/gdbtypes.c:840 -+# ... -+# #21 in psymtab_to_symtab (...) at ../../gdb/symfile.c:292 -+# ... -+# #29 in backtrace_command_1 () at ../../gdb/stack.c:1273 -+ -+set testfile vla-overflow -+set shfile ${objdir}/${subdir}/${testfile}-gdb.sh -+set srcfile ${testfile}.c -+set binfile ${objdir}/${subdir}/${testfile} -+if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } { -+ untested "Couldn't compile test program" -+ return -1 -+} -+ -+set f [open "|getconf PAGESIZE" "r"] -+gets $f pagesize -+close $f -+ -+gdb_exit -+gdb_start -+gdb_reinitialize_dir $srcdir/$subdir -+gdb_load ${binfile} -+ -+set pid_of_gdb [exp_pid -i [board_info host fileid]] -+ -+if { [runto_main] < 0 } { -+ untested vla-overflow -+ return -1 -+} -+ -+# Get the GDB memory size when we stay at main. -+ -+proc memory_v_pages_get {} { -+ global pid_of_gdb pagesize -+ set fd [open "/proc/$pid_of_gdb/statm"] -+ gets $fd line -+ close $fd -+ # number of pages of virtual memory -+ scan $line "%d" drs -+ return $drs -+} -+ -+set pages_found [memory_v_pages_get] -+ -+set mb_reserve 10 -+verbose -log "pages_found = $pages_found, mb_reserve = $mb_reserve" -+set kb_found [expr $pages_found * $pagesize / 1024] -+set kb_permit [expr $kb_found + 1 * 1024 + $mb_reserve * 1024] -+verbose -log "kb_found = $kb_found, kb_permit = $kb_permit" -+ -+# Create the ulimit wrapper. -+set f [open $shfile "w"] -+puts $f "#! /bin/sh" -+puts $f "ulimit -v $kb_permit" -+puts $f "exec $GDB \"\$@\"" -+close $f -+remote_exec host "chmod +x $shfile" -+ -+gdb_exit -+set GDBold $GDB -+set GDB "$shfile" -+gdb_start -+set GDB $GDBold -+ -+gdb_reinitialize_dir $srcdir/$subdir -+gdb_load ${binfile} -+ -+set pid_of_gdb [exp_pid -i [board_info host fileid]] -+ -+# Check the size again after the second run. -+# We must not stop in main as it would cache `array' and never crash later. -+ -+gdb_run_cmd -+ -+verbose -log "kb_found before abort() = [expr [memory_v_pages_get] * $pagesize / 1024]" -+ -+gdb_test "" "Program received signal SIGABRT, Aborted..*" "Enter abort()" -+ -+verbose -log "kb_found in abort() = [expr [memory_v_pages_get] * $pagesize / 1024]" -+ -+# `abort' can get expressed as `*__GI_abort'. -+gdb_test "bt" "in \[^ \]*abort \\(.* in main \\(.*" "Backtrace after abort()" -+ -+verbose -log "kb_found in bt after abort() = [expr [memory_v_pages_get] * $pagesize / 1024]" -diff --git a/gdb/testsuite/gdb.base/vla.c b/gdb/testsuite/gdb.base/vla.c -new file mode 100644 -index 0000000..e1f3ed1 ---- /dev/null -+++ b/gdb/testsuite/gdb.base/vla.c -@@ -0,0 +1,55 @@ -+/* This testcase is part of GDB, the GNU debugger. -+ -+ Copyright 2008 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 -+ -+void -+marker (void) -+{ -+} -+ -+void -+bar (char *a, char *b, char *c, int size) -+{ -+ memset (a, '1', size); -+ memset (b, '2', size); -+ memset (c, '3', 48); -+} -+ -+void -+foo (int size) -+{ -+ char temp1[size]; -+ char temp3[48]; -+ -+ temp1[size - 1] = '\0'; -+ { -+ char temp2[size]; -+ -+ bar (temp1, temp2, temp3, size); -+ -+ marker (); /* break-here */ -+ } -+} -+ -+int -+main (void) -+{ -+ foo (26); -+ foo (78); -+ return 0; -+} -diff --git a/gdb/testsuite/gdb.base/vla.exp b/gdb/testsuite/gdb.base/vla.exp -new file mode 100644 -index 0000000..5da7378 ---- /dev/null -+++ b/gdb/testsuite/gdb.base/vla.exp -@@ -0,0 +1,62 @@ -+# Copyright 2008 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 . -+ -+set testfile vla -+set srcfile ${testfile}.c -+set binfile ${objdir}/${subdir}/${testfile} -+if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } { -+ untested "Couldn't compile test program" -+ return -1 -+} -+ -+gdb_exit -+gdb_start -+gdb_reinitialize_dir $srcdir/$subdir -+gdb_load ${binfile} -+ -+if ![runto_main] { -+ untested vla -+ return -1 -+} -+ -+gdb_breakpoint [gdb_get_line_number "break-here"] -+ -+gdb_continue_to_breakpoint "break-here" -+ -+gdb_test "whatis temp1" "type = char \\\[variable\\\]" "first: whatis temp1" -+gdb_test "whatis temp2" "type = char \\\[variable\\\]" "first: whatis temp2" -+gdb_test "whatis temp3" "type = char \\\[48\\\]" "first: whatis temp3" -+ -+gdb_test "ptype temp1" "type = char \\\[26\\\]" "first: ptype temp1" -+gdb_test "ptype temp2" "type = char \\\[26\\\]" "first: ptype temp2" -+gdb_test "ptype temp3" "type = char \\\[48\\\]" "first: ptype temp3" -+ -+gdb_test "p temp1" " = '1' " "first: print temp1" -+gdb_test "p temp2" " = '2' " "first: print temp2" -+gdb_test "p temp3" " = '3' " "first: print temp3" -+ -+gdb_continue_to_breakpoint "break-here" -+ -+gdb_test "whatis temp1" "type = char \\\[variable\\\]" "second: whatis temp1" -+gdb_test "whatis temp2" "type = char \\\[variable\\\]" "second: whatis temp2" -+gdb_test "whatis temp3" "type = char \\\[48\\\]" "second: whatis temp3" -+ -+gdb_test "ptype temp1" "type = char \\\[78\\\]" "second: ptype temp1" -+gdb_test "ptype temp2" "type = char \\\[78\\\]" "second: ptype temp2" -+gdb_test "ptype temp3" "type = char \\\[48\\\]" "second: ptype temp3" -+ -+gdb_test "p temp1" " = '1' " "second: print temp1" -+gdb_test "p temp2" " = '2' " "second: print temp2" -+gdb_test "p temp3" " = '3' " "second: print temp3" -diff --git a/gdb/testsuite/gdb.base/watchpoint-hw.c b/gdb/testsuite/gdb.base/watchpoint-hw.c -index 8da9af5..e2de53a 100644 ---- a/gdb/testsuite/gdb.base/watchpoint-hw.c -+++ b/gdb/testsuite/gdb.base/watchpoint-hw.c -@@ -20,5 +20,11 @@ int watchee; - int - main (void) - { -+ volatile int dummy; -+ -+ dummy = watchee; -+ dummy = 1; -+ dummy = 2; /* break-at-exit */ -+ - return 0; - } -diff --git a/gdb/testsuite/gdb.base/watchpoint-hw.exp b/gdb/testsuite/gdb.base/watchpoint-hw.exp -index a2bb731..d74d6c7 100644 ---- a/gdb/testsuite/gdb.base/watchpoint-hw.exp -+++ b/gdb/testsuite/gdb.base/watchpoint-hw.exp -@@ -21,19 +21,12 @@ if {(![istarget "i?86-*-*"] && ![istarget "x86_64-*-*"] - return - } - --set testfile watchpoint-hw --set srcfile ${testfile}.c --set binfile ${objdir}/${subdir}/${testfile} --if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } { -- untested "Couldn't compile test program" -+set test watchpoint-hw -+set srcfile ${test}.c -+if { [prepare_for_testing ${test}.exp ${test} ${srcfile}] } { - return -1 - } - --gdb_exit --gdb_start --gdb_reinitialize_dir $srcdir/$subdir --gdb_load ${binfile} -- - # Create the watchpoint before the inferior gets started. Now the native CPU - # target is still not active and its `to_can_use_hw_breakpoint' is not - # installed, therefore only a software watchpoint gets created. -@@ -43,10 +36,40 @@ gdb_test "watch watchee" "atchpoint 1: watchee" - # `runto_main' or `runto main' would delete the watchpoint created above. - - if { [gdb_start_cmd] < 0 } { -- untested start -+ untested ${test}.exp - return -1 - } - gdb_test "" "main .* at .*" "start" - - # Check it is really a `hw'-watchpoint. - gdb_test "info watchpoints" "1 *hw watchpoint .* watchee" -+ -+# Before the inferior gets started we would get: -+# Target does not support this type of hardware watchpoint. -+gdb_test "delete 1" -+gdb_test "rwatch watchee" -+ -+set breakline [gdb_get_line_number "break-at-exit"] -+gdb_breakpoint $breakline -+ -+gdb_test "continue" "Continuing.\r\nHardware read watchpoint 3: watchee\r\n\r\nValue = 0\r\n.*" -+ -+# Here should be no repeated notification of the read watchpoint. -+gdb_test "continue" \ -+ "Continuing\\.\[ \r\n\]+Breakpoint \[0-9\]+, .*break-at-exit.*" \ -+ "continue to break-at-exit after rwatch" -+ -+clean_restart ${test} -+ -+if ![runto_main] { -+ untested ${test}.exp -+ return -1 -+} -+ -+gdb_test "hbreak ${srcfile}:${breakline}" \ -+ "Hardware assisted breakpoint 2 at 0x\[0-9a-f\]+: file .*${srcfile}, line ${breakline}\\." \ -+ "hbreak" -+ -+gdb_test "continue" \ -+ "Continuing\\.\[ \r\n\]+Breakpoint \[0-9\]+, .*break-at-exit.*" \ -+ "continue to break-at-exit after hbreak" -diff --git a/gdb/testsuite/gdb.cp/Makefile.in b/gdb/testsuite/gdb.cp/Makefile.in -index 0a087c7..b4880f2 100644 ---- a/gdb/testsuite/gdb.cp/Makefile.in -+++ b/gdb/testsuite/gdb.cp/Makefile.in -@@ -4,7 +4,7 @@ srcdir = @srcdir@ - EXECUTABLES = ambiguous annota2 anon-union cplusfuncs cttiadd \ - derivation inherit local member-ptr method misc \ - overload ovldbreak ref-typ ref-typ2 templates userdef virtfunc namespace \ -- ref-types ref-params method2 pr9594 gdb2495 -+ ref-types ref-params method2 pr9594 gdb2495 gdb9593 - - all info install-info dvi install uninstall installcheck check: - @echo "Nothing to be done for $@..." -diff --git a/gdb/testsuite/gdb.cp/cp-relocate.exp b/gdb/testsuite/gdb.cp/cp-relocate.exp -index 4095ccf..03c07d5 100644 ---- a/gdb/testsuite/gdb.cp/cp-relocate.exp -+++ b/gdb/testsuite/gdb.cp/cp-relocate.exp -@@ -30,7 +30,7 @@ proc get_func_address { func } { - global gdb_prompt hex - - set rfunc [string_to_regexp $func] -- gdb_test_multiple "print '${func}'" "get address of ${func}" { -+ gdb_test_multiple "print ${func}" "get address of ${func}" { - -re "\\\$\[0-9\]+ = \\{.*\\} (0|($hex) <${rfunc}>)\[\r\n\]+${gdb_prompt} $" { - # $1 = {int ()} 0x24 - # But if the function is at zero, the name may be omitted. -@@ -130,7 +130,7 @@ gdb_test "add-symbol-file ${binfile} 0 -s ${func1_sec} 0x10000 -s ${func2_sec} 0 - "y" - - # Make sure the function addresses were updated. --gdb_test "break *'$func1_name'" \ -+gdb_test "break *$func1_name" \ - "Breakpoint $decimal at 0x1....: file .*" --gdb_test "break *'$func2_name'" \ -+gdb_test "break *$func2_name" \ - "Breakpoint $decimal at 0x2....: file .*" -diff --git a/gdb/testsuite/gdb.cp/cplusfuncs.cc b/gdb/testsuite/gdb.cp/cplusfuncs.cc -index 7f033d6..11dba06 100644 ---- a/gdb/testsuite/gdb.cp/cplusfuncs.cc -+++ b/gdb/testsuite/gdb.cp/cplusfuncs.cc -@@ -46,7 +46,9 @@ public: - void operator [] (foo&); - void operator () (foo&); - void* operator new (size_t) throw (); -+ void* operator new[] (size_t) throw (); - void operator delete (void *); -+ void operator delete[] (void *); - /**/ operator int (); - /**/ operator char* (); - -@@ -115,7 +117,9 @@ void foo::operator ->* (foo& afoo) { afoo.ifoo = 0; } - void foo::operator [] (foo& afoo) { afoo.ifoo = 0; } - void foo::operator () (foo& afoo) { afoo.ifoo = 0; } - void* foo::operator new (size_t ival) throw () { ival = 0; return 0; } -+void* foo::operator new[] (size_t ival) throw () { ival = 0; return 0; } - void foo::operator delete (void *ptr) { ptr = 0; } -+void foo::operator delete[] (void *ptr) { ptr = 0; } - /**/ foo::operator int () { return 0; } - /**/ foo::operator char* () { return 0; } - -@@ -191,6 +195,12 @@ char * dm_type_char_star (char * p) { return p; } - int dm_type_foo_ref (foo & foo) { return foo.ifoo; } - int * dm_type_int_star (int * p) { return p; } - long * dm_type_long_star (long * p) { return p; } -+int dm_type_short (short i) { return i; } -+int dm_type_long (long i) { return i; } - int dm_type_unsigned_int (unsigned int i) { return i; } -+int dm_type_unsigned_short (unsigned short i) { return i; } -+int dm_type_unsigned_long (unsigned long i) { return i; } - int dm_type_void (void) { return 0; } - void * dm_type_void_star (void * p) { return p; } -+typedef int myint; -+int dm_type_typedef (myint i) { return i; } -diff --git a/gdb/testsuite/gdb.cp/cplusfuncs.exp b/gdb/testsuite/gdb.cp/cplusfuncs.exp -index 5e08768..2ec50ca 100644 ---- a/gdb/testsuite/gdb.cp/cplusfuncs.exp -+++ b/gdb/testsuite/gdb.cp/cplusfuncs.exp -@@ -63,12 +63,28 @@ set dm_type_foo_ref "foo&" - set dm_type_int_star "int*" - set dm_type_long_star "long*" - set dm_type_unsigned_int "unsigned" --set dm_type_void "" -+set dm_type_void "void" - set dm_type_void_star "void*" - -+# Some other vagaries of GDB's type printing machinery. The integer types -+# may have unsigned before or after their length, and may have "int" -+# appended. The char* conversion operator may have name "char*" even if -+# the type is "char *", because the name comes from the debug information -+# and the type from GDB. Function types may not see through typedefs. -+ -+set dm_type_short "short" -+set dm_type_long "long" -+set dm_type_unsigned_short "unsigned short" -+set dm_type_unsigned_long "unsigned long" -+set dm_operator_char_star "char*" -+set dm_operator_char_star_quoted "char\\*" -+set dm_type_typedef 0 -+ - proc probe_demangler { } { - global gdb_prompt - global dm_operator_comma -+ global dm_operator_char_star -+ global dm_operator_char_star_quoted - global dm_type_char_star - global dm_type_char_star_quoted - global dm_type_foo_ref -@@ -77,8 +93,13 @@ proc probe_demangler { } { - global dm_type_unsigned_int - global dm_type_void - global dm_type_void_star -+ global dm_type_short -+ global dm_type_unsigned_short -+ global dm_type_long -+ global dm_type_unsigned_long -+ global dm_type_typedef - -- send_gdb "print &'foo::operator,(foo&)'\n" -+ send_gdb "print &foo::operator,(foo&)\n" - gdb_expect { - -re ".*foo::operator, \\(.*foo.*&.*\\).*\r\n$gdb_prompt $" { - # v2 demangler -@@ -97,6 +118,26 @@ proc probe_demangler { } { - } - } - -+ send_gdb "print &foo::operator char*($dm_type_void)\n" -+ gdb_expect { -+ -re ".*foo::operator char \\*\\(void\\).*\r\n$gdb_prompt $" { -+ # v2 demangler or GDB type printer -+ set dm_operator_char_star "char *" -+ set dm_operator_char_star_quoted "char \\*" -+ pass "detect dm_operator_char_star" -+ } -+ -re ".*foo::operator char\\*\\(\\).*\r\n$gdb_prompt $" { -+ # v3 demangler -+ pass "detect dm_operator_char_star" -+ } -+ -re ".*$gdb_prompt $" { -+ fail "detect dm_operator_char_star" -+ } -+ timeout { -+ fail "detect dm_operator_char_star" -+ } -+ } -+ - send_gdb "print &'dm_type_char_star'\n" - gdb_expect { - -re ".*dm_type_char_star\\(char \\*\\).*\r\n$gdb_prompt $" { -@@ -166,6 +207,11 @@ proc probe_demangler { } { - # v3 demangler - pass "detect dm_type_long_star" - } -+ -re ".*dm_type_long_star\\(long int \\*\\).*\r\n$gdb_prompt $" { -+ # GCC v3 and GDB's type printer -+ set dm_type_long_star "long int *" -+ pass "detect dm_type_long_star" -+ } - -re ".*$gdb_prompt $" { - fail "detect dm_type_long_star" - } -@@ -230,6 +276,101 @@ proc probe_demangler { } { - fail "detect dm_type_void_star (timeout)" - } - } -+ -+ send_gdb "print &'dm_type_short'\n" -+ gdb_expect { -+ -re ".*dm_type_short\\(short\\).*\r\n$gdb_prompt $" { -+ # v2 and v3 demanglers -+ pass "detect dm_type_short" -+ } -+ -re ".*dm_type_short\\(short int\\).*\r\n$gdb_prompt $" { -+ # GDB type printer -+ set dm_type_short "short int" -+ pass "detect dm_type_short" -+ } -+ -re ".*$gdb_prompt $" { -+ fail "detect dm_type_short" -+ } -+ timeout { -+ fail "detect dm_type_short (timeout)" -+ } -+ } -+ -+ send_gdb "print &'dm_type_unsigned_short'\n" -+ gdb_expect { -+ -re ".*dm_type_unsigned_short\\(unsigned short\\).*\r\n$gdb_prompt $" { -+ # v2 and v3 demanglers -+ pass "detect dm_type_unsigned_short" -+ } -+ -re ".*dm_type_unsigned_short\\(short unsigned int\\).*\r\n$gdb_prompt $" { -+ # GDB type printer -+ set dm_type_unsigned_short "short unsigned int" -+ pass "detect dm_type_unsigned_short" -+ } -+ -re ".*$gdb_prompt $" { -+ fail "detect dm_type_unsigned_short" -+ } -+ timeout { -+ fail "detect dm_type_unsigned_short (timeout)" -+ } -+ } -+ -+ send_gdb "print &'dm_type_long'\n" -+ gdb_expect { -+ -re ".*dm_type_long\\(long\\).*\r\n$gdb_prompt $" { -+ # v2 and v3 demanglers -+ pass "detect dm_type_long" -+ } -+ -re ".*dm_type_long\\(long int\\).*\r\n$gdb_prompt $" { -+ # GDB type printer -+ set dm_type_long "long int" -+ pass "detect dm_type_long" -+ } -+ -re ".*$gdb_prompt $" { -+ fail "detect dm_type_long" -+ } -+ timeout { -+ fail "detect dm_type_long (timeout)" -+ } -+ } -+ -+ send_gdb "print &'dm_type_unsigned_long'\n" -+ gdb_expect { -+ -re ".*dm_type_unsigned_long\\(unsigned long\\).*\r\n$gdb_prompt $" { -+ # v2 and v3 demanglers -+ pass "detect dm_type_unsigned_long" -+ } -+ -re ".*dm_type_unsigned_long\\(long unsigned int\\).*\r\n$gdb_prompt $" { -+ # GDB type printer -+ set dm_type_unsigned_long "long unsigned int" -+ pass "detect dm_type_unsigned_long" -+ } -+ -re ".*$gdb_prompt $" { -+ fail "detect dm_type_unsigned_long" -+ } -+ timeout { -+ fail "detect dm_type_unsigned_long (timeout)" -+ } -+ } -+ -+ send_gdb "print &'dm_type_typedef'\n" -+ gdb_expect { -+ -re ".*dm_type_typedef\\(int\\).*\r\n$gdb_prompt $" { -+ # v2 and v3 demanglers -+ pass "detect dm_type_typedef" -+ } -+ -re ".*dm_type_typedef\\(myint\\).*\r\n$gdb_prompt $" { -+ # GDB type printer -+ set dm_type_typedef 1 -+ pass "detect dm_type_typedef" -+ } -+ -re ".*$gdb_prompt $" { -+ fail "detect dm_type_typedef" -+ } -+ timeout { -+ fail "detect dm_type_typedef (timeout)" -+ } -+ } - } - - # -@@ -241,6 +382,7 @@ proc info_func_regexp { name demangled } { - global gdb_prompt - - send_gdb "info function $name\n" -+ set demangled [regsub {\\\(void\\\)} $demangled {\(\)}] - gdb_expect { - -re ".*File .*:\r\n(class |)$demangled\r\n.*$gdb_prompt $" { - pass "info function for \"$name\"" -@@ -277,16 +419,16 @@ proc print_addr_2 { name good } { - - set good_pattern [string_to_regexp $good] - -- send_gdb "print &'$name'\n" -+ send_gdb "print &$name\n" - gdb_expect { - -re ".* = .* $hex <$good_pattern>\r\n$gdb_prompt $" { -- pass "print &'$name'" -+ pass "print &$name" - } - -re ".*$gdb_prompt $" { -- fail "print &'$name'" -+ fail "print &$name" - } - timeout { -- fail "print &'$name' (timeout)" -+ fail "print &$name (timeout)" - } - } - } -@@ -327,7 +469,12 @@ proc print_addr_2_kfail { name good bad bugid } { - # - - proc print_addr { name } { -- print_addr_2 "$name" "$name" -+ set expected [regsub {\(void\)} $name {()}] -+ if {[string first "::" $name] == -1} { -+ # C function -- must be qutoed -+ set name "'$name'" -+ } -+ print_addr_2 "$name" $expected - } - - # -@@ -345,8 +492,9 @@ proc print_addr { name } { - - proc test_lookup_operator_functions {} { - global dm_operator_comma -+ global dm_operator_char_star - global dm_type_char_star -- global dm_type_char_star_quoted -+ global dm_operator_char_star_quoted - global dm_type_foo_ref - global dm_type_void - global dm_type_void_star -@@ -404,8 +552,8 @@ proc test_lookup_operator_functions {} { - - info_func "operator int(" "int foo::operator int($dm_type_void);" - info_func "operator()(" "void foo::operator()($dm_type_foo_ref);" -- info_func "operator $dm_type_char_star_quoted\(" \ -- "char *foo::operator $dm_type_char_star\($dm_type_void);" -+ info_func "operator $dm_operator_char_star_quoted\(" \ -+ "char *foo::operator $dm_operator_char_star\($dm_type_void);" - - } - -@@ -420,6 +568,7 @@ proc test_paddr_operator_functions {} { - global dm_type_unsigned_int - global dm_type_void - global dm_type_void_star -+ global dm_operator_char_star - - print_addr "foo::operator*($dm_type_foo_ref)" - print_addr "foo::operator%($dm_type_foo_ref)" -@@ -460,17 +609,20 @@ proc test_paddr_operator_functions {} { - print_addr "foo::operator\[\]($dm_type_foo_ref)" - print_addr "foo::operator()($dm_type_foo_ref)" - -- gdb_test "print &'foo::operator new'" \ -+ gdb_test "print &foo::operator new" \ - " = .* $hex " -+ gdb_test "print &foo::operator new\[\]" \ -+ " = .* $hex " - if { !$hp_aCC_compiler } { - print_addr "foo::operator delete($dm_type_void_star)" -+ print_addr "foo::operator delete[]($dm_type_void_star)" - } else { - gdb_test "print &'foo::operator delete($dm_type_void_star) static'" \ - " = .*(0x\[0-9a-f\]+|) " - } - - print_addr "foo::operator int($dm_type_void)" -- print_addr "foo::operator $dm_type_char_star\($dm_type_void)" -+ print_addr "foo::operator $dm_operator_char_star\($dm_type_void)" - } - - # -@@ -480,17 +632,21 @@ proc test_paddr_operator_functions {} { - proc test_paddr_overloaded_functions {} { - global dm_type_unsigned_int - global dm_type_void -+ global dm_type_short -+ global dm_type_unsigned_short -+ global dm_type_long -+ global dm_type_unsigned_long - - print_addr "overload1arg($dm_type_void)" - print_addr "overload1arg(char)" - print_addr "overload1arg(signed char)" - print_addr "overload1arg(unsigned char)" -- print_addr "overload1arg(short)" -- print_addr "overload1arg(unsigned short)" -+ print_addr "overload1arg($dm_type_short)" -+ print_addr "overload1arg($dm_type_unsigned_short)" - print_addr "overload1arg(int)" - print_addr "overload1arg($dm_type_unsigned_int)" -- print_addr "overload1arg(long)" -- print_addr "overload1arg(unsigned long)" -+ print_addr "overload1arg($dm_type_long)" -+ print_addr "overload1arg($dm_type_unsigned_long)" - print_addr "overload1arg(float)" - print_addr "overload1arg(double)" - -@@ -513,17 +669,31 @@ proc test_paddr_hairy_functions {} { - global dm_type_char_star - global dm_type_int_star - global dm_type_long_star -+ global dm_type_typedef - - print_addr_2 "hairyfunc1" "hairyfunc1(int)" -- print_addr_2 "hairyfunc2" "hairyfunc2(int (*)($dm_type_char_star))" -- print_addr_2 "hairyfunc3" "hairyfunc3(int (*)(short (*)($dm_type_long_star)))" -- print_addr_2 "hairyfunc4" "hairyfunc4(int (*)(short (*)($dm_type_char_star)))" -- -- # gdb-gnats bug gdb/19: -- # "gdb v3 demangler fails on hairyfunc5 hairyfunc6 hairyfunc7" -- print_addr_2_kfail "hairyfunc5" "hairyfunc5(int (*(*)($dm_type_char_star))(long))" "hairyfunc5(int (*)(long) (*)(char*))" "gdb/19" -- print_addr_2_kfail "hairyfunc6" "hairyfunc6(int (*(*)($dm_type_int_star))(long))" "hairyfunc6(int (*)(long) (*)(int*))" "gdb/19" -- print_addr_2_kfail "hairyfunc7" "hairyfunc7(int (*(*)(int (*)($dm_type_char_star)))(long))" "hairyfunc7(int (*)(long) (*)(int (*)(char*)))" "gdb/19" -+ -+ if {$dm_type_typedef == 0} { -+ print_addr_2 "hairyfunc2" "hairyfunc2(int (*)($dm_type_char_star))" -+ print_addr_2 "hairyfunc3" "hairyfunc3(int (*)(short (*)($dm_type_long_star)))" -+ print_addr_2 "hairyfunc4" "hairyfunc4(int (*)(short (*)($dm_type_char_star)))" -+ -+ # gdb-gnats bug gdb/19: -+ # "gdb v3 demangler fails on hairyfunc5 hairyfunc6 hairyfunc7" -+ print_addr_2_kfail "hairyfunc5" "hairyfunc5(int (*(*)($dm_type_char_star))(long))" "hairyfunc5(int (*)(long) (*)(char*))" "gdb/19" -+ print_addr_2_kfail "hairyfunc6" "hairyfunc6(int (*(*)($dm_type_int_star))(long))" "hairyfunc6(int (*)(long) (*)(int*))" "gdb/19" -+ print_addr_2_kfail "hairyfunc7" "hairyfunc7(int (*(*)(int (*)($dm_type_char_star)))(long))" "hairyfunc7(int (*)(long) (*)(int (*)(char*)))" "gdb/19" -+ } else { -+ print_addr_2 "hairyfunc2" "hairyfunc2(PFPc_i)" -+ print_addr_2 "hairyfunc3" "hairyfunc3(PFPFPl_s_i)" -+ print_addr_2 "hairyfunc4" "hairyfunc4(PFPFPc_s_i)" -+ -+ # gdb-gnats bug gdb/19: -+ # "gdb v3 demangler fails on hairyfunc5 hairyfunc6 hairyfunc7" -+ print_addr_2 "hairyfunc5" "hairyfunc5(PFPc_PFl_i)" -+ print_addr_2 "hairyfunc6" "hairyfunc6(PFPi_PFl_i)" -+ print_addr_2 "hairyfunc7" "hairyfunc7(PFPFPc_i_PFl_i)" -+ } - } - - proc do_tests {} { -@@ -534,6 +704,7 @@ proc do_tests {} { - global srcdir - global binfile - global gdb_prompt -+ global dm_type_int_star - - set prms_id 0 - set bug_id 0 -@@ -557,6 +728,10 @@ proc do_tests {} { - test_paddr_operator_functions - test_paddr_hairy_functions - test_lookup_operator_functions -+ -+ # A regression test on errors involving operators -+ gdb_test "list foo::operator $dm_type_int_star" \ -+ ".*the class foo does not have any method named operator $dm_type_int_star.*" - } - - do_tests -diff --git a/gdb/testsuite/gdb.cp/expand-sals.exp b/gdb/testsuite/gdb.cp/expand-sals.exp -index 3c302c3..cd0496d 100644 ---- a/gdb/testsuite/gdb.cp/expand-sals.exp -+++ b/gdb/testsuite/gdb.cp/expand-sals.exp -@@ -48,7 +48,7 @@ gdb_continue_to_breakpoint "caller" ".*caller-line.*" - - # Test GDB caught this return call and not the next one through B::B() - gdb_test "bt" \ -- "#0 \[^\r\n\]* A \[^\r\n\]*\r\n#1 \[^\r\n\]* main \[^\r\n\]*" \ -+ "#0 \[^\r\n\]* (A::)?A \[^\r\n\]*\r\n#1 \[^\r\n\]* main \[^\r\n\]*" \ - "bt from A" - - gdb_continue_to_breakpoint "next caller func" ".*func-line.*" -diff --git a/gdb/testsuite/gdb.cp/gdb9593.cc b/gdb/testsuite/gdb.cp/gdb9593.cc -new file mode 100644 -index 0000000..783c962 ---- /dev/null -+++ b/gdb/testsuite/gdb.cp/gdb9593.cc -@@ -0,0 +1,180 @@ -+/* This testcase is part of GDB, the GNU debugger. -+ -+ Copyright 2008, 2009 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 -+ -+using namespace std; -+ -+class NextOverThrowDerivates -+{ -+ -+public: -+ -+ -+ // Single throw an exception in this function. -+ void function1() -+ { -+ throw 20; -+ } -+ -+ // Throw an exception in another function. -+ void function2() -+ { -+ function1(); -+ } -+ -+ // Throw an exception in another function, but handle it -+ // locally. -+ void function3 () -+ { -+ { -+ try -+ { -+ function1 (); -+ } -+ catch (...) -+ { -+ cout << "Caught and handled function1 exception" << endl; -+ } -+ } -+ } -+ -+ void rethrow () -+ { -+ try -+ { -+ function1 (); -+ } -+ catch (...) -+ { -+ throw; -+ } -+ } -+ -+ void finish () -+ { -+ // We use this to test that a "finish" here does not end up in -+ // this frame, but in the one above. -+ try -+ { -+ function1 (); -+ } -+ catch (int x) -+ { -+ } -+ function1 (); // marker for until -+ } -+ -+ void until () -+ { -+ function1 (); -+ function1 (); // until here -+ } -+ -+}; -+NextOverThrowDerivates next_cases; -+ -+ -+int main () -+{ -+ try -+ { -+ next_cases.function1 (); -+ } -+ catch (...) -+ { -+ // Discard -+ } -+ -+ try -+ { -+ next_cases.function2 (); -+ } -+ catch (...) -+ { -+ // Discard -+ } -+ -+ try -+ { -+ // This is duplicated so we can next over one but step into -+ // another. -+ next_cases.function2 (); -+ } -+ catch (...) -+ { -+ // Discard -+ } -+ -+ next_cases.function3 (); -+ -+ try -+ { -+ next_cases.rethrow (); -+ } -+ catch (...) -+ { -+ // Discard -+ } -+ -+ try -+ { -+ // Another duplicate so we can test "finish". -+ next_cases.function2 (); -+ } -+ catch (...) -+ { -+ // Discard -+ } -+ -+ // Another test for "finish". -+ try -+ { -+ next_cases.finish (); -+ } -+ catch (...) -+ { -+ } -+ -+ // Test of "until". -+ try -+ { -+ next_cases.finish (); -+ } -+ catch (...) -+ { -+ } -+ -+ // Test of "until" with an argument. -+ try -+ { -+ next_cases.until (); -+ } -+ catch (...) -+ { -+ } -+ -+ // Test of "advance". -+ try -+ { -+ next_cases.until (); -+ } -+ catch (...) -+ { -+ } -+} -+ -diff --git a/gdb/testsuite/gdb.cp/gdb9593.exp b/gdb/testsuite/gdb.cp/gdb9593.exp -new file mode 100644 -index 0000000..ee9aeff ---- /dev/null -+++ b/gdb/testsuite/gdb.cp/gdb9593.exp -@@ -0,0 +1,185 @@ -+# Copyright 2008, 2009 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 $tracelevel then { -+ strace $tracelevel -+} -+ -+if { [skip_cplus_tests] } { continue } -+ -+set prms_id 9593 -+set bug_id 0 -+ -+set testfile "gdb9593" -+set srcfile ${testfile}.cc -+set binfile $objdir/$subdir/$testfile -+ -+# Create and source the file that provides information about the compiler -+# used to compile the test case. -+if [get_compiler_info ${binfile} "c++"] { -+ untested gdb9593.exp -+ return -1 -+} -+ -+if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } { -+ untested gdb9593.exp -+ return -1 -+} -+ -+# Some targets can't do function calls, so don't even bother with this -+# test. -+if [target_info exists gdb,cannot_call_functions] { -+ setup_xfail "*-*-*" 9593 -+ fail "This target can not call functions" -+ continue -+} -+ -+gdb_exit -+gdb_start -+gdb_reinitialize_dir $srcdir/$subdir -+gdb_load ${binfile} -+ -+if ![runto_main] then { -+ perror "couldn't run to main" -+ continue -+} -+ -+# See whether we have the needed unwinder hooks. -+set ok 1 -+gdb_test_multiple "print _Unwind_DebugHook" "check for unwinder hook" { -+ -re "= .*_Unwind_DebugHook.*\r\n$gdb_prompt $" { -+ pass "check for unwinder hook" -+ } -+ -re "No symbol .* in current context.\r\n$gdb_prompt $" { -+ # Pass the test so we don't get bogus fails in the results. -+ pass "check for unwinder hook" -+ set ok 0 -+ } -+} -+if {!$ok} { -+ untested gdb9593.exp -+ return -1 -+} -+ -+# See http://sourceware.org/bugzilla/show_bug.cgi?id=9593 -+ -+gdb_test "next" \ -+ ".*catch (...).*" \ -+ "next over a throw 1" -+ -+gdb_test "next" \ -+ ".*next_cases.function2.*" \ -+ "next past catch 1" -+ -+gdb_test "next" \ -+ ".*catch (...).*" \ -+ "next over a throw 2" -+ -+gdb_test "next" \ -+ ".*next_cases.function2.*" \ -+ "next past catch 2" -+ -+gdb_test "step" \ -+ ".*function1().*" \ -+ "step into function2 1" -+ -+gdb_test "next" \ -+ ".*catch (...).*" \ -+ "next over a throw 3" -+ -+gdb_test "next" \ -+ ".*next_cases.function3.*" \ -+ "next past catch 3" -+ -+gdb_test "next" \ -+ ".*next_cases.rethrow.*" \ -+ "next over a throw 4" -+ -+gdb_test "next" \ -+ ".*catch (...).*" \ -+ "next over a rethrow" -+ -+gdb_test "next" \ -+ ".*next_cases.function2.*" \ -+ "next after a rethrow" -+ -+gdb_test "step" \ -+ ".*function1().*" \ -+ "step into function2 2" -+ -+gdb_test "finish" \ -+ ".*catch (...).*" \ -+ "finish 1" -+ -+gdb_test "next" \ -+ ".*next_cases.finish ().*" \ -+ "next past catch 4" -+ -+gdb_test "step" \ -+ ".*function1 ().*" \ -+ "step into finish method" -+ -+gdb_test "finish" \ -+ ".*catch (...).*" \ -+ "finish 2" -+ -+gdb_test "next" \ -+ ".*next_cases.finish ().*" \ -+ "next past catch 5" -+ -+gdb_test "step" \ -+ ".*function1 ().*" \ -+ "step into finish, for until" -+ -+gdb_test "until" \ -+ ".*catch .int x.*" \ -+ "until with no argument 1" -+ -+set line [gdb_get_line_number "marker for until" $testfile.cc] -+ -+gdb_test "until $line" \ -+ ".*function1 ().*" \ -+ "next past catch 6" -+ -+gdb_test "until" \ -+ ".*catch (...).*" \ -+ "until with no argument 2" -+ -+set line [gdb_get_line_number "until here" $testfile.cc] -+ -+gdb_test "next" \ -+ ".*next_cases.until ().*" \ -+ "next past catch 6" -+ -+gdb_test "step" \ -+ ".*function1 ().*" \ -+ "step into until" -+ -+gdb_test "until $line" \ -+ ".*catch (...).*" \ -+ "until-over-throw" -+ -+gdb_test "next" \ -+ ".*next_cases.until ().*" \ -+ "next past catch 7" -+ -+gdb_test "step" \ -+ ".*function1 ().*" \ -+ "step into until, for advance" -+ -+gdb_test "advance $line" \ -+ ".*catch (...).*" \ -+ "advance-over-throw" -diff --git a/gdb/testsuite/gdb.cp/member-ptr.cc b/gdb/testsuite/gdb.cp/member-ptr.cc -index 1dff70a..648b2af 100644 ---- a/gdb/testsuite/gdb.cp/member-ptr.cc -+++ b/gdb/testsuite/gdb.cp/member-ptr.cc -@@ -138,6 +138,7 @@ class Diamond : public Padding, public Left, public Right - { - public: - virtual int vget_base (); -+ int (*func_ptr) (int); - }; - - int Diamond::vget_base () -@@ -145,6 +146,12 @@ int Diamond::vget_base () - return this->Left::x + 2000; - } - -+int -+func (int x) -+{ -+ return 19 + x; -+} -+ - int main () - { - A a; -@@ -162,6 +169,7 @@ int main () - int (Diamond::*right_vpmf) (); - int (Base::*base_vpmf) (); - int Diamond::*diamond_pmi; -+ int (* Diamond::*diamond_pfunc_ptr) (int); - - PMI null_pmi; - PMF null_pmf; -@@ -179,6 +187,7 @@ int main () - - diamond.Left::x = 77; - diamond.Right::x = 88; -+ diamond.func_ptr = func; - - /* Some valid pointer to members from a base class. */ - left_pmf = (int (Diamond::*) ()) (int (Left::*) ()) (&Base::get_x); -@@ -193,11 +202,19 @@ int main () - /* A pointer to data member from a base class. */ - diamond_pmi = (int Diamond::*) (int Left::*) &Base::x; - -+ /* A pointer to data member, where the member is itself a pointer to -+ a function. */ -+ diamond_pfunc_ptr = (int (* Diamond::*) (int)) &Diamond::func_ptr; -+ - null_pmi = NULL; - null_pmf = NULL; - - pmi = NULL; /* Breakpoint 1 here. */ - -+ // Invalid (uses diamond_pfunc_ptr as a function): -+ // diamond.*diamond_pfunc_ptr (20); -+ (diamond.*diamond_pfunc_ptr) (20); -+ - k = (a.*pmf)(3); - - pmi = &A::jj; -diff --git a/gdb/testsuite/gdb.cp/member-ptr.exp b/gdb/testsuite/gdb.cp/member-ptr.exp -index b69d4ad..83dd0d5 100644 ---- a/gdb/testsuite/gdb.cp/member-ptr.exp -+++ b/gdb/testsuite/gdb.cp/member-ptr.exp -@@ -390,6 +390,33 @@ gdb_test_multiple "print ((int) pmi) == ((char *) &a.j - (char *) & a)" $name { - } - } - -+# Check pointers to data members, which are themselves pointers to -+# functions. These behave like data members, not like pointers to -+# member functions. -+ -+gdb_test "ptype diamond_pfunc_ptr" \ -+ "type = int \\(\\*Diamond::\\*\\)\\(int\\)" -+ -+gdb_test "ptype diamond.*diamond_pfunc_ptr" \ -+ "type = int \\(\\*\\)\\(int\\)" -+ -+# This one is invalid; () binds more tightly than .*, so it tries to -+# call the member pointer as a normal pointer-to-function. -+ -+gdb_test "print diamond.*diamond_pfunc_ptr (20)" \ -+ "Invalid data type for function to be called." -+ -+# With parentheses, it is valid. -+ -+gdb_test "print (diamond.*diamond_pfunc_ptr) (20)" \ -+ "$vhn = 39" -+ -+# Make sure that we do not interpret this as either a member pointer -+# call or a member function call. -+ -+gdb_test "print diamond.func_ptr (20)" \ -+ "$vhn = 39" -+ - # ========================== - # pointer to member function - # ========================== -@@ -420,7 +447,7 @@ gdb_test_multiple "ptype pmf" $name { - - set name "print pmf" - gdb_test_multiple "print pmf" $name { -- -re "$vhn = $hex \r\n$gdb_prompt $" { -+ -re "$vhn = \\(int \\(A::\\*\\)\\(A \\*, int\\)\\) $hex \r\n$gdb_prompt $" { - pass $name - } - -re "$vhn = .*not supported with HP aCC.*\r\n$gdb_prompt $" { -@@ -608,6 +635,9 @@ gdb_test_multiple "print (a.*pmf)(3)" $name { - } - } - -+gdb_test "ptype a.*pmf" "type = int \\(A \\*, int\\)" -+gdb_test "ptype (a.*pmf)(3)" "type = int" -+ - # Print out a pointer to data member which requires looking into - # a base class. - gdb_test "print diamond_pmi" "$vhn = &Base::x" -@@ -658,5 +688,5 @@ gdb_test "print null_pmi = &A::j" "$vhn = &A::j" - gdb_test "print null_pmi = 0" "$vhn = NULL" - - gdb_test "print null_pmf" "$vhn = NULL" --gdb_test "print null_pmf = &A::foo" "$vhn = $hex " -+gdb_test "print null_pmf = &A::foo" "$vhn = \\(int \\(A::\\*\\)\\(A \\*, int\\)\\) $hex " - gdb_test "print null_pmf = 0" "$vhn = NULL" -diff --git a/gdb/testsuite/gdb.cp/namespace-multiple-imports.cc b/gdb/testsuite/gdb.cp/namespace-multiple-imports.cc -new file mode 100644 -index 0000000..6b180d6 ---- /dev/null -+++ b/gdb/testsuite/gdb.cp/namespace-multiple-imports.cc -@@ -0,0 +1,20 @@ -+namespace A { -+ int x = 11; -+ namespace{ -+ int xx = 22; -+ } -+} -+ -+using namespace A; -+ -+namespace{ -+ int xxx = 33; -+}; -+ -+int main() -+{ -+ x; -+ xx; -+ xxx; -+ return 0; -+} -diff --git a/gdb/testsuite/gdb.cp/namespace-multiple-imports.exp b/gdb/testsuite/gdb.cp/namespace-multiple-imports.exp -new file mode 100644 -index 0000000..e4bb9f8 ---- /dev/null -+++ b/gdb/testsuite/gdb.cp/namespace-multiple-imports.exp -@@ -0,0 +1,49 @@ -+# Copyright 2008 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 $tracelevel then { -+ strace $tracelevel -+} -+ -+set prms_id 0 -+set bug_id 0 -+ -+set testfile namespace-multiple-imports -+set srcfile ${testfile}.cc -+set binfile ${objdir}/${subdir}/${testfile} -+if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } { -+ untested "Couldn't compile test program" -+ return -1 -+} -+ -+# Get things started. -+ -+gdb_exit -+gdb_start -+gdb_reinitialize_dir $srcdir/$subdir -+gdb_load ${binfile} -+ -+############################################ -+# test printing of namespace imported within -+# the function. -+ -+if ![runto_main] then { -+ perror "couldn't run to breakpoint main" -+ continue -+} -+ -+gdb_test "print x" "\\$\[0-9\].* = 11" -+gdb_test "print xx" "\\$\[0-9\].* = 22" -+gdb_test "print xxx" "\\$\[0-9\].* = 33" -diff --git a/gdb/testsuite/gdb.cp/namespace-nested-imports.cc b/gdb/testsuite/gdb.cp/namespace-nested-imports.cc -new file mode 100644 -index 0000000..9723f87 ---- /dev/null -+++ b/gdb/testsuite/gdb.cp/namespace-nested-imports.cc -@@ -0,0 +1,36 @@ -+namespace A -+{ -+ namespace B -+ { -+ int ab = 11; -+ } -+} -+ -+namespace C -+{ -+ namespace D -+ { -+ using namespace A::B; -+ -+ int -+ second() -+ { -+ ab; -+ return 0; -+ } -+ } -+ -+ int -+ first() -+ { -+ //ab; -+ return D::second(); -+ } -+} -+ -+int -+main() -+{ -+ //ab; -+ return C::first(); -+} -diff --git a/gdb/testsuite/gdb.cp/namespace-nested-imports.exp b/gdb/testsuite/gdb.cp/namespace-nested-imports.exp -new file mode 100644 -index 0000000..d279fb5 ---- /dev/null -+++ b/gdb/testsuite/gdb.cp/namespace-nested-imports.exp -@@ -0,0 +1,57 @@ -+# Copyright 2008 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 $tracelevel then { -+ strace $tracelevel -+} -+ -+set prms_id 0 -+set bug_id 0 -+ -+set testfile namespace-nested-imports -+set srcfile ${testfile}.cc -+set binfile ${objdir}/${subdir}/${testfile} -+if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } { -+ untested "Couldn't compile test program" -+ return -1 -+} -+ -+# Get things started. -+ -+gdb_exit -+gdb_start -+gdb_reinitialize_dir $srcdir/$subdir -+gdb_load ${binfile} -+ -+############################################ -+if ![runto_main] then { -+ perror "couldn't run to breakpoint main" -+ continue -+} -+ -+gdb_test "print ab" "No symbol .* in current context." -+ -+############################################ -+gdb_breakpoint C::first -+gdb_continue_to_breakpoint "C::first" -+ -+gdb_test "print ab" "No symbol .* in current context." -+gdb_test "print C::D::ab" "= 11" -+ -+############################################ -+gdb_breakpoint C::D::second -+gdb_continue_to_breakpoint "C::D::second" -+ -+gdb_test "print ab" "= 11" -diff --git a/gdb/testsuite/gdb.cp/namespace-no-imports.cc b/gdb/testsuite/gdb.cp/namespace-no-imports.cc -new file mode 100644 -index 0000000..d1c68ab ---- /dev/null -+++ b/gdb/testsuite/gdb.cp/namespace-no-imports.cc -@@ -0,0 +1,37 @@ -+ -+namespace A -+{ -+ int _a = 11; -+ -+ namespace B{ -+ -+ int ab = 22; -+ -+ namespace C{ -+ -+ int abc = 33; -+ -+ int second(){ -+ return 0; -+ } -+ -+ } -+ -+ int first(){ -+ _a; -+ ab; -+ C::abc; -+ return C::second(); -+ } -+ } -+} -+ -+ -+int -+main() -+{ -+ A::_a; -+ A::B::ab; -+ A::B::C::abc; -+ return A::B::first(); -+} -diff --git a/gdb/testsuite/gdb.cp/namespace-no-imports.exp b/gdb/testsuite/gdb.cp/namespace-no-imports.exp -new file mode 100644 -index 0000000..e508103 ---- /dev/null -+++ b/gdb/testsuite/gdb.cp/namespace-no-imports.exp -@@ -0,0 +1,76 @@ -+# Copyright 2008 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 $tracelevel then { -+ strace $tracelevel -+} -+ -+set prms_id 0 -+set bug_id 0 -+ -+set testfile namespace-no-imports -+set srcfile ${testfile}.cc -+set binfile ${objdir}/${subdir}/${testfile} -+if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } { -+ untested "Couldn't compile test program" -+ return -1 -+} -+ -+# Get things started. -+ -+gdb_exit -+gdb_start -+gdb_reinitialize_dir $srcdir/$subdir -+gdb_load ${binfile} -+ -+############################################ -+if ![runto_main] then { -+ perror "couldn't run to breakpoint main" -+ continue -+} -+ -+gdb_test "print A::_a" "= 11" -+gdb_test "print A::B::ab" "= 22" -+gdb_test "print A::B::C::abc" "= 33" -+ -+gdb_test "print _a" "No symbol .* in current context." -+gdb_test "print ab" "No symbol .* in current context." -+gdb_test "print abc" "No symbol .* in current context." -+ -+############################################ -+gdb_breakpoint A::B::first -+gdb_continue_to_breakpoint "A::B::first" -+ -+gdb_test "print A::_a" "= 11" -+gdb_test "print A::B::ab" "= 22" -+gdb_test "print A::B::C::abc" "= 33" -+ -+gdb_test "print _a" "= 11" -+gdb_test "print ab" "= 22" -+gdb_test "print C::abc" "= 33" -+ -+gdb_test "print abc" "No symbol .* in current context." -+ -+############################################ -+gdb_breakpoint A::B::C::second -+gdb_continue_to_breakpoint "A::B::C::second" -+ -+gdb_test "print A::_a" "= 11" -+gdb_test "print A::B::ab" "= 22" -+gdb_test "print A::B::C::abc" "= 33" -+ -+gdb_test "print _a" "= 11" -+gdb_test "print ab" "= 22" -+gdb_test "print abc" "= 33" -diff --git a/gdb/testsuite/gdb.cp/namespace-recursive.cc b/gdb/testsuite/gdb.cp/namespace-recursive.cc -new file mode 100644 -index 0000000..46d4c18 ---- /dev/null -+++ b/gdb/testsuite/gdb.cp/namespace-recursive.cc -@@ -0,0 +1,47 @@ -+namespace A{ -+ int ax = 9; -+} -+ -+namespace B{ -+ using namespace A; -+} -+ -+namespace C{ -+ using namespace B; -+} -+ -+using namespace C; -+ -+//--------------- -+namespace D{ -+ using namespace D; -+ int dx = 99; -+} -+using namespace D; -+ -+//--------------- -+namespace{ -+ namespace{ -+ int xx = 999; -+ } -+} -+ -+//--------------- -+namespace E{ -+ int ex = 9999; -+} -+ -+namespace F{ -+ namespace FE = E; -+} -+ -+namespace G{ -+ namespace GF = F; -+} -+ -+//---------------- -+int main(){ -+ using namespace D; -+ namespace GX = G; -+ return ax + dx + xx + G::GF::FE::ex; -+} -diff --git a/gdb/testsuite/gdb.cp/namespace-recursive.exp b/gdb/testsuite/gdb.cp/namespace-recursive.exp -new file mode 100644 -index 0000000..5543757 ---- /dev/null -+++ b/gdb/testsuite/gdb.cp/namespace-recursive.exp -@@ -0,0 +1,75 @@ -+# Copyright 2008 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 $tracelevel then { -+ strace $tracelevel -+} -+ -+set prms_id 0 -+set bug_id 0 -+ -+set testfile namespace-recursive -+set srcfile ${testfile}.cc -+set binfile ${objdir}/${subdir}/${testfile} -+if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } { -+ untested "Couldn't compile test program" -+ return -1 -+} -+ -+if [get_compiler_info ${binfile}] { -+ return -1; -+} -+ -+ -+# Get things started. -+ -+gdb_exit -+gdb_start -+gdb_reinitialize_dir $srcdir/$subdir -+gdb_load ${binfile} -+ -+if ![runto_main] then { -+ perror "couldn't run to breakpoint main" -+ continue -+} -+ -+############################################ -+# test printing from namespace imported into -+# imported namespace -+ -+gdb_test "print ax" "= 9" -+ -+############################################ -+# test that gdb can print without falling -+# into search loop -+ -+gdb_test "print dx" "= 99" -+ -+############################################ -+# test printing from namespace imported into -+# imported namespace where imports are implicit -+# anonymous namespace imports. -+ -+gdb_test "print xx" "= 999" -+ -+############################################ -+# Test printing using recursive namespace -+# aliases. -+ -+setup_kfail "gdb/10541" "*-*-*" -+gdb_test "ptype G::GF" "= namespace F" -+ -+setup_kfail "gdb/10541" "*-*-*" -+gdb_test "print G::GF::FE::ex" "= 9999" -diff --git a/gdb/testsuite/gdb.cp/namespace-stress-declarations.cc b/gdb/testsuite/gdb.cp/namespace-stress-declarations.cc -new file mode 100644 -index 0000000..173e49b ---- /dev/null -+++ b/gdb/testsuite/gdb.cp/namespace-stress-declarations.cc -@@ -0,0 +1,93 @@ -+int a; -+int b; -+int c; -+int d; -+int e; -+int f; -+int g; -+int h; -+int i; -+int j; -+int k; -+int l; -+int m; -+int n; -+int o; -+int p; -+int q; -+int r; -+int s; -+int t; -+int u; -+int v; -+int w; -+int x; -+int y; -+int z; -+ -+namespace A -+{ -+ int xyz; -+ -+ using ::a; -+ using ::b; -+ using ::c; -+ using ::d; -+ using ::e; -+ using ::f; -+ using ::g; -+ using ::h; -+ using ::i; -+ using ::j; -+ using ::k; -+ using ::l; -+ using ::m; -+ using ::n; -+ using ::o; -+ using ::p; -+ using ::q; -+ using ::r; -+ using ::s; -+ using ::t; -+ using ::u; -+ using ::v; -+ using ::w; -+ using ::x; -+ using ::y; -+ using ::z; -+ -+} -+ -+using A::a; -+using A::b; -+using A::c; -+using A::d; -+using A::e; -+using A::f; -+using A::g; -+using A::h; -+using A::i; -+using A::j; -+using A::k; -+using A::l; -+using A::m; -+using A::n; -+using A::o; -+using A::p; -+using A::q; -+using A::r; -+using A::s; -+using A::t; -+using A::u; -+using A::v; -+using A::w; -+using A::x; -+using A::y; -+using A::z; -+ -+using namespace A; -+ -+int main () -+{ -+ return 0; -+} -\ No newline at end of file -diff --git a/gdb/testsuite/gdb.cp/namespace-stress-declarations.exp b/gdb/testsuite/gdb.cp/namespace-stress-declarations.exp -new file mode 100644 -index 0000000..f22a14e ---- /dev/null -+++ b/gdb/testsuite/gdb.cp/namespace-stress-declarations.exp -@@ -0,0 +1,50 @@ -+# Copyright 2008 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 $tracelevel then { -+ strace $tracelevel -+} -+ -+set prms_id 0 -+set bug_id 0 -+ -+set testfile namespace-stress-declarations -+set srcfile ${testfile}.cc -+set binfile ${objdir}/${subdir}/${testfile} -+if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } { -+ untested "Couldn't compile test program" -+ return -1 -+} -+ -+if [get_compiler_info ${binfile}] { -+ return -1; -+} -+ -+# Get things started. -+ -+gdb_exit -+gdb_start -+gdb_reinitialize_dir $srcdir/$subdir -+gdb_load ${binfile} -+ -+if ![runto_main] then { -+ perror "couldn't run to breakpoint main" -+ continue -+} -+ -+############################################ -+# Test that the search can fail efficiently -+ -+gdb_test "print fakex" "No symbol \"fakex\" in current context." -diff --git a/gdb/testsuite/gdb.cp/namespace-stress.cc b/gdb/testsuite/gdb.cp/namespace-stress.cc -new file mode 100644 -index 0000000..f34083e ---- /dev/null -+++ b/gdb/testsuite/gdb.cp/namespace-stress.cc -@@ -0,0 +1,60 @@ -+ -+namespace A{ int x; } -+namespace B{ int x; } -+namespace C{ int x; } -+namespace D{ int x; } -+namespace E{ int x; } -+namespace F{ int x; } -+namespace G{ int x; } -+namespace H{ int x; } -+namespace I{ int x; } -+namespace J{ int x; } -+namespace K{ int x; } -+namespace L{ int x; } -+namespace M{ int x; } -+namespace N{ int x; } -+namespace O{ int x; } -+namespace P{ int x; } -+namespace Q{ int x; } -+namespace R{ int x; } -+namespace S{ int x; } -+namespace T{ int x; } -+namespace U{ int x; } -+namespace V{ int x; } -+namespace W{ int x; } -+namespace X{ int x; } -+namespace Y{ int x; } -+namespace Z{ int x; } -+ -+ -+int main(){ -+ -+ using namespace A; -+ using namespace B; -+ using namespace C; -+ using namespace D; -+ using namespace E; -+ using namespace F; -+ using namespace G; -+ using namespace H; -+ using namespace I; -+ using namespace J; -+ using namespace K; -+ using namespace L; -+ using namespace M; -+ using namespace N; -+ using namespace O; -+ using namespace P; -+ using namespace Q; -+ using namespace R; -+ using namespace S; -+ using namespace T; -+ using namespace U; -+ using namespace V; -+ using namespace W; -+ using namespace X; -+ using namespace Y; -+ using namespace Z; -+ -+ return 0; -+} -\ No newline at end of file -diff --git a/gdb/testsuite/gdb.cp/namespace-stress.exp b/gdb/testsuite/gdb.cp/namespace-stress.exp -new file mode 100644 -index 0000000..1806523 ---- /dev/null -+++ b/gdb/testsuite/gdb.cp/namespace-stress.exp -@@ -0,0 +1,50 @@ -+# Copyright 2008 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 $tracelevel then { -+ strace $tracelevel -+} -+ -+set prms_id 0 -+set bug_id 0 -+ -+set testfile namespace-stress -+set srcfile ${testfile}.cc -+set binfile ${objdir}/${subdir}/${testfile} -+if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } { -+ untested "Couldn't compile test program" -+ return -1 -+} -+ -+if [get_compiler_info ${binfile}] { -+ return -1; -+} -+ -+# Get things started. -+ -+gdb_exit -+gdb_start -+gdb_reinitialize_dir $srcdir/$subdir -+gdb_load ${binfile} -+ -+if ![runto_main] then { -+ perror "couldn't run to breakpoint main" -+ continue -+} -+ -+############################################ -+# Test that the search can fail efficiently -+ -+gdb_test "print y" "No symbol \"y\" in current context." -diff --git a/gdb/testsuite/gdb.cp/namespace-using.cc b/gdb/testsuite/gdb.cp/namespace-using.cc -index 4786fd5..8ff5622 100644 ---- a/gdb/testsuite/gdb.cp/namespace-using.cc -+++ b/gdb/testsuite/gdb.cp/namespace-using.cc -@@ -1,26 +1,129 @@ -+namespace M -+{ -+ int x = 911; -+} -+ -+namespace N -+{ -+ int x = 912; -+} -+ -+int marker10 () -+{ -+ using namespace M; -+ int y = x + 1; // marker10 stop -+ using namespace N; -+ return y; -+} -+ -+namespace J -+{ -+ int jx = 44; -+} -+ -+namespace K -+{ -+ int -+ marker9 () -+ { -+ //x; -+ return marker10 (); -+ } -+} -+ -+namespace L -+{ -+ using namespace J; -+ int -+ marker8 () -+ { -+ jx; -+ return K::marker9 (); -+ } -+} -+ -+namespace G -+{ -+ namespace H -+ { -+ int ghx = 6; -+ } -+} -+ -+namespace I -+{ -+ int -+ marker7 () -+ { -+ using namespace G::H; -+ ghx; -+ return L::marker8 (); -+ } -+} -+ -+namespace E -+{ -+ namespace F -+ { -+ int efx = 5; -+ } -+} -+ -+using namespace E::F; -+int -+marker6 () -+{ -+ efx; -+ return I::marker7 (); -+} -+ - namespace A - { - int _a = 1; - int x = 2; - } - --int marker4(){ -- using A::x; -- return 0; -+namespace C -+{ -+ int cc = 3; -+} -+ -+namespace D -+{ -+ int dx = 4; -+} -+ -+using namespace C; -+int -+marker5 () -+{ -+ cc; -+ return marker6 (); -+} -+ -+int -+marker4 () -+{ -+ using D::dx; -+ return marker5 (); - } - --int marker3(){ -- return marker4(); -+int -+marker3 () -+{ -+ return marker4 (); - } - --int marker2() -+int -+marker2 () - { - namespace B = A; - B::_a; -- return marker3(); -+ return marker3 (); - } - --int marker1() -+int -+marker1 () - { - int total = 0; - { -@@ -29,17 +132,18 @@ int marker1() - using namespace A; - int c = 2; - { -- int d = 3; -- total = _a + b + c + d + marker2(); // marker1 stop -+ int d = 3; -+ total = _a + b + c + d + marker2 (); // marker1 stop - } - } - } - return total; - } - --int main() -+int -+main () - { - using namespace A; - _a; -- return marker1(); -+ return marker1 (); - } -diff --git a/gdb/testsuite/gdb.cp/namespace-using.exp b/gdb/testsuite/gdb.cp/namespace-using.exp -index f24973f..fc23115 100644 ---- a/gdb/testsuite/gdb.cp/namespace-using.exp -+++ b/gdb/testsuite/gdb.cp/namespace-using.exp -@@ -28,6 +28,11 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {deb - return -1 - } - -+if [get_compiler_info ${binfile}] { -+ return -1; -+} -+ -+ - # Get things started. - - gdb_exit -@@ -46,42 +51,155 @@ if ![runto_main] then { - - gdb_test "print _a" "= 1" - -+# Test that names are not printed when they -+# are not imported -+ -+gdb_breakpoint marker3 -+gdb_continue_to_breakpoint "marker3" -+ -+#send_gdb "break marker3\n" -+#send_gdb "continue\n" -+ -+gdb_test "print _a" "No symbol \"_a\" in current context." "Print _a without import" -+ -+gdb_exit -+gdb_start -+gdb_reinitialize_dir $srcdir/$subdir -+gdb_load ${binfile} -+ -+ - ############################################ - # test printing of namespace imported into - # a scope containing the pc. - -+if ![runto_main] then { -+ perror "couldn't run to breakpoint main" -+ continue -+} -+ - gdb_breakpoint [gdb_get_line_number "marker1 stop"] - gdb_continue_to_breakpoint "marker1 stop" - - gdb_test "print _a" "= 1" "print _a in a nested scope" - -+ -+gdb_exit -+gdb_start -+gdb_reinitialize_dir $srcdir/$subdir -+gdb_load ${binfile} -+ -+############################################ -+# test printing of namespace imported into -+# file scope. -+ -+ -+if ![runto marker5] then { -+ perror "couldn't run to breakpoint marker5" -+ continue -+} -+ -+gdb_test "print cc" "= 3" -+ -+gdb_exit -+gdb_start -+gdb_reinitialize_dir $srcdir/$subdir -+gdb_load ${binfile} -+ -+ - ############################################ - # Test printing of namespace aliases - --setup_kfail "gdb/7935" "*-*-*" - if ![runto marker2] then { - perror "couldn't run to breakpoint marker2" - continue - } - --gdb_test "print B::a" "= 1" -+gdb_test "print B::_a" "= 1" -+ -+gdb_test "print _a" "No symbol \"_a\" in current context." "print _a in namespace alias scope" -+gdb_test "print x" "No symbol \"x\" in current context." "print x in namespace alias scope" -+ -+gdb_exit -+gdb_start -+gdb_reinitialize_dir $srcdir/$subdir -+gdb_load ${binfile} -+ - - ############################################ - # Test that names are not printed when they - # are not imported - --gdb_breakpoint "marker3" --gdb_continue_to_breakpoint "marker3" -+if {![runto marker3]} { -+ perror "couldn't run to breakpoint marker3" -+} - --gdb_test "print _a" "No symbol \"_a\" in current context." "Print a without import" -+# gcc-4-3 puts import statements for aliases in -+# the global scope instead of the corresponding -+# function scope. These wrong import statements throw -+# this test off. This is fixed in gcc-4-4. -+if [test_compiler_info gcc-4-3-*] then { setup_xfail *-*-* } -+ -+gdb_test "print _a" "No symbol \"_a\" in current context." "Print _a without import" - - ############################################ - # Test printing of individually imported elements - --setup_kfail "gdb/7936" "*-*-*" - if ![runto marker4] then { - perror "couldn't run to breakpoint marker4" - continue - } - --gdb_test "print x" "= 2" -+gdb_test "print dx" "= 4" -+ -+############################################ -+# Test printing of namespace aliases -+ -+if ![runto marker5] then { -+ perror "couldn't run to marker5" -+ continue -+} -+ -+gdb_test "print efx" "= 5" -+ -+############################################ -+# Test printing of variables imported from -+# nested namespaces -+ -+if ![runto I::marker7] then { -+ perror "couldn't run to breakpoint I::marker7" -+ continue -+} -+ -+gdb_test "print ghx" "= 6" -+ -+############################################ -+# Test that variables are not printed in a namespace -+# that is sibling to the namespace containing an import -+ -+if ![runto L::marker8] then { -+ perror "couldn't run to breakpoint L::marker8" -+ continue -+} -+ -+gdb_test "print jx" "= 44" -+ -+gdb_breakpoint "K::marker9" -+gdb_continue_to_breakpoint "K::marker9" -+ -+gdb_test "print jx" "No symbol \"jx\" in current context." -+ -+############################################ -+# Test that variables are only printed after the line -+# containing the import -+ -+if ![runto_main] then { -+ perror "couldn't run to breakpoint main" -+ continue -+} -+ -+gdb_breakpoint [gdb_get_line_number "marker10 stop"] -+gdb_continue_to_breakpoint "marker10 stop" -+ -+# Assert that M::x is printed and not N::x -+gdb_test "print x" "= 911" "print x (from M::x)" -+ -diff --git a/gdb/testsuite/gdb.cp/namespace.exp b/gdb/testsuite/gdb.cp/namespace.exp -index 76b1b82..2042db2 100644 ---- a/gdb/testsuite/gdb.cp/namespace.exp -+++ b/gdb/testsuite/gdb.cp/namespace.exp -@@ -24,6 +24,7 @@ - # for namespaces. - # Note: As of 2000-06-03, they passed under g++ - djb - -+load_lib "cp-support.exp" - - if $tracelevel then { - strace $tracelevel -@@ -259,11 +260,16 @@ gdb_test "ptype E" "type = namespace C::D::E" - gdb_test "ptype CClass" "type = (class C::CClass \{\r\n public:|struct C::CClass \{)\r\n int x;\r\n\}" - gdb_test "ptype CClass::NestedClass" "type = (class C::CClass::NestedClass \{\r\n public:|struct C::CClass::NestedClass \{)\r\n int y;\r\n\}" - gdb_test "ptype NestedClass" "No symbol \"NestedClass\" in current context." --setup_kfail "gdb/1448" "*-*-*" --gdb_test "ptype ::C::CClass" "type = class C::CClass \{\r\n public:\r\n int x;\r\n\}" --setup_kfail "gdb/1448" "*-*-*" --gdb_test "ptype ::C::CClass::NestedClass" "type = class C::CClass::NestedClass \{\r\n public:\r\n int y;\r\n\}" --setup_kfail "gdb/1448" "*-*-*" -+cp_test_ptype_class \ -+ "ptype ::C::CClass" "" "class" "C::CClass" \ -+ { -+ { field public "int x;" } -+ } -+cp_test_ptype_class \ -+ "ptype ::C::CClass::NestedClass" "" "class" "C::CClass::NestedClass" \ -+ { -+ { field public "int y;" } -+ } - gdb_test "ptype ::C::NestedClass" "No symbol \"NestedClass\" in namespace \"C\"." - gdb_test "ptype C::CClass" "No symbol \"CClass\" in namespace \"C::C\"." - gdb_test "ptype C::CClass::NestedClass" "No type \"CClass\" within class or namespace \"C::C\"." -@@ -273,8 +279,11 @@ gdb_test "ptype C::NestedClass" "No symbol \"NestedClass\" in namespace \"C::C\" - - gdb_test "print cOtherFile" "\\$\[0-9\].* = 316" - gdb_test "ptype OtherFileClass" "type = (class C::OtherFileClass \{\r\n public:|struct C::OtherFileClass \{)\r\n int z;\r\n\}" --setup_kfail "gdb/1448" "*-*-*" --gdb_test "ptype ::C::OtherFileClass" "type = class C::OtherFileClass \{\r\n public:\r\n int z;\r\n\}" -+cp_test_ptype_class \ -+ "ptype ::C::OtherFileClass" "" "class" "C::OtherFileClass" \ -+ { -+ { field public "int z;" } -+ } - gdb_test "ptype C::OtherFileClass" "No symbol \"OtherFileClass\" in namespace \"C::C\"." - - # Some anonymous namespace tests. -diff --git a/gdb/testsuite/gdb.cp/overload.exp b/gdb/testsuite/gdb.cp/overload.exp -index 24025a2..a72932e 100644 ---- a/gdb/testsuite/gdb.cp/overload.exp -+++ b/gdb/testsuite/gdb.cp/overload.exp -@@ -74,12 +74,12 @@ set re_methods "${re_methods}${ws}int overload1arg\\((void|)\\);" - set re_methods "${re_methods}${ws}int overload1arg\\(char\\);" - set re_methods "${re_methods}${ws}int overload1arg\\(signed char\\);" - set re_methods "${re_methods}${ws}int overload1arg\\(unsigned char\\);" --set re_methods "${re_methods}${ws}int overload1arg\\(short\\);" --set re_methods "${re_methods}${ws}int overload1arg\\(unsigned short\\);" -+set re_methods "${re_methods}${ws}int overload1arg\\(short( int)?\\);" -+set re_methods "${re_methods}${ws}int overload1arg\\((unsigned short|short unsigned)( int)?\\);" - set re_methods "${re_methods}${ws}int overload1arg\\(int\\);" - set re_methods "${re_methods}${ws}int overload1arg\\(unsigned int\\);" --set re_methods "${re_methods}${ws}int overload1arg\\(long\\);" --set re_methods "${re_methods}${ws}int overload1arg\\(unsigned long\\);" -+set re_methods "${re_methods}${ws}int overload1arg\\(long( int)?\\);" -+set re_methods "${re_methods}${ws}int overload1arg\\((unsigned long|long unsigned)( int)?\\);" - set re_methods "${re_methods}${ws}int overload1arg\\(float\\);" - set re_methods "${re_methods}${ws}int overload1arg\\(double\\);" - set re_methods "${re_methods}${ws}int overloadfnarg\\((void|)\\);" -diff --git a/gdb/testsuite/gdb.cp/ovldbreak.exp b/gdb/testsuite/gdb.cp/ovldbreak.exp -index 8a6b795..9997a45 100644 ---- a/gdb/testsuite/gdb.cp/ovldbreak.exp -+++ b/gdb/testsuite/gdb.cp/ovldbreak.exp -@@ -127,10 +127,24 @@ proc set_bp_overloaded {name expectedmenu mychoice bpnumber linenumber} { - } - - # This is the expected menu for overload1arg. --# Note the arg type variations on lines 6 and 13. -+# Note the arg type variations for void and integer types. - # This accommodates different versions of g++. - --set menu_overload1arg "\\\[0\\\] cancel\r\n\\\[1\\\] all\r\n\\\[2\\\] foo::overload1arg\\(double\\) at.*$srcfile:121\r\n\\\[3\\\] foo::overload1arg\\(float\\) at.*$srcfile:120\r\n\\\[4\\\] foo::overload1arg\\(unsigned long\\) at.*$srcfile:119\r\n\\\[5\\\] foo::overload1arg\\(long\\) at.*$srcfile:118\r\n\\\[6\\\] foo::overload1arg\\((unsigned int|unsigned)\\) at.*$srcfile:117\r\n\\\[7\\\] foo::overload1arg\\(int\\) at.*$srcfile:116\r\n\\\[8\\\] foo::overload1arg\\(unsigned short\\) at.*$srcfile:115\r\n\\\[9\\\] foo::overload1arg\\(short\\) at.*$srcfile:114\r\n\\\[10\\\] foo::overload1arg\\(unsigned char\\) at.*$srcfile:113\r\n\\\[11\\\] foo::overload1arg\\(signed char\\) at.*$srcfile:112\r\n\\\[12\\\] foo::overload1arg\\(char\\) at.*$srcfile:111\r\n\\\[13\\\] foo::overload1arg\\((void|)\\) at.*$srcfile:110\r\n> $" -+set menu_overload1arg "\\\[0\\\] cancel\r\n" -+append menu_overload1arg "\\\[1\\\] all\r\n" -+append menu_overload1arg "\\\[2\\\] foo::overload1arg\\(double\\) at.*$srcfile:121\r\n" -+append menu_overload1arg "\\\[3\\\] foo::overload1arg\\(float\\) at.*$srcfile:120\r\n" -+append menu_overload1arg "\\\[4\\\] foo::overload1arg\\((unsigned long|long unsigned)( int)?\\) at.*$srcfile:119\r\n" -+append menu_overload1arg "\\\[5\\\] foo::overload1arg\\(long( int)?\\) at.*$srcfile:118\r\n" -+append menu_overload1arg "\\\[6\\\] foo::overload1arg\\((unsigned int|unsigned)\\) at.*$srcfile:117\r\n" -+append menu_overload1arg "\\\[7\\\] foo::overload1arg\\(int\\) at.*$srcfile:116\r\n" -+append menu_overload1arg "\\\[8\\\] foo::overload1arg\\((unsigned short|short unsigned)( int)?\\) at.*$srcfile:115\r\n" -+append menu_overload1arg "\\\[9\\\] foo::overload1arg\\(short( int)?\\) at.*$srcfile:114\r\n" -+append menu_overload1arg "\\\[10\\\] foo::overload1arg\\(unsigned char\\) at.*$srcfile:113\r\n" -+append menu_overload1arg "\\\[11\\\] foo::overload1arg\\(signed char\\) at.*$srcfile:112\r\n" -+append menu_overload1arg "\\\[12\\\] foo::overload1arg\\(char\\) at.*$srcfile:111\r\n" -+append menu_overload1arg "\\\[13\\\] foo::overload1arg\\((void|)\\) at.*$srcfile:110\r\n" -+append menu_overload1arg "> $" - - # Set multiple-symbols to "ask", to allow us to test the use - # of the multiple-choice menu when breaking on an overloaded method. -@@ -157,17 +171,17 @@ set_bp_overloaded "foo::overload1arg" "$menu_overload1arg" 13 13 110 - - gdb_test "info break" \ - "Num Type\[\t \]+Disp Enb Address\[\t \]+What.* --\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in main at.*$srcfile:49\r -+\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in main(\\((|void)\\))? at.*$srcfile:49\r - \[\t \]+breakpoint already hit 1 time\r - \[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(char\\) at.*$srcfile:111\r - \[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(signed char\\) at.*$srcfile:112\r - \[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(unsigned char\\) at.*$srcfile:113\r --\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(short\\) at.*$srcfile:114\r --\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(unsigned short\\) at.*$srcfile:115\r -+\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(short( int)?\\) at.*$srcfile:114\r -+\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\((unsigned short|short unsigned)( int)?\\) at.*$srcfile:115\r - \[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(int\\) at.*$srcfile:116\r - \[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\((unsigned|unsigned int)\\) at.*$srcfile:117\r --\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(long\\) at.*$srcfile:118\r --\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(unsigned long\\) at.*$srcfile:119\r -+\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(long( int)?\\) at.*$srcfile:118\r -+\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\((unsigned long|long unsigned)( int)?\\) at.*$srcfile:119\r - \[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(float\\) at.*$srcfile:120\r - \[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(double\\) at.*$srcfile:121\r - \[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\((void|)\\) at.*$srcfile:110" \ -@@ -215,17 +229,17 @@ gdb_expect { - - gdb_test "info break" \ - "Num Type\[\t \]+Disp Enb Address\[\t \]+What.* --\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in main at.*$srcfile:49\r -+\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in main(\\((|void)\\))? at.*$srcfile:49\r - \[\t \]+breakpoint already hit 1 time\r - \[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(char\\) at.*$srcfile:111\r - \[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(signed char\\) at.*$srcfile:112\r - \[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(unsigned char\\) at.*$srcfile:113\r --\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(short\\) at.*$srcfile:114\r --\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(unsigned short\\) at.*$srcfile:115\r -+\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(short( int)?\\) at.*$srcfile:114\r -+\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\((unsigned short|short unsigned)( int)?\\) at.*$srcfile:115\r - \[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(int\\) at.*$srcfile:116\r - \[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\((unsigned|unsigned int)\\) at.*$srcfile:117\r --\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(long\\) at.*$srcfile:118\r --\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(unsigned long\\) at.*$srcfile:119\r -+\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(long( int)?\\) at.*$srcfile:118\r -+\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\((unsigned long|long unsigned)( int)?\\) at.*$srcfile:119\r - \[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(float\\) at.*$srcfile:120\r - \[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(double\\) at.*$srcfile:121\r - \[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\((void|)\\) at.*$srcfile:110" \ -@@ -296,12 +310,12 @@ gdb_test "info break" \ - "Num Type\[\t \]+Disp Enb Address\[\t \]+What.* - \[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(double\\) at.*$srcfile:121\r - \[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(float\\) at.*$srcfile:120\r --\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(unsigned long\\) at.*$srcfile:119\r --\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(long\\) at.*$srcfile:118\r -+\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\((unsigned long|long unsigned)( int)?\\) at.*$srcfile:119\r -+\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(long( int)?\\) at.*$srcfile:118\r - \[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\((unsigned|unsigned int)\\) at.*$srcfile:117\r - \[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(int\\) at.*$srcfile:116\r --\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(unsigned short\\) at.*$srcfile:115\r --\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(short\\) at.*$srcfile:114\r -+\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\((unsigned short|short unsigned)( int)?\\) at.*$srcfile:115\r -+\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(short( int)?\\) at.*$srcfile:114\r - \[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(unsigned char\\) at.*$srcfile:113\r - \[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(signed char\\) at.*$srcfile:112\r - \[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(char\\) at.*$srcfile:111\r -diff --git a/gdb/testsuite/gdb.cp/shadowing.cc b/gdb/testsuite/gdb.cp/shadowing.cc -new file mode 100644 -index 0000000..6d9c2f1 ---- /dev/null -+++ b/gdb/testsuite/gdb.cp/shadowing.cc -@@ -0,0 +1,48 @@ -+namespace A -+{ -+ int x = 11; -+} -+ -+int x = 22; -+int y = 0; -+ -+class B -+{ -+public: -+ int x; -+ -+ int -+ func() -+ { -+ x = 33; -+ y+=x; // marker1 -+ -+ { -+ int x = 44; -+ y+=x; // marker2 -+ -+ { -+ int x = 55; -+ y+=x; // marker3 -+ -+ { -+ int z = x; //prevent gcc from optimizing away this scope -+ using namespace A; -+ y+=x; // marker4 -+ -+ using A::x; -+ y+=x; // marker5 -+ -+ return this->x; -+ } -+ } -+ } -+ } -+}; -+ -+int -+main() -+{ -+ B theB; -+ return theB.func(); -+} -diff --git a/gdb/testsuite/gdb.cp/shadowing.exp b/gdb/testsuite/gdb.cp/shadowing.exp -new file mode 100644 -index 0000000..6922eed ---- /dev/null -+++ b/gdb/testsuite/gdb.cp/shadowing.exp -@@ -0,0 +1,91 @@ -+# Copyright 2008 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 $tracelevel then { -+ strace $tracelevel -+} -+ -+set prms_id 0 -+set bug_id 0 -+ -+set testfile shadowing -+set srcfile ${testfile}.cc -+set binfile ${objdir}/${subdir}/${testfile} -+if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } { -+ untested "Couldn't compile test program" -+ return -1 -+} -+ -+if [get_compiler_info ${binfile}] { -+ return -1; -+} -+ -+# Get things started. -+ -+gdb_exit -+gdb_start -+gdb_reinitialize_dir $srcdir/$subdir -+gdb_load ${binfile} -+ -+if ![runto_main] then { -+ perror "couldn't run to breakpoint main" -+ continue -+} -+ -+############################################ -+# Test printing of class variable is not shadowed -+# by global variable -+ -+gdb_breakpoint [gdb_get_line_number "marker1"] -+gdb_continue_to_breakpoint "marker1" -+ -+gdb_test "print x" "= 33" "Print class x shadowing global x" -+ -+ -+############################################ -+# Test printing local variable is not shadowed -+# by class variable -+ -+gdb_breakpoint [gdb_get_line_number "marker2"] -+gdb_continue_to_breakpoint "marker2" -+ -+gdb_test "print x" "= 44" "Print local x shadowing class x" -+ -+############################################ -+# Test inner scope x is printed not outer scope -+ -+gdb_breakpoint [gdb_get_line_number "marker3"] -+gdb_continue_to_breakpoint "marker3" -+ -+gdb_test "print x" "= 55" "Print inner scope x" -+ -+############################################ -+# Test printing local variable is not shadowed -+# by namespace variable -+ -+gdb_breakpoint [gdb_get_line_number "marker4"] -+gdb_continue_to_breakpoint "marker4" -+ -+gdb_test "print x" "= 55" "Print local x not namespace x" -+ -+############################################ -+# Test imported namespace element is printed -+ -+gdb_breakpoint [gdb_get_line_number "marker5"] -+gdb_continue_to_breakpoint "marker5" -+ -+if [test_compiler_info gcc-4-3-*] then { setup_xfail *-*-* } -+ -+gdb_test "print x" "= 11" "Print imported namespace x" -diff --git a/gdb/testsuite/gdb.dwarf2/dw2-aranges.S b/gdb/testsuite/gdb.dwarf2/dw2-aranges.S -new file mode 100644 -index 0000000..d5b9ca5 ---- /dev/null -+++ b/gdb/testsuite/gdb.dwarf2/dw2-aranges.S -@@ -0,0 +1,140 @@ -+/* This testcase is part of GDB, the GNU debugger. -+ -+ Copyright 2004, 2007, 2008, 2009 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 . */ -+ -+/* Test .debug_aranges containing zero address_size. */ -+ -+/* Dummy function to provide debug information for. */ -+ ++++ b/gdb/testsuite/gdb.arch/x86_64-vla-pointer-foo.S +@@ -0,0 +1,457 @@ ++ .file "x86_64-vla-pointer.c" ++ .section .debug_abbrev,"",@progbits ++.Ldebug_abbrev0: ++ .section .debug_info,"",@progbits ++.Ldebug_info0: ++ .section .debug_line,"",@progbits ++.Ldebug_line0: + .text -+.Lbegin_text1: -+ .globl main -+ .type main, %function -+main: -+.Lbegin_main: -+ .int 0 -+.Lend_main: -+ .size main, .-main -+.Lend_text1: -+ -+/* Debug information */ -+ -+ .section .debug_info -+.Lcu1_begin: -+ /* CU header */ -+ .4byte .Lcu1_end - .Lcu1_start /* Length of Compilation Unit */ -+.Lcu1_start: -+ .2byte 2 /* DWARF Version */ -+ .4byte .Labbrev1_begin /* Offset into abbrev section */ -+ .byte 4 /* Pointer size */ -+ -+ /* CU die */ -+ .uleb128 1 /* Abbrev: DW_TAG_compile_unit */ -+ .4byte .Lend_text1 /* DW_AT_high_pc */ -+ .4byte .Lbegin_text1 /* DW_AT_low_pc */ -+ .ascii "file1.txt\0" /* DW_AT_name */ -+ .ascii "GNU C 3.3.3\0" /* DW_AT_producer */ -+ .byte 1 /* DW_AT_language (C) */ -+ -+ /* main */ -+ .uleb128 2 /* Abbrev: DW_TAG_subprogram */ -+ .byte 1 /* DW_AT_external */ -+ .byte 1 /* DW_AT_decl_file */ -+ .byte 2 /* DW_AT_decl_line */ -+ .ascii "main\0" /* DW_AT_name */ -+ .4byte .Ltype_int-.Lcu1_begin /* DW_AT_type */ -+ .4byte .Lbegin_main /* DW_AT_low_pc */ -+ .4byte .Lend_main /* DW_AT_high_pc */ -+ .byte 1 /* DW_AT_frame_base: length */ -+ .byte 0x55 /* DW_AT_frame_base: DW_OP_reg5 */ -+ -+.Ltype_int: -+ .uleb128 3 /* Abbrev: DW_TAG_base_type */ -+ .ascii "int\0" /* DW_AT_name */ -+ .byte 4 /* DW_AT_byte_size */ -+ .byte 5 /* DW_AT_encoding */ -+ -+ .byte 0 /* End of children of CU */ -+ -+.Lcu1_end: -+ -+/* Abbrev table */ -+ .section .debug_abbrev -+.Labbrev1_begin: -+ .uleb128 1 /* Abbrev code */ -+ .uleb128 0x11 /* DW_TAG_compile_unit */ -+ .byte 1 /* has_children */ -+ .uleb128 0x12 /* DW_AT_high_pc */ -+ .uleb128 0x1 /* DW_FORM_addr */ -+ .uleb128 0x11 /* DW_AT_low_pc */ -+ .uleb128 0x1 /* DW_FORM_addr */ -+ .uleb128 0x3 /* DW_AT_name */ -+ .uleb128 0x8 /* DW_FORM_string */ -+ .uleb128 0x25 /* DW_AT_producer */ -+ .uleb128 0x8 /* DW_FORM_string */ -+ .uleb128 0x13 /* DW_AT_language */ -+ .uleb128 0xb /* DW_FORM_data1 */ -+ .byte 0x0 /* Terminator */ -+ .byte 0x0 /* Terminator */ -+ -+ .uleb128 2 /* Abbrev code */ -+ .uleb128 0x2e /* DW_TAG_subprogram */ -+ .byte 0 /* has_children */ -+ .uleb128 0x3f /* DW_AT_external */ -+ .uleb128 0xc /* DW_FORM_flag */ -+ .uleb128 0x3a /* DW_AT_decl_file */ -+ .uleb128 0xb /* DW_FORM_data1 */ -+ .uleb128 0x3b /* DW_AT_decl_line */ -+ .uleb128 0xb /* DW_FORM_data1 */ -+ .uleb128 0x3 /* DW_AT_name */ -+ .uleb128 0x8 /* DW_FORM_string */ -+ .uleb128 0x49 /* DW_AT_type */ -+ .uleb128 0x13 /* DW_FORM_ref4 */ -+ .uleb128 0x11 /* DW_AT_low_pc */ -+ .uleb128 0x1 /* DW_FORM_addr */ -+ .uleb128 0x12 /* DW_AT_high_pc */ -+ .uleb128 0x1 /* DW_FORM_addr */ -+ .uleb128 0x40 /* DW_AT_frame_base */ -+ .uleb128 0xa /* DW_FORM_block1 */ -+ .byte 0x0 /* Terminator */ -+ .byte 0x0 /* Terminator */ -+ -+ .uleb128 3 /* Abbrev code */ -+ .uleb128 0x24 /* DW_TAG_base_type */ -+ .byte 0 /* has_children */ -+ .uleb128 0x3 /* DW_AT_name */ -+ .uleb128 0x8 /* DW_FORM_string */ -+ .uleb128 0xb /* DW_AT_byte_size */ -+ .uleb128 0xb /* DW_FORM_data1 */ -+ .uleb128 0x3e /* DW_AT_encoding */ -+ .uleb128 0xb /* DW_FORM_data1 */ -+ .byte 0x0 /* Terminator */ -+ .byte 0x0 /* Terminator */ -+ -+ .byte 0x0 /* Terminator */ -+ .byte 0x0 /* Terminator */ -+ -+/* aranges table */ -+ .section .debug_aranges -+ .long .Laranges_end - 1f -+1: -+ .2byte 2 /* aranges Version */ -+ .4byte .Lcu1_begin - .debug_info /* Offset into .debug_info section */ -+ /* The GDB crasher is this zero value. */ -+ .byte 0 /* aranges address_size */ -+ .byte 0 /* aranges segment_size */ -+ -+.Laranges_end: -diff --git a/gdb/testsuite/gdb.dwarf2/dw2-aranges.exp b/gdb/testsuite/gdb.dwarf2/dw2-aranges.exp -new file mode 100644 -index 0000000..39632d5 ---- /dev/null -+++ b/gdb/testsuite/gdb.dwarf2/dw2-aranges.exp -@@ -0,0 +1,40 @@ -+# Copyright 2004, 2005, 2007, 2008, 2009 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 . -+ -+# Test .debug_aranges containing zero address_size. -+ -+# This test can only be run on targets which support DWARF-2 and use gas. -+# For now pick a sampling of likely targets. -+if {![istarget *-*-linux*] -+ && ![istarget *-*-gnu*] -+ && ![istarget *-*-elf*] -+ && ![istarget *-*-openbsd*] -+ && ![istarget arm-*-eabi*] -+ && ![istarget powerpc-*-eabi*]} { -+ return 0 -+} -+ -+set testfile "dw2-aranges" -+set srcfile ${testfile}.S -+set binfile ${objdir}/${subdir}/${testfile} -+ -+if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {nodebug}] != "" } { -+ return -1 -+} -+ -+clean_restart $testfile -+ -+# Failed gdb_load would abort the testcase execution earlier. -+pass "file loaded" -diff --git a/gdb/testsuite/gdb.dwarf2/dw2-stripped.c b/gdb/testsuite/gdb.dwarf2/dw2-stripped.c ++.Ltext0: ++.globl foo ++ .type foo, @function ++foo: ++.LFB2: ++ .file 1 "x86_64-vla-pointer.c" ++ .loc 1 22 0 ++ pushq %rbp ++.LCFI0: ++ movq %rsp, %rbp ++.LCFI1: ++ subq $64, %rsp ++.LCFI2: ++ movl %edi, -36(%rbp) ++ .loc 1 22 0 ++ movq %rsp, %rax ++ movq %rax, -48(%rbp) ++ .loc 1 23 0 ++ movl -36(%rbp), %edx ++ movslq %edx,%rax ++ subq $1, %rax ++ movq %rax, -24(%rbp) ++ .loc 1 24 0 ++ movslq %edx,%rax ++ addq $15, %rax ++ addq $15, %rax ++ shrq $4, %rax ++ salq $4, %rax ++ subq %rax, %rsp ++ movq %rsp, -56(%rbp) ++ movq -56(%rbp), %rax ++ addq $15, %rax ++ shrq $4, %rax ++ salq $4, %rax ++ movq %rax, -56(%rbp) ++ movq -56(%rbp), %rax ++ movq %rax, -16(%rbp) ++ .loc 1 27 0 ++ movl $0, -4(%rbp) ++ jmp .L2 ++.L3: ++ .loc 1 28 0 ++ movl -4(%rbp), %esi ++ movl -4(%rbp), %eax ++ movl %eax, %ecx ++ movq -16(%rbp), %rdx ++ movslq %esi,%rax ++ movb %cl, (%rdx,%rax) ++ .loc 1 27 0 ++ addl $1, -4(%rbp) ++.L2: ++ movl -4(%rbp), %eax ++ cmpl -36(%rbp), %eax ++ jl .L3 ++ .loc 1 30 0 ++ .globl break_here ++break_here: ++ movq -16(%rbp), %rax ++ movb $0, (%rax) ++ movq -48(%rbp), %rsp ++ .loc 1 31 0 ++ leave ++ ret ++.LFE2: ++ .size foo, .-foo ++ .section .debug_frame,"",@progbits ++.Lframe0: ++ .long .LECIE0-.LSCIE0 ++.LSCIE0: ++ .long 0xffffffff ++ .byte 0x1 ++ .string "" ++ .uleb128 0x1 ++ .sleb128 -8 ++ .byte 0x10 ++ .byte 0xc ++ .uleb128 0x7 ++ .uleb128 0x8 ++ .byte 0x90 ++ .uleb128 0x1 ++ .align 8 ++.LECIE0: ++.LSFDE0: ++ .long .LEFDE0-.LASFDE0 ++.LASFDE0: ++ .long .Lframe0 ++ .quad .LFB2 ++ .quad .LFE2-.LFB2 ++ .byte 0x4 ++ .long .LCFI0-.LFB2 ++ .byte 0xe ++ .uleb128 0x10 ++ .byte 0x86 ++ .uleb128 0x2 ++ .byte 0x4 ++ .long .LCFI1-.LCFI0 ++ .byte 0xd ++ .uleb128 0x6 ++ .align 8 ++.LEFDE0: ++ .section .eh_frame,"a",@progbits ++.Lframe1: ++ .long .LECIE1-.LSCIE1 ++.LSCIE1: ++ .long 0x0 ++ .byte 0x1 ++ .string "zR" ++ .uleb128 0x1 ++ .sleb128 -8 ++ .byte 0x10 ++ .uleb128 0x1 ++ .byte 0x3 ++ .byte 0xc ++ .uleb128 0x7 ++ .uleb128 0x8 ++ .byte 0x90 ++ .uleb128 0x1 ++ .align 8 ++.LECIE1: ++.LSFDE1: ++ .long .LEFDE1-.LASFDE1 ++.LASFDE1: ++ .long .LASFDE1-.Lframe1 ++ .long .LFB2 ++ .long .LFE2-.LFB2 ++ .uleb128 0x0 ++ .byte 0x4 ++ .long .LCFI0-.LFB2 ++ .byte 0xe ++ .uleb128 0x10 ++ .byte 0x86 ++ .uleb128 0x2 ++ .byte 0x4 ++ .long .LCFI1-.LCFI0 ++ .byte 0xd ++ .uleb128 0x6 ++ .align 8 ++.LEFDE1: ++ .text ++.Letext0: ++ .section .debug_loc,"",@progbits ++.Ldebug_loc0: ++.LLST0: ++ .quad .LFB2-.Ltext0 ++ .quad .LCFI0-.Ltext0 ++ .value 0x2 ++ .byte 0x77 ++ .sleb128 8 ++ .quad .LCFI0-.Ltext0 ++ .quad .LCFI1-.Ltext0 ++ .value 0x2 ++ .byte 0x77 ++ .sleb128 16 ++ .quad .LCFI1-.Ltext0 ++ .quad .LFE2-.Ltext0 ++ .value 0x2 ++ .byte 0x76 ++ .sleb128 16 ++ .quad 0x0 ++ .quad 0x0 ++ .section .debug_info ++.Ldebug_relative: ++ .long .Ldebug_end - .Ldebug_start ++.Ldebug_start: ++ .value 0x2 ++ .long .Ldebug_abbrev0 ++ .byte 0x8 ++ .uleb128 0x1 ++ .long .LASF2 ++ .byte 0x1 ++ .long .LASF3 ++ .long .LASF4 ++ .quad .Ltext0 ++ .quad .Letext0 ++ .long .Ldebug_line0 ++ .uleb128 0x2 ++ .byte 0x1 ++ .string "foo" ++ .byte 0x1 ++ .byte 0x16 ++ .byte 0x1 ++ .quad .LFB2 ++ .quad .LFE2 ++ .long .LLST0 ++ .long .Ltype_int - .Ldebug_relative ++ .uleb128 0x3 ++ .long .LASF5 ++ .byte 0x1 ++ .byte 0x15 ++ .long .Ltype_int - .Ldebug_relative ++ .byte 0x2 ++ .byte 0x91 ++ .sleb128 -52 ++.Ltag_pointer: ++ .uleb128 0x4 ++ .byte 0x8 /* DW_AT_byte_size */ ++ .long .Ltag_array_type - .debug_info /* DW_AT_type */ ++ .uleb128 0x5 /* Abbrev Number: 5 (DW_TAG_variable) */ ++ .long .LASF0 ++ .byte 0x1 ++ .byte 0x18 ++#if 1 ++ .long .Ltag_pointer - .debug_info ++#else ++ /* Debugging only: Skip the typedef indirection. */ ++ .long .Ltag_array_type - .debug_info ++#endif ++ /* DW_AT_location: DW_FORM_block1: start */ ++ .byte 0x3 ++ .byte 0x91 ++ .sleb128 -32 ++#if 0 ++ .byte 0x6 /* DW_OP_deref */ ++#else ++ .byte 0x96 /* DW_OP_nop */ ++#endif ++ /* DW_AT_location: DW_FORM_block1: end */ ++ .uleb128 0x6 ++ .string "i" ++ .byte 0x1 ++ .byte 0x19 ++ .long .Ltype_int - .Ldebug_relative ++ .byte 0x2 ++ .byte 0x91 ++ .sleb128 -20 ++ .byte 0x0 ++.Ltype_int: ++ .uleb128 0x7 ++ .byte 0x4 ++ .byte 0x5 ++ .string "int" ++.Ltag_array_type: ++ .uleb128 0x8 /* Abbrev Number: 8 (DW_TAG_array_type) */ ++ .long .Ltype_char - .Ldebug_relative ++ .long .Ltype_ulong - .Ldebug_relative /* DW_AT_sibling: DW_FORM_ref4 */ ++1: /* DW_AT_data_location: DW_FORM_block1: start */ ++ .byte 2f - 3f /* length */ ++3: ++ .byte 0x97 /* DW_OP_push_object_address */ ++#if 1 ++ .byte 0x6 /* DW_OP_deref */ ++#else ++ .byte 0x96 /* DW_OP_nop */ ++#endif ++2: /* DW_AT_data_location: DW_FORM_block1: end */ ++ .uleb128 0x9 ++ .long .Ltype_char - .Ldebug_relative /* DW_AT_type: DW_FORM_ref4 */ ++ .byte 0x3 ++ .byte 0x91 ++ .sleb128 -40 ++ .byte 0x6 ++ .byte 0x0 ++.Ltype_ulong: ++ .uleb128 0xa ++ .byte 0x8 ++ .byte 0x7 ++.Ltype_char: ++ .uleb128 0xb ++ .byte 0x1 ++ .byte 0x6 ++ .long .LASF1 ++ .byte 0x0 ++.Ldebug_end: ++ .section .debug_abbrev ++ .uleb128 0x1 ++ .uleb128 0x11 ++ .byte 0x1 ++ .uleb128 0x25 ++ .uleb128 0xe ++ .uleb128 0x13 ++ .uleb128 0xb ++ .uleb128 0x3 ++ .uleb128 0xe ++ .uleb128 0x1b ++ .uleb128 0xe ++ .uleb128 0x11 ++ .uleb128 0x1 ++ .uleb128 0x12 ++ .uleb128 0x1 ++ .uleb128 0x10 ++ .uleb128 0x6 ++ .byte 0x0 ++ .byte 0x0 ++ .uleb128 0x2 ++ .uleb128 0x2e ++ .byte 0x1 ++ .uleb128 0x3f ++ .uleb128 0xc ++ .uleb128 0x3 ++ .uleb128 0x8 ++ .uleb128 0x3a ++ .uleb128 0xb ++ .uleb128 0x3b ++ .uleb128 0xb ++ .uleb128 0x27 ++ .uleb128 0xc ++ .uleb128 0x11 ++ .uleb128 0x1 ++ .uleb128 0x12 ++ .uleb128 0x1 ++ .uleb128 0x40 ++ .uleb128 0x6 ++ .uleb128 0x1 ++ .uleb128 0x13 ++ .byte 0x0 ++ .byte 0x0 ++ .uleb128 0x3 ++ .uleb128 0x5 ++ .byte 0x0 ++ .uleb128 0x3 ++ .uleb128 0xe ++ .uleb128 0x3a ++ .uleb128 0xb ++ .uleb128 0x3b ++ .uleb128 0xb ++ .uleb128 0x49 ++ .uleb128 0x13 ++ .uleb128 0x2 ++ .uleb128 0xa ++ .byte 0x0 ++ .byte 0x0 ++ .uleb128 0x4 /* .Ltag_pointer abbrev */ ++ .uleb128 0x0f /* DW_TAG_pointer_type */ ++ .byte 0x0 ++ .uleb128 0x0b ++ .uleb128 0xb ++ .uleb128 0x49 ++ .uleb128 0x13 ++ .byte 0x0 ++ .byte 0x0 ++ .uleb128 0x5 ++ .uleb128 0x34 ++ .byte 0x0 ++ .uleb128 0x3 ++ .uleb128 0xe ++ .uleb128 0x3a ++ .uleb128 0xb ++ .uleb128 0x3b ++ .uleb128 0xb ++ .uleb128 0x49 ++ .uleb128 0x13 ++ .uleb128 0x2 ++ .uleb128 0xa ++ .byte 0x0 ++ .byte 0x0 ++ .uleb128 0x6 ++ .uleb128 0x34 ++ .byte 0x0 ++ .uleb128 0x3 ++ .uleb128 0x8 ++ .uleb128 0x3a ++ .uleb128 0xb ++ .uleb128 0x3b ++ .uleb128 0xb ++ .uleb128 0x49 ++ .uleb128 0x13 ++ .uleb128 0x2 ++ .uleb128 0xa ++ .byte 0x0 ++ .byte 0x0 ++ .uleb128 0x7 ++ .uleb128 0x24 ++ .byte 0x0 ++ .uleb128 0xb ++ .uleb128 0xb ++ .uleb128 0x3e ++ .uleb128 0xb ++ .uleb128 0x3 ++ .uleb128 0x8 ++ .byte 0x0 ++ .byte 0x0 ++ .uleb128 0x8 /* Abbrev Number: 8 (DW_TAG_array_type) */ ++ .uleb128 0x1 ++ .byte 0x1 ++ .uleb128 0x49 /* DW_AT_type */ ++ .uleb128 0x13 /* DW_FORM_ref4 */ ++ .uleb128 0x1 /* DW_AT_sibling */ ++ .uleb128 0x13 /* DW_FORM_ref4 */ ++ .uleb128 0x50 /* DW_AT_data_location */ ++ .uleb128 0xa /* DW_FORM_block1 */ ++ .byte 0x0 ++ .byte 0x0 ++ .uleb128 0x9 ++ .uleb128 0x21 ++ .byte 0x0 ++ .uleb128 0x49 /* DW_AT_type */ ++ .uleb128 0x13 /* DW_FORM_ref4 */ ++ .uleb128 0x2f ++ .uleb128 0xa ++ .byte 0x0 ++ .byte 0x0 ++ .uleb128 0xa ++ .uleb128 0x24 ++ .byte 0x0 ++ .uleb128 0xb ++ .uleb128 0xb ++ .uleb128 0x3e ++ .uleb128 0xb ++ .byte 0x0 ++ .byte 0x0 ++ .uleb128 0xb ++ .uleb128 0x24 ++ .byte 0x0 ++ .uleb128 0xb ++ .uleb128 0xb ++ .uleb128 0x3e ++ .uleb128 0xb ++ .uleb128 0x3 ++ .uleb128 0xe ++ .byte 0x0 ++ .byte 0x0 ++ .byte 0x0 ++ .section .debug_pubnames,"",@progbits ++ .long 0x16 ++ .value 0x2 ++ .long .Ldebug_info0 ++ .long 0xa8 ++ .long 0x2d ++ .string "foo" ++ .long 0x0 ++ .section .debug_aranges,"",@progbits ++ .long 0x2c ++ .value 0x2 ++ .long .Ldebug_info0 ++ .byte 0x8 ++ .byte 0x0 ++ .value 0x0 ++ .value 0x0 ++ .quad .Ltext0 ++ .quad .Letext0-.Ltext0 ++ .quad 0x0 ++ .quad 0x0 ++ .section .debug_str,"MS",@progbits,1 ++.LASF0: ++ .string "array" ++.LASF5: ++ .string "size" ++.LASF3: ++ .string "x86_64-vla-pointer.c" ++.LASF6: ++ .string "array_t" ++.LASF1: ++ .string "char" ++.LASF4: ++ .string "gdb.arch" ++.LASF2: ++ .string "GNU C 4.3.2 20081105 (Red Hat 4.3.2-7)" ++ .ident "GCC: (GNU) 4.3.2 20081105 (Red Hat 4.3.2-7)" ++ .section .note.GNU-stack,"",@progbits +diff --git a/gdb/testsuite/gdb.arch/x86_64-vla-pointer.c b/gdb/testsuite/gdb.arch/x86_64-vla-pointer.c new file mode 100644 -index 0000000..1f02d90 +index 0000000..fe2c8f7 --- /dev/null -+++ b/gdb/testsuite/gdb.dwarf2/dw2-stripped.c -@@ -0,0 +1,42 @@ ++++ b/gdb/testsuite/gdb.arch/x86_64-vla-pointer.c +@@ -0,0 +1,43 @@ +/* This testcase is part of GDB, the GNU debugger. + -+ Copyright 2004 Free Software Foundation, Inc. ++ Copyright 2009 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 ++ 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, write to the Free Software -+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, -+ USA. */ + ++ You should have received a copy of the GNU General Public License ++ along with this program. If not, see . */ + -+/* The function `func1' traced into must have debug info on offset > 0; -+ (DW_UNSND (attr)). This is the reason of `func0' existence. */ ++#if 0 + +void -+func0(int a, int b) ++foo (int size) +{ -+} ++ typedef char array_t[size]; ++ array_t array; ++ int i; + -+/* `func1' being traced into must have some arguments to dump. */ ++ for (i = 0; i < size; i++) ++ array[i] = i; + -+void -+func1(int a, int b) -+{ -+ func0 (a,b); ++ array[0] = 0; /* break-here */ +} + ++#else ++ +int -+main(void) ++main (void) +{ -+ func1 (1, 2); ++ foo (26); ++ foo (78); + return 0; +} -diff --git a/gdb/testsuite/gdb.dwarf2/dw2-stripped.exp b/gdb/testsuite/gdb.dwarf2/dw2-stripped.exp -new file mode 100644 -index 0000000..1c6e84a ---- /dev/null -+++ b/gdb/testsuite/gdb.dwarf2/dw2-stripped.exp -@@ -0,0 +1,79 @@ -+# Copyright 2006 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. -+ -+# Minimal DWARF-2 unit test -+ -+# This test can only be run on targets which support DWARF-2. -+# For now pick a sampling of likely targets. -+if {![istarget *-*-linux*] -+ && ![istarget *-*-gnu*] -+ && ![istarget *-*-elf*] -+ && ![istarget *-*-openbsd*] -+ && ![istarget arm-*-eabi*] -+ && ![istarget powerpc-*-eabi*]} { -+ return 0 -+} -+ -+set testfile "dw2-stripped" -+set srcfile ${testfile}.c -+set binfile ${objdir}/${subdir}/${testfile}.x -+ -+remote_exec build "rm -f ${binfile}" -+ -+# get the value of gcc_compiled -+if [get_compiler_info ${binfile}] { -+ return -1 -+} -+ -+# This test can only be run on gcc as we use additional_flags=FIXME -+if {$gcc_compiled == 0} { -+ return 0 -+} -+ -+if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-ggdb3}] != "" } { -+ return -1 -+} -+ -+remote_exec build "objcopy -R .debug_loc ${binfile}" -+set strip_output [remote_exec build "objdump -h ${binfile}"] -+ -+set test "stripping test file preservation" -+if [ regexp ".debug_info " $strip_output] { -+ pass "$test (.debug_info preserved)" -+} else { -+ fail "$test (.debug_info got also stripped)" -+} -+ -+set test "stripping test file functionality" -+if [ regexp ".debug_loc " $strip_output] { -+ fail "$test (.debug_loc still present)" -+} else { -+ pass "$test (.debug_loc stripped)" -+} -+ -+gdb_exit -+gdb_start -+gdb_reinitialize_dir $srcdir/$subdir -+gdb_load ${binfile} -+ -+# For C programs, "start" should stop in main(). -+ -+gdb_test "start" \ -+ ".*main \\(\\) at .*" \ -+ "start" -+gdb_test "step" \ -+ "func.* \\(.*\\) at .*" \ -+ "step" -diff --git a/gdb/testsuite/gdb.dwarf2/dw2-struct-member-data-location.S b/gdb/testsuite/gdb.dwarf2/dw2-struct-member-data-location.S -new file mode 100644 -index 0000000..5fcdd84 ---- /dev/null -+++ b/gdb/testsuite/gdb.dwarf2/dw2-struct-member-data-location.S -@@ -0,0 +1,83 @@ -+/* This testcase is part of GDB, the GNU debugger. -+ -+ Copyright 2009 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 . */ -+ -+/* Debug information */ -+ -+ .section .debug_info -+.Lcu1_begin: -+ /* CU header */ -+ .4byte .Lcu1_end - .Lcu1_start /* Length of Compilation Unit */ -+.Lcu1_start: -+ .2byte 2 /* DWARF Version */ -+ .4byte .Labbrev1_begin /* Offset into abbrev section */ -+ .byte 4 /* Pointer size */ -+ -+ /* CU die */ -+ .uleb128 1 /* Abbrev: DW_TAG_compile_unit */ -+ .ascii "dw2-struct-member-data-location.c\0" /* DW_AT_name */ -+ .ascii "GNU C 4.3.2\0" /* DW_AT_producer */ -+ .byte 1 /* DW_AT_language (C) */ -+ -+.Ltype_uchar: -+ .uleb128 2 /* Abbrev: DW_TAG_structure_type */ -+ .ascii "some_struct\0" /* DW_AT_name */ -+ -+ .uleb128 3 /* Abbrev: DW_TAG_member */ -+ .ascii "field\0" /* DW_AT_name */ -+ .byte 0 /* DW_AT_data_member_location */ -+ -+ .byte 0 /* End of children of some_struct */ -+ -+ .byte 0 /* End of children of CU */ -+ -+.Lcu1_end: -+ -+/* Abbrev table */ -+ .section .debug_abbrev -+.Labbrev1_begin: -+ .uleb128 1 /* Abbrev code */ -+ .uleb128 0x11 /* DW_TAG_compile_unit */ -+ .byte 1 /* has_children */ -+ .uleb128 0x3 /* DW_AT_name */ -+ .uleb128 0x8 /* DW_FORM_string */ -+ .uleb128 0x25 /* DW_AT_producer */ -+ .uleb128 0x8 /* DW_FORM_string */ -+ .uleb128 0x13 /* DW_AT_language */ -+ .uleb128 0xb /* DW_FORM_data1 */ -+ .byte 0x0 /* Terminator */ -+ .byte 0x0 /* Terminator */ -+ -+ .uleb128 2 /* Abbrev code */ -+ .uleb128 0x13 /* DW_TAG_structure_type */ -+ .byte 1 /* has_children */ -+ .uleb128 0x3 /* DW_AT_name */ -+ .uleb128 0x8 /* DW_FORM_string */ -+ .byte 0x0 /* Terminator */ -+ .byte 0x0 /* Terminator */ -+ -+ .uleb128 3 /* Abbrev code */ -+ .uleb128 0x0d /* DW_TAG_member */ -+ .byte 0 /* has_children */ -+ .uleb128 0x3 /* DW_AT_name */ -+ .uleb128 0x8 /* DW_FORM_string */ -+ .uleb128 0x38 /* DW_AT_data_member_location */ -+ .uleb128 0x0b /* DW_FORM_data1 */ -+ .byte 0x0 /* Terminator */ -+ .byte 0x0 /* Terminator */ + -+ .byte 0x0 /* Terminator */ -+ .byte 0x0 /* Terminator */ -diff --git a/gdb/testsuite/gdb.dwarf2/dw2-struct-member-data-location.exp b/gdb/testsuite/gdb.dwarf2/dw2-struct-member-data-location.exp ++#endif +diff --git a/gdb/testsuite/gdb.arch/x86_64-vla-pointer.exp b/gdb/testsuite/gdb.arch/x86_64-vla-pointer.exp new file mode 100644 -index 0000000..c41151c +index 0000000..d243cf1 --- /dev/null -+++ b/gdb/testsuite/gdb.dwarf2/dw2-struct-member-data-location.exp -@@ -0,0 +1,37 @@ ++++ b/gdb/testsuite/gdb.arch/x86_64-vla-pointer.exp +@@ -0,0 +1,66 @@ +# Copyright 2009 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify @@ -24660,58 +11607,22 @@ index 0000000..c41151c +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + -+# This test can only be run on targets which support DWARF-2 and use gas. -+# For now pick a sampling of likely targets. -+if {![istarget *-*-linux*] -+ && ![istarget *-*-gnu*] -+ && ![istarget *-*-elf*] -+ && ![istarget *-*-openbsd*] -+ && ![istarget arm-*-eabi*] -+ && ![istarget powerpc-*-eabi*]} { -+ return 0 ++if ![istarget "x86_64-*-*"] then { ++ verbose "Skipping over gdb.arch/x86_64-vla-pointer.exp test made only for x86_64." ++ return +} + -+set testfile "dw2-struct-member-data-location" -+set srcfile ${testfile}.S -+set binfile ${testfile}.x -+ -+if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${objdir}/${subdir}/${binfile}" object {nodebug}] != "" } { ++set testfile x86_64-vla-pointer ++set srcasmfile ${testfile}-foo.S ++set srcfile ${testfile}.c ++set binfile ${objdir}/${subdir}/${testfile} ++set binobjfile ${objdir}/${subdir}/${testfile}-foo.o ++if { [gdb_compile "${srcdir}/${subdir}/${srcasmfile}" "${binobjfile}" object {}] != "" } { ++ untested "Couldn't compile test program" + return -1 +} -+ -+clean_restart $binfile -+ -+gdb_test "ptype struct some_struct" "type = struct some_struct {\[\r\n \t\]*void field;\[\r\n \t\]*}" -diff --git a/gdb/testsuite/gdb.fortran/common-block.exp b/gdb/testsuite/gdb.fortran/common-block.exp -new file mode 100644 -index 0000000..888f6c3 ---- /dev/null -+++ b/gdb/testsuite/gdb.fortran/common-block.exp -@@ -0,0 +1,101 @@ -+# Copyright 2008 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. -+ -+# This file was written by Jan Kratochvil . -+ -+set testfile "common-block" -+set srcfile ${testfile}.f90 -+set binfile ${objdir}/${subdir}/${testfile} -+ -+if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug f77 quiet}] != "" } { -+ untested "Couldn't compile ${srcfile}" ++if { [gdb_compile "${srcdir}/${subdir}/${srcfile} ${binobjfile}" "${binfile}" executable {debug}] != "" } { ++ untested "Couldn't compile test program" + return -1 +} + @@ -24720,277 +11631,582 @@ index 0000000..888f6c3 +gdb_reinitialize_dir $srcdir/$subdir +gdb_load ${binfile} + -+if ![runto MAIN__] then { -+ perror "couldn't run to breakpoint MAIN__" -+ continue ++if ![runto_main] { ++ untested x86_64-vla-pointer ++ return -1 +} + -+gdb_breakpoint [gdb_get_line_number "stop-here-out"] -+gdb_continue_to_breakpoint "stop-here-out" -+ -+# Common block naming with source name /foo/: -+# .symtab DW_TAG_common_block's DW_AT_name -+# Intel Fortran foo_ foo_ -+# GNU Fortran foo_ foo -+#set suffix "_" -+set suffix "" -+ -+set int4 {(integer\(kind=4\)|INTEGER\(4\))} -+set real4 {(real\(kind=4\)|REAL\(4\))} -+set real8 {(real\(kind=8\)|REAL\(8\))} -+ -+gdb_test "whatis foo$suffix" "No symbol \"foo$suffix\" in current context." -+gdb_test "ptype foo$suffix" "No symbol \"foo$suffix\" in current context." -+gdb_test "p foo$suffix" "No symbol \"foo$suffix\" in current context." -+gdb_test "whatis fo_o$suffix" "No symbol \"fo_o$suffix\" in current context." -+gdb_test "ptype fo_o$suffix" "No symbol \"fo_o$suffix\" in current context." -+gdb_test "p fo_o$suffix" "No symbol \"fo_o$suffix\" in current context." -+ -+gdb_test "info locals" "ix_x = 11\r\niy_y = 22\r\niz_z = 33\r\nix = 1\r\niy = 2\r\niz = 3" "info locals out" -+gdb_test "info common" "Contents of F77 COMMON block 'fo_o':\r\nix_x = 11\r\niy_y = 22\r\niz_z = 33\r\n\r\nContents of F77 COMMON block 'foo':\r\nix = 1\r\niy = 2\r\niz = 3" "info common out" -+ -+gdb_test "ptype ix" "type = $int4" "ptype ix out" -+gdb_test "ptype iy" "type = $real4" "ptype iy out" -+gdb_test "ptype iz" "type = $real8" "ptype iz out" -+gdb_test "ptype ix_x" "type = $int4" "ptype ix_x out" -+gdb_test "ptype iy_y" "type = $real4" "ptype iy_y out" -+gdb_test "ptype iz_z" "type = $real8" "ptype iz_z out" -+ -+gdb_test "p ix" " = 1 *" "p ix out" -+gdb_test "p iy" " = 2 *" "p iy out" -+gdb_test "p iz" " = 3 *" "p iz out" -+gdb_test "p ix_x" " = 11 *" "p ix_x out" -+gdb_test "p iy_y" " = 22 *" "p iy_y out" -+gdb_test "p iz_z" " = 33 *" "p iz_z out" -+ -+gdb_breakpoint [gdb_get_line_number "stop-here-in"] -+gdb_continue_to_breakpoint "stop-here-in" -+ -+gdb_test "whatis foo$suffix" "No symbol \"foo$suffix\" in current context." "whatis foo$suffix in" -+gdb_test "ptype foo$suffix" "No symbol \"foo$suffix\" in current context." "ptype foo$suffix in" -+gdb_test "p foo$suffix" "No symbol \"foo$suffix\" in current context." "p foo$suffix in" -+gdb_test "whatis fo_o$suffix" "No symbol \"fo_o$suffix\" in current context." "whatis fo_o$suffix in" -+gdb_test "ptype fo_o$suffix" "No symbol \"fo_o$suffix\" in current context." "ptype fo_o$suffix in" -+gdb_test "p fo_o$suffix" "No symbol \"fo_o$suffix\" in current context." "p fo_o$suffix in" -+ -+gdb_test "info locals" "ix = 11\r\niy2 = 22\r\niz = 33\r\nix_x = 1\r\niy_y = 2\r\niz_z2 = 3\r\niy = 5\r\niz_z = 55" "info locals in" -+gdb_test "info common" "Contents of F77 COMMON block 'fo_o':\r\nix = 11\r\niy2 = 22\r\niz = 33\r\n\r\nContents of F77 COMMON block 'foo':\r\nix_x = 1\r\niy_y = 2\r\niz_z2 = 3" "info common in" -+ -+gdb_test "ptype ix" "type = $int4" "ptype ix in" -+gdb_test "ptype iy2" "type = $real4" "ptype iy2 in" -+gdb_test "ptype iz" "type = $real8" "ptype iz in" -+gdb_test "ptype ix_x" "type = $int4" "ptype ix_x in" -+gdb_test "ptype iy_y" "type = $real4" "ptype iy_y in" -+gdb_test "ptype iz_z2" "type = $real8" "ptype iz_z2 in" -+ -+gdb_test "p ix" " = 11 *" "p ix in" -+gdb_test "p iy2" " = 22 *" "p iy2 in" -+gdb_test "p iz" " = 33 *" "p iz in" -+gdb_test "p ix_x" " = 1 *" "p ix_x in" -+gdb_test "p iy_y" " = 2 *" "p iy_y in" -+gdb_test "p iz_z2" " = 3 *" "p iz_z2 in" -diff --git a/gdb/testsuite/gdb.fortran/common-block.f90 b/gdb/testsuite/gdb.fortran/common-block.f90 ++gdb_breakpoint "break_here" ++ ++gdb_continue_to_breakpoint "break_here" ++ ++gdb_test "whatis array" "type = char \\(\\*\\)\\\[variable\\\]" "first: whatis array" ++gdb_test "ptype array" "type = char \\(\\*\\)\\\[26\\\]" "first: ptype array" ++ ++gdb_test "whatis *array" "type = char \\\[26\\\]" "first: whatis *array" ++gdb_test "ptype *array" "type = char \\\[26\\\]" "first: ptype *array" ++ ++gdb_test "p (*array)\[1\]" "\\$\[0-9\] = 1 '\\\\001'" ++gdb_test "p (*array)\[2\]" "\\$\[0-9\] = 2 '\\\\002'" ++gdb_test "p (*array)\[3\]" "\\$\[0-9\] = 3 '\\\\003'" ++gdb_test "p (*array)\[4\]" "\\$\[0-9\] = 4 '\\\\004'" ++ ++gdb_continue_to_breakpoint "break_here" ++ ++gdb_test "whatis array" "type = char \\(\\*\\)\\\[variable\\\]" "second: whatis array" ++gdb_test "ptype array" "type = char \\(\\*\\)\\\[78\\\]" "second: ptype array" ++ ++gdb_test "whatis *array" "type = char \\\[78\\\]" "second: whatis *array" ++gdb_test "ptype *array" "type = char \\\[78\\\]" "second: ptype *array" +diff --git a/gdb/testsuite/gdb.arch/x86_64-vla-typedef-foo.S b/gdb/testsuite/gdb.arch/x86_64-vla-typedef-foo.S +new file mode 100644 +index 0000000..66f7a39 +--- /dev/null ++++ b/gdb/testsuite/gdb.arch/x86_64-vla-typedef-foo.S +@@ -0,0 +1,455 @@ ++ .file "x86_64-vla-typedef.c" ++ .section .debug_abbrev,"",@progbits ++.Ldebug_abbrev0: ++ .section .debug_info,"",@progbits ++.Ldebug_info0: ++ .section .debug_line,"",@progbits ++.Ldebug_line0: ++ .text ++.Ltext0: ++.globl foo ++ .type foo, @function ++foo: ++.LFB2: ++ .file 1 "x86_64-vla-typedef.c" ++ .loc 1 22 0 ++ pushq %rbp ++.LCFI0: ++ movq %rsp, %rbp ++.LCFI1: ++ subq $64, %rsp ++.LCFI2: ++ movl %edi, -36(%rbp) ++ .loc 1 22 0 ++ movq %rsp, %rax ++ movq %rax, -48(%rbp) ++ .loc 1 23 0 ++ movl -36(%rbp), %edx ++ movslq %edx,%rax ++ subq $1, %rax ++ movq %rax, -24(%rbp) ++ .loc 1 24 0 ++ movslq %edx,%rax ++ addq $15, %rax ++ addq $15, %rax ++ shrq $4, %rax ++ salq $4, %rax ++ subq %rax, %rsp ++ movq %rsp, -56(%rbp) ++ movq -56(%rbp), %rax ++ addq $15, %rax ++ shrq $4, %rax ++ salq $4, %rax ++ movq %rax, -56(%rbp) ++ movq -56(%rbp), %rax ++ movq %rax, -16(%rbp) ++ .loc 1 27 0 ++ movl $0, -4(%rbp) ++ jmp .L2 ++.L3: ++ .loc 1 28 0 ++ movl -4(%rbp), %esi ++ movl -4(%rbp), %eax ++ movl %eax, %ecx ++ movq -16(%rbp), %rdx ++ movslq %esi,%rax ++ movb %cl, (%rdx,%rax) ++ .loc 1 27 0 ++ addl $1, -4(%rbp) ++.L2: ++ movl -4(%rbp), %eax ++ cmpl -36(%rbp), %eax ++ jl .L3 ++ .loc 1 30 0 ++ .globl break_here ++break_here: ++ movq -16(%rbp), %rax ++ movb $0, (%rax) ++ movq -48(%rbp), %rsp ++ .loc 1 31 0 ++ leave ++ ret ++.LFE2: ++ .size foo, .-foo ++ .section .debug_frame,"",@progbits ++.Lframe0: ++ .long .LECIE0-.LSCIE0 ++.LSCIE0: ++ .long 0xffffffff ++ .byte 0x1 ++ .string "" ++ .uleb128 0x1 ++ .sleb128 -8 ++ .byte 0x10 ++ .byte 0xc ++ .uleb128 0x7 ++ .uleb128 0x8 ++ .byte 0x90 ++ .uleb128 0x1 ++ .align 8 ++.LECIE0: ++.LSFDE0: ++ .long .LEFDE0-.LASFDE0 ++.LASFDE0: ++ .long .Lframe0 ++ .quad .LFB2 ++ .quad .LFE2-.LFB2 ++ .byte 0x4 ++ .long .LCFI0-.LFB2 ++ .byte 0xe ++ .uleb128 0x10 ++ .byte 0x86 ++ .uleb128 0x2 ++ .byte 0x4 ++ .long .LCFI1-.LCFI0 ++ .byte 0xd ++ .uleb128 0x6 ++ .align 8 ++.LEFDE0: ++ .section .eh_frame,"a",@progbits ++.Lframe1: ++ .long .LECIE1-.LSCIE1 ++.LSCIE1: ++ .long 0x0 ++ .byte 0x1 ++ .string "zR" ++ .uleb128 0x1 ++ .sleb128 -8 ++ .byte 0x10 ++ .uleb128 0x1 ++ .byte 0x3 ++ .byte 0xc ++ .uleb128 0x7 ++ .uleb128 0x8 ++ .byte 0x90 ++ .uleb128 0x1 ++ .align 8 ++.LECIE1: ++.LSFDE1: ++ .long .LEFDE1-.LASFDE1 ++.LASFDE1: ++ .long .LASFDE1-.Lframe1 ++ .long .LFB2 ++ .long .LFE2-.LFB2 ++ .uleb128 0x0 ++ .byte 0x4 ++ .long .LCFI0-.LFB2 ++ .byte 0xe ++ .uleb128 0x10 ++ .byte 0x86 ++ .uleb128 0x2 ++ .byte 0x4 ++ .long .LCFI1-.LCFI0 ++ .byte 0xd ++ .uleb128 0x6 ++ .align 8 ++.LEFDE1: ++ .text ++.Letext0: ++ .section .debug_loc,"",@progbits ++.Ldebug_loc0: ++.LLST0: ++ .quad .LFB2-.Ltext0 ++ .quad .LCFI0-.Ltext0 ++ .value 0x2 ++ .byte 0x77 ++ .sleb128 8 ++ .quad .LCFI0-.Ltext0 ++ .quad .LCFI1-.Ltext0 ++ .value 0x2 ++ .byte 0x77 ++ .sleb128 16 ++ .quad .LCFI1-.Ltext0 ++ .quad .LFE2-.Ltext0 ++ .value 0x2 ++ .byte 0x76 ++ .sleb128 16 ++ .quad 0x0 ++ .quad 0x0 ++ .section .debug_info ++ .long .Ldebug_end - .Ldebug_start ++.Ldebug_start: ++ .value 0x2 ++ .long .Ldebug_abbrev0 ++ .byte 0x8 ++ .uleb128 0x1 ++ .long .LASF2 ++ .byte 0x1 ++ .long .LASF3 ++ .long .LASF4 ++ .quad .Ltext0 ++ .quad .Letext0 ++ .long .Ldebug_line0 ++ .uleb128 0x2 ++ .byte 0x1 ++ .string "foo" ++ .byte 0x1 ++ .byte 0x16 ++ .byte 0x1 ++ .quad .LFB2 ++ .quad .LFE2 ++ .long .LLST0 ++ .long 0x83 ++ .uleb128 0x3 ++ .long .LASF5 ++ .byte 0x1 ++ .byte 0x15 ++ .long 0x83 ++ .byte 0x2 ++ .byte 0x91 ++ .sleb128 -52 ++.Ltag_typedef: ++ .uleb128 0x4 ++ .long .LASF6 ++ .byte 0x1 ++ .byte 0x17 ++ .long .Ltag_array_type - .debug_info ++ .uleb128 0x5 /* Abbrev Number: 5 (DW_TAG_variable) */ ++ .long .LASF0 ++ .byte 0x1 ++ .byte 0x18 ++#if 1 ++ .long .Ltag_typedef - .debug_info ++#else ++ /* Debugging only: Skip the typedef indirection. */ ++ .long .Ltag_array_type - .debug_info ++#endif ++ /* DW_AT_location: DW_FORM_block1: start */ ++ .byte 0x3 ++ .byte 0x91 ++ .sleb128 -32 ++#if 0 ++ .byte 0x6 /* DW_OP_deref */ ++#else ++ .byte 0x96 /* DW_OP_nop */ ++#endif ++ /* DW_AT_location: DW_FORM_block1: end */ ++ .uleb128 0x6 ++ .string "i" ++ .byte 0x1 ++ .byte 0x19 ++ .long 0x83 ++ .byte 0x2 ++ .byte 0x91 ++ .sleb128 -20 ++ .byte 0x0 ++ .uleb128 0x7 ++ .byte 0x4 ++ .byte 0x5 ++ .string "int" ++.Ltag_array_type: ++ .uleb128 0x8 /* Abbrev Number: 8 (DW_TAG_array_type) */ ++ .long 0xa0 + (2f - 1f) /* DW_AT_type: DW_FORM_ref4 */ ++ .long 0x9d + (2f - 1f) /* DW_AT_sibling: DW_FORM_ref4 */ ++1: /* DW_AT_data_location: DW_FORM_block1: start */ ++ .byte 2f - 3f /* length */ ++3: ++ .byte 0x97 /* DW_OP_push_object_address */ ++ .byte 0x6 /* DW_OP_deref */ ++2: /* DW_AT_data_location: DW_FORM_block1: end */ ++ .uleb128 0x9 ++ .long 0x9d + (2b - 1b) /* DW_AT_type: DW_FORM_ref4 */ ++ .byte 0x3 ++ .byte 0x91 ++ .sleb128 -40 ++ .byte 0x6 ++ .byte 0x0 ++ .uleb128 0xa ++ .byte 0x8 ++ .byte 0x7 ++ .uleb128 0xb ++ .byte 0x1 ++ .byte 0x6 ++ .long .LASF1 ++ .byte 0x0 ++.Ldebug_end: ++ .section .debug_abbrev ++ .uleb128 0x1 ++ .uleb128 0x11 ++ .byte 0x1 ++ .uleb128 0x25 ++ .uleb128 0xe ++ .uleb128 0x13 ++ .uleb128 0xb ++ .uleb128 0x3 ++ .uleb128 0xe ++ .uleb128 0x1b ++ .uleb128 0xe ++ .uleb128 0x11 ++ .uleb128 0x1 ++ .uleb128 0x12 ++ .uleb128 0x1 ++ .uleb128 0x10 ++ .uleb128 0x6 ++ .byte 0x0 ++ .byte 0x0 ++ .uleb128 0x2 ++ .uleb128 0x2e ++ .byte 0x1 ++ .uleb128 0x3f ++ .uleb128 0xc ++ .uleb128 0x3 ++ .uleb128 0x8 ++ .uleb128 0x3a ++ .uleb128 0xb ++ .uleb128 0x3b ++ .uleb128 0xb ++ .uleb128 0x27 ++ .uleb128 0xc ++ .uleb128 0x11 ++ .uleb128 0x1 ++ .uleb128 0x12 ++ .uleb128 0x1 ++ .uleb128 0x40 ++ .uleb128 0x6 ++ .uleb128 0x1 ++ .uleb128 0x13 ++ .byte 0x0 ++ .byte 0x0 ++ .uleb128 0x3 ++ .uleb128 0x5 ++ .byte 0x0 ++ .uleb128 0x3 ++ .uleb128 0xe ++ .uleb128 0x3a ++ .uleb128 0xb ++ .uleb128 0x3b ++ .uleb128 0xb ++ .uleb128 0x49 ++ .uleb128 0x13 ++ .uleb128 0x2 ++ .uleb128 0xa ++ .byte 0x0 ++ .byte 0x0 ++ .uleb128 0x4 ++ .uleb128 0x16 ++ .byte 0x0 ++ .uleb128 0x3 ++ .uleb128 0xe ++ .uleb128 0x3a ++ .uleb128 0xb ++ .uleb128 0x3b ++ .uleb128 0xb ++ .uleb128 0x49 ++ .uleb128 0x13 ++ .byte 0x0 ++ .byte 0x0 ++ .uleb128 0x5 ++ .uleb128 0x34 ++ .byte 0x0 ++ .uleb128 0x3 ++ .uleb128 0xe ++ .uleb128 0x3a ++ .uleb128 0xb ++ .uleb128 0x3b ++ .uleb128 0xb ++ .uleb128 0x49 ++ .uleb128 0x13 ++ .uleb128 0x2 ++ .uleb128 0xa ++ .byte 0x0 ++ .byte 0x0 ++ .uleb128 0x6 ++ .uleb128 0x34 ++ .byte 0x0 ++ .uleb128 0x3 ++ .uleb128 0x8 ++ .uleb128 0x3a ++ .uleb128 0xb ++ .uleb128 0x3b ++ .uleb128 0xb ++ .uleb128 0x49 ++ .uleb128 0x13 ++ .uleb128 0x2 ++ .uleb128 0xa ++ .byte 0x0 ++ .byte 0x0 ++ .uleb128 0x7 ++ .uleb128 0x24 ++ .byte 0x0 ++ .uleb128 0xb ++ .uleb128 0xb ++ .uleb128 0x3e ++ .uleb128 0xb ++ .uleb128 0x3 ++ .uleb128 0x8 ++ .byte 0x0 ++ .byte 0x0 ++ .uleb128 0x8 /* Abbrev Number: 8 (DW_TAG_array_type) */ ++ .uleb128 0x1 ++ .byte 0x1 ++ .uleb128 0x49 /* DW_AT_type */ ++ .uleb128 0x13 /* DW_FORM_ref4 */ ++ .uleb128 0x1 /* DW_AT_sibling */ ++ .uleb128 0x13 /* DW_FORM_ref4 */ ++ .uleb128 0x50 /* DW_AT_data_location */ ++ .uleb128 0xa /* DW_FORM_block1 */ ++ .byte 0x0 ++ .byte 0x0 ++ .uleb128 0x9 ++ .uleb128 0x21 ++ .byte 0x0 ++ .uleb128 0x49 /* DW_AT_type */ ++ .uleb128 0x13 /* DW_FORM_ref4 */ ++ .uleb128 0x2f ++ .uleb128 0xa ++ .byte 0x0 ++ .byte 0x0 ++ .uleb128 0xa ++ .uleb128 0x24 ++ .byte 0x0 ++ .uleb128 0xb ++ .uleb128 0xb ++ .uleb128 0x3e ++ .uleb128 0xb ++ .byte 0x0 ++ .byte 0x0 ++ .uleb128 0xb ++ .uleb128 0x24 ++ .byte 0x0 ++ .uleb128 0xb ++ .uleb128 0xb ++ .uleb128 0x3e ++ .uleb128 0xb ++ .uleb128 0x3 ++ .uleb128 0xe ++ .byte 0x0 ++ .byte 0x0 ++ .byte 0x0 ++ .section .debug_pubnames,"",@progbits ++ .long 0x16 ++ .value 0x2 ++ .long .Ldebug_info0 ++ .long 0xa8 ++ .long 0x2d ++ .string "foo" ++ .long 0x0 ++ .section .debug_aranges,"",@progbits ++ .long 0x2c ++ .value 0x2 ++ .long .Ldebug_info0 ++ .byte 0x8 ++ .byte 0x0 ++ .value 0x0 ++ .value 0x0 ++ .quad .Ltext0 ++ .quad .Letext0-.Ltext0 ++ .quad 0x0 ++ .quad 0x0 ++ .section .debug_str,"MS",@progbits,1 ++.LASF0: ++ .string "array" ++.LASF5: ++ .string "size" ++.LASF3: ++ .string "x86_64-vla-typedef.c" ++.LASF6: ++ .string "array_t" ++.LASF1: ++ .string "char" ++.LASF4: ++ .string "gdb.arch" ++.LASF2: ++ .string "GNU C 4.3.2 20081105 (Red Hat 4.3.2-7)" ++ .ident "GCC: (GNU) 4.3.2 20081105 (Red Hat 4.3.2-7)" ++ .section .note.GNU-stack,"",@progbits +diff --git a/gdb/testsuite/gdb.arch/x86_64-vla-typedef.c b/gdb/testsuite/gdb.arch/x86_64-vla-typedef.c new file mode 100644 -index 0000000..b614e8a +index 0000000..b809c4e --- /dev/null -+++ b/gdb/testsuite/gdb.fortran/common-block.f90 -@@ -0,0 +1,67 @@ -+! Copyright 2008 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. -+! -+! Ihis file is the Fortran source file for dynamic.exp. -+! Original file written by Jakub Jelinek . -+! Modified for the GDB testcase by Jan Kratochvil . -+ -+subroutine in -+ -+ INTEGER*4 ix -+ REAL*4 iy2 -+ REAL*8 iz -+ -+ INTEGER*4 ix_x -+ REAL*4 iy_y -+ REAL*8 iz_z2 -+ -+ common /fo_o/ix,iy2,iz -+ common /foo/ix_x,iy_y,iz_z2 -+ -+ iy = 5 -+ iz_z = 55 ++++ b/gdb/testsuite/gdb.arch/x86_64-vla-typedef.c +@@ -0,0 +1,43 @@ ++/* This testcase is part of GDB, the GNU debugger. + -+ if (ix .ne. 11 .or. iy2 .ne. 22.0 .or. iz .ne. 33.0) call abort -+ if (ix_x .ne. 1 .or. iy_y .ne. 2.0 .or. iz_z2 .ne. 3.0) call abort ++ Copyright 2008 Free Software Foundation, Inc. + -+ ix = 0 ! stop-here-in ++ 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. + -+end subroutine in ++ 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. + -+program common_test ++ You should have received a copy of the GNU General Public License ++ along with this program. If not, see . */ + -+ INTEGER*4 ix -+ REAL*4 iy -+ REAL*8 iz ++#if 0 + -+ INTEGER*4 ix_x -+ REAL*4 iy_y -+ REAL*8 iz_z ++void ++foo (int size) ++{ ++ typedef char array_t[size]; ++ array_t array; ++ int i; + -+ common /foo/ix,iy,iz -+ common /fo_o/ix_x,iy_y,iz_z ++ for (i = 0; i < size; i++) ++ array[i] = i; + -+ ix = 1 -+ iy = 2.0 -+ iz = 3.0 ++ array[0] = 0; /* break-here */ ++} + -+ ix_x = 11 -+ iy_y = 22.0 -+ iz_z = 33.0 ++#else + -+ call in ! stop-here-out ++int ++main (void) ++{ ++ foo (26); ++ foo (78); ++ return 0; ++} + -+end program common_test -diff --git a/gdb/testsuite/gdb.fortran/dwarf-stride.exp b/gdb/testsuite/gdb.fortran/dwarf-stride.exp ++#endif +diff --git a/gdb/testsuite/gdb.arch/x86_64-vla-typedef.exp b/gdb/testsuite/gdb.arch/x86_64-vla-typedef.exp new file mode 100644 -index 0000000..cd3486b +index 0000000..b05411e --- /dev/null -+++ b/gdb/testsuite/gdb.fortran/dwarf-stride.exp -@@ -0,0 +1,42 @@ ++++ b/gdb/testsuite/gdb.arch/x86_64-vla-typedef.exp +@@ -0,0 +1,64 @@ +# Copyright 2009 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 ++# 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, write to the Free Software -+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -+ -+# This file was written by Jan Kratochvil . -+ -+# This file is part of the gdb testsuite. Array element stride must not be -+# specified in the number of elements but in a number of bytes instead. -+# Original problem: -+# (gdb) p c40pt(1) -+# $1 = '0-hello', ' ' -+# (gdb) p c40pt(2) -+# warning: Fortran array stride not divisible by the element size -+ -+set testfile dwarf-stride -+set srcfile ${testfile}.f90 ++# along with this program. If not, see . + -+if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} {debug f77}] } { -+ return -1 -+} ++# Test DW_AT_data_location accessed through DW_TAG_typedef intermediate. + -+if ![runto MAIN__] then { -+ perror "couldn't run to breakpoint MAIN__" -+ continue ++if ![istarget "x86_64-*-*"] then { ++ verbose "Skipping over gdb.arch/x86_64-vla-typedef.exp test made only for x86_64." ++ return +} + -+gdb_breakpoint [gdb_get_line_number "break-here"] -+gdb_continue_to_breakpoint "break-here" ".*break-here.*" -+gdb_test "p c40pt(1)" " = '0-hello.*" -+gdb_test "p c40pt(2)" " = '1-hello.*" -diff --git a/gdb/testsuite/gdb.fortran/dwarf-stride.f90 b/gdb/testsuite/gdb.fortran/dwarf-stride.f90 -new file mode 100644 -index 0000000..e492b3a ---- /dev/null -+++ b/gdb/testsuite/gdb.fortran/dwarf-stride.f90 -@@ -0,0 +1,40 @@ -+! Copyright 2009 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. -+! -+! File written by Alan Matsuoka. -+ -+program repro -+ -+ type small_stride -+ character*40 long_string -+ integer small_pad -+ end type small_stride -+ -+ type(small_stride), dimension (20), target :: unpleasant -+ character*40, pointer, dimension(:):: c40pt -+ -+ integer i -+ -+ do i = 0,19 -+ unpleasant(i+1)%small_pad = i+1 -+ unpleasant(i+1)%long_string = char (ichar('0') + i) // '-hello' -+ end do -+ -+ c40pt => unpleasant%long_string -+ -+ print *, c40pt ! break-here -+ -+end program repro -diff --git a/gdb/testsuite/gdb.fortran/dynamic.exp b/gdb/testsuite/gdb.fortran/dynamic.exp -new file mode 100644 -index 0000000..0ccebe0 ---- /dev/null -+++ b/gdb/testsuite/gdb.fortran/dynamic.exp -@@ -0,0 +1,145 @@ -+# Copyright 2007 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. -+ -+# This file was written by Jan Kratochvil . -+ -+# This file is part of the gdb testsuite. It contains tests for dynamically -+# allocated Fortran arrays. -+# It depends on the GCC dynamic Fortran arrays DWARF support: -+# http://gcc.gnu.org/bugzilla/show_bug.cgi?id=22244 -+ -+set testfile "dynamic" -+set srcfile ${testfile}.f90 ++set testfile x86_64-vla-typedef ++set srcasmfile ${testfile}-foo.S ++set srcfile ${testfile}.c +set binfile ${objdir}/${subdir}/${testfile} -+ -+if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug f77 quiet}] != "" } { -+ untested "Couldn't compile ${srcfile}" ++set binobjfile ${objdir}/${subdir}/${testfile}-foo.o ++if { [gdb_compile "${srcdir}/${subdir}/${srcasmfile}" "${binobjfile}" object {}] != "" } { ++ untested "Couldn't compile test program" ++ return -1 ++} ++if { [gdb_compile "${srcdir}/${subdir}/${srcfile} ${binobjfile}" "${binfile}" executable {debug}] != "" } { ++ untested "Couldn't compile test program" + return -1 +} + @@ -24999,288 +12215,178 @@ index 0000000..0ccebe0 +gdb_reinitialize_dir $srcdir/$subdir +gdb_load ${binfile} + -+if ![runto MAIN__] then { -+ perror "couldn't run to breakpoint MAIN__" -+ continue -+} -+ -+gdb_breakpoint [gdb_get_line_number "varx-init"] -+gdb_continue_to_breakpoint "varx-init" -+gdb_test "p varx" "\\$\[0-9\]* = <(object|the array) is not allocated>" "p varx unallocated" -+gdb_test "ptype varx" "type = <(object|the array) is not allocated>" "ptype varx unallocated" -+gdb_test "p varx(1,5,17)" "(Cannot access it|Unable to access the object) because the (object|array) is not allocated\\." "p varx(1,5,17) unallocated" -+gdb_test "p varx(1,5,17)=1" "(Cannot access it|Unable to access the object) because the (object|array) is not allocated\\." "p varx(1,5,17)=1 unallocated" -+gdb_test "ptype varx(1,5,17)" "(Cannot access it|Unable to access the object) because the (object|array) is not allocated\\." "ptype varx(1,5,17) unallocated" -+ -+gdb_breakpoint [gdb_get_line_number "varx-allocated"] -+gdb_continue_to_breakpoint "varx-allocated" -+# $1 = (( ( 0, 0, 0, 0, 0, 0) ( 0, 0, 0, 0, 0, 0) --- , 0) ) ( ( 0, 0, ...) ...) ...) -+gdb_test "ptype varx" "type = real(\\(kind=4\\)|\\*4) \\(6,5:15,17:28\\)" "ptype varx allocated" -+# Intel Fortran Compiler 10.1.008 uses -1 there, GCC uses 1. -+gdb_test "p l" "\\$\[0-9\]* = (\\.TRUE\\.|4294967295)" "p l if varx allocated" -+ -+gdb_breakpoint [gdb_get_line_number "varx-filled"] -+gdb_continue_to_breakpoint "varx-filled" -+gdb_test "p varx(2, 5, 17)" "\\$\[0-9\]* = 6" -+gdb_test "p varx(1, 5, 17)" "\\$\[0-9\]* = 7" -+gdb_test "p varx(2, 6, 18)" "\\$\[0-9\]* = 8" -+gdb_test "p varx(6, 15, 28)" "\\$\[0-9\]* = 9" -+# The latter one is for the Intel Fortran Compiler 10.1.008 pointer type. -+gdb_test "p varv" "\\$\[0-9\]* = (<(object|the array) is not associated>|.*(Cannot access it|Unable to access the object) because the object is not associated.)" "p varv unassociated" -+gdb_test "ptype varv" "type = (<(object|the array) is not associated>|.*(Cannot access it|Unable to access the object) because the object is not associated.)" "ptype varv unassociated" -+ -+gdb_breakpoint [gdb_get_line_number "varv-associated"] -+gdb_continue_to_breakpoint "varv-associated" -+gdb_test "p varx(3, 7, 19)" "\\$\[0-9\]* = 6" "p varx(3, 7, 19) with varv associated" -+gdb_test "p varv(3, 7, 19)" "\\$\[0-9\]* = 6" "p varv(3, 7, 19) associated" -+# Intel Fortran Compiler 10.1.008 uses -1 there, GCC uses 1. -+gdb_test "p l" "\\$\[0-9\]* = (\\.TRUE\\.|4294967295)" "p l if varv associated" -+gdb_test "ptype varx" "type = real(\\(kind=4\\)|\\*4) \\(6,5:15,17:28\\)" "ptype varx with varv associated" -+# Intel Fortran Compiler 10.1.008 uses the pointer type. -+gdb_test "ptype varv" "type = (PTR TO -> \\( )?real(\\(kind=4\\)|\\*4) \\(6,5:15,17:28\\)\\)?" "ptype varv associated" ++if ![runto_main] { ++ untested x86_64-vla-typedef ++ return -1 ++} + -+gdb_breakpoint [gdb_get_line_number "varv-filled"] -+gdb_continue_to_breakpoint "varv-filled" -+gdb_test "p varx(3, 7, 19)" "\\$\[0-9\]* = 10" "p varx(3, 7, 19) with varv filled" -+gdb_test "p varv(3, 7, 19)" "\\$\[0-9\]* = 10" "p varv(3, 7, 19) filled" ++gdb_breakpoint "break_here" + -+gdb_breakpoint [gdb_get_line_number "varv-deassociated"] -+gdb_continue_to_breakpoint "varv-deassociated" -+# The latter one is for the Intel Fortran Compiler 10.1.008 pointer type. -+gdb_test "p varv" "\\$\[0-9\]* = (<(object|the array) is not associated>|.*(Cannot access it|Unable to access the object) because the object is not associated.)" "p varv deassociated" -+gdb_test "ptype varv" "type = (<(object|the array) is not associated>|.*(Cannot access it|Unable to access the object) because the object is not associated.)" "ptype varv deassociated" -+gdb_test "p l" "\\$\[0-9\]* = \\.FALSE\\." "p l if varv deassociated" -+gdb_test "p varv(1,5,17)" "(Cannot access it|Unable to access the object) because the (object|array) is not associated\\." -+gdb_test "ptype varv(1,5,17)" "(Cannot access it|Unable to access the object) because the (object|array) is not associated\\." ++gdb_continue_to_breakpoint "break_here" + -+gdb_breakpoint [gdb_get_line_number "varx-deallocated"] -+gdb_continue_to_breakpoint "varx-deallocated" -+gdb_test "p varx" "\\$\[0-9\]* = <(object|the array) is not allocated>" "p varx deallocated" -+gdb_test "ptype varx" "type = <(object|the array) is not allocated>" "ptype varx deallocated" -+gdb_test "p l" "\\$\[0-9\]* = \\.FALSE\\." "p l if varx deallocated" -+gdb_test "p varx(1,5,17)" "(Cannot access it|Unable to access the object) because the (object|array) is not allocated\\." "p varx(1,5,17) deallocated" -+gdb_test "ptype varx(1,5,17)" "(Cannot access it|Unable to access the object) because the (object|array) is not allocated\\." "ptype varx(1,5,17) deallocated" ++gdb_test "whatis array" "type = array_t" "first: whatis array" + -+gdb_breakpoint [gdb_get_line_number "vary-passed"] -+gdb_continue_to_breakpoint "vary-passed" -+# $1 = (( ( 1, 1, 1, 1, 1, 1) ( 1, 1, 1, 1, 1, 1) --- , 1) ) ( ( 1, 1, ...) ...) ...) -+gdb_test "p vary" "\\$\[0-9\]* = \\(\[()1, .\]*\\)" ++gdb_test "ptype array" "type = char \\\[26\\\]" "first: ptype array" + -+gdb_breakpoint [gdb_get_line_number "vary-filled"] -+gdb_continue_to_breakpoint "vary-filled" -+gdb_test "ptype vary" "type = real(\\(kind=4\\)|\\*4) \\(10,10\\)" -+gdb_test "p vary(1, 1)" "\\$\[0-9\]* = 8" -+gdb_test "p vary(2, 2)" "\\$\[0-9\]* = 9" -+gdb_test "p vary(1, 3)" "\\$\[0-9\]* = 10" -+# $1 = (( ( 3, 3, 3, 3, 3, 3) ( 3, 3, 3, 3, 3, 3) --- , 3) ) ( ( 3, 3, ...) ...) ...) -+gdb_test "p varw" "\\$\[0-9\]* = \\(\[()3, .\]*\\)" ++gdb_test "p array\[1\]" "\\$\[0-9\] = 1 '\\\\001'" ++gdb_test "p array\[2\]" "\\$\[0-9\] = 2 '\\\\002'" ++gdb_test "p array\[3\]" "\\$\[0-9\] = 3 '\\\\003'" ++gdb_test "p array\[4\]" "\\$\[0-9\] = 4 '\\\\004'" + -+gdb_breakpoint [gdb_get_line_number "varw-almostfilled"] -+gdb_continue_to_breakpoint "varw-almostfilled" -+gdb_test "ptype varw" "type = real(\\(kind=4\\)|\\*4) \\(5,4,3\\)" -+gdb_test "p varw(3,1,1)=1" "\\$\[0-9\]* = 1" -+# $1 = (( ( 6, 5, 1, 5, 5, 5) ( 5, 5, 5, 5, 5, 5) --- , 5) ) ( ( 5, 5, ...) ...) ...) -+gdb_test "p varw" "\\$\[0-9\]* = \\( *\\( *\\( *6, *5, *1,\[()5, .\]*\\)" "p varw filled" -+# "up" works with GCC but other Fortran compilers may copy the values into the -+# outer function only on the exit of the inner function. -+# We need both variants as depending on the arch we optionally may still be -+# executing the caller line or not after `finish'. -+gdb_test "finish" ".*(call bar \\(y, x\\)|call foo \\(x, z\\(2:6, 4:7, 6:8\\)\\))" -+gdb_test "p z(2,4,5)" "\\$\[0-9\]* = 3" -+gdb_test "p z(2,4,6)" "\\$\[0-9\]* = 6" -+gdb_test "p z(2,4,7)" "\\$\[0-9\]* = 5" -+gdb_test "p z(4,4,6)" "\\$\[0-9\]* = 1" ++gdb_continue_to_breakpoint "break_here" + -+gdb_breakpoint [gdb_get_line_number "varz-almostfilled"] -+gdb_continue_to_breakpoint "varz-almostfilled" -+# GCC uses the pointer type here, Intel Fortran Compiler 10.1.008 does not. -+gdb_test "ptype varz" "type = (PTR TO -> \\( )?real(\\(kind=4\\)|\\*4) \\(\\*\\)\\)?" -+# Intel Fortran Compiler 10.1.008 has a bug here - (2:11,7:7) -+# as it produces DW_AT_lower_bound == DW_AT_upper_bound == 7. -+gdb_test "ptype vart" "type = (PTR TO -> \\( )?real(\\(kind=4\\)|\\*4) \\(2:11,7:\\*\\)\\)?" -+gdb_test "p varz" "\\$\[0-9\]* = \\(\\)" -+gdb_test "p vart" "\\$\[0-9\]* = \\(\\)" -+gdb_test "p varz(3)" "\\$\[0-9\]* = 4" -+# maps to foo::vary(1,1) -+gdb_test "p vart(2,7)" "\\$\[0-9\]* = 8" -+# maps to foo::vary(2,2) -+gdb_test "p vart(3,8)" "\\$\[0-9\]* = 9" -+# maps to foo::vary(1,3) -+gdb_test "p vart(2,9)" "\\$\[0-9\]* = 10" -diff --git a/gdb/testsuite/gdb.fortran/dynamic.f90 b/gdb/testsuite/gdb.fortran/dynamic.f90 -new file mode 100644 -index 0000000..0f43564 ---- /dev/null -+++ b/gdb/testsuite/gdb.fortran/dynamic.f90 -@@ -0,0 +1,98 @@ -+! Copyright 2007 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. -+! -+! Ihis file is the Fortran source file for dynamic.exp. -+! Original file written by Jakub Jelinek . -+! Modified for the GDB testcase by Jan Kratochvil . ++gdb_test "whatis array" "type = array_t" "second: whatis array" + -+subroutine baz -+ real, target, allocatable :: varx (:, :, :) -+ real, pointer :: varv (:, :, :) -+ real, target :: varu (1, 2, 3) -+ logical :: l -+ allocate (varx (1:6, 5:15, 17:28)) ! varx-init -+ l = allocated (varx) -+ varx(:, :, :) = 6 ! varx-allocated -+ varx(1, 5, 17) = 7 -+ varx(2, 6, 18) = 8 -+ varx(6, 15, 28) = 9 -+ varv => varx ! varx-filled -+ l = associated (varv) -+ varv(3, 7, 19) = 10 ! varv-associated -+ varv => null () ! varv-filled -+ l = associated (varv) -+ deallocate (varx) ! varv-deassociated -+ l = allocated (varx) -+ varu(:, :, :) = 10 ! varx-deallocated -+ allocate (varv (1:6, 5:15, 17:28)) -+ l = associated (varv) -+ varv(:, :, :) = 6 -+ varv(1, 5, 17) = 7 -+ varv(2, 6, 18) = 8 -+ varv(6, 15, 28) = 9 -+ deallocate (varv) -+ l = associated (varv) -+ varv => varu -+ varv(1, 1, 1) = 6 -+ varv(1, 2, 3) = 7 -+ l = associated (varv) -+end subroutine baz -+subroutine foo (vary, varw) -+ real :: vary (:, :) -+ real :: varw (:, :, :) -+ vary(:, :) = 4 ! vary-passed -+ vary(1, 1) = 8 -+ vary(2, 2) = 9 -+ vary(1, 3) = 10 -+ varw(:, :, :) = 5 ! vary-filled -+ varw(1, 1, 1) = 6 -+ varw(2, 2, 2) = 7 ! varw-almostfilled -+end subroutine foo -+subroutine bar (varz, vart) -+ real :: varz (*) -+ real :: vart (2:11, 7:*) -+ varz(1:3) = 4 -+ varz(2) = 5 ! varz-almostfilled -+ vart(2,7) = vart(2,7) -+end subroutine bar -+program test -+ interface -+ subroutine foo (vary, varw) -+ real :: vary (:, :) -+ real :: varw (:, :, :) -+ end subroutine -+ end interface -+ interface -+ subroutine bar (varz, vart) -+ real :: varz (*) -+ real :: vart (2:11, 7:*) -+ end subroutine -+ end interface -+ real :: x (10, 10), y (5), z(8, 8, 8) -+ x(:,:) = 1 -+ y(:) = 2 -+ z(:,:,:) = 3 -+ call baz -+ call foo (x, z(2:6, 4:7, 6:8)) -+ call bar (y, x) -+ if (x (1, 1) .ne. 8 .or. x (2, 2) .ne. 9 .or. x (1, 2) .ne. 4) call abort -+ if (x (1, 3) .ne. 10) call abort -+ if (z (2, 4, 6) .ne. 6 .or. z (3, 5, 7) .ne. 7 .or. z (2, 4, 7) .ne. 5) call abort -+ if (any (y .ne. (/4, 5, 4, 2, 2/))) call abort -+ call foo (transpose (x), z) -+ if (x (1, 1) .ne. 8 .or. x (2, 2) .ne. 9 .or. x (1, 2) .ne. 4) call abort -+ if (x (3, 1) .ne. 10) call abort -+end -diff --git a/gdb/testsuite/gdb.fortran/library-module-lib.f90 b/gdb/testsuite/gdb.fortran/library-module-lib.f90 ++gdb_test "ptype array" "type = char \\\[78\\\]" "second: ptype array" +diff --git a/gdb/testsuite/gdb.base/arrayidx.c b/gdb/testsuite/gdb.base/arrayidx.c +index ecc3289..f79ad40 100644 +--- a/gdb/testsuite/gdb.base/arrayidx.c ++++ b/gdb/testsuite/gdb.base/arrayidx.c +@@ -17,6 +17,13 @@ + + int array[] = {1, 2, 3, 4}; + ++#ifdef __GNUC__ ++struct ++ { ++ int a[0]; ++ } unbound; ++#endif ++ + int + main (void) + { +diff --git a/gdb/testsuite/gdb.base/arrayidx.exp b/gdb/testsuite/gdb.base/arrayidx.exp +index 3a33618..f2e11dd 100644 +--- a/gdb/testsuite/gdb.base/arrayidx.exp ++++ b/gdb/testsuite/gdb.base/arrayidx.exp +@@ -57,4 +57,12 @@ gdb_test "print array" \ + "\\{\\\[0\\\] = 1, \\\[1\\\] = 2, \\\[2\\\] = 3, \\\[3\\\] = 4\\}" \ + "Print array with array-indexes on" + +- ++set test "p unbound.a == &unbound.a\[0\]" ++gdb_test_multiple $test $test { ++ -re " = 1\r\n$gdb_prompt $" { ++ pass $test ++ } ++ -re "No symbol \"unbound\" in current context.\r\n$gdb_prompt $" { ++ unsupported "$test (no GCC)" ++ } ++} +diff --git a/gdb/testsuite/gdb.base/gnu-ifunc-lib.c b/gdb/testsuite/gdb.base/gnu-ifunc-lib.c new file mode 100644 -index 0000000..6369d34 +index 0000000..680530a --- /dev/null -+++ b/gdb/testsuite/gdb.fortran/library-module-lib.f90 -@@ -0,0 +1,28 @@ -+! Copyright 2009 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 . -+ -+module lib -+ integer :: var_i = 1 -+contains -+ subroutine lib_func -+ if (var_i .ne. 1) call abort -+ var_i = 2 -+ end subroutine lib_func -+end module lib -+ -+module libmany -+ integer :: var_j = 3 -+ integer :: var_k = 4 -+end module libmany -diff --git a/gdb/testsuite/gdb.fortran/library-module-main.f90 b/gdb/testsuite/gdb.fortran/library-module-main.f90 ++++ b/gdb/testsuite/gdb.base/gnu-ifunc-lib.c +@@ -0,0 +1,33 @@ ++/* This testcase is part of GDB, the GNU debugger. ++ ++ Copyright 2009, 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 . */ ++ ++extern volatile int gnu_ifunc_initialized; ++extern int init_stub (int arg); ++extern int final (int arg); ++ ++typedef int (*final_t) (int arg); ++ ++asm (".type gnu_ifunc, @gnu_indirect_function"); ++ ++final_t ++gnu_ifunc (void) ++{ ++ if (! gnu_ifunc_initialized) ++ return init_stub; ++ else ++ return final; ++} +diff --git a/gdb/testsuite/gdb.base/gnu-ifunc.c b/gdb/testsuite/gdb.base/gnu-ifunc.c new file mode 100644 -index 0000000..de63a65 +index 0000000..106271f --- /dev/null -+++ b/gdb/testsuite/gdb.fortran/library-module-main.f90 -@@ -0,0 +1,23 @@ -+! Copyright 2009 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 . -+ -+ use lib -+ use libmany, only: var_j -+ if (var_i .ne. 1) call abort -+ call lib_func -+ if (var_i .ne. 2) call abort -+ if (var_j .ne. 3) call abort -+ var_i = var_i ! i-is-2 -+end -diff --git a/gdb/testsuite/gdb.fortran/library-module.exp b/gdb/testsuite/gdb.fortran/library-module.exp ++++ b/gdb/testsuite/gdb.base/gnu-ifunc.c +@@ -0,0 +1,61 @@ ++/* This testcase is part of GDB, the GNU debugger. ++ ++ Copyright 2009, 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 ++ ++int ++init_stub (int arg) ++{ ++ return 0; ++} ++ ++int ++final (int arg) ++{ ++ return arg + 1; ++} ++ ++/* Make differentiation of how the gnu_ifunc call resolves before and after ++ calling gnu_ifunc_pre. This ensures the resolved function address is not ++ being cached anywhere for the debugging purposes. */ ++ ++volatile int gnu_ifunc_initialized; ++ ++static void ++gnu_ifunc_pre (void) ++{ ++ assert (!gnu_ifunc_initialized); ++ ++ gnu_ifunc_initialized = 1; ++} ++ ++extern int gnu_ifunc (int arg); ++ ++int ++main (void) ++{ ++ int i; ++ ++ gnu_ifunc_pre (); ++ ++ i = gnu_ifunc (1); /* break-at-call */ ++ assert (i == 2); ++ ++ gnu_ifunc (2); /* break-at-nextcall */ ++ ++ return 0; /* break-at-exit */ ++} +diff --git a/gdb/testsuite/gdb.base/gnu-ifunc.exp b/gdb/testsuite/gdb.base/gnu-ifunc.exp new file mode 100644 -index 0000000..4b4ea4c +index 0000000..8ecf558 --- /dev/null -+++ b/gdb/testsuite/gdb.fortran/library-module.exp -@@ -0,0 +1,53 @@ -+# Copyright 2009 Free Software Foundation, Inc. ++++ b/gdb/testsuite/gdb.base/gnu-ifunc.exp +@@ -0,0 +1,110 @@ ++# Copyright (C) 2009, 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 @@ -25295,355 +12401,378 @@ index 0000000..4b4ea4c +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + -+set testfile "library-module" -+set srcfile ${testfile}-main.f90 -+set srclibfile ${testfile}-lib.f90 -+set libfile ${testfile}-lib.so -+set binfile ${testfile} ++if {[skip_shlib_tests]} { ++ return 0 ++} ++ ++set testfile "gnu-ifunc" ++set srcfile ${testfile}.c ++set binfile ${objdir}/${subdir}/${testfile} ++ ++set libfile "${testfile}-lib" ++set libsrc ${libfile}.c ++set lib_so ${objdir}/${subdir}/${libfile}.so ++ ++# We need DWARF for the "final" function as we "step" into the function and GDB ++# would step-over the "final" function if there would be no line number debug ++# information (DWARF) available. ++# ++# We must not have DWARF for the "gnu_ifunc" function as DWARF has no way to ++# express the gnu-ifunc type and it would be considered as a regular function ++# due to DWARF by GDB. In ELF gnu-ifunc is expressed by the STT_GNU_IFUNC type. ++# ++# Both functions need to be in the same shared library file but ++# gdb_compile_shlib has no way to specify source-specific compilation options. ++# ++# Therefore $libfile contains only the gnu-ifunc function with no DWARF ++# referencing all the other parts from the main executable with DWARF. ++ ++set lib_opts {} ++set exec_opts [list debug shlib=$lib_so] + -+# Required for -fPIC by gdb_compile_shlib. -+if [get_compiler_info not-used] { -+ warning "Could not get compiler info" -+ return -1 ++if [get_compiler_info ${binfile}] { ++ return -1 +} + -+if { [gdb_compile_shlib "${srcdir}/${subdir}/${srclibfile}" $objdir/$subdir/$libfile {debug f77}] != "" } { -+ untested "Couldn't compile ${srclibfile}" ++if { [gdb_compile_shlib ${srcdir}/${subdir}/$libsrc $lib_so $lib_opts] != "" ++ || [gdb_compile ${srcdir}/${subdir}/$srcfile $binfile executable $exec_opts] != ""} { ++ untested "Could not compile either $libsrc or $srcfile." + return -1 +} + -+# prepare_for_testing cannot be used as linking with $libfile cannot be passed -+# just for the linking phase (and not the source compilation phase). And any -+# warnings on ignored $libfile abort the process. ++# Start with a fresh gdb. + -+if { [gdb_compile [list $srcdir/$subdir/$srcfile $objdir/$subdir/$libfile] $objdir/$subdir/$binfile executable {debug f77}] != "" } { -+ untested "Couldn't compile ${srcfile}" ++clean_restart $testfile ++gdb_load_shlibs ${lib_so} ++ ++if ![runto_main] then { ++ fail "Can't run to main" ++ return 1; ++} ++ ++# The "if" condition is artifical to test regression of a former patch. ++gdb_breakpoint "[gdb_get_line_number "break-at-nextcall"] if i && gnu_ifunc (i) != 42" ++ ++gdb_breakpoint [gdb_get_line_number "break-at-call"] ++gdb_continue_to_breakpoint "break-at-call" ".*break-at-call.*" ++ ++# Test GDB will automatically indirect the call. ++ ++gdb_test "p gnu_ifunc (3)" " = 4" ++ ++# Test GDB will skip the gnu_ifunc resolver on first call. ++ ++gdb_test "step" "\r\nfinal .*" ++ ++# Test GDB will not break before the final chosen implementation. ++ ++# Also test a former patch regression: ++# Continuing. ++# Error in testing breakpoint condition: ++# Attempt to take address of value not located in memory. ++# ++# Breakpoint 2, main () at ./gdb.base/gnu-ifunc.c:33 ++ ++gdb_test "continue" "Continuing.\r\n\r\nBreakpoint .* (at|in) .*break-at-nextcall.*" \ ++ "continue to break-at-nextcall" ++ ++gdb_breakpoint "gnu_ifunc" ++ ++gdb_continue_to_breakpoint "nextcall gnu_ifunc" ++ ++gdb_test "frame" "#0 +(0x\[0-9a-f\]+ in +)?final \\(.*" "nextcall gnu_ifunc skipped" ++ ++ ++# Check any commands not doing an inferior call still compute with address of ++# the gnu-ifunc resolver. ++ ++gdb_test "p gnu_ifunc" " = {} 0x\[0-9a-f\]+ " "p gnu_ifunc executing" ++gdb_test "info sym gnu_ifunc" "gnu_ifunc in section .*" "info sym gnu_ifunc executing" ++ ++set test "info addr gnu_ifunc" ++gdb_test_multiple $test $test { ++ -re "Symbol \"gnu_ifunc\" is at (0x\[0-9a-f\]+) in .*$gdb_prompt $" { ++ pass $test ++ } ++} ++gdb_test "info sym $expect_out(1,string)" "gnu_ifunc in section .*" "info sym " +diff --git a/gdb/testsuite/gdb.base/internal-var-field-address.c b/gdb/testsuite/gdb.base/internal-var-field-address.c +new file mode 100644 +index 0000000..eeb7b85 +--- /dev/null ++++ b/gdb/testsuite/gdb.base/internal-var-field-address.c +@@ -0,0 +1,20 @@ ++/* This testcase is part of GDB, the GNU debugger. ++ ++ Copyright 2009 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 . */ ++ ++struct { ++ int field; ++} staticstruct = { 1 }; +diff --git a/gdb/testsuite/gdb.base/internal-var-field-address.exp b/gdb/testsuite/gdb.base/internal-var-field-address.exp +new file mode 100644 +index 0000000..6d82e73 +--- /dev/null ++++ b/gdb/testsuite/gdb.base/internal-var-field-address.exp +@@ -0,0 +1,26 @@ ++# Copyright 2009 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 . ++ ++set test internal-var-field-address ++set binfile ${test}.x ++if { [gdb_compile "${srcdir}/${subdir}/${test}.c" "${objdir}/${subdir}/${binfile}" object {debug}] != "" } { ++ untested "Couldn't compile test program" + return -1 +} + +clean_restart $binfile + -+if ![runto MAIN__] then { -+ perror "couldn't run to breakpoint MAIN__" -+ continue -+} ++gdb_test {set $varstruct = staticstruct} ++gdb_test {p $varstruct.field} " = 1" +diff --git a/gdb/testsuite/gdb.base/vla-overflow.c b/gdb/testsuite/gdb.base/vla-overflow.c +new file mode 100644 +index 0000000..c5d5ee0 +--- /dev/null ++++ b/gdb/testsuite/gdb.base/vla-overflow.c +@@ -0,0 +1,30 @@ ++/* This testcase is part of GDB, the GNU debugger. ++ ++ Copyright 2008 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 ++ ++int ++main (int argc, char **argv) ++{ ++ int array[argc]; ++ ++ array[0] = array[0]; ++ ++ abort (); + -+gdb_breakpoint [gdb_get_line_number "i-is-2"] -+gdb_continue_to_breakpoint "i-is-2" ".*i-is-2.*" -+gdb_test "print var_i" " = 2" -+gdb_test "print var_j" " = 3" -+gdb_test "print var_k" "No symbol \"var_k\" in current context\\." -diff --git a/gdb/testsuite/gdb.fortran/logical.exp b/gdb/testsuite/gdb.fortran/logical.exp ++ return 0; ++} +diff --git a/gdb/testsuite/gdb.base/vla-overflow.exp b/gdb/testsuite/gdb.base/vla-overflow.exp new file mode 100644 -index 0000000..ef76f43 +index 0000000..24a608f --- /dev/null -+++ b/gdb/testsuite/gdb.fortran/logical.exp -@@ -0,0 +1,44 @@ -+# Copyright 2007 Free Software Foundation, Inc. ++++ b/gdb/testsuite/gdb.base/vla-overflow.exp +@@ -0,0 +1,109 @@ ++# Copyright 2008 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 ++# 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, write to the Free Software -+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ++# along with this program. If not, see . ++ ++# We could crash in: ++# #0 block_linkage_function (bl=0x0) at ../../gdb/block.c:69 ++# #1 in dwarf_block_get_frame_base (...) at ../../gdb/dwarf2block.c:97 ++# 97 framefunc = block_linkage_function (get_frame_block (frame, NULL)); ++# #2 in execute_stack_op (...) at ../../gdb/dwarf2expr.c:496 ++# #3 in dwarf_block_exec_core () at ../../gdb/dwarf2block.c:156 ++# #4 dwarf_block_exec (...) at ../../gdb/dwarf2block.c:206 ++# #5 in range_type_count_bound_internal (...) at ../../gdb/gdbtypes.c:1430 ++# #6 in create_array_type (...) at ../../gdb/gdbtypes.c:840 ++# ... ++# #21 in psymtab_to_symtab (...) at ../../gdb/symfile.c:292 ++# ... ++# #29 in backtrace_command_1 () at ../../gdb/stack.c:1273 ++ ++set testfile vla-overflow ++set shfile ${objdir}/${subdir}/${testfile}-gdb.sh ++set srcfile ${testfile}.c ++set binfile ${objdir}/${subdir}/${testfile} ++if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } { ++ untested "Couldn't compile test program" ++ return -1 ++} ++ ++set f [open "|getconf PAGESIZE" "r"] ++gets $f pagesize ++close $f ++ ++gdb_exit ++gdb_start ++gdb_reinitialize_dir $srcdir/$subdir ++gdb_load ${binfile} ++ ++set pid_of_gdb [exp_pid -i [board_info host fileid]] ++ ++if { [runto_main] < 0 } { ++ untested vla-overflow ++ return -1 ++} ++ ++# Get the GDB memory size when we stay at main. ++ ++proc memory_v_pages_get {} { ++ global pid_of_gdb pagesize ++ set fd [open "/proc/$pid_of_gdb/statm"] ++ gets $fd line ++ close $fd ++ # number of pages of virtual memory ++ scan $line "%d" drs ++ return $drs ++} ++ ++set pages_found [memory_v_pages_get] ++ ++# s390x with glibc-debuginfo.s390x installed used approx. 16MB. ++set mb_reserve 40 ++verbose -log "pages_found = $pages_found, mb_reserve = $mb_reserve" ++set kb_found [expr $pages_found * $pagesize / 1024] ++set kb_permit [expr $kb_found + 1 * 1024 + $mb_reserve * 1024] ++verbose -log "kb_found = $kb_found, kb_permit = $kb_permit" ++ ++# Create the ulimit wrapper. ++set f [open $shfile "w"] ++puts $f "#! /bin/sh" ++puts $f "ulimit -v $kb_permit" ++puts $f "exec $GDB \"\$@\"" ++close $f ++remote_exec host "chmod +x $shfile" ++ ++gdb_exit ++set GDBold $GDB ++set GDB "$shfile" ++gdb_start ++set GDB $GDBold ++ ++gdb_reinitialize_dir $srcdir/$subdir ++gdb_load ${binfile} ++ ++set pid_of_gdb [exp_pid -i [board_info host fileid]] ++ ++# Check the size again after the second run. ++# We must not stop in main as it would cache `array' and never crash later. + -+# This file was written by Jan Kratochvil . ++gdb_run_cmd + -+set testfile "logical" -+set srcfile ${testfile}.f90 -+set binfile ${objdir}/${subdir}/${testfile} ++verbose -log "kb_found before abort() = [expr [memory_v_pages_get] * $pagesize / 1024]" + -+if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug f77 quiet}] != "" } { -+ untested "Couldn't compile ${srcfile}" -+ return -1 -+} ++gdb_test "" "Program received signal SIGABRT, Aborted..*" "Enter abort()" + -+gdb_exit -+gdb_start -+gdb_reinitialize_dir $srcdir/$subdir -+gdb_load ${binfile} ++verbose -log "kb_found in abort() = [expr [memory_v_pages_get] * $pagesize / 1024]" + -+if ![runto MAIN__] then { -+ perror "couldn't run to breakpoint MAIN__" -+ continue -+} ++# `abort' can get expressed as `*__GI_abort'. ++gdb_test "bt" "in \[^ \]*abort \\(.* in main \\(.*" "Backtrace after abort()" + -+gdb_breakpoint [gdb_get_line_number "stop-here"] -+gdb_continue_to_breakpoint "stop-here" -+gdb_test "p l" " = \\.TRUE\\." -+gdb_test "p l1" " = \\.TRUE\\." -+gdb_test "p l2" " = \\.TRUE\\." -+gdb_test "p l4" " = \\.TRUE\\." -+gdb_test "p l8" " = \\.TRUE\\." -diff --git a/gdb/testsuite/gdb.fortran/logical.f90 b/gdb/testsuite/gdb.fortran/logical.f90 ++verbose -log "kb_found in bt after abort() = [expr [memory_v_pages_get] * $pagesize / 1024]" +diff --git a/gdb/testsuite/gdb.base/vla.c b/gdb/testsuite/gdb.base/vla.c new file mode 100644 -index 0000000..4229304 +index 0000000..e1f3ed1 --- /dev/null -+++ b/gdb/testsuite/gdb.fortran/logical.f90 -@@ -0,0 +1,33 @@ -+! Copyright 2008 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. -+! -+! Ihis file is the Fortran source file for dynamic.exp. -+! Original file written by Jakub Jelinek . -+! Modified for the GDB testcase by Jan Kratochvil . ++++ b/gdb/testsuite/gdb.base/vla.c +@@ -0,0 +1,55 @@ ++/* This testcase is part of GDB, the GNU debugger. + -+program test -+ logical :: l -+ logical (kind=1) :: l1 -+ logical (kind=2) :: l2 -+ logical (kind=4) :: l4 -+ logical (kind=8) :: l8 -+ l = .TRUE. -+ l1 = .TRUE. -+ l2 = .TRUE. -+ l4 = .TRUE. -+ l8 = .TRUE. -+ l = .FALSE. ! stop-here -+end -diff --git a/gdb/testsuite/gdb.fortran/module.exp b/gdb/testsuite/gdb.fortran/module.exp -index 342ccee..c836c3c 100644 ---- a/gdb/testsuite/gdb.fortran/module.exp -+++ b/gdb/testsuite/gdb.fortran/module.exp -@@ -15,21 +15,31 @@ - - set testfile "module" - set srcfile ${testfile}.f90 --set binfile ${objdir}/${subdir}/${testfile} - --if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug f77 quiet}] != "" } { -- untested "Couldn't compile ${srcfile}" -+if { [prepare_for_testing $testfile.exp $testfile $srcfile {debug f77}] } { - return -1 - } - --gdb_exit --gdb_start --gdb_reinitialize_dir $srcdir/$subdir --gdb_load ${binfile} -- - if ![runto MAIN__] then { - perror "couldn't run to breakpoint MAIN__" - continue - } - --gdb_test "print i" " = 42" -+# Do not use simple single-letter names as GDB would pick up for expectedly -+# nonexisting symbols some static variables from system libraries debuginfos. -+ -+gdb_breakpoint [gdb_get_line_number "i-is-1"] -+gdb_continue_to_breakpoint "i-is-1" ".*i-is-1.*" -+gdb_test "print var_i" " = 1" "print var_i value 1" -+ -+gdb_breakpoint [gdb_get_line_number "i-is-2"] -+gdb_continue_to_breakpoint "i-is-2" ".*i-is-2.*" -+gdb_test "print var_i" " = 2" "print var_i value 2" -+ -+gdb_breakpoint [gdb_get_line_number "a-b-c-d"] -+gdb_continue_to_breakpoint "a-b-c-d" ".*a-b-c-d.*" -+gdb_test "print var_a" "No symbol \"var_a\" in current context\\." -+gdb_test "print var_b" " = 11" -+gdb_test "print var_c" "No symbol \"var_c\" in current context\\." -+gdb_test "print var_d" " = 12" -+gdb_test "print var_i" " = 14" "print var_i value 14" -diff --git a/gdb/testsuite/gdb.fortran/module.f90 b/gdb/testsuite/gdb.fortran/module.f90 -index 501ccc8..118931d 100644 ---- a/gdb/testsuite/gdb.fortran/module.f90 -+++ b/gdb/testsuite/gdb.fortran/module.f90 -@@ -13,10 +13,37 @@ - ! You should have received a copy of the GNU General Public License - ! along with this program. If not, see . - --module mod -- integer :: i = 42 --end module mod -+module mod1 -+ integer :: var_i = 1 -+end module mod1 - -- use mod -- print *, i -+module mod2 -+ integer :: var_i = 2 -+end module mod2 -+ -+module modmany -+ integer :: var_a = 10, var_b = 11, var_c = 12, var_i = 14 -+end module modmany -+ -+ subroutine sub1 -+ use mod1 -+ if (var_i .ne. 1) call abort -+ var_i = var_i ! i-is-1 -+ end -+ -+ subroutine sub2 -+ use mod2 -+ if (var_i .ne. 2) call abort -+ var_i = var_i ! i-is-2 -+ end -+ -+ use modmany, only: var_b, var_d => var_c, var_i -+ -+ call sub1 -+ call sub2 -+ -+ if (var_b .ne. 11) call abort -+ if (var_d .ne. 12) call abort -+ if (var_i .ne. 14) call abort -+ var_b = var_b ! a-b-c-d - end -diff --git a/gdb/testsuite/gdb.fortran/string.exp b/gdb/testsuite/gdb.fortran/string.exp -new file mode 100644 -index 0000000..b1120c3 ---- /dev/null -+++ b/gdb/testsuite/gdb.fortran/string.exp -@@ -0,0 +1,59 @@ -+# Copyright 2008 Free Software Foundation, Inc. ++ Copyright 2008 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. ++ 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 file was written by Jan Kratochvil . ++ 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. + -+# This file is part of the gdb testsuite. It contains tests for Fortran -+# strings with dynamic length. ++ You should have received a copy of the GNU General Public License ++ along with this program. If not, see . */ + -+set testfile "string" -+set srcfile ${testfile}.f90 -+set binfile ${objdir}/${subdir}/${testfile} ++#include + -+if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug f77 quiet}] != "" } { -+ untested "Couldn't compile ${srcfile}" -+ return -1 ++void ++marker (void) ++{ +} + -+gdb_exit -+gdb_start -+gdb_reinitialize_dir $srcdir/$subdir -+gdb_load ${binfile} -+ -+if ![runto MAIN__] then { -+ perror "couldn't run to breakpoint MAIN__" -+ continue ++void ++bar (char *a, char *b, char *c, int size) ++{ ++ memset (a, '1', size); ++ memset (b, '2', size); ++ memset (c, '3', 48); +} + -+gdb_breakpoint [gdb_get_line_number "var-init"] -+gdb_continue_to_breakpoint "var-init" -+gdb_test "ptype c" "type = character(\\(kind=1\\)|\\*1)" -+gdb_test "ptype d" "type = character(\\(kind=8\\)|\\*8)" -+gdb_test "ptype e" "type = character(\\(kind=4\\)|\\*4)" -+gdb_test "ptype f" "type = character(\\(kind=4\\)|\\*4) \\(7,8:10\\)" -+gdb_test "ptype *e" "Attempt to take contents of a non-pointer value." -+gdb_test "ptype *f" "type = character(\\(kind=4\\)|\\*4) \\(7\\)" -+gdb_test "p c" "\\$\[0-9\]* = 'c'" -+gdb_test "p d" "\\$\[0-9\]* = 'd '" -+gdb_test "p e" "\\$\[0-9\]* = 'g '" -+gdb_test "p f" "\\$\[0-9\]* = \\(\\( 'h ', 'h ', 'h ', 'h ', 'h ', 'h ', 'h '\\) \\( 'h ', 'h ', 'h ', 'h ', 'h ', 'h ', 'h '\\) \\( 'h ', 'h ', 'h ', 'h ', 'h ', 'h ', 'h '\\) \\)" -+gdb_test "p *e" "Attempt to take contents of a non-pointer value." -+gdb_test "p *f" "Attempt to take contents of a non-pointer value." ++void ++foo (int size) ++{ ++ char temp1[size]; ++ char temp3[48]; + -+gdb_breakpoint [gdb_get_line_number "var-finish"] -+gdb_continue_to_breakpoint "var-finish" -+gdb_test "p e" "\\$\[0-9\]* = 'e '" "p e re-set" -+gdb_test "p f" "\\$\[0-9\]* = \\(\\( 'f ', 'f ', 'f ', 'f ', 'f ', 'f ', 'f '\\) \\( 'f2 ', 'f ', 'f ', 'f ', 'f ', 'f ', 'f '\\) \\( 'f ', 'f ', 'f ', 'f ', 'f ', 'f ', 'f '\\) \\)" "p *f re-set" -diff --git a/gdb/testsuite/gdb.fortran/string.f90 b/gdb/testsuite/gdb.fortran/string.f90 -new file mode 100644 -index 0000000..226dc5d ---- /dev/null -+++ b/gdb/testsuite/gdb.fortran/string.f90 -@@ -0,0 +1,37 @@ -+! Copyright 2008 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. -+! -+! Ihis file is the Fortran source file for dynamic.exp. -+! Original file written by Jakub Jelinek . -+! Modified for the GDB testcase by Jan Kratochvil . ++ temp1[size - 1] = '\0'; ++ { ++ char temp2[size]; + -+subroutine foo (e, f) -+ character (len=1) :: c -+ character (len=8) :: d -+ character (len=*) :: e -+ character (len=*) :: f (1:7, 8:10) -+ c = 'c' -+ d = 'd' -+ e = 'e' ! var-init -+ f = 'f' -+ f(1,9) = 'f2' -+ c = 'c' ! var-finish -+end subroutine foo -+ character (len=4) :: g, h (1:7, 8:10) -+ g = 'g' -+ h = 'h' -+ call foo (g, h) -+end -diff --git a/gdb/testsuite/gdb.gdb/selftest.exp b/gdb/testsuite/gdb.gdb/selftest.exp -index 495ae45..d08d7a4 100644 ---- a/gdb/testsuite/gdb.gdb/selftest.exp -+++ b/gdb/testsuite/gdb.gdb/selftest.exp -@@ -95,6 +95,10 @@ proc do_steps_and_nexts {} { - set description "step over ttyarg initialization" - set command "step" - } -+ -re ".*python_script = 0.*$gdb_prompt $" { -+ set description "step over python_script initialization" -+ set command "step" -+ } - -re ".*time_at_startup = get_run_time.*$gdb_prompt $" { - set description "next over get_run_time and everything it calls" - set command "next" -diff --git a/gdb/testsuite/gdb.java/jnpe.exp b/gdb/testsuite/gdb.java/jnpe.exp ++ bar (temp1, temp2, temp3, size); ++ ++ marker (); /* break-here */ ++ } ++} ++ ++int ++main (void) ++{ ++ foo (26); ++ foo (78); ++ return 0; ++} +diff --git a/gdb/testsuite/gdb.base/vla.exp b/gdb/testsuite/gdb.base/vla.exp new file mode 100644 -index 0000000..e71391e +index 0000000..5da7378 --- /dev/null -+++ b/gdb/testsuite/gdb.java/jnpe.exp -@@ -0,0 +1,77 @@ -+# Copyright 2009 Free Software Foundation, Inc. ++++ b/gdb/testsuite/gdb.base/vla.exp +@@ -0,0 +1,62 @@ ++# Copyright 2008 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 @@ -25658,78 +12787,62 @@ index 0000000..e71391e +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + -+if $tracelevel then { -+ strace $tracelevel -+} -+ -+load_lib "java.exp" -+ -+set testfile "jnpe" -+set srcfile ${testfile}.java -+set binfile ${objdir}/${subdir}/${testfile} -+if { [compile_java_from_source ${srcdir}/$subdir/${srcfile} ${binfile} "-g"] != "" } { -+ untested "Couldn't compile ${srcdir}/$subdir/${srcfile}" -+ return -1 -+} -+ -+set prms_id 0 -+set bug_id 0 -+ -+# Start with a fresh gdb. -+ -+gdb_exit -+gdb_start -+gdb_reinitialize_dir $srcdir/$subdir -+gdb_load ${binfile} -+ -+set line [gdb_get_line_number "break here" $testfile.java] -+gdb_test "break $testfile.java:$line" "" -+ -+gdb_test "run" \ -+ "// break here.*" \ -+ "run java next-over-throw" -+ -+# See whether we have the needed unwinder hooks. -+set ok 1 -+gdb_test_multiple "print _Unwind_DebugHook" "check for unwinder hook in java" { -+ -re "= .*_Unwind_DebugHook.*\r\n$gdb_prompt $" { -+ pass "check for unwinder hook in java" -+ } -+ -re "No symbol .* in current context.?\r\n$gdb_prompt $" { -+ # Pass the test so we don't get bogus fails in the results. -+ setup_xfail *-*-* -+ fail "check for unwinder hook in java" -+ set ok 0 -+ } ++set testfile vla ++set srcfile ${testfile}.c ++set binfile ${objdir}/${subdir}/${testfile} ++if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } { ++ untested "Couldn't compile test program" ++ return -1 +} -+if {!$ok} { -+ untested jnpe.exp ++ ++gdb_exit ++gdb_start ++gdb_reinitialize_dir $srcdir/$subdir ++gdb_load ${binfile} ++ ++if ![runto_main] { ++ untested vla + return -1 +} + -+gdb_test "handle SIGSEGV nostop noprint" \ -+ "SIGSEGV.*fault" \ -+ "disable SIGSEGV for next-over-NPE" ++gdb_breakpoint [gdb_get_line_number "break-here"] + -+# The line where we stop differ according to gcj; check just we did not already -+# execute the catch point. ++gdb_continue_to_breakpoint "break-here" + -+gdb_test "next" \ -+ "" \ -+ "next over NPE" ++gdb_test "whatis temp1" "type = char \\\[variable\\\]" "first: whatis temp1" ++gdb_test "whatis temp2" "type = char \\\[variable\\\]" "first: whatis temp2" ++gdb_test "whatis temp3" "type = char \\\[48\\\]" "first: whatis temp3" + -+gdb_breakpoint [gdb_get_line_number "catch point"] -+gdb_continue_to_breakpoint "catch point" ".*// catch point.*" -diff --git a/gdb/testsuite/gdb.java/jnpe.java b/gdb/testsuite/gdb.java/jnpe.java ++gdb_test "ptype temp1" "type = char \\\[26\\\]" "first: ptype temp1" ++gdb_test "ptype temp2" "type = char \\\[26\\\]" "first: ptype temp2" ++gdb_test "ptype temp3" "type = char \\\[48\\\]" "first: ptype temp3" ++ ++gdb_test "p temp1" " = '1' " "first: print temp1" ++gdb_test "p temp2" " = '2' " "first: print temp2" ++gdb_test "p temp3" " = '3' " "first: print temp3" ++ ++gdb_continue_to_breakpoint "break-here" ++ ++gdb_test "whatis temp1" "type = char \\\[variable\\\]" "second: whatis temp1" ++gdb_test "whatis temp2" "type = char \\\[variable\\\]" "second: whatis temp2" ++gdb_test "whatis temp3" "type = char \\\[48\\\]" "second: whatis temp3" ++ ++gdb_test "ptype temp1" "type = char \\\[78\\\]" "second: ptype temp1" ++gdb_test "ptype temp2" "type = char \\\[78\\\]" "second: ptype temp2" ++gdb_test "ptype temp3" "type = char \\\[48\\\]" "second: ptype temp3" ++ ++gdb_test "p temp1" " = '1' " "second: print temp1" ++gdb_test "p temp2" " = '2' " "second: print temp2" ++gdb_test "p temp3" " = '3' " "second: print temp3" +diff --git a/gdb/testsuite/gdb.cp/gdb9593.cc b/gdb/testsuite/gdb.cp/gdb9593.cc new file mode 100644 -index 0000000..3524830 +index 0000000..783c962 --- /dev/null -+++ b/gdb/testsuite/gdb.java/jnpe.java -@@ -0,0 +1,38 @@ -+// Test next-over-NPE. ++++ b/gdb/testsuite/gdb.cp/gdb9593.cc +@@ -0,0 +1,180 @@ +/* This testcase is part of GDB, the GNU debugger. + -+ Copyright 2009 Free Software Foundation, Inc. ++ Copyright 2008, 2009 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 @@ -25744,99 +12857,180 @@ index 0000000..3524830 + You should have received a copy of the GNU General Public License + along with this program. If not, see . + */ ++#include + -+public class jnpe ++using namespace std; ++ ++class NextOverThrowDerivates +{ -+ public static String npe () ++ ++public: ++ ++ ++ // Single throw an exception in this function. ++ void function1() + { -+ return ((Object) null).toString(); ++ throw 20; + } + -+ public static void main (String[] args) ++ // Throw an exception in another function. ++ void function2() ++ { ++ function1(); ++ } ++ ++ // Throw an exception in another function, but handle it ++ // locally. ++ void function3 () ++ { ++ { ++ try ++ { ++ function1 (); ++ } ++ catch (...) ++ { ++ cout << "Caught and handled function1 exception" << endl; ++ } ++ } ++ } ++ ++ void rethrow () + { + try + { -+ System.out.println (npe ()); // break here ++ function1 (); + } -+ catch (NullPointerException n) ++ catch (...) + { -+ System.out.println ("success"); // catch point ++ throw; + } + } -+} -diff --git a/gdb/testsuite/gdb.opt/array-from-register-func.c b/gdb/testsuite/gdb.opt/array-from-register-func.c -new file mode 100644 -index 0000000..729f457 ---- /dev/null -+++ b/gdb/testsuite/gdb.opt/array-from-register-func.c -@@ -0,0 +1,22 @@ -+/* This file is part of GDB, the GNU debugger. + -+ Copyright 2009 Free Software Foundation, Inc. ++ void finish () ++ { ++ // We use this to test that a "finish" here does not end up in ++ // this frame, but in the one above. ++ try ++ { ++ function1 (); ++ } ++ catch (int x) ++ { ++ } ++ function1 (); // marker for until ++ } + -+ 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. ++ void until () ++ { ++ function1 (); ++ function1 (); // until here ++ } + -+ 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. ++}; ++NextOverThrowDerivates next_cases; + -+ You should have received a copy of the GNU General Public License -+ along with this program. If not, see . */ + -+int -+func (int *arr) -+{ -+ return arr[0]; -+} -diff --git a/gdb/testsuite/gdb.opt/array-from-register.c b/gdb/testsuite/gdb.opt/array-from-register.c -new file mode 100644 -index 0000000..3090e7e ---- /dev/null -+++ b/gdb/testsuite/gdb.opt/array-from-register.c -@@ -0,0 +1,28 @@ -+/* This file is part of GDB, the GNU debugger. ++int main () ++{ ++ try ++ { ++ next_cases.function1 (); ++ } ++ catch (...) ++ { ++ // Discard ++ } + -+ Copyright 2009 Free Software Foundation, Inc. ++ try ++ { ++ next_cases.function2 (); ++ } ++ catch (...) ++ { ++ // Discard ++ } + -+ 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. ++ try ++ { ++ // This is duplicated so we can next over one but step into ++ // another. ++ next_cases.function2 (); ++ } ++ catch (...) ++ { ++ // Discard ++ } + -+ 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. ++ next_cases.function3 (); + -+ You should have received a copy of the GNU General Public License -+ along with this program. If not, see . */ ++ try ++ { ++ next_cases.rethrow (); ++ } ++ catch (...) ++ { ++ // Discard ++ } + -+extern int func (int *arr); ++ try ++ { ++ // Another duplicate so we can test "finish". ++ next_cases.function2 (); ++ } ++ catch (...) ++ { ++ // Discard ++ } + -+int -+main (void) -+{ -+ int arr[] = { 42 }; ++ // Another test for "finish". ++ try ++ { ++ next_cases.finish (); ++ } ++ catch (...) ++ { ++ } + -+ func (arr); ++ // Test of "until". ++ try ++ { ++ next_cases.finish (); ++ } ++ catch (...) ++ { ++ } + -+ return 0; ++ // Test of "until" with an argument. ++ try ++ { ++ next_cases.until (); ++ } ++ catch (...) ++ { ++ } ++ ++ // Test of "advance". ++ try ++ { ++ next_cases.until (); ++ } ++ catch (...) ++ { ++ } +} -diff --git a/gdb/testsuite/gdb.opt/array-from-register.exp b/gdb/testsuite/gdb.opt/array-from-register.exp ++ +diff --git a/gdb/testsuite/gdb.cp/gdb9593.exp b/gdb/testsuite/gdb.cp/gdb9593.exp new file mode 100644 -index 0000000..f2de718 +index 0000000..3dad7ca --- /dev/null -+++ b/gdb/testsuite/gdb.opt/array-from-register.exp -@@ -0,0 +1,33 @@ -+# Copyright 2009 Free Software Foundation, Inc. -+# ++++ b/gdb/testsuite/gdb.cp/gdb9593.exp +@@ -0,0 +1,182 @@ ++# Copyright 2008, 2009 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 ++# 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, @@ -25845,347 +13039,400 @@ index 0000000..f2de718 +# 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. -+# -+# This file is part of the gdb testsuite. ++# along with this program. If not, see . + -+if { [prepare_for_testing array-from-register.exp "array-from-register" \ -+ {array-from-register.c array-from-register-func.c} \ -+ {debug optimize=-O2}] } { -+ return -1 ++ ++if $tracelevel then { ++ strace $tracelevel +} + -+if ![runto func] then { ++if { [skip_cplus_tests] } { continue } ++ ++set testfile "gdb9593" ++set srcfile ${testfile}.cc ++set binfile $objdir/$subdir/$testfile ++ ++# Create and source the file that provides information about the compiler ++# used to compile the test case. ++if [get_compiler_info ${binfile} "c++"] { ++ untested gdb9593.exp + return -1 +} + -+gdb_test "p arr" "\\$\[0-9\]+ = \\(int \\*\\) *0x\[0-9a-f\]+" -+ -+# Seen regression: -+# Address requested for identifier "arr" which is in register $rdi -+gdb_test "p arr\[0\]" "\\$\[0-9\]+ = 42" -diff --git a/gdb/testsuite/gdb.opt/fortran-string.exp b/gdb/testsuite/gdb.opt/fortran-string.exp -new file mode 100644 -index 0000000..f997eec ---- /dev/null -+++ b/gdb/testsuite/gdb.opt/fortran-string.exp -@@ -0,0 +1,41 @@ -+# Copyright 2009 Free Software Foundation, Inc. ++if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } { ++ untested gdb9593.exp ++ return -1 ++} + -+# 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 targets can't do function calls, so don't even bother with this ++# test. ++if [target_info exists gdb,cannot_call_functions] { ++ setup_xfail "*-*-*" 9593 ++ fail "This target can not call functions" ++ continue ++} + -+# This file was written by Jan Kratochvil . ++gdb_exit ++gdb_start ++gdb_reinitialize_dir $srcdir/$subdir ++gdb_load ${binfile} + -+# Test GDB can cope with Fortran strings having their length present in a CPU -+# register. With -O0 the string length is passed on the stack. To make this -+# test meaningful the follow assertion should pass. It is not being checked -+# here as the "_s" symbol is compiler dependent: -+# (gdb) info address _s -+# Symbol "_s" is a variable in register XX. ++if ![runto_main] then { ++ perror "couldn't run to main" ++ continue ++} + -+set test fortran-string -+set srcfile ${test}.f90 -+if { [prepare_for_testing ${test}.exp ${test} ${srcfile} {debug f77 additional_flags=-O2}] } { ++# See whether we have the needed unwinder hooks. ++set ok 1 ++gdb_test_multiple "print _Unwind_DebugHook" "check for unwinder hook" { ++ -re "= .*_Unwind_DebugHook.*\r\n$gdb_prompt $" { ++ pass "check for unwinder hook" ++ } ++ -re "No symbol .* in current context.\r\n$gdb_prompt $" { ++ # Pass the test so we don't get bogus fails in the results. ++ pass "check for unwinder hook" ++ set ok 0 ++ } ++} ++if {!$ok} { ++ untested gdb9593.exp + return -1 +} + -+if ![runto MAIN__] then { -+ perror "couldn't run to breakpoint MAIN__" -+ continue -+} ++# See http://sourceware.org/bugzilla/show_bug.cgi?id=9593 + -+gdb_breakpoint [gdb_get_line_number "s = s"] -+gdb_continue_to_breakpoint "s = s" -+gdb_test "frame" ".*s='foo'.*" -+gdb_test "ptype s" "type = character\\*3" -+gdb_test "p s" "\\$\[0-9\]* = 'foo'" -diff --git a/gdb/testsuite/gdb.opt/fortran-string.f90 b/gdb/testsuite/gdb.opt/fortran-string.f90 -new file mode 100644 -index 0000000..e48d520 ---- /dev/null -+++ b/gdb/testsuite/gdb.opt/fortran-string.f90 -@@ -0,0 +1,28 @@ -+! Copyright 2009 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. -+! -+! Ihis file is the Fortran source file for dynamic.exp. -+! Original file written by Jakub Jelinek . -+! Modified for the GDB testcase by Jan Kratochvil . ++gdb_test "next" \ ++ ".*catch (...).*" \ ++ "next over a throw 1" + -+ subroutine f(s) -+ character*(*) s -+ s = s -+ end ++gdb_test "next" \ ++ ".*next_cases.function2.*" \ ++ "next past catch 1" + -+ program main -+ call f ('foo') -+ end -diff --git a/gdb/testsuite/gdb.python/py-cmd.exp b/gdb/testsuite/gdb.python/py-cmd.exp -index f6ef938..1032a2d 100644 ---- a/gdb/testsuite/gdb.python/py-cmd.exp -+++ b/gdb/testsuite/gdb.python/py-cmd.exp -@@ -20,36 +20,15 @@ if $tracelevel then { - strace $tracelevel - } - --# Usage: gdb_py_test_multiple NAME INPUT RESULT {INPUT RESULT}... --# Run a test named NAME, consisting of multiple lines of input. --# After each input line INPUT, search for result line RESULT. --# Succeed if all results are seen; fail otherwise. --proc gdb_py_test_multiple {name args} { -- global gdb_prompt -- foreach {input result} $args { -- if {[gdb_test_multiple $input "$name - $input" { -- -re "\[\r\n\]*($result)\[\r\n\]+($gdb_prompt | *>)$" { -- pass "$name - $input" -- } -- }]} { -- return 1 -- } -- } -- return 0 --} -- - # Start with a fresh gdb. - - gdb_exit - gdb_start - gdb_reinitialize_dir $srcdir/$subdir - --gdb_test_multiple "python print 'hello, world!'" "verify python support" { -- -re "not supported.*$gdb_prompt $" { -- unsupported "python support is disabled" -- return -1 -- } -- -re "$gdb_prompt $" {} -+if ![python_supported] then { -+ unsupported "python support is disabled" -+ return -1 - } - - # Test a simple command. -diff --git a/gdb/testsuite/gdb.python/py-frame.exp b/gdb/testsuite/gdb.python/py-frame.exp -index a67eaa3..5380c0f 100644 ---- a/gdb/testsuite/gdb.python/py-frame.exp -+++ b/gdb/testsuite/gdb.python/py-frame.exp -@@ -20,40 +20,28 @@ if $tracelevel then { - strace $tracelevel - } - -+# Start with a fresh gdb. ++gdb_test "next" \ ++ ".*catch (...).*" \ ++ "next over a throw 2" ++ ++gdb_test "next" \ ++ ".*next_cases.function2.*" \ ++ "next past catch 2" ++ ++gdb_test "step" \ ++ ".*function1().*" \ ++ "step into function2 1" ++ ++gdb_test "next" \ ++ ".*catch (...).*" \ ++ "next over a throw 3" ++ ++gdb_test "next" \ ++ ".*next_cases.function3.*" \ ++ "next past catch 3" ++ ++gdb_test "next" \ ++ ".*next_cases.rethrow.*" \ ++ "next over a throw 4" ++ ++gdb_test "next" \ ++ ".*catch (...).*" \ ++ "next over a rethrow" ++ ++gdb_test "next" \ ++ ".*next_cases.function2.*" \ ++ "next after a rethrow" ++ ++gdb_test "step" \ ++ ".*function1().*" \ ++ "step into function2 2" ++ ++gdb_test "finish" \ ++ ".*catch (...).*" \ ++ "finish 1" ++ ++gdb_test "next" \ ++ ".*next_cases.finish ().*" \ ++ "next past catch 4" ++ ++gdb_test "step" \ ++ ".*function1 ().*" \ ++ "step into finish method" ++ ++gdb_test "finish" \ ++ ".*catch (...).*" \ ++ "finish 2" ++ ++gdb_test "next" \ ++ ".*next_cases.finish ().*" \ ++ "next past catch 5" ++ ++gdb_test "step" \ ++ ".*function1 ().*" \ ++ "step into finish, for until" ++ ++gdb_test "until" \ ++ ".*function1 ().*" \ ++ "until with no argument 1" ++ ++set line [gdb_get_line_number "marker for until" $testfile.cc] ++ ++gdb_test "until $line" \ ++ ".*function1 ().*" \ ++ "next past catch 6" + -+gdb_exit -+gdb_start -+gdb_reinitialize_dir $srcdir/$subdir ++gdb_test "until" \ ++ ".*catch (...).*" \ ++ "until with no argument 2" + -+if ![python_supported] then { -+ unsupported "python support is disabled" -+ return -1 -+} ++set line [gdb_get_line_number "until here" $testfile.cc] + - set testfile "py-frame" - set srcfile ${testfile}.c - set binfile ${objdir}/${subdir}/${testfile} ++gdb_test "next" \ ++ ".*next_cases.until ().*" \ ++ "next past catch 6" + - if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } { - untested "Couldn't compile ${srcfile}" - return -1 - } - --# Run a command in GDB, and report a failure if a Python exception is thrown. --# If report_pass is true, report a pass if no exception is thrown. --proc gdb_py_test_silent_cmd {cmd name report_pass} { -- global gdb_prompt -- -- gdb_test_multiple $cmd $name { -- -re "Traceback.*$gdb_prompt $" { fail $name } -- -re "$gdb_prompt $" { if $report_pass { pass $name } } -- } --} -- --# Start with a fresh gdb. -- --gdb_exit --gdb_start --gdb_reinitialize_dir $srcdir/$subdir - gdb_load ${binfile} - --gdb_test_multiple "python print 'hello, world!'" "verify python support" { -- -re "not supported.*$gdb_prompt $" { -- unsupported "python support is disabled" -- return -1 -- } -- -re "$gdb_prompt $" {} --} -- - # The following tests require execution. - - if ![runto_main] then { -@@ -65,19 +53,20 @@ gdb_breakpoint "f2" - gdb_continue_to_breakpoint "breakpoint at f2" - gdb_test "up" "" "" - --gdb_py_test_silent_cmd "python f1 = gdb.selected_frame ()" "get second frame" 0 --gdb_py_test_silent_cmd "python f0 = f1.newer ()" "get first frame" 0 -+gdb_py_test_silent_cmd "python frames = gdb.selected_thread ().frames ()" "get frames list" 1 -+gdb_test "python print frames" "\\(, , \\)" "verify frames list" -+gdb_py_test_silent_cmd "python f0 = frames\[0\]" "get first frame" 0 -+gdb_py_test_silent_cmd "python f1 = frames\[1\]" "get second frame" 0 - - gdb_test "python print 'result =', f0 == f1" " = False" "test equality comparison (false)" - gdb_test "python print 'result =', f0 == f0" " = True" "test equality comparison (true)" --gdb_test "python print 'result =', f0 != f1" " = True" "test inequality comparison (true)" --gdb_test "python print 'result =', f0 != f0" " = False" "test inequality comparison (false)" - gdb_test "python print 'result =', f0.is_valid ()" " = True" "test Frame.is_valid" - gdb_test "python print 'result =', f0.name ()" " = f2" "test Frame.name" - gdb_test "python print 'result =', f0.type () == gdb.NORMAL_FRAME" " = True" "test Frame.type" - gdb_test "python print 'result =', f0.unwind_stop_reason () == gdb.FRAME_UNWIND_NO_REASON" " = True" "test Frame.type" - gdb_test "python print 'result =', gdb.frame_stop_reason_string (gdb.FRAME_UNWIND_INNER_ID)" " = previous frame inner to this frame \\(corrupt stack\\?\\)" "test gdb.frame_stop_reason_string" - gdb_test "python print 'result =', f0.pc ()" " = \[0-9\]+" "test Frame.pc" -+gdb_test "python print 'result =', f0.function ()" " = symbol for f2" "test Frame.function" - gdb_test "python print 'result =', f0.older () == f1" " = True" "test Frame.older" - gdb_test "python print 'result =', f1.newer () == f0" " = True" "test Frame.newer" - gdb_test "python print 'result =', f0.read_var ('variable_which_surely_doesnt_exist')" \ -@@ -85,4 +74,7 @@ gdb_test "python print 'result =', f0.read_var ('variable_which_surely_doesnt_ex - "test Frame.read_var - error" - gdb_test "python print 'result =', f0.read_var ('a')" " = 1" "test Frame.read_var - success" - -+gdb_test "python print 'result =', gdb.selected_thread ().newest_frame () == f0" " = True" "test gdb.newest_frame" - gdb_test "python print 'result =', gdb.selected_frame () == f1" " = True" "test gdb.selected_frame" ++gdb_test "step" \ ++ ".*function1 ().*" \ ++ "step into until" + -+gdb_test "python print 'result =', f0.block ()" "" "test Frame.block" -diff --git a/gdb/testsuite/gdb.python/py-function.exp b/gdb/testsuite/gdb.python/py-function.exp -index 30fde7d..14cd90c 100644 ---- a/gdb/testsuite/gdb.python/py-function.exp -+++ b/gdb/testsuite/gdb.python/py-function.exp -@@ -20,36 +20,15 @@ if $tracelevel then { - strace $tracelevel - } - --# Usage: gdb_py_test_multiple NAME INPUT RESULT {INPUT RESULT}... --# Run a test named NAME, consisting of multiple lines of input. --# After each input line INPUT, search for result line RESULT. --# Succeed if all results are seen; fail otherwise. --proc gdb_py_test_multiple {name args} { -- global gdb_prompt -- foreach {input result} $args { -- if {[gdb_test_multiple $input "$name - $input" { -- -re "\[\r\n\]*($result)\[\r\n\]+($gdb_prompt | *>)$" { -- pass "$name - $input" -- } -- }]} { -- return 1 -- } -- } -- return 0 --} -- - # Start with a fresh gdb. - - gdb_exit - gdb_start - gdb_reinitialize_dir $srcdir/$subdir - --gdb_test_multiple "python print 'hello, world!'" "verify python support" { -- -re "not supported.*$gdb_prompt $" { -- unsupported "python support is disabled" -- return -1 -- } -- -re "$gdb_prompt $" {} -+if ![python_supported] then { -+ unsupported "python support is disabled" -+ return -1 - } - - gdb_py_test_multiple "input convenience function" \ -diff --git a/gdb/testsuite/gdb.python/py-inferior.c b/gdb/testsuite/gdb.python/py-inferior.c ++gdb_test "until $line" \ ++ ".*catch (...).*" \ ++ "until-over-throw" ++ ++gdb_test "next" \ ++ ".*next_cases.until ().*" \ ++ "next past catch 7" ++ ++gdb_test "step" \ ++ ".*function1 ().*" \ ++ "step into until, for advance" ++ ++gdb_test "advance $line" \ ++ ".*catch (...).*" \ ++ "advance-over-throw" +diff --git a/gdb/testsuite/gdb.dwarf2/dw2-bound-loclist.S b/gdb/testsuite/gdb.dwarf2/dw2-bound-loclist.S new file mode 100644 -index 0000000..0b48299 +index 0000000..7fb00ea --- /dev/null -+++ b/gdb/testsuite/gdb.python/py-inferior.c -@@ -0,0 +1,49 @@ -+#include -+#include -+#include -+#include ++++ b/gdb/testsuite/gdb.dwarf2/dw2-bound-loclist.S +@@ -0,0 +1,212 @@ ++/* This testcase is part of GDB, the GNU debugger. + -+#define CHUNK_SIZE 16000 /* same as findcmd.c's */ -+#define BUF_SIZE (2 * CHUNK_SIZE) /* at least two chunks */ ++ Copyright 2010 Free Software Foundation, Inc. + -+static int8_t int8_search_buf[100]; -+static int16_t int16_search_buf[100]; -+static int32_t int32_search_buf[100]; -+static int64_t int64_search_buf[100]; ++ 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. + -+static char *search_buf; -+static int search_buf_size; ++ 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. + -+static int x; ++ You should have received a copy of the GNU General Public License ++ along with this program. If not, see . */ + ++/* Debug information */ + -+int f2 (int a) -+{ -+ char *str = "hello, testsuite"; ++/* We will `break *main' at the very first instruction. */ ++#define main_length 1 + -+ puts (str); /* Break here. */ ++ .section .data ++vardata: ++ /* See DW_OP_lit3 + 1 (0-based). */ ++ .string "seennotseen" + -+ return ++a; -+} ++ .section .debug_info ++.Lcu1_begin: ++ .4byte .Lcu1_end - .Lcu1_start /* Length of Compilation Unit */ ++.Lcu1_start: ++ .2byte 2 /* DWARF version number */ ++ .4byte .Ldebug_abbrev0 /* Offset Into Abbrev. Section */ ++ .byte 4 /* Pointer Size (in bytes) */ + -+int f1 (int a, int b) -+{ -+ return f2(a) + b; -+} ++ /* CU die */ ++ .uleb128 1 /* Abbrev: DW_TAG_compile_unit */ ++ .4byte .Lproducer /* DW_AT_producer */ ++ /* Use C++ to exploit a bug in parsing DW_AT_name "". */ ++ .byte 4 /* DW_AT_language (C++) - */ ++ .4byte main /* DW_AT_low_pc */ ++ .byte main_length /* DW_AT_high_pc */ ++ ++.Larray_type: ++ .uleb128 2 /* Abbrev: DW_TAG_array_type */ ++ .4byte .Lchar_type-.Lcu1_begin /* DW_AT_type */ ++ ++ .uleb128 3 /* Abbrev: DW_TAG_subrange_type */ ++ .4byte .Luint_type-.Lcu1_begin /* DW_AT_type */ ++ .byte 0 /* DW_AT_lower_bound */ ++ .4byte .Llen_var-.Lcu1_begin /* DW_AT_upper_bound */ ++ .byte 0 /* End of children of die */ ++ ++ /* DW_AT_upper_bound is referencing an optimized-out variable. */ ++.Larrayb_type: ++ .uleb128 2 /* Abbrev: DW_TAG_array_type */ ++ .4byte .Lchar_type-.Lcu1_begin /* DW_AT_type */ ++ ++ .uleb128 3 /* Abbrev: DW_TAG_subrange_type */ ++ .4byte .Luint_type-.Lcu1_begin /* DW_AT_type */ ++ .byte 0 /* DW_AT_lower_bound */ ++ .4byte .Llenb_var-.Lcu1_begin /* DW_AT_upper_bound */ ++ .byte 0 /* End of children of die */ ++ ++.Luint_type: ++ .uleb128 4 /* Abbrev: DW_TAG_base_type */ ++ .4byte .Luint_str /* DW_AT_name */ ++ .byte 4 /* DW_AT_byte_size */ ++ .byte 7 /* DW_AT_encoding */ ++ ++.Lchar_type: ++ .uleb128 4 /* Abbrev: DW_TAG_base_type */ ++ .4byte .Lchar_str /* DW_AT_name */ ++ .byte 1 /* DW_AT_byte_size */ ++ .byte 6 /* DW_AT_encoding */ ++ ++.Llen_var: ++ .uleb128 5 /* Abbrev: DW_TAG_variable artificial */ ++ .byte 1 /* DW_AT_artificial */ ++ .4byte .Luint_type-.Lcu1_begin /* DW_AT_type */ ++ .4byte .Llen_loclist-.Lloclist /* DW_AT_location */ ++ ++ /* optimized-out variable for b_string. */ ++.Llenb_var: ++ .uleb128 7 /* Abbrev: DW_TAG_variable artificial no DW_AT_location */ ++ .byte 1 /* DW_AT_artificial */ ++ .4byte .Luint_type-.Lcu1_begin /* DW_AT_type */ ++ ++ .uleb128 6 /* Abbrev: DW_TAG_variable DW_FORM_string */ ++ .string "a_string" /* DW_AT_name */ ++ .4byte .Larray_type-.Lcu1_begin /* DW_AT_type */ ++ .byte 2f - 1f /* DW_AT_location */ ++1: .byte 3 /* DW_OP_addr */ ++ .4byte vardata /* */ ++2: ++ ++ /* DW_AT_upper_bound is referencing an optimized-out variable. */ ++ .uleb128 6 /* Abbrev: DW_TAG_variable DW_FORM_string */ ++ .string "b_string" /* DW_AT_name */ ++ .4byte .Larrayb_type-.Lcu1_begin /* DW_AT_type */ ++ .byte 2f - 1f /* DW_AT_location */ ++1: .byte 3 /* DW_OP_addr */ ++ .4byte vardata /* */ ++2: + -+static void -+init_bufs () -+{ -+ search_buf_size = BUF_SIZE; -+ search_buf = malloc (search_buf_size); -+ if (search_buf == NULL) -+ exit (1); -+ memset (search_buf, 'x', search_buf_size); -+} ++ .byte 0 /* End of children of CU */ ++.Lcu1_end: + -+int main (int argc, char *argv[]) -+{ -+ init_bufs (); ++ .section .debug_loc ++.Lloclist: ++.Llen_loclist: ++ .4byte 0 # Location list begin address ++ .4byte main_length # Location list end address ++ .value 2f-1f # Location expression size ++1: .byte 0x33 # DW_OP_lit3 ++ .byte 0x9f # DW_OP_stack_value ++2: ++ .quad 0x0 # Location list terminator begin (*.LLST2) ++ .quad 0x0 # Location list terminator end (*.LLST2) + -+ return f1 (1, 2); -+} -diff --git a/gdb/testsuite/gdb.python/py-inferior.exp b/gdb/testsuite/gdb.python/py-inferior.exp ++ .section .debug_abbrev ++.Ldebug_abbrev0: ++ .uleb128 1 /* Abbrev code */ ++ .uleb128 0x11 /* DW_TAG_compile_unit */ ++ .byte 0x1 /* has_children */ ++ .uleb128 0x25 /* DW_AT_producer */ ++ .uleb128 0xe /* DW_FORM_strp */ ++ .uleb128 0x13 /* DW_AT_language */ ++ .uleb128 0xb /* DW_FORM_data1 */ ++ .uleb128 0x11 /* DW_AT_low_pc */ ++ .uleb128 0x1 /* DW_FORM_addr */ ++ .uleb128 0x12 /* DW_AT_high_pc */ ++ .uleb128 0xb /* DW_FORM_data1 */ ++ .byte 0x0 /* Terminator */ ++ .byte 0x0 /* Terminator */ ++ ++ .uleb128 2 /* Abbrev code */ ++ .uleb128 0x1 /* TAG: DW_TAG_array_type */ ++ .byte 0x1 /* DW_children_yes */ ++ .uleb128 0x49 /* DW_AT_type */ ++ .uleb128 0x13 /* DW_FORM_ref4 */ ++ .byte 0x0 /* Terminator */ ++ .byte 0x0 /* Terminator */ ++ ++ .uleb128 3 /* Abbrev code */ ++ .uleb128 0x21 /* DW_TAG_subrange_type */ ++ .byte 0x0 /* no children */ ++ .uleb128 0x49 /* DW_AT_type */ ++ .uleb128 0x13 /* DW_FORM_ref4 */ ++ .uleb128 0x22 /* DW_AT_lower_bound */ ++ .uleb128 0xb /* DW_FORM_data1 */ ++ .uleb128 0x2f /* DW_AT_upper_bound */ ++ .uleb128 0x13 /* DW_FORM_ref4 */ ++ .byte 0x0 /* Terminator */ ++ .byte 0x0 /* Terminator */ ++ ++ .uleb128 4 /* Abbrev code */ ++ .uleb128 0x24 /* DW_TAG_base_type */ ++ .byte 0x0 /* no_children */ ++ .uleb128 0x3 /* DW_AT_name */ ++ .uleb128 0xe /* DW_FORM_strp */ ++ .uleb128 0xb /* DW_AT_byte_size */ ++ .uleb128 0xb /* DW_FORM_data1 */ ++ .uleb128 0x3e /* DW_AT_encoding */ ++ .uleb128 0xb /* DW_FORM_data1 */ ++ .byte 0x0 /* Terminator */ ++ .byte 0x0 /* Terminator */ ++ ++ .uleb128 5 /* Abbrev code */ ++ .uleb128 0x34 /* DW_TAG_variable */ ++ .byte 0x0 /* no_children */ ++ .uleb128 0x34 /* DW_AT_artificial */ ++ .uleb128 0x0c /* DW_FORM_flag */ ++ .uleb128 0x49 /* DW_AT_type */ ++ .uleb128 0x13 /* DW_FORM_ref4 */ ++ .uleb128 0x02 /* DW_AT_location */ ++ .uleb128 0x06 /* DW_FORM_data4 */ ++ .byte 0x0 /* Terminator */ ++ .byte 0x0 /* Terminator */ ++ ++ .uleb128 6 /* Abbrev code */ ++ .uleb128 0x34 /* DW_TAG_variable */ ++ .byte 0x0 /* no_children */ ++ .uleb128 0x3 /* DW_AT_name */ ++ .uleb128 0x8 /* DW_FORM_string */ ++ .uleb128 0x49 /* DW_AT_type */ ++ .uleb128 0x13 /* DW_FORM_ref4 */ ++ .uleb128 0x2 /* DW_AT_location */ ++ .uleb128 0xa /* DW_FORM_block1 */ ++ .byte 0x0 /* Terminator */ ++ .byte 0x0 /* Terminator */ ++ ++ .uleb128 7 /* Abbrev code */ ++ .uleb128 0x34 /* DW_TAG_variable */ ++ .byte 0x0 /* no_children */ ++ .uleb128 0x34 /* DW_AT_artificial */ ++ .uleb128 0x0c /* DW_FORM_flag */ ++ .uleb128 0x49 /* DW_AT_type */ ++ .uleb128 0x13 /* DW_FORM_ref4 */ ++ .byte 0x0 /* Terminator */ ++ .byte 0x0 /* Terminator */ ++ ++ .byte 0x0 /* Terminator */ ++ ++/* String table */ ++ .section .debug_str ++.Lproducer: ++ .string "GNU C 3.3.3" ++.Lchar_str: ++ .string "char" ++.Luint_str: ++ .string "unsigned int" +diff --git a/gdb/testsuite/gdb.dwarf2/dw2-bound-loclist.exp b/gdb/testsuite/gdb.dwarf2/dw2-bound-loclist.exp new file mode 100644 -index 0000000..719b178 +index 0000000..5dbed3f --- /dev/null -+++ b/gdb/testsuite/gdb.python/py-inferior.exp -@@ -0,0 +1,201 @@ -+# Copyright (C) 2009 Free Software Foundation, Inc. ++++ b/gdb/testsuite/gdb.dwarf2/dw2-bound-loclist.exp +@@ -0,0 +1,51 @@ ++# 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 @@ -26200,219 +13447,271 @@ index 0000000..719b178 +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + -+# This file is part of the GDB testsuite. It tests the mechanism -+# exposing inferiors to Python. -+ -+if $tracelevel then { -+ strace $tracelevel -+} -+ -+# Start with a fresh gdb. -+ -+gdb_exit -+gdb_start -+gdb_reinitialize_dir $srcdir/$subdir ++# Test printing variable with dynamic bounds which reference a different ++# (artificial in the GCC case) variable containing loclist as its location. ++# This testcase uses value (not address) of the referenced variable: ++# http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43762 + -+if ![python_supported] then { -+ unsupported "python support is disabled" -+ return -1 ++# This test can only be run on targets which support DWARF-2 and use gas. ++# For now pick a sampling of likely targets. ++if {![istarget *-*-linux*] ++ && ![istarget *-*-gnu*] ++ && ![istarget *-*-elf*] ++ && ![istarget *-*-openbsd*] ++ && ![istarget arm-*-eabi*] ++ && ![istarget powerpc-*-eabi*]} { ++ return 0 +} + -+set testfile "py-inferior" -+set srcfile ${testfile}.c -+set binfile ${objdir}/${subdir}/${testfile} -+ -+if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } { -+ untested "Couldn't compile ${srcfile}" ++set testfile dw2-bound-loclist ++if { [prepare_for_testing ${testfile}.exp ${testfile} [list ${testfile}.S main.c] {}] } { + return -1 +} + -+gdb_load ${binfile} ++# Verify it behaves at least as an unbound array without inferior. + -+# The following tests require execution. ++gdb_test "p a_string" { = 0x[0-9a-f]+ "seennotseen"} ++gdb_test "ptype a_string" {type = char \[\]} + -+if ![runto_main] then { -+ fail "Can't run to main" -+ return 0 ++# Not runto_main as dw2-bound-loclist.S handles only the first byte of main. ++if ![runto "*main"] { ++ return -1 +} + -+runto [gdb_get_line_number "Break here."] ++gdb_test "p a_string" { = "seen"} ++gdb_test "ptype a_string" {type = char \[4\]} + -+# Test basic gdb.Inferior attributes and methods. -+ -+gdb_py_test_silent_cmd "python inferiors = gdb.inferiors ()" "get inferiors list" 1 -+gdb_test "python print inferiors" "\\(,\\)" "verify inferiors list" -+gdb_py_test_silent_cmd "python i0 = inferiors\[0\]" "get first inferior" 0 -+ -+gdb_test "python print 'result =', i0 == inferiors\[0\]" " = True" "test equality comparison (true)" -+gdb_test "python print 'result =', i0.num" " = \[0-9\]+" "test Inferior.num" -+gdb_test "python print 'result =', i0.pid" " = \[0-9\]+" "test Inferior.pid" -+gdb_test "python print 'result =', i0.was_attached" " = False" "test Inferior.was_attached" -+gdb_test "python print i0.threads ()" "\\(,\\)" "test Inferior.threads" ++gdb_test "p b_string" { = (0x[0-9a-f]+ )?"seennotseen"} ++gdb_test "ptype b_string" {type = char \[\]} +diff --git a/gdb/testsuite/gdb.dwarf2/dw2-stripped.c b/gdb/testsuite/gdb.dwarf2/dw2-stripped.c +new file mode 100644 +index 0000000..1f02d90 +--- /dev/null ++++ b/gdb/testsuite/gdb.dwarf2/dw2-stripped.c +@@ -0,0 +1,42 @@ ++/* This testcase is part of GDB, the GNU debugger. + -+# Test memory read and write operations. ++ Copyright 2004 Free Software Foundation, Inc. + -+gdb_py_test_silent_cmd "python addr = gdb.selected_frame ().read_var ('str')" \ -+ "read str address" 0 -+gdb_py_test_silent_cmd "python str = gdb.inferiors()\[0\].read_memory (addr, 5)" \ -+ "read str contents" 1 -+gdb_py_test_silent_cmd "python str\[1\] = 'a'" "change str" 0 -+gdb_py_test_silent_cmd "python gdb.inferiors()\[0\].write_memory (addr, str)" \ -+ "write str" 1 -+gdb_test "print str" " = 0x\[\[:xdigit:\]\]+ \"hallo, testsuite\"" \ -+ "ensure str was changed in the inferior" ++ 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. + -+# Test memory search. ++ 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. */ + -+set hex_number {0x[0-9a-fA-F][0-9a-fA-F]*} -+set dec_number {[0-9]+} -+set history_prefix {[$][0-9]* = } -+set newline {[\r\n]+} -+set pattern_not_found "${newline}.]" -+set one_pattern_found "${newline}.${dec_number}L]" -+set two_patterns_found "${newline}.${dec_number}L, ${dec_number}L]" + -+# Test string pattern. ++/* The function `func1' traced into must have debug info on offset > 0; ++ (DW_UNSND (attr)). This is the reason of `func0' existence. */ + -+gdb_test "set *(int32_t*) &int8_search_buf\[10\] = 0x61616161" "" "" -+gdb_test "py search_buf = gdb.selected_frame ().read_var ('int8_search_buf')" "" "" -+gdb_test "py start_addr = search_buf.address" "" "" -+gdb_test "py length = search_buf.type.sizeof" "" "" ++void ++func0(int a, int b) ++{ ++} + -+gdb_test "py print gdb.inferiors()\[0\].search_memory (start_addr, length, 'aaa')" \ -+ "${two_patterns_found}" "find string pattern" ++/* `func1' being traced into must have some arguments to dump. */ + -+# Test not finding pattern because search range too small, with -+# potential find at the edge of the range. ++void ++func1(int a, int b) ++{ ++ func0 (a,b); ++} + -+gdb_test "py print gdb.inferiors()\[0\].search_memory (start_addr, 10+3, 'aaaa')" \ -+ "${pattern_not_found}" "pattern not found at end of range" ++int ++main(void) ++{ ++ func1 (1, 2); ++ return 0; ++} +diff --git a/gdb/testsuite/gdb.dwarf2/dw2-stripped.exp b/gdb/testsuite/gdb.dwarf2/dw2-stripped.exp +new file mode 100644 +index 0000000..1c6e84a +--- /dev/null ++++ b/gdb/testsuite/gdb.dwarf2/dw2-stripped.exp +@@ -0,0 +1,79 @@ ++# Copyright 2006 Free Software Foundation, Inc. + -+# Increase the search range by 1 and we should find the pattern. ++# 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. + -+gdb_test "py print gdb.inferiors()\[0\].search_memory (start_addr, 10+3+1, \['a', 'a', 'a', 'a'\])" \ -+ "${one_pattern_found}" "pattern found at end of range" ++# Minimal DWARF-2 unit test + -+# Test max-count with size, with different parameter position ++# This test can only be run on targets which support DWARF-2. ++# For now pick a sampling of likely targets. ++if {![istarget *-*-linux*] ++ && ![istarget *-*-gnu*] ++ && ![istarget *-*-elf*] ++ && ![istarget *-*-openbsd*] ++ && ![istarget arm-*-eabi*] ++ && ![istarget powerpc-*-eabi*]} { ++ return 0 ++} + -+gdb_test "py print gdb.inferiors()\[0\].search_memory (start_addr, length, \[0x61, 0x61\], 1, 1)" \ -+ "${one_pattern_found}" "size = 1, max_count = 1" ++set testfile "dw2-stripped" ++set srcfile ${testfile}.c ++set binfile ${objdir}/${subdir}/${testfile}.x + -+gdb_test "py print gdb.inferiors()\[0\].search_memory (start_addr, length, \[0x61, 0x61\], 1, 2)" \ -+ "${two_patterns_found}" "size = 1, max_count = 2, normal ordering" ++remote_exec build "rm -f ${binfile}" + -+gdb_test "py print gdb.inferiors()\[0\].search_memory (start_addr, length, \[0x61, 0x61\], size = 1, max_count = 2)" \ -+ "${two_patterns_found}" "size = 1, max_count = 2, normal ordering, with keywords" ++# get the value of gcc_compiled ++if [get_compiler_info ${binfile}] { ++ return -1 ++} + -+gdb_test "py print gdb.inferiors()\[0\].search_memory (start_addr, length, \[0x61, 0x61\], max_count = 2, size = 1)" \ -+ "${two_patterns_found}" "size = 1, max_count = 2, inverted ordering" ++# This test can only be run on gcc as we use additional_flags=FIXME ++if {$gcc_compiled == 0} { ++ return 0 ++} + -+gdb_test "py print gdb.inferiors()\[0\].search_memory (start_addr, length, \['a', 'a'\], max_count = 2)" \ -+ "${two_patterns_found}" "max_count = 2, with keyword" ++if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-ggdb3}] != "" } { ++ return -1 ++} + -+# Test 16-bit pattern. ++remote_exec build "objcopy -R .debug_loc ${binfile}" ++set strip_output [remote_exec build "objdump -h ${binfile}"] + -+gdb_test "set int16_search_buf\[10\] = 0x1234" "" "" -+gdb_test "py search_buf = gdb.selected_frame ().read_var ('int16_search_buf')" "" "" -+gdb_test "py start_addr = search_buf.address" "" "" -+gdb_test "py length = search_buf.type.sizeof" "" "" -+gdb_test "py pattern = gdb.parse_and_eval ('(int16_t) 0x1234')" "" "" ++set test "stripping test file preservation" ++if [ regexp ".debug_info " $strip_output] { ++ pass "$test (.debug_info preserved)" ++} else { ++ fail "$test (.debug_info got also stripped)" ++} + -+gdb_test "py print gdb.inferiors()\[0\].search_memory (start_addr, length, 0x1234, 2)" \ -+ "${one_pattern_found}" "find 16-bit pattern, with python pattern" ++set test "stripping test file functionality" ++if [ regexp ".debug_loc " $strip_output] { ++ fail "$test (.debug_loc still present)" ++} else { ++ pass "$test (.debug_loc stripped)" ++} + -+gdb_test "py print gdb.inferiors()\[0\].search_memory (start_addr, length, pattern)" \ -+ "${one_pattern_found}" "find 16-bit pattern, with value pattern" ++gdb_exit ++gdb_start ++gdb_reinitialize_dir $srcdir/$subdir ++gdb_load ${binfile} + -+# Test 32-bit pattern. ++# For C programs, "start" should stop in main(). + -+gdb_test "set int32_search_buf\[10\] = 0x12345678" "" "" -+gdb_test "py search_buf = gdb.selected_frame ().read_var ('int32_search_buf')" "" "" -+gdb_test "py start_addr = search_buf.address" "" "" -+gdb_test "py length = search_buf.type.sizeof" "" "" -+gdb_test "py pattern = gdb.parse_and_eval ('(int32_t) 0x12345678')" "" "" ++gdb_test "start" \ ++ ".*main \\(\\) at .*" \ ++ "start" ++gdb_test "step" \ ++ "func.* \\(.*\\) at .*" \ ++ "step" +diff --git a/gdb/testsuite/gdb.dwarf2/dw2-struct-member-data-location.S b/gdb/testsuite/gdb.dwarf2/dw2-struct-member-data-location.S +new file mode 100644 +index 0000000..5fcdd84 +--- /dev/null ++++ b/gdb/testsuite/gdb.dwarf2/dw2-struct-member-data-location.S +@@ -0,0 +1,83 @@ ++/* This testcase is part of GDB, the GNU debugger. + -+gdb_test "py print gdb.inferiors()\[0\].search_memory (start_addr, length, 0x12345678, 4)" \ -+ "${one_pattern_found}" "find 32-bit pattern, with python pattern" -+gdb_test "py print gdb.inferiors()\[0\].search_memory (start_addr, length, pattern)" \ -+ "${one_pattern_found}" "find 32-bit pattern, with value pattern" ++ Copyright 2009 Free Software Foundation, Inc. + -+# Test 64-bit pattern. ++ 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. + -+gdb_test "set int64_search_buf\[10\] = 0xfedcba9876543210LL" "" "" -+gdb_test "py search_buf = gdb.selected_frame ().read_var ('int64_search_buf')" "" "" -+gdb_test "py start_addr = search_buf.address" "" "" -+gdb_test "py length = search_buf.type.sizeof" "" "" -+gdb_test "py pattern = gdb.parse_and_eval ('(int64_t) 0xfedcba9876543210LL')" "" "" ++ 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. + -+gdb_test "py print gdb.inferiors()\[0\].search_memory (start_addr, length, 0xfedcba9876543210, 8)" \ -+ "${one_pattern_found}" "find 64-bit pattern, with python pattern" -+gdb_test "py print gdb.inferiors()\[0\].search_memory (start_addr, length, pattern)" \ -+ "${one_pattern_found}" "find 64-bit pattern, with value pattern" ++ You should have received a copy of the GNU General Public License ++ along with this program. If not, see . */ + -+# Test mixed-sized patterns. ++/* Debug information */ + -+gdb_test "set *(int8_t*) &search_buf\[10\] = 0x62" "" "" -+gdb_test "set *(int16_t*) &search_buf\[11\] = 0x6363" "" "" -+gdb_test "set *(int32_t*) &search_buf\[13\] = 0x64646464" "" "" -+gdb_test "py search_buf = gdb.selected_frame ().read_var ('search_buf')" "" "" -+gdb_test "py start_addr = search_buf\[0\].address" "" "" -+gdb_test "py pattern1 = gdb.parse_and_eval ('(int8_t) 0x62')" "" "" -+gdb_test "py pattern2 = gdb.parse_and_eval ('(int16_t) 0x6363')" "" "" -+gdb_test "py pattern3 = gdb.parse_and_eval ('(int32_t) 0x64646464')" "" "" ++ .section .debug_info ++.Lcu1_begin: ++ /* CU header */ ++ .4byte .Lcu1_end - .Lcu1_start /* Length of Compilation Unit */ ++.Lcu1_start: ++ .2byte 2 /* DWARF Version */ ++ .4byte .Labbrev1_begin /* Offset into abbrev section */ ++ .byte 4 /* Pointer size */ + -+gdb_test "py print gdb.inferiors()\[0\].search_memory (start_addr, 100, \[pattern1, pattern2, pattern3\])" \ -+ "${one_pattern_found}" "find mixed-sized pattern" ++ /* CU die */ ++ .uleb128 1 /* Abbrev: DW_TAG_compile_unit */ ++ .ascii "dw2-struct-member-data-location.c\0" /* DW_AT_name */ ++ .ascii "GNU C 4.3.2\0" /* DW_AT_producer */ ++ .byte 1 /* DW_AT_language (C) */ + -+# Test search spanning a large range, in the particular case of native -+# targets, test the search spanning multiple chunks. -+# Remote targets may implement the search differently. ++.Ltype_uchar: ++ .uleb128 2 /* Abbrev: DW_TAG_structure_type */ ++ .ascii "some_struct\0" /* DW_AT_name */ + -+set CHUNK_SIZE 16000 ; ++ .uleb128 3 /* Abbrev: DW_TAG_member */ ++ .ascii "field\0" /* DW_AT_name */ ++ .byte 0 /* DW_AT_data_member_location */ + -+gdb_test "set *(int32_t*) &search_buf\[0*${CHUNK_SIZE}+100\] = 0x12345678" "" "" -+gdb_test "set *(int32_t*) &search_buf\[1*${CHUNK_SIZE}+100\] = 0x12345678" "" "" -+gdb_test "py start_addr = gdb.selected_frame ().read_var ('search_buf')" "" "" -+gdb_test "py length = gdb.selected_frame ().read_var ('search_buf_size')" "" "" ++ .byte 0 /* End of children of some_struct */ + -+gdb_test "py print gdb.inferiors()\[0\].search_memory (start_addr, length, 0x12345678, 4)" \ -+ "${two_patterns_found}" "search spanning large range" ++ .byte 0 /* End of children of CU */ + -+# For native targets, test a pattern straddling a chunk boundary. ++.Lcu1_end: + -+if [isnative] { -+ gdb_test "set *(int32_t*) &search_buf\[${CHUNK_SIZE}-1\] = 0xfdb97531" "" "" ++/* Abbrev table */ ++ .section .debug_abbrev ++.Labbrev1_begin: ++ .uleb128 1 /* Abbrev code */ ++ .uleb128 0x11 /* DW_TAG_compile_unit */ ++ .byte 1 /* has_children */ ++ .uleb128 0x3 /* DW_AT_name */ ++ .uleb128 0x8 /* DW_FORM_string */ ++ .uleb128 0x25 /* DW_AT_producer */ ++ .uleb128 0x8 /* DW_FORM_string */ ++ .uleb128 0x13 /* DW_AT_language */ ++ .uleb128 0xb /* DW_FORM_data1 */ ++ .byte 0x0 /* Terminator */ ++ .byte 0x0 /* Terminator */ + -+ gdb_test "py print gdb.inferiors()\[0\].search_memory (start_addr, length, 0xfdb97531, 4)" \ -+ "${one_pattern_found}" "find pattern straddling chunk boundary" -+} -diff --git a/gdb/testsuite/gdb.python/py-infthread.c b/gdb/testsuite/gdb.python/py-infthread.c -new file mode 100644 -index 0000000..22eb9f2 ---- /dev/null -+++ b/gdb/testsuite/gdb.python/py-infthread.c -@@ -0,0 +1,14 @@ -+int f2 (int a) -+{ -+ return ++a; -+} ++ .uleb128 2 /* Abbrev code */ ++ .uleb128 0x13 /* DW_TAG_structure_type */ ++ .byte 1 /* has_children */ ++ .uleb128 0x3 /* DW_AT_name */ ++ .uleb128 0x8 /* DW_FORM_string */ ++ .byte 0x0 /* Terminator */ ++ .byte 0x0 /* Terminator */ + -+int f1 (int a, int b) -+{ -+ return f2(a) + b; -+} ++ .uleb128 3 /* Abbrev code */ ++ .uleb128 0x0d /* DW_TAG_member */ ++ .byte 0 /* has_children */ ++ .uleb128 0x3 /* DW_AT_name */ ++ .uleb128 0x8 /* DW_FORM_string */ ++ .uleb128 0x38 /* DW_AT_data_member_location */ ++ .uleb128 0x0b /* DW_FORM_data1 */ ++ .byte 0x0 /* Terminator */ ++ .byte 0x0 /* Terminator */ + -+int main (int argc, char *argv[]) -+{ -+ return f1 (1, 2); -+} -diff --git a/gdb/testsuite/gdb.python/py-infthread.exp b/gdb/testsuite/gdb.python/py-infthread.exp ++ .byte 0x0 /* Terminator */ ++ .byte 0x0 /* Terminator */ +diff --git a/gdb/testsuite/gdb.dwarf2/dw2-struct-member-data-location.exp b/gdb/testsuite/gdb.dwarf2/dw2-struct-member-data-location.exp new file mode 100644 -index 0000000..e9d18b7 +index 0000000..c41151c --- /dev/null -+++ b/gdb/testsuite/gdb.python/py-infthread.exp -@@ -0,0 +1,58 @@ -+# Copyright (C) 2009 Free Software Foundation, Inc. ++++ b/gdb/testsuite/gdb.dwarf2/dw2-struct-member-data-location.exp +@@ -0,0 +1,37 @@ ++# Copyright 2009 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 @@ -26427,588 +13726,665 @@ index 0000000..e9d18b7 +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + -+# This file is part of the GDB testsuite. It tests the mechanism -+# exposing inferior threads to Python. -+ -+if $tracelevel then { -+ strace $tracelevel -+} -+ -+# Start with a fresh gdb. -+ -+gdb_exit -+gdb_start -+gdb_reinitialize_dir $srcdir/$subdir -+ -+if ![python_supported] then { -+ unsupported "python support is disabled" -+ return -1 -+} -+ -+set testfile "py-infthread" -+set srcfile ${testfile}.c -+set binfile ${objdir}/${subdir}/${testfile} -+ -+if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } { -+ untested "Couldn't compile ${srcfile}" -+ return -1 -+} -+ -+gdb_load ${binfile} -+ -+# The following tests require execution. -+ -+if ![runto_main] then { -+ fail "Can't run to main" -+ return 0 -+} -+ -+runto [gdb_get_line_number "Break here."] -+ -+# Test basic gdb.Inferior attributes and methods. -+ -+gdb_py_test_silent_cmd "python t0 = gdb.selected_thread ()" "test gdb.selected_thread" 1 -+gdb_test "python print t0" "\\" "verify InferiorThread object" -+gdb_test "python print 'result =', t0.num" " = \[0-9\]+" "test Inferior.num" -diff --git a/gdb/testsuite/gdb.python/py-prettyprint.exp b/gdb/testsuite/gdb.python/py-prettyprint.exp -index b4b3776..359c4ed 100644 ---- a/gdb/testsuite/gdb.python/py-prettyprint.exp -+++ b/gdb/testsuite/gdb.python/py-prettyprint.exp -@@ -27,12 +27,20 @@ set binfile ${objdir}/${subdir}/${testfile} - # Start with a fresh gdb. - gdb_exit - gdb_start --gdb_test_multiple "python print 'hello, world!'" "verify python support" { -- -re "not supported.*$gdb_prompt $" { -- unsupported "python support is disabled" -- return -1 -- } -- -re "$gdb_prompt $" {} -+if ![python_supported] then { -+ unsupported "python support is disabled" -+ return -1 -+} -+ -+# Run a command in GDB, and report a failure if a Python exception is thrown. -+# If report_pass is true, report a pass if no exception is thrown. -+proc gdb_py_test_silent_cmd {cmd name report_pass} { -+ global gdb_prompt -+ -+ gdb_test_multiple $cmd $name { -+ -re "Traceback.*$gdb_prompt $" { fail $name } -+ -re "$gdb_prompt $" { if $report_pass { pass $name } } -+ } - } - - # Run a command in GDB, and report a failure if a Python exception is thrown. -@@ -102,6 +110,8 @@ proc run_lang_tests {lang} { - - gdb_test "print c" " = container $hex \"container\" with 2 elements = {$nl *.0. = 23,$nl *.1. = 72$nl}" - -+ gdb_test "print nullstr" "RuntimeError: Error reading string from inferior.*" -+ - gdb_test "continue" "Program exited normally\." - } - -diff --git a/gdb/testsuite/gdb.python/py-template.exp b/gdb/testsuite/gdb.python/py-template.exp -index cea6ae0..c9a63d4 100644 ---- a/gdb/testsuite/gdb.python/py-template.exp -+++ b/gdb/testsuite/gdb.python/py-template.exp -@@ -20,6 +20,17 @@ if $tracelevel then { - strace $tracelevel - } - -+# Start with a fresh gdb. -+ -+gdb_exit -+gdb_start -+gdb_reinitialize_dir $srcdir/$subdir -+ -+if ![python_supported] then { -+ unsupported "python support is disabled" -+ return -1 -+} -+ - set testfile "py-template" - set srcfile ${testfile}.cc - set binfile ${objdir}/${subdir}/${testfile} -@@ -29,20 +40,6 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable \ - return -1 - } - --# Start with a fresh gdb. -- --gdb_exit --gdb_start --gdb_reinitialize_dir $srcdir/$subdir -- --gdb_test_multiple "python print 23" "verify python support" { -- -re "not supported.*$gdb_prompt $" { -- unsupported "python support is disabled" -- return -1 -- } -- -re "$gdb_prompt $" {} --} -- - proc test_template_arg {type} { - global testfile srcdir subdir srcfile binfile - if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" \ -diff --git a/gdb/testsuite/gdb.python/py-value.exp b/gdb/testsuite/gdb.python/py-value.exp -index 2958233..0de1cae 100644 ---- a/gdb/testsuite/gdb.python/py-value.exp -+++ b/gdb/testsuite/gdb.python/py-value.exp -@@ -292,6 +292,15 @@ proc test_value_after_death {} { - "print value's type" - } - -+# Regression test for a cast failure. The bug was that if we cast a -+# value to its own type, gdb could crash. This happened because we -+# could end up double-freeing a struct value. -+proc test_cast_regression {} { -+ gdb_test "python v = gdb.Value(5)" "" "create value for cast test" -+ gdb_test "python v = v.cast(v.type)" "" "cast value for cast test" -+ gdb_test "python print v" "5" "print value for cast test" -+} -+ - # Regression test for invalid subscript operations. The bug was that - # the type of the value was not being checked before allowing a - # subscript operation to proceed. -@@ -366,16 +375,23 @@ proc test_subscript_regression {lang} { - gdb_exit - gdb_start - gdb_reinitialize_dir $srcdir/$subdir --gdb_load ${binfile} - --gdb_test_multiple "python print 'hello, world!'" "verify python support" { -- -re "not supported.*$gdb_prompt $" { -- unsupported "python support is disabled" -- return -1 -- } -- -re "$gdb_prompt $" {} -+if ![python_supported] then { -+ unsupported "python support is disabled" -+ return -1 - } - -+set testfile "py-value" -+set srcfile ${testfile}.c -+set binfile ${objdir}/${subdir}/${testfile} ++# This test can only be run on targets which support DWARF-2 and use gas. ++# For now pick a sampling of likely targets. ++if {![istarget *-*-linux*] ++ && ![istarget *-*-gnu*] ++ && ![istarget *-*-elf*] ++ && ![istarget *-*-openbsd*] ++ && ![istarget arm-*-eabi*] ++ && ![istarget powerpc-*-eabi*]} { ++ return 0 ++} + -+if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } { -+ untested "Couldn't compile ${srcfile}" ++set testfile "dw2-struct-member-data-location" ++set srcfile ${testfile}.S ++set binfile ${testfile}.x ++ ++if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${objdir}/${subdir}/${binfile}" object {nodebug}] != "" } { + return -1 +} + -+gdb_load ${binfile} ++clean_restart $binfile + - test_value_creation - test_value_numeric_ops - test_value_boolean -@@ -391,6 +407,7 @@ if ![runto_main] then { - - test_value_in_inferior - test_value_after_death -+test_cast_regression - - # The following test recompiles the binary to test either C or C++ - # values. -diff --git a/gdb/testsuite/gdb.python/python.exp b/gdb/testsuite/gdb.python/python.exp -index 5223fc8..03e1eab 100644 ---- a/gdb/testsuite/gdb.python/python.exp -+++ b/gdb/testsuite/gdb.python/python.exp -@@ -26,30 +26,9 @@ gdb_exit - gdb_start - gdb_reinitialize_dir $srcdir/$subdir - --gdb_test_multiple "python print 23" "verify python support" { -- -re "not supported.*$gdb_prompt $" { -- unsupported "python support is disabled" -- return -1 -- } -- -re "$gdb_prompt $" {} --} -- --# Usage: gdb_py_test_multiple NAME INPUT RESULT {INPUT RESULT}... --# Run a test named NAME, consisting of multiple lines of input. --# After each input line INPUT, search for result line RESULT. --# Succeed if all results are seen; fail otherwise. --proc gdb_py_test_multiple {name args} { -- global gdb_prompt -- foreach {input result} $args { -- if {[gdb_test_multiple $input "$name - $input" { -- -re "\[\r\n\]*($result)\[\r\n\]+($gdb_prompt | *>)$" { -- pass "$name - $input" -- } -- }]} { -- return 1 -- } -- } -- return 0 -+if ![python_supported] then { -+ unsupported "python support is disabled" -+ return -1 - } - - gdb_py_test_multiple "multi-line python command" \ -diff --git a/gdb/testsuite/gdb.threads/watchpoint-fork-forkoff.c b/gdb/testsuite/gdb.threads/watchpoint-fork-forkoff.c ++gdb_test "ptype struct some_struct" "type = struct some_struct {\[\r\n \t\]*void field;\[\r\n \t\]*}" +diff --git a/gdb/testsuite/gdb.fortran/dwarf-stride.exp b/gdb/testsuite/gdb.fortran/dwarf-stride.exp new file mode 100644 -index 0000000..4dc308b +index 0000000..cd3486b --- /dev/null -+++ b/gdb/testsuite/gdb.threads/watchpoint-fork-forkoff.c -@@ -0,0 +1,175 @@ -+/* Test case for forgotten hw-watchpoints after fork()-off of a process. -+ -+ Copyright 2008, 2009 Free Software Foundation, Inc. -+ -+ This file is part of GDB. ++++ b/gdb/testsuite/gdb.fortran/dwarf-stride.exp +@@ -0,0 +1,42 @@ ++# Copyright 2009 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 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. + -+ 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. ++# This file was written by Jan Kratochvil . + -+ 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. */ ++# This file is part of the gdb testsuite. Array element stride must not be ++# specified in the number of elements but in a number of bytes instead. ++# Original problem: ++# (gdb) p c40pt(1) ++# $1 = '0-hello', ' ' ++# (gdb) p c40pt(2) ++# warning: Fortran array stride not divisible by the element size + -+#include -+#include ++set testfile dwarf-stride ++set srcfile ${testfile}.f90 + -+static void -+delay (void) -+{ -+ int i = usleep (1000000 / 100); -+ assert (i == 0 || errno == EINTR); ++if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} {debug f77}] } { ++ return -1 +} + -+#if defined FOLLOW_PARENT ++if ![runto MAIN__] then { ++ perror "couldn't run to breakpoint MAIN__" ++ continue ++} + -+static void -+forkoff (int nr) -+{ -+ pid_t child, pid_got; -+ int exit_code = 42 + nr; -+ int status, i; ++gdb_breakpoint [gdb_get_line_number "break-here"] ++gdb_continue_to_breakpoint "break-here" ".*break-here.*" ++gdb_test "p c40pt(1)" " = '0-hello.*" ++gdb_test "p c40pt(2)" " = '1-hello.*" +diff --git a/gdb/testsuite/gdb.fortran/dwarf-stride.f90 b/gdb/testsuite/gdb.fortran/dwarf-stride.f90 +new file mode 100644 +index 0000000..e492b3a +--- /dev/null ++++ b/gdb/testsuite/gdb.fortran/dwarf-stride.f90 +@@ -0,0 +1,40 @@ ++! Copyright 2009 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. ++! ++! File written by Alan Matsuoka. + -+ child = fork (); -+ switch (child) -+ { -+ case -1: -+ assert (0); -+ case 0: -+ printf ("child%d: %d\n", nr, (int) getpid ()); -+ /* Delay to get both the "child%d" and "parent%d" message printed without -+ a race breaking expect by its endless wait on `$gdb_prompt$': -+ Breakpoint 3, breakpoint () at ../../../gdb/testsuite/gdb.threads/watchpoint-fork.c:33 -+ 33 } -+ (gdb) parent2: 14223 */ -+ i = sleep (1); -+ assert (i == 0); ++program repro + -+ /* We must not get caught here (against a forgotten breakpoint). */ -+ var++; -+ breakpoint (); ++ type small_stride ++ character*40 long_string ++ integer small_pad ++ end type small_stride + -+ _exit (exit_code); -+ default: -+ printf ("parent%d: %d\n", nr, (int) child); -+ /* Delay to get both the "child%d" and "parent%d" message printed, see -+ above. */ -+ i = sleep (1); -+ assert (i == 0); ++ type(small_stride), dimension (20), target :: unpleasant ++ character*40, pointer, dimension(:):: c40pt + -+ pid_got = wait (&status); -+ assert (pid_got == child); -+ assert (WIFEXITED (status)); -+ assert (WEXITSTATUS (status) == exit_code); ++ integer i + -+ /* We must get caught here (against a false watchpoint removal). */ -+ breakpoint (); -+ } -+} ++ do i = 0,19 ++ unpleasant(i+1)%small_pad = i+1 ++ unpleasant(i+1)%long_string = char (ichar('0') + i) // '-hello' ++ end do + -+#elif defined FOLLOW_CHILD ++ c40pt => unpleasant%long_string + -+static volatile int usr1_got; ++ print *, c40pt ! break-here + -+static void -+handler_usr1 (int signo) -+{ -+ usr1_got++; -+} ++end program repro +diff --git a/gdb/testsuite/gdb.fortran/dynamic.exp b/gdb/testsuite/gdb.fortran/dynamic.exp +new file mode 100644 +index 0000000..0ccebe0 +--- /dev/null ++++ b/gdb/testsuite/gdb.fortran/dynamic.exp +@@ -0,0 +1,145 @@ ++# Copyright 2007 Free Software Foundation, Inc. + -+static void -+forkoff (int nr) -+{ -+ pid_t child; -+ int i, loop; -+ struct sigaction act, oldact; -+#ifdef THREAD -+ void *thread_result; -+#endif ++# 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. + -+ memset (&act, 0, sizeof act); -+ act.sa_flags = SA_RESTART; -+ act.sa_handler = handler_usr1; -+ sigemptyset (&act.sa_mask); -+ i = sigaction (SIGUSR1, &act, &oldact); -+ assert (i == 0); ++# This file was written by Jan Kratochvil . + -+ child = fork (); -+ switch (child) -+ { -+ case -1: -+ assert (0); -+ default: -+ printf ("parent%d: %d\n", nr, (int) child); ++# This file is part of the gdb testsuite. It contains tests for dynamically ++# allocated Fortran arrays. ++# It depends on the GCC dynamic Fortran arrays DWARF support: ++# http://gcc.gnu.org/bugzilla/show_bug.cgi?id=22244 + -+ /* Sleep for a while to possibly get incorrectly ATTACH_THREADed by GDB -+ tracing the child fork with no longer valid thread/lwp entries of the -+ parent. */ ++set testfile "dynamic" ++set srcfile ${testfile}.f90 ++set binfile ${objdir}/${subdir}/${testfile} + -+ i = sleep (2); -+ assert (i == 0); ++if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug f77 quiet}] != "" } { ++ untested "Couldn't compile ${srcfile}" ++ return -1 ++} + -+ /* We must not get caught here (against a forgotten breakpoint). */ ++gdb_exit ++gdb_start ++gdb_reinitialize_dir $srcdir/$subdir ++gdb_load ${binfile} + -+ var++; -+ breakpoint (); ++if ![runto MAIN__] then { ++ perror "couldn't run to breakpoint MAIN__" ++ continue ++} + -+#ifdef THREAD -+ /* And neither got caught our thread. */ ++gdb_breakpoint [gdb_get_line_number "varx-init"] ++gdb_continue_to_breakpoint "varx-init" ++gdb_test "p varx" "\\$\[0-9\]* = <(object|the array) is not allocated>" "p varx unallocated" ++gdb_test "ptype varx" "type = <(object|the array) is not allocated>" "ptype varx unallocated" ++gdb_test "p varx(1,5,17)" "(Cannot access it|Unable to access the object) because the (object|array) is not allocated\\." "p varx(1,5,17) unallocated" ++gdb_test "p varx(1,5,17)=1" "(Cannot access it|Unable to access the object) because the (object|array) is not allocated\\." "p varx(1,5,17)=1 unallocated" ++gdb_test "ptype varx(1,5,17)" "(Cannot access it|Unable to access the object) because the (object|array) is not allocated\\." "ptype varx(1,5,17) unallocated" + -+ step = 99; -+ i = pthread_join (thread, &thread_result); -+ assert (i == 0); -+ assert (thread_result == (void *) 99UL); -+#endif ++gdb_breakpoint [gdb_get_line_number "varx-allocated"] ++gdb_continue_to_breakpoint "varx-allocated" ++# $1 = (( ( 0, 0, 0, 0, 0, 0) ( 0, 0, 0, 0, 0, 0) --- , 0) ) ( ( 0, 0, ...) ...) ...) ++gdb_test "ptype varx" "type = real(\\(kind=4\\)|\\*4) \\(6,5:15,17:28\\)" "ptype varx allocated" ++# Intel Fortran Compiler 10.1.008 uses -1 there, GCC uses 1. ++gdb_test "p l" "\\$\[0-9\]* = (\\.TRUE\\.|4294967295)" "p l if varx allocated" + -+ /* Be sure our child knows we did not get caught above. */ ++gdb_breakpoint [gdb_get_line_number "varx-filled"] ++gdb_continue_to_breakpoint "varx-filled" ++gdb_test "p varx(2, 5, 17)" "\\$\[0-9\]* = 6" ++gdb_test "p varx(1, 5, 17)" "\\$\[0-9\]* = 7" ++gdb_test "p varx(2, 6, 18)" "\\$\[0-9\]* = 8" ++gdb_test "p varx(6, 15, 28)" "\\$\[0-9\]* = 9" ++# The latter one is for the Intel Fortran Compiler 10.1.008 pointer type. ++gdb_test "p varv" "\\$\[0-9\]* = (<(object|the array) is not associated>|.*(Cannot access it|Unable to access the object) because the object is not associated.)" "p varv unassociated" ++gdb_test "ptype varv" "type = (<(object|the array) is not associated>|.*(Cannot access it|Unable to access the object) because the object is not associated.)" "ptype varv unassociated" + -+ i = kill (child, SIGUSR1); -+ assert (i == 0); ++gdb_breakpoint [gdb_get_line_number "varv-associated"] ++gdb_continue_to_breakpoint "varv-associated" ++gdb_test "p varx(3, 7, 19)" "\\$\[0-9\]* = 6" "p varx(3, 7, 19) with varv associated" ++gdb_test "p varv(3, 7, 19)" "\\$\[0-9\]* = 6" "p varv(3, 7, 19) associated" ++# Intel Fortran Compiler 10.1.008 uses -1 there, GCC uses 1. ++gdb_test "p l" "\\$\[0-9\]* = (\\.TRUE\\.|4294967295)" "p l if varv associated" ++gdb_test "ptype varx" "type = real(\\(kind=4\\)|\\*4) \\(6,5:15,17:28\\)" "ptype varx with varv associated" ++# Intel Fortran Compiler 10.1.008 uses the pointer type. ++gdb_test "ptype varv" "type = (PTR TO -> \\( )?real(\\(kind=4\\)|\\*4) \\(6,5:15,17:28\\)\\)?" "ptype varv associated" + -+ /* Sleep for a while to check GDB's `info threads' no longer tracks us in -+ the child fork. */ ++gdb_breakpoint [gdb_get_line_number "varv-filled"] ++gdb_continue_to_breakpoint "varv-filled" ++gdb_test "p varx(3, 7, 19)" "\\$\[0-9\]* = 10" "p varx(3, 7, 19) with varv filled" ++gdb_test "p varv(3, 7, 19)" "\\$\[0-9\]* = 10" "p varv(3, 7, 19) filled" + -+ i = sleep (2); -+ assert (i == 0); ++gdb_breakpoint [gdb_get_line_number "varv-deassociated"] ++gdb_continue_to_breakpoint "varv-deassociated" ++# The latter one is for the Intel Fortran Compiler 10.1.008 pointer type. ++gdb_test "p varv" "\\$\[0-9\]* = (<(object|the array) is not associated>|.*(Cannot access it|Unable to access the object) because the object is not associated.)" "p varv deassociated" ++gdb_test "ptype varv" "type = (<(object|the array) is not associated>|.*(Cannot access it|Unable to access the object) because the object is not associated.)" "ptype varv deassociated" ++gdb_test "p l" "\\$\[0-9\]* = \\.FALSE\\." "p l if varv deassociated" ++gdb_test "p varv(1,5,17)" "(Cannot access it|Unable to access the object) because the (object|array) is not associated\\." ++gdb_test "ptype varv(1,5,17)" "(Cannot access it|Unable to access the object) because the (object|array) is not associated\\." + -+ _exit (0); -+ case 0: -+ printf ("child%d: %d\n", nr, (int) getpid ()); ++gdb_breakpoint [gdb_get_line_number "varx-deallocated"] ++gdb_continue_to_breakpoint "varx-deallocated" ++gdb_test "p varx" "\\$\[0-9\]* = <(object|the array) is not allocated>" "p varx deallocated" ++gdb_test "ptype varx" "type = <(object|the array) is not allocated>" "ptype varx deallocated" ++gdb_test "p l" "\\$\[0-9\]* = \\.FALSE\\." "p l if varx deallocated" ++gdb_test "p varx(1,5,17)" "(Cannot access it|Unable to access the object) because the (object|array) is not allocated\\." "p varx(1,5,17) deallocated" ++gdb_test "ptype varx(1,5,17)" "(Cannot access it|Unable to access the object) because the (object|array) is not allocated\\." "ptype varx(1,5,17) deallocated" + -+ /* Let the parent signal us about its success. Be careful of races. */ ++gdb_breakpoint [gdb_get_line_number "vary-passed"] ++gdb_continue_to_breakpoint "vary-passed" ++# $1 = (( ( 1, 1, 1, 1, 1, 1) ( 1, 1, 1, 1, 1, 1) --- , 1) ) ( ( 1, 1, ...) ...) ...) ++gdb_test "p vary" "\\$\[0-9\]* = \\(\[()1, .\]*\\)" + -+ for (loop = 0; loop < 1000; loop++) -+ { -+ /* Parent either died (and USR1_GOT is zero) or it succeeded. */ -+ if (kill (getppid (), 0) != 0) -+ break; -+ /* Parent succeeded? */ -+ if (usr1_got) -+ break; ++gdb_breakpoint [gdb_get_line_number "vary-filled"] ++gdb_continue_to_breakpoint "vary-filled" ++gdb_test "ptype vary" "type = real(\\(kind=4\\)|\\*4) \\(10,10\\)" ++gdb_test "p vary(1, 1)" "\\$\[0-9\]* = 8" ++gdb_test "p vary(2, 2)" "\\$\[0-9\]* = 9" ++gdb_test "p vary(1, 3)" "\\$\[0-9\]* = 10" ++# $1 = (( ( 3, 3, 3, 3, 3, 3) ( 3, 3, 3, 3, 3, 3) --- , 3) ) ( ( 3, 3, ...) ...) ...) ++gdb_test "p varw" "\\$\[0-9\]* = \\(\[()3, .\]*\\)" + -+ delay (); -+ } -+ assert (usr1_got); ++gdb_breakpoint [gdb_get_line_number "varw-almostfilled"] ++gdb_continue_to_breakpoint "varw-almostfilled" ++gdb_test "ptype varw" "type = real(\\(kind=4\\)|\\*4) \\(5,4,3\\)" ++gdb_test "p varw(3,1,1)=1" "\\$\[0-9\]* = 1" ++# $1 = (( ( 6, 5, 1, 5, 5, 5) ( 5, 5, 5, 5, 5, 5) --- , 5) ) ( ( 5, 5, ...) ...) ...) ++gdb_test "p varw" "\\$\[0-9\]* = \\( *\\( *\\( *6, *5, *1,\[()5, .\]*\\)" "p varw filled" ++# "up" works with GCC but other Fortran compilers may copy the values into the ++# outer function only on the exit of the inner function. ++# We need both variants as depending on the arch we optionally may still be ++# executing the caller line or not after `finish'. ++gdb_test "finish" ".*(call bar \\(y, x\\)|call foo \\(x, z\\(2:6, 4:7, 6:8\\)\\))" ++gdb_test "p z(2,4,5)" "\\$\[0-9\]* = 3" ++gdb_test "p z(2,4,6)" "\\$\[0-9\]* = 6" ++gdb_test "p z(2,4,7)" "\\$\[0-9\]* = 5" ++gdb_test "p z(4,4,6)" "\\$\[0-9\]* = 1" + -+ /* We must get caught here (against a false watchpoint removal). */ ++gdb_breakpoint [gdb_get_line_number "varz-almostfilled"] ++gdb_continue_to_breakpoint "varz-almostfilled" ++# GCC uses the pointer type here, Intel Fortran Compiler 10.1.008 does not. ++gdb_test "ptype varz" "type = (PTR TO -> \\( )?real(\\(kind=4\\)|\\*4) \\(\\*\\)\\)?" ++# Intel Fortran Compiler 10.1.008 has a bug here - (2:11,7:7) ++# as it produces DW_AT_lower_bound == DW_AT_upper_bound == 7. ++gdb_test "ptype vart" "type = (PTR TO -> \\( )?real(\\(kind=4\\)|\\*4) \\(2:11,7:\\*\\)\\)?" ++gdb_test "p varz" "\\$\[0-9\]* = \\(\\)" ++gdb_test "p vart" "\\$\[0-9\]* = \\(\\)" ++gdb_test "p varz(3)" "\\$\[0-9\]* = 4" ++# maps to foo::vary(1,1) ++gdb_test "p vart(2,7)" "\\$\[0-9\]* = 8" ++# maps to foo::vary(2,2) ++gdb_test "p vart(3,8)" "\\$\[0-9\]* = 9" ++# maps to foo::vary(1,3) ++gdb_test "p vart(2,9)" "\\$\[0-9\]* = 10" +diff --git a/gdb/testsuite/gdb.fortran/dynamic.f90 b/gdb/testsuite/gdb.fortran/dynamic.f90 +new file mode 100644 +index 0000000..0f43564 +--- /dev/null ++++ b/gdb/testsuite/gdb.fortran/dynamic.f90 +@@ -0,0 +1,98 @@ ++! Copyright 2007 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. ++! ++! Ihis file is the Fortran source file for dynamic.exp. ++! Original file written by Jakub Jelinek . ++! Modified for the GDB testcase by Jan Kratochvil . + -+ breakpoint (); -+ } ++subroutine baz ++ real, target, allocatable :: varx (:, :, :) ++ real, pointer :: varv (:, :, :) ++ real, target :: varu (1, 2, 3) ++ logical :: l ++ allocate (varx (1:6, 5:15, 17:28)) ! varx-init ++ l = allocated (varx) ++ varx(:, :, :) = 6 ! varx-allocated ++ varx(1, 5, 17) = 7 ++ varx(2, 6, 18) = 8 ++ varx(6, 15, 28) = 9 ++ varv => varx ! varx-filled ++ l = associated (varv) ++ varv(3, 7, 19) = 10 ! varv-associated ++ varv => null () ! varv-filled ++ l = associated (varv) ++ deallocate (varx) ! varv-deassociated ++ l = allocated (varx) ++ varu(:, :, :) = 10 ! varx-deallocated ++ allocate (varv (1:6, 5:15, 17:28)) ++ l = associated (varv) ++ varv(:, :, :) = 6 ++ varv(1, 5, 17) = 7 ++ varv(2, 6, 18) = 8 ++ varv(6, 15, 28) = 9 ++ deallocate (varv) ++ l = associated (varv) ++ varv => varu ++ varv(1, 1, 1) = 6 ++ varv(1, 2, 3) = 7 ++ l = associated (varv) ++end subroutine baz ++subroutine foo (vary, varw) ++ real :: vary (:, :) ++ real :: varw (:, :, :) ++ vary(:, :) = 4 ! vary-passed ++ vary(1, 1) = 8 ++ vary(2, 2) = 9 ++ vary(1, 3) = 10 ++ varw(:, :, :) = 5 ! vary-filled ++ varw(1, 1, 1) = 6 ++ varw(2, 2, 2) = 7 ! varw-almostfilled ++end subroutine foo ++subroutine bar (varz, vart) ++ real :: varz (*) ++ real :: vart (2:11, 7:*) ++ varz(1:3) = 4 ++ varz(2) = 5 ! varz-almostfilled ++ vart(2,7) = vart(2,7) ++end subroutine bar ++program test ++ interface ++ subroutine foo (vary, varw) ++ real :: vary (:, :) ++ real :: varw (:, :, :) ++ end subroutine ++ end interface ++ interface ++ subroutine bar (varz, vart) ++ real :: varz (*) ++ real :: vart (2:11, 7:*) ++ end subroutine ++ end interface ++ real :: x (10, 10), y (5), z(8, 8, 8) ++ x(:,:) = 1 ++ y(:) = 2 ++ z(:,:,:) = 3 ++ call baz ++ call foo (x, z(2:6, 4:7, 6:8)) ++ call bar (y, x) ++ if (x (1, 1) .ne. 8 .or. x (2, 2) .ne. 9 .or. x (1, 2) .ne. 4) call abort ++ if (x (1, 3) .ne. 10) call abort ++ if (z (2, 4, 6) .ne. 6 .or. z (3, 5, 7) .ne. 7 .or. z (2, 4, 7) .ne. 5) call abort ++ if (any (y .ne. (/4, 5, 4, 2, 2/))) call abort ++ call foo (transpose (x), z) ++ if (x (1, 1) .ne. 8 .or. x (2, 2) .ne. 9 .or. x (1, 2) .ne. 4) call abort ++ if (x (3, 1) .ne. 10) call abort ++end +diff --git a/gdb/testsuite/gdb.fortran/string.exp b/gdb/testsuite/gdb.fortran/string.exp +new file mode 100644 +index 0000000..b1120c3 +--- /dev/null ++++ b/gdb/testsuite/gdb.fortran/string.exp +@@ -0,0 +1,59 @@ ++# Copyright 2008 Free Software Foundation, Inc. + -+ i = sigaction (SIGUSR1, &oldact, NULL); -+ assert (i == 0); -+} ++# 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. + -+#else -+# error "!FOLLOW_PARENT && !FOLLOW_CHILD" -+#endif -diff --git a/gdb/testsuite/gdb.threads/watchpoint-fork-mt.c b/gdb/testsuite/gdb.threads/watchpoint-fork-mt.c -new file mode 100644 -index 0000000..edacfc0 ---- /dev/null -+++ b/gdb/testsuite/gdb.threads/watchpoint-fork-mt.c -@@ -0,0 +1,157 @@ -+/* Test case for forgotten hw-watchpoints after fork()-off of a process. ++# This file was written by Jan Kratochvil . + -+ Copyright 2008, 2009 Free Software Foundation, Inc. ++# This file is part of the gdb testsuite. It contains tests for Fortran ++# strings with dynamic length. + -+ This file is part of GDB. ++set testfile "string" ++set srcfile ${testfile}.f90 ++set binfile ${objdir}/${subdir}/${testfile} + -+ 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. ++if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug f77 quiet}] != "" } { ++ untested "Couldn't compile ${srcfile}" ++ return -1 ++} + -+ 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. ++gdb_exit ++gdb_start ++gdb_reinitialize_dir $srcdir/$subdir ++gdb_load ${binfile} + -+ 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. */ ++if ![runto MAIN__] then { ++ perror "couldn't run to breakpoint MAIN__" ++ continue ++} + -+#include -+#include -+#include -+#include -+#include -+#include ++gdb_breakpoint [gdb_get_line_number "var-init"] ++gdb_continue_to_breakpoint "var-init" ++gdb_test "ptype c" "type = character(\\(kind=1\\)|\\*1)" ++gdb_test "ptype d" "type = character(\\(kind=8\\)|\\*8)" ++gdb_test "ptype e" "type = character(\\(kind=4\\)|\\*4)" ++gdb_test "ptype f" "type = character(\\(kind=4\\)|\\*4) \\(7,8:10\\)" ++gdb_test "ptype *e" "Attempt to take contents of a non-pointer value." ++gdb_test "ptype *f" "type = character(\\(kind=4\\)|\\*4) \\(7\\)" ++gdb_test "p c" "\\$\[0-9\]* = 'c'" ++gdb_test "p d" "\\$\[0-9\]* = 'd '" ++gdb_test "p e" "\\$\[0-9\]* = 'g '" ++gdb_test "p f" "\\$\[0-9\]* = \\(\\( 'h ', 'h ', 'h ', 'h ', 'h ', 'h ', 'h '\\) \\( 'h ', 'h ', 'h ', 'h ', 'h ', 'h ', 'h '\\) \\( 'h ', 'h ', 'h ', 'h ', 'h ', 'h ', 'h '\\) \\)" ++gdb_test "p *e" "Attempt to take contents of a non-pointer value." ++gdb_test "p *f" "Attempt to take contents of a non-pointer value." + -+#include -+#include -+#define gettid() syscall (__NR_gettid) ++gdb_breakpoint [gdb_get_line_number "var-finish"] ++gdb_continue_to_breakpoint "var-finish" ++gdb_test "p e" "\\$\[0-9\]* = 'e '" "p e re-set" ++gdb_test "p f" "\\$\[0-9\]* = \\(\\( 'f ', 'f ', 'f ', 'f ', 'f ', 'f ', 'f '\\) \\( 'f2 ', 'f ', 'f ', 'f ', 'f ', 'f ', 'f '\\) \\( 'f ', 'f ', 'f ', 'f ', 'f ', 'f ', 'f '\\) \\)" "p *f re-set" +diff --git a/gdb/testsuite/gdb.fortran/string.f90 b/gdb/testsuite/gdb.fortran/string.f90 +new file mode 100644 +index 0000000..226dc5d +--- /dev/null ++++ b/gdb/testsuite/gdb.fortran/string.f90 +@@ -0,0 +1,37 @@ ++! Copyright 2008 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. ++! ++! Ihis file is the Fortran source file for dynamic.exp. ++! Original file written by Jakub Jelinek . ++! Modified for the GDB testcase by Jan Kratochvil . + -+/* Non-atomic `var++' should not hurt as we synchronize the threads by the STEP -+ variable. Hit-comments need to be duplicite there to catch both at-stops -+ and behind-stops, depending on the target. */ ++subroutine foo (e, f) ++ character (len=1) :: c ++ character (len=8) :: d ++ character (len=*) :: e ++ character (len=*) :: f (1:7, 8:10) ++ c = 'c' ++ d = 'd' ++ e = 'e' ! var-init ++ f = 'f' ++ f(1,9) = 'f2' ++ c = 'c' ! var-finish ++end subroutine foo ++ character (len=4) :: g, h (1:7, 8:10) ++ g = 'g' ++ h = 'h' ++ call foo (g, h) ++end +diff --git a/gdb/testsuite/gdb.gdb/selftest.exp b/gdb/testsuite/gdb.gdb/selftest.exp +index fc8bccc..e053813 100644 +--- a/gdb/testsuite/gdb.gdb/selftest.exp ++++ b/gdb/testsuite/gdb.gdb/selftest.exp +@@ -92,6 +92,10 @@ proc do_steps_and_nexts {} { + set description "step over ttyarg initialization" + set command "step" + } ++ -re ".*python_script = 0.*$gdb_prompt $" { ++ set description "step over python_script initialization" ++ set command "step" ++ } + -re ".*pre_stat_chain = make_command_stats_cleanup.*$gdb_prompt $" { + set description "next over make_command_stats_cleanup and everything it calls" + set command "next" +diff --git a/gdb/testsuite/gdb.java/jnpe.exp b/gdb/testsuite/gdb.java/jnpe.exp +new file mode 100644 +index 0000000..55aa80d +--- /dev/null ++++ b/gdb/testsuite/gdb.java/jnpe.exp +@@ -0,0 +1,74 @@ ++# Copyright 2009 Free Software Foundation, Inc. + -+static volatile int var; ++# 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 . + -+static void -+dummy (void) -+{ ++if $tracelevel then { ++ strace $tracelevel +} + -+static void -+breakpoint (void) -+{ -+} ++load_lib "java.exp" + -+/* Include here the functions: -+ static void forkoff (int nr); -+ static void delay (void); */ ++set testfile "jnpe" ++set srcfile ${testfile}.java ++set binfile ${objdir}/${subdir}/${testfile} ++if { [compile_java_from_source ${srcdir}/$subdir/${srcfile} ${binfile} "-g"] != "" } { ++ untested "Couldn't compile ${srcdir}/$subdir/${srcfile}" ++ return -1 ++} + -+static pthread_t thread; -+static volatile int step; -+#define THREAD ++# Start with a fresh gdb. + -+#include "watchpoint-fork-forkoff.c" ++gdb_exit ++gdb_start ++gdb_reinitialize_dir $srcdir/$subdir ++gdb_load ${binfile} + -+static void * -+start (void *arg) -+{ -+ if (step >= 3) -+ goto step_3; ++set line [gdb_get_line_number "break here" $testfile.java] ++gdb_test "break $testfile.java:$line" "" + -+ while (step != 1) -+ delay (); ++gdb_test "run" \ ++ "// break here.*" \ ++ "run java next-over-throw" + -+ var++; /* validity-thread-B */ -+ dummy (); /* validity-thread-B */ -+ step = 2; -+ while (step != 3) -+ { -+ if (step == 99) -+ goto step_99; -+ delay (); ++# See whether we have the needed unwinder hooks. ++set ok 1 ++gdb_test_multiple "print _Unwind_DebugHook" "check for unwinder hook in java" { ++ -re "= .*_Unwind_DebugHook.*\r\n$gdb_prompt $" { ++ pass "check for unwinder hook in java" + } -+ -+step_3: -+ if (step >= 5) -+ goto step_5; -+ -+ var++; /* after-fork1-B */ -+ dummy (); /* after-fork1-B */ -+ step = 4; -+ while (step != 5) -+ { -+ if (step == 99) -+ goto step_99; -+ delay (); ++ -re "No symbol .* in current context.?\r\n$gdb_prompt $" { ++ # Pass the test so we don't get bogus fails in the results. ++ setup_xfail *-*-* ++ fail "check for unwinder hook in java" ++ set ok 0 + } ++} ++if {!$ok} { ++ untested jnpe.exp ++ return -1 ++} + -+step_5: -+ var++; /* after-fork2-B */ -+ dummy (); /* after-fork2-B */ -+ return (void *) 5UL; ++gdb_test "handle SIGSEGV nostop noprint" \ ++ "SIGSEGV.*fault" \ ++ "disable SIGSEGV for next-over-NPE" + -+step_99: -+ /* We must not get caught here (against a forgotten breakpoint). */ -+ var++; -+ breakpoint (); -+ return (void *) 99UL; -+} ++# The line where we stop differ according to gcj; check just we did not already ++# execute the catch point. + -+int -+main (void) -+{ -+ int i; -+ void *thread_result; ++gdb_test "next" \ ++ "" \ ++ "next over NPE" ++ ++gdb_breakpoint [gdb_get_line_number "catch point"] ++gdb_continue_to_breakpoint "catch point" ".*// catch point.*" +diff --git a/gdb/testsuite/gdb.java/jnpe.java b/gdb/testsuite/gdb.java/jnpe.java +new file mode 100644 +index 0000000..3524830 +--- /dev/null ++++ b/gdb/testsuite/gdb.java/jnpe.java +@@ -0,0 +1,38 @@ ++// Test next-over-NPE. ++/* This testcase is part of GDB, the GNU debugger. + -+ setbuf (stdout, NULL); -+ printf ("main: %d\n", (int) gettid ()); ++ Copyright 2009 Free Software Foundation, Inc. + -+ /* General watchpoints validity. */ -+ var++; /* validity-first */ -+ dummy (); /* validity-first */ ++ 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. + -+ i = pthread_create (&thread, NULL, start, NULL); -+ assert (i == 0); ++ 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. + -+ var++; /* validity-thread-A */ -+ dummy (); /* validity-thread-A */ -+ step = 1; -+ while (step != 2) -+ delay (); ++ You should have received a copy of the GNU General Public License ++ along with this program. If not, see . ++ */ + -+ /* Hardware watchpoints got disarmed here. */ -+ forkoff (1); ++public class jnpe ++{ ++ public static String npe () ++ { ++ return ((Object) null).toString(); ++ } + -+ var++; /* after-fork1-A */ -+ dummy (); /* after-fork1-A */ -+ step = 3; -+#ifdef FOLLOW_CHILD -+ /* Spawn new thread as it was deleted in the child of FORK. */ -+ i = pthread_create (&thread, NULL, start, NULL); -+ assert (i == 0); -+#endif -+ while (step != 4) -+ delay (); ++ public static void main (String[] args) ++ { ++ try ++ { ++ System.out.println (npe ()); // break here ++ } ++ catch (NullPointerException n) ++ { ++ System.out.println ("success"); // catch point ++ } ++ } ++} +diff --git a/gdb/testsuite/gdb.opt/array-from-register-func.c b/gdb/testsuite/gdb.opt/array-from-register-func.c +new file mode 100644 +index 0000000..729f457 +--- /dev/null ++++ b/gdb/testsuite/gdb.opt/array-from-register-func.c +@@ -0,0 +1,22 @@ ++/* This file is part of GDB, the GNU debugger. + -+ /* A sanity check for double hardware watchpoints removal. */ -+ forkoff (2); ++ Copyright 2009 Free Software Foundation, Inc. + -+ var++; /* after-fork2-A */ -+ dummy (); /* after-fork2-A */ -+ step = 5; -+#ifdef FOLLOW_CHILD -+ /* Spawn new thread as it was deleted in the child of FORK. */ -+ i = pthread_create (&thread, NULL, start, NULL); -+ assert (i == 0); -+#endif ++ 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. + -+ i = pthread_join (thread, &thread_result); -+ assert (i == 0); -+ assert (thread_result == (void *) 5UL); ++ 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. + -+ return 0; ++ You should have received a copy of the GNU General Public License ++ along with this program. If not, see . */ ++ ++int ++func (int *arr) ++{ ++ return arr[0]; +} -diff --git a/gdb/testsuite/gdb.threads/watchpoint-fork.c b/gdb/testsuite/gdb.threads/watchpoint-fork.c +diff --git a/gdb/testsuite/gdb.opt/array-from-register.c b/gdb/testsuite/gdb.opt/array-from-register.c new file mode 100644 -index 0000000..5f62e7f +index 0000000..3090e7e --- /dev/null -+++ b/gdb/testsuite/gdb.threads/watchpoint-fork.c -@@ -0,0 +1,57 @@ -+/* Test case for forgotten hw-watchpoints after fork()-off of a process. -+ -+ Copyright 2008, 2009 Free Software Foundation, Inc. ++++ b/gdb/testsuite/gdb.opt/array-from-register.c +@@ -0,0 +1,28 @@ ++/* This file is part of GDB, the GNU debugger. + -+ This file is part of GDB. ++ Copyright 2009 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 ++ 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, @@ -27017,54 +14393,147 @@ index 0000000..5f62e7f + 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. */ -+ -+#include -+#include -+#include -+#include -+#include ++ along with this program. If not, see . */ + -+static volatile int var; ++extern int func (int *arr); + -+static void -+breakpoint (void) ++int ++main (void) +{ ++ int arr[] = { 42 }; ++ ++ func (arr); ++ ++ return 0; +} +diff --git a/gdb/testsuite/gdb.opt/array-from-register.exp b/gdb/testsuite/gdb.opt/array-from-register.exp +new file mode 100644 +index 0000000..f2de718 +--- /dev/null ++++ b/gdb/testsuite/gdb.opt/array-from-register.exp +@@ -0,0 +1,33 @@ ++# Copyright 2009 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. ++# ++# This file is part of the gdb testsuite. + -+/* Include here the function: -+ static void forkoff (int nr); */ ++if { [prepare_for_testing array-from-register.exp "array-from-register" \ ++ {array-from-register.c array-from-register-func.c} \ ++ {debug optimize=-O2}] } { ++ return -1 ++} + -+#include "watchpoint-fork-forkoff.c" ++if ![runto func] then { ++ return -1 ++} + -+int -+main (void) -+{ -+ setbuf (stdout, NULL); -+ printf ("main: %d\n", (int) getpid ()); ++gdb_test "p arr" "\\$\[0-9\]+ = \\(int \\*\\) *0x\[0-9a-f\]+" + -+ /* General watchpoints validity. */ -+ var++; -+ /* Hardware watchpoints got disarmed here. */ -+ forkoff (1); -+ /* This watchpoint got lost before. */ -+ var++; -+ /* A sanity check for double hardware watchpoints removal. */ -+ forkoff (2); -+ var++; ++# Seen regression: ++# Address requested for identifier "arr" which is in register $rdi ++gdb_test "p arr\[0\]" "\\$\[0-9\]+ = 42" +diff --git a/gdb/testsuite/gdb.opt/fortran-string.exp b/gdb/testsuite/gdb.opt/fortran-string.exp +new file mode 100644 +index 0000000..f997eec +--- /dev/null ++++ b/gdb/testsuite/gdb.opt/fortran-string.exp +@@ -0,0 +1,41 @@ ++# Copyright 2009 Free Software Foundation, Inc. + -+ return 0; ++# 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. ++ ++# This file was written by Jan Kratochvil . ++ ++# Test GDB can cope with Fortran strings having their length present in a CPU ++# register. With -O0 the string length is passed on the stack. To make this ++# test meaningful the follow assertion should pass. It is not being checked ++# here as the "_s" symbol is compiler dependent: ++# (gdb) info address _s ++# Symbol "_s" is a variable in register XX. ++ ++set test fortran-string ++set srcfile ${test}.f90 ++if { [prepare_for_testing ${test}.exp ${test} ${srcfile} {debug f77 additional_flags=-O2}] } { ++ return -1 +} -diff --git a/gdb/testsuite/gdb.threads/watchpoint-fork.exp b/gdb/testsuite/gdb.threads/watchpoint-fork.exp ++ ++if ![runto MAIN__] then { ++ perror "couldn't run to breakpoint MAIN__" ++ continue ++} ++ ++gdb_breakpoint [gdb_get_line_number "s = s"] ++gdb_continue_to_breakpoint "s = s" ++gdb_test "frame" ".*s='foo'.*" ++gdb_test "ptype s" "type = character\\*3" ++gdb_test "p s" "\\$\[0-9\]* = 'foo'" +diff --git a/gdb/testsuite/gdb.opt/fortran-string.f90 b/gdb/testsuite/gdb.opt/fortran-string.f90 +new file mode 100644 +index 0000000..e48d520 +--- /dev/null ++++ b/gdb/testsuite/gdb.opt/fortran-string.f90 +@@ -0,0 +1,28 @@ ++! Copyright 2009 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. ++! ++! Ihis file is the Fortran source file for dynamic.exp. ++! Original file written by Jakub Jelinek . ++! Modified for the GDB testcase by Jan Kratochvil . ++ ++ subroutine f(s) ++ character*(*) s ++ s = s ++ end ++ ++ program main ++ call f ('foo') ++ end +diff --git a/gdb/testsuite/gdb.pascal/arrays.exp b/gdb/testsuite/gdb.pascal/arrays.exp new file mode 100644 -index 0000000..1dc93ab +index 0000000..ccc6e1e --- /dev/null -+++ b/gdb/testsuite/gdb.threads/watchpoint-fork.exp -@@ -0,0 +1,130 @@ ++++ b/gdb/testsuite/gdb.pascal/arrays.exp +@@ -0,0 +1,104 @@ +# Copyright 2008, 2009 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 @@ -27078,134 +14547,346 @@ index 0000000..1dc93ab +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + -+# Test case for forgotten hw-watchpoints after fork()-off of a process. ++if $tracelevel then { ++ strace $tracelevel ++} + -+proc test {type symbol} { -+ global objdir subdir srcdir ++load_lib "pascal.exp" + -+ set test watchpoint-fork ++set testfile "arrays" ++set srcfile ${testfile}.pas ++set binfile ${objdir}/${subdir}/${testfile}$EXEEXT + -+ global pf_prefix -+ set prefix_test $pf_prefix -+ lappend pf_prefix "$type:" -+ set prefix_mt $pf_prefix ++# These tests only work with fpc, using the -gw3 compile-option ++pascal_init ++if { $pascal_compiler_is_fpc != 1 } { ++ return -1 ++} + -+ # no threads ++# Detect if the fpc version is below 2.3.0 ++set fpc_generates_dwarf_for_dynamic_arrays 1 ++if { ($fpcversion_major < 2) || ( ($fpcversion_major == 2) && ($fpcversion_minor < 3))} { ++ set fpc_generates_dwarf_for_dynamic_arrays 0 ++} + -+ set pf_prefix $prefix_mt -+ lappend pf_prefix "singlethreaded:" + -+ set executable ${test}-${type} -+ if { [gdb_compile ${srcdir}/${subdir}/${test}.c ${objdir}/${subdir}/${executable} executable [list debug additional_flags=-D$symbol]] != "" } { -+ untested ${test}.exp -+ return -1 -+ } -+ clean_restart $executable ++if {[gdb_compile_pascal "-gw3 ${srcdir}/${subdir}/${srcfile}" "${binfile}" executable [list debug ]] != "" } { ++ return -1 ++} + -+ gdb_test "show detach-on-fork" "Whether gdb will detach the child of a fork is on." -+ gdb_test "set follow-fork-mode $type" -+ gdb_test "show follow-fork-mode" "Debugger response to a program call of fork or vfork is \"$type\"." -+ # Testcase uses it for the `follow-fork-mode child' type. -+ gdb_test "handle SIGUSR1 nostop noprint pass" ++gdb_exit ++gdb_start ++gdb_reinitialize_dir $srcdir/$subdir ++gdb_load ${binfile} ++set bp_location1 [gdb_get_line_number "set breakpoint 1 here"] ++set bp_location2 [gdb_get_line_number "set breakpoint 2 here"] + -+ if { ![runto_main] } then { -+ gdb_suppress_tests -+ return -+ } + -+ # Install the watchpoint only after getting into MAIN - workaround some PPC -+ # problem. -+ gdb_test "watch var" "atchpoint 2: var" "Set the watchpoint" ++if { [gdb_breakpoint ${srcfile}:${bp_location1}] } { ++ pass "setting breakpoint 1" ++} ++if { [gdb_breakpoint ${srcfile}:${bp_location2}] } { ++ pass "setting breakpoint 2" ++} + -+ # It is never hit but it should not be left over in the fork()ed-off child. -+ gdb_breakpoint "breakpoint" ++# Verify that "start" lands inside the right procedure. ++if { [gdb_start_cmd] < 0 } { ++ untested start ++ return -1 ++} + -+ gdb_test "continue" \ -+ "atchpoint 2: var.*Old value = 0.*New value = 1.*forkoff *\\(1\\).*" "watchpoints work" -+ gdb_test "continue" \ -+ "reakpoint 3, breakpoint.*" "breakpoint after the first fork" -+ gdb_test "continue" \ -+ "atchpoint 2: var.*Old value = 1.*New value = 2.*forkoff *\\(2\\).*" "watchpoint after the first fork" -+ gdb_test "continue" \ -+ "reakpoint 3, breakpoint.*" "breakpoint after the second fork" -+ gdb_test "continue" \ -+ "atchpoint 2: var.*Old value = 2.*New value = 3.*return *0;" "watchpoint after the second fork" -+ gdb_test "continue" "Continuing..*Program exited normally." "finish" ++gdb_test "" ".* at .*${srcfile}.*" "start" + ++gdb_test "cont" "Breakpoint .*:${bp_location1}.*" "Going to first breakpoint" + -+ # threads ++gdb_test "print StatArrInt" ".* = \\{50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61\\}" "Print static array of integer type" ++gdb_test "print StatArrInt_" ".* = \\{50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61\\}" "Print static array of integer" + -+ set pf_prefix $prefix_mt -+ lappend pf_prefix "multithreaded:" ++gdb_test "cont" "Breakpoint .*:${bp_location2}.*" "Going to second breakpoint" + -+ set executable ${test}-mt-${type} -+ if { [gdb_compile_pthreads ${srcdir}/${subdir}/${test}-mt.c ${objdir}/${subdir}/${executable} executable [list debug additional_flags=-D$symbol]] != "" } { -+ untested ${test}.exp -+ return -1 -+ } -+ clean_restart $executable ++gdb_test "print StatArrChar" ".* = 'abcdefghijkl'" "Print static array of char" ++gdb_test "print Stat2dArrInt" ".* = \\{\\{0, 1, 2, 3, 4\\}, \\{1, 2, 3, 4, 5\\}, \\{2, 3, 4, 5, 6\\}, \\{3, 4, 5, 6, 7\\}, \\{4, 5, 6, 7, 8\\}, \\{5, 6, 7, 8, 9\\}, \\{6, 7, 8, 9, 10\\}, \\{7, 8, 9, 10, 11\\}, \\{8, 9, 10, 11, 12\\}, \\{9, 10, 11, 12, 13\\}, \\{10, 11, 12, 13, 14\\}, \\{11, 12, 13, 14, 15\\}\\}" "Print static 2-dimensional array of integer" + -+ gdb_test "set follow-fork-mode $type" -+ # Testcase uses it for the `follow-fork-mode child' type. -+ gdb_test "handle SIGUSR1 nostop noprint pass" ++if { $fpc_generates_dwarf_for_dynamic_arrays == 0} { ++ setup_xfail "*-*-*" ++} ++gdb_test "print DynArrInt" ".* = \\{50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62\\}" "Print dynamic array of integer type" ++if { $fpc_generates_dwarf_for_dynamic_arrays == 0} { ++ setup_xfail "*-*-*" ++} ++gdb_test "print DynArrInt_" ".* = \\{50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62\\}" "Print dynamic array of integer" + -+ if { ![runto_main] } then { -+ gdb_suppress_tests -+ return -+ } ++if { $fpc_generates_dwarf_for_dynamic_arrays == 0} { ++ setup_xfail "*-*-*" ++} ++gdb_test "print s" ".* = 'test'#0'string'" "Print string containing null-char" + -+ # Install the watchpoint only after getting into MAIN - workaround some PPC -+ # problem. -+ gdb_test "watch var" "atchpoint 2: var" "Set the watchpoint" ++if { $fpc_generates_dwarf_for_dynamic_arrays == 0} { ++ setup_xfail "*-*-*" ++} ++gdb_test "print DynArrStr" ".* = \\{'dstr0', 'dstr1', 'dstr2', 'dstr3', 'dstr4', 'dstr5', 'dstr6', 'dstr7', 'dstr8', 'dstr9', 'dstr10', 'dstr11', 'dstr12'\\}" "Print dynamic array of string" + -+ # It is never hit but it should not be left over in the fork()ed-off child. -+ gdb_breakpoint "breakpoint" ++if { $fpc_generates_dwarf_for_dynamic_arrays == 0} { ++ setup_xfail "*-*-*" ++} ++gdb_test "print StatArrStr" ".* = \\{'str0', 'str1', 'str2', 'str3', 'str4', 'str5', 'str6', 'str7', 'str8', 'str9', 'str10', 'str11', 'str12'\\}" "Print static array of string" + -+ gdb_test "continue" \ -+ "atchpoint 2: var.*Old value = 0.*New value = 1.*validity-first.*" "singlethread watchpoints work" -+ gdb_test "continue" \ -+ "atchpoint 2: var.*Old value = 1.*New value = 2.*validity-thread-A.*" "multithreaded watchpoints work at A" -+ gdb_test "continue" \ -+ "atchpoint 2: var.*Old value = 2.*New value = 3.*validity-thread-B.*" "multithreaded watchpoints work at B" -+ gdb_test "continue" \ -+ "reakpoint 3, breakpoint.*" "breakpoint (A) after the first fork" -+ gdb_test "continue" \ -+ "atchpoint 2: var.*Old value = 3.*New value = 4.*after-fork1-A.*" "watchpoint A after the first fork" -+ gdb_test "continue" \ -+ "atchpoint 2: var.*Old value = 4.*New value = 5.*after-fork1-B.*" "watchpoint B after the first fork" -+ gdb_test "continue" \ -+ "reakpoint 3, breakpoint.*" "breakpoint (A) after the second fork" -+ gdb_test "continue" \ -+ "atchpoint 2: var.*Old value = 5.*New value = 6.*after-fork2-A.*" "watchpoint A after the second fork" -+ gdb_test "continue" \ -+ "atchpoint 2: var.*Old value = 6.*New value = 7.*after-fork2-B.*" "watchpoint B after the second fork" -+ gdb_test "continue" "Continuing..*Program exited normally." "finish" ++if { $fpc_generates_dwarf_for_dynamic_arrays == 0} { ++ setup_xfail "*-*-*" ++} ++gdb_test "print DynArrChar" ".* = 'abcdefghijklm'" "Print dynamic array of char" ++ +diff --git a/gdb/testsuite/gdb.pascal/arrays.pas b/gdb/testsuite/gdb.pascal/arrays.pas +new file mode 100644 +index 0000000..295602d +--- /dev/null ++++ b/gdb/testsuite/gdb.pascal/arrays.pas +@@ -0,0 +1,82 @@ ++{ ++ Copyright 2008, 2009 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. + -+ # cleanup ++ 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. + -+ set pf_prefix $prefix_test ++ You should have received a copy of the GNU General Public License ++ along with this program. If not, see . +} + -+test parent FOLLOW_PARENT ++program arrays; + -+# Only GNU/Linux is known to support `set follow-fork-mode child'. -+if {[istarget "*-*-linux*"]} { -+ test child FOLLOW_CHILD ++{$mode objfpc}{$h+} ++ ++uses sysutils; ++ ++type TStatArrInt= array[0..11] of integer; ++ TDynArrInt= array of integer; ++ TStatArrStr= array[0..12] of string; ++ TDynArrStr= array of string; ++ TDynArrChar = array of char; ++ TStatArrChar = array [0..11] of char; ++ ++ TStat2dArrInt = array[0..11,0..4] of integer; ++ ++var StatArrInt: TStatArrInt; ++ StatArrInt_: Array[0..11] of integer; ++ DynArrInt: TDynArrInt; ++ DynArrInt_: Array of integer; ++ StatArrStr: TStatArrStr; ++ DynArrStr: TDynArrStr; ++ StatArrChar: TStatArrChar; ++ DynArrChar: TDynArrChar; ++ ++ Stat2dArrInt: TStat2dArrInt; ++ ++ s: string; ++ ++ i,j : integer; ++ ++begin ++ for i := 0 to 11 do ++ begin ++ StatArrInt[i]:= i+50; ++ StatArrInt_[i]:= i+50; ++ StatArrChar[i]:= chr(ord('a')+i); ++ for j := 0 to 4 do ++ Stat2dArrInt[i,j]:=i+j; ++ end; ++ writeln(StatArrInt_[0]); ++ writeln(StatArrInt[0]); { set breakpoint 1 here } ++ writeln(StatArrChar[0]); ++ writeln(Stat2dArrInt[0,0]); ++ ++ setlength(DynArrInt,13); ++ setlength(DynArrInt_,13); ++ setlength(DynArrStr,13); ++ setlength(DynArrChar,13); ++ for i := 0 to 12 do ++ begin ++ DynArrInt[i]:= i+50; ++ DynArrInt_[i]:= i+50; ++ DynArrChar[i]:= chr(ord('a')+i); ++ StatArrStr[i]:='str'+inttostr(i); ++ DynArrStr[i]:='dstr'+inttostr(i); ++ end; ++ writeln(DynArrInt_[1]); ++ writeln(DynArrInt[1]); ++ writeln(DynArrStr[1]); ++ writeln(StatArrStr[1]); ++ writeln(DynArrChar[1]); ++ ++ s := 'test'#0'string'; ++ writeln(s); { set breakpoint 2 here } ++end. +diff --git a/gdb/testsuite/gdb.python/py-cmd.exp b/gdb/testsuite/gdb.python/py-cmd.exp +index 0f250d2..84e5038 100644 +--- a/gdb/testsuite/gdb.python/py-cmd.exp ++++ b/gdb/testsuite/gdb.python/py-cmd.exp +@@ -20,24 +20,6 @@ if $tracelevel then { + strace $tracelevel + } + +-# Usage: gdb_py_test_multiple NAME INPUT RESULT {INPUT RESULT}... +-# Run a test named NAME, consisting of multiple lines of input. +-# After each input line INPUT, search for result line RESULT. +-# Succeed if all results are seen; fail otherwise. +-proc gdb_py_test_multiple {name args} { +- global gdb_prompt +- foreach {input result} $args { +- if {[gdb_test_multiple $input "$name - $input" { +- -re "\[\r\n\]*($result)\[\r\n\]+($gdb_prompt | *>)$" { +- pass "$name - $input" +- } +- }]} { +- return 1 +- } +- } +- return 0 +-} +- + # Start with a fresh gdb. + + gdb_exit +diff --git a/gdb/testsuite/gdb.python/py-frame.exp b/gdb/testsuite/gdb.python/py-frame.exp +index e1212d3..77f44f5 100644 +--- a/gdb/testsuite/gdb.python/py-frame.exp ++++ b/gdb/testsuite/gdb.python/py-frame.exp +@@ -89,8 +89,6 @@ gdb_py_test_silent_cmd "python f0 = f1.newer ()" "get first frame" 0 + + gdb_test "python print 'result =', f0 == f1" " = False" "test equality comparison (false)" + gdb_test "python print 'result =', f0 == f0" " = True" "test equality comparison (true)" +-gdb_test "python print 'result =', f0 != f1" " = True" "test inequality comparison (true)" +-gdb_test "python print 'result =', f0 != f0" " = False" "test inequality comparison (false)" + gdb_test "python print 'result =', f0.is_valid ()" " = True" "test Frame.is_valid" + gdb_test "python print 'result =', f0.name ()" " = f2" "test Frame.name" + gdb_test "python print 'result =', f0.type () == gdb.NORMAL_FRAME" " = True" "test Frame.type" +@@ -105,3 +103,5 @@ gdb_test "python print 'result =', f0.read_var ('variable_which_surely_doesnt_ex + gdb_test "python print 'result =', f0.read_var ('a')" " = 1" "test Frame.read_var - success" + + gdb_test "python print 'result =', gdb.selected_frame () == f1" " = True" "test gdb.selected_frame" ++ ++gdb_test "python print 'result =', f0.block ()" "" "test Frame.block" +diff --git a/gdb/testsuite/gdb.python/py-function.exp b/gdb/testsuite/gdb.python/py-function.exp +index 38c5693..e7f0037 100644 +--- a/gdb/testsuite/gdb.python/py-function.exp ++++ b/gdb/testsuite/gdb.python/py-function.exp +@@ -20,24 +20,6 @@ if $tracelevel then { + strace $tracelevel + } + +-# Usage: gdb_py_test_multiple NAME INPUT RESULT {INPUT RESULT}... +-# Run a test named NAME, consisting of multiple lines of input. +-# After each input line INPUT, search for result line RESULT. +-# Succeed if all results are seen; fail otherwise. +-proc gdb_py_test_multiple {name args} { +- global gdb_prompt +- foreach {input result} $args { +- if {[gdb_test_multiple $input "$name - $input" { +- -re "\[\r\n\]*($result)\[\r\n\]+($gdb_prompt | *>)$" { +- pass "$name - $input" +- } +- }]} { +- return 1 +- } +- } +- return 0 +-} +- + # Start with a fresh gdb. + + gdb_exit +diff --git a/gdb/testsuite/gdb.python/py-prettyprint.exp b/gdb/testsuite/gdb.python/py-prettyprint.exp +index 3b2aadd..03bbf3e 100644 +--- a/gdb/testsuite/gdb.python/py-prettyprint.exp ++++ b/gdb/testsuite/gdb.python/py-prettyprint.exp +@@ -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 nullstr" "RuntimeError: Error reading string from inferior.*" ++ + gdb_test "print nstype" " = {$nl *.0. = 7,$nl *.1. = 42$nl}" + gdb_test "continue" "Program exited normally\." + +diff --git a/gdb/testsuite/gdb.python/py-value.exp b/gdb/testsuite/gdb.python/py-value.exp +index a24bc11..e3043bc 100644 +--- a/gdb/testsuite/gdb.python/py-value.exp ++++ b/gdb/testsuite/gdb.python/py-value.exp +@@ -313,6 +313,15 @@ proc test_value_after_death {} { + "print value's type" + } + ++# Regression test for a cast failure. The bug was that if we cast a ++# value to its own type, gdb could crash. This happened because we ++# could end up double-freeing a struct value. ++proc test_cast_regression {} { ++ gdb_test "python v = gdb.Value(5)" "" "create value for cast test" ++ gdb_test "python v = v.cast(v.type)" "" "cast value for cast test" ++ gdb_test "python print v" "5" "print value for cast test" +} -diff --git a/gdb/testsuite/gdb.threads/watchthreads-reorder.c b/gdb/testsuite/gdb.threads/watchthreads-reorder.c ++ + # Regression test for invalid subscript operations. The bug was that + # the type of the value was not being checked before allowing a + # subscript operation to proceed. +@@ -437,6 +446,7 @@ if ![runto_main] then { + test_value_in_inferior + test_lazy_strings + test_value_after_death ++test_cast_regression + + # The following test recompiles the binary to test either C or C++ + # values. +diff --git a/gdb/testsuite/gdb.python/rh634108-solib_address.exp b/gdb/testsuite/gdb.python/rh634108-solib_address.exp new file mode 100644 -index 0000000..14f42d6 +index 0000000..70319ff --- /dev/null -+++ b/gdb/testsuite/gdb.threads/watchthreads-reorder.c -@@ -0,0 +1,366 @@ -+/* This testcase is part of GDB, the GNU debugger. ++++ b/gdb/testsuite/gdb.python/rh634108-solib_address.exp +@@ -0,0 +1,24 @@ ++# Copyright (C) 2008, 2009, 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 . ++ ++# https://bugzilla.redhat.com/show_bug.cgi?id=634108 ++ ++gdb_exit ++gdb_start ++ ++# Skip all tests if Python scripting is not enabled. ++if { [skip_python_tests] } { continue } ++ ++gdb_test "python print gdb.solib_address(-1)" "None" "gdb.solib_address exists" +diff --git a/gdb/testsuite/gdb.threads/watchpoint-fork-forkoff.c b/gdb/testsuite/gdb.threads/watchpoint-fork-forkoff.c +new file mode 100644 +index 0000000..4dc308b +--- /dev/null ++++ b/gdb/testsuite/gdb.threads/watchpoint-fork-forkoff.c +@@ -0,0 +1,175 @@ ++/* Test case for forgotten hw-watchpoints after fork()-off of a process. + -+ Copyright 2009 Free Software Foundation, Inc. ++ Copyright 2008, 2009 Free Software Foundation, Inc. ++ ++ This file is part of GDB. + + 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 ++ 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, @@ -27214,366 +14895,397 @@ index 0000000..14f42d6 + 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 . */ ++ along with this program; if not, write to the Free Software ++ Foundation, Inc., 59 Temple Place - Suite 330, ++ Boston, MA 02111-1307, USA. */ + -+#define _GNU_SOURCE -+#include -+#include -+#include -+#include -+#include +#include -+#include -+#include -+#include -+#include -+#include ++#include + -+#define gettid() syscall (__NR_gettid) ++static void ++delay (void) ++{ ++ int i = usleep (1000000 / 100); ++ assert (i == 0 || errno == EINTR); ++} + -+/* Terminate always in the main task, it can lock up with SIGSTOPped GDB -+ otherwise. */ -+#define TIMEOUT (gettid () == getpid() ? 10 : 15) ++#if defined FOLLOW_PARENT ++ ++static void ++forkoff (int nr) ++{ ++ pid_t child, pid_got; ++ int exit_code = 42 + nr; ++ int status, i; ++ ++ child = fork (); ++ switch (child) ++ { ++ case -1: ++ assert (0); ++ case 0: ++ printf ("child%d: %d\n", nr, (int) getpid ()); ++ /* Delay to get both the "child%d" and "parent%d" message printed without ++ a race breaking expect by its endless wait on `$gdb_prompt$': ++ Breakpoint 3, breakpoint () at ../../../gdb/testsuite/gdb.threads/watchpoint-fork.c:33 ++ 33 } ++ (gdb) parent2: 14223 */ ++ i = sleep (1); ++ assert (i == 0); + -+static pthread_mutex_t gdbstop_mutex = PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP; ++ /* We must not get caught here (against a forgotten breakpoint). */ ++ var++; ++ breakpoint (); + -+static pid_t thread1_tid; -+static pthread_cond_t thread1_tid_cond = PTHREAD_COND_INITIALIZER; -+static pthread_mutex_t thread1_tid_mutex = PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP; ++ _exit (exit_code); ++ default: ++ printf ("parent%d: %d\n", nr, (int) child); ++ /* Delay to get both the "child%d" and "parent%d" message printed, see ++ above. */ ++ i = sleep (1); ++ assert (i == 0); + -+static pid_t thread2_tid; -+static pthread_cond_t thread2_tid_cond = PTHREAD_COND_INITIALIZER; -+static pthread_mutex_t thread2_tid_mutex = PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP; ++ pid_got = wait (&status); ++ assert (pid_got == child); ++ assert (WIFEXITED (status)); ++ assert (WEXITSTATUS (status) == exit_code); + -+static pthread_mutex_t terminate_mutex = PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP; ++ /* We must get caught here (against a false watchpoint removal). */ ++ breakpoint (); ++ } ++} + -+static volatile int thread1_rwatch; -+static volatile int thread2_rwatch; ++#elif defined FOLLOW_CHILD + -+static int unused1_rwatch; -+static int unused2_rwatch; ++static volatile int usr1_got; + -+/* Do not use alarm as it would create a ptrace event which would hang up us if -+ * we are being traced by GDB which we stopped ourselves. */ ++static void ++handler_usr1 (int signo) ++{ ++ usr1_got++; ++} + -+static void timed_mutex_lock (pthread_mutex_t *mutex) ++static void ++forkoff (int nr) +{ -+ int i; -+ struct timespec start, now; ++ pid_t child; ++ int i, loop; ++ struct sigaction act, oldact; ++#ifdef THREAD ++ void *thread_result; ++#endif + -+ i = clock_gettime (CLOCK_MONOTONIC, &start); ++ memset (&act, 0, sizeof act); ++ act.sa_flags = SA_RESTART; ++ act.sa_handler = handler_usr1; ++ sigemptyset (&act.sa_mask); ++ i = sigaction (SIGUSR1, &act, &oldact); + assert (i == 0); + -+ do ++ child = fork (); ++ switch (child) + { -+ i = pthread_mutex_trylock (mutex); -+ if (i == 0) -+ return; -+ assert (i == EBUSY); ++ case -1: ++ assert (0); ++ default: ++ printf ("parent%d: %d\n", nr, (int) child); ++ ++ /* Sleep for a while to possibly get incorrectly ATTACH_THREADed by GDB ++ tracing the child fork with no longer valid thread/lwp entries of the ++ parent. */ + -+ i = clock_gettime (CLOCK_MONOTONIC, &now); ++ i = sleep (2); + assert (i == 0); -+ assert (now.tv_sec >= start.tv_sec); -+ } -+ while (now.tv_sec - start.tv_sec < TIMEOUT); + -+ fprintf (stderr, "Timed out waiting for internal lock!\n"); -+ exit (EXIT_FAILURE); -+} ++ /* We must not get caught here (against a forgotten breakpoint). */ + -+static void * -+thread1_func (void *unused) -+{ -+ int i; -+ volatile int rwatch_store; ++ var++; ++ breakpoint (); + -+ thread1_tid = gettid (); -+ i = pthread_cond_signal (&thread1_tid_cond); -+ assert (i == 0); ++#ifdef THREAD ++ /* And neither got caught our thread. */ + -+ /* Be sure GDB is already stopped before continuing. */ -+ timed_mutex_lock (&gdbstop_mutex); -+ i = pthread_mutex_unlock (&gdbstop_mutex); -+ assert (i == 0); ++ step = 99; ++ i = pthread_join (thread, &thread_result); ++ assert (i == 0); ++ assert (thread_result == (void *) 99UL); ++#endif + -+ rwatch_store = thread1_rwatch; ++ /* Be sure our child knows we did not get caught above. */ + -+ /* 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); ++ i = kill (child, SIGUSR1); ++ assert (i == 0); + -+ return NULL; -+} ++ /* Sleep for a while to check GDB's `info threads' no longer tracks us in ++ the child fork. */ + -+static void * -+thread2_func (void *unused) -+{ -+ int i; -+ volatile int rwatch_store; ++ i = sleep (2); ++ assert (i == 0); + -+ thread2_tid = gettid (); -+ i = pthread_cond_signal (&thread2_tid_cond); -+ assert (i == 0); ++ _exit (0); ++ case 0: ++ printf ("child%d: %d\n", nr, (int) getpid ()); + -+ /* Be sure GDB is already stopped before continuing. */ -+ timed_mutex_lock (&gdbstop_mutex); -+ i = pthread_mutex_unlock (&gdbstop_mutex); -+ assert (i == 0); ++ /* Let the parent signal us about its success. Be careful of races. */ ++ ++ for (loop = 0; loop < 1000; loop++) ++ { ++ /* Parent either died (and USR1_GOT is zero) or it succeeded. */ ++ if (kill (getppid (), 0) != 0) ++ break; ++ /* Parent succeeded? */ ++ if (usr1_got) ++ break; + -+ rwatch_store = thread2_rwatch; ++ delay (); ++ } ++ assert (usr1_got); + -+ /* 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); ++ /* We must get caught here (against a false watchpoint removal). */ + -+ return NULL; ++ breakpoint (); ++ } ++ ++ i = sigaction (SIGUSR1, &oldact, NULL); ++ assert (i == 0); +} + -+static const char * -+proc_string (const char *filename, const char *line) -+{ -+ FILE *f; -+ static char buf[LINE_MAX]; -+ size_t line_len = strlen (line); ++#else ++# error "!FOLLOW_PARENT && !FOLLOW_CHILD" ++#endif +diff --git a/gdb/testsuite/gdb.threads/watchpoint-fork-mt.c b/gdb/testsuite/gdb.threads/watchpoint-fork-mt.c +new file mode 100644 +index 0000000..edacfc0 +--- /dev/null ++++ b/gdb/testsuite/gdb.threads/watchpoint-fork-mt.c +@@ -0,0 +1,157 @@ ++/* Test case for forgotten hw-watchpoints after fork()-off of a process. + -+ f = fopen (filename, "r"); -+ if (f == NULL) -+ { -+ fprintf (stderr, "fopen (\"%s\") for \"%s\": %s\n", filename, line, -+ strerror (errno)); -+ exit (EXIT_FAILURE); -+ } -+ while (errno = 0, fgets (buf, sizeof (buf), f)) -+ { -+ char *s; ++ Copyright 2008, 2009 Free Software Foundation, Inc. + -+ s = strchr (buf, '\n'); -+ assert (s != NULL); -+ *s = 0; ++ This file is part of GDB. + -+ if (strncmp (buf, line, line_len) != 0) -+ continue; ++ 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. + -+ if (fclose (f)) -+ { -+ fprintf (stderr, "fclose (\"%s\") for \"%s\": %s\n", filename, line, -+ strerror (errno)); -+ exit (EXIT_FAILURE); -+ } ++ 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. + -+ return &buf[line_len]; -+ } -+ if (errno != 0) -+ { -+ fprintf (stderr, "fgets (\"%s\": %s\n", filename, strerror (errno)); -+ exit (EXIT_FAILURE); -+ } -+ fprintf (stderr, "\"%s\": No line \"%s\" found.\n", filename, line); -+ exit (EXIT_FAILURE); -+} ++ 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. */ + -+static unsigned long -+proc_ulong (const char *filename, const char *line) -+{ -+ const char *s = proc_string (filename, line); -+ long retval; -+ char *end; ++#include ++#include ++#include ++#include ++#include ++#include + -+ errno = 0; -+ retval = strtol (s, &end, 10); -+ if (retval < 0 || retval >= LONG_MAX || (end && *end)) -+ { -+ fprintf (stderr, "\"%s\":\"%s\": %ld, %s\n", filename, line, retval, -+ strerror (errno)); -+ exit (EXIT_FAILURE); -+ } -+ return retval; -+} ++#include ++#include ++#define gettid() syscall (__NR_gettid) ++ ++/* Non-atomic `var++' should not hurt as we synchronize the threads by the STEP ++ variable. Hit-comments need to be duplicite there to catch both at-stops ++ and behind-stops, depending on the target. */ ++ ++static volatile int var; + +static void -+state_wait (pid_t process, const char *wanted) ++dummy (void) +{ -+ char *filename; -+ int i; -+ struct timespec start, now; -+ const char *state; ++} + -+ i = asprintf (&filename, "/proc/%lu/status", (unsigned long) process); -+ assert (i > 0); ++static void ++breakpoint (void) ++{ ++} + -+ i = clock_gettime (CLOCK_MONOTONIC, &start); -+ assert (i == 0); ++/* Include here the functions: ++ static void forkoff (int nr); ++ static void delay (void); */ + -+ do -+ { -+ state = proc_string (filename, "State:\t"); -+ if (strcmp (state, wanted) == 0) -+ { -+ free (filename); -+ return; -+ } ++static pthread_t thread; ++static volatile int step; ++#define THREAD + -+ if (sched_yield ()) -+ { -+ perror ("sched_yield()"); -+ exit (EXIT_FAILURE); -+ } ++#include "watchpoint-fork-forkoff.c" + -+ i = clock_gettime (CLOCK_MONOTONIC, &now); -+ assert (i == 0); -+ assert (now.tv_sec >= start.tv_sec); -+ } -+ while (now.tv_sec - start.tv_sec < TIMEOUT); ++static void * ++start (void *arg) ++{ ++ if (step >= 3) ++ goto step_3; + -+ fprintf (stderr, "Timed out waiting for PID %lu \"%s\" (now it is \"%s\")!\n", -+ (unsigned long) process, wanted, state); -+ exit (EXIT_FAILURE); -+} ++ while (step != 1) ++ delay (); + -+static volatile pid_t tracer = 0; -+static pthread_t thread1, thread2; ++ var++; /* validity-thread-B */ ++ dummy (); /* validity-thread-B */ ++ step = 2; ++ while (step != 3) ++ { ++ if (step == 99) ++ goto step_99; ++ delay (); ++ } + -+static void -+cleanup (void) -+{ -+ printf ("Resuming GDB PID %lu.\n", (unsigned long) tracer); ++step_3: ++ if (step >= 5) ++ goto step_5; + -+ if (tracer) ++ var++; /* after-fork1-B */ ++ dummy (); /* after-fork1-B */ ++ step = 4; ++ while (step != 5) + { -+ int i; -+ int tracer_save = tracer; ++ if (step == 99) ++ goto step_99; ++ delay (); ++ } + -+ tracer = 0; ++step_5: ++ var++; /* after-fork2-B */ ++ dummy (); /* after-fork2-B */ ++ return (void *) 5UL; + -+ i = kill (tracer_save, SIGCONT); -+ assert (i == 0); -+ } ++step_99: ++ /* We must not get caught here (against a forgotten breakpoint). */ ++ var++; ++ breakpoint (); ++ return (void *) 99UL; +} + +int -+main (int argc, char **argv) ++main (void) +{ + int i; -+ int standalone = 0; -+ -+ if (argc == 2 && strcmp (argv[1], "-s") == 0) -+ standalone = 1; -+ else -+ assert (argc == 1); ++ void *thread_result; + + setbuf (stdout, NULL); ++ printf ("main: %d\n", (int) gettid ()); + -+ timed_mutex_lock (&gdbstop_mutex); -+ -+ timed_mutex_lock (&terminate_mutex); -+ -+ i = pthread_create (&thread1, NULL, thread1_func, NULL); -+ assert (i == 0); ++ /* General watchpoints validity. */ ++ var++; /* validity-first */ ++ dummy (); /* validity-first */ + -+ i = pthread_create (&thread2, NULL, thread2_func, NULL); ++ i = pthread_create (&thread, NULL, start, NULL); + assert (i == 0); + -+ if (!standalone) -+ { -+ tracer = proc_ulong ("/proc/self/status", "TracerPid:\t"); -+ if (tracer == 0) -+ { -+ fprintf (stderr, "The testcase must be run by GDB!\n"); -+ exit (EXIT_FAILURE); -+ } -+ if (tracer != getppid ()) -+ { -+ fprintf (stderr, "The testcase parent must be our GDB tracer!\n"); -+ exit (EXIT_FAILURE); -+ } -+ } -+ -+ /* SIGCONT our debugger in the case of our crash as we would deadlock -+ otherwise. */ -+ -+ atexit (cleanup); -+ -+ printf ("Stopping GDB PID %lu.\n", (unsigned long) tracer); -+ -+ if (tracer) -+ { -+ i = kill (tracer, SIGSTOP); -+ assert (i == 0); -+ state_wait (tracer, "T (stopped)"); -+ } ++ var++; /* validity-thread-A */ ++ dummy (); /* validity-thread-A */ ++ step = 1; ++ while (step != 2) ++ delay (); + -+ timed_mutex_lock (&thread1_tid_mutex); -+ timed_mutex_lock (&thread2_tid_mutex); ++ /* Hardware watchpoints got disarmed here. */ ++ forkoff (1); + -+ /* Let the threads start. */ -+ i = pthread_mutex_unlock (&gdbstop_mutex); ++ var++; /* after-fork1-A */ ++ dummy (); /* after-fork1-A */ ++ step = 3; ++#ifdef FOLLOW_CHILD ++ /* Spawn new thread as it was deleted in the child of FORK. */ ++ i = pthread_create (&thread, NULL, start, NULL); + assert (i == 0); ++#endif ++ while (step != 4) ++ delay (); + -+ printf ("Waiting till the threads initialize their TIDs.\n"); -+ -+ if (thread1_tid == 0) -+ { -+ i = pthread_cond_wait (&thread1_tid_cond, &thread1_tid_mutex); -+ assert (i == 0); ++ /* A sanity check for double hardware watchpoints removal. */ ++ forkoff (2); + -+ assert (thread1_tid > 0); -+ } ++ var++; /* after-fork2-A */ ++ dummy (); /* after-fork2-A */ ++ step = 5; ++#ifdef FOLLOW_CHILD ++ /* Spawn new thread as it was deleted in the child of FORK. */ ++ i = pthread_create (&thread, NULL, start, NULL); ++ assert (i == 0); ++#endif + -+ if (thread2_tid == 0) -+ { -+ i = pthread_cond_wait (&thread2_tid_cond, &thread2_tid_mutex); -+ assert (i == 0); ++ i = pthread_join (thread, &thread_result); ++ assert (i == 0); ++ assert (thread_result == (void *) 5UL); + -+ assert (thread2_tid > 0); -+ } ++ return 0; ++} +diff --git a/gdb/testsuite/gdb.threads/watchpoint-fork.c b/gdb/testsuite/gdb.threads/watchpoint-fork.c +new file mode 100644 +index 0000000..5f62e7f +--- /dev/null ++++ b/gdb/testsuite/gdb.threads/watchpoint-fork.c +@@ -0,0 +1,57 @@ ++/* Test case for forgotten hw-watchpoints after fork()-off of a process. + -+ printf ("Thread 1 TID = %lu, thread 2 TID = %lu, PID = %lu.\n", -+ (unsigned long) thread1_tid, (unsigned long) thread2_tid, -+ (unsigned long) getpid ()); ++ Copyright 2008, 2009 Free Software Foundation, Inc. + -+ printf ("Waiting till the threads get trapped by the watchpoints.\n"); ++ This file is part of GDB. + -+ if (tracer) -+ { -+ /* s390x-unknown-linux-gnu will fail with "R (running)". */ ++ 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. + -+ state_wait (thread1_tid, "T (tracing stop)"); ++ 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. + -+ state_wait (thread2_tid, "T (tracing stop)"); -+ } ++ 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. */ + -+ cleanup (); ++#include ++#include ++#include ++#include ++#include + -+ printf ("Joining the threads.\n"); ++static volatile int var; + -+ i = pthread_mutex_unlock (&terminate_mutex); -+ assert (i == 0); ++static void ++breakpoint (void) ++{ ++} + -+ i = pthread_join (thread1, NULL); -+ assert (i == 0); ++/* Include here the function: ++ static void forkoff (int nr); */ + -+ i = pthread_join (thread2, NULL); -+ assert (i == 0); ++#include "watchpoint-fork-forkoff.c" + -+ printf ("Exiting.\n"); /* break-at-exit */ ++int ++main (void) ++{ ++ setbuf (stdout, NULL); ++ printf ("main: %d\n", (int) getpid ()); + -+ /* Just prevent compiler `warning: $B!F(BunusedX_rwatch$B!G(B defined but not used'. */ -+ unused1_rwatch = 1; -+ unused2_rwatch = 2; ++ /* General watchpoints validity. */ ++ var++; ++ /* Hardware watchpoints got disarmed here. */ ++ forkoff (1); ++ /* This watchpoint got lost before. */ ++ var++; ++ /* A sanity check for double hardware watchpoints removal. */ ++ forkoff (2); ++ var++; + -+ return EXIT_SUCCESS; ++ return 0; +} -diff --git a/gdb/testsuite/gdb.threads/watchthreads-reorder.exp b/gdb/testsuite/gdb.threads/watchthreads-reorder.exp +diff --git a/gdb/testsuite/gdb.threads/watchpoint-fork.exp b/gdb/testsuite/gdb.threads/watchpoint-fork.exp new file mode 100644 -index 0000000..5ad1a4e +index 0000000..1dc93ab --- /dev/null -+++ b/gdb/testsuite/gdb.threads/watchthreads-reorder.exp -@@ -0,0 +1,105 @@ -+# This testcase is part of GDB, the GNU debugger. -+ -+# Copyright 2009 Free Software Foundation, Inc. ++++ b/gdb/testsuite/gdb.threads/watchpoint-fork.exp +@@ -0,0 +1,130 @@ ++# Copyright 2008, 2009 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 @@ -27588,117 +15300,123 @@ index 0000000..5ad1a4e +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + -+# Test GDB can cope with two watchpoints being hit by different threads at the -+# same time, GDB reports one of them and after "continue" to report the other -+# one GDB should not be confused by differently set watchpoints that time. -+# This is the goal of "reorder1". "reorder0" tests the basic functionality of -+# two watchpoint being hit at the same time, without reordering them during the -+# stop. The formerly broken functionality is due to the all-stop mode default -+# "show breakpoint always-inserted" being "off". Formerly the remembered hit -+# could be assigned during continuation of a thread with pending SIGTRAP to the -+# different/new watchpoint, just based on the watchpoint/debug register number. -+ -+if {[target_info exists gdb,no_hardware_watchpoints] -+ || ![istarget *-*-linux*]} { -+ return 0; -+} ++# Test case for forgotten hw-watchpoints after fork()-off of a process. + -+set testfile "watchthreads-reorder" -+set srcfile ${testfile}.c -+set binfile ${objdir}/${subdir}/${testfile} -+if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" ${binfile} executable [list debug additional_flags=-lrt]] != "" } { -+ return -1 -+} ++proc test {type symbol} { ++ global objdir subdir srcdir + -+foreach reorder {0 1} { ++ set test watchpoint-fork + + global pf_prefix + set prefix_test $pf_prefix -+ lappend pf_prefix "reorder$reorder:" ++ lappend pf_prefix "$type:" ++ set prefix_mt $pf_prefix + -+ clean_restart $testfile ++ # no threads + -+ gdb_test "set can-use-hw-watchpoints 1" ++ set pf_prefix $prefix_mt ++ lappend pf_prefix "singlethreaded:" + -+ if ![runto_main] { -+ gdb_suppress_tests ++ set executable ${test}-${type} ++ if { [gdb_compile ${srcdir}/${subdir}/${test}.c ${objdir}/${subdir}/${executable} executable [list debug additional_flags=-D$symbol]] != "" } { ++ untested ${test}.exp ++ return -1 + } ++ clean_restart $executable + -+ # Use "rwatch" as "watch" would report the watchpoint changed just based on its -+ # read memory value during a stop by unrelated event. We are interested to not -+ # to lose the hardware watchpoint trigger. -+ -+ gdb_test "rwatch thread1_rwatch" "Hardware read watchpoint \[0-9\]+: thread1_rwatch" -+ gdb_test {set $rwatch1=$bpnum} -+ set test "rwatch thread2_rwatch" -+ gdb_test_multiple $test $test { -+ -re "Target does not support this type of hardware watchpoint\\.\r\n$gdb_prompt $" { -+ # ppc64 supports at most 1 hw watchpoints. -+ unsupported $test -+ return -+ } -+ -re "Hardware read watchpoint \[0-9\]+: thread2_rwatch\r\n$gdb_prompt $" { -+ pass $test -+ } ++ gdb_test "show detach-on-fork" "Whether gdb will detach the child of a fork is on." ++ gdb_test "set follow-fork-mode $type" ++ gdb_test "show follow-fork-mode" "Debugger response to a program call of fork or vfork is \"$type\"." ++ # Testcase uses it for the `follow-fork-mode child' type. ++ gdb_test "handle SIGUSR1 nostop noprint pass" ++ ++ if { ![runto_main] } then { ++ gdb_suppress_tests ++ return + } -+ gdb_test {set $rwatch2=$bpnum} -+ gdb_breakpoint [gdb_get_line_number "break-at-exit"] + -+ # The watchpoints can happen in arbitrary order depending on random: -+ # SEL: Found 2 SIGTRAP events, selecting #[01] -+ # As GDB contains no srand() on the specific host/OS it will behave always the -+ # same. Such order cannot be guaranteed for GDB in general. ++ # Install the watchpoint only after getting into MAIN - workaround some PPC ++ # problem. ++ gdb_test "watch var" "atchpoint 2: var" "Set the watchpoint" ++ ++ # It is never hit but it should not be left over in the fork()ed-off child. ++ gdb_breakpoint "breakpoint" + + gdb_test "continue" \ -+ "Hardware read watchpoint \[0-9\]+: thread\[12\]_rwatch\r\n\r\nValue = 0\r\n0x\[0-9a-f\]+ in thread\[12\]_func .*" \ -+ "continue a" ++ "atchpoint 2: var.*Old value = 0.*New value = 1.*forkoff *\\(1\\).*" "watchpoints work" ++ gdb_test "continue" \ ++ "reakpoint 3, breakpoint.*" "breakpoint after the first fork" ++ gdb_test "continue" \ ++ "atchpoint 2: var.*Old value = 1.*New value = 2.*forkoff *\\(2\\).*" "watchpoint after the first fork" ++ gdb_test "continue" \ ++ "reakpoint 3, breakpoint.*" "breakpoint after the second fork" ++ gdb_test "continue" \ ++ "atchpoint 2: var.*Old value = 2.*New value = 3.*return *0;" "watchpoint after the second fork" ++ gdb_test "continue" "Continuing..*Program exited normally." "finish" ++ ++ ++ # threads ++ ++ set pf_prefix $prefix_mt ++ lappend pf_prefix "multithreaded:" + -+ if $reorder { -+ gdb_test {delete $rwatch1} -+ gdb_test {delete $rwatch2} ++ set executable ${test}-mt-${type} ++ if { [gdb_compile_pthreads ${srcdir}/${subdir}/${test}-mt.c ${objdir}/${subdir}/${executable} executable [list debug additional_flags=-D$symbol]] != "" } { ++ untested ${test}.exp ++ return -1 ++ } ++ clean_restart $executable + -+ gdb_test "rwatch unused1_rwatch" "Hardware read watchpoint \[0-9\]+: unused1_rwatch" -+ gdb_test "rwatch unused2_rwatch" "Hardware read watchpoint \[0-9\]+: unused2_rwatch" ++ gdb_test "set follow-fork-mode $type" ++ # Testcase uses it for the `follow-fork-mode child' type. ++ gdb_test "handle SIGUSR1 nostop noprint pass" + -+ gdb_test "rwatch thread1_rwatch" "Hardware read watchpoint \[0-9\]+: thread1_rwatch" -+ gdb_test "rwatch thread2_rwatch" "Hardware read watchpoint \[0-9\]+: thread2_rwatch" ++ if { ![runto_main] } then { ++ gdb_suppress_tests ++ return + } + ++ # Install the watchpoint only after getting into MAIN - workaround some PPC ++ # problem. ++ gdb_test "watch var" "atchpoint 2: var" "Set the watchpoint" ++ ++ # It is never hit but it should not be left over in the fork()ed-off child. ++ gdb_breakpoint "breakpoint" ++ ++ gdb_test "continue" \ ++ "atchpoint 2: var.*Old value = 0.*New value = 1.*validity-first.*" "singlethread watchpoints work" ++ gdb_test "continue" \ ++ "atchpoint 2: var.*Old value = 1.*New value = 2.*validity-thread-A.*" "multithreaded watchpoints work at A" ++ gdb_test "continue" \ ++ "atchpoint 2: var.*Old value = 2.*New value = 3.*validity-thread-B.*" "multithreaded watchpoints work at B" ++ gdb_test "continue" \ ++ "reakpoint 3, breakpoint.*" "breakpoint (A) after the first fork" ++ gdb_test "continue" \ ++ "atchpoint 2: var.*Old value = 3.*New value = 4.*after-fork1-A.*" "watchpoint A after the first fork" ++ gdb_test "continue" \ ++ "atchpoint 2: var.*Old value = 4.*New value = 5.*after-fork1-B.*" "watchpoint B after the first fork" ++ gdb_test "continue" \ ++ "reakpoint 3, breakpoint.*" "breakpoint (A) after the second fork" ++ gdb_test "continue" \ ++ "atchpoint 2: var.*Old value = 5.*New value = 6.*after-fork2-A.*" "watchpoint A after the second fork" + gdb_test "continue" \ -+ "Hardware read watchpoint \[0-9\]+: thread\[12\]_rwatch\r\n\r\nValue = 0\r\n0x\[0-9a-f\]+ in thread\[12\]_func .*" \ -+ "continue b" ++ "atchpoint 2: var.*Old value = 6.*New value = 7.*after-fork2-B.*" "watchpoint B after the second fork" ++ gdb_test "continue" "Continuing..*Program exited normally." "finish" + -+ # While the debug output itself is not checked in this testcase one bug was -+ # found in the DEBUG_INFRUN code path. -+ gdb_test "set debug infrun 1" + -+ gdb_continue_to_breakpoint "break-at-exit" ".*break-at-exit.*" ++ # cleanup + + set pf_prefix $prefix_test +} -diff --git a/gdb/testsuite/lib/cp-support.exp b/gdb/testsuite/lib/cp-support.exp -index dbd2f59..44e1b51 100644 ---- a/gdb/testsuite/lib/cp-support.exp -+++ b/gdb/testsuite/lib/cp-support.exp -@@ -222,7 +222,7 @@ proc cp_test_ptype_class { in_command in_testname in_key in_tag in_class_table { - - set parse_okay 0 - gdb_test_multiple "$in_command" "$in_testname // parse failed" { -- -re "type = (struct|class)${wsopt}(\[A-Za-z0-9_\]*)${wsopt}((:\[^\{\]*)?)${wsopt}\{(.*)\}${wsopt}(\[^\r\n\]*)\[\r\n\]+$gdb_prompt $" { -+ -re "type = (struct|class)${wsopt}(\[A-Za-z0-9_:\]*)${wsopt}((:\[^\{\]*)?)${wsopt}\{(.*)\}${wsopt}(\[^\r\n\]*)\[\r\n\]+$gdb_prompt $" { - set parse_okay 1 - set actual_key $expect_out(1,string) - set actual_tag $expect_out(2,string) -@@ -231,6 +231,7 @@ proc cp_test_ptype_class { in_command in_testname in_key in_tag in_class_table { - set actual_tail $expect_out(6,string) - } - } -+ - if { ! $parse_okay } then { return } - - # Check the actual key. It would be nice to require that it match ++ ++test parent FOLLOW_PARENT ++ ++# Only GNU/Linux is known to support `set follow-fork-mode child'. ++if {[istarget "*-*-linux*"]} { ++ test child FOLLOW_CHILD ++} diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp -index 0c93a73..d0c3493 100644 +index 20e2fb7..b27d25c 100644 --- a/gdb/testsuite/lib/gdb.exp +++ b/gdb/testsuite/lib/gdb.exp @@ -27,6 +27,7 @@ if {$tool == ""} { @@ -27709,6 +15427,41 @@ index 0c93a73..d0c3493 100644 global GDB +diff --git a/gdb/testsuite/lib/pascal.exp b/gdb/testsuite/lib/pascal.exp +index 9691bc1..13ea8b5 100644 +--- a/gdb/testsuite/lib/pascal.exp ++++ b/gdb/testsuite/lib/pascal.exp +@@ -37,6 +37,9 @@ proc pascal_init {} { + global pascal_compiler_is_fpc + global gpc_compiler + global fpc_compiler ++ global fpcversion_major ++ global fpcversion_minor ++ global fpcversion_release + global env + + if { $pascal_init_done == 1 } { +@@ -64,6 +67,20 @@ proc pascal_init {} { + set pascal_compiler_is_fpc 1 + verbose -log "Free Pascal compiler found" + } ++ ++ # Detect the fpc-version ++ if { $pascal_compiler_is_fpc == 1 } { ++ set fpcversion_major 1 ++ set fpcversion_minor 0 ++ set fpcversion_release 0 ++ set fpcversion [ remote_exec host $fpc_compiler "-iV" ] ++ if [regexp {.*([0-9]+)\.([0-9]+)\.([0-9]+).?} $fpcversion] { ++ regsub {.*([0-9]+)\.([0-9]+)\.([0-9]+).?\n?.?} $fpcversion {\1} fpcversion_major ++ regsub {.*([0-9]+)\.([0-9]+)\.([0-9]+).?\n?.?} $fpcversion {\2} fpcversion_minor ++ regsub {.*([0-9]+)\.([0-9]+)\.([0-9]+).?\n?.?} $fpcversion {\3} fpcversion_release ++ } ++ verbose -log "Freepascal version: $fpcversion_major.$fpcversion_minor.$fpcversion_release" ++ } + } + set pascal_init_done 1 + } diff --git a/gdb/testsuite/lib/python-support.exp b/gdb/testsuite/lib/python-support.exp new file mode 100644 index 0000000..b8e9836 @@ -27769,51 +15522,44 @@ index 0000000..b8e9836 + return 0 +} diff --git a/gdb/thread.c b/gdb/thread.c -index 55b4b96..e0ad2d3 100644 +index 0b291ba..ae3e4ff 100644 --- a/gdb/thread.c +++ b/gdb/thread.c -@@ -61,7 +61,6 @@ static int thread_alive (struct thread_info *); - static void info_threads_command (char *, int); - static void thread_apply_command (char *, int); - static void restore_current_thread (ptid_t); --static void prune_threads (void); - - /* Frontend view of the thread state. Possible extensions: stepping, - finishing, until(ling),... */ -@@ -497,16 +496,23 @@ thread_alive (struct thread_info *tp) - return 1; +@@ -90,6 +90,16 @@ delete_step_resume_breakpoint (struct thread_info *tp) + } } --static void +void - prune_threads (void) ++delete_exception_resume_breakpoint (struct thread_info *tp) ++{ ++ if (tp && tp->exception_resume_breakpoint) ++ { ++ delete_breakpoint (tp->exception_resume_breakpoint); ++ tp->exception_resume_breakpoint = NULL; ++ } ++} ++ + static void + clear_thread_inferior_resources (struct thread_info *tp) { -- struct thread_info *tp, *next; -+ struct thread_info *tp; -+ struct thread_info **prevp = &thread_list; - -- for (tp = thread_list; tp; tp = next) -+ for (tp = *prevp; tp; tp = *prevp) - { -- next = tp->next; -+ /* If the thread has died, free it and unlink it from the list. -+ Otherwise, advance to the next thread. */ - if (!thread_alive (tp)) -- delete_thread (tp->ptid); -+ { -+ *prevp = tp->next; -+ free_thread (tp); -+ } -+ else -+ prevp = &tp->next; +@@ -103,6 +113,12 @@ clear_thread_inferior_resources (struct thread_info *tp) + tp->step_resume_breakpoint = NULL; } - } ++ if (tp->exception_resume_breakpoint) ++ { ++ tp->exception_resume_breakpoint->disposition = disp_del_at_next_stop; ++ tp->exception_resume_breakpoint = NULL; ++ } ++ + bpstat_clear (&tp->stop_bpstat); + + discard_all_intermediate_continuations_thread (tp); diff --git a/gdb/top.c b/gdb/top.c -index 1b4aa9d..3cfe57e 100644 +index b29e68d..8edac70 100644 --- a/gdb/top.c +++ b/gdb/top.c -@@ -349,6 +349,7 @@ void +@@ -337,6 +337,7 @@ void prepare_execute_command (void) { free_all_values (); @@ -27822,19 +15568,18 @@ index 1b4aa9d..3cfe57e 100644 /* With multiple threads running while the one we're examining is stopped, the dcache can get stale without us being able to detect it. diff --git a/gdb/typeprint.c b/gdb/typeprint.c -index f090231..fc15ec1 100644 +index ce9f551..5f9d739 100644 --- a/gdb/typeprint.c +++ b/gdb/typeprint.c -@@ -35,6 +35,8 @@ +@@ -36,6 +36,7 @@ #include "gdb_string.h" #include "exceptions.h" #include "valprint.h" +#include "dwarf2loc.h" -+ #include extern void _initialize_typeprint (void); -@@ -76,6 +78,9 @@ void +@@ -77,6 +78,9 @@ void type_print (struct type *type, char *varstring, struct ui_file *stream, int show) { @@ -27844,7 +15589,7 @@ index f090231..fc15ec1 100644 LA_PRINT_TYPE (type, varstring, stream, show, 0); } -@@ -114,7 +119,8 @@ whatis_exp (char *exp, int show) +@@ -115,7 +119,8 @@ whatis_exp (char *exp, int show) { struct expression *expr; struct value *val; @@ -27854,7 +15599,7 @@ index f090231..fc15ec1 100644 struct type *real_type = NULL; struct type *type; int full = 0; -@@ -125,12 +131,13 @@ whatis_exp (char *exp, int show) +@@ -126,12 +131,13 @@ whatis_exp (char *exp, int show) if (exp) { expr = parse_expression (exp); @@ -27869,7 +15614,7 @@ index f090231..fc15ec1 100644 type = value_type (val); get_user_print_options (&opts); -@@ -167,8 +174,7 @@ whatis_exp (char *exp, int show) +@@ -168,8 +174,7 @@ whatis_exp (char *exp, int show) type_print (type, "", gdb_stdout, show); printf_filtered ("\n"); @@ -27879,133 +15624,13 @@ index f090231..fc15ec1 100644 } static void -diff --git a/gdb/typeprint.h b/gdb/typeprint.h -index f561310..d261c79 100644 ---- a/gdb/typeprint.h -+++ b/gdb/typeprint.h -@@ -20,10 +20,13 @@ - #ifndef TYPEPRINT_H - #define TYPEPRINT_H - -+enum language; - struct ui_file; - - void print_type_scalar (struct type * type, LONGEST, struct ui_file *); - - void c_type_print_varspec_suffix (struct type *, struct ui_file *, int, - int, int); -+ -+void c_type_print_args (struct type *, struct ui_file *, int, enum language); - #endif -diff --git a/gdb/ui-file.c b/gdb/ui-file.c -index 527917c..07d959a 100644 ---- a/gdb/ui-file.c -+++ b/gdb/ui-file.c -@@ -22,6 +22,7 @@ - - #include "defs.h" - #include "ui-file.h" -+#include "gdb_obstack.h" - #include "gdb_string.h" - - #include -@@ -263,7 +264,7 @@ set_ui_file_data (struct ui_file *file, void *data, - } - - /* ui_file utility function for converting a ``struct ui_file'' into -- a memory buffer''. */ -+ a memory buffer. */ - - struct accumulated_ui_file - { -@@ -297,6 +298,23 @@ ui_file_xstrdup (struct ui_file *file, long *length) - *length = acc.length; - return acc.buffer; - } -+ -+static void -+do_ui_file_obsavestring (void *context, const char *buffer, long length) -+{ -+ struct obstack *obstack = (struct obstack *) context; -+ obstack_grow (obstack, buffer, length); -+} -+ -+char * -+ui_file_obsavestring (struct ui_file *file, struct obstack *obstack, -+ long *length) -+{ -+ ui_file_put (file, do_ui_file_obsavestring, obstack); -+ *length = obstack_object_size (obstack); -+ obstack_1grow (obstack, '\0'); -+ return obstack_finish (obstack); -+} - - /* A pure memory based ``struct ui_file'' that can be used an output - buffer. The buffers accumulated contents are available via -diff --git a/gdb/ui-file.h b/gdb/ui-file.h -index bf9915c..233206c 100644 ---- a/gdb/ui-file.h -+++ b/gdb/ui-file.h -@@ -19,6 +19,7 @@ - #ifndef UI_FILE_H - #define UI_FILE_H - -+struct obstack; - struct ui_file; - - /* Create a generic ui_file object with null methods. */ -@@ -77,7 +78,10 @@ extern void ui_file_put (struct ui_file *src, ui_file_put_method_ftype *write, v - minus that appended NUL. */ - extern char *ui_file_xstrdup (struct ui_file *file, long *length); - -- -+/* Similar to ui_file_xstrdup, but return a new string allocated on -+ OBSTACK. */ -+extern char *ui_file_obsavestring (struct ui_file *file, -+ struct obstack *obstack, long *length); - - extern long ui_file_read (struct ui_file *file, char *buf, long length_buf); - -diff --git a/gdb/utils.c b/gdb/utils.c -index 16ad084..3021a43 100644 ---- a/gdb/utils.c -+++ b/gdb/utils.c -@@ -2610,7 +2610,10 @@ fprintf_symbol_filtered (struct ui_file *stream, char *name, - As an extra hack, string1=="FOO(ARGS)" matches string2=="FOO". - This "feature" is useful when searching for matching C++ function names - (such as if the user types 'break FOO', where FOO is a mangled C++ -- function). */ -+ function). -+ -+ As an extra-special hack, we do the same with ' ', so that -+ "FOO(ARGS) const" can match "FOO", too. */ - - int - strcmp_iw (const char *string1, const char *string2) -@@ -2635,7 +2638,7 @@ strcmp_iw (const char *string1, const char *string2) - string2++; - } - } -- return (*string1 != '\0' && *string1 != '(') || (*string2 != '\0'); -+ return (*string1 != ' ' && *string1 != '\0' && *string1 != '(') || (*string2 != '\0' && *string2 != '('); - } - - /* This is like strcmp except that it ignores whitespace and treats diff --git a/gdb/valarith.c b/gdb/valarith.c -index a9c875d..12f6f07 100644 +index 0c40905..a781636 100644 --- a/gdb/valarith.c +++ b/gdb/valarith.c -@@ -139,7 +139,6 @@ an integer nor a pointer of the same type.")); - struct value * - value_subscript (struct value *array, LONGEST index) - { -- struct value *bound; - int c_style = current_language->c_style_arrays; - struct type *tarray; +@@ -161,12 +161,26 @@ value_subscript (struct value *array, LONGEST index) -@@ -154,12 +153,26 @@ value_subscript (struct value *array, LONGEST index) get_discrete_bounds (range_type, &lowerbound, &upperbound); - if (VALUE_LVAL (array) != lval_memory) - return value_subscripted_rvalue (array, index, lowerbound); + { @@ -28032,7 +15657,7 @@ index a9c875d..12f6f07 100644 /* Emit warning unless we have an array of unknown size. An array of unknown size has lowerbound 0 and upperbound -1. */ if (upperbound > -1) -@@ -178,33 +191,37 @@ value_subscript (struct value *array, LONGEST index) +@@ -185,34 +199,37 @@ value_subscript (struct value *array, LONGEST index) error (_("not an array or string")); } @@ -28055,7 +15680,8 @@ index a9c875d..12f6f07 100644 - unsigned int elt_offs = elt_size * longest_to_int (index - lowerbound); struct value *v; -- if (index < lowerbound || elt_offs >= TYPE_LENGTH (array_type)) +- if (index < lowerbound || (!TYPE_ARRAY_UPPER_BOUND_IS_UNDEFINED (array_type) +- && elt_offs >= TYPE_LENGTH (array_type))) - error (_("no such vector element")); + /* Do not check TYPE_LENGTH (array_type) as we may have been given the + innermost dimension of a multi-dimensional Fortran array where its length @@ -28081,8 +15707,19 @@ index a9c875d..12f6f07 100644 return v; } +@@ -292,6 +309,10 @@ int + binop_user_defined_p (enum exp_opcode op, + struct value *arg1, struct value *arg2) + { ++ /* FIXME: We should support user defined ops for dynamic types. */ ++ if (TYPE_DYNAMIC (value_type (arg1)) || TYPE_DYNAMIC (value_type (arg2))) ++ return 0; ++ + return binop_types_user_defined_p (op, value_type (arg1), value_type (arg2)); + } + diff --git a/gdb/valops.c b/gdb/valops.c -index 012ea6a..9b4d2a8 100644 +index 7fbad10..8e32405 100644 --- a/gdb/valops.c +++ b/gdb/valops.c @@ -38,6 +38,7 @@ @@ -28093,16 +15730,7 @@ index 012ea6a..9b4d2a8 100644 #include #include "gdb_string.h" -@@ -369,8 +370,6 @@ value_cast (struct type *type, struct value *arg2) - new_length = val_length / element_length; - if (val_length % element_length != 0) - warning (_("array element type size does not divide object size in cast")); -- /* FIXME-type-allocation: need a way to free this type when -- we are done with it. */ - range_type = create_range_type ((struct type *) NULL, - TYPE_TARGET_TYPE (range_type), - low_bound, -@@ -565,6 +564,64 @@ value_one (struct type *type, enum lval_type lv) +@@ -858,6 +859,65 @@ value_one (struct type *type, enum lval_type lv) return val; } @@ -28130,14 +15758,15 @@ index 012ea6a..9b4d2a8 100644 + return NULL; +} + -+/* Return non-zero if the variable is valid. If it is valid the function -+ may store the data address (DW_AT_DATA_LOCATION) of TYPE at *ADDRESS_RETURN. -+ You must set *ADDRESS_RETURN from value_raw_address (VAL) before calling this -+ function. If no DW_AT_DATA_LOCATION is present for TYPE the address at -+ *ADDRESS_RETURN is left unchanged. ADDRESS_RETURN must not be NULL, use ++/* Return non-NULL check_typedef result on TYPE if the variable is valid. If ++ it is valid the function may store the data address (DW_AT_DATA_LOCATION) of ++ TYPE at *ADDRESS_RETURN. You must set *ADDRESS_RETURN from ++ value_raw_address (VAL) before calling this function. If no ++ DW_AT_DATA_LOCATION is present for TYPE the address at *ADDRESS_RETURN is ++ left unchanged. ADDRESS_RETURN must not be NULL, use + object_address_data_not_valid () for just the data validity check. */ + -+int ++struct type * +object_address_get_data (struct type *type, CORE_ADDR *address_return) +{ + gdb_assert (address_return != NULL); @@ -28152,7 +15781,7 @@ index 012ea6a..9b4d2a8 100644 + { + /* Do not try to evaluate DW_AT_data_location as it may even crash + (it would just return the value zero in the gfortran case). */ -+ return 0; ++ return NULL; + } + + if (TYPE_DATA_LOCATION_IS_ADDR (type)) @@ -28161,13 +15790,13 @@ index 012ea6a..9b4d2a8 100644 + *address_return + = dwarf_locexpr_baton_eval (TYPE_DATA_LOCATION_DWARF_BLOCK (type)); + -+ return 1; ++ return type; +} + /* Helper function for value_at, value_at_lazy, and value_at_lazy_stack. */ static struct value * -@@ -656,15 +713,21 @@ value_fetch_lazy (struct value *val) +@@ -956,15 +1016,21 @@ value_fetch_lazy (struct value *val) } else if (VALUE_LVAL (val) == lval_memory) { @@ -28196,7 +15825,7 @@ index 012ea6a..9b4d2a8 100644 } } else if (VALUE_LVAL (val) == lval_register) -@@ -1072,7 +1135,18 @@ address_of_variable (struct symbol *var, struct block *b) +@@ -1374,7 +1440,18 @@ address_of_variable (struct symbol *var, struct block *b) if ((VALUE_LVAL (val) == lval_memory && value_lazy (val)) || TYPE_CODE (type) == TYPE_CODE_FUNC) { @@ -28213,10 +15842,10 @@ index 012ea6a..9b4d2a8 100644 + } + + addr = value_address (val); + return value_from_pointer (lookup_pointer_type (type), addr); } - -@@ -1178,6 +1252,7 @@ struct value * +@@ -1481,6 +1558,7 @@ struct value * value_coerce_array (struct value *arg1) { struct type *type = check_typedef (value_type (arg1)); @@ -28224,7 +15853,7 @@ index 012ea6a..9b4d2a8 100644 /* If the user tries to do something requiring a pointer with an array that has not yet been pushed to the target, then this would -@@ -1187,8 +1262,12 @@ value_coerce_array (struct value *arg1) +@@ -1490,8 +1568,12 @@ value_coerce_array (struct value *arg1) if (VALUE_LVAL (arg1) != lval_memory) error (_("Attempt to take address of value not located in memory.")); @@ -28238,362 +15867,131 @@ index 012ea6a..9b4d2a8 100644 } /* Given a value which is a function, return a value which is a pointer -@@ -2071,12 +2150,25 @@ find_overload_match (struct type **arg_types, int nargs, - if (method) - { - gdb_assert (obj); -+ -+ /* OBJ may be a pointer value rather than the object itself. */ -+ obj = coerce_ref (obj); -+ while (TYPE_CODE (check_typedef (value_type (obj))) == TYPE_CODE_PTR) -+ obj = coerce_ref (value_ind (obj)); - obj_type_name = TYPE_NAME (value_type (obj)); -- /* Hack: evaluate_subexp_standard often passes in a pointer -- value rather than the object itself, so try again. */ -- if ((!obj_type_name || !*obj_type_name) -- && (TYPE_CODE (value_type (obj)) == TYPE_CODE_PTR)) -- obj_type_name = TYPE_NAME (TYPE_TARGET_TYPE (value_type (obj))); -+ -+ /* First check whether this is a data member, e.g. a pointer to -+ a function. */ -+ if (TYPE_CODE (check_typedef (value_type (obj))) == TYPE_CODE_STRUCT) -+ { -+ *valp = search_struct_field (name, obj, 0, -+ check_typedef (value_type (obj)), 0); -+ if (*valp) -+ { -+ *staticp = 1; -+ return 0; -+ } -+ } - - fns_ptr = value_find_oload_method_list (&temp, name, - 0, &num_fns, -@@ -2096,16 +2188,29 @@ find_overload_match (struct type **arg_types, int nargs, - } - else - { -- const char *qualified_name = SYMBOL_CPLUS_DEMANGLED_NAME (fsym); -+ const char *qualified_name = SYMBOL_NATURAL_NAME (fsym); -+ -+ /* If we have a function with a C++ name, try to extract just -+ the function part. Do not try this for non-functions (e.g. -+ function pointers). */ -+ if (qualified_name -+ && TYPE_CODE (check_typedef (SYMBOL_TYPE (fsym))) == TYPE_CODE_FUNC) -+ { -+ func_name = cp_func_name (qualified_name); - -- /* If we have a C++ name, try to extract just the function -- part. */ -- if (qualified_name) -- func_name = cp_func_name (qualified_name); -+ /* If cp_func_name did not remove anything, the name of the -+ symbol did not include scope or argument types - it was -+ probably a C-style function. */ -+ if (func_name && strcmp (func_name, qualified_name) == 0) -+ { -+ xfree (func_name); -+ func_name = NULL; -+ } -+ } +diff --git a/gdb/valprint.c b/gdb/valprint.c +index ad6268e..fb0ef7a 100644 +--- a/gdb/valprint.c ++++ b/gdb/valprint.c +@@ -36,6 +36,7 @@ + #include "dfp.h" + #include "python/python.h" + #include "ada-lang.h" ++#include "dwarf2loc.h" -- /* If there was no C++ name, this must be a C-style function. -- Just return the same symbol. Do the same if cp_func_name -- fails for some reason. */ -+ /* If there was no C++ name, this must be a C-style function or -+ not a function at all. Just return the same symbol. Do the -+ same if cp_func_name fails for some reason. */ - if (func_name == NULL) - { - *symp = fsym; -@@ -2536,8 +2641,8 @@ check_field (struct type *type, const char *name) - the comment before value_struct_elt_for_reference. */ + #include - struct value * --value_aggregate_elt (struct type *curtype, -- char *name, int want_address, -+value_aggregate_elt (struct type *curtype, char *name, -+ struct type *expect_type, int want_address, - enum noside noside) - { - switch (TYPE_CODE (curtype)) -@@ -2545,7 +2650,7 @@ value_aggregate_elt (struct type *curtype, +@@ -237,7 +238,6 @@ scalar_type_p (struct type *type) case TYPE_CODE_STRUCT: case TYPE_CODE_UNION: - return value_struct_elt_for_reference (curtype, 0, curtype, -- name, NULL, -+ name, expect_type, - want_address, noside); - case TYPE_CODE_NAMESPACE: - return value_namespace_elt (curtype, name, -@@ -2556,6 +2661,56 @@ value_aggregate_elt (struct type *curtype, - } - } - -+/* Compares the two method/function types T1 and T2 for "equality" -+ with respect to the the methods' parameters. If the types of the -+ two parameter lists are the same, returns 1; 0 otherwise. This -+ comparison may ignore any artificial parameters in T1 if -+ SKIP_ARTIFICIAL is non-zero. This function will ALWAYS skip -+ the first artificial parameter in T1, assumed to be a 'this' pointer. -+ -+ The type T2 is expected to have come from make_params (in eval.c). */ -+static int -+compare_parameters (struct type *t1, struct type *t2, int skip_artificial) -+{ -+ int start = 0; -+ -+ if (TYPE_FIELD_ARTIFICIAL (t1, 0)) -+ ++start; -+ -+ /* If skipping artificial fields, find the first real field -+ in T1. */ -+ if (skip_artificial) + case TYPE_CODE_SET: +- case TYPE_CODE_STRING: + case TYPE_CODE_BITSTRING: + return 0; + default: +@@ -1142,6 +1142,7 @@ val_print_array_elements (struct type *type, const gdb_byte *valaddr, + { + unsigned int things_printed = 0; + unsigned len; ++ struct type *saved_type = type; + struct type *elttype, *index_type; + unsigned eltlen; + /* Position of the array element we are examining to see +@@ -1150,9 +1151,33 @@ val_print_array_elements (struct type *type, const gdb_byte *valaddr, + /* Number of repetitions we have detected so far. */ + unsigned int reps; + LONGEST low_bound_index = 0; ++ struct cleanup *back_to; ++ CORE_ADDR saved_address = address; ++ ++ back_to = make_cleanup (null_cleanup, 0); ++ type = object_address_get_data (type, &address); ++ if (!type) + { -+ while (start < TYPE_NFIELDS (t1) -+ && TYPE_FIELD_ARTIFICIAL (t1, start)) -+ ++start; ++ fputs_filtered (object_address_data_not_valid (type), stream); ++ do_cleanups (back_to); ++ return; + } -+ -+ /* Now compare parameters */ -+ -+ /* Special case: a method taking void. T1 will contain no -+ non-artificial fields, and T2 will contain TYPE_CODE_VOID. */ -+ if ((TYPE_NFIELDS (t1) - start) == 0 && TYPE_NFIELDS (t2) == 1 -+ && TYPE_CODE (TYPE_FIELD_TYPE (t2, 0)) == TYPE_CODE_VOID) -+ return 1; -+ -+ if ((TYPE_NFIELDS (t1) - start) == TYPE_NFIELDS (t2)) ++ if (address != saved_address) + { -+ int i; -+ for (i = 0; i < TYPE_NFIELDS (t2); ++i) -+ { -+ if (rank_one_type (TYPE_FIELD_TYPE (t1, start + i), -+ TYPE_FIELD_TYPE (t2, i)) -+ != 0) -+ return 0; -+ } -+ -+ return 1; -+ } -+ -+ return 0; -+} -+ - /* C++: Given an aggregate type CURTYPE, and a member name NAME, - return the address of this member as a "pointer to member" type. - If INTYPE is non-null, then it will be the type of the member we -@@ -2633,23 +2788,46 @@ value_struct_elt_for_reference (struct type *domain, int offset, - } - if (t_field_name && strcmp (t_field_name, name) == 0) - { -- int j = TYPE_FN_FIELDLIST_LENGTH (t, i); -+ int j; -+ int len = TYPE_FN_FIELDLIST_LENGTH (t, i); - struct fn_field *f = TYPE_FN_FIELDLIST1 (t, i); - - check_stub_method_group (t, i); ++ size_t length = TYPE_LENGTH (type); -- if (intype == 0 && j > 1) -- error (_("non-unique member `%s' requires type instantiation"), name); - if (intype) - { -- while (j--) -- if (TYPE_FN_FIELD_TYPE (f, j) == intype) -- break; -- if (j < 0) -- error (_("no member function matches that type instantiation")); -- } -+ for (j = 0; j < len; ++j) -+ { -+ if (compare_parameters (TYPE_FN_FIELD_TYPE (f, j), intype, 0) -+ || compare_parameters (TYPE_FN_FIELD_TYPE (f, j), intype, 1)) -+ break; -+ } -+ -+ if (j == len) -+ error (_("no member function matches that type instantiation")); } - else -- j = 0; -+ { -+ int ii; -+ /* Skip artificial methods. This is necessary if, for example, -+ the user wants to "print subclass::subclass" with only -+ one defined user constructor. There is no ambiguity in this -+ case. */ -+ for (ii = 0; ii < TYPE_FN_FIELDLIST_LENGTH (t, i); -+ ++ii) -+ { -+ if (TYPE_FN_FIELD_ARTIFICIAL (f, ii)) -+ --len; -+ } +- elttype = TYPE_TARGET_TYPE (type); +- eltlen = TYPE_LENGTH (check_typedef (elttype)); ++ valaddr = xmalloc (length); ++ make_cleanup (xfree, (gdb_byte *) valaddr); ++ read_memory (address, (gdb_byte *) valaddr, length); ++ } + -+ /* Desired method is ambiguous if more than one method is -+ defined. */ -+ if (len > 1) -+ error (_("non-unique member `%s' requires type instantiation"), name); ++ /* Skip typedefs but do not resolve TYPE_DYNAMIC. */ ++ elttype = saved_type; ++ while (TYPE_CODE (elttype) == TYPE_CODE_TYPEDEF) ++ elttype = TYPE_TARGET_TYPE (elttype); ++ elttype = TYPE_TARGET_TYPE (elttype); + -+ /* This assumes, of course, that all artificial methods appear -+ BEFORE any concrete methods. */ -+ j = TYPE_FN_FIELDLIST_LENGTH (t, i) - 1; -+ } ++ eltlen = TYPE_ARRAY_BYTE_STRIDE_VALUE (type); + index_type = TYPE_INDEX_TYPE (type); - if (TYPE_FN_FIELD_STATIC_P (f, j)) - { -@@ -2763,7 +2941,7 @@ value_maybe_namespace_elt (const struct type *curtype, - struct symbol *sym; - struct value *result; - -- sym = cp_lookup_symbol_namespace (namespace_name, name, NULL, -+ sym = cp_lookup_symbol_namespace(namespace_name, name, - get_selected_block (0), - VAR_DOMAIN); - -@@ -2907,7 +3085,7 @@ value_of_local (const char *name, int complain) - - /* Calling lookup_block_symbol is necessary to get the LOC_REGISTER - symbol instead of the LOC_ARG one (if both exist). */ -- sym = lookup_block_symbol (b, name, NULL, VAR_DOMAIN); -+ sym = lookup_block_symbol (b, name, VAR_DOMAIN); - if (sym == NULL) + /* Compute the number of elements in the array. On most arrays, +@@ -1160,9 +1185,6 @@ val_print_array_elements (struct type *type, const gdb_byte *valaddr, + is simply the size of the array divided by the size of the elements. + But for arrays of elements whose size is zero, we need to look at + the bounds. */ +- if (eltlen != 0) +- len = TYPE_LENGTH (type) / eltlen; +- else { - if (complain) -@@ -2961,8 +3139,6 @@ value_slice (struct value *array, int lowbound, int length) - || lowbound + length - 1 > upperbound) - error (_("slice out of range")); - -- /* FIXME-type-allocation: need a way to free this type when we are -- done with it. */ - slice_range_type = create_range_type ((struct type *) NULL, - TYPE_TARGET_TYPE (range_type), - lowbound, -diff --git a/gdb/valprint.c b/gdb/valprint.c -index cbb5d94..f9634ea 100644 ---- a/gdb/valprint.c -+++ b/gdb/valprint.c -@@ -236,7 +236,6 @@ scalar_type_p (struct type *type) - case TYPE_CODE_STRUCT: - case TYPE_CODE_UNION: - case TYPE_CODE_SET: -- case TYPE_CODE_STRING: - case TYPE_CODE_BITSTRING: - return 0; - default: -@@ -1153,6 +1152,7 @@ val_print_array_elements (struct type *type, const gdb_byte *valaddr, + LONGEST low, hi; - for (; i < len && things_printed < options->print_max; i++) +@@ -1236,6 +1258,8 @@ val_print_array_elements (struct type *type, const gdb_byte *valaddr, { -+ size_t elt_offset = i * eltlen; - if (i != 0) - { - if (options->prettyprint_arrays) -@@ -1172,7 +1172,7 @@ val_print_array_elements (struct type *type, const gdb_byte *valaddr, - rep1 = i + 1; - reps = 1; - while ((rep1 < len) && -- !memcmp (valaddr + i * eltlen, valaddr + rep1 * eltlen, eltlen)) -+ !memcmp (valaddr + elt_offset, valaddr + rep1 * eltlen, eltlen)) - { - ++reps; - ++rep1; + fprintf_filtered (stream, "..."); + } ++ ++ do_cleanups (back_to); + } + + /* Read LEN bytes of target memory at address MEMADDR, placing the diff --git a/gdb/value.c b/gdb/value.c -index 589e03b..66013b7 100644 +index d552402..b10269c 100644 --- a/gdb/value.c +++ b/gdb/value.c -@@ -37,8 +37,10 @@ - #include "block.h" - #include "dfp.h" +@@ -39,6 +39,7 @@ #include "objfiles.h" -+#include "cli/cli-decode.h" #include "valprint.h" #include "cli/cli-decode.h" +#include "observer.h" #include "python/python.h" -@@ -170,6 +172,14 @@ struct value - taken off this list. */ - struct value *next; - -+ /* The reference count. A value that is still on the `all_values' -+ list will have a reference count of 0. A call to `release_value' -+ will increment the reference count (and remove the value from the -+ list, the first time). A call to `value_free' will decrement the -+ reference count, and will free the value when there are no more -+ references. */ -+ int refcount; -+ - /* Register number if the value is from a register. */ - short regnum; - -@@ -261,7 +271,9 @@ allocate_value_lazy (struct type *type) - val->next = all_values; - all_values = val; - val->type = type; -+ type_incref (type); - val->enclosing_type = type; -+ type_incref (type); - VALUE_LVAL (val) = not_lval; - val->location.address = 0; - VALUE_FRAME_ID (val) = null_frame_id; -@@ -346,6 +358,8 @@ value_type (struct value *value) - void - deprecated_set_value_type (struct value *value, struct type *type) - { -+ type_incref (type); -+ type_decref (value->type); - value->type = type; - } - -@@ -624,6 +638,9 @@ value_free (struct value *val) - if (val->parent != NULL) - value_free (val->parent); - -+ type_decref (val->type); -+ type_decref (val->enclosing_type); -+ - if (VALUE_LVAL (val) == lval_computed) - { - struct lval_funcs *funcs = val->location.computed.funcs; -@@ -728,6 +745,9 @@ value_copy (struct value *arg) - val = allocate_value_lazy (encl_type); - else - val = allocate_value (encl_type); -+ -+ type_incref (arg->type); -+ type_decref (val->type); - val->type = arg->type; - VALUE_LVAL (val) = VALUE_LVAL (arg); - val->location = arg->location; -@@ -763,12 +783,15 @@ value_copy (struct value *arg) - void - set_value_component_location (struct value *component, struct value *whole) +@@ -828,12 +829,15 @@ void + set_value_component_location (struct value *component, + const struct value *whole) { + CORE_ADDR addr; + - if (VALUE_LVAL (whole) == lval_internalvar) + if (whole->lval == lval_internalvar) VALUE_LVAL (component) = lval_internalvar_component; else - VALUE_LVAL (component) = VALUE_LVAL (whole); + VALUE_LVAL (component) = whole->lval; component->location = whole->location; + - if (VALUE_LVAL (whole) == lval_computed) + if (whole->lval == lval_computed) { struct lval_funcs *funcs = whole->location.computed.funcs; -@@ -776,6 +799,10 @@ set_value_component_location (struct value *component, struct value *whole) +@@ -841,6 +845,12 @@ set_value_component_location (struct value *component, if (funcs->copy_closure) component->location.computed.closure = funcs->copy_closure (whole); } + + addr = value_raw_address (component); + object_address_get_data (value_type (whole), &addr); -+ set_value_address (component, addr); ++ if (component->lval != lval_internalvar ++ && component->lval != lval_internalvar_component) ++ set_value_address (component, addr); } -@@ -906,6 +933,29 @@ show_values (char *num_exp, int from_tty) +@@ -973,6 +983,29 @@ show_values (char *num_exp, int from_tty) num_exp[1] = '\0'; } } @@ -28623,7 +16021,7 @@ index 589e03b..66013b7 100644 /* Internal variables. These are variables within the debugger that hold values assigned by debugger commands. -@@ -1381,6 +1431,40 @@ call_internal_function (struct gdbarch *gdbarch, +@@ -1451,6 +1484,40 @@ call_internal_function (struct gdbarch *gdbarch, return (*ifn->handler) (gdbarch, language, ifn->cookie, argc, argv); } @@ -28664,7 +16062,7 @@ index 589e03b..66013b7 100644 /* The 'function' command. This does nothing -- it is just a placeholder to let "help function NAME" work. This is also used as the implementation of the sub-command that is created when -@@ -1428,11 +1512,10 @@ preserve_one_value (struct value *value, struct objfile *objfile, +@@ -1498,11 +1565,10 @@ preserve_one_value (struct value *value, struct objfile *objfile, htab_t copied_types) { if (TYPE_OBJFILE (value->type) == objfile) @@ -28678,7 +16076,7 @@ index 589e03b..66013b7 100644 copied_types); } -@@ -1447,13 +1530,13 @@ preserve_one_internalvar (struct internalvar *var, struct objfile *objfile, +@@ -1517,13 +1583,13 @@ preserve_one_internalvar (struct internalvar *var, struct objfile *objfile, case INTERNALVAR_INTEGER: if (var->u.integer.type && TYPE_OBJFILE (var->u.integer.type) == objfile) var->u.integer.type @@ -28694,88 +16092,33 @@ index 589e03b..66013b7 100644 break; case INTERNALVAR_VALUE: -@@ -1855,6 +1938,8 @@ value_change_enclosing_type (struct value *val, struct type *new_encl_type) - val->contents = - (gdb_byte *) xrealloc (val->contents, TYPE_LENGTH (new_encl_type)); - -+ type_incref (new_encl_type); -+ type_decref (val->enclosing_type); - val->enclosing_type = new_encl_type; - return val; - } -@@ -1919,6 +2004,8 @@ value_primitive_field (struct value *arg1, int offset, - memcpy (value_contents_all_raw (v), value_contents_all_raw (arg1), - TYPE_LENGTH (value_enclosing_type (arg1))); - } -+ type_incref (type); -+ type_decref (v->type); - v->type = type; - v->offset = value_offset (arg1); - v->embedded_offset = (offset + value_embedded_offset (arg1) -@@ -2177,6 +2264,42 @@ pack_long (gdb_byte *buf, struct type *type, LONGEST num) - } - - -+/* Pack NUM into BUF using a target format of TYPE. */ -+ -+void -+pack_unsigned_long (gdb_byte *buf, struct type *type, ULONGEST num) -+{ -+ enum bfd_endian byte_order = gdbarch_byte_order (get_type_arch (type)); -+ int len; -+ -+ type = check_typedef (type); -+ len = TYPE_LENGTH (type); +@@ -2387,7 +2453,24 @@ value_from_decfloat (struct type *type, const gdb_byte *dec) + struct value * + coerce_ref (struct value *arg) + { +- struct type *value_type_arg_tmp = check_typedef (value_type (arg)); ++ struct type *value_type_arg_tmp; + -+ switch (TYPE_CODE (type)) ++ if (TYPE_DYNAMIC (value_type (arg))) + { -+ case TYPE_CODE_INT: -+ case TYPE_CODE_CHAR: -+ case TYPE_CODE_ENUM: -+ case TYPE_CODE_FLAGS: -+ case TYPE_CODE_BOOL: -+ case TYPE_CODE_RANGE: -+ case TYPE_CODE_MEMBERPTR: -+ store_unsigned_integer (buf, len, byte_order, num); -+ break; -+ -+ case TYPE_CODE_REF: -+ case TYPE_CODE_PTR: -+ store_typed_address (buf, type, (CORE_ADDR) num); -+ break; ++ struct cleanup *cleanups = make_cleanup (null_cleanup, NULL); ++ CORE_ADDR address; + -+ default: -+ error (_("\ -+Unexpected type (%d) encountered for unsigned integer constant."), -+ TYPE_CODE (type)); ++ value_type_arg_tmp = value_type (arg); ++ address = value_raw_address (arg); ++ value_type_arg_tmp = object_address_get_data (value_type_arg_tmp, ++ &address); ++ if (! value_type_arg_tmp) ++ error (_("Attempt to coerce non-valid value.")); ++ arg = value_at_lazy (value_type_arg_tmp, address); ++ do_cleanups (cleanups); + } -+} -+ -+ - /* Convert C numbers into newly allocated values. */ - - struct value * -@@ -2190,6 +2313,19 @@ value_from_longest (struct type *type, LONGEST num) - } - ++ else ++ value_type_arg_tmp = check_typedef (value_type (arg)); -+/* Convert C unsigned numbers into newly allocated values. */ -+ -+struct value * -+value_from_ulongest (struct type *type, ULONGEST num) -+{ -+ struct value *val = allocate_value (type); -+ -+ pack_unsigned_long (value_contents_raw (val), type, num); -+ -+ return val; -+} -+ -+ - /* Create a value representing a pointer of type TYPE to the address - ADDR. */ - struct value * -@@ -2348,4 +2484,8 @@ VARIABLE is already initialized.")); + if (TYPE_CODE (value_type_arg_tmp) == TYPE_CODE_REF) + arg = value_at_lazy (TYPE_TARGET_TYPE (value_type_arg_tmp), +@@ -2485,4 +2568,8 @@ VARIABLE is already initialized.")); add_prefix_cmd ("function", no_class, function_command, _("\ Placeholder command for showing help on convenience functions."), &functionlist, "function ", 0, &cmdlist); @@ -28785,35 +16128,21 @@ index 589e03b..66013b7 100644 + observer_attach_mark_used (value_types_mark_used); } diff --git a/gdb/value.h b/gdb/value.h -index 51e6960..48b30e4 100644 +index 12cbc0a..a508bf6 100644 --- a/gdb/value.h +++ b/gdb/value.h -@@ -342,11 +342,16 @@ extern LONGEST unpack_field_as_long (struct type *type, - extern void pack_long (gdb_byte *buf, struct type *type, LONGEST num); - - extern struct value *value_from_longest (struct type *type, LONGEST num); -+extern struct value *value_from_ulongest (struct type *type, ULONGEST num); - extern struct value *value_from_pointer (struct type *type, CORE_ADDR addr); - extern struct value *value_from_double (struct type *type, DOUBLEST num); +@@ -372,6 +372,10 @@ extern struct value *value_from_double (struct type *type, DOUBLEST num); extern struct value *value_from_decfloat (struct type *type, const gdb_byte *decbytes); +extern const char *object_address_data_not_valid (struct type *type); -+extern int object_address_get_data (struct type *type, -+ CORE_ADDR *address_return); ++extern struct type *object_address_get_data (struct type *type, ++ CORE_ADDR *address_return); + extern struct value *value_at (struct type *type, CORE_ADDR addr); extern struct value *value_at_lazy (struct type *type, CORE_ADDR addr); -@@ -436,6 +441,7 @@ extern struct value *value_struct_elt (struct value **argp, - - extern struct value *value_aggregate_elt (struct type *curtype, - char *name, -+ struct type *expect_type, - int want_address, - enum noside noside); - -@@ -681,7 +687,7 @@ extern struct value *value_allocate_space_in_inferior (int); +@@ -729,7 +733,7 @@ extern struct value *value_allocate_space_in_inferior (int); extern struct value *value_of_local (const char *name, int complain); extern struct value *value_subscripted_rvalue (struct value *array, @@ -28823,7 +16152,7 @@ index 51e6960..48b30e4 100644 /* User function handler. */ diff --git a/gdb/varobj.c b/gdb/varobj.c -index 8f22156..8fe72ca 100644 +index b9b8e91..a81d25c 100644 --- a/gdb/varobj.c +++ b/gdb/varobj.c @@ -26,6 +26,8 @@ @@ -28835,138 +16164,3 @@ index 8f22156..8fe72ca 100644 #include "gdb_assert.h" #include "gdb_string.h" -@@ -253,6 +255,8 @@ static void free_variable (struct varobj *var); - - static struct cleanup *make_cleanup_free_variable (struct varobj *var); - -+static struct cleanup *make_cleanup_uninstall_variable (struct varobj *var); -+ - static struct type *get_type (struct varobj *var); - - static struct type *get_value_type (struct varobj *var); -@@ -480,6 +484,8 @@ is_root_p (struct varobj *var) - struct cleanup * - varobj_ensure_python_env (struct varobj *var) - { -+ gdb_assert (var->root->is_valid); -+ - return ensure_python_env (var->root->exp->gdbarch, - var->root->exp->language_defn); - } -@@ -651,6 +657,7 @@ varobj_create (char *objname, - do_cleanups (old_chain); - return NULL; - } -+ make_cleanup_uninstall_variable (var); - } - - discard_cleanups (old_chain); -@@ -821,7 +828,12 @@ varobj_get_display_hint (struct varobj *var) - char *result = NULL; - - #if HAVE_PYTHON -- struct cleanup *back_to = varobj_ensure_python_env (var); -+ struct cleanup *back_to; -+ -+ if (!var->root->is_valid) -+ return NULL; -+ -+ back_to = varobj_ensure_python_env (var); - - if (var->pretty_printer) - result = gdbpy_get_display_hint (var->pretty_printer); -@@ -2186,6 +2198,18 @@ make_cleanup_free_variable (struct varobj *var) - return make_cleanup (do_free_variable_cleanup, var); - } - -+static void -+do_uninstall_variable_cleanup (void *var) -+{ -+ uninstall_variable (var); -+} -+ -+static struct cleanup * -+make_cleanup_uninstall_variable (struct varobj *var) -+{ -+ return make_cleanup (do_uninstall_variable_cleanup, var); -+} -+ - /* This returns the type of the variable. It also skips past typedefs - to return the real type of the variable. - -@@ -3442,6 +3466,19 @@ java_value_of_variable (struct varobj *var, enum varobj_display_formats format) - return cplus_value_of_variable (var, format); - } - -+/* Iterate all the existing VAROBJs and call the FUNC callback for them with an -+ arbitrary caller supplied DATA pointer. */ -+ -+static void -+all_varobjs (void (*func) (struct varobj *var, void *data), void *data) -+{ -+ struct vlist **vlp, *vl; -+ -+ for (vlp = varobj_table; vlp < varobj_table + VAROBJ_TABLE_SIZE; vlp++) -+ for (vl = *vlp; vl != NULL; vl = vl->next) -+ (*func) (vl->var, data); -+} -+ - /* Iterate all the existing _root_ VAROBJs and call the FUNC callback for them - with an arbitrary caller supplied DATA pointer. */ - -@@ -3459,6 +3496,43 @@ all_root_varobjs (void (*func) (struct varobj *var, void *data), void *data) - (*func) (var_root->rootvar, data); - } - } -+ -+/* Helper for varobj_types_mark_used. Call type_mark_used for any TYPEs -+ referenced from this VAR. */ -+ -+static void -+varobj_types_mark_used_iter (struct varobj *var, void *unused) -+{ -+ /* Even FLOATING or IS_INVALID VARs with non-NULL TYPE references will -+ free them in free_variable. Still EXP may also reference TYPEs -+ but these belong to SYMBOLs which should be always associated with -+ an OBJFILE (and therefore not useful to be type_mark_used). */ -+ -+ type_mark_used (var->type); -+ if (var->value) -+ type_mark_used (value_type (var->value)); -+ -+ /* Check VAROBJROOTs only once during the varobj_types_mark_used pass. */ -+ -+ if (var->root->rootvar == var) -+ { -+ if (var->root->exp) -+ exp_types_mark_used (var->root->exp); -+ } -+} -+ -+/* Call type_mark_used for any TYPEs referenced from this GDB source file. */ -+ -+static void -+varobj_types_mark_used (void) -+{ -+ /* Check all the VAROBJs, even non-root ones. Child VAROBJs can reference -+ types from other OBJFILEs through TYPE_IS_OPAQUE resolutions by -+ check_typedef. Such types references will not be interconnected into the -+ same TYPE_GROUP. */ -+ -+ all_varobjs (varobj_types_mark_used_iter, NULL); -+} - - extern void _initialize_varobj (void); - void -diff --git a/gdb/xcoffread.c b/gdb/xcoffread.c -index c56ab86..dacf913 100644 ---- a/gdb/xcoffread.c -+++ b/gdb/xcoffread.c -@@ -3038,6 +3038,7 @@ static struct sym_fns xcoff_sym_fns = - xcoff_new_init, /* sym_new_init: init anything gbl to entire symtab */ - xcoff_symfile_init, /* sym_init: read initial info, setup for sym_read() */ - xcoff_initial_scan, /* sym_read: read a symbol file into symtab */ -+ NULL, /* sym_read_psymbols */ - xcoff_symfile_finish, /* sym_finish: finished with file, cleanup */ - xcoff_symfile_offsets, /* sym_offsets: xlate offsets ext->int form */ - default_symfile_segments, /* sym_segments: Get segment information from diff --git a/gdb-bz528668-symfile-cleanup.patch b/gdb-bz528668-symfile-cleanup.patch deleted file mode 100644 index 2a843fa..0000000 --- a/gdb-bz528668-symfile-cleanup.patch +++ /dev/null @@ -1,137 +0,0 @@ -http://sourceware.org/ml/gdb-patches/2009-10/msg00509.html -Subject: [patch 2/3] find_separate_debug_file cleanup - -Hi, - -current code was: -* difficult to maintain as a new variable required xfree on many places -* was causing memory corruptions due to silently misapplied 3rd party patches - as the close code fragments unfortunately match patch context - - -Thanks, -Jan - - -gdb/ -2009-10-21 Jan Kratochvil - - * symfile.c (find_separate_debug_file): Initialize dir, debugfile and - canon_name to NULL. Change alloca to xmalloc, newly call xfree for it. - New label cleanup_return_debugfile, jump to it from the failure paths. - ---- a/gdb/symfile.c -+++ b/gdb/symfile.c -@@ -1333,11 +1333,10 @@ static char * - find_separate_debug_file (struct objfile *objfile) - { - asection *sect; -- char *basename; -- char *dir; -- char *debugfile; -- char *name_copy; -- char *canon_name; -+ char *basename, *name_copy; -+ char *dir = NULL; -+ char *debugfile = NULL; -+ char *canon_name = NULL; - bfd_size_type debuglink_size; - unsigned long crc32; - int i; -@@ -1366,7 +1365,7 @@ find_separate_debug_file (struct objfile *objfile) - if (basename == NULL) - /* There's no separate debug info, hence there's no way we could - load it => no warning. */ -- return NULL; -+ goto cleanup_return_debugfile; - - dir = xstrdup (objfile->name); - -@@ -1388,24 +1387,19 @@ find_separate_debug_file (struct objfile *objfile) - if (canon_name && strlen (canon_name) > i) - i = strlen (canon_name); - -- debugfile = alloca (strlen (debug_file_directory) + 1 -- + i -- + strlen (DEBUG_SUBDIRECTORY) -- + strlen ("/") -- + strlen (basename) -- + 1); -+ debugfile = xmalloc (strlen (debug_file_directory) + 1 -+ + i -+ + strlen (DEBUG_SUBDIRECTORY) -+ + strlen ("/") -+ + strlen (basename) -+ + 1); - - /* First try in the same directory as the original file. */ - strcpy (debugfile, dir); - strcat (debugfile, basename); - - if (separate_debug_file_exists (debugfile, crc32, objfile->name)) -- { -- xfree (basename); -- xfree (dir); -- xfree (canon_name); -- return xstrdup (debugfile); -- } -+ goto cleanup_return_debugfile; - - /* Then try in the subdirectory named DEBUG_SUBDIRECTORY. */ - strcpy (debugfile, dir); -@@ -1414,12 +1408,7 @@ find_separate_debug_file (struct objfile *objfile) - strcat (debugfile, basename); - - if (separate_debug_file_exists (debugfile, crc32, objfile->name)) -- { -- xfree (basename); -- xfree (dir); -- xfree (canon_name); -- return xstrdup (debugfile); -- } -+ goto cleanup_return_debugfile; - - /* Then try in the global debugfile directory. */ - strcpy (debugfile, debug_file_directory); -@@ -1428,12 +1417,7 @@ find_separate_debug_file (struct objfile *objfile) - strcat (debugfile, basename); - - if (separate_debug_file_exists (debugfile, crc32, objfile->name)) -- { -- xfree (basename); -- xfree (dir); -- xfree (canon_name); -- return xstrdup (debugfile); -- } -+ goto cleanup_return_debugfile; - - /* If the file is in the sysroot, try using its base path in the - global debugfile directory. */ -@@ -1447,20 +1431,17 @@ find_separate_debug_file (struct objfile *objfile) - strcat (debugfile, basename); - - if (separate_debug_file_exists (debugfile, crc32, objfile->name)) -- { -- xfree (canon_name); -- xfree (basename); -- xfree (dir); -- return xstrdup (debugfile); -- } -+ goto cleanup_return_debugfile; - } - -- if (canon_name) -- xfree (canon_name); -+ xfree (debugfile); -+ debugfile = NULL; - -+cleanup_return_debugfile: -+ xfree (canon_name); - xfree (basename); - xfree (dir); -- return NULL; -+ return debugfile; - } - - - diff --git a/gdb-bz528668-symfile-multi.patch b/gdb-bz528668-symfile-multi.patch deleted file mode 100644 index e773f2f..0000000 --- a/gdb-bz528668-symfile-multi.patch +++ /dev/null @@ -1,271 +0,0 @@ -http://sourceware.org/ml/gdb-patches/2009-10/msg00508.html -Subject: [patch 3/3] debug-file-directory with multiple components - -Hi, - -for various reasons `debug-file-directory' would be sometimes useful to have -multiple components such as `solib-search-path' has. - -I found it useful myself during various separate debuginfo tests/scripts. - -It was requested for the ABRT bugreporting project at the preceding mail of: - https://fedorahosted.org/pipermail/crash-catcher/2009-October/000054.html - -It should be a backward compatible extension as DIRNAME_SEPARATOR should never -be a valid part of a single DEBUG_FILE_DIRECTORY component. - - -Thanks, -Jan - - -gdb/doc/ -2009-10-22 Jan Kratochvil - - * gdb.texinfo (set debug-file-directory, show debug-file-directory) - (Auto-loading): Use plural and note one can use multiple components now. - -gdb/ -2009-10-22 Jan Kratochvil - - * symfile.c (build_id_to_debug_filename): New variable debugdir. Move - variables size, s and data into a new inner block. Change xmalloc for - alloca, use direct BUILDID->SIZE there now. Loop for the - DEBUG_FILE_DIRECTORY components. - (find_separate_debug_file): New variable debugdir and debugdir_end. - Loop for the DEBUG_FILE_DIRECTORY components. - (_initialize_symfile): For "debug-file-directory" use plural and note - one can use multiple components now. - -gdb/testsuite/ -2009-10-22 Jan Kratochvil - - * gdb.base/sepdebug.exp: New test_different_dir call for multiple-dirs. - ---- a/gdb/doc/gdb.texinfo -+++ b/gdb/doc/gdb.texinfo -@@ -14066,13 +14066,14 @@ name @value{GDBN} is currently using. - @table @code - - @kindex set debug-file-directory --@item set debug-file-directory @var{directory} --Set the directory which @value{GDBN} searches for separate debugging --information files to @var{directory}. -+@item set debug-file-directory @var{directories} -+Set the directories which @value{GDBN} searches for separate debugging -+information files to @var{directory}. Multiple directory components can be set -+concatenating them by a directory separator. - - @kindex show debug-file-directory - @item show debug-file-directory --Show the directory @value{GDBN} searches for separate debugging -+Show the directories @value{GDBN} searches for separate debugging - information files. - - @end table -@@ -19336,8 +19337,8 @@ readable, @value{GDBN} will evaluate it as a Python script. - - If this file does not exist, and if the parameter - @code{debug-file-directory} is set (@pxref{Separate Debug Files}), --then @value{GDBN} will use the file named --@file{@var{debug-file-directory}/@var{real-name}}, where -+then @value{GDBN} will use for its each separated directory component -+@code{component} the file named @file{@code{component}/@var{real-name}}, where - @var{real-name} is the object file's real name, as described above. - - Finally, if this file does not exist, then @value{GDBN} will look for ---- a/gdb/symfile.c -+++ b/gdb/symfile.c -@@ -1218,35 +1218,59 @@ build_id_verify (const char *filename, struct build_id *check) - static char * - build_id_to_debug_filename (struct build_id *build_id) - { -- char *link, *s, *retval = NULL; -- gdb_byte *data = build_id->data; -- size_t size = build_id->size; -+ char *link, *debugdir, *retval = NULL; - - /* DEBUG_FILE_DIRECTORY/.build-id/ab/cdef */ -- link = xmalloc (strlen (debug_file_directory) + (sizeof "/.build-id/" - 1) + 1 -- + 2 * size + (sizeof ".debug" - 1) + 1); -- s = link + sprintf (link, "%s/.build-id/", debug_file_directory); -- if (size > 0) -- { -- size--; -- s += sprintf (s, "%02x", (unsigned) *data++); -- } -- if (size > 0) -- *s++ = '/'; -- while (size-- > 0) -- s += sprintf (s, "%02x", (unsigned) *data++); -- strcpy (s, ".debug"); -- -- /* lrealpath() is expensive even for the usually non-existent files. */ -- if (access (link, F_OK) == 0) -- retval = lrealpath (link); -- xfree (link); -- -- if (retval != NULL && !build_id_verify (retval, build_id)) -+ link = alloca (strlen (debug_file_directory) + (sizeof "/.build-id/" - 1) + 1 -+ + 2 * build_id->size + (sizeof ".debug" - 1) + 1); -+ -+ /* Keep backward compatibility so that DEBUG_FILE_DIRECTORY being "" will -+ cause "/.build-id/..." lookups. */ -+ -+ debugdir = debug_file_directory; -+ do - { -- xfree (retval); -- retval = NULL; -+ char *s, *debugdir_end; -+ gdb_byte *data = build_id->data; -+ size_t size = build_id->size; -+ -+ while (*debugdir == DIRNAME_SEPARATOR) -+ debugdir++; -+ -+ debugdir_end = strchr (debugdir, DIRNAME_SEPARATOR); -+ if (debugdir_end == NULL) -+ debugdir_end = &debugdir[strlen (debugdir)]; -+ -+ memcpy (link, debugdir, debugdir_end - debugdir); -+ s = &link[debugdir_end - debugdir]; -+ s += sprintf (s, "/.build-id/"); -+ if (size > 0) -+ { -+ size--; -+ s += sprintf (s, "%02x", (unsigned) *data++); -+ } -+ if (size > 0) -+ *s++ = '/'; -+ while (size-- > 0) -+ s += sprintf (s, "%02x", (unsigned) *data++); -+ strcpy (s, ".debug"); -+ -+ /* lrealpath() is expensive even for the usually non-existent files. */ -+ if (access (link, F_OK) == 0) -+ retval = lrealpath (link); -+ -+ if (retval != NULL && !build_id_verify (retval, build_id)) -+ { -+ xfree (retval); -+ retval = NULL; -+ } -+ -+ if (retval != NULL) -+ break; -+ -+ debugdir = debugdir_end; - } -+ while (*debugdir != 0); - - return retval; - } -@@ -1333,7 +1357,7 @@ static char * - find_separate_debug_file (struct objfile *objfile) - { - asection *sect; -- char *basename, *name_copy; -+ char *basename, *name_copy, *debugdir; - char *dir = NULL; - char *debugfile = NULL; - char *canon_name = NULL; -@@ -1410,29 +1434,51 @@ find_separate_debug_file (struct objfile *objfile) - if (separate_debug_file_exists (debugfile, crc32, objfile->name)) - goto cleanup_return_debugfile; - -- /* Then try in the global debugfile directory. */ -- strcpy (debugfile, debug_file_directory); -- strcat (debugfile, "/"); -- strcat (debugfile, dir); -- strcat (debugfile, basename); -- -- if (separate_debug_file_exists (debugfile, crc32, objfile->name)) -- goto cleanup_return_debugfile; -+ /* Then try in the global debugfile directories. -+ -+ Keep backward compatibility so that DEBUG_FILE_DIRECTORY being "" will -+ cause "/..." lookups. */ - -- /* If the file is in the sysroot, try using its base path in the -- global debugfile directory. */ -- if (canon_name -- && strncmp (canon_name, gdb_sysroot, strlen (gdb_sysroot)) == 0 -- && IS_DIR_SEPARATOR (canon_name[strlen (gdb_sysroot)])) -+ debugdir = debug_file_directory; -+ do - { -- strcpy (debugfile, debug_file_directory); -- strcat (debugfile, canon_name + strlen (gdb_sysroot)); -+ char *debugdir_end; -+ -+ while (*debugdir == DIRNAME_SEPARATOR) -+ debugdir++; -+ -+ debugdir_end = strchr (debugdir, DIRNAME_SEPARATOR); -+ if (debugdir_end == NULL) -+ debugdir_end = &debugdir[strlen (debugdir)]; -+ -+ memcpy (debugfile, debugdir, debugdir_end - debugdir); -+ debugfile[debugdir_end - debugdir] = 0; - strcat (debugfile, "/"); -+ strcat (debugfile, dir); - strcat (debugfile, basename); - - if (separate_debug_file_exists (debugfile, crc32, objfile->name)) - goto cleanup_return_debugfile; -+ -+ /* If the file is in the sysroot, try using its base path in the -+ global debugfile directory. */ -+ if (canon_name -+ && strncmp (canon_name, gdb_sysroot, strlen (gdb_sysroot)) == 0 -+ && IS_DIR_SEPARATOR (canon_name[strlen (gdb_sysroot)])) -+ { -+ memcpy (debugfile, debugdir, debugdir_end - debugdir); -+ debugfile[debugdir_end - debugdir] = 0; -+ strcat (debugfile, canon_name + strlen (gdb_sysroot)); -+ strcat (debugfile, "/"); -+ strcat (debugfile, basename); -+ -+ if (separate_debug_file_exists (debugfile, crc32, objfile->name)) -+ goto cleanup_return_debugfile; -+ } -+ -+ debugdir = debugdir_end; - } -+ while (*debugdir != 0); - - xfree (debugfile); - debugfile = NULL; -@@ -4173,12 +4219,12 @@ Usage: set extension-language .foo bar"), - - add_setshow_optional_filename_cmd ("debug-file-directory", class_support, - &debug_file_directory, _("\ --Set the directory where separate debug symbols are searched for."), _("\ --Show the directory where separate debug symbols are searched for."), _("\ -+Set the directories where separate debug symbols are searched for."), _("\ -+Show the directories where separate debug symbols are searched for."), _("\ - Separate debug symbols are first searched for in the same\n\ - directory as the binary, then in the `" DEBUG_SUBDIRECTORY "' subdirectory,\n\ - and lastly at the path of the directory of the binary with\n\ --the global debug-file directory prepended."), -+each global debug-file-directory component prepended."), - NULL, - show_debug_file_directory, - &setlist, &showlist); ---- a/gdb/testsuite/gdb.base/sepdebug.exp -+++ b/gdb/testsuite/gdb.base/sepdebug.exp -@@ -995,6 +995,12 @@ if ![string compare $build_id_debug_filename ""] then { - - test_different_dir build-id "${objdir}/${subdir}" $xfail - -+ # Test also multiple directories can be specified. Without the build-id -+ # reference GDB would find the separate debug info just at the same -+ # location as the executable file. -+ -+ test_different_dir multiple-dirs "/doesnotexist:${objdir}/${subdir}" $xfail -+ - # Spare debug files may confuse testsuite runs in the future. - remote_exec build "rm -f ${objdir}/${subdir}/${build_id_debug_filename}" - } - diff --git a/gdb-bz528668-symfile-sepcrc.patch b/gdb-bz528668-symfile-sepcrc.patch deleted file mode 100644 index 387e45f..0000000 --- a/gdb-bz528668-symfile-sepcrc.patch +++ /dev/null @@ -1,151 +0,0 @@ -http://sourceware.org/ml/gdb-patches/2009-10/msg00507.html -Subject: [patch 1/3] print the .debug file name having CRC mismatch - -Hi, - -this patch is left as is from Andrew Cagney. - - -Thanks, -Jan - - -gdb/ -2005-04-02 Andrew Cagney - - * symfile.c (separate_debug_file_exists): When the CRCs mismatch - print a warning. - (find_separate_debug_file): Pass in the objfile's name. - -gdb/testsuite/ -2009-10-21 Jan Kratochvil - - * gdb.base/sepdebug.exp (CRC mismatch is reported): New test. - * gdb.base/sepdebug2.c: New file. - ---- a/gdb/symfile.c -+++ b/gdb/symfile.c -@@ -1283,7 +1283,8 @@ get_debug_link_info (struct objfile *objfile, unsigned long *crc32_out) - } - - static int --separate_debug_file_exists (const char *name, unsigned long crc) -+separate_debug_file_exists (const char *name, unsigned long crc, -+ const char *parent_name) - { - unsigned long file_crc = 0; - bfd *abfd; -@@ -1303,7 +1304,15 @@ separate_debug_file_exists (const char *name, unsigned long crc) - - bfd_close (abfd); - -- return crc == file_crc; -+ if (crc != file_crc) -+ { -+ warning (_("the debug information found in \"%s\"" -+ " does not match \"%s\" (CRC mismatch).\n"), -+ name, parent_name); -+ return 0; -+ } -+ -+ return 1; - } - - char *debug_file_directory = NULL; -@@ -1355,6 +1364,8 @@ find_separate_debug_file (struct objfile *objfile) - basename = get_debug_link_info (objfile, &crc32); - - if (basename == NULL) -+ /* There's no separate debug info, hence there's no way we could -+ load it => no warning. */ - return NULL; - - dir = xstrdup (objfile->name); -@@ -1388,7 +1399,7 @@ find_separate_debug_file (struct objfile *objfile) - strcpy (debugfile, dir); - strcat (debugfile, basename); - -- if (separate_debug_file_exists (debugfile, crc32)) -+ if (separate_debug_file_exists (debugfile, crc32, objfile->name)) - { - xfree (basename); - xfree (dir); -@@ -1402,7 +1413,7 @@ find_separate_debug_file (struct objfile *objfile) - strcat (debugfile, "/"); - strcat (debugfile, basename); - -- if (separate_debug_file_exists (debugfile, crc32)) -+ if (separate_debug_file_exists (debugfile, crc32, objfile->name)) - { - xfree (basename); - xfree (dir); -@@ -1416,7 +1427,7 @@ find_separate_debug_file (struct objfile *objfile) - strcat (debugfile, dir); - strcat (debugfile, basename); - -- if (separate_debug_file_exists (debugfile, crc32)) -+ if (separate_debug_file_exists (debugfile, crc32, objfile->name)) - { - xfree (basename); - xfree (dir); -@@ -1435,7 +1446,7 @@ find_separate_debug_file (struct objfile *objfile) - strcat (debugfile, "/"); - strcat (debugfile, basename); - -- if (separate_debug_file_exists (debugfile, crc32)) -+ if (separate_debug_file_exists (debugfile, crc32, objfile->name)) - { - xfree (canon_name); - xfree (basename); ---- a/gdb/testsuite/gdb.base/sepdebug.exp -+++ b/gdb/testsuite/gdb.base/sepdebug.exp -@@ -952,6 +952,23 @@ set debugfile "${objdir}/${subdir}/${testfile}.debug" - test_different_dir debuglink "${objdir}/${subdir}" 0 - - -+# Test CRC mismatch is reported. -+ -+if {[build_executable sepdebug.exp sepdebug2 sepdebug2.c debug] != -1 -+ && ![gdb_gnu_strip_debug ${objdir}/${subdir}/sepdebug2]} { -+ -+ remote_exec build "cp ${debugfile} ${objdir}/${subdir}/.debug/sepdebug2.debug" -+ -+ gdb_exit -+ gdb_start -+ gdb_reinitialize_dir $srcdir/$subdir -+ -+ set escapedobjdirsubdir [string_to_regexp ${objdir}/${subdir}] -+ -+ gdb_test "file ${objdir}/${subdir}/sepdebug2" "warning: the debug information found in \"${escapedobjdirsubdir}/\\.debug/sepdebug2\\.debug\" does not match \"${escapedobjdirsubdir}/sepdebug2\" \\(CRC mismatch\\)\\..*\\(no debugging symbols found\\).*" "CRC mismatch is reported" -+} -+ -+ - # NT_GNU_BUILD_ID / .note.gnu.build-id test: - - set build_id_debug_filename [build_id_debug_filename_get $binfile] ---- /dev/null -+++ b/gdb/testsuite/gdb.base/sepdebug2.c -@@ -0,0 +1,22 @@ -+/* This testcase is part of GDB, the GNU debugger. -+ -+ Copyright 2009 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 . */ -+ -+int -+main (void) -+{ -+ return 0; -+} - diff --git a/gdb-bz533176-fortran-omp-step.patch b/gdb-bz533176-fortran-omp-step.patch new file mode 100644 index 0000000..39cac0d --- /dev/null +++ b/gdb-bz533176-fortran-omp-step.patch @@ -0,0 +1,115 @@ +https://bugzilla.redhat.com/show_bug.cgi?id=533176#c4 + +I find it a bug in DWARF and gdb behaves correctly according to it. From the +current DWARF's point of view the is a function call which you skip by "next". + +If you hide any /usr/lib/debug such as using: +gdb -nx -ex 'set debug-file-directory /qwe' -ex 'file ./tpcommon_gfortran44' +and use "step" command instead of "next" there it will work. +(You need to hide debuginfo from libgomp as you would step into libgomp sources +to maintain the threads for execution.) + +There should be some DWARF extension for it, currently tried to detect +substring ".omp_fn." as this function is called "MAIN__.omp_fn.0" and do not +consider such sub-function as a skippable by "next". + +Another problem is that with "set scheduler-locking" being "off" (default +upstream) or "step" (default in F/RHEL) the simultaneous execution of the +threads is inconvenient. Setting it to "on" will lockup the debugging as the +threads need to get synchronized at some point. This is a more general +debugging problem of GOMP outside of the scope of this Bug. + + + +--- ./gdb/infrun.c 2009-12-09 22:03:33.000000000 +0100 ++++ ./gdb/infrun.c 2009-12-09 22:29:56.000000000 +0100 +@@ -3994,6 +3994,12 @@ infrun: not switching back to stepped th + + if (ecs->event_thread->step_over_calls == STEP_OVER_ALL) + { ++ struct symbol *stop_fn = find_pc_function (stop_pc); ++ ++ if (stop_fn == NULL ++ || strstr (SYMBOL_LINKAGE_NAME (stop_fn), ".omp_fn.") == NULL) ++{ /* ".omp_fn." */ ++ + /* We're doing a "next". + + Normal (forward) execution: set a breakpoint at the +@@ -4020,6 +4026,7 @@ infrun: not switching back to stepped th + + keep_going (ecs); + return; ++} /* ".omp_fn." */ + } + + /* If we are in a function call trampoline (a stub between the +--- ./gdb/testsuite/gdb.fortran/omp-step.exp 1970-01-01 01:00:00.000000000 +0100 ++++ ./gdb/testsuite/gdb.fortran/omp-step.exp 2009-12-09 22:31:04.000000000 +0100 +@@ -0,0 +1,31 @@ ++# Copyright 2009 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 . ++ ++set testfile "omp-step" ++set srcfile ${testfile}.f90 ++if { [prepare_for_testing $testfile.exp $testfile $srcfile {debug f77 additional_flags=-fopenmp}] } { ++ return -1 ++} ++ ++if ![runto [gdb_get_line_number "start-here"]] { ++ perror "Couldn't run to start-here" ++ return 0 ++} ++ ++gdb_test "next" {!\$omp parallel} "step closer" ++gdb_test "next" {a\(omp_get_thread_num\(\) \+ 1\) = 1} "step into omp" ++ ++gdb_breakpoint [gdb_get_line_number "success"] ++gdb_continue_to_breakpoint "success" ".*success.*" +--- ./gdb/testsuite/gdb.fortran/omp-step.f90 1970-01-01 01:00:00.000000000 +0100 ++++ ./gdb/testsuite/gdb.fortran/omp-step.f90 2009-12-09 22:25:35.000000000 +0100 +@@ -0,0 +1,32 @@ ++! Copyright 2009 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 . ++ ++ use omp_lib ++ integer nthreads, i, a(1000) ++ nthreads = omp_get_num_threads() ++ if (nthreads .gt. 1000) call abort ++ ++ do i = 1, nthreads ++ a(i) = 0 ++ end do ++ print *, "start-here" ++!$omp parallel ++ a(omp_get_thread_num() + 1) = 1 ++!$omp end parallel ++ do i = 1, nthreads ++ if (a(i) .ne. 1) call abort ++ end do ++ print *, "success" ++ end diff --git a/gdb-bz538626-bp_location-accel-bp-cond.patch b/gdb-bz538626-bp_location-accel-bp-cond.patch deleted file mode 100644 index f734d51..0000000 --- a/gdb-bz538626-bp_location-accel-bp-cond.patch +++ /dev/null @@ -1,134 +0,0 @@ -Index: gdb-7.0/gdb/breakpoint.c -=================================================================== ---- gdb-7.0.orig/gdb/breakpoint.c 2009-11-25 10:24:49.000000000 +0100 -+++ gdb-7.0/gdb/breakpoint.c 2009-11-25 10:28:35.000000000 +0100 -@@ -337,14 +337,21 @@ static int executing_startup; - B ? (TMP=B->next, 1): 0; \ - B = TMP) - --/* Similar iterator for the low-level breakpoints. SAFE variant is not -- provided so update_global_location_list must not be called while executing -- the block of ALL_BP_LOCATIONS. */ -- --#define ALL_BP_LOCATIONS(B,BP_TMP) \ -- for (BP_TMP = bp_location; \ -- BP_TMP < bp_location + bp_location_count && (B = *BP_TMP); \ -- BP_TMP++) -+/* Similar iterator for the low-level breakpoints. This iterator -+ requires a defined BP_LOCATION array and BP_LOCATION_COUNT. */ -+ -+#define ALL_BP_LOCATIONS_FROM(B,BP_TMP,BP_LOCATION,BP_LOCATION_COUNT) \ -+ for (BP_TMP = BP_LOCATION; \ -+ BP_TMP < BP_LOCATION + BP_LOCATION_COUNT && (B = *BP_TMP); \ -+ BP_TMP++) -+ -+/* Iterator that calls ALL_BP_LOCATIONS_FROM with the global -+ bp_locations and bp_location_count variables. SAFE variant is not -+ provided so update_global_location_list must not be called while -+ executing the block of ALL_BP_LOCATIONS. */ -+ -+#define ALL_BP_LOCATIONS(B,BP_TMP) \ -+ ALL_BP_LOCATIONS_FROM(B,BP_TMP,bp_location, bp_location_count) - - /* Iterator for tracepoints only. */ - -@@ -3313,6 +3320,7 @@ bpstat_check_breakpoint_conditions (bpst - bpstat - bpstat_stop_status (CORE_ADDR bp_addr, ptid_t ptid) - { -+ struct cleanup *old_chain; - struct breakpoint *b = NULL; - struct bp_location *bl, **blp_tmp; - struct bp_location *loc; -@@ -3322,8 +3330,14 @@ bpstat_stop_status (CORE_ADDR bp_addr, p - bpstat bs = root_bs; - int ix; - int need_remove_insert, update_locations = 0; -+ struct bp_location **saved_bp_location; -+ int saved_bp_location_count = bp_location_count; - -- ALL_BP_LOCATIONS (bl, blp_tmp) -+ saved_bp_location = xmalloc (sizeof (*bp_location) * bp_location_count); -+ memcpy (saved_bp_location, bp_location, sizeof (*bp_location) * bp_location_count); -+ old_chain = make_cleanup (xfree, saved_bp_location); -+ -+ ALL_BP_LOCATIONS_FROM (bl, blp_tmp, saved_bp_location, saved_bp_location_count) - { - bpstat bs_prev = bs; - -@@ -3460,6 +3474,7 @@ bpstat_stop_status (CORE_ADDR bp_addr, p - insert_breakpoints (); - } - -+ do_cleanups (old_chain); - return root_bs->next; - } - -Index: gdb-7.0/gdb/testsuite/gdb.base/condbreak.exp -=================================================================== ---- gdb-7.0.orig/gdb/testsuite/gdb.base/condbreak.exp 2009-01-03 06:58:03.000000000 +0100 -+++ gdb-7.0/gdb/testsuite/gdb.base/condbreak.exp 2009-11-25 10:27:50.000000000 +0100 -@@ -68,6 +68,8 @@ set bp_location1 [gdb_get_line_number " - set bp_location6 [gdb_get_line_number "set breakpoint 6 here"] - set bp_location8 [gdb_get_line_number "set breakpoint 8 here" $srcfile1] - set bp_location9 [gdb_get_line_number "set breakpoint 9 here" $srcfile1] -+set bp_location13 [gdb_get_line_number "set breakpoint 13 here" $srcfile1] -+set bp_location14 [gdb_get_line_number "set breakpoint 14 here" $srcfile1] - set bp_location15 [gdb_get_line_number "set breakpoint 15 here" $srcfile1] - set bp_location16 [gdb_get_line_number "set breakpoint 16 here" $srcfile1] - -@@ -110,15 +112,23 @@ gdb_test "break marker2 if (a==43)" \ - "Breakpoint.*at.* file .*$srcfile1, line.*" - - # -+# Check break involving inferior function call. -+# -+gdb_test "break marker4 if (multi_line_if_conditional(1,1,1)==0)" \ -+ "Breakpoint.*at.* file .*$srcfile1, line.*" -+ -+# - # check to see what breakpoints are set - # - - if {$hp_aCC_compiler} { - set marker1_proto "\\(void\\)" - set marker2_proto "\\(int\\)" -+ set marker4_proto "\\(long\\)" - } else { - set marker1_proto "" - set marker2_proto "" -+ set marker4_proto "" - } - - gdb_test "info break" \ -@@ -129,7 +139,9 @@ gdb_test "info break" \ - \[0-9\]+\[\t \]+breakpoint keep y.* in main at .*$srcfile:$bp_location1.* - \[\t \]+stop only if \\(1==1\\).* - \[0-9\]+\[\t \]+breakpoint keep y.* in marker2$marker2_proto at .*$srcfile1:($bp_location8|$bp_location9).* --\[\t \]+stop only if \\(a==43\\).*" \ -+\[\t \]+stop only if \\(a==43\\).* -+\[0-9\]+\[\t \]+breakpoint keep y.* in marker4$marker4_proto at .*$srcfile1:($bp_location13|$bp_location14).* -+\[\t \]+stop only if \\(multi_line_if_conditional\\(1,1,1\\)==0\\).*" \ - "breakpoint info" - - -@@ -220,3 +232,19 @@ gdb_expect { - fail "(timeout) run until breakpoint at marker2" - } - } -+ -+send_gdb "continue\n" -+gdb_expect { -+ -re "Continuing\\..*Breakpoint \[0-9\]+, marker4 \\(d=177601976\\) at .*$srcfile1:($bp_location13|$bp_location14).*($bp_location13|$bp_location14)\[\t \]+.*" { -+ pass "run until breakpoint at marker4" -+ } -+ -re "Continuing\\..*Breakpoint \[0-9\]+, $hex in marker4 \\(d=177601976\\) at .*$srcfile1:($bp_location13|$bp_location14).*($bp_location13|$bp_location14)\[\t \]+.*" { -+ xfail "run until breakpoint at marker4" -+ } -+ -re "$gdb_prompt $" { -+ fail "run until breakpoint at marker4" -+ } -+ timeout { -+ fail "(timeout) run until breakpoint at marker4" -+ } -+} diff --git a/gdb-bz539590-gnu-ifunc-fix-cond.patch b/gdb-bz539590-gnu-ifunc-fix-cond.patch new file mode 100644 index 0000000..98bf5c0 --- /dev/null +++ b/gdb-bz539590-gnu-ifunc-fix-cond.patch @@ -0,0 +1,14 @@ +--- ./gdb/breakpoint.c 2010-04-26 02:35:53.000000000 +0200 ++++ ./gdb/breakpoint.c 2010-04-26 02:33:26.000000000 +0200 +@@ -8499,6 +8499,11 @@ update_breakpoint_locations (struct brea + { + struct gdb_exception e; + ++ /* Temporary workaround before the non-intrusive ifunc patch gets in. ++ exp parsing can now call inferior function invalidating ++ EXISTING_LOCATIONS. */ ++ existing_locations = NULL; ++ + s = b->cond_string; + TRY_CATCH (e, RETURN_MASK_ERROR) + { diff --git a/gdb-bz539590-gnu-ifunc.patch b/gdb-bz539590-gnu-ifunc.patch deleted file mode 100644 index 2f1b80b..0000000 --- a/gdb-bz539590-gnu-ifunc.patch +++ /dev/null @@ -1,511 +0,0 @@ -gdb/ -2009-11-24 Jan Kratochvil - - Transparent GNU-IFUNCs support. - * elfread.c (record_minimal_symbol): Apply also for mst_text_gnu_ifunc. - (elf_symtab_read): Set also mst_text_gnu_ifunc. - * gdbtypes.c (init_type): Support TYPE_FLAG_GNU_IFUNC. - (gdbtypes_post_init): Initialize builtin_func_func_ptr. - (objfile_type): Initialize nodebug_text_gnu_ifunc_symbol. - * gdbtypes.h (enum type_flag_value ) - (TYPE_GNU_IFUNC, struct main_type ) - (struct builtin_type ) - (struct objfile_type ): New. - * infcall.c (find_function_addr ): New. - * minsyms.c (lookup_minimal_symbol_text, prim_record_minimal_symbol) - (find_solib_trampoline_target): Support also mst_text_gnu_ifunc. - (in_gnu_ifunc_stub): New. - * parse.c (write_exp_msymbol ): New. - * solib-svr4.c (svr4_in_dynsym_resolve_code): Call also - in_gnu_ifunc_stub. - * symmisc.c (dump_msymbols ): New. - * symtab.c (search_symbols): Support also mst_text_gnu_ifunc. - * symtab.h (enum minimal_symbol_type ) - (in_gnu_ifunc_stub): New. - * linespec.c: Include infcall.h. - (minsym_found ): New. - -gdb/testsuite/ -2009-11-24 Jan Kratochvil - - Transparent GNU-IFUNCs support. - * gdb.base/gnu-ifunc-lib.c, gdb.base/gnu-ifunc.c, - gdb.base/gnu-ifunc.exp: New. - -Index: gdb-7.0/gdb/elfread.c -=================================================================== ---- gdb-7.0.orig/gdb/elfread.c 2009-11-25 10:24:45.000000000 +0100 -+++ gdb-7.0/gdb/elfread.c 2009-11-25 10:25:50.000000000 +0100 -@@ -168,7 +168,8 @@ record_minimal_symbol (char *name, CORE_ - { - struct gdbarch *gdbarch = get_objfile_arch (objfile); - -- if (ms_type == mst_text || ms_type == mst_file_text) -+ if (ms_type == mst_text || ms_type == mst_file_text -+ || ms_type == mst_text_gnu_ifunc) - address = gdbarch_smash_text_address (gdbarch, address); - - return prim_record_minimal_symbol_and_info -@@ -373,7 +374,10 @@ elf_symtab_read (struct objfile *objfile - { - if (sym->flags & (BSF_GLOBAL | BSF_WEAK)) - { -- ms_type = mst_text; -+ if (sym->flags & BSF_GNU_INDIRECT_FUNCTION) -+ ms_type = mst_text_gnu_ifunc; -+ else -+ ms_type = mst_text; - } - else if ((sym->name[0] == '.' && sym->name[1] == 'L') - || ((sym->flags & BSF_LOCAL) -Index: gdb-7.0/gdb/gdbtypes.c -=================================================================== ---- gdb-7.0.orig/gdb/gdbtypes.c 2009-11-25 10:24:47.000000000 +0100 -+++ gdb-7.0/gdb/gdbtypes.c 2009-11-25 10:24:56.000000000 +0100 -@@ -1904,6 +1904,8 @@ init_type (enum type_code code, int leng - TYPE_NOTTEXT (type) = 1; - if (flags & TYPE_FLAG_FIXED_INSTANCE) - TYPE_FIXED_INSTANCE (type) = 1; -+ if (flags & TYPE_FLAG_GNU_IFUNC) -+ TYPE_GNU_IFUNC (type) = 1; - - if (name) - TYPE_NAME (type) = obsavestring (name, strlen (name), -@@ -3762,6 +3764,8 @@ gdbtypes_post_init (struct gdbarch *gdba - = lookup_pointer_type (builtin_type->builtin_void); - builtin_type->builtin_func_ptr - = lookup_pointer_type (lookup_function_type (builtin_type->builtin_void)); -+ builtin_type->builtin_func_func_ptr -+ = lookup_pointer_type (lookup_function_type (builtin_type->builtin_func_ptr)); - - /* This type represents a GDB internal function. */ - builtin_type->internal_fn -@@ -3878,6 +3882,11 @@ objfile_type (struct objfile *objfile) - "", objfile); - TYPE_TARGET_TYPE (objfile_type->nodebug_text_symbol) - = objfile_type->builtin_int; -+ objfile_type->nodebug_text_gnu_ifunc_symbol -+ = init_type (TYPE_CODE_FUNC, 1, TYPE_FLAG_GNU_IFUNC, -+ "", objfile); -+ TYPE_TARGET_TYPE (objfile_type->nodebug_text_gnu_ifunc_symbol) -+ = objfile_type->nodebug_text_symbol; - objfile_type->nodebug_data_symbol - = init_type (TYPE_CODE_INT, - gdbarch_int_bit (gdbarch) / HOST_CHAR_BIT, 0, -Index: gdb-7.0/gdb/gdbtypes.h -=================================================================== ---- gdb-7.0.orig/gdb/gdbtypes.h 2009-11-25 10:24:48.000000000 +0100 -+++ gdb-7.0/gdb/gdbtypes.h 2009-11-25 10:25:17.000000000 +0100 -@@ -187,6 +187,7 @@ enum type_flag_value - TYPE_FLAG_FIXED_INSTANCE = (1 << 15), - TYPE_FLAG_STUB_SUPPORTED = (1 << 16), - TYPE_FLAG_NOTTEXT = (1 << 17), -+ TYPE_FLAG_GNU_IFUNC = (1 << 18), - - /* Used for error-checking. */ - TYPE_FLAG_MIN = TYPE_FLAG_UNSIGNED -@@ -292,6 +293,12 @@ enum type_instance_flag_value - - #define TYPE_NOTTEXT(t) (TYPE_MAIN_TYPE (t)->flag_nottext) - -+/* Currently used only for TYPE_CODE_FUNC where specifies the real function -+ address is returned by this function call. TYPE_TARGET_TYPE determines the -+ final returned function type to be presented to user. */ -+ -+#define TYPE_GNU_IFUNC(t) (TYPE_MAIN_TYPE (t)->flag_gnu_ifunc) -+ - /* Type owner. If TYPE_OBJFILE_OWNED is true, the type is owned by - the objfile retrieved as TYPE_OBJFILE. Otherweise, the type is - owned by an architecture; TYPE_OBJFILE is NULL in this case. */ -@@ -427,6 +434,7 @@ struct main_type - unsigned int flag_vector : 1; - unsigned int flag_stub_supported : 1; - unsigned int flag_nottext : 1; -+ unsigned int flag_gnu_ifunc : 1; - unsigned int flag_fixed_instance : 1; - unsigned int flag_objfile_owned : 1; - unsigned int flag_discardable : 1; -@@ -1144,6 +1152,10 @@ struct builtin_type - (*) () can server as a generic function pointer. */ - struct type *builtin_func_ptr; - -+ /* `pointer to function returning pointer to function (returning void)' type. -+ The final void return type is not significant for it. */ -+ struct type *builtin_func_func_ptr; -+ - - /* Special-purpose types. */ - -@@ -1186,6 +1198,7 @@ struct objfile_type - - /* Types used for symbols with no debug information. */ - struct type *nodebug_text_symbol; -+ struct type *nodebug_text_gnu_ifunc_symbol; - struct type *nodebug_data_symbol; - struct type *nodebug_unknown_symbol; - struct type *nodebug_tls_symbol; -Index: gdb-7.0/gdb/infcall.c -=================================================================== ---- gdb-7.0.orig/gdb/infcall.c 2009-11-25 10:24:45.000000000 +0100 -+++ gdb-7.0/gdb/infcall.c 2009-11-25 10:24:56.000000000 +0100 -@@ -286,6 +286,27 @@ find_function_addr (struct value *functi - else - error (_("Invalid data type for function to be called.")); - -+ if (TYPE_GNU_IFUNC (ftype)) -+ { -+ struct type *func_func_ptr; -+ -+ funaddr += gdbarch_deprecated_function_start_offset (gdbarch); -+ -+ /* Cast FUNADDR to drop TYPE_GNU_IFUNC and being able to call gnu-ifunc -+ FUNADDR without causing deadlock by this block of code. */ -+ -+ func_func_ptr = builtin_type (gdbarch)->builtin_func_func_ptr; -+ function = value_from_pointer (func_func_ptr, funaddr); -+ -+ /* gnu-ifuncs have no arguments. */ -+ function = call_function_by_hand (function, 0, NULL); -+ -+ funaddr = value_as_address (function); -+ -+ /* This is `int' as the return type of the final function. */ -+ value_type = TYPE_TARGET_TYPE (value_type); -+ } -+ - if (retval_type != NULL) - *retval_type = value_type; - return funaddr + gdbarch_deprecated_function_start_offset (gdbarch); -Index: gdb-7.0/gdb/linespec.c -=================================================================== ---- gdb-7.0.orig/gdb/linespec.c 2009-11-25 10:24:45.000000000 +0100 -+++ gdb-7.0/gdb/linespec.c 2009-11-25 10:24:56.000000000 +0100 -@@ -40,6 +40,7 @@ - #include "interps.h" - #include "mi/mi-cmds.h" - #include "target.h" -+#include "infcall.h" - - /* We share this one with symtab.c, but it is not exported widely. */ - -@@ -1875,6 +1876,22 @@ minsym_found (int funfirstline, struct m - pc = gdbarch_convert_from_func_ptr_addr (gdbarch, - values.sals[0].pc, - ¤t_target); -+ -+ /* Call gnu-ifunc to resolve breakpoint at its returned function. */ -+ if (MSYMBOL_TYPE (msymbol) == mst_text_gnu_ifunc) -+ { -+ struct type *func_func_ptr; -+ struct value *function; -+ -+ func_func_ptr = builtin_type (gdbarch)->builtin_func_func_ptr; -+ function = value_from_pointer (func_func_ptr, pc); -+ -+ /* gnu-ifuncs have no arguments. */ -+ function = call_function_by_hand (function, 0, NULL); -+ -+ pc = value_as_address (function); -+ } -+ - if (pc != values.sals[0].pc) - values.sals[0] = find_pc_sect_line (pc, NULL, 0); - -Index: gdb-7.0/gdb/minsyms.c -=================================================================== ---- gdb-7.0.orig/gdb/minsyms.c 2009-11-25 10:24:47.000000000 +0100 -+++ gdb-7.0/gdb/minsyms.c 2009-11-25 10:24:56.000000000 +0100 -@@ -331,8 +331,9 @@ lookup_minimal_symbol_text (const char * - msymbol = msymbol->hash_next) - { - if (strcmp (SYMBOL_LINKAGE_NAME (msymbol), name) == 0 && -- (MSYMBOL_TYPE (msymbol) == mst_text || -- MSYMBOL_TYPE (msymbol) == mst_file_text)) -+ (MSYMBOL_TYPE (msymbol) == mst_text -+ || MSYMBOL_TYPE (msymbol) == mst_text_gnu_ifunc -+ || MSYMBOL_TYPE (msymbol) == mst_file_text)) - { - switch (MSYMBOL_TYPE (msymbol)) - { -@@ -699,6 +700,16 @@ lookup_minimal_symbol_by_pc (CORE_ADDR p - { - return lookup_minimal_symbol_by_pc_section (pc, NULL); - } -+ -+/* Return non-zero iff PC is in function implementing gnu-ifunc selection. */ -+ -+int -+in_gnu_ifunc_stub (CORE_ADDR pc) -+{ -+ struct minimal_symbol *msymbol = lookup_minimal_symbol_by_pc (pc); -+ -+ return msymbol && MSYMBOL_TYPE (msymbol) == mst_text_gnu_ifunc; -+} - - - /* Return leading symbol character for a BFD. If BFD is NULL, -@@ -738,6 +749,7 @@ prim_record_minimal_symbol (const char * - switch (ms_type) - { - case mst_text: -+ case mst_text_gnu_ifunc: - case mst_file_text: - case mst_solib_trampoline: - section = SECT_OFF_TEXT (objfile); -@@ -1184,7 +1196,8 @@ find_solib_trampoline_target (struct fra - { - ALL_MSYMBOLS (objfile, msymbol) - { -- if (MSYMBOL_TYPE (msymbol) == mst_text -+ if ((MSYMBOL_TYPE (msymbol) == mst_text -+ || MSYMBOL_TYPE (msymbol) == mst_text_gnu_ifunc) - && strcmp (SYMBOL_LINKAGE_NAME (msymbol), - SYMBOL_LINKAGE_NAME (tsymbol)) == 0) - return SYMBOL_VALUE_ADDRESS (msymbol); -Index: gdb-7.0/gdb/parse.c -=================================================================== ---- gdb-7.0.orig/gdb/parse.c 2009-11-25 10:24:47.000000000 +0100 -+++ gdb-7.0/gdb/parse.c 2009-11-25 10:26:16.000000000 +0100 -@@ -517,6 +517,11 @@ write_exp_msymbol (struct minimal_symbol - write_exp_elt_type (objfile_type (objfile)->nodebug_text_symbol); - break; - -+ case mst_text_gnu_ifunc: -+ write_exp_elt_type (objfile_type (objfile) -+ ->nodebug_text_gnu_ifunc_symbol); -+ break; -+ - case mst_data: - case mst_file_data: - case mst_bss: -Index: gdb-7.0/gdb/solib-svr4.c -=================================================================== ---- gdb-7.0.orig/gdb/solib-svr4.c 2009-11-25 10:24:49.000000000 +0100 -+++ gdb-7.0/gdb/solib-svr4.c 2009-11-25 10:26:41.000000000 +0100 -@@ -1242,7 +1242,8 @@ svr4_in_dynsym_resolve_code (CORE_ADDR p - { - return ((pc >= interp_text_sect_low && pc < interp_text_sect_high) - || (pc >= interp_plt_sect_low && pc < interp_plt_sect_high) -- || in_plt_section (pc, NULL)); -+ || in_plt_section (pc, NULL) -+ || in_gnu_ifunc_stub (pc)); - } - - /* Given an executable's ABFD and target, compute the entry-point -Index: gdb-7.0/gdb/symmisc.c -=================================================================== ---- gdb-7.0.orig/gdb/symmisc.c 2009-11-25 10:24:47.000000000 +0100 -+++ gdb-7.0/gdb/symmisc.c 2009-11-25 10:24:56.000000000 +0100 -@@ -287,6 +287,9 @@ dump_msymbols (struct objfile *objfile, - case mst_text: - ms_type = 'T'; - break; -+ case mst_text_gnu_ifunc: -+ ms_type = 'i'; -+ break; - case mst_solib_trampoline: - ms_type = 'S'; - break; -Index: gdb-7.0/gdb/symtab.c -=================================================================== ---- gdb-7.0.orig/gdb/symtab.c 2009-11-25 10:24:47.000000000 +0100 -+++ gdb-7.0/gdb/symtab.c 2009-11-25 10:24:56.000000000 +0100 -@@ -3155,7 +3155,7 @@ search_symbols (char *regexp, domain_enu - {mst_file_data, mst_solib_trampoline, mst_abs, mst_unknown}; - static enum minimal_symbol_type types4[] - = -- {mst_file_bss, mst_text, mst_abs, mst_unknown}; -+ {mst_file_bss, mst_text_gnu_ifunc, mst_abs, mst_unknown}; - enum minimal_symbol_type ourtype; - enum minimal_symbol_type ourtype2; - enum minimal_symbol_type ourtype3; -Index: gdb-7.0/gdb/symtab.h -=================================================================== ---- gdb-7.0.orig/gdb/symtab.h 2009-11-25 10:24:45.000000000 +0100 -+++ gdb-7.0/gdb/symtab.h 2009-11-25 10:24:56.000000000 +0100 -@@ -275,6 +275,8 @@ enum minimal_symbol_type - { - mst_unknown = 0, /* Unknown type, the default */ - mst_text, /* Generally executable instructions */ -+ mst_text_gnu_ifunc, /* Executable code returning address -+ of executable code */ - mst_data, /* Generally initialized data */ - mst_bss, /* Generally uninitialized data */ - mst_abs, /* Generally absolute (nonrelocatable) */ -@@ -1149,6 +1151,8 @@ extern struct minimal_symbol *lookup_min - - extern struct minimal_symbol *lookup_minimal_symbol_by_pc (CORE_ADDR); - -+extern int in_gnu_ifunc_stub (CORE_ADDR pc); -+ - extern struct minimal_symbol - *lookup_minimal_symbol_by_pc_section (CORE_ADDR, struct obj_section *); - -Index: gdb-7.0/gdb/testsuite/gdb.base/gnu-ifunc-lib.c -=================================================================== ---- /dev/null 1970-01-01 00:00:00.000000000 +0000 -+++ gdb-7.0/gdb/testsuite/gdb.base/gnu-ifunc-lib.c 2009-11-25 10:24:56.000000000 +0100 -@@ -0,0 +1,45 @@ -+/* This testcase is part of GDB, the GNU debugger. -+ -+ Copyright 2009 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 -+ -+typedef int (*final_t) (int arg); -+ -+static int -+final (int arg) -+{ -+ return arg + 1; -+} -+ -+static volatile int gnu_ifunc_initialized; -+ -+void -+gnu_ifunc_pre (void) -+{ -+ assert (!gnu_ifunc_initialized); -+} -+ -+final_t gnu_ifuncX (void) asm ("gnu_ifunc"); -+asm (".type gnu_ifunc, @gnu_indirect_function"); -+ -+final_t -+gnu_ifuncX (void) -+{ -+ gnu_ifunc_initialized = 1; -+ -+ return final; -+} -Index: gdb-7.0/gdb/testsuite/gdb.base/gnu-ifunc.c -=================================================================== ---- /dev/null 1970-01-01 00:00:00.000000000 +0000 -+++ gdb-7.0/gdb/testsuite/gdb.base/gnu-ifunc.c 2009-11-25 10:24:56.000000000 +0100 -@@ -0,0 +1,36 @@ -+/* This testcase is part of GDB, the GNU debugger. -+ -+ Copyright 2009 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 -+ -+extern int gnu_ifunc (int arg); -+extern void gnu_ifunc_pre (void); -+ -+int -+main (void) -+{ -+ int i; -+ -+ gnu_ifunc_pre (); -+ -+ i = gnu_ifunc (1); /* break-at-call */ -+ assert (i == 2); -+ -+ gnu_ifunc (2); /* break-at-nextcall */ -+ -+ return 0; /* break-at-exit */ -+} -Index: gdb-7.0/gdb/testsuite/gdb.base/gnu-ifunc.exp -=================================================================== ---- /dev/null 1970-01-01 00:00:00.000000000 +0000 -+++ gdb-7.0/gdb/testsuite/gdb.base/gnu-ifunc.exp 2009-11-25 10:24:56.000000000 +0100 -@@ -0,0 +1,72 @@ -+# Copyright (C) 2009 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 -+} -+ -+set testfile "gnu-ifunc" -+set srcfile ${testfile}.c -+set binfile ${objdir}/${subdir}/${testfile} -+ -+set libfile "${testfile}-lib" -+set libsrc ${libfile}.c -+set lib_so ${objdir}/${subdir}/${libfile}.so -+ -+set lib_opts [list debug] -+set exec_opts [list debug shlib=$lib_so] -+ -+if [get_compiler_info ${binfile}] { -+ return -1 -+} -+ -+if { [gdb_compile_shlib ${srcdir}/${subdir}/$libsrc $lib_so $lib_opts] != "" -+ || [gdb_compile ${srcdir}/${subdir}/$srcfile $binfile executable $exec_opts] != ""} { -+ untested "Could not compile either $libsrc or $srcfile." -+ return -1 -+} -+ -+# Start with a fresh gdb. -+ -+clean_restart $testfile -+gdb_load_shlibs ${lib_so} -+ -+if ![runto_main] then { -+ fail "Can't run to main" -+ return 1; -+} -+ -+gdb_breakpoint [gdb_get_line_number "break-at-nextcall"] -+ -+gdb_breakpoint [gdb_get_line_number "break-at-call"] -+gdb_continue_to_breakpoint "break-at-call" ".*break-at-call.*" -+ -+# Test GDB will automatically indirect the call. -+ -+gdb_test "p gnu_ifunc (3)" " = 4" -+ -+# Test GDB will skip the gnu_ifunc resolver on first call. -+ -+gdb_test "step" "\r\nfinal .*" -+ -+# Test GDB will not break before the final chosen implementation. -+ -+gdb_continue_to_breakpoint "break-at-nextcall" ".*break-at-nextcall.*" -+ -+gdb_breakpoint "gnu_ifunc" -+ -+gdb_continue_to_breakpoint "nextcall gnu_ifunc" -+ -+gdb_test "frame" "#0 +final \\(.*" "nextcall gnu_ifunc skipped" diff --git a/gdb-bz541866-rwatch-before-run.patch b/gdb-bz541866-rwatch-before-run.patch new file mode 100644 index 0000000..f485b2f --- /dev/null +++ b/gdb-bz541866-rwatch-before-run.patch @@ -0,0 +1,106 @@ +Index: gdb-7.1.90.20100711/gdb/config/i386/linux64.mh +=================================================================== +--- gdb-7.1.90.20100711.orig/gdb/config/i386/linux64.mh 2010-05-28 20:50:31.000000000 +0200 ++++ gdb-7.1.90.20100711/gdb/config/i386/linux64.mh 2010-07-13 19:02:54.000000000 +0200 +@@ -2,7 +2,7 @@ + NATDEPFILES= inf-ptrace.o fork-child.o \ + i386-nat.o amd64-nat.o amd64-linux-nat.o linux-nat.o \ + proc-service.o linux-thread-db.o linux-fork.o +-NAT_FILE= config/nm-linux.h ++NAT_FILE= nm-linux64.h + NAT_CDEPS = $(srcdir)/proc-service.list + + # The dynamically loaded libthread_db needs access to symbols in the +Index: gdb-7.1.90.20100711/gdb/config/i386/nm-linux64.h +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ gdb-7.1.90.20100711/gdb/config/i386/nm-linux64.h 2010-07-13 19:02:28.000000000 +0200 +@@ -0,0 +1,28 @@ ++/* Native support for GNU/Linux amd64. ++ ++ Copyright 2010 Free Software Foundation, Inc. ++ ++ This file is part of GDB. ++ ++ 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 . */ ++ ++#ifndef NM_LINUX64_H ++#define NM_LINUX64_H ++ ++#include "config/nm-linux.h" ++ ++/* Red Hat backward compatibility with gdb-6.8. */ ++#define target_can_use_hardware_watchpoint(type, cnt, ot) 1 ++ ++#endif /* NM_LINUX64_H */ +Index: gdb-7.1.90.20100711/gdb/target.h +=================================================================== +--- gdb-7.1.90.20100711.orig/gdb/target.h 2010-07-12 23:07:34.000000000 +0200 ++++ gdb-7.1.90.20100711/gdb/target.h 2010-07-13 19:02:28.000000000 +0200 +@@ -1298,8 +1298,10 @@ extern char *normal_pid_to_str (ptid_t p + bp_hardware_breakpoint. CNT is the number of such watchpoints used so far + (including this one?). OTHERTYPE is who knows what... */ + ++#ifndef target_can_use_hardware_watchpoint + #define target_can_use_hardware_watchpoint(TYPE,CNT,OTHERTYPE) \ + (*current_target.to_can_use_hw_breakpoint) (TYPE, CNT, OTHERTYPE); ++#endif + + #define target_region_ok_for_hw_watchpoint(addr, len) \ + (*current_target.to_region_ok_for_hw_watchpoint) (addr, len) +Index: gdb-7.1.90.20100711/gdb/testsuite/gdb.base/watchpoint-hw-before-run.exp +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ gdb-7.1.90.20100711/gdb/testsuite/gdb.base/watchpoint-hw-before-run.exp 2010-07-13 19:02:28.000000000 +0200 +@@ -0,0 +1,40 @@ ++# Copyright 2009, 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 . ++ ++# Arch not supporting hw watchpoints does not imply no_hardware_watchpoints set. ++if {(![istarget "i?86-*-*"] && ![istarget "x86_64-*-*"] ++ && ![istarget "ia64-*-*"]) ++ || [target_info exists gdb,no_hardware_watchpoints]} then { ++ verbose "Skipping watchpoint-hw-before-run test." ++ return ++} ++ ++set test watchpoint-hw-before-run ++set srcfile watchpoint-hw-hit-once.c ++if { [prepare_for_testing ${test}.exp ${test} ${srcfile}] } { ++ return -1 ++} ++ ++gdb_test "rwatch watchee" "ardware read watchpoint 1: watchee" ++ ++# `runto_main' or `runto main' would delete the watchpoint created above. ++ ++if { [gdb_start_cmd] < 0 } { ++ untested start ++ return -1 ++} ++gdb_test "" "main .* at .*" "start" ++ ++gdb_test "continue" "Continuing.\r\nHardware read watchpoint \[0-9\]+: watchee\r\n\r\nValue = 0\r\n.*" diff --git a/gdb-bz555076-gcore-small-height.patch b/gdb-bz555076-gcore-small-height.patch new file mode 100644 index 0000000..acad66b --- /dev/null +++ b/gdb-bz555076-gcore-small-height.patch @@ -0,0 +1,12 @@ +--- a/gdb/gdb_gcore.sh ++++ b/gdb/gdb_gcore.sh +@@ -64,6 +64,9 @@ for pid in $* + do + # Write gdb script for pid $pid. + cat >>$tmpfile < + + * python/py-prettyprint.c (print_children): Add formatting for + matrices. (apply_val_pretty_printer): Detect and deal with matrix + hints. + + +2010-05-31 Chris Moller + + * gdb.python/Makefile.in (EXECUTABLES): Added pr10659. + * gdb.python/pr10659.cc: New file. + * gdb.python/pr10659.exp. New file. + * gdb.python/pr10659.py: New file. + +Index: gdb-7.1/gdb/valprint.h +=================================================================== +--- gdb-7.1.orig/gdb/valprint.h 2010-06-30 14:02:16.000000000 +0200 ++++ gdb-7.1/gdb/valprint.h 2010-06-30 14:35:24.000000000 +0200 +@@ -90,6 +90,9 @@ struct value_print_options + + /* If nonzero, print the value in "summary" form. */ + int summary; ++ ++ /* Affects pretty printing of matrices. */ ++ int prettyprint_matrix; + }; + + /* The global print options set by the user. In general this should +Index: gdb-7.1/gdb/python/py-prettyprint.c +=================================================================== +--- gdb-7.1.orig/gdb/python/py-prettyprint.c 2010-06-30 14:01:40.000000000 +0200 ++++ gdb-7.1/gdb/python/py-prettyprint.c 2010-06-30 14:34:49.000000000 +0200 +@@ -385,7 +385,8 @@ print_children (PyObject *printer, const + + /* Use the prettyprint_arrays option if we are printing an array, + and the pretty option otherwise. */ +- pretty = is_array ? options->prettyprint_arrays : options->pretty; ++ pretty = (is_array || options->prettyprint_matrix) ? ++ options->prettyprint_arrays : options->pretty; + + /* Manufacture a dummy Python frame to work around Python 2.4 bug, + where it insists on having a non-NULL tstate->frame when +@@ -397,6 +398,9 @@ print_children (PyObject *printer, const + goto done; + } + make_cleanup_py_decref (frame); ++ ++ if (options->prettyprint_matrix && recurse == 0) ++ fputs_filtered ("\n", stream); + + done_flag = 0; + for (i = 0; i < options->print_max; ++i) +@@ -431,12 +435,23 @@ print_children (PyObject *printer, const + 3. Other. Always print a ",". */ + if (i == 0) + { +- if (is_py_none) +- fputs_filtered ("{", stream); +- else +- fputs_filtered (" = {", stream); ++ if (options->prettyprint_matrix && recurse == 0) ++ print_spaces_filtered (2 + 2 * recurse, stream); ++ if (is_py_none) ++ { ++ if (options->prettyprint_matrix && strcmp (hint, "array")) ++ { ++ fputs_filtered ("{\n", stream); ++ print_spaces_filtered (4 + 2 * recurse, stream); ++ } ++ else ++ fputs_filtered ("{", stream); ++ } ++ else ++ fputs_filtered (" = {", stream); + } +- ++ else if (options->prettyprint_matrix) ++ print_spaces_filtered (4 + 2 * recurse, stream); + else if (! is_map || i % 2 == 0) + fputs_filtered (pretty ? "," : ", ", stream); + +@@ -465,6 +480,10 @@ print_children (PyObject *printer, const + + if (is_map && i % 2 == 0) + fputs_filtered ("[", stream); ++ else if (options->prettyprint_matrix) ++ { ++ /* Force a do-nothing. */ ++ } + else if (is_array) + { + /* We print the index, not whatever the child method +@@ -539,7 +558,12 @@ print_children (PyObject *printer, const + fputs_filtered ("\n", stream); + print_spaces_filtered (2 * recurse, stream); + } +- fputs_filtered ("}", stream); ++ if (options->prettyprint_matrix) ++ { ++ print_spaces_filtered (4 * recurse, stream); ++ fputs_filtered ("}\n", stream); ++ } ++ else fputs_filtered ("}", stream); + } + + done: +@@ -561,6 +585,7 @@ apply_val_pretty_printer (struct type *t + struct cleanup *cleanups; + int result = 0; + int is_py_none = 0; ++ struct value_print_options *options_copy; + cleanups = ensure_python_env (gdbarch, language); + + /* Instantiate the printer. */ +@@ -582,12 +607,23 @@ apply_val_pretty_printer (struct type *t + + /* If we are printing a map, we want some special formatting. */ + hint = gdbpy_get_display_hint (printer); ++ ++ if (recurse == 0) ++ { ++ options_copy = alloca (sizeof (struct value_print_options)); ++ memcpy (options_copy, options, sizeof (struct value_print_options)); ++ options_copy->prettyprint_matrix = hint && !strcmp (hint, "matrix"); ++ } ++ else options_copy = (struct value_print_options *)options; ++ + make_cleanup (free_current_contents, &hint); + + /* Print the section */ +- is_py_none = print_string_repr (printer, hint, stream, recurse, +- options, language, gdbarch); +- print_children (printer, hint, stream, recurse, options, language, ++ is_py_none = options_copy->prettyprint_matrix ? ++ 1 : print_string_repr (printer, hint, stream, ++ recurse, options_copy, ++ language, gdbarch); ++ print_children (printer, hint, stream, recurse, options_copy, language, + is_py_none); + + result = 1; +Index: gdb-7.1/gdb/testsuite/gdb.python/pr10659.cc +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ gdb-7.1/gdb/testsuite/gdb.python/pr10659.cc 2010-06-30 14:34:49.000000000 +0200 +@@ -0,0 +1,43 @@ ++#include ++#include // /usr/include/c++/4.4.1/bits/vector.tcc ++#include ++ ++using namespace std; ++ ++int use_windows = 9999; ++ ++int ++main(){ ++ vector test1(2,0); ++ test1[0]=8; ++ test1[1]=9; ++ ++ vector< vector > test2(3, vector(2,0)); ++ test2[0][0]=0; ++ test2[0][1]=1; ++ test2[1][0]=2; ++ test2[1][1]=3; ++ test2[2][0]=4; ++ test2[2][1]=5; ++ ++#define NR_ROWS 2 ++#define NR_COLS 3 ++#define NR_PLANES 4 ++ vector rows(NR_ROWS, 0); ++ vector< vector > columns(NR_COLS, rows); ++ vector< vector < vector > > test3(NR_PLANES, columns); ++ ++ cout << "rows.size() = " << rows.size() ++ << ", columns.size() = " << columns.size() ++ << ", test3.size() = " << test3.size() << "\n"; ++ ++ for (int i = 0; i < rows.size(); i++) { ++ for (int j = 0; j < columns.size(); j++) { ++ for (int k = 0; k < test3.size(); k++) { ++ test3[k][j][i] = k * 100 + j * 10 + i; ++ } ++ } ++ } ++ ++ return 0; // break ++} +Index: gdb-7.1/gdb/testsuite/gdb.python/pr10659.exp +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ gdb-7.1/gdb/testsuite/gdb.python/pr10659.exp 2010-06-30 14:34:49.000000000 +0200 +@@ -0,0 +1,82 @@ ++#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 . ++ ++set nl "\[\r\n\]+" ++ ++set testfile pr10659 ++set srcfile ${testfile}.cc ++if [prepare_for_testing $testfile.exp $testfile $srcfile {debug c++}] { ++ return -1 ++} ++ ++#if { [skip_python_tests] } { continue } ++ ++gdb_test "python execfile(\"$srcdir/$subdir/pr10659.py\")" "" ++gdb_test "python gdb.pretty_printers = \[lookup_function\]" "" ++ ++if ![runto_main] then { ++ fail "Can't run to main" ++ return ++} ++ ++gdb_breakpoint [gdb_get_line_number "break"] ++gdb_continue_to_breakpoint "break" ++ ++gdb_test "p test1" "vector of length 2, capacity 2 =.*" ++ ++gdb_test "p test2" "= $nl {$nl {.*" ++ ++# Complete result is: ++# ++# (gdb) p test2 ++# $2 = ++# { ++# {0 1 } ++# {2 3 } ++# {4 5 } ++# } ++ ++ ++gdb_test "p test3" "= $nl {$nl {$nl {.*" ++ ++# Complete result is: ++# ++# (gdb) p test3 ++# $3 = ++# { ++# { ++# {0 1 } ++# {10 11 } ++# {20 21 } ++# } ++# { ++# {100 101 } ++# {110 111 } ++# {120 121 } ++# } ++# { ++# {200 201 } ++# {210 211 } ++# {220 221 } ++# } ++# { ++# {300 301 } ++# {310 311 } ++# {320 321 } ++# } ++# } ++# ++ ++ +Index: gdb-7.1/gdb/testsuite/gdb.python/pr10659.py +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ gdb-7.1/gdb/testsuite/gdb.python/pr10659.py 2010-06-30 14:34:49.000000000 +0200 +@@ -0,0 +1,109 @@ ++# Copyright (C) 2008, 2009 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 . ++ ++import gdb ++import itertools ++import re ++ ++vector_sig = 'std::vector' ++vector_regex = re.compile('^' + vector_sig + '<.*>$') ++ ++class FakeVectorPrinter: ++ "Print a std::vector" ++ ++ class _iterator: ++ def __init__ (self, start, finish): ++ self.item = start ++ self.finish = finish ++ self.count = 0 ++ ++ def __iter__(self): ++ return self ++ ++ def next(self): ++ if self.item == self.finish: ++ raise StopIteration ++ count = self.count ++ self.count = self.count + 1 ++ elt = self.item.dereference() ++ self.item = self.item + 1 ++ return ('[%d]' % count, elt) ++ ++ def __init__(self, typename, val): ++ self.typename = typename ++ self.val = val ++ ++ def children(self): ++ return self._iterator(self.val['_M_impl']['_M_start'], ++ self.val['_M_impl']['_M_finish']) ++ ++ def to_string(self): ++ start = self.val['_M_impl']['_M_start'] ++ finish = self.val['_M_impl']['_M_finish'] ++ end = self.val['_M_impl']['_M_end_of_storage'] ++ return ('std::vector of length %d, capacity %d' ++ % (int (finish - start), int (end - start))) ++ ++ def display_hint(self): ++ itype0 = self.val.type.template_argument(0) ++ itag = itype0.tag ++ if itag and re.match(vector_regex, itag): ++ rc = 'matrix' ++ else: ++ rc = 'array' ++ return rc ++ ++def register_libstdcxx_printers (obj): ++ "Register libstdc++ pretty-printers with objfile Obj." ++ ++ if obj == None: ++ obj = gdb ++ ++ obj.pretty_printers.append (lookup_function) ++ ++def lookup_function (val): ++ "Look-up and return a pretty-printer that can print val." ++ ++ # Get the type. ++ type = val.type; ++ ++ # If it points to a reference, get the reference. ++ if type.code == gdb.TYPE_CODE_REF: ++ type = type.target () ++ ++ # Get the unqualified type, stripped of typedefs. ++ type = type.unqualified ().strip_typedefs () ++ ++ # Get the type name. ++ typename = type.tag ++ if typename == None: ++ return None ++ ++ # Iterate over local dictionary of types to determine ++ # if a printer is registered for that type. Return an ++ # instantiation of the printer if found. ++ for function in fake_pretty_printers_dict: ++ if function.search (typename): ++ return fake_pretty_printers_dict[function] (val) ++ ++ # Cannot find a pretty printer. Return None. ++ return None ++ ++def build_libfakecxx_dictionary (): ++ fake_pretty_printers_dict[vector_regex] = lambda val: FakeVectorPrinter(vector_sig, val) ++ ++fake_pretty_printers_dict = {} ++ ++build_libfakecxx_dictionary () +Index: gdb-7.1/gdb/valprint.c +=================================================================== +--- gdb-7.1.orig/gdb/valprint.c 2010-06-30 13:51:26.000000000 +0200 ++++ gdb-7.1/gdb/valprint.c 2010-06-30 14:35:41.000000000 +0200 +@@ -83,7 +83,8 @@ struct value_print_options user_print_op + 1, /* static_field_print */ + 1, /* pascal_static_field_print */ + 0, /* raw */ +- 0 /* summary */ ++ 0, /* summary */ ++ 0 /* prettyprint_matrix */ + }; + + /* Initialize *OPTS to be a copy of the user print options. */ diff --git a/gdb-bz568248-oom-is-error.patch b/gdb-bz568248-oom-is-error.patch new file mode 100644 index 0000000..2aaf522 --- /dev/null +++ b/gdb-bz568248-oom-is-error.patch @@ -0,0 +1,69 @@ +http://sourceware.org/ml/gdb-patches/2010-06/msg00005.html +Subject: [rfc patch] nomem: internal_error -> error + +Hi, + +unfortunately I see this problem reproducible only with the +archer-jankratochvil-vla branch (VLA = Variable Length Arrays - char[var]). +OTOH this branch I hopefully submit in some form for FSF GDB later. + +In this case (a general problem but tested for example on Fedora 13 i686): + +int +main (int argc, char **argv) +{ + char a[argc]; + return a[0]; +} + +(gdb) start +(gdb) print a +../../gdb/utils.c:1251: internal-error: virtual memory exhausted: can't allocate 4294951689 bytes. + +It is apparently because boundary for the variable `a' is not initialized +there. Users notice it due to Eclipse-CDT trying to automatically display all +the local variables on each step. + + +Apparentl no regressions on {x86_64,x86_64-m32,i686}-fedora13-linux-gnu. +But is anone aware of the reasons to use internal_error there? +I find simple error as a perfectly reasonable there. +(history only tracks it since the initial import) + +IIRC this idea has been discussed with Tom Tromey, not sure of its origin. + +I understand it may be offtopic for FSF GDB but from some GDB crashes I am not +sure if it can happen only due to the VLA variables. + + +Thanks, +Jan + + +gdb/ +2010-06-01 Jan Kratochvil + Tom Tromey + + * utils.c (nomem): Change internal_error to error. + +--- a/gdb/utils.c ++++ b/gdb/utils.c +@@ -1265,15 +1265,9 @@ void + nomem (long size) + { + if (size > 0) +- { +- internal_error (__FILE__, __LINE__, +- _("virtual memory exhausted: can't allocate %ld bytes."), +- size); +- } ++ error (_("virtual memory exhausted: can't allocate %ld bytes."), size); + else +- { +- internal_error (__FILE__, __LINE__, _("virtual memory exhausted.")); +- } ++ error (_("virtual memory exhausted.")); + } + + /* The xmalloc() (libiberty.h) family of memory management routines. + diff --git a/gdb-bz575292-delayed-physname.patch b/gdb-bz575292-delayed-physname.patch new file mode 100644 index 0000000..e15391d --- /dev/null +++ b/gdb-bz575292-delayed-physname.patch @@ -0,0 +1,630 @@ +Made more safe (but less effective) by using a linked list. + +Based on: + Re: [RFA] Delayed physname computation + http://sourceware.org/ml/gdb-patches/2010-05/msg00248.html + +Neither its obstack-leak.patch nor + [patch] Fix duplicate types for single DIE + http://sourceware.org/ml/gdb-patches/2010-05/msg00271.html +is needed as the linked list is used instead. + +Index: gdb-7.1.90.20100721/gdb/dwarf2read.c +=================================================================== +--- gdb-7.1.90.20100721.orig/gdb/dwarf2read.c 2010-07-22 11:59:19.000000000 +0200 ++++ gdb-7.1.90.20100721/gdb/dwarf2read.c 2010-07-22 12:00:08.000000000 +0200 +@@ -253,6 +253,28 @@ struct comp_unit_head + unsigned int first_die_offset; + }; + ++/* Type used for delaying computation of method physnames. ++ See comments for compute_delayed_physnames. */ ++struct delayed_method_info ++{ ++ struct delayed_method_info *next; ++ ++ /* The type to which the method is attached, i.e., its parent class. */ ++ struct type *type; ++ ++ /* The index of the method in the type's function fieldlists. */ ++ int fnfield_index; ++ ++ /* The index of the method in the fieldlist. */ ++ int index; ++ ++ /* The name of the DIE. */ ++ const char *name; ++ ++ /* The DIE associated with this method. */ ++ struct die_info *die; ++}; ++ + /* Internal state when decoding a particular compilation unit. */ + struct dwarf2_cu + { +@@ -331,6 +353,10 @@ struct dwarf2_cu + /* Header data from the line table, during full symbol processing. */ + struct line_header *line_header; + ++ /* A list of methods which need to have physnames computed ++ after all type information has been read. */ ++ struct delayed_method_info *method_list; ++ + /* Mark used when releasing cached dies. */ + unsigned int mark : 1; + +@@ -1239,6 +1265,9 @@ static gdb_byte *partial_read_comp_unit_ + static void init_cu_die_reader (struct die_reader_specs *reader, + struct dwarf2_cu *cu); + ++static const char *dwarf2_physname (char *name, struct die_info *die, ++ struct dwarf2_cu *cu); ++ + #if WORDS_BIGENDIAN + + /* Convert VALUE between big- and little-endian. */ +@@ -4103,6 +4132,58 @@ load_full_comp_unit (struct dwarf2_per_c + discard_cleanups (free_cu_cleanup); + } + ++/* Add a DIE to the delayed physname list. */ ++static void ++add_to_method_list (struct type *type, int fnfield_index, int index, ++ const char *name, struct die_info *die, ++ struct dwarf2_cu *cu) ++{ ++ struct delayed_method_info *mi; ++ ++ mi = xmalloc (sizeof (*mi)); ++ mi->next = cu->method_list; ++ cu->method_list = mi; ++ mi->type = type; ++ mi->fnfield_index = fnfield_index; ++ mi->index = index; ++ mi->name = name; ++ mi->die = die; ++} ++ ++/* Compute the physnames of any methods on the CU's method list. ++ ++ The computation of method physnames is delayed in order to avoid the ++ (bad) condition that one of the method's formal parameters is of an as yet ++ incomplete type. */ ++static void ++compute_delayed_physnames (struct dwarf2_cu *cu) ++{ ++ struct delayed_method_info *mi; ++ ++ for (mi = cu->method_list; mi; mi = mi->next) ++ { ++ char *physname; ++ struct fn_fieldlist *fn_flp ++ = &TYPE_FN_FIELDLIST (mi->type, mi->fnfield_index); ++ physname = (char *) dwarf2_physname ((char *) mi->name, mi->die, cu); ++ fn_flp->fn_fields[mi->index].physname = physname ? physname : ""; ++ } ++} ++ ++static void ++method_list_cleanup (void *arg) ++{ ++ struct delayed_method_info **method_list_pointer = arg; ++ ++ while (*method_list_pointer) ++ { ++ struct delayed_method_info *mi = *method_list_pointer; ++ ++ *method_list_pointer = mi->next; ++ xfree (mi); ++ } ++} ++ + /* Generate full symbol information for PST and CU, whose DIEs have + already been loaded into memory. */ + +@@ -4113,7 +4194,7 @@ process_full_comp_unit (struct dwarf2_pe + struct objfile *objfile = per_cu->objfile; + CORE_ADDR lowpc, highpc; + struct symtab *symtab; +- struct cleanup *back_to; ++ struct cleanup *back_to, *delayed_list_cleanup; + CORE_ADDR baseaddr; + + baseaddr = ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile)); +@@ -4123,11 +4204,22 @@ process_full_comp_unit (struct dwarf2_pe + + cu->list_in_scope = &file_symbols; + ++ /* If methods were found in the partial symbol table, we allocate one ++ big buffer to hold the entire delayed list for the CU. */ ++ delayed_list_cleanup = make_cleanup (method_list_cleanup, ++ &cu->method_list); ++ + dwarf2_find_base_address (cu->dies, cu); + + /* Do line number decoding in read_file_scope () */ + process_die (cu->dies, cu); + ++ /* Now that we have processed all the DIEs in the CU, all the types ++ should be complete, and it should now be safe to compute all of the ++ physnames. */ ++ compute_delayed_physnames (cu); ++ do_cleanups (delayed_list_cleanup); ++ + /* Some compilers don't define a DW_AT_high_pc attribute for the + compilation unit. If the DW_AT_high_pc is missing, synthesize + it, by scanning the DIE's below the compilation unit. */ +@@ -5838,7 +5930,6 @@ dwarf2_add_member_fn (struct field_info + int i; + struct fn_field *fnp; + char *fieldname; +- char *physname; + struct nextfnfield *new_fnfield; + struct type *this_type; + +@@ -5850,9 +5941,6 @@ dwarf2_add_member_fn (struct field_info + if (fieldname == NULL) + return; + +- /* Get the mangled name. */ +- physname = (char *) dwarf2_physname (fieldname, die, cu); +- + /* Look up member function name in fieldlist. */ + for (i = 0; i < fip->nfnfields; i++) + { +@@ -5878,7 +5966,7 @@ dwarf2_add_member_fn (struct field_info + flp->name = fieldname; + flp->length = 0; + flp->head = NULL; +- fip->nfnfields++; ++ i = fip->nfnfields++; + } + + /* Create a new member function field and chain it to the field list +@@ -5892,9 +5980,19 @@ dwarf2_add_member_fn (struct field_info + + /* Fill in the member function field info. */ + fnp = &new_fnfield->fnfield; +- /* The name is already allocated along with this objfile, so we don't +- need to duplicate it for the type. */ +- fnp->physname = physname ? physname : ""; ++ ++ /* Delay processing of the physname until later. */ ++ if (cu->language == language_cplus || cu->language == language_java) ++ { ++ add_to_method_list (type, i, flp->length - 1, fieldname, ++ die, cu); ++ } ++ else ++ { ++ char *physname = (char *) dwarf2_physname (fieldname, die, cu); ++ fnp->physname = physname ? physname : ""; ++ } ++ + fnp->type = alloc_type (objfile); + this_type = read_type_die (die, cu); + if (this_type && TYPE_CODE (this_type) == TYPE_CODE_FUNC) +@@ -5920,7 +6018,7 @@ dwarf2_add_member_fn (struct field_info + } + else + complaint (&symfile_complaints, _("member function type missing for '%s'"), +- physname); ++ dwarf2_full_name (fieldname, die, cu)); + + /* Get fcontext from DW_AT_containing_type if present. */ + if (dwarf2_attr (die, DW_AT_containing_type, cu) != NULL) +@@ -8299,7 +8397,9 @@ load_partial_dies (bfd *abfd, gdb_byte * + || last_die->tag == DW_TAG_interface_type + || last_die->tag == DW_TAG_structure_type + || last_die->tag == DW_TAG_union_type)) +- || (cu->language == language_ada ++ || ((cu->language == language_ada ++ || cu->language == language_cplus ++ || cu->language == language_java) + && (last_die->tag == DW_TAG_subprogram + || last_die->tag == DW_TAG_lexical_block)))) + { +Index: gdb-7.1.90.20100721/gdb/testsuite/gdb.dwarf2/pr11465.S +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ gdb-7.1.90.20100721/gdb/testsuite/gdb.dwarf2/pr11465.S 2010-07-22 11:59:29.000000000 +0200 +@@ -0,0 +1,355 @@ ++/* 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 . */ ++ ++/* Compiled from: ++ ++ namespace N ++ { ++ class C ++ { ++ public: ++ typedef void (*t) (C); ++ C (t) {} ++ }; ++ typedef C::t u; ++ u f; ++ C c (f); ++ }; ++ ++ int ++ main () ++ { ++ return 0; ++ } ++*/ ++ ++ .text ++_ZN1N1cE: ++ .section .debug_info ++d: ++ .long .Ldebug_info_end - 1f /* Length of CU info */ ++1: ++ .2byte 0x2 /* DWARF version number */ ++ .long .Ldebug_abbrev0 /* Abbrev offset */ ++ .byte 0x4 /* Pointer size */ ++dieb: .uleb128 0x1 /* DW_TAG_compile_unit */ ++ .long .LASF4 /* DW_AT_producer */ ++ .byte 0x4 /* DW_AT_language */ ++ .long .LASF5 /* DW_AT_name */ ++ .long .LASF6 /* DW_AT_comp_dir */ ++ .long 0x0 /* DW_AT_low_pc */ ++ .long 0x0 /* DW_AT_high_pc */ ++ .long 0x0 /* DW_AT_entry_pc */ ++die29: .uleb128 0x2 /* DW_TAG_namespace */ ++ .string "N" /* DW_AT_name */ ++die32: .uleb128 0x3 /* DW_TAG_class_type */ ++ .string "C" /* DW_AT_name */ ++ .byte 0x1 /* DW_AT_declaration */ ++die36: .uleb128 0x4 /* DW_TAG_typedef */ ++ .string "u" /* DW_AT_name */ ++ .long die7e-d /* DW_AT_type */ ++die3f: .uleb128 0x5 /* DW_TAG_variable */ ++ .string "f" /* DW_AT_name */ ++ .long .LASF0 /* DW_AT_MIPS_linkage_name */ ++ .long die36-d /* DW_AT_type */ ++ .byte 0x1 /* DW_AT_external */ ++ .byte 0x1 /* DW_AT_declaration */ ++die4e: .uleb128 0x5 /* DW_TAG_variable */ ++ .string "c" /* DW_AT_name */ ++ .long .LASF1 /* DW_AT_MIPS_linkage_name */ ++ .long die5e-d /* DW_AT_type */ ++ .byte 0x1 /* DW_AT_external */ ++ .byte 0x1 /* DW_AT_declaration */ ++ .byte 0x0 ++die5e: .uleb128 0x6 /* DW_TAG_class_type */ ++ .long die32-d /* DW_AT_specification */ ++ .byte 0x1 /* DW_AT_byte_size */ ++die6a: .uleb128 0x7 /* DW_TAG_subprogram */ ++ .byte 0x1 /* DW_AT_external */ ++ .string "C" /* DW_AT_name */ ++ .byte 0x1 /* DW_AT_declaration */ ++die71: .uleb128 0x8 /* DW_TAG_formal_parameter */ ++ .long die8f-d /* DW_AT_type */ ++ .byte 0x1 /* DW_AT_artificial */ ++die77: .uleb128 0x9 /* DW_TAG_formal_parameter */ ++ .long die7e-d /* DW_AT_type */ ++ .byte 0x0 ++ .byte 0x0 ++die7e: .uleb128 0xa /* DW_TAG_pointer_type */ ++ .byte 0x4 /* DW_AT_byte_size */ ++ .long die84-d /* DW_AT_type */ ++die84: .uleb128 0xb /* DW_TAG_subroutine_type */ ++die89: .uleb128 0x9 /* DW_TAG_formal_parameter */ ++ .long die5e-d /* DW_AT_type */ ++ .byte 0x0 ++die8f: .uleb128 0xa /* DW_TAG_pointer_type */ ++ .byte 0x4 /* DW_AT_byte_size */ ++ .long die5e-d /* DW_AT_type */ ++die95: .uleb128 0xc /* DW_TAG_subprogram */ ++ .long die6a-d /* DW_AT_specification */ ++ .byte 0x2 /* DW_AT_inline */ ++die9f: .uleb128 0xd /* DW_TAG_formal_parameter */ ++ .long .LASF7 /* DW_AT_name */ ++ .long dieaf-d /* DW_AT_type */ ++ .byte 0x1 /* DW_AT_artificial */ ++diea9: .uleb128 0x9 /* DW_TAG_formal_parameter */ ++ .long die7e-d /* DW_AT_type */ ++ .byte 0x0 ++dieaf: .uleb128 0xe /* DW_TAG_const_type */ ++ .long die8f-d /* DW_AT_type */ ++dieb4: .uleb128 0xf /* DW_TAG_subprogram */ ++ .long die95-d /* DW_AT_abstract_origin */ ++ .long _ZN1N1cE /* DW_AT_low_pc */ ++ .long _ZN1N1cE /* DW_AT_high_pc */ ++diec9: .uleb128 0x10 /* DW_TAG_subprogram */ ++ .long die9f-d /* DW_AT_abstract_origin */ ++ .byte 2f-1f /* DW_AT_location */ ++1: ++ .byte 0x50 /* DW_OP_reg0 */ ++2: ++died1: .uleb128 0x10 /* DW_TAG_formal_parameter */ ++ .long diea9-d /* DW_AT_abstract_origin */ ++ .byte 2f-1f /* DW_AT_location */ ++1: ++ .byte 0x51 /* DW_OP_reg1 */ ++2: ++ .byte 0x0 ++dieda: .uleb128 0x11 /* DW_TAG_subprogram */ ++ .byte 0x1 /* DW_AT_external */ ++ .long .LASF8 /* DW_AT_name */ ++ .long dief2-d /* DW_AT_type */ ++ .long _ZN1N1cE /* DW_AT_low_pc */ ++ .long _ZN1N1cE /* DW_AT_high_pc */ ++dief2: .uleb128 0x12 /* DW_TAG_base_type */ ++ .byte 0x4 /* DW_AT_byte_size */ ++ .byte 0x5 /* DW_AT_encoding */ ++ .string "int" /* DW_AT_name */ ++die149: .uleb128 0x16 /* DW_TAG_variable */ ++ .long die4e-d /* DW_AT_specification */ ++ .byte 0x5 /* DW_AT_location */ ++ .byte 0x3 ++ .long _ZN1N1cE ++ .byte 0x0 ++.Ldebug_info_end: ++ .section .debug_abbrev ++.Ldebug_abbrev0: ++ .uleb128 0x1 /* abbrev code*/ ++ .uleb128 0x11 /* DW_TAG_compile_unit */ ++ .byte 0x1 /* DW_children_yes */ ++ .uleb128 0x25 /* DW_AT_producer*/ ++ .uleb128 0xe /* DW_FORM_strp */ ++ .uleb128 0x13 /* DW_AT_language */ ++ .uleb128 0xb /* DW_FORM_data1 */ ++ .uleb128 0x3 /* DW_AT_name */ ++ .uleb128 0xe /* DW_FORM_strp */ ++ .uleb128 0x1b /* DW_AT_comp_dir */ ++ .uleb128 0xe /* DW_FORM_strp */ ++ .uleb128 0x11 /* DW_AT_low_pc */ ++ .uleb128 0x1 /* DW_FORM_addr */ ++ .uleb128 0x12 /* DW_AT_high_pc */ ++ .uleb128 0x1 /* DW_FORM_addr */ ++ .uleb128 0x52 /* DW_AT_entry_pc */ ++ .uleb128 0x1 /* DW_FORM_addr */ ++ .byte 0x0 ++ .byte 0x0 ++ .uleb128 0x2 /* abbrev code */ ++ .uleb128 0x39 /* DW_TAG_namespace */ ++ .byte 0x1 /* DW_children_yes */ ++ .uleb128 0x3 /* DW_AT_name */ ++ .uleb128 0x8 /* DW_FORM_string */ ++ .byte 0x0 ++ .byte 0x0 ++ .uleb128 0x3 /* abbrev code */ ++ .uleb128 0x2 /* DW_TAG_class_type */ ++ .byte 0x0 /* DW_has_children_no */ ++ .uleb128 0x3 /* DW_AT_name */ ++ .uleb128 0x8 /* DW_FORM_string */ ++ .uleb128 0x3c /* DW_AT_declaration */ ++ .uleb128 0xc /* DW_FORM_flag */ ++ .byte 0x0 ++ .byte 0x0 ++ .uleb128 0x4 /* abbrev code */ ++ .uleb128 0x16 /* DW_TAG_typedef */ ++ .byte 0x0 /* DW_has_children_no */ ++ .uleb128 0x3 /* DW_AT_name */ ++ .uleb128 0x8 /* DW_FORM_string */ ++ .uleb128 0x49 /* DW_AT_type */ ++ .uleb128 0x13 /* DW_FORM_ref4 */ ++ .byte 0x0 ++ .byte 0x0 ++ .uleb128 0x5 /* abbrev code */ ++ .uleb128 0x34 /* DW_TAG_variable */ ++ .byte 0x0 /* DW_has_children_no */ ++ .uleb128 0x3 /* DW_AT_name */ ++ .uleb128 0x8 /* DW_FORM_string */ ++ .uleb128 0x2007 /* DW_AT_MIPS_linkage_name */ ++ .uleb128 0xe /* DW_FORM_strp */ ++ .uleb128 0x49 /* DW_AT_TYPE */ ++ .uleb128 0x13 /* DW_FORM_ref4 */ ++ .uleb128 0x3f /* DW_AT_external */ ++ .uleb128 0xc /* DW_FORM_flag */ ++ .uleb128 0x3c /* DW_AT_declaration */ ++ .uleb128 0xc /* DW_FORM_flag */ ++ .byte 0x0 ++ .byte 0x0 ++ .uleb128 0x6 /* abbrev code */ ++ .uleb128 0x2 /* DW_TAG_class_type */ ++ .byte 0x1 /* DW_has_children_yes */ ++ .uleb128 0x47 /* DW_AT_specification */ ++ .uleb128 0x13 /* DW_FORM_ref4 */ ++ .uleb128 0xb /* DW_AT_byte_size */ ++ .uleb128 0xb /* DW_FORM_data1 */ ++ .byte 0x0 ++ .byte 0x0 ++ .uleb128 0x7 /* abbrev code */ ++ .uleb128 0x2e /* DW_TAG_subprogra */ ++ .byte 0x1 /* DW_has_children_yes */ ++ .uleb128 0x3f /* DW_AT_external */ ++ .uleb128 0xc /* DW_FORM_flag */ ++ .uleb128 0x3 /* DW_AT_name */ ++ .uleb128 0x8 /* DW_FORM_string */ ++ .uleb128 0x3c /* DW_AT_declaration */ ++ .uleb128 0xc /* DW_FORM_flag */ ++ .byte 0x0 ++ .byte 0x0 ++ .uleb128 0x8 /* abbrev code */ ++ .uleb128 0x5 /* DW_TAG_formal_parameter */ ++ .byte 0x0 /* DW_has_children_no */ ++ .uleb128 0x49 /* DW_AT_type */ ++ .uleb128 0x13 /* DW_FORM_ref4 */ ++ .uleb128 0x34 /* DW_AT_artificial */ ++ .uleb128 0xc /* DW_FORM_flag */ ++ .byte 0x0 ++ .byte 0x0 ++ .uleb128 0x9 /* abbrev code */ ++ .uleb128 0x5 /* DW_TAG_formal_parameter */ ++ .byte 0x0 /* DW_has_children_no */ ++ .uleb128 0x49 /* DW_AT_type */ ++ .uleb128 0x13 /* DW_FORM_ref4 */ ++ .byte 0x0 ++ .byte 0x0 ++ .uleb128 0xa /* abbrev code */ ++ .uleb128 0xf /* DW_TAG_pointer_type */ ++ .byte 0x0 /* DW_has_children_no */ ++ .uleb128 0xb /* DW_AT_byte_size */ ++ .uleb128 0xb /* DW_FORM_data1 */ ++ .uleb128 0x49 /* DW_AT_type */ ++ .uleb128 0x13 /* DW_FORM_ref4 */ ++ .byte 0x0 ++ .byte 0x0 ++ .uleb128 0xb /* abbrev code */ ++ .uleb128 0x15 /* DW_TAG_subroutine_type */ ++ .byte 0x1 /* DW_has_children_yes */ ++ .byte 0x0 ++ .byte 0x0 ++ .uleb128 0xc /* abbrev code */ ++ .uleb128 0x2e /* DW_TAG_subprogram */ ++ .byte 0x1 /* DW_has_children_yes */ ++ .uleb128 0x47 /* DW_AT_specification */ ++ .uleb128 0x13 /* DW_FORM_ref4 */ ++ .uleb128 0x20 /* DW_AT_inline */ ++ .uleb128 0xb /* DW_FORM_data1 */ ++ .byte 0x0 ++ .byte 0x0 ++ .uleb128 0xd /* abbrev code */ ++ .uleb128 0x5 /* DW_TAG_formal_parameter */ ++ .byte 0x0 /* DW_has_children_no */ ++ .uleb128 0x3 /* DW_AT_name */ ++ .uleb128 0xe /* DW_FORM_strp */ ++ .uleb128 0x49 /* DW_AT_type */ ++ .uleb128 0x13 /* DW_FORM_ref4 */ ++ .uleb128 0x34 /* DW_AT_artificial */ ++ .uleb128 0xc /* DW_FORM_flag */ ++ .byte 0x0 ++ .byte 0x0 ++ .uleb128 0xe /* abbrev code */ ++ .uleb128 0x26 /* DW_TAG_const_type */ ++ .byte 0x0 /* DW_has_children_no */ ++ .uleb128 0x49 /* DW_AT_type */ ++ .uleb128 0x13 /* DW_FORM_ref4 */ ++ .byte 0x0 ++ .byte 0x0 ++ .uleb128 0xf /* abbrev code */ ++ .uleb128 0x2e /* DW_TAG_subprogram */ ++ .byte 0x1 /* DW_has_children_yes */ ++ .uleb128 0x31 /* DW_AT_abstract_origin */ ++ .uleb128 0x13 /* DW_FORM_ref4 */ ++ .uleb128 0x11 /* DW_AT_low_pc */ ++ .uleb128 0x1 /* DW_FORM_addr */ ++ .uleb128 0x12 /* DW_AT_high_pc */ ++ .uleb128 0x1 /* DW_FORM_addr */ ++ .byte 0x0 ++ .byte 0x0 ++ .uleb128 0x10 /* abbrev code */ ++ .uleb128 0x5 /* DW_TAG_formal_parameter */ ++ .byte 0x0 /* DW_has_children_no */ ++ .uleb128 0x31 /* DW_AT_abstract_origin */ ++ .uleb128 0x13 /* DW_FORM_ref4 */ ++ .uleb128 0x2 /* DW_AT_location */ ++ .uleb128 0xa /* DW_FORM_block1 */ ++ .byte 0x0 ++ .byte 0x0 ++ .uleb128 0x11 /* abbrev code */ ++ .uleb128 0x2e /* DW_TAG_subprogram */ ++ .byte 0x0 /* DW_has_children_no */ ++ .uleb128 0x3f /* DW_AT_external */ ++ .uleb128 0xc /* DW_FORM_flag */ ++ .uleb128 0x3 /* DW_AT_name */ ++ .uleb128 0xe /* DW_FORM_strp */ ++ .uleb128 0x49 /* DW_AT_type */ ++ .uleb128 0x13 /* DW_FORM_ref4 */ ++ .uleb128 0x11 /* DW_AT_low_pc */ ++ .uleb128 0x1 /* DW_FORM_addr */ ++ .uleb128 0x12 /* DW_AT_high_pc */ ++ .uleb128 0x1 /* DW_FORM_addr */ ++ .byte 0x0 ++ .byte 0x0 ++ .uleb128 0x12 /* abbrev code */ ++ .uleb128 0x24 /* DW_TAG_base_type */ ++ .byte 0x0 /* DW_has_children_no */ ++ .uleb128 0xb /* DW_AT_byte_size */ ++ .uleb128 0xb /* DW_FORM_data1 */ ++ .uleb128 0x3e /* DW_AT_encoding */ ++ .uleb128 0xb /* DW_FORM_data1 */ ++ .uleb128 0x3 /* DW_AT_name */ ++ .uleb128 0x8 /* DW_FORM_string */ ++ .byte 0x0 ++ .byte 0x0 ++ .uleb128 0x16 /* abbrev code */ ++ .uleb128 0x34 /* DW_TAG_variable */ ++ .byte 0x0 /* DW_has_children_no */ ++ .uleb128 0x47 /* DW_AT_specification */ ++ .uleb128 0x13 /* DW_FORM_ref4 */ ++ .uleb128 0x2 /* DW_AT_location */ ++ .uleb128 0xa /* DW_FORM_block1 */ ++ .byte 0x0 ++ .byte 0x0 ++ .byte 0x0 ++ .section .debug_str ++.LASF0: ++ .string "_ZN1N1fE" ++.LASF7: ++ .string "this" ++.LASF6: ++ .string "" ++.LASF8: ++ .string "main" ++.LASF1: ++ .string "_ZN1N1cE" ++.LASF5: ++ .string "pr11465.cc" ++.LASF4: ++ .string "GNU C++ 4.4.2" ++ .ident "GCC: (GNU) 4.4.2" +Index: gdb-7.1.90.20100721/gdb/testsuite/gdb.dwarf2/pr11465.exp +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ gdb-7.1.90.20100721/gdb/testsuite/gdb.dwarf2/pr11465.exp 2010-07-22 11:59:29.000000000 +0200 +@@ -0,0 +1,39 @@ ++# 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 . ++ ++# This test can only be run on targets which support DWARF-2 and use gas. ++# For now pick a sampling of likely targets. ++if {![istarget *-*-linux*] ++ && ![istarget *-*-gnu*] ++ && ![istarget *-*-elf*] ++ && ![istarget *-*-openbsd*] ++ && ![istarget arm-*-eabi*] ++ && ![istarget powerpc-*-eabi*]} { ++ return 0 ++} ++ ++set testfile "pr11465" ++set srcfile ${testfile}.S ++set executable ${testfile}.x ++set binfile ${objdir}/${subdir}/${executable} ++ ++if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" object {}] != "" } { ++ return -1 ++} ++ ++clean_restart $executable ++ ++# Test delayed physname computations ++gdb_test "p N::c.C" { = {void \(N::C \*, void \(\*\)\(N::C\)\)}.*} diff --git a/gdb-bz592031-siginfo-lost-1of5.patch b/gdb-bz592031-siginfo-lost-1of5.patch new file mode 100644 index 0000000..16c789f --- /dev/null +++ b/gdb-bz592031-siginfo-lost-1of5.patch @@ -0,0 +1,87 @@ +http://sourceware.org/ml/gdb-patches/2010-08/msg00559.html +http://sourceware.org/ml/gdb-cvs/2010-08/msg00199.html + +### src/gdb/ChangeLog 2010/08/31 18:08:42 1.12129 +### src/gdb/ChangeLog 2010/08/31 18:11:48 1.12130 +## -1,5 +1,14 @@ + 2010-08-31 Jan Kratochvil + ++ Make linux_get_siginfo_type `type *' unique. ++ * linux-tdep.c (linux_gdbarch_data_handle, struct linux_gdbarch_data) ++ (init_linux_gdbarch_data, get_linux_gdbarch_data): New. ++ (linux_get_siginfo_type): New variable linux_gdbarch_data. Initialize ++ it. Use linux_gdbarch_data->siginfo_type as a persistent storage. ++ (_initialize_linux_tdep): New. ++ ++2010-08-31 Jan Kratochvil ++ + Code cleanup. + * defs.h (find_memory_region_ftype): New typedef. + (exec_set_find_memory_regions): Use it. +Index: gdb-7.2/gdb/linux-tdep.c +=================================================================== +--- gdb-7.2.orig/gdb/linux-tdep.c 2010-09-25 15:30:50.000000000 +0200 ++++ gdb-7.2/gdb/linux-tdep.c 2010-09-25 15:31:54.000000000 +0200 +@@ -26,18 +26,42 @@ + #include "value.h" + #include "infcall.h" + ++static struct gdbarch_data *linux_gdbarch_data_handle; ++ ++struct linux_gdbarch_data ++ { ++ struct type *siginfo_type; ++ }; ++ ++static void * ++init_linux_gdbarch_data (struct gdbarch *gdbarch) ++{ ++ return GDBARCH_OBSTACK_ZALLOC (gdbarch, struct linux_gdbarch_data); ++} ++ ++static struct linux_gdbarch_data * ++get_linux_gdbarch_data (struct gdbarch *gdbarch) ++{ ++ return gdbarch_data (gdbarch, linux_gdbarch_data_handle); ++} ++ + /* This function is suitable for architectures that don't + extend/override the standard siginfo structure. */ + + struct type * + linux_get_siginfo_type (struct gdbarch *gdbarch) + { ++ struct linux_gdbarch_data *linux_gdbarch_data; + struct type *int_type, *uint_type, *long_type, *void_ptr_type; + struct type *uid_type, *pid_type; + struct type *sigval_type, *clock_type; + struct type *siginfo_type, *sifields_type; + struct type *type; + ++ linux_gdbarch_data = get_linux_gdbarch_data (gdbarch); ++ if (linux_gdbarch_data->siginfo_type != NULL) ++ return linux_gdbarch_data->siginfo_type; ++ + int_type = arch_integer_type (gdbarch, gdbarch_int_bit (gdbarch), + 0, "int"); + uint_type = arch_integer_type (gdbarch, gdbarch_int_bit (gdbarch), +@@ -137,6 +161,8 @@ linux_get_siginfo_type (struct gdbarch * + "_sifields", sifields_type, + TYPE_LENGTH (long_type)); + ++ linux_gdbarch_data->siginfo_type = siginfo_type; ++ + return siginfo_type; + } + +@@ -154,3 +180,10 @@ linux_has_shared_address_space (void) + + return target_is_uclinux; + } ++ ++void ++_initialize_linux_tdep (void) ++{ ++ linux_gdbarch_data_handle = ++ gdbarch_data_register_post_init (init_linux_gdbarch_data); ++} diff --git a/gdb-bz592031-siginfo-lost-2of5.patch b/gdb-bz592031-siginfo-lost-2of5.patch new file mode 100644 index 0000000..c5184e0 --- /dev/null +++ b/gdb-bz592031-siginfo-lost-2of5.patch @@ -0,0 +1,139 @@ +http://sourceware.org/ml/gdb-patches/2010-09/msg00430.html +http://sourceware.org/ml/gdb-cvs/2010-09/msg00152.html + +### src/gdb/ChangeLog 2010/09/24 11:15:51 1.12199 +### src/gdb/ChangeLog 2010/09/24 13:41:42 1.12200 +## -1,5 +1,12 @@ + 2010-09-24 Pedro Alves + ++ * amd64-linux-nat.c (compat_siginfo_from_siginfo) ++ (siginfo_from_compat_siginfo): Also copy si_pid and si_uid when ++ si_code is < 0. Check for si_code == SI_TIMER before checking for ++ si_code < 0. ++ ++2010-09-24 Pedro Alves ++ + * objfiles.h (ALL_OBJSECTIONS): Handle breaks in the inner loop. + + 2010-09-22 Joel Brobecker +--- src/gdb/amd64-linux-nat.c 2010/04/22 20:02:55 1.32 ++++ src/gdb/amd64-linux-nat.c 2010/09/24 13:41:43 1.33 +@@ -574,8 +574,10 @@ + to->si_errno = from->si_errno; + to->si_code = from->si_code; + +- if (to->si_code < 0) ++ if (to->si_code == SI_TIMER) + { ++ to->cpt_si_timerid = from->si_timerid; ++ to->cpt_si_overrun = from->si_overrun; + to->cpt_si_ptr = (intptr_t) from->si_ptr; + } + else if (to->si_code == SI_USER) +@@ -583,10 +585,10 @@ + to->cpt_si_pid = from->si_pid; + to->cpt_si_uid = from->si_uid; + } +- else if (to->si_code == SI_TIMER) ++ else if (to->si_code < 0) + { +- to->cpt_si_timerid = from->si_timerid; +- to->cpt_si_overrun = from->si_overrun; ++ to->cpt_si_pid = from->si_pid; ++ to->cpt_si_uid = from->si_uid; + to->cpt_si_ptr = (intptr_t) from->si_ptr; + } + else +@@ -628,8 +630,10 @@ + to->si_errno = from->si_errno; + to->si_code = from->si_code; + +- if (to->si_code < 0) ++ if (to->si_code == SI_TIMER) + { ++ to->si_timerid = from->cpt_si_timerid; ++ to->si_overrun = from->cpt_si_overrun; + to->si_ptr = (void *) (intptr_t) from->cpt_si_ptr; + } + else if (to->si_code == SI_USER) +@@ -637,10 +641,10 @@ + to->si_pid = from->cpt_si_pid; + to->si_uid = from->cpt_si_uid; + } +- else if (to->si_code == SI_TIMER) ++ if (to->si_code < 0) + { +- to->si_timerid = from->cpt_si_timerid; +- to->si_overrun = from->cpt_si_overrun; ++ to->si_pid = from->cpt_si_pid; ++ to->si_uid = from->cpt_si_uid; + to->si_ptr = (void *) (intptr_t) from->cpt_si_ptr; + } + else +### src/gdb/gdbserver/ChangeLog 2010/09/13 19:11:03 1.431 +### src/gdb/gdbserver/ChangeLog 2010/09/24 13:41:43 1.432 +## -1,3 +1,10 @@ ++2010-09-24 Pedro Alves ++ ++ * linux-x86-low.c (compat_siginfo_from_siginfo) ++ (siginfo_from_compat_siginfo): Also copy si_pid and si_uid when ++ si_code is < 0. Check for si_code == SI_TIMER before checking for ++ si_code < 0. ++ + 2010-09-13 Joel Brobecker + + * lynx-i386-low.c: New file. +--- src/gdb/gdbserver/linux-x86-low.c 2010/08/27 00:16:48 1.23 ++++ src/gdb/gdbserver/linux-x86-low.c 2010/09/24 13:41:43 1.24 +@@ -792,8 +792,10 @@ + to->si_errno = from->si_errno; + to->si_code = from->si_code; + +- if (to->si_code < 0) ++ if (to->si_code == SI_TIMER) + { ++ to->cpt_si_timerid = from->si_timerid; ++ to->cpt_si_overrun = from->si_overrun; + to->cpt_si_ptr = (intptr_t) from->si_ptr; + } + else if (to->si_code == SI_USER) +@@ -801,10 +803,10 @@ + to->cpt_si_pid = from->si_pid; + to->cpt_si_uid = from->si_uid; + } +- else if (to->si_code == SI_TIMER) ++ else if (to->si_code < 0) + { +- to->cpt_si_timerid = from->si_timerid; +- to->cpt_si_overrun = from->si_overrun; ++ to->cpt_si_pid = from->si_pid; ++ to->cpt_si_uid = from->si_uid; + to->cpt_si_ptr = (intptr_t) from->si_ptr; + } + else +@@ -846,8 +848,10 @@ + to->si_errno = from->si_errno; + to->si_code = from->si_code; + +- if (to->si_code < 0) ++ if (to->si_code == SI_TIMER) + { ++ to->si_timerid = from->cpt_si_timerid; ++ to->si_overrun = from->cpt_si_overrun; + to->si_ptr = (void *) (intptr_t) from->cpt_si_ptr; + } + else if (to->si_code == SI_USER) +@@ -855,10 +859,10 @@ + to->si_pid = from->cpt_si_pid; + to->si_uid = from->cpt_si_uid; + } +- else if (to->si_code == SI_TIMER) ++ else if (to->si_code < 0) + { +- to->si_timerid = from->cpt_si_timerid; +- to->si_overrun = from->cpt_si_overrun; ++ to->si_pid = from->cpt_si_pid; ++ to->si_uid = from->cpt_si_uid; + to->si_ptr = (void *) (intptr_t) from->cpt_si_ptr; + } + else diff --git a/gdb-bz592031-siginfo-lost-3of5.patch b/gdb-bz592031-siginfo-lost-3of5.patch new file mode 100644 index 0000000..e45c83d --- /dev/null +++ b/gdb-bz592031-siginfo-lost-3of5.patch @@ -0,0 +1,259 @@ +http://sourceware.org/ml/gdb-patches/2010-09/msg00438.html +http://sourceware.org/ml/gdb-cvs/2010-09/msg00156.html + +### src/gdb/ChangeLog 2010/09/24 16:11:44 1.12203 +### src/gdb/ChangeLog 2010/09/24 18:35:20 1.12204 +## -1,3 +1,16 @@ ++2010-09-24 Jan Kratochvil ++ ++ Fix lost siginfo_t for inferior calls. ++ * infrun.c ++ (struct inferior_thread_state) : New. ++ (save_inferior_thread_state): New variables regcache, gdbarch and ++ siginfo_data. Initialize SIGINFO_DATA if gdbarch_get_siginfo_type_p. ++ Move INF_STATE allocation later, pre-clear it. Initialize REGISTERS ++ using REGCACHE. ++ (restore_inferior_thread_state): New variables regcache and gdbarch. ++ Restore SIGINFO_DATA for matching GDBARCH. Restore REGISTERS using ++ REGCACHE. Free also SIGINFO_DATA. ++ + 2010-09-24 Tom Tromey + + * dwarf2read.c (dw2_expand_symtabs_matching): Add missing +--- src/gdb/infrun.c 2010/09/06 14:22:07 1.450 ++++ src/gdb/infrun.c 2010/09/24 18:35:27 1.451 +@@ -6037,18 +6037,57 @@ + enum target_signal stop_signal; + CORE_ADDR stop_pc; + struct regcache *registers; ++ ++ /* Format of SIGINFO or NULL if it is not present. */ ++ struct gdbarch *siginfo_gdbarch; ++ ++ /* The inferior format depends on SIGINFO_GDBARCH and it has a length of ++ TYPE_LENGTH (gdbarch_get_siginfo_type ()). For different gdbarch the ++ content would be invalid. */ ++ gdb_byte *siginfo_data; + }; + + struct inferior_thread_state * + save_inferior_thread_state (void) + { +- struct inferior_thread_state *inf_state = XMALLOC (struct inferior_thread_state); ++ struct inferior_thread_state *inf_state; + struct thread_info *tp = inferior_thread (); ++ struct regcache *regcache = get_current_regcache (); ++ struct gdbarch *gdbarch = get_regcache_arch (regcache); ++ gdb_byte *siginfo_data = NULL; ++ ++ if (gdbarch_get_siginfo_type_p (gdbarch)) ++ { ++ struct type *type = gdbarch_get_siginfo_type (gdbarch); ++ size_t len = TYPE_LENGTH (type); ++ struct cleanup *back_to; ++ ++ siginfo_data = xmalloc (len); ++ back_to = make_cleanup (xfree, siginfo_data); ++ ++ if (target_read (¤t_target, TARGET_OBJECT_SIGNAL_INFO, NULL, ++ siginfo_data, 0, len) == len) ++ discard_cleanups (back_to); ++ else ++ { ++ /* Errors ignored. */ ++ do_cleanups (back_to); ++ siginfo_data = NULL; ++ } ++ } ++ ++ inf_state = XZALLOC (struct inferior_thread_state); ++ ++ if (siginfo_data) ++ { ++ inf_state->siginfo_gdbarch = gdbarch; ++ inf_state->siginfo_data = siginfo_data; ++ } + + inf_state->stop_signal = tp->stop_signal; + inf_state->stop_pc = stop_pc; + +- inf_state->registers = regcache_dup (get_current_regcache ()); ++ inf_state->registers = regcache_dup (regcache); + + return inf_state; + } +@@ -6059,16 +6098,29 @@ + restore_inferior_thread_state (struct inferior_thread_state *inf_state) + { + struct thread_info *tp = inferior_thread (); ++ struct regcache *regcache = get_current_regcache (); ++ struct gdbarch *gdbarch = get_regcache_arch (regcache); + + tp->stop_signal = inf_state->stop_signal; + stop_pc = inf_state->stop_pc; + ++ if (inf_state->siginfo_gdbarch == gdbarch) ++ { ++ struct type *type = gdbarch_get_siginfo_type (gdbarch); ++ size_t len = TYPE_LENGTH (type); ++ ++ /* Errors ignored. */ ++ target_write (¤t_target, TARGET_OBJECT_SIGNAL_INFO, NULL, ++ inf_state->siginfo_data, 0, len); ++ } ++ + /* The inferior can be gone if the user types "print exit(0)" + (and perhaps other times). */ + if (target_has_execution) + /* NB: The register write goes through to the target. */ +- regcache_cpy (get_current_regcache (), inf_state->registers); ++ regcache_cpy (regcache, inf_state->registers); + regcache_xfree (inf_state->registers); ++ xfree (inf_state->siginfo_data); + xfree (inf_state); + } + +### src/gdb/testsuite/ChangeLog 2010/09/22 20:08:04 1.2456 +### src/gdb/testsuite/ChangeLog 2010/09/24 18:35:28 1.2457 +## -1,3 +1,9 @@ ++2010-09-24 Jan Kratochvil ++ ++ Fix lost siginfo_t for inferior calls. ++ * gdb.base/siginfo-infcall.exp: New file. ++ * gdb.base/siginfo-infcall.c: New file. ++ + 2010-09-22 Joel Brobecker + + * gdb.dwarf2/dw2-const.S: Minor (space) reformatting. +--- src/gdb/testsuite/gdb.base/siginfo-infcall.c ++++ src/gdb/testsuite/gdb.base/siginfo-infcall.c 2010-09-25 13:25:25.007169000 +0000 +@@ -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 . */ ++ ++#include ++#include ++#include ++#include ++ ++#ifndef SA_SIGINFO ++# error "SA_SIGINFO is required for this test" ++#endif ++ ++static int ++callme (void) ++{ ++ return 42; ++} ++ ++static int ++pass (void) ++{ ++ return 1; ++} ++ ++static int ++fail (void) ++{ ++ return 1; ++} ++ ++static void ++handler (int sig, siginfo_t *siginfo, void *context) ++{ ++ assert (sig == SIGUSR1); ++ assert (siginfo->si_signo == SIGUSR1); ++ if (siginfo->si_pid == getpid ()) ++ pass (); ++ else ++ fail (); ++} ++ ++int ++main (void) ++{ ++ struct sigaction sa; ++ int i; ++ ++ callme (); ++ ++ memset (&sa, 0, sizeof (sa)); ++ sa.sa_sigaction = handler; ++ sa.sa_flags = SA_SIGINFO; ++ ++ i = sigemptyset (&sa.sa_mask); ++ assert (i == 0); ++ ++ i = sigaction (SIGUSR1, &sa, NULL); ++ assert (i == 0); ++ ++ i = raise (SIGUSR1); ++ assert (i == 0); ++ ++ sleep (600); ++ return 0; ++} +--- src/gdb/testsuite/gdb.base/siginfo-infcall.exp ++++ src/gdb/testsuite/gdb.base/siginfo-infcall.exp 2010-09-25 13:25:25.357724000 +0000 +@@ -0,0 +1,47 @@ ++# 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 [target_info exists gdb,nosignals] { ++ verbose "Skipping siginfo-infcall.exp because of nosignals." ++ continue ++} ++ ++set testfile siginfo-infcall ++set srcfile ${testfile}.c ++set executable ${testfile} ++if { [prepare_for_testing ${testfile}.exp $executable] } { ++ return -1 ++} ++ ++if ![runto_main] { ++ return -1 ++} ++ ++gdb_breakpoint "pass" ++gdb_breakpoint "fail" ++ ++gdb_test "continue" "Program received signal SIGUSR1, .*" "continue to SIGUSR1" ++ ++gdb_test "p callme ()" " = 42" ++ ++set test "continue to the handler" ++gdb_test_multiple "continue" $test { ++ -re "Breakpoint \[0-9\]+,\[^\r\n\]* pass .*\r\n$gdb_prompt $" { ++ pass $test ++ } ++ -re "Breakpoint \[0-9\]+,\[^\r\n\]* fail .*\r\n$gdb_prompt $" { ++ fail $test ++ } ++} diff --git a/gdb-bz592031-siginfo-lost-4of5.patch b/gdb-bz592031-siginfo-lost-4of5.patch new file mode 100644 index 0000000..a73ab33 --- /dev/null +++ b/gdb-bz592031-siginfo-lost-4of5.patch @@ -0,0 +1,992 @@ +http://sourceware.org/ml/gdb-patches/2010-09/msg00360.html +Subject: [patch 3/4]#3 linux-nat: Do not respawn signals + +Hi, + +linux-nat.c is fixed to never respawn signals; possibly keeping SIGSTOP +pending, as is done in current in FSF gdbserver and as suggested by Pedro: + http://sourceware.org/ml/gdb-patches/2010-08/msg00544.html + +The last linux-nat.c removed patch chunk comes from the initial implementation +by Mark Kettenis: + [PATCH] New Linux threads support + http://sourceware.org/ml/gdb-patches/2000-09/msg00020.html + 92280a75e017683bf8e4f339f4f85640b0700509 +It gets in part reimplemented into the new stop_wait_callback step)> +part and partially just not needed as currently GDB never drops the signals as +it does not PTRACE_CONT the thread; signal is kept for processing: + "RC: Not resuming sibling %s (has pending)\n" + +In stop_wait_callback I believe breakpoints cancellation is not needed here, +it would be done later. + + +The testcase sigstep-threads.exp was written to catch a regression-like +appearance then the new step)> part of stop_wait_callback gets +removed. Still the tecase fails even with FSF HEAD: + +32 var++; /* step-1 */ +(gdb) step +Program received signal SIGUSR1, User defined signal 1. +Program received signal SIGUSR1, User defined signal 1. +31 { /* step-0 */ + +There is no reason why it shouldn't stop on line 33, between line 32 and line +33 no signal would occur. Stepping of the current thread should not be +affected by whatever happens in the other threads as select_event_lwp has: + /* Give preference to any LWP that is being single-stepped. */ + +There is a problem that with FSF HEAD GDB does PTRACE_SINGLESTEP for thread A, +PTRACE_CONT for thread B (because of set scheduler-locking off), thread B hits +SIGUSR1, so GDB tkills thread A with SIGSTOP and it can receive SIGSTOP for +thread A before the SIGTRAP for completed PTRACE_SINGLESTEP. At that moment +select_event_lwp. forgets it was stepping thread A because there is no pending +SIGTRAP event. currently_stepping still remembers thread A was stepping so it +will later stop but as thread A was PTRACE_CONT-ed in the meantime it is too +late. + +There is the new step)> part of stop_wait_callback to always track +thread A is stepping. Due to different scheduling without this part the +changed GDB would very rarely stop in this testcase otherwise, making it look +as a regression. + +I have some another patch I may post separately as if multiple signals happen +besides SIGTRAP GDB still may switch from thread A away (as not considering it +stepping) to thread B for SIGUSR and accidentally PTRACE_CONT thread A. +But I do not find this as a prerequisite for this patchset. + + + +Thanks, +Jan + + +gdb/ +2010-09-20 Jan Kratochvil + + * linux-nat.c (stop_wait_callback): New gdb_assert. Remove signals + respawning; keep TP with SIGNALLED. New debugging message "SWC: + Delayed SIGSTOP caught for %s.". Catch next signal if SIGSTOP has + been caught and LP->STEP is set. + (linux_nat_wait_1) signalled>: Remove. + +gdb/testsuite/ +2010-09-20 Jan Kratochvil + + * gdb.threads/siginfo-threads.exp: New file. + * gdb.threads/siginfo-threads.c: New file. + * gdb.threads/sigstep-threads.exp: New file. + * gdb.threads/sigstep-threads.c: New file. + +Index: gdb-7.2/gdb/linux-nat.c +=================================================================== +--- gdb-7.2.orig/gdb/linux-nat.c 2010-09-25 15:30:54.000000000 +0200 ++++ gdb-7.2/gdb/linux-nat.c 2010-09-25 15:37:23.000000000 +0200 +@@ -2702,6 +2702,8 @@ stop_wait_callback (struct lwp_info *lp, + { + int status; + ++ gdb_assert (lp->resumed); ++ + status = wait_lwp (lp); + if (status == 0) + return 0; +@@ -2726,110 +2728,61 @@ stop_wait_callback (struct lwp_info *lp, + + if (WSTOPSIG (status) != SIGSTOP) + { +- if (WSTOPSIG (status) == SIGTRAP) +- { +- /* If a LWP other than the LWP that we're reporting an +- event for has hit a GDB breakpoint (as opposed to +- some random trap signal), then just arrange for it to +- hit it again later. We don't keep the SIGTRAP status +- and don't forward the SIGTRAP signal to the LWP. We +- will handle the current event, eventually we will +- resume all LWPs, and this one will get its breakpoint +- trap again. +- +- If we do not do this, then we run the risk that the +- user will delete or disable the breakpoint, but the +- thread will have already tripped on it. */ +- +- /* Save the trap's siginfo in case we need it later. */ +- save_siginfo (lp); +- +- save_sigtrap (lp); +- +- /* Now resume this LWP and get the SIGSTOP event. */ +- errno = 0; +- ptrace (PTRACE_CONT, GET_LWP (lp->ptid), 0, 0); +- if (debug_linux_nat) +- { +- fprintf_unfiltered (gdb_stdlog, +- "PTRACE_CONT %s, 0, 0 (%s)\n", +- target_pid_to_str (lp->ptid), +- errno ? safe_strerror (errno) : "OK"); +- +- fprintf_unfiltered (gdb_stdlog, +- "SWC: Candidate SIGTRAP event in %s\n", +- target_pid_to_str (lp->ptid)); +- } +- /* Hold this event/waitstatus while we check to see if +- there are any more (we still want to get that SIGSTOP). */ +- stop_wait_callback (lp, NULL); ++ /* The thread was stopped with a signal other than SIGSTOP. */ + +- /* Hold the SIGTRAP for handling by linux_nat_wait. If +- there's another event, throw it back into the +- queue. */ +- if (lp->status) +- { +- if (debug_linux_nat) +- fprintf_unfiltered (gdb_stdlog, +- "SWC: kill %s, %s\n", +- target_pid_to_str (lp->ptid), +- status_to_str ((int) status)); +- kill_lwp (GET_LWP (lp->ptid), WSTOPSIG (lp->status)); +- } ++ /* Save the trap's siginfo in case we need it later. */ ++ save_siginfo (lp); + +- /* Save the sigtrap event. */ +- lp->status = status; +- return 0; +- } +- else +- { +- /* The thread was stopped with a signal other than +- SIGSTOP, and didn't accidentally trip a breakpoint. */ ++ save_sigtrap (lp); + +- if (debug_linux_nat) +- { +- fprintf_unfiltered (gdb_stdlog, +- "SWC: Pending event %s in %s\n", +- status_to_str ((int) status), +- target_pid_to_str (lp->ptid)); +- } +- /* Now resume this LWP and get the SIGSTOP event. */ +- errno = 0; +- ptrace (PTRACE_CONT, GET_LWP (lp->ptid), 0, 0); +- if (debug_linux_nat) +- fprintf_unfiltered (gdb_stdlog, +- "SWC: PTRACE_CONT %s, 0, 0 (%s)\n", +- target_pid_to_str (lp->ptid), +- errno ? safe_strerror (errno) : "OK"); +- +- /* Hold this event/waitstatus while we check to see if +- there are any more (we still want to get that SIGSTOP). */ +- stop_wait_callback (lp, NULL); ++ if (debug_linux_nat) ++ fprintf_unfiltered (gdb_stdlog, ++ "SWC: Pending event %s in %s\n", ++ status_to_str ((int) status), ++ target_pid_to_str (lp->ptid)); + +- /* If the lp->status field is still empty, use it to +- hold this event. If not, then this event must be +- returned to the event queue of the LWP. */ +- if (lp->status) +- { +- if (debug_linux_nat) +- { +- fprintf_unfiltered (gdb_stdlog, +- "SWC: kill %s, %s\n", +- target_pid_to_str (lp->ptid), +- status_to_str ((int) status)); +- } +- kill_lwp (GET_LWP (lp->ptid), WSTOPSIG (status)); +- } +- else +- lp->status = status; +- return 0; +- } ++ /* Save the sigtrap event. */ ++ lp->status = status; ++ gdb_assert (! lp->stopped); ++ gdb_assert (lp->signalled); ++ lp->stopped = 1; + } + else + { + /* We caught the SIGSTOP that we intended to catch, so + there's no SIGSTOP pending. */ +- lp->stopped = 1; ++ ++ if (debug_linux_nat) ++ fprintf_unfiltered (gdb_stdlog, ++ "SWC: Delayed SIGSTOP caught for %s.\n", ++ target_pid_to_str (lp->ptid)); ++ ++ if (lp->step) ++ { ++ /* LP->STATUS is 0 here. That means SIGTRAP from ++ PTRACE_SINGLESTEP still has to be delivered for this inferior ++ stop. Catching the SIGTRAP event is important to prevent ++ starvation in select_event_lwp. */ ++ ++ registers_changed (); ++ linux_ops->to_resume (linux_ops, pid_to_ptid (GET_LWP (lp->ptid)), ++ 1, TARGET_SIGNAL_0); ++ if (debug_linux_nat) ++ fprintf_unfiltered (gdb_stdlog, ++ "SWC: %s %s, 0, 0 (discard SIGSTOP)\n", ++ "PTRACE_SINGLESTEP", ++ target_pid_to_str (lp->ptid)); ++ ++ lp->stopped = 0; ++ gdb_assert (lp->resumed); ++ stop_wait_callback (lp, NULL); ++ gdb_assert (lp->stopped); ++ } ++ else ++ lp->stopped = 1; ++ ++ /* Reset SIGNALLED only after the stop_wait_callback call above as ++ it does gdb_assert on SIGNALLED. */ + lp->signalled = 0; + } + } +@@ -3416,52 +3369,6 @@ retry: + lp = NULL; + } + +- if (lp && lp->signalled) +- { +- /* A pending SIGSTOP may interfere with the normal stream of +- events. In a typical case where interference is a problem, +- we have a SIGSTOP signal pending for LWP A while +- single-stepping it, encounter an event in LWP B, and take the +- pending SIGSTOP while trying to stop LWP A. After processing +- the event in LWP B, LWP A is continued, and we'll never see +- the SIGTRAP associated with the last time we were +- single-stepping LWP A. */ +- +- /* Resume the thread. It should halt immediately returning the +- pending SIGSTOP. */ +- registers_changed (); +- linux_ops->to_resume (linux_ops, pid_to_ptid (GET_LWP (lp->ptid)), +- lp->step, TARGET_SIGNAL_0); +- if (debug_linux_nat) +- fprintf_unfiltered (gdb_stdlog, +- "LLW: %s %s, 0, 0 (expect SIGSTOP)\n", +- lp->step ? "PTRACE_SINGLESTEP" : "PTRACE_CONT", +- target_pid_to_str (lp->ptid)); +- lp->stopped = 0; +- gdb_assert (lp->resumed); +- +- /* Catch the pending SIGSTOP. */ +- status = lp->status; +- lp->status = 0; +- +- stop_wait_callback (lp, NULL); +- +- /* If the lp->status field isn't empty, we caught another signal +- while flushing the SIGSTOP. Return it back to the event +- queue of the LWP, as we already have an event to handle. */ +- if (lp->status) +- { +- if (debug_linux_nat) +- fprintf_unfiltered (gdb_stdlog, +- "LLW: kill %s, %s\n", +- target_pid_to_str (lp->ptid), +- status_to_str (lp->status)); +- kill_lwp (GET_LWP (lp->ptid), WSTOPSIG (lp->status)); +- } +- +- lp->status = status; +- } +- + if (!target_can_async_p ()) + { + /* Causes SIGINT to be passed on to the attached process. */ +Index: gdb-7.2/gdb/testsuite/gdb.threads/siginfo-threads.c +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ gdb-7.2/gdb/testsuite/gdb.threads/siginfo-threads.c 2010-09-25 15:32:32.000000000 +0200 +@@ -0,0 +1,447 @@ ++/* 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 . */ ++ ++#define _GNU_SOURCE ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++ ++#define gettid() syscall (__NR_gettid) ++#define tgkill(tgid, tid, sig) syscall (__NR_tgkill, tgid, tid, sig) ++ ++/* Terminate always in the main task, it can lock up with SIGSTOPped GDB ++ otherwise. */ ++#define TIMEOUT (gettid () == getpid() ? 10 : 15) ++ ++static pid_t thread1_tid; ++static pthread_cond_t thread1_tid_cond = PTHREAD_COND_INITIALIZER; ++static pthread_mutex_t thread1_tid_mutex = PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP; ++static int thread1_sigusr1_hit; ++static int thread1_sigusr2_hit; ++ ++static pid_t thread2_tid; ++static pthread_cond_t thread2_tid_cond = PTHREAD_COND_INITIALIZER; ++static pthread_mutex_t thread2_tid_mutex = PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP; ++static int thread2_sigusr1_hit; ++static int thread2_sigusr2_hit; ++ ++static pthread_mutex_t terminate_mutex = PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP; ++ ++/* Do not use alarm as it would create a ptrace event which would hang up us if ++ we are being traced by GDB which we stopped ourselves. */ ++ ++static void timed_mutex_lock (pthread_mutex_t *mutex) ++{ ++ int i; ++ struct timespec start, now; ++ ++ i = clock_gettime (CLOCK_MONOTONIC, &start); ++ assert (i == 0); ++ ++ do ++ { ++ i = pthread_mutex_trylock (mutex); ++ if (i == 0) ++ return; ++ assert (i == EBUSY); ++ ++ i = clock_gettime (CLOCK_MONOTONIC, &now); ++ assert (i == 0); ++ assert (now.tv_sec >= start.tv_sec); ++ } ++ while (now.tv_sec - start.tv_sec < TIMEOUT); ++ ++ fprintf (stderr, "Timed out waiting for internal lock!\n"); ++ exit (EXIT_FAILURE); ++} ++ ++static void ++handler (int signo, siginfo_t *siginfo, void *exception) ++{ ++ int *varp; ++ ++ assert (siginfo->si_signo == signo); ++ assert (siginfo->si_code == SI_TKILL); ++ assert (siginfo->si_pid == getpid ()); ++ ++ if (gettid () == thread1_tid) ++ { ++ if (signo == SIGUSR1) ++ varp = &thread1_sigusr1_hit; ++ else if (signo == SIGUSR2) ++ varp = &thread1_sigusr2_hit; ++ else ++ assert (0); ++ } ++ else if (gettid () == thread2_tid) ++ { ++ if (signo == SIGUSR1) ++ varp = &thread2_sigusr1_hit; ++ else if (signo == SIGUSR2) ++ varp = &thread2_sigusr2_hit; ++ else ++ assert (0); ++ } ++ else ++ assert (0); ++ ++ if (*varp) ++ { ++ fprintf (stderr, "Signal %d for TID %lu has been already hit!\n", signo, ++ (unsigned long) gettid ()); ++ exit (EXIT_FAILURE); ++ } ++ *varp = 1; ++} ++ ++static void * ++thread1_func (void *unused) ++{ ++ int i; ++ ++ timed_mutex_lock (&thread1_tid_mutex); ++ ++ /* THREAD1_TID_MUTEX must be already locked to avoid race. */ ++ thread1_tid = gettid (); ++ ++ i = pthread_cond_signal (&thread1_tid_cond); ++ assert (i == 0); ++ i = pthread_mutex_unlock (&thread1_tid_mutex); ++ assert (i == 0); ++ ++ /* 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); ++ ++ if (! thread1_sigusr1_hit) ++ { ++ fprintf (stderr, "Thread 1 signal SIGUSR1 not hit!\n"); ++ exit (EXIT_FAILURE); ++ } ++ if (! thread1_sigusr2_hit) ++ { ++ fprintf (stderr, "Thread 1 signal SIGUSR2 not hit!\n"); ++ exit (EXIT_FAILURE); ++ } ++ ++ return NULL; ++} ++ ++static void * ++thread2_func (void *unused) ++{ ++ int i; ++ ++ timed_mutex_lock (&thread2_tid_mutex); ++ ++ /* THREAD2_TID_MUTEX must be already locked to avoid race. */ ++ thread2_tid = gettid (); ++ ++ i = pthread_cond_signal (&thread2_tid_cond); ++ assert (i == 0); ++ i = pthread_mutex_unlock (&thread2_tid_mutex); ++ assert (i == 0); ++ ++ /* 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); ++ ++ if (! thread2_sigusr1_hit) ++ { ++ fprintf (stderr, "Thread 2 signal SIGUSR1 not hit!\n"); ++ exit (EXIT_FAILURE); ++ } ++ if (! thread2_sigusr2_hit) ++ { ++ fprintf (stderr, "Thread 2 signal SIGUSR2 not hit!\n"); ++ exit (EXIT_FAILURE); ++ } ++ ++ return NULL; ++} ++ ++static const char * ++proc_string (const char *filename, const char *line) ++{ ++ FILE *f; ++ static char buf[LINE_MAX]; ++ size_t line_len = strlen (line); ++ ++ f = fopen (filename, "r"); ++ if (f == NULL) ++ { ++ fprintf (stderr, "fopen (\"%s\") for \"%s\": %s\n", filename, line, ++ strerror (errno)); ++ exit (EXIT_FAILURE); ++ } ++ while (errno = 0, fgets (buf, sizeof (buf), f)) ++ { ++ char *s; ++ ++ s = strchr (buf, '\n'); ++ assert (s != NULL); ++ *s = 0; ++ ++ if (strncmp (buf, line, line_len) != 0) ++ continue; ++ ++ if (fclose (f)) ++ { ++ fprintf (stderr, "fclose (\"%s\") for \"%s\": %s\n", filename, line, ++ strerror (errno)); ++ exit (EXIT_FAILURE); ++ } ++ ++ return &buf[line_len]; ++ } ++ if (errno != 0) ++ { ++ fprintf (stderr, "fgets (\"%s\": %s\n", filename, strerror (errno)); ++ exit (EXIT_FAILURE); ++ } ++ fprintf (stderr, "\"%s\": No line \"%s\" found.\n", filename, line); ++ exit (EXIT_FAILURE); ++} ++ ++static unsigned long ++proc_ulong (const char *filename, const char *line) ++{ ++ const char *s = proc_string (filename, line); ++ long retval; ++ char *end; ++ ++ errno = 0; ++ retval = strtol (s, &end, 10); ++ if (retval < 0 || retval >= LONG_MAX || (end && *end)) ++ { ++ fprintf (stderr, "\"%s\":\"%s\": %ld, %s\n", filename, line, retval, ++ strerror (errno)); ++ exit (EXIT_FAILURE); ++ } ++ return retval; ++} ++ ++static void ++state_wait (pid_t process, const char *wanted) ++{ ++ char *filename; ++ int i; ++ struct timespec start, now; ++ const char *state; ++ ++ i = asprintf (&filename, "/proc/%lu/status", (unsigned long) process); ++ assert (i > 0); ++ ++ i = clock_gettime (CLOCK_MONOTONIC, &start); ++ assert (i == 0); ++ ++ 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); ++ return; ++ } ++ ++ if (sched_yield ()) ++ { ++ perror ("sched_yield()"); ++ exit (EXIT_FAILURE); ++ } ++ ++ i = clock_gettime (CLOCK_MONOTONIC, &now); ++ assert (i == 0); ++ assert (now.tv_sec >= start.tv_sec); ++ } ++ while (now.tv_sec - start.tv_sec < TIMEOUT); ++ ++ fprintf (stderr, "Timed out waiting for PID %lu \"%s\" (now it is \"%s\")!\n", ++ (unsigned long) process, wanted, state); ++ exit (EXIT_FAILURE); ++} ++ ++static volatile pid_t tracer = 0; ++static pthread_t thread1, thread2; ++ ++static void ++cleanup (void) ++{ ++ printf ("Resuming GDB PID %lu.\n", (unsigned long) tracer); ++ ++ if (tracer) ++ { ++ int i; ++ int tracer_save = tracer; ++ ++ tracer = 0; ++ ++ i = kill (tracer_save, SIGCONT); ++ assert (i == 0); ++ } ++} ++ ++int ++main (int argc, char **argv) ++{ ++ int i; ++ int standalone = 0; ++ struct sigaction act; ++ ++ if (argc == 2 && strcmp (argv[1], "-s") == 0) ++ standalone = 1; ++ else ++ assert (argc == 1); ++ ++ setbuf (stdout, NULL); ++ ++ timed_mutex_lock (&thread1_tid_mutex); ++ timed_mutex_lock (&thread2_tid_mutex); ++ ++ timed_mutex_lock (&terminate_mutex); ++ ++ errno = 0; ++ memset (&act, 0, sizeof (act)); ++ act.sa_sigaction = handler; ++ act.sa_flags = SA_RESTART | SA_SIGINFO; ++ i = sigemptyset (&act.sa_mask); ++ assert_perror (errno); ++ assert (i == 0); ++ i = sigaction (SIGUSR1, &act, NULL); ++ assert_perror (errno); ++ assert (i == 0); ++ i = sigaction (SIGUSR2, &act, NULL); ++ assert_perror (errno); ++ assert (i == 0); ++ ++ i = pthread_create (&thread1, NULL, thread1_func, NULL); ++ assert (i == 0); ++ ++ i = pthread_create (&thread2, NULL, thread2_func, NULL); ++ assert (i == 0); ++ ++ if (!standalone) ++ { ++ tracer = proc_ulong ("/proc/self/status", "TracerPid:\t"); ++ if (tracer == 0) ++ { ++ fprintf (stderr, "The testcase must be run by GDB!\n"); ++ exit (EXIT_FAILURE); ++ } ++ if (tracer != getppid ()) ++ { ++ fprintf (stderr, "The testcase parent must be our GDB tracer!\n"); ++ exit (EXIT_FAILURE); ++ } ++ } ++ ++ /* SIGCONT our debugger in the case of our crash as we would deadlock ++ otherwise. */ ++ ++ atexit (cleanup); ++ ++ printf ("Stopping GDB PID %lu.\n", (unsigned long) tracer); ++ ++ if (tracer) ++ { ++ i = kill (tracer, SIGSTOP); ++ assert (i == 0); ++ state_wait (tracer, "T (stopped)"); ++ } ++ ++ /* Threads are now waiting at timed_mutex_lock (thread1_tid_mutex) and so ++ they could not trigger the signals before GDB gets unstopped later. ++ Threads get resumed at pthread_cond_wait below. Use `while' loops for ++ protection against spurious pthread_cond_wait wakeups. */ ++ ++ printf ("Waiting till the threads initialize their TIDs.\n"); ++ ++ while (thread1_tid == 0) ++ { ++ i = pthread_cond_wait (&thread1_tid_cond, &thread1_tid_mutex); ++ assert (i == 0); ++ } ++ ++ while (thread2_tid == 0) ++ { ++ i = pthread_cond_wait (&thread2_tid_cond, &thread2_tid_mutex); ++ assert (i == 0); ++ } ++ ++ printf ("Thread 1 TID = %lu, thread 2 TID = %lu, PID = %lu.\n", ++ (unsigned long) thread1_tid, (unsigned long) thread2_tid, ++ (unsigned long) getpid ()); ++ ++ errno = 0; ++ i = tgkill (getpid (), thread1_tid, SIGUSR1); ++ assert_perror (errno); ++ assert (i == 0); ++ i = tgkill (getpid (), thread1_tid, SIGUSR2); ++ assert_perror (errno); ++ assert (i == 0); ++ i = tgkill (getpid (), thread2_tid, SIGUSR1); ++ assert_perror (errno); ++ assert (i == 0); ++ i = tgkill (getpid (), thread2_tid, SIGUSR2); ++ assert_perror (errno); ++ assert (i == 0); ++ ++ printf ("Waiting till the threads get trapped by the signals.\n"); ++ ++ if (tracer) ++ { ++ /* s390x-unknown-linux-gnu will fail with "R (running)". */ ++ ++ state_wait (thread1_tid, "t (tracing stop)"); ++ ++ state_wait (thread2_tid, "t (tracing stop)"); ++ } ++ ++ cleanup (); ++ ++ printf ("Joining the threads.\n"); ++ ++ i = pthread_mutex_unlock (&terminate_mutex); ++ assert (i == 0); ++ ++ i = pthread_join (thread1, NULL); ++ assert (i == 0); ++ ++ i = pthread_join (thread2, NULL); ++ assert (i == 0); ++ ++ printf ("Exiting.\n"); /* break-at-exit */ ++ ++ return EXIT_SUCCESS; ++} +Index: gdb-7.2/gdb/testsuite/gdb.threads/siginfo-threads.exp +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ gdb-7.2/gdb/testsuite/gdb.threads/siginfo-threads.exp 2010-09-25 15:32:32.000000000 +0200 +@@ -0,0 +1,94 @@ ++# 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 . ++ ++set testfile "siginfo-threads" ++set srcfile ${testfile}.c ++set binfile ${objdir}/${subdir}/${testfile} ++if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" ${binfile} executable [list debug additional_flags=-lrt]] != "" } { ++ return -1 ++} ++ ++clean_restart $testfile ++ ++if ![runto_main] { ++ return -1 ++} ++ ++# `nostop noprint pass' could in some cases report false PASS due to the ++# (preempt 'handle') code path. ++ ++gdb_test "handle SIGUSR1 stop print pass" "Signal\[ \t\]+Stop\[ \t\]+Print\[ \t\]+Pass to program\[ \t\]+Description\r\nSIGUSR1\[ \t\]+Yes\[ \t\]+Yes\[ \t\]+Yes\[ \t\].*" ++gdb_test "handle SIGUSR2 stop print pass" "Signal\[ \t\]+Stop\[ \t\]+Print\[ \t\]+Pass to program\[ \t\]+Description\r\nSIGUSR2\[ \t\]+Yes\[ \t\]+Yes\[ \t\]+Yes\[ \t\].*" ++ ++gdb_breakpoint [gdb_get_line_number "break-at-exit"] ++ ++set test "get pid" ++gdb_test_multiple "p getpid ()" $test { ++ -re " = (\[0-9\]+)\r\n$gdb_prompt $" { ++ set pid $expect_out(1,string) ++ pass $test ++ } ++} ++ ++for {set sigcount 0} {$sigcount < 4} {incr sigcount} { ++ set test "catch signal $sigcount" ++ set sigusr "" ++ gdb_test_multiple "continue" $test { ++ -re "Program received signal SIGUSR(\[12\]), User defined signal \[12\]\\.\r\n.*\r\n$gdb_prompt $" { ++ set sigusr $expect_out(1,string) ++ pass $test ++ } ++ } ++ if {$sigusr == ""} { ++ return -1 ++ } ++ ++ set test "signal $sigcount si_signo" ++ if {$sigusr == 1} { ++ set signo 10 ++ } else { ++ set signo 12 ++ } ++ gdb_test_multiple {p $_siginfo.si_signo} $test { ++ -re " = $signo\r\n$gdb_prompt $" { ++ pass $test ++ } ++ -re "Attempt to extract a component of a value that is not a structure\\.\r\n$gdb_prompt $" { ++ unsupported $test ++ } ++ } ++ ++ set test "signal $sigcount si_code is SI_TKILL" ++ gdb_test_multiple {p $_siginfo.si_code} $test { ++ -re " = -6\r\n$gdb_prompt $" { ++ pass $test ++ } ++ -re "Attempt to extract a component of a value that is not a structure\\.\r\n$gdb_prompt $" { ++ unsupported $test ++ } ++ } ++ ++ set test "signal $sigcount si_pid" ++ gdb_test_multiple {p $_siginfo._sifields._kill.si_pid} $test { ++ -re " = $pid\r\n$gdb_prompt $" { ++ pass $test ++ } ++ -re "Attempt to extract a component of a value that is not a structure\\.\r\n$gdb_prompt $" { ++ unsupported $test ++ } ++ } ++} ++ ++gdb_continue_to_breakpoint break-at-exit ".*break-at-exit.*" +Index: gdb-7.2/gdb/testsuite/gdb.threads/sigstep-threads.c +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ gdb-7.2/gdb/testsuite/gdb.threads/sigstep-threads.c 2010-09-25 15:32:32.000000000 +0200 +@@ -0,0 +1,54 @@ ++/* 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 ++#include ++ ++#include ++#include ++#define tgkill(tgid, tid, sig) syscall (__NR_tgkill, (tgid), (tid), (sig)) ++#define gettid() syscall (__NR_gettid) ++ ++static volatile int var; ++ ++static void ++handler (int signo) /* step-0 */ ++{ /* step-0 */ ++ var++; /* step-1 */ ++ tgkill (getpid (), gettid (), SIGUSR1); /* step-2 */ ++} ++ ++static void * ++start (void *arg) ++{ ++ signal (SIGUSR1, handler); ++ tgkill (getpid (), gettid (), SIGUSR1); ++ assert (0); ++ ++ return NULL; ++} ++ ++int ++main (void) ++{ ++ pthread_t thread; ++ ++ pthread_create (&thread, NULL, start, NULL); ++ start (NULL); /* main-start */ ++ return 0; ++} +Index: gdb-7.2/gdb/testsuite/gdb.threads/sigstep-threads.exp +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ gdb-7.2/gdb/testsuite/gdb.threads/sigstep-threads.exp 2010-09-25 15:32:32.000000000 +0200 +@@ -0,0 +1,74 @@ ++# 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 . ++ ++set testfile sigstep-threads ++set srcfile ${testfile}.c ++set executable ${testfile} ++set binfile ${objdir}/${subdir}/${executable} ++ ++if { [gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } { ++ untested ${testfile}.exp ++ return -1 ++} ++ ++clean_restart $executable ++ ++if ![runto_main] { ++ return -1; ++} ++ ++# `noprint' would not test the full logic of GDB. ++gdb_test "handle SIGUSR1 nostop print pass" "\r\nSIGUSR1\[ \t\]+No\[ \t\]+Yes\[ \t\]+Yes\[ \t\].*" ++ ++gdb_test_no_output "set scheduler-locking off" ++ ++gdb_breakpoint [gdb_get_line_number "step-1"] ++gdb_test_no_output {set $step1=$bpnum} ++gdb_continue_to_breakpoint "step-1" ".* step-1 .*" ++gdb_test_no_output {disable $step1} ++ ++# 1 as we are now stopped at the `step-1' label. ++set step_at 1 ++for {set i 0} {$i < 100} {incr i} { ++ set test "step $i" ++ # Presume this step failed - as in the case of a timeout. ++ set failed 1 ++ gdb_test_multiple "step" $test { ++ -re "\r\nProgram received signal SIGUSR1, User defined signal 1.\r\n" { ++ exp_continue -continue_timer ++ } ++ -re "step-(\[012\]).*\r\n$gdb_prompt $" { ++ set now $expect_out(1,string) ++ if {$step_at == 2 && $now == 1} { ++ set failed 0 ++ } elseif {$step_at == 1 && $now == 2} { ++ set failed 0 ++ # Continue over the re-signalling back to the handle entry. ++ gdb_test_no_output {enable $step1} "" ++ gdb_test "continue" " step-1 .*" "" ++ set now 1 ++ gdb_test_no_output {disable $step1} "" ++ } else { ++ fail $test ++ } ++ set step_at $now ++ } ++ } ++ if $failed { ++ return ++ } ++} ++# We can never reliably say the racy problematic case has been tested. ++pass "step" diff --git a/gdb-bz592031-siginfo-lost-5of5.patch b/gdb-bz592031-siginfo-lost-5of5.patch new file mode 100644 index 0000000..6bf93ef --- /dev/null +++ b/gdb-bz592031-siginfo-lost-5of5.patch @@ -0,0 +1,141 @@ +http://sourceware.org/ml/gdb-patches/2010-09/msg00361.html +Subject: [patch 4/4]#3 Remove redundant lp->siginfo + +Hi, + +this is a simplification which should not affect GDB behavior. As linux-nat +now stops on each received signal without any reordering of them then +PTRACE_GETSIGINFO is enough to access siginfo, without any need to copy it in +advance. + + +Thanks, +Jan + + +gdb/ +2010-09-20 Jan Kratochvil + + * linux-nat.c (resume_callback) stopped && lp->status == 0> + (linux_nat_resume): Remove LP->SIGINFO clearing. + (save_siginfo): Remove. + (stop_wait_callback) + (linux_nat_filter_event) : Remove + the save_siginfo call. + (resume_stopped_resumed_lwps): Remove LP->SIGINFO clearing. + (linux_nat_set_siginfo_fixup): Use PTRACE_GETSIGINFO. + * linux-nat.h (struct lwp_info) : Remove. + +Index: gdb-7.2/gdb/linux-nat.c +=================================================================== +--- gdb-7.2.orig/gdb/linux-nat.c 2010-09-25 15:37:23.000000000 +0200 ++++ gdb-7.2/gdb/linux-nat.c 2010-09-25 15:38:18.000000000 +0200 +@@ -1851,7 +1851,6 @@ resume_callback (struct lwp_info *lp, vo + target_pid_to_str (lp->ptid)); + lp->stopped = 0; + lp->step = 0; +- memset (&lp->siginfo, 0, sizeof (lp->siginfo)); + lp->stopped_by_watchpoint = 0; + } + else if (lp->stopped && debug_linux_nat) +@@ -1993,7 +1992,6 @@ linux_nat_resume (struct target_ops *ops + ptid = pid_to_ptid (GET_LWP (lp->ptid)); + + linux_ops->to_resume (linux_ops, ptid, step, signo); +- memset (&lp->siginfo, 0, sizeof (lp->siginfo)); + lp->stopped_by_watchpoint = 0; + + if (debug_linux_nat) +@@ -2483,22 +2481,6 @@ wait_lwp (struct lwp_info *lp) + return status; + } + +-/* Save the most recent siginfo for LP. This is currently only called +- for SIGTRAP; some ports use the si_addr field for +- target_stopped_data_address. In the future, it may also be used to +- restore the siginfo of requeued signals. */ +- +-static void +-save_siginfo (struct lwp_info *lp) +-{ +- errno = 0; +- ptrace (PTRACE_GETSIGINFO, GET_LWP (lp->ptid), +- (PTRACE_TYPE_ARG3) 0, &lp->siginfo); +- +- if (errno != 0) +- memset (&lp->siginfo, 0, sizeof (lp->siginfo)); +-} +- + /* Send a SIGSTOP to LP. */ + + static int +@@ -2730,9 +2712,6 @@ stop_wait_callback (struct lwp_info *lp, + { + /* The thread was stopped with a signal other than SIGSTOP. */ + +- /* Save the trap's siginfo in case we need it later. */ +- save_siginfo (lp); +- + save_sigtrap (lp); + + if (debug_linux_nat) +@@ -3102,12 +3081,7 @@ linux_nat_filter_event (int lwpid, int s + } + + if (WIFSTOPPED (status) && WSTOPSIG (status) == SIGTRAP) +- { +- /* Save the trap's siginfo in case we need it later. */ +- save_siginfo (lp); +- +- save_sigtrap (lp); +- } ++ save_sigtrap (lp); + + /* Check if the thread has exited. */ + if ((WIFEXITED (status) || WIFSIGNALED (status)) +@@ -3706,7 +3680,6 @@ resume_stopped_resumed_lwps (struct lwp_ + linux_ops->to_resume (linux_ops, pid_to_ptid (GET_LWP (lp->ptid)), + lp->step, TARGET_SIGNAL_0); + lp->stopped = 0; +- memset (&lp->siginfo, 0, sizeof (lp->siginfo)); + lp->stopped_by_watchpoint = 0; + } + +@@ -5878,11 +5851,19 @@ linux_nat_set_siginfo_fixup (struct targ + struct siginfo * + linux_nat_get_siginfo (ptid_t ptid) + { +- struct lwp_info *lp = find_lwp_pid (ptid); ++ static struct siginfo siginfo; ++ int pid; + +- gdb_assert (lp != NULL); ++ pid = GET_LWP (ptid); ++ if (pid == 0) ++ pid = GET_PID (ptid); ++ ++ errno = 0; ++ ptrace (PTRACE_GETSIGINFO, pid, (PTRACE_TYPE_ARG3) 0, &siginfo); ++ if (errno != 0) ++ memset (&siginfo, 0, sizeof (siginfo)); + +- return &lp->siginfo; ++ return &siginfo; + } + + /* Provide a prototype to silence -Wmissing-prototypes. */ +Index: gdb-7.2/gdb/linux-nat.h +=================================================================== +--- gdb-7.2.orig/gdb/linux-nat.h 2010-09-25 15:30:50.000000000 +0200 ++++ gdb-7.2/gdb/linux-nat.h 2010-09-25 15:37:57.000000000 +0200 +@@ -58,10 +58,6 @@ struct lwp_info + /* The kind of stepping of this LWP. */ + enum resume_step step; + +- /* Non-zero si_signo if this LWP stopped with a trap. si_addr may +- be the address of a hardware watchpoint. */ +- struct siginfo siginfo; +- + /* STOPPED_BY_WATCHPOINT is non-zero if this LWP stopped with a data + watchpoint trap. */ + int stopped_by_watchpoint; diff --git a/gdb-bz594560-core-vs-process.patch b/gdb-bz594560-core-vs-process.patch new file mode 100644 index 0000000..5f7b9d4 --- /dev/null +++ b/gdb-bz594560-core-vs-process.patch @@ -0,0 +1,164 @@ +--- ./gdb/doc/gdb.texinfo 2010-05-24 19:37:01.000000000 +0200 ++++ ./gdb/doc/gdb.texinfo 2010-05-24 19:38:56.000000000 +0200 +@@ -14768,33 +14768,21 @@ and @code{show architecture}. + @cindex active targets + @cindex multiple targets + +-There are three classes of targets: processes, core files, and +-executable files. @value{GDBN} can work concurrently on up to three +-active targets, one in each class. This allows you to (for example) +-start a process and inspect its activity without abandoning your work on +-a core file. +- +-For example, if you execute @samp{gdb a.out}, then the executable file +-@code{a.out} is the only active target. If you designate a core file as +-well---presumably from a prior run that crashed and coredumped---then +-@value{GDBN} has two active targets and uses them in tandem, looking +-first in the corefile target, then in the executable file, to satisfy +-requests for memory addresses. (Typically, these two classes of target +-are complementary, since core files contain only a program's +-read-write memory---variables and so on---plus machine status, while +-executable files contain only the program text and initialized data.) +- +-When you type @code{run}, your executable file becomes an active process +-target as well. When a process target is active, all @value{GDBN} +-commands requesting memory addresses refer to that target; addresses in +-an active core file or executable file target are obscured while the +-process target is active. +- +-Use the @code{core-file} and @code{exec-file} commands to select a new +-core file or executable target (@pxref{Files, ,Commands to Specify +-Files}). To specify as a target a process that is already running, use +-the @code{attach} command (@pxref{Attach, ,Debugging an Already-running +-Process}). ++There are multiple classes of targets such as: processes, executable files or ++recording sessions. Core files belong to the process class, there can be ++active only one of a core or a running process. Otherwise @value{GDBN} can ++work concurrently on multiple active targets, one in each class. This allows ++you to (for example) start a process and inspect its activity while still ++having access to the executable file after the process finishes. Or if you ++start process recording (@pxref{Reverse Execution}) and @code{reverse-step} ++there you are presented a virtual layer of the recording target while the ++process target remains stopped at the chronologically last point of the process ++execution. ++ ++Use the @code{core-file} and @code{exec-file} commands to select a new core ++file or executable target (@pxref{Files, ,Commands to Specify Files}). To ++specify as a target a process that is already running, use the @code{attach} ++command (@pxref{Attach, ,Debugging an Already-running Process}). + + @node Target Commands + @section Commands for Managing Targets +--- ./gdb/infcmd.c 2010-05-24 19:37:01.000000000 +0200 ++++ ./gdb/infcmd.c 2010-05-24 19:41:21.000000000 +0200 +@@ -483,6 +483,13 @@ run_command_1 (char *args, int from_tty, + + dont_repeat (); + ++ if (core_bfd) ++ { ++ core_file_command (NULL, from_tty); ++ if (core_bfd) ++ warning (_("Core file not unloaded.")); ++ } ++ + kill_if_already_running (from_tty); + + init_wait_for_inferior (); +@@ -2373,6 +2380,13 @@ attach_command (char *args, int from_tty + error (_("Not killed.")); + } + ++ if (core_bfd) ++ { ++ core_file_command (NULL, from_tty); ++ if (core_bfd) ++ warning (_("Core file not unloaded.")); ++ } ++ + /* Clean up any leftovers from other runs. Some other things from + this function should probably be moved into target_pre_inferior. */ + target_pre_inferior (from_tty); +--- ./gdb/testsuite/gdb.base/corefile.exp 2010-01-09 01:14:11.000000000 +0100 ++++ ./gdb/testsuite/gdb.base/corefile.exp 2010-05-24 19:38:56.000000000 +0200 +@@ -182,3 +182,62 @@ gdb_load ${binfile} + gdb_test "up" "#\[0-9\]* *\[0-9xa-fH'\]* in .* \\(.*\\).*" "up in corefile.exp (reinit)" + + gdb_test "core" "No core file now." ++ ++ ++# Test a run (start) command will clear any loaded core file. ++ ++gdb_test "core-file $corefile" "Core was generated by .*" "run: load core again" ++gdb_test "info files" "\r\nLocal core dump file:\r\n.*" "run: sanity check we see the core file" ++ ++set test "run: with core" ++if [runto_main] { ++ pass $test ++} else { ++ fail $test ++} ++ ++set test "run: core file is cleared" ++gdb_test_multiple "info files" $test { ++ "\r\nLocal core dump file:\r\n.*\r\n$gdb_prompt $" { ++ fail $test ++ } ++ "\r\n$gdb_prompt $" { ++ pass $test ++ } ++} ++ ++gdb_exit ++ ++ ++# Test an attach command will clear any loaded core file. ++ ++if ![is_remote target] { ++ set test "attach: spawn sleep" ++ set res [remote_spawn host "$binfile sleep"]; ++ if { $res < 0 || $res == "" } { ++ perror "$test failed." ++ fail $test ++ return ++ } ++ set pid [exp_pid -i $res] ++ # We do not care of the startup phase where it will be caught. ++ ++ gdb_start ++ ++ gdb_test "core-file $corefile" "Core was generated by .*" "attach: load core again" ++ gdb_test "info files" "\r\nLocal core dump file:\r\n.*" "attach: sanity check we see the core file" ++ ++ gdb_test "attach $pid" "Attaching to process $pid\r\n.*" "attach: with core" ++ ++ set test "attach: core file is cleared" ++ gdb_test_multiple "info files" $test { ++ "\r\nLocal core dump file:\r\n.*\r\n$gdb_prompt $" { ++ fail $test ++ } ++ "\r\n$gdb_prompt $" { ++ pass $test ++ } ++ } ++ ++ gdb_exit ++} +--- ./gdb/testsuite/gdb.base/coremaker.c 2010-01-01 08:32:00.000000000 +0100 ++++ ./gdb/testsuite/gdb.base/coremaker.c 2010-05-24 19:38:56.000000000 +0200 +@@ -133,8 +133,14 @@ func1 () + func2 (); + } + +-int main () ++int ++main (int argc, char **argv) + { ++ if (argc == 2 && strcmp (argv[1], "sleep") == 0) ++ { ++ sleep (60); ++ return 0; ++ } + mmapdata (); + func1 (); + return 0; diff --git a/gdb-bz601887-dwarf4-rh-test.patch b/gdb-bz601887-dwarf4-rh-test.patch new file mode 100644 index 0000000..4774bda --- /dev/null +++ b/gdb-bz601887-dwarf4-rh-test.patch @@ -0,0 +1,240 @@ +--- /dev/null 2010-06-08 20:35:46.800278452 +0200 ++++ gdb-7.1/gdb/testsuite/gdb.dwarf2/rh-dwarf4-x86_64.S 2010-06-09 15:22:57.000000000 +0200 +@@ -0,0 +1,167 @@ ++/* 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 . */ ++ ++ .file "rh-dwarf4-x86_64.c" ++ .section .debug_abbrev,"",@progbits ++.Ldebug_abbrev0: ++ .section .debug_info,"",@progbits ++.Ldebug_info0: ++ .section .debug_line,"",@progbits ++.Ldebug_line0: ++ .text ++.Ltext0: ++.globl main ++ .type main, @function ++main: ++.LFB0: ++ .file 1 "gdb.dwarf2/rh-dwarf4-x86_64.c" ++ # gdb.dwarf2/rh-dwarf4-x86_64.c:20 ++ .loc 1 20 0 ++ .cfi_startproc ++ # basic block 2 ++ pushq %rbp ++ .cfi_def_cfa_offset 16 ++ movq %rsp, %rbp ++ .cfi_offset 6, -16 ++ .cfi_def_cfa_register 6 ++ # gdb.dwarf2/rh-dwarf4-x86_64.c:21 ++ .loc 1 21 0 ++ movl $0, %eax ++ # gdb.dwarf2/rh-dwarf4-x86_64.c:22 ++ .loc 1 22 0 ++ leave ++ .cfi_def_cfa 7, 8 ++ ret ++ .cfi_endproc ++.LFE0: ++ .size main, .-main ++.Letext0: ++ .section .debug_info ++ .long 0x4e # Length of Compilation Unit Info ++ .value 0x4 # DWARF version number ++ .long .Ldebug_abbrev0 # Offset Into Abbrev. Section ++ .byte 0x8 # Pointer Size (in bytes) ++ .uleb128 0x1 # (DIE (0xb) DW_TAG_compile_unit) ++ .long .LASF0 # DW_AT_producer: "GNU C 4.4.4 20100503 (Red Hat 4.4.4-2)" ++ .byte 0x1 # DW_AT_language ++ .long .LASF1 # DW_AT_name: "gdb.dwarf2/rh-dwarf4-x86_64.c" ++ .long .LASF2 # DW_AT_comp_dir ++ .quad .Ltext0 # DW_AT_low_pc ++ .quad .Letext0 # DW_AT_high_pc ++ .long .Ldebug_line0 # DW_AT_stmt_list ++ .uleb128 0x2 # (DIE (0x2d) DW_TAG_subprogram) ++ # DW_AT_external ++ .long .LASF3 # DW_AT_name: "main" ++ .byte 0x1 # DW_AT_decl_file (gdb.dwarf2/rh-dwarf4-x86_64.c) ++ .byte 0x13 # DW_AT_decl_line ++ # DW_AT_prototyped ++ .long 0x4a # DW_AT_type ++ .quad .LFB0 # DW_AT_low_pc ++ .quad .LFE0 # DW_AT_high_pc ++ .uleb128 0x1 # DW_AT_frame_base ++ .byte 0x9c # DW_OP_call_frame_cfa ++ .uleb128 0x3 # (DIE (0x4a) DW_TAG_base_type) ++ .byte 0x4 # DW_AT_byte_size ++ .byte 0x5 # DW_AT_encoding ++ .ascii "int\0" # DW_AT_name ++ .byte 0x0 # end of children of DIE 0xb ++ .section .debug_abbrev ++ .uleb128 0x1 # (abbrev code) ++ .uleb128 0x11 # (TAG: DW_TAG_compile_unit) ++ .byte 0x1 # DW_children_yes ++ .uleb128 0x25 # (DW_AT_producer) ++ .uleb128 0xe # (DW_FORM_strp) ++ .uleb128 0x13 # (DW_AT_language) ++ .uleb128 0xb # (DW_FORM_data1) ++ .uleb128 0x3 # (DW_AT_name) ++ .uleb128 0xe # (DW_FORM_strp) ++ .uleb128 0x1b # (DW_AT_comp_dir) ++ .uleb128 0xe # (DW_FORM_strp) ++ .uleb128 0x11 # (DW_AT_low_pc) ++ .uleb128 0x1 # (DW_FORM_addr) ++ .uleb128 0x12 # (DW_AT_high_pc) ++ .uleb128 0x1 # (DW_FORM_addr) ++ .uleb128 0x10 # (DW_AT_stmt_list) ++ .uleb128 0x17 # (DW_FORM_sec_offset) ++ .byte 0x0 ++ .byte 0x0 ++ .uleb128 0x2 # (abbrev code) ++ .uleb128 0x2e # (TAG: DW_TAG_subprogram) ++ .byte 0x0 # DW_children_no ++ .uleb128 0x3f # (DW_AT_external) ++ .uleb128 0x19 # (DW_FORM_flag_present) ++ .uleb128 0x3 # (DW_AT_name) ++ .uleb128 0xe # (DW_FORM_strp) ++ .uleb128 0x3a # (DW_AT_decl_file) ++ .uleb128 0xb # (DW_FORM_data1) ++ .uleb128 0x3b # (DW_AT_decl_line) ++ .uleb128 0xb # (DW_FORM_data1) ++ .uleb128 0x27 # (DW_AT_prototyped) ++ .uleb128 0x19 # (DW_FORM_flag_present) ++ .uleb128 0x49 # (DW_AT_type) ++ .uleb128 0x13 # (DW_FORM_ref4) ++ .uleb128 0x11 # (DW_AT_low_pc) ++ .uleb128 0x1 # (DW_FORM_addr) ++ .uleb128 0x12 # (DW_AT_high_pc) ++ .uleb128 0x1 # (DW_FORM_addr) ++ .uleb128 0x40 # (DW_AT_frame_base) ++ .uleb128 0x18 # (DW_FORM_exprloc) ++ .byte 0x0 ++ .byte 0x0 ++ .uleb128 0x3 # (abbrev code) ++ .uleb128 0x24 # (TAG: DW_TAG_base_type) ++ .byte 0x0 # DW_children_no ++ .uleb128 0xb # (DW_AT_byte_size) ++ .uleb128 0xb # (DW_FORM_data1) ++ .uleb128 0x3e # (DW_AT_encoding) ++ .uleb128 0xb # (DW_FORM_data1) ++ .uleb128 0x3 # (DW_AT_name) ++ .uleb128 0x8 # (DW_FORM_string) ++ .byte 0x0 ++ .byte 0x0 ++ .byte 0x0 ++ .section .debug_pubnames,"",@progbits ++ .long 0x17 # Length of Public Names Info ++ .value 0x2 # DWARF Version ++ .long .Ldebug_info0 # Offset of Compilation Unit Info ++ .long 0x52 # Compilation Unit Length ++ .long 0x2d # DIE offset ++ .ascii "main\0" # external name ++ .long 0x0 ++ .section .debug_aranges,"",@progbits ++ .long 0x2c # Length of Address Ranges Info ++ .value 0x2 # DWARF Version ++ .long .Ldebug_info0 # Offset of Compilation Unit Info ++ .byte 0x8 # Size of Address ++ .byte 0x0 # Size of Segment Descriptor ++ .value 0x0 # Pad to 16 byte boundary ++ .value 0x0 ++ .quad .Ltext0 # Address ++ .quad .Letext0-.Ltext0 # Length ++ .quad 0x0 ++ .quad 0x0 ++ .section .debug_str,"MS",@progbits,1 ++.LASF2: ++ .string "." ++.LASF0: ++ .string "GNU C 4.4.4 20100503 (Red Hat 4.4.4-2)" ++.LASF1: ++ .string "gdb.dwarf2/rh-dwarf4-x86_64.c" ++.LASF3: ++ .string "main" ++ .ident "GCC: (GNU) 4.4.4 20100503 (Red Hat 4.4.4-2)" ++ .section .note.GNU-stack,"",@progbits +--- /dev/null 2010-06-08 20:35:46.800278452 +0200 ++++ gdb-7.1/gdb/testsuite/gdb.dwarf2/rh-dwarf4-x86_64.c 2010-06-09 15:21:35.000000000 +0200 +@@ -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 . */ ++ ++int ++main (void) ++{ ++ return 0; ++} +--- /dev/null 2010-06-08 20:35:46.800278452 +0200 ++++ gdb-7.1/gdb/testsuite/gdb.dwarf2/rh-dwarf4-x86_64.exp 2010-06-09 15:26:21.000000000 +0200 +@@ -0,0 +1,42 @@ ++# 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 . ++ ++# This test can only be run on targets which support DWARF-2 and use gas. ++# For now pick a sampling of likely targets. ++if {![istarget *-*-linux*] ++ && ![istarget *-*-gnu*] ++ && ![istarget *-*-elf*] ++ && ![istarget *-*-openbsd*] ++ && ![istarget arm-*-eabi*] ++ && ![istarget powerpc-*-eabi*]} { ++ return 0 ++} ++ ++if {![istarget x86_64-*]} { ++ return 0 ++} ++ ++set testfile "rh-dwarf4-x86_64" ++set srcfile ${testfile}.S ++set executable ${testfile}.x ++set binfile ${objdir}/${subdir}/${executable} ++ ++if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" object {}] != "" } { ++ return -1 ++} ++ ++clean_restart $executable ++ ++gdb_test "ptype main" {type = int \(void\)} diff --git a/gdb-bz614659-prelink-dynbss.patch b/gdb-bz614659-prelink-dynbss.patch new file mode 100644 index 0000000..75514ec --- /dev/null +++ b/gdb-bz614659-prelink-dynbss.patch @@ -0,0 +1,217 @@ +http://sourceware.org/ml/gdb-patches/2010-07/msg00237.html +Subject: [patch] Fix regression on prelinked executables + +Hi, + +there is a regression since gdb-7.0 for a combination of: + * prelinked + * main executable + * using separate debug info + * using copy relocations + +It is since a patch for both PIE and (AFAIK) OSX support: + [commit] syms_from_objfile: Relativize also MAINLINE + http://sourceware.org/ml/gdb-patches/2010-01/msg00080.html + +which started to use problematic addr_info_make_relative even for main +executables. prelink<->gdb discussion at: + https://bugzilla.redhat.com/show_bug.cgi?id=614659 + +Currently in the unfortunately executables GDB has invalid displcement for +symbols in .bss: + int bssvar, *bssvarp = &bssvar; + (gdb) p &bssvar + $1 = (int *) 0x600b54 + (gdb) p bssvarp + $2 = (int *) 0x600b50 + + +addr_info_make_relative could just simply subtract entry point address and +provide single CORE_ADDR objfile->offset (instead of the current +section_offsets array with offsets specific for each section). Linux systems +use always single offset for the whole objfile. AFAIK these per-section +offsets are there for some embedded targets. Curiously GDB already uses at +many places + baseaddr = ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile)); +instead of using offset for the appropriate section at that place and nobody +complains. + + +No regressions on {x86_64,x86_64-m32,i686}-fedora13-linux-gnu. + +Proposing for the gdb-7.2 branch. I had problems fixing up my crashing X. + + +Thanks, +Jan + + +gdb/ +2010-07-15 Jan Kratochvil + + * symfile.c (addr_section_name): New function. + (addrs_section_compar): Use it. + (addr_info_make_relative): Use it. Move variable sect_name into a more + inner block. Make ".dynbss" and ".sdynbss" checks more strict. + +gdb/testsuite/ +2010-07-15 Jan Kratochvil + + * gdb.base/prelink-lib.c (copyreloc): New initialized variable. + * gdb.base/prelink.c (copyreloc, bssvar, bssvarp): New variables. + (main): Use copyreloc. + * gdb.base/prelink.exp (split debug of executable) + (.dynbss vs. .bss address shift): New tests. + +--- a/gdb/symfile.c ++++ b/gdb/symfile.c +@@ -547,6 +547,23 @@ relative_addr_info_to_section_offsets (struct section_offsets *section_offsets, + } + } + ++/* Transform section name S for a name comparison. prelink can split section ++ `.bss' into two sections `.dynbss' and `.bss' (in this order). Similarly ++ prelink can split `.sbss' into `.sdynbss' and `.sbss'. Use virtual address ++ of the new `.dynbss' (`.sdynbss') section as the adjacent new `.bss' ++ (`.sbss') section has invalid (increased) virtual address. */ ++ ++static const char * ++addr_section_name (const char *s) ++{ ++ if (strcmp (s, ".dynbss") == 0) ++ return ".bss"; ++ if (strcmp (s, ".sdynbss") == 0) ++ return ".sbss"; ++ ++ return s; ++} ++ + /* qsort comparator for addrs_section_sort. Sort entries in ascending order by + their (name, sectindex) pair. sectindex makes the sort by name stable. */ + +@@ -557,7 +574,7 @@ addrs_section_compar (const void *ap, const void *bp) + const struct other_sections *b = *((struct other_sections **) bp); + int retval, a_idx, b_idx; + +- retval = strcmp (a->name, b->name); ++ retval = strcmp (addr_section_name (a->name), addr_section_name (b->name)); + if (retval) + return retval; + +@@ -641,14 +658,16 @@ addr_info_make_relative (struct section_addr_info *addrs, bfd *abfd) + + while (*addrs_sorted) + { +- const char *sect_name = (*addrs_sorted)->name; ++ const char *sect_name = addr_section_name ((*addrs_sorted)->name); + + while (*abfd_addrs_sorted +- && strcmp ((*abfd_addrs_sorted)->name, sect_name) < 0) ++ && strcmp (addr_section_name ((*abfd_addrs_sorted)->name), ++ sect_name) < 0) + abfd_addrs_sorted++; + + if (*abfd_addrs_sorted +- && strcmp ((*abfd_addrs_sorted)->name, sect_name) == 0) ++ && strcmp (addr_section_name ((*abfd_addrs_sorted)->name), ++ sect_name) == 0) + { + int index_in_addrs; + +@@ -676,7 +695,6 @@ addr_info_make_relative (struct section_addr_info *addrs, bfd *abfd) + + for (i = 0; i < addrs->num_sections && addrs->other[i].name; i++) + { +- const char *sect_name = addrs->other[i].name; + struct other_sections *sect = addrs_to_abfd_addrs[i]; + + if (sect) +@@ -694,6 +712,9 @@ addr_info_make_relative (struct section_addr_info *addrs, bfd *abfd) + } + else + { ++ /* addr_section_name transformation is not used for SECT_NAME. */ ++ const char *sect_name = addrs->other[i].name; ++ + /* This section does not exist in ABFD, which is normally + unexpected and we want to issue a warning. + +@@ -704,12 +725,20 @@ addr_info_make_relative (struct section_addr_info *addrs, bfd *abfd) + 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. */ ++ created by prelink have no special flags. ++ ++ For the sections `.bss' and `.sbss' see addr_section_name. */ + + if (!(strcmp (sect_name, ".gnu.liblist") == 0 + || strcmp (sect_name, ".gnu.conflict") == 0 +- || strcmp (sect_name, ".dynbss") == 0 +- || strcmp (sect_name, ".sdynbss") == 0)) ++ || (strcmp (sect_name, ".bss") == 0 ++ && i > 0 ++ && strcmp (addrs->other[i - 1].name, ".dynbss") == 0 ++ && addrs_to_abfd_addrs[i - 1] != NULL) ++ || (strcmp (sect_name, ".sbss") == 0 ++ && i > 0 ++ && strcmp (addrs->other[i - 1].name, ".sdynbss") == 0 ++ && addrs_to_abfd_addrs[i - 1] != NULL))) + warning (_("section %s not found in %s"), sect_name, + bfd_get_filename (abfd)); + +--- a/gdb/testsuite/gdb.base/prelink-lib.c ++++ b/gdb/testsuite/gdb.base/prelink-lib.c +@@ -16,6 +16,8 @@ + along with this program. If not, see . + */ + ++int copyreloc = 1; ++ + int + g (void (*p)(void)) + { +--- a/gdb/testsuite/gdb.base/prelink.c ++++ b/gdb/testsuite/gdb.base/prelink.c +@@ -18,6 +18,11 @@ + + #include + ++extern int copyreloc; ++ ++/* Test GDB itself finds `&bssvar' right. */ ++static int bssvar, *bssvarp = &bssvar; ++ + extern void (*h (void)) (void (*)(void)); + + int +@@ -25,5 +30,6 @@ main (void) + { + void (*f) (void (*)(void)) = h (); + printf ("%p\n", f); ++ printf ("%d\n", copyreloc); + f (0); + } +--- a/gdb/testsuite/gdb.base/prelink.exp ++++ b/gdb/testsuite/gdb.base/prelink.exp +@@ -57,6 +57,13 @@ if {$prelink_args == ""} { + return -1 + } + ++set test "split debug of executable" ++if [gdb_gnu_strip_debug $binfile] { ++ fail $test ++} else { ++ pass $test ++} ++ + if ![prelink_yes $prelink_args] { + # Maybe we don't have prelink. + return -1 +@@ -105,3 +112,5 @@ clean_restart $executable + gdb_test_no_output "set verbose on" + + gdb_test "core-file $objdir/$subdir/prelink.core" "Using PIC \\(Position Independent Code\\) prelink displacement 0x\[^0\]\[0-9a-f\]* for \[^\r\n\]*[file tail ${libfile}].*" "seen displacement message" ++ ++gdb_test "p &bssvar == bssvarp" " = 1" ".dynbss vs. .bss address shift" + diff --git a/gdb-bz623749-gcore-relro.patch b/gdb-bz623749-gcore-relro.patch new file mode 100644 index 0000000..4015a7a --- /dev/null +++ b/gdb-bz623749-gcore-relro.patch @@ -0,0 +1,169 @@ +gdb: +https://bugzilla.redhat.com/show_bug.cgi?id=623749 +kernel: +https://bugzilla.redhat.com/show_bug.cgi?id=636937 + +http://sourceware.org/ml/gdb-patches/2010-09/msg00395.html +Subject: Re: [patch] Fix gcore writer for -Wl,-z,relro (PR corefiles/11804) + +gdb/testsuite/ +2010-09-22 Jan Kratochvil + + Fix gcore writer for -Wl,-z,relro. + * gdb.base/gcore-relro.exp: New file. + * gdb.base/gcore-relro-main.c: New file. + * gdb.base/gcore-relro-lib.c: New file. + +--- ./gdb/gcore.c 2010-09-23 20:14:56.000000000 +0200 ++++ ./gdb/gcore.c 2010-09-23 20:37:56.000000000 +0200 +@@ -401,6 +401,7 @@ gcore_create_callback (CORE_ADDR vaddr, + + if (write == 0 && !solib_keep_data_in_core (vaddr, size)) + { ++#if 0 /* https://bugzilla.redhat.com/show_bug.cgi?id=636937 */ + /* See if this region of memory lies inside a known file on disk. + If so, we can avoid copying its contents by clearing SEC_LOAD. */ + struct objfile *objfile; +@@ -433,6 +434,7 @@ gcore_create_callback (CORE_ADDR vaddr, + } + + keep: ++#endif + flags |= SEC_READONLY; + } + +--- /dev/null ++++ b/gdb/testsuite/gdb.base/gcore-relro-lib.c +@@ -0,0 +1,21 @@ ++/* Copyright 2010 Free Software Foundation, Inc. ++ ++ This file is part of GDB. ++ ++ 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 . */ ++ ++void ++lib (void) ++{ ++} +--- /dev/null ++++ b/gdb/testsuite/gdb.base/gcore-relro-main.c +@@ -0,0 +1,25 @@ ++/* Copyright 2010 Free Software Foundation, Inc. ++ ++ This file is part of GDB. ++ ++ 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 . */ ++ ++extern void lib (void); ++ ++int ++main (void) ++{ ++ lib (); ++ return 0; ++} +--- /dev/null ++++ b/gdb/testsuite/gdb.base/gcore-relro.exp +@@ -0,0 +1,80 @@ ++# 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 ++} ++ ++set testfile "gcore-relro" ++set srcmainfile ${testfile}-main.c ++set srclibfile ${testfile}-lib.c ++set libfile ${objdir}/${subdir}/${testfile}-lib.so ++set objfile ${objdir}/${subdir}/${testfile}-main.o ++set executable ${testfile}-main ++set binfile ${objdir}/${subdir}/${executable} ++set gcorefile ${objdir}/${subdir}/${executable}.gcore ++ ++if { [gdb_compile_shlib ${srcdir}/${subdir}/${srclibfile} ${libfile} {debug}] != "" ++ || [gdb_compile ${srcdir}/${subdir}/${srcmainfile} ${objfile} object {debug}] != "" } { ++ untested ${testfile}.exp ++ return -1 ++} ++set opts [list debug shlib=${libfile} additional_flags=-Wl,-z,relro] ++if { [gdb_compile ${objfile} ${binfile} executable $opts] != "" } { ++ unsupported "-Wl,-z,relro compilation failed" ++ return -1 ++} ++ ++clean_restart $executable ++gdb_load_shlibs $libfile ++ ++# Does this gdb support gcore? ++set test "help gcore" ++gdb_test_multiple $test $test { ++ -re "Undefined command: .gcore.*\r\n$gdb_prompt $" { ++ # gcore command not supported -- nothing to test here. ++ unsupported "gdb does not support gcore on this target" ++ return -1; ++ } ++ -re "Save a core file .*\r\n$gdb_prompt $" { ++ pass $test ++ } ++} ++ ++if { ![runto lib] } then { ++ return -1 ++} ++ ++set escapedfilename [string_to_regexp ${gcorefile}] ++ ++set test "save a corefile" ++gdb_test_multiple "gcore ${gcorefile}" $test { ++ -re "Saved corefile ${escapedfilename}\r\n$gdb_prompt $" { ++ pass $test ++ } ++ -re "Can't create a corefile\r\n$gdb_prompt $" { ++ unsupported $test ++ return -1 ++ } ++} ++ ++# Now restart gdb and load the corefile. ++ ++clean_restart $executable ++gdb_load_shlibs $libfile ++ ++gdb_test "core ${gcorefile}" "Core was generated by .*" "re-load generated corefile" ++ ++gdb_test "frame" "#0 \[^\r\n\]* lib .*" "library got loaded" diff --git a/gdb-bz627432-loop-static-self-class.patch b/gdb-bz627432-loop-static-self-class.patch new file mode 100644 index 0000000..7a03f17 --- /dev/null +++ b/gdb-bz627432-loop-static-self-class.patch @@ -0,0 +1,280 @@ +http://sourceware.org/ml/gdb-patches/2010-09/msg00440.html +Subject: [patch] Fix infinite loop crash on self-referencing class + +Hi, + +class C { static C s; }; is a problem for GDB as it references itself and it +can crash. Downstream Bug: + https://bugzilla.redhat.com/show_bug.cgi?id=627432 + +#3 0x00000000005b2cc5 in gnuv3_pass_by_reference (type=0x1044d3c8) at ../../gdb/gnu-v3-abi.c:840 +#4 0x00000000005b2cc5 in gnuv3_pass_by_reference (type=0x1044d3c8) at ../../gdb/gnu-v3-abi.c:840 +[...] + +No regressions on {x86_64,x86_64-m32,i686}-fedora13-linux-gnu. + +FYI the .cc file is not reproducible on - and only on - Fedora 14 GCC, filed: + https://bugzilla.redhat.com/show_bug.cgi?id=637315 + +I would even check it in in some time. + + +Thanks, +Jan + + +gdb/ +2010-09-24 Jan Kratochvil + + Fix GDB crash on inferior calls with self-referencing classes. + * gnu-v3-abi.c (gnuv3_pass_by_reference): Do not call itself on static + member fields. + +gdb/testsuite/ +2010-09-24 Jan Kratochvil + + Fix GDB crash on inferior calls with self-referencing classes. + * gdb.dwarf2/dw2-cp-infcall-ref-static.exp: New file. + * gdb.dwarf2/dw2-cp-infcall-ref-static-main.c: New file. + * gdb.dwarf2/dw2-cp-infcall-ref-static.S: New file. + +--- a/gdb/gnu-v3-abi.c ++++ b/gdb/gnu-v3-abi.c +@@ -835,9 +835,10 @@ gnuv3_pass_by_reference (struct type *type) + by reference, so does this class. Similarly for members, which + are constructed whenever this class is. We do not need to worry + about recursive loops here, since we are only looking at members +- of complete class type. */ ++ of complete class type. Also ignore any static members. */ + for (fieldnum = 0; fieldnum < TYPE_NFIELDS (type); fieldnum++) +- if (gnuv3_pass_by_reference (TYPE_FIELD_TYPE (type, fieldnum))) ++ if (TYPE_FIELD_LOC_KIND (type, fieldnum) == FIELD_LOC_KIND_BITPOS ++ && gnuv3_pass_by_reference (TYPE_FIELD_TYPE (type, fieldnum))) + return 1; + + return 0; +--- /dev/null ++++ b/gdb/testsuite/gdb.dwarf2/dw2-cp-infcall-ref-static-main.c +@@ -0,0 +1,51 @@ ++/* 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 . */ ++ ++/* class C ++ { ++ public: ++ static C s; ++ }; ++ C C::s; ++ C f() ++ { ++ return C::s; ++ } */ ++ ++asm (".globl cu_text_start"); ++asm ("cu_text_start:"); ++ ++asm (".globl f_start"); ++asm ("f_start:"); ++ ++void ++f (void) ++{ ++} ++ ++asm (".globl f_end"); ++asm ("f_end:"); ++ ++int ++main (void) ++{ ++ f (); ++ return 0; ++} ++ ++asm (".globl cu_text_end"); ++asm ("cu_text_end:"); +--- /dev/null ++++ b/gdb/testsuite/gdb.dwarf2/dw2-cp-infcall-ref-static.S +@@ -0,0 +1,115 @@ ++/* 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 . */ ++ ++/* Debug information */ ++ ++ .section .debug_info ++.Lcu1_begin: ++ /* CU header */ ++ .4byte .Lcu1_end - .Lcu1_start /* Length of Compilation Unit */ ++.Lcu1_start: ++ .2byte 2 /* DWARF Version */ ++ .4byte .Labbrev1_begin /* Offset into abbrev section */ ++ .byte 4 /* Pointer size */ ++ ++ /* CU die */ ++ .uleb128 1 /* Abbrev: DW_TAG_compile_unit */ ++ .4byte cu_text_start /* DW_AT_low_pc */ ++ .4byte cu_text_end /* DW_AT_high_pc */ ++ .ascii "file1.txt\0" /* DW_AT_name */ ++ .ascii "GNU C 3.3.3\0" /* DW_AT_producer */ ++ .byte 4 /* DW_AT_language (DW_LANG_C_plus_plus) */ ++ ++.Ltype_class: ++ .uleb128 3 /* Abbrev: DW_TAG_class_type */ ++ .ascii "C\0" /* DW_AT_name */ ++ ++ .uleb128 4 /* Abbrev: DW_TAG_member */ ++ .ascii "s\0" /* DW_AT_name */ ++ .4byte .Ltype_class-.Lcu1_begin /* DW_AT_type */ ++ .byte 1 /* DW_AT_declaration */ ++ .byte 1 /* DW_AT_external */ ++ ++ .byte 0 /* End of children of DW_TAG_class_type */ ++ ++ .uleb128 5 /* Abbrev: DW_TAG_subprogram */ ++ .ascii "f\0" /* DW_AT_name */ ++ .4byte .Ltype_class-.Lcu1_begin /* DW_AT_type */ ++ .4byte f_start /* DW_AT_low_pc */ ++ .4byte f_end /* DW_AT_high_pc */ ++ ++ .byte 0 /* End of children of CU */ ++ ++.Lcu1_end: ++ ++/* Abbrev table */ ++ .section .debug_abbrev ++.Labbrev1_begin: ++ .uleb128 1 /* Abbrev code */ ++ .uleb128 0x11 /* DW_TAG_compile_unit */ ++ .byte 1 /* has_children */ ++ .uleb128 0x11 /* DW_AT_low_pc */ ++ .uleb128 0x1 /* DW_FORM_addr */ ++ .uleb128 0x12 /* DW_AT_high_pc */ ++ .uleb128 0x1 /* DW_FORM_addr */ ++ .uleb128 0x3 /* DW_AT_name */ ++ .uleb128 0x8 /* DW_FORM_string */ ++ .uleb128 0x25 /* DW_AT_producer */ ++ .uleb128 0x8 /* DW_FORM_string */ ++ .uleb128 0x13 /* DW_AT_language */ ++ .uleb128 0xb /* DW_FORM_data1 */ ++ .byte 0x0 /* Terminator */ ++ .byte 0x0 /* Terminator */ ++ ++ .uleb128 3 /* Abbrev code */ ++ .uleb128 0x2 /* DW_TAG_class_type */ ++ .byte 1 /* has_children */ ++ .uleb128 0x3 /* DW_AT_name */ ++ .uleb128 0x8 /* DW_FORM_string */ ++ .byte 0x0 /* Terminator */ ++ .byte 0x0 /* Terminator */ ++ ++ .uleb128 4 /* Abbrev code */ ++ .uleb128 0xd /* DW_TAG_member */ ++ .byte 0 /* has_children */ ++ .uleb128 0x3 /* DW_AT_name */ ++ .uleb128 0x8 /* DW_FORM_string */ ++ .uleb128 0x49 /* DW_AT_type */ ++ .uleb128 0x13 /* DW_FORM_ref4 */ ++ .uleb128 0x3c /* DW_AT_declaration */ ++ .uleb128 0xc /* DW_FORM_flag */ ++ .uleb128 0x3f /* DW_AT_external */ ++ .uleb128 0xc /* DW_FORM_flag */ ++ .byte 0x0 /* Terminator */ ++ .byte 0x0 /* Terminator */ ++ ++ .uleb128 5 /* Abbrev code */ ++ .uleb128 0x2e /* DW_TAG_subprogram */ ++ .byte 0 /* has_children */ ++ .uleb128 0x3 /* DW_AT_name */ ++ .uleb128 0x8 /* DW_FORM_string */ ++ .uleb128 0x49 /* DW_AT_type */ ++ .uleb128 0x13 /* DW_FORM_ref4 */ ++ .uleb128 0x11 /* DW_AT_low_pc */ ++ .uleb128 0x1 /* DW_FORM_addr */ ++ .uleb128 0x12 /* DW_AT_high_pc */ ++ .uleb128 0x1 /* DW_FORM_addr */ ++ .byte 0x0 /* Terminator */ ++ .byte 0x0 /* Terminator */ ++ ++ .byte 0x0 /* Terminator */ ++ .byte 0x0 /* Terminator */ +--- /dev/null ++++ b/gdb/testsuite/gdb.dwarf2/dw2-cp-infcall-ref-static.exp +@@ -0,0 +1,49 @@ ++# 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 . ++ ++# Check that GDB can call C++ functions whose parameters or return values have ++# type containing a static member of the same type. ++ ++# Still no C++ compiler is used. ++if { [skip_cplus_tests] } { continue } ++ ++# This test can only be run on targets which support DWARF-2 and use gas. ++# For now pick a sampling of likely targets. ++if {![istarget *-*-linux*] ++ && ![istarget *-*-gnu*] ++ && ![istarget *-*-elf*] ++ && ![istarget *-*-openbsd*] ++ && ![istarget arm-*-eabi*] ++ && ![istarget powerpc-*-eabi*]} { ++ return 0 ++} ++ ++set testfile "dw2-cp-infcall-ref-static" ++if { [prepare_for_testing ${testfile}.exp ${testfile} [list ${testfile}-main.c ${testfile}.S] {}] } { ++ return -1 ++} ++ ++if ![runto_main] then { ++ return -1 ++} ++ ++# main is not provided by DWARF. ++gdb_test_no_output "set language c++" ++ ++# There are no mangled names in DWARF to suggest the v3 ABI. ++gdb_test_no_output "set cp-abi gnu-v3" ++ ++# GDB could crash. There is no DW_AT_location so it is . ++gdb_test "p f()" { = {static s = }} + diff --git a/gdb-bz631158-cxx-this-lookup.patch b/gdb-bz631158-cxx-this-lookup.patch new file mode 100644 index 0000000..0d7ae05 --- /dev/null +++ b/gdb-bz631158-cxx-this-lookup.patch @@ -0,0 +1,14 @@ +https://bugzilla.redhat.com/show_bug.cgi?id=631158 +http://sourceware.org/ml/gdb-patches/2010-09/msg00229.html +Subject: [patch] PR 11992 "Regression: C++ this scope sometimes does not work" + +--- gdb-7.2/gdb/c-exp.y.orig 2010-08-19 17:50:00.000000000 +0200 ++++ gdb-7.2/gdb/c-exp.y 2010-09-11 20:30:15.000000000 +0200 +@@ -2422,6 +2422,7 @@ classify_name (struct block *block) + + if (sym == NULL + && parse_language->la_language == language_cplus ++ && !is_a_field_of_this + && !lookup_minimal_symbol (copy, NULL, NULL)) + return UNKNOWN_CPP_NAME; + diff --git a/gdb-bz631575-gdb-index-nobits.patch b/gdb-bz631575-gdb-index-nobits.patch new file mode 100644 index 0000000..707a613 --- /dev/null +++ b/gdb-bz631575-gdb-index-nobits.patch @@ -0,0 +1,61 @@ +http://sourceware.org/ml/gdb-patches/2010-09/msg00183.html +Subject: [patch] .gdb_index: Do not crash on NOBITS + +Hi, + +elfutils-0.148 still do not contain patch of its GIT +804e9ca4d644e64a6125307cbf0a0b89477d7611 where the .gdb_index section has been +also split into the separate debug info file. + +Due to it binaries split using elfutils-0.148 contain + [38] .gdb_index NOBITS 0000000000000000 0000338c +instead of expected + [28] .gdb_index PROGBITS 0000000000000000 0000211c + +and due to it GDB while reading the file can error() by: +Reading symbols from x.debug...Dwarf Error: Can't read DWARF data from 'x.debug' + +which should not be fatal but due to some other bugs therein it can crash GDB. + +The wrong separate debug info file is for example: +http://kojipkgs.fedoraproject.org/packages/glibc/2.12.90/10/x86_64/glibc-debuginfo-2.12.90-10.x86_64.rpm +/usr/lib/debug/lib64/libutil-2.12.90.so.debug + +OK to check-in? + +It does not attempt to use .gdb_index from the main binary, it will just +disable .gdb_index usage on these binaries. + + +Thanks, +Jan + + +http://sourceware.org/ml/gdb-cvs/2010-09/msg00062.html + +### src/gdb/ChangeLog 2010/09/08 19:09:42 1.12162 +### src/gdb/ChangeLog 2010/09/08 19:49:28 1.12163 +## -1,3 +1,7 @@ ++2010-09-08 Jan Kratochvil ++ ++ * dwarf2read.c (dwarf2_read_index): Return on no SEC_HAS_CONTENTS. ++ + 2010-09-08 Daniel Jacobowitz + + * dwarf2read.c (read_structure_type): Move processing of +--- src/gdb/dwarf2read.c 2010/09/08 19:09:42 1.452 ++++ src/gdb/dwarf2read.c 2010/09/08 19:49:28 1.453 +@@ -1904,6 +1904,13 @@ + if (dwarf2_per_objfile->gdb_index.asection == NULL + || dwarf2_per_objfile->gdb_index.size == 0) + return 0; ++ ++ /* Older elfutils strip versions could keep the section in the main ++ executable while splitting it for the separate debug info file. */ ++ if ((bfd_get_file_flags (dwarf2_per_objfile->gdb_index.asection) ++ & SEC_HAS_CONTENTS) == 0) ++ return 0; ++ + dwarf2_read_section (objfile, &dwarf2_per_objfile->gdb_index); + + addr = dwarf2_per_objfile->gdb_index.buffer; diff --git a/gdb-bz634660-gdbpy-load-on-attach.patch b/gdb-bz634660-gdbpy-load-on-attach.patch new file mode 100644 index 0000000..2223776 --- /dev/null +++ b/gdb-bz634660-gdbpy-load-on-attach.patch @@ -0,0 +1,61 @@ +http://sourceware.org/ml/gdb-patches/2010-09/msg00365.html +Subject: [patch] python: load *-gdb.py for shlibs during attach + +Hi, + +currently if you attach to or load a core file for executable, its -gdb.py +script is loaded. But none -gdb.py for the shared libraries. + +Spawned or with the fix (libstdc++-gdb.py): +#1 0x00000000004007b5 in f (s="a") at 1.C:4 + ^ is std::string + +Attached/core without the fix: +#1 0x00000000004007b5 in f (s=...) at 1.C:4 + +No regressions on {x86_64,x86_64-m32,i686}-fedora13-linux-gnu. + +Mostly obvious, I will check it in later. + + +Thanks, +Jan + + +gdb/ +2010-09-22 Jan Kratochvil + + * main.c: Include objfiles.h. + (captured_main): New variable objfile. Call + load_auto_scripts_for_objfile for ALL_OBJFILES. + +--- ./gdb/main.c 2010-09-22 10:51:32.000000000 +0200 ++++ ./gdb/main.c 2010-09-22 10:50:44.000000000 +0200 +@@ -43,6 +43,7 @@ + #include "source.h" + #include "cli/cli-cmds.h" + #include "python/python.h" ++#include "objfiles.h" + + /* The selected interpreter. This will be used as a set command + variable, so it should always be malloc'ed - since +@@ -323,6 +324,7 @@ captured_main (void *data) + + int i; + int save_auto_load; ++ struct objfile *objfile; + + struct cleanup *pre_stat_chain = make_command_stats_cleanup (0); + +@@ -957,8 +959,8 @@ Can't attach to process and specify a co + We wait until now because it is common to add to the source search + path in local_gdbinit. */ + gdbpy_global_auto_load = save_auto_load; +- if (symfile_objfile != NULL) +- load_auto_scripts_for_objfile (symfile_objfile); ++ ALL_OBJFILES (objfile) ++ load_auto_scripts_for_objfile (objfile); + + for (i = 0; i < ncmd; i++) + { + diff --git a/gdb-bz637770-ifunc-watchpoint-delete.patch b/gdb-bz637770-ifunc-watchpoint-delete.patch new file mode 100644 index 0000000..17015dd --- /dev/null +++ b/gdb-bz637770-ifunc-watchpoint-delete.patch @@ -0,0 +1,111 @@ +commit 30fedadf224a8c119575fcc8a6ced51f0d4aee9f +Author: Jan Kratochvil +Date: Wed Sep 29 01:25:39 2010 +0200 + + Fix the crash. + +commit d101ce597f2d6143e9f023a4444352bceffb2679 +Author: Jan Kratochvil +Date: Wed Sep 29 00:42:37 2010 +0200 + + New testcase for: https://bugzilla.redhat.com/show_bug.cgi?id=637770 + +diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c +index de51231..18b7868 100644 +--- a/gdb/breakpoint.c ++++ b/gdb/breakpoint.c +@@ -10560,6 +10560,11 @@ map_breakpoint_numbers (char *args, void (*function) (struct breakpoint *, + /* FUNCTION can be also delete_breakpoint. */ + next_related_b = related_breakpoint->related_breakpoint; + function (related_breakpoint, data); ++ ++ /* For delete_breakpoint of the last entry of the ring we ++ were traversing we would never get back to B. */ ++ if (next_related_b == related_breakpoint) ++ break; + related_breakpoint = next_related_b; + } + while (related_breakpoint != b); +diff --git a/gdb/testsuite/gdb.base/watchpoint-delete.c b/gdb/testsuite/gdb.base/watchpoint-delete.c +new file mode 100644 +index 0000000..031ef92 +--- /dev/null ++++ b/gdb/testsuite/gdb.base/watchpoint-delete.c +@@ -0,0 +1,33 @@ ++/* 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 . */ ++ ++void ++func (void) ++{ ++ volatile int x = 0; ++ ++ x++; /* break-here */ ++ x++; ++} ++ ++int ++main (void) ++{ ++ func (); ++ ++ return 0; ++} +diff --git a/gdb/testsuite/gdb.base/watchpoint-delete.exp b/gdb/testsuite/gdb.base/watchpoint-delete.exp +new file mode 100644 +index 0000000..45bc650 +--- /dev/null ++++ b/gdb/testsuite/gdb.base/watchpoint-delete.exp +@@ -0,0 +1,38 @@ ++# 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 . ++ ++set testfile "watchpoint-delete" ++set srcfile ${testfile}.c ++set binfile ${objdir}/${subdir}/${testfile} ++ ++if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile}] } { ++ untested ${testfile}.exp ++ return -1 ++} ++ ++# It is more compatible this way. ++gdb_test_no_output "set can-use-hw-watchpoints 0" ++ ++if ![runto_main] { ++ return -1 ++} ++ ++# Ensure there is a parent frame to create related bp_watchpoint_scope. ++gdb_breakpoint [gdb_get_line_number "break-here"] ++gdb_continue_to_breakpoint "break-here" ".* break-here .*" ++ ++gdb_test "watch x" {Watchpoint [0-9]+: x} ++ ++gdb_test_no_output {delete $bpnum} diff --git a/gdb-ccache-workaround.patch b/gdb-ccache-workaround.patch new file mode 100644 index 0000000..86147bf --- /dev/null +++ b/gdb-ccache-workaround.patch @@ -0,0 +1,17 @@ +--- a/gdb/testsuite/gdb.base/macscp.exp ++++ b/gdb/testsuite/gdb.base/macscp.exp +@@ -33,6 +33,14 @@ if [test_compiler_info gcc*] { + lappend options additional_flags=-g3 + } + ++# Workaround ccache making lineno non-zero for command-line definitions. ++if {[find_gcc] == "gcc" && [file executable "/usr/bin/gcc"]} { ++ set result [catch "exec which gcc" output] ++ if {$result == 0 && [string first "/ccache/" $output] >= -1} { ++ lappend options "compiler=/usr/bin/gcc" ++ } ++} ++ + # Generate the intermediate object file. This is required by Darwin to + # have access to the .debug_macinfo section. + if {[gdb_compile "${srcdir}/${subdir}/macscp1.c" "${objfile}" \ diff --git a/gdb-core-open-vdso-warning.patch b/gdb-core-open-vdso-warning.patch index d05e72b..056a28c 100644 --- a/gdb-core-open-vdso-warning.patch +++ b/gdb-core-open-vdso-warning.patch @@ -33,9 +33,11 @@ gdb/ [ Context backport. ] ---- a/gdb/solib-svr4.c -+++ b/gdb/solib-svr4.c -@@ -1097,8 +1097,18 @@ svr4_current_sos (void) +Index: gdb-7.1.90.20100711/gdb/solib-svr4.c +=================================================================== +--- gdb-7.1.90.20100711.orig/gdb/solib-svr4.c 2010-07-12 23:07:35.000000000 +0200 ++++ gdb-7.1.90.20100711/gdb/solib-svr4.c 2010-07-13 00:19:03.000000000 +0200 +@@ -1177,8 +1177,18 @@ svr4_current_sos (void) target_read_string (LM_NAME (new), &buffer, SO_NAME_MAX_PATH_SIZE - 1, &errcode); if (errcode != 0) @@ -56,9 +58,11 @@ gdb/ else { struct build_id *build_id; ---- a/gdb/solib.c -+++ b/gdb/solib.c -@@ -538,6 +538,7 @@ update_solib_list (int from_tty, struct target_ops *target) +Index: gdb-7.1.90.20100711/gdb/solib.c +=================================================================== +--- gdb-7.1.90.20100711.orig/gdb/solib.c 2010-05-17 01:49:58.000000000 +0200 ++++ gdb-7.1.90.20100711/gdb/solib.c 2010-07-13 00:21:01.000000000 +0200 +@@ -705,6 +705,7 @@ update_solib_list (int from_tty, struct struct target_so_ops *ops = solib_ops (target_gdbarch); struct so_list *inferior = ops->current_sos(); struct so_list *gdb, **gdb_link; @@ -66,17 +70,16 @@ gdb/ /* We can reach here due to changing solib-search-path or the sysroot, before having any inferior. */ -@@ -668,6 +669,12 @@ update_solib_list (int from_tty, struct target_ops *target) +@@ -844,6 +845,12 @@ Error while mapping shared library secti observer_notify_solib_loaded (i); } - } + ++ /* If this was the very first DSO list scan and we possibly read in ld.so ++ recheck all the formerly unreadable DSO names strings. */ + -+ /* If this was the very first DSO list scan and we possibly read in ld.so -+ recheck all the formerly unreadable DSO names strings. */ ++ if (saved_so_list_head == NULL && so_list_head != NULL) ++ return update_solib_list (from_tty, target); + -+ if (saved_so_list_head == NULL && so_list_head != NULL) -+ update_solib_list (from_tty, target); - } - - - + /* If a library was not found, issue an appropriate warning + message. We have to use a single call to warning in case the + front end does something special with warnings, e.g., pop up diff --git a/gdb-false-gcc-warning.patch b/gdb-false-gcc-warning.patch new file mode 100644 index 0000000..22ad08c --- /dev/null +++ b/gdb-false-gcc-warning.patch @@ -0,0 +1,11 @@ +--- gdb-7.1.90.20100806/gdb/infcall.c.orig 2010-08-10 00:34:10.000000000 +0200 ++++ gdb-7.1.90.20100806/gdb/infcall.c 2010-08-10 00:36:03.000000000 +0200 +@@ -284,7 +284,7 @@ find_function_addr (struct value *functi + struct type *ftype = check_typedef (value_type (function)); + struct gdbarch *gdbarch = get_type_arch (ftype); + struct type *value_type = NULL; +- CORE_ADDR funaddr; ++ CORE_ADDR funaddr = 0; /* GCC false -fprofile-use warning. */ + + /* If it's a member function, just look at the function + part of it. */ diff --git a/gdb-follow-child-stale-parent.patch b/gdb-follow-child-stale-parent.patch new file mode 100644 index 0000000..336790c --- /dev/null +++ b/gdb-follow-child-stale-parent.patch @@ -0,0 +1,27 @@ +Problem occurs with python and its get_current_arch () as it selects +selected_frame and current_frame while still inferior_ptid is valid for the +original parent. But since this place it is already attached and later +unwinders try to access it, breaking: + -PASS: gdb.threads/watchpoint-fork.exp: child: singlethreaded: breakpoint after the first fork + -PASS: gdb.threads/watchpoint-fork.exp: child: singlethreaded: watchpoint after the first fork + -PASS: gdb.threads/watchpoint-fork.exp: child: singlethreaded: breakpoint after the second fork + -PASS: gdb.threads/watchpoint-fork.exp: child: singlethreaded: watchpoint after the second fork + -PASS: gdb.threads/watchpoint-fork.exp: child: singlethreaded: finish + +FAIL: gdb.threads/watchpoint-fork.exp: child: singlethreaded: breakpoint after the first fork + +FAIL: gdb.threads/watchpoint-fork.exp: child: singlethreaded: watchpoint after the first fork + +FAIL: gdb.threads/watchpoint-fork.exp: child: singlethreaded: breakpoint after the second fork + +FAIL: gdb.threads/watchpoint-fork.exp: child: singlethreaded: watchpoint after the second fork + +FAIL: gdb.threads/watchpoint-fork.exp: child: singlethreaded: finish + +--- ./gdb/infrun.c 2009-12-21 20:26:30.000000000 +0100 ++++ ./gdb/infrun.c 2009-12-21 20:26:11.000000000 +0100 +@@ -375,6 +375,9 @@ follow_fork (void) + } + else + { ++ /* Possibly referenced PARENT is no longer valid. */ ++ reinit_frame_cache (); ++ + /* This pending follow fork event is now handled, one way + or another. The previous selected thread may be gone + from the lists by now, but if it is still around, need diff --git a/gdb-fortran-common-reduce.patch b/gdb-fortran-common-reduce.patch new file mode 100644 index 0000000..3b843b8 --- /dev/null +++ b/gdb-fortran-common-reduce.patch @@ -0,0 +1,507 @@ +Index: gdb-7.1.90.20100711/gdb/f-lang.c +=================================================================== +--- gdb-7.1.90.20100711.orig/gdb/f-lang.c 2010-06-03 00:41:55.000000000 +0200 ++++ gdb-7.1.90.20100711/gdb/f-lang.c 2010-07-13 00:24:04.000000000 +0200 +@@ -56,20 +56,6 @@ typedef struct saved_bf_symnum SAVED_BF, + /* Local functions */ + + extern void _initialize_f_language (void); +-#if 0 +-static void clear_function_list (void); +-static long get_bf_for_fcn (long); +-static void clear_bf_list (void); +-static void patch_all_commons_by_name (char *, CORE_ADDR, int); +-static SAVED_F77_COMMON_PTR find_first_common_named (char *); +-static void add_common_entry (struct symbol *); +-static void add_common_block (char *, CORE_ADDR, int, char *); +-static SAVED_FUNCTION *allocate_saved_function_node (void); +-static SAVED_BF_PTR allocate_saved_bf_node (void); +-static COMMON_ENTRY_PTR allocate_common_entry_node (void); +-static SAVED_F77_COMMON_PTR allocate_saved_f77_common_node (void); +-static void patch_common_entries (SAVED_F77_COMMON_PTR, CORE_ADDR, int); +-#endif + + static void f_printchar (int c, struct type *type, struct ui_file * stream); + static void f_emit_char (int c, struct type *type, +@@ -458,185 +444,7 @@ _initialize_f_language (void) + add_language (&f_language_defn); + } + +-#if 0 +-static SAVED_BF_PTR +-allocate_saved_bf_node (void) +-{ +- SAVED_BF_PTR new; +- +- new = (SAVED_BF_PTR) xmalloc (sizeof (SAVED_BF)); +- return (new); +-} +- +-static SAVED_FUNCTION * +-allocate_saved_function_node (void) +-{ +- SAVED_FUNCTION *new; +- +- new = (SAVED_FUNCTION *) xmalloc (sizeof (SAVED_FUNCTION)); +- return (new); +-} +- +-static SAVED_F77_COMMON_PTR +-allocate_saved_f77_common_node (void) +-{ +- SAVED_F77_COMMON_PTR new; +- +- new = (SAVED_F77_COMMON_PTR) xmalloc (sizeof (SAVED_F77_COMMON)); +- return (new); +-} +- +-static COMMON_ENTRY_PTR +-allocate_common_entry_node (void) +-{ +- COMMON_ENTRY_PTR new; +- +- new = (COMMON_ENTRY_PTR) xmalloc (sizeof (COMMON_ENTRY)); +- return (new); +-} +-#endif +- + SAVED_F77_COMMON_PTR head_common_list = NULL; /* Ptr to 1st saved COMMON */ +-SAVED_F77_COMMON_PTR tail_common_list = NULL; /* Ptr to last saved COMMON */ +-SAVED_F77_COMMON_PTR current_common = NULL; /* Ptr to current COMMON */ +- +-#if 0 +-static SAVED_BF_PTR saved_bf_list = NULL; /* Ptr to (.bf,function) +- list */ +-static SAVED_BF_PTR saved_bf_list_end = NULL; /* Ptr to above list's end */ +-static SAVED_BF_PTR current_head_bf_list = NULL; /* Current head of above list +- */ +- +-static SAVED_BF_PTR tmp_bf_ptr; /* Generic temporary for use +- in macros */ +- +-/* The following function simply enters a given common block onto +- the global common block chain */ +- +-static void +-add_common_block (char *name, CORE_ADDR offset, int secnum, char *func_stab) +-{ +- SAVED_F77_COMMON_PTR tmp; +- char *c, *local_copy_func_stab; +- +- /* If the COMMON block we are trying to add has a blank +- name (i.e. "#BLNK_COM") then we set it to __BLANK +- because the darn "#" character makes GDB's input +- parser have fits. */ +- +- +- if (strcmp (name, BLANK_COMMON_NAME_ORIGINAL) == 0 +- || strcmp (name, BLANK_COMMON_NAME_MF77) == 0) +- { +- +- xfree (name); +- name = alloca (strlen (BLANK_COMMON_NAME_LOCAL) + 1); +- strcpy (name, BLANK_COMMON_NAME_LOCAL); +- } +- +- tmp = allocate_saved_f77_common_node (); +- +- local_copy_func_stab = xmalloc (strlen (func_stab) + 1); +- strcpy (local_copy_func_stab, func_stab); +- +- tmp->name = xmalloc (strlen (name) + 1); +- +- /* local_copy_func_stab is a stabstring, let us first extract the +- function name from the stab by NULLing out the ':' character. */ +- +- +- c = NULL; +- c = strchr (local_copy_func_stab, ':'); +- +- if (c) +- *c = '\0'; +- else +- error (_("Malformed function STAB found in add_common_block()")); +- +- +- tmp->owning_function = xmalloc (strlen (local_copy_func_stab) + 1); +- +- strcpy (tmp->owning_function, local_copy_func_stab); +- +- strcpy (tmp->name, name); +- tmp->offset = offset; +- tmp->next = NULL; +- tmp->entries = NULL; +- tmp->secnum = secnum; +- +- current_common = tmp; +- +- if (head_common_list == NULL) +- { +- head_common_list = tail_common_list = tmp; +- } +- else +- { +- tail_common_list->next = tmp; +- tail_common_list = tmp; +- } +-} +-#endif +- +-/* The following function simply enters a given common entry onto +- the "current_common" block that has been saved away. */ +- +-#if 0 +-static void +-add_common_entry (struct symbol *entry_sym_ptr) +-{ +- COMMON_ENTRY_PTR tmp; +- +- +- +- /* The order of this list is important, since +- we expect the entries to appear in decl. +- order when we later issue "info common" calls */ +- +- tmp = allocate_common_entry_node (); +- +- tmp->next = NULL; +- tmp->symbol = entry_sym_ptr; +- +- if (current_common == NULL) +- error (_("Attempt to add COMMON entry with no block open!")); +- else +- { +- if (current_common->entries == NULL) +- { +- current_common->entries = tmp; +- current_common->end_of_entries = tmp; +- } +- else +- { +- current_common->end_of_entries->next = tmp; +- current_common->end_of_entries = tmp; +- } +- } +-} +-#endif +- +-/* This routine finds the first encountred COMMON block named "name" */ +- +-#if 0 +-static SAVED_F77_COMMON_PTR +-find_first_common_named (char *name) +-{ +- +- SAVED_F77_COMMON_PTR tmp; +- +- tmp = head_common_list; +- +- while (tmp != NULL) +- { +- if (strcmp (tmp->name, name) == 0) +- return (tmp); +- else +- tmp = tmp->next; +- } +- return (NULL); +-} +-#endif + + /* This routine finds the first encountred COMMON block named "name" + that belongs to function funcname */ +@@ -659,193 +467,3 @@ find_common_for_function (char *name, ch + } + return (NULL); + } +- +- +-#if 0 +- +-/* The following function is called to patch up the offsets +- for the statics contained in the COMMON block named +- "name." */ +- +-static void +-patch_common_entries (SAVED_F77_COMMON_PTR blk, CORE_ADDR offset, int secnum) +-{ +- COMMON_ENTRY_PTR entry; +- +- blk->offset = offset; /* Keep this around for future use. */ +- +- entry = blk->entries; +- +- while (entry != NULL) +- { +- SYMBOL_VALUE (entry->symbol) += offset; +- SYMBOL_SECTION (entry->symbol) = secnum; +- +- entry = entry->next; +- } +- blk->secnum = secnum; +-} +- +-/* Patch all commons named "name" that need patching.Since COMMON +- blocks occur with relative infrequency, we simply do a linear scan on +- the name. Eventually, the best way to do this will be a +- hashed-lookup. Secnum is the section number for the .bss section +- (which is where common data lives). */ +- +-static void +-patch_all_commons_by_name (char *name, CORE_ADDR offset, int secnum) +-{ +- +- SAVED_F77_COMMON_PTR tmp; +- +- /* For blank common blocks, change the canonical reprsentation +- of a blank name */ +- +- if (strcmp (name, BLANK_COMMON_NAME_ORIGINAL) == 0 +- || strcmp (name, BLANK_COMMON_NAME_MF77) == 0) +- { +- xfree (name); +- name = alloca (strlen (BLANK_COMMON_NAME_LOCAL) + 1); +- strcpy (name, BLANK_COMMON_NAME_LOCAL); +- } +- +- tmp = head_common_list; +- +- while (tmp != NULL) +- { +- if (COMMON_NEEDS_PATCHING (tmp)) +- if (strcmp (tmp->name, name) == 0) +- patch_common_entries (tmp, offset, secnum); +- +- tmp = tmp->next; +- } +-} +-#endif +- +-/* This macro adds the symbol-number for the start of the function +- (the symbol number of the .bf) referenced by symnum_fcn to a +- list. This list, in reality should be a FIFO queue but since +- #line pragmas sometimes cause line ranges to get messed up +- we simply create a linear list. This list can then be searched +- first by a queueing algorithm and upon failure fall back to +- a linear scan. */ +- +-#if 0 +-#define ADD_BF_SYMNUM(bf_sym,fcn_sym) \ +- \ +- if (saved_bf_list == NULL) \ +-{ \ +- tmp_bf_ptr = allocate_saved_bf_node(); \ +- \ +- tmp_bf_ptr->symnum_bf = (bf_sym); \ +- tmp_bf_ptr->symnum_fcn = (fcn_sym); \ +- tmp_bf_ptr->next = NULL; \ +- \ +- current_head_bf_list = saved_bf_list = tmp_bf_ptr; \ +- saved_bf_list_end = tmp_bf_ptr; \ +- } \ +-else \ +-{ \ +- tmp_bf_ptr = allocate_saved_bf_node(); \ +- \ +- tmp_bf_ptr->symnum_bf = (bf_sym); \ +- tmp_bf_ptr->symnum_fcn = (fcn_sym); \ +- tmp_bf_ptr->next = NULL; \ +- \ +- saved_bf_list_end->next = tmp_bf_ptr; \ +- saved_bf_list_end = tmp_bf_ptr; \ +- } +-#endif +- +-/* This function frees the entire (.bf,function) list */ +- +-#if 0 +-static void +-clear_bf_list (void) +-{ +- +- SAVED_BF_PTR tmp = saved_bf_list; +- SAVED_BF_PTR next = NULL; +- +- while (tmp != NULL) +- { +- next = tmp->next; +- xfree (tmp); +- tmp = next; +- } +- saved_bf_list = NULL; +-} +-#endif +- +-int global_remote_debug; +- +-#if 0 +- +-static long +-get_bf_for_fcn (long the_function) +-{ +- SAVED_BF_PTR tmp; +- int nprobes = 0; +- +- /* First use a simple queuing algorithm (i.e. look and see if the +- item at the head of the queue is the one you want) */ +- +- if (saved_bf_list == NULL) +- internal_error (__FILE__, __LINE__, +- _("cannot get .bf node off empty list")); +- +- if (current_head_bf_list != NULL) +- if (current_head_bf_list->symnum_fcn == the_function) +- { +- if (global_remote_debug) +- fprintf_unfiltered (gdb_stderr, "*"); +- +- tmp = current_head_bf_list; +- current_head_bf_list = current_head_bf_list->next; +- return (tmp->symnum_bf); +- } +- +- /* If the above did not work (probably because #line directives were +- used in the sourcefile and they messed up our internal tables) we now do +- the ugly linear scan */ +- +- if (global_remote_debug) +- fprintf_unfiltered (gdb_stderr, "\ndefaulting to linear scan\n"); +- +- nprobes = 0; +- tmp = saved_bf_list; +- while (tmp != NULL) +- { +- nprobes++; +- if (tmp->symnum_fcn == the_function) +- { +- if (global_remote_debug) +- fprintf_unfiltered (gdb_stderr, "Found in %d probes\n", nprobes); +- current_head_bf_list = tmp->next; +- return (tmp->symnum_bf); +- } +- tmp = tmp->next; +- } +- +- return (-1); +-} +- +-static SAVED_FUNCTION_PTR saved_function_list = NULL; +-static SAVED_FUNCTION_PTR saved_function_list_end = NULL; +- +-static void +-clear_function_list (void) +-{ +- SAVED_FUNCTION_PTR tmp = saved_function_list; +- SAVED_FUNCTION_PTR next = NULL; +- +- while (tmp != NULL) +- { +- next = tmp->next; +- xfree (tmp); +- tmp = next; +- } +- +- saved_function_list = NULL; +-} +-#endif +Index: gdb-7.1.90.20100711/gdb/f-lang.h +=================================================================== +--- gdb-7.1.90.20100711.orig/gdb/f-lang.h 2010-07-12 23:07:33.000000000 +0200 ++++ gdb-7.1.90.20100711/gdb/f-lang.h 2010-07-13 00:24:04.000000000 +0200 +@@ -76,14 +76,9 @@ typedef struct saved_f77_common SAVED_F7 + typedef struct common_entry COMMON_ENTRY, *COMMON_ENTRY_PTR; + + extern SAVED_F77_COMMON_PTR head_common_list; /* Ptr to 1st saved COMMON */ +-extern SAVED_F77_COMMON_PTR tail_common_list; /* Ptr to last saved COMMON */ +-extern SAVED_F77_COMMON_PTR current_common; /* Ptr to current COMMON */ + + extern SAVED_F77_COMMON_PTR find_common_for_function (char *, char *); + +-#define UNINITIALIZED_SECNUM -1 +-#define COMMON_NEEDS_PATCHING(blk) ((blk)->secnum == UNINITIALIZED_SECNUM) +- + #define BLANK_COMMON_NAME_ORIGINAL "#BLNK_COM" /* XLF assigned */ + #define BLANK_COMMON_NAME_MF77 "__BLNK__" /* MF77 assigned */ + #define BLANK_COMMON_NAME_LOCAL "__BLANK" /* Local GDB */ +Index: gdb-7.1.90.20100711/gdb/f-valprint.c +=================================================================== +--- gdb-7.1.90.20100711.orig/gdb/f-valprint.c 2010-07-12 23:07:33.000000000 +0200 ++++ gdb-7.1.90.20100711/gdb/f-valprint.c 2010-07-13 00:24:25.000000000 +0200 +@@ -35,10 +35,6 @@ + #include "command.h" + #include "block.h" + +-#if 0 +-static int there_is_a_visible_common_named (char *); +-#endif +- + extern void _initialize_f_valprint (void); + static void info_common_command (char *, int); + static void list_all_visible_commons (char *); +@@ -601,67 +597,6 @@ info_common_command (char *comname, int + comname, funname); + } + +-/* This function is used to determine whether there is a +- F77 common block visible at the current scope called 'comname'. */ +- +-#if 0 +-static int +-there_is_a_visible_common_named (char *comname) +-{ +- SAVED_F77_COMMON_PTR the_common; +- struct frame_info *fi; +- char *funname = 0; +- struct symbol *func; +- +- if (comname == NULL) +- error (_("Cannot deal with NULL common name!")); +- +- fi = get_selected_frame (_("No frame selected")); +- +- /* The following is generally ripped off from stack.c's routine +- print_frame_info() */ +- +- func = find_pc_function (fi->pc); +- if (func) +- { +- /* In certain pathological cases, the symtabs give the wrong +- function (when we are in the first function in a file which +- is compiled without debugging symbols, the previous function +- is compiled with debugging symbols, and the "foo.o" symbol +- that is supposed to tell us where the file with debugging symbols +- ends has been truncated by ar because it is longer than 15 +- characters). +- +- So look in the minimal symbol tables as well, and if it comes +- up with a larger address for the function use that instead. +- I don't think this can ever cause any problems; there shouldn't +- be any minimal symbols in the middle of a function. +- FIXME: (Not necessarily true. What about text labels) */ +- +- struct minimal_symbol *msymbol = lookup_minimal_symbol_by_pc (fi->pc); +- +- if (msymbol != NULL +- && (SYMBOL_VALUE_ADDRESS (msymbol) +- > BLOCK_START (SYMBOL_BLOCK_VALUE (func)))) +- funname = SYMBOL_LINKAGE_NAME (msymbol); +- else +- funname = SYMBOL_LINKAGE_NAME (func); +- } +- else +- { +- struct minimal_symbol *msymbol = +- lookup_minimal_symbol_by_pc (fi->pc); +- +- if (msymbol != NULL) +- funname = SYMBOL_LINKAGE_NAME (msymbol); +- } +- +- the_common = find_common_for_function (comname, funname); +- +- return (the_common ? 1 : 0); +-} +-#endif +- + void + _initialize_f_valprint (void) + { diff --git a/gdb-fortran-common.patch b/gdb-fortran-common.patch new file mode 100644 index 0000000..63fa81c --- /dev/null +++ b/gdb-fortran-common.patch @@ -0,0 +1,580 @@ +Index: gdb-7.1.90.20100711/gdb/dwarf2read.c +=================================================================== +--- gdb-7.1.90.20100711.orig/gdb/dwarf2read.c 2010-07-13 00:13:02.000000000 +0200 ++++ gdb-7.1.90.20100711/gdb/dwarf2read.c 2010-07-13 00:26:25.000000000 +0200 +@@ -5727,12 +5727,14 @@ read_set_type (struct die_info *die, str + return set_die_type (die, set_type, cu); + } + +-/* First cut: install each common block member as a global variable. */ ++/* Create appropriate locally-scoped variables for all the DW_TAG_common_block ++ entries. Create also TYPE_CODE_STRUCT listing all such variables to be ++ available for `info common'. COMMON_BLOCK_DOMAIN is used to sepate the ++ common blocks name namespace from regular variable names. */ + + static void + read_common_block (struct die_info *die, struct dwarf2_cu *cu) + { +- struct die_info *child_die; + struct attribute *attr; + struct symbol *sym; + CORE_ADDR base = (CORE_ADDR) 0; +@@ -5757,10 +5759,40 @@ read_common_block (struct die_info *die, + } + if (die->child != NULL) + { ++ struct objfile *objfile = cu->objfile; ++ struct die_info *child_die; ++ struct type *type; ++ struct field *field; ++ char *name; ++ struct symbol *sym; ++ ++ type = alloc_type (objfile); ++ TYPE_CODE (type) = TYPE_CODE_STRUCT; ++ /* Artificial type to be used only by `info common'. */ ++ TYPE_NAME (type) = ""; ++ ++ child_die = die->child; ++ while (child_die && child_die->tag) ++ { ++ TYPE_NFIELDS (type)++; ++ child_die = sibling_die (child_die); ++ } ++ ++ TYPE_FIELDS (type) = obstack_alloc (&objfile->objfile_obstack, ++ sizeof (*TYPE_FIELDS (type)) ++ * TYPE_NFIELDS (type)); ++ memset (TYPE_FIELDS (type), 0, sizeof (*TYPE_FIELDS (type)) ++ * TYPE_NFIELDS (type)); ++ ++ field = TYPE_FIELDS (type); + child_die = die->child; + while (child_die && child_die->tag) + { ++ /* Create the symbol in the DW_TAG_common_block block in the current ++ symbol scope. */ + sym = new_symbol (child_die, NULL, cu); ++ ++ /* Undocumented in DWARF3, when it can be present? */ + attr = dwarf2_attr (child_die, DW_AT_data_member_location, cu); + if (attr) + { +@@ -5778,8 +5810,25 @@ read_common_block (struct die_info *die, + SYMBOL_VALUE_ADDRESS (sym) = base + byte_offset; + add_symbol_to_list (sym, &global_symbols); + } ++ ++ if (SYMBOL_CLASS (sym) == LOC_STATIC) ++ SET_FIELD_PHYSADDR (*field, SYMBOL_VALUE_ADDRESS (sym)); ++ else ++ SET_FIELD_PHYSNAME (*field, SYMBOL_LINKAGE_NAME (sym)); ++ FIELD_TYPE (*field) = SYMBOL_TYPE (sym); ++ FIELD_NAME (*field) = SYMBOL_NATURAL_NAME (sym); ++ field++; + child_die = sibling_die (child_die); + } ++ ++ /* TYPE_LENGTH (type) is left 0 - it is only a virtual structure even ++ with no consecutive address space. */ ++ ++ sym = new_symbol (die, type, cu); ++ /* SYMBOL_VALUE_ADDRESS never gets used as all its fields are static. */ ++ SYMBOL_VALUE_ADDRESS (sym) = base; ++ ++ set_die_type (die, type, cu); + } + } + +@@ -9106,6 +9155,13 @@ new_symbol (struct die_info *die, struct + { + var_decode_location (attr, sym, cu); + attr2 = dwarf2_attr (die, DW_AT_external, cu); ++ ++ /* Fortran explicitly imports any global symbols to the local ++ scope by DW_TAG_common_block. */ ++ if (cu->language == language_fortran && die->parent ++ && die->parent->tag == DW_TAG_common_block) ++ attr2 = NULL; ++ + if (attr2 && (DW_UNSND (attr2) != 0)) + { + struct pending **list_to_add; +@@ -9277,6 +9333,11 @@ new_symbol (struct die_info *die, struct + SYMBOL_CLASS (sym) = LOC_TYPEDEF; + add_symbol_to_list (sym, &global_symbols); + break; ++ case DW_TAG_common_block: ++ SYMBOL_CLASS (sym) = LOC_STATIC; ++ SYMBOL_DOMAIN (sym) = COMMON_BLOCK_DOMAIN; ++ add_symbol_to_list (sym, cu->list_in_scope); ++ break; + default: + /* Not a tag we recognize. Hopefully we aren't processing + trash data, but since we must specifically ignore things +Index: gdb-7.1.90.20100711/gdb/f-lang.c +=================================================================== +--- gdb-7.1.90.20100711.orig/gdb/f-lang.c 2010-07-13 00:24:04.000000000 +0200 ++++ gdb-7.1.90.20100711/gdb/f-lang.c 2010-07-13 00:25:56.000000000 +0200 +@@ -443,27 +443,3 @@ _initialize_f_language (void) + + add_language (&f_language_defn); + } +- +-SAVED_F77_COMMON_PTR head_common_list = NULL; /* Ptr to 1st saved COMMON */ +- +-/* This routine finds the first encountred COMMON block named "name" +- that belongs to function funcname */ +- +-SAVED_F77_COMMON_PTR +-find_common_for_function (char *name, char *funcname) +-{ +- +- SAVED_F77_COMMON_PTR tmp; +- +- tmp = head_common_list; +- +- while (tmp != NULL) +- { +- if (strcmp (tmp->name, name) == 0 +- && strcmp (tmp->owning_function, funcname) == 0) +- return (tmp); +- else +- tmp = tmp->next; +- } +- return (NULL); +-} +Index: gdb-7.1.90.20100711/gdb/f-lang.h +=================================================================== +--- gdb-7.1.90.20100711.orig/gdb/f-lang.h 2010-07-13 00:24:04.000000000 +0200 ++++ gdb-7.1.90.20100711/gdb/f-lang.h 2010-07-13 00:25:56.000000000 +0200 +@@ -52,36 +52,8 @@ enum f90_range_type + NONE_BOUND_DEFAULT /* "(low:high)" */ + }; + +-struct common_entry +- { +- struct symbol *symbol; /* The symbol node corresponding +- to this component */ +- struct common_entry *next; /* The next component */ +- }; +- +-struct saved_f77_common +- { +- char *name; /* Name of COMMON */ +- char *owning_function; /* Name of parent function */ +- int secnum; /* Section # of .bss */ +- CORE_ADDR offset; /* Offset from .bss for +- this block */ +- struct common_entry *entries; /* List of block's components */ +- struct common_entry *end_of_entries; /* ptr. to end of components */ +- struct saved_f77_common *next; /* Next saved COMMON block */ +- }; +- +-typedef struct saved_f77_common SAVED_F77_COMMON, *SAVED_F77_COMMON_PTR; +- +-typedef struct common_entry COMMON_ENTRY, *COMMON_ENTRY_PTR; +- +-extern SAVED_F77_COMMON_PTR head_common_list; /* Ptr to 1st saved COMMON */ +- +-extern SAVED_F77_COMMON_PTR find_common_for_function (char *, char *); +- + #define BLANK_COMMON_NAME_ORIGINAL "#BLNK_COM" /* XLF assigned */ + #define BLANK_COMMON_NAME_MF77 "__BLNK__" /* MF77 assigned */ +-#define BLANK_COMMON_NAME_LOCAL "__BLANK" /* Local GDB */ + + /* When reasonable array bounds cannot be fetched, such as when + you ask to 'mt print symbols' and there is no stack frame and +Index: gdb-7.1.90.20100711/gdb/f-valprint.c +=================================================================== +--- gdb-7.1.90.20100711.orig/gdb/f-valprint.c 2010-07-13 00:24:25.000000000 +0200 ++++ gdb-7.1.90.20100711/gdb/f-valprint.c 2010-07-13 00:32:05.000000000 +0200 +@@ -34,6 +34,8 @@ + #include "gdbcore.h" + #include "command.h" + #include "block.h" ++#include "dictionary.h" ++#include "gdb_assert.h" + + extern void _initialize_f_valprint (void); + static void info_common_command (char *, int); +@@ -486,22 +488,54 @@ f_val_print (struct type *type, const gd + return 0; + } + +-static void +-list_all_visible_commons (char *funname) ++static int ++info_common_command_for_block (struct block *block, struct frame_info *frame, ++ const char *comname) + { +- SAVED_F77_COMMON_PTR tmp; +- +- tmp = head_common_list; ++ struct dict_iterator iter; ++ struct symbol *sym; ++ int values_printed = 0; ++ const char *name; ++ struct value_print_options opts; ++ ++ get_user_print_options (&opts); ++ ++ ALL_BLOCK_SYMBOLS (block, iter, sym) ++ if (SYMBOL_DOMAIN (sym) == COMMON_BLOCK_DOMAIN) ++ { ++ struct type *type = SYMBOL_TYPE (sym); ++ int index; ++ ++ gdb_assert (SYMBOL_CLASS (sym) == LOC_STATIC); ++ gdb_assert (TYPE_CODE (type) == TYPE_CODE_STRUCT); ++ ++ if (comname && (!SYMBOL_LINKAGE_NAME (sym) ++ || strcmp (comname, SYMBOL_LINKAGE_NAME (sym)) != 0)) ++ continue; ++ ++ values_printed = 1; ++ if (SYMBOL_PRINT_NAME (sym)) ++ printf_filtered (_("Contents of F77 COMMON block '%s':\n"), ++ SYMBOL_PRINT_NAME (sym)); ++ else ++ printf_filtered (_("Contents of blank COMMON block:\n")); ++ ++ for (index = 0; index < TYPE_NFIELDS (type); index++) ++ { ++ struct value *val; ++ ++ gdb_assert (field_is_static (&TYPE_FIELD (type, index))); ++ val = value_static_field (type, index); ++ ++ printf_filtered ("%s = ", TYPE_FIELD_NAME (type, index)); ++ value_print (val, gdb_stdout, &opts); ++ putchar_filtered ('\n'); ++ } + +- printf_filtered (_("All COMMON blocks visible at this level:\n\n")); ++ putchar_filtered ('\n'); ++ } + +- while (tmp != NULL) +- { +- if (strcmp (tmp->owning_function, funname) == 0) +- printf_filtered ("%s\n", tmp->name); +- +- tmp = tmp->next; +- } ++ return values_printed; + } + + /* This function is used to print out the values in a given COMMON +@@ -511,11 +545,9 @@ list_all_visible_commons (char *funname) + static void + info_common_command (char *comname, int from_tty) + { +- SAVED_F77_COMMON_PTR the_common; +- COMMON_ENTRY_PTR entry; + struct frame_info *fi; +- char *funname = 0; +- struct symbol *func; ++ struct block *block; ++ int values_printed = 0; + + /* We have been told to display the contents of F77 COMMON + block supposedly visible in this function. Let us +@@ -527,74 +559,31 @@ info_common_command (char *comname, int + /* The following is generally ripped off from stack.c's routine + print_frame_info() */ + +- func = find_pc_function (get_frame_pc (fi)); +- if (func) ++ block = get_frame_block (fi, 0); ++ if (block == NULL) + { +- /* In certain pathological cases, the symtabs give the wrong +- function (when we are in the first function in a file which +- is compiled without debugging symbols, the previous function +- is compiled with debugging symbols, and the "foo.o" symbol +- that is supposed to tell us where the file with debugging symbols +- ends has been truncated by ar because it is longer than 15 +- characters). +- +- So look in the minimal symbol tables as well, and if it comes +- up with a larger address for the function use that instead. +- I don't think this can ever cause any problems; there shouldn't +- be any minimal symbols in the middle of a function. +- FIXME: (Not necessarily true. What about text labels) */ +- +- struct minimal_symbol *msymbol = +- lookup_minimal_symbol_by_pc (get_frame_pc (fi)); +- +- if (msymbol != NULL +- && (SYMBOL_VALUE_ADDRESS (msymbol) +- > BLOCK_START (SYMBOL_BLOCK_VALUE (func)))) +- funname = SYMBOL_LINKAGE_NAME (msymbol); +- else +- funname = SYMBOL_LINKAGE_NAME (func); +- } +- else +- { +- struct minimal_symbol *msymbol = +- lookup_minimal_symbol_by_pc (get_frame_pc (fi)); +- +- if (msymbol != NULL) +- funname = SYMBOL_LINKAGE_NAME (msymbol); +- else /* Got no 'funname', code below will fail. */ +- error (_("No function found for frame.")); ++ printf_filtered (_("No symbol table info available.\n")); ++ return; + } + +- /* If comname is NULL, we assume the user wishes to see the +- which COMMON blocks are visible here and then return */ +- +- if (comname == 0) ++ while (block) + { +- list_all_visible_commons (funname); +- return; ++ if (info_common_command_for_block (block, fi, comname)) ++ values_printed = 1; ++ /* After handling the function's top-level block, stop. Don't ++ continue to its superblock, the block of per-file symbols. */ ++ if (BLOCK_FUNCTION (block)) ++ break; ++ block = BLOCK_SUPERBLOCK (block); + } + +- the_common = find_common_for_function (comname, funname); +- +- if (the_common) ++ if (!values_printed) + { +- if (strcmp (comname, BLANK_COMMON_NAME_LOCAL) == 0) +- printf_filtered (_("Contents of blank COMMON block:\n")); ++ if (comname) ++ printf_filtered (_("No common block '%s'.\n"), comname); + else +- printf_filtered (_("Contents of F77 COMMON block '%s':\n"), comname); +- +- printf_filtered ("\n"); +- entry = the_common->entries; +- +- while (entry != NULL) +- { +- print_variable_and_value (NULL, entry->symbol, fi, gdb_stdout, 0); +- entry = entry->next; +- } ++ printf_filtered (_("No common blocks.\n")); + } +- else +- printf_filtered (_("Cannot locate the common block %s in function '%s'\n"), +- comname, funname); + } + + void +Index: gdb-7.1.90.20100711/gdb/stack.c +=================================================================== +--- gdb-7.1.90.20100711.orig/gdb/stack.c 2010-07-01 17:36:17.000000000 +0200 ++++ gdb-7.1.90.20100711/gdb/stack.c 2010-07-13 00:29:49.000000000 +0200 +@@ -1484,6 +1484,8 @@ iterate_over_block_locals (struct block + case LOC_COMPUTED: + if (SYMBOL_IS_ARGUMENT (sym)) + break; ++ if (SYMBOL_DOMAIN (sym) == COMMON_BLOCK_DOMAIN) ++ break; + (*cb) (SYMBOL_PRINT_NAME (sym), sym, cb_data); + break; + +Index: gdb-7.1.90.20100711/gdb/symtab.h +=================================================================== +--- gdb-7.1.90.20100711.orig/gdb/symtab.h 2010-07-12 23:07:33.000000000 +0200 ++++ gdb-7.1.90.20100711/gdb/symtab.h 2010-07-13 00:27:02.000000000 +0200 +@@ -396,7 +396,10 @@ typedef enum domain_enum_tag + FUNCTIONS_DOMAIN, + + /* All defined types */ +- TYPES_DOMAIN ++ TYPES_DOMAIN, ++ ++ /* Fortran common blocks. Their naming must be separate from VAR_DOMAIN. */ ++ COMMON_BLOCK_DOMAIN + } + domain_enum; + +Index: gdb-7.1.90.20100711/gdb/testsuite/gdb.fortran/common-block.exp +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ gdb-7.1.90.20100711/gdb/testsuite/gdb.fortran/common-block.exp 2010-07-13 00:25:56.000000000 +0200 +@@ -0,0 +1,101 @@ ++# Copyright 2008 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. ++ ++# This file was written by Jan Kratochvil . ++ ++set testfile "common-block" ++set srcfile ${testfile}.f90 ++set binfile ${objdir}/${subdir}/${testfile} ++ ++if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug f77 quiet}] != "" } { ++ untested "Couldn't compile ${srcfile}" ++ return -1 ++} ++ ++gdb_exit ++gdb_start ++gdb_reinitialize_dir $srcdir/$subdir ++gdb_load ${binfile} ++ ++if ![runto MAIN__] then { ++ perror "couldn't run to breakpoint MAIN__" ++ continue ++} ++ ++gdb_breakpoint [gdb_get_line_number "stop-here-out"] ++gdb_continue_to_breakpoint "stop-here-out" ++ ++# Common block naming with source name /foo/: ++# .symtab DW_TAG_common_block's DW_AT_name ++# Intel Fortran foo_ foo_ ++# GNU Fortran foo_ foo ++#set suffix "_" ++set suffix "" ++ ++set int4 {(integer\(kind=4\)|INTEGER\(4\))} ++set real4 {(real\(kind=4\)|REAL\(4\))} ++set real8 {(real\(kind=8\)|REAL\(8\))} ++ ++gdb_test "whatis foo$suffix" "No symbol \"foo$suffix\" in current context." ++gdb_test "ptype foo$suffix" "No symbol \"foo$suffix\" in current context." ++gdb_test "p foo$suffix" "No symbol \"foo$suffix\" in current context." ++gdb_test "whatis fo_o$suffix" "No symbol \"fo_o$suffix\" in current context." ++gdb_test "ptype fo_o$suffix" "No symbol \"fo_o$suffix\" in current context." ++gdb_test "p fo_o$suffix" "No symbol \"fo_o$suffix\" in current context." ++ ++gdb_test "info locals" "ix_x = 11\r\niy_y = 22\r\niz_z = 33\r\nix = 1\r\niy = 2\r\niz = 3" "info locals out" ++gdb_test "info common" "Contents of F77 COMMON block 'fo_o':\r\nix_x = 11\r\niy_y = 22\r\niz_z = 33\r\n\r\nContents of F77 COMMON block 'foo':\r\nix = 1\r\niy = 2\r\niz = 3" "info common out" ++ ++gdb_test "ptype ix" "type = $int4" "ptype ix out" ++gdb_test "ptype iy" "type = $real4" "ptype iy out" ++gdb_test "ptype iz" "type = $real8" "ptype iz out" ++gdb_test "ptype ix_x" "type = $int4" "ptype ix_x out" ++gdb_test "ptype iy_y" "type = $real4" "ptype iy_y out" ++gdb_test "ptype iz_z" "type = $real8" "ptype iz_z out" ++ ++gdb_test "p ix" " = 1 *" "p ix out" ++gdb_test "p iy" " = 2 *" "p iy out" ++gdb_test "p iz" " = 3 *" "p iz out" ++gdb_test "p ix_x" " = 11 *" "p ix_x out" ++gdb_test "p iy_y" " = 22 *" "p iy_y out" ++gdb_test "p iz_z" " = 33 *" "p iz_z out" ++ ++gdb_breakpoint [gdb_get_line_number "stop-here-in"] ++gdb_continue_to_breakpoint "stop-here-in" ++ ++gdb_test "whatis foo$suffix" "No symbol \"foo$suffix\" in current context." "whatis foo$suffix in" ++gdb_test "ptype foo$suffix" "No symbol \"foo$suffix\" in current context." "ptype foo$suffix in" ++gdb_test "p foo$suffix" "No symbol \"foo$suffix\" in current context." "p foo$suffix in" ++gdb_test "whatis fo_o$suffix" "No symbol \"fo_o$suffix\" in current context." "whatis fo_o$suffix in" ++gdb_test "ptype fo_o$suffix" "No symbol \"fo_o$suffix\" in current context." "ptype fo_o$suffix in" ++gdb_test "p fo_o$suffix" "No symbol \"fo_o$suffix\" in current context." "p fo_o$suffix in" ++ ++gdb_test "info locals" "ix = 11\r\niy2 = 22\r\niz = 33\r\nix_x = 1\r\niy_y = 2\r\niz_z2 = 3\r\niy = 5\r\niz_z = 55" "info locals in" ++gdb_test "info common" "Contents of F77 COMMON block 'fo_o':\r\nix = 11\r\niy2 = 22\r\niz = 33\r\n\r\nContents of F77 COMMON block 'foo':\r\nix_x = 1\r\niy_y = 2\r\niz_z2 = 3" "info common in" ++ ++gdb_test "ptype ix" "type = $int4" "ptype ix in" ++gdb_test "ptype iy2" "type = $real4" "ptype iy2 in" ++gdb_test "ptype iz" "type = $real8" "ptype iz in" ++gdb_test "ptype ix_x" "type = $int4" "ptype ix_x in" ++gdb_test "ptype iy_y" "type = $real4" "ptype iy_y in" ++gdb_test "ptype iz_z2" "type = $real8" "ptype iz_z2 in" ++ ++gdb_test "p ix" " = 11 *" "p ix in" ++gdb_test "p iy2" " = 22 *" "p iy2 in" ++gdb_test "p iz" " = 33 *" "p iz in" ++gdb_test "p ix_x" " = 1 *" "p ix_x in" ++gdb_test "p iy_y" " = 2 *" "p iy_y in" ++gdb_test "p iz_z2" " = 3 *" "p iz_z2 in" +Index: gdb-7.1.90.20100711/gdb/testsuite/gdb.fortran/common-block.f90 +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ gdb-7.1.90.20100711/gdb/testsuite/gdb.fortran/common-block.f90 2010-07-13 00:25:56.000000000 +0200 +@@ -0,0 +1,67 @@ ++! Copyright 2008 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. ++! ++! Ihis file is the Fortran source file for dynamic.exp. ++! Original file written by Jakub Jelinek . ++! Modified for the GDB testcase by Jan Kratochvil . ++ ++subroutine in ++ ++ INTEGER*4 ix ++ REAL*4 iy2 ++ REAL*8 iz ++ ++ INTEGER*4 ix_x ++ REAL*4 iy_y ++ REAL*8 iz_z2 ++ ++ common /fo_o/ix,iy2,iz ++ common /foo/ix_x,iy_y,iz_z2 ++ ++ iy = 5 ++ iz_z = 55 ++ ++ if (ix .ne. 11 .or. iy2 .ne. 22.0 .or. iz .ne. 33.0) call abort ++ if (ix_x .ne. 1 .or. iy_y .ne. 2.0 .or. iz_z2 .ne. 3.0) call abort ++ ++ ix = 0 ! stop-here-in ++ ++end subroutine in ++ ++program common_test ++ ++ INTEGER*4 ix ++ REAL*4 iy ++ REAL*8 iz ++ ++ INTEGER*4 ix_x ++ REAL*4 iy_y ++ REAL*8 iz_z ++ ++ common /foo/ix,iy,iz ++ common /fo_o/ix_x,iy_y,iz_z ++ ++ ix = 1 ++ iy = 2.0 ++ iz = 3.0 ++ ++ ix_x = 11 ++ iy_y = 22.0 ++ iz_z = 33.0 ++ ++ call in ! stop-here-out ++ ++end program common_test diff --git a/gdb-gdb-add-index-script.patch b/gdb-gdb-add-index-script.patch new file mode 100644 index 0000000..c770a77 --- /dev/null +++ b/gdb-gdb-add-index-script.patch @@ -0,0 +1,122 @@ +http://sourceware.org/ml/gdb-patches/2010-07/msg00184.html +Subject: Re: [0/4] RFC: add DWARF index support + +Jan Kratochvil: Fixed $d -> $dir. +Jan Kratochvil: Remove /dev/null redirection. + +>>>>> "Tom" == Tom Tromey writes: + +Tom> This patch series adds support for a DWARF index to gdb. + +Roland suggested we wrap up the index-creation code into a helper +script. + +I'm not sure if this is something people would want in gdb proper, but I +figured I would send it here just in case. + +Tom + +2010-07-09 Tom Tromey + + * Makefile.in (install-only): Install gdb-add-index. + * gdb-add-index: New file. + +2010-07-09 Tom Tromey + + * gdb.texinfo (Index Files): Mention gdb-add-index. + +>From 30714fe719e61baea03d0dc5793eb0d564faebb7 Mon Sep 17 00:00:00 2001 +From: Tom Tromey +Date: Fri, 9 Jul 2010 11:17:54 -0600 +Subject: [PATCH 4/4] add gdb-add-index +Subject: [PATCH 4/4] add gdb-add-index + +--- + gdb/ChangeLog | 5 +++++ + gdb/Makefile.in | 11 ++++++++++- + gdb/doc/ChangeLog | 4 ++++ + gdb/doc/gdb.texinfo | 8 ++++++++ + gdb/gdb-add-index | 30 ++++++++++++++++++++++++++++++ + 5 files changed, 57 insertions(+), 1 deletions(-) + create mode 100755 gdb/gdb-add-index + +diff --git a/gdb/Makefile.in b/gdb/Makefile.in +index 6dbb284..8210a2c 100644 +--- a/gdb/Makefile.in ++++ b/gdb/Makefile.in +@@ -1018,7 +1018,16 @@ install-only: $(CONFIG_INSTALL) xml-syscall-install + $(SHELL) $(srcdir)/../mkinstalldirs \ + $(DESTDIR)$(man1dir) ; \ + $(INSTALL_DATA) $(srcdir)/gdb.1 \ +- $(DESTDIR)$(man1dir)/$$transformed_name.1 ++ $(DESTDIR)$(man1dir)/$$transformed_name.1; \ ++ transformed_name=`t='$(program_transform_name)'; \ ++ echo gdb-add-index | sed -e "$$t"` ; \ ++ if test "x$$transformed_name" = x; then \ ++ transformed_name=gdb-add-index ; \ ++ else \ ++ true ; \ ++ fi ; \ ++ $(INSTALL_PROGRAM) $(srcdir)/gdb-add-index \ ++ $(DESTDIR)$(bindir)/$$transformed_name$(EXEEXT) + @$(MAKE) DO=install "DODIRS=$(SUBDIRS)" $(FLAGS_TO_PASS) subdir_do + .PHONY: install-tui + install-tui: +diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo +index 69141e3..457e6b4 100644 +--- a/gdb/doc/gdb.texinfo ++++ b/gdb/doc/gdb.texinfo +@@ -15045,6 +15045,14 @@ There are currently some limitation on indices. They only work when + for DWARF debugging information, not stabs. And, they do not + currently work for programs using Ada. + ++@value{GDBN} comes with a program, @command{gdb-add-index}, which can ++be used to add the index to a symbol file. It takes the symbol file ++as its only argument: ++ ++@smallexample ++$ gdb-add-index symfile ++@end smallexample ++ + + @node Symbol Errors + @section Errors Reading Symbol Files +diff --git a/gdb/gdb-add-index b/gdb/gdb-add-index +new file mode 100755 +index 0000000..c9a03b0 +--- /dev/null ++++ b/gdb/gdb-add-index +@@ -0,0 +1,30 @@ ++#! /bin/sh ++ ++# Add a .gdb_index section to a file. ++ ++# 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 . ++ ++file="$1" ++dir="${file%/*}" ++ ++# We don't care if gdb gives an error. ++gdb -nx --batch-silent -ex "file $file" -ex "save gdb-index $dir" ++ ++if test -f "${file}.gdb-index"; then ++ objcopy --add-section .gdb_index="${file}.gdb-index" --set-section-flags .gdb_index=readonly "$file" "$file" ++ rm -f "${file}.gdb-index" ++fi ++ ++exit 0 +-- +1.6.2.5 + diff --git a/gdb-gdbindex-ada-regression.patch b/gdb-gdbindex-ada-regression.patch new file mode 100644 index 0000000..9d67d58 --- /dev/null +++ b/gdb-gdbindex-ada-regression.patch @@ -0,0 +1,50 @@ +http://sourceware.org/ml/gdb-patches/2010-09/msg00273.html +Subject: [patch] .gdb_index: Fix Ada regression + +Hi, + +on a system with libraries using .gdb_index all the Ada testcases FAIL: + +Running ./gdb.ada/print_pc.exp ... +FAIL: gdb.ada/print_pc.exp: start inferior (GDB internal error) +FAIL: gdb.ada/print_pc.exp: p /x $pc + +dwarf2read.c:2374: internal-error: map_ada_symtabs called via index method + +FAIl is on Fedora 14 snapshot using gcc-debuginfo-4.5.1-3.fc14.x86_64 file: + /usr/lib/debug/lib64/libgcc_s-4.5.1-20100907.so.1.debug + +The regressions get fixed on x86_64-fedora14snapshot-linux-gnu by the attached +patch. No regressions on {x86_64,x86_64-m32,i686}-fedora14snapshot-linux-gnu. + +During my tests with `set language ada' I could not lookup non-Ada symbols +anyway so I believe the patch is OK but sure it needs an Ada-wise review. + + +Thanks, +Jan + + +gdb/ +2010-09-14 Jan Kratochvil + + * dwarf2read.c (dw2_map_ada_symtabs): Remove the internal_error. + Update the comment. + +--- a/gdb/dwarf2read.c ++++ b/gdb/dwarf2read.c +@@ -2369,10 +2369,9 @@ dw2_map_ada_symtabs (struct objfile *objfile, + domain_enum namespace, int wild, + void *data) + { +- /* For now, we don't support Ada, so this function can't be +- reached. */ +- internal_error (__FILE__, __LINE__, +- _("map_ada_symtabs called via index method")); ++ /* For now, we don't support Ada. Still the function can be called if the ++ current language is Ada for a non-Ada objfile using GNU index. As Ada ++ does not look for non-Ada symbols this function should just return. */ + } + + static void + diff --git a/gdb-gdbindex-bigendian.patch b/gdb-gdbindex-bigendian.patch new file mode 100644 index 0000000..b03632f --- /dev/null +++ b/gdb-gdbindex-bigendian.patch @@ -0,0 +1,96 @@ +http://sourceware.org/ml/gdb-patches/2010-09/msg00434.html +http://sourceware.org/ml/gdb-cvs/2010-09/msg00155.html + +### src/gdb/ChangeLog 2010/09/24 14:47:52 1.12202 +### src/gdb/ChangeLog 2010/09/24 16:11:44 1.12203 +## -1,3 +1,9 @@ ++2010-09-24 Tom Tromey ++ ++ * dwarf2read.c (dw2_expand_symtabs_matching): Add missing ++ MAYBE_SWAPs. ++ (dw2_map_symbol_names): Likewise. ++ + 2010-09-24 Sami Wagiaalla + + * valops.c (find_oload_champ_namespace_loop): replace incorrect +--- src/gdb/dwarf2read.c 2010/09/22 19:22:44 1.460 ++++ src/gdb/dwarf2read.c 2010/09/24 16:11:46 1.461 +@@ -2248,10 +2248,12 @@ dw2_expand_symtabs_matching (struct objf + { + int i; + offset_type iter; ++ struct mapped_index *index; + + dw2_setup (objfile); + if (!dwarf2_per_objfile->index_table) + return; ++ index = dwarf2_per_objfile->index_table; + + for (i = 0; i < dwarf2_per_objfile->n_comp_units; ++i) + { +@@ -2411,28 +2413,24 @@ + } + } + +- for (iter = 0; +- iter < dwarf2_per_objfile->index_table->index_table_slots; +- ++iter) ++ for (iter = 0; iter < index->index_table_slots; ++iter) + { + offset_type idx = 2 * iter; + const char *name; + offset_type *vec, vec_len, vec_idx; + +- if (dwarf2_per_objfile->index_table->index_table[idx] == 0 +- && dwarf2_per_objfile->index_table->index_table[idx + 1] == 0) ++ if (index->index_table[idx] == 0 && index->index_table[idx + 1] == 0) + continue; + +- name = (dwarf2_per_objfile->index_table->constant_pool +- + dwarf2_per_objfile->index_table->index_table[idx]); ++ name = index->constant_pool + MAYBE_SWAP (index->index_table[idx]); + + if (! (*name_matcher) (name, data)) + continue; + + /* The name was matched, now expand corresponding CUs that were + marked. */ +- vec = (offset_type *) (dwarf2_per_objfile->index_table->constant_pool +- + dwarf2_per_objfile->index_table->index_table[idx + 1]); ++ vec = (offset_type *) (index->constant_pool ++ + MAYBE_SWAP (index->index_table[idx + 1])); + vec_len = MAYBE_SWAP (vec[0]); + for (vec_idx = 0; vec_idx < vec_len; ++vec_idx) + { +@@ -2476,25 +2474,24 @@ + void *data) + { + offset_type iter; ++ struct mapped_index *index; ++ + dw2_setup (objfile); + + if (!dwarf2_per_objfile->index_table) + return; ++ index = dwarf2_per_objfile->index_table; + +- for (iter = 0; +- iter < dwarf2_per_objfile->index_table->index_table_slots; +- ++iter) ++ for (iter = 0; iter < index->index_table_slots; ++iter) + { + offset_type idx = 2 * iter; + const char *name; + offset_type *vec, vec_len, vec_idx; + +- if (dwarf2_per_objfile->index_table->index_table[idx] == 0 +- && dwarf2_per_objfile->index_table->index_table[idx + 1] == 0) ++ if (index->index_table[idx] == 0 && index->index_table[idx + 1] == 0) + continue; + +- name = (dwarf2_per_objfile->index_table->constant_pool +- + dwarf2_per_objfile->index_table->index_table[idx]); ++ name = (index->constant_pool + MAYBE_SWAP (index->index_table[idx])); + + (*fun) (name, data); + } diff --git a/gdb-info.patch b/gdb-info.patch index e23ea83..6c75598 100644 --- a/gdb-info.patch +++ b/gdb-info.patch @@ -9,9 +9,9 @@ diff -urN gdb-5.0.org/gdb/Makefile.in gdb-5.0/gdb/Makefile.in "exec_prefix=$(exec_prefix)" \ "against=$(against)" \ "AR=$(AR)" \ ---- gdb-6.1.1/gdb/doc/gdb.texinfo.orig 2004-06-15 00:25:29.000000000 +0200 -+++ gdb-6.1.1/gdb/doc/gdb.texinfo 2004-06-22 23:37:55.963941600 +0200 -@@ -38,9 +38,9 @@ +--- gdb-7.2/gdb/doc/gdb.texinfo.orig 2010-10-15 18:51:49.632994831 +0200 ++++ gdb-7.2/gdb/doc/gdb.texinfo 2010-10-15 18:51:49.719668622 +0200 +@@ -39,9 +39,9 @@ @c This is a dir.info fragment to support semi-automated addition of @c manuals to an info tree. @@ -22,13 +22,13 @@ diff -urN gdb-5.0.org/gdb/Makefile.in gdb-5.0/gdb/Makefile.in +* Gdb: (gdb). The GNU debugger @end direntry - @ifinfo ---- gdb-6.1.1/gdb/doc/gdbint.texinfo.orig 2004-06-15 00:25:31.000000000 +0200 -+++ gdb-6.1.1/gdb/doc/gdbint.texinfo 2004-06-22 23:38:21.741022888 +0200 -@@ -1,9 +1,9 @@ - \input texinfo @c -*- texinfo -*- - @setfilename gdbint.info + @copying +--- gdb-7.2/gdb/doc/gdbint.texinfo.orig 2010-10-15 18:57:03.000000000 +0200 ++++ gdb-7.2/gdb/doc/gdbint.texinfo 2010-10-15 18:58:17.944938994 +0200 +@@ -3,9 +3,9 @@ @include gdb-cfg.texi + @settitle @value{GDBN} Internals + @setchapternewpage off -@dircategory Software development +@dircategory Programming tools: @direntry @@ -36,7 +36,7 @@ diff -urN gdb-5.0.org/gdb/Makefile.in gdb-5.0/gdb/Makefile.in +* Gdb-Internals: (gdbint). The GNU debugger's internals @end direntry - @ifinfo + @copying --- gdb-6.1.1/gdb/doc/stabs.texinfo.orig 2004-06-15 00:25:31.000000000 +0200 +++ gdb-6.1.1/gdb/doc/stabs.texinfo 2004-06-22 23:38:51.279532352 +0200 @@ -5,9 +5,9 @@ diff --git a/gdb-lineno-makeup-test.patch b/gdb-lineno-makeup-test.patch new file mode 100644 index 0000000..073662a --- /dev/null +++ b/gdb-lineno-makeup-test.patch @@ -0,0 +1,151 @@ +New testcase for: +https://bugzilla.redhat.com/show_bug.cgi?id=466222 + (for the first / customer recommended fix) +and the upstream fix: +http://sourceware.org/ml/gdb-patches/2006-11/msg00253.html + [rfc] Do not make up line information +http://sourceware.org/ml/gdb-cvs/2006-11/msg00127.html + +--- /dev/null ++++ b/gdb/testsuite/gdb.base/lineno-makeup-func.c +@@ -0,0 +1,21 @@ ++/* This testcase is part of GDB, the GNU debugger. ++ ++ Copyright 2009 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 . */ ++ ++void ++func (void) ++{ ++} +--- /dev/null ++++ b/gdb/testsuite/gdb.base/lineno-makeup.c +@@ -0,0 +1,35 @@ ++/* This testcase is part of GDB, the GNU debugger. ++ ++ Copyright 2009 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 . */ ++ ++/* DW_AT_low_pc-DW_AT_high_pc should cover the function without line number ++ information (.debug_line) so we cannot use an external object file. ++ ++ It must not be just a label as it would alias on the next function even for ++ correct GDB. Therefore some stub data must be placed there. ++ ++ We need to provide a real stub function body as at least s390 ++ (s390_analyze_prologue) would skip the whole body till reaching `main'. */ ++ ++extern void func (void); ++asm ("func: .incbin \"gdb.base/lineno-makeup-func.bin\""); ++ ++int ++main (void) ++{ ++ func (); ++ return 0; ++} +--- /dev/null ++++ b/gdb/testsuite/gdb.base/lineno-makeup.exp +@@ -0,0 +1,78 @@ ++# Copyright 2009 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 . ++ ++set testfile "lineno-makeup" ++set srcfuncfile ${testfile}-func.c ++set srcfile ${testfile}.c ++set objfuncfile ${objdir}/${subdir}/${testfile}-func.o ++set binfuncfile ${objdir}/${subdir}/${testfile}-func.bin ++set binfile ${objdir}/${subdir}/${testfile} ++ ++if { [gdb_compile "${srcdir}/${subdir}/${srcfuncfile}" "${objfuncfile}" object {}] != "" } { ++ gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." ++} ++ ++set objcopy [catch "exec objcopy -O binary --only-section .text ${objfuncfile} ${binfuncfile}" output] ++verbose -log "objcopy=$objcopy: $output" ++if { $objcopy != 0 } { ++ gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." ++} ++set binfuncfilesize [file size $binfuncfile] ++verbose -log "file size $binfuncfile = $binfuncfilesize" ++ ++if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } { ++ gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." ++} ++ ++gdb_exit ++gdb_start ++gdb_reinitialize_dir $srcdir/$subdir ++gdb_load ${binfile} ++ ++set b_addr "" ++set test "break func" ++gdb_test_multiple $test $test { ++ -re "Breakpoint \[0-9\]+ at (0x\[0-9a-f\]+)\r\n$gdb_prompt $" { ++ set b_addr $expect_out(1,string) ++ pass $test ++ } ++ -re "Breakpoint \[0-9\]+ at (0x\[0-9a-f\]+): .*\r\n$gdb_prompt $" { ++ set b_addr $expect_out(1,string) ++ fail $test ++ } ++} ++verbose -log "b_addr=<$b_addr>" ++ ++set p_addr "" ++set test "print func" ++gdb_test_multiple $test $test { ++ -re "\\$\[0-9\]+ = {} (0x\[0-9a-f\]+) \r\n$gdb_prompt $" { ++ set p_addr $expect_out(1,string) ++ pass $test ++ } ++} ++verbose -log "p_addr=<$p_addr>" ++ ++set test "break address belongs to func" ++if {$b_addr == $p_addr} { ++ pass "$test (exact match)" ++} else { ++ set skip [expr $b_addr - $p_addr] ++ if {$skip > 0 && $skip < $binfuncfilesize} { ++ pass "$test (prologue skip by $skip bytes)" ++ } else { ++ fail $test ++ } ++} diff --git a/gdb-moribund-utrace-workaround.patch b/gdb-moribund-utrace-workaround.patch new file mode 100644 index 0000000..6b50a8e --- /dev/null +++ b/gdb-moribund-utrace-workaround.patch @@ -0,0 +1,16 @@ +https://bugzilla.redhat.com/show_bug.cgi?id=590623 +http://sources.redhat.com/bugzilla/show_bug.cgi?id=11593 + +Bug in FSF GDB exploited by the ptrace-on-utrace interaction. + +--- a/gdb/breakpoint.c ++++ b/gdb/breakpoint.c +@@ -9084,6 +9084,8 @@ update_global_location_list (int should_insert) + traps we can no longer explain. */ + + old_loc->events_till_retirement = 3 * (thread_count () + 1); ++ /* Red Hat Bug 590623. */ ++ old_loc->events_till_retirement *= 10; + old_loc->owner = NULL; + + VEC_safe_push (bp_location_p, moribund_locations, old_loc); diff --git a/gdb-ppc-power7-test.patch b/gdb-ppc-power7-test.patch new file mode 100644 index 0000000..4d4772a --- /dev/null +++ b/gdb-ppc-power7-test.patch @@ -0,0 +1,295 @@ +--- /dev/null ++++ b/gdb/testsuite/gdb.arch/powerpc-power7.exp +@@ -0,0 +1,182 @@ ++# Copyright 2009 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. ++ ++# Test PowerPC Power7 instructions disassembly. ++ ++if {![istarget "powerpc*-*-*"]} then { ++ verbose "Skipping PowerPC Power7 instructions disassembly." ++ return ++} ++ ++set testfile "powerpc-power7" ++set srcfile ${testfile}.s ++set objfile ${objdir}/${subdir}/${testfile}.o ++ ++if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${objfile}" object {debug}] != "" } { ++ untested "PowerPC Power7 instructions disassembly" ++ return -1 ++} ++ ++ ++gdb_exit ++gdb_start ++gdb_reinitialize_dir $srcdir/$subdir ++gdb_load ${objfile} ++ ++ ++# Disassemble the function. ++ ++set test "disass func" ++gdb_test_multiple $test $test { ++ -re "\r\nDump of assembler code for function func:(\r\n.*\r\n)End of assembler dump.\r\n$gdb_prompt $" { ++ set func $expect_out(1,string) ++ pass $test ++ } ++} ++ ++proc instr_to_patt {offset instr} { ++ # 0x0000000000000018 : stxvd2x vs43,r4,r5 ++ return ".*\r\n\[ \t\]*[string map {0x 0x0*} $offset] <(func)?\\+?\[0-9\]*>:\[ \t\]*[string map [list { } "\[ \t\]+" . {\.}] $instr]\[ \t\]*\r\n.*" ++} ++ ++# KFAIL strings would not exist if -Many would print the same as -Mpower7. ++# That means the power7 form should be the preferred one. ++# http://sourceware.org/ml/gdb-patches/2009-03/threads.html#00020 ++ ++proc func_check {offset instr {kfail ""}} { ++ global func ++ ++ set test "Found $offset: $instr" ++ if [regexp -nocase -line [instr_to_patt $offset $instr] $func] { ++ pass $test ++ } elseif {$kfail != "" && [regexp -nocase -line [instr_to_patt $offset $kfail] $func]} { ++ kfail gdb/NNNN $test ++ } else { ++ fail $test ++ } ++} ++ ++func_check 0x0 "lxvd2x vs3,r4,r5" ++# [PATCH] Remove support for POWER7 VSX load/store with update instructions ++# http://sourceware.org/ml/binutils/2009-09/msg00680.html ++# http://sourceware.org/ml/binutils-cvs/2009-09/msg00331.html ++# lxvd2ux vs3,r4,r5 ++func_check 0x4 ".long 0x7c642ed8" ++func_check 0x8 "lxvd2x vs43,r4,r5" ++# lxvd2ux vs43,r4,r5 ++func_check 0xc ".long 0x7d642ed9" ++func_check 0x10 "stxvd2x vs3,r4,r5" ++# stxvd2ux vs3,r4,r5 ++func_check 0x14 ".long 0x7c642fd8" ++func_check 0x18 "stxvd2x vs43,r4,r5" ++# stxvd2ux vs43,r4,r5 ++func_check 0x1c ".long 0x7d642fd9" ++func_check 0x20 "xxmrghd vs3,vs4,vs5" ++func_check 0x24 "xxmrghd vs43,vs44,vs45" ++func_check 0x28 "xxmrgld vs3,vs4,vs5" ++func_check 0x2c "xxmrgld vs43,vs44,vs45" ++func_check 0x30 "xxmrghd vs3,vs4,vs5" ++func_check 0x34 "xxmrghd vs43,vs44,vs45" ++func_check 0x38 "xxmrgld vs3,vs4,vs5" ++func_check 0x3c "xxmrgld vs43,vs44,vs45" ++func_check 0x40 "xxpermdi vs3,vs4,vs5,1" ++func_check 0x44 "xxpermdi vs43,vs44,vs45,1" ++func_check 0x48 "xxpermdi vs3,vs4,vs5,2" ++func_check 0x4c "xxpermdi vs43,vs44,vs45,2" ++func_check 0x50 "xvmovdp vs3,vs4" ++func_check 0x54 "xvmovdp vs43,vs44" ++func_check 0x58 "xvmovdp vs3,vs4" ++func_check 0x5c "xvmovdp vs43,vs44" ++func_check 0x60 "xvcpsgndp vs3,vs4,vs5" ++func_check 0x64 "xvcpsgndp vs43,vs44,vs45" ++func_check 0x68 "wait" ++func_check 0x6c "wait" ++func_check 0x70 "waitrsv" ++func_check 0x74 "waitrsv" ++func_check 0x78 "waitimpl" ++func_check 0x7c "waitimpl" ++func_check 0x80 "doze" ++func_check 0x84 "nap" ++func_check 0x88 "sleep" ++func_check 0x8c "rvwinkle" ++func_check 0x90 "prtyw r3,r4" ++func_check 0x94 "prtyd r13,r14" ++func_check 0x98 "mfcfar r10" "mfspr r10,28" ++func_check 0x9c "mtcfar r11" "mtspr 28,r11" ++func_check 0xa0 "cmpb r3,r4,r5" ++func_check 0xa4 "lwzcix r10,r11,r12" ++func_check 0xa8 "dadd f16,f17,f18" ++func_check 0xac "daddq f20,f22,f24" ++func_check 0xb0 "dss 3" ++func_check 0xb4 "dssall" ++func_check 0xb8 "dst r5,r4,1" ++func_check 0xbc "dstt r8,r7,0" ++func_check 0xc0 "dstst r5,r6,3" ++func_check 0xc4 "dststt r4,r5,2" ++func_check 0xc8 "divwe r10,r11,r12" ++func_check 0xcc "divwe. r11,r12,r13" ++func_check 0xd0 "divweo r12,r13,r14" ++func_check 0xd4 "divweo. r13,r14,r15" ++func_check 0xd8 "divweu r10,r11,r12" ++func_check 0xdc "divweu. r11,r12,r13" ++func_check 0xe0 "divweuo r12,r13,r14" ++func_check 0xe4 "divweuo. r13,r14,r15" ++func_check 0xe8 "bpermd r7,r17,r27" ++func_check 0xec "popcntw r10,r20" ++func_check 0xf0 "popcntd r10,r20" ++func_check 0xf4 "ldbrx r20,r21,r22" ++func_check 0xf8 "stdbrx r20,r21,r22" ++func_check 0xfc "lfiwzx f10,0,r10" ++func_check 0x100 "lfiwzx f10,r9,r10" ++func_check 0x104 "fcfids f4,f5" ++func_check 0x108 "fcfids. f4,f5" ++func_check 0x10c "fcfidus f4,f5" ++func_check 0x110 "fcfidus. f4,f5" ++func_check 0x114 "fctiwu f4,f5" ++func_check 0x118 "fctiwu. f4,f5" ++func_check 0x11c "fctiwuz f4,f5" ++func_check 0x120 "fctiwuz. f4,f5" ++func_check 0x124 "fctidu f4,f5" ++func_check 0x128 "fctidu. f4,f5" ++func_check 0x12c "fctiduz f4,f5" ++func_check 0x130 "fctiduz. f4,f5" ++func_check 0x134 "fcfidu f4,f5" ++func_check 0x138 "fcfidu. f4,f5" ++func_check 0x13c "ftdiv cr0,f10,f11" ++func_check 0x140 "ftdiv cr7,f10,f11" ++func_check 0x144 "ftsqrt cr0,f10" ++func_check 0x148 "ftsqrt cr7,f10" ++func_check 0x14c "dcbtt r8,r9" "dcbt 16,r8,r9" ++func_check 0x150 "dcbtstt r8,r9" "dcbtst 16,r8,r9" ++func_check 0x154 "dcffix f10,f12" ++func_check 0x158 "dcffix. f20,f22" ++func_check 0x15c "lbarx r10,r11,r12" ++func_check 0x160 "lbarx r10,r11,r12" ++func_check 0x164 "lbarx r10,r11,r12,1" ++func_check 0x168 "lharx r20,r21,r22" ++func_check 0x16c "lharx r20,r21,r22" ++func_check 0x170 "lharx r20,r21,r22,1" ++func_check 0x174 "stbcx. r10,r11,r12" ++func_check 0x178 "sthcx. r10,r11,r12" ++func_check 0x17c "fre f14,f15" ++func_check 0x180 "fre. f14,f15" ++func_check 0x184 "fres f14,f15" ++func_check 0x188 "fres. f14,f15" ++func_check 0x18c "frsqrte f14,f15" ++func_check 0x190 "frsqrte. f14,f15" ++func_check 0x194 "frsqrtes f14,f15" ++func_check 0x198 "frsqrtes. f14,f15" ++func_check 0x19c "isel r2,r3,r4,28" +--- /dev/null ++++ b/gdb/testsuite/gdb.arch/powerpc-power7.s +@@ -0,0 +1,107 @@ ++ .text ++ .globl func ++func: ++ .long 0x7c642e98 /* 0: lxvd2x vs3,r4,r5 */ ++ .long 0x7c642ed8 /* 4: lxvd2ux vs3,r4,r5 */ ++ .long 0x7d642e99 /* 8: lxvd2x vs43,r4,r5 */ ++ .long 0x7d642ed9 /* c: lxvd2ux vs43,r4,r5 */ ++ .long 0x7c642f98 /* 10: stxvd2x vs3,r4,r5 */ ++ .long 0x7c642fd8 /* 14: stxvd2ux vs3,r4,r5 */ ++ .long 0x7d642f99 /* 18: stxvd2x vs43,r4,r5 */ ++ .long 0x7d642fd9 /* 1c: stxvd2ux vs43,r4,r5 */ ++ .long 0xf0642850 /* 20: xxmrghd vs3,vs4,vs5 */ ++ .long 0xf16c6857 /* 24: xxmrghd vs43,vs44,vs45 */ ++ .long 0xf0642b50 /* 28: xxmrgld vs3,vs4,vs5 */ ++ .long 0xf16c6b57 /* 2c: xxmrgld vs43,vs44,vs45 */ ++ .long 0xf0642850 /* 30: xxmrghd vs3,vs4,vs5 */ ++ .long 0xf16c6857 /* 34: xxmrghd vs43,vs44,vs45 */ ++ .long 0xf0642b50 /* 38: xxmrgld vs3,vs4,vs5 */ ++ .long 0xf16c6b57 /* 3c: xxmrgld vs43,vs44,vs45 */ ++ .long 0xf0642950 /* 40: xxpermdi vs3,vs4,vs5,1 */ ++ .long 0xf16c6957 /* 44: xxpermdi vs43,vs44,vs45,1 */ ++ .long 0xf0642a50 /* 48: xxpermdi vs3,vs4,vs5,2 */ ++ .long 0xf16c6a57 /* 4c: xxpermdi vs43,vs44,vs45,2 */ ++ .long 0xf0642780 /* 50: xvmovdp vs3,vs4 */ ++ .long 0xf16c6787 /* 54: xvmovdp vs43,vs44 */ ++ .long 0xf0642780 /* 58: xvmovdp vs3,vs4 */ ++ .long 0xf16c6787 /* 5c: xvmovdp vs43,vs44 */ ++ .long 0xf0642f80 /* 60: xvcpsgndp vs3,vs4,vs5 */ ++ .long 0xf16c6f87 /* 64: xvcpsgndp vs43,vs44,vs45 */ ++ .long 0x7c00007c /* 68: wait */ ++ .long 0x7c00007c /* 6c: wait */ ++ .long 0x7c20007c /* 70: waitrsv */ ++ .long 0x7c20007c /* 74: waitrsv */ ++ .long 0x7c40007c /* 78: waitimpl */ ++ .long 0x7c40007c /* 7c: waitimpl */ ++ .long 0x4c000324 /* 80: doze */ ++ .long 0x4c000364 /* 84: nap */ ++ .long 0x4c0003a4 /* 88: sleep */ ++ .long 0x4c0003e4 /* 8c: rvwinkle */ ++ .long 0x7c830134 /* 90: prtyw r3,r4 */ ++ .long 0x7dcd0174 /* 94: prtyd r13,r14 */ ++ .long 0x7d5c02a6 /* 98: mfcfar r10 */ ++ .long 0x7d7c03a6 /* 9c: mtcfar r11 */ ++ .long 0x7c832bf8 /* a0: cmpb r3,r4,r5 */ ++ .long 0x7d4b662a /* a4: lwzcix r10,r11,r12 */ ++ .long 0xee119004 /* a8: dadd f16,f17,f18 */ ++ .long 0xfe96c004 /* ac: daddq f20,f22,f24 */ ++ .long 0x7c60066c /* b0: dss 3 */ ++ .long 0x7e00066c /* b4: dssall */ ++ .long 0x7c2522ac /* b8: dst r5,r4,1 */ ++ .long 0x7e083aac /* bc: dstt r8,r7,0 */ ++ .long 0x7c6532ec /* c0: dstst r5,r6,3 */ ++ .long 0x7e442aec /* c4: dststt r4,r5,2 */ ++ .long 0x7d4b6356 /* c8: divwe r10,r11,r12 */ ++ .long 0x7d6c6b57 /* cc: divwe. r11,r12,r13 */ ++ .long 0x7d8d7756 /* d0: divweo r12,r13,r14 */ ++ .long 0x7dae7f57 /* d4: divweo. r13,r14,r15 */ ++ .long 0x7d4b6316 /* d8: divweu r10,r11,r12 */ ++ .long 0x7d6c6b17 /* dc: divweu. r11,r12,r13 */ ++ .long 0x7d8d7716 /* e0: divweuo r12,r13,r14 */ ++ .long 0x7dae7f17 /* e4: divweuo. r13,r14,r15 */ ++ .long 0x7e27d9f8 /* e8: bpermd r7,r17,r27 */ ++ .long 0x7e8a02f4 /* ec: popcntw r10,r20 */ ++ .long 0x7e8a03f4 /* f0: popcntd r10,r20 */ ++ .long 0x7e95b428 /* f4: ldbrx r20,r21,r22 */ ++ .long 0x7e95b528 /* f8: stdbrx r20,r21,r22 */ ++ .long 0x7d4056ee /* fc: lfiwzx f10,0,r10 */ ++ .long 0x7d4956ee /* 100: lfiwzx f10,r9,r10 */ ++ .long 0xec802e9c /* 104: fcfids f4,f5 */ ++ .long 0xec802e9d /* 108: fcfids. f4,f5 */ ++ .long 0xec802f9c /* 10c: fcfidus f4,f5 */ ++ .long 0xec802f9d /* 110: fcfidus. f4,f5 */ ++ .long 0xfc80291c /* 114: fctiwu f4,f5 */ ++ .long 0xfc80291d /* 118: fctiwu. f4,f5 */ ++ .long 0xfc80291e /* 11c: fctiwuz f4,f5 */ ++ .long 0xfc80291f /* 120: fctiwuz. f4,f5 */ ++ .long 0xfc802f5c /* 124: fctidu f4,f5 */ ++ .long 0xfc802f5d /* 128: fctidu. f4,f5 */ ++ .long 0xfc802f5e /* 12c: fctiduz f4,f5 */ ++ .long 0xfc802f5f /* 130: fctiduz. f4,f5 */ ++ .long 0xfc802f9c /* 134: fcfidu f4,f5 */ ++ .long 0xfc802f9d /* 138: fcfidu. f4,f5 */ ++ .long 0xfc0a5900 /* 13c: ftdiv cr0,f10,f11 */ ++ .long 0xff8a5900 /* 140: ftdiv cr7,f10,f11 */ ++ .long 0xfc005140 /* 144: ftsqrt cr0,f10 */ ++ .long 0xff805140 /* 148: ftsqrt cr7,f10 */ ++ .long 0x7e084a2c /* 14c: dcbtt r8,r9 */ ++ .long 0x7e0849ec /* 150: dcbtstt r8,r9 */ ++ .long 0xed406644 /* 154: dcffix f10,f12 */ ++ .long 0xee80b645 /* 158: dcffix. f20,f22 */ ++ .long 0x7d4b6068 /* 15c: lbarx r10,r11,r12 */ ++ .long 0x7d4b6068 /* 160: lbarx r10,r11,r12 */ ++ .long 0x7d4b6069 /* 164: lbarx r10,r11,r12,1 */ ++ .long 0x7e95b0e8 /* 168: lharx r20,r21,r22 */ ++ .long 0x7e95b0e8 /* 16c: lharx r20,r21,r22 */ ++ .long 0x7e95b0e9 /* 170: lharx r20,r21,r22,1 */ ++ .long 0x7d4b656d /* 174: stbcx. r10,r11,r12 */ ++ .long 0x7d4b65ad /* 178: sthcx. r10,r11,r12 */ ++ .long 0xfdc07830 /* 17c: fre f14,f15 */ ++ .long 0xfdc07831 /* 180: fre. f14,f15 */ ++ .long 0xedc07830 /* 184: fres f14,f15 */ ++ .long 0xedc07831 /* 188: fres. f14,f15 */ ++ .long 0xfdc07834 /* 18c: frsqrte f14,f15 */ ++ .long 0xfdc07835 /* 190: frsqrte. f14,f15 */ ++ .long 0xedc07834 /* 194: frsqrtes f14,f15 */ ++ .long 0xedc07835 /* 198: frsqrtes. f14,f15 */ ++ .long 0x7c43271e /* 19c: isel r2,r3,r4,28 */ diff --git a/gdb-pr12028-double-free.patch b/gdb-pr12028-double-free.patch new file mode 100644 index 0000000..deb2115 --- /dev/null +++ b/gdb-pr12028-double-free.patch @@ -0,0 +1,99 @@ +http://sourceware.org/ml/gdb-patches/2010-09/msg00321.html +Subject: [patch] PR 12028 "GDB crashes on a double free during overload resolution" + +old_cleanups was being set twice making the later call to +discard_cleanups ignore the first 'make_cleanup' request. + +The patch is proposed for both head and the 7.2 branch. + +This has been regression tested on x8664 with gcc-4.4.4-10.fc13 + + +Fix PR 12028: "GDB crashes on a double free during overload resolution " + +2010-09-16 Sami Wagiaalla + + PR C++/12028 + * valops.c (find_oload_champ_namespace_loop): removed incorrect + 'old_cleanups' reassignment. + +2010-09-16 Sami Wagiaalla + + * gdb.cp/pr12028.cc: New. + * gdb.cp/pr12028.exp: New. + +diff --git a/gdb/testsuite/gdb.cp/pr12028.cc b/gdb/testsuite/gdb.cp/pr12028.cc +new file mode 100644 +index 0000000..0fcab6b +--- /dev/null ++++ b/gdb/testsuite/gdb.cp/pr12028.cc +@@ -0,0 +1,21 @@ ++class A{}; ++class B{}; ++class C: public B {}; ++ ++namespace D{ ++ int foo (A) { return 11; } ++ int foo (C) { return 12; } ++} ++ ++int main() ++{ ++ A a; ++ B b; ++ C c; ++ ++ D::foo (a); ++ // D::foo (b); ++ D::foo (c); ++ ++ return 0; ++} +diff --git a/gdb/testsuite/gdb.cp/pr12028.exp b/gdb/testsuite/gdb.cp/pr12028.exp +new file mode 100644 +index 0000000..746c6b5 +--- /dev/null ++++ b/gdb/testsuite/gdb.cp/pr12028.exp +@@ -0,0 +1,29 @@ ++# Copyright 2008 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 . ++ ++set testfile pr12028 ++set srcfile ${testfile}.cc ++if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} {debug c++}] } { ++ return -1 ++} ++ ++############################################ ++ ++if ![runto_main] then { ++ perror "couldn't run to breakpoint main" ++ continue ++} ++ ++gdb_test "p D::foo(b)" "Cannot resolve function foo to any overloaded instance" +diff --git a/gdb/valops.c b/gdb/valops.c +index 7fbad10..4e83a04 100644 +--- a/gdb/valops.c ++++ b/gdb/valops.c +@@ -2715,7 +2715,7 @@ find_oload_champ_namespace_loop (struct type **arg_types, int nargs, + function symbol to start off with.) */ + + old_cleanups = make_cleanup (xfree, *oload_syms); +- old_cleanups = make_cleanup (xfree, *oload_champ_bv); ++ make_cleanup (xfree, *oload_champ_bv); + new_namespace = alloca (namespace_len + 1); + strncpy (new_namespace, qualified_name, namespace_len); + new_namespace[namespace_len] = '\0'; diff --git a/gdb-python.patch b/gdb-python.patch deleted file mode 100644 index dbb8082..0000000 --- a/gdb-python.patch +++ /dev/null @@ -1,27 +0,0 @@ ---- gdb-7.0/gdb/configure.ac~ 2010-07-08 14:54:43.770583270 +0200 -+++ gdb-7.0/gdb/configure.ac 2010-07-08 14:56:17.539947910 +0200 -@@ -881,6 +881,12 @@ - LIBS="$LIBS ${python_libs}" - have_libpython=no - if test "${have_libpython}" = no; then -+ AC_TRY_LIBPYTHON(python2.7, have_libpython) -+ if test "${HAVE_LIBPYTHON2_7}" = yes; then -+ AC_DEFINE(HAVE_LIBPYTHON2_7, 1, [Define if Python 2.7 is being used.]) -+ fi -+ fi -+ if test "${have_libpython}" = no; then - AC_TRY_LIBPYTHON(python2.6, have_libpython) - if test "${HAVE_LIBPYTHON2_6}" = yes; then - AC_DEFINE(HAVE_LIBPYTHON2_6, 1, [Define if Python 2.6 is being used.]) ---- gdb-7.0/gdb/python/python-internal.h~ 2010-07-08 14:54:43.136858331 +0200 -+++ gdb-7.0/gdb/python/python-internal.h 2010-07-08 14:56:56.739736159 +0200 -@@ -45,6 +45,9 @@ - #elif HAVE_LIBPYTHON2_6 - #include "python2.6/Python.h" - #include "python2.6/frameobject.h" -+#elif HAVE_LIBPYTHON2_7 -+#include "python2.7/Python.h" -+#include "python2.7/frameobject.h" - #else - #error "Unable to find usable Python.h" - #endif diff --git a/gdb-readline-6.0-signal.patch b/gdb-readline-6.0-signal.patch deleted file mode 100644 index 0873bea..0000000 --- a/gdb-readline-6.0-signal.patch +++ /dev/null @@ -1,312 +0,0 @@ -http://sourceware.org/ml/gdb-patches/2009-11/msg00596.html -Subject: [gdb FYI-patch] callback-mode readline-6.0 regression - -Hi Chet, - -FSF GDB currently ships bundled with readline-5.2 which works fine. -But using --with-system-readline and readline-6.0-patchlevel4 has -a regression: - -readline-5.2: Run `gdb -nx -q' and type CTRL-C: -(gdb) Quit -(gdb) _ - -readline-6.0: Run `gdb -nx -q' and type CTRL-C: -(gdb) _ - = nothing happens (it gets buffered and executed later) - (It does also FAIL on gdb.gdb/selftest.exp.) - -It is because GDB waits in its own poll() mainloop and readline uses via -rl_callback_handler_install and rl_callback_handler_remove. This way the -readline internal variable _rl_interrupt_immediately remains 0 and CTRL-C gets -only stored to _rl_caught_signal but not executed. - -Seen in rl_signal_handler even if _rl_interrupt_immediately is set and -_rl_handle_signal is called then the signal is still stored to -_rl_caught_signal. In the _rl_interrupt_immediately case it should not be -stored when it was already processed. - -rl_signal_handler does `_rl_interrupt_immediately = 0;' - while I am not aware -of its meaning it breaks the nest-counting of other routines which do -`_rl_interrupt_immediately++;' and `_rl_interrupt_immediately--;' possibly -creating problematic `_rl_interrupt_immediately == -1'. - -`_rl_interrupt_immediately' is an internal variable, how it could be accessed -by a readline application? (OK, maybe it should not be used.) - -Attaching a current GDB-side patch but it must access readline internal -variable _rl_caught_signal and it is generally just a workaround. Could you -please include support for signals in this asynchronous mode in readline-6.1? -I find it would be enough to make RL_CHECK_SIGNALS public? - - -GDB: No regressions on {x86_64,x86_64-m32,i686}-fedora12-linux-gnu. -But this is not a patch intended to be accepted. - - -Thanks, -Jan - - -gdb/ -2009-11-29 Jan Kratochvil - - * config.in, configure: Regenerate. - * configure.ac (for readline_echoing_p): Move inside $LIBS change. - (for _rl_caught_signal): New. - * event-loop.c: Include readline/readline.h. - (gdb_do_one_event) [HAVE_READLINE_CAUGHT_SIGNAL]: New. - -gdb/testsuite/ -2009-11-29 Jan Kratochvil - - * gdb.gdb/selftest.exp (backtrace through signal handler): Move before - SIGINT pass, drop the timeout case. - (send SIGINT signal to child process): Use gdb_test. - (backtrace through readline handler): New. - ---- a/gdb/config.in -+++ b/gdb/config.in -@@ -351,6 +351,9 @@ - /* Define if Python interpreter is being linked in. */ - #undef HAVE_PYTHON - -+/* readline-6.0 workaround of blocked signals. */ -+#undef HAVE_READLINE_CAUGHT_SIGNAL -+ - /* Define to 1 if you have the `realpath' function. */ - #undef HAVE_REALPATH - ---- a/gdb/configure.ac -+++ b/gdb/configure.ac -@@ -539,17 +539,25 @@ if test "$with_system_readline" = yes; then - # readline-6.0 started to use the name `_rl_echoing_p'. - # `$(READLINE_DIR)/' of bundled readline would not resolve in configure. - -- AC_MSG_CHECKING([for readline_echoing_p]) - save_LIBS=$LIBS - LIBS="$LIBS $READLINE" -+ AC_MSG_CHECKING([for readline_echoing_p]) - AC_LINK_IFELSE(AC_LANG_PROGRAM(,[[extern int readline_echoing_p; - return readline_echoing_p;]]), - [READLINE_ECHOING_P=yes], - [READLINE_ECHOING_P=no - AC_DEFINE([readline_echoing_p], [_rl_echoing_p], - [readline-6.0 started to use different name.])]) -- LIBS="$save_LIBS" - AC_MSG_RESULT([$READLINE_ECHOING_P]) -+ AC_MSG_CHECKING([for _rl_caught_signal]) -+ AC_LINK_IFELSE(AC_LANG_PROGRAM(,[[extern int volatile _rl_caught_signal; -+ return _rl_caught_signal;]]), -+ [READLINE_CAUGHT_SIGNAL=yes -+ AC_DEFINE([HAVE_READLINE_CAUGHT_SIGNAL],, -+ [readline-6.0 workaround of blocked signals.])], -+ [READLINE_CAUGHT_SIGNAL=no]) -+ AC_MSG_RESULT([$READLINE_CAUGHT_SIGNAL]) -+ LIBS="$save_LIBS" - else - READLINE='$(READLINE_DIR)/libreadline.a' - READLINE_DEPS='$(READLINE)' ---- a/gdb/event-loop.c -+++ b/gdb/event-loop.c -@@ -37,6 +37,7 @@ - #include "exceptions.h" - #include "gdb_assert.h" - #include "gdb_select.h" -+#include "readline/readline.h" - - /* Data point to pass to the event handler. */ - typedef union event_data -@@ -411,6 +412,9 @@ gdb_do_one_event (void *data) - static int event_source_head = 0; - const int number_of_sources = 3; - int current = 0; -+#ifdef HAVE_READLINE_CAUGHT_SIGNAL -+ extern int volatile _rl_caught_signal; -+#endif - - /* Any events already waiting in the queue? */ - if (process_event ()) -@@ -455,6 +459,16 @@ gdb_do_one_event (void *data) - if (gdb_wait_for_event (1) < 0) - return -1; - -+#ifdef HAVE_READLINE_CAUGHT_SIGNAL -+ if (async_command_editing_p && RL_ISSTATE (RL_STATE_CALLBACK) -+ && _rl_caught_signal) -+ { -+ /* Call RL_CHECK_SIGNALS this way. */ -+ rl_callback_handler_remove (); -+ rl_callback_handler_install (NULL, input_handler); -+ } -+#endif -+ - /* Handle any new events occurred while waiting. */ - if (process_event ()) - return 1; ---- a/gdb/testsuite/gdb.gdb/selftest.exp -+++ b/gdb/testsuite/gdb.gdb/selftest.exp -@@ -464,31 +464,42 @@ GDB.*Copyright \[0-9\]+ Free Software Foundation, Inc..*$gdb_prompt $"\ - fail "$description (timeout)" - } - } -- -- set description "send SIGINT signal to child process" -- send_gdb "signal SIGINT\n" -- gdb_expect { -- -re "Continuing with signal SIGINT.*$gdb_prompt $" { -+ -+ # get a stack trace with the poll function -+ # -+ # This fails on some linux systems for unknown reasons. On the -+ # systems where it fails, sometimes it works fine when run manually. -+ # The testsuite failures may not be limited to just aout systems. -+ setup_xfail "i*86-pc-linuxaout-gnu" -+ set description "backtrace through signal handler" -+ gdb_test_multiple "backtrace" $description { -+ -re "#0.*(read|poll).*in main \\(.*\\) at .*gdb\\.c.*$gdb_prompt $" { - pass "$description" - } - -re ".*$gdb_prompt $" { -+ # On the alpha, we hit the infamous problem about gdb -+ # being unable to get the frame pointer (mentioned in -+ # gdb/README). As it is intermittent, there is no way to -+ # XFAIL it which will give us an XPASS if the problem goes -+ # away. -+ setup_xfail "alpha*-*-osf*" - fail "$description" - } -- timeout { -- fail "$description (timeout)" -- } - } - -- # get a stack trace -+ gdb_test "signal SIGINT" "Continuing with signal SIGINT.*" \ -+ "send SIGINT signal to child process" -+ -+ # get a stack trace being redelivered by readline - # - # This fails on some linux systems for unknown reasons. On the - # systems where it fails, sometimes it works fine when run manually. - # The testsuite failures may not be limited to just aout systems. -+ # Optional system readline may not have symbols to be shown. - setup_xfail "i*86-pc-linuxaout-gnu" -- set description "backtrace through signal handler" -- send_gdb "backtrace\n" -- gdb_expect { -- -re "#0.*(read|poll).*in main \\(.*\\) at .*gdb\\.c.*$gdb_prompt $" { -+ set description "backtrace through readline handler" -+ gdb_test_multiple "backtrace" $description { -+ -re "#0.*gdb_do_one_event.*in main \\(.*\\) at .*gdb\\.c.*$gdb_prompt $" { - pass "$description" - } - -re ".*$gdb_prompt $" { -@@ -500,9 +510,6 @@ GDB.*Copyright \[0-9\]+ Free Software Foundation, Inc..*$gdb_prompt $"\ - setup_xfail "alpha*-*-osf*" - fail "$description" - } -- timeout { -- fail "$description (timeout)" -- } - } - - ---- gdb-7.0/gdb/configure 2009-12-07 18:53:30.000000000 +0100 -+++ gdb-7.0-x/gdb/configure 2009-12-07 18:53:14.000000000 +0100 -@@ -9201,15 +9201,11 @@ if test "$with_system_readline" = yes; t - # readline-6.0 started to use the name `_rl_echoing_p'. - # `$(READLINE_DIR)/' of bundled readline would not resolve in configure. - -- echo "$as_me:$LINENO: checking for readline_echoing_p" >&5 --echo $ECHO_N "checking for readline_echoing_p... $ECHO_C" >&6 - save_LIBS=$LIBS - LIBS="$LIBS $READLINE" -- cat >conftest.$ac_ext <<_ACEOF --/* confdefs.h. */ --_ACEOF --cat confdefs.h >>conftest.$ac_ext --cat >>conftest.$ac_ext <<_ACEOF -+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for readline_echoing_p" >&5 -+$as_echo_n "checking for readline_echoing_p... " >&6; } -+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext - /* end confdefs.h. */ - - int -@@ -9221,45 +9217,45 @@ extern int readline_echoing_p; - return 0; - } - _ACEOF --rm -f conftest.$ac_objext conftest$ac_exeext --if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 -- (eval $ac_link) 2>conftest.er1 -- ac_status=$? -- grep -v '^ *+' conftest.er1 >conftest.err -- rm -f conftest.er1 -- cat conftest.err >&5 -- echo "$as_me:$LINENO: \$? = $ac_status" >&5 -- (exit $ac_status); } && -- { ac_try='test -z "$ac_c_werror_flag" -- || test ! -s conftest.err' -- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -- (eval $ac_try) 2>&5 -- ac_status=$? -- echo "$as_me:$LINENO: \$? = $ac_status" >&5 -- (exit $ac_status); }; } && -- { ac_try='test -s conftest$ac_exeext' -- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -- (eval $ac_try) 2>&5 -- ac_status=$? -- echo "$as_me:$LINENO: \$? = $ac_status" >&5 -- (exit $ac_status); }; }; then -+if ac_fn_c_try_link "$LINENO"; then : - READLINE_ECHOING_P=yes - else -- echo "$as_me: failed program was:" >&5 --sed 's/^/| /' conftest.$ac_ext >&5 -+ READLINE_ECHOING_P=no - --READLINE_ECHOING_P=no -+$as_echo "#define readline_echoing_p _rl_echoing_p" >>confdefs.h -+ -+fi -+rm -f core conftest.err conftest.$ac_objext \ -+ conftest$ac_exeext conftest.$ac_ext -+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $READLINE_ECHOING_P" >&5 -+$as_echo "$READLINE_ECHOING_P" >&6; } -+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for _rl_caught_signal" >&5 -+$as_echo_n "checking for _rl_caught_signal... " >&6; } -+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext -+/* end confdefs.h. */ - --cat >>confdefs.h <<\_ACEOF --#define readline_echoing_p _rl_echoing_p -+int -+main () -+{ -+extern int volatile _rl_caught_signal; -+ return _rl_caught_signal; -+ ; -+ return 0; -+} - _ACEOF -+if ac_fn_c_try_link "$LINENO"; then : -+ READLINE_CAUGHT_SIGNAL=yes -+ -+$as_echo "#define HAVE_READLINE_CAUGHT_SIGNAL /**/" >>confdefs.h - -+else -+ READLINE_CAUGHT_SIGNAL=no - fi --rm -f conftest.err conftest.$ac_objext \ -- conftest$ac_exeext conftest.$ac_ext -+rm -f core conftest.err conftest.$ac_objext \ -+ conftest$ac_exeext conftest.$ac_ext -+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $READLINE_CAUGHT_SIGNAL" >&5 -+$as_echo "$READLINE_CAUGHT_SIGNAL" >&6; } - LIBS="$save_LIBS" -- echo "$as_me:$LINENO: result: $READLINE_ECHOING_P" >&5 --echo "${ECHO_T}$READLINE_ECHOING_P" >&6 - else - READLINE='$(READLINE_DIR)/libreadline.a' - READLINE_DEPS='$(READLINE)' diff --git a/gdb-readline-6.0.patch b/gdb-readline-6.0.patch deleted file mode 100644 index 2d0060b..0000000 --- a/gdb-readline-6.0.patch +++ /dev/null @@ -1,123 +0,0 @@ -gdb/ -2009-07-31 Jan Kratochvil - - Fix compatibility of --with-system-readline and readline-6.0+. - * configure.ac <--with-system-readline> (for readline_echoing_p): New - test. - * config.in: Regenerate. - * configure: Regenerate. - -Index: gdb-6.8.50.20090909/gdb/configure.ac -=================================================================== ---- gdb-6.8.50.20090909.orig/gdb/configure.ac 2009-09-09 20:11:04.000000000 +0200 -+++ gdb-6.8.50.20090909/gdb/configure.ac 2009-09-09 20:11:54.000000000 +0200 -@@ -773,6 +773,21 @@ if test "$with_system_readline" = yes; t - READLINE=-lreadline - READLINE_DEPS= - READLINE_CFLAGS= -+ -+ # readline-6.0 started to use the name `_rl_echoing_p'. -+ # `$(READLINE_DIR)/' of bundled readline would not resolve in configure. -+ -+ AC_MSG_CHECKING([for readline_echoing_p]) -+ save_LIBS=$LIBS -+ LIBS="$LIBS $READLINE" -+ AC_LINK_IFELSE(AC_LANG_PROGRAM(,[[extern int readline_echoing_p; -+ return readline_echoing_p;]]), -+ [READLINE_ECHOING_P=yes], -+ [READLINE_ECHOING_P=no -+ AC_DEFINE([readline_echoing_p], [_rl_echoing_p], -+ [readline-6.0 started to use different name.])]) -+ LIBS="$save_LIBS" -+ AC_MSG_RESULT([$READLINE_ECHOING_P]) - else - READLINE='$(READLINE_DIR)/libreadline.a' - READLINE_DEPS='$(READLINE)' -Index: gdb-6.8.50.20090909/gdb/config.in -=================================================================== ---- gdb-6.8.50.20090909.orig/gdb/config.in 2009-09-09 20:11:33.000000000 +0200 -+++ gdb-6.8.50.20090909/gdb/config.in 2009-09-09 20:12:00.000000000 +0200 -@@ -815,6 +815,9 @@ - /* Define to `int' if does not define. */ - #undef pid_t - -+/* readline-6.0 started to use different name. */ -+#undef readline_echoing_p -+ - /* Define to the equivalent of the C99 'restrict' keyword, or to - nothing if this is not supported. Do not define if restrict is - supported directly. */ -Index: gdb-6.8.50.20090909/gdb/configure -=================================================================== ---- gdb-6.8.50.20090909.orig/gdb/configure 2009-09-09 20:11:07.000000000 +0200 -+++ gdb-6.8.50.20090909/gdb/configure 2009-09-09 20:11:54.000000000 +0200 -@@ -9197,6 +9197,69 @@ if test "$with_system_readline" = yes; t - READLINE=-lreadline - READLINE_DEPS= - READLINE_CFLAGS= -+ -+ # readline-6.0 started to use the name `_rl_echoing_p'. -+ # `$(READLINE_DIR)/' of bundled readline would not resolve in configure. -+ -+ echo "$as_me:$LINENO: checking for readline_echoing_p" >&5 -+echo $ECHO_N "checking for readline_echoing_p... $ECHO_C" >&6 -+ save_LIBS=$LIBS -+ LIBS="$LIBS $READLINE" -+ cat >conftest.$ac_ext <<_ACEOF -+/* confdefs.h. */ -+_ACEOF -+cat confdefs.h >>conftest.$ac_ext -+cat >>conftest.$ac_ext <<_ACEOF -+/* end confdefs.h. */ -+ -+int -+main () -+{ -+extern int readline_echoing_p; -+ return readline_echoing_p; -+ ; -+ return 0; -+} -+_ACEOF -+rm -f conftest.$ac_objext conftest$ac_exeext -+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 -+ (eval $ac_link) 2>conftest.er1 -+ ac_status=$? -+ grep -v '^ *+' conftest.er1 >conftest.err -+ rm -f conftest.er1 -+ cat conftest.err >&5 -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); } && -+ { ac_try='test -z "$ac_c_werror_flag" -+ || test ! -s conftest.err' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; } && -+ { ac_try='test -s conftest$ac_exeext' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; }; then -+ READLINE_ECHOING_P=yes -+else -+ echo "$as_me: failed program was:" >&5 -+sed 's/^/| /' conftest.$ac_ext >&5 -+ -+READLINE_ECHOING_P=no -+ -+cat >>confdefs.h <<\_ACEOF -+#define readline_echoing_p _rl_echoing_p -+_ACEOF -+ -+fi -+rm -f conftest.err conftest.$ac_objext \ -+ conftest$ac_exeext conftest.$ac_ext -+ LIBS="$save_LIBS" -+ echo "$as_me:$LINENO: result: $READLINE_ECHOING_P" >&5 -+echo "${ECHO_T}$READLINE_ECHOING_P" >&6 - else - READLINE='$(READLINE_DIR)/libreadline.a' - READLINE_DEPS='$(READLINE)' diff --git a/gdb-unused-revert.patch b/gdb-unused-revert.patch new file mode 100644 index 0000000..2abe3cf --- /dev/null +++ b/gdb-unused-revert.patch @@ -0,0 +1,44 @@ +[RFA/commit 5/5] Add -Wunused-function to compile flags. +http://sourceware.org/ml/gdb-patches/2010-01/msg00371.html +http://sourceware.org/ml/gdb-cvs/2010-01/msg00163.html + +REVERTED + +--- src/gdb/configure.ac 2010/01/15 00:34:37 1.112 ++++ src/gdb/configure.ac 2010/01/19 09:52:31 1.113 +@@ -1544,8 +1544,7 @@ + # gdb/doc/gdbint.texinfo. + build_warnings="-Wall -Wdeclaration-after-statement -Wpointer-arith \ + -Wformat-nonliteral -Wno-pointer-sign \ +--Wno-unused -Wunused-value -Wunused-function \ +--Wno-switch -Wno-char-subscripts" ++-Wno-unused -Wunused-value -Wno-switch -Wno-char-subscripts" + + # Enable -Wno-format by default when using gcc on mingw since many + # GCC versions complain about %I64. +--- src/gdb/configure 2010/01/15 00:34:37 1.297 ++++ src/gdb/configure 2010/01/19 09:52:32 1.298 +@@ -13435,8 +13435,7 @@ + # gdb/doc/gdbint.texinfo. + build_warnings="-Wall -Wdeclaration-after-statement -Wpointer-arith \ + -Wformat-nonliteral -Wno-pointer-sign \ +--Wno-unused -Wunused-value -Wunused-function \ +--Wno-switch -Wno-char-subscripts" ++-Wno-unused -Wunused-value -Wno-switch -Wno-char-subscripts" + + # Enable -Wno-format by default when using gcc on mingw since many + # GCC versions complain about %I64. +### src/gdb/ChangeLog 2010/01/19 09:50:48 1.11271 +### src/gdb/ChangeLog 2010/01/19 09:52:33 1.11272 +## -1,11 +1,5 @@ + 2010-01-19 Joel Brobecker + +- Add -Wunused-function to compile flags. +- * configure.ac: Add -Wunused-function to build_warnings. +- * configure: Regenerate. +- +-2010-01-19 Joel Brobecker +- + "delete" ada-lex.c:input function, not used. + * ada-lex.l: #define YY_NO_INPUT. + diff --git a/gdb-upstream.patch b/gdb-upstream.patch new file mode 100644 index 0000000..ad3d10c --- /dev/null +++ b/gdb-upstream.patch @@ -0,0 +1,467 @@ +https://bugzilla.redhat.com/show_bug.cgi?id=610986 +http://sourceware.org/ml/gdb-cvs/2010-08/msg00112.html + +### src/gdb/ChangeLog 2010/08/18 22:57:45 1.12097 +### src/gdb/ChangeLog 2010/08/19 07:34:26 1.12098 +## -1,3 +1,9 @@ ++2010-08-19 Jan Kratochvil ++ ++ * varobj.c (varobj_create): Replace variable old_fi with old_id, ++ initialize it by null_frame_id, wrap its usage by get_frame_id, ++ frame_id_p and frame_find_by_id. ++ + 2010-08-18 Tom Tromey + + PR python/11900: +--- src/gdb/varobj.c 2010/08/06 14:17:56 1.159 ++++ src/gdb/varobj.c 2010/08/19 07:34:27 1.160 +@@ -524,7 +524,7 @@ varobj_create (char *objname, + { + struct varobj *var; + struct frame_info *fi; +- struct frame_info *old_fi = NULL; ++ struct frame_id old_id = null_frame_id; + struct block *block; + struct cleanup *old_chain; + +@@ -611,7 +611,7 @@ + + var->root->frame = get_frame_id (fi); + var->root->thread_id = pid_to_thread_id (inferior_ptid); +- old_fi = get_selected_frame (NULL); ++ old_id = get_frame_id (get_selected_frame (NULL)); + select_frame (fi); + } + +@@ -639,8 +639,8 @@ + var->root->rootvar = var; + + /* Reset the selected frame */ +- if (old_fi != NULL) +- select_frame (old_fi); ++ if (frame_id_p (old_id)) ++ select_frame (frame_find_by_id (old_id)); + } + + /* If the variable object name is null, that means this + + + +https://bugzilla.redhat.com/show_bug.cgi?id=627506 +Re: [patch] Fix nesting of ui_out_redirect +http://sourceware.org/ml/gdb-patches/2010-09/msg00122.html +http://sourceware.org/ml/gdb-cvs/2010-09/msg00031.html + +### src/gdb/ChangeLog 2010/09/03 01:29:09 1.12149 +### src/gdb/ChangeLog 2010/09/03 15:41:59 1.12150 +## -1,3 +1,27 @@ ++2010-09-03 Jan Kratochvil ++ ++ * breakpoint.c (save_breakpoints): Use RETURN_MASK_ALL. ++ * cli-out.c: Include vec.h. ++ (cli_field_fmt, cli_spaces, cli_text, cli_message, cli_flush): New ++ variable stream, initialize it, use it. ++ (cli_redirect): New function comment. Replace the stream and ++ original_stream fields by the new streams field. Remove the ++ original_stream != NULL conditional, assert error on NULL instead. ++ (out_field_fmt, field_separator): New variable stream, initialize it, use it. ++ (cli_out_data_ctor): Assert non-NULL stream. Replace the stream and ++ original_stream fields by the new streams field. ++ (cli_out_set_stream): Replace the stream field by the new streams ++ field. ++ * cli-out.h: Include vec.h. ++ (ui_filep): New typedef, call DEF_VEC_P for it. ++ (struct cli_ui_out_data): Replace the stream and original_stream ++ fields by the new streams field. ++ * cli/cli-logging.c (set_logging_redirect): Call ui_out_redirect with ++ NULL first. Extend the comment. ++ (handle_redirections): Call ui_out_redirect with output. ++ * python/py-breakpoint.c (bppy_get_commands): Move ui_out_redirect ++ calls outside of the TRY_CATCH block. ++ + +[ cli/cli-logging.c removed. ] + +--- src/gdb/breakpoint.c 2010/08/30 09:49:12 1.511 ++++ src/gdb/breakpoint.c 2010/09/03 15:42:02 1.512 +@@ -11487,7 +11487,7 @@ + fprintf_unfiltered (fp, " commands\n"); + + ui_out_redirect (uiout, fp); +- TRY_CATCH (ex, RETURN_MASK_ERROR) ++ TRY_CATCH (ex, RETURN_MASK_ALL) + { + print_command_lines (uiout, tp->commands->commands, 2); + } +--- src/gdb/cli-out.c 2010/05/13 23:53:32 1.30 ++++ src/gdb/cli-out.c 2010/09/03 15:42:02 1.31 +@@ -26,6 +26,7 @@ + #include "cli-out.h" + #include "gdb_string.h" + #include "gdb_assert.h" ++#include "vec.h" + + typedef struct cli_ui_out_data cli_out_data; + +@@ -224,11 +225,13 @@ + va_list args) + { + cli_out_data *data = ui_out_data (uiout); ++ struct ui_file *stream; + + if (data->suppress_output) + return; + +- vfprintf_filtered (data->stream, format, args); ++ stream = VEC_last (ui_filep, data->streams); ++ vfprintf_filtered (stream, format, args); + + if (align != ui_noalign) + field_separator (); +@@ -238,20 +241,26 @@ + cli_spaces (struct ui_out *uiout, int numspaces) + { + cli_out_data *data = ui_out_data (uiout); ++ struct ui_file *stream; + + if (data->suppress_output) + return; +- print_spaces_filtered (numspaces, data->stream); ++ ++ stream = VEC_last (ui_filep, data->streams); ++ print_spaces_filtered (numspaces, stream); + } + + static void + cli_text (struct ui_out *uiout, const char *string) + { + cli_out_data *data = ui_out_data (uiout); ++ struct ui_file *stream; + + if (data->suppress_output) + return; +- fputs_filtered (string, data->stream); ++ ++ stream = VEC_last (ui_filep, data->streams); ++ fputs_filtered (string, stream); + } + + static void ATTRIBUTE_PRINTF (3, 0) +@@ -262,8 +271,13 @@ + + if (data->suppress_output) + return; ++ + if (ui_out_get_verblvl (uiout) >= verbosity) +- vfprintf_unfiltered (data->stream, format, args); ++ { ++ struct ui_file *stream = VEC_last (ui_filep, data->streams); ++ ++ vfprintf_unfiltered (stream, format, args); ++ } + } + + static void +@@ -280,25 +294,24 @@ + cli_flush (struct ui_out *uiout) + { + cli_out_data *data = ui_out_data (uiout); ++ struct ui_file *stream = VEC_last (ui_filep, data->streams); + +- gdb_flush (data->stream); ++ gdb_flush (stream); + } + ++/* OUTSTREAM as non-NULL will push OUTSTREAM on the stack of output streams ++ and make it therefore active. OUTSTREAM as NULL will pop the last pushed ++ output stream; it is an internal error if it does not exist. */ ++ + static int + cli_redirect (struct ui_out *uiout, struct ui_file *outstream) + { + cli_out_data *data = ui_out_data (uiout); + + if (outstream != NULL) +- { +- data->original_stream = data->stream; +- data->stream = outstream; +- } +- else if (data->original_stream != NULL) +- { +- data->stream = data->original_stream; +- data->original_stream = NULL; +- } ++ VEC_safe_push (ui_filep, data->streams, outstream); ++ else ++ VEC_pop (ui_filep, data->streams); + + return 0; + } +@@ -315,10 +328,11 @@ + const char *format,...) + { + cli_out_data *data = ui_out_data (uiout); ++ struct ui_file *stream = VEC_last (ui_filep, data->streams); + va_list args; + + va_start (args, format); +- vfprintf_filtered (data->stream, format, args); ++ vfprintf_filtered (stream, format, args); + + va_end (args); + } +@@ -329,8 +343,9 @@ + field_separator (void) + { + cli_out_data *data = ui_out_data (uiout); ++ struct ui_file *stream = VEC_last (ui_filep, data->streams); + +- fputc_filtered (' ', data->stream); ++ fputc_filtered (' ', stream); + } + + /* This is the CLI ui-out implementation functions vector */ +@@ -364,8 +379,11 @@ + void + cli_out_data_ctor (cli_out_data *self, struct ui_file *stream) + { +- self->stream = stream; +- self->original_stream = NULL; ++ gdb_assert (stream != NULL); ++ ++ self->streams = NULL; ++ VEC_safe_push (ui_filep, self->streams, stream); ++ + self->suppress_output = 0; + } + +@@ -385,8 +403,10 @@ + cli_out_set_stream (struct ui_out *uiout, struct ui_file *stream) + { + cli_out_data *data = ui_out_data (uiout); +- struct ui_file *old = data->stream; ++ struct ui_file *old; ++ ++ old = VEC_pop (ui_filep, data->streams); ++ VEC_quick_push (ui_filep, data->streams, stream); + +- data->stream = stream; + return old; + } +--- src/gdb/cli-out.h 2010/04/18 00:11:55 1.11 ++++ src/gdb/cli-out.h 2010/09/03 15:42:02 1.12 +@@ -22,14 +22,19 @@ + #define CLI_OUT_H + + #include "ui-out.h" ++#include "vec.h" ++ ++/* Used for cli_ui_out_data->streams. */ ++ ++typedef struct ui_file *ui_filep; ++DEF_VEC_P (ui_filep); + + /* These are exported so that they can be extended by other `ui_out' + implementations, like TUI's. */ + + struct cli_ui_out_data + { +- struct ui_file *stream; +- struct ui_file *original_stream; ++ VEC (ui_filep) *streams; + int suppress_output; + }; + +--- src/gdb/python/py-breakpoint.c 2010/07/01 10:36:12 1.4 ++++ src/gdb/python/py-breakpoint.c 2010/09/03 15:42:03 1.5 +@@ -474,12 +474,12 @@ + string_file = mem_fileopen (); + chain = make_cleanup_ui_file_delete (string_file); + ++ ui_out_redirect (uiout, string_file); + TRY_CATCH (except, RETURN_MASK_ALL) + { +- ui_out_redirect (uiout, string_file); + print_command_lines (uiout, breakpoint_commands (bp), 0); +- ui_out_redirect (uiout, NULL); + } ++ ui_out_redirect (uiout, NULL); + cmdstr = ui_file_xstrdup (string_file, &length); + GDB_PY_HANDLE_EXCEPTION (except); + +### src/gdb/testsuite/ChangeLog 2010/09/02 15:19:56 1.2435 +### src/gdb/testsuite/ChangeLog 2010/09/03 15:42:04 1.2436 +## -1,3 +1,7 @@ ++2010-09-03 Jan Kratochvil ++ ++ * gdb.base/ui-redirect.exp: New file. ++ + 2010-09-02 Jan Kratochvil + Joel Brobecker + +--- src/gdb/testsuite/gdb.base/ui-redirect.exp ++++ src/gdb/testsuite/gdb.base/ui-redirect.exp 2010-09-11 18:42:40.040910000 +0000 +@@ -0,0 +1,41 @@ ++# 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 . ++ ++if { [prepare_for_testing ui-redirect.exp ui-redirect start.c] } { ++ return -1 ++} ++ ++gdb_breakpoint main ++ ++set test "commands" ++gdb_test_multiple $test $test { ++ -re "End with a line saying just \"end\"\\.\r\n>$" { ++ pass $test ++ } ++} ++ ++set test "print 1" ++gdb_test_multiple $test $test { ++ -re "\r\n>$" { ++ pass $test ++ } ++} ++gdb_test_no_output "end" ++ ++gdb_test_no_output "set logging file /dev/null" ++gdb_test "set logging on" "Copying output to /dev/null\\." ++gdb_test "save breakpoints /dev/null" "Saved to file '/dev/null'\\." ++gdb_test "set logging off" "Done logging to /dev/null\\." ++gdb_test "help" "List of classes of commands:.*" + + + +https://bugzilla.redhat.com/show_bug.cgi?id=627506 +Re: [patch] Fix uiout for execute_command_to_string +http://sourceware.org/ml/gdb-patches/2010-09/msg00235.html +http://sourceware.org/ml/gdb-cvs/2010-09/msg00080.html + +### src/gdb/ChangeLog 2010/09/10 16:17:11 1.12170 +### src/gdb/ChangeLog 2010/09/11 16:00:20 1.12171 +## -1,3 +1,21 @@ ++2010-09-11 Jan Kratochvil ++ Paul Bolle ++ ++ Redirect also uiout and stdtarg{,err} in execute_command_to_string. ++ * cli-logging.c (struct saved_output_files) : New. ++ (set_logging_redirect, pop_output_files, handle_redirections): ++ Redirect also gdb_stdtargerr. ++ * defs.h (struct ui_out, make_cleanup_ui_out_redirect_pop): New ++ declarations. ++ * event-top.c (gdb_setup_readline, gdb_disable_readline): Redirect ++ also gdb_stdtargerr. ++ * top.c (execute_command_to_string): Move make_cleanup_ui_file_delete ++ to the top. Redirect also gdb_stdlog, gdb_stdtarg and gdb_stdtargerr. ++ Use ui_out_redirect, register make_cleanup_ui_out_redirect_pop. ++ * tui/tui-io.c (tui_setup_io): Redirect also gdb_stdtargerr. ++ * utils.c (do_ui_out_redirect_pop, make_cleanup_ui_out_redirect_pop): ++ New functions. ++ + +### src/gdb/testsuite/ChangeLog 2010/09/10 20:29:25 1.2444 +### src/gdb/testsuite/ChangeLog 2010/09/11 16:00:26 1.2445 +## -1,3 +1,8 @@ ++2010-09-11 Jan Kratochvil ++ ++ * gdb.python/python.exp (set height 0, collect help from uiout) ++ (verify help to uiout): New tests. ++ + +[ gdb_stdtargerr handling dropped. ] + +--- src/gdb/defs.h 2010/08/31 18:08:43 1.278 ++++ src/gdb/defs.h 2010/09/11 16:00:25 1.279 +@@ -337,6 +337,10 @@ + struct ui_file; + extern struct cleanup *make_cleanup_ui_file_delete (struct ui_file *); + ++struct ui_out; ++extern struct cleanup * ++ make_cleanup_ui_out_redirect_pop (struct ui_out *uiout); ++ + struct section_addr_info; + extern struct cleanup *(make_cleanup_free_section_addr_info + (struct section_addr_info *)); +--- src/gdb/top.c 2010/08/07 15:00:37 1.183 ++++ src/gdb/top.c 2010/09/11 16:00:25 1.184 +@@ -475,12 +475,23 @@ + + str_file = mem_fileopen (); + ++ make_cleanup_ui_file_delete (str_file); + make_cleanup_restore_ui_file (&gdb_stdout); + make_cleanup_restore_ui_file (&gdb_stderr); +- make_cleanup_ui_file_delete (str_file); ++ make_cleanup_restore_ui_file (&gdb_stdlog); ++ make_cleanup_restore_ui_file (&gdb_stdtarg); ++ make_cleanup_restore_ui_file (&gdb_stdtargerr); ++ ++ if (ui_out_redirect (uiout, str_file) < 0) ++ warning (_("Current output protocol does not support redirection")); ++ else ++ make_cleanup_ui_out_redirect_pop (uiout); + + gdb_stdout = str_file; + gdb_stderr = str_file; ++ gdb_stdlog = str_file; ++ gdb_stdtarg = str_file; ++ gdb_stdtargerr = str_file; + + execute_command (p, from_tty); + +--- src/gdb/utils.c 2010/08/07 15:00:37 1.239 ++++ src/gdb/utils.c 2010/09/11 16:00:25 1.240 +@@ -311,6 +311,26 @@ + return make_my_cleanup (&cleanup_chain, do_ui_file_delete, arg); + } + ++/* Helper function for make_cleanup_ui_out_redirect_pop. */ ++ ++static void ++do_ui_out_redirect_pop (void *arg) ++{ ++ struct ui_out *uiout = arg; ++ ++ if (ui_out_redirect (uiout, NULL) < 0) ++ warning (_("Cannot restore redirection of the current output protocol")); ++} ++ ++/* Return a new cleanup that pops the last redirection by ui_out_redirect ++ with NULL parameter. */ ++ ++struct cleanup * ++make_cleanup_ui_out_redirect_pop (struct ui_out *uiout) ++{ ++ return make_my_cleanup (&cleanup_chain, do_ui_out_redirect_pop, uiout); ++} ++ + static void + do_free_section_addr_info (void *arg) + { +--- gdb-7.2/gdb/testsuite/gdb.python/python.exp-orig 2010-08-09 21:23:00.000000000 +0200 ++++ gdb-7.2/gdb/testsuite/gdb.python/python.exp 2010-09-11 20:49:22.000000000 +0200 +@@ -110,3 +110,9 @@ gdb_test_multiple "python print \"\\n\" + } + } + gdb_test "q" "Quit" "verify pagination afterwards: q" ++ ++gdb_test_no_output "set height 0" ++ ++gdb_test_no_output "python a = gdb.execute('help', to_string=True)" "collect help from uiout" ++ ++gdb_test "python print a" ".*aliases -- Aliases of other commands.*" "verify help to uiout" diff --git a/gdb.spec b/gdb.spec index 4961b78..9e0aac4 100644 --- a/gdb.spec +++ b/gdb.spec @@ -5,7 +5,7 @@ # - change install msg to poldek in buildid-locate-rpm-pld.patch when poldek allows it. LP#493922 # # Conditional build: -%bcond_without python # build without python support +%bcond_with python # build with python support Summary: A GNU source-level debugger for C, C++ and Fortran Summary(de.UTF-8): Symbolischer Debugger für C und andere Sprachen @@ -19,17 +19,15 @@ Summary(uk.UTF-8): Символьний відладчик для С та інш Summary(zh_CN.UTF-8): [开发]C和其他语言的调试器 Summary(zh_TW.UTF-8): [.-A開發]C和.$)B其.-A他語.$)B言的調試器 Name: gdb -Version: 7.0 -Release: 7 +Version: 7.2 +Release: 0.1 License: GPL v3+ Group: Development/Debuggers Source0: http://ftp.gnu.org/gnu/gdb/%{name}-%{version}.tar.bz2 -# Source0-md5: 3386a7b69c010785c920ffc1e9cb890a +# Source0-md5: 64260e6c56979ee750a01055f16091a5 Source1: http://www.mif.pg.gda.pl/homepages/ankry/man-PLD/%{name}-non-english-man-pages.tar.bz2 # Source1-md5: 2e8a48939ae282c12bbacdd54e398247 Source3: %{name}-gstack.man -Source4: libstdc++-v3-python-r151798.tar.bz2 -# Source4-md5: 7507540c50a1edeb2fc22a37bc4a08b8 # FEDORA -- use the same numbering that they do # don't ever modify these patches, apply secondary patch to alter it pld way @@ -46,8 +44,8 @@ Patch112: %{name}-6.6-scheduler_locking-step-sw-watchpoints2.patch Patch260: %{name}-6.6-scheduler_locking-step-is-default.patch Patch118: %{name}-6.3-gstack-20050411.patch Patch122: %{name}-6.3-test-pie-20050107.patch -Patch124: %{name}-archer-pie.patch Patch389: %{name}-archer-pie-addons.patch +Patch394: %{name}-archer-pie-addons-keep-disabled.patch Patch125: %{name}-6.3-test-self-20050110.patch Patch133: %{name}-6.3-test-dtorfix-20050121.patch Patch136: %{name}-6.3-test-movedir-20050125.patch @@ -68,33 +66,27 @@ Patch164: %{name}-6.3-readnever-20050907.patch Patch169: %{name}-6.3-ia64-sigill-20051115.patch Patch170: %{name}-6.3-bt-past-zero-20051201.patch Patch176: %{name}-6.3-large-core-20051206.patch -Patch177: %{name}-6.3-gstack-without-path-20060414.patch Patch188: %{name}-6.5-bz203661-emit-relocs.patch Patch190: %{name}-6.5-dwarf-stack-overflow.patch Patch194: %{name}-6.5-bz185337-resolve-tls-without-debuginfo-v2.patch -Patch195: %{name}-6.5-tls-of-separate-debuginfo.patch Patch196: %{name}-6.5-sharedlibrary-path.patch Patch199: %{name}-6.5-bz190810-gdbserver-arch-advice.patch -Patch201: %{name}-6.5-gcore-i386-on-amd64.patch Patch211: %{name}-6.5-last-address-space-byte-test.patch Patch208: %{name}-6.5-BEA-testsuite.patch Patch209: %{name}-6.5-readline-long-line-crash.patch Patch213: %{name}-6.5-readline-long-line-crash-test.patch Patch214: %{name}-6.5-bz216711-clone-is-outermost.patch -Patch215: %{name}-6.5-bz218379-ppc-solib-trampoline-fix.patch Patch216: %{name}-6.5-bz218379-ppc-solib-trampoline-test.patch Patch217: %{name}-6.5-bz218379-solib-trampoline-lookup-lock-fix.patch Patch225: %{name}-6.5-bz109921-DW_AT_decl_file-test.patch Patch229: %{name}-6.3-bz140532-ppc-unwinding-test.patch Patch231: %{name}-6.3-bz202689-exec-from-pthread-test.patch -Patch232: %{name}-7.0-upstream.patch +Patch232: %{name}-upstream.patch Patch234: %{name}-6.6-bz230000-power6-disassembly-test.patch Patch235: %{name}-6.3-bz231832-obstack-2gb.patch -Patch240: %{name}-6.6-bz225783-prelink-path.patch Patch241: %{name}-6.6-bz225783-gdb-debuginfo-paths.patch Patch245: %{name}-6.6-bz229517-gcore-without-terminal.patch Patch247: %{name}-6.6-bz235197-fork-detach-info.patch -Patch249: %{name}-6.6-gcore32-test.patch Patch254: %{name}-6.6-testsuite-timeouts.patch Patch258: %{name}-6.6-bz237572-ppc-atomic-sequence-test.patch Patch261: %{name}-6.6-readline-system.patch @@ -104,6 +96,7 @@ Patch266: %{name}-6.6-bz247354-leader-exit-test.patch Patch271: %{name}-6.5-bz243845-stale-testing-zombie-test.patch Patch274: %{name}-6.6-buildid-locate.patch Patch353: %{name}-6.6-buildid-locate-rpm.patch +Patch415: %{name}-6.6-buildid-locate-core-as-arg.patch Patch282: %{name}-6.7-charsign-test.patch Patch284: %{name}-6.7-ppc-clobbered-registers-O2-test.patch Patch287: %{name}-6.7-testsuite-stable-results.patch @@ -116,16 +109,12 @@ Patch298: %{name}-6.6-threads-static-test.patch Patch304: %{name}-6.7-kernel-headers-compat.patch Patch309: %{name}-6.3-mapping-zero-inode-test.patch Patch311: %{name}-6.3-focus-cmd-prev-test.patch -Patch314: %{name}-6.3-watchpoint-cond-gone-test.patch Patch315: %{name}-6.8-bz442765-threaded-exec-test.patch Patch317: %{name}-6.8-sparc64-silence-memcpy-check.patch Patch318: %{name}-6.8-gcc35998-ada-memory-trash.patch Patch320: %{name}-6.5-section-num-fixup-test.patch -Patch322: %{name}-6.8-constant-watchpoints.patch Patch324: %{name}-6.8-glibc-headers-compat.patch Patch326: %{name}-6.8-tui-singlebinary.patch -Patch350: %{name}-6.8-inlining-addon.patch -Patch328: %{name}-6.8-inlining-by-name.patch Patch329: %{name}-6.8-bz254229-gcore-prpsinfo.patch Patch330: %{name}-6.8-bz436037-reg-no-longer-active.patch Patch331: %{name}-6.8-quit-never-aborts.patch @@ -134,27 +123,54 @@ Patch337: %{name}-6.8-attach-signalled-detach-stopped.patch Patch343: %{name}-6.8-watchpoint-conditionals-test.patch Patch348: %{name}-6.8-bz466901-backtrace-full-prelinked.patch Patch349: %{name}-archer.patch -Patch352: %{name}-6.8-bz457187-largefile.patch +Patch420: %{name}-archer-ada.patch Patch360: %{name}-6.8-bz457187-largefile-test.patch -Patch375: %{name}-readline-6.0.patch -Patch376: libstdc++-v3-python-common-prefix.patch Patch381: %{name}-simultaneous-step-resume-breakpoint-test.patch Patch382: %{name}-core-open-vdso-warning.patch -Patch383: %{name}-bz528668-symfile-sepcrc.patch -Patch384: %{name}-bz528668-symfile-cleanup.patch -Patch385: %{name}-bz528668-symfile-multi.patch -Patch387: %{name}-bz539590-gnu-ifunc.patch -Patch388: %{name}-bz538626-bp_location-accel-bp-cond.patch -Patch390: %{name}-readline-6.0-signal.patch Patch391: %{name}-x86_64-i386-syscall-restart.patch +Patch392: %{name}-bz533176-fortran-omp-step.patch +Patch397: %{name}-follow-child-stale-parent.patch +Patch403: %{name}-ccache-workaround.patch +Patch404: %{name}-fortran-common-reduce.patch +Patch405: %{name}-fortran-common.patch +Patch407: %{name}-lineno-makeup-test.patch +Patch408: %{name}-ppc-power7-test.patch +Patch412: %{name}-unused-revert.patch +Patch417: %{name}-bz541866-rwatch-before-run.patch +Patch451: %{name}-bz575292-delayed-physname.patch +Patch454: %{name}-bz539590-gnu-ifunc-fix-cond.patch +Patch459: %{name}-moribund-utrace-workaround.patch +Patch461: %{name}-bz594560-core-vs-process.patch +Patch470: %{name}-archer-next-over-throw-cxx-exec.patch +Patch475: %{name}-bz601887-dwarf4-rh-test.patch +Patch486: %{name}-bz562763-pretty-print-2d-vectors.patch +Patch489: %{name}-bz614659-prelink-dynbss.patch +Patch491: %{name}-gdb-add-index-script.patch +Patch493: %{name}-bz555076-gcore-small-height.patch +Patch496: %{name}-bz568248-oom-is-error.patch +Patch497: %{name}-false-gcc-warning.patch +Patch499: %{name}-bz631575-gdb-index-nobits.patch +Patch500: %{name}-bz631158-cxx-this-lookup.patch +Patch501: %{name}-gdbindex-ada-regression.patch +Patch502: %{name}-bz634660-gdbpy-load-on-attach.patch +Patch503: %{name}-pr12028-double-free.patch +Patch504: %{name}-bz623749-gcore-relro.patch +Patch506: %{name}-bz627432-loop-static-self-class.patch +Patch507: %{name}-bz592031-siginfo-lost-1of5.patch +Patch508: %{name}-bz592031-siginfo-lost-2of5.patch +Patch509: %{name}-bz592031-siginfo-lost-3of5.patch +Patch510: %{name}-bz592031-siginfo-lost-4of5.patch +Patch511: %{name}-bz592031-siginfo-lost-5of5.patch +Patch512: %{name}-gdbindex-bigendian.patch +Patch513: %{name}-bz637770-ifunc-watchpoint-delete.patch # PLD patches Patch1000: %{name}-readline.patch Patch1001: %{name}-info.patch Patch1002: %{name}-passflags.patch Patch1005: %{name}-pretty-print-by-default.patch -Patch1006: buildid-locate-rpm-pld.patch -Patch1007: %{name}-python.patch +#Patch1006: buildid-locate-rpm-pld.patch NEEDS UPDATE/REVIEW + URL: http://www.gnu.org/software/gdb/ BuildRequires: autoconf >= 2.53 BuildRequires: automake @@ -263,9 +279,6 @@ GDB w postaci biblioteki statycznej. %prep %setup -q -# libstdc++ pretty printers. -bzip2 -dc %{SOURCE4} | tar xf - - # Files have `# ' statements breaking VPATH / find-debuginfo.sh . rm -f gdb/ada-exp.c gdb/ada-lex.c gdb/c-exp.c gdb/cp-name-parser.c gdb/f-exp.c rm -f gdb/jv-exp.c gdb/m2-exp.c gdb/objc-exp.c gdb/p-exp.c @@ -274,10 +287,7 @@ rm -f gdb/jv-exp.c gdb/m2-exp.c gdb/objc-exp.c gdb/p-exp.c %patch2 -p1 %patch232 -p1 %patch349 -p1 -%patch383 -p1 -%patch384 -p1 -%patch385 -p1 -%patch124 -p1 +%patch420 -p1 %patch1 -p1 %patch3 -p1 %patch104 -p1 @@ -307,20 +317,16 @@ rm -f gdb/jv-exp.c gdb/m2-exp.c gdb/objc-exp.c gdb/p-exp.c %patch169 -p1 %patch170 -p1 %patch176 -p1 -%patch177 -p1 %patch188 -p1 %patch190 -p1 %patch194 -p1 -%patch195 -p1 %patch196 -p1 %patch199 -p1 -%patch201 -p1 %patch208 -p1 %patch209 -p1 %patch211 -p1 %patch213 -p1 %patch214 -p1 -%patch215 -p1 %patch216 -p1 %patch217 -p1 %patch225 -p1 @@ -328,11 +334,9 @@ rm -f gdb/jv-exp.c gdb/m2-exp.c gdb/objc-exp.c gdb/p-exp.c %patch231 -p1 %patch234 -p1 %patch235 -p1 -%patch240 -p1 %patch241 -p1 %patch245 -p1 %patch247 -p1 -%patch249 -p1 %patch254 -p1 %patch258 -p1 %patch260 -p1 @@ -355,16 +359,12 @@ rm -f gdb/jv-exp.c gdb/m2-exp.c gdb/objc-exp.c gdb/p-exp.c %patch304 -p1 %patch309 -p1 %patch311 -p1 -%patch314 -p1 %patch315 -p1 %patch317 -p1 %patch318 -p1 %patch320 -p1 -%patch322 -p1 %patch324 -p1 %patch326 -p1 -%patch350 -p1 -%patch328 -p1 %patch329 -p1 %patch330 -p1 %patch331 -p1 @@ -372,34 +372,62 @@ rm -f gdb/jv-exp.c gdb/m2-exp.c gdb/objc-exp.c gdb/p-exp.c %patch337 -p1 %patch343 -p1 %patch348 -p1 -%patch352 -p1 %patch360 -p1 -%patch375 -p1 -%patch376 -p1 %patch381 -p1 %patch382 -p1 -%patch387 -p1 -%patch388 -p1 -%patch389 -p1 -%patch390 -p1 %patch391 -p1 +%patch392 -p1 +%patch397 -p1 +%patch403 -p1 +%patch404 -p1 +%patch405 -p1 +%patch389 -p1 +%patch394 -p1 +%patch407 -p1 +%patch408 -p1 +%patch412 -p1 +%patch417 -p1 +%patch451 -p1 +%patch454 -p1 +%patch459 -p1 +%patch461 -p1 +%patch470 -p1 +%patch475 -p1 +%patch486 -p1 +%patch415 -p1 +%patch489 -p1 +%patch491 -p1 +%patch493 -p1 +%patch496 -p1 +%patch497 -p1 +%patch499 -p1 +%patch500 -p1 +%patch501 -p1 +%patch502 -p1 +%patch503 -p1 +%patch504 -p1 +%patch506 -p1 +%patch507 -p1 +%patch508 -p1 +%patch509 -p1 +%patch510 -p1 +%patch511 -p1 +%patch512 -p1 +%patch513 -p1 # PLD patches %patch1000 -p1 %patch1001 -p1 %patch1002 -p1 %patch1005 -p1 -%patch1006 -p1 -%patch1007 -p1 - -mv $(basename %{SOURCE4} .tar.bz2) libstdcxxpython +#patch1006 -p1 # Change the version that gets printed at GDB startup, so it is PLD Linux specific. cat > gdb/version.in << EOF PLD Linux (%{version}-%{release}) EOF -sed -i -e 's#_GCC_AUTOCONF_VERSION\], \[2\.64\]#_GCC_AUTOCONF_VERSION], [2.65]#g' config/override.m4 +sed -i -e 's#_GCC_AUTOCONF_VERSION\], \[2\.64\]#_GCC_AUTOCONF_VERSION], [2.68]#g' config/override.m4 %build for dir in $(find gdb -name 'configure.in' -o -name 'configure.ac'); do @@ -505,6 +533,7 @@ rm -rf $RPM_BUILD_ROOT %doc gdb/{ChangeLog,NEWS,PROBLEMS,README} %attr(755,root,root) %{_bindir}/gdb %attr(755,root,root) %{_bindir}/gdbtui +%attr(755,root,root) %{_bindir}/gdb-add-index %attr(755,root,root) %{_bindir}/gstack %dir %{_datadir}/gdb %{_datadir}/gdb/syscalls @@ -545,6 +574,7 @@ rm -rf $RPM_BUILD_ROOT %defattr(644,root,root,755) %attr(755,root,root) %{_bindir}/gdbserver %{_mandir}/man1/gdbserver.1* +%attr(755,root,root) %{_libdir}/libinproctrace.so %files lib %defattr(644,root,root,755) diff --git a/libstdc++-v3-python-common-prefix.patch b/libstdc++-v3-python-common-prefix.patch deleted file mode 100644 index 7409c9a..0000000 --- a/libstdc++-v3-python-common-prefix.patch +++ /dev/null @@ -1,18 +0,0 @@ -On x86_64 host with: -pythondir: /usr/lib/python2.6/site-packages/gdb -libdir: /usr/lib64 - -prefix got set to "/usr/lib" but the code expects a trailing "/" (missing then -one "../" path component). - ---- ./libstdc++-v3-python-r151798/hook.in-orig 2009-06-18 21:12:37.000000000 +0200 -+++ ./libstdc++-v3-python-r151798/hook.in 2009-09-17 23:37:35.000000000 +0200 -@@ -40,7 +40,7 @@ if gdb.current_objfile () is not None: - # In some bizarre configuration we might have found a match in the - # middle of a directory name. - if prefix[-1] != '/': -- prefix = os.path.dirname (prefix) -+ prefix = os.path.dirname (prefix) + '/' - - # Strip off the prefix. - pythondir = pythondir[len (prefix):] -- 2.44.0