diff --git a/.cvsignore b/.cvsignore index a5c3915..1caffd4 100644 --- a/.cvsignore +++ b/.cvsignore @@ -1,2 +1,2 @@ -gdb-7.0.50.20100118.tar.bz2 +gdb-7.0.50.20100121.tar.bz2 libstdc++-v3-python-r155978.tar.bz2 diff --git a/gdb-6.3-readnever-20050907.patch b/gdb-6.3-readnever-20050907.patch index 433944d..bd89dd5 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-7.0.50.20100115/gdb/doc/gdb.texinfo +Index: gdb-7.0.50.20100121/gdb/doc/gdb.texinfo =================================================================== ---- gdb-7.0.50.20100115.orig/gdb/doc/gdb.texinfo 2010-01-15 03:16:43.000000000 +0100 -+++ gdb-7.0.50.20100115/gdb/doc/gdb.texinfo 2010-01-15 03:20:04.000000000 +0100 -@@ -995,6 +995,12 @@ Read each symbol file's entire symbol ta +--- gdb-7.0.50.20100121.orig/gdb/doc/gdb.texinfo 2010-01-21 15:11:09.000000000 +0100 ++++ gdb-7.0.50.20100121/gdb/doc/gdb.texinfo 2010-01-21 15:13:02.000000000 +0100 +@@ -997,6 +997,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,10 +28,10 @@ Index: gdb-7.0.50.20100115/gdb/doc/gdb.texinfo @end table @node Mode Options -Index: gdb-7.0.50.20100115/gdb/main.c +Index: gdb-7.0.50.20100121/gdb/main.c =================================================================== ---- gdb-7.0.50.20100115.orig/gdb/main.c 2010-01-15 03:18:23.000000000 +0100 -+++ gdb-7.0.50.20100115/gdb/main.c 2010-01-15 03:20:04.000000000 +0100 +--- gdb-7.0.50.20100121.orig/gdb/main.c 2010-01-21 15:11:18.000000000 +0100 ++++ gdb-7.0.50.20100121/gdb/main.c 2010-01-21 15:13:02.000000000 +0100 @@ -382,6 +382,7 @@ captured_main (void *data) {"xdb", no_argument, &xdb_commands, 1}, {"dbx", no_argument, &dbx_commands, 1}, @@ -40,7 +40,7 @@ Index: gdb-7.0.50.20100115/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\ +@@ -1033,6 +1034,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,10 +48,10 @@ Index: gdb-7.0.50.20100115/gdb/main.c "), stream); fputs_unfiltered (_("\ --se=FILE Use FILE as symbol file and executable file.\n\ -Index: gdb-7.0.50.20100115/gdb/symfile.c +Index: gdb-7.0.50.20100121/gdb/symfile.c =================================================================== ---- gdb-7.0.50.20100115.orig/gdb/symfile.c 2010-01-15 03:16:43.000000000 +0100 -+++ gdb-7.0.50.20100115/gdb/symfile.c 2010-01-15 03:20:04.000000000 +0100 +--- gdb-7.0.50.20100121.orig/gdb/symfile.c 2010-01-21 15:11:09.000000000 +0100 ++++ gdb-7.0.50.20100121/gdb/symfile.c 2010-01-21 15:13:02.000000000 +0100 @@ -79,6 +79,7 @@ static void clear_symtab_users_cleanup ( /* Global variables owned by this file */ @@ -60,19 +60,19 @@ Index: gdb-7.0.50.20100115/gdb/symfile.c /* External variables and functions referenced. */ -Index: gdb-7.0.50.20100115/gdb/dwarf2read.c +Index: gdb-7.0.50.20100121/gdb/dwarf2read.c =================================================================== ---- gdb-7.0.50.20100115.orig/gdb/dwarf2read.c 2010-01-15 03:16:43.000000000 +0100 -+++ gdb-7.0.50.20100115/gdb/dwarf2read.c 2010-01-15 03:20:18.000000000 +0100 -@@ -50,6 +50,7 @@ - #include "addrmap.h" - #include "block.h" - #include "f-lang.h" +--- gdb-7.0.50.20100121.orig/gdb/dwarf2read.c 2010-01-21 15:11:09.000000000 +0100 ++++ gdb-7.0.50.20100121/gdb/dwarf2read.c 2010-01-21 15:13:15.000000000 +0100 +@@ -53,6 +53,7 @@ + #include "typeprint.h" + #include "jv-lang.h" + #include "vec.h" +#include "top.h" #include #include "gdb_string.h" -@@ -1226,7 +1227,8 @@ dwarf2_has_info (struct objfile *objfile +@@ -1237,7 +1238,8 @@ dwarf2_has_info (struct objfile *objfile bfd_map_over_sections (objfile->obfd, dwarf2_locate_sections, NULL); } @@ -82,10 +82,10 @@ Index: gdb-7.0.50.20100115/gdb/dwarf2read.c && dwarf2_per_objfile->abbrev.asection != NULL); } -Index: gdb-7.0.50.20100115/gdb/top.h +Index: gdb-7.0.50.20100121/gdb/top.h =================================================================== ---- gdb-7.0.50.20100115.orig/gdb/top.h 2010-01-01 08:31:42.000000000 +0100 -+++ gdb-7.0.50.20100115/gdb/top.h 2010-01-15 03:20:04.000000000 +0100 +--- gdb-7.0.50.20100121.orig/gdb/top.h 2010-01-01 08:31:42.000000000 +0100 ++++ gdb-7.0.50.20100121/gdb/top.h 2010-01-21 15:13:02.000000000 +0100 @@ -63,6 +63,7 @@ extern void set_prompt (char *); /* From random places. */ diff --git a/gdb-6.3-security-errata-20050610.patch b/gdb-6.3-security-errata-20050610.patch index 56d75b9..5578570 100644 --- a/gdb-6.3-security-errata-20050610.patch +++ b/gdb-6.3-security-errata-20050610.patch @@ -19,11 +19,11 @@ Proposed upstream but never committed upstream. (source_command): Update documentation. Check permissions if FROM_TTY is -1. -Index: gdb-7.0.50.20100115/gdb/cli/cli-cmds.c +Index: gdb-7.0.50.20100121/gdb/cli/cli-cmds.c =================================================================== ---- gdb-7.0.50.20100115.orig/gdb/cli/cli-cmds.c 2010-01-15 03:16:43.000000000 +0100 -+++ gdb-7.0.50.20100115/gdb/cli/cli-cmds.c 2010-01-15 03:19:13.000000000 +0100 -@@ -37,6 +37,7 @@ +--- gdb-7.0.50.20100121.orig/gdb/cli/cli-cmds.c 2010-01-18 07:25:22.000000000 +0100 ++++ gdb-7.0.50.20100121/gdb/cli/cli-cmds.c 2010-01-21 15:12:28.000000000 +0100 +@@ -38,6 +38,7 @@ #include "objfiles.h" #include "source.h" #include "disasm.h" @@ -31,18 +31,9 @@ Index: gdb-7.0.50.20100115/gdb/cli/cli-cmds.c extern void disconnect_or_stop_tracing (int from_tty); #include "ui-out.h" -@@ -475,7 +476,7 @@ source_script (char *file, int from_tty) - - if (fd == -1) - { -- if (from_tty) -+ if (from_tty > 0) - perror_with_name (file); - else - { -@@ -484,6 +485,29 @@ source_script (char *file, int from_tty) - } - } +@@ -488,6 +489,29 @@ find_and_open_script (int from_tty, char + file, O_RDONLY, &full_pathname); + make_cleanup (xfree, full_pathname); +#ifdef HAVE_GETUID + if (from_tty == -1) @@ -62,15 +53,24 @@ Index: gdb-7.0.50.20100115/gdb/cli/cli-cmds.c + warning (_("not using untrusted file \"%s\""), file); + close (fd); + do_cleanups (old_cleanups); -+ return; ++ return 0; + } + } +#endif + - is_python = source_python; - if (strlen (file) > 3 && !strcmp (&file[strlen (file) - 3], ".py")) - is_python = 1; -@@ -495,6 +519,7 @@ source_script (char *file, int from_tty) + /* Use the full path name, if it is found. */ + if (full_pathname != NULL && fd != -1) + { +@@ -496,7 +520,7 @@ find_and_open_script (int from_tty, char + + if (fd == -1) + { +- if (from_tty) ++ if (from_tty > 0) + perror_with_name (file); + else + { +@@ -554,6 +578,7 @@ source_script (char *file, int from_tty) else script_from_file (stream, file); @@ -78,10 +78,10 @@ Index: gdb-7.0.50.20100115/gdb/cli/cli-cmds.c do_cleanups (old_cleanups); } -Index: gdb-7.0.50.20100115/gdb/testsuite/gdb.base/gdbinit.exp +Index: gdb-7.0.50.20100121/gdb/testsuite/gdb.base/gdbinit.exp =================================================================== --- /dev/null 1970-01-01 00:00:00.000000000 +0000 -+++ gdb-7.0.50.20100115/gdb/testsuite/gdb.base/gdbinit.exp 2010-01-15 03:18:23.000000000 +0100 ++++ gdb-7.0.50.20100121/gdb/testsuite/gdb.base/gdbinit.exp 2010-01-21 15:11:18.000000000 +0100 @@ -0,0 +1,98 @@ +# Copyright 2005 +# Free Software Foundation, Inc. @@ -181,17 +181,17 @@ Index: gdb-7.0.50.20100115/gdb/testsuite/gdb.base/gdbinit.exp +} + +remote_exec build "rm .gdbinit" -Index: gdb-7.0.50.20100115/gdb/testsuite/gdb.base/gdbinit.sample +Index: gdb-7.0.50.20100121/gdb/testsuite/gdb.base/gdbinit.sample =================================================================== --- /dev/null 1970-01-01 00:00:00.000000000 +0000 -+++ gdb-7.0.50.20100115/gdb/testsuite/gdb.base/gdbinit.sample 2010-01-15 03:18:23.000000000 +0100 ++++ gdb-7.0.50.20100121/gdb/testsuite/gdb.base/gdbinit.sample 2010-01-21 15:11:18.000000000 +0100 @@ -0,0 +1 @@ +echo "\nin gdbinit" -Index: gdb-7.0.50.20100115/gdb/main.c +Index: gdb-7.0.50.20100121/gdb/main.c =================================================================== ---- gdb-7.0.50.20100115.orig/gdb/main.c 2010-01-15 03:16:43.000000000 +0100 -+++ gdb-7.0.50.20100115/gdb/main.c 2010-01-15 03:18:23.000000000 +0100 -@@ -815,7 +815,7 @@ Excess command line arguments ignored. ( +--- gdb-7.0.50.20100121.orig/gdb/main.c 2010-01-21 15:11:09.000000000 +0100 ++++ gdb-7.0.50.20100121/gdb/main.c 2010-01-21 15:11:18.000000000 +0100 +@@ -818,7 +818,7 @@ Excess command line arguments ignored. ( debugging or what directory you are in. */ if (home_gdbinit && !inhibit_gdbinit) @@ -200,7 +200,7 @@ Index: gdb-7.0.50.20100115/gdb/main.c /* Now perform all the actions indicated by the arguments. */ if (cdarg != NULL) -@@ -884,7 +884,7 @@ Can't attach to process and specify a co +@@ -887,7 +887,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) diff --git a/gdb-6.7-testsuite-stable-results.patch b/gdb-6.7-testsuite-stable-results.patch index 81e0c02..75f68b3 100644 --- a/gdb-6.7-testsuite-stable-results.patch +++ b/gdb-6.7-testsuite-stable-results.patch @@ -102,154 +102,3 @@ frames-invalid can happen asynchronously. set timeout $oldtimeout return 0 - - - -http://sourceware.org/ml/gdb-patches/2009-12/msg00234.html -Subject: [patch] testsuite: Fix a race by me - watchthreads-reorder.exp - -Hi, - -there is a bug explainable by man pthread_cond_signal: - The [...] pthread_cond_signal() functions shall have no effect if - there are no threads currently blocked on cond. - -meaning a race for the testcase. - +FAIL: gdb.threads/watchthreads-reorder.exp: reorder1: continue a (timeout) - -One can reproduce the race on CVS HEAD by: -# --- a/gdb/testsuite/gdb.threads/watchthreads-reorder.c -# +++ b/gdb/testsuite/gdb.threads/watchthreads-reorder.c -# @@ -89,6 +89,7 @@ thread1_func (void *unused) -# int i; -# volatile int rwatch_store; -# -# +sleep(1); -# thread1_tid = gettid (); -# i = pthread_cond_signal (&thread1_tid_cond); -# assert (i == 0); -# @@ -317,6 +318,7 @@ main (int argc, char **argv) -# -# if (thread1_tid == 0) -# { -# +sleep(2); -# i = pthread_cond_wait (&thread1_tid_cond, &thread1_tid_mutex); -# assert (i == 0); -# - -Fixed; gdbstop_mutex got removed as it became redundant there. - -Going to check it in as obvious in several days (code is by me + it is just -a testcase). - - -Sorry, -Jan - - -gdb/testsuite/ -2009-12-17 Jan Kratochvil - - * gdb.threads/watchthreads-reorder.c (gdbstop_mutex): Remove. - (thread1_func): Protect thread1_tid_cond by thread1_tid_mutex. Remove - gdbstop_mutex handling. - (thread2_func): Protect thread2_tid_cond by thread2_tid_mutex. Remove - gdbstop_mutex handling. - (main): Move thread1_tid_mutex and thread2_tid_mutex locks before - pthread_create. Remove gdbstop_mutex handling. New comment. Remove - pthread_cond_wait conditionalizations. - ---- a/gdb/testsuite/gdb.threads/watchthreads-reorder.c -+++ b/gdb/testsuite/gdb.threads/watchthreads-reorder.c -@@ -34,8 +34,6 @@ - otherwise. */ - #define TIMEOUT (gettid () == getpid() ? 10 : 15) - --static pthread_mutex_t gdbstop_mutex = PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP; -- - 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; -@@ -90,12 +88,11 @@ thread1_func (void *unused) - volatile int rwatch_store; - - thread1_tid = gettid (); -+ -+ timed_mutex_lock (&thread1_tid_mutex); - i = pthread_cond_signal (&thread1_tid_cond); - assert (i == 0); -- -- /* Be sure GDB is already stopped before continuing. */ -- timed_mutex_lock (&gdbstop_mutex); -- i = pthread_mutex_unlock (&gdbstop_mutex); -+ i = pthread_mutex_unlock (&thread1_tid_mutex); - assert (i == 0); - - rwatch_store = thread1_rwatch; -@@ -115,12 +112,11 @@ thread2_func (void *unused) - volatile int rwatch_store; - - thread2_tid = gettid (); -+ -+ timed_mutex_lock (&thread2_tid_mutex); - i = pthread_cond_signal (&thread2_tid_cond); - assert (i == 0); -- -- /* Be sure GDB is already stopped before continuing. */ -- timed_mutex_lock (&gdbstop_mutex); -- i = pthread_mutex_unlock (&gdbstop_mutex); -+ i = pthread_mutex_unlock (&thread2_tid_mutex); - assert (i == 0); - - rwatch_store = thread2_rwatch; -@@ -267,7 +263,8 @@ main (int argc, char **argv) - - setbuf (stdout, NULL); - -- timed_mutex_lock (&gdbstop_mutex); -+ timed_mutex_lock (&thread1_tid_mutex); -+ timed_mutex_lock (&thread2_tid_mutex); - - timed_mutex_lock (&terminate_mutex); - -@@ -306,30 +303,21 @@ main (int argc, char **argv) - state_wait (tracer, "T (stopped)"); - } - -- timed_mutex_lock (&thread1_tid_mutex); -- timed_mutex_lock (&thread2_tid_mutex); -- -- /* Let the threads start. */ -- i = pthread_mutex_unlock (&gdbstop_mutex); -- assert (i == 0); -+ /* Threads are now waiting at timed_mutex_lock (thread1_tid_mutex) and so -+ they could not trigger the watchpoints before GDB gets unstopped later. -+ Threads get resumed at pthread_cond_wait below. */ - - 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); -+ i = pthread_cond_wait (&thread1_tid_cond, &thread1_tid_mutex); -+ assert (i == 0); - -- assert (thread1_tid > 0); -- } -+ assert (thread1_tid > 0); - -- if (thread2_tid == 0) -- { -- i = pthread_cond_wait (&thread2_tid_cond, &thread2_tid_mutex); -- assert (i == 0); -+ i = pthread_cond_wait (&thread2_tid_cond, &thread2_tid_mutex); -+ assert (i == 0); - -- assert (thread2_tid > 0); -- } -+ assert (thread2_tid > 0); - - printf ("Thread 1 TID = %lu, thread 2 TID = %lu, PID = %lu.\n", - (unsigned long) thread1_tid, (unsigned long) thread2_tid, - diff --git a/gdb-6.8-inlining-addon.patch b/gdb-6.8-inlining-addon.patch index b41b807..7b84ef9 100644 --- a/gdb-6.8-inlining-addon.patch +++ b/gdb-6.8-inlining-addon.patch @@ -5,10 +5,10 @@ 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-7.0.50.20100115/gdb/testsuite/gdb.opt/inline-bt.c +Index: gdb-7.0.50.20100121/gdb/testsuite/gdb.opt/inline-bt.c =================================================================== ---- gdb-7.0.50.20100115.orig/gdb/testsuite/gdb.opt/inline-bt.c 2010-01-01 08:32:04.000000000 +0100 -+++ gdb-7.0.50.20100115/gdb/testsuite/gdb.opt/inline-bt.c 2010-01-15 11:50:59.000000000 +0100 +--- gdb-7.0.50.20100121.orig/gdb/testsuite/gdb.opt/inline-bt.c 2010-01-01 08:32:04.000000000 +0100 ++++ gdb-7.0.50.20100121/gdb/testsuite/gdb.opt/inline-bt.c 2010-01-21 15:14:47.000000000 +0100 @@ -13,10 +13,16 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ @@ -28,10 +28,10 @@ Index: gdb-7.0.50.20100115/gdb/testsuite/gdb.opt/inline-bt.c inline int func1(void) { -Index: gdb-7.0.50.20100115/gdb/testsuite/gdb.opt/inline-cmds.c +Index: gdb-7.0.50.20100121/gdb/testsuite/gdb.opt/inline-cmds.c =================================================================== ---- gdb-7.0.50.20100115.orig/gdb/testsuite/gdb.opt/inline-cmds.c 2010-01-01 08:32:04.000000000 +0100 -+++ gdb-7.0.50.20100115/gdb/testsuite/gdb.opt/inline-cmds.c 2010-01-15 11:50:59.000000000 +0100 +--- gdb-7.0.50.20100121.orig/gdb/testsuite/gdb.opt/inline-cmds.c 2010-01-01 08:32:04.000000000 +0100 ++++ gdb-7.0.50.20100121/gdb/testsuite/gdb.opt/inline-cmds.c 2010-01-21 15:14:47.000000000 +0100 @@ -13,13 +13,19 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ @@ -54,10 +54,10 @@ Index: gdb-7.0.50.20100115/gdb/testsuite/gdb.opt/inline-cmds.c inline int func1(void) { bar (); -Index: gdb-7.0.50.20100115/gdb/testsuite/gdb.opt/inline-cmds.exp +Index: gdb-7.0.50.20100121/gdb/testsuite/gdb.opt/inline-cmds.exp =================================================================== ---- gdb-7.0.50.20100115.orig/gdb/testsuite/gdb.opt/inline-cmds.exp 2010-01-01 08:32:04.000000000 +0100 -+++ gdb-7.0.50.20100115/gdb/testsuite/gdb.opt/inline-cmds.exp 2010-01-15 11:50:59.000000000 +0100 +--- gdb-7.0.50.20100121.orig/gdb/testsuite/gdb.opt/inline-cmds.exp 2010-01-01 08:32:04.000000000 +0100 ++++ gdb-7.0.50.20100121/gdb/testsuite/gdb.opt/inline-cmds.exp 2010-01-21 15:14:47.000000000 +0100 @@ -230,7 +230,7 @@ set line3 [gdb_get_line_number "set brea gdb_breakpoint $line3 gdb_continue_to_breakpoint "consecutive func1" @@ -110,10 +110,10 @@ Index: gdb-7.0.50.20100115/gdb/testsuite/gdb.opt/inline-cmds.exp +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-7.0.50.20100115/gdb/testsuite/gdb.opt/inline-locals.c +Index: gdb-7.0.50.20100121/gdb/testsuite/gdb.opt/inline-locals.c =================================================================== ---- gdb-7.0.50.20100115.orig/gdb/testsuite/gdb.opt/inline-locals.c 2010-01-01 08:32:04.000000000 +0100 -+++ gdb-7.0.50.20100115/gdb/testsuite/gdb.opt/inline-locals.c 2010-01-15 11:50:59.000000000 +0100 +--- gdb-7.0.50.20100121.orig/gdb/testsuite/gdb.opt/inline-locals.c 2010-01-01 08:32:04.000000000 +0100 ++++ gdb-7.0.50.20100121/gdb/testsuite/gdb.opt/inline-locals.c 2010-01-21 15:14:47.000000000 +0100 @@ -13,11 +13,16 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ @@ -133,10 +133,10 @@ Index: gdb-7.0.50.20100115/gdb/testsuite/gdb.opt/inline-locals.c inline int func1(int arg1) { -Index: gdb-7.0.50.20100115/gdb/testsuite/gdb.opt/inline-locals.exp +Index: gdb-7.0.50.20100121/gdb/testsuite/gdb.opt/inline-locals.exp =================================================================== ---- gdb-7.0.50.20100115.orig/gdb/testsuite/gdb.opt/inline-locals.exp 2010-01-01 08:32:04.000000000 +0100 -+++ gdb-7.0.50.20100115/gdb/testsuite/gdb.opt/inline-locals.exp 2010-01-15 11:50:59.000000000 +0100 +--- gdb-7.0.50.20100121.orig/gdb/testsuite/gdb.opt/inline-locals.exp 2010-01-01 08:32:04.000000000 +0100 ++++ gdb-7.0.50.20100121/gdb/testsuite/gdb.opt/inline-locals.exp 2010-01-21 15:14:47.000000000 +0100 @@ -77,6 +77,9 @@ if { ! $no_frames } { # Make sure that locals on the stack are found. This is an array to @@ -155,10 +155,10 @@ Index: gdb-7.0.50.20100115/gdb/testsuite/gdb.opt/inline-locals.exp + setup_kfail *-*-* "gcc/debug.optimization" +} gdb_test "print array\[0\]" "\\\$$decimal = 184" "print local (3)" -Index: gdb-7.0.50.20100115/gdb/frame.c +Index: gdb-7.0.50.20100121/gdb/frame.c =================================================================== ---- gdb-7.0.50.20100115.orig/gdb/frame.c 2010-01-15 03:22:14.000000000 +0100 -+++ gdb-7.0.50.20100115/gdb/frame.c 2010-01-15 11:50:59.000000000 +0100 +--- gdb-7.0.50.20100121.orig/gdb/frame.c 2010-01-21 15:13:26.000000000 +0100 ++++ gdb-7.0.50.20100121/gdb/frame.c 2010-01-21 15:14:47.000000000 +0100 @@ -316,7 +316,7 @@ fprint_frame (struct ui_file *file, stru static struct frame_info * skip_inlined_frames (struct frame_info *frame) @@ -195,10 +195,10 @@ Index: gdb-7.0.50.20100115/gdb/frame.c { sal->symtab = SYMBOL_SYMTAB (sym); sal->line = SYMBOL_LINE (sym); -Index: gdb-7.0.50.20100115/gdb/breakpoint.c +Index: gdb-7.0.50.20100121/gdb/breakpoint.c =================================================================== ---- gdb-7.0.50.20100115.orig/gdb/breakpoint.c 2010-01-15 11:49:49.000000000 +0100 -+++ gdb-7.0.50.20100115/gdb/breakpoint.c 2010-01-15 11:52:20.000000000 +0100 +--- gdb-7.0.50.20100121.orig/gdb/breakpoint.c 2010-01-21 15:14:41.000000000 +0100 ++++ gdb-7.0.50.20100121/gdb/breakpoint.c 2010-01-21 15:14:47.000000000 +0100 @@ -62,6 +62,7 @@ #include "jit.h" #include "xml-syscall.h" @@ -207,7 +207,7 @@ Index: gdb-7.0.50.20100115/gdb/breakpoint.c /* readline include files */ #include "readline/readline.h" -@@ -3560,10 +3561,24 @@ bpstat_check_breakpoint_conditions (bpst +@@ -3558,10 +3559,24 @@ bpstat_check_breakpoint_conditions (bpst const struct bp_location *bl = bs->breakpoint_at; struct breakpoint *b = bl->owner; @@ -236,7 +236,7 @@ Index: gdb-7.0.50.20100115/gdb/breakpoint.c { int value_is_zero = 0; -@@ -3731,6 +3746,12 @@ bpstat_stop_status (struct address_space +@@ -3729,6 +3744,12 @@ bpstat_stop_status (struct address_space bs->print = 0; } bs->commands = copy_command_lines (bs->commands); @@ -249,7 +249,7 @@ Index: gdb-7.0.50.20100115/gdb/breakpoint.c } /* Print nothing for this entry if we dont stop or dont print. */ -@@ -6039,9 +6060,9 @@ set_momentary_breakpoint (struct gdbarch +@@ -6043,9 +6064,9 @@ set_momentary_breakpoint (struct gdbarch { struct breakpoint *b; @@ -262,10 +262,10 @@ Index: gdb-7.0.50.20100115/gdb/breakpoint.c b = set_raw_breakpoint (gdbarch, sal, type); b->enable_state = bp_enabled; -Index: gdb-7.0.50.20100115/gdb/inline-frame.c +Index: gdb-7.0.50.20100121/gdb/inline-frame.c =================================================================== ---- gdb-7.0.50.20100115.orig/gdb/inline-frame.c 2010-01-01 08:31:36.000000000 +0100 -+++ gdb-7.0.50.20100115/gdb/inline-frame.c 2010-01-15 11:50:59.000000000 +0100 +--- gdb-7.0.50.20100121.orig/gdb/inline-frame.c 2010-01-01 08:31:36.000000000 +0100 ++++ gdb-7.0.50.20100121/gdb/inline-frame.c 2010-01-21 15:14:47.000000000 +0100 @@ -213,6 +213,12 @@ inline_frame_sniffer (const struct frame if (frame_block == NULL) return 0; @@ -342,10 +342,10 @@ Index: gdb-7.0.50.20100115/gdb/inline-frame.c /* Return the number of hidden functions inlined into the current frame. */ -Index: gdb-7.0.50.20100115/gdb/testsuite/gdb.opt/inline-markers.c +Index: gdb-7.0.50.20100121/gdb/testsuite/gdb.opt/inline-markers.c =================================================================== ---- gdb-7.0.50.20100115.orig/gdb/testsuite/gdb.opt/inline-markers.c 2010-01-01 08:32:04.000000000 +0100 -+++ gdb-7.0.50.20100115/gdb/testsuite/gdb.opt/inline-markers.c 2010-01-15 11:50:59.000000000 +0100 +--- gdb-7.0.50.20100121.orig/gdb/testsuite/gdb.opt/inline-markers.c 2010-01-01 08:32:04.000000000 +0100 ++++ gdb-7.0.50.20100121/gdb/testsuite/gdb.opt/inline-markers.c 2010-01-21 15:14:47.000000000 +0100 @@ -15,11 +15,6 @@ extern int x, y; @@ -358,10 +358,10 @@ Index: gdb-7.0.50.20100115/gdb/testsuite/gdb.opt/inline-markers.c void marker(void) { x += y; /* set breakpoint 2 here */ -Index: gdb-7.0.50.20100115/gdb/gdbthread.h +Index: gdb-7.0.50.20100121/gdb/gdbthread.h =================================================================== ---- gdb-7.0.50.20100115.orig/gdb/gdbthread.h 2010-01-15 03:22:13.000000000 +0100 -+++ gdb-7.0.50.20100115/gdb/gdbthread.h 2010-01-15 11:51:19.000000000 +0100 +--- gdb-7.0.50.20100121.orig/gdb/gdbthread.h 2010-01-21 15:11:09.000000000 +0100 ++++ gdb-7.0.50.20100121/gdb/gdbthread.h 2010-01-21 15:14:47.000000000 +0100 @@ -195,6 +195,12 @@ struct thread_info /* Function that is called to free PRIVATE. If this is NULL, then xfree will be called on PRIVATE. */ @@ -375,11 +375,11 @@ Index: gdb-7.0.50.20100115/gdb/gdbthread.h }; /* Create an empty thread list, or empty the existing one. */ -Index: gdb-7.0.50.20100115/gdb/infcmd.c +Index: gdb-7.0.50.20100121/gdb/infcmd.c =================================================================== ---- gdb-7.0.50.20100115.orig/gdb/infcmd.c 2010-01-15 03:22:13.000000000 +0100 -+++ gdb-7.0.50.20100115/gdb/infcmd.c 2010-01-15 11:51:53.000000000 +0100 -@@ -1438,11 +1438,11 @@ finish_command_continuation (void *arg) +--- gdb-7.0.50.20100121.orig/gdb/infcmd.c 2010-01-21 15:11:09.000000000 +0100 ++++ gdb-7.0.50.20100121/gdb/infcmd.c 2010-01-21 15:14:47.000000000 +0100 +@@ -1439,11 +1439,11 @@ finish_command_continuation (void *arg) struct type *value_type; value_type = TYPE_TARGET_TYPE (SYMBOL_TYPE (a->function)); @@ -393,7 +393,7 @@ Index: gdb-7.0.50.20100115/gdb/infcmd.c print_return_value (SYMBOL_TYPE (a->function), value_type); } -@@ -1550,6 +1550,16 @@ finish_forward (struct symbol *function, +@@ -1551,6 +1551,16 @@ finish_forward (struct symbol *function, tp->initiating_frame = get_frame_id (frame); make_cleanup (delete_longjmp_breakpoint_cleanup, &thread); @@ -410,7 +410,7 @@ Index: gdb-7.0.50.20100115/gdb/infcmd.c tp->proceed_to_finish = 1; /* We want stop_registers, please... */ cargs = xmalloc (sizeof (*cargs)); -@@ -1570,7 +1580,9 @@ finish_forward (struct symbol *function, +@@ -1571,7 +1581,9 @@ finish_forward (struct symbol *function, static void finish_command (char *arg, int from_tty) { @@ -421,7 +421,7 @@ Index: gdb-7.0.50.20100115/gdb/infcmd.c struct symbol *function; int async_exec = 0; -@@ -1601,45 +1613,63 @@ finish_command (char *arg, int from_tty) +@@ -1602,45 +1614,63 @@ finish_command (char *arg, int from_tty) if (!target_has_execution) error (_("The program is not running.")); @@ -502,7 +502,7 @@ Index: gdb-7.0.50.20100115/gdb/infcmd.c /* Print info on the selected frame, including level number but not source. */ -@@ -1653,10 +1683,14 @@ finish_command (char *arg, int from_tty) +@@ -1654,10 +1684,14 @@ finish_command (char *arg, int from_tty) print_stack_frame (get_selected_frame (NULL), 1, LOCATION); } @@ -518,11 +518,11 @@ Index: gdb-7.0.50.20100115/gdb/infcmd.c } -Index: gdb-7.0.50.20100115/gdb/target.c +Index: gdb-7.0.50.20100121/gdb/target.c =================================================================== ---- gdb-7.0.50.20100115.orig/gdb/target.c 2010-01-15 03:22:31.000000000 +0100 -+++ gdb-7.0.50.20100115/gdb/target.c 2010-01-15 11:50:59.000000000 +0100 -@@ -2241,6 +2241,7 @@ target_resume (ptid_t ptid, int step, en +--- gdb-7.0.50.20100121.orig/gdb/target.c 2010-01-21 15:13:26.000000000 +0100 ++++ gdb-7.0.50.20100121/gdb/target.c 2010-01-21 15:14:47.000000000 +0100 +@@ -2216,6 +2216,7 @@ target_resume (ptid_t ptid, int step, en { struct target_ops *t; @@ -530,10 +530,10 @@ Index: gdb-7.0.50.20100115/gdb/target.c target_dcache_invalidate (); for (t = current_target.beneath; t != NULL; t = t->beneath) -Index: gdb-7.0.50.20100115/gdb/inline-frame.h +Index: gdb-7.0.50.20100121/gdb/inline-frame.h =================================================================== ---- gdb-7.0.50.20100115.orig/gdb/inline-frame.h 2010-01-01 08:31:36.000000000 +0100 -+++ gdb-7.0.50.20100115/gdb/inline-frame.h 2010-01-15 11:50:59.000000000 +0100 +--- gdb-7.0.50.20100121.orig/gdb/inline-frame.h 2010-01-01 08:31:36.000000000 +0100 ++++ gdb-7.0.50.20100121/gdb/inline-frame.h 2010-01-21 15:14:47.000000000 +0100 @@ -43,6 +43,10 @@ void clear_inline_frame_state (ptid_t pt void step_into_inline_frame (ptid_t ptid); @@ -545,19 +545,19 @@ Index: gdb-7.0.50.20100115/gdb/inline-frame.h /* Return the number of hidden functions inlined into the current frame. */ -Index: gdb-7.0.50.20100115/gdb/dwarf2read.c +Index: gdb-7.0.50.20100121/gdb/dwarf2read.c =================================================================== ---- gdb-7.0.50.20100115.orig/gdb/dwarf2read.c 2010-01-15 11:46:29.000000000 +0100 -+++ gdb-7.0.50.20100115/gdb/dwarf2read.c 2010-01-15 11:52:59.000000000 +0100 -@@ -4078,6 +4078,7 @@ read_func_scope (struct die_info *die, s - CORE_ADDR baseaddr; +--- gdb-7.0.50.20100121.orig/gdb/dwarf2read.c 2010-01-21 15:14:41.000000000 +0100 ++++ gdb-7.0.50.20100121/gdb/dwarf2read.c 2010-01-21 15:15:09.000000000 +0100 +@@ -4137,6 +4137,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) { -@@ -4109,7 +4110,10 @@ read_func_scope (struct die_info *die, s +@@ -4178,7 +4179,10 @@ read_func_scope (struct die_info *die, s add_to_cu_func_list (name, lowpc, highpc, cu); new = push_context (0, lowpc); diff --git a/gdb-archer.patch b/gdb-archer.patch index 67e6510..2e89450 100644 --- a/gdb-archer.patch +++ b/gdb-archer.patch @@ -2,7 +2,7 @@ http://sourceware.org/gdb/wiki/ProjectArcher http://sourceware.org/gdb/wiki/ArcherBranchManagement GIT snapshot: -commit 81810a20b2d2c3bf18e151de3cddfc96445b3c46 +commit ccde1530479cc966374351038057b9dda90aa251 branch `archer' - the merge of branches: archer-tromey-delayed-symfile @@ -11,7 +11,7 @@ archer-pmuldoon-next-over-throw archer-jankratochvil-fortran-module archer-jankratochvil-watchpoint archer-jankratochvil-vla -TODO:archer-keiths-expr-cumulative +archer-keiths-expr-cumulative diff --git a/gdb/Makefile.in b/gdb/Makefile.in @@ -188,38 +188,27 @@ index ff8b86e..f450a7b 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 17d64fb..e0eb160 100644 ---- a/gdb/NEWS -+++ b/gdb/NEWS -@@ -669,6 +669,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 24def95..4682045 100644 +index 40b70ab..b291d40 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c -@@ -1644,7 +1644,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); -@@ -10937,6 +10937,40 @@ ada_operator_length (struct expression *exp, int pc, int *oplenp, int *argsp) +@@ -4781,14 +4781,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); + } + + +@@ -10931,6 +10927,40 @@ ada_operator_length (struct expression *exp, int pc, int *oplenp, int *argsp) } } @@ -260,7 +249,7 @@ index 24def95..4682045 100644 static char * ada_op_name (enum exp_opcode opcode) { -@@ -11325,6 +11359,7 @@ parse (void) +@@ -11319,6 +11349,7 @@ parse (void) static const struct exp_descriptor ada_exp_descriptor = { ada_print_subexp, ada_operator_length, @@ -301,11 +290,36 @@ index 5c9e558..55a1873 100644 i386_set_debug_register_length (8); /* Override the GNU/Linux inferior startup hook. */ +diff --git a/gdb/ax-gdb.c b/gdb/ax-gdb.c +index 5776bb0..6099e99 100644 +--- a/gdb/ax-gdb.c ++++ b/gdb/ax-gdb.c +@@ -1810,7 +1810,7 @@ gen_expr (struct expression *exp, union exp_element **pc, + + /* 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, this_name, NULL, VAR_DOMAIN); ++ sym = lookup_block_symbol (b, this_name, VAR_DOMAIN); + if (!sym) + error (_("no `%s' found"), this_name); + diff --git a/gdb/block.c b/gdb/block.c -index 48ac21b..80003b8 100644 +index 48ac21b..0eccecb 100644 --- a/gdb/block.c +++ b/gdb/block.c -@@ -318,6 +318,25 @@ allocate_block (struct obstack *obstack) +@@ -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; @@ -367,7 +381,7 @@ index 7eedb6c..b147826 100644 + #endif /* BLOCK_H */ diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c -index 0dc8474..1a309b5 100644 +index d404ee7..2be397f 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -61,6 +61,7 @@ @@ -378,7 +392,7 @@ index 0dc8474..1a309b5 100644 /* readline include files */ #include "readline/readline.h" -@@ -616,6 +617,53 @@ get_breakpoint (int num) +@@ -614,6 +615,53 @@ get_breakpoint (int num) } @@ -432,7 +446,7 @@ index 0dc8474..1a309b5 100644 /* condition N EXP -- set break condition of breakpoint N to EXP. */ static void -@@ -636,42 +684,7 @@ condition_command (char *arg, int from_tty) +@@ -634,42 +682,7 @@ condition_command (char *arg, int from_tty) ALL_BREAKPOINTS (b) if (b->number == bnum) { @@ -476,7 +490,7 @@ index 0dc8474..1a309b5 100644 return; } -@@ -1870,6 +1883,36 @@ create_longjmp_master_breakpoint (char *func_name) +@@ -1868,6 +1881,36 @@ create_longjmp_master_breakpoint (char *func_name) do_cleanups (old_chain); } @@ -513,7 +527,7 @@ index 0dc8474..1a309b5 100644 void update_breakpoints_after_exec (void) { -@@ -1911,7 +1954,7 @@ update_breakpoints_after_exec (void) +@@ -1909,7 +1952,7 @@ 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 @@ -522,7 +536,7 @@ index 0dc8474..1a309b5 100644 { delete_breakpoint (b); continue; -@@ -1926,7 +1969,8 @@ update_breakpoints_after_exec (void) +@@ -1924,7 +1967,8 @@ update_breakpoints_after_exec (void) /* Longjmp and longjmp-resume breakpoints are also meaningless after an exec. */ @@ -532,7 +546,7 @@ index 0dc8474..1a309b5 100644 { delete_breakpoint (b); continue; -@@ -1987,6 +2031,7 @@ update_breakpoints_after_exec (void) +@@ -1985,6 +2029,7 @@ update_breakpoints_after_exec (void) create_longjmp_master_breakpoint ("_longjmp"); create_longjmp_master_breakpoint ("siglongjmp"); create_longjmp_master_breakpoint ("_siglongjmp"); @@ -540,7 +554,7 @@ index 0dc8474..1a309b5 100644 } int -@@ -2010,6 +2055,7 @@ detach_breakpoints (int pid) +@@ -2008,6 +2053,7 @@ detach_breakpoints (int pid) if (b->inserted) val |= remove_breakpoint_1 (b, mark_inserted); } @@ -548,7 +562,7 @@ index 0dc8474..1a309b5 100644 do_cleanups (old_chain); return val; } -@@ -2109,12 +2155,14 @@ remove_breakpoint_1 (struct bp_location *b, insertion_state_t is) +@@ -2107,12 +2153,14 @@ remove_breakpoint_1 (struct bp_location *b, insertion_state_t is) return val; b->inserted = (is == mark_inserted); } @@ -565,7 +579,7 @@ index 0dc8474..1a309b5 100644 val = target_remove_watchpoint (b->address, b->length, b->watchpoint_type); -@@ -2894,6 +2942,12 @@ print_it_typical (bpstat bs) +@@ -2892,6 +2940,12 @@ print_it_typical (bpstat bs) result = PRINT_NOTHING; break; @@ -578,7 +592,7 @@ index 0dc8474..1a309b5 100644 case bp_watchpoint: case bp_hardware_watchpoint: annotate_watchpoint (b->number); -@@ -2981,6 +3035,8 @@ print_it_typical (bpstat bs) +@@ -2979,6 +3033,8 @@ print_it_typical (bpstat bs) case bp_none: case bp_longjmp: case bp_longjmp_resume: @@ -587,7 +601,7 @@ index 0dc8474..1a309b5 100644 case bp_step_resume: case bp_watchpoint_scope: case bp_call_dummy: -@@ -3385,8 +3441,12 @@ bpstat_check_location (const struct bp_location *bl, +@@ -3383,8 +3439,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 @@ -602,7 +616,7 @@ index 0dc8474..1a309b5 100644 bpstat_check_watchpoint (bpstat bs) { const struct bp_location *bl = bs->breakpoint_at; -@@ -3475,8 +3535,10 @@ bpstat_check_watchpoint (bpstat bs) +@@ -3473,8 +3533,10 @@ bpstat_check_watchpoint (bpstat bs) anything for this watchpoint. */ bs->print_it = print_it_noop; bs->stop = 0; @@ -613,7 +627,7 @@ index 0dc8474..1a309b5 100644 } -@@ -3590,6 +3652,8 @@ bpstat_stop_status (struct address_space *aspace, +@@ -3588,6 +3650,8 @@ bpstat_stop_status (struct address_space *aspace, for (bl = b->loc; bl != NULL; bl = bl->next) { @@ -622,7 +636,7 @@ index 0dc8474..1a309b5 100644 /* For hardware watchpoints, we look only at the first location. The watchpoint_check function will work on entire expression, not the individual locations. For read watchopints, the -@@ -3607,6 +3671,7 @@ bpstat_stop_status (struct address_space *aspace, +@@ -3605,6 +3669,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 */ @@ -630,7 +644,7 @@ index 0dc8474..1a309b5 100644 /* Assume we stop. Should we find watchpoint that is not actually triggered, or if condition of breakpoint is false, we'll reset -@@ -3614,12 +3679,22 @@ bpstat_stop_status (struct address_space *aspace, +@@ -3612,12 +3677,22 @@ bpstat_stop_status (struct address_space *aspace, bs->stop = 1; bs->print = 1; @@ -657,7 +671,7 @@ index 0dc8474..1a309b5 100644 /* We do not stop for these. */ bs->stop = 0; else -@@ -3829,6 +3904,7 @@ bpstat_what (bpstat bs) +@@ -3827,6 +3902,7 @@ bpstat_what (bpstat bs) struct bpstat_what retval; retval.call_dummy = 0; @@ -665,7 +679,7 @@ index 0dc8474..1a309b5 100644 for (; bs != NULL; bs = bs->next) { enum class bs_class = no_effect; -@@ -3875,10 +3951,15 @@ bpstat_what (bpstat bs) +@@ -3873,10 +3949,15 @@ bpstat_what (bpstat bs) bs_class = no_effect; break; case bp_longjmp: @@ -681,7 +695,7 @@ index 0dc8474..1a309b5 100644 break; case bp_step_resume: if (bs->stop) -@@ -3901,6 +3982,7 @@ bpstat_what (bpstat bs) +@@ -3899,6 +3980,7 @@ bpstat_what (bpstat bs) case bp_thread_event: case bp_overlay_event: case bp_longjmp_master: @@ -689,7 +703,7 @@ index 0dc8474..1a309b5 100644 bs_class = bp_nostop; break; case bp_catchpoint: -@@ -4045,6 +4127,8 @@ print_one_breakpoint_location (struct breakpoint *b, +@@ -4043,6 +4125,8 @@ print_one_breakpoint_location (struct breakpoint *b, {bp_access_watchpoint, "acc watchpoint"}, {bp_longjmp, "longjmp"}, {bp_longjmp_resume, "longjmp resume"}, @@ -698,7 +712,7 @@ index 0dc8474..1a309b5 100644 {bp_step_resume, "step resume"}, {bp_watchpoint_scope, "watchpoint scope"}, {bp_call_dummy, "call dummy"}, -@@ -4052,6 +4136,7 @@ print_one_breakpoint_location (struct breakpoint *b, +@@ -4050,6 +4134,7 @@ print_one_breakpoint_location (struct breakpoint *b, {bp_thread_event, "thread events"}, {bp_overlay_event, "overlay events"}, {bp_longjmp_master, "longjmp master"}, @@ -706,7 +720,7 @@ index 0dc8474..1a309b5 100644 {bp_catchpoint, "catchpoint"}, {bp_tracepoint, "tracepoint"}, {bp_fast_tracepoint, "fast tracepoint"}, -@@ -4176,6 +4261,8 @@ print_one_breakpoint_location (struct breakpoint *b, +@@ -4174,6 +4259,8 @@ print_one_breakpoint_location (struct breakpoint *b, case bp_finish: case bp_longjmp: case bp_longjmp_resume: @@ -715,7 +729,7 @@ index 0dc8474..1a309b5 100644 case bp_step_resume: case bp_watchpoint_scope: case bp_call_dummy: -@@ -4183,6 +4270,7 @@ print_one_breakpoint_location (struct breakpoint *b, +@@ -4181,6 +4268,7 @@ print_one_breakpoint_location (struct breakpoint *b, case bp_thread_event: case bp_overlay_event: case bp_longjmp_master: @@ -723,7 +737,7 @@ index 0dc8474..1a309b5 100644 case bp_tracepoint: case bp_fast_tracepoint: case bp_jit_event: -@@ -4821,6 +4909,8 @@ allocate_bp_location (struct breakpoint *bpt) +@@ -4819,6 +4907,8 @@ allocate_bp_location (struct breakpoint *bpt) case bp_finish: case bp_longjmp: case bp_longjmp_resume: @@ -732,7 +746,7 @@ index 0dc8474..1a309b5 100644 case bp_step_resume: case bp_watchpoint_scope: case bp_call_dummy: -@@ -4829,6 +4919,7 @@ allocate_bp_location (struct breakpoint *bpt) +@@ -4827,6 +4917,7 @@ allocate_bp_location (struct breakpoint *bpt) case bp_overlay_event: case bp_jit_event: case bp_longjmp_master: @@ -740,7 +754,7 @@ index 0dc8474..1a309b5 100644 loc->loc_type = bp_loc_software_breakpoint; break; case bp_hardware_breakpoint: -@@ -5015,8 +5106,7 @@ make_breakpoint_permanent (struct breakpoint *b) +@@ -5013,8 +5104,7 @@ make_breakpoint_permanent (struct breakpoint *b) } /* Call this routine when stepping and nexting to enable a breakpoint @@ -750,7 +764,7 @@ index 0dc8474..1a309b5 100644 void set_longjmp_breakpoint (int thread) -@@ -5029,10 +5119,11 @@ set_longjmp_breakpoint (int thread) +@@ -5027,10 +5117,11 @@ set_longjmp_breakpoint (int thread) clones of those and enable them for the requested thread. */ ALL_BREAKPOINTS_SAFE (b, temp) if (b->pspace == current_program_space @@ -764,7 +778,7 @@ index 0dc8474..1a309b5 100644 clone->thread = thread; } } -@@ -5044,7 +5135,7 @@ delete_longjmp_breakpoint (int thread) +@@ -5042,7 +5133,7 @@ delete_longjmp_breakpoint (int thread) struct breakpoint *b, *temp; ALL_BREAKPOINTS_SAFE (b, temp) @@ -773,7 +787,7 @@ index 0dc8474..1a309b5 100644 { if (b->thread == thread) delete_breakpoint (b); -@@ -6119,6 +6210,8 @@ mention (struct breakpoint *b) +@@ -6117,6 +6208,8 @@ mention (struct breakpoint *b) case bp_finish: case bp_longjmp: case bp_longjmp_resume: @@ -782,7 +796,7 @@ index 0dc8474..1a309b5 100644 case bp_step_resume: case bp_call_dummy: case bp_watchpoint_scope: -@@ -6127,6 +6220,7 @@ mention (struct breakpoint *b) +@@ -6125,6 +6218,7 @@ mention (struct breakpoint *b) case bp_overlay_event: case bp_jit_event: case bp_longjmp_master: @@ -790,7 +804,7 @@ index 0dc8474..1a309b5 100644 break; } -@@ -7511,6 +7605,7 @@ struct until_break_command_continuation_args +@@ -7509,6 +7603,7 @@ struct until_break_command_continuation_args { struct breakpoint *breakpoint; struct breakpoint *breakpoint2; @@ -798,7 +812,7 @@ index 0dc8474..1a309b5 100644 }; /* This function is called by fetch_inferior_event via the -@@ -7525,6 +7620,7 @@ until_break_command_continuation (void *arg) +@@ -7523,6 +7618,7 @@ until_break_command_continuation (void *arg) delete_breakpoint (a->breakpoint); if (a->breakpoint2) delete_breakpoint (a->breakpoint2); @@ -806,7 +820,7 @@ index 0dc8474..1a309b5 100644 } void -@@ -7536,6 +7632,8 @@ until_break_command (char *arg, int from_tty, int anywhere) +@@ -7534,6 +7630,8 @@ until_break_command (char *arg, int from_tty, int anywhere) struct breakpoint *breakpoint; struct breakpoint *breakpoint2 = NULL; struct cleanup *old_chain; @@ -815,7 +829,7 @@ index 0dc8474..1a309b5 100644 clear_proceed_status (); -@@ -7574,6 +7672,9 @@ until_break_command (char *arg, int from_tty, int anywhere) +@@ -7572,6 +7670,9 @@ until_break_command (char *arg, int from_tty, int anywhere) old_chain = make_cleanup_delete_breakpoint (breakpoint); @@ -825,7 +839,7 @@ index 0dc8474..1a309b5 100644 /* Keep within the current frame, or in frames called by the current one. */ -@@ -7586,6 +7687,10 @@ until_break_command (char *arg, int from_tty, int anywhere) +@@ -7584,6 +7685,10 @@ until_break_command (char *arg, int from_tty, int anywhere) frame_unwind_caller_id (frame), bp_until); make_cleanup_delete_breakpoint (breakpoint2); @@ -836,7 +850,7 @@ index 0dc8474..1a309b5 100644 } proceed (-1, TARGET_SIGNAL_DEFAULT, 0); -@@ -7602,6 +7707,7 @@ until_break_command (char *arg, int from_tty, int anywhere) +@@ -7600,6 +7705,7 @@ until_break_command (char *arg, int from_tty, int anywhere) args->breakpoint = breakpoint; args->breakpoint2 = breakpoint2; @@ -844,7 +858,7 @@ index 0dc8474..1a309b5 100644 discard_cleanups (old_chain); add_continuation (inferior_thread (), -@@ -8823,6 +8929,7 @@ delete_command (char *arg, int from_tty) +@@ -8785,6 +8891,7 @@ delete_command (char *arg, int from_tty) && b->type != bp_thread_event && b->type != bp_overlay_event && b->type != bp_longjmp_master @@ -852,7 +866,7 @@ index 0dc8474..1a309b5 100644 && b->number >= 0) { breaks_to_delete = 1; -@@ -8842,6 +8949,7 @@ delete_command (char *arg, int from_tty) +@@ -8804,6 +8911,7 @@ delete_command (char *arg, int from_tty) && b->type != bp_jit_event && b->type != bp_overlay_event && b->type != bp_longjmp_master @@ -860,7 +874,7 @@ index 0dc8474..1a309b5 100644 && b->number >= 0) delete_breakpoint (b); } -@@ -9152,6 +9260,7 @@ breakpoint_re_set_one (void *bint) +@@ -9114,6 +9222,7 @@ breakpoint_re_set_one (void *bint) reset later by breakpoint_re_set. */ case bp_overlay_event: case bp_longjmp_master: @@ -868,7 +882,7 @@ index 0dc8474..1a309b5 100644 delete_breakpoint (b); break; -@@ -9174,6 +9283,8 @@ breakpoint_re_set_one (void *bint) +@@ -9136,6 +9245,8 @@ breakpoint_re_set_one (void *bint) case bp_step_resume: case bp_longjmp: case bp_longjmp_resume: @@ -877,7 +891,7 @@ index 0dc8474..1a309b5 100644 case bp_jit_event: break; } -@@ -9216,6 +9327,7 @@ breakpoint_re_set (void) +@@ -9178,6 +9289,7 @@ breakpoint_re_set (void) create_longjmp_master_breakpoint ("_longjmp"); create_longjmp_master_breakpoint ("siglongjmp"); create_longjmp_master_breakpoint ("_siglongjmp"); @@ -885,7 +899,7 @@ index 0dc8474..1a309b5 100644 } /* Reset the thread number of this breakpoint: -@@ -10177,6 +10289,22 @@ all_tracepoints () +@@ -10173,6 +10285,22 @@ all_tracepoints () return tp_vec; } @@ -908,7 +922,7 @@ index 0dc8474..1a309b5 100644 /* This help string is used for the break, hbreak, tbreak and thbreak commands. It is defined as a macro to prevent duplication. -@@ -10721,4 +10849,5 @@ inferior in all-stop mode, gdb behaves as if always-inserted mode is off."), +@@ -10717,4 +10845,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); @@ -963,30 +977,173 @@ index 6b373a3..59aa412 100644 /* 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 8e00979..92efb39 100644 +--- a/gdb/c-exp.y ++++ b/gdb/c-exp.y +@@ -418,6 +418,24 @@ exp : exp '(' nonempty_typelist ')' const_or_volatile + } + ; + ++/* ++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; } + ; +@@ -785,12 +803,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); +@@ -2033,6 +2052,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; +@@ -2041,9 +2067,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 ()) + { +@@ -2079,10 +2115,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; + } + +@@ -2111,6 +2156,8 @@ yylex (void) + return 0; + + case ' ': ++ name_prefix_len++; ++ terminate_prefix = 0; + case '\t': + case '\n': + lexptr++; +@@ -2268,11 +2315,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'. */ + +@@ -2357,14 +2406,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). */ +@@ -2423,6 +2487,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 d620881..d4a229d 100644 +index d620881..34cb34a 100644 --- a/gdb/c-lang.c +++ b/gdb/c-lang.c -@@ -717,7 +717,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; - - *char_type = element_type; - -@@ -1040,6 +1040,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 -@@ -1140,6 +1143,7 @@ static const struct exp_descriptor exp_descriptor_c = +@@ -1140,6 +1140,7 @@ static const struct exp_descriptor exp_descriptor_c = { print_subexp_standard, operator_length_standard, @@ -995,10 +1152,90 @@ index d620881..d4a229d 100644 dump_subexp_body_standard, evaluate_subexp_c diff --git a/gdb/c-typeprint.c b/gdb/c-typeprint.c -index d1af481..1c930b5 100644 +index d1af481..96b0705 100644 --- a/gdb/c-typeprint.c +++ b/gdb/c-typeprint.c -@@ -558,7 +558,12 @@ c_type_print_varspec_suffix (struct type *type, struct ui_file *stream, +@@ -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, +@@ -197,6 +196,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"); ++ } + } + + +@@ -353,10 +369,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; +@@ -368,13 +388,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; + } + +@@ -558,7 +584,12 @@ c_type_print_varspec_suffix (struct type *type, struct ui_file *stream, fprintf_filtered (stream, ")"); fprintf_filtered (stream, "["); @@ -1012,146 +1249,20 @@ index d1af481..1c930b5 100644 && !TYPE_ARRAY_UPPER_BOUND_IS_UNDEFINED (type)) fprintf_filtered (stream, "%d", (TYPE_LENGTH (type) -diff --git a/gdb/cli/cli-cmds.c b/gdb/cli/cli-cmds.c -index 4833898..992c46f 100644 ---- a/gdb/cli/cli-cmds.c -+++ b/gdb/cli/cli-cmds.c -@@ -47,6 +47,8 @@ extern void disconnect_or_stop_tracing (int from_tty); - #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 -@@ -184,6 +186,7 @@ struct cmd_list_element *showchecklist; - - /* Command tracing state. */ - -+static int source_python = 0; - int source_verbose = 0; - int trace_commands = 0; - -@@ -448,6 +451,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) - { -@@ -480,8 +484,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); - } -@@ -495,15 +507,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 -@@ -511,23 +538,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); - } - - -@@ -1309,7 +1341,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); +@@ -591,7 +622,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/coffread.c b/gdb/coffread.c -index eca6618..0579ce6 100644 +index 8e5dca9..7e7fb8b 100644 --- a/gdb/coffread.c +++ b/gdb/coffread.c -@@ -2126,6 +2126,7 @@ static struct sym_fns coff_sym_fns = +@@ -2123,6 +2123,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 */ @@ -1187,249 +1298,8 @@ index ebde876..907b275 100644 /* Relocated directory for source files. */ #undef RELOC_SRCDIR -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 7f26c64..0542f7e 100755 +index 4980106..be69488 100755 --- a/gdb/configure +++ b/gdb/configure @@ -676,6 +676,8 @@ REPORT_BUGS_TO @@ -1544,7 +1414,7 @@ index 7f26c64..0542f7e 100755 # Flags needed to compile Python code (taken from python-config --cflags). diff --git a/gdb/configure.ac b/gdb/configure.ac -index ebb0a95..c8ebafe 100644 +index a756a2d..b44e21d 100644 --- a/gdb/configure.ac +++ b/gdb/configure.ac @@ -108,6 +108,51 @@ AS_HELP_STRING([--with-relocated-sources=PATH], [automatically relocate this pat @@ -1608,11 +1478,593 @@ index ebb0a95..c8ebafe 100644 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 81f6a5d..097db65 100644 +--- a/gdb/cp-name-parser.y ++++ b/gdb/cp-name-parser.y +@@ -389,7 +389,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 04b665b..21e013a 100644 +--- a/gdb/cp-namespace.c ++++ b/gdb/cp-namespace.c +@@ -34,14 +34,17 @@ + #include "buildsym.h" + + 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); +@@ -117,7 +120,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; +@@ -132,7 +135,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; +@@ -146,7 +150,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); + + } + +@@ -199,7 +204,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. */ +@@ -207,14 +215,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; + } +@@ -229,12 +244,48 @@ cp_add_using (const char *dest, + + 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 +@@ -252,9 +303,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, +@@ -276,8 +326,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; + } +@@ -288,25 +337,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. */ + +@@ -314,39 +436,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 +@@ -356,17 +517,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 +@@ -376,12 +535,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) +@@ -402,6 +560,7 @@ lookup_symbol_file (const char *name, + sym = lookup_possible_namespace_symbol (name); + if (sym != NULL) + return sym; ++ + } + + return NULL; +@@ -429,9 +588,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) +@@ -677,7 +835,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) + { +@@ -718,7 +876,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 c31fcff..fc294ae 100644 +--- a/gdb/cp-support.c ++++ b/gdb/cp-support.c +@@ -190,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) +@@ -840,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); + } +diff --git a/gdb/cp-support.h b/gdb/cp-support.h +index a629955..2afdb48 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); +@@ -79,10 +98,16 @@ extern int cp_validate_operator (const char *input); + 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); +@@ -99,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 816a355..e9f56f9 100644 +index 6ef6767..5f4825c 100644 --- a/gdb/dbxread.c +++ b/gdb/dbxread.c -@@ -3570,6 +3570,7 @@ static struct sym_fns aout_sym_fns = +@@ -3565,6 +3565,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 */ @@ -1621,23 +2073,10 @@ index 816a355..e9f56f9 100644 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 253e251..6d73fc5 100644 +index d716d0d..35dc185 100644 --- a/gdb/doc/gdb.texinfo +++ b/gdb/doc/gdb.texinfo -@@ -962,8 +962,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} -@@ -1155,6 +1157,16 @@ for remote debugging. +@@ -1159,6 +1159,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. @@ -1654,7 +2093,7 @@ index 253e251..6d73fc5 100644 @c resolve the situation of these eventually @item -tui @cindex @code{--tui} -@@ -19101,7 +19113,7 @@ command: +@@ -19145,7 +19155,7 @@ command: @table @code @kindex source @cindex execute commands from a file @@ -1663,19 +2102,7 @@ index 253e251..6d73fc5 100644 Execute the command file @var{filename}. @end table -@@ -19118,6 +19130,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. -+ - 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 -@@ -19379,8 +19396,6 @@ containing @code{end}. For example: +@@ -19428,8 +19438,6 @@ containing @code{end}. For example: @smallexample (@value{GDBP}) python @@ -1684,7 +2111,7 @@ index 253e251..6d73fc5 100644 >print 23 >end 23 -@@ -19393,6 +19408,14 @@ in a Python script. This can be controlled using @code{maint set +@@ -19442,6 +19450,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. @@ -1699,7 +2126,7 @@ index 253e251..6d73fc5 100644 @end table @node Python API -@@ -19400,6 +19423,14 @@ disabled. +@@ -19449,6 +19465,14 @@ disabled. @cindex python api @cindex programming in python @@ -1714,7 +2141,7 @@ index 253e251..6d73fc5 100644 @cindex python stdout @cindex python pagination At startup, @value{GDBN} overrides Python's @code{sys.stdout} and -@@ -19412,13 +19443,17 @@ situation, a Python @code{KeyboardInterrupt} exception is thrown. +@@ -19461,13 +19485,17 @@ situation, a Python @code{KeyboardInterrupt} exception is thrown. * Basic Python:: Basic Python Functions. * Exception Handling:: * Auto-loading:: Automatically loading Python code. @@ -1733,7 +2160,7 @@ index 253e251..6d73fc5 100644 * Frames In Python:: Acessing inferior stack frames from Python. * Lazy Strings In Python:: Python representation of lazy strings. @end menu -@@ -19446,6 +19481,12 @@ command as having originated from the user invoking it interactively. +@@ -19495,6 +19523,12 @@ command as having originated from the user invoking it interactively. It must be a boolean value. If omitted, it defaults to @code{False}. @end defun @@ -1746,7 +2173,7 @@ index 253e251..6d73fc5 100644 @findex gdb.parameter @defun parameter parameter Return the value of a @value{GDBN} parameter. @var{parameter} is a -@@ -19462,6 +19503,7 @@ a Python value of the appropriate type, and returned. +@@ -19511,6 +19545,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. @@ -1754,7 +2181,7 @@ index 253e251..6d73fc5 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 -@@ -19486,6 +19528,21 @@ compute values, for example, it is the only way to get the value of a +@@ -19535,6 +19570,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 @@ -1776,7 +2203,7 @@ index 253e251..6d73fc5 100644 @findex gdb.write @defun write string Print a string to @value{GDBN}'s paginated standard output stream. -@@ -19500,6 +19557,11 @@ Flush @value{GDBN}'s paginated standard output stream. Flushing +@@ -19549,6 +19599,11 @@ Flush @value{GDBN}'s paginated standard output stream. Flushing function. @end defun @@ -1788,7 +2215,7 @@ index 253e251..6d73fc5 100644 @node Exception Handling @subsubsection Exception Handling @cindex python exceptions -@@ -19738,6 +19800,9 @@ module: +@@ -19787,6 +19842,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. @@ -1798,7 +2225,7 @@ index 253e251..6d73fc5 100644 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 -@@ -19860,7 +19925,7 @@ If the type does not have a target, this method will throw an +@@ -19909,7 +19967,7 @@ If the type does not have a target, this method will throw an exception. @end defmethod @@ -1807,7 +2234,7 @@ index 253e251..6d73fc5 100644 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. -@@ -19868,7 +19933,8 @@ return a new @code{gdb.Type} which represents the type of the +@@ -19917,7 +19975,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. @@ -1817,7 +2244,7 @@ index 253e251..6d73fc5 100644 @end defmethod @end table -@@ -20222,6 +20288,121 @@ import gdb.libstdcxx.v6 +@@ -20271,6 +20330,121 @@ import gdb.libstdcxx.v6 gdb.libstdcxx.v6.register_printers (gdb.current_objfile ()) @end smallexample @@ -1939,7 +2366,7 @@ index 253e251..6d73fc5 100644 @node Commands In Python @subsubsection Commands In Python -@@ -20474,6 +20655,135 @@ registration of the command with @value{GDBN}. Depending on how the +@@ -20523,6 +20697,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. @@ -2075,7 +2502,7 @@ index 253e251..6d73fc5 100644 @node Functions In Python @subsubsection Writing new convenience functions -@@ -20578,6 +20888,82 @@ which is used to format the value. @xref{Pretty Printing}, for more +@@ -20627,6 +20930,82 @@ which is used to format the value. @xref{Pretty Printing}, for more information. @end defivar @@ -2158,7 +2585,7 @@ index 253e251..6d73fc5 100644 @node Frames In Python @subsubsection Acessing inferior stack frames from Python. -@@ -20642,6 +21028,14 @@ function to a string. +@@ -20691,6 +21070,14 @@ function to a string. Returns the frame's resume address. @end defmethod @@ -2173,7 +2600,7 @@ index 253e251..6d73fc5 100644 @defmethod Frame older Return the frame that called this frame. @end defmethod -@@ -20650,10 +21044,18 @@ Return the frame that called this frame. +@@ -20699,10 +21086,18 @@ Return the frame that called this frame. Return the frame called by this frame. @end defmethod @@ -2365,10 +2792,10 @@ index 99100d7..5915249 100644 if (fde_table == NULL) continue; diff --git a/gdb/dwarf2expr.c b/gdb/dwarf2expr.c -index 5e27d38..628ba88 100644 +index ed21edf..1b10cb7 100644 --- a/gdb/dwarf2expr.c +++ b/gdb/dwarf2expr.c -@@ -848,6 +848,13 @@ execute_stack_op (struct dwarf_expr_context *ctx, +@@ -868,6 +868,13 @@ execute_stack_op (struct dwarf_expr_context *ctx, ctx->initialized = 0; goto no_push; @@ -2718,19 +3145,22 @@ index fa0bd11..fdea2b4 100644 #endif /* dwarf2loc.h */ diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c -index 243859c..2fccec5 100644 +index 15ef3e9..99f729b 100644 --- a/gdb/dwarf2read.c +++ b/gdb/dwarf2read.c -@@ -48,6 +48,8 @@ +@@ -48,6 +48,11 @@ #include "gdbcmd.h" #include "block.h" #include "addrmap.h" +#include "block.h" +#include "f-lang.h" ++#include "typeprint.h" ++#include "jv-lang.h" ++#include "vec.h" #include #include "gdb_string.h" -@@ -96,7 +98,7 @@ typedef struct pubnames_header +@@ -96,7 +101,7 @@ typedef struct pubnames_header _PUBNAMES_HEADER; #define _ACTUAL_PUBNAMES_HEADER_SIZE 13 @@ -2739,7 +3169,7 @@ index 243859c..2fccec5 100644 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 -@@ -153,7 +155,10 @@ struct dwarf2_section_info +@@ -153,7 +158,10 @@ struct dwarf2_section_info asection *asection; gdb_byte *buffer; bfd_size_type size; @@ -2751,7 +3181,7 @@ index 243859c..2fccec5 100644 }; struct dwarf2_per_objfile -@@ -333,6 +338,19 @@ struct dwarf2_cu +@@ -333,6 +341,19 @@ struct dwarf2_cu DIEs for namespaces, we don't need to try to infer them from mangled names. */ unsigned int has_namespace_info : 1; @@ -2771,17 +3201,41 @@ index 243859c..2fccec5 100644 }; /* Persistent data held for a compilation unit, even when not -@@ -788,6 +806,9 @@ static void scan_partial_symbols (struct partial_die_info *, +@@ -487,8 +508,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; + + /* The scope to prepend to our children. This is generally +@@ -677,6 +697,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; ++ + /* One item on the queue of compilation units to read in full symbols + for. */ + struct dwarf2_queue_item +@@ -788,7 +813,10 @@ static void scan_partial_symbols (struct partial_die_info *, static void add_partial_symbol (struct partial_die_info *, struct dwarf2_cu *); +-static int pdi_needs_namespace (enum dwarf_tag tag); +static gdb_byte *read_comp_unit_head (struct comp_unit_head *, gdb_byte *, + bfd *); + - static int pdi_needs_namespace (enum dwarf_tag tag); ++static int die_needs_namespace (struct die_info *, struct dwarf2_cu *); static void add_partial_namespace (struct partial_die_info *pdi, -@@ -813,6 +834,10 @@ static void dwarf2_psymtab_to_symtab (struct partial_symtab *); + CORE_ADDR *lowpc, CORE_ADDR *highpc, +@@ -813,6 +841,10 @@ static void dwarf2_psymtab_to_symtab (struct partial_symtab *); static void psymtab_to_symtab_1 (struct partial_symtab *); @@ -2792,7 +3246,32 @@ index 243859c..2fccec5 100644 static void dwarf2_read_abbrevs (bfd *abfd, struct dwarf2_cu *cu); static void dwarf2_free_abbrev_table (void *); -@@ -995,6 +1020,15 @@ static void read_module (struct die_info *die, struct dwarf2_cu *cu); +@@ -940,6 +972,11 @@ static struct type *tag_type_to_type (struct die_info *, struct dwarf2_cu *); + + static struct type *read_type_die (struct die_info *, struct dwarf2_cu *); + ++static char *physname_prefix (struct die_info *die, struct dwarf2_cu *); ++ ++static void physname_prefix_1 (struct ui_file *, struct die_info *, ++ struct dwarf2_cu *); ++ + static char *determine_prefix (struct die_info *die, struct dwarf2_cu *); + + static char *typename_concat (struct obstack *, +@@ -984,17 +1021,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 *); ++ + static void read_module (struct die_info *die, struct dwarf2_cu *cu); static void read_import_statement (struct die_info *die, struct dwarf2_cu *); @@ -2808,17 +3287,19 @@ index 243859c..2fccec5 100644 static const char *namespace_name (struct die_info *die, int *is_anonymous, struct dwarf2_cu *); -@@ -1030,6 +1064,9 @@ static void process_die (struct die_info *, struct dwarf2_cu *); +@@ -1028,7 +1073,10 @@ static gdb_byte *read_full_die (const struct die_reader_specs *reader, - static char *dwarf2_linkage_name (struct die_info *, struct dwarf2_cu *); + static void process_die (struct die_info *, struct dwarf2_cu *); +-static char *dwarf2_linkage_name (struct die_info *, struct dwarf2_cu *); ++static char *dwarf2_physname (struct die_info *, struct dwarf2_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 *); - -@@ -1144,6 +1181,9 @@ static void age_cached_comp_units (void); +@@ -1144,6 +1192,9 @@ static void age_cached_comp_units (void); static void free_one_cached_comp_unit (void *); @@ -2828,7 +3309,7 @@ index 243859c..2fccec5 100644 static struct type *set_die_type (struct die_info *, struct type *, struct dwarf2_cu *); -@@ -1163,22 +1203,31 @@ static void dwarf2_clear_marks (struct dwarf2_per_cu_data *); +@@ -1163,22 +1214,31 @@ static void dwarf2_clear_marks (struct dwarf2_per_cu_data *); static struct type *get_die_type (struct die_info *die, struct dwarf2_cu *cu); @@ -2869,7 +3350,7 @@ index 243859c..2fccec5 100644 } /* When loading sections, we can either look for ".", or for -@@ -1271,10 +1320,13 @@ dwarf2_locate_sections (bfd *abfd, asection *sectp, void *ignore_ptr) +@@ -1271,10 +1331,13 @@ dwarf2_locate_sections (bfd *abfd, asection *sectp, void *ignore_ptr) } /* Decompress a section that was compressed using zlib. Store the @@ -2885,7 +3366,7 @@ index 243859c..2fccec5 100644 gdb_byte **outbuf, bfd_size_type *outsize) { bfd *abfd = objfile->obfd; -@@ -1291,6 +1343,7 @@ zlib_decompress_section (struct objfile *objfile, asection *sectp, +@@ -1291,6 +1354,7 @@ zlib_decompress_section (struct objfile *objfile, asection *sectp, z_stream strm; int rc; int header_size = 12; @@ -2893,7 +3374,7 @@ index 243859c..2fccec5 100644 if (bfd_seek (abfd, sectp->filepos, SEEK_SET) != 0 || bfd_bread (compressed_buffer, compressed_size, abfd) != compressed_size) -@@ -1320,8 +1373,13 @@ zlib_decompress_section (struct objfile *objfile, asection *sectp, +@@ -1320,8 +1384,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; @@ -2909,7 +3390,7 @@ index 243859c..2fccec5 100644 rc = inflateInit (&strm); while (strm.avail_in > 0) { -@@ -1342,26 +1400,176 @@ zlib_decompress_section (struct objfile *objfile, asection *sectp, +@@ -1342,26 +1411,176 @@ zlib_decompress_section (struct objfile *objfile, asection *sectp, error (_("Dwarf Error: concluding DWARF uncompression in '%s': %d"), bfd_get_filename (abfd), rc); @@ -3091,7 +3572,7 @@ index 243859c..2fccec5 100644 if (info->asection == NULL || info->size == 0) return; -@@ -1374,7 +1582,7 @@ dwarf2_read_section (struct objfile *objfile, struct dwarf2_section_info *info) +@@ -1374,7 +1593,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) { @@ -3100,7 +3581,7 @@ index 243859c..2fccec5 100644 &info->size); return; } -@@ -1397,7 +1605,7 @@ dwarf2_read_section (struct objfile *objfile, struct dwarf2_section_info *info) +@@ -1397,7 +1616,7 @@ dwarf2_read_section (struct objfile *objfile, struct dwarf2_section_info *info) if (retbuf != MAP_FAILED) { @@ -3109,7 +3590,7 @@ index 243859c..2fccec5 100644 info->buffer = retbuf + (sectp->filepos & (pagesize - 1)) ; return; } -@@ -1405,8 +1613,15 @@ dwarf2_read_section (struct objfile *objfile, struct dwarf2_section_info *info) +@@ -1405,8 +1624,15 @@ dwarf2_read_section (struct objfile *objfile, struct dwarf2_section_info *info) #endif /* If we get here, we are a normal, not-compressed section. */ @@ -3127,7 +3608,7 @@ index 243859c..2fccec5 100644 /* When debugging .o files, we may need to apply relocations; see http://sourceware.org/ml/gdb-patches/2002-04/msg00136.html . -@@ -1415,6 +1630,8 @@ dwarf2_read_section (struct objfile *objfile, struct dwarf2_section_info *info) +@@ -1415,6 +1641,8 @@ dwarf2_read_section (struct objfile *objfile, struct dwarf2_section_info *info) retbuf = symfile_relocate_debug_section (abfd, sectp, buf); if (retbuf != NULL) { @@ -3136,7 +3617,7 @@ index 243859c..2fccec5 100644 info->buffer = retbuf; return; } -@@ -1423,6 +1640,19 @@ dwarf2_read_section (struct objfile *objfile, struct dwarf2_section_info *info) +@@ -1423,6 +1651,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)); @@ -3156,7 +3637,80 @@ index 243859c..2fccec5 100644 } /* Fill in SECTP, BUFP and SIZEP with section info, given OBJFILE and -@@ -2548,6 +2778,13 @@ add_partial_symbol (struct partial_die_info *pdi, struct dwarf2_cu *cu) +@@ -2389,11 +2630,18 @@ partial_die_parent_scope (struct partial_die_info *pdi, + || parent->tag == DW_TAG_union_type + || parent->tag == DW_TAG_enumeration_type) + { ++ char *parent_name = parent->name; ++ ++ /* G++ 4.1 produced DW_TAG_namespace with DW_AT_name "::". */ ++ if (parent->tag == DW_TAG_namespace && parent_name != NULL ++ && strcmp (parent_name, "::") == 0) ++ parent_name = NULL; ++ + if (grandparent_scope == NULL) +- parent->scope = parent->name; ++ parent->scope = parent_name; + else + parent->scope = typename_concat (&cu->comp_unit_obstack, grandparent_scope, +- parent->name, cu); ++ parent_name, cu); + } + else if (parent->tag == DW_TAG_enumerator) + /* Enumerators should not get the name of the enumeration as a prefix. */ +@@ -2405,7 +2653,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; + } + +@@ -2420,12 +2668,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. */ ++ ++ real_pdi = pdi; ++ while (real_pdi->has_specification) ++ real_pdi = find_partial_die (real_pdi->spec_offset, cu); ++ ++ parent_scope = partial_die_parent_scope (real_pdi, cu); ++ if (parent_scope != NULL) + return typename_concat (NULL, parent_scope, pdi->name, cu); ++ ++ return NULL; + } + + static void +@@ -2441,12 +2699,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; +@@ -2543,6 +2798,13 @@ add_partial_symbol (struct partial_die_info *pdi, struct dwarf2_cu *cu) &objfile->global_psymbols, 0, (CORE_ADDR) 0, cu->language, objfile); break; @@ -3170,7 +3724,70 @@ index 243859c..2fccec5 100644 case DW_TAG_class_type: case DW_TAG_interface_type: case DW_TAG_structure_type: -@@ -2661,12 +2898,12 @@ static void +@@ -2586,34 +2848,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: +@@ -2623,7 +2868,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; ++ + default: + return 0; + } +@@ -2656,12 +2917,12 @@ static void add_partial_module (struct partial_die_info *pdi, CORE_ADDR *lowpc, CORE_ADDR *highpc, int need_pc, struct dwarf2_cu *cu) { @@ -3187,7 +3804,35 @@ index 243859c..2fccec5 100644 } /* Read a partial die corresponding to a subprogram and create a partial -@@ -3330,6 +3567,14 @@ process_die (struct die_info *die, struct dwarf2_cu *cu) +@@ -2752,27 +3013,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; +- } + } + } + +@@ -3325,6 +3565,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; @@ -3202,21 +3847,247 @@ index 243859c..2fccec5 100644 if (die->child != NULL && (die->tag == DW_TAG_imported_declaration || cu->language != language_fortran)) complaint (&symfile_complaints, _("Tag '%s' has unexpected children"), -@@ -3881,6 +4126,13 @@ read_func_scope (struct die_info *die, struct dwarf2_cu *cu) +@@ -3340,41 +3588,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)) ++ { ++ if (die_needs_namespace (die, cu)) ++ { ++ 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') ++ { ++ char *prefixed_name = typename_concat (NULL, prefix, name, cu); ++ fputs_unfiltered (prefixed_name, buf); ++ xfree (prefixed_name); ++ } ++ 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) ++ { ++ char *cname ++ = dwarf2_canonicalize_name (name, cu, ++ &cu->objfile->objfile_obstack); ++ if (cname != NULL) ++ name = cname; ++ } ++ } ++ } + + 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; ++ ++ line_attr = dwarf2_attr (die, DW_AT_decl_line, cu); ++ if (line_attr) ++ return DW_UNSND (line_attr); ++ ++ return -1; ++} ++ + /* Read the import statement specified by the given die and record it. */ + + static void +@@ -3385,9 +3663,15 @@ read_import_statement (struct die_info *die, struct dwarf2_cu *cu) + struct dwarf2_cu *imported_cu; + 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) + { +@@ -3436,17 +3720,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, imported_cu); +- +- if (strlen (imported_name_prefix) > 0) +- { ++ imported_name_prefix = determine_prefix (imported_die, cu); ++ ++ 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, "::"); +@@ -3457,8 +3751,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 +@@ -3727,6 +4027,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; + +@@ -3825,6 +4133,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) +@@ -3843,13 +4152,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, NULL)) ++ 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; + +@@ -3876,14 +4195,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; + } + - if (die->child != NULL) - { - child_die = die->child; -@@ -3904,6 +4156,13 @@ read_func_scope (struct die_info *die, struct dwarf2_cu *cu) ++ 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); +@@ -3899,6 +4223,13 @@ read_func_scope (struct die_info *die, struct dwarf2_cu *cu) determine_prefix (die, cu), processing_has_namespace_info); @@ -3230,7 +4101,108 @@ index 243859c..2fccec5 100644 /* If we have address ranges, record them. */ dwarf2_record_block_ranges (die, block, baseaddr, cu); -@@ -5385,6 +5644,29 @@ process_enumeration_scope (struct die_info *die, struct dwarf2_cu *cu) +@@ -3952,7 +4283,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, +@@ -4517,7 +4848,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. */ +@@ -4679,7 +5010,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++) +@@ -5010,14 +5341,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); + } + } + +@@ -5258,51 +5593,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. +@@ -5380,6 +5670,29 @@ process_enumeration_scope (struct die_info *die, struct dwarf2_cu *cu) new_symbol (die, this_type, cu); } @@ -3260,7 +4232,7 @@ index 243859c..2fccec5 100644 /* 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. */ -@@ -5398,7 +5680,7 @@ read_array_type (struct die_info *die, struct dwarf2_cu *cu) +@@ -5393,7 +5706,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; @@ -3269,7 +4241,7 @@ index 243859c..2fccec5 100644 struct cleanup *back_to; char *name; -@@ -5445,16 +5727,11 @@ read_array_type (struct die_info *die, struct dwarf2_cu *cu) +@@ -5440,16 +5753,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) @@ -3291,7 +4263,16 @@ index 243859c..2fccec5 100644 /* Understand Dwarf2 support for vector types (like they occur on the PowerPC w/ AltiVec). Gcc just adds another attribute to the -@@ -5659,20 +5936,155 @@ read_namespace (struct die_info *die, struct dwarf2_cu *cu) +@@ -5638,7 +5946,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)); + } + } + +@@ -5654,20 +5962,155 @@ read_namespace (struct die_info *die, struct dwarf2_cu *cu) } } @@ -3304,14 +4285,13 @@ index 243859c..2fccec5 100644 { - struct die_info *child_die = die->child; + struct type *type; - -- /* FIXME: Support the separate Fortran module namespaces. */ ++ + type = read_module_type (die, cu); + + if (type) + new_symbol (die, type, cu); +} - ++ +/* Read a Fortran module as type. + + Modules present only as declarations - being used only for DW_AT_import of @@ -3340,9 +4320,10 @@ index 243859c..2fccec5 100644 + type = init_type (TYPE_CODE_MODULE, 0, 0, module_name, objfile); + + /* 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; @@ -3450,7 +4431,7 @@ index 243859c..2fccec5 100644 } /* Return the name of the namespace represented by DIE. Set -@@ -5837,29 +6249,113 @@ read_tag_string_type (struct die_info *die, struct dwarf2_cu *cu) +@@ -5832,29 +6275,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; @@ -3578,7 +4559,7 @@ index 243859c..2fccec5 100644 char_type = language_string_char_type (cu->language_defn, gdbarch); type = create_string_type (NULL, char_type, range_type); -@@ -5959,7 +6455,6 @@ static struct type * +@@ -5954,7 +6481,6 @@ static struct type * read_typedef (struct die_info *die, struct dwarf2_cu *cu) { struct objfile *objfile = cu->objfile; @@ -3586,7 +4567,7 @@ index 243859c..2fccec5 100644 const char *name = NULL; struct type *this_type; -@@ -6067,8 +6562,7 @@ read_subrange_type (struct die_info *die, struct dwarf2_cu *cu) +@@ -6062,8 +6588,7 @@ read_subrange_type (struct die_info *die, struct dwarf2_cu *cu) struct type *base_type; struct type *range_type; struct attribute *attr; @@ -3596,7 +4577,7 @@ index 243859c..2fccec5 100644 char *name; LONGEST negative_mask; -@@ -6082,49 +6576,101 @@ read_subrange_type (struct die_info *die, struct dwarf2_cu *cu) +@@ -6077,49 +6602,101 @@ read_subrange_type (struct die_info *die, struct dwarf2_cu *cu) 0, NULL, cu->objfile); } @@ -3734,7 +4715,7 @@ index 243859c..2fccec5 100644 name = dwarf2_name (die, cu); if (name) -@@ -6583,6 +7129,7 @@ load_partial_dies (bfd *abfd, gdb_byte *buffer, gdb_byte *info_ptr, +@@ -6578,6 +7155,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 @@ -3742,7 +4723,28 @@ index 243859c..2fccec5 100644 && abbrev->tag != DW_TAG_member) { /* Otherwise we skip to the next sibling, if any. */ -@@ -8331,10 +8878,12 @@ var_decode_location (struct attribute *attr, struct symbol *sym, +@@ -6786,8 +7364,8 @@ read_partial_die (struct partial_die_info *part_die, + } + break; + case DW_AT_MIPS_linkage_name: +- part_die->name = DW_STRING (&attr); +- break; ++ if (cu->language == language_ada) ++ part_die->name = DW_STRING (&attr); + case DW_AT_low_pc: + has_low_pc_attr = 1; + part_die->lowpc = DW_ADDR (&attr); +@@ -6984,7 +7562,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; + +@@ -8326,10 +8905,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 @@ -3757,16 +4759,35 @@ index 243859c..2fccec5 100644 } /* Given a pointer to a DWARF information entry, figure out if we need -@@ -8367,10 +8916,17 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu) +@@ -8351,21 +8932,29 @@ 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, 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), 0, objfile); +- SYMBOL_SET_NAMES (sym, name, strlen (name), 0, 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), 0, objfile); + if (cu->language == language_fortran) + { + SYMBOL_CPLUS_DEMANGLED_NAME (sym) = SYMBOL_LINKAGE_NAME (sym); @@ -3775,7 +4796,7 @@ index 243859c..2fccec5 100644 /* Default assumptions. Use the passed type or decode it from the die. */ -@@ -8470,7 +9026,18 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu) +@@ -8465,7 +9054,18 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu) var_decode_location (attr, sym, cu); attr2 = dwarf2_attr (die, DW_AT_external, cu); if (attr2 && (DW_UNSND (attr2) != 0)) @@ -3795,7 +4816,16 @@ index 243859c..2fccec5 100644 else add_symbol_to_list (sym, cu->list_in_scope); } -@@ -8631,6 +9198,11 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu) +@@ -8602,7 +9202,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) + { +@@ -8626,6 +9226,11 @@ 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; @@ -3807,7 +4837,17 @@ index 243859c..2fccec5 100644 default: /* Not a tag we recognize. Hopefully we aren't processing trash data, but since we must specifically ignore things -@@ -8957,12 +9529,18 @@ read_type_die (struct die_info *die, struct dwarf2_cu *cu) +@@ -8639,8 +9244,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); +@@ -8952,12 +9556,18 @@ read_type_die (struct die_info *die, struct dwarf2_cu *cu) case DW_TAG_namespace: this_type = read_namespace_type (die, cu); break; @@ -3826,10 +4866,195 @@ index 243859c..2fccec5 100644 return this_type; } -@@ -9110,6 +9688,39 @@ dwarf2_linkage_name (struct die_info *die, struct dwarf2_cu *cu) - return dwarf2_name (die, cu); +@@ -9039,10 +9649,103 @@ 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)"; ++ /* G++ 4.1 produced DW_TAG_namespace with DW_AT_name "::". */ ++ else if (strcmp (name, "::") == 0) ++ name = NULL; ++ 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, +@@ -9092,17 +9795,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; ++ } ++ } + +- attr = dwarf2_attr (die, DW_AT_MIPS_linkage_name, cu); +- if (attr && DW_STRING (attr)) +- return DW_STRING (attr); +- return dwarf2_name (die, cu); ++ return name; ++} ++ +/* Return the fully qualified .symtab name for symbols contained in Fortran + modules. Return DWARF2_NAME otherwise. */ + @@ -3861,12 +5086,10 @@ index 243859c..2fccec5 100644 + } + + return name; -+} -+ - /* Get name of a die, return NULL if not found. */ + } - static char * -@@ -11455,6 +12066,34 @@ attr_form_is_constant (struct attribute *attr) + /* Get name of a die, return NULL if not found. */ +@@ -11450,6 +12247,34 @@ attr_form_is_constant (struct attribute *attr) } } @@ -3901,7 +5124,7 @@ index 243859c..2fccec5 100644 static void dwarf2_symbol_mark_computed (struct attribute *attr, struct symbol *sym, struct dwarf2_cu *cu) -@@ -11484,35 +12123,25 @@ dwarf2_symbol_mark_computed (struct attribute *attr, struct symbol *sym, +@@ -11479,35 +12304,25 @@ dwarf2_symbol_mark_computed (struct attribute *attr, struct symbol *sym, SYMBOL_COMPUTED_OPS (sym) = &dwarf2_loclist_funcs; SYMBOL_LOCATION_BATON (sym) = baton; } @@ -3952,7 +5175,7 @@ index 243859c..2fccec5 100644 } } -@@ -11800,6 +12429,31 @@ offset_and_type_eq (const void *item_lhs, const void *item_rhs) +@@ -11795,6 +12610,31 @@ offset_and_type_eq (const void *item_lhs, const void *item_rhs) return ofs_lhs->offset == ofs_rhs->offset; } @@ -3984,7 +5207,7 @@ index 243859c..2fccec5 100644 /* Set the type associated with DIE to TYPE. Save it in CU's hash table if necessary. For convenience, return TYPE. */ -@@ -11808,6 +12462,8 @@ set_die_type (struct die_info *die, struct type *type, struct dwarf2_cu *cu) +@@ -11803,6 +12643,8 @@ set_die_type (struct die_info *die, struct type *type, struct dwarf2_cu *cu) { struct dwarf2_offset_and_type **slot, ofs; @@ -3993,7 +5216,7 @@ index 243859c..2fccec5 100644 /* 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 -@@ -11963,23 +12619,13 @@ show_dwarf2_cmd (char *args, int from_tty) +@@ -11958,23 +12800,13 @@ show_dwarf2_cmd (char *args, int from_tty) cmd_show_list (show_dwarf2_cmdlist, from_tty, ""); } @@ -4021,7 +5244,7 @@ index 243859c..2fccec5 100644 } /* munmap debug sections for OBJFILE, if necessary. */ -@@ -11988,15 +12634,15 @@ static void +@@ -11983,15 +12815,15 @@ static void dwarf2_per_objfile_free (struct objfile *objfile, void *d) { struct dwarf2_per_objfile *data = d; @@ -4046,6 +5269,14 @@ index 243859c..2fccec5 100644 } void _initialize_dwarf2_read (void); +@@ -11999,6 +12831,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 78e9163..4e208d1 100644 --- a/gdb/elfread.c @@ -4104,15 +5335,10 @@ index 78e9163..4e208d1 100644 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 3dbbc8b..4deb82d 100644 +index 27b7895..90c29a3 100644 --- a/gdb/eval.c +++ b/gdb/eval.c -@@ -39,10 +39,12 @@ - #include "exceptions.h" - #include "regcache.h" - #include "user-regs.h" -+#include "python/python.h" - #include "valprint.h" +@@ -43,6 +43,7 @@ #include "gdb_obstack.h" #include "objfiles.h" #include "python/python.h" @@ -4120,7 +5346,7 @@ index 3dbbc8b..4deb82d 100644 #include "gdb_assert.h" -@@ -696,6 +698,7 @@ evaluate_subexp_standard (struct type *expect_type, +@@ -696,6 +697,7 @@ evaluate_subexp_standard (struct type *expect_type, long mem_offset; struct type **arg_types; int save_pos1; @@ -4128,7 +5354,78 @@ index 3dbbc8b..4deb82d 100644 pc = (*pos)++; op = exp->elts[pc].opcode; -@@ -1588,6 +1591,8 @@ evaluate_subexp_standard (struct type *expect_type, +@@ -1332,7 +1334,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)++; + +@@ -1356,21 +1357,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); ++ ++ /* Now, say which argument to start evaluating from */ ++ nargs++; ++ tem = 2; ++ argvec[1] = arg2; ++ break; ++ ++ case TYPE_CODE_MEMBERPTR: ++ /* Now, convert these values to an address. */ ++ arg2 = value_cast (lookup_pointer_type (TYPE_DOMAIN_TYPE (type)), ++ arg2); ++ ++ mem_offset = value_as_long (arg1); ++ ++ arg1 = value_from_pointer (lookup_pointer_type (TYPE_TARGET_TYPE (type)), ++ value_as_long (arg2) + mem_offset); ++ arg1 = value_ind (arg1); ++ tem = 1; ++ break; ++ ++ 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) + { +@@ -1496,8 +1516,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) + { +@@ -1588,6 +1607,8 @@ evaluate_subexp_standard (struct type *expect_type, /* First determine the type code we are dealing with. */ arg1 = evaluate_subexp (NULL_TYPE, exp, pos, noside); @@ -4137,7 +5434,7 @@ index 3dbbc8b..4deb82d 100644 type = check_typedef (value_type (arg1)); code = TYPE_CODE (type); -@@ -1608,6 +1613,7 @@ evaluate_subexp_standard (struct type *expect_type, +@@ -1608,6 +1629,7 @@ evaluate_subexp_standard (struct type *expect_type, code = TYPE_CODE (type); } } @@ -4145,7 +5442,35 @@ index 3dbbc8b..4deb82d 100644 switch (code) { -@@ -2040,13 +2046,19 @@ evaluate_subexp_standard (struct type *expect_type, +@@ -1769,6 +1791,27 @@ evaluate_subexp_standard (struct type *expect_type, + xfree (expect_type); + return arg1; + ++ 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; ++ + case BINOP_CONCAT: + arg1 = evaluate_subexp_with_coercion (exp, pos, noside); + arg2 = evaluate_subexp_with_coercion (exp, pos, noside); +@@ -2040,13 +2083,19 @@ evaluate_subexp_standard (struct type *expect_type, { int subscript_array[MAX_FORTRAN_DIMS]; int array_size_array[MAX_FORTRAN_DIMS]; @@ -4165,7 +5490,7 @@ index 3dbbc8b..4deb82d 100644 tmp_type = check_typedef (value_type (arg1)); ndimensions = calc_f77_array_dims (type); -@@ -2076,6 +2088,9 @@ evaluate_subexp_standard (struct type *expect_type, +@@ -2076,6 +2125,9 @@ evaluate_subexp_standard (struct type *expect_type, upper = f77_get_upperbound (tmp_type); lower = f77_get_lowerbound (tmp_type); @@ -4175,7 +5500,7 @@ index 3dbbc8b..4deb82d 100644 array_size_array[nargs - i - 1] = upper - lower + 1; /* Zero-normalize subscripts so that offsetting will work. */ -@@ -2094,13 +2109,25 @@ evaluate_subexp_standard (struct type *expect_type, +@@ -2094,13 +2146,25 @@ evaluate_subexp_standard (struct type *expect_type, tmp_type = check_typedef (TYPE_TARGET_TYPE (tmp_type)); } @@ -4205,7 +5530,7 @@ index 3dbbc8b..4deb82d 100644 /* Let us now play a dirty trick: we will take arg1 which is a value node pointing to the topmost level -@@ -2110,7 +2137,7 @@ evaluate_subexp_standard (struct type *expect_type, +@@ -2110,7 +2174,7 @@ evaluate_subexp_standard (struct type *expect_type, returns the correct type value */ deprecated_set_value_type (arg1, tmp_type); @@ -4214,7 +5539,7 @@ index 3dbbc8b..4deb82d 100644 } case BINOP_LOGICAL_AND: -@@ -2344,14 +2371,22 @@ evaluate_subexp_standard (struct type *expect_type, +@@ -2344,14 +2408,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); @@ -4239,7 +5564,7 @@ index 3dbbc8b..4deb82d 100644 else if (noside == EVAL_AVOID_SIDE_EFFECTS) { type = check_typedef (value_type (arg1)); -@@ -2360,12 +2395,18 @@ evaluate_subexp_standard (struct type *expect_type, +@@ -2360,12 +2432,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 ) @@ -4263,7 +5588,7 @@ index 3dbbc8b..4deb82d 100644 else error (_("Attempt to take contents of a non-pointer value.")); } -@@ -2375,9 +2416,14 @@ evaluate_subexp_standard (struct type *expect_type, +@@ -2375,9 +2453,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) @@ -4281,7 +5606,7 @@ index 3dbbc8b..4deb82d 100644 case UNOP_ADDR: /* C++: check for and handle pointer to members. */ -@@ -2696,7 +2742,7 @@ evaluate_subexp_with_coercion (struct expression *exp, +@@ -2712,7 +2795,7 @@ evaluate_subexp_with_coercion (struct expression *exp, { enum exp_opcode op; int pc; @@ -4290,7 +5615,7 @@ index 3dbbc8b..4deb82d 100644 struct symbol *var; struct type *type; -@@ -2707,12 +2753,17 @@ evaluate_subexp_with_coercion (struct expression *exp, +@@ -2723,12 +2806,17 @@ evaluate_subexp_with_coercion (struct expression *exp, { case OP_VAR_VALUE: var = exp->elts[pc + 2].symbol; @@ -4309,7 +5634,7 @@ index 3dbbc8b..4deb82d 100644 return value_cast (lookup_pointer_type (TYPE_TARGET_TYPE (type)), val); } -@@ -2764,9 +2815,13 @@ evaluate_subexp_for_sizeof (struct expression *exp, int *pos) +@@ -2780,9 +2868,13 @@ evaluate_subexp_for_sizeof (struct expression *exp, int *pos) case OP_VAR_VALUE: (*pos) += 4; @@ -4327,17 +5652,29 @@ index 3dbbc8b..4deb82d 100644 default: val = evaluate_subexp (NULL_TYPE, exp, pos, EVAL_AVOID_SIDE_EFFECTS); diff --git a/gdb/expression.h b/gdb/expression.h -index e4e8598..ca96b9b 100644 +index ca216cf..2195fef 100644 --- a/gdb/expression.h +++ b/gdb/expression.h -@@ -445,4 +445,5 @@ extern char *op_string (enum exp_opcode); +@@ -95,6 +95,11 @@ enum exp_opcode + 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 */ +@@ -451,4 +456,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-lang.c b/gdb/f-lang.c -index b914b49..79b46d2 100644 +index b914b49..67c7232 100644 --- a/gdb/f-lang.c +++ b/gdb/f-lang.c @@ -31,6 +31,8 @@ @@ -4349,7 +5686,7 @@ index b914b49..79b46d2 100644 /* Following is dubious stuff that had been in the xcoff reader. */ -@@ -306,6 +308,48 @@ f_language_arch_info (struct gdbarch *gdbarch, +@@ -306,6 +308,46 @@ f_language_arch_info (struct gdbarch *gdbarch, lai->bool_type_default = builtin->builtin_logical_s2; } @@ -4361,7 +5698,6 @@ index b914b49..79b46d2 100644 + +static struct symbol * +f_lookup_symbol_nonlocal (const char *name, -+ const char *linkage_name, + const struct block *block, + const domain_enum domain) +{ @@ -4376,7 +5712,7 @@ index b914b49..79b46d2 100644 + struct type *type; + struct symbol *retval; + -+ sym = lookup_symbol_global (use->module_name, NULL, block, MODULE_DOMAIN); ++ sym = lookup_symbol_global (use->module_name, block, MODULE_DOMAIN); + + /* Module name lookup should not fail with correct debug info. */ + if (sym == NULL) @@ -4386,8 +5722,7 @@ index b914b49..79b46d2 100644 + gdb_assert (TYPE_CODE (type) == TYPE_CODE_MODULE); + gdb_assert (TYPE_MODULE_BLOCK (type) != NULL); + -+ retval = lookup_block_symbol (TYPE_MODULE_BLOCK (type), name, -+ linkage_name, domain); ++ retval = lookup_block_symbol (TYPE_MODULE_BLOCK (type), name, domain); + if (retval) + return retval; + } @@ -4398,7 +5733,7 @@ index b914b49..79b46d2 100644 /* 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 +377,7 @@ const struct language_defn f_language_defn = +@@ -333,7 +375,7 @@ const struct language_defn f_language_defn = c_value_print, /* FIXME */ NULL, /* Language specific skip_trampoline */ NULL, /* name_of_this */ @@ -5038,412 +6373,6 @@ 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]); -+ -+ supply_register_by_name ("orig_eax", ((char *) buf) + ORIG_EAX * 4); -+} -+ -+static void -+i386_fill_fpregset (void *buf) -+{ -+ i387_cache_to_fsave (buf); -+} -+ -+static void -+i386_store_fpregset (const void *buf) -+{ -+ i387_fsave_to_cache (buf); -+} -+ -+static void -+i386_fill_fpxregset (void *buf) -+{ -+ i387_cache_to_fxsave (buf); -+} -+ -+static void -+i386_store_fpxregset (const void *buf) -+{ -+ 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; -+ -+static CORE_ADDR -+i386_get_pc () -+{ -+ unsigned long pc; -+ -+ collect_register_by_name ("eip", &pc); -+ -+ if (debug_threads) -+ fprintf (stderr, "stop pc (before any decrement) is %08lx\n", pc); -+ return pc; -+} -+ -+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); -+} -+ -+static int -+i386_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_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 cd24eaf..119af7d 100644 --- a/gdb/gdbthread.h @@ -5470,7 +6399,7 @@ index cd24eaf..119af7d 100644 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 16b34ca..b5e6110 100644 +index 117606a..536bee2 100644 --- a/gdb/gdbtypes.c +++ b/gdb/gdbtypes.c @@ -39,6 +39,9 @@ @@ -5832,7 +6761,7 @@ index 16b34ca..b5e6110 100644 return type; } -@@ -2889,33 +3051,42 @@ type_pair_eq (const void *item_lhs, const void *item_rhs) +@@ -2986,33 +3148,42 @@ type_pair_eq (const void *item_lhs, const void *item_rhs) } /* Allocate the hash table used by copy_type_recursive to walk @@ -5890,7 +6819,7 @@ index 16b34ca..b5e6110 100644 return type; /* This type shouldn't be pointing to any types in other objfiles; -@@ -2930,8 +3101,10 @@ copy_type_recursive (struct objfile *objfile, +@@ -3027,8 +3198,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 @@ -5903,7 +6832,7 @@ index 16b34ca..b5e6110 100644 stored->old = type; stored->new = new_type; *slot = stored; -@@ -2942,6 +3115,19 @@ copy_type_recursive (struct objfile *objfile, +@@ -3039,6 +3212,19 @@ copy_type_recursive (struct objfile *objfile, TYPE_OBJFILE_OWNED (new_type) = 0; TYPE_OWNER (new_type).gdbarch = get_type_arch (type); @@ -5923,7 +6852,7 @@ index 16b34ca..b5e6110 100644 if (TYPE_NAME (type)) TYPE_NAME (new_type) = xstrdup (TYPE_NAME (type)); if (TYPE_TAG_NAME (type)) -@@ -2950,12 +3136,45 @@ copy_type_recursive (struct objfile *objfile, +@@ -3047,12 +3233,45 @@ copy_type_recursive (struct objfile *objfile, TYPE_INSTANCE_FLAGS (new_type) = TYPE_INSTANCE_FLAGS (type); TYPE_LENGTH (new_type) = TYPE_LENGTH (type); @@ -5969,7 +6898,7 @@ index 16b34ca..b5e6110 100644 TYPE_FIELDS (new_type) = XCALLOC (nfields, struct field); for (i = 0; i < nfields; i++) { -@@ -2964,8 +3183,8 @@ copy_type_recursive (struct objfile *objfile, +@@ -3061,8 +3280,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) @@ -5980,7 +6909,7 @@ index 16b34ca..b5e6110 100644 if (TYPE_FIELD_NAME (type, i)) TYPE_FIELD_NAME (new_type, i) = xstrdup (TYPE_FIELD_NAME (type, i)); -@@ -2992,24 +3211,75 @@ copy_type_recursive (struct objfile *objfile, +@@ -3089,24 +3308,75 @@ copy_type_recursive (struct objfile *objfile, } } @@ -6062,7 +6991,7 @@ index 16b34ca..b5e6110 100644 /* Maybe copy the type_specific bits. NOTE drow/2005-12-09: We do not copy the C++-specific bits like -@@ -3027,6 +3297,17 @@ copy_type_recursive (struct objfile *objfile, +@@ -3124,6 +3394,17 @@ copy_type_recursive (struct objfile *objfile, return new_type; } @@ -6080,13 +7009,25 @@ index 16b34ca..b5e6110 100644 /* Make a copy of the given TYPE, except that the pointer & reference types are not preserved. -@@ -3049,6 +3330,199 @@ copy_type (const struct type *type) +@@ -3146,6 +3427,211 @@ copy_type (const struct type *type) return new_type; } +/* Callback type for main_type_crawl. */ +typedef int (*main_type_crawl_iter) (struct type *type, void *data); + ++#if 0 ++ ++/* Allocate a hash table which is used when freeing a struct type. */ ++ ++static htab_t ++create_deleted_types_hash (void) ++{ ++ return htab_create (1, htab_hash_pointer, htab_eq_pointer, NULL); ++} ++ ++#endif ++ +/* Iterate all main_type structures reachable through any `struct type *' from + TYPE. ITER will be called only for one type of each main_type, use + TYPE_CHAIN traversal to find all the type instances. ITER is being called @@ -6280,7 +7221,7 @@ index 16b34ca..b5e6110 100644 /* Helper functions to initialize architecture-specific types. */ -@@ -3539,6 +4013,11 @@ void +@@ -3636,6 +4122,11 @@ void _initialize_gdbtypes (void) { gdbtypes_data = gdbarch_data_register_post_init (gdbtypes_post_init); @@ -6293,7 +7234,7 @@ index 16b34ca..b5e6110 100644 add_setshow_zinteger_cmd ("overload", no_class, &overload_debug, _("\ diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h -index 8e73ca0..85888e1 100644 +index 380f72a..54c8739 100644 --- a/gdb/gdbtypes.h +++ b/gdb/gdbtypes.h @@ -138,6 +138,8 @@ enum type_code @@ -6462,7 +7403,21 @@ index 8e73ca0..85888e1 100644 } type_specific; }; -@@ -900,9 +975,9 @@ extern void allocate_gnat_aux_type (struct type *); +@@ -839,13 +914,6 @@ struct cplus_struct_type + int is_dynamic : 2; + }; + +-/* Struct used in computing virtual base list */ +-struct vbase +- { +- struct type *vbasetype; /* pointer to virtual base */ +- struct vbase *next; /* next in chain */ +- }; +- + /* Struct used for ranking a function for overload resolution */ + struct badness_vector + { +@@ -900,9 +968,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 @@ -6475,7 +7430,7 @@ index 8e73ca0..85888e1 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 -@@ -911,15 +986,26 @@ extern void allocate_gnat_aux_type (struct type *); +@@ -911,15 +979,26 @@ extern void allocate_gnat_aux_type (struct type *); #define TYPE_NFIELDS(thistype) TYPE_MAIN_TYPE(thistype)->nfields #define TYPE_FIELDS(thistype) TYPE_MAIN_TYPE(thistype)->flds_bnds.fields #define TYPE_TEMPLATE_ARGS(thistype) TYPE_CPLUS_SPECIFIC(thistype)->template_args @@ -6504,7 +7459,7 @@ index 8e73ca0..85888e1 100644 /* Moto-specific stuff for FORTRAN arrays */ -@@ -928,11 +1014,23 @@ extern void allocate_gnat_aux_type (struct type *); +@@ -928,11 +1007,23 @@ extern void allocate_gnat_aux_type (struct type *); #define TYPE_ARRAY_LOWER_BOUND_IS_UNDEFINED(arraytype) \ TYPE_LOW_BOUND_UNDEFINED(TYPE_INDEX_TYPE(arraytype)) @@ -6529,7 +7484,7 @@ index 8e73ca0..85888e1 100644 /* C++ */ -@@ -961,6 +1059,7 @@ extern void allocate_gnat_aux_type (struct type *); +@@ -961,6 +1052,7 @@ extern void allocate_gnat_aux_type (struct type *); #define TYPE_GNAT_SPECIFIC(thistype) TYPE_MAIN_TYPE(thistype)->type_specific.gnat_stuff #define TYPE_DESCRIPTIVE_TYPE(thistype) TYPE_GNAT_SPECIFIC(thistype)->descriptive_type #define TYPE_CALLING_CONVENTION(thistype) TYPE_MAIN_TYPE(thistype)->type_specific.calling_convention @@ -6537,7 +7492,7 @@ index 8e73ca0..85888e1 100644 #define TYPE_BASECLASS(thistype,index) TYPE_FIELD_TYPE(thistype, index) #define TYPE_N_BASECLASSES(thistype) TYPE_CPLUS_SPECIFIC(thistype)->n_baseclasses #define TYPE_BASECLASS_NAME(thistype,index) TYPE_FIELD_NAME(thistype, index) -@@ -979,7 +1078,6 @@ extern void allocate_gnat_aux_type (struct type *); +@@ -979,7 +1071,6 @@ extern void allocate_gnat_aux_type (struct type *); #define FIELD_BITPOS(thisfld) ((thisfld).loc.bitpos) #define FIELD_STATIC_PHYSNAME(thisfld) ((thisfld).loc.physname) #define FIELD_STATIC_PHYSADDR(thisfld) ((thisfld).loc.physaddr) @@ -6545,7 +7500,7 @@ index 8e73ca0..85888e1 100644 #define SET_FIELD_BITPOS(thisfld, bitpos) \ (FIELD_LOC_KIND (thisfld) = FIELD_LOC_KIND_BITPOS, \ FIELD_BITPOS (thisfld) = (bitpos)) -@@ -989,9 +1087,6 @@ extern void allocate_gnat_aux_type (struct type *); +@@ -989,9 +1080,6 @@ extern void allocate_gnat_aux_type (struct type *); #define SET_FIELD_PHYSADDR(thisfld, addr) \ (FIELD_LOC_KIND (thisfld) = FIELD_LOC_KIND_PHYSADDR, \ FIELD_STATIC_PHYSADDR (thisfld) = (addr)) @@ -6555,7 +7510,7 @@ index 8e73ca0..85888e1 100644 #define FIELD_ARTIFICIAL(thisfld) ((thisfld).artificial) #define FIELD_BITSIZE(thisfld) ((thisfld).bitsize) -@@ -1002,7 +1097,6 @@ extern void allocate_gnat_aux_type (struct type *); +@@ -1002,7 +1090,6 @@ extern void allocate_gnat_aux_type (struct type *); #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)) #define TYPE_FIELD_STATIC_PHYSADDR(thistype, n) FIELD_STATIC_PHYSADDR (TYPE_FIELD (thistype, n)) @@ -6563,7 +7518,7 @@ index 8e73ca0..85888e1 100644 #define TYPE_FIELD_ARTIFICIAL(thistype, n) FIELD_ARTIFICIAL(TYPE_FIELD(thistype,n)) #define TYPE_FIELD_BITSIZE(thistype, n) FIELD_BITSIZE(TYPE_FIELD(thistype,n)) #define TYPE_FIELD_PACKED(thistype, n) (FIELD_BITSIZE(TYPE_FIELD(thistype,n))!=0) -@@ -1333,6 +1427,18 @@ extern struct type *create_array_type (struct type *, struct type *, +@@ -1333,6 +1420,18 @@ extern struct type *create_array_type (struct type *, struct type *, struct type *); extern struct type *lookup_array_range_type (struct type *, int, int); @@ -6582,16 +7537,16 @@ index 8e73ca0..85888e1 100644 extern struct type *create_string_type (struct type *, struct type *, struct type *); extern struct type *lookup_string_range_type (struct type *, int, int); -@@ -1369,6 +1475,8 @@ extern int get_discrete_bounds (struct type *, LONGEST *, LONGEST *); +@@ -1375,6 +1474,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]) -@@ -1431,10 +1539,11 @@ extern void maintenance_print_type (char *, int); +@@ -1437,10 +1538,11 @@ extern void maintenance_print_type (char *, int); extern htab_t create_copied_types_hash (struct objfile *objfile); @@ -6605,6 +7560,57 @@ index 8e73ca0..85888e1 100644 +extern void free_all_types (void); + #endif /* GDBTYPES_H */ +diff --git a/gdb/gnu-v3-abi.c b/gdb/gnu-v3-abi.c +index 5321401..b1882a2 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" +@@ -456,10 +457,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; +@@ -587,15 +586,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 ff837f2..1710487 100644 --- a/gdb/i386-linux-nat.c @@ -6693,10 +7699,10 @@ index 7317e7d..ea914a5 100644 }; diff --git a/gdb/infcmd.c b/gdb/infcmd.c -index 21a2233..34a3718 100644 +index f99a4ae..5599908 100644 --- a/gdb/infcmd.c +++ b/gdb/infcmd.c -@@ -805,7 +805,7 @@ nexti_command (char *count_string, int from_tty) +@@ -806,7 +806,7 @@ nexti_command (char *count_string, int from_tty) step_1 (1, 1, count_string); } @@ -6705,7 +7711,7 @@ index 21a2233..34a3718 100644 delete_longjmp_breakpoint_cleanup (void *arg) { int thread = * (int *) arg; -@@ -845,10 +845,13 @@ step_1 (int skip_subroutines, int single_inst, char *count_string) +@@ -846,10 +846,13 @@ step_1 (int skip_subroutines, int single_inst, char *count_string) if (!single_inst || skip_subroutines) /* leave si command alone */ { @@ -6719,7 +7725,7 @@ index 21a2233..34a3718 100644 make_cleanup (delete_longjmp_breakpoint_cleanup, &thread); } -@@ -1197,6 +1200,15 @@ signal_command (char *signum_exp, int from_tty) +@@ -1198,6 +1201,15 @@ signal_command (char *signum_exp, int from_tty) proceed ((CORE_ADDR) -1, oursig, 0); } @@ -6735,7 +7741,7 @@ index 21a2233..34a3718 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. -@@ -1213,6 +1225,8 @@ until_next_command (int from_tty) +@@ -1214,6 +1226,8 @@ until_next_command (int from_tty) struct symbol *func; struct symtab_and_line sal; struct thread_info *tp = inferior_thread (); @@ -6744,7 +7750,7 @@ index 21a2233..34a3718 100644 clear_proceed_status (); set_step_frame (); -@@ -1248,7 +1262,19 @@ until_next_command (int from_tty) +@@ -1249,7 +1263,19 @@ until_next_command (int from_tty) tp->step_multi = 0; /* Only one call to proceed */ @@ -6764,7 +7770,7 @@ index 21a2233..34a3718 100644 } static void -@@ -1425,6 +1451,7 @@ finish_command_continuation (void *arg) +@@ -1426,6 +1452,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); @@ -6772,7 +7778,7 @@ index 21a2233..34a3718 100644 } static void -@@ -1508,6 +1535,7 @@ finish_forward (struct symbol *function, struct frame_info *frame) +@@ -1509,6 +1536,7 @@ finish_forward (struct symbol *function, struct frame_info *frame) struct breakpoint *breakpoint; struct cleanup *old_chain; struct finish_command_continuation_args *cargs; @@ -6780,7 +7786,7 @@ index 21a2233..34a3718 100644 sal = find_pc_line (get_frame_pc (frame), 0); sal.pc = get_frame_pc (frame); -@@ -1518,6 +1546,10 @@ finish_forward (struct symbol *function, struct frame_info *frame) +@@ -1519,6 +1547,10 @@ finish_forward (struct symbol *function, struct frame_info *frame) old_chain = make_cleanup_delete_breakpoint (breakpoint); @@ -6792,10 +7798,10 @@ index 21a2233..34a3718 100644 cargs = xmalloc (sizeof (*cargs)); diff --git a/gdb/inferior.h b/gdb/inferior.h -index 9798ef1..e9783fb 100644 +index e557d6c..d4ae1df 100644 --- a/gdb/inferior.h +++ b/gdb/inferior.h -@@ -279,6 +279,8 @@ extern void interrupt_target_command (char *args, int from_tty); +@@ -275,6 +275,8 @@ extern void interrupt_target_command (char *args, int from_tty); extern void interrupt_target_1 (int all_threads); @@ -6805,7 +7811,7 @@ index 9798ef1..e9783fb 100644 extern void notice_new_inferior (ptid_t, int, int); diff --git a/gdb/infrun.c b/gdb/infrun.c -index 426b816..bd65258 100644 +index 06f3ea0..fe3719e 100644 --- a/gdb/infrun.c +++ b/gdb/infrun.c @@ -45,6 +45,8 @@ @@ -6817,7 +7823,7 @@ index 426b816..bd65258 100644 #include "gdb_assert.h" #include "mi/mi-common.h" #include "event-top.h" -@@ -2013,6 +2015,8 @@ static void insert_step_resume_breakpoint_at_sal (struct gdbarch *gdbarch, +@@ -2010,6 +2012,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); @@ -6826,7 +7832,7 @@ index 426b816..bd65258 100644 static void stop_stepping (struct execution_control_state *ecs); static void prepare_to_wait (struct execution_control_state *ecs); -@@ -2942,6 +2946,10 @@ handle_inferior_event (struct execution_control_state *ecs) +@@ -2930,6 +2934,10 @@ handle_inferior_event (struct execution_control_state *ecs) stop_pc = regcache_read_pc (get_thread_regcache (ecs->ptid)); @@ -6837,7 +7843,7 @@ index 426b816..bd65258 100644 ecs->event_thread->stop_bpstat = bpstat_stop_status (get_regcache_aspace (get_current_regcache ()), stop_pc, ecs->ptid); -@@ -3026,6 +3034,10 @@ handle_inferior_event (struct execution_control_state *ecs) +@@ -3014,6 +3022,10 @@ handle_inferior_event (struct execution_control_state *ecs) stop_pc = regcache_read_pc (get_thread_regcache (ecs->ptid)); @@ -6848,7 +7854,7 @@ index 426b816..bd65258 100644 /* Do whatever is necessary to the parent branch of the vfork. */ handle_vfork_child_exec_or_exit (1); -@@ -3784,23 +3796,33 @@ process_event_stop_test: +@@ -3772,23 +3784,33 @@ process_event_stop_test: ecs->event_thread->stepping_over_breakpoint = 1; @@ -6894,7 +7900,7 @@ index 426b816..bd65258 100644 keep_going (ecs); return; -@@ -3812,6 +3834,53 @@ infrun: BPSTAT_WHAT_SET_LONGJMP_RESUME (!gdbarch_get_longjmp_target)\n"); +@@ -3800,6 +3822,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); @@ -6948,7 +7954,7 @@ index 426b816..bd65258 100644 ecs->event_thread->stop_step = 1; print_stop_reason (END_STEPPING_RANGE, 0); stop_stepping (ecs); -@@ -4831,6 +4900,96 @@ insert_longjmp_resume_breakpoint (struct gdbarch *gdbarch, CORE_ADDR pc) +@@ -4819,6 +4888,96 @@ insert_longjmp_resume_breakpoint (struct gdbarch *gdbarch, CORE_ADDR pc) set_momentary_breakpoint_at_pc (gdbarch, pc, bp_longjmp_resume); } @@ -7057,11 +8063,318 @@ index 24b6673..22ed960 100644 op_name_standard, dump_subexp_body_standard, evaluate_subexp_java +diff --git a/gdb/language.h b/gdb/language.h +index aaefb03..c274572 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 74902b6..a9b4f1e 100644 +--- a/gdb/linespec.c ++++ b/gdb/linespec.c +@@ -50,8 +50,6 @@ extern char *operator_chars (char *, char **); + static void initialize_defaults (struct symtab **default_symtab, + int *default_line); + +-static void set_flags (char *arg, int *is_quoted, char **paren_pointer); +- + static struct symtabs_and_lines decode_indirect (char **argptr); + + static char *locate_first_half (char **argptr, int *is_quote_enclosed); +@@ -688,9 +686,6 @@ decode_line_1 (char **argptr, int funfirstline, struct symtab *default_symtab, + struct symtab *file_symtab = NULL; + + char *copy; +- /* This is NULL if there are no parens in *ARGPTR, or a pointer to +- the closing parenthesis if there are parens. */ +- char *paren_pointer; + /* This says whether or not something in *ARGPTR is quoted with + completer_quotes (i.e. with single quotes). */ + int is_quoted; +@@ -711,12 +706,9 @@ decode_line_1 (char **argptr, int funfirstline, struct symtab *default_symtab, + if (**argptr == '*') + return decode_indirect (argptr); + +- /* Set various flags. 'paren_pointer' is important for overload +- checking, where we allow things like: +- (gdb) break c::f(int) +- */ +- +- set_flags (*argptr, &is_quoted, &paren_pointer); ++ is_quoted = (*argptr ++ && strchr (get_gdb_completer_quote_characters (), ++ **argptr) != NULL); + + /* Check to see if it's a multipart linespec (with colons or + periods). */ +@@ -732,10 +724,7 @@ decode_line_1 (char **argptr, int funfirstline, struct symtab *default_symtab, + /* Check if this is an Objective-C method (anything that starts with + a '+' or '-' and a '['). */ + if (is_objc_method_format (p)) +- { +- is_objc_method = 1; +- paren_pointer = NULL; /* Just a category name. Ignore it. */ +- } ++ is_objc_method = 1; + + /* Check if the symbol could be an Objective-C selector. */ + +@@ -749,11 +738,11 @@ decode_line_1 (char **argptr, int funfirstline, struct symtab *default_symtab, + + /* Does it look like there actually were two parts? */ + +- if ((p[0] == ':' || p[0] == '.') && paren_pointer == NULL) ++ if (p[0] == ':' || p[0] == '.') + { + if (is_quoted) + *argptr = *argptr + 1; +- ++ + /* Is it a C++ or Java compound data structure? + The check on p[1] == ':' is capturing the case of "::", + since p[0]==':' was checked above. +@@ -762,48 +751,31 @@ decode_line_1 (char **argptr, int funfirstline, struct symtab *default_symtab, + can return now. */ + + if (p[0] == '.' || p[1] == ':') +- return decode_compound (argptr, funfirstline, canonical, +- saved_arg, p, not_found_ptr); ++ { ++ struct symtabs_and_lines values; ++ ++ if (is_quote_enclosed) ++ ++saved_arg; ++ values = decode_compound (argptr, funfirstline, canonical, ++ saved_arg, p, not_found_ptr); ++ if (is_quoted && **argptr == '\'') ++ *argptr = *argptr + 1; ++ return values; ++ } + + /* No, the first part is a filename; set file_symtab to be that file's + symtab. Also, move argptr past the filename. */ + + file_symtab = symtab_from_filename (argptr, p, is_quote_enclosed, + not_found_ptr); +- } +-#if 0 +- /* No one really seems to know why this was added. It certainly +- breaks the command line, though, whenever the passed +- name is of the form ClassName::Method. This bit of code +- singles out the class name, and if funfirstline is set (for +- example, you are setting a breakpoint at this function), +- you get an error. This did not occur with earlier +- verions, so I am ifdef'ing this out. 3/29/99 */ +- else +- { +- /* Check if what we have till now is a symbol name */ +- +- /* We may be looking at a template instantiation such +- as "foo". Check here whether we know about it, +- instead of falling through to the code below which +- handles ordinary function names, because that code +- doesn't like seeing '<' and '>' in a name -- the +- skip_quoted call doesn't go past them. So see if we +- can figure it out right now. */ +- +- copy = (char *) alloca (p - *argptr + 1); +- memcpy (copy, *argptr, p - *argptr); +- copy[p - *argptr] = '\000'; +- sym = lookup_symbol (copy, 0, VAR_DOMAIN, 0); +- if (sym) ++ if (file_symtab != NULL) + { +- *argptr = (*p == '\'') ? p + 1 : p; +- return symbol_found (funfirstline, canonical, copy, sym, NULL); ++ /* Double-check if the remainder of the argument is quoted. ++ The rbreak command uses syntax like this. */ ++ if (**argptr == '\'') ++ is_quoted = 1; + } +- /* Otherwise fall out from here and go to file/line spec +- processing, etc. */ + } +-#endif + + /* file_symtab is specified file's symtab, or 0 if no file specified. + arg no longer contains the file name. */ +@@ -838,10 +810,6 @@ decode_line_1 (char **argptr, int funfirstline, struct symtab *default_symtab, + /* allow word separators in method names for Obj-C */ + p = skip_quoted_chars (*argptr, NULL, ""); + } +- else if (paren_pointer != NULL) +- { +- p = paren_pointer + 1; +- } + else + { + p = skip_quoted (*argptr); +@@ -851,6 +819,15 @@ decode_line_1 (char **argptr, int funfirstline, struct symtab *default_symtab, + if (*p == '<') + p = find_template_name_end (p); + ++ /* Keep method overload information. */ ++ q = strchr (p, '('); ++ if (q != NULL) ++ p = strrchr (q, ')') + 1; ++ ++ /* Make sure we keep important kewords like "const" */ ++ if (strncmp (p, " const", 6) == 0) ++ p += 6; ++ + copy = (char *) alloca (p - *argptr + 1); + memcpy (copy, *argptr, p - *argptr); + copy[p - *argptr] = '\0'; +@@ -926,44 +903,6 @@ initialize_defaults (struct symtab **default_symtab, int *default_line) + } + } + +-static void +-set_flags (char *arg, int *is_quoted, char **paren_pointer) +-{ +- char *ii; +- int has_if = 0; +- +- /* 'has_if' is for the syntax: +- (gdb) break foo if (a==b) +- */ +- if ((ii = strstr (arg, " if ")) != NULL || +- (ii = strstr (arg, "\tif ")) != NULL || +- (ii = strstr (arg, " if\t")) != NULL || +- (ii = strstr (arg, "\tif\t")) != NULL || +- (ii = strstr (arg, " if(")) != NULL || +- (ii = strstr (arg, "\tif( ")) != NULL) +- has_if = 1; +- /* Temporarily zap out "if (condition)" to not confuse the +- parenthesis-checking code below. This is undone below. Do not +- change ii!! */ +- if (has_if) +- { +- *ii = '\0'; +- } +- +- *is_quoted = (*arg +- && strchr (get_gdb_completer_quote_characters (), +- *arg) != NULL); +- +- *paren_pointer = strchr (arg, '('); +- if (*paren_pointer != NULL) +- *paren_pointer = strrchr (*paren_pointer, ')'); +- +- /* Now that we're safely past the paren_pointer check, put back " if +- (condition)" so outer layers can see it. */ +- if (has_if) +- *ii = ' '; +-} +- + + + /* Decode arg of the form *PC. */ +@@ -1264,7 +1203,8 @@ decode_compound (char **argptr, int funfirstline, char ***canonical, + /* PASS2: p2->"::fun", p->":fun" */ + + /* Move pointer ahead to next double-colon. */ +- while (*p && (p[0] != ' ') && (p[0] != '\t') && (p[0] != '\'')) ++ while (*p && (p[0] != ' ') && (p[0] != '\t') && (p[0] != '\'') ++ && (*p != '(')) + { + if (current_language->la_language == language_cplus) + p += cp_validate_operator (p); +@@ -1342,8 +1282,10 @@ decode_compound (char **argptr, int funfirstline, char ***canonical, + else + { + /* At this point argptr->"fun". */ ++ char *a; + p = *argptr; +- while (*p && *p != ' ' && *p != '\t' && *p != ',' && *p != ':') ++ while (*p && *p != ' ' && *p != '\t' && *p != ',' && *p != ':' ++ && *p != '(') + p++; + /* At this point p->"". String ended. */ + /* Nope, C++ operators could have spaces in them +@@ -1355,6 +1297,19 @@ decode_compound (char **argptr, int funfirstline, char ***canonical, + /* The above loop has already swallowed "operator". */ + p += cp_validate_operator (p - 8) - 8; + } ++ ++ /* Keep any template parameters */ ++ if (*p == '<') ++ p = find_template_name_end (p); ++ ++ /* Keep method overload information. */ ++ a = strchr (p, '('); ++ if (a != NULL) ++ p = strrchr (a, ')') + 1; ++ ++ /* Make sure we keep important kewords like "const" */ ++ if (strncmp (p, " const", 6) == 0) ++ p += 6; + } + + /* Allocate our own copy of the substring between argptr and +@@ -1509,8 +1464,39 @@ find_method (int funfirstline, char ***canonical, char *saved_arg, + } + if (i1 > 0) + { +- /* There is more than one field with that name +- (overloaded). Ask the user which one to use. */ ++ /* If we were given a specific overload instance, use that ++ (or error if no matches were found). Otherwise ask the user ++ which one to use. */ ++ if (strchr (saved_arg, '(') != NULL) ++ { ++ int i; ++ for (i = 0; i < i1; ++i) ++ { ++ char *name = saved_arg; ++ char *canon = cp_canonicalize_string (name); ++ if (canon != NULL) ++ name = canon; ++ ++ if (strcmp_iw (name, SYMBOL_LINKAGE_NAME (sym_arr[i])) == 0) ++ { ++ values.sals = (struct symtab_and_line *) ++ xmalloc (sizeof (struct symtab_and_line)); ++ values.nelts = 1; ++ values.sals[0] = find_function_start_sal (sym_arr[i], ++ funfirstline); ++ if (canon) ++ xfree (canon); ++ return values; ++ } ++ ++ if (canon) ++ xfree (canon); ++ } ++ ++ error (_("the class `%s' does not have any method instance named %s\n"), ++ SYMBOL_PRINT_NAME (sym_class), copy); ++ } ++ + return decode_line_2 (sym_arr, i1, funfirstline, canonical); + } + else +@@ -1815,7 +1801,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 03563cd..8145629 100644 +index 7fc9584..b286dfd 100644 --- a/gdb/linux-nat.c +++ b/gdb/linux-nat.c -@@ -2643,6 +2643,39 @@ linux_nat_stopped_data_address (struct target_ops *ops, CORE_ADDR *addr_p) +@@ -2624,6 +2624,39 @@ linux_nat_stopped_data_address (struct target_ops *ops, CORE_ADDR *addr_p) return lp->stopped_data_address_p; } @@ -7101,7 +8414,7 @@ index 03563cd..8145629 100644 /* Wait until LP is stopped. */ static int -@@ -5519,6 +5552,8 @@ linux_nat_add_target (struct target_ops *t) +@@ -5500,6 +5533,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; @@ -7135,7 +8448,7 @@ index 02b61d3..13ab595 100644 macho_symfile_offsets, /* sym_offsets: xlate external to internal form */ default_symfile_segments, /* sym_segments: Get segment information from diff --git a/gdb/main.c b/gdb/main.c -index 0cc0f75..e3fc2e6 100644 +index e261348..92c63a7 100644 --- a/gdb/main.c +++ b/gdb/main.c @@ -40,6 +40,7 @@ @@ -7181,40 +8494,40 @@ index 0cc0f75..e3fc2e6 100644 case OPT_SE: symarg = optarg; execarg = optarg; -@@ -631,7 +641,31 @@ extern int gdbtk_test (char *); - use_windows = 0; - } +@@ -641,7 +651,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 +@@ -867,7 +901,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. */ @@ -7224,7 +8537,7 @@ index 0cc0f75..e3fc2e6 100644 if (batch) { -@@ -893,13 +928,25 @@ Can't attach to process and specify a core file at the same time.")); +@@ -896,13 +931,25 @@ Can't attach to process and specify a core file at the same time.")); #endif } @@ -7256,7 +8569,7 @@ index 0cc0f75..e3fc2e6 100644 } /* No exit -- exit is through quit_command. */ } -@@ -931,7 +978,12 @@ print_gdb_help (struct ui_file *stream) +@@ -934,7 +981,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\ @@ -7270,7 +8583,7 @@ index 0cc0f75..e3fc2e6 100644 Options:\n\n\ "), stream); fputs_unfiltered (_("\ -@@ -969,7 +1021,13 @@ Options:\n\n\ +@@ -972,7 +1024,13 @@ Options:\n\n\ --nw Do not use a window interface.\n\ --nx Do not read "), stream); fputs_unfiltered (gdbinit, stream); @@ -7314,19 +8627,6 @@ index b227411..3b932f0 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 dde0062..832cfcc 100644 ---- a/gdb/mi/mi-main.c -+++ b/gdb/mi/mi-main.c -@@ -1400,7 +1400,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 4ef817e..1c53574 100644 --- a/gdb/mipsread.c @@ -7431,7 +8731,7 @@ index c689622..eb3ae10 100644 ALL_PSPACE_OBJFILES (ss, objfile) \ ALL_OBJFILE_PSYMTABS (objfile, p) diff --git a/gdb/parse.c b/gdb/parse.c -index 2885506..779b819 100644 +index d5a199b..d2a04c3 100644 --- a/gdb/parse.c +++ b/gdb/parse.c @@ -62,6 +62,7 @@ const struct exp_descriptor exp_descriptor_standard = @@ -7442,7 +8742,18 @@ index 2885506..779b819 100644 op_name_standard, dump_subexp_body_standard, evaluate_subexp_standard -@@ -1359,6 +1360,150 @@ parser_fprintf (FILE *x, const char *y, ...) +@@ -841,6 +842,10 @@ operator_length_standard (struct expression *expr, int endpos, + args = 1; + break; + ++ case TYPE_INSTANCE_LOOKUP: ++ oplen = 3; ++ break; ++ + case OP_OBJC_MSGCALL: /* Objective C message (method) call */ + oplen = 4; + args = 1 + longest_to_int (expr->elts[endpos - 2].longconst); +@@ -1361,6 +1366,150 @@ parser_fprintf (FILE *x, const char *y, ...) va_end (args); } @@ -9691,7 +11002,7 @@ index 0000000..783385e + breakpoint_object_getset /* tp_getset */ +}; diff --git a/gdb/python/py-cmd.c b/gdb/python/py-cmd.c -index ae462d9..22d1405 100644 +index ae462d9..dd364df 100644 --- a/gdb/python/py-cmd.c +++ b/gdb/python/py-cmd.c @@ -49,8 +49,7 @@ static struct cmdpy_completer completers[] = @@ -9704,15 +11015,7 @@ index ae462d9..22d1405 100644 struct cmdpy_object { PyObject_HEAD -@@ -70,7 +69,6 @@ typedef struct cmdpy_object cmdpy_object; - - static PyTypeObject cmdpy_object_type; - -- - /* 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) +@@ -263,10 +262,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. @@ -9728,7 +11031,7 @@ index ae462d9..22d1405 100644 { struct cmd_list_element *elt; int len = strlen (text); -@@ -299,7 +300,7 @@ parse_command_name (char *text, struct cmd_list_element ***base_list) +@@ -299,7 +301,7 @@ parse_command_name (char *text, struct cmd_list_element ***base_list) ; if (i < 0) { @@ -9737,7 +11040,7 @@ index ae462d9..22d1405 100644 return result; } -@@ -308,7 +309,7 @@ parse_command_name (char *text, struct cmd_list_element ***base_list) +@@ -308,7 +310,7 @@ parse_command_name (char *text, struct cmd_list_element ***base_list) prefix_text[i + 1] = '\0'; text = prefix_text; @@ -9746,7 +11049,7 @@ index ae462d9..22d1405 100644 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) +@@ -399,7 +401,7 @@ cmdpy_init (PyObject *self, PyObject *args, PyObject *kw) return -1; } @@ -13419,23 +14722,22 @@ index 9196f08..5230a8c 100644 #endif /* GDB_PYTHON_INTERNAL_H */ diff --git a/gdb/python/python.c b/gdb/python/python.c -index 827372c..171cd5b 100644 +index 29386c9..195dace 100644 --- a/gdb/python/python.c +++ b/gdb/python/python.c -@@ -27,6 +27,7 @@ - #include "observer.h" +@@ -28,6 +28,7 @@ #include "value.h" #include "language.h" + #include "exceptions.h" +#include "event-loop.h" #include -@@ -45,11 +46,18 @@ static int gdbpy_auto_load = 1; +@@ -46,10 +47,17 @@ 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" @@ -13624,7 +14926,7 @@ index 827372c..171cd5b 100644 /* Parse a string and evaluate it as an expression. */ static PyObject * gdbpy_parse_and_eval (PyObject *self, PyObject *args) -@@ -345,6 +452,114 @@ gdbpy_parse_and_eval (PyObject *self, PyObject *args) +@@ -361,6 +468,114 @@ source_python_script (FILE *stream, char *file) @@ -13739,7 +15041,7 @@ index 827372c..171cd5b 100644 /* Printing. */ /* A python function to write a single string using gdb's filtered -@@ -381,6 +596,67 @@ gdbpy_print_stack (void) +@@ -397,6 +612,55 @@ gdbpy_print_stack (void) @@ -13790,38 +15092,12 @@ index 827372c..171cd5b 100644 + exit (0); +} + -+void -+source_python_script (FILE *stream, char *file) -+{ -+ struct cleanup *cleanup; -+ -+ cleanup = ensure_python_env (get_current_arch (), current_language); -+ PyRun_SimpleFile (stream, file); -+ -+ fclose (stream); -+ do_cleanups (cleanup); -+} -+ + + /* 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. */ -@@ -525,6 +801,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 */ - - -@@ -616,14 +899,28 @@ Enables or disables auto-loading of Python code when an object is opened."), +@@ -640,14 +904,28 @@ 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); @@ -13850,7 +15126,7 @@ index 827372c..171cd5b 100644 PyRun_SimpleString ("import gdb"); PyRun_SimpleString ("gdb.pretty_printers = []"); -@@ -659,6 +956,15 @@ class GdbOutputFile:\n\ +@@ -683,6 +961,15 @@ class GdbOutputFile:\n\ \n\ sys.stderr = GdbOutputFile()\n\ sys.stdout = GdbOutputFile()\n\ @@ -13866,7 +15142,7 @@ index 827372c..171cd5b 100644 "); /* Release the GIL while gdb runs. */ -@@ -678,9 +984,14 @@ static PyMethodDef GdbMethods[] = +@@ -702,9 +989,14 @@ static PyMethodDef GdbMethods[] = "Get a value from history" }, { "execute", execute_gdb_command, METH_VARARGS, "Execute a gdb command" }, @@ -13881,7 +15157,7 @@ index 827372c..171cd5b 100644 { "default_visualizer", gdbpy_default_visualizer, METH_VARARGS, "Find the default visualizer for a Value." }, -@@ -701,11 +1012,39 @@ Return a string explaining unwind stop reason." }, +@@ -725,11 +1017,39 @@ Return a string explaining unwind stop reason." }, "lookup_type (name [, block]) -> type\n\ Return a Type corresponding to the given name." }, @@ -13922,25 +15198,23 @@ index 827372c..171cd5b 100644 "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 f35827b..1a5b9a8 100644 +index 5d93f67..1a5b9a8 100644 --- a/gdb/python/python.h +++ b/gdb/python/python.h -@@ -24,6 +24,10 @@ +@@ -26,6 +26,8 @@ void eval_python_from_control_command (struct command_line *); - void eval_python_from_control_command (struct command_line *); + void source_python_script (FILE *stream, char *file); -+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 1d05f8a..e2015c4 100644 +index 5898aad..23e5f22 100644 --- a/gdb/scm-lang.c +++ b/gdb/scm-lang.c -@@ -233,6 +233,7 @@ const struct exp_descriptor exp_descriptor_scm = +@@ -231,6 +231,7 @@ const struct exp_descriptor exp_descriptor_scm = { print_subexp_standard, operator_length_standard, @@ -13948,6 +15222,118 @@ index 1d05f8a..e2015c4 100644 op_name_standard, dump_subexp_body_standard, evaluate_exp +diff --git a/gdb/scm-valprint.c b/gdb/scm-valprint.c +index 1e8d48e..95185d4 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 3c70089..0ee7d85 100644 +--- a/gdb/solib-darwin.c ++++ b/gdb/solib-darwin.c +@@ -408,7 +408,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 94a77fb..7ea68d2 100644 +--- a/gdb/solib-spu.c ++++ b/gdb/solib-spu.c +@@ -326,16 +326,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 826f8bf..4def88d 100644 +--- a/gdb/solib-svr4.c ++++ b/gdb/solib-svr4.c +@@ -1960,7 +1960,6 @@ 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) + { + bfd *abfd; +@@ -1978,8 +1977,7 @@ elf_lookup_lib_symbol (const struct objfile *objfile, + if (abfd == NULL || scan_dyntag (DT_SYMBOLIC, abfd, 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 842b27c..ac1c407 100644 +--- a/gdb/solib.c ++++ b/gdb/solib.c +@@ -1154,13 +1154,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 573f736..51bfce9 100644 +--- a/gdb/solist.h ++++ b/gdb/solist.h +@@ -117,7 +117,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 +@@ -157,7 +156,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 c7beaba..e31164c 100644 --- a/gdb/somread.c @@ -13960,8 +15346,21 @@ index c7beaba..e31164c 100644 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 c6db8dc..7359b50 100644 +--- a/gdb/spu-tdep.c ++++ b/gdb/spu-tdep.c +@@ -1841,7 +1841,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/stack.c b/gdb/stack.c -index 6e198e0..94a3ef9 100644 +index 2caf9d2..7adc399 100644 --- a/gdb/stack.c +++ b/gdb/stack.c @@ -1309,24 +1309,24 @@ backtrace_command_1 (char *count_exp, int show_locals, int from_tty) @@ -14008,10 +15407,10 @@ index 6e198e0..94a3ef9 100644 for (i = 0, fi = trailing; fi && count--; i++, fi = get_prev_frame (fi)) { diff --git a/gdb/symfile.c b/gdb/symfile.c -index 89cc07c..b759f10 100644 +index bc52406..5d5d83f 100644 --- a/gdb/symfile.c +++ b/gdb/symfile.c -@@ -968,13 +968,16 @@ symbol_file_add_with_addrs_or_offsets (bfd *abfd, +@@ -966,13 +966,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. */ @@ -14030,7 +15429,7 @@ index 89cc07c..b759f10 100644 discard_cleanups (my_cleanups); /* We either created a new mapped symbol table, mapped an existing -@@ -1001,6 +1004,8 @@ symbol_file_add_with_addrs_or_offsets (bfd *abfd, +@@ -999,6 +1002,8 @@ symbol_file_add_with_addrs_or_offsets (bfd *abfd, if ((flags & OBJF_READNOW) || readnow_symbol_files) { @@ -14039,7 +15438,7 @@ index 89cc07c..b759f10 100644 if (from_tty || info_verbose) { printf_unfiltered (_("expanding to full symbols...")); -@@ -2323,6 +2328,7 @@ reread_symbols (void) +@@ -2321,6 +2326,7 @@ reread_symbols (void) objfile->symtabs = NULL; objfile->psymtabs = NULL; objfile->psymtabs_addrmap = NULL; @@ -14047,7 +15446,7 @@ index 89cc07c..b759f10 100644 objfile->free_psymtabs = NULL; objfile->cp_namespace_symtab = NULL; objfile->msymbols = NULL; -@@ -2333,6 +2339,8 @@ reread_symbols (void) +@@ -2331,6 +2337,8 @@ reread_symbols (void) memset (&objfile->msymbol_demangled_hash, 0, sizeof (objfile->msymbol_demangled_hash)); @@ -14057,7 +15456,7 @@ index 89cc07c..b759f10 100644 objfile->macro_cache = bcache_xmalloc (); objfile->filename_cache = bcache_xmalloc (); diff --git a/gdb/symfile.h b/gdb/symfile.h -index 7ae819c..f3f6eb3 100644 +index efa069e..b520b93 100644 --- a/gdb/symfile.h +++ b/gdb/symfile.h @@ -139,6 +139,12 @@ struct sym_fns @@ -14073,7 +15472,17 @@ index 7ae819c..f3f6eb3 100644 /* Called when we are finished with an objfile. Should do all cleanup that is specific to the object file format for the particular objfile. */ -@@ -389,7 +395,7 @@ void free_symfile_segment_data (struct symfile_segment_data *data); +@@ -315,8 +321,7 @@ extern int auto_solib_limit; + + extern void set_initial_language (void); + +-extern struct partial_symtab *allocate_psymtab (const char *, +- struct objfile *); ++extern struct partial_symtab *allocate_psymtab (const char *, struct objfile *); + + extern void discard_psymtab (struct partial_symtab *); + +@@ -387,7 +392,7 @@ void free_symfile_segment_data (struct symfile_segment_data *data); /* From dwarf2read.c */ extern int dwarf2_has_info (struct objfile *); @@ -14082,11 +15491,73 @@ index 7ae819c..f3f6eb3 100644 extern void dwarf2_build_psymtabs (struct objfile *); extern void dwarf2_build_frame_info (struct objfile *); +diff --git a/gdb/symmisc.c b/gdb/symmisc.c +index 1f3eb9e..d096d5c 100644 +--- a/gdb/symmisc.c ++++ b/gdb/symmisc.c +@@ -1143,7 +1143,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 `"); +@@ -1160,7 +1160,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 426326d..bac4ca3 100644 +index 426326d..20d90de 100644 --- a/gdb/symtab.c +++ b/gdb/symtab.c -@@ -271,7 +271,7 @@ lookup_partial_symtab (const char *name) +@@ -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); } @@ -14095,7 +15566,7 @@ index 426326d..bac4ca3 100644 { if (FILENAME_CMP (name, pst->filename) == 0) { -@@ -414,7 +414,8 @@ symbol_init_language_specific (struct general_symbol_info *gsymbol, +@@ -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 @@ -14105,7 +15576,16 @@ index 426326d..bac4ca3 100644 { gsymbol->language_specific.cplus_specific.demangled_name = NULL; } -@@ -695,6 +696,7 @@ symbol_natural_name (const struct general_symbol_info *gsymbol) +@@ -498,7 +498,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; +@@ -695,6 +695,7 @@ symbol_natural_name (const struct general_symbol_info *gsymbol) case language_cplus: case language_java: case language_objc: @@ -14113,7 +15593,7 @@ index 426326d..bac4ca3 100644 if (gsymbol->language_specific.cplus_specific.demangled_name != NULL) return gsymbol->language_specific.cplus_specific.demangled_name; break; -@@ -720,6 +722,7 @@ symbol_demangled_name (const struct general_symbol_info *gsymbol) +@@ -720,6 +721,7 @@ symbol_demangled_name (const struct general_symbol_info *gsymbol) case language_cplus: case language_java: case language_objc: @@ -14121,7 +15601,7 @@ index 426326d..bac4ca3 100644 if (gsymbol->language_specific.cplus_specific.demangled_name != NULL) return gsymbol->language_specific.cplus_specific.demangled_name; break; -@@ -931,7 +934,13 @@ find_pc_sect_psymtab (CORE_ADDR pc, struct obj_section *section) +@@ -931,7 +933,13 @@ find_pc_sect_psymtab (CORE_ADDR pc, struct obj_section *section) than the later used TEXTLOW/TEXTHIGH one. */ ALL_OBJFILES (objfile) @@ -14136,7 +15616,7 @@ index 426326d..bac4ca3 100644 { struct partial_symtab *pst; -@@ -964,6 +973,7 @@ find_pc_sect_psymtab (CORE_ADDR pc, struct obj_section *section) +@@ -964,6 +972,7 @@ find_pc_sect_psymtab (CORE_ADDR pc, struct obj_section *section) return pst; } } @@ -14144,7 +15624,7 @@ index 426326d..bac4ca3 100644 /* Existing PSYMTABS_ADDRMAP mapping is present even for PARTIAL_SYMTABs which still have no corresponding full SYMTABs read. But it is not -@@ -1231,6 +1241,22 @@ fixup_psymbol_section (struct partial_symbol *psym, struct objfile *objfile) +@@ -1231,6 +1240,22 @@ fixup_psymbol_section (struct partial_symbol *psym, struct objfile *objfile) return psym; } @@ -14167,7 +15647,266 @@ index 426326d..bac4ca3 100644 /* 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. -@@ -1534,6 +1560,7 @@ lookup_global_symbol_from_objfile (const struct objfile *main_objfile, +@@ -1257,10 +1282,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 +@@ -1270,7 +1299,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); + } +@@ -1292,7 +1320,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); + } +@@ -1311,8 +1338,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; +@@ -1336,9 +1363,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; +@@ -1354,55 +1381,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; + +@@ -1412,11 +1403,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; + +@@ -1427,30 +1418,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 (language == language_cplus ) ++ { ++ sym = cp_lookup_symbol_imports (block_scope (block_iterator), name, ++ block_iterator, domain, 1, 1); + +- if (BLOCK_FUNCTION (block) != NULL && block_inlined_p (block)) +- break; +- block = BLOCK_SUPERBLOCK (block); ++ 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; + } +@@ -1484,13 +1526,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; +@@ -1506,7 +1547,6 @@ lookup_symbol_aux_block (const char *name, const char *linkage_name, + struct symbol * + lookup_global_symbol_from_objfile (const struct objfile *main_objfile, + const char *name, +- const char *linkage_name, + const domain_enum domain) + { + const struct objfile *objfile; +@@ -1525,7 +1565,7 @@ lookup_global_symbol_from_objfile (const struct objfile *main_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; +@@ -1534,16 +1574,16 @@ lookup_global_symbol_from_objfile (const struct objfile *main_objfile, } /* Now go through psymtabs. */ @@ -14175,7 +15914,46 @@ index 426326d..bac4ca3 100644 ALL_OBJFILE_PSYMTABS (objfile, ps) { if (!ps->readin -@@ -1601,7 +1628,7 @@ lookup_symbol_aux_psymtabs (int block_index, const char *name, +- && 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); + } + } +@@ -1558,8 +1598,7 @@ lookup_global_symbol_from_objfile (const struct objfile *main_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; +@@ -1572,7 +1611,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; +@@ -1590,7 +1629,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; +@@ -1601,16 +1639,15 @@ lookup_symbol_aux_psymtabs (int block_index, const char *name, struct symtab *s; const int psymtab_index = (block_index == GLOBAL_BLOCK ? 1 : 0); @@ -14183,8 +15961,148 @@ index 426326d..bac4ca3 100644 + ALL_PSYMTABS_REQUIRED (objfile, ps) { if (!ps->readin - && lookup_partial_symbol (ps, name, linkage_name, -@@ -1886,7 +1913,11 @@ basic_lookup_transparent_type (const char *name) +- && 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 +@@ -1627,7 +1664,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", +@@ -1646,7 +1683,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) + { +@@ -1680,11 +1716,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 +@@ -1692,14 +1728,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; + } +@@ -1709,7 +1744,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) + { +@@ -1719,15 +1753,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 +@@ -1751,14 +1785,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; +@@ -1810,9 +1841,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)) +@@ -1829,15 +1858,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); + } + } + +@@ -1879,22 +1902,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); } } @@ -14195,9 +16113,36 @@ index 426326d..bac4ca3 100644 + call but that would behave nondeterministically. */ + ALL_PSYMTABS_REQUIRED (objfile, ps) { - if (!ps->readin && lookup_partial_symbol (ps, name, NULL, - 1, STRUCT_DOMAIN)) -@@ -1934,7 +1965,12 @@ basic_lookup_transparent_type (const char *name) +- 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 +@@ -1903,7 +1929,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\ +@@ -1927,21 +1953,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); } } @@ -14209,9 +16154,27 @@ index 426326d..bac4ca3 100644 + 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, NULL, 0, STRUCT_DOMAIN)) ++ if (!ps->readin && lookup_partial_symbol (ps, name, 0, STRUCT_DOMAIN)) { -@@ -1975,7 +2011,21 @@ find_main_psymtab (void) + 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 +@@ -1950,7 +1981,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\ +@@ -1975,9 +2006,23 @@ find_main_psymtab (void) struct partial_symtab *pst; struct objfile *objfile; @@ -14223,7 +16186,7 @@ index 426326d..bac4ca3 100644 + require_partial_symbols (objfile); + ALL_OBJFILE_PSYMTABS (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; + } @@ -14232,9 +16195,49 @@ index 426326d..bac4ca3 100644 + + ALL_PSYMTABS_REQUIRED (objfile, pst) { - if (lookup_partial_symbol (pst, main_name (), NULL, 1, VAR_DOMAIN)) +- if (lookup_partial_symbol (pst, main_name (), NULL, 1, VAR_DOMAIN)) ++ if (lookup_partial_symbol (pst, main_name (), 1, VAR_DOMAIN)) { -@@ -3261,7 +3311,7 @@ search_symbols (char *regexp, domain_enum kind, int nfiles, char *files[], + return (pst); + } +@@ -1995,14 +2040,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; +@@ -2015,9 +2056,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; +@@ -2037,9 +2076,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)) +@@ -3261,7 +3298,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. */ @@ -14244,7 +16247,7 @@ index 426326d..bac4ca3 100644 struct partial_symbol **bound, **gbound, **sbound; int keep_going = 1; diff --git a/gdb/symtab.h b/gdb/symtab.h -index 800ffd8..3ed6947 100644 +index 800ffd8..4253f9d 100644 --- a/gdb/symtab.h +++ b/gdb/symtab.h @@ -396,7 +396,10 @@ typedef enum domain_enum_tag @@ -14259,7 +16262,53 @@ index 800ffd8..3ed6947 100644 } domain_enum; -@@ -1065,6 +1068,8 @@ extern void clear_pc_function_cache (void); +@@ -993,7 +996,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); + +@@ -1004,7 +1006,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); + +@@ -1012,7 +1013,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); + +@@ -1021,21 +1021,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 */ +@@ -1065,6 +1062,8 @@ extern void clear_pc_function_cache (void); /* from symtab.c: */ @@ -14268,11 +16317,19 @@ index 800ffd8..3ed6947 100644 /* lookup partial symbol table by filename */ extern struct partial_symtab *lookup_partial_symtab (const char *); +@@ -1367,7 +1366,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 edf8697..a7ed206 100644 +index e6659c9..eabd9fc 100644 --- a/gdb/target.c +++ b/gdb/target.c -@@ -124,6 +124,8 @@ static int debug_to_insert_watchpoint (CORE_ADDR, int, int); +@@ -120,6 +120,8 @@ static int debug_to_insert_watchpoint (CORE_ADDR, int, int); static int debug_to_remove_watchpoint (CORE_ADDR, int, int); @@ -14281,7 +16338,7 @@ index edf8697..a7ed206 100644 static int debug_to_stopped_by_watchpoint (void); static int debug_to_stopped_data_address (struct target_ops *, CORE_ADDR *); -@@ -624,6 +626,7 @@ update_current_target (void) +@@ -583,6 +585,7 @@ update_current_target (void) INHERIT (to_remove_hw_breakpoint, t); INHERIT (to_insert_watchpoint, t); INHERIT (to_remove_watchpoint, t); @@ -14289,7 +16346,7 @@ index edf8697..a7ed206 100644 INHERIT (to_stopped_data_address, t); INHERIT (to_have_steppable_watchpoint, t); INHERIT (to_have_continuable_watchpoint, t); -@@ -747,6 +750,9 @@ update_current_target (void) +@@ -710,6 +713,9 @@ update_current_target (void) de_fault (to_remove_watchpoint, (int (*) (CORE_ADDR, int, int)) return_minus_one); @@ -14299,7 +16356,7 @@ index edf8697..a7ed206 100644 de_fault (to_stopped_by_watchpoint, (int (*) (void)) return_zero); -@@ -3302,6 +3308,19 @@ debug_to_remove_watchpoint (CORE_ADDR addr, int len, int type) +@@ -3277,6 +3283,19 @@ debug_to_remove_watchpoint (CORE_ADDR addr, int len, int type) return retval; } @@ -14319,7 +16376,7 @@ index edf8697..a7ed206 100644 static void debug_to_terminal_init (void) { -@@ -3549,6 +3568,7 @@ setup_target_debug (void) +@@ -3524,6 +3543,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; @@ -14328,10 +16385,10 @@ index edf8697..a7ed206 100644 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 a020bf7..2c5e58e 100644 +index 7103ab2..741b2e5 100644 --- a/gdb/target.h +++ b/gdb/target.h -@@ -419,6 +419,7 @@ struct target_ops +@@ -422,6 +422,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); @@ -14339,7 +16396,7 @@ index a020bf7..2c5e58e 100644 int (*to_stopped_by_watchpoint) (void); int to_have_steppable_watchpoint; int to_have_continuable_watchpoint; -@@ -1262,6 +1263,15 @@ extern char *normal_pid_to_str (ptid_t ptid); +@@ -1274,6 +1275,15 @@ extern char *normal_pid_to_str (ptid_t ptid); #define target_remove_watchpoint(addr, len, type) \ (*current_target.to_remove_watchpoint) (addr, len, type) @@ -14355,7 +16412,7 @@ index a020bf7..2c5e58e 100644 #define target_insert_hw_breakpoint(gdbarch, bp_tgt) \ (*current_target.to_insert_hw_breakpoint) (gdbarch, bp_tgt) -@@ -1302,6 +1312,20 @@ extern int target_search_memory (CORE_ADDR start_addr, +@@ -1314,6 +1324,20 @@ extern int target_search_memory (CORE_ADDR start_addr, ULONGEST pattern_len, CORE_ADDR *found_addrp); @@ -15576,19 +17633,6 @@ index 0ef6c4b..330ed87 100644 + unsupported "$test (no GCC)" + } +} -diff --git a/gdb/testsuite/gdb.base/help.exp b/gdb/testsuite/gdb.base/help.exp -index d71641b..dbe86eb 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/internal-var-field-address.c b/gdb/testsuite/gdb.base/internal-var-field-address.c new file mode 100644 index 0000000..eeb7b85 @@ -15647,24 +17691,6 @@ index 0000000..6d82e73 + +gdb_test {set $varstruct = staticstruct} +gdb_test {p $varstruct.field} " = 1" -diff --git a/gdb/testsuite/gdb.base/radix.exp b/gdb/testsuite/gdb.base/radix.exp -index 9fd6cb5..93aa142 100644 ---- a/gdb/testsuite/gdb.base/radix.exp -+++ b/gdb/testsuite/gdb.base/radix.exp -@@ -163,13 +163,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/vla-overflow.c b/gdb/testsuite/gdb.base/vla-overflow.c new file mode 100644 index 0000000..c5d5ee0 @@ -15957,6 +17983,364 @@ index c990a64..c964db9 100644 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 f81a212..30d362a 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 f4f78a6..11dba06 100644 +--- a/gdb/testsuite/gdb.cp/cplusfuncs.cc ++++ b/gdb/testsuite/gdb.cp/cplusfuncs.cc +@@ -195,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 f322586..443af7a 100644 +--- a/gdb/testsuite/gdb.cp/cplusfuncs.exp ++++ b/gdb/testsuite/gdb.cp/cplusfuncs.exp +@@ -66,9 +66,25 @@ set dm_type_unsigned_int "unsigned" + 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,6 +93,11 @@ 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" + gdb_expect { +@@ -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)" ++ } ++ } + } + + # +@@ -351,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 +@@ -410,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);" + + } + +@@ -426,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)" +@@ -479,7 +622,7 @@ proc test_paddr_operator_functions {} { + } + + 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)" + } + + # +@@ -489,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)" + +@@ -522,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 {} { +diff --git a/gdb/testsuite/gdb.cp/ctti.exp b/gdb/testsuite/gdb.cp/ctti.exp +index 454c6f4..8f88ad7 100644 +--- a/gdb/testsuite/gdb.cp/ctti.exp ++++ b/gdb/testsuite/gdb.cp/ctti.exp +@@ -85,11 +85,6 @@ gdb_test "print c" "\\$\[0-9\]+ = 194 .*" + gdb_test "print f" "\\$\[0-9\]+ = 9" + gdb_test "print i" "\\$\[0-9\]+ = 4" + +-# TODO: this needs more work before actually deploying it. +-# So bail out here. +- +-if { [ test_compiler_info gcc-*] } then { continue } +- + gdb_test_multiple "print add(2,2)" "print add(2,2)" { + -re "\\$\[0-9\]+ = 4\r\n$gdb_prompt $" { + pass "print add(2,2)" +diff --git a/gdb/testsuite/gdb.cp/expand-sals.exp b/gdb/testsuite/gdb.cp/expand-sals.exp +index 25ec4a9..e4fd59b 100644 +--- a/gdb/testsuite/gdb.cp/expand-sals.exp ++++ b/gdb/testsuite/gdb.cp/expand-sals.exp +@@ -46,7 +46,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 @@ -16334,6 +18718,2825 @@ index 0000000..ee9aeff +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 ffffb4c..b406a59 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 6832f3b..baf08d7 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 319552b..0673088 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 4362fd8..f7cfd57 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 +@@ -241,11 +242,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\"." +@@ -255,8 +261,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 1bfa0f3..9fd31a8 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 5b06b31..3e47c77 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/realcpp.cc b/gdb/testsuite/gdb.cp/realcpp.cc +new file mode 100644 +index 0000000..8e4f72a +--- /dev/null ++++ b/gdb/testsuite/gdb.cp/realcpp.cc +@@ -0,0 +1,409 @@ ++#include ++#include ++ ++// Forward decls ++class base; ++class derived; ++ ++// A simple template with specializations ++template ++class tclass ++{ ++public: ++ void do_something () { } // tclass::do_something ++}; ++ ++template <> ++void tclass::do_something () { } // tclass::do_something ++ ++template <> ++void tclass::do_something () { } // tclass::do_something ++ ++template<> ++void tclass::do_something () { } // tclass::do_something ++ ++template<> ++void tclass::do_something () { } // tclass::do_something ++ ++// A simple template with multiple template parameters ++template ++void flubber (void) // flubber ++{ ++ A a; ++ B b; ++ C c; ++ D d; ++ E e; ++ ++ ++a; ++ ++b; ++ ++c; ++ ++d; ++ ++e; ++} ++ ++// Some contrived policies ++template ++struct operation_1 ++{ ++ static void function (void) { } // operation_1::function ++}; ++ ++template ++struct operation_2 ++{ ++ static void function (void) { } // operation_2::function ++}; ++ ++template ++struct operation_3 ++{ ++ static void function (void) { } // operation_3::function ++}; ++ ++template ++struct operation_4 ++{ ++ static void function (void) { } // operation_4::function ++}; ++ ++// A policy-based class w/ and w/o default policy ++template ++class policy : public Policy ++{ ++public: ++ policy (T obj) : obj_ (obj) { } // policy::policy ++ ++private: ++ T obj_; ++}; ++ ++template > ++class policyd : public Policy ++{ ++public: ++ policyd (T obj) : obj_ (obj) { } // policyd::policyd ++ ~policyd (void) { } // policyd::~policyd ++ ++private: ++ T obj_; ++}; ++ ++typedef policy > policy1; ++typedef policy > policy2; ++typedef policy > policy3; ++typedef policy > policy4; ++ ++typedef policyd policyd1; ++typedef policyd policyd2; ++typedef policyd policyd3; ++typedef policyd policyd4; ++typedef policyd > policyd5; ++ ++class fluff { }; ++static fluff *g_fluff = new fluff (); ++ ++class base ++{ ++protected: ++ int foo_; ++ ++public: ++ base (void) : foo_ (42) { } // base::base(void) ++ base (int foo) : foo_ (foo) { } // base::base(int) ++ ~base (void) { } // base::~base ++ ++ // Some overloaded methods ++ int overload (void) const { return 0; } // base::overload(void) const ++ int overload (int i) const { return 1; } // base::overload(int) const ++ int overload (short s) const { return 2; } // base::overload(short) const ++ int overload (long l) const { return 3; } // base::overload(long) const ++ int overload (char* a) const { return 4; } // base::overload(char*) const ++ int overload (base& b) const { return 5; } // base::overload(base&) const ++ ++ // Operators ++ int operator+ (base const& o) const // base::operator+ ++ { return foo_ + o.foo_; } ++ ++ base operator++ (void) // base::operator++ ++ { ++foo_; return *this; } ++ ++ base operator+=(base const& o) // base::operator+= ++ { foo_ += o.foo_; return *this; } ++ ++ int operator- (base const& o) const // base::operator- ++ { return foo_ - o.foo_; } ++ ++ base operator-- (void) // base::operator-- ++ { --foo_; return *this; } ++ ++ base operator-= (base const& o) // base::operator-= ++ { foo_ -= o.foo_; return *this; } ++ ++ int operator* (base const& o) const // base::operator* ++ { return foo_ * o.foo_; } ++ ++ base operator*= (base const& o) // base::operator*= ++ { foo_ *= o.foo_; return *this; } ++ ++ int operator/ (base const& o) const // base::operator/ ++ { return foo_ / o.foo_; } ++ ++ base operator/= (base const& o) // base::operator/= ++ { foo_ /= o.foo_; return *this; } ++ ++ int operator% (base const& o) const // base::operator% ++ { return foo_ % o.foo_; } ++ ++ base operator%= (base const& o) // base::operator%= ++ { foo_ %= o.foo_; return *this; } ++ ++ bool operator< (base const& o) const // base::operator< ++ { return foo_ < o.foo_; } ++ ++ bool operator<= (base const& o) const // base::operator<= ++ { return foo_ <= o.foo_; } ++ ++ bool operator> (base const& o) const // base::operator> ++ { return foo_ > o.foo_; } ++ ++ bool operator>= (base const& o) const // base::operator>= ++ { return foo_ >= o.foo_; } ++ ++ bool operator!= (base const& o) const // base::operator!= ++ { return foo_ != o.foo_; } ++ ++ bool operator== (base const& o) const // base::operator== ++ { return foo_ == o.foo_; } ++ ++ bool operator! (void) const // base::operator! ++ { return !foo_; } ++ ++ bool operator&& (base const& o) const // base::operator&& ++ { return foo_ && o.foo_; } ++ ++ bool operator|| (base const& o) const // base::operator|| ++ { return foo_ || o.foo_; } ++ ++ int operator<< (int value) const // base::operator<< ++ { return foo_ << value; } ++ ++ base operator<<= (int value) // base::operator<<= ++ { foo_ <<= value; return *this; } ++ ++ int operator>> (int value) const // base::operator>> ++ { return foo_ >> value; } ++ ++ base operator>>= (int value) // base::operator>>= ++ { foo_ >>= value; return *this; } ++ ++ int operator~ (void) const // base::operator~ ++ { return ~foo_; } ++ ++ int operator& (base const& o) const // base::operator& ++ { return foo_ & o.foo_; } ++ ++ base operator&= (base const& o) // base::operator&= ++ { foo_ &= o.foo_; return *this; } ++ ++ int operator| (base const& o) const // base::operator| ++ { return foo_ | o.foo_; } ++ ++ base operator|= (base const& o) // base::operator|= ++ { foo_ |= o.foo_; return *this; } ++ ++ int operator^ (base const& o) const // base::operator^ ++ { return foo_ ^ o.foo_; } ++ ++ base operator^= (base const& o) // base::operator^= ++ { foo_ ^= o.foo_; return *this; } ++ ++ base operator= (base const& o) // base::operator= ++ { foo_ = o.foo_; return *this; } ++ ++ void operator() (void) const // base::operator() ++ { return; } ++ ++ int operator[] (int idx) const // base::operator[] ++ { return idx; } ++ ++ void* operator new (size_t size) throw () // base::operator new ++ { return malloc (size); } ++ ++ void operator delete (void* ptr) // base::operator delete ++ { free (ptr); } ++ ++ void* operator new[] (size_t size) throw () // base::operator new[] ++ { return malloc (size); } ++ ++ void operator delete[] (void* ptr) // base::operator delete[] ++ { free (ptr); } ++ ++ base const* operator-> (void) const // base::opeartor-> ++ { return this; } ++ ++ int operator->* (base const& b) const // base::operator->* ++ { return foo_ * b.foo_; } ++ ++ operator char* () const { return const_cast ("hello"); } // base::operator char* ++ operator int () const { return 21; } // base::operator int ++ operator fluff* () const { return new fluff (); } // base::operator fluff* ++ operator fluff** () const { return &g_fluff; } // base::operator fluff** ++}; ++ ++class base1 : public virtual base ++{ ++public: ++ base1 (void) : foo_ (21) { } // base1::base1(void) ++ base1 (int a) : foo_(a) { } // base1::base1(int) ++ void a_function (void) const { } // base1::a_function ++ ++protected: ++ int foo_; ++}; ++ ++class base2 : public virtual base ++{ ++public: ++ base2 () : foo_ (3) { } // base2::base2 ++ ++protected: ++ void a_function (void) const { } // base2::a_function ++ int foo_; ++}; ++ ++class derived : public base1, public base2 ++{ ++ public: ++ derived(void) : foo_ (4) { } // derived::derived ++ void a_function (void) const // derived::a_function ++ { ++ this->base1::a_function (); ++ this->base2::a_function (); ++ } ++ ++ protected: ++ int foo_; ++}; ++ ++int ++main (int argc, char* argv[]) // main ++{ // main ++ derived d; ++ void (derived::*pfunc) (void) const = &derived::a_function; ++ (d.*pfunc) (); ++ ++ base a (1), b (3), c (8); ++ (void) a.overload (); ++ (void) a.overload (static_cast (0)); ++ (void) a.overload (static_cast (0)); ++ (void) a.overload (static_cast (0)); ++ (void) a.overload (static_cast (0)); ++ (void) a.overload (a); ++ ++ int r; ++ r = b + c; ++ ++a; ++ a += b; ++ r = b - c; ++ --a; ++ a -= b; ++ r = b * c; ++ a *= b; ++ r = b / c; ++ a /= b; ++ r = b % c; ++ a %= b; ++ bool x = (b < c); ++ x = (b <= c); ++ x = (b > c); ++ x = (b >= c); ++ x = (b != c); ++ x = (b == c); ++ x = (!b); ++ x = (b && c); ++ x = (b || c); ++ r = b << 2; ++ a <<= 1; ++ r = b >> 2; ++ a >>= 1; ++ r = ~b; ++ r = b & c; ++ a &= c; ++ r = b | c; ++ a |= c; ++ r = b ^ c; ++ a ^= c; ++ a = c; ++ a (); ++ int i = a[3]; ++ derived* f = new derived (); ++ derived* g = new derived[3]; ++ delete f; ++ delete[] g; ++ a->overload (); ++ r = a->*b; ++ ++ tclass char_tclass; ++ tclass int_tclass; ++ tclass short_tclass; ++ tclass long_tclass; ++ tclass base_tclass; ++ char_tclass.do_something (); ++ int_tclass.do_something (); ++ short_tclass.do_something (); ++ long_tclass.do_something (); ++ base_tclass.do_something (); ++ ++ flubber (); ++ flubber (); ++ flubber (); ++ flubber (); ++ flubber (); ++ flubber (); ++ flubber (); ++ flubber (); ++ flubber (); ++ flubber (); ++ flubber (); ++ flubber (); ++ flubber (); ++ flubber (); ++ flubber (); ++ flubber (); ++ flubber (); ++ flubber (); ++ flubber (); ++ flubber (); ++ flubber (); ++ flubber (); ++ flubber (); ++ ++ policy1 p1 (1); ++ p1.function (); ++ policy2 p2 (2); ++ p2.function (); ++ policy3 p3 (3); ++ p3.function (); ++ policy4 p4 (4); ++ p4.function (); ++ ++ policyd1 pd1 (5); ++ pd1.function (); ++ policyd2 pd2 (6); ++ pd2.function (); ++ policyd3 pd3 (7); ++ pd3.function (); ++ policyd4 pd4 (d); ++ pd4.function (); ++ policyd5 pd5 (int_tclass); ++ pd5.function (); ++ ++ base1 b1 (3); ++ ++ r = a; ++ char* str = a; ++ fluff* flp = a; ++ fluff** flpp = a; ++} ++ +diff --git a/gdb/testsuite/gdb.cp/realcpp.exp b/gdb/testsuite/gdb.cp/realcpp.exp +new file mode 100644 +index 0000000..4e92e75 +--- /dev/null ++++ b/gdb/testsuite/gdb.cp/realcpp.exp +@@ -0,0 +1,891 @@ ++# 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 . ++ ++# This file is part of the gdb testsuite. ++ ++### ++# ++# SOME IMPORTANT NOTES ++# ++### ++ ++# The "info func" tests here aren't complete. I've commented them ++# out for now. ++ ++# A helper proc which sets a breakpoint at FUNC and attempts to ++# run to the breakpoint. ++proc test_breakpoint {func} { ++ global DEC ++ ++ # Restart every time ++ if {![runto_main]} { ++ perror "could not run to main when attempting to break at $func" ++ continue ++ } else { ++ gdb_breakpoint "$func" ++ set i [expr {[string last : $func] + 1}] ++ set efunc [escape [string range $func $i end]] ++ gdb_test "continue" \ ++ "Continuing.\r\n\r\nBreakpoint $DEC+,.*$efunc.*" \ ++ "continue to $func" ++ } ++} ++ ++# Escape expect-reserved characters in the string ++proc escape {string} { ++ regsub -all {\*} $string {\*} string ++ regsub -all {\(} $string {\(} string ++ regsub -all {\)} $string {\)} string ++ regsub -all {\]} $string {\]} string ++ regsub -all {\[} $string {\[} string ++ regsub -all {\+} $string {\+} string ++ regsub -all {\^} $string {\^} string ++ regsub -all {\!} $string {\!} string ++ return $string ++} ++ ++# Add a function to the list of tested functions ++# FUNC is the name of the function (which will be passed to gdb commands) ++# TYPE is the type of the function, as expected from the "print" command ++# PRINT is the name of the function, as expected result of the print command ++# *OR* "-", indicating that FUNC should be used (needed for virtual/inherited ++# funcs) ++# LST is either the expected result of the list command (the comment from ++# the source code) *OR* "-", in which case FUNC will be used ++# INF is the expected result of "info func" ++# ++# If any of PRINT, LST, or INF is "", the test will be skipped ++# ++# Usage: ++# add NAME TYPE PRINT LST INFO ++# add NAME TYPE PRINT - INFO ++proc add {func type print lst inf} { ++ global all_functions CONVAR ADDR ++ ++ set all_functions($func,type) $type ++ if {$print == "-"} { ++ set print $func ++ } ++ ++ # An exception: since gdb canonicalizes C++ output, ++ # "(void)" must be mutated to "()". ++ set print [regsub {\(void\)} $print {()}] ++ ++ set all_functions($func,print) \ ++ "$CONVAR = {[escape $type]} $ADDR <[escape $print].*>" ++ if {$lst == "-"} { ++ set lst "$func" ++ } ++ set all_functions($func,list) ".*// [escape $lst]" ++ set all_functions($func,info_func) $inf ++} ++ ++proc get {func cmd} { ++ global all_functions ++ return $all_functions($func,$cmd) ++} ++ ++# Returns a list of function names for a given command ++proc get_functions {cmd} { ++ global all_functions ++ set result {} ++ foreach i [array names all_functions *,$cmd] { ++ if {$all_functions($i) != ""} { ++ set idx [string last , $i] ++ if {$idx != -1} { ++ lappend result [string range $i 0 [expr {$idx - 1}]] ++ } ++ } ++ } ++ ++ return [lsort $result] ++} ++ ++# Some convenience variables for this test ++set DEC {[0-9]}; # a decimal number ++set HEX {[0-9a-fA-F]}; # a hexidecimal number ++set CONVAR "\\\$$DEC+"; # convenience variable regexp ++set ADDR "0x$HEX+"; # address ++ ++# An array of functions/methods that we are testing... ++# Each element consists is indexed by NAME,COMMAND, where ++# NAME is the function name and COMMAND is the gdb command that ++# we are testing. The value of the array for any index pair is ++# the expected result of running COMMAND with the NAME as argument. ++# If the value is blank, the test will be skipped for the given function. ++ ++# The array holding all functions/methods to test. Valid subindexes ++# are (none need character escaping -- "add" will take care of that): ++ ++# add name type print_name list info_func ++# NAME,type: value is type of function ++# NAME,print: value is print name of function (careful w/inherited/virtual!) ++# NAME,list: value is comment in source code on first line of function ++# (without the leading "//") ++# NAME,info_func: value is the expected result of "info func" ++array set all_functions {} ++ ++# "Normal" functions/methods ++add {main} \ ++ {int (int, char **)} \ ++ - \ ++ - \ ++ {int main(int, char **);} ++add {derived::a_function} \ ++ {void (const derived * const)} \ ++ - \ ++ - \ ++ {void derived::a_function();} ++add {base1::a_function} \ ++ {void (const base1 * const)} \ ++ - \ ++ - \ ++ {void base1::a_function();} ++add {base2::a_function} \ ++ {void (const base2 * const)} \ ++ - \ ++ - \ ++ {void base2::a_function();} ++ ++# Constructors ++add {derived::derived} \ ++ {void (derived * const)} \ ++ - \ ++ - \ ++ {void derived::derived();} ++add {base1::base1(void)} \ ++ {void (base1 * const, const void ** const)} \ ++ - \ ++ - \ ++ {void base1::base1();} ++add {base1::base1(int)} \ ++ {void (base1 * const, int)} \ ++ - \ ++ - \ ++ {void base1::base1(int);} ++add {base2::base2} \ ++ {void (base2 * const, const void ** const)} \ ++ - \ ++ - \ ++ {void base2::base2();} ++add {base::base(void)} \ ++ {void (base * const)} \ ++ - \ ++ - \ ++ {void base::base();} ++add {base::base(int)} \ ++ {void (base * const, int)} \ ++ - \ ++ - \ ++ {void base::base();} ++ ++# Destructors ++add {base::~base} \ ++ {void (base * const)} \ ++ - \ ++ - \ ++ {void base::~base();} ++ ++# Overloaded methods (all are const -- we try to use the void ++# method with and without specifying "const") ++add {base::overload(void)} \ ++ {int (const base * const)} \ ++ - \ ++ {base::overload(void) const} \ ++ {int base::overload() const;} ++add {base::overload(void) const} \ ++ {int (const base * const)} \ ++ - \ ++ {base::overload(void) const} \ ++ {int base::overload() const;} ++add {base::overload(int) const} \ ++ {int (const base * const, int)} \ ++ - \ ++ - \ ++ {int base::overload(int) const;} ++add {base::overload(short) const} \ ++ {int (const base * const, short)} \ ++ - \ ++ - \ ++ {int base::overload(short) const;} ++add {base::overload(long) const} \ ++ {int (const base * const, long)} \ ++ - \ ++ - \ ++ {int base::overload(long) const;} ++add {base::overload(char*) const} \ ++ {int (const base * const, char *)} \ ++ - \ ++ - \ ++ {int base::overload(char *) const;} ++add {base::overload(base&) const} \ ++ {int (const base * const, base &)} \ ++ - \ ++ - \ ++ {int base::overload(base &) const;} ++ ++# Operators ++add {base::operator+} \ ++ {int (const base * const, const base &)} \ ++ - \ ++ - \ ++ - ++add {base::operator++} \ ++ {base (base * const)} \ ++ - \ ++ - \ ++ - ++add {base::operator+=} \ ++ {base (base * const, const base &)} \ ++ - \ ++ - \ ++ - ++add {base::operator-} \ ++ {int (const base * const, const base &)} \ ++ - \ ++ - \ ++ - ++add {base::operator--} \ ++ {base (base * const)} \ ++ - \ ++ - \ ++ - ++add {base::operator-=} \ ++ {base (base * const, const base &)} \ ++ - \ ++ - \ ++ - ++add {base::operator*} \ ++ {int (const base * const, const base &)} \ ++ - \ ++ - \ ++ - ++add {base::operator*=} \ ++ {base (base * const, const base &)} \ ++ - \ ++ - \ ++ - ++add {base::operator/} \ ++ {int (const base * const, const base &)} \ ++ - \ ++ - \ ++ - ++add {base::operator/=} \ ++ {base (base * const, const base &)} \ ++ - \ ++ - \ ++ - ++add {base::operator%} \ ++ {int (const base * const, const base &)} \ ++ - \ ++ - \ ++ - ++add {base::operator%=} \ ++ {base (base * const, const base &)} \ ++ - \ ++ - \ ++ - ++add {base::operator<} \ ++ {bool (const base * const, const base &)} \ ++ - \ ++ - \ ++ - ++add {base::operator<=} \ ++ {bool (const base * const, const base &)} \ ++ - \ ++ - \ ++ - ++add {base::operator>} \ ++ {bool (const base * const, const base &)} \ ++ - \ ++ - \ ++ - ++add {base::operator>=} \ ++ {bool (const base * const, const base &)} \ ++ - \ ++ - \ ++ - ++add {base::operator!=} \ ++ {bool (const base * const, const base &)} \ ++ - \ ++ - \ ++ - ++add {base::operator==} \ ++ {bool (const base * const, const base &)} \ ++ - \ ++ - \ ++ - ++add {base::operator!} \ ++ {bool (const base * const)} \ ++ - \ ++ - \ ++ - ++add {base::operator&&} \ ++ {bool (const base * const, const base &)} \ ++ - \ ++ - \ ++ - ++add {base::operator||} \ ++ {bool (const base * const, const base &)} \ ++ - \ ++ - \ ++ - ++add {base::operator<<} \ ++ {int (const base * const, int)} \ ++ - \ ++ - \ ++ - ++add {base::operator<<=} \ ++ {base (base * const, int)} \ ++ - \ ++ - \ ++ - ++add {base::operator>>} \ ++ {int (const base * const, int)} \ ++ - \ ++ - \ ++ - ++add {base::operator>>=} \ ++ {base (base * const, int)} \ ++ - \ ++ - \ ++ - ++add {base::operator~} \ ++ {int (const base * const)} \ ++ - \ ++ - \ ++ - ++add {base::operator&} \ ++ {int (const base * const, const base &)} \ ++ - \ ++ - \ ++ - ++add {base::operator&=} \ ++ {base (base * const, const base &)} \ ++ - \ ++ - \ ++ - ++add {base::operator|} \ ++ {int (const base * const, const base &)} \ ++ - \ ++ - \ ++ - ++add {base::operator|=} \ ++ {base (base * const, const base &)} \ ++ - \ ++ - \ ++ - ++add {base::operator^} \ ++ {int (const base * const, const base &)} \ ++ - \ ++ - \ ++ - ++add {base::operator^=} \ ++ {base (base * const, const base &)} \ ++ - \ ++ - \ ++ - ++add {base::operator=} \ ++ {base (base * const, const base &)} \ ++ - \ ++ - \ ++ - ++add {base::operator()} \ ++ {void (const base * const)} \ ++ - \ ++ - \ ++ - ++add {base::operator[]} \ ++ {int (const base * const, int)} \ ++ - \ ++ - \ ++ - ++add {base::operator new} \ ++ {void *(size_t)} \ ++ - \ ++ - \ ++ - ++add {base::operator delete} \ ++ {void (void *)} \ ++ - \ ++ - \ ++ - ++add {base::operator new[]} \ ++ {void *(size_t)} \ ++ - \ ++ - \ ++ - ++add {base::operator delete[]} \ ++ {void (void *)} \ ++ - \ ++ - \ ++ - ++add {base::operator char*} \ ++ {char *(const base * const)} \ ++ - \ ++ - \ ++ - ++add {base::operator fluff*} \ ++ {fluff *(const base * const)} \ ++ - \ ++ - \ ++ - ++add {base::operator fluff**} \ ++ {fluff **(const base * const)} \ ++ - \ ++ - \ ++ - ++add {base::operator int} \ ++ {int (const base * const)} \ ++ - \ ++ - \ ++ - ++ ++# Templates ++add {tclass::do_something} \ ++ {void (tclass * const)} \ ++ - \ ++ - \ ++ - ++add {tclass::do_something} \ ++ {void (tclass * const)} \ ++ - \ ++ - \ ++ - ++add {tclass::do_something} \ ++ {void (tclass * const)} \ ++ - \ ++ - \ ++ - ++add {tclass::do_something} \ ++ {void (tclass * const)} \ ++ - \ ++ - \ ++ - ++add {tclass::do_something} \ ++ {void (tclass * const)} \ ++ - \ ++ - \ ++ - ++add {flubber} \ ++ {void (void)} \ ++ - \ ++ flubber \ ++ - ++add {flubber} \ ++ {void (void)} \ ++ - \ ++ flubber \ ++ - ++add {flubber} \ ++ {void (void)} \ ++ - \ ++ flubber \ ++ - ++add {flubber} \ ++ {void (void)} \ ++ - \ ++ flubber \ ++ - ++add {flubber} \ ++ {void (void)} \ ++ - \ ++ flubber \ ++ - ++add {flubber} \ ++ {void (void)} \ ++ - \ ++ flubber \ ++ - ++add {flubber} \ ++ {void (void)} \ ++ - \ ++ flubber \ ++ - ++add {flubber} \ ++ {void (void)} \ ++ - \ ++ flubber \ ++ - ++add {flubber} \ ++ {void (void)} \ ++ - \ ++ flubber \ ++ - ++add {flubber} \ ++ {void (void)} \ ++ - \ ++ flubber \ ++ - ++add {flubber} \ ++ {void (void)} \ ++ - \ ++ flubber \ ++ - ++add {flubber} \ ++ {void (void)} \ ++ - \ ++ flubber \ ++ - ++add {flubber} \ ++ {void (void)} \ ++ - \ ++ flubber \ ++ - ++add {flubber} \ ++ {void (void)} \ ++ - \ ++ flubber \ ++ - ++add {flubber} \ ++ {void (void)} \ ++ - \ ++ flubber \ ++ - ++add {flubber} \ ++ {void (void)} \ ++ - \ ++ flubber \ ++ - ++add {flubber} \ ++ {void (void)} \ ++ - \ ++ flubber \ ++ - ++add {flubber} \ ++ {void (void)} \ ++ - \ ++ flubber \ ++ - ++add {flubber} \ ++ {void (void)} \ ++ - \ ++ flubber \ ++ - ++add {flubber} \ ++ {void (void)} \ ++ - \ ++ flubber \ ++ - ++add {flubber} \ ++ {void (void)} \ ++ - \ ++ flubber \ ++ - ++add {flubber} \ ++ {void (void)} \ ++ - \ ++ flubber \ ++ - ++add {flubber} \ ++ {void (void)} \ ++ - \ ++ flubber \ ++ - ++add {tclass::do_something} \ ++ {void (tclass * const)} \ ++ - \ ++ {tclass::do_something} \ ++ - ++add {policy1::policy} \ ++ {void (policy > * const, int)} \ ++ {policy >::policy} \ ++ {policy::policy} \ ++ - ++add {policy2::policy} \ ++ {void (policy > * const, int)} \ ++ {policy >::policy} \ ++ {policy::policy} \ ++ - ++add {policy3::policy} \ ++ {void (policy > * const, int)} \ ++ {policy >::policy} \ ++ {policy::policy} \ ++ - ++add {policy4::policy} \ ++ {void (policy > * const, int)} \ ++ {policy >::policy} \ ++ {policy::policy} \ ++ - ++add {policy1::function} \ ++ {void (void)} \ ++ {operation_1::function} \ ++ {operation_1::function} \ ++ - ++add {policy2::function} \ ++ {void (void)} \ ++ {operation_2::function} \ ++ {operation_2::function} \ ++ - ++add {policy3::function} \ ++ {void (void)} \ ++ {operation_3::function} \ ++ {operation_3::function} \ ++ - ++add {policy4::function} \ ++ {void (void)} \ ++ {operation_4::function} \ ++ {operation_4::function} \ ++ - ++add {policyd >::policyd} \ ++ {void (policyd > * const, int)} \ ++ - \ ++ {policyd::policyd} \ ++ - ++add {policyd1::policyd} \ ++ {void (policyd > * const, int)} \ ++ {policyd >::policyd} \ ++ {policyd::policyd} \ ++ - ++add {policyd >::~policyd} \ ++ {void (policyd > * const)} \ ++ - \ ++ {policyd::~policyd} \ ++ - ++add {policyd1::~policyd} \ ++ {void (policyd > * const)} \ ++ {policyd >::~policyd} \ ++ {policyd::~policyd} \ ++ - ++add {policyd >::policyd} \ ++ {void (policyd > * const, long)} \ ++ - \ ++ {policyd::policyd} \ ++ - ++add {policyd2::policyd} \ ++ {void (policyd > * const, long)} \ ++ {policyd >::policyd} \ ++ {policyd::policyd} \ ++ - ++add {policyd >::~policyd} \ ++ {void (policyd > * const)} \ ++ - \ ++ {policyd::~policyd} \ ++ - ++add {policyd2::~policyd} \ ++ {void (policyd > * const)} \ ++ {policyd >::~policyd} \ ++ {policyd::~policyd} \ ++ - ++add {policyd >::policyd} \ ++ {void (policyd > * const, char)} \ ++ - \ ++ {policyd::policyd} \ ++ - ++add {policyd3::policyd} \ ++ {void (policyd > * const, char)} \ ++ {policyd >::policyd} \ ++ {policyd::policyd} \ ++ - ++add {policyd >::~policyd} \ ++ {void (policyd > * const)} \ ++ - \ ++ {policyd::~policyd} \ ++ - ++add {policyd3::~policyd} \ ++ {void (policyd > * const)} \ ++ {policyd >::~policyd} \ ++ {policyd::~policyd} \ ++ - ++add {policyd >::policyd} \ ++ {void (policyd > * const, base)} \ ++ - \ ++ {policyd::policyd} \ ++ - ++add {policyd4::policyd} \ ++ {void (policyd > * const, base)} \ ++ {policyd >::policyd} \ ++ {policyd::policyd} \ ++ - ++add {policyd >::~policyd} \ ++ {void (policyd > * const)} \ ++ - \ ++ {policyd::~policyd} \ ++ - ++add {policyd4::~policyd} \ ++ {void (policyd > * const)} \ ++ {policyd >::~policyd} \ ++ {policyd::~policyd} \ ++ - ++add {policyd, operation_1 > >::policyd} \ ++ {void (policyd, operation_1 > > * const, tclass)} \ ++ - \ ++ {policyd::policyd} \ ++ - ++add {policyd5::policyd} \ ++ {void (policyd, operation_1 > > * const, tclass)} \ ++ {policyd, operation_1 > >::policyd} \ ++ {policyd::policyd} \ ++ - ++add {policyd, operation_1 > >::~policyd} \ ++ {void (policyd, operation_1 > > * const)} \ ++ - \ ++ {policyd::~policyd} \ ++ - ++add {policyd5::~policyd} \ ++ {void (policyd, operation_1 > > * const)} \ ++ {policyd, operation_1 > >::~policyd} \ ++ {policyd::~policyd} \ ++ - ++add {policyd >::function} \ ++ {void (void)} \ ++ {operation_1::function}\ ++ {operation_1::function} \ ++ - ++add {policyd1::function} \ ++ {void (void)} \ ++ {operation_1::function} \ ++ {operation_1::function} \ ++ - ++add {policyd2::function} \ ++ {void (void)} \ ++ {operation_1::function} \ ++ {operation_1::function} \ ++ - ++add {policyd >::function} \ ++ {void (void)} \ ++ {operation_1::function} \ ++ {operation_1::function} \ ++ - ++add {policyd3::function} \ ++ {void (void)} \ ++ {operation_1::function} \ ++ {operation_1::function} \ ++ - ++add {policyd >::function} \ ++ {void (void)} \ ++ {operation_1::function} \ ++ {operation_1::function} \ ++ - ++add {policyd4::function} \ ++ {void (void)} \ ++ {operation_1::function} \ ++ {operation_1::function} \ ++ - ++add {policyd, operation_1 > >::function} \ ++ {void (void)} \ ++ {operation_1 >::function} \ ++ {operation_1::function} \ ++ - ++add {policyd5::function} \ ++ {void (void)} \ ++ {operation_1 >::function} \ ++ {operation_1::function} \ ++ - ++# The below test default template arguments ++add {policyd::policyd} \ ++ {void (policyd > * const, int)} \ ++ - \ ++ {policyd::policyd} \ ++ - ++add {policyd::policyd} \ ++ {void (policyd > * const, long)} \ ++ - \ ++ {policyd::policyd} \ ++ - ++add {policyd::policyd} \ ++ {void (policyd > * const, char)} \ ++ - \ ++ {policyd::policyd} \ ++ - ++add {policyd::policyd} \ ++ {void (policyd > * const, base)} \ ++ - \ ++ {policyd::policyd} \ ++ - ++add {policyd >::policyd} \ ++ {void (policyd >, operation_1 > > * const, int)} \ ++ - \ ++ {policyd::policyd} \ ++ - ++ ++# Start the test ++if {$tracelevel} { ++ strace $tracelevel ++} ++ ++if {[skip_cplus_tests]} { continue } ++ ++# ++# test running programs ++# ++set prms_id 0 ++set bug_id 0 ++ ++set testfile "realcpp" ++set srcfile "${testfile}.cc" ++set binfile [file join $objdir $subdir $testfile] ++ ++if {[gdb_compile [file join $srcdir $subdir $srcfile] $binfile \ ++ executable {debug c++}] != "" } { ++ untested "$testfile.exp" ++ return -1 ++} ++ ++if {[get_compiler_info $binfile "c++"]} { ++ return -1 ++} ++ ++gdb_exit ++gdb_start ++gdb_reinitialize_dir [file join $srcdir $subdir] ++gdb_load $binfile ++ ++# Set the listsize to one. This will help with testing "list". ++gdb_test "set listsize 1" ++ ++# "print METHOD" ++foreach name [get_functions print] { ++ gdb_test "print $name" [get $name print] "print $name" ++} ++ ++# "list METHOD" ++foreach name [get_functions list] { ++ gdb_test "list $name" [get $name list] "list $name" ++} ++ ++# Running to breakpoint -- use any function we can "list" ++foreach name [get_functions list] { ++ # Skip "main", since test_breakpoint uses it ++ if {[string compare $name "main"] != 0} { ++ test_breakpoint $name ++ } ++} ++ ++# "info func METHOD" ++if {false} { ++foreach name [get_functions "info_func"] { ++ regsub -all {\*} $name {\*} n ++ regsub -all {\^} $n {\^} n ++ regsub -all {\]} $n {\]} n ++ regsub -all {\[} $n {\[} n ++ gdb_test "info func $n" [get $name info_func] "info func $name" ++} ++} ++ ++# What of these is not covered by above? ++# operator-specific tests ('p a + b', 'print cout << "hello"', etc) ++# overloaded operators & ctors ++# operator names with spaces in them (other than delete and new) ++# ptype of classes/templates ++# backtraces ++# printing data members ++# catching, throwing exceptions ++# STL (esp containers and iterators) ++# inheritance tests ++# completion scoping ++ ++gdb_exit ++return 0 +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 @@ -16526,6 +21729,169 @@ index 0000000..39632d5 + +# Failed gdb_load would abort the testcase execution earlier. +pass "file loaded" +diff --git a/gdb/testsuite/gdb.dwarf2/dw2-empty-namespace.S b/gdb/testsuite/gdb.dwarf2/dw2-empty-namespace.S +new file mode 100644 +index 0000000..7b03ff1 +--- /dev/null ++++ b/gdb/testsuite/gdb.dwarf2/dw2-empty-namespace.S +@@ -0,0 +1,108 @@ ++/* 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 . */ ++ ++/* Test G++ 4.1 producing DW_TAG_namespace with DW_AT_name "::". */ ++ ++ .data ++var: .4byte 1 ++ ++ .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 "file1.txt\0" /* DW_AT_name */ ++ .ascii "GNU C 3.3.3\0" /* DW_AT_producer */ ++ .byte 4 /* DW_LANG_C_plus_plus (C++) */ ++ ++.Ltype_int: ++ .uleb128 2 /* Abbrev: DW_TAG_base_type */ ++ .ascii "int\0" /* DW_AT_name */ ++ .byte 4 /* DW_AT_byte_size */ ++ .byte 5 /* DW_AT_encoding */ ++ ++ .uleb128 3 /* Abbrev: DW_TAG_namespace */ ++ .ascii "::\0" /* DW_AT_name */ ++ ++ .uleb128 7 /* Abbrev: DW_TAG_variable (location) */ ++ .ascii "var\0" /* DW_AT_name */ ++ .byte 2f - 1f /* DW_AT_location */ ++1: .byte 3 /* DW_OP_addr */ ++ .4byte var /* */ ++2: .4byte .Ltype_int-.Lcu1_begin /* DW_AT_type */ ++ ++ .byte 0 /* End of children of DW_TAG_namespace */ ++ ++ .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 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 */ ++ ++ .uleb128 3 /* Abbrev code */ ++ .uleb128 0x39 /* DW_TAG_namespace */ ++ .byte 1 /* has_children */ ++ .uleb128 0x3 /* DW_AT_name */ ++ .uleb128 0x8 /* DW_FORM_string */ ++ .byte 0x0 /* Terminator */ ++ .byte 0x0 /* Terminator */ ++ ++ .uleb128 7 /* Abbrev code (location) */ ++ .uleb128 0x34 /* DW_TAG_variable */ ++ .byte 0 /* has_children */ ++ .uleb128 0x3 /* DW_AT_name */ ++ .uleb128 0x8 /* DW_FORM_string */ ++ .uleb128 0x2 /* DW_AT_location */ ++ .uleb128 0xa /* DW_FORM_block1 */ ++ .uleb128 0x49 /* DW_AT_type */ ++ .uleb128 0x13 /* DW_FORM_ref4 */ ++ .byte 0x0 /* Terminator */ ++ .byte 0x0 /* Terminator */ ++ ++ .byte 0x0 /* Terminator */ ++ .byte 0x0 /* Terminator */ +diff --git a/gdb/testsuite/gdb.dwarf2/dw2-empty-namespace.exp b/gdb/testsuite/gdb.dwarf2/dw2-empty-namespace.exp +new file mode 100644 +index 0000000..1a8da16 +--- /dev/null ++++ b/gdb/testsuite/gdb.dwarf2/dw2-empty-namespace.exp +@@ -0,0 +1,43 @@ ++# 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 G++ 4.1 producing DW_TAG_namespace with DW_AT_name "::". ++ ++# 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-empty-namespace" ++set srcfile ${testfile}.S ++set executable ${testfile}.x ++ ++if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${objdir}/${subdir}/${executable}" object {nodebug}] != "" } { ++ return -1 ++} ++ ++clean_restart $executable ++ ++# `p var' below can work without identified DWARF DIE just based on its ELF symbol. ++# Catch it here as `type = '. ++gdb_test "ptype var" "type = int" ++ ++gdb_test "p var" " = 1" 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 @@ -18452,44 +23818,6 @@ index aa4e519..f87277d 100644 # 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 951c295..9dd0c12 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 new file mode 100644 index 0000000..4dc308b @@ -19033,6 +24361,27 @@ index 0000000..1dc93ab +if {[istarget "*-*-linux*"]} { + test child FOLLOW_CHILD +} +diff --git a/gdb/testsuite/lib/cp-support.exp b/gdb/testsuite/lib/cp-support.exp +index 6fbee84..1189cfd 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 diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp index 9b06a2f..419d5a9 100644 --- a/gdb/testsuite/lib/gdb.exp @@ -19126,10 +24475,10 @@ index 16a207c..c3cff06 100644 { struct thread_info *tp, *next; diff --git a/gdb/top.c b/gdb/top.c -index 85e7b62..b4f0bf7 100644 +index 90e8f1e..489e24a 100644 --- a/gdb/top.c +++ b/gdb/top.c -@@ -346,6 +346,7 @@ void +@@ -337,6 +337,7 @@ void prepare_execute_command (void) { free_all_values (); @@ -19194,8 +24543,120 @@ index ce9f551..5f9d739 100644 } static void +diff --git a/gdb/typeprint.h b/gdb/typeprint.h +index 7d7e6bc..6ee65cf 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 e6aaf93..1760b4c 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 "gdb_select.h" + +@@ -264,7 +265,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 + { +@@ -298,6 +299,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 6155699..bb94f4b 100644 +--- a/gdb/ui-file.h ++++ b/gdb/ui-file.h +@@ -20,6 +20,7 @@ + #ifndef UI_FILE_H + #define UI_FILE_H + ++struct obstack; + struct ui_file; + + /* Create a generic ui_file object with null methods. */ +@@ -78,7 +79,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 82a66a1..c305506 100644 +--- a/gdb/utils.c ++++ b/gdb/utils.c +@@ -2656,7 +2656,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) +@@ -2681,7 +2684,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 2b66f85..9c36e56 100644 +index ed76b09..8bf3634 100644 --- a/gdb/valarith.c +++ b/gdb/valarith.c @@ -139,7 +139,6 @@ an integer nor a pointer of the same type.")); @@ -19285,7 +24746,7 @@ index 2b66f85..9c36e56 100644 } diff --git a/gdb/valops.c b/gdb/valops.c -index 1667368..e1a6bef 100644 +index ca34083..c23fd68 100644 --- a/gdb/valops.c +++ b/gdb/valops.c @@ -38,6 +38,7 @@ @@ -19305,7 +24766,7 @@ index 1667368..e1a6bef 100644 range_type = create_range_type ((struct type *) NULL, TYPE_TARGET_TYPE (range_type), low_bound, -@@ -570,6 +569,64 @@ value_one (struct type *type, enum lval_type lv) +@@ -822,6 +821,64 @@ value_one (struct type *type, enum lval_type lv) return val; } @@ -19370,7 +24831,7 @@ index 1667368..e1a6bef 100644 /* Helper function for value_at, value_at_lazy, and value_at_lazy_stack. */ static struct value * -@@ -661,15 +718,21 @@ value_fetch_lazy (struct value *val) +@@ -913,15 +970,21 @@ value_fetch_lazy (struct value *val) } else if (VALUE_LVAL (val) == lval_memory) { @@ -19399,7 +24860,7 @@ index 1667368..e1a6bef 100644 } } else if (VALUE_LVAL (val) == lval_register) -@@ -1077,7 +1140,18 @@ address_of_variable (struct symbol *var, struct block *b) +@@ -1329,7 +1392,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) { @@ -19419,7 +24880,7 @@ index 1667368..e1a6bef 100644 return value_from_pointer (lookup_pointer_type (type), addr); } -@@ -1183,6 +1257,7 @@ struct value * +@@ -1435,6 +1509,7 @@ struct value * value_coerce_array (struct value *arg1) { struct type *type = check_typedef (value_type (arg1)); @@ -19427,7 +24888,7 @@ index 1667368..e1a6bef 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 -@@ -1192,8 +1267,12 @@ value_coerce_array (struct value *arg1) +@@ -1444,8 +1519,12 @@ value_coerce_array (struct value *arg1) if (VALUE_LVAL (arg1) != lval_memory) error (_("Attempt to take address of value not located in memory.")); @@ -19441,7 +24902,94 @@ index 1667368..e1a6bef 100644 } /* Given a value which is a function, return a value which is a pointer -@@ -3042,8 +3121,6 @@ value_slice (struct value *array, int lowbound, int length) +@@ -2328,12 +2407,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, +@@ -2353,16 +2445,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 C++ name, try to extract just the function +- part. */ +- if (qualified_name) +- func_name = cp_func_name (qualified_name); ++ /* 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 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; ++ } ++ } + +- /* 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; +@@ -3096,7 +3201,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); + +@@ -3240,7 +3345,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) + { + if (complain) +@@ -3294,8 +3399,6 @@ value_slice (struct value *array, int lowbound, int length) || lowbound + length - 1 > upperbound) error (_("slice out of range")); @@ -19734,7 +25282,7 @@ index a462ee4..968cdf4 100644 + observer_attach_mark_used (value_types_mark_used); } diff --git a/gdb/value.h b/gdb/value.h -index 8ac62b8..051c8c5 100644 +index 42b4497..6f9923c 100644 --- a/gdb/value.h +++ b/gdb/value.h @@ -342,11 +342,16 @@ extern LONGEST unpack_field_as_long (struct type *type, @@ -19754,7 +25302,7 @@ index 8ac62b8..051c8c5 100644 extern struct value *value_at (struct type *type, CORE_ADDR addr); extern struct value *value_at_lazy (struct type *type, CORE_ADDR addr); -@@ -684,7 +689,7 @@ extern struct value *value_allocate_space_in_inferior (int); +@@ -689,7 +694,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, @@ -19764,7 +25312,7 @@ index 8ac62b8..051c8c5 100644 /* User function handler. */ diff --git a/gdb/varobj.c b/gdb/varobj.c -index 46d6b34..0536753 100644 +index 6ec87b3..b274ade 100644 --- a/gdb/varobj.c +++ b/gdb/varobj.c @@ -26,6 +26,8 @@ @@ -19776,75 +25324,20 @@ index 46d6b34..0536753 100644 #include "gdb_assert.h" #include "gdb_string.h" -@@ -3468,6 +3470,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. */ - -@@ -3485,6 +3500,43 @@ all_root_varobjs (void (*func) (struct varobj *var, void *data), void *data) +@@ -3495,7 +3497,7 @@ 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 + _initialize_varobj (void) diff --git a/gdb/xcoffread.c b/gdb/xcoffread.c -index 6301b61..47c2acb 100644 +index 25cc2d9..6784654 100644 --- a/gdb/xcoffread.c +++ b/gdb/xcoffread.c -@@ -3035,6 +3035,7 @@ static struct sym_fns xcoff_sym_fns = +@@ -3030,6 +3030,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 */ diff --git a/gdb-bz539590-gnu-ifunc.patch b/gdb-bz539590-gnu-ifunc.patch index fb4f56d..a5ce160 100644 --- a/gdb-bz539590-gnu-ifunc.patch +++ b/gdb-bz539590-gnu-ifunc.patch @@ -1,41 +1,65 @@ -gdb/ -2009-11-24 Jan Kratochvil +http://sourceware.org/gdb/wiki/ProjectArcher +http://sourceware.org/gdb/wiki/ArcherBranchManagement - 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. +GIT snapshot: +commit 791165df07fd22d381def1318954c389a606f81a -gdb/testsuite/ -2009-11-24 Jan Kratochvil +archer-jankratochvil-ifunc - 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.50.20100115/gdb/elfread.c +Index: gdb-7.0.50.20100121/gdb/alpha-linux-tdep.c =================================================================== ---- gdb-7.0.50.20100115.orig/gdb/elfread.c 2010-01-15 11:45:34.000000000 +0100 -+++ gdb-7.0.50.20100115/gdb/elfread.c 2010-01-15 12:17:16.000000000 +0100 +--- gdb-7.0.50.20100121.orig/gdb/alpha-linux-tdep.c 2010-01-01 08:31:29.000000000 +0100 ++++ gdb-7.0.50.20100121/gdb/alpha-linux-tdep.c 2010-01-21 15:15:41.000000000 +0100 +@@ -26,6 +26,7 @@ + #include "symtab.h" + #include "regset.h" + #include "regcache.h" ++#include "linux-tdep.h" + + #include "alpha-tdep.h" + +@@ -236,6 +237,9 @@ alpha_linux_init_abi (struct gdbarch_inf + + set_gdbarch_regset_from_core_section + (gdbarch, alpha_linux_regset_from_core_section); ++ ++ set_gdbarch_convert_from_func_ptr_addr (gdbarch, ++ linux_convert_from_func_ptr_addr); + } + + /* Provide a prototype to silence -Wmissing-prototypes. */ +Index: gdb-7.0.50.20100121/gdb/amd64-linux-tdep.c +=================================================================== +--- gdb-7.0.50.20100121.orig/gdb/amd64-linux-tdep.c 2010-01-21 15:13:26.000000000 +0100 ++++ gdb-7.0.50.20100121/gdb/amd64-linux-tdep.c 2010-01-21 15:15:41.000000000 +0100 +@@ -1557,6 +1557,9 @@ amd64_linux_init_abi (struct gdbarch_inf + amd64_linux_record_tdep.arg6 = AMD64_R9_REGNUM; + + tdep->i386_syscall_record = amd64_linux_syscall_record; ++ ++ set_gdbarch_convert_from_func_ptr_addr (gdbarch, ++ linux_convert_from_func_ptr_addr); + } + + +Index: gdb-7.0.50.20100121/gdb/arm-linux-tdep.c +=================================================================== +--- gdb-7.0.50.20100121.orig/gdb/arm-linux-tdep.c 2010-01-01 08:31:29.000000000 +0100 ++++ gdb-7.0.50.20100121/gdb/arm-linux-tdep.c 2010-01-21 15:15:41.000000000 +0100 +@@ -907,6 +907,9 @@ arm_linux_init_abi (struct gdbarch_info + set_gdbarch_displaced_step_free_closure (gdbarch, + simple_displaced_step_free_closure); + set_gdbarch_displaced_step_location (gdbarch, displaced_step_at_entry_point); ++ ++ set_gdbarch_convert_from_func_ptr_addr (gdbarch, ++ linux_convert_from_func_ptr_addr); + } + + /* Provide a prototype to silence -Wmissing-prototypes. */ +Index: gdb-7.0.50.20100121/gdb/elfread.c +=================================================================== +--- gdb-7.0.50.20100121.orig/gdb/elfread.c 2010-01-21 15:13:27.000000000 +0100 ++++ gdb-7.0.50.20100121/gdb/elfread.c 2010-01-21 15:15:41.000000000 +0100 @@ -184,7 +184,8 @@ record_minimal_symbol (const char *name, { struct gdbarch *gdbarch = get_objfile_arch (objfile); @@ -58,10 +82,80 @@ Index: gdb-7.0.50.20100115/gdb/elfread.c } else if ((sym->name[0] == '.' && sym->name[1] == 'L') || ((sym->flags & BSF_LOCAL) -Index: gdb-7.0.50.20100115/gdb/gdbtypes.c +Index: gdb-7.0.50.20100121/gdb/frv-linux-tdep.c =================================================================== ---- gdb-7.0.50.20100115.orig/gdb/gdbtypes.c 2010-01-15 03:22:31.000000000 +0100 -+++ gdb-7.0.50.20100115/gdb/gdbtypes.c 2010-01-15 12:16:49.000000000 +0100 +--- gdb-7.0.50.20100121.orig/gdb/frv-linux-tdep.c 2010-01-01 08:31:32.000000000 +0100 ++++ gdb-7.0.50.20100121/gdb/frv-linux-tdep.c 2010-01-21 15:15:41.000000000 +0100 +@@ -32,6 +32,7 @@ + #include "frame-unwind.h" + #include "regset.h" + #include "gdb_string.h" ++#include "linux-tdep.h" + + /* Define the size (in bytes) of an FR-V instruction. */ + static const int frv_instr_size = 4; +@@ -486,7 +487,21 @@ frv_linux_regset_from_core_section (stru + return NULL; + } + +- ++static CORE_ADDR ++frv_linux_convert_from_func_ptr_addr (struct gdbarch *gdbarch, ++ CORE_ADDR addr, ++ struct target_ops *targ) ++{ ++ CORE_ADDR pc = frv_convert_from_func_ptr_addr (gdbarch, addr, targ); ++ CORE_ADDR resolved; ++ ++ resolved = linux_convert_from_func_and_ptr (gdbarch, addr, pc); ++ if (resolved != pc) ++ pc = frv_convert_from_func_ptr_addr (gdbarch, resolved, targ); ++ ++ return pc; ++} ++ + static void + frv_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) + { +@@ -494,6 +509,10 @@ frv_linux_init_abi (struct gdbarch_info + frame_unwind_append_unwinder (gdbarch, &frv_linux_sigtramp_frame_unwind); + set_gdbarch_regset_from_core_section (gdbarch, + frv_linux_regset_from_core_section); ++ ++ if (frv_abi (gdbarch) == FRV_ABI_FDPIC) ++ set_gdbarch_convert_from_func_ptr_addr (gdbarch, ++ frv_linux_convert_from_func_ptr_addr); + } + + static enum gdb_osabi +Index: gdb-7.0.50.20100121/gdb/frv-tdep.c +=================================================================== +--- gdb-7.0.50.20100121.orig/gdb/frv-tdep.c 2010-01-01 08:31:32.000000000 +0100 ++++ gdb-7.0.50.20100121/gdb/frv-tdep.c 2010-01-21 15:15:41.000000000 +0100 +@@ -1169,7 +1169,7 @@ find_func_descr (struct gdbarch *gdbarch + return descr; + } + +-static CORE_ADDR ++CORE_ADDR + frv_convert_from_func_ptr_addr (struct gdbarch *gdbarch, CORE_ADDR addr, + struct target_ops *targ) + { +Index: gdb-7.0.50.20100121/gdb/frv-tdep.h +=================================================================== +--- gdb-7.0.50.20100121.orig/gdb/frv-tdep.h 2010-01-01 08:31:32.000000000 +0100 ++++ gdb-7.0.50.20100121/gdb/frv-tdep.h 2010-01-21 15:15:41.000000000 +0100 +@@ -118,3 +118,6 @@ CORE_ADDR frv_fetch_objfile_link_map (st + struct target_so_ops; + extern struct target_so_ops frv_so_ops; + ++CORE_ADDR frv_convert_from_func_ptr_addr (struct gdbarch *gdbarch, ++ CORE_ADDR addr, ++ struct target_ops *targ); +Index: gdb-7.0.50.20100121/gdb/gdbtypes.c +=================================================================== +--- gdb-7.0.50.20100121.orig/gdb/gdbtypes.c 2010-01-21 15:13:26.000000000 +0100 ++++ gdb-7.0.50.20100121/gdb/gdbtypes.c 2010-01-21 15:15:41.000000000 +0100 @@ -1946,6 +1946,8 @@ init_type (enum type_code code, int leng TYPE_NOTTEXT (type) = 1; if (flags & TYPE_FLAG_FIXED_INSTANCE) @@ -71,16 +165,16 @@ Index: gdb-7.0.50.20100115/gdb/gdbtypes.c if (name) TYPE_NAME (type) = obsavestring (name, strlen (name), -@@ -3846,6 +3848,8 @@ gdbtypes_post_init (struct gdbarch *gdba +@@ -3955,6 +3957,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)); ++ builtin_type->builtin_func_func ++ = lookup_function_type (builtin_type->builtin_func_ptr); /* This type represents a GDB internal function. */ builtin_type->internal_fn -@@ -3962,6 +3966,11 @@ objfile_type (struct objfile *objfile) +@@ -4071,6 +4075,11 @@ objfile_type (struct objfile *objfile) "", objfile); TYPE_TARGET_TYPE (objfile_type->nodebug_text_symbol) = objfile_type->builtin_int; @@ -92,10 +186,10 @@ Index: gdb-7.0.50.20100115/gdb/gdbtypes.c objfile_type->nodebug_data_symbol = init_type (TYPE_CODE_INT, gdbarch_int_bit (gdbarch) / HOST_CHAR_BIT, 0, -Index: gdb-7.0.50.20100115/gdb/gdbtypes.h +Index: gdb-7.0.50.20100121/gdb/gdbtypes.h =================================================================== ---- gdb-7.0.50.20100115.orig/gdb/gdbtypes.h 2010-01-15 11:49:26.000000000 +0100 -+++ gdb-7.0.50.20100115/gdb/gdbtypes.h 2010-01-15 12:16:49.000000000 +0100 +--- gdb-7.0.50.20100121.orig/gdb/gdbtypes.h 2010-01-21 15:14:41.000000000 +0100 ++++ gdb-7.0.50.20100121/gdb/gdbtypes.h 2010-01-21 15:16:39.000000000 +0100 @@ -188,6 +188,7 @@ enum type_flag_value TYPE_FLAG_FIXED_INSTANCE = (1 << 15), TYPE_FLAG_STUB_SUPPORTED = (1 << 16), @@ -125,18 +219,18 @@ Index: gdb-7.0.50.20100115/gdb/gdbtypes.h unsigned int flag_fixed_instance : 1; unsigned int flag_objfile_owned : 1; unsigned int flag_discardable : 1; -@@ -1250,6 +1258,10 @@ struct builtin_type +@@ -1243,6 +1251,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. ++ /* `function returning pointer to function (returning void)' type. + The final void return type is not significant for it. */ -+ struct type *builtin_func_func_ptr; ++ struct type *builtin_func_func; + /* Special-purpose types. */ -@@ -1292,6 +1304,7 @@ struct objfile_type +@@ -1285,6 +1297,7 @@ struct objfile_type /* Types used for symbols with no debug information. */ struct type *nodebug_text_symbol; @@ -144,77 +238,260 @@ Index: gdb-7.0.50.20100115/gdb/gdbtypes.h struct type *nodebug_data_symbol; struct type *nodebug_unknown_symbol; struct type *nodebug_tls_symbol; -Index: gdb-7.0.50.20100115/gdb/infcall.c +Index: gdb-7.0.50.20100121/gdb/hppa-linux-tdep.c =================================================================== ---- gdb-7.0.50.20100115.orig/gdb/infcall.c 2010-01-01 08:31:36.000000000 +0100 -+++ gdb-7.0.50.20100115/gdb/infcall.c 2010-01-15 12:16:49.000000000 +0100 -@@ -286,6 +286,27 @@ find_function_addr (struct value *functi - else - error (_("Invalid data type for function to be called.")); +--- gdb-7.0.50.20100121.orig/gdb/hppa-linux-tdep.c 2010-01-01 08:31:33.000000000 +0100 ++++ gdb-7.0.50.20100121/gdb/hppa-linux-tdep.c 2010-01-21 15:15:41.000000000 +0100 +@@ -32,6 +32,7 @@ + #include "regset.h" + #include "regcache.h" + #include "hppa-tdep.h" ++#include "linux-tdep.h" -+ if (TYPE_GNU_IFUNC (ftype)) -+ { -+ struct type *func_func_ptr; + #include "elf/common.h" + +@@ -513,7 +514,21 @@ hppa_linux_regset_from_core_section (str + + return NULL; + } +- + -+ funaddr += gdbarch_deprecated_function_start_offset (gdbarch); ++static CORE_ADDR ++hppa32_linux_convert_from_func_ptr_addr (struct gdbarch *gdbarch, ++ CORE_ADDR addr, ++ struct target_ops *targ) ++{ ++ CORE_ADDR pc = hppa32_convert_from_func_ptr_addr (gdbarch, addr, targ); ++ CORE_ADDR resolved; + -+ /* Cast FUNADDR to drop TYPE_GNU_IFUNC and being able to call gnu-ifunc -+ FUNADDR without causing deadlock by this block of code. */ ++ resolved = linux_convert_from_func_and_ptr (gdbarch, addr, pc); ++ if (resolved != pc) ++ pc = hppa32_convert_from_func_ptr_addr (gdbarch, resolved, targ); + -+ func_func_ptr = builtin_type (gdbarch)->builtin_func_func_ptr; -+ function = value_from_pointer (func_func_ptr, funaddr); ++ return pc; ++} + + /* Forward declarations. */ + extern initialize_file_ftype _initialize_hppa_linux_tdep; +@@ -555,6 +570,10 @@ hppa_linux_init_abi (struct gdbarch_info + /* Enable TLS support. */ + set_gdbarch_fetch_tls_load_module_address (gdbarch, + svr4_fetch_objfile_link_map); + -+ /* 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.50.20100115/gdb/linespec.c ++ if (tdep->bytes_per_address == 4) ++ set_gdbarch_convert_from_func_ptr_addr (gdbarch, ++ hppa32_linux_convert_from_func_ptr_addr); + } + + void +Index: gdb-7.0.50.20100121/gdb/hppa-tdep.c =================================================================== ---- gdb-7.0.50.20100115.orig/gdb/linespec.c 2010-01-12 06:48:56.000000000 +0100 -+++ gdb-7.0.50.20100115/gdb/linespec.c 2010-01-15 12:16:49.000000000 +0100 -@@ -40,6 +40,7 @@ - #include "interps.h" - #include "mi/mi-cmds.h" +--- gdb-7.0.50.20100121.orig/gdb/hppa-tdep.c 2010-01-19 10:39:12.000000000 +0100 ++++ gdb-7.0.50.20100121/gdb/hppa-tdep.c 2010-01-21 15:15:41.000000000 +0100 +@@ -1247,7 +1247,7 @@ hppa64_return_value (struct gdbarch *gdb + } + + +-static CORE_ADDR ++CORE_ADDR + hppa32_convert_from_func_ptr_addr (struct gdbarch *gdbarch, CORE_ADDR addr, + struct target_ops *targ) + { +Index: gdb-7.0.50.20100121/gdb/hppa-tdep.h +=================================================================== +--- gdb-7.0.50.20100121.orig/gdb/hppa-tdep.h 2010-01-01 08:31:33.000000000 +0100 ++++ gdb-7.0.50.20100121/gdb/hppa-tdep.h 2010-01-21 15:15:41.000000000 +0100 +@@ -246,4 +246,8 @@ extern int hppa_in_solib_call_trampoline + CORE_ADDR pc, char *name); + extern CORE_ADDR hppa_skip_trampoline_code (struct frame_info *, CORE_ADDR pc); + ++extern CORE_ADDR hppa32_convert_from_func_ptr_addr (struct gdbarch *gdbarch, ++ CORE_ADDR addr, ++ struct target_ops *targ); ++ + #endif /* hppa-tdep.h */ +Index: gdb-7.0.50.20100121/gdb/i386-linux-tdep.c +=================================================================== +--- gdb-7.0.50.20100121.orig/gdb/i386-linux-tdep.c 2010-01-04 15:57:43.000000000 +0100 ++++ gdb-7.0.50.20100121/gdb/i386-linux-tdep.c 2010-01-21 15:15:41.000000000 +0100 +@@ -798,6 +798,9 @@ i386_linux_init_abi (struct gdbarch_info + i386_linux_get_syscall_number); + + set_gdbarch_get_siginfo_type (gdbarch, linux_get_siginfo_type); ++ ++ set_gdbarch_convert_from_func_ptr_addr (gdbarch, ++ linux_convert_from_func_ptr_addr); + } + + /* Provide a prototype to silence -Wmissing-prototypes. */ +Index: gdb-7.0.50.20100121/gdb/ia64-linux-tdep.c +=================================================================== +--- gdb-7.0.50.20100121.orig/gdb/ia64-linux-tdep.c 2010-01-01 08:31:36.000000000 +0100 ++++ gdb-7.0.50.20100121/gdb/ia64-linux-tdep.c 2010-01-21 15:15:41.000000000 +0100 +@@ -26,6 +26,7 @@ + #include "osabi.h" + #include "solib-svr4.h" + #include "symtab.h" ++#include "linux-tdep.h" + + /* The sigtramp code is in a non-readable (executable-only) region + of memory called the ``gate page''. The addresses in question +@@ -139,6 +140,9 @@ ia64_linux_init_abi (struct gdbarch_info + /* Enable TLS support. */ + set_gdbarch_fetch_tls_load_module_address (gdbarch, + svr4_fetch_objfile_link_map); ++ ++ set_gdbarch_convert_from_func_ptr_addr (gdbarch, ++ linux_convert_from_func_ptr_addr); + } + + /* Provide a prototype to silence -Wmissing-prototypes. */ +Index: gdb-7.0.50.20100121/gdb/infcall.c +=================================================================== +--- gdb-7.0.50.20100121.orig/gdb/infcall.c 2010-01-01 08:31:36.000000000 +0100 ++++ gdb-7.0.50.20100121/gdb/infcall.c 2010-01-21 15:15:41.000000000 +0100 +@@ -252,9 +252,17 @@ find_function_addr (struct value *functi + if (TYPE_CODE (ftype) == TYPE_CODE_FUNC + || TYPE_CODE (ftype) == TYPE_CODE_METHOD) + { +- funaddr = gdbarch_convert_from_func_ptr_addr (gdbarch, funaddr, +- ¤t_target); +- value_type = TYPE_TARGET_TYPE (ftype); ++ CORE_ADDR funaddr2; ++ ++ funaddr2 = gdbarch_convert_from_func_ptr_addr (gdbarch, funaddr, ++ ¤t_target); ++ ++ /* If TYPE_GNU_IFUNC is currently not resolvable keep its type. */ ++ if (funaddr2 != funaddr || !TYPE_GNU_IFUNC (ftype)) ++ { ++ funaddr = funaddr2; ++ value_type = TYPE_TARGET_TYPE (ftype); ++ } + } + } + else if (code == TYPE_CODE_INT) +Index: gdb-7.0.50.20100121/gdb/linux-tdep.c +=================================================================== +--- gdb-7.0.50.20100121.orig/gdb/linux-tdep.c 2010-01-14 22:20:11.000000000 +0100 ++++ gdb-7.0.50.20100121/gdb/linux-tdep.c 2010-01-21 15:15:41.000000000 +0100 +@@ -23,6 +23,8 @@ + #include "auxv.h" #include "target.h" + #include "elf/common.h" ++#include "value.h" +#include "infcall.h" - /* We share this one with symtab.c, but it is not exported widely. */ + /* This function is suitable for architectures that don't + extend/override the standard siginfo structure. */ +@@ -152,3 +154,43 @@ linux_has_shared_address_space (void) -@@ -1867,6 +1868,22 @@ minsym_found (int funfirstline, struct m - pc = gdbarch_convert_from_func_ptr_addr (gdbarch, - values.sals[0].pc, - ¤t_target); + return target_is_uclinux; + } + -+ /* 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; ++/* Call gnu-ifunc to resolve breakpoint at its returned function. */ + -+ func_func_ptr = builtin_type (gdbarch)->builtin_func_func_ptr; -+ function = value_from_pointer (func_func_ptr, pc); ++CORE_ADDR ++linux_convert_from_func_and_ptr (struct gdbarch *gdbarch, CORE_ADDR func_ptr, ++ CORE_ADDR pc) ++{ ++ struct type *func_func_type = builtin_type (gdbarch)->builtin_func_func; ++ struct minimal_symbol *msymbol; ++ struct value *function, *address; + -+ /* gnu-ifuncs have no arguments. */ -+ function = call_function_by_hand (function, 0, NULL); ++ if (!target_has_execution) ++ return pc; + -+ pc = value_as_address (function); -+ } ++ msymbol = lookup_minimal_symbol_by_pc (func_ptr); ++ if (msymbol == NULL) ++ return pc; ++ if (MSYMBOL_TYPE (msymbol) != mst_text_gnu_ifunc) ++ return pc; + - if (pc != values.sals[0].pc) - values.sals[0] = find_pc_sect_line (pc, NULL, 0); - -Index: gdb-7.0.50.20100115/gdb/minsyms.c ++ /* Not at the gnu-ifunc entry point? */ ++ if (SYMBOL_VALUE_ADDRESS (msymbol) != func_ptr) ++ return pc; ++ ++ function = allocate_value (func_func_type); ++ set_value_address (function, pc); ++ ++ /* gnu-ifuncs have no arguments. FUNCTION is the code instruction address ++ while ADDRESS is a function descriptor. */ ++ address = call_function_by_hand (function, 0, NULL); ++ ++ return value_as_address (address); ++} ++ ++CORE_ADDR ++linux_convert_from_func_ptr_addr (struct gdbarch *gdbarch, CORE_ADDR addr, ++ struct target_ops *targ) ++{ ++ return linux_convert_from_func_and_ptr (gdbarch, addr, addr); ++} +Index: gdb-7.0.50.20100121/gdb/linux-tdep.h =================================================================== ---- gdb-7.0.50.20100115.orig/gdb/minsyms.c 2010-01-15 03:22:31.000000000 +0100 -+++ gdb-7.0.50.20100115/gdb/minsyms.c 2010-01-15 12:16:49.000000000 +0100 +--- gdb-7.0.50.20100121.orig/gdb/linux-tdep.h 2010-01-01 08:31:37.000000000 +0100 ++++ gdb-7.0.50.20100121/gdb/linux-tdep.h 2010-01-21 15:15:41.000000000 +0100 +@@ -22,4 +22,11 @@ + + struct type *linux_get_siginfo_type (struct gdbarch *); + ++CORE_ADDR linux_convert_from_func_and_ptr (struct gdbarch *gdbarch, ++ CORE_ADDR func_ptr, CORE_ADDR pc); ++ ++CORE_ADDR linux_convert_from_func_ptr_addr (struct gdbarch *gdbarch, ++ CORE_ADDR addr, ++ struct target_ops *targ); ++ + #endif /* linux-tdep.h */ +Index: gdb-7.0.50.20100121/gdb/m32r-linux-tdep.c +=================================================================== +--- gdb-7.0.50.20100121.orig/gdb/m32r-linux-tdep.c 2010-01-01 08:31:37.000000000 +0100 ++++ gdb-7.0.50.20100121/gdb/m32r-linux-tdep.c 2010-01-21 15:15:41.000000000 +0100 +@@ -30,6 +30,7 @@ + #include "gdb_string.h" + + #include "glibc-tdep.h" ++#include "linux-tdep.h" + #include "solib-svr4.h" + #include "symtab.h" + +@@ -422,6 +423,9 @@ m32r_linux_init_abi (struct gdbarch_info + /* Enable TLS support. */ + set_gdbarch_fetch_tls_load_module_address (gdbarch, + svr4_fetch_objfile_link_map); ++ ++ set_gdbarch_convert_from_func_ptr_addr (gdbarch, ++ linux_convert_from_func_ptr_addr); + } + + /* Provide a prototype to silence -Wmissing-prototypes. */ +Index: gdb-7.0.50.20100121/gdb/microblaze-linux-tdep.c +=================================================================== +--- gdb-7.0.50.20100121.orig/gdb/microblaze-linux-tdep.c 2010-01-01 08:31:37.000000000 +0100 ++++ gdb-7.0.50.20100121/gdb/microblaze-linux-tdep.c 2010-01-21 15:15:41.000000000 +0100 +@@ -35,6 +35,7 @@ + #include "trad-frame.h" + #include "frame-unwind.h" + #include "tramp-frame.h" ++#include "linux-tdep.h" + + + static int +@@ -133,6 +134,9 @@ microblaze_linux_init_abi (struct gdbarc + /* Trampolines. */ + tramp_frame_prepend_unwinder (gdbarch, + µblaze_linux_sighandler_tramp_frame); ++ ++ set_gdbarch_convert_from_func_ptr_addr (gdbarch, ++ linux_convert_from_func_ptr_addr); + } + + void +Index: gdb-7.0.50.20100121/gdb/minsyms.c +=================================================================== +--- gdb-7.0.50.20100121.orig/gdb/minsyms.c 2010-01-21 15:13:26.000000000 +0100 ++++ gdb-7.0.50.20100121/gdb/minsyms.c 2010-01-21 15:15:41.000000000 +0100 @@ -331,8 +331,9 @@ lookup_minimal_symbol_text (const char * msymbol = msymbol->hash_next) { @@ -262,10 +539,93 @@ Index: gdb-7.0.50.20100115/gdb/minsyms.c && strcmp (SYMBOL_LINKAGE_NAME (msymbol), SYMBOL_LINKAGE_NAME (tsymbol)) == 0) return SYMBOL_VALUE_ADDRESS (msymbol); -Index: gdb-7.0.50.20100115/gdb/parse.c +Index: gdb-7.0.50.20100121/gdb/mips-linux-tdep.c =================================================================== ---- gdb-7.0.50.20100115.orig/gdb/parse.c 2010-01-15 03:22:31.000000000 +0100 -+++ gdb-7.0.50.20100115/gdb/parse.c 2010-01-15 12:16:49.000000000 +0100 +--- gdb-7.0.50.20100121.orig/gdb/mips-linux-tdep.c 2010-01-01 08:31:37.000000000 +0100 ++++ gdb-7.0.50.20100121/gdb/mips-linux-tdep.c 2010-01-21 15:15:41.000000000 +0100 +@@ -38,6 +38,7 @@ + #include "target-descriptions.h" + #include "mips-linux-tdep.h" + #include "glibc-tdep.h" ++#include "linux-tdep.h" + + static struct target_so_ops mips_svr4_so_ops; + +@@ -1225,6 +1226,9 @@ mips_linux_init_abi (struct gdbarch_info + tdesc_numbered_register (feature, tdesc_data, MIPS_RESTART_REGNUM, + "restart"); + } ++ ++ set_gdbarch_convert_from_func_ptr_addr (gdbarch, ++ linux_convert_from_func_ptr_addr); + } + + /* Provide a prototype to silence -Wmissing-prototypes. */ +Index: gdb-7.0.50.20100121/gdb/mn10300-linux-tdep.c +=================================================================== +--- gdb-7.0.50.20100121.orig/gdb/mn10300-linux-tdep.c 2010-01-01 08:31:37.000000000 +0100 ++++ gdb-7.0.50.20100121/gdb/mn10300-linux-tdep.c 2010-01-21 15:15:41.000000000 +0100 +@@ -32,6 +32,7 @@ + #include "frame.h" + #include "trad-frame.h" + #include "tramp-frame.h" ++#include "linux-tdep.h" + + #include + +@@ -718,6 +719,9 @@ am33_linux_init_osabi (struct gdbarch_in + + tramp_frame_prepend_unwinder (gdbarch, &am33_linux_sigframe); + tramp_frame_prepend_unwinder (gdbarch, &am33_linux_rt_sigframe); ++ ++ set_gdbarch_convert_from_func_ptr_addr (gdbarch, ++ linux_convert_from_func_ptr_addr); + } + + /* Provide a prototype to silence -Wmissing-prototypes. */ +Index: gdb-7.0.50.20100121/gdb/objc-lang.c +=================================================================== +--- gdb-7.0.50.20100121.orig/gdb/objc-lang.c 2010-01-14 09:03:36.000000000 +0100 ++++ gdb-7.0.50.20100121/gdb/objc-lang.c 2010-01-21 15:15:41.000000000 +0100 +@@ -1178,16 +1178,6 @@ find_methods (struct symtab *symtab, cha + + QUIT; + +- /* The minimal symbol might point to a function descriptor; +- resolve it to the actual code address instead. */ +- pc = gdbarch_convert_from_func_ptr_addr (gdbarch, pc, +- ¤t_target); +- +- if (symtab) +- if (pc < BLOCK_START (block) || pc >= BLOCK_END (block)) +- /* Not in the specified symtab. */ +- continue; +- + symname = SYMBOL_NATURAL_NAME (msymbol); + if (symname == NULL) + continue; +@@ -1223,6 +1213,17 @@ find_methods (struct symtab *symtab, cha + ((nselector == NULL) || (strcmp (selector, nselector) != 0))) + continue; + ++ /* The minimal symbol might point to a function descriptor; ++ resolve it to the actual code address instead. Delay the call as ++ its resolution may be expensive. */ ++ pc = gdbarch_convert_from_func_ptr_addr (gdbarch, pc, ++ ¤t_target); ++ ++ if (symtab) ++ if (pc < BLOCK_START (block) || pc >= BLOCK_END (block)) ++ /* Not in the specified symtab. */ ++ continue; ++ + sym = find_pc_function (pc); + if (sym != NULL) + { +Index: gdb-7.0.50.20100121/gdb/parse.c +=================================================================== +--- gdb-7.0.50.20100121.orig/gdb/parse.c 2010-01-21 15:13:26.000000000 +0100 ++++ gdb-7.0.50.20100121/gdb/parse.c 2010-01-21 15:16:15.000000000 +0100 @@ -516,6 +516,11 @@ write_exp_msymbol (struct minimal_symbol write_exp_elt_type (objfile_type (objfile)->nodebug_text_symbol); break; @@ -278,10 +638,66 @@ Index: gdb-7.0.50.20100115/gdb/parse.c case mst_data: case mst_file_data: case mst_bss: -Index: gdb-7.0.50.20100115/gdb/solib-svr4.c +Index: gdb-7.0.50.20100121/gdb/ppc-linux-tdep.c =================================================================== ---- gdb-7.0.50.20100115.orig/gdb/solib-svr4.c 2010-01-15 12:16:41.000000000 +0100 -+++ gdb-7.0.50.20100115/gdb/solib-svr4.c 2010-01-15 12:17:40.000000000 +0100 +--- gdb-7.0.50.20100121.orig/gdb/ppc-linux-tdep.c 2010-01-04 15:57:44.000000000 +0100 ++++ gdb-7.0.50.20100121/gdb/ppc-linux-tdep.c 2010-01-21 15:15:41.000000000 +0100 +@@ -48,6 +48,7 @@ + #include "arch-utils.h" + #include "spu-tdep.h" + #include "xml-syscall.h" ++#include "linux-tdep.h" + + #include "features/rs6000/powerpc-32l.c" + #include "features/rs6000/powerpc-altivec32l.c" +@@ -672,8 +673,19 @@ ppc64_linux_convert_from_func_ptr_addr ( + res = bfd_get_section_contents (s->bfd, s->the_bfd_section, + &buf, addr - s->addr, 8); + if (res != 0) +- return extract_unsigned_integer (buf, 8, byte_order) +- - bfd_section_vma (s->bfd, s->the_bfd_section) + s->addr; ++ { ++ CORE_ADDR pc, resolved; ++ ++ pc = extract_unsigned_integer (buf, 8, byte_order) ++ - bfd_section_vma (s->bfd, s->the_bfd_section) + s->addr; ++ ++ resolved = linux_convert_from_func_and_ptr (gdbarch, addr, pc); ++ if (resolved != pc) ++ pc = ppc64_linux_convert_from_func_ptr_addr (gdbarch, resolved, ++ targ); ++ ++ return pc; ++ } + } + + return addr; +Index: gdb-7.0.50.20100121/gdb/sh-linux-tdep.c +=================================================================== +--- gdb-7.0.50.20100121.orig/gdb/sh-linux-tdep.c 2010-01-01 08:31:41.000000000 +0100 ++++ gdb-7.0.50.20100121/gdb/sh-linux-tdep.c 2010-01-21 15:15:41.000000000 +0100 +@@ -25,6 +25,7 @@ + + #include "glibc-tdep.h" + #include "sh-tdep.h" ++#include "linux-tdep.h" + + #define REGSx16(base) \ + {(base), 0}, \ +@@ -89,6 +90,9 @@ sh_linux_init_abi (struct gdbarch_info i + tdep->core_gregmap = (struct sh_corefile_regmap *)gregs_table; + tdep->core_fpregmap = (struct sh_corefile_regmap *)fpregs_table; + } ++ ++ set_gdbarch_convert_from_func_ptr_addr (gdbarch, ++ linux_convert_from_func_ptr_addr); + } + + /* Provide a prototype to silence -Wmissing-prototypes. */ +Index: gdb-7.0.50.20100121/gdb/solib-svr4.c +=================================================================== +--- gdb-7.0.50.20100121.orig/gdb/solib-svr4.c 2010-01-21 15:15:22.000000000 +0100 ++++ gdb-7.0.50.20100121/gdb/solib-svr4.c 2010-01-21 15:15:41.000000000 +0100 @@ -1257,7 +1257,8 @@ svr4_in_dynsym_resolve_code (CORE_ADDR p && pc < info->interp_text_sect_high) || (pc >= info->interp_plt_sect_low @@ -292,10 +708,54 @@ Index: gdb-7.0.50.20100115/gdb/solib-svr4.c } /* Given an executable's ABFD and target, compute the entry-point -Index: gdb-7.0.50.20100115/gdb/symmisc.c +Index: gdb-7.0.50.20100121/gdb/sparc-linux-tdep.c =================================================================== ---- gdb-7.0.50.20100115.orig/gdb/symmisc.c 2010-01-15 03:22:32.000000000 +0100 -+++ gdb-7.0.50.20100115/gdb/symmisc.c 2010-01-15 12:16:49.000000000 +0100 +--- gdb-7.0.50.20100121.orig/gdb/sparc-linux-tdep.c 2010-01-01 08:31:42.000000000 +0100 ++++ gdb-7.0.50.20100121/gdb/sparc-linux-tdep.c 2010-01-21 15:15:41.000000000 +0100 +@@ -32,6 +32,7 @@ + #include "symtab.h" + #include "trad-frame.h" + #include "tramp-frame.h" ++#include "linux-tdep.h" + + #include "sparc-tdep.h" + +@@ -279,6 +280,9 @@ sparc32_linux_init_abi (struct gdbarch_i + dwarf2_append_unwinders (gdbarch); + + set_gdbarch_write_pc (gdbarch, sparc_linux_write_pc); ++ ++ set_gdbarch_convert_from_func_ptr_addr (gdbarch, ++ linux_convert_from_func_ptr_addr); + } + + /* Provide a prototype to silence -Wmissing-prototypes. */ +Index: gdb-7.0.50.20100121/gdb/sparc64-linux-tdep.c +=================================================================== +--- gdb-7.0.50.20100121.orig/gdb/sparc64-linux-tdep.c 2010-01-01 08:31:42.000000000 +0100 ++++ gdb-7.0.50.20100121/gdb/sparc64-linux-tdep.c 2010-01-21 15:15:41.000000000 +0100 +@@ -31,6 +31,7 @@ + #include "symtab.h" + #include "trad-frame.h" + #include "tramp-frame.h" ++#include "linux-tdep.h" + + #include "sparc64-tdep.h" + +@@ -244,6 +245,9 @@ sparc64_linux_init_abi (struct gdbarch_i + tdep->step_trap = sparc64_linux_step_trap; + + set_gdbarch_write_pc (gdbarch, sparc64_linux_write_pc); ++ ++ set_gdbarch_convert_from_func_ptr_addr (gdbarch, ++ linux_convert_from_func_ptr_addr); + } + + +Index: gdb-7.0.50.20100121/gdb/symmisc.c +=================================================================== +--- gdb-7.0.50.20100121.orig/gdb/symmisc.c 2010-01-21 15:13:27.000000000 +0100 ++++ gdb-7.0.50.20100121/gdb/symmisc.c 2010-01-21 15:15:41.000000000 +0100 @@ -294,6 +294,9 @@ dump_msymbols (struct objfile *objfile, case mst_text: ms_type = 'T'; @@ -306,11 +766,11 @@ Index: gdb-7.0.50.20100115/gdb/symmisc.c case mst_solib_trampoline: ms_type = 'S'; break; -Index: gdb-7.0.50.20100115/gdb/symtab.c +Index: gdb-7.0.50.20100121/gdb/symtab.c =================================================================== ---- gdb-7.0.50.20100115.orig/gdb/symtab.c 2010-01-15 03:22:31.000000000 +0100 -+++ gdb-7.0.50.20100115/gdb/symtab.c 2010-01-15 12:16:49.000000000 +0100 -@@ -3257,7 +3257,7 @@ search_symbols (char *regexp, domain_enu +--- gdb-7.0.50.20100121.orig/gdb/symtab.c 2010-01-21 15:13:27.000000000 +0100 ++++ gdb-7.0.50.20100121/gdb/symtab.c 2010-01-21 15:15:41.000000000 +0100 +@@ -3244,7 +3244,7 @@ search_symbols (char *regexp, domain_enu {mst_file_data, mst_solib_trampoline, mst_abs, mst_unknown}; static enum minimal_symbol_type types4[] = @@ -319,10 +779,10 @@ Index: gdb-7.0.50.20100115/gdb/symtab.c enum minimal_symbol_type ourtype; enum minimal_symbol_type ourtype2; enum minimal_symbol_type ourtype3; -Index: gdb-7.0.50.20100115/gdb/symtab.h +Index: gdb-7.0.50.20100121/gdb/symtab.h =================================================================== ---- gdb-7.0.50.20100115.orig/gdb/symtab.h 2010-01-15 03:22:13.000000000 +0100 -+++ gdb-7.0.50.20100115/gdb/symtab.h 2010-01-15 12:16:49.000000000 +0100 +--- gdb-7.0.50.20100121.orig/gdb/symtab.h 2010-01-21 15:11:09.000000000 +0100 ++++ gdb-7.0.50.20100121/gdb/symtab.h 2010-01-21 15:15:41.000000000 +0100 @@ -280,6 +280,8 @@ enum minimal_symbol_type { mst_unknown = 0, /* Unknown type, the default */ @@ -332,7 +792,7 @@ Index: gdb-7.0.50.20100115/gdb/symtab.h mst_data, /* Generally initialized data */ mst_bss, /* Generally uninitialized data */ mst_abs, /* Generally absolute (nonrelocatable) */ -@@ -1163,6 +1165,8 @@ extern struct minimal_symbol *lookup_min +@@ -1157,6 +1159,8 @@ extern struct minimal_symbol *lookup_min extern struct minimal_symbol *lookup_minimal_symbol_by_pc (CORE_ADDR); @@ -341,11 +801,11 @@ Index: gdb-7.0.50.20100115/gdb/symtab.h extern struct minimal_symbol *lookup_minimal_symbol_by_pc_section (CORE_ADDR, struct obj_section *); -Index: gdb-7.0.50.20100115/gdb/testsuite/gdb.base/gnu-ifunc-lib.c +Index: gdb-7.0.50.20100121/gdb/testsuite/gdb.base/gnu-ifunc-lib.c =================================================================== --- /dev/null 1970-01-01 00:00:00.000000000 +0000 -+++ gdb-7.0.50.20100115/gdb/testsuite/gdb.base/gnu-ifunc-lib.c 2010-01-15 12:16:49.000000000 +0100 -@@ -0,0 +1,45 @@ ++++ gdb-7.0.50.20100121/gdb/testsuite/gdb.base/gnu-ifunc-lib.c 2010-01-21 15:15:41.000000000 +0100 +@@ -0,0 +1,54 @@ +/* This testcase is part of GDB, the GNU debugger. + + Copyright 2009 Free Software Foundation, Inc. @@ -368,6 +828,12 @@ Index: gdb-7.0.50.20100115/gdb/testsuite/gdb.base/gnu-ifunc-lib.c +typedef int (*final_t) (int arg); + +static int ++init_stub (int arg) ++{ ++ return 0; ++} ++ ++static int +final (int arg) +{ + return arg + 1; @@ -379,6 +845,8 @@ Index: gdb-7.0.50.20100115/gdb/testsuite/gdb.base/gnu-ifunc-lib.c +gnu_ifunc_pre (void) +{ + assert (!gnu_ifunc_initialized); ++ ++ gnu_ifunc_initialized = 1; +} + +final_t gnu_ifuncX (void) asm ("gnu_ifunc"); @@ -387,14 +855,15 @@ Index: gdb-7.0.50.20100115/gdb/testsuite/gdb.base/gnu-ifunc-lib.c +final_t +gnu_ifuncX (void) +{ -+ gnu_ifunc_initialized = 1; -+ -+ return final; ++ if (!gnu_ifunc_initialized) ++ return init_stub; ++ else ++ return final; +} -Index: gdb-7.0.50.20100115/gdb/testsuite/gdb.base/gnu-ifunc.c +Index: gdb-7.0.50.20100121/gdb/testsuite/gdb.base/gnu-ifunc.c =================================================================== --- /dev/null 1970-01-01 00:00:00.000000000 +0000 -+++ gdb-7.0.50.20100115/gdb/testsuite/gdb.base/gnu-ifunc.c 2010-01-15 12:16:49.000000000 +0100 ++++ gdb-7.0.50.20100121/gdb/testsuite/gdb.base/gnu-ifunc.c 2010-01-21 15:15:41.000000000 +0100 @@ -0,0 +1,36 @@ +/* This testcase is part of GDB, the GNU debugger. + @@ -432,11 +901,11 @@ Index: gdb-7.0.50.20100115/gdb/testsuite/gdb.base/gnu-ifunc.c + + return 0; /* break-at-exit */ +} -Index: gdb-7.0.50.20100115/gdb/testsuite/gdb.base/gnu-ifunc.exp +Index: gdb-7.0.50.20100121/gdb/testsuite/gdb.base/gnu-ifunc.exp =================================================================== --- /dev/null 1970-01-01 00:00:00.000000000 +0000 -+++ gdb-7.0.50.20100115/gdb/testsuite/gdb.base/gnu-ifunc.exp 2010-01-15 12:16:49.000000000 +0100 -@@ -0,0 +1,72 @@ ++++ gdb-7.0.50.20100121/gdb/testsuite/gdb.base/gnu-ifunc.exp 2010-01-21 15:15:41.000000000 +0100 +@@ -0,0 +1,115 @@ +# Copyright (C) 2009 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify @@ -464,7 +933,14 @@ Index: gdb-7.0.50.20100115/gdb/testsuite/gdb.base/gnu-ifunc.exp +set libsrc ${libfile}.c +set lib_so ${objdir}/${subdir}/${libfile}.so + ++set lib_nodebug_so_base ${libfile}-nodebug.so ++set lib_nodebug_so ${objdir}/${subdir}/${lib_nodebug_so_base} ++ ++# {debug} provides DWARF symbol gnu_ifuncX confusing the ELF symbol ++# gnu_ifunc during address->symbol resolution for printing the symbol. ++# Still we need it here for "step"ping into the function. +set lib_opts [list debug] ++set lib_nodebug_opts [list] +set exec_opts [list debug shlib=$lib_so] + +if [get_compiler_info ${binfile}] { @@ -487,7 +963,8 @@ Index: gdb-7.0.50.20100115/gdb/testsuite/gdb.base/gnu-ifunc.exp + return 1; +} + -+gdb_breakpoint [gdb_get_line_number "break-at-nextcall"] ++# The "if" condition is artifical to test regression of a format 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.*" @@ -502,10 +979,67 @@ Index: gdb-7.0.50.20100115/gdb/testsuite/gdb.base/gnu-ifunc.exp + +# Test GDB will not break before the final chosen implementation. + -+gdb_continue_to_breakpoint "break-at-nextcall" ".*break-at-nextcall.*" ++# Also test a format 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 +final \\(.*" "nextcall gnu_ifunc skipped" ++gdb_test "frame" "#0 +(0x\[0-9a-f\]+ in +)?final \\(.*" "nextcall gnu_ifunc skipped" ++ ++ ++# Compare the two different addresses: ++ ++gdb_test "p gnu_ifunc" " = {} 0x\[0-9a-f\]+ " "p gnu_ifunc executing" ++gdb_test "info sym gnu_ifunc" "final 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 " ++ ++# <*gnu_ifunc> would be an incorrect resolution from DW_AT_MIPS_linkage_name. ++# We do not use {debug} build option for this purpose. ++ ++if { [gdb_compile_shlib ${srcdir}/${subdir}/$libsrc $lib_nodebug_so $lib_nodebug_opts] != ""} { ++ untested "Could not compile either $libsrc." ++ return -1 ++} ++ ++clean_restart $lib_nodebug_so_base ++ ++gdb_test "p gnu_ifunc" " = {} 0x\[0-9a-f\]+ " "p gnu_ifunc not executing without debug" ++gdb_test "info sym gnu_ifunc" "gnu_ifunc in section .*" "info sym gnu_ifunc not executing without debug" +Index: gdb-7.0.50.20100121/gdb/xtensa-linux-tdep.c +=================================================================== +--- gdb-7.0.50.20100121.orig/gdb/xtensa-linux-tdep.c 2010-01-01 08:31:46.000000000 +0100 ++++ gdb-7.0.50.20100121/gdb/xtensa-linux-tdep.c 2010-01-21 15:15:41.000000000 +0100 +@@ -22,6 +22,7 @@ + + #include "solib-svr4.h" + #include "symtab.h" ++#include "linux-tdep.h" + + /* OS specific initialization of gdbarch. */ + +@@ -30,6 +31,9 @@ xtensa_linux_init_abi (struct gdbarch_in + { + set_solib_svr4_fetch_link_map_offsets + (gdbarch, svr4_ilp32_fetch_link_map_offsets); ++ ++ set_gdbarch_convert_from_func_ptr_addr (gdbarch, ++ linux_convert_from_func_ptr_addr); + } + + /* Provide a prototype to silence -Wmissing-prototypes. */ diff --git a/gdb-empty-namespace.patch b/gdb-empty-namespace.patch deleted file mode 100644 index 1aa7654..0000000 --- a/gdb-empty-namespace.patch +++ /dev/null @@ -1,204 +0,0 @@ -###gdb/ -###2009-12-20 Jan Kratochvil -### -### Fix compatibility with G++-4.1. -### * dwarf2read.c (partial_die_parent_scope): New variable PARENT_NAME. -### Ignore parent namespaces with name "::". -### (physname_prefix_1): Ignore namespaces with name "::". - -gdb/testsuite/ -2009-12-20 Jan Kratochvil - - * gdb.dwarf2/dw2-empty-namespace.exp, gdb.dwarf2/dw2-empty-namespace.S: - New. - -###--- a/gdb/dwarf2read.c -###+++ b/gdb/dwarf2read.c -###@@ -2355,11 +2355,18 @@ partial_die_parent_scope (struct partial_die_info *pdi, -### || parent->tag == DW_TAG_interface_type -### || parent->tag == DW_TAG_union_type) -### { -###+ char *parent_name = parent->name; -###+ -###+ /* G++ 4.1 produced DW_TAG_namespace with DW_AT_name "::". */ -###+ if (parent->tag == DW_TAG_namespace && parent_name != NULL -###+ && strcmp (parent_name, "::") == 0) -###+ parent_name = NULL; -###+ -### if (grandparent_scope == NULL) -###- parent->scope = parent->name; -###+ parent->scope = parent_name; -### else -### parent->scope = typename_concat (&cu->comp_unit_obstack, grandparent_scope, -###- parent->name, cu); -###+ parent_name, cu); -### } -### else if (parent->tag == DW_TAG_enumeration_type) -### /* Enumerators should not get the name of the enumeration as a prefix. */ -###@@ -9008,6 +9015,9 @@ physname_prefix_1 (struct ui_file *buf, struct die_info *die, -### name = dwarf2_name (die, cu); -### if (name == NULL) -### name = "(anonymous namespace)"; -###+ /* G++ 4.1 produced DW_TAG_namespace with DW_AT_name "::". */ -###+ else if (strcmp (name, "::") == 0) -###+ name = NULL; -### break; -### -### case DW_TAG_class_type: ---- /dev/null -+++ b/gdb/testsuite/gdb.dwarf2/dw2-empty-namespace.S -@@ -0,0 +1,108 @@ -+/* 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 . */ -+ -+/* Test G++ 4.1 producing DW_TAG_namespace with DW_AT_name "::". */ -+ -+ .data -+var: .4byte 1 -+ -+ .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 "file1.txt\0" /* DW_AT_name */ -+ .ascii "GNU C 3.3.3\0" /* DW_AT_producer */ -+ .byte 4 /* DW_LANG_C_plus_plus (C++) */ -+ -+.Ltype_int: -+ .uleb128 2 /* Abbrev: DW_TAG_base_type */ -+ .ascii "int\0" /* DW_AT_name */ -+ .byte 4 /* DW_AT_byte_size */ -+ .byte 5 /* DW_AT_encoding */ -+ -+ .uleb128 3 /* Abbrev: DW_TAG_namespace */ -+ .ascii "::\0" /* DW_AT_name */ -+ -+ .uleb128 7 /* Abbrev: DW_TAG_variable (location) */ -+ .ascii "var\0" /* DW_AT_name */ -+ .byte 2f - 1f /* DW_AT_location */ -+1: .byte 3 /* DW_OP_addr */ -+ .4byte var /* */ -+2: .4byte .Ltype_int-.Lcu1_begin /* DW_AT_type */ -+ -+ .byte 0 /* End of children of DW_TAG_namespace */ -+ -+ .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 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 */ -+ -+ .uleb128 3 /* Abbrev code */ -+ .uleb128 0x39 /* DW_TAG_namespace */ -+ .byte 1 /* has_children */ -+ .uleb128 0x3 /* DW_AT_name */ -+ .uleb128 0x8 /* DW_FORM_string */ -+ .byte 0x0 /* Terminator */ -+ .byte 0x0 /* Terminator */ -+ -+ .uleb128 7 /* Abbrev code (location) */ -+ .uleb128 0x34 /* DW_TAG_variable */ -+ .byte 0 /* has_children */ -+ .uleb128 0x3 /* DW_AT_name */ -+ .uleb128 0x8 /* DW_FORM_string */ -+ .uleb128 0x2 /* DW_AT_location */ -+ .uleb128 0xa /* DW_FORM_block1 */ -+ .uleb128 0x49 /* DW_AT_type */ -+ .uleb128 0x13 /* DW_FORM_ref4 */ -+ .byte 0x0 /* Terminator */ -+ .byte 0x0 /* Terminator */ -+ -+ .byte 0x0 /* Terminator */ -+ .byte 0x0 /* Terminator */ ---- /dev/null -+++ b/gdb/testsuite/gdb.dwarf2/dw2-empty-namespace.exp -@@ -0,0 +1,43 @@ -+# 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 G++ 4.1 producing DW_TAG_namespace with DW_AT_name "::". -+ -+# 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-empty-namespace" -+set srcfile ${testfile}.S -+set executable ${testfile}.x -+ -+if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${objdir}/${subdir}/${executable}" object {nodebug}] != "" } { -+ return -1 -+} -+ -+clean_restart $executable -+ -+# `p var' below can work without identified DWARF DIE just based on its ELF symbol. -+# Catch it here as `type = '. -+gdb_test "ptype var" "type = int" -+ -+gdb_test "p var" " = 1" diff --git a/gdb-solib-display.patch b/gdb-solib-display.patch new file mode 100644 index 0000000..dac3420 --- /dev/null +++ b/gdb-solib-display.patch @@ -0,0 +1,58 @@ +http://sourceware.org/ml/gdb-patches/2010-01/msg00485.html +Subject: [patch] Fix solib-display.exp crash + +[ Made more safe for downstream patch + ported for VLA. ] + +Hi, + +it is a testsuite regression against gdb-7.0 although the bug was probably +present even in gdb-7.0 (it started to reproduce since one completely +unrelated Daniel J.'s patch). This patch fixes (-lmcheck may be required): + + PASS: gdb.base/solib-display.exp: display a_global + PASS: gdb.base/solib-display.exp: display b_global + PASS: gdb.base/solib-display.exp: display c_global +-ERROR: Process no longer exists +-UNRESOLVED: gdb.base/solib-display.exp: after rerun +-WARNING: remote_expect statement without a default case?! +-FAIL: gdb.base/solib-display.exp: Can't run to main (3) ++PASS: gdb.base/solib-display.exp: after rerun ++PASS: gdb.base/solib-display.exp: after rerun ++PASS: gdb.base/solib-display.exp: break 25 ++PASS: gdb.base/solib-display.exp: continue ++PASS: gdb.base/solib-display.exp: display main_global ++PASS: gdb.base/solib-display.exp: display a_local ++PASS: gdb.base/solib-display.exp: display a_static ++PASS: gdb.base/solib-display.exp: break 25 ++PASS: gdb.base/solib-display.exp: continue + +No regressions on {x86_64,x86_64-m32,i686}-fedora12-linux-gnu. + +The question is whether SYMBOL_SYMTAB (symbol) can be ever NULL at this point. +IMO not, it can be NULL only temporarily during reading symbols. + + +Thanks, +Jan + + +2010-01-20 Jan Kratochvil + + * printcmd.c (display_uses_solib_p): Remove variable section. Access + objfile via SYMBOL_SYMTAB. + +Index: gdb-7.0.50.20100121/gdb/parse.c +=================================================================== +--- gdb-7.0.50.20100121.orig/gdb/parse.c 2010-01-21 15:16:15.000000000 +0100 ++++ gdb-7.0.50.20100121/gdb/parse.c 2010-01-21 15:21:45.000000000 +0100 +@@ -1425,6 +1425,10 @@ operator_check_standard (struct expressi + if (section && objfile_func && (*objfile_func) (section->objfile, data)) + return 1; + ++ /* SYMBOL_OBJ_SECTION (symbol) may be NULL. */ ++ if (SYMBOL_SYMTAB (symbol) && objfile_func && (*objfile_func) (SYMBOL_SYMTAB (symbol)->objfile, data)) ++ return 1; ++ + /* Check objfile where is placed the code touching the variable. */ + objfile = block_objfile (block); + diff --git a/gdb-testsuite-lineno.patch b/gdb-testsuite-lineno.patch deleted file mode 100644 index 4ebc827..0000000 --- a/gdb-testsuite-lineno.patch +++ /dev/null @@ -1,152 +0,0 @@ -http://sourceware.org/ml/gdb-patches/2010-01/msg00461.html -Subject: [patch] testsuite: Fix misplaced line numbers - -Hi, - -commit 7a82dfb2a9be66f0230229642cbee54ebda3b0da -Author: Joel Brobecker -Date: Fri Jan 1 07:31:28 2010 +0000 - - Update copyright year in most headers. - - Automatic update by copyright.sh. - -regressed: - --PASS: gdb.mi/mi-break.exp: run to breakpoint with ignore count -+FAIL: gdb.mi/mi-break.exp: run to breakpoint with ignore count (stopped at wrong place) --PASS: gdb.mi/mi-cli.exp: continue to callee4 -+FAIL: gdb.mi/mi-cli.exp: continue to callee4 (stopped at wrong place) --PASS: gdb.mi/mi-cli.exp: check *stopped from CLI command -+FAIL: gdb.mi/mi-cli.exp: check *stopped from CLI command (stopped at wrong place) --PASS: gdb.mi/mi2-cli.exp: continue to callee4 -+FAIL: gdb.mi/mi2-cli.exp: continue to callee4 (stopped at wrong place) - -due to: - -#--- a/gdb/testsuite/gdb.mi/basics.c -#+++ b/gdb/testsuite/gdb.mi/basics.c -#@@ -1,4 +1,5 @@ -#-/* Copyright 1999, 2000, 2004, 2007, 2008, 2009 Free Software Foundation, Inc. -#+/* Copyright 1999, 2000, 2004, 2007, 2008, 2009, 2010 -#+Free Software Foundation, Inc. - - -Tested on x86_64-fedora12-linux-gnu. - - -Thanks, -Jan - - -2010-01-18 Jan Kratochvil - - * gdb.mi/mi-break.exp (set line_callme_head, set line_callme_body): New. - (test_ignore_count): Declare line_callme_body global. - (run to breakpoint with ignore count): Use line_callme_body. - * gdb.mi/mi-cli.exp (set line_main_head, set line_main_body) - (set line_main_hello, set line_main_return): Reindent. - (set line_callee4_head, set line_callee4_body, set line_callee4_next): - New. - (continue to callee4): Use line_callee4_body. - (check *stopped from CLI command): Use line_callee4_next. - * gdb.mi/mi2-cli.exp (set line_main_head, set line_main_body) - (set line_main_hello, set line_main_return): Reindent. - (set line_callee4_head, set line_callee4_body): New. - (continue to callee4): Use line_callee4_body. - ---- a/gdb/testsuite/gdb.mi/mi-break.exp -+++ b/gdb/testsuite/gdb.mi/mi-break.exp -@@ -56,6 +56,8 @@ set line_callee1_head [gdb_get_line_number "callee1 ("] - set line_callee1_body [expr $line_callee1_head + 2] - set line_main_head [gdb_get_line_number "main ("] - set line_main_body [expr $line_main_head + 2] -+set line_callme_head [gdb_get_line_number "callme ("] -+set line_callme_body [expr $line_callme_head + 2] - - set fullname "fullname=\"${fullname_syntax}${srcfile}\"" - -@@ -152,6 +154,7 @@ proc test_rbreak_creation_and_listing {} { - - proc test_ignore_count {} { - global mi_gdb_prompt -+ global line_callme_body - - mi_gdb_test "-break-insert -i 1 callme" \ - "\\^done.*ignore=\"1\".*" \ -@@ -159,7 +162,7 @@ proc test_ignore_count {} { - - mi_run_cmd - -- mi_expect_stop "breakpoint-hit" "callme" "\{name=\"i\",value=\"2\"\}" ".*basics.c" "52" \ -+ mi_expect_stop "breakpoint-hit" "callme" "\{name=\"i\",value=\"2\"\}" ".*basics.c" $line_callme_body \ - {"" "disp=\"keep\"" } "run to breakpoint with ignore count" - } - ---- a/gdb/testsuite/gdb.mi/mi-cli.exp -+++ b/gdb/testsuite/gdb.mi/mi-cli.exp -@@ -63,10 +63,13 @@ mi_gdb_test "-interpreter-exec console \"file $binfile\"" \ - - mi_run_to_main - --set line_main_head [gdb_get_line_number "main ("] --set line_main_body [expr $line_main_head + 2] --set line_main_hello [gdb_get_line_number "Hello, World!"] --set line_main_return [expr $line_main_hello + 2] -+set line_main_head [gdb_get_line_number "main ("] -+set line_main_body [expr $line_main_head + 2] -+set line_main_hello [gdb_get_line_number "Hello, World!"] -+set line_main_return [expr $line_main_hello + 2] -+set line_callee4_head [gdb_get_line_number "callee4 ("] -+set line_callee4_body [expr $line_callee4_head + 2] -+set line_callee4_next [expr $line_callee4_body + 1] - - mi_gdb_test "-interpreter-exec console \"set args foobar\"" \ - {\^done} \ -@@ -97,7 +100,7 @@ mi_gdb_test "-interpreter-exec console \"list\"" \ - ".*\~\"$line_main_body\[\\\\t \]*callee1.*;\\\\n\".*\\^done" \ - "-interpreter-exec console \"list\"" - --mi_execute_to "exec-continue" "breakpoint-hit" "callee4" "" ".*basics.c" "28" \ -+mi_execute_to "exec-continue" "breakpoint-hit" "callee4" "" ".*basics.c" $line_callee4_body \ - { "" "disp=\"keep\"" } "continue to callee4" - - # NOTE: cagney/2003-02-03: Not yet. -@@ -155,7 +158,7 @@ if {$async} { - set reason "" - } - --mi_execute_to "interpreter-exec console step" $reason "callee4" "" ".*basics.c" "29" \ -+mi_execute_to "interpreter-exec console step" $reason "callee4" "" ".*basics.c" $line_callee4_next \ - "" "check *stopped from CLI command" - - # NOTE: cagney/2003-02-03: Not yet. ---- a/gdb/testsuite/gdb.mi/mi2-cli.exp -+++ b/gdb/testsuite/gdb.mi/mi2-cli.exp -@@ -63,10 +63,12 @@ mi_gdb_test "-interpreter-exec console \"file $binfile\"" \ - - mi_run_to_main - --set line_main_head [gdb_get_line_number "main ("] --set line_main_body [expr $line_main_head + 2] --set line_main_hello [gdb_get_line_number "Hello, World!"] --set line_main_return [expr $line_main_hello + 2] -+set line_main_head [gdb_get_line_number "main ("] -+set line_main_body [expr $line_main_head + 2] -+set line_main_hello [gdb_get_line_number "Hello, World!"] -+set line_main_return [expr $line_main_hello + 2] -+set line_callee4_head [gdb_get_line_number "callee4 ("] -+set line_callee4_body [expr $line_callee4_head + 2] - - mi_gdb_test "-interpreter-exec console \"set args foobar\"" \ - {\^done} \ -@@ -97,7 +100,7 @@ mi_gdb_test "-interpreter-exec console \"list\"" \ - ".*\~\"$line_main_body\[\\\\t \]*callee1.*;\\\\n\".*\\^done" \ - "-interpreter-exec console \"list\"" - --mi_execute_to "exec-continue" "breakpoint-hit" "callee4" "" ".*basics.c" "28" \ -+mi_execute_to "exec-continue" "breakpoint-hit" "callee4" "" ".*basics.c" $line_callee4_body \ - { "" "disp=\"keep\"" } \ - "continue to callee4" - - 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-watchpoint-cond-gone.patch b/gdb-watchpoint-cond-gone.patch deleted file mode 100644 index 12a4c76..0000000 --- a/gdb-watchpoint-cond-gone.patch +++ /dev/null @@ -1,231 +0,0 @@ -http://sourceware.org/ml/gdb-patches/2009-12/msg00394.html -Subject: [patch] Fix watchpoint-at-epilogue 7.0 regression (s390x) - -Hi, - -attached testcase regressed 6.8->7.0 on some s390x systems. - -At the moment PC is at epilogue (after frame pointer got destroyed and PC is -still in the calleed function) we must not try any unwinding as it can try to -unwind a garbage. - -Correct way would be to implement epilogue unwinder (such as -amd64_epilogue_frame_unwind or i386_epilogue_frame_unwind ones) but it would -not be so easy on s390x as it would need full prologue-analyzer: After SP gets -restored there can be various instructions before the last jump - GDB needs to -interpret the jump to find the register value where it is going to jump to. -00000048279aa09c : -[...] - 48279aa1b8: eb 6f f0 d0 00 04 lmg %r6,%r15,208(%r15) - 48279aa1be: 50 32 10 00 st %r3,0(%r2,%r1) # SP (%r15) is gone hone - 48279aa1c2: b3 74 00 00 lzer %r0 - 48279aa1c6: 07 f4 br %r4 # %r4 is the target -[...] - -Just an easy fix is to be more careful and do not try any unwinding if we find -PC is in the epilogue (previous instruction modifies SP=%r15). - -It is even a performance optimization and I see no regression risk there. - -The specific s390x error is: -#0 throw_error (error=MEMORY_ERROR, fmt=0x8042676a "Cannot access memory at address %s") at exceptions.c:415 -#1 in memory_error (status=5, memaddr=0) at corefile.c:220 -#2 in read_memory (memaddr=0, myaddr=0x3ffffc7f7f0 "", len=8) at corefile.c:238 -#3 in read_memory_unsigned_integer (memaddr=0, len=8, byte_order=BFD_ENDIAN_BIG) at corefile.c:321 -#4 in s390_backchain_frame_unwind_cache (this_frame=0x80608958, info=0x80608a08) at s390-tdep.c:1525 -#5 in s390_frame_unwind_cache (this_frame=0x80608958, this_prologue_cache=0x80608970) at s390-tdep.c:1572 -#6 in s390_frame_this_id (this_frame=0x80608958, this_prologue_cache=0x80608970, this_id=0x806089b8) at s390-tdep.c:1583 -#7 in get_frame_id (fi=0x80608958) at frame.c:335 -#8 in frame_find_by_id (id={stack_addr = 4398044824952, code_addr = 2147484952, special_addr = 0, stack_addr_p = 1, code_addr_p = 1, special_addr_p = 0, inline_depth = 0}) at frame.c:587 -#9 in watchpoint_check (p=0x8095bbc0) at breakpoint.c:3203 -#10 in catch_errors (func=0x801262c0 , func_args=0x8095bbc0, errstring=0x80a26410 "Error evaluating expression for watchpoint 3\n", mask=6) at exceptions.c:510 -#11 in bpstat_check_watchpoint (bs=0x8095bbc0) at breakpoint.c:3404 -#12 in bpstat_stop_status (aspace=0x8061fcb0, bp_addr=2147485040, ptid={pid = 17372, lwp = 17372, tid = 0}) at breakpoint.c:3594 -#13 in handle_inferior_event (ecs=0x3ffffc80520) at infrun.c:3588 - -I did not analyze why 6.8 did not error out, the GDB code is similar there. - -No regressions on: -{x86_64,x86_64-m32,i686}-fedora12-linux-gnu (CVS HEAD GDB) -s390x-rhel48-linux-gnu (CVS HEAD GDB) -s390-rhel48-linux-gnu (CVS HEAD GDB) -s390x-rhel54-linux-gnu (Fedora 12 GDB) -s390-rhel54-linux-gnu (Fedora 12 GDB) - - -Thanks, -Jan - - -gdb/ -2009-12-25 Jan Kratochvil - - * breakpoint.c (watchpoint_check): Check the call - gdbarch_in_function_epilogue_p before calling frame_find_by_id. - Extend the comment. - -gdb/testsuite/ -2009-12-25 Jan Kratochvil - - * gdb.base/watchpoint-cond-gone.exp, gdb.base/watchpoint-cond-gone.c, - gdb.base/watchpoint-cond-gone-stripped.c: New. - ---- a/gdb/breakpoint.c -+++ b/gdb/breakpoint.c -@@ -3200,6 +3200,17 @@ watchpoint_check (void *p) - struct gdbarch *frame_arch = get_frame_arch (frame); - CORE_ADDR frame_pc = get_frame_pc (frame); - -+ /* in_function_epilogue_p() returns a non-zero value if we're still -+ in the function but the stack frame has already been invalidated. -+ Since we can't rely on the values of local variables after the -+ stack has been destroyed, we are treating the watchpoint in that -+ state as `not changed' without further checking. Don't mark -+ watchpoints as changed if the current frame is in an epilogue - -+ even if they are in some other frame, our view of the stack -+ is likely to be wrong and frame_find_by_id could error out. */ -+ if (gdbarch_in_function_epilogue_p (frame_arch, frame_pc)) -+ return WP_VALUE_NOT_CHANGED; -+ - fr = frame_find_by_id (b->watchpoint_frame); - within_current_scope = (fr != NULL); - -@@ -3216,17 +3227,6 @@ watchpoint_check (void *p) - within_current_scope = 0; - } - -- /* in_function_epilogue_p() returns a non-zero value if we're still -- in the function but the stack frame has already been invalidated. -- Since we can't rely on the values of local variables after the -- stack has been destroyed, we are treating the watchpoint in that -- state as `not changed' without further checking. Don't mark -- watchpoints as changed if the current frame is in an epilogue - -- even if they are in some other frame, our view of the stack -- is likely to be wrong. */ -- if (gdbarch_in_function_epilogue_p (frame_arch, frame_pc)) -- return WP_VALUE_NOT_CHANGED; -- - if (within_current_scope) - /* If we end up stopping, the current frame will get selected - in normal_stop. So this call to select_frame won't affect ---- /dev/null -+++ b/gdb/testsuite/gdb.base/watchpoint-cond-gone-stripped.c -@@ -0,0 +1,23 @@ -+/* 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 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 -+++ b/gdb/testsuite/gdb.base/watchpoint-cond-gone.c -@@ -0,0 +1,37 @@ -+/* 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 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)); -+ -+static void -+func (void) -+{ -+ volatile int c; -+ -+ c = 5; -+ c = 10; /* watchpoint-here */ -+ c = 20; -+} -+ -+int -+main (void) -+{ -+ jumper (func); -+ -+ return 0; -+} ---- /dev/null -+++ b/gdb/testsuite/gdb.base/watchpoint-cond-gone.exp -@@ -0,0 +1,51 @@ -+# 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. -+ -+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_compile "${srcdir}/${subdir}/${srcfile} ${objfilestripped}" "${binfile}" executable {debug}] != "" } { -+ gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." -+} -+ -+clean_restart ${testfile} -+ -+# Problem does not occur otherwise. -+gdb_test "set can-use-hw-watchpoints 0" -+ -+if ![runto_main] { -+ return -1 -+} -+ -+gdb_breakpoint [gdb_get_line_number "watchpoint-here"] -+gdb_continue_to_breakpoint "Place to set the watchpoint" -+ -+# The condition `c == 30' is the subject being tested. -+gdb_test "watch c if c == 30" "" "Place the watchpoint" -+ -+# We may stay either in the function itself or only at the first instruction of -+# its caller depending on the epilogue unwinder (or valid epilogue CFI) presence. -+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.spec b/gdb.spec index 3d59fcd..228d484 100644 --- a/gdb.spec +++ b/gdb.spec @@ -32,11 +32,11 @@ Name: gdb%{?_with_debug:-debug} # Set version to contents of gdb/version.in. # NOTE: the FSF gdb versions are numbered N.M for official releases, like 6.3 # and, since January 2005, X.Y.Z.date for daily snapshots, like 6.3.50.20050112 # (daily snapshot from mailine), or 6.3.0.20040112 (head of the release branch). -Version: 7.0.50.20100118 +Version: 7.0.50.20100121 # The release always contains a leading reserved number, start it at 1. # `upstream' is not a part of `name' to stay fully rpm dependencies compatible for the testing. -Release: 2%{?_with_upstream:.upstream}%{dist} +Release: 1%{?_with_upstream:.upstream}%{dist} License: GPLv3+ Group: Development/Debuggers @@ -322,9 +322,6 @@ Patch309: gdb-6.3-mapping-zero-inode-test.patch # Test a crash on `focus cmd', `focus prev' commands. Patch311: gdb-6.3-focus-cmd-prev-test.patch -# Fix error on a sw watchpoint active at function epilogue (hit on s390x). -Patch314: gdb-watchpoint-cond-gone.patch - # Test various forms of threads tracking across exec() (BZ 442765). Patch315: gdb-6.8-bz442765-threaded-exec-test.patch @@ -403,9 +400,6 @@ Patch393: gdb-rhel5-gcc44.patch # Workaround RHEL-5 kernels for detaching SIGSTOPped processes (BZ 498595). Patch335: gdb-rhel5-compat.patch -# Fix backward compatibility with G++ 4.1 namespaces "::". -Patch395: gdb-empty-namespace.patch - # Fix regression by python on ia64 due to stale current frame. Patch397: gdb-follow-child-stale-parent.patch @@ -428,8 +422,11 @@ Patch407: gdb-lineno-makeup-test.patch # Test power7 ppc disassembly. Patch408: gdb-ppc-power7-test.patch -# [patch] testsuite: Fix misplaced line numbers -Patch410: gdb-testsuite-lineno.patch +# Fix solib-display.exp crash +Patch411: gdb-solib-display.patch + +# Revert: Add -Wunused-function to compile flags. +Patch412: gdb-unused-revert.patch BuildRequires: ncurses-devel%{?_isa} texinfo gettext flex bison expat-devel%{?_isa} Requires: readline%{?_isa} @@ -641,7 +638,6 @@ 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 @@ -665,7 +661,6 @@ rm -f gdb/jv-exp.c gdb/m2-exp.c gdb/objc-exp.c gdb/p-exp.c %patch390 -p1 %patch391 -p1 %patch392 -p1 -%patch395 -p1 %patch397 -p1 %patch400 -p1 %patch403 -p1 @@ -676,7 +671,8 @@ rm -f gdb/jv-exp.c gdb/m2-exp.c gdb/objc-exp.c gdb/p-exp.c %patch406 -p1 %patch407 -p1 %patch408 -p1 -%patch410 -p1 +%patch411 -p1 +%patch412 -p1 # Always verify its applicability. %patch393 -p1 %patch335 -p1 @@ -1002,6 +998,11 @@ fi %endif %changelog +* Thu Jan 21 2010 Jan Kratochvil - 7.0.50.20100121-1.fc13 +- Upgrade to the FSF GDB snapshot: 7.0.50.20100121 +- archer-jankratochvil-fedora13 commit: ccde1530479cc966374351038057b9dda90aa251 +- [expr-cumulative] Archer branch is now included. + * Tue Jan 19 2010 Jan Kratochvil - 7.0.50.20100118-2.fc13 - Fix false PASS->FAIL of gdb.arch/i386-biarch-core.exp. diff --git a/sources b/sources index 2221761..7fa6a44 100644 --- a/sources +++ b/sources @@ -1,2 +1,2 @@ -2fb1a2ac78b3bdc495bbabd85e310a5d gdb-7.0.50.20100118.tar.bz2 +fcfbe6ccb36d86bc06891fbd70f1664d gdb-7.0.50.20100121.tar.bz2 04e5c4b1b9e633422cc48990fe61958d libstdc++-v3-python-r155978.tar.bz2