diff --git a/.gitignore b/.gitignore index 5910984..6c4f28d 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1 @@ -/gdb-7.2.50.20110104.tar.bz2 +/gdb-7.2.50.20110107.tar.bz2 diff --git a/gdb-6.3-ia64-gcore-page0-20050421.patch b/gdb-6.3-ia64-gcore-page0-20050421.patch index 0c4245c..ecdfbae 100644 --- a/gdb-6.3-ia64-gcore-page0-20050421.patch +++ b/gdb-6.3-ia64-gcore-page0-20050421.patch @@ -1,8 +1,8 @@ -Index: gdb-6.8.50.20090802/gdb/gcore.c +Index: gdb-7.2.50.20110107/gdb/gcore.c =================================================================== ---- gdb-6.8.50.20090802.orig/gdb/gcore.c 2009-08-03 12:27:55.000000000 +0200 -+++ gdb-6.8.50.20090802/gdb/gcore.c 2009-08-03 12:28:56.000000000 +0200 -@@ -479,8 +479,14 @@ gcore_copy_callback (bfd *obfd, asection +--- gdb-7.2.50.20110107.orig/gdb/gcore.c 2011-01-05 23:22:49.000000000 +0100 ++++ gdb-7.2.50.20110107/gdb/gcore.c 2011-01-07 09:04:28.000000000 +0100 +@@ -534,8 +534,14 @@ gcore_copy_callback (bfd *obfd, asection if (size > total_size) size = total_size; @@ -16,5 +16,5 @@ Index: gdb-6.8.50.20090802/gdb/gcore.c + "ia64") + || bfd_section_vma (obfd, osec) != 0)) { - warning (_("Memory read failed for corefile section, %s bytes at %s."), - plongest (size), + warning (_("Memory read failed for corefile " + "section, %s bytes at %s."), diff --git a/gdb-6.3-readnever-20050907.patch b/gdb-6.3-readnever-20050907.patch index 80e3068..86c31bf 100644 --- a/gdb-6.3-readnever-20050907.patch +++ b/gdb-6.3-readnever-20050907.patch @@ -11,10 +11,10 @@ * gdb.texinfo (File Options): Document --readnever. -Index: gdb-7.2.50.20101231/gdb/doc/gdb.texinfo +Index: gdb-7.2.50.20110107/gdb/doc/gdb.texinfo =================================================================== ---- gdb-7.2.50.20101231.orig/gdb/doc/gdb.texinfo 2010-12-29 09:01:31.000000000 +0100 -+++ gdb-7.2.50.20101231/gdb/doc/gdb.texinfo 2011-01-01 00:54:07.000000000 +0100 +--- gdb-7.2.50.20110107.orig/gdb/doc/gdb.texinfo 2011-01-07 09:03:38.000000000 +0100 ++++ gdb-7.2.50.20110107/gdb/doc/gdb.texinfo 2011-01-07 09:04:48.000000000 +0100 @@ -1007,6 +1007,12 @@ Read each symbol file's entire symbol ta the default, which is to read it incrementally as it is needed. This makes startup slower, but makes future operations faster. @@ -28,11 +28,11 @@ Index: gdb-7.2.50.20101231/gdb/doc/gdb.texinfo @end table @node Mode Options -Index: gdb-7.2.50.20101231/gdb/main.c +Index: gdb-7.2.50.20110107/gdb/main.c =================================================================== ---- gdb-7.2.50.20101231.orig/gdb/main.c 2011-01-01 00:53:09.000000000 +0100 -+++ gdb-7.2.50.20101231/gdb/main.c 2011-01-01 00:54:07.000000000 +0100 -@@ -391,6 +391,7 @@ captured_main (void *data) +--- gdb-7.2.50.20110107.orig/gdb/main.c 2011-01-07 09:04:39.000000000 +0100 ++++ gdb-7.2.50.20110107/gdb/main.c 2011-01-07 09:05:02.000000000 +0100 +@@ -395,6 +395,7 @@ captured_main (void *data) {"xdb", no_argument, &xdb_commands, 1}, {"dbx", no_argument, &dbx_commands, 1}, {"readnow", no_argument, &readnow_symbol_files, 1}, @@ -40,19 +40,19 @@ Index: gdb-7.2.50.20101231/gdb/main.c {"r", no_argument, &readnow_symbol_files, 1}, {"quiet", no_argument, &quiet, 1}, {"q", no_argument, &quiet, 1}, -@@ -993,6 +994,7 @@ Options:\n\n\ - fputs_unfiltered (_(" file.\n\ +@@ -1060,6 +1061,7 @@ Options:\n\n\ + fputs_unfiltered (_("\ --quiet Do not print version number on startup.\n\ --readnow Fully read symbol files on first access.\n\ + --readnever Do not read symbol files.\n\ "), stream); fputs_unfiltered (_("\ --se=FILE Use FILE as symbol file and executable file.\n\ -Index: gdb-7.2.50.20101231/gdb/symfile.c +Index: gdb-7.2.50.20110107/gdb/symfile.c =================================================================== ---- gdb-7.2.50.20101231.orig/gdb/symfile.c 2010-11-23 01:59:58.000000000 +0100 -+++ gdb-7.2.50.20101231/gdb/symfile.c 2011-01-01 00:54:07.000000000 +0100 -@@ -80,6 +80,7 @@ static void clear_symtab_users_cleanup ( +--- gdb-7.2.50.20110107.orig/gdb/symfile.c 2011-01-05 23:22:50.000000000 +0100 ++++ gdb-7.2.50.20110107/gdb/symfile.c 2011-01-07 09:04:48.000000000 +0100 +@@ -81,6 +81,7 @@ static void clear_symtab_users_cleanup ( /* Global variables owned by this file */ int readnow_symbol_files; /* Read full symbols immediately */ @@ -60,10 +60,10 @@ Index: gdb-7.2.50.20101231/gdb/symfile.c /* External variables and functions referenced. */ -Index: gdb-7.2.50.20101231/gdb/dwarf2read.c +Index: gdb-7.2.50.20110107/gdb/dwarf2read.c =================================================================== ---- gdb-7.2.50.20101231.orig/gdb/dwarf2read.c 2011-01-01 00:41:51.000000000 +0100 -+++ gdb-7.2.50.20101231/gdb/dwarf2read.c 2011-01-01 00:54:07.000000000 +0100 +--- gdb-7.2.50.20110107.orig/gdb/dwarf2read.c 2011-01-07 09:03:38.000000000 +0100 ++++ gdb-7.2.50.20110107/gdb/dwarf2read.c 2011-01-07 09:04:48.000000000 +0100 @@ -57,6 +57,7 @@ #include "vec.h" #include "c-lang.h" @@ -72,7 +72,7 @@ Index: gdb-7.2.50.20101231/gdb/dwarf2read.c #include #include "gdb_string.h" -@@ -1345,8 +1346,9 @@ dwarf2_has_info (struct objfile *objfile +@@ -1350,8 +1351,9 @@ dwarf2_has_info (struct objfile *objfile bfd_map_over_sections (objfile->obfd, dwarf2_locate_sections, NULL); dwarf2_per_objfile->objfile = objfile; } @@ -84,10 +84,10 @@ Index: gdb-7.2.50.20101231/gdb/dwarf2read.c } /* When loading sections, we can either look for ".", or for -Index: gdb-7.2.50.20101231/gdb/top.h +Index: gdb-7.2.50.20110107/gdb/top.h =================================================================== ---- gdb-7.2.50.20101231.orig/gdb/top.h 2010-12-29 01:58:14.000000000 +0100 -+++ gdb-7.2.50.20101231/gdb/top.h 2011-01-01 00:54:21.000000000 +0100 +--- gdb-7.2.50.20110107.orig/gdb/top.h 2011-01-01 16:33:18.000000000 +0100 ++++ gdb-7.2.50.20110107/gdb/top.h 2011-01-07 09:04:48.000000000 +0100 @@ -61,6 +61,7 @@ extern void set_prompt (char *); /* From random places. */ diff --git a/gdb-6.5-bz218379-solib-trampoline-lookup-lock-fix.patch b/gdb-6.5-bz218379-solib-trampoline-lookup-lock-fix.patch index b7bbe42..2e78a3e 100644 --- a/gdb-6.5-bz218379-solib-trampoline-lookup-lock-fix.patch +++ b/gdb-6.5-bz218379-solib-trampoline-lookup-lock-fix.patch @@ -1,13 +1,13 @@ https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=218379 -Index: gdb-6.8.50.20090803/gdb/symtab.c +Index: gdb-7.2.50.20110107/gdb/symtab.c =================================================================== ---- gdb-6.8.50.20090803.orig/gdb/symtab.c 2009-08-03 16:09:36.000000000 +0200 -+++ gdb-6.8.50.20090803/gdb/symtab.c 2009-08-03 16:13:13.000000000 +0200 -@@ -2261,6 +2261,13 @@ find_pc_sect_line (CORE_ADDR pc, struct - /* See above comment about why warning is commented out */ - /* warning ("In stub for %s; unable to find real function/line info", SYMBOL_LINKAGE_NAME (msymbol)) */ ; +--- gdb-7.2.50.20110107.orig/gdb/symtab.c 2011-01-07 09:03:38.000000000 +0100 ++++ gdb-7.2.50.20110107/gdb/symtab.c 2011-01-07 09:06:32.000000000 +0100 +@@ -2014,6 +2014,13 @@ find_pc_sect_line (CORE_ADDR pc, struct + /* warning ("In stub for %s; unable to find real function/line info", + SYMBOL_LINKAGE_NAME (msymbol)) */ ; /* fall through */ + /* `msymbol' trampoline may be located before its .text symbol + but this text symbol may be the address we were looking for. diff --git a/gdb-6.6-buildid-locate-core-as-arg.patch b/gdb-6.6-buildid-locate-core-as-arg.patch index c8b8883..e4a5767 100644 --- a/gdb-6.6-buildid-locate-core-as-arg.patch +++ b/gdb-6.6-buildid-locate-core-as-arg.patch @@ -58,10 +58,10 @@ Http://sourceware.org/ml/gdb-patches/2010-01/msg00517.html * exec.c (exec_file_attach): Print a more useful error message if the user did "gdb core". -Index: gdb-7.2.50.20101231/gdb/exceptions.h +Index: gdb-7.2.50.20110107/gdb/exceptions.h =================================================================== ---- gdb-7.2.50.20101231.orig/gdb/exceptions.h 2010-05-03 01:52:14.000000000 +0200 -+++ gdb-7.2.50.20101231/gdb/exceptions.h 2011-01-01 01:10:44.000000000 +0100 +--- gdb-7.2.50.20110107.orig/gdb/exceptions.h 2011-01-05 23:22:48.000000000 +0100 ++++ gdb-7.2.50.20110107/gdb/exceptions.h 2011-01-07 09:09:18.000000000 +0100 @@ -78,6 +78,9 @@ enum errors { /* Feature is not supported in this copy of GDB. */ UNSUPPORTED_ERROR, @@ -72,10 +72,10 @@ Index: gdb-7.2.50.20101231/gdb/exceptions.h /* Add more errors here. */ NR_ERRORS }; -Index: gdb-7.2.50.20101231/gdb/exec.c +Index: gdb-7.2.50.20110107/gdb/exec.c =================================================================== ---- gdb-7.2.50.20101231.orig/gdb/exec.c 2010-08-31 20:08:43.000000000 +0200 -+++ gdb-7.2.50.20101231/gdb/exec.c 2011-01-01 01:10:44.000000000 +0100 +--- gdb-7.2.50.20110107.orig/gdb/exec.c 2011-01-05 23:22:48.000000000 +0100 ++++ gdb-7.2.50.20110107/gdb/exec.c 2011-01-07 09:09:18.000000000 +0100 @@ -34,6 +34,7 @@ #include "arch-utils.h" #include "gdbthread.h" @@ -115,11 +115,11 @@ Index: gdb-7.2.50.20101231/gdb/exec.c } /* FIXME - This should only be run for RS6000, but the ifdef is a poor -Index: gdb-7.2.50.20101231/gdb/main.c +Index: gdb-7.2.50.20110107/gdb/main.c =================================================================== ---- gdb-7.2.50.20101231.orig/gdb/main.c 2011-01-01 01:00:54.000000000 +0100 -+++ gdb-7.2.50.20101231/gdb/main.c 2011-01-01 01:11:48.000000000 +0100 -@@ -242,6 +242,36 @@ captured_command_loop (void *data) +--- gdb-7.2.50.20110107.orig/gdb/main.c 2011-01-07 09:05:02.000000000 +0100 ++++ gdb-7.2.50.20110107/gdb/main.c 2011-01-07 09:10:14.000000000 +0100 +@@ -243,6 +243,36 @@ captured_command_loop (void *data) return 1; } @@ -156,7 +156,7 @@ Index: gdb-7.2.50.20101231/gdb/main.c static int captured_main (void *data) { -@@ -688,6 +718,8 @@ captured_main (void *data) +@@ -726,6 +756,8 @@ captured_main (void *data) { symarg = argv[optind]; execarg = argv[optind]; @@ -165,7 +165,7 @@ Index: gdb-7.2.50.20101231/gdb/main.c optind++; } -@@ -828,10 +860,25 @@ Excess command line arguments ignored. ( +@@ -867,11 +899,25 @@ captured_main (void *data) && symarg != NULL && strcmp (execarg, symarg) == 0) { @@ -184,12 +184,13 @@ Index: gdb-7.2.50.20101231/gdb/main.c /* The exec file and the symbol-file are the same. If we can't open it, better only print one error message. - catch_command_errors returns non-zero on success! */ -- if (catch_command_errors (exec_file_attach, execarg, !batch_flag, RETURN_MASK_ALL)) +- if (catch_command_errors (exec_file_attach, execarg, +- !batch_flag, RETURN_MASK_ALL)) + catch_command_errors returns non-zero on success! + Do not load EXECARG as a symbol file if it has been already processed + as a core file. */ + if (catch_command_errors (func, execarg, !batch_flag, RETURN_MASK_ALL) + && core_bfd == NULL) - catch_command_errors (symbol_file_add_main, symarg, !batch_flag, RETURN_MASK_ALL); + catch_command_errors (symbol_file_add_main, symarg, + !batch_flag, RETURN_MASK_ALL); } - else diff --git a/gdb-6.6-buildid-locate.patch b/gdb-6.6-buildid-locate.patch index 19cb8ad..e35447c 100644 --- a/gdb-6.6-buildid-locate.patch +++ b/gdb-6.6-buildid-locate.patch @@ -1,7 +1,7 @@ -Index: gdb-7.2.50.20110104/gdb/corelow.c +Index: gdb-7.2.50.20110107/gdb/corelow.c =================================================================== ---- gdb-7.2.50.20110104.orig/gdb/corelow.c 2011-01-01 16:32:59.000000000 +0100 -+++ gdb-7.2.50.20110104/gdb/corelow.c 2011-01-04 06:15:49.000000000 +0100 +--- gdb-7.2.50.20110107.orig/gdb/corelow.c 2011-01-05 23:22:47.000000000 +0100 ++++ gdb-7.2.50.20110107/gdb/corelow.c 2011-01-07 09:07:01.000000000 +0100 @@ -47,6 +47,9 @@ #include "filenames.h" #include "progspace.h" @@ -12,7 +12,7 @@ Index: gdb-7.2.50.20110104/gdb/corelow.c #ifndef O_LARGEFILE -@@ -277,6 +280,52 @@ add_to_thread_list (bfd *abfd, asection +@@ -278,6 +281,52 @@ add_to_thread_list (bfd *abfd, asection inferior_ptid = ptid; /* Yes, make it current. */ } @@ -65,7 +65,7 @@ Index: gdb-7.2.50.20110104/gdb/corelow.c /* This routine opens and sets up the core file bfd. */ static void -@@ -377,6 +426,12 @@ core_open (char *filename, int from_tty) +@@ -379,6 +428,12 @@ core_open (char *filename, int from_tty) push_target (&core_ops); discard_cleanups (old_chain); @@ -78,7 +78,7 @@ Index: gdb-7.2.50.20110104/gdb/corelow.c /* Do this before acknowledging the inferior, so if post_create_inferior throws (can happen easilly if you're loading a core file with the wrong exec), we aren't left with threads -@@ -930,4 +985,11 @@ _initialize_corelow (void) +@@ -932,4 +987,11 @@ _initialize_corelow (void) init_core_ops (); add_target (&core_ops); @@ -90,11 +90,11 @@ Index: gdb-7.2.50.20110104/gdb/corelow.c + NULL, NULL, NULL, + &setlist, &showlist); } -Index: gdb-7.2.50.20110104/gdb/doc/gdb.texinfo +Index: gdb-7.2.50.20110107/gdb/doc/gdb.texinfo =================================================================== ---- gdb-7.2.50.20110104.orig/gdb/doc/gdb.texinfo 2011-01-04 06:15:02.000000000 +0100 -+++ gdb-7.2.50.20110104/gdb/doc/gdb.texinfo 2011-01-04 06:15:14.000000000 +0100 -@@ -15267,6 +15267,27 @@ information files. +--- gdb-7.2.50.20110107.orig/gdb/doc/gdb.texinfo 2011-01-07 09:04:48.000000000 +0100 ++++ gdb-7.2.50.20110107/gdb/doc/gdb.texinfo 2011-01-07 09:07:01.000000000 +0100 +@@ -15277,6 +15277,27 @@ information files. @end table @@ -122,10 +122,10 @@ Index: gdb-7.2.50.20110104/gdb/doc/gdb.texinfo @cindex @code{.gnu_debuglink} sections @cindex debug link sections A debug link is a special section of the executable file named -Index: gdb-7.2.50.20110104/gdb/solib-svr4.c +Index: gdb-7.2.50.20110107/gdb/solib-svr4.c =================================================================== ---- gdb-7.2.50.20110104.orig/gdb/solib-svr4.c 2011-01-04 06:15:01.000000000 +0100 -+++ gdb-7.2.50.20110104/gdb/solib-svr4.c 2011-01-04 06:15:14.000000000 +0100 +--- gdb-7.2.50.20110107.orig/gdb/solib-svr4.c 2011-01-07 09:03:38.000000000 +0100 ++++ gdb-7.2.50.20110107/gdb/solib-svr4.c 2011-01-07 09:07:01.000000000 +0100 @@ -1179,9 +1179,49 @@ svr4_current_sos (void) safe_strerror (errcode)); else @@ -179,10 +179,10 @@ Index: gdb-7.2.50.20110104/gdb/solib-svr4.c } xfree (buffer); -Index: gdb-7.2.50.20110104/gdb/elfread.c +Index: gdb-7.2.50.20110107/gdb/elfread.c =================================================================== ---- gdb-7.2.50.20110104.orig/gdb/elfread.c 2011-01-04 06:15:01.000000000 +0100 -+++ gdb-7.2.50.20110104/gdb/elfread.c 2011-01-04 06:15:14.000000000 +0100 +--- gdb-7.2.50.20110107.orig/gdb/elfread.c 2011-01-07 09:03:38.000000000 +0100 ++++ gdb-7.2.50.20110107/gdb/elfread.c 2011-01-07 09:07:33.000000000 +0100 @@ -38,6 +38,10 @@ #include "demangle.h" #include "psympriv.h" @@ -194,7 +194,7 @@ Index: gdb-7.2.50.20110104/gdb/elfread.c extern void _initialize_elfread (void); -@@ -821,16 +825,65 @@ resolve_gnu_ifunc (const char *function_ +@@ -823,16 +827,65 @@ resolve_gnu_ifunc (const char *function_ return 0; } @@ -262,7 +262,7 @@ Index: gdb-7.2.50.20110104/gdb/elfread.c { struct build_id *retval; -@@ -846,6 +899,348 @@ build_id_bfd_get (bfd *abfd) +@@ -848,6 +901,348 @@ build_id_bfd_get (bfd *abfd) return retval; } @@ -611,7 +611,7 @@ Index: gdb-7.2.50.20110104/gdb/elfread.c /* Return if FILENAME has NT_GNU_BUILD_ID matching the CHECK value. */ static int -@@ -860,7 +1255,7 @@ build_id_verify (const char *filename, s +@@ -862,7 +1257,7 @@ build_id_verify (const char *filename, s if (abfd == NULL) return 0; @@ -620,7 +620,7 @@ Index: gdb-7.2.50.20110104/gdb/elfread.c if (found == NULL) warning (_("File \"%s\" has no build-id, file skipped"), filename); -@@ -877,14 +1272,16 @@ build_id_verify (const char *filename, s +@@ -880,14 +1275,16 @@ build_id_verify (const char *filename, s return retval; } @@ -641,7 +641,7 @@ Index: gdb-7.2.50.20110104/gdb/elfread.c /* Keep backward compatibility so that DEBUG_FILE_DIRECTORY being "" will cause "/.build-id/..." lookups. */ -@@ -915,7 +1312,10 @@ build_id_to_debug_filename (struct build +@@ -918,7 +1315,10 @@ build_id_to_debug_filename (struct build *s++ = '/'; while (size-- > 0) s += sprintf (s, "%02x", (unsigned) *data++); @@ -653,7 +653,7 @@ Index: gdb-7.2.50.20110104/gdb/elfread.c /* lrealpath() is expensive even for the usually non-existent files. */ if (access (link, F_OK) == 0) -@@ -928,26 +1328,201 @@ build_id_to_debug_filename (struct build +@@ -931,26 +1331,201 @@ build_id_to_debug_filename (struct build } if (retval != NULL) @@ -859,7 +859,7 @@ Index: gdb-7.2.50.20110104/gdb/elfread.c xfree (build_id); /* Prevent looping on a stripped .debug file. */ if (build_id_name != NULL && strcmp (build_id_name, objfile->name) == 0) -@@ -957,7 +1532,7 @@ find_separate_debug_file_by_buildid (str +@@ -960,7 +1535,7 @@ find_separate_debug_file_by_buildid (str xfree (build_id_name); } else if (build_id_name != NULL) @@ -868,8 +868,8 @@ Index: gdb-7.2.50.20110104/gdb/elfread.c } return NULL; } -@@ -1138,9 +1713,10 @@ elf_symfile_read (struct objfile *objfil - `.gnu_debuglink' may no longer be present with `.note.gnu.build-id'. */ +@@ -1148,9 +1723,10 @@ elf_symfile_read (struct objfile *objfil + `.note.gnu.build-id'. */ if (!objfile_has_partial_symbols (objfile)) { - char *debugfile; @@ -881,7 +881,7 @@ Index: gdb-7.2.50.20110104/gdb/elfread.c if (debugfile == NULL) debugfile = find_separate_debug_file_by_debuglink (objfile); -@@ -1152,6 +1728,12 @@ elf_symfile_read (struct objfile *objfil +@@ -1162,6 +1738,12 @@ elf_symfile_read (struct objfile *objfil symbol_file_add_separate (abfd, symfile_flags, objfile); xfree (debugfile); } @@ -894,7 +894,7 @@ Index: gdb-7.2.50.20110104/gdb/elfread.c } } -@@ -1327,4 +1909,16 @@ void +@@ -1337,4 +1919,16 @@ void _initialize_elfread (void) { add_symtab_fns (&elf_sym_fns); @@ -911,11 +911,11 @@ Index: gdb-7.2.50.20110104/gdb/elfread.c + + observer_attach_executable_changed (debug_print_executable_changed); } -Index: gdb-7.2.50.20110104/gdb/symfile.h +Index: gdb-7.2.50.20110107/gdb/symfile.h =================================================================== ---- gdb-7.2.50.20110104.orig/gdb/symfile.h 2011-01-01 16:33:16.000000000 +0100 -+++ gdb-7.2.50.20110104/gdb/symfile.h 2011-01-04 06:15:14.000000000 +0100 -@@ -553,6 +553,13 @@ void free_symfile_segment_data (struct s +--- gdb-7.2.50.20110107.orig/gdb/symfile.h 2011-01-05 23:22:53.000000000 +0100 ++++ gdb-7.2.50.20110107/gdb/symfile.h 2011-01-07 09:07:01.000000000 +0100 +@@ -554,6 +554,13 @@ void free_symfile_segment_data (struct s extern struct cleanup *increment_reading_symtab (void); @@ -929,11 +929,11 @@ Index: gdb-7.2.50.20110104/gdb/symfile.h /* From dwarf2read.c */ extern int dwarf2_has_info (struct objfile *); -Index: gdb-7.2.50.20110104/gdb/testsuite/lib/gdb.exp +Index: gdb-7.2.50.20110107/gdb/testsuite/lib/gdb.exp =================================================================== ---- gdb-7.2.50.20110104.orig/gdb/testsuite/lib/gdb.exp 2011-01-04 06:15:01.000000000 +0100 -+++ gdb-7.2.50.20110104/gdb/testsuite/lib/gdb.exp 2011-01-04 06:15:14.000000000 +0100 -@@ -1390,6 +1390,16 @@ proc default_gdb_start { } { +--- gdb-7.2.50.20110107.orig/gdb/testsuite/lib/gdb.exp 2011-01-07 09:03:38.000000000 +0100 ++++ gdb-7.2.50.20110107/gdb/testsuite/lib/gdb.exp 2011-01-07 09:07:01.000000000 +0100 +@@ -1391,6 +1391,16 @@ proc default_gdb_start { } { warning "Couldn't set the width to 0." } } @@ -950,10 +950,10 @@ Index: gdb-7.2.50.20110104/gdb/testsuite/lib/gdb.exp return 0; } -Index: gdb-7.2.50.20110104/gdb/testsuite/lib/mi-support.exp +Index: gdb-7.2.50.20110107/gdb/testsuite/lib/mi-support.exp =================================================================== ---- gdb-7.2.50.20110104.orig/gdb/testsuite/lib/mi-support.exp 2011-01-01 16:33:52.000000000 +0100 -+++ gdb-7.2.50.20110104/gdb/testsuite/lib/mi-support.exp 2011-01-04 06:15:14.000000000 +0100 +--- gdb-7.2.50.20110107.orig/gdb/testsuite/lib/mi-support.exp 2011-01-01 16:33:52.000000000 +0100 ++++ gdb-7.2.50.20110107/gdb/testsuite/lib/mi-support.exp 2011-01-07 09:07:01.000000000 +0100 @@ -221,6 +221,16 @@ proc default_mi_gdb_start { args } { } } @@ -971,11 +971,11 @@ Index: gdb-7.2.50.20110104/gdb/testsuite/lib/mi-support.exp detect_async -Index: gdb-7.2.50.20110104/gdb/objfiles.h +Index: gdb-7.2.50.20110107/gdb/objfiles.h =================================================================== ---- gdb-7.2.50.20110104.orig/gdb/objfiles.h 2011-01-01 16:33:12.000000000 +0100 -+++ gdb-7.2.50.20110104/gdb/objfiles.h 2011-01-04 06:15:14.000000000 +0100 -@@ -433,6 +433,10 @@ struct objfile +--- gdb-7.2.50.20110107.orig/gdb/objfiles.h 2011-01-05 23:22:49.000000000 +0100 ++++ gdb-7.2.50.20110107/gdb/objfiles.h 2011-01-07 09:07:01.000000000 +0100 +@@ -434,6 +434,10 @@ struct objfile #define OBJF_USERLOADED (1 << 3) /* User loaded */ diff --git a/gdb-archer.patch b/gdb-archer.patch index b8e47a9..63204d4 100644 --- a/gdb-archer.patch +++ b/gdb-archer.patch @@ -2,17 +2,44 @@ http://sourceware.org/gdb/wiki/ProjectArcher http://sourceware.org/gdb/wiki/ArcherBranchManagement GIT snapshot: -commit 2be613ebefe3f3c2a5bb329c207d435024af7a2b +commit f06acfde4cc6df21d4f34547e5de1a0170e7b263 branch `archer' - the merge of branches: archer-jankratochvil-vla archer-jankratochvil-watchpoint3 archer-jankratochvil-ifunc -#TODO?:archer-tromey-python (not a merge) +archer-tromey-python #TODO?:archer-tromey-optional-psymtab (cherry-picked from post-7.2 master) #TODO?:archer-tromey-threaded-dwarf +diff --git a/gdb/Makefile.in b/gdb/Makefile.in +index 9459de4..95c3b57 100644 +--- a/gdb/Makefile.in ++++ b/gdb/Makefile.in +@@ -782,7 +782,8 @@ config/rs6000/nm-rs6000.h top.h bsd-kvm.h gdb-stabs.h reggroups.h \ + annotate.h sim-regno.h dictionary.h dfp.h main.h frame-unwind.h \ + remote-fileio.h i386-linux-tdep.h vax-tdep.h objc-lang.h \ + sentinel-frame.h bcache.h symfile.h windows-tdep.h linux-tdep.h \ +-gdb_usleep.h jit.h xml-syscall.h ada-operator.inc microblaze-tdep.h \ ++gdb_usleep.h jit.h python/python.h python/python-internal.h \ ++xml-syscall.h ada-operator.inc microblaze-tdep.h \ + psymtab.h psympriv.h progspace.h bfin-tdep.h + + # Header files that already have srcdir in them, or which are in objdir. +@@ -1289,6 +1290,12 @@ stamp-h: $(srcdir)/config.in config.status + CONFIG_LINKS= \ + $(SHELL) config.status + ++.gdbinit: $(srcdir)/gdbinit.in config.status ++ CONFIG_FILES=".gdbinit:gdbinit.in" \ ++ CONFIG_COMMANDS= \ ++ CONFIG_HEADERS= \ ++ $(SHELL) config.status ++ + config.status: $(srcdir)/configure configure.tgt configure.host + $(SHELL) config.status --recheck + diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index 3efff2e..99097bf 100644 --- a/gdb/ada-lang.c @@ -303,7 +330,7 @@ index 07d5bc7..fad89b1 100644 + #endif /* BLOCK_H */ diff --git a/gdb/blockframe.c b/gdb/blockframe.c -index 4cfc6e6..dc64d51 100644 +index b9aaf54..e1f3242 100644 --- a/gdb/blockframe.c +++ b/gdb/blockframe.c @@ -160,6 +160,7 @@ static CORE_ADDR cache_pc_function_low = 0; @@ -354,7 +381,7 @@ index 4cfc6e6..dc64d51 100644 /* If the minimal symbol has a size, use it for the cache. Otherwise use the lesser of the next minimal symbol in the same -@@ -324,7 +328,8 @@ find_pc_partial_function (CORE_ADDR pc, char **name, CORE_ADDR *address, +@@ -327,7 +331,8 @@ find_pc_partial_function (CORE_ADDR pc, char **name, CORE_ADDR *address, *endaddr = cache_pc_function_high; } @@ -365,7 +392,7 @@ index 4cfc6e6..dc64d51 100644 /* Return the innermost stack frame executing inside of BLOCK, or NULL diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c -index 785155c..63d736f 100644 +index 97efc0a..f633f57 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -62,6 +62,7 @@ @@ -397,7 +424,7 @@ index 785155c..63d736f 100644 /* Assuming we're creating a static tracepoint, does S look like a static tracepoint marker spec ("-m MARKER_ID")? */ #define is_marker_spec(s) \ -@@ -1270,6 +1278,22 @@ watchpoint_in_thread_scope (struct breakpoint *b) +@@ -1278,6 +1286,22 @@ watchpoint_in_thread_scope (struct breakpoint *b) && !is_executing (inferior_ptid))); } @@ -420,7 +447,7 @@ index 785155c..63d736f 100644 /* Assuming that B is a watchpoint: - Reparse watchpoint expression, if REPARSE is non-zero - Evaluate expression and store the result in B->val -@@ -1329,12 +1353,17 @@ update_watchpoint (struct breakpoint *b, int reparse) +@@ -1337,12 +1361,17 @@ update_watchpoint (struct breakpoint *b, int reparse) struct frame_id saved_frame_id; int frame_saved; @@ -438,9 +465,9 @@ index 785155c..63d736f 100644 /* We don't free locations. They are stored in bp_location array and update_global_locations will eventually delete them and remove breakpoints if needed. */ -@@ -1534,13 +1563,7 @@ update_watchpoint (struct breakpoint *b, int reparse) - Watchpoint %d deleted because the program has left the block\n\ - in which its expression is valid.\n"), +@@ -1542,13 +1571,7 @@ update_watchpoint (struct breakpoint *b, int reparse) + "the program has left the block\n" + "in which its expression is valid.\n"), b->number); - if (b->related_breakpoint) - { @@ -453,7 +480,7 @@ index 785155c..63d736f 100644 } /* Restore the selected frame. */ -@@ -1916,6 +1939,7 @@ insert_breakpoint_locations (void) +@@ -1930,6 +1953,7 @@ insert_breakpoint_locations (void) int val = 0; int disabled_breaks = 0; int hw_breakpoint_error = 0; @@ -461,7 +488,7 @@ index 785155c..63d736f 100644 struct ui_file *tmp_error_stream = mem_fileopen (); struct cleanup *cleanups = make_cleanup_ui_file_delete (tmp_error_stream); -@@ -1943,9 +1967,13 @@ insert_breakpoint_locations (void) +@@ -1957,9 +1981,13 @@ insert_breakpoint_locations (void) /* For targets that support global breakpoints, there's no need to select an inferior to insert breakpoint to. In fact, even if we aren't attached to any process yet, we should still @@ -477,7 +504,7 @@ index 785155c..63d736f 100644 continue; val = insert_bp_location (bl, tmp_error_stream, &disabled_breaks, -@@ -1969,13 +1997,19 @@ insert_breakpoint_locations (void) +@@ -1983,13 +2011,19 @@ insert_breakpoint_locations (void) if (bpt->disposition == disp_del_at_next_stop) continue; @@ -503,7 +530,7 @@ index 785155c..63d736f 100644 if (some_failed) { for (loc = bpt->loc; loc; loc = loc->next) -@@ -2525,8 +2559,7 @@ remove_breakpoint_1 (struct bp_location *bl, insertion_state_t is) +@@ -2539,8 +2573,7 @@ remove_breakpoint_1 (struct bp_location *bl, insertion_state_t is) { bl->inserted = (is == mark_inserted); val = target_remove_watchpoint (bl->address, bl->length, @@ -513,7 +540,7 @@ index 785155c..63d736f 100644 /* Failure to remove any of the hardware watchpoints comes here. */ if ((is == mark_uninserted) && (bl->inserted)) -@@ -3419,6 +3452,8 @@ print_it_typical (bpstat bs) +@@ -3436,6 +3469,8 @@ print_it_typical (bpstat bs) case bp_tracepoint: case bp_fast_tracepoint: case bp_jit_event: @@ -522,7 +549,7 @@ index 785155c..63d736f 100644 default: result = PRINT_UNKNOWN; break; -@@ -3640,6 +3675,8 @@ watchpoint_check (void *p) +@@ -3657,6 +3692,8 @@ watchpoint_check (void *p) gdb_assert (bs->breakpoint_at != NULL); b = bs->breakpoint_at; @@ -531,8 +558,8 @@ index 785155c..63d736f 100644 /* If this is a local watchpoint, we only want to check if the watchpoint frame is in scope if the current thread is the thread that was used to create the watchpoint. */ -@@ -3748,13 +3785,7 @@ watchpoint_check (void *p) - ui_out_text (uiout, " deleted because the program has left the block in\n\ +@@ -3766,13 +3803,7 @@ watchpoint_check (void *p) + " deleted because the program has left the block in\n\ which its expression is valid.\n"); - if (b->related_breakpoint) @@ -546,7 +573,7 @@ index 785155c..63d736f 100644 return WP_DELETED; } -@@ -3958,9 +3989,7 @@ bpstat_check_watchpoint (bpstat bs) +@@ -3977,9 +4008,7 @@ bpstat_check_watchpoint (bpstat bs) case 0: /* Error from catch_errors. */ printf_filtered (_("Watchpoint %d deleted.\n"), b->number); @@ -557,7 +584,7 @@ index 785155c..63d736f 100644 /* We've already printed what needs to be printed. */ bs->print_it = print_it_done; break; -@@ -4166,7 +4195,7 @@ bpstat_stop_status (struct address_space *aspace, +@@ -4185,7 +4214,7 @@ bpstat_stop_status (struct address_space *aspace, watchpoint as triggered so that we will handle the out-of-scope event. We'll get to the watchpoint next iteration. */ @@ -566,7 +593,7 @@ index 785155c..63d736f 100644 b->related_breakpoint->watchpoint_triggered = watch_triggered_yes; } } -@@ -4288,7 +4317,7 @@ handle_jit_event (void) +@@ -4307,7 +4336,7 @@ handle_jit_event (void) /* Decide what infrun needs to do with this bpstat. */ struct bpstat_what @@ -575,7 +602,7 @@ index 785155c..63d736f 100644 { struct bpstat_what retval; /* We need to defer calling `solib_add', as adding new symbols -@@ -4296,12 +4325,13 @@ bpstat_what (bpstat bs) +@@ -4315,12 +4344,13 @@ bpstat_what (bpstat bs) and hence may clear unprocessed entries in the BS chain. */ int shlib_event = 0; int jit_event = 0; @@ -590,7 +617,7 @@ index 785155c..63d736f 100644 { /* Extract this BS's action. After processing each BS, we check if its action overrides all we've seem so far. */ -@@ -4431,6 +4461,20 @@ bpstat_what (bpstat bs) +@@ -4450,6 +4480,20 @@ bpstat_what (bpstat bs) out already. */ internal_error (__FILE__, __LINE__, _("bpstat_what: tracepoint encountered")); @@ -611,7 +638,7 @@ index 785155c..63d736f 100644 default: internal_error (__FILE__, __LINE__, _("bpstat_what: unhandled bptype %d"), (int) bptype); -@@ -4468,6 +4512,21 @@ bpstat_what (bpstat bs) +@@ -4487,6 +4531,21 @@ bpstat_what (bpstat bs) handle_jit_event (); } @@ -633,7 +660,7 @@ index 785155c..63d736f 100644 return retval; } -@@ -4589,6 +4648,8 @@ bptype_string (enum bptype type) +@@ -4608,6 +4667,8 @@ bptype_string (enum bptype type) {bp_fast_tracepoint, "fast tracepoint"}, {bp_static_tracepoint, "static tracepoint"}, {bp_jit_event, "jit events"}, @@ -642,7 +669,7 @@ index 785155c..63d736f 100644 }; if (((int) type >= (sizeof (bptypes) / sizeof (bptypes[0]))) -@@ -4736,6 +4797,8 @@ print_one_breakpoint_location (struct breakpoint *b, +@@ -4755,6 +4816,8 @@ print_one_breakpoint_location (struct breakpoint *b, case bp_fast_tracepoint: case bp_static_tracepoint: case bp_jit_event: @@ -651,7 +678,7 @@ index 785155c..63d736f 100644 if (opts.addressprint) { annotate_field (4); -@@ -5017,7 +5080,8 @@ user_settable_breakpoint (const struct breakpoint *b) +@@ -5036,7 +5099,8 @@ user_settable_breakpoint (const struct breakpoint *b) || b->type == bp_catchpoint || b->type == bp_hardware_breakpoint || is_tracepoint (b) @@ -661,7 +688,7 @@ index 785155c..63d736f 100644 } /* Print information on user settable breakpoint (watchpoint, etc) -@@ -5497,6 +5561,8 @@ allocate_bp_location (struct breakpoint *bpt) +@@ -5518,6 +5582,8 @@ allocate_bp_location (struct breakpoint *bpt) case bp_longjmp_master: case bp_std_terminate_master: case bp_exception_master: @@ -670,7 +697,7 @@ index 785155c..63d736f 100644 loc->loc_type = bp_loc_software_breakpoint; break; case bp_hardware_breakpoint: -@@ -5586,6 +5652,7 @@ set_raw_breakpoint_without_location (struct gdbarch *gdbarch, +@@ -5607,6 +5673,7 @@ set_raw_breakpoint_without_location (struct gdbarch *gdbarch, b->ops = NULL; b->condition_not_parsed = 0; b->py_bp_object = NULL; @@ -678,7 +705,7 @@ index 785155c..63d736f 100644 /* Add this breakpoint to the end of the chain so that a list of breakpoints will come out in order of increasing numbers. */ -@@ -5604,7 +5671,7 @@ set_raw_breakpoint_without_location (struct gdbarch *gdbarch, +@@ -5625,7 +5692,7 @@ set_raw_breakpoint_without_location (struct gdbarch *gdbarch, /* Initialize loc->function_name. */ static void @@ -687,7 +714,7 @@ index 785155c..63d736f 100644 { gdb_assert (loc->owner != NULL); -@@ -5612,8 +5679,29 @@ set_breakpoint_location_function (struct bp_location *loc) +@@ -5633,8 +5700,29 @@ set_breakpoint_location_function (struct bp_location *loc) || loc->owner->type == bp_hardware_breakpoint || is_tracepoint (loc->owner)) { @@ -719,7 +746,7 @@ index 785155c..63d736f 100644 if (loc->function_name) loc->function_name = xstrdup (loc->function_name); } -@@ -5688,7 +5776,8 @@ set_raw_breakpoint (struct gdbarch *gdbarch, +@@ -5709,7 +5797,8 @@ set_raw_breakpoint (struct gdbarch *gdbarch, b->loc->section = sal.section; b->line_number = sal.line; @@ -729,7 +756,7 @@ index 785155c..63d736f 100644 breakpoints_changed (); -@@ -6775,7 +6864,7 @@ clone_momentary_breakpoint (struct breakpoint *orig) +@@ -6799,7 +6888,7 @@ clone_momentary_breakpoint (struct breakpoint *orig) copy = set_raw_breakpoint_without_location (orig->gdbarch, orig->type); copy->loc = allocate_bp_location (copy); @@ -738,7 +765,7 @@ index 785155c..63d736f 100644 copy->loc->gdbarch = orig->loc->gdbarch; copy->loc->requested_address = orig->loc->requested_address; -@@ -6874,6 +6963,7 @@ mention (struct breakpoint *b) +@@ -6899,6 +6988,7 @@ mention (struct breakpoint *b) do_cleanups (ui_out_chain); break; case bp_breakpoint: @@ -746,7 +773,7 @@ index 785155c..63d736f 100644 if (ui_out_is_mi_like_p (uiout)) { say_where = 0; -@@ -6884,6 +6974,8 @@ mention (struct breakpoint *b) +@@ -6909,6 +6999,8 @@ mention (struct breakpoint *b) else printf_filtered (_("Breakpoint")); printf_filtered (_(" %d"), b->number); @@ -755,7 +782,7 @@ index 785155c..63d736f 100644 say_where = 1; break; case bp_hardware_breakpoint: -@@ -6943,6 +7035,7 @@ mention (struct breakpoint *b) +@@ -6968,6 +7060,7 @@ mention (struct breakpoint *b) case bp_longjmp_master: case bp_std_terminate_master: case bp_exception_master: @@ -763,7 +790,7 @@ index 785155c..63d736f 100644 break; } -@@ -7003,7 +7096,8 @@ add_location_to_breakpoint (struct breakpoint *b, +@@ -7028,7 +7121,8 @@ add_location_to_breakpoint (struct breakpoint *b, gdb_assert (loc->pspace != NULL); loc->section = sal->section; @@ -773,7 +800,7 @@ index 785155c..63d736f 100644 return loc; } -@@ -8397,6 +8491,7 @@ watch_command_1 (char *arg, int accessflag, int from_tty, +@@ -8427,6 +8521,7 @@ watch_command_1 (char *arg, int accessflag, int from_tty, b = set_raw_breakpoint_without_location (NULL, bp_type); set_breakpoint_number (internal, b); b->thread = thread; @@ -781,7 +808,7 @@ index 785155c..63d736f 100644 b->disposition = disp_donttouch; b->exp = exp; b->exp_valid_block = exp_valid_block; -@@ -9550,6 +9645,9 @@ update_global_location_list (int should_insert) +@@ -9582,6 +9677,9 @@ update_global_location_list (int should_insert) int keep_in_target = 0; int removed = 0; @@ -791,7 +818,7 @@ index 785155c..63d736f 100644 /* Skip LOCP entries which will definitely never be needed. Stop either at or being the one matching OLD_LOC. */ while (locp < bp_location + bp_location_count -@@ -9865,12 +9963,22 @@ delete_breakpoint (struct breakpoint *bpt) +@@ -9898,12 +9996,22 @@ delete_breakpoint (struct breakpoint *bpt) /* At least avoid this stale reference until the reference counting of breakpoints gets resolved. */ @@ -819,7 +846,7 @@ index 785155c..63d736f 100644 } observer_notify_breakpoint_deleted (bpt->number); -@@ -10201,6 +10309,9 @@ update_breakpoint_locations (struct breakpoint *b, +@@ -10234,6 +10342,9 @@ update_breakpoint_locations (struct breakpoint *b, return; b->loc = NULL; @@ -829,7 +856,7 @@ index 785155c..63d736f 100644 for (i = 0; i < sals.nelts; ++i) { -@@ -10227,11 +10338,7 @@ update_breakpoint_locations (struct breakpoint *b, +@@ -10261,11 +10372,7 @@ update_breakpoint_locations (struct breakpoint *b, } } @@ -842,7 +869,7 @@ index 785155c..63d736f 100644 b->source_file = xstrdup (sals.sals[i].symtab->filename); if (b->line_number == 0) -@@ -10314,6 +10421,7 @@ breakpoint_re_set_one (void *bint) +@@ -10348,6 +10455,7 @@ breakpoint_re_set_one (void *bint) case bp_tracepoint: case bp_fast_tracepoint: case bp_static_tracepoint: @@ -850,7 +877,7 @@ index 785155c..63d736f 100644 /* Do not attempt to re-set breakpoints disabled during startup. */ if (b->enable_state == bp_startup_disabled) return 0; -@@ -10484,6 +10592,7 @@ breakpoint_re_set_one (void *bint) +@@ -10518,6 +10626,7 @@ breakpoint_re_set_one (void *bint) case bp_exception: case bp_exception_resume: case bp_jit_event: @@ -858,7 +885,7 @@ index 785155c..63d736f 100644 break; } -@@ -10656,11 +10765,25 @@ map_breakpoint_numbers (char *args, void (*function) (struct breakpoint *, +@@ -10692,11 +10801,25 @@ map_breakpoint_numbers (char *args, void (*function) (struct breakpoint *, ALL_BREAKPOINTS_SAFE (b, tmp) if (b->number == num) { @@ -888,7 +915,7 @@ index 785155c..63d736f 100644 break; } if (match == 0) -@@ -11769,6 +11892,22 @@ all_tracepoints () +@@ -11811,6 +11934,22 @@ all_tracepoints () return tp_vec; } @@ -911,7 +938,7 @@ index 785155c..63d736f 100644 /* This help string is used for the break, hbreak, tbreak and thbreak commands. It is defined as a macro to prevent duplication. -@@ -11854,6 +11993,107 @@ iterate_over_breakpoints (int (*callback) (struct breakpoint *, void *), +@@ -11896,6 +12035,107 @@ iterate_over_breakpoints (int (*callback) (struct breakpoint *, void *), return NULL; } @@ -1019,7 +1046,7 @@ index 785155c..63d736f 100644 void _initialize_breakpoint (void) { -@@ -12388,4 +12628,5 @@ inferior in all-stop mode, gdb behaves as if always-inserted mode is off."), +@@ -12430,4 +12670,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); @@ -1040,7 +1067,7 @@ index 2d815c2..66b3ece 100644 /* States of enablement of breakpoint. */ diff --git a/gdb/c-typeprint.c b/gdb/c-typeprint.c -index feee86d..363c62b 100644 +index c889264..3155af7 100644 --- a/gdb/c-typeprint.c +++ b/gdb/c-typeprint.c @@ -609,9 +609,14 @@ c_type_print_varspec_suffix (struct type *type, @@ -1061,8 +1088,39 @@ index feee86d..363c62b 100644 fprintf_filtered (stream, "]"); c_type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream, +diff --git a/gdb/data-directory/Makefile.in b/gdb/data-directory/Makefile.in +index 565a837..c9ff0de 100644 +--- a/gdb/data-directory/Makefile.in ++++ b/gdb/data-directory/Makefile.in +@@ -51,11 +51,23 @@ SYSCALLS_FILES = \ + PYTHON_DIR = python + PYTHON_INSTALL_DIR = $(DESTDIR)$(GDB_DATADIR)/$(PYTHON_DIR) + PYTHON_FILES = \ ++ gdb/FrameIterator.py \ ++ gdb/FrameWrapper.py \ + gdb/__init__.py \ +- gdb/types.py \ +- gdb/printing.py \ ++ gdb/backtrace.py \ + gdb/command/__init__.py \ +- gdb/command/pretty_printers.py ++ gdb/command/alias.py \ ++ gdb/command/backtrace.py \ ++ gdb/command/ignore_errors.py \ ++ gdb/command/pahole.py \ ++ gdb/command/pretty_printers.py \ ++ gdb/command/require.py \ ++ gdb/command/upto.py \ ++ gdb/function/__init__.py \ ++ gdb/function/caller_is.py \ ++ gdb/function/in_scope.py \ ++ gdb/printing.py \ ++ gdb/types.py + + FLAGS_TO_PASS = \ + "prefix=$(prefix)" \ diff --git a/gdb/defs.h b/gdb/defs.h -index 9d8f6fc..229378a 100644 +index 6a90b08..31d55de 100644 --- a/gdb/defs.h +++ b/gdb/defs.h @@ -398,6 +398,8 @@ extern struct cleanup *make_cleanup_restore_page_info (void); @@ -1074,8 +1132,98 @@ index 9d8f6fc..229378a 100644 extern char *gdb_realpath (const char *); extern char *xfullpath (const char *); +diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo +index d47a484..c860c87 100644 +--- a/gdb/doc/gdb.texinfo ++++ b/gdb/doc/gdb.texinfo +@@ -1177,6 +1177,16 @@ for remote debugging. + Run using @var{device} for your program's standard input and output. + @c FIXME: kingdon thinks there is more to -tty. Investigate. + ++@item -P ++@cindex @code{-P} ++@itemx --python ++@cindex @code{--python} ++Change interpretation of command line so that the argument immediately ++following this switch is taken to be the name of a Python script file. ++This option stops option processing; subsequent options are passed to ++Python as @code{sys.argv}. This option is only available if Python ++scripting support was enabled when @value{GDBN} was configured. ++ + @c resolve the situation of these eventually + @item -tui + @cindex @code{--tui} +@@ -20665,8 +20675,6 @@ containing @code{end}. For example: + + @smallexample + (@value{GDBP}) python +-Type python script +-End with a line saying just "end". + >print 23 + >end + 23 +@@ -20679,6 +20687,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. ++ ++@kindex maint set python auto-load ++@item maint set python auto-load ++By default, @value{GDBN} will attempt to automatically load Python ++code when an object file is opened. This can be controlled using ++@code{maint set python auto-load}: if @code{on}, the default, then ++Python auto-loading is enabled; if @code{off}, then Python ++auto-loading is disabled. + @end table + + It is also possible to execute a Python script from the @value{GDBN} +@@ -20700,6 +20716,14 @@ and thus is always available. + @cindex python api + @cindex programming in python + ++You can get quick online help for @value{GDBN}'s Python API by issuing ++the command @w{@kbd{python help (gdb)}}. ++ ++Functions and methods which have two or more optional arguments allow ++them to be specified using keyword syntax. This allows passing some ++optional arguments while skipping others. Example: ++@w{@code{gdb.some_function ('foo', bar = 1, baz = 2)}}. ++ + @cindex python stdout + @cindex python pagination + At startup, @value{GDBN} overrides Python's @code{sys.stdout} and +@@ -20711,7 +20735,7 @@ situation, a Python @code{KeyboardInterrupt} exception is thrown. + @menu + * Basic Python:: Basic Python Functions. + * Exception Handling:: +-* Values From Inferior:: ++* Values From Inferior:: Python representation of values. + * Types In Python:: Python representation of types. + * Pretty Printing API:: Pretty-printing values. + * Selecting Pretty-Printers:: How GDB chooses a pretty-printer. +@@ -20772,6 +20796,12 @@ Return a sequence holding all of @value{GDBN}'s breakpoints. + @xref{Breakpoints In Python}, for more information. + @end defun + ++@findex gdb.breakpoints ++@defun breakpoints ++Return a sequence holding all of @value{GDBN}'s breakpoints. ++@xref{Breakpoints In Python}, for more information. ++@end defun ++ + @findex gdb.parameter + @defun parameter parameter + Return the value of a @value{GDBN} parameter. @var{parameter} is a +@@ -20789,6 +20819,7 @@ 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. ++ + 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 diff --git a/gdb/doc/gdbint.texinfo b/gdb/doc/gdbint.texinfo -index 4a112aa..7b6bed4 100644 +index 8149cb9..4812558 100644 --- a/gdb/doc/gdbint.texinfo +++ b/gdb/doc/gdbint.texinfo @@ -2104,6 +2104,18 @@ time, and so we attempt to handle symbols incrementally. For instance, @@ -1204,7 +1352,7 @@ index 4a112aa..7b6bed4 100644 @node Language Support diff --git a/gdb/doc/observer.texi b/gdb/doc/observer.texi -index e19b8ed..343e160 100644 +index d16c865..d8d24d9 100644 --- a/gdb/doc/observer.texi +++ b/gdb/doc/observer.texi @@ -223,6 +223,11 @@ Bytes from @var{data} to @var{data} + @var{len} have been written @@ -1220,10 +1368,10 @@ index e19b8ed..343e160 100644 This observer is used for internal testing. Do not use. See testsuite/gdb.gdb/observer.exp. diff --git a/gdb/dwarf2expr.c b/gdb/dwarf2expr.c -index 4ef6d55..1a3580a 100644 +index aa8c8cf..537b69b 100644 --- a/gdb/dwarf2expr.c +++ b/gdb/dwarf2expr.c -@@ -900,6 +900,13 @@ execute_stack_op (struct dwarf_expr_context *ctx, +@@ -904,6 +904,13 @@ execute_stack_op (struct dwarf_expr_context *ctx, ctx->dwarf_call (ctx, result); goto no_push; @@ -1259,10 +1407,10 @@ index 3858dc8..a172585 100644 /* The current depth of dwarf expression recursion, via DW_OP_call*, DW_OP_fbreg, DW_OP_push_object_address, etc., and the maximum diff --git a/gdb/dwarf2loc.c b/gdb/dwarf2loc.c -index 12e4dac..943b37d 100644 +index 4ec2549..60c38e9 100644 --- a/gdb/dwarf2loc.c +++ b/gdb/dwarf2loc.c -@@ -133,6 +133,9 @@ struct dwarf_expr_baton +@@ -134,6 +134,9 @@ struct dwarf_expr_baton { struct frame_info *frame; struct dwarf2_per_cu_data *per_cu; @@ -1272,7 +1420,7 @@ index 12e4dac..943b37d 100644 }; /* Helper functions for dwarf2_evaluate_loc_desc. */ -@@ -201,23 +204,33 @@ dwarf_expr_frame_base_1 (struct symbol *framefunc, CORE_ADDR pc, +@@ -202,23 +205,33 @@ dwarf_expr_frame_base_1 (struct symbol *framefunc, CORE_ADDR pc, symbaton = SYMBOL_LOCATION_BATON (framefunc); *start = dwarf2_find_location_expression (symbaton, length, pc); } @@ -1315,7 +1463,7 @@ index 12e4dac..943b37d 100644 } /* Helper function for dwarf2_evaluate_loc_desc. Computes the CFA for -@@ -284,6 +297,159 @@ dwarf_expr_dwarf_call (struct dwarf_expr_context *ctx, size_t die_offset) +@@ -286,6 +299,159 @@ dwarf_expr_dwarf_call (struct dwarf_expr_context *ctx, size_t die_offset) ctx->get_frame_pc, ctx->baton); } @@ -1475,7 +1623,7 @@ index 12e4dac..943b37d 100644 struct piece_closure { /* Reference count. */ -@@ -1038,10 +1204,8 @@ dwarf2_evaluate_loc_desc_full (struct type *type, struct frame_info *frame, +@@ -1045,10 +1211,8 @@ dwarf2_evaluate_loc_desc_full (struct type *type, struct frame_info *frame, LONGEST byte_offset) { struct value *retval; @@ -1486,7 +1634,7 @@ index 12e4dac..943b37d 100644 if (byte_offset < 0) invalid_synthetic_pointer (); -@@ -1054,25 +1218,10 @@ dwarf2_evaluate_loc_desc_full (struct type *type, struct frame_info *frame, +@@ -1061,25 +1225,10 @@ dwarf2_evaluate_loc_desc_full (struct type *type, struct frame_info *frame, return retval; } @@ -1514,7 +1662,7 @@ index 12e4dac..943b37d 100644 if (ctx->num_pieces > 0) { struct piece_closure *c; -@@ -1116,6 +1265,15 @@ dwarf2_evaluate_loc_desc_full (struct type *type, struct frame_info *frame, +@@ -1123,6 +1272,15 @@ dwarf2_evaluate_loc_desc_full (struct type *type, struct frame_info *frame, CORE_ADDR address = dwarf_expr_fetch_address (ctx, 0); int in_stack_memory = dwarf_expr_fetch_in_stack_memory (ctx, 0); @@ -1530,7 +1678,7 @@ index 12e4dac..943b37d 100644 retval = allocate_value (type); VALUE_LVAL (retval) = lval_memory; set_value_lazy (retval, 1); -@@ -2810,11 +2968,51 @@ loclist_tracepoint_var_ref (struct symbol *symbol, struct gdbarch *gdbarch, +@@ -2822,11 +2980,51 @@ loclist_tracepoint_var_ref (struct symbol *symbol, struct gdbarch *gdbarch, dlbaton->per_cu); } @@ -1604,10 +1752,10 @@ index ee52506..6a77c3f 100644 #endif /* dwarf2loc.h */ diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c -index 82a2f0b..327164c 100644 +index 201513d..f49a149 100644 --- a/gdb/dwarf2read.c +++ b/gdb/dwarf2read.c -@@ -1206,6 +1206,9 @@ static void fill_in_loclist_baton (struct dwarf2_cu *cu, +@@ -1211,6 +1211,9 @@ static void fill_in_loclist_baton (struct dwarf2_cu *cu, struct dwarf2_loclist_baton *baton, struct attribute *attr); @@ -1617,7 +1765,7 @@ index 82a2f0b..327164c 100644 static void dwarf2_symbol_mark_computed (struct attribute *attr, struct symbol *sym, struct dwarf2_cu *cu); -@@ -1240,6 +1243,9 @@ static void age_cached_comp_units (void); +@@ -1245,6 +1248,9 @@ static void age_cached_comp_units (void); static void free_one_cached_comp_unit (void *); @@ -1627,7 +1775,7 @@ index 82a2f0b..327164c 100644 static struct type *set_die_type (struct die_info *, struct type *, struct dwarf2_cu *); -@@ -1264,6 +1270,9 @@ static struct type *get_die_type_at_offset (unsigned int, +@@ -1269,6 +1275,9 @@ static struct type *get_die_type_at_offset (unsigned int, static struct type *get_die_type (struct die_info *die, struct dwarf2_cu *cu); @@ -1637,7 +1785,7 @@ index 82a2f0b..327164c 100644 static void dwarf2_release_queue (void *dummy); static void queue_comp_unit (struct dwarf2_per_cu_data *per_cu, -@@ -7237,6 +7246,29 @@ process_enumeration_scope (struct die_info *die, struct dwarf2_cu *cu) +@@ -7263,6 +7272,29 @@ process_enumeration_scope (struct die_info *die, struct dwarf2_cu *cu) new_symbol (die, this_type, cu); } @@ -1667,7 +1815,7 @@ index 82a2f0b..327164c 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. */ -@@ -7250,7 +7282,7 @@ read_array_type (struct die_info *die, struct dwarf2_cu *cu) +@@ -7276,7 +7308,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; @@ -1676,7 +1824,7 @@ index 82a2f0b..327164c 100644 struct cleanup *back_to; char *name; -@@ -7303,17 +7335,11 @@ read_array_type (struct die_info *die, struct dwarf2_cu *cu) +@@ -7329,17 +7361,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) @@ -1699,7 +1847,7 @@ index 82a2f0b..327164c 100644 /* Understand Dwarf2 support for vector types (like they occur on the PowerPC w/ AltiVec). Gcc just adds another attribute to the -@@ -7806,29 +7832,114 @@ read_tag_string_type (struct die_info *die, struct dwarf2_cu *cu) +@@ -7835,29 +7861,114 @@ read_tag_string_type (struct die_info *die, struct dwarf2_cu *cu) struct gdbarch *gdbarch = get_objfile_arch (objfile); struct type *type, *range_type, *index_type, *char_type; struct attribute *attr; @@ -1828,7 +1976,7 @@ index 82a2f0b..327164c 100644 char_type = language_string_char_type (cu->language_defn, gdbarch); type = create_string_type (NULL, char_type, range_type); -@@ -8110,8 +8221,7 @@ read_subrange_type (struct die_info *die, struct dwarf2_cu *cu) +@@ -8139,8 +8250,7 @@ read_subrange_type (struct die_info *die, struct dwarf2_cu *cu) struct type *base_type; struct type *range_type; struct attribute *attr; @@ -1838,7 +1986,7 @@ index 82a2f0b..327164c 100644 char *name; LONGEST negative_mask; -@@ -8124,48 +8234,125 @@ read_subrange_type (struct die_info *die, struct dwarf2_cu *cu) +@@ -8153,48 +8263,125 @@ read_subrange_type (struct die_info *die, struct dwarf2_cu *cu) if (range_type) return range_type; @@ -1996,7 +2144,7 @@ index 82a2f0b..327164c 100644 } /* Dwarf-2 specifications explicitly allows to create subrange types -@@ -8207,20 +8394,41 @@ read_subrange_type (struct die_info *die, struct dwarf2_cu *cu) +@@ -8236,20 +8423,41 @@ read_subrange_type (struct die_info *die, struct dwarf2_cu *cu) } } @@ -2050,7 +2198,7 @@ index 82a2f0b..327164c 100644 name = dwarf2_name (die, cu); if (name) -@@ -10686,10 +10894,12 @@ var_decode_location (struct attribute *attr, struct symbol *sym, +@@ -10725,10 +10933,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 @@ -2065,7 +2213,7 @@ index 82a2f0b..327164c 100644 } /* Given a pointer to a DWARF information entry, figure out if we need -@@ -10727,6 +10937,8 @@ new_symbol_full (struct die_info *die, struct type *type, struct dwarf2_cu *cu, +@@ -10766,6 +10976,8 @@ new_symbol_full (struct die_info *die, struct type *type, struct dwarf2_cu *cu, else sym = OBSTACK_ZALLOC (&objfile->objfile_obstack, struct symbol); OBJSTAT (objfile, n_syms++); @@ -2074,7 +2222,7 @@ index 82a2f0b..327164c 100644 /* Cache this symbol's name and the name's demangled form (if any). */ SYMBOL_SET_LANGUAGE (sym, cu->language); -@@ -11494,6 +11706,9 @@ read_type_die_1 (struct die_info *die, struct dwarf2_cu *cu) +@@ -11538,6 +11750,9 @@ read_type_die_1 (struct die_info *die, struct dwarf2_cu *cu) break; } @@ -2084,7 +2232,7 @@ index 82a2f0b..327164c 100644 return this_type; } -@@ -14292,59 +14507,97 @@ fill_in_loclist_baton (struct dwarf2_cu *cu, +@@ -14350,60 +14565,98 @@ fill_in_loclist_baton (struct dwarf2_cu *cu, baton->base_address = cu->base_address; } @@ -2129,7 +2277,8 @@ index 82a2f0b..327164c 100644 - if (cu->base_known == 0) - complaint (&symfile_complaints, -- _("Location list used without specifying the CU base address.")); +- _("Location list used without " +- "specifying the CU base address.")); +static struct dwarf2_loclist_baton * +dwarf2_attr_to_loclist_baton (struct attribute *attr, struct dwarf2_cu *cu) +{ @@ -2157,7 +2306,8 @@ index 82a2f0b..327164c 100644 + + if (cu->base_known == 0) + complaint (&symfile_complaints, -+ _("Location list used without specifying the CU base address.")); ++ _("Location list used without " ++ "specifying the CU base address.")); + + return baton; +} @@ -2223,7 +2373,7 @@ index 82a2f0b..327164c 100644 } } -@@ -14690,6 +14943,31 @@ offset_and_type_eq (const void *item_lhs, const void *item_rhs) +@@ -14749,6 +15002,31 @@ offset_and_type_eq (const void *item_lhs, const void *item_rhs) return ofs_lhs->offset == ofs_rhs->offset; } @@ -2255,7 +2405,7 @@ index 82a2f0b..327164c 100644 /* Set the type associated with DIE to TYPE. Save it in CU's hash table if necessary. For convenience, return TYPE. -@@ -14715,6 +14993,8 @@ set_die_type (struct die_info *die, struct type *type, struct dwarf2_cu *cu) +@@ -14774,6 +15052,8 @@ set_die_type (struct die_info *die, struct type *type, struct dwarf2_cu *cu) struct objfile *objfile = cu->objfile; htab_t *type_hash_ptr; @@ -2265,7 +2415,7 @@ index 82a2f0b..327164c 100644 initialized (if not already set). There are a few types where we should not be doing so, because the type-specific area is diff --git a/gdb/elfread.c b/gdb/elfread.c -index 5944eb0..9b283e1 100644 +index 8d9b0f7..cdb3290 100644 --- a/gdb/elfread.c +++ b/gdb/elfread.c @@ -37,6 +37,7 @@ @@ -2298,7 +2448,7 @@ index 5944eb0..9b283e1 100644 } else if ((sym->name[0] == '.' && sym->name[1] == 'L') || ((sym->flags & BSF_LOCAL) -@@ -572,6 +577,250 @@ elf_symtab_read (struct objfile *objfile, int type, +@@ -574,6 +579,250 @@ elf_symtab_read (struct objfile *objfile, int type, } } @@ -2549,7 +2699,7 @@ index 5944eb0..9b283e1 100644 struct build_id { size_t size; -@@ -806,6 +1055,8 @@ elf_symfile_read (struct objfile *objfile, int symfile_flags) +@@ -814,6 +1063,8 @@ elf_symfile_read (struct objfile *objfile, int symfile_flags) bfd_errmsg (bfd_get_error ())); elf_symtab_read (objfile, ST_DYNAMIC, dynsymcount, dyn_symbol_table, 0); @@ -2559,7 +2709,7 @@ index 5944eb0..9b283e1 100644 /* Add synthetic symbols - for instance, names for any PLT entries. */ diff --git a/gdb/eval.c b/gdb/eval.c -index fbd3698..56d51c8 100644 +index 8394623..3d3a31e 100644 --- a/gdb/eval.c +++ b/gdb/eval.c @@ -44,6 +44,7 @@ @@ -2578,7 +2728,7 @@ index fbd3698..56d51c8 100644 pc = (*pos)++; op = exp->elts[pc].opcode; -@@ -1822,6 +1824,8 @@ evaluate_subexp_standard (struct type *expect_type, +@@ -1847,6 +1849,8 @@ evaluate_subexp_standard (struct type *expect_type, return value_zero (builtin_type (exp->gdbarch)->builtin_int, not_lval); } @@ -2587,7 +2737,7 @@ index fbd3698..56d51c8 100644 else if (TYPE_TARGET_TYPE (ftype)) return allocate_value (TYPE_TARGET_TYPE (ftype)); else -@@ -1848,6 +1852,8 @@ evaluate_subexp_standard (struct type *expect_type, +@@ -1875,6 +1879,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); @@ -2596,7 +2746,7 @@ index fbd3698..56d51c8 100644 type = check_typedef (value_type (arg1)); code = TYPE_CODE (type); -@@ -1868,6 +1874,7 @@ evaluate_subexp_standard (struct type *expect_type, +@@ -1895,6 +1901,7 @@ evaluate_subexp_standard (struct type *expect_type, code = TYPE_CODE (type); } } @@ -2604,7 +2754,7 @@ index fbd3698..56d51c8 100644 switch (code) { -@@ -2325,13 +2332,19 @@ evaluate_subexp_standard (struct type *expect_type, +@@ -2354,13 +2361,19 @@ evaluate_subexp_standard (struct type *expect_type, { int subscript_array[MAX_FORTRAN_DIMS]; int array_size_array[MAX_FORTRAN_DIMS]; @@ -2624,7 +2774,7 @@ index fbd3698..56d51c8 100644 tmp_type = check_typedef (value_type (arg1)); ndimensions = calc_f77_array_dims (type); -@@ -2361,6 +2374,9 @@ evaluate_subexp_standard (struct type *expect_type, +@@ -2390,6 +2403,9 @@ evaluate_subexp_standard (struct type *expect_type, upper = f77_get_upperbound (tmp_type); lower = f77_get_lowerbound (tmp_type); @@ -2634,7 +2784,7 @@ index fbd3698..56d51c8 100644 array_size_array[nargs - i - 1] = upper - lower + 1; /* Zero-normalize subscripts so that offsetting will work. */ -@@ -2379,13 +2395,25 @@ evaluate_subexp_standard (struct type *expect_type, +@@ -2408,13 +2424,25 @@ evaluate_subexp_standard (struct type *expect_type, tmp_type = check_typedef (TYPE_TARGET_TYPE (tmp_type)); } @@ -2664,7 +2814,7 @@ index fbd3698..56d51c8 100644 /* Let us now play a dirty trick: we will take arg1 which is a value node pointing to the topmost level -@@ -2395,7 +2423,7 @@ evaluate_subexp_standard (struct type *expect_type, +@@ -2424,7 +2452,7 @@ evaluate_subexp_standard (struct type *expect_type, returns the correct type value */ deprecated_set_value_type (arg1, tmp_type); @@ -2673,7 +2823,7 @@ index fbd3698..56d51c8 100644 } case BINOP_LOGICAL_AND: -@@ -2629,14 +2657,22 @@ evaluate_subexp_standard (struct type *expect_type, +@@ -2658,15 +2686,23 @@ 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); @@ -2682,7 +2832,8 @@ index fbd3698..56d51c8 100644 type = check_typedef (value_type (arg1)); if (TYPE_CODE (type) == TYPE_CODE_METHODPTR || TYPE_CODE (type) == TYPE_CODE_MEMBERPTR) - error (_("Attempt to dereference pointer to member without an object")); + error (_("Attempt to dereference pointer " + "to member without an object")); if (noside == EVAL_SKIP) - goto nosideret; + { @@ -2698,7 +2849,7 @@ index fbd3698..56d51c8 100644 else if (noside == EVAL_AVOID_SIDE_EFFECTS) { type = check_typedef (value_type (arg1)); -@@ -2645,12 +2681,18 @@ evaluate_subexp_standard (struct type *expect_type, +@@ -2675,12 +2711,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 ) @@ -2722,7 +2873,7 @@ index fbd3698..56d51c8 100644 else error (_("Attempt to take contents of a non-pointer value.")); } -@@ -2660,9 +2702,14 @@ evaluate_subexp_standard (struct type *expect_type, +@@ -2690,9 +2732,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) @@ -2740,7 +2891,7 @@ index fbd3698..56d51c8 100644 case UNOP_ADDR: /* C++: check for and handle pointer to members. */ -@@ -3008,7 +3055,7 @@ evaluate_subexp_with_coercion (struct expression *exp, +@@ -3040,7 +3087,7 @@ evaluate_subexp_with_coercion (struct expression *exp, { enum exp_opcode op; int pc; @@ -2749,7 +2900,7 @@ index fbd3698..56d51c8 100644 struct symbol *var; struct type *type; -@@ -3019,13 +3066,18 @@ evaluate_subexp_with_coercion (struct expression *exp, +@@ -3051,13 +3098,18 @@ evaluate_subexp_with_coercion (struct expression *exp, { case OP_VAR_VALUE: var = exp->elts[pc + 2].symbol; @@ -2769,7 +2920,7 @@ index fbd3698..56d51c8 100644 return value_cast (lookup_pointer_type (TYPE_TARGET_TYPE (type)), val); } -@@ -3077,9 +3129,13 @@ evaluate_subexp_for_sizeof (struct expression *exp, int *pos) +@@ -3109,9 +3161,13 @@ evaluate_subexp_for_sizeof (struct expression *exp, int *pos) case OP_VAR_VALUE: (*pos) += 4; @@ -2870,7 +3021,7 @@ index 6618188..968de7a 100644 { case TYPE_CODE_ARRAY: diff --git a/gdb/f-valprint.c b/gdb/f-valprint.c -index 5db2ed7..e104e21 100644 +index 64c0989..787b4aa 100644 --- a/gdb/f-valprint.c +++ b/gdb/f-valprint.c @@ -54,15 +54,17 @@ int f77_array_offset_tbl[MAX_FORTRAN_DIMS + 1][2]; @@ -2917,7 +3068,7 @@ index 5db2ed7..e104e21 100644 } return TYPE_ARRAY_UPPER_BOUND_VALUE (type); -@@ -134,24 +139,29 @@ f77_create_arrayprint_offset_tbl (struct type *type, struct ui_file *stream) +@@ -135,24 +140,29 @@ f77_create_arrayprint_offset_tbl (struct type *type, struct ui_file *stream) upper = f77_get_upperbound (tmp_type); lower = f77_get_lowerbound (tmp_type); @@ -2953,11 +3104,13 @@ index 5db2ed7..e104e21 100644 } } -@@ -172,34 +182,34 @@ f77_print_array_1 (int nss, int ndimensions, struct type *type, +@@ -173,36 +183,34 @@ f77_print_array_1 (int nss, int ndimensions, struct type *type, if (nss != ndimensions) { -- for (i = 0; (i < F77_DIM_SIZE (nss) && (*elts) < options->print_max); i++) +- for (i = 0; +- (i < F77_DIM_SIZE (nss) && (*elts) < options->print_max); +- i++) + for (i = 0; (i < F77_DIM_COUNT (nss) && (*elts) < options->print_max); i++) { fprintf_filtered (stream, "( "); @@ -2997,7 +3150,7 @@ index 5db2ed7..e104e21 100644 fprintf_filtered (stream, "..."); } } -@@ -256,6 +266,9 @@ f_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset, +@@ -260,6 +268,9 @@ f_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset, CORE_ADDR addr; int index; @@ -3007,6 +3160,171 @@ index 5db2ed7..e104e21 100644 CHECK_TYPEDEF (type); switch (TYPE_CODE (type)) { +diff --git a/gdb/findcmd.c b/gdb/findcmd.c +index c21c028..4ff9177 100644 +--- a/gdb/findcmd.c ++++ b/gdb/findcmd.c +@@ -45,6 +45,41 @@ put_bits (bfd_uint64_t data, char *buf, int bits, bfd_boolean big_p) + } + } + ++/* Allocates a buffer in *PATTERN_BUF, with a hard-coded initial size which ++ will be returned in *PATTERN_BUF_SIZE. *PATTERN_BUF_END points to the same ++ place as *PATTERN_BUF, indicating that the buffer is initially empty. */ ++ ++void ++allocate_pattern_buffer (char **pattern_buf, char **pattern_buf_end, ++ ULONGEST *pattern_buf_size) ++{ ++#define INITIAL_PATTERN_BUF_SIZE 100 ++ *pattern_buf_size = INITIAL_PATTERN_BUF_SIZE; ++ *pattern_buf = xmalloc (*pattern_buf_size); ++ *pattern_buf_end = *pattern_buf; ++} ++ ++/* Grows *PATTERN_BUF by a factor of two if it's not large enough to hold ++ VAL_BYTES more bytes or a 64-bit value, whichever is larger. ++ *PATTERN_BUF_END is updated as necessary. */ ++ ++void ++increase_pattern_buffer (char **pattern_buf, char **pattern_buf_end, ++ ULONGEST *pattern_buf_size, int val_bytes) ++{ ++ /* Keep it simple and assume size == 'g' when watching for when we ++ need to grow the pattern buf. */ ++ if ((*pattern_buf_end - *pattern_buf + max (val_bytes, sizeof (int64_t))) ++ > *pattern_buf_size) ++ { ++ size_t current_offset = *pattern_buf_end - *pattern_buf; ++ ++ *pattern_buf_size *= 2; ++ *pattern_buf = xrealloc (*pattern_buf, *pattern_buf_size); ++ *pattern_buf_end = *pattern_buf + current_offset; ++ } ++} ++ + /* Subroutine of find_command to simplify it. + Parse the arguments of the "find" command. */ + +@@ -61,8 +96,7 @@ parse_find_args (char *args, ULONGEST *max_countp, + char *pattern_buf; + /* Current size of search pattern buffer. + We realloc space as needed. */ +-#define INITIAL_PATTERN_BUF_SIZE 100 +- ULONGEST pattern_buf_size = INITIAL_PATTERN_BUF_SIZE; ++ ULONGEST pattern_buf_size; + /* Pointer to one past the last in-use part of pattern_buf. */ + char *pattern_buf_end; + ULONGEST pattern_len; +@@ -75,8 +109,7 @@ parse_find_args (char *args, ULONGEST *max_countp, + if (args == NULL) + error (_("Missing search parameters.")); + +- pattern_buf = xmalloc (pattern_buf_size); +- pattern_buf_end = pattern_buf; ++ allocate_pattern_buffer (&pattern_buf, &pattern_buf_end, &pattern_buf_size); + old_cleanups = make_cleanup (free_current_contents, &pattern_buf); + + /* Get search granularity and/or max count if specified. +@@ -176,17 +209,9 @@ parse_find_args (char *args, ULONGEST *max_countp, + v = parse_to_comma_and_eval (&s); + val_bytes = TYPE_LENGTH (value_type (v)); + +- /* Keep it simple and assume size == 'g' when watching for when we +- need to grow the pattern buf. */ +- if ((pattern_buf_end - pattern_buf + max (val_bytes, sizeof (int64_t))) +- > pattern_buf_size) +- { +- size_t current_offset = pattern_buf_end - pattern_buf; ++ increase_pattern_buffer (&pattern_buf, &pattern_buf_end, ++ &pattern_buf_size, val_bytes); + +- pattern_buf_size *= 2; +- pattern_buf = xrealloc (pattern_buf, pattern_buf_size); +- pattern_buf_end = pattern_buf + current_offset; +- } + + if (size != '\0') + { +@@ -241,6 +266,45 @@ parse_find_args (char *args, ULONGEST *max_countp, + discard_cleanups (old_cleanups); + } + ++/* Drives target_search_memory to sweep through the specified search space, ++ possibly in several iterations (with one call to this function for each ++ iteration). *START_ADDR is the address where the search starts, and is ++ updated to the next starting address to continue the search. ++ *SEARCH_SPACE_LEN is the amount of bytes which will be searched, and is ++ updated for the next iteration. PATTERN_BUF holds the pattern to be searched ++ for, PATTERN_LEN is the size of the pattern in bytes. If a match is found, ++ it's address is put in *FOUND_ADDR. ++ ++ Returns 1 if found, 0 if not found, and -1 if there was an error requiring ++ halting of the search (e.g. memory read error). */ ++ ++int ++search_memory (CORE_ADDR *start_addr, ULONGEST *search_space_len, ++ const char *pattern_buf, ULONGEST pattern_len, ++ CORE_ADDR *found_addr) ++{ ++ /* Offset from start of this iteration to the next iteration. */ ++ ULONGEST next_iter_incr; ++ int found; ++ ++ found = target_search_memory (*start_addr, *search_space_len, ++ pattern_buf, pattern_len, found_addr); ++ if (found <= 0) ++ return found; ++ ++ /* Begin next iteration at one byte past this match. */ ++ next_iter_incr = (*found_addr - *start_addr) + 1; ++ ++ /* For robustness, we don't let search_space_len go -ve here. */ ++ if (*search_space_len >= next_iter_incr) ++ *search_space_len -= next_iter_incr; ++ else ++ *search_space_len = 0; ++ *start_addr += next_iter_incr; ++ ++ return found; ++} ++ + static void + find_command (char *args, int from_tty) + { +@@ -271,12 +335,11 @@ find_command (char *args, int from_tty) + while (search_space_len >= pattern_len + && found_count < max_count) + { +- /* Offset from start of this iteration to the next iteration. */ +- ULONGEST next_iter_incr; + CORE_ADDR found_addr; +- int found = target_search_memory (start_addr, search_space_len, +- pattern_buf, pattern_len, &found_addr); ++ int found; + ++ found = search_memory (&start_addr, &search_space_len, pattern_buf, ++ pattern_len, &found_addr); + if (found <= 0) + break; + +@@ -284,16 +347,6 @@ find_command (char *args, int from_tty) + printf_filtered ("\n"); + ++found_count; + last_found_addr = found_addr; +- +- /* Begin next iteration at one byte past this match. */ +- next_iter_incr = (found_addr - start_addr) + 1; +- +- /* For robustness, we don't let search_space_len go -ve here. */ +- if (search_space_len >= next_iter_incr) +- search_space_len -= next_iter_incr; +- else +- search_space_len = 0; +- start_addr += next_iter_incr; + } + + /* Record and print the results. */ diff --git a/gdb/findvar.c b/gdb/findvar.c index 5f97422..2c2670e 100644 --- a/gdb/findvar.c @@ -3218,8 +3536,28 @@ index 5f97422..2c2670e 100644 } else { +diff --git a/gdb/gdbinit.in b/gdb/gdbinit.in +index ffb7f53..a2e7e94 100644 +--- a/gdb/gdbinit.in ++++ b/gdb/gdbinit.in +@@ -1,5 +1,15 @@ + echo Setting up the environment for debugging gdb.\n + ++# Set up the Python library and "require" command. ++python ++from os.path import abspath ++gdb.datadir = abspath ('@srcdir@/python/lib') ++gdb.pythonlibdir = gdb.datadir ++gdb.__path__ = [gdb.datadir + '/gdb'] ++sys.path.insert(0, gdb.datadir) ++end ++source @srcdir@/python/lib/gdb/__init__.py ++ + set complaints 1 + + b internal_error diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c -index fac1e98..cbc3aeb 100644 +index 00a7075..eaadac0 100644 --- a/gdb/gdbtypes.c +++ b/gdb/gdbtypes.c @@ -39,6 +39,9 @@ @@ -3565,7 +3903,7 @@ index fac1e98..cbc3aeb 100644 if (name) TYPE_NAME (type) = obsavestring (name, strlen (name), -@@ -3194,33 +3341,42 @@ type_pair_eq (const void *item_lhs, const void *item_rhs) +@@ -3199,33 +3346,42 @@ type_pair_eq (const void *item_lhs, const void *item_rhs) } /* Allocate the hash table used by copy_type_recursive to walk @@ -3623,12 +3961,13 @@ index fac1e98..cbc3aeb 100644 return type; /* This type shouldn't be pointing to any types in other objfiles; -@@ -3235,8 +3391,10 @@ copy_type_recursive (struct objfile *objfile, +@@ -3240,9 +3396,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 - we encounter this type again during a recursive call below. */ -- stored = obstack_alloc (&objfile->objfile_obstack, sizeof (struct type_pair)); +- stored +- = obstack_alloc (&objfile->objfile_obstack, sizeof (struct type_pair)); + we encounter this type again during a recursive call below. Memory could + be allocated from OBJFILE in the case we will be removing OBJFILE, this + optimization is missed and xfree is called for it from COPIED_TYPES. */ @@ -3636,7 +3975,7 @@ index fac1e98..cbc3aeb 100644 stored->old = type; stored->new = new_type; *slot = stored; -@@ -3247,6 +3405,19 @@ copy_type_recursive (struct objfile *objfile, +@@ -3253,6 +3410,19 @@ copy_type_recursive (struct objfile *objfile, TYPE_OBJFILE_OWNED (new_type) = 0; TYPE_OWNER (new_type).gdbarch = get_type_arch (type); @@ -3656,7 +3995,7 @@ index fac1e98..cbc3aeb 100644 if (TYPE_NAME (type)) TYPE_NAME (new_type) = xstrdup (TYPE_NAME (type)); if (TYPE_TAG_NAME (type)) -@@ -3255,12 +3426,48 @@ copy_type_recursive (struct objfile *objfile, +@@ -3261,12 +3431,48 @@ copy_type_recursive (struct objfile *objfile, TYPE_INSTANCE_FLAGS (new_type) = TYPE_INSTANCE_FLAGS (type); TYPE_LENGTH (new_type) = TYPE_LENGTH (type); @@ -3705,7 +4044,7 @@ index fac1e98..cbc3aeb 100644 TYPE_FIELDS (new_type) = XCALLOC (nfields, struct field); for (i = 0; i < nfields; i++) { -@@ -3269,8 +3476,8 @@ copy_type_recursive (struct objfile *objfile, +@@ -3275,8 +3481,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) @@ -3716,7 +4055,7 @@ index fac1e98..cbc3aeb 100644 if (TYPE_FIELD_NAME (type, i)) TYPE_FIELD_NAME (new_type, i) = xstrdup (TYPE_FIELD_NAME (type, i)); -@@ -3297,24 +3504,166 @@ copy_type_recursive (struct objfile *objfile, +@@ -3303,24 +3509,166 @@ copy_type_recursive (struct objfile *objfile, } } @@ -3890,7 +4229,7 @@ index fac1e98..cbc3aeb 100644 /* Maybe copy the type_specific bits. NOTE drow/2005-12-09: We do not copy the C++-specific bits like -@@ -3331,6 +3680,17 @@ copy_type_recursive (struct objfile *objfile, +@@ -3337,6 +3685,17 @@ copy_type_recursive (struct objfile *objfile, return new_type; } @@ -3908,7 +4247,7 @@ index fac1e98..cbc3aeb 100644 /* Make a copy of the given TYPE, except that the pointer & reference types are not preserved. -@@ -3353,6 +3713,199 @@ copy_type (const struct type *type) +@@ -3359,6 +3718,199 @@ copy_type (const struct type *type) return new_type; } @@ -4108,7 +4447,7 @@ index fac1e98..cbc3aeb 100644 /* Helper functions to initialize architecture-specific types. */ -@@ -3701,6 +4254,8 @@ gdbtypes_post_init (struct gdbarch *gdbarch) +@@ -3707,6 +4259,8 @@ gdbtypes_post_init (struct gdbarch *gdbarch) = lookup_pointer_type (builtin_type->builtin_void); builtin_type->builtin_func_ptr = lookup_pointer_type (lookup_function_type (builtin_type->builtin_void)); @@ -4117,7 +4456,7 @@ index fac1e98..cbc3aeb 100644 /* This type represents a GDB internal function. */ builtin_type->internal_fn -@@ -3814,6 +4369,18 @@ objfile_type (struct objfile *objfile) +@@ -3820,6 +4374,18 @@ objfile_type (struct objfile *objfile) "", objfile); TYPE_TARGET_TYPE (objfile_type->nodebug_text_symbol) = objfile_type->builtin_int; @@ -4136,7 +4475,7 @@ index fac1e98..cbc3aeb 100644 objfile_type->nodebug_data_symbol = init_type (TYPE_CODE_INT, gdbarch_int_bit (gdbarch) / HOST_CHAR_BIT, 0, -@@ -3868,6 +4435,11 @@ void +@@ -3874,6 +4440,11 @@ void _initialize_gdbtypes (void) { gdbtypes_data = gdbarch_data_register_post_init (gdbtypes_post_init); @@ -4147,9 +4486,9 @@ index fac1e98..cbc3aeb 100644 + objfile_type_data = register_objfile_data (); - add_setshow_zinteger_cmd ("overload", no_class, &overload_debug, _("\ + add_setshow_zinteger_cmd ("overload", no_class, &overload_debug, diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h -index 9898991..652994c 100644 +index 0353f96..a035bad 100644 --- a/gdb/gdbtypes.h +++ b/gdb/gdbtypes.h @@ -170,6 +170,7 @@ enum type_flag_value @@ -4234,7 +4573,7 @@ index 9898991..652994c 100644 /* Constant type. If this is set, the corresponding type has a * const modifier. */ -@@ -388,11 +442,19 @@ struct main_type +@@ -389,11 +443,19 @@ struct main_type unsigned int flag_varargs : 1; unsigned int flag_vector : 1; unsigned int flag_stub_supported : 1; @@ -4254,7 +4593,7 @@ index 9898991..652994c 100644 /* A discriminant telling us which field of the type_specific union is being used for this type, if any. */ -@@ -466,6 +528,20 @@ struct main_type +@@ -467,6 +529,20 @@ struct main_type struct type *target_type; @@ -4275,7 +4614,7 @@ index 9898991..652994c 100644 /* For structure and union types, a description of each field. For set and pascal array types, there is one "field", whose type is the domain type of the set or array. -@@ -539,13 +615,34 @@ struct main_type +@@ -541,13 +617,34 @@ struct main_type struct range_bounds { @@ -4315,7 +4654,7 @@ index 9898991..652994c 100644 /* Flags indicating whether the values of low and high are valid. When true, the respective range value is -@@ -917,9 +1014,9 @@ extern void allocate_gnat_aux_type (struct type *); +@@ -921,9 +1018,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 @@ -4328,7 +4667,7 @@ index 9898991..652994c 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 -@@ -927,11 +1024,16 @@ extern void allocate_gnat_aux_type (struct type *); +@@ -931,11 +1028,16 @@ extern void allocate_gnat_aux_type (struct type *); #define TYPE_CODE(thistype) TYPE_MAIN_TYPE(thistype)->code #define TYPE_NFIELDS(thistype) TYPE_MAIN_TYPE(thistype)->nfields #define TYPE_FIELDS(thistype) TYPE_MAIN_TYPE(thistype)->flds_bnds.fields @@ -4347,7 +4686,7 @@ index 9898991..652994c 100644 #define TYPE_LOW_BOUND_UNDEFINED(range_type) \ TYPE_RANGE_DATA(range_type)->low_undefined #define TYPE_HIGH_BOUND_UNDEFINED(range_type) \ -@@ -948,7 +1050,14 @@ extern void allocate_gnat_aux_type (struct type *); +@@ -952,7 +1054,14 @@ extern void allocate_gnat_aux_type (struct type *); (TYPE_HIGH_BOUND(TYPE_INDEX_TYPE((arraytype)))) #define TYPE_ARRAY_LOWER_BOUND_VALUE(arraytype) \ @@ -4363,7 +4702,7 @@ index 9898991..652994c 100644 /* C++ */ -@@ -1177,6 +1286,10 @@ struct builtin_type +@@ -1181,6 +1290,10 @@ struct builtin_type (*) () can server as a generic function pointer. */ struct type *builtin_func_ptr; @@ -4374,7 +4713,7 @@ index 9898991..652994c 100644 /* Special-purpose types. */ -@@ -1217,6 +1330,8 @@ struct objfile_type +@@ -1221,6 +1334,8 @@ struct objfile_type /* Types used for symbols with no debug information. */ struct type *nodebug_text_symbol; @@ -4383,7 +4722,7 @@ index 9898991..652994c 100644 struct type *nodebug_data_symbol; struct type *nodebug_unknown_symbol; struct type *nodebug_tls_symbol; -@@ -1364,6 +1479,18 @@ extern struct type *create_array_type (struct type *, struct type *, +@@ -1368,6 +1483,18 @@ extern struct type *create_array_type (struct type *, struct type *, struct type *); extern struct type *lookup_array_range_type (struct type *, int, int); @@ -4402,7 +4741,7 @@ index 9898991..652994c 100644 extern struct type *create_string_type (struct type *, struct type *, struct type *); extern struct type *lookup_string_range_type (struct type *, int, int); -@@ -1409,6 +1536,8 @@ extern int is_public_ancestor (struct type *, struct type *); +@@ -1413,6 +1540,8 @@ extern int is_public_ancestor (struct type *, struct type *); extern int is_unique_ancestor (struct type *, struct value *); @@ -4411,7 +4750,7 @@ index 9898991..652994c 100644 /* Overload resolution */ #define LENGTH_MATCH(bv) ((bv)->rank[0]) -@@ -1479,10 +1608,11 @@ extern void maintenance_print_type (char *, int); +@@ -1483,10 +1612,11 @@ extern void maintenance_print_type (char *, int); extern htab_t create_copied_types_hash (struct objfile *objfile); @@ -5022,10 +5361,10 @@ index 10fdc3b..ed6de56 100644 rather than setting it directly to check that the length is only set once. It also enables the 'maint set/show show-debug-regs' diff --git a/gdb/infcall.c b/gdb/infcall.c -index 85b814a..f0cb929 100644 +index 48c183e..716fb68 100644 --- a/gdb/infcall.c +++ b/gdb/infcall.c -@@ -225,6 +225,56 @@ value_arg_coerce (struct gdbarch *gdbarch, struct value *arg, +@@ -228,6 +228,56 @@ value_arg_coerce (struct gdbarch *gdbarch, struct value *arg, return value_cast (type, arg); } @@ -5082,7 +5421,7 @@ index 85b814a..f0cb929 100644 /* Determine a function's address and its return type from its value. Calls error() if the function is not valid for calling. */ -@@ -233,7 +283,6 @@ find_function_addr (struct value *function, struct type **retval_type) +@@ -236,7 +286,6 @@ find_function_addr (struct value *function, struct type **retval_type) { struct type *ftype = check_typedef (value_type (function)); struct gdbarch *gdbarch = get_type_arch (ftype); @@ -5090,7 +5429,7 @@ index 85b814a..f0cb929 100644 struct type *value_type = NULL; CORE_ADDR funaddr; -@@ -241,24 +290,34 @@ find_function_addr (struct value *function, struct type **retval_type) +@@ -244,24 +293,34 @@ find_function_addr (struct value *function, struct type **retval_type) part of it. */ /* Determine address to call. */ @@ -5136,10 +5475,10 @@ index 85b814a..f0cb929 100644 /* Handle the case of functions lacking debugging info. Their values are characters since their addresses are char */ diff --git a/gdb/linux-nat.c b/gdb/linux-nat.c -index 146bb8c..9e08eee 100644 +index e467e9a..d7b5396 100644 --- a/gdb/linux-nat.c +++ b/gdb/linux-nat.c -@@ -1243,6 +1243,64 @@ iterate_over_lwps (ptid_t filter, +@@ -1257,6 +1257,64 @@ iterate_over_lwps (ptid_t filter, return NULL; } @@ -5205,10 +5544,10 @@ index 146bb8c..9e08eee 100644 another indicated by NEW_PTID. We can only switch single-threaded applications, so we only create one new LWP, and the previous list diff --git a/gdb/linux-nat.h b/gdb/linux-nat.h -index 2987fab..0e5f353 100644 +index 42cb2fc..05ac11d 100644 --- a/gdb/linux-nat.h +++ b/gdb/linux-nat.h -@@ -139,6 +139,11 @@ struct lwp_info *iterate_over_lwps (ptid_t filter, +@@ -140,6 +140,11 @@ struct lwp_info *iterate_over_lwps (ptid_t filter, void *), void *data); @@ -5220,11 +5559,162 @@ index 2987fab..0e5f353 100644 /* Create a prototype generic GNU/Linux target. The client can override it with local methods. */ struct target_ops * linux_target (void); +diff --git a/gdb/main.c b/gdb/main.c +index 69f2298..6b2530b 100644 +--- a/gdb/main.c ++++ b/gdb/main.c +@@ -39,6 +39,7 @@ + + #include "interps.h" + #include "main.h" ++#include "python/python.h" + #include "source.h" + #include "cli/cli-cmds.h" + #include "python/python.h" +@@ -260,6 +261,8 @@ captured_main (void *data) + char *cdarg = NULL; + char *ttyarg = NULL; + ++ int python_script = 0; ++ + /* These are static so that we can take their address in an + initializer. */ + static int print_help; +@@ -448,10 +451,14 @@ captured_main (void *data) + {"args", no_argument, &set_args, 1}, + {"l", required_argument, 0, 'l'}, + {"return-child-result", no_argument, &return_child_result, 1}, ++#if HAVE_PYTHON ++ {"python", no_argument, 0, 'P'}, ++ {"P", no_argument, 0, 'P'}, ++#endif + {0, no_argument, 0, 0} + }; + +- while (1) ++ while (!python_script) + { + int option_index; + +@@ -469,6 +476,9 @@ captured_main (void *data) + case 0: + /* Long option that just sets a flag. */ + break; ++ case 'P': ++ python_script = 1; ++ break; + case OPT_SE: + symarg = optarg; + execarg = optarg; +@@ -663,7 +673,31 @@ captured_main (void *data) + + /* 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 +@@ -912,7 +946,8 @@ captured_main (void *data) + + /* Read in the old history after all the command files have been + read. */ +- init_history (); ++ if (!python_script) ++ init_history (); + + if (batch_flag) + { +@@ -923,13 +958,25 @@ captured_main (void *data) + /* Show time and/or space usage. */ + do_cleanups (pre_stat_chain); + +- /* NOTE: cagney/1999-11-07: There is probably no reason for not +- moving this loop and the code found in captured_command_loop() +- into the command_loop() proper. The main thing holding back that +- change - SET_TOP_LEVEL() - has been eliminated. */ +- while (1) ++#if HAVE_PYTHON ++ if (python_script) + { +- catch_errors (captured_command_loop, 0, "", RETURN_MASK_ALL); ++ extern int pagination_enabled; ++ pagination_enabled = 0; ++ run_python_script (argc - optind, &argv[optind]); ++ return 1; ++ } ++ else ++#endif ++ { ++ /* NOTE: cagney/1999-11-07: There is probably no reason for not ++ moving this loop and the code found in captured_command_loop() ++ into the command_loop() proper. The main thing holding back that ++ change - SET_TOP_LEVEL() - has been eliminated. */ ++ while (1) ++ { ++ catch_errors (captured_command_loop, 0, "", RETURN_MASK_ALL); ++ } + } + /* No exit -- exit is through quit_command. */ + } +@@ -961,7 +1008,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\ +- gdb [options] --args executable-file [inferior-arguments ...]\n\n\ ++ gdb [options] --args executable-file [inferior-arguments ...]\n"), stream); ++#if HAVE_PYTHON ++ fputs_unfiltered (_("\ ++ gdb [options] [--python|-P] script-file [script-arguments ...]\n"), stream); ++#endif ++ fputs_unfiltered (_("\n\ + Options:\n\n\ + "), stream); + fputs_unfiltered (_("\ +@@ -999,7 +1051,13 @@ Options:\n\n\ + --nw Do not use a window interface.\n\ + --nx Do not read "), stream); + fputs_unfiltered (gdbinit, stream); +- fputs_unfiltered (_(" file.\n\ ++ fputs_unfiltered (_(" file.\n"), stream); ++#if HAVE_PYTHON ++ fputs_unfiltered (_("\ ++ --python, -P Following argument is Python script file; remaining\n\ ++ arguments are passed to script.\n"), stream); ++#endif ++ fputs_unfiltered (_("\ + --quiet Do not print version number on startup.\n\ + --readnow Fully read symbol files on first access.\n\ + "), stream); diff --git a/gdb/mi/mi-cmd-var.c b/gdb/mi/mi-cmd-var.c -index 1478cb0..c4492a7 100644 +index 8e0f410..e23f482 100644 --- a/gdb/mi/mi-cmd-var.c +++ b/gdb/mi/mi-cmd-var.c -@@ -702,7 +702,6 @@ mi_cmd_var_update (char *command, char **argv, int argc) +@@ -707,7 +707,6 @@ mi_cmd_var_update (char *command, char **argv, int argc) } else { @@ -5233,7 +5723,7 @@ index 1478cb0..c4492a7 100644 varobj_update_one (var, print_values, 1 /* explicit */); diff --git a/gdb/minsyms.c b/gdb/minsyms.c -index e870954..0436b57 100644 +index 77159a5..ea94c13 100644 --- a/gdb/minsyms.c +++ b/gdb/minsyms.c @@ -338,8 +338,9 @@ lookup_minimal_symbol_text (const char *name, struct objfile *objf) @@ -5284,7 +5774,7 @@ index e870954..0436b57 100644 SYMBOL_LINKAGE_NAME (tsymbol)) == 0) return SYMBOL_VALUE_ADDRESS (msymbol); diff --git a/gdb/p-valprint.c b/gdb/p-valprint.c -index bd01fea..77b1033 100644 +index 5390dd9..c0a0b2a 100644 --- a/gdb/p-valprint.c +++ b/gdb/p-valprint.c @@ -38,6 +38,7 @@ @@ -5324,19 +5814,18 @@ index bd01fea..77b1033 100644 switch (TYPE_CODE (type)) { case TYPE_CODE_ARRAY: -@@ -125,8 +145,9 @@ pascal_val_print (struct type *type, const gdb_byte *valaddr, +@@ -125,8 +145,8 @@ pascal_val_print (struct type *type, const gdb_byte *valaddr, { i = 0; } -- val_print_array_elements (type, valaddr + embedded_offset, address, stream, -- recurse, original_value, options, i); +- val_print_array_elements (type, valaddr + embedded_offset, +- address, stream, recurse, + val_print_array_elements (saved_type, valaddr + embedded_offset, + saved_address, stream, recurse, -+ original_value, options, i); + original_value, options, i); fprintf_filtered (stream, "}"); } - break; -@@ -164,6 +185,7 @@ pascal_val_print (struct type *type, const gdb_byte *valaddr, +@@ -165,6 +185,7 @@ pascal_val_print (struct type *type, const gdb_byte *valaddr, /* Try to print what function it points to. */ print_address_demangle (gdbarch, addr, stream, demangle); /* Return value is irrelevant except for string pointers. */ @@ -5344,7 +5833,7 @@ index bd01fea..77b1033 100644 return (0); } -@@ -254,6 +276,7 @@ pascal_val_print (struct type *type, const gdb_byte *valaddr, +@@ -256,6 +277,7 @@ pascal_val_print (struct type *type, const gdb_byte *valaddr, /* Return number of characters printed, including the terminating '\0' if we reached the end. val_print_string takes care including the terminating '\0' if necessary. */ @@ -5352,8 +5841,8 @@ index bd01fea..77b1033 100644 return i; break; -@@ -556,6 +579,7 @@ pascal_val_print (struct type *type, const gdb_byte *valaddr, - error (_("Invalid pascal type code %d in symbol table."), TYPE_CODE (type)); +@@ -572,6 +594,7 @@ pascal_val_print (struct type *type, const gdb_byte *valaddr, + TYPE_CODE (type)); } gdb_flush (stream); + do_cleanups (back_to); @@ -5361,7 +5850,7 @@ index bd01fea..77b1033 100644 } diff --git a/gdb/parse.c b/gdb/parse.c -index daee633..1f9a0d1 100644 +index 4f0c111..243a94a 100644 --- a/gdb/parse.c +++ b/gdb/parse.c @@ -487,9 +487,21 @@ write_exp_msymbol (struct minimal_symbol *msymbol) @@ -5410,7 +5899,7 @@ index daee633..1f9a0d1 100644 default: write_exp_elt_type (objfile_type (objfile)->nodebug_unknown_symbol); break; -@@ -1481,6 +1502,7 @@ parser_fprintf (FILE *x, const char *y, ...) +@@ -1482,6 +1503,7 @@ parser_fprintf (FILE *x, const char *y, ...) int operator_check_standard (struct expression *exp, int pos, @@ -5418,7 +5907,7 @@ index daee633..1f9a0d1 100644 int (*objfile_func) (struct objfile *objfile, void *data), void *data) -@@ -1522,7 +1544,7 @@ operator_check_standard (struct expression *exp, int pos, +@@ -1523,7 +1545,7 @@ operator_check_standard (struct expression *exp, int pos, struct type *type = elts[pos + 2 + arg].type; struct objfile *objfile = TYPE_OBJFILE (type); @@ -5427,7 +5916,7 @@ index daee633..1f9a0d1 100644 return 1; } } -@@ -1540,7 +1562,8 @@ operator_check_standard (struct expression *exp, int pos, +@@ -1541,7 +1563,8 @@ operator_check_standard (struct expression *exp, int pos, /* Check objfile where the variable itself is placed. SYMBOL_OBJ_SECTION (symbol) may be NULL. */ @@ -5437,7 +5926,7 @@ index daee633..1f9a0d1 100644 return 1; /* Check objfile where is placed the code touching the variable. */ -@@ -1553,24 +1576,27 @@ operator_check_standard (struct expression *exp, int pos, +@@ -1554,24 +1577,27 @@ operator_check_standard (struct expression *exp, int pos, /* Invoke callbacks for TYPE and OBJFILE if they were set as non-NULL. */ @@ -5473,7 +5962,7 @@ index daee633..1f9a0d1 100644 int (*objfile_func) (struct objfile *objfile, void *data), void *data) { -@@ -1585,7 +1611,9 @@ exp_iterate (struct expression *exp, +@@ -1586,7 +1612,9 @@ exp_iterate (struct expression *exp, pos = endpos - oplen; if (exp->language_defn->la_exp_desc->operator_check (exp, pos, @@ -5484,7 +5973,7 @@ index daee633..1f9a0d1 100644 return 1; endpos = pos; -@@ -1616,7 +1644,26 @@ exp_uses_objfile (struct expression *exp, struct objfile *objfile) +@@ -1617,7 +1645,26 @@ exp_uses_objfile (struct expression *exp, struct objfile *objfile) { gdb_assert (objfile->separate_debug_objfile_backlink == NULL); @@ -5684,10 +6173,10 @@ index ca7312b..58696d3 100644 return ret; diff --git a/gdb/printcmd.c b/gdb/printcmd.c -index eb3c3f9..ed8d67a 100644 +index b7d3ade..a6fa86a 100644 --- a/gdb/printcmd.c +++ b/gdb/printcmd.c -@@ -971,6 +971,11 @@ print_command_1 (char *exp, int inspect, int voidprint) +@@ -973,6 +973,11 @@ print_command_1 (char *exp, int inspect, int voidprint) else val = access_value_history (0); @@ -5699,7 +6188,7 @@ index eb3c3f9..ed8d67a 100644 if (voidprint || (val && value_type (val) && TYPE_CODE (value_type (val)) != TYPE_CODE_VOID)) { -@@ -1471,6 +1476,22 @@ x_command (char *exp, int from_tty) +@@ -1474,6 +1479,22 @@ x_command (char *exp, int from_tty) set_internalvar (lookup_internalvar ("__"), last_examine_value); } } @@ -5722,13 +6211,1163 @@ index eb3c3f9..ed8d67a 100644 /* Add an expression to the auto-display chain. -@@ -2869,4 +2890,6 @@ Show printing of source filename and line number with ."), NULL, +@@ -2874,4 +2895,6 @@ Show printing of source filename and line number with ."), NULL, add_com ("eval", no_class, eval_command, _("\ Convert \"printf format string\", arg1, arg2, arg3, ..., argn to\n\ a command line, and call it.")); + + observer_attach_mark_used (print_types_mark_used); } +diff --git a/gdb/python/lib/gdb/FrameIterator.py b/gdb/python/lib/gdb/FrameIterator.py +new file mode 100644 +index 0000000..5654546 +--- /dev/null ++++ b/gdb/python/lib/gdb/FrameIterator.py +@@ -0,0 +1,33 @@ ++# Iterator over frames. ++ ++# Copyright (C) 2008, 2009 Free Software Foundation, Inc. ++ ++# This program is free software; you can redistribute it and/or modify ++# it under the terms of the GNU General Public License as published by ++# the Free Software Foundation; either version 3 of the License, or ++# (at your option) any later version. ++# ++# This program is distributed in the hope that it will be useful, ++# but WITHOUT ANY WARRANTY; without even the implied warranty of ++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++# GNU General Public License for more details. ++# ++# You should have received a copy of the GNU General Public License ++# along with this program. If not, see . ++ ++class FrameIterator: ++ """An iterator that iterates over frames.""" ++ ++ def __init__ (self, frame): ++ "Initialize a FrameIterator. FRAME is the starting frame." ++ self.frame = frame ++ ++ def __iter__ (self): ++ return self ++ ++ def next (self): ++ result = self.frame ++ if result is None: ++ raise StopIteration ++ self.frame = result.older () ++ return result +diff --git a/gdb/python/lib/gdb/FrameWrapper.py b/gdb/python/lib/gdb/FrameWrapper.py +new file mode 100644 +index 0000000..b790a54 +--- /dev/null ++++ b/gdb/python/lib/gdb/FrameWrapper.py +@@ -0,0 +1,112 @@ ++# Wrapper API for frames. ++ ++# Copyright (C) 2008, 2009 Free Software Foundation, Inc. ++ ++# This program is free software; you can redistribute it and/or modify ++# it under the terms of the GNU General Public License as published by ++# the Free Software Foundation; either version 3 of the License, or ++# (at your option) any later version. ++# ++# This program is distributed in the hope that it will be useful, ++# but WITHOUT ANY WARRANTY; without even the implied warranty of ++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++# GNU General Public License for more details. ++# ++# You should have received a copy of the GNU General Public License ++# along with this program. If not, see . ++ ++import gdb ++ ++# FIXME: arguably all this should be on Frame somehow. ++class FrameWrapper: ++ def __init__ (self, frame): ++ self.frame = frame; ++ ++ def write_symbol (self, stream, sym, block): ++ if len (sym.linkage_name): ++ nsym, is_field_of_this = gdb.lookup_symbol (sym.linkage_name, block) ++ if nsym.addr_class != gdb.SYMBOL_LOC_REGISTER: ++ sym = nsym ++ ++ stream.write (sym.print_name + "=") ++ try: ++ val = self.read_var (sym) ++ if val != None: ++ val = str (val) ++ # FIXME: would be nice to have a more precise exception here. ++ except RuntimeError, text: ++ val = text ++ if val == None: ++ stream.write ("???") ++ else: ++ stream.write (str (val)) ++ ++ def print_frame_locals (self, stream, func): ++ if not func: ++ return ++ ++ first = True ++ block = func.value ++ ++ for sym in block: ++ if sym.is_argument: ++ continue; ++ ++ self.write_symbol (stream, sym, block) ++ stream.write ('\n') ++ ++ def print_frame_args (self, stream, func): ++ if not func: ++ return ++ ++ first = True ++ block = func.value ++ ++ for sym in block: ++ if not sym.is_argument: ++ continue; ++ ++ if not first: ++ stream.write (", ") ++ ++ self.write_symbol (stream, sym, block) ++ first = False ++ ++ # FIXME: this should probably just be a method on gdb.Frame. ++ # But then we need stream wrappers. ++ def describe (self, stream, full): ++ if self.type () == gdb.DUMMY_FRAME: ++ stream.write (" \n") ++ elif self.type () == gdb.SIGTRAMP_FRAME: ++ stream.write (" \n") ++ else: ++ sal = self.find_sal () ++ pc = self.pc () ++ name = self.name () ++ if not name: ++ name = "??" ++ if pc != sal.pc or not sal.symtab: ++ stream.write (" 0x%08x in" % pc) ++ stream.write (" " + name + " (") ++ ++ func = self.function () ++ self.print_frame_args (stream, func) ++ ++ stream.write (")") ++ ++ if sal.symtab and sal.symtab.filename: ++ stream.write (" at " + sal.symtab.filename) ++ stream.write (":" + str (sal.line)) ++ ++ if not self.name () or (not sal.symtab or not sal.symtab.filename): ++ lib = gdb.solib_address (pc) ++ if lib: ++ stream.write (" from " + lib) ++ ++ stream.write ("\n") ++ ++ if full: ++ self.print_frame_locals (stream, func) ++ ++ def __getattr__ (self, name): ++ return getattr (self.frame, name) +diff --git a/gdb/python/lib/gdb/backtrace.py b/gdb/python/lib/gdb/backtrace.py +new file mode 100644 +index 0000000..2baab5f +--- /dev/null ++++ b/gdb/python/lib/gdb/backtrace.py +@@ -0,0 +1,42 @@ ++# Filtering backtrace. ++ ++# Copyright (C) 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 . ++ ++import gdb ++import itertools ++ ++# Our only exports. ++__all__ = ['push_frame_filter', 'create_frame_filter'] ++ ++frame_filter = None ++ ++def push_frame_filter (constructor): ++ """Register a new backtrace filter class with the 'backtrace' command. ++The filter will be passed an iterator as an argument. The iterator ++will return gdb.Frame-like objects. The filter should in turn act as ++an iterator returning such objects.""" ++ global frame_filter ++ if frame_filter == None: ++ frame_filter = constructor ++ else: ++ frame_filter = lambda iterator: constructor (frame_filter (iterator)) ++ ++def create_frame_filter (iter): ++ global frame_filter ++ if frame_filter is None: ++ return iter ++ return frame_filter (iter) ++ +diff --git a/gdb/python/lib/gdb/command/alias.py b/gdb/python/lib/gdb/command/alias.py +new file mode 100644 +index 0000000..96b6618 +--- /dev/null ++++ b/gdb/python/lib/gdb/command/alias.py +@@ -0,0 +1,59 @@ ++# Alias command. ++ ++# Copyright (C) 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 . ++ ++import gdb ++ ++class AliasImplementation (gdb.Command): ++ def __init__ (self, name, real, doc): ++ # Have to set __doc__ before the super init call. ++ # It would be nice if gdb's help looked up __doc__ dynamically. ++ self.__doc__ = doc ++ # Note: no good way to complete :( ++ super (AliasImplementation, self).__init__ (name, gdb.COMMAND_NONE) ++ self.real = real ++ ++ def invoke(self, arg, from_tty): ++ gdb.execute (self.real + ' ' + arg, from_tty) ++ ++class AliasCommand (gdb.Command): ++ """Alias one command to another. ++In the simplest form, the first word is the name of the alias, and ++the remaining words are the the expansion. ++An '=' by itself can be used to define a multi-word alias; words ++before the '=' are the name of the new command.""" ++ ++ def __init__ (self): ++ # Completion is not quite right here. ++ super (AliasCommand, self).__init__ ("alias", gdb.COMMAND_NONE, ++ gdb.COMPLETE_COMMAND) ++ ++ def invoke (self, arg, from_tty): ++ self.dont_repeat () ++ # Without some form of quoting we can't alias a multi-word ++ # command to another command. ++ args = arg.split() ++ try: ++ start = args.index ('=') ++ end = start + 1 ++ except ValueError: ++ start = 1 ++ end = 1 ++ target = " ".join(args[end:]) ++ AliasImplementation (" ".join (args[0:start]), target, ++ "This command is an alias for '%s'." % target) ++ ++AliasCommand() +diff --git a/gdb/python/lib/gdb/command/backtrace.py b/gdb/python/lib/gdb/command/backtrace.py +new file mode 100644 +index 0000000..ec9a527 +--- /dev/null ++++ b/gdb/python/lib/gdb/command/backtrace.py +@@ -0,0 +1,106 @@ ++# New backtrace command. ++ ++# Copyright (C) 2008, 2009 Free Software Foundation, Inc. ++ ++# This program is free software; you can redistribute it and/or modify ++# it under the terms of the GNU General Public License as published by ++# the Free Software Foundation; either version 3 of the License, or ++# (at your option) any later version. ++# ++# This program is distributed in the hope that it will be useful, ++# but WITHOUT ANY WARRANTY; without even the implied warranty of ++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++# GNU General Public License for more details. ++# ++# You should have received a copy of the GNU General Public License ++# along with this program. If not, see . ++ ++import gdb ++import gdb.backtrace ++import itertools ++from gdb.FrameIterator import FrameIterator ++from gdb.FrameWrapper import FrameWrapper ++import sys ++ ++class ReverseBacktraceParameter (gdb.Parameter): ++ """The new-backtrace command can show backtraces in 'reverse' order. ++This means that the innermost frame will be printed last. ++Note that reverse backtraces are more expensive to compute.""" ++ ++ set_doc = "Enable or disable reverse backtraces." ++ show_doc = "Show whether backtraces will be printed in reverse order." ++ ++ def __init__(self): ++ gdb.Parameter.__init__ (self, "reverse-backtrace", ++ gdb.COMMAND_STACK, gdb.PARAM_BOOLEAN) ++ # Default to compatibility with gdb. ++ self.value = False ++ ++class FilteringBacktrace (gdb.Command): ++ """Print backtrace of all stack frames, or innermost COUNT frames. ++With a negative argument, print outermost -COUNT frames. ++Use of the 'full' qualifier also prints the values of the local variables. ++Use of the 'raw' qualifier avoids any filtering by loadable modules. ++""" ++ ++ def __init__ (self): ++ # FIXME: this is not working quite well enough to replace ++ # "backtrace" yet. ++ gdb.Command.__init__ (self, "new-backtrace", gdb.COMMAND_STACK) ++ self.reverse = ReverseBacktraceParameter() ++ ++ def reverse_iter (self, iter): ++ result = [] ++ for item in iter: ++ result.append (item) ++ result.reverse() ++ return result ++ ++ def final_n (self, iter, x): ++ result = [] ++ for item in iter: ++ result.append (item) ++ return result[x:] ++ ++ def invoke (self, arg, from_tty): ++ i = 0 ++ count = 0 ++ filter = True ++ full = False ++ ++ for word in arg.split (" "): ++ if word == '': ++ continue ++ elif word == 'raw': ++ filter = False ++ elif word == 'full': ++ full = True ++ else: ++ count = int (word) ++ ++ # FIXME: provide option to start at selected frame ++ # However, should still number as if starting from newest ++ newest_frame = gdb.selected_thread ().newest_frame () ++ iter = itertools.imap (FrameWrapper, ++ FrameIterator (newest_frame)) ++ if filter: ++ iter = gdb.backtrace.create_frame_filter (iter) ++ ++ # Now wrap in an iterator that numbers the frames. ++ iter = itertools.izip (itertools.count (0), iter) ++ ++ # Reverse if the user wanted that. ++ if self.reverse.value: ++ iter = self.reverse_iter (iter) ++ ++ # Extract sub-range user wants. ++ if count < 0: ++ iter = self.final_n (iter, count) ++ elif count > 0: ++ iter = itertools.islice (iter, 0, count) ++ ++ for pair in iter: ++ sys.stdout.write ("#%-2d" % pair[0]) ++ pair[1].describe (sys.stdout, full) ++ ++FilteringBacktrace() +diff --git a/gdb/python/lib/gdb/command/ignore_errors.py b/gdb/python/lib/gdb/command/ignore_errors.py +new file mode 100644 +index 0000000..6fa48ff +--- /dev/null ++++ b/gdb/python/lib/gdb/command/ignore_errors.py +@@ -0,0 +1,37 @@ ++# Ignore errors in user commands. ++ ++# Copyright (C) 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 . ++ ++import gdb ++ ++class IgnoreErrorsCommand (gdb.Command): ++ """Execute a single command, ignoring all errors. ++Only one-line commands are supported. ++This is primarily useful in scripts.""" ++ ++ def __init__ (self): ++ super (IgnoreErrorsCommand, self).__init__ ("ignore-errors", ++ gdb.COMMAND_OBSCURE, ++ # FIXME... ++ gdb.COMPLETE_COMMAND) ++ ++ def invoke (self, arg, from_tty): ++ try: ++ gdb.execute (arg, from_tty) ++ except: ++ pass ++ ++IgnoreErrorsCommand () +diff --git a/gdb/python/lib/gdb/command/pahole.py b/gdb/python/lib/gdb/command/pahole.py +new file mode 100644 +index 0000000..21a0bf0 +--- /dev/null ++++ b/gdb/python/lib/gdb/command/pahole.py +@@ -0,0 +1,75 @@ ++# pahole command for gdb ++ ++# Copyright (C) 2008, 2009 Free Software Foundation, Inc. ++ ++# This program is free software; you can redistribute it and/or modify ++# it under the terms of the GNU General Public License as published by ++# the Free Software Foundation; either version 3 of the License, or ++# (at your option) any later version. ++# ++# This program is distributed in the hope that it will be useful, ++# but WITHOUT ANY WARRANTY; without even the implied warranty of ++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++# GNU General Public License for more details. ++# ++# You should have received a copy of the GNU General Public License ++# along with this program. If not, see . ++ ++import gdb ++ ++class Pahole (gdb.Command): ++ """Show the holes in a structure. ++This command takes a single argument, a type name. ++It prints the type and displays comments showing where holes are.""" ++ ++ def __init__ (self): ++ super (Pahole, self).__init__ ("pahole", gdb.COMMAND_NONE, ++ gdb.COMPLETE_SYMBOL) ++ ++ def pahole (self, type, level, name): ++ if name is None: ++ name = '' ++ tag = type.tag ++ if tag is None: ++ tag = '' ++ print '%sstruct %s {' % (' ' * (2 * level), tag) ++ bitpos = 0 ++ for field in type.fields (): ++ # Skip static fields. ++ if not hasattr (field, ('bitpos')): ++ continue ++ ++ ftype = field.type.strip_typedefs() ++ ++ if bitpos != field.bitpos: ++ hole = field.bitpos - bitpos ++ print ' /* XXX %d bit hole, try to pack */' % hole ++ bitpos = field.bitpos ++ if field.bitsize > 0: ++ fieldsize = field.bitsize ++ else: ++ # TARGET_CHAR_BIT here... ++ fieldsize = 8 * ftype.sizeof ++ ++ # TARGET_CHAR_BIT ++ print ' /* %3d %3d */' % (int (bitpos / 8), int (fieldsize / 8)), ++ bitpos = bitpos + fieldsize ++ ++ if ftype.code == gdb.TYPE_CODE_STRUCT: ++ self.pahole (ftype, level + 1, field.name) ++ else: ++ print ' ' * (2 + 2 * level), ++ print '%s %s' % (str (ftype), field.name) ++ ++ print ' ' * (14 + 2 * level), ++ print '} %s' % name ++ ++ def invoke (self, arg, from_tty): ++ type = gdb.lookup_type (arg) ++ type = type.strip_typedefs () ++ if type.code != gdb.TYPE_CODE_STRUCT: ++ raise TypeError, '%s is not a struct type' % arg ++ print ' ' * 14, ++ self.pahole (type, 0, '') ++ ++Pahole() +diff --git a/gdb/python/lib/gdb/command/require.py b/gdb/python/lib/gdb/command/require.py +new file mode 100644 +index 0000000..1fbc1e8 +--- /dev/null ++++ b/gdb/python/lib/gdb/command/require.py +@@ -0,0 +1,57 @@ ++# Demand-loading commands. ++ ++# Copyright (C) 2008, 2009 Free Software Foundation, Inc. ++ ++# This program is free software; you can redistribute it and/or modify ++# it under the terms of the GNU General Public License as published by ++# the Free Software Foundation; either version 3 of the License, or ++# (at your option) any later version. ++# ++# This program is distributed in the hope that it will be useful, ++# but WITHOUT ANY WARRANTY; without even the implied warranty of ++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++# GNU General Public License for more details. ++# ++# You should have received a copy of the GNU General Public License ++# along with this program. If not, see . ++ ++import gdb ++import os ++ ++class RequireCommand (gdb.Command): ++ """Prefix command for requiring features.""" ++ ++ def __init__ (self): ++ super (RequireCommand, self).__init__ ("require", ++ gdb.COMMAND_SUPPORT, ++ gdb.COMPLETE_NONE, ++ True) ++ ++class RequireSubcommand (gdb.Command): ++ """Demand-load a command by name.""" ++ ++ def __init__ (self, name): ++ self.__doc__ = "Demand-load a %s by name." % name ++ super (RequireSubcommand, self).__init__ ("require %s" % name, ++ gdb.COMMAND_SUPPORT) ++ self.name = name ++ ++ def invoke (self, arg, from_tty): ++ for cmd in arg.split(): ++ exec ('import gdb.' + self.name + '.' + cmd, globals ()) ++ ++ def complete (self, text, word): ++ dir = gdb.pythondir + '/gdb/' + self.name ++ result = [] ++ for file in os.listdir(dir): ++ if not file.startswith (word) or not file.endswith ('.py'): ++ continue ++ feature = file[0:-3] ++ if feature == 'require' or feature == '__init__': ++ continue ++ result.append (feature) ++ return result ++ ++RequireCommand() ++RequireSubcommand("command") ++RequireSubcommand("function") +diff --git a/gdb/python/lib/gdb/command/upto.py b/gdb/python/lib/gdb/command/upto.py +new file mode 100644 +index 0000000..faf54ed +--- /dev/null ++++ b/gdb/python/lib/gdb/command/upto.py +@@ -0,0 +1,129 @@ ++# upto command. ++ ++# Copyright (C) 2009 Free Software Foundation, Inc. ++ ++# This program is free software; you can redistribute it and/or modify ++# it under the terms of the GNU General Public License as published by ++# the Free Software Foundation; either version 3 of the License, or ++# (at your option) any later version. ++# ++# This program is distributed in the hope that it will be useful, ++# but WITHOUT ANY WARRANTY; without even the implied warranty of ++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++# GNU General Public License for more details. ++# ++# You should have received a copy of the GNU General Public License ++# along with this program. If not, see . ++ ++import gdb ++import re ++from gdb.FrameIterator import FrameIterator ++from gdb.FrameWrapper import FrameWrapper ++ ++class UptoPrefix (gdb.Command): ++ def __init__ (self): ++ super (UptoPrefix, self).__init__ ("upto", gdb.COMMAND_STACK, ++ prefix = True) ++ ++class UptoImplementation (gdb.Command): ++ def __init__ (self, subcommand): ++ super (UptoImplementation, self).__init__ ("upto " + subcommand, ++ gdb.COMMAND_STACK) ++ ++ def search (self): ++ saved = gdb.selected_frame () ++ iter = FrameIterator (saved) ++ found = False ++ try: ++ for frame in iter: ++ frame.select () ++ try: ++ if self.filter (frame): ++ wrapper = FrameWrapper (frame) ++ wrapper.describe (sys.stdout, False) ++ return ++ except: ++ pass ++ except: ++ pass ++ saved.select () ++ raise RuntimeError, 'Could not find a matching frame' ++ ++ def invoke (self, arg, from_tty): ++ self.rx = re.compile (arg) ++ self.search () ++ ++class UptoSymbolCommand (UptoImplementation): ++ """Select and print some calling stack frame, based on symbol. ++The argument is a regular expression. This command moves up the ++stack, stopping at the first frame whose symbol matches the regular ++expression.""" ++ ++ def __init__ (self): ++ super (UptoSymbolCommand, self).__init__ ("symbol") ++ ++ def filter (self, frame): ++ name = frame.name () ++ if name is not None: ++ if self.rx.search (name) is not None: ++ return True ++ return False ++ ++class UptoSourceCommand (UptoImplementation): ++ """Select and print some calling stack frame, based on source file. ++The argument is a regular expression. This command moves up the ++stack, stopping at the first frame whose source file name matches the ++regular expression.""" ++ ++ def __init__ (self): ++ super (UptoSourceCommand, self).__init__ ("source") ++ ++ def filter (self, frame): ++ name = frame.find_sal ().symtab.filename ++ if name is not None: ++ if self.rx.search (name) is not None: ++ return True ++ return False ++ ++class UptoObjectCommand (UptoImplementation): ++ """Select and print some calling stack frame, based on object file. ++The argument is a regular expression. This command moves up the ++stack, stopping at the first frame whose object file name matches the ++regular expression.""" ++ ++ def __init__ (self): ++ super (UptoObjectCommand, self).__init__ ("object") ++ ++ def filter (self, frame): ++ name = frame.find_sal ().symtab.objfile.filename ++ if name is not None: ++ if self.rx.search (name) is not None: ++ return True ++ return False ++ ++class UptoWhereCommand (UptoImplementation): ++ """Select and print some calling stack frame, based on expression. ++The argument is an expression. This command moves up the stack, ++parsing and evaluating the expression in each frame. This stops when ++the expression evaluates to a non-zero (true) value.""" ++ ++ def __init__ (self): ++ super (UptoWhereCommand, self).__init__ ("where") ++ ++ def filter (self, frame): ++ try: ++ if gdb.parse_and_eval (self.expression): ++ return True ++ except: ++ pass ++ return False ++ ++ def invoke (self, arg, from_tty): ++ self.expression = arg ++ self.search () ++ ++UptoPrefix () ++UptoSymbolCommand () ++UptoSourceCommand () ++UptoObjectCommand () ++UptoWhereCommand () +diff --git a/gdb/python/lib/gdb/function/__init__.py b/gdb/python/lib/gdb/function/__init__.py +new file mode 100644 +index 0000000..8b13789 +--- /dev/null ++++ b/gdb/python/lib/gdb/function/__init__.py +@@ -0,0 +1 @@ ++ +diff --git a/gdb/python/lib/gdb/function/caller_is.py b/gdb/python/lib/gdb/function/caller_is.py +new file mode 100644 +index 0000000..2b9c5c7 +--- /dev/null ++++ b/gdb/python/lib/gdb/function/caller_is.py +@@ -0,0 +1,58 @@ ++# Caller-is functions. ++ ++# Copyright (C) 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 . ++ ++import gdb ++import re ++ ++class CallerIs (gdb.Function): ++ """Return True if the calling function's name is equal to a string. ++This function takes one or two arguments. ++The first argument is the name of a function; if the calling function's ++name is equal to this argument, this function returns True. ++The optional second argument tells this function how many stack frames ++to traverse to find the calling function. The default is 1.""" ++ ++ def __init__ (self): ++ super (CallerIs, self).__init__ ("caller_is") ++ ++ def invoke (self, name, nframes = 1): ++ frame = gdb.selected_frame () ++ while nframes > 0: ++ frame = frame.older () ++ nframes = nframes - 1 ++ return frame.name () == name.string () ++ ++class CallerMatches (gdb.Function): ++ """Return True if the calling function's name matches a string. ++This function takes one or two arguments. ++The first argument is a regular expression; if the calling function's ++name is matched by this argument, this function returns True. ++The optional second argument tells this function how many stack frames ++to traverse to find the calling function. The default is 1.""" ++ ++ def __init__ (self): ++ super (CallerMatches, self).__init__ ("caller_matches") ++ ++ def invoke (self, name, nframes = 1): ++ frame = gdb.selected_frame () ++ while nframes > 0: ++ frame = frame.older () ++ nframes = nframes - 1 ++ return re.match (name.string (), frame.name ()) is not None ++ ++CallerIs() ++CallerMatches() +diff --git a/gdb/python/lib/gdb/function/in_scope.py b/gdb/python/lib/gdb/function/in_scope.py +new file mode 100644 +index 0000000..debb3bb +--- /dev/null ++++ b/gdb/python/lib/gdb/function/in_scope.py +@@ -0,0 +1,47 @@ ++# In-scope function. ++ ++# Copyright (C) 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 . ++ ++import gdb ++ ++class InScope (gdb.Function): ++ """Return True if all the given variables or macros are in scope. ++Takes one argument for each variable name to be checked.""" ++ ++ def __init__ (self): ++ super (InScope, self).__init__ ("in_scope") ++ ++ def invoke (self, *vars): ++ if len (vars) == 0: ++ raise TypeError, "in_scope takes at least one argument" ++ ++ # gdb.Value isn't hashable so it can't be put in a map. ++ # Convert to string first. ++ wanted = set (map (lambda x: x.string (), vars)) ++ found = set () ++ block = gdb.selected_frame ().block () ++ while block: ++ for sym in block: ++ if (sym.is_argument or sym.is_constant ++ or sym.is_function or sym.is_variable): ++ if sym.name in wanted: ++ found.add (sym.name) ++ ++ block = block.superblock ++ ++ return wanted == found ++ ++InScope () +diff --git a/gdb/python/py-cmd.c b/gdb/python/py-cmd.c +index 3de3af2..6a7a20b 100644 +--- a/gdb/python/py-cmd.c ++++ b/gdb/python/py-cmd.c +@@ -49,8 +49,7 @@ static struct cmdpy_completer completers[] = + + #define N_COMPLETERS (sizeof (completers) / sizeof (completers[0])) + +-/* A gdb command. For the time being only ordinary commands (not +- set/show commands) are allowed. */ ++/* A gdb command. */ + struct cmdpy_object + { + PyObject_HEAD +diff --git a/gdb/python/py-membuf.c b/gdb/python/py-membuf.c +new file mode 100644 +index 0000000..7bc294c +--- /dev/null ++++ b/gdb/python/py-membuf.c +@@ -0,0 +1,268 @@ ++/* Python interface to the inferior memory. ++ ++ Copyright (C) 2008, 2009 Free Software Foundation, Inc. ++ ++ This file is part of GDB. ++ ++ This program is free software; you can redistribute it and/or modify ++ it under the terms of the GNU General Public License as published by ++ the Free Software Foundation; either version 3 of the License, or ++ (at your option) any later version. ++ ++ This program is distributed in the hope that it will be useful, ++ but WITHOUT ANY WARRANTY; without even the implied warranty of ++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++ GNU General Public License for more details. ++ ++ You should have received a copy of the GNU General Public License ++ along with this program. If not, see . */ ++ ++#include "defs.h" ++#include "exceptions.h" ++#include "gdbcore.h" ++#include "python-internal.h" ++ ++typedef struct { ++ PyObject_HEAD ++ void *buffer; ++ ++ /* These are kept just for mbpy_str. */ ++ CORE_ADDR addr; ++ CORE_ADDR length; ++} membuf_object; ++ ++static PyTypeObject membuf_object_type; ++ ++/* Implementation of gdb.read_memory (address, length). ++ Returns a Python buffer object with LENGTH bytes of the inferior's memory ++ at ADDRESS. Both arguments are integers. */ ++ ++PyObject * ++gdbpy_read_memory (PyObject *self, PyObject *args) ++{ ++ int error = 0; ++ CORE_ADDR addr, length; ++ void *buffer = NULL; ++ membuf_object *membuf_obj; ++ PyObject *addr_obj, *length_obj; ++ struct cleanup *cleanups = NULL; ++ volatile struct gdb_exception except; ++ ++ if (! PyArg_ParseTuple (args, "OO", &addr_obj, &length_obj)) ++ return NULL; ++ ++ TRY_CATCH (except, RETURN_MASK_ALL) ++ { ++ if (!get_addr_from_python (addr_obj, &addr) ++ || !get_addr_from_python (length_obj, &length)) ++ { ++ error = 1; ++ break; ++ } ++ ++ buffer = xmalloc (length); ++ cleanups = make_cleanup (xfree, buffer); ++ ++ read_memory (addr, buffer, length); ++ } ++ GDB_PY_HANDLE_EXCEPTION (except); ++ ++ if (error) ++ return NULL; ++ ++ discard_cleanups (cleanups); ++ ++ membuf_obj = PyObject_New (membuf_object, &membuf_object_type); ++ if (membuf_obj == NULL) ++ { ++ xfree (buffer); ++ PyErr_SetString (PyExc_MemoryError, ++ "Could not allocate memory buffer object."); ++ return NULL; ++ } ++ ++ membuf_obj->buffer = buffer; ++ membuf_obj->addr = addr; ++ membuf_obj->length = length; ++ ++ return PyBuffer_FromReadWriteObject ((PyObject *) membuf_obj, 0, ++ Py_END_OF_BUFFER); ++} ++ ++/* Implementation of gdb.write_memory (address, buffer [, length]). ++ Writes the contents of BUFFER (a Python object supporting the read buffer ++ protocol) at ADDRESS in the inferior's memory. Write LENGTH bytes from ++ BUFFER, or its entire contents if the argument is not provided. The ++ function returns nothing. */ ++ ++PyObject * ++gdbpy_write_memory (PyObject *self, PyObject *args) ++{ ++ int buf_len, error = 0; ++ const char *buffer; ++ CORE_ADDR addr, length; ++ PyObject *addr_obj, *length_obj = NULL; ++ volatile struct gdb_exception except; ++ ++ if (! PyArg_ParseTuple (args, "Os#|O", &addr_obj, &buffer, &buf_len, ++ &length_obj)) ++ return NULL; ++ ++ TRY_CATCH (except, RETURN_MASK_ALL) ++ { ++ if (!get_addr_from_python (addr_obj, &addr)) ++ { ++ error = 1; ++ break; ++ } ++ ++ if (!length_obj) ++ length = buf_len; ++ else if (!get_addr_from_python (length_obj, &length)) ++ { ++ error = 1; ++ break; ++ } ++ ++ write_memory (addr, buffer, length); ++ } ++ GDB_PY_HANDLE_EXCEPTION (except); ++ ++ if (error) ++ return NULL; ++ ++ Py_RETURN_NONE; ++} ++ ++/* Destructor of Membuf objects. */ ++ ++static void ++mbpy_dealloc (PyObject *self) ++{ ++ xfree (((membuf_object *) self)->buffer); ++ self->ob_type->tp_free (self); ++} ++ ++/* Return a description of the Membuf object. */ ++ ++static PyObject * ++mbpy_str (PyObject *self) ++{ ++ membuf_object *membuf_obj = (membuf_object *) self; ++ ++ return PyString_FromFormat ("memory buffer for address %s, %s bytes long", ++ paddress (membuf_obj->addr), ++ pulongest (membuf_obj->length)); ++} ++ ++static Py_ssize_t ++get_read_buffer (PyObject *self, Py_ssize_t segment, void **ptrptr) ++{ ++ membuf_object *membuf_obj = (membuf_object *) self; ++ ++ if (segment) ++ { ++ PyErr_SetString (PyExc_SystemError, ++ "The memory buffer supports only one segment."); ++ return -1; ++ } ++ ++ *ptrptr = membuf_obj->buffer; ++ ++ return membuf_obj->length; ++} ++ ++static Py_ssize_t ++get_write_buffer (PyObject *self, Py_ssize_t segment, void **ptrptr) ++{ ++ return get_read_buffer (self, segment, ptrptr); ++} ++ ++static Py_ssize_t ++get_seg_count (PyObject *self, Py_ssize_t *lenp) ++{ ++ if (lenp) ++ *lenp = ((membuf_object *) self)->length; ++ ++ return 1; ++} ++ ++static Py_ssize_t ++get_char_buffer (PyObject *self, Py_ssize_t segment, char **ptrptr) ++{ ++ void *ptr = NULL; ++ Py_ssize_t ret; ++ ++ ret = get_read_buffer (self, segment, &ptr); ++ *ptrptr = (char *) ptr; ++ ++ return ret; ++} ++ ++/* Python doesn't provide a decent way to get compatibility here. */ ++#if HAVE_LIBPYTHON2_4 ++#define CHARBUFFERPROC_NAME getcharbufferproc ++#else ++#define CHARBUFFERPROC_NAME charbufferproc ++#endif ++ ++static PyBufferProcs buffer_procs = { ++ get_read_buffer, ++ get_write_buffer, ++ get_seg_count, ++ /* The cast here works around a difference between Python 2.4 and ++ Python 2.5. */ ++ (CHARBUFFERPROC_NAME) get_char_buffer ++}; ++ ++static PyTypeObject membuf_object_type = { ++ PyObject_HEAD_INIT (NULL) ++ 0, /*ob_size*/ ++ "gdb.Membuf", /*tp_name*/ ++ sizeof (membuf_object), /*tp_basicsize*/ ++ 0, /*tp_itemsize*/ ++ mbpy_dealloc, /*tp_dealloc*/ ++ 0, /*tp_print*/ ++ 0, /*tp_getattr*/ ++ 0, /*tp_setattr*/ ++ 0, /*tp_compare*/ ++ 0, /*tp_repr*/ ++ 0, /*tp_as_number*/ ++ 0, /*tp_as_sequence*/ ++ 0, /*tp_as_mapping*/ ++ 0, /*tp_hash */ ++ 0, /*tp_call*/ ++ mbpy_str, /*tp_str*/ ++ 0, /*tp_getattro*/ ++ 0, /*tp_setattro*/ ++ &buffer_procs, /*tp_as_buffer*/ ++ Py_TPFLAGS_DEFAULT, /*tp_flags*/ ++ "GDB memory buffer object", /*tp_doc*/ ++ 0, /* tp_traverse */ ++ 0, /* tp_clear */ ++ 0, /* tp_richcompare */ ++ 0, /* tp_weaklistoffset */ ++ 0, /* tp_iter */ ++ 0, /* tp_iternext */ ++ 0, /* tp_methods */ ++ 0, /* tp_members */ ++ 0, /* tp_getset */ ++ 0, /* tp_base */ ++ 0, /* tp_dict */ ++ 0, /* tp_descr_get */ ++ 0, /* tp_descr_set */ ++ 0, /* tp_dictoffset */ ++ 0, /* tp_init */ ++ 0, /* tp_alloc */ ++ PyType_GenericNew /* tp_new */ ++}; ++ ++void ++gdbpy_initialize_membuf (void) ++{ ++ if (PyType_Ready (&membuf_object_type) < 0) ++ return; ++ ++ Py_INCREF (&membuf_object_type); ++ PyModule_AddObject (gdb_module, "Membuf", (PyObject *) &membuf_object_type); ++} +diff --git a/gdb/python/py-prettyprint.c b/gdb/python/py-prettyprint.c +index 7532aa5..85f3940 100644 +--- a/gdb/python/py-prettyprint.c ++++ b/gdb/python/py-prettyprint.c +@@ -227,10 +227,10 @@ pretty_print_one_value (PyObject *printer, struct value **out_value) + && result != Py_None) + { + *out_value = convert_value_from_python (result); +- if (PyErr_Occurred ()) +- *out_value = NULL; +- Py_DECREF (result); +- result = NULL; ++ if (PyErr_Occurred ()) ++ *out_value = NULL; ++ Py_DECREF (result); ++ result = NULL; + } + } + } +@@ -763,14 +763,7 @@ gdbpy_get_varobj_pretty_printer (struct value *value) + { + PyObject *val_obj; + PyObject *pretty_printer = NULL; +- volatile struct gdb_exception except; + +- TRY_CATCH (except, RETURN_MASK_ALL) +- { +- value = value_copy (value); +- } +- GDB_PY_HANDLE_EXCEPTION (except); +- + val_obj = value_to_value_object (value); + if (! val_obj) + return NULL; diff --git a/gdb/python/py-type.c b/gdb/python/py-type.c index 9a6b077..656d3a1 100644 --- a/gdb/python/py-type.c @@ -5916,7 +7555,7 @@ index 9a6b077..656d3a1 100644 diff --git a/gdb/python/py-value.c b/gdb/python/py-value.c -index adb7658..1e1f7e9 100644 +index 1aa9443..786c45a 100644 --- a/gdb/python/py-value.c +++ b/gdb/python/py-value.c @@ -28,6 +28,7 @@ @@ -5927,7 +7566,7 @@ index adb7658..1e1f7e9 100644 #ifdef HAVE_PYTHON -@@ -1220,6 +1221,17 @@ gdbpy_is_value_object (PyObject *obj) +@@ -1222,6 +1223,17 @@ gdbpy_is_value_object (PyObject *obj) return PyObject_TypeCheck (obj, &value_object_type); } @@ -5945,7 +7584,7 @@ index adb7658..1e1f7e9 100644 void gdbpy_initialize_values (void) { -@@ -1230,6 +1242,8 @@ gdbpy_initialize_values (void) +@@ -1232,6 +1244,8 @@ gdbpy_initialize_values (void) PyModule_AddObject (gdb_module, "Value", (PyObject *) &value_object_type); values_in_python = NULL; @@ -5954,8 +7593,175 @@ index adb7658..1e1f7e9 100644 } +diff --git a/gdb/python/python-internal.h b/gdb/python/python-internal.h +index 80d0763..0040403 100644 +--- a/gdb/python/python-internal.h ++++ b/gdb/python/python-internal.h +@@ -88,10 +88,11 @@ struct language_defn; + struct program_space; + + extern PyObject *gdb_module; +-extern PyTypeObject value_object_type; + extern PyTypeObject block_object_type; ++extern PyTypeObject value_object_type; + extern PyTypeObject symbol_object_type; + ++/* Used in python-inferior.c. */ + typedef struct + { + PyObject_HEAD +@@ -133,6 +134,10 @@ PyObject *block_to_block_object (struct block *block, struct objfile *objfile); + PyObject *value_to_value_object (struct value *v); + PyObject *type_to_type_object (struct type *); + PyObject *frame_info_to_frame_object (struct frame_info *frame); ++PyObject *frame_info_to_frame_object (struct frame_info *frame); ++thread_object *create_thread_object (struct thread_info *tp); ++thread_object *find_thread_object (ptid_t ptid); ++PyObject *find_inferior_object (int pid); + + PyObject *pspace_to_pspace_object (struct program_space *); + PyObject *pspy_get_printers (PyObject *, void *); +@@ -153,7 +158,9 @@ struct symtab *symtab_object_to_symtab (PyObject *obj); + struct symtab_and_line *sal_object_to_symtab_and_line (PyObject *obj); + + void gdbpy_initialize_auto_load (void); ++ + void gdbpy_initialize_values (void); ++void gdbpy_initialize_breakpoints (void); + void gdbpy_initialize_frames (void); + void gdbpy_initialize_symtabs (void); + void gdbpy_initialize_commands (void); +@@ -161,6 +168,7 @@ void gdbpy_initialize_symbols (void); + void gdbpy_initialize_symtabs (void); + void gdbpy_initialize_blocks (void); + void gdbpy_initialize_types (void); ++void gdbpy_initialize_blocks (void); + void gdbpy_initialize_functions (void); + void gdbpy_initialize_pspace (void); + void gdbpy_initialize_objfile (void); +@@ -178,6 +186,12 @@ struct cleanup *ensure_python_env (struct gdbarch *gdbarch, + extern struct gdbarch *python_gdbarch; + extern const struct language_defn *python_language; + ++char *gdbpy_parse_command_name (char *text, ++ struct cmd_list_element ***base_list, ++ struct cmd_list_element **start_list); ++ ++PyObject *gdbpy_parameter_value (enum var_types, void *); ++ + /* Use this after a TRY_EXCEPT to throw the appropriate Python + exception. */ + #define GDB_PY_HANDLE_EXCEPTION(Exception) \ +@@ -225,13 +239,14 @@ PyObject *apply_varobj_pretty_printer (PyObject *print_obj, + struct value **replacement, + struct ui_file *stream); + PyObject *gdbpy_get_varobj_pretty_printer (struct value *value); ++PyObject *gdbpy_instantiate_printer (PyObject *cons, PyObject *value); + char *gdbpy_get_display_hint (PyObject *printer); + PyObject *gdbpy_default_visualizer (PyObject *self, PyObject *args); + +-extern PyObject *gdbpy_doc_cst; + extern PyObject *gdbpy_children_cst; + extern PyObject *gdbpy_to_string_cst; + extern PyObject *gdbpy_display_hint_cst; ++extern PyObject *gdbpy_doc_cst; + extern PyObject *gdbpy_enabled_cst; + + /* Exception types. */ +diff --git a/gdb/python/python.c b/gdb/python/python.c +index 375042c..b6af645 100644 +--- a/gdb/python/python.c ++++ b/gdb/python/python.c +@@ -49,8 +49,11 @@ static int gdbpy_should_print_stack = 1; + #include "linespec.h" + #include "source.h" + #include "version.h" ++#include "inferior.h" ++#include "gdbthread.h" + #include "target.h" + #include "gdbthread.h" ++#include "event-top.h" + + static PyMethodDef GdbMethods[]; + +@@ -728,6 +731,53 @@ gdbpy_print_stack (void) + + /* Return the current Progspace. + There always is one. */ ++/* True if 'gdb -P' was used, false otherwise. */ ++static int running_python_script; ++ ++/* True if we are currently in a call to 'gdb.cli', false otherwise. */ ++static int in_cli; ++ ++/* Enter the command loop. */ ++ ++static PyObject * ++gdbpy_cli (PyObject *unused1, PyObject *unused2) ++{ ++ if (! running_python_script || in_cli) ++ return PyErr_Format (PyExc_RuntimeError, "cannot invoke CLI recursively"); ++ ++ in_cli = 1; ++ cli_command_loop (); ++ in_cli = 0; ++ ++ Py_RETURN_NONE; ++} ++ ++/* Set up the Python argument vector and evaluate a script. This is ++ used to implement 'gdb -P'. */ ++ ++void ++run_python_script (int argc, char **argv) ++{ ++ FILE *input; ++ ++ /* We never free this, since we plan to exit at the end. */ ++ ensure_python_env (get_current_arch (), current_language); ++ ++ running_python_script = 1; ++ PySys_SetArgv (argc - 1, argv + 1); ++ input = fopen (argv[0], "r"); ++ if (! input) ++ { ++ fprintf (stderr, "could not open %s: %s\n", argv[0], strerror (errno)); ++ exit (1); ++ } ++ PyRun_SimpleFile (input, argv[0]); ++ fclose (input); ++ exit (0); ++} ++ ++ ++ + + static PyObject * + gdbpy_get_current_progspace (PyObject *unused1, PyObject *unused2) +@@ -1102,6 +1152,8 @@ static PyMethodDef GdbMethods[] = + "Get a value from history" }, + { "execute", (PyCFunction) execute_gdb_command, METH_VARARGS | METH_KEYWORDS, + "Execute a gdb command" }, ++ { "cli", gdbpy_cli, METH_NOARGS, ++ "Enter the gdb CLI" }, + { "parameter", gdbpy_parameter, METH_VARARGS, + "Return a gdb parameter's value" }, + +diff --git a/gdb/python/python.h b/gdb/python/python.h +index 58d97fc..93d56ef 100644 +--- a/gdb/python/python.h ++++ b/gdb/python/python.h +@@ -30,6 +30,8 @@ void eval_python_from_control_command (struct command_line *); + + void source_python_script (FILE *stream, const char *file); + ++void run_python_script (int argc, char **argv); ++ + int apply_val_pretty_printer (struct type *type, const gdb_byte *valaddr, + int embedded_offset, CORE_ADDR address, + struct ui_file *stream, int recurse, diff --git a/gdb/solib-svr4.c b/gdb/solib-svr4.c -index ef04dd7..512b6e4 100644 +index d45cd92..f6955e9 100644 --- a/gdb/solib-svr4.c +++ b/gdb/solib-svr4.c @@ -1276,7 +1276,8 @@ svr4_in_dynsym_resolve_code (CORE_ADDR pc) @@ -5969,7 +7775,7 @@ index ef04dd7..512b6e4 100644 /* Given an executable's ABFD and target, compute the entry-point diff --git a/gdb/stack.c b/gdb/stack.c -index 1d23806..c20df41 100644 +index 4fc634f..f6df7ee 100644 --- a/gdb/stack.c +++ b/gdb/stack.c @@ -366,6 +366,7 @@ print_frame_args (struct symbol *func, struct frame_info *frame, @@ -5995,7 +7801,7 @@ index 1d23806..c20df41 100644 } else diff --git a/gdb/symmisc.c b/gdb/symmisc.c -index b292c3b..4db6629 100644 +index 7f2d38a..7d3589e 100644 --- a/gdb/symmisc.c +++ b/gdb/symmisc.c @@ -264,6 +264,9 @@ dump_msymbols (struct objfile *objfile, struct ui_file *outfile) @@ -6009,10 +7815,10 @@ index b292c3b..4db6629 100644 ms_type = 'S'; break; diff --git a/gdb/symtab.c b/gdb/symtab.c -index 4e68f1b..e6e91ba 100644 +index bdf34d6..fe2dc4c 100644 --- a/gdb/symtab.c +++ b/gdb/symtab.c -@@ -2988,7 +2988,7 @@ search_symbols (char *regexp, domain_enum kind, int nfiles, char *files[], +@@ -3000,7 +3000,7 @@ search_symbols (char *regexp, domain_enum kind, int nfiles, char *files[], static const enum minimal_symbol_type types3[] = {mst_file_data, mst_solib_trampoline, mst_abs, mst_unknown}; static const enum minimal_symbol_type types4[] @@ -6022,7 +7828,7 @@ index 4e68f1b..e6e91ba 100644 enum minimal_symbol_type ourtype2; enum minimal_symbol_type ourtype3; diff --git a/gdb/symtab.h b/gdb/symtab.h -index e85b432..6d97d6e 100644 +index 6864b96..651bd67 100644 --- a/gdb/symtab.h +++ b/gdb/symtab.h @@ -290,6 +290,9 @@ enum minimal_symbol_type @@ -6035,7 +7841,7 @@ index e85b432..6d97d6e 100644 mst_data, /* Generally initialized data */ mst_bss, /* Generally uninitialized data */ mst_abs, /* Generally absolute (nonrelocatable) */ -@@ -955,11 +958,25 @@ extern struct symbol *find_pc_sect_function (CORE_ADDR, struct obj_section *); +@@ -956,11 +959,25 @@ extern struct symbol *find_pc_sect_function (CORE_ADDR, struct obj_section *); /* lookup function from address, return name, start addr and end addr */ @@ -6063,7 +7869,7 @@ index e85b432..6d97d6e 100644 /* lookup partial symbol table by address and section */ extern struct symtab *find_pc_sect_symtab_via_partial (CORE_ADDR, -@@ -1034,6 +1051,8 @@ extern struct minimal_symbol *lookup_minimal_symbol_by_pc_name +@@ -1035,6 +1052,8 @@ extern struct minimal_symbol *lookup_minimal_symbol_by_pc_name extern struct minimal_symbol *lookup_minimal_symbol_by_pc (CORE_ADDR); @@ -6072,6 +7878,29 @@ index e85b432..6d97d6e 100644 extern struct minimal_symbol * lookup_minimal_symbol_and_objfile (const char *, struct objfile **); +diff --git a/gdb/target.h b/gdb/target.h +index c34625c..d4fcbfc 100644 +--- a/gdb/target.h ++++ b/gdb/target.h +@@ -1372,6 +1372,18 @@ extern int target_search_memory (CORE_ADDR start_addr, + ULONGEST pattern_len, + CORE_ADDR *found_addrp); + ++/* Utility functions which can be used by search_memory implementations. */ ++ ++void allocate_pattern_buffer (char **pattern_bufp, char **pattern_buf_end, ++ ULONGEST *pattern_buf_size); ++ ++void increase_pattern_buffer (char **pattern_bufp, char **pattern_buf_end, ++ ULONGEST *pattern_buf_size, int val_bytes); ++ ++int search_memory (CORE_ADDR *start_addr, ULONGEST *search_space_len, ++ const char *pattern_buf, ULONGEST pattern_len, ++ CORE_ADDR *found_addr); ++ + /* Tracepoint-related operations. */ + + #define target_trace_init() \ diff --git a/gdb/testsuite/gdb.arch/x86_64-vla-pointer-foo.S b/gdb/testsuite/gdb.arch/x86_64-vla-pointer-foo.S new file mode 100644 index 0000000..83faaf6 @@ -9047,6 +10876,21 @@ index 0000000..226dc5d + h = 'h' + call foo (g, h) +end +diff --git a/gdb/testsuite/gdb.gdb/selftest.exp b/gdb/testsuite/gdb.gdb/selftest.exp +index 30a71dd..4bb8e7d 100644 +--- a/gdb/testsuite/gdb.gdb/selftest.exp ++++ b/gdb/testsuite/gdb.gdb/selftest.exp +@@ -92,6 +92,10 @@ proc do_steps_and_nexts {} { + set description "step over ttyarg initialization" + set command "step" + } ++ -re ".*python_script = 0.*$gdb_prompt $" { ++ set description "step over python_script initialization" ++ set command "step" ++ } + -re ".*pre_stat_chain = make_command_stats_cleanup.*$gdb_prompt $" { + set description "next over make_command_stats_cleanup and everything it calls" + set command "next" diff --git a/gdb/testsuite/gdb.multi/watchpoint-multi.c b/gdb/testsuite/gdb.multi/watchpoint-multi.c new file mode 100644 index 0000000..153c18b @@ -9609,6 +11453,124 @@ index 0000000..295602d + s := 'test'#0'string'; + writeln(s); { set breakpoint 2 here } +end. +diff --git a/gdb/testsuite/gdb.python/py-cmd.exp b/gdb/testsuite/gdb.python/py-cmd.exp +index 66d3e53..0ee5f63 100644 +--- a/gdb/testsuite/gdb.python/py-cmd.exp ++++ b/gdb/testsuite/gdb.python/py-cmd.exp +@@ -20,24 +20,6 @@ if $tracelevel then { + strace $tracelevel + } + +-# Usage: gdb_py_test_multiple NAME INPUT RESULT {INPUT RESULT}... +-# Run a test named NAME, consisting of multiple lines of input. +-# After each input line INPUT, search for result line RESULT. +-# Succeed if all results are seen; fail otherwise. +-proc gdb_py_test_multiple {name args} { +- global gdb_prompt +- foreach {input result} $args { +- if {[gdb_test_multiple $input "$name - $input" { +- -re "\[\r\n\]*($result)\[\r\n\]+($gdb_prompt | *>)$" { +- pass "$name - $input" +- } +- }]} { +- return 1 +- } +- } +- return 0 +-} +- + # Start with a fresh gdb. + + gdb_exit +diff --git a/gdb/testsuite/gdb.python/py-frame.exp b/gdb/testsuite/gdb.python/py-frame.exp +index e3b5629..2a63d8d 100644 +--- a/gdb/testsuite/gdb.python/py-frame.exp ++++ b/gdb/testsuite/gdb.python/py-frame.exp +@@ -87,8 +87,6 @@ gdb_test "python print bframe == gdb.newest_frame()" True \ + + gdb_test "python print 'result =', f0 == f1" " = False" "test equality comparison (false)" + gdb_test "python print 'result =', f0 == f0" " = True" "test equality comparison (true)" +-gdb_test "python print 'result =', f0 != f1" " = True" "test inequality comparison (true)" +-gdb_test "python print 'result =', f0 != f0" " = False" "test inequality comparison (false)" + gdb_test "python print 'result =', f0.is_valid ()" " = True" "test Frame.is_valid" + gdb_test "python print 'result =', f0.name ()" " = f2" "test Frame.name" + gdb_test "python print 'result =', f0.type () == gdb.NORMAL_FRAME" " = True" "test Frame.type" +@@ -103,3 +101,5 @@ gdb_test "python print 'result =', f0.read_var ('variable_which_surely_doesnt_ex + gdb_test "python print 'result =', f0.read_var ('a')" " = 1" "test Frame.read_var - success" + + gdb_test "python print 'result =', gdb.selected_frame () == f1" " = True" "test gdb.selected_frame" ++ ++gdb_test "python print 'result =', f0.block ()" "" "test Frame.block" +diff --git a/gdb/testsuite/gdb.python/py-function.exp b/gdb/testsuite/gdb.python/py-function.exp +index a5c8025..8a5dcda 100644 +--- a/gdb/testsuite/gdb.python/py-function.exp ++++ b/gdb/testsuite/gdb.python/py-function.exp +@@ -20,24 +20,6 @@ if $tracelevel then { + strace $tracelevel + } + +-# Usage: gdb_py_test_multiple NAME INPUT RESULT {INPUT RESULT}... +-# Run a test named NAME, consisting of multiple lines of input. +-# After each input line INPUT, search for result line RESULT. +-# Succeed if all results are seen; fail otherwise. +-proc gdb_py_test_multiple {name args} { +- global gdb_prompt +- foreach {input result} $args { +- if {[gdb_test_multiple $input "$name - $input" { +- -re "\[\r\n\]*($result)\[\r\n\]+($gdb_prompt | *>)$" { +- pass "$name - $input" +- } +- }]} { +- return 1 +- } +- } +- return 0 +-} +- + # Start with a fresh gdb. + + gdb_exit +diff --git a/gdb/testsuite/gdb.python/py-prettyprint.exp b/gdb/testsuite/gdb.python/py-prettyprint.exp +index e4a6c38..09ac065 100644 +--- a/gdb/testsuite/gdb.python/py-prettyprint.exp ++++ b/gdb/testsuite/gdb.python/py-prettyprint.exp +@@ -99,6 +99,8 @@ proc run_lang_tests {lang} { + + gdb_test "print c" " = container \"container\" with 2 elements = {$nl *.0. = 23,$nl *.1. = 72$nl}" + ++ gdb_test "print nullstr" "RuntimeError: Error reading string from inferior.*" ++ + gdb_test "print nstype" " = {$nl *.0. = 7,$nl *.1. = 42$nl}" + gdb_test "continue" "Program exited normally\." + +diff --git a/gdb/testsuite/gdb.python/py-value.exp b/gdb/testsuite/gdb.python/py-value.exp +index e012d53..1bd9e53 100644 +--- a/gdb/testsuite/gdb.python/py-value.exp ++++ b/gdb/testsuite/gdb.python/py-value.exp +@@ -318,6 +318,15 @@ proc test_value_after_death {} { + "print value's type" + } + ++# Regression test for a cast failure. The bug was that if we cast a ++# value to its own type, gdb could crash. This happened because we ++# could end up double-freeing a struct value. ++proc test_cast_regression {} { ++ gdb_test "python v = gdb.Value(5)" "" "create value for cast test" ++ gdb_test "python v = v.cast(v.type)" "" "cast value for cast test" ++ gdb_test "python print v" "5" "print value for cast test" ++} ++ + # Regression test for invalid subscript operations. The bug was that + # the type of the value was not being checked before allowing a + # subscript operation to proceed. +@@ -455,6 +464,7 @@ test_value_in_inferior + test_inferior_function_call + test_lazy_strings + test_value_after_death ++test_cast_regression + + # The following test recompiles the binary to test either C or C++ + # values. diff --git a/gdb/testsuite/gdb.threads/watchpoint-fork-child.c b/gdb/testsuite/gdb.threads/watchpoint-fork-child.c new file mode 100644 index 0000000..a2ad29a @@ -10262,6 +12224,18 @@ index 0000000..31f7656 + +extern void marker (void); +extern void forkoff (int nr); +diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp +index 5a3f1fc..62466f8 100644 +--- a/gdb/testsuite/lib/gdb.exp ++++ b/gdb/testsuite/lib/gdb.exp +@@ -28,6 +28,7 @@ if {$tool == ""} { + } + + load_lib libgloss.exp ++load_lib python-support.exp + + global GDB + diff --git a/gdb/testsuite/lib/pascal.exp b/gdb/testsuite/lib/pascal.exp index 891da37..236c5ca 100644 --- a/gdb/testsuite/lib/pascal.exp @@ -10297,8 +12271,67 @@ index 891da37..236c5ca 100644 } set pascal_init_done 1 } +diff --git a/gdb/testsuite/lib/python-support.exp b/gdb/testsuite/lib/python-support.exp +new file mode 100644 +index 0000000..b8e9836 +--- /dev/null ++++ b/gdb/testsuite/lib/python-support.exp +@@ -0,0 +1,53 @@ ++global python_supported_saved ++ ++# Return 1 if Python scripting is supported in GDB, 0 if not. ++proc python_supported { } { ++ global gdb_prompt ++ global python_supported_saved ++ ++ if [info exists python_supported_saved] { ++ verbose "python_supported: returning saved $python_supported_saved" 2 ++ return $python_supported_saved ++ } ++ ++ gdb_test_multiple "python print 'hello, world!'" "verify python support" { ++ -re "not supported.*$gdb_prompt $" { ++ return [set python_supported_saved 0] ++ } ++ -re "$gdb_prompt $" { ++ return [set python_supported_saved 1] ++ } ++ } ++ ++ return [set python_supported_saved 0] ++} ++ ++# Run a command in GDB, and report a failure if a Python exception is thrown. ++# If report_pass is true, report a pass if no exception is thrown. ++proc gdb_py_test_silent_cmd {cmd name report_pass} { ++ global gdb_prompt ++ ++ gdb_test_multiple $cmd $name { ++ -re "Traceback.*$gdb_prompt $" { fail $name } ++ -re "$gdb_prompt $" { if $report_pass { pass $name } } ++ } ++} ++ ++# 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 ++} diff --git a/gdb/top.c b/gdb/top.c -index 702e05b..a41cdc6 100644 +index e0feba5..e8981dd 100644 --- a/gdb/top.c +++ b/gdb/top.c @@ -343,6 +343,7 @@ void @@ -10367,10 +12400,10 @@ index a1c44f2..036d939 100644 static void diff --git a/gdb/utils.c b/gdb/utils.c -index 2b55449..6b481cd 100644 +index 985f219..ccb068e 100644 --- a/gdb/utils.c +++ b/gdb/utils.c -@@ -2198,6 +2198,36 @@ set_batch_flag_and_make_cleanup_restore_page_info (void) +@@ -2206,6 +2206,36 @@ set_batch_flag_and_make_cleanup_restore_page_info (void) return back_to; } @@ -10408,7 +12441,7 @@ index 2b55449..6b481cd 100644 static void diff --git a/gdb/valarith.c b/gdb/valarith.c -index f200b2c..4921b54 100644 +index 18e88b7..9f90acb 100644 --- a/gdb/valarith.c +++ b/gdb/valarith.c @@ -165,12 +165,26 @@ value_subscript (struct value *array, LONGEST index) @@ -10502,7 +12535,7 @@ index f200b2c..4921b54 100644 } diff --git a/gdb/valops.c b/gdb/valops.c -index c66c41e..8d76259 100644 +index fdbb702..f93f94a 100644 --- a/gdb/valops.c +++ b/gdb/valops.c @@ -38,6 +38,7 @@ @@ -10513,7 +12546,7 @@ index c66c41e..8d76259 100644 #include #include "gdb_string.h" -@@ -901,6 +902,65 @@ value_one (struct type *type, enum lval_type lv) +@@ -907,6 +908,65 @@ value_one (struct type *type, enum lval_type lv) return val; } @@ -10579,7 +12612,7 @@ index c66c41e..8d76259 100644 /* Helper function for value_at, value_at_lazy, and value_at_lazy_stack. */ static struct value * -@@ -999,15 +1059,21 @@ value_fetch_lazy (struct value *val) +@@ -1005,15 +1065,21 @@ value_fetch_lazy (struct value *val) } else if (VALUE_LVAL (val) == lval_memory) { @@ -10608,7 +12641,7 @@ index c66c41e..8d76259 100644 } } else if (VALUE_LVAL (val) == lval_register) -@@ -1418,7 +1484,18 @@ address_of_variable (struct symbol *var, struct block *b) +@@ -1427,7 +1493,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) { @@ -10628,7 +12661,7 @@ index c66c41e..8d76259 100644 return value_from_pointer (lookup_pointer_type (type), addr); } -@@ -1526,6 +1603,7 @@ struct value * +@@ -1535,6 +1612,7 @@ struct value * value_coerce_array (struct value *arg1) { struct type *type = check_typedef (value_type (arg1)); @@ -10636,7 +12669,7 @@ index c66c41e..8d76259 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 -@@ -1535,8 +1613,12 @@ value_coerce_array (struct value *arg1) +@@ -1544,8 +1622,12 @@ value_coerce_array (struct value *arg1) if (VALUE_LVAL (arg1) != lval_memory) error (_("Attempt to take address of value not located in memory.")); @@ -10651,7 +12684,7 @@ index c66c41e..8d76259 100644 /* Given a value which is a function, return a value which is a pointer diff --git a/gdb/valprint.c b/gdb/valprint.c -index 1b16f1f..eef7d61 100644 +index d78df5c..e4fe7f9 100644 --- a/gdb/valprint.c +++ b/gdb/valprint.c @@ -36,6 +36,7 @@ @@ -10662,7 +12695,7 @@ index 1b16f1f..eef7d61 100644 #include -@@ -237,7 +238,6 @@ scalar_type_p (struct type *type) +@@ -239,7 +240,6 @@ scalar_type_p (struct type *type) case TYPE_CODE_STRUCT: case TYPE_CODE_UNION: case TYPE_CODE_SET: @@ -10670,7 +12703,7 @@ index 1b16f1f..eef7d61 100644 case TYPE_CODE_BITSTRING: return 0; default: -@@ -1111,6 +1111,7 @@ val_print_array_elements (struct type *type, const gdb_byte *valaddr, +@@ -1115,6 +1115,7 @@ val_print_array_elements (struct type *type, const gdb_byte *valaddr, { unsigned int things_printed = 0; unsigned len; @@ -10678,7 +12711,7 @@ index 1b16f1f..eef7d61 100644 struct type *elttype, *index_type; unsigned eltlen; /* Position of the array element we are examining to see -@@ -1119,9 +1120,33 @@ val_print_array_elements (struct type *type, const gdb_byte *valaddr, +@@ -1123,9 +1124,33 @@ val_print_array_elements (struct type *type, const gdb_byte *valaddr, /* Number of repetitions we have detected so far. */ unsigned int reps; LONGEST low_bound, high_bound; @@ -10714,7 +12747,7 @@ index 1b16f1f..eef7d61 100644 index_type = TYPE_INDEX_TYPE (type); if (get_array_bounds (type, &low_bound, &high_bound)) -@@ -1196,6 +1221,8 @@ val_print_array_elements (struct type *type, const gdb_byte *valaddr, +@@ -1200,6 +1225,8 @@ val_print_array_elements (struct type *type, const gdb_byte *valaddr, { fprintf_filtered (stream, "..."); } @@ -10724,7 +12757,7 @@ index 1b16f1f..eef7d61 100644 /* Read LEN bytes of target memory at address MEMADDR, placing the diff --git a/gdb/value.c b/gdb/value.c -index 58067e8..82efef0 100644 +index 1c50428..9b1b438 100644 --- a/gdb/value.c +++ b/gdb/value.c @@ -39,6 +39,7 @@ @@ -10764,7 +12797,7 @@ index 58067e8..82efef0 100644 } -@@ -1009,6 +1019,29 @@ show_values (char *num_exp, int from_tty) +@@ -1010,6 +1020,29 @@ show_values (char *num_exp, int from_tty) num_exp[1] = '\0'; } } @@ -10794,7 +12827,7 @@ index 58067e8..82efef0 100644 /* Internal variables. These are variables within the debugger that hold values assigned by debugger commands. -@@ -1503,6 +1536,40 @@ call_internal_function (struct gdbarch *gdbarch, +@@ -1505,6 +1538,40 @@ call_internal_function (struct gdbarch *gdbarch, return (*ifn->handler) (gdbarch, language, ifn->cookie, argc, argv); } @@ -10835,7 +12868,7 @@ index 58067e8..82efef0 100644 /* The 'function' command. This does nothing -- it is just a placeholder to let "help function NAME" work. This is also used as the implementation of the sub-command that is created when -@@ -1550,11 +1617,10 @@ preserve_one_value (struct value *value, struct objfile *objfile, +@@ -1552,11 +1619,10 @@ preserve_one_value (struct value *value, struct objfile *objfile, htab_t copied_types) { if (TYPE_OBJFILE (value->type) == objfile) @@ -10849,7 +12882,7 @@ index 58067e8..82efef0 100644 copied_types); } -@@ -1569,13 +1635,13 @@ preserve_one_internalvar (struct internalvar *var, struct objfile *objfile, +@@ -1571,13 +1637,13 @@ preserve_one_internalvar (struct internalvar *var, struct objfile *objfile, case INTERNALVAR_INTEGER: if (var->u.integer.type && TYPE_OBJFILE (var->u.integer.type) == objfile) var->u.integer.type @@ -10865,7 +12898,7 @@ index 58067e8..82efef0 100644 break; case INTERNALVAR_VALUE: -@@ -2438,7 +2504,24 @@ value_from_decfloat (struct type *type, const gdb_byte *dec) +@@ -2442,7 +2508,24 @@ value_from_decfloat (struct type *type, const gdb_byte *dec) struct value * coerce_ref (struct value *arg) { @@ -10891,7 +12924,7 @@ index 58067e8..82efef0 100644 if (TYPE_CODE (value_type_arg_tmp) == TYPE_CODE_REF) arg = value_at_lazy (TYPE_TARGET_TYPE (value_type_arg_tmp), -@@ -2536,4 +2619,8 @@ VARIABLE is already initialized.")); +@@ -2540,4 +2623,8 @@ VARIABLE is already initialized.")); add_prefix_cmd ("function", no_class, function_command, _("\ Placeholder command for showing help on convenience functions."), &functionlist, "function ", 0, &cmdlist); @@ -10924,16 +12957,3 @@ index e637842..5f36aef 100644 /* User function handler. */ -diff --git a/gdb/varobj.c b/gdb/varobj.c -index d020fff..303ecdf 100644 ---- a/gdb/varobj.c -+++ b/gdb/varobj.c -@@ -26,6 +26,8 @@ - #include "gdbcmd.h" - #include "block.h" - #include "valprint.h" -+#include "objfiles.h" -+#include "parser-defs.h" - - #include "gdb_assert.h" - #include "gdb_string.h" diff --git a/gdb-fortran-common-reduce.patch b/gdb-fortran-common-reduce.patch index 3b843b8..2df3d3b 100644 --- a/gdb-fortran-common-reduce.patch +++ b/gdb-fortran-common-reduce.patch @@ -1,8 +1,8 @@ -Index: gdb-7.1.90.20100711/gdb/f-lang.c +Index: gdb-7.2.50.20110107/gdb/f-lang.c =================================================================== ---- gdb-7.1.90.20100711.orig/gdb/f-lang.c 2010-06-03 00:41:55.000000000 +0200 -+++ gdb-7.1.90.20100711/gdb/f-lang.c 2010-07-13 00:24:04.000000000 +0200 -@@ -56,20 +56,6 @@ typedef struct saved_bf_symnum SAVED_BF, +--- gdb-7.2.50.20110107.orig/gdb/f-lang.c 2011-01-05 23:22:48.000000000 +0100 ++++ gdb-7.2.50.20110107/gdb/f-lang.c 2011-01-07 09:08:52.000000000 +0100 +@@ -57,20 +57,6 @@ typedef struct saved_bf_symnum SAVED_BF, /* Local functions */ extern void _initialize_f_language (void); @@ -23,7 +23,7 @@ Index: gdb-7.1.90.20100711/gdb/f-lang.c static void f_printchar (int c, struct type *type, struct ui_file * stream); static void f_emit_char (int c, struct type *type, -@@ -458,185 +444,7 @@ _initialize_f_language (void) +@@ -461,185 +447,7 @@ _initialize_f_language (void) add_language (&f_language_defn); } @@ -73,8 +73,8 @@ Index: gdb-7.1.90.20100711/gdb/f-lang.c -static SAVED_BF_PTR saved_bf_list = NULL; /* Ptr to (.bf,function) - list */ -static SAVED_BF_PTR saved_bf_list_end = NULL; /* Ptr to above list's end */ --static SAVED_BF_PTR current_head_bf_list = NULL; /* Current head of above list -- */ +-static SAVED_BF_PTR current_head_bf_list = NULL; /* Current head of +- above list. */ - -static SAVED_BF_PTR tmp_bf_ptr; /* Generic temporary for use - in macros */ @@ -209,7 +209,7 @@ Index: gdb-7.1.90.20100711/gdb/f-lang.c /* This routine finds the first encountred COMMON block named "name" that belongs to function funcname */ -@@ -659,193 +467,3 @@ find_common_for_function (char *name, ch +@@ -662,193 +470,3 @@ find_common_for_function (char *name, ch } return (NULL); } @@ -403,10 +403,10 @@ Index: gdb-7.1.90.20100711/gdb/f-lang.c - saved_function_list = NULL; -} -#endif -Index: gdb-7.1.90.20100711/gdb/f-lang.h +Index: gdb-7.2.50.20110107/gdb/f-lang.h =================================================================== ---- gdb-7.1.90.20100711.orig/gdb/f-lang.h 2010-07-12 23:07:33.000000000 +0200 -+++ gdb-7.1.90.20100711/gdb/f-lang.h 2010-07-13 00:24:04.000000000 +0200 +--- gdb-7.2.50.20110107.orig/gdb/f-lang.h 2011-01-07 09:03:38.000000000 +0100 ++++ gdb-7.2.50.20110107/gdb/f-lang.h 2011-01-07 09:07:58.000000000 +0100 @@ -76,14 +76,9 @@ typedef struct saved_f77_common SAVED_F7 typedef struct common_entry COMMON_ENTRY, *COMMON_ENTRY_PTR; @@ -422,10 +422,10 @@ Index: gdb-7.1.90.20100711/gdb/f-lang.h #define BLANK_COMMON_NAME_ORIGINAL "#BLNK_COM" /* XLF assigned */ #define BLANK_COMMON_NAME_MF77 "__BLNK__" /* MF77 assigned */ #define BLANK_COMMON_NAME_LOCAL "__BLANK" /* Local GDB */ -Index: gdb-7.1.90.20100711/gdb/f-valprint.c +Index: gdb-7.2.50.20110107/gdb/f-valprint.c =================================================================== ---- gdb-7.1.90.20100711.orig/gdb/f-valprint.c 2010-07-12 23:07:33.000000000 +0200 -+++ gdb-7.1.90.20100711/gdb/f-valprint.c 2010-07-13 00:24:25.000000000 +0200 +--- gdb-7.2.50.20110107.orig/gdb/f-valprint.c 2011-01-07 09:03:38.000000000 +0100 ++++ gdb-7.2.50.20110107/gdb/f-valprint.c 2011-01-07 09:07:58.000000000 +0100 @@ -35,10 +35,6 @@ #include "command.h" #include "block.h" @@ -437,7 +437,7 @@ Index: gdb-7.1.90.20100711/gdb/f-valprint.c extern void _initialize_f_valprint (void); static void info_common_command (char *, int); static void list_all_visible_commons (char *); -@@ -601,67 +597,6 @@ info_common_command (char *comname, int +@@ -604,67 +600,6 @@ info_common_command (char *comname, int comname, funname); } diff --git a/gdb-test-pp-hint-error.patch b/gdb-test-pp-hint-error.patch index 68213a2..de7bdbf 100644 --- a/gdb-test-pp-hint-error.patch +++ b/gdb-test-pp-hint-error.patch @@ -27,8 +27,10 @@ gdb/testsuite/ * gdb.python/py-prettyprint.py (class pp_hint_error): New. (register_pretty_printers): Register it. ---- a/gdb/testsuite/gdb.python/py-prettyprint.c -+++ b/gdb/testsuite/gdb.python/py-prettyprint.c +Index: gdb-7.2.50.20110107/gdb/testsuite/gdb.python/py-prettyprint.c +=================================================================== +--- gdb-7.2.50.20110107.orig/gdb/testsuite/gdb.python/py-prettyprint.c 2011-01-01 16:33:49.000000000 +0100 ++++ gdb-7.2.50.20110107/gdb/testsuite/gdb.python/py-prettyprint.c 2011-01-07 09:11:18.000000000 +0100 @@ -44,6 +44,10 @@ struct lazystring { const char *lazy_str; }; @@ -48,8 +50,10 @@ gdb/testsuite/ nstype.elements = narray; nstype.len = 0; ---- a/gdb/testsuite/gdb.python/py-prettyprint.exp -+++ b/gdb/testsuite/gdb.python/py-prettyprint.exp +Index: gdb-7.2.50.20110107/gdb/testsuite/gdb.python/py-prettyprint.exp +=================================================================== +--- gdb-7.2.50.20110107.orig/gdb/testsuite/gdb.python/py-prettyprint.exp 2011-01-07 09:03:38.000000000 +0100 ++++ gdb-7.2.50.20110107/gdb/testsuite/gdb.python/py-prettyprint.exp 2011-01-07 09:11:32.000000000 +0100 @@ -97,6 +97,8 @@ proc run_lang_tests {lang} { gdb_test_no_output "python pp_ls_encoding = 'UTF-8'" gdb_test "print estring2" "\"embedded \", " @@ -58,9 +62,11 @@ gdb/testsuite/ + gdb_test "print c" " = container \"container\" with 2 elements = {$nl *.0. = 23,$nl *.1. = 72$nl}" - gdb_test "print nstype" " = {$nl *.0. = 7,$nl *.1. = 42$nl}" ---- a/gdb/testsuite/gdb.python/py-prettyprint.py -+++ b/gdb/testsuite/gdb.python/py-prettyprint.py + gdb_test "print nullstr" "RuntimeError: Error reading string from inferior.*" +Index: gdb-7.2.50.20110107/gdb/testsuite/gdb.python/py-prettyprint.py +=================================================================== +--- gdb-7.2.50.20110107.orig/gdb/testsuite/gdb.python/py-prettyprint.py 2011-01-01 16:33:49.000000000 +0100 ++++ gdb-7.2.50.20110107/gdb/testsuite/gdb.python/py-prettyprint.py 2011-01-07 09:11:18.000000000 +0100 @@ -156,6 +156,18 @@ class pp_ls: def display_hint (self): return 'string' @@ -90,4 +96,3 @@ gdb/testsuite/ pretty_printers_dict = {} register_pretty_printers () - diff --git a/gdb.spec b/gdb.spec index 4c9da4a..cbfa8bd 100644 --- a/gdb.spec +++ b/gdb.spec @@ -23,11 +23,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.2.50.20110104 +Version: 7.2.50.20110107 # 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: 7%{?_with_upstream:.upstream}%{dist} +Release: 8%{?_with_upstream:.upstream}%{dist} License: GPLv3+ and GPLv3+ with exceptions and GPLv2+ and GPLv2+ with exceptions and GPL+ and LGPLv2+ and GFDL and BSD and Public Domain Group: Development/Debuggers @@ -1132,6 +1132,10 @@ fi %endif %changelog +* Fri Jan 7 2011 Jan Kratochvil - 7.2.50.20110107-8.fc15 +- Rebase to FSF GDB 7.2.50.20110107 (which is a 7.3 pre-release). +- Import archer-tromey-python (BZ 666177, branch update by Phil Muldoon). + * Tue Jan 4 2011 Jan Kratochvil - 7.2.50.20110104-7.fc15 - Rebase to FSF GDB 7.2.50.20110104 (which is a 7.3 pre-release). - New testcase py-prettyprint.exp:print hint_error (for BZ 611569, BZ 629236). diff --git a/sources b/sources index 5e2a1c9..cc8115a 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -190e007189ea1522d34559f43ec40eed gdb-7.2.50.20110104.tar.bz2 +a409209e95cd717274431b2eaa77dac0 gdb-7.2.50.20110107.tar.bz2