+gdb_run_cmd
+
+gdb_test_multiple {} "Program exited" {
-+ -re "\r\nProgram exited normally.\r\n$gdb_prompt $" {
++ -re "\r\n\\\[Inferior .* exited normally\\\]\r\n$gdb_prompt $" {
+ pass "Program exited"
+ }
+}
https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=231832
-Index: gdb-6.8/gdb/symmisc.c
+Index: gdb-7.2.50.20101116/gdb/symmisc.c
===================================================================
---- gdb-6.8.orig/gdb/symmisc.c 2008-03-17 16:06:24.000000000 +0100
-+++ gdb-6.8/gdb/symmisc.c 2008-07-14 10:27:50.000000000 +0200
-@@ -230,8 +230,8 @@ print_objfile_statistics (void)
+--- gdb-7.2.50.20101116.orig/gdb/symmisc.c 2010-11-16 07:53:59.000000000 +0100
++++ gdb-7.2.50.20101116/gdb/symmisc.c 2010-11-16 08:03:08.000000000 +0100
+@@ -186,8 +186,8 @@ print_objfile_statistics (void)
if (OBJSTAT (objfile, sz_strtab) > 0)
printf_filtered (_(" Space used by a.out string tables: %d\n"),
OBJSTAT (objfile, sz_strtab));
+ printf_filtered (_(" Total memory used for objfile obstack: %ld\n"),
+ (long) obstack_memory_used (&objfile->objfile_obstack));
printf_filtered (_(" Total memory used for psymbol cache: %d\n"),
- bcache_memory_used (objfile->psymbol_cache));
- printf_filtered (_(" Total memory used for macro cache: %d\n"),
-Index: gdb-6.8/include/obstack.h
+ bcache_memory_used (psymbol_bcache_get_bcache
+ (objfile->psymbol_cache)));
+Index: gdb-7.2.50.20101116/include/obstack.h
===================================================================
---- gdb-6.8.orig/include/obstack.h 2005-05-10 12:21:08.000000000 +0200
-+++ gdb-6.8/include/obstack.h 2008-07-14 10:27:50.000000000 +0200
+--- gdb-7.2.50.20101116.orig/include/obstack.h 2008-10-21 01:03:31.000000000 +0200
++++ gdb-7.2.50.20101116/include/obstack.h 2010-11-16 08:02:37.000000000 +0100
@@ -188,31 +188,31 @@ struct obstack /* control current objec
/* Declare the external functions we use; they are in obstack.c. */
= (h)->temp + (char *) (h)->chunk) \
: (((obstack_free) ((h), (h)->temp + (char *) (h)->chunk), 0), 0)))
-Index: gdb-6.8/libiberty/obstack.c
+Index: gdb-7.2.50.20101116/libiberty/obstack.c
===================================================================
---- gdb-6.8.orig/libiberty/obstack.c 2005-05-10 17:33:33.000000000 +0200
-+++ gdb-6.8/libiberty/obstack.c 2008-07-14 10:27:50.000000000 +0200
+--- gdb-7.2.50.20101116.orig/libiberty/obstack.c 2005-05-10 17:33:33.000000000 +0200
++++ gdb-7.2.50.20101116/libiberty/obstack.c 2010-11-16 08:02:37.000000000 +0100
@@ -44,9 +44,11 @@
#if !defined (_LIBC) && defined (__GNU_LIBRARY__) && __GNU_LIBRARY__ > 1
#include <gnu-versions.h>
to install and uninstall.
* gstack.sh, gstack.1: New files.
-Index: gdb-7.2/gdb/Makefile.in
+Index: gdb-7.2.50.20101116/gdb/Makefile.in
===================================================================
---- gdb-7.2.orig/gdb/Makefile.in 2010-09-03 09:37:55.000000000 +0200
-+++ gdb-7.2/gdb/Makefile.in 2010-09-03 09:38:45.000000000 +0200
-@@ -1010,7 +1010,7 @@ install: all install-only
+--- gdb-7.2.50.20101116.orig/gdb/Makefile.in 2010-11-05 15:31:25.000000000 +0100
++++ gdb-7.2.50.20101116/gdb/Makefile.in 2010-11-16 07:56:10.000000000 +0100
+@@ -972,7 +972,7 @@ gdb.z:gdb.1
+ install: all
+ @$(MAKE) $(FLAGS_TO_PASS) install-only
- # The "install-only" target also installs the syscalls' XML files in
- # the system.
--install-only: $(CONFIG_INSTALL) xml-syscall-install
-+install-only: install-gstack $(CONFIG_INSTALL) xml-syscall-install
+-install-only: $(CONFIG_INSTALL)
++install-only: install-gstack $(CONFIG_INSTALL)
transformed_name=`t='$(program_transform_name)'; \
echo gdb | sed -e "$$t"` ; \
if test "x$$transformed_name" = x; then \
-@@ -1046,7 +1046,25 @@ install-tui:
+@@ -1008,7 +1008,25 @@ install-tui:
install-python:
$(SHELL) $(srcdir)/../mkinstalldirs $(DESTDIR)$(GDB_DATADIR)/python/gdb
transformed_name=`t='$(program_transform_name)'; \
echo gdb | sed -e $$t` ; \
if test "x$$transformed_name" = x; then \
-@@ -1068,6 +1086,17 @@ uninstall-tui:
+@@ -1030,6 +1048,17 @@ uninstall-tui:
fi ; \
rm -f $(DESTDIR)$(bindir)/$$transformed_name$(EXEEXT) \
$(DESTDIR)$(man1dir)/$$transformed_name.1
# The C++ name parser can be built standalone for testing.
test-cp-name-parser.o: cp-name-parser.c
-Index: gdb-7.2/gdb/gstack.sh
+Index: gdb-7.2.50.20101116/gdb/gstack.sh
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
-+++ gdb-7.2/gdb/gstack.sh 2010-09-03 09:38:12.000000000 +0200
++++ gdb-7.2.50.20101116/gdb/gstack.sh 2010-11-16 07:55:47.000000000 +0100
@@ -0,0 +1,48 @@
+#!/bin/sh
+
+ -e 's/^\((gdb) \)*//' \
+ -e '/^#/p' \
+ -e '/^Thread/p'
-Index: gdb-7.2/gdb/testsuite/gdb.base/gstack.exp
+Index: gdb-7.2.50.20101116/gdb/testsuite/gdb.base/gstack.exp
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
-+++ gdb-7.2/gdb/testsuite/gdb.base/gstack.exp 2010-09-03 09:38:12.000000000 +0200
++++ gdb-7.2.50.20101116/gdb/testsuite/gdb.base/gstack.exp 2010-11-16 07:55:47.000000000 +0100
@@ -0,0 +1,71 @@
+# Copyright (C) 2010 Free Software Foundation, Inc.
+
+gdb_exit
+
+remote_exec host "kill -9 $pid"
-Index: gdb-7.2/gdb/testsuite/gdb.base/gstack.c
+Index: gdb-7.2.50.20101116/gdb/testsuite/gdb.base/gstack.c
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
-+++ gdb-7.2/gdb/testsuite/gdb.base/gstack.c 2010-09-03 09:38:12.000000000 +0200
++++ gdb-7.2.50.20101116/gdb/testsuite/gdb.base/gstack.c 2010-11-16 07:55:47.000000000 +0100
@@ -0,0 +1,43 @@
+/* This testcase is part of GDB, the GNU debugger.
+
-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;
+ "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."),
* gdb.arch/ia64-sigill.c: New test.
* gdb.arch/ia64-sigill.exp: Ditto.
-Index: gdb-6.8.50.20081128/gdb/testsuite/gdb.arch/ia64-sigill.exp
+Index: gdb-7.2.50.20101231/gdb/testsuite/gdb.arch/ia64-sigill.exp
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
-+++ gdb-6.8.50.20081128/gdb/testsuite/gdb.arch/ia64-sigill.exp 2008-12-02 21:10:57.000000000 +0100
++++ gdb-7.2.50.20101231/gdb/testsuite/gdb.arch/ia64-sigill.exp 2011-01-01 00:55:04.000000000 +0100
@@ -0,0 +1,49 @@
+# Copyright 2005 Free Software Foundation, Inc.
+
+gdb_test "handle SIGILL nostop noprint" "SIGILL.*No.*No.*Yes.*" "handle sigill"
+gdb_test "run" "Starting program.*ia64-sigill.*\[New thread.*\].*hello world.*Program exited normally." "run to exit"
+
-Index: gdb-6.8.50.20081128/gdb/testsuite/gdb.arch/ia64-sigill.c
+Index: gdb-7.2.50.20101231/gdb/testsuite/gdb.arch/ia64-sigill.c
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
-+++ gdb-6.8.50.20081128/gdb/testsuite/gdb.arch/ia64-sigill.c 2008-12-02 21:10:57.000000000 +0100
++++ gdb-7.2.50.20101231/gdb/testsuite/gdb.arch/ia64-sigill.c 2011-01-01 00:55:04.000000000 +0100
@@ -0,0 +1,8 @@
+#include <stdio.h>
+
+ return 0;
+}
+
-Index: gdb-6.8.50.20081128/gdb/linux-nat.c
+Index: gdb-7.2.50.20101231/gdb/linux-nat.c
===================================================================
---- gdb-6.8.50.20081128.orig/gdb/linux-nat.c 2008-12-02 19:04:38.000000000 +0100
-+++ gdb-6.8.50.20081128/gdb/linux-nat.c 2008-12-02 21:11:11.000000000 +0100
-@@ -2974,7 +2974,8 @@ retry:
+--- gdb-7.2.50.20101231.orig/gdb/linux-nat.c 2011-01-01 00:54:04.000000000 +0100
++++ gdb-7.2.50.20101231/gdb/linux-nat.c 2011-01-01 00:55:58.000000000 +0100
+@@ -3652,7 +3652,8 @@ retry:
threads can be a bit time-consuming so if we want decent
performance with heavily multi-threaded programs, especially when
they're using a high frequency timer, we'd better avoid it if we
if (WIFSTOPPED (status))
{
-@@ -2992,7 +2993,9 @@ retry:
- && inf->stop_soon == NO_STOP_QUIETLY
+@@ -3670,7 +3671,9 @@ retry:
+ && inf->control.stop_soon == NO_STOP_QUIETLY
&& signal_stop_state (signo) == 0
&& signal_print_state (signo) == 0
- && signal_pass_state (signo) == 1)
* gdb.base/attach-32.exp: Fix forgotten $GDBFLAGS as set.
-Index: gdb-6.8.50.20081128/gdb/testsuite/gdb.base/attach-32.c
+Index: gdb-7.2.50.20110320/gdb/testsuite/gdb.base/attach-32.c
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
-+++ gdb-6.8.50.20081128/gdb/testsuite/gdb.base/attach-32.c 2008-12-07 10:06:03.000000000 +0100
++++ gdb-7.2.50.20110320/gdb/testsuite/gdb.base/attach-32.c 2011-03-20 20:15:57.000000000 +0100
@@ -0,0 +1,20 @@
+/* This program is intended to be started outside of gdb, and then
+ attached to by gdb. Thus, it simply spins in a loop. The loop
+ }
+ return 0;
+}
-Index: gdb-6.8.50.20081128/gdb/testsuite/gdb.base/attach-32.exp
+Index: gdb-7.2.50.20110320/gdb/testsuite/gdb.base/attach-32.exp
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
-+++ gdb-6.8.50.20081128/gdb/testsuite/gdb.base/attach-32.exp 2008-12-07 10:08:52.000000000 +0100
++++ gdb-7.2.50.20110320/gdb/testsuite/gdb.base/attach-32.exp 2011-03-20 20:20:03.000000000 +0100
@@ -0,0 +1,245 @@
+# Copyright 2005 Free Software Foundation, Inc.
+
+
+ # Allow the test process to exit, to cleanup after ourselves.
+
-+ gdb_test "continue" "Program exited normally." "after attach-32, exit"
++ gdb_test "continue" {\[Inferior .* exited normally\]} "after attach-32, exit"
+
+ # Make sure we don't leave a process around to confuse
+ # the next test run (and prevent the compile by keeping
+ # Get rid of the process
+
+ gdb_test "p should_exit = 1"
-+ gdb_test "c" "Program exited normally."
++ gdb_test "c" {\[Inferior .* exited normally\]}
+
+ # Be paranoid
+
+do_call_attach_tests
+
+return 0
-Index: gdb-6.8.50.20081128/gdb/testsuite/gdb.base/attach-32b.c
+Index: gdb-7.2.50.20110320/gdb/testsuite/gdb.base/attach-32b.c
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
-+++ gdb-6.8.50.20081128/gdb/testsuite/gdb.base/attach-32b.c 2008-12-07 10:06:03.000000000 +0100
++++ gdb-7.2.50.20110320/gdb/testsuite/gdb.base/attach-32b.c 2011-03-20 20:15:57.000000000 +0100
@@ -0,0 +1,24 @@
+/* This program is intended to be started outside of gdb, and then
+ attached to by gdb. Thus, it simply spins in a loop. The loop
use to skip over first half of a GNU/Linux syscall and update
"func_start".
-Index: gdb-6.8.50.20090802/gdb/rs6000-tdep.c
+Index: gdb-7.2.50.20110117/gdb/rs6000-tdep.c
===================================================================
---- gdb-6.8.50.20090802.orig/gdb/rs6000-tdep.c 2009-07-31 17:23:20.000000000 +0200
-+++ gdb-6.8.50.20090802/gdb/rs6000-tdep.c 2009-08-03 09:52:39.000000000 +0200
+--- gdb-7.2.50.20110117.orig/gdb/rs6000-tdep.c 2011-01-11 20:23:02.000000000 +0100
++++ gdb-7.2.50.20110117/gdb/rs6000-tdep.c 2011-01-17 15:48:19.000000000 +0100
@@ -126,6 +126,7 @@ static const char *powerpc_vector_abi_st
struct rs6000_framedata
int offset; /* total size of frame --- the distance
by which we decrement sp to allocate
the frame */
-@@ -1488,7 +1489,6 @@ static CORE_ADDR
+@@ -1496,7 +1497,6 @@ static CORE_ADDR
skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc, CORE_ADDR lim_pc,
struct rs6000_framedata *fdata)
{
CORE_ADDR last_prologue_pc = pc;
CORE_ADDR li_found_pc = 0;
gdb_byte buf[4];
-@@ -1506,12 +1506,14 @@ skip_prologue (struct gdbarch *gdbarch,
+@@ -1514,12 +1514,14 @@ skip_prologue (struct gdbarch *gdbarch,
int minimal_toc_loaded = 0;
int prev_insn_was_prologue_insn = 1;
int num_skip_non_prologue_insns = 0;
fdata->saved_gpr = -1;
fdata->saved_fpr = -1;
fdata->saved_vr = -1;
-@@ -1545,6 +1547,55 @@ skip_prologue (struct gdbarch *gdbarch,
+@@ -1553,6 +1555,55 @@ skip_prologue (struct gdbarch *gdbarch,
break;
op = extract_unsigned_integer (buf, 4, byte_order);
if ((op & 0xfc1fffff) == 0x7c0802a6)
{ /* mflr Rx */
/* Since shared library / PIC code, which needs to get its
-@@ -1726,9 +1777,9 @@ skip_prologue (struct gdbarch *gdbarch,
+@@ -1734,9 +1785,9 @@ skip_prologue (struct gdbarch *gdbarch,
we have no line table information or the line info tells
us that the subroutine call is not part of the line
associated with the prologue. */
+ struct symtab_and_line prologue_sal = find_pc_line (fdata->func_start, 0);
struct symtab_and_line this_sal = find_pc_line (pc, 0);
- if ((prologue_sal.line == 0) || (prologue_sal.line != this_sal.line))
+ if ((prologue_sal.line == 0)
* gdb.texinfo (File Options): Document --readnever.
-Index: gdb-7.1.90.20100721/gdb/doc/gdb.texinfo
+Index: gdb-7.2.90.20110411/gdb/doc/gdb.texinfo
===================================================================
---- gdb-7.1.90.20100721.orig/gdb/doc/gdb.texinfo 2010-07-23 20:58:52.000000000 +0200
-+++ gdb-7.1.90.20100721/gdb/doc/gdb.texinfo 2010-07-23 20:59:15.000000000 +0200
-@@ -998,6 +998,12 @@ Read each symbol file's entire symbol ta
+--- gdb-7.2.90.20110411.orig/gdb/doc/gdb.texinfo 2011-04-11 19:11:55.000000000 +0200
++++ gdb-7.2.90.20110411/gdb/doc/gdb.texinfo 2011-04-11 19:15:51.000000000 +0200
+@@ -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.
@end table
@node Mode Options
-Index: gdb-7.1.90.20100721/gdb/main.c
+Index: gdb-7.2.90.20110411/gdb/main.c
===================================================================
---- gdb-7.1.90.20100721.orig/gdb/main.c 2010-07-23 20:58:55.000000000 +0200
-+++ gdb-7.1.90.20100721/gdb/main.c 2010-07-23 20:59:15.000000000 +0200
-@@ -391,6 +391,7 @@ captured_main (void *data)
+--- gdb-7.2.90.20110411.orig/gdb/main.c 2011-04-11 19:11:56.000000000 +0200
++++ gdb-7.2.90.20110411/gdb/main.c 2011-04-11 19:15:51.000000000 +0200
+@@ -398,6 +398,7 @@ captured_main (void *data)
{"xdb", no_argument, &xdb_commands, 1},
{"dbx", no_argument, &dbx_commands, 1},
{"readnow", no_argument, &readnow_symbol_files, 1},
{"r", no_argument, &readnow_symbol_files, 1},
{"quiet", no_argument, &quiet, 1},
{"q", no_argument, &quiet, 1},
-@@ -1038,6 +1039,7 @@ Options:\n\n\
+@@ -1064,6 +1065,7 @@ Options:\n\n\
fputs_unfiltered (_("\
--quiet Do not print version number on startup.\n\
--readnow Fully read symbol files on first access.\n\
"), stream);
fputs_unfiltered (_("\
--se=FILE Use FILE as symbol file and executable file.\n\
-Index: gdb-7.1.90.20100721/gdb/symfile.c
+Index: gdb-7.2.90.20110411/gdb/symfile.c
===================================================================
---- gdb-7.1.90.20100721.orig/gdb/symfile.c 2010-07-23 20:58:52.000000000 +0200
-+++ gdb-7.1.90.20100721/gdb/symfile.c 2010-07-23 20:59:15.000000000 +0200
-@@ -80,6 +80,7 @@ static void clear_symtab_users_cleanup (
+--- gdb-7.2.90.20110411.orig/gdb/symfile.c 2011-03-23 19:23:55.000000000 +0100
++++ gdb-7.2.90.20110411/gdb/symfile.c 2011-04-11 19:15:51.000000000 +0200
+@@ -81,6 +81,7 @@ static void clear_symtab_users_cleanup (
- /* Global variables owned by this file */
- int readnow_symbol_files; /* Read full symbols immediately */
+ /* Global variables owned by this file. */
+ int readnow_symbol_files; /* Read full symbols immediately. */
+int readnever_symbol_files; /* Never read full symbols. */
- /* External variables and functions referenced. */
+ /* External variables and functions referenced. */
-Index: gdb-7.1.90.20100721/gdb/dwarf2read.c
+Index: gdb-7.2.90.20110411/gdb/dwarf2read.c
===================================================================
---- gdb-7.1.90.20100721.orig/gdb/dwarf2read.c 2010-07-23 20:58:53.000000000 +0200
-+++ gdb-7.1.90.20100721/gdb/dwarf2read.c 2010-07-23 20:59:26.000000000 +0200
-@@ -54,6 +54,7 @@
- #include "exceptions.h"
- #include "gdb_stat.h"
- #include "completer.h"
+--- gdb-7.2.90.20110411.orig/gdb/dwarf2read.c 2011-04-11 19:11:55.000000000 +0200
++++ gdb-7.2.90.20110411/gdb/dwarf2read.c 2011-04-11 19:16:01.000000000 +0200
+@@ -58,6 +58,7 @@
+ #include "c-lang.h"
+ #include "valprint.h"
+ #include <ctype.h>
+#include "top.h"
#include <fcntl.h>
#include "gdb_string.h"
-@@ -1283,8 +1284,9 @@ dwarf2_has_info (struct objfile *objfile
+@@ -1351,8 +1352,9 @@ dwarf2_has_info (struct objfile *objfile
bfd_map_over_sections (objfile->obfd, dwarf2_locate_sections, NULL);
dwarf2_per_objfile->objfile = objfile;
}
}
/* When loading sections, we can either look for ".<name>", or for
-Index: gdb-7.1.90.20100721/gdb/top.h
+Index: gdb-7.2.90.20110411/gdb/top.h
===================================================================
---- gdb-7.1.90.20100721.orig/gdb/top.h 2010-04-07 18:54:39.000000000 +0200
-+++ gdb-7.1.90.20100721/gdb/top.h 2010-07-23 20:59:15.000000000 +0200
+--- gdb-7.2.90.20110411.orig/gdb/top.h 2011-01-01 16:33:18.000000000 +0100
++++ gdb-7.2.90.20110411/gdb/top.h 2011-04-11 19:15:51.000000000 +0200
@@ -61,6 +61,7 @@ extern void set_prompt (char *);
/* From random places. */
extern int readnow_symbol_files;
+extern int readnever_symbol_files;
- /* Perform _initialize initialization */
+ /* Perform _initialize initialization. */
extern void gdb_init (char *);
(source_command): Update documentation. Check permissions if
FROM_TTY is -1.
-Index: gdb-7.1.90.20100720/gdb/cli/cli-cmds.c
+Index: gdb-7.2.50.20101231/gdb/cli/cli-cmds.c
===================================================================
---- gdb-7.1.90.20100720.orig/gdb/cli/cli-cmds.c 2010-05-17 21:28:12.000000000 +0200
-+++ gdb-7.1.90.20100720/gdb/cli/cli-cmds.c 2010-07-21 20:30:30.000000000 +0200
+--- gdb-7.2.50.20101231.orig/gdb/cli/cli-cmds.c 2010-12-29 03:11:04.000000000 +0100
++++ gdb-7.2.50.20101231/gdb/cli/cli-cmds.c 2011-01-01 00:53:51.000000000 +0100
@@ -39,6 +39,7 @@
#include "source.h"
#include "disasm.h"
#include "ui-out.h"
-@@ -487,7 +488,7 @@ Script filename extension recognition is
+@@ -488,7 +489,7 @@ Script filename extension recognition is
int
find_and_open_script (const char *script_file, int search_path,
{
char *file;
int fd;
-@@ -513,6 +514,32 @@ find_and_open_script (const char *script
+@@ -514,6 +515,32 @@ find_and_open_script (const char *script
return 0;
}
do_cleanups (old_cleanups);
*streamp = fdopen (fd, FOPEN_RT);
-@@ -572,13 +599,14 @@ source_script_with_search (const char *f
+@@ -573,13 +600,14 @@ source_script_with_search (const char *f
if (file == NULL || *file == 0)
error (_("source command requires file name of file to source."));
+ if (!find_and_open_script (file, search_path, &stream, &full_path,
+ from_tty))
{
- /* The script wasn't found, or was otherwise inaccessible.
- If the source command was invoked interactively, throw an error.
- Otherwise (e.g. if it was invoked by a script), silently ignore
- the error. */
+ /* The script wasn't found, or was otherwise inaccessible.
+ If the source command was invoked interactively, throw an
+ error. Otherwise (e.g. if it was invoked by a script),
+ silently ignore the error. */
- if (from_tty)
+ if (from_tty > 0)
perror_with_name (file);
else
return;
-Index: gdb-7.1.90.20100720/gdb/testsuite/gdb.base/gdbinit.exp
+Index: gdb-7.2.50.20101231/gdb/testsuite/gdb.base/gdbinit.exp
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
-+++ gdb-7.1.90.20100720/gdb/testsuite/gdb.base/gdbinit.exp 2010-07-20 22:25:40.000000000 +0200
++++ gdb-7.2.50.20101231/gdb/testsuite/gdb.base/gdbinit.exp 2011-01-01 00:53:09.000000000 +0100
@@ -0,0 +1,91 @@
+# Copyright 2005
+# Free Software Foundation, Inc.
+}
+
+remote_exec build "rm .gdbinit"
-Index: gdb-7.1.90.20100720/gdb/testsuite/gdb.base/gdbinit.sample
+Index: gdb-7.2.50.20101231/gdb/testsuite/gdb.base/gdbinit.sample
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
-+++ gdb-7.1.90.20100720/gdb/testsuite/gdb.base/gdbinit.sample 2010-07-20 22:25:40.000000000 +0200
++++ gdb-7.2.50.20101231/gdb/testsuite/gdb.base/gdbinit.sample 2011-01-01 00:53:09.000000000 +0100
@@ -0,0 +1 @@
+echo "\nin gdbinit"
-Index: gdb-7.1.90.20100720/gdb/main.c
+Index: gdb-7.2.50.20101231/gdb/main.c
===================================================================
---- gdb-7.1.90.20100720.orig/gdb/main.c 2010-06-26 08:44:47.000000000 +0200
-+++ gdb-7.1.90.20100720/gdb/main.c 2010-07-21 20:09:03.000000000 +0200
-@@ -794,7 +794,7 @@ Excess command line arguments ignored. (
+--- gdb-7.2.50.20101231.orig/gdb/main.c 2010-12-29 01:58:14.000000000 +0100
++++ gdb-7.2.50.20101231/gdb/main.c 2011-01-01 00:53:09.000000000 +0100
+@@ -805,7 +805,7 @@ Excess command line arguments ignored. (
debugging or what directory you are in. */
if (home_gdbinit && !inhibit_gdbinit)
/* Now perform all the actions indicated by the arguments. */
if (cdarg != NULL)
-@@ -868,7 +868,7 @@ Can't attach to process and specify a co
+@@ -880,7 +880,7 @@ Can't attach to process and specify a co
/* Read the .gdbinit file in the current directory, *if* it isn't
the same as the $HOME/.gdbinit file (it should exist, also). */
if (local_gdbinit && !inhibit_gdbinit)
/* Now that all .gdbinit's have been read and all -d options have been
processed, we can read any scripts mentioned in SYMARG.
-Index: gdb-7.1.90.20100720/gdb/python/py-auto-load.c
+Index: gdb-7.2.50.20101231/gdb/python/py-auto-load.c
===================================================================
---- gdb-7.1.90.20100720.orig/gdb/python/py-auto-load.c 2010-05-17 23:23:25.000000000 +0200
-+++ gdb-7.1.90.20100720/gdb/python/py-auto-load.c 2010-07-20 22:25:40.000000000 +0200
-@@ -219,7 +219,7 @@ source_section_scripts (struct objfile *
+--- gdb-7.2.50.20101231.orig/gdb/python/py-auto-load.c 2010-12-15 18:27:59.000000000 +0100
++++ gdb-7.2.50.20101231/gdb/python/py-auto-load.c 2011-01-01 00:53:09.000000000 +0100
+@@ -224,7 +224,7 @@ source_section_scripts (struct objfile *
}
opened = find_and_open_script (file, 1 /*search_path*/,
/* If the file is not found, we still record the file in the hash table,
we only want to print an error message once.
-Index: gdb-7.1.90.20100720/gdb/cli/cli-cmds.h
+Index: gdb-7.2.50.20101231/gdb/cli/cli-cmds.h
===================================================================
---- gdb-7.1.90.20100720.orig/gdb/cli/cli-cmds.h 2010-05-03 01:52:14.000000000 +0200
-+++ gdb-7.1.90.20100720/gdb/cli/cli-cmds.h 2010-07-20 22:25:40.000000000 +0200
+--- gdb-7.2.50.20101231.orig/gdb/cli/cli-cmds.h 2010-12-29 03:11:04.000000000 +0100
++++ gdb-7.2.50.20101231/gdb/cli/cli-cmds.h 2011-01-01 00:53:09.000000000 +0100
@@ -126,7 +126,8 @@ extern void source_script (char *, int);
/* Exported to objfiles.c. */
-Index: gdb-7.0.90.20100306/gdb/testsuite/configure.ac
+Index: gdb-7.2.50.20110320/gdb/testsuite/configure.ac
===================================================================
---- gdb-7.0.90.20100306.orig/gdb/testsuite/configure.ac 2010-02-19 20:16:36.000000000 +0100
-+++ gdb-7.0.90.20100306/gdb/testsuite/configure.ac 2010-03-06 23:19:56.000000000 +0100
-@@ -144,6 +144,6 @@ AC_OUTPUT([Makefile \
- gdb.cp/Makefile gdb.disasm/Makefile gdb.dwarf2/Makefile \
- gdb.fortran/Makefile gdb.server/Makefile gdb.java/Makefile \
+--- gdb-7.2.50.20110320.orig/gdb/testsuite/configure.ac 2011-03-03 17:57:55.000000000 +0100
++++ gdb-7.2.50.20110320/gdb/testsuite/configure.ac 2011-03-20 20:21:43.000000000 +0100
+@@ -97,6 +97,6 @@ AC_OUTPUT([Makefile \
+ gdb.hp/gdb.aCC/Makefile gdb.hp/gdb.compat/Makefile \
+ gdb.hp/gdb.defects/Makefile \
gdb.mi/Makefile gdb.modula2/Makefile gdb.multi/Makefile \
-- gdb.objc/Makefile gdb.opt/Makefile gdb.pascal/Makefile \
-+ gdb.objc/Makefile gdb.opt/Makefile gdb.pascal/Makefile gdb.pie/Makefile \
- gdb.python/Makefile gdb.reverse/Makefile \
+- gdb.objc/Makefile gdb.opencl/Makefile gdb.opt/Makefile gdb.pascal/Makefile \
++ gdb.objc/Makefile gdb.opencl/Makefile gdb.opt/Makefile gdb.pascal/Makefile gdb.pie/Makefile \
+ gdb.python/Makefile gdb.reverse/Makefile gdb.stabs/Makefile \
gdb.threads/Makefile gdb.trace/Makefile gdb.xml/Makefile])
-Index: gdb-7.0.90.20100306/gdb/testsuite/configure
+Index: gdb-7.2.50.20110320/gdb/testsuite/configure
===================================================================
---- gdb-7.0.90.20100306.orig/gdb/testsuite/configure 2010-02-19 20:16:36.000000000 +0100
-+++ gdb-7.0.90.20100306/gdb/testsuite/configure 2010-03-06 23:20:12.000000000 +0100
-@@ -3515,7 +3515,7 @@ done
+--- gdb-7.2.50.20110320.orig/gdb/testsuite/configure 2011-03-03 17:57:55.000000000 +0100
++++ gdb-7.2.50.20110320/gdb/testsuite/configure 2011-03-20 20:21:43.000000000 +0100
+@@ -3448,7 +3448,7 @@ done
--ac_config_files="$ac_config_files Makefile gdb.ada/Makefile gdb.arch/Makefile gdb.asm/Makefile gdb.base/Makefile gdb.cp/Makefile gdb.disasm/Makefile gdb.dwarf2/Makefile gdb.fortran/Makefile gdb.server/Makefile gdb.java/Makefile gdb.mi/Makefile gdb.modula2/Makefile gdb.multi/Makefile gdb.objc/Makefile gdb.opt/Makefile gdb.pascal/Makefile gdb.python/Makefile gdb.reverse/Makefile gdb.threads/Makefile gdb.trace/Makefile gdb.xml/Makefile"
-+ac_config_files="$ac_config_files Makefile gdb.ada/Makefile gdb.arch/Makefile gdb.asm/Makefile gdb.base/Makefile gdb.cp/Makefile gdb.disasm/Makefile gdb.dwarf2/Makefile gdb.fortran/Makefile gdb.server/Makefile gdb.java/Makefile gdb.mi/Makefile gdb.modula2/Makefile gdb.multi/Makefile gdb.objc/Makefile gdb.opt/Makefile gdb.pascal/Makefile gdb.pie/Makefile gdb.python/Makefile gdb.reverse/Makefile gdb.threads/Makefile gdb.trace/Makefile gdb.xml/Makefile"
+-ac_config_files="$ac_config_files Makefile gdb.ada/Makefile gdb.arch/Makefile gdb.asm/Makefile gdb.base/Makefile gdb.cell/Makefile gdb.cp/Makefile gdb.disasm/Makefile gdb.dwarf2/Makefile gdb.fortran/Makefile gdb.server/Makefile gdb.java/Makefile gdb.hp/Makefile gdb.hp/gdb.objdbg/Makefile gdb.hp/gdb.base-hp/Makefile gdb.hp/gdb.aCC/Makefile gdb.hp/gdb.compat/Makefile gdb.hp/gdb.defects/Makefile gdb.mi/Makefile gdb.modula2/Makefile gdb.multi/Makefile gdb.objc/Makefile gdb.opencl/Makefile gdb.opt/Makefile gdb.pascal/Makefile gdb.python/Makefile gdb.reverse/Makefile gdb.stabs/Makefile gdb.threads/Makefile gdb.trace/Makefile gdb.xml/Makefile"
++ac_config_files="$ac_config_files Makefile gdb.ada/Makefile gdb.arch/Makefile gdb.asm/Makefile gdb.base/Makefile gdb.cell/Makefile gdb.cp/Makefile gdb.disasm/Makefile gdb.dwarf2/Makefile gdb.fortran/Makefile gdb.server/Makefile gdb.java/Makefile gdb.hp/Makefile gdb.hp/gdb.objdbg/Makefile gdb.hp/gdb.base-hp/Makefile gdb.hp/gdb.aCC/Makefile gdb.hp/gdb.compat/Makefile gdb.hp/gdb.defects/Makefile gdb.mi/Makefile gdb.modula2/Makefile gdb.multi/Makefile gdb.objc/Makefile gdb.opencl/Makefile gdb.opt/Makefile gdb.pascal/Makefile gdb.pie/Makefile gdb.python/Makefile gdb.reverse/Makefile gdb.stabs/Makefile gdb.threads/Makefile gdb.trace/Makefile gdb.xml/Makefile"
cat >confcache <<\_ACEOF
# This file is a shell script that caches the results of configure
-@@ -4232,6 +4232,7 @@ do
- "gdb.objc/Makefile") CONFIG_FILES="$CONFIG_FILES gdb.objc/Makefile" ;;
+@@ -4173,6 +4173,7 @@ do
+ "gdb.opencl/Makefile") CONFIG_FILES="$CONFIG_FILES gdb.opencl/Makefile" ;;
"gdb.opt/Makefile") CONFIG_FILES="$CONFIG_FILES gdb.opt/Makefile" ;;
"gdb.pascal/Makefile") CONFIG_FILES="$CONFIG_FILES gdb.pascal/Makefile" ;;
+ "gdb.pie/Makefile") CONFIG_FILES="$CONFIG_FILES gdb.pie/Makefile" ;;
"gdb.python/Makefile") CONFIG_FILES="$CONFIG_FILES gdb.python/Makefile" ;;
"gdb.reverse/Makefile") CONFIG_FILES="$CONFIG_FILES gdb.reverse/Makefile" ;;
- "gdb.threads/Makefile") CONFIG_FILES="$CONFIG_FILES gdb.threads/Makefile" ;;
-Index: gdb-7.0.90.20100306/gdb/testsuite/gdb.pie/attach.c
+ "gdb.stabs/Makefile") CONFIG_FILES="$CONFIG_FILES gdb.stabs/Makefile" ;;
+Index: gdb-7.2.50.20110320/gdb/testsuite/gdb.pie/attach.c
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
-+++ gdb-7.0.90.20100306/gdb/testsuite/gdb.pie/attach.c 2010-03-06 23:19:31.000000000 +0100
++++ gdb-7.2.50.20110320/gdb/testsuite/gdb.pie/attach.c 2011-03-20 20:21:43.000000000 +0100
@@ -0,0 +1,20 @@
+/* This program is intended to be started outside of gdb, and then
+ attached to by gdb. Thus, it simply spins in a loop. The loop
+ }
+ return 0;
+}
-Index: gdb-7.0.90.20100306/gdb/testsuite/gdb.pie/attach2.c
+Index: gdb-7.2.50.20110320/gdb/testsuite/gdb.pie/attach2.c
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
-+++ gdb-7.0.90.20100306/gdb/testsuite/gdb.pie/attach2.c 2010-03-06 23:19:31.000000000 +0100
++++ gdb-7.2.50.20110320/gdb/testsuite/gdb.pie/attach2.c 2011-03-20 20:21:43.000000000 +0100
@@ -0,0 +1,24 @@
+/* This program is intended to be started outside of gdb, and then
+ attached to by gdb. Thus, it simply spins in a loop. The loop
+ }
+ return (0);
+}
-Index: gdb-7.0.90.20100306/gdb/testsuite/gdb.pie/break.c
+Index: gdb-7.2.50.20110320/gdb/testsuite/gdb.pie/break.c
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
-+++ gdb-7.0.90.20100306/gdb/testsuite/gdb.pie/break.c 2010-03-06 23:19:31.000000000 +0100
++++ gdb-7.2.50.20110320/gdb/testsuite/gdb.pie/break.c 2011-03-20 20:21:43.000000000 +0100
@@ -0,0 +1,146 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+ }
+ return 0;
+}
-Index: gdb-7.0.90.20100306/gdb/testsuite/gdb.pie/break1.c
+Index: gdb-7.2.50.20110320/gdb/testsuite/gdb.pie/break1.c
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
-+++ gdb-7.0.90.20100306/gdb/testsuite/gdb.pie/break1.c 2010-03-06 23:19:31.000000000 +0100
++++ gdb-7.2.50.20110320/gdb/testsuite/gdb.pie/break1.c 2011-03-20 20:21:43.000000000 +0100
@@ -0,0 +1,44 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+void marker3 (a, b) char *a, *b; {} /* set breakpoint 18 here */
+void marker4 (d) long d; {} /* set breakpoint 13 here */
+#endif
-Index: gdb-7.0.90.20100306/gdb/testsuite/gdb.pie/coremaker.c
+Index: gdb-7.2.50.20110320/gdb/testsuite/gdb.pie/coremaker.c
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
-+++ gdb-7.0.90.20100306/gdb/testsuite/gdb.pie/coremaker.c 2010-03-06 23:19:31.000000000 +0100
++++ gdb-7.2.50.20110320/gdb/testsuite/gdb.pie/coremaker.c 2011-03-20 20:21:43.000000000 +0100
@@ -0,0 +1,142 @@
+/* Copyright 1992, 1993, 1994, 1995, 1996, 1999
+ Free Software Foundation, Inc.
+ return 0;
+}
+
-Index: gdb-7.0.90.20100306/gdb/testsuite/gdb.pie/attach.exp
+Index: gdb-7.2.50.20110320/gdb/testsuite/gdb.pie/attach.exp
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
-+++ gdb-7.0.90.20100306/gdb/testsuite/gdb.pie/attach.exp 2010-03-06 23:19:31.000000000 +0100
-@@ -0,0 +1,423 @@
++++ gdb-7.2.50.20110320/gdb/testsuite/gdb.pie/attach.exp 2011-03-20 20:25:53.000000000 +0100
+@@ -0,0 +1,417 @@
+# Copyright 1997, 1999, 2002 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+
+ # Allow the test process to exit, to cleanup after ourselves.
+ #
-+ send_gdb "continue\n"
-+ gdb_expect {
-+ -re "Program exited normally.*$gdb_prompt $"\
-+ {pass "after attach2, exit"}
-+ -re "$gdb_prompt $" {fail "after attach2, exit"}
-+ timeout {fail "(timeout) after attach2, exit"}
-+ }
++ gdb_test "continue" {\[Inferior .* exited normally\]} "after attach2, exit"
+
+ # Make sure we don't leave a process around to confuse
+ # the next test run (and prevent the compile by keeping
+ # Get rid of the process
+ #
+ gdb_test "p should_exit = 1" ".*"
-+ gdb_test "c" ".*Program exited normally.*"
++ gdb_test "c" {\[Inferior .* exited normally\]}
+
+ # Be paranoid
+ #
+do_call_attach_tests
+
+return 0
-Index: gdb-7.0.90.20100306/gdb/testsuite/gdb.pie/break.exp
+Index: gdb-7.2.50.20110320/gdb/testsuite/gdb.pie/break.exp
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
-+++ gdb-7.0.90.20100306/gdb/testsuite/gdb.pie/break.exp 2010-03-06 23:19:31.000000000 +0100
++++ gdb-7.2.50.20110320/gdb/testsuite/gdb.pie/break.exp 2011-03-20 20:21:43.000000000 +0100
@@ -0,0 +1,966 @@
+# Copyright 1988, 1990, 1991, 1992, 1994, 1995, 1996, 1997, 1998, 1999,
+# 2000, 2002, 2003, 2004
+ send_gdb "set args main\n"
+ gdb_expect -re ".*$gdb_prompt $" {}
+}
-Index: gdb-7.0.90.20100306/gdb/testsuite/gdb.pie/corefile.exp
+Index: gdb-7.2.50.20110320/gdb/testsuite/gdb.pie/corefile.exp
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
-+++ gdb-7.0.90.20100306/gdb/testsuite/gdb.pie/corefile.exp 2010-03-06 23:19:31.000000000 +0100
++++ gdb-7.2.50.20110320/gdb/testsuite/gdb.pie/corefile.exp 2011-03-20 20:21:43.000000000 +0100
@@ -0,0 +1,233 @@
+# Copyright 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000
+# Free Software Foundation, Inc.
+gdb_test "up" "#\[0-9\]* *\[0-9xa-fH'\]* in .* \\(.*\\).*" "up in corefile.exp (reinit)"
+
+gdb_test "core" "No core file now."
-Index: gdb-7.0.90.20100306/gdb/testsuite/gdb.pie/Makefile.in
+Index: gdb-7.2.50.20110320/gdb/testsuite/gdb.pie/Makefile.in
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
-+++ gdb-7.0.90.20100306/gdb/testsuite/gdb.pie/Makefile.in 2010-03-06 23:19:31.000000000 +0100
++++ gdb-7.2.50.20110320/gdb/testsuite/gdb.pie/Makefile.in 2011-03-20 20:21:43.000000000 +0100
@@ -0,0 +1,19 @@
+VPATH = @srcdir@
+srcdir = @srcdir@
<81a2> DW_AT_name : (indirect string, offset: 0x280e): __errno_location
<81a8> DW_AT_MIPS_linkage_name: (indirect string, offset: 0x2808): *__GI___errno_location
-Index: gdb-7.2/gdb/printcmd.c
-===================================================================
---- gdb-7.2.orig/gdb/printcmd.c 2011-03-29 10:55:32.000000000 +0200
-+++ gdb-7.2/gdb/printcmd.c 2011-03-29 10:56:00.000000000 +0200
-@@ -947,10 +947,10 @@ validate_format (struct format_data fmt,
- static void
- print_command_1 (char *exp, int inspect, int voidprint)
- {
-- struct expression *expr;
- struct cleanup *old_chain = 0;
- char format = 0;
-- struct value *val;
-+ /* False GCC warning due to the TRY_CATCH. */
-+ struct value *val = NULL;
- struct format_data fmt;
- int cleanup = 0;
-
-@@ -971,10 +971,25 @@ print_command_1 (char *exp, int inspect,
+--- a/gdb/printcmd.c
++++ b/gdb/printcmd.c
+@@ -967,6 +967,8 @@ print_command_1 (char *exp, int inspect, int voidprint)
if (exp && *exp)
{
-+ struct expression *expr;
-+ volatile struct gdb_exception except;
-+
++ if (strcmp (exp, "errno") == 0)
++ exp = "*((int *(*) (void)) __errno_location) ()";
expr = parse_expression (exp);
-- old_chain = make_cleanup (free_current_contents, &expr);
-+ old_chain = make_cleanup (xfree, expr);
+ old_chain = make_cleanup (free_current_contents, &expr);
cleanup = 1;
-- val = evaluate_expression (expr);
-+ TRY_CATCH (except, RETURN_MASK_ERROR)
-+ {
-+ val = evaluate_expression (expr);
-+ }
-+ if (except.reason < 0)
-+ {
-+ if (strcmp (exp, "errno") != 0)
-+ throw_exception (except);
-+
-+ expr = parse_expression ("*((int *(*) (void)) __errno_location) ()");
-+ make_cleanup (xfree, expr);
-+ val = evaluate_expression (expr);
-+ }
- }
- else
- val = access_value_history (0);
Index: gdb-7.2/gdb/testsuite/gdb.dwarf2/dw2-errno.c
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=218379
-Index: gdb-6.8.50.20090803/gdb/symtab.c
+Index: gdb-7.2.50.20110117/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.20110117.orig/gdb/symtab.c 2011-01-17 15:47:37.000000000 +0100
++++ gdb-7.2.50.20110117/gdb/symtab.c 2011-01-17 15:51:48.000000000 +0100
+@@ -2015,6 +2015,13 @@ find_pc_sect_line (CORE_ADDR pc, struct
+ 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.
* exec.c (exec_file_attach): Print a more useful error message if the
user did "gdb core".
-Index: gdb-7.1.90.20100711/gdb/exceptions.h
+Index: gdb-7.2.50.20110218/gdb/exceptions.h
===================================================================
---- gdb-7.1.90.20100711.orig/gdb/exceptions.h 2010-05-03 01:52:14.000000000 +0200
-+++ gdb-7.1.90.20100711/gdb/exceptions.h 2010-07-13 22:56:29.000000000 +0200
-@@ -78,6 +78,9 @@ enum errors {
- /* Feature is not supported in this copy of GDB. */
- UNSUPPORTED_ERROR,
+--- gdb-7.2.50.20110218.orig/gdb/exceptions.h 2011-02-14 12:35:44.000000000 +0100
++++ gdb-7.2.50.20110218/gdb/exceptions.h 2011-02-18 10:45:31.000000000 +0100
+@@ -85,6 +85,9 @@ enum errors {
+ traceframe. */
+ NOT_AVAILABLE_ERROR,
+ /* Attempt to load a core file as executable. */
+ IS_CORE_ERROR,
/* Add more errors here. */
NR_ERRORS
};
-Index: gdb-7.1.90.20100711/gdb/exec.c
+Index: gdb-7.2.50.20110218/gdb/exec.c
===================================================================
---- gdb-7.1.90.20100711.orig/gdb/exec.c 2010-07-12 23:07:34.000000000 +0200
-+++ gdb-7.1.90.20100711/gdb/exec.c 2010-07-13 22:56:29.000000000 +0200
+--- gdb-7.2.50.20110218.orig/gdb/exec.c 2011-02-14 23:08:48.000000000 +0100
++++ gdb-7.2.50.20110218/gdb/exec.c 2011-02-18 10:45:16.000000000 +0100
@@ -34,6 +34,7 @@
#include "arch-utils.h"
#include "gdbthread.h"
}
/* FIXME - This should only be run for RS6000, but the ifdef is a poor
-Index: gdb-7.1.90.20100711/gdb/main.c
+Index: gdb-7.2.50.20110218/gdb/main.c
===================================================================
---- gdb-7.1.90.20100711.orig/gdb/main.c 2010-07-12 23:07:34.000000000 +0200
-+++ gdb-7.1.90.20100711/gdb/main.c 2010-07-13 22:58:20.000000000 +0200
-@@ -241,6 +241,36 @@ captured_command_loop (void *data)
+--- gdb-7.2.50.20110218.orig/gdb/main.c 2011-02-18 10:44:17.000000000 +0100
++++ gdb-7.2.50.20110218/gdb/main.c 2011-02-18 10:45:16.000000000 +0100
+@@ -243,6 +243,36 @@ captured_command_loop (void *data)
return 1;
}
static int
captured_main (void *data)
{
-@@ -678,6 +708,8 @@ extern int gdbtk_test (char *);
+@@ -727,6 +757,8 @@ captured_main (void *data)
{
symarg = argv[optind];
execarg = argv[optind];
optind++;
}
-@@ -816,10 +848,25 @@ Excess command line arguments ignored. (
+@@ -868,11 +900,25 @@ captured_main (void *data)
&& symarg != NULL
&& strcmp (execarg, symarg) == 0)
{
+ func = exec_file_attach;
+
/* The exec file and the symbol-file are the same. If we can't
-- open it, better only print one error message.
-- catch_command_errors returns non-zero on success! */
-- if (catch_command_errors (exec_file_attach, execarg, !batch_flag, RETURN_MASK_ALL))
-+ open it, better only print one error message.
-+ catch_command_errors returns non-zero on success!
+ 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))
++ 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
--- /dev/null
+--- ./gdb/elfread.c 2010-10-14 17:07:45.000000000 +0200
++++ ./gdb/elfread.c 2010-10-14 17:06:30.000000000 +0200
+@@ -1382,6 +1382,18 @@ build_id_to_filename (struct build_id *b
+ #include <dlfcn.h>
+ #endif
+
++/* Workarodun https://bugzilla.redhat.com/show_bug.cgi?id=643031
++ librpm must not exit() an application on SIGINT
++
++ Enable or disable a signal handler. SIGNUM: signal to enable (or disable
++ if negative). HANDLER: sa_sigaction handler (or NULL to use
++ rpmsqHandler()). Returns: no. of refs, -1 on error. */
++int
++rpmsqEnable (int signum, /* rpmsqAction_t handler */ void *handler)
++{
++ return 0;
++}
++
+ /* This MISSING_RPM_HASH tracker is used to collect all the missing rpm files
+ and avoid their duplicities during a single inferior run. */
+
+--- ./gdb/proc-service.list 2010-05-28 20:50:30.000000000 +0200
++++ ./gdb/proc-service.list 2010-10-14 17:06:30.000000000 +0200
+@@ -37,4 +37,7 @@
+ ps_pstop;
+ ps_ptread;
+ ps_ptwrite;
++
++ /* gdb-6.6-buildid-locate-rpm.patch */
++ rpmsqEnable;
+ };
-Index: gdb-7.2/gdb/event-top.c
+Index: gdb-7.2.90.20110429/gdb/event-top.c
===================================================================
---- gdb-7.2.orig/gdb/event-top.c 2010-06-26 08:44:47.000000000 +0200
-+++ gdb-7.2/gdb/event-top.c 2010-10-06 22:39:32.000000000 +0200
+--- gdb-7.2.90.20110429.orig/gdb/event-top.c 2011-03-16 16:18:58.000000000 +0100
++++ gdb-7.2.90.20110429/gdb/event-top.c 2011-05-03 05:21:11.000000000 +0200
@@ -33,6 +33,7 @@
#include "cli/cli-script.h" /* for reset_command_nest_depth */
#include "main.h"
#include "gdbthread.h"
+#include "symfile.h"
- /* For dont_repeat() */
- #include "gdbcmd.h"
-@@ -193,6 +194,8 @@ cli_command_loop (void)
+ #include "gdbcmd.h" /* for dont_repeat() */
+
+@@ -192,6 +193,8 @@ cli_command_loop (void)
char *a_prompt;
char *gdb_prompt = get_prompt ();
+ debug_flush_missing ();
+
- /* Tell readline what the prompt to display is and what function it
- will need to call after a whole line is read. This also displays
- the first prompt. */
-@@ -264,6 +267,8 @@ display_gdb_prompt (char *new_prompt)
+ /* Tell readline what the prompt to display is and what function
+ it will need to call after a whole line is read. This also
+ displays the first prompt. */
+@@ -263,6 +266,8 @@ display_gdb_prompt (char *new_prompt)
/* Reset the nesting depth used when trace-commands is set. */
reset_command_nest_depth ();
/* Each interpreter has its own rules on displaying the command
prompt. */
if (!current_interp_display_prompt_p ())
-Index: gdb-7.2/gdb/elfread.c
+Index: gdb-7.2.90.20110429/gdb/elfread.c
===================================================================
---- gdb-7.2.orig/gdb/elfread.c 2010-10-06 22:39:32.000000000 +0200
-+++ gdb-7.2/gdb/elfread.c 2010-10-06 22:39:52.000000000 +0200
-@@ -42,6 +42,7 @@
+--- gdb-7.2.90.20110429.orig/gdb/elfread.c 2011-05-03 05:19:27.000000000 +0200
++++ gdb-7.2.90.20110429/gdb/elfread.c 2011-05-03 05:21:22.000000000 +0200
+@@ -53,6 +53,7 @@
#include "gdbcore.h"
#include "gdbcmd.h"
#include "observer.h"
+#include "elf/external.h"
+ #include <sys/stat.h>
extern void _initialize_elfread (void);
-
-@@ -1371,8 +1372,361 @@ build_id_to_filename (struct build_id *b
+@@ -1655,8 +1656,361 @@ build_id_to_filename (struct build_id *b
return retval;
}
avoidance. */
struct missing_filepair
-@@ -1426,11 +1780,17 @@ missing_filepair_change (void)
+@@ -1710,11 +2064,17 @@ missing_filepair_change (void)
/* All their memory came just from missing_filepair_OBSTACK. */
missing_filepair_hash = NULL;
}
missing_filepair_change ();
}
-@@ -1497,14 +1857,35 @@ debug_print_missing (const char *binary,
+@@ -1781,14 +2141,35 @@ debug_print_missing (const char *binary,
*slot = missing_filepair;
}
static char *
-Index: gdb-7.2/gdb/symfile.h
+Index: gdb-7.2.90.20110429/gdb/symfile.h
===================================================================
---- gdb-7.2.orig/gdb/symfile.h 2010-10-06 22:39:32.000000000 +0200
-+++ gdb-7.2/gdb/symfile.h 2010-10-06 22:39:52.000000000 +0200
-@@ -577,6 +577,8 @@ extern struct build_id *build_id_addr_ge
+--- gdb-7.2.90.20110429.orig/gdb/symfile.h 2011-05-03 05:14:57.000000000 +0200
++++ gdb-7.2.90.20110429/gdb/symfile.h 2011-05-03 05:21:11.000000000 +0200
+@@ -611,6 +611,8 @@ extern struct build_id *build_id_addr_ge
extern char *build_id_to_filename (struct build_id *build_id,
char **link_return, int add_debug_suffix);
extern void debug_print_missing (const char *binary, const char *debug);
/* From dwarf2read.c */
-Index: gdb-7.2/gdb/testsuite/lib/gdb.exp
+Index: gdb-7.2.90.20110429/gdb/testsuite/lib/gdb.exp
===================================================================
---- gdb-7.2.orig/gdb/testsuite/lib/gdb.exp 2010-10-06 22:39:32.000000000 +0200
-+++ gdb-7.2/gdb/testsuite/lib/gdb.exp 2010-10-06 22:39:32.000000000 +0200
-@@ -1359,7 +1359,7 @@ proc default_gdb_start { } {
+--- gdb-7.2.90.20110429.orig/gdb/testsuite/lib/gdb.exp 2011-05-03 05:14:57.000000000 +0200
++++ gdb-7.2.90.20110429/gdb/testsuite/lib/gdb.exp 2011-05-03 05:21:11.000000000 +0200
+@@ -1381,7 +1381,7 @@ proc default_gdb_start { } {
warning "Couldn't set the width to 0."
}
}
send_gdb "set build-id-verbose 0\n"
gdb_expect 10 {
-re "$gdb_prompt $" {
-Index: gdb-7.2/gdb/testsuite/lib/mi-support.exp
+Index: gdb-7.2.90.20110429/gdb/testsuite/lib/mi-support.exp
===================================================================
---- gdb-7.2.orig/gdb/testsuite/lib/mi-support.exp 2010-10-06 22:39:32.000000000 +0200
-+++ gdb-7.2/gdb/testsuite/lib/mi-support.exp 2010-10-06 22:39:32.000000000 +0200
+--- gdb-7.2.90.20110429.orig/gdb/testsuite/lib/mi-support.exp 2011-05-03 05:14:57.000000000 +0200
++++ gdb-7.2.90.20110429/gdb/testsuite/lib/mi-support.exp 2011-05-03 05:21:11.000000000 +0200
@@ -221,7 +221,7 @@ proc default_mi_gdb_start { args } {
}
}
send_gdb "190-gdb-set build-id-verbose 0\n"
gdb_expect 10 {
-re ".*190-gdb-set build-id-verbose 0\r\n190\\\^done\r\n$mi_gdb_prompt$" {
-Index: gdb-7.2/gdb/tui/tui-interp.c
+Index: gdb-7.2.90.20110429/gdb/tui/tui-interp.c
===================================================================
---- gdb-7.2.orig/gdb/tui/tui-interp.c 2010-05-18 00:21:43.000000000 +0200
-+++ gdb-7.2/gdb/tui/tui-interp.c 2010-10-06 22:39:32.000000000 +0200
-@@ -30,6 +30,7 @@
+--- gdb-7.2.90.20110429.orig/gdb/tui/tui-interp.c 2011-01-01 16:33:52.000000000 +0100
++++ gdb-7.2.90.20110429/gdb/tui/tui-interp.c 2011-05-03 05:21:11.000000000 +0200
+@@ -31,6 +31,7 @@
#include "tui/tui.h"
#include "tui/tui-io.h"
#include "exceptions.h"
/* Set to 1 when the TUI mode must be activated when we first start
gdb. */
-@@ -146,6 +147,8 @@ tui_command_loop (void *data)
+@@ -147,6 +148,8 @@ tui_command_loop (void *data)
char *a_prompt;
char *gdb_prompt = get_prompt ();
/* Tell readline what the prompt to display is and what function
it will need to call after a whole line is read. This also
displays the first prompt. */
-Index: gdb-7.2/gdb/aclocal.m4
+Index: gdb-7.2.90.20110429/gdb/aclocal.m4
===================================================================
---- gdb-7.2.orig/gdb/aclocal.m4 2010-05-23 02:56:59.000000000 +0200
-+++ gdb-7.2/gdb/aclocal.m4 2010-10-06 22:39:32.000000000 +0200
+--- gdb-7.2.90.20110429.orig/gdb/aclocal.m4 2011-02-15 22:05:53.000000000 +0100
++++ gdb-7.2.90.20110429/gdb/aclocal.m4 2011-05-03 05:21:11.000000000 +0200
@@ -19,6 +19,162 @@ You have another version of autoconf. I
If you have problems, you may need to regenerate the build system entirely.
To do so, use the procedure documented by the package, typically `autoreconf'.])])
# Copyright (C) 2002, 2003, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
-Index: gdb-7.2/gdb/config.in
+Index: gdb-7.2.90.20110429/gdb/config.in
===================================================================
---- gdb-7.2.orig/gdb/config.in 2010-10-06 22:39:31.000000000 +0200
-+++ gdb-7.2/gdb/config.in 2010-10-06 22:39:32.000000000 +0200
+--- gdb-7.2.90.20110429.orig/gdb/config.in 2011-03-17 14:19:09.000000000 +0100
++++ gdb-7.2.90.20110429/gdb/config.in 2011-05-03 05:21:11.000000000 +0200
@@ -46,6 +46,9 @@
/* Define to BFD's default target vector. */
#undef DEFAULT_BFD_VEC
/* Define to 1 if translation of program messages to the user's native
language is requested. */
#undef ENABLE_NLS
-@@ -231,6 +234,9 @@
+@@ -233,6 +236,9 @@
/* Define if Python 2.7 is being used. */
#undef HAVE_LIBPYTHON2_7
/* Define if libunwind library is being used. */
#undef HAVE_LIBUNWIND
-Index: gdb-7.2/gdb/configure
+Index: gdb-7.2.90.20110429/gdb/configure
===================================================================
---- gdb-7.2.orig/gdb/configure 2010-10-06 22:39:31.000000000 +0200
-+++ gdb-7.2/gdb/configure 2010-10-06 22:39:32.000000000 +0200
-@@ -679,6 +679,9 @@ REPORT_BUGS_TO
+--- gdb-7.2.90.20110429.orig/gdb/configure 2011-04-03 18:32:40.000000000 +0200
++++ gdb-7.2.90.20110429/gdb/configure 2011-05-03 05:21:11.000000000 +0200
+@@ -682,6 +682,9 @@ REPORT_BUGS_TO
PKGVERSION
TARGET_OBS
subdirs
+RPM_LIBS
+RPM_CFLAGS
+PKG_CONFIG
- pythondir
- GDB_DATADIR_PATH
GDB_DATADIR
-@@ -948,6 +951,7 @@ with_separate_debug_dir
+ DEBUGDIR
+ am__fastdepCC_FALSE
+@@ -948,6 +951,7 @@ enable_dependency_tracking
+ with_separate_debug_dir
with_gdb_datadir
with_relocated_sources
- with_pythondir
+with_rpm
enable_targets
enable_64_bit_bfd
enable_gdbcli
-@@ -988,6 +992,9 @@ LDFLAGS
+@@ -989,6 +993,9 @@ LDFLAGS
LIBS
CPPFLAGS
CPP
YACC
YFLAGS
XMKMF'
-@@ -1653,6 +1660,8 @@ Optional Packages:
+@@ -1652,6 +1659,8 @@ Optional Packages:
[DATADIR/gdb]
- --with-pythondir install Python data files in this path
- [DATADIR/gdb/python]
+ --with-relocated-sources=PATH
+ automatically relocate this path for source files
+ --with-rpm query rpm database for missing debuginfos (yes/no,
+ def. auto=librpm.so)
--with-libunwind use libunwind frame unwinding support
--with-curses use the curses library instead of the termcap
library
-@@ -1688,6 +1697,9 @@ Some influential environment variables:
+@@ -1687,6 +1696,9 @@ Some influential environment variables:
CPPFLAGS C/C++/Objective C preprocessor flags, e.g. -I<include dir> if
you have headers in a nonstandard directory <include dir>
CPP C preprocessor
YACC The `Yet Another C Compiler' implementation to use. Defaults to
the first program found out of: `bison -y', `byacc', `yacc'.
YFLAGS The list of arguments that will be passed by default to $YACC.
-@@ -7951,6 +7963,485 @@ _ACEOF
+@@ -7884,6 +7896,486 @@ _ACEOF
fi
+ fi
+ fi
+fi
++
-
-Index: gdb-7.2/gdb/configure.ac
+ subdirs="$subdirs testsuite"
+Index: gdb-7.2.90.20110429/gdb/configure.ac
===================================================================
---- gdb-7.2.orig/gdb/configure.ac 2010-10-06 22:39:31.000000000 +0200
-+++ gdb-7.2/gdb/configure.ac 2010-10-06 22:39:32.000000000 +0200
-@@ -152,6 +152,198 @@ else
- fi
- AC_SUBST(pythondir)
+--- gdb-7.2.90.20110429.orig/gdb/configure.ac 2011-04-03 18:32:40.000000000 +0200
++++ gdb-7.2.90.20110429/gdb/configure.ac 2011-05-03 05:21:11.000000000 +0200
+@@ -108,6 +108,199 @@ AS_HELP_STRING([--with-relocated-sources
+ [Relocated directory for source files. ])
+ ])
+# Integration with rpm library to support missing debuginfo suggestions.
+# --without-rpm: Disable any rpm support.
+ fi
+ fi
+fi
++
+ AC_CONFIG_SUBDIRS(testsuite)
- AC_CONFIG_SUBDIRS(doc testsuite)
-
-Index: gdb-7.2/gdb/acinclude.m4
+ # Check whether to support alternative target configurations
+Index: gdb-7.2.90.20110429/gdb/acinclude.m4
===================================================================
---- gdb-7.2.orig/gdb/acinclude.m4 2010-05-27 05:40:45.000000000 +0200
-+++ gdb-7.2/gdb/acinclude.m4 2010-10-06 22:39:32.000000000 +0200
+--- gdb-7.2.90.20110429.orig/gdb/acinclude.m4 2010-05-27 05:40:45.000000000 +0200
++++ gdb-7.2.90.20110429/gdb/acinclude.m4 2011-05-03 05:21:11.000000000 +0200
@@ -1,3 +1,5 @@
+# serial 1
+
# @defmac AC_PROG_CC_STDC
# @maindex PROG_CC_STDC
# @ovindex CC
-Index: gdb-7.2/gdb/corelow.c
+Index: gdb-7.2.90.20110429/gdb/corelow.c
===================================================================
---- gdb-7.2.orig/gdb/corelow.c 2010-10-06 22:39:39.000000000 +0200
-+++ gdb-7.2/gdb/corelow.c 2010-10-06 22:39:52.000000000 +0200
-@@ -331,7 +331,7 @@ build_id_locate_exec (int from_tty)
+--- gdb-7.2.90.20110429.orig/gdb/corelow.c 2011-05-03 05:14:57.000000000 +0200
++++ gdb-7.2.90.20110429/gdb/corelow.c 2011-05-03 05:21:11.000000000 +0200
+@@ -320,7 +320,7 @@ build_id_locate_exec (int from_tty)
symfile_objfile->flags |= OBJF_BUILD_ID_CORE_LOADED;
}
else
-Index: gdb-7.1.90.20100711/gdb/corelow.c
+Index: gdb-7.2.90.20110429/gdb/corelow.c
===================================================================
---- gdb-7.1.90.20100711.orig/gdb/corelow.c 2010-05-14 01:53:32.000000000 +0200
-+++ gdb-7.1.90.20100711/gdb/corelow.c 2010-07-12 11:07:33.000000000 +0200
+--- gdb-7.2.90.20110429.orig/gdb/corelow.c 2011-02-26 03:07:07.000000000 +0100
++++ gdb-7.2.90.20110429/gdb/corelow.c 2011-05-03 05:14:57.000000000 +0200
@@ -47,6 +47,9 @@
#include "filenames.h"
#include "progspace.h"
#ifndef O_LARGEFILE
-@@ -289,6 +292,52 @@ add_to_thread_list (bfd *abfd, asection
- inferior_ptid = ptid; /* Yes, make it current */
+@@ -278,6 +281,52 @@ add_to_thread_list (bfd *abfd, asection
+ inferior_ptid = ptid; /* Yes, make it current. */
}
+static int build_id_core_loads = 1;
/* This routine opens and sets up the core file bfd. */
static void
-@@ -386,6 +435,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);
/* 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
-@@ -924,4 +979,11 @@ _initialize_corelow (void)
+@@ -932,4 +987,11 @@ _initialize_corelow (void)
init_core_ops ();
add_target (&core_ops);
+ NULL, NULL, NULL,
+ &setlist, &showlist);
}
-Index: gdb-7.1.90.20100711/gdb/doc/gdb.texinfo
+Index: gdb-7.2.90.20110429/gdb/doc/gdb.texinfo
===================================================================
---- gdb-7.1.90.20100711.orig/gdb/doc/gdb.texinfo 2010-07-12 10:59:30.000000000 +0200
-+++ gdb-7.1.90.20100711/gdb/doc/gdb.texinfo 2010-07-12 11:05:57.000000000 +0200
-@@ -14980,6 +14980,27 @@ information files.
+--- gdb-7.2.90.20110429.orig/gdb/doc/gdb.texinfo 2011-05-03 05:14:56.000000000 +0200
++++ gdb-7.2.90.20110429/gdb/doc/gdb.texinfo 2011-05-03 05:14:57.000000000 +0200
+@@ -15356,6 +15356,27 @@ information files.
@end table
@cindex @code{.gnu_debuglink} sections
@cindex debug link sections
A debug link is a special section of the executable file named
-Index: gdb-7.1.90.20100711/gdb/solib-svr4.c
+Index: gdb-7.2.90.20110429/gdb/solib-svr4.c
===================================================================
---- gdb-7.1.90.20100711.orig/gdb/solib-svr4.c 2010-07-12 10:00:56.000000000 +0200
-+++ gdb-7.1.90.20100711/gdb/solib-svr4.c 2010-07-12 11:05:57.000000000 +0200
-@@ -1181,9 +1181,49 @@ svr4_current_sos (void)
+--- gdb-7.2.90.20110429.orig/gdb/solib-svr4.c 2011-05-03 05:14:56.000000000 +0200
++++ gdb-7.2.90.20110429/gdb/solib-svr4.c 2011-05-03 05:14:57.000000000 +0200
+@@ -1179,9 +1179,49 @@ svr4_current_sos (void)
safe_strerror (errcode));
else
{
}
xfree (buffer);
-Index: gdb-7.1.90.20100711/gdb/elfread.c
+Index: gdb-7.2.90.20110429/gdb/elfread.c
===================================================================
---- gdb-7.1.90.20100711.orig/gdb/elfread.c 2010-07-12 10:00:56.000000000 +0200
-+++ gdb-7.1.90.20100711/gdb/elfread.c 2010-07-12 11:30:30.000000000 +0200
-@@ -38,6 +38,10 @@
- #include "demangle.h"
- #include "psympriv.h"
- #include "gdbtypes.h"
+--- gdb-7.2.90.20110429.orig/gdb/elfread.c 2011-05-03 05:14:56.000000000 +0200
++++ gdb-7.2.90.20110429/gdb/elfread.c 2011-05-03 05:19:27.000000000 +0200
+@@ -49,6 +49,11 @@
+ #include "infcall.h"
+ #include "gdbthread.h"
+ #include "regcache.h"
+#include "libbfd.h"
+#include "gdbcore.h"
+#include "gdbcmd.h"
+#include "observer.h"
++#include <sys/stat.h>
extern void _initialize_elfread (void);
-@@ -818,16 +822,65 @@ resolve_gnu_ifunc (const char *function_
- return 0;
+@@ -1077,16 +1082,65 @@ elf_gnu_ifunc_resolver_return_stop (stru
+ update_breakpoint_locations (b, sals, sals_end);
}
-+/* Locate NT_GNU_BUILD_ID and return its matching debug filename.
-+ FIXME: NOTE decoding should be unified with the BFD core notes decoding. */
-+
+#define BUILD_ID_VERBOSE_NONE 0
+#define BUILD_ID_VERBOSE_FILENAMES 1
+#define BUILD_ID_VERBOSE_BINARY_PARSE 2
};
-/* Locate NT_GNU_BUILD_ID from ABFD and return its content. */
++/* Locate NT_GNU_BUILD_ID and return its matching debug filename.
++ FIXME: NOTE decoding should be unified with the BFD core notes decoding. */
++
+struct build_id *
+build_id_buf_get (bfd *templ, gdb_byte *buf, bfd_size_type size)
+{
{
struct build_id *retval;
-@@ -843,6 +896,348 @@ build_id_bfd_get (bfd *abfd)
+@@ -1102,6 +1156,348 @@ build_id_bfd_get (bfd *abfd)
return retval;
}
/* Return if FILENAME has NT_GNU_BUILD_ID matching the CHECK value. */
static int
-@@ -857,7 +1252,7 @@ build_id_verify (const char *filename, s
+@@ -1116,7 +1512,7 @@ build_id_verify (const char *filename, s
if (abfd == NULL)
return 0;
if (found == NULL)
warning (_("File \"%s\" has no build-id, file skipped"), filename);
-@@ -874,14 +1269,16 @@ build_id_verify (const char *filename, s
+@@ -1134,14 +1530,15 @@ build_id_verify (const char *filename, s
return retval;
}
/* DEBUG_FILE_DIRECTORY/.build-id/ab/cdef */
- link = alloca (strlen (debug_file_directory) + (sizeof "/.build-id/" - 1) + 1
- + 2 * build_id->size + (sizeof ".debug" - 1) + 1);
-+ link = xmalloc (strlen (debug_file_directory) + (sizeof "/.build-id/" - 1) + 1
-+ + 2 * build_id->size + (sizeof ".debug" - 1) + 1);
++ link = xmalloc (strlen (debug_file_directory) + 2 * build_id->size + 50);
/* Keep backward compatibility so that DEBUG_FILE_DIRECTORY being "" will
cause "/.build-id/..." lookups. */
-@@ -912,7 +1309,10 @@ build_id_to_debug_filename (struct build
+@@ -1152,6 +1549,8 @@ build_id_to_debug_filename (struct build
+ char *s, *debugdir_end;
+ gdb_byte *data = build_id->data;
+ size_t size = build_id->size;
++ unsigned seqno;
++ struct stat statbuf_trash;
+
+ while (*debugdir == DIRNAME_SEPARATOR)
+ debugdir++;
+@@ -1172,39 +1571,242 @@ build_id_to_debug_filename (struct build
*s++ = '/';
while (size-- > 0)
s += sprintf (s, "%02x", (unsigned) *data++);
- strcpy (s, ".debug");
-+ if (add_debug_suffix)
-+ strcpy (s, ".debug");
-+ else
-+ *s = 0;
+-
+- /* lrealpath() is expensive even for the usually non-existent files. */
+- if (access (link, F_OK) == 0)
+- retval = lrealpath (link);
- /* lrealpath() is expensive even for the usually non-existent files. */
- if (access (link, F_OK) == 0)
-@@ -925,26 +1325,201 @@ build_id_to_debug_filename (struct build
+- if (retval != NULL && !build_id_verify (retval, build_id))
++ for (seqno = 0;; seqno++)
+ {
+- xfree (retval);
+- retval = NULL;
++ char *s2;
++
++ if (seqno)
++ {
++ /* There can be multiple build-id symlinks pointing to real files
++ with the same build-id (such as hard links). Some of the real
++ files may not be installed. */
++
++ s2 = s + sprintf (s, ".%u", seqno);
++ }
++ else
++ s2 = s;
++
++ if (add_debug_suffix)
++ strcpy (s2, ".debug");
++ else
++ *s2 = 0;
++
++ /* `access' automatically dereferences LINK. */
++ if (lstat (link, &statbuf_trash) != 0)
++ {
++ /* Stop increasing SEQNO. */
++ break;
++ }
++
++ retval = lrealpath (link);
++
++ if (retval != NULL && !build_id_verify (retval, build_id))
++ {
++ xfree (retval);
++ retval = NULL;
++ }
++
++ if (retval)
++ break;
}
if (retval != NULL)
+ 1);
xfree (build_id);
/* Prevent looping on a stripped .debug file. */
- if (build_id_name != NULL && strcmp (build_id_name, objfile->name) == 0)
-@@ -954,7 +1529,7 @@ find_separate_debug_file_by_buildid (str
+ if (build_id_name != NULL
+@@ -1215,7 +1817,7 @@ find_separate_debug_file_by_buildid (str
xfree (build_id_name);
}
else if (build_id_name != NULL)
}
return NULL;
}
-@@ -1131,9 +1706,10 @@ elf_symfile_read (struct objfile *objfil
- `.gnu_debuglink' may no longer be present with `.note.gnu.build-id'. */
- if (!objfile_has_partial_symbols (objfile))
+@@ -1418,9 +2020,10 @@ elf_symfile_read (struct objfile *objfil
+ `.note.gnu.build-id'. */
+ else if (!objfile_has_partial_symbols (objfile))
{
- char *debugfile;
+ char *debugfile, *build_id_filename;
if (debugfile == NULL)
debugfile = find_separate_debug_file_by_debuglink (objfile);
-@@ -1145,6 +1721,12 @@ elf_symfile_read (struct objfile *objfil
+@@ -1432,6 +2035,12 @@ elf_symfile_read (struct objfile *objfil
symbol_file_add_separate (abfd, symfile_flags, objfile);
xfree (debugfile);
}
}
}
-@@ -1304,4 +1886,16 @@ void
- _initialize_elfread (void)
- {
- add_symtab_fns (&elf_sym_fns);
+@@ -1911,4 +2520,16 @@ _initialize_elfread (void)
+
+ elf_objfile_gnu_ifunc_cache_data = register_objfile_data ();
+ gnu_ifunc_fns_p = &elf_gnu_ifunc_fns;
+
+ add_setshow_zinteger_cmd ("build-id-verbose", no_class, &build_id_verbose,
+ _("\
+
+ observer_attach_executable_changed (debug_print_executable_changed);
}
-Index: gdb-7.1.90.20100711/gdb/symfile.h
+Index: gdb-7.2.90.20110429/gdb/symfile.h
===================================================================
---- gdb-7.1.90.20100711.orig/gdb/symfile.h 2010-05-08 06:58:45.000000000 +0200
-+++ gdb-7.1.90.20100711/gdb/symfile.h 2010-07-12 11:06:18.000000000 +0200
-@@ -562,6 +562,13 @@ void free_symfile_segment_data (struct s
+--- gdb-7.2.90.20110429.orig/gdb/symfile.h 2011-05-03 05:14:56.000000000 +0200
++++ gdb-7.2.90.20110429/gdb/symfile.h 2011-05-03 05:14:57.000000000 +0200
+@@ -605,6 +605,13 @@ void free_symfile_segment_data (struct s
extern struct cleanup *increment_reading_symtab (void);
/* From dwarf2read.c */
extern int dwarf2_has_info (struct objfile *);
-Index: gdb-7.1.90.20100711/gdb/testsuite/lib/gdb.exp
+Index: gdb-7.2.90.20110429/gdb/testsuite/lib/gdb.exp
===================================================================
---- gdb-7.1.90.20100711.orig/gdb/testsuite/lib/gdb.exp 2010-07-12 10:00:56.000000000 +0200
-+++ gdb-7.1.90.20100711/gdb/testsuite/lib/gdb.exp 2010-07-12 11:05:57.000000000 +0200
-@@ -1353,6 +1353,16 @@ proc default_gdb_start { } {
+--- gdb-7.2.90.20110429.orig/gdb/testsuite/lib/gdb.exp 2011-05-03 05:14:56.000000000 +0200
++++ gdb-7.2.90.20110429/gdb/testsuite/lib/gdb.exp 2011-05-03 05:14:57.000000000 +0200
+@@ -1381,6 +1381,16 @@ proc default_gdb_start { } {
warning "Couldn't set the width to 0."
}
}
return 0;
}
-Index: gdb-7.1.90.20100711/gdb/testsuite/lib/mi-support.exp
+Index: gdb-7.2.90.20110429/gdb/testsuite/lib/mi-support.exp
===================================================================
---- gdb-7.1.90.20100711.orig/gdb/testsuite/lib/mi-support.exp 2010-03-15 04:43:13.000000000 +0100
-+++ gdb-7.1.90.20100711/gdb/testsuite/lib/mi-support.exp 2010-07-12 11:05:57.000000000 +0200
+--- gdb-7.2.90.20110429.orig/gdb/testsuite/lib/mi-support.exp 2011-03-07 17:03:04.000000000 +0100
++++ gdb-7.2.90.20110429/gdb/testsuite/lib/mi-support.exp 2011-05-03 05:14:57.000000000 +0200
@@ -221,6 +221,16 @@ proc default_mi_gdb_start { args } {
}
}
detect_async
-Index: gdb-7.1.90.20100711/gdb/objfiles.h
+Index: gdb-7.2.90.20110429/gdb/objfiles.h
===================================================================
---- gdb-7.1.90.20100711.orig/gdb/objfiles.h 2010-04-14 19:26:11.000000000 +0200
-+++ gdb-7.1.90.20100711/gdb/objfiles.h 2010-07-12 11:07:08.000000000 +0200
-@@ -426,6 +426,10 @@ struct objfile
+--- gdb-7.2.90.20110429.orig/gdb/objfiles.h 2011-03-07 17:17:29.000000000 +0100
++++ gdb-7.2.90.20110429/gdb/objfiles.h 2011-05-03 05:14:57.000000000 +0200
+@@ -441,6 +441,10 @@ struct objfile
- #define OBJF_USERLOADED (1 << 3) /* User loaded */
+ #define OBJF_PSYMTABS_READ (1 << 4)
+/* This file was loaded according to the BUILD_ID_CORE_LOADS rules. */
+
+#define OBJF_BUILD_ID_CORE_LOADED (1 << 12)
+
/* The object file that contains the runtime common minimal symbols
- for SunOS4. Note that this objfile has no associated BFD. */
+ for SunOS4. Note that this objfile has no associated BFD. */
* gdb.base/gcorebg.exp, gdb.base/gcorebg.c: New files.
---- gdb-6.6-orig/gdb/gdb_gcore.sh 2005-12-17 17:33:59.000000000 -0500
-+++ gdb-6.6/gdb/gdb_gcore.sh 2007-04-22 05:42:50.000000000 -0400
-@@ -71,7 +71,9 @@
- quit
- EOF
-
-- gdb -x $tmpfile -batch
-+ # `</dev/null' to avoid touching interactive terminal if it is
-+ # available but not accessible (SIGTTIN risk)
-+ gdb -x $tmpfile -batch </dev/null
-
- if [ -r $name.$pid ] ; then
- rc=0
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ ./gdb/testsuite/gdb.base/gcorebg.c 25 Feb 2007 12:21:20 -0000
@@ -0,0 +1,43 @@
Port to GDB-6.8pre.
Remove the `[' character from the GDB-6.8 default message.
-Index: gdb-7.0.50.20100115/gdb/linux-nat.c
+Index: gdb-7.2.50.20110320/gdb/linux-nat.c
===================================================================
---- gdb-7.0.50.20100115.orig/gdb/linux-nat.c 2010-01-15 03:22:31.000000000 +0100
-+++ gdb-7.0.50.20100115/gdb/linux-nat.c 2010-01-15 03:23:28.000000000 +0100
-@@ -724,7 +724,7 @@ holding the child stopped. Try \"set de
+--- gdb-7.2.50.20110320.orig/gdb/linux-nat.c 2011-03-20 16:59:51.000000000 +0100
++++ gdb-7.2.50.20110320/gdb/linux-nat.c 2011-03-20 16:59:51.000000000 +0100
+@@ -716,7 +716,7 @@ holding the child stopped. Try \"set de
remove_breakpoints_pid (GET_PID (inferior_ptid));
}
{
target_terminal_ours ();
fprintf_filtered (gdb_stdlog,
-Index: gdb-7.0.50.20100115/gdb/testsuite/gdb.base/fork-detach.c
+Index: gdb-7.2.50.20110320/gdb/testsuite/gdb.base/fork-detach.c
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
-+++ gdb-7.0.50.20100115/gdb/testsuite/gdb.base/fork-detach.c 2010-01-15 03:22:52.000000000 +0100
++++ gdb-7.2.50.20110320/gdb/testsuite/gdb.base/fork-detach.c 2011-03-20 16:59:51.000000000 +0100
@@ -0,0 +1,57 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+ }
+ return 0;
+}
-Index: gdb-7.0.50.20100115/gdb/testsuite/gdb.base/fork-detach.exp
+Index: gdb-7.2.50.20110320/gdb/testsuite/gdb.base/fork-detach.exp
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
-+++ gdb-7.0.50.20100115/gdb/testsuite/gdb.base/fork-detach.exp 2010-01-15 03:22:52.000000000 +0100
++++ gdb-7.2.50.20110320/gdb/testsuite/gdb.base/fork-detach.exp 2011-03-20 17:12:22.000000000 +0100
@@ -0,0 +1,36 @@
+# Copyright 2007 Free Software Foundation, Inc.
+
+gdb_run_cmd
+# `Starting program: .*' prefix is available since gdb-6.7.
+gdb_test "" \
-+ "Detaching after fork from child process.*Program exited normally\\..*" \
++ "Detaching after fork from child process.*\\\[Inferior .* exited normally\\\]" \
+ "Info message caught"
Port to GDB-6.8pre.
-Index: gdb-7.1.90.20100711/gdb/inferior.h
+Index: gdb-7.2.50.20110117/gdb/inferior.h
===================================================================
---- gdb-7.1.90.20100711.orig/gdb/inferior.h 2010-07-12 10:00:56.000000000 +0200
-+++ gdb-7.1.90.20100711/gdb/inferior.h 2010-07-12 10:04:25.000000000 +0200
-@@ -198,7 +198,15 @@ extern void reopen_exec_file (void);
+--- gdb-7.2.50.20110117.orig/gdb/inferior.h 2011-01-09 04:08:56.000000000 +0100
++++ gdb-7.2.50.20110117/gdb/inferior.h 2011-01-17 15:48:39.000000000 +0100
+@@ -186,7 +186,15 @@ extern void reopen_exec_file (void);
/* The `resume' routine should only be called in special circumstances.
Normally, use `proceed', which handles a lot of bookkeeping. */
/* From misc files */
-Index: gdb-7.1.90.20100711/gdb/infrun.c
+Index: gdb-7.2.50.20110117/gdb/infrun.c
===================================================================
---- gdb-7.1.90.20100711.orig/gdb/infrun.c 2010-07-12 10:00:56.000000000 +0200
-+++ gdb-7.1.90.20100711/gdb/infrun.c 2010-07-12 10:05:26.000000000 +0200
+--- gdb-7.2.50.20110117.orig/gdb/infrun.c 2011-01-09 04:08:56.000000000 +0100
++++ gdb-7.2.50.20110117/gdb/infrun.c 2011-01-17 15:49:40.000000000 +0100
@@ -76,7 +76,7 @@ static int follow_fork (void);
static void set_schedlock_func (char *args, int from_tty,
struct cmd_list_element *c);
static int currently_stepping_or_nexting_callback (struct thread_info *tp,
void *data);
-@@ -1549,7 +1549,7 @@ maybe_software_singlestep (struct gdbarc
+@@ -1577,7 +1577,7 @@ maybe_software_singlestep (struct gdbarc
STEP nonzero if we should step (zero to continue instead).
SIG is the signal to give the inferior (zero for none). */
void
{
int should_resume = 1;
struct cleanup *old_cleanups = make_cleanup (resume_cleanups, 0);
-@@ -1562,10 +1562,12 @@ resume (int step, enum target_signal sig
- QUIT;
+@@ -1609,10 +1609,12 @@ resume (int step, enum target_signal sig
+ }
if (debug_infrun)
- fprintf_unfiltered (gdb_stdlog,
- "infrun: resume (step=%d, signal=%d), "
- "trap_expected=%d\n",
-- step, sig, tp->trap_expected);
+- step, sig, tp->control.trap_expected);
+ fprintf_unfiltered (gdb_stdlog, "infrun: resume (step=%s, signal=%d), "
+ "trap_expected=%d\n",
+ (step == RESUME_STEP_CONTINUE ? "RESUME_STEP_CONTINUE"
+ : (step == RESUME_STEP_USER ? "RESUME_STEP_USER"
+ : "RESUME_STEP_NEEDED")),
-+ sig, tp->trap_expected);
++ sig, tp->control.trap_expected);
/* Normally, by the time we reach `resume', the breakpoints are either
removed or inserted, as appropriate. The exception is if we're sitting
-@@ -1678,9 +1680,10 @@ a command like `return' or `jump' to con
+@@ -1730,9 +1732,10 @@ a command like `return' or `jump' to con
individually. */
resume_ptid = inferior_ptid;
}
+ && (step == RESUME_STEP_USER
+ || singlestep_breakpoints_inserted_p)))
{
- /* User-settable 'scheduler' mode requires solo thread resume. */
+ /* User-settable 'scheduler' mode requires solo thread resume. */
resume_ptid = inferior_ptid;
-@@ -1889,7 +1892,7 @@ proceed (CORE_ADDR addr, enum target_sig
+@@ -1941,7 +1944,7 @@ proceed (CORE_ADDR addr, enum target_sig
struct thread_info *tp;
CORE_ADDR pc;
struct address_space *aspace;
/* If we're stopped at a fork/vfork, follow the branch set by the
"set follow-fork-mode" command; otherwise, we'll just proceed
-@@ -1924,13 +1927,13 @@ proceed (CORE_ADDR addr, enum target_sig
+@@ -1976,13 +1979,13 @@ proceed (CORE_ADDR addr, enum target_sig
actually be executing the breakpoint insn anyway.
We'll be (un-)executing the previous instruction. */
}
else
{
-@@ -1971,13 +1974,13 @@ proceed (CORE_ADDR addr, enum target_sig
+@@ -2023,13 +2026,13 @@ proceed (CORE_ADDR addr, enum target_sig
is required it returns TRUE and sets the current thread to
- the old thread. */
+ the old thread. */
if (prepare_to_proceed (step))
- oneproc = 1;
+ resume_step = RESUME_STEP_USER;
- if (oneproc)
+ if (resume_step == RESUME_STEP_USER)
{
- tp->trap_expected = 1;
+ tp->control.trap_expected = 1;
/* If displaced stepping is enabled, we can step over the
-@@ -2064,8 +2067,13 @@ proceed (CORE_ADDR addr, enum target_sig
+@@ -2116,8 +2119,13 @@ proceed (CORE_ADDR addr, enum target_sig
/* Reset to normal state. */
init_infwait_state ();
+ resume_step = RESUME_STEP_NEEDED;
+
/* Resume inferior. */
-- resume (oneproc || step || bpstat_should_step (), tp->stop_signal);
-+ resume (resume_step, tp->stop_signal);
+- resume (oneproc || step || bpstat_should_step (), tp->suspend.stop_signal);
++ resume (resume_step, tp->suspend.stop_signal);
/* Wait for it to stop (if not standalone)
and in any case decode why it stopped, and act accordingly. */
-@@ -4903,13 +4911,18 @@ infrun: not switching back to stepped th
+@@ -4957,14 +4965,19 @@ process_event_stop_test:
/* Is thread TP in the middle of single-stepping? */
+static enum resume_step
currently_stepping (struct thread_info *tp)
{
-- return ((tp->step_range_end && tp->step_resume_breakpoint == NULL)
-- || tp->trap_expected
-- || tp->stepping_through_solib_after_catch
-- || bpstat_should_step ());
-+ if ((tp->step_range_end && tp->step_resume_breakpoint == NULL)
-+ || tp->trap_expected
+- return ((tp->control.step_range_end
+- && tp->control.step_resume_breakpoint == NULL)
+- || tp->control.trap_expected
+- || tp->stepping_through_solib_after_catch
+- || bpstat_should_step ());
++ if ((tp->control.step_range_end
++ && tp->control.step_resume_breakpoint == NULL)
++ || tp->control.trap_expected
+ || tp->stepping_through_solib_after_catch)
+ return RESUME_STEP_USER;
+
}
/* Returns true if any thread *but* the one passed in "data" is in the
-Index: gdb-7.1.90.20100711/gdb/linux-nat.c
+Index: gdb-7.2.50.20110117/gdb/linux-nat.c
===================================================================
---- gdb-7.1.90.20100711.orig/gdb/linux-nat.c 2010-07-12 10:00:56.000000000 +0200
-+++ gdb-7.1.90.20100711/gdb/linux-nat.c 2010-07-12 10:04:25.000000000 +0200
-@@ -2827,7 +2827,10 @@ count_events_callback (struct lwp_info *
+--- gdb-7.2.50.20110117.orig/gdb/linux-nat.c 2011-01-17 15:47:37.000000000 +0100
++++ gdb-7.2.50.20110117/gdb/linux-nat.c 2011-01-17 15:48:39.000000000 +0100
+@@ -2928,7 +2928,10 @@ count_events_callback (struct lwp_info *
static int
select_singlestep_lwp_callback (struct lwp_info *lp, void *data)
{
return 1;
else
return 0;
-Index: gdb-7.1.90.20100711/gdb/linux-nat.h
+Index: gdb-7.2.50.20110117/gdb/linux-nat.h
===================================================================
---- gdb-7.1.90.20100711.orig/gdb/linux-nat.h 2010-06-11 14:10:12.000000000 +0200
-+++ gdb-7.1.90.20100711/gdb/linux-nat.h 2010-07-12 10:04:25.000000000 +0200
+--- gdb-7.2.50.20110117.orig/gdb/linux-nat.h 2011-01-17 15:47:37.000000000 +0100
++++ gdb-7.2.50.20110117/gdb/linux-nat.h 2011-01-17 15:48:39.000000000 +0100
@@ -55,8 +55,8 @@ struct lwp_info
/* If non-zero, a pending wait status. */
int status;
-Index: gdb-6.8.50.20090811/gdb/linux-nat.c
+Index: gdb-7.2.50.20101116/gdb/linux-nat.c
===================================================================
---- gdb-6.8.50.20090811.orig/gdb/linux-nat.c 2009-08-12 07:21:20.000000000 +0200
-+++ gdb-6.8.50.20090811/gdb/linux-nat.c 2009-08-12 08:11:25.000000000 +0200
-@@ -1656,16 +1656,18 @@ resume_set_callback (struct lwp_info *lp
+--- gdb-7.2.50.20101116.orig/gdb/linux-nat.c 2010-11-16 07:58:15.000000000 +0100
++++ gdb-7.2.50.20101116/gdb/linux-nat.c 2010-11-16 07:59:06.000000000 +0100
+@@ -1863,16 +1863,18 @@ resume_set_callback (struct lwp_info *lp
static void
linux_nat_resume (struct target_ops *ops,
+ (step == RESUME_STEP_NEEDED
+ ? "needed" : (step ? "step" : "resume")),
target_pid_to_str (ptid),
- signo ? strsignal (signo) : "0",
- target_pid_to_str (inferior_ptid));
-@@ -2625,10 +2627,34 @@ linux_nat_filter_event (int lwpid, int s
+ (signo != TARGET_SIGNAL_0
+ ? strsignal (target_signal_to_host (signo)) : "0"),
+@@ -3171,10 +3173,34 @@ linux_nat_filter_event (int lwpid, int s
if (num_lwps (GET_PID (lp->ptid)) > 1)
{
}
/* Convert a native/host siginfo object, into/from the siginfo in the
-Index: gdb-7.0.50.20100115/gdb/linux-nat.c
-===================================================================
---- gdb-7.0.50.20100115.orig/gdb/linux-nat.c 2010-01-15 22:19:27.000000000 +0100
-+++ gdb-7.0.50.20100115/gdb/linux-nat.c 2010-01-15 22:19:55.000000000 +0100
-@@ -1768,8 +1768,22 @@ GPT: lwp %s had signal %s, but it is in
- target_signal_to_string (signo));
- }
-
-- if (*status == 0 && GET_PID (lp->ptid) == pid_was_stopped)
-- *status = W_STOPCODE (SIGSTOP);
-+ /* Workaround RHEL-5 kernel which has unreliable PTRACE_DETACH, SIGSTOP (that
-+ many TIDs are left unstopped). See RH Bug 496732. */
-+ if (GET_PID (lp->ptid) == pid_was_stopped)
-+ {
-+ int err;
-+
-+ errno = 0;
-+ err = kill_lwp (GET_LWP (lp->ptid), SIGSTOP);
-+ if (debug_linux_nat)
-+ {
-+ fprintf_unfiltered (gdb_stdlog,
-+ "SC: lwp kill %d %s\n",
-+ err,
-+ errno ? safe_strerror (errno) : "ERRNO-OK");
-+ }
-+ }
-
- return 0;
- }
Index: gdb-7.0.50.20100115/gdb/testsuite/gdb.threads/attach-stopped.exp
===================================================================
--- gdb-7.0.50.20100115.orig/gdb/testsuite/gdb.threads/attach-stopped.exp 2010-01-01 08:32:06.000000000 +0100
-Index: gdb-7.1.90.20100711/bfd/elf-bfd.h
+Index: gdb-7.2.50.20110320/bfd/elf-bfd.h
===================================================================
---- gdb-7.1.90.20100711.orig/bfd/elf-bfd.h 2010-06-27 06:07:51.000000000 +0200
-+++ gdb-7.1.90.20100711/bfd/elf-bfd.h 2010-07-12 23:00:04.000000000 +0200
-@@ -2171,8 +2171,10 @@ extern Elf_Internal_Phdr * _bfd_elf_find
+--- gdb-7.2.50.20110320.orig/bfd/elf-bfd.h 2011-03-20 15:17:42.000000000 +0100
++++ gdb-7.2.50.20110320/bfd/elf-bfd.h 2011-03-20 15:24:02.000000000 +0100
+@@ -2193,8 +2193,10 @@ extern Elf_Internal_Phdr * _bfd_elf_find
/* Exported interface for writing elf corefile notes. */
extern char *elfcore_write_note
(bfd *, char *, int *, const char *, int, const void *, int);
extern char *elfcore_write_prstatus
(bfd *, char *, int *, long, int, const void *);
extern char * elfcore_write_pstatus
-Index: gdb-7.1.90.20100711/bfd/elf.c
+Index: gdb-7.2.50.20110320/bfd/elf.c
===================================================================
---- gdb-7.1.90.20100711.orig/bfd/elf.c 2010-05-18 05:31:05.000000000 +0200
-+++ gdb-7.1.90.20100711/bfd/elf.c 2010-07-12 22:51:17.000000000 +0200
-@@ -8582,13 +8582,12 @@ elfcore_write_note (bfd *abfd,
+--- gdb-7.2.50.20110320.orig/bfd/elf.c 2011-03-20 15:17:42.000000000 +0100
++++ gdb-7.2.50.20110320/bfd/elf.c 2011-03-20 15:24:02.000000000 +0100
+@@ -8814,13 +8814,12 @@ elfcore_write_note (bfd *abfd,
return buf;
}
{
const char *note_name = "CORE";
const struct elf_backend_data *bed = get_elf_backend_data (abfd);
-@@ -8596,48 +8595,55 @@ elfcore_write_prpsinfo (bfd *abfd,
+@@ -8828,48 +8827,55 @@ elfcore_write_prpsinfo (bfd *abfd,
if (bed->elf_backend_write_core_note != NULL)
{
char *ret;
#if defined (HAVE_PRSTATUS_T)
char *
-Index: gdb-7.1.90.20100711/gdb/linux-nat.c
+Index: gdb-7.2.50.20110320/gdb/linux-nat.c
===================================================================
---- gdb-7.1.90.20100711.orig/gdb/linux-nat.c 2010-07-12 23:05:22.000000000 +0200
-+++ gdb-7.1.90.20100711/gdb/linux-nat.c 2010-07-12 22:57:34.000000000 +0200
-@@ -4466,6 +4466,131 @@ linux_spu_make_corefile_notes (bfd *obfd
+--- gdb-7.2.50.20110320.orig/gdb/linux-nat.c 2011-03-20 15:17:46.000000000 +0100
++++ gdb-7.2.50.20110320/gdb/linux-nat.c 2011-03-20 15:25:36.000000000 +0100
+@@ -4603,6 +4603,131 @@ linux_spu_make_corefile_notes (bfd *obfd
return args.note_data;
}
/* Fills the "to_make_corefile_note" target vector. Builds the note
section for a corefile, and returns it in a malloc buffer. */
-@@ -4484,26 +4609,11 @@ linux_nat_make_corefile_notes (bfd *obfd
+@@ -4621,26 +4746,11 @@ linux_nat_make_corefile_notes (bfd *obfd
if (get_exec_file (0))
{
-- strncpy (fname, strrchr (get_exec_file (0), '/') + 1, sizeof (fname));
+- strncpy (fname, lbasename (get_exec_file (0)), sizeof (fname));
- strncpy (psargs, get_exec_file (0), sizeof (psargs));
- if (get_inferior_args ())
- {
}
/* Dump information for threads. */
-Index: gdb-7.1.90.20100711/gdb/procfs.c
+Index: gdb-7.2.50.20110320/gdb/procfs.c
===================================================================
---- gdb-7.1.90.20100711.orig/gdb/procfs.c 2010-07-07 18:15:16.000000000 +0200
-+++ gdb-7.1.90.20100711/gdb/procfs.c 2010-07-12 23:05:23.000000000 +0200
-@@ -5770,6 +5770,7 @@ procfs_make_note_section (bfd *obfd, int
+--- gdb-7.2.50.20110320.orig/gdb/procfs.c 2011-03-09 13:48:55.000000000 +0100
++++ gdb-7.2.50.20110320/gdb/procfs.c 2011-03-20 15:24:02.000000000 +0100
+@@ -5752,6 +5752,7 @@ procfs_make_note_section (bfd *obfd, int
note_data = (char *) elfcore_write_prpsinfo (obfd,
note_data,
note_size,
+gdb_run_cmd ${binfile_nothreads} ${binfile_threads} 0
gdb_test_multiple {} "Program exited" {
- -re "\r\nProgram exited normally.\r\n$gdb_prompt $" {
+ -re "\r\n\\\[Inferior .* exited normally\\\]\r\n$gdb_prompt $" {
should have been detached with SIGSTOP (as they are accidentally left running
on the debugger termination).
-Index: gdb-6.8.50.20081128/gdb/defs.h
+Index: gdb-7.2.50.20110117/gdb/defs.h
===================================================================
---- gdb-6.8.50.20081128.orig/gdb/defs.h 2008-11-27 10:23:01.000000000 +0100
-+++ gdb-6.8.50.20081128/gdb/defs.h 2008-12-06 21:49:32.000000000 +0100
-@@ -155,6 +155,7 @@ extern char *gdb_sysroot;
+--- gdb-7.2.50.20110117.orig/gdb/defs.h 2011-01-17 15:47:37.000000000 +0100
++++ gdb-7.2.50.20110117/gdb/defs.h 2011-01-17 15:53:05.000000000 +0100
+@@ -165,6 +165,7 @@ extern char *python_libdir;
extern char *debug_file_directory;
extern int quit_flag;
extern int immediate_quit;
extern int sevenbit_strings;
-@@ -168,7 +169,7 @@ extern void quit (void);
- needed. */
+@@ -178,7 +179,7 @@ extern void quit (void);
+ needed. */
#define QUIT { \
- if (quit_flag) quit (); \
if (deprecated_interactive_hook) deprecated_interactive_hook (); \
}
-Index: gdb-6.8.50.20081128/gdb/event-top.c
+Index: gdb-7.2.50.20110117/gdb/event-top.c
===================================================================
---- gdb-6.8.50.20081128.orig/gdb/event-top.c 2008-12-04 10:34:31.000000000 +0100
-+++ gdb-6.8.50.20081128/gdb/event-top.c 2008-12-06 21:49:07.000000000 +0100
-@@ -939,7 +939,7 @@ async_request_quit (gdb_client_data arg)
+--- gdb-7.2.50.20110117.orig/gdb/event-top.c 2011-01-17 15:52:39.000000000 +0100
++++ gdb-7.2.50.20110117/gdb/event-top.c 2011-01-17 15:52:49.000000000 +0100
+@@ -904,7 +904,7 @@ async_request_quit (gdb_client_data arg)
is no reason to call quit again here, unless immediate_quit is
- set.*/
+ set. */
- if (quit_flag || immediate_quit)
+ if ((quit_flag || immediate_quit) && !quit_flag_cleanup)
quit ();
}
-Index: gdb-6.8.50.20081128/gdb/top.c
+Index: gdb-7.2.50.20110117/gdb/top.c
===================================================================
---- gdb-6.8.50.20081128.orig/gdb/top.c 2008-12-04 10:23:12.000000000 +0100
-+++ gdb-6.8.50.20081128/gdb/top.c 2008-12-06 21:49:07.000000000 +0100
-@@ -1299,7 +1299,9 @@ quit_force (char *args, int from_tty)
+--- gdb-7.2.50.20110117.orig/gdb/top.c 2011-01-17 15:47:37.000000000 +0100
++++ gdb-7.2.50.20110117/gdb/top.c 2011-01-17 15:52:49.000000000 +0100
+@@ -1257,7 +1257,9 @@ quit_force (char *args, int from_tty)
qt.args = args;
qt.from_tty = from_tty;
catch_errors (quit_target, &qt,
"Quitting: ", RETURN_MASK_ALL);
-Index: gdb-6.8.50.20081128/gdb/utils.c
+Index: gdb-7.2.50.20110117/gdb/utils.c
===================================================================
---- gdb-6.8.50.20081128.orig/gdb/utils.c 2008-12-04 10:31:00.000000000 +0100
-+++ gdb-6.8.50.20081128/gdb/utils.c 2008-12-06 21:49:07.000000000 +0100
-@@ -114,6 +114,11 @@ int job_control;
+--- gdb-7.2.50.20110117.orig/gdb/utils.c 2011-01-17 15:47:37.000000000 +0100
++++ gdb-7.2.50.20110117/gdb/utils.c 2011-01-17 15:52:49.000000000 +0100
+@@ -121,6 +121,11 @@ int job_control;
int quit_flag;
--- /dev/null
+--- gdb-7.2.50.20110328.orig/gdb/dwarf2read.c 2011-03-30 12:52:20.395450001 +0200
++++ gdb-7.2.50.20110328/gdb/dwarf2read.c 2011-03-30 13:41:55.485450006 +0200
+@@ -66,12 +66,14 @@
+ #ifdef HAVE_ZLIB_H
+ #include <zlib.h>
+ #endif
++#ifndef __sparc__
+ #ifdef HAVE_MMAP
+ #include <sys/mman.h>
+ #ifndef MAP_FAILED
+ #define MAP_FAILED ((void *) -1)
+ #endif
+ #endif
++#endif
+
+ typedef struct symbol *symbolp;
+ DEF_VEC_P (symbolp);
+@@ -1563,6 +1565,7 @@
+ }
+ }
+
++#ifndef __sparc__
+ #ifdef HAVE_MMAP
+ if (pagesize == 0)
+ pagesize = getpagesize ();
+@@ -1589,6 +1592,7 @@
+ }
+ }
+ #endif
++#endif
+
+ /* If we get here, we are a normal, not-compressed section. */
+ info->buffer = buf
+@@ -15439,6 +15443,7 @@
+ {
+ if (info->was_mmapped)
+ {
++#ifndef __sparc__
+ #ifdef HAVE_MMAP
+ intptr_t begin = (intptr_t) info->buffer;
+ intptr_t map_begin = begin & ~(pagesize - 1);
+@@ -15449,6 +15454,7 @@
+ /* Without HAVE_MMAP, we should never be here to begin with. */
+ gdb_assert_not_reached ("no mmap support");
+ #endif
++#endif
+ }
+ }
+
-Index: gdb-7.1.90.20100711/gdb/breakpoint.c
+Index: gdb-7.2.90.20110411/gdb/breakpoint.c
===================================================================
---- gdb-7.1.90.20100711.orig/gdb/breakpoint.c 2010-07-12 23:07:33.000000000 +0200
-+++ gdb-7.1.90.20100711/gdb/breakpoint.c 2010-07-13 00:38:04.000000000 +0200
-@@ -10159,6 +10159,50 @@ update_breakpoint_locations (struct brea
- update_global_location_list (1);
+--- gdb-7.2.90.20110411.orig/gdb/breakpoint.c 2011-04-11 19:11:55.000000000 +0200
++++ gdb-7.2.90.20110411/gdb/breakpoint.c 2011-04-11 19:18:10.000000000 +0200
+@@ -11233,6 +11233,50 @@ re_set_breakpoint (struct breakpoint *b)
+ do_cleanups (cleanups);
}
+void
/* Reset a breakpoint given it's struct breakpoint * BINT.
The value we return ends up being the return value from catch_errors.
Unused in this case. */
-Index: gdb-7.1.90.20100711/gdb/breakpoint.h
+Index: gdb-7.2.90.20110411/gdb/breakpoint.h
===================================================================
---- gdb-7.1.90.20100711.orig/gdb/breakpoint.h 2010-07-12 23:07:33.000000000 +0200
-+++ gdb-7.1.90.20100711/gdb/breakpoint.h 2010-07-13 00:37:34.000000000 +0200
-@@ -1088,4 +1088,7 @@ extern void check_tracepoint_command (ch
- extern void start_rbreak_breakpoints (void);
- extern void end_rbreak_breakpoints (void);
+--- gdb-7.2.90.20110411.orig/gdb/breakpoint.h 2011-04-11 19:11:55.000000000 +0200
++++ gdb-7.2.90.20110411/gdb/breakpoint.h 2011-04-11 19:17:53.000000000 +0200
+@@ -1245,4 +1245,7 @@ extern int user_breakpoint_p (struct bre
+
+ extern void modify_semaphore (struct bp_location *location, int set);
+extern void breakpoints_relocate (struct objfile *objfile,
+ struct section_offsets *delta);
+
#endif /* !defined (BREAKPOINT_H) */
-Index: gdb-7.1.90.20100711/gdb/objfiles.c
+Index: gdb-7.2.90.20110411/gdb/objfiles.c
===================================================================
---- gdb-7.1.90.20100711.orig/gdb/objfiles.c 2010-05-16 02:46:46.000000000 +0200
-+++ gdb-7.1.90.20100711/gdb/objfiles.c 2010-07-13 00:37:19.000000000 +0200
-@@ -834,6 +834,11 @@ objfile_relocate1 (struct objfile *objfi
- obj_section_addr (s));
- }
+--- gdb-7.2.90.20110411.orig/gdb/objfiles.c 2011-04-11 19:11:55.000000000 +0200
++++ gdb-7.2.90.20110411/gdb/objfiles.c 2011-04-11 19:17:53.000000000 +0200
+@@ -851,6 +851,11 @@ objfile_relocate1 (struct objfile *objfi
+ objfile->sf->sym_probe_fns->sym_relocate_probe (objfile,
+ new_offsets, delta);
+ /* Final call of breakpoint_re_set can keep breakpoint locations disabled if
+ their addresses match. */
-Index: gdb-7.1.90.20100711/gdb/dwarf2read.c
+Index: gdb-7.2.90.20110525/gdb/dwarf2read.c
===================================================================
---- gdb-7.1.90.20100711.orig/gdb/dwarf2read.c 2010-07-13 00:26:25.000000000 +0200
-+++ gdb-7.1.90.20100711/gdb/dwarf2read.c 2010-07-13 00:34:00.000000000 +0200
-@@ -5737,7 +5737,12 @@ read_common_block (struct die_info *die,
+--- gdb-7.2.90.20110525.orig/gdb/dwarf2read.c 2011-05-25 17:10:46.000000000 +0200
++++ gdb-7.2.90.20110525/gdb/dwarf2read.c 2011-05-25 17:12:35.000000000 +0200
+@@ -7675,7 +7675,12 @@ read_common_block (struct die_info *die,
{
struct attribute *attr;
struct symbol *sym;
attr = dwarf2_attr (die, DW_AT_location, cu);
if (attr)
-@@ -5746,6 +5751,7 @@ read_common_block (struct die_info *die,
+@@ -7684,6 +7689,7 @@ read_common_block (struct die_info *die,
if (attr_form_is_block (attr))
{
base = decode_locdesc (DW_BLOCK (attr), cu);
}
else if (attr_form_is_section_offset (attr))
{
-@@ -5807,12 +5813,15 @@ read_common_block (struct die_info *die,
- else
- dwarf2_complex_location_expr_complaint ();
-
-- SYMBOL_VALUE_ADDRESS (sym) = base + byte_offset;
+@@ -7736,12 +7742,15 @@ read_common_block (struct die_info *die,
+ if (sym != NULL
+ && handle_data_member_location (child_die, cu, &offset))
+ {
+- SYMBOL_VALUE_ADDRESS (sym) = base + offset;
+ if (!base_p)
+ dwarf2_invalid_attrib_class_complaint
+ ("DW_AT_data_member_location", "common block member");
-+ SYMBOL_VALUE_ADDRESS (sym) = base + byte_offset + baseaddr;
++ SYMBOL_VALUE_ADDRESS (sym) = base + offset + baseaddr;
add_symbol_to_list (sym, &global_symbols);
}
else
SET_FIELD_PHYSNAME (*field, SYMBOL_LINKAGE_NAME (sym));
FIELD_TYPE (*field) = SYMBOL_TYPE (sym);
-@@ -5826,7 +5835,7 @@ read_common_block (struct die_info *die,
+@@ -7755,7 +7764,7 @@ read_common_block (struct die_info *die,
sym = new_symbol (die, type, cu);
/* SYMBOL_VALUE_ADDRESS never gets used as all its fields are static. */
set_die_type (die, type, cu);
}
-Index: gdb-7.1.90.20100711/gdb/gdbtypes.h
+Index: gdb-7.2.90.20110525/gdb/gdbtypes.h
===================================================================
---- gdb-7.1.90.20100711.orig/gdb/gdbtypes.h 2010-07-12 23:07:34.000000000 +0200
-+++ gdb-7.1.90.20100711/gdb/gdbtypes.h 2010-07-13 00:34:00.000000000 +0200
-@@ -395,6 +395,7 @@ enum type_instance_flag_value
+--- gdb-7.2.90.20110525.orig/gdb/gdbtypes.h 2011-05-25 17:05:21.000000000 +0200
++++ gdb-7.2.90.20110525/gdb/gdbtypes.h 2011-05-25 17:11:10.000000000 +0200
+@@ -396,6 +396,7 @@ enum type_instance_flag_value
enum field_loc_kind
{
FIELD_LOC_KIND_BITPOS, /* bitpos */
FIELD_LOC_KIND_PHYSADDR, /* physaddr */
FIELD_LOC_KIND_PHYSNAME /* physname */
};
-@@ -577,6 +578,7 @@ struct main_type
+@@ -580,6 +581,7 @@ struct main_type
is the location (in the target) of the static field.
- Otherwise, physname is the mangled label of the static field. */
+ Otherwise, physname is the mangled label of the static field. */
+ /* This address is unrelocated by the objfile's ANOFFSET. */
CORE_ADDR physaddr;
char *physname;
}
-@@ -1073,6 +1075,7 @@ extern void allocate_gnat_aux_type (stru
+@@ -1106,6 +1108,7 @@ extern void allocate_gnat_aux_type (stru
#define FIELD_LOC_KIND(thisfld) ((thisfld).loc_kind)
#define FIELD_BITPOS(thisfld) ((thisfld).loc.bitpos)
#define FIELD_STATIC_PHYSNAME(thisfld) ((thisfld).loc.physname)
#define FIELD_STATIC_PHYSADDR(thisfld) ((thisfld).loc.physaddr)
#define SET_FIELD_BITPOS(thisfld, bitpos) \
(FIELD_LOC_KIND (thisfld) = FIELD_LOC_KIND_BITPOS, \
-@@ -1080,6 +1083,7 @@ extern void allocate_gnat_aux_type (stru
+@@ -1113,6 +1116,7 @@ extern void allocate_gnat_aux_type (stru
#define SET_FIELD_PHYSNAME(thisfld, name) \
(FIELD_LOC_KIND (thisfld) = FIELD_LOC_KIND_PHYSNAME, \
FIELD_STATIC_PHYSNAME (thisfld) = (name))
#define SET_FIELD_PHYSADDR(thisfld, addr) \
(FIELD_LOC_KIND (thisfld) = FIELD_LOC_KIND_PHYSADDR, \
FIELD_STATIC_PHYSADDR (thisfld) = (addr))
-@@ -1092,6 +1096,7 @@ extern void allocate_gnat_aux_type (stru
+@@ -1125,6 +1129,7 @@ extern void allocate_gnat_aux_type (stru
#define TYPE_FIELD_LOC_KIND(thistype, n) FIELD_LOC_KIND (TYPE_FIELD (thistype, n))
#define TYPE_FIELD_BITPOS(thistype, n) FIELD_BITPOS (TYPE_FIELD (thistype, n))
#define TYPE_FIELD_STATIC_PHYSNAME(thistype, n) FIELD_STATIC_PHYSNAME (TYPE_FIELD (thistype, n))
#define TYPE_FIELD_STATIC_PHYSADDR(thistype, n) FIELD_STATIC_PHYSADDR (TYPE_FIELD (thistype, n))
#define TYPE_FIELD_ARTIFICIAL(thistype, n) FIELD_ARTIFICIAL(TYPE_FIELD(thistype,n))
#define TYPE_FIELD_BITSIZE(thistype, n) FIELD_BITSIZE(TYPE_FIELD(thistype,n))
-Index: gdb-7.1.90.20100711/gdb/jv-lang.c
+Index: gdb-7.2.90.20110525/gdb/jv-lang.c
===================================================================
---- gdb-7.1.90.20100711.orig/gdb/jv-lang.c 2010-05-17 19:18:39.000000000 +0200
-+++ gdb-7.1.90.20100711/gdb/jv-lang.c 2010-07-13 00:34:00.000000000 +0200
-@@ -409,7 +409,8 @@ java_link_class_type (struct gdbarch *gd
+--- gdb-7.2.90.20110525.orig/gdb/jv-lang.c 2011-03-02 01:42:53.000000000 +0100
++++ gdb-7.2.90.20110525/gdb/jv-lang.c 2011-05-25 17:11:10.000000000 +0200
+@@ -414,7 +414,8 @@ java_link_class_type (struct gdbarch *gd
fields = NULL;
- nfields--; /* First set up dummy "class" field. */
+ nfields--; /* First set up dummy "class" field. */
- SET_FIELD_PHYSADDR (TYPE_FIELD (type, nfields), value_address (clas));
+ SET_FIELD_PHYSADDR (TYPE_FIELD (type, nfields), value_address (clas)
+ - (TYPE_OBJFILE (type) == NULL ? 0 : ANOFFSET (TYPE_OBJFILE (type)->section_offsets, SECT_OFF_TEXT (TYPE_OBJFILE (type)))));
TYPE_FIELD_NAME (type, nfields) = "class";
TYPE_FIELD_TYPE (type, nfields) = value_type (clas);
SET_TYPE_FIELD_PRIVATE (type, nfields);
-@@ -457,7 +458,8 @@ java_link_class_type (struct gdbarch *gd
+@@ -462,7 +463,8 @@ java_link_class_type (struct gdbarch *gd
SET_TYPE_FIELD_PROTECTED (type, i);
}
if (accflags & 0x0008) /* ACC_STATIC */
else
TYPE_FIELD_BITPOS (type, i) = 8 * boffset;
if (accflags & 0x8000) /* FIELD_UNRESOLVED_FLAG */
-Index: gdb-7.1.90.20100711/gdb/value.c
+Index: gdb-7.2.90.20110525/gdb/value.c
===================================================================
---- gdb-7.1.90.20100711.orig/gdb/value.c 2010-07-12 23:07:33.000000000 +0200
-+++ gdb-7.1.90.20100711/gdb/value.c 2010-07-13 00:35:21.000000000 +0200
-@@ -1943,7 +1943,8 @@ value_static_field (struct type *type, i
+--- gdb-7.2.90.20110525.orig/gdb/value.c 2011-05-25 17:05:21.000000000 +0200
++++ gdb-7.2.90.20110525/gdb/value.c 2011-05-25 17:11:10.000000000 +0200
+@@ -2492,7 +2492,8 @@ value_static_field (struct type *type, i
{
case FIELD_LOC_KIND_PHYSADDR:
retval = value_at_lazy (TYPE_FIELD_TYPE (type, fieldno),
break;
case FIELD_LOC_KIND_PHYSNAME:
{
-@@ -1977,7 +1978,8 @@ value_static_field (struct type *type, i
- }
- if (retval && VALUE_LVAL (retval) == lval_memory)
- SET_FIELD_PHYSADDR (TYPE_FIELD (type, fieldno),
-- value_address (retval));
-+ value_address (retval)
-+ - (TYPE_OBJFILE (type) == NULL ? 0 : ANOFFSET (TYPE_OBJFILE (type)->section_offsets, SECT_OFF_TEXT (TYPE_OBJFILE (type)))));
- break;
- }
- default:
http://sourceware.org/gdb/wiki/ArcherBranchManagement
GIT snapshot:
-commit 74fff58d0076fe97c6c99d65fa58126315266646
+commit 42fbc89fd3a797da9880ecbc467c32f282acf31f
branch `archer' - the merge of branches:
archer-jankratochvil-vla
archer-jankratochvil-watchpoint3
-archer-jankratochvil-ifunc
-archer-pmuldoon-next-over-throw2
-archer-tromey-python (not a merge)
-archer-tromey-optional-psymtab (cherry-picked from post-7.2 master)
-#TODO:archer-tromey-threaded-dwarf
+archer-tromey-python
+archer-sergiodj-stap-fedora15jk
-diff --git a/gdb/Makefile.in b/gdb/Makefile.in
-index f07bc8b..3703dca 100644
---- a/gdb/Makefile.in
-+++ b/gdb/Makefile.in
-@@ -169,6 +169,12 @@ TARGET_SYSTEM_ROOT = @TARGET_SYSTEM_ROOT@
- TARGET_SYSTEM_ROOT_DEFINE = @TARGET_SYSTEM_ROOT_DEFINE@
-
- # Did the user give us a --with-gdb-datadir option?
-+GDB_DATADIR_PATH = @GDB_DATADIR_PATH@
-+
-+# The argument to --with-pythondir. If not given, this is
-+# GDB_DATADIR_PATH/python.
-+pythondir = @pythondir@
-+
- GDB_DATADIR = @GDB_DATADIR@
-
- # Helper code from gnulib.
-@@ -295,13 +301,13 @@ SUBDIR_PYTHON_SRCS = \
- python/py-cmd.c \
- python/py-frame.c \
- python/py-function.c \
-+ python/py-hooks.c \
- python/py-inferior.c \
- python/py-infthread.c \
- python/py-lazy-string.c \
- python/py-objfile.c \
- python/py-param.c \
- python/py-prettyprint.c \
-- python/py-progspace.c \
- python/py-symbol.c \
- python/py-symtab.c \
- python/py-type.c \
-@@ -780,8 +786,8 @@ config/rs6000/nm-rs6000.h top.h bsd-kvm.h gdb-stabs.h reggroups.h \
- annotate.h sim-regno.h dictionary.h dfp.h main.h frame-unwind.h \
- remote-fileio.h i386-linux-tdep.h vax-tdep.h objc-lang.h \
- sentinel-frame.h bcache.h symfile.h windows-tdep.h linux-tdep.h \
--gdb_usleep.h jit.h xml-syscall.h ada-operator.inc microblaze-tdep.h \
--psymtab.h psympriv.h
-+gdb_usleep.h jit.h python/python.h python/python-internal.h \
-+xml-syscall.h ada-operator.inc microblaze-tdep.h
+Index: gdb-7.2.90.20110703/bfd/elf-bfd.h
+===================================================================
+--- gdb-7.2.90.20110703.orig/bfd/elf-bfd.h 2011-03-14 16:54:57.000000000 +0100
++++ gdb-7.2.90.20110703/bfd/elf-bfd.h 2011-07-03 10:33:11.000000000 +0200
+@@ -1476,6 +1476,15 @@ enum
+ Tag_compatibility = 32
+ };
+
++/* The following struct stores information about every SystemTap section
++ found in the object file. */
++struct sdt_note
++{
++ struct sdt_note *next;
++ bfd_size_type size;
++ bfd_byte data[1];
++};
++
+ /* Some private data is stashed away for future use using the tdata pointer
+ in the bfd structure. */
+
+@@ -1633,6 +1642,11 @@ struct elf_obj_tdata
+ bfd_size_type build_id_size;
+ bfd_byte *build_id;
+
++ /* Linked-list containing information about every Systemtap section
++ found in the object file. Each section corresponds to one entry
++ in the list. */
++ struct sdt_note *sdt_note_head;
++
+ /* True if the bfd contains symbols that have the STT_GNU_IFUNC
+ symbol type. Used to set the osabi field in the ELF header
+ structure. */
+Index: gdb-7.2.90.20110703/bfd/elf.c
+===================================================================
+--- gdb-7.2.90.20110703.orig/bfd/elf.c 2011-03-14 16:54:58.000000000 +0100
++++ gdb-7.2.90.20110703/bfd/elf.c 2011-07-03 10:33:11.000000000 +0200
+@@ -8416,6 +8416,37 @@ elfobj_grok_gnu_note (bfd *abfd, Elf_Int
+ }
+ }
+
++#define SDT_NOTE_TYPE 3
++
++static bfd_boolean
++elfobj_grok_stapsdt_note_1 (bfd *abfd, Elf_Internal_Note *note)
++{
++ struct sdt_note *cur =
++ (struct sdt_note *) bfd_alloc (abfd, sizeof (struct sdt_note)
++ + note->descsz);
++
++ cur->next = (struct sdt_note *) (elf_tdata (abfd))->sdt_note_head;
++ cur->size = (bfd_size_type) note->descsz;
++ memcpy (cur->data, note->descdata, note->descsz);
++
++ elf_tdata (abfd)->sdt_note_head = cur;
++
++ return TRUE;
++}
++
++static bfd_boolean
++elfobj_grok_stapsdt_note (bfd *abfd, Elf_Internal_Note *note)
++{
++ switch (note->type)
++ {
++ case SDT_NOTE_TYPE:
++ return elfobj_grok_stapsdt_note_1 (abfd, note);
++
++ default:
++ return TRUE;
++ }
++}
++
+ static bfd_boolean
+ elfcore_netbsd_get_lwpid (Elf_Internal_Note *note, int *lwpidp)
+ {
+@@ -9189,6 +9220,12 @@ elf_parse_notes (bfd *abfd, char *buf, s
+ if (! elfobj_grok_gnu_note (abfd, &in))
+ return FALSE;
+ }
++ else if (in.namesz == sizeof "stapsdt"
++ && strcmp (in.namedata, "stapsdt") == 0)
++ {
++ if (! elfobj_grok_stapsdt_note (abfd, &in))
++ return FALSE;
++ }
+ break;
+ }
+
+Index: gdb-7.2.90.20110703/gdb/Makefile.in
+===================================================================
+--- gdb-7.2.90.20110703.orig/gdb/Makefile.in 2011-03-30 08:55:39.000000000 +0200
++++ gdb-7.2.90.20110703/gdb/Makefile.in 2011-07-03 10:33:11.000000000 +0200
+@@ -721,8 +721,8 @@ SFILES = ada-exp.y ada-lang.c ada-typepr
+ sentinel-frame.c \
+ serial.c ser-base.c ser-unix.c \
+ solib.c solib-target.c source.c \
+- stabsread.c stack.c std-regs.c symfile.c symfile-mem.c symmisc.c \
+- symtab.c \
++ stabsread.c stack.c stap-probe.c std-regs.c \
++ symfile.c symfile-mem.c symmisc.c symtab.c \
+ target.c target-descriptions.c target-memory.c \
+ thread.c top.c tracepoint.c \
+ trad-frame.c \
+@@ -814,7 +814,7 @@ osdata.h procfs.h python/py-event.h pyth
+ python/python-internal.h python/python.h ravenscar-thread.h record.h \
+ solib-darwin.h solib-ia64-hpux.h solib-spu.h windows-nat.h xcoffread.h \
+ gnulib/extra/arg-nonnull.h gnulib/extra/c++defs.h gnulib/extra/warn-on-use.h \
+-gnulib/stddef.in.h inline-frame.h
++gnulib/stddef.in.h inline-frame.h stap-probe.h
# Header files that already have srcdir in them, or which are in objdir.
-@@ -1301,6 +1307,12 @@ stamp-h: $(srcdir)/config.in config.status
+@@ -899,7 +899,7 @@ COMMON_OBS = $(DEPFILES) $(CONFIG_OBS) $
+ prologue-value.o memory-map.o memrange.o xml-support.o xml-syscall.o \
+ target-descriptions.o target-memory.o xml-tdesc.o xml-builtin.o \
+ inferior.o osdata.o gdb_usleep.o record.o gcore.o \
+- jit.o progspace.o
++ jit.o progspace.o stap-probe.o
+
+ TSOBS = inflow.o
+
+@@ -1320,6 +1320,12 @@ stamp-h: $(srcdir)/config.in config.stat
CONFIG_LINKS= \
$(SHELL) config.status
config.status: $(srcdir)/configure configure.tgt configure.host
$(SHELL) config.status --recheck
-@@ -2024,6 +2036,10 @@ py-function.o: $(srcdir)/python/py-function.c
- $(COMPILE) $(PYTHON_CFLAGS) $(srcdir)/python/py-function.c
- $(POSTCOMPILE)
-
-+py-hooks.o: $(srcdir)/python/py-hooks.c
-+ $(COMPILE) $(PYTHON_CFLAGS) $(srcdir)/python/py-hooks.c
-+ $(POSTCOMPILE)
-+
- py-inferior.o: $(srcdir)/python/py-inferior.c
- $(COMPILE) $(PYTHON_CFLAGS) $(srcdir)/python/py-inferior.c
- $(POSTCOMPILE)
-@@ -2072,6 +2088,36 @@ py-value.o: $(srcdir)/python/py-value.c
- $(COMPILE) $(PYTHON_CFLAGS) $(srcdir)/python/py-value.c
- $(POSTCOMPILE)
-
-+# All python library files, with the "python/lib" stripped off.
-+# Note that we should only install files in the "gdb" module.
-+PY_FILES = gdb/FrameIterator.py gdb/FrameWrapper.py gdb/command/alias.py \
-+ gdb/command/backtrace.py gdb/command/require.py \
-+ gdb/command/pahole.py gdb/command/upto.py gdb/command/__init__.py \
-+ gdb/command/ignore_errors.py gdb/command/save_breakpoints.py \
-+ gdb/function/caller_is.py gdb/function/in_scope.py \
-+ gdb/function/__init__.py gdb/backtrace.py gdb/__init__.py
-+
-+# Install the Python library. Python library files go under
-+# $(pythondir).
-+install-python:
-+ files='$(PY_FILES)'; for file in $$files; do \
-+ dir=`echo "$$file" | sed 's,/[^/]*$$,,'`; \
-+ $(SHELL) $(srcdir)/../mkinstalldirs $(DESTDIR)$(pythondir)/$$dir; \
-+ $(INSTALL_DATA) $(srcdir)/python/lib/$$file $(DESTDIR)$(pythondir)/$$file; \
-+ done
-+
-+# Other packages may have their files installed in $(pythondir).
-+uninstall-python:
-+ files='$(PY_FILES)'; for file in $$files; do \
-+ slashdir=`echo "/$$file" | sed 's,/[^/]*$$,,'`; \
-+ rm -f $(DESTDIR)$(pythondir)/$$file; \
-+ while test "x$$file" != "x$$slashdir"; do \
-+ rmdir 2>/dev/null "$(DESTDIR)$(pythondir)$$slashdir"; \
-+ file="$$slashdir"; \
-+ slashdir=`echo "$$file" | sed 's,/[^/]*$$,,'`; \
-+ done \
-+ done
-+
- #
- # Dependency tracking. Most of this is conditional on GNU Make being
- # found by configure; if GNU Make is not found, we fall back to a
-diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
-index 1d4c38b..cafb88e 100644
---- a/gdb/ada-lang.c
-+++ b/gdb/ada-lang.c
-@@ -11114,6 +11114,7 @@ ada_operator_length (const struct expression *exp, int pc, int *oplenp,
+Index: gdb-7.2.90.20110703/gdb/NEWS
+===================================================================
+--- gdb-7.2.90.20110703.orig/gdb/NEWS 2011-03-31 16:32:48.000000000 +0200
++++ gdb-7.2.90.20110703/gdb/NEWS 2011-07-03 10:33:11.000000000 +0200
+@@ -36,6 +36,10 @@
+ Initial support for the OpenCL C language (http://www.khronos.org/opencl)
+ has been integrated into GDB.
+
++* GDB now has support for SystemTap <sys/sdt.h> probes. You can set a
++ breakpoint using the new "probe:" linespec and inspect the probe
++ arguments using the new $_probe_arg family of convenience variables.
++
+ * Python scripting
+
+ ** The function gdb.Write now accepts an optional keyword 'stream'.
+Index: gdb-7.2.90.20110703/gdb/ada-lang.c
+===================================================================
+--- gdb-7.2.90.20110703.orig/gdb/ada-lang.c 2011-05-17 23:26:08.000000000 +0200
++++ gdb-7.2.90.20110703/gdb/ada-lang.c 2011-07-03 10:33:11.000000000 +0200
+@@ -11421,6 +11421,7 @@ ada_operator_length (const struct expres
static int
ada_operator_check (struct expression *exp, int pos,
int (*objfile_func) (struct objfile *objfile, void *data),
void *data)
{
-@@ -11128,12 +11129,15 @@ ada_operator_check (struct expression *exp, int pos,
+@@ -11435,12 +11436,15 @@ ada_operator_check (struct expression *e
break;
default:
&& (*objfile_func) (TYPE_OBJFILE (type), data))
return 1;
-diff --git a/gdb/amd64-linux-nat.c b/gdb/amd64-linux-nat.c
-index c0edc10..17d36b5 100644
---- a/gdb/amd64-linux-nat.c
-+++ b/gdb/amd64-linux-nat.c
-@@ -375,6 +375,20 @@ amd64_linux_dr_unset_status (unsigned long mask)
- }
+Index: gdb-7.2.90.20110703/gdb/amd64-linux-nat.c
+===================================================================
+--- gdb-7.2.90.20110703.orig/gdb/amd64-linux-nat.c 2011-01-07 20:36:15.000000000 +0100
++++ gdb-7.2.90.20110703/gdb/amd64-linux-nat.c 2011-07-03 10:33:11.000000000 +0200
+@@ -265,18 +265,11 @@ amd64_linux_store_inferior_registers (st
+ \f
+ /* Support for debug registers. */
+
+-static unsigned long amd64_linux_dr[DR_CONTROL + 1];
+-
+ static unsigned long
+-amd64_linux_dr_get (ptid_t ptid, int regnum)
++amd64_linux_dr_get (int tid, int regnum)
+ {
+- int tid;
+ unsigned long value;
+
+- tid = TIDGET (ptid);
+- if (tid == 0)
+- tid = PIDGET (ptid);
+-
+ /* FIXME: kettenis/2001-03-27: Calling perror_with_name if the
+ ptrace call fails breaks debugging remote targets. The correct
+ way to fix this is to add the hardware breakpoint and watchpoint
+@@ -298,14 +291,8 @@ amd64_linux_dr_get (ptid_t ptid, int reg
+ /* Set debug register REGNUM to VALUE in only the one LWP of PTID. */
+
+ static void
+-amd64_linux_dr_set (ptid_t ptid, int regnum, unsigned long value)
++amd64_linux_dr_set (int tid, int regnum, unsigned long value)
+ {
+- int tid;
+-
+- tid = TIDGET (ptid);
+- if (tid == 0)
+- tid = PIDGET (ptid);
+-
+ errno = 0;
+ ptrace (PTRACE_POKEUSER, tid,
+ offsetof (struct user, u_debugreg[regnum]), value);
+@@ -313,35 +300,96 @@ amd64_linux_dr_set (ptid_t ptid, int reg
+ perror_with_name (_("Couldn't write debug register"));
}
-+/* See i386_dr_low_type.detach. Do not use wrappers amd64_linux_dr_set_control
-+ or amd64_linux_dr_reset_addr as they would modify the register cache
-+ (amd64_linux_dr). */
+-/* Set DR_CONTROL to ADDR in all LWPs of LWP_LIST. */
++/* Helper for amd64_linux_dr_set_control. */
++
++static void
++amd64_linux_dr_set_control_callback (int tid, void *control_voidp)
++{
++ unsigned long control = *(unsigned long *) control_voidp;
++
++ amd64_linux_dr_set (tid, DR_CONTROL, control);
++}
++
++static void amd64_linux_dr_set_addr (int regnum, CORE_ADDR addr);
++
++/* Set DR_CONTROL to ADDR in all LWPs of CURRENT_INFERIOR. */
+
+ static void
+ amd64_linux_dr_set_control (unsigned long control)
+ {
+- struct lwp_info *lp;
+- ptid_t ptid;
++ int inferior_pid = ptid_get_pid (inferior_ptid);
++ struct inferior *inf = current_inferior ();
++
++ /* Are we detaching breakpoints from a fork-ed child?
++ See linux_nat_iterate_watchpoint_lwps for the fork-ed child description.
++ The i386 counterpart is i386_linux_dr_set_control. */
++ if (inf->pid != inferior_pid)
++ {
++ struct i386_dr_mirror *dr_mirror = i386_dr_mirror_get ();
++ int i;
++
++ /* There were two changes in Linux kernel 2.6.33 by the commit:
++ 72f674d203cd230426437cdcf7dd6f681dad8b0d
++
++ (1) After fork/vfork/clone the new task no longer inherits the debug
++ registers. It has them zeroed instead. Either case is OK for GDB as
++ GDB already registers a fix up by linux_nat_set_new_thread.
++
++ (2) If you enable a breakpoint by the CONTROL bits you have already
++ written its ADDRESS. Otherwise Linux kernel will report EINVAL.
++ For this case the workaround here ensures that during resetting
++ (detaching) watchpoints for a fork-ed child we can set CONTROL
++ arbitrarily as the addresses get pre-set here just to be sure.
++
++ The second issue is hopefully going to be fixed in Linux kernel:
++ https://bugzilla.redhat.com/show_bug.cgi?id=660204 */
++
++ if (!dr_mirror->addr_preset)
++ {
++ dr_mirror->addr_preset = 1;
++
++ for (i = 0; i < DR_LASTADDR - DR_FIRSTADDR; i++)
++ amd64_linux_dr_set_addr (i, dr_mirror->addr[i]);
++ }
++ }
++
++ linux_nat_iterate_watchpoint_lwps (amd64_linux_dr_set_control_callback,
++ &control);
++}
++
++/* Helper for amd64_linux_dr_set_addr. */
++
++struct amd64_linux_dr_set_addr_data
++ {
++ int regnum;
++ CORE_ADDR addr;
++ };
+
+static void
-+amd64_linux_dr_detach (void)
++amd64_linux_dr_set_addr_callback (int tid, void *datap_voidp)
+{
-+ int regnum;
++ const struct amd64_linux_dr_set_addr_data *datap = datap_voidp;
+
+- amd64_linux_dr[DR_CONTROL] = control;
+- ALL_LWPS (lp, ptid)
+- amd64_linux_dr_set (ptid, DR_CONTROL, control);
++ amd64_linux_dr_set (tid, DR_FIRSTADDR + datap->regnum, datap->addr);
+ }
+
+-/* Set address REGNUM (zero based) to ADDR in all LWPs of LWP_LIST. */
++/* Set address REGNUM (zero based) to ADDR in all LWPs of CURRENT_INFERIOR.
++ */
+
+ static void
+ amd64_linux_dr_set_addr (int regnum, CORE_ADDR addr)
+ {
+- struct lwp_info *lp;
+- ptid_t ptid;
++ struct amd64_linux_dr_set_addr_data data;
+
+ gdb_assert (regnum >= 0 && regnum <= DR_LASTADDR - DR_FIRSTADDR);
+
+- amd64_linux_dr[DR_FIRSTADDR + regnum] = addr;
+- ALL_LWPS (lp, ptid)
+- amd64_linux_dr_set (ptid, DR_FIRSTADDR + regnum, addr);
++ data.regnum = regnum;
++ data.addr = addr;
++ linux_nat_iterate_watchpoint_lwps (amd64_linux_dr_set_addr_callback, &data);
+ }
+
+-/* Set address REGNUM (zero based) to zero in all LWPs of LWP_LIST. */
++/* Set address REGNUM (zero based) to zero in all LWPs of CURRENT_INFERIOR.
++ */
+
+ static void
+ amd64_linux_dr_reset_addr (int regnum)
+@@ -354,37 +402,54 @@ amd64_linux_dr_reset_addr (int regnum)
+ static unsigned long
+ amd64_linux_dr_get_status (void)
+ {
+- return amd64_linux_dr_get (inferior_ptid, DR_STATUS);
++ int tid;
++
++ tid = TIDGET (inferior_ptid);
++ if (tid == 0)
++ tid = PIDGET (inferior_ptid);
++
++ return amd64_linux_dr_get (tid, DR_STATUS);
+ }
+
+-/* Unset MASK bits in DR_STATUS in all LWPs of LWP_LIST. */
++/* Helper for amd64_linux_dr_unset_status. */
+
+ static void
+-amd64_linux_dr_unset_status (unsigned long mask)
++amd64_linux_dr_unset_status_callback (int tid, void *mask_voidp)
+ {
+- struct lwp_info *lp;
+- ptid_t ptid;
+-
+- ALL_LWPS (lp, ptid)
+- {
+- unsigned long value;
++ unsigned long mask = *(unsigned long *) mask_voidp;
++ unsigned long value;
+
+- value = amd64_linux_dr_get (ptid, DR_STATUS);
+- value &= ~mask;
+- amd64_linux_dr_set (ptid, DR_STATUS, value);
+- }
++ value = amd64_linux_dr_get (tid, DR_STATUS);
++ value &= ~mask;
++ amd64_linux_dr_set (tid, DR_STATUS, value);
+ }
+
++/* Unset MASK bits in DR_STATUS in all LWPs of CURRENT_INFERIOR. */
+
-+ amd64_linux_dr_set (inferior_ptid, DR_CONTROL, 0);
-+ amd64_linux_dr_unset_status (~0UL);
-+ for (regnum = DR_FIRSTADDR; regnum <= DR_LASTADDR; regnum++)
-+ amd64_linux_dr_set (inferior_ptid, regnum, 0);
++static void
++amd64_linux_dr_unset_status (unsigned long mask)
++{
++ linux_nat_iterate_watchpoint_lwps (amd64_linux_dr_unset_status_callback,
++ &mask);
+}
static void
amd64_linux_new_thread (ptid_t ptid)
-@@ -796,6 +810,7 @@ _initialize_amd64_linux_nat (void)
- i386_dr_low.reset_addr = amd64_linux_dr_reset_addr;
- i386_dr_low.get_status = amd64_linux_dr_get_status;
- i386_dr_low.unset_status = amd64_linux_dr_unset_status;
-+ i386_dr_low.detach = amd64_linux_dr_detach;
- i386_set_debug_register_length (8);
-
- /* Override the GNU/Linux inferior startup hook. */
-diff --git a/gdb/block.c b/gdb/block.c
-index 48ac21b..ffcc97f 100644
---- a/gdb/block.c
-+++ b/gdb/block.c
-@@ -321,3 +321,21 @@ allocate_block (struct obstack *obstack)
+ {
+- int i;
++ struct i386_dr_mirror *dr_mirror = i386_dr_mirror_get ();
++ int i, tid;
++
++ /* Verify DR_MIRROR is valid. */
++ gdb_assert (PIDGET (ptid) == PIDGET (inferior_ptid));
++
++ tid = TIDGET (ptid);
++ if (tid == 0)
++ tid = PIDGET (ptid);
+
+- for (i = DR_FIRSTADDR; i <= DR_LASTADDR; i++)
+- amd64_linux_dr_set (ptid, i, amd64_linux_dr[i]);
++ for (i = 0; i < DR_LASTADDR - DR_FIRSTADDR; i++)
++ amd64_linux_dr_set (tid, DR_FIRSTADDR + i, dr_mirror->addr[i]);
+
+- amd64_linux_dr_set (ptid, DR_CONTROL, amd64_linux_dr[DR_CONTROL]);
++ amd64_linux_dr_set (tid, DR_CONTROL, dr_mirror->control);
+ }
+ \f
+
+Index: gdb-7.2.90.20110703/gdb/ax-gdb.c
+===================================================================
+--- gdb-7.2.90.20110703.orig/gdb/ax-gdb.c 2011-02-24 08:39:47.000000000 +0100
++++ gdb-7.2.90.20110703/gdb/ax-gdb.c 2011-07-03 10:33:11.000000000 +0200
+@@ -2001,7 +2001,8 @@ gen_expr (struct expression *exp, union
+
+ case OP_INTERNALVAR:
+ {
+- const char *name = internalvar_name ((*pc)[1].internalvar);
++ struct internalvar *var = (*pc)[1].internalvar;
++ const char *name = internalvar_name (var);
+ struct trace_state_variable *tsv;
+
+ (*pc) += 3;
+@@ -2015,7 +2016,7 @@ gen_expr (struct expression *exp, union
+ value->kind = axs_rvalue;
+ value->type = builtin_type (exp->gdbarch)->builtin_long_long;
+ }
+- else
++ else if (! compile_internalvar_to_ax (var, ax, value))
+ error (_("$%s is not a trace state variable; GDB agent "
+ "expressions cannot use convenience variables."), name);
+ }
+Index: gdb-7.2.90.20110703/gdb/block.c
+===================================================================
+--- gdb-7.2.90.20110703.orig/gdb/block.c 2011-01-01 16:32:57.000000000 +0100
++++ gdb-7.2.90.20110703/gdb/block.c 2011-07-03 10:33:11.000000000 +0200
+@@ -322,3 +322,21 @@ allocate_block (struct obstack *obstack)
return bl;
}
+
+ return SYMBOL_SYMTAB (func)->objfile;
+}
-diff --git a/gdb/block.h b/gdb/block.h
-index 7eedb6c..a517e80 100644
---- a/gdb/block.h
-+++ b/gdb/block.h
-@@ -166,4 +166,6 @@ extern const struct block *block_global_block (const struct block *block);
+Index: gdb-7.2.90.20110703/gdb/block.h
+===================================================================
+--- gdb-7.2.90.20110703.orig/gdb/block.h 2011-01-01 16:32:57.000000000 +0100
++++ gdb-7.2.90.20110703/gdb/block.h 2011-07-03 10:33:11.000000000 +0200
+@@ -167,4 +167,6 @@ extern const struct block *block_global_
extern struct block *allocate_block (struct obstack *obstack);
+extern struct objfile *block_objfile (const struct block *block);
+
#endif /* BLOCK_H */
-diff --git a/gdb/blockframe.c b/gdb/blockframe.c
-index 0348bf4..f01d0ee 100644
---- a/gdb/blockframe.c
-+++ b/gdb/blockframe.c
-@@ -38,6 +38,7 @@
- #include "block.h"
- #include "inline-frame.h"
- #include "psymtab.h"
-+#include "elf-bfd.h"
-
- /* Return the innermost lexical block in execution
- in a specified stack frame. The frame address is assumed valid.
-@@ -159,6 +160,7 @@ static CORE_ADDR cache_pc_function_low = 0;
- static CORE_ADDR cache_pc_function_high = 0;
- static char *cache_pc_function_name = 0;
- static struct obj_section *cache_pc_function_section = NULL;
-+static int cache_pc_function_is_gnu_ifunc = 0;
-
- /* Clear cache, e.g. when symbol table is discarded. */
-
-@@ -169,6 +171,7 @@ clear_pc_function_cache (void)
- cache_pc_function_high = 0;
- cache_pc_function_name = (char *) 0;
- cache_pc_function_section = NULL;
-+ cache_pc_function_is_gnu_ifunc = 0;
- }
-
- /* Finds the "function" (text symbol) that is smaller than PC but
-@@ -184,7 +187,7 @@ clear_pc_function_cache (void)
-
- /* Backward compatibility, no section argument. */
-
--int
-+enum find_pc_partial_function_type
- find_pc_partial_function (CORE_ADDR pc, char **name, CORE_ADDR *address,
- CORE_ADDR *endaddr)
- {
-@@ -236,6 +239,7 @@ find_pc_partial_function (CORE_ADDR pc, char **name, CORE_ADDR *address,
- cache_pc_function_high = BLOCK_END (SYMBOL_BLOCK_VALUE (f));
- cache_pc_function_name = SYMBOL_LINKAGE_NAME (f);
- cache_pc_function_section = section;
-+ cache_pc_function_is_gnu_ifunc = TYPE_GNU_IFUNC (SYMBOL_TYPE (f));
- goto return_cached_value;
- }
- }
-@@ -258,12 +262,13 @@ find_pc_partial_function (CORE_ADDR pc, char **name, CORE_ADDR *address,
- *address = 0;
- if (endaddr != NULL)
- *endaddr = 0;
-- return 0;
-+ return FIND_PC_PARTIAL_FUNCTION_NOT_FOUND;
- }
-
- cache_pc_function_low = SYMBOL_VALUE_ADDRESS (msymbol);
- cache_pc_function_name = SYMBOL_LINKAGE_NAME (msymbol);
- cache_pc_function_section = section;
-+ cache_pc_function_is_gnu_ifunc = MSYMBOL_TYPE (msymbol) == mst_text_gnu_ifunc;
-
- /* If the minimal symbol has a size, use it for the cache.
- Otherwise use the lesser of the next minimal symbol in the same
-@@ -323,7 +328,8 @@ find_pc_partial_function (CORE_ADDR pc, char **name, CORE_ADDR *address,
- *endaddr = cache_pc_function_high;
- }
-
-- return 1;
-+ return cache_pc_function_is_gnu_ifunc ? FIND_PC_PARTIAL_FUNCTION_GNU_IFUNC
-+ : FIND_PC_PARTIAL_FUNCTION_NORMAL;
- }
-
- /* Return the innermost stack frame executing inside of BLOCK,
-diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
-index 6a6864c..5df336d 100644
---- a/gdb/breakpoint.c
-+++ b/gdb/breakpoint.c
-@@ -62,6 +62,7 @@
+Index: gdb-7.2.90.20110703/gdb/breakpoint.c
+===================================================================
+--- gdb-7.2.90.20110703.orig/gdb/breakpoint.c 2011-07-02 21:33:09.000000000 +0200
++++ gdb-7.2.90.20110703/gdb/breakpoint.c 2011-07-03 10:35:09.000000000 +0200
+@@ -63,6 +63,8 @@
#include "jit.h"
#include "xml-syscall.h"
#include "parser-defs.h"
-+#include "regcache.h"
++#include "gdb_regex.h"
++#include "stap-probe.h"
+ #include "cli/cli-utils.h"
/* readline include files */
- #include "readline/readline.h"
-@@ -92,6 +93,9 @@ static void map_breakpoint_numbers (char *, void (*) (struct breakpoint *,
-
- static void ignore_command (char *, int);
-
-+static void update_breakpoint_locations (struct breakpoint *b,
-+ struct symtabs_and_lines sals);
-+
- static int breakpoint_re_set_one (void *);
-
- static void clear_command (char *, int);
-@@ -106,6 +110,9 @@ static void break_command_1 (char *, int, int);
+@@ -107,6 +109,9 @@ static void break_command_1 (char *, int
static void mention (struct breakpoint *);
+static struct bp_location *add_location_to_breakpoint (struct breakpoint *b,
+ const struct symtab_and_line *sal);
+
- /* This function is used in gdbtk sources and thus can not be made static. */
+ /* This function is used in gdbtk sources and thus can not be made
+ static. */
struct breakpoint *set_raw_breakpoint (struct gdbarch *gdbarch,
- struct symtab_and_line,
-@@ -230,6 +237,10 @@ static void disable_trace_command (char *, int);
-
- static void trace_pass_command (char *, int);
-
-+static void gnu_ifunc_resolver_stop (struct breakpoint *b);
-+
-+static void gnu_ifunc_resolver_return_stop (struct breakpoint *b);
-+
- /* Assuming we're creating a static tracepoint, does S look like a
- static tracepoint marker spec ("-m MARKER_ID")? */
- #define is_marker_spec(s) \
-@@ -430,7 +441,7 @@ static int tracepoint_count;
-
- static struct cmd_list_element *breakpoint_set_cmdlist;
- static struct cmd_list_element *breakpoint_show_cmdlist;
--static struct cmd_list_element *save_cmdlist;
-+struct cmd_list_element *save_cmdlist;
-
- /* Return whether a breakpoint is an active enabled breakpoint. */
- static int
-@@ -1252,6 +1263,22 @@ watchpoint_in_thread_scope (struct breakpoint *b)
- && !is_executing (inferior_ptid)));
- }
+@@ -1249,6 +1254,9 @@ update_watchpoint (struct breakpoint *b,
+ if (!watchpoint_in_thread_scope (b))
+ return;
-+static void
-+watchpoint_del_at_next_stop (struct breakpoint *b)
-+{
-+ gdb_assert (is_watchpoint (b));
++ if (b->pspace != current_program_space)
++ return;
+
-+ if (b->related_breakpoint != b)
-+ {
-+ gdb_assert (b->related_breakpoint->type == bp_watchpoint_scope);
-+ gdb_assert (b->related_breakpoint->related_breakpoint == b);
-+ b->related_breakpoint->disposition = disp_del_at_next_stop;
-+ b->related_breakpoint->related_breakpoint = b->related_breakpoint;
-+ b->related_breakpoint = b;
-+ }
-+ b->disposition = disp_del_at_next_stop;
-+}
-+
- /* Assuming that B is a watchpoint:
- - Reparse watchpoint expression, if REPARSE is non-zero
- - Evaluate expression and store the result in B->val
-@@ -1307,6 +1334,8 @@ update_watchpoint (struct breakpoint *b, int reparse)
- struct frame_id saved_frame_id;
- int frame_saved;
-
-+ gdb_assert (is_watchpoint (b));
-+
- /* If this is a local watchpoint, we only want to check if the
- watchpoint frame is in scope if the current thread is the thread
- that was used to create the watchpoint. */
-@@ -1510,13 +1539,7 @@ update_watchpoint (struct breakpoint *b, int reparse)
- Watchpoint %d deleted because the program has left the block\n\
- in which its expression is valid.\n"),
- b->number);
-- if (b->related_breakpoint)
-- {
-- b->related_breakpoint->disposition = disp_del_at_next_stop;
-- b->related_breakpoint->related_breakpoint = NULL;
-- b->related_breakpoint= NULL;
-- }
-- b->disposition = disp_del_at_next_stop;
-+ watchpoint_del_at_next_stop (b);
- }
-
- /* Restore the selected frame. */
-@@ -2201,6 +2224,33 @@ create_std_terminate_master_breakpoint (const char *func_name)
- do_cleanups (old_chain);
+ if (b->disposition == disp_del_at_next_stop)
+ return;
+
+@@ -1520,6 +1528,40 @@ should_be_inserted (struct bp_location *
+ return 1;
}
-+/* Install a master breakpoint on the unwinder's debug hook. */
++/* See the comment in breakpoint.h. */
+
+void
-+create_exception_master_breakpoint (void)
++modify_semaphore (struct bp_location *loc, int set)
+{
-+ struct objfile *objfile;
++ struct gdbarch *arch = loc->gdbarch;
++ gdb_byte bytes[sizeof (LONGEST)];
++ /* The ABI specifies "unsigned short". */
++ struct type *type = builtin_type (arch)->builtin_unsigned_short;
++ CORE_ADDR address = loc->semaphore;
++ ULONGEST value;
+
-+ ALL_OBJFILES (objfile)
-+ {
-+ struct minimal_symbol *debug_hook;
++ if (address == 0)
++ return;
+
-+ debug_hook = lookup_minimal_symbol_text ("_Unwind_DebugHook", objfile);
-+ if (debug_hook != NULL)
-+ {
-+ struct breakpoint *b;
++ /* Swallow errors. */
++ if (target_read_memory (address, bytes, TYPE_LENGTH (type)) != 0)
++ return;
+
-+ b = create_internal_breakpoint (get_objfile_arch (objfile),
-+ SYMBOL_VALUE_ADDRESS (debug_hook),
-+ bp_exception_master);
-+ b->addr_string = xstrdup ("_Unwind_DebugHook");
-+ b->enable_state = bp_disabled;
-+ }
-+ }
++ value = extract_unsigned_integer (bytes, TYPE_LENGTH (type),
++ gdbarch_byte_order (arch));
++ /* Note that we explicitly don't worry about overflow or
++ underflow. */
++ if (set)
++ ++value;
++ else
++ --value;
+
-+ update_global_location_list (1);
++ store_unsigned_integer (bytes, TYPE_LENGTH (type),
++ gdbarch_byte_order (arch), value);
++
++ target_write_memory (address, bytes, TYPE_LENGTH (type));
+}
+
- void
- update_breakpoints_after_exec (void)
- {
-@@ -2242,7 +2292,8 @@ update_breakpoints_after_exec (void)
- /* Thread event breakpoints must be set anew after an exec(),
- as must overlay event and longjmp master breakpoints. */
- if (b->type == bp_thread_event || b->type == bp_overlay_event
-- || b->type == bp_longjmp_master || b->type == bp_std_terminate_master)
-+ || b->type == bp_longjmp_master || b->type == bp_std_terminate_master
-+ || b->type == bp_exception_master)
- {
- delete_breakpoint (b);
- continue;
-@@ -2257,7 +2308,8 @@ update_breakpoints_after_exec (void)
-
- /* Longjmp and longjmp-resume breakpoints are also meaningless
- after an exec. */
-- if (b->type == bp_longjmp || b->type == bp_longjmp_resume)
-+ if (b->type == bp_longjmp || b->type == bp_longjmp_resume
-+ || b->type == bp_exception || b->type == bp_exception_resume)
- {
- delete_breakpoint (b);
+ /* Insert a low-level "breakpoint" of some type. BL is the breakpoint
+ location. Any error messages are printed to TMP_ERROR_STREAM; and
+ DISABLED_BREAKS, and HW_BREAKPOINT_ERROR are used to report problems.
+@@ -1616,6 +1658,8 @@ insert_bp_location (struct bp_location *
+ else
+ val = target_insert_breakpoint (bl->gdbarch,
+ &bl->target_info);
++
++ modify_semaphore (bl, 1);
+ }
+ else
+ {
+@@ -1870,6 +1914,7 @@ insert_breakpoint_locations (void)
+ int val = 0;
+ int disabled_breaks = 0;
+ int hw_breakpoint_error = 0;
++ struct program_space *saved_current_program_space = current_program_space;
+
+ struct ui_file *tmp_error_stream = mem_fileopen ();
+ struct cleanup *cleanups = make_cleanup_ui_file_delete (tmp_error_stream);
+@@ -1897,9 +1942,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
+- insert breakpoints. */
++ insert breakpoints.
++
++ Also inserting breakpoints into inappropriate inferior must be
++ prevented. */
+ if (!gdbarch_has_global_breakpoints (target_gdbarch)
+- && ptid_equal (inferior_ptid, null_ptid))
++ && (ptid_equal (inferior_ptid, null_ptid)
++ || bl->pspace != saved_current_program_space))
continue;
-@@ -2319,6 +2371,7 @@ update_breakpoints_after_exec (void)
- create_longjmp_master_breakpoint ("siglongjmp");
- create_longjmp_master_breakpoint ("_siglongjmp");
- create_std_terminate_master_breakpoint ("std::terminate()");
-+ create_exception_master_breakpoint ();
- }
- int
-@@ -2346,6 +2399,8 @@ detach_breakpoints (int pid)
- /* Detach single-step breakpoints as well. */
- detach_single_step_breakpoints ();
+ val = insert_bp_location (bl, tmp_error_stream, &disabled_breaks,
+@@ -1923,13 +1972,19 @@ insert_breakpoint_locations (void)
-+ val |= target_detach_watchpoints ();
+ if (bpt->disposition == disp_del_at_next_stop)
+ continue;
+-
+
- do_cleanups (old_chain);
- return val;
- }
-@@ -2447,9 +2502,11 @@ remove_breakpoint_1 (struct bp_location *b, insertion_state_t is)
- return val;
- b->inserted = (is == mark_inserted);
- }
-- else if (b->loc_type == bp_loc_hardware_watchpoint)
-+ /* bp_loc_hardware_watchpoint with mark_inserted is being handled by
-+ target_detach_watchpoints. */
-+ else if (b->loc_type == bp_loc_hardware_watchpoint && is == mark_uninserted)
- {
-- b->inserted = (is == mark_inserted);
-+ b->inserted = 0;
- val = target_remove_watchpoint (b->address, b->length,
- b->watchpoint_type, b->owner->cond_exp);
-
-@@ -3237,6 +3294,12 @@ print_it_typical (bpstat bs)
- result = PRINT_NOTHING;
- break;
+ for (loc = bpt->loc; loc; loc = loc->next)
+- if (!loc->inserted && should_be_inserted (loc))
+- {
+- some_failed = 1;
+- break;
+- }
++ {
++ /* Verify the first loop above really tried to insert this LOC. */
++ if (!loc->inserted && should_be_inserted (loc)
++ && (gdbarch_has_global_breakpoints (target_gdbarch)
++ || (!ptid_equal (inferior_ptid, null_ptid)
++ && loc->pspace == saved_current_program_space)))
++ {
++ some_failed = 1;
++ break;
++ }
++ }
+ if (some_failed)
+ {
+ for (loc = bpt->loc; loc; loc = loc->next)
+@@ -2111,15 +2166,24 @@ struct breakpoint_objfile_data
+ /* Minimal symbol(s) for "longjmp", "siglongjmp", etc. (if any). */
+ struct minimal_symbol *longjmp_msym[NUM_LONGJMP_NAMES];
-+ case bp_exception_master:
-+ /* These should never be enabled. */
-+ printf_filtered (_("Exception Master Breakpoint: gdb should not stop!\n"));
-+ result = PRINT_NOTHING;
-+ break;
++ /* SystemTap probe point for longjmp (if any). */
++ const struct stap_probe *longjmp_probe;
+
- case bp_watchpoint:
- case bp_hardware_watchpoint:
- annotate_watchpoint (b->number);
-@@ -3324,6 +3387,8 @@ print_it_typical (bpstat bs)
- case bp_none:
- case bp_longjmp:
- case bp_longjmp_resume:
-+ case bp_exception:
-+ case bp_exception_resume:
- case bp_step_resume:
- case bp_watchpoint_scope:
- case bp_call_dummy:
-@@ -3331,6 +3396,8 @@ print_it_typical (bpstat bs)
- case bp_tracepoint:
- case bp_fast_tracepoint:
- case bp_jit_event:
-+ case bp_gnu_ifunc_resolver:
-+ case bp_gnu_ifunc_resolver_return:
- default:
- result = PRINT_UNKNOWN;
- break;
-@@ -3549,6 +3616,8 @@ watchpoint_check (void *p)
- gdb_assert (bs->breakpoint_at->owner != NULL);
- b = bs->breakpoint_at->owner;
+ /* Minimal symbol for "std::terminate()" (if any). */
+ struct minimal_symbol *terminate_msym;
-+ gdb_assert (is_watchpoint (b));
+ /* Minimal symbol for "_Unwind_DebugHook" (if any). */
+ struct minimal_symbol *exception_msym;
+
- /* If this is a local watchpoint, we only want to check if the
- watchpoint frame is in scope if the current thread is the thread
- that was used to create the watchpoint. */
-@@ -3655,13 +3724,7 @@ watchpoint_check (void *p)
- ui_out_text (uiout, " deleted because the program has left the block in\n\
- which its expression is valid.\n");
-
-- if (b->related_breakpoint)
-- {
-- b->related_breakpoint->disposition = disp_del_at_next_stop;
-- b->related_breakpoint->related_breakpoint = NULL;
-- b->related_breakpoint = NULL;
-- }
-- b->disposition = disp_del_at_next_stop;
-+ watchpoint_del_at_next_stop (b);
-
- return WP_DELETED;
- }
-@@ -3730,8 +3793,12 @@ bpstat_check_location (const struct bp_location *bl,
++ /* SystemTap probe point for unwinding (if any). */
++ const struct stap_probe *exception_probe;
+ };
- /* If BS refers to a watchpoint, determine if the watched values
- has actually changed, and we should stop. If not, set BS->stop
-- to 0. */
--static void
-+ to 0.
-+ Return 0 for watchpoints which could not be the cause of this trap.
-+ In such case PRINT_IT will be print_it_noop and STOP will be 0.
-+ Otherwise return 1 but in such case it is not guaranteed whether this
-+ breakpoint did or did not trigger this trap. */
-+static int
- bpstat_check_watchpoint (bpstat bs)
- {
- const struct bp_location *bl;
-@@ -3865,9 +3932,7 @@ bpstat_check_watchpoint (bpstat bs)
- case 0:
- /* Error from catch_errors. */
- printf_filtered (_("Watchpoint %d deleted.\n"), b->number);
-- if (b->related_breakpoint)
-- b->related_breakpoint->disposition = disp_del_at_next_stop;
-- b->disposition = disp_del_at_next_stop;
-+ watchpoint_del_at_next_stop (b);
- /* We've already printed what needs to be printed. */
- bs->print_it = print_it_done;
- break;
-@@ -3881,8 +3946,10 @@ bpstat_check_watchpoint (bpstat bs)
- anything for this watchpoint. */
- bs->print_it = print_it_noop;
- bs->stop = 0;
-+ return 0;
- }
- }
-+ return 1;
- }
+ static const struct objfile_data *breakpoint_objfile_key;
++/* SystemTap probe not found sentinel. */
++static const struct stap_probe probe_not_found;
++
+ /* Minimal symbol not found sentinel. */
+ static struct minimal_symbol msym_not_found;
-@@ -3914,7 +3981,7 @@ bpstat_check_breakpoint_conditions (bpstat bs, ptid_t ptid)
- watchpoint as triggered so that we will handle the
- out-of-scope event. We'll get to the watchpoint next
- iteration. */
-- if (b->type == bp_watchpoint_scope)
-+ if (b->type == bp_watchpoint_scope && b->related_breakpoint != b)
- b->related_breakpoint->watchpoint_triggered = watch_triggered_yes;
+@@ -2227,6 +2291,29 @@ create_longjmp_master_breakpoint (void)
- if (is_watchpoint (b))
-@@ -4045,6 +4112,8 @@ bpstat_stop_status (struct address_space *aspace,
+ bp_objfile_data = get_breakpoint_objfile_data (objfile);
- for (bl = b->loc; bl != NULL; bl = bl->next)
- {
-+ bpstat bs_prev = bs;
-+
- /* For hardware watchpoints, we look only at the first location.
- The watchpoint_check function will work on the entire expression,
- not the individual locations. For read watchpoints, the
-@@ -4062,6 +4131,7 @@ bpstat_stop_status (struct address_space *aspace,
- /* Come here if it's a watchpoint, or if the break address matches */
-
- bs = bpstat_alloc (bl, bs); /* Alloc a bpstat to explain stop */
-+ gdb_assert (bs_prev->next == bs);
-
- /* Assume we stop. Should we find watchpoint that is not actually
- triggered, or if condition of breakpoint is false, we'll reset
-@@ -4069,13 +4139,23 @@ bpstat_stop_status (struct address_space *aspace,
- bs->stop = 1;
- bs->print = 1;
-
-- bpstat_check_watchpoint (bs);
-- if (!bs->stop)
-- continue;
-+ if (!bpstat_check_watchpoint (bs))
++ if (bp_objfile_data->longjmp_probe != &probe_not_found)
++ {
++ if (bp_objfile_data->longjmp_probe == NULL)
++ bp_objfile_data->longjmp_probe
++ = find_probe_in_objfile (objfile, "libc", "longjmp");
++
++ if (bp_objfile_data->longjmp_probe)
+ {
-+ /* Ensure bpstat_explains_signal stays false if this BL could not be
-+ the cause of this trap. */
-+
-+ gdb_assert (bs->print_it == print_it_noop);
-+ gdb_assert (!bs->stop);
-+ xfree (bs);
-+ bs = bs_prev;
-+ bs->next = NULL;
++ struct breakpoint *b;
++ struct gdbarch *gdbarch = get_objfile_arch (objfile);
++
++ b = create_internal_breakpoint (gdbarch,
++ bp_objfile_data->longjmp_probe->address,
++ bp_longjmp_master);
++ b->addr_string = xstrdup ("probe:libc:longjmp");
++ b->enable_state = bp_disabled;
++
+ continue;
+ }
-
- if (b->type == bp_thread_event || b->type == bp_overlay_event
- || b->type == bp_longjmp_master
-- || b->type == bp_std_terminate_master)
-+ || b->type == bp_std_terminate_master
-+ || b->type == bp_exception_master)
- /* We do not stop for these. */
- bs->stop = 0;
- else
-@@ -4176,7 +4256,7 @@ handle_jit_event (void)
- /* Decide what infrun needs to do with this bpstat. */
-
- struct bpstat_what
--bpstat_what (bpstat bs)
-+bpstat_what (bpstat bs_head)
- {
- struct bpstat_what retval;
- /* We need to defer calling `solib_add', as adding new symbols
-@@ -4184,11 +4264,13 @@ bpstat_what (bpstat bs)
- and hence may clear unprocessed entries in the BS chain. */
- int shlib_event = 0;
- int jit_event = 0;
-+ bpstat bs;
-
- retval.main_action = BPSTAT_WHAT_KEEP_CHECKING;
- retval.call_dummy = STOP_NONE;
-+ retval.is_longjmp = 0;
-
-- for (; bs != NULL; bs = bs->next)
-+ for (bs = bs_head; bs != NULL; bs = bs->next)
- {
- /* Extract this BS's action. After processing each BS, we check
- if its action overrides all we've seem so far. */
-@@ -4242,10 +4324,15 @@ bpstat_what (bpstat bs)
- }
- break;
- case bp_longjmp:
-+ case bp_exception:
- this_action = BPSTAT_WHAT_SET_LONGJMP_RESUME;
-+ retval.is_longjmp = bs->breakpoint_at->owner->type == bp_longjmp;
- break;
- case bp_longjmp_resume:
-+ case bp_exception_resume:
- this_action = BPSTAT_WHAT_CLEAR_LONGJMP_RESUME;
-+ retval.is_longjmp
-+ = bs->breakpoint_at->owner->type == bp_longjmp_resume;
- break;
- case bp_step_resume:
- if (bs->stop)
-@@ -4261,6 +4348,7 @@ bpstat_what (bpstat bs)
- case bp_overlay_event:
- case bp_longjmp_master:
- case bp_std_terminate_master:
-+ case bp_exception_master:
- this_action = BPSTAT_WHAT_SINGLE;
- break;
- case bp_catchpoint:
-@@ -4313,6 +4401,20 @@ bpstat_what (bpstat bs)
- out already. */
- internal_error (__FILE__, __LINE__,
- _("bpstat_what: tracepoint encountered"));
-+ break;
-+ case bp_gnu_ifunc_resolver:
-+ /* Skip the current breakpoint but otherwise nothing happens. GDB is
-+ inserting new bp_gnu_ifunc_resolver_return at this point but
-+ bp_gnu_ifunc_resolver is being kept there as another
-+ bp_gnu_ifunc_resolver_return may be inserted in the meantime. */
-+ this_action = BPSTAT_WHAT_SINGLE;
-+ break;
-+ case bp_gnu_ifunc_resolver_return:
-+ /* The whole bp_gnu_ifunc_resolver with its associated
-+ bp_gnu_ifunc_resolver_return related_breakpoint's has been
-+ resolved now, all these helper breakpoints are being removed and
-+ new final bp_breakpoint is being put at the target location. */
-+ break;
- default:
- internal_error (__FILE__, __LINE__,
- _("bpstat_what: unhandled bptype %d"), (int) bptype);
-@@ -4350,6 +4452,23 @@ bpstat_what (bpstat bs)
- handle_jit_event ();
- }
-
-+ for (bs = bs_head; bs != NULL; bs = bs->next)
-+ {
-+ if (bs->breakpoint_at == NULL)
-+ continue;
-+ if (bs->breakpoint_at->owner == NULL)
-+ continue;
-+ switch (bs->breakpoint_at->owner->type)
-+ {
-+ case bp_gnu_ifunc_resolver:
-+ gnu_ifunc_resolver_stop (bs->breakpoint_at->owner);
-+ break;
-+ case bp_gnu_ifunc_resolver_return:
-+ gnu_ifunc_resolver_return_stop (bs->breakpoint_at->owner);
-+ break;
++ else
++ bp_objfile_data->longjmp_probe = &probe_not_found;
+ }
-+ }
+
- return retval;
- }
+ for (i = 0; i < NUM_LONGJMP_NAMES; i++)
+ {
+ struct breakpoint *b;
+@@ -2335,6 +2422,31 @@ create_exception_master_breakpoint (void
-@@ -4461,6 +4580,8 @@ print_one_breakpoint_location (struct breakpoint *b,
- {bp_access_watchpoint, "acc watchpoint"},
- {bp_longjmp, "longjmp"},
- {bp_longjmp_resume, "longjmp resume"},
-+ {bp_exception, "exception"},
-+ {bp_exception_resume, "exception resume"},
- {bp_step_resume, "step resume"},
- {bp_watchpoint_scope, "watchpoint scope"},
- {bp_call_dummy, "call dummy"},
-@@ -4470,11 +4591,14 @@ print_one_breakpoint_location (struct breakpoint *b,
- {bp_overlay_event, "overlay events"},
- {bp_longjmp_master, "longjmp master"},
- {bp_std_terminate_master, "std::terminate master"},
-+ {bp_exception_master, "exception master"},
- {bp_catchpoint, "catchpoint"},
- {bp_tracepoint, "tracepoint"},
- {bp_fast_tracepoint, "fast tracepoint"},
- {bp_static_tracepoint, "static tracepoint"},
- {bp_jit_event, "jit events"},
-+ {bp_gnu_ifunc_resolver, "gnu-ifunc resolver"},
-+ {bp_gnu_ifunc_resolver_return, "gnu-func resolver return"},
- };
-
- static char bpenables[] = "nynny";
-@@ -4595,6 +4719,8 @@ print_one_breakpoint_location (struct breakpoint *b,
- case bp_finish:
- case bp_longjmp:
- case bp_longjmp_resume:
-+ case bp_exception:
-+ case bp_exception_resume:
- case bp_step_resume:
- case bp_watchpoint_scope:
- case bp_call_dummy:
-@@ -4604,10 +4730,13 @@ print_one_breakpoint_location (struct breakpoint *b,
- case bp_overlay_event:
- case bp_longjmp_master:
- case bp_std_terminate_master:
-+ case bp_exception_master:
- case bp_tracepoint:
- case bp_fast_tracepoint:
- case bp_static_tracepoint:
- case bp_jit_event:
-+ case bp_gnu_ifunc_resolver:
-+ case bp_gnu_ifunc_resolver_return:
- if (opts.addressprint)
- {
- annotate_field (4);
-@@ -4888,7 +5017,8 @@ user_settable_breakpoint (const struct breakpoint *b)
- || b->type == bp_catchpoint
- || b->type == bp_hardware_breakpoint
- || is_tracepoint (b)
-- || is_watchpoint (b));
-+ || is_watchpoint (b)
-+ || b->type == bp_gnu_ifunc_resolver);
- }
-
- /* Print information on user settable breakpoint (watchpoint, etc)
-@@ -5334,6 +5464,8 @@ allocate_bp_location (struct breakpoint *bpt)
- case bp_finish:
- case bp_longjmp:
- case bp_longjmp_resume:
-+ case bp_exception:
-+ case bp_exception_resume:
- case bp_step_resume:
- case bp_watchpoint_scope:
- case bp_call_dummy:
-@@ -5344,6 +5476,9 @@ allocate_bp_location (struct breakpoint *bpt)
- case bp_jit_event:
- case bp_longjmp_master:
- case bp_std_terminate_master:
-+ case bp_gnu_ifunc_resolver:
-+ case bp_gnu_ifunc_resolver_return:
-+ case bp_exception_master:
- loc->loc_type = bp_loc_software_breakpoint;
- break;
- case bp_hardware_breakpoint:
-@@ -5420,6 +5555,7 @@ set_raw_breakpoint_without_location (struct gdbarch *gdbarch,
- b->syscalls_to_be_caught = NULL;
- b->ops = NULL;
- b->condition_not_parsed = 0;
-+ b->related_breakpoint = b;
-
- /* Add this breakpoint to the end of the chain
- so that a list of breakpoints will come out in order
-@@ -5439,7 +5575,7 @@ set_raw_breakpoint_without_location (struct gdbarch *gdbarch,
-
- /* Initialize loc->function_name. */
- static void
--set_breakpoint_location_function (struct bp_location *loc)
-+set_breakpoint_location_function (struct bp_location *loc, int explicit_loc)
- {
- gdb_assert (loc->owner != NULL);
+ bp_objfile_data = get_breakpoint_objfile_data (objfile);
-@@ -5447,8 +5583,29 @@ set_breakpoint_location_function (struct bp_location *loc)
- || loc->owner->type == bp_hardware_breakpoint
- || is_tracepoint (loc->owner))
- {
-- find_pc_partial_function (loc->address, &(loc->function_name),
-- NULL, NULL);
-+ if (find_pc_partial_function (loc->address, &(loc->function_name), NULL,
-+ NULL) == FIND_PC_PARTIAL_FUNCTION_GNU_IFUNC
-+ && !explicit_loc)
++ /* We prefer the SystemTap probe point if it exists. */
++ if (bp_objfile_data->exception_probe != &probe_not_found)
+ {
-+ struct breakpoint *b = loc->owner;
++ if (bp_objfile_data->exception_probe == NULL)
++ bp_objfile_data->exception_probe
++ = find_probe_in_objfile (objfile, "libgcc", "unwind");
+
-+ gdb_assert (loc->pspace == current_program_space);
-+ if (resolve_gnu_ifunc (loc->function_name, &loc->requested_address))
-+ {
-+ /* Recalculate ADDRESS based on new REQUESTED_ADDRESS. */
-+ loc->address = adjust_breakpoint_address (loc->gdbarch,
-+ loc->requested_address,
-+ b->type);
-+ }
-+ else if (b->type == bp_breakpoint && b->loc == loc
-+ && loc->next == NULL && b->related_breakpoint == b)
++ if (bp_objfile_data->exception_probe)
+ {
-+ /* Create only the whole new breakpoint of this type but do not
-+ mess more complicated breakpoints with multiple locations. */
-+ b->type = bp_gnu_ifunc_resolver;
++ struct breakpoint *b;
++ struct gdbarch *gdbarch = get_objfile_arch (objfile);
++
++ b = create_internal_breakpoint (gdbarch,
++ bp_objfile_data->exception_probe->address,
++ bp_exception_master);
++ b->addr_string = xstrdup ("probe:libgcc:unwind");
++ b->enable_state = bp_disabled;
++ continue;
+ }
++ else
++ bp_objfile_data->exception_probe = &probe_not_found;
+ }
+
- if (loc->function_name)
- loc->function_name = xstrdup (loc->function_name);
- }
-@@ -5521,7 +5678,8 @@ set_raw_breakpoint (struct gdbarch *gdbarch,
- b->loc->section = sal.section;
- b->line_number = sal.line;
-
-- set_breakpoint_location_function (b->loc);
-+ set_breakpoint_location_function (b->loc,
-+ sal.explicit_pc || sal.explicit_line);
-
- breakpoints_changed ();
-
-@@ -5548,8 +5706,7 @@ make_breakpoint_permanent (struct breakpoint *b)
- }
-
- /* Call this routine when stepping and nexting to enable a breakpoint
-- if we do a longjmp() in THREAD. When we hit that breakpoint, call
-- set_longjmp_resume_breakpoint() to figure out where we are going. */
-+ if we do a longjmp() or 'throw' in THREAD. */
-
- void
- set_longjmp_breakpoint (int thread)
-@@ -5562,11 +5719,12 @@ set_longjmp_breakpoint (int thread)
- clones of those and enable them for the requested thread. */
- ALL_BREAKPOINTS_SAFE (b, temp)
- if (b->pspace == current_program_space
-- && b->type == bp_longjmp_master)
-+ && (b->type == bp_longjmp_master
-+ || b->type == bp_exception_master))
- {
- struct breakpoint *clone = clone_momentary_breakpoint (b);
-
-- clone->type = bp_longjmp;
-+ clone->type = b->type == bp_longjmp_master ? bp_longjmp : bp_exception;
- clone->thread = thread;
- }
- }
-@@ -5578,7 +5736,7 @@ delete_longjmp_breakpoint (int thread)
- struct breakpoint *b, *temp;
-
- ALL_BREAKPOINTS_SAFE (b, temp)
-- if (b->type == bp_longjmp)
-+ if (b->type == bp_longjmp || b->type == bp_exception)
- {
- if (b->thread == thread)
- delete_breakpoint (b);
-@@ -6595,7 +6753,7 @@ clone_momentary_breakpoint (struct breakpoint *orig)
-
- copy = set_raw_breakpoint_without_location (orig->gdbarch, orig->type);
- copy->loc = allocate_bp_location (copy);
-- set_breakpoint_location_function (copy->loc);
-+ set_breakpoint_location_function (copy->loc, 1);
-
- copy->loc->gdbarch = orig->loc->gdbarch;
- copy->loc->requested_address = orig->loc->requested_address;
-@@ -6694,6 +6852,7 @@ mention (struct breakpoint *b)
- do_cleanups (ui_out_chain);
- break;
- case bp_breakpoint:
-+ case bp_gnu_ifunc_resolver:
- if (ui_out_is_mi_like_p (uiout))
- {
- say_where = 0;
-@@ -6704,6 +6863,8 @@ mention (struct breakpoint *b)
- else
- printf_filtered (_("Breakpoint"));
- printf_filtered (_(" %d"), b->number);
-+ if (b->type == bp_gnu_ifunc_resolver)
-+ printf_filtered (_(" at gnu-indirect-function resolver"));
- say_where = 1;
- break;
- case bp_hardware_breakpoint:
-@@ -6750,6 +6911,8 @@ mention (struct breakpoint *b)
- case bp_finish:
- case bp_longjmp:
- case bp_longjmp_resume:
-+ case bp_exception:
-+ case bp_exception_resume:
- case bp_step_resume:
- case bp_call_dummy:
- case bp_std_terminate:
-@@ -6760,6 +6923,8 @@ mention (struct breakpoint *b)
- case bp_jit_event:
- case bp_longjmp_master:
- case bp_std_terminate_master:
-+ case bp_gnu_ifunc_resolver_return:
-+ case bp_exception_master:
- break;
- }
++ /* Otherwise, try the hook function. */
++
+ if (msym_not_found_p (bp_objfile_data->exception_msym))
+ continue;
-@@ -6820,7 +6985,8 @@ add_location_to_breakpoint (struct breakpoint *b,
+@@ -2553,6 +2665,8 @@ remove_breakpoint_1 (struct bp_location
+ val = target_remove_hw_breakpoint (bl->gdbarch, &bl->target_info);
+ else
+ val = target_remove_breakpoint (bl->gdbarch, &bl->target_info);
++
++ modify_semaphore (bl, 0);
+ }
+ else
+ {
+@@ -5902,6 +6016,7 @@ set_raw_breakpoint (struct gdbarch *gdba
+ b->loc->requested_address = sal.pc;
+ b->loc->address = adjusted_address;
+ b->loc->pspace = sal.pspace;
++ b->loc->semaphore = sal.semaphore;
+
+ /* Store the program space that was used to set the breakpoint, for
+ breakpoint resetting. */
+@@ -7056,6 +7171,7 @@ clone_momentary_breakpoint (struct break
+ copy->loc->address = orig->loc->address;
+ copy->loc->section = orig->loc->section;
+ copy->loc->pspace = orig->loc->pspace;
++ copy->loc->semaphore = orig->loc->semaphore;
+
+ if (orig->source_file == NULL)
+ copy->source_file = NULL;
+@@ -7279,6 +7395,7 @@ add_location_to_breakpoint (struct break
+ loc->address = adjust_breakpoint_address (loc->gdbarch,
+ loc->requested_address, b->type);
+ loc->pspace = sal->pspace;
++ loc->semaphore = sal->semaphore;
gdb_assert (loc->pspace != NULL);
loc->section = sal->section;
-- set_breakpoint_location_function (loc);
-+ set_breakpoint_location_function (loc,
-+ sal->explicit_pc || sal->explicit_line);
- return loc;
- }
- \f
-@@ -8346,6 +8512,7 @@ struct until_break_command_continuation_args
+@@ -7628,6 +7745,16 @@ create_breakpoints_sal (struct gdbarch *
{
- struct breakpoint *breakpoint;
- struct breakpoint *breakpoint2;
-+ int thread_num;
- };
-
- /* This function is called by fetch_inferior_event via the
-@@ -8360,6 +8527,7 @@ until_break_command_continuation (void *arg)
- delete_breakpoint (a->breakpoint);
- if (a->breakpoint2)
- delete_breakpoint (a->breakpoint2);
-+ delete_longjmp_breakpoint (a->thread_num);
- }
-
- void
-@@ -8371,6 +8539,8 @@ until_break_command (char *arg, int from_tty, int anywhere)
- struct breakpoint *breakpoint;
- struct breakpoint *breakpoint2 = NULL;
- struct cleanup *old_chain;
-+ int thread;
-+ struct thread_info *tp;
-
- clear_proceed_status ();
-
-@@ -8409,6 +8579,9 @@ until_break_command (char *arg, int from_tty, int anywhere)
-
- old_chain = make_cleanup_delete_breakpoint (breakpoint);
-
-+ tp = inferior_thread ();
-+ thread = tp->num;
-+
- /* Keep within the current frame, or in frames called by the current
- one. */
+ int i;
-@@ -8421,6 +8594,10 @@ until_break_command (char *arg, int from_tty, int anywhere)
- frame_unwind_caller_id (frame),
- bp_until);
- make_cleanup_delete_breakpoint (breakpoint2);
++ if (canonical->pre_expanded)
++ {
++ create_breakpoint_sal (gdbarch, sals, canonical->canonical[0],
++ cond_string, type, disposition,
++ thread, task, ignore_count, ops,
++ from_tty, enabled, internal,
++ canonical->special_display);
++ return;
++ }
+
-+ set_longjmp_breakpoint (thread);
-+ tp->initiating_frame = frame_unwind_caller_id (frame);
-+ make_cleanup (delete_longjmp_breakpoint_cleanup, &thread);
+ for (i = 0; i < sals.nelts; ++i)
+ {
+ struct symtabs_and_lines expanded =
+@@ -8148,7 +8275,7 @@ create_breakpoint (struct gdbarch *gdbar
+ mention (b);
}
-
- proceed (-1, TARGET_SIGNAL_DEFAULT, 0);
-@@ -8437,6 +8614,7 @@ until_break_command (char *arg, int from_tty, int anywhere)
-
- args->breakpoint = breakpoint;
- args->breakpoint2 = breakpoint2;
-+ args->thread_num = thread;
-
- discard_cleanups (old_chain);
- add_continuation (inferior_thread (),
-@@ -9564,12 +9742,22 @@ delete_breakpoint (struct breakpoint *bpt)
-
- /* At least avoid this stale reference until the reference counting of
- breakpoints gets resolved. */
-- if (bpt->related_breakpoint != NULL)
-+ if (bpt->related_breakpoint != bpt)
+
+- if (sals.nelts > 1)
++ if (sals.nelts > 1 && !canonical.pre_expanded)
{
-- gdb_assert (bpt->related_breakpoint->related_breakpoint == bpt);
-- bpt->related_breakpoint->disposition = disp_del_at_next_stop;
-- bpt->related_breakpoint->related_breakpoint = NULL;
-- bpt->related_breakpoint = NULL;
-+ if (bpt->type == bp_watchpoint_scope)
-+ watchpoint_del_at_next_stop (bpt->related_breakpoint);
-+ else if (bpt->related_breakpoint->type == bp_watchpoint_scope)
-+ watchpoint_del_at_next_stop (bpt);
-+ else
+ warning (_("Multiple breakpoints were set.\nUse the "
+ "\"delete\" command to delete unwanted breakpoints."));
+@@ -9020,6 +9147,7 @@ watch_command_1 (char *arg, int accessfl
+ b = set_raw_breakpoint_without_location (NULL, bp_type);
+ set_breakpoint_number (internal, b);
+ b->thread = thread;
++ b->pspace = current_program_space;
+ b->disposition = disp_donttouch;
+ b->exp = exp;
+ b->exp_valid_block = exp_valid_block;
+@@ -10182,6 +10310,9 @@ update_global_location_list (int should_
+ int keep_in_target = 0;
+ int removed = 0;
+
++ if (old_loc->pspace != current_program_space)
++ continue;
++
+ /* 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
+@@ -10946,12 +11077,14 @@ update_breakpoint_locations (struct brea
+ On return, FOUND will be 1 if any SaL was found, zero otherwise. */
+
+ static struct symtabs_and_lines
+-addr_string_to_sals (struct breakpoint *b, char *addr_string, int *found)
++addr_string_to_sals (struct breakpoint *b, char *addr_string, int *found,
++ int *pre_expanded)
+ {
+ char *s;
+ int marker_spec;
+ struct symtabs_and_lines sals = {0};
+ struct gdb_exception e;
++ int my_pre_expanded = 0;
+
+ s = addr_string;
+ marker_spec = b->type == bp_static_tracepoint && is_marker_spec (s);
+@@ -10970,7 +11103,27 @@ addr_string_to_sals (struct breakpoint *
+ error (_("marker %s not found"), b->static_trace_marker_id);
+ }
+ else
+- sals = decode_line_1 (&s, 1, (struct symtab *) NULL, 0, NULL);
+ {
-+ struct breakpoint *related;
++ struct linespec_result canonical;
+
-+ /* Unlink bpt from the bpt->related_breakpoint ring. */
-+ for (related = bpt; related->related_breakpoint != bpt;
-+ related = related->related_breakpoint);
-+ related->related_breakpoint = bpt->related_breakpoint;
-+ bpt->related_breakpoint = bpt;
++ init_linespec_result (&canonical);
++ sals = decode_line_1 (&s, 1, (struct symtab *) NULL, 0,
++ &canonical);
++
++ /* We don't need the contents. */
++ if (canonical.canonical)
++ {
++ int i;
++
++ for (i = 0; i < sals.nelts; ++i)
++ xfree (canonical.canonical[i]);
++ xfree (canonical.canonical);
++ }
++
++ my_pre_expanded = canonical.pre_expanded;
++ if (pre_expanded)
++ *pre_expanded = my_pre_expanded;
+ }
}
-
- observer_notify_breakpoint_deleted (bpt->number);
-@@ -9658,6 +9846,7 @@ delete_command (char *arg, int from_tty)
- && b->type != bp_overlay_event
- && b->type != bp_longjmp_master
- && b->type != bp_std_terminate_master
-+ && b->type != bp_exception_master
- && b->number >= 0)
- {
- breaks_to_delete = 1;
-@@ -9679,6 +9868,7 @@ delete_command (char *arg, int from_tty)
- && b->type != bp_overlay_event
- && b->type != bp_longjmp_master
- && b->type != bp_std_terminate_master
-+ && b->type != bp_exception_master
- && b->number >= 0)
- delete_breakpoint (b);
- }
-@@ -9887,6 +10077,9 @@ update_breakpoint_locations (struct breakpoint *b,
- return;
-
- b->loc = NULL;
-+ xfree (b->source_file);
-+ b->source_file = NULL;
-+ b->line_number = 0;
-
- for (i = 0; i < sals.nelts; ++i)
+ if (e.reason < 0)
{
-@@ -9913,11 +10106,7 @@ update_breakpoint_locations (struct breakpoint *b,
- }
- }
-
-- if (b->source_file != NULL)
-- xfree (b->source_file);
-- if (sals.sals[i].symtab == NULL)
-- b->source_file = NULL;
-- else
-+ if (sals.sals[i].symtab != NULL && b->source_file == NULL)
- b->source_file = xstrdup (sals.sals[i].symtab->filename);
-
- if (b->line_number == 0)
-@@ -9999,6 +10188,7 @@ breakpoint_re_set_one (void *bint)
- case bp_tracepoint:
- case bp_fast_tracepoint:
- case bp_static_tracepoint:
-+ case bp_gnu_ifunc_resolver:
- /* Do not attempt to re-set breakpoints disabled during startup. */
- if (b->enable_state == bp_startup_disabled)
- return 0;
-@@ -10139,6 +10329,7 @@ breakpoint_re_set_one (void *bint)
- case bp_overlay_event:
- case bp_longjmp_master:
- case bp_std_terminate_master:
-+ case bp_exception_master:
- delete_breakpoint (b);
- break;
+@@ -11003,7 +11156,7 @@ addr_string_to_sals (struct breakpoint *
-@@ -10162,7 +10353,10 @@ breakpoint_re_set_one (void *bint)
- case bp_step_resume:
- case bp_longjmp:
- case bp_longjmp_resume:
-+ case bp_exception:
-+ case bp_exception_resume:
- case bp_jit_event:
-+ case bp_gnu_ifunc_resolver_return:
- break;
+ if (e.reason == 0 || e.error != NOT_FOUND_ERROR)
+ {
+- gdb_assert (sals.nelts == 1);
++ gdb_assert (my_pre_expanded || sals.nelts == 1);
+
+ resolve_sal_pc (&sals.sals[0]);
+ if (b->condition_not_parsed && s && s[0])
+@@ -11044,22 +11197,27 @@ re_set_breakpoint (struct breakpoint *b)
+ struct symtabs_and_lines expanded = {0};
+ struct symtabs_and_lines expanded_end = {0};
+ struct cleanup *cleanups = make_cleanup (null_cleanup, NULL);
++ int pre_expanded = 0;
+
+ input_radix = b->input_radix;
+ save_current_space_and_thread ();
+ switch_to_program_space_and_thread (b->pspace);
+ set_language (b->language);
+
+- sals = addr_string_to_sals (b, b->addr_string, &found);
++ sals = addr_string_to_sals (b, b->addr_string, &found, &pre_expanded);
+ if (found)
+ {
+ make_cleanup (xfree, sals.sals);
+- expanded = expand_line_sal_maybe (sals.sals[0]);
++ if (pre_expanded)
++ expanded = sals;
++ else
++ expanded = expand_line_sal_maybe (sals.sals[0]);
}
-@@ -10205,6 +10399,7 @@ breakpoint_re_set (void)
- create_longjmp_master_breakpoint ("siglongjmp");
- create_longjmp_master_breakpoint ("_siglongjmp");
- create_std_terminate_master_breakpoint ("std::terminate()");
-+ create_exception_master_breakpoint ();
- }
- \f
- /* Reset the thread number of this breakpoint:
-@@ -10334,11 +10529,20 @@ map_breakpoint_numbers (char *args, void (*function) (struct breakpoint *,
- ALL_BREAKPOINTS_SAFE (b, tmp)
- if (b->number == num)
- {
-- struct breakpoint *related_breakpoint = b->related_breakpoint;
-+ struct breakpoint *related_breakpoint;
-+
- match = 1;
-- function (b, data);
-- if (related_breakpoint)
-- function (related_breakpoint, data);
-+ related_breakpoint = b;
-+ do
-+ {
-+ struct breakpoint *next_related_b;
-+
-+ /* FUNCTION can be also delete_breakpoint. */
-+ next_related_b = related_breakpoint->related_breakpoint;
-+ function (related_breakpoint, data);
-+ related_breakpoint = next_related_b;
-+ }
-+ while (related_breakpoint != b);
- break;
- }
- if (match == 0)
-@@ -11428,6 +11632,22 @@ all_tracepoints ()
+ if (b->addr_string_range_end)
+ {
+- sals_end = addr_string_to_sals (b, b->addr_string_range_end, &found);
++ sals_end = addr_string_to_sals (b, b->addr_string_range_end, &found,
++ NULL);
+ if (found)
+ {
+ make_cleanup (xfree, sals_end.sals);
+@@ -12496,6 +12654,24 @@ all_tracepoints (void)
return tp_vec;
}
++#if 0
+/* Call type_mark_used for any TYPEs referenced from this GDB source file. */
+
+static void
+ type_mark_used (value_type (b->val));
+ }
+}
++#endif
+
\f
- /* This help string is used for the break, hbreak, tbreak and thbreak commands.
- It is defined as a macro to prevent duplication.
-@@ -11497,6 +11717,107 @@ save_command (char *arg, int from_tty)
- help_list (save_cmdlist, "save ", -1, gdb_stdout);
- }
-
-+static void
-+gnu_ifunc_resolver_stop (struct breakpoint *b)
-+{
-+ struct breakpoint *b_return;
-+ struct frame_info *prev_frame = get_prev_frame (get_current_frame ());
-+ struct frame_id prev_frame_id = get_stack_frame_id (prev_frame);
-+ CORE_ADDR prev_pc = get_frame_pc (prev_frame);
-+ int thread_id = pid_to_thread_id (inferior_ptid);
-+
-+ gdb_assert (b->type == bp_gnu_ifunc_resolver);
-+
-+ for (b_return = b->related_breakpoint; b_return != b;
-+ b_return = b_return->related_breakpoint)
-+ {
-+ gdb_assert (b_return->type == bp_gnu_ifunc_resolver_return);
-+ gdb_assert (b_return->loc != NULL && b_return->loc->next == NULL);
-+ gdb_assert (frame_id_p (b_return->frame_id));
-+
-+ if (b_return->thread == thread_id
-+ && b_return->loc->requested_address == prev_pc
-+ && frame_id_eq (b_return->frame_id, prev_frame_id))
-+ break;
-+ }
-+
-+ if (b_return == b)
-+ {
-+ struct symtab_and_line sal;
-+
-+ /* No need to call find_pc_line for symbols resolving as this is only
-+ a helper breakpointer never shown to the user. */
-+
-+ init_sal (&sal);
-+ sal.pspace = current_inferior ()->pspace;
-+ sal.pc = prev_pc;
-+ sal.section = find_pc_overlay (sal.pc);
-+ sal.explicit_pc = 1;
-+ b_return = set_momentary_breakpoint (get_frame_arch (prev_frame), sal,
-+ prev_frame_id,
-+ bp_gnu_ifunc_resolver_return);
-+
-+ /* Add new b_return to the ring list b->related_breakpoint. */
-+ gdb_assert (b_return->related_breakpoint == b_return);
-+ b_return->related_breakpoint = b->related_breakpoint;
-+ b->related_breakpoint = b_return;
-+ }
-+}
-+
-+static void
-+gnu_ifunc_resolver_return_stop (struct breakpoint *b)
-+{
-+ struct gdbarch *gdbarch = get_frame_arch (get_current_frame ());
-+ struct type *func_func_type = builtin_type (gdbarch)->builtin_func_func;
-+ struct type *value_type = TYPE_TARGET_TYPE (func_func_type);
-+ struct regcache *regcache = get_thread_regcache (inferior_ptid);
-+ struct value *value;
-+ CORE_ADDR resolved_address, resolved_pc;
-+ struct symtab_and_line sal;
-+ struct symtabs_and_lines sals;
-+
-+ gdb_assert (b->type == bp_gnu_ifunc_resolver_return);
-+
-+ value = allocate_value (value_type);
-+ gdbarch_return_value (gdbarch, func_func_type, value_type, regcache,
-+ value_contents_raw (value), NULL);
-+ resolved_address = value_as_address (value);
-+ resolved_pc = gdbarch_convert_from_func_ptr_addr (gdbarch,
-+ resolved_address,
-+ ¤t_target);
-+
-+ while (b->related_breakpoint != b)
-+ {
-+ struct breakpoint *b_next = b->related_breakpoint;
-+
-+ switch (b->type)
-+ {
-+ case bp_gnu_ifunc_resolver:
-+ break;
-+ case bp_gnu_ifunc_resolver_return:
-+ delete_breakpoint (b);
-+ break;
-+ default:
-+ internal_error (__FILE__, __LINE__,
-+ _("handle_inferior_event: Invalid "
-+ "gnu-indirect-function breakpoint type %d"),
-+ (int) b->type);
-+ }
-+ b = b_next;
-+ }
-+ gdb_assert (b->type == bp_gnu_ifunc_resolver);
-+
-+ gdb_assert (current_program_space == b->pspace);
-+ gnu_ifunc_record_cache (gdbarch, b->addr_string, resolved_pc);
-+
-+ sal = find_pc_line (resolved_pc, 0);
-+ sals.nelts = 1;
-+ sals.sals = &sal;
-+
-+ b->type = bp_breakpoint;
-+ update_breakpoint_locations (b, sals);
-+}
-+
- void
- _initialize_breakpoint (void)
- {
-@@ -12022,4 +12343,5 @@ inferior in all-stop mode, gdb behaves as if always-inserted mode is off."),
+ /* This help string is used for the break, hbreak, tbreak and thbreak
+ commands. It is defined as a macro to prevent duplication.
+@@ -13131,4 +13307,7 @@ range (including START-LOCATION and END-
automatic_hardware_breakpoints = 1;
observer_attach_about_to_proceed (breakpoint_about_to_proceed);
++#if 0
+ observer_attach_mark_used (breakpoint_types_mark_used);
++#endif
+ }
+Index: gdb-7.2.90.20110703/gdb/breakpoint.h
+===================================================================
+--- gdb-7.2.90.20110703.orig/gdb/breakpoint.h 2011-05-17 23:25:56.000000000 +0200
++++ gdb-7.2.90.20110703/gdb/breakpoint.h 2011-07-03 10:33:11.000000000 +0200
+@@ -363,6 +363,11 @@ struct bp_location
+ processor's architectual constraints. */
+ CORE_ADDR requested_address;
+
++ /* If the location comes from a SystemTap probe point, and the probe
++ has an associated semaphore variable, then this is the address of
++ the semaphore. Otherwise, this is zero. */
++ CORE_ADDR semaphore;
++
+ char *function_name;
+
+ /* Details of the placed breakpoint, when inserted. */
+@@ -1237,4 +1242,11 @@ extern struct breakpoint *iterate_over_b
+
+ extern int user_breakpoint_p (struct breakpoint *);
+
++/* Set or clear a SystemTap semaphore. LOC is the location which may
++ hold a semaphore. SET is non-zero if the semaphore should be set,
++ or zero if the semaphore should be cleared. Semaphores act as
++ reference counters, so calls to this function must be paired. */
++
++extern void modify_semaphore (struct bp_location *location, int set);
++
+ #endif /* !defined (BREAKPOINT_H) */
+Index: gdb-7.2.90.20110703/gdb/c-typeprint.c
+===================================================================
+--- gdb-7.2.90.20110703.orig/gdb/c-typeprint.c 2011-03-22 18:35:22.000000000 +0100
++++ gdb-7.2.90.20110703/gdb/c-typeprint.c 2011-07-03 10:33:11.000000000 +0200
+@@ -625,9 +625,14 @@ c_type_print_varspec_suffix (struct type
+ fprintf_filtered (stream, ")");
+
+ fprintf_filtered (stream, "[");
+- if (get_array_bounds (type, &low_bound, &high_bound))
+- fprintf_filtered (stream, "%d",
+- (int) (high_bound - low_bound + 1));
++ if (TYPE_RANGE_DATA (TYPE_INDEX_TYPE (type))->high.kind
++ != RANGE_BOUND_KIND_CONSTANT)
++ {
++ /* No _() - printed sources should not be locale dependent. */
++ fprintf_filtered (stream, "variable");
++ }
++ else if (get_array_bounds (type, &low_bound, &high_bound))
++ fprintf_filtered (stream, "%d", (int) (high_bound - low_bound + 1));
+ fprintf_filtered (stream, "]");
+
+ c_type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream,
+Index: gdb-7.2.90.20110703/gdb/cli/cli-utils.c
+===================================================================
+--- gdb-7.2.90.20110703.orig/gdb/cli/cli-utils.c 2011-03-16 22:12:12.000000000 +0100
++++ gdb-7.2.90.20110703/gdb/cli/cli-utils.c 2011-07-03 10:33:11.000000000 +0200
+@@ -245,3 +245,32 @@ remove_trailing_whitespace (const char *
+
+ return s;
}
-diff --git a/gdb/breakpoint.h b/gdb/breakpoint.h
-index 6f5d050..d0c3cc1 100644
---- a/gdb/breakpoint.h
-+++ b/gdb/breakpoint.h
-@@ -56,6 +56,13 @@ enum bptype
- bp_longjmp, /* secret breakpoint to find longjmp() */
- bp_longjmp_resume, /* secret breakpoint to escape longjmp() */
-
-+ /* An internal breakpoint that is installed on the unwinder's
-+ debug hook. */
-+ bp_exception,
-+ /* An internal breakpoint that is set at the point where an
-+ exception will land. */
-+ bp_exception_resume,
-+
- /* Used by wait_for_inferior for stepping over subroutine calls, for
- stepping over signal handlers, and for skipping prologues. */
- bp_step_resume,
-@@ -125,6 +132,9 @@ enum bptype
- /* Master copies of std::terminate breakpoints. */
- bp_std_terminate_master,
-
-+ /* Like bp_longjmp_master, but for exceptions. */
-+ bp_exception_master,
-+
- bp_catchpoint,
-
- bp_tracepoint,
-@@ -133,6 +143,9 @@ enum bptype
-
- /* Event for JIT compiled code generation or deletion. */
- bp_jit_event,
-+
-+ bp_gnu_ifunc_resolver,
-+ bp_gnu_ifunc_resolver_return,
- };
-
- /* States of enablement of breakpoint. */
-@@ -653,6 +666,10 @@ struct bpstat_what
- continuing from a call dummy without popping the frame is not a
- useful one). */
- enum stop_stack_kind call_dummy;
-+
-+ /* Used for BPSTAT_WHAT_SET_LONGJMP_RESUME. True if we are
-+ handling a longjmp, false if we are handling an exception. */
-+ int is_longjmp;
- };
-
- /* The possible return values for print_bpstat, print_it_normal,
-diff --git a/gdb/c-typeprint.c b/gdb/c-typeprint.c
-index 926ae2f..a59b965 100644
---- a/gdb/c-typeprint.c
-+++ b/gdb/c-typeprint.c
-@@ -585,7 +585,13 @@ c_type_print_varspec_suffix (struct type *type, struct ui_file *stream,
- fprintf_filtered (stream, ")");
-
- fprintf_filtered (stream, "[");
-- if (TYPE_LENGTH (TYPE_TARGET_TYPE (type)) > 0
-+ if (TYPE_RANGE_DATA (TYPE_INDEX_TYPE (type))->high.kind
-+ != RANGE_BOUND_KIND_CONSTANT)
-+ {
-+ /* No _() - printed sources should not be locale dependent. */
-+ fprintf_filtered (stream, "variable");
-+ }
-+ else if (TYPE_LENGTH (TYPE_TARGET_TYPE (type)) > 0
- && !TYPE_ARRAY_UPPER_BOUND_IS_UNDEFINED (type))
- fprintf_filtered (stream, "%d",
- (TYPE_LENGTH (type)
-diff --git a/gdb/config.in b/gdb/config.in
-index 1fc457d..f4c846a 100644
---- a/gdb/config.in
-+++ b/gdb/config.in
-@@ -50,11 +50,10 @@
- language is requested. */
- #undef ENABLE_NLS
-
--/* look for global separate data files in this path [DATADIR/gdb] */
-+/* Global directory for GDB data files. */
- #undef GDB_DATADIR
-
--/* Define if the gdb-datadir directory should be relocated when GDB is moved.
-- */
-+/* Define if GDB datadir should be relocated when GDB is moved. */
- #undef GDB_DATADIR_RELOCATABLE
-
- /* Define to be a string naming the default host character set. */
-@@ -769,6 +768,9 @@
- 'ptrdiff_t'. */
- #undef PTRDIFF_T_SUFFIX
-
-+/* Define to install path for Python sources */
-+#undef PYTHONDIR
-+
- /* Define if the python directory should be relocated when GDB is moved. */
- #undef PYTHON_PATH_RELOCATABLE
-
-diff --git a/gdb/configure b/gdb/configure
-index 041ffc1..8243abb 100755
---- a/gdb/configure
-+++ b/gdb/configure
-@@ -679,6 +679,8 @@ REPORT_BUGS_TO
- PKGVERSION
- TARGET_OBS
- subdirs
-+pythondir
-+GDB_DATADIR_PATH
- GDB_DATADIR
- DEBUGDIR
- am__fastdepCC_FALSE
-@@ -945,6 +947,7 @@ enable_dependency_tracking
- with_separate_debug_dir
- with_gdb_datadir
- with_relocated_sources
-+with_pythondir
- enable_targets
- enable_64_bit_bfd
- enable_gdbcli
-@@ -1646,6 +1649,10 @@ Optional Packages:
- [DATADIR/gdb]
- --with-relocated-sources=PATH
- automatically relocate this path for source files
-+ --with-gdb-datadir look for global separate data files in this path
-+ [DATADIR/gdb]
-+ --with-pythondir install Python data files in this path
-+ [DATADIR/gdb/python]
- --with-libunwind use libunwind frame unwinding support
- --with-curses use the curses library instead of the termcap
- library
-@@ -7878,6 +7885,73 @@ _ACEOF
- fi
-
-
-+# GDB's datadir relocation
-+
-+gdbdatadir=${datadir}/gdb
-+
-+
-+# Check whether --with-gdb-datadir was given.
-+if test "${with_gdb_datadir+set}" = set; then :
-+ withval=$with_gdb_datadir; gdbdatadir="${withval}"
-+fi
-+
-+
-+
-+ test "x$prefix" = xNONE && prefix="$ac_default_prefix"
-+ test "x$exec_prefix" = xNONE && exec_prefix='${prefix}'
-+ ac_define_dir=`eval echo $gdbdatadir`
-+ ac_define_dir=`eval echo $ac_define_dir`
-+
-+cat >>confdefs.h <<_ACEOF
-+#define GDB_DATADIR "$ac_define_dir"
-+_ACEOF
-+
-+
-+
-+if test "x$exec_prefix" = xNONE || test "x$exec_prefix" = 'x${prefix}'; then
-+ if test "x$prefix" = xNONE; then
-+ test_prefix=/usr/local
-+ else
-+ test_prefix=$prefix
-+ fi
-+else
-+ test_prefix=$exec_prefix
-+fi
-+
-+case ${gdbdatadir} in
-+ "${test_prefix}"|"${test_prefix}/"*|\
-+ '${exec_prefix}'|'${exec_prefix}/'*)
-+
-+$as_echo "#define GDB_DATADIR_RELOCATABLE 1" >>confdefs.h
+
-+ ;;
-+esac
-+GDB_DATADIR_PATH=${gdbdatadir}
++/* See documentation in cli-utils.h. */
+
++char *
++extract_arg (char **arg)
++{
++ char *result, *copy;
+
++ if (!*arg)
++ return NULL;
+
-+# Check whether --with-pythondir was given.
-+if test "${with_pythondir+set}" = set; then :
-+ withval=$with_pythondir; pythondir="${withval}"
-+else
-+ pythondir=no
-+fi
++ /* Find the start of the argument. */
++ *arg = skip_spaces (*arg);
++ if (! **arg)
++ return NULL;
++ result = *arg;
+
++ /* Find the end of the argument. */
++ *arg = skip_to_space (*arg + 1);
+
-+# If the user passed in a path, define it. Otherwise, compute it at
-+# runtime based on the possibly-relocatable datadir.
-+if test "$pythondir" = "no"; then
-+ pythondir='$(GDB_DATADIR_PATH)/python'
-+else
++ if (result == *arg)
++ return NULL;
+
-+cat >>confdefs.h <<_ACEOF
-+#define PYTHONDIR "$pythondir"
-+_ACEOF
++ copy = xmalloc (*arg - result + 1);
++ memcpy (copy, result, *arg - result);
++ copy[*arg - result] = '\0';
+
-+fi
++ return copy;
++}
+Index: gdb-7.2.90.20110703/gdb/cli/cli-utils.h
+===================================================================
+--- gdb-7.2.90.20110703.orig/gdb/cli/cli-utils.h 2011-03-16 22:12:12.000000000 +0100
++++ gdb-7.2.90.20110703/gdb/cli/cli-utils.h 2011-07-03 10:33:11.000000000 +0200
+@@ -103,4 +103,11 @@ extern char *skip_to_space (char *inp);
+ START. */
+
+ extern char *remove_trailing_whitespace (const char *start, char *s);
+
++/* A helper function to extract an argument from *ARG. An argument is
++ delimited by whitespace. The return value is either NULL if no
++ argument was found, or an xmalloc'd string. */
+
++extern char *extract_arg (char **arg);
+
+ #endif /* CLI_UTILS_H */
+Index: gdb-7.2.90.20110703/gdb/coffread.c
+===================================================================
+--- gdb-7.2.90.20110703.orig/gdb/coffread.c 2011-03-17 14:19:23.000000000 +0100
++++ gdb-7.2.90.20110703/gdb/coffread.c 2011-07-03 10:33:11.000000000 +0200
+@@ -2193,6 +2193,7 @@ static const struct sym_fns coff_sym_fns
+ default_symfile_relocate, /* sym_relocate: Relocate a debug
+ section. */
++ NULL, /* sym_probe_fns */
+ &psym_functions
+ };
- subdirs="$subdirs doc testsuite"
-@@ -10919,6 +10993,7 @@ $as_echo "#define HAVE_PYTHON 1" >>confdefs.h
- CONFIG_DEPS="$CONFIG_DEPS \$(SUBDIR_PYTHON_DEPS)"
- CONFIG_SRCS="$CONFIG_SRCS \$(SUBDIR_PYTHON_SRCS)"
- CONFIG_INSTALL="$CONFIG_INSTALL install-python"
-+ CONFIG_UNINSTALL="$CONFIG_UNINSTALL uninstall-python"
- ENABLE_CFLAGS="$ENABLE_CFLAGS \$(SUBDIR_PYTHON_CFLAGS)"
+Index: gdb-7.2.90.20110703/gdb/data-directory/Makefile.in
+===================================================================
+--- gdb-7.2.90.20110703.orig/gdb/data-directory/Makefile.in 2011-02-04 19:34:41.000000000 +0100
++++ gdb-7.2.90.20110703/gdb/data-directory/Makefile.in 2011-07-03 10:33:11.000000000 +0200
+@@ -52,11 +52,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)" \
+Index: gdb-7.2.90.20110703/gdb/dbxread.c
+===================================================================
+--- gdb-7.2.90.20110703.orig/gdb/dbxread.c 2011-03-23 19:23:54.000000000 +0100
++++ gdb-7.2.90.20110703/gdb/dbxread.c 2011-07-03 10:33:11.000000000 +0200
+@@ -1,6 +1,6 @@
+ /* Read dbx symbol tables and convert to internal format, for GDB.
+ Copyright (C) 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995,
+- 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2008, 2009, 2010.
++ 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2008, 2009, 2010, 2011.
+ Free Software Foundation, Inc.
- # Flags needed to compile Python code (taken from python-config --cflags).
-diff --git a/gdb/configure.ac b/gdb/configure.ac
-index b69c3b6..4e89558 100644
---- a/gdb/configure.ac
-+++ b/gdb/configure.ac
-@@ -108,6 +108,51 @@ AS_HELP_STRING([--with-relocated-sources=PATH], [automatically relocate this pat
- [Relocated directory for source files. ])
- ])
+ This file is part of GDB.
+@@ -3587,6 +3587,7 @@ static const struct sym_fns aout_sym_fns
+ default_symfile_segments, /* Get segment information from a file. */
+ NULL,
+ default_symfile_relocate, /* Relocate a debug section. */
++ NULL, /* sym_probe_fns */
+ &psym_functions
+ };
-+# GDB's datadir relocation
-+
-+gdbdatadir=${datadir}/gdb
-+
-+AC_ARG_WITH([gdb-datadir],
-+ [AS_HELP_STRING([--with-gdb-datadir],
-+ [look for global separate data files in this path [DATADIR/gdb]])], [gdbdatadir="${withval}"])
-+
-+AC_DEFINE_DIR(GDB_DATADIR, gdbdatadir,
-+ [Global directory for GDB data files. ])
+Index: gdb-7.2.90.20110703/gdb/defs.h
+===================================================================
+--- gdb-7.2.90.20110703.orig/gdb/defs.h 2011-03-31 16:32:48.000000000 +0200
++++ gdb-7.2.90.20110703/gdb/defs.h 2011-07-03 10:33:11.000000000 +0200
+@@ -398,6 +398,8 @@ extern struct cleanup *make_cleanup_rest
+ extern struct cleanup *
+ set_batch_flag_and_make_cleanup_restore_page_info (void);
+
++extern struct cleanup *make_cleanup_restore_selected_frame (void);
+
-+if test "x$exec_prefix" = xNONE || test "x$exec_prefix" = 'x${prefix}'; then
-+ if test "x$prefix" = xNONE; then
-+ test_prefix=/usr/local
-+ else
-+ test_prefix=$prefix
-+ fi
-+else
-+ test_prefix=$exec_prefix
-+fi
-+
-+case ${gdbdatadir} in
-+ "${test_prefix}"|"${test_prefix}/"*|\
-+ '${exec_prefix}'|'${exec_prefix}/'*)
-+ AC_DEFINE(GDB_DATADIR_RELOCATABLE, 1, [Define if GDB datadir should be relocated when GDB is moved.])
-+ ;;
-+esac
-+GDB_DATADIR_PATH=${gdbdatadir}
-+AC_SUBST(GDB_DATADIR_PATH)
-+
-+AC_ARG_WITH([pythondir],
-+ [AS_HELP_STRING([--with-pythondir],
-+ [install Python data files in this path [DATADIR/gdb/python]])], [pythondir="${withval}"], [pythondir=no])
-+
-+# If the user passed in a path, define it. Otherwise, compute it at
-+# runtime based on the possibly-relocatable datadir.
-+if test "$pythondir" = "no"; then
-+ pythondir='$(GDB_DATADIR_PATH)/python'
-+else
-+ AC_DEFINE_UNQUOTED(PYTHONDIR, "$pythondir",
-+ [Define to install path for Python sources])
-+fi
-+AC_SUBST(pythondir)
-+
-+
- AC_CONFIG_SUBDIRS(doc testsuite)
-
- # Check whether to support alternative target configurations
-@@ -833,6 +878,7 @@ if test "${have_libpython}" != no; then
- CONFIG_DEPS="$CONFIG_DEPS \$(SUBDIR_PYTHON_DEPS)"
- CONFIG_SRCS="$CONFIG_SRCS \$(SUBDIR_PYTHON_SRCS)"
- CONFIG_INSTALL="$CONFIG_INSTALL install-python"
-+ CONFIG_UNINSTALL="$CONFIG_UNINSTALL uninstall-python"
- ENABLE_CFLAGS="$ENABLE_CFLAGS \$(SUBDIR_PYTHON_CFLAGS)"
-
- # Flags needed to compile Python code (taken from python-config --cflags).
-diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
-index 65d4899..96767b0 100644
---- a/gdb/doc/gdb.texinfo
-+++ b/gdb/doc/gdb.texinfo
-@@ -1162,6 +1162,16 @@ for remote debugging.
+ extern char *gdb_realpath (const char *);
+ extern char *xfullpath (const char *);
+
+Index: gdb-7.2.90.20110703/gdb/doc/gdb.texinfo
+===================================================================
+--- gdb-7.2.90.20110703.orig/gdb/doc/gdb.texinfo 2011-07-02 21:59:29.000000000 +0200
++++ gdb-7.2.90.20110703/gdb/doc/gdb.texinfo 2011-07-03 10:33:11.000000000 +0200
+@@ -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.
@c resolve the situation of these eventually
@item -tui
@cindex @code{--tui}
-@@ -14308,6 +14318,7 @@ program. To debug a core dump of a previous run, you must also tell
- @menu
- * Files:: Commands to specify files
- * Separate Debug Files:: Debugging information in separate files
-+* Index Files:: Index files speed up GDB
- * Symbol Errors:: Errors reading symbol files
- * Data Files:: GDB data files
+@@ -3286,6 +3296,7 @@ all breakpoints in that range are operat
+ * Conditions:: Break conditions
+ * Break Commands:: Breakpoint command lists
+ * Save Breakpoints:: How to save breakpoints in a file
++* Static Probe Points:: Listing static probe points
+ * Error in Breakpoints:: ``Cannot insert breakpoints''
+ * Breakpoint-related Warnings:: ``Breakpoint address adjusted...''
@end menu
-@@ -15197,6 +15208,46 @@ gnu_debuglink_crc32 (unsigned long crc,
- This computation does not apply to the ``build ID'' method.
-
+@@ -4499,6 +4510,50 @@ and remove the breakpoint definitions yo
+ that can no longer be recreated.
+ @end table
-+@node Index Files
-+@section Index Files Speed Up @value{GDBN}
-+@cindex index files
-+@cindex @samp{.gdb_index} section
-+
-+When @value{GDBN} finds a symbol file, it scans the symbols in the
-+file in order to construct an internal symbol table. This lets most
-+@value{GDBN} operations work quickly---at the cost of a delay early
-+on. For large programs, this delay can be quite lengthy, so
-+@value{GDBN} provides a way to build an index, which speeds up
-+startup.
++@node Static Probe Points
++@subsection Static Probe Points
+
-+The index is stored as a section in the symbol file. @value{GDBN} can
-+write the index to a file, then you can put it into the symbol file
-+using @command{objcopy}.
++@cindex SystemTap static probe point
++@cindex sdt-probe
++The @sc{gnu}/Linux tool @code{SystemTap} provides a way for
++applications to embed static probes, using @file{sys/sdt.h}. @value{GDBN}
++can list the available probes, and you can put breakpoints at the
++probe points (@pxref{Specify Location}).
+
-+To create an index file, use the @code{save gdb-index} command:
++You can examine the available @code{SystemTap} static probes using
++@code{info probes}:
+
+@table @code
-+@item save gdb-index @var{directory}
-+@kindex save gdb-index
-+Create an index file for each symbol file currently known by
-+@value{GDBN}. Each file is named after its corresponding symbol file,
-+with @samp{.gdb-index} appended, and is written into the given
-+@var{directory}.
-+@end table
++@kindex info probes
++@item info probes [@var{provider} [@var{name} [@var{objfile}]]]
++List the available @code{SystemTap} static probes.
++
++If given, @var{provider} is a regular expression used to select which
++providers to list. If omitted, all providers are listed.
+
-+Once you have created an index file you can merge it into your symbol
-+file, here named @file{symfile}, using @command{objcopy}:
++If given, @var{name} is a regular expression used to select which
++probes to list. If omitted, all probes are listed.
+
-+@smallexample
-+$ objcopy --add-section .gdb_index=symfile.gdb-index \
-+ --set-section-flags .gdb_index=readonly symfile symfile
-+@end smallexample
++If given, @var{objfile} is a regular expression used to select which
++object files (executable or shared libraries) to examine. If not
++given, all object files are considered.
++@end table
+
-+There are currently some limitation on indices. They only work when
-+for DWARF debugging information, not stabs. And, they do not
-+currently work for programs using Ada.
++@vindex $_probe_arg@r{, convenience variable}
++A probe may specify up to ten arguments. These are available at the
++point at which the probe is defined---that is, when the current PC is
++at the probe's location. The arguments are available using the
++convenience variables (@pxref{Convenience Vars})
++@code{$_probe_arg0}@dots{}@code{$_probe_arg9}. Each probe argument is
++an integer of the appropriate size; types are not preserved. The
++convenience variable @code{$_probe_argc} holds the number of arguments
++at the current probe point.
++
++These variables are always available, but attempts to access them at
++any location other than a probe point will cause @value{GDBN} to give
++an error.
++
++
+ @c @ifclear BARETARGET
+ @node Error in Breakpoints
+ @subsection ``Cannot insert breakpoints''
+@@ -6414,6 +6469,29 @@ specify the function unambiguously, e.g.
+ functions with identical names in different source files.
+ @end table
+
++@cindex SystemTap static probe point
++@item probe:@r{[}@var{objfile}:@r{]}@r{[}@var{provider}:@r{]}@var{name}
++The @sc{gnu}/Linux tool @code{SystemTap} provides a way for
++applications to embed static probes. This form of linespec specifies
++the location of such a static probe. See
++@uref{http://sourceware.org/systemtap/wiki/AddingUserSpaceProbingToApps}
++for more information on static probes.
++
++If @var{objfile} is given, only probes coming from that shared library
++or executable are considered. If @var{provider} is given, then only
++probes from that provider are considered.
++
++@xref{Static Probe Points}, for more information on finding and using
++static probes.
++
++Some probes have an associated semaphore variable; for instance, this
++happens automatically if you defined your probe using a DTrace-style
++@file{.d} file. If your probe has a semaphore, @value{GDBN} will
++automatically enable it when you specify a breakpoint using the
++@samp{probe:} notation. But, if you put a breakpoint at a probe's
++location by some other method (e.g., @code{break file:line}), then
++@value{GDBN} will not automatically set the semaphore.
+
+ @end table
+
+
+@@ -8500,6 +8578,10 @@ to match the format in which the data wa
+ The variable @code{$_exitcode} is automatically set to the exit code when
+ the program being debugged terminates.
+
++@item $_probe_argc
++@itemx $_probe_arg0@dots{}$_probe_arg9
++Arguments to a SystemTap static probe. @xref{Static Probe Points}.
+
- @node Symbol Errors
- @section Errors Reading Symbol Files
+ @item $_sdata
+ @vindex $_sdata@r{, inspect, convenience variable}
+ The variable @code{$_sdata} contains extra collected static tracepoint
+@@ -10219,6 +10301,16 @@ Collect all function arguments.
+ @item $locals
+ Collect all local variables.
-@@ -20349,8 +20400,6 @@ containing @code{end}. For example:
++@item $_probe_argc
++Collects the number of arguments from the @code{SystemTap} probe at
++which the tracepoint is located.
++@xref{Static Probe Points,,Static Probe Points}
++
++@item $_probe_arg@var{N}
++Where @var{N} varies from 0 to 9. Collects the @var{N}th argument
++from the @code{SystemTap} probe at which the tracepoint is located.
++@xref{Static Probe Points,,Static Probe Points}
++
+ @item $_sdata
+ @vindex $_sdata@r{, collect}
+ Collect static tracepoint marker specific data. Only available for
+@@ -20720,8 +20812,6 @@ containing @code{end}. For example:
@smallexample
(@value{GDBP}) python
>print 23
>end
23
-@@ -20363,6 +20412,14 @@ in a Python script. This can be controlled using @code{maint set
+@@ -20734,6 +20824,14 @@ in a Python script. This can be control
python print-stack}: if @code{on}, the default, then Python stack
printing is enabled; if @code{off}, then Python stack printing is
disabled.
@end table
It is also possible to execute a Python script from the @value{GDBN}
-@@ -20384,6 +20441,14 @@ and thus is always available.
+@@ -20755,6 +20853,14 @@ and thus is always available.
@cindex python api
@cindex programming in python
@cindex python stdout
@cindex python pagination
At startup, @value{GDBN} overrides Python's @code{sys.stdout} and
-@@ -20395,7 +20460,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.
-@@ -20456,6 +20521,12 @@ Return a sequence holding all of @value{GDBN}'s breakpoints.
- @xref{Breakpoints In Python}, for more information.
- @end defun
-
-+@findex gdb.breakpoints
-+@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
-@@ -20472,6 +20543,7 @@ a Python value of the appropriate type, and returned.
- @defun history number
- Return a value from @value{GDBN}'s value history (@pxref{Value
- History}). @var{number} indicates which history element to return.
-+
- 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
-@@ -20496,6 +20568,21 @@ compute values, for example, it is the only way to get the value of a
- convenience variable (@pxref{Convenience Vars}) as a @code{gdb.Value}.
- @end defun
-
-+@findex gdb.post_event
-+@defun post_event event
-+Put @var{event}, a callable object taking no arguments, into
-+@value{GDBN}'s internal event queue. This callable will be invoked at
-+some later point, during @value{GDBN}'s event processing. Events
-+posted using @code{post_event} will be run in the order in which they
-+were posted; however, there is no way to know when they will be
-+processed relative to other events inside @value{GDBN}.
-+
-+@value{GDBN} is not thread-safe. If your Python program uses multiple
-+threads, you must be careful to only call @value{GDBN}-specific
-+functions in the main @value{GDBN} thread. @code{post_event} ensures
-+this.
-+@end defun
-+
- @findex gdb.write
- @defun write string
- Print a string to @value{GDBN}'s paginated standard output stream.
-diff --git a/gdb/doc/gdbint.texinfo b/gdb/doc/gdbint.texinfo
-index 54187dd..320b501 100644
---- a/gdb/doc/gdbint.texinfo
-+++ b/gdb/doc/gdbint.texinfo
-@@ -2102,6 +2102,18 @@ time, and so we attempt to handle symbols incrementally. For instance,
+Index: gdb-7.2.90.20110703/gdb/doc/gdbint.texinfo
+===================================================================
+--- gdb-7.2.90.20110703.orig/gdb/doc/gdbint.texinfo 2011-02-04 20:10:12.000000000 +0100
++++ gdb-7.2.90.20110703/gdb/doc/gdbint.texinfo 2011-07-03 10:33:11.000000000 +0200
+@@ -2104,6 +2104,18 @@ time, and so we attempt to handle symbol
we create @dfn{partial symbol tables} consisting of only selected
symbols, and only expand them to full symbol tables when necessary.
@section Symbol Reading
@cindex symbol reading
-@@ -2194,6 +2206,7 @@ symtab. Upon return, @code{pst->readin} should have been set to 1, and
+@@ -2196,6 +2208,7 @@ symtab. Upon return, @code{pst->readin}
zero if there were no symbols in that part of the symbol file.
@end table
@section Partial Symbol Tables
@value{GDBN} has three types of symbol tables:
-@@ -2295,6 +2308,7 @@ and partial symbol tables behind a set of function pointers known as
+@@ -2297,6 +2310,7 @@ and partial symbol tables behind a set o
the @dfn{quick symbol functions}. These are documented in
@file{symfile.h}.
@section Types
@unnumberedsubsec Fundamental Types (e.g., @code{FT_VOID}, @code{FT_BOOLEAN}).
-@@ -2317,6 +2331,7 @@ types map to one @code{TYPE_CODE_*} type, and are distinguished by
+@@ -2319,6 +2333,7 @@ types map to one @code{TYPE_CODE_*} type
other members of the type struct, such as whether the type is signed
or unsigned, and how many bits it uses.
@unnumberedsubsec Builtin Types (e.g., @code{builtin_type_void}, @code{builtin_type_char}).
These are instances of type structs that roughly correspond to
-@@ -2331,6 +2346,7 @@ only one instance exists, while @file{c-lang.c} builds as many
+@@ -2333,6 +2348,7 @@ only one instance exists, while @file{c-
@code{TYPE_CODE_INT} types as needed, with each one associated with
some particular objfile.
@section Object File Formats
@cindex object file formats
-@@ -2416,6 +2432,7 @@ SOM, which is a cross-language ABI).
+@@ -2418,6 +2434,7 @@ SOM, which is a cross-language ABI).
The SOM reader is in @file{somread.c}.
@section Debugging File Formats
This section describes characteristics of debugging information that
-@@ -2487,6 +2504,7 @@ DWARF 3 is an improved version of DWARF 2.
+@@ -2489,6 +2506,7 @@ DWARF 3 is an improved version of DWARF
@cindex SOM debugging info
Like COFF, the SOM definition includes debugging information.
@section Adding a New Symbol Reader to @value{GDBN}
@cindex adding debugging info reader
-@@ -2509,6 +2527,7 @@ will only ever be implemented by one object file format may be called
+@@ -2511,6 +2529,7 @@ will only ever be implemented by one obj
directly. This interface should be described in a file
@file{bfd/lib@var{xyz}.h}, which is included by @value{GDBN}.
@section Memory Management for Symbol Files
Most memory associated with a loaded symbol file is stored on
-@@ -2520,10 +2539,45 @@ released when the objfile is unloaded or reloaded. Therefore one
+@@ -2522,10 +2541,45 @@ released when the objfile is unloaded or
objfile must not reference symbol or type data from another objfile;
they could be unloaded at different times.
@node Language Support
-diff --git a/gdb/doc/observer.texi b/gdb/doc/observer.texi
-index e19b8ed..343e160 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
+Index: gdb-7.2.90.20110703/gdb/doc/observer.texi
+===================================================================
+--- gdb-7.2.90.20110703.orig/gdb/doc/observer.texi 2011-01-05 06:09:54.000000000 +0100
++++ gdb-7.2.90.20110703/gdb/doc/observer.texi 2011-07-03 10:33:11.000000000 +0200
+@@ -223,6 +223,11 @@ Bytes from @var{data} to @var{data} + @v
to the current inferior at @var{addr}.
@end deftypefun
-+@deftypefun void mark_used (void)
-+Mark any possibly reclaimable objects as used during a mark-and-sweep garbage
-+collector pass. Currently only @code{type_mark_used} marker is supported.
-+@end deftypefun
++@c @deftypefun void mark_used (void)
++@c Mark any possibly reclaimable objects as used during a mark-and-sweep garbage
++@c collector pass. Currently only @code{type_mark_used} marker is supported.
++@c @end deftypefun
+
@deftypefun void test_notification (int @var{somearg})
This observer is used for internal testing. Do not use.
See testsuite/gdb.gdb/observer.exp.
-diff --git a/gdb/dwarf2expr.c b/gdb/dwarf2expr.c
-index b9ae108..2555908 100644
---- a/gdb/dwarf2expr.c
-+++ b/gdb/dwarf2expr.c
-@@ -875,6 +875,13 @@ execute_stack_op (struct dwarf_expr_context *ctx,
- ctx->dwarf_call (ctx, result);
- goto no_push;
+Index: gdb-7.2.90.20110703/gdb/dwarf2expr.c
+===================================================================
+--- gdb-7.2.90.20110703.orig/gdb/dwarf2expr.c 2011-05-13 20:54:47.000000000 +0200
++++ gdb-7.2.90.20110703/gdb/dwarf2expr.c 2011-07-03 10:33:11.000000000 +0200
+@@ -912,6 +912,13 @@ execute_stack_op (struct dwarf_expr_cont
+ ctx->num_pieces = 0;
+ goto abort_expression;
+ case DW_OP_push_object_address:
+ if (ctx->get_object_address == NULL)
default:
error (_("Unhandled dwarf expression opcode 0x%x"), op);
}
-diff --git a/gdb/dwarf2expr.h b/gdb/dwarf2expr.h
-index 61b8f00..d94c03c 100644
---- a/gdb/dwarf2expr.h
-+++ b/gdb/dwarf2expr.h
-@@ -108,9 +108,15 @@ struct dwarf_expr_context
+Index: gdb-7.2.90.20110703/gdb/dwarf2expr.h
+===================================================================
+--- gdb-7.2.90.20110703.orig/gdb/dwarf2expr.h 2011-02-27 17:25:37.000000000 +0100
++++ gdb-7.2.90.20110703/gdb/dwarf2expr.h 2011-07-03 10:33:11.000000000 +0200
+@@ -114,9 +114,15 @@ struct dwarf_expr_context
#if 0
/* Not yet implemented. */
/* 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 f59bc40..7ff0ef9 100644
---- a/gdb/dwarf2loc.c
-+++ b/gdb/dwarf2loc.c
-@@ -48,6 +48,12 @@ static void
- dwarf_expr_frame_base_1 (struct symbol *framefunc, CORE_ADDR pc,
- const gdb_byte **start, size_t *length);
-
-+static struct value *dwarf2_evaluate_loc_desc (struct type *type,
-+ struct frame_info *frame,
-+ const gdb_byte *data,
-+ unsigned short size,
-+ struct dwarf2_per_cu_data *per_cu);
-+
- /* A helper function for dealing with location lists. Given a
- symbol baton (BATON) and a pc value (PC), find the appropriate
- location expression, set *LOCEXPR_LENGTH, and return a pointer
-@@ -127,6 +133,9 @@ struct dwarf_expr_baton
+Index: gdb-7.2.90.20110703/gdb/dwarf2loc.c
+===================================================================
+--- gdb-7.2.90.20110703.orig/gdb/dwarf2loc.c 2011-03-22 22:06:33.000000000 +0100
++++ gdb-7.2.90.20110703/gdb/dwarf2loc.c 2011-07-03 10:33:11.000000000 +0200
+@@ -134,6 +134,9 @@ struct dwarf_expr_baton
{
struct frame_info *frame;
struct dwarf2_per_cu_data *per_cu;
};
/* Helper functions for dwarf2_evaluate_loc_desc. */
-@@ -195,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 *
symbaton = SYMBOL_LOCATION_BATON (framefunc);
- *start = find_location_expression (symbaton, length, pc);
+ *start = dwarf2_find_location_expression (symbaton, length, pc);
}
- else
+ else if (SYMBOL_COMPUTED_OPS (framefunc) == &dwarf2_locexpr_funcs)
+ gdb_assert (symbaton != NULL);
+ *start = symbaton->data;
+ *length = symbaton->size;
- }
++ }
+ else if (SYMBOL_COMPUTED_OPS (framefunc) == &dwarf2_missing_funcs)
+ {
+ struct dwarf2_locexpr_baton *symbaton;
+ gdb_assert (symbaton == NULL);
+ *start = NULL;
+ *length = 0; /* unused */
-+ }
+ }
+ else
+ internal_error (__FILE__, __LINE__,
+ _("Unsupported SYMBOL_COMPUTED_OPS %p for \"%s\""),
}
/* Helper function for dwarf2_evaluate_loc_desc. Computes the CFA for
-@@ -263,6 +282,158 @@ dwarf_expr_dwarf_call (struct dwarf_expr_context *ctx, size_t die_offset)
- return per_cu_dwarf_call (ctx, die_offset, debaton->per_cu);
+@@ -286,6 +299,172 @@ dwarf_expr_dwarf_call (struct dwarf_expr
+ ctx->get_frame_pc, ctx->baton);
}
+static CORE_ADDR
+ struct dwarf_expr_context *ctx;
+ struct dwarf_expr_baton baton;
+ struct objfile *objfile = dwarf2_per_cu_objfile (per_cu);
++ volatile struct gdb_exception ex;
+
+ baton.frame = frame;
+ baton.per_cu = per_cu;
+ ctx->read_mem = dwarf_expr_read_mem;
+ ctx->get_frame_base = dwarf_expr_frame_base;
+ ctx->get_frame_cfa = dwarf_expr_frame_cfa;
++ ctx->get_frame_pc = dwarf_expr_frame_pc;
+ ctx->get_tls_address = dwarf_expr_tls_address;
+ ctx->dwarf_call = dwarf_expr_dwarf_call;
+ ctx->get_object_address = dwarf_expr_object_address;
+
-+ dwarf_expr_eval (ctx, data, size);
++ TRY_CATCH (ex, RETURN_MASK_ERROR)
++ {
++ dwarf_expr_eval (ctx, data, size);
++ }
++ if (ex.reason < 0)
++ {
++ if (ex.error == NOT_AVAILABLE_ERROR)
++ return NULL;
++ else
++ throw_exception (ex);
++ }
+
+ /* It was used only during dwarf_expr_eval. */
+ ctx->baton = NULL;
+
+ ctx = dwarf_expr_prep_ctx (get_selected_frame (NULL), dlbaton->data,
+ dlbaton->size, dlbaton->per_cu);
++ if (ctx == NULL)
++ throw_error (NOT_AVAILABLE_ERROR, _("Value not available"));
+ if (ctx->num_pieces > 0)
+ error (_("DW_OP_*piece is unsupported for DW_FORM_block"));
+
+ if (!dllbaton)
+ return 0;
+
-+ data = find_location_expression (dllbaton, &size,
-+ get_frame_address_in_block (frame));
++ data = dwarf2_find_location_expression (dllbaton, &size,
++ get_frame_address_in_block (frame));
+ if (data == NULL)
+ return 0;
+
struct piece_closure
{
/* Reference count. */
-@@ -887,10 +1058,8 @@ dwarf2_evaluate_loc_desc (struct type *type, struct frame_info *frame,
- struct dwarf2_per_cu_data *per_cu)
+@@ -1072,11 +1251,8 @@ dwarf2_evaluate_loc_desc_full (struct ty
+ LONGEST byte_offset)
{
struct value *retval;
- struct dwarf_expr_baton baton;
struct dwarf_expr_context *ctx;
-- struct cleanup *old_chain;
+ struct cleanup *old_chain;
- struct objfile *objfile = dwarf2_per_cu_objfile (per_cu);
-+ struct cleanup *old_chain = make_cleanup (null_cleanup, 0);
+- volatile struct gdb_exception ex;
- if (size == 0)
- {
-@@ -900,24 +1069,8 @@ dwarf2_evaluate_loc_desc (struct type *type, struct frame_info *frame,
+ if (byte_offset < 0)
+ invalid_synthetic_pointer ();
+@@ -1089,38 +1265,14 @@ dwarf2_evaluate_loc_desc_full (struct ty
return retval;
}
- baton.frame = frame;
- baton.per_cu = per_cu;
-+ ctx = dwarf_expr_prep_ctx (frame, data, size, per_cu);
-
+-
- ctx = new_dwarf_expr_context ();
- old_chain = make_cleanup_free_dwarf_expr_context (ctx);
-
- ctx->read_mem = dwarf_expr_read_mem;
- ctx->get_frame_base = dwarf_expr_frame_base;
- ctx->get_frame_cfa = dwarf_expr_frame_cfa;
+- ctx->get_frame_pc = dwarf_expr_frame_pc;
- ctx->get_tls_address = dwarf_expr_tls_address;
- ctx->dwarf_call = dwarf_expr_dwarf_call;
--
-- dwarf_expr_eval (ctx, data, size);
- if (ctx->num_pieces > 0)
++ old_chain = make_cleanup (null_cleanup, 0);
+
+- TRY_CATCH (ex, RETURN_MASK_ERROR)
+- {
+- dwarf_expr_eval (ctx, data, size);
+- }
+- if (ex.reason < 0)
++ ctx = dwarf_expr_prep_ctx (frame, data, size, per_cu);
++ if (ctx == NULL)
{
- struct piece_closure *c;
-@@ -951,6 +1104,11 @@ dwarf2_evaluate_loc_desc (struct type *type, struct frame_info *frame,
+- if (ex.error == NOT_AVAILABLE_ERROR)
+- {
+- retval = allocate_value (type);
+- mark_value_bytes_unavailable (retval, 0, TYPE_LENGTH (type));
+- return retval;
+- }
+- else
+- throw_exception (ex);
++ retval = allocate_value (type);
++ mark_value_bytes_unavailable (retval, 0, TYPE_LENGTH (type));
++ return retval;
+ }
+
+ if (ctx->num_pieces > 0)
+@@ -1166,6 +1318,15 @@ dwarf2_evaluate_loc_desc_full (struct ty
CORE_ADDR address = dwarf_expr_fetch_address (ctx, 0);
int in_stack_memory = dwarf_expr_fetch_in_stack_memory (ctx, 0);
++ /* Frame may be needed for check_typedef of TYPE_DYNAMIC. */
++ make_cleanup_restore_selected_frame ();
++ select_frame (frame);
++
+ /* object_address_set called here is required in ALLOCATE_VALUE's
+ CHECK_TYPEDEF for the object's possible
+ DW_OP_push_object_address. */
+ object_address_set (address);
+
- retval = allocate_value (type);
+ retval = allocate_value_lazy (type);
VALUE_LVAL (retval) = lval_memory;
- set_value_lazy (retval, 1);
-@@ -2590,11 +2748,51 @@ loclist_tracepoint_var_ref (struct symbol *symbol, struct gdbarch *gdbarch,
- dlbaton->per_cu);
+ if (in_stack_memory)
+@@ -2855,11 +3016,51 @@ loclist_tracepoint_var_ref (struct symbo
+ dlbaton->per_cu);
}
-/* The set of location functions used with the DWARF-2 expression
+ missing_describe_location,
+ missing_tracepoint_var_ref
+};
-diff --git a/gdb/dwarf2loc.h b/gdb/dwarf2loc.h
-index 826bc45..1e7d8dc 100644
---- a/gdb/dwarf2loc.h
-+++ b/gdb/dwarf2loc.h
-@@ -86,5 +86,14 @@ struct dwarf2_loclist_baton
+Index: gdb-7.2.90.20110703/gdb/dwarf2loc.h
+===================================================================
+--- gdb-7.2.90.20110703.orig/gdb/dwarf2loc.h 2011-02-17 17:20:44.000000000 +0100
++++ gdb-7.2.90.20110703/gdb/dwarf2loc.h 2011-07-03 10:33:11.000000000 +0200
+@@ -107,6 +107,15 @@ struct dwarf2_loclist_baton
extern const struct symbol_computed_ops dwarf2_locexpr_funcs;
extern const struct symbol_computed_ops dwarf2_loclist_funcs;
+extern int dwarf_loclist_baton_eval (struct dwarf2_loclist_baton *dllbaton,
+ struct type *type, CORE_ADDR *addrp);
- #endif /* dwarf2loc.h */
-diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
-index 1e75235..d54e266 100644
---- a/gdb/dwarf2read.c
-+++ b/gdb/dwarf2read.c
-@@ -51,6 +51,9 @@
- #include "typeprint.h"
- #include "jv-lang.h"
- #include "psympriv.h"
-+#include "exceptions.h"
-+#include "gdb_stat.h"
-+#include "completer.h"
-
- #include <fcntl.h>
- #include "gdb_string.h"
-@@ -129,6 +132,33 @@ struct dwarf2_section_info
- int readin;
- };
-
-+/* All offsets in the index are of this type. It must be
-+ architecture-independent. */
-+typedef uint32_t offset_type;
-+
-+DEF_VEC_I (offset_type);
-+
-+/* A description of the mapped index. The file format is described in
-+ a comment by the code that writes the index. */
-+struct mapped_index
-+{
-+ /* The total length of the buffer. */
-+ off_t total_size;
-+ /* A pointer to the address table data. */
-+ const gdb_byte *address_table;
-+ /* Size of the address table data in bytes. */
-+ offset_type address_table_size;
-+ /* The hash table. */
-+ const offset_type *index_table;
-+ /* Size in slots, each slot is 2 offset_types. */
-+ offset_type index_table_slots;
-+ /* A pointer to the constant pool. */
-+ const char *constant_pool;
-+};
-+
-+typedef struct dwarf2_per_cu_data *dwarf2_per_cu_data_ptr;
-+DEF_VEC_P (dwarf2_per_cu_data_ptr);
-+
- struct dwarf2_per_objfile
- {
- struct dwarf2_section_info info;
-@@ -141,6 +171,7 @@ struct dwarf2_per_objfile
- struct dwarf2_section_info types;
- struct dwarf2_section_info frame;
- struct dwarf2_section_info eh_frame;
-+ struct dwarf2_section_info gdb_index;
-
- /* Back link. */
- struct objfile *objfile;
-@@ -163,6 +194,12 @@ struct dwarf2_per_objfile
- /* A flag indicating wether this objfile has a section loaded at a
- VMA of 0. */
- int has_section_at_zero;
-+
-+ /* True if we are using the mapped index. */
-+ unsigned char using_index;
-+
-+ /* The mapped index. */
-+ struct mapped_index *index_table;
- };
-
- static struct dwarf2_per_objfile *dwarf2_per_objfile;
-@@ -182,6 +219,7 @@ static struct dwarf2_per_objfile *dwarf2_per_objfile;
- #define TYPES_SECTION "debug_types"
- #define FRAME_SECTION "debug_frame"
- #define EH_FRAME_SECTION "eh_frame"
-+#define GDB_INDEX_SECTION "gdb_index"
-
- /* local data types */
-
-@@ -307,6 +345,32 @@ struct dwarf2_cu
- unsigned int has_namespace_info : 1;
- };
-
-+/* When using the index (and thus not using psymtabs), each CU has an
-+ object of this type. This is used to hold information needed by
-+ the various "quick" methods. */
-+struct dwarf2_per_cu_quick_data
-+{
-+ /* The line table. This can be NULL if there was no line table. */
-+ struct line_header *lines;
-+
-+ /* The file names from the line table. */
-+ const char **file_names;
-+ /* The file names from the line table after being run through
-+ gdb_realpath. */
-+ const char **full_names;
-+
-+ /* The corresponding symbol table. This is NULL if symbols for this
-+ CU have not yet been read. */
-+ struct symtab *symtab;
-+
-+ /* A temporary mark bit used when iterating over all CUs in
-+ expand_symtabs_matching. */
-+ unsigned int mark : 1;
-+
-+ /* True if we've tried to read the line table. */
-+ unsigned int read_lines : 1;
-+};
-+
- /* Persistent data held for a compilation unit, even when not
- processing it. We put a pointer to this structure in the
- read_symtab_private field of the psymtab. If we encounter
-@@ -347,10 +411,21 @@ struct dwarf2_per_cu_data
- it. */
- htab_t type_hash;
-
-- /* The partial symbol table associated with this compilation unit,
-- or NULL for partial units (which do not have an associated
-- symtab). */
-- struct partial_symtab *psymtab;
-+ /* The corresponding objfile. */
-+ struct objfile *objfile;
-+
-+ /* When using partial symbol tables, the 'psymtab' field is active.
-+ Otherwise the 'quick' field is active. */
-+ union
-+ {
-+ /* The partial symbol table associated with this compilation unit,
-+ or NULL for partial units (which do not have an associated
-+ symtab). */
-+ struct partial_symtab *psymtab;
-+
-+ /* Data needed by the "quick" functions. */
-+ struct dwarf2_per_cu_quick_data *quick;
-+ } v;
- };
-
- /* Entry in the signatured_types hash table. */
-@@ -1083,6 +1158,9 @@ static int attr_form_is_section_offset (struct attribute *);
-
- static int attr_form_is_constant (struct attribute *);
+ /* Compile a DWARF location expression to an agent expression.
+
+Index: gdb-7.2.90.20110703/gdb/dwarf2read.c
+===================================================================
+--- gdb-7.2.90.20110703.orig/gdb/dwarf2read.c 2011-07-02 21:59:29.000000000 +0200
++++ gdb-7.2.90.20110703/gdb/dwarf2read.c 2011-07-03 10:33:11.000000000 +0200
+@@ -1222,6 +1222,9 @@ static void fill_in_loclist_baton (struc
+ struct dwarf2_loclist_baton *baton,
+ struct attribute *attr);
+static struct dwarf2_loclist_baton *dwarf2_attr_to_loclist_baton
+ (struct attribute *attr, struct dwarf2_cu *cu);
static void dwarf2_symbol_mark_computed (struct attribute *attr,
struct symbol *sym,
struct dwarf2_cu *cu);
-@@ -1113,6 +1191,9 @@ static void age_cached_comp_units (void);
+@@ -1256,6 +1259,9 @@ static void age_cached_comp_units (void)
static void free_one_cached_comp_unit (void *);
static struct type *set_die_type (struct die_info *, struct type *,
struct dwarf2_cu *);
-@@ -1132,6 +1213,56 @@ static void dwarf2_clear_marks (struct dwarf2_per_cu_data *);
+@@ -1280,6 +1286,9 @@ static struct type *get_die_type_at_offs
static struct type *get_die_type (struct die_info *die, struct dwarf2_cu *cu);
+static struct dwarf2_locexpr_baton *dwarf2_attr_to_locexpr_baton
+ (struct attribute *attr, struct dwarf2_cu *cu);
+
-+static void dwarf2_release_queue (void *dummy);
-+
-+static void queue_comp_unit (struct dwarf2_per_cu_data *per_cu,
-+ struct objfile *objfile);
-+
-+static void process_queue (struct objfile *objfile);
-+
-+static void find_file_and_directory (struct die_info *die,
-+ struct dwarf2_cu *cu,
-+ char **name, char **comp_dir);
-+
-+static char *file_full_name (int file, struct line_header *lh,
-+ const char *comp_dir);
-+
-+static gdb_byte *partial_read_comp_unit_head (struct comp_unit_head *header,
-+ gdb_byte *info_ptr,
-+ gdb_byte *buffer,
-+ unsigned int buffer_size,
-+ bfd *abfd);
-+
-+static void init_cu_die_reader (struct die_reader_specs *reader,
-+ struct dwarf2_cu *cu);
+ static void dwarf2_release_queue (void *dummy);
+
+ static void queue_comp_unit (struct dwarf2_per_cu_data *per_cu,
+@@ -7542,6 +7551,29 @@ process_enumeration_scope (struct die_in
+ new_symbol (die, this_type, cu);
+ }
+
++/* Create a new array dimension referencing its target type TYPE.
+
-+#if WORDS_BIGENDIAN
++ Multidimensional arrays are internally represented as a stack of
++ singledimensional arrays being referenced by their TYPE_TARGET_TYPE. */
+
-+/* Convert VALUE between big- and little-endian. */
-+static offset_type
-+byte_swap (offset_type value)
++static struct type *
++create_single_array_dimension (struct type *type, struct type *range_type,
++ struct die_info *die, struct dwarf2_cu *cu)
+{
-+ offset_type result;
-+
-+ result = (value & 0xff) << 24;
-+ result |= (value & 0xff00) << 8;
-+ result |= (value & 0xff0000) >> 8;
-+ result |= (value & 0xff000000) >> 24;
-+ return result;
-+}
++ type = create_array_type (NULL, type, range_type);
+
-+#define MAYBE_SWAP(V) byte_swap (V)
++ /* These generic type attributes need to be fetched by
++ evaluate_subexp_standard <multi_f77_subscript>'s call of
++ value_subscripted_rvalue only for the innermost array type. */
++ fetch_die_type_attrs (die, type, cu);
+
-+#else
-+#define MAYBE_SWAP(V) (V)
-+#endif /* WORDS_BIGENDIAN */
++ /* These generic type attributes are checked for allocated/associated
++ validity while accessing FIELD_LOC_KIND_DWARF_BLOCK. */
++ fetch_die_type_attrs (die, range_type, cu);
+
-+/* The suffix for an index file. */
-+#define INDEX_SUFFIX ".gdb-index"
++ return type;
++}
+
- /* Try to locate the sections we need for DWARF 2 debugging
- information and return true if we have enough to do something. */
-
-@@ -1230,6 +1361,11 @@ dwarf2_locate_sections (bfd *abfd, asection *sectp, void *ignore_ptr)
- dwarf2_per_objfile->types.asection = sectp;
- dwarf2_per_objfile->types.size = bfd_get_section_size (sectp);
- }
-+ else if (section_is_p (sectp->name, GDB_INDEX_SECTION))
-+ {
-+ dwarf2_per_objfile->gdb_index.asection = sectp;
-+ dwarf2_per_objfile->gdb_index.size = bfd_get_section_size (sectp);
-+ }
-
- if ((bfd_get_section_flags (abfd, sectp) & SEC_LOAD)
- && bfd_section_vma (abfd, sectp) == 0)
-@@ -1353,87 +1489,940 @@ dwarf2_read_section (struct objfile *objfile, struct dwarf2_section_info *info)
- if (pagesize == 0)
- pagesize = getpagesize ();
+ /* 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. */
+@@ -7555,7 +7587,7 @@ read_array_type (struct die_info *die, s
+ struct type *element_type, *range_type, *index_type;
+ struct type **range_types = NULL;
+ struct attribute *attr;
+- int ndim = 0;
++ int ndim = 0, i;
+ struct cleanup *back_to;
+ char *name;
-- /* Only try to mmap sections which are large enough: we don't want to
-- waste space due to fragmentation. Also, only try mmap for sections
-- without relocations. */
-+ /* Only try to mmap sections which are large enough: we don't want to
-+ waste space due to fragmentation. Also, only try mmap for sections
-+ without relocations. */
-+
-+ if (info->size > 4 * pagesize && (sectp->flags & SEC_RELOC) == 0)
-+ {
-+ off_t pg_offset = sectp->filepos & ~(pagesize - 1);
-+ size_t map_length = info->size + sectp->filepos - pg_offset;
-+ caddr_t retbuf = bfd_mmap (abfd, 0, map_length, PROT_READ,
-+ MAP_PRIVATE, pg_offset);
-+
-+ if (retbuf != MAP_FAILED)
-+ {
-+ info->was_mmapped = 1;
-+ info->buffer = retbuf + (sectp->filepos & (pagesize - 1)) ;
-+#if HAVE_POSIX_MADVISE
-+ posix_madvise (retbuf, map_length, POSIX_MADV_WILLNEED);
-+#endif
-+ return;
-+ }
-+ }
-+#endif
-+
-+ /* If we get here, we are a normal, not-compressed section. */
-+ info->buffer = buf
-+ = obstack_alloc (&objfile->objfile_obstack, info->size);
-+
-+ /* When debugging .o files, we may need to apply relocations; see
-+ http://sourceware.org/ml/gdb-patches/2002-04/msg00136.html .
-+ We never compress sections in .o files, so we only need to
-+ try this when the section is not compressed. */
-+ retbuf = symfile_relocate_debug_section (objfile, sectp, buf);
-+ if (retbuf != NULL)
-+ {
-+ info->buffer = retbuf;
-+ return;
-+ }
-+
-+ if (bfd_seek (abfd, sectp->filepos, SEEK_SET) != 0
-+ || bfd_bread (buf, info->size, abfd) != info->size)
-+ error (_("Dwarf Error: Can't read DWARF data from '%s'"),
-+ bfd_get_filename (abfd));
-+}
-+
-+/* Fill in SECTP, BUFP and SIZEP with section info, given OBJFILE and
-+ SECTION_NAME. */
+@@ -7608,17 +7640,19 @@ read_array_type (struct die_info *die, s
+ type = element_type;
+
+ if (read_array_order (die, cu) == DW_ORD_col_major)
+- {
+- int i = 0;
+-
+- while (i < ndim)
+- type = create_array_type (NULL, type, range_types[i++]);
+- }
+- else
+- {
+- while (ndim-- > 0)
+- type = create_array_type (NULL, type, range_types[ndim]);
+- }
++ for (i = 0; i < ndim; i++)
++ type = create_single_array_dimension (type, range_types[i], die, cu);
++ else /* (read_array_order (die, cu) == DW_ORD_row_major) */
++ for (i = ndim - 1; i >= 0; i--)
++ type = create_single_array_dimension (type, range_types[i], die, cu);
+
-+void
-+dwarf2_get_section_info (struct objfile *objfile, const char *section_name,
-+ asection **sectp, gdb_byte **bufp,
-+ bfd_size_type *sizep)
-+{
-+ struct dwarf2_per_objfile *data
-+ = objfile_data (objfile, dwarf2_objfile_data_key);
-+ struct dwarf2_section_info *info;
++ /* Data locations should be set only for the outermost dimension as they
++ would be confusing for the dereferenced offset on the inner ones. */
++ attr = dwarf2_attr (die, DW_AT_data_location, cu);
++ if (attr_form_is_block (attr))
++ TYPE_DATA_LOCATION_DWARF_BLOCK (type)
++ = dwarf2_attr_to_locexpr_baton (attr, cu);
++ gdb_assert (!TYPE_DATA_LOCATION_IS_ADDR (type));
+
+ /* Understand Dwarf2 support for vector types (like they occur on
+ the PowerPC w/ AltiVec). Gcc just adds another attribute to the
+@@ -8102,29 +8136,114 @@ read_tag_string_type (struct die_info *d
+ struct gdbarch *gdbarch = get_objfile_arch (objfile);
+ struct type *type, *range_type, *index_type, *char_type;
+ struct attribute *attr;
+- unsigned int length;
++ int length;
+
-+ /* We may see an objfile without any DWARF, in which case we just
-+ return nothing. */
-+ if (data == NULL)
-+ {
-+ *sectp = NULL;
-+ *bufp = NULL;
-+ *sizep = 0;
-+ return;
-+ }
-+ if (section_is_p (section_name, EH_FRAME_SECTION))
-+ info = &data->eh_frame;
-+ else if (section_is_p (section_name, FRAME_SECTION))
-+ info = &data->frame;
-+ else
-+ gdb_assert (0);
++ index_type = objfile_type (objfile)->builtin_int;
++ /* RANGE_TYPE is allocated from OBJFILE, not as a permanent type. */
++ range_type = alloc_type (objfile);
++ /* LOW_BOUND and HIGH_BOUND are set for real below. */
++ range_type = create_range_type (range_type, index_type, 0, -1);
+
-+ if (info->asection != NULL && info->size != 0 && info->buffer == NULL)
-+ /* We haven't read this section in yet. Do it now. */
-+ dwarf2_read_section (objfile, info);
++ /* C/C++ should probably have the low bound 0 but C/C++ does not use
++ DW_TAG_string_type. */
++ TYPE_LOW_BOUND (range_type) = 1;
+
+ attr = dwarf2_attr (die, DW_AT_string_length, cu);
+- if (attr)
++ if (attr && attr_form_is_block (attr))
+ {
+- length = DW_UNSND (attr);
++ /* Security check for a size overflow. */
++ if (DW_BLOCK (attr)->size + 2 < DW_BLOCK (attr)->size)
++ TYPE_HIGH_BOUND (range_type) = 1;
++ /* Extend the DWARF block by a new DW_OP_deref/DW_OP_deref_size
++ instruction as DW_AT_string_length specifies the length location, not
++ its value. */
++ else
++ {
++ struct dwarf2_locexpr_baton *length_baton = NULL;
++ struct dwarf_block *blk = DW_BLOCK (attr);
+
-+ *sectp = info->asection;
-+ *bufp = info->buffer;
-+ *sizep = info->size;
-+}
++ /* Turn any single DW_OP_reg* into DW_OP_breg*(0) but clearing
++ DW_OP_deref* in such case. */
+
-+\f
++ if (blk->size == 1 && blk->data[0] >= DW_OP_reg0
++ && blk->data[0] <= DW_OP_reg31)
++ length_baton = dwarf2_attr_to_locexpr_baton (attr, cu);
++ else if (blk->size > 1 && blk->data[0] == DW_OP_regx)
++ {
++ ULONGEST ulongest;
++ const gdb_byte *end;
+
-+/* Read in the symbols for PER_CU. OBJFILE is the objfile from which
-+ this CU came. */
-+static void
-+dw2_do_instantiate_symtab (struct objfile *objfile,
-+ struct dwarf2_per_cu_data *per_cu)
-+{
-+ struct cleanup *back_to;
++ end = read_uleb128 (&blk->data[1], &blk->data[blk->size],
++ &ulongest);
++ if (end == &blk->data[blk->size])
++ length_baton = dwarf2_attr_to_locexpr_baton (attr, cu);
++ }
+
-+ back_to = make_cleanup (dwarf2_release_queue, NULL);
++ if (length_baton == NULL)
++ {
++ struct attribute *size_attr;
++ gdb_byte *data;
+
-+ queue_comp_unit (per_cu, objfile);
++ length_baton = obstack_alloc (&cu->comp_unit_obstack,
++ sizeof (*length_baton));
++ length_baton->per_cu = cu->per_cu;
++ length_baton->size = DW_BLOCK (attr)->size + 2;
++ data = obstack_alloc (&cu->comp_unit_obstack,
++ length_baton->size);
++ length_baton->data = data;
++ memcpy (data, DW_BLOCK (attr)->data, DW_BLOCK (attr)->size);
+
-+ if (per_cu->from_debug_types)
-+ read_signatured_type_at_offset (objfile, per_cu->offset);
-+ else
-+ load_full_comp_unit (per_cu, objfile);
++ /* DW_AT_BYTE_SIZE existing together with DW_AT_STRING_LENGTH
++ specifies the size of an integer to fetch. */
++ size_attr = dwarf2_attr (die, DW_AT_byte_size, cu);
++ if (size_attr)
++ {
++ data[DW_BLOCK (attr)->size] = DW_OP_deref_size;
++ data[DW_BLOCK (attr)->size + 1] = DW_UNSND (size_attr);
++ if (data[DW_BLOCK (attr)->size + 1] != DW_UNSND (size_attr))
++ complaint (&symfile_complaints,
++ _("DW_AT_string_length's DW_AT_byte_size "
++ "integer exceeds the byte size storage"));
++ }
++ else
++ {
++ data[DW_BLOCK (attr)->size] = DW_OP_deref;
++ data[DW_BLOCK (attr)->size + 1] = DW_OP_nop;
++ }
++ }
+
-+ process_queue (objfile);
++ TYPE_RANGE_DATA (range_type)->high.kind
++ = RANGE_BOUND_KIND_DWARF_BLOCK;
++ TYPE_RANGE_DATA (range_type)->high.u.dwarf_block = length_baton;
++ TYPE_DYNAMIC (range_type) = 1;
++ }
+ }
+ else
+ {
+- /* Check for the DW_AT_byte_size attribute. */
++ if (attr && attr_form_is_constant (attr))
++ {
++ /* We currently do not support a constant address where the location
++ should be read from - attr_form_is_block is expected instead. See
++ DWARF for the DW_AT_STRING_LENGTH vs. DW_AT_BYTE_SIZE difference.
++ */
++ /* PASSTHRU */
++ }
+
-+ /* Age the cache, releasing compilation units that have not
-+ been used recently. */
-+ age_cached_comp_units ();
+ attr = dwarf2_attr (die, DW_AT_byte_size, cu);
+- if (attr)
+- {
+- length = DW_UNSND (attr);
+- }
++ if (attr && attr_form_is_block (attr))
++ {
++ TYPE_RANGE_DATA (range_type)->high.kind
++ = RANGE_BOUND_KIND_DWARF_BLOCK;
++ TYPE_RANGE_DATA (range_type)->high.u.dwarf_block =
++ dwarf2_attr_to_locexpr_baton (attr, cu);
++ TYPE_DYNAMIC (range_type) = 1;
++ }
++ else if (attr && attr_form_is_constant (attr))
++ TYPE_HIGH_BOUND (range_type) = dwarf2_get_attr_constant_value (attr, 0);
+ else
+- {
+- length = 1;
+- }
++ TYPE_HIGH_BOUND (range_type) = 1;
+ }
+
+- index_type = objfile_type (objfile)->builtin_int;
+- range_type = create_range_type (NULL, index_type, 1, length);
+ char_type = language_string_char_type (cu->language_defn, gdbarch);
+ type = create_string_type (NULL, char_type, range_type);
+
+@@ -8409,8 +8528,7 @@ read_subrange_type (struct die_info *die
+ struct type *base_type;
+ struct type *range_type;
+ struct attribute *attr;
+- LONGEST low = 0;
+- LONGEST high = -1;
++ LONGEST low;
+ char *name;
+ LONGEST negative_mask;
+
+@@ -8423,53 +8541,126 @@ read_subrange_type (struct die_info *die
+ if (range_type)
+ return range_type;
+
+- if (cu->language == language_fortran)
++ /* LOW_BOUND and HIGH_BOUND are set for real below. */
++ range_type = create_range_type (NULL, base_type, 0, -1);
++ TYPE_UNSIGNED (range_type) = 0;
+
-+ do_cleanups (back_to);
-+}
++ negative_mask =
++ (LONGEST) -1 << (TYPE_LENGTH (base_type) * TARGET_CHAR_BIT - 1);
+
-+/* Ensure that the symbols for PER_CU have been read in. OBJFILE is
-+ the objfile from which this CU came. Returns the resulting symbol
-+ table. */
-+static struct symtab *
-+dw2_instantiate_symtab (struct objfile *objfile,
-+ struct dwarf2_per_cu_data *per_cu)
-+{
-+ if (!per_cu->v.quick->symtab)
-+ {
-+ struct cleanup *back_to = make_cleanup (free_cached_comp_units, NULL);
-+ increment_reading_symtab ();
-+ dw2_do_instantiate_symtab (objfile, per_cu);
-+ do_cleanups (back_to);
-+ }
-+ return per_cu->v.quick->symtab;
-+}
++ /* Exclude language_ada from any TYPE_DYNAMIC constructs below. GDB Ada
++ supports implements the dynamic bounds in a non-DWARF way and the
++ existing DWARF dynamic bounds are invalid, leading to memory access
++ errors. */
+
-+/* A helper function that knows how to read a 64-bit value in a way
-+ that doesn't make gdb die. Returns 1 if the conversion went ok, 0
-+ otherwise. */
-+static int
-+extract_cu_value (const char *bytes, ULONGEST *result)
-+{
-+ if (sizeof (ULONGEST) < 8)
++ attr = dwarf2_attr (die, DW_AT_lower_bound, cu);
++ if (attr && attr_form_is_block (attr) && cu->language != language_ada)
+ {
+- /* FORTRAN implies a lower bound of 1, if not given. */
+- low = 1;
++ TYPE_RANGE_DATA (range_type)->low.kind = RANGE_BOUND_KIND_DWARF_BLOCK;
++ TYPE_RANGE_DATA (range_type)->low.u.dwarf_block =
++ dwarf2_attr_to_locexpr_baton (attr, cu);
++ TYPE_DYNAMIC (range_type) = 1;
++ /* For setting a default if DW_AT_UPPER_BOUND would be missing. */
++ low = 0;
+ }
++ else if (attr && is_ref_attr (attr) && cu->language != language_ada)
+ {
-+ int i;
-+
-+ /* Ignore the upper 4 bytes if they are all zero. */
-+ for (i = 0; i < 4; ++i)
-+ if (bytes[i + 4] != 0)
-+ return 0;
-+
-+ *result = extract_unsigned_integer (bytes, 4, BFD_ENDIAN_LITTLE);
++ struct die_info *target_die;
++ struct dwarf2_cu *target_cu = cu;
++ struct attribute *target_loc_attr;
+
+- /* FIXME: For variable sized arrays either of these could be
+- a variable rather than a constant value. We'll allow it,
+- but we don't know how to handle it. */
+- attr = dwarf2_attr (die, DW_AT_lower_bound, cu);
+- if (attr)
+- low = dwarf2_get_attr_constant_value (attr, 0);
++ target_die = follow_die_ref_or_sig (die, attr, &target_cu);
++ gdb_assert (target_cu->objfile == cu->objfile);
++ target_loc_attr = dwarf2_attr (target_die, DW_AT_location, target_cu);
+
+- attr = dwarf2_attr (die, DW_AT_upper_bound, cu);
+- if (attr)
++ TYPE_RANGE_DATA (range_type)->low.kind = RANGE_BOUND_KIND_DWARF_LOCLIST;
++ TYPE_RANGE_DATA (range_type)->low.u.dwarf_loclist.loclist
++ = dwarf2_attr_to_loclist_baton (target_loc_attr, target_cu);
++ TYPE_RANGE_DATA (range_type)->low.u.dwarf_loclist.type
++ = die_type (target_die, target_cu);
++ TYPE_DYNAMIC (range_type) = 1;
++ /* For setting a default if DW_AT_UPPER_BOUND would be missing. */
++ low = 0;
+ }
+ else
-+ *result = extract_unsigned_integer (bytes, 8, BFD_ENDIAN_LITTLE);
-+ return 1;
-+}
-+
-+/* Read the CU list from the mapped index, and use it to create all
-+ the CU objects for this objfile. Return 0 if something went wrong,
-+ 1 if everything went ok. */
-+static int
-+create_cus_from_index (struct objfile *objfile, struct mapped_index *index,
-+ const gdb_byte *cu_list, offset_type cu_list_elements)
-+{
-+ offset_type i;
-+ const char *entry;
-+
-+ dwarf2_per_objfile->n_comp_units = cu_list_elements / 2;
-+ dwarf2_per_objfile->all_comp_units
-+ = obstack_alloc (&objfile->objfile_obstack,
-+ dwarf2_per_objfile->n_comp_units
-+ * sizeof (struct dwarf2_per_cu_data *));
-+
-+ for (i = 0; i < cu_list_elements; i += 2)
-+ {
-+ struct dwarf2_per_cu_data *the_cu;
-+ ULONGEST offset, length;
-+
-+ if (!extract_cu_value (cu_list, &offset)
-+ || !extract_cu_value (cu_list + 8, &length))
-+ return 0;
-+ cu_list += 2 * 8;
-+
-+ the_cu = OBSTACK_ZALLOC (&objfile->objfile_obstack,
-+ struct dwarf2_per_cu_data);
-+ the_cu->offset = offset;
-+ the_cu->length = length;
-+ the_cu->objfile = objfile;
-+ the_cu->v.quick = OBSTACK_ZALLOC (&objfile->objfile_obstack,
-+ struct dwarf2_per_cu_quick_data);
-+ dwarf2_per_objfile->all_comp_units[i / 2] = the_cu;
+ {
+- if (attr->form == DW_FORM_block1 || is_ref_attr (attr))
+- {
+- /* GCC encodes arrays with unspecified or dynamic length
+- with a DW_FORM_block1 attribute or a reference attribute.
+- FIXME: GDB does not yet know how to handle dynamic
+- arrays properly, treat them as arrays with unspecified
+- length for now.
+-
+- FIXME: jimb/2003-09-22: GDB does not really know
+- how to handle arrays of unspecified length
+- either; we just represent them as zero-length
+- arrays. Choose an appropriate upper bound given
+- the lower bound we've computed above. */
+- high = low - 1;
+- }
++ if (attr && attr_form_is_constant (attr))
++ low = dwarf2_get_attr_constant_value (attr, 0);
+ else
+- high = dwarf2_get_attr_constant_value (attr, 1);
++ {
++ if (cu->language == language_fortran)
++ {
++ /* FORTRAN implies a lower bound of 1, if not given. */
++ low = 1;
++ }
++ else
++ {
++ /* According to DWARF we should assume the value 0 only for
++ LANGUAGE_C and LANGUAGE_CPLUS. */
++ low = 0;
++ }
++ }
++ if (!TYPE_UNSIGNED (base_type) && (low & negative_mask))
++ low |= negative_mask;
++ TYPE_LOW_BOUND (range_type) = low;
++ if (low >= 0)
++ TYPE_UNSIGNED (range_type) = 1;
+ }
+- else
++
++ attr = dwarf2_attr (die, DW_AT_upper_bound, cu);
++ if (!attr || (!attr_form_is_block (attr) && !attr_form_is_constant (attr)
++ && !is_ref_attr (attr)))
+ {
+ attr = dwarf2_attr (die, DW_AT_count, cu);
+- if (attr)
+- {
+- int count = dwarf2_get_attr_constant_value (attr, 1);
+- high = low + count - 1;
++ /* It does not hurt but it is needlessly ineffective in check_typedef. */
++ if (attr && (attr_form_is_block (attr) || attr_form_is_constant (attr)))
++ {
++ TYPE_RANGE_HIGH_BOUND_IS_COUNT (range_type) = 1;
++ TYPE_DYNAMIC (range_type) = 1;
+ }
++ /* Pass it now as the regular DW_AT_upper_bound. */
+ }
+
-+ return 1;
-+}
++ if (attr && attr_form_is_block (attr) && cu->language != language_ada)
++ {
++ TYPE_RANGE_DATA (range_type)->high.kind = RANGE_BOUND_KIND_DWARF_BLOCK;
++ TYPE_RANGE_DATA (range_type)->high.u.dwarf_block =
++ dwarf2_attr_to_locexpr_baton (attr, cu);
++ TYPE_DYNAMIC (range_type) = 1;
++ }
++ else if (attr && is_ref_attr (attr) && cu->language != language_ada)
++ {
++ struct die_info *target_die;
++ struct dwarf2_cu *target_cu = cu;
++ struct attribute *target_loc_attr;
+
-+/* Read the address map data from the mapped index, and use it to
-+ populate the objfile's psymtabs_addrmap. */
-+static void
-+create_addrmap_from_index (struct objfile *objfile, struct mapped_index *index)
-+{
-+ const gdb_byte *iter, *end;
-+ struct obstack temp_obstack;
-+ struct addrmap *mutable_map;
-+ struct cleanup *cleanup;
-+ CORE_ADDR baseaddr;
++ target_die = follow_die_ref_or_sig (die, attr, &target_cu);
++ gdb_assert (target_cu->objfile == cu->objfile);
++ target_loc_attr = dwarf2_attr (target_die, DW_AT_location, target_cu);
+
-+ obstack_init (&temp_obstack);
-+ cleanup = make_cleanup_obstack_free (&temp_obstack);
-+ mutable_map = addrmap_create_mutable (&temp_obstack);
++ TYPE_RANGE_DATA (range_type)->high.kind = RANGE_BOUND_KIND_DWARF_LOCLIST;
++ TYPE_RANGE_DATA (range_type)->high.u.dwarf_loclist.loclist
++ = dwarf2_attr_to_loclist_baton (target_loc_attr, target_cu);
++ TYPE_RANGE_DATA (range_type)->high.u.dwarf_loclist.type
++ = die_type (target_die, target_cu);
++ TYPE_DYNAMIC (range_type) = 1;
++ }
++ else
++ {
++ LONGEST high;
+
-+ iter = index->address_table;
-+ end = iter + index->address_table_size;
++ if (attr && attr_form_is_constant (attr))
++ high = dwarf2_get_attr_constant_value (attr, 0);
+ else
+ {
+- /* Unspecified array length. */
++ /* Ada expects an empty array on no boundary attributes. */
++ if (cu->language != language_ada)
++ TYPE_HIGH_BOUND_UNDEFINED (range_type) = 1;
+ high = low - 1;
+ }
++ if (!TYPE_UNSIGNED (base_type) && (high & negative_mask))
++ high |= negative_mask;
++ TYPE_HIGH_BOUND (range_type) = high;
+ }
+
+ /* Dwarf-2 specifications explicitly allows to create subrange types
+@@ -8510,24 +8701,41 @@ read_subrange_type (struct die_info *die
+ }
+ }
+
+- negative_mask =
+- (LONGEST) -1 << (TYPE_LENGTH (base_type) * TARGET_CHAR_BIT - 1);
+- if (!TYPE_UNSIGNED (base_type) && (low & negative_mask))
+- low |= negative_mask;
+- if (!TYPE_UNSIGNED (base_type) && (high & negative_mask))
+- high |= negative_mask;
+-
+- range_type = create_range_type (NULL, base_type, low, high);
+-
+- /* Mark arrays with dynamic length at least as an array of unspecified
+- length. GDB could check the boundary but before it gets implemented at
+- least allow accessing the array elements. */
+- if (attr && attr->form == DW_FORM_block1)
+- TYPE_HIGH_BOUND_UNDEFINED (range_type) = 1;
+-
+- /* Ada expects an empty array on no boundary attributes. */
+- if (attr == NULL && cu->language != language_ada)
+- TYPE_HIGH_BOUND_UNDEFINED (range_type) = 1;
++ /* DW_AT_bit_stride is currently unsupported as we count in bytes. */
++ attr = dwarf2_attr (die, DW_AT_byte_stride, cu);
++ if (attr && attr_form_is_block (attr) && cu->language != language_ada)
++ {
++ TYPE_RANGE_DATA (range_type)->byte_stride.kind
++ = RANGE_BOUND_KIND_DWARF_BLOCK;
++ TYPE_RANGE_DATA (range_type)->byte_stride.u.dwarf_block =
++ dwarf2_attr_to_locexpr_baton (attr, cu);
++ TYPE_DYNAMIC (range_type) = 1;
++ }
++ else if (attr && is_ref_attr (attr) && cu->language != language_ada)
++ {
++ struct die_info *target_die;
++ struct dwarf2_cu *target_cu = cu;
++ struct attribute *target_loc_attr;
+
-+ baseaddr = ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
++ target_die = follow_die_ref_or_sig (die, attr, &target_cu);
++ gdb_assert (target_cu->objfile == cu->objfile);
++ target_loc_attr = dwarf2_attr (target_die, DW_AT_location, target_cu);
+
-+ while (iter < end)
++ TYPE_RANGE_DATA (range_type)->byte_stride.kind
++ = RANGE_BOUND_KIND_DWARF_LOCLIST;
++ TYPE_RANGE_DATA (range_type)->byte_stride.u.dwarf_loclist.loclist
++ = dwarf2_attr_to_loclist_baton (target_loc_attr, target_cu);
++ TYPE_RANGE_DATA (range_type)->byte_stride.u.dwarf_loclist.type
++ = die_type (target_die, target_cu);
++ TYPE_DYNAMIC (range_type) = 1;
++ }
++ else if (attr && attr_form_is_constant (attr))
+ {
-+ ULONGEST hi, lo, cu_index;
-+ lo = extract_unsigned_integer (iter, 8, BFD_ENDIAN_LITTLE);
-+ iter += 8;
-+ hi = extract_unsigned_integer (iter, 8, BFD_ENDIAN_LITTLE);
-+ iter += 8;
-+ cu_index = extract_unsigned_integer (iter, 4, BFD_ENDIAN_LITTLE);
-+ iter += 4;
-+
-+ addrmap_set_empty (mutable_map, lo + baseaddr, hi + baseaddr - 1,
-+ dwarf2_per_objfile->all_comp_units[cu_index]);
++ TYPE_BYTE_STRIDE (range_type) = dwarf2_get_attr_constant_value (attr, 0);
++ if (TYPE_BYTE_STRIDE (range_type) == 0)
++ complaint (&symfile_complaints,
++ _("Found DW_AT_byte_stride with unsupported value 0"));
+ }
+
+ name = dwarf2_name (die, cu);
+ if (name)
+@@ -11072,10 +11280,12 @@ var_decode_location (struct attribute *a
+ (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
+- or memory numbers show me otherwise. */
++ or memory numbers show me otherwise.
++
++ SYMBOL_CLASS may get overriden by dwarf2_symbol_mark_computed. */
+
+- dwarf2_symbol_mark_computed (attr, sym, cu);
+ SYMBOL_CLASS (sym) = LOC_COMPUTED;
++ dwarf2_symbol_mark_computed (attr, sym, cu);
+
+ if (SYMBOL_COMPUTED_OPS (sym) == &dwarf2_loclist_funcs)
+ cu->has_loclist = 1;
+@@ -11116,6 +11326,8 @@ new_symbol_full (struct die_info *die, s
+ else
+ sym = OBSTACK_ZALLOC (&objfile->objfile_obstack, struct symbol);
+ OBJSTAT (objfile, n_syms++);
++ /* Some methods are called w/o checking SYMBOL_COMPUTED_OPS validity. */
++ SYMBOL_COMPUTED_OPS (sym) = &dwarf2_missing_funcs;
+
+ /* Cache this symbol's name and the name's demangled form (if any). */
+ SYMBOL_SET_LANGUAGE (sym, cu->language);
+@@ -11888,6 +12100,9 @@ read_type_die_1 (struct die_info *die, s
+ break;
+ }
+
++ if (this_type)
++ finalize_type (this_type);
+
-+ objfile->psymtabs_addrmap = addrmap_create_fixed (mutable_map,
-+ &objfile->objfile_obstack);
-+ do_cleanups (cleanup);
-+}
-+
-+/* The hash function for strings in the mapped index. This is the
-+ same as the hashtab.c hash function, but we keep a separate copy to
-+ maintain control over the implementation. This is necessary
-+ because the hash function is tied to the format of the mapped index
-+ file. */
-+static hashval_t
-+mapped_index_string_hash (const void *p)
-+{
-+ const unsigned char *str = (const unsigned char *) p;
-+ hashval_t r = 0;
-+ unsigned char c;
+ return this_type;
+ }
+
+@@ -14742,61 +14957,99 @@ fill_in_loclist_baton (struct dwarf2_cu
+ baton->base_address = cu->base_address;
+ }
+
+-static void
+-dwarf2_symbol_mark_computed (struct attribute *attr, struct symbol *sym,
+- struct dwarf2_cu *cu)
++/* Convert DW_BLOCK into struct dwarf2_locexpr_baton. ATTR must be a DW_BLOCK
++ attribute type. */
+
-+ while ((c = *str++) != 0)
-+ r = r * 67 + c - 113;
++static struct dwarf2_locexpr_baton *
++dwarf2_attr_to_locexpr_baton (struct attribute *attr, struct dwarf2_cu *cu)
+ {
+- if (attr_form_is_section_offset (attr)
+- /* ".debug_loc" may not exist at all, or the offset may be outside
+- the section. If so, fall through to the complaint in the
+- other branch. */
+- && DW_UNSND (attr) < dwarf2_section_size (dwarf2_per_objfile->objfile,
+- &dwarf2_per_objfile->loc))
+- {
+- struct dwarf2_loclist_baton *baton;
++ struct dwarf2_locexpr_baton *baton;
+
+- baton = obstack_alloc (&cu->objfile->objfile_obstack,
+- sizeof (struct dwarf2_loclist_baton));
++ gdb_assert (attr_form_is_block (attr));
+
+- fill_in_loclist_baton (cu, baton, attr);
++ baton = obstack_alloc (&cu->objfile->objfile_obstack, sizeof (*baton));
++ baton->per_cu = cu->per_cu;
++ gdb_assert (baton->per_cu);
+
+- if (cu->base_known == 0)
+- complaint (&symfile_complaints,
+- _("Location list used without "
+- "specifying the CU base address."));
++ /* Note that we're just copying the block's data pointer
++ here, not the actual data. We're still pointing into the
++ info_buffer for SYM's objfile; right now we never release
++ that buffer, but when we do clean up properly this may
++ need to change. */
++ baton->size = DW_BLOCK (attr)->size;
++ baton->data = DW_BLOCK (attr)->data;
++ gdb_assert (baton->size == 0 || baton->data != NULL);
+
-+ return r;
++ return baton;
+}
-+
-+/* Find a slot in the mapped index INDEX for the object named NAME.
-+ If NAME is found, set *VEC_OUT to point to the CU vector in the
-+ constant pool and return 1. If NAME cannot be found, return 0. */
-+static int
-+find_slot_in_mapped_hash (struct mapped_index *index, const char *name,
-+ offset_type **vec_out)
+
++static struct dwarf2_loclist_baton *
++dwarf2_attr_to_loclist_baton (struct attribute *attr, struct dwarf2_cu *cu)
+{
-+ offset_type hash = mapped_index_string_hash (name);
-+ offset_type slot, step;
-+
-+ slot = hash & (index->index_table_slots - 1);
-+ step = ((hash * 17) & (index->index_table_slots - 1)) | 1;
-+
-+ for (;;)
-+ {
-+ /* Convert a slot number to an offset into the table. */
-+ offset_type i = 2 * slot;
-+ const char *str;
-+ if (index->index_table[i] == 0 && index->index_table[i + 1] == 0)
-+ return 0;
-+
-+ str = index->constant_pool + MAYBE_SWAP (index->index_table[i]);
-+ if (!strcmp (name, str))
-+ {
-+ *vec_out = (offset_type *) (index->constant_pool
-+ + MAYBE_SWAP (index->index_table[i + 1]));
-+ return 1;
-+ }
-+
-+ slot = (slot + step) & (index->index_table_slots - 1);
-+ }
-+}
++ struct dwarf2_loclist_baton *baton;
+
-+/* Read the index file. If everything went ok, initialize the "quick"
-+ elements of all the CUs and return 1. Otherwise, return 0. */
-+static int
-+dwarf2_read_index (struct objfile *objfile)
-+{
-+ char *addr;
-+ struct mapped_index *map;
-+ offset_type *metadata;
-+ const gdb_byte *cu_list;
-+ offset_type cu_list_elements;
++ /* DW_AT_location of the referenced DIE may be missing if the referenced
++ variable has been optimized out. */
++ if (!attr)
++ return NULL;
+
-+ if (dwarf2_per_objfile->gdb_index.asection == NULL
-+ || dwarf2_per_objfile->gdb_index.size == 0)
-+ return 0;
-+ dwarf2_read_section (objfile, &dwarf2_per_objfile->gdb_index);
++ dwarf2_read_section (dwarf2_per_objfile->objfile,
++ &dwarf2_per_objfile->loc);
+
-+ addr = dwarf2_per_objfile->gdb_index.buffer;
-+ /* Version check. */
-+ if (MAYBE_SWAP (*(offset_type *) addr) != 1)
-+ return 0;
++ if (!(attr_form_is_section_offset (attr)
++ /* ".debug_loc" may not exist at all, or the offset may be outside
++ the section. If so, fall through to the complaint in the
++ other branch. */
++ && DW_UNSND (attr) < dwarf2_section_size (dwarf2_per_objfile->objfile,
++ &dwarf2_per_objfile->loc)))
++ return NULL;
+
-+ map = OBSTACK_ZALLOC (&objfile->objfile_obstack, struct mapped_index);
-+ map->total_size = dwarf2_per_objfile->gdb_index.size;
-+
-+ metadata = (offset_type *) (addr + sizeof (offset_type));
-+ cu_list = addr + MAYBE_SWAP (metadata[0]);
-+ cu_list_elements = ((MAYBE_SWAP (metadata[1]) - MAYBE_SWAP (metadata[0]))
-+ / 8);
-+ map->address_table = addr + MAYBE_SWAP (metadata[1]);
-+ map->address_table_size = (MAYBE_SWAP (metadata[2])
-+ - MAYBE_SWAP (metadata[1]));
-+ map->index_table = (offset_type *) (addr + MAYBE_SWAP (metadata[2]));
-+ map->index_table_slots = ((MAYBE_SWAP (metadata[3])
-+ - MAYBE_SWAP (metadata[2]))
-+ / (2 * sizeof (offset_type)));
-+ map->constant_pool = addr + MAYBE_SWAP (metadata[3]);
-+
-+ if (!create_cus_from_index (objfile, map, cu_list, cu_list_elements))
-+ return 0;
++ baton = obstack_alloc (&cu->objfile->objfile_obstack,
++ sizeof (struct dwarf2_loclist_baton));
+
-+ create_addrmap_from_index (objfile, map);
++ fill_in_loclist_baton (cu, baton, attr);
+
-+ dwarf2_per_objfile->index_table = map;
-+ dwarf2_per_objfile->using_index = 1;
++ if (cu->base_known == 0)
++ complaint (&symfile_complaints,
++ _("Location list used without "
++ "specifying the CU base address."));
+
-+ return 1;
++ return baton;
+}
+
-+/* A helper for the "quick" functions which sets the global
-+ dwarf2_per_objfile according to OBJFILE. */
++/* SYM may get its SYMBOL_CLASS overriden on invalid ATTR content. */
++
+static void
-+dw2_setup (struct objfile *objfile)
-+{
-+ dwarf2_per_objfile = objfile_data (objfile, dwarf2_objfile_data_key);
-+ gdb_assert (dwarf2_per_objfile);
-+}
++dwarf2_symbol_mark_computed (struct attribute *attr, struct symbol *sym,
++ struct dwarf2_cu *cu)
++{
++ struct dwarf2_loclist_baton *loclist_baton;
++
++ loclist_baton = dwarf2_attr_to_loclist_baton (attr, cu);
++ if (loclist_baton)
++ {
+ SYMBOL_COMPUTED_OPS (sym) = &dwarf2_loclist_funcs;
+- SYMBOL_LOCATION_BATON (sym) = baton;
++ SYMBOL_LOCATION_BATON (sym) = loclist_baton;
++ }
++ else if (attr_form_is_block (attr))
++ {
++ SYMBOL_COMPUTED_OPS (sym) = &dwarf2_locexpr_funcs;
++ SYMBOL_LOCATION_BATON (sym) = dwarf2_attr_to_locexpr_baton (attr, cu);
+ }
+ else
+ {
+- struct dwarf2_locexpr_baton *baton;
++ dwarf2_invalid_attrib_class_complaint ("location description",
++ SYMBOL_NATURAL_NAME (sym));
+
+- baton = obstack_alloc (&cu->objfile->objfile_obstack,
+- sizeof (struct dwarf2_locexpr_baton));
+- baton->per_cu = cu->per_cu;
+- gdb_assert (baton->per_cu);
++ /* Some methods are called w/o checking SYMBOL_COMPUTED_OPS validity. */
+
+- if (attr_form_is_block (attr))
+- {
+- /* Note that we're just copying the block's data pointer
+- here, not the actual data. We're still pointing into the
+- info_buffer for SYM's objfile; right now we never release
+- that buffer, but when we do clean up properly this may
+- need to change. */
+- baton->size = DW_BLOCK (attr)->size;
+- baton->data = DW_BLOCK (attr)->data;
+- }
+- else
+- {
+- dwarf2_invalid_attrib_class_complaint ("location description",
+- SYMBOL_NATURAL_NAME (sym));
+- baton->size = 0;
+- baton->data = NULL;
+- }
++ SYMBOL_COMPUTED_OPS (sym) = &dwarf2_missing_funcs;
++ SYMBOL_LOCATION_BATON (sym) = NULL;
+
+- SYMBOL_COMPUTED_OPS (sym) = &dwarf2_locexpr_funcs;
+- SYMBOL_LOCATION_BATON (sym) = baton;
++ /* For functions a missing DW_AT_frame_base does not optimize out the
++ whole function definition, only its frame base resolving. */
++ if (attr->name == DW_AT_location)
++ SYMBOL_CLASS (sym) = LOC_OPTIMIZED_OUT;
+ }
+ }
+
+@@ -15145,6 +15398,25 @@ offset_and_type_eq (const void *item_lhs
+ return ofs_lhs->offset == ofs_rhs->offset;
+ }
+
++/* Fill in generic attributes applicable for type DIEs. */
+
-+/* A helper for the "quick" functions which attempts to read the line
-+ table for THIS_CU. */
+static void
-+dw2_require_line_header (struct objfile *objfile,
-+ struct dwarf2_per_cu_data *this_cu)
++fetch_die_type_attrs (struct die_info *die, struct type *type,
++ struct dwarf2_cu *cu)
+{
-+ bfd *abfd = objfile->obfd;
-+ struct line_header *lh = NULL;
+ struct attribute *attr;
-+ struct cleanup *cleanups;
-+ struct die_info *comp_unit_die;
-+ gdb_byte *beg_of_comp_unit, *info_ptr, *buffer;
-+ int has_children, i;
-+ struct dwarf2_cu cu;
-+ unsigned int bytes_read, buffer_size;
-+ struct die_reader_specs reader_specs;
-+ char *name, *comp_dir;
-+
-+ if (this_cu->v.quick->read_lines)
-+ return;
-+ this_cu->v.quick->read_lines = 1;
-+
-+ memset (&cu, 0, sizeof (cu));
-+ cu.objfile = objfile;
-+ obstack_init (&cu.comp_unit_obstack);
+
-+ cleanups = make_cleanup (free_stack_comp_unit, &cu);
++ attr = dwarf2_attr (die, DW_AT_allocated, cu);
++ if (attr_form_is_block (attr))
++ TYPE_ALLOCATED (type) = dwarf2_attr_to_locexpr_baton (attr, cu);
++ gdb_assert (!TYPE_NOT_ALLOCATED (type));
+
-+ dwarf2_read_section (objfile, &dwarf2_per_objfile->info);
-+ buffer_size = dwarf2_per_objfile->info.size;
-+ buffer = dwarf2_per_objfile->info.buffer;
-+ info_ptr = buffer + this_cu->offset;
-+ beg_of_comp_unit = info_ptr;
++ attr = dwarf2_attr (die, DW_AT_associated, cu);
++ if (attr_form_is_block (attr))
++ TYPE_ASSOCIATED (type) = dwarf2_attr_to_locexpr_baton (attr, cu);
++ gdb_assert (!TYPE_NOT_ASSOCIATED (type));
++}
+
-+ info_ptr = partial_read_comp_unit_head (&cu.header, info_ptr,
-+ buffer, buffer_size,
-+ abfd);
+ /* Set the type associated with DIE to TYPE. Save it in CU's hash
+ table if necessary. For convenience, return TYPE.
+
+@@ -15170,6 +15442,8 @@ set_die_type (struct die_info *die, stru
+ struct objfile *objfile = cu->objfile;
+ htab_t *type_hash_ptr;
+
++ fetch_die_type_attrs (die, type, cu);
+
-+ /* Complete the cu_header. */
-+ cu.header.offset = beg_of_comp_unit - buffer;
-+ cu.header.first_die_offset = info_ptr - beg_of_comp_unit;
+ /* For Ada types, make sure that the gnat-specific data is always
+ initialized (if not already set). There are a few types where
+ we should not be doing so, because the type-specific area is
+Index: gdb-7.2.90.20110703/gdb/elfread.c
+===================================================================
+--- gdb-7.2.90.20110703.orig/gdb/elfread.c 2011-05-03 18:25:20.000000000 +0200
++++ gdb-7.2.90.20110703/gdb/elfread.c 2011-07-03 10:33:11.000000000 +0200
+@@ -43,6 +43,12 @@
+ #include "infcall.h"
+ #include "gdbthread.h"
+ #include "regcache.h"
++#include "stap-probe.h"
++#include "arch-utils.h"
++#include "value.h"
++#include "infcall.h"
++#include "gdbthread.h"
++#include "regcache.h"
+
+ extern void _initialize_elfread (void);
+
+@@ -61,6 +67,21 @@ struct elfinfo
+ asection *mdebugsect; /* Section pointer for .mdebug section */
+ };
+
++/* Per-objfile data for SystemTap probe info. */
+
-+ this_cu->cu = &cu;
-+ cu.per_cu = this_cu;
++static const struct objfile_data *stap_probe_key = NULL;
+
-+ dwarf2_read_abbrevs (abfd, &cu);
-+ make_cleanup (dwarf2_free_abbrev_table, &cu);
++/* Per-objfile data about SystemTap probes. */
+
-+ if (this_cu->from_debug_types)
-+ info_ptr += 8 /*signature*/ + cu.header.offset_size;
-+ init_cu_die_reader (&reader_specs, &cu);
-+ info_ptr = read_full_die (&reader_specs, &comp_unit_die, info_ptr,
-+ &has_children);
++struct stap_probe_per_objfile
++ {
++ /* The number of probes in this objfile. */
++ int stap_num_probes;
+
-+ attr = dwarf2_attr (comp_unit_die, DW_AT_stmt_list, &cu);
-+ if (attr)
-+ {
-+ unsigned int line_offset = DW_UNSND (attr);
-+ lh = dwarf_decode_line_header (line_offset, abfd, &cu);
-+ }
-+ if (lh == NULL)
-+ {
-+ do_cleanups (cleanups);
-+ return;
-+ }
++ /* The probes themselves. */
++ struct stap_probe *probes;
++ };
+
-+ find_file_and_directory (comp_unit_die, &cu, &name, &comp_dir);
+ static void free_elfinfo (void *);
+
+ /* Minimal symbols located at the GOT entries for .plt - that is the real
+@@ -1553,7 +1574,266 @@ elfstab_offset_sections (struct objfile
+ complaint (&symfile_complaints,
+ _("elf/stab section information missing for %s"), filename);
+ }
+
-+ this_cu->v.quick->lines = lh;
++/* Helper function that parses the information contained in a
++ SystemTap's probe. Basically, the information consists in:
+
-+ this_cu->v.quick->file_names
-+ = obstack_alloc (&objfile->objfile_obstack,
-+ lh->num_file_names * sizeof (char *));
-+ for (i = 0; i < lh->num_file_names; ++i)
-+ this_cu->v.quick->file_names[i] = file_full_name (i + 1, lh, comp_dir);
++ - Probe's PC address;
++ - Link-time section address of `.stapsdt.base' section;
++ - Link-time address of the semaphore variable, or ZERO if the
++ probe doesn't have an associated semaphore;
++ - Probe's provider name;
++ - Probe's name;
++ - Probe's argument format. */
+
-+ do_cleanups (cleanups);
++static void
++handle_probe (struct objfile *objfile, struct sdt_note *el,
++ struct stap_probe *ret, CORE_ADDR base)
++{
++ bfd *abfd = objfile->obfd;
++ int size = bfd_get_arch_size (abfd) / 8;
++ struct gdbarch *gdbarch = get_objfile_arch (objfile);
++ struct type *ptr_type = builtin_type (gdbarch)->builtin_data_ptr;
++ CORE_ADDR base_ref;
++
++ /* Provider and the name of the probe. */
++ ret->provider = (const char *) &el->data[3 * size];
++ ret->name = memchr (ret->provider, '\0',
++ (unsigned long *) el->data
++ + el->size - (unsigned long *) ret->provider);
++ /* Making sure there is a name. */
++ if (!ret->name)
++ complaint (&symfile_complaints, _("corrupt probe when reading `%s'"),
++ objfile->name);
++ else
++ ++ret->name;
++
++ /* Retrieving the probe's address. */
++ ret->address = extract_typed_address ((const gdb_byte *) &el->data[0],
++ ptr_type);
++ /* Link-time sh_addr of `.stapsdt.base' section. */
++ base_ref = extract_typed_address ((const gdb_byte *) &el->data[size],
++ ptr_type);
++ /* Semaphore address. */
++ ret->sem_addr = extract_typed_address ((const gdb_byte *) &el->data[2 * size],
++ ptr_type);
++
++ ret->address += (ANOFFSET (objfile->section_offsets,
++ SECT_OFF_TEXT (objfile))
++ + base - base_ref);
++ if (ret->sem_addr)
++ ret->sem_addr += (ANOFFSET (objfile->section_offsets,
++ SECT_OFF_DATA (objfile))
++ + base - base_ref);
++
++ /* Arguments. We can only extract the argument format if there is a valid
++ name for this probe. */
++ if (ret->name)
++ {
++ ret->args = memchr (ret->name, '\0',
++ (unsigned long *) el->data
++ + el->size - (unsigned long *) ret->name);
++
++ if (ret->args++ != NULL
++ || memchr (ret->args, '\0', (unsigned long *) el->data
++ + el->size - (unsigned long *) ret->name)
++ != el->data + el->size - 1)
++ complaint (&symfile_complaints, _("corrupt probe when reading `%s'"),
++ objfile->name);
++ }
++ else
++ ret->args = NULL;
+}
+
-+/* A helper for the "quick" functions which computes and caches the
-+ real path for a given file name from the line table.
-+ dw2_require_line_header must have been called before this is
-+ invoked. */
-+static const char *
-+dw2_require_full_path (struct objfile *objfile,
-+ struct dwarf2_per_cu_data *cu,
-+ int index)
-+{
-+ if (!cu->v.quick->full_names)
-+ cu->v.quick->full_names
-+ = OBSTACK_CALLOC (&objfile->objfile_obstack,
-+ cu->v.quick->lines->num_file_names,
-+ sizeof (char *));
++/* The name of the SystemTap section where we will find information about
++ the probes. */
+
-+ if (!cu->v.quick->full_names[index])
-+ cu->v.quick->full_names[index]
-+ = gdb_realpath (cu->v.quick->file_names[index]);
++#define STAP_BASE_SECTION_NAME ".stapsdt.base"
+
-+ return cu->v.quick->full_names[index];
-+}
++/* Helper function which tries to find the base address of the SystemTap
++ base section named STAP_BASE_SECTION_NAME. */
+
-+static struct symtab *
-+dw2_find_last_source_symtab (struct objfile *objfile)
++static void
++get_base_address_1 (bfd *abfd, asection *sect, void *obj)
+{
-+ int index;
-+ dw2_setup (objfile);
-+ index = dwarf2_per_objfile->n_comp_units - 1;
-+ return dw2_instantiate_symtab (objfile,
-+ dwarf2_per_objfile->all_comp_units[index]);
++ bfd_vma *base = (bfd_vma *) obj;
++
++ if (*base == (bfd_vma) -1
++ && (sect->flags & (SEC_DATA | SEC_ALLOC | SEC_HAS_CONTENTS))
++ && sect->name && !strcmp (sect->name, STAP_BASE_SECTION_NAME))
++ *base = sect->vma;
+}
+
-+static void
-+dw2_forget_cached_source_info (struct objfile *objfile)
-+{
-+ int i;
++/* Helper function which iterates over every section in the BFD file,
++ trying to find the base address of the SystemTap base section.
++ Returns the section address if found, or -1 otherwise. */
+
-+ dw2_setup (objfile);
-+ for (i = 0; i < dwarf2_per_objfile->n_comp_units; ++i)
-+ {
-+ struct dwarf2_per_cu_data *cu = dwarf2_per_objfile->all_comp_units[i];
++static bfd_vma
++get_base_address (bfd *obfd)
++{
++ bfd_vma base = (bfd_vma) -1;
+
-+ if (cu->v.quick->full_names)
-+ {
-+ int j;
++ bfd_map_over_sections (obfd, get_base_address_1, (void *) &base);
+
-+ for (j = 0; j < cu->v.quick->lines->num_file_names; ++j)
-+ xfree ((void *) cu->v.quick->full_names[j]);
-+ }
-+ }
++ return base;
+}
+
-+static int
-+dw2_lookup_symtab (struct objfile *objfile, const char *name,
-+ const char *full_path, const char *real_path,
-+ struct symtab **result)
++/* Implementation of `sym_get_probes', as documented in symfile.h. */
++
++static const struct stap_probe *
++elf_get_probes (struct objfile *objfile, int *num_probes)
+{
-+ int i;
-+ int check_basename = lbasename (name) == name;
-+ struct dwarf2_per_cu_data *base_cu = NULL;
++ struct stap_probe *ret = NULL;
++ struct stap_probe_per_objfile *probes_per_objfile;
+
-+ dw2_setup (objfile);
-+ for (i = 0; i < dwarf2_per_objfile->n_comp_units; ++i)
-+ {
-+ int j;
-+ struct dwarf2_per_cu_data *cu = dwarf2_per_objfile->all_comp_units[i];
++ /* Initially, no probes. */
++ *num_probes = 0;
+
-+ if (cu->v.quick->symtab)
-+ continue;
++ /* Have we parsed this objfile's probes already? */
++ probes_per_objfile
++ = (struct stap_probe_per_objfile *) objfile_data (objfile,
++ stap_probe_key);
+
-+ dw2_require_line_header (objfile, cu);
-+ if (!cu->v.quick->lines)
-+ continue;
++ if (!probes_per_objfile)
++ {
++ /* If we are here, then this is the first time we are parsing the
++ probe's information. We basically have to count how many probes
++ the objfile has, and then fill in the necessary information
++ for each one. */
+
-+ for (j = 0; j < cu->v.quick->lines->num_file_names; ++j)
-+ {
-+ const char *this_name = cu->v.quick->file_names[j];
++ bfd *obfd = objfile->obfd;
++ bfd_vma base = get_base_address (obfd);
++ struct sdt_note *iter;
++ int i;
++ int n = 0;
+
-+ if (FILENAME_CMP (name, this_name) == 0)
-+ {
-+ *result = dw2_instantiate_symtab (objfile, cu);
-+ return 1;
-+ }
++ if (! elf_tdata (obfd)->sdt_note_head)
++ /* There isn't any probe here. */
++ return NULL;
+
-+ if (check_basename && ! base_cu
-+ && FILENAME_CMP (lbasename (this_name), name) == 0)
-+ base_cu = cu;
++ /* Allocating space for probe info. */
++ for (iter = elf_tdata (obfd)->sdt_note_head;
++ iter;
++ iter = iter->next, ++n);
+
-+ if (full_path != NULL)
-+ {
-+ const char *this_full_name = dw2_require_full_path (objfile,
-+ cu, j);
++ ret = xcalloc (n, sizeof (struct stap_probe));
+
-+ if (this_full_name
-+ && FILENAME_CMP (full_path, this_full_name) == 0)
-+ {
-+ *result = dw2_instantiate_symtab (objfile, cu);
-+ return 1;
-+ }
-+ }
++ /* Parsing each probe's information. */
++ for (iter = elf_tdata (obfd)->sdt_note_head, i = 0;
++ iter;
++ iter = iter->next, i++)
++ /* We first have to handle all the information about the
++ probe which is present in the section. */
++ handle_probe (objfile, iter, &ret[i], base);
+
-+ if (real_path != NULL)
-+ {
-+ const char *this_full_name = dw2_require_full_path (objfile,
-+ cu, j);
++ /* Creating a cache for these probes in the objfile's registry. */
++ probes_per_objfile = xmalloc (sizeof (struct stap_probe_per_objfile));
+
-+ if (this_full_name != NULL)
-+ {
-+ char *rp = gdb_realpath (this_full_name);
-+ if (rp != NULL && FILENAME_CMP (real_path, rp) == 0)
-+ {
-+ xfree (rp);
-+ *result = dw2_instantiate_symtab (objfile, cu);
-+ return 1;
-+ }
-+ xfree (rp);
-+ }
-+ }
-+ }
-+ }
++ probes_per_objfile->stap_num_probes = n;
++ probes_per_objfile->probes = ret;
+
-+ if (base_cu)
-+ {
-+ *result = dw2_instantiate_symtab (objfile, base_cu);
-+ return 1;
++ set_objfile_data (objfile, stap_probe_key, probes_per_objfile);
+ }
++ else
++ ret = probes_per_objfile->probes;
+
-+ return 0;
-+}
++ *num_probes = probes_per_objfile->stap_num_probes;
+
-+static struct symtab *
-+dw2_lookup_symbol (struct objfile *objfile, int block_index,
-+ const char *name, domain_enum domain)
-+{
-+ /* We do all the work in the pre_expand_symtabs_matching hook
-+ instead. */
-+ return NULL;
++ return ret;
+}
+
-+/* A helper function that expands all symtabs that hold an object
-+ named NAME. */
-+static void
-+dw2_do_expand_symtabs_matching (struct objfile *objfile, const char *name)
++/* Implementation of `sym_get_probe_argument_count', as documented in
++ symfile.h. */
++
++static int
++elf_get_probe_argument_count (struct objfile *objfile,
++ const struct stap_probe *probe)
+{
-+ dw2_setup (objfile);
++ const char *pargs = probe->args;
+
-+ if (dwarf2_per_objfile->index_table)
-+ {
-+ offset_type *vec;
++ if (!pargs || !*pargs || *pargs == ':')
++ /* No arguments. */
++ return 0;
+
-+ if (find_slot_in_mapped_hash (dwarf2_per_objfile->index_table,
-+ name, &vec))
-+ {
-+ offset_type i, len = MAYBE_SWAP (*vec);
-+ for (i = 0; i < len; ++i)
-+ {
-+ offset_type cu_index = MAYBE_SWAP (vec[i + 1]);
-+ struct dwarf2_per_cu_data *cu;
-+ cu = dwarf2_per_objfile->all_comp_units[cu_index];
-+ dw2_instantiate_symtab (objfile, cu);
-+ }
-+ }
-+ }
++ return stap_get_probe_argument_count (probe);
+}
+
-+static void
-+dw2_pre_expand_symtabs_matching (struct objfile *objfile,
-+ int kind, const char *name,
-+ domain_enum domain)
-+{
-+ dw2_do_expand_symtabs_matching (objfile, name);
-+}
++/* Implementation of `sym_evaluate_probe_argument', as documented in
++ symfile.h. */
+
-+static void
-+dw2_print_stats (struct objfile *objfile)
++static struct value *
++elf_evaluate_probe_argument (struct objfile *objfile,
++ const struct stap_probe *probe,
++ struct frame_info *frame,
++ int n)
+{
-+ int i, count;
-+
-+ dw2_setup (objfile);
-+ count = 0;
-+ for (i = 0; i < dwarf2_per_objfile->n_comp_units; ++i)
-+ {
-+ struct dwarf2_per_cu_data *cu = dwarf2_per_objfile->all_comp_units[i];
-+
-+ if (!cu->v.quick->symtab)
-+ ++count;
-+ }
-+ printf_filtered (_(" Number of unread CUs: %d\n"), count);
++ return stap_evaluate_probe_argument (objfile, probe, frame, n);
+}
+
-+static void
-+dw2_dump (struct objfile *objfile)
-+{
-+ /* Nothing worth printing. */
-+}
++/* Implementation of `sym_compile_to_ax', as documented in symfile.h. */
+
+static void
-+dw2_relocate (struct objfile *objfile, struct section_offsets *new_offsets,
-+ struct section_offsets *delta)
++elf_compile_to_ax (struct objfile *objfile,
++ const struct stap_probe *probe,
++ struct agent_expr *expr,
++ struct axs_value *value,
++ int n)
+{
-+ /* There's nothing to relocate here. */
++ stap_compile_to_ax (objfile, probe, expr, value, n);
+}
+
-+static void
-+dw2_expand_symtabs_for_function (struct objfile *objfile,
-+ const char *func_name)
-+{
-+ dw2_do_expand_symtabs_matching (objfile, func_name);
-+}
++/* Implementation of `sym_relocate_probe', as documented in symfile.h. */
+
+static void
-+dw2_expand_all_symtabs (struct objfile *objfile)
++elf_symfile_relocate_probe (struct objfile *objfile,
++ struct section_offsets *new_offsets,
++ struct section_offsets *delta)
+{
+ int i;
++ struct stap_probe_per_objfile *p
++ = (struct stap_probe_per_objfile *) objfile_data (objfile,
++ stap_probe_key);
+
-+ dw2_setup (objfile);
-+ for (i = 0; i < dwarf2_per_objfile->n_comp_units; ++i)
-+ {
-+ struct dwarf2_per_cu_data *cu = dwarf2_per_objfile->all_comp_units[i];
++ if (!p)
++ /* No probe to relocate. */
++ return;
+
-+ dw2_instantiate_symtab (objfile, cu);
++ for (i = 0; i < p->stap_num_probes; i++)
++ {
++ p->probes[i].address += ANOFFSET (delta, SECT_OFF_TEXT (objfile));
++ if (p->probes[i].sem_addr)
++ p->probes[i].sem_addr += ANOFFSET (delta, SECT_OFF_DATA (objfile));
+ }
+}
+
++/* Helper function used to free the space allocated for storing SystemTap
++ probe information. */
++
+static void
-+dw2_expand_symtabs_with_filename (struct objfile *objfile,
-+ const char *filename)
++stap_probe_key_free (struct objfile *objfile, void *d)
+{
+ int i;
++ struct stap_probe_per_objfile *data = (struct stap_probe_per_objfile *) d;
+
-+ dw2_setup (objfile);
-+ for (i = 0; i < dwarf2_per_objfile->n_comp_units; ++i)
-+ {
-+ int j;
-+ struct dwarf2_per_cu_data *cu = dwarf2_per_objfile->all_comp_units[i];
++ for (i = 0; i < data->stap_num_probes; i++)
++ stap_free_parsed_args (data->probes[i].parsed_args);
++ xfree (data->probes);
++ xfree (data);
++}
+
-+ if (cu->v.quick->symtab)
-+ continue;
+ \f
+
-+ dw2_require_line_header (objfile, cu);
-+ if (!cu->v.quick->lines)
-+ continue;
++/* Implementation `sym_probe_fns', as documented in symfile.h. */
++
++static const struct sym_probe_fns elf_probe_fns =
++{
++ elf_get_probes, /* sym_get_probes */
++ elf_get_probe_argument_count, /* sym_get_probe_argument_count */
++ elf_evaluate_probe_argument, /* sym_evaluate_probe_argument */
++ elf_compile_to_ax, /* sym_compile_to_ax */
++ elf_symfile_relocate_probe, /* sym_relocate_probe */
++};
+
-+ for (j = 0; j < cu->v.quick->lines->num_file_names; ++j)
+ /* Register that we are able to handle ELF object file formats. */
+
+ static const struct sym_fns elf_sym_fns =
+@@ -1568,6 +1848,7 @@ static const struct sym_fns elf_sym_fns
+ elf_symfile_segments, /* Get segment information from a file. */
+ NULL,
+ default_symfile_relocate, /* Relocate a debug section. */
++ &elf_probe_fns, /* sym_probe_fns */
+ &psym_functions
+ };
+
+@@ -1586,6 +1867,7 @@ static const struct sym_fns elf_sym_fns_
+ elf_symfile_segments, /* Get segment information from a file. */
+ NULL,
+ default_symfile_relocate, /* Relocate a debug section. */
++ &elf_probe_fns, /* sym_probe_fns */
+ &psym_functions
+ };
+
+@@ -1603,6 +1885,7 @@ static const struct sym_fns elf_sym_fns_
+ elf_symfile_segments, /* Get segment information from a file. */
+ NULL,
+ default_symfile_relocate, /* Relocate a debug section. */
++ &elf_probe_fns, /* sym_probe_fns */
+ &dwarf2_gdb_index_functions
+ };
+
+@@ -1619,6 +1902,8 @@ static const struct gnu_ifunc_fns elf_gn
+ void
+ _initialize_elfread (void)
+ {
++ stap_probe_key
++ = register_objfile_data_with_cleanup (NULL, stap_probe_key_free);
+ add_symtab_fns (&elf_sym_fns);
+
+ elf_objfile_gnu_ifunc_cache_data = register_objfile_data ();
+Index: gdb-7.2.90.20110703/gdb/eval.c
+===================================================================
+--- gdb-7.2.90.20110703.orig/gdb/eval.c 2011-03-28 22:21:03.000000000 +0200
++++ gdb-7.2.90.20110703/gdb/eval.c 2011-07-03 10:33:11.000000000 +0200
+@@ -44,6 +44,7 @@
+ #include "objfiles.h"
+ #include "python/python.h"
+ #include "wrapper.h"
++#include "dwarf2loc.h"
+
+ #include "gdb_assert.h"
+
+@@ -489,27 +490,217 @@ init_array_element (struct value *array,
+ }
+
+ static struct value *
+-value_f90_subarray (struct value *array,
+- struct expression *exp, int *pos, enum noside noside)
++value_f90_subarray (struct value *array, struct expression *exp, int *pos,
++ int nargs, enum noside noside)
+ {
+- int pc = (*pos) + 1;
+- LONGEST low_bound, high_bound;
+- struct type *range = check_typedef (TYPE_INDEX_TYPE (value_type (array)));
+- enum f90_range_type range_type = longest_to_int (exp->elts[pc].longconst);
+-
+- *pos += 3;
++ /* Type to use for the newly allocated value ARRAY. */
++ struct type *new_array_type;
+
+- if (range_type == LOW_BOUND_DEFAULT || range_type == BOTH_BOUND_DEFAULT)
+- low_bound = TYPE_LOW_BOUND (range);
++ /* Type being iterated for each dimension. */
++ struct type *type, *type_last_target;
++
++ /* Pointer in the last holder to the type of current dimension. */
++ struct type **typep = &new_array_type;
++
++ struct subscript_index
++ {
++ enum { SUBSCRIPT_RANGE, SUBSCRIPT_NUMBER } kind;
++ union
+ {
-+ const char *this_name = cu->v.quick->file_names[j];
-+ if (strcmp (this_name, filename) == 0)
++ struct subscript_range
+ {
-+ dw2_instantiate_symtab (objfile, cu);
-+ break;
++ enum f90_range_type f90_range_type;
++ LONGEST low_bound, high_bound;
+ }
-+ }
++ range;
++ LONGEST number;
++ };
+ }
-+}
-+
-+static const char *
-+dw2_find_symbol_file (struct objfile *objfile, const char *name)
-+{
-+ struct dwarf2_per_cu_data *cu;
-+ offset_type *vec;
++ *subscript_array;
++ struct type **type_array;
++ int i;
++ struct cleanup *old_chain;
++ CORE_ADDR value_byte_address, value_byte_offset = 0;
++ htab_t copied_types;
++ struct value *saved_array;
++
++ old_chain = make_cleanup (null_cleanup, 0);
++ object_address_set (value_raw_address (array));
++
++ if (value_optimized_out (array)
++ || (VALUE_LVAL (array) != not_lval
++ && VALUE_LVAL (array) != lval_memory
++ && VALUE_LVAL (array) != lval_internalvar_component
++ && VALUE_LVAL (array) != lval_internalvar))
++ error (_("value being subranged must be in memory"));
++ type = check_typedef (value_type (array));
++ f_object_address_data_valid_or_error (type);
+
-+ dw2_setup (objfile);
++ copied_types = create_copied_types_hash (NULL);
++ type = copy_type_recursive (type, copied_types);
++ htab_delete (copied_types);
+
-+ if (!dwarf2_per_objfile->index_table)
-+ return NULL;
++ if (nargs != calc_f77_array_dims (type))
++ error (_("Wrong number of subscripts"));
+
-+ if (!find_slot_in_mapped_hash (dwarf2_per_objfile->index_table,
-+ name, &vec))
-+ return NULL;
++ if (TYPE_DATA_LOCATION_IS_ADDR (type))
++ {
++ value_byte_address = (TYPE_DATA_LOCATION_ADDR (type)
++ + value_offset (array));
++ TYPE_DATA_LOCATION_IS_ADDR (type) = 0;
++ TYPE_DATA_LOCATION_DWARF_BLOCK (type) = NULL;
++ }
+ else
+- low_bound = value_as_long (evaluate_subexp (NULL_TYPE, exp, pos, noside));
++ {
++ gdb_assert (TYPE_DATA_LOCATION_DWARF_BLOCK (type) == NULL);
++ value_byte_address = value_address (array);
++ }
+
-+ /* Note that this just looks at the very first one named NAME -- but
-+ actually we are looking for a function. find_main_filename
-+ should be rewritten so that it doesn't require a custom hook. It
-+ could just use the ordinary symbol tables. */
-+ /* vec[0] is the length, which must always be >0. */
-+ cu = dwarf2_per_objfile->all_comp_units[MAYBE_SWAP (vec[1])];
++ new_array_type = type;
+
-+ dw2_require_line_header (objfile, cu);
-+ if (!cu->v.quick->lines)
-+ return NULL;
++ subscript_array = alloca (sizeof (*subscript_array) * nargs);
+
-+ return cu->v.quick->file_names[cu->v.quick->lines->num_file_names - 1];
-+}
++ gdb_assert (nargs > 0);
+
-+static void
-+dw2_map_ada_symtabs (struct objfile *objfile,
-+ int (*wild_match) (const char *, int, const char *),
-+ int (*is_name_suffix) (const char *),
-+ void (*callback) (struct objfile *,
-+ struct symtab *, void *),
-+ const char *name, int global,
-+ domain_enum namespace, int wild,
-+ void *data)
-+{
-+ /* For now, we don't support Ada, so this function can't be
-+ reached. */
-+ internal_error (__FILE__, __LINE__,
-+ _("map_ada_symtabs called via index method"));
-+}
++ /* Now that we know we have a legal array subscript expression
++ let us actually find out where this element exists in the array. */
+
-+static void
-+dw2_expand_symtabs_matching (struct objfile *objfile,
-+ int (*file_matcher) (const char *, void *),
-+ int (*name_matcher) (const char *, void *),
-+ domain_enum kind,
-+ void *data)
-+{
-+ int i;
-+ offset_type iter;
++ /* Take array indices left to right. */
++ for (i = 0; i < nargs; i++)
++ {
++ struct subscript_index *index = &subscript_array[i];
+
-+ dw2_setup (objfile);
-+ if (!dwarf2_per_objfile->index_table)
-+ return;
++ if (exp->elts[*pos].opcode == OP_F90_RANGE)
++ {
++ int pc = (*pos) + 1;
++ struct subscript_range *range;
+
-+ for (i = 0; i < dwarf2_per_objfile->n_comp_units; ++i)
-+ {
-+ int j;
-+ struct dwarf2_per_cu_data *cu = dwarf2_per_objfile->all_comp_units[i];
++ index->kind = SUBSCRIPT_RANGE;
++ range = &index->range;
+
-+ cu->v.quick->mark = 0;
-+ if (cu->v.quick->symtab)
-+ continue;
++ *pos += 3;
++ range->f90_range_type = longest_to_int (exp->elts[pc].longconst);
+
-+ dw2_require_line_header (objfile, cu);
-+ if (!cu->v.quick->lines)
-+ continue;
++ if (range->f90_range_type == HIGH_BOUND_DEFAULT
++ || range->f90_range_type == NONE_BOUND_DEFAULT)
++ range->low_bound = value_as_long (evaluate_subexp (NULL_TYPE, exp,
++ pos, noside));
+
-+ for (j = 0; j < cu->v.quick->lines->num_file_names; ++j)
++ if (range->f90_range_type == LOW_BOUND_DEFAULT
++ || range->f90_range_type == NONE_BOUND_DEFAULT)
++ range->high_bound = value_as_long (evaluate_subexp (NULL_TYPE, exp,
++ pos, noside));
++ }
++ else
+ {
-+ if (file_matcher (cu->v.quick->file_names[j], data))
-+ {
-+ cu->v.quick->mark = 1;
-+ break;
-+ }
++ struct value *val;
++
++ index->kind = SUBSCRIPT_NUMBER;
+
+- if (range_type == HIGH_BOUND_DEFAULT || range_type == BOTH_BOUND_DEFAULT)
+- high_bound = TYPE_HIGH_BOUND (range);
++ /* Evaluate each subscript; it must be a legal integer in F77. */
++ val = evaluate_subexp_with_coercion (exp, pos, noside);
++ index->number = value_as_long (val);
+ }
+ }
+
-+ for (iter = 0;
-+ iter < dwarf2_per_objfile->index_table->index_table_slots;
-+ ++iter)
++ /* Internal type of array is arranged right to left. */
++ for (i = nargs - 1; i >= 0; i--)
+ {
-+ offset_type idx = 2 * iter;
-+ const char *name;
-+ offset_type *vec, vec_len, vec_idx;
++ struct subscript_index *index = &subscript_array[i];
++ struct type *range_type = TYPE_INDEX_TYPE (type);
+
-+ if (dwarf2_per_objfile->index_table->index_table[idx] == 0
-+ && dwarf2_per_objfile->index_table->index_table[idx + 1] == 0)
-+ continue;
-+
-+ name = (dwarf2_per_objfile->index_table->constant_pool
-+ + dwarf2_per_objfile->index_table->index_table[idx]);
-+
-+ if (! (*name_matcher) (name, data))
-+ continue;
-+
-+ /* The name was matched, now expand corresponding CUs that were
-+ marked. */
-+ vec = (offset_type *) (dwarf2_per_objfile->index_table->constant_pool
-+ + dwarf2_per_objfile->index_table->index_table[idx + 1]);
-+ vec_len = MAYBE_SWAP (vec[0]);
-+ for (vec_idx = 0; vec_idx < vec_len; ++vec_idx)
++ switch (index->kind)
+ {
-+ struct dwarf2_per_cu_data *cu
-+ = dwarf2_per_objfile->all_comp_units[MAYBE_SWAP (vec[vec_idx + 1])];
-+ if (cu->v.quick->mark)
-+ dw2_instantiate_symtab (objfile, cu);
-+ }
-+ }
-+}
-+
-+static struct symtab *
-+dw2_find_pc_sect_symtab (struct objfile *objfile,
-+ struct minimal_symbol *msymbol,
-+ CORE_ADDR pc,
-+ struct obj_section *section,
-+ int warn_if_readin)
-+{
-+ struct dwarf2_per_cu_data *data;
-+
-+ dw2_setup (objfile);
-+
-+ if (!objfile->psymtabs_addrmap)
-+ return NULL;
++ case SUBSCRIPT_RANGE:
++ {
++ struct subscript_range *range = &index->range;
++ CORE_ADDR byte_offset;
++
++ if (range->f90_range_type == LOW_BOUND_DEFAULT
++ || range->f90_range_type == BOTH_BOUND_DEFAULT)
++ range->low_bound = TYPE_LOW_BOUND (range_type);
++
++ if (range->f90_range_type == HIGH_BOUND_DEFAULT
++ || range->f90_range_type == BOTH_BOUND_DEFAULT)
++ range->high_bound = TYPE_HIGH_BOUND (range_type);
++
++ if (range->low_bound < TYPE_LOW_BOUND (range_type)
++ || (!TYPE_HIGH_BOUND_UNDEFINED (range_type)
++ && range->high_bound > TYPE_HIGH_BOUND (range_type)))
++ error (_("slice out of range"));
++
++ byte_offset = ((range->low_bound - TYPE_LOW_BOUND (range_type))
++ * TYPE_ARRAY_BYTE_STRIDE_VALUE (type));
++ TYPE_LOW_BOUND (range_type) = range->low_bound;
++ TYPE_HIGH_BOUND (range_type) = range->high_bound;
++ if (range->f90_range_type == LOW_BOUND_DEFAULT
++ || range->f90_range_type == NONE_BOUND_DEFAULT)
++ TYPE_HIGH_BOUND_UNDEFINED (range_type) = 0;
++
++ typep = &TYPE_TARGET_TYPE (type);
++ value_byte_offset += byte_offset;
++ type = TYPE_TARGET_TYPE (type);
++ }
++ break;
+
-+ data = addrmap_find (objfile->psymtabs_addrmap, pc);
-+ if (!data)
-+ return NULL;
++ case SUBSCRIPT_NUMBER:
++ {
++ CORE_ADDR byte_offset;
+
-+ if (warn_if_readin && data->v.quick->symtab)
-+ warning (_("(Internal error: pc %s in read in CU, but not in symtab.)\n"),
-+ paddress (get_objfile_arch (objfile), pc));
++ if (index->number < TYPE_LOW_BOUND (range_type)
++ || (!TYPE_HIGH_BOUND_UNDEFINED (range_type)
++ && index->number > TYPE_HIGH_BOUND (range_type)))
++ error (_("no such vector element"));
+
-+ return dw2_instantiate_symtab (objfile, data);
-+}
++ byte_offset = ((index->number - TYPE_LOW_BOUND (range_type))
++ * TYPE_ARRAY_BYTE_STRIDE_VALUE (type));
+
-+static void
-+dw2_map_symbol_names (struct objfile *objfile,
-+ void (*fun) (const char *, void *),
-+ void *data)
-+{
-+ offset_type iter;
-+ dw2_setup (objfile);
-
-- if (info->size > 4 * pagesize && (sectp->flags & SEC_RELOC) == 0)
-+ if (!dwarf2_per_objfile->index_table)
-+ return;
++ type = TYPE_TARGET_TYPE (type);
++ *typep = type;
++ value_byte_offset += byte_offset;
++ }
++ break;
++ }
++ }
+
-+ for (iter = 0;
-+ iter < dwarf2_per_objfile->index_table->index_table_slots;
-+ ++iter)
- {
-- off_t pg_offset = sectp->filepos & ~(pagesize - 1);
-- size_t map_length = info->size + sectp->filepos - pg_offset;
-- caddr_t retbuf = bfd_mmap (abfd, 0, map_length, PROT_READ,
-- MAP_PRIVATE, pg_offset);
-+ offset_type idx = 2 * iter;
-+ const char *name;
-+ offset_type *vec, vec_len, vec_idx;
-
-- if (retbuf != MAP_FAILED)
-- {
-- info->was_mmapped = 1;
-- info->buffer = retbuf + (sectp->filepos & (pagesize - 1)) ;
--#if HAVE_POSIX_MADVISE
-- posix_madvise (retbuf, map_length, POSIX_MADV_WILLNEED);
--#endif
-- return;
-- }
-+ if (dwarf2_per_objfile->index_table->index_table[idx] == 0
-+ && dwarf2_per_objfile->index_table->index_table[idx + 1] == 0)
-+ continue;
++ type_last_target = type;
++ type_array = alloca (sizeof (*type_array) * nargs);
++ i = 0;
++ for (type = new_array_type; type != type_last_target;
++ type = TYPE_TARGET_TYPE (type))
++ type_array[i++] = type;
++ while (i > 0)
++ {
++ struct type *type = type_array[--i];
+
-+ name = (dwarf2_per_objfile->index_table->constant_pool
-+ + dwarf2_per_objfile->index_table->index_table[idx]);
++ /* Force TYPE_LENGTH (type) recalculation. */
++ TYPE_TARGET_STUB (type) = 1;
++ check_typedef (type);
++ }
+
-+ (*fun) (name, data);
- }
--#endif
-+}
-
-- /* If we get here, we are a normal, not-compressed section. */
-- info->buffer = buf
-- = obstack_alloc (&objfile->objfile_obstack, info->size);
-+static void
-+dw2_map_symbol_filenames (struct objfile *objfile,
-+ void (*fun) (const char *, const char *, void *),
-+ void *data)
-+{
-+ int i;
++ saved_array = array;
++ array = allocate_value_lazy (new_array_type);
++ VALUE_LVAL (array) = VALUE_LVAL (saved_array);
++ if (VALUE_LVAL (saved_array) == lval_internalvar_component)
++ VALUE_LVAL (array) = lval_internalvar;
+ else
+- high_bound = value_as_long (evaluate_subexp (NULL_TYPE, exp, pos, noside));
++ VALUE_LVAL (array) = VALUE_LVAL (saved_array);
++ VALUE_FRAME_ID (array) = VALUE_FRAME_ID (saved_array);
++ if (VALUE_LVAL (array) != lval_internalvar)
++ set_value_address (array, value_byte_address + value_byte_offset);
-- /* When debugging .o files, we may need to apply relocations; see
-- http://sourceware.org/ml/gdb-patches/2002-04/msg00136.html .
-- We never compress sections in .o files, so we only need to
-- try this when the section is not compressed. */
-- retbuf = symfile_relocate_debug_section (objfile, sectp, buf);
-- if (retbuf != NULL)
-+ dw2_setup (objfile);
-+ for (i = 0; i < dwarf2_per_objfile->n_comp_units; ++i)
- {
-- info->buffer = retbuf;
-- return;
-+ int j;
-+ struct dwarf2_per_cu_data *cu = dwarf2_per_objfile->all_comp_units[i];
-+
-+ if (cu->v.quick->symtab)
-+ continue;
+- return value_slice (array, low_bound, high_bound - low_bound + 1);
++ if (!value_lazy (saved_array))
++ {
++ allocate_value_contents (array);
++ set_value_lazy (array, 0);
+
-+ dw2_require_line_header (objfile, cu);
-+ if (!cu->v.quick->lines)
-+ continue;
++ memcpy (value_contents_writeable (array),
++ value_contents (saved_array) + value_byte_offset,
++ TYPE_LENGTH (new_array_type));
++ }
+
-+ for (j = 0; j < cu->v.quick->lines->num_file_names; ++j)
-+ {
-+ const char *this_full_name = dw2_require_full_path (objfile, cu, j);
-+ (*fun) (cu->v.quick->file_names[j], this_full_name, data);
-+ }
- }
-+}
-
-- if (bfd_seek (abfd, sectp->filepos, SEEK_SET) != 0
-- || bfd_bread (buf, info->size, abfd) != info->size)
-- error (_("Dwarf Error: Can't read DWARF data from '%s'"),
-- bfd_get_filename (abfd));
-+static int
-+dw2_has_symbols (struct objfile *objfile)
-+{
-+ return 1;
++ do_cleanups (old_chain);
++ return array;
}
--/* Fill in SECTP, BUFP and SIZEP with section info, given OBJFILE and
-- SECTION_NAME. */
-+const struct quick_symbol_functions dwarf2_gdb_index_functions =
-+{
-+ dw2_has_symbols,
-+ dw2_find_last_source_symtab,
-+ dw2_forget_cached_source_info,
-+ dw2_lookup_symtab,
-+ dw2_lookup_symbol,
-+ dw2_pre_expand_symtabs_matching,
-+ dw2_print_stats,
-+ dw2_dump,
-+ dw2_relocate,
-+ dw2_expand_symtabs_for_function,
-+ dw2_expand_all_symtabs,
-+ dw2_expand_symtabs_with_filename,
-+ dw2_find_symbol_file,
-+ dw2_map_ada_symtabs,
-+ dw2_expand_symtabs_matching,
-+ dw2_find_pc_sect_symtab,
-+ dw2_map_symbol_names,
-+ dw2_map_symbol_filenames
-+};
--void
--dwarf2_get_section_info (struct objfile *objfile, const char *section_name,
-- asection **sectp, gdb_byte **bufp,
-- bfd_size_type *sizep)
--{
-- struct dwarf2_per_objfile *data
-- = objfile_data (objfile, dwarf2_objfile_data_key);
-- struct dwarf2_section_info *info;
-+/* Initialize for reading DWARF for this objfile. Return 0 if this
-+ file will use psymtabs, or 1 if using the GNU index. */
-
-- /* We may see an objfile without any DWARF, in which case we just
-- return nothing. */
-- if (data == NULL)
-+int
-+dwarf2_initialize_objfile (struct objfile *objfile)
-+{
-+ /* If we're about to read full symbols, don't bother with the
-+ indices. In this case we also don't care if some other debug
-+ format is making psymtabs, because they are all about to be
-+ expanded anyway. */
-+ if ((objfile->flags & OBJF_READNOW))
- {
-- *sectp = NULL;
-- *bufp = NULL;
-- *sizep = 0;
-- return;
-+ int i;
-+
-+ dwarf2_per_objfile->using_index = 1;
-+ create_all_comp_units (objfile);
-+
-+ for (i = 0; i < dwarf2_per_objfile->n_comp_units; ++i)
-+ {
-+ struct dwarf2_per_cu_data *cu = dwarf2_per_objfile->all_comp_units[i];
-+
-+ cu->v.quick = OBSTACK_ZALLOC (&objfile->objfile_obstack,
-+ struct dwarf2_per_cu_quick_data);
-+ }
-+
-+ /* Return 1 so that gdb sees the "quick" functions. However,
-+ these functions will be no-ops because we will have expanded
-+ all symtabs. */
-+ return 1;
- }
-- if (section_is_p (section_name, EH_FRAME_SECTION))
-- info = &data->eh_frame;
-- else if (section_is_p (section_name, FRAME_SECTION))
-- info = &data->frame;
-- else
-- gdb_assert (0);
+@@ -790,6 +981,7 @@ evaluate_subexp_standard (struct type *e
+ int save_pos1;
+ struct symbol *function = NULL;
+ char *function_name = NULL;
++ struct cleanup *old_chain;
-- if (info->asection != NULL && info->size != 0 && info->buffer == NULL)
-- /* We haven't read this section in yet. Do it now. */
-- dwarf2_read_section (objfile, info);
-+ if (dwarf2_read_index (objfile))
-+ return 1;
+ pc = (*pos)++;
+ op = exp->elts[pc].opcode;
+@@ -1862,6 +2054,8 @@ evaluate_subexp_standard (struct type *e
-- *sectp = info->asection;
-- *bufp = info->buffer;
-- *sizep = info->size;
-+ dwarf2_build_psymtabs (objfile);
-+ return 0;
- }
+ /* First determine the type code we are dealing with. */
+ arg1 = evaluate_subexp (NULL_TYPE, exp, pos, noside);
++ old_chain = make_cleanup (null_cleanup, 0);
++ object_address_set (value_raw_address (arg1));
+ type = check_typedef (value_type (arg1));
+ code = TYPE_CODE (type);
-+\f
-+
- /* Build a partial symbol table. */
+@@ -1882,23 +2076,13 @@ evaluate_subexp_standard (struct type *e
+ code = TYPE_CODE (type);
+ }
+ }
++ do_cleanups (old_chain);
- void
-@@ -1699,6 +2688,7 @@ create_debug_types_hash_table (struct objfile *objfile)
- type_sig->signature = signature;
- type_sig->offset = offset;
- type_sig->type_offset = type_offset;
-+ type_sig->per_cu.objfile = objfile;
-
- slot = htab_find_slot (types_htab, type_sig, INSERT);
- gdb_assert (slot != NULL);
-@@ -1897,7 +2887,7 @@ process_psymtab_comp_unit (struct objfile *objfile,
- /* Store the function that reads in the rest of the symbol table */
- pst->read_symtab = dwarf2_psymtab_to_symtab;
-
-- this_cu->psymtab = pst;
-+ this_cu->v.psymtab = pst;
-
- dwarf2_find_base_address (comp_unit_die, &cu);
-
-@@ -2182,6 +3172,7 @@ create_all_comp_units (struct objfile *objfile)
- memset (this_cu, 0, sizeof (*this_cu));
- this_cu->offset = offset;
- this_cu->length = length + initial_length_size;
-+ this_cu->objfile = objfile;
-
- if (n_comp_units == n_allocated)
+ switch (code)
{
-@@ -2613,7 +3604,7 @@ add_partial_subprogram (struct partial_die_info *pdi,
- addrmap_set_empty (objfile->psymtabs_addrmap,
- pdi->lowpc + baseaddr,
- pdi->highpc - 1 + baseaddr,
-- cu->per_cu->psymtab);
-+ cu->per_cu->v.psymtab);
- }
- if (!pdi->is_declaration)
- /* Ignore subprogram DIEs that do not have a name, they are
-@@ -2885,7 +3876,6 @@ locate_pdi_sibling (struct partial_die_info *orig_pdi,
- static void
- dwarf2_psymtab_to_symtab (struct partial_symtab *pst)
- {
-- /* FIXME: This is barely more than a stub. */
- if (pst != NULL)
- {
- if (pst->readin)
-@@ -2958,7 +3948,9 @@ process_queue (struct objfile *objfile)
- may load a new CU, adding it to the end of the queue. */
- for (item = dwarf2_queue; item != NULL; dwarf2_queue = item = next_item)
- {
-- if (item->per_cu->psymtab && !item->per_cu->psymtab->readin)
-+ if (dwarf2_per_objfile->using_index
-+ ? !item->per_cu->v.quick->symtab
-+ : (item->per_cu->v.psymtab && !item->per_cu->v.psymtab->readin))
- process_full_comp_unit (item->per_cu);
-
- item->per_cu->queued = 0;
-@@ -3035,22 +4027,7 @@ psymtab_to_symtab_1 (struct partial_symtab *pst)
- return;
- }
+ case TYPE_CODE_ARRAY:
+- if (exp->elts[*pos].opcode == OP_F90_RANGE)
+- return value_f90_subarray (arg1, exp, pos, noside);
+- else
+- goto multi_f77_subscript;
+-
+ case TYPE_CODE_STRING:
+- if (exp->elts[*pos].opcode == OP_F90_RANGE)
+- return value_f90_subarray (arg1, exp, pos, noside);
+- else
+- {
+- arg2 = evaluate_subexp_with_coercion (exp, pos, noside);
+- return value_subscript (arg1, value_as_long (arg2));
+- }
++ return value_f90_subarray (arg1, exp, pos, nargs, noside);
+
+ case TYPE_CODE_PTR:
+ case TYPE_CODE_FUNC:
+@@ -2337,49 +2521,6 @@ evaluate_subexp_standard (struct type *e
+ }
+ return (arg1);
-- back_to = make_cleanup (dwarf2_release_queue, NULL);
+- multi_f77_subscript:
+- {
+- LONGEST subscript_array[MAX_FORTRAN_DIMS];
+- int ndimensions = 1, i;
+- struct value *array = arg1;
-
-- queue_comp_unit (per_cu, pst->objfile);
+- if (nargs > MAX_FORTRAN_DIMS)
+- error (_("Too many subscripts for F77 (%d Max)"), MAX_FORTRAN_DIMS);
-
-- if (per_cu->from_debug_types)
-- read_signatured_type_at_offset (pst->objfile, per_cu->offset);
-- else
-- load_full_comp_unit (per_cu, pst->objfile);
+- ndimensions = calc_f77_array_dims (type);
-
-- process_queue (pst->objfile);
+- if (nargs != ndimensions)
+- error (_("Wrong number of subscripts"));
-
-- /* Age the cache, releasing compilation units that have not
-- been used recently. */
-- age_cached_comp_units ();
+- gdb_assert (nargs > 0);
-
-- do_cleanups (back_to);
-+ dw2_do_instantiate_symtab (pst->objfile, per_cu);
- }
+- /* Now that we know we have a legal array subscript expression
+- let us actually find out where this element exists in the array. */
+-
+- /* Take array indices left to right. */
+- for (i = 0; i < nargs; i++)
+- {
+- /* Evaluate each subscript; it must be a legal integer in F77. */
+- arg2 = evaluate_subexp_with_coercion (exp, pos, noside);
+-
+- /* Fill in the subscript array. */
+-
+- subscript_array[i] = value_as_long (arg2);
+- }
+-
+- /* Internal type of array is arranged right to left. */
+- for (i = nargs; i > 0; i--)
+- {
+- struct type *array_type = check_typedef (value_type (array));
+- LONGEST index = subscript_array[i - 1];
+-
+- lower = f77_get_lowerbound (array_type);
+- array = value_subscripted_rvalue (array, index, lower);
+- }
+-
+- return array;
+- }
+-
+ case BINOP_LOGICAL_AND:
+ arg1 = evaluate_subexp (NULL_TYPE, exp, pos, noside);
+ if (noside == EVAL_SKIP)
+@@ -2611,15 +2752,23 @@ evaluate_subexp_standard (struct type *e
+ if (expect_type && TYPE_CODE (expect_type) == TYPE_CODE_PTR)
+ expect_type = TYPE_TARGET_TYPE (check_typedef (expect_type));
+ arg1 = evaluate_subexp (expect_type, exp, pos, noside);
++ old_chain = make_cleanup (null_cleanup, 0);
++ object_address_set (value_raw_address (arg1));
+ type = check_typedef (value_type (arg1));
+ if (TYPE_CODE (type) == TYPE_CODE_METHODPTR
+ || TYPE_CODE (type) == TYPE_CODE_MEMBERPTR)
+ error (_("Attempt to dereference pointer "
+ "to member without an object"));
+ if (noside == EVAL_SKIP)
+- goto nosideret;
++ {
++ do_cleanups (old_chain);
++ goto nosideret;
++ }
+ if (unop_user_defined_p (op, arg1))
+- return value_x_unop (arg1, op, noside);
++ {
++ do_cleanups (old_chain);
++ return value_x_unop (arg1, op, noside);
++ }
+ else if (noside == EVAL_AVOID_SIDE_EFFECTS)
+ {
+ type = check_typedef (value_type (arg1));
+@@ -2628,12 +2777,18 @@ evaluate_subexp_standard (struct type *e
+ /* In C you can dereference an array to get the 1st elt. */
+ || TYPE_CODE (type) == TYPE_CODE_ARRAY
+ )
+- return value_zero (TYPE_TARGET_TYPE (type),
+- lval_memory);
++ {
++ do_cleanups (old_chain);
++ return value_zero (TYPE_TARGET_TYPE (type),
++ lval_memory);
++ }
+ else if (TYPE_CODE (type) == TYPE_CODE_INT)
+- /* GDB allows dereferencing an int. */
+- return value_zero (builtin_type (exp->gdbarch)->builtin_int,
+- lval_memory);
++ {
++ do_cleanups (old_chain);
++ /* GDB allows dereferencing an int. */
++ return value_zero (builtin_type (exp->gdbarch)->builtin_int,
++ lval_memory);
++ }
+ else
+ error (_("Attempt to take contents of a non-pointer value."));
+ }
+@@ -2643,9 +2798,14 @@ evaluate_subexp_standard (struct type *e
+ do. "long long" variables are rare enough that
+ BUILTIN_TYPE_LONGEST would seem to be a mistake. */
+ if (TYPE_CODE (type) == TYPE_CODE_INT)
+- return value_at_lazy (builtin_type (exp->gdbarch)->builtin_int,
+- (CORE_ADDR) value_as_address (arg1));
+- return value_ind (arg1);
++ {
++ do_cleanups (old_chain);
++ return value_at_lazy (builtin_type (exp->gdbarch)->builtin_int,
++ (CORE_ADDR) value_as_address (arg1));
++ }
++ arg1 = value_ind (arg1);
++ do_cleanups (old_chain);
++ return arg1;
- /* Load the DIEs associated with PER_CU into memory. */
-@@ -3130,9 +4107,8 @@ load_full_comp_unit (struct dwarf2_per_cu_data *per_cu, struct objfile *objfile)
- static void
- process_full_comp_unit (struct dwarf2_per_cu_data *per_cu)
+ case UNOP_ADDR:
+ /* C++: check for and handle pointer to members. */
+@@ -2991,7 +3151,7 @@ evaluate_subexp_with_coercion (struct ex
{
-- struct partial_symtab *pst = per_cu->psymtab;
- struct dwarf2_cu *cu = per_cu->cu;
-- struct objfile *objfile = pst->objfile;
-+ struct objfile *objfile = per_cu->objfile;
- CORE_ADDR lowpc, highpc;
- struct symtab *symtab;
- struct cleanup *back_to;
-@@ -3165,8 +4141,15 @@ process_full_comp_unit (struct dwarf2_per_cu_data *per_cu)
+ enum exp_opcode op;
+ int pc;
+- struct value *val;
++ struct value *val = NULL;
+ struct symbol *var;
+ struct type *type;
+
+@@ -3002,13 +3162,18 @@ evaluate_subexp_with_coercion (struct ex
{
- symtab->language = cu->language;
- }
-- pst->symtab = symtab;
-- pst->readin = 1;
-+
-+ if (dwarf2_per_objfile->using_index)
-+ per_cu->v.quick->symtab = symtab;
-+ else
-+ {
-+ struct partial_symtab *pst = per_cu->v.psymtab;
-+ pst->symtab = symtab;
-+ pst->readin = 1;
-+ }
+ case OP_VAR_VALUE:
+ var = exp->elts[pc + 2].symbol;
++ /* address_of_variable will call object_address_set for check_typedef.
++ Call it only if required as it can error-out on VAR in register. */
++ if (TYPE_DYNAMIC (SYMBOL_TYPE (var)))
++ val = address_of_variable (var, exp->elts[pc + 1].block);
+ type = check_typedef (SYMBOL_TYPE (var));
+ if (TYPE_CODE (type) == TYPE_CODE_ARRAY
+ && !TYPE_VECTOR (type)
+ && CAST_IS_CONVERSION (exp->language_defn))
+ {
+ (*pos) += 4;
+- val = address_of_variable (var, exp->elts[pc + 1].block);
++ if (!val)
++ val = address_of_variable (var, exp->elts[pc + 1].block);
+ return value_cast (lookup_pointer_type (TYPE_TARGET_TYPE (type)),
+ val);
+ }
+@@ -3060,9 +3225,13 @@ evaluate_subexp_for_sizeof (struct expre
- do_cleanups (back_to);
- }
-@@ -3557,6 +4540,46 @@ free_cu_line_header (void *arg)
- }
+ case OP_VAR_VALUE:
+ (*pos) += 4;
+- type = check_typedef (SYMBOL_TYPE (exp->elts[pc + 2].symbol));
+- return
+- value_from_longest (size_type, (LONGEST) TYPE_LENGTH (type));
++ /* We do not need to call read_var_value but the object evaluation may
++ need to have executed object_address_set which needs valid
++ SYMBOL_VALUE_ADDRESS of the symbol. Still VALUE returned by
++ read_var_value we left as lazy. */
++ type = value_type (read_var_value (exp->elts[pc + 2].symbol,
++ deprecated_safe_get_selected_frame ()));
++ return value_from_longest (size_type, (LONGEST) TYPE_LENGTH (type));
- static void
-+find_file_and_directory (struct die_info *die, struct dwarf2_cu *cu,
-+ char **name, char **comp_dir)
-+{
-+ struct attribute *attr;
-+
-+ *name = NULL;
-+ *comp_dir = NULL;
-+
-+ /* Find the filename. Do not use dwarf2_name here, since the filename
-+ is not a source language identifier. */
-+ attr = dwarf2_attr (die, DW_AT_name, cu);
-+ if (attr)
-+ {
-+ *name = DW_STRING (attr);
-+ }
-+
-+ attr = dwarf2_attr (die, DW_AT_comp_dir, cu);
-+ if (attr)
-+ *comp_dir = DW_STRING (attr);
-+ else if (*name != NULL && IS_ABSOLUTE_PATH (*name))
-+ {
-+ *comp_dir = ldirname (*name);
-+ if (*comp_dir != NULL)
-+ make_cleanup (xfree, *comp_dir);
-+ }
-+ if (*comp_dir != NULL)
-+ {
-+ /* Irix 6.2 native cc prepends <machine>.: to the compilation
-+ directory, get rid of it. */
-+ char *cp = strchr (*comp_dir, ':');
-+
-+ if (cp && cp != *comp_dir && cp[-1] == '.' && cp[1] == '/')
-+ *comp_dir = cp + 1;
-+ }
-+
-+ if (*name == NULL)
-+ *name = "<unknown>";
-+}
-+
-+static void
- read_file_scope (struct die_info *die, struct dwarf2_cu *cu)
+ default:
+ val = evaluate_subexp (NULL_TYPE, exp, pos, EVAL_AVOID_SIDE_EFFECTS);
+@@ -3093,18 +3262,25 @@ parse_and_eval_type (char *p, int length
+ int
+ calc_f77_array_dims (struct type *array_type)
{
- struct objfile *objfile = cu->objfile;
-@@ -3582,35 +4605,7 @@ read_file_scope (struct die_info *die, struct dwarf2_cu *cu)
- lowpc += baseaddr;
- highpc += baseaddr;
+- int ndimen = 1;
+- struct type *tmp_type;
++ switch (TYPE_CODE (array_type))
++ {
++ case TYPE_CODE_STRING:
++ return 1;
-- /* Find the filename. Do not use dwarf2_name here, since the filename
-- is not a source language identifier. */
-- attr = dwarf2_attr (die, DW_AT_name, cu);
-- if (attr)
+- if ((TYPE_CODE (array_type) != TYPE_CODE_ARRAY))
+- error (_("Can't get dimensions for a non-array type"));
++ case TYPE_CODE_ARRAY:
++ {
++ int ndimen = 1;
+
+- tmp_type = array_type;
++ while ((array_type = TYPE_TARGET_TYPE (array_type)))
++ {
++ if (TYPE_CODE (array_type) == TYPE_CODE_ARRAY)
++ ++ndimen;
++ }
++ return ndimen;
++ }
+
+- while ((tmp_type = TYPE_TARGET_TYPE (tmp_type)))
- {
-- name = DW_STRING (attr);
-- }
--
-- attr = dwarf2_attr (die, DW_AT_comp_dir, cu);
-- if (attr)
-- comp_dir = DW_STRING (attr);
-- else if (name != NULL && IS_ABSOLUTE_PATH (name))
-- {
-- comp_dir = ldirname (name);
-- if (comp_dir != NULL)
-- make_cleanup (xfree, comp_dir);
-- }
-- if (comp_dir != NULL)
-- {
-- /* Irix 6.2 native cc prepends <machine>.: to the compilation
-- directory, get rid of it. */
-- char *cp = strchr (comp_dir, ':');
--
-- if (cp && cp != comp_dir && cp[-1] == '.' && cp[1] == '/')
-- comp_dir = cp + 1;
-- }
--
-- if (name == NULL)
-- name = "<unknown>";
-+ find_file_and_directory (die, cu, &name, &comp_dir);
-
- attr = dwarf2_attr (die, DW_AT_language, cu);
- if (attr)
-@@ -5529,6 +6524,29 @@ process_enumeration_scope (struct die_info *die, struct dwarf2_cu *cu)
- new_symbol (die, this_type, cu);
+- if (TYPE_CODE (tmp_type) == TYPE_CODE_ARRAY)
+- ++ndimen;
++ default:
++ error (_("Can't get dimensions for a non-array/non-string type"));
+ }
+- return ndimen;
++
}
+Index: gdb-7.2.90.20110703/gdb/f-exp.y
+===================================================================
+--- gdb-7.2.90.20110703.orig/gdb/f-exp.y 2011-03-18 14:51:41.000000000 +0100
++++ gdb-7.2.90.20110703/gdb/f-exp.y 2011-07-03 10:33:11.000000000 +0200
+@@ -293,7 +293,9 @@ arglist : subrange
+ { arglist_len = 1; }
+ ;
+
+-arglist : arglist ',' exp %prec ABOVE_COMMA
++arglist : arglist ',' exp %prec ABOVE_COMMA
++ { arglist_len++; }
++ | arglist ',' subrange %prec ABOVE_COMMA
+ { arglist_len++; }
+ ;
+
+Index: gdb-7.2.90.20110703/gdb/f-lang.h
+===================================================================
+--- gdb-7.2.90.20110703.orig/gdb/f-lang.h 2011-01-07 20:36:16.000000000 +0100
++++ gdb-7.2.90.20110703/gdb/f-lang.h 2011-07-03 10:33:11.000000000 +0200
+@@ -28,6 +28,10 @@ extern void f_error (char *); /* Defined
+ extern void f_print_type (struct type *, const char *, struct ui_file *, int,
+ int);
-+/* Create a new array dimension referencing its target type TYPE.
-+
-+ Multidimensional arrays are internally represented as a stack of
-+ singledimensional arrays being referenced by their TYPE_TARGET_TYPE. */
++extern const char *f_object_address_data_valid_print_to_stream
++ (struct type *type, struct ui_file *stream);
++extern void f_object_address_data_valid_or_error (struct type *type);
+
-+static struct type *
-+create_single_array_dimension (struct type *type, struct type *range_type,
-+ struct die_info *die, struct dwarf2_cu *cu)
+ extern int f_val_print (struct type *, const gdb_byte *, int, CORE_ADDR,
+ struct ui_file *, int,
+ const struct value *,
+Index: gdb-7.2.90.20110703/gdb/f-typeprint.c
+===================================================================
+--- gdb-7.2.90.20110703.orig/gdb/f-typeprint.c 2011-01-07 20:36:16.000000000 +0100
++++ gdb-7.2.90.20110703/gdb/f-typeprint.c 2011-07-03 10:33:11.000000000 +0200
+@@ -32,7 +32,7 @@
+ #include "gdbcore.h"
+ #include "target.h"
+ #include "f-lang.h"
+-
++#include "dwarf2loc.h"
+ #include "gdb_string.h"
+ #include <errno.h>
+
+@@ -49,6 +49,34 @@ void f_type_print_varspec_prefix (struct
+ void f_type_print_base (struct type *, struct ui_file *, int, int);
+ \f
+
++const char *
++f_object_address_data_valid_print_to_stream (struct type *type,
++ struct ui_file *stream)
+{
-+ type = create_array_type (NULL, type, range_type);
++ const char *msg;
+
-+ /* These generic type attributes need to be fetched by
-+ evaluate_subexp_standard <multi_f77_subscript>'s call of
-+ value_subscripted_rvalue only for the innermost array type. */
-+ fetch_die_type_attrs (die, type, cu);
++ msg = object_address_data_not_valid (type);
++ if (msg != NULL)
++ {
++ /* Assuming the content printed to STREAM should not be localized. */
++ fprintf_filtered (stream, "<%s>", msg);
++ }
+
-+ /* These generic type attributes are checked for allocated/associated
-+ validity while accessing FIELD_LOC_KIND_DWARF_BLOCK. */
-+ fetch_die_type_attrs (die, range_type, cu);
++ return msg;
++}
+
-+ return type;
++void
++f_object_address_data_valid_or_error (struct type *type)
++{
++ const char *msg;
++
++ msg = object_address_data_not_valid (type);
++ if (msg != NULL)
++ {
++ error (_("Cannot access it because the %s."), _(msg));
++ }
+}
+
- /* Extract all information from a DW_TAG_array_type DIE and put it in
- the DIE's type field. For now, this only handles one dimensional
- arrays. */
-@@ -5542,7 +6560,7 @@ read_array_type (struct die_info *die, struct dwarf2_cu *cu)
- struct type *element_type, *range_type, *index_type;
- struct type **range_types = NULL;
- struct attribute *attr;
-- int ndim = 0;
-+ int ndim = 0, i;
- struct cleanup *back_to;
- char *name;
-
-@@ -5595,17 +6613,11 @@ read_array_type (struct die_info *die, struct dwarf2_cu *cu)
- type = element_type;
+ /* LEVEL is the depth to indent lines by. */
- if (read_array_order (die, cu) == DW_ORD_col_major)
-- {
-- int i = 0;
--
-- while (i < ndim)
-- type = create_array_type (NULL, type, range_types[i++]);
-- }
-- else
-- {
-- while (ndim-- > 0)
-- type = create_array_type (NULL, type, range_types[ndim]);
-- }
-+ for (i = 0; i < ndim; i++)
-+ type = create_single_array_dimension (type, range_types[i], die, cu);
-+ else /* (read_array_order (die, cu) == DW_ORD_row_major) */
-+ for (i = ndim - 1; i >= 0; i--)
-+ type = create_single_array_dimension (type, range_types[i], die, cu);
+ void
+@@ -58,6 +86,9 @@ f_print_type (struct type *type, const c
+ enum type_code code;
+ int demangled_args;
- /* Understand Dwarf2 support for vector types (like they occur on
- the PowerPC w/ AltiVec). Gcc just adds another attribute to the
-@@ -6059,29 +7071,114 @@ read_tag_string_type (struct die_info *die, struct dwarf2_cu *cu)
- struct gdbarch *gdbarch = get_objfile_arch (objfile);
- struct type *type, *range_type, *index_type, *char_type;
- struct attribute *attr;
-- unsigned int length;
-+ int length;
-+
-+ index_type = objfile_type (objfile)->builtin_int;
-+ /* RANGE_TYPE is allocated from OBJFILE, not as a permanent type. */
-+ range_type = alloc_type (objfile);
-+ /* LOW_BOUND and HIGH_BOUND are set for real below. */
-+ range_type = create_range_type (range_type, index_type, 0, -1);
++ if (f_object_address_data_valid_print_to_stream (type, stream) != NULL)
++ return;
+
-+ /* C/C++ should probably have the low bound 0 but C/C++ does not use
-+ DW_TAG_string_type. */
-+ TYPE_LOW_BOUND (range_type) = 1;
+ f_type_print_base (type, stream, show, level);
+ code = TYPE_CODE (type);
+ if ((varstring != NULL && *varstring != '\0')
+@@ -165,6 +196,9 @@ f_type_print_varspec_suffix (struct type
- attr = dwarf2_attr (die, DW_AT_string_length, cu);
-- if (attr)
-- {
-- length = DW_UNSND (attr);
-+ if (attr && attr_form_is_block (attr))
-+ {
-+ /* Security check for a size overflow. */
-+ if (DW_BLOCK (attr)->size + 2 < DW_BLOCK (attr)->size)
-+ TYPE_HIGH_BOUND (range_type) = 1;
-+ /* Extend the DWARF block by a new DW_OP_deref/DW_OP_deref_size
-+ instruction as DW_AT_string_length specifies the length location, not
-+ its value. */
-+ else
-+ {
-+ struct dwarf2_locexpr_baton *length_baton = NULL;
-+ struct dwarf_block *blk = DW_BLOCK (attr);
-+
-+ /* Turn any single DW_OP_reg* into DW_OP_breg*(0) but clearing
-+ DW_OP_deref* in such case. */
-+
-+ if (blk->size == 1 && blk->data[0] >= DW_OP_reg0
-+ && blk->data[0] <= DW_OP_reg31)
-+ length_baton = dwarf2_attr_to_locexpr_baton (attr, cu);
-+ else if (blk->size > 1 && blk->data[0] == DW_OP_regx)
-+ {
-+ ULONGEST ulongest;
-+ const gdb_byte *end;
-+
-+ end = read_uleb128 (&blk->data[1], &blk->data[blk->size],
-+ &ulongest);
-+ if (end == &blk->data[blk->size])
-+ length_baton = dwarf2_attr_to_locexpr_baton (attr, cu);
-+ }
-+
-+ if (length_baton == NULL)
-+ {
-+ struct attribute *size_attr;
-+ gdb_byte *data;
-+
-+ length_baton = obstack_alloc (&cu->comp_unit_obstack,
-+ sizeof (*length_baton));
-+ length_baton->per_cu = cu->per_cu;
-+ length_baton->size = DW_BLOCK (attr)->size + 2;
-+ data = obstack_alloc (&cu->comp_unit_obstack,
-+ length_baton->size);
-+ length_baton->data = data;
-+ memcpy (data, DW_BLOCK (attr)->data, DW_BLOCK (attr)->size);
-+
-+ /* DW_AT_BYTE_SIZE existing together with DW_AT_STRING_LENGTH
-+ specifies the size of an integer to fetch. */
-+ size_attr = dwarf2_attr (die, DW_AT_byte_size, cu);
-+ if (size_attr)
-+ {
-+ data[DW_BLOCK (attr)->size] = DW_OP_deref_size;
-+ data[DW_BLOCK (attr)->size + 1] = DW_UNSND (size_attr);
-+ if (data[DW_BLOCK (attr)->size + 1] != DW_UNSND (size_attr))
-+ complaint (&symfile_complaints,
-+ _("DW_AT_string_length's DW_AT_byte_size "
-+ "integer exceeds the byte size storage"));
-+ }
-+ else
-+ {
-+ data[DW_BLOCK (attr)->size] = DW_OP_deref;
-+ data[DW_BLOCK (attr)->size + 1] = DW_OP_nop;
-+ }
-+ }
+ QUIT;
+
++ if (TYPE_CODE (type) != TYPE_CODE_TYPEDEF)
++ CHECK_TYPEDEF (type);
+
-+ TYPE_RANGE_DATA (range_type)->high.kind
-+ = RANGE_BOUND_KIND_DWARF_BLOCK;
-+ TYPE_RANGE_DATA (range_type)->high.u.dwarf_block = length_baton;
-+ TYPE_DYNAMIC (range_type) = 1;
-+ }
- }
- else
+ switch (TYPE_CODE (type))
{
-- /* check for the DW_AT_byte_size attribute */
-+ if (attr && attr_form_is_constant (attr))
-+ {
-+ /* We currently do not support a constant address where the location
-+ should be read from - attr_form_is_block is expected instead. See
-+ DWARF for the DW_AT_STRING_LENGTH vs. DW_AT_BYTE_SIZE difference.
-+ */
-+ /* PASSTHRU */
-+ }
-+
- attr = dwarf2_attr (die, DW_AT_byte_size, cu);
-- if (attr)
-- {
-- length = DW_UNSND (attr);
-- }
-+ if (attr && attr_form_is_block (attr))
-+ {
-+ TYPE_RANGE_DATA (range_type)->high.kind
-+ = RANGE_BOUND_KIND_DWARF_BLOCK;
-+ TYPE_RANGE_DATA (range_type)->high.u.dwarf_block =
-+ dwarf2_attr_to_locexpr_baton (attr, cu);
-+ TYPE_DYNAMIC (range_type) = 1;
-+ }
-+ else if (attr && attr_form_is_constant (attr))
-+ TYPE_HIGH_BOUND (range_type) = dwarf2_get_attr_constant_value (attr, 0);
- else
-- {
-- length = 1;
-- }
-+ TYPE_HIGH_BOUND (range_type) = 1;
- }
-
-- index_type = objfile_type (objfile)->builtin_int;
-- range_type = create_range_type (NULL, index_type, 1, length);
- char_type = language_string_char_type (cu->language_defn, gdbarch);
- type = create_string_type (NULL, char_type, range_type);
+ case TYPE_CODE_ARRAY:
+Index: gdb-7.2.90.20110703/gdb/f-valprint.c
+===================================================================
+--- gdb-7.2.90.20110703.orig/gdb/f-valprint.c 2011-02-07 18:49:32.000000000 +0100
++++ gdb-7.2.90.20110703/gdb/f-valprint.c 2011-07-03 10:33:11.000000000 +0200
+@@ -54,15 +54,17 @@ int f77_array_offset_tbl[MAX_FORTRAN_DIM
+ /* The following macro gives us the size of the nth dimension, Where
+ n is 1 based. */
-@@ -6324,60 +7421,136 @@ read_subrange_type (struct die_info *die, struct dwarf2_cu *cu)
- struct type *base_type;
- struct type *range_type;
- struct attribute *attr;
-- LONGEST low = 0;
-- LONGEST high = -1;
-+ LONGEST low;
- char *name;
- LONGEST negative_mask;
+-#define F77_DIM_SIZE(n) (f77_array_offset_tbl[n][1])
++#define F77_DIM_COUNT(n) (f77_array_offset_tbl[n][1])
- base_type = die_type (die, cu);
-+ /* Preserve BASE_TYPE's original type, just set its LENGTH. */
-+ check_typedef (base_type);
+-/* The following gives us the offset for row n where n is 1-based. */
++/* The following gives us the element size for row n where n is 1-based. */
- /* The die_type call above may have already set the type for this DIE. */
- range_type = get_die_type (die, cu);
- if (range_type)
- return range_type;
+-#define F77_DIM_OFFSET(n) (f77_array_offset_tbl[n][0])
++#define F77_DIM_BYTE_STRIDE(n) (f77_array_offset_tbl[n][0])
-- if (cu->language == language_fortran)
-- {
-- /* FORTRAN implies a lower bound of 1, if not given. */
-- low = 1;
-- }
-+ /* LOW_BOUND and HIGH_BOUND are set for real below. */
-+ range_type = create_range_type (NULL, base_type, 0, -1);
-+
-+ negative_mask =
-+ (LONGEST) -1 << (TYPE_LENGTH (base_type) * TARGET_CHAR_BIT - 1);
+ int
+ f77_get_lowerbound (struct type *type)
+ {
++ f_object_address_data_valid_or_error (type);
+
-+ /* Exclude language_ada from any TYPE_DYNAMIC constructs below. GDB Ada
-+ supports implements the dynamic bounds in a non-DWARF way and the
-+ existing DWARF dynamic bounds are invalid, leading to memory access
-+ errors. */
+ if (TYPE_ARRAY_LOWER_BOUND_IS_UNDEFINED (type))
+ error (_("Lower bound may not be '*' in F77"));
-- /* FIXME: For variable sized arrays either of these could be
-- a variable rather than a constant value. We'll allow it,
-- but we don't know how to handle it. */
- attr = dwarf2_attr (die, DW_AT_lower_bound, cu);
-- if (attr)
-- low = dwarf2_get_attr_constant_value (attr, 0);
-+ if (attr && attr_form_is_block (attr) && cu->language != language_ada)
-+ {
-+ TYPE_RANGE_DATA (range_type)->low.kind = RANGE_BOUND_KIND_DWARF_BLOCK;
-+ TYPE_RANGE_DATA (range_type)->low.u.dwarf_block =
-+ dwarf2_attr_to_locexpr_baton (attr, cu);
-+ TYPE_DYNAMIC (range_type) = 1;
-+ /* For setting a default if DW_AT_UPPER_BOUND would be missing. */
-+ low = 0;
-+ }
-+ else if (attr && is_ref_attr (attr) && cu->language != language_ada)
-+ {
-+ struct die_info *target_die;
-+ struct dwarf2_cu *target_cu = cu;
-+ struct attribute *target_loc_attr;
+@@ -72,14 +74,17 @@ f77_get_lowerbound (struct type *type)
+ int
+ f77_get_upperbound (struct type *type)
+ {
++ f_object_address_data_valid_or_error (type);
+
-+ target_die = follow_die_ref_or_sig (die, attr, &target_cu);
-+ gdb_assert (target_cu->objfile == cu->objfile);
-+ target_loc_attr = dwarf2_attr (target_die, DW_AT_location, target_cu);
+ if (TYPE_ARRAY_UPPER_BOUND_IS_UNDEFINED (type))
+ {
+- /* We have an assumed size array on our hands. Assume that
+- upper_bound == lower_bound so that we show at least 1 element.
+- If the user wants to see more elements, let him manually ask for 'em
+- and we'll subscript the array and show him. */
++ /* We have an assumed size array on our hands. As type_length_get
++ already assumes a length zero of arrays with underfined bounds VALADDR
++ passed to the Fortran functions does not contained the real inferior
++ memory content. User should request printing of specific array
++ elements instead. */
+
+- return f77_get_lowerbound (type);
++ return f77_get_lowerbound (type) - 1;
+ }
+
+ return TYPE_ARRAY_UPPER_BOUND_VALUE (type);
+@@ -135,24 +140,29 @@ f77_create_arrayprint_offset_tbl (struct
+ upper = f77_get_upperbound (tmp_type);
+ lower = f77_get_lowerbound (tmp_type);
+
+- F77_DIM_SIZE (ndimen) = upper - lower + 1;
++ F77_DIM_COUNT (ndimen) = upper - lower + 1;
+
-+ TYPE_RANGE_DATA (range_type)->low.kind = RANGE_BOUND_KIND_DWARF_LOCLIST;
-+ TYPE_RANGE_DATA (range_type)->low.u.dwarf_loclist.loclist
-+ = dwarf2_attr_to_loclist_baton (target_loc_attr, target_cu);
-+ TYPE_RANGE_DATA (range_type)->low.u.dwarf_loclist.type
-+ = die_type (target_die, target_cu);
-+ TYPE_DYNAMIC (range_type) = 1;
-+ /* For setting a default if DW_AT_UPPER_BOUND would be missing. */
-+ low = 0;
-+ }
-+ else
-+ {
-+ if (attr && attr_form_is_constant (attr))
-+ low = dwarf2_get_attr_constant_value (attr, 0);
-+ else
-+ {
-+ if (cu->language == language_fortran)
-+ {
-+ /* FORTRAN implies a lower bound of 1, if not given. */
-+ low = 1;
-+ }
-+ else
-+ {
-+ /* According to DWARF we should assume the value 0 only for
-+ LANGUAGE_C and LANGUAGE_CPLUS. */
-+ low = 0;
-+ }
-+ }
-+ if (!TYPE_UNSIGNED (base_type) && (low & negative_mask))
-+ low |= negative_mask;
-+ TYPE_LOW_BOUND (range_type) = low;
-+ if (low >= 0)
-+ TYPE_UNSIGNED (range_type) = 1;
-+ }
++ F77_DIM_BYTE_STRIDE (ndimen) =
++ TYPE_ARRAY_BYTE_STRIDE_VALUE (tmp_type);
- attr = dwarf2_attr (die, DW_AT_upper_bound, cu);
-- if (attr)
-+ if (!attr || (!attr_form_is_block (attr) && !attr_form_is_constant (attr)
-+ && !is_ref_attr (attr)))
+ tmp_type = TYPE_TARGET_TYPE (tmp_type);
+ ndimen++;
+ }
+
+- /* Now we multiply eltlen by all the offsets, so that later we
++ /* Now we multiply eltlen by all the BYTE_STRIDEs, so that later we
+ can print out array elements correctly. Up till now we
+- know an offset to apply to get the item but we also
++ know an eltlen to apply to get the item but we also
+ have to know how much to add to get to the next item. */
+
+ ndimen--;
+ eltlen = TYPE_LENGTH (tmp_type);
+- F77_DIM_OFFSET (ndimen) = eltlen;
++ if (F77_DIM_BYTE_STRIDE (ndimen) == 0)
++ F77_DIM_BYTE_STRIDE (ndimen) = eltlen;
+ while (--ndimen > 0)
{
-- if (attr->form == DW_FORM_block1 || is_ref_attr (attr))
-- {
-- /* GCC encodes arrays with unspecified or dynamic length
-- with a DW_FORM_block1 attribute or a reference attribute.
-- FIXME: GDB does not yet know how to handle dynamic
-- arrays properly, treat them as arrays with unspecified
-- length for now.
--
-- FIXME: jimb/2003-09-22: GDB does not really know
-- how to handle arrays of unspecified length
-- either; we just represent them as zero-length
-- arrays. Choose an appropriate upper bound given
-- the lower bound we've computed above. */
-- high = low - 1;
-- }
-- else
-- high = dwarf2_get_attr_constant_value (attr, 1);
-+ attr = dwarf2_attr (die, DW_AT_count, cu);
-+ /* It does not hurt but it is needlessly ineffective in check_typedef. */
-+ if (attr && (attr_form_is_block (attr) || attr_form_is_constant (attr)))
-+ {
-+ TYPE_RANGE_HIGH_BOUND_IS_COUNT (range_type) = 1;
-+ TYPE_DYNAMIC (range_type) = 1;
-+ }
-+ /* Pass it now as the regular DW_AT_upper_bound. */
-+ }
-+
-+ if (attr && attr_form_is_block (attr) && cu->language != language_ada)
-+ {
-+ TYPE_RANGE_DATA (range_type)->high.kind = RANGE_BOUND_KIND_DWARF_BLOCK;
-+ TYPE_RANGE_DATA (range_type)->high.u.dwarf_block =
-+ dwarf2_attr_to_locexpr_baton (attr, cu);
-+ TYPE_DYNAMIC (range_type) = 1;
-+ }
-+ else if (attr && is_ref_attr (attr) && cu->language != language_ada)
-+ {
-+ struct die_info *target_die;
-+ struct dwarf2_cu *target_cu = cu;
-+ struct attribute *target_loc_attr;
-+
-+ target_die = follow_die_ref_or_sig (die, attr, &target_cu);
-+ gdb_assert (target_cu->objfile == cu->objfile);
-+ target_loc_attr = dwarf2_attr (target_die, DW_AT_location, target_cu);
-+
-+ TYPE_RANGE_DATA (range_type)->high.kind = RANGE_BOUND_KIND_DWARF_LOCLIST;
-+ TYPE_RANGE_DATA (range_type)->high.u.dwarf_loclist.loclist
-+ = dwarf2_attr_to_loclist_baton (target_loc_attr, target_cu);
-+ TYPE_RANGE_DATA (range_type)->high.u.dwarf_loclist.type
-+ = die_type (target_die, target_cu);
-+ TYPE_DYNAMIC (range_type) = 1;
+- eltlen *= F77_DIM_SIZE (ndimen + 1);
+- F77_DIM_OFFSET (ndimen) = eltlen;
++ eltlen *= F77_DIM_COUNT (ndimen + 1);
++ if (F77_DIM_BYTE_STRIDE (ndimen) == 0)
++ F77_DIM_BYTE_STRIDE (ndimen) = eltlen;
}
- else
+ }
+
+@@ -174,37 +184,35 @@ f77_print_array_1 (int nss, int ndimensi
+
+ if (nss != ndimensions)
{
-- attr = dwarf2_attr (die, DW_AT_count, cu);
-- if (attr)
-+ LONGEST high;
-+
-+ if (attr && attr_form_is_constant (attr))
-+ high = dwarf2_get_attr_constant_value (attr, 0);
-+ else
+- 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++)
{
-- int count = dwarf2_get_attr_constant_value (attr, 1);
-- high = low + count - 1;
-+ TYPE_HIGH_BOUND_UNDEFINED (range_type) = 1;
-+ high = low - 1;
+ fprintf_filtered (stream, "( ");
+ f77_print_array_1 (nss + 1, ndimensions, TYPE_TARGET_TYPE (type),
+ valaddr,
+- embedded_offset + i * F77_DIM_OFFSET (nss),
++ embedded_offset + i * F77_DIM_BYTE_STRIDE (nss),
+ address,
+ stream, recurse, val, options, elts);
+ fprintf_filtered (stream, ") ");
}
-+ if (!TYPE_UNSIGNED (base_type) && (high & negative_mask))
-+ high |= negative_mask;
-+ TYPE_HIGH_BOUND (range_type) = high;
+- if (*elts >= options->print_max && i < F77_DIM_SIZE (nss))
++ if (*elts >= options->print_max && i < F77_DIM_COUNT (nss))
+ fprintf_filtered (stream, "...");
}
+ else
+ {
+- for (i = 0; i < F77_DIM_SIZE (nss) && (*elts) < options->print_max;
++ for (i = 0; i < F77_DIM_COUNT (nss) && (*elts) < options->print_max;
+ i++, (*elts)++)
+ {
+ val_print (TYPE_TARGET_TYPE (type),
+ valaddr,
+- embedded_offset + i * F77_DIM_OFFSET (ndimensions),
++ embedded_offset + i * F77_DIM_BYTE_STRIDE (ndimensions),
+ address, stream, recurse,
+ val, options, current_language);
- /* Dwarf-2 specifications explicitly allows to create subrange types
-@@ -6419,20 +7592,41 @@ read_subrange_type (struct die_info *die, struct dwarf2_cu *cu)
+- if (i != (F77_DIM_SIZE (nss) - 1))
++ if (i != (F77_DIM_COUNT (nss) - 1))
+ fprintf_filtered (stream, ", ");
+
+ if ((*elts == options->print_max - 1)
+- && (i != (F77_DIM_SIZE (nss) - 1)))
++ && (i != (F77_DIM_COUNT (nss) - 1)))
+ fprintf_filtered (stream, "...");
}
}
+@@ -260,6 +268,9 @@ f_val_print (struct type *type, const gd
+ CORE_ADDR addr;
+ int index;
-- negative_mask =
-- (LONGEST) -1 << (TYPE_LENGTH (base_type) * TARGET_CHAR_BIT - 1);
-- if (!TYPE_UNSIGNED (base_type) && (low & negative_mask))
-- low |= negative_mask;
-- if (!TYPE_UNSIGNED (base_type) && (high & negative_mask))
-- high |= negative_mask;
-+ /* DW_AT_bit_stride is currently unsupported as we count in bytes. */
-+ attr = dwarf2_attr (die, DW_AT_byte_stride, cu);
-+ if (attr && attr_form_is_block (attr) && cu->language != language_ada)
-+ {
-+ TYPE_RANGE_DATA (range_type)->byte_stride.kind
-+ = RANGE_BOUND_KIND_DWARF_BLOCK;
-+ TYPE_RANGE_DATA (range_type)->byte_stride.u.dwarf_block =
-+ dwarf2_attr_to_locexpr_baton (attr, cu);
-+ TYPE_DYNAMIC (range_type) = 1;
-+ }
-+ else if (attr && is_ref_attr (attr) && cu->language != language_ada)
-+ {
-+ struct die_info *target_die;
-+ struct dwarf2_cu *target_cu = cu;
-+ struct attribute *target_loc_attr;
++ if (f_object_address_data_valid_print_to_stream (type, stream) != NULL)
++ return 0;
++
+ CHECK_TYPEDEF (type);
+ switch (TYPE_CODE (type))
+ {
+Index: gdb-7.2.90.20110703/gdb/findvar.c
+===================================================================
+--- gdb-7.2.90.20110703.orig/gdb/findvar.c 2011-03-18 19:42:41.000000000 +0100
++++ gdb-7.2.90.20110703/gdb/findvar.c 2011-07-03 10:33:11.000000000 +0200
+@@ -35,6 +35,7 @@
+ #include "user-regs.h"
+ #include "block.h"
+ #include "objfiles.h"
++#include "dwarf2loc.h"
-- range_type = create_range_type (NULL, base_type, low, high);
-+ target_die = follow_die_ref_or_sig (die, attr, &target_cu);
-+ gdb_assert (target_cu->objfile == cu->objfile);
-+ target_loc_attr = dwarf2_attr (target_die, DW_AT_location, target_cu);
+ /* Basic byte-swapping routines. All 'extract' functions return a
+ host-format integer from a target-format integer at ADDR which is
+@@ -408,8 +409,11 @@ symbol_read_needs_frame (struct symbol *
-- /* Mark arrays with dynamic length at least as an array of unspecified
-- length. GDB could check the boundary but before it gets implemented at
-- least allow accessing the array elements. */
-- if (attr && attr->form == DW_FORM_block1)
-- TYPE_HIGH_BOUND_UNDEFINED (range_type) = 1;
-+ TYPE_RANGE_DATA (range_type)->byte_stride.kind
-+ = RANGE_BOUND_KIND_DWARF_LOCLIST;
-+ TYPE_RANGE_DATA (range_type)->byte_stride.u.dwarf_loclist.loclist
-+ = dwarf2_attr_to_loclist_baton (target_loc_attr, target_cu);
-+ TYPE_RANGE_DATA (range_type)->byte_stride.u.dwarf_loclist.type
-+ = die_type (target_die, target_cu);
-+ TYPE_DYNAMIC (range_type) = 1;
-+ }
-+ else if (attr && attr_form_is_constant (attr))
-+ {
-+ TYPE_BYTE_STRIDE (range_type) = dwarf2_get_attr_constant_value (attr, 0);
-+ if (TYPE_BYTE_STRIDE (range_type) == 0)
-+ complaint (&symfile_complaints,
-+ _("Found DW_AT_byte_stride with unsupported value 0"));
-+ }
+ /* Given a struct symbol for a variable,
+ and a stack frame id, read the value of the variable
+- and return a (pointer to a) struct value containing the value.
+- If the variable cannot be found, return a zero pointer. */
++ and return a (pointer to a) struct value containing the value.
++ If the variable cannot be found, return a zero pointer.
++ We have to first find the address of the variable before allocating struct
++ value to return as its size may depend on DW_OP_PUSH_OBJECT_ADDRESS possibly
++ used by its type. */
- name = dwarf2_name (die, cu);
- if (name)
-@@ -8712,10 +9906,12 @@ var_decode_location (struct attribute *attr, struct symbol *sym,
- (i.e. when the value of a register or memory location is
- referenced, or a thread-local block, etc.). Then again, it might
- not be worthwhile. I'm assuming that it isn't unless performance
-- or memory numbers show me otherwise. */
-+ or memory numbers show me otherwise.
-+
-+ SYMBOL_CLASS may get overriden by dwarf2_symbol_mark_computed. */
+ struct value *
+ read_var_value (struct symbol *var, struct frame_info *frame)
+@@ -417,16 +421,6 @@ read_var_value (struct symbol *var, stru
+ struct value *v;
+ struct type *type = SYMBOL_TYPE (var);
+ CORE_ADDR addr;
+- int len;
+-
+- /* Call check_typedef on our type to make sure that, if TYPE is
+- a TYPE_CODE_TYPEDEF, its length is set to the length of the target type
+- instead of zero. However, we do not replace the typedef type by the
+- target type, because we want to keep the typedef in order to be able to
+- set the returned value type description correctly. */
+- check_typedef (type);
+-
+- len = TYPE_LENGTH (type);
-- dwarf2_symbol_mark_computed (attr, sym, cu);
- SYMBOL_CLASS (sym) = LOC_COMPUTED;
-+ dwarf2_symbol_mark_computed (attr, sym, cu);
- }
+ if (symbol_read_needs_frame (var))
+ gdb_assert (frame);
+@@ -436,7 +430,7 @@ read_var_value (struct symbol *var, stru
+ case LOC_CONST:
+ /* Put the constant back in target format. */
+ v = allocate_value (type);
+- store_signed_integer (value_contents_raw (v), len,
++ store_signed_integer (value_contents_raw (v), TYPE_LENGTH (type),
+ gdbarch_byte_order (get_type_arch (type)),
+ (LONGEST) SYMBOL_VALUE (var));
+ VALUE_LVAL (v) = not_lval;
+@@ -461,12 +455,12 @@ read_var_value (struct symbol *var, stru
- /* Given a pointer to a DWARF information entry, figure out if we need
-@@ -8746,6 +9942,8 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu)
- sizeof (struct symbol));
- OBJSTAT (objfile, n_syms++);
- memset (sym, 0, sizeof (struct symbol));
-+ /* Some methods are called w/o checking SYMBOL_COMPUTED_OPS validity. */
-+ SYMBOL_COMPUTED_OPS (sym) = &dwarf2_missing_funcs;
+ case LOC_CONST_BYTES:
+ v = allocate_value (type);
+- memcpy (value_contents_raw (v), SYMBOL_VALUE_BYTES (var), len);
++ memcpy (value_contents_raw (v), SYMBOL_VALUE_BYTES (var),
++ TYPE_LENGTH (type));
+ VALUE_LVAL (v) = not_lval;
+ return v;
- /* Cache this symbol's name and the name's demangled form (if any). */
- SYMBOL_LANGUAGE (sym) = cu->language;
-@@ -9375,6 +10573,9 @@ read_type_die (struct die_info *die, struct dwarf2_cu *cu)
+ case LOC_STATIC:
+- v = allocate_value_lazy (type);
+ if (overlay_debugging)
+ addr = symbol_overlayed_address (SYMBOL_VALUE_ADDRESS (var),
+ SYMBOL_OBJ_SECTION (var));
+@@ -479,7 +473,6 @@ read_var_value (struct symbol *var, stru
+ if (!addr)
+ return 0;
+ addr += SYMBOL_VALUE (var);
+- v = allocate_value_lazy (type);
+ break;
+
+ case LOC_REF_ARG:
+@@ -493,14 +486,12 @@ read_var_value (struct symbol *var, stru
+ argref += SYMBOL_VALUE (var);
+ ref = value_at (lookup_pointer_type (type), argref);
+ addr = value_as_address (ref);
+- v = allocate_value_lazy (type);
+ break;
+ }
+
+ case LOC_LOCAL:
+ addr = get_frame_locals_address (frame);
+ addr += SYMBOL_VALUE (var);
+- v = allocate_value_lazy (type);
+ break;
+
+ case LOC_TYPEDEF:
+@@ -508,7 +499,6 @@ read_var_value (struct symbol *var, stru
+ break;
+
+ case LOC_BLOCK:
+- v = allocate_value_lazy (type);
+ if (overlay_debugging)
+ addr = symbol_overlayed_address
+ (BLOCK_START (SYMBOL_BLOCK_VALUE (var)), SYMBOL_OBJ_SECTION (var));
+@@ -533,7 +523,6 @@ read_var_value (struct symbol *var, stru
+ error (_("Value of register variable not available."));
+
+ addr = value_as_address (regval);
+- v = allocate_value_lazy (type);
+ }
+ else
+ {
+@@ -572,7 +561,6 @@ read_var_value (struct symbol *var, stru
+ if (obj_section
+ && (obj_section->the_bfd_section->flags & SEC_THREAD_LOCAL) != 0)
+ addr = target_translate_tls_address (obj_section->objfile, addr);
+- v = allocate_value_lazy (type);
+ }
+ break;
+
+@@ -587,6 +575,10 @@ read_var_value (struct symbol *var, stru
break;
}
-+ if (this_type)
-+ finalize_type (this_type);
-+
- return this_type;
- }
++ /* ADDR is set here for ALLOCATE_VALUE's CHECK_TYPEDEF for
++ DW_OP_PUSH_OBJECT_ADDRESS. */
++ object_address_set (addr);
++ v = allocate_value_lazy (type);
+ VALUE_LVAL (v) = lval_memory;
+ set_value_address (v, addr);
+ return v;
+@@ -626,11 +618,12 @@ struct value *
+ value_from_register (struct type *type, int regnum, struct frame_info *frame)
+ {
+ struct gdbarch *gdbarch = get_frame_arch (frame);
+- struct type *type1 = check_typedef (type);
+ struct value *v;
+ int optim, unavail, ok;
-@@ -11979,67 +13180,102 @@ attr_form_is_constant (struct attribute *attr)
+- if (gdbarch_convert_register_p (gdbarch, regnum, type1))
++ type = check_typedef (type);
++
++ if (gdbarch_convert_register_p (gdbarch, regnum, type))
+ {
+ /* The ISA/ABI need to something weird when obtaining the
+ specified value from this register. It might need to
+@@ -643,7 +636,7 @@ value_from_register (struct type *type,
+ VALUE_LVAL (v) = lval_register;
+ VALUE_FRAME_ID (v) = get_frame_id (frame);
+ VALUE_REGNUM (v) = regnum;
+- ok = gdbarch_register_to_value (gdbarch, frame, regnum, type1,
++ ok = gdbarch_register_to_value (gdbarch, frame, regnum, type,
+ value_contents_raw (v), &optim,
+ &unavail);
}
- }
+Index: gdb-7.2.90.20110703/gdb/gdbinit.in
+===================================================================
+--- gdb-7.2.90.20110703.orig/gdb/gdbinit.in 2009-10-05 15:46:52.000000000 +0200
++++ gdb-7.2.90.20110703/gdb/gdbinit.in 2011-07-03 10:33:11.000000000 +0200
+@@ -1,5 +1,15 @@
+ echo Setting up the environment for debugging gdb.\n
--static void
--dwarf2_symbol_mark_computed (struct attribute *attr, struct symbol *sym,
-- struct dwarf2_cu *cu)
-+/* Convert DW_BLOCK into struct dwarf2_locexpr_baton. ATTR must be a DW_BLOCK
-+ attribute type. */
++# 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
+
-+static struct dwarf2_locexpr_baton *
-+dwarf2_attr_to_locexpr_baton (struct attribute *attr, struct dwarf2_cu *cu)
- {
-- if (attr_form_is_section_offset (attr)
-- /* ".debug_loc" may not exist at all, or the offset may be outside
-- the section. If so, fall through to the complaint in the
-- other branch. */
-- && DW_UNSND (attr) < dwarf2_per_objfile->loc.size)
-- {
-- struct dwarf2_loclist_baton *baton;
-+ struct dwarf2_locexpr_baton *baton;
+ set complaints 1
-- baton = obstack_alloc (&cu->objfile->objfile_obstack,
-- sizeof (struct dwarf2_loclist_baton));
-- baton->per_cu = cu->per_cu;
-- gdb_assert (baton->per_cu);
-+ gdb_assert (attr_form_is_block (attr));
+ b internal_error
+Index: gdb-7.2.90.20110703/gdb/gdbtypes.c
+===================================================================
+--- gdb-7.2.90.20110703.orig/gdb/gdbtypes.c 2011-03-28 22:21:03.000000000 +0200
++++ gdb-7.2.90.20110703/gdb/gdbtypes.c 2011-07-03 10:33:11.000000000 +0200
+@@ -39,6 +39,9 @@
+ #include "cp-abi.h"
+ #include "gdb_assert.h"
+ #include "hashtab.h"
++#include "observer.h"
++#include "dwarf2expr.h"
++#include "dwarf2loc.h"
-- dwarf2_read_section (dwarf2_per_objfile->objfile,
-- &dwarf2_per_objfile->loc);
-+ baton = obstack_alloc (&cu->objfile->objfile_obstack, sizeof (*baton));
-+ baton->per_cu = cu->per_cu;
-+ gdb_assert (baton->per_cu);
-- /* We don't know how long the location list is, but make sure we
-- don't run off the edge of the section. */
-- baton->size = dwarf2_per_objfile->loc.size - DW_UNSND (attr);
-- baton->data = dwarf2_per_objfile->loc.buffer + DW_UNSND (attr);
-- baton->base_address = cu->base_address;
-- if (cu->base_known == 0)
-- complaint (&symfile_complaints,
-- _("Location list used without specifying the CU base address."));
-+ /* Note that we're just copying the block's data pointer
-+ here, not the actual data. We're still pointing into the
-+ info_buffer for SYM's objfile; right now we never release
-+ that buffer, but when we do clean up properly this may
-+ need to change. */
-+ baton->size = DW_BLOCK (attr)->size;
-+ baton->data = DW_BLOCK (attr)->data;
-+ gdb_assert (baton->size == 0 || baton->data != NULL);
+ /* Initialize BADNESS constants. */
+@@ -144,7 +147,16 @@ static void print_bit_vector (B_TYPE *,
+ static void print_arg_types (struct field *, int, int);
+ static void dump_fn_fieldlists (struct type *, int);
+ static void print_cplus_stuff (struct type *, int);
++static LONGEST type_length_get (struct type *type, struct type *target_type,
++ int full_span);
+
++#if 0
++/* The hash table holding all discardable `struct type *' references. */
++static htab_t type_discardable_table;
+
-+ return baton;
-+}
++/* Current type_discardable_check pass used for TYPE_DISCARDABLE_AGE. */
++static int type_discardable_age_current;
++#endif
+
+ /* Allocate a new OBJFILE-associated type structure and fill it
+ with some defaults. Space for the type structure is allocated
+@@ -175,6 +187,43 @@ alloc_type (struct objfile *objfile)
+ return type;
+ }
+
++#if 0
++/* Declare TYPE as discardable on next garbage collection by free_all_types.
++ You must call type_mark_used during each free_all_types to protect TYPE from
++ being deallocated. */
+
-+static struct dwarf2_loclist_baton *
-+dwarf2_attr_to_loclist_baton (struct attribute *attr, struct dwarf2_cu *cu)
++static void
++set_type_as_discardable (struct type *type)
+{
-+ struct dwarf2_loclist_baton *baton;
++ void **slot;
+
-+ /* DW_AT_location of the referenced DIE may be missing if the referenced
-+ variable has been optimized out. */
-+ if (!attr)
-+ return NULL;
++ gdb_assert (!TYPE_DISCARDABLE (type));
+
-+ dwarf2_read_section (dwarf2_per_objfile->objfile,
-+ &dwarf2_per_objfile->loc);
++ TYPE_DISCARDABLE (type) = 1;
++ TYPE_DISCARDABLE_AGE (type) = type_discardable_age_current;
+
-+ if (!(attr_form_is_section_offset (attr)
-+ /* ".debug_loc" may not exist at all, or the offset may be outside
-+ the section. If so, fall through to the complaint in the
-+ other branch. */
-+ && DW_UNSND (attr) < dwarf2_per_objfile->loc.size))
-+ return NULL;
++ slot = htab_find_slot (type_discardable_table, type, INSERT);
++ gdb_assert (!*slot);
++ *slot = type;
++}
++#endif
+
-+ baton = obstack_alloc (&cu->objfile->objfile_obstack,
-+ sizeof (struct dwarf2_loclist_baton));
-+ baton->per_cu = cu->per_cu;
-+ gdb_assert (baton->per_cu);
++/* Allocate a new type like alloc_type but preserve for it the discardability
++ state of PARENT_TYPE. */
+
-+ /* We don't know how long the location list is, but make sure we
-+ don't run off the edge of the section. */
-+ baton->size = dwarf2_per_objfile->loc.size - DW_UNSND (attr);
-+ baton->data = dwarf2_per_objfile->loc.buffer + DW_UNSND (attr);
-+ baton->base_address = cu->base_address;
-+ if (cu->base_known == 0)
-+ complaint (&symfile_complaints,
-+ _("Location list used without specifying the CU base address."));
++static struct type *
++alloc_type_as_parent (struct type *parent_type)
++{
++ struct type *new_type = alloc_type_copy (parent_type);
+
-+ return baton;
-+}
++#if 0
++ if (TYPE_DISCARDABLE (parent_type))
++ set_type_as_discardable (new_type);
++#endif
+
-+/* SYM may get its SYMBOL_CLASS overriden on invalid ATTR content. */
++ return new_type;
++}
+
-+static void
-+dwarf2_symbol_mark_computed (struct attribute *attr, struct symbol *sym,
-+ struct dwarf2_cu *cu)
-+{
-+ struct dwarf2_loclist_baton *loclist_baton;
+ /* Allocate a new GDBARCH-associated type structure and fill it
+ with some defaults. Space for the type structure is allocated
+ on the heap. */
+@@ -300,7 +349,7 @@ make_pointer_type (struct type *type, st
-+ loclist_baton = dwarf2_attr_to_loclist_baton (attr, cu);
-+ if (loclist_baton)
-+ {
- SYMBOL_COMPUTED_OPS (sym) = &dwarf2_loclist_funcs;
-- SYMBOL_LOCATION_BATON (sym) = baton;
-+ SYMBOL_LOCATION_BATON (sym) = loclist_baton;
-+ }
-+ else if (attr_form_is_block (attr))
-+ {
-+ SYMBOL_COMPUTED_OPS (sym) = &dwarf2_locexpr_funcs;
-+ SYMBOL_LOCATION_BATON (sym) = dwarf2_attr_to_locexpr_baton (attr, cu);
- }
- else
+ if (typeptr == 0 || *typeptr == 0) /* We'll need to allocate one. */
{
-- struct dwarf2_locexpr_baton *baton;
-+ dwarf2_invalid_attrib_class_complaint ("location description",
-+ SYMBOL_NATURAL_NAME (sym));
+- ntype = alloc_type_copy (type);
++ ntype = alloc_type_as_parent (type);
+ if (typeptr)
+ *typeptr = ntype;
+ }
+@@ -377,7 +426,7 @@ make_reference_type (struct type *type,
-- baton = obstack_alloc (&cu->objfile->objfile_obstack,
-- sizeof (struct dwarf2_locexpr_baton));
-- baton->per_cu = cu->per_cu;
-- gdb_assert (baton->per_cu);
-+ /* Some methods are called w/o checking SYMBOL_COMPUTED_OPS validity. */
-
-- if (attr_form_is_block (attr))
-- {
-- /* Note that we're just copying the block's data pointer
-- here, not the actual data. We're still pointing into the
-- info_buffer for SYM's objfile; right now we never release
-- that buffer, but when we do clean up properly this may
-- need to change. */
-- baton->size = DW_BLOCK (attr)->size;
-- baton->data = DW_BLOCK (attr)->data;
-- }
-- else
-- {
-- dwarf2_invalid_attrib_class_complaint ("location description",
-- SYMBOL_NATURAL_NAME (sym));
-- baton->size = 0;
-- baton->data = NULL;
-- }
-+ SYMBOL_COMPUTED_OPS (sym) = &dwarf2_missing_funcs;
-+ SYMBOL_LOCATION_BATON (sym) = NULL;
-
-- SYMBOL_COMPUTED_OPS (sym) = &dwarf2_locexpr_funcs;
-- SYMBOL_LOCATION_BATON (sym) = baton;
-+ /* For functions a missing DW_AT_frame_base does not optimize out the
-+ whole function definition, only its frame base resolving. */
-+ if (attr->name == DW_AT_location)
-+ SYMBOL_CLASS (sym) = LOC_OPTIMIZED_OUT;
+ if (typeptr == 0 || *typeptr == 0) /* We'll need to allocate one. */
+ {
+- ntype = alloc_type_copy (type);
++ ntype = alloc_type_as_parent (type);
+ if (typeptr)
+ *typeptr = ntype;
}
- }
-
-@@ -12050,7 +13286,7 @@ dwarf2_symbol_mark_computed (struct attribute *attr, struct symbol *sym,
- struct objfile *
- dwarf2_per_cu_objfile (struct dwarf2_per_cu_data *per_cu)
- {
-- struct objfile *objfile = per_cu->psymtab->objfile;
-+ struct objfile *objfile = per_cu->objfile;
+@@ -748,6 +797,7 @@ create_range_type (struct type *result_t
+ TYPE_ZALLOC (result_type, sizeof (struct range_bounds));
+ TYPE_LOW_BOUND (result_type) = low_bound;
+ TYPE_HIGH_BOUND (result_type) = high_bound;
++ TYPE_BYTE_STRIDE (result_type) = 0;
- /* Return the master objfile, so that we can report and look up the
- correct file containing this variable. */
-@@ -12070,7 +13306,7 @@ dwarf2_per_cu_addr_size (struct dwarf2_per_cu_data *per_cu)
- else
- {
- /* If the CU is not currently read in, we re-read its header. */
-- struct objfile *objfile = per_cu->psymtab->objfile;
-+ struct objfile *objfile = per_cu->objfile;
- struct dwarf2_per_objfile *per_objfile
- = objfile_data (objfile, dwarf2_objfile_data_key);
- gdb_byte *info_ptr = per_objfile->info.buffer + per_cu->offset;
-@@ -12092,7 +13328,7 @@ dwarf2_per_cu_offset_size (struct dwarf2_per_cu_data *per_cu)
- else
- {
- /* If the CU is not currently read in, we re-read its header. */
-- struct objfile *objfile = per_cu->psymtab->objfile;
-+ struct objfile *objfile = per_cu->objfile;
- struct dwarf2_per_objfile *per_objfile
- = objfile_data (objfile, dwarf2_objfile_data_key);
- gdb_byte *info_ptr = per_objfile->info.buffer + per_cu->offset;
-@@ -12112,7 +13348,7 @@ dwarf2_per_cu_offset_size (struct dwarf2_per_cu_data *per_cu)
- CORE_ADDR
- dwarf2_per_cu_text_offset (struct dwarf2_per_cu_data *per_cu)
- {
-- struct objfile *objfile = per_cu->psymtab->objfile;
-+ struct objfile *objfile = per_cu->objfile;
+ if (low_bound >= 0)
+ TYPE_UNSIGNED (result_type) = 1;
+@@ -891,26 +941,31 @@ create_array_type (struct type *result_t
- return ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
- }
-@@ -12334,6 +13570,30 @@ dwarf2_free_objfile (struct objfile *objfile)
- /* Cached DIE trees use xmalloc and the comp_unit_obstack. */
- free_cached_comp_units (NULL);
+ TYPE_CODE (result_type) = TYPE_CODE_ARRAY;
+ TYPE_TARGET_TYPE (result_type) = element_type;
+- if (get_discrete_bounds (range_type, &low_bound, &high_bound) < 0)
+- low_bound = high_bound = 0;
+- CHECK_TYPEDEF (element_type);
+- /* Be careful when setting the array length. Ada arrays can be
+- empty arrays with the high_bound being smaller than the low_bound.
+- In such cases, the array length should be zero. */
+- if (high_bound < low_bound)
+- TYPE_LENGTH (result_type) = 0;
+- else
+- TYPE_LENGTH (result_type) =
+- TYPE_LENGTH (element_type) * (high_bound - low_bound + 1);
+ TYPE_NFIELDS (result_type) = 1;
+ TYPE_FIELDS (result_type) =
+ (struct field *) TYPE_ZALLOC (result_type, sizeof (struct field));
+ TYPE_INDEX_TYPE (result_type) = range_type;
+ TYPE_VPTR_FIELDNO (result_type) = -1;
-+ if (dwarf2_per_objfile->using_index)
+- /* TYPE_FLAG_TARGET_STUB will take care of zero length arrays. */
++ /* DWARF blocks may depend on runtime information like
++ DW_OP_PUSH_OBJECT_ADDRESS not being available during the
++ CREATE_ARRAY_TYPE time. */
++ if (TYPE_RANGE_DATA (range_type)->low.kind != RANGE_BOUND_KIND_CONSTANT
++ || TYPE_RANGE_DATA (range_type)->high.kind != RANGE_BOUND_KIND_CONSTANT
++ || TYPE_DYNAMIC (element_type))
++ TYPE_LENGTH (result_type) = 0;
++ else
+ {
-+ int i;
-+
-+ for (i = 0; i < dwarf2_per_objfile->n_comp_units; ++i)
-+ {
-+ int j;
-+ struct dwarf2_per_cu_data *cu = dwarf2_per_objfile->all_comp_units[i];
-+
-+ if (!cu->v.quick->lines)
-+ continue;
-+
-+ for (j = 0; j < cu->v.quick->lines->num_file_names; ++j)
-+ {
-+ if (cu->v.quick->file_names)
-+ xfree ((void *) cu->v.quick->file_names[j]);
-+ if (cu->v.quick->full_names)
-+ xfree ((void *) cu->v.quick->full_names[j]);
-+ }
-+
-+ free_line_header (cu->v.quick->lines);
-+ }
++ CHECK_TYPEDEF (element_type);
++ TYPE_LENGTH (result_type) = type_length_get (result_type, element_type,
++ 0);
++ }
+ if (TYPE_LENGTH (result_type) == 0)
+- TYPE_TARGET_STUB (result_type) = 1;
++ {
++ /* The real size will be computed for specific instances by
++ CHECK_TYPEDEF. */
++ TYPE_TARGET_STUB (result_type) = 1;
+ }
-+
- /* Everything else should be on the objfile obstack. */
- }
-@@ -12368,6 +13628,31 @@ offset_and_type_eq (const void *item_lhs, const void *item_rhs)
- return ofs_lhs->offset == ofs_rhs->offset;
+ return result_type;
+ }
+@@ -1413,6 +1468,105 @@ stub_noname_complaint (void)
+ complaint (&symfile_complaints, _("stub type has NULL name"));
}
-+/* Fill in generic attributes applicable for type DIEs. */
-+
-+static void
-+fetch_die_type_attrs (struct die_info *die, struct type *type,
-+ struct dwarf2_cu *cu)
-+{
-+ struct attribute *attr;
-+
-+ attr = dwarf2_attr (die, DW_AT_data_location, cu);
-+ if (attr_form_is_block (attr))
-+ TYPE_DATA_LOCATION_DWARF_BLOCK (type) = dwarf2_attr_to_locexpr_baton (attr,
-+ cu);
-+ gdb_assert (!TYPE_DATA_LOCATION_IS_ADDR (type));
-+
-+ attr = dwarf2_attr (die, DW_AT_allocated, cu);
-+ if (attr_form_is_block (attr))
-+ TYPE_ALLOCATED (type) = dwarf2_attr_to_locexpr_baton (attr, cu);
-+ gdb_assert (!TYPE_NOT_ALLOCATED (type));
-+
-+ attr = dwarf2_attr (die, DW_AT_associated, cu);
-+ if (attr_form_is_block (attr))
-+ TYPE_ASSOCIATED (type) = dwarf2_attr_to_locexpr_baton (attr, cu);
-+ gdb_assert (!TYPE_NOT_ASSOCIATED (type));
-+}
-+
- /* Set the type associated with DIE to TYPE. Save it in CU's hash
- table if necessary. For convenience, return TYPE.
-
-@@ -12391,6 +13676,8 @@ set_die_type (struct die_info *die, struct type *type, struct dwarf2_cu *cu)
- {
- struct dwarf2_offset_and_type **slot, ofs;
-
-+ fetch_die_type_attrs (die, type, cu);
-+
- /* For Ada types, make sure that the gnat-specific data is always
- initialized (if not already set). There are a few types where
- we should not be doing so, because the type-specific area is
-@@ -12591,8 +13878,567 @@ dwarf2_per_objfile_free (struct objfile *objfile, void *d)
- munmap_section_buffer (&data->types);
- munmap_section_buffer (&data->frame);
- munmap_section_buffer (&data->eh_frame);
-+ munmap_section_buffer (&data->gdb_index);
-+}
++/* Calculate the memory length of array TYPE.
+
-+\f
++ TARGET_TYPE should be set to `check_typedef (TYPE_TARGET_TYPE (type))' as
++ a performance hint. Feel free to pass NULL. Set FULL_SPAN to return the
++ size incl. the possible padding of the last element - it may differ from the
++ cleared FULL_SPAN return value (the expected SIZEOF) for non-zero
++ TYPE_BYTE_STRIDE values. */
+
-+/* The contents of the hash table we create when building the string
-+ table. */
-+struct strtab_entry
++static LONGEST
++type_length_get (struct type *type, struct type *target_type, int full_span)
+{
-+ offset_type offset;
-+ const char *str;
-+};
++ struct type *range_type;
++ LONGEST byte_stride = 0; /* `= 0' for a false GCC warning. */
++ LONGEST count, element_size, retval;
+
-+/* Hash function for a strtab_entry. */
-+static hashval_t
-+hash_strtab_entry (const void *e)
-+{
-+ const struct strtab_entry *entry = e;
-+ return mapped_index_string_hash (entry->str);
-+}
++ if (TYPE_CODE (type) != TYPE_CODE_ARRAY
++ && TYPE_CODE (type) != TYPE_CODE_STRING)
++ return TYPE_LENGTH (type);
+
-+/* Equality function for a strtab_entry. */
-+static int
-+eq_strtab_entry (const void *a, const void *b)
-+{
-+ const struct strtab_entry *ea = a;
-+ const struct strtab_entry *eb = b;
-+ return !strcmp (ea->str, eb->str);
-+}
++ /* Avoid executing TYPE_HIGH_BOUND for invalid (unallocated/unassociated)
++ Fortran arrays. The allocated data will never be used so they can be
++ zero-length. */
++ if (object_address_data_not_valid (type))
++ return 0;
+
-+/* Create a strtab_entry hash table. */
-+static htab_t
-+create_strtab (void)
-+{
-+ return htab_create_alloc (100, hash_strtab_entry, eq_strtab_entry,
-+ xfree, xcalloc, xfree);
-+}
++ range_type = TYPE_INDEX_TYPE (type);
++ if (TYPE_LOW_BOUND_UNDEFINED (range_type)
++ || TYPE_HIGH_BOUND_UNDEFINED (range_type))
++ return 0;
++ count = TYPE_HIGH_BOUND (range_type) - TYPE_LOW_BOUND (range_type) + 1;
++ /* It may happen for wrong DWARF annotations returning garbage data. */
++ if (count < 0)
++ warning (_("Range for type %s has invalid bounds %s..%s"),
++ TYPE_NAME (type), plongest (TYPE_LOW_BOUND (range_type)),
++ plongest (TYPE_HIGH_BOUND (range_type)));
++ /* The code below does not handle count == 0 right. */
++ if (count <= 0)
++ return 0;
++ if (full_span || count > 1)
++ {
++ /* We do not use TYPE_ARRAY_BYTE_STRIDE_VALUE (type) here as we want to
++ force FULL_SPAN to 1. */
++ byte_stride = TYPE_BYTE_STRIDE (range_type);
++ if (byte_stride == 0)
++ {
++ if (target_type == NULL)
++ target_type = check_typedef (TYPE_TARGET_TYPE (type));
++ byte_stride = type_length_get (target_type, NULL, 1);
++ }
++ }
+
-+/* Add a string to the constant pool. Return the string's offset in
-+ host order. */
-+static offset_type
-+add_string (htab_t table, struct obstack *cpool, const char *str)
-+{
-+ void **slot;
-+ struct strtab_entry entry;
-+ struct strtab_entry *result;
++ /* For now, we conservatively take the array length to be 0 if its length
++ exceeds UINT_MAX. The code below assumes that for x < 0,
++ (ULONGEST) x == -x + ULONGEST_MAX + 1, which is technically not guaranteed
++ by C, but is usually true (because it would be true if x were unsigned
++ with its high-order bit on). It uses the fact that high_bound-low_bound is
++ always representable in ULONGEST and that if high_bound-low_bound+1
++ overflows, it overflows to 0. We must change these tests if we decide to
++ increase the representation of TYPE_LENGTH from unsigned int to ULONGEST.
++ */
+
-+ entry.str = str;
-+ slot = htab_find_slot (table, &entry, INSERT);
-+ if (*slot)
-+ result = *slot;
-+ else
++ if (full_span)
+ {
-+ result = XNEW (struct strtab_entry);
-+ result->offset = obstack_object_size (cpool);
-+ result->str = str;
-+ obstack_grow_str0 (cpool, str);
-+ *slot = result;
++ retval = count * byte_stride;
++ if (count == 0 || retval / count != byte_stride || retval > UINT_MAX)
++ retval = 0;
++ return retval;
+ }
-+ return result->offset;
++ if (target_type == NULL)
++ target_type = check_typedef (TYPE_TARGET_TYPE (type));
++ element_size = type_length_get (target_type, NULL, 1);
++ retval = (count - 1) * byte_stride + element_size;
++ if (retval < element_size
++ || (byte_stride != 0
++ && (retval - element_size) / byte_stride != count - 1)
++ || retval > UINT_MAX)
++ retval = 0;
++ return retval;
+}
+
-+/* An entry in the symbol table. */
-+struct symtab_index_entry
-+{
-+ /* The name of the symbol. */
-+ const char *name;
-+ /* The offset of the name in the constant pool. */
-+ offset_type index_offset;
-+ /* A sorted vector of the indices of all the CUs that hold an object
-+ of this name. */
-+ VEC (offset_type) *cu_indices;
-+};
-+
-+/* The symbol table. This is a power-of-2-sized hash table. */
-+struct mapped_symtab
-+{
-+ offset_type n_elements;
-+ offset_type size;
-+ struct symtab_index_entry **data;
-+};
++/* Prepare TYPE after being read in by the backend. Currently this function
++ only propagates the TYPE_DYNAMIC flag. */
+
-+/* Hash function for a symtab_index_entry. */
-+static hashval_t
-+hash_symtab_entry (const void *e)
++void
++finalize_type (struct type *type)
+{
-+ const struct symtab_index_entry *entry = e;
-+ return iterative_hash (VEC_address (offset_type, entry->cu_indices),
-+ sizeof (offset_type) * VEC_length (offset_type,
-+ entry->cu_indices),
-+ 0);
-+}
++ int i;
+
-+/* Equality function for a symtab_index_entry. */
-+static int
-+eq_symtab_entry (const void *a, const void *b)
-+{
-+ const struct symtab_index_entry *ea = a;
-+ const struct symtab_index_entry *eb = b;
-+ int len = VEC_length (offset_type, ea->cu_indices);
-+ if (len != VEC_length (offset_type, eb->cu_indices))
-+ return 0;
-+ return !memcmp (VEC_address (offset_type, ea->cu_indices),
-+ VEC_address (offset_type, eb->cu_indices),
-+ sizeof (offset_type) * len);
-+}
++ for (i = 0; i < TYPE_NFIELDS (type); ++i)
++ if (TYPE_FIELD_TYPE (type, i) && TYPE_DYNAMIC (TYPE_FIELD_TYPE (type, i)))
++ break;
+
-+/* Destroy a symtab_index_entry. */
-+static void
-+delete_symtab_entry (void *p)
-+{
-+ struct symtab_index_entry *entry = p;
-+ VEC_free (offset_type, entry->cu_indices);
-+ xfree (entry);
++ /* FIXME: cplus_stuff is ignored here. */
++ if (i < TYPE_NFIELDS (type)
++ || (TYPE_VPTR_BASETYPE (type) && TYPE_DYNAMIC (TYPE_VPTR_BASETYPE (type)))
++ || (TYPE_TARGET_TYPE (type) && TYPE_DYNAMIC (TYPE_TARGET_TYPE (type))))
++ TYPE_DYNAMIC (type) = 1;
+}
+
-+/* Create a hash table holding symtab_index_entry objects. */
-+static htab_t
-+create_index_table (void)
-+{
-+ return htab_create_alloc (100, hash_symtab_entry, eq_symtab_entry,
-+ delete_symtab_entry, xcalloc, xfree);
-+}
+ /* Find the real type of TYPE. This function returns the real type,
+ after removing all layers of typedefs, and completing opaque or stub
+ types. Completion changes the TYPE argument, but stripping of
+@@ -1575,52 +1729,37 @@ check_typedef (struct type *type)
+ }
+ }
+
+- if (TYPE_TARGET_STUB (type))
++ /* copy_type_recursive automatically makes the resulting type containing only
++ constant values expected by the callers of this function. */
++ if (TYPE_DYNAMIC (type))
++ {
++ htab_t copied_types;
+
-+/* Create a new mapped symtab object. */
-+static struct mapped_symtab *
-+create_mapped_symtab (void)
-+{
-+ struct mapped_symtab *symtab = XNEW (struct mapped_symtab);
-+ symtab->n_elements = 0;
-+ symtab->size = 1024;
-+ symtab->data = XCNEWVEC (struct symtab_index_entry *, symtab->size);
-+ return symtab;
-+}
++ copied_types = create_copied_types_hash (NULL);
++ type = copy_type_recursive (type, copied_types);
++ htab_delete (copied_types);
+
-+/* Destroy a mapped_symtab. */
-+static void
-+cleanup_mapped_symtab (void *p)
-+{
-+ struct mapped_symtab *symtab = p;
-+ /* The contents of the array are freed when the other hash table is
-+ destroyed. */
-+ xfree (symtab->data);
-+ xfree (symtab);
-+}
-+
-+/* Find a slot in SYMTAB for the symbol NAME. Returns a pointer to
-+ the slot. */
-+static struct symtab_index_entry **
-+find_slot (struct mapped_symtab *symtab, const char *name)
-+{
-+ offset_type index, step, hash = mapped_index_string_hash (name);
-+
-+ index = hash & (symtab->size - 1);
-+ step = ((hash * 17) & (symtab->size - 1)) | 1;
-+
-+ for (;;)
-+ {
-+ if (!symtab->data[index] || !strcmp (name, symtab->data[index]->name))
-+ return &symtab->data[index];
-+ index = (index + step) & (symtab->size - 1);
++ gdb_assert (TYPE_DYNAMIC (type) == 0);
++ /* Force TYPE_LENGTH (type) recalculation. */
++ TYPE_DYNAMIC (type) = 1;
+ }
++
++ if (TYPE_TARGET_STUB (type) || TYPE_DYNAMIC (type))
+ {
+- struct type *range_type;
+ struct type *target_type = check_typedef (TYPE_TARGET_TYPE (type));
+
++ if (TYPE_DYNAMIC (type))
++ TYPE_TARGET_TYPE (type) = target_type;
+ if (TYPE_STUB (target_type) || TYPE_TARGET_STUB (target_type))
+ {
+ /* Nothing we can do. */
+ }
+ else if (TYPE_CODE (type) == TYPE_CODE_ARRAY
+- && TYPE_NFIELDS (type) == 1
+- && (TYPE_CODE (range_type = TYPE_INDEX_TYPE (type))
+- == TYPE_CODE_RANGE))
++ || TYPE_CODE (type) == TYPE_CODE_STRING)
+ {
+ /* Now recompute the length of the array type, based on its
+- number of elements and the target type's length.
+- Watch out for Ada null Ada arrays where the high bound
+- is smaller than the low bound. */
+- const LONGEST low_bound = TYPE_LOW_BOUND (range_type);
+- const LONGEST high_bound = TYPE_HIGH_BOUND (range_type);
+- ULONGEST len;
+-
+- if (high_bound < low_bound)
+- len = 0;
+- else
+- {
+- /* For now, we conservatively take the array length to be 0
+- if its length exceeds UINT_MAX. The code below assumes
+- that for x < 0, (ULONGEST) x == -x + ULONGEST_MAX + 1,
+- which is technically not guaranteed by C, but is usually true
+- (because it would be true if x were unsigned with its
+- high-order bit on). It uses the fact that
+- high_bound-low_bound is always representable in
+- ULONGEST and that if high_bound-low_bound+1 overflows,
+- it overflows to 0. We must change these tests if we
+- decide to increase the representation of TYPE_LENGTH
+- from unsigned int to ULONGEST. */
+- ULONGEST ulow = low_bound, uhigh = high_bound;
+- ULONGEST tlen = TYPE_LENGTH (target_type);
+-
+- len = tlen * (uhigh - ulow + 1);
+- if (tlen == 0 || (len / tlen - 1 + ulow) != uhigh
+- || len > UINT_MAX)
+- len = 0;
+- }
+- TYPE_LENGTH (type) = len;
++ number of elements and the target type's length. */
++ TYPE_LENGTH (type) = type_length_get (type, target_type, 0);
+ TYPE_TARGET_STUB (type) = 0;
+ }
+ else if (TYPE_CODE (type) == TYPE_CODE_RANGE)
+@@ -1628,6 +1767,7 @@ check_typedef (struct type *type)
+ TYPE_LENGTH (type) = TYPE_LENGTH (target_type);
+ TYPE_TARGET_STUB (type) = 0;
+ }
++ TYPE_DYNAMIC (type) = 0;
+ }
+
+ type = make_qualified_type (type, instance_flags, NULL);
+@@ -3266,33 +3406,42 @@ type_pair_eq (const void *item_lhs, cons
}
-+/* Expand SYMTAB's hash table. */
-+static void
-+hash_expand (struct mapped_symtab *symtab)
-+{
-+ offset_type old_size = symtab->size;
-+ offset_type i;
-+ struct symtab_index_entry **old_entries = symtab->data;
-+
-+ symtab->size *= 2;
-+ symtab->data = XCNEWVEC (struct symtab_index_entry *, symtab->size);
-+
-+ for (i = 0; i < old_size; ++i)
+ /* Allocate the hash table used by copy_type_recursive to walk
+- types without duplicates. We use OBJFILE's obstack, because
+- OBJFILE is about to be deleted. */
++ types without duplicates. */
+
+ htab_t
+ create_copied_types_hash (struct objfile *objfile)
+ {
+- return htab_create_alloc_ex (1, type_pair_hash, type_pair_eq,
+- NULL, &objfile->objfile_obstack,
+- hashtab_obstack_allocate,
+- dummy_obstack_deallocate);
++ if (objfile == NULL)
+ {
-+ if (old_entries[i])
-+ {
-+ struct symtab_index_entry **slot = find_slot (symtab,
-+ old_entries[i]->name);
-+ *slot = old_entries[i];
-+ }
++ /* NULL OBJFILE is for TYPE_DYNAMIC types already contained in
++ OBJFILE_MALLOC memory, such as those from VALUE_HISTORY_CHAIN. Table
++ element entries get allocated by xmalloc - so use xfree. */
++ return htab_create (1, type_pair_hash, type_pair_eq, xfree);
+ }
-+
-+ xfree (old_entries);
-+}
-+
-+/* Add an entry to SYMTAB. NAME is the name of the symbol. CU_INDEX
-+ is the index of the CU in which the symbol appears. */
-+static void
-+add_index_entry (struct mapped_symtab *symtab, const char *name,
-+ offset_type cu_index)
-+{
-+ struct symtab_index_entry **slot;
-+
-+ ++symtab->n_elements;
-+ if (4 * symtab->n_elements / 3 >= symtab->size)
-+ hash_expand (symtab);
-+
-+ slot = find_slot (symtab, name);
-+ if (!*slot)
++ else
+ {
-+ *slot = XNEW (struct symtab_index_entry);
-+ (*slot)->name = name;
-+ (*slot)->cu_indices = NULL;
++ /* Use OBJFILE's obstack, because OBJFILE is about to be deleted. Table
++ element entries get allocated by xmalloc - so use xfree. */
++ return htab_create_alloc_ex (1, type_pair_hash, type_pair_eq,
++ xfree, &objfile->objfile_obstack,
++ hashtab_obstack_allocate,
++ dummy_obstack_deallocate);
+ }
-+ /* Don't push an index twice. Due to how we add entries we only
-+ have to check the last one. */
-+ if (VEC_empty (offset_type, (*slot)->cu_indices)
-+ || VEC_length (offset_type, (*slot)->cu_indices) != cu_index)
-+ VEC_safe_push (offset_type, (*slot)->cu_indices, cu_index);
-+}
+ }
+
+-/* Recursively copy (deep copy) TYPE, if it is associated with
+- OBJFILE. Return a new type allocated using malloc, a saved type if
+- we have already visited TYPE (using COPIED_TYPES), or TYPE if it is
+- not associated with OBJFILE. */
++/* A helper for copy_type_recursive. This does all the work. OBJFILE is used
++ only for an assertion checking. */
+
+-struct type *
+-copy_type_recursive (struct objfile *objfile,
+- struct type *type,
+- htab_t copied_types)
++static struct type *
++copy_type_recursive_1 (struct objfile *objfile,
++ struct type *type,
++ htab_t copied_types)
+ {
+ struct type_pair *stored, pair;
+ void **slot;
+ struct type *new_type;
+
+- if (! TYPE_OBJFILE_OWNED (type))
++ if (! TYPE_OBJFILE_OWNED (type) && !TYPE_DYNAMIC (type))
+ return type;
+
+ /* This type shouldn't be pointing to any types in other objfiles;
+@@ -3307,9 +3456,10 @@ copy_type_recursive (struct objfile *obj
+ 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));
++ 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. */
++ stored = xmalloc (sizeof (*stored));
+ stored->old = type;
+ stored->new = new_type;
+ *slot = stored;
+@@ -3320,6 +3470,21 @@ copy_type_recursive (struct objfile *obj
+ TYPE_OBJFILE_OWNED (new_type) = 0;
+ TYPE_OWNER (new_type).gdbarch = get_type_arch (type);
+
++#if 0
++ /* TYPE_MAIN_TYPE memory copy above rewrote the TYPE_DISCARDABLE flag so we
++ need to initialize it again. And even if TYPE was already discardable
++ NEW_TYPE so far is not registered in TYPE_DISCARDABLE_TABLE. */
++ TYPE_DISCARDABLE (new_type) = 0;
++ set_type_as_discardable (new_type);
++#endif
+
-+/* Add a vector of indices to the constant pool. */
-+static offset_type
-+add_indices_to_cpool (htab_t index_table, struct obstack *cpool,
-+ struct symtab_index_entry *entry)
-+{
-+ void **slot;
++ /* Pre-clear the fields processed by delete_main_type. If DWARF block
++ evaluations below call error we would leave an unfreeable TYPE. */
++ TYPE_TARGET_TYPE (new_type) = NULL;
++ TYPE_VPTR_BASETYPE (new_type) = NULL;
++ TYPE_NFIELDS (new_type) = 0;
++ TYPE_FIELDS (new_type) = NULL;
+
-+ slot = htab_find_slot (index_table, entry, INSERT);
-+ if (!*slot)
+ if (TYPE_NAME (type))
+ TYPE_NAME (new_type) = xstrdup (TYPE_NAME (type));
+ if (TYPE_TAG_NAME (type))
+@@ -3328,12 +3493,48 @@ copy_type_recursive (struct objfile *obj
+ TYPE_INSTANCE_FLAGS (new_type) = TYPE_INSTANCE_FLAGS (type);
+ TYPE_LENGTH (new_type) = TYPE_LENGTH (type);
+
++ if (TYPE_ALLOCATED (new_type))
+ {
-+ offset_type len = VEC_length (offset_type, entry->cu_indices);
-+ offset_type val = MAYBE_SWAP (len);
-+ offset_type iter;
-+ int i;
-+
-+ *slot = entry;
-+ entry->index_offset = obstack_object_size (cpool);
++ gdb_assert (!TYPE_NOT_ALLOCATED (new_type));
+
-+ obstack_grow (cpool, &val, sizeof (val));
-+ for (i = 0;
-+ VEC_iterate (offset_type, entry->cu_indices, i, iter);
-+ ++i)
-+ {
-+ val = MAYBE_SWAP (iter);
-+ obstack_grow (cpool, &val, sizeof (val));
-+ }
-+ }
-+ else
-+ {
-+ struct symtab_index_entry *old_entry = *slot;
-+ entry->index_offset = old_entry->index_offset;
-+ entry = old_entry;
++ if (!dwarf_locexpr_baton_eval (TYPE_ALLOCATED (new_type)))
++ TYPE_NOT_ALLOCATED (new_type) = 1;
++ TYPE_ALLOCATED (new_type) = NULL;
+ }
-+ return entry->index_offset;
-+}
+
-+/* Write the mapped hash table SYMTAB to the obstack OUTPUT, with
-+ constant pool entries going into the obstack CPOOL. */
-+static void
-+write_hash_table (struct mapped_symtab *symtab,
-+ struct obstack *output, struct obstack *cpool)
-+{
-+ offset_type i;
-+ htab_t index_table;
-+ htab_t str_table;
-+
-+ index_table = create_index_table ();
-+ str_table = create_strtab ();
-+ /* We add all the index vectors to the constant pool first, to
-+ ensure alignment is ok. */
-+ for (i = 0; i < symtab->size; ++i)
++ if (TYPE_ASSOCIATED (new_type))
+ {
-+ if (symtab->data[i])
-+ add_indices_to_cpool (index_table, cpool, symtab->data[i]);
++ gdb_assert (!TYPE_NOT_ASSOCIATED (new_type));
++
++ if (!dwarf_locexpr_baton_eval (TYPE_ASSOCIATED (new_type)))
++ TYPE_NOT_ASSOCIATED (new_type) = 1;
++ TYPE_ASSOCIATED (new_type) = NULL;
+ }
+
-+ /* Now write out the hash table. */
-+ for (i = 0; i < symtab->size; ++i)
++ if (!TYPE_DATA_LOCATION_IS_ADDR (new_type)
++ && TYPE_DATA_LOCATION_DWARF_BLOCK (new_type))
+ {
-+ offset_type str_off, vec_off;
-+
-+ if (symtab->data[i])
-+ {
-+ str_off = add_string (str_table, cpool, symtab->data[i]->name);
-+ vec_off = symtab->data[i]->index_offset;
-+ }
++ if (TYPE_NOT_ALLOCATED (new_type)
++ || TYPE_NOT_ASSOCIATED (new_type))
++ TYPE_DATA_LOCATION_DWARF_BLOCK (new_type) = NULL;
+ else
+ {
-+ /* While 0 is a valid constant pool index, it is not valid
-+ to have 0 for both offsets. */
-+ str_off = 0;
-+ vec_off = 0;
++ TYPE_DATA_LOCATION_IS_ADDR (new_type) = 1;
++ TYPE_DATA_LOCATION_ADDR (new_type) = dwarf_locexpr_baton_eval
++ (TYPE_DATA_LOCATION_DWARF_BLOCK (new_type));
+ }
-+
-+ str_off = MAYBE_SWAP (str_off);
-+ vec_off = MAYBE_SWAP (vec_off);
-+
-+ obstack_grow (output, &str_off, sizeof (str_off));
-+ obstack_grow (output, &vec_off, sizeof (vec_off));
-+ }
-+
-+ htab_delete (str_table);
-+ htab_delete (index_table);
-+}
-+
-+/* Write an address entry to ADDR_OBSTACK. The addresses are taken
-+ from PST; CU_INDEX is the index of the CU in the vector of all
-+ CUs. */
-+static void
-+add_address_entry (struct objfile *objfile,
-+ struct obstack *addr_obstack, struct partial_symtab *pst,
-+ unsigned int cu_index)
-+{
-+ offset_type offset;
-+ char addr[8];
-+ CORE_ADDR baseaddr;
-+
-+ baseaddr = ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
-+
-+ store_unsigned_integer (addr, 8, BFD_ENDIAN_LITTLE, pst->textlow - baseaddr);
-+ obstack_grow (addr_obstack, addr, 8);
-+ store_unsigned_integer (addr, 8, BFD_ENDIAN_LITTLE, pst->texthigh - baseaddr);
-+ obstack_grow (addr_obstack, addr, 8);
-+ offset = MAYBE_SWAP (cu_index);
-+ obstack_grow (addr_obstack, &offset, sizeof (offset_type));
-+}
-+
-+/* Add a list of partial symbols to SYMTAB. */
-+static void
-+write_psymbols (struct mapped_symtab *symtab,
-+ struct partial_symbol **psymp,
-+ int count,
-+ offset_type cu_index)
-+{
-+ for (; count-- > 0; ++psymp)
-+ {
-+ if (SYMBOL_LANGUAGE (*psymp) == language_ada)
-+ error (_("Ada is not currently supported by the index"));
-+ add_index_entry (symtab, SYMBOL_NATURAL_NAME (*psymp), cu_index);
+ }
-+}
+
-+/* Write the contents of an ("unfinished") obstack to FILE. Throw an
-+ exception if there is an error. */
-+static void
-+write_obstack (FILE *file, struct obstack *obstack)
-+{
-+ if (fwrite (obstack_base (obstack), 1, obstack_object_size (obstack),
-+ file)
-+ != obstack_object_size (obstack))
-+ error (_("couldn't data write to file"));
-+}
+ /* Copy the fields. */
+ if (TYPE_NFIELDS (type))
+ {
+ int i, nfields;
+
++ /* TYPE_CODE_RANGE uses TYPE_RANGE_DATA of the union with TYPE_FIELDS. */
++ gdb_assert (TYPE_CODE (type) != TYPE_CODE_RANGE);
+
-+/* Unlink a file if the argument is not NULL. */
-+static void
-+unlink_if_set (void *p)
-+{
-+ char **filename = p;
-+ if (*filename)
-+ unlink (*filename);
-+}
+ nfields = TYPE_NFIELDS (type);
++ TYPE_NFIELDS (new_type) = nfields;
+ TYPE_FIELDS (new_type) = XCALLOC (nfields, struct field);
+ for (i = 0; i < nfields; i++)
+ {
+@@ -3342,8 +3543,8 @@ copy_type_recursive (struct objfile *obj
+ TYPE_FIELD_BITSIZE (new_type, i) = TYPE_FIELD_BITSIZE (type, i);
+ if (TYPE_FIELD_TYPE (type, i))
+ TYPE_FIELD_TYPE (new_type, i)
+- = copy_type_recursive (objfile, TYPE_FIELD_TYPE (type, i),
+- copied_types);
++ = copy_type_recursive_1 (objfile, TYPE_FIELD_TYPE (type, i),
++ copied_types);
+ if (TYPE_FIELD_NAME (type, i))
+ TYPE_FIELD_NAME (new_type, i) =
+ xstrdup (TYPE_FIELD_NAME (type, i));
+@@ -3370,24 +3571,184 @@ copy_type_recursive (struct objfile *obj
+ }
+ }
+
++ /* Both FIELD_LOC_KIND_DWARF_BLOCK and TYPE_RANGE_HIGH_BOUND_IS_COUNT were
++ possibly converted. */
++ TYPE_DYNAMIC (new_type) = 0;
+
-+/* Create an index file for OBJFILE in the directory DIR. */
-+static void
-+write_psymtabs_to_index (struct objfile *objfile, const char *dir)
-+{
-+ struct cleanup *cleanup;
-+ char *filename, *cleanup_filename;
-+ struct obstack contents, addr_obstack, constant_pool, symtab_obstack, cu_list;
-+ int i;
-+ FILE *out_file;
-+ struct mapped_symtab *symtab;
-+ offset_type val, size_of_contents, total_len;
-+ struct stat st;
-+ char buf[8];
+ /* For range types, copy the bounds information. */
+- if (TYPE_CODE (type) == TYPE_CODE_RANGE)
++ if (TYPE_CODE (new_type) == TYPE_CODE_RANGE)
+ {
+ TYPE_RANGE_DATA (new_type) = xmalloc (sizeof (struct range_bounds));
+ *TYPE_RANGE_DATA (new_type) = *TYPE_RANGE_DATA (type);
+
-+ if (!objfile->psymtabs)
-+ return;
-+ if (dwarf2_per_objfile->using_index)
-+ error (_("Cannot use an index to create the index"));
-+
-+ if (stat (objfile->name, &st) < 0)
-+ perror_with_name (_("Could not stat"));
++ switch (TYPE_RANGE_DATA (new_type)->low.kind)
++ {
++ case RANGE_BOUND_KIND_CONSTANT:
++ break;
++ case RANGE_BOUND_KIND_DWARF_BLOCK:
++ /* `struct dwarf2_locexpr_baton' is too bound to its objfile so
++ it is expected to be made constant by CHECK_TYPEDEF.
++ TYPE_NOT_ALLOCATED and TYPE_NOT_ASSOCIATED are not valid for TYPE.
++ */
++ if (TYPE_NOT_ALLOCATED (new_type) || TYPE_NOT_ASSOCIATED (new_type)
++ || ! has_stack_frames ())
++ {
++ /* We should set 1 for Fortran but how to find the language? */
++ TYPE_LOW_BOUND (new_type) = 0;
++ TYPE_LOW_BOUND_UNDEFINED (new_type) = 1;
++ }
++ else
++ {
++ TYPE_LOW_BOUND (new_type) = dwarf_locexpr_baton_eval
++ (TYPE_RANGE_DATA (new_type)->low.u.dwarf_block);
++ if (TYPE_LOW_BOUND (new_type) >= 0)
++ TYPE_UNSIGNED (new_type) = 1;
++ }
++ TYPE_RANGE_DATA (new_type)->low.kind = RANGE_BOUND_KIND_CONSTANT;
++ break;
++ case RANGE_BOUND_KIND_DWARF_LOCLIST:
++ {
++ CORE_ADDR addr;
+
-+ filename = concat (dir, SLASH_STRING, lbasename (objfile->name),
-+ INDEX_SUFFIX, (char *) NULL);
-+ cleanup = make_cleanup (xfree, filename);
++ /* `struct dwarf2_loclist_baton' is too bound to its objfile so
++ it is expected to be made constant by CHECK_TYPEDEF.
++ TYPE_NOT_ALLOCATED and TYPE_NOT_ASSOCIATED are not valid for TYPE.
++ */
++ if (! TYPE_NOT_ALLOCATED (new_type)
++ && ! TYPE_NOT_ASSOCIATED (new_type) && has_stack_frames ()
++ && dwarf_loclist_baton_eval
++ (TYPE_RANGE_DATA (new_type)->low.u.dwarf_loclist.loclist,
++ TYPE_RANGE_DATA (new_type)->low.u.dwarf_loclist.type, &addr))
++ {
++ TYPE_LOW_BOUND (new_type) = addr;
++ if (TYPE_LOW_BOUND (new_type) >= 0)
++ TYPE_UNSIGNED (new_type) = 1;
++ }
++ else
++ {
++ /* We should set 1 for Fortran but how to find the language? */
++ TYPE_LOW_BOUND (new_type) = 0;
++ TYPE_LOW_BOUND_UNDEFINED (new_type) = 1;
++ }
++ TYPE_RANGE_DATA (new_type)->low.kind = RANGE_BOUND_KIND_CONSTANT;
++ }
++ break;
++ }
+
-+ out_file = fopen (filename, "wb");
-+ if (!out_file)
-+ error (_("Can't open `%s' for writing"), filename);
++ switch (TYPE_RANGE_DATA (new_type)->high.kind)
++ {
++ case RANGE_BOUND_KIND_CONSTANT:
++ break;
++ case RANGE_BOUND_KIND_DWARF_BLOCK:
++ /* `struct dwarf2_locexpr_baton' is too bound to its objfile so
++ it is expected to be made constant by CHECK_TYPEDEF.
++ TYPE_NOT_ALLOCATED and TYPE_NOT_ASSOCIATED are not valid for TYPE.
++ */
++ if (TYPE_NOT_ALLOCATED (new_type) || TYPE_NOT_ASSOCIATED (new_type)
++ || ! has_stack_frames ())
++ {
++ TYPE_HIGH_BOUND (new_type) = TYPE_LOW_BOUND (new_type) - 1;
++ TYPE_HIGH_BOUND_UNDEFINED (new_type) = 1;
++ }
++ else
++ TYPE_HIGH_BOUND (new_type) = dwarf_locexpr_baton_eval
++ (TYPE_RANGE_DATA (new_type)->high.u.dwarf_block);
++ TYPE_RANGE_DATA (new_type)->high.kind = RANGE_BOUND_KIND_CONSTANT;
++ break;
++ case RANGE_BOUND_KIND_DWARF_LOCLIST:
++ {
++ CORE_ADDR addr;
+
-+ cleanup_filename = filename;
-+ make_cleanup (unlink_if_set, &cleanup_filename);
++ /* `struct dwarf2_loclist_baton' is too bound to its objfile so
++ it is expected to be made constant by CHECK_TYPEDEF.
++ TYPE_NOT_ALLOCATED and TYPE_NOT_ASSOCIATED are not valid for TYPE.
++ */
++ if (! TYPE_NOT_ALLOCATED (new_type)
++ && ! TYPE_NOT_ASSOCIATED (new_type) && has_stack_frames ()
++ && dwarf_loclist_baton_eval
++ (TYPE_RANGE_DATA (new_type)->high.u.dwarf_loclist.loclist,
++ TYPE_RANGE_DATA (new_type)->high.u.dwarf_loclist.type,
++ &addr))
++ TYPE_HIGH_BOUND (new_type) = addr;
++ else
++ {
++ TYPE_HIGH_BOUND (new_type) = TYPE_LOW_BOUND (new_type) - 1;
++ TYPE_HIGH_BOUND_UNDEFINED (new_type) = 1;
++ }
++ TYPE_RANGE_DATA (new_type)->high.kind = RANGE_BOUND_KIND_CONSTANT;
++ }
++ break;
++ }
+
-+ symtab = create_mapped_symtab ();
-+ make_cleanup (cleanup_mapped_symtab, symtab);
++ switch (TYPE_RANGE_DATA (new_type)->byte_stride.kind)
++ {
++ case RANGE_BOUND_KIND_CONSTANT:
++ break;
++ case RANGE_BOUND_KIND_DWARF_BLOCK:
++ /* `struct dwarf2_locexpr_baton' is too bound to its objfile so
++ it is expected to be made constant by CHECK_TYPEDEF.
++ TYPE_NOT_ALLOCATED and TYPE_NOT_ASSOCIATED are not valid for TYPE.
++ */
++ if (TYPE_NOT_ALLOCATED (new_type) || TYPE_NOT_ASSOCIATED (new_type)
++ || ! has_stack_frames ())
++ TYPE_BYTE_STRIDE (new_type) = 0;
++ else
++ TYPE_BYTE_STRIDE (new_type) = dwarf_locexpr_baton_eval
++ (TYPE_RANGE_DATA (new_type)->byte_stride.u.dwarf_block);
++ TYPE_RANGE_DATA (new_type)->byte_stride.kind
++ = RANGE_BOUND_KIND_CONSTANT;
++ break;
++ case RANGE_BOUND_KIND_DWARF_LOCLIST:
++ {
++ CORE_ADDR addr = 0;
+
-+ obstack_init (&addr_obstack);
-+ make_cleanup_obstack_free (&addr_obstack);
++ /* `struct dwarf2_loclist_baton' is too bound to its objfile so
++ it is expected to be made constant by CHECK_TYPEDEF.
++ TYPE_NOT_ALLOCATED and TYPE_NOT_ASSOCIATED are not valid for TYPE.
++ */
++ if (! TYPE_NOT_ALLOCATED (new_type)
++ && ! TYPE_NOT_ASSOCIATED (new_type) && has_stack_frames ())
++ dwarf_loclist_baton_eval
++ (TYPE_RANGE_DATA (new_type)->byte_stride.u.dwarf_loclist.loclist,
++ TYPE_RANGE_DATA (new_type)->byte_stride.u.dwarf_loclist.type,
++ &addr);
++ TYPE_BYTE_STRIDE (new_type) = addr;
++ TYPE_RANGE_DATA (new_type)->byte_stride.kind
++ = RANGE_BOUND_KIND_CONSTANT;
++ }
++ break;
++ }
+
-+ obstack_init (&cu_list);
-+ make_cleanup_obstack_free (&cu_list);
++ /* Convert TYPE_RANGE_HIGH_BOUND_IS_COUNT into a regular bound. */
++ if (TYPE_RANGE_HIGH_BOUND_IS_COUNT (new_type))
++ {
++ TYPE_HIGH_BOUND (new_type) = TYPE_LOW_BOUND (new_type)
++ + TYPE_HIGH_BOUND (new_type) - 1;
++ TYPE_RANGE_HIGH_BOUND_IS_COUNT (new_type) = 0;
++ }
+ }
+
+ /* Copy pointers to other types. */
+ if (TYPE_TARGET_TYPE (type))
+ TYPE_TARGET_TYPE (new_type) =
+- copy_type_recursive (objfile,
+- TYPE_TARGET_TYPE (type),
+- copied_types);
++ copy_type_recursive_1 (objfile,
++ TYPE_TARGET_TYPE (type),
++ copied_types);
+ if (TYPE_VPTR_BASETYPE (type))
+ TYPE_VPTR_BASETYPE (new_type) =
+- copy_type_recursive (objfile,
+- TYPE_VPTR_BASETYPE (type),
+- copied_types);
++ copy_type_recursive_1 (objfile,
++ TYPE_VPTR_BASETYPE (type),
++ copied_types);
+
-+ for (i = 0; i < dwarf2_per_objfile->n_comp_units; ++i)
++ if (TYPE_CODE (new_type) == TYPE_CODE_ARRAY)
+ {
-+ struct dwarf2_per_cu_data *cu = dwarf2_per_objfile->all_comp_units[i];
-+ struct partial_symtab *psymtab = cu->v.psymtab;
-+ gdb_byte val[8];
-+
-+ write_psymbols (symtab,
-+ objfile->global_psymbols.list + psymtab->globals_offset,
-+ psymtab->n_global_syms, i);
-+ write_psymbols (symtab,
-+ objfile->static_psymbols.list + psymtab->statics_offset,
-+ psymtab->n_static_syms, i);
-+
-+ add_address_entry (objfile, &addr_obstack, psymtab, i);
-+
-+ store_unsigned_integer (val, 8, BFD_ENDIAN_LITTLE, cu->offset);
-+ obstack_grow (&cu_list, val, 8);
-+ store_unsigned_integer (val, 8, BFD_ENDIAN_LITTLE, cu->length);
-+ obstack_grow (&cu_list, val, 8);
++ struct type *new_index_type = TYPE_INDEX_TYPE (new_type);
++
++ if (TYPE_BYTE_STRIDE (new_index_type) == 0)
++ TYPE_BYTE_STRIDE (new_index_type)
++ = TYPE_LENGTH (TYPE_TARGET_TYPE (new_type));
+ }
+
-+ obstack_init (&constant_pool);
-+ make_cleanup_obstack_free (&constant_pool);
-+ obstack_init (&symtab_obstack);
-+ make_cleanup_obstack_free (&symtab_obstack);
-+ write_hash_table (symtab, &symtab_obstack, &constant_pool);
+ /* Maybe copy the type_specific bits.
+
+ NOTE drow/2005-12-09: We do not copy the C++-specific bits like
+@@ -3404,6 +3765,17 @@ copy_type_recursive (struct objfile *obj
+ return new_type;
+ }
+
++/* Recursively copy (deep copy) TYPE. Return a new type allocated using
++ malloc, a saved type if we have already visited TYPE (using COPIED_TYPES),
++ or TYPE if it is not associated with OBJFILE. */
++
++struct type *
++copy_type_recursive (struct type *type,
++ htab_t copied_types)
++{
++ return copy_type_recursive_1 (TYPE_OBJFILE (type), type, copied_types);
++}
++
+ /* Make a copy of the given TYPE, except that the pointer & reference
+ types are not preserved.
+
+@@ -3426,6 +3798,201 @@ copy_type (const struct type *type)
+ return new_type;
+ }
+
++#if 0
++/* Callback type for main_type_crawl. */
++typedef int (*main_type_crawl_iter) (struct type *type, void *data);
+
-+ obstack_init (&contents);
-+ make_cleanup_obstack_free (&contents);
-+ size_of_contents = 5 * sizeof (offset_type);
-+ total_len = size_of_contents;
++/* Iterate all main_type structures reachable through any `struct type *' from
++ TYPE. ITER will be called only for one type of each main_type, use
++ TYPE_CHAIN traversal to find all the type instances. ITER is being called
++ for each main_type found. ITER returns non-zero if main_type_crawl should
++ depth-first enter the specific type. ITER must provide some detection for
++ reentering the same main_type as this function would otherwise endlessly
++ loop. */
+
-+ /* The version number. */
-+ val = MAYBE_SWAP (1);
-+ obstack_grow (&contents, &val, sizeof (val));
++static void
++main_type_crawl (struct type *type, main_type_crawl_iter iter, void *data)
++{
++ struct type *type_iter;
++ int i;
+
-+ /* The offset of the CU list from the start of the file. */
-+ val = MAYBE_SWAP (total_len);
-+ obstack_grow (&contents, &val, sizeof (val));
-+ total_len += obstack_object_size (&cu_list);
++ if (!type)
++ return;
+
-+ /* The offset of the address table from the start of the file. */
-+ val = MAYBE_SWAP (total_len);
-+ obstack_grow (&contents, &val, sizeof (val));
-+ total_len += obstack_object_size (&addr_obstack);
++ gdb_assert (TYPE_OBJFILE (type) == NULL);
+
-+ /* The offset of the symbol table from the start of the file. */
-+ val = MAYBE_SWAP (total_len);
-+ obstack_grow (&contents, &val, sizeof (val));
-+ total_len += obstack_object_size (&symtab_obstack);
++ /* `struct cplus_struct_type' handling is unsupported by this function. */
++ gdb_assert ((TYPE_CODE (type) != TYPE_CODE_STRUCT
++ && TYPE_CODE (type) != TYPE_CODE_UNION)
++ || !HAVE_CPLUS_STRUCT (type));
+
-+ /* The offset of the constant pool from the start of the file. */
-+ val = MAYBE_SWAP (total_len);
-+ obstack_grow (&contents, &val, sizeof (val));
-+ total_len += obstack_object_size (&constant_pool);
++ if (!(*iter) (type, data))
++ return;
+
-+ gdb_assert (obstack_object_size (&contents) == size_of_contents);
++ /* Iterate all the type instances of this main_type. */
++ type_iter = type;
++ do
++ {
++ gdb_assert (TYPE_MAIN_TYPE (type_iter) == TYPE_MAIN_TYPE (type));
+
-+ write_obstack (out_file, &contents);
-+ write_obstack (out_file, &cu_list);
-+ write_obstack (out_file, &addr_obstack);
-+ write_obstack (out_file, &symtab_obstack);
-+ write_obstack (out_file, &constant_pool);
++ main_type_crawl (TYPE_POINTER_TYPE (type), iter, data);
++ main_type_crawl (TYPE_REFERENCE_TYPE (type), iter, data);
+
-+ fclose (out_file);
++ type_iter = TYPE_CHAIN (type_iter);
++ }
++ while (type_iter != type);
+
-+ /* We want to keep the file, so we set cleanup_filename to NULL
-+ here. See unlink_if_set. */
-+ cleanup_filename = NULL;
++ for (i = 0; i < TYPE_NFIELDS (type); i++)
++ main_type_crawl (TYPE_FIELD_TYPE (type, i), iter, data);
+
-+ do_cleanups (cleanup);
++ main_type_crawl (TYPE_TARGET_TYPE (type), iter, data);
++ main_type_crawl (TYPE_VPTR_BASETYPE (type), iter, data);
+}
+
-+/* The mapped index file format is designed to be directly mmap()able
-+ on any architecture. In most cases, a datum is represented using a
-+ little-endian 32-bit integer value, called an offset_type. Big
-+ endian machines must byte-swap the values before using them.
-+ Exceptions to this rule are noted. The data is laid out such that
-+ alignment is always respected.
-+
-+ A mapped index consists of several sections.
-+
-+ 1. The file header. This is a sequence of values, of offset_type
-+ unless otherwise noted:
-+ [0] The version number. Currently 1.
-+ [1] The offset, from the start of the file, of the CU list.
-+ [2] The offset, from the start of the file, of the address section.
-+ [3] The offset, from the start of the file, of the symbol table.
-+ [4] The offset, from the start of the file, of the constant pool.
-+
-+ 2. The CU list. This is a sequence of pairs of 64-bit
-+ little-endian values. The first element in each pair is the offset
-+ of a CU in the .debug_info section. The second element in each
-+ pair is the length of that CU. References to a CU elsewhere in the
-+ map are done using a CU index, which is just the 0-based index into
-+ this table.
-+
-+ 3. The address section. The address section consists of a sequence
-+ of address entries. Each address entry has three elements.
-+ [0] The low address. This is a 64-bit little-endian value.
-+ [1] The high address. This is a 64-bit little-endian value.
-+ [2] The CU index. This is an offset_type value.
-+
-+ 4. The symbol table. This is a hash table. The size of the hash
-+ table is always a power of 2. The initial hash and the step are
-+ currently defined by the `find_slot' function.
-+
-+ Each slot in the hash table consists of a pair of offset_type
-+ values. The first value is the offset of the symbol's name in the
-+ constant pool. The second value is the offset of the CU vector in
-+ the constant pool.
-+
-+ If both values are 0, then this slot in the hash table is empty.
-+ This is ok because while 0 is a valid constant pool index, it
-+ cannot be a valid index for both a string and a CU vector.
-+
-+ A string in the constant pool is stored as a \0-terminated string,
-+ as you'd expect.
-+
-+ A CU vector in the constant pool is a sequence of offset_type
-+ values. The first value is the number of CU indices in the vector.
-+ Each subsequent value is the index of a CU in the CU list. This
-+ element in the hash table is used to indicate which CUs define the
-+ symbol.
-+
-+ 5. The constant pool. This is simply a bunch of bytes. It is
-+ organized so that alignment is correct: CU vectors are stored
-+ first, followed by strings. */
++/* A helper for delete_type which deletes a main_type and the things to which
++ it refers. TYPE is a type whose main_type we wish to destroy. */
++
+static void
-+save_gdb_index_command (char *arg, int from_tty)
++delete_main_type (struct type *type)
+{
-+ struct objfile *objfile;
-+
-+ if (!arg || !*arg)
-+ error (_("usage: save gdb-index DIRECTORY"));
++ int i;
+
-+ ALL_OBJFILES (objfile)
-+ {
-+ struct stat st;
++ gdb_assert (TYPE_DISCARDABLE (type));
++ gdb_assert (TYPE_OBJFILE (type) == NULL);
+
-+ /* If the objfile does not correspond to an actual file, skip it. */
-+ if (stat (objfile->name, &st) < 0)
-+ continue;
++ xfree (TYPE_NAME (type));
++ xfree (TYPE_TAG_NAME (type));
+
-+ dwarf2_per_objfile = objfile_data (objfile, dwarf2_objfile_data_key);
-+ if (dwarf2_per_objfile)
-+ {
-+ volatile struct gdb_exception except;
++ for (i = 0; i < TYPE_NFIELDS (type); ++i)
++ {
++ xfree (TYPE_FIELD_NAME (type, i));
+
-+ TRY_CATCH (except, RETURN_MASK_ERROR)
-+ {
-+ write_psymtabs_to_index (objfile, arg);
-+ }
-+ if (except.reason < 0)
-+ exception_fprintf (gdb_stderr, except,
-+ _("Error while writing index for `%s': "),
-+ objfile->name);
-+ }
-+ }
-+}
++ if (TYPE_FIELD_LOC_KIND (type, i) == FIELD_LOC_KIND_PHYSNAME)
++ xfree (TYPE_FIELD_STATIC_PHYSNAME (type, i));
++ }
++ xfree (TYPE_FIELDS (type));
+
-+\f
++ gdb_assert (!HAVE_CPLUS_STRUCT (type));
+
- int dwarf2_always_disassemble;
-
- static void
-@@ -12609,6 +14455,8 @@ void _initialize_dwarf2_read (void);
- void
- _initialize_dwarf2_read (void)
- {
-+ struct cmd_list_element *c;
++ xfree (TYPE_MAIN_TYPE (type));
++}
+
- dwarf2_objfile_data_key
- = register_objfile_data_with_cleanup (NULL, dwarf2_per_objfile_free);
-
-@@ -12656,4 +14504,9 @@ The value is the maximum depth to print."),
- NULL,
- NULL,
- &setdebuglist, &showdebuglist);
-+
-+ c = add_cmd ("gdb-index", class_files, save_gdb_index_command,
-+ _("Save a .gdb-index file"),
-+ &save_cmdlist);
-+ set_cmd_completer (c, filename_completer);
- }
-diff --git a/gdb/elfread.c b/gdb/elfread.c
-index 8c00938..a250c58 100644
---- a/gdb/elfread.c
-+++ b/gdb/elfread.c
-@@ -37,9 +37,13 @@
- #include "complaints.h"
- #include "demangle.h"
- #include "psympriv.h"
-+#include "gdbtypes.h"
-
- extern void _initialize_elfread (void);
-
-+/* Forward declaration. */
-+static struct sym_fns elf_sym_fns_gdb_index;
-+
- /* The struct elfinfo is available only during ELF symbol table and
- psymtab reading. It is destroyed at the completion of psymtab-reading.
- It's local to elf_symfile_read. */
-@@ -180,7 +184,8 @@ record_minimal_symbol (const char *name, int name_len, int copy_name,
- {
- struct gdbarch *gdbarch = get_objfile_arch (objfile);
-
-- if (ms_type == mst_text || ms_type == mst_file_text)
-+ if (ms_type == mst_text || ms_type == mst_file_text
-+ || ms_type == mst_text_gnu_ifunc)
- address = gdbarch_smash_text_address (gdbarch, address);
-
- return prim_record_minimal_symbol_full (name, name_len, copy_name, address,
-@@ -388,7 +393,10 @@ elf_symtab_read (struct objfile *objfile, int type,
- {
- if (sym->flags & (BSF_GLOBAL | BSF_WEAK))
- {
-- ms_type = mst_text;
-+ if (sym->flags & BSF_GNU_INDIRECT_FUNCTION)
-+ ms_type = mst_text_gnu_ifunc;
-+ else
-+ ms_type = mst_text;
- }
- else if ((sym->name[0] == '.' && sym->name[1] == 'L')
- || ((sym->flags & BSF_LOCAL)
-@@ -569,6 +577,250 @@ elf_symtab_read (struct objfile *objfile, int type,
- }
- }
-
-+/* FIXME: Delay it through elf_sym_fns. */
++/* Delete all the instances on TYPE_CHAIN of TYPE, including their referenced
++ main_type. TYPE must be a reclaimable type - neither permanent nor objfile
++ associated. */
+
+static void
-+elf_rel_plt_read (struct objfile *objfile, asymbol **dyn_symbol_table)
-+{
-+ bfd *obfd = objfile->obfd;
-+ const struct elf_backend_data *bed = get_elf_backend_data (obfd);
-+ asection *plt, *relplt, *got_plt;
-+ unsigned u;
-+ int plt_elf_idx;
-+ bfd_size_type reloc_count, reloc;
-+ char *string_buffer = NULL;
-+ size_t string_buffer_size = 0;
-+ struct cleanup *back_to;
-+ struct gdbarch *gdbarch = objfile->gdbarch;
-+ struct type *ptr_type = builtin_type (gdbarch)->builtin_data_ptr;
-+ size_t ptr_size = TYPE_LENGTH (ptr_type);
-+
-+ if (objfile->separate_debug_objfile_backlink)
-+ return;
++delete_type_chain (struct type *type)
++{
++ struct type *type_iter, *type_iter_to_free;
+
-+ plt = bfd_get_section_by_name (obfd, ".plt");
-+ if (plt == NULL)
-+ return;
-+ plt_elf_idx = elf_section_data (plt)->this_idx;
++ gdb_assert (TYPE_DISCARDABLE (type));
++ gdb_assert (TYPE_OBJFILE (type) == NULL);
+
-+ got_plt = bfd_get_section_by_name (obfd, ".got.plt");
-+ if (got_plt == NULL)
-+ return;
++ delete_main_type (type);
+
-+ /* This search algorithm is from _bfd_elf_canonicalize_dynamic_reloc. */
-+ for (relplt = obfd->sections; relplt != NULL; relplt = relplt->next)
-+ if (elf_section_data (relplt)->this_hdr.sh_info == plt_elf_idx
-+ && (elf_section_data (relplt)->this_hdr.sh_type == SHT_REL
-+ || elf_section_data (relplt)->this_hdr.sh_type == SHT_RELA))
-+ break;
-+ if (relplt == NULL)
-+ return;
++ type_iter = type;
++ do
++ {
++ type_iter_to_free = type_iter;
++ type_iter = TYPE_CHAIN (type_iter);
++ xfree (type_iter_to_free);
++ }
++ while (type_iter != type);
++}
+
-+ if (! bed->s->slurp_reloc_table (obfd, relplt, dyn_symbol_table, TRUE))
-+ return;
++/* Hash function for type_discardable_table. */
+
-+ back_to = make_cleanup (free_current_contents, &string_buffer);
++static hashval_t
++type_discardable_hash (const void *p)
++{
++ const struct type *type = p;
+
-+ reloc_count = relplt->size / elf_section_data (relplt)->this_hdr.sh_entsize;
-+ for (reloc = 0; reloc < reloc_count; reloc++)
-+ {
-+ const char *name, *name_got_plt;
-+ struct minimal_symbol *msym;
-+ CORE_ADDR address;
-+ const char *suffix = "@got.plt";
-+ size_t suffix_len = strlen (suffix);
-+ size_t name_len;
-+
-+ name = bfd_asymbol_name (*relplt->relocation[reloc].sym_ptr_ptr);
-+ name_len = strlen (name);
-+ address = relplt->relocation[reloc].address;
-+
-+ /* Does the pointer reside in the .got.plt section? */
-+ if (!(bfd_get_section_vma (obfd, got_plt) <= address
-+ && address < bfd_get_section_vma (obfd, got_plt)
-+ + bfd_get_section_size (got_plt)))
-+ continue;
++ return htab_hash_pointer (TYPE_MAIN_TYPE (type));
++}
+
-+ /* We cannot check if NAME is a reference to mst_text_gnu_ifunc as in
-+ OBJFILE the symbol is undefined and the objfile having NAME defined
-+ may not yet have been loaded. */
++/* Equality function for type_discardable_table. */
+
-+ if (string_buffer_size < name_len + suffix_len)
-+ {
-+ string_buffer_size = 2 * (name_len + suffix_len);
-+ string_buffer = xrealloc (string_buffer, string_buffer_size);
-+ }
-+ memcpy (string_buffer, name, name_len);
-+ memcpy (&string_buffer[name_len], suffix, suffix_len);
-+
-+ msym = record_minimal_symbol (string_buffer, name_len + suffix_len, 1,
-+ address, mst_slot_got_plt, got_plt,
-+ objfile);
-+ if (msym)
-+ MSYMBOL_SIZE (msym) = ptr_size;
-+ }
++static int
++type_discardable_equal (const void *a, const void *b)
++{
++ const struct type *left = a;
++ const struct type *right = b;
+
-+ do_cleanups (back_to);
++ return TYPE_MAIN_TYPE (left) == TYPE_MAIN_TYPE (right);
+}
+
-+/* Function does not check for possibly created duplicities in the cache.
-+ Check it by resolve_gnu_ifunc_by_cache first. */
++/* A helper for type_mark_used. */
+
-+static struct minimal_symbol *
-+gnu_ifunc_record_cache_unchecked (const char *function_name,
-+ CORE_ADDR function_address)
++static int
++type_mark_used_crawl (struct type *type, void *unused)
+{
-+ struct minimal_symbol *msym, *msym_new;
-+ asection *sect;
-+ struct objfile *objfile;
-+ char *function_name_gnu_ifunc_tgt;
-+
-+ msym = lookup_minimal_symbol_by_pc (function_address);
-+ if (msym == NULL)
-+ return NULL;
-+ if (SYMBOL_VALUE_ADDRESS (msym) != function_address)
-+ return NULL;
-+ /* minimal symbols have always SYMBOL_OBJ_SECTION non-NULL. */
-+ sect = SYMBOL_OBJ_SECTION (msym)->the_bfd_section;
-+ objfile = SYMBOL_OBJ_SECTION (msym)->objfile;
-+
-+ /* If .plt jumps back to .plt the symbol is still deferred for later
-+ resolution and it has no use for GDB. Besides ".text" this symbol can
-+ reside also in ".opd" for ppc64 function descriptor. */
-+ if (strcmp (bfd_get_section_name (objfile->obfd, sect), ".plt") == 0)
-+ return NULL;
++ if (!TYPE_DISCARDABLE (type))
++ return 0;
+
-+ function_name_gnu_ifunc_tgt = alloca (strlen (function_name)
-+ + strlen ("@gnu-ifunc-tgt") + 1);
-+ sprintf (function_name_gnu_ifunc_tgt, "%s@gnu-ifunc-tgt", function_name);
-+
-+ /* Create new alias "@gnu-ifunc-tgt" for MSYM. */
-+ msym_new = record_minimal_symbol (function_name_gnu_ifunc_tgt,
-+ strlen (function_name_gnu_ifunc_tgt), 1,
-+ SYMBOL_VALUE_ADDRESS (msym),
-+ MSYMBOL_TYPE (msym), sect, objfile);
-+ /* Should not happen. */
-+ if (msym_new == NULL)
++ if (TYPE_DISCARDABLE_AGE (type) == type_discardable_age_current)
+ return 0;
+
-+ /* objfile->msymbols array is already allocated on obstack and it cannot be
-+ easily extended. Therefore <tab>-completion on symbol names will never
-+ show the @gnu-ifunc-tgt symbol. Link it at least to the hash table so
-+ that resolve_gnu_ifunc_by_cache can find it. */
-+ add_minsym_to_hash_table (msym_new, objfile->msymbol_hash);
-+
-+ MSYMBOL_SIZE (msym_new) = MSYMBOL_SIZE (msym);
-+ return msym_new;
++ TYPE_DISCARDABLE_AGE (type) = type_discardable_age_current;
++
++ /* Continue the traversal. */
++ return 1;
+}
+
-+/* Check first the cache if it - unlikely - has not been populated since
-+ bp_gnu_ifunc_resolver has been created. gnu_ifunc_record_cache_unchecked
-+ could create a duplicate symbol otherwise. */
++/* Mark TYPE and its connected types as used in this free_all_types pass. */
+
+void
-+gnu_ifunc_record_cache (struct gdbarch *gdbarch, const char *function_name,
-+ CORE_ADDR function_address)
++type_mark_used (struct type *type)
+{
-+ struct minimal_symbol *msym;
++ if (type == NULL)
++ return;
+
-+ msym = resolve_gnu_ifunc_by_cache (function_name);
-+ if (msym == NULL)
-+ gnu_ifunc_record_cache_unchecked (function_name, function_address);
-+ else if (SYMBOL_VALUE_ADDRESS (msym) != function_address)
-+ {
-+ /* This case indicates buggy inferior program. GDB would need to update
-+ its MSYM cache symbol for function_address. Anyway FUNCTION_NAME is
-+ never normally found in the case as in such case no
-+ bp_gnu_ifunc_resolver would be created in the first place. */
-+
-+ warning (_("gnu-indirect-function \"%s\" has changed its resolved "
-+ "function_address from %s to %s; GDB is using the former one"),
-+ function_name, paddress (gdbarch, SYMBOL_VALUE_ADDRESS (msym)),
-+ paddress (gdbarch, function_address));
-+ }
++ if (!TYPE_DISCARDABLE (type))
++ return;
++
++ main_type_crawl (type, type_mark_used_crawl, NULL);
+}
+
-+static struct minimal_symbol *
-+resolve_gnu_ifunc_by_got (const char *function_name)
++/* A traverse callback for type_discardable_table which removes any
++ type_discardable whose reference count is now zero (unused link). */
++
++static int
++type_discardable_remove (void **slot, void *unused)
+{
-+ char *function_name_got_plt;
-+ struct objfile *objfile;
++ struct type *type = *slot;
+
-+ function_name_got_plt = alloca (strlen (function_name) + strlen ("@got.plt")
-+ + 1);
-+ sprintf (function_name_got_plt, "%s@got.plt", function_name);
++ gdb_assert (TYPE_DISCARDABLE (type));
+
-+ ALL_PSPACE_OBJFILES (current_program_space, objfile)
++ if (TYPE_DISCARDABLE_AGE (type) != type_discardable_age_current)
+ {
-+ bfd *obfd = objfile->obfd;
-+ struct gdbarch *gdbarch = objfile->gdbarch;
-+ struct type *ptr_type = builtin_type (gdbarch)->builtin_data_ptr;
-+ size_t ptr_size = TYPE_LENGTH (ptr_type);
-+ CORE_ADDR pointer_address, function_address;
-+ asection *plt;
-+ gdb_byte *buf = alloca (ptr_size);
-+ struct minimal_symbol *msym;
-+
-+ msym = lookup_minimal_symbol (function_name_got_plt, NULL, objfile);
-+ if (msym == NULL)
-+ continue;
-+ if (MSYMBOL_TYPE (msym) != mst_slot_got_plt)
-+ continue;
-+ pointer_address = SYMBOL_VALUE_ADDRESS (msym);
-+
-+ plt = bfd_get_section_by_name (obfd, ".plt");
-+ if (plt == NULL)
-+ continue;
-+
-+ if (MSYMBOL_SIZE (msym) != ptr_size)
-+ continue;
-+ if (target_read_memory (pointer_address, buf, ptr_size) != 0)
-+ continue;
-+ function_address = extract_typed_address (buf, ptr_type);
++ delete_type_chain (type);
+
-+ msym = gnu_ifunc_record_cache_unchecked (function_name, function_address);
-+ if (msym == NULL)
-+ continue;
-+ return msym;
++ htab_clear_slot (type_discardable_table, slot);
+ }
+
-+ return NULL;
++ return 1;
+}
+
-+struct minimal_symbol *
-+resolve_gnu_ifunc_by_cache (const char *function_name)
-+{
-+ char *function_name_gnu_ifunc_tgt;
-+
-+ function_name_gnu_ifunc_tgt = alloca (strlen (function_name)
-+ + strlen ("@gnu-ifunc-tgt") + 1);
-+ sprintf (function_name_gnu_ifunc_tgt, "%s@gnu-ifunc-tgt", function_name);
++/* Free all the reclaimable types that have been allocated and that have
++ currently zero reference counter.
+
-+ return lookup_minimal_symbol (function_name_gnu_ifunc_tgt, NULL, NULL);
-+}
++ This function is called after each command, successful or not. Use this
++ cleanup only in the GDB idle state as GDB only marks those types used by
++ globally tracked objects (with no autovariable references tracking). */
+
-+int
-+resolve_gnu_ifunc (const char *function_name, CORE_ADDR *function_addressp)
++void
++free_all_types (void)
+{
-+ struct minimal_symbol *msym;
-+
-+ msym = resolve_gnu_ifunc_by_cache (function_name);
-+ if (msym != NULL)
-+ {
-+ *function_addressp = SYMBOL_VALUE_ADDRESS (msym);
-+ return 1;
-+ }
++ /* Mark a new pass. As GDB checks all the entries were visited after each
++ pass there cannot be any stale entries already containing the changed
++ value. */
++ type_discardable_age_current ^= 1;
+
-+ msym = resolve_gnu_ifunc_by_got (function_name);
-+ if (msym != NULL)
-+ {
-+ *function_addressp = SYMBOL_VALUE_ADDRESS (msym);
-+ return 1;
-+ }
++ observer_notify_mark_used ();
+
-+ return 0;
++ htab_traverse (type_discardable_table, type_discardable_remove, NULL);
+}
-+
- struct build_id
- {
- size_t size;
-@@ -797,6 +1049,8 @@ elf_symfile_read (struct objfile *objfile, int symfile_flags)
- bfd_errmsg (bfd_get_error ()));
++#endif
- elf_symtab_read (objfile, ST_DYNAMIC, dynsymcount, dyn_symbol_table, 0);
-+
-+ elf_rel_plt_read (objfile, dyn_symbol_table);
- }
+ /* Helper functions to initialize architecture-specific types. */
- /* Add synthetic symbols - for instance, names for any PLT entries. */
-@@ -869,11 +1123,9 @@ elf_symfile_read (struct objfile *objfile, int symfile_flags)
- str_sect->filepos,
- bfd_section_size (abfd, str_sect));
- }
-- if (dwarf2_has_info (objfile))
-- {
-- /* DWARF 2 sections */
-- dwarf2_build_psymtabs (objfile);
-- }
+@@ -3955,6 +4522,13 @@ void
+ _initialize_gdbtypes (void)
+ {
+ gdbtypes_data = gdbarch_data_register_post_init (gdbtypes_post_init);
+
-+ if (dwarf2_has_info (objfile) && dwarf2_initialize_objfile (objfile))
-+ objfile->sf = &elf_sym_fns_gdb_index;
-
- /* If the file has its own symbol tables it has no separate debug info.
- `.dynsym'/`.symtab' go to MSYMBOLS, `.debug_info' goes to SYMTABS/PSYMTABS.
-@@ -1049,6 +1301,24 @@ static struct sym_fns elf_sym_fns =
- NULL /* next: pointer to next struct sym_fns */
- };
-
-+/* The same as elf_sym_fns, but not registered and uses the
-+ DWARF-specific GNU index rather than psymtab. */
-+static struct sym_fns elf_sym_fns_gdb_index =
-+{
-+ bfd_target_elf_flavour,
-+ elf_new_init, /* sym_new_init: init anything gbl to entire symab */
-+ elf_symfile_init, /* sym_init: read initial info, setup for sym_red() */
-+ elf_symfile_read, /* sym_read: read a symbol file into symtab */
-+ elf_symfile_finish, /* sym_finish: finished with file, cleanup */
-+ default_symfile_offsets, /* sym_offsets: Translate ext. to int. relocatin */
-+ elf_symfile_segments, /* sym_segments: Get segment information from
-+ a file. */
-+ NULL, /* sym_read_linetable */
-+ default_symfile_relocate, /* sym_relocate: Relocate a debug section. */
-+ &dwarf2_gdb_index_functions,
-+ NULL /* next: pointer to next struct sym_fns */
-+};
++#if 0
++ type_discardable_table = htab_create_alloc (20, type_discardable_hash,
++ type_discardable_equal, NULL,
++ xcalloc, xfree);
++#endif
+
- void
- _initialize_elfread (void)
- {
-diff --git a/gdb/eval.c b/gdb/eval.c
-index ff17c34..7b9e871 100644
---- a/gdb/eval.c
-+++ b/gdb/eval.c
-@@ -44,6 +44,7 @@
- #include "objfiles.h"
- #include "python/python.h"
- #include "wrapper.h"
-+#include "dwarf2loc.h"
-
- #include "gdb_assert.h"
-
-@@ -788,6 +789,7 @@ evaluate_subexp_standard (struct type *expect_type,
- int save_pos1;
- struct symbol *function = NULL;
- char *function_name = NULL;
-+ struct cleanup *old_chain;
-
- pc = (*pos)++;
- op = exp->elts[pc].opcode;
-@@ -1772,6 +1774,8 @@ evaluate_subexp_standard (struct type *expect_type,
- return value_zero (builtin_type (exp->gdbarch)->builtin_int,
- not_lval);
- }
-+ else if (TYPE_GNU_IFUNC (ftype))
-+ return allocate_value (TYPE_TARGET_TYPE (TYPE_TARGET_TYPE (ftype)));
- else if (TYPE_TARGET_TYPE (ftype))
- return allocate_value (TYPE_TARGET_TYPE (ftype));
- else
-@@ -1798,6 +1802,8 @@ evaluate_subexp_standard (struct type *expect_type,
-
- /* First determine the type code we are dealing with. */
- arg1 = evaluate_subexp (NULL_TYPE, exp, pos, noside);
-+ old_chain = make_cleanup (null_cleanup, 0);
-+ object_address_set (value_raw_address (arg1));
- type = check_typedef (value_type (arg1));
- code = TYPE_CODE (type);
-
-@@ -1818,6 +1824,7 @@ evaluate_subexp_standard (struct type *expect_type,
- code = TYPE_CODE (type);
- }
- }
-+ do_cleanups (old_chain);
+ objfile_type_data = register_objfile_data ();
- switch (code)
- {
-@@ -2254,13 +2261,19 @@ evaluate_subexp_standard (struct type *expect_type,
- {
- int subscript_array[MAX_FORTRAN_DIMS];
- int array_size_array[MAX_FORTRAN_DIMS];
-+ int byte_stride_array[MAX_FORTRAN_DIMS];
- int ndimensions = 1, i;
- struct type *tmp_type;
- int offset_item; /* The array offset where the item lives */
-+ CORE_ADDR offset_byte; /* byte_stride based offset */
-+ unsigned element_size;
+ add_setshow_zinteger_cmd ("overload", no_class, &overload_debug,
+Index: gdb-7.2.90.20110703/gdb/gdbtypes.h
+===================================================================
+--- gdb-7.2.90.20110703.orig/gdb/gdbtypes.h 2011-03-28 22:21:03.000000000 +0200
++++ gdb-7.2.90.20110703/gdb/gdbtypes.h 2011-07-03 10:33:11.000000000 +0200
+@@ -215,6 +215,11 @@ enum type_instance_flag_value
- if (nargs > MAX_FORTRAN_DIMS)
- error (_("Too many subscripts for F77 (%d Max)"), MAX_FORTRAN_DIMS);
+ #define TYPE_TARGET_STUB(t) (TYPE_MAIN_TYPE (t)->flag_target_stub)
-+ old_chain = make_cleanup (null_cleanup, 0);
-+ object_address_set (value_raw_address (arg1));
++/* Type needs to be evaluated on each CHECK_TYPEDEF and its results must not be
++ sticky. */
+
- tmp_type = check_typedef (value_type (arg1));
- ndimensions = calc_f77_array_dims (type);
-
-@@ -2290,6 +2303,9 @@ evaluate_subexp_standard (struct type *expect_type,
- upper = f77_get_upperbound (tmp_type);
- lower = f77_get_lowerbound (tmp_type);
-
-+ byte_stride_array[nargs - i - 1] =
-+ TYPE_ARRAY_BYTE_STRIDE_VALUE (tmp_type);
++#define TYPE_DYNAMIC(t) (TYPE_MAIN_TYPE (t)->flag_dynamic)
+
- array_size_array[nargs - i - 1] = upper - lower + 1;
+ /* Static type. If this is set, the corresponding type had
+ a static modifier.
+ Note: This may be unnecessary, since static data members
+@@ -292,6 +297,50 @@ enum type_instance_flag_value
- /* Zero-normalize subscripts so that offsetting will work. */
-@@ -2308,13 +2324,25 @@ evaluate_subexp_standard (struct type *expect_type,
- tmp_type = check_typedef (TYPE_TARGET_TYPE (tmp_type));
- }
+ #define TYPE_DECLARED_CLASS(t) (TYPE_MAIN_TYPE (t)->flag_declared_class)
-+ /* Kept for the f77_get_upperbound / f77_get_lowerbound calls above. */
-+ do_cleanups (old_chain);
++#if 0
++/* Define this type as being reclaimable during free_all_types. Type is
++ required to be have TYPE_OBJFILE set to NULL. Setting this flag requires
++ initializing TYPE_DISCARDABLE_AGE, see alloc_type_discardable. */
+
- /* Now let us calculate the offset for this item */
-
-- offset_item = subscript_array[ndimensions - 1];
-+ offset_item = 0;
-+ offset_byte = 0;
++#define TYPE_DISCARDABLE(t) (TYPE_MAIN_TYPE (t)->flag_discardable)
+
-+ for (i = ndimensions - 1; i >= 0; --i)
-+ {
-+ offset_item *= array_size_array[i];
-+ if (byte_stride_array[i] == 0)
-+ offset_item += subscript_array[i];
-+ else
-+ offset_byte += subscript_array[i] * byte_stride_array[i];
-+ }
-
-- for (i = ndimensions - 1; i > 0; --i)
-- offset_item =
-- array_size_array[i - 1] * offset_item + subscript_array[i - 1];
-+ element_size = TYPE_LENGTH (TYPE_TARGET_TYPE (tmp_type));
-+ offset_byte += offset_item * element_size;
-
- /* Let us now play a dirty trick: we will take arg1
- which is a value node pointing to the topmost level
-@@ -2324,7 +2352,7 @@ evaluate_subexp_standard (struct type *expect_type,
- returns the correct type value */
-
- deprecated_set_value_type (arg1, tmp_type);
-- return value_subscripted_rvalue (arg1, offset_item, 0);
-+ return value_subscripted_rvalue (arg1, offset_byte);
- }
++/* Marker this type has been visited by the type_mark_used by this
++ mark-and-sweep types garbage collecting pass. Current pass is represented
++ by TYPE_DISCARDABLE_AGE_CURRENT. */
++
++#define TYPE_DISCARDABLE_AGE(t) (TYPE_MAIN_TYPE (t)->flag_discardable_age)
++#endif
++
++/* Is HIGH_BOUND a low-bound relative count (1) or the high bound itself (0)? */
++
++#define TYPE_RANGE_HIGH_BOUND_IS_COUNT(range_type) \
++ (TYPE_MAIN_TYPE (range_type)->flag_range_high_bound_is_count)
++
++/* Not allocated. TYPE_ALLOCATED(t) must be NULL in such case. If this flag
++ is unset and TYPE_ALLOCATED(t) is NULL then the type is allocated. If this
++ flag is unset and TYPE_ALLOCATED(t) is not NULL then its DWARF block
++ determines the actual allocation state. */
++
++#define TYPE_NOT_ALLOCATED(t) (TYPE_MAIN_TYPE (t)->flag_not_allocated)
++
++/* Not associated. TYPE_ASSOCIATED(t) must be NULL in such case. If this flag
++ is unset and TYPE_ASSOCIATED(t) is NULL then the type is associated. If
++ this flag is unset and TYPE_ASSOCIATED(t) is not NULL then its DWARF block
++ determines the actual association state. */
++
++#define TYPE_NOT_ASSOCIATED(t) (TYPE_MAIN_TYPE (t)->flag_not_associated)
++
++/* Address of the actual data as for DW_AT_data_location. Its dwarf block must
++ not be evaluated unless both TYPE_NOT_ALLOCATED and TYPE_NOT_ASSOCIATED are
++ false. If TYPE_DATA_LOCATION_IS_ADDR set then TYPE_DATA_LOCATION_ADDR value
++ is the actual data address value. If unset and
++ TYPE_DATA_LOCATION_DWARF_BLOCK is NULL then the value is the normal
++ value_raw_address. If unset and TYPE_DATA_LOCATION_DWARF_BLOCK is not NULL
++ then its DWARF block determines the actual data address. */
++
++#define TYPE_DATA_LOCATION_IS_ADDR(t) \
++ (TYPE_MAIN_TYPE (t)->flag_data_location_is_addr)
++
+ /* Constant type. If this is set, the corresponding type has a
+ const modifier. */
- case BINOP_LOGICAL_AND:
-@@ -2558,14 +2586,22 @@ evaluate_subexp_standard (struct type *expect_type,
- if (expect_type && TYPE_CODE (expect_type) == TYPE_CODE_PTR)
- expect_type = TYPE_TARGET_TYPE (check_typedef (expect_type));
- arg1 = evaluate_subexp (expect_type, exp, pos, noside);
-+ old_chain = make_cleanup (null_cleanup, 0);
-+ object_address_set (value_raw_address (arg1));
- type = check_typedef (value_type (arg1));
- if (TYPE_CODE (type) == TYPE_CODE_METHODPTR
- || TYPE_CODE (type) == TYPE_CODE_MEMBERPTR)
- error (_("Attempt to dereference pointer to member without an object"));
- if (noside == EVAL_SKIP)
-- goto nosideret;
-+ {
-+ do_cleanups (old_chain);
-+ goto nosideret;
-+ }
- if (unop_user_defined_p (op, arg1))
-- return value_x_unop (arg1, op, noside);
+@@ -400,6 +449,15 @@ struct main_type
+ /* True if this type was declared with "class" rather than
+ "struct". */
+ unsigned int flag_declared_class : 1;
++#if 0
++ unsigned int flag_discardable : 1;
++ unsigned int flag_discardable_age : 1;
++#endif
++ unsigned int flag_dynamic : 1;
++ unsigned int flag_range_high_bound_is_count : 1;
++ unsigned int flag_not_allocated : 1;
++ unsigned int flag_not_associated : 1;
++ unsigned int flag_data_location_is_addr : 1;
+
+ /* A discriminant telling us which field of the type_specific union
+ is being used for this type, if any. */
+@@ -473,6 +531,20 @@ struct main_type
+
+ struct type *target_type;
+
++ /* For DW_AT_data_location. */
++ union
++ {
++ struct dwarf2_locexpr_baton *dwarf_block;
++ CORE_ADDR addr;
++ }
++ data_location;
++
++ /* For DW_AT_allocated. */
++ struct dwarf2_locexpr_baton *allocated;
++
++ /* For DW_AT_associated. */
++ struct dwarf2_locexpr_baton *associated;
++
+ /* 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.
+@@ -547,13 +619,34 @@ struct main_type
+
+ struct range_bounds
+ {
++ struct
+ {
-+ do_cleanups (old_chain);
-+ return value_x_unop (arg1, op, noside);
-+ }
- else if (noside == EVAL_AVOID_SIDE_EFFECTS)
- {
- type = check_typedef (value_type (arg1));
-@@ -2574,12 +2610,18 @@ evaluate_subexp_standard (struct type *expect_type,
- /* In C you can dereference an array to get the 1st elt. */
- || TYPE_CODE (type) == TYPE_CODE_ARRAY
- )
-- return value_zero (TYPE_TARGET_TYPE (type),
-- lval_memory);
++ union
+ {
-+ do_cleanups (old_chain);
-+ return value_zero (TYPE_TARGET_TYPE (type),
-+ lval_memory);
++ LONGEST constant;
++ struct dwarf2_locexpr_baton *dwarf_block;
++ struct
++ {
++ struct dwarf2_loclist_baton *loclist;
++ struct type *type;
++ }
++ dwarf_loclist;
+ }
- else if (TYPE_CODE (type) == TYPE_CODE_INT)
-- /* GDB allows dereferencing an int. */
-- return value_zero (builtin_type (exp->gdbarch)->builtin_int,
-- lval_memory);
++ u;
++ enum range_bound_kind
+ {
-+ do_cleanups (old_chain);
-+ /* GDB allows dereferencing an int. */
-+ return value_zero (builtin_type (exp->gdbarch)->builtin_int,
-+ lval_memory);
++ RANGE_BOUND_KIND_CONSTANT,
++ RANGE_BOUND_KIND_DWARF_BLOCK,
++ RANGE_BOUND_KIND_DWARF_LOCLIST
+ }
- else
- error (_("Attempt to take contents of a non-pointer value."));
- }
-@@ -2589,9 +2631,14 @@ evaluate_subexp_standard (struct type *expect_type,
- do. "long long" variables are rare enough that
- BUILTIN_TYPE_LONGEST would seem to be a mistake. */
- if (TYPE_CODE (type) == TYPE_CODE_INT)
-- return value_at_lazy (builtin_type (exp->gdbarch)->builtin_int,
-- (CORE_ADDR) value_as_address (arg1));
-- return value_ind (arg1);
-+ {
-+ do_cleanups (old_chain);
-+ return value_at_lazy (builtin_type (exp->gdbarch)->builtin_int,
-+ (CORE_ADDR) value_as_address (arg1));
++ kind;
+ }
-+ arg1 = value_ind (arg1);
-+ do_cleanups (old_chain);
-+ return arg1;
-
- case UNOP_ADDR:
- /* C++: check for and handle pointer to members. */
-@@ -2933,7 +2980,7 @@ evaluate_subexp_with_coercion (struct expression *exp,
- {
- enum exp_opcode op;
- int pc;
-- struct value *val;
-+ struct value *val = NULL;
- struct symbol *var;
- struct type *type;
-
-@@ -2944,12 +2991,17 @@ evaluate_subexp_with_coercion (struct expression *exp,
- {
- case OP_VAR_VALUE:
- var = exp->elts[pc + 2].symbol;
-+ /* address_of_variable will call object_address_set for check_typedef.
-+ Call it only if required as it can error-out on VAR in register. */
-+ if (TYPE_DYNAMIC (SYMBOL_TYPE (var)))
-+ val = address_of_variable (var, exp->elts[pc + 1].block);
- type = check_typedef (SYMBOL_TYPE (var));
- if (TYPE_CODE (type) == TYPE_CODE_ARRAY
- && CAST_IS_CONVERSION (exp->language_defn))
- {
- (*pos) += 4;
-- val = address_of_variable (var, exp->elts[pc + 1].block);
-+ if (!val)
-+ val = address_of_variable (var, exp->elts[pc + 1].block);
- return value_cast (lookup_pointer_type (TYPE_TARGET_TYPE (type)),
- val);
- }
-@@ -3001,9 +3053,13 @@ evaluate_subexp_for_sizeof (struct expression *exp, int *pos)
+ /* Low bound of range. */
+-
+- LONGEST low;
+-
++ low,
+ /* High bound of range. */
+-
+- LONGEST high;
++ high,
++ /* Byte stride of range. */
++ byte_stride;
- case OP_VAR_VALUE:
- (*pos) += 4;
-- type = check_typedef (SYMBOL_TYPE (exp->elts[pc + 2].symbol));
-- return
-- value_from_longest (size_type, (LONGEST) TYPE_LENGTH (type));
-+ /* We do not need to call read_var_value but the object evaluation may
-+ need to have executed object_address_set which needs valid
-+ SYMBOL_VALUE_ADDRESS of the symbol. Still VALUE returned by
-+ read_var_value we left as lazy. */
-+ type = value_type (read_var_value (exp->elts[pc + 2].symbol,
-+ deprecated_safe_get_selected_frame ()));
-+ return value_from_longest (size_type, (LONGEST) TYPE_LENGTH (type));
+ /* Flags indicating whether the values of low and high are
+ valid. When true, the respective range value is
+@@ -926,9 +1019,9 @@ extern void allocate_gnat_aux_type (stru
+ #define TYPE_POINTER_TYPE(thistype) (thistype)->pointer_type
+ #define TYPE_REFERENCE_TYPE(thistype) (thistype)->reference_type
+ #define TYPE_CHAIN(thistype) (thistype)->chain
+-/* Note that if thistype is a TYPEDEF type, you have to call check_typedef.
+- But check_typedef does set the TYPE_LENGTH of the TYPEDEF type,
+- so you only have to call check_typedef once. Since allocate_value
++/* Note that if thistype is a TYPEDEF, ARRAY or STRING type, you have to call
++ check_typedef. But check_typedef does set the TYPE_LENGTH of the TYPEDEF
++ type, so you only have to call check_typedef once. Since allocate_value
+ 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
+@@ -936,11 +1029,16 @@ extern void allocate_gnat_aux_type (stru
+ #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
++#define TYPE_DATA_LOCATION_DWARF_BLOCK(thistype) TYPE_MAIN_TYPE (thistype)->data_location.dwarf_block
++#define TYPE_DATA_LOCATION_ADDR(thistype) TYPE_MAIN_TYPE (thistype)->data_location.addr
++#define TYPE_ALLOCATED(thistype) TYPE_MAIN_TYPE (thistype)->allocated
++#define TYPE_ASSOCIATED(thistype) TYPE_MAIN_TYPE (thistype)->associated
- default:
- val = evaluate_subexp (NULL_TYPE, exp, pos, EVAL_AVOID_SIDE_EFFECTS);
-diff --git a/gdb/f-lang.h b/gdb/f-lang.h
-index f5bb82d..29cf5ba 100644
---- a/gdb/f-lang.h
-+++ b/gdb/f-lang.h
-@@ -28,6 +28,10 @@ extern void f_error (char *); /* Defined in f-exp.y */
- extern void f_print_type (struct type *, const char *, struct ui_file *, int,
- int);
+ #define TYPE_INDEX_TYPE(type) TYPE_FIELD_TYPE (type, 0)
+ #define TYPE_RANGE_DATA(thistype) TYPE_MAIN_TYPE(thistype)->flds_bnds.bounds
+-#define TYPE_LOW_BOUND(range_type) TYPE_RANGE_DATA(range_type)->low
+-#define TYPE_HIGH_BOUND(range_type) TYPE_RANGE_DATA(range_type)->high
++#define TYPE_LOW_BOUND(range_type) TYPE_RANGE_DATA(range_type)->low.u.constant
++#define TYPE_HIGH_BOUND(range_type) TYPE_RANGE_DATA(range_type)->high.u.constant
++#define TYPE_BYTE_STRIDE(range_type) TYPE_RANGE_DATA(range_type)->byte_stride.u.constant
+ #define TYPE_LOW_BOUND_UNDEFINED(range_type) \
+ TYPE_RANGE_DATA(range_type)->low_undefined
+ #define TYPE_HIGH_BOUND_UNDEFINED(range_type) \
+@@ -957,7 +1055,14 @@ extern void allocate_gnat_aux_type (stru
+ (TYPE_HIGH_BOUND(TYPE_INDEX_TYPE((arraytype))))
-+extern const char *f_object_address_data_valid_print_to_stream
-+ (struct type *type, struct ui_file *stream);
-+extern void f_object_address_data_valid_or_error (struct type *type);
+ #define TYPE_ARRAY_LOWER_BOUND_VALUE(arraytype) \
+- (TYPE_LOW_BOUND(TYPE_INDEX_TYPE((arraytype))))
++ TYPE_LOW_BOUND (TYPE_INDEX_TYPE (arraytype))
+
- extern int f_val_print (struct type *, const gdb_byte *, int, CORE_ADDR,
- struct ui_file *, int,
- const struct value *,
-diff --git a/gdb/f-typeprint.c b/gdb/f-typeprint.c
-index d35a255..dec81d5 100644
---- a/gdb/f-typeprint.c
-+++ b/gdb/f-typeprint.c
-@@ -32,7 +32,7 @@
- #include "gdbcore.h"
- #include "target.h"
- #include "f-lang.h"
--
-+#include "dwarf2loc.h"
- #include "gdb_string.h"
- #include <errno.h>
++/* TYPE_BYTE_STRIDE (TYPE_INDEX_TYPE (arraytype)) with a fallback to the
++ element size if no specific stride value is known. */
++#define TYPE_ARRAY_BYTE_STRIDE_VALUE(arraytype) \
++ (TYPE_BYTE_STRIDE (TYPE_INDEX_TYPE (arraytype)) == 0 \
++ ? TYPE_LENGTH (TYPE_TARGET_TYPE (arraytype)) \
++ : TYPE_BYTE_STRIDE (TYPE_INDEX_TYPE (arraytype)))
-@@ -49,6 +49,34 @@ void f_type_print_varspec_prefix (struct type *, struct ui_file *,
- void f_type_print_base (struct type *, struct ui_file *, int, int);
- \f
+ /* C++ */
-+const char *
-+f_object_address_data_valid_print_to_stream (struct type *type,
-+ struct ui_file *stream)
-+{
-+ const char *msg;
+@@ -1379,6 +1484,18 @@ extern struct type *create_array_type (s
+ struct type *);
+ extern struct type *lookup_array_range_type (struct type *, int, int);
+
++extern CORE_ADDR type_range_any_field_internal (struct type *range_type,
++ int fieldno);
+
-+ msg = object_address_data_not_valid (type);
-+ if (msg != NULL)
-+ {
-+ /* Assuming the content printed to STREAM should not be localized. */
-+ fprintf_filtered (stream, "<%s>", msg);
-+ }
++extern int type_range_high_bound_internal (struct type *range_type);
+
-+ return msg;
-+}
++extern int type_range_count_bound_internal (struct type *range_type);
+
-+void
-+f_object_address_data_valid_or_error (struct type *type)
-+{
-+ const char *msg;
++extern CORE_ADDR type_range_byte_stride_internal (struct type *range_type,
++ struct type *element_type);
+
-+ msg = object_address_data_not_valid (type);
-+ if (msg != NULL)
-+ {
-+ error (_("Cannot access it because the %s."), _(msg));
-+ }
-+}
++extern void finalize_type (struct type *type);
+
- /* LEVEL is the depth to indent lines by. */
+ extern struct type *create_string_type (struct type *, struct type *,
+ struct type *);
+ extern struct type *lookup_string_range_type (struct type *, int, int);
+@@ -1424,6 +1541,10 @@ extern int is_public_ancestor (struct ty
- void
-@@ -58,6 +86,9 @@ f_print_type (struct type *type, const char *varstring, struct ui_file *stream,
- enum type_code code;
- int demangled_args;
+ extern int is_unique_ancestor (struct type *, struct value *);
-+ if (f_object_address_data_valid_print_to_stream (type, stream) != NULL)
-+ return;
++#if 0
++extern void type_mark_used (struct type *type);
++#endif
+
- f_type_print_base (type, stream, show, level);
- code = TYPE_CODE (type);
- if ((varstring != NULL && *varstring != '\0')
-@@ -165,6 +196,9 @@ f_type_print_varspec_suffix (struct type *type, struct ui_file *stream,
+ /* Overload resolution */
- QUIT;
+ #define LENGTH_MATCH(bv) ((bv)->rank[0])
+@@ -1496,10 +1617,13 @@ extern void maintenance_print_type (char
-+ if (TYPE_CODE (type) != TYPE_CODE_TYPEDEF)
-+ CHECK_TYPEDEF (type);
+ extern htab_t create_copied_types_hash (struct objfile *objfile);
+
+-extern struct type *copy_type_recursive (struct objfile *objfile,
+- struct type *type,
++extern struct type *copy_type_recursive (struct type *type,
+ htab_t copied_types);
+
+ extern struct type *copy_type (const struct type *type);
+
++#if 0
++extern void free_all_types (void);
++#endif
+
- switch (TYPE_CODE (type))
- {
- case TYPE_CODE_ARRAY:
-diff --git a/gdb/f-valprint.c b/gdb/f-valprint.c
-index 85f698d..2f72b97 100644
---- a/gdb/f-valprint.c
-+++ b/gdb/f-valprint.c
-@@ -54,15 +54,17 @@ int f77_array_offset_tbl[MAX_FORTRAN_DIMS + 1][2];
- /* The following macro gives us the size of the nth dimension, Where
- n is 1 based. */
+ #endif /* GDBTYPES_H */
+Index: gdb-7.2.90.20110703/gdb/i386-linux-nat.c
+===================================================================
+--- gdb-7.2.90.20110703.orig/gdb/i386-linux-nat.c 2011-02-27 17:25:37.000000000 +0100
++++ gdb-7.2.90.20110703/gdb/i386-linux-nat.c 2011-07-03 10:33:11.000000000 +0200
+@@ -649,22 +649,13 @@ i386_linux_store_inferior_registers (str
+ }
+ \f
--#define F77_DIM_SIZE(n) (f77_array_offset_tbl[n][1])
-+#define F77_DIM_COUNT(n) (f77_array_offset_tbl[n][1])
+-/* Support for debug registers. */
+-
+-static unsigned long i386_linux_dr[DR_CONTROL + 1];
+-
+ /* Get debug register REGNUM value from only the one LWP of PTID. */
--/* The following gives us the offset for row n where n is 1-based. */
-+/* The following gives us the element size for row n where n is 1-based. */
+ static unsigned long
+-i386_linux_dr_get (ptid_t ptid, int regnum)
++i386_linux_dr_get (int tid, int regnum)
+ {
+- int tid;
+ unsigned long value;
--#define F77_DIM_OFFSET(n) (f77_array_offset_tbl[n][0])
-+#define F77_DIM_BYTE_STRIDE(n) (f77_array_offset_tbl[n][0])
+- tid = TIDGET (ptid);
+- if (tid == 0)
+- tid = PIDGET (ptid);
+-
+ /* FIXME: kettenis/2001-03-27: Calling perror_with_name if the
+ ptrace call fails breaks debugging remote targets. The correct
+ way to fix this is to add the hardware breakpoint and watchpoint
+@@ -686,14 +677,8 @@ i386_linux_dr_get (ptid_t ptid, int regn
+ /* Set debug register REGNUM to VALUE in only the one LWP of PTID. */
- int
- f77_get_lowerbound (struct type *type)
+ static void
+-i386_linux_dr_set (ptid_t ptid, int regnum, unsigned long value)
++i386_linux_dr_set (int tid, int regnum, unsigned long value)
{
-+ f_object_address_data_valid_or_error (type);
+- int tid;
+-
+- tid = TIDGET (ptid);
+- if (tid == 0)
+- tid = PIDGET (ptid);
+-
+ errno = 0;
+ ptrace (PTRACE_POKEUSER, tid,
+ offsetof (struct user, u_debugreg[regnum]), value);
+@@ -701,35 +686,78 @@ i386_linux_dr_set (ptid_t ptid, int regn
+ perror_with_name (_("Couldn't write debug register"));
+ }
+
+-/* Set DR_CONTROL to ADDR in all LWPs of LWP_LIST. */
++/* Helper for i386_linux_dr_set_control. */
+
- if (TYPE_ARRAY_LOWER_BOUND_IS_UNDEFINED (type))
- error (_("Lower bound may not be '*' in F77"));
++static void
++i386_linux_dr_set_control_callback (int tid, void *control_voidp)
++{
++ unsigned long control = *(unsigned long *) control_voidp;
++
++ i386_linux_dr_set (tid, DR_CONTROL, control);
++}
++
++static void i386_linux_dr_set_addr (int regnum, CORE_ADDR addr);
++
++/* Set DR_CONTROL to ADDR in all LWPs of CURRENT_INFERIOR. */
-@@ -72,14 +74,17 @@ f77_get_lowerbound (struct type *type)
- int
- f77_get_upperbound (struct type *type)
+ static void
+ i386_linux_dr_set_control (unsigned long control)
{
-+ f_object_address_data_valid_or_error (type);
+- struct lwp_info *lp;
+- ptid_t ptid;
++ int inferior_pid = ptid_get_pid (inferior_ptid);
++ struct inferior *inf = current_inferior ();
+
- if (TYPE_ARRAY_UPPER_BOUND_IS_UNDEFINED (type))
- {
-- /* We have an assumed size array on our hands. Assume that
-- upper_bound == lower_bound so that we show at least 1 element.
-- If the user wants to see more elements, let him manually ask for 'em
-- and we'll subscript the array and show him. */
-+ /* We have an assumed size array on our hands. As type_length_get
-+ already assumes a length zero of arrays with underfined bounds VALADDR
-+ passed to the Fortran functions does not contained the real inferior
-+ memory content. User should request printing of specific array
-+ elements instead. */
-
-- return f77_get_lowerbound (type);
-+ return f77_get_lowerbound (type) - 1;
- }
++ /* The amd64 counterpart and description is amd64_linux_dr_set_control. */
++ if (inf->pid != inferior_pid)
++ {
++ struct i386_dr_mirror *dr_mirror = i386_dr_mirror_get ();
++ int i;
++
++ if (!dr_mirror->addr_preset)
++ {
++ dr_mirror->addr_preset = 1;
- return TYPE_ARRAY_UPPER_BOUND_VALUE (type);
-@@ -134,24 +139,29 @@ f77_create_arrayprint_offset_tbl (struct type *type, struct ui_file *stream)
- upper = f77_get_upperbound (tmp_type);
- lower = f77_get_lowerbound (tmp_type);
+- i386_linux_dr[DR_CONTROL] = control;
+- ALL_LWPS (lp, ptid)
+- i386_linux_dr_set (ptid, DR_CONTROL, control);
++ for (i = 0; i < DR_LASTADDR - DR_FIRSTADDR; i++)
++ i386_linux_dr_set_addr (i, dr_mirror->addr[i]);
++ }
++ }
++
++ linux_nat_iterate_watchpoint_lwps (i386_linux_dr_set_control_callback,
++ &control);
+ }
-- F77_DIM_SIZE (ndimen) = upper - lower + 1;
-+ F77_DIM_COUNT (ndimen) = upper - lower + 1;
+-/* Set address REGNUM (zero based) to ADDR in all LWPs of LWP_LIST. */
++/* Helper for i386_linux_dr_set_addr. */
+
-+ F77_DIM_BYTE_STRIDE (ndimen) =
-+ TYPE_ARRAY_BYTE_STRIDE_VALUE (tmp_type);
++struct i386_linux_dr_set_addr_data
++ {
++ int regnum;
++ CORE_ADDR addr;
++ };
++
++static void
++i386_linux_dr_set_addr_callback (int tid, void *datap_voidp)
++{
++ const struct i386_linux_dr_set_addr_data *datap = datap_voidp;
++
++ i386_linux_dr_set (tid, DR_FIRSTADDR + datap->regnum, datap->addr);
++}
++
++/* Set address REGNUM (zero based) to ADDR in all LWPs of CURRENT_INFERIOR.
++ */
- tmp_type = TYPE_TARGET_TYPE (tmp_type);
- ndimen++;
- }
+ static void
+ i386_linux_dr_set_addr (int regnum, CORE_ADDR addr)
+ {
+- struct lwp_info *lp;
+- ptid_t ptid;
++ struct i386_linux_dr_set_addr_data data;
+
+ gdb_assert (regnum >= 0 && regnum <= DR_LASTADDR - DR_FIRSTADDR);
+
+- i386_linux_dr[DR_FIRSTADDR + regnum] = addr;
+- ALL_LWPS (lp, ptid)
+- i386_linux_dr_set (ptid, DR_FIRSTADDR + regnum, addr);
++ data.regnum = regnum;
++ data.addr = addr;
++ linux_nat_iterate_watchpoint_lwps (i386_linux_dr_set_addr_callback, &data);
+ }
-- /* Now we multiply eltlen by all the offsets, so that later we
-+ /* Now we multiply eltlen by all the BYTE_STRIDEs, so that later we
- can print out array elements correctly. Up till now we
-- know an offset to apply to get the item but we also
-+ know an eltlen to apply to get the item but we also
- have to know how much to add to get to the next item */
+-/* Set address REGNUM (zero based) to zero in all LWPs of LWP_LIST. */
++/* Set address REGNUM (zero based) to zero in all LWPs of CURRENT_INFERIOR.
++ */
- ndimen--;
- eltlen = TYPE_LENGTH (tmp_type);
-- F77_DIM_OFFSET (ndimen) = eltlen;
-+ if (F77_DIM_BYTE_STRIDE (ndimen) == 0)
-+ F77_DIM_BYTE_STRIDE (ndimen) = eltlen;
- while (--ndimen > 0)
- {
-- eltlen *= F77_DIM_SIZE (ndimen + 1);
-- F77_DIM_OFFSET (ndimen) = eltlen;
-+ eltlen *= F77_DIM_COUNT (ndimen + 1);
-+ if (F77_DIM_BYTE_STRIDE (ndimen) == 0)
-+ F77_DIM_BYTE_STRIDE (ndimen) = eltlen;
- }
+ static void
+ i386_linux_dr_reset_addr (int regnum)
+@@ -742,36 +770,54 @@ i386_linux_dr_reset_addr (int regnum)
+ static unsigned long
+ i386_linux_dr_get_status (void)
+ {
+- return i386_linux_dr_get (inferior_ptid, DR_STATUS);
++ int tid;
++
++ tid = TIDGET (inferior_ptid);
++ if (tid == 0)
++ tid = PIDGET (inferior_ptid);
++
++ return i386_linux_dr_get (tid, DR_STATUS);
}
-@@ -172,34 +182,34 @@ f77_print_array_1 (int nss, int ndimensions, struct type *type,
+-/* Unset MASK bits in DR_STATUS in all LWPs of LWP_LIST. */
++/* Helper for i386_linux_dr_unset_status. */
- if (nss != ndimensions)
- {
-- 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, "( ");
- f77_print_array_1 (nss + 1, ndimensions, TYPE_TARGET_TYPE (type),
-- valaddr + i * F77_DIM_OFFSET (nss),
-- address + i * F77_DIM_OFFSET (nss),
-+ valaddr + i * F77_DIM_BYTE_STRIDE (nss),
-+ address + i * F77_DIM_BYTE_STRIDE (nss),
- stream, recurse, val, options, elts);
- fprintf_filtered (stream, ") ");
- }
-- if (*elts >= options->print_max && i < F77_DIM_SIZE (nss))
-+ if (*elts >= options->print_max && i < F77_DIM_COUNT (nss))
- fprintf_filtered (stream, "...");
- }
- else
- {
-- for (i = 0; i < F77_DIM_SIZE (nss) && (*elts) < options->print_max;
-+ for (i = 0; i < F77_DIM_COUNT (nss) && (*elts) < options->print_max;
- i++, (*elts)++)
- {
- val_print (TYPE_TARGET_TYPE (type),
-- valaddr + i * F77_DIM_OFFSET (ndimensions),
-+ valaddr + i * F77_DIM_BYTE_STRIDE (ndimensions),
- 0,
-- address + i * F77_DIM_OFFSET (ndimensions),
-+ address + i * F77_DIM_BYTE_STRIDE (ndimensions),
- stream, recurse, val, options, current_language);
+ static void
+-i386_linux_dr_unset_status (unsigned long mask)
++i386_linux_dr_unset_status_callback (int tid, void *mask_voidp)
+ {
+- struct lwp_info *lp;
+- ptid_t ptid;
+-
+- ALL_LWPS (lp, ptid)
+- {
+- unsigned long value;
++ unsigned long mask = *(unsigned long *) mask_voidp;
++ unsigned long value;
+
+- value = i386_linux_dr_get (ptid, DR_STATUS);
+- value &= ~mask;
+- i386_linux_dr_set (ptid, DR_STATUS, value);
+- }
++ value = i386_linux_dr_get (tid, DR_STATUS);
++ value &= ~mask;
++ i386_linux_dr_set (tid, DR_STATUS, value);
++}
++
++/* Unset MASK bits in DR_STATUS in all LWPs of CURRENT_INFERIOR. */
++
++static void
++i386_linux_dr_unset_status (unsigned long mask)
++{
++ linux_nat_iterate_watchpoint_lwps (i386_linux_dr_unset_status_callback,
++ &mask);
+ }
-- if (i != (F77_DIM_SIZE (nss) - 1))
-+ if (i != (F77_DIM_COUNT (nss) - 1))
- fprintf_filtered (stream, ", ");
+ static void
+ i386_linux_new_thread (ptid_t ptid)
+ {
+- int i;
++ struct i386_dr_mirror *dr_mirror = i386_dr_mirror_get ();
++ int i, tid;
++
++ /* Verify DR_MIRROR is valid. */
++ gdb_assert (PIDGET (ptid) == PIDGET (inferior_ptid));
++
++ tid = TIDGET (ptid);
++ if (tid == 0)
++ tid = PIDGET (ptid);
- if ((*elts == options->print_max - 1)
-- && (i != (F77_DIM_SIZE (nss) - 1)))
-+ && (i != (F77_DIM_COUNT (nss) - 1)))
- fprintf_filtered (stream, "...");
- }
- }
-@@ -256,6 +266,9 @@ f_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
- CORE_ADDR addr;
- int index;
+- for (i = DR_FIRSTADDR; i <= DR_LASTADDR; i++)
+- i386_linux_dr_set (ptid, i, i386_linux_dr[i]);
++ for (i = 0; i < DR_LASTADDR - DR_FIRSTADDR; i++)
++ i386_linux_dr_set (tid, DR_FIRSTADDR + i, dr_mirror->addr[i]);
-+ if (f_object_address_data_valid_print_to_stream (type, stream) != NULL)
-+ return 0;
-+
- CHECK_TYPEDEF (type);
- switch (TYPE_CODE (type))
- {
-diff --git a/gdb/findcmd.c b/gdb/findcmd.c
-index ac63a9e..e9ba45c 100644
---- a/gdb/findcmd.c
-+++ b/gdb/findcmd.c
-@@ -45,6 +45,41 @@ put_bits (bfd_uint64_t data, char *buf, int bits, bfd_boolean big_p)
- }
+- i386_linux_dr_set (ptid, DR_CONTROL, i386_linux_dr[DR_CONTROL]);
++ i386_linux_dr_set (tid, DR_CONTROL, dr_mirror->control);
}
+ \f
+
+Index: gdb-7.2.90.20110703/gdb/i386-nat.c
+===================================================================
+--- gdb-7.2.90.20110703.orig/gdb/i386-nat.c 2011-02-26 23:04:51.000000000 +0100
++++ gdb-7.2.90.20110703/gdb/i386-nat.c 2011-07-03 10:33:11.000000000 +0200
+@@ -25,6 +25,7 @@
+ #include "gdbcmd.h"
+ #include "target.h"
+ #include "gdb_assert.h"
++#include "inferior.h"
-+/* 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. */
+ /* Support for hardware watchpoints and breakpoints using the i386
+ debug registers.
+@@ -44,7 +45,6 @@ struct i386_dr_low_type i386_dr_low;
+ #define TARGET_HAS_DR_LEN_8 (i386_dr_low.debug_register_length == 8)
+
+ /* Debug registers' indices. */
+-#define DR_NADDR 4 /* The number of debug address registers. */
+ #define DR_STATUS 6 /* Index of debug status register (DR6). */
+ #define DR_CONTROL 7 /* Index of debug control register (DR7). */
+
+@@ -111,49 +111,60 @@ struct i386_dr_low_type i386_dr_low;
+
+ /* The I'th debug register is vacant if its Local and Global Enable
+ bits are reset in the Debug Control register. */
+-#define I386_DR_VACANT(i) \
+- ((dr_control_mirror & (3 << (DR_ENABLE_SIZE * (i)))) == 0)
+
-+void
-+allocate_pattern_buffer (char **pattern_buf, char **pattern_buf_end,
-+ ULONGEST *pattern_buf_size)
++static inline int
++i386_dr_vacant (struct i386_dr_mirror *dr_mirror, int i)
+{
-+#define INITIAL_PATTERN_BUF_SIZE 100
-+ *pattern_buf_size = INITIAL_PATTERN_BUF_SIZE;
-+ *pattern_buf = xmalloc (*pattern_buf_size);
-+ *pattern_buf_end = *pattern_buf;
++ return (dr_mirror->control & (3 << (DR_ENABLE_SIZE * i))) == 0;
+}
+
+ /* Locally enable the break/watchpoint in the I'th debug register. */
+-#define I386_DR_LOCAL_ENABLE(i) \
+- dr_control_mirror |= (1 << (DR_LOCAL_ENABLE_SHIFT + DR_ENABLE_SIZE * (i)))
+
+-/* Globally enable the break/watchpoint in the I'th debug register. */
+-#define I386_DR_GLOBAL_ENABLE(i) \
+- dr_control_mirror |= (1 << (DR_GLOBAL_ENABLE_SHIFT + DR_ENABLE_SIZE * (i)))
++static inline void
++i386_dr_local_enable (struct i386_dr_mirror *dr_mirror, int i)
++{
++ dr_mirror->control |= 1 << (DR_LOCAL_ENABLE_SHIFT + DR_ENABLE_SIZE * i);
++}
+
+ /* Disable the break/watchpoint in the I'th debug register. */
+-#define I386_DR_DISABLE(i) \
+- dr_control_mirror &= ~(3 << (DR_ENABLE_SIZE * (i)))
+
-+/* 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)
++static inline void
++i386_dr_disable (struct i386_dr_mirror *dr_mirror, int i)
+{
-+ /* 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;
++ dr_mirror->control &= ~(3 << (DR_ENABLE_SIZE * i));
++}
+
+ /* Set in DR7 the RW and LEN fields for the I'th debug register. */
+-#define I386_DR_SET_RW_LEN(i,rwlen) \
+- do { \
+- dr_control_mirror &= ~(0x0f << (DR_CONTROL_SHIFT+DR_CONTROL_SIZE*(i))); \
+- dr_control_mirror |= ((rwlen) << (DR_CONTROL_SHIFT+DR_CONTROL_SIZE*(i))); \
+- } while (0)
+
-+ *pattern_buf_size *= 2;
-+ *pattern_buf = xrealloc (*pattern_buf, *pattern_buf_size);
-+ *pattern_buf_end = *pattern_buf + current_offset;
-+ }
++static inline void
++i386_dr_set_rw_len (struct i386_dr_mirror *dr_mirror, int i, unsigned rwlen)
++{
++ dr_mirror->control &= ~(0x0f << (DR_CONTROL_SHIFT + DR_CONTROL_SIZE * i));
++ dr_mirror->control |= rwlen << (DR_CONTROL_SHIFT + DR_CONTROL_SIZE * i);
+}
+
+ /* Get from DR7 the RW and LEN fields for the I'th debug register. */
+-#define I386_DR_GET_RW_LEN(i) \
+- ((dr_control_mirror >> (DR_CONTROL_SHIFT + DR_CONTROL_SIZE * (i))) & 0x0f)
+
- /* 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.
-@@ -175,17 +208,9 @@ parse_find_args (char *args, ULONGEST *max_countp,
- v = parse_to_comma_and_eval (&s);
- val_bytes = TYPE_LENGTH (value_type (v));
-
-- /* 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);
++static inline unsigned
++i386_dr_get_rw_len (struct i386_dr_mirror *dr_mirror, int i)
++{
++ return ((dr_mirror->control >> (DR_CONTROL_SHIFT + DR_CONTROL_SIZE * i))
++ & 0x0f);
++}
-- pattern_buf_size *= 2;
-- pattern_buf = xrealloc (pattern_buf, pattern_buf_size);
-- pattern_buf_end = pattern_buf + current_offset;
-- }
+ /* Mask that this I'th watchpoint has triggered. */
+ #define I386_DR_WATCH_MASK(i) (1 << (i))
- if (size != '\0')
- {
-@@ -240,6 +265,45 @@ parse_find_args (char *args, ULONGEST *max_countp,
- discard_cleanups (old_cleanups);
- }
+ /* Did the watchpoint whose address is in the I'th register break? */
+-#define I386_DR_WATCH_HIT(i) (dr_status_mirror & I386_DR_WATCH_MASK (i))
++static inline int
++i386_dr_watch_hit (struct i386_dr_mirror *dr_mirror, int i)
++{
++ return (dr_mirror->status & I386_DR_WATCH_MASK (i)) != 0;
++}
+
+ /* A macro to loop over all debug registers. */
+ #define ALL_DEBUG_REGISTERS(i) for (i = 0; i < DR_NADDR; i++)
+
+-/* Mirror the inferior's DRi registers. We keep the status and
+- control registers separated because they don't hold addresses. */
+-static CORE_ADDR dr_mirror[DR_NADDR];
+-static unsigned long dr_status_mirror, dr_control_mirror;
+-
+-/* Reference counts for each debug register. */
+-static int dr_ref_count[DR_NADDR];
+-
+ /* Whether or not to print the mirrored debug registers. */
+ static int maint_show_dr;
+
+@@ -195,21 +206,80 @@ static int i386_handle_nonaligned_watchp
-+/* 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.
+ /* Implementation. */
+
++/* Per-inferior data key. */
++static const struct inferior_data *i386_inferior_data;
++
++struct i386_inferior_data
++ {
++ /* Copy of i386 hardware debug registers for performance reasons. */
++ struct i386_dr_mirror dr_mirror;
++ };
+
-+ 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). */
++static void
++i386_inferior_data_cleanup (struct inferior *inf, void *arg)
++{
++ struct i386_inferior_data *inf_data = arg;
+
-+int
-+search_memory (CORE_ADDR *start_addr, ULONGEST *search_space_len,
-+ const char *pattern_buf, ULONGEST pattern_len,
-+ CORE_ADDR *found_addr)
++ xfree (inf_data);
++}
++
++static struct i386_inferior_data *
++i386_inferior_data_get (void)
+{
-+ /* 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;
++ struct inferior *inf = current_inferior ();
++ struct i386_inferior_data *inf_data;
++
++ inf_data = inferior_data (inf, i386_inferior_data);
++ if (inf_data == NULL)
++ {
++ inf_data = xzalloc (sizeof (*inf_data));
++ set_inferior_data (current_inferior (), i386_inferior_data, inf_data);
++ }
+
-+ /* Begin next iteration at one byte past this match. */
-+ next_iter_incr = (*found_addr - *start_addr) + 1;
++ if (inf->pid != ptid_get_pid (inferior_ptid))
++ {
++ static struct i386_inferior_data detached_inf_data_local;
++ static int detached_inf_pid = -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;
++ if (detached_inf_pid != ptid_get_pid (inferior_ptid))
++ {
++ detached_inf_pid = ptid_get_pid (inferior_ptid);
++
++ /* Forked processes get a copy of the debug registers. */
++ memcpy (&detached_inf_data_local, inf_data,
++ sizeof (detached_inf_data_local));
++ detached_inf_data_local.dr_mirror.addr_preset = 0;
++ }
++
++ return &detached_inf_data_local;
++ }
+
-+ return found;
++ return inf_data;
+}
+
- static void
- find_command (char *args, int from_tty)
+ /* Clear the reference counts and forget everything we knew about the
+ debug registers. */
+
++struct i386_dr_mirror *
++i386_dr_mirror_get (void)
++{
++ return &i386_inferior_data_get ()->dr_mirror;
++}
++
+ void
+ i386_cleanup_dregs (void)
{
-@@ -270,12 +334,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;
++ struct i386_dr_mirror *dr_mirror = i386_dr_mirror_get ();
+ int i;
-@@ -283,16 +346,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;
+ ALL_DEBUG_REGISTERS(i)
+ {
+- dr_mirror[i] = 0;
+- dr_ref_count[i] = 0;
++ dr_mirror->addr[i] = 0;
++ dr_mirror->ref_count[i] = 0;
}
+- dr_control_mirror = 0;
+- dr_status_mirror = 0;
++ dr_mirror->addr_preset = 0;
++ dr_mirror->control = 0;
++ dr_mirror->status = 0;
+ }
- /* Record and print the results. */
-diff --git a/gdb/findvar.c b/gdb/findvar.c
-index e0ca12c..de6311a 100644
---- a/gdb/findvar.c
-+++ b/gdb/findvar.c
-@@ -35,6 +35,7 @@
- #include "user-regs.h"
- #include "block.h"
- #include "objfiles.h"
-+#include "dwarf2loc.h"
+ /* Print the values of the mirrored debug registers. This is called
+@@ -220,6 +290,7 @@ static void
+ i386_show_dr (const char *func, CORE_ADDR addr,
+ int len, enum target_hw_bp_type type)
+ {
++ struct i386_dr_mirror *dr_mirror = i386_dr_mirror_get ();
+ int addr_size = gdbarch_addr_bit (target_gdbarch) / 8;
+ int i;
- /* Basic byte-swapping routines. All 'extract' functions return a
- host-format integer from a target-format integer at ADDR which is
-@@ -401,27 +402,16 @@ symbol_read_needs_frame (struct symbol *sym)
- /* Given a struct symbol for a variable,
- and a stack frame id, read the value of the variable
- and return a (pointer to a) struct value containing the value.
-- If the variable cannot be found, return a zero pointer. */
-+ If the variable cannot be found, return a zero pointer.
-+ We have to first find the address of the variable before allocating struct
-+ value to return as its size may depend on DW_OP_PUSH_OBJECT_ADDRESS possibly
-+ used by its type. */
+@@ -239,13 +310,16 @@ i386_show_dr (const char *func, CORE_ADD
+ : "??unknown??"))));
+ puts_unfiltered (":\n");
+ printf_unfiltered ("\tCONTROL (DR7): %s STATUS (DR6): %s\n",
+- phex (dr_control_mirror, 8), phex (dr_status_mirror, 8));
++ phex (dr_mirror->control, 8),
++ phex (dr_mirror->status, 8));
+ ALL_DEBUG_REGISTERS(i)
+ {
+ printf_unfiltered ("\
+ \tDR%d: addr=0x%s, ref.count=%d DR%d: addr=0x%s, ref.count=%d\n",
+- i, phex (dr_mirror[i], addr_size), dr_ref_count[i],
+- i+1, phex (dr_mirror[i+1], addr_size), dr_ref_count[i+1]);
++ i, phex (dr_mirror->addr[i], addr_size),
++ dr_mirror->ref_count[i], i + 1,
++ phex (dr_mirror->addr[i + 1], addr_size),
++ dr_mirror->ref_count[i + 1]);
+ i++;
+ }
+ }
+@@ -313,6 +387,7 @@ Invalid hardware breakpoint length %d in
+ static int
+ i386_insert_aligned_watchpoint (CORE_ADDR addr, unsigned len_rw_bits)
+ {
++ struct i386_dr_mirror *dr_mirror = i386_dr_mirror_get ();
+ int i;
- struct value *
- read_var_value (struct symbol *var, struct frame_info *frame)
+ if (!i386_dr_low.set_addr || !i386_dr_low.set_control)
+@@ -323,11 +398,10 @@ i386_insert_aligned_watchpoint (CORE_ADD
+ reuse it for this watchpoint as well (and save a register). */
+ ALL_DEBUG_REGISTERS(i)
+ {
+- if (!I386_DR_VACANT (i)
+- && dr_mirror[i] == addr
+- && I386_DR_GET_RW_LEN (i) == len_rw_bits)
++ if (!i386_dr_vacant (dr_mirror, i) && dr_mirror->addr[i] == addr
++ && i386_dr_get_rw_len (dr_mirror, i) == len_rw_bits)
+ {
+- dr_ref_count[i]++;
++ dr_mirror->ref_count[i]++;
+ return 0;
+ }
+ }
+@@ -335,7 +409,7 @@ i386_insert_aligned_watchpoint (CORE_ADD
+ /* Next, look for a vacant debug register. */
+ ALL_DEBUG_REGISTERS(i)
+ {
+- if (I386_DR_VACANT (i))
++ if (i386_dr_vacant (dr_mirror, i))
+ break;
+ }
+
+@@ -346,9 +420,9 @@ i386_insert_aligned_watchpoint (CORE_ADD
+ /* Now set up the register I to watch our region. */
+
+ /* Record the info in our local mirrored array. */
+- dr_mirror[i] = addr;
+- dr_ref_count[i] = 1;
+- I386_DR_SET_RW_LEN (i, len_rw_bits);
++ dr_mirror->addr[i] = addr;
++ dr_mirror->ref_count[i] = 1;
++ i386_dr_set_rw_len (dr_mirror, i, len_rw_bits);
+ /* Note: we only enable the watchpoint locally, i.e. in the current
+ task. Currently, no i386 target allows or supports global
+ watchpoints; however, if any target would want that in the
+@@ -356,13 +430,13 @@ i386_insert_aligned_watchpoint (CORE_ADD
+ to enable watchpoints globally or locally, and the code below
+ should use global or local enable and slow-down flags as
+ appropriate. */
+- I386_DR_LOCAL_ENABLE (i);
+- dr_control_mirror |= DR_LOCAL_SLOWDOWN;
+- dr_control_mirror &= I386_DR_CONTROL_MASK;
++ i386_dr_local_enable (dr_mirror, i);
++ dr_mirror->control |= DR_LOCAL_SLOWDOWN;
++ dr_mirror->control &= I386_DR_CONTROL_MASK;
+
+ /* Finally, actually pass the info to the inferior. */
+ i386_dr_low.set_addr (i, addr);
+- i386_dr_low.set_control (dr_control_mirror);
++ i386_dr_low.set_control (dr_mirror->control);
+
+ /* Only a sanity check for leftover bits (set possibly only by inferior). */
+ if (i386_dr_low.unset_status)
+@@ -380,21 +454,21 @@ i386_insert_aligned_watchpoint (CORE_ADD
+ static int
+ i386_remove_aligned_watchpoint (CORE_ADDR addr, unsigned len_rw_bits)
{
-- struct value *v;
- struct type *type = SYMBOL_TYPE (var);
- CORE_ADDR addr;
-- int len;
--
-- if (SYMBOL_CLASS (var) == LOC_COMPUTED
-- || SYMBOL_CLASS (var) == LOC_REGISTER)
-- /* These cases do not use V. */
-- v = NULL;
-- else
-- {
-- v = allocate_value (type);
-- VALUE_LVAL (v) = lval_memory; /* The most likely possibility. */
-- }
--
-- len = TYPE_LENGTH (type);
++ struct i386_dr_mirror *dr_mirror = i386_dr_mirror_get ();
+ int i, retval = -1;
- if (symbol_read_needs_frame (var))
- gdb_assert (frame);
-@@ -429,33 +419,43 @@ read_var_value (struct symbol *var, struct frame_info *frame)
- switch (SYMBOL_CLASS (var))
+ ALL_DEBUG_REGISTERS(i)
{
- case LOC_CONST:
-- /* Put the constant back in target format. */
-- store_signed_integer (value_contents_raw (v), len,
-- gdbarch_byte_order (get_type_arch (type)),
-- (LONGEST) SYMBOL_VALUE (var));
-- VALUE_LVAL (v) = not_lval;
-- return v;
-+ {
-+ /* Put the constant back in target format. */
-+ struct value *v = allocate_value (type);
-+ VALUE_LVAL (v) = not_lval;
-+ store_signed_integer (value_contents_raw (v), TYPE_LENGTH (type),
-+ gdbarch_byte_order (get_type_arch (type)),
-+ (LONGEST) SYMBOL_VALUE (var));
-+ return v;
-+ }
+- if (!I386_DR_VACANT (i)
+- && dr_mirror[i] == addr
+- && I386_DR_GET_RW_LEN (i) == len_rw_bits)
++ if (!i386_dr_vacant (dr_mirror, i) && dr_mirror->addr[i] == addr
++ && i386_dr_get_rw_len (dr_mirror, i) == len_rw_bits)
+ {
+- if (--dr_ref_count[i] == 0) /* no longer in use? */
++ if (--dr_mirror->ref_count[i] == 0) /* no longer in use? */
+ {
+ /* Reset our mirror. */
+- dr_mirror[i] = 0;
+- I386_DR_DISABLE (i);
++ dr_mirror->addr[i] = 0;
++ i386_dr_disable (dr_mirror, i);
+ /* Reset it in the inferior. */
+- i386_dr_low.set_control (dr_control_mirror);
++ i386_dr_low.set_control (dr_mirror->control);
+ if (i386_dr_low.reset_addr)
+ i386_dr_low.reset_addr (i);
+ }
+@@ -556,26 +630,27 @@ i386_region_ok_for_watchpoint (CORE_ADDR
+ static int
+ i386_stopped_data_address (struct target_ops *ops, CORE_ADDR *addr_p)
+ {
++ struct i386_dr_mirror *dr_mirror = i386_dr_mirror_get ();
+ CORE_ADDR addr = 0;
+ int i;
+ int rc = 0;
- case LOC_LABEL:
-- /* Put the constant back in target format. */
-- if (overlay_debugging)
-- {
-- CORE_ADDR addr
-- = symbol_overlayed_address (SYMBOL_VALUE_ADDRESS (var),
-- SYMBOL_OBJ_SECTION (var));
-+ {
-+ /* Put the constant back in target format. */
-+ struct value *v = allocate_value (type);
-+ VALUE_LVAL (v) = not_lval;
-+ if (overlay_debugging)
-+ {
-+ CORE_ADDR addr
-+ = symbol_overlayed_address (SYMBOL_VALUE_ADDRESS (var),
-+ SYMBOL_OBJ_SECTION (var));
+- dr_status_mirror = i386_dr_low.get_status ();
++ dr_mirror->status = i386_dr_low.get_status ();
-- store_typed_address (value_contents_raw (v), type, addr);
-- }
-- else
-- store_typed_address (value_contents_raw (v), type,
-- SYMBOL_VALUE_ADDRESS (var));
-- VALUE_LVAL (v) = not_lval;
-- return v;
-+ store_typed_address (value_contents_raw (v), type, addr);
-+ }
-+ else
-+ store_typed_address (value_contents_raw (v), type,
-+ SYMBOL_VALUE_ADDRESS (var));
-+ return v;
-+ }
+ ALL_DEBUG_REGISTERS(i)
+ {
+- if (I386_DR_WATCH_HIT (i)
++ if (i386_dr_watch_hit (dr_mirror, i)
+ /* This second condition makes sure DRi is set up for a data
+ watchpoint, not a hardware breakpoint. The reason is
+ that GDB doesn't call the target_stopped_data_address
+ method except for data watchpoints. In other words, I'm
+ being paranoiac. */
+- && I386_DR_GET_RW_LEN (i) != 0
++ && i386_dr_get_rw_len (dr_mirror, i) != 0
+ /* This third condition makes sure DRi is not vacant, this
+ avoids false positives in windows-nat.c. */
+- && !I386_DR_VACANT (i))
++ && !i386_dr_vacant (dr_mirror, i))
+ {
+- addr = dr_mirror[i];
++ addr = dr_mirror->addr[i];
+ rc = 1;
+ if (maint_show_dr)
+ i386_show_dr ("watchpoint_hit", addr, -1, hw_write);
+@@ -689,6 +764,10 @@ i386_use_watchpoints (struct target_ops
+ t->to_remove_watchpoint = i386_remove_watchpoint;
+ t->to_insert_hw_breakpoint = i386_insert_hw_breakpoint;
+ t->to_remove_hw_breakpoint = i386_remove_hw_breakpoint;
++
++ if (i386_inferior_data == NULL)
++ i386_inferior_data
++ = register_inferior_data_with_cleanup (i386_inferior_data_cleanup);
+ }
- case LOC_CONST_BYTES:
-- memcpy (value_contents_raw (v), SYMBOL_VALUE_BYTES (var), len);
-- VALUE_LVAL (v) = not_lval;
-- return v;
-+ {
-+ struct value *v = allocate_value (type);
-+ VALUE_LVAL (v) = not_lval;
-+ memcpy (value_contents_raw (v), SYMBOL_VALUE_BYTES (var),
-+ TYPE_LENGTH (type));
-+ return v;
-+ }
+ void
+Index: gdb-7.2.90.20110703/gdb/i386-nat.h
+===================================================================
+--- gdb-7.2.90.20110703.orig/gdb/i386-nat.h 2011-01-09 04:08:56.000000000 +0100
++++ gdb-7.2.90.20110703/gdb/i386-nat.h 2011-07-03 10:33:11.000000000 +0200
+@@ -78,6 +78,28 @@ struct i386_dr_low_type
- case LOC_STATIC:
- if (overlay_debugging)
-@@ -496,12 +496,23 @@ read_var_value (struct symbol *var, struct frame_info *frame)
- break;
+ extern struct i386_dr_low_type i386_dr_low;
- case LOC_BLOCK:
-- if (overlay_debugging)
-- set_value_address (v, symbol_overlayed_address
-- (BLOCK_START (SYMBOL_BLOCK_VALUE (var)), SYMBOL_OBJ_SECTION (var)));
-- else
-- set_value_address (v, BLOCK_START (SYMBOL_BLOCK_VALUE (var)));
-- return v;
-+ {
-+ CORE_ADDR addr;
-+ struct value *v;
++/* The number of debug address registers. */
++#define DR_NADDR 4
+
-+ if (overlay_debugging)
-+ addr = symbol_overlayed_address
-+ (BLOCK_START (SYMBOL_BLOCK_VALUE (var)), SYMBOL_OBJ_SECTION (var));
-+ else
-+ addr = BLOCK_START (SYMBOL_BLOCK_VALUE (var));
-+ /* ADDR is set here for ALLOCATE_VALUE's CHECK_TYPEDEF for
-+ DW_OP_push_object_address. */
-+ object_address_set (addr);
-+ v = allocate_value (type);
-+ VALUE_LVAL (v) = lval_memory;
-+ set_value_address (v, addr);
-+ return v;
-+ }
++/* Copy of hardware debug registers for performance reasons. */
++
++struct i386_dr_mirror
++ {
++ /* Mirror the inferior's DRi registers. We keep the status and
++ control registers separated because they don't hold addresses. */
++ CORE_ADDR addr[DR_NADDR];
++
++ /* All the ADDR hardware registers have been written at least once. */
++ unsigned addr_preset : 1;
++
++ /* Reference counts for each debug register. */
++ int ref_count[DR_NADDR];
++
++ unsigned long status, control;
++ };
++
++extern struct i386_dr_mirror *i386_dr_mirror_get (void);
++
+ /* Use this function to set i386_dr_low debug_register_length field
+ rather than setting it directly to check that the length is only
+ set once. It also enables the 'maint set/show show-debug-regs'
+Index: gdb-7.2.90.20110703/gdb/infrun.c
+===================================================================
+--- gdb-7.2.90.20110703.orig/gdb/infrun.c 2011-06-03 17:32:13.000000000 +0200
++++ gdb-7.2.90.20110703/gdb/infrun.c 2011-07-03 10:33:11.000000000 +0200
+@@ -54,6 +54,8 @@
+ #include "inline-frame.h"
+ #include "jit.h"
+ #include "tracepoint.h"
++#include "stap-probe.h"
++#include "objfiles.h"
- case LOC_REGISTER:
- case LOC_REGPARM_ADDR:
-@@ -520,7 +531,6 @@ read_var_value (struct symbol *var, struct frame_info *frame)
- error (_("Value of register variable not available."));
+ /* Prototypes for local functions */
- addr = value_as_address (regval);
-- VALUE_LVAL (v) = lval_memory;
+@@ -2247,7 +2249,7 @@ static void insert_step_resume_breakpoin
+ struct frame_id);
+ static void insert_longjmp_resume_breakpoint (struct gdbarch *, CORE_ADDR);
+ static void check_exception_resume (struct execution_control_state *,
+- struct frame_info *, struct symbol *);
++ struct frame_info *);
+
+ static void stop_stepping (struct execution_control_state *ecs);
+ static void prepare_to_wait (struct execution_control_state *ecs);
+@@ -4169,9 +4171,17 @@ process_event_stop_test:
+
+ if (what.is_longjmp)
+ {
+- if (!gdbarch_get_longjmp_target_p (gdbarch)
+- || !gdbarch_get_longjmp_target (gdbarch,
+- frame, &jmp_buf_pc))
++ struct value *arg_value;
++
++ /* If we set the longjmp breakpoint via a SystemTap probe,
++ then use it to extract the arguments. The destination
++ PC is the third argument to the probe. */
++ arg_value = stap_safe_evaluate_at_pc (frame, 2);
++ if (arg_value)
++ jmp_buf_pc = value_as_address (arg_value);
++ else if (!gdbarch_get_longjmp_target_p (gdbarch)
++ || !gdbarch_get_longjmp_target (gdbarch,
++ frame, &jmp_buf_pc))
+ {
+ if (debug_infrun)
+ fprintf_unfiltered (gdb_stdlog,
+@@ -4189,12 +4199,7 @@ process_event_stop_test:
+ insert_longjmp_resume_breakpoint (gdbarch, jmp_buf_pc);
}
else
- {
-@@ -563,18 +573,33 @@ read_var_value (struct symbol *var, struct frame_info *frame)
- break;
-
- case LOC_OPTIMIZED_OUT:
-- VALUE_LVAL (v) = not_lval;
-- set_value_optimized_out (v, 1);
-- return v;
-+ {
-+ struct value *v = allocate_value (type);
-+
-+ VALUE_LVAL (v) = not_lval;
-+ set_value_optimized_out (v, 1);
-+ return v;
-+ }
+- {
+- struct symbol *func = get_frame_function (frame);
+-
+- if (func)
+- check_exception_resume (ecs, frame, func);
+- }
++ check_exception_resume (ecs, frame);
+ keep_going (ecs);
+ return;
- default:
- error (_("Cannot look up value of a botched symbol."));
- break;
+@@ -5268,15 +5273,65 @@ insert_exception_resume_breakpoint (stru
}
+ }
-- set_value_address (v, addr);
-- set_value_lazy (v, 1);
-- return v;
-+ {
-+ struct value *v;
++/* A helper for check_exception_resume that sets an
++ exception-breakpoint based on a SystemTap probe. */
+
-+ /* ADDR is set here for ALLOCATE_VALUE's CHECK_TYPEDEF for
-+ DW_OP_PUSH_OBJECT_ADDRESS. */
-+ object_address_set (addr);
-+ v = allocate_value (type);
-+ VALUE_LVAL (v) = lval_memory;
-+ set_value_address (v, addr);
++static void
++insert_exception_resume_from_probe (struct thread_info *tp,
++ const struct stap_probe *probe,
++ struct objfile *objfile,
++ struct frame_info *frame)
++{
++ struct value *arg_value;
++ CORE_ADDR handler;
++ struct breakpoint *bp;
+
-+ set_value_lazy (v, 1);
++ arg_value = stap_safe_evaluate_at_pc (frame, 1);
++ if (!arg_value)
++ return;
+
-+ return v;
-+ }
- }
-
- /* Install default attributes for register values. */
-@@ -611,10 +636,11 @@ struct value *
- value_from_register (struct type *type, int regnum, struct frame_info *frame)
- {
- struct gdbarch *gdbarch = get_frame_arch (frame);
-- struct type *type1 = check_typedef (type);
- struct value *v;
-
-- if (gdbarch_convert_register_p (gdbarch, regnum, type1))
-+ type = check_typedef (type);
++ handler = value_as_address (arg_value);
+
-+ if (gdbarch_convert_register_p (gdbarch, regnum, type))
- {
- /* The ISA/ABI need to something weird when obtaining the
- specified value from this register. It might need to
-@@ -628,7 +654,7 @@ value_from_register (struct type *type, int regnum, struct frame_info *frame)
- VALUE_FRAME_ID (v) = get_frame_id (frame);
- VALUE_REGNUM (v) = regnum;
- gdbarch_register_to_value (gdbarch,
-- frame, regnum, type1, value_contents_raw (v));
-+ frame, regnum, type, value_contents_raw (v));
- }
- else
- {
-diff --git a/gdb/gdbcmd.h b/gdb/gdbcmd.h
-index 78151dd..da11686 100644
---- a/gdb/gdbcmd.h
-+++ b/gdb/gdbcmd.h
-@@ -124,6 +124,10 @@ extern struct cmd_list_element *setchecklist;
-
- extern struct cmd_list_element *showchecklist;
-
-+/* Chain containing all defined "save" subcommands. */
++ if (debug_infrun)
++ fprintf_unfiltered (gdb_stdlog,
++ "infrun: exception resume at %s\n",
++ paddress (get_objfile_arch (objfile),
++ handler));
+
-+extern struct cmd_list_element *save_cmdlist;
++ bp = set_momentary_breakpoint_at_pc (get_frame_arch (frame),
++ handler, bp_exception_resume);
++ bp->thread = tp->num;
++ inferior_thread ()->control.exception_resume_breakpoint = bp;
++}
+
- extern void execute_command (char *, int);
- extern char *execute_command_to_string (char *p, int from_tty);
-
-diff --git a/gdb/gdbinit.in b/gdb/gdbinit.in
-index ffb7f53..a2e7e94 100644
---- a/gdb/gdbinit.in
-+++ b/gdb/gdbinit.in
-@@ -1,5 +1,15 @@
- echo Setting up the environment for debugging gdb.\n
+ /* This is called when an exception has been intercepted. Check to
+ see whether the exception's destination is of interest, and if so,
+ set an exception resume breakpoint there. */
-+# 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
+ static void
+ check_exception_resume (struct execution_control_state *ecs,
+- struct frame_info *frame, struct symbol *func)
++ struct frame_info *frame)
+ {
+ struct gdb_exception e;
++ struct objfile *objfile;
++ const struct stap_probe *probe;
++ struct symbol *func;
+
- set complaints 1
-
- b internal_error
-diff --git a/gdb/gdbthread.h b/gdb/gdbthread.h
-index cd24eaf..9638368 100644
---- a/gdb/gdbthread.h
-+++ b/gdb/gdbthread.h
-@@ -66,6 +66,9 @@ struct thread_info
- /* Step-resume or longjmp-resume breakpoint. */
- struct breakpoint *step_resume_breakpoint;
-
-+ /* Exception-resume breakpoint. */
-+ struct breakpoint *exception_resume_breakpoint;
-+
- /* Range to single step within.
-
- If this is nonzero, respond to a single-step signal by continuing
-@@ -185,6 +188,10 @@ struct thread_info
- /* True if this thread has been explicitly requested to stop. */
- int stop_requested;
-
-+ /* The initiating frame of a nexting operation, used for deciding
-+ which exceptions to intercept. */
-+ struct frame_id initiating_frame;
-+
- /* Private data used by the target vector implementation. */
- struct private_thread_info *private;
-
-@@ -221,6 +228,9 @@ extern void delete_thread_silent (ptid_t);
- /* Delete a step_resume_breakpoint from the thread database. */
- extern void delete_step_resume_breakpoint (struct thread_info *);
-
-+/* Delete an exception_resume_breakpoint from the thread database. */
-+extern void delete_exception_resume_breakpoint (struct thread_info *);
-+
- /* Translate the integer thread id (GDB's homegrown id, not the system's)
- into a "pid" (which may be overloaded with extra thread information). */
- extern ptid_t thread_id_to_pid (int);
-diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c
-index 443f6f7..d852a14 100644
---- a/gdb/gdbtypes.c
-+++ b/gdb/gdbtypes.c
-@@ -39,6 +39,9 @@
- #include "cp-abi.h"
- #include "gdb_assert.h"
- #include "hashtab.h"
-+#include "observer.h"
-+#include "dwarf2expr.h"
-+#include "dwarf2loc.h"
++ /* First see if this exception unwinding breakpoint was set via a
++ SystemTap probe point. If so, the probe has two arguments: the
++ CFA and the HANDLER. We ignore the CFA, extract the handler, and
++ set a breakpoint there. */
++ probe = find_probe_by_pc (get_frame_pc (frame), &objfile);
++ if (probe)
++ {
++ insert_exception_resume_from_probe (ecs->event_thread, probe,
++ objfile, frame);
++ return;
++ }
++
++ func = get_frame_function (frame);
++ if (!func)
++ return;
+ TRY_CATCH (e, RETURN_MASK_ERROR)
+ {
+@@ -6258,7 +6313,8 @@ static struct lval_funcs siginfo_value_f
+ if there's no object available. */
- /* Floatformat pairs. */
-@@ -123,6 +126,11 @@ static void print_arg_types (struct field *, int, int);
- static void dump_fn_fieldlists (struct type *, int);
- static void print_cplus_stuff (struct type *, int);
+ static struct value *
+-siginfo_make_value (struct gdbarch *gdbarch, struct internalvar *var)
++siginfo_make_value (struct gdbarch *gdbarch, struct internalvar *var,
++ void *ignore)
+ {
+ if (target_has_stack
+ && !ptid_equal (inferior_ptid, null_ptid)
+@@ -6826,6 +6882,15 @@ show_schedule_multiple (struct ui_file *
+ "of all processes is %s.\n"), value);
+ }
-+/* The hash table holding all discardable `struct type *' references. */
-+static htab_t type_discardable_table;
++/* Implementation of `siginfo' variable. */
+
-+/* Current type_discardable_check pass used for TYPE_DISCARDABLE_AGE. */
-+static int type_discardable_age_current;
-
- /* Allocate a new OBJFILE-associated type structure and fill it
- with some defaults. Space for the type structure is allocated
-@@ -153,6 +161,39 @@ alloc_type (struct objfile *objfile)
- return type;
++static const struct internalvar_funcs siginfo_funcs =
++{
++ siginfo_make_value,
++ NULL,
++ NULL
++};
++
+ void
+ _initialize_infrun (void)
+ {
+@@ -7098,7 +7163,7 @@ Tells gdb whether to detach the child of
+ value with a void typed value, and when we get here, gdbarch
+ isn't initialized yet. At this point, we're quite sure there
+ isn't another convenience variable of the same name. */
+- create_internalvar_type_lazy ("_siginfo", siginfo_make_value);
++ create_internalvar_type_lazy ("_siginfo", &siginfo_funcs, NULL);
+
+ add_setshow_boolean_cmd ("observer", no_class,
+ &observer_mode_1, _("\
+Index: gdb-7.2.90.20110703/gdb/linespec.c
+===================================================================
+--- gdb-7.2.90.20110703.orig/gdb/linespec.c 2011-07-02 22:13:08.000000000 +0200
++++ gdb-7.2.90.20110703/gdb/linespec.c 2011-07-03 10:33:11.000000000 +0200
+@@ -43,6 +43,7 @@
+ #include "arch-utils.h"
+ #include <ctype.h>
+ #include "cli/cli-utils.h"
++#include "stap-probe.h"
+
+ /* We share this one with symtab.c, but it is not exported widely. */
+
+@@ -786,6 +787,7 @@ keep_name_info (char *p, int on_boundary
+ PC returned is 0.
+ FILE:FUNCTION -- likewise, but prefer functions in that file.
+ *EXPR -- line in which address EXPR appears.
++ probe:[OBJFILE:][PROVIDER:]NAME -- a systemtap static probe
+
+ This may all be followed by an "if EXPR", which we ignore.
+
+@@ -854,6 +856,9 @@ decode_line_1 (char **argptr, int funfir
+ if (**argptr == '*')
+ return decode_indirect (argptr);
+
++ if (strncmp (*argptr, "probe:", 6) == 0)
++ return parse_stap_probe (argptr, canonical);
++
+ is_quoted = (strchr (get_gdb_completer_quote_characters (),
+ **argptr) != NULL);
+
+Index: gdb-7.2.90.20110703/gdb/linespec.h
+===================================================================
+--- gdb-7.2.90.20110703.orig/gdb/linespec.h 2011-07-02 21:33:09.000000000 +0200
++++ gdb-7.2.90.20110703/gdb/linespec.h 2011-07-03 10:33:11.000000000 +0200
+@@ -30,6 +30,10 @@ struct linespec_result
+ display mechanism would do the wrong thing. */
+ int special_display;
+
++ /* If non-zero, the linespec result should be considered to be a
++ "pre-expanded" multi-location linespec. */
++ int pre_expanded;
++
+ /* If non-NULL, an array of canonical names for returned
+ symtab_and_line objects. The array has as many elements as the
+ `nelts' field in the symtabs_and_line returned by decode_line_1.
+Index: gdb-7.2.90.20110703/gdb/linux-nat.c
+===================================================================
+--- gdb-7.2.90.20110703.orig/gdb/linux-nat.c 2011-04-29 18:02:10.000000000 +0200
++++ gdb-7.2.90.20110703/gdb/linux-nat.c 2011-07-03 10:33:11.000000000 +0200
+@@ -1272,6 +1272,64 @@ iterate_over_lwps (ptid_t filter,
+ return NULL;
}
-+/* Declare TYPE as discardable on next garbage collection by free_all_types.
-+ You must call type_mark_used during each free_all_types to protect TYPE from
-+ being deallocated. */
++/* Helper for linux_nat_iterate_watchpoint_lwps. */
+
-+static void
-+set_type_as_discardable (struct type *type)
++struct iterate_watchpoint_lwps_data
++ {
++ linux_nat_iterate_watchpoint_lwps_ftype callback;
++ void *callback_data;
++ };
++
++static int
++iterate_watchpoint_lwps_callback (struct lwp_info *lp, void *datap_voidp)
+{
-+ void **slot;
++ struct iterate_watchpoint_lwps_data *datap = datap_voidp;
++ int tid;
+
-+ gdb_assert (!TYPE_DISCARDABLE (type));
++ tid = TIDGET (lp->ptid);
++ if (tid == 0)
++ tid = PIDGET (lp->ptid);
+
-+ TYPE_DISCARDABLE (type) = 1;
-+ TYPE_DISCARDABLE_AGE (type) = type_discardable_age_current;
++ datap->callback (tid, datap->callback_data);
+
-+ slot = htab_find_slot (type_discardable_table, type, INSERT);
-+ gdb_assert (!*slot);
-+ *slot = type;
++ /* Continue the traversal. */
++ return 0;
+}
+
-+/* Allocate a new type like alloc_type but preserve for it the discardability
-+ state of PARENT_TYPE. */
++/* Iterate like iterate_over_lwps does except when forking-off a child call
++ CALLBACK with CALLBACK_DATA specifically only for that new child PID.
+
-+static struct type *
-+alloc_type_as_parent (struct type *parent_type)
++ During `set follow-fork-mode child' the call is also made for the new child
++ PID; parent watchpoints get detached elsewhere (during target_detach). */
++
++void
++linux_nat_iterate_watchpoint_lwps
++ (linux_nat_iterate_watchpoint_lwps_ftype callback, void *callback_data)
+{
-+ struct type *new_type = alloc_type_copy (parent_type);
++ struct iterate_watchpoint_lwps_data data;
++ int inferior_pid = ptid_get_pid (inferior_ptid);
++ struct inferior *inf = current_inferior ();
+
-+ if (TYPE_DISCARDABLE (parent_type))
-+ set_type_as_discardable (new_type);
++ data.callback = callback;
++ data.callback_data = callback_data;
+
-+ return new_type;
++ if (inf->pid == inferior_pid)
++ {
++ /* Standard mode. Iterate all the threads of the current inferior.
++ Without specifying INFERIOR_PID it would iterate all the threads of
++ all the inferiors, which is inappropriate for watchpoints. */
++
++ iterate_over_lwps (pid_to_ptid (inferior_pid),
++ iterate_watchpoint_lwps_callback, &data);
++ }
++ else
++ {
++ /* Detaching a new child PID temporarily present in INFERIOR_PID. */
++
++ callback (inferior_pid, callback_data);
++ }
+}
+
- /* Allocate a new GDBARCH-associated type structure and fill it
- with some defaults. Space for the type structure is allocated
- on the heap. */
-@@ -278,7 +319,7 @@ make_pointer_type (struct type *type, struct type **typeptr)
-
- if (typeptr == 0 || *typeptr == 0) /* We'll need to allocate one. */
- {
-- ntype = alloc_type_copy (type);
-+ ntype = alloc_type_as_parent (type);
- if (typeptr)
- *typeptr = ntype;
- }
-@@ -355,7 +396,7 @@ make_reference_type (struct type *type, struct type **typeptr)
+ /* Update our internal state when changing from one checkpoint to
+ another indicated by NEW_PTID. We can only switch single-threaded
+ applications, so we only create one new LWP, and the previous list
+Index: gdb-7.2.90.20110703/gdb/linux-nat.h
+===================================================================
+--- gdb-7.2.90.20110703.orig/gdb/linux-nat.h 2011-01-05 23:22:49.000000000 +0100
++++ gdb-7.2.90.20110703/gdb/linux-nat.h 2011-07-03 10:33:11.000000000 +0200
+@@ -140,6 +140,11 @@ struct lwp_info *iterate_over_lwps (ptid
+ void *),
+ void *data);
- if (typeptr == 0 || *typeptr == 0) /* We'll need to allocate one. */
- {
-- ntype = alloc_type_copy (type);
-+ ntype = alloc_type_as_parent (type);
- if (typeptr)
- *typeptr = ntype;
- }
-@@ -726,6 +767,7 @@ create_range_type (struct type *result_type, struct type *index_type,
- TYPE_ZALLOC (result_type, sizeof (struct range_bounds));
- TYPE_LOW_BOUND (result_type) = low_bound;
- TYPE_HIGH_BOUND (result_type) = high_bound;
-+ TYPE_BYTE_STRIDE (result_type) = 0;
++typedef void (*linux_nat_iterate_watchpoint_lwps_ftype) (int tid, void *data);
++
++extern void linux_nat_iterate_watchpoint_lwps
++ (linux_nat_iterate_watchpoint_lwps_ftype callback, void *callback_data);
++
+ /* Create a prototype generic GNU/Linux target. The client can
+ override it with local methods. */
+ struct target_ops * linux_target (void);
+Index: gdb-7.2.90.20110703/gdb/machoread.c
+===================================================================
+--- gdb-7.2.90.20110703.orig/gdb/machoread.c 2011-03-07 17:17:29.000000000 +0100
++++ gdb-7.2.90.20110703/gdb/machoread.c 2011-07-03 10:33:11.000000000 +0200
+@@ -849,6 +849,7 @@ static const struct sym_fns macho_sym_fn
+ default_symfile_segments, /* Get segment information from a file. */
+ NULL,
+ macho_symfile_relocate, /* Relocate a debug section. */
++ NULL, /* sym_get_probes */
+ &psym_functions
+ };
- if (low_bound >= 0)
- TYPE_UNSIGNED (result_type) = 1;
-@@ -825,26 +867,45 @@ create_array_type (struct type *result_type,
+Index: gdb-7.2.90.20110703/gdb/main.c
+===================================================================
+--- gdb-7.2.90.20110703.orig/gdb/main.c 2011-03-07 19:34:31.000000000 +0100
++++ gdb-7.2.90.20110703/gdb/main.c 2011-07-03 10:33:11.000000000 +0200
+@@ -39,6 +39,7 @@
- TYPE_CODE (result_type) = TYPE_CODE_ARRAY;
- TYPE_TARGET_TYPE (result_type) = element_type;
-- if (get_discrete_bounds (range_type, &low_bound, &high_bound) < 0)
-- low_bound = high_bound = 0;
-- CHECK_TYPEDEF (element_type);
-- /* Be careful when setting the array length. Ada arrays can be
-- empty arrays with the high_bound being smaller than the low_bound.
-- In such cases, the array length should be zero. */
-- if (high_bound < low_bound)
-- TYPE_LENGTH (result_type) = 0;
-- else
-- TYPE_LENGTH (result_type) =
-- TYPE_LENGTH (element_type) * (high_bound - low_bound + 1);
- TYPE_NFIELDS (result_type) = 1;
- TYPE_FIELDS (result_type) =
- (struct field *) TYPE_ZALLOC (result_type, sizeof (struct field));
- TYPE_INDEX_TYPE (result_type) = range_type;
- TYPE_VPTR_FIELDNO (result_type) = -1;
+ #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;
-- /* TYPE_FLAG_TARGET_STUB will take care of zero length arrays */
-+ /* DWARF blocks may depend on runtime information like
-+ DW_OP_PUSH_OBJECT_ADDRESS not being available during the
-+ CREATE_ARRAY_TYPE time. */
-+ if (TYPE_RANGE_DATA (range_type)->low.kind != RANGE_BOUND_KIND_CONSTANT
-+ || TYPE_RANGE_DATA (range_type)->high.kind != RANGE_BOUND_KIND_CONSTANT
-+ || TYPE_LOW_BOUND_UNDEFINED (range_type)
-+ || TYPE_HIGH_BOUND_UNDEFINED (range_type)
-+ || get_discrete_bounds (range_type, &low_bound, &high_bound) < 0)
-+ {
-+ low_bound = 0;
-+ high_bound = -1;
-+ }
-+
-+ /* Be careful when setting the array length. Ada arrays can be
-+ empty arrays with the high_bound being smaller than the low_bound.
-+ In such cases, the array length should be zero. TYPE_TARGET_STUB needs to
-+ be checked as it may have dependencies on DWARF blocks depending on
-+ runtime information not available during the CREATE_ARRAY_TYPE time. */
-+ if (high_bound < low_bound || TYPE_TARGET_STUB (element_type))
-+ TYPE_LENGTH (result_type) = 0;
-+ else
-+ {
-+ CHECK_TYPEDEF (element_type);
-+ TYPE_LENGTH (result_type) =
-+ TYPE_LENGTH (element_type) * (high_bound - low_bound + 1);
-+ }
++ int python_script = 0;
+
- if (TYPE_LENGTH (result_type) == 0)
-- TYPE_TARGET_STUB (result_type) = 1;
-+ {
-+ /* The real size will be computed for specific instances by
-+ CHECK_TYPEDEF. */
-+ TYPE_TARGET_STUB (result_type) = 1;
-+ }
+ /* These are static so that we can take their address in an
+ initializer. */
+ static int print_help;
+@@ -451,10 +454,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}
+ };
- return result_type;
- }
-@@ -1353,6 +1414,105 @@ stub_noname_complaint (void)
- complaint (&symfile_complaints, _("stub type has NULL name"));
- }
+- while (1)
++ while (!python_script)
+ {
+ int option_index;
-+/* Calculate the memory length of array TYPE.
-+
-+ TARGET_TYPE should be set to `check_typedef (TYPE_TARGET_TYPE (type))' as
-+ a performance hint. Feel free to pass NULL. Set FULL_SPAN to return the
-+ size incl. the possible padding of the last element - it may differ from the
-+ cleared FULL_SPAN return value (the expected SIZEOF) for non-zero
-+ TYPE_BYTE_STRIDE values. */
-+
-+static LONGEST
-+type_length_get (struct type *type, struct type *target_type, int full_span)
-+{
-+ struct type *range_type;
-+ LONGEST byte_stride = 0; /* `= 0' for a false GCC warning. */
-+ LONGEST count, element_size, retval;
-+
-+ if (TYPE_CODE (type) != TYPE_CODE_ARRAY
-+ && TYPE_CODE (type) != TYPE_CODE_STRING)
-+ return TYPE_LENGTH (type);
-+
-+ /* Avoid executing TYPE_HIGH_BOUND for invalid (unallocated/unassociated)
-+ Fortran arrays. The allocated data will never be used so they can be
-+ zero-length. */
-+ if (object_address_data_not_valid (type))
-+ return 0;
-+
-+ range_type = TYPE_INDEX_TYPE (type);
-+ if (TYPE_LOW_BOUND_UNDEFINED (range_type)
-+ || TYPE_HIGH_BOUND_UNDEFINED (range_type))
-+ return 0;
-+ count = TYPE_HIGH_BOUND (range_type) - TYPE_LOW_BOUND (range_type) + 1;
-+ /* It may happen for wrong DWARF annotations returning garbage data. */
-+ if (count < 0)
-+ warning (_("Range for type %s has invalid bounds %s..%s"),
-+ TYPE_NAME (type), plongest (TYPE_LOW_BOUND (range_type)),
-+ plongest (TYPE_HIGH_BOUND (range_type)));
-+ /* The code below does not handle count == 0 right. */
-+ if (count <= 0)
-+ return 0;
-+ if (full_span || count > 1)
+@@ -472,6 +479,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;
+@@ -667,7 +677,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)
+ {
-+ /* We do not use TYPE_ARRAY_BYTE_STRIDE_VALUE (type) here as we want to
-+ force FULL_SPAN to 1. */
-+ byte_stride = TYPE_BYTE_STRIDE (range_type);
-+ if (byte_stride == 0)
-+ {
-+ if (target_type == NULL)
-+ target_type = check_typedef (TYPE_TARGET_TYPE (type));
-+ byte_stride = type_length_get (target_type, NULL, 1);
++ /* 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);
+ }
-+ }
-+
-+ /* For now, we conservatively take the array length to be 0 if its length
-+ exceeds UINT_MAX. The code below assumes that for x < 0,
-+ (ULONGEST) x == -x + ULONGEST_MAX + 1, which is technically not guaranteed
-+ by C, but is usually true (because it would be true if x were unsigned
-+ with its high-order bit on). It uses the fact that high_bound-low_bound is
-+ always representable in ULONGEST and that if high_bound-low_bound+1
-+ overflows, it overflows to 0. We must change these tests if we decide to
-+ increase the representation of TYPE_LENGTH from unsigned int to ULONGEST.
-+ */
+
-+ if (full_span)
-+ {
-+ retval = count * byte_stride;
-+ if (count == 0 || retval / count != byte_stride || retval > UINT_MAX)
-+ retval = 0;
-+ return retval;
++ /* 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;
+ }
-+ if (target_type == NULL)
-+ target_type = check_typedef (TYPE_TARGET_TYPE (type));
-+ element_size = type_length_get (target_type, NULL, 1);
-+ retval = (count - 1) * byte_stride + element_size;
-+ if (retval < element_size
-+ || (byte_stride != 0
-+ && (retval - element_size) / byte_stride != count - 1)
-+ || retval > UINT_MAX)
-+ retval = 0;
-+ return retval;
-+}
-+
-+/* Prepare TYPE after being read in by the backend. Currently this function
-+ only propagates the TYPE_DYNAMIC flag. */
-+
-+void
-+finalize_type (struct type *type)
-+{
-+ int i;
-+
-+ for (i = 0; i < TYPE_NFIELDS (type); ++i)
-+ if (TYPE_FIELD_TYPE (type, i) && TYPE_DYNAMIC (TYPE_FIELD_TYPE (type, i)))
-+ break;
-+
-+ /* FIXME: cplus_stuff is ignored here. */
-+ if (i < TYPE_NFIELDS (type)
-+ || (TYPE_VPTR_BASETYPE (type) && TYPE_DYNAMIC (TYPE_VPTR_BASETYPE (type)))
-+ || (TYPE_TARGET_TYPE (type) && TYPE_DYNAMIC (TYPE_TARGET_TYPE (type))))
-+ TYPE_DYNAMIC (type) = 1;
-+}
-+
- /* Added by Bryan Boreham, Kewill, Sun Sep 17 18:07:17 1989.
++ 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
+@@ -916,7 +950,8 @@ captured_main (void *data)
- If this is a stubbed struct (i.e. declared as struct foo *), see if
-@@ -1486,52 +1646,36 @@ check_typedef (struct type *type)
- }
- }
+ /* Read in the old history after all the command files have been
+ read. */
+- init_history ();
++ if (!python_script)
++ init_history ();
-- if (TYPE_TARGET_STUB (type))
-+ /* copy_type_recursive automatically makes the resulting type containing only
-+ constant values expected by the callers of this function. */
-+ if (TYPE_DYNAMIC (type))
-+ {
-+ htab_t copied_types;
-+ struct type *type_old = type;
-+
-+ copied_types = create_copied_types_hash (NULL);
-+ type = copy_type_recursive (type, copied_types);
-+ htab_delete (copied_types);
-+
-+ gdb_assert (TYPE_DYNAMIC (type) == 0);
-+ }
-+
-+ if (TYPE_TARGET_STUB (type) || TYPE_DYNAMIC (type))
+ if (batch_flag)
{
-- struct type *range_type;
- struct type *target_type = check_typedef (TYPE_TARGET_TYPE (type));
+@@ -927,13 +962,25 @@ captured_main (void *data)
+ /* Show time and/or space usage. */
+ do_cleanups (pre_stat_chain);
-+ if (TYPE_DYNAMIC (type))
-+ TYPE_TARGET_TYPE (type) = target_type;
- if (TYPE_STUB (target_type) || TYPE_TARGET_STUB (target_type))
- {
- /* Empty. */
- }
- else if (TYPE_CODE (type) == TYPE_CODE_ARRAY
-- && TYPE_NFIELDS (type) == 1
-- && (TYPE_CODE (range_type = TYPE_INDEX_TYPE (type))
-- == TYPE_CODE_RANGE))
-+ || TYPE_CODE (type) == TYPE_CODE_STRING)
- {
- /* Now recompute the length of the array type, based on its
-- number of elements and the target type's length.
-- Watch out for Ada null Ada arrays where the high bound
-- is smaller than the low bound. */
-- const LONGEST low_bound = TYPE_LOW_BOUND (range_type);
-- const LONGEST high_bound = TYPE_HIGH_BOUND (range_type);
-- ULONGEST len;
--
-- if (high_bound < low_bound)
-- len = 0;
-- else
-- {
-- /* For now, we conservatively take the array length to be 0
-- if its length exceeds UINT_MAX. The code below assumes
-- that for x < 0, (ULONGEST) x == -x + ULONGEST_MAX + 1,
-- which is technically not guaranteed by C, but is usually true
-- (because it would be true if x were unsigned with its
-- high-order bit on). It uses the fact that
-- high_bound-low_bound is always representable in
-- ULONGEST and that if high_bound-low_bound+1 overflows,
-- it overflows to 0. We must change these tests if we
-- decide to increase the representation of TYPE_LENGTH
-- from unsigned int to ULONGEST. */
-- ULONGEST ulow = low_bound, uhigh = high_bound;
-- ULONGEST tlen = TYPE_LENGTH (target_type);
--
-- len = tlen * (uhigh - ulow + 1);
-- if (tlen == 0 || (len / tlen - 1 + ulow) != uhigh
-- || len > UINT_MAX)
-- len = 0;
-- }
-- TYPE_LENGTH (type) = len;
-+ number of elements and the target type's length. */
-+ TYPE_LENGTH (type) = type_length_get (type, target_type, 0);
- TYPE_TARGET_STUB (type) = 0;
- }
- else if (TYPE_CODE (type) == TYPE_CODE_RANGE)
-@@ -1539,9 +1683,12 @@ check_typedef (struct type *type)
- TYPE_LENGTH (type) = TYPE_LENGTH (target_type);
- TYPE_TARGET_STUB (type) = 0;
- }
-+ TYPE_DYNAMIC (type) = 0;
+- /* 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);
++ }
}
-+
- /* Cache TYPE_LENGTH for future use. */
- TYPE_LENGTH (orig_type) = TYPE_LENGTH (type);
-+
- return type;
+ /* No exit -- exit is through quit_command. */
}
+@@ -965,7 +1012,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 (_("\
+@@ -1003,7 +1055,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);
+Index: gdb-7.2.90.20110703/gdb/mi/mi-cmd-var.c
+===================================================================
+--- gdb-7.2.90.20110703.orig/gdb/mi/mi-cmd-var.c 2011-01-12 22:09:39.000000000 +0100
++++ gdb-7.2.90.20110703/gdb/mi/mi-cmd-var.c 2011-07-03 10:33:11.000000000 +0200
+@@ -707,7 +707,6 @@ mi_cmd_var_update (char *command, char *
+ }
+ else
+ {
+- /* Get varobj handle, if a valid var obj name was specified */
+ struct varobj *var = varobj_get_handle (name);
-@@ -1811,6 +1958,8 @@ init_type (enum type_code code, int length, int flags,
- TYPE_NOTTEXT (type) = 1;
- if (flags & TYPE_FLAG_FIXED_INSTANCE)
- TYPE_FIXED_INSTANCE (type) = 1;
-+ if (flags & TYPE_FLAG_GNU_IFUNC)
-+ TYPE_GNU_IFUNC (type) = 1;
+ varobj_update_one (var, print_values, 1 /* explicit */);
+Index: gdb-7.2.90.20110703/gdb/mipsread.c
+===================================================================
+--- gdb-7.2.90.20110703.orig/gdb/mipsread.c 2011-03-07 17:17:29.000000000 +0100
++++ gdb-7.2.90.20110703/gdb/mipsread.c 2011-07-03 10:33:11.000000000 +0200
+@@ -402,6 +402,7 @@ static const struct sym_fns ecoff_sym_fn
+ default_symfile_segments, /* Get segment information from a file. */
+ NULL,
+ default_symfile_relocate, /* Relocate a debug section. */
++ NULL, /* sym_probe_fns */
+ &psym_functions
+ };
- if (name)
- TYPE_NAME (type) = obsavestring (name, strlen (name),
-@@ -3006,33 +3155,42 @@ type_pair_eq (const void *item_lhs, const void *item_rhs)
- }
+Index: gdb-7.2.90.20110703/gdb/objfiles.c
+===================================================================
+--- gdb-7.2.90.20110703.orig/gdb/objfiles.c 2011-04-25 23:25:18.000000000 +0200
++++ gdb-7.2.90.20110703/gdb/objfiles.c 2011-07-03 10:33:11.000000000 +0200
+@@ -846,6 +846,11 @@ objfile_relocate1 (struct objfile *objfi
+ obj_section_addr (s));
+ }
- /* Allocate the hash table used by copy_type_recursive to walk
-- types without duplicates. We use OBJFILE's obstack, because
-- OBJFILE is about to be deleted. */
-+ types without duplicates. */
++ /* Relocating SystemTap probes. */
++ if (objfile->sf && objfile->sf->sym_probe_fns)
++ objfile->sf->sym_probe_fns->sym_relocate_probe (objfile,
++ new_offsets, delta);
++
+ /* Data changed. */
+ return 1;
+ }
+Index: gdb-7.2.90.20110703/gdb/p-valprint.c
+===================================================================
+--- gdb-7.2.90.20110703.orig/gdb/p-valprint.c 2011-03-15 17:00:56.000000000 +0100
++++ gdb-7.2.90.20110703/gdb/p-valprint.c 2011-07-03 10:33:11.000000000 +0200
+@@ -39,6 +39,7 @@
+ #include "cp-abi.h"
+ #include "cp-support.h"
+ #include "exceptions.h"
++#include "dwarf2loc.h"
+ \f
- htab_t
- create_copied_types_hash (struct objfile *objfile)
- {
-- return htab_create_alloc_ex (1, type_pair_hash, type_pair_eq,
-- NULL, &objfile->objfile_obstack,
-- hashtab_obstack_allocate,
-- dummy_obstack_deallocate);
-+ if (objfile == NULL)
+ /* See val_print for a description of the various parameters of this
+@@ -63,8 +64,31 @@ pascal_val_print (struct type *type, con
+ struct type *char_type;
+ LONGEST val;
+ CORE_ADDR addr;
++ struct cleanup *back_to;
++ struct type *saved_type = type;
++ CORE_ADDR saved_address = address;
++
++ back_to = make_cleanup (null_cleanup, 0);
++ address += embedded_offset;
++ type = object_address_get_data (type, &address);
++ if (type == NULL)
+ {
-+ /* NULL OBJFILE is for TYPE_DYNAMIC types already contained in
-+ OBJFILE_MALLOC memory, such as those from VALUE_HISTORY_CHAIN. Table
-+ element entries get allocated by xmalloc - so use xfree. */
-+ return htab_create (1, type_pair_hash, type_pair_eq, xfree);
++ fputs_filtered (object_address_data_not_valid (saved_type), stream);
++ gdb_flush (stream);
++ do_cleanups (back_to);
++ return 0;
+ }
-+ else
++ if (address != saved_address + embedded_offset)
+ {
-+ /* Use OBJFILE's obstack, because OBJFILE is about to be deleted. Table
-+ element entries get allocated by xmalloc - so use xfree. */
-+ return htab_create_alloc_ex (1, type_pair_hash, type_pair_eq,
-+ xfree, &objfile->objfile_obstack,
-+ hashtab_obstack_allocate,
-+ dummy_obstack_deallocate);
++ size_t length = TYPE_LENGTH (type);
+
+- CHECK_TYPEDEF (type);
++ valaddr = xmalloc (length);
++ make_cleanup (xfree, (gdb_byte *) valaddr);
++ read_memory (address, (gdb_byte *) valaddr, length);
++ embedded_offset = 0;
+ }
++ else
++ address -= embedded_offset;
+ switch (TYPE_CODE (type))
+ {
+ case TYPE_CODE_ARRAY:
+@@ -120,8 +144,8 @@ pascal_val_print (struct type *type, con
+ {
+ i = 0;
+ }
+- 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);
+ fprintf_filtered (stream, "}");
+ }
+@@ -160,6 +184,7 @@ pascal_val_print (struct type *type, con
+ /* Try to print what function it points to. */
+ print_address_demangle (gdbarch, addr, stream, demangle);
+ /* Return value is irrelevant except for string pointers. */
++ do_cleanups (back_to);
+ return (0);
+ }
+
+@@ -251,6 +276,7 @@ pascal_val_print (struct type *type, con
+ /* Return number of characters printed, including the terminating
+ '\0' if we reached the end. val_print_string takes care including
+ the terminating '\0' if necessary. */
++ do_cleanups (back_to);
+ return i;
+
+ break;
+@@ -567,6 +593,7 @@ pascal_val_print (struct type *type, con
+ TYPE_CODE (type));
+ }
+ gdb_flush (stream);
++ do_cleanups (back_to);
+ return (0);
}
+ \f
+Index: gdb-7.2.90.20110703/gdb/parse.c
+===================================================================
+--- gdb-7.2.90.20110703.orig/gdb/parse.c 2011-03-28 22:21:03.000000000 +0200
++++ gdb-7.2.90.20110703/gdb/parse.c 2011-07-03 10:33:11.000000000 +0200
+@@ -1502,6 +1502,7 @@ parser_fprintf (FILE *x, const char *y,
--/* Recursively copy (deep copy) TYPE, if it is associated with
-- OBJFILE. Return a new type allocated using malloc, a saved type if
-- we have already visited TYPE (using COPIED_TYPES), or TYPE if it is
-- not associated with OBJFILE. */
-+/* A helper for copy_type_recursive. This does all the work. OBJFILE is used
-+ only for an assertion checking. */
+ int
+ operator_check_standard (struct expression *exp, int pos,
++ int (*type_func) (struct type *type, void *data),
+ int (*objfile_func) (struct objfile *objfile,
+ void *data),
+ void *data)
+@@ -1543,7 +1544,7 @@ operator_check_standard (struct expressi
+ struct type *type = elts[pos + 2 + arg].type;
+ struct objfile *objfile = TYPE_OBJFILE (type);
--struct type *
--copy_type_recursive (struct objfile *objfile,
-- struct type *type,
-- htab_t copied_types)
-+static struct type *
-+copy_type_recursive_1 (struct objfile *objfile,
-+ struct type *type,
-+ htab_t copied_types)
- {
- struct type_pair *stored, pair;
- void **slot;
- struct type *new_type;
+- if (objfile && (*objfile_func) (objfile, data))
++ if (objfile && objfile_func && (*objfile_func) (objfile, data))
+ return 1;
+ }
+ }
+@@ -1561,7 +1562,8 @@ operator_check_standard (struct expressi
-- if (! TYPE_OBJFILE_OWNED (type))
-+ if (! TYPE_OBJFILE_OWNED (type) && !TYPE_DYNAMIC (type))
- return type;
+ /* Check objfile where the variable itself is placed.
+ SYMBOL_OBJ_SECTION (symbol) may be NULL. */
+- if ((*objfile_func) (SYMBOL_SYMTAB (symbol)->objfile, data))
++ if (objfile_func
++ && (*objfile_func) (SYMBOL_SYMTAB (symbol)->objfile, data))
+ return 1;
- /* This type shouldn't be pointing to any types in other objfiles;
-@@ -3047,8 +3205,10 @@ copy_type_recursive (struct objfile *objfile,
- new_type = alloc_type_arch (get_type_arch (type));
+ /* Check objfile where is placed the code touching the variable. */
+@@ -1574,24 +1576,27 @@ operator_check_standard (struct expressi
- /* 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));
-+ 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. */
-+ stored = xmalloc (sizeof (*stored));
- stored->old = type;
- stored->new = new_type;
- *slot = stored;
-@@ -3059,6 +3219,19 @@ copy_type_recursive (struct objfile *objfile,
- TYPE_OBJFILE_OWNED (new_type) = 0;
- TYPE_OWNER (new_type).gdbarch = get_type_arch (type);
+ /* Invoke callbacks for TYPE and OBJFILE if they were set as non-NULL. */
-+ /* TYPE_MAIN_TYPE memory copy above rewrote the TYPE_DISCARDABLE flag so we
-+ need to initialize it again. And even if TYPE was already discardable
-+ NEW_TYPE so far is not registered in TYPE_DISCARDABLE_TABLE. */
-+ TYPE_DISCARDABLE (new_type) = 0;
-+ set_type_as_discardable (new_type);
-+
-+ /* Pre-clear the fields processed by delete_main_type. If DWARF block
-+ evaluations below call error we would leave an unfreeable TYPE. */
-+ TYPE_TARGET_TYPE (new_type) = NULL;
-+ TYPE_VPTR_BASETYPE (new_type) = NULL;
-+ TYPE_NFIELDS (new_type) = 0;
-+ TYPE_FIELDS (new_type) = NULL;
-+
- if (TYPE_NAME (type))
- TYPE_NAME (new_type) = xstrdup (TYPE_NAME (type));
- if (TYPE_TAG_NAME (type))
-@@ -3067,12 +3240,48 @@ copy_type_recursive (struct objfile *objfile,
- TYPE_INSTANCE_FLAGS (new_type) = TYPE_INSTANCE_FLAGS (type);
- TYPE_LENGTH (new_type) = TYPE_LENGTH (type);
+- if (type && TYPE_OBJFILE (type)
++ if (type && type_func && (*type_func) (type, data))
++ return 1;
++ if (type && TYPE_OBJFILE (type) && objfile_func
+ && (*objfile_func) (TYPE_OBJFILE (type), data))
+ return 1;
+- if (objfile && (*objfile_func) (objfile, data))
++ if (objfile && objfile_func && (*objfile_func) (objfile, data))
+ return 1;
+
+ return 0;
+ }
+
+-/* Call OBJFILE_FUNC for any TYPE and OBJFILE found being referenced by EXP.
+- The functions are never called with NULL OBJFILE. Functions get passed an
+- arbitrary caller supplied DATA pointer. If any of the functions returns
+- non-zero value then (any other) non-zero value is immediately returned to
+- the caller. Otherwise zero is returned after iterating through whole EXP.
+- */
++/* Call TYPE_FUNC and OBJFILE_FUNC for any TYPE and OBJFILE found being
++ referenced by EXP. The functions are never called with NULL TYPE or NULL
++ OBJFILE. Functions get passed an arbitrary caller supplied DATA pointer.
++ If any of the functions returns non-zero value then (any other) non-zero
++ value is immediately returned to the caller. Otherwise zero is returned
++ after iterating through whole EXP. */
+
+ static int
+ exp_iterate (struct expression *exp,
++ int (*type_func) (struct type *type, void *data),
+ int (*objfile_func) (struct objfile *objfile, void *data),
+ void *data)
+ {
+@@ -1606,7 +1611,9 @@ exp_iterate (struct expression *exp,
+
+ pos = endpos - oplen;
+ if (exp->language_defn->la_exp_desc->operator_check (exp, pos,
+- objfile_func, data))
++ type_func,
++ objfile_func,
++ data))
+ return 1;
-+ if (TYPE_ALLOCATED (new_type))
-+ {
-+ gdb_assert (!TYPE_NOT_ALLOCATED (new_type));
+ endpos = pos;
+@@ -1637,8 +1644,29 @@ exp_uses_objfile (struct expression *exp
+ {
+ gdb_assert (objfile->separate_debug_objfile_backlink == NULL);
+
+- return exp_iterate (exp, exp_uses_objfile_iter, objfile);
++ return exp_iterate (exp, NULL, exp_uses_objfile_iter, objfile);
++}
+
-+ if (!dwarf_locexpr_baton_eval (TYPE_ALLOCATED (new_type)))
-+ TYPE_NOT_ALLOCATED (new_type) = 1;
-+ TYPE_ALLOCATED (new_type) = NULL;
-+ }
++/* Helper for exp_types_mark_used. */
+
-+ if (TYPE_ASSOCIATED (new_type))
-+ {
-+ gdb_assert (!TYPE_NOT_ASSOCIATED (new_type));
++#if 0
++static int
++exp_types_mark_used_iter (struct type *type, void *unused)
++{
++ type_mark_used (type);
+
-+ if (!dwarf_locexpr_baton_eval (TYPE_ASSOCIATED (new_type)))
-+ TYPE_NOT_ASSOCIATED (new_type) = 1;
-+ TYPE_ASSOCIATED (new_type) = NULL;
-+ }
++ /* Continue the traversal. */
++ return 0;
++}
+
-+ if (!TYPE_DATA_LOCATION_IS_ADDR (new_type)
-+ && TYPE_DATA_LOCATION_DWARF_BLOCK (new_type))
-+ {
-+ if (TYPE_NOT_ALLOCATED (new_type)
-+ || TYPE_NOT_ASSOCIATED (new_type))
-+ TYPE_DATA_LOCATION_DWARF_BLOCK (new_type) = NULL;
-+ else
-+ {
-+ TYPE_DATA_LOCATION_IS_ADDR (new_type) = 1;
-+ TYPE_DATA_LOCATION_ADDR (new_type) = dwarf_locexpr_baton_eval
-+ (TYPE_DATA_LOCATION_DWARF_BLOCK (new_type));
-+ }
-+ }
++/* Call type_mark_used for any type contained in EXP. */
+
- /* Copy the fields. */
- if (TYPE_NFIELDS (type))
- {
- int i, nfields;
++void
++exp_types_mark_used (struct expression *exp)
++{
++ exp_iterate (exp, exp_types_mark_used_iter, NULL, NULL);
+ }
++#endif
-+ /* TYPE_CODE_RANGE uses TYPE_RANGE_DATA of the union with TYPE_FIELDS. */
-+ gdb_assert (TYPE_CODE (type) != TYPE_CODE_RANGE);
-+
- nfields = TYPE_NFIELDS (type);
-+ TYPE_NFIELDS (new_type) = nfields;
- TYPE_FIELDS (new_type) = XCALLOC (nfields, struct field);
- for (i = 0; i < nfields; i++)
- {
-@@ -3081,8 +3290,8 @@ copy_type_recursive (struct objfile *objfile,
- TYPE_FIELD_BITSIZE (new_type, i) = TYPE_FIELD_BITSIZE (type, i);
- if (TYPE_FIELD_TYPE (type, i))
- TYPE_FIELD_TYPE (new_type, i)
-- = copy_type_recursive (objfile, TYPE_FIELD_TYPE (type, i),
-- copied_types);
-+ = copy_type_recursive_1 (objfile, TYPE_FIELD_TYPE (type, i),
-+ copied_types);
- if (TYPE_FIELD_NAME (type, i))
- TYPE_FIELD_NAME (new_type, i) =
- xstrdup (TYPE_FIELD_NAME (type, i));
-@@ -3109,24 +3318,166 @@ copy_type_recursive (struct objfile *objfile,
- }
- }
+ void
+ _initialize_parse (void)
+Index: gdb-7.2.90.20110703/gdb/parser-defs.h
+===================================================================
+--- gdb-7.2.90.20110703.orig/gdb/parser-defs.h 2011-01-10 21:38:49.000000000 +0100
++++ gdb-7.2.90.20110703/gdb/parser-defs.h 2011-07-03 10:33:11.000000000 +0200
+@@ -194,6 +194,8 @@ extern void operator_length_standard (co
+ int *);
-+ /* Both FIELD_LOC_KIND_DWARF_BLOCK and TYPE_RANGE_HIGH_BOUND_IS_COUNT were
-+ possibly converted. */
-+ TYPE_DYNAMIC (new_type) = 0;
-+
- /* For range types, copy the bounds information. */
-- if (TYPE_CODE (type) == TYPE_CODE_RANGE)
-+ if (TYPE_CODE (new_type) == TYPE_CODE_RANGE)
- {
- TYPE_RANGE_DATA (new_type) = xmalloc (sizeof (struct range_bounds));
- *TYPE_RANGE_DATA (new_type) = *TYPE_RANGE_DATA (type);
-+
-+ switch (TYPE_RANGE_DATA (new_type)->low.kind)
-+ {
-+ case RANGE_BOUND_KIND_CONSTANT:
-+ break;
-+ case RANGE_BOUND_KIND_DWARF_BLOCK:
-+ /* `struct dwarf2_locexpr_baton' is too bound to its objfile so
-+ it is expected to be made constant by CHECK_TYPEDEF.
-+ TYPE_NOT_ALLOCATED and TYPE_NOT_ASSOCIATED are not valid for TYPE.
-+ */
-+ if (TYPE_NOT_ALLOCATED (new_type) || TYPE_NOT_ASSOCIATED (new_type)
-+ || ! has_stack_frames ())
-+ {
-+ /* We should set 1 for Fortran but how to find the language? */
-+ TYPE_LOW_BOUND (new_type) = 0;
-+ TYPE_LOW_BOUND_UNDEFINED (new_type) = 1;
-+ }
-+ else
-+ TYPE_LOW_BOUND (new_type) = dwarf_locexpr_baton_eval
-+ (TYPE_RANGE_DATA (new_type)->low.u.dwarf_block);
-+ TYPE_RANGE_DATA (new_type)->low.kind = RANGE_BOUND_KIND_CONSTANT;
-+ break;
-+ case RANGE_BOUND_KIND_DWARF_LOCLIST:
-+ {
-+ CORE_ADDR addr;
-+
-+ /* `struct dwarf2_loclist_baton' is too bound to its objfile so
-+ it is expected to be made constant by CHECK_TYPEDEF.
-+ TYPE_NOT_ALLOCATED and TYPE_NOT_ASSOCIATED are not valid for TYPE.
-+ */
-+ if (! TYPE_NOT_ALLOCATED (new_type)
-+ && ! TYPE_NOT_ASSOCIATED (new_type) && has_stack_frames ()
-+ && dwarf_loclist_baton_eval
-+ (TYPE_RANGE_DATA (new_type)->low.u.dwarf_loclist.loclist,
-+ TYPE_RANGE_DATA (new_type)->low.u.dwarf_loclist.type, &addr))
-+ TYPE_LOW_BOUND (new_type) = addr;
-+ else
-+ {
-+ /* We should set 1 for Fortran but how to find the language? */
-+ TYPE_LOW_BOUND (new_type) = 0;
-+ TYPE_LOW_BOUND_UNDEFINED (new_type) = 1;
-+ }
-+ TYPE_RANGE_DATA (new_type)->low.kind = RANGE_BOUND_KIND_CONSTANT;
-+ }
-+ break;
-+ }
+ extern int operator_check_standard (struct expression *exp, int pos,
++ int (*type_func) (struct type *type,
++ void *data),
+ int (*objfile_func)
+ (struct objfile *objfile, void *data),
+ void *data);
+@@ -291,6 +293,7 @@ struct exp_descriptor
+ value should be immediately returned to the caller. Otherwise zero
+ should be returned. */
+ int (*operator_check) (struct expression *exp, int pos,
++ int (*type_func) (struct type *type, void *data),
+ int (*objfile_func) (struct objfile *objfile,
+ void *data),
+ void *data);
+@@ -329,4 +332,10 @@ extern void parser_fprintf (FILE *, cons
+
+ extern int exp_uses_objfile (struct expression *exp, struct objfile *objfile);
+
++extern int exp_uses_objfile (struct expression *exp, struct objfile *objfile);
+
-+ switch (TYPE_RANGE_DATA (new_type)->high.kind)
-+ {
-+ case RANGE_BOUND_KIND_CONSTANT:
-+ break;
-+ case RANGE_BOUND_KIND_DWARF_BLOCK:
-+ /* `struct dwarf2_locexpr_baton' is too bound to its objfile so
-+ it is expected to be made constant by CHECK_TYPEDEF.
-+ TYPE_NOT_ALLOCATED and TYPE_NOT_ASSOCIATED are not valid for TYPE.
-+ */
-+ if (TYPE_NOT_ALLOCATED (new_type) || TYPE_NOT_ASSOCIATED (new_type)
-+ || ! has_stack_frames ())
-+ {
-+ TYPE_HIGH_BOUND (new_type) = TYPE_LOW_BOUND (new_type) - 1;
-+ TYPE_HIGH_BOUND_UNDEFINED (new_type) = 1;
-+ }
-+ else
-+ TYPE_HIGH_BOUND (new_type) = dwarf_locexpr_baton_eval
-+ (TYPE_RANGE_DATA (new_type)->high.u.dwarf_block);
-+ TYPE_RANGE_DATA (new_type)->high.kind = RANGE_BOUND_KIND_CONSTANT;
-+ break;
-+ case RANGE_BOUND_KIND_DWARF_LOCLIST:
-+ {
-+ CORE_ADDR addr;
++#if 0
++extern void exp_types_mark_used (struct expression *exp);
++#endif
+
-+ /* `struct dwarf2_loclist_baton' is too bound to its objfile so
-+ it is expected to be made constant by CHECK_TYPEDEF.
-+ TYPE_NOT_ALLOCATED and TYPE_NOT_ASSOCIATED are not valid for TYPE.
-+ */
-+ if (! TYPE_NOT_ALLOCATED (new_type)
-+ && ! TYPE_NOT_ASSOCIATED (new_type) && has_stack_frames ()
-+ && dwarf_loclist_baton_eval
-+ (TYPE_RANGE_DATA (new_type)->high.u.dwarf_loclist.loclist,
-+ TYPE_RANGE_DATA (new_type)->high.u.dwarf_loclist.type,
-+ &addr))
-+ TYPE_HIGH_BOUND (new_type) = addr;
-+ else
-+ {
-+ TYPE_HIGH_BOUND (new_type) = TYPE_LOW_BOUND (new_type) - 1;
-+ TYPE_HIGH_BOUND_UNDEFINED (new_type) = 1;
-+ }
-+ TYPE_RANGE_DATA (new_type)->high.kind = RANGE_BOUND_KIND_CONSTANT;
-+ }
-+ break;
-+ }
+ #endif /* PARSER_DEFS_H */
+Index: gdb-7.2.90.20110703/gdb/ppc-linux-nat.c
+===================================================================
+--- gdb-7.2.90.20110703.orig/gdb/ppc-linux-nat.c 2011-04-18 23:29:18.000000000 +0200
++++ gdb-7.2.90.20110703/gdb/ppc-linux-nat.c 2011-07-03 10:33:11.000000000 +0200
+@@ -1637,6 +1637,14 @@ booke_remove_point (struct ppc_hw_breakp
+ hw_breaks[i].hw_break = NULL;
+ }
+
++static void
++booke_insert_point_callback (int tid, void *pp_voidp)
++{
++ struct ppc_hw_breakpoint *pp = pp_voidp;
+
-+ switch (TYPE_RANGE_DATA (new_type)->byte_stride.kind)
-+ {
-+ case RANGE_BOUND_KIND_CONSTANT:
-+ break;
-+ case RANGE_BOUND_KIND_DWARF_BLOCK:
-+ /* `struct dwarf2_locexpr_baton' is too bound to its objfile so
-+ it is expected to be made constant by CHECK_TYPEDEF.
-+ TYPE_NOT_ALLOCATED and TYPE_NOT_ASSOCIATED are not valid for TYPE.
-+ */
-+ if (TYPE_NOT_ALLOCATED (new_type) || TYPE_NOT_ASSOCIATED (new_type)
-+ || ! has_stack_frames ())
-+ TYPE_BYTE_STRIDE (new_type) = 0;
-+ else
-+ TYPE_BYTE_STRIDE (new_type) = dwarf_locexpr_baton_eval
-+ (TYPE_RANGE_DATA (new_type)->byte_stride.u.dwarf_block);
-+ TYPE_RANGE_DATA (new_type)->byte_stride.kind
-+ = RANGE_BOUND_KIND_CONSTANT;
-+ break;
-+ case RANGE_BOUND_KIND_DWARF_LOCLIST:
-+ {
-+ CORE_ADDR addr = 0;
++ booke_insert_point (pp, tid);
++}
+
-+ /* `struct dwarf2_loclist_baton' is too bound to its objfile so
-+ it is expected to be made constant by CHECK_TYPEDEF.
-+ TYPE_NOT_ALLOCATED and TYPE_NOT_ASSOCIATED are not valid for TYPE.
-+ */
-+ if (! TYPE_NOT_ALLOCATED (new_type)
-+ && ! TYPE_NOT_ASSOCIATED (new_type) && has_stack_frames ())
-+ dwarf_loclist_baton_eval
-+ (TYPE_RANGE_DATA (new_type)->byte_stride.u.dwarf_loclist.loclist,
-+ TYPE_RANGE_DATA (new_type)->byte_stride.u.dwarf_loclist.type,
-+ &addr);
-+ TYPE_BYTE_STRIDE (new_type) = addr;
-+ TYPE_RANGE_DATA (new_type)->byte_stride.kind
-+ = RANGE_BOUND_KIND_CONSTANT;
-+ }
-+ break;
-+ }
+ /* Return the number of registers needed for a ranged breakpoint. */
+
+ static int
+@@ -1654,8 +1662,6 @@ static int
+ ppc_linux_insert_hw_breakpoint (struct gdbarch *gdbarch,
+ struct bp_target_info *bp_tgt)
+ {
+- ptid_t ptid;
+- struct lwp_info *lp;
+ struct ppc_hw_breakpoint p;
+
+ if (!have_ptrace_booke_interface ())
+@@ -1681,18 +1687,23 @@ ppc_linux_insert_hw_breakpoint (struct g
+ p.addr2 = 0;
+ }
+
+- ALL_LWPS (lp, ptid)
+- booke_insert_point (&p, TIDGET (ptid));
++ linux_nat_iterate_watchpoint_lwps (booke_insert_point_callback, &p);
+
+ return 0;
+ }
+
++static void
++booke_remove_point_callback (int tid, void *pp_voidp)
++{
++ struct ppc_hw_breakpoint *pp = pp_voidp;
+
-+ /* Convert TYPE_RANGE_HIGH_BOUND_IS_COUNT into a regular bound. */
-+ if (TYPE_RANGE_HIGH_BOUND_IS_COUNT (new_type))
-+ {
-+ TYPE_HIGH_BOUND (new_type) = TYPE_LOW_BOUND (new_type)
-+ + TYPE_HIGH_BOUND (new_type) - 1;
-+ TYPE_RANGE_HIGH_BOUND_IS_COUNT (new_type) = 0;
-+ }
++ booke_remove_point (pp, tid);
++}
++
+ static int
+ ppc_linux_remove_hw_breakpoint (struct gdbarch *gdbarch,
+ struct bp_target_info *bp_tgt)
+ {
+- ptid_t ptid;
+- struct lwp_info *lp;
+ struct ppc_hw_breakpoint p;
+
+ if (!have_ptrace_booke_interface ())
+@@ -1718,8 +1729,7 @@ ppc_linux_remove_hw_breakpoint (struct g
+ p.addr2 = 0;
}
- /* Copy pointers to other types. */
- if (TYPE_TARGET_TYPE (type))
- TYPE_TARGET_TYPE (new_type) =
-- copy_type_recursive (objfile,
-- TYPE_TARGET_TYPE (type),
-- copied_types);
-+ copy_type_recursive_1 (objfile,
-+ TYPE_TARGET_TYPE (type),
-+ copied_types);
- if (TYPE_VPTR_BASETYPE (type))
- TYPE_VPTR_BASETYPE (new_type) =
-- copy_type_recursive (objfile,
-- TYPE_VPTR_BASETYPE (type),
-- copied_types);
-+ copy_type_recursive_1 (objfile,
-+ TYPE_VPTR_BASETYPE (type),
-+ copied_types);
- /* Maybe copy the type_specific bits.
+- ALL_LWPS (lp, ptid)
+- booke_remove_point (&p, TIDGET (ptid));
++ linux_nat_iterate_watchpoint_lwps (booke_remove_point_callback, &p);
- NOTE drow/2005-12-09: We do not copy the C++-specific bits like
-@@ -3143,6 +3494,17 @@ copy_type_recursive (struct objfile *objfile,
- return new_type;
+ return 0;
+ }
+@@ -1946,6 +1956,15 @@ ppc_linux_can_accel_watchpoint_condition
+ && check_condition (addr, cond, &data_value, &len));
}
-+/* Recursively copy (deep copy) TYPE. Return a new type allocated using
-+ malloc, a saved type if we have already visited TYPE (using COPIED_TYPES),
-+ or TYPE if it is not associated with OBJFILE. */
-+
-+struct type *
-+copy_type_recursive (struct type *type,
-+ htab_t copied_types)
++static void
++set_saved_dabr_value_callback (int tid, void *retp_voidp)
+{
-+ return copy_type_recursive_1 (TYPE_OBJFILE (type), type, copied_types);
++ int *retp = retp_voidp;
++
++ if (ptrace (PTRACE_SET_DEBUGREG, tid, 0, saved_dabr_value) < 0)
++ *retp = -1;
+}
+
- /* Make a copy of the given TYPE, except that the pointer & reference
- types are not preserved.
-
-@@ -3165,6 +3527,199 @@ copy_type (const struct type *type)
- return new_type;
- }
+ /* Set up P with the parameters necessary to request a watchpoint covering
+ LEN bytes starting at ADDR and if possible with condition expression COND
+ evaluated by hardware. INSERT tells if we are creating a request for
+@@ -2000,8 +2019,6 @@ static int
+ ppc_linux_insert_watchpoint (CORE_ADDR addr, int len, int rw,
+ struct expression *cond)
+ {
+- struct lwp_info *lp;
+- ptid_t ptid;
+ int ret = -1;
-+/* Callback type for main_type_crawl. */
-+typedef int (*main_type_crawl_iter) (struct type *type, void *data);
+ if (have_ptrace_booke_interface ())
+@@ -2010,8 +2027,7 @@ ppc_linux_insert_watchpoint (CORE_ADDR a
+
+ create_watchpoint_request (&p, addr, len, rw, cond, 1);
+
+- ALL_LWPS (lp, ptid)
+- booke_insert_point (&p, TIDGET (ptid));
++ linux_nat_iterate_watchpoint_lwps (booke_insert_point_callback, &p);
+
+ ret = 0;
+ }
+@@ -2054,12 +2070,8 @@ ppc_linux_insert_watchpoint (CORE_ADDR a
+
+ saved_dabr_value = dabr_value;
+
+- ALL_LWPS (lp, ptid)
+- if (ptrace (PTRACE_SET_DEBUGREG, TIDGET (ptid), 0,
+- saved_dabr_value) < 0)
+- return -1;
+-
+ ret = 0;
++ linux_nat_iterate_watchpoint_lwps (set_saved_dabr_value_callback, &ret);
+ }
+
+ return ret;
+@@ -2069,8 +2081,6 @@ static int
+ ppc_linux_remove_watchpoint (CORE_ADDR addr, int len, int rw,
+ struct expression *cond)
+ {
+- struct lwp_info *lp;
+- ptid_t ptid;
+ int ret = -1;
+
+ if (have_ptrace_booke_interface ())
+@@ -2079,20 +2089,16 @@ ppc_linux_remove_watchpoint (CORE_ADDR a
+
+ create_watchpoint_request (&p, addr, len, rw, cond, 0);
+
+- ALL_LWPS (lp, ptid)
+- booke_remove_point (&p, TIDGET (ptid));
++ linux_nat_iterate_watchpoint_lwps (booke_remove_point_callback, &p);
+
+ ret = 0;
+ }
+ else
+ {
+ saved_dabr_value = 0;
+- ALL_LWPS (lp, ptid)
+- if (ptrace (PTRACE_SET_DEBUGREG, TIDGET (ptid), 0,
+- saved_dabr_value) < 0)
+- return -1;
+
+ ret = 0;
++ linux_nat_iterate_watchpoint_lwps (set_saved_dabr_value_callback, &ret);
+ }
+
+ return ret;
+Index: gdb-7.2.90.20110703/gdb/printcmd.c
+===================================================================
+--- gdb-7.2.90.20110703.orig/gdb/printcmd.c 2011-03-22 15:39:40.000000000 +0100
++++ gdb-7.2.90.20110703/gdb/printcmd.c 2011-07-03 10:33:11.000000000 +0200
+@@ -975,6 +975,11 @@ print_command_1 (char *exp, int inspect,
+ else
+ val = access_value_history (0);
+
++ /* Do not try to OBJECT_ADDRESS_SET here anything. We are interested in the
++ source variable base addresses as found by READ_VAR_VALUE. The value here
++ can be already a calculated expression address inappropriate for
++ DW_OP_push_object_address. */
+
-+/* Iterate all main_type structures reachable through any `struct type *' from
-+ TYPE. ITER will be called only for one type of each main_type, use
-+ TYPE_CHAIN traversal to find all the type instances. ITER is being called
-+ for each main_type found. ITER returns non-zero if main_type_crawl should
-+ depth-first enter the specific type. ITER must provide some detection for
-+ reentering the same main_type as this function would otherwise endlessly
-+ loop. */
+ if (voidprint || (val && value_type (val) &&
+ TYPE_CODE (value_type (val)) != TYPE_CODE_VOID))
+ {
+@@ -1476,6 +1481,24 @@ x_command (char *exp, int from_tty)
+ set_internalvar (lookup_internalvar ("__"), last_examine_value);
+ }
+ }
++
++#if 0
++/* Call type_mark_used for any TYPEs referenced from this GDB source file. */
+
+static void
-+main_type_crawl (struct type *type, main_type_crawl_iter iter, void *data)
++print_types_mark_used (void)
+{
-+ struct type *type_iter;
-+ int i;
++ struct display *d;
+
-+ if (!type)
-+ return;
++ if (last_examine_value)
++ type_mark_used (value_type (last_examine_value));
+
-+ gdb_assert (TYPE_OBJFILE (type) == NULL);
++ for (d = display_chain; d; d = d->next)
++ if (d->exp)
++ exp_types_mark_used (d->exp);
++}
++#endif
+
-+ /* `struct cplus_struct_type' handling is unsupported by this function. */
-+ gdb_assert ((TYPE_CODE (type) != TYPE_CODE_STRUCT
-+ && TYPE_CODE (type) != TYPE_CODE_UNION)
-+ || !HAVE_CPLUS_STRUCT (type));
+ \f
+
+ /* Add an expression to the auto-display chain.
+@@ -2870,4 +2893,8 @@ Show printing of source filename and lin
+ add_com ("eval", no_class, eval_command, _("\
+ Convert \"printf format string\", arg1, arg2, arg3, ..., argn to\n\
+ a command line, and call it."));
+
-+ if (!(*iter) (type, data))
-+ return;
++#if 0
++ observer_attach_mark_used (print_types_mark_used);
++#endif
+ }
+Index: gdb-7.2.90.20110703/gdb/python/lib/gdb/FrameIterator.py
+===================================================================
+--- /dev/null 1970-01-01 00:00:00.000000000 +0000
++++ gdb-7.2.90.20110703/gdb/python/lib/gdb/FrameIterator.py 2011-07-03 10:33:11.000000000 +0200
+@@ -0,0 +1,33 @@
++# Iterator over frames.
+
-+ /* Iterate all the type instances of this main_type. */
-+ type_iter = type;
-+ do
-+ {
-+ gdb_assert (TYPE_MAIN_TYPE (type_iter) == TYPE_MAIN_TYPE (type));
++# Copyright (C) 2008, 2009 Free Software Foundation, Inc.
+
-+ main_type_crawl (TYPE_POINTER_TYPE (type), iter, data);
-+ main_type_crawl (TYPE_REFERENCE_TYPE (type), iter, data);
++# This program is free software; you can redistribute it and/or modify
++# it under the terms of the GNU General Public License as published by
++# the Free Software Foundation; either version 3 of the License, or
++# (at your option) any later version.
++#
++# This program is distributed in the hope that it will be useful,
++# but WITHOUT ANY WARRANTY; without even the implied warranty of
++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++# GNU General Public License for more details.
++#
++# You should have received a copy of the GNU General Public License
++# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
-+ type_iter = TYPE_CHAIN (type_iter);
-+ }
-+ while (type_iter != type);
++class FrameIterator:
++ """An iterator that iterates over frames."""
+
-+ for (i = 0; i < TYPE_NFIELDS (type); i++)
-+ main_type_crawl (TYPE_FIELD_TYPE (type, i), iter, data);
++ def __init__ (self, frame):
++ "Initialize a FrameIterator. FRAME is the starting frame."
++ self.frame = frame
+
-+ main_type_crawl (TYPE_TARGET_TYPE (type), iter, data);
-+ main_type_crawl (TYPE_VPTR_BASETYPE (type), iter, data);
-+}
++ def __iter__ (self):
++ return self
+
-+/* A helper for delete_type which deletes a main_type and the things to which
-+ it refers. TYPE is a type whose main_type we wish to destroy. */
++ def next (self):
++ result = self.frame
++ if result is None:
++ raise StopIteration
++ self.frame = result.older ()
++ return result
+Index: gdb-7.2.90.20110703/gdb/python/lib/gdb/FrameWrapper.py
+===================================================================
+--- /dev/null 1970-01-01 00:00:00.000000000 +0000
++++ gdb-7.2.90.20110703/gdb/python/lib/gdb/FrameWrapper.py 2011-07-03 10:33:11.000000000 +0200
+@@ -0,0 +1,112 @@
++# Wrapper API for frames.
+
-+static void
-+delete_main_type (struct type *type)
-+{
-+ int i;
++# Copyright (C) 2008, 2009 Free Software Foundation, Inc.
+
-+ gdb_assert (TYPE_DISCARDABLE (type));
-+ gdb_assert (TYPE_OBJFILE (type) == NULL);
++# This program is free software; you can redistribute it and/or modify
++# it under the terms of the GNU General Public License as published by
++# the Free Software Foundation; either version 3 of the License, or
++# (at your option) any later version.
++#
++# This program is distributed in the hope that it will be useful,
++# but WITHOUT ANY WARRANTY; without even the implied warranty of
++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++# GNU General Public License for more details.
++#
++# You should have received a copy of the GNU General Public License
++# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
-+ xfree (TYPE_NAME (type));
-+ xfree (TYPE_TAG_NAME (type));
++import gdb
+
-+ for (i = 0; i < TYPE_NFIELDS (type); ++i)
-+ {
-+ xfree (TYPE_FIELD_NAME (type, i));
++# FIXME: arguably all this should be on Frame somehow.
++class FrameWrapper:
++ def __init__ (self, frame):
++ self.frame = frame;
+
-+ if (TYPE_FIELD_LOC_KIND (type, i) == FIELD_LOC_KIND_PHYSNAME)
-+ xfree (TYPE_FIELD_STATIC_PHYSNAME (type, i));
-+ }
-+ xfree (TYPE_FIELDS (type));
++ 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 (" <function called from gdb>\n")
++ elif self.type () == gdb.SIGTRAMP_FRAME:
++ stream.write (" <signal handler called>\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 + " (")
+
-+ gdb_assert (!HAVE_CPLUS_STRUCT (type));
++ func = self.function ()
++ self.print_frame_args (stream, func)
+
-+ xfree (TYPE_MAIN_TYPE (type));
-+}
++ stream.write (")")
+
-+/* Delete all the instances on TYPE_CHAIN of TYPE, including their referenced
-+ main_type. TYPE must be a reclaimable type - neither permanent nor objfile
-+ associated. */
++ if sal.symtab and sal.symtab.filename:
++ stream.write (" at " + sal.symtab.filename)
++ stream.write (":" + str (sal.line))
+
-+static void
-+delete_type_chain (struct type *type)
-+{
-+ struct type *type_iter, *type_iter_to_free;
++ if not self.name () or (not sal.symtab or not sal.symtab.filename):
++ lib = gdb.solib_address (pc)
++ if lib:
++ stream.write (" from " + lib)
+
-+ gdb_assert (TYPE_DISCARDABLE (type));
-+ gdb_assert (TYPE_OBJFILE (type) == NULL);
++ stream.write ("\n")
+
-+ delete_main_type (type);
++ if full:
++ self.print_frame_locals (stream, func)
+
-+ type_iter = type;
-+ do
-+ {
-+ type_iter_to_free = type_iter;
-+ type_iter = TYPE_CHAIN (type_iter);
-+ xfree (type_iter_to_free);
-+ }
-+ while (type_iter != type);
-+}
++ def __getattr__ (self, name):
++ return getattr (self.frame, name)
+Index: gdb-7.2.90.20110703/gdb/python/lib/gdb/backtrace.py
+===================================================================
+--- /dev/null 1970-01-01 00:00:00.000000000 +0000
++++ gdb-7.2.90.20110703/gdb/python/lib/gdb/backtrace.py 2011-07-03 10:33:11.000000000 +0200
+@@ -0,0 +1,42 @@
++# Filtering backtrace.
+
-+/* Hash function for type_discardable_table. */
++# Copyright (C) 2008, 2011 Free Software Foundation, Inc.
+
-+static hashval_t
-+type_discardable_hash (const void *p)
-+{
-+ const struct type *type = p;
++# This program is free software; you can redistribute it and/or modify
++# it under the terms of the GNU General Public License as published by
++# the Free Software Foundation; either version 3 of the License, or
++# (at your option) any later version.
++#
++# This program is distributed in the hope that it will be useful,
++# but WITHOUT ANY WARRANTY; without even the implied warranty of
++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++# GNU General Public License for more details.
++#
++# You should have received a copy of the GNU General Public License
++# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
-+ return htab_hash_pointer (TYPE_MAIN_TYPE (type));
-+}
++import gdb
++import itertools
+
-+/* Equality function for type_discardable_table. */
++# Our only exports.
++__all__ = ['push_frame_filter', 'create_frame_filter']
+
-+static int
-+type_discardable_equal (const void *a, const void *b)
-+{
-+ const struct type *left = a;
-+ const struct type *right = b;
++frame_filter = None
+
-+ return TYPE_MAIN_TYPE (left) == TYPE_MAIN_TYPE (right);
-+}
++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, filter = frame_filter: constructor (filter (iterator))
+
-+/* A helper for type_mark_used. */
++def create_frame_filter (iter):
++ global frame_filter
++ if frame_filter is None:
++ return iter
++ return frame_filter (iter)
+
-+static int
-+type_mark_used_crawl (struct type *type, void *unused)
-+{
-+ if (!TYPE_DISCARDABLE (type))
-+ return 0;
+Index: gdb-7.2.90.20110703/gdb/python/lib/gdb/command/alias.py
+===================================================================
+--- /dev/null 1970-01-01 00:00:00.000000000 +0000
++++ gdb-7.2.90.20110703/gdb/python/lib/gdb/command/alias.py 2011-07-03 10:33:11.000000000 +0200
+@@ -0,0 +1,59 @@
++# Alias command.
+
-+ if (TYPE_DISCARDABLE_AGE (type) == type_discardable_age_current)
-+ return 0;
++# Copyright (C) 2008 Free Software Foundation, Inc.
+
-+ TYPE_DISCARDABLE_AGE (type) = type_discardable_age_current;
++# This program is free software; you can redistribute it and/or modify
++# it under the terms of the GNU General Public License as published by
++# the Free Software Foundation; either version 3 of the License, or
++# (at your option) any later version.
++#
++# This program is distributed in the hope that it will be useful,
++# but WITHOUT ANY WARRANTY; without even the implied warranty of
++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++# GNU General Public License for more details.
++#
++# You should have received a copy of the GNU General Public License
++# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
-+ /* Continue the traversal. */
-+ return 1;
-+}
++import gdb
+
-+/* Mark TYPE and its connected types as used in this free_all_types pass. */
++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
+
-+void
-+type_mark_used (struct type *type)
-+{
-+ if (type == NULL)
-+ return;
++ def invoke(self, arg, from_tty):
++ gdb.execute (self.real + ' ' + arg, from_tty)
+
-+ if (!TYPE_DISCARDABLE (type))
-+ return;
++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."""
+
-+ main_type_crawl (type, type_mark_used_crawl, NULL);
-+}
++ def __init__ (self):
++ # Completion is not quite right here.
++ super (AliasCommand, self).__init__ ("alias", gdb.COMMAND_NONE,
++ gdb.COMPLETE_COMMAND)
+
-+/* A traverse callback for type_discardable_table which removes any
-+ type_discardable whose reference count is now zero (unused link). */
++ 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)
+
-+static int
-+type_discardable_remove (void **slot, void *unused)
-+{
-+ struct type *type = *slot;
++AliasCommand()
+Index: gdb-7.2.90.20110703/gdb/python/lib/gdb/command/backtrace.py
+===================================================================
+--- /dev/null 1970-01-01 00:00:00.000000000 +0000
++++ gdb-7.2.90.20110703/gdb/python/lib/gdb/command/backtrace.py 2011-07-03 10:33:11.000000000 +0200
+@@ -0,0 +1,106 @@
++# New backtrace command.
+
-+ gdb_assert (TYPE_DISCARDABLE (type));
++# Copyright (C) 2008, 2009, 2011 Free Software Foundation, Inc.
+
-+ if (TYPE_DISCARDABLE_AGE (type) != type_discardable_age_current)
-+ {
-+ delete_type_chain (type);
++# This program is free software; you can redistribute it and/or modify
++# it under the terms of the GNU General Public License as published by
++# the Free Software Foundation; either version 3 of the License, or
++# (at your option) any later version.
++#
++# This program is distributed in the hope that it will be useful,
++# but WITHOUT ANY WARRANTY; without even the implied warranty of
++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++# GNU General Public License for more details.
++#
++# You should have received a copy of the GNU General Public License
++# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
-+ htab_clear_slot (type_discardable_table, slot);
-+ }
++import gdb
++import gdb.backtrace
++import itertools
++from gdb.FrameIterator import FrameIterator
++from gdb.FrameWrapper import FrameWrapper
++import sys
+
-+ return 1;
-+}
++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."""
+
-+/* Free all the reclaimable types that have been allocated and that have
-+ currently zero reference counter.
++ set_doc = "Enable or disable reverse backtraces."
++ show_doc = "Show whether backtraces will be printed in reverse order."
+
-+ This function is called after each command, successful or not. Use this
-+ cleanup only in the GDB idle state as GDB only marks those types used by
-+ globally tracked objects (with no autovariable references tracking). */
++ def __init__(self):
++ gdb.Parameter.__init__ (self, "reverse-backtrace",
++ gdb.COMMAND_STACK, gdb.PARAM_BOOLEAN)
++ # Default to compatibility with gdb.
++ self.value = False
+
-+void
-+free_all_types (void)
-+{
-+ /* Mark a new pass. As GDB checks all the entries were visited after each
-+ pass there cannot be any stale entries already containing the changed
-+ value. */
-+ type_discardable_age_current ^= 1;
++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.
++"""
+
-+ observer_notify_mark_used ();
++ 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()
+
-+ htab_traverse (type_discardable_table, type_discardable_remove, NULL);
-+}
-
- /* Helper functions to initialize architecture-specific types. */
-
-@@ -3511,6 +4066,8 @@ gdbtypes_post_init (struct gdbarch *gdbarch)
- = lookup_pointer_type (builtin_type->builtin_void);
- builtin_type->builtin_func_ptr
- = lookup_pointer_type (lookup_function_type (builtin_type->builtin_void));
-+ builtin_type->builtin_func_func
-+ = lookup_function_type (builtin_type->builtin_func_ptr);
-
- /* This type represents a GDB internal function. */
- builtin_type->internal_fn
-@@ -3624,6 +4181,18 @@ objfile_type (struct objfile *objfile)
- "<text variable, no debug info>", objfile);
- TYPE_TARGET_TYPE (objfile_type->nodebug_text_symbol)
- = objfile_type->builtin_int;
-+ objfile_type->nodebug_text_gnu_ifunc_symbol
-+ = init_type (TYPE_CODE_FUNC, 1, TYPE_FLAG_GNU_IFUNC,
-+ "<text gnu-indirect-function variable, no debug info>",
-+ objfile);
-+ TYPE_TARGET_TYPE (objfile_type->nodebug_text_gnu_ifunc_symbol)
-+ = objfile_type->nodebug_text_symbol;
-+ objfile_type->nodebug_got_plt_symbol
-+ = init_type (TYPE_CODE_PTR, gdbarch_addr_bit (gdbarch) / 8, 0,
-+ "<text from jump slot in .got.plt, no debug info>",
-+ objfile);
-+ TYPE_TARGET_TYPE (objfile_type->nodebug_got_plt_symbol)
-+ = objfile_type->nodebug_text_symbol;
- objfile_type->nodebug_data_symbol
- = init_type (TYPE_CODE_INT,
- gdbarch_int_bit (gdbarch) / HOST_CHAR_BIT, 0,
-@@ -3678,6 +4247,11 @@ void
- _initialize_gdbtypes (void)
- {
- gdbtypes_data = gdbarch_data_register_post_init (gdbtypes_post_init);
++ def reverse_iter (self, iter):
++ result = []
++ for item in iter:
++ result.append (item)
++ result.reverse()
++ return result
+
-+ type_discardable_table = htab_create_alloc (20, type_discardable_hash,
-+ type_discardable_equal, NULL,
-+ xcalloc, xfree);
++ def final_n (self, iter, x):
++ result = []
++ for item in iter:
++ result.append (item)
++ return result[x:]
+
- objfile_type_data = register_objfile_data ();
-
- add_setshow_zinteger_cmd ("overload", no_class, &overload_debug, _("\
-diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h
-index 085270e..cb2b88e 100644
---- a/gdb/gdbtypes.h
-+++ b/gdb/gdbtypes.h
-@@ -171,6 +171,7 @@ enum type_flag_value
- TYPE_FLAG_FIXED_INSTANCE = (1 << 15),
- TYPE_FLAG_STUB_SUPPORTED = (1 << 16),
- TYPE_FLAG_NOTTEXT = (1 << 17),
-+ TYPE_FLAG_GNU_IFUNC = (1 << 18),
-
- /* Used for error-checking. */
- TYPE_FLAG_MIN = TYPE_FLAG_UNSIGNED
-@@ -214,6 +215,11 @@ enum type_instance_flag_value
-
- #define TYPE_TARGET_STUB(t) (TYPE_MAIN_TYPE (t)->flag_target_stub)
-
-+/* Type needs to be evaluated on each CHECK_TYPEDEF and its results must not be
-+ sticky. */
++ def invoke (self, arg, from_tty):
++ i = 0
++ count = 0
++ filter = True
++ full = False
+
-+#define TYPE_DYNAMIC(t) (TYPE_MAIN_TYPE (t)->flag_dynamic)
++ for word in arg.split (" "):
++ if word == '':
++ continue
++ elif word == 'raw':
++ filter = False
++ elif word == 'full':
++ full = True
++ else:
++ count = int (word)
+
- /* Static type. If this is set, the corresponding type had
- * a static modifier.
- * Note: This may be unnecessary, since static data members
-@@ -271,6 +277,12 @@ enum type_instance_flag_value
-
- #define TYPE_NOTTEXT(t) (TYPE_MAIN_TYPE (t)->flag_nottext)
-
-+/* Used only for TYPE_CODE_FUNC where it specifies the real function
-+ address is returned by this function call. TYPE_TARGET_TYPE determines the
-+ final returned function type to be presented to user. */
++ # FIXME: provide option to start at selected frame
++ # However, should still number as if starting from newest
++ newest_frame = gdb.newest_frame()
++ iter = itertools.imap (FrameWrapper,
++ FrameIterator (newest_frame))
++ if filter:
++ iter = gdb.backtrace.create_frame_filter (iter)
+
-+#define TYPE_GNU_IFUNC(t) (TYPE_MAIN_TYPE (t)->flag_gnu_ifunc)
++ # Now wrap in an iterator that numbers the frames.
++ iter = itertools.izip (itertools.count (0), iter)
+
- /* Type owner. If TYPE_OBJFILE_OWNED is true, the type is owned by
- the objfile retrieved as TYPE_OBJFILE. Otherweise, the type is
- owned by an architecture; TYPE_OBJFILE is NULL in this case. */
-@@ -285,6 +297,48 @@ enum type_instance_flag_value
-
- #define TYPE_DECLARED_CLASS(t) (TYPE_MAIN_TYPE (t)->flag_declared_class)
-
-+/* Define this type as being reclaimable during free_all_types. Type is
-+ required to be have TYPE_OBJFILE set to NULL. Setting this flag requires
-+ initializing TYPE_DISCARDABLE_AGE, see alloc_type_discardable. */
++ # Reverse if the user wanted that.
++ if self.reverse.value:
++ iter = self.reverse_iter (iter)
+
-+#define TYPE_DISCARDABLE(t) (TYPE_MAIN_TYPE (t)->flag_discardable)
++ # Extract sub-range user wants.
++ if count < 0:
++ iter = self.final_n (iter, count)
++ elif count > 0:
++ iter = itertools.islice (iter, 0, count)
+
-+/* Marker this type has been visited by the type_mark_used by this
-+ mark-and-sweep types garbage collecting pass. Current pass is represented
-+ by TYPE_DISCARDABLE_AGE_CURRENT. */
++ for pair in iter:
++ sys.stdout.write ("#%-2d" % pair[0])
++ pair[1].describe (sys.stdout, full)
+
-+#define TYPE_DISCARDABLE_AGE(t) (TYPE_MAIN_TYPE (t)->flag_discardable_age)
++FilteringBacktrace()
+Index: gdb-7.2.90.20110703/gdb/python/lib/gdb/command/ignore_errors.py
+===================================================================
+--- /dev/null 1970-01-01 00:00:00.000000000 +0000
++++ gdb-7.2.90.20110703/gdb/python/lib/gdb/command/ignore_errors.py 2011-07-03 10:33:11.000000000 +0200
+@@ -0,0 +1,37 @@
++# Ignore errors in user commands.
+
-+/* Is HIGH_BOUND a low-bound relative count (1) or the high bound itself (0)? */
++# Copyright (C) 2008 Free Software Foundation, Inc.
+
-+#define TYPE_RANGE_HIGH_BOUND_IS_COUNT(range_type) \
-+ (TYPE_MAIN_TYPE (range_type)->flag_range_high_bound_is_count)
++# This program is free software; you can redistribute it and/or modify
++# it under the terms of the GNU General Public License as published by
++# the Free Software Foundation; either version 3 of the License, or
++# (at your option) any later version.
++#
++# This program is distributed in the hope that it will be useful,
++# but WITHOUT ANY WARRANTY; without even the implied warranty of
++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++# GNU General Public License for more details.
++#
++# You should have received a copy of the GNU General Public License
++# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
-+/* Not allocated. TYPE_ALLOCATED(t) must be NULL in such case. If this flag
-+ is unset and TYPE_ALLOCATED(t) is NULL then the type is allocated. If this
-+ flag is unset and TYPE_ALLOCATED(t) is not NULL then its DWARF block
-+ determines the actual allocation state. */
++import gdb
+
-+#define TYPE_NOT_ALLOCATED(t) (TYPE_MAIN_TYPE (t)->flag_not_allocated)
++class IgnoreErrorsCommand (gdb.Command):
++ """Execute a single command, ignoring all errors.
++Only one-line commands are supported.
++This is primarily useful in scripts."""
+
-+/* Not associated. TYPE_ASSOCIATED(t) must be NULL in such case. If this flag
-+ is unset and TYPE_ASSOCIATED(t) is NULL then the type is associated. If
-+ this flag is unset and TYPE_ASSOCIATED(t) is not NULL then its DWARF block
-+ determines the actual association state. */
++ def __init__ (self):
++ super (IgnoreErrorsCommand, self).__init__ ("ignore-errors",
++ gdb.COMMAND_OBSCURE,
++ # FIXME...
++ gdb.COMPLETE_COMMAND)
+
-+#define TYPE_NOT_ASSOCIATED(t) (TYPE_MAIN_TYPE (t)->flag_not_associated)
++ def invoke (self, arg, from_tty):
++ try:
++ gdb.execute (arg, from_tty)
++ except:
++ pass
+
-+/* Address of the actual data as for DW_AT_data_location. Its dwarf block must
-+ not be evaluated unless both TYPE_NOT_ALLOCATED and TYPE_NOT_ASSOCIATED are
-+ false. If TYPE_DATA_LOCATION_IS_ADDR set then TYPE_DATA_LOCATION_ADDR value
-+ is the actual data address value. If unset and
-+ TYPE_DATA_LOCATION_DWARF_BLOCK is NULL then the value is the normal
-+ value_raw_address. If unset and TYPE_DATA_LOCATION_DWARF_BLOCK is not NULL
-+ then its DWARF block determines the actual data address. */
++IgnoreErrorsCommand ()
+Index: gdb-7.2.90.20110703/gdb/python/lib/gdb/command/pahole.py
+===================================================================
+--- /dev/null 1970-01-01 00:00:00.000000000 +0000
++++ gdb-7.2.90.20110703/gdb/python/lib/gdb/command/pahole.py 2011-07-03 10:33:11.000000000 +0200
+@@ -0,0 +1,75 @@
++# pahole command for gdb
+
-+#define TYPE_DATA_LOCATION_IS_ADDR(t) \
-+ (TYPE_MAIN_TYPE (t)->flag_data_location_is_addr)
++# Copyright (C) 2008, 2009 Free Software Foundation, Inc.
+
- /* Constant type. If this is set, the corresponding type has a
- * const modifier.
- */
-@@ -389,11 +443,19 @@ struct main_type
- unsigned int flag_vector : 1;
- unsigned int flag_stub_supported : 1;
- unsigned int flag_nottext : 1;
-+ unsigned int flag_gnu_ifunc : 1;
- unsigned int flag_fixed_instance : 1;
- unsigned int flag_objfile_owned : 1;
- /* True if this type was declared with "class" rather than
- "struct". */
- unsigned int flag_declared_class : 1;
-+ unsigned int flag_discardable : 1;
-+ unsigned int flag_discardable_age : 1;
-+ unsigned int flag_dynamic : 1;
-+ unsigned int flag_range_high_bound_is_count : 1;
-+ unsigned int flag_not_allocated : 1;
-+ unsigned int flag_not_associated : 1;
-+ unsigned int flag_data_location_is_addr : 1;
-
- /* A discriminant telling us which field of the type_specific union
- is being used for this type, if any. */
-@@ -467,6 +529,20 @@ struct main_type
-
- struct type *target_type;
-
-+ /* For DW_AT_data_location. */
-+ union
-+ {
-+ struct dwarf2_locexpr_baton *dwarf_block;
-+ CORE_ADDR addr;
-+ }
-+ data_location;
++# This program is free software; you can redistribute it and/or modify
++# it under the terms of the GNU General Public License as published by
++# the Free Software Foundation; either version 3 of the License, or
++# (at your option) any later version.
++#
++# This program is distributed in the hope that it will be useful,
++# but WITHOUT ANY WARRANTY; without even the implied warranty of
++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++# GNU General Public License for more details.
++#
++# You should have received a copy of the GNU General Public License
++# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
-+ /* For DW_AT_allocated. */
-+ struct dwarf2_locexpr_baton *allocated;
++import gdb
+
-+ /* For DW_AT_associated. */
-+ struct dwarf2_locexpr_baton *associated;
++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."""
+
- /* 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.
-@@ -540,13 +616,34 @@ struct main_type
-
- struct range_bounds
- {
-+ struct
-+ {
-+ union
-+ {
-+ LONGEST constant;
-+ struct dwarf2_locexpr_baton *dwarf_block;
-+ struct
-+ {
-+ struct dwarf2_loclist_baton *loclist;
-+ struct type *type;
-+ }
-+ dwarf_loclist;
-+ }
-+ u;
-+ enum range_bound_kind
-+ {
-+ RANGE_BOUND_KIND_CONSTANT,
-+ RANGE_BOUND_KIND_DWARF_BLOCK,
-+ RANGE_BOUND_KIND_DWARF_LOCLIST
-+ }
-+ kind;
-+ }
- /* Low bound of range. */
--
-- LONGEST low;
--
-+ low,
- /* High bound of range. */
--
-- LONGEST high;
-+ high,
-+ /* Byte stride of range. */
-+ byte_stride;
-
- /* Flags indicating whether the values of low and high are
- valid. When true, the respective range value is
-@@ -889,9 +986,9 @@ extern void allocate_gnat_aux_type (struct type *);
- #define TYPE_POINTER_TYPE(thistype) (thistype)->pointer_type
- #define TYPE_REFERENCE_TYPE(thistype) (thistype)->reference_type
- #define TYPE_CHAIN(thistype) (thistype)->chain
--/* Note that if thistype is a TYPEDEF type, you have to call check_typedef.
-- But check_typedef does set the TYPE_LENGTH of the TYPEDEF type,
-- so you only have to call check_typedef once. Since allocate_value
-+/* Note that if thistype is a TYPEDEF, ARRAY or STRING type, you have to call
-+ check_typedef. But check_typedef does set the TYPE_LENGTH of the TYPEDEF
-+ type, so you only have to call check_typedef once. Since allocate_value
- 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
-@@ -899,11 +996,16 @@ extern void allocate_gnat_aux_type (struct type *);
- #define TYPE_CODE(thistype) TYPE_MAIN_TYPE(thistype)->code
- #define TYPE_NFIELDS(thistype) TYPE_MAIN_TYPE(thistype)->nfields
- #define TYPE_FIELDS(thistype) TYPE_MAIN_TYPE(thistype)->flds_bnds.fields
-+#define TYPE_DATA_LOCATION_DWARF_BLOCK(thistype) TYPE_MAIN_TYPE (thistype)->data_location.dwarf_block
-+#define TYPE_DATA_LOCATION_ADDR(thistype) TYPE_MAIN_TYPE (thistype)->data_location.addr
-+#define TYPE_ALLOCATED(thistype) TYPE_MAIN_TYPE (thistype)->allocated
-+#define TYPE_ASSOCIATED(thistype) TYPE_MAIN_TYPE (thistype)->associated
-
- #define TYPE_INDEX_TYPE(type) TYPE_FIELD_TYPE (type, 0)
- #define TYPE_RANGE_DATA(thistype) TYPE_MAIN_TYPE(thistype)->flds_bnds.bounds
--#define TYPE_LOW_BOUND(range_type) TYPE_RANGE_DATA(range_type)->low
--#define TYPE_HIGH_BOUND(range_type) TYPE_RANGE_DATA(range_type)->high
-+#define TYPE_LOW_BOUND(range_type) TYPE_RANGE_DATA(range_type)->low.u.constant
-+#define TYPE_HIGH_BOUND(range_type) TYPE_RANGE_DATA(range_type)->high.u.constant
-+#define TYPE_BYTE_STRIDE(range_type) TYPE_RANGE_DATA(range_type)->byte_stride.u.constant
- #define TYPE_LOW_BOUND_UNDEFINED(range_type) \
- TYPE_RANGE_DATA(range_type)->low_undefined
- #define TYPE_HIGH_BOUND_UNDEFINED(range_type) \
-@@ -920,7 +1022,14 @@ extern void allocate_gnat_aux_type (struct type *);
- (TYPE_HIGH_BOUND(TYPE_INDEX_TYPE((arraytype))))
-
- #define TYPE_ARRAY_LOWER_BOUND_VALUE(arraytype) \
-- (TYPE_LOW_BOUND(TYPE_INDEX_TYPE((arraytype))))
-+ TYPE_LOW_BOUND (TYPE_INDEX_TYPE (arraytype))
++ def __init__ (self):
++ super (Pahole, self).__init__ ("pahole", gdb.COMMAND_NONE,
++ gdb.COMPLETE_SYMBOL)
+
-+/* TYPE_BYTE_STRIDE (TYPE_INDEX_TYPE (arraytype)) with a fallback to the
-+ element size if no specific stride value is known. */
-+#define TYPE_ARRAY_BYTE_STRIDE_VALUE(arraytype) \
-+ (TYPE_BYTE_STRIDE (TYPE_INDEX_TYPE (arraytype)) == 0 \
-+ ? TYPE_LENGTH (TYPE_TARGET_TYPE (arraytype)) \
-+ : TYPE_BYTE_STRIDE (TYPE_INDEX_TYPE (arraytype)))
-
- /* C++ */
-
-@@ -1141,6 +1250,10 @@ struct builtin_type
- (*) () can server as a generic function pointer. */
- struct type *builtin_func_ptr;
-
-+ /* `function returning pointer to function (returning void)' type.
-+ The final void return type is not significant for it. */
-+ struct type *builtin_func_func;
++ 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
+
-
- /* Special-purpose types. */
-
-@@ -1181,6 +1294,8 @@ struct objfile_type
-
- /* Types used for symbols with no debug information. */
- struct type *nodebug_text_symbol;
-+ struct type *nodebug_text_gnu_ifunc_symbol;
-+ struct type *nodebug_got_plt_symbol;
- struct type *nodebug_data_symbol;
- struct type *nodebug_unknown_symbol;
- struct type *nodebug_tls_symbol;
-@@ -1328,6 +1443,18 @@ extern struct type *create_array_type (struct type *, struct type *,
- struct type *);
- extern struct type *lookup_array_range_type (struct type *, int, int);
-
-+extern CORE_ADDR type_range_any_field_internal (struct type *range_type,
-+ int fieldno);
++ ftype = field.type.strip_typedefs()
+
-+extern int type_range_high_bound_internal (struct type *range_type);
++ 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
+
-+extern int type_range_count_bound_internal (struct type *range_type);
++ # TARGET_CHAR_BIT
++ print ' /* %3d %3d */' % (int (bitpos / 8), int (fieldsize / 8)),
++ bitpos = bitpos + fieldsize
+
-+extern CORE_ADDR type_range_byte_stride_internal (struct type *range_type,
-+ struct type *element_type);
++ 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)
+
-+extern void finalize_type (struct type *type);
++ print ' ' * (14 + 2 * level),
++ print '} %s' % name
+
- extern struct type *create_string_type (struct type *, struct type *,
- struct type *);
- extern struct type *lookup_string_range_type (struct type *, int, int);
-@@ -1370,6 +1497,8 @@ extern int is_public_ancestor (struct type *, struct type *);
-
- extern int is_unique_ancestor (struct type *, struct value *);
-
-+extern void type_mark_used (struct type *type);
++ 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, '')
+
- /* Overload resolution */
-
- #define LENGTH_MATCH(bv) ((bv)->rank[0])
-@@ -1432,10 +1561,11 @@ extern void maintenance_print_type (char *, int);
-
- extern htab_t create_copied_types_hash (struct objfile *objfile);
-
--extern struct type *copy_type_recursive (struct objfile *objfile,
-- struct type *type,
-+extern struct type *copy_type_recursive (struct type *type,
- htab_t copied_types);
-
- extern struct type *copy_type (const struct type *type);
-
-+extern void free_all_types (void);
++Pahole()
+Index: gdb-7.2.90.20110703/gdb/python/lib/gdb/command/require.py
+===================================================================
+--- /dev/null 1970-01-01 00:00:00.000000000 +0000
++++ gdb-7.2.90.20110703/gdb/python/lib/gdb/command/require.py 2011-07-03 10:33:11.000000000 +0200
+@@ -0,0 +1,57 @@
++# Demand-loading commands.
+
- #endif /* GDBTYPES_H */
-diff --git a/gdb/i386-linux-nat.c b/gdb/i386-linux-nat.c
-index 4fce1ac..144a899 100644
---- a/gdb/i386-linux-nat.c
-+++ b/gdb/i386-linux-nat.c
-@@ -747,6 +747,21 @@ i386_linux_dr_unset_status (unsigned long mask)
- }
- }
-
-+/* See i386_dr_low_type.detach. Do not use wrappers i386_linux_dr_set_control
-+ or i386_linux_dr_reset_addr as they would modify the register cache
-+ (i386_linux_dr). */
++# Copyright (C) 2008, 2009 Free Software Foundation, Inc.
+
-+static void
-+i386_linux_dr_detach (void)
-+{
-+ int regnum;
++# This program is free software; you can redistribute it and/or modify
++# it under the terms of the GNU General Public License as published by
++# the Free Software Foundation; either version 3 of the License, or
++# (at your option) any later version.
++#
++# This program is distributed in the hope that it will be useful,
++# but WITHOUT ANY WARRANTY; without even the implied warranty of
++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++# GNU General Public License for more details.
++#
++# You should have received a copy of the GNU General Public License
++# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
-+ i386_linux_dr_set (inferior_ptid, DR_CONTROL, 0);
-+ i386_linux_dr_unset_status (~0UL);
-+ for (regnum = DR_FIRSTADDR; regnum <= DR_LASTADDR; regnum++)
-+ i386_linux_dr_set (inferior_ptid, regnum, 0);
-+}
++import gdb
++import os
+
- static void
- i386_linux_new_thread (ptid_t ptid)
- {
-@@ -976,6 +991,7 @@ _initialize_i386_linux_nat (void)
- i386_dr_low.reset_addr = i386_linux_dr_reset_addr;
- i386_dr_low.get_status = i386_linux_dr_get_status;
- i386_dr_low.unset_status = i386_linux_dr_unset_status;
-+ i386_dr_low.detach = i386_linux_dr_detach;
- i386_set_debug_register_length (4);
-
- /* Override the default ptrace resume method. */
-diff --git a/gdb/i386-nat.c b/gdb/i386-nat.c
-index eaa3644..0921c7e 100644
---- a/gdb/i386-nat.c
-+++ b/gdb/i386-nat.c
-@@ -533,6 +533,17 @@ i386_remove_watchpoint (CORE_ADDR addr, int len, int type,
- return retval;
- }
-
-+/* See target_detach_watchpoints. */
++class RequireCommand (gdb.Command):
++ """Prefix command for requiring features."""
+
-+static int
-+i386_detach_watchpoints (void)
-+{
-+ if (i386_dr_low.detach)
-+ i386_dr_low.detach ();
++ def __init__ (self):
++ super (RequireCommand, self).__init__ ("require",
++ gdb.COMMAND_SUPPORT,
++ gdb.COMPLETE_NONE,
++ True)
+
-+ return 0;
-+}
++class RequireSubcommand (gdb.Command):
++ """Demand-load a command by name."""
+
- /* Return non-zero if we can watch a memory region that starts at
- address ADDR and whose length is LEN bytes. */
-
-@@ -685,6 +696,7 @@ i386_use_watchpoints (struct target_ops *t)
- t->to_stopped_data_address = i386_stopped_data_address;
- t->to_insert_watchpoint = i386_insert_watchpoint;
- t->to_remove_watchpoint = i386_remove_watchpoint;
-+ t->to_detach_watchpoints = i386_detach_watchpoints;
- t->to_insert_hw_breakpoint = i386_insert_hw_breakpoint;
- t->to_remove_hw_breakpoint = i386_remove_hw_breakpoint;
- }
-diff --git a/gdb/i386-nat.h b/gdb/i386-nat.h
-index 7317e7d..ea914a5 100644
---- a/gdb/i386-nat.h
-+++ b/gdb/i386-nat.h
-@@ -62,6 +62,10 @@ extern void i386_use_watchpoints (struct target_ops *);
- unset_status -- unset the specified bits of the debug
- status (DR6) register for all LWPs
-
-+ detach -- clear all debug registers of only the
-+ INFERIOR_PTID task without affecting any
-+ register caches.
-+
- Additionally, the native file should set the debug_register_length
- field to 4 or 8 depending on the number of bytes used for
- deubg registers. */
-@@ -73,6 +77,7 @@ struct i386_dr_low_type
- void (*reset_addr) (int);
- unsigned long (*get_status) (void);
- void (*unset_status) (unsigned long);
-+ void (*detach) (void);
- int debug_register_length;
- };
-
-diff --git a/gdb/infcall.c b/gdb/infcall.c
-index 0c9a3af..957ec1d 100644
---- a/gdb/infcall.c
-+++ b/gdb/infcall.c
-@@ -225,6 +225,56 @@ value_arg_coerce (struct gdbarch *gdbarch, struct value *arg,
- return value_cast (type, arg);
- }
-
-+/* Call gnu-ifunc (STT_GNU_IFUNC - a function returning addresss of a real
-+ function to call). PC is the gnu-ifunc function entry. Function returns
-+ function entry of the gnu-ifunc-resolved function to call. If RETVAL_TYPEP
-+ is not NULL fill in *RETVAL_TYPEP with return type of the gnu-ifunc-resolved
-+ function to call. Keep *RETVAL_TYPEP intact if the return type could not be
-+ found. */
++ 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
+
-+static CORE_ADDR
-+gnu_ifunc_resolve (struct gdbarch *gdbarch, CORE_ADDR pc)
-+{
-+ char *name_at_pc;
-+ CORE_ADDR start_at_pc, address;
-+ struct type *func_func_type = builtin_type (gdbarch)->builtin_func_func;
-+ struct value *function, *address_val;
++ def invoke (self, arg, from_tty):
++ for cmd in arg.split():
++ exec ('import gdb.' + self.name + '.' + cmd, globals ())
+
-+ if (find_pc_partial_function (pc, &name_at_pc, &start_at_pc, NULL)
-+ && start_at_pc == pc)
-+ {
-+ if (resolve_gnu_ifunc (name_at_pc, &address))
-+ return address;
-+ }
-+ else
-+ name_at_pc = NULL;
++ 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
+
-+ function = allocate_value (func_func_type);
-+ set_value_address (function, pc);
++RequireCommand()
++RequireSubcommand("command")
++RequireSubcommand("function")
+Index: gdb-7.2.90.20110703/gdb/python/lib/gdb/command/upto.py
+===================================================================
+--- /dev/null 1970-01-01 00:00:00.000000000 +0000
++++ gdb-7.2.90.20110703/gdb/python/lib/gdb/command/upto.py 2011-07-03 10:33:11.000000000 +0200
+@@ -0,0 +1,129 @@
++# upto command.
+
-+ /* gnu-ifuncs have no arguments. FUNCTION is the function entry address
-+ while ADDRESS is a possible function descriptor.. */
-+ address_val = call_function_by_hand (function, 0, NULL);
-+ address = value_as_address (address_val);
++# Copyright (C) 2009 Free Software Foundation, Inc.
+
-+ if (name_at_pc)
-+ gnu_ifunc_record_cache (gdbarch, name_at_pc, address);
++# This program is free software; you can redistribute it and/or modify
++# it under the terms of the GNU General Public License as published by
++# the Free Software Foundation; either version 3 of the License, or
++# (at your option) any later version.
++#
++# This program is distributed in the hope that it will be useful,
++# but WITHOUT ANY WARRANTY; without even the implied warranty of
++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++# GNU General Public License for more details.
++#
++# You should have received a copy of the GNU General Public License
++# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
-+ return gdbarch_convert_from_func_ptr_addr (gdbarch, address, ¤t_target);
-+}
++import gdb
++import re
++from gdb.FrameIterator import FrameIterator
++from gdb.FrameWrapper import FrameWrapper
+
-+static struct type *
-+find_function_return_type (CORE_ADDR pc)
-+{
-+ struct symbol *sym = find_pc_function (pc);
++class UptoPrefix (gdb.Command):
++ def __init__ (self):
++ super (UptoPrefix, self).__init__ ("upto", gdb.COMMAND_STACK,
++ prefix = True)
+
-+ if (sym != NULL && BLOCK_START (SYMBOL_BLOCK_VALUE (sym)) == pc
-+ && SYMBOL_TYPE (sym) != NULL)
-+ return TYPE_TARGET_TYPE (SYMBOL_TYPE (sym));
++class UptoImplementation (gdb.Command):
++ def __init__ (self, subcommand):
++ super (UptoImplementation, self).__init__ ("upto " + subcommand,
++ gdb.COMMAND_STACK)
+
-+ return NULL;
-+}
++ 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'
+
- /* Determine a function's address and its return type from its value.
- Calls error() if the function is not valid for calling. */
-
-@@ -233,7 +283,6 @@ find_function_addr (struct value *function, struct type **retval_type)
- {
- struct type *ftype = check_typedef (value_type (function));
- struct gdbarch *gdbarch = get_type_arch (ftype);
-- enum type_code code = TYPE_CODE (ftype);
- struct type *value_type = NULL;
- CORE_ADDR funaddr;
-
-@@ -241,24 +290,34 @@ find_function_addr (struct value *function, struct type **retval_type)
- part of it. */
-
- /* Determine address to call. */
-- if (code == TYPE_CODE_FUNC || code == TYPE_CODE_METHOD)
-- {
-- funaddr = value_address (function);
-- value_type = TYPE_TARGET_TYPE (ftype);
-- }
-- else if (code == TYPE_CODE_PTR)
-+ if (TYPE_CODE (ftype) == TYPE_CODE_FUNC
-+ || TYPE_CODE (ftype) == TYPE_CODE_METHOD)
-+ funaddr = value_address (function);
-+ else if (TYPE_CODE (ftype) == TYPE_CODE_PTR)
- {
- funaddr = value_as_address (function);
- ftype = check_typedef (TYPE_TARGET_TYPE (ftype));
- if (TYPE_CODE (ftype) == TYPE_CODE_FUNC
- || TYPE_CODE (ftype) == TYPE_CODE_METHOD)
-+ funaddr = gdbarch_convert_from_func_ptr_addr (gdbarch, funaddr,
-+ ¤t_target);
-+ }
-+ if (TYPE_CODE (ftype) == TYPE_CODE_FUNC
-+ || TYPE_CODE (ftype) == TYPE_CODE_METHOD)
-+ {
-+ value_type = TYPE_TARGET_TYPE (ftype);
++ def invoke (self, arg, from_tty):
++ self.rx = re.compile (arg)
++ self.search ()
+
-+ if (TYPE_GNU_IFUNC (ftype))
- {
-- funaddr = gdbarch_convert_from_func_ptr_addr (gdbarch, funaddr,
-- ¤t_target);
-- value_type = TYPE_TARGET_TYPE (ftype);
-+ funaddr = gnu_ifunc_resolve (gdbarch, funaddr);
-+
-+ /* Skip querying the function symbol if no RETVAL_TYPE has been
-+ asked for. */
-+ if (retval_type)
-+ value_type = find_function_return_type (funaddr);
- }
- }
-- else if (code == TYPE_CODE_INT)
-+ else if (TYPE_CODE (ftype) == TYPE_CODE_INT)
- {
- /* Handle the case of functions lacking debugging info.
- Their values are characters since their addresses are char */
-diff --git a/gdb/infcmd.c b/gdb/infcmd.c
-index c4cdb06..d213f6a 100644
---- a/gdb/infcmd.c
-+++ b/gdb/infcmd.c
-@@ -822,7 +822,7 @@ nexti_command (char *count_string, int from_tty)
- step_1 (1, 1, count_string);
- }
-
--static void
-+void
- delete_longjmp_breakpoint_cleanup (void *arg)
- {
- int thread = * (int *) arg;
-@@ -862,10 +862,13 @@ step_1 (int skip_subroutines, int single_inst, char *count_string)
-
- if (!single_inst || skip_subroutines) /* leave si command alone */
- {
-+ struct thread_info *tp = inferior_thread ();
++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."""
+
- if (in_thread_list (inferior_ptid))
- thread = pid_to_thread_id (inferior_ptid);
-
- set_longjmp_breakpoint (thread);
-+ tp->initiating_frame = get_frame_id (get_current_frame ());
-
- make_cleanup (delete_longjmp_breakpoint_cleanup, &thread);
- }
-@@ -1219,6 +1222,15 @@ signal_command (char *signum_exp, int from_tty)
- proceed ((CORE_ADDR) -1, oursig, 0);
- }
-
-+/* A continuation callback for until_next_command. */
++ def __init__ (self):
++ super (UptoSymbolCommand, self).__init__ ("symbol")
+
-+static void
-+until_next_continuation (void *arg)
-+{
-+ struct thread_info *tp = arg;
-+ delete_longjmp_breakpoint (tp->num);
-+}
++ def filter (self, frame):
++ name = frame.name ()
++ if name is not None:
++ if self.rx.search (name) is not None:
++ return True
++ return False
+
- /* Proceed until we reach a different source line with pc greater than
- our current one or exit the function. We skip calls in both cases.
-
-@@ -1235,6 +1247,8 @@ until_next_command (int from_tty)
- struct symbol *func;
- struct symtab_and_line sal;
- struct thread_info *tp = inferior_thread ();
-+ int thread = tp->num;
-+ struct cleanup *old_chain;
-
- clear_proceed_status ();
- set_step_frame ();
-@@ -1270,7 +1284,19 @@ until_next_command (int from_tty)
-
- tp->step_multi = 0; /* Only one call to proceed */
-
-+ set_longjmp_breakpoint (thread);
-+ tp->initiating_frame = get_frame_id (frame);
-+ old_chain = make_cleanup (delete_longjmp_breakpoint_cleanup, &thread);
++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
+
- proceed ((CORE_ADDR) -1, TARGET_SIGNAL_DEFAULT, 1);
++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."""
+
-+ if (target_can_async_p () && is_running (inferior_ptid))
-+ {
-+ discard_cleanups (old_chain);
-+ add_continuation (tp, until_next_continuation, tp, NULL);
-+ }
-+ else
-+ do_cleanups (old_chain);
- }
-
- static void
-@@ -1463,6 +1489,7 @@ finish_command_continuation (void *arg)
- if (bs != NULL && tp->proceed_to_finish)
- observer_notify_normal_stop (bs, 1 /* print frame */);
- delete_breakpoint (a->breakpoint);
-+ delete_longjmp_breakpoint (inferior_thread ()->num);
- }
-
- static void
-@@ -1546,6 +1573,7 @@ finish_forward (struct symbol *function, struct frame_info *frame)
- struct breakpoint *breakpoint;
- struct cleanup *old_chain;
- struct finish_command_continuation_args *cargs;
-+ int thread = tp->num;
-
- sal = find_pc_line (get_frame_pc (frame), 0);
- sal.pc = get_frame_pc (frame);
-@@ -1556,6 +1584,10 @@ finish_forward (struct symbol *function, struct frame_info *frame)
-
- old_chain = make_cleanup_delete_breakpoint (breakpoint);
-
-+ set_longjmp_breakpoint (thread);
-+ tp->initiating_frame = get_frame_id (frame);
-+ make_cleanup (delete_longjmp_breakpoint_cleanup, &thread);
++ def __init__ (self):
++ super (UptoObjectCommand, self).__init__ ("object")
+
- tp->proceed_to_finish = 1; /* We want stop_registers, please... */
- cargs = xmalloc (sizeof (*cargs));
-
-diff --git a/gdb/inferior.h b/gdb/inferior.h
-index 5abec68..e309277 100644
---- a/gdb/inferior.h
-+++ b/gdb/inferior.h
-@@ -291,6 +291,8 @@ extern void interrupt_target_command (char *args, int from_tty);
-
- extern void interrupt_target_1 (int all_threads);
-
-+extern void delete_longjmp_breakpoint_cleanup (void *arg);
++ 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
+
- extern void detach_command (char *, int);
-
- extern void notice_new_inferior (ptid_t, int, int);
-diff --git a/gdb/infrun.c b/gdb/infrun.c
-index 54b1d9f..58d045a 100644
---- a/gdb/infrun.c
-+++ b/gdb/infrun.c
-@@ -45,6 +45,8 @@
- #include "language.h"
- #include "solib.h"
- #include "main.h"
-+#include "dictionary.h"
-+#include "block.h"
- #include "gdb_assert.h"
- #include "mi/mi-common.h"
- #include "event-top.h"
-@@ -367,6 +369,7 @@ follow_fork (void)
- parent thread structure's run control related fields, not just these.
- Initialized to avoid "may be used uninitialized" warnings from gcc. */
- struct breakpoint *step_resume_breakpoint = NULL;
-+ struct breakpoint *exception_resume_breakpoint = NULL;
- CORE_ADDR step_range_start = 0;
- CORE_ADDR step_range_end = 0;
- struct frame_id step_frame_id = { 0 };
-@@ -419,6 +422,8 @@ follow_fork (void)
- step_range_start = tp->step_range_start;
- step_range_end = tp->step_range_end;
- step_frame_id = tp->step_frame_id;
-+ exception_resume_breakpoint
-+ = clone_momentary_breakpoint (tp->exception_resume_breakpoint);
-
- /* For now, delete the parent's sr breakpoint, otherwise,
- parent/child sr breakpoints are considered duplicates,
-@@ -429,6 +434,7 @@ follow_fork (void)
- tp->step_range_start = 0;
- tp->step_range_end = 0;
- tp->step_frame_id = null_frame_id;
-+ delete_exception_resume_breakpoint (tp);
- }
-
- parent = inferior_ptid;
-@@ -470,6 +476,8 @@ follow_fork (void)
- tp->step_range_start = step_range_start;
- tp->step_range_end = step_range_end;
- tp->step_frame_id = step_frame_id;
-+ tp->exception_resume_breakpoint
-+ = exception_resume_breakpoint;
- }
- else
- {
-@@ -523,6 +531,9 @@ follow_inferior_reset_breakpoints (void)
- if (tp->step_resume_breakpoint)
- breakpoint_re_set_thread (tp->step_resume_breakpoint);
-
-+ if (tp->exception_resume_breakpoint)
-+ breakpoint_re_set_thread (tp->exception_resume_breakpoint);
-+
- /* Reinsert all breakpoints in the child. The user may have set
- breakpoints after catching the fork, in which case those
- were never set in the child, but only in the parent. This makes
-@@ -760,6 +771,7 @@ follow_exec (ptid_t pid, char *execd_pathname)
- /* If there was one, it's gone now. We cannot truly step-to-next
- statement through an exec(). */
- th->step_resume_breakpoint = NULL;
-+ th->exception_resume_breakpoint = NULL;
- th->step_range_start = 0;
- th->step_range_end = 0;
-
-@@ -2190,6 +2202,8 @@ static void insert_step_resume_breakpoint_at_sal (struct gdbarch *gdbarch,
- struct symtab_and_line sr_sal,
- struct frame_id sr_id);
- static void insert_longjmp_resume_breakpoint (struct gdbarch *, CORE_ADDR);
-+static void check_exception_resume (struct execution_control_state *,
-+ struct frame_info *, struct symbol *);
-
- static void stop_stepping (struct execution_control_state *ecs);
- static void prepare_to_wait (struct execution_control_state *ecs);
-@@ -2313,6 +2327,7 @@ delete_step_resume_breakpoint_callback (struct thread_info *info, void *data)
- return 0;
-
- delete_step_resume_breakpoint (info);
-+ delete_exception_resume_breakpoint (info);
- return 0;
- }
-
-@@ -2337,6 +2352,7 @@ delete_step_thread_step_resume_breakpoint (void)
- struct thread_info *tp = inferior_thread ();
-
- delete_step_resume_breakpoint (tp);
-+ delete_exception_resume_breakpoint (tp);
- }
- else
- /* In all-stop mode, delete all step-resume and longjmp-resume
-@@ -3241,6 +3257,10 @@ handle_inferior_event (struct execution_control_state *ecs)
-
- stop_pc = regcache_read_pc (get_thread_regcache (ecs->ptid));
-
-+ /* Clear WATCHPOINT_TRIGGERED values from previous stop which could
-+ confuse bpstat_stop_status and bpstat_explains_signal. */
-+ watchpoints_triggered (&ecs->ws);
++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."""
+
- ecs->event_thread->stop_bpstat
- = bpstat_stop_status (get_regcache_aspace (get_current_regcache ()),
- stop_pc, ecs->ptid);
-@@ -3328,6 +3348,10 @@ handle_inferior_event (struct execution_control_state *ecs)
-
- stop_pc = regcache_read_pc (get_thread_regcache (ecs->ptid));
-
-+ /* Clear WATCHPOINT_TRIGGERED values from previous stop which could
-+ confuse bpstat_stop_status and bpstat_explains_signal. */
-+ watchpoints_triggered (&ecs->ws);
++ def __init__ (self):
++ super (UptoWhereCommand, self).__init__ ("where")
+
- /* Do whatever is necessary to the parent branch of the vfork. */
- handle_vfork_child_exec_or_exit (1);
-
-@@ -4076,23 +4100,33 @@ process_event_stop_test:
-
- ecs->event_thread->stepping_over_breakpoint = 1;
-
-- if (!gdbarch_get_longjmp_target_p (gdbarch)
-- || !gdbarch_get_longjmp_target (gdbarch, frame, &jmp_buf_pc))
-+ if (what.is_longjmp)
- {
-- if (debug_infrun)
-- fprintf_unfiltered (gdb_stdlog, "\
-+ if (!gdbarch_get_longjmp_target_p (gdbarch)
-+ || !gdbarch_get_longjmp_target (gdbarch,
-+ frame, &jmp_buf_pc))
-+ {
-+ if (debug_infrun)
-+ fprintf_unfiltered (gdb_stdlog, "\
- infrun: BPSTAT_WHAT_SET_LONGJMP_RESUME (!gdbarch_get_longjmp_target)\n");
-- keep_going (ecs);
-- return;
-- }
-+ keep_going (ecs);
-+ return;
-+ }
-
-- /* We're going to replace the current step-resume breakpoint
-- with a longjmp-resume breakpoint. */
-- delete_step_resume_breakpoint (ecs->event_thread);
-+ /* We're going to replace the current step-resume breakpoint
-+ with a longjmp-resume breakpoint. */
-+ delete_step_resume_breakpoint (ecs->event_thread);
-
-- /* Insert a breakpoint at resume address. */
-- insert_longjmp_resume_breakpoint (gdbarch, jmp_buf_pc);
-+ /* Insert a breakpoint at resume address. */
-+ insert_longjmp_resume_breakpoint (gdbarch, jmp_buf_pc);
-+ }
-+ else
-+ {
-+ struct symbol *func = get_frame_function (frame);
-
-+ if (func)
-+ check_exception_resume (ecs, frame, func);
-+ }
- keep_going (ecs);
- return;
-
-@@ -4101,8 +4135,52 @@ infrun: BPSTAT_WHAT_SET_LONGJMP_RESUME (!gdbarch_get_longjmp_target)\n");
- fprintf_unfiltered (gdb_stdlog,
- "infrun: BPSTAT_WHAT_CLEAR_LONGJMP_RESUME\n");
-
-- gdb_assert (ecs->event_thread->step_resume_breakpoint != NULL);
-- delete_step_resume_breakpoint (ecs->event_thread);
-+ if (what.is_longjmp)
-+ {
-+ gdb_assert (ecs->event_thread->step_resume_breakpoint != NULL);
-+ delete_step_resume_breakpoint (ecs->event_thread);
-+ }
-+ else
-+ {
-+ /* There are several cases to consider.
++ def filter (self, frame):
++ try:
++ if gdb.parse_and_eval (self.expression):
++ return True
++ except:
++ pass
++ return False
+
-+ 1. The initiating frame no longer exists. In this case
-+ we must stop, because the exception has gone too far.
++ def invoke (self, arg, from_tty):
++ self.expression = arg
++ self.search ()
+
-+ 2. The initiating frame exists, and is the same as the
-+ current frame. We stop, because the exception has been
-+ caught.
++UptoPrefix ()
++UptoSymbolCommand ()
++UptoSourceCommand ()
++UptoObjectCommand ()
++UptoWhereCommand ()
+Index: gdb-7.2.90.20110703/gdb/python/lib/gdb/function/__init__.py
+===================================================================
+--- /dev/null 1970-01-01 00:00:00.000000000 +0000
++++ gdb-7.2.90.20110703/gdb/python/lib/gdb/function/__init__.py 2011-07-03 10:33:11.000000000 +0200
+@@ -0,0 +1 @@
+
-+ 3. The initiating frame exists and is different from
-+ the current frame. This means the exception has been
-+ caught beneath the initiating frame, so keep going. */
-+ struct frame_info *init_frame
-+ = frame_find_by_id (ecs->event_thread->initiating_frame);
+Index: gdb-7.2.90.20110703/gdb/python/lib/gdb/function/caller_is.py
+===================================================================
+--- /dev/null 1970-01-01 00:00:00.000000000 +0000
++++ gdb-7.2.90.20110703/gdb/python/lib/gdb/function/caller_is.py 2011-07-03 10:33:11.000000000 +0200
+@@ -0,0 +1,58 @@
++# Caller-is functions.
+
-+ gdb_assert (ecs->event_thread->exception_resume_breakpoint != NULL);
-+ delete_exception_resume_breakpoint (ecs->event_thread);
++# Copyright (C) 2008 Free Software Foundation, Inc.
+
-+ if (init_frame)
-+ {
-+ struct frame_id current_id
-+ = get_frame_id (get_current_frame ());
-+ if (frame_id_eq (current_id,
-+ ecs->event_thread->initiating_frame))
-+ {
-+ /* Case 2. Fall through. */
-+ }
-+ else
-+ {
-+ /* Case 3. */
-+ keep_going (ecs);
-+ return;
-+ }
-+ }
++# This program is free software; you can redistribute it and/or modify
++# it under the terms of the GNU General Public License as published by
++# the Free Software Foundation; either version 3 of the License, or
++# (at your option) any later version.
++#
++# This program is distributed in the hope that it will be useful,
++# but WITHOUT ANY WARRANTY; without even the implied warranty of
++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++# GNU General Public License for more details.
++#
++# You should have received a copy of the GNU General Public License
++# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
-+ /* For Cases 1 and 2, remove the step-resume breakpoint,
-+ if it exists. */
-+ delete_step_resume_breakpoint (ecs->event_thread);
-+ }
-
- ecs->event_thread->stop_step = 1;
- print_stop_reason (END_STEPPING_RANGE, 0);
-@@ -5070,6 +5148,97 @@ insert_longjmp_resume_breakpoint (struct gdbarch *gdbarch, CORE_ADDR pc)
- set_momentary_breakpoint_at_pc (gdbarch, pc, bp_longjmp_resume);
- }
-
-+/* Insert an exception resume breakpoint. TP is the thread throwing
-+ the exception. The block B is the block of the unwinder debug hook
-+ function. FRAME is the frame corresponding to the call to this
-+ function. SYM is the symbol of the function argument holding the
-+ target PC of the exception. */
++import gdb
++import re
+
-+static void
-+insert_exception_resume_breakpoint (struct thread_info *tp,
-+ struct block *b,
-+ struct frame_info *frame,
-+ struct symbol *sym)
-+{
-+ struct gdb_exception e;
++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."""
+
-+ /* We want to ignore errors here. */
-+ TRY_CATCH (e, RETURN_MASK_ALL)
-+ {
-+ struct symbol *vsym;
-+ struct value *value;
-+ CORE_ADDR handler;
-+ struct breakpoint *bp;
-+
-+ vsym = lookup_symbol (SYMBOL_LINKAGE_NAME (sym), b, VAR_DOMAIN, NULL);
-+ value = read_var_value (vsym, frame);
-+ /* If the value was optimized out, revert to the old behavior. */
-+ if (! value_optimized_out (value))
-+ {
-+ handler = value_as_address (value);
++ def __init__ (self):
++ super (CallerIs, self).__init__ ("caller_is")
+
-+ if (debug_infrun)
-+ fprintf_unfiltered (gdb_stdlog,
-+ "infrun: exception resume at %lx\n",
-+ (unsigned long) handler);
++ def invoke (self, name, nframes = 1):
++ frame = gdb.selected_frame ()
++ while nframes > 0:
++ frame = frame.older ()
++ nframes = nframes - 1
++ return frame.name () == name.string ()
+
-+ bp = set_momentary_breakpoint_at_pc (get_frame_arch (frame),
-+ handler, bp_exception_resume);
-+ bp->thread = tp->num;
-+ inferior_thread ()->exception_resume_breakpoint = bp;
-+ }
-+ }
-+}
++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."""
+
-+/* This is called when an exception has been intercepted. Check to
-+ see whether the exception's destination is of interest, and if so,
-+ set an exception resume breakpoint there. */
++ def __init__ (self):
++ super (CallerMatches, self).__init__ ("caller_matches")
+
-+static void
-+check_exception_resume (struct execution_control_state *ecs,
-+ struct frame_info *frame, struct symbol *func)
-+{
-+ struct gdb_exception e;
++ 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
+
-+ TRY_CATCH (e, RETURN_MASK_ALL)
-+ {
-+ struct block *b;
-+ struct dict_iterator iter;
-+ struct symbol *sym;
-+ int argno = 0;
-+
-+ /* The exception breakpoint is a thread-specific breakpoint on
-+ the unwinder's debug hook, declared as:
-+
-+ void _Unwind_DebugHook (void *cfa, void *handler);
-+
-+ The CFA argument indicates the frame to which control is
-+ about to be transferred. HANDLER is the destination PC.
-+
-+ We ignore the CFA and set a temporary breakpoint at HANDLER.
-+ This is not extremely efficient but it avoids issues in gdb
-+ with computing the DWARF CFA, and it also works even in weird
-+ cases such as throwing an exception from inside a signal
-+ handler. */
-+
-+ b = SYMBOL_BLOCK_VALUE (func);
-+ ALL_BLOCK_SYMBOLS (b, iter, sym)
-+ {
-+ if (!SYMBOL_IS_ARGUMENT (sym))
-+ continue;
++CallerIs()
++CallerMatches()
+Index: gdb-7.2.90.20110703/gdb/python/lib/gdb/function/in_scope.py
+===================================================================
+--- /dev/null 1970-01-01 00:00:00.000000000 +0000
++++ gdb-7.2.90.20110703/gdb/python/lib/gdb/function/in_scope.py 2011-07-03 10:33:11.000000000 +0200
+@@ -0,0 +1,47 @@
++# In-scope function.
+
-+ if (argno == 0)
-+ ++argno;
-+ else
-+ {
-+ insert_exception_resume_breakpoint (ecs->event_thread,
-+ b, frame, sym);
-+ break;
-+ }
-+ }
-+ }
-+}
++# Copyright (C) 2008 Free Software Foundation, Inc.
+
- static void
- stop_stepping (struct execution_control_state *ecs)
- {
-diff --git a/gdb/linux-nat.c b/gdb/linux-nat.c
-index 93adfcd..34412a6 100644
---- a/gdb/linux-nat.c
-+++ b/gdb/linux-nat.c
-@@ -2587,6 +2587,39 @@ linux_nat_stopped_data_address (struct target_ops *ops, CORE_ADDR *addr_p)
- return lp->stopped_data_address_p;
- }
-
-+/* In `set follow-fork-mode child' with multithreaded parent we need to detach
-+ watchpoints from all the LWPs. In such case INFERIOR_PTID will be the
-+ non-threaded new child while LWP_LIST will still contain all the threads of
-+ the parent being detached. */
++# This program is free software; you can redistribute it and/or modify
++# it under the terms of the GNU General Public License as published by
++# the Free Software Foundation; either version 3 of the License, or
++# (at your option) any later version.
++#
++# This program is distributed in the hope that it will be useful,
++# but WITHOUT ANY WARRANTY; without even the implied warranty of
++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++# GNU General Public License for more details.
++#
++# You should have received a copy of the GNU General Public License
++# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
-+static int
-+linux_nat_detach_watchpoints (void)
-+{
-+ struct lwp_info *lp;
-+ int found = 0, retval = 0;
-+ ptid_t filter = pid_to_ptid (ptid_get_pid (inferior_ptid));
-+ struct cleanup *old_chain = save_inferior_ptid ();
++import gdb
+
-+ for (lp = lwp_list; lp; lp = lp->next)
-+ if (ptid_match (lp->ptid, filter))
-+ {
-+ inferior_ptid = lp->ptid;
-+ retval |= linux_ops->to_detach_watchpoints ();
-+ found = 1;
-+ }
++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."""
+
-+ do_cleanups (old_chain);
++ def __init__ (self):
++ super (InScope, self).__init__ ("in_scope")
+
-+ if (!found)
-+ {
-+ gdb_assert (!is_lwp (inferior_ptid));
++ def invoke (self, *vars):
++ if len (vars) == 0:
++ raise TypeError, "in_scope takes at least one argument"
+
-+ retval |= linux_ops->to_detach_watchpoints ();
-+ }
++ # 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)
+
-+ return retval;
-+}
++ block = block.superblock
+
- /* Wait until LP is stopped. */
-
- static int
-@@ -5606,6 +5639,8 @@ linux_nat_add_target (struct target_ops *t)
- t->to_thread_address_space = linux_nat_thread_address_space;
- t->to_stopped_by_watchpoint = linux_nat_stopped_by_watchpoint;
- t->to_stopped_data_address = linux_nat_stopped_data_address;
-+ if (linux_ops->to_detach_watchpoints)
-+ t->to_detach_watchpoints = linux_nat_detach_watchpoints;
-
- t->to_can_async_p = linux_nat_can_async_p;
- t->to_is_async_p = linux_nat_is_async_p;
-diff --git a/gdb/linux-tdep.c b/gdb/linux-tdep.c
-index 07fd67c..2524250 100644
---- a/gdb/linux-tdep.c
-+++ b/gdb/linux-tdep.c
-@@ -23,6 +23,8 @@
- #include "auxv.h"
- #include "target.h"
- #include "elf/common.h"
-+#include "value.h"
-+#include "infcall.h"
-
- /* This function is suitable for architectures that don't
- extend/override the standard siginfo structure. */
-diff --git a/gdb/main.c b/gdb/main.c
-index bfd1213..72faabd 100644
---- a/gdb/main.c
-+++ b/gdb/main.c
-@@ -39,6 +39,7 @@
++ return wanted == found
++
++InScope ()
+Index: gdb-7.2.90.20110703/gdb/python/py-type.c
+===================================================================
+--- gdb-7.2.90.20110703.orig/gdb/python/py-type.c 2011-01-26 21:53:45.000000000 +0100
++++ gdb-7.2.90.20110703/gdb/python/py-type.c 2011-07-03 10:33:11.000000000 +0200
+@@ -29,6 +29,8 @@
+ #include "language.h"
+ #include "vec.h"
+ #include "bcache.h"
++#include "observer.h"
++#include "gdb_assert.h"
- #include "interps.h"
- #include "main.h"
-+#include "python/python.h"
- #include "source.h"
- #include "cli/cli-cmds.h"
- #include "python/python.h"
-@@ -259,6 +260,8 @@ captured_main (void *data)
- char *cdarg = NULL;
- char *ttyarg = NULL;
+ typedef struct pyty_type_object
+ {
+@@ -37,11 +39,19 @@ typedef struct pyty_type_object
-+ int python_script = 0;
+ /* If a Type object is associated with an objfile, it is kept on a
+ doubly-linked list, rooted in the objfile. This lets us copy the
+- underlying struct type when the objfile is deleted. */
++ underlying struct type when the objfile is deleted.
+
- /* These are static so that we can take their address in an initializer. */
- static int print_help;
- static int print_version;
-@@ -443,10 +446,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'},
++ With NULL objfile Type still can be doubly-linked in the list
++ PYTY_OBJECTS_DISCARDABLE. */
+ struct pyty_type_object *prev;
+ struct pyty_type_object *next;
+ } type_object;
+
++#if 0
++/* First element of a doubly-linked list of TYPE_DISCARDABLE Types. */
++static type_object *pyty_objects_discardable;
+#endif
- {0, no_argument, 0, 0}
- };
++
+ static PyTypeObject type_object_type;
-- while (1)
-+ while (!python_script)
- {
- int option_index;
+ /* A Field object. */
+@@ -919,8 +929,63 @@ typy_richcompare (PyObject *self, PyObje
-@@ -464,6 +471,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;
-@@ -650,7 +660,31 @@ extern int gdbtk_test (char *);
+ \f
- /* 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)
++/* Key associated with each objfile pointing to the first element of
++ a doubly-linked list of Types associated with this objfile. */
+ static const struct objfile_data *typy_objfile_data_key;
+
++/* Link TYPE_OBJ to its appropriate list. Either to its objfile associated one
++ or at least to the global list for TYPE_DISCARDABLE Types. Permanent types
++ do not get linked anywhere. */
++static void
++typy_link (type_object *type_obj)
++{
++ type_obj->prev = NULL;
++
++ if (type_obj->type && TYPE_OBJFILE (type_obj->type))
+ {
-+ /* 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);
-+ }
++ struct objfile *objfile = TYPE_OBJFILE (type_obj->type);
+
-+ /* FIXME: should handle inferior I/O intelligently here.
-+ E.g., should be possible to run gdb in pipeline and have
-+ Python (and gdb) output go to stderr or file; and if a
-+ prompt is needed, open the tty. */
-+ quiet = 1;
-+ /* FIXME: should read .gdbinit if, and only if, a prompt is
-+ requested by the script. Though... maybe this is not
-+ ideal? */
-+ /* FIXME: likewise, reading in history. */
-+ inhibit_gdbinit = 1;
-+ }
-+ else if (set_args)
- {
- /* The remaining options are the command-line options for the
- inferior. The first one is the sym/exec file, and the rest
-@@ -890,7 +924,8 @@ Can't attach to process and specify a core file at the same time."));
- xfree (cmdarg);
-
- /* Read in the old history after all the command files have been read. */
-- init_history ();
-+ if (!python_script)
-+ init_history ();
-
- if (batch_flag)
- {
-@@ -901,13 +936,25 @@ Can't attach to process and specify a core file at the same time."));
- /* Show time and/or space usage. */
- do_cleanups (pre_stat_chain);
-
-- /* NOTE: cagney/1999-11-07: There is probably no reason for not
-- moving this loop and the code found in captured_command_loop()
-- 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;
++ type_obj->next = objfile_data (objfile, typy_objfile_data_key);
++ if (type_obj->next)
++ type_obj->next->prev = type_obj;
++ set_objfile_data (objfile, typy_objfile_data_key, type_obj);
+ }
-+ else
-+#endif
++#if 0
++ else if (type_obj->type && TYPE_DISCARDABLE (type_obj->type))
+ {
-+ /* 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. */
- }
-@@ -939,7 +986,12 @@ print_gdb_help (struct ui_file *stream)
- fputs_unfiltered (_("\
- This is the GNU debugger. Usage:\n\n\
- gdb [options] [executable-file [core-file or process-id]]\n\
-- 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 (_("\
-@@ -977,7 +1029,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);
++ type_obj->next = pyty_objects_discardable;
++ if (type_obj->next)
++ type_obj->next->prev = type_obj;
++ pyty_objects_discardable = type_obj;
++ }
+#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/maint.c b/gdb/maint.c
-index 28fd610..4e21476 100644
---- a/gdb/maint.c
-+++ b/gdb/maint.c
-@@ -909,4 +909,12 @@ When enabled GDB is profiled."),
- show_maintenance_profile_p,
- &maintenance_set_cmdlist,
- &maintenance_show_cmdlist);
-+ add_setshow_filename_cmd ("gdb_datadir", class_maintenance,
-+ &gdb_datadir, _("Set GDB's datadir path."),
-+ _("Show GDB's datadir path."),
-+ _("\
-+When set, GDB uses the specified path to search for data files."),
-+ NULL, NULL,
-+ &maintenance_set_cmdlist,
-+ &maintenance_show_cmdlist);
- }
-diff --git a/gdb/mi/mi-cmd-var.c b/gdb/mi/mi-cmd-var.c
-index 310ade9..d8710a1 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)
- }
- else
- {
-- /* Get varobj handle, if a valid var obj name was specified */
- struct varobj *var = varobj_get_handle (name);
-
- varobj_update_one (var, print_values, 1 /* explicit */);
-diff --git a/gdb/minsyms.c b/gdb/minsyms.c
-index cb4545c..92d4027 100644
---- a/gdb/minsyms.c
-+++ b/gdb/minsyms.c
-@@ -337,8 +337,9 @@ lookup_minimal_symbol_text (const char *name, struct objfile *objf)
- msymbol = msymbol->hash_next)
- {
- if (strcmp (SYMBOL_LINKAGE_NAME (msymbol), name) == 0 &&
-- (MSYMBOL_TYPE (msymbol) == mst_text ||
-- MSYMBOL_TYPE (msymbol) == mst_file_text))
-+ (MSYMBOL_TYPE (msymbol) == mst_text
-+ || MSYMBOL_TYPE (msymbol) == mst_text_gnu_ifunc
-+ || MSYMBOL_TYPE (msymbol) == mst_file_text))
- {
- switch (MSYMBOL_TYPE (msymbol))
- {
-@@ -700,6 +701,16 @@ lookup_minimal_symbol_by_pc (CORE_ADDR pc)
- return lookup_minimal_symbol_by_pc_section (pc, NULL);
- }
-
-+/* Return non-zero iff PC is in function implementing gnu-ifunc selection. */
++ else
++ type_obj->next = NULL;
++}
+
-+int
-+in_gnu_ifunc_stub (CORE_ADDR pc)
++/* Unlink TYPE_OBJ from its current list. Permanent types are not linked
++ anywhere and this function has no effect on them. */
++static void
++typy_unlink (type_object *type_obj)
+{
-+ struct minimal_symbol *msymbol = lookup_minimal_symbol_by_pc (pc);
++ if (type_obj->prev)
++ type_obj->prev->next = type_obj->next;
++ else if (type_obj->type && TYPE_OBJFILE (type_obj->type))
++ {
++ /* Must reset head of list. */
++ struct objfile *objfile = TYPE_OBJFILE (type_obj->type);
++
++ set_objfile_data (objfile, typy_objfile_data_key, type_obj->next);
++ }
++#if 0
++ else if (pyty_objects_discardable == type_obj)
++ pyty_objects_discardable = type_obj->next;
++#endif
+
-+ return msymbol && MSYMBOL_TYPE (msymbol) == mst_text_gnu_ifunc;
++ if (type_obj->next)
++ type_obj->next->prev = type_obj->prev;
+}
+
- /* Find the minimal symbol named NAME, and return both the minsym
- struct and its objfile. This only checks the linkage name. Sets
- *OBJFILE_P and returns the minimal symbol, if it is found. If it
-@@ -769,6 +780,7 @@ prim_record_minimal_symbol (const char *name, CORE_ADDR address,
- switch (ms_type)
- {
- case mst_text:
-+ case mst_text_gnu_ifunc:
- case mst_file_text:
- case mst_solib_trampoline:
- section = SECT_OFF_TEXT (objfile);
-@@ -1235,7 +1247,8 @@ find_solib_trampoline_target (struct frame_info *frame, CORE_ADDR pc)
+ static void
+ save_objfile_types (struct objfile *objfile, void *datum)
+ {
+@@ -938,12 +1003,13 @@ save_objfile_types (struct objfile *objf
{
- ALL_MSYMBOLS (objfile, msymbol)
- {
-- if (MSYMBOL_TYPE (msymbol) == mst_text
-+ if ((MSYMBOL_TYPE (msymbol) == mst_text
-+ || MSYMBOL_TYPE (msymbol) == mst_text_gnu_ifunc)
- && strcmp (SYMBOL_LINKAGE_NAME (msymbol),
- SYMBOL_LINKAGE_NAME (tsymbol)) == 0)
- return SYMBOL_VALUE_ADDRESS (msymbol);
-diff --git a/gdb/p-lang.c b/gdb/p-lang.c
-index 08738ac..64d2e9f 100644
---- a/gdb/p-lang.c
-+++ b/gdb/p-lang.c
-@@ -222,7 +222,11 @@ pascal_printstr (struct ui_file *stream, struct type *type,
- unsigned int things_printed = 0;
- int in_quotes = 0;
- int need_comma = 0;
-- int width = TYPE_LENGTH (type);
-+ int width;
-+
-+ /* Preserve TYPE's original type, just set its LENGTH. */
-+ check_typedef (type);
-+ width = TYPE_LENGTH (type);
-
- /* If the string was not truncated due to `set print elements', and
- the last byte of it is a null, we don't print that, in traditional C
-diff --git a/gdb/p-valprint.c b/gdb/p-valprint.c
-index 4d39bed..d0ddebc 100644
---- a/gdb/p-valprint.c
-+++ b/gdb/p-valprint.c
-@@ -38,6 +38,7 @@
- #include "p-lang.h"
- #include "cp-abi.h"
- #include "cp-support.h"
-+#include "dwarf2loc.h"
- \f
-
+ type_object *next = obj->next;
-@@ -68,8 +69,27 @@ pascal_val_print (struct type *type, const gdb_byte *valaddr,
- struct type *char_type;
- LONGEST val;
- CORE_ADDR addr;
-+ struct cleanup *back_to;
-+ struct type *saved_type = type;
-+ CORE_ADDR saved_address = address;
-+
-+ back_to = make_cleanup (null_cleanup, 0);
-+ type = object_address_get_data (type, &address);
-+ if (type == NULL)
-+ {
-+ fputs_filtered (object_address_data_not_valid (saved_type), stream);
-+ gdb_flush (stream);
-+ do_cleanups (back_to);
-+ return 0;
-+ }
-+ if (address != saved_address)
-+ {
-+ size_t length = TYPE_LENGTH (type);
+- htab_empty (copied_types);
++ gdb_assert (TYPE_OBJFILE (obj->type) == objfile);
++ typy_unlink (obj);
-- CHECK_TYPEDEF (type);
-+ valaddr = xmalloc (length);
-+ make_cleanup (xfree, (gdb_byte *) valaddr);
-+ read_memory (address, (gdb_byte *) valaddr, length);
-+ }
- switch (TYPE_CODE (type))
- {
- case TYPE_CODE_ARRAY:
-@@ -125,8 +145,9 @@ pascal_val_print (struct type *type, const gdb_byte *valaddr,
- {
- i = 0;
- }
-- val_print_array_elements (type, valaddr + embedded_offset, address, stream,
-- recurse, original_value, options, i);
-+ val_print_array_elements (saved_type, valaddr + embedded_offset,
-+ saved_address, stream, recurse,
-+ original_value, options, i);
- fprintf_filtered (stream, "}");
- }
- break;
-@@ -164,6 +185,7 @@ pascal_val_print (struct type *type, const gdb_byte *valaddr,
- /* Try to print what function it points to. */
- print_address_demangle (gdbarch, addr, stream, demangle);
- /* Return value is irrelevant except for string pointers. */
-+ do_cleanups (back_to);
- return (0);
- }
+- obj->type = copy_type_recursive (objfile, obj->type, copied_types);
++ obj->type = copy_type_recursive (obj->type, copied_types);
-@@ -252,6 +274,7 @@ pascal_val_print (struct type *type, const gdb_byte *valaddr,
- /* Return number of characters printed, including the terminating
- '\0' if we reached the end. val_print_string takes care including
- the terminating '\0' if necessary. */
-+ do_cleanups (back_to);
- return i;
+- obj->next = NULL;
+- obj->prev = NULL;
++ gdb_assert (TYPE_OBJFILE (obj->type) == NULL);
++ typy_link (obj);
- break;
-@@ -554,6 +577,7 @@ pascal_val_print (struct type *type, const gdb_byte *valaddr,
- error (_("Invalid pascal type code %d in symbol table."), TYPE_CODE (type));
+ obj = next;
}
- gdb_flush (stream);
-+ do_cleanups (back_to);
- return (0);
+@@ -954,43 +1020,28 @@ save_objfile_types (struct objfile *objf
}
- \f
-diff --git a/gdb/parse.c b/gdb/parse.c
-index c885c6a..cbf9c65 100644
---- a/gdb/parse.c
-+++ b/gdb/parse.c
-@@ -487,9 +487,21 @@ write_exp_msymbol (struct minimal_symbol *msymbol)
- pc = gdbarch_convert_from_func_ptr_addr (gdbarch, addr, ¤t_target);
- if (pc != addr)
- {
-+ struct minimal_symbol *ifunc_msym = lookup_minimal_symbol_by_pc (pc);
+
+ static void
+-set_type (type_object *obj, struct type *type)
++typy_dealloc (PyObject *obj)
+ {
+- obj->type = type;
+- obj->prev = NULL;
+- if (type && TYPE_OBJFILE (type))
+- {
+- struct objfile *objfile = TYPE_OBJFILE (type);
+-
+- obj->next = objfile_data (objfile, typy_objfile_data_key);
+- if (obj->next)
+- obj->next->prev = obj;
+- set_objfile_data (objfile, typy_objfile_data_key, obj);
+- }
+- else
+- obj->next = NULL;
++ type_object *type_obj = (type_object *) obj;
+
- /* In this case, assume we have a code symbol instead of
- a data symbol. */
-- type = mst_text;
++ typy_unlink (type_obj);
+
-+ if (ifunc_msym != NULL && MSYMBOL_TYPE (ifunc_msym) == mst_text_gnu_ifunc
-+ && SYMBOL_VALUE_ADDRESS (ifunc_msym) == pc)
-+ {
-+ /* A function descriptor has been resolved but PC is still in the
-+ gnu-ifunc resolver body (such as because inferior does not run to
-+ be able to call it). */
-+ type = mst_text_gnu_ifunc;
-+ }
-+ else
-+ type = mst_text;
- section = NULL;
- addr = pc;
- }
-@@ -521,6 +533,11 @@ write_exp_msymbol (struct minimal_symbol *msymbol)
- write_exp_elt_type (objfile_type (objfile)->nodebug_text_symbol);
- break;
++ type_obj->ob_type->tp_free (obj);
+ }
-+ case mst_text_gnu_ifunc:
-+ write_exp_elt_type (objfile_type (objfile)
-+ ->nodebug_text_gnu_ifunc_symbol);
-+ break;
-+
- case mst_data:
- case mst_file_data:
- case mst_bss:
-@@ -528,6 +545,10 @@ write_exp_msymbol (struct minimal_symbol *msymbol)
- write_exp_elt_type (objfile_type (objfile)->nodebug_data_symbol);
- break;
++#if 0
++/* Call type_mark_used for any TYPEs referenced from this GDB source file. */
+ static void
+-typy_dealloc (PyObject *obj)
++typy_types_mark_used (void)
+ {
+- type_object *type = (type_object *) obj;
+-
+- if (type->prev)
+- type->prev->next = type->next;
+- else if (type->type && TYPE_OBJFILE (type->type))
+- {
+- /* Must reset head of list. */
+- struct objfile *objfile = TYPE_OBJFILE (type->type);
+-
+- if (objfile)
+- set_objfile_data (objfile, typy_objfile_data_key, type->next);
+- }
+- if (type->next)
+- type->next->prev = type->prev;
++ type_object *type_obj;
-+ case mst_slot_got_plt:
-+ write_exp_elt_type (objfile_type (objfile)->nodebug_got_plt_symbol);
-+ break;
-+
- default:
- write_exp_elt_type (objfile_type (objfile)->nodebug_unknown_symbol);
- break;
-@@ -1412,6 +1433,7 @@ parser_fprintf (FILE *x, const char *y, ...)
+- type->ob_type->tp_free (type);
++ for (type_obj = pyty_objects_discardable;
++ type_obj != NULL;
++ type_obj = type_obj->next)
++ type_mark_used (type_obj->type);
+ }
++#endif
- int
- operator_check_standard (struct expression *exp, int pos,
-+ int (*type_func) (struct type *type, void *data),
- int (*objfile_func) (struct objfile *objfile,
- void *data),
- void *data)
-@@ -1453,7 +1475,7 @@ operator_check_standard (struct expression *exp, int pos,
- struct type *type = elts[pos + 2 + arg].type;
- struct objfile *objfile = TYPE_OBJFILE (type);
+ /* Create a new Type referring to TYPE. */
+ PyObject *
+@@ -1000,7 +1051,10 @@ type_to_type_object (struct type *type)
-- if (objfile && (*objfile_func) (objfile, data))
-+ if (objfile && objfile_func && (*objfile_func) (objfile, data))
- return 1;
- }
- }
-@@ -1471,7 +1493,8 @@ operator_check_standard (struct expression *exp, int pos,
+ type_obj = PyObject_New (type_object, &type_object_type);
+ if (type_obj)
+- set_type (type_obj, type);
++ {
++ type_obj->type = type;
++ typy_link (type_obj);
++ }
- /* Check objfile where the variable itself is placed.
- SYMBOL_OBJ_SECTION (symbol) may be NULL. */
-- if ((*objfile_func) (SYMBOL_SYMTAB (symbol)->objfile, data))
-+ if (objfile_func
-+ && (*objfile_func) (SYMBOL_SYMTAB (symbol)->objfile, data))
- return 1;
+ return (PyObject *) type_obj;
+ }
+@@ -1074,6 +1128,10 @@ gdbpy_initialize_types (void)
- /* Check objfile where is placed the code touching the variable. */
-@@ -1484,24 +1507,27 @@ operator_check_standard (struct expression *exp, int pos,
+ Py_INCREF (&field_object_type);
+ PyModule_AddObject (gdb_module, "Field", (PyObject *) &field_object_type);
++
++#if 0
++ observer_attach_mark_used (typy_types_mark_used);
++#endif
+ }
- /* Invoke callbacks for TYPE and OBJFILE if they were set as non-NULL. */
+ \f
+Index: gdb-7.2.90.20110703/gdb/python/py-value.c
+===================================================================
+--- gdb-7.2.90.20110703.orig/gdb/python/py-value.c 2011-03-18 17:09:57.000000000 +0100
++++ gdb-7.2.90.20110703/gdb/python/py-value.c 2011-07-03 10:33:11.000000000 +0200
+@@ -28,6 +28,7 @@
+ #include "infcall.h"
+ #include "expression.h"
+ #include "cp-abi.h"
++#include "observer.h"
-- if (type && TYPE_OBJFILE (type)
-+ if (type && type_func && (*type_func) (type, data))
-+ return 1;
-+ if (type && TYPE_OBJFILE (type) && objfile_func
- && (*objfile_func) (TYPE_OBJFILE (type), data))
- return 1;
-- if (objfile && (*objfile_func) (objfile, data))
-+ if (objfile && objfile_func && (*objfile_func) (objfile, data))
- return 1;
+ #ifdef HAVE_PYTHON
- return 0;
+@@ -1210,6 +1211,19 @@ gdbpy_is_value_object (PyObject *obj)
+ return PyObject_TypeCheck (obj, &value_object_type);
}
--/* Call OBJFILE_FUNC for any TYPE and OBJFILE found being referenced by EXP.
-- The functions are never called with NULL OBJFILE. Functions get passed an
-- arbitrary caller supplied DATA pointer. If any of the functions returns
-- non-zero value then (any other) non-zero value is immediately returned to
-- the caller. Otherwise zero is returned after iterating through whole EXP.
-- */
-+/* Call TYPE_FUNC and OBJFILE_FUNC for any TYPE and OBJFILE found being
-+ referenced by EXP. The functions are never called with NULL TYPE or NULL
-+ OBJFILE. Functions get passed an arbitrary caller supplied DATA pointer.
-+ If any of the functions returns non-zero value then (any other) non-zero
-+ value is immediately returned to the caller. Otherwise zero is returned
-+ after iterating through whole EXP. */
-
- static int
- exp_iterate (struct expression *exp,
-+ int (*type_func) (struct type *type, void *data),
- int (*objfile_func) (struct objfile *objfile, void *data),
- void *data)
++#if 0
++/* Call type_mark_used for any TYPEs referenced from this GDB source file. */
++
++static void
++python_types_mark_used (void)
++{
++ value_object *iter;
++
++ for (iter = values_in_python; iter; iter = iter->next)
++ type_mark_used (value_type (iter->value));
++}
++#endif
++
+ void
+ gdbpy_initialize_values (void)
{
-@@ -1516,7 +1542,9 @@ exp_iterate (struct expression *exp,
+@@ -1220,6 +1234,10 @@ gdbpy_initialize_values (void)
+ PyModule_AddObject (gdb_module, "Value", (PyObject *) &value_object_type);
- pos = endpos - oplen;
- if (exp->language_defn->la_exp_desc->operator_check (exp, pos,
-- objfile_func, data))
-+ type_func,
-+ objfile_func,
-+ data))
- return 1;
+ values_in_python = NULL;
++
++#if 0
++ observer_attach_mark_used (python_types_mark_used);
++#endif
+ }
- endpos = pos;
-@@ -1547,7 +1575,26 @@ exp_uses_objfile (struct expression *exp, struct objfile *objfile)
- {
- gdb_assert (objfile->separate_debug_objfile_backlink == NULL);
+ \f
+Index: gdb-7.2.90.20110703/gdb/python/python.c
+===================================================================
+--- gdb-7.2.90.20110703.orig/gdb/python/python.c 2011-07-02 21:33:10.000000000 +0200
++++ gdb-7.2.90.20110703/gdb/python/python.c 2011-07-03 10:33:11.000000000 +0200
+@@ -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"
-- return exp_iterate (exp, exp_uses_objfile_iter, objfile);
-+ return exp_iterate (exp, NULL, exp_uses_objfile_iter, objfile);
-+}
+ static PyMethodDef GdbMethods[];
+
+@@ -769,6 +772,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;
+
-+/* Helper for exp_types_mark_used. */
++/* True if we are currently in a call to 'gdb.cli', false otherwise. */
++static int in_cli;
+
-+static int
-+exp_types_mark_used_iter (struct type *type, void *unused)
++/* Enter the command loop. */
++
++static PyObject *
++gdbpy_cli (PyObject *unused1, PyObject *unused2)
+{
-+ type_mark_used (type);
++ if (! running_python_script || in_cli)
++ return PyErr_Format (PyExc_RuntimeError, "cannot invoke CLI recursively");
+
-+ /* Continue the traversal. */
-+ return 0;
++ in_cli = 1;
++ cli_command_loop ();
++ in_cli = 0;
++
++ Py_RETURN_NONE;
+}
+
-+/* Call type_mark_used for any type contained in EXP. */
++/* Set up the Python argument vector and evaluate a script. This is
++ used to implement 'gdb -P'. */
+
+void
-+exp_types_mark_used (struct expression *exp)
++run_python_script (int argc, char **argv)
+{
-+ exp_iterate (exp, exp_types_mark_used_iter, NULL, NULL);
- }
++ 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);
++}
++
++\f
++
- void
-diff --git a/gdb/parser-defs.h b/gdb/parser-defs.h
-index bb79ae1..fbbd600 100644
---- a/gdb/parser-defs.h
-+++ b/gdb/parser-defs.h
-@@ -194,6 +194,8 @@ extern void operator_length_standard (const struct expression *, int, int *,
- int *);
+ static PyObject *
+ gdbpy_get_current_progspace (PyObject *unused1, PyObject *unused2)
+@@ -1194,6 +1244,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" },
- extern int operator_check_standard (struct expression *exp, int pos,
-+ int (*type_func) (struct type *type,
-+ void *data),
- int (*objfile_func)
- (struct objfile *objfile, void *data),
- void *data);
-@@ -285,6 +287,7 @@ struct exp_descriptor
- value should be immediately returned to the caller. Otherwise zero
- should be returned. */
- int (*operator_check) (struct expression *exp, int pos,
-+ int (*type_func) (struct type *type, void *data),
- int (*objfile_func) (struct objfile *objfile,
- void *data),
- void *data);
-@@ -323,4 +326,8 @@ extern void parser_fprintf (FILE *, const char *, ...) ATTRIBUTE_PRINTF (2, 3);
+Index: gdb-7.2.90.20110703/gdb/python/python.h
+===================================================================
+--- gdb-7.2.90.20110703.orig/gdb/python/python.h 2011-03-14 17:09:54.000000000 +0100
++++ gdb-7.2.90.20110703/gdb/python/python.h 2011-07-03 10:33:11.000000000 +0200
+@@ -32,6 +32,8 @@ void eval_python_from_control_command (s
- extern int exp_uses_objfile (struct expression *exp, struct objfile *objfile);
+ void source_python_script (FILE *stream, const char *file);
-+extern int exp_uses_objfile (struct expression *exp, struct objfile *objfile);
++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,
+Index: gdb-7.2.90.20110703/gdb/somread.c
+===================================================================
+--- gdb-7.2.90.20110703.orig/gdb/somread.c 2011-03-07 17:17:29.000000000 +0100
++++ gdb-7.2.90.20110703/gdb/somread.c 2011-07-03 10:33:11.000000000 +0200
+@@ -439,6 +439,7 @@ static const struct sym_fns som_sym_fns
+ default_symfile_segments, /* Get segment information from a file. */
+ NULL,
+ default_symfile_relocate, /* Relocate a debug section. */
++ NULL, /* sym_get_probes */
+ &psym_functions
+ };
+
+Index: gdb-7.2.90.20110703/gdb/stack.c
+===================================================================
+--- gdb-7.2.90.20110703.orig/gdb/stack.c 2011-03-18 19:48:56.000000000 +0100
++++ gdb-7.2.90.20110703/gdb/stack.c 2011-07-03 10:33:11.000000000 +0200
+@@ -366,6 +366,7 @@ print_frame_args (struct symbol *func, s
+ {
+ const struct language_defn *language;
+ struct value_print_options opts;
++ struct cleanup *old_chain;
+
+ /* Use the appropriate language to display our symbol,
+ unless the user forced the language to a specific
+@@ -378,7 +379,13 @@ print_frame_args (struct symbol *func, s
+ get_raw_print_options (&opts);
+ opts.deref_ref = 0;
+ opts.summary = summary;
++
++ /* Frame may be needed for check_typedef of TYPE_DYNAMIC. */
++ old_chain = make_cleanup_restore_selected_frame ();
++ select_frame (frame);
+ common_val_print (val, stb->stream, 2, &opts, language);
++ do_cleanups (old_chain);
++
+ ui_out_field_stream (uiout, "value", stb);
+ }
+ else
+Index: gdb-7.2.90.20110703/gdb/stap-probe.c
+===================================================================
+--- /dev/null 1970-01-01 00:00:00.000000000 +0000
++++ gdb-7.2.90.20110703/gdb/stap-probe.c 2011-07-03 10:33:11.000000000 +0200
+@@ -0,0 +1,2041 @@
++/* SystemTap probe support for GDB.
++
++ Copyright (C) 2011 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.
+
-+extern void exp_types_mark_used (struct expression *exp);
++ 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.
+
- #endif /* PARSER_DEFS_H */
-diff --git a/gdb/ppc-linux-nat.c b/gdb/ppc-linux-nat.c
-index 18ddee7..652b02a 100644
---- a/gdb/ppc-linux-nat.c
-+++ b/gdb/ppc-linux-nat.c
-@@ -2010,6 +2010,24 @@ ppc_linux_remove_watchpoint (CORE_ADDR addr, int len, int rw,
- return ret;
- }
-
-+/* See target_detach_watchpoints. Do not use wrapper
-+ ppc_linux_remove_watchpoint as it would modify the register cache
-+ (saved_dabr_value). */
++ You should have received a copy of the GNU General Public License
++ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
-+static int
-+ppc_linux_detach_watchpoints (void)
-+{
-+ pid_t tid;
++#include "defs.h"
++#include "stap-probe.h"
++#include "vec.h"
++#include "ui-out.h"
++#include "gdb_regex.h"
++#include "objfiles.h"
++#include "arch-utils.h"
++#include "command.h"
++#include "filenames.h"
++#include "value.h"
++#include "exceptions.h"
++#include "ax.h"
++#include "ax-gdb.h"
++#include "user-regs.h"
++#include "complaints.h"
++#include "cli/cli-utils.h"
++#include "linespec.h"
+
-+ tid = TIDGET (inferior_ptid);
-+ if (tid == 0)
-+ tid = PIDGET (inferior_ptid);
++#include <ctype.h>
+
-+ if (ptrace (PTRACE_SET_DEBUGREG, tid, NULL, NULL) < 0)
-+ return -1;
-+ return 0;
-+}
++/* This define is used to inform whether we are compiling an agent
++ expression or not. */
+
- static void
- ppc_linux_new_thread (ptid_t ptid)
- {
-@@ -2349,6 +2367,7 @@ _initialize_ppc_linux_nat (void)
- t->to_region_ok_for_hw_watchpoint = ppc_linux_region_ok_for_hw_watchpoint;
- t->to_insert_watchpoint = ppc_linux_insert_watchpoint;
- t->to_remove_watchpoint = ppc_linux_remove_watchpoint;
-+ t->to_detach_watchpoints = ppc_linux_detach_watchpoints;
- t->to_stopped_by_watchpoint = ppc_linux_stopped_by_watchpoint;
- t->to_stopped_data_address = ppc_linux_stopped_data_address;
- t->to_watchpoint_addr_within_range = ppc_linux_watchpoint_addr_within_range;
-diff --git a/gdb/printcmd.c b/gdb/printcmd.c
-index 5ffa099..58d9c79 100644
---- a/gdb/printcmd.c
-+++ b/gdb/printcmd.c
-@@ -971,6 +971,11 @@ print_command_1 (char *exp, int inspect, int voidprint)
- else
- val = access_value_history (0);
-
-+ /* Do not try to OBJECT_ADDRESS_SET here anything. We are interested in the
-+ source variable base addresses as found by READ_VAR_VALUE. The value here
-+ can be already a calculated expression address inappropriate for
-+ DW_OP_push_object_address. */
++#define STAP_COMPILING_AGENT_EXPR_P(eval_info) \
++ (eval_info->aexpr != NULL)
+
- 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)
- set_internalvar (lookup_internalvar ("__"), last_examine_value);
- }
- }
++/* The various possibilities of bitness defined for a probe's argument.
+
-+/* Call type_mark_used for any TYPEs referenced from this GDB source file. */
++ The relationship is:
+
-+static void
-+print_types_mark_used (void)
++ - STAP_ARG_BITNESS_UNDEFINED: The user hasn't specified the bitness.
++ - STAP_ARG_BITNESS_32BIT_UNSIGNED: argument string starts with `4@'.
++ - STAP_ARG_BITNESS_32BIT_SIGNED: argument string starts with `-4@'.
++ - STAP_ARG_BITNESS_64BIT_UNSIGNED: argument string starts with `8@'.
++ - STAP_ARG_BITNESS_64BIT_SIGNED: argument string starts with `-8@'. */
++
++enum stap_arg_bitness
+{
-+ struct display *d;
++ STAP_ARG_BITNESS_UNDEFINED,
++ STAP_ARG_BITNESS_32BIT_UNSIGNED,
++ STAP_ARG_BITNESS_32BIT_SIGNED,
++ STAP_ARG_BITNESS_64BIT_UNSIGNED,
++ STAP_ARG_BITNESS_64BIT_SIGNED,
++};
+
-+ if (last_examine_value)
-+ type_mark_used (value_type (last_examine_value));
++/* The following structure represents a single argument for the probe. */
+
-+ for (d = display_chain; d; d = d->next)
-+ if (d->exp)
-+ exp_types_mark_used (d->exp);
-+}
++struct stap_probe_arg
++{
++ /* The bitness of this argument. */
++ enum stap_arg_bitness bitness;
+
- \f
-
- /* Add an expression to the auto-display chain.
-@@ -2869,4 +2890,6 @@ Show printing of source filename and line number with <symbol>."), NULL,
- add_com ("eval", no_class, eval_command, _("\
- Convert \"printf format string\", arg1, arg2, arg3, ..., argn to\n\
- a command line, and call it."));
++ /* The string representing this argument. */
++ char *arg_str;
++};
+
-+ observer_attach_mark_used (print_types_mark_used);
- }
-diff --git a/gdb/psymtab.c b/gdb/psymtab.c
-index 97a4eec..fce19c9 100644
---- a/gdb/psymtab.c
-+++ b/gdb/psymtab.c
-@@ -421,6 +421,14 @@ lookup_symbol_aux_psymtabs (struct objfile *objfile,
- return NULL;
- }
-
-+static void
-+pre_expand_symtabs_matching_psymtabs (struct objfile *objfile,
-+ int kind, const char *name,
-+ domain_enum domain)
++/* The maximum number of arguments that a probe can have,
++ as defined in <sys/sdt.h>. */
++
++#define STAP_MAX_ARGS 10
++
++/* Structure that holds information about all arguments of a probe. */
++
++struct stap_args_info
+{
-+ /* Nothing. */
-+}
++ /* The number of valid parsed arguments. */
++ int n_args;
+
- /* Look, in partial_symtab PST, for symbol whose natural name is NAME.
- Check the global symbols if GLOBAL, the static symbols if not. */
-
-@@ -941,7 +949,7 @@ psymtab_to_fullname (struct partial_symtab *ps)
- return NULL;
- }
-
--static char *
-+static const char *
- find_symbol_file_from_partial (struct objfile *objfile, const char *name)
- {
- struct partial_symtab *pst;
-@@ -1199,6 +1207,7 @@ const struct quick_symbol_functions psym_functions =
- forget_cached_source_info_partial,
- lookup_symtab_via_partial_symtab,
- lookup_symbol_aux_psymtabs,
-+ pre_expand_symtabs_matching_psymtabs,
- print_psymtab_stats_for_objfile,
- dump_psymtabs_for_objfile,
- relocate_psymtabs,
-diff --git a/gdb/psymtab.h b/gdb/psymtab.h
-index 9b8c8df..de8b67e 100644
---- a/gdb/psymtab.h
-+++ b/gdb/psymtab.h
-@@ -1,6 +1,6 @@
- /* Public partial symbol table definitions.
-
-- Copyright (C) 2009 Free Software Foundation, Inc.
-+ Copyright (C) 2009, 2010 Free Software Foundation, Inc.
-
- This file is part of GDB.
-
-@@ -28,4 +28,6 @@ void map_partial_symbol_filenames (void (*) (const char *, const char *,
-
- extern const struct quick_symbol_functions psym_functions;
-
-+extern const struct quick_symbol_functions dwarf2_gdb_index_functions;
++ /* The probe to which these arguments belong. */
++ struct stap_probe *probe;
+
- #endif /* PSYMTAB_H */
-diff --git a/gdb/python/lib/gdb/FrameIterator.py b/gdb/python/lib/gdb/FrameIterator.py
-new file mode 100644
-index 0000000..5654546
---- /dev/null
-+++ b/gdb/python/lib/gdb/FrameIterator.py
-@@ -0,0 +1,33 @@
-+# Iterator over frames.
++ /* Information about each argument. */
++ struct stap_probe_arg *arg;
++};
+
-+# Copyright (C) 2008, 2009 Free Software Foundation, Inc.
++/* Structure that contains all the necessary information to evaluate
++ an expression. */
+
-+# This program is free software; you can redistribute it and/or modify
-+# it under the terms of the GNU General Public License as published by
-+# the Free Software Foundation; either version 3 of the License, or
-+# (at your option) any later version.
-+#
-+# This program is distributed in the hope that it will be useful,
-+# but WITHOUT ANY WARRANTY; without even the implied warranty of
-+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-+# GNU General Public License for more details.
-+#
-+# You should have received a copy of the GNU General Public License
-+# along with this program. If not, see <http://www.gnu.org/licenses/>.
++struct stap_evaluation_info
++{
++ /* The constant pointer which holds the expression. This is primarily
++ used for printing error messages. Evaluation functions should
++ not modify this pointer directly; instead, they should use the
++ EXP_BUFFER pointer below. */
++ const char *saved_expr;
+
-+class FrameIterator:
-+ """An iterator that iterates over frames."""
++ /* Modifiable version of the above pointer. */
++ char *exp_buf;
+
-+ def __init__ (self, frame):
-+ "Initialize a FrameIterator. FRAME is the starting frame."
-+ self.frame = frame
++ /* The pointer to the current gdbarch. */
++ struct gdbarch *gdbarch;
+
-+ def __iter__ (self):
-+ return self
++ /* The pointer to the current frame, used when accessing registers'
++ contents. */
++ struct frame_info *frame;
+
-+ 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.
++ /* The bitness specified for this argument. */
++ enum stap_arg_bitness bitness;
+
-+# Copyright (C) 2008, 2009 Free Software Foundation, Inc.
++ /* If the above flag is true (one), this field will contain the
++ pointer to the agent expression. */
++ struct agent_expr *aexpr;
+
-+# This program is free software; you can redistribute it and/or modify
-+# it under the terms of the GNU General Public License as published by
-+# the Free Software Foundation; either version 3 of the License, or
-+# (at your option) any later version.
-+#
-+# This program is distributed in the hope that it will be useful,
-+# but WITHOUT ANY WARRANTY; without even the implied warranty of
-+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-+# GNU General Public License for more details.
-+#
-+# You should have received a copy of the GNU General Public License
-+# along with this program. If not, see <http://www.gnu.org/licenses/>.
++ /* The value we are modifying (for agent expression). */
++ struct axs_value *avalue;
++};
+
-+import gdb
++/* This dummy variable is used when parsing a probe's argument fails.
++ In this case, the number of arguments for this probe is zero, so that's
++ why this variable is useful. */
+
-+# FIXME: arguably all this should be on Frame somehow.
-+class FrameWrapper:
-+ def __init__ (self, frame):
-+ self.frame = frame;
++static struct stap_args_info dummy_stap_args_info =
++ { 0, NULL, NULL };
+
-+ 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
++static struct value *stap_evaluate_probe_argument_2
++ (struct stap_evaluation_info *eval_info,
++ struct value *lhs, int prec);
+
-+ 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))
++static struct value *stap_evaluate_conditionally
++ (struct stap_evaluation_info *eval_info);
+
-+ def print_frame_locals (self, stream, func):
-+ if not func:
-+ return
++/* Helper function which decides to skip whitespaces or not in a probe's
++ argument string. Basically, if we are inside a parenthesis expression
++ (i.e., inside a subexpression), we can skip whitespaces; otherwise we
++ cannot. */
+
-+ first = True
-+ block = func.value
++static void
++stap_skip_whitespace_cond (char **s, int inside_paren)
++{
++ if (inside_paren)
++ *s = skip_spaces (*s);
++}
+
-+ for sym in block:
-+ if sym.is_argument:
-+ continue;
++/* Helper function which parses a single argument in a probe's argument
++ string, based on various rules (which can be learned from the `gas'
++ manual). It returns 1 on success, or 0 otherwise. */
+
-+ self.write_symbol (stream, sym, block)
-+ stream.write ('\n')
++static int
++stap_parse_arg (const char **p)
++{
++ char *cur = (char *) *p;
++ int done = 0;
++ int paren_open = 0;
+
-+ def print_frame_args (self, stream, func):
-+ if not func:
-+ return
++ while (!done)
++ {
++ switch (*cur)
++ {
++ case ' ': case 0:
++ /* If we're here, then we have already parsed everything
++ from this argument. */
++ if (paren_open)
++ return 0;
++ done = 1;
++ break;
+
-+ first = True
-+ block = func.value
++ case '(':
++ ++paren_open;
++ ++cur;
++ stap_skip_whitespace_cond (&cur, paren_open);
++ break;
+
-+ for sym in block:
-+ if not sym.is_argument:
-+ continue;
++ case ')':
++ if (!paren_open)
++ return 0;
+
-+ if not first:
-+ stream.write (", ")
++ --paren_open;
++ ++cur;
++ if (paren_open)
++ cur = skip_spaces (cur);
++ break;
+
-+ self.write_symbol (stream, sym, block)
-+ first = False
++ case '+': case '-':
++ case '*': case '/':
++ case '>': case '<': case '|': case '&':
++ case '^': case '!':
++ {
++ char c = *cur;
+
-+ # 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 (" <function called from gdb>\n")
-+ elif self.type () == gdb.SIGTRAMP_FRAME:
-+ stream.write (" <signal handler called>\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 + " (")
++ ++cur;
++ switch (*cur)
++ {
++ case '>':
++ if (c != '<' && c != '>')
++ return 0;
+
-+ func = self.function ()
-+ self.print_frame_args (stream, func)
++ ++cur;
++ break;
+
-+ stream.write (")")
++ case '<':
++ if (c != '<')
++ return 0;
+
-+ if sal.symtab and sal.symtab.filename:
-+ stream.write (" at " + sal.symtab.filename)
-+ stream.write (":" + str (sal.line))
++ ++cur;
++ break;
+
-+ if not self.name () or (not sal.symtab or not sal.symtab.filename):
-+ lib = gdb.solib_address (pc)
-+ if lib:
-+ stream.write (" from " + lib)
++ case '=':
++ if (c != '=' && c != '<' && c != '>' && c != '!')
++ return 0;
+
-+ stream.write ("\n")
++ ++cur;
++ break;
+
-+ if full:
-+ self.print_frame_locals (stream, func)
++ case '|':
++ if (c != '|')
++ return 0;
+
-+ def __getattr__ (self, name):
-+ return getattr (self.frame, name)
-diff --git a/gdb/python/lib/gdb/__init__.py b/gdb/python/lib/gdb/__init__.py
-new file mode 100644
-index 0000000..b375c68
---- /dev/null
-+++ b/gdb/python/lib/gdb/__init__.py
-@@ -0,0 +1,19 @@
-+# Startup code.
++ ++cur;
++ break;
+
-+# Copyright (C) 2008 Free Software Foundation, Inc.
++ case '&':
++ if (c != '&')
++ return 0;
+
-+# This program is free software; you can redistribute it and/or modify
-+# it under the terms of the GNU General Public License as published by
-+# the Free Software Foundation; either version 3 of the License, or
-+# (at your option) any later version.
-+#
-+# This program is distributed in the hope that it will be useful,
-+# but WITHOUT ANY WARRANTY; without even the implied warranty of
-+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-+# GNU General Public License for more details.
-+#
-+# You should have received a copy of the GNU General Public License
-+# along with this program. If not, see <http://www.gnu.org/licenses/>.
++ ++cur;
++ break;
+
-+# Load the require command by default.
-+import gdb.command.require
-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.
++ default:
++ break;
++ }
++ /* Infix operators take two arguments, one on either
++ side. Skipping the whitespaces that may happen on the
++ right side. */
++ stap_skip_whitespace_cond (&cur, paren_open);
++ }
++ break;
+
-+# Copyright (C) 2008 Free Software Foundation, Inc.
++ case '%':
++ {
++ ++cur;
++ stap_skip_whitespace_cond (&cur, paren_open);
++ if (*cur >= 'a' && *cur <= 'z')
++ {
++ /* We're dealing with a register name. */
++ while (isalnum (*cur))
++ ++cur;
+
-+# This program is free software; you can redistribute it and/or modify
-+# it under the terms of the GNU General Public License as published by
-+# the Free Software Foundation; either version 3 of the License, or
-+# (at your option) any later version.
-+#
-+# This program is distributed in the hope that it will be useful,
-+# but WITHOUT ANY WARRANTY; without even the implied warranty of
-+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-+# GNU General Public License for more details.
-+#
-+# You should have received a copy of the GNU General Public License
-+# along with this program. If not, see <http://www.gnu.org/licenses/>.
++ stap_skip_whitespace_cond (&cur, paren_open);
++
++ /* Some registers (e.g. floating-point register stack
++ registers on Intel i386) have the following syntax:
++
++ `%st(0)', `%st(1)', and so on.
++
++ So it's ok to expect parenthesis here. */
++ if (*cur == '(')
++ {
++ ++cur;
++ stap_skip_whitespace_cond (&cur, paren_open);
++ if (!isdigit (*cur))
++ /* This is an error, since we only expect numbers
++ inside this parenthesis. */
++ return 0;
++ ++cur;
++ stap_skip_whitespace_cond (&cur, paren_open);
++ if (*cur != ')')
++ /* We only expect one number. */
++ return 0;
++ ++cur;
++ stap_skip_whitespace_cond (&cur, paren_open);
++ }
++ }
++ }
++ break;
+
-+import gdb
-+import itertools
++ case '$':
++ {
++ /* This is an integer constant. */
++ ++cur;
++ stap_skip_whitespace_cond (&cur, paren_open);
+
-+# Our only exports.
-+__all__ = ['push_frame_filter', 'create_frame_filter']
++ while (isdigit (*cur))
++ ++cur;
+
-+frame_filter = None
++ stap_skip_whitespace_cond (&cur, paren_open);
++ }
++ break;
+
-+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))
++ case '0': case '1': case '2': case '3': case '4':
++ case '5': case '6': case '7': case '8': case '9':
++ {
++ char *old = cur;
+
-+def create_frame_filter (iter):
-+ global frame_filter
-+ if frame_filter is None:
-+ return iter
-+ return frame_filter (iter)
++ /* Number. */
++ while (isdigit (*cur))
++ ++cur;
+
-diff --git a/gdb/python/lib/gdb/command/__init__.py b/gdb/python/lib/gdb/command/__init__.py
-new file mode 100644
-index 0000000..8b13789
---- /dev/null
-+++ b/gdb/python/lib/gdb/command/__init__.py
-@@ -0,0 +1 @@
++ /* We have to do a lookahead here, because the user may
++ input `2 + 2' (with spaces), and this is not an error. */
++ cur = skip_spaces (cur);
+
-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.
++ switch (*cur)
++ {
++ case '+': case '-':
++ /* We may find the `@' sign, and it means that the
++ argument has finished, so we shouldn't advance the
++ pointer. */
++ if (cur[1] && (cur[1] == '4' || cur[1] == '8')
++ && cur[2] && cur[2] == '@')
++ {
++ cur = old;
++ goto fin;
++ }
++ break;
+
-+# Copyright (C) 2008 Free Software Foundation, Inc.
++ case '*': case '/': case '>': case '<':
++ case '|': case '&': case '^': case '!':
++ /* This is a binary operation, which means we'll
++ have to find another number after the operator. */
++ break;
+
-+# This program is free software; you can redistribute it and/or modify
-+# it under the terms of the GNU General Public License as published by
-+# the Free Software Foundation; either version 3 of the License, or
-+# (at your option) any later version.
-+#
-+# This program is distributed in the hope that it will be useful,
-+# but WITHOUT ANY WARRANTY; without even the implied warranty of
-+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-+# GNU General Public License for more details.
-+#
-+# You should have received a copy of the GNU General Public License
-+# along with this program. If not, see <http://www.gnu.org/licenses/>.
++ case '(':
++ /* We may also have sentences in the form:
+
-+import gdb
++ `4 (%rax)' */
++ break;
++ }
++ }
++fin:
++ break;
++ }
++ }
+
-+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
++ *p = cur;
+
-+ def invoke(self, arg, from_tty):
-+ gdb.execute (self.real + ' ' + arg, from_tty)
++ return 1;
++}
+
-+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."""
++/* Helper function which is responsible for freeing the space allocated to
++ hold information about a probe's arguments. */
+
-+ def __init__ (self):
-+ # Completion is not quite right here.
-+ super (AliasCommand, self).__init__ ("alias", gdb.COMMAND_NONE,
-+ gdb.COMPLETE_COMMAND)
++static void
++stap_free_args_info (void *args_info_ptr)
++{
++ struct stap_args_info *a = (struct stap_args_info *) args_info_ptr;
++ int i;
+
-+ 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)
++ for (i = 0; i < a->n_args; i++)
++ {
++ xfree (a->arg[i].arg_str);
++ }
+
-+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.
++ xfree (a->arg);
++ xfree (a);
++}
+
-+# Copyright (C) 2008, 2009 Free Software Foundation, Inc.
++/* Function which parses an argument string from PROBE, correctly splitting
++ the arguments and storing their information in properly ways. This function
++ only separates the arguments, but does not evaluate them.
+
-+# This program is free software; you can redistribute it and/or modify
-+# it under the terms of the GNU General Public License as published by
-+# the Free Software Foundation; either version 3 of the License, or
-+# (at your option) any later version.
-+#
-+# This program is distributed in the hope that it will be useful,
-+# but WITHOUT ANY WARRANTY; without even the implied warranty of
-+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-+# GNU General Public License for more details.
-+#
-+# You should have received a copy of the GNU General Public License
-+# along with this program. If not, see <http://www.gnu.org/licenses/>.
++ Consider the following argument string:
+
-+import gdb
-+import gdb.backtrace
-+import itertools
-+from gdb.FrameIterator import FrameIterator
-+from gdb.FrameWrapper import FrameWrapper
-+import sys
++ `4@%eax 4@$10'
+
-+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."""
++ We have two arguments, `%eax' and `$10', both with 32-bit unsigned bitness.
++ This function basically handles them, properly filling some structures with
++ this information. */
+
-+ set_doc = "Enable or disable reverse backtraces."
-+ show_doc = "Show whether backtraces will be printed in reverse order."
++static void
++stap_parse_probe_arguments (struct stap_probe *probe)
++{
++ struct stap_args_info *args_info;
++ struct cleanup *back_to;
++ const char *cur = probe->args;
++ int current_arg = -1;
++ /* This is a state-machine parser, which means we will always be
++ in a known state when parsing an argument. The state could be
++ either `NEW_ARG' if we are parsing a new argument, `BITNESS' if
++ we are parsing the bitness-definition part (i.e., `4@'), or
++ `PARSE_ARG' if we are actually parsing the argument part. */
++ enum
++ {
++ NEW_ARG,
++ BITNESS,
++ PARSE_ARG,
++ } current_state;
++
++ /* For now, we assume everything is not going to work. */
++ probe->parsed_args = &dummy_stap_args_info;
++
++ if (!cur || !*cur || *cur == ':')
++ return;
+
-+ def __init__(self):
-+ gdb.Parameter.__init__ (self, "reverse-backtrace",
-+ gdb.COMMAND_STACK, gdb.PARAM_BOOLEAN)
-+ # Default to compatibility with gdb.
-+ self.value = False
++ args_info = xmalloc (sizeof (struct stap_args_info));
++ back_to = make_cleanup (stap_free_args_info, args_info);
++ args_info->arg = xcalloc (STAP_MAX_ARGS, sizeof (struct stap_probe_arg));
+
-+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.
-+"""
++ /* Ok, let's start. */
++ current_state = NEW_ARG;
+
-+ 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()
++ while (*cur)
++ {
++ switch (current_state)
++ {
++ case NEW_ARG:
++ ++current_arg;
+
-+ def reverse_iter (self, iter):
-+ result = []
-+ for item in iter:
-+ result.append (item)
-+ result.reverse()
-+ return result
++ if (current_arg >= STAP_MAX_ARGS)
++ {
++ complaint (&symfile_complaints,
++ _("probe `%s' has more arguments than the maximum "
++ "allowed"), probe->name);
++ do_cleanups (back_to);
++ return;
++ }
+
-+ def final_n (self, iter, x):
-+ result = []
-+ for item in iter:
-+ result.append (item)
-+ return result[x:]
++ current_state = BITNESS;
++ break;
+
-+ def invoke (self, arg, from_tty):
-+ i = 0
-+ count = 0
-+ filter = True
-+ full = False
++ case BITNESS:
++ {
++ enum stap_arg_bitness b;
++ int got_minus = 0;
+
-+ for word in arg.split (" "):
-+ if word == '':
-+ continue
-+ elif word == 'raw':
-+ filter = False
-+ elif word == 'full':
-+ full = True
-+ else:
-+ count = int (word)
++ /* We expect to find something like:
+
-+ # 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)
++ N@OP
+
-+ # Now wrap in an iterator that numbers the frames.
-+ iter = itertools.izip (itertools.count (0), iter)
++ Where `N' can be [+,-][4,8]. This is not mandatory, so
++ we check it here. If we don't find it, go to the next
++ state. */
++ if ((*cur == '-' && cur[1] && cur[2] != '@')
++ && cur[1] != '@')
++ {
++ current_state = PARSE_ARG;
++ args_info->arg[current_arg].bitness
++ = STAP_ARG_BITNESS_UNDEFINED;
++ break;
++ }
+
-+ # Reverse if the user wanted that.
-+ if self.reverse.value:
-+ iter = self.reverse_iter (iter)
++ if (*cur == '-')
++ {
++ /* Discard the `-'. */
++ ++cur;
++ got_minus = 1;
++ }
+
-+ # Extract sub-range user wants.
-+ if count < 0:
-+ iter = self.final_n (iter, count)
-+ elif count > 0:
-+ iter = itertools.islice (iter, 0, count)
++ if (*cur == '4')
++ b = got_minus ? STAP_ARG_BITNESS_32BIT_SIGNED
++ : STAP_ARG_BITNESS_32BIT_UNSIGNED;
++ else if (*cur == '8')
++ b = got_minus ? STAP_ARG_BITNESS_64BIT_SIGNED
++ : STAP_ARG_BITNESS_64BIT_UNSIGNED;
++ else
++ {
++ /* We have an error, because we don't expect anything
++ except 4 and 8. */
++ complaint (&symfile_complaints,
++ _("unrecognized bitness `%c' for probe `%s'"),
++ *cur, probe->name);
++ do_cleanups (back_to);
++ return;
++ }
+
-+ for pair in iter:
-+ sys.stdout.write ("#%-2d" % pair[0])
-+ pair[1].describe (sys.stdout, full)
++ args_info->arg[current_arg].bitness = b;
++ /* Discard the number and the `@' sign. */
++ cur += 2;
++ /* Move on. */
++ current_state = PARSE_ARG;
++ }
++ break;
+
-+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.
++ case PARSE_ARG:
++ {
++ const char *start = cur;
+
-+# Copyright (C) 2008 Free Software Foundation, Inc.
++ if (!stap_parse_arg (&cur))
++ {
++ /* We have tried to parse this argument, but it's
++ malformed. This is an error. */
++ do_cleanups (back_to);
++ return;
++ }
+
-+# This program is free software; you can redistribute it and/or modify
-+# it under the terms of the GNU General Public License as published by
-+# the Free Software Foundation; either version 3 of the License, or
-+# (at your option) any later version.
-+#
-+# This program is distributed in the hope that it will be useful,
-+# but WITHOUT ANY WARRANTY; without even the implied warranty of
-+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-+# GNU General Public License for more details.
-+#
-+# You should have received a copy of the GNU General Public License
-+# along with this program. If not, see <http://www.gnu.org/licenses/>.
++ args_info->arg[current_arg].arg_str
++ = savestring (start, cur - start);
++ /* Start it over again. */
++ cur = skip_spaces ((char *) cur);
++ current_state = NEW_ARG;
++ }
++ break;
++ }
+
-+import gdb
++ if (!*cur && current_state != NEW_ARG)
++ {
++ /* We reached the end of the argument string, but we're
++ still in the middle of the process of parsing an argument.
++ It means the argument string is malformed. */
++ complaint (&symfile_complaints,
++ _("malformed argument for probe `%s'"),
++ probe->name);
++ do_cleanups (back_to);
++ return;
++ }
++ }
+
-+class IgnoreErrorsCommand (gdb.Command):
-+ """Execute a single command, ignoring all errors.
-+Only one-line commands are supported.
-+This is primarily useful in scripts."""
++ args_info->n_args = current_arg + 1;
++ args_info->arg = xrealloc (args_info->arg,
++ args_info->n_args
++ * sizeof (struct stap_probe_arg));
++ args_info->probe = probe;
+
-+ def __init__ (self):
-+ super (IgnoreErrorsCommand, self).__init__ ("ignore-errors",
-+ gdb.COMMAND_OBSCURE,
-+ # FIXME...
-+ gdb.COMPLETE_COMMAND)
++ probe->parsed_args = args_info;
+
-+ def invoke (self, arg, from_tty):
-+ try:
-+ gdb.execute (arg, from_tty)
-+ except:
-+ pass
++ discard_cleanups (back_to);
++}
+
-+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
++/* See definition in stap-probe.h. */
++
++int
++stap_get_probe_argument_count (const struct stap_probe *probe)
++{
++ if (!probe->parsed_args)
++ stap_parse_probe_arguments ((struct stap_probe *) probe);
++
++ return probe->parsed_args->n_args;
++}
++
++/* Returns the operator precedence level of OP, or zero if the operator
++ code was not recognized.
++ The levels were taken from the gas manual. */
++
++static int
++stap_get_operator_prec (enum exp_opcode op)
++{
++ switch (op)
++ {
++ case BINOP_LOGICAL_OR:
++ return 1;
+
-+# Copyright (C) 2008, 2009 Free Software Foundation, Inc.
++ case BINOP_LOGICAL_AND:
++ return 2;
+
-+# This program is free software; you can redistribute it and/or modify
-+# it under the terms of the GNU General Public License as published by
-+# the Free Software Foundation; either version 3 of the License, or
-+# (at your option) any later version.
-+#
-+# This program is distributed in the hope that it will be useful,
-+# but WITHOUT ANY WARRANTY; without even the implied warranty of
-+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-+# GNU General Public License for more details.
-+#
-+# You should have received a copy of the GNU General Public License
-+# along with this program. If not, see <http://www.gnu.org/licenses/>.
++ case BINOP_ADD: case BINOP_SUB:
++ case BINOP_EQUAL: case BINOP_NOTEQUAL:
++ case BINOP_LESS: case BINOP_LEQ:
++ case BINOP_GTR: case BINOP_GEQ:
++ return 3;
+
-+import gdb
++ case BINOP_BITWISE_IOR: case BINOP_BITWISE_AND:
++ case BINOP_BITWISE_XOR: case UNOP_LOGICAL_NOT:
++ return 4;
+
-+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."""
++ case BINOP_MUL: case BINOP_DIV: case BINOP_REM:
++ case BINOP_LSH: case BINOP_RSH:
++ return 5;
+
-+ def __init__ (self):
-+ super (Pahole, self).__init__ ("pahole", gdb.COMMAND_NONE,
-+ gdb.COMPLETE_SYMBOL)
++ default:
++ return 0;
++ }
++}
+
-+ 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
++/* Given S, this function reads the operator in it and fills the OP
++ pointer with its code. Returns 1 on success, zero if the operator
++ was not recognized. */
+
-+ ftype = field.type.strip_typedefs()
++static int
++stap_get_opcode (char **s, enum exp_opcode *op)
++{
++ char c = **s;
++ int ret = 1;
+
-+ 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
++ *s += 1;
+
-+ # TARGET_CHAR_BIT
-+ print ' /* %3d %3d */' % (int (bitpos / 8), int (fieldsize / 8)),
-+ bitpos = bitpos + fieldsize
++ switch (c)
++ {
++ case '*':
++ *op = BINOP_MUL;
++ break;
+
-+ 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)
++ case '/':
++ *op = BINOP_DIV;
++ break;
+
-+ print ' ' * (14 + 2 * level),
-+ print '} %s' % name
++ case '%':
++ {
++ if (isalpha (**s))
++ {
++ /* Dealing with a register name. */
++ ret = 0;
++ break;
++ }
+
-+ 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, '')
++ *op = BINOP_REM;
++ }
++ break;
+
-+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.
++ case '<':
++ *op = BINOP_LESS;
++ if (**s == '<')
++ {
++ *s += 1;
++ *op = BINOP_LSH;
++ }
++ else if (**s == '=')
++ {
++ *s += 1;
++ *op = BINOP_LEQ;
++ }
++ else if (**s == '>')
++ {
++ *s += 1;
++ *op = BINOP_NOTEQUAL;
++ }
++ break;
+
-+# Copyright (C) 2008, 2009 Free Software Foundation, Inc.
++ case '>':
++ *op = BINOP_GTR;
++ if (**s == '>')
++ {
++ *s += 1;
++ *op = BINOP_RSH;
++ }
++ else if (**s == '=')
++ {
++ *s += 1;
++ *op = BINOP_GEQ;
++ }
++ break;
+
-+# This program is free software; you can redistribute it and/or modify
-+# it under the terms of the GNU General Public License as published by
-+# the Free Software Foundation; either version 3 of the License, or
-+# (at your option) any later version.
-+#
-+# This program is distributed in the hope that it will be useful,
-+# but WITHOUT ANY WARRANTY; without even the implied warranty of
-+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-+# GNU General Public License for more details.
-+#
-+# You should have received a copy of the GNU General Public License
-+# along with this program. If not, see <http://www.gnu.org/licenses/>.
++ case '|':
++ *op = BINOP_BITWISE_IOR;
++ if (**s == '|')
++ {
++ *s += 1;
++ *op = BINOP_LOGICAL_OR;
++ }
++ break;
+
-+import gdb
-+import os
++ case '&':
++ *op = BINOP_BITWISE_AND;
++ if (**s == '&')
++ {
++ *s += 1;
++ *op = BINOP_LOGICAL_AND;
++ }
++ break;
+
-+class RequireCommand (gdb.Command):
-+ """Prefix command for requiring features."""
++ case '^':
++ *op = BINOP_BITWISE_XOR;
++ break;
+
-+ def __init__ (self):
-+ super (RequireCommand, self).__init__ ("require",
-+ gdb.COMMAND_SUPPORT,
-+ gdb.COMPLETE_NONE,
-+ True)
++ case '!':
++ *op = UNOP_LOGICAL_NOT;
++ break;
+
-+class RequireSubcommand (gdb.Command):
-+ """Demand-load a command by name."""
++ case '+':
++ *op = BINOP_ADD;
++ break;
+
-+ 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
++ case '-':
++ *op = BINOP_SUB;
++ break;
+
-+ def invoke (self, arg, from_tty):
-+ for cmd in arg.split():
-+ exec ('import gdb.' + self.name + '.' + cmd, globals ())
++ case '=':
++ if (**s != '=')
++ {
++ ret = 0;
++ break;
++ }
++ *op = BINOP_EQUAL;
++ break;
+
-+ 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
++ default:
++ /* We didn't find any operator. */
++ *s -= 1;
++ return 0;
++ }
+
-+RequireCommand()
-+RequireSubcommand("command")
-+RequireSubcommand("function")
-diff --git a/gdb/python/lib/gdb/command/save_breakpoints.py b/gdb/python/lib/gdb/command/save_breakpoints.py
-new file mode 100644
-index 0000000..6143187
---- /dev/null
-+++ b/gdb/python/lib/gdb/command/save_breakpoints.py
-@@ -0,0 +1,65 @@
-+# Save breakpoints.
++ return ret;
++}
+
-+# Copyright (C) 2008, 2009 Free Software Foundation, Inc.
++/* Given the operator OPCODE, this function generates agent bytecode
++ for it. */
+
-+# This program is free software; you can redistribute it and/or modify
-+# it under the terms of the GNU General Public License as published by
-+# the Free Software Foundation; either version 3 of the License, or
-+# (at your option) any later version.
-+#
-+# This program is distributed in the hope that it will be useful,
-+# but WITHOUT ANY WARRANTY; without even the implied warranty of
-+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-+# GNU General Public License for more details.
-+#
-+# You should have received a copy of the GNU General Public License
-+# along with this program. If not, see <http://www.gnu.org/licenses/>.
++static void
++stap_opcode_to_ax (struct stap_evaluation_info *eval_info,
++ enum exp_opcode opcode)
++{
++ struct agent_expr *expr = eval_info->aexpr;
+
-+from __future__ import with_statement
-+import gdb
++ switch (opcode)
++ {
++ case BINOP_MUL:
++ ax_simple (expr, aop_mul);
++ break;
+
-+class SavePrefixCommand (gdb.Command):
-+ "Prefix command for saving things."
++ case BINOP_DIV:
++ ax_simple (expr, aop_div_signed);
++ break;
+
-+ def __init__ (self):
-+ super (SavePrefixCommand, self).__init__ ("save",
-+ gdb.COMMAND_SUPPORT,
-+ gdb.COMPLETE_NONE, True)
++ case BINOP_REM:
++ ax_simple (expr, aop_rem_unsigned);
++ break;
+
-+class SaveBreakpointsCommand (gdb.Command):
-+ """Save the current breakpoints to a file.
-+This command takes a single argument, a file name.
-+The breakpoints can be restored using the 'source' command."""
++ case BINOP_LESS:
++ ax_simple (expr, aop_less_signed);
++ break;
+
-+ def __init__ (self):
-+ super (SaveBreakpointsCommand, self).__init__ ("save breakpoints",
-+ gdb.COMMAND_SUPPORT,
-+ gdb.COMPLETE_FILENAME)
++ case BINOP_LEQ:
++ /* A <= B is !(B < A) */
++ ax_simple (expr, aop_swap);
++ ax_simple (expr, aop_less_signed);
++ ax_simple (expr, aop_log_not);
++ break;
+
-+ def invoke (self, arg, from_tty):
-+ self.dont_repeat ()
-+ bps = gdb.breakpoints ()
-+ if bps is None:
-+ raise RuntimeError, 'No breakpoints to save'
-+ with open (arg.strip (), 'w') as f:
-+ for bp in bps:
-+ print >> f, "break", bp.location,
-+ if bp.thread is not None:
-+ print >> f, " thread", bp.thread,
-+ if bp.condition is not None:
-+ print >> f, " if", bp.condition,
-+ print >> f
-+ if not bp.enabled:
-+ print >> f, "disable $bpnum"
-+ # Note: we don't save the ignore count; there doesn't
-+ # seem to be much point.
-+ commands = bp.commands
-+ if commands is not None:
-+ print >> f, "commands"
-+ # Note that COMMANDS has a trailing newline.
-+ print >> f, commands,
-+ print >> f, "end"
-+ print >> f
-+
-+SavePrefixCommand ()
-+SaveBreakpointsCommand ()
-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.
++ case BINOP_GTR:
++ /* A > B is B < A */
++ ax_simple (expr, aop_swap);
++ ax_simple (expr, aop_less_signed);
++ break;
+
-+# Copyright (C) 2009 Free Software Foundation, Inc.
++ case BINOP_GEQ:
++ /* A >= B is !(A < B) */
++ ax_simple (expr, aop_less_signed);
++ ax_simple (expr, aop_log_not);
++ break;
+
-+# This program is free software; you can redistribute it and/or modify
-+# it under the terms of the GNU General Public License as published by
-+# the Free Software Foundation; either version 3 of the License, or
-+# (at your option) any later version.
-+#
-+# This program is distributed in the hope that it will be useful,
-+# but WITHOUT ANY WARRANTY; without even the implied warranty of
-+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-+# GNU General Public License for more details.
-+#
-+# You should have received a copy of the GNU General Public License
-+# along with this program. If not, see <http://www.gnu.org/licenses/>.
++ case BINOP_NOTEQUAL:
++ ax_simple (expr, aop_equal);
++ ax_simple (expr, aop_log_not);
++ break;
+
-+import gdb
-+import re
-+from gdb.FrameIterator import FrameIterator
-+from gdb.FrameWrapper import FrameWrapper
++ case BINOP_LSH:
++ ax_simple (expr, aop_lsh);
++ break;
+
-+class UptoPrefix (gdb.Command):
-+ def __init__ (self):
-+ super (UptoPrefix, self).__init__ ("upto", gdb.COMMAND_STACK,
-+ prefix = True)
++ case BINOP_RSH:
++ ax_simple (expr, aop_rsh_unsigned);
++ break;
+
-+class UptoImplementation (gdb.Command):
-+ def __init__ (self, subcommand):
-+ super (UptoImplementation, self).__init__ ("upto " + subcommand,
-+ gdb.COMMAND_STACK)
++ case BINOP_BITWISE_IOR:
++ ax_simple (expr, aop_bit_or);
++ break;
++
++ case BINOP_LOGICAL_OR:
++ error (_("Operator logical-or (`||') not supported yet."));
++ break;
+
-+ 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'
++ case BINOP_BITWISE_AND:
++ ax_simple (expr, aop_bit_and);
++ break;
+
-+ def invoke (self, arg, from_tty):
-+ self.rx = re.compile (arg)
-+ self.search ()
++ case BINOP_LOGICAL_AND:
++ error (_("Operator logical-and (`&&') not supported yet."));
++ break;
+
-+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."""
++ case BINOP_BITWISE_XOR:
++ ax_simple (expr, aop_bit_xor);
++ break;
+
-+ def __init__ (self):
-+ super (UptoSymbolCommand, self).__init__ ("symbol")
++ case UNOP_LOGICAL_NOT:
++ ax_simple (expr, aop_log_not);
++ break;
+
-+ def filter (self, frame):
-+ name = frame.name ()
-+ if name is not None:
-+ if self.rx.search (name) is not None:
-+ return True
-+ return False
++ case BINOP_ADD:
++ ax_simple (expr, aop_add);
++ break;
+
-+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."""
++ case BINOP_SUB:
++ ax_simple (expr, aop_sub);
++ break;
+
-+ def __init__ (self):
-+ super (UptoSourceCommand, self).__init__ ("source")
++ case BINOP_EQUAL:
++ ax_simple (expr, aop_equal);
++ break;
+
-+ 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
++ default:
++ error (_("Invalid operator."));
++ }
++}
+
-+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."""
++/* Returns 1 if *S is an operator, zero otherwise. */
+
-+ def __init__ (self):
-+ super (UptoObjectCommand, self).__init__ ("object")
++static int
++stap_is_operator (char *s)
++{
++ char op;
+
-+ 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
++ if (!s || !*s)
++ return 0;
+
-+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."""
++ op = *s;
+
-+ def __init__ (self):
-+ super (UptoWhereCommand, self).__init__ ("where")
++ if (*s == '%' && isalpha (s[1]))
++ /* Register name. */
++ return 0;
+
-+ def filter (self, frame):
-+ try:
-+ if gdb.parse_and_eval (self.expression):
-+ return True
-+ except:
-+ pass
-+ return False
++ return (op == '+' || op == '-' || op == '*' || op == '/'
++ || op == '>' || op == '<' || op == '!' || op == '^'
++ || op == '|' || op == '&' || op == '%' || op == '=');
++}
+
-+ def invoke (self, arg, from_tty):
-+ self.expression = arg
-+ self.search ()
++/* This function fetches the value of the register whose
++ name starts in the expression buffer. It also applies any register
++ displacements (e.g., `-4(%eax)'), and indirects the contents of the
++ register (e.g., `(%eax)'). It returns RET if the operation has succeeded,
++ or calls `error' otherwise. */
+
-+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 @@
++static struct value *
++stap_fetch_reg_value (struct stap_evaluation_info *eval_info,
++ struct value *displacement)
++{
++ const char *start;
++ char *s = eval_info->exp_buf;
++ struct gdbarch *gdbarch = eval_info->gdbarch;
++ struct frame_info *frame = eval_info->frame;
++ enum stap_arg_bitness bitness = eval_info->bitness;
++ char *regname;
++ int len, regnum, indirect_p = 0;
++ struct value *ret = NULL;
++
++ /* The function which called us did not check if the expression
++ buffer was empty. */
++ gdb_assert (s && *s);
+
-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.
++ if (STAP_COMPILING_AGENT_EXPR_P (eval_info))
++ /* If we are compiling, we cannot return NULL because that would
++ lead to errors in future evaluations. That's why we just make
++ this dummy value, representing that the return value of this
++ function is not NULL. */
++ ret = value_from_longest (builtin_type (gdbarch)->builtin_int, 0);
+
-+# Copyright (C) 2008 Free Software Foundation, Inc.
++ /* Valid register name on x86 platforms are:
+
-+# This program is free software; you can redistribute it and/or modify
-+# it under the terms of the GNU General Public License as published by
-+# the Free Software Foundation; either version 3 of the License, or
-+# (at your option) any later version.
-+#
-+# This program is distributed in the hope that it will be useful,
-+# but WITHOUT ANY WARRANTY; without even the implied warranty of
-+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-+# GNU General Public License for more details.
-+#
-+# You should have received a copy of the GNU General Public License
-+# along with this program. If not, see <http://www.gnu.org/licenses/>.
++ [paren]%{a-z0-9}[paren]
+
-+import gdb
-+import re
++ Let's check for that here. */
++ if (*s == '(')
++ {
++ ++s;
++ if (!*s || *s != '%'
++ || (*s == '%' && !isalpha (s[1])))
++ error (_("Invalid register name on expression `%s'."),
++ eval_info->saved_expr);
++ ++s;
++ /* The presence of parenthesis means that we want to indirect
++ the register. */
++ indirect_p = 1;
++ }
++ else if (*s == '%')
++ {
++ ++s;
++ if (!*s || !isalpha (*s))
++ error (_("Invalid register name on expression `%s'."),
++ eval_info->saved_expr);
++ }
++ else
++ error (_("Invalid register name on expression `%s'."),
++ eval_info->saved_expr);
+
-+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."""
++ if (displacement && !indirect_p)
++ /* We cannot apply displacement to non-indirect register access. */
++ error (_("Trying to apply displacement without indirecting register "
++ "on expression `%s'."), eval_info->saved_expr);
+
-+ def __init__ (self):
-+ super (CallerIs, self).__init__ ("caller_is")
++ /* Ok, let's calculate the size of the register name. */
++ start = s;
++ while (isalnum (*s))
++ ++s;
+
-+ def invoke (self, name, nframes = 1):
-+ frame = gdb.selected_frame ()
-+ while nframes > 0:
-+ frame = frame.older ()
-+ nframes = nframes - 1
-+ return frame.name () == name.string ()
++ len = s - start;
+
-+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."""
++ if (indirect_p && *s == ')')
++ ++s;
+
-+ def __init__ (self):
-+ super (CallerMatches, self).__init__ ("caller_matches")
++ regname = alloca (len + 1);
++ strncpy (regname, start, len);
++ regname[len] = '\0';
+
-+ 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
++ /* Translating the register name into the corresponding number. */
++ regnum = user_reg_map_name_to_regnum (gdbarch, regname, len);
+
-+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.
++ if (regnum == -1)
++ error (_("Invalid register name `%s' on expression `%s'."),
++ regname, eval_info->saved_expr);
+
-+# Copyright (C) 2008 Free Software Foundation, Inc.
++ if (STAP_COMPILING_AGENT_EXPR_P (eval_info))
++ ax_reg (eval_info->aexpr, regnum);
++ else
++ ret = value_of_register (regnum, frame);
+
-+# This program is free software; you can redistribute it and/or modify
-+# it under the terms of the GNU General Public License as published by
-+# the Free Software Foundation; either version 3 of the License, or
-+# (at your option) any later version.
-+#
-+# This program is distributed in the hope that it will be useful,
-+# but WITHOUT ANY WARRANTY; without even the implied warranty of
-+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-+# GNU General Public License for more details.
-+#
-+# You should have received a copy of the GNU General Public License
-+# along with this program. If not, see <http://www.gnu.org/licenses/>.
++ if (indirect_p)
++ {
++ struct type *t = NULL;
++ enum agent_op aop = aop_ref32;
+
-+import gdb
++ /* If the user has specified that the register must be indirected,
++ we should know what's the correct type to cast it before making
++ the indirection. This type corresponds to the bitness specified
++ before the `@' sign on the argument string, or it defaults to
++ `unsigned long' if the `@' were not present. */
+
-+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."""
++ switch (bitness)
++ {
++ case STAP_ARG_BITNESS_UNDEFINED:
++ if (STAP_COMPILING_AGENT_EXPR_P (eval_info))
++ {
++ if (gdbarch_addr_bit (gdbarch) == 32)
++ aop = aop_ref32;
++ else
++ aop = aop_ref64;
++ }
++ else
++ {
++ if (gdbarch_addr_bit (gdbarch) == 32)
++ t = lookup_pointer_type
++ (builtin_type (gdbarch)->builtin_uint32);
++ else
++ t = lookup_pointer_type
++ (builtin_type (gdbarch)->builtin_uint64);
++ }
++ break;
+
-+ def __init__ (self):
-+ super (InScope, self).__init__ ("in_scope")
++ case STAP_ARG_BITNESS_32BIT_SIGNED:
++ if (STAP_COMPILING_AGENT_EXPR_P (eval_info))
++ aop = aop_ref32;
++ else
++ t = lookup_pointer_type
++ (builtin_type (gdbarch)->builtin_int32);
++ break;
+
-+ def invoke (self, *vars):
-+ if len (vars) == 0:
-+ raise TypeError, "in_scope takes at least one argument"
++ case STAP_ARG_BITNESS_32BIT_UNSIGNED:
++ if (STAP_COMPILING_AGENT_EXPR_P (eval_info))
++ aop = aop_ref32;
++ else
++ t = lookup_pointer_type
++ (builtin_type (gdbarch)->builtin_uint32);
++ break;
+
-+ # 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)
++ case STAP_ARG_BITNESS_64BIT_SIGNED:
++ if (STAP_COMPILING_AGENT_EXPR_P (eval_info))
++ aop = aop_ref64;
++ else
++ t = lookup_pointer_type
++ (builtin_type (gdbarch)->builtin_int64);
++ break;
+
-+ block = block.superblock
++ case STAP_ARG_BITNESS_64BIT_UNSIGNED:
++ if (STAP_COMPILING_AGENT_EXPR_P (eval_info))
++ aop = aop_ref64;
++ else
++ t = lookup_pointer_type
++ (builtin_type (gdbarch)->builtin_uint64);
++ break;
+
-+ return wanted == found
++ default:
++ internal_error (__FILE__, __LINE__,
++ _("Undefined bitness for probe."));
++ break;
++ }
+
-+InScope ()
-diff --git a/gdb/python/py-cmd.c b/gdb/python/py-cmd.c
-index 2cff4ba..9255336 100644
---- a/gdb/python/py-cmd.c
-+++ b/gdb/python/py-cmd.c
-@@ -49,8 +49,7 @@ static struct cmdpy_completer completers[] =
-
- #define N_COMPLETERS (sizeof (completers) / sizeof (completers[0]))
-
--/* A gdb command. For the time being only ordinary commands (not
-- set/show commands) are allowed. */
-+/* A gdb command. */
- struct cmdpy_object
- {
- PyObject_HEAD
-diff --git a/gdb/python/py-hooks.c b/gdb/python/py-hooks.c
-new file mode 100644
-index 0000000..a3140bc
---- /dev/null
-+++ b/gdb/python/py-hooks.c
-@@ -0,0 +1,50 @@
-+/* Notifications from gdb to Python
++ if (displacement)
++ {
++ if (STAP_COMPILING_AGENT_EXPR_P (eval_info))
++ {
++ ax_const_l (eval_info->aexpr, value_as_long (displacement));
++ ax_simple (eval_info->aexpr, aop_add);
++ }
++ else
++ ret = value_ptradd (ret, value_as_long (displacement));
++ }
+
-+ Copyright (C) 2008 Free Software Foundation, Inc.
++ if (STAP_COMPILING_AGENT_EXPR_P (eval_info))
++ {
++ if (trace_kludge)
++ {
++ gdb_assert (aop == aop_ref32 || aop == aop_ref64);
++ ax_trace_quick (eval_info->aexpr, aop == aop_ref32 ? 4 : 8);
++ }
++ ax_simple (eval_info->aexpr, aop);
++ }
++ else
++ {
++ ret = value_cast (t, ret);
++ ret = value_ind (ret);
++ }
++ }
+
-+ This file is part of GDB.
++ /* Updating the expression buffer pointer, because we have made
++ some modifications to it before. */
++ eval_info->exp_buf = s;
+
-+ This program is free software; you can redistribute it and/or modify
-+ it under the terms of the GNU General Public License as published by
-+ the Free Software Foundation; either version 3 of the License, or
-+ (at your option) any later version.
++ return ret;
++}
+
-+ This program is distributed in the hope that it will be useful,
-+ but WITHOUT ANY WARRANTY; without even the implied warranty of
-+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-+ GNU General Public License for more details.
++/* This function tries to evaluate a single operand of the expression.
+
-+ You should have received a copy of the GNU General Public License
-+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
++ Single operands can be:
+
-+#include "defs.h"
-+#include "cli/cli-decode.h"
-+#include "charset.h"
-+#include "python.h"
-+#include "python-internal.h"
-+#include "observer.h"
++ - unary operators `-' and `~';
++ - integer constants (beginning with `$');
++ - register access, with/out displacement and indirection. */
+
-+PyObject *
-+gdbpy_get_hook_function (const char *name)
++static struct value *
++stap_evaluate_single_operand (struct stap_evaluation_info *eval_info)
+{
-+ PyObject *hooks;
-+ PyObject *result;
++ struct gdbarch *gdbarch = eval_info->gdbarch;
++ struct frame_info *frame = eval_info->frame;
++ enum stap_arg_bitness bitness = eval_info->bitness;
++ struct value *res = NULL;
+
-+ if (! PyObject_HasAttrString (gdb_module, "hooks"))
-+ return NULL;
-+ hooks = PyObject_GetAttrString (gdb_module, "hooks");
-+ if (! hooks)
-+ return NULL;
-+ /* The cast is because the Python function doesn't declare const argument.
-+ This is a problem in Python version 2.4, but not in 2.5. */
-+ if (! PyObject_HasAttrString (hooks, (char *) name))
++ if (STAP_COMPILING_AGENT_EXPR_P (eval_info))
++ /* If we are compiling, we cannot return NULL because that would
++ lead to errors in future evaluations. That's why we just make
++ this dummy value, representing that the return value of this
++ function is not NULL. */
++ res = value_from_longest (builtin_type (gdbarch)->builtin_int, 0);
++
++ switch (*eval_info->exp_buf)
+ {
-+ Py_DECREF (hooks);
-+ return NULL;
-+ }
-+ /* The cast is because the Python function doesn't declare const argument.
-+ This is a problem in Python version 2.4, but not in 2.5. */
-+ result = PyObject_GetAttrString (hooks, (char *) name);
-+ Py_DECREF (hooks);
-+ return result;
-+}
-diff --git a/gdb/python/py-membuf.c b/gdb/python/py-membuf.c
-new file mode 100644
-index 0000000..7bc294c
---- /dev/null
-+++ b/gdb/python/py-membuf.c
-@@ -0,0 +1,268 @@
-+/* Python interface to the inferior memory.
++ case '-': case '~':
++ {
++ char c = *eval_info->exp_buf;
+
-+ Copyright (C) 2008, 2009 Free Software Foundation, Inc.
++ /* This is an unary operator (either `-' or `~').
+
-+ This file is part of GDB.
++ If it is followed by a parenthesis, and this parenthesis
++ is NOT followed by a `%', then we are dealing with an expression
++ like `-(2 + 3)' or `~(2 + 3)'. We just have to treat separately
++ and return the result after applying the operation (`-' or `~').
+
-+ 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.
++ If it is followed by a digit, then we have only one choice: it
++ is a displacement argument for a register access, like
++ `-4(%eax)'. It also means that the operator can *only* be `-',
++ and the characters immediately after the number *must* be `(%'.
+
-+ 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.
++ If it is followed by a `$', then it is an integer constant, and
++ we should apply the correct operation to it. */
+
-+ You should have received a copy of the GNU General Public License
-+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
++ ++eval_info->exp_buf;
++ eval_info->exp_buf = skip_spaces (eval_info->exp_buf);
++ if (*eval_info->exp_buf
++ && *eval_info->exp_buf == '('
++ && eval_info->exp_buf[1] != '%')
++ {
++ struct value *tmp_res;
+
-+#include "defs.h"
-+#include "exceptions.h"
-+#include "gdbcore.h"
-+#include "python-internal.h"
++ /* We're not dealing with a register name, but with an
++ expression like `-(2 + 3)' or `~(2 + 3)'. We first have
++ to evaluate the right side of the expression (i.e., the
++ parenthesis), and then apply the specified operation
++ (either `-' or `~') to it. */
++ tmp_res = stap_evaluate_conditionally (eval_info);
+
-+typedef struct {
-+ PyObject_HEAD
-+ void *buffer;
++ if (c == '-')
++ {
++ if (STAP_COMPILING_AGENT_EXPR_P (eval_info))
++ {
++ /* We have to add `-1' to the stack, and multiply
++ the two values. */
++ ax_const_l (eval_info->aexpr, -1);
++ ax_simple (eval_info->aexpr, aop_mul);
++ }
++ else
++ res = value_neg (tmp_res);
++ }
++ else
++ {
++ if (STAP_COMPILING_AGENT_EXPR_P (eval_info))
++ ax_simple (eval_info->aexpr, aop_bit_not);
++ else
++ res = value_complement (tmp_res);
++ }
++ }
++ else if (isdigit (*eval_info->exp_buf))
++ {
++ int number;
++
++ /* This is a number, so it MUST be a register displacement.
++ The only operator allowed here is `-', it MUST be
++ followed by a number, and the number MUST be followed by
++ `(%'. */
++ if (c != '-')
++ error (_("Invalid operator `%c' for register displacement "
++ "on expression `%s'."), c, eval_info->saved_expr);
++
++ number = strtol (eval_info->exp_buf,
++ &eval_info->exp_buf, 0) * -1;
++
++ if (!*eval_info->exp_buf
++ || *eval_info->exp_buf != '('
++ || (*eval_info->exp_buf == '('
++ && eval_info->exp_buf[1] != '%'))
++ error (_("Invalid method of indirecting a register on "
++ "expression `%s'."), eval_info->saved_expr);
++
++ res
++ = value_from_longest (builtin_type (gdbarch)->builtin_int,
++ number);
++
++ res = stap_fetch_reg_value (eval_info, res);
++ }
++ else if (*eval_info->exp_buf == '$')
++ {
++ int number;
++
++ /* Last case. We are dealing with an integer constant, so
++ we must read it and then apply the necessary operation,
++ either `-' or `~'. */
++ ++eval_info->exp_buf;
++ number = strtol (eval_info->exp_buf,
++ &eval_info->exp_buf, 0);
++
++ if (!STAP_COMPILING_AGENT_EXPR_P (eval_info))
++ res
++ = value_from_longest (builtin_type (gdbarch)->builtin_int,
++ number);
++ else
++ ax_const_l (eval_info->aexpr, number);
+
-+ /* These are kept just for mbpy_str. */
-+ CORE_ADDR addr;
-+ CORE_ADDR length;
-+} membuf_object;
++ eval_info->exp_buf = skip_spaces (eval_info->exp_buf);
+
-+static PyTypeObject membuf_object_type;
++ if (c == '-')
++ {
++ if (STAP_COMPILING_AGENT_EXPR_P (eval_info))
++ ax_simple (eval_info->aexpr, aop_log_not);
++ else
++ res = value_neg (res);
++ }
++ else
++ {
++ if (STAP_COMPILING_AGENT_EXPR_P (eval_info))
++ ax_simple (eval_info->aexpr, aop_bit_not);
++ else
++ res = value_complement (res);
++ }
++ }
++ else
++ error (_("Invalid operand to unary operator `%c' on "
++ "expression `%s'."), c, eval_info->saved_expr);
++ }
++ break;
+
-+/* 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. */
++ case '0': case '1': case '2': case '3': case '4':
++ case '5': case '6': case '7': case '8': case '9':
++ {
++ int number = strtol (eval_info->exp_buf, &eval_info->exp_buf, 0);
+
-+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;
++ /* This is a register displacement with a positive value. We read
++ the number, and then check for the mandatory `(%' part. */
++ if (!*eval_info->exp_buf
++ || !(*eval_info->exp_buf == '('
++ && eval_info->exp_buf[1] == '%'))
++ error (_("Invalid register access on expression `%s'."),
++ eval_info->saved_expr);
+
-+ if (! PyArg_ParseTuple (args, "OO", &addr_obj, &length_obj))
-+ return NULL;
++ res = value_from_longest (builtin_type (gdbarch)->builtin_int,
++ number);
+
-+ TRY_CATCH (except, RETURN_MASK_ALL)
-+ {
-+ if (!get_addr_from_python (addr_obj, &addr)
-+ || !get_addr_from_python (length_obj, &length))
-+ {
-+ error = 1;
-+ break;
-+ }
++ res = stap_fetch_reg_value (eval_info, res);
++ }
++ break;
+
-+ buffer = xmalloc (length);
-+ cleanups = make_cleanup (xfree, buffer);
++ case '$':
++ {
++ int number;
+
-+ read_memory (addr, buffer, length);
-+ }
-+ GDB_PY_HANDLE_EXCEPTION (except);
++ /* This is an integer constant. We just have to read the number
++ and return it. */
++ ++eval_info->exp_buf;
++ eval_info->exp_buf = skip_spaces (eval_info->exp_buf);
+
-+ if (error)
-+ return NULL;
++ number = strtol (eval_info->exp_buf, &eval_info->exp_buf, 0);
+
-+ discard_cleanups (cleanups);
++ if (STAP_COMPILING_AGENT_EXPR_P (eval_info))
++ ax_const_l (eval_info->aexpr, number);
++ else
++ res = value_from_longest (builtin_type (gdbarch)->builtin_int,
++ number);
+
-+ 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;
-+ }
++ eval_info->exp_buf = skip_spaces (eval_info->exp_buf);
++ }
++ break;
+
-+ membuf_obj->buffer = buffer;
-+ membuf_obj->addr = addr;
-+ membuf_obj->length = length;
++ case '(': case '%':
++ {
++ /* Register access, with or without indirection. */
++ res = stap_fetch_reg_value (eval_info, /*displacement=*/NULL);
++ eval_info->exp_buf = skip_spaces (eval_info->exp_buf);
++ }
++ break;
++
++ default:
++ {
++ error (_("Operator `%c' not recognized on expression `%s'."),
++ *eval_info->exp_buf, eval_info->saved_expr);
++ }
++ }
+
-+ return PyBuffer_FromReadWriteObject ((PyObject *) membuf_obj, 0,
-+ Py_END_OF_BUFFER);
++ return res;
+}
+
-+/* 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. */
++/* This function is responsible for checking the necessary type of evaluation
++ depending on what is the next "thing" in the buffer. Valid values are:
+
-+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;
++ - Unary operators;
++ - Integer constants;
++ - Register displacement, indirection, and direct access;
++ - Parenthesized operand. */
+
-+ if (! PyArg_ParseTuple (args, "Os#|O", &addr_obj, &buffer, &buf_len,
-+ &length_obj))
-+ return NULL;
++static struct value *
++stap_evaluate_conditionally (struct stap_evaluation_info *eval_info)
++{
++ char *s = eval_info->exp_buf;
++ struct value *ret = NULL;
+
-+ TRY_CATCH (except, RETURN_MASK_ALL)
++ if (*s == '-' || *s == '~' /* Unary operators. */
++ || *s == '$' /* Number (integer constant). */
++ || (isdigit (*s) && s[1] == '(' && s[2] == '%') /* Displacement. */
++ || (*s == '(' && s[1] == '%') /* Register indirection. */
++ || (*s == '%' && isalpha (s[1]))) /* Register value. */
++ /* This is a single operand, so just evaluate it and return. */
++ ret = stap_evaluate_single_operand (eval_info);
++ else if (*s == '(')
+ {
-+ 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;
-+ }
++ /* We are dealing with a parenthesized operand. It means we
++ have to evaluate it as it was a separate expression, without
++ left-side or precedence. */
++ ++eval_info->exp_buf;
++ eval_info->exp_buf = skip_spaces (eval_info->exp_buf);
+
-+ write_memory (addr, buffer, length);
-+ }
-+ GDB_PY_HANDLE_EXCEPTION (except);
++ ret = stap_evaluate_probe_argument_2 (eval_info,
++ /*lhs=*/NULL, /*prec=*/0);
+
-+ if (error)
-+ return NULL;
++ if (*eval_info->exp_buf != ')')
++ error (_("Missign close-paren on expression `%s'."),
++ eval_info->saved_expr);
+
-+ Py_RETURN_NONE;
++ ++eval_info->exp_buf;
++ eval_info->exp_buf = skip_spaces (eval_info->exp_buf);
++ }
++ else
++ error (_("Cannot evaluate expression `%s'."),
++ eval_info->saved_expr);
++
++ return ret;
+}
+
-+/* Destructor of Membuf objects. */
++/* Evaluation function for probe's argument expressions. LHS represents
++ the left side of the expression, and PREC is the precedence of the
++ last operator identified before calling the function. */
+
-+static void
-+mbpy_dealloc (PyObject *self)
-+{
-+ xfree (((membuf_object *) self)->buffer);
-+ self->ob_type->tp_free (self);
-+}
++static struct value *
++stap_evaluate_probe_argument_2 (struct stap_evaluation_info *eval_info,
++ struct value *lhs, int prec)
++{
++ struct value *rhs = NULL;
++ int compiling_p = STAP_COMPILING_AGENT_EXPR_P (eval_info);
++
++ /* This is an operator-precedence parser and evaluator.
++
++ We work with left- and right-sides of expressions, and
++ evaluate them depending on the precedence of the operators
++ we find. */
++
++ eval_info->exp_buf = skip_spaces (eval_info->exp_buf);
++
++ if (!lhs)
++ /* We were called without a left-side, either because this is the
++ first call, or because we were called to evaluate a parenthesized
++ expression. It doesn't really matter; we have to evaluate the
++ left-side in order to continue the process. */
++ lhs = stap_evaluate_conditionally (eval_info);
++
++ /* Start to evaluate the right-side, and to "join" left and right sides
++ depending on the operation specified.
++
++ This loop shall continue until we run out of characters in the input,
++ or until we find a close-parenthesis, which means that we've reached
++ the end of a sub-expression. */
++ while (eval_info->exp_buf
++ && *eval_info->exp_buf
++ && *eval_info->exp_buf != ')')
++ {
++ char *tmp_exp_buf;
++ enum exp_opcode opcode;
++ int cur_prec;
++
++ if (!stap_is_operator (eval_info->exp_buf))
++ error (_("Invalid operator `%c' on expression `%s'."),
++ *eval_info->exp_buf, eval_info->saved_expr);
++
++ /* We have to save the current value of the expression buffer because
++ the `stap_get_opcode' modifies it in order to get the current
++ operator. If this operator's precedence is lower than PREC, we
++ should return and not advance the expression buffer pointer. */
++ tmp_exp_buf = eval_info->exp_buf;
++ stap_get_opcode (&tmp_exp_buf, &opcode);
++
++ cur_prec = stap_get_operator_prec (opcode);
++ if (cur_prec < prec)
++ /* If the precedence of the operator that we are seeing now is
++ lower than the precedence of the first operator seen before
++ this evaluation process began, it means we should stop evaluating
++ and return. */
++ break;
+
-+/* Return a description of the Membuf object. */
++ eval_info->exp_buf = tmp_exp_buf;
++ eval_info->exp_buf = skip_spaces (eval_info->exp_buf);
+
-+static PyObject *
-+mbpy_str (PyObject *self)
-+{
-+ membuf_object *membuf_obj = (membuf_object *) self;
++ /* Evaluate the right-side of the expression. */
++ rhs = stap_evaluate_conditionally (eval_info);
+
-+ return PyString_FromFormat ("memory buffer for address %s, %s bytes long",
-+ paddress (membuf_obj->addr),
-+ pulongest (membuf_obj->length));
-+}
++ /* While we still have operators, try to evaluate another
++ right-side, but using the current right-side as a left-side. */
++ while (*eval_info->exp_buf
++ && stap_is_operator (eval_info->exp_buf))
++ {
++ enum exp_opcode lookahead_opcode;
++ int lookahead_prec;
++
++ /* Saving the current expression buffer position. The explanation
++ is the same as above. */
++ tmp_exp_buf = eval_info->exp_buf;
++ stap_get_opcode (&tmp_exp_buf, &lookahead_opcode);
++ lookahead_prec = stap_get_operator_prec (lookahead_opcode);
++
++ if (lookahead_prec <= prec)
++ /* If we are dealing with an operator whose precedence is lower
++ than the first one, just abandon the attempt. */
++ break;
+
-+static Py_ssize_t
-+get_read_buffer (PyObject *self, Py_ssize_t segment, void **ptrptr)
-+{
-+ membuf_object *membuf_obj = (membuf_object *) self;
++ rhs = stap_evaluate_probe_argument_2 (eval_info,
++ rhs, lookahead_prec);
++ }
+
-+ if (segment)
-+ {
-+ PyErr_SetString (PyExc_SystemError,
-+ "The memory buffer supports only one segment.");
-+ return -1;
++ /* Now, "join" both left and right sides into one left-side, using
++ the specified operator. */
++ if (compiling_p)
++ stap_opcode_to_ax (eval_info, opcode);
++ else
++ lhs = value_binop (lhs, rhs, opcode);
+ }
+
-+ *ptrptr = membuf_obj->buffer;
-+
-+ return membuf_obj->length;
++ return lhs;
+}
+
-+static Py_ssize_t
-+get_write_buffer (PyObject *self, Py_ssize_t segment, void **ptrptr)
-+{
-+ return get_read_buffer (self, segment, ptrptr);
-+}
++/* This function fills the necessary arguments for the evaluation function
++ to work. */
+
-+static Py_ssize_t
-+get_seg_count (PyObject *self, Py_ssize_t *lenp)
++static struct value *
++stap_evaluate_probe_argument_1 (struct objfile *objfile,
++ const struct stap_probe *probe,
++ struct frame_info *frame,
++ int n)
+{
-+ if (lenp)
-+ *lenp = ((membuf_object *) self)->length;
++ struct stap_evaluation_info eval_info;
++ char *s = (char *) probe->parsed_args->arg[n].arg_str;
++ struct value *res, *vs[4];
+
-+ return 1;
-+}
++ /* Filling necessary information for evaluation function. */
++ eval_info.saved_expr = s;
++ eval_info.exp_buf = s;
++ eval_info.gdbarch = get_objfile_arch (objfile);
++ eval_info.frame = frame;
++ eval_info.bitness = probe->parsed_args->arg[n].bitness;
++ /* We are not compiling to an agent expression. */
++ eval_info.aexpr = NULL;
++ eval_info.avalue = NULL;
+
-+static Py_ssize_t
-+get_char_buffer (PyObject *self, Py_ssize_t segment, char **ptrptr)
-+{
-+ void *ptr = NULL;
-+ Py_ssize_t ret;
++ res = stap_evaluate_probe_argument_2 (&eval_info,
++ /*lhs=*/NULL, /*prec=*/0);
+
-+ ret = get_read_buffer (self, segment, &ptr);
-+ *ptrptr = (char *) ptr;
++ if (!res)
++ error (_("Could not evaluate expression `%s'."),
++ eval_info.saved_expr);
+
-+ return ret;
++ return res;
+}
+
-+/* 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 */
-+};
++/* See definition in stap-probe.h. */
+
-+void
-+gdbpy_initialize_membuf (void)
++struct value *
++stap_evaluate_probe_argument (struct objfile *objfile,
++ const struct stap_probe *probe,
++ struct frame_info *frame,
++ int n)
+{
-+ if (PyType_Ready (&membuf_object_type) < 0)
-+ return;
++ if (!probe->parsed_args)
++ stap_parse_probe_arguments ((struct stap_probe *) probe);
++
++ if (!probe->parsed_args->arg
++ || n >= probe->parsed_args->n_args)
++ return NULL;
+
-+ Py_INCREF (&membuf_object_type);
-+ PyModule_AddObject (gdb_module, "Membuf", (PyObject *) &membuf_object_type);
++ return stap_evaluate_probe_argument_1 (objfile, probe, frame, n);
+}
-diff --git a/gdb/python/py-prettyprint.c b/gdb/python/py-prettyprint.c
-index 434c8a5..b22c557 100644
---- a/gdb/python/py-prettyprint.c
-+++ b/gdb/python/py-prettyprint.c
-@@ -204,10 +204,10 @@ pretty_print_one_value (PyObject *printer, struct value **out_value)
- && result != Py_None)
- {
- *out_value = convert_value_from_python (result);
-- if (PyErr_Occurred ())
-- *out_value = NULL;
-- Py_DECREF (result);
-- result = NULL;
-+ if (PyErr_Occurred ())
-+ *out_value = NULL;
-+ Py_DECREF (result);
-+ result = NULL;
- }
- }
- }
-@@ -700,14 +700,7 @@ gdbpy_get_varobj_pretty_printer (struct value *value)
- {
- PyObject *val_obj;
- PyObject *pretty_printer = NULL;
-- volatile struct gdb_exception except;
-
-- TRY_CATCH (except, RETURN_MASK_ALL)
-- {
-- value = value_copy (value);
-- }
-- GDB_PY_HANDLE_EXCEPTION (except);
--
- val_obj = value_to_value_object (value);
- if (! val_obj)
- return NULL;
-diff --git a/gdb/python/py-type.c b/gdb/python/py-type.c
-index b901255..4ff18e5 100644
---- a/gdb/python/py-type.c
-+++ b/gdb/python/py-type.c
-@@ -27,6 +27,8 @@
- #include "demangle.h"
- #include "objfiles.h"
- #include "language.h"
-+#include "observer.h"
-+#include "gdb_assert.h"
-
- typedef struct pyty_type_object
- {
-@@ -35,11 +37,17 @@ typedef struct pyty_type_object
-
- /* If a Type object is associated with an objfile, it is kept on a
- doubly-linked list, rooted in the objfile. This lets us copy the
-- underlying struct type when the objfile is deleted. */
-+ underlying struct type when the objfile is deleted.
+
-+ With NULL objfile Type still can be doubly-linked in the list
-+ PYTY_OBJECTS_DISCARDABLE. */
- struct pyty_type_object *prev;
- struct pyty_type_object *next;
- } type_object;
-
-+/* First element of a doubly-linked list of TYPE_DISCARDABLE Types. */
-+static type_object *pyty_objects_discardable;
++/* Helper function which compiles the probe's argument N into an
++ agent expression, suitable for using with tracepoints. */
+
- static PyTypeObject type_object_type;
-
- /* A Field object. */
-@@ -618,8 +626,59 @@ typy_str (PyObject *self)
-
- \f
-
-+/* Key associated with each objfile pointing to the first element of
-+ a doubly-linked list of Types associated with this objfile. */
- static const struct objfile_data *typy_objfile_data_key;
-
-+/* Link TYPE_OBJ to its appropriate list. Either to its objfile associated one
-+ or at least to the global list for TYPE_DISCARDABLE Types. Permanent types
-+ do not get linked anywhere. */
+static void
-+typy_link (type_object *type_obj)
-+{
-+ type_obj->prev = NULL;
++stap_compile_to_ax_1 (struct objfile *objfile,
++ const struct stap_probe *probe,
++ struct agent_expr *expr,
++ struct axs_value *value,
++ int n)
++{
++ struct stap_evaluation_info eval_info;
++ struct gdbarch *gdbarch = expr->gdbarch;
++ char *s = (char *) probe->parsed_args->arg[n].arg_str;
++
++ /* Filling necessary information for evaluation function. */
++ eval_info.saved_expr = s;
++ eval_info.exp_buf = s;
++ eval_info.gdbarch = expr->gdbarch;
++ eval_info.frame = NULL;
++ eval_info.bitness = probe->parsed_args->arg[n].bitness;
++ /* We are compiling to an agent expression. */
++ eval_info.aexpr = expr;
++ eval_info.avalue = value;
++
++ /* We can always use this kind. */
++ value->kind = axs_rvalue;
++
++ /* Figuring out the correct type for this axs_value. */
++ switch (eval_info.bitness)
++ {
++ case STAP_ARG_BITNESS_UNDEFINED:
++ if (gdbarch_addr_bit (gdbarch) == 32)
++ value->type = builtin_type (gdbarch)->builtin_uint32;
++ else
++ value->type = builtin_type (gdbarch)->builtin_uint64;
++ break;
+
-+ if (type_obj->type && TYPE_OBJFILE (type_obj->type))
-+ {
-+ struct objfile *objfile = TYPE_OBJFILE (type_obj->type);
++ case STAP_ARG_BITNESS_32BIT_SIGNED:
++ value->type = builtin_type (gdbarch)->builtin_int32;
++ break;
+
-+ type_obj->next = objfile_data (objfile, typy_objfile_data_key);
-+ if (type_obj->next)
-+ type_obj->next->prev = type_obj;
-+ set_objfile_data (objfile, typy_objfile_data_key, type_obj);
-+ }
-+ else if (type_obj->type && TYPE_DISCARDABLE (type_obj->type))
-+ {
-+ type_obj->next = pyty_objects_discardable;
-+ if (type_obj->next)
-+ type_obj->next->prev = type_obj;
-+ pyty_objects_discardable = type_obj;
-+ }
-+ else
-+ type_obj->next = NULL;
-+}
++ case STAP_ARG_BITNESS_32BIT_UNSIGNED:
++ value->type = builtin_type (gdbarch)->builtin_uint32;
++ break;
+
-+/* Unlink TYPE_OBJ from its current list. Permanent types are not linked
-+ anywhere and this function has no effect on them. */
-+static void
-+typy_unlink (type_object *type_obj)
-+{
-+ if (type_obj->prev)
-+ type_obj->prev->next = type_obj->next;
-+ else if (type_obj->type && TYPE_OBJFILE (type_obj->type))
-+ {
-+ /* Must reset head of list. */
-+ struct objfile *objfile = TYPE_OBJFILE (type_obj->type);
++ case STAP_ARG_BITNESS_64BIT_SIGNED:
++ value->type = builtin_type (gdbarch)->builtin_int64;
++ break;
+
-+ set_objfile_data (objfile, typy_objfile_data_key, type_obj->next);
++ case STAP_ARG_BITNESS_64BIT_UNSIGNED:
++ value->type = builtin_type (gdbarch)->builtin_uint64;
++ break;
++
++ default:
++ internal_error (__FILE__, __LINE__,
++ _("Undefined bitness for probe."));
++ break;
+ }
-+ else if (pyty_objects_discardable == type_obj)
-+ pyty_objects_discardable = type_obj->next;
+
-+ if (type_obj->next)
-+ type_obj->next->prev = type_obj->prev;
++ stap_evaluate_probe_argument_2 (&eval_info,
++ /*lhs=*/NULL, /*prec=*/0);
+}
+
- static void
- save_objfile_types (struct objfile *objfile, void *datum)
- {
-@@ -637,12 +696,13 @@ save_objfile_types (struct objfile *objfile, void *datum)
- {
- type_object *next = obj->next;
-
-- htab_empty (copied_types);
-+ gdb_assert (TYPE_OBJFILE (obj->type) == objfile);
-+ typy_unlink (obj);
-
-- obj->type = copy_type_recursive (objfile, obj->type, copied_types);
-+ obj->type = copy_type_recursive (obj->type, copied_types);
-
-- obj->next = NULL;
-- obj->prev = NULL;
-+ gdb_assert (TYPE_OBJFILE (obj->type) == NULL);
-+ typy_link (obj);
-
- obj = next;
- }
-@@ -653,42 +713,25 @@ save_objfile_types (struct objfile *objfile, void *datum)
- }
-
- static void
--set_type (type_object *obj, struct type *type)
-+typy_dealloc (PyObject *obj)
- {
-- obj->type = type;
-- obj->prev = NULL;
-- if (type && TYPE_OBJFILE (type))
-- {
-- struct objfile *objfile = TYPE_OBJFILE (type);
-+ type_object *type_obj = (type_object *) obj;
-
-- obj->next = objfile_data (objfile, typy_objfile_data_key);
-- if (obj->next)
-- obj->next->prev = obj;
-- set_objfile_data (objfile, typy_objfile_data_key, obj);
-- }
-- else
-- obj->next = NULL;
-+ typy_unlink (type_obj);
-+
-+ type_obj->ob_type->tp_free (obj);
- }
-
-+/* Call type_mark_used for any TYPEs referenced from this GDB source file. */
- static void
--typy_dealloc (PyObject *obj)
-+typy_types_mark_used (void)
- {
-- type_object *type = (type_object *) obj;
--
-- if (type->prev)
-- type->prev->next = type->next;
-- else if (type->type && TYPE_OBJFILE (type->type))
-- {
-- /* Must reset head of list. */
-- struct objfile *objfile = TYPE_OBJFILE (type->type);
--
-- if (objfile)
-- set_objfile_data (objfile, typy_objfile_data_key, type->next);
-- }
-- if (type->next)
-- type->next->prev = type->prev;
-+ type_object *type_obj;
-
-- type->ob_type->tp_free (type);
-+ for (type_obj = pyty_objects_discardable;
-+ type_obj != NULL;
-+ type_obj = type_obj->next)
-+ type_mark_used (type_obj->type);
- }
-
- /* Create a new Type referring to TYPE. */
-@@ -699,7 +742,10 @@ type_to_type_object (struct type *type)
-
- type_obj = PyObject_New (type_object, &type_object_type);
- if (type_obj)
-- set_type (type_obj, type);
-+ {
-+ type_obj->type = type;
-+ typy_link (type_obj);
-+ }
-
- return (PyObject *) type_obj;
- }
-@@ -773,6 +819,8 @@ gdbpy_initialize_types (void)
-
- Py_INCREF (&field_object_type);
- PyModule_AddObject (gdb_module, "Field", (PyObject *) &field_object_type);
++/* See definition in stap-probe.h. */
+
-+ observer_attach_mark_used (typy_types_mark_used);
- }
-
- \f
-diff --git a/gdb/python/py-value.c b/gdb/python/py-value.c
-index 2024021..e8be12d 100644
---- a/gdb/python/py-value.c
-+++ b/gdb/python/py-value.c
-@@ -25,6 +25,7 @@
- #include "language.h"
- #include "dfp.h"
- #include "valprint.h"
-+#include "observer.h"
-
- #ifdef HAVE_PYTHON
-
-@@ -1067,6 +1068,17 @@ gdbpy_is_value_object (PyObject *obj)
- return PyObject_TypeCheck (obj, &value_object_type);
- }
-
-+/* Call type_mark_used for any TYPEs referenced from this GDB source file. */
++void
++stap_compile_to_ax (struct objfile *objfile,
++ const struct stap_probe *probe,
++ struct agent_expr *expr,
++ struct axs_value *value,
++ int n)
++{
++ if (!probe->parsed_args)
++ stap_parse_probe_arguments ((struct stap_probe *) probe);
+
-+static void
-+python_types_mark_used (void)
++ if (!probe->parsed_args->arg
++ || n >= probe->parsed_args->n_args)
++ return;
++
++ stap_compile_to_ax_1 (objfile, probe, expr, value, n);
++}
++
++struct value *
++stap_safe_evaluate_at_pc (struct frame_info *frame, int n)
+{
-+ value_object *iter;
++ const struct stap_probe *probe;
++ struct objfile *objfile;
++ int n_probes;
+
-+ for (iter = values_in_python; iter; iter = iter->next)
-+ type_mark_used (value_type (iter->value));
++ probe = find_probe_by_pc (get_frame_pc (frame), &objfile);
++ if (!probe)
++ return NULL;
++ gdb_assert (objfile->sf && objfile->sf->sym_probe_fns);
++
++ n_probes
++ = objfile->sf->sym_probe_fns->sym_get_probe_argument_count (objfile,
++ probe);
++ if (n >= n_probes)
++ return NULL;
++
++ return objfile->sf->sym_probe_fns->sym_evaluate_probe_argument (objfile,
++ probe,
++ frame,
++ n);
+}
+
- void
- gdbpy_initialize_values (void)
- {
-@@ -1077,6 +1089,8 @@ gdbpy_initialize_values (void)
- PyModule_AddObject (gdb_module, "Value", (PyObject *) &value_object_type);
-
- values_in_python = NULL;
++/* This function frees the space allocated to hold information about
++ the probe's parsed arguments. */
+
-+ observer_attach_mark_used (python_types_mark_used);
- }
-
- \f
-diff --git a/gdb/python/python-internal.h b/gdb/python/python-internal.h
-index 2b8d301..0af99c8 100644
---- a/gdb/python/python-internal.h
-+++ b/gdb/python/python-internal.h
-@@ -82,10 +82,11 @@ struct language_defn;
- struct program_space;
-
- extern PyObject *gdb_module;
--extern PyTypeObject value_object_type;
- extern PyTypeObject block_object_type;
-+extern PyTypeObject value_object_type;
- extern PyTypeObject symbol_object_type;
-
-+/* Used in python-inferior.c. */
- typedef struct
- {
- PyObject_HEAD
-@@ -126,6 +127,10 @@ PyObject *block_to_block_object (struct block *block, struct objfile *objfile);
- PyObject *value_to_value_object (struct value *v);
- PyObject *type_to_type_object (struct type *);
- PyObject *frame_info_to_frame_object (struct frame_info *frame);
-+PyObject *frame_info_to_frame_object (struct frame_info *frame);
-+thread_object *create_thread_object (struct thread_info *tp);
-+thread_object *find_thread_object (ptid_t ptid);
-+PyObject *find_inferior_object (int pid);
-
- PyObject *pspace_to_pspace_object (struct program_space *);
- PyObject *pspy_get_printers (PyObject *, void *);
-@@ -145,8 +150,11 @@ struct type *type_object_to_type (PyObject *obj);
- struct symtab *symtab_object_to_symtab (PyObject *obj);
- struct symtab_and_line *sal_object_to_symtab_and_line (PyObject *obj);
-
-+PyObject *gdbpy_get_hook_function (const char *);
- void gdbpy_initialize_auto_load (void);
-+
- void gdbpy_initialize_values (void);
-+void gdbpy_initialize_breakpoints (void);
- void gdbpy_initialize_frames (void);
- void gdbpy_initialize_symtabs (void);
- void gdbpy_initialize_commands (void);
-@@ -154,6 +162,7 @@ void gdbpy_initialize_symbols (void);
- void gdbpy_initialize_symtabs (void);
- void gdbpy_initialize_blocks (void);
- void gdbpy_initialize_types (void);
-+void gdbpy_initialize_blocks (void);
- void gdbpy_initialize_functions (void);
- void gdbpy_initialize_pspace (void);
- void gdbpy_initialize_objfile (void);
-@@ -171,6 +180,12 @@ struct cleanup *ensure_python_env (struct gdbarch *gdbarch,
- extern struct gdbarch *python_gdbarch;
- extern const struct language_defn *python_language;
-
-+char *gdbpy_parse_command_name (char *text,
-+ struct cmd_list_element ***base_list,
-+ struct cmd_list_element **start_list);
-+
-+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) \
-@@ -221,13 +236,14 @@ int gdbpy_is_value_object (PyObject *obj);
- PyObject *apply_varobj_pretty_printer (PyObject *print_obj,
- struct value **replacement);
- PyObject *gdbpy_get_varobj_pretty_printer (struct value *value);
-+PyObject *gdbpy_instantiate_printer (PyObject *cons, PyObject *value);
- char *gdbpy_get_display_hint (PyObject *printer);
- PyObject *gdbpy_default_visualizer (PyObject *self, PyObject *args);
-
--extern PyObject *gdbpy_doc_cst;
- extern PyObject *gdbpy_children_cst;
- extern PyObject *gdbpy_to_string_cst;
- extern PyObject *gdbpy_display_hint_cst;
-+extern PyObject *gdbpy_doc_cst;
- extern PyObject *gdbpy_enabled_cst;
-
- extern PyObject *gdbpy_gdberror_exc;
-diff --git a/gdb/python/python.c b/gdb/python/python.c
-index 7346fba..34708c4 100644
---- a/gdb/python/python.c
-+++ b/gdb/python/python.c
-@@ -28,6 +28,7 @@
- #include "value.h"
- #include "language.h"
- #include "exceptions.h"
-+#include "event-loop.h"
-
- #include <ctype.h>
-
-@@ -42,10 +43,17 @@ static int gdbpy_should_print_stack = 1;
- #include "cli/cli-decode.h"
- #include "charset.h"
- #include "top.h"
-+#include "solib.h"
- #include "python-internal.h"
-+#include "linespec.h"
-+#include "symtab.h"
-+#include "source.h"
- #include "version.h"
-+#include "inferior.h"
-+#include "gdbthread.h"
- #include "target.h"
- #include "gdbthread.h"
-+#include "event-top.h"
-
- static PyMethodDef GdbMethods[];
-
-@@ -374,6 +382,105 @@ execute_gdb_command (PyObject *self, PyObject *args, PyObject *kw)
- Py_RETURN_NONE;
- }
-
-+/* Implementation of gdb.solib_address (Long) -> String.
-+ Returns the name of the shared library holding a given address, or None. */
++void
++stap_free_parsed_args (struct stap_args_info *parsed_args)
++{
++ int i;
+
-+static PyObject *
-+gdbpy_solib_address (PyObject *self, PyObject *args)
++ if (!parsed_args
++ || parsed_args == &dummy_stap_args_info
++ || parsed_args->n_args == 0)
++ return;
++
++ for (i = 0; i < parsed_args->n_args; i++)
++ xfree (parsed_args->arg);
++
++ xfree (parsed_args);
++}
++
++/* A utility structure. A VEC of these is built when handling "info
++ probes". */
++
++struct stap_probe_and_objfile
++{
++ /* The probe. */
++ const struct stap_probe *probe;
++ /* The probe's objfile. */
++ struct objfile *objfile;
++};
++
++typedef struct stap_probe_and_objfile stap_entry;
++DEF_VEC_O (stap_entry);
++
++/* A helper function for collect_probes that compiles a regexp and
++ throws an exception on error. This installs a cleanup to free the
++ resulting pattern on success. If RX is NULL, this does nothing. */
++
++static void
++compile_rx_or_error (regex_t *pattern, const char *rx, const char *message)
+{
-+ unsigned long long pc;
-+ char *soname;
-+ PyObject *str_obj;
++ int code;
+
-+ if (!PyArg_ParseTuple (args, "K", &pc))
-+ return NULL;
++ if (!rx)
++ return;
+
-+ soname = solib_name_from_address (current_program_space, pc);
-+ if (soname)
-+ str_obj = PyString_Decode (soname, strlen (soname), host_charset (), NULL);
++ code = regcomp (pattern, rx, REG_NOSUB);
++ if (code == 0)
++ make_regfree_cleanup (pattern);
+ else
+ {
-+ str_obj = Py_None;
-+ Py_INCREF (Py_None);
++ char *err = get_regcomp_error (code, pattern);
++
++ make_cleanup (xfree, err);
++ error (_("%s: %s"), message, err);
+ }
++}
++
++/* Make a vector of probes matching OBJNAME, PROVIDER, and PROBE.
++ Each argument is a regexp, or NULL, which matches anything. */
++
++static VEC (stap_entry) *
++collect_probes (char *objname, char *provider, char *probe)
++{
++ struct objfile *objfile;
++ VEC (stap_entry) *result = NULL;
++ struct cleanup *cleanup;
++ regex_t obj_pat, prov_pat, probe_pat;
++
++ cleanup = make_cleanup (VEC_cleanup (stap_entry), &result);
++
++ compile_rx_or_error (&prov_pat, provider, _("Invalid provider regexp"));
++ compile_rx_or_error (&probe_pat, probe, _("Invalid probe regexp"));
++ compile_rx_or_error (&obj_pat, objname, _("Invalid object file regexp"));
++
++ ALL_OBJFILES (objfile)
++ {
++ const struct stap_probe *probes;
++ int i, num_probes;
++
++ if (! objfile->sf || ! objfile->sf->sym_probe_fns)
++ continue;
++
++ if (objname)
++ {
++ if (regexec (&obj_pat, objfile->name, 0, NULL, 0) != 0)
++ continue;
++ }
+
-+ return str_obj;
++ probes = objfile->sf->sym_probe_fns->sym_get_probes (objfile, &num_probes);
++ for (i = 0; i < num_probes; ++i)
++ {
++ stap_entry entry;
++
++ if (provider)
++ {
++ if (regexec (&prov_pat, probes[i].provider, 0, NULL, 0) != 0)
++ continue;
++ }
++
++ if (probe)
++ {
++ if (regexec (&probe_pat, probes[i].name, 0, NULL, 0) != 0)
++ continue;
++ }
++
++ entry.probe = &probes[i];
++ entry.objfile = objfile;
++ VEC_safe_push (stap_entry, result, &entry);
++ }
++ }
++
++ discard_cleanups (cleanup);
++ return result;
+}
+
-+/* A Python function which is a wrapper for decode_line_1. */
++/* A qsort comparison function for stap_entry objects. */
+
-+static PyObject *
-+gdbpy_decode_line (PyObject *self, PyObject *args)
++static int
++compare_entries (const void *a, const void *b)
+{
-+ struct symtabs_and_lines sals = { NULL, 0 }; /* Initialize to appease gcc. */
-+ struct symtab_and_line sal;
-+ char *arg = NULL;
-+ int free_sals = 0, i;
-+ PyObject *result = NULL;
-+ volatile struct gdb_exception except;
++ const stap_entry *ea = a;
++ const stap_entry *eb = b;
++ int v;
+
-+ if (! PyArg_ParseTuple (args, "|s", &arg))
-+ return NULL;
++ v = strcmp (ea->probe->provider, eb->probe->provider);
++ if (v)
++ return v;
+
-+ TRY_CATCH (except, RETURN_MASK_ALL)
-+ {
-+ if (arg)
-+ {
-+ char *copy;
++ v = strcmp (ea->probe->name, eb->probe->name);
++ if (v)
++ return v;
+
-+ arg = strdup (arg);
-+ copy = arg;
++ if (ea->probe->address < eb->probe->address)
++ return -1;
++ if (ea->probe->address > eb->probe->address)
++ return 1;
+
-+ sals = decode_line_1 (©, 0, 0, 0, 0, 0);
-+ free_sals = 1;
-+ }
-+ else
++ return strcmp (ea->objfile->name, eb->objfile->name);
++}
++
++/* Implementation of the "info probes" command. */
++
++static void
++info_probes_command (char *arg, int from_tty)
++{
++ char *provider, *probe = NULL, *objname = NULL;
++ struct cleanup *cleanup = make_cleanup (null_cleanup, NULL);
++ VEC (stap_entry) *items;
++ int i, addr_width, any_found;
++ stap_entry *entry;
++
++ provider = extract_arg (&arg);
++ if (provider)
++ {
++ make_cleanup (xfree, provider);
++
++ probe = extract_arg (&arg);
++ if (probe)
+ {
-+ set_default_source_symtab_and_line ();
-+ sal = get_current_source_symtab_and_line ();
-+ sals.sals = &sal;
-+ sals.nelts = 1;
++ make_cleanup (xfree, probe);
++
++ objname = extract_arg (&arg);
++ if (objname)
++ make_cleanup (xfree, objname);
+ }
+ }
-+ if (arg)
-+ xfree (arg);
+
-+ if (except.reason < 0)
-+ {
-+ if (free_sals)
-+ xfree (sals.sals);
-+ /* We know this will always throw. */
-+ GDB_PY_HANDLE_EXCEPTION (except);
-+ }
++ items = collect_probes (objname, provider, probe);
++ make_cleanup (VEC_cleanup (stap_entry), &items);
++ make_cleanup_ui_out_table_begin_end (uiout, 5,
++ VEC_length (stap_entry, items),
++ "SystemTapProbes");
+
-+ if (sals.nelts)
++ if (! VEC_empty (stap_entry, items))
++ qsort (VEC_address (stap_entry, items),
++ VEC_length (stap_entry, items),
++ sizeof (stap_entry),
++ compare_entries);
++
++ addr_width = 4 + (gdbarch_ptr_bit (get_current_arch ()) / 4);
++
++ ui_out_table_header (uiout, 10, ui_left, "provider", _("Provider"));
++ ui_out_table_header (uiout, 10, ui_left, "name", _("Name"));
++ ui_out_table_header (uiout, addr_width - 1, ui_left, "addr", _("Where"));
++ ui_out_table_header (uiout, addr_width - 1, ui_left, "semaphore",
++ _("Semaphore"));
++ ui_out_table_header (uiout, 30, ui_left, "object", _("Object"));
++ ui_out_table_body (uiout);
++
++ for (i = 0; VEC_iterate (stap_entry, items, i, entry); ++i)
+ {
-+ result = PyTuple_New (sals.nelts);
-+ for (i = 0; i < sals.nelts; ++i)
-+ {
-+ PyObject *obj;
-+ char *str;
++ struct cleanup *inner;
+
-+ obj = symtab_and_line_to_sal_object (sals.sals[i]);
-+ if (! obj)
-+ {
-+ Py_DECREF (result);
-+ result = NULL;
-+ break;
-+ }
++ inner = make_cleanup_ui_out_tuple_begin_end (uiout, "probe");
+
-+ PyTuple_SetItem (result, i, obj);
-+ }
++ ui_out_field_string (uiout, "provider", entry->probe->provider);
++ ui_out_field_string (uiout, "name", entry->probe->name);
++ ui_out_field_core_addr (uiout, "addr", get_current_arch (),
++ entry->probe->address);
++ if (entry->probe->sem_addr == 0)
++ ui_out_field_skip (uiout, "semaphore");
++ else
++ ui_out_field_core_addr (uiout, "semaphore", get_current_arch (),
++ entry->probe->sem_addr);
++ ui_out_field_string (uiout, "object", entry->objfile->name);
++ ui_out_text (uiout, "\n");
++
++ do_cleanups (inner);
+ }
+
-+ if (free_sals)
-+ xfree (sals.sals);
++ any_found = ! VEC_empty (stap_entry, items);
++ do_cleanups (cleanup);
+
-+ if (result)
-+ return result;
-+ Py_RETURN_NONE;
++ if (! any_found)
++ ui_out_message (uiout, 0, _("No probes matched.\n"));
+}
+
- /* Parse a string and evaluate it as an expression. */
- static PyObject *
- gdbpy_parse_and_eval (PyObject *self, PyObject *args)
-@@ -414,6 +521,114 @@ source_python_script (FILE *stream, const char *file)
-
- \f
-
-+/* Posting and handling events. */
++\f
++
++/* See definition in stap-probe.h. */
+
-+/* A single event. */
-+struct gdbpy_event
++const struct stap_probe *
++find_probe_in_objfile (struct objfile *objfile,
++ const char *provider,
++ const char *name)
+{
-+ /* The Python event. This is just a callable object. */
-+ PyObject *event;
-+ /* The next event. */
-+ struct gdbpy_event *next;
-+};
++ const struct stap_probe *probes;
++ int i, num_probes;
++
++ if (! objfile->sf || ! objfile->sf->sym_probe_fns)
++ return NULL;
++
++ probes = objfile->sf->sym_probe_fns->sym_get_probes (objfile, &num_probes);
++ for (i = 0; i < num_probes; ++i)
++ {
++ if (strcmp (probes[i].provider, provider) != 0)
++ continue;
+
-+/* All pending events. */
-+static struct gdbpy_event *gdbpy_event_list;
-+/* The final link of the event list. */
-+static struct gdbpy_event **gdbpy_event_list_end;
++ if (strcmp (probes[i].name, name) != 0)
++ continue;
+
-+/* We use a file handler, and not an async handler, so that we can
-+ wake up the main thread even when it is blocked in poll(). */
-+static int gdbpy_event_fds[2];
++ return &probes[i];
++ }
+
-+/* The file handler callback. This reads from the internal pipe, and
-+ then processes the Python event queue. This will always be run in
-+ the main gdb thread. */
-+static void
-+gdbpy_run_events (int err, gdb_client_data ignore)
++ return NULL;
++}
++
++/* See definition in stap-probe.h. */
++
++struct symtabs_and_lines
++parse_stap_probe (char **argptr, struct linespec_result *canonical)
+{
++ char *full_arg = extract_arg (argptr);
++ char *arg = xstrdup (full_arg);
++ char *objfile_name = NULL, *provider = NULL, *name, *p;
+ struct cleanup *cleanup;
-+ char buffer[100];
-+ int r;
++ struct symtabs_and_lines result;
++ struct objfile *objfile;
++
++ result.sals = NULL;
++ result.nelts = 0;
++
++ /* The caller ensured that this starts with 'probe:'. */
++ gdb_assert (arg && strncmp (arg, "probe:", 6) == 0);
++ cleanup = make_cleanup (xfree, arg);
++ make_cleanup (xfree, full_arg);
++ arg += 6;
++
++ /* Extract each word from the argument, separated by ":"s. */
++ p = strchr (arg, ':');
++ if (p == NULL)
++ {
++ /* This is `probe:name'. */
++ name = arg;
++ }
++ else
++ {
++ char *hold = p + 1;
++
++ *p = '\0';
++ p = strchr (hold, ':');
++ if (p == NULL)
++ {
++ /* This is `probe:provider:name'. */
++ provider = arg;
++ name = hold;
++ }
++ else
++ {
++ /* This is `probe:objfile:provider:name'. */
++ *p = '\0';
++ objfile_name = arg;
++ provider = hold;
++ name = p + 1;
++ }
++ }
++
++ if (*name == '\0')
++ error (_("no probe name specified"));
++ if (provider && *provider == '\0')
++ error (_("invalid provider name"));
++ if (objfile_name && *objfile_name == '\0')
++ error (_("invalid objfile name"));
++
++ if (canonical)
++ canonical->canonical = NULL;
++
++ ALL_OBJFILES (objfile)
++ {
++ const struct stap_probe *probes;
++ int i, num_probes;
++
++ if (! objfile->sf || ! objfile->sf->sym_probe_fns)
++ continue;
++
++ if (objfile_name
++ && FILENAME_CMP (objfile->name, objfile_name) != 0
++ && FILENAME_CMP (lbasename (objfile->name), objfile_name) != 0)
++ continue;
++
++ probes = objfile->sf->sym_probe_fns->sym_get_probes (objfile, &num_probes);
++ for (i = 0; i < num_probes; ++i)
++ {
++ struct symtab_and_line *sal;
++
++ if (provider && strcmp (probes[i].provider, provider) != 0)
++ continue;
++
++ if (strcmp (probes[i].name, name) != 0)
++ continue;
++
++ ++result.nelts;
++ result.sals = xrealloc (result.sals,
++ result.nelts * sizeof (struct symtab_and_line));
++ sal = &result.sals[result.nelts - 1];
+
-+ cleanup = ensure_python_env (get_current_arch (), current_language);
++ init_sal (sal);
+
-+ /* Just read whatever is available on the fd. It is relatively
-+ harmless if there are any bytes left over. */
-+ r = read (gdbpy_event_fds[0], buffer, sizeof (buffer));
++ sal->pc = probes[i].address;
++ sal->explicit_pc = 1;
++ sal->section = find_pc_overlay (sal->pc);
++ sal->pspace = current_program_space;
++ sal->semaphore = probes[i].sem_addr;
+
-+ while (gdbpy_event_list)
++ if (canonical)
++ {
++ canonical->canonical = xrealloc (canonical->canonical,
++ result.nelts * sizeof (char **));
++ canonical->canonical[result.nelts - 1] = xstrdup (full_arg);
++ }
++ }
++ }
++
++ if (result.nelts == 0)
++ {
++ throw_error (NOT_FOUND_ERROR,
++ _("No probe matching objfile=`%s', provider=`%s', name=`%s'"),
++ objfile_name ? objfile_name : _("<any>"),
++ provider ? provider : _("<any>"),
++ name);
++ }
++
++ if (canonical)
+ {
-+ /* Dispatching the event might push a new element onto the event
-+ loop, so we update here "atomically enough". */
-+ struct gdbpy_event *item = gdbpy_event_list;
-+ gdbpy_event_list = gdbpy_event_list->next;
-+ if (gdbpy_event_list == NULL)
-+ gdbpy_event_list_end = &gdbpy_event_list;
-+
-+ /* Ignore errors. */
-+ PyObject_CallObject (item->event, NULL);
-+
-+ Py_DECREF (item->event);
-+ xfree (item);
++ canonical->special_display = 1;
++ canonical->pre_expanded = 1;
+ }
+
+ do_cleanups (cleanup);
++
++ return result;
+}
+
-+/* Submit an event to the gdb thread. */
-+static PyObject *
-+gdbpy_post_event (PyObject *self, PyObject *args)
++\f
++
++/* See definition in stap-probe.h. */
++
++const struct stap_probe *
++find_probe_by_pc (CORE_ADDR pc, struct objfile **objfile_out)
+{
-+ struct gdbpy_event *event;
-+ PyObject *func;
-+ int wakeup;
++ struct objfile *objfile;
+
-+ if (!PyArg_ParseTuple (args, "O", &func))
-+ return NULL;
++ ALL_OBJFILES (objfile)
++ {
++ const struct stap_probe *probes;
++ int i, num_probes;
++ stap_entry entry;
+
-+ if (!PyCallable_Check (func))
-+ {
-+ PyErr_SetString (PyExc_RuntimeError, "Posted event is not callable");
-+ return NULL;
-+ }
++ if (! objfile->sf || ! objfile->sf->sym_probe_fns)
++ continue;
+
-+ Py_INCREF (func);
++ /* If this proves too inefficient, we can replace with a hash. */
++ probes = objfile->sf->sym_probe_fns->sym_get_probes (objfile, &num_probes);
++ for (i = 0; i < num_probes; ++i)
++ {
++ if (probes[i].address == pc)
++ {
++ *objfile_out = objfile;
++ return &probes[i];
++ }
++ }
++ }
+
-+ /* From here until the end of the function, we have the GIL, so we
-+ can operate on our global data structures without worrying. */
-+ wakeup = gdbpy_event_list == NULL;
++ return NULL;
++}
+
-+ event = XNEW (struct gdbpy_event);
-+ event->event = func;
-+ event->next = NULL;
-+ *gdbpy_event_list_end = event;
-+ gdbpy_event_list_end = &event->next;
++/* This is called to compute the value of one of the $_probe_arg*
++ convenience variables. */
+
-+ /* Wake up gdb when needed. */
-+ if (wakeup)
-+ {
-+ char c = 'q'; /* Anything. */
-+ if (write (gdbpy_event_fds[1], &c, 1) != 1)
-+ return PyErr_SetFromErrno (PyExc_IOError);
-+ }
++static struct value *
++compute_probe_arg (struct gdbarch *arch, struct internalvar *ivar,
++ void *data)
++{
++ struct frame_info *frame = get_selected_frame (_("No frame selected"));
++ CORE_ADDR pc = get_frame_pc (frame);
++ int sel = (int) (uintptr_t) data;
++ struct objfile *objfile;
++ const struct stap_probe *pc_probe;
++ int n_probes;
+
-+ Py_RETURN_NONE;
++ /* SEL==10 means "_probe_argc". */
++ gdb_assert (sel >= 0 && sel <= STAP_MAX_ARGS);
++
++ pc_probe = find_probe_by_pc (pc, &objfile);
++ if (pc_probe == NULL)
++ error (_("No SystemTap probe at PC %s"), core_addr_to_string (pc));
++
++ n_probes
++ = objfile->sf->sym_probe_fns->sym_get_probe_argument_count (objfile,
++ pc_probe);
++ if (sel == 10)
++ return value_from_longest (builtin_type (arch)->builtin_int, n_probes);
++
++ if (sel >= n_probes)
++ error (_("Invalid probe argument %d -- probe has %d arguments available"),
++ sel, n_probes);
++
++ return objfile->sf->sym_probe_fns->sym_evaluate_probe_argument (objfile,
++ pc_probe,
++ frame, sel);
+}
+
-+/* Initialize the Python event handler. */
++/* This is called to compile one of the $_probe_arg* convenience
++ variables into an agent expression. */
++
+static void
-+gdbpy_initialize_events (void)
++compile_probe_arg (struct internalvar *ivar, struct agent_expr *expr,
++ struct axs_value *value, void *data)
+{
-+ if (!pipe (gdbpy_event_fds))
++ CORE_ADDR pc = expr->scope;
++ int sel = (int) (uintptr_t) data;
++ struct objfile *objfile;
++ const struct stap_probe *pc_probe;
++ int n_probes;
++
++ /* SEL==10 means "_probe_argc". */
++ gdb_assert (sel >= 0 && sel <= 10);
++
++ pc_probe = find_probe_by_pc (pc, &objfile);
++ if (pc_probe == NULL)
++ error (_("No SystemTap probe at PC %s"), core_addr_to_string (pc));
++
++ n_probes
++ = objfile->sf->sym_probe_fns->sym_get_probe_argument_count (objfile,
++ pc_probe);
++ if (sel == 10)
+ {
-+ gdbpy_event_list_end = &gdbpy_event_list;
-+ add_file_handler (gdbpy_event_fds[0], gdbpy_run_events, NULL);
++ value->kind = axs_rvalue;
++ value->type = builtin_type (expr->gdbarch)->builtin_int;
++ ax_const_l (expr, n_probes);
++ return;
+ }
++
++ gdb_assert (sel >= 0);
++ if (sel >= n_probes)
++ error (_("Invalid probe argument %d -- probe has %d arguments available"),
++ sel, n_probes);
++
++ objfile->sf->sym_probe_fns->sym_compile_to_ax (objfile, pc_probe,
++ expr, value, sel);
+}
+
+\f
+
- /* Printing. */
-
- /* A python function to write a single string using gdb's filtered
-@@ -459,6 +674,53 @@ gdbpy_print_stack (void)
-
- /* Return the current Progspace.
- There always is one. */
-+/* True if 'gdb -P' was used, false otherwise. */
-+static int running_python_script;
++/* Implementation of `$_probe_arg*' set of variables. */
++
++static const struct internalvar_funcs probe_funcs =
++{
++ compute_probe_arg,
++ compile_probe_arg,
++ NULL
++};
++
++void
++_initialize_stap_probe (void)
++{
++ add_info ("probes", info_probes_command, _("\
++Show available static probes.\n\
++Usage: info probes [PROVIDER [NAME [OBJECT]]]\n\
++Each argument is a regular expression, used to select probes.\n\
++PROVIDER matches probe provider names.\n\
++NAME matches the probe names.\n\
++OBJECT match the executable or shared library name."));
++
++ create_internalvar_type_lazy ("_probe_argc", &probe_funcs,
++ (void *) (uintptr_t) 10);
++ create_internalvar_type_lazy ("_probe_arg0", &probe_funcs,
++ (void *) (uintptr_t) 0);
++ create_internalvar_type_lazy ("_probe_arg1", &probe_funcs,
++ (void *) (uintptr_t) 1);
++ create_internalvar_type_lazy ("_probe_arg2", &probe_funcs,
++ (void *) (uintptr_t) 2);
++ create_internalvar_type_lazy ("_probe_arg3", &probe_funcs,
++ (void *) (uintptr_t) 3);
++ create_internalvar_type_lazy ("_probe_arg4", &probe_funcs,
++ (void *) (uintptr_t) 4);
++ create_internalvar_type_lazy ("_probe_arg5", &probe_funcs,
++ (void *) (uintptr_t) 5);
++ create_internalvar_type_lazy ("_probe_arg6", &probe_funcs,
++ (void *) (uintptr_t) 6);
++ create_internalvar_type_lazy ("_probe_arg7", &probe_funcs,
++ (void *) (uintptr_t) 7);
++ create_internalvar_type_lazy ("_probe_arg8", &probe_funcs,
++ (void *) (uintptr_t) 8);
++ create_internalvar_type_lazy ("_probe_arg9", &probe_funcs,
++ (void *) (uintptr_t) 9);
++}
+Index: gdb-7.2.90.20110703/gdb/stap-probe.h
+===================================================================
+--- /dev/null 1970-01-01 00:00:00.000000000 +0000
++++ gdb-7.2.90.20110703/gdb/stap-probe.h 2011-07-03 10:33:11.000000000 +0200
+@@ -0,0 +1,109 @@
++/* SystemTap probe support for GDB.
++
++ Copyright (C) 2011 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 <http://www.gnu.org/licenses/>. */
++
++#if !defined (STAP_PROBE_H)
++#define STAP_PROBE_H 1
++
++struct stap_args_info;
++struct axs_value;
++struct linespec_result;
++
++/* Main structure which holds information about a SystemTap probe. */
++
++struct stap_probe
++{
++ /* The provider of this probe. */
++ const char *provider;
++
++ /* The name of the probe. */
++ const char *name;
++
++ /* The address where the probe is inserted. */
++ CORE_ADDR address;
++
++ /* The address of the probe's semaphore, or 0 if this probe does not
++ have an associated semaphore. */
++ CORE_ADDR sem_addr;
++
++ /* Probe's arguments. Users should generally not examine this, but
++ should instead extract information about the arguments using the
++ methods provided in sym_probe_fns. */
++ const char *args;
+
-+/* True if we are currently in a call to 'gdb.cli', false otherwise. */
-+static int in_cli;
++ /* Probe's arguments after parsing. This is an opaque structure that
++ will hold information about the arguments pointed by ARGS. */
++ struct stap_args_info *parsed_args;
++};
+
-+/* 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");
++/* A helper for linespec that decodes a stap probe specification. It
++ returns a symtabs_and_lines object and updates *ARGPTR or throws an
++ error. */
+
-+ in_cli = 1;
-+ cli_command_loop ();
-+ in_cli = 0;
++extern struct symtabs_and_lines parse_stap_probe (char **argptr,
++ struct linespec_result *canon);
+
-+ Py_RETURN_NONE;
-+}
++/* Search OBJFILE for a probe with the given PROVIDER and NAME. If a
++ probe is found, return it. If no probe is found, return NULL. */
+
-+/* Set up the Python argument vector and evaluate a script. This is
-+ used to implement 'gdb -P'. */
++extern const struct stap_probe *find_probe_in_objfile (struct objfile *objfile,
++ const char *provider,
++ const char *name);
+
-+void
-+run_python_script (int argc, char **argv)
-+{
-+ FILE *input;
++/* Given a PC, find an associated SystemTap probe. If a probe is
++ found, set *OBJFILE_OUT to the probe's objfile, and return the
++ probe. If no probe is found, return NULL. */
+
-+ /* We never free this, since we plan to exit at the end. */
-+ ensure_python_env (get_current_arch (), current_language);
++extern const struct stap_probe *find_probe_by_pc (CORE_ADDR pc,
++ struct objfile **objfile_out);
+
-+ 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);
-+}
++/* Given PROBE, returns the number of arguments present in that probe's
++ argument string. */
+
-+\f
++extern int stap_get_probe_argument_count (const struct stap_probe *probe);
+
-
- static PyObject *
- gdbpy_get_current_progspace (PyObject *unused1, PyObject *unused2)
-@@ -720,6 +982,7 @@ Enables or disables printing of Python stack traces."),
- gdbpy_initialize_lazy_string ();
- gdbpy_initialize_thread ();
- gdbpy_initialize_inferior ();
-+ gdbpy_initialize_events ();
-
- PyRun_SimpleString ("import gdb");
- PyRun_SimpleString ("gdb.pretty_printers = []");
-@@ -787,6 +1050,8 @@ static PyMethodDef GdbMethods[] =
- "Get a value from history" },
- { "execute", (PyCFunction) execute_gdb_command, METH_VARARGS | METH_KEYWORDS,
- "Execute a gdb command" },
-+ { "cli", gdbpy_cli, METH_NOARGS,
-+ "Enter the gdb CLI" },
- { "parameter", gdbpy_parameter, METH_VARARGS,
- "Return a gdb parameter's value" },
-
-@@ -825,11 +1090,21 @@ a boolean indicating if name is a field of the current implied argument\n\
- `this' (when the current language is object-oriented)." },
- { "block_for_pc", gdbpy_block_for_pc, METH_VARARGS,
- "Return the block containing the given pc value, or None." },
-+ { "solib_address", gdbpy_solib_address, METH_VARARGS,
-+ "solib_address (Long) -> String.\n\
-+Return the name of the shared library holding a given address, or None." },
-+ { "decode_line", gdbpy_decode_line, METH_VARARGS,
-+ "Decode a string argument the way that 'break' or 'edit' does.\n\
-+Return a tuple holding the file name (or None) and line number (or None).\n\
-+Note: may later change to return an object." },
- { "parse_and_eval", gdbpy_parse_and_eval, METH_VARARGS,
- "parse_and_eval (String) -> Value.\n\
- Parse String as an expression, evaluate it, and return the result as a Value."
- },
-
-+ { "post_event", gdbpy_post_event, METH_VARARGS,
-+ "Post an event into gdb's event loop." },
-+
- { "target_charset", gdbpy_target_charset, METH_NOARGS,
- "target_charset () -> string.\n\
- Return the name of the current target charset." },
-diff --git a/gdb/python/python.h b/gdb/python/python.h
-index affd4a4..5407878 100644
---- a/gdb/python/python.h
-+++ b/gdb/python/python.h
-@@ -28,6 +28,8 @@ void eval_python_from_control_command (struct command_line *);
-
- void source_python_script (FILE *stream, const char *file);
-
-+void run_python_script (int argc, char **argv);
++/* Given PARSED_ARGS, frees the space allocated to hold information about
++ the probe's parsed arguments. */
+
- int apply_val_pretty_printer (struct type *type, const gdb_byte *valaddr,
- int embedded_offset, CORE_ADDR address,
- struct ui_file *stream, int recurse,
-diff --git a/gdb/solib-svr4.c b/gdb/solib-svr4.c
-index 1f135d4..489838d 100644
---- a/gdb/solib-svr4.c
-+++ b/gdb/solib-svr4.c
-@@ -1278,7 +1278,8 @@ svr4_in_dynsym_resolve_code (CORE_ADDR pc)
- && pc < info->interp_text_sect_high)
- || (pc >= info->interp_plt_sect_low
- && pc < info->interp_plt_sect_high)
-- || in_plt_section (pc, NULL));
-+ || in_plt_section (pc, NULL)
-+ || in_gnu_ifunc_stub (pc));
- }
-
- /* Given an executable's ABFD and target, compute the entry-point
-diff --git a/gdb/symfile.c b/gdb/symfile.c
-index 42f7ae3..371db0d 100644
---- a/gdb/symfile.c
-+++ b/gdb/symfile.c
-@@ -1059,6 +1059,9 @@ symbol_file_add_with_addrs_or_offsets (bfd *abfd,
- const char *name = bfd_get_filename (abfd);
- const int from_tty = add_flags & SYMFILE_VERBOSE;
-
-+ if (readnow_symbol_files)
-+ flags |= OBJF_READNOW;
++extern void stap_free_parsed_args (struct stap_args_info *parsed_args);
+
- my_cleanups = make_cleanup_bfd_close (abfd);
-
- /* Give user a chance to burp if we'd be
-@@ -1095,7 +1098,7 @@ symbol_file_add_with_addrs_or_offsets (bfd *abfd,
- the gdb startup command line or on a per symbol file basis. Expand
- all partial symbol tables for this objfile if so. */
-
-- if ((flags & OBJF_READNOW) || readnow_symbol_files)
-+ if ((flags & OBJF_READNOW))
- {
- if (from_tty || info_verbose)
- {
-@@ -1533,7 +1536,7 @@ symbol_file_command (char *args, int from_tty)
- void
- set_initial_language (void)
- {
-- char *filename;
-+ const char *filename;
- enum language lang = language_unknown;
-
- filename = find_main_filename ();
-@@ -2660,7 +2663,7 @@ init_filename_language_table (void)
- }
-
- enum language
--deduce_language_from_filename (char *filename)
-+deduce_language_from_filename (const char *filename)
- {
- int i;
- char *cp;
-diff --git a/gdb/symfile.h b/gdb/symfile.h
-index d53c465..5815354 100644
---- a/gdb/symfile.h
-+++ b/gdb/symfile.h
-@@ -171,6 +171,15 @@ struct quick_symbol_functions
- int kind, const char *name,
- domain_enum domain);
-
-+ /* This is called to expand symbol tables before looking up a
-+ symbol. A backend can choose to implement this and then have its
-+ `lookup_symbol' hook always return NULL, or the reverse. (It
-+ doesn't make sense to implement both.) The arguments are as for
-+ `lookup_symbol'. */
-+ void (*pre_expand_symtabs_matching) (struct objfile *objfile,
-+ int kind, const char *name,
-+ domain_enum domain);
-+
- /* Print statistics about any indices loaded for OBJFILE. The
- statistics should be printed to gdb_stdout. This is used for
- "maint print statistics". */
-@@ -201,7 +210,7 @@ struct quick_symbol_functions
-
- /* Return the file name of the file holding the symbol in OBJFILE
- named NAME. If no such symbol exists in OBJFILE, return NULL. */
-- char *(*find_symbol_file) (struct objfile *objfile, const char *name);
-+ const char *(*find_symbol_file) (struct objfile *objfile, const char *name);
-
- /* This method is specific to Ada. It walks the partial symbol
- tables of OBJFILE looking for a name match. WILD_MATCH and
-@@ -566,6 +575,7 @@ extern struct cleanup *increment_reading_symtab (void);
-
- extern int dwarf2_has_info (struct objfile *);
-
-+extern int dwarf2_initialize_objfile (struct objfile *);
- extern void dwarf2_build_psymtabs (struct objfile *);
- extern void dwarf2_build_frame_info (struct objfile *);
-
-diff --git a/gdb/symmisc.c b/gdb/symmisc.c
-index 62e6b97..00dc613 100644
---- a/gdb/symmisc.c
-+++ b/gdb/symmisc.c
-@@ -262,6 +262,9 @@ dump_msymbols (struct objfile *objfile, struct ui_file *outfile)
- case mst_text:
- ms_type = 'T';
- break;
-+ case mst_text_gnu_ifunc:
-+ ms_type = 'i';
-+ break;
- case mst_solib_trampoline:
- ms_type = 'S';
- break;
-diff --git a/gdb/symtab.c b/gdb/symtab.c
-index 2c4c9e4..28f0450 100644
---- a/gdb/symtab.c
-+++ b/gdb/symtab.c
-@@ -1295,16 +1295,25 @@ lookup_symbol_aux_symtabs (int block_index, const char *name,
- const struct block *block;
- struct symtab *s;
-
-- ALL_PRIMARY_SYMTABS (objfile, s)
-+ ALL_OBJFILES (objfile)
- {
-- bv = BLOCKVECTOR (s);
-- block = BLOCKVECTOR_BLOCK (bv, block_index);
-- sym = lookup_block_symbol (block, name, domain);
-- if (sym)
-- {
-- block_found = block;
-- return fixup_symbol_section (sym, objfile);
-- }
-+ if (objfile->sf)
-+ objfile->sf->qf->pre_expand_symtabs_matching (objfile,
-+ block_index,
-+ name, domain);
++/* Evaluates the probe's argument N, returning a value corresponding
++ to it. */
+
-+ ALL_OBJFILE_SYMTABS (objfile, s)
-+ if (s->primary)
-+ {
-+ bv = BLOCKVECTOR (s);
-+ block = BLOCKVECTOR_BLOCK (bv, block_index);
-+ sym = lookup_block_symbol (block, name, domain);
-+ if (sym)
-+ {
-+ block_found = block;
-+ return fixup_symbol_section (sym, objfile);
-+ }
-+ }
- }
-
- return NULL;
-@@ -1547,15 +1556,24 @@ basic_lookup_transparent_type (const char *name)
- of the desired name as a global, then do psymtab-to-symtab
- conversion on the fly and return the found symbol. */
-
-- ALL_PRIMARY_SYMTABS (objfile, s)
-+ ALL_OBJFILES (objfile)
- {
-- bv = BLOCKVECTOR (s);
-- block = BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK);
-- sym = lookup_block_symbol (block, name, STRUCT_DOMAIN);
-- if (sym && !TYPE_IS_OPAQUE (SYMBOL_TYPE (sym)))
-- {
-- return SYMBOL_TYPE (sym);
-- }
-+ if (objfile->sf)
-+ objfile->sf->qf->pre_expand_symtabs_matching (objfile,
-+ GLOBAL_BLOCK,
-+ name, STRUCT_DOMAIN);
++extern struct value *stap_evaluate_probe_argument (struct objfile *objfile,
++ const struct stap_probe *probe,
++ struct frame_info *frame,
++ int n);
+
-+ ALL_OBJFILE_SYMTABS (objfile, s)
-+ if (s->primary)
-+ {
-+ bv = BLOCKVECTOR (s);
-+ block = BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK);
-+ sym = lookup_block_symbol (block, name, STRUCT_DOMAIN);
-+ if (sym && !TYPE_IS_OPAQUE (SYMBOL_TYPE (sym)))
-+ {
-+ return SYMBOL_TYPE (sym);
-+ }
-+ }
- }
-
- ALL_OBJFILES (objfile)
-@@ -1599,14 +1617,16 @@ basic_lookup_transparent_type (const char *name)
- /* FIXME: What about languages without main() or specially linked
- executables that have no main() ? */
-
--char *
-+const char *
- find_main_filename (void)
- {
- struct objfile *objfile;
-- char *result, *name = main_name ();
-+ char *name = main_name ();
-
- ALL_OBJFILES (objfile)
- {
-+ const char *result;
-+
- if (!objfile->sf)
- continue;
- result = objfile->sf->qf->find_symbol_file (objfile, name);
-@@ -2914,7 +2934,7 @@ search_symbols (char *regexp, domain_enum kind, int nfiles, char *files[],
- static enum minimal_symbol_type types3[]
- = {mst_file_data, mst_solib_trampoline, mst_abs, mst_unknown};
- static enum minimal_symbol_type types4[]
-- = {mst_file_bss, mst_text, mst_abs, mst_unknown};
-+ = {mst_file_bss, mst_text_gnu_ifunc, mst_abs, mst_unknown};
- enum minimal_symbol_type ourtype;
- enum minimal_symbol_type ourtype2;
- enum minimal_symbol_type ourtype3;
-diff --git a/gdb/symtab.h b/gdb/symtab.h
-index bedc10a..dc284e4 100644
---- a/gdb/symtab.h
-+++ b/gdb/symtab.h
-@@ -277,6 +277,9 @@ enum minimal_symbol_type
- {
- mst_unknown = 0, /* Unknown type, the default */
- mst_text, /* Generally executable instructions */
-+ mst_text_gnu_ifunc, /* Executable code returning address
-+ of executable code */
-+ mst_slot_got_plt,
- mst_data, /* Generally initialized data */
- mst_bss, /* Generally uninitialized data */
- mst_abs, /* Generally absolute (nonrelocatable) */
-@@ -917,11 +920,25 @@ extern struct symbol *find_pc_sect_function (CORE_ADDR, struct obj_section *);
-
- /* lookup function from address, return name, start addr and end addr */
-
--extern int find_pc_partial_function (CORE_ADDR, char **, CORE_ADDR *,
-- CORE_ADDR *);
-+extern enum find_pc_partial_function_type
-+ {
-+ FIND_PC_PARTIAL_FUNCTION_NOT_FOUND = 0,
-+ FIND_PC_PARTIAL_FUNCTION_NORMAL,
-+ FIND_PC_PARTIAL_FUNCTION_GNU_IFUNC
-+ } find_pc_partial_function (CORE_ADDR, char **, CORE_ADDR *, CORE_ADDR *);
-
- extern void clear_pc_function_cache (void);
-
-+extern int resolve_gnu_ifunc (const char *function_name,
-+ CORE_ADDR *function_addressp);
++/* Compile the probe's argument N to agent expression. */
+
-+extern struct minimal_symbol *resolve_gnu_ifunc_by_cache
-+ (const char *function_name);
++extern void stap_compile_to_ax (struct objfile *objfile,
++ const struct stap_probe *probe,
++ struct agent_expr *expr,
++ struct axs_value *value,
++ int n);
+
-+extern void gnu_ifunc_record_cache (struct gdbarch *gdbarch,
-+ const char *function_name,
-+ CORE_ADDR function_address);
++/* A convenience function that finds a probe at the PC in FRAME and
++ evaluates argument N. If there is no probe at that location, or if
++ the probe does not have enough arguments, this returns NULL. */
+
- /* lookup partial symbol table by address and section */
-
- extern struct symtab *find_pc_sect_symtab_via_partial (CORE_ADDR,
-@@ -996,6 +1013,8 @@ extern struct minimal_symbol *lookup_minimal_symbol_by_pc_name
-
- extern struct minimal_symbol *lookup_minimal_symbol_by_pc (CORE_ADDR);
-
-+extern int in_gnu_ifunc_stub (CORE_ADDR pc);
++extern struct value *stap_safe_evaluate_at_pc (struct frame_info *frame,
++ int n);
+
- extern struct minimal_symbol *
- lookup_minimal_symbol_and_objfile (const char *,
- struct objfile **);
-@@ -1137,7 +1156,7 @@ extern char **make_source_files_completion_list (char *, char *);
++#endif /* !defined (STAP_PROBE_H) */
+Index: gdb-7.2.90.20110703/gdb/symfile.h
+===================================================================
+--- gdb-7.2.90.20110703.orig/gdb/symfile.h 2011-04-25 23:25:18.000000000 +0200
++++ gdb-7.2.90.20110703/gdb/symfile.h 2011-07-03 10:33:11.000000000 +0200
+@@ -31,6 +31,11 @@ struct objfile;
+ struct obj_section;
+ struct obstack;
+ struct block;
++struct stap_probe;
++struct value;
++struct frame_info;
++struct agent_expr;
++struct axs_value;
- int matching_obj_sections (struct obj_section *, struct obj_section *);
+ /* Comparison function for symbol look ups. */
--extern char *find_main_filename (void);
-+extern const char *find_main_filename (void);
-
- extern struct symtab *find_line_symtab (struct symtab *, int, int *, int *);
-
-@@ -1150,7 +1169,7 @@ extern void skip_prologue_sal (struct symtab_and_line *);
-
- extern void clear_symtab_users (void);
-
--extern enum language deduce_language_from_filename (char *);
-+extern enum language deduce_language_from_filename (const char *);
-
- /* symtab.c */
-
-diff --git a/gdb/target.c b/gdb/target.c
-index 4cabcbd..34b3b60 100644
---- a/gdb/target.c
-+++ b/gdb/target.c
-@@ -123,6 +123,8 @@ static int debug_to_insert_watchpoint (CORE_ADDR, int, int,
- static int debug_to_remove_watchpoint (CORE_ADDR, int, int,
- struct expression *);
+@@ -290,6 +295,52 @@ struct quick_symbol_functions
+ void *data);
+ };
-+static int debug_to_detach_watchpoints (void);
++/* Structure of functions used for SystemTap probe support. If one of
++ these functions is provided, all must be. */
++
++struct sym_probe_fns
++{
++ /* If non-NULL, return an array of SystemTap probe objects. The
++ number of objects is returned in *NUM_PROBES. */
++ const struct stap_probe *(*sym_get_probes) (struct objfile *,
++ int *num_probes);
++
++ /* Return the number of arguments available to PROBE. PROBE will
++ have come from a call to this objfile's sym_get_probes method.
++ If you provide an implementation of sym_get_probes, you must
++ implement this method as well. */
++ int (*sym_get_probe_argument_count) (struct objfile *objfile,
++ const struct stap_probe *probe);
++
++ /* Evaluate the Nth argument available to PROBE. PROBE will have
++ come from a call to this objfile's sym_get_probes method. N will
++ be between 0 and the number of arguments available to this probe.
++ FRAME is the frame in which the evaluation is done; the frame's
++ PC will match the address of the probe. If you provide an
++ implementation of sym_get_probes, you must implement this method
++ as well. */
++ struct value *(*sym_evaluate_probe_argument) (struct objfile *objfile,
++ const struct stap_probe *probe,
++ struct frame_info *frame,
++ int n);
++
++ /* Compile the Nth probe argument to an agent expression. PROBE
++ will have come from a call to this objfile's sym_get_probes
++ method. N will be between 0 and the number of arguments
++ available to this probe. EXPR and VALUE are the agent expression
++ that is being updated. */
++ void (*sym_compile_to_ax) (struct objfile *objfile,
++ const struct stap_probe *probe,
++ struct agent_expr *expr,
++ struct axs_value *value,
++ int n);
++
++ /* Relocate the probe section of OBJFILE. */
++ void (*sym_relocate_probe) (struct objfile *objfile,
++ struct section_offsets *new_offsets,
++ struct section_offsets *delta);
++};
+
- static int debug_to_stopped_by_watchpoint (void);
-
- static int debug_to_stopped_data_address (struct target_ops *, CORE_ADDR *);
-@@ -606,6 +608,7 @@ update_current_target (void)
- INHERIT (to_remove_hw_breakpoint, t);
- INHERIT (to_insert_watchpoint, t);
- INHERIT (to_remove_watchpoint, t);
-+ INHERIT (to_detach_watchpoints, t);
- INHERIT (to_stopped_data_address, t);
- INHERIT (to_have_steppable_watchpoint, t);
- INHERIT (to_have_continuable_watchpoint, t);
-@@ -739,6 +742,9 @@ update_current_target (void)
- de_fault (to_remove_watchpoint,
- (int (*) (CORE_ADDR, int, int, struct expression *))
- return_minus_one);
-+ de_fault (to_detach_watchpoints,
-+ (int (*) (void))
-+ return_zero);
- de_fault (to_stopped_by_watchpoint,
- (int (*) (void))
- return_zero);
-@@ -3440,6 +3446,19 @@ debug_to_remove_watchpoint (CORE_ADDR addr, int len, int type,
- return retval;
+ /* Structure to keep track of symbol reading functions for various
+ object file types. */
+
+@@ -360,6 +411,10 @@ struct sym_fns
+
+ bfd_byte *(*sym_relocate) (struct objfile *, asection *sectp, bfd_byte *buf);
+
++ /* If non-NULL, this objfile has probe support, and all the probe
++ functions referred to here will be non-NULL. */
++ const struct sym_probe_fns *sym_probe_fns;
++
+ /* The "quick" (aka partial) symbol functions for this symbol
+ reader. */
+ const struct quick_symbol_functions *qf;
+Index: gdb-7.2.90.20110703/gdb/symtab.c
+===================================================================
+--- gdb-7.2.90.20110703.orig/gdb/symtab.c 2011-07-02 22:03:43.000000000 +0200
++++ gdb-7.2.90.20110703/gdb/symtab.c 2011-07-03 10:33:11.000000000 +0200
+@@ -770,6 +770,7 @@ init_sal (struct symtab_and_line *sal)
+ sal->end = 0;
+ sal->explicit_pc = 0;
+ sal->explicit_line = 0;
++ sal->semaphore = 0;
}
+ \f
-+static int
-+debug_to_detach_watchpoints (void)
-+{
-+ int retval;
-+
-+ retval = debug_target.to_detach_watchpoints ();
-+
-+ fprintf_unfiltered (gdb_stdlog,
-+ "target_detach_watchpoints () = %ld\n",
-+ (unsigned long) retval);
-+ return retval;
-+}
-+
- static void
- debug_to_terminal_init (void)
- {
-@@ -3687,6 +3706,7 @@ setup_target_debug (void)
- current_target.to_remove_hw_breakpoint = debug_to_remove_hw_breakpoint;
- current_target.to_insert_watchpoint = debug_to_insert_watchpoint;
- current_target.to_remove_watchpoint = debug_to_remove_watchpoint;
-+ current_target.to_detach_watchpoints = debug_to_detach_watchpoints;
- current_target.to_stopped_by_watchpoint = debug_to_stopped_by_watchpoint;
- current_target.to_stopped_data_address = debug_to_stopped_data_address;
- current_target.to_watchpoint_addr_within_range = debug_to_watchpoint_addr_within_range;
-diff --git a/gdb/target.h b/gdb/target.h
-index 3c8c017..608a742 100644
---- a/gdb/target.h
-+++ b/gdb/target.h
-@@ -433,6 +433,7 @@ struct target_ops
- provided with the corresponding target_* macros. */
- int (*to_remove_watchpoint) (CORE_ADDR, int, int, struct expression *);
- int (*to_insert_watchpoint) (CORE_ADDR, int, int, struct expression *);
-+ int (*to_detach_watchpoints) (void);
-
- int (*to_stopped_by_watchpoint) (void);
- int to_have_steppable_watchpoint;
-@@ -1316,6 +1317,15 @@ extern char *normal_pid_to_str (ptid_t ptid);
- #define target_remove_watchpoint(addr, len, type, cond) \
- (*current_target.to_remove_watchpoint) (addr, len, type, cond)
-
-+/* Clear all debug registers without affecting any register caches. Function
-+ acts on INFERIOR_PTID which should be the forked-off process, either the
-+ non-threaded child one or the threaded parent one, depending on `set
-+ follow-fork-mode'. Both watchpoints and hardware breakpoints get removed.
-+ Return 0 on success, -1 on failure. */
-+
-+#define target_detach_watchpoints() \
-+ (*current_target.to_detach_watchpoints) ()
-+
- #define target_insert_hw_breakpoint(gdbarch, bp_tgt) \
- (*current_target.to_insert_hw_breakpoint) (gdbarch, bp_tgt)
-
-@@ -1369,6 +1379,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
---- /dev/null
-+++ b/gdb/testsuite/gdb.arch/x86_64-vla-pointer-foo.S
+Index: gdb-7.2.90.20110703/gdb/symtab.h
+===================================================================
+--- gdb-7.2.90.20110703.orig/gdb/symtab.h 2011-05-06 17:13:37.000000000 +0200
++++ gdb-7.2.90.20110703/gdb/symtab.h 2011-07-03 10:33:11.000000000 +0200
+@@ -1118,6 +1118,10 @@ struct symtab_and_line
+ CORE_ADDR end;
+ int explicit_pc;
+ int explicit_line;
++
++ /* If non-zero, the semaphore location associated with a SystemTap
++ probe. */
++ CORE_ADDR semaphore;
+ };
+
+ extern void init_sal (struct symtab_and_line *sal);
+Index: gdb-7.2.90.20110703/gdb/testsuite/gdb.arch/x86_64-vla-pointer-foo.S
+===================================================================
+--- /dev/null 1970-01-01 00:00:00.000000000 +0000
++++ gdb-7.2.90.20110703/gdb/testsuite/gdb.arch/x86_64-vla-pointer-foo.S 2011-07-03 10:33:11.000000000 +0200
@@ -0,0 +1,457 @@
+ .file "x86_64-vla-pointer.c"
+ .section .debug_abbrev,"",@progbits
+ .string "GNU C 4.3.2 20081105 (Red Hat 4.3.2-7)"
+ .ident "GCC: (GNU) 4.3.2 20081105 (Red Hat 4.3.2-7)"
+ .section .note.GNU-stack,"",@progbits
-diff --git a/gdb/testsuite/gdb.arch/x86_64-vla-pointer.c b/gdb/testsuite/gdb.arch/x86_64-vla-pointer.c
-new file mode 100644
-index 0000000..fe2c8f7
---- /dev/null
-+++ b/gdb/testsuite/gdb.arch/x86_64-vla-pointer.c
+Index: gdb-7.2.90.20110703/gdb/testsuite/gdb.arch/x86_64-vla-pointer.c
+===================================================================
+--- /dev/null 1970-01-01 00:00:00.000000000 +0000
++++ gdb-7.2.90.20110703/gdb/testsuite/gdb.arch/x86_64-vla-pointer.c 2011-07-03 10:33:11.000000000 +0200
@@ -0,0 +1,43 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+}
+
+#endif
-diff --git a/gdb/testsuite/gdb.arch/x86_64-vla-pointer.exp b/gdb/testsuite/gdb.arch/x86_64-vla-pointer.exp
-new file mode 100644
-index 0000000..d243cf1
---- /dev/null
-+++ b/gdb/testsuite/gdb.arch/x86_64-vla-pointer.exp
+Index: gdb-7.2.90.20110703/gdb/testsuite/gdb.arch/x86_64-vla-pointer.exp
+===================================================================
+--- /dev/null 1970-01-01 00:00:00.000000000 +0000
++++ gdb-7.2.90.20110703/gdb/testsuite/gdb.arch/x86_64-vla-pointer.exp 2011-07-03 10:33:11.000000000 +0200
@@ -0,0 +1,66 @@
+# Copyright 2009 Free Software Foundation, Inc.
+
+
+gdb_test "whatis *array" "type = char \\\[78\\\]" "second: whatis *array"
+gdb_test "ptype *array" "type = char \\\[78\\\]" "second: ptype *array"
-diff --git a/gdb/testsuite/gdb.arch/x86_64-vla-typedef-foo.S b/gdb/testsuite/gdb.arch/x86_64-vla-typedef-foo.S
-new file mode 100644
-index 0000000..66f7a39
---- /dev/null
-+++ b/gdb/testsuite/gdb.arch/x86_64-vla-typedef-foo.S
+Index: gdb-7.2.90.20110703/gdb/testsuite/gdb.arch/x86_64-vla-typedef-foo.S
+===================================================================
+--- /dev/null 1970-01-01 00:00:00.000000000 +0000
++++ gdb-7.2.90.20110703/gdb/testsuite/gdb.arch/x86_64-vla-typedef-foo.S 2011-07-03 10:33:11.000000000 +0200
@@ -0,0 +1,455 @@
+ .file "x86_64-vla-typedef.c"
+ .section .debug_abbrev,"",@progbits
+ .string "GNU C 4.3.2 20081105 (Red Hat 4.3.2-7)"
+ .ident "GCC: (GNU) 4.3.2 20081105 (Red Hat 4.3.2-7)"
+ .section .note.GNU-stack,"",@progbits
-diff --git a/gdb/testsuite/gdb.arch/x86_64-vla-typedef.c b/gdb/testsuite/gdb.arch/x86_64-vla-typedef.c
-new file mode 100644
-index 0000000..b809c4e
---- /dev/null
-+++ b/gdb/testsuite/gdb.arch/x86_64-vla-typedef.c
+Index: gdb-7.2.90.20110703/gdb/testsuite/gdb.arch/x86_64-vla-typedef.c
+===================================================================
+--- /dev/null 1970-01-01 00:00:00.000000000 +0000
++++ gdb-7.2.90.20110703/gdb/testsuite/gdb.arch/x86_64-vla-typedef.c 2011-07-03 10:33:11.000000000 +0200
@@ -0,0 +1,43 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+}
+
+#endif
-diff --git a/gdb/testsuite/gdb.arch/x86_64-vla-typedef.exp b/gdb/testsuite/gdb.arch/x86_64-vla-typedef.exp
-new file mode 100644
-index 0000000..b05411e
---- /dev/null
-+++ b/gdb/testsuite/gdb.arch/x86_64-vla-typedef.exp
+Index: gdb-7.2.90.20110703/gdb/testsuite/gdb.arch/x86_64-vla-typedef.exp
+===================================================================
+--- /dev/null 1970-01-01 00:00:00.000000000 +0000
++++ gdb-7.2.90.20110703/gdb/testsuite/gdb.arch/x86_64-vla-typedef.exp 2011-07-03 10:33:11.000000000 +0200
@@ -0,0 +1,64 @@
+# Copyright 2009 Free Software Foundation, Inc.
+
+gdb_test "whatis array" "type = array_t" "second: whatis array"
+
+gdb_test "ptype array" "type = char \\\[78\\\]" "second: ptype array"
-diff --git a/gdb/testsuite/gdb.base/arrayidx.c b/gdb/testsuite/gdb.base/arrayidx.c
-index ecc3289..f79ad40 100644
---- a/gdb/testsuite/gdb.base/arrayidx.c
-+++ b/gdb/testsuite/gdb.base/arrayidx.c
+Index: gdb-7.2.90.20110703/gdb/testsuite/gdb.base/arrayidx.c
+===================================================================
+--- gdb-7.2.90.20110703.orig/gdb/testsuite/gdb.base/arrayidx.c 2011-01-01 16:33:40.000000000 +0100
++++ gdb-7.2.90.20110703/gdb/testsuite/gdb.base/arrayidx.c 2011-07-03 10:33:11.000000000 +0200
@@ -17,6 +17,13 @@
int array[] = {1, 2, 3, 4};
int
main (void)
{
-diff --git a/gdb/testsuite/gdb.base/arrayidx.exp b/gdb/testsuite/gdb.base/arrayidx.exp
-index 3a33618..f2e11dd 100644
---- a/gdb/testsuite/gdb.base/arrayidx.exp
-+++ b/gdb/testsuite/gdb.base/arrayidx.exp
+Index: gdb-7.2.90.20110703/gdb/testsuite/gdb.base/arrayidx.exp
+===================================================================
+--- gdb-7.2.90.20110703.orig/gdb/testsuite/gdb.base/arrayidx.exp 2011-01-01 16:33:40.000000000 +0100
++++ gdb-7.2.90.20110703/gdb/testsuite/gdb.base/arrayidx.exp 2011-07-03 10:33:11.000000000 +0200
@@ -57,4 +57,12 @@ gdb_test "print array" \
"\\{\\\[0\\\] = 1, \\\[1\\\] = 2, \\\[2\\\] = 3, \\\[3\\\] = 4\\}" \
"Print array with array-indexes on"
-
-+set test "p unbound.a == &unbound.a\[0\]"
-+gdb_test_multiple $test $test {
-+ -re " = 1\r\n$gdb_prompt $" {
-+ pass $test
-+ }
-+ -re "No symbol \"unbound\" in current context.\r\n$gdb_prompt $" {
-+ unsupported "$test (no GCC)"
-+ }
-+}
-diff --git a/gdb/testsuite/gdb.base/gnu-ifunc-lib.c b/gdb/testsuite/gdb.base/gnu-ifunc-lib.c
-new file mode 100644
-index 0000000..680530a
---- /dev/null
-+++ b/gdb/testsuite/gdb.base/gnu-ifunc-lib.c
-@@ -0,0 +1,33 @@
-+/* This testcase is part of GDB, the GNU debugger.
-+
-+ Copyright 2009, 2010 Free Software Foundation, Inc.
-+
-+ This program is free software; you can redistribute it and/or modify
-+ it under the terms of the GNU General Public License as published by
-+ the Free Software Foundation; either version 3 of the License, or
-+ (at your option) any later version.
-+
-+ This program is distributed in the hope that it will be useful,
-+ but WITHOUT ANY WARRANTY; without even the implied warranty of
-+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-+ GNU General Public License for more details.
-+
-+ You should have received a copy of the GNU General Public License
-+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
-+
-+extern volatile int gnu_ifunc_initialized;
-+extern int init_stub (int arg);
-+extern int final (int arg);
-+
-+typedef int (*final_t) (int arg);
-+
-+asm (".type gnu_ifunc, @gnu_indirect_function");
-+
-+final_t
-+gnu_ifunc (void)
-+{
-+ if (! gnu_ifunc_initialized)
-+ return init_stub;
-+ else
-+ return final;
-+}
-diff --git a/gdb/testsuite/gdb.base/gnu-ifunc.c b/gdb/testsuite/gdb.base/gnu-ifunc.c
-new file mode 100644
-index 0000000..106271f
---- /dev/null
-+++ b/gdb/testsuite/gdb.base/gnu-ifunc.c
-@@ -0,0 +1,61 @@
-+/* This testcase is part of GDB, the GNU debugger.
-+
-+ Copyright 2009, 2010 Free Software Foundation, Inc.
-+
-+ This program is free software; you can redistribute it and/or modify
-+ it under the terms of the GNU General Public License as published by
-+ the Free Software Foundation; either version 3 of the License, or
-+ (at your option) any later version.
-+
-+ This program is distributed in the hope that it will be useful,
-+ but WITHOUT ANY WARRANTY; without even the implied warranty of
-+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-+ GNU General Public License for more details.
-+
-+ You should have received a copy of the GNU General Public License
-+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
-+
-+#include <assert.h>
-+
-+int
-+init_stub (int arg)
-+{
-+ return 0;
-+}
-+
-+int
-+final (int arg)
-+{
-+ return arg + 1;
-+}
-+
-+/* Make differentiation of how the gnu_ifunc call resolves before and after
-+ calling gnu_ifunc_pre. This ensures the resolved function address is not
-+ being cached anywhere for the debugging purposes. */
-+
-+volatile int gnu_ifunc_initialized;
-+
-+static void
-+gnu_ifunc_pre (void)
-+{
-+ assert (!gnu_ifunc_initialized);
-+
-+ gnu_ifunc_initialized = 1;
-+}
-+
-+extern int gnu_ifunc (int arg);
-+
-+int
-+main (void)
-+{
-+ int i;
-+
-+ gnu_ifunc_pre ();
-+
-+ i = gnu_ifunc (1); /* break-at-call */
-+ assert (i == 2);
-+
-+ gnu_ifunc (2); /* break-at-nextcall */
-+
-+ return 0; /* break-at-exit */
-+}
-diff --git a/gdb/testsuite/gdb.base/gnu-ifunc.exp b/gdb/testsuite/gdb.base/gnu-ifunc.exp
-new file mode 100644
-index 0000000..8ecf558
---- /dev/null
-+++ b/gdb/testsuite/gdb.base/gnu-ifunc.exp
-@@ -0,0 +1,110 @@
-+# Copyright (C) 2009, 2010 Free Software Foundation, Inc.
-+
-+# This program is free software; you can redistribute it and/or modify
-+# it under the terms of the GNU General Public License as published by
-+# the Free Software Foundation; either version 3 of the License, or
-+# (at your option) any later version.
-+#
-+# This program is distributed in the hope that it will be useful,
-+# but WITHOUT ANY WARRANTY; without even the implied warranty of
-+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-+# GNU General Public License for more details.
-+#
-+# You should have received a copy of the GNU General Public License
-+# along with this program. If not, see <http://www.gnu.org/licenses/>.
-+
-+if {[skip_shlib_tests]} {
-+ return 0
-+}
-+
-+set testfile "gnu-ifunc"
-+set srcfile ${testfile}.c
-+set binfile ${objdir}/${subdir}/${testfile}
-+
-+set libfile "${testfile}-lib"
-+set libsrc ${libfile}.c
-+set lib_so ${objdir}/${subdir}/${libfile}.so
-+
-+# We need DWARF for the "final" function as we "step" into the function and GDB
-+# would step-over the "final" function if there would be no line number debug
-+# information (DWARF) available.
-+#
-+# We must not have DWARF for the "gnu_ifunc" function as DWARF has no way to
-+# express the gnu-ifunc type and it would be considered as a regular function
-+# due to DWARF by GDB. In ELF gnu-ifunc is expressed by the STT_GNU_IFUNC type.
-+#
-+# Both functions need to be in the same shared library file but
-+# gdb_compile_shlib has no way to specify source-specific compilation options.
-+#
-+# Therefore $libfile contains only the gnu-ifunc function with no DWARF
-+# referencing all the other parts from the main executable with DWARF.
-+
-+set lib_opts {}
-+set exec_opts [list debug shlib=$lib_so]
-+
-+if [get_compiler_info ${binfile}] {
-+ return -1
-+}
-+
-+if { [gdb_compile_shlib ${srcdir}/${subdir}/$libsrc $lib_so $lib_opts] != ""
-+ || [gdb_compile ${srcdir}/${subdir}/$srcfile $binfile executable $exec_opts] != ""} {
-+ untested "Could not compile either $libsrc or $srcfile."
-+ return -1
-+}
-+
-+# Start with a fresh gdb.
-+
-+clean_restart $testfile
-+gdb_load_shlibs ${lib_so}
-+
-+if ![runto_main] then {
-+ fail "Can't run to main"
-+ return 1;
-+}
-+
-+# The "if" condition is artifical to test regression of a former patch.
-+gdb_breakpoint "[gdb_get_line_number "break-at-nextcall"] if i && gnu_ifunc (i) != 42"
-+
-+gdb_breakpoint [gdb_get_line_number "break-at-call"]
-+gdb_continue_to_breakpoint "break-at-call" ".*break-at-call.*"
-+
-+# Test GDB will automatically indirect the call.
-+
-+gdb_test "p gnu_ifunc (3)" " = 4"
-+
-+# Test GDB will skip the gnu_ifunc resolver on first call.
-+
-+gdb_test "step" "\r\nfinal .*"
-+
-+# Test GDB will not break before the final chosen implementation.
-+
-+# Also test a former patch regression:
-+# Continuing.
-+# Error in testing breakpoint condition:
-+# Attempt to take address of value not located in memory.
-+#
-+# Breakpoint 2, main () at ./gdb.base/gnu-ifunc.c:33
-+
-+gdb_test "continue" "Continuing.\r\n\r\nBreakpoint .* (at|in) .*break-at-nextcall.*" \
-+ "continue to break-at-nextcall"
-+
-+gdb_breakpoint "gnu_ifunc"
-+
-+gdb_continue_to_breakpoint "nextcall gnu_ifunc"
-+
-+gdb_test "frame" "#0 +(0x\[0-9a-f\]+ in +)?final \\(.*" "nextcall gnu_ifunc skipped"
-+
-+
-+# Check any commands not doing an inferior call still compute with address of
-+# the gnu-ifunc resolver.
-+
-+gdb_test "p gnu_ifunc" " = {<text gnu-indirect-function variable, no debug info>} 0x\[0-9a-f\]+ <gnu_ifunc>" "p gnu_ifunc executing"
-+gdb_test "info sym gnu_ifunc" "gnu_ifunc in section .*" "info sym gnu_ifunc executing"
-+
-+set test "info addr gnu_ifunc"
++set test "p unbound.a == &unbound.a\[0\]"
+gdb_test_multiple $test $test {
-+ -re "Symbol \"gnu_ifunc\" is at (0x\[0-9a-f\]+) in .*$gdb_prompt $" {
++ -re " = 1\r\n$gdb_prompt $" {
+ pass $test
+ }
++ -re "No symbol \"unbound\" in current context.\r\n$gdb_prompt $" {
++ unsupported "$test (no GCC)"
++ }
+}
-+gdb_test "info sym $expect_out(1,string)" "gnu_ifunc in section .*" "info sym <gnu_ifunc-address>"
-diff --git a/gdb/testsuite/gdb.base/internal-var-field-address.c b/gdb/testsuite/gdb.base/internal-var-field-address.c
-new file mode 100644
-index 0000000..eeb7b85
---- /dev/null
-+++ b/gdb/testsuite/gdb.base/internal-var-field-address.c
+Index: gdb-7.2.90.20110703/gdb/testsuite/gdb.base/default.exp
+===================================================================
+--- gdb-7.2.90.20110703.orig/gdb/testsuite/gdb.base/default.exp 2011-02-15 22:17:52.000000000 +0100
++++ gdb-7.2.90.20110703/gdb/testsuite/gdb.base/default.exp 2011-07-03 10:33:11.000000000 +0200
+@@ -607,6 +607,17 @@ gdb_test_list_exact "show convenience" "
+ {$_sdata = void} \
+ {$_siginfo = void} \
+ {$_thread = 0} \
++ {$_probe_argc = <error: No frame selected>} \
++ {$_probe_arg0 = <error: No frame selected>} \
++ {$_probe_arg1 = <error: No frame selected>} \
++ {$_probe_arg2 = <error: No frame selected>} \
++ {$_probe_arg3 = <error: No frame selected>} \
++ {$_probe_arg4 = <error: No frame selected>} \
++ {$_probe_arg5 = <error: No frame selected>} \
++ {$_probe_arg6 = <error: No frame selected>} \
++ {$_probe_arg7 = <error: No frame selected>} \
++ {$_probe_arg8 = <error: No frame selected>} \
++ {$_probe_arg9 = <error: No frame selected>} \
+ }
+
+ #test show directories
+Index: gdb-7.2.90.20110703/gdb/testsuite/gdb.base/internal-var-field-address.c
+===================================================================
+--- /dev/null 1970-01-01 00:00:00.000000000 +0000
++++ gdb-7.2.90.20110703/gdb/testsuite/gdb.base/internal-var-field-address.c 2011-07-03 10:33:11.000000000 +0200
@@ -0,0 +1,20 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+struct {
+ int field;
+} staticstruct = { 1 };
-diff --git a/gdb/testsuite/gdb.base/internal-var-field-address.exp b/gdb/testsuite/gdb.base/internal-var-field-address.exp
-new file mode 100644
-index 0000000..6d82e73
---- /dev/null
-+++ b/gdb/testsuite/gdb.base/internal-var-field-address.exp
+Index: gdb-7.2.90.20110703/gdb/testsuite/gdb.base/internal-var-field-address.exp
+===================================================================
+--- /dev/null 1970-01-01 00:00:00.000000000 +0000
++++ gdb-7.2.90.20110703/gdb/testsuite/gdb.base/internal-var-field-address.exp 2011-07-03 10:33:11.000000000 +0200
@@ -0,0 +1,26 @@
+# Copyright 2009 Free Software Foundation, Inc.
+
+
+gdb_test {set $varstruct = staticstruct}
+gdb_test {p $varstruct.field} " = 1"
-diff --git a/gdb/testsuite/gdb.base/vla-overflow.c b/gdb/testsuite/gdb.base/vla-overflow.c
-new file mode 100644
-index 0000000..c5d5ee0
---- /dev/null
-+++ b/gdb/testsuite/gdb.base/vla-overflow.c
+Index: gdb-7.2.90.20110703/gdb/testsuite/gdb.base/stap-probe.c
+===================================================================
+--- /dev/null 1970-01-01 00:00:00.000000000 +0000
++++ gdb-7.2.90.20110703/gdb/testsuite/gdb.base/stap-probe.c 2011-07-03 10:33:11.000000000 +0200
+@@ -0,0 +1,69 @@
++/* This testcase is part of GDB, the GNU debugger.
++
++ Copyright 2011 Free Software Foundation, Inc.
++
++ This program is free software; you can redistribute it and/or modify
++ it under the terms of the GNU General Public License as published by
++ the Free Software Foundation; either version 3 of the License, or
++ (at your option) any later version.
++
++ This program is distributed in the hope that it will be useful,
++ but WITHOUT ANY WARRANTY; without even the implied warranty of
++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ GNU General Public License for more details.
++
++ You should have received a copy of the GNU General Public License
++ along with this program. If not, see <http://www.gnu.org/licenses/>. */
++
++#if USE_PROBES
++
++#define _SDT_HAS_SEMAPHORES
++__extension__ unsigned short teste_user_semaphore __attribute__ ((unused)) __attribute__ ((section (".probes")));
++#define TEST teste_user_semaphore
++
++__extension__ unsigned short teste_two_semaphore __attribute__ ((unused)) __attribute__ ((section (".probes")));
++#define TEST2 teste_two_semaphore
++
++#else
++
++#define TEST 1
++#define TEST2 1
++
++#endif
++
++#include <sys/sdt.h>
++
++/* We only support SystemTap and only the v3 form. */
++#if _SDT_NOTE_TYPE != 3
++#error "not using SystemTap v3 probes"
++#endif
++
++void
++m1 (void)
++{
++ if (TEST2)
++ STAP_PROBE (teste, two);
++}
++
++void
++m2 (void)
++{
++ if (TEST2)
++ STAP_PROBE (teste, two);
++}
++
++int
++f (int x)
++{
++ if (TEST)
++ STAP_PROBE1(teste, user, x);
++ return x+5;
++}
++
++int
++main()
++{
++ f(f(23));
++ m1();
++ m2();
++}
+Index: gdb-7.2.90.20110703/gdb/testsuite/gdb.base/stap-probe.exp
+===================================================================
+--- /dev/null 1970-01-01 00:00:00.000000000 +0000
++++ gdb-7.2.90.20110703/gdb/testsuite/gdb.base/stap-probe.exp 2011-07-03 10:33:11.000000000 +0200
+@@ -0,0 +1,72 @@
++# Copyright (C) 2011 Free Software Foundation, Inc.
++
++# This program is free software; you can redistribute it and/or modify
++# it under the terms of the GNU General Public License as published by
++# the Free Software Foundation; either version 3 of the License, or
++# (at your option) any later version.
++#
++# This program is distributed in the hope that it will be useful,
++# but WITHOUT ANY WARRANTY; without even the implied warranty of
++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++# GNU General Public License for more details.
++#
++# You should have received a copy of the GNU General Public License
++# along with this program. If not, see <http://www.gnu.org/licenses/>.
++
++set testfile stap-probe
++
++# Run the tests. We run the tests two different ways: once with a
++# plain probe, and once with a probe that has an associated semaphore.
++# This returns -1 on failure to compile or start, 0 otherwise.
++proc stap_test {{arg ""}} {
++ global testfile hex
++
++ if {$arg != ""} {
++ set arg "additional_flags=$arg"
++ set addendum ", with semaphore"
++ } else {
++ set addendum ", no semaphore"
++ }
++
++ if {[prepare_for_testing ${testfile}.exp ${testfile} ${testfile}.c \
++ [concat $arg debug]]} {
++ return -1
++ }
++
++ if ![runto_main] {
++ return -1
++ }
++
++ gdb_test "print \$_probe_argc" "No SystemTap probe at PC $hex" \
++ "check argument not at probe point$addendum"
++
++ gdb_test "info probes" \
++ "teste *user *$hex .*" \
++ "info probes$addendum"
++
++ if {[runto "probe:teste:user"]} {
++ pass "run to probe:teste:user$addendum"
++ } else {
++ fail "run to probe:teste:user$addendum"
++ }
++
++ # Test probe arguments.
++ gdb_test "print \$_probe_argc" " = 1" "print \$_probe_argc$addendum"
++ gdb_test "print \$_probe_arg0 == x" " = 1" "check \$_probe_arg0$addendum"
++ gdb_test "print \$_probe_arg1" \
++ "Invalid probe argument 1 -- probe has 1 arguments available" \
++ "check \$_probe_arg1$addendum"
++
++ # Set a breakpoint with multiple probe locations.
++ gdb_test "break probe:teste:two" \
++ "Breakpoint .* at $hex.*2 locations.*" \
++ "set multi-location probe breakpoint$addendum"
++
++ return 0
++}
++
++if {[stap_test] == -1} {
++ untested stap-probe.exp
++ return -1
++}
++stap_test "-DUSE_PROBES"
+Index: gdb-7.2.90.20110703/gdb/testsuite/gdb.base/vla-overflow.c
+===================================================================
+--- /dev/null 1970-01-01 00:00:00.000000000 +0000
++++ gdb-7.2.90.20110703/gdb/testsuite/gdb.base/vla-overflow.c 2011-07-03 10:33:11.000000000 +0200
@@ -0,0 +1,30 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+
+ return 0;
+}
-diff --git a/gdb/testsuite/gdb.base/vla-overflow.exp b/gdb/testsuite/gdb.base/vla-overflow.exp
-new file mode 100644
-index 0000000..24a608f
---- /dev/null
-+++ b/gdb/testsuite/gdb.base/vla-overflow.exp
+Index: gdb-7.2.90.20110703/gdb/testsuite/gdb.base/vla-overflow.exp
+===================================================================
+--- /dev/null 1970-01-01 00:00:00.000000000 +0000
++++ gdb-7.2.90.20110703/gdb/testsuite/gdb.base/vla-overflow.exp 2011-07-03 10:33:11.000000000 +0200
@@ -0,0 +1,109 @@
+# Copyright 2008 Free Software Foundation, Inc.
+
+gdb_test "bt" "in \[^ \]*abort \\(.* in main \\(.*" "Backtrace after abort()"
+
+verbose -log "kb_found in bt after abort() = [expr [memory_v_pages_get] * $pagesize / 1024]"
-diff --git a/gdb/testsuite/gdb.base/vla.c b/gdb/testsuite/gdb.base/vla.c
-new file mode 100644
-index 0000000..e1f3ed1
---- /dev/null
-+++ b/gdb/testsuite/gdb.base/vla.c
+Index: gdb-7.2.90.20110703/gdb/testsuite/gdb.base/vla.c
+===================================================================
+--- /dev/null 1970-01-01 00:00:00.000000000 +0000
++++ gdb-7.2.90.20110703/gdb/testsuite/gdb.base/vla.c 2011-07-03 10:33:11.000000000 +0200
@@ -0,0 +1,55 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+ char temp1[size];
+ char temp3[48];
+
-+ temp1[size - 1] = '\0';
-+ {
-+ char temp2[size];
-+
-+ bar (temp1, temp2, temp3, size);
-+
-+ marker (); /* break-here */
-+ }
-+}
-+
-+int
-+main (void)
-+{
-+ foo (26);
-+ foo (78);
-+ return 0;
-+}
-diff --git a/gdb/testsuite/gdb.base/vla.exp b/gdb/testsuite/gdb.base/vla.exp
-new file mode 100644
-index 0000000..5da7378
---- /dev/null
-+++ b/gdb/testsuite/gdb.base/vla.exp
-@@ -0,0 +1,62 @@
-+# Copyright 2008 Free Software Foundation, Inc.
-+
-+# This program is free software; you can redistribute it and/or modify
-+# it under the terms of the GNU General Public License as published by
-+# the Free Software Foundation; either version 3 of the License, or
-+# (at your option) any later version.
-+#
-+# This program is distributed in the hope that it will be useful,
-+# but WITHOUT ANY WARRANTY; without even the implied warranty of
-+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-+# GNU General Public License for more details.
-+#
-+# You should have received a copy of the GNU General Public License
-+# along with this program. If not, see <http://www.gnu.org/licenses/>.
-+
-+set testfile vla
-+set srcfile ${testfile}.c
-+set binfile ${objdir}/${subdir}/${testfile}
-+if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
-+ untested "Couldn't compile test program"
-+ return -1
-+}
-+
-+gdb_exit
-+gdb_start
-+gdb_reinitialize_dir $srcdir/$subdir
-+gdb_load ${binfile}
-+
-+if ![runto_main] {
-+ untested vla
-+ return -1
-+}
-+
-+gdb_breakpoint [gdb_get_line_number "break-here"]
-+
-+gdb_continue_to_breakpoint "break-here"
-+
-+gdb_test "whatis temp1" "type = char \\\[variable\\\]" "first: whatis temp1"
-+gdb_test "whatis temp2" "type = char \\\[variable\\\]" "first: whatis temp2"
-+gdb_test "whatis temp3" "type = char \\\[48\\\]" "first: whatis temp3"
-+
-+gdb_test "ptype temp1" "type = char \\\[26\\\]" "first: ptype temp1"
-+gdb_test "ptype temp2" "type = char \\\[26\\\]" "first: ptype temp2"
-+gdb_test "ptype temp3" "type = char \\\[48\\\]" "first: ptype temp3"
-+
-+gdb_test "p temp1" " = '1' <repeats 26 times>" "first: print temp1"
-+gdb_test "p temp2" " = '2' <repeats 26 times>" "first: print temp2"
-+gdb_test "p temp3" " = '3' <repeats 48 times>" "first: print temp3"
-+
-+gdb_continue_to_breakpoint "break-here"
-+
-+gdb_test "whatis temp1" "type = char \\\[variable\\\]" "second: whatis temp1"
-+gdb_test "whatis temp2" "type = char \\\[variable\\\]" "second: whatis temp2"
-+gdb_test "whatis temp3" "type = char \\\[48\\\]" "second: whatis temp3"
-+
-+gdb_test "ptype temp1" "type = char \\\[78\\\]" "second: ptype temp1"
-+gdb_test "ptype temp2" "type = char \\\[78\\\]" "second: ptype temp2"
-+gdb_test "ptype temp3" "type = char \\\[48\\\]" "second: ptype temp3"
-+
-+gdb_test "p temp1" " = '1' <repeats 78 times>" "second: print temp1"
-+gdb_test "p temp2" " = '2' <repeats 78 times>" "second: print temp2"
-+gdb_test "p temp3" " = '3' <repeats 48 times>" "second: print temp3"
-diff --git a/gdb/testsuite/gdb.cp/gdb9593.cc b/gdb/testsuite/gdb.cp/gdb9593.cc
-new file mode 100644
-index 0000000..783c962
---- /dev/null
-+++ b/gdb/testsuite/gdb.cp/gdb9593.cc
-@@ -0,0 +1,180 @@
-+/* This testcase is part of GDB, the GNU debugger.
-+
-+ Copyright 2008, 2009 Free Software Foundation, Inc.
-+
-+ This program is free software; you can redistribute it and/or modify
-+ it under the terms of the GNU General Public License as published by
-+ the Free Software Foundation; either version 3 of the License, or
-+ (at your option) any later version.
-+
-+ This program is distributed in the hope that it will be useful,
-+ but WITHOUT ANY WARRANTY; without even the implied warranty of
-+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-+ GNU General Public License for more details.
-+
-+ You should have received a copy of the GNU General Public License
-+ along with this program. If not, see <http://www.gnu.org/licenses/>.
-+ */
-+#include <iostream>
-+
-+using namespace std;
-+
-+class NextOverThrowDerivates
-+{
-+
-+public:
-+
-+
-+ // Single throw an exception in this function.
-+ void function1()
-+ {
-+ throw 20;
-+ }
-+
-+ // Throw an exception in another function.
-+ void function2()
-+ {
-+ function1();
-+ }
-+
-+ // Throw an exception in another function, but handle it
-+ // locally.
-+ void function3 ()
-+ {
-+ {
-+ try
-+ {
-+ function1 ();
-+ }
-+ catch (...)
-+ {
-+ cout << "Caught and handled function1 exception" << endl;
-+ }
-+ }
-+ }
-+
-+ void rethrow ()
-+ {
-+ try
-+ {
-+ function1 ();
-+ }
-+ catch (...)
-+ {
-+ throw;
-+ }
-+ }
-+
-+ void finish ()
-+ {
-+ // We use this to test that a "finish" here does not end up in
-+ // this frame, but in the one above.
-+ try
-+ {
-+ function1 ();
-+ }
-+ catch (int x)
-+ {
-+ }
-+ function1 (); // marker for until
-+ }
-+
-+ void until ()
-+ {
-+ function1 ();
-+ function1 (); // until here
-+ }
-+
-+};
-+NextOverThrowDerivates next_cases;
-+
-+
-+int main ()
-+{
-+ try
-+ {
-+ next_cases.function1 ();
-+ }
-+ catch (...)
-+ {
-+ // Discard
-+ }
-+
-+ try
-+ {
-+ next_cases.function2 ();
-+ }
-+ catch (...)
-+ {
-+ // Discard
-+ }
-+
-+ try
-+ {
-+ // This is duplicated so we can next over one but step into
-+ // another.
-+ next_cases.function2 ();
-+ }
-+ catch (...)
-+ {
-+ // Discard
-+ }
-+
-+ next_cases.function3 ();
-+
-+ try
-+ {
-+ next_cases.rethrow ();
-+ }
-+ catch (...)
-+ {
-+ // Discard
-+ }
-+
-+ try
-+ {
-+ // Another duplicate so we can test "finish".
-+ next_cases.function2 ();
-+ }
-+ catch (...)
-+ {
-+ // Discard
-+ }
-+
-+ // Another test for "finish".
-+ try
-+ {
-+ next_cases.finish ();
-+ }
-+ catch (...)
-+ {
-+ }
-+
-+ // Test of "until".
-+ try
-+ {
-+ next_cases.finish ();
-+ }
-+ catch (...)
-+ {
-+ }
-+
-+ // Test of "until" with an argument.
-+ try
-+ {
-+ next_cases.until ();
-+ }
-+ catch (...)
-+ {
-+ }
++ temp1[size - 1] = '\0';
++ {
++ char temp2[size];
+
-+ // Test of "advance".
-+ try
-+ {
-+ next_cases.until ();
-+ }
-+ catch (...)
-+ {
-+ }
++ bar (temp1, temp2, temp3, size);
++
++ marker (); /* break-here */
++ }
+}
+
-diff --git a/gdb/testsuite/gdb.cp/gdb9593.exp b/gdb/testsuite/gdb.cp/gdb9593.exp
-new file mode 100644
-index 0000000..3dad7ca
---- /dev/null
-+++ b/gdb/testsuite/gdb.cp/gdb9593.exp
-@@ -0,0 +1,182 @@
-+# Copyright 2008, 2009 Free Software Foundation, Inc.
++int
++main (void)
++{
++ foo (26);
++ foo (78);
++ return 0;
++}
+Index: gdb-7.2.90.20110703/gdb/testsuite/gdb.base/vla.exp
+===================================================================
+--- /dev/null 1970-01-01 00:00:00.000000000 +0000
++++ gdb-7.2.90.20110703/gdb/testsuite/gdb.base/vla.exp 2011-07-03 10:33:11.000000000 +0200
+@@ -0,0 +1,62 @@
++# Copyright 2008 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
-+
-+if $tracelevel then {
-+ strace $tracelevel
-+}
-+
-+if { [skip_cplus_tests] } { continue }
-+
-+set testfile "gdb9593"
-+set srcfile ${testfile}.cc
-+set binfile $objdir/$subdir/$testfile
-+
-+# Create and source the file that provides information about the compiler
-+# used to compile the test case.
-+if [get_compiler_info ${binfile} "c++"] {
-+ untested gdb9593.exp
-+ return -1
-+}
-+
-+if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } {
-+ untested gdb9593.exp
++set testfile vla
++set srcfile ${testfile}.c
++set binfile ${objdir}/${subdir}/${testfile}
++if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
++ untested "Couldn't compile test program"
+ return -1
+}
+
-+# Some targets can't do function calls, so don't even bother with this
-+# test.
-+if [target_info exists gdb,cannot_call_functions] {
-+ setup_xfail "*-*-*" 9593
-+ fail "This target can not call functions"
-+ continue
-+}
-+
+gdb_exit
+gdb_start
+gdb_reinitialize_dir $srcdir/$subdir
+gdb_load ${binfile}
+
-+if ![runto_main] then {
-+ perror "couldn't run to main"
-+ continue
-+}
-+
-+# See whether we have the needed unwinder hooks.
-+set ok 1
-+gdb_test_multiple "print _Unwind_DebugHook" "check for unwinder hook" {
-+ -re "= .*_Unwind_DebugHook.*\r\n$gdb_prompt $" {
-+ pass "check for unwinder hook"
-+ }
-+ -re "No symbol .* in current context.\r\n$gdb_prompt $" {
-+ # Pass the test so we don't get bogus fails in the results.
-+ pass "check for unwinder hook"
-+ set ok 0
-+ }
-+}
-+if {!$ok} {
-+ untested gdb9593.exp
++if ![runto_main] {
++ untested vla
+ return -1
+}
+
-+# See http://sourceware.org/bugzilla/show_bug.cgi?id=9593
-+
-+gdb_test "next" \
-+ ".*catch (...).*" \
-+ "next over a throw 1"
-+
-+gdb_test "next" \
-+ ".*next_cases.function2.*" \
-+ "next past catch 1"
-+
-+gdb_test "next" \
-+ ".*catch (...).*" \
-+ "next over a throw 2"
-+
-+gdb_test "next" \
-+ ".*next_cases.function2.*" \
-+ "next past catch 2"
-+
-+gdb_test "step" \
-+ ".*function1().*" \
-+ "step into function2 1"
-+
-+gdb_test "next" \
-+ ".*catch (...).*" \
-+ "next over a throw 3"
-+
-+gdb_test "next" \
-+ ".*next_cases.function3.*" \
-+ "next past catch 3"
-+
-+gdb_test "next" \
-+ ".*next_cases.rethrow.*" \
-+ "next over a throw 4"
-+
-+gdb_test "next" \
-+ ".*catch (...).*" \
-+ "next over a rethrow"
-+
-+gdb_test "next" \
-+ ".*next_cases.function2.*" \
-+ "next after a rethrow"
-+
-+gdb_test "step" \
-+ ".*function1().*" \
-+ "step into function2 2"
-+
-+gdb_test "finish" \
-+ ".*catch (...).*" \
-+ "finish 1"
-+
-+gdb_test "next" \
-+ ".*next_cases.finish ().*" \
-+ "next past catch 4"
-+
-+gdb_test "step" \
-+ ".*function1 ().*" \
-+ "step into finish method"
-+
-+gdb_test "finish" \
-+ ".*catch (...).*" \
-+ "finish 2"
-+
-+gdb_test "next" \
-+ ".*next_cases.finish ().*" \
-+ "next past catch 5"
-+
-+gdb_test "step" \
-+ ".*function1 ().*" \
-+ "step into finish, for until"
-+
-+gdb_test "until" \
-+ ".*function1 ().*" \
-+ "until with no argument 1"
++gdb_breakpoint [gdb_get_line_number "break-here"]
+
-+set line [gdb_get_line_number "marker for until" $testfile.cc]
++gdb_continue_to_breakpoint "break-here"
+
-+gdb_test "until $line" \
-+ ".*function1 ().*" \
-+ "next past catch 6"
++gdb_test "whatis temp1" "type = char \\\[variable\\\]" "first: whatis temp1"
++gdb_test "whatis temp2" "type = char \\\[variable\\\]" "first: whatis temp2"
++gdb_test "whatis temp3" "type = char \\\[48\\\]" "first: whatis temp3"
+
-+gdb_test "until" \
-+ ".*catch (...).*" \
-+ "until with no argument 2"
++gdb_test "ptype temp1" "type = char \\\[26\\\]" "first: ptype temp1"
++gdb_test "ptype temp2" "type = char \\\[26\\\]" "first: ptype temp2"
++gdb_test "ptype temp3" "type = char \\\[48\\\]" "first: ptype temp3"
+
-+set line [gdb_get_line_number "until here" $testfile.cc]
++gdb_test "p temp1" " = '1' <repeats 26 times>" "first: print temp1"
++gdb_test "p temp2" " = '2' <repeats 26 times>" "first: print temp2"
++gdb_test "p temp3" " = '3' <repeats 48 times>" "first: print temp3"
+
-+gdb_test "next" \
-+ ".*next_cases.until ().*" \
-+ "next past catch 6"
++gdb_continue_to_breakpoint "break-here"
+
-+gdb_test "step" \
-+ ".*function1 ().*" \
-+ "step into until"
++gdb_test "whatis temp1" "type = char \\\[variable\\\]" "second: whatis temp1"
++gdb_test "whatis temp2" "type = char \\\[variable\\\]" "second: whatis temp2"
++gdb_test "whatis temp3" "type = char \\\[48\\\]" "second: whatis temp3"
+
-+gdb_test "until $line" \
-+ ".*catch (...).*" \
-+ "until-over-throw"
++gdb_test "ptype temp1" "type = char \\\[78\\\]" "second: ptype temp1"
++gdb_test "ptype temp2" "type = char \\\[78\\\]" "second: ptype temp2"
++gdb_test "ptype temp3" "type = char \\\[48\\\]" "second: ptype temp3"
+
-+gdb_test "next" \
-+ ".*next_cases.until ().*" \
-+ "next past catch 7"
++gdb_test "p temp1" " = '1' <repeats 78 times>" "second: print temp1"
++gdb_test "p temp2" " = '2' <repeats 78 times>" "second: print temp2"
++gdb_test "p temp3" " = '3' <repeats 48 times>" "second: print temp3"
+Index: gdb-7.2.90.20110703/gdb/testsuite/gdb.cp/nextoverthrow.exp
+===================================================================
+--- gdb-7.2.90.20110703.orig/gdb/testsuite/gdb.cp/nextoverthrow.exp 2011-01-01 16:33:44.000000000 +0100
++++ gdb-7.2.90.20110703/gdb/testsuite/gdb.cp/nextoverthrow.exp 2011-07-03 10:33:11.000000000 +0200
+@@ -53,6 +53,17 @@ gdb_test_multiple "print _Unwind_DebugHo
+ }
+ }
+ if {!$ok} {
++ gdb_test_multiple "info probe" "check for stap probe in unwinder" {
++ -re ".*libgcc.*unwind.*\r\n$gdb_prompt $" {
++ pass "check for stap probe in unwinder"
++ set ok 1
++ }
++ -re "\r\n$gdb_prompt $" {
++ }
++ }
++}
+
-+gdb_test "step" \
-+ ".*function1 ().*" \
-+ "step into until, for advance"
-+
-+gdb_test "advance $line" \
-+ ".*catch (...).*" \
-+ "advance-over-throw"
-diff --git a/gdb/testsuite/gdb.dwarf2/dw2-bound-loclist.S b/gdb/testsuite/gdb.dwarf2/dw2-bound-loclist.S
-new file mode 100644
-index 0000000..7fb00ea
---- /dev/null
-+++ b/gdb/testsuite/gdb.dwarf2/dw2-bound-loclist.S
-@@ -0,0 +1,212 @@
++if {!$ok} {
+ unsupported "nextoverthrow.exp could not find _Unwind_DebugHook"
+ return -1
+ }
+Index: gdb-7.2.90.20110703/gdb/testsuite/gdb.dwarf2/dw2-bound-loclist.S
+===================================================================
+--- /dev/null 1970-01-01 00:00:00.000000000 +0000
++++ gdb-7.2.90.20110703/gdb/testsuite/gdb.dwarf2/dw2-bound-loclist.S 2011-07-03 10:33:11.000000000 +0200
+@@ -0,0 +1,246 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+ Copyright 2010 Free Software Foundation, Inc.
+ .4byte .Llenb_var-.Lcu1_begin /* DW_AT_upper_bound */
+ .byte 0 /* End of children of die */
+
++ /* DW_AT_upper_bound is referencing register. */
++.Larrayreg_type:
++ .uleb128 2 /* Abbrev: DW_TAG_array_type */
++ .4byte .Lchar_type-.Lcu1_begin /* DW_AT_type */
++
++ .uleb128 8 /* Abbrev: DW_TAG_subrange_type with block */
++ .4byte .Luint_type-.Lcu1_begin /* DW_AT_type */
++ .byte 0 /* DW_AT_lower_bound */
++ .byte 2f - 1f /* DW_AT_upper_bound */
++1: .byte 0x50 /* DW_OP_reg0 */
++2:
++ .byte 0 /* End of children of die */
++
+.Luint_type:
+ .uleb128 4 /* Abbrev: DW_TAG_base_type */
+ .4byte .Luint_str /* DW_AT_name */
+ .4byte vardata /* <addr> */
+2:
+
++ /* DW_AT_upper_bound is referencing register. */
++ .uleb128 6 /* Abbrev: DW_TAG_variable DW_FORM_string */
++ .string "reg_string" /* DW_AT_name */
++ .4byte .Larrayreg_type-.Lcu1_begin /* DW_AT_type */
++ .byte 2f - 1f /* DW_AT_location */
++1: .byte 3 /* DW_OP_addr */
++ .4byte vardata /* <addr> */
++2:
++
+ .byte 0 /* End of children of CU */
+.Lcu1_end:
+
+ .byte 0x0 /* Terminator */
+ .byte 0x0 /* Terminator */
+
++ .uleb128 8 /* Abbrev code */
++ .uleb128 0x21 /* DW_TAG_subrange_type with block */
++ .byte 0x0 /* no children */
++ .uleb128 0x49 /* DW_AT_type */
++ .uleb128 0x13 /* DW_FORM_ref4 */
++ .uleb128 0x22 /* DW_AT_lower_bound */
++ .uleb128 0xb /* DW_FORM_data1 */
++ .uleb128 0x2f /* DW_AT_upper_bound */
++ .uleb128 0xa /* DW_FORM_block1 */
++ .byte 0x0 /* Terminator */
++ .byte 0x0 /* Terminator */
++
+ .byte 0x0 /* Terminator */
+
+/* String table */
+ .string "char"
+.Luint_str:
+ .string "unsigned int"
-diff --git a/gdb/testsuite/gdb.dwarf2/dw2-bound-loclist.exp b/gdb/testsuite/gdb.dwarf2/dw2-bound-loclist.exp
-new file mode 100644
-index 0000000..5dbed3f
---- /dev/null
-+++ b/gdb/testsuite/gdb.dwarf2/dw2-bound-loclist.exp
-@@ -0,0 +1,51 @@
+Index: gdb-7.2.90.20110703/gdb/testsuite/gdb.dwarf2/dw2-bound-loclist.exp
+===================================================================
+--- /dev/null 1970-01-01 00:00:00.000000000 +0000
++++ gdb-7.2.90.20110703/gdb/testsuite/gdb.dwarf2/dw2-bound-loclist.exp 2011-07-03 10:33:11.000000000 +0200
+@@ -0,0 +1,54 @@
+# Copyright 2010 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+
+gdb_test "p b_string" { = (0x[0-9a-f]+ )?"seennotseen"}
+gdb_test "ptype b_string" {type = char \[\]}
-diff --git a/gdb/testsuite/gdb.dwarf2/dw2-stripped.c b/gdb/testsuite/gdb.dwarf2/dw2-stripped.c
-new file mode 100644
-index 0000000..1f02d90
---- /dev/null
-+++ b/gdb/testsuite/gdb.dwarf2/dw2-stripped.c
++
++# The register contains unpredictable value - the array size.
++gdb_test "ptype reg_string" {type = char \[-?[0-9]+\]}
+Index: gdb-7.2.90.20110703/gdb/testsuite/gdb.dwarf2/dw2-stripped.c
+===================================================================
+--- /dev/null 1970-01-01 00:00:00.000000000 +0000
++++ gdb-7.2.90.20110703/gdb/testsuite/gdb.dwarf2/dw2-stripped.c 2011-07-03 10:33:11.000000000 +0200
@@ -0,0 +1,42 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+ func1 (1, 2);
+ return 0;
+}
-diff --git a/gdb/testsuite/gdb.dwarf2/dw2-stripped.exp b/gdb/testsuite/gdb.dwarf2/dw2-stripped.exp
-new file mode 100644
-index 0000000..1c6e84a
---- /dev/null
-+++ b/gdb/testsuite/gdb.dwarf2/dw2-stripped.exp
+Index: gdb-7.2.90.20110703/gdb/testsuite/gdb.dwarf2/dw2-stripped.exp
+===================================================================
+--- /dev/null 1970-01-01 00:00:00.000000000 +0000
++++ gdb-7.2.90.20110703/gdb/testsuite/gdb.dwarf2/dw2-stripped.exp 2011-07-03 10:33:11.000000000 +0200
@@ -0,0 +1,79 @@
+# Copyright 2006 Free Software Foundation, Inc.
+
+gdb_test "step" \
+ "func.* \\(.*\\) at .*" \
+ "step"
-diff --git a/gdb/testsuite/gdb.dwarf2/dw2-struct-member-data-location.S b/gdb/testsuite/gdb.dwarf2/dw2-struct-member-data-location.S
-new file mode 100644
-index 0000000..5fcdd84
---- /dev/null
-+++ b/gdb/testsuite/gdb.dwarf2/dw2-struct-member-data-location.S
+Index: gdb-7.2.90.20110703/gdb/testsuite/gdb.dwarf2/dw2-struct-member-data-location.S
+===================================================================
+--- /dev/null 1970-01-01 00:00:00.000000000 +0000
++++ gdb-7.2.90.20110703/gdb/testsuite/gdb.dwarf2/dw2-struct-member-data-location.S 2011-07-03 10:33:11.000000000 +0200
@@ -0,0 +1,83 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+
+ .byte 0x0 /* Terminator */
+ .byte 0x0 /* Terminator */
-diff --git a/gdb/testsuite/gdb.dwarf2/dw2-struct-member-data-location.exp b/gdb/testsuite/gdb.dwarf2/dw2-struct-member-data-location.exp
-new file mode 100644
-index 0000000..c41151c
---- /dev/null
-+++ b/gdb/testsuite/gdb.dwarf2/dw2-struct-member-data-location.exp
+Index: gdb-7.2.90.20110703/gdb/testsuite/gdb.dwarf2/dw2-struct-member-data-location.exp
+===================================================================
+--- /dev/null 1970-01-01 00:00:00.000000000 +0000
++++ gdb-7.2.90.20110703/gdb/testsuite/gdb.dwarf2/dw2-struct-member-data-location.exp 2011-07-03 10:33:11.000000000 +0200
@@ -0,0 +1,37 @@
+# Copyright 2009 Free Software Foundation, Inc.
+
+clean_restart $binfile
+
+gdb_test "ptype struct some_struct" "type = struct some_struct {\[\r\n \t\]*void field;\[\r\n \t\]*}"
-diff --git a/gdb/testsuite/gdb.fortran/dwarf-stride.exp b/gdb/testsuite/gdb.fortran/dwarf-stride.exp
-new file mode 100644
-index 0000000..cd3486b
---- /dev/null
-+++ b/gdb/testsuite/gdb.fortran/dwarf-stride.exp
+Index: gdb-7.2.90.20110703/gdb/testsuite/gdb.fortran/dwarf-stride.exp
+===================================================================
+--- /dev/null 1970-01-01 00:00:00.000000000 +0000
++++ gdb-7.2.90.20110703/gdb/testsuite/gdb.fortran/dwarf-stride.exp 2011-07-03 10:33:11.000000000 +0200
@@ -0,0 +1,42 @@
+# Copyright 2009 Free Software Foundation, Inc.
+
+gdb_continue_to_breakpoint "break-here" ".*break-here.*"
+gdb_test "p c40pt(1)" " = '0-hello.*"
+gdb_test "p c40pt(2)" " = '1-hello.*"
-diff --git a/gdb/testsuite/gdb.fortran/dwarf-stride.f90 b/gdb/testsuite/gdb.fortran/dwarf-stride.f90
-new file mode 100644
-index 0000000..e492b3a
---- /dev/null
-+++ b/gdb/testsuite/gdb.fortran/dwarf-stride.f90
+Index: gdb-7.2.90.20110703/gdb/testsuite/gdb.fortran/dwarf-stride.f90
+===================================================================
+--- /dev/null 1970-01-01 00:00:00.000000000 +0000
++++ gdb-7.2.90.20110703/gdb/testsuite/gdb.fortran/dwarf-stride.f90 2011-07-03 10:33:11.000000000 +0200
@@ -0,0 +1,40 @@
+! Copyright 2009 Free Software Foundation, Inc.
+!
+ print *, c40pt ! break-here
+
+end program repro
-diff --git a/gdb/testsuite/gdb.fortran/dynamic.exp b/gdb/testsuite/gdb.fortran/dynamic.exp
-new file mode 100644
-index 0000000..0ccebe0
---- /dev/null
-+++ b/gdb/testsuite/gdb.fortran/dynamic.exp
+Index: gdb-7.2.90.20110703/gdb/testsuite/gdb.fortran/dynamic-other-frame-stub.f90
+===================================================================
+--- /dev/null 1970-01-01 00:00:00.000000000 +0000
++++ gdb-7.2.90.20110703/gdb/testsuite/gdb.fortran/dynamic-other-frame-stub.f90 2011-07-03 10:33:11.000000000 +0200
+@@ -0,0 +1,24 @@
++! Copyright 2010 Free Software Foundation, Inc.
++!
++! This program is free software; you can redistribute it and/or modify
++! it under the terms of the GNU General Public License as published by
++! the Free Software Foundation; either version 2 of the License, or
++! (at your option) any later version.
++!
++! This program is distributed in the hope that it will be useful,
++! but WITHOUT ANY WARRANTY; without even the implied warranty of
++! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++! GNU General Public License for more details.
++!
++! You should have received a copy of the GNU General Public License
++! along with this program; if not, write to the Free Software
++! Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
++!
++! Ihis file is the Fortran source file for dynamic.exp.
++! Original file written by Jakub Jelinek <jakub@redhat.com>.
++! Modified for the GDB testcase by Jan Kratochvil <jan.kratochvil@redhat.com>.
++
++subroutine bar
++ real :: dummy
++ dummy = 1
++end subroutine bar
+Index: gdb-7.2.90.20110703/gdb/testsuite/gdb.fortran/dynamic-other-frame.exp
+===================================================================
+--- /dev/null 1970-01-01 00:00:00.000000000 +0000
++++ gdb-7.2.90.20110703/gdb/testsuite/gdb.fortran/dynamic-other-frame.exp 2011-07-03 10:33:11.000000000 +0200
+@@ -0,0 +1,37 @@
++# Copyright 2010 Free Software Foundation, Inc.
++
++# This program is free software; you can redistribute it and/or modify
++# it under the terms of the GNU General Public License as published by
++# the Free Software Foundation; either version 2 of the License, or
++# (at your option) any later version.
++#
++# This program is distributed in the hope that it will be useful,
++# but WITHOUT ANY WARRANTY; without even the implied warranty of
++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++# GNU General Public License for more details.
++#
++# You should have received a copy of the GNU General Public License
++# along with this program; if not, write to the Free Software
++# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
++
++set testfile "dynamic-other-frame"
++set srcfile1 ${testfile}.f90
++set srcfile2 ${testfile}-stub.f90
++set objfile2 ${objdir}/${subdir}/${testfile}-stub.o
++set executable ${testfile}
++set binfile ${objdir}/${subdir}/${executable}
++
++if { [gdb_compile "${srcdir}/${subdir}/${srcfile2}" "${objfile2}" object {f77}] != ""
++ || [gdb_compile "${srcdir}/${subdir}/${srcfile1} ${objfile2}" "${binfile}" executable {debug f77}] != "" } {
++ untested "Couldn't compile ${srcfile1} or ${srcfile2}"
++ return -1
++}
++
++clean_restart ${executable}
++
++if ![runto bar_] then {
++ perror "couldn't run to bar_"
++ continue
++}
++
++gdb_test "bt" {foo \(string='hello'.*}
+Index: gdb-7.2.90.20110703/gdb/testsuite/gdb.fortran/dynamic-other-frame.f90
+===================================================================
+--- /dev/null 1970-01-01 00:00:00.000000000 +0000
++++ gdb-7.2.90.20110703/gdb/testsuite/gdb.fortran/dynamic-other-frame.f90 2011-07-03 10:33:11.000000000 +0200
+@@ -0,0 +1,36 @@
++! Copyright 2010 Free Software Foundation, Inc.
++!
++! This program is free software; you can redistribute it and/or modify
++! it under the terms of the GNU General Public License as published by
++! the Free Software Foundation; either version 2 of the License, or
++! (at your option) any later version.
++!
++! This program is distributed in the hope that it will be useful,
++! but WITHOUT ANY WARRANTY; without even the implied warranty of
++! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++! GNU General Public License for more details.
++!
++! You should have received a copy of the GNU General Public License
++! along with this program; if not, write to the Free Software
++! Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
++!
++! Ihis file is the Fortran source file for dynamic.exp.
++! Original file written by Jakub Jelinek <jakub@redhat.com>.
++! Modified for the GDB testcase by Jan Kratochvil <jan.kratochvil@redhat.com>.
++
++subroutine foo (string)
++ interface
++ subroutine bar
++ end subroutine
++ end interface
++ character string*(*)
++ call bar ! stop-here
++end subroutine foo
++program test
++ interface
++ subroutine foo (string)
++ character string*(*)
++ end subroutine
++ end interface
++ call foo ('hello')
++end
+Index: gdb-7.2.90.20110703/gdb/testsuite/gdb.fortran/dynamic.exp
+===================================================================
+--- /dev/null 1970-01-01 00:00:00.000000000 +0000
++++ gdb-7.2.90.20110703/gdb/testsuite/gdb.fortran/dynamic.exp 2011-07-03 10:33:11.000000000 +0200
@@ -0,0 +1,145 @@
+# Copyright 2007 Free Software Foundation, Inc.
+
+gdb_test "p vart(3,8)" "\\$\[0-9\]* = 9"
+# maps to foo::vary(1,3)
+gdb_test "p vart(2,9)" "\\$\[0-9\]* = 10"
-diff --git a/gdb/testsuite/gdb.fortran/dynamic.f90 b/gdb/testsuite/gdb.fortran/dynamic.f90
-new file mode 100644
-index 0000000..0f43564
---- /dev/null
-+++ b/gdb/testsuite/gdb.fortran/dynamic.f90
+Index: gdb-7.2.90.20110703/gdb/testsuite/gdb.fortran/dynamic.f90
+===================================================================
+--- /dev/null 1970-01-01 00:00:00.000000000 +0000
++++ gdb-7.2.90.20110703/gdb/testsuite/gdb.fortran/dynamic.f90 2011-07-03 10:33:11.000000000 +0200
@@ -0,0 +1,98 @@
+! Copyright 2007 Free Software Foundation, Inc.
+!
+ if (x (1, 1) .ne. 8 .or. x (2, 2) .ne. 9 .or. x (1, 2) .ne. 4) call abort
+ if (x (3, 1) .ne. 10) call abort
+end
-diff --git a/gdb/testsuite/gdb.fortran/string.exp b/gdb/testsuite/gdb.fortran/string.exp
-new file mode 100644
-index 0000000..b1120c3
---- /dev/null
-+++ b/gdb/testsuite/gdb.fortran/string.exp
+Index: gdb-7.2.90.20110703/gdb/testsuite/gdb.fortran/string.exp
+===================================================================
+--- /dev/null 1970-01-01 00:00:00.000000000 +0000
++++ gdb-7.2.90.20110703/gdb/testsuite/gdb.fortran/string.exp 2011-07-03 10:33:11.000000000 +0200
@@ -0,0 +1,59 @@
+# Copyright 2008 Free Software Foundation, Inc.
+
+gdb_continue_to_breakpoint "var-finish"
+gdb_test "p e" "\\$\[0-9\]* = 'e '" "p e re-set"
+gdb_test "p f" "\\$\[0-9\]* = \\(\\( 'f ', 'f ', 'f ', 'f ', 'f ', 'f ', 'f '\\) \\( 'f2 ', 'f ', 'f ', 'f ', 'f ', 'f ', 'f '\\) \\( 'f ', 'f ', 'f ', 'f ', 'f ', 'f ', 'f '\\) \\)" "p *f re-set"
-diff --git a/gdb/testsuite/gdb.fortran/string.f90 b/gdb/testsuite/gdb.fortran/string.f90
-new file mode 100644
-index 0000000..226dc5d
---- /dev/null
-+++ b/gdb/testsuite/gdb.fortran/string.f90
+Index: gdb-7.2.90.20110703/gdb/testsuite/gdb.fortran/string.f90
+===================================================================
+--- /dev/null 1970-01-01 00:00:00.000000000 +0000
++++ gdb-7.2.90.20110703/gdb/testsuite/gdb.fortran/string.f90 2011-07-03 10:33:11.000000000 +0200
@@ -0,0 +1,37 @@
+! Copyright 2008 Free Software Foundation, Inc.
+!
+ h = 'h'
+ call foo (g, h)
+end
-diff --git a/gdb/testsuite/gdb.gdb/selftest.exp b/gdb/testsuite/gdb.gdb/selftest.exp
-index fc8bccc..e053813 100644
---- a/gdb/testsuite/gdb.gdb/selftest.exp
-+++ b/gdb/testsuite/gdb.gdb/selftest.exp
+Index: gdb-7.2.90.20110703/gdb/testsuite/gdb.fortran/subrange.exp
+===================================================================
+--- /dev/null 1970-01-01 00:00:00.000000000 +0000
++++ gdb-7.2.90.20110703/gdb/testsuite/gdb.fortran/subrange.exp 2011-07-03 10:33:11.000000000 +0200
+@@ -0,0 +1,60 @@
++# Copyright 2011 Free Software Foundation, Inc.
++
++# This program is free software; you can redistribute it and/or modify
++# it under the terms of the GNU General Public License as published by
++# the Free Software Foundation; either version 3 of the License, or
++# (at your option) any later version.
++#
++# This program is distributed in the hope that it will be useful,
++# but WITHOUT ANY WARRANTY; without even the implied warranty of
++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++# GNU General Public License for more details.
++#
++# You should have received a copy of the GNU General Public License
++# along with this program. If not, see <http://www.gnu.org/licenses/>.
++
++if { [skip_fortran_tests] } { return -1 }
++
++set testfile "subrange"
++set srcfile ${testfile}.f90
++if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} {debug f77}] } {
++ return -1
++}
++
++if ![runto MAIN__] {
++ perror "Couldn't run to MAIN__"
++ continue
++}
++
++# Depending on the compiler version being used, the name of the 4-byte integer
++# and real types can be printed differently. For instance, gfortran-4.1 uses
++# "int4" whereas gfortran-4.3 uses "int(kind=4)".
++set int4 "(int4|integer\\(kind=4\\))"
++
++gdb_breakpoint [gdb_get_line_number "break-static"]
++gdb_continue_to_breakpoint "break-static" ".*break-static.*"
++
++foreach var {a alloc ptr} {
++ global pf_prefix
++ set old_prefix $pf_prefix
++ lappend pf_prefix "$var:"
++
++ gdb_test "p $var (2, 2:3)" { = \(22, 32\)}
++ gdb_test "p $var (2:3, 3)" { = \(32, 33\)}
++ gdb_test "p $var (1, 2:)" { = \(21, 31\)}
++ gdb_test "p $var (2, :2)" { = \(12, 22\)}
++ gdb_test "p $var (3, 2:2)" { = \(23\)}
++ gdb_test "ptype $var (3, 2:2)" " = $int4 \\(2:2\\)"
++ gdb_test "p $var (4, :)" { = \(14, 24, 34\)}
++ gdb_test "p $var (:, :)" { = \(\( *11, 12, 13, 14\) \( *21, 22, 23, 24\) \( *31, 32, 33, 34\) *\)}
++ gdb_test "ptype $var (:, :)" " = $int4 \\(4,3\\)"
++ gdb_test "p $var (:)" "Wrong number of subscripts"
++ gdb_test "p $var (:, :, :)" "Wrong number of subscripts"
++
++ set pf_prefix $old_prefix
++}
++
++gdb_test_no_output {set $a=a}
++delete_breakpoints
++gdb_unload
++gdb_test {p $a (3, 2:2)} { = \(23\)}
+Index: gdb-7.2.90.20110703/gdb/testsuite/gdb.fortran/subrange.f90
+===================================================================
+--- /dev/null 1970-01-01 00:00:00.000000000 +0000
++++ gdb-7.2.90.20110703/gdb/testsuite/gdb.fortran/subrange.f90 2011-07-03 10:33:11.000000000 +0200
+@@ -0,0 +1,28 @@
++! Copyright 2011 Free Software Foundation, Inc.
++!
++! This program is free software; you can redistribute it and/or modify
++! it under the terms of the GNU General Public License as published by
++! the Free Software Foundation; either version 3 of the License, or
++! (at your option) any later version.
++!
++! This program is distributed in the hope that it will be useful,
++! but WITHOUT ANY WARRANTY; without even the implied warranty of
++! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++! GNU General Public License for more details.
++!
++! You should have received a copy of the GNU General Public License
++! along with this program. If not, see <http://www.gnu.org/licenses/>.
++
++program test
++ integer, target :: a (4, 3)
++ integer, allocatable :: alloc (:, :)
++ integer, pointer :: ptr (:, :)
++ do 1 i = 1, 4
++ do 1 j = 1, 3
++ a (i, j) = j * 10 + i
++1 continue
++ allocate (alloc (4, 3))
++ alloc = a
++ ptr => a
++ write (*,*) a ! break-static
++end
+Index: gdb-7.2.90.20110703/gdb/testsuite/gdb.gdb/selftest.exp
+===================================================================
+--- gdb-7.2.90.20110703.orig/gdb/testsuite/gdb.gdb/selftest.exp 2011-07-03 10:33:07.000000000 +0200
++++ gdb-7.2.90.20110703/gdb/testsuite/gdb.gdb/selftest.exp 2011-07-03 10:33:11.000000000 +0200
@@ -92,6 +92,10 @@ proc do_steps_and_nexts {} {
set description "step over ttyarg initialization"
set command "step"
-re ".*pre_stat_chain = make_command_stats_cleanup.*$gdb_prompt $" {
set description "next over make_command_stats_cleanup and everything it calls"
set command "next"
-diff --git a/gdb/testsuite/gdb.java/jnpe.exp b/gdb/testsuite/gdb.java/jnpe.exp
-new file mode 100644
-index 0000000..55aa80d
---- /dev/null
-+++ b/gdb/testsuite/gdb.java/jnpe.exp
-@@ -0,0 +1,74 @@
-+# Copyright 2009 Free Software Foundation, Inc.
+Index: gdb-7.2.90.20110703/gdb/testsuite/gdb.mi/mi2-var-stale-type.c
+===================================================================
+--- /dev/null 1970-01-01 00:00:00.000000000 +0000
++++ gdb-7.2.90.20110703/gdb/testsuite/gdb.mi/mi2-var-stale-type.c 2011-07-03 10:33:11.000000000 +0200
+@@ -0,0 +1,26 @@
++/* Copyright 2011 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 <http://www.gnu.org/licenses/>. */
++
++int
++main (int argc, char **argv)
++{
++ char vla[argc];
+
++ vla[0] = 0; /* break-here */
++
++ return 0;
++}
+Index: gdb-7.2.90.20110703/gdb/testsuite/gdb.mi/mi2-var-stale-type.exp
+===================================================================
+--- /dev/null 1970-01-01 00:00:00.000000000 +0000
++++ gdb-7.2.90.20110703/gdb/testsuite/gdb.mi/mi2-var-stale-type.exp 2011-07-03 10:33:11.000000000 +0200
+@@ -0,0 +1,57 @@
++# Copyright 2011 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
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
-+if $tracelevel then {
-+ strace $tracelevel
-+}
++load_lib mi-support.exp
++set MIFLAGS "-i=mi2"
+
-+load_lib "java.exp"
++gdb_exit
++if [mi_gdb_start] {
++ continue
++}
+
-+set testfile "jnpe"
-+set srcfile ${testfile}.java
++set testfile "mi2-var-stale-type"
++set srcfile ${testfile}.c
+set binfile ${objdir}/${subdir}/${testfile}
-+if { [compile_java_from_source ${srcdir}/$subdir/${srcfile} ${binfile} "-g"] != "" } {
-+ untested "Couldn't compile ${srcdir}/$subdir/${srcfile}"
++if {[build_executable ${testfile}.exp $testfile $srcfile] == -1} {
+ return -1
+}
+
-+# Start with a fresh gdb.
++mi_delete_breakpoints
++mi_gdb_reinitialize_dir $srcdir/$subdir
++mi_gdb_load ${binfile}
+
-+gdb_exit
-+gdb_start
-+gdb_reinitialize_dir $srcdir/$subdir
-+gdb_load ${binfile}
++mi_gdb_test {-interpreter-exec console "maintenance set internal-error quit yes"} \
++ {\^done} \
++ "maintenance set internal-error quit yes"
+
-+set line [gdb_get_line_number "break here" $testfile.java]
-+gdb_test "break $testfile.java:$line" ""
++mi_gdb_test {-interpreter-exec console "maintenance set internal-error corefile yes"} \
++ {\^done} \
++ "maintenance set internal-error corefile yes"
+
-+gdb_test "run" \
-+ "// break here.*" \
-+ "run java next-over-throw"
++set line [gdb_get_line_number "break-here"]
++set func "main"
+
-+# See whether we have the needed unwinder hooks.
-+set ok 1
-+gdb_test_multiple "print _Unwind_DebugHook" "check for unwinder hook in java" {
-+ -re "= .*_Unwind_DebugHook.*\r\n$gdb_prompt $" {
-+ pass "check for unwinder hook in java"
-+ }
-+ -re "No symbol .* in current context.?\r\n$gdb_prompt $" {
-+ # Pass the test so we don't get bogus fails in the results.
-+ setup_xfail *-*-*
-+ fail "check for unwinder hook in java"
-+ set ok 0
-+ }
-+}
-+if {!$ok} {
-+ untested jnpe.exp
++mi_gdb_test "-break-insert -t $srcfile:$line" \
++ "\\^done,bkpt=\{number=\"\[0-9\]+\",type=\"breakpoint\",disp=\"del\",enabled=\"y\",addr=\"$hex\",func=\"$func\(\\\(.*\\\)\)?\",file=\".*\",line=\"$line\",times=\"0\",original-location=\".*\"\}" \
++ "breakpoint at $func"
++
++if { [mi_run_cmd] < 0 } {
+ return -1
+}
++mi_expect_stop "breakpoint-hit" $func ".*" ".*" "\[0-9\]+" { "" "disp=\"del\"" } "stop after initializing vla"
+
-+gdb_test "handle SIGSEGV nostop noprint" \
-+ "SIGSEGV.*fault" \
-+ "disable SIGSEGV for next-over-NPE"
++mi_create_varobj "vla" "vla" "create local variable vla"
+
-+# The line where we stop differ according to gcj; check just we did not already
-+# execute the catch point.
-+
-+gdb_test "next" \
-+ "" \
-+ "next over NPE"
-+
-+gdb_breakpoint [gdb_get_line_number "catch point"]
-+gdb_continue_to_breakpoint "catch point" ".*// catch point.*"
-diff --git a/gdb/testsuite/gdb.java/jnpe.java b/gdb/testsuite/gdb.java/jnpe.java
-new file mode 100644
-index 0000000..3524830
---- /dev/null
-+++ b/gdb/testsuite/gdb.java/jnpe.java
-@@ -0,0 +1,38 @@
-+// Test next-over-NPE.
++mi_gdb_test "-var-update *" "\\^done,changelist=.*" "-var-update *"
+Index: gdb-7.2.90.20110703/gdb/testsuite/gdb.multi/watchpoint-multi.c
+===================================================================
+--- /dev/null 1970-01-01 00:00:00.000000000 +0000
++++ gdb-7.2.90.20110703/gdb/testsuite/gdb.multi/watchpoint-multi.c 2011-07-03 10:33:11.000000000 +0200
+@@ -0,0 +1,59 @@
+/* This testcase is part of GDB, the GNU debugger.
+
-+ Copyright 2009 Free Software Foundation, Inc.
++ Copyright 2010 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
-+ along with this program. If not, see <http://www.gnu.org/licenses/>.
-+ */
++ along with this program. If not, see <http://www.gnu.org/licenses/>. */
++
++#include <pthread.h>
++#include <assert.h>
+
-+public class jnpe
++static volatile int a, b, c;
++
++static void
++marker_exit1 (void)
+{
-+ public static String npe ()
-+ {
-+ return ((Object) null).toString();
-+ }
++ a = 1;
++}
+
-+ public static void main (String[] args)
-+ {
-+ try
-+ {
-+ System.out.println (npe ()); // break here
-+ }
-+ catch (NullPointerException n)
-+ {
-+ System.out.println ("success"); // catch point
-+ }
-+ }
++/* Workaround PR breakpoints/12272 by two different breakpoint locations. */
++static void
++marker_exit2 (void)
++{
++ a = 1;
++}
++
++static void *
++start (void *arg)
++{
++ b = 2;
++ c = 3;
++
++ return NULL;
++}
++
++int
++main (void)
++{
++ pthread_t thread;
++ int i;
++
++ i = pthread_create (&thread, NULL, start, NULL);
++ assert (i == 0);
++ i = pthread_join (thread, NULL);
++ assert (i == 0);
++
++ marker_exit1 ();
++ marker_exit2 ();
++ return 0;
++}
+Index: gdb-7.2.90.20110703/gdb/testsuite/gdb.multi/watchpoint-multi.exp
+===================================================================
+--- /dev/null 1970-01-01 00:00:00.000000000 +0000
++++ gdb-7.2.90.20110703/gdb/testsuite/gdb.multi/watchpoint-multi.exp 2011-07-03 10:33:11.000000000 +0200
+@@ -0,0 +1,113 @@
++# Copyright 2010 Free Software Foundation, Inc.
++
++# This program is free software; you can redistribute it and/or modify
++# it under the terms of the GNU General Public License as published by
++# the Free Software Foundation; either version 3 of the License, or
++# (at your option) any later version.
++#
++# This program is distributed in the hope that it will be useful,
++# but WITHOUT ANY WARRANTY; without even the implied warranty of
++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++# GNU General Public License for more details.
++#
++# You should have received a copy of the GNU General Public License
++# along with this program. If not, see <http://www.gnu.org/licenses/>.
++
++if { [is_remote target] || ![isnative] } then {
++ continue
++}
++
++set testfile "watchpoint-multi"
++
++set executable ${testfile}
++set srcfile ${testfile}.c
++set binfile ${objdir}/${subdir}/${executable}
++
++if { [gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
++ untested ${testfile}.exp
++ return -1
++}
++
++clean_restart $executable
++
++if ![runto_main] {
++ return
++}
++# Never keep/use any non-hw breakpoints to workaround a multi-inferior bug.
++delete_breakpoints
++
++gdb_test "add-inferior" "Added inferior 2"
++gdb_test "inferior 2" "witching to inferior 2 .*"
++gdb_load $binfile
++
++if ![runto_main] {
++ return
++}
++delete_breakpoints
++
++# Simulate non-stop+target-async which also uses breakpoint always-inserted.
++gdb_test_no_output "set breakpoint always-inserted on"
++# displaced-stepping is also needed as other GDB sometimes still removes the
++# breakpoints, even with always-inserted on.
++gdb_test_no_output "set displaced-stepping on"
++
++# Debugging of this testcase:
++#gdb_test_no_output "maintenance set show-debug-regs on"
++#gdb_test_no_output "set debug infrun 1"
++
++# Do not use simple hardware watchpoint ("watch") as its false hit may be
++# unnoticed by GDB if it reads it still has the same value.
++gdb_test "awatch c" "Hardware access \\(read/write\\) watchpoint \[0-9\]+: c"
++# Never keep/use any non-hw breakpoints to workaround a multi-inferior bug.
++# Use `*' to workaround a multi-inferior bug.
++set test "hbreak *marker_exit2"
++gdb_test_multiple $test $test {
++ -re "Hardware assisted breakpoint \[0-9\]+ at .*\r\n$gdb_prompt $" {
++ pass $test
++ }
++ -re "(No hardware breakpoint support in the target\\.|Hardware breakpoints used exceeds limit\\.)\r\n$gdb_prompt $" {
++ pass $test
++ untested ${testfile}.exp
++ return
++ }
++}
++
++gdb_test "inferior 1" "witching to inferior 1 .*"
++
++gdb_test "awatch b" "Hardware access \\(read/write\\) watchpoint \[0-9\]+: b"
++gdb_test "hbreak *marker_exit1" {Hardware assisted breakpoint [0-9]+ at .*}
++
++gdb_test "inferior 2" "witching to inferior 2 .*"
++
++# FAIL would be a hit on watchpoint for `b' - that one is for the other
++# inferior.
++gdb_test "continue" "Hardware access \\(read/write\\) watchpoint \[0-9\]+: c\r\n\r\nOld value = 0\r\nNew value = 3\r\n.*" "catch c"
++
++set test "catch marker_exit2"
++gdb_test_multiple "continue" $test {
++ -re "Breakpoint \[0-9\]+, marker_exit2 .*\r\n$gdb_prompt $" {
++ setup_kfail breakpoints/12312 *-*-*
++ pass $test
++ }
++ -re "Hardware access \\(read/write\\) watchpoint \[0-9\]+: c\r\n\r\nValue = 3\r\n(.* in )?\\*?(__GI_)?__nptl_death_event .*\r\n$gdb_prompt $" {
++ setup_kfail breakpoints/12312 *-*-*
++ fail $test
++ }
++}
++
++gdb_test "inferior 1" "witching to inferior 1 .*"
++
++gdb_test "continue" "Hardware access \\(read/write\\) watchpoint \[0-9\]+: b\r\n\r\nOld value = 0\r\nNew value = 2\r\n.*" "catch b"
++
++set test "catch marker_exit1"
++gdb_test_multiple "continue" $test {
++ -re "Breakpoint \[0-9\]+, marker_exit1 .*\r\n$gdb_prompt $" {
++ setup_kfail breakpoints/12312 *-*-*
++ pass $test
++ }
++ -re "Hardware access \\(read/write\\) watchpoint \[0-9\]+: b\r\n\r\nValue = 2\r\n(.* in )?\\*?(__GI_)?__nptl_death_event .*\r\n$gdb_prompt $" {
++ setup_kfail breakpoints/12312 *-*-*
++ fail $test
++ }
+}
-diff --git a/gdb/testsuite/gdb.opt/array-from-register-func.c b/gdb/testsuite/gdb.opt/array-from-register-func.c
-new file mode 100644
-index 0000000..729f457
---- /dev/null
-+++ b/gdb/testsuite/gdb.opt/array-from-register-func.c
++
+Index: gdb-7.2.90.20110703/gdb/testsuite/gdb.opt/array-from-register-func.c
+===================================================================
+--- /dev/null 1970-01-01 00:00:00.000000000 +0000
++++ gdb-7.2.90.20110703/gdb/testsuite/gdb.opt/array-from-register-func.c 2011-07-03 10:33:11.000000000 +0200
@@ -0,0 +1,22 @@
+/* This file is part of GDB, the GNU debugger.
+
+{
+ return arr[0];
+}
-diff --git a/gdb/testsuite/gdb.opt/array-from-register.c b/gdb/testsuite/gdb.opt/array-from-register.c
-new file mode 100644
-index 0000000..3090e7e
---- /dev/null
-+++ b/gdb/testsuite/gdb.opt/array-from-register.c
+Index: gdb-7.2.90.20110703/gdb/testsuite/gdb.opt/array-from-register.c
+===================================================================
+--- /dev/null 1970-01-01 00:00:00.000000000 +0000
++++ gdb-7.2.90.20110703/gdb/testsuite/gdb.opt/array-from-register.c 2011-07-03 10:33:11.000000000 +0200
@@ -0,0 +1,28 @@
+/* This file is part of GDB, the GNU debugger.
+
+
+ return 0;
+}
-diff --git a/gdb/testsuite/gdb.opt/array-from-register.exp b/gdb/testsuite/gdb.opt/array-from-register.exp
-new file mode 100644
-index 0000000..f2de718
---- /dev/null
-+++ b/gdb/testsuite/gdb.opt/array-from-register.exp
+Index: gdb-7.2.90.20110703/gdb/testsuite/gdb.opt/array-from-register.exp
+===================================================================
+--- /dev/null 1970-01-01 00:00:00.000000000 +0000
++++ gdb-7.2.90.20110703/gdb/testsuite/gdb.opt/array-from-register.exp 2011-07-03 10:33:11.000000000 +0200
@@ -0,0 +1,33 @@
+# Copyright 2009 Free Software Foundation, Inc.
+#
+# Seen regression:
+# Address requested for identifier "arr" which is in register $rdi
+gdb_test "p arr\[0\]" "\\$\[0-9\]+ = 42"
-diff --git a/gdb/testsuite/gdb.opt/fortran-string.exp b/gdb/testsuite/gdb.opt/fortran-string.exp
-new file mode 100644
-index 0000000..f997eec
---- /dev/null
-+++ b/gdb/testsuite/gdb.opt/fortran-string.exp
-@@ -0,0 +1,41 @@
-+# Copyright 2009 Free Software Foundation, Inc.
-+
-+# This program is free software; you can redistribute it and/or modify
-+# it under the terms of the GNU General Public License as published by
-+# the Free Software Foundation; either version 2 of the License, or
-+# (at your option) any later version.
-+#
-+# This program is distributed in the hope that it will be useful,
-+# but WITHOUT ANY WARRANTY; without even the implied warranty of
-+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-+# GNU General Public License for more details.
-+#
-+# You should have received a copy of the GNU General Public License
-+# along with this program; if not, write to the Free Software
-+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-+
-+# This file was written by Jan Kratochvil <jan.kratochvil@redhat.com>.
-+
-+# Test GDB can cope with Fortran strings having their length present in a CPU
-+# register. With -O0 the string length is passed on the stack. To make this
-+# test meaningful the follow assertion should pass. It is not being checked
-+# here as the "_s" symbol is compiler dependent:
-+# (gdb) info address _s
-+# Symbol "_s" is a variable in register XX.
-+
-+set test fortran-string
-+set srcfile ${test}.f90
-+if { [prepare_for_testing ${test}.exp ${test} ${srcfile} {debug f77 additional_flags=-O2}] } {
-+ return -1
-+}
-+
-+if ![runto MAIN__] then {
-+ perror "couldn't run to breakpoint MAIN__"
-+ continue
-+}
-+
-+gdb_breakpoint [gdb_get_line_number "s = s"]
-+gdb_continue_to_breakpoint "s = s"
-+gdb_test "frame" ".*s='foo'.*"
-+gdb_test "ptype s" "type = character\\*3"
-+gdb_test "p s" "\\$\[0-9\]* = 'foo'"
-diff --git a/gdb/testsuite/gdb.opt/fortran-string.f90 b/gdb/testsuite/gdb.opt/fortran-string.f90
-new file mode 100644
-index 0000000..e48d520
---- /dev/null
-+++ b/gdb/testsuite/gdb.opt/fortran-string.f90
-@@ -0,0 +1,28 @@
-+! Copyright 2009 Free Software Foundation, Inc.
-+!
-+! This program is free software; you can redistribute it and/or modify
-+! it under the terms of the GNU General Public License as published by
-+! the Free Software Foundation; either version 2 of the License, or
-+! (at your option) any later version.
-+!
-+! This program is distributed in the hope that it will be useful,
-+! but WITHOUT ANY WARRANTY; without even the implied warranty of
-+! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-+! GNU General Public License for more details.
-+!
-+! You should have received a copy of the GNU General Public License
-+! along with this program; if not, write to the Free Software
-+! Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-+!
-+! Ihis file is the Fortran source file for dynamic.exp.
-+! Original file written by Jakub Jelinek <jakub@redhat.com>.
-+! Modified for the GDB testcase by Jan Kratochvil <jan.kratochvil@redhat.com>.
-+
-+ subroutine f(s)
-+ character*(*) s
-+ s = s
-+ end
-+
-+ program main
-+ call f ('foo')
-+ end
-diff --git a/gdb/testsuite/gdb.pascal/arrays.exp b/gdb/testsuite/gdb.pascal/arrays.exp
-new file mode 100644
-index 0000000..ccc6e1e
---- /dev/null
-+++ b/gdb/testsuite/gdb.pascal/arrays.exp
+Index: gdb-7.2.90.20110703/gdb/testsuite/gdb.pascal/arrays.exp
+===================================================================
+--- /dev/null 1970-01-01 00:00:00.000000000 +0000
++++ gdb-7.2.90.20110703/gdb/testsuite/gdb.pascal/arrays.exp 2011-07-03 10:33:11.000000000 +0200
@@ -0,0 +1,104 @@
+# Copyright 2008, 2009 Free Software Foundation, Inc.
+#
+}
+gdb_test "print DynArrChar" ".* = 'abcdefghijklm'" "Print dynamic array of char"
+
-diff --git a/gdb/testsuite/gdb.pascal/arrays.pas b/gdb/testsuite/gdb.pascal/arrays.pas
-new file mode 100644
-index 0000000..295602d
---- /dev/null
-+++ b/gdb/testsuite/gdb.pascal/arrays.pas
+Index: gdb-7.2.90.20110703/gdb/testsuite/gdb.pascal/arrays.pas
+===================================================================
+--- /dev/null 1970-01-01 00:00:00.000000000 +0000
++++ gdb-7.2.90.20110703/gdb/testsuite/gdb.pascal/arrays.pas 2011-07-03 10:33:11.000000000 +0200
@@ -0,0 +1,82 @@
+{
+ Copyright 2008, 2009 Free Software Foundation, Inc.
+ s := 'test'#0'string';
+ writeln(s); { set breakpoint 2 here }
+end.
-diff --git a/gdb/testsuite/gdb.python/py-cmd.exp b/gdb/testsuite/gdb.python/py-cmd.exp
-index 0f250d2..84e5038 100644
---- a/gdb/testsuite/gdb.python/py-cmd.exp
-+++ b/gdb/testsuite/gdb.python/py-cmd.exp
-@@ -20,24 +20,6 @@ if $tracelevel then {
- strace $tracelevel
- }
-
--# Usage: gdb_py_test_multiple NAME INPUT RESULT {INPUT RESULT}...
--# Run a test named NAME, consisting of multiple lines of input.
--# After each input line INPUT, search for result line RESULT.
--# Succeed if all results are seen; fail otherwise.
--proc gdb_py_test_multiple {name args} {
-- global gdb_prompt
-- foreach {input result} $args {
-- if {[gdb_test_multiple $input "$name - $input" {
-- -re "\[\r\n\]*($result)\[\r\n\]+($gdb_prompt | *>)$" {
-- pass "$name - $input"
-- }
-- }]} {
-- return 1
-- }
-- }
-- return 0
--}
--
- # Start with a fresh gdb.
-
- gdb_exit
-diff --git a/gdb/testsuite/gdb.python/py-frame.exp b/gdb/testsuite/gdb.python/py-frame.exp
-index e1212d3..77f44f5 100644
---- a/gdb/testsuite/gdb.python/py-frame.exp
-+++ b/gdb/testsuite/gdb.python/py-frame.exp
-@@ -89,8 +89,6 @@ gdb_py_test_silent_cmd "python f0 = f1.newer ()" "get first frame" 0
+Index: gdb-7.2.90.20110703/gdb/testsuite/gdb.python/py-frame.exp
+===================================================================
+--- gdb-7.2.90.20110703.orig/gdb/testsuite/gdb.python/py-frame.exp 2011-02-26 15:06:28.000000000 +0100
++++ gdb-7.2.90.20110703/gdb/testsuite/gdb.python/py-frame.exp 2011-07-03 10:33:11.000000000 +0200
+@@ -78,8 +78,6 @@ gdb_test "python print bframe == gdb.new
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.is_valid ()" " = True" "test Frame.is_valid"
gdb_test "python print 'result =', f0.name ()" " = f2" "test Frame.name"
gdb_test "python print 'result =', f0.type () == gdb.NORMAL_FRAME" " = True" "test Frame.type"
-@@ -105,3 +103,5 @@ gdb_test "python print 'result =', f0.read_var ('variable_which_surely_doesnt_ex
+@@ -94,3 +92,5 @@ gdb_test "python print 'result =', f0.re
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 ()" "<gdb.Block object at 0x\[\[:xdigit:\]\]+>" "test Frame.block"
-diff --git a/gdb/testsuite/gdb.python/py-function.exp b/gdb/testsuite/gdb.python/py-function.exp
-index 38c5693..e7f0037 100644
---- a/gdb/testsuite/gdb.python/py-function.exp
-+++ b/gdb/testsuite/gdb.python/py-function.exp
-@@ -20,24 +20,6 @@ if $tracelevel then {
- strace $tracelevel
- }
-
--# Usage: gdb_py_test_multiple NAME INPUT RESULT {INPUT RESULT}...
--# Run a test named NAME, consisting of multiple lines of input.
--# After each input line INPUT, search for result line RESULT.
--# Succeed if all results are seen; fail otherwise.
--proc gdb_py_test_multiple {name args} {
-- global gdb_prompt
-- foreach {input result} $args {
-- if {[gdb_test_multiple $input "$name - $input" {
-- -re "\[\r\n\]*($result)\[\r\n\]+($gdb_prompt | *>)$" {
-- pass "$name - $input"
-- }
-- }]} {
-- return 1
-- }
-- }
-- return 0
--}
--
- # Start with a fresh gdb.
-
- gdb_exit
-diff --git a/gdb/testsuite/gdb.python/py-prettyprint.exp b/gdb/testsuite/gdb.python/py-prettyprint.exp
-index 3b2aadd..03bbf3e 100644
---- a/gdb/testsuite/gdb.python/py-prettyprint.exp
-+++ b/gdb/testsuite/gdb.python/py-prettyprint.exp
-@@ -102,6 +102,8 @@ proc run_lang_tests {lang} {
- gdb_test "print estring" "\"embedded x\\\\201\\\\202\\\\203\\\\204\""
- gdb_test "print c" " = container \"container\" with 2 elements = {$nl *.0. = 23,$nl *.1. = 72$nl}"
-
-+ gdb_test "print nullstr" "RuntimeError: Error reading string from inferior.*"
-+
- gdb_test "print nstype" " = {$nl *.0. = 7,$nl *.1. = 42$nl}"
- gdb_test "continue" "Program exited normally\."
-
-diff --git a/gdb/testsuite/gdb.python/py-value.exp b/gdb/testsuite/gdb.python/py-value.exp
-index a24bc11..e3043bc 100644
---- a/gdb/testsuite/gdb.python/py-value.exp
-+++ b/gdb/testsuite/gdb.python/py-value.exp
-@@ -313,6 +313,15 @@ proc test_value_after_death {} {
+Index: gdb-7.2.90.20110703/gdb/testsuite/gdb.python/py-value.exp
+===================================================================
+--- gdb-7.2.90.20110703.orig/gdb/testsuite/gdb.python/py-value.exp 2011-01-01 16:33:49.000000000 +0100
++++ gdb-7.2.90.20110703/gdb/testsuite/gdb.python/py-value.exp 2011-07-03 10:33:11.000000000 +0200
+@@ -318,6 +318,15 @@ proc test_value_after_death {} {
"print value's type"
}
# Regression test for invalid subscript operations. The bug was that
# the type of the value was not being checked before allowing a
# subscript operation to proceed.
-@@ -437,6 +446,7 @@ if ![runto_main] then {
- test_value_in_inferior
+@@ -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.python/rh634108-solib_address.exp b/gdb/testsuite/gdb.python/rh634108-solib_address.exp
-new file mode 100644
-index 0000000..70319ff
---- /dev/null
-+++ b/gdb/testsuite/gdb.python/rh634108-solib_address.exp
-@@ -0,0 +1,24 @@
-+# Copyright (C) 2008, 2009, 2010 Free Software Foundation, Inc.
-+
-+# This program is free software; you can redistribute it and/or modify
-+# it under the terms of the GNU General Public License as published by
-+# the Free Software Foundation; either version 3 of the License, or
-+# (at your option) any later version.
-+#
-+# This program is distributed in the hope that it will be useful,
-+# but WITHOUT ANY WARRANTY; without even the implied warranty of
-+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-+# GNU General Public License for more details.
-+#
-+# You should have received a copy of the GNU General Public License
-+# along with this program. If not, see <http://www.gnu.org/licenses/>.
-+
-+# https://bugzilla.redhat.com/show_bug.cgi?id=634108
-+
-+gdb_exit
-+gdb_start
-+
-+# Skip all tests if Python scripting is not enabled.
-+if { [skip_python_tests] } { continue }
-+
-+gdb_test "python print gdb.solib_address(-1)" "None" "gdb.solib_address exists"
-diff --git a/gdb/testsuite/gdb.threads/watchpoint-fork-forkoff.c b/gdb/testsuite/gdb.threads/watchpoint-fork-forkoff.c
-new file mode 100644
-index 0000000..4dc308b
---- /dev/null
-+++ b/gdb/testsuite/gdb.threads/watchpoint-fork-forkoff.c
-@@ -0,0 +1,175 @@
+Index: gdb-7.2.90.20110703/gdb/testsuite/gdb.threads/watchpoint-fork-child.c
+===================================================================
+--- /dev/null 1970-01-01 00:00:00.000000000 +0000
++++ gdb-7.2.90.20110703/gdb/testsuite/gdb.threads/watchpoint-fork-child.c 2011-07-03 10:33:11.000000000 +0200
+@@ -0,0 +1,127 @@
+/* Test case for forgotten hw-watchpoints after fork()-off of a process.
+
-+ Copyright 2008, 2009 Free Software Foundation, Inc.
++ Copyright 2008, 2009, 2010 Free Software Foundation, Inc.
+
+ This file is part of GDB.
+
+ Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
-+#include <string.h>
-+#include <errno.h>
-+
-+static void
-+delay (void)
-+{
-+ int i = usleep (1000000 / 100);
-+ assert (i == 0 || errno == EINTR);
-+}
-+
-+#if defined FOLLOW_PARENT
-+
-+static void
-+forkoff (int nr)
-+{
-+ pid_t child, pid_got;
-+ int exit_code = 42 + nr;
-+ int status, i;
-+
-+ child = fork ();
-+ switch (child)
-+ {
-+ case -1:
-+ assert (0);
-+ case 0:
-+ printf ("child%d: %d\n", nr, (int) getpid ());
-+ /* Delay to get both the "child%d" and "parent%d" message printed without
-+ a race breaking expect by its endless wait on `$gdb_prompt$':
-+ Breakpoint 3, breakpoint () at ../../../gdb/testsuite/gdb.threads/watchpoint-fork.c:33
-+ 33 }
-+ (gdb) parent2: 14223 */
-+ i = sleep (1);
-+ assert (i == 0);
-+
-+ /* We must not get caught here (against a forgotten breakpoint). */
-+ var++;
-+ breakpoint ();
-+
-+ _exit (exit_code);
-+ default:
-+ printf ("parent%d: %d\n", nr, (int) child);
-+ /* Delay to get both the "child%d" and "parent%d" message printed, see
-+ above. */
-+ i = sleep (1);
-+ assert (i == 0);
-+
-+ pid_got = wait (&status);
-+ assert (pid_got == child);
-+ assert (WIFEXITED (status));
-+ assert (WEXITSTATUS (status) == exit_code);
-+
-+ /* We must get caught here (against a false watchpoint removal). */
-+ breakpoint ();
-+ }
-+}
++#include <string.h>
++#include <errno.h>
++#include <unistd.h>
++#include <assert.h>
++#include <signal.h>
++#include <stdio.h>
+
-+#elif defined FOLLOW_CHILD
++#include "watchpoint-fork.h"
+
+static volatile int usr1_got;
+
+ usr1_got++;
+}
+
-+static void
++void
+forkoff (int nr)
+{
-+ pid_t child;
-+ int i, loop;
++ pid_t child, save_parent = getpid ();
++ int i;
+ struct sigaction act, oldact;
+#ifdef THREAD
+ void *thread_result;
+ /* We must not get caught here (against a forgotten breakpoint). */
+
+ var++;
-+ breakpoint ();
++ marker ();
+
+#ifdef THREAD
+ /* And neither got caught our thread. */
+
+ /* Let the parent signal us about its success. Be careful of races. */
+
-+ for (loop = 0; loop < 1000; loop++)
++ for (;;)
+ {
+ /* Parent either died (and USR1_GOT is zero) or it succeeded. */
++ if (getppid () != save_parent)
++ break;
+ if (kill (getppid (), 0) != 0)
+ break;
+ /* Parent succeeded? */
+ if (usr1_got)
+ break;
+
-+ delay ();
++#ifdef THREAD
++ i = pthread_yield ();
++ assert (i == 0);
++#endif
+ }
+ assert (usr1_got);
+
+ /* We must get caught here (against a false watchpoint removal). */
+
-+ breakpoint ();
++ marker ();
+ }
+
+ i = sigaction (SIGUSR1, &oldact, NULL);
+ assert (i == 0);
+}
-+
-+#else
-+# error "!FOLLOW_PARENT && !FOLLOW_CHILD"
-+#endif
-diff --git a/gdb/testsuite/gdb.threads/watchpoint-fork-mt.c b/gdb/testsuite/gdb.threads/watchpoint-fork-mt.c
-new file mode 100644
-index 0000000..edacfc0
---- /dev/null
-+++ b/gdb/testsuite/gdb.threads/watchpoint-fork-mt.c
-@@ -0,0 +1,157 @@
+Index: gdb-7.2.90.20110703/gdb/testsuite/gdb.threads/watchpoint-fork-mt.c
+===================================================================
+--- /dev/null 1970-01-01 00:00:00.000000000 +0000
++++ gdb-7.2.90.20110703/gdb/testsuite/gdb.threads/watchpoint-fork-mt.c 2011-07-03 10:33:11.000000000 +0200
+@@ -0,0 +1,174 @@
+/* Test case for forgotten hw-watchpoints after fork()-off of a process.
+
-+ Copyright 2008, 2009 Free Software Foundation, Inc.
++ Copyright 2008, 2009, 2010 Free Software Foundation, Inc.
+
+ This file is part of GDB.
+
+#include <unistd.h>
+#define gettid() syscall (__NR_gettid)
+
++#include "watchpoint-fork.h"
++
+/* Non-atomic `var++' should not hurt as we synchronize the threads by the STEP
+ variable. Hit-comments need to be duplicite there to catch both at-stops
+ and behind-stops, depending on the target. */
+
-+static volatile int var;
++volatile int var;
+
-+static void
-+dummy (void)
++void
++marker (void)
+{
+}
+
+static void
-+breakpoint (void)
++empty (void)
+{
+}
+
-+/* Include here the functions:
-+ static void forkoff (int nr);
-+ static void delay (void); */
-+
-+static pthread_t thread;
-+static volatile int step;
-+#define THREAD
++static void
++mark_exit (void)
++{
++}
+
-+#include "watchpoint-fork-forkoff.c"
++pthread_t thread;
++volatile int step;
+
+static void *
+start (void *arg)
+{
++ int i;
++
+ if (step >= 3)
+ goto step_3;
+
+ while (step != 1)
-+ delay ();
++ {
++ i = pthread_yield ();
++ assert (i == 0);
++ }
+
+ var++; /* validity-thread-B */
-+ dummy (); /* validity-thread-B */
++ empty (); /* validity-thread-B */
+ step = 2;
+ while (step != 3)
+ {
+ if (step == 99)
+ goto step_99;
-+ delay ();
++
++ i = pthread_yield ();
++ assert (i == 0);
+ }
+
+step_3:
+ goto step_5;
+
+ var++; /* after-fork1-B */
-+ dummy (); /* after-fork1-B */
++ empty (); /* after-fork1-B */
+ step = 4;
+ while (step != 5)
+ {
+ if (step == 99)
+ goto step_99;
-+ delay ();
++
++ i = pthread_yield ();
++ assert (i == 0);
+ }
+
+step_5:
+ var++; /* after-fork2-B */
-+ dummy (); /* after-fork2-B */
++ empty (); /* after-fork2-B */
+ return (void *) 5UL;
+
+step_99:
+ /* We must not get caught here (against a forgotten breakpoint). */
+ var++;
-+ breakpoint ();
++ marker ();
+ return (void *) 99UL;
+}
+
+ setbuf (stdout, NULL);
+ printf ("main: %d\n", (int) gettid ());
+
-+ /* General watchpoints validity. */
++ /* General hardware breakpoints and watchpoints validity. */
++ marker ();
+ var++; /* validity-first */
-+ dummy (); /* validity-first */
++ empty (); /* validity-first */
+
+ i = pthread_create (&thread, NULL, start, NULL);
+ assert (i == 0);
+
+ var++; /* validity-thread-A */
-+ dummy (); /* validity-thread-A */
++ empty (); /* validity-thread-A */
+ step = 1;
+ while (step != 2)
-+ delay ();
++ {
++ i = pthread_yield ();
++ assert (i == 0);
++ }
+
+ /* Hardware watchpoints got disarmed here. */
+ forkoff (1);
+
+ var++; /* after-fork1-A */
-+ dummy (); /* after-fork1-A */
++ empty (); /* after-fork1-A */
+ step = 3;
+#ifdef FOLLOW_CHILD
+ /* Spawn new thread as it was deleted in the child of FORK. */
+ assert (i == 0);
+#endif
+ while (step != 4)
-+ delay ();
++ {
++ i = pthread_yield ();
++ assert (i == 0);
++ }
+
+ /* A sanity check for double hardware watchpoints removal. */
+ forkoff (2);
+
+ var++; /* after-fork2-A */
-+ dummy (); /* after-fork2-A */
++ empty (); /* after-fork2-A */
+ step = 5;
+#ifdef FOLLOW_CHILD
+ /* Spawn new thread as it was deleted in the child of FORK. */
+ assert (i == 0);
+ assert (thread_result == (void *) 5UL);
+
++ mark_exit ();
+ return 0;
+}
-diff --git a/gdb/testsuite/gdb.threads/watchpoint-fork.c b/gdb/testsuite/gdb.threads/watchpoint-fork.c
-new file mode 100644
-index 0000000..5f62e7f
---- /dev/null
-+++ b/gdb/testsuite/gdb.threads/watchpoint-fork.c
-@@ -0,0 +1,57 @@
+Index: gdb-7.2.90.20110703/gdb/testsuite/gdb.threads/watchpoint-fork-parent.c
+===================================================================
+--- /dev/null 1970-01-01 00:00:00.000000000 +0000
++++ gdb-7.2.90.20110703/gdb/testsuite/gdb.threads/watchpoint-fork-parent.c 2011-07-03 10:33:11.000000000 +0200
+@@ -0,0 +1,74 @@
++/* Test case for forgotten hw-watchpoints after fork()-off of a process.
++
++ Copyright 2008, 2009, 2010 Free Software Foundation, Inc.
++
++ This file is part of GDB.
++
++ This program is free software; you can redistribute it and/or modify
++ it under the terms of the GNU General Public License as published by
++ the Free Software Foundation; either version 2 of the License, or
++ (at your option) any later version.
++
++ This program is distributed in the hope that it will be useful,
++ but WITHOUT ANY WARRANTY; without even the implied warranty of
++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ GNU General Public License for more details.
++
++ You should have received a copy of the GNU General Public License
++ along with this program; if not, write to the Free Software
++ Foundation, Inc., 59 Temple Place - Suite 330,
++ Boston, MA 02111-1307, USA. */
++
++#include <string.h>
++#include <errno.h>
++#include <sys/types.h>
++#include <unistd.h>
++#include <assert.h>
++#include <stdio.h>
++#include <sys/wait.h>
++
++#include "watchpoint-fork.h"
++
++void
++forkoff (int nr)
++{
++ pid_t child, pid_got;
++ int exit_code = 42 + nr;
++ int status, i;
++
++ child = fork ();
++ switch (child)
++ {
++ case -1:
++ assert (0);
++ case 0:
++ printf ("child%d: %d\n", nr, (int) getpid ());
++ /* Delay to get both the "child%d" and "parent%d" message printed without
++ a race breaking expect by its endless wait on `$gdb_prompt$':
++ Breakpoint 3, marker () at ../../../gdb/testsuite/gdb.threads/watchpoint-fork.c:33
++ 33 }
++ (gdb) parent2: 14223 */
++ i = sleep (1);
++ assert (i == 0);
++
++ /* We must not get caught here (against a forgotten breakpoint). */
++ var++;
++ marker ();
++
++ _exit (exit_code);
++ default:
++ printf ("parent%d: %d\n", nr, (int) child);
++ /* Delay to get both the "child%d" and "parent%d" message printed, see
++ above. */
++ i = sleep (1);
++ assert (i == 0);
++
++ pid_got = wait (&status);
++ assert (pid_got == child);
++ assert (WIFEXITED (status));
++ assert (WEXITSTATUS (status) == exit_code);
++
++ /* We must get caught here (against a false watchpoint removal). */
++ marker ();
++ }
++}
+Index: gdb-7.2.90.20110703/gdb/testsuite/gdb.threads/watchpoint-fork-st.c
+===================================================================
+--- /dev/null 1970-01-01 00:00:00.000000000 +0000
++++ gdb-7.2.90.20110703/gdb/testsuite/gdb.threads/watchpoint-fork-st.c 2011-07-03 10:33:11.000000000 +0200
+@@ -0,0 +1,61 @@
+/* Test case for forgotten hw-watchpoints after fork()-off of a process.
+
-+ Copyright 2008, 2009 Free Software Foundation, Inc.
++ Copyright 2008, 2009, 2010 Free Software Foundation, Inc.
+
+ This file is part of GDB.
+
+#include <stdio.h>
+#include <stdlib.h>
+
-+static volatile int var;
++#include "watchpoint-fork.h"
+
-+static void
-+breakpoint (void)
++volatile int var;
++
++void
++marker (void)
+{
+}
+
-+/* Include here the function:
-+ static void forkoff (int nr); */
-+
-+#include "watchpoint-fork-forkoff.c"
++static void
++mark_exit (void)
++{
++}
+
+int
+main (void)
+ setbuf (stdout, NULL);
+ printf ("main: %d\n", (int) getpid ());
+
-+ /* General watchpoints validity. */
++ /* General hardware breakpoints and watchpoints validity. */
++ marker ();
+ var++;
+ /* Hardware watchpoints got disarmed here. */
+ forkoff (1);
+ forkoff (2);
+ var++;
+
++ mark_exit ();
+ return 0;
+}
-diff --git a/gdb/testsuite/gdb.threads/watchpoint-fork.exp b/gdb/testsuite/gdb.threads/watchpoint-fork.exp
-new file mode 100644
-index 0000000..1dc93ab
---- /dev/null
-+++ b/gdb/testsuite/gdb.threads/watchpoint-fork.exp
-@@ -0,0 +1,130 @@
-+# Copyright 2008, 2009 Free Software Foundation, Inc.
+Index: gdb-7.2.90.20110703/gdb/testsuite/gdb.threads/watchpoint-fork.exp
+===================================================================
+--- /dev/null 1970-01-01 00:00:00.000000000 +0000
++++ gdb-7.2.90.20110703/gdb/testsuite/gdb.threads/watchpoint-fork.exp 2011-07-03 10:33:11.000000000 +0200
+@@ -0,0 +1,149 @@
++# Copyright 2008, 2009, 2010 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# Test case for forgotten hw-watchpoints after fork()-off of a process.
+
+proc test {type symbol} {
-+ global objdir subdir srcdir
++ global objdir subdir srcdir gdb_prompt
+
-+ set test watchpoint-fork
++ set testfile watchpoint-fork
+
+ global pf_prefix
+ set prefix_test $pf_prefix
+ lappend pf_prefix "$type:"
+ set prefix_mt $pf_prefix
+
++ set srcfile_type ${srcdir}/${subdir}/${testfile}-${type}.c
++
++
+ # no threads
+
+ set pf_prefix $prefix_mt
+ lappend pf_prefix "singlethreaded:"
+
-+ set executable ${test}-${type}
-+ if { [gdb_compile ${srcdir}/${subdir}/${test}.c ${objdir}/${subdir}/${executable} executable [list debug additional_flags=-D$symbol]] != "" } {
-+ untested ${test}.exp
-+ return -1
++ set executable ${testfile}-${type}-st
++ set srcfile_main ${srcdir}/${subdir}/${testfile}-st.c
++ if { [gdb_compile "${srcfile_main} ${srcfile_type}" ${objdir}/${subdir}/${executable} executable [list debug additional_flags=-D$symbol]] != "" } {
++ untested ${testfile}.exp
++ return
+ }
+ clean_restart $executable
+
-+ gdb_test "show detach-on-fork" "Whether gdb will detach the child of a fork is on."
-+ gdb_test "set follow-fork-mode $type"
-+ gdb_test "show follow-fork-mode" "Debugger response to a program call of fork or vfork is \"$type\"."
++ gdb_test "show detach-on-fork" "Whether gdb will detach the child of a fork is on\\."
++ gdb_test_no_output "set follow-fork-mode $type"
++ gdb_test "show follow-fork-mode" "Debugger response to a program call of fork or vfork is \"$type\"\\."
+ # Testcase uses it for the `follow-fork-mode child' type.
-+ gdb_test "handle SIGUSR1 nostop noprint pass"
++ gdb_test "handle SIGUSR1 nostop noprint pass" "No\[ \t\]+No\[ \t\]+Yes.*"
+
-+ if { ![runto_main] } then {
-+ gdb_suppress_tests
++ if ![runto_main] {
+ return
+ }
+
-+ # Install the watchpoint only after getting into MAIN - workaround some PPC
-+ # problem.
-+ gdb_test "watch var" "atchpoint 2: var" "Set the watchpoint"
++ gdb_test "watch var" "atchpoint \[0-9\]+: var" "Set the watchpoint"
+
+ # It is never hit but it should not be left over in the fork()ed-off child.
-+ gdb_breakpoint "breakpoint"
++ set hbreak "hbreak"
++ set test "hbreak marker"
++ gdb_test_multiple $test $test {
++ -re "Hardware assisted breakpoint \[0-9\]+ at .*\r\n$gdb_prompt $" {
++ pass $test
++ }
++ -re "(No hardware breakpoint support in the target\\.|Hardware breakpoints used exceeds limit\\.)\r\n$gdb_prompt $" {
++ pass $test
++ set hbreak "break"
++ gdb_test "break marker"
++ }
++ }
++
++ gdb_breakpoint "mark_exit"
+
+ gdb_test "continue" \
-+ "atchpoint 2: var.*Old value = 0.*New value = 1.*forkoff *\\(1\\).*" "watchpoints work"
++ "reakpoint \[0-9\]+, marker.*" "hardware breakpoints work"
+ gdb_test "continue" \
-+ "reakpoint 3, breakpoint.*" "breakpoint after the first fork"
++ "atchpoint \[0-9\]+: var.*Old value = 0.*New value = 1.*forkoff *\\(1\\).*" "watchpoints work"
+ gdb_test "continue" \
-+ "atchpoint 2: var.*Old value = 1.*New value = 2.*forkoff *\\(2\\).*" "watchpoint after the first fork"
++ "reakpoint \[0-9\]+, marker.*" "breakpoint after the first fork"
+ gdb_test "continue" \
-+ "reakpoint 3, breakpoint.*" "breakpoint after the second fork"
++ "atchpoint \[0-9\]+: var.*Old value = 1.*New value = 2.*forkoff *\\(2\\).*" "watchpoint after the first fork"
+ gdb_test "continue" \
-+ "atchpoint 2: var.*Old value = 2.*New value = 3.*return *0;" "watchpoint after the second fork"
-+ gdb_test "continue" "Continuing..*Program exited normally." "finish"
++ "reakpoint \[0-9\]+, marker.*" "breakpoint after the second fork"
++ gdb_test "continue" \
++ "atchpoint \[0-9\]+: var.*Old value = 2.*New value = 3.*mark_exit \\(\\);" "watchpoint after the second fork"
++ gdb_test "continue" "Continuing\\..*\r\nBreakpoint \[0-9\]+, mark_exit .*" "finish"
++
++
++ # threads
++
++ set pf_prefix $prefix_mt
++ lappend pf_prefix "multithreaded:"
++
++ set executable ${testfile}-${type}-mt
++ set srcfile_main ${srcdir}/${subdir}/${testfile}-mt.c
++ if { [gdb_compile_pthreads "${srcfile_main} ${srcfile_type}" ${objdir}/${subdir}/${executable} executable [list debug "additional_flags=-D$symbol -DTHREAD"]] != "" } {
++ untested ${testfile}.exp
++ return
++ }
++ clean_restart $executable
++
++ gdb_test_no_output "set follow-fork-mode $type"
++ # Testcase uses it for the `follow-fork-mode child' type.
++ gdb_test "handle SIGUSR1 nostop noprint pass" "No\[ \t\]+No\[ \t\]+Yes.*"
++
++ if ![runto_main] {
++ return
++ }
++
++ gdb_test "watch var" "atchpoint \[0-9\]+: var" "Set the watchpoint"
++
++ # It should not be left over in the fork()ed-off child.
++ gdb_test "$hbreak marker" {reakpoint [0-9]+.*}
++
++ gdb_breakpoint "mark_exit"
++
++ gdb_test "continue" \
++ "reakpoint \[0-9\]+, marker.*" "hardware breakpoints work"
++ gdb_test "continue" \
++ "atchpoint \[0-9\]+: var.*Old value = 0.*New value = 1.*validity-first.*" "singlethread watchpoints work"
++ gdb_test "continue" \
++ "atchpoint \[0-9\]+: var.*Old value = 1.*New value = 2.*validity-thread-A.*" "multithreaded watchpoints work at A"
++ gdb_test "continue" \
++ "atchpoint \[0-9\]+: var.*Old value = 2.*New value = 3.*validity-thread-B.*" "multithreaded watchpoints work at B"
++ gdb_test "continue" \
++ "reakpoint \[0-9\]+, marker.*" "breakpoint (A) after the first fork"
++ gdb_test "continue" \
++ "atchpoint \[0-9\]+: var.*Old value = 3.*New value = 4.*after-fork1-A.*" "watchpoint A after the first fork"
++ gdb_test "continue" \
++ "atchpoint \[0-9\]+: var.*Old value = 4.*New value = 5.*after-fork1-B.*" "watchpoint B after the first fork"
++ gdb_test "continue" \
++ "reakpoint \[0-9\]+, marker.*" "breakpoint (A) after the second fork"
++ gdb_test "continue" \
++ "atchpoint \[0-9\]+: var.*Old value = 5.*New value = 6.*after-fork2-A.*" "watchpoint A after the second fork"
++ gdb_test "continue" \
++ "atchpoint \[0-9\]+: var.*Old value = 6.*New value = 7.*after-fork2-B.*" "watchpoint B after the second fork"
++ gdb_test "continue" "Continuing\\..*\r\nBreakpoint \[0-9\]+, mark_exit .*" "finish"
++
++
++ # cleanup
++ set pf_prefix $prefix_test
++}
++
++test parent FOLLOW_PARENT
++
++# Only GNU/Linux is known to support `set follow-fork-mode child'.
++if {[istarget "*-*-linux*"] && ![is_remote target]} {
++ test child FOLLOW_CHILD
++} else {
++ untested "child"
++}
+Index: gdb-7.2.90.20110703/gdb/testsuite/gdb.threads/watchpoint-fork.h
+===================================================================
+--- /dev/null 1970-01-01 00:00:00.000000000 +0000
++++ gdb-7.2.90.20110703/gdb/testsuite/gdb.threads/watchpoint-fork.h 2011-07-03 10:33:11.000000000 +0200
+@@ -0,0 +1,32 @@
++/* Test case for forgotten hw-watchpoints after fork()-off of a process.
++
++ Copyright 2008, 2009, 2010 Free Software Foundation, Inc.
++
++ This file is part of GDB.
++
++ This program is free software; you can redistribute it and/or modify
++ it under the terms of the GNU General Public License as published by
++ the Free Software Foundation; either version 2 of the License, or
++ (at your option) any later version.
++
++ This program is distributed in the hope that it will be useful,
++ but WITHOUT ANY WARRANTY; without even the implied warranty of
++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ GNU General Public License for more details.
++
++ You should have received a copy of the GNU General Public License
++ along with this program; if not, write to the Free Software
++ Foundation, Inc., 59 Temple Place - Suite 330,
++ Boston, MA 02111-1307, USA. */
++
++#ifdef THREAD
++#include <pthread.h>
++
++extern volatile int step;
++extern pthread_t thread;
++#endif /* THREAD */
++
++extern volatile int var;
++
++extern void marker (void);
++extern void forkoff (int nr);
+Index: gdb-7.2.90.20110703/gdb/testsuite/gdb.trace/stap-trace.c
+===================================================================
+--- /dev/null 1970-01-01 00:00:00.000000000 +0000
++++ gdb-7.2.90.20110703/gdb/testsuite/gdb.trace/stap-trace.c 2011-07-03 10:33:11.000000000 +0200
+@@ -0,0 +1,71 @@
++/* This testcase is part of GDB, the GNU debugger.
++
++ Copyright 2011 Free Software Foundation, Inc.
++
++ This program is free software; you can redistribute it and/or modify
++ it under the terms of the GNU General Public License as published by
++ the Free Software Foundation; either version 3 of the License, or
++ (at your option) any later version.
++
++ This program is distributed in the hope that it will be useful,
++ but WITHOUT ANY WARRANTY; without even the implied warranty of
++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ GNU General Public License for more details.
++
++ You should have received a copy of the GNU General Public License
++ along with this program. If not, see <http://www.gnu.org/licenses/>. */
++
++#if USE_PROBES
++
++#define _SDT_HAS_SEMAPHORES
++__extension__ unsigned short teste_user_semaphore __attribute__ ((unused)) __attribute__ ((section (".probes")));
++#define TEST teste_user_semaphore
++
++__extension__ unsigned short teste_two_semaphore __attribute__ ((unused)) __attribute__ ((section (".probes")));
++#define TEST2 teste_two_semaphore
++
++#else
++
++#define TEST 1
++#define TEST2 1
++
++#endif /* USE_PROBES */
++
++#include <sys/sdt.h>
++
++/* We only support SystemTap and only the v3 form. */
++#if _SDT_NOTE_TYPE != 3
++#error "not using SystemTap v3 probes"
++#endif
++
++void
++m1 (int x)
++{
++ if (TEST2)
++ STAP_PROBE1 (teste, two, x);
++}
++
++int
++f (int x)
++{
++ if (TEST)
++ STAP_PROBE1(teste, user, x);
++ return x+5;
++}
++
++void
++nothing (void)
++{
++ int a = 1 + 1;
++ return;
++}
++
++int
++main()
++{
++ f (f (23));
++ m1 (46);
++ nothing (); /* end-here */
++
++ return 0;
++}
+Index: gdb-7.2.90.20110703/gdb/testsuite/gdb.trace/stap-trace.exp
+===================================================================
+--- /dev/null 1970-01-01 00:00:00.000000000 +0000
++++ gdb-7.2.90.20110703/gdb/testsuite/gdb.trace/stap-trace.exp 2011-07-03 10:33:11.000000000 +0200
+@@ -0,0 +1,129 @@
++# Copyright 2011
++# Free Software Foundation, Inc.
++
++# This program is free software; you can redistribute it and/or modify
++# it under the terms of the GNU General Public License as published by
++# the Free Software Foundation; either version 3 of the License, or
++# (at your option) any later version.
++#
++# This program is distributed in the hope that it will be useful,
++# but WITHOUT ANY WARRANTY; without even the implied warranty of
++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++# GNU General Public License for more details.
++#
++# You should have received a copy of the GNU General Public License
++# along with this program. If not, see <http://www.gnu.org/licenses/>.
++
++load_lib "trace-support.exp"
++
++if $tracelevel then {
++ strace $tracelevel
++}
+
++set testfile "stap-trace"
++set srcfile ${testfile}.c
++set executable $testfile
++set binfile $objdir/$subdir/$executable
+
-+ # threads
++set ws "\[\r\n\t \]+"
++set cr "\[\r\n\]+"
+
-+ set pf_prefix $prefix_mt
-+ lappend pf_prefix "multithreaded:"
++# Only x86 and x86_64 targets are supported for now.
++
++if { ![istarget "x86_64-*"] && ![istarget "i?86-*"] } {
++ continue
++}
++
++proc compile_stap_bin {{ arg "" }} {
++ global srcfile
++ global binfile
++ global srcdir
++ global subdir
+
-+ set executable ${test}-mt-${type}
-+ if { [gdb_compile_pthreads ${srcdir}/${subdir}/${test}-mt.c ${objdir}/${subdir}/${executable} executable [list debug additional_flags=-D$symbol]] != "" } {
-+ untested ${test}.exp
++ if { $arg != "" } {
++ set arg "additional_flags=$arg"
++ }
++
++ if { [gdb_compile "$srcdir/$subdir/$srcfile" $binfile \
++ executable [concat $arg debug nowarnings]] != "" } {
++ untested "Could not compile ${srcfile}"
+ return -1
+ }
-+ clean_restart $executable
++}
+
-+ gdb_test "set follow-fork-mode $type"
-+ # Testcase uses it for the `follow-fork-mode child' type.
-+ gdb_test "handle SIGUSR1 nostop noprint pass"
++proc prepare_for_trace_test {} {
++ global executable
+
-+ if { ![runto_main] } then {
-+ gdb_suppress_tests
-+ return
++ clean_restart $executable
++
++ if { ![runto_main] } {
++ perror "Could not run to `main'."
++ continue
+ }
+
-+ # Install the watchpoint only after getting into MAIN - workaround some PPC
-+ # problem.
-+ gdb_test "watch var" "atchpoint 2: var" "Set the watchpoint"
++ gdb_breakpoint [gdb_get_line_number "end-here"]
++}
+
-+ # It is never hit but it should not be left over in the fork()ed-off child.
-+ gdb_breakpoint "breakpoint"
++proc run_trace_experiment { test_probe msg } {
++ global gdb_prompt
++
++ set test "collect $msg: start trace experiment"
++ gdb_test_multiple "tstart" "$test" {
++ -re "^tstart\r\n$gdb_prompt $" {
++ pass "$test"
++ }
++ }
+
+ gdb_test "continue" \
-+ "atchpoint 2: var.*Old value = 0.*New value = 1.*validity-first.*" "singlethread watchpoints work"
-+ gdb_test "continue" \
-+ "atchpoint 2: var.*Old value = 1.*New value = 2.*validity-thread-A.*" "multithreaded watchpoints work at A"
-+ gdb_test "continue" \
-+ "atchpoint 2: var.*Old value = 2.*New value = 3.*validity-thread-B.*" "multithreaded watchpoints work at B"
-+ gdb_test "continue" \
-+ "reakpoint 3, breakpoint.*" "breakpoint (A) after the first fork"
-+ gdb_test "continue" \
-+ "atchpoint 2: var.*Old value = 3.*New value = 4.*after-fork1-A.*" "watchpoint A after the first fork"
-+ gdb_test "continue" \
-+ "atchpoint 2: var.*Old value = 4.*New value = 5.*after-fork1-B.*" "watchpoint B after the first fork"
-+ gdb_test "continue" \
-+ "reakpoint 3, breakpoint.*" "breakpoint (A) after the second fork"
-+ gdb_test "continue" \
-+ "atchpoint 2: var.*Old value = 5.*New value = 6.*after-fork2-A.*" "watchpoint A after the second fork"
-+ gdb_test "continue" \
-+ "atchpoint 2: var.*Old value = 6.*New value = 7.*after-fork2-B.*" "watchpoint B after the second fork"
-+ gdb_test "continue" "Continuing..*Program exited normally." "finish"
++ "Continuing.*Breakpoint \[0-9\]+.*" \
++ "collect $msg: run trace experiment"
++ gdb_test "tstop" \
++ "\[\r\n\]+" \
++ "collect $msg: stop trace experiment"
++ gdb_test "tfind start" \
++ "#0 .*" \
++ "collect $msg: tfind test frame"
++}
++
++proc gdb_collect_probe_arg { msg probe val_arg0 } {
++ global gdb_prompt
++ global cr
+
++ prepare_for_trace_test
+
-+ # cleanup
++ gdb_test "trace $probe" \
++ "Tracepoint \[0-9\]+ at .*" \
++ "collect $msg: set tracepoint"
++ gdb_trace_setactions "collect $msg: define actions" \
++ "" \
++ "collect \$_probe_arg0" "^$"
+
-+ set pf_prefix $prefix_test
++ # Begin the test.
++ run_trace_experiment $msg $probe
++
++ gdb_test "print \$_probe_arg0" \
++ "\\$\[0-9\]+ = $val_arg0$cr" \
++ "collect $msg: collected probe arg0"
+}
+
-+test parent FOLLOW_PARENT
++compile_stap_bin ""
+
-+# Only GNU/Linux is known to support `set follow-fork-mode child'.
-+if {[istarget "*-*-linux*"]} {
-+ test child FOLLOW_CHILD
++clean_restart $executable
++if { ![runto_main] } {
++ perror "Could not run to `main'."
++ continue
+}
-diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
-index 20e2fb7..b27d25c 100644
---- a/gdb/testsuite/lib/gdb.exp
-+++ b/gdb/testsuite/lib/gdb.exp
-@@ -27,6 +27,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 9691bc1..13ea8b5 100644
---- a/gdb/testsuite/lib/pascal.exp
-+++ b/gdb/testsuite/lib/pascal.exp
++
++if { ![gdb_target_supports_trace] } {
++ # Test cannot run on this target.
++ return 1;
++}
++
++gdb_collect_probe_arg "probe args without semaphore" "probe:user" "23"
++gdb_exit
++
++compile_stap_bin "-DUSE_PROBES"
++gdb_collect_probe_arg "probe args with semaphore" "probe:two" "46"
++
++# Finished!
++gdb_test "tfind none" ".*" ""
+Index: gdb-7.2.90.20110703/gdb/testsuite/lib/gdb.exp
+===================================================================
+--- gdb-7.2.90.20110703.orig/gdb/testsuite/lib/gdb.exp 2011-03-25 14:08:11.000000000 +0100
++++ gdb-7.2.90.20110703/gdb/testsuite/lib/gdb.exp 2011-07-03 10:33:11.000000000 +0200
+@@ -141,6 +141,11 @@ proc gdb_unload {} {
+ send_gdb "y\n"
+ exp_continue
+ }
++ -re "A program is being debugged already..*Are you sure you want to change the file.*y or n. $"\
++ { send_gdb "y\n"
++ verbose "\t\tUnloading symbols for program being debugged"
++ exp_continue
++ }
+ -re "Discard symbol table from .*y or n.*$" {
+ send_gdb "y\n"
+ exp_continue
+Index: gdb-7.2.90.20110703/gdb/testsuite/lib/pascal.exp
+===================================================================
+--- gdb-7.2.90.20110703.orig/gdb/testsuite/lib/pascal.exp 2011-01-01 16:33:52.000000000 +0100
++++ gdb-7.2.90.20110703/gdb/testsuite/lib/pascal.exp 2011-07-03 10:33:11.000000000 +0200
@@ -37,6 +37,9 @@ proc pascal_init {} {
global pascal_compiler_is_fpc
global gpc_compiler
}
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/thread.c b/gdb/thread.c
-index 0b291ba..ae3e4ff 100644
---- a/gdb/thread.c
-+++ b/gdb/thread.c
-@@ -90,6 +90,16 @@ delete_step_resume_breakpoint (struct thread_info *tp)
- }
- }
+Index: gdb-7.2.90.20110703/gdb/thread.c
+===================================================================
+--- gdb-7.2.90.20110703.orig/gdb/thread.c 2011-04-19 17:24:49.000000000 +0200
++++ gdb-7.2.90.20110703/gdb/thread.c 2011-07-03 10:33:11.000000000 +0200
+@@ -1438,7 +1438,8 @@ update_thread_list (void)
+ no thread is selected, or no threads exist. */
-+void
-+delete_exception_resume_breakpoint (struct thread_info *tp)
+ static struct value *
+-thread_id_make_value (struct gdbarch *gdbarch, struct internalvar *var)
++thread_id_make_value (struct gdbarch *gdbarch, struct internalvar *var,
++ void *ignore)
+ {
+ struct thread_info *tp = find_thread_ptid (inferior_ptid);
+
+@@ -1449,6 +1450,15 @@ thread_id_make_value (struct gdbarch *gd
+ /* Commands with a prefix of `thread'. */
+ struct cmd_list_element *thread_cmd_list = NULL;
+
++/* Implementation of `thread' variable. */
++
++static struct internalvar_funcs thread_funcs =
+{
-+ if (tp && tp->exception_resume_breakpoint)
-+ {
-+ delete_breakpoint (tp->exception_resume_breakpoint);
-+ tp->exception_resume_breakpoint = NULL;
-+ }
-+}
++ thread_id_make_value,
++ NULL,
++ NULL
++};
+
- static void
- clear_thread_inferior_resources (struct thread_info *tp)
+ void
+ _initialize_thread (void)
+ {
+@@ -1494,5 +1504,5 @@ Show printing of thread events (such as
+ show_print_thread_events,
+ &setprintlist, &showprintlist);
+
+- create_internalvar_type_lazy ("_thread", thread_id_make_value);
++ create_internalvar_type_lazy ("_thread", &thread_funcs, NULL);
+ }
+Index: gdb-7.2.90.20110703/gdb/top.c
+===================================================================
+--- gdb-7.2.90.20110703.orig/gdb/top.c 2011-03-12 23:59:24.000000000 +0100
++++ gdb-7.2.90.20110703/gdb/top.c 2011-07-03 10:33:11.000000000 +0200
+@@ -343,6 +343,9 @@ void
+ prepare_execute_command (void)
{
-@@ -103,6 +113,12 @@ clear_thread_inferior_resources (struct thread_info *tp)
- tp->step_resume_breakpoint = NULL;
+ free_all_values ();
++#if 0
++ free_all_types ();
++#endif
+
+ /* With multiple threads running while the one we're examining is
+ stopped, the dcache can get stale without us being able to detect
+Index: gdb-7.2.90.20110703/gdb/tracepoint.c
+===================================================================
+--- gdb-7.2.90.20110703.orig/gdb/tracepoint.c 2011-07-02 21:33:10.000000000 +0200
++++ gdb-7.2.90.20110703/gdb/tracepoint.c 2011-07-03 10:33:11.000000000 +0200
+@@ -1603,6 +1603,8 @@ start_tracing (void)
+
+ for (ix = 0; VEC_iterate (breakpoint_p, tp_vec, ix, t); ix++)
+ {
++ struct bp_location *loc;
++
+ if ((t->type == bp_fast_tracepoint
+ ? !may_insert_fast_tracepoints
+ : !may_insert_tracepoints))
+@@ -1611,6 +1613,9 @@ start_tracing (void)
+ t->number_on_target = 0;
+ target_download_tracepoint (t);
+ t->number_on_target = t->number;
++
++ for (loc = t->loc; loc; loc = loc->next)
++ modify_semaphore (loc, 1);
}
+ VEC_free (breakpoint_p, tp_vec);
-+ if (tp->exception_resume_breakpoint)
+@@ -1672,7 +1677,28 @@ trace_stop_command (char *args, int from
+ void
+ stop_tracing (void)
+ {
++ VEC(breakpoint_p) *tp_vec = NULL;
++ int ix;
++ struct breakpoint *t;
++
+ target_trace_stop ();
++
++ tp_vec = all_tracepoints ();
++ for (ix = 0; VEC_iterate (breakpoint_p, tp_vec, ix, t); ix++)
+ {
-+ tp->exception_resume_breakpoint->disposition = disp_del_at_next_stop;
-+ tp->exception_resume_breakpoint = NULL;
++ struct bp_location *loc;
++
++ if ((t->type == bp_fast_tracepoint
++ ? !may_insert_fast_tracepoints
++ : !may_insert_tracepoints))
++ continue;
++
++ for (loc = t->loc; loc; loc = loc->next)
++ modify_semaphore (loc, 0);
+ }
+
- bpstat_clear (&tp->stop_bpstat);
++ VEC_free (breakpoint_p, tp_vec);
++
+ /* Should change in response to reply? */
+ current_trace_status ()->running = 0;
+ }
+@@ -4515,7 +4541,8 @@ info_static_tracepoint_markers_command (
+ available. */
- discard_all_intermediate_continuations_thread (tp);
-diff --git a/gdb/top.c b/gdb/top.c
-index b29e68d..8edac70 100644
---- a/gdb/top.c
-+++ b/gdb/top.c
-@@ -337,6 +337,7 @@ void
- prepare_execute_command (void)
+ static struct value *
+-sdata_make_value (struct gdbarch *gdbarch, struct internalvar *var)
++sdata_make_value (struct gdbarch *gdbarch, struct internalvar *var,
++ void *ignore)
{
- free_all_values ();
-+ free_all_types ();
+ LONGEST size;
+ gdb_byte *buf;
+@@ -4694,6 +4721,15 @@ traceframe_available_memory (VEC(mem_ran
+ return 0;
+ }
- /* With multiple threads running while the one we're examining is stopped,
- the dcache can get stale without us being able to detect it.
-diff --git a/gdb/typeprint.c b/gdb/typeprint.c
-index ce9f551..5f9d739 100644
---- a/gdb/typeprint.c
-+++ b/gdb/typeprint.c
++/* Implementation of `sdata' variable. */
++
++static const struct internalvar_funcs sdata_funcs =
++{
++ sdata_make_value,
++ NULL,
++ NULL
++};
++
+ /* module initialization */
+ void
+ _initialize_tracepoint (void)
+@@ -4704,7 +4740,7 @@ _initialize_tracepoint (void)
+ value with a void typed value, and when we get here, gdbarch
+ isn't initialized yet. At this point, we're quite sure there
+ isn't another convenience variable of the same name. */
+- create_internalvar_type_lazy ("_sdata", sdata_make_value);
++ create_internalvar_type_lazy ("_sdata", &sdata_funcs, NULL);
+
+ traceframe_number = -1;
+ tracepoint_number = -1;
+Index: gdb-7.2.90.20110703/gdb/typeprint.c
+===================================================================
+--- gdb-7.2.90.20110703.orig/gdb/typeprint.c 2011-01-11 22:53:25.000000000 +0100
++++ gdb-7.2.90.20110703/gdb/typeprint.c 2011-07-03 10:33:11.000000000 +0200
@@ -36,6 +36,7 @@
#include "gdb_string.h"
#include "exceptions.h"
}
static void
-diff --git a/gdb/valarith.c b/gdb/valarith.c
-index 0c40905..a781636 100644
---- a/gdb/valarith.c
-+++ b/gdb/valarith.c
-@@ -161,12 +161,26 @@ value_subscript (struct value *array, LONGEST index)
-
- get_discrete_bounds (range_type, &lowerbound, &upperbound);
- if (VALUE_LVAL (array) != lval_memory)
-- return value_subscripted_rvalue (array, index, lowerbound);
-+ {
-+ if (index >= lowerbound && index <= upperbound)
-+ {
-+ CORE_ADDR element_size = TYPE_LENGTH (TYPE_TARGET_TYPE (tarray));
-+ CORE_ADDR offset = (index - lowerbound) * element_size;
-+
-+ return value_subscripted_rvalue (array, offset);
-+ }
-+ error (_("array or string index out of range"));
-+ }
-
- if (c_style == 0)
- {
- if (index >= lowerbound && index <= upperbound)
-- return value_subscripted_rvalue (array, index, lowerbound);
-+ {
-+ CORE_ADDR element_size = TYPE_LENGTH (TYPE_TARGET_TYPE (tarray));
-+ CORE_ADDR offset = (index - lowerbound) * element_size;
-+
-+ return value_subscripted_rvalue (array, offset);
-+ }
- /* Emit warning unless we have an array of unknown size.
- An array of unknown size has lowerbound 0 and upperbound -1. */
- if (upperbound > -1)
-@@ -185,34 +199,37 @@ value_subscript (struct value *array, LONGEST index)
- error (_("not an array or string"));
+Index: gdb-7.2.90.20110703/gdb/utils.c
+===================================================================
+--- gdb-7.2.90.20110703.orig/gdb/utils.c 2011-05-17 23:26:28.000000000 +0200
++++ gdb-7.2.90.20110703/gdb/utils.c 2011-07-03 10:33:11.000000000 +0200
+@@ -2243,6 +2243,36 @@ set_batch_flag_and_make_cleanup_restore_
+ return back_to;
}
--/* Return the value of EXPR[IDX], expr an aggregate rvalue
-- (eg, a vector register). This routine used to promote floats
-- to doubles, but no longer does. */
-+/* Return the value of *((void *) ARRAY + ELEMENT), ARRAY an aggregate rvalue
-+ (eg, a vector register). This routine used to promote floats to doubles,
-+ but no longer does. OFFSET is zero-based with 0 for the lowermost existing
-+ element, it must be expressed in bytes (therefore multiplied by
-+ check_typedef (TYPE_TARGET_TYPE (array_type)). */
++/* Helper for make_cleanup_restore_page_info. */
++
++static void
++do_restore_selected_frame_cleanup (void *arg)
++{
++ struct frame_id *frame_idp = arg;
++
++ select_frame (frame_find_by_id (*frame_idp));
++
++ xfree (frame_idp);
++}
++
++/* Provide cleanup for restoring currently selected frame. Use frame_id for
++ the case the current frame becomes stale in the meantime. */
++
++struct cleanup *
++make_cleanup_restore_selected_frame (void)
++{
++ struct frame_id *frame_idp;
++
++ /* get_selected_frame->get_current_frame would error otherwise. */
++ if (!has_stack_frames ())
++ return make_cleanup (null_cleanup, NULL);
++
++ frame_idp = xmalloc (sizeof (*frame_idp));
++ *frame_idp = get_frame_id (get_selected_frame (NULL));
++
++ return make_cleanup (do_restore_selected_frame_cleanup, frame_idp);
++}
++
+ /* Set the screen size based on LINES_PER_PAGE and CHARS_PER_LINE. */
- struct value *
--value_subscripted_rvalue (struct value *array, LONGEST index, int lowerbound)
-+value_subscripted_rvalue (struct value *array, CORE_ADDR offset)
- {
+ static void
+Index: gdb-7.2.90.20110703/gdb/valarith.c
+===================================================================
+--- gdb-7.2.90.20110703.orig/gdb/valarith.c 2011-02-18 20:10:46.000000000 +0100
++++ gdb-7.2.90.20110703/gdb/valarith.c 2011-07-03 10:33:11.000000000 +0200
+@@ -198,7 +198,10 @@ value_subscripted_rvalue (struct value *
struct type *array_type = check_typedef (value_type (array));
struct type *elt_type = check_typedef (TYPE_TARGET_TYPE (array_type));
-- unsigned int elt_size = TYPE_LENGTH (elt_type);
+ unsigned int elt_size = TYPE_LENGTH (elt_type);
- unsigned int elt_offs = elt_size * longest_to_int (index - lowerbound);
++ unsigned int elt_stride
++ = (TYPE_BYTE_STRIDE (TYPE_INDEX_TYPE (array_type)) == 0
++ ? elt_size : TYPE_BYTE_STRIDE (TYPE_INDEX_TYPE (array_type)));
++ unsigned int elt_offs = elt_stride * longest_to_int (index - lowerbound);
struct value *v;
-- if (index < lowerbound || (!TYPE_ARRAY_UPPER_BOUND_IS_UNDEFINED (array_type)
-- && elt_offs >= TYPE_LENGTH (array_type)))
-- error (_("no such vector element"));
-+ /* Do not check TYPE_LENGTH (array_type) as we may have been given the
-+ innermost dimension of a multi-dimensional Fortran array where its length
-+ is shorter than the possibly accessed element offset. */
-
- v = allocate_value (elt_type);
- if (VALUE_LVAL (array) == lval_memory && value_lazy (array))
- set_value_lazy (v, 1);
- else
-- memcpy (value_contents_writeable (v),
-- value_contents (array) + elt_offs, elt_size);
-+ {
-+ unsigned int elt_size = TYPE_LENGTH (elt_type);
-+ memcpy (value_contents_writeable (v),
-+ value_contents (array) + offset, elt_size);
-+ }
-
- set_value_component_location (v, array);
- VALUE_REGNUM (v) = VALUE_REGNUM (array);
- VALUE_FRAME_ID (v) = VALUE_FRAME_ID (array);
-- set_value_offset (v, value_offset (array) + elt_offs);
-+ set_value_offset (v, value_offset (array) + offset);
- return v;
- }
-
-@@ -292,6 +309,10 @@ int
+ if (index < lowerbound || (!TYPE_ARRAY_UPPER_BOUND_IS_UNDEFINED (array_type)
+@@ -298,6 +301,10 @@ int
binop_user_defined_p (enum exp_opcode op,
struct value *arg1, struct value *arg2)
{
return binop_types_user_defined_p (op, value_type (arg1), value_type (arg2));
}
-diff --git a/gdb/valops.c b/gdb/valops.c
-index 7fbad10..8e32405 100644
---- a/gdb/valops.c
-+++ b/gdb/valops.c
-@@ -38,6 +38,7 @@
- #include "cp-support.h"
- #include "dfp.h"
- #include "user-regs.h"
+Index: gdb-7.2.90.20110703/gdb/valops.c
+===================================================================
+--- gdb-7.2.90.20110703.orig/gdb/valops.c 2011-03-29 19:04:30.000000000 +0200
++++ gdb-7.2.90.20110703/gdb/valops.c 2011-07-03 10:33:11.000000000 +0200
+@@ -47,6 +47,7 @@
+ #include "objfiles.h"
+ #include "symtab.h"
+ #include "exceptions.h"
+#include "dwarf2loc.h"
- #include <errno.h>
- #include "gdb_string.h"
-@@ -858,6 +859,65 @@ value_one (struct type *type, enum lval_type lv)
+ extern int overload_debug;
+ /* Local functions. */
+@@ -915,6 +916,65 @@ value_one (struct type *type, enum lval_
return val;
}
/* Helper function for value_at, value_at_lazy, and value_at_lazy_stack. */
static struct value *
-@@ -956,15 +1016,21 @@ value_fetch_lazy (struct value *val)
+@@ -1011,12 +1071,20 @@ value_fetch_lazy (struct value *val)
}
else if (VALUE_LVAL (val) == lval_memory)
{
+ CORE_ADDR addr = value_raw_address (val);
- if (length)
+- read_value_memory (val, 0, value_stack (val),
+- addr, value_contents_all_raw (val), length);
+ if (object_address_get_data (value_type (val), &addr))
- {
-- if (value_stack (val))
-- read_stack (addr, value_contents_all_raw (val), length);
-- else
-- read_memory (addr, value_contents_all_raw (val), length);
++ {
+ struct type *type = value_enclosing_type (val);
+ int length = TYPE_LENGTH (check_typedef (type));
+
+ if (length)
+ {
+ addr += value_offset (val);
-+ if (value_stack (val))
-+ read_stack (addr, value_contents_all_raw (val), length);
-+ else
-+ read_memory (addr, value_contents_all_raw (val), length);
++ read_value_memory (val, 0, value_stack (val),
++ addr, value_contents_all_raw (val), length);
+ }
- }
++ }
}
else if (VALUE_LVAL (val) == lval_register)
-@@ -1374,7 +1440,18 @@ address_of_variable (struct symbol *var, struct block *b)
+ {
+@@ -1528,7 +1596,18 @@ address_of_variable (struct symbol *var,
if ((VALUE_LVAL (val) == lval_memory && value_lazy (val))
|| TYPE_CODE (type) == TYPE_CODE_FUNC)
{
return value_from_pointer (lookup_pointer_type (type), addr);
}
-@@ -1481,6 +1558,7 @@ struct value *
+@@ -1635,6 +1714,7 @@ struct value *
value_coerce_array (struct value *arg1)
{
struct type *type = check_typedef (value_type (arg1));
/* 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
-@@ -1490,8 +1568,12 @@ value_coerce_array (struct value *arg1)
+@@ -1644,8 +1724,12 @@ value_coerce_array (struct value *arg1)
if (VALUE_LVAL (arg1) != lval_memory)
error (_("Attempt to take address of value not located in memory."));
}
/* 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 ad6268e..fb0ef7a 100644
---- a/gdb/valprint.c
-+++ b/gdb/valprint.c
+@@ -3695,6 +3779,8 @@ value_slice (struct value *array, int lo
+ TYPE_TARGET_TYPE (range_type),
+ lowbound,
+ lowbound + length - 1);
++ TYPE_BYTE_STRIDE (slice_range_type) = TYPE_BYTE_STRIDE (range_type);
++
+ if (TYPE_CODE (array_type) == TYPE_CODE_BITSTRING)
+ {
+ int i;
+Index: gdb-7.2.90.20110703/gdb/valprint.c
+===================================================================
+--- gdb-7.2.90.20110703.orig/gdb/valprint.c 2011-04-29 21:23:05.000000000 +0200
++++ gdb-7.2.90.20110703/gdb/valprint.c 2011-07-03 10:33:11.000000000 +0200
@@ -36,6 +36,7 @@
#include "dfp.h"
#include "python/python.h"
#include <errno.h>
-@@ -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:
case TYPE_CODE_BITSTRING:
return 0;
default:
-@@ -1142,6 +1142,7 @@ val_print_array_elements (struct type *type, const gdb_byte *valaddr,
+@@ -1193,6 +1193,7 @@ val_print_array_elements (struct type *t
{
unsigned int things_printed = 0;
unsigned len;
struct type *elttype, *index_type;
unsigned eltlen;
/* Position of the array element we are examining to see
-@@ -1150,9 +1151,33 @@ val_print_array_elements (struct type *type, const gdb_byte *valaddr,
+@@ -1201,9 +1202,33 @@ val_print_array_elements (struct type *t
/* Number of repetitions we have detected so far. */
unsigned int reps;
- LONGEST low_bound_index = 0;
+ LONGEST low_bound, high_bound;
+ struct cleanup *back_to;
+ CORE_ADDR saved_address = address;
+
+ eltlen = TYPE_ARRAY_BYTE_STRIDE_VALUE (type);
index_type = TYPE_INDEX_TYPE (type);
- /* Compute the number of elements in the array. On most arrays,
-@@ -1160,9 +1185,6 @@ val_print_array_elements (struct type *type, const gdb_byte *valaddr,
- is simply the size of the array divided by the size of the elements.
- But for arrays of elements whose size is zero, we need to look at
- the bounds. */
-- if (eltlen != 0)
-- len = TYPE_LENGTH (type) / eltlen;
-- else
- {
- LONGEST low, hi;
-
-@@ -1236,6 +1258,8 @@ val_print_array_elements (struct type *type, const gdb_byte *valaddr,
+ if (get_array_bounds (type, &low_bound, &high_bound))
+@@ -1290,6 +1315,8 @@ val_print_array_elements (struct type *t
{
fprintf_filtered (stream, "...");
}
}
/* Read LEN bytes of target memory at address MEMADDR, placing the
-diff --git a/gdb/value.c b/gdb/value.c
-index d552402..b10269c 100644
---- a/gdb/value.c
-+++ b/gdb/value.c
-@@ -39,6 +39,7 @@
- #include "objfiles.h"
- #include "valprint.h"
- #include "cli/cli-decode.h"
+Index: gdb-7.2.90.20110703/gdb/value.c
+===================================================================
+--- gdb-7.2.90.20110703.orig/gdb/value.c 2011-02-27 21:57:15.000000000 +0100
++++ gdb-7.2.90.20110703/gdb/value.c 2011-07-03 10:33:11.000000000 +0200
+@@ -43,6 +43,7 @@
+ #include "python/python.h"
+ #include <ctype.h>
+ #include "tracepoint.h"
+#include "observer.h"
- #include "python/python.h"
+ /* Prototypes for exported functions. */
-@@ -828,12 +829,15 @@ void
+@@ -1339,12 +1340,15 @@ void
set_value_component_location (struct value *component,
const struct value *whole)
{
if (whole->lval == lval_computed)
{
struct lval_funcs *funcs = whole->location.computed.funcs;
-@@ -841,6 +845,12 @@ set_value_component_location (struct value *component,
+@@ -1352,6 +1356,12 @@ set_value_component_location (struct val
if (funcs->copy_closure)
component->location.computed.closure = funcs->copy_closure (whole);
}
}
\f
-@@ -973,6 +983,29 @@ show_values (char *num_exp, int from_tty)
+@@ -1485,6 +1495,31 @@ show_values (char *num_exp, int from_tty
num_exp[1] = '\0';
}
}
+
+ /* Free the unreferenced types above. */
+ free_all_values ();
++#if 0
+ free_all_types ();
++#endif
+}
\f
/* Internal variables. These are variables within the debugger
that hold values assigned by debugger commands.
-@@ -1451,6 +1484,40 @@ call_internal_function (struct gdbarch *gdbarch,
+@@ -1530,7 +1565,14 @@ struct internalvar
+ struct value *value;
+
+ /* The call-back routine used with INTERNALVAR_MAKE_VALUE. */
+- internalvar_make_value make_value;
++ struct
++ {
++ /* The functions to call. */
++ const struct internalvar_funcs *functions;
++
++ /* The function's user-data. */
++ void *data;
++ } make_value;
+
+ /* The internal function used with INTERNALVAR_FUNCTION. */
+ struct
+@@ -1629,18 +1671,39 @@ create_internalvar (const char *name)
+ /* Create an internal variable with name NAME and register FUN as the
+ function that value_of_internalvar uses to create a value whenever
+ this variable is referenced. NAME should not normally include a
+- dollar sign. */
++ dollar sign. DATA is passed uninterpreted to FUN when it is
++ called. CLEANUP, if not NULL, is called when the internal variable
++ is destroyed. It is passed DATA as its only argument. */
+
+ struct internalvar *
+-create_internalvar_type_lazy (char *name, internalvar_make_value fun)
++create_internalvar_type_lazy (const char *name,
++ const struct internalvar_funcs *funcs,
++ void *data)
+ {
+ struct internalvar *var = create_internalvar (name);
+
+ var->kind = INTERNALVAR_MAKE_VALUE;
+- var->u.make_value = fun;
++ var->u.make_value.functions = funcs;
++ var->u.make_value.data = data;
+ return var;
+ }
+
++/* See documentation in value.h. */
++
++int
++compile_internalvar_to_ax (struct internalvar *var,
++ struct agent_expr *expr,
++ struct axs_value *value)
++{
++ if (var->kind != INTERNALVAR_MAKE_VALUE
++ || var->u.make_value.functions->compile_to_ax == NULL)
++ return 0;
++
++ var->u.make_value.functions->compile_to_ax (var, expr, value,
++ var->u.make_value.data);
++ return 1;
++}
++
+ /* Look up an internal variable with name NAME. NAME should not
+ normally include a dollar sign.
+
+@@ -1713,7 +1776,8 @@ value_of_internalvar (struct gdbarch *gd
+ break;
+
+ case INTERNALVAR_MAKE_VALUE:
+- val = (*var->u.make_value) (gdbarch, var);
++ val = (*var->u.make_value.functions->make_value) (gdbarch, var,
++ var->u.make_value.data);
+ break;
+
+ default:
+@@ -1909,6 +1973,11 @@ clear_internalvar (struct internalvar *v
+ xfree (var->u.string);
+ break;
+
++ case INTERNALVAR_MAKE_VALUE:
++ if (var->u.make_value.functions->destroy != NULL)
++ var->u.make_value.functions->destroy (var->u.make_value.data);
++ break;
++
+ default:
+ break;
+ }
+@@ -1963,6 +2032,38 @@ call_internal_function (struct gdbarch *
return (*ifn->handler) (gdbarch, language, ifn->cookie, argc, argv);
}
++#if 0
+/* Call type_mark_used for any TYPEs referenced from this GDB source file. */
+
+static void
+ case INTERNALVAR_INTEGER:
+ type_mark_used (var->u.integer.type);
+ break;
-+
-+ case INTERNALVAR_POINTER:
-+ type_mark_used (var->u.pointer.type);
-+ break;
+ }
+
+ for (chunk = value_history_chain; chunk != NULL; chunk = chunk->next)
+ type_mark_used (value_type (chunk->values[i]));
+ }
+}
++#endif
+
/* 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
-@@ -1498,11 +1565,10 @@ preserve_one_value (struct value *value, struct objfile *objfile,
+@@ -2010,11 +2111,10 @@ preserve_one_value (struct value *value,
htab_t copied_types)
{
if (TYPE_OBJFILE (value->type) == objfile)
copied_types);
}
-@@ -1517,13 +1583,13 @@ preserve_one_internalvar (struct internalvar *var, struct objfile *objfile,
+@@ -2029,7 +2129,7 @@ preserve_one_internalvar (struct interna
case INTERNALVAR_INTEGER:
if (var->u.integer.type && TYPE_OBJFILE (var->u.integer.type) == objfile)
var->u.integer.type
+ = copy_type_recursive (var->u.integer.type, copied_types);
break;
- case INTERNALVAR_POINTER:
- if (TYPE_OBJFILE (var->u.pointer.type) == objfile)
- var->u.pointer.type
-- = copy_type_recursive (objfile, var->u.pointer.type, copied_types);
-+ = copy_type_recursive (var->u.pointer.type, copied_types);
- break;
-
case INTERNALVAR_VALUE:
-@@ -2387,7 +2453,24 @@ value_from_decfloat (struct type *type, const gdb_byte *dec)
+@@ -2080,14 +2180,22 @@ show_convenience (char *ignore, int from
+ get_user_print_options (&opts);
+ for (var = internalvars; var; var = var->next)
+ {
++ volatile struct gdb_exception e;
++
+ if (!varseen)
+ {
+ varseen = 1;
+ }
+ printf_filtered (("$%s = "), var->name);
+- value_print (value_of_internalvar (gdbarch, var), gdb_stdout,
+- &opts);
+- printf_filtered (("\n"));
++
++ TRY_CATCH (e, RETURN_MASK_ERROR)
++ {
++ value_print (value_of_internalvar (gdbarch, var), gdb_stdout,
++ &opts);
++ printf_filtered (("\n"));
++ }
++ if (e.reason < 0)
++ printf_filtered (_("<error: %s>\n"), e.message);
+ }
+ if (!varseen)
+ printf_unfiltered (_("No debugger convenience variables now defined.\n"
+@@ -3047,7 +3155,24 @@ value_from_history_ref (char *h, char **
struct value *
coerce_ref (struct value *arg)
{
if (TYPE_CODE (value_type_arg_tmp) == TYPE_CODE_REF)
arg = value_at_lazy (TYPE_TARGET_TYPE (value_type_arg_tmp),
-@@ -2485,4 +2568,8 @@ VARIABLE is already initialized."));
+@@ -3145,4 +3270,10 @@ VARIABLE is already initialized."));
add_prefix_cmd ("function", no_class, function_command, _("\
Placeholder command for showing help on convenience functions."),
&functionlist, "function ", 0, &cmdlist);
+
+ make_final_cleanup (value_history_cleanup, NULL);
+
++#if 0
+ observer_attach_mark_used (value_types_mark_used);
++#endif
}
-diff --git a/gdb/value.h b/gdb/value.h
-index 12cbc0a..a508bf6 100644
---- a/gdb/value.h
-+++ b/gdb/value.h
-@@ -372,6 +372,10 @@ extern struct value *value_from_double (struct type *type, DOUBLEST num);
- extern struct value *value_from_decfloat (struct type *type,
+Index: gdb-7.2.90.20110703/gdb/value.h
+===================================================================
+--- gdb-7.2.90.20110703.orig/gdb/value.h 2011-03-04 21:07:22.000000000 +0100
++++ gdb-7.2.90.20110703/gdb/value.h 2011-07-03 10:33:11.000000000 +0200
+@@ -473,6 +473,10 @@ extern struct value *value_from_decfloat
const gdb_byte *decbytes);
+ extern struct value *value_from_history_ref (char *, char **);
+extern const char *object_address_data_not_valid (struct type *type);
+extern struct type *object_address_get_data (struct type *type,
extern struct value *value_at (struct type *type, CORE_ADDR addr);
extern struct value *value_at_lazy (struct type *type, CORE_ADDR addr);
-@@ -729,7 +733,7 @@ extern struct value *value_allocate_space_in_inferior (int);
- extern struct value *value_of_local (const char *name, int complain);
+@@ -697,10 +701,52 @@ extern struct internalvar *lookup_only_i
+
+ extern struct internalvar *create_internalvar (const char *name);
- extern struct value *value_subscripted_rvalue (struct value *array,
-- LONGEST index, int lowerbound);
-+ CORE_ADDR offset);
+-typedef struct value * (*internalvar_make_value) (struct gdbarch *,
+- struct internalvar *);
++/* An internalvar can be dynamically computed by supplying a vector of
++ function pointers to perform various operations. */
++
++struct internalvar_funcs
++{
++ /* Compute the value of the variable. The DATA argument passed to
++ the function is the same argument that was passed to
++ `create_internalvar_type_lazy'. */
++
++ struct value *(*make_value) (struct gdbarch *arch,
++ struct internalvar *var,
++ void *data);
++
++ /* Update the agent expression EXPR with bytecode to compute the
++ value. VALUE is the agent value we are updating. The DATA
++ argument passed to this function is the same argument that was
++ passed to `create_internalvar_type_lazy'. If this pointer is
++ NULL, then the internalvar cannot be compiled to an agent
++ expression. */
++
++ void (*compile_to_ax) (struct internalvar *var,
++ struct agent_expr *expr,
++ struct axs_value *value,
++ void *data);
++
++ /* If non-NULL, this is called to destroy DATA. The DATA argument
++ passed to this function is the same argument that was passed to
++ `create_internalvar_type_lazy'. */
++
++ void (*destroy) (void *data);
++};
++
+ extern struct internalvar *
+- create_internalvar_type_lazy (char *name, internalvar_make_value fun);
++create_internalvar_type_lazy (const char *name,
++ const struct internalvar_funcs *funcs,
++ void *data);
++
++/* Compile an internal variable to an agent expression. VAR is the
++ variable to compile; EXPR and VALUE are the agent expression we are
++ updating. This will return 0 if there is no known way to compile
++ VAR, and 1 if VAR was successfully compiled. It may also throw an
++ exception on error. */
++
++extern int compile_internalvar_to_ax (struct internalvar *var,
++ struct agent_expr *expr,
++ struct axs_value *value);
- /* User function handler. */
+ extern struct internalvar *lookup_internalvar (const char *name);
-diff --git a/gdb/varobj.c b/gdb/varobj.c
-index b9b8e91..a81d25c 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"
+Index: gdb-7.2.90.20110703/gdb/windows-tdep.c
+===================================================================
+--- gdb-7.2.90.20110703.orig/gdb/windows-tdep.c 2011-01-12 02:23:29.000000000 +0100
++++ gdb-7.2.90.20110703/gdb/windows-tdep.c 2011-07-03 10:33:11.000000000 +0200
+@@ -268,7 +268,7 @@ static struct lval_funcs tlb_value_funcs
+ if there's no object available. */
+
+ static struct value *
+-tlb_make_value (struct gdbarch *gdbarch, struct internalvar *var)
++tlb_make_value (struct gdbarch *gdbarch, struct internalvar *var, void *ignore)
+ {
+ if (target_has_stack && !ptid_equal (inferior_ptid, null_ptid))
+ {
+@@ -425,6 +425,15 @@ init_w32_command_list (void)
+ }
+ }
+
++/* Implementation of `tlb' variable. */
++
++static const struct internalvar_funcs tlb_funcs =
++{
++ tlb_make_value,
++ NULL,
++ NULL
++};
++
+ void
+ _initialize_windows_tdep (void)
+ {
+@@ -451,5 +460,5 @@ even if their meaning is unknown."),
+ value with a void typed value, and when we get here, gdbarch
+ isn't initialized yet. At this point, we're quite sure there
+ isn't another convenience variable of the same name. */
+- create_internalvar_type_lazy ("_tlb", tlb_make_value);
++ create_internalvar_type_lazy ("_tlb", &tlb_funcs, NULL);
+ }
+Index: gdb-7.2.90.20110703/gdb/xcoffread.c
+===================================================================
+--- gdb-7.2.90.20110703.orig/gdb/xcoffread.c 2011-03-07 17:17:29.000000000 +0100
++++ gdb-7.2.90.20110703/gdb/xcoffread.c 2011-07-03 10:33:11.000000000 +0200
+@@ -3090,6 +3090,7 @@ static const struct sym_fns xcoff_sym_fn
+ default_symfile_segments, /* Get segment information from a file. */
+ aix_process_linenos,
+ default_symfile_relocate, /* Relocate a debug section. */
++ NULL, /* sym_probe_fns */
+ &psym_functions
+ };
- #include "gdb_assert.h"
- #include "gdb_string.h"
---- ./gdb/infrun.c 2009-12-09 22:03:33.000000000 +0100
-+++ ./gdb/infrun.c 2009-12-09 22:29:56.000000000 +0100
-@@ -3994,6 +3994,12 @@ infrun: not switching back to stepped th
+Index: gdb-7.2.50.20101231/gdb/infrun.c
+===================================================================
+--- gdb-7.2.50.20101231.orig/gdb/infrun.c 2011-01-01 01:02:45.000000000 +0100
++++ gdb-7.2.50.20101231/gdb/infrun.c 2011-01-01 01:10:22.000000000 +0100
+@@ -4585,6 +4585,12 @@ infrun: not switching back to stepped th
- if (ecs->event_thread->step_over_calls == STEP_OVER_ALL)
+ if (ecs->event_thread->control.step_over_calls == STEP_OVER_ALL)
{
+ struct symbol *stop_fn = find_pc_function (stop_pc);
+
/* We're doing a "next".
Normal (forward) execution: set a breakpoint at the
-@@ -4020,6 +4026,7 @@ infrun: not switching back to stepped th
+@@ -4612,6 +4618,7 @@ infrun: not switching back to stepped th
keep_going (ecs);
return;
}
/* If we are in a function call trampoline (a stub between the
---- ./gdb/testsuite/gdb.fortran/omp-step.exp 1970-01-01 01:00:00.000000000 +0100
-+++ ./gdb/testsuite/gdb.fortran/omp-step.exp 2009-12-09 22:31:04.000000000 +0100
+Index: gdb-7.2.50.20101231/gdb/testsuite/gdb.fortran/omp-step.exp
+===================================================================
+--- /dev/null 1970-01-01 00:00:00.000000000 +0000
++++ gdb-7.2.50.20101231/gdb/testsuite/gdb.fortran/omp-step.exp 2011-01-01 01:09:58.000000000 +0100
@@ -0,0 +1,31 @@
+# Copyright 2009 Free Software Foundation, Inc.
+
+
+gdb_breakpoint [gdb_get_line_number "success"]
+gdb_continue_to_breakpoint "success" ".*success.*"
---- ./gdb/testsuite/gdb.fortran/omp-step.f90 1970-01-01 01:00:00.000000000 +0100
-+++ ./gdb/testsuite/gdb.fortran/omp-step.f90 2009-12-09 22:25:35.000000000 +0100
+Index: gdb-7.2.50.20101231/gdb/testsuite/gdb.fortran/omp-step.f90
+===================================================================
+--- /dev/null 1970-01-01 00:00:00.000000000 +0000
++++ gdb-7.2.50.20101231/gdb/testsuite/gdb.fortran/omp-step.f90 2011-01-01 01:09:58.000000000 +0100
@@ -0,0 +1,32 @@
+! Copyright 2009 Free Software Foundation, Inc.
+
-Index: gdb-7.1.90.20100711/gdb/config/i386/linux64.mh
+Index: gdb-7.2.50.20110117/gdb/config/i386/linux64.mh
===================================================================
---- gdb-7.1.90.20100711.orig/gdb/config/i386/linux64.mh 2010-05-28 20:50:31.000000000 +0200
-+++ gdb-7.1.90.20100711/gdb/config/i386/linux64.mh 2010-07-13 19:02:54.000000000 +0200
+--- gdb-7.2.50.20110117.orig/gdb/config/i386/linux64.mh 2010-05-28 20:50:31.000000000 +0200
++++ gdb-7.2.50.20110117/gdb/config/i386/linux64.mh 2011-01-17 16:01:48.000000000 +0100
@@ -2,7 +2,7 @@
NATDEPFILES= inf-ptrace.o fork-child.o \
i386-nat.o amd64-nat.o amd64-linux-nat.o linux-nat.o \
+#define target_can_use_hardware_watchpoint(type, cnt, ot) 1
+
+#endif /* NM_LINUX64_H */
-Index: gdb-7.1.90.20100711/gdb/config/i386/nm-linux64.h
+Index: gdb-7.2.50.20110117/gdb/config/i386/nm-linux64.h
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
-+++ gdb-7.1.90.20100711/gdb/config/i386/nm-linux64.h 2010-07-13 19:02:28.000000000 +0200
++++ gdb-7.2.50.20110117/gdb/config/i386/nm-linux64.h 2011-01-17 16:01:48.000000000 +0100
@@ -0,0 +1,28 @@
+/* Native support for GNU/Linux amd64.
+
+#define target_can_use_hardware_watchpoint(type, cnt, ot) 1
+
+#endif /* NM_LINUX64_H */
-Index: gdb-7.1.90.20100711/gdb/target.h
+Index: gdb-7.2.50.20110117/gdb/target.h
===================================================================
---- gdb-7.1.90.20100711.orig/gdb/target.h 2010-07-12 23:07:34.000000000 +0200
-+++ gdb-7.1.90.20100711/gdb/target.h 2010-07-13 19:02:28.000000000 +0200
-@@ -1298,8 +1298,10 @@ extern char *normal_pid_to_str (ptid_t p
+--- gdb-7.2.50.20110117.orig/gdb/target.h 2011-01-14 14:47:15.000000000 +0100
++++ gdb-7.2.50.20110117/gdb/target.h 2011-01-17 16:02:08.000000000 +0100
+@@ -1318,8 +1318,10 @@ extern char *normal_pid_to_str (ptid_t p
bp_hardware_breakpoint. CNT is the number of such watchpoints used so far
(including this one?). OTHERTYPE is who knows what... */
(*current_target.to_can_use_hw_breakpoint) (TYPE, CNT, OTHERTYPE);
+#endif
- #define target_region_ok_for_hw_watchpoint(addr, len) \
- (*current_target.to_region_ok_for_hw_watchpoint) (addr, len)
-Index: gdb-7.1.90.20100711/gdb/testsuite/gdb.base/watchpoint-hw-before-run.exp
+ /* Returns the number of debug registers needed to watch the given
+ memory region, or zero if not supported. */
+Index: gdb-7.2.50.20110117/gdb/testsuite/gdb.base/watchpoint-hw-before-run.exp
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
-+++ gdb-7.1.90.20100711/gdb/testsuite/gdb.base/watchpoint-hw-before-run.exp 2010-07-13 19:02:28.000000000 +0200
++++ gdb-7.2.50.20110117/gdb/testsuite/gdb.base/watchpoint-hw-before-run.exp 2011-01-17 16:01:48.000000000 +0100
@@ -0,0 +1,40 @@
+# Copyright 2009, 2010 Free Software Foundation, Inc.
+
--- /dev/null
+2010-06-01 Chris Moller <cmoller@redhat.com>
+
+ * python/libstdcxx/v6/printers.py (StdVectorPrinter): Add
+ detection for matrices as nested vectors.
+
+Index: libstdc++-v3/python/libstdcxx/v6/printers.py
+===================================================================
+--- ./libstdc++-v3-python-r155978/libstdcxx/v6/printers.py (revision 159937)
++++ ./libstdc++-v3-python-r155978/libstdcxx/v6/printers.py (working copy)
+@@ -19,6 +19,9 @@
+ import itertools
+ import re
+
++vector_sig = 'std::vector'
++vector_regex = re.compile('^' + vector_sig + '<.*>$')
++
+ class StdPointerPrinter:
+ "Print a smart pointer of some kind"
+
+@@ -186,7 +189,13 @@
+ % (self.typename, int (finish - start), int (end - start)))
+
+ def display_hint(self):
+- return 'array'
++ itype0 = self.val.type.template_argument(0)
++ itag = itype0.tag
++ if itag and re.match(vector_regex, itag):
++ rc = 'matrix'
++ else:
++ rc = 'array'
++ return rc
+
+ class StdVectorIteratorPrinter:
+ "Print std::vector::iterator"
+@@ -692,7 +701,7 @@
+ pretty_printers_dict[re.compile('^std::set<.*>$')] = lambda val: StdSetPrinter("std::set", val)
+ pretty_printers_dict[re.compile('^std::stack<.*>$')] = lambda val: StdStackOrQueuePrinter("std::stack", val)
+ pretty_printers_dict[re.compile('^std::unique_ptr<.*>$')] = UniquePointerPrinter
+- pretty_printers_dict[re.compile('^std::vector<.*>$')] = lambda val: StdVectorPrinter("std::vector", val)
++ pretty_printers_dict[vector_regex] = lambda val: StdVectorPrinter(vector_sig, val)
+ # vector<bool>
+
+ # Printer registrations for classes compiled with -D_GLIBCXX_DEBUG.
* gdb.python/pr10659.exp. New file.
* gdb.python/pr10659.py: New file.
-Index: gdb-7.1/gdb/valprint.h
+Index: gdb-7.2.50.20110218/gdb/valprint.h
===================================================================
---- gdb-7.1.orig/gdb/valprint.h 2010-06-30 14:02:16.000000000 +0200
-+++ gdb-7.1/gdb/valprint.h 2010-06-30 14:35:24.000000000 +0200
+--- gdb-7.2.50.20110218.orig/gdb/valprint.h 2011-02-14 12:35:45.000000000 +0100
++++ gdb-7.2.50.20110218/gdb/valprint.h 2011-02-18 10:44:32.000000000 +0100
@@ -90,6 +90,9 @@ struct value_print_options
/* If nonzero, print the value in "summary" form. */
};
/* The global print options set by the user. In general this should
-Index: gdb-7.1/gdb/python/py-prettyprint.c
+Index: gdb-7.2.50.20110218/gdb/python/py-prettyprint.c
===================================================================
---- gdb-7.1.orig/gdb/python/py-prettyprint.c 2010-06-30 14:01:40.000000000 +0200
-+++ gdb-7.1/gdb/python/py-prettyprint.c 2010-06-30 14:34:49.000000000 +0200
-@@ -385,7 +385,8 @@ print_children (PyObject *printer, const
+--- gdb-7.2.50.20110218.orig/gdb/python/py-prettyprint.c 2011-02-14 12:10:53.000000000 +0100
++++ gdb-7.2.50.20110218/gdb/python/py-prettyprint.c 2011-02-18 10:45:02.000000000 +0100
+@@ -501,7 +501,7 @@ print_children (PyObject *printer, const
/* Use the prettyprint_arrays option if we are printing an array,
and the pretty option otherwise. */
-- pretty = is_array ? options->prettyprint_arrays : options->pretty;
-+ pretty = (is_array || options->prettyprint_matrix) ?
-+ options->prettyprint_arrays : options->pretty;
-
- /* Manufacture a dummy Python frame to work around Python 2.4 bug,
- where it insists on having a non-NULL tstate->frame when
-@@ -397,6 +398,9 @@ print_children (PyObject *printer, const
+- if (is_array)
++ if (is_array || options->prettyprint_matrix)
+ pretty = options->prettyprint_arrays;
+ else
+ {
+@@ -521,6 +521,9 @@ print_children (PyObject *printer, const
goto done;
}
make_cleanup_py_decref (frame);
done_flag = 0;
for (i = 0; i < options->print_max; ++i)
-@@ -431,12 +435,23 @@ print_children (PyObject *printer, const
+@@ -555,12 +558,23 @@ print_children (PyObject *printer, const
3. Other. Always print a ",". */
if (i == 0)
{
else if (! is_map || i % 2 == 0)
fputs_filtered (pretty ? "," : ", ", stream);
-@@ -465,6 +480,10 @@ print_children (PyObject *printer, const
+@@ -589,6 +603,10 @@ print_children (PyObject *printer, const
if (is_map && i % 2 == 0)
fputs_filtered ("[", stream);
else if (is_array)
{
/* We print the index, not whatever the child method
-@@ -539,7 +558,12 @@ print_children (PyObject *printer, const
+@@ -667,7 +685,12 @@ print_children (PyObject *printer, const
fputs_filtered ("\n", stream);
print_spaces_filtered (2 * recurse, stream);
}
}
done:
-@@ -561,6 +585,7 @@ apply_val_pretty_printer (struct type *t
+@@ -689,6 +712,7 @@ apply_val_pretty_printer (struct type *t
+ char *hint = NULL;
struct cleanup *cleanups;
int result = 0;
- int is_py_none = 0;
+ struct value_print_options *options_copy;
- cleanups = ensure_python_env (gdbarch, language);
+ enum string_repr_result print_result;
- /* Instantiate the printer. */
-@@ -582,12 +607,23 @@ apply_val_pretty_printer (struct type *t
+ /* No pretty-printer support for unavailable values. */
+@@ -726,9 +750,21 @@ apply_val_pretty_printer (struct type *t
/* If we are printing a map, we want some special formatting. */
hint = gdbpy_get_display_hint (printer);
make_cleanup (free_current_contents, &hint);
/* Print the section */
-- is_py_none = print_string_repr (printer, hint, stream, recurse,
-- options, language, gdbarch);
-- print_children (printer, hint, stream, recurse, options, language,
-+ is_py_none = options_copy->prettyprint_matrix ?
-+ 1 : print_string_repr (printer, hint, stream,
-+ recurse, options_copy,
-+ language, gdbarch);
-+ print_children (printer, hint, stream, recurse, options_copy, language,
- is_py_none);
-
- result = 1;
-Index: gdb-7.1/gdb/testsuite/gdb.python/pr10659.cc
++ if (options_copy->prettyprint_matrix)
++ print_result = string_repr_none;
++else /* Red Hat 2D matrix patch */
+ print_result = print_string_repr (printer, hint, stream, recurse,
+ options, language, gdbarch);
+ if (print_result != string_repr_error)
+Index: gdb-7.2.50.20110218/gdb/testsuite/gdb.python/pr10659.cc
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
-+++ gdb-7.1/gdb/testsuite/gdb.python/pr10659.cc 2010-06-30 14:34:49.000000000 +0200
++++ gdb-7.2.50.20110218/gdb/testsuite/gdb.python/pr10659.cc 2011-02-18 10:44:32.000000000 +0100
@@ -0,0 +1,43 @@
+#include <list>
+#include <vector> // /usr/include/c++/4.4.1/bits/vector.tcc
+
+ return 0; // break
+}
-Index: gdb-7.1/gdb/testsuite/gdb.python/pr10659.exp
+Index: gdb-7.2.50.20110218/gdb/testsuite/gdb.python/pr10659.exp
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
-+++ gdb-7.1/gdb/testsuite/gdb.python/pr10659.exp 2010-06-30 14:34:49.000000000 +0200
++++ gdb-7.2.50.20110218/gdb/testsuite/gdb.python/pr10659.exp 2011-02-18 10:44:32.000000000 +0100
@@ -0,0 +1,82 @@
+#Copyright 2010 Free Software Foundation, Inc.
+
+#
+
+
-Index: gdb-7.1/gdb/testsuite/gdb.python/pr10659.py
+Index: gdb-7.2.50.20110218/gdb/testsuite/gdb.python/pr10659.py
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
-+++ gdb-7.1/gdb/testsuite/gdb.python/pr10659.py 2010-06-30 14:34:49.000000000 +0200
++++ gdb-7.2.50.20110218/gdb/testsuite/gdb.python/pr10659.py 2011-02-18 10:44:32.000000000 +0100
@@ -0,0 +1,109 @@
+# Copyright (C) 2008, 2009 Free Software Foundation, Inc.
+
+fake_pretty_printers_dict = {}
+
+build_libfakecxx_dictionary ()
-Index: gdb-7.1/gdb/valprint.c
+Index: gdb-7.2.50.20110218/gdb/valprint.c
===================================================================
---- gdb-7.1.orig/gdb/valprint.c 2010-06-30 13:51:26.000000000 +0200
-+++ gdb-7.1/gdb/valprint.c 2010-06-30 14:35:41.000000000 +0200
-@@ -83,7 +83,8 @@ struct value_print_options user_print_op
+--- gdb-7.2.50.20110218.orig/gdb/valprint.c 2011-02-18 10:44:16.000000000 +0100
++++ gdb-7.2.50.20110218/gdb/valprint.c 2011-02-18 10:44:32.000000000 +0100
+@@ -85,7 +85,8 @@ struct value_print_options user_print_op
1, /* static_field_print */
1, /* pascal_static_field_print */
0, /* raw */
* gdb.threads/sigstep-threads.exp: New file.
* gdb.threads/sigstep-threads.c: New file.
-Index: gdb-7.2/gdb/linux-nat.c
+Index: gdb-7.2.50.20110117/gdb/linux-nat.c
===================================================================
---- gdb-7.2.orig/gdb/linux-nat.c 2010-09-25 15:30:54.000000000 +0200
-+++ gdb-7.2/gdb/linux-nat.c 2010-09-25 15:37:23.000000000 +0200
-@@ -2702,6 +2702,8 @@ stop_wait_callback (struct lwp_info *lp,
+--- gdb-7.2.50.20110117.orig/gdb/linux-nat.c 2011-01-17 15:53:14.000000000 +0100
++++ gdb-7.2.50.20110117/gdb/linux-nat.c 2011-01-17 16:05:57.000000000 +0100
+@@ -2803,6 +2803,8 @@ stop_wait_callback (struct lwp_info *lp,
{
int status;
status = wait_lwp (lp);
if (status == 0)
return 0;
-@@ -2726,110 +2728,61 @@ stop_wait_callback (struct lwp_info *lp,
+@@ -2828,110 +2830,61 @@ stop_wait_callback (struct lwp_info *lp,
if (WSTOPSIG (status) != SIGSTOP)
{
-- if (WSTOPSIG (status) == SIGTRAP)
+- if (linux_nat_status_is_event (status))
- {
- /* If a LWP other than the LWP that we're reporting an
- event for has hit a GDB breakpoint (as opposed to
-
- save_sigtrap (lp);
-
-- /* Now resume this LWP and get the SIGSTOP event. */
+- /* Now resume this LWP and get the SIGSTOP event. */
- errno = 0;
- ptrace (PTRACE_CONT, GET_LWP (lp->ptid), 0, 0);
- if (debug_linux_nat)
- target_pid_to_str (lp->ptid));
- }
- /* Hold this event/waitstatus while we check to see if
-- there are any more (we still want to get that SIGSTOP). */
+- there are any more (we still want to get that SIGSTOP). */
- stop_wait_callback (lp, NULL);
+ /* The thread was stopped with a signal other than SIGSTOP. */
- /* Hold the SIGTRAP for handling by linux_nat_wait. If
- there's another event, throw it back into the
-- queue. */
+- queue. */
- if (lp->status)
- {
- if (debug_linux_nat)
+ /* Save the trap's siginfo in case we need it later. */
+ save_siginfo (lp);
-- /* Save the sigtrap event. */
+- /* Save the sigtrap event. */
- lp->status = status;
- return 0;
- }
- else
- {
- /* The thread was stopped with a signal other than
-- SIGSTOP, and didn't accidentally trip a breakpoint. */
+- SIGSTOP, and didn't accidentally trip a breakpoint. */
+ save_sigtrap (lp);
- if (debug_linux_nat)
- status_to_str ((int) status),
- target_pid_to_str (lp->ptid));
- }
-- /* Now resume this LWP and get the SIGSTOP event. */
+- /* Now resume this LWP and get the SIGSTOP event. */
- errno = 0;
- ptrace (PTRACE_CONT, GET_LWP (lp->ptid), 0, 0);
- if (debug_linux_nat)
- errno ? safe_strerror (errno) : "OK");
-
- /* Hold this event/waitstatus while we check to see if
-- there are any more (we still want to get that SIGSTOP). */
+- there are any more (we still want to get that SIGSTOP). */
- stop_wait_callback (lp, NULL);
+ if (debug_linux_nat)
+ fprintf_unfiltered (gdb_stdlog,
- lp->status = status;
- return 0;
- }
-+ /* Save the sigtrap event. */
++ /* Save the sigtrap event. */
+ lp->status = status;
+ gdb_assert (! lp->stopped);
+ gdb_assert (lp->signalled);
lp->signalled = 0;
}
}
-@@ -3416,52 +3369,6 @@ retry:
+@@ -3514,52 +3467,6 @@ retry:
lp = NULL;
}
if (!target_can_async_p ())
{
/* Causes SIGINT to be passed on to the attached process. */
-Index: gdb-7.2/gdb/testsuite/gdb.threads/siginfo-threads.c
+Index: gdb-7.2.50.20110117/gdb/testsuite/gdb.threads/siginfo-threads.c
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
-+++ gdb-7.2/gdb/testsuite/gdb.threads/siginfo-threads.c 2010-09-25 15:32:32.000000000 +0200
++++ gdb-7.2.50.20110117/gdb/testsuite/gdb.threads/siginfo-threads.c 2011-01-17 16:02:40.000000000 +0100
@@ -0,0 +1,447 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+
+ return EXIT_SUCCESS;
+}
-Index: gdb-7.2/gdb/testsuite/gdb.threads/siginfo-threads.exp
+Index: gdb-7.2.50.20110117/gdb/testsuite/gdb.threads/siginfo-threads.exp
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
-+++ gdb-7.2/gdb/testsuite/gdb.threads/siginfo-threads.exp 2010-09-25 15:32:32.000000000 +0200
++++ gdb-7.2.50.20110117/gdb/testsuite/gdb.threads/siginfo-threads.exp 2011-01-17 16:02:40.000000000 +0100
@@ -0,0 +1,94 @@
+# Copyright 2010 Free Software Foundation, Inc.
+
+}
+
+gdb_continue_to_breakpoint break-at-exit ".*break-at-exit.*"
-Index: gdb-7.2/gdb/testsuite/gdb.threads/sigstep-threads.c
+Index: gdb-7.2.50.20110117/gdb/testsuite/gdb.threads/sigstep-threads.c
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
-+++ gdb-7.2/gdb/testsuite/gdb.threads/sigstep-threads.c 2010-09-25 15:32:32.000000000 +0200
++++ gdb-7.2.50.20110117/gdb/testsuite/gdb.threads/sigstep-threads.c 2011-01-17 16:02:40.000000000 +0100
@@ -0,0 +1,54 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+ start (NULL); /* main-start */
+ return 0;
+}
-Index: gdb-7.2/gdb/testsuite/gdb.threads/sigstep-threads.exp
+Index: gdb-7.2.50.20110117/gdb/testsuite/gdb.threads/sigstep-threads.exp
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
-+++ gdb-7.2/gdb/testsuite/gdb.threads/sigstep-threads.exp 2010-09-25 15:32:32.000000000 +0200
++++ gdb-7.2.50.20110117/gdb/testsuite/gdb.threads/sigstep-threads.exp 2011-01-17 16:02:40.000000000 +0100
@@ -0,0 +1,74 @@
+# Copyright 2010 Free Software Foundation, Inc.
+
(linux_nat_set_siginfo_fixup): Use PTRACE_GETSIGINFO.
* linux-nat.h (struct lwp_info) <siginfo>: Remove.
-Index: gdb-7.2/gdb/linux-nat.c
+Index: gdb-7.2.50.20101116/gdb/linux-nat.c
===================================================================
---- gdb-7.2.orig/gdb/linux-nat.c 2010-09-25 15:37:23.000000000 +0200
-+++ gdb-7.2/gdb/linux-nat.c 2010-09-25 15:38:18.000000000 +0200
-@@ -1851,7 +1851,6 @@ resume_callback (struct lwp_info *lp, vo
+--- gdb-7.2.50.20101116.orig/gdb/linux-nat.c 2010-11-16 09:12:26.000000000 +0100
++++ gdb-7.2.50.20101116/gdb/linux-nat.c 2010-11-16 09:13:21.000000000 +0100
+@@ -1850,7 +1850,6 @@ resume_callback (struct lwp_info *lp, vo
target_pid_to_str (lp->ptid));
lp->stopped = 0;
lp->step = 0;
lp->stopped_by_watchpoint = 0;
if (debug_linux_nat)
-@@ -2483,22 +2481,6 @@ wait_lwp (struct lwp_info *lp)
+@@ -2503,22 +2501,6 @@ wait_lwp (struct lwp_info *lp)
return status;
}
/* Send a SIGSTOP to LP. */
static int
-@@ -2730,9 +2712,6 @@ stop_wait_callback (struct lwp_info *lp,
+@@ -2787,9 +2769,6 @@ stop_wait_callback (struct lwp_info *lp,
{
/* The thread was stopped with a signal other than SIGSTOP. */
save_sigtrap (lp);
if (debug_linux_nat)
-@@ -3102,12 +3081,7 @@ linux_nat_filter_event (int lwpid, int s
+@@ -3155,12 +3134,7 @@ linux_nat_filter_event (int lwpid, int s
}
- if (WIFSTOPPED (status) && WSTOPSIG (status) == SIGTRAP)
+ if (linux_nat_status_is_event (status))
- {
- /* Save the trap's siginfo in case we need it later. */
- save_siginfo (lp);
/* Check if the thread has exited. */
if ((WIFEXITED (status) || WIFSIGNALED (status))
-@@ -3706,7 +3680,6 @@ resume_stopped_resumed_lwps (struct lwp_
+@@ -3763,7 +3737,6 @@ resume_stopped_resumed_lwps (struct lwp_
linux_ops->to_resume (linux_ops, pid_to_ptid (GET_LWP (lp->ptid)),
lp->step, TARGET_SIGNAL_0);
lp->stopped = 0;
lp->stopped_by_watchpoint = 0;
}
-@@ -5878,11 +5851,19 @@ linux_nat_set_siginfo_fixup (struct targ
+@@ -5932,11 +5905,19 @@ linux_nat_set_siginfo_fixup (struct targ
struct siginfo *
linux_nat_get_siginfo (ptid_t ptid)
{
}
/* Provide a prototype to silence -Wmissing-prototypes. */
-Index: gdb-7.2/gdb/linux-nat.h
+Index: gdb-7.2.50.20101116/gdb/linux-nat.h
===================================================================
---- gdb-7.2.orig/gdb/linux-nat.h 2010-09-25 15:30:50.000000000 +0200
-+++ gdb-7.2/gdb/linux-nat.h 2010-09-25 15:37:57.000000000 +0200
+--- gdb-7.2.50.20101116.orig/gdb/linux-nat.h 2010-11-16 07:54:36.000000000 +0100
++++ gdb-7.2.50.20101116/gdb/linux-nat.h 2010-11-16 09:12:44.000000000 +0100
@@ -58,10 +58,6 @@ struct lwp_info
/* The kind of stepping of this LWP. */
enum resume_step step;
--- /dev/null
+Fix gdb.solib_address (fix by Phil Muldoon).
+
+--- /dev/null
++++ b/gdb/testsuite/gdb.python/rh634108-solib_address.exp
+@@ -0,0 +1,24 @@
++# Copyright (C) 2008, 2009, 2010 Free Software Foundation, Inc.
++
++# This program is free software; you can redistribute it and/or modify
++# it under the terms of the GNU General Public License as published by
++# the Free Software Foundation; either version 3 of the License, or
++# (at your option) any later version.
++#
++# This program is distributed in the hope that it will be useful,
++# but WITHOUT ANY WARRANTY; without even the implied warranty of
++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++# GNU General Public License for more details.
++#
++# You should have received a copy of the GNU General Public License
++# along with this program. If not, see <http://www.gnu.org/licenses/>.
++
++# https://bugzilla.redhat.com/show_bug.cgi?id=634108
++
++gdb_exit
++gdb_start
++
++# Skip all tests if Python scripting is not enabled.
++if { [skip_python_tests] } { continue }
++
++gdb_test "python print gdb.solib_address(-1)" "None" "gdb.solib_address exists"
--- /dev/null
+[patch] Code cleanup: New SYMBOL_HASH_NEXT
+http://sourceware.org/ml/gdb-patches/2011-04/msg00022.html
+http://sourceware.org/ml/gdb-cvs/2011-04/msg00043.html
+
+### src/gdb/ChangeLog 2011/04/06 03:24:22 1.12908
+### src/gdb/ChangeLog 2011/04/06 19:50:03 1.12909
+## -1,3 +1,12 @@
++2011-04-06 Jan Kratochvil <jan.kratochvil@redhat.com>
++
++ Code cleanup.
++ * dictionary.c (dict_hash): Use SYMBOL_HASH_NEXT.
++ * dwarf2read.c (mapped_index_string_hash): Refer to SYMBOL_HASH_NEXT
++ in the function comment, a new note on values compatibility.
++ * minsyms.c (msymbol_hash_iw, msymbol_hash): Use SYMBOL_HASH_NEXT.
++ * symtab.h (SYMBOL_HASH_NEXT): New.
++
+ 2011-04-06 Thiago Jung Bauermann <bauerman@br.ibm.com>
+
+ * ppc-linux-nat.c (check_condition): Add len output parameter.
+--- src/gdb/dictionary.c 2011/01/07 19:36:15 1.21
++++ src/gdb/dictionary.c 2011/04/06 19:50:04 1.22
+@@ -826,7 +826,7 @@
+ }
+ /* FALL THROUGH */
+ default:
+- hash = hash * 67 + *string - 113;
++ hash = SYMBOL_HASH_NEXT (hash, *string);
+ string += 1;
+ break;
+ }
+--- src/gdb/dwarf2read.c 2011/04/04 14:10:12 1.520
++++ src/gdb/dwarf2read.c 2011/04/06 19:50:04 1.521
+@@ -1962,11 +1962,11 @@
+ do_cleanups (cleanup);
+ }
+
+-/* The hash function for strings in the mapped index. This is the
+- same as the hashtab.c hash function, but we keep a separate copy to
+- maintain control over the implementation. This is necessary
+- because the hash function is tied to the format of the mapped index
+- file. */
++/* The hash function for strings in the mapped index. This is the same as
++ SYMBOL_HASH_NEXT, but we keep a separate copy to maintain control over the
++ implementation. This is necessary because the hash function is tied to the
++ format of the mapped index file. The hash values do not have to match with
++ SYMBOL_HASH_NEXT. */
+
+ static hashval_t
+ mapped_index_string_hash (const void *p)
+--- src/gdb/minsyms.c 2011/03/28 20:29:51 1.81
++++ src/gdb/minsyms.c 2011/04/06 19:50:05 1.82
+@@ -91,7 +91,7 @@
+ ++string;
+ if (*string && *string != '(')
+ {
+- hash = hash * 67 + *string - 113;
++ hash = SYMBOL_HASH_NEXT (hash, *string);
+ ++string;
+ }
+ }
+@@ -106,7 +106,7 @@
+ unsigned int hash = 0;
+
+ for (; *string; ++string)
+- hash = hash * 67 + *string - 113;
++ hash = SYMBOL_HASH_NEXT (hash, *string);
+ return hash;
+ }
+
+--- src/gdb/symtab.h 2011/04/04 15:19:59 1.177
++++ src/gdb/symtab.h 2011/04/06 19:50:05 1.178
+@@ -1004,6 +1004,12 @@
+
+ extern unsigned int msymbol_hash (const char *);
+
++/* Compute the next hash value from previous HASH and the character C. This
++ is only a GDB in-memory computed value with no external files compatibility
++ requirements. */
++
++#define SYMBOL_HASH_NEXT(hash, c) ((hash) * 67 + (c) - 113)
++
+ extern struct objfile * msymbol_objfile (struct minimal_symbol *sym);
+
+ extern void
--- /dev/null
+http://sourceware.org/ml/gdb-patches/2011-04/msg00124.html
+Subject: [patch 1/3] case insensitive: Reformat code
+
+Hi,
+
+just some reformatting to make the later patch more clear. There should be no
+functionality difference by this patch. c1+c2 are a bit ugly but I found any
+other solution a bit ugly.
+
+
+Thanks,
+Jan
+
+
+gdb/
+2011-04-08 Jan Kratochvil <jan.kratochvil@redhat.com>
+
+ Format the code for the next patch.
+ * dwarf2read.c (struct mapped_index): Include delimiting newlines.
+ * utils.c (strcmp_iw_ordered): Reformat the code for the next patch.
+ New variables c1 and c2.
+
+--- a/gdb/dwarf2read.c
++++ b/gdb/dwarf2read.c
+@@ -150,14 +150,19 @@ struct mapped_index
+ {
+ /* The total length of the buffer. */
+ off_t total_size;
++
+ /* A pointer to the address table data. */
+ const gdb_byte *address_table;
++
+ /* Size of the address table data in bytes. */
+ offset_type address_table_size;
++
+ /* The symbol table, implemented as a hash table. */
+ const offset_type *symbol_table;
++
+ /* Size in slots, each slot is 2 offset_types. */
+ offset_type symbol_table_slots;
++
+ /* A pointer to the constant pool. */
+ const char *constant_pool;
+ };
+--- a/gdb/utils.c
++++ b/gdb/utils.c
+@@ -3023,48 +3023,55 @@ strcmp_iw (const char *string1, const char *string2)
+ int
+ strcmp_iw_ordered (const char *string1, const char *string2)
+ {
+- while ((*string1 != '\0') && (*string2 != '\0'))
++ /* Formatting stub. */
++ if (1)
+ {
+- while (isspace (*string1))
+- {
+- string1++;
+- }
+- while (isspace (*string2))
+- {
+- string2++;
+- }
+- if (*string1 != *string2)
++ /* C1 and C2 are valid only if *string1 != '\0' && *string2 != '\0'.
++ Provide stub characters if we are already at the end of one of the
++ strings. */
++ char c1 = 'X', c2 = 'X';
++
++ while (*string1 != '\0' && *string2 != '\0')
+ {
+- break;
++ while (isspace (*string1))
++ string1++;
++ while (isspace (*string2))
++ string2++;
++
++ c1 = *string1;
++ c2 = *string2;
++ if (c1 != c2)
++ break;
++
++ if (*string1 != '\0')
++ {
++ string1++;
++ string2++;
++ }
+ }
+- if (*string1 != '\0')
++
++ switch (*string1)
+ {
+- string1++;
+- string2++;
++ /* Characters are non-equal unless they're both '\0'; we want to
++ make sure we get the comparison right according to our
++ comparison in the cases where one of them is '\0' or '('. */
++ case '\0':
++ if (*string2 == '\0')
++ return 0;
++ else
++ return -1;
++ case '(':
++ if (*string2 == '\0')
++ return 1;
++ else
++ return -1;
++ default:
++ if (*string2 == '\0' || *string2 == '(')
++ return 1;
++ else
++ return c1 - c2;
+ }
+ }
+-
+- switch (*string1)
+- {
+- /* Characters are non-equal unless they're both '\0'; we want to
+- make sure we get the comparison right according to our
+- comparison in the cases where one of them is '\0' or '('. */
+- case '\0':
+- if (*string2 == '\0')
+- return 0;
+- else
+- return -1;
+- case '(':
+- if (*string2 == '\0')
+- return 1;
+- else
+- return -1;
+- default:
+- if (*string2 == '(')
+- return 1;
+- else
+- return *string1 - *string2;
+- }
+ }
+
+ /* A simple comparison function with opposite semantics to strcmp. */
+
--- /dev/null
+http://sourceware.org/ml/gdb-patches/2011-04/msg00125.html
+Subject: [patch 2/3] case insensitive: re_comp->regcomp
+
+Hi,
+
+re_comp cannot be passed REG_ICASE. Therefore change the code. The should
+have no functionality impact.
+
+The new boolean field `preg_p' could be maybe replaced by a conditional
+`preg.buffer != NULL' which would work with libiberty regcomp implementation
+but I do not see it guaranteed anywhere. GDB is always using static libiberty
+implementation which I do not see why in the case it is running on glibc.
+But if it gets fixed one day and it starts to use externally linked
+regcomp/regexec I would find the `preg.buffer != NULL' conditional dangerous.
+
+
+Thanks,
+Jan
+
+
+gdb/
+2011-04-08 Jan Kratochvil <jan.kratochvil@redhat.com>
+
+ Replace re_comp/re_exec by regcomp/regexec.
+ * symtab.c (struct search_symbols_data): New fields preg, preg_p.
+ (search_symbols_name_matches): Use them, use regexec.
+ (search_symbols): New variable retval_chain, adjust the use of
+ old_chain against it. Replace re_comp by regcomp. Use the new struct
+ search_symbols_data fields, use regexec instead of re_exec.
+
+Index: gdb-7.2.90.20110429/gdb/symtab.c
+===================================================================
+--- gdb-7.2.90.20110429.orig/gdb/symtab.c 2011-04-29 09:43:33.000000000 +0200
++++ gdb-7.2.90.20110429/gdb/symtab.c 2011-04-29 09:43:55.000000000 +0200
+@@ -2958,7 +2958,10 @@ struct search_symbols_data
+ {
+ int nfiles;
+ char **files;
+- char *regexp;
++
++ /* It is true if PREG contains valid data, false otherwise. */
++ unsigned preg_p : 1;
++ regex_t preg;
+ };
+
+ /* A callback for expand_symtabs_matching. */
+@@ -2976,7 +2979,7 @@ search_symbols_name_matches (const char
+ {
+ struct search_symbols_data *data = user_data;
+
+- return data->regexp == NULL || re_exec (symname);
++ return !data->preg_p || regexec (&data->preg, symname, 0, NULL, 0) == 0;
+ }
+
+ /* Search the symbol table for matches to the regular expression REGEXP,
+@@ -3023,9 +3026,13 @@ search_symbols (char *regexp, domain_enu
+ struct symbol_search *sr;
+ struct symbol_search *psr;
+ struct symbol_search *tail;
+- struct cleanup *old_chain = NULL;
+ struct search_symbols_data datum;
+
++ /* OLD_CHAIN .. RETVAL_CHAIN is always freed, RETVAL_CHAIN .. current
++ CLEANUP_CHAIN is freed only in the case of an error. */
++ struct cleanup *old_chain = make_cleanup (null_cleanup, NULL);
++ struct cleanup *retval_chain;
++
+ if (kind < VARIABLES_DOMAIN || kind >= ALL_DOMAIN)
+ error (_("must search on specific domain"));
+
+@@ -3036,6 +3043,7 @@ search_symbols (char *regexp, domain_enu
+
+ sr = *matches = NULL;
+ tail = NULL;
++ datum.preg_p = 0;
+
+ if (regexp != NULL)
+ {
+@@ -3045,6 +3053,7 @@ search_symbols (char *regexp, domain_enu
+ and <TYPENAME> or <OPERATOR>. */
+ char *opend;
+ char *opname = operator_chars (regexp, &opend);
++ int errcode;
+
+ if (*opname)
+ {
+@@ -3073,8 +3082,16 @@ search_symbols (char *regexp, domain_enu
+ }
+ }
+
+- if (0 != (val = re_comp (regexp)))
+- error (_("Invalid regexp (%s): %s"), val, regexp);
++ errcode = regcomp (&datum.preg, regexp, REG_NOSUB);
++ if (errcode != 0)
++ {
++ char *err = get_regcomp_error (errcode, &datum.preg);
++
++ make_cleanup (xfree, err);
++ error (_("Invalid regexp (%s): %s"), err, regexp);
++ }
++ datum.preg_p = 1;
++ make_regfree_cleanup (&datum.preg);
+ }
+
+ /* Search through the partial symtabs *first* for all symbols
+@@ -3083,7 +3100,6 @@ search_symbols (char *regexp, domain_enu
+
+ datum.nfiles = nfiles;
+ datum.files = files;
+- datum.regexp = regexp;
+ ALL_OBJFILES (objfile)
+ {
+ if (objfile->sf)
+@@ -3094,6 +3110,8 @@ search_symbols (char *regexp, domain_enu
+ &datum);
+ }
+
++ retval_chain = old_chain;
++
+ /* Here, we search through the minimal symbol tables for functions
+ and variables that match, and force their symbols to be read.
+ This is in particular necessary for demangled variable names,
+@@ -3117,8 +3135,9 @@ search_symbols (char *regexp, domain_enu
+ MSYMBOL_TYPE (msymbol) == ourtype3 ||
+ MSYMBOL_TYPE (msymbol) == ourtype4)
+ {
+- if (regexp == NULL
+- || re_exec (SYMBOL_NATURAL_NAME (msymbol)) != 0)
++ if (!datum.preg_p
++ || regexec (&datum.preg, SYMBOL_NATURAL_NAME (msymbol), 0,
++ NULL, 0) == 0)
+ {
+ if (0 == find_pc_symtab (SYMBOL_VALUE_ADDRESS (msymbol)))
+ {
+@@ -3156,8 +3175,9 @@ search_symbols (char *regexp, domain_enu
+ QUIT;
+
+ if (file_matches (real_symtab->filename, files, nfiles)
+- && ((regexp == NULL
+- || re_exec (SYMBOL_NATURAL_NAME (sym)) != 0)
++ && ((!datum.preg_p
++ || regexec (&datum.preg, SYMBOL_NATURAL_NAME (sym), 0,
++ NULL, 0) == 0)
+ && ((kind == VARIABLES_DOMAIN
+ && SYMBOL_CLASS (sym) != LOC_TYPEDEF
+ && SYMBOL_CLASS (sym) != LOC_UNRESOLVED
+@@ -3199,7 +3219,7 @@ search_symbols (char *regexp, domain_enu
+ tail = sort_search_symbols (&dummy, nfound);
+ sr = dummy.next;
+
+- old_chain = make_cleanup_free_search_symbols (sr);
++ make_cleanup_free_search_symbols (sr);
+ }
+ else
+ tail = sort_search_symbols (prevtail, nfound);
+@@ -3221,8 +3241,9 @@ search_symbols (char *regexp, domain_enu
+ MSYMBOL_TYPE (msymbol) == ourtype3 ||
+ MSYMBOL_TYPE (msymbol) == ourtype4)
+ {
+- if (regexp == NULL
+- || re_exec (SYMBOL_NATURAL_NAME (msymbol)) != 0)
++ if (!datum.preg_p
++ || regexec (&datum.preg, SYMBOL_NATURAL_NAME (msymbol), 0,
++ NULL, 0) == 0)
+ {
+ /* Functions: Look up by address. */
+ if (kind != FUNCTIONS_DOMAIN ||
+@@ -3244,7 +3265,7 @@ search_symbols (char *regexp, domain_enu
+ if (tail == NULL)
+ {
+ sr = psr;
+- old_chain = make_cleanup_free_search_symbols (sr);
++ make_cleanup_free_search_symbols (sr);
+ }
+ else
+ tail->next = psr;
+@@ -3256,9 +3277,9 @@ search_symbols (char *regexp, domain_enu
+ }
+ }
+
++ discard_cleanups (retval_chain);
++ do_cleanups (old_chain);
+ *matches = sr;
+- if (sr != NULL)
+- discard_cleanups (old_chain);
+ }
+
+ /* Helper function for symtab_symbol_info, this function uses
--- /dev/null
+http://sourceware.org/ml/gdb-patches/2011-04/msg00418.html
+Subject: Re: [patch 3/3] case insensitive: the fix [rediff]
+
+On Fri, 22 Apr 2011 21:05:07 +0200, Eli Zaretskii wrote:
+> This @table will look weird in the manual: it produces lines that
+> begin with a lower-case letter. Perhaps reorder thusly:
+
+OK, thanks for the review.
+
+
+Regards,
+Jan
+
+
+gdb/doc/
+2011-04-22 Jan Kratochvil <jan.kratochvil@redhat.com>
+ Eli Zaretskii <eliz@gnu.org>
+
+ * gdb.texinfo (Index Section Format): Change the version to 5.
+ Describe the different formula.
+
+gdb/
+2011-04-08 Jan Kratochvil <jan.kratochvil@redhat.com>
+
+ * dwarf2read.c: Include ctype.h.
+ (struct mapped_index): New field version.
+ (mapped_index_string_hash): New parameter index_version. New comment
+ for it. Call tolower appropriately.
+ (find_slot_in_mapped_hash): New variable cmp, initialize it, use it.
+ Choose the right index version for mapped_index_string_hash.
+ (dwarf2_read_index): Support also the index version 5. Initialize the
+ new struct mapped_index field version.
+ (hash_strtab_entry): Pass INT_MAX for the new parameter, explain why.
+ (find_slot): Explain the version needs. Pass INT_MAX for the new
+ parameter.
+ (write_psymtabs_to_index): Produce version 5.
+ * minsyms.c (lookup_minimal_symbol): New variable cmp, initialize it,
+ use it. New comment for SYMBOL_MATCHES_SEARCH_NAME.
+ * psymtab.c (lookup_partial_symbol): Find the
+ SYMBOL_MATCHES_SEARCH_NAME start of the found block of matching
+ entries.
+ * symtab.c (lookup_symbol_in_language): Remove the case_sensitive_off
+ NAME lowercasing.
+ (search_symbols): Pass REG_ICASE to regcomp for case_sensitive_off.
+ (completion_list_add_name): New variable ncmp, initialize it, use it.
+ * symtab.h (SYMBOL_HASH_NEXT): Always call tolower.
+ * utils.c (strcmp_iw): Support case_sensitive_off.
+ (strcmp_iw_ordered): Sort in a way compatible with case_sensitive_off.
+ New function comment part. New variables saved_string1,
+ saved_string2 and case_pass. Add a proper second pass.
+
+gdb/testsuite/
+2011-04-08 Jan Kratochvil <jan.kratochvil@redhat.com>
+
+ * gdb.base/fortran-sym-case.c: New file.
+ * gdb.base/fortran-sym-case.exp: New file.
+ * gdb.dwarf2/dw2-case-insensitive-debug.S: New file.
+ * gdb.dwarf2/dw2-case-insensitive.c: New file.
+ * gdb.dwarf2/dw2-case-insensitive.exp: New file.
+
+Index: gdb-7.2.90.20110525/gdb/dwarf2read.c
+===================================================================
+--- gdb-7.2.90.20110525.orig/gdb/dwarf2read.c 2011-05-25 17:12:51.000000000 +0200
++++ gdb-7.2.90.20110525/gdb/dwarf2read.c 2011-05-25 19:12:33.000000000 +0200
+@@ -152,6 +152,9 @@ DEF_VEC_I (offset_type);
+ a comment by the code that writes the index. */
+ struct mapped_index
+ {
++ /* Index data format version. */
++ int version;
++
+ /* The total length of the buffer. */
+ off_t total_size;
+
+@@ -1997,17 +2000,23 @@ create_addrmap_from_index (struct objfil
+ SYMBOL_HASH_NEXT, but we keep a separate copy to maintain control over the
+ implementation. This is necessary because the hash function is tied to the
+ format of the mapped index file. The hash values do not have to match with
+- SYMBOL_HASH_NEXT. */
++ SYMBOL_HASH_NEXT.
++
++ Use INT_MAX for INDEX_VERSION if you generate the current index format. */
+
+ static hashval_t
+-mapped_index_string_hash (const void *p)
++mapped_index_string_hash (int index_version, const void *p)
+ {
+ const unsigned char *str = (const unsigned char *) p;
+ hashval_t r = 0;
+ unsigned char c;
+
+ while ((c = *str++) != 0)
+- r = r * 67 + c - 113;
++ {
++ if (index_version >= 5)
++ c = tolower (c);
++ r = r * 67 + c - 113;
++ }
+
+ return r;
+ }
+@@ -2023,6 +2032,7 @@ find_slot_in_mapped_hash (struct mapped_
+ struct cleanup *back_to = make_cleanup (null_cleanup, 0);
+ offset_type hash;
+ offset_type slot, step;
++ int (*cmp) (const char *, const char *);
+
+ if (current_language->la_language == language_cplus
+ || current_language->la_language == language_java
+@@ -2045,9 +2055,16 @@ find_slot_in_mapped_hash (struct mapped_
+ }
+ }
+
+- hash = mapped_index_string_hash (name);
++ /* Index version 4 did not support case insensitive searches. But the
++ indexes for case insensitive languages are built in lowercase, therefore
++ simulate our NAME being searched is also lowercased. */
++ hash = mapped_index_string_hash ((index->version == 4
++ && case_sensitivity == case_sensitive_off
++ ? 5 : index->version),
++ name);
+ slot = hash & (index->symbol_table_slots - 1);
+ step = ((hash * 17) & (index->symbol_table_slots - 1)) | 1;
++ cmp = (case_sensitivity == case_sensitive_on ? strcmp : strcasecmp);
+
+ for (;;)
+ {
+@@ -2061,7 +2078,7 @@ find_slot_in_mapped_hash (struct mapped_
+ }
+
+ str = index->constant_pool + MAYBE_SWAP (index->symbol_table[i]);
+- if (!strcmp (name, str))
++ if (!cmp (name, str))
+ {
+ *vec_out = (offset_type *) (index->constant_pool
+ + MAYBE_SWAP (index->symbol_table[i + 1]));
+@@ -2105,15 +2122,17 @@ dwarf2_read_index (struct objfile *objfi
+ /* Versions earlier than 3 emitted every copy of a psymbol. This
+ causes the index to behave very poorly for certain requests. Version 3
+ contained incomplete addrmap. So, it seems better to just ignore such
+- indices. */
++ indices. Index version 4 uses a different hash function than index
++ version 5 and later. */
+ if (version < 4)
+ return 0;
+ /* Indexes with higher version than the one supported by GDB may be no
+ longer backward compatible. */
+- if (version > 4)
++ if (version > 5)
+ return 0;
+
+ map = OBSTACK_ZALLOC (&objfile->objfile_obstack, struct mapped_index);
++ map->version = version;
+ map->total_size = dwarf2_per_objfile->gdb_index.size;
+
+ metadata = (offset_type *) (addr + sizeof (offset_type));
+@@ -15692,13 +15711,16 @@ struct strtab_entry
+ const char *str;
+ };
+
+-/* Hash function for a strtab_entry. */
++/* Hash function for a strtab_entry.
++
++ Function is used only during write_hash_table so no index format backward
++ compatibility is needed. */
+
+ static hashval_t
+ hash_strtab_entry (const void *e)
+ {
+ const struct strtab_entry *entry = e;
+- return mapped_index_string_hash (entry->str);
++ return mapped_index_string_hash (INT_MAX, entry->str);
+ }
+
+ /* Equality function for a strtab_entry. */
+@@ -15836,12 +15858,15 @@ cleanup_mapped_symtab (void *p)
+ }
+
+ /* Find a slot in SYMTAB for the symbol NAME. Returns a pointer to
+- the slot. */
++ the slot.
++
++ Function is used only during write_hash_table so no index format backward
++ compatibility is needed. */
+
+ static struct symtab_index_entry **
+ find_slot (struct mapped_symtab *symtab, const char *name)
+ {
+- offset_type index, step, hash = mapped_index_string_hash (name);
++ offset_type index, step, hash = mapped_index_string_hash (INT_MAX, name);
+
+ index = hash & (symtab->size - 1);
+ step = ((hash * 17) & (symtab->size - 1)) | 1;
+@@ -16369,7 +16394,7 @@ write_psymtabs_to_index (struct objfile
+ total_len = size_of_contents;
+
+ /* The version number. */
+- val = MAYBE_SWAP (4);
++ val = MAYBE_SWAP (5);
+ obstack_grow (&contents, &val, sizeof (val));
+
+ /* The offset of the CU list from the start of the file. */
+Index: gdb-7.2.90.20110525/gdb/minsyms.c
+===================================================================
+--- gdb-7.2.90.20110525.orig/gdb/minsyms.c 2011-05-25 17:12:51.000000000 +0200
++++ gdb-7.2.90.20110525/gdb/minsyms.c 2011-05-25 17:13:13.000000000 +0200
+@@ -239,11 +239,16 @@ lookup_minimal_symbol (const char *name,
+
+ if (pass == 1)
+ {
+- match = strcmp (SYMBOL_LINKAGE_NAME (msymbol),
+- modified_name) == 0;
++ int (*cmp) (const char *, const char *);
++
++ cmp = (case_sensitivity == case_sensitive_on
++ ? strcmp : strcasecmp);
++ match = cmp (SYMBOL_LINKAGE_NAME (msymbol),
++ modified_name) == 0;
+ }
+ else
+ {
++ /* The function respects CASE_SENSITIVITY. */
+ match = SYMBOL_MATCHES_SEARCH_NAME (msymbol,
+ modified_name);
+ }
+Index: gdb-7.2.90.20110525/gdb/psymtab.c
+===================================================================
+--- gdb-7.2.90.20110525.orig/gdb/psymtab.c 2011-04-20 22:10:29.000000000 +0200
++++ gdb-7.2.90.20110525/gdb/psymtab.c 2011-05-25 17:13:13.000000000 +0200
+@@ -690,8 +690,15 @@ lookup_partial_symbol (struct partial_sy
+ internal_error (__FILE__, __LINE__,
+ _("failed internal consistency check"));
+
+- while (top <= real_top
+- && SYMBOL_MATCHES_SEARCH_NAME (*top, search_name))
++ /* For `case_sensitivity == case_sensitive_off' strcmp_iw_ordered will
++ search more exactly than what matches SYMBOL_MATCHES_SEARCH_NAME. */
++ while (top >= start && SYMBOL_MATCHES_SEARCH_NAME (*top, search_name))
++ top--;
++
++ /* Fixup to have a symbol which matches SYMBOL_MATCHES_SEARCH_NAME. */
++ top++;
++
++ while (top <= real_top && SYMBOL_MATCHES_SEARCH_NAME (*top, search_name))
+ {
+ if (symbol_matches_domain (SYMBOL_LANGUAGE (*top),
+ SYMBOL_DOMAIN (*top), domain))
+Index: gdb-7.2.90.20110525/gdb/symtab.c
+===================================================================
+--- gdb-7.2.90.20110525.orig/gdb/symtab.c 2011-05-25 17:12:51.000000000 +0200
++++ gdb-7.2.90.20110525/gdb/symtab.c 2011-05-25 17:13:49.000000000 +0200
+@@ -1062,19 +1062,6 @@ lookup_symbol_in_language (const char *n
+ }
+ }
+
+- if (case_sensitivity == case_sensitive_off)
+- {
+- char *copy;
+- int len, i;
+-
+- len = strlen (name);
+- copy = (char *) alloca (len + 1);
+- for (i= 0; i < len; i++)
+- copy[i] = tolower (name[i]);
+- copy[len] = 0;
+- modified_name = copy;
+- }
+-
+ returnval = lookup_symbol_aux (modified_name, block, domain, lang,
+ is_a_field_of_this);
+ do_cleanups (cleanup);
+@@ -3106,7 +3093,9 @@ search_symbols (char *regexp, domain_enu
+ }
+ }
+
+- errcode = regcomp (&datum.preg, regexp, REG_NOSUB);
++ errcode = regcomp (&datum.preg, regexp,
++ REG_NOSUB | (case_sensitivity == case_sensitive_off
++ ? REG_ICASE : 0));
+ if (errcode != 0)
+ {
+ char *err = get_regcomp_error (errcode, &datum.preg);
+@@ -3546,7 +3535,11 @@ rbreak_command (char *regexp, int from_t
+ static int
+ compare_symbol_name (const char *name, const char *sym_text, int sym_text_len)
+ {
+- if (strncmp (name, sym_text, sym_text_len) != 0)
++ int (*ncmp) (const char *, const char *, size_t);
++
++ ncmp = (case_sensitivity == case_sensitive_on ? strncmp : strncasecmp);
++
++ if (ncmp (name, sym_text, sym_text_len) != 0)
+ return 0;
+
+ if (sym_text[sym_text_len] == '(')
+Index: gdb-7.2.90.20110525/gdb/symtab.h
+===================================================================
+--- gdb-7.2.90.20110525.orig/gdb/symtab.h 2011-05-25 17:12:51.000000000 +0200
++++ gdb-7.2.90.20110525/gdb/symtab.h 2011-05-25 17:13:13.000000000 +0200
+@@ -1036,7 +1036,8 @@ extern unsigned int msymbol_hash (const
+ is only a GDB in-memory computed value with no external files compatibility
+ requirements. */
+
+-#define SYMBOL_HASH_NEXT(hash, c) ((hash) * 67 + (c) - 113)
++#define SYMBOL_HASH_NEXT(hash, c) \
++ ((hash) * 67 + tolower ((unsigned char) (c)) - 113)
+
+ extern struct objfile * msymbol_objfile (struct minimal_symbol *sym);
+
+Index: gdb-7.2.90.20110525/gdb/testsuite/gdb.base/fortran-sym-case.c
+===================================================================
+--- /dev/null 1970-01-01 00:00:00.000000000 +0000
++++ gdb-7.2.90.20110525/gdb/testsuite/gdb.base/fortran-sym-case.c 2011-05-25 17:13:13.000000000 +0200
+@@ -0,0 +1,22 @@
++/* This testcase is part of GDB, the GNU debugger.
++
++ Copyright 2011 Free Software Foundation, Inc.
++
++ This program is free software; you can redistribute it and/or modify
++ it under the terms of the GNU General Public License as published by
++ the Free Software Foundation; either version 3 of the License, or
++ (at your option) any later version.
++
++ This program is distributed in the hope that it will be useful,
++ but WITHOUT ANY WARRANTY; without even the implied warranty of
++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ GNU General Public License for more details.
++
++ You should have received a copy of the GNU General Public License
++ along with this program. If not, see <http://www.gnu.org/licenses/>. */
++
++int
++main (int argc, char **aRGv)
++{
++ return 0;
++}
+Index: gdb-7.2.90.20110525/gdb/testsuite/gdb.base/fortran-sym-case.exp
+===================================================================
+--- /dev/null 1970-01-01 00:00:00.000000000 +0000
++++ gdb-7.2.90.20110525/gdb/testsuite/gdb.base/fortran-sym-case.exp 2011-05-25 17:13:13.000000000 +0200
+@@ -0,0 +1,27 @@
++# Copyright (C) 2011 Free Software Foundation, Inc.
++
++# This program is free software; you can redistribute it and/or modify
++# it under the terms of the GNU General Public License as published by
++# the Free Software Foundation; either version 3 of the License, or
++# (at your option) any later version.
++#
++# This program is distributed in the hope that it will be useful,
++# but WITHOUT ANY WARRANTY; without even the implied warranty of
++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++# GNU General Public License for more details.
++#
++# You should have received a copy of the GNU General Public License
++# along with this program. If not, see <http://www.gnu.org/licenses/>.
++
++set testfile fortran-sym-case
++if { [prepare_for_testing ${testfile}.exp ${testfile}] } {
++ return -1
++}
++
++if ![runto_main] {
++ return -1
++}
++
++gdb_test "set language fortran" {Warning: the current language does not match this frame\.}
++
++gdb_test "frame" ", aRGv=.*"
+Index: gdb-7.2.90.20110525/gdb/testsuite/gdb.dwarf2/dw2-case-insensitive-debug.S
+===================================================================
+--- /dev/null 1970-01-01 00:00:00.000000000 +0000
++++ gdb-7.2.90.20110525/gdb/testsuite/gdb.dwarf2/dw2-case-insensitive-debug.S 2011-05-25 17:13:13.000000000 +0200
+@@ -0,0 +1,102 @@
++/* This testcase is part of GDB, the GNU debugger.
++
++ Copyright 2011 Free Software Foundation, Inc.
++
++ This program is free software; you can redistribute it and/or modify
++ it under the terms of the GNU General Public License as published by
++ the Free Software Foundation; either version 3 of the License, or
++ (at your option) any later version.
++
++ This program is distributed in the hope that it will be useful,
++ but WITHOUT ANY WARRANTY; without even the implied warranty of
++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ GNU General Public License for more details.
++
++ You should have received a copy of the GNU General Public License
++ along with this program. If not, see <http://www.gnu.org/licenses/>. */
++
++ .section .debug_info
++.Lcu1_begin:
++ /* CU header */
++ .4byte .Lcu1_end - .Lcu1_start /* Length of Compilation Unit */
++.Lcu1_start:
++ .2byte 2 /* DWARF Version */
++ .4byte .Labbrev1_begin /* Offset into abbrev section */
++ .byte 4 /* Pointer size */
++
++ /* CU die */
++ .uleb128 1 /* Abbrev: DW_TAG_compile_unit */
++ .ascii "file1.txt\0" /* DW_AT_name */
++ .ascii "GNU C 3.3.3\0" /* DW_AT_producer */
++ .byte 8 /* DW_AT_language (DW_LANG_Fortran90) */
++ .4byte FUNC_lang /* DW_AT_low_pc */
++ .4byte main /* DW_AT_high_pc */
++
++ .uleb128 3 /* Abbrev: DW_TAG_subprogram */
++ .byte 1 /* DW_AT_external */
++ .ascii "FUNC_lang\0" /* DW_AT_name */
++ .4byte FUNC_lang /* DW_AT_low_pc */
++ .4byte main /* DW_AT_high_pc */
++ .byte 1 /* DW_AT_prototyped */
++ .4byte .Ltype - .Lcu1_begin /* DW_AT_type */
++
++.Ltype:
++ .uleb128 0x5 /* Abbrev: DW_TAG_base_type */
++ .byte 0x4 /* DW_AT_byte_size */
++ .byte 0x5 /* DW_AT_encoding */
++ .ascii "foo\0" /* DW_AT_name */
++
++ .byte 0 /* End of children of CU */
++.Lcu1_end:
++
++/* Abbrev table */
++ .section .debug_abbrev
++.Labbrev1_begin:
++ .uleb128 1 /* Abbrev code */
++ .uleb128 0x11 /* DW_TAG_compile_unit */
++ .byte 1 /* has_children */
++ .uleb128 0x3 /* DW_AT_name */
++ .uleb128 0x8 /* DW_FORM_string */
++ .uleb128 0x25 /* DW_AT_producer */
++ .uleb128 0x8 /* DW_FORM_string */
++ .uleb128 0x13 /* DW_AT_language */
++ .uleb128 0xb /* DW_FORM_data1 */
++ .uleb128 0x11 /* DW_AT_low_pc */
++ .uleb128 0x1 /* DW_FORM_addr */
++ .uleb128 0x12 /* DW_AT_high_pc */
++ .uleb128 0x1 /* DW_FORM_addr */
++ .byte 0x0 /* Terminator */
++ .byte 0x0 /* Terminator */
++
++ .uleb128 3 /* Abbrev code */
++ .uleb128 0x2e /* DW_TAG_subprogram */
++ .byte 0 /* has_children */
++ .uleb128 0x3f /* DW_AT_external */
++ .uleb128 0xc /* DW_FORM_flag */
++ .uleb128 0x3 /* DW_AT_name */
++ .uleb128 0x8 /* DW_FORM_string */
++ .uleb128 0x11 /* DW_AT_low_pc */
++ .uleb128 0x1 /* DW_FORM_addr */
++ .uleb128 0x12 /* DW_AT_high_pc */
++ .uleb128 0x1 /* DW_FORM_addr */
++ .uleb128 0x27 /* DW_AT_prototyped */
++ .uleb128 0xc /* DW_FORM_flag */
++ .uleb128 0x49 /* DW_AT_type */
++ .uleb128 0x13 /* DW_FORM_ref4 */
++ .byte 0x0 /* Terminator */
++ .byte 0x0 /* Terminator */
++
++ .uleb128 0x5 /* Abbrev code */
++ .uleb128 0x24 /* DW_TAG_base_type */
++ .byte 0x0 /* DW_children_no */
++ .uleb128 0xb /* DW_AT_byte_size */
++ .uleb128 0xb /* DW_FORM_data1 */
++ .uleb128 0x3e /* DW_AT_encoding */
++ .uleb128 0xb /* DW_FORM_data1 */
++ .uleb128 0x3 /* DW_AT_name */
++ .uleb128 0x8 /* DW_FORM_string */
++ .byte 0x0 /* Terminator */
++ .byte 0x0 /* Terminator */
++
++ .byte 0x0 /* Terminator */
++ .byte 0x0 /* Terminator */
+Index: gdb-7.2.90.20110525/gdb/testsuite/gdb.dwarf2/dw2-case-insensitive.c
+===================================================================
+--- /dev/null 1970-01-01 00:00:00.000000000 +0000
++++ gdb-7.2.90.20110525/gdb/testsuite/gdb.dwarf2/dw2-case-insensitive.c 2011-05-25 17:13:13.000000000 +0200
+@@ -0,0 +1,38 @@
++/* This testcase is part of GDB, the GNU debugger.
++
++ Copyright 2011 Free Software Foundation, Inc.
++
++ This program is free software; you can redistribute it and/or modify
++ it under the terms of the GNU General Public License as published by
++ the Free Software Foundation; either version 3 of the License, or
++ (at your option) any later version.
++
++ This program is distributed in the hope that it will be useful,
++ but WITHOUT ANY WARRANTY; without even the implied warranty of
++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ GNU General Public License for more details.
++
++ You should have received a copy of the GNU General Public License
++ along with this program. If not, see <http://www.gnu.org/licenses/>. */
++
++/* Use DW_LANG_Fortran90 for case insensitive DWARF. */
++
++void
++FUNC_lang (void)
++{
++}
++
++/* Symbol is present only in ELF .symtab. */
++
++void
++FUNC_symtab (void)
++{
++}
++
++int
++main (void)
++{
++ FUNC_lang ();
++ FUNC_symtab ();
++ return 0;
++}
+Index: gdb-7.2.90.20110525/gdb/testsuite/gdb.dwarf2/dw2-case-insensitive.exp
+===================================================================
+--- /dev/null 1970-01-01 00:00:00.000000000 +0000
++++ gdb-7.2.90.20110525/gdb/testsuite/gdb.dwarf2/dw2-case-insensitive.exp 2011-05-25 17:13:13.000000000 +0200
+@@ -0,0 +1,49 @@
++# Copyright 2011 Free Software Foundation, Inc.
++
++# This program is free software; you can redistribute it and/or modify
++# it under the terms of the GNU General Public License as published by
++# the Free Software Foundation; either version 3 of the License, or
++# (at your option) any later version.
++#
++# This program is distributed in the hope that it will be useful,
++# but WITHOUT ANY WARRANTY; without even the implied warranty of
++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++# GNU General Public License for more details.
++#
++# You should have received a copy of the GNU General Public License
++# along with this program. If not, see <http://www.gnu.org/licenses/>.
++load_lib dwarf.exp
++
++# This test can only be run on targets which support DWARF-2 and use gas.
++if {![dwarf2_support]} {
++ return 0
++}
++
++set testfile "dw2-case-insensitive"
++
++if { [prepare_for_testing ${testfile}.exp ${testfile} [list ${testfile}.c ${testfile}-debug.S] {nodebug}] } {
++ return -1
++}
++
++gdb_test "show case-sensitive" {Case sensitivity in name search is "auto; currently on"\.}
++
++gdb_test "info functions fUnC_lang" \
++ "All functions matching regular expression \"fUnC_lang\":" \
++ "regexp case-sensitive on"
++
++gdb_test "set case-sensitive off" {warning: the current case sensitivity setting does not match the language\.}
++
++gdb_test "info functions fUnC_lang" \
++ "All functions matching regular expression \"fUnC_lang\":\[\r\n\]+File file1.txt:\r\nfoo FUNC_lang\\(void\\);" \
++ "regexp case-sensitive off"
++
++gdb_test "p fuNC_lang" { = {foo \(void\)} 0x[0-9a-f]+ <FUNC_lang>}
++gdb_test "p fuNC_symtab" { = {<text variable, no debug info>} 0x[0-9a-f]+ <FUNC_symtab>}
++
++if {[gdb_breakpoint "fuNC_lang"] == 1} {
++ pass "setting breakpoint at fuNC_lang"
++}
++
++if {[gdb_breakpoint "fuNC_symtab"] == 1} {
++ pass "setting breakpoint at fuNC_symtab"
++}
+Index: gdb-7.2.90.20110525/gdb/utils.c
+===================================================================
+--- gdb-7.2.90.20110525.orig/gdb/utils.c 2011-05-25 17:12:51.000000000 +0200
++++ gdb-7.2.90.20110525/gdb/utils.c 2011-05-25 17:13:13.000000000 +0200
+@@ -3003,10 +3003,12 @@ strcmp_iw (const char *string1, const ch
+ {
+ string2++;
+ }
+- if (*string1 != *string2)
+- {
+- break;
+- }
++ if (case_sensitivity == case_sensitive_on && *string1 != *string2)
++ break;
++ if (case_sensitivity == case_sensitive_off
++ && (tolower ((unsigned char) *string1)
++ != tolower ((unsigned char) *string2)))
++ break;
+ if (*string1 != '\0')
+ {
+ string1++;
+@@ -3027,6 +3029,10 @@ strcmp_iw (const char *string1, const ch
+ strcmp_iw(LIST_ELT, NAME), then the place to start looking is right
+ where this function would put NAME.
+
++ This function must be neutral to the CASE_SENSITIVITY setting as the user
++ may choose it during later lookup. Therefore this function always sorts
++ primarily case-insensitively and secondarily case-sensitively.
++
+ Here are some examples of why using strcmp to sort is a bad idea:
+
+ Whitespace example:
+@@ -3052,8 +3058,10 @@ strcmp_iw (const char *string1, const ch
+ int
+ strcmp_iw_ordered (const char *string1, const char *string2)
+ {
+- /* Formatting stub. */
+- if (1)
++ const char *saved_string1 = string1, *saved_string2 = string2;
++ enum case_sensitivity case_pass = case_sensitive_off;
++
++ for (;;)
+ {
+ /* C1 and C2 are valid only if *string1 != '\0' && *string2 != '\0'.
+ Provide stub characters if we are already at the end of one of the
+@@ -3067,8 +3075,17 @@ strcmp_iw_ordered (const char *string1,
+ while (isspace (*string2))
+ string2++;
+
++ switch (case_pass)
++ {
++ case case_sensitive_off:
++ c1 = tolower ((unsigned char) *string1);
++ c2 = tolower ((unsigned char) *string2);
++ break;
++ case case_sensitive_on:
+ c1 = *string1;
+ c2 = *string2;
++ break;
++ }
+ if (c1 != c2)
+ break;
+
+@@ -3086,7 +3103,7 @@ strcmp_iw_ordered (const char *string1,
+ comparison in the cases where one of them is '\0' or '('. */
+ case '\0':
+ if (*string2 == '\0')
+- return 0;
++ break;
+ else
+ return -1;
+ case '(':
+@@ -3097,9 +3114,22 @@ strcmp_iw_ordered (const char *string1,
+ default:
+ if (*string2 == '\0' || *string2 == '(')
+ return 1;
+- else
+- return c1 - c2;
++ else if (c1 > c2)
++ return 1;
++ else if (c1 < c2)
++ return -1;
++ /* PASSTHRU */
+ }
++
++ if (case_pass == case_sensitive_on)
++ return 0;
++
++ /* Otherwise the strings were equal in case insensitive way, make
++ a more fine grained comparison in a case sensitive way. */
++
++ case_pass = case_sensitive_on;
++ string1 = saved_string1;
++ string2 = saved_string2;
+ }
+ }
+
--- /dev/null
+archer-jankratochvil-readline62
+b13706abbee9646f4de522c0552ddd68d1a4f43a
+
+Index: gdb-7.2.90.20110703/gdb/config.in
+===================================================================
+--- gdb-7.2.90.20110703.orig/gdb/config.in 2011-07-03 10:40:53.000000000 +0200
++++ gdb-7.2.90.20110703/gdb/config.in 2011-07-03 10:41:21.000000000 +0200
+@@ -953,9 +953,6 @@
+ /* Define to `int' if <sys/types.h> does not define. */
+ #undef pid_t
+
+-/* readline-6.0 started to use different name. */
+-#undef readline_echoing_p
+-
+ /* Define to the equivalent of the C99 'restrict' keyword, or to
+ nothing if this is not supported. Do not define if restrict is
+ supported directly. */
+Index: gdb-7.2.90.20110703/gdb/configure
+===================================================================
+--- gdb-7.2.90.20110703.orig/gdb/configure 2011-07-03 10:40:53.000000000 +0200
++++ gdb-7.2.90.20110703/gdb/configure 2011-07-03 10:41:21.000000000 +0200
+@@ -10235,39 +10235,6 @@ if test "$with_system_readline" = yes; t
+ READLINE_DEPS=
+ READLINE_CFLAGS=
+ READLINE_TEXI_INCFLAG=
+-
+- # readline-6.0 started to use the name `_rl_echoing_p'.
+- # `$(READLINE_DIR)/' of bundled readline would not resolve in configure.
+-
+- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for readline_echoing_p" >&5
+-$as_echo_n "checking for readline_echoing_p... " >&6; }
+- save_LIBS=$LIBS
+- LIBS="$LIBS $READLINE"
+- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+-/* end confdefs.h. */
+-
+-int
+-main ()
+-{
+-extern int readline_echoing_p;
+- return readline_echoing_p;
+- ;
+- return 0;
+-}
+-_ACEOF
+-if ac_fn_c_try_link "$LINENO"; then :
+- READLINE_ECHOING_P=yes
+-else
+- READLINE_ECHOING_P=no
+-
+-$as_echo "#define readline_echoing_p _rl_echoing_p" >>confdefs.h
+-
+-fi
+-rm -f core conftest.err conftest.$ac_objext \
+- conftest$ac_exeext conftest.$ac_ext
+- LIBS="$save_LIBS"
+- { $as_echo "$as_me:${as_lineno-$LINENO}: result: $READLINE_ECHOING_P" >&5
+-$as_echo "$READLINE_ECHOING_P" >&6; }
+ else
+ READLINE='$(READLINE_DIR)/libreadline.a'
+ READLINE_DEPS='$(READLINE)'
+Index: gdb-7.2.90.20110703/gdb/configure.ac
+===================================================================
+--- gdb-7.2.90.20110703.orig/gdb/configure.ac 2011-07-03 10:40:53.000000000 +0200
++++ gdb-7.2.90.20110703/gdb/configure.ac 2011-07-03 10:41:21.000000000 +0200
+@@ -732,21 +732,6 @@ if test "$with_system_readline" = yes; t
+ READLINE_DEPS=
+ READLINE_CFLAGS=
+ READLINE_TEXI_INCFLAG=
+-
+- # readline-6.0 started to use the name `_rl_echoing_p'.
+- # `$(READLINE_DIR)/' of bundled readline would not resolve in configure.
+-
+- AC_MSG_CHECKING([for readline_echoing_p])
+- save_LIBS=$LIBS
+- LIBS="$LIBS $READLINE"
+- AC_LINK_IFELSE(AC_LANG_PROGRAM(,[[extern int readline_echoing_p;
+- return readline_echoing_p;]]),
+- [READLINE_ECHOING_P=yes],
+- [READLINE_ECHOING_P=no
+- AC_DEFINE([readline_echoing_p], [_rl_echoing_p],
+- [readline-6.0 started to use different name.])])
+- LIBS="$save_LIBS"
+- AC_MSG_RESULT([$READLINE_ECHOING_P])
+ else
+ READLINE='$(READLINE_DIR)/libreadline.a'
+ READLINE_DEPS='$(READLINE)'
+Index: gdb-7.2.90.20110703/gdb/tui/tui-io.c
+===================================================================
+--- gdb-7.2.90.20110703.orig/gdb/tui/tui-io.c 2011-07-03 10:40:53.000000000 +0200
++++ gdb-7.2.90.20110703/gdb/tui/tui-io.c 2011-07-03 10:41:21.000000000 +0200
+@@ -133,7 +133,7 @@ static Function *tui_old_rl_getc_functio
+ static VFunction *tui_old_rl_redisplay_function;
+ static VFunction *tui_old_rl_prep_terminal;
+ static VFunction *tui_old_rl_deprep_terminal;
+-static int tui_old_readline_echoing_p;
++static int tui_old_rl_echoing_p;
+
+ /* Readline output stream.
+ Should be removed when readline is clean. */
+@@ -506,8 +506,8 @@ tui_rl_display_match_list (char **matche
+ void
+ tui_setup_io (int mode)
+ {
+- extern int readline_echoing_p;
+-
++ extern int _rl_echoing_p;
++
+ if (mode)
+ {
+ /* Redirect readline to TUI. */
+@@ -516,12 +516,12 @@ tui_setup_io (int mode)
+ tui_old_rl_prep_terminal = rl_prep_term_function;
+ tui_old_rl_getc_function = rl_getc_function;
+ tui_old_rl_outstream = rl_outstream;
+- tui_old_readline_echoing_p = readline_echoing_p;
++ tui_old_rl_echoing_p = _rl_echoing_p;
+ rl_redisplay_function = tui_redisplay_readline;
+ rl_deprep_term_function = tui_deprep_terminal;
+ rl_prep_term_function = tui_prep_terminal;
+ rl_getc_function = tui_getc;
+- readline_echoing_p = 0;
++ _rl_echoing_p = 0;
+ rl_outstream = tui_rl_outstream;
+ rl_prompt = 0;
+ rl_completion_display_matches_hook = tui_rl_display_match_list;
+@@ -560,7 +560,7 @@ tui_setup_io (int mode)
+ rl_getc_function = tui_old_rl_getc_function;
+ rl_outstream = tui_old_rl_outstream;
+ rl_completion_display_matches_hook = 0;
+- readline_echoing_p = tui_old_readline_echoing_p;
++ _rl_echoing_p = tui_old_rl_echoing_p;
+ rl_already_prompted = 0;
+
+ /* Save tty for SIGCONT. */
+Index: gdb-7.2.90.20110703/readline/CHANGELOG
+===================================================================
+--- gdb-7.2.90.20110703.orig/readline/CHANGELOG 2011-07-03 10:40:53.000000000 +0200
++++ gdb-7.2.90.20110703/readline/CHANGELOG 2011-07-03 10:41:21.000000000 +0200
+@@ -918,3 +918,178 @@ configure.in
+ - changed release status to `release'
+
+ [readline-5.1 frozen]
++
++ 12/9
++ ----
++[readline-5.1 released]
++
++ 12/14
++ -----
++examples/rlfe/Makefile.in
++ - add @LIBS@ to LIBS assignment to pick up extra libraries from
++ configure
++
++ 1/3/2006
++ --------
++support/shlib-install
++ - Install shared libraries with execute bit set on Linux
++
++ 6/9
++ ---
++[readline-5.2-alpha frozen]
++
++ 6/26
++ ----
++configure.in
++ - set CROSS_COMPILE to the empty string by default, so we don't inherit
++ a random value from the environment
++
++ 7/8
++ ---
++[readline-5.2-alpha released]
++
++
++[readline-5.2-beta released]
++
++ 9/12
++ ----
++config.h.in
++ - add defines for wcscoll, iswctype, iswupper, iswlower, towupper,
++ towlower functions
++ - replace define for wctomb with one for wcrtomb
++ - add defines for wchar_t, wint_t, wctype_t types
++
++ 10/11
++ -----
++[readline-5.2 released]
++
++ 11/9
++ ----
++examples/rlfe/{configure.in,Makefile.in,config.h.in,rlfe.c,pty.c}
++ - portability fixes from Mike Frysinger <vapier@gentoo.org>
++
++ 11/21
++ -----
++Makefile.in
++ - add `install-examples' and `uninstall-examples' targets
++
++examples/Makefile.in
++ - add correct variables to build examples on Windows
++ - add appropriate rules to install and uninstall example sources in
++ $(datadir)/readline
++
++ 11/27
++ -----
++config.h.in
++ - move #undef of HAVE_STRCOLL out of config.h.in, since autoconf tries
++ to substitute it based on configure tests
++
++ 4/27/2007
++ ---------
++examples/autoconf
++ - new directory with example autoconf macros to detect readline and
++ return information about the installed version
++
++ 6/13
++ ----
++support/shlib-install
++ - changes to support AIX 5.x shared library installation
++
++ 3/20/2008
++ ---------
++support/shlib-install
++ - add support for NetBSD and Interix shared library installation
++
++ 4/22
++ ----
++support/wcwidth.c
++ - updated implementation from 2007-05
++
++ 7/18
++ ----
++support/shlib-install
++ - support for mingw32, contributed by Carlo Bramix <carlo.bramix@libero.it>
++
++ 8/4
++ ---
++configure.in
++ - changed to readline-6.0
++
++ 8/18
++ ----
++support/config.{guess,sub}
++ - updated to newer versions from autoconf-2.62 distribution
++
++ 3/5/2009
++ --------
++support/shlib-install
++ - take a new -V host_vendor argument
++ - add ${host_vendor} to string tested in case statement for symlink
++ creation section
++ - add support for FreeBSD/gentoo, which uses Linux library naming
++ scheme
++ - change FreeBSD symlink rules, since FreeBSD 7+ has only ELF shared
++ libraries. DragonflyBSD rules are the same. Fix from Timothy
++ Redaelli <drizzt@gentoo.org>
++
++shlib/Makefile.in
++ - add definition of host_vendor, substituted by configure
++ - add -V host_vendor argument to all invocations of shlib-install.
++ Fix from Timothy Redaelli <drizzt@gentoo.org>
++
++ 3/10
++ ----
++configure.in
++ - add call to AC_SYS_LARGEFILE for readdir and largefile support on
++ Linux
++
++config.h.in
++ - add _FILE_OFFSET_BITS define
++
++ 4/19
++ ----
++Makefile.in
++ - add targets for making and installing documentation required by GNU
++ coding standards. Fix from Joseph Myers <joseph@codesourcery.com>
++
++posixselect.h
++ - pick up from bash. Inspired by Mike Frysinger <vapier@gentoo.org>
++
++ 10/28
++ -----
++support/shlib-install
++ - decrease the default version of FreeBSD that installs shared libraries
++ to 4.x. Advice from Peter Jeremy <peterjeremy@acm.org>
++
++ 12/18
++ -----
++[readline-6.1-rc1 released]
++
++ 12/23
++ -----
++doc/Makefile.in
++ - make sure $(topdir) is not ".." before removing all of the formatted
++ documentation in `make distclean'. $(topdir) is set to `..' if
++ readline is being built in the source directory. Fixes problem
++ noticed by THOUMIN Damien <thoumin@ipanematech.com>
++
++ 12/29
++ -----
++[readline-6.1 frozen]
++
++ 2/5/2010
++ --------
++examples/Makefile.in
++ - make sure to install example C files using $(srcdir)/$$f in case
++ we're building outside the source directory. Bug report and fix
++ from Peter Breitenlohner <peb@mppmu.mpg.de>
++
++ 7/25
++ ----
++xfree.c
++ - new file with xfree() implementation, moved from xmalloc.c
++
++ 12/28
++ -----
++{examples,shlib}/Makefile.in
++ - Cygwin-based changes from Eric Blake <eblake@redhat.com>
+Index: gdb-7.2.90.20110703/readline/CHANGES
+===================================================================
+--- gdb-7.2.90.20110703.orig/readline/CHANGES 2011-07-03 10:40:53.000000000 +0200
++++ gdb-7.2.90.20110703/readline/CHANGES 2011-07-03 10:41:21.000000000 +0200
+@@ -1,3 +1,320 @@
++This document details the changes between this version, readline-6.2,
++and the previous version, readline-6.1.
++
++1. Changes to Readline
++
++a. Fixed a bug that caused the unconverted filename to be added to the list of
++ completions when the application specified filename conversion functions.
++
++b. Fixed a bug that caused the wrong filename to be passed to opendir when the
++ application has specified a filename dequoting function.
++
++c. Fixed a bug when repeating a character search in vi mode in the case where
++ there was no search to repeat.
++
++d. When show-all-if-ambiguous is set, the completion routines no longer insert
++ a common match prefix that is shorter than the text being completed.
++
++e. The full set of vi editing commands may now be used in callback mode.
++
++f. Fixed a bug that caused readline to not update its idea of the terminal
++ dimensions while running in `no-echo' mode.
++
++h. Fixed a bug that caused readline to dump core if an application called
++ rl_prep_terminal without setting rl_instream.
++
++i. Fixed a bug that caused meta-prefixed characters bound to incremental
++ search forward or backward to not be recognized if they were typed
++ subsequently.
++
++j. The incremental search code treats key sequences that map to the same
++ functions as (default) ^G, ^W, and ^Y as equivalent to those characters.
++
++k. Fixed a bug in menu-complete that caused it to misbehave with large
++ negative argument.
++
++l. Fixed a bug that caused vi-mode yank-last-arg to ring the bell when invoked
++ at the end of the line.
++
++m. Fixed a bug that made an explicit argument of 0 to yank-last-arg behave
++ as if it were a negative argument.
++
++n. Fixed a bug that caused directory names in words to be completed to not
++ be dequoted correctly.
++
++2. New Features in Readline
++
++a. The history library does not try to write the history filename in the
++ current directory if $HOME is unset. This closes a potential security
++ problem if the application does not specify a history filename.
++
++b. New bindable variable `completion-display-width' to set the number of
++ columns used when displaying completions.
++
++c. New bindable variable `completion-case-map' to cause case-insensitive
++ completion to treat `-' and `_' as identical.
++
++d. There are new bindable vi-mode command names to avoid readline's case-
++ insensitive matching not allowing them to be bound separately.
++
++e. New bindable variable `menu-complete-display-prefix' causes the menu
++ completion code to display the common prefix of the possible completions
++ before cycling through the list, instead of after.
++
++-------------------------------------------------------------------------------
++This document details the changes between this version, readline-6.1,
++and the previous version, readline-6.0.
++
++1. Changes to Readline
++
++a. The SIGWINCH signal handler now avoids calling the redisplay code if
++ one arrives while in the middle of redisplay.
++
++b. Changes to the timeout code to make sure that timeout values greater
++ than one second are handled better.
++
++c. Fixed a bug in the redisplay code that was triggered by a prompt
++ containing invisible characters exactly the width of the screen.
++
++d. Fixed a bug in the redisplay code encountered when running in horizontal
++ scroll mode.
++
++e. Fixed a bug that prevented menu completion from properly completing
++ filenames.
++
++f. Fixed a redisplay bug caused by a multibyte character causing a line to
++ wrap.
++
++g. Fixed a bug that caused key sequences of two characters to not be
++ recognized when a longer sequence identical in the first two characters
++ was bound.
++
++h. Fixed a bug that caused history expansion to be attempted on $'...'
++ single-quoted strings.
++
++i. Fixed a bug that caused incorrect redisplay when the prompt contained
++ multibyte characters in an `invisible' sequence bracketed by \[ and
++ \].
++
++j. Fixed a bug that caused history expansion to short-circuit after
++ encountering a multibyte character.
++
++k. Fixed a bug that caused applications using the callback interface to not
++ react to SIGINT (or other signals) until another character arrived.
++
++2. New Features in Readline
++
++a. New bindable function: menu-complete-backward.
++
++b. In the vi insertion keymap, C-n is now bound to menu-complete by default,
++ and C-p to menu-complete-backward.
++
++c. When in vi command mode, repeatedly hitting ESC now does nothing, even
++ when ESC introduces a bound key sequence. This is closer to how
++ historical vi behaves.
++
++d. New bindable function: skip-csi-sequence. Can be used as a default to
++ consume key sequences generated by keys like Home and End without having
++ to bind all keys.
++
++e. New application-settable function: rl_filename_rewrite_hook. Can be used
++ to rewite or modify filenames read from the file system before they are
++ compared to the word to be completed.
++
++f. New bindable variable: skip-completed-text, active when completing in the
++ middle of a word. If enabled, it means that characters in the completion
++ that match characters in the remainder of the word are "skipped" rather
++ than inserted into the line.
++
++g. The pre-readline-6.0 version of menu completion is available as
++ "old-menu-complete" for users who do not like the readline-6.0 version.
++
++h. New bindable variable: echo-control-characters. If enabled, and the
++ tty ECHOCTL bit is set, controls the echoing of characters corresponding
++ to keyboard-generated signals.
++
++i. New bindable variable: enable-meta-key. Controls whether or not readline
++ sends the smm/rmm sequences if the terminal indicates it has a meta key
++ that enables eight-bit characters.
++
++-------------------------------------------------------------------------------
++This document details the changes between this version, readline-6.0,
++and the previous version, readline-5.2.
++
++1. Changes to Readline
++
++a. Fixed a number of redisplay errors in environments supporting multibyte
++ characters.
++
++b. Fixed bugs in vi command mode that caused motion commands to inappropriately
++ set the mark.
++
++c. When using the arrow keys in vi insertion mode, readline allows movement
++ beyond the current end of the line (unlike command mode).
++
++d. Fixed bugs that caused readline to loop when the terminal has been taken
++ away and reads return -1/EIO.
++
++e. Fixed bugs in redisplay occurring when displaying prompts containing
++ invisible characters.
++
++f. Fixed a bug that caused the completion append character to not be reset to
++ the default after an application-specified completion function changed it.
++
++g. Fixed a problem that caused incorrect positioning of the cursor while in
++ emacs editing mode when moving forward at the end of a line while using
++ a locale supporting multibyte characters.
++
++h. Fixed an off-by-one error that caused readline to drop every 511th
++ character of buffered input.
++
++i. Fixed a bug that resulted in SIGTERM not being caught or cleaned up.
++
++j. Fixed redisplay bugs caused by multiline prompts with invisible characters
++ or no characters following the final newline.
++
++k. Fixed redisplay bug caused by prompts consisting solely of invisible
++ characters.
++
++l. Fixed a bug in the code that buffers characters received very quickly in
++ succession which caused characters to be dropped.
++
++m. Fixed a bug that caused readline to reference uninitialized data structures
++ if it received a SIGWINCH before completing initialzation.
++
++n. Fixed a bug that caused the vi-mode `last command' to be set incorrectly
++ and therefore unrepeatable.
++
++o. Fixed a bug that caused readline to disable echoing when it was being used
++ with an output file descriptor that was not a terminal.
++
++p. Readline now blocks SIGINT while manipulating internal data structures
++ during redisplay.
++
++q. Fixed a bug in redisplay that caused readline to segfault when pasting a
++ very long line (over 130,000 characters).
++
++r. Fixed bugs in redisplay when using prompts with no visible printing
++ characters.
++
++s. Fixed a bug that caused redisplay errors when using prompts with invisible
++ characters and numeric arguments to a command in a multibyte locale.
++
++t. Fixed a bug that caused redisplay errors when using prompts with invisible
++ characters spanning more than two physical screen lines.
++
++2. New Features in Readline
++
++a. A new variable, rl_sort_completion_matches; allows applications to inhibit
++ match list sorting (but beware: some things don't work right if
++ applications do this).
++
++b. A new variable, rl_completion_invoking_key; allows applications to discover
++ the key that invoked rl_complete or rl_menu_complete.
++
++c. The functions rl_block_sigint and rl_release_sigint are now public and
++ available to calling applications who want to protect critical sections
++ (like redisplay).
++
++d. The functions rl_save_state and rl_restore_state are now public and
++ available to calling applications; documented rest of readline's state
++ flag values.
++
++e. A new user-settable variable, `history-size', allows setting the maximum
++ number of entries in the history list.
++
++f. There is a new implementation of menu completion, with several improvements
++ over the old; the most notable improvement is a better `completions
++ browsing' mode.
++
++g. The menu completion code now uses the rl_menu_completion_entry_function
++ variable, allowing applications to provide their own menu completion
++ generators.
++
++h. There is support for replacing a prefix of a pathname with a `...' when
++ displaying possible completions. This is controllable by setting the
++ `completion-prefix-display-length' variable. Matches with a common prefix
++ longer than this value have the common prefix replaced with `...'.
++
++i. There is a new `revert-all-at-newline' variable. If enabled, readline will
++ undo all outstanding changes to all history lines when `accept-line' is
++ executed.
++
++-------------------------------------------------------------------------------
++This document details the changes between this version, readline-5.2,
++and the previous version, readline-5.1.
++
++1. Changes to Readline
++
++a. Fixed a problem that caused segmentation faults when using readline in
++ callback mode and typing consecutive DEL characters on an empty line.
++
++b. Fixed several redisplay problems with multibyte characters, all having to
++ do with the different code paths and variable meanings between single-byte
++ and multibyte character redisplay.
++
++c. Fixed a problem with key sequence translation when presented with the
++ sequence \M-\C-x.
++
++d. Fixed a problem that prevented the `a' command in vi mode from being
++ undone and redone properly.
++
++e. Fixed a problem that prevented empty inserts in vi mode from being undone
++ properly.
++
++f. Fixed a problem that caused readline to initialize with an incorrect idea
++ of whether or not the terminal can autowrap.
++
++g. Fixed output of key bindings (like bash `bind -p') to honor the setting of
++ convert-meta and use \e where appropriate.
++
++h. Changed the default filename completion function to call the filename
++ dequoting function if the directory completion hook isn't set. This means
++ that any directory completion hooks need to dequote the directory name,
++ since application-specific hooks need to know how the word was quoted,
++ even if no other changes are made.
++
++i. Fixed a bug with creating the prompt for a non-interactive search string
++ when there are non-printing characters in the primary prompt.
++
++j. Fixed a bug that caused prompts with invisible characters to be redrawn
++ multiple times in a multibyte locale.
++
++k. Fixed a bug that could cause the key sequence scanning code to return the
++ wrong function.
++
++l. Fixed a problem with the callback interface that caused it to fail when
++ using multi-character keyboard macros.
++
++m. Fixed a bug that could cause a core dump when an edited history entry was
++ re-executed under certain conditions.
++
++n. Fixed a bug that caused readline to reference freed memory when attmpting
++ to display a portion of the prompt.
++
++o. Fixed a bug with prompt redisplay in a multi-byte locale to avoid redrawing
++ the prompt and input line multiple times.
++
++p. Fixed history expansion to not be confused by here-string redirection.
++
++q. Readline no longer treats read errors by converting them to newlines, as
++ it does with EOF. This caused partial lines to be returned from readline().
++
++r. Fixed a redisplay bug that occurred in multibyte-capable locales when the
++ prompt was one character longer than the screen width.
++
++2. New Features in Readline
++
++a. Calling applications can now set the keyboard timeout to 0, allowing
++ poll-like behavior.
++
++b. The value of SYS_INPUTRC (configurable at compilation time) is now used as
++ the default last-ditch startup file.
++
++c. The history file reading functions now allow windows-like \r\n line
++ terminators.
++
++-------------------------------------------------------------------------------
+ This document details the changes between this version, readline-5.1,
+ and the previous version, readline-5.0.
+
+Index: gdb-7.2.90.20110703/readline/COPYING
+===================================================================
+--- gdb-7.2.90.20110703.orig/readline/COPYING 2011-07-03 10:40:53.000000000 +0200
++++ gdb-7.2.90.20110703/readline/COPYING 2011-07-03 10:41:21.000000000 +0200
+@@ -1,285 +1,626 @@
+- GNU GENERAL PUBLIC LICENSE
+- Version 2, June 1991
++ GNU GENERAL PUBLIC LICENSE
++ Version 3, 29 June 2007
+
+- Copyright (C) 1989, 1991 Free Software Foundation, Inc.
+- 59 Temple Place, Suite 330, Boston, MA 02111 USA
++ Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+- Preamble
++ Preamble
+
+- The licenses for most software are designed to take away your
+-freedom to share and change it. By contrast, the GNU General Public
+-License is intended to guarantee your freedom to share and change free
+-software--to make sure the software is free for all its users. This
+-General Public License applies to most of the Free Software
+-Foundation's software and to any other program whose authors commit to
+-using it. (Some other Free Software Foundation software is covered by
+-the GNU Library General Public License instead.) You can apply it to
++ The GNU General Public License is a free, copyleft license for
++software and other kinds of works.
++
++ The licenses for most software and other practical works are designed
++to take away your freedom to share and change the works. By contrast,
++the GNU General Public License is intended to guarantee your freedom to
++share and change all versions of a program--to make sure it remains free
++software for all its users. We, the Free Software Foundation, use the
++GNU General Public License for most of our software; it applies also to
++any other work released this way by its authors. You can apply it to
+ your programs, too.
+
+ When we speak of free software, we are referring to freedom, not
+ price. Our General Public Licenses are designed to make sure that you
+ have the freedom to distribute copies of free software (and charge for
+-this service if you wish), that you receive source code or can get it
+-if you want it, that you can change the software or use pieces of it
+-in new free programs; and that you know you can do these things.
+-
+- To protect your rights, we need to make restrictions that forbid
+-anyone to deny you these rights or to ask you to surrender the rights.
+-These restrictions translate to certain responsibilities for you if you
+-distribute copies of the software, or if you modify it.
++them if you wish), that you receive source code or can get it if you
++want it, that you can change the software or use pieces of it in new
++free programs, and that you know you can do these things.
++
++ To protect your rights, we need to prevent others from denying you
++these rights or asking you to surrender the rights. Therefore, you have
++certain responsibilities if you distribute copies of the software, or if
++you modify it: responsibilities to respect the freedom of others.
+
+ For example, if you distribute copies of such a program, whether
+-gratis or for a fee, you must give the recipients all the rights that
+-you have. You must make sure that they, too, receive or can get the
+-source code. And you must show them these terms so they know their
+-rights.
+-
+- We protect your rights with two steps: (1) copyright the software, and
+-(2) offer you this license which gives you legal permission to copy,
+-distribute and/or modify the software.
+-
+- Also, for each author's protection and ours, we want to make certain
+-that everyone understands that there is no warranty for this free
+-software. If the software is modified by someone else and passed on, we
+-want its recipients to know that what they have is not the original, so
+-that any problems introduced by others will not reflect on the original
+-authors' reputations.
+-
+- Finally, any free program is threatened constantly by software
+-patents. We wish to avoid the danger that redistributors of a free
+-program will individually obtain patent licenses, in effect making the
+-program proprietary. To prevent this, we have made it clear that any
+-patent must be licensed for everyone's free use or not licensed at all.
++gratis or for a fee, you must pass on to the recipients the same
++freedoms that you received. You must make sure that they, too, receive
++or can get the source code. And you must show them these terms so they
++know their rights.
++
++ Developers that use the GNU GPL protect your rights with two steps:
++(1) assert copyright on the software, and (2) offer you this License
++giving you legal permission to copy, distribute and/or modify it.
++
++ For the developers' and authors' protection, the GPL clearly explains
++that there is no warranty for this free software. For both users' and
++authors' sake, the GPL requires that modified versions be marked as
++changed, so that their problems will not be attributed erroneously to
++authors of previous versions.
++
++ Some devices are designed to deny users access to install or run
++modified versions of the software inside them, although the manufacturer
++can do so. This is fundamentally incompatible with the aim of
++protecting users' freedom to change the software. The systematic
++pattern of such abuse occurs in the area of products for individuals to
++use, which is precisely where it is most unacceptable. Therefore, we
++have designed this version of the GPL to prohibit the practice for those
++products. If such problems arise substantially in other domains, we
++stand ready to extend this provision to those domains in future versions
++of the GPL, as needed to protect the freedom of users.
++
++ Finally, every program is threatened constantly by software patents.
++States should not allow patents to restrict development and use of
++software on general-purpose computers, but in those that do, we wish to
++avoid the special danger that patents applied to a free program could
++make it effectively proprietary. To prevent this, the GPL assures that
++patents cannot be used to render the program non-free.
+
+ The precise terms and conditions for copying, distribution and
+ modification follow.
+-\f
+- GNU GENERAL PUBLIC LICENSE
+- TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+-
+- 0. This License applies to any program or other work which contains
+-a notice placed by the copyright holder saying it may be distributed
+-under the terms of this General Public License. The "Program", below,
+-refers to any such program or work, and a "work based on the Program"
+-means either the Program or any derivative work under copyright law:
+-that is to say, a work containing the Program or a portion of it,
+-either verbatim or with modifications and/or translated into another
+-language. (Hereinafter, translation is included without limitation in
+-the term "modification".) Each licensee is addressed as "you".
+-
+-Activities other than copying, distribution and modification are not
+-covered by this License; they are outside its scope. The act of
+-running the Program is not restricted, and the output from the Program
+-is covered only if its contents constitute a work based on the
+-Program (independent of having been made by running the Program).
+-Whether that is true depends on what the Program does.
+-
+- 1. You may copy and distribute verbatim copies of the Program's
+-source code as you receive it, in any medium, provided that you
+-conspicuously and appropriately publish on each copy an appropriate
+-copyright notice and disclaimer of warranty; keep intact all the
+-notices that refer to this License and to the absence of any warranty;
+-and give any other recipients of the Program a copy of this License
+-along with the Program.
+-
+-You may charge a fee for the physical act of transferring a copy, and
+-you may at your option offer warranty protection in exchange for a fee.
+-
+- 2. You may modify your copy or copies of the Program or any portion
+-of it, thus forming a work based on the Program, and copy and
+-distribute such modifications or work under the terms of Section 1
+-above, provided that you also meet all of these conditions:
+-
+- a) You must cause the modified files to carry prominent notices
+- stating that you changed the files and the date of any change.
+-
+- b) You must cause any work that you distribute or publish, that in
+- whole or in part contains or is derived from the Program or any
+- part thereof, to be licensed as a whole at no charge to all third
+- parties under the terms of this License.
+-
+- c) If the modified program normally reads commands interactively
+- when run, you must cause it, when started running for such
+- interactive use in the most ordinary way, to print or display an
+- announcement including an appropriate copyright notice and a
+- notice that there is no warranty (or else, saying that you provide
+- a warranty) and that users may redistribute the program under
+- these conditions, and telling the user how to view a copy of this
+- License. (Exception: if the Program itself is interactive but
+- does not normally print such an announcement, your work based on
+- the Program is not required to print an announcement.)
+-\f
+-These requirements apply to the modified work as a whole. If
+-identifiable sections of that work are not derived from the Program,
+-and can be reasonably considered independent and separate works in
+-themselves, then this License, and its terms, do not apply to those
+-sections when you distribute them as separate works. But when you
+-distribute the same sections as part of a whole which is a work based
+-on the Program, the distribution of the whole must be on the terms of
+-this License, whose permissions for other licensees extend to the
+-entire whole, and thus to each and every part regardless of who wrote it.
+-
+-Thus, it is not the intent of this section to claim rights or contest
+-your rights to work written entirely by you; rather, the intent is to
+-exercise the right to control the distribution of derivative or
+-collective works based on the Program.
+-
+-In addition, mere aggregation of another work not based on the Program
+-with the Program (or with a work based on the Program) on a volume of
+-a storage or distribution medium does not bring the other work under
+-the scope of this License.
+-
+- 3. You may copy and distribute the Program (or a work based on it,
+-under Section 2) in object code or executable form under the terms of
+-Sections 1 and 2 above provided that you also do one of the following:
+-
+- a) Accompany it with the complete corresponding machine-readable
+- source code, which must be distributed under the terms of Sections
+- 1 and 2 above on a medium customarily used for software interchange; or,
+-
+- b) Accompany it with a written offer, valid for at least three
+- years, to give any third party, for a charge no more than your
+- cost of physically performing source distribution, a complete
+- machine-readable copy of the corresponding source code, to be
+- distributed under the terms of Sections 1 and 2 above on a medium
+- customarily used for software interchange; or,
+-
+- c) Accompany it with the information you received as to the offer
+- to distribute corresponding source code. (This alternative is
+- allowed only for noncommercial distribution and only if you
+- received the program in object code or executable form with such
+- an offer, in accord with Subsection b above.)
+-
+-The source code for a work means the preferred form of the work for
+-making modifications to it. For an executable work, complete source
+-code means all the source code for all modules it contains, plus any
+-associated interface definition files, plus the scripts used to
+-control compilation and installation of the executable. However, as a
+-special exception, the source code distributed need not include
+-anything that is normally distributed (in either source or binary
+-form) with the major components (compiler, kernel, and so on) of the
+-operating system on which the executable runs, unless that component
+-itself accompanies the executable.
+-
+-If distribution of executable or object code is made by offering
+-access to copy from a designated place, then offering equivalent
+-access to copy the source code from the same place counts as
+-distribution of the source code, even though third parties are not
+-compelled to copy the source along with the object code.
+-\f
+- 4. You may not copy, modify, sublicense, or distribute the Program
+-except as expressly provided under this License. Any attempt
+-otherwise to copy, modify, sublicense or distribute the Program is
+-void, and will automatically terminate your rights under this License.
+-However, parties who have received copies, or rights, from you under
+-this License will not have their licenses terminated so long as such
+-parties remain in full compliance.
+-
+- 5. You are not required to accept this License, since you have not
+-signed it. However, nothing else grants you permission to modify or
+-distribute the Program or its derivative works. These actions are
+-prohibited by law if you do not accept this License. Therefore, by
+-modifying or distributing the Program (or any work based on the
+-Program), you indicate your acceptance of this License to do so, and
+-all its terms and conditions for copying, distributing or modifying
+-the Program or works based on it.
+-
+- 6. Each time you redistribute the Program (or any work based on the
+-Program), the recipient automatically receives a license from the
+-original licensor to copy, distribute or modify the Program subject to
+-these terms and conditions. You may not impose any further
+-restrictions on the recipients' exercise of the rights granted herein.
+-You are not responsible for enforcing compliance by third parties to
++
++ TERMS AND CONDITIONS
++
++ 0. Definitions.
++
++ "This License" refers to version 3 of the GNU General Public License.
++
++ "Copyright" also means copyright-like laws that apply to other kinds of
++works, such as semiconductor masks.
++
++ "The Program" refers to any copyrightable work licensed under this
++License. Each licensee is addressed as "you". "Licensees" and
++"recipients" may be individuals or organizations.
++
++ To "modify" a work means to copy from or adapt all or part of the work
++in a fashion requiring copyright permission, other than the making of an
++exact copy. The resulting work is called a "modified version" of the
++earlier work or a work "based on" the earlier work.
++
++ A "covered work" means either the unmodified Program or a work based
++on the Program.
++
++ To "propagate" a work means to do anything with it that, without
++permission, would make you directly or secondarily liable for
++infringement under applicable copyright law, except executing it on a
++computer or modifying a private copy. Propagation includes copying,
++distribution (with or without modification), making available to the
++public, and in some countries other activities as well.
++
++ To "convey" a work means any kind of propagation that enables other
++parties to make or receive copies. Mere interaction with a user through
++a computer network, with no transfer of a copy, is not conveying.
++
++ An interactive user interface displays "Appropriate Legal Notices"
++to the extent that it includes a convenient and prominently visible
++feature that (1) displays an appropriate copyright notice, and (2)
++tells the user that there is no warranty for the work (except to the
++extent that warranties are provided), that licensees may convey the
++work under this License, and how to view a copy of this License. If
++the interface presents a list of user commands or options, such as a
++menu, a prominent item in the list meets this criterion.
++
++ 1. Source Code.
++
++ The "source code" for a work means the preferred form of the work
++for making modifications to it. "Object code" means any non-source
++form of a work.
++
++ A "Standard Interface" means an interface that either is an official
++standard defined by a recognized standards body, or, in the case of
++interfaces specified for a particular programming language, one that
++is widely used among developers working in that language.
++
++ The "System Libraries" of an executable work include anything, other
++than the work as a whole, that (a) is included in the normal form of
++packaging a Major Component, but which is not part of that Major
++Component, and (b) serves only to enable use of the work with that
++Major Component, or to implement a Standard Interface for which an
++implementation is available to the public in source code form. A
++"Major Component", in this context, means a major essential component
++(kernel, window system, and so on) of the specific operating system
++(if any) on which the executable work runs, or a compiler used to
++produce the work, or an object code interpreter used to run it.
++
++ The "Corresponding Source" for a work in object code form means all
++the source code needed to generate, install, and (for an executable
++work) run the object code and to modify the work, including scripts to
++control those activities. However, it does not include the work's
++System Libraries, or general-purpose tools or generally available free
++programs which are used unmodified in performing those activities but
++which are not part of the work. For example, Corresponding Source
++includes interface definition files associated with source files for
++the work, and the source code for shared libraries and dynamically
++linked subprograms that the work is specifically designed to require,
++such as by intimate data communication or control flow between those
++subprograms and other parts of the work.
++
++ The Corresponding Source need not include anything that users
++can regenerate automatically from other parts of the Corresponding
++Source.
++
++ The Corresponding Source for a work in source code form is that
++same work.
++
++ 2. Basic Permissions.
++
++ All rights granted under this License are granted for the term of
++copyright on the Program, and are irrevocable provided the stated
++conditions are met. This License explicitly affirms your unlimited
++permission to run the unmodified Program. The output from running a
++covered work is covered by this License only if the output, given its
++content, constitutes a covered work. This License acknowledges your
++rights of fair use or other equivalent, as provided by copyright law.
++
++ You may make, run and propagate covered works that you do not
++convey, without conditions so long as your license otherwise remains
++in force. You may convey covered works to others for the sole purpose
++of having them make modifications exclusively for you, or provide you
++with facilities for running those works, provided that you comply with
++the terms of this License in conveying all material for which you do
++not control copyright. Those thus making or running the covered works
++for you must do so exclusively on your behalf, under your direction
++and control, on terms that prohibit them from making any copies of
++your copyrighted material outside their relationship with you.
++
++ Conveying under any other circumstances is permitted solely under
++the conditions stated below. Sublicensing is not allowed; section 10
++makes it unnecessary.
++
++ 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
++
++ No covered work shall be deemed part of an effective technological
++measure under any applicable law fulfilling obligations under article
++11 of the WIPO copyright treaty adopted on 20 December 1996, or
++similar laws prohibiting or restricting circumvention of such
++measures.
++
++ When you convey a covered work, you waive any legal power to forbid
++circumvention of technological measures to the extent such circumvention
++is effected by exercising rights under this License with respect to
++the covered work, and you disclaim any intention to limit operation or
++modification of the work as a means of enforcing, against the work's
++users, your or third parties' legal rights to forbid circumvention of
++technological measures.
++
++ 4. Conveying Verbatim Copies.
++
++ You may convey verbatim copies of the Program's source code as you
++receive it, in any medium, provided that you conspicuously and
++appropriately publish on each copy an appropriate copyright notice;
++keep intact all notices stating that this License and any
++non-permissive terms added in accord with section 7 apply to the code;
++keep intact all notices of the absence of any warranty; and give all
++recipients a copy of this License along with the Program.
++
++ You may charge any price or no price for each copy that you convey,
++and you may offer support or warranty protection for a fee.
++
++ 5. Conveying Modified Source Versions.
++
++ You may convey a work based on the Program, or the modifications to
++produce it from the Program, in the form of source code under the
++terms of section 4, provided that you also meet all of these conditions:
++
++ a) The work must carry prominent notices stating that you modified
++ it, and giving a relevant date.
++
++ b) The work must carry prominent notices stating that it is
++ released under this License and any conditions added under section
++ 7. This requirement modifies the requirement in section 4 to
++ "keep intact all notices".
++
++ c) You must license the entire work, as a whole, under this
++ License to anyone who comes into possession of a copy. This
++ License will therefore apply, along with any applicable section 7
++ additional terms, to the whole of the work, and all its parts,
++ regardless of how they are packaged. This License gives no
++ permission to license the work in any other way, but it does not
++ invalidate such permission if you have separately received it.
++
++ d) If the work has interactive user interfaces, each must display
++ Appropriate Legal Notices; however, if the Program has interactive
++ interfaces that do not display Appropriate Legal Notices, your
++ work need not make them do so.
++
++ A compilation of a covered work with other separate and independent
++works, which are not by their nature extensions of the covered work,
++and which are not combined with it such as to form a larger program,
++in or on a volume of a storage or distribution medium, is called an
++"aggregate" if the compilation and its resulting copyright are not
++used to limit the access or legal rights of the compilation's users
++beyond what the individual works permit. Inclusion of a covered work
++in an aggregate does not cause this License to apply to the other
++parts of the aggregate.
++
++ 6. Conveying Non-Source Forms.
++
++ You may convey a covered work in object code form under the terms
++of sections 4 and 5, provided that you also convey the
++machine-readable Corresponding Source under the terms of this License,
++in one of these ways:
++
++ a) Convey the object code in, or embodied in, a physical product
++ (including a physical distribution medium), accompanied by the
++ Corresponding Source fixed on a durable physical medium
++ customarily used for software interchange.
++
++ b) Convey the object code in, or embodied in, a physical product
++ (including a physical distribution medium), accompanied by a
++ written offer, valid for at least three years and valid for as
++ long as you offer spare parts or customer support for that product
++ model, to give anyone who possesses the object code either (1) a
++ copy of the Corresponding Source for all the software in the
++ product that is covered by this License, on a durable physical
++ medium customarily used for software interchange, for a price no
++ more than your reasonable cost of physically performing this
++ conveying of source, or (2) access to copy the
++ Corresponding Source from a network server at no charge.
++
++ c) Convey individual copies of the object code with a copy of the
++ written offer to provide the Corresponding Source. This
++ alternative is allowed only occasionally and noncommercially, and
++ only if you received the object code with such an offer, in accord
++ with subsection 6b.
++
++ d) Convey the object code by offering access from a designated
++ place (gratis or for a charge), and offer equivalent access to the
++ Corresponding Source in the same way through the same place at no
++ further charge. You need not require recipients to copy the
++ Corresponding Source along with the object code. If the place to
++ copy the object code is a network server, the Corresponding Source
++ may be on a different server (operated by you or a third party)
++ that supports equivalent copying facilities, provided you maintain
++ clear directions next to the object code saying where to find the
++ Corresponding Source. Regardless of what server hosts the
++ Corresponding Source, you remain obligated to ensure that it is
++ available for as long as needed to satisfy these requirements.
++
++ e) Convey the object code using peer-to-peer transmission, provided
++ you inform other peers where the object code and Corresponding
++ Source of the work are being offered to the general public at no
++ charge under subsection 6d.
++
++ A separable portion of the object code, whose source code is excluded
++from the Corresponding Source as a System Library, need not be
++included in conveying the object code work.
++
++ A "User Product" is either (1) a "consumer product", which means any
++tangible personal property which is normally used for personal, family,
++or household purposes, or (2) anything designed or sold for incorporation
++into a dwelling. In determining whether a product is a consumer product,
++doubtful cases shall be resolved in favor of coverage. For a particular
++product received by a particular user, "normally used" refers to a
++typical or common use of that class of product, regardless of the status
++of the particular user or of the way in which the particular user
++actually uses, or expects or is expected to use, the product. A product
++is a consumer product regardless of whether the product has substantial
++commercial, industrial or non-consumer uses, unless such uses represent
++the only significant mode of use of the product.
++
++ "Installation Information" for a User Product means any methods,
++procedures, authorization keys, or other information required to install
++and execute modified versions of a covered work in that User Product from
++a modified version of its Corresponding Source. The information must
++suffice to ensure that the continued functioning of the modified object
++code is in no case prevented or interfered with solely because
++modification has been made.
++
++ If you convey an object code work under this section in, or with, or
++specifically for use in, a User Product, and the conveying occurs as
++part of a transaction in which the right of possession and use of the
++User Product is transferred to the recipient in perpetuity or for a
++fixed term (regardless of how the transaction is characterized), the
++Corresponding Source conveyed under this section must be accompanied
++by the Installation Information. But this requirement does not apply
++if neither you nor any third party retains the ability to install
++modified object code on the User Product (for example, the work has
++been installed in ROM).
++
++ The requirement to provide Installation Information does not include a
++requirement to continue to provide support service, warranty, or updates
++for a work that has been modified or installed by the recipient, or for
++the User Product in which it has been modified or installed. Access to a
++network may be denied when the modification itself materially and
++adversely affects the operation of the network or violates the rules and
++protocols for communication across the network.
++
++ Corresponding Source conveyed, and Installation Information provided,
++in accord with this section must be in a format that is publicly
++documented (and with an implementation available to the public in
++source code form), and must require no special password or key for
++unpacking, reading or copying.
++
++ 7. Additional Terms.
++
++ "Additional permissions" are terms that supplement the terms of this
++License by making exceptions from one or more of its conditions.
++Additional permissions that are applicable to the entire Program shall
++be treated as though they were included in this License, to the extent
++that they are valid under applicable law. If additional permissions
++apply only to part of the Program, that part may be used separately
++under those permissions, but the entire Program remains governed by
++this License without regard to the additional permissions.
++
++ When you convey a copy of a covered work, you may at your option
++remove any additional permissions from that copy, or from any part of
++it. (Additional permissions may be written to require their own
++removal in certain cases when you modify the work.) You may place
++additional permissions on material, added by you to a covered work,
++for which you have or can give appropriate copyright permission.
++
++ Notwithstanding any other provision of this License, for material you
++add to a covered work, you may (if authorized by the copyright holders of
++that material) supplement the terms of this License with terms:
++
++ a) Disclaiming warranty or limiting liability differently from the
++ terms of sections 15 and 16 of this License; or
++
++ b) Requiring preservation of specified reasonable legal notices or
++ author attributions in that material or in the Appropriate Legal
++ Notices displayed by works containing it; or
++
++ c) Prohibiting misrepresentation of the origin of that material, or
++ requiring that modified versions of such material be marked in
++ reasonable ways as different from the original version; or
++
++ d) Limiting the use for publicity purposes of names of licensors or
++ authors of the material; or
++
++ e) Declining to grant rights under trademark law for use of some
++ trade names, trademarks, or service marks; or
++
++ f) Requiring indemnification of licensors and authors of that
++ material by anyone who conveys the material (or modified versions of
++ it) with contractual assumptions of liability to the recipient, for
++ any liability that these contractual assumptions directly impose on
++ those licensors and authors.
++
++ All other non-permissive additional terms are considered "further
++restrictions" within the meaning of section 10. If the Program as you
++received it, or any part of it, contains a notice stating that it is
++governed by this License along with a term that is a further
++restriction, you may remove that term. If a license document contains
++a further restriction but permits relicensing or conveying under this
++License, you may add to a covered work material governed by the terms
++of that license document, provided that the further restriction does
++not survive such relicensing or conveying.
++
++ If you add terms to a covered work in accord with this section, you
++must place, in the relevant source files, a statement of the
++additional terms that apply to those files, or a notice indicating
++where to find the applicable terms.
++
++ Additional terms, permissive or non-permissive, may be stated in the
++form of a separately written license, or stated as exceptions;
++the above requirements apply either way.
++
++ 8. Termination.
++
++ You may not propagate or modify a covered work except as expressly
++provided under this License. Any attempt otherwise to propagate or
++modify it is void, and will automatically terminate your rights under
++this License (including any patent licenses granted under the third
++paragraph of section 11).
++
++ However, if you cease all violation of this License, then your
++license from a particular copyright holder is reinstated (a)
++provisionally, unless and until the copyright holder explicitly and
++finally terminates your license, and (b) permanently, if the copyright
++holder fails to notify you of the violation by some reasonable means
++prior to 60 days after the cessation.
++
++ Moreover, your license from a particular copyright holder is
++reinstated permanently if the copyright holder notifies you of the
++violation by some reasonable means, this is the first time you have
++received notice of violation of this License (for any work) from that
++copyright holder, and you cure the violation prior to 30 days after
++your receipt of the notice.
++
++ Termination of your rights under this section does not terminate the
++licenses of parties who have received copies or rights from you under
++this License. If your rights have been terminated and not permanently
++reinstated, you do not qualify to receive new licenses for the same
++material under section 10.
++
++ 9. Acceptance Not Required for Having Copies.
++
++ You are not required to accept this License in order to receive or
++run a copy of the Program. Ancillary propagation of a covered work
++occurring solely as a consequence of using peer-to-peer transmission
++to receive a copy likewise does not require acceptance. However,
++nothing other than this License grants you permission to propagate or
++modify any covered work. These actions infringe copyright if you do
++not accept this License. Therefore, by modifying or propagating a
++covered work, you indicate your acceptance of this License to do so.
++
++ 10. Automatic Licensing of Downstream Recipients.
++
++ Each time you convey a covered work, the recipient automatically
++receives a license from the original licensors, to run, modify and
++propagate that work, subject to this License. You are not responsible
++for enforcing compliance by third parties with this License.
++
++ An "entity transaction" is a transaction transferring control of an
++organization, or substantially all assets of one, or subdividing an
++organization, or merging organizations. If propagation of a covered
++work results from an entity transaction, each party to that
++transaction who receives a copy of the work also receives whatever
++licenses to the work the party's predecessor in interest had or could
++give under the previous paragraph, plus a right to possession of the
++Corresponding Source of the work from the predecessor in interest, if
++the predecessor has it or can get it with reasonable efforts.
++
++ You may not impose any further restrictions on the exercise of the
++rights granted or affirmed under this License. For example, you may
++not impose a license fee, royalty, or other charge for exercise of
++rights granted under this License, and you may not initiate litigation
++(including a cross-claim or counterclaim in a lawsuit) alleging that
++any patent claim is infringed by making, using, selling, offering for
++sale, or importing the Program or any portion of it.
++
++ 11. Patents.
++
++ A "contributor" is a copyright holder who authorizes use under this
++License of the Program or a work on which the Program is based. The
++work thus licensed is called the contributor's "contributor version".
++
++ A contributor's "essential patent claims" are all patent claims
++owned or controlled by the contributor, whether already acquired or
++hereafter acquired, that would be infringed by some manner, permitted
++by this License, of making, using, or selling its contributor version,
++but do not include claims that would be infringed only as a
++consequence of further modification of the contributor version. For
++purposes of this definition, "control" includes the right to grant
++patent sublicenses in a manner consistent with the requirements of
+ this License.
+
+- 7. If, as a consequence of a court judgment or allegation of patent
+-infringement or for any other reason (not limited to patent issues),
+-conditions are imposed on you (whether by court order, agreement or
++ Each contributor grants you a non-exclusive, worldwide, royalty-free
++patent license under the contributor's essential patent claims, to
++make, use, sell, offer for sale, import and otherwise run, modify and
++propagate the contents of its contributor version.
++
++ In the following three paragraphs, a "patent license" is any express
++agreement or commitment, however denominated, not to enforce a patent
++(such as an express permission to practice a patent or covenant not to
++sue for patent infringement). To "grant" such a patent license to a
++party means to make such an agreement or commitment not to enforce a
++patent against the party.
++
++ If you convey a covered work, knowingly relying on a patent license,
++and the Corresponding Source of the work is not available for anyone
++to copy, free of charge and under the terms of this License, through a
++publicly available network server or other readily accessible means,
++then you must either (1) cause the Corresponding Source to be so
++available, or (2) arrange to deprive yourself of the benefit of the
++patent license for this particular work, or (3) arrange, in a manner
++consistent with the requirements of this License, to extend the patent
++license to downstream recipients. "Knowingly relying" means you have
++actual knowledge that, but for the patent license, your conveying the
++covered work in a country, or your recipient's use of the covered work
++in a country, would infringe one or more identifiable patents in that
++country that you have reason to believe are valid.
++
++ If, pursuant to or in connection with a single transaction or
++arrangement, you convey, or propagate by procuring conveyance of, a
++covered work, and grant a patent license to some of the parties
++receiving the covered work authorizing them to use, propagate, modify
++or convey a specific copy of the covered work, then the patent license
++you grant is automatically extended to all recipients of the covered
++work and works based on it.
++
++ A patent license is "discriminatory" if it does not include within
++the scope of its coverage, prohibits the exercise of, or is
++conditioned on the non-exercise of one or more of the rights that are
++specifically granted under this License. You may not convey a covered
++work if you are a party to an arrangement with a third party that is
++in the business of distributing software, under which you make payment
++to the third party based on the extent of your activity of conveying
++the work, and under which the third party grants, to any of the
++parties who would receive the covered work from you, a discriminatory
++patent license (a) in connection with copies of the covered work
++conveyed by you (or copies made from those copies), or (b) primarily
++for and in connection with specific products or compilations that
++contain the covered work, unless you entered into that arrangement,
++or that patent license was granted, prior to 28 March 2007.
++
++ Nothing in this License shall be construed as excluding or limiting
++any implied license or other defenses to infringement that may
++otherwise be available to you under applicable patent law.
++
++ 12. No Surrender of Others' Freedom.
++
++ If conditions are imposed on you (whether by court order, agreement or
+ otherwise) that contradict the conditions of this License, they do not
+-excuse you from the conditions of this License. If you cannot
+-distribute so as to satisfy simultaneously your obligations under this
+-License and any other pertinent obligations, then as a consequence you
+-may not distribute the Program at all. For example, if a patent
+-license would not permit royalty-free redistribution of the Program by
+-all those who receive copies directly or indirectly through you, then
+-the only way you could satisfy both it and this License would be to
+-refrain entirely from distribution of the Program.
+-
+-If any portion of this section is held invalid or unenforceable under
+-any particular circumstance, the balance of the section is intended to
+-apply and the section as a whole is intended to apply in other
+-circumstances.
+-
+-It is not the purpose of this section to induce you to infringe any
+-patents or other property right claims or to contest validity of any
+-such claims; this section has the sole purpose of protecting the
+-integrity of the free software distribution system, which is
+-implemented by public license practices. Many people have made
+-generous contributions to the wide range of software distributed
+-through that system in reliance on consistent application of that
+-system; it is up to the author/donor to decide if he or she is willing
+-to distribute software through any other system and a licensee cannot
+-impose that choice.
+-
+-This section is intended to make thoroughly clear what is believed to
+-be a consequence of the rest of this License.
+-\f
+- 8. If the distribution and/or use of the Program is restricted in
+-certain countries either by patents or by copyrighted interfaces, the
+-original copyright holder who places the Program under this License
+-may add an explicit geographical distribution limitation excluding
+-those countries, so that distribution is permitted only in or among
+-countries not thus excluded. In such case, this License incorporates
+-the limitation as if written in the body of this License.
++excuse you from the conditions of this License. If you cannot convey a
++covered work so as to satisfy simultaneously your obligations under this
++License and any other pertinent obligations, then as a consequence you may
++not convey it at all. For example, if you agree to terms that obligate you
++to collect a royalty for further conveying from those to whom you convey
++the Program, the only way you could satisfy both those terms and this
++License would be to refrain entirely from conveying the Program.
++
++ 13. Use with the GNU Affero General Public License.
++
++ Notwithstanding any other provision of this License, you have
++permission to link or combine any covered work with a work licensed
++under version 3 of the GNU Affero General Public License into a single
++combined work, and to convey the resulting work. The terms of this
++License will continue to apply to the part which is the covered work,
++but the special requirements of the GNU Affero General Public License,
++section 13, concerning interaction through a network will apply to the
++combination as such.
++
++ 14. Revised Versions of this License.
+
+- 9. The Free Software Foundation may publish revised and/or new versions
+-of the General Public License from time to time. Such new versions will
++ The Free Software Foundation may publish revised and/or new versions of
++the GNU General Public License from time to time. Such new versions will
+ be similar in spirit to the present version, but may differ in detail to
+ address new problems or concerns.
+
+-Each version is given a distinguishing version number. If the Program
+-specifies a version number of this License which applies to it and "any
+-later version", you have the option of following the terms and conditions
+-either of that version or of any later version published by the Free
+-Software Foundation. If the Program does not specify a version number of
+-this License, you may choose any version ever published by the Free Software
+-Foundation.
+-
+- 10. If you wish to incorporate parts of the Program into other free
+-programs whose distribution conditions are different, write to the author
+-to ask for permission. For software which is copyrighted by the Free
+-Software Foundation, write to the Free Software Foundation; we sometimes
+-make exceptions for this. Our decision will be guided by the two goals
+-of preserving the free status of all derivatives of our free software and
+-of promoting the sharing and reuse of software generally.
+-
+- NO WARRANTY
+-
+- 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
+-FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
+-OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
+-PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
+-OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+-MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
+-TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
+-PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
+-REPAIR OR CORRECTION.
+-
+- 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+-WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
+-REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
+-INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
+-OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
+-TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
+-YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
+-PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
+-POSSIBILITY OF SUCH DAMAGES.
+-
+- END OF TERMS AND CONDITIONS
+-\f
+- Appendix: How to Apply These Terms to Your New Programs
++ Each version is given a distinguishing version number. If the
++Program specifies that a certain numbered version of the GNU General
++Public License "or any later version" applies to it, you have the
++option of following the terms and conditions either of that numbered
++version or of any later version published by the Free Software
++Foundation. If the Program does not specify a version number of the
++GNU General Public License, you may choose any version ever published
++by the Free Software Foundation.
++
++ If the Program specifies that a proxy can decide which future
++versions of the GNU General Public License can be used, that proxy's
++public statement of acceptance of a version permanently authorizes you
++to choose that version for the Program.
++
++ Later license versions may give you additional or different
++permissions. However, no additional obligations are imposed on any
++author or copyright holder as a result of your choosing to follow a
++later version.
++
++ 15. Disclaimer of Warranty.
++
++ THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
++APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
++HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
++OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
++THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
++PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
++IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
++ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
++
++ 16. Limitation of Liability.
++
++ IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
++WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
++THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
++GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
++USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
++DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
++PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
++EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
++SUCH DAMAGES.
++
++ 17. Interpretation of Sections 15 and 16.
++
++ If the disclaimer of warranty and limitation of liability provided
++above cannot be given local legal effect according to their terms,
++reviewing courts shall apply local law that most closely approximates
++an absolute waiver of all civil liability in connection with the
++Program, unless a warranty or assumption of liability accompanies a
++copy of the Program in return for a fee.
++
++ END OF TERMS AND CONDITIONS
++
++ How to Apply These Terms to Your New Programs
+
+ If you develop a new program, and you want it to be of the greatest
+ possible use to the public, the best way to achieve this is to make it
+@@ -287,15 +628,15 @@ free software which everyone can redistr
+
+ To do so, attach the following notices to the program. It is safest
+ to attach them to the start of each source file to most effectively
+-convey the exclusion of warranty; and each file should have at least
++state the exclusion of warranty; and each file should have at least
+ the "copyright" line and a pointer to where the full notice is found.
+
+ <one line to give the program's name and a brief idea of what it does.>
+- Copyright (C) 19yy <name of author>
++ Copyright (C) <year> <name of author>
+
+- This program is free software; you can redistribute it and/or modify
++ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+- the Free Software Foundation; either version 2 of the License, or
++ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+@@ -304,36 +645,30 @@ the "copyright" line and a pointer to wh
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+- along with this program; if not, write to the Free Software
+- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
++ along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+ Also add information on how to contact you by electronic and paper mail.
+
+-If the program is interactive, make it output a short notice like this
+-when it starts in an interactive mode:
++ If the program does terminal interaction, make it output a short
++notice like this when it starts in an interactive mode:
+
+- Gnomovision version 69, Copyright (C) 19yy name of author
+- Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
++ <program> Copyright (C) <year> <name of author>
++ This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+ This is free software, and you are welcome to redistribute it
+ under certain conditions; type `show c' for details.
+
+ The hypothetical commands `show w' and `show c' should show the appropriate
+-parts of the General Public License. Of course, the commands you use may
+-be called something other than `show w' and `show c'; they could even be
+-mouse-clicks or menu items--whatever suits your program.
+-
+-You should also get your employer (if you work as a programmer) or your
+-school, if any, to sign a "copyright disclaimer" for the program, if
+-necessary. Here is a sample; alter the names:
+-
+- Yoyodyne, Inc., hereby disclaims all copyright interest in the program
+- `Gnomovision' (which makes passes at compilers) written by James Hacker.
+-
+- <signature of Ty Coon>, 1 April 1989
+- Ty Coon, President of Vice
+-
+-This General Public License does not permit incorporating your program into
+-proprietary programs. If your program is a subroutine library, you may
+-consider it more useful to permit linking proprietary applications with the
+-library. If this is what you want to do, use the GNU Library General
+-Public License instead of this License.
++parts of the General Public License. Of course, your program's commands
++might be different; for a GUI interface, you would use an "about box".
++
++ You should also get your employer (if you work as a programmer) or school,
++if any, to sign a "copyright disclaimer" for the program, if necessary.
++For more information on this, and how to apply and follow the GNU GPL, see
++<http://www.gnu.org/licenses/>.
++
++ The GNU General Public License does not permit incorporating your program
++into proprietary programs. If your program is a subroutine library, you
++may consider it more useful to permit linking proprietary applications with
++the library. If this is what you want to do, use the GNU Lesser General
++Public License instead of this License. But first, please read
++<http://www.gnu.org/philosophy/why-not-lgpl.html>.
+Index: gdb-7.2.90.20110703/readline/ChangeLog.gdb
+===================================================================
+--- gdb-7.2.90.20110703.orig/readline/ChangeLog.gdb 2011-07-03 10:40:53.000000000 +0200
++++ gdb-7.2.90.20110703/readline/ChangeLog.gdb 2011-07-03 10:41:21.000000000 +0200
+@@ -1,3 +1,12 @@
++2011-04-30 Jan Kratochvil <jan.kratochvil@redhat.com>
++
++ Workaround gdb.base/completion.exp regression on readline-6.2.
++ * complete.c (get_y_or_n): Disable the return on RL_STATE_CALLBACK.
++
++2011-04-25 Jan Kratochvil <jan.kratochvil@redhat.com>
++
++ Imported readline 6.2, and upstream patch 001.
++
+ 2011-06-27 Jan Kratochvil <jan.kratochvil@redhat.com>
+
+ Avoid free from a signal handler.
+Index: gdb-7.2.90.20110703/readline/INSTALL
+===================================================================
+--- gdb-7.2.90.20110703.orig/readline/INSTALL 2011-07-03 10:40:53.000000000 +0200
++++ gdb-7.2.90.20110703/readline/INSTALL 2011-07-03 10:41:21.000000000 +0200
+@@ -1,7 +1,7 @@
+ Basic Installation
+ ==================
+
+-These are installation instructions for Readline-5.1.
++These are installation instructions for Readline-6.2.
+
+ The simplest way to compile readline is:
+
+Index: gdb-7.2.90.20110703/readline/MANIFEST
+===================================================================
+--- gdb-7.2.90.20110703.orig/readline/MANIFEST 2011-07-03 10:40:53.000000000 +0200
++++ gdb-7.2.90.20110703/readline/MANIFEST 2011-07-03 10:41:21.000000000 +0200
+@@ -3,6 +3,7 @@
+ #
+ doc d
+ examples d
++examples/autoconf d
+ examples/rlfe d
+ support d
+ shlib d
+@@ -26,6 +27,7 @@ histlib.h f
+ keymaps.h f
+ posixdir.h f
+ posixjmp.h f
++posixselect.h f
+ posixstat.h f
+ readline.h f
+ rlconf.h f
+@@ -69,11 +71,13 @@ undo.c f
+ util.c f
+ vi_keymap.c f
+ vi_mode.c f
++xfree.c f
+ xmalloc.c f
+ history.c f
+ histexpand.c f
+ histfile.c f
+ histsearch.c f
++patchlevel f
+ shlib/Makefile.in f
+ support/config.guess f
+ support/config.rpath f
+@@ -107,12 +111,16 @@ examples/manexamp.c f
+ examples/readlinebuf.h f
+ examples/rl-fgets.c f
+ examples/rlcat.c f
++examples/rlevent.c f
+ examples/rltest.c f
+ examples/rl.c f
+ examples/rlptytest.c f
+ examples/rlversion.c f
+ examples/histexamp.c f
+ examples/Inputrc f
++examples/autoconf/BASH_CHECK_LIB_TERMCAP f
++examples/autoconf/RL_LIB_READLINE_VERSION f
++examples/autoconf/wi_LIB_READLINE f
+ examples/rlfe/ChangeLog f
+ examples/rlfe/Makefile.in f
+ examples/rlfe/README f
+@@ -124,6 +132,7 @@ examples/rlfe/os.h f
+ examples/rlfe/pty.c f
+ examples/rlfe/rlfe.c f
+ examples/rlfe/screen.h f
++examples/rlwrap-0.30.tar.gz f
+ # formatted documentation, from MANIFEST.doc
+ doc/readline.ps f
+ doc/history.ps f
+Index: gdb-7.2.90.20110703/readline/Makefile.in
+===================================================================
+--- gdb-7.2.90.20110703.orig/readline/Makefile.in 2011-07-03 10:40:53.000000000 +0200
++++ gdb-7.2.90.20110703/readline/Makefile.in 2011-07-03 10:43:36.000000000 +0200
+@@ -1,20 +1,20 @@
+ ## -*- text -*- ##
+ # Master Makefile for the GNU readline library.
+-# Copyright (C) 1994-2004 Free Software Foundation, Inc.
++# Copyright (C) 1994-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 <http://www.gnu.org/licenses/>.
+
+-# This program is free software; you can redistribute it and/or modify
+-# it under the terms of the GNU General Public License as published by
+-# the Free Software Foundation; either version 2, or (at your option)
+-# any later version.
+-
+-# This program is distributed in the hope that it will be useful,
+-# but WITHOUT ANY WARRANTY; without even the implied warranty of
+-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+-# GNU General Public License for more details.
+-
+-# You should have received a copy of the GNU General Public License
+-# along with this program; if not, write to the Free Software
+-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA.
+ RL_LIBRARY_VERSION = @LIBVERSION@
+ RL_LIBRARY_NAME = readline
+
+@@ -58,7 +58,7 @@ libdir = @libdir@
+ mandir = @mandir@
+ includedir = @includedir@
+ datadir = @datadir@
+-localedir = $(datadir)/locale
++localedir = @localedir@
+
+ infodir = @infodir@
+
+@@ -68,7 +68,7 @@ man3dir = $(mandir)/man3
+ DESTDIR =
+
+ # Programs to make tags files.
+-ETAGS = etags -tw
++ETAGS = etags
+ CTAGS = ctags -tw
+
+ CFLAGS = @CFLAGS@
+@@ -100,8 +100,6 @@ GCC_LINT_CFLAGS = $(XCCFLAGS) $(GCC_LINT
+ LIBRARY_NAME = libreadline.a
+ STATIC_LIBS = libreadline.a libhistory.a
+
+-WCWIDTH_OBJ = @WCWIDTH_OBJ@
+-
+ # The C code source files for this library.
+ CSOURCES = $(srcdir)/readline.c $(srcdir)/funmap.c $(srcdir)/keymaps.c \
+ $(srcdir)/vi_mode.c $(srcdir)/parens.c $(srcdir)/rltty.c \
+@@ -109,26 +107,28 @@ CSOURCES = $(srcdir)/readline.c $(srcdir
+ $(srcdir)/display.c $(srcdir)/signals.c $(srcdir)/emacs_keymap.c \
+ $(srcdir)/vi_keymap.c $(srcdir)/util.c $(srcdir)/kill.c \
+ $(srcdir)/undo.c $(srcdir)/macro.c $(srcdir)/input.c \
+- $(srcdir)/callback.c $(srcdir)/terminal.c $(srcdir)/xmalloc.c \
++ $(srcdir)/callback.c $(srcdir)/terminal.c $(srcdir)/xmalloc.c $(srcdir)/xfree.c \
+ $(srcdir)/history.c $(srcdir)/histsearch.c $(srcdir)/histexpand.c \
+ $(srcdir)/histfile.c $(srcdir)/nls.c $(srcdir)/search.c \
+ $(srcdir)/shell.c $(srcdir)/savestring.c $(srcdir)/tilde.c \
+ $(srcdir)/text.c $(srcdir)/misc.c $(srcdir)/compat.c \
+- $(srcdir)/mbutil.c $(srcdir)/support/wcwidth.c
++ $(srcdir)/mbutil.c
+
+ # The header files for this library.
+-HSOURCES = readline.h rldefs.h chardefs.h keymaps.h history.h histlib.h \
+- posixstat.h posixdir.h posixjmp.h tilde.h rlconf.h rltty.h \
+- ansi_stdlib.h tcap.h rlstdc.h xmalloc.h rlprivate.h rlshell.h \
+- rltypedefs.h rlmbutil.h
++HSOURCES = $(srcdir)/readline.h $(srcdir)/rldefs.h $(srcdir)/chardefs.h \
++ $(srcdir)/keymaps.h $(srcdir)/history.h $(srcdir)/histlib.h \
++ $(srcdir)/posixstat.h $(srcdir)/posixdir.h $(srcdir)/posixjmp.h \
++ $(srcdir)/tilde.h $(srcdir)/rlconf.h $(srcdir)/rltty.h \
++ $(srcdir)/ansi_stdlib.h $(srcdir)/tcap.h $(srcdir)/rlstdc.h \
++ $(srcdir)/xmalloc.h $(srcdir)/rlprivate.h $(srcdir)/rlshell.h \
++ $(srcdir)/rltypedefs.h $(srcdir)/rlmbutil.h
+
+ HISTOBJ = history.o histexpand.o histfile.o histsearch.o shell.o mbutil.o
+ TILDEOBJ = tilde.o
+ OBJECTS = readline.o vi_mode.o funmap.o keymaps.o parens.o search.o \
+ rltty.o complete.o bind.o isearch.o display.o signals.o \
+ util.o kill.o undo.o macro.o input.o callback.o terminal.o \
+- text.o nls.o misc.o compat.o xmalloc.o $(HISTOBJ) $(TILDEOBJ) \
+- $(WCWIDTH_OBJ)
++ text.o nls.o misc.o compat.o xfree.o xmalloc.o $(HISTOBJ) $(TILDEOBJ)
+
+ # The texinfo files which document this library.
+ DOCSOURCE = doc/rlman.texinfo doc/rltech.texinfo doc/rluser.texinfo
+@@ -159,15 +159,11 @@ libreadline.a: $(OBJECTS)
+ $(AR) $(ARFLAGS) $@ $(OBJECTS)
+ -test -n "$(RANLIB)" && $(RANLIB) $@
+
+-libhistory.a: $(HISTOBJ) xmalloc.o
++libhistory.a: $(HISTOBJ) xmalloc.o xfree.o
+ $(RM) $@
+- $(AR) $(ARFLAGS) $@ $(HISTOBJ) xmalloc.o
++ $(AR) $(ARFLAGS) $@ $(HISTOBJ) xmalloc.o xfree.o
+ -test -n "$(RANLIB)" && $(RANLIB) $@
+
+-wcwidth.o: $(srcdir)/support/wcwidth.c
+- $(RM) $@
+- $(CC) $(CCFLAGS) -c $(srcdir)/support/wcwidth.c
+-
+ # Since tilde.c is shared between readline and bash, make sure we compile
+ # it with the right flags when it's built as part of readline
+ tilde.o: tilde.c
+@@ -175,7 +171,7 @@ tilde.o: tilde.c
+ $(CC) $(CCFLAGS) -DREADLINE_LIBRARY -c $(srcdir)/tilde.c
+
+ readline: $(OBJECTS) readline.h rldefs.h chardefs.h ./libreadline.a
+- $(CC) $(CCFLAGS) -o $@ ./examples/rl.c ./libreadline.a ${TERMCAP_LIB}
++ $(CC) $(CCFLAGS) -DREADLINE_LIBRARY -o $@ $(top_srcdir)/examples/rl.c ./libreadline.a ${TERMCAP_LIB}
+
+ lint: force
+ $(MAKE) $(MFLAGS) CCFLAGS='$(GCC_LINT_CFLAGS)' static
+@@ -200,6 +196,7 @@ stamp-h: config.status $(srcdir)/config.
+ #$(srcdir)/configure: $(srcdir)/configure.in ## Comment-me-out in distribution
+ # cd $(srcdir) && autoconf ## Comment-me-out in distribution
+
++
+ shared: force
+ -test -d shlib || mkdir shlib
+ -( cd shlib ; ${MAKE} ${MFLAGS} all )
+@@ -214,17 +211,6 @@ examples: force
+
+ force:
+
+-install-headers: installdirs ${INSTALLED_HEADERS}
+- for f in ${INSTALLED_HEADERS}; do \
+- $(INSTALL_DATA) $(srcdir)/$$f $(DESTDIR)$(includedir)/readline ; \
+- done
+-
+-uninstall-headers:
+- -test -n "$(includedir)" && cd $(DESTDIR)$(includedir)/readline && \
+- ${RM} ${INSTALLED_HEADERS}
+-
+-maybe-uninstall-headers: uninstall-headers
+-
+ ## GDB LOCAL
+ ## Don't mess with people's installed readline's.
+ ## This tries to install this version of readline over whatever
+@@ -237,7 +223,18 @@ install:
+
+ #install: $(INSTALL_TARGETS)
+
+-install-static: installdirs $(STATIC_LIBS) install-headers install-doc
++install-headers: installdirs ${INSTALLED_HEADERS}
++ for f in ${INSTALLED_HEADERS}; do \
++ $(INSTALL_DATA) $(srcdir)/$$f $(DESTDIR)$(includedir)/readline ; \
++ done
++
++uninstall-headers:
++ -test -n "$(includedir)" && cd $(DESTDIR)$(includedir)/readline && \
++ ${RM} ${INSTALLED_HEADERS}
++
++maybe-uninstall-headers: uninstall-headers
++
++install-static: installdirs $(STATIC_LIBS) install-headers install-doc install-examples
+ -$(MV) $(DESTDIR)$(libdir)/libreadline.a $(DESTDIR)$(libdir)/libreadline.old
+ $(INSTALL_DATA) libreadline.a $(DESTDIR)$(libdir)/libreadline.a
+ -test -n "$(RANLIB)" && $(RANLIB) $(DESTDIR)$(libdir)/libreadline.a
+@@ -250,7 +247,7 @@ installdirs: $(srcdir)/support/mkinstall
+ $(DESTDIR)$(includedir)/readline $(DESTDIR)$(libdir) \
+ $(DESTDIR)$(infodir) $(DESTDIR)$(man3dir)
+
+-uninstall: uninstall-headers uninstall-doc
++uninstall: uninstall-headers uninstall-doc uninstall-examples
+ -test -n "$(DESTDIR)$(libdir)" && cd $(DESTDIR)$(libdir) && \
+ ${RM} libreadline.a libreadline.old libhistory.a libhistory.old $(SHARED_LIBS)
+ -( cd shlib; ${MAKE} ${MFLAGS} DESTDIR=${DESTDIR} uninstall )
+@@ -261,6 +258,12 @@ install-shared: installdirs install-head
+ uninstall-shared: maybe-uninstall-headers
+ -( cd shlib; ${MAKE} ${MFLAGS} DESTDIR=${DESTDIR} uninstall )
+
++install-examples: installdirs install-headers shared
++ -( cd examples ; ${MAKE} ${MFLAGS} DESTDIR=${DESTDIR} install )
++
++uninstall-examples: maybe-uninstall-headers
++ -( cd examples; ${MAKE} ${MFLAGS} DESTDIR=${DESTDIR} uninstall )
++
+ install-doc: installdirs
+ -( if test -d doc ; then \
+ cd doc && \
+@@ -274,10 +277,10 @@ uninstall-doc:
+ fi )
+
+ TAGS: force
+- $(ETAGS) $(CSOURCES) $(HSOURCES)
++ -( cd $(srcdir) && $(ETAGS) $(CSOURCES) $(HSOURCES) )
+
+ tags: force
+- $(CTAGS) $(CSOURCES) $(HSOURCES)
++ -( cd $(srcdir) && $(CTAGS) $(CSOURCES) $(HSOURCES) )
+
+ clean: force
+ $(RM) $(OBJECTS) $(STATIC_LIBS)
+@@ -299,12 +302,14 @@ distclean maintainer-clean: clean
+ $(RM) $(CREATED_CONFIGURE)
+ $(RM) $(CREATED_TAGS)
+
+-info dvi html pdf:
++info dvi html pdf ps:
+ -( cd doc && $(MAKE) $(MFLAGS) $@ )
+
+ install-info:
++install-dvi:
+ install-html:
+ install-pdf:
++install-ps:
+ check:
+ installcheck:
+
+@@ -417,7 +422,7 @@ vi_mode.o: rldefs.h ${BUILD_DIR}/config.
+ vi_mode.o: readline.h keymaps.h rltypedefs.h chardefs.h tilde.h
+ vi_mode.o: history.h ansi_stdlib.h rlstdc.h
+ xmalloc.o: ${BUILD_DIR}/config.h
+-xmalloc.o: ansi_stdlib.h readline.h
++xmalloc.o: ansi_stdlib.h
+
+ bind.o: rlshell.h
+ histfile.o: rlshell.h
+@@ -474,6 +479,7 @@ tilde.o: xmalloc.h
+ undo.o: xmalloc.h
+ util.o: xmalloc.h
+ vi_mode.o: xmalloc.h
++xfree.o: xmalloc.h readline.h
+ xmalloc.o: xmalloc.h
+
+ complete.o: rlmbutil.h
+@@ -515,6 +521,7 @@ tilde.o: $(srcdir)/tilde.c
+ undo.o: $(srcdir)/undo.c
+ util.o: $(srcdir)/util.c
+ vi_mode.o: $(srcdir)/vi_mode.c
++xfree.o: $(srcdir)/xfree.c
+ xmalloc.o: $(srcdir)/xmalloc.c
+
+ histexpand.o: $(srcdir)/histexpand.c
+@@ -549,6 +556,7 @@ tilde.o: tilde.c
+ undo.o: undo.c
+ util.o: util.c
+ vi_mode.o: vi_mode.c
++xfree.o: xfree.c
+ xmalloc.o: xmalloc.c
+
+ histexpand.o: histexpand.c
+Index: gdb-7.2.90.20110703/readline/NEWS
+===================================================================
+--- gdb-7.2.90.20110703.orig/readline/NEWS 2011-07-03 10:40:53.000000000 +0200
++++ gdb-7.2.90.20110703/readline/NEWS 2011-07-03 10:41:21.000000000 +0200
+@@ -1,32 +1,19 @@
+-This is a terse description of the new features added to readline-5.1 since
+-the release of readline-5.0.
++This is a terse description of the new features added to readline-6.2 since
++the release of readline-6.1.
+
+-1. New Features in Readline
++a. The history library does not try to write the history filename in the
++ current directory if $HOME is unset. This closes a potential security
++ problem if the application does not specify a history filename.
+
+-a. The key sequence sent by the keypad `delete' key is now automatically
+- bound to delete-char.
++b. New bindable variable `completion-display-width' to set the number of
++ columns used when displaying completions.
+
+-b. A negative argument to menu-complete now cycles backward through the
+- completion list.
++c. New bindable variable `completion-case-map' to cause case-insensitive
++ completion to treat `-' and `_' as identical.
+
+-c. A new bindable readline variable: bind-tty-special-chars. If non-zero,
+- readline will bind the terminal special characters to their readline
+- equivalents when it's called (on by default).
++d. There are new bindable vi-mode command names to avoid readline's case-
++ insensitive matching not allowing them to be bound separately.
+
+-d. New bindable command: vi-rubout. Saves deleted text for possible
+- reinsertion, as with any vi-mode `text modification' command; `X' is bound
+- to this in vi command mode.
+-
+-e. If the rl_completion_query_items is set to a value < 0, readline never
+- asks the user whether or not to view the possible completions.
+-
+-f. New application-callable auxiliary function, rl_variable_value, returns
+- a string corresponding to a readline variable's value.
+-
+-g. When parsing inputrc files and variable binding commands, the parser
+- strips trailing whitespace from values assigned to boolean variables
+- before checking them.
+-
+-h. A new external application-controllable variable that allows the LINES
+- and COLUMNS environment variables to set the window size regardless of
+- what the kernel returns.
++e. New bindable variable `menu-complete-display-prefix' causes the menu
++ completion code to display the common prefix of the possible completions
++ before cycling through the list, instead of after.
+Index: gdb-7.2.90.20110703/readline/README
+===================================================================
+--- gdb-7.2.90.20110703.orig/readline/README 2011-07-03 10:40:53.000000000 +0200
++++ gdb-7.2.90.20110703/readline/README 2011-07-03 10:41:21.000000000 +0200
+@@ -1,7 +1,7 @@
+ Introduction
+ ============
+
+-This is the Gnu Readline library, version 5.1.
++This is the Gnu Readline library, version 6.2.
+
+ The Readline library provides a set of functions for use by applications
+ that allow users to edit command lines as they are typed in. Both
+@@ -16,8 +16,9 @@ may be used without Readline in applicat
+ capabilities.
+
+ The Readline library is free software, distributed under the terms of
+-the [GNU] General Public License, version 2. For more information, see
+-the file COPYING.
++the [GNU] General Public License as published by the Free Software
++Foundation, version 3 of the License. For more information, see the
++file COPYING.
+
+ To build the library, try typing `./configure', then `make'. The
+ configuration process is automated, so no further intervention should
+@@ -183,4 +184,4 @@ list (mirrored to the Usenet newsgroup g
+ Readline bug reports and fixes.
+
+ Chet Ramey
+-chet@po.cwru.edu
++chet.ramey@case.edu
+Index: gdb-7.2.90.20110703/readline/aclocal.m4
+===================================================================
+--- gdb-7.2.90.20110703.orig/readline/aclocal.m4 2011-07-03 10:40:53.000000000 +0200
++++ gdb-7.2.90.20110703/readline/aclocal.m4 2011-07-03 10:41:21.000000000 +0200
+@@ -80,6 +80,9 @@ AC_CACHE_VAL(bash_cv_type_$1,
+ #if HAVE_INTTYPES_H
+ #include <inttypes.h>
+ #endif
++#if HAVE_STDINT_H
++#include <stdint.h>
++#endif
+ $2
+ ], bash_cv_type_$1=yes, bash_cv_type_$1=no)])
+ AC_MSG_RESULT($bash_cv_type_$1)
+@@ -215,7 +218,7 @@ AC_CACHE_VAL(bash_cv_sys_siglist,
+ #ifdef HAVE_UNISTD_H
+ #include <unistd.h>
+ #endif
+-#ifndef SYS_SIGLIST_DECLARED
++#if !HAVE_DECL_SYS_SIGLIST
+ extern char *sys_siglist[];
+ #endif
+ main()
+@@ -336,18 +339,18 @@ main()
+ {
+ DIR *dir;
+ int fd, err;
+-err = mkdir("/tmp/bash-aclocal", 0700);
++err = mkdir("bash-aclocal", 0700);
+ if (err < 0) {
+ perror("mkdir");
+ exit(1);
+ }
+-unlink("/tmp/bash-aclocal/not_a_directory");
+-fd = open("/tmp/bash-aclocal/not_a_directory", O_WRONLY|O_CREAT|O_EXCL, 0666);
++unlink("bash-aclocal/not_a_directory");
++fd = open("bash-aclocal/not_a_directory", O_WRONLY|O_CREAT|O_EXCL, 0666);
+ write(fd, "\n", 1);
+ close(fd);
+-dir = opendir("/tmp/bash-aclocal/not_a_directory");
+-unlink("/tmp/bash-aclocal/not_a_directory");
+-rmdir("/tmp/bash-aclocal");
++dir = opendir("bash-aclocal/not_a_directory");
++unlink("bash-aclocal/not_a_directory");
++rmdir("bash-aclocal");
+ exit (dir == 0);
+ }], bash_cv_opendir_not_robust=yes,bash_cv_opendir_not_robust=no,
+ [AC_MSG_WARN(cannot check opendir if cross compiling -- defaulting to no)
+@@ -531,6 +534,18 @@ AC_DEFINE(RLIMTYPE, rlim_t)
+ fi
+ ])
+
++AC_DEFUN(BASH_TYPE_SIG_ATOMIC_T,
++[AC_CACHE_CHECK([for sig_atomic_t in signal.h], ac_cv_have_sig_atomic_t,
++[AC_TRY_LINK([
++#include <signal.h>
++],[ sig_atomic_t x; ],
++ac_cv_have_sig_atomic_t=yes, ac_cv_have_sig_atomic_t=no)])
++if test "$ac_cv_have_sig_atomic_t" = "no"
++then
++ AC_CHECK_TYPE(sig_atomic_t,int)
++fi
++])
++
+ AC_DEFUN(BASH_FUNC_LSTAT,
+ [dnl Cannot use AC_CHECK_FUNCS(lstat) because Linux defines lstat() as an
+ dnl inline function in <sys/stat.h>.
+@@ -685,7 +700,7 @@ fi
+ ])
+
+ AC_DEFUN(BASH_FUNC_GETCWD,
+-[AC_MSG_CHECKING([if getcwd() will dynamically allocate memory])
++[AC_MSG_CHECKING([if getcwd() will dynamically allocate memory with 0 size])
+ AC_CACHE_VAL(bash_cv_getcwd_malloc,
+ [AC_TRY_RUN([
+ #include <stdio.h>
+@@ -933,7 +948,7 @@ AC_DEFINE(HAVE_STRUCT_STAT_ST_BLOCKS)
+ fi
+ ])
+
+-AC_DEFUN(BASH_CHECK_LIB_TERMCAP,
++AC_DEFUN([BASH_CHECK_LIB_TERMCAP],
+ [
+ if test "X$bash_cv_termcap_lib" = "X"; then
+ _bash_needmsg=yes
+@@ -1423,19 +1438,19 @@ exit (1);
+ #if defined (NeXT)
+ exit (1);
+ #endif
+-err = mkdir("/tmp/bash-aclocal", 0700);
++err = mkdir("bash-aclocal", 0700);
+ if (err < 0) {
+ perror ("mkdir");
+ exit(1);
+ }
+-fd = mknod ("/tmp/bash-aclocal/sh-np-autoconf", 0666 | S_IFIFO, 0);
++fd = mknod ("bash-aclocal/sh-np-autoconf", 0666 | S_IFIFO, 0);
+ if (fd == -1) {
+- rmdir ("/tmp/bash-aclocal");
++ rmdir ("bash-aclocal");
+ exit (1);
+ }
+ close(fd);
+-unlink ("/tmp/bash-aclocal/sh-np-autoconf");
+-rmdir ("/tmp/bash-aclocal");
++unlink ("bash-aclocal/sh-np-autoconf");
++rmdir ("bash-aclocal");
+ exit(0);
+ }], bash_cv_sys_named_pipes=present, bash_cv_sys_named_pipes=missing,
+ [AC_MSG_WARN(cannot check for named pipes if cross-compiling -- defaulting to missing)
+@@ -1540,20 +1555,22 @@ fi
+ AC_DEFUN(BASH_CHECK_DEV_FD,
+ [AC_MSG_CHECKING(whether /dev/fd is available)
+ AC_CACHE_VAL(bash_cv_dev_fd,
+-[if test -d /dev/fd && test -r /dev/fd/0 < /dev/null; then
++[bash_cv_dev_fd=""
++if test -d /dev/fd && (exec test -r /dev/fd/0 < /dev/null) ; then
+ # check for systems like FreeBSD 5 that only provide /dev/fd/[012]
+- exec 3<&0
+- if test -r /dev/fd/3; then
++ if (exec test -r /dev/fd/3 3</dev/null) ; then
+ bash_cv_dev_fd=standard
+ else
+ bash_cv_dev_fd=absent
+ fi
+- exec 3<&-
+- elif test -d /proc/self/fd && test -r /proc/self/fd/0 < /dev/null; then
+- bash_cv_dev_fd=whacky
+- else
+- bash_cv_dev_fd=absent
+- fi
++fi
++if test -z "$bash_cv_dev_fd" ; then
++ if test -d /proc/self/fd && (exec test -r /proc/self/fd/0 < /dev/null) ; then
++ bash_cv_dev_fd=whacky
++ else
++ bash_cv_dev_fd=absent
++ fi
++fi
+ ])
+ AC_MSG_RESULT($bash_cv_dev_fd)
+ if test $bash_cv_dev_fd = "standard"; then
+@@ -1568,9 +1585,9 @@ fi
+ AC_DEFUN(BASH_CHECK_DEV_STDIN,
+ [AC_MSG_CHECKING(whether /dev/stdin stdout stderr are available)
+ AC_CACHE_VAL(bash_cv_dev_stdin,
+-[if test -d /dev/fd && test -r /dev/stdin < /dev/null; then
++[if test -d /dev/fd && (exec test -r /dev/stdin < /dev/null) ; then
+ bash_cv_dev_stdin=present
+- elif test -d /proc/self/fd && test -r /dev/stdin < /dev/null; then
++ elif test -d /proc/self/fd && (exec test -r /dev/stdin < /dev/null) ; then
+ bash_cv_dev_stdin=present
+ else
+ bash_cv_dev_stdin=absent
+@@ -1667,37 +1684,39 @@ fi
+ dnl
+ dnl check for availability of multibyte characters and functions
+ dnl
++dnl geez, I wish I didn't have to check for all of this stuff separately
++dnl
+ AC_DEFUN(BASH_CHECK_MULTIBYTE,
+ [
+ AC_CHECK_HEADERS(wctype.h)
+ AC_CHECK_HEADERS(wchar.h)
+ AC_CHECK_HEADERS(langinfo.h)
+
+-AC_CHECK_FUNC(mbsrtowcs, AC_DEFINE(HAVE_MBSRTOWCS))
+-AC_CHECK_FUNC(mbrtowc, AC_DEFINE(HAVE_MBRTOWC))
+ AC_CHECK_FUNC(mbrlen, AC_DEFINE(HAVE_MBRLEN))
+-AC_CHECK_FUNC(wctomb, AC_DEFINE(HAVE_WCTOMB))
+-AC_CHECK_FUNC(wcwidth, AC_DEFINE(HAVE_WCWIDTH))
++AC_CHECK_FUNC(mbscasecmp, AC_DEFINE(HAVE_MBSCMP))
++AC_CHECK_FUNC(mbscmp, AC_DEFINE(HAVE_MBSCMP))
++AC_CHECK_FUNC(mbsnrtowcs, AC_DEFINE(HAVE_MBSNRTOWCS))
++AC_CHECK_FUNC(mbsrtowcs, AC_DEFINE(HAVE_MBSRTOWCS))
++
++
++AC_REPLACE_FUNCS(mbschr)
++
++AC_CHECK_FUNC(wcrtomb, AC_DEFINE(HAVE_WCRTOMB))
++AC_CHECK_FUNC(wcscoll, AC_DEFINE(HAVE_WCSCOLL))
+ AC_CHECK_FUNC(wcsdup, AC_DEFINE(HAVE_WCSDUP))
++AC_CHECK_FUNC(wcwidth, AC_DEFINE(HAVE_WCWIDTH))
++AC_CHECK_FUNC(wctype, AC_DEFINE(HAVE_WCTYPE))
+
+-if test "$ac_cv_func_wcwidth" = no && test "$ac_cv_header_wchar_h" = yes; then
+- WCWIDTH_OBJ=wcwidth.o
+-else
+- WCWIDTH_OBJ=
+-fi
+-AC_SUBST(WCWIDTH_OBJ)
++AC_REPLACE_FUNCS(wcswidth)
+
+-AC_CACHE_CHECK([for mbstate_t], bash_cv_have_mbstate_t,
+-[AC_TRY_COMPILE([
+-#include <wchar.h>], [
+- mbstate_t ps;
+- mbstate_t *psp;
+- psp = (mbstate_t *)0;
+-], bash_cv_have_mbstate_t=yes, bash_cv_have_mbstate_t=no)])
+-if test $bash_cv_have_mbstate_t = yes; then
++dnl checks for both mbrtowc and mbstate_t
++AC_FUNC_MBRTOWC
++if test $ac_cv_func_mbrtowc = yes; then
+ AC_DEFINE(HAVE_MBSTATE_T)
+ fi
+
++AC_CHECK_FUNCS(iswlower iswupper towlower towupper iswctype)
++
+ AC_CACHE_CHECK([for nl_langinfo and CODESET], bash_cv_langinfo_codeset,
+ [AC_TRY_LINK(
+ [#include <langinfo.h>],
+@@ -1707,6 +1726,50 @@ if test $bash_cv_langinfo_codeset = yes;
+ AC_DEFINE(HAVE_LANGINFO_CODESET)
+ fi
+
++dnl check for wchar_t in <wchar.h>
++AC_CACHE_CHECK([for wchar_t in wchar.h], bash_cv_type_wchar_t,
++[AC_TRY_COMPILE(
++[#include <wchar.h>
++],
++[
++ wchar_t foo;
++ foo = 0;
++], bash_cv_type_wchar_t=yes, bash_cv_type_wchar_t=no)])
++if test $bash_cv_type_wchar_t = yes; then
++ AC_DEFINE(HAVE_WCHAR_T, 1, [systems should define this type here])
++fi
++
++dnl check for wctype_t in <wctype.h>
++AC_CACHE_CHECK([for wctype_t in wctype.h], bash_cv_type_wctype_t,
++[AC_TRY_COMPILE(
++[#include <wctype.h>],
++[
++ wctype_t foo;
++ foo = 0;
++], bash_cv_type_wctype_t=yes, bash_cv_type_wctype_t=no)])
++if test $bash_cv_type_wctype_t = yes; then
++ AC_DEFINE(HAVE_WCTYPE_T, 1, [systems should define this type here])
++fi
++
++dnl check for wint_t in <wctype.h>
++AC_CACHE_CHECK([for wint_t in wctype.h], bash_cv_type_wint_t,
++[AC_TRY_COMPILE(
++[#include <wctype.h>],
++[
++ wint_t foo;
++ foo = 0;
++], bash_cv_type_wint_t=yes, bash_cv_type_wint_t=no)])
++if test $bash_cv_type_wint_t = yes; then
++ AC_DEFINE(HAVE_WINT_T, 1, [systems should define this type here])
++fi
++
++if test "$am_cv_func_iconv" = yes; then
++ OLDLIBS="$LIBS"
++ LIBS="$LIBS $LIBICONV"
++ AC_CHECK_FUNCS(locale_charset)
++ LIBS="$OLDLIBS"
++fi
++
+ ])
+
+ dnl need: prefix exec_prefix libdir includedir CC TERMCAP_LIB
+@@ -1714,7 +1777,7 @@ dnl require:
+ dnl AC_PROG_CC
+ dnl BASH_CHECK_LIB_TERMCAP
+
+-AC_DEFUN(RL_LIB_READLINE_VERSION,
++AC_DEFUN([RL_LIB_READLINE_VERSION],
+ [
+ AC_REQUIRE([BASH_CHECK_LIB_TERMCAP])
+
+@@ -2331,7 +2394,7 @@ AC_DEFUN([AM_INTL_SUBDIR],
+ AC_CHECK_HEADERS([argz.h limits.h locale.h nl_types.h malloc.h stddef.h \
+ stdlib.h string.h unistd.h sys/param.h])
+ AC_CHECK_FUNCS([feof_unlocked fgets_unlocked getc_unlocked getcwd getegid \
+-geteuid getgid getuid mempcpy munmap putenv setenv setlocale stpcpy \
++geteuid getgid getuid mempcpy munmap putenv setenv setlocale localeconv stpcpy \
+ strcasecmp strdup strtoul tsearch __argz_count __argz_stringify __argz_next \
+ __fsetlocking])
+
+@@ -3964,3 +4027,143 @@ AC_DEFUN([jm_AC_TYPE_UNSIGNED_LONG_LONG]
+ [Define if you have the unsigned long long type.])
+ fi
+ ])
++
++dnl From gnulib
++AC_DEFUN([BASH_FUNC_FPURGE],
++[
++ AC_CHECK_FUNCS_ONCE([fpurge])
++ AC_CHECK_FUNCS_ONCE([__fpurge])
++ AC_CHECK_DECLS([fpurge], , , [#include <stdio.h>])
++])
++
++AC_DEFUN([BASH_FUNC_SNPRINTF],
++[
++ AC_CHECK_FUNCS_ONCE([snprintf])
++ if test X$ac_cv_func_snprintf = Xyes; then
++ AC_CACHE_CHECK([for standard-conformant snprintf], [bash_cv_func_snprintf],
++ [AC_TRY_RUN([
++#include <stdio.h>
++
++main()
++{
++ int n;
++ n = snprintf (0, 0, "%s", "0123456");
++ exit(n != 7);
++}
++], bash_cv_func_snprintf=yes, bash_cv_func_snprintf=no,
++ [AC_MSG_WARN([cannot check standard snprintf if cross-compiling])
++ bash_cv_func_snprintf=yes]
++)])
++ if test $bash_cv_func_snprintf = no; then
++ ac_cv_func_snprintf=no
++ fi
++ fi
++ if test $ac_cv_func_snprintf = no; then
++ AC_DEFINE(HAVE_SNPRINTF, 0,
++ [Define if you have a standard-conformant snprintf function.])
++ fi
++])
++
++AC_DEFUN([BASH_FUNC_VSNPRINTF],
++[
++ AC_CHECK_FUNCS_ONCE([vsnprintf])
++ if test X$ac_cv_func_vsnprintf = Xyes; then
++ AC_CACHE_CHECK([for standard-conformant vsnprintf], [bash_cv_func_vsnprintf],
++ [AC_TRY_RUN([
++#if HAVE_STDARG_H
++#include <stdarg.h>
++#else
++#include <varargs.h>
++#endif
++#include <stdio.h>
++#include <stdlib.h>
++
++static int
++#if HAVE_STDARG_H
++foo(const char *fmt, ...)
++#else
++foo(format, va_alist)
++ const char *format;
++ va_dcl
++#endif
++{
++ va_list args;
++ int n;
++
++#if HAVE_STDARG_H
++ va_start(args, fmt);
++#else
++ va_start(args);
++#endif
++ n = vsnprintf(0, 0, fmt, args);
++ va_end (args);
++ return n;
++}
++
++main()
++{
++ int n;
++ n = foo("%s", "0123456");
++ exit(n != 7);
++}
++], bash_cv_func_vsnprintf=yes, bash_cv_func_vsnprintf=no,
++ [AC_MSG_WARN([cannot check standard vsnprintf if cross-compiling])
++ bash_cv_func_vsnprintf=yes]
++)])
++ if test $bash_cv_func_vsnprintf = no; then
++ ac_cv_func_vsnprintf=no
++ fi
++ fi
++ if test $ac_cv_func_vsnprintf = no; then
++ AC_DEFINE(HAVE_VSNPRINTF, 0,
++ [Define if you have a standard-conformant vsnprintf function.])
++ fi
++])
++
++AC_DEFUN(BASH_STRUCT_WEXITSTATUS_OFFSET,
++[AC_MSG_CHECKING(for offset of exit status in return status from wait)
++AC_CACHE_VAL(bash_cv_wexitstatus_offset,
++[AC_RUN_IFELSE([
++#include <stdlib.h>
++#include <unistd.h>
++
++#include <sys/wait.h>
++
++main(c, v)
++ int c;
++ char **v;
++{
++ pid_t pid, p;
++ int s, i, n;
++
++ s = 0;
++ pid = fork();
++ if (pid == 0)
++ exit (42);
++
++ /* wait for the process */
++ p = wait(&s);
++ if (p != pid)
++ exit (255);
++
++ /* crack s */
++ for (i = 0; i < (sizeof(s) - 8); i++)
++ {
++ n = (s >> i) & 0xff;
++ if (n == 42)
++ exit (i);
++ }
++
++ exit (254);
++}
++], bash_cv_wexitstatus_offset=0, bash_cv_wexitstatus_offset=$?,
++ [AC_MSG_WARN(cannot check WEXITSTATUS offset if cross compiling -- defaulting to 0)
++ bash_cv_wexitstatus_offset=0]
++)])
++if test "$bash_cv_wexitstatus_offset" -gt 32 ; then
++ AC_MSG_WARN(bad exit status from test program -- defaulting to 0)
++ bash_cv_wexitstatus_offset=0
++fi
++AC_MSG_RESULT($bash_cv_wexitstatus_offset)
++AC_DEFINE_UNQUOTED([WEXITSTATUS_OFFSET], [$bash_cv_wexitstatus_offset], [Offset of exit status in wait status word])
++])
+Index: gdb-7.2.90.20110703/readline/ansi_stdlib.h
+===================================================================
+--- gdb-7.2.90.20110703.orig/readline/ansi_stdlib.h 2011-07-03 10:40:53.000000000 +0200
++++ gdb-7.2.90.20110703/readline/ansi_stdlib.h 2011-07-03 10:41:21.000000000 +0200
+@@ -6,19 +6,19 @@
+
+ This file is part of GNU Bash, the Bourne Again SHell.
+
+- Bash is free software; you can redistribute it and/or modify it under
+- the terms of the GNU General Public License as published by the Free
+- Software Foundation; either version 2, or (at your option) any later
+- version.
+-
+- Bash 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 Bash; see the file COPYING. If not, write to the Free Software
+- Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
++ Bash 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.
++
++ Bash 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 Bash. If not, see <http://www.gnu.org/licenses/>.
++*/
+
+ #if !defined (_STDLIB_H_)
+ #define _STDLIB_H_ 1
+Index: gdb-7.2.90.20110703/readline/bind.c
+===================================================================
+--- gdb-7.2.90.20110703.orig/readline/bind.c 2011-07-03 10:40:53.000000000 +0200
++++ gdb-7.2.90.20110703/readline/bind.c 2011-07-03 10:41:21.000000000 +0200
+@@ -1,24 +1,23 @@
+ /* bind.c -- key binding and startup file support for the readline library. */
+
+-/* Copyright (C) 1987-2005 Free Software Foundation, Inc.
++/* Copyright (C) 1987-2010 Free Software Foundation, Inc.
+
+- This file is part of the GNU Readline Library, a library for
+- reading lines of text with interactive input and history editing.
++ This file is part of the GNU Readline Library (Readline), a library
++ for reading lines of text with interactive input and history editing.
+
+- The GNU Readline Library is free software; you can redistribute it
+- and/or modify it under the terms of the GNU General Public License
+- as published by the Free Software Foundation; either version 2, or
++ Readline 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.
+
+- The GNU Readline Library is distributed in the hope that it will be
+- useful, but WITHOUT ANY WARRANTY; without even the implied warranty
+- of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ Readline 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.
+
+- The GNU General Public License is often shipped with GNU software, and
+- is generally kept in a file called COPYING or LICENSE. If you do not
+- have a copy of the license, write to the Free Software Foundation,
+- 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
++ You should have received a copy of the GNU General Public License
++ along with Readline. If not, see <http://www.gnu.org/licenses/>.
++*/
+
+ #define READLINE_LIBRARY
+
+@@ -80,7 +79,7 @@ static int glean_key_from_name PARAMS((c
+ static int find_boolean_var PARAMS((const char *));
+
+ static char *_rl_get_string_variable_value PARAMS((const char *));
+-static int substring_member_of_array PARAMS((char *, const char **));
++static int substring_member_of_array PARAMS((const char *, const char * const *));
+
+ static int currently_reading_init_file;
+
+@@ -317,7 +316,7 @@ rl_macro_bind (keyseq, macro, map)
+
+ if (rl_translate_keyseq (macro, macro_keys, ¯o_keys_len))
+ {
+- free (macro_keys);
++ xfree (macro_keys);
+ return -1;
+ }
+ rl_generic_bind (ISMACR, keyseq, macro_keys, map);
+@@ -347,7 +346,7 @@ rl_generic_bind (type, keyseq, data, map
+ if (keyseq == 0 || *keyseq == 0)
+ {
+ if (type == ISMACR)
+- free (data);
++ xfree (data);
+ return -1;
+ }
+
+@@ -358,7 +357,7 @@ rl_generic_bind (type, keyseq, data, map
+ KEYS into KEYS_LEN. */
+ if (rl_translate_keyseq (keyseq, keys, &keys_len))
+ {
+- free (keys);
++ xfree (keys);
+ return -1;
+ }
+
+@@ -370,7 +369,10 @@ rl_generic_bind (type, keyseq, data, map
+
+ ic = uc;
+ if (ic < 0 || ic >= KEYMAP_SIZE)
+- return -1;
++ {
++ xfree (keys);
++ return -1;
++ }
+
+ if (META_CHAR (ic) && _rl_convert_meta_chars_to_ascii)
+ {
+@@ -411,11 +413,18 @@ rl_generic_bind (type, keyseq, data, map
+ else
+ {
+ if (map[ic].type == ISMACR)
+- free ((char *)map[ic].function);
++ xfree ((char *)map[ic].function);
+ else if (map[ic].type == ISKMAP)
+ {
+ map = FUNCTION_TO_KEYMAP (map, ic);
+ ic = ANYOTHERKEY;
++ /* If we're trying to override a keymap with a null function
++ (e.g., trying to unbind it), we can't use a null pointer
++ here because that's indistinguishable from having not been
++ overridden. We use a special bindable function that does
++ nothing. */
++ if (type == ISFUNC && data == 0)
++ data = (char *)_rl_null_function;
+ }
+
+ map[ic].function = KEYMAP_TO_FUNCTION (data);
+@@ -424,7 +433,7 @@ rl_generic_bind (type, keyseq, data, map
+
+ rl_binding_keymap = map;
+ }
+- free (keys);
++ xfree (keys);
+ return 0;
+ }
+
+@@ -462,12 +471,21 @@ rl_translate_keyseq (seq, array, len)
+ }
+ else if (c == 'M')
+ {
+- i++;
+- /* XXX - should obey convert-meta setting? */
++ i++; /* seq[i] == '-' */
++ /* XXX - obey convert-meta setting */
+ if (_rl_convert_meta_chars_to_ascii && _rl_keymap[ESC].type == ISKMAP)
+ array[l++] = ESC; /* ESC is meta-prefix */
++ else if (seq[i+1] == '\\' && seq[i+2] == 'C' && seq[i+3] == '-')
++ {
++ i += 4;
++ temp = (seq[i] == '?') ? RUBOUT : CTRL (_rl_to_upper (seq[i]));
++ array[l++] = META (temp);
++ }
+ else
+ {
++ /* This doesn't yet handle things like \M-\a, which may
++ or may not have any reasonable meaning. You're
++ probably better off using straight octal or hex. */
+ i++;
+ array[l++] = META (seq[i]);
+ }
+@@ -565,6 +583,11 @@ rl_untranslate_keyseq (seq)
+ kseq[i++] = '-';
+ c = UNMETA (c);
+ }
++ else if (c == ESC)
++ {
++ kseq[i++] = '\\';
++ c = 'e';
++ }
+ else if (CTRL_CHAR (c))
+ {
+ kseq[i++] = '\\';
+@@ -613,7 +636,12 @@ _rl_untranslate_macro_value (seq)
+ *r++ = '-';
+ c = UNMETA (c);
+ }
+- else if (CTRL_CHAR (c) && c != ESC)
++ else if (c == ESC)
++ {
++ *r++ = '\\';
++ c = 'e';
++ }
++ else if (CTRL_CHAR (c))
+ {
+ *r++ = '\\';
+ *r++ = 'C';
+@@ -672,7 +700,7 @@ rl_function_of_keyseq (keyseq, map, type
+ {
+ register int i;
+
+- if (!map)
++ if (map == 0)
+ map = _rl_keymap;
+
+ for (i = 0; keyseq && keyseq[i]; i++)
+@@ -681,25 +709,27 @@ rl_function_of_keyseq (keyseq, map, type
+
+ if (META_CHAR (ic) && _rl_convert_meta_chars_to_ascii)
+ {
+- if (map[ESC].type != ISKMAP)
++ if (map[ESC].type == ISKMAP)
++ {
++ map = FUNCTION_TO_KEYMAP (map, ESC);
++ ic = UNMETA (ic);
++ }
++ /* XXX - should we just return NULL here, since this obviously
++ doesn't match? */
++ else
+ {
+ if (type)
+ *type = map[ESC].type;
+
+ return (map[ESC].function);
+ }
+- else
+- {
+- map = FUNCTION_TO_KEYMAP (map, ESC);
+- ic = UNMETA (ic);
+- }
+ }
+
+ if (map[ic].type == ISKMAP)
+ {
+ /* If this is the last key in the key sequence, return the
+ map. */
+- if (!keyseq[i + 1])
++ if (keyseq[i + 1] == '\0')
+ {
+ if (type)
+ *type = ISKMAP;
+@@ -709,7 +739,12 @@ rl_function_of_keyseq (keyseq, map, type
+ else
+ map = FUNCTION_TO_KEYMAP (map, ic);
+ }
+- else
++ /* If we're not at the end of the key sequence, and the current key
++ is bound to something other than a keymap, then the entire key
++ sequence is not bound. */
++ else if (map[ic].type != ISKMAP && keyseq[i+1])
++ return ((rl_command_func_t *)NULL);
++ else /* map[ic].type != ISKMAP && keyseq[i+1] == 0 */
+ {
+ if (type)
+ *type = map[ic].type;
+@@ -764,10 +799,12 @@ _rl_read_file (filename, sizep)
+
+ if (i < 0)
+ {
+- free (buffer);
++ xfree (buffer);
+ return ((char *)NULL);
+ }
+
++ RL_CHECK_SIGNALS ();
++
+ buffer[i] = '\0';
+ if (sizep)
+ *sizep = i;
+@@ -791,6 +828,7 @@ rl_re_read_init_file (count, ignore)
+ 1. the filename used for the previous call
+ 2. the value of the shell variable `INPUTRC'
+ 3. ~/.inputrc
++ 4. /etc/inputrc
+ If the file existed and could be opened and read, 0 is returned,
+ otherwise errno is returned. */
+ int
+@@ -799,17 +837,18 @@ rl_read_init_file (filename)
+ {
+ /* Default the filename. */
+ if (filename == 0)
++ filename = last_readline_init_file;
++ if (filename == 0)
++ filename = sh_get_env_value ("INPUTRC");
++ if (filename == 0 || *filename == 0)
+ {
+- filename = last_readline_init_file;
+- if (filename == 0)
+- filename = sh_get_env_value ("INPUTRC");
+- if (filename == 0)
+- filename = DEFAULT_INPUTRC;
++ filename = DEFAULT_INPUTRC;
++ /* Try to read DEFAULT_INPUTRC; fall back to SYS_INPUTRC on failure */
++ if (_rl_read_init_file (filename, 0) == 0)
++ return 0;
++ filename = SYS_INPUTRC;
+ }
+
+- if (*filename == 0)
+- filename = DEFAULT_INPUTRC;
+-
+ #if defined (__MSDOS__)
+ if (_rl_read_init_file (filename, 0) == 0)
+ return 0;
+@@ -832,8 +871,9 @@ _rl_read_init_file (filename, include_le
+
+ openname = tilde_expand (filename);
+ buffer = _rl_read_file (openname, &file_size);
+- free (openname);
++ xfree (openname);
+
++ RL_CHECK_SIGNALS ();
+ if (buffer == 0)
+ return (errno);
+
+@@ -880,7 +920,7 @@ _rl_read_init_file (filename, include_le
+ current_readline_init_lineno++;
+ }
+
+- free (buffer);
++ xfree (buffer);
+ currently_reading_init_file = 0;
+ return (0);
+ }
+@@ -890,10 +930,10 @@ _rl_init_file_error (msg)
+ const char *msg;
+ {
+ if (currently_reading_init_file)
+- fprintf (stderr, "readline: %s: line %d: %s\n", current_readline_init_file,
++ _rl_errmsg ("%s: line %d: %s\n", current_readline_init_file,
+ current_readline_init_lineno, msg);
+ else
+- fprintf (stderr, "readline: %s\n", msg);
++ _rl_errmsg ("%s", msg);
+ }
+
+ /* **************************************************************** */
+@@ -905,11 +945,11 @@ _rl_init_file_error (msg)
+ typedef int _rl_parser_func_t PARAMS((char *));
+
+ /* Things that mean `Control'. */
+-const char *_rl_possible_control_prefixes[] = {
++const char * const _rl_possible_control_prefixes[] = {
+ "Control-", "C-", "CTRL-", (const char *)NULL
+ };
+
+-const char *_rl_possible_meta_prefixes[] = {
++const char * const _rl_possible_meta_prefixes[] = {
+ "Meta", "M-", (const char *)NULL
+ };
+
+@@ -971,7 +1011,7 @@ parser_if (args)
+ `$if term=sun-cmd' into their .inputrc. */
+ _rl_parsing_conditionalized_out = _rl_stricmp (args + 5, tname) &&
+ _rl_stricmp (args + 5, rl_terminal_name);
+- free (tname);
++ xfree (tname);
+ }
+ #if defined (VI_MODE)
+ else if (_rl_strnicmp (args, "mode=", 5) == 0)
+@@ -1068,8 +1108,8 @@ parser_include (args)
+ }
+
+ /* Associate textual names with actual functions. */
+-static struct {
+- const char *name;
++static const struct {
++ const char * const name;
+ _rl_parser_func_t *function;
+ } parser_directives [] = {
+ { "if", parser_if },
+@@ -1321,7 +1361,7 @@ rl_parse_and_bind (string)
+ else
+ rl_bind_keyseq (seq, rl_named_function (funname));
+
+- free (seq);
++ xfree (seq);
+ return 0;
+ }
+
+@@ -1375,8 +1415,8 @@ rl_parse_and_bind (string)
+
+ #define V_SPECIAL 0x1
+
+-static struct {
+- const char *name;
++static const struct {
++ const char * const name;
+ int *value;
+ int flags;
+ } boolean_varlist [] = {
+@@ -1384,9 +1424,12 @@ static struct {
+ { "blink-matching-paren", &rl_blink_matching_paren, V_SPECIAL },
+ { "byte-oriented", &rl_byte_oriented, 0 },
+ { "completion-ignore-case", &_rl_completion_case_fold, 0 },
++ { "completion-map-case", &_rl_completion_case_map, 0 },
+ { "convert-meta", &_rl_convert_meta_chars_to_ascii, 0 },
+ { "disable-completion", &rl_inhibit_completion, 0 },
++ { "echo-control-characters", &_rl_echo_control_chars, 0 },
+ { "enable-keypad", &_rl_enable_keypad, 0 },
++ { "enable-meta-key", &_rl_enable_meta, 0 },
+ { "expand-tilde", &rl_complete_with_tilde_expansion, 0 },
+ { "history-preserve-point", &_rl_history_preserve_point, 0 },
+ { "horizontal-scroll-mode", &_rl_horizontal_scroll_mode, 0 },
+@@ -1395,17 +1438,20 @@ static struct {
+ { "mark-modified-lines", &_rl_mark_modified_lines, 0 },
+ { "mark-symlinked-directories", &_rl_complete_mark_symlink_dirs, 0 },
+ { "match-hidden-files", &_rl_match_hidden_files, 0 },
++ { "menu-complete-display-prefix", &_rl_menu_complete_prefix_first, 0 },
+ { "meta-flag", &_rl_meta_flag, 0 },
+ { "output-meta", &_rl_output_meta_chars, 0 },
+ { "page-completions", &_rl_page_completions, 0 },
+ { "prefer-visible-bell", &_rl_prefer_visible_bell, V_SPECIAL },
+ { "print-completions-horizontally", &_rl_print_completions_horizontally, 0 },
++ { "revert-all-at-newline", &_rl_revert_all_at_newline, 0 },
+ { "show-all-if-ambiguous", &_rl_complete_show_all, 0 },
+ { "show-all-if-unmodified", &_rl_complete_show_unmodified, 0 },
++ { "skip-completed-text", &_rl_skip_completed_text, 0 },
+ #if defined (VISIBLE_STATS)
+ { "visible-stats", &rl_visible_stats, 0 },
+ #endif /* VISIBLE_STATS */
+- { (char *)NULL, (int *)NULL }
++ { (char *)NULL, (int *)NULL, 0 }
+ };
+
+ static int
+@@ -1458,23 +1504,29 @@ typedef int _rl_sv_func_t PARAMS((const
+ /* Forward declarations */
+ static int sv_bell_style PARAMS((const char *));
+ static int sv_combegin PARAMS((const char *));
++static int sv_dispprefix PARAMS((const char *));
+ static int sv_compquery PARAMS((const char *));
++static int sv_compwidth PARAMS((const char *));
+ static int sv_editmode PARAMS((const char *));
++static int sv_histsize PARAMS((const char *));
+ static int sv_isrchterm PARAMS((const char *));
+ static int sv_keymap PARAMS((const char *));
+
+-static struct {
+- const char *name;
++static const struct {
++ const char * const name;
+ int flags;
+ _rl_sv_func_t *set_func;
+ } string_varlist[] = {
+ { "bell-style", V_STRING, sv_bell_style },
+ { "comment-begin", V_STRING, sv_combegin },
++ { "completion-display-width", V_INT, sv_compwidth },
++ { "completion-prefix-display-length", V_INT, sv_dispprefix },
+ { "completion-query-items", V_INT, sv_compquery },
+ { "editing-mode", V_STRING, sv_editmode },
++ { "history-size", V_INT, sv_histsize },
+ { "isearch-terminators", V_STRING, sv_isrchterm },
+ { "keymap", V_STRING, sv_keymap },
+- { (char *)NULL, 0 }
++ { (char *)NULL, 0, (_rl_sv_func_t *)0 }
+ };
+
+ static int
+@@ -1506,8 +1558,6 @@ rl_variable_value (name)
+ const char *name;
+ {
+ register int i;
+- int v;
+- char *ret;
+
+ /* Check for simple variables first. */
+ i = find_boolean_var (name);
+@@ -1585,6 +1635,22 @@ sv_combegin (value)
+ }
+
+ static int
++sv_dispprefix (value)
++ const char *value;
++{
++ int nval = 0;
++
++ if (value && *value)
++ {
++ nval = atoi (value);
++ if (nval < 0)
++ nval = 0;
++ }
++ _rl_completion_prefix_display_length = nval;
++ return 0;
++}
++
++static int
+ sv_compquery (value)
+ const char *value;
+ {
+@@ -1601,6 +1667,35 @@ sv_compquery (value)
+ }
+
+ static int
++sv_compwidth (value)
++ const char *value;
++{
++ int nval = -1;
++
++ if (value && *value)
++ nval = atoi (value);
++
++ _rl_completion_columns = nval;
++ return 0;
++}
++
++static int
++sv_histsize (value)
++ const char *value;
++{
++ int nval = 500;
++
++ if (value && *value)
++ {
++ nval = atoi (value);
++ if (nval < 0)
++ return 1;
++ }
++ stifle_history (nval);
++ return 0;
++}
++
++static int
+ sv_keymap (value)
+ const char *value;
+ {
+@@ -1664,7 +1759,7 @@ sv_isrchterm (value)
+ rl_translate_keyseq (v + beg, _rl_isearch_terminators, &end);
+ _rl_isearch_terminators[end] = '\0';
+
+- free (v);
++ xfree (v);
+ return 0;
+ }
+
+@@ -1672,11 +1767,11 @@ sv_isrchterm (value)
+ For example, `Space' returns ' '. */
+
+ typedef struct {
+- const char *name;
++ const char * const name;
+ int value;
+ } assoc_list;
+
+-static assoc_list name_key_alist[] = {
++static const assoc_list name_key_alist[] = {
+ { "DEL", 0x7f },
+ { "ESC", '\033' },
+ { "Escape", '\033' },
+@@ -1705,8 +1800,8 @@ glean_key_from_name (name)
+ }
+
+ /* Auxiliary functions to manage keymaps. */
+-static struct {
+- const char *name;
++static const struct {
++ const char * const name;
+ Keymap map;
+ } keymap_names[] = {
+ { "emacs", emacs_standard_keymap },
+@@ -1809,7 +1904,7 @@ rl_list_funmap_names ()
+ for (i = 0; funmap_names[i]; i++)
+ fprintf (rl_outstream, "%s\n", funmap_names[i]);
+
+- free (funmap_names);
++ xfree (funmap_names);
+ }
+
+ static char *
+@@ -1948,12 +2043,16 @@ rl_invoking_keyseqs_in_map (function, ma
+ char *keyname = (char *)xmalloc (6 + strlen (seqs[i]));
+
+ if (key == ESC)
+-#if 0
+- sprintf (keyname, "\\e");
+-#else
+- /* XXX - experimental */
+- sprintf (keyname, "\\M-");
+-#endif
++ {
++ /* If ESC is the meta prefix and we're converting chars
++ with the eighth bit set to ESC-prefixed sequences, then
++ we can use \M-. Otherwise we need to use the sequence
++ for ESC. */
++ if (_rl_convert_meta_chars_to_ascii && map[ESC].type == ISKMAP)
++ sprintf (keyname, "\\M-");
++ else
++ sprintf (keyname, "\\e");
++ }
+ else if (CTRL_CHAR (key))
+ sprintf (keyname, "\\C-%c", _rl_to_lower (UNCTRL (key)));
+ else if (key == RUBOUT)
+@@ -1971,7 +2070,7 @@ rl_invoking_keyseqs_in_map (function, ma
+ }
+
+ strcat (keyname, seqs[i]);
+- free (seqs[i]);
++ xfree (seqs[i]);
+
+ if (result_index + 2 > result_size)
+ {
+@@ -1983,7 +2082,7 @@ rl_invoking_keyseqs_in_map (function, ma
+ result[result_index] = (char *)NULL;
+ }
+
+- free (seqs);
++ xfree (seqs);
+ }
+ break;
+ }
+@@ -2035,10 +2134,10 @@ rl_function_dumper (print_readably)
+ {
+ fprintf (rl_outstream, "\"%s\": %s\n",
+ invokers[j], name);
+- free (invokers[j]);
++ xfree (invokers[j]);
+ }
+
+- free (invokers);
++ xfree (invokers);
+ }
+ }
+ else
+@@ -2062,9 +2161,9 @@ rl_function_dumper (print_readably)
+ fprintf (rl_outstream, "...\n");
+
+ for (j = 0; invokers[j]; j++)
+- free (invokers[j]);
++ xfree (invokers[j]);
+
+- free (invokers);
++ xfree (invokers);
+ }
+ }
+ }
+@@ -2111,8 +2210,8 @@ _rl_macro_dumper_internal (print_readabl
+ fprintf (rl_outstream, "%s%s outputs %s\n", prefix ? prefix : "",
+ keyname,
+ out ? out : "");
+- free (keyname);
+- free (out);
++ xfree (keyname);
++ xfree (out);
+ break;
+ case ISFUNC:
+ break;
+@@ -2135,13 +2234,13 @@ _rl_macro_dumper_internal (print_readabl
+ out = (char *)xmalloc (strlen (keyname) + prefix_len + 1);
+ strcpy (out, prefix);
+ strcpy (out + prefix_len, keyname);
+- free (keyname);
++ xfree (keyname);
+ keyname = out;
+ }
+ }
+
+ _rl_macro_dumper_internal (print_readably, FUNCTION_TO_KEYMAP (map, key), keyname);
+- free (keyname);
++ xfree (keyname);
+ break;
+ }
+ }
+@@ -2171,7 +2270,6 @@ _rl_get_string_variable_value (name)
+ {
+ static char numbuf[32];
+ char *ret;
+- int n;
+
+ if (_rl_stricmp (name, "bell-style") == 0)
+ {
+@@ -2188,6 +2286,16 @@ _rl_get_string_variable_value (name)
+ }
+ else if (_rl_stricmp (name, "comment-begin") == 0)
+ return (_rl_comment_begin ? _rl_comment_begin : RL_COMMENT_BEGIN_DEFAULT);
++ else if (_rl_stricmp (name, "completion-display-width") == 0)
++ {
++ sprintf (numbuf, "%d", _rl_completion_columns);
++ return (numbuf);
++ }
++ else if (_rl_stricmp (name, "completion-prefix-display-length") == 0)
++ {
++ sprintf (numbuf, "%d", _rl_completion_prefix_display_length);
++ return (numbuf);
++ }
+ else if (_rl_stricmp (name, "completion-query-items") == 0)
+ {
+ sprintf (numbuf, "%d", rl_completion_query_items);
+@@ -2195,6 +2303,11 @@ _rl_get_string_variable_value (name)
+ }
+ else if (_rl_stricmp (name, "editing-mode") == 0)
+ return (rl_get_keymap_name_from_edit_mode ());
++ else if (_rl_stricmp (name, "history-size") == 0)
++ {
++ sprintf (numbuf, "%d", history_is_stifled() ? history_max_entries : 0);
++ return (numbuf);
++ }
+ else if (_rl_stricmp (name, "isearch-terminators") == 0)
+ {
+ if (_rl_isearch_terminators == 0)
+@@ -2203,7 +2316,7 @@ _rl_get_string_variable_value (name)
+ if (ret)
+ {
+ strncpy (numbuf, ret, sizeof (numbuf) - 1);
+- free (ret);
++ xfree (ret);
+ numbuf[sizeof(numbuf) - 1] = '\0';
+ }
+ else
+@@ -2267,8 +2380,8 @@ rl_dump_variables (count, key)
+ /* Return non-zero if any members of ARRAY are a substring in STRING. */
+ static int
+ substring_member_of_array (string, array)
+- char *string;
+- const char **array;
++ const char *string;
++ const char * const *array;
+ {
+ while (*array)
+ {
+Index: gdb-7.2.90.20110703/readline/callback.c
+===================================================================
+--- gdb-7.2.90.20110703.orig/readline/callback.c 2011-07-03 10:40:53.000000000 +0200
++++ gdb-7.2.90.20110703/readline/callback.c 2011-07-03 10:41:21.000000000 +0200
+@@ -1,24 +1,24 @@
+ /* callback.c -- functions to use readline as an X `callback' mechanism. */
+
+-/* Copyright (C) 1987-2005 Free Software Foundation, Inc.
++/* Copyright (C) 1987-2009 Free Software Foundation, Inc.
+
+- This file is part of the GNU Readline Library, a library for
+- reading lines of text with interactive input and history editing.
++ This file is part of the GNU Readline Library (Readline), a library
++ for reading lines of text with interactive input and history editing.
+
+- The GNU Readline Library is free software; you can redistribute it
+- and/or modify it under the terms of the GNU General Public License
+- as published by the Free Software Foundation; either version 2, or
++ Readline 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.
+
+- The GNU Readline Library is distributed in the hope that it will be
+- useful, but WITHOUT ANY WARRANTY; without even the implied warranty
+- of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ Readline 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.
+
+- The GNU General Public License is often shipped with GNU software, and
+- is generally kept in a file called COPYING or LICENSE. If you do not
+- have a copy of the license, write to the Free Software Foundation,
+- 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
++ You should have received a copy of the GNU General Public License
++ along with Readline. If not, see <http://www.gnu.org/licenses/>.
++*/
++
+ #define READLINE_LIBRARY
+
+ #if defined (HAVE_CONFIG_H)
+@@ -87,6 +87,7 @@ _rl_callback_newline ()
+ }
+
+ readline_internal_setup ();
++ RL_CHECK_SIGNALS ();
+ }
+
+ /* Install a readline handler, set up the terminal, and issue the prompt. */
+@@ -111,87 +112,101 @@ rl_callback_read_char ()
+
+ if (rl_linefunc == NULL)
+ {
+- fprintf (stderr, "readline: readline_callback_read_char() called with no handler!\r\n");
++ _rl_errmsg ("readline_callback_read_char() called with no handler!");
+ abort ();
+ }
+
+- memcpy ((void *)olevel, (void *)readline_top_level, sizeof (procenv_t));
+- jcode = setjmp (readline_top_level);
++ memcpy ((void *)olevel, (void *)_rl_top_level, sizeof (procenv_t));
++ jcode = setjmp (_rl_top_level);
+ if (jcode)
+ {
+ (*rl_redisplay_function) ();
+ _rl_want_redisplay = 0;
+- memcpy ((void *)readline_top_level, (void *)olevel, sizeof (procenv_t));
++ memcpy ((void *)_rl_top_level, (void *)olevel, sizeof (procenv_t));
+ return;
+ }
+
+- if (RL_ISSTATE (RL_STATE_ISEARCH))
++ do
+ {
+- eof = _rl_isearch_callback (_rl_iscxt);
+- if (eof == 0 && (RL_ISSTATE (RL_STATE_ISEARCH) == 0) && RL_ISSTATE (RL_STATE_INPUTPENDING))
+- rl_callback_read_char ();
++ RL_CHECK_SIGNALS ();
++ if (RL_ISSTATE (RL_STATE_ISEARCH))
++ {
++ eof = _rl_isearch_callback (_rl_iscxt);
++ if (eof == 0 && (RL_ISSTATE (RL_STATE_ISEARCH) == 0) && RL_ISSTATE (RL_STATE_INPUTPENDING))
++ rl_callback_read_char ();
+
+- return;
+- }
+- else if (RL_ISSTATE (RL_STATE_NSEARCH))
+- {
+- eof = _rl_nsearch_callback (_rl_nscxt);
+- return;
+- }
+- else if (RL_ISSTATE (RL_STATE_NUMERICARG))
+- {
+- eof = _rl_arg_callback (_rl_argcxt);
+- if (eof == 0 && (RL_ISSTATE (RL_STATE_NUMERICARG) == 0) && RL_ISSTATE (RL_STATE_INPUTPENDING))
+- rl_callback_read_char ();
+- /* XXX - this should handle _rl_last_command_was_kill better */
+- else if (RL_ISSTATE (RL_STATE_NUMERICARG) == 0)
+- _rl_internal_char_cleanup ();
++ return;
++ }
++ else if (RL_ISSTATE (RL_STATE_NSEARCH))
++ {
++ eof = _rl_nsearch_callback (_rl_nscxt);
++ return;
++ }
++#if defined (VI_MODE)
++ else if (RL_ISSTATE (RL_STATE_VIMOTION))
++ {
++ eof = _rl_vi_domove_callback (_rl_vimvcxt);
++ /* Should handle everything, including cleanup, numeric arguments,
++ and turning off RL_STATE_VIMOTION */
++ if (RL_ISSTATE (RL_STATE_NUMERICARG) == 0)
++ _rl_internal_char_cleanup ();
+
+- return;
+- }
+- else if (RL_ISSTATE (RL_STATE_MULTIKEY))
+- {
+- eof = _rl_dispatch_callback (_rl_kscxt); /* For now */
+- while ((eof == -1 || eof == -2) && RL_ISSTATE (RL_STATE_MULTIKEY) && _rl_kscxt && (_rl_kscxt->flags & KSEQ_DISPATCHED))
+- eof = _rl_dispatch_callback (_rl_kscxt);
+- if (RL_ISSTATE (RL_STATE_MULTIKEY) == 0)
++ return;
++ }
++#endif
++ else if (RL_ISSTATE (RL_STATE_NUMERICARG))
++ {
++ eof = _rl_arg_callback (_rl_argcxt);
++ if (eof == 0 && (RL_ISSTATE (RL_STATE_NUMERICARG) == 0) && RL_ISSTATE (RL_STATE_INPUTPENDING))
++ rl_callback_read_char ();
++ /* XXX - this should handle _rl_last_command_was_kill better */
++ else if (RL_ISSTATE (RL_STATE_NUMERICARG) == 0)
++ _rl_internal_char_cleanup ();
++
++ return;
++ }
++ else if (RL_ISSTATE (RL_STATE_MULTIKEY))
+ {
+- _rl_internal_char_cleanup ();
+- _rl_want_redisplay = 1;
++ eof = _rl_dispatch_callback (_rl_kscxt); /* For now */
++ while ((eof == -1 || eof == -2) && RL_ISSTATE (RL_STATE_MULTIKEY) && _rl_kscxt && (_rl_kscxt->flags & KSEQ_DISPATCHED))
++ eof = _rl_dispatch_callback (_rl_kscxt);
++ if (RL_ISSTATE (RL_STATE_MULTIKEY) == 0)
++ {
++ _rl_internal_char_cleanup ();
++ _rl_want_redisplay = 1;
++ }
+ }
+- }
+- else if (_rl_callback_func)
+- {
+- /* This allows functions that simply need to read an additional character
+- (like quoted-insert) to register a function to be called when input is
+- available. _rl_callback_data is simply a pointer to a struct that has
+- the argument count originally passed to the registering function and
+- space for any additional parameters. */
+- eof = (*_rl_callback_func) (_rl_callback_data);
+- /* If the function `deregisters' itself, make sure the data is cleaned
+- up. */
+- if (_rl_callback_func == 0)
++ else if (_rl_callback_func)
+ {
+- if (_rl_callback_data)
++ /* This allows functions that simply need to read an additional
++ character (like quoted-insert) to register a function to be
++ called when input is available. _rl_callback_data is simply a
++ pointer to a struct that has the argument count originally
++ passed to the registering function and space for any additional
++ parameters. */
++ eof = (*_rl_callback_func) (_rl_callback_data);
++ /* If the function `deregisters' itself, make sure the data is
++ cleaned up. */
++ if (_rl_callback_func == 0)
+ {
+- _rl_callback_data_dispose (_rl_callback_data);
+- _rl_callback_data = 0;
++ if (_rl_callback_data)
++ {
++ _rl_callback_data_dispose (_rl_callback_data);
++ _rl_callback_data = 0;
++ }
++ _rl_internal_char_cleanup ();
+ }
+- _rl_internal_char_cleanup ();
+ }
+- }
+- else
+- eof = readline_internal_char ();
++ else
++ eof = readline_internal_char ();
+
+- if (rl_done == 0 && _rl_want_redisplay)
+- {
+- (*rl_redisplay_function) ();
+- _rl_want_redisplay = 0;
+- }
++ RL_CHECK_SIGNALS ();
++ if (rl_done == 0 && _rl_want_redisplay)
++ {
++ (*rl_redisplay_function) ();
++ _rl_want_redisplay = 0;
++ }
+
+- /* We loop in case some function has pushed input back with rl_execute_next. */
+- for (;;)
+- {
+ if (rl_done)
+ {
+ line = readline_internal_teardown (eof);
+@@ -213,11 +228,8 @@ rl_callback_read_char ()
+ if (in_handler == 0 && rl_linefunc)
+ _rl_callback_newline ();
+ }
+- if (rl_pending_input || _rl_pushed_input_available () || RL_ISSTATE (RL_STATE_MACROINPUT))
+- eof = readline_internal_char ();
+- else
+- break;
+ }
++ while (rl_pending_input || _rl_pushed_input_available () || RL_ISSTATE (RL_STATE_MACROINPUT));
+ }
+
+ /* Remove the handler, and make sure the terminal is in its normal state. */
+@@ -226,6 +238,7 @@ rl_callback_handler_remove ()
+ {
+ rl_linefunc = NULL;
+ RL_UNSETSTATE (RL_STATE_CALLBACK);
++ RL_CHECK_SIGNALS ();
+ if (in_handler)
+ {
+ in_handler = 0;
+@@ -254,8 +267,7 @@ _rl_callback_data_alloc (count)
+ void _rl_callback_data_dispose (arg)
+ _rl_callback_generic_arg *arg;
+ {
+- if (arg)
+- free (arg);
++ xfree (arg);
+ }
+
+ #endif
+Index: gdb-7.2.90.20110703/readline/chardefs.h
+===================================================================
+--- gdb-7.2.90.20110703.orig/readline/chardefs.h 2011-07-03 10:40:53.000000000 +0200
++++ gdb-7.2.90.20110703/readline/chardefs.h 2011-07-03 10:41:21.000000000 +0200
+@@ -1,24 +1,23 @@
+ /* chardefs.h -- Character definitions for readline. */
+
+-/* Copyright (C) 1994 Free Software Foundation, Inc.
++/* Copyright (C) 1994-2009 Free Software Foundation, Inc.
+
+- This file is part of the GNU Readline Library, a library for
+- reading lines of text with interactive input and history editing.
++ This file is part of the GNU Readline Library (Readline), a library
++ for reading lines of text with interactive input and history editing.
+
+- The GNU Readline Library is free software; you can redistribute it
+- and/or modify it under the terms of the GNU General Public License
+- as published by the Free Software Foundation; either version 2, or
++ Readline 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.
+
+- The GNU Readline Library is distributed in the hope that it will be
+- useful, but WITHOUT ANY WARRANTY; without even the implied warranty
+- of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ Readline 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.
+
+- The GNU General Public License is often shipped with GNU software, and
+- is generally kept in a file called COPYING or LICENSE. If you do not
+- have a copy of the license, write to the Free Software Foundation,
+- 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
++ You should have received a copy of the GNU General Public License
++ along with Readline. If not, see <http://www.gnu.org/licenses/>.
++*/
+
+ #ifndef _CHARDEFS_H_
+ #define _CHARDEFS_H_
+Index: gdb-7.2.90.20110703/readline/compat.c
+===================================================================
+--- gdb-7.2.90.20110703.orig/readline/compat.c 2011-07-03 10:40:53.000000000 +0200
++++ gdb-7.2.90.20110703/readline/compat.c 2011-07-03 10:41:21.000000000 +0200
+@@ -1,24 +1,24 @@
+ /* compat.c -- backwards compatibility functions. */
+
+-/* Copyright (C) 2000 Free Software Foundation, Inc.
++/* Copyright (C) 2000-2009 Free Software Foundation, Inc.
+
+- This file is part of the GNU Readline Library, a library for
+- reading lines of text with interactive input and history editing.
++ This file is part of the GNU Readline Library (Readline), a library
++ for reading lines of text with interactive input and history editing.
+
+- The GNU Readline Library is free software; you can redistribute it
+- and/or modify it under the terms of the GNU General Public License
+- as published by the Free Software Foundation; either version 2, or
++ Readline 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.
+
+- The GNU Readline Library is distributed in the hope that it will be
+- useful, but WITHOUT ANY WARRANTY; without even the implied warranty
+- of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ Readline 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.
+
+- The GNU General Public License is often shipped with GNU software, and
+- is generally kept in a file called COPYING or LICENSE. If you do not
+- have a copy of the license, write to the Free Software Foundation,
+- 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
++ You should have received a copy of the GNU General Public License
++ along with Readline. If not, see <http://www.gnu.org/licenses/>.
++*/
++
+ #define READLINE_LIBRARY
+
+ #if defined (HAVE_CONFIG_H)
+Index: gdb-7.2.90.20110703/readline/complete.c
+===================================================================
+--- gdb-7.2.90.20110703.orig/readline/complete.c 2011-07-03 10:40:53.000000000 +0200
++++ gdb-7.2.90.20110703/readline/complete.c 2011-07-03 10:41:21.000000000 +0200
+@@ -1,24 +1,24 @@
+ /* complete.c -- filename completion for readline. */
+
+-/* Copyright (C) 1987-2005 Free Software Foundation, Inc.
++/* Copyright (C) 1987-2011 Free Software Foundation, Inc.
+
+- This file is part of the GNU Readline Library, a library for
+- reading lines of text with interactive input and history editing.
++ This file is part of the GNU Readline Library (Readline), a library
++ for reading lines of text with interactive input and history editing.
+
+- The GNU Readline Library is free software; you can redistribute it
+- and/or modify it under the terms of the GNU General Public License
+- as published by the Free Software Foundation; either version 2, or
++ Readline 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.
+
+- The GNU Readline Library is distributed in the hope that it will be
+- useful, but WITHOUT ANY WARRANTY; without even the implied warranty
+- of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ Readline 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.
+
+- The GNU General Public License is often shipped with GNU software, and
+- is generally kept in a file called COPYING or LICENSE. If you do not
+- have a copy of the license, write to the Free Software Foundation,
+- 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
++ You should have received a copy of the GNU General Public License
++ along with Readline. If not, see <http://www.gnu.org/licenses/>.
++*/
++
+ #define READLINE_LIBRARY
+
+ #if defined (HAVE_CONFIG_H)
+@@ -110,8 +110,8 @@ static int get_y_or_n PARAMS((int));
+ static int _rl_internal_pager PARAMS((int));
+ static char *printable_part PARAMS((char *));
+ static int fnwidth PARAMS((const char *));
+-static int fnprint PARAMS((const char *));
+-static int print_filename PARAMS((char *, char *));
++static int fnprint PARAMS((const char *, int));
++static int print_filename PARAMS((char *, char *, int));
+
+ static char **gen_completion_matches PARAMS((char *, int, int, rl_compentry_func_t *, int, int));
+
+@@ -119,9 +119,11 @@ static char **remove_duplicate_matches P
+ static void insert_match PARAMS((char *, int, int, char *));
+ static int append_to_match PARAMS((char *, int, int, int));
+ static void insert_all_matches PARAMS((char **, int, char *));
++static int complete_fncmp PARAMS((const char *, int, const char *, int));
+ static void display_matches PARAMS((char **));
+ static int compute_lcd_of_matches PARAMS((char **, int, const char *));
+ static int postprocess_matches PARAMS((char ***, int));
++static int complete_get_screenwidth PARAMS((void));
+
+ static char *make_quoted_replacement PARAMS((char *, int, char *));
+
+@@ -157,13 +159,27 @@ int _rl_print_completions_horizontally;
+ #if defined (__MSDOS__) && !defined (__DJGPP__)
+ int _rl_completion_case_fold = 1;
+ #else
+-int _rl_completion_case_fold;
++int _rl_completion_case_fold = 0;
+ #endif
+
+-/* If non-zero, don't match hidden files (filenames beginning with a `.' on
++/* Non-zero means that `-' and `_' are equivalent when comparing filenames
++ for completion. */
++int _rl_completion_case_map = 0;
++
++/* If zero, don't match hidden files (filenames beginning with a `.' on
+ Unix) when doing filename completion. */
+ int _rl_match_hidden_files = 1;
+
++/* Length in characters of a common prefix replaced with an ellipsis (`...')
++ when displaying completion matches. Matches whose printable portion has
++ more than this number of displaying characters in common will have the common
++ display prefix replaced with an ellipsis. */
++int _rl_completion_prefix_display_length = 0;
++
++/* The readline-private number of screen columns to use when displaying
++ matches. If < 0 or > _rl_screenwidth, it is ignored. */
++int _rl_completion_columns = -1;
++
+ /* Global variables available to applications using readline. */
+
+ #if defined (VISIBLE_STATS)
+@@ -173,6 +189,16 @@ int _rl_match_hidden_files = 1;
+ int rl_visible_stats = 0;
+ #endif /* VISIBLE_STATS */
+
++/* If non-zero, when completing in the middle of a word, don't insert
++ characters from the match that match characters following point in
++ the word. This means, for instance, completing when the cursor is
++ after the `e' in `Makefile' won't result in `Makefilefile'. */
++int _rl_skip_completed_text = 0;
++
++/* If non-zero, menu completion displays the common prefix first in the
++ cycle of possible completions instead of the last. */
++int _rl_menu_complete_prefix_first = 0;
++
+ /* If non-zero, then this is the address of a function to call when
+ completing on a directory name. The function is called with
+ the address of a string (the current directory name) as an arg. */
+@@ -180,6 +206,17 @@ rl_icppfunc_t *rl_directory_completion_h
+
+ rl_icppfunc_t *rl_directory_rewrite_hook = (rl_icppfunc_t *)NULL;
+
++/* If non-zero, this is the address of a function to call when reading
++ directory entries from the filesystem for completion and comparing
++ them to the partial word to be completed. The function should
++ either return its first argument (if no conversion takes place) or
++ newly-allocated memory. This can, for instance, convert filenames
++ between character sets for comparison against what's typed at the
++ keyboard. The returned value is what is added to the list of
++ matches. The second argument is the length of the filename to be
++ converted. */
++rl_dequote_func_t *rl_filename_rewrite_hook = (rl_dequote_func_t *)NULL;
++
+ /* Non-zero means readline completion functions perform tilde expansion. */
+ int rl_complete_with_tilde_expansion = 0;
+
+@@ -188,6 +225,10 @@ int rl_complete_with_tilde_expansion = 0
+ completer. */
+ rl_compentry_func_t *rl_completion_entry_function = (rl_compentry_func_t *)NULL;
+
++/* Pointer to generator function for rl_menu_complete (). NULL means to use
++ *rl_completion_entry_function (see above). */
++rl_compentry_func_t *rl_menu_completion_entry_function = (rl_compentry_func_t *)NULL;
++
+ /* Pointer to alternative function to create matches.
+ Function is called with TEXT, START, and END.
+ START and END are indices in RL_LINE_BUFFER saying what the boundaries
+@@ -325,11 +366,20 @@ int rl_completion_mark_symlink_dirs;
+ /* If non-zero, inhibit completion (temporarily). */
+ int rl_inhibit_completion;
+
++/* Set to the last key used to invoke one of the completion functions */
++int rl_completion_invoking_key;
++
++/* If non-zero, sort the completion matches. On by default. */
++int rl_sort_completion_matches = 1;
++
+ /* Variables local to this file. */
+
+ /* Local variable states what happened during the last completion attempt. */
+ static int completion_changed_buffer;
+
++/* The result of the query to the user about displaying completion matches */
++static int completion_y_or_n;
++
+ /*************************************/
+ /* */
+ /* Bindable completion functions */
+@@ -343,6 +393,8 @@ int
+ rl_complete (ignore, invoking_key)
+ int ignore, invoking_key;
+ {
++ rl_completion_invoking_key = invoking_key;
++
+ if (rl_inhibit_completion)
+ return (_rl_insert_char (ignore, invoking_key));
+ else if (rl_last_func == rl_complete && !completion_changed_buffer)
+@@ -360,6 +412,7 @@ int
+ rl_possible_completions (ignore, invoking_key)
+ int ignore, invoking_key;
+ {
++ rl_completion_invoking_key = invoking_key;
+ return (rl_complete_internal ('?'));
+ }
+
+@@ -367,6 +420,7 @@ int
+ rl_insert_completions (ignore, invoking_key)
+ int ignore, invoking_key;
+ {
++ rl_completion_invoking_key = invoking_key;
+ return (rl_complete_internal ('*'));
+ }
+
+@@ -395,6 +449,14 @@ rl_completion_mode (cfunc)
+ /* */
+ /************************************/
+
++/* Reset readline state on a signal or other event. */
++void
++_rl_reset_completion_state ()
++{
++ rl_completion_found_quote = 0;
++ rl_completion_quote_character = 0;
++}
++
+ /* Set default values for readline word completion. These are the variables
+ that application completion functions can change or inspect. */
+ static void
+@@ -406,6 +468,7 @@ set_completion_defaults (what_to_do)
+ rl_filename_quoting_desired = 1;
+ rl_completion_type = what_to_do;
+ rl_completion_suppress_append = rl_completion_suppress_quote = 0;
++ rl_completion_append_character = ' ';
+
+ /* The completion entry function may optionally change this. */
+ rl_completion_mark_symlink_dirs = _rl_complete_mark_symlink_dirs;
+@@ -418,6 +481,19 @@ get_y_or_n (for_pager)
+ {
+ int c;
+
++/* Disabled for GDB due to the gdb.base/readline-ask.exp regression.
++ [patch] testsuite: Test readline-6.2 "ask" regression
++ http://sourceware.org/ml/gdb-patches/2011-05/msg00002.html */
++#if 0
++ /* For now, disable pager in callback mode, until we later convert to state
++ driven functions. Have to wait until next major version to add new
++ state definition, since it will change value of RL_STATE_DONE. */
++#if defined (READLINE_CALLBACKS)
++ if (RL_ISSTATE (RL_STATE_CALLBACK))
++ return 1;
++#endif
++#endif
++
+ for (;;)
+ {
+ RL_SETSTATE(RL_STATE_MOREINPUT);
+@@ -428,7 +504,7 @@ get_y_or_n (for_pager)
+ return (1);
+ if (c == 'n' || c == 'N' || c == RUBOUT)
+ return (0);
+- if (c == ABORT_CHAR)
++ if (c == ABORT_CHAR || c < 0)
+ _rl_abort_internal ();
+ if (for_pager && (c == NEWLINE || c == RETURN))
+ return (2);
+@@ -481,6 +557,13 @@ stat_char (filename)
+ struct stat finfo;
+ int character, r;
+
++ /* Short-circuit a //server on cygwin, since that will always behave as
++ a directory. */
++#if __CYGWIN__
++ if (filename[0] == '/' && filename[1] == '/' && strchr (filename+2, '/') == 0)
++ return '/';
++#endif
++
+ #if defined (HAVE_LSTAT) && defined (S_ISLNK)
+ r = lstat (filename, &finfo);
+ #else
+@@ -581,7 +664,7 @@ fnwidth (string)
+ width = pos = 0;
+ while (string[pos])
+ {
+- if (CTRL_CHAR (*string) || *string == RUBOUT)
++ if (CTRL_CHAR (string[pos]) || string[pos] == RUBOUT)
+ {
+ width += 2;
+ pos++;
+@@ -614,17 +697,20 @@ fnwidth (string)
+ return width;
+ }
+
++#define ELLIPSIS_LEN 3
++
+ static int
+-fnprint (to_print)
++fnprint (to_print, prefix_bytes)
+ const char *to_print;
++ int prefix_bytes;
+ {
+- int printed_len;
++ int printed_len, w;
+ const char *s;
+ #if defined (HANDLE_MULTIBYTE)
+ mbstate_t ps;
+ const char *end;
+ size_t tlen;
+- int width, w;
++ int width;
+ wchar_t wc;
+
+ end = to_print + strlen (to_print) + 1;
+@@ -632,7 +718,23 @@ fnprint (to_print)
+ #endif
+
+ printed_len = 0;
+- s = to_print;
++
++ /* Don't print only the ellipsis if the common prefix is one of the
++ possible completions */
++ if (to_print[prefix_bytes] == '\0')
++ prefix_bytes = 0;
++
++ if (prefix_bytes)
++ {
++ char ellipsis;
++
++ ellipsis = (to_print[prefix_bytes] == '.') ? '_' : '.';
++ for (w = 0; w < ELLIPSIS_LEN; w++)
++ putc (ellipsis, rl_outstream);
++ printed_len = ELLIPSIS_LEN;
++ }
++
++ s = to_print + prefix_bytes;
+ while (*s)
+ {
+ if (CTRL_CHAR (*s))
+@@ -691,14 +793,15 @@ fnprint (to_print)
+ filenames. Return the number of characters we output. */
+
+ static int
+-print_filename (to_print, full_pathname)
++print_filename (to_print, full_pathname, prefix_bytes)
+ char *to_print, *full_pathname;
++ int prefix_bytes;
+ {
+ int printed_len, extension_char, slen, tlen;
+ char *s, c, *new_full_pathname, *dn;
+
+ extension_char = 0;
+- printed_len = fnprint (to_print);
++ printed_len = fnprint (to_print, prefix_bytes);
+
+ #if defined (VISIBLE_STATS)
+ if (rl_filename_completion_desired && (rl_visible_stats || _rl_complete_mark_directories))
+@@ -753,7 +856,7 @@ print_filename (to_print, full_pathname)
+ if (path_isdir (new_full_pathname))
+ extension_char = '/';
+
+- free (new_full_pathname);
++ xfree (new_full_pathname);
+ to_print[-1] = c;
+ }
+ else
+@@ -768,7 +871,7 @@ print_filename (to_print, full_pathname)
+ extension_char = '/';
+ }
+
+- free (s);
++ xfree (s);
+ if (extension_char)
+ {
+ putc (extension_char, rl_outstream);
+@@ -950,7 +1053,7 @@ gen_completion_matches (text, start, end
+ rl_compentry_func_t *our_func;
+ int found_quote, quote_char;
+ {
+- char **matches, *temp;
++ char **matches;
+
+ rl_completion_found_quote = found_quote;
+ rl_completion_quote_character = quote_char;
+@@ -960,7 +1063,10 @@ gen_completion_matches (text, start, end
+ variable rl_attempted_completion_function. */
+ if (rl_attempted_completion_function)
+ {
++ _rl_interrupt_immediately++;
+ matches = (*rl_attempted_completion_function) (text, start, end);
++ if (_rl_interrupt_immediately > 0)
++ _rl_interrupt_immediately--;
+
+ if (matches || rl_attempted_completion_over)
+ {
+@@ -969,21 +1075,9 @@ gen_completion_matches (text, start, end
+ }
+ }
+
+- /* Beware -- we're stripping the quotes here. Do this only if we know
+- we are doing filename completion and the application has defined a
+- filename dequoting function. */
+- temp = (char *)NULL;
+-
+- if (found_quote && our_func == rl_filename_completion_function &&
+- rl_filename_dequoting_function)
+- {
+- /* delete single and double quotes */
+- temp = (*rl_filename_dequoting_function) (text, quote_char);
+- text = temp; /* not freeing text is not a memory leak */
+- }
++ /* XXX -- filename dequoting moved into rl_filename_completion_function */
+
+ matches = rl_completion_matches (text, our_func);
+- FREE (temp);
+ return matches;
+ }
+
+@@ -1004,7 +1098,7 @@ remove_duplicate_matches (matches)
+
+ /* Sort the array without matches[0], since we need it to
+ stay in place no matter what. */
+- if (i)
++ if (i && rl_sort_completion_matches)
+ qsort (matches+1, i-1, sizeof (char *), (QSFUNC *)_rl_qsort_string_compare);
+
+ /* Remember the lowest common denominator for it may be unique. */
+@@ -1014,7 +1108,7 @@ remove_duplicate_matches (matches)
+ {
+ if (strcmp (matches[i], matches[i + 1]) == 0)
+ {
+- free (matches[i]);
++ xfree (matches[i]);
+ matches[i] = (char *)&dead_slot;
+ }
+ else
+@@ -1032,7 +1126,7 @@ remove_duplicate_matches (matches)
+ temp_array[j] = (char *)NULL;
+
+ if (matches[0] != (char *)&dead_slot)
+- free (matches[0]);
++ xfree (matches[0]);
+
+ /* Place the lowest common denominator back in [0]. */
+ temp_array[0] = lowest_common;
+@@ -1042,7 +1136,7 @@ remove_duplicate_matches (matches)
+ insert. */
+ if (j == 2 && strcmp (temp_array[0], temp_array[1]) == 0)
+ {
+- free (temp_array[1]);
++ xfree (temp_array[1]);
+ temp_array[1] = (char *)NULL;
+ }
+ return (temp_array);
+@@ -1116,7 +1210,8 @@ compute_lcd_of_matches (match_list, matc
+ #if defined (HANDLE_MULTIBYTE)
+ if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
+ {
+- mbstate_t ps_back = ps1;
++ mbstate_t ps_back;
++ ps_back = ps1;
+ if (!_rl_compare_chars (match_list[i], si, &ps1, match_list[i+1], si, &ps2))
+ break;
+ else if ((v = _rl_get_char_len (&match_list[i][si], &ps_back)) > 1)
+@@ -1220,7 +1315,7 @@ postprocess_matches (matchesp, matching_
+ if (rl_ignore_completion_duplicates)
+ {
+ temp_matches = remove_duplicate_matches (matches);
+- free (matches);
++ xfree (matches);
+ matches = temp_matches;
+ }
+
+@@ -1257,6 +1352,23 @@ postprocess_matches (matchesp, matching_
+ return (1);
+ }
+
++static int
++complete_get_screenwidth ()
++{
++ int cols;
++ char *envcols;
++
++ cols = _rl_completion_columns;
++ if (cols >= 0 && cols <= _rl_screenwidth)
++ return cols;
++ envcols = getenv ("COLUMNS");
++ if (envcols && *envcols)
++ cols = atoi (envcols);
++ if (cols >= 0 && cols <= _rl_screenwidth)
++ return cols;
++ return _rl_screenwidth;
++}
++
+ /* A convenience function for displaying a list of strings in
+ columnar format on readline's output stream. MATCHES is the list
+ of strings, in argv format, LEN is the number of strings in MATCHES,
+@@ -1266,17 +1378,38 @@ rl_display_match_list (matches, len, max
+ char **matches;
+ int len, max;
+ {
+- int count, limit, printed_len, lines;
+- int i, j, k, l;
+- char *temp;
++ int count, limit, printed_len, lines, cols;
++ int i, j, k, l, common_length, sind;
++ char *temp, *t;
++
++ /* Find the length of the prefix common to all items: length as displayed
++ characters (common_length) and as a byte index into the matches (sind) */
++ common_length = sind = 0;
++ if (_rl_completion_prefix_display_length > 0)
++ {
++ t = printable_part (matches[0]);
++ temp = strrchr (t, '/');
++ common_length = temp ? fnwidth (temp) : fnwidth (t);
++ sind = temp ? strlen (temp) : strlen (t);
++
++ if (common_length > _rl_completion_prefix_display_length && common_length > ELLIPSIS_LEN)
++ max -= common_length - ELLIPSIS_LEN;
++ else
++ common_length = sind = 0;
++ }
+
+ /* How many items of MAX length can we fit in the screen window? */
++ cols = complete_get_screenwidth ();
+ max += 2;
+- limit = _rl_screenwidth / max;
+- if (limit != 1 && (limit * max == _rl_screenwidth))
++ limit = cols / max;
++ if (limit != 1 && (limit * max == cols))
+ limit--;
+
+- /* Avoid a possible floating exception. If max > _rl_screenwidth,
++ /* If cols == 0, limit will end up -1 */
++ if (cols < _rl_screenwidth && limit < 0)
++ limit = 1;
++
++ /* Avoid a possible floating exception. If max > cols,
+ limit will be 0 and a divide-by-zero fault will result. */
+ if (limit == 0)
+ limit = 1;
+@@ -1289,7 +1422,7 @@ rl_display_match_list (matches, len, max
+ 0 < len <= limit implies count = 1. */
+
+ /* Sort the items if they are not already sorted. */
+- if (rl_ignore_completion_duplicates == 0)
++ if (rl_ignore_completion_duplicates == 0 && rl_sort_completion_matches)
+ qsort (matches + 1, len, sizeof (char *), (QSFUNC *)_rl_qsort_string_compare);
+
+ rl_crlf ();
+@@ -1307,7 +1440,7 @@ rl_display_match_list (matches, len, max
+ else
+ {
+ temp = printable_part (matches[l]);
+- printed_len = print_filename (temp, matches[l]);
++ printed_len = print_filename (temp, matches[l], sind);
+
+ if (j + 1 < limit)
+ for (k = 0; k < max - printed_len; k++)
+@@ -1331,7 +1464,7 @@ rl_display_match_list (matches, len, max
+ for (i = 1; matches[i]; i++)
+ {
+ temp = printable_part (matches[i]);
+- printed_len = print_filename (temp, matches[i]);
++ printed_len = print_filename (temp, matches[i], sind);
+ /* Have we reached the end of this line? */
+ if (matches[i+1])
+ {
+@@ -1381,7 +1514,7 @@ display_matches (matches)
+ {
+ temp = printable_part (matches[0]);
+ rl_crlf ();
+- print_filename (temp, matches[0]);
++ print_filename (temp, matches[0], 0);
+ rl_crlf ();
+
+ rl_forced_update_display ();
+@@ -1417,7 +1550,7 @@ display_matches (matches)
+ rl_crlf ();
+ fprintf (rl_outstream, "Display all %d possibilities? (y or n)", len);
+ fflush (rl_outstream);
+- if (get_y_or_n (0) == 0)
++ if ((completion_y_or_n = get_y_or_n (0)) == 0)
+ {
+ rl_crlf ();
+
+@@ -1485,8 +1618,9 @@ insert_match (match, start, mtype, qc)
+ int start, mtype;
+ char *qc;
+ {
+- char *replacement;
++ char *replacement, *r;
+ char oqc;
++ int end, rlen;
+
+ oqc = qc ? *qc : '\0';
+ replacement = make_quoted_replacement (match, mtype, qc);
+@@ -1494,6 +1628,7 @@ insert_match (match, start, mtype, qc)
+ /* Now insert the match. */
+ if (replacement)
+ {
++ rlen = strlen (replacement);
+ /* Don't double an opening quote character. */
+ if (qc && *qc && start && rl_line_buffer[start - 1] == *qc &&
+ replacement[0] == *qc)
+@@ -1503,9 +1638,26 @@ insert_match (match, start, mtype, qc)
+ else if (qc && (*qc != oqc) && start && rl_line_buffer[start - 1] == oqc &&
+ replacement[0] != oqc)
+ start--;
+- _rl_replace_text (replacement, start, rl_point - 1);
++ end = rl_point - 1;
++ /* Don't double a closing quote character */
++ if (qc && *qc && end && rl_line_buffer[rl_point] == *qc && replacement[rlen - 1] == *qc)
++ end++;
++ if (_rl_skip_completed_text)
++ {
++ r = replacement;
++ while (start < rl_end && *r && rl_line_buffer[start] == *r)
++ {
++ start++;
++ r++;
++ }
++ if (start <= end || *r)
++ _rl_replace_text (r, start, end);
++ rl_point = start + strlen (r);
++ }
++ else
++ _rl_replace_text (replacement, start, end);
+ if (replacement != match)
+- free (replacement);
++ xfree (replacement);
+ }
+ }
+
+@@ -1572,7 +1724,7 @@ append_to_match (text, delimiter, quote_
+ if (rl_point == rl_end && temp_string_index)
+ rl_insert_text (temp_string);
+ }
+- free (filename);
++ xfree (filename);
+ }
+ else
+ {
+@@ -1608,7 +1760,7 @@ insert_all_matches (matches, point, qc)
+ rl_insert_text (rp);
+ rl_insert_text (" ");
+ if (rp != matches[i])
+- free (rp);
++ xfree (rp);
+ }
+ }
+ else
+@@ -1617,7 +1769,7 @@ insert_all_matches (matches, point, qc)
+ rl_insert_text (rp);
+ rl_insert_text (" ");
+ if (rp != matches[0])
+- free (rp);
++ xfree (rp);
+ }
+ rl_end_undo_group ();
+ }
+@@ -1632,8 +1784,8 @@ _rl_free_match_list (matches)
+ return;
+
+ for (i = 0; matches[i]; i++)
+- free (matches[i]);
+- free (matches);
++ xfree (matches[i]);
++ xfree (matches);
+ }
+
+ /* Complete the word at or before point.
+@@ -1654,6 +1806,9 @@ rl_complete_internal (what_to_do)
+ int start, end, delimiter, found_quote, i, nontrivial_lcd;
+ char *text, *saved_line_buffer;
+ char quote_char;
++#if 1
++ int tlen, mlen;
++#endif
+
+ RL_SETSTATE(RL_STATE_COMPLETING);
+
+@@ -1681,7 +1836,11 @@ rl_complete_internal (what_to_do)
+ /* nontrivial_lcd is set if the common prefix adds something to the word
+ being completed. */
+ nontrivial_lcd = matches && strcmp (text, matches[0]) != 0;
+- free (text);
++#if 1
++ if (what_to_do == '!' || what_to_do == '@')
++ tlen = strlen (text);
++#endif
++ xfree (text);
+
+ if (matches == 0)
+ {
+@@ -1689,6 +1848,7 @@ rl_complete_internal (what_to_do)
+ FREE (saved_line_buffer);
+ completion_changed_buffer = 0;
+ RL_UNSETSTATE(RL_STATE_COMPLETING);
++ _rl_reset_completion_state ();
+ return (0);
+ }
+
+@@ -1703,6 +1863,7 @@ rl_complete_internal (what_to_do)
+ FREE (saved_line_buffer);
+ completion_changed_buffer = 0;
+ RL_UNSETSTATE(RL_STATE_COMPLETING);
++ _rl_reset_completion_state ();
+ return (0);
+ }
+
+@@ -1712,8 +1873,25 @@ rl_complete_internal (what_to_do)
+ case '!':
+ case '@':
+ /* Insert the first match with proper quoting. */
++#if 0
+ if (*matches[0])
+ insert_match (matches[0], start, matches[1] ? MULT_MATCH : SINGLE_MATCH, "e_char);
++#else
++ if (what_to_do == TAB)
++ {
++ if (*matches[0])
++ insert_match (matches[0], start, matches[1] ? MULT_MATCH : SINGLE_MATCH, "e_char);
++ }
++ else if (*matches[0] && matches[1] == 0)
++ /* should we perform the check only if there are multiple matches? */
++ insert_match (matches[0], start, matches[1] ? MULT_MATCH : SINGLE_MATCH, "e_char);
++ else if (*matches[0]) /* what_to_do != TAB && multiple matches */
++ {
++ mlen = *matches[0] ? strlen (matches[0]) : 0;
++ if (mlen >= tlen)
++ insert_match (matches[0], start, matches[1] ? MULT_MATCH : SINGLE_MATCH, "e_char);
++ }
++#endif
+
+ /* If there are more matches, ring the bell to indicate.
+ If we are in vi mode, Posix.2 says to not ring the bell.
+@@ -1753,10 +1931,11 @@ rl_complete_internal (what_to_do)
+ break;
+
+ default:
+- fprintf (stderr, "\r\nreadline: bad value %d for what_to_do in rl_complete\n", what_to_do);
++ _rl_ttymsg ("bad value %d for what_to_do in rl_complete", what_to_do);
+ rl_ding ();
+ FREE (saved_line_buffer);
+ RL_UNSETSTATE(RL_STATE_COMPLETING);
++ _rl_reset_completion_state ();
+ return 1;
+ }
+
+@@ -1766,10 +1945,11 @@ rl_complete_internal (what_to_do)
+ if (saved_line_buffer)
+ {
+ completion_changed_buffer = strcmp (rl_line_buffer, saved_line_buffer) != 0;
+- free (saved_line_buffer);
++ xfree (saved_line_buffer);
+ }
+
+ RL_UNSETSTATE(RL_STATE_COMPLETING);
++ _rl_reset_completion_state ();
+ return 0;
+ }
+
+@@ -1813,6 +1993,7 @@ rl_completion_matches (text, entry_funct
+ match_list = (char **)xmalloc ((match_list_size + 1) * sizeof (char *));
+ match_list[1] = (char *)NULL;
+
++ _rl_interrupt_immediately++;
+ while (string = (*entry_function) (text, matches))
+ {
+ if (matches + 1 == match_list_size)
+@@ -1822,6 +2003,8 @@ rl_completion_matches (text, entry_funct
+ match_list[++matches] = string;
+ match_list[matches + 1] = (char *)NULL;
+ }
++ if (_rl_interrupt_immediately > 0)
++ _rl_interrupt_immediately--;
+
+ /* If there were any matches, then look through them finding out the
+ lowest common denominator. That then becomes match_list[0]. */
+@@ -1829,7 +2012,7 @@ rl_completion_matches (text, entry_funct
+ compute_lcd_of_matches (match_list, matches, text);
+ else /* There were no matches. */
+ {
+- free (match_list);
++ xfree (match_list);
+ match_list = (char **)NULL;
+ }
+ return (match_list);
+@@ -1895,6 +2078,62 @@ rl_username_completion_function (text, s
+ #endif /* !__WIN32__ && !__OPENNT */
+ }
+
++/* Return non-zero if CONVFN matches FILENAME up to the length of FILENAME
++ (FILENAME_LEN). If _rl_completion_case_fold is set, compare without
++ regard to the alphabetic case of characters. CONVFN is the possibly-
++ converted directory entry; FILENAME is what the user typed. */
++static int
++complete_fncmp (convfn, convlen, filename, filename_len)
++ const char *convfn;
++ int convlen;
++ const char *filename;
++ int filename_len;
++{
++ register char *s1, *s2;
++ int d, len;
++
++ /* Otherwise, if these match up to the length of filename, then
++ it is a match. */
++ if (_rl_completion_case_fold && _rl_completion_case_map)
++ {
++ /* Case-insensitive comparison treating _ and - as equivalent */
++ if (filename_len == 0)
++ return 1;
++ if (convlen < filename_len)
++ return 0;
++ s1 = (char *)convfn;
++ s2 = (char *)filename;
++ len = filename_len;
++ do
++ {
++ d = _rl_to_lower (*s1) - _rl_to_lower (*s2);
++ /* *s1 == [-_] && *s2 == [-_] */
++ if ((*s1 == '-' || *s1 == '_') && (*s2 == '-' || *s2 == '_'))
++ d = 0;
++ if (d != 0)
++ return 0;
++ s1++; s2++; /* already checked convlen >= filename_len */
++ }
++ while (--len != 0);
++ return 1;
++ }
++ else if (_rl_completion_case_fold)
++ {
++ if ((_rl_to_lower (convfn[0]) == _rl_to_lower (filename[0])) &&
++ (convlen >= filename_len) &&
++ (_rl_strnicmp (filename, convfn, filename_len) == 0))
++ return 1;
++ }
++ else
++ {
++ if ((convfn[0] == filename[0]) &&
++ (convlen >= filename_len) &&
++ (strncmp (filename, convfn, filename_len) == 0))
++ return 1;
++ }
++ return 0;
++}
++
+ /* Okay, now we write the entry_function for filename completion. In the
+ general case. Note that completion in the shell is a little different
+ because of all the pathnames that must be followed when looking up the
+@@ -1909,8 +2148,8 @@ rl_filename_completion_function (text, s
+ static char *dirname = (char *)NULL;
+ static char *users_dirname = (char *)NULL;
+ static int filename_len;
+- char *temp;
+- int dirlen;
++ char *temp, *dentry, *convfn;
++ int dirlen, dentlen, convlen;
+ struct dirent *entry;
+
+ /* If we don't have any state, then do some initialization. */
+@@ -1961,26 +2200,52 @@ rl_filename_completion_function (text, s
+
+ /* We aren't done yet. We also support the "~user" syntax. */
+
+- /* Save the version of the directory that the user typed. */
+- users_dirname = savestring (dirname);
++ /* Save the version of the directory that the user typed, dequoting
++ it if necessary. */
++ if (rl_completion_found_quote && rl_filename_dequoting_function)
++ users_dirname = (*rl_filename_dequoting_function) (dirname, rl_completion_quote_character);
++ else
++ users_dirname = savestring (dirname);
+
+ if (*dirname == '~')
+ {
+ temp = tilde_expand (dirname);
+- free (dirname);
++ xfree (dirname);
+ dirname = temp;
+ }
+
++ /* We have saved the possibly-dequoted version of the directory name
++ the user typed. Now transform the directory name we're going to
++ pass to opendir(2). The directory rewrite hook modifies only the
++ directory name; the directory completion hook modifies both the
++ directory name passed to opendir(2) and the version the user
++ typed. Both the directory completion and rewrite hooks should perform
++ any necessary dequoting. The hook functions return 1 if they modify
++ the directory name argument. If either hook returns 0, it should
++ not modify the directory name pointer passed as an argument. */
+ if (rl_directory_rewrite_hook)
+ (*rl_directory_rewrite_hook) (&dirname);
+-
+- if (rl_directory_completion_hook && (*rl_directory_completion_hook) (&dirname))
++ else if (rl_directory_completion_hook && (*rl_directory_completion_hook) (&dirname))
+ {
+- free (users_dirname);
++ xfree (users_dirname);
+ users_dirname = savestring (dirname);
+ }
+-
++ else if (rl_completion_found_quote && rl_filename_dequoting_function)
++ {
++ /* delete single and double quotes */
++ xfree (dirname);
++ dirname = savestring (users_dirname);
++ }
+ directory = opendir (dirname);
++
++ /* Now dequote a non-null filename. */
++ if (filename && *filename && rl_completion_found_quote && rl_filename_dequoting_function)
++ {
++ /* delete single and double quotes */
++ temp = (*rl_filename_dequoting_function) (filename, rl_completion_quote_character);
++ xfree (filename);
++ filename = temp;
++ }
+ filename_len = strlen (filename);
+
+ rl_filename_completion_desired = 1;
+@@ -1997,37 +2262,31 @@ rl_filename_completion_function (text, s
+ entry = (struct dirent *)NULL;
+ while (directory && (entry = readdir (directory)))
+ {
++ convfn = dentry = entry->d_name;
++ convlen = dentlen = D_NAMLEN (entry);
++
++ if (rl_filename_rewrite_hook)
++ {
++ convfn = (*rl_filename_rewrite_hook) (dentry, dentlen);
++ convlen = (convfn == dentry) ? dentlen : strlen (convfn);
++ }
++
+ /* Special case for no filename. If the user has disabled the
+ `match-hidden-files' variable, skip filenames beginning with `.'.
+ All other entries except "." and ".." match. */
+ if (filename_len == 0)
+ {
+- if (_rl_match_hidden_files == 0 && HIDDEN_FILE (entry->d_name))
++ if (_rl_match_hidden_files == 0 && HIDDEN_FILE (convfn))
+ continue;
+
+- if (entry->d_name[0] != '.' ||
+- (entry->d_name[1] &&
+- (entry->d_name[1] != '.' || entry->d_name[2])))
++ if (convfn[0] != '.' ||
++ (convfn[1] && (convfn[1] != '.' || convfn[2])))
+ break;
+ }
+ else
+ {
+- /* Otherwise, if these match up to the length of filename, then
+- it is a match. */
+- if (_rl_completion_case_fold)
+- {
+- if ((_rl_to_lower (entry->d_name[0]) == _rl_to_lower (filename[0])) &&
+- (((int)D_NAMLEN (entry)) >= filename_len) &&
+- (_rl_strnicmp (filename, entry->d_name, filename_len) == 0))
+- break;
+- }
+- else
+- {
+- if ((entry->d_name[0] == filename[0]) &&
+- (((int)D_NAMLEN (entry)) >= filename_len) &&
+- (strncmp (filename, entry->d_name, filename_len) == 0))
+- break;
+- }
++ if (complete_fncmp (convfn, convlen, filename, filename_len))
++ break;
+ }
+ }
+
+@@ -2040,17 +2299,17 @@ rl_filename_completion_function (text, s
+ }
+ if (dirname)
+ {
+- free (dirname);
++ xfree (dirname);
+ dirname = (char *)NULL;
+ }
+ if (filename)
+ {
+- free (filename);
++ xfree (filename);
+ filename = (char *)NULL;
+ }
+ if (users_dirname)
+ {
+- free (users_dirname);
++ xfree (users_dirname);
+ users_dirname = (char *)NULL;
+ }
+
+@@ -2084,27 +2343,30 @@ rl_filename_completion_function (text, s
+ temp[dirlen++] = '/';
+ }
+
+- strcpy (temp + dirlen, entry->d_name);
++ strcpy (temp + dirlen, convfn);
+ }
+ else
+- temp = savestring (entry->d_name);
++ temp = savestring (convfn);
++
++ if (convfn != dentry)
++ xfree (convfn);
+
+ return (temp);
+ }
+ }
+
+ /* An initial implementation of a menu completion function a la tcsh. The
+- first time (if the last readline command was not rl_menu_complete), we
++ first time (if the last readline command was not rl_old_menu_complete), we
+ generate the list of matches. This code is very similar to the code in
+ rl_complete_internal -- there should be a way to combine the two. Then,
+ for each item in the list of matches, we insert the match in an undoable
+ fashion, with the appropriate character appended (this happens on the
+- second and subsequent consecutive calls to rl_menu_complete). When we
++ second and subsequent consecutive calls to rl_old_menu_complete). When we
+ hit the end of the match list, we restore the original unmatched text,
+ ring the bell, and reset the counter to zero. */
+ int
+-rl_menu_complete (count, ignore)
+- int count, ignore;
++rl_old_menu_complete (count, invoking_key)
++ int count, invoking_key;
+ {
+ rl_compentry_func_t *our_func;
+ int matching_filenames, found_quote;
+@@ -2119,7 +2381,7 @@ rl_menu_complete (count, ignore)
+
+ /* The first time through, we generate the list of matches and set things
+ up to insert them. */
+- if (rl_last_func != rl_menu_complete)
++ if (rl_last_func != rl_old_menu_complete)
+ {
+ /* Clean up from previous call, if any. */
+ FREE (orig_text);
+@@ -2129,10 +2391,16 @@ rl_menu_complete (count, ignore)
+ match_list_index = match_list_size = 0;
+ matches = (char **)NULL;
+
++ rl_completion_invoking_key = invoking_key;
++
++ RL_SETSTATE(RL_STATE_COMPLETING);
++
+ /* Only the completion entry function can change these. */
+ set_completion_defaults ('%');
+
+- our_func = rl_completion_entry_function
++ our_func = rl_menu_completion_entry_function;
++ if (our_func == 0)
++ our_func = rl_completion_entry_function
+ ? rl_completion_entry_function
+ : rl_filename_completion_function;
+
+@@ -2160,19 +2428,25 @@ rl_menu_complete (count, ignore)
+
+ if (matches == 0 || postprocess_matches (&matches, matching_filenames) == 0)
+ {
+- rl_ding ();
++ rl_ding ();
+ FREE (matches);
+ matches = (char **)0;
+ FREE (orig_text);
+ orig_text = (char *)0;
+- completion_changed_buffer = 0;
+- return (0);
++ completion_changed_buffer = 0;
++ RL_UNSETSTATE(RL_STATE_COMPLETING);
++ return (0);
+ }
+
++ RL_UNSETSTATE(RL_STATE_COMPLETING);
++
+ for (match_list_size = 0; matches[match_list_size]; match_list_size++)
+ ;
+ /* matches[0] is lcd if match_list_size > 1, but the circular buffer
+ code below should take care of it. */
++
++ if (match_list_size > 1 && _rl_complete_show_all)
++ display_matches (matches);
+ }
+
+ /* Now we have the list of matches. Replace the text between
+@@ -2190,7 +2464,10 @@ rl_menu_complete (count, ignore)
+
+ match_list_index += count;
+ if (match_list_index < 0)
+- match_list_index += match_list_size;
++ {
++ while (match_list_index < 0)
++ match_list_index += match_list_size;
++ }
+ else
+ match_list_index %= match_list_size;
+
+@@ -2209,3 +2486,180 @@ rl_menu_complete (count, ignore)
+ completion_changed_buffer = 1;
+ return (0);
+ }
++
++int
++rl_menu_complete (count, ignore)
++ int count, ignore;
++{
++ rl_compentry_func_t *our_func;
++ int matching_filenames, found_quote;
++
++ static char *orig_text;
++ static char **matches = (char **)0;
++ static int match_list_index = 0;
++ static int match_list_size = 0;
++ static int nontrivial_lcd = 0;
++ static int full_completion = 0; /* set to 1 if menu completion should reinitialize on next call */
++ static int orig_start, orig_end;
++ static char quote_char;
++ static int delimiter, cstate;
++
++ /* The first time through, we generate the list of matches and set things
++ up to insert them. */
++ if ((rl_last_func != rl_menu_complete && rl_last_func != rl_backward_menu_complete) || full_completion)
++ {
++ /* Clean up from previous call, if any. */
++ FREE (orig_text);
++ if (matches)
++ _rl_free_match_list (matches);
++
++ match_list_index = match_list_size = 0;
++ matches = (char **)NULL;
++
++ full_completion = 0;
++
++ RL_SETSTATE(RL_STATE_COMPLETING);
++
++ /* Only the completion entry function can change these. */
++ set_completion_defaults ('%');
++
++ our_func = rl_menu_completion_entry_function;
++ if (our_func == 0)
++ our_func = rl_completion_entry_function
++ ? rl_completion_entry_function
++ : rl_filename_completion_function;
++
++ /* We now look backwards for the start of a filename/variable word. */
++ orig_end = rl_point;
++ found_quote = delimiter = 0;
++ quote_char = '\0';
++
++ if (rl_point)
++ /* This (possibly) changes rl_point. If it returns a non-zero char,
++ we know we have an open quote. */
++ quote_char = _rl_find_completion_word (&found_quote, &delimiter);
++
++ orig_start = rl_point;
++ rl_point = orig_end;
++
++ orig_text = rl_copy_text (orig_start, orig_end);
++ matches = gen_completion_matches (orig_text, orig_start, orig_end,
++ our_func, found_quote, quote_char);
++
++ nontrivial_lcd = matches && strcmp (orig_text, matches[0]) != 0;
++
++ /* If we are matching filenames, the attempted completion function will
++ have set rl_filename_completion_desired to a non-zero value. The basic
++ rl_filename_completion_function does this. */
++ matching_filenames = rl_filename_completion_desired;
++
++ if (matches == 0 || postprocess_matches (&matches, matching_filenames) == 0)
++ {
++ rl_ding ();
++ FREE (matches);
++ matches = (char **)0;
++ FREE (orig_text);
++ orig_text = (char *)0;
++ completion_changed_buffer = 0;
++ RL_UNSETSTATE(RL_STATE_COMPLETING);
++ return (0);
++ }
++
++ RL_UNSETSTATE(RL_STATE_COMPLETING);
++
++ for (match_list_size = 0; matches[match_list_size]; match_list_size++)
++ ;
++
++ if (match_list_size == 0)
++ {
++ rl_ding ();
++ FREE (matches);
++ matches = (char **)0;
++ match_list_index = 0;
++ completion_changed_buffer = 0;
++ return (0);
++ }
++
++ /* matches[0] is lcd if match_list_size > 1, but the circular buffer
++ code below should take care of it. */
++ if (*matches[0])
++ {
++ insert_match (matches[0], orig_start, matches[1] ? MULT_MATCH : SINGLE_MATCH, "e_char);
++ orig_end = orig_start + strlen (matches[0]);
++ completion_changed_buffer = STREQ (orig_text, matches[0]) == 0;
++ }
++
++ if (match_list_size > 1 && _rl_complete_show_all)
++ {
++ display_matches (matches);
++ /* If there are so many matches that the user has to be asked
++ whether or not he wants to see the matches, menu completion
++ is unwieldy. */
++ if (rl_completion_query_items > 0 && match_list_size >= rl_completion_query_items)
++ {
++ rl_ding ();
++ FREE (matches);
++ matches = (char **)0;
++ full_completion = 1;
++ return (0);
++ }
++ }
++ else if (match_list_size <= 1)
++ {
++ append_to_match (matches[0], delimiter, quote_char, nontrivial_lcd);
++ full_completion = 1;
++ return (0);
++ }
++ else if (_rl_menu_complete_prefix_first && match_list_size > 1)
++ {
++ rl_ding ();
++ return (0);
++ }
++ }
++
++ /* Now we have the list of matches. Replace the text between
++ rl_line_buffer[orig_start] and rl_line_buffer[rl_point] with
++ matches[match_list_index], and add any necessary closing char. */
++
++ if (matches == 0 || match_list_size == 0)
++ {
++ rl_ding ();
++ FREE (matches);
++ matches = (char **)0;
++ completion_changed_buffer = 0;
++ return (0);
++ }
++
++ match_list_index += count;
++ if (match_list_index < 0)
++ {
++ while (match_list_index < 0)
++ match_list_index += match_list_size;
++ }
++ else
++ match_list_index %= match_list_size;
++
++ if (match_list_index == 0 && match_list_size > 1)
++ {
++ rl_ding ();
++ insert_match (matches[0], orig_start, MULT_MATCH, "e_char);
++ }
++ else
++ {
++ insert_match (matches[match_list_index], orig_start, SINGLE_MATCH, "e_char);
++ append_to_match (matches[match_list_index], delimiter, quote_char,
++ strcmp (orig_text, matches[match_list_index]));
++ }
++
++ completion_changed_buffer = 1;
++ return (0);
++}
++
++int
++rl_backward_menu_complete (count, key)
++ int count, key;
++{
++ /* Positive arguments to backward-menu-complete translate into negative
++ arguments for menu-complete, and vice versa. */
++ return (rl_menu_complete (-count, key));
++}
+Index: gdb-7.2.90.20110703/readline/config.h.in
+===================================================================
+--- gdb-7.2.90.20110703.orig/readline/config.h.in 2011-07-03 10:40:53.000000000 +0200
++++ gdb-7.2.90.20110703/readline/config.h.in 2011-07-03 10:41:21.000000000 +0200
+@@ -4,6 +4,8 @@
+ characters, even if the OS supports them. */
+ #undef NO_MULTIBYTE_SUPPORT
+
++#undef _FILE_OFFSET_BITS
++
+ /* Define if on MINIX. */
+ #undef _MINIX
+
+@@ -13,12 +15,16 @@
+ #undef VOID_SIGHANDLER
+
+ /* Characteristics of the compiler. */
+-#undef const
++#undef sig_atomic_t
+
+ #undef size_t
+
+ #undef ssize_t
+
++#undef const
++
++#undef volatile
++
+ #undef PROTOTYPES
+
+ #undef __CHAR_UNSIGNED__
+@@ -41,6 +47,15 @@
+ /* Define if you have the isascii function. */
+ #undef HAVE_ISASCII
+
++/* Define if you have the iswctype function. */
++#undef HAVE_ISWCTYPE
++
++/* Define if you have the iswlower function. */
++#undef HAVE_ISWLOWER
++
++/* Define if you have the iswupper function. */
++#undef HAVE_ISWUPPER
++
+ /* Define if you have the isxdigit function. */
+ #undef HAVE_ISXDIGIT
+
+@@ -88,11 +103,23 @@
+ /* Define if you have the tcgetattr function. */
+ #undef HAVE_TCGETATTR
+
++/* Define if you have the towlower function. */
++#undef HAVE_TOWLOWER
++
++/* Define if you have the towupper function. */
++#undef HAVE_TOWUPPER
++
+ /* Define if you have the vsnprintf function. */
+ #undef HAVE_VSNPRINTF
+
+-/* Define if you have the wctomb function. */
+-#undef HAVE_WCTOMB
++/* Define if you have the wcrtomb function. */
++#undef HAVE_WCRTOMB
++
++/* Define if you have the wcscoll function. */
++#undef HAVE_WCSCOLL
++
++/* Define if you have the wctype function. */
++#undef HAVE_WCTYPE
+
+ /* Define if you have the wcwidth function. */
+ #undef HAVE_WCWIDTH
+@@ -174,11 +201,20 @@
+ /* Define if you have the <wchar.h> header file. */
+ #undef HAVE_WCHAR_H
+
+-/* Define if you have the <varargs.h> header file. */
++/* Define if you have the <wctype.h> header file. */
+ #undef HAVE_WCTYPE_H
+
+ #undef HAVE_MBSTATE_T
+
++/* Define if you have wchar_t in <wctype.h>. */
++#undef HAVE_WCHAR_T
++
++/* Define if you have wctype_t in <wctype.h>. */
++#undef HAVE_WCTYPE_T
++
++/* Define if you have wint_t in <wctype.h>. */
++#undef HAVE_WINT_T
++
+ /* Define if you have <langinfo.h> and nl_langinfo(CODESET). */
+ #undef HAVE_LANGINFO_CODESET
+
+@@ -223,10 +259,6 @@
+ # define TERMIOS_MISSING
+ #endif
+
+-#if defined (STRCOLL_BROKEN)
+-# undef HAVE_STRCOLL
+-#endif
+-
+ #if defined (__STDC__) && defined (HAVE_STDARG_H)
+ # define PREFER_STDARG
+ # define USE_VARARGS
+Index: gdb-7.2.90.20110703/readline/configure
+===================================================================
+--- gdb-7.2.90.20110703.orig/readline/configure 2011-07-03 10:40:53.000000000 +0200
++++ gdb-7.2.90.20110703/readline/configure 2011-07-03 10:41:21.000000000 +0200
+@@ -1,7 +1,7 @@
+ #! /bin/sh
+-# From configure.in for Readline 5.1, version 2.59.
++# From configure.in for Readline 6.2, version 2.67.
+ # Guess values for system-dependent variables and create Makefiles.
+-# Generated by GNU Autoconf 2.64 for readline 5.1-release.
++# Generated by GNU Autoconf 2.64 for readline 6.2.
+ #
+ # Report bugs to <bug-readline@gnu.org>.
+ #
+@@ -550,8 +550,8 @@ MAKEFLAGS=
+ # Identity of this package.
+ PACKAGE_NAME='readline'
+ PACKAGE_TARNAME='readline'
+-PACKAGE_VERSION='5.1-release'
+-PACKAGE_STRING='readline 5.1-release'
++PACKAGE_VERSION='6.2'
++PACKAGE_STRING='readline 6.2'
+ PACKAGE_BUGREPORT='bug-readline@gnu.org'
+ PACKAGE_URL=''
+
+@@ -593,7 +593,6 @@ ac_includes_default="\
+ #endif"
+
+ ac_subst_vars='LTLIBOBJS
+-LIBOBJS
+ TERMCAP_LIB
+ LIBVERSION
+ ARFLAGS
+@@ -623,14 +622,13 @@ SHOBJ_LDFLAGS
+ SHOBJ_LD
+ SHOBJ_CFLAGS
+ SHOBJ_CC
+-WCWIDTH_OBJ
++LIBOBJS
+ MAKE_SHELL
+ RANLIB
+ AR
+ INSTALL_DATA
+ INSTALL_SCRIPT
+ INSTALL_PROGRAM
+-CC_FOR_BUILD
+ EGREP
+ GREP
+ CPP
+@@ -696,6 +694,7 @@ with_curses
+ with_purify
+ enable_multibyte
+ enable_static
++enable_largefile
+ '
+ ac_precious_vars='build_alias
+ host_alias
+@@ -1247,7 +1246,7 @@ if test "$ac_init_help" = "long"; then
+ # Omit some internal or obsolete options to make the list less imposing.
+ # This message is too long to be a string in the A/UX 3.1 sh.
+ cat <<_ACEOF
+-\`configure' configures readline 5.1-release to adapt to many kinds of systems.
++\`configure' configures readline 6.2 to adapt to many kinds of systems.
+
+ Usage: $0 [OPTION]... [VAR=VALUE]...
+
+@@ -1312,7 +1311,7 @@ fi
+
+ if test -n "$ac_init_help"; then
+ case $ac_init_help in
+- short | recursive ) echo "Configuration of readline 5.1-release:";;
++ short | recursive ) echo "Configuration of readline 6.2:";;
+ esac
+ cat <<\_ACEOF
+
+@@ -1322,6 +1321,7 @@ Optional Features:
+ --enable-FEATURE[=ARG] include FEATURE [ARG=yes]
+ --enable-multibyte enable multibyte characters if OS supports them
+ --enable-static build static libraries [default=YES]
++ --disable-largefile omit support for large files
+
+ Optional Packages:
+ --with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
+@@ -1406,7 +1406,7 @@ fi
+ test -n "$ac_init_help" && exit $ac_status
+ if $ac_init_version; then
+ cat <<\_ACEOF
+-readline configure 5.1-release
++readline configure 6.2
+ generated by GNU Autoconf 2.64
+
+ Copyright (C) 2009 Free Software Foundation, Inc.
+@@ -1831,7 +1831,7 @@ cat >config.log <<_ACEOF
+ This file contains any messages produced by compilers while
+ running configure, to aid debugging if configure makes a mistake.
+
+-It was created by readline $as_me 5.1-release, which was
++It was created by readline $as_me 6.2, which was
+ generated by GNU Autoconf 2.64. Invocation command line was
+
+ $ $0 $@
+@@ -2211,7 +2211,7 @@ ac_configure="$SHELL $ac_aux_dir/configu
+ ac_config_headers="$ac_config_headers config.h"
+
+
+-LIBVERSION=5.1
++LIBVERSION=6.2
+
+ # Make sure we can run config.sub.
+ $SHELL "$ac_aux_dir/config.sub" sun4 >/dev/null 2>&1 ||
+@@ -3622,39 +3622,6 @@ $as_echo "$ac_cv_safe_to_define___extens
+
+
+
+-
+-if test "x$cross_compiling" = "xyes"; then
+- case "${host}" in
+- *-cygwin*)
+- cross_cache=${srcdir}/cross-build/cygwin.cache
+- LOCAL_CFLAGS="$LOCAL_CFLAGS -I${srcdir}/../libtermcap"
+- ;;
+- *-mingw32*)
+- cross_cache=${srcdir}/cross-build/mingw.cache
+- ;;
+- *) echo "configure: cross-compiling for a non-cygwin target is not supported" >&2
+- ;;
+- esac
+-
+- if test "x$cross_cache" != "x"; then
+- if test -r "${cross_cache}"; then
+- echo "loading cross-build cache file ${cross_cache}"
+- . ${cross_cache}
+- fi
+- unset cross_cache
+- fi
+-fi
+-
+-if test -z "$CC_FOR_BUILD"; then
+- if test "x$cross_compiling" = "xno"; then
+- CC_FOR_BUILD='$(CC)'
+- else
+- CC_FOR_BUILD=gcc
+- fi
+-fi
+-
+-
+-
+ # If we're using gcc and the user hasn't specified CFLAGS, add -O to CFLAGS.
+ test -n "$GCC" && test -n "$auto_cflags" && CFLAGS="$CFLAGS -O"
+
+@@ -4056,6 +4023,40 @@ if test $ac_cv_c_char_unsigned = yes &&
+
+ fi
+
++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for working volatile" >&5
++$as_echo_n "checking for working volatile... " >&6; }
++if test "${ac_cv_c_volatile+set}" = set; then :
++ $as_echo_n "(cached) " >&6
++else
++ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
++/* end confdefs.h. */
++
++int
++main ()
++{
++
++volatile int x;
++int * volatile y = (int *) 0;
++return !x && !y;
++ ;
++ return 0;
++}
++_ACEOF
++if ac_fn_c_try_compile "$LINENO"; then :
++ ac_cv_c_volatile=yes
++else
++ ac_cv_c_volatile=no
++fi
++rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
++fi
++{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_volatile" >&5
++$as_echo "$ac_cv_c_volatile" >&6; }
++if test $ac_cv_c_volatile = no; then
++
++$as_echo "#define volatile /**/" >>confdefs.h
++
++fi
++
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking return type of signal handlers" >&5
+ $as_echo_n "checking return type of signal handlers... " >&6; }
+@@ -4571,6 +4572,205 @@ fi
+ done
+
+
++# Check whether --enable-largefile was given.
++if test "${enable_largefile+set}" = set; then :
++ enableval=$enable_largefile;
++fi
++
++if test "$enable_largefile" != no; then
++
++ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for special C compiler options needed for large files" >&5
++$as_echo_n "checking for special C compiler options needed for large files... " >&6; }
++if test "${ac_cv_sys_largefile_CC+set}" = set; then :
++ $as_echo_n "(cached) " >&6
++else
++ ac_cv_sys_largefile_CC=no
++ if test "$GCC" != yes; then
++ ac_save_CC=$CC
++ while :; do
++ # IRIX 6.2 and later do not support large files by default,
++ # so use the C compiler's -n32 option if that helps.
++ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
++/* end confdefs.h. */
++#include <sys/types.h>
++ /* Check that off_t can represent 2**63 - 1 correctly.
++ We can't simply define LARGE_OFF_T to be 9223372036854775807,
++ since some C++ compilers masquerading as C compilers
++ incorrectly reject 9223372036854775807. */
++#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
++ int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
++ && LARGE_OFF_T % 2147483647 == 1)
++ ? 1 : -1];
++int
++main ()
++{
++
++ ;
++ return 0;
++}
++_ACEOF
++ if ac_fn_c_try_compile "$LINENO"; then :
++ break
++fi
++rm -f core conftest.err conftest.$ac_objext
++ CC="$CC -n32"
++ if ac_fn_c_try_compile "$LINENO"; then :
++ ac_cv_sys_largefile_CC=' -n32'; break
++fi
++rm -f core conftest.err conftest.$ac_objext
++ break
++ done
++ CC=$ac_save_CC
++ rm -f conftest.$ac_ext
++ fi
++fi
++{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sys_largefile_CC" >&5
++$as_echo "$ac_cv_sys_largefile_CC" >&6; }
++ if test "$ac_cv_sys_largefile_CC" != no; then
++ CC=$CC$ac_cv_sys_largefile_CC
++ fi
++
++ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for _FILE_OFFSET_BITS value needed for large files" >&5
++$as_echo_n "checking for _FILE_OFFSET_BITS value needed for large files... " >&6; }
++if test "${ac_cv_sys_file_offset_bits+set}" = set; then :
++ $as_echo_n "(cached) " >&6
++else
++ while :; do
++ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
++/* end confdefs.h. */
++#include <sys/types.h>
++ /* Check that off_t can represent 2**63 - 1 correctly.
++ We can't simply define LARGE_OFF_T to be 9223372036854775807,
++ since some C++ compilers masquerading as C compilers
++ incorrectly reject 9223372036854775807. */
++#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
++ int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
++ && LARGE_OFF_T % 2147483647 == 1)
++ ? 1 : -1];
++int
++main ()
++{
++
++ ;
++ return 0;
++}
++_ACEOF
++if ac_fn_c_try_compile "$LINENO"; then :
++ ac_cv_sys_file_offset_bits=no; break
++fi
++rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
++ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
++/* end confdefs.h. */
++#define _FILE_OFFSET_BITS 64
++#include <sys/types.h>
++ /* Check that off_t can represent 2**63 - 1 correctly.
++ We can't simply define LARGE_OFF_T to be 9223372036854775807,
++ since some C++ compilers masquerading as C compilers
++ incorrectly reject 9223372036854775807. */
++#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
++ int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
++ && LARGE_OFF_T % 2147483647 == 1)
++ ? 1 : -1];
++int
++main ()
++{
++
++ ;
++ return 0;
++}
++_ACEOF
++if ac_fn_c_try_compile "$LINENO"; then :
++ ac_cv_sys_file_offset_bits=64; break
++fi
++rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
++ ac_cv_sys_file_offset_bits=unknown
++ break
++done
++fi
++{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sys_file_offset_bits" >&5
++$as_echo "$ac_cv_sys_file_offset_bits" >&6; }
++case $ac_cv_sys_file_offset_bits in #(
++ no | unknown) ;;
++ *)
++cat >>confdefs.h <<_ACEOF
++#define _FILE_OFFSET_BITS $ac_cv_sys_file_offset_bits
++_ACEOF
++;;
++esac
++rm -rf conftest*
++ if test $ac_cv_sys_file_offset_bits = unknown; then
++ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for _LARGE_FILES value needed for large files" >&5
++$as_echo_n "checking for _LARGE_FILES value needed for large files... " >&6; }
++if test "${ac_cv_sys_large_files+set}" = set; then :
++ $as_echo_n "(cached) " >&6
++else
++ while :; do
++ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
++/* end confdefs.h. */
++#include <sys/types.h>
++ /* Check that off_t can represent 2**63 - 1 correctly.
++ We can't simply define LARGE_OFF_T to be 9223372036854775807,
++ since some C++ compilers masquerading as C compilers
++ incorrectly reject 9223372036854775807. */
++#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
++ int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
++ && LARGE_OFF_T % 2147483647 == 1)
++ ? 1 : -1];
++int
++main ()
++{
++
++ ;
++ return 0;
++}
++_ACEOF
++if ac_fn_c_try_compile "$LINENO"; then :
++ ac_cv_sys_large_files=no; break
++fi
++rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
++ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
++/* end confdefs.h. */
++#define _LARGE_FILES 1
++#include <sys/types.h>
++ /* Check that off_t can represent 2**63 - 1 correctly.
++ We can't simply define LARGE_OFF_T to be 9223372036854775807,
++ since some C++ compilers masquerading as C compilers
++ incorrectly reject 9223372036854775807. */
++#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
++ int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
++ && LARGE_OFF_T % 2147483647 == 1)
++ ? 1 : -1];
++int
++main ()
++{
++
++ ;
++ return 0;
++}
++_ACEOF
++if ac_fn_c_try_compile "$LINENO"; then :
++ ac_cv_sys_large_files=1; break
++fi
++rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
++ ac_cv_sys_large_files=unknown
++ break
++done
++fi
++{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sys_large_files" >&5
++$as_echo "$ac_cv_sys_large_files" >&6; }
++case $ac_cv_sys_large_files in #(
++ no | unknown) ;;
++ *)
++cat >>confdefs.h <<_ACEOF
++#define _LARGE_FILES $ac_cv_sys_large_files
++_ACEOF
++;;
++esac
++rm -rf conftest*
++ fi
++fi
++
++
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for type of signal functions" >&5
+ $as_echo_n "checking for type of signal functions... " >&6; }
+@@ -5078,6 +5278,49 @@ $as_echo "#define GWINSZ_IN_SYS_IOCTL 1"
+ fi
+
+
++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for sig_atomic_t in signal.h" >&5
++$as_echo_n "checking for sig_atomic_t in signal.h... " >&6; }
++if test "${ac_cv_have_sig_atomic_t+set}" = set; then :
++ $as_echo_n "(cached) " >&6
++else
++ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
++/* end confdefs.h. */
++
++#include <signal.h>
++
++int
++main ()
++{
++ sig_atomic_t x;
++ ;
++ return 0;
++}
++_ACEOF
++if ac_fn_c_try_link "$LINENO"; then :
++ ac_cv_have_sig_atomic_t=yes
++else
++ ac_cv_have_sig_atomic_t=no
++fi
++rm -f core conftest.err conftest.$ac_objext \
++ conftest$ac_exeext conftest.$ac_ext
++fi
++{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_have_sig_atomic_t" >&5
++$as_echo "$ac_cv_have_sig_atomic_t" >&6; }
++if test "$ac_cv_have_sig_atomic_t" = "no"
++then
++ ac_fn_c_check_type "$LINENO" "sig_atomic_t" "ac_cv_type_sig_atomic_t" "$ac_includes_default"
++if test "x$ac_cv_type_sig_atomic_t" = x""yes; then :
++
++else
++
++cat >>confdefs.h <<_ACEOF
++#define sig_atomic_t int
++_ACEOF
++
++fi
++
++fi
++
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether signal handlers are of type void" >&5
+ $as_echo_n "checking whether signal handlers are of type void... " >&6; }
+ if test "${bash_cv_void_sighandler+set}" = set; then :
+@@ -5116,6 +5359,7 @@ $as_echo "#define VOID_SIGHANDLER 1" >>c
+
+ fi
+
++
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for TIOCSTAT in sys/ioctl.h" >&5
+ $as_echo_n "checking for TIOCSTAT in sys/ioctl.h... " >&6; }
+ if test "${bash_cv_tiocstat_in_ioctl+set}" = set; then :
+@@ -5638,27 +5882,73 @@ fi
+ done
+
+
++ac_fn_c_check_func "$LINENO" "mbrlen" "ac_cv_func_mbrlen"
++if test "x$ac_cv_func_mbrlen" = x""yes; then :
++ $as_echo "#define HAVE_MBRLEN 1" >>confdefs.h
++
++fi
++
++ac_fn_c_check_func "$LINENO" "mbscasecmp" "ac_cv_func_mbscasecmp"
++if test "x$ac_cv_func_mbscasecmp" = x""yes; then :
++ $as_echo "#define HAVE_MBSCMP 1" >>confdefs.h
++
++fi
++
++ac_fn_c_check_func "$LINENO" "mbscmp" "ac_cv_func_mbscmp"
++if test "x$ac_cv_func_mbscmp" = x""yes; then :
++ $as_echo "#define HAVE_MBSCMP 1" >>confdefs.h
++
++fi
++
++ac_fn_c_check_func "$LINENO" "mbsnrtowcs" "ac_cv_func_mbsnrtowcs"
++if test "x$ac_cv_func_mbsnrtowcs" = x""yes; then :
++ $as_echo "#define HAVE_MBSNRTOWCS 1" >>confdefs.h
++
++fi
++
+ ac_fn_c_check_func "$LINENO" "mbsrtowcs" "ac_cv_func_mbsrtowcs"
+ if test "x$ac_cv_func_mbsrtowcs" = x""yes; then :
+ $as_echo "#define HAVE_MBSRTOWCS 1" >>confdefs.h
+
+ fi
+
+-ac_fn_c_check_func "$LINENO" "mbrtowc" "ac_cv_func_mbrtowc"
+-if test "x$ac_cv_func_mbrtowc" = x""yes; then :
+- $as_echo "#define HAVE_MBRTOWC 1" >>confdefs.h
++
++
++for ac_func in mbschr
++do :
++ ac_fn_c_check_func "$LINENO" "mbschr" "ac_cv_func_mbschr"
++if test "x$ac_cv_func_mbschr" = x""yes; then :
++ cat >>confdefs.h <<_ACEOF
++#define HAVE_MBSCHR 1
++_ACEOF
++
++else
++ case " $LIBOBJS " in
++ *" $ac_func.$ac_objext "* ) ;;
++ *) LIBOBJS="$LIBOBJS $ac_func.$ac_objext"
++ ;;
++esac
+
+ fi
++done
+
+-ac_fn_c_check_func "$LINENO" "mbrlen" "ac_cv_func_mbrlen"
+-if test "x$ac_cv_func_mbrlen" = x""yes; then :
+- $as_echo "#define HAVE_MBRLEN 1" >>confdefs.h
++
++
++ac_fn_c_check_func "$LINENO" "wcrtomb" "ac_cv_func_wcrtomb"
++if test "x$ac_cv_func_wcrtomb" = x""yes; then :
++ $as_echo "#define HAVE_WCRTOMB 1" >>confdefs.h
+
+ fi
+
+-ac_fn_c_check_func "$LINENO" "wctomb" "ac_cv_func_wctomb"
+-if test "x$ac_cv_func_wctomb" = x""yes; then :
+- $as_echo "#define HAVE_WCTOMB 1" >>confdefs.h
++ac_fn_c_check_func "$LINENO" "wcscoll" "ac_cv_func_wcscoll"
++if test "x$ac_cv_func_wcscoll" = x""yes; then :
++ $as_echo "#define HAVE_WCSCOLL 1" >>confdefs.h
++
++fi
++
++ac_fn_c_check_func "$LINENO" "wcsdup" "ac_cv_func_wcsdup"
++if test "x$ac_cv_func_wcsdup" = x""yes; then :
++ $as_echo "#define HAVE_WCSDUP 1" >>confdefs.h
+
+ fi
+
+@@ -5668,55 +5958,89 @@ if test "x$ac_cv_func_wcwidth" = x""yes;
+
+ fi
+
+-ac_fn_c_check_func "$LINENO" "wcsdup" "ac_cv_func_wcsdup"
+-if test "x$ac_cv_func_wcsdup" = x""yes; then :
+- $as_echo "#define HAVE_WCSDUP 1" >>confdefs.h
++ac_fn_c_check_func "$LINENO" "wctype" "ac_cv_func_wctype"
++if test "x$ac_cv_func_wctype" = x""yes; then :
++ $as_echo "#define HAVE_WCTYPE 1" >>confdefs.h
+
+ fi
+
+
+-if test "$ac_cv_func_wcwidth" = no && test "$ac_cv_header_wchar_h" = yes; then
+- WCWIDTH_OBJ=wcwidth.o
++for ac_func in wcswidth
++do :
++ ac_fn_c_check_func "$LINENO" "wcswidth" "ac_cv_func_wcswidth"
++if test "x$ac_cv_func_wcswidth" = x""yes; then :
++ cat >>confdefs.h <<_ACEOF
++#define HAVE_WCSWIDTH 1
++_ACEOF
++
+ else
+- WCWIDTH_OBJ=
++ case " $LIBOBJS " in
++ *" $ac_func.$ac_objext "* ) ;;
++ *) LIBOBJS="$LIBOBJS $ac_func.$ac_objext"
++ ;;
++esac
++
+ fi
++done
++
++
+
+
+-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for mbstate_t" >&5
+-$as_echo_n "checking for mbstate_t... " >&6; }
+-if test "${bash_cv_have_mbstate_t+set}" = set; then :
++ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether mbrtowc and mbstate_t are properly declared" >&5
++$as_echo_n "checking whether mbrtowc and mbstate_t are properly declared... " >&6; }
++if test "${ac_cv_func_mbrtowc+set}" = set; then :
+ $as_echo_n "(cached) " >&6
+ else
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+ /* end confdefs.h. */
+-
+ #include <wchar.h>
+ int
+ main ()
+ {
+-
+- mbstate_t ps;
+- mbstate_t *psp;
+- psp = (mbstate_t *)0;
+-
++wchar_t wc;
++ char const s[] = "";
++ size_t n = 1;
++ mbstate_t state;
++ return ! (sizeof state && (mbrtowc) (&wc, s, n, &state));
+ ;
+ return 0;
+ }
+ _ACEOF
+-if ac_fn_c_try_compile "$LINENO"; then :
+- bash_cv_have_mbstate_t=yes
++if ac_fn_c_try_link "$LINENO"; then :
++ ac_cv_func_mbrtowc=yes
+ else
+- bash_cv_have_mbstate_t=no
++ ac_cv_func_mbrtowc=no
+ fi
+-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
++rm -f core conftest.err conftest.$ac_objext \
++ conftest$ac_exeext conftest.$ac_ext
+ fi
+-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $bash_cv_have_mbstate_t" >&5
+-$as_echo "$bash_cv_have_mbstate_t" >&6; }
+-if test $bash_cv_have_mbstate_t = yes; then
++{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_mbrtowc" >&5
++$as_echo "$ac_cv_func_mbrtowc" >&6; }
++ if test $ac_cv_func_mbrtowc = yes; then
++
++$as_echo "#define HAVE_MBRTOWC 1" >>confdefs.h
++
++ fi
++
++if test $ac_cv_func_mbrtowc = yes; then
+ $as_echo "#define HAVE_MBSTATE_T 1" >>confdefs.h
+
+ fi
+
++for ac_func in iswlower iswupper towlower towupper iswctype
++do :
++ as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
++ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
++eval as_val=\$$as_ac_var
++ if test "x$as_val" = x""yes; then :
++ cat >>confdefs.h <<_ACEOF
++#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
++_ACEOF
++
++fi
++done
++
++
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for nl_langinfo and CODESET" >&5
+ $as_echo_n "checking for nl_langinfo and CODESET... " >&6; }
+ if test "${bash_cv_langinfo_codeset+set}" = set; then :
+@@ -5748,6 +6072,126 @@ if test $bash_cv_langinfo_codeset = yes;
+
+ fi
+
++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for wchar_t in wchar.h" >&5
++$as_echo_n "checking for wchar_t in wchar.h... " >&6; }
++if test "${bash_cv_type_wchar_t+set}" = set; then :
++ $as_echo_n "(cached) " >&6
++else
++ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
++/* end confdefs.h. */
++#include <wchar.h>
++
++int
++main ()
++{
++
++ wchar_t foo;
++ foo = 0;
++
++ ;
++ return 0;
++}
++_ACEOF
++if ac_fn_c_try_compile "$LINENO"; then :
++ bash_cv_type_wchar_t=yes
++else
++ bash_cv_type_wchar_t=no
++fi
++rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
++fi
++{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $bash_cv_type_wchar_t" >&5
++$as_echo "$bash_cv_type_wchar_t" >&6; }
++if test $bash_cv_type_wchar_t = yes; then
++
++$as_echo "#define HAVE_WCHAR_T 1" >>confdefs.h
++
++fi
++
++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for wctype_t in wctype.h" >&5
++$as_echo_n "checking for wctype_t in wctype.h... " >&6; }
++if test "${bash_cv_type_wctype_t+set}" = set; then :
++ $as_echo_n "(cached) " >&6
++else
++ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
++/* end confdefs.h. */
++#include <wctype.h>
++int
++main ()
++{
++
++ wctype_t foo;
++ foo = 0;
++
++ ;
++ return 0;
++}
++_ACEOF
++if ac_fn_c_try_compile "$LINENO"; then :
++ bash_cv_type_wctype_t=yes
++else
++ bash_cv_type_wctype_t=no
++fi
++rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
++fi
++{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $bash_cv_type_wctype_t" >&5
++$as_echo "$bash_cv_type_wctype_t" >&6; }
++if test $bash_cv_type_wctype_t = yes; then
++
++$as_echo "#define HAVE_WCTYPE_T 1" >>confdefs.h
++
++fi
++
++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for wint_t in wctype.h" >&5
++$as_echo_n "checking for wint_t in wctype.h... " >&6; }
++if test "${bash_cv_type_wint_t+set}" = set; then :
++ $as_echo_n "(cached) " >&6
++else
++ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
++/* end confdefs.h. */
++#include <wctype.h>
++int
++main ()
++{
++
++ wint_t foo;
++ foo = 0;
++
++ ;
++ return 0;
++}
++_ACEOF
++if ac_fn_c_try_compile "$LINENO"; then :
++ bash_cv_type_wint_t=yes
++else
++ bash_cv_type_wint_t=no
++fi
++rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
++fi
++{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $bash_cv_type_wint_t" >&5
++$as_echo "$bash_cv_type_wint_t" >&6; }
++if test $bash_cv_type_wint_t = yes; then
++
++$as_echo "#define HAVE_WINT_T 1" >>confdefs.h
++
++fi
++
++if test "$am_cv_func_iconv" = yes; then
++ OLDLIBS="$LIBS"
++ LIBS="$LIBS $LIBICONV"
++ for ac_func in locale_charset
++do :
++ ac_fn_c_check_func "$LINENO" "locale_charset" "ac_cv_func_locale_charset"
++if test "x$ac_cv_func_locale_charset" = x""yes; then :
++ cat >>confdefs.h <<_ACEOF
++#define HAVE_LOCALE_CHARSET 1
++_ACEOF
++
++fi
++done
++
++ LIBS="$OLDLIBS"
++fi
++
+
+
+ case "$host_cpu" in
+@@ -6357,7 +6801,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_wri
+ # report actual input values of CONFIG_FILES etc. instead of their
+ # values after options handling.
+ ac_log="
+-This file was extended by readline $as_me 5.1-release, which was
++This file was extended by readline $as_me 6.2, which was
+ generated by GNU Autoconf 2.64. Invocation command line was
+
+ CONFIG_FILES = $CONFIG_FILES
+@@ -6421,7 +6865,7 @@ Report bugs to <bug-readline@gnu.org>."
+ _ACEOF
+ cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
+ ac_cs_version="\\
+-readline config.status 5.1-release
++readline config.status 6.2
+ configured by $0, generated by GNU Autoconf 2.64,
+ with options \\"`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\"
+
+Index: gdb-7.2.90.20110703/readline/configure.in
+===================================================================
+--- gdb-7.2.90.20110703.orig/readline/configure.in 2011-07-03 10:40:53.000000000 +0200
++++ gdb-7.2.90.20110703/readline/configure.in 2011-07-03 10:41:21.000000000 +0200
+@@ -5,28 +5,26 @@ dnl report bugs to chet@po.cwru.edu
+ dnl
+ dnl Process this file with autoconf to produce a configure script.
+
+-# Copyright (C) 1987-2005 Free Software Foundation, Inc.
++# Copyright (C) 1987-2009 Free Software Foundation, Inc.
+
+-# This program is free software; you can redistribute it and/or modify
+-# it under the terms of the GNU General Public License as published by
+-# the Free Software Foundation; either version 2, or (at your option)
+-# any later version.
+-
+-# This program is distributed in the hope that it will be useful,
+-# but WITHOUT ANY WARRANTY; without even the implied warranty of
+-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+-# GNU General Public License for more details.
+-
+-# You should have received a copy of the GNU General Public License
+-# along with this program; if not, write to the Free Software
+-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+-# 02111-1307, USA.
++# This program is free software: you can redistribute it and/or modify
++# it under the terms of the GNU General Public License as published by
++# the Free Software Foundation, either version 3 of the License, or
++# (at your option) any later version.
++
++# This 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.
+
+-AC_REVISION([for Readline 5.1, version 2.59])
++# You should have received a copy of the GNU General Public License
++# along with this program. If not, see <http://www.gnu.org/licenses/>.
++
++AC_REVISION([for Readline 6.2, version 2.67])
+
+ m4_include([../config/override.m4])
+
+-AC_INIT(readline, 5.1-release, bug-readline@gnu.org)
++AC_INIT(readline, 6.2, bug-readline@gnu.org)
+
+ dnl make sure we are using a recent autoconf version
+ AC_PREREQ(2.50)
+@@ -38,7 +36,7 @@ AC_CONFIG_AUX_DIR(`cd $srcdir;pwd`/..)
+ AC_CONFIG_HEADERS(config.h)
+
+ dnl update the value of RL_READLINE_VERSION in readline.h when this changes
+-LIBVERSION=5.1
++LIBVERSION=6.2
+
+ AC_CANONICAL_HOST
+
+@@ -115,44 +113,6 @@ AC_PROG_CC
+ dnl AC_AIX
+ AC_MINIX
+
+-dnl BEGIN changes for CYGNUS cross-building for Cygwin
+-dnl NOTE: Some of these changes may no longer be necessary.
+-
+-dnl load up the cross-building cache file -- add more cases and cache
+-dnl files as necessary
+-if test "x$cross_compiling" = "xyes"; then
+- case "${host}" in
+- *-cygwin*)
+- cross_cache=${srcdir}/cross-build/cygwin.cache
+- LOCAL_CFLAGS="$LOCAL_CFLAGS -I${srcdir}/../libtermcap"
+- ;;
+- *-mingw32*)
+- cross_cache=${srcdir}/cross-build/mingw.cache
+- ;;
+- *) echo "configure: cross-compiling for a non-cygwin target is not supported" >&2
+- ;;
+- esac
+-
+- if test "x$cross_cache" != "x"; then
+- if test -r "${cross_cache}"; then
+- echo "loading cross-build cache file ${cross_cache}"
+- . ${cross_cache}
+- fi
+- unset cross_cache
+- fi
+-fi
+-
+-if test -z "$CC_FOR_BUILD"; then
+- if test "x$cross_compiling" = "xno"; then
+- CC_FOR_BUILD='$(CC)'
+- else
+- CC_FOR_BUILD=gcc
+- fi
+-fi
+-AC_SUBST(CC_FOR_BUILD)
+-
+-dnl END changes for CYGNUS cross-building for Cygwin
+-
+ # If we're using gcc and the user hasn't specified CFLAGS, add -O to CFLAGS.
+ test -n "$GCC" && test -n "$auto_cflags" && CFLAGS="$CFLAGS -O"
+
+@@ -170,6 +130,7 @@ AC_SUBST(MAKE_SHELL)
+ AC_C_CONST
+ AC_C_PROTOTYPES
+ AC_C_CHAR_UNSIGNED
++AC_C_VOLATILE
+
+ AC_TYPE_SIGNAL
+
+@@ -200,6 +161,8 @@ AC_CHECK_HEADERS(sys/ptem.h,,,
+ #endif
+ ]])
+
++AC_SYS_LARGEFILE
++
+ BASH_SYS_SIGNAL_VINTAGE
+ BASH_SYS_REINSTALL_SIGHANDLERS
+
+@@ -212,7 +175,9 @@ BASH_CHECK_GETPW_FUNCS
+
+ AC_HEADER_TIOCGWINSZ
+
++BASH_TYPE_SIG_ATOMIC_T
+ BASH_TYPE_SIGHANDLER
++
+ BASH_HAVE_TIOCSTAT
+ BASH_HAVE_FIONREAD
+ BASH_CHECK_SPEED_T
+Index: gdb-7.2.90.20110703/readline/display.c
+===================================================================
+--- gdb-7.2.90.20110703.orig/readline/display.c 2011-07-03 10:40:53.000000000 +0200
++++ gdb-7.2.90.20110703/readline/display.c 2011-07-03 10:41:21.000000000 +0200
+@@ -1,24 +1,24 @@
+ /* display.c -- readline redisplay facility. */
+
+-/* Copyright (C) 1987-2005 Free Software Foundation, Inc.
++/* Copyright (C) 1987-2009 Free Software Foundation, Inc.
+
+- This file is part of the GNU Readline Library, a library for
+- reading lines of text with interactive input and history editing.
++ This file is part of the GNU Readline Library (Readline), a library
++ for reading lines of text with interactive input and history editing.
+
+- The GNU Readline Library is free software; you can redistribute it
+- and/or modify it under the terms of the GNU General Public License
+- as published by the Free Software Foundation; either version 2, or
++ Readline 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.
+
+- The GNU Readline Library is distributed in the hope that it will be
+- useful, but WITHOUT ANY WARRANTY; without even the implied warranty
+- of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ Readline 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.
+
+- The GNU General Public License is often shipped with GNU software, and
+- is generally kept in a file called COPYING or LICENSE. If you do not
+- have a copy of the license, write to the Free Software Foundation,
+- 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
++ You should have received a copy of the GNU General Public License
++ along with Readline. If not, see <http://www.gnu.org/licenses/>.
++*/
++
+ #define READLINE_LIBRARY
+
+ #if defined (HAVE_CONFIG_H)
+@@ -63,30 +63,59 @@
+ extern char *strchr (), *strrchr ();
+ #endif /* !strchr && !__STDC__ */
+
+-#if defined (HACK_TERMCAP_MOTION)
+-extern char *_rl_term_forward_char;
+-#endif
+-
+ static void update_line PARAMS((char *, char *, int, int, int, int));
+ static void space_to_eol PARAMS((int));
+ static void delete_chars PARAMS((int));
+ static void insert_some_chars PARAMS((char *, int, int));
+ static void cr PARAMS((void));
+
++/* State of visible and invisible lines. */
++struct line_state
++ {
++ char *line;
++ int *lbreaks;
++ int lbsize;
+ #if defined (HANDLE_MULTIBYTE)
+-static int _rl_col_width PARAMS((const char *, int, int));
+-static int *_rl_wrapped_line;
+-#else
+-# define _rl_col_width(l, s, e) (((e) <= (s)) ? 0 : (e) - (s))
++ int *wrapped_line;
++ int wbsize;
+ #endif
++ };
++
++/* The line display buffers. One is the line currently displayed on
++ the screen. The other is the line about to be displayed. */
++static struct line_state line_state_array[2];
++static struct line_state *line_state_visible = &line_state_array[0];
++static struct line_state *line_state_invisible = &line_state_array[1];
++static int line_structures_initialized = 0;
+
+-static int *inv_lbreaks, *vis_lbreaks;
+-static int inv_lbsize, vis_lbsize;
++/* Backwards-compatible names. */
++#define inv_lbreaks (line_state_invisible->lbreaks)
++#define inv_lbsize (line_state_invisible->lbsize)
++#define vis_lbreaks (line_state_visible->lbreaks)
++#define vis_lbsize (line_state_visible->lbsize)
++
++#define visible_line (line_state_visible->line)
++#define invisible_line (line_state_invisible->line)
++
++#if defined (HANDLE_MULTIBYTE)
++static int _rl_col_width PARAMS((const char *, int, int, int));
++#else
++# define _rl_col_width(l, s, e, f) (((e) <= (s)) ? 0 : (e) - (s))
++#endif
+
+ /* Heuristic used to decide whether it is faster to move from CUR to NEW
+- by backing up or outputting a carriage return and moving forward. */
++ by backing up or outputting a carriage return and moving forward. CUR
++ and NEW are either both buffer positions or absolute screen positions. */
+ #define CR_FASTER(new, cur) (((new) + 1) < ((cur) - (new)))
+
++/* _rl_last_c_pos is an absolute cursor position in multibyte locales and a
++ buffer index in others. This macro is used when deciding whether the
++ current cursor position is in the middle of a prompt string containing
++ invisible characters. XXX - might need to take `modmark' into account. */
++#define PROMPT_ENDING_INDEX \
++ ((MB_CUR_MAX > 1 && rl_byte_oriented == 0) ? prompt_physical_chars : prompt_last_invisible+1)
++
++
+ /* **************************************************************** */
+ /* */
+ /* Display stuff */
+@@ -139,6 +168,8 @@ int _rl_last_c_pos = 0;
+ int _rl_last_v_pos = 0;
+
+ static int cpos_adjusted;
++static int cpos_buffer_position;
++static int prompt_multibyte_chars;
+
+ /* Number of lines currently on screen minus 1. */
+ int _rl_vis_botlin = 0;
+@@ -148,11 +179,6 @@ int _rl_vis_botlin = 0;
+ doing horizontal scrolling. It shifts in thirds of a screenwidth. */
+ static int last_lmargin;
+
+-/* The line display buffers. One is the line currently displayed on
+- the screen. The other is the line about to be displayed. */
+-static char *visible_line = (char *)NULL;
+-static char *invisible_line = (char *)NULL;
+-
+ /* A buffer for `modeline' messages. */
+ static char msg_buf[128];
+
+@@ -166,6 +192,7 @@ static int line_size = 1024;
+ include invisible characters. */
+
+ static char *local_prompt, *local_prompt_prefix;
++static int local_prompt_len;
+ static int prompt_visible_length, prompt_prefix_length;
+
+ /* The number of invisible characters in the line currently being
+@@ -192,6 +219,10 @@ static int prompt_last_screen_line;
+
+ static int prompt_physical_chars;
+
++/* set to a non-zero value by rl_redisplay if we are marking modified history
++ lines and the current line is so marked. */
++static int modmark;
++
+ /* Variables to save and restore prompt and display information. */
+
+ /* These are getting numerous enough that it's time to create a struct. */
+@@ -201,6 +232,7 @@ static char *saved_local_prefix;
+ static int saved_last_invisible;
+ static int saved_visible_length;
+ static int saved_prefix_length;
++static int saved_local_length;
+ static int saved_invis_chars_first_line;
+ static int saved_physical_chars;
+
+@@ -224,7 +256,7 @@ expand_prompt (pmt, lp, lip, niflp, vlp)
+ char *pmt;
+ int *lp, *lip, *niflp, *vlp;
+ {
+- char *r, *ret, *p;
++ char *r, *ret, *p, *igstart;
+ int l, rl, last, ignoring, ninvis, invfl, invflset, ind, pind, physchars;
+
+ /* Short-circuit if we can. */
+@@ -248,19 +280,21 @@ expand_prompt (pmt, lp, lip, niflp, vlp)
+ invfl = 0; /* invisible chars in first line of prompt */
+ invflset = 0; /* we only want to set invfl once */
+
++ igstart = 0;
+ for (rl = ignoring = last = ninvis = physchars = 0, p = pmt; p && *p; p++)
+ {
+ /* This code strips the invisible character string markers
+ RL_PROMPT_START_IGNORE and RL_PROMPT_END_IGNORE */
+- if (*p == RL_PROMPT_START_IGNORE)
++ if (ignoring == 0 && *p == RL_PROMPT_START_IGNORE) /* XXX - check ignoring? */
+ {
+- ignoring++;
++ ignoring = 1;
++ igstart = p;
+ continue;
+ }
+ else if (ignoring && *p == RL_PROMPT_END_IGNORE)
+ {
+ ignoring = 0;
+- if (p[-1] != RL_PROMPT_START_IGNORE)
++ if (p != (igstart + 1))
+ last = r - ret - 1;
+ continue;
+ }
+@@ -276,8 +310,13 @@ expand_prompt (pmt, lp, lip, niflp, vlp)
+ *r++ = *p++;
+ if (!ignoring)
+ {
++ /* rl ends up being assigned to prompt_visible_length,
++ which is the number of characters in the buffer that
++ contribute to characters on the screen, which might
++ not be the same as the number of physical characters
++ on the screen in the presence of multibyte characters */
+ rl += ind - pind;
+- physchars += _rl_col_width (pmt, pind, ind);
++ physchars += _rl_col_width (pmt, pind, ind, 0);
+ }
+ else
+ ninvis += ind - pind;
+@@ -360,6 +399,7 @@ rl_expand_prompt (prompt)
+ FREE (local_prompt_prefix);
+
+ local_prompt = local_prompt_prefix = (char *)0;
++ local_prompt_len = 0;
+ prompt_last_invisible = prompt_invis_chars_first_line = 0;
+ prompt_visible_length = prompt_physical_chars = 0;
+
+@@ -375,6 +415,7 @@ rl_expand_prompt (prompt)
+ &prompt_invis_chars_first_line,
+ &prompt_physical_chars);
+ local_prompt_prefix = (char *)0;
++ local_prompt_len = local_prompt ? strlen (local_prompt) : 0;
+ return (prompt_visible_length);
+ }
+ else
+@@ -383,16 +424,17 @@ rl_expand_prompt (prompt)
+ t = ++p;
+ local_prompt = expand_prompt (p, &prompt_visible_length,
+ &prompt_last_invisible,
+- (int *)NULL,
++ &prompt_invis_chars_first_line,
+ &prompt_physical_chars);
+ c = *t; *t = '\0';
+ /* The portion of the prompt string up to and including the
+ final newline is now null-terminated. */
+ local_prompt_prefix = expand_prompt (prompt, &prompt_prefix_length,
+ (int *)NULL,
+- &prompt_invis_chars_first_line,
++ (int *)NULL,
+ (int *)NULL);
+ *t = c;
++ local_prompt_len = local_prompt ? strlen (local_prompt) : 0;
+ return (prompt_prefix_length);
+ }
+ }
+@@ -434,13 +476,21 @@ init_line_structures (minsize)
+ {
+ /* should be enough. */
+ inv_lbsize = vis_lbsize = 256;
+- inv_lbreaks = (int *)xmalloc (inv_lbsize * sizeof (int));
+- vis_lbreaks = (int *)xmalloc (vis_lbsize * sizeof (int));
++
+ #if defined (HANDLE_MULTIBYTE)
+- _rl_wrapped_line = (int *)xmalloc (vis_lbsize * sizeof (int));
++ line_state_visible->wbsize = vis_lbsize;
++ line_state_visible->wrapped_line = (int *)xmalloc (line_state_visible->wbsize * sizeof (int));
++
++ line_state_invisible->wbsize = inv_lbsize;
++ line_state_invisible->wrapped_line = (int *)xmalloc (line_state_invisible->wbsize * sizeof (int));
+ #endif
++
++ inv_lbreaks = (int *)xmalloc (inv_lbsize * sizeof (int));
++ vis_lbreaks = (int *)xmalloc (vis_lbsize * sizeof (int));
+ inv_lbreaks[0] = vis_lbreaks[0] = 0;
+ }
++
++ line_structures_initialized = 1;
+ }
+
+ /* Basic redisplay algorithm. */
+@@ -449,8 +499,8 @@ rl_redisplay ()
+ {
+ register int in, out, c, linenum, cursor_linenum;
+ register char *line;
+- int c_pos, inv_botlin, lb_botlin, lb_linenum, o_cpos;
+- int newlines, lpos, temp, modmark, n0, num;
++ int inv_botlin, lb_botlin, lb_linenum, o_cpos;
++ int newlines, lpos, temp, n0, num, prompt_lines_estimate;
+ char *prompt_this_line;
+ #if defined (HANDLE_MULTIBYTE)
+ wchar_t wc;
+@@ -460,24 +510,27 @@ rl_redisplay ()
+ int _rl_wrapped_multicolumn = 0;
+ #endif
+
+- if (!readline_echoing_p)
++ if (_rl_echoing_p == 0)
+ return;
+
+- /* Signals are blocked through this function as the global data structures
+- could get corrupted upon modifications from an invoked signal handler. */
+- _rl_block_sigint ();
++ /* Block keyboard interrupts because this function manipulates global
++ data structures. */
++ _rl_block_sigint ();
++ RL_SETSTATE (RL_STATE_REDISPLAYING);
+
+ if (!rl_display_prompt)
+ rl_display_prompt = "";
+
+- if (invisible_line == 0 || vis_lbreaks == 0)
++ if (line_structures_initialized == 0)
+ {
+ init_line_structures (0);
+ rl_on_new_line ();
+ }
+
+ /* Draw the line into the buffer. */
+- c_pos = -1;
++ cpos_buffer_position = -1;
++
++ prompt_multibyte_chars = prompt_visible_length - prompt_physical_chars;
+
+ line = invisible_line;
+ out = inv_botlin = 0;
+@@ -504,24 +557,23 @@ rl_redisplay ()
+ number of non-visible characters in the prompt string. */
+ if (rl_display_prompt == rl_prompt || local_prompt)
+ {
+- int local_len = local_prompt ? strlen (local_prompt) : 0;
+ if (local_prompt_prefix && forced_display)
+ _rl_output_some_chars (local_prompt_prefix, strlen (local_prompt_prefix));
+
+- if (local_len > 0)
++ if (local_prompt_len > 0)
+ {
+- temp = local_len + out + 2;
++ temp = local_prompt_len + out + 2;
+ if (temp >= line_size)
+ {
+ line_size = (temp + 1024) - (temp % 1024);
+ visible_line = (char *)xrealloc (visible_line, line_size);
+ line = invisible_line = (char *)xrealloc (invisible_line, line_size);
+ }
+- strncpy (line + out, local_prompt, local_len);
+- out += local_len;
++ strncpy (line + out, local_prompt, local_prompt_len);
++ out += local_prompt_len;
+ }
+ line[out] = '\0';
+- wrap_offset = local_len - prompt_visible_length;
++ wrap_offset = local_prompt_len - prompt_visible_length;
+ }
+ else
+ {
+@@ -576,10 +628,14 @@ rl_redisplay ()
+ { \
+ inv_lbsize *= 2; \
+ inv_lbreaks = (int *)xrealloc (inv_lbreaks, inv_lbsize * sizeof (int)); \
+- _rl_wrapped_line = (int *)xrealloc (_rl_wrapped_line, inv_lbsize * sizeof (int)); \
+ } \
+ inv_lbreaks[++newlines] = out; \
+- _rl_wrapped_line[newlines] = _rl_wrapped_multicolumn; \
++ if (newlines >= (line_state_invisible->wbsize - 1)) \
++ { \
++ line_state_invisible->wbsize *= 2; \
++ line_state_invisible->wrapped_line = (int *)xrealloc (line_state_invisible->wrapped_line, line_state_invisible->wbsize * sizeof(int)); \
++ } \
++ line_state_invisible->wrapped_line[newlines] = _rl_wrapped_multicolumn; \
+ lpos = 0; \
+ } \
+ } while (0)
+@@ -602,26 +658,26 @@ rl_redisplay ()
+
+ /* inv_lbreaks[i] is where line i starts in the buffer. */
+ inv_lbreaks[newlines = 0] = 0;
+-#if 0
+- lpos = out - wrap_offset;
+-#else
+ lpos = prompt_physical_chars + modmark;
+-#endif
+
+ #if defined (HANDLE_MULTIBYTE)
+- memset (_rl_wrapped_line, 0, vis_lbsize);
++ memset (line_state_invisible->wrapped_line, 0, line_state_invisible->wbsize * sizeof (int));
+ num = 0;
+ #endif
+
+ /* prompt_invis_chars_first_line is the number of invisible characters in
+ the first physical line of the prompt.
+ wrap_offset - prompt_invis_chars_first_line is the number of invis
+- chars on the second line. */
++ chars on the second (or, more generally, last) line. */
++
++ /* This is zero-based, used to set the newlines */
++ prompt_lines_estimate = lpos / _rl_screenwidth;
+
+ /* what if lpos is already >= _rl_screenwidth before we start drawing the
+ contents of the command line? */
+ while (lpos >= _rl_screenwidth)
+ {
++ int z;
+ /* fix from Darin Johnson <darin@acuson.com> for prompt string with
+ invisible characters that is longer than the screen width. The
+ prompt_invis_chars_first_line variable could be made into an array
+@@ -630,37 +686,48 @@ rl_redisplay ()
+ prompts that exceed two physical lines?
+ Additional logic fix from Edward Catmur <ed@catmur.co.uk> */
+ #if defined (HANDLE_MULTIBYTE)
+- n0 = num;
+- temp = local_prompt ? strlen (local_prompt) : 0;
+- while (num < temp)
++ if (MB_CUR_MAX > 1 && rl_byte_oriented == 0 && prompt_multibyte_chars > 0)
+ {
+- if (_rl_col_width (local_prompt, n0, num) > _rl_screenwidth)
++ n0 = num;
++ temp = local_prompt_len;
++ while (num < temp)
+ {
+- num = _rl_find_prev_mbchar (local_prompt, num, MB_FIND_ANY);
+- break;
++ z = _rl_col_width (local_prompt, n0, num, 1);
++ if (z > _rl_screenwidth)
++ {
++ num = _rl_find_prev_mbchar (local_prompt, num, MB_FIND_ANY);
++ break;
++ }
++ else if (z == _rl_screenwidth)
++ break;
++ num++;
+ }
+- num++;
++ temp = num;
+ }
+- temp = num +
+-#else
+- temp = ((newlines + 1) * _rl_screenwidth) +
++ else
+ #endif /* !HANDLE_MULTIBYTE */
+- ((local_prompt_prefix == 0) ? ((newlines == 0) ? prompt_invis_chars_first_line
+- : ((newlines == 1) ? wrap_offset : 0))
+- : ((newlines == 0) ? wrap_offset :0));
++ temp = ((newlines + 1) * _rl_screenwidth);
++
++ /* Now account for invisible characters in the current line. */
++ /* XXX - this assumes that the invisible characters may be split, but only
++ between the first and the last lines. */
++ temp += ((local_prompt_prefix == 0) ? ((newlines == 0) ? prompt_invis_chars_first_line
++ : ((newlines == prompt_lines_estimate) ? wrap_offset : prompt_invis_chars_first_line))
++ : ((newlines == 0) ? wrap_offset : 0));
+
+ inv_lbreaks[++newlines] = temp;
+ #if defined (HANDLE_MULTIBYTE)
+- lpos -= _rl_col_width (local_prompt, n0, num);
+-#else
+- lpos -= _rl_screenwidth;
++ if (MB_CUR_MAX > 1 && rl_byte_oriented == 0 && prompt_multibyte_chars > 0)
++ lpos -= _rl_col_width (local_prompt, n0, num, 1);
++ else
+ #endif
++ lpos -= _rl_screenwidth;
+ }
+
+ prompt_last_screen_line = newlines;
+
+ /* Draw the rest of the line (after the prompt) into invisible_line, keeping
+- track of where the cursor is (c_pos), the number of the line containing
++ track of where the cursor is (cpos_buffer_position), the number of the line containing
+ the cursor (lb_linenum), the last line number (lb_botlin and inv_botlin).
+ It maintains an array of line breaks for display (inv_lbreaks).
+ This handles expanding tabs for display and displaying meta characters. */
+@@ -670,6 +737,7 @@ rl_redisplay ()
+ if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
+ {
+ memset (&ps, 0, sizeof (mbstate_t));
++ /* XXX - what if wc_bytes ends up <= 0? check for MB_INVALIDCH */
+ wc_bytes = mbrtowc (&wc, rl_line_buffer, rl_end, &ps);
+ }
+ else
+@@ -713,7 +781,7 @@ rl_redisplay ()
+
+ if (in == rl_point)
+ {
+- c_pos = out;
++ cpos_buffer_position = out;
+ lb_linenum = newlines;
+ }
+
+@@ -807,7 +875,7 @@ rl_redisplay ()
+ }
+ if (in == rl_point)
+ {
+- c_pos = out;
++ cpos_buffer_position = out;
+ lb_linenum = newlines;
+ }
+ for (i = in; i < in+wc_bytes; i++)
+@@ -830,6 +898,7 @@ rl_redisplay ()
+ if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
+ {
+ in += wc_bytes;
++ /* XXX - what if wc_bytes ends up <= 0? check for MB_INVALIDCH */
+ wc_bytes = mbrtowc (&wc, rl_line_buffer + in, rl_end - in, &ps);
+ }
+ else
+@@ -838,9 +907,9 @@ rl_redisplay ()
+
+ }
+ line[out] = '\0';
+- if (c_pos < 0)
++ if (cpos_buffer_position < 0)
+ {
+- c_pos = out;
++ cpos_buffer_position = out;
+ lb_linenum = newlines;
+ }
+
+@@ -849,7 +918,7 @@ rl_redisplay ()
+ inv_lbreaks[newlines+1] = out;
+ cursor_linenum = lb_linenum;
+
+- /* C_POS == position in buffer where cursor should be placed.
++ /* CPOS_BUFFER_POSITION == position in buffer where cursor should be placed.
+ CURSOR_LINENUM == line number where the cursor should be placed. */
+
+ /* PWP: now is when things get a bit hairy. The visible and invisible
+@@ -884,6 +953,10 @@ rl_redisplay ()
+ second and subsequent lines start at inv_lbreaks[N], offset by
+ OFFSET (which has already been calculated above). */
+
++#define INVIS_FIRST() (prompt_physical_chars > _rl_screenwidth ? prompt_invis_chars_first_line : wrap_offset)
++#define WRAP_OFFSET(line, offset) ((line == 0) \
++ ? (offset ? INVIS_FIRST() : 0) \
++ : ((line == prompt_last_screen_line) ? wrap_offset-prompt_invis_chars_first_line : 0))
+ #define W_OFFSET(line, offset) ((line) == 0 ? offset : 0)
+ #define VIS_LLEN(l) ((l) > _rl_vis_botlin ? 0 : (vis_lbreaks[l+1] - vis_lbreaks[l]))
+ #define INV_LLEN(l) (inv_lbreaks[l+1] - inv_lbreaks[l])
+@@ -891,9 +964,16 @@ rl_redisplay ()
+ #define VIS_LINE(line) ((line) > _rl_vis_botlin) ? "" : VIS_CHARS(line)
+ #define INV_LINE(line) (invisible_line + inv_lbreaks[line])
+
++#define OLD_CPOS_IN_PROMPT() (cpos_adjusted == 0 && \
++ _rl_last_c_pos != o_cpos && \
++ _rl_last_c_pos > wrap_offset && \
++ o_cpos < prompt_last_invisible)
++
+ /* For each line in the buffer, do the updating display. */
+ for (linenum = 0; linenum <= inv_botlin; linenum++)
+ {
++ /* This can lead us astray if we execute a program that changes
++ the locale from a non-multibyte to a multibyte one. */
+ o_cpos = _rl_last_c_pos;
+ cpos_adjusted = 0;
+ update_line (VIS_LINE(linenum), INV_LINE(linenum), linenum,
+@@ -903,16 +983,22 @@ rl_redisplay ()
+ take invisible characters into account, since _rl_last_c_pos
+ is an absolute cursor position in a multibyte locale. See
+ if compensating here is the right thing, or if we have to
+- change update_line itself. There is one case in which
++ change update_line itself. There are several cases in which
+ update_line adjusts _rl_last_c_pos itself (so it can pass
+ _rl_move_cursor_relative accurate values); it communicates
+- this back by setting cpos_adjusted */
+- if (linenum == 0 && (MB_CUR_MAX > 1 && rl_byte_oriented == 0) &&
+- cpos_adjusted == 0 &&
+- _rl_last_c_pos != o_cpos &&
+- _rl_last_c_pos > wrap_offset &&
+- o_cpos < prompt_last_invisible)
+- _rl_last_c_pos -= wrap_offset;
++ this back by setting cpos_adjusted. If we assume that
++ _rl_last_c_pos is correct (an absolute cursor position) each
++ time update_line is called, then we can assume in our
++ calculations that o_cpos does not need to be adjusted by
++ wrap_offset. */
++ if (linenum == 0 && (MB_CUR_MAX > 1 && rl_byte_oriented == 0) && OLD_CPOS_IN_PROMPT())
++ _rl_last_c_pos -= prompt_invis_chars_first_line; /* XXX - was wrap_offset */
++ else if (linenum == prompt_last_screen_line && prompt_physical_chars > _rl_screenwidth &&
++ (MB_CUR_MAX > 1 && rl_byte_oriented == 0) &&
++ cpos_adjusted == 0 &&
++ _rl_last_c_pos != o_cpos &&
++ _rl_last_c_pos > (prompt_last_invisible - _rl_screenwidth - prompt_invis_chars_first_line))
++ _rl_last_c_pos -= (wrap_offset-prompt_invis_chars_first_line);
+
+ /* If this is the line with the prompt, we might need to
+ compensate for invisible characters in the new line. Do
+@@ -932,6 +1018,19 @@ rl_redisplay ()
+ if (nleft)
+ _rl_clear_to_eol (nleft);
+ }
++#if 0
++ /* This segment is intended to handle the case where the prompt
++ has invisible characters on the second line and the new line
++ to be displayed needs to clear the rest of the old characters
++ out (e.g., when printing the i-search prompt). In general,
++ the case of the new line being shorter than the old.
++ Incomplete */
++ else if (linenum == prompt_last_screen_line &&
++ prompt_physical_chars > _rl_screenwidth &&
++ wrap_offset != prompt_invis_chars_first_line &&
++ _rl_last_c_pos == out &&
++#endif
++
+
+ /* Since the new first line is now visible, save its length. */
+ if (linenum == 0)
+@@ -975,7 +1074,11 @@ rl_redisplay ()
+ invisible character in the prompt string. */
+ nleft = prompt_visible_length + wrap_offset;
+ if (cursor_linenum == 0 && wrap_offset > 0 && _rl_last_c_pos > 0 &&
+- _rl_last_c_pos <= prompt_last_invisible && local_prompt)
++#if 0
++ _rl_last_c_pos <= PROMPT_ENDING_INDEX && local_prompt)
++#else
++ _rl_last_c_pos < PROMPT_ENDING_INDEX && local_prompt)
++#endif
+ {
+ #if defined (__MSDOS__)
+ putc ('\r', rl_outstream);
+@@ -983,19 +1086,22 @@ rl_redisplay ()
+ if (_rl_term_cr)
+ tputs (_rl_term_cr, 1, _rl_output_character_function);
+ #endif
++ if (modmark)
++ _rl_output_some_chars ("*", 1);
++
+ _rl_output_some_chars (local_prompt, nleft);
+ if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
+- _rl_last_c_pos = _rl_col_width (local_prompt, 0, nleft) - wrap_offset;
++ _rl_last_c_pos = _rl_col_width (local_prompt, 0, nleft, 1) - wrap_offset + modmark;
+ else
+- _rl_last_c_pos = nleft;
++ _rl_last_c_pos = nleft + modmark;
+ }
+
+ /* Where on that line? And where does that line start
+ in the buffer? */
+ pos = inv_lbreaks[cursor_linenum];
+ /* nleft == number of characters in the line buffer between the
+- start of the line and the cursor position. */
+- nleft = c_pos - pos;
++ start of the line and the desired cursor position. */
++ nleft = cpos_buffer_position - pos;
+
+ /* NLEFT is now a number of characters in a buffer. When in a
+ multibyte locale, however, _rl_last_c_pos is an absolute cursor
+@@ -1007,11 +1113,12 @@ rl_redisplay ()
+ those characters here and call _rl_backspace() directly. */
+ if (wrap_offset && cursor_linenum == 0 && nleft < _rl_last_c_pos)
+ {
++ /* TX == new physical cursor position in multibyte locale. */
+ if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
+- tx = _rl_col_width (&visible_line[pos], 0, nleft) - visible_wrap_offset;
++ tx = _rl_col_width (&visible_line[pos], 0, nleft, 1) - visible_wrap_offset;
+ else
+ tx = nleft;
+- if (_rl_last_c_pos > tx)
++ if (tx >= 0 && _rl_last_c_pos > tx)
+ {
+ _rl_backspace (_rl_last_c_pos - tx); /* XXX */
+ _rl_last_c_pos = tx;
+@@ -1040,11 +1147,11 @@ rl_redisplay ()
+ will be LMARGIN. */
+
+ /* The number of characters that will be displayed before the cursor. */
+- ndisp = c_pos - wrap_offset;
++ ndisp = cpos_buffer_position - wrap_offset;
+ nleft = prompt_visible_length + wrap_offset;
+ /* Where the new cursor position will be on the screen. This can be
+ longer than SCREENWIDTH; if it is, lmargin will be adjusted. */
+- phys_c_pos = c_pos - (last_lmargin ? last_lmargin : wrap_offset);
++ phys_c_pos = cpos_buffer_position - (last_lmargin ? last_lmargin : wrap_offset);
+ t = _rl_screenwidth / 3;
+
+ /* If the number of characters had already exceeded the screenwidth,
+@@ -1055,7 +1162,7 @@ rl_redisplay ()
+ two-thirds of the way across the screen. */
+ if (phys_c_pos > _rl_screenwidth - 2)
+ {
+- lmargin = c_pos - (2 * t);
++ lmargin = cpos_buffer_position - (2 * t);
+ if (lmargin < 0)
+ lmargin = 0;
+ /* If the left margin would be in the middle of a prompt with
+@@ -1069,7 +1176,7 @@ rl_redisplay ()
+ {
+ /* If we are moving back towards the beginning of the line and
+ the last margin is no longer correct, compute a new one. */
+- lmargin = ((c_pos - 1) / t) * t; /* XXX */
++ lmargin = ((cpos_buffer_position - 1) / t) * t; /* XXX */
+ if (wrap_offset && lmargin > 0 && lmargin < nleft)
+ lmargin = nleft;
+ }
+@@ -1089,9 +1196,11 @@ rl_redisplay ()
+ if (t < out)
+ line[t - 1] = '>';
+
+- if (!rl_display_fixed || forced_display || lmargin != last_lmargin)
++ if (rl_display_fixed == 0 || forced_display || lmargin != last_lmargin)
+ {
+ forced_display = 0;
++ o_cpos = _rl_last_c_pos;
++ cpos_adjusted = 0;
+ update_line (&visible_line[last_lmargin],
+ &invisible_line[lmargin],
+ 0,
+@@ -1099,6 +1208,9 @@ rl_redisplay ()
+ _rl_screenwidth + (lmargin ? 0 : wrap_offset),
+ 0);
+
++ if ((MB_CUR_MAX > 1 && rl_byte_oriented == 0) && OLD_CPOS_IN_PROMPT())
++ _rl_last_c_pos -= prompt_invis_chars_first_line; /* XXX - was wrap_offset */
++
+ /* If the visible new line is shorter than the old, but the number
+ of invisible characters is greater, and we are at the end of
+ the new line, we need to clear to eol. */
+@@ -1114,7 +1226,7 @@ rl_redisplay ()
+ if (visible_first_line_len > _rl_screenwidth)
+ visible_first_line_len = _rl_screenwidth;
+
+- _rl_move_cursor_relative (c_pos - lmargin, &invisible_line[lmargin]);
++ _rl_move_cursor_relative (cpos_buffer_position - lmargin, &invisible_line[lmargin]);
+ last_lmargin = lmargin;
+ }
+ }
+@@ -1122,17 +1234,10 @@ rl_redisplay ()
+
+ /* Swap visible and non-visible lines. */
+ {
+- char *vtemp = visible_line;
+- int *itemp = vis_lbreaks, ntemp = vis_lbsize;
++ struct line_state *vtemp = line_state_visible;
+
+- visible_line = invisible_line;
+- invisible_line = vtemp;
+-
+- vis_lbreaks = inv_lbreaks;
+- inv_lbreaks = itemp;
+-
+- vis_lbsize = inv_lbsize;
+- inv_lbsize = ntemp;
++ line_state_visible = line_state_invisible;
++ line_state_invisible = vtemp;
+
+ rl_display_fixed = 0;
+ /* If we are displaying on a single line, and last_lmargin is > 0, we
+@@ -1144,6 +1249,7 @@ rl_redisplay ()
+ visible_wrap_offset = wrap_offset;
+ }
+
++ RL_UNSETSTATE (RL_STATE_REDISPLAYING);
+ _rl_release_sigint ();
+ }
+
+@@ -1169,12 +1275,12 @@ update_line (old, new, current_line, oma
+ int current_line, omax, nmax, inv_botlin;
+ {
+ register char *ofd, *ols, *oe, *nfd, *nls, *ne;
+- int temp, lendiff, wsatend, od, nd;
++ int temp, lendiff, wsatend, od, nd, twidth, o_cpos;
+ int current_invis_chars;
+ int col_lendiff, col_temp;
+ #if defined (HANDLE_MULTIBYTE)
+ mbstate_t ps_new, ps_old;
+- int new_offset, old_offset, tmp;
++ int new_offset, old_offset;
+ #endif
+
+ /* If we're at the right edge of a terminal that supports xn, we're
+@@ -1185,7 +1291,7 @@ update_line (old, new, current_line, oma
+ if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
+ temp = _rl_last_c_pos;
+ else
+- temp = _rl_last_c_pos - W_OFFSET(_rl_last_v_pos, visible_wrap_offset);
++ temp = _rl_last_c_pos - WRAP_OFFSET (_rl_last_v_pos, visible_wrap_offset);
+ if (temp == _rl_screenwidth && _rl_term_autowrap && !_rl_horizontal_scroll_mode
+ && _rl_last_v_pos == current_line - 1)
+ {
+@@ -1200,8 +1306,8 @@ update_line (old, new, current_line, oma
+ /* This fixes only double-column characters, but if the wrapped
+ character comsumes more than three columns, spaces will be
+ inserted in the string buffer. */
+- if (_rl_wrapped_line[current_line] > 0)
+- _rl_clear_to_eol (_rl_wrapped_line[current_line]);
++ if (current_line < line_state_visible->wbsize && line_state_visible->wrapped_line[current_line] > 0)
++ _rl_clear_to_eol (line_state_visible->wrapped_line[current_line]);
+
+ memset (&ps, 0, sizeof (mbstate_t));
+ ret = mbrtowc (&wc, new, MB_CUR_MAX, &ps);
+@@ -1217,7 +1323,7 @@ update_line (old, new, current_line, oma
+
+ if (tempwidth > 0)
+ {
+- int count;
++ int count, i;
+ bytes = ret;
+ for (count = 0; count < bytes; count++)
+ putc (new[count], rl_outstream);
+@@ -1228,10 +1334,13 @@ update_line (old, new, current_line, oma
+ if (ret != 0 && bytes != 0)
+ {
+ if (MB_INVALIDCH (ret))
+- memmove (old+bytes, old+1, strlen (old+1));
+- else
+- memmove (old+bytes, old+ret, strlen (old+ret));
++ ret = 1;
++ memmove (old+bytes, old+ret, strlen (old+ret));
+ memcpy (old, new, bytes);
++ /* Fix up indices if we copy data from one line to another */
++ omax += bytes - ret;
++ for (i = current_line+1; i < inv_botlin+1; i++)
++ vis_lbreaks[i] += bytes - ret;
+ }
+ }
+ else
+@@ -1265,7 +1374,7 @@ update_line (old, new, current_line, oma
+ /* See if the old line is a subset of the new line, so that the
+ only change is adding characters. */
+ temp = (omax < nmax) ? omax : nmax;
+- if (memcmp (old, new, temp) == 0)
++ if (memcmp (old, new, temp) == 0) /* adding at the end */
+ {
+ ofd = old + temp;
+ nfd = new + temp;
+@@ -1407,30 +1516,48 @@ update_line (old, new, current_line, oma
+ sequences (like drawing the `unbold' sequence without a corresponding
+ `bold') that manifests itself on certain terminals. */
+
+- lendiff = local_prompt ? strlen (local_prompt) : 0;
++ lendiff = local_prompt_len;
+ od = ofd - old; /* index of first difference in visible line */
+ if (current_line == 0 && !_rl_horizontal_scroll_mode &&
+ _rl_term_cr && lendiff > prompt_visible_length && _rl_last_c_pos > 0 &&
+- od >= lendiff && _rl_last_c_pos <= prompt_last_invisible)
++ od >= lendiff && _rl_last_c_pos < PROMPT_ENDING_INDEX)
+ {
+ #if defined (__MSDOS__)
+ putc ('\r', rl_outstream);
+ #else
+ tputs (_rl_term_cr, 1, _rl_output_character_function);
+ #endif
++ if (modmark)
++ _rl_output_some_chars ("*", 1);
+ _rl_output_some_chars (local_prompt, lendiff);
+ if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
+ {
+ /* We take wrap_offset into account here so we can pass correct
+ information to _rl_move_cursor_relative. */
+- _rl_last_c_pos = _rl_col_width (local_prompt, 0, lendiff) - wrap_offset;
++ _rl_last_c_pos = _rl_col_width (local_prompt, 0, lendiff, 1) - wrap_offset + modmark;
+ cpos_adjusted = 1;
+ }
+ else
+- _rl_last_c_pos = lendiff;
++ _rl_last_c_pos = lendiff + modmark;
+ }
+
++ o_cpos = _rl_last_c_pos;
++
++ /* When this function returns, _rl_last_c_pos is correct, and an absolute
++ cursor postion in multibyte mode, but a buffer index when not in a
++ multibyte locale. */
+ _rl_move_cursor_relative (od, old);
++#if 1
++#if defined (HANDLE_MULTIBYTE)
++ /* We need to indicate that the cursor position is correct in the presence of
++ invisible characters in the prompt string. Let's see if setting this when
++ we make sure we're at the end of the drawn prompt string works. */
++ if (current_line == 0 && MB_CUR_MAX > 1 && rl_byte_oriented == 0 &&
++ (_rl_last_c_pos > 0 || o_cpos > 0) &&
++ _rl_last_c_pos == prompt_physical_chars)
++ cpos_adjusted = 1;
++#endif
++#endif
+
+ /* if (len (new) > len (old))
+ lendiff == difference in buffer
+@@ -1438,7 +1565,7 @@ update_line (old, new, current_line, oma
+ When not using multibyte characters, these are equal */
+ lendiff = (nls - nfd) - (ols - ofd);
+ if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
+- col_lendiff = _rl_col_width (new, nfd - new, nls - new) - _rl_col_width (old, ofd - old, ols - old);
++ col_lendiff = _rl_col_width (new, nfd - new, nls - new, 1) - _rl_col_width (old, ofd - old, ols - old, 1);
+ else
+ col_lendiff = lendiff;
+
+@@ -1463,7 +1590,7 @@ update_line (old, new, current_line, oma
+ /* Insert (diff (len (old), len (new)) ch. */
+ temp = ne - nfd;
+ if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
+- col_temp = _rl_col_width (new, nfd - new, ne - new);
++ col_temp = _rl_col_width (new, nfd - new, ne - new, 1);
+ else
+ col_temp = temp;
+
+@@ -1471,22 +1598,60 @@ update_line (old, new, current_line, oma
+ {
+ /* Non-zero if we're increasing the number of lines. */
+ int gl = current_line >= _rl_vis_botlin && inv_botlin > _rl_vis_botlin;
++ /* If col_lendiff is > 0, implying that the new string takes up more
++ screen real estate than the old, but lendiff is < 0, meaning that it
++ takes fewer bytes, we need to just output the characters starting
++ from the first difference. These will overwrite what is on the
++ display, so there's no reason to do a smart update. This can really
++ only happen in a multibyte environment. */
++ if (lendiff < 0)
++ {
++ _rl_output_some_chars (nfd, temp);
++ _rl_last_c_pos += _rl_col_width (nfd, 0, temp, 1);
++ /* If nfd begins before any invisible characters in the prompt,
++ adjust _rl_last_c_pos to account for wrap_offset and set
++ cpos_adjusted to let the caller know. */
++ if (current_line == 0 && wrap_offset && ((nfd - new) <= prompt_last_invisible))
++ {
++ _rl_last_c_pos -= wrap_offset;
++ cpos_adjusted = 1;
++ }
++ return;
++ }
+ /* Sometimes it is cheaper to print the characters rather than
+ use the terminal's capabilities. If we're growing the number
+ of lines, make sure we actually cause the new line to wrap
+ around on auto-wrapping terminals. */
+- if (_rl_terminal_can_insert && ((2 * col_temp) >= col_lendiff || _rl_term_IC) && (!_rl_term_autowrap || !gl))
++ else if (_rl_terminal_can_insert && ((2 * col_temp) >= col_lendiff || _rl_term_IC) && (!_rl_term_autowrap || !gl))
+ {
+ /* If lendiff > prompt_visible_length and _rl_last_c_pos == 0 and
+ _rl_horizontal_scroll_mode == 1, inserting the characters with
+ _rl_term_IC or _rl_term_ic will screw up the screen because of the
+ invisible characters. We need to just draw them. */
+- if (*ols && (!_rl_horizontal_scroll_mode || _rl_last_c_pos > 0 ||
+- lendiff <= prompt_visible_length || !current_invis_chars))
++ /* The same thing happens if we're trying to draw before the last
++ invisible character in the prompt string or we're increasing the
++ number of invisible characters in the line and we're not drawing
++ the entire prompt string. */
++ if (*ols && ((_rl_horizontal_scroll_mode &&
++ _rl_last_c_pos == 0 &&
++ lendiff > prompt_visible_length &&
++ current_invis_chars > 0) == 0) &&
++ (((MB_CUR_MAX > 1 && rl_byte_oriented == 0) &&
++ current_line == 0 && wrap_offset &&
++ ((nfd - new) <= prompt_last_invisible) &&
++ (col_lendiff < prompt_visible_length)) == 0) &&
++ (visible_wrap_offset >= current_invis_chars))
+ {
+ insert_some_chars (nfd, lendiff, col_lendiff);
+ _rl_last_c_pos += col_lendiff;
+ }
++#if 0 /* XXX - for now */
++ else if ((MB_CUR_MAX > 1 && rl_byte_oriented == 0) && _rl_last_c_pos == 0 && wrap_offset && (nfd-new) <= prompt_last_invisible && col_lendiff < prompt_visible_length && visible_wrap_offset >= current_invis_chars)
++ {
++ _rl_output_some_chars (nfd, lendiff);
++ _rl_last_c_pos += col_lendiff;
++ }
++#endif
+ else if ((MB_CUR_MAX == 1 || rl_byte_oriented != 0) && *ols == 0 && lendiff > 0)
+ {
+ /* At the end of a line the characters do not have to
+@@ -1498,11 +1663,16 @@ update_line (old, new, current_line, oma
+ }
+ else
+ {
+- /* We have horizontal scrolling and we are not inserting at
+- the end. We have invisible characters in this line. This
+- is a dumb update. */
+ _rl_output_some_chars (nfd, temp);
+ _rl_last_c_pos += col_temp;
++ /* If nfd begins before the last invisible character in the
++ prompt, adjust _rl_last_c_pos to account for wrap_offset
++ and set cpos_adjusted to let the caller know. */
++ if ((MB_CUR_MAX > 1 && rl_byte_oriented == 0) && current_line == 0 && wrap_offset && ((nfd - new) <= prompt_last_invisible))
++ {
++ _rl_last_c_pos -= wrap_offset;
++ cpos_adjusted = 1;
++ }
+ return;
+ }
+ /* Copy (new) chars to screen from first diff to last match. */
+@@ -1510,15 +1680,23 @@ update_line (old, new, current_line, oma
+ if ((temp - lendiff) > 0)
+ {
+ _rl_output_some_chars (nfd + lendiff, temp - lendiff);
+-#if 1
+ /* XXX -- this bears closer inspection. Fixes a redisplay bug
+ reported against bash-3.0-alpha by Andreas Schwab involving
+ multibyte characters and prompt strings with invisible
+ characters, but was previously disabled. */
+- _rl_last_c_pos += _rl_col_width (nfd+lendiff, 0, temp-col_lendiff);
+-#else
+- _rl_last_c_pos += _rl_col_width (nfd+lendiff, 0, temp-lendiff);
+-#endif
++ if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
++ twidth = _rl_col_width (nfd+lendiff, 0, temp-col_lendiff, 1);
++ else
++ twidth = temp - lendiff;
++ _rl_last_c_pos += twidth;
++ /* If nfd begins before the last invisible character in the
++ prompt, adjust _rl_last_c_pos to account for wrap_offset
++ and set cpos_adjusted to let the caller know. */
++ if ((MB_CUR_MAX > 1 && rl_byte_oriented == 0) && current_line == 0 && wrap_offset && ((nfd - new) <= prompt_last_invisible))
++ {
++ _rl_last_c_pos -= wrap_offset;
++ cpos_adjusted = 1;
++ }
+ }
+ }
+ else
+@@ -1530,6 +1708,14 @@ update_line (old, new, current_line, oma
+ char in the current line (which implies we just output some invisible
+ characters) we need to adjust _rl_last_c_pos, since it represents
+ a physical character position. */
++ if ((MB_CUR_MAX > 1 && rl_byte_oriented == 0) &&
++ current_line == prompt_last_screen_line && wrap_offset &&
++ wrap_offset != prompt_invis_chars_first_line &&
++ ((nfd-new) < (prompt_last_invisible-(current_line*_rl_screenwidth))))
++ {
++ _rl_last_c_pos -= wrap_offset - prompt_invis_chars_first_line;
++ cpos_adjusted = 1;
++ }
+ }
+ }
+ else /* Delete characters from line. */
+@@ -1551,8 +1737,22 @@ update_line (old, new, current_line, oma
+ temp = nls - nfd;
+ if (temp > 0)
+ {
++ /* If nfd begins at the prompt, or before the invisible
++ characters in the prompt, we need to adjust _rl_last_c_pos
++ in a multibyte locale to account for the wrap offset and
++ set cpos_adjusted accordingly. */
+ _rl_output_some_chars (nfd, temp);
+- _rl_last_c_pos += _rl_col_width (nfd, 0, temp);;
++ if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
++ {
++ _rl_last_c_pos += _rl_col_width (nfd, 0, temp, 1);
++ if (current_line == 0 && wrap_offset && ((nfd - new) <= prompt_last_invisible))
++ {
++ _rl_last_c_pos -= wrap_offset;
++ cpos_adjusted = 1;
++ }
++ }
++ else
++ _rl_last_c_pos += temp;
+ }
+ }
+ /* Otherwise, print over the existing material. */
+@@ -1560,16 +1760,37 @@ update_line (old, new, current_line, oma
+ {
+ if (temp > 0)
+ {
++ /* If nfd begins at the prompt, or before the invisible
++ characters in the prompt, we need to adjust _rl_last_c_pos
++ in a multibyte locale to account for the wrap offset and
++ set cpos_adjusted accordingly. */
+ _rl_output_some_chars (nfd, temp);
+ _rl_last_c_pos += col_temp; /* XXX */
++ if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
++ {
++ if (current_line == 0 && wrap_offset && ((nfd - new) <= prompt_last_invisible))
++ {
++ _rl_last_c_pos -= wrap_offset;
++ cpos_adjusted = 1;
++ }
++ }
+ }
+ lendiff = (oe - old) - (ne - new);
+ if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
+- col_lendiff = _rl_col_width (old, 0, oe - old) - _rl_col_width (new, 0, ne - new);
++ col_lendiff = _rl_col_width (old, 0, oe - old, 1) - _rl_col_width (new, 0, ne - new, 1);
+ else
+ col_lendiff = lendiff;
+
++#if 0
+ if (col_lendiff)
++#else
++ /* If we've already printed over the entire width of the screen,
++ including the old material, then col_lendiff doesn't matter and
++ space_to_eol will insert too many spaces. XXX - maybe we should
++ adjust col_lendiff based on the difference between _rl_last_c_pos
++ and _rl_screenwidth */
++ if (col_lendiff && ((MB_CUR_MAX == 1 || rl_byte_oriented) || (_rl_last_c_pos < _rl_screenwidth)))
++#endif
+ {
+ if (_rl_term_autowrap && current_line < inv_botlin)
+ space_to_eol (col_lendiff);
+@@ -1623,7 +1844,7 @@ rl_on_new_line_with_prompt ()
+
+ l = strlen (prompt_last_line);
+ if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
+- _rl_last_c_pos = _rl_col_width (prompt_last_line, 0, l); /* XXX */
++ _rl_last_c_pos = _rl_col_width (prompt_last_line, 0, l, 1); /* XXX */
+ else
+ _rl_last_c_pos = l;
+
+@@ -1658,10 +1879,11 @@ rl_on_new_line_with_prompt ()
+ int
+ rl_forced_update_display ()
+ {
++ register char *temp;
++
+ if (visible_line)
+ {
+- register char *temp = visible_line;
+-
++ temp = visible_line;
+ while (*temp)
+ *temp++ = '\0';
+ }
+@@ -1684,9 +1906,14 @@ _rl_move_cursor_relative (new, data)
+ register int i;
+ int woff; /* number of invisible chars on current line */
+ int cpos, dpos; /* current and desired cursor positions */
++ int adjust;
+
+- woff = W_OFFSET (_rl_last_v_pos, wrap_offset);
++ woff = WRAP_OFFSET (_rl_last_v_pos, wrap_offset);
+ cpos = _rl_last_c_pos;
++
++ if (cpos == 0 && cpos == new)
++ return;
++
+ #if defined (HANDLE_MULTIBYTE)
+ /* If we have multibyte characters, NEW is indexed by the buffer point in
+ a multibyte string, but _rl_last_c_pos is the display position. In
+@@ -1695,9 +1922,42 @@ _rl_move_cursor_relative (new, data)
+ as long as we are past them and they are counted by _rl_col_width. */
+ if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
+ {
+- dpos = _rl_col_width (data, 0, new);
+- if (dpos > woff)
+- dpos -= woff;
++ adjust = 1;
++ /* Try to short-circuit common cases and eliminate a bunch of multibyte
++ character function calls. */
++ /* 1. prompt string */
++ if (new == local_prompt_len && memcmp (data, local_prompt, new) == 0)
++ {
++ dpos = prompt_physical_chars;
++ cpos_adjusted = 1;
++ adjust = 0;
++ }
++ /* 2. prompt_string + line contents */
++ else if (new > local_prompt_len && local_prompt && memcmp (data, local_prompt, local_prompt_len) == 0)
++ {
++ dpos = prompt_physical_chars + _rl_col_width (data, local_prompt_len, new, 1);
++ cpos_adjusted = 1;
++ adjust = 0;
++ }
++ else
++ dpos = _rl_col_width (data, 0, new, 1);
++
++ /* Use NEW when comparing against the last invisible character in the
++ prompt string, since they're both buffer indices and DPOS is a
++ desired display position. */
++ if (adjust && ((new > prompt_last_invisible) || /* XXX - don't use woff here */
++ (prompt_physical_chars >= _rl_screenwidth &&
++ _rl_last_v_pos == prompt_last_screen_line &&
++ wrap_offset >= woff && dpos >= woff &&
++ new > (prompt_last_invisible-(_rl_screenwidth*_rl_last_v_pos)-wrap_offset))))
++ /* XXX last comparison might need to be >= */
++ {
++ dpos -= woff;
++ /* Since this will be assigned to _rl_last_c_pos at the end (more
++ precisely, _rl_last_c_pos == dpos when this function returns),
++ let the caller know. */
++ cpos_adjusted = 1;
++ }
+ }
+ else
+ #endif
+@@ -1716,7 +1976,7 @@ _rl_move_cursor_relative (new, data)
+ else
+ #endif
+ i = _rl_last_c_pos - woff;
+- if (new == 0 || CR_FASTER (new, _rl_last_c_pos) ||
++ if (dpos == 0 || CR_FASTER (dpos, _rl_last_c_pos) ||
+ (_rl_term_autowrap && i == _rl_screenwidth))
+ {
+ #if defined (__MSDOS__)
+@@ -1738,19 +1998,27 @@ _rl_move_cursor_relative (new, data)
+ sequence telling the terminal to move forward one character.
+ That kind of control is for people who don't know what the
+ data is underneath the cursor. */
+-#if defined (HACK_TERMCAP_MOTION)
+- if (_rl_term_forward_char)
+- {
+- for (i = cpos; i < dpos; i++)
+- tputs (_rl_term_forward_char, 1, _rl_output_character_function);
+- }
+- else
+-#endif /* HACK_TERMCAP_MOTION */
++
++ /* However, we need a handle on where the current display position is
++ in the buffer for the immediately preceding comment to be true.
++ In multibyte locales, we don't currently have that info available.
++ Without it, we don't know where the data we have to display begins
++ in the buffer and we have to go back to the beginning of the screen
++ line. In this case, we can use the terminal sequence to move forward
++ if it's available. */
+ if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
+ {
+- tputs (_rl_term_cr, 1, _rl_output_character_function);
+- for (i = 0; i < new; i++)
+- putc (data[i], rl_outstream);
++ if (_rl_term_forward_char)
++ {
++ for (i = cpos; i < dpos; i++)
++ tputs (_rl_term_forward_char, 1, _rl_output_character_function);
++ }
++ else
++ {
++ tputs (_rl_term_cr, 1, _rl_output_character_function);
++ for (i = 0; i < new; i++)
++ putc (data[i], rl_outstream);
++ }
+ }
+ else
+ for (i = cpos; i < new; i++)
+@@ -1908,6 +2176,7 @@ rl_message (va_alist)
+ &prompt_invis_chars_first_line,
+ &prompt_physical_chars);
+ local_prompt_prefix = (char *)NULL;
++ local_prompt_len = local_prompt ? strlen (local_prompt) : 0;
+ (*rl_redisplay_function) ();
+
+ return 0;
+@@ -1931,6 +2200,7 @@ rl_message (format, arg1, arg2)
+ &prompt_invis_chars_first_line,
+ &prompt_physical_chars);
+ local_prompt_prefix = (char *)NULL;
++ local_prompt_len = local_prompt ? strlen (local_prompt) : 0;
+ (*rl_redisplay_function) ();
+
+ return 0;
+@@ -1967,12 +2237,14 @@ rl_save_prompt ()
+ saved_local_prompt = local_prompt;
+ saved_local_prefix = local_prompt_prefix;
+ saved_prefix_length = prompt_prefix_length;
++ saved_local_length = local_prompt_len;
+ saved_last_invisible = prompt_last_invisible;
+ saved_visible_length = prompt_visible_length;
+ saved_invis_chars_first_line = prompt_invis_chars_first_line;
+ saved_physical_chars = prompt_physical_chars;
+
+ local_prompt = local_prompt_prefix = (char *)0;
++ local_prompt_len = 0;
+ prompt_last_invisible = prompt_visible_length = prompt_prefix_length = 0;
+ prompt_invis_chars_first_line = prompt_physical_chars = 0;
+ }
+@@ -1985,6 +2257,7 @@ rl_restore_prompt ()
+
+ local_prompt = saved_local_prompt;
+ local_prompt_prefix = saved_local_prefix;
++ local_prompt_len = saved_local_length;
+ prompt_prefix_length = saved_prefix_length;
+ prompt_last_invisible = saved_last_invisible;
+ prompt_visible_length = saved_visible_length;
+@@ -1993,6 +2266,7 @@ rl_restore_prompt ()
+
+ /* can test saved_local_prompt to see if prompt info has been saved. */
+ saved_local_prompt = saved_local_prefix = (char *)0;
++ saved_local_length = 0;
+ saved_last_invisible = saved_visible_length = saved_prefix_length = 0;
+ saved_invis_chars_first_line = saved_physical_chars = 0;
+ }
+@@ -2106,7 +2380,7 @@ insert_some_chars (string, count, col)
+ /* DEBUGGING */
+ if (MB_CUR_MAX == 1 || rl_byte_oriented)
+ if (count != col)
+- fprintf(stderr, "readline: debug: insert_some_chars: count (%d) != col (%d)\n", count, col);
++ _rl_ttymsg ("debug: insert_some_chars: count (%d) != col (%d)", count, col);
+
+ /* If IC is defined, then we do not have to "enter" insert mode. */
+ if (_rl_term_IC)
+@@ -2189,7 +2463,8 @@ _rl_update_final ()
+ char *last_line;
+
+ last_line = &visible_line[vis_lbreaks[_rl_vis_botlin]];
+- _rl_move_cursor_relative (_rl_screenwidth - 1, last_line);
++ cpos_buffer_position = -1; /* don't know where we are in buffer */
++ _rl_move_cursor_relative (_rl_screenwidth - 1, last_line); /* XXX */
+ _rl_clear_to_eol (0);
+ putc (last_line[_rl_screenwidth - 1], rl_outstream);
+ }
+@@ -2232,6 +2507,7 @@ redraw_prompt (t)
+ &prompt_invis_chars_first_line,
+ &prompt_physical_chars);
+ local_prompt_prefix = (char *)NULL;
++ local_prompt_len = local_prompt ? strlen (local_prompt) : 0;
+
+ rl_forced_update_display ();
+
+@@ -2245,10 +2521,14 @@ _rl_redisplay_after_sigwinch ()
+ {
+ char *t;
+
+- /* Clear the current line and put the cursor at column 0. Make sure
+- the right thing happens if we have wrapped to a new screen line. */
++ /* Clear the last line (assuming that the screen size change will result in
++ either more or fewer characters on that line only) and put the cursor at
++ column 0. Make sure the right thing happens if we have wrapped to a new
++ screen line. */
+ if (_rl_term_cr)
+ {
++ _rl_move_vert (_rl_vis_botlin);
++
+ #if defined (__MSDOS__)
+ putc ('\r', rl_outstream);
+ #else
+@@ -2284,7 +2564,7 @@ _rl_redisplay_after_sigwinch ()
+ void
+ _rl_clean_up_for_exit ()
+ {
+- if (readline_echoing_p)
++ if (_rl_echoing_p)
+ {
+ _rl_move_vert (_rl_vis_botlin);
+ _rl_vis_botlin = 0;
+@@ -2329,20 +2609,41 @@ _rl_current_display_line ()
+ In the case of multibyte characters with stateful encoding, we have to
+ scan from the beginning of the string to take the state into account. */
+ static int
+-_rl_col_width (str, start, end)
++_rl_col_width (str, start, end, flags)
+ const char *str;
+- int start, end;
++ int start, end, flags;
+ {
+ wchar_t wc;
+- mbstate_t ps = {0};
++ mbstate_t ps;
+ int tmp, point, width, max;
+
+ if (end <= start)
+ return 0;
++ if (MB_CUR_MAX == 1 || rl_byte_oriented)
++{
++_rl_ttymsg ("_rl_col_width: called with MB_CUR_MAX == 1");
++ return (end - start);
++}
++
++ memset (&ps, 0, sizeof (mbstate_t));
+
+ point = 0;
+ max = end;
+
++ /* Try to short-circuit common cases. The adjustment to remove wrap_offset
++ is done by the caller. */
++ /* 1. prompt string */
++ if (flags && start == 0 && end == local_prompt_len && memcmp (str, local_prompt, local_prompt_len) == 0)
++ return (prompt_physical_chars + wrap_offset);
++ /* 2. prompt string + line contents */
++ else if (flags && start == 0 && local_prompt_len > 0 && end > local_prompt_len && local_prompt && memcmp (str, local_prompt, local_prompt_len) == 0)
++ {
++ tmp = prompt_physical_chars + wrap_offset;
++ /* XXX - try to call ourselves recursively with non-prompt portion */
++ tmp += _rl_col_width (str, local_prompt_len, end, flags);
++ return (tmp);
++ }
++
+ while (point < start)
+ {
+ tmp = mbrlen (str + point, max, &ps);
+Index: gdb-7.2.90.20110703/readline/doc/ChangeLog.gdb
+===================================================================
+--- gdb-7.2.90.20110703.orig/readline/doc/ChangeLog.gdb 2011-07-03 10:40:53.000000000 +0200
++++ gdb-7.2.90.20110703/readline/doc/ChangeLog.gdb 2011-07-03 10:41:21.000000000 +0200
+@@ -1,3 +1,7 @@
++2011-04-25 Jan Kratochvil <jan.kratochvil@redhat.com>
++
++ Imported readline 6.2, and upstream patch 001.
++
+ 2006-04-24 Daniel Jacobowitz <dan@codesourcery.com>
+
+ Imported readline 5.1, and upstream patches 001-004.
+Index: gdb-7.2.90.20110703/readline/doc/Makefile.in
+===================================================================
+--- gdb-7.2.90.20110703.orig/readline/doc/Makefile.in 2011-07-03 10:40:53.000000000 +0200
++++ gdb-7.2.90.20110703/readline/doc/Makefile.in 2011-07-03 10:41:21.000000000 +0200
+@@ -1,25 +1,24 @@
+ # This makefile for Readline library documentation is in -*- text -*- mode.
+ # Emacs likes it that way.
+
+-# Copyright (C) 1996-2004 Free Software Foundation, Inc.
++# Copyright (C) 1996-2009 Free Software Foundation, Inc.
+
+-# This program is free software; you can redistribute it and/or modify
+-# it under the terms of the GNU General Public License as published by
+-# the Free Software Foundation; either version 2, or (at your option)
+-# any later version.
+-
+-# This program is distributed in the hope that it will be useful,
+-# but WITHOUT ANY WARRANTY; without even the implied warranty of
+-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+-# GNU General Public License for more details.
+-
+-# You should have received a copy of the GNU General Public License
+-# along with this program; if not, write to the Free Software
+-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA.
++# This program is free software: you can redistribute it and/or modify
++# it under the terms of the GNU General Public License as published by
++# the Free Software Foundation, either version 3 of the License, or
++# (at your option) any later version.
++
++# This program is distributed in the hope that it will be useful,
++# but WITHOUT ANY WARRANTY; without even the implied warranty of
++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++# GNU General Public License for more details.
++
++# You should have received a copy of the GNU General Public License
++# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+ topdir = @top_srcdir@
+ srcdir = @srcdir@
+-VPATH = .:@srcdir@
++VPATH = @srcdir@
+
+ prefix = @prefix@
+
+@@ -64,9 +63,9 @@ PSPDF = gs -sPAPERSIZE=${PAPERSIZE
+
+ RLSRC = $(srcdir)/rlman.texi $(srcdir)/rluser.texi \
+ $(srcdir)/rltech.texi $(srcdir)/version.texi \
+- $(srcdir)/rluserman.texi
++ $(srcdir)/rluserman.texi $(srcdir)/fdl.texi
+ HISTSRC = $(srcdir)/history.texi $(srcdir)/hsuser.texi \
+- $(srcdir)/hstech.texi $(srcdir)/version.texi
++ $(srcdir)/hstech.texi $(srcdir)/version.texi $(srcdir)/fdl.texi
+
+ # This should be a program that converts troff to an ascii-readable format
+ NROFF = groff -Tascii
+@@ -83,7 +82,7 @@ PDFOBJ = readline.pdf history.pdf rluser
+
+ INTERMEDIATE_OBJ = rlman.dvi
+
+-DIST_DOCS = $(DVIOBJ) $(PSOBJ) $(HTMLOBJ) $(INFOOBJ) $(TEXTOBJ)
++DIST_DOCS = $(DVIOBJ) $(PSOBJ) $(HTMLOBJ) $(INFOOBJ) $(TEXTOBJ) $(PDFOBJ)
+
+ .SUFFIXES: .0 .3 .ps .txt .dvi .html .pdf
+
+@@ -99,9 +98,11 @@ DIST_DOCS = $(DVIOBJ) $(PSOBJ) $(HTMLOBJ
+ $(RM) $@
+ -${DVIPDF} $<
+
+-all: info dvi html ps text
++all: info dvi html ps text pdf
+ nodvi: info html text
+
++xdist: $(DIST_DOCS)
++
+ info: $(INFOOBJ)
+ dvi: $(DVIOBJ)
+ ps: $(PSOBJ)
+@@ -156,13 +157,13 @@ history.html: ${HISTSRC}
+
+ readline.0: readline.3
+
+-readline_3.ps: readline.3
++readline_3.ps: $(srcdir)/readline.3
+ ${RM} $@
+ ${GROFF} -man < $(srcdir)/readline.3 > $@
+
+ history.0: history.3
+
+-history_3.ps: history.3
++history_3.ps: $(srcdir)/history.3
+ ${RM} $@
+ ${GROFF} -man < $(srcdir)/history.3 > $@
+
+@@ -182,7 +183,7 @@ distclean: clean maybe-clean
+ $(RM) Makefile
+
+ maybe-clean:
+- -if test "X$(topdir)" != "X$(BUILD_DIR)"; then \
++ -if test "X$(topdir)" != "X.." && test "X$(topdir)" != "X$(BUILD_DIR)"; then \
+ $(RM) $(DIST_DOCS); \
+ fi
+
+Index: gdb-7.2.90.20110703/readline/doc/fdl.texi
+===================================================================
+--- gdb-7.2.90.20110703.orig/readline/doc/fdl.texi 2011-07-03 10:40:53.000000000 +0200
++++ gdb-7.2.90.20110703/readline/doc/fdl.texi 2011-07-03 10:41:21.000000000 +0200
+@@ -1,13 +1,12 @@
++@c The GNU Free Documentation License.
++@center Version 1.3, 3 November 2008
+
+-@node GNU Free Documentation License
+-@appendixsec GNU Free Documentation License
+-
+-@cindex FDL, GNU Free Documentation License
+-@center Version 1.2, November 2002
++@c This file is intended to be included within another document,
++@c hence no sectioning command or @node.
+
+ @display
+-Copyright @copyright{} 2000,2001,2002 Free Software Foundation, Inc.
+-59 Temple Place, Suite 330, Boston, MA 02111-1307, USA
++Copyright @copyright{} 2000, 2001, 2002, 2007, 2008 Free Software Foundation, Inc.
++@uref{http://fsf.org/}
+
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+@@ -112,6 +111,9 @@ formats which do not have any title page
+ the text near the most prominent appearance of the work's title,
+ preceding the beginning of the body of the text.
+
++The ``publisher'' means any person or entity that distributes copies
++of the Document to the public.
++
+ A section ``Entitled XYZ'' means a named subunit of the Document whose
+ title either is precisely XYZ or contains XYZ in parentheses following
+ text that translates XYZ in another language. (Here XYZ stands for a
+@@ -344,7 +346,7 @@ and independent documents or works, in o
+ distribution medium, is called an ``aggregate'' if the copyright
+ resulting from the compilation is not used to limit the legal rights
+ of the compilation's users beyond what the individual works permit.
+-When the Document is included an aggregate, this License does not
++When the Document is included in an aggregate, this License does not
+ apply to the other works in the aggregate which are not themselves
+ derivative works of the Document.
+
+@@ -380,13 +382,30 @@ title.
+ @item
+ TERMINATION
+
+-You may not copy, modify, sublicense, or distribute the Document except
+-as expressly provided for under this License. Any other attempt to
+-copy, modify, sublicense or distribute the Document is void, and will
+-automatically terminate your rights under this License. However,
+-parties who have received copies, or rights, from you under this
+-License will not have their licenses terminated so long as such
+-parties remain in full compliance.
++You may not copy, modify, sublicense, or distribute the Document
++except as expressly provided under this License. Any attempt
++otherwise to copy, modify, sublicense, or distribute it is void, and
++will automatically terminate your rights under this License.
++
++However, if you cease all violation of this License, then your license
++from a particular copyright holder is reinstated (a) provisionally,
++unless and until the copyright holder explicitly and finally
++terminates your license, and (b) permanently, if the copyright holder
++fails to notify you of the violation by some reasonable means prior to
++60 days after the cessation.
++
++Moreover, your license from a particular copyright holder is
++reinstated permanently if the copyright holder notifies you of the
++violation by some reasonable means, this is the first time you have
++received notice of violation of this License (for any work) from that
++copyright holder, and you cure the violation prior to 30 days after
++your receipt of the notice.
++
++Termination of your rights under this section does not terminate the
++licenses of parties who have received copies or rights from you under
++this License. If your rights have been terminated and not permanently
++reinstated, receipt of a copy of some or all of the same material does
++not give you any rights to use it.
+
+ @item
+ FUTURE REVISIONS OF THIS LICENSE
+@@ -404,11 +423,46 @@ following the terms and conditions eithe
+ of any later version that has been published (not as a draft) by the
+ Free Software Foundation. If the Document does not specify a version
+ number of this License, you may choose any version ever published (not
+-as a draft) by the Free Software Foundation.
++as a draft) by the Free Software Foundation. If the Document
++specifies that a proxy can decide which future versions of this
++License can be used, that proxy's public statement of acceptance of a
++version permanently authorizes you to choose that version for the
++Document.
++
++@item
++RELICENSING
++
++``Massive Multiauthor Collaboration Site'' (or ``MMC Site'') means any
++World Wide Web server that publishes copyrightable works and also
++provides prominent facilities for anybody to edit those works. A
++public wiki that anybody can edit is an example of such a server. A
++``Massive Multiauthor Collaboration'' (or ``MMC'') contained in the
++site means any set of copyrightable works thus published on the MMC
++site.
++
++``CC-BY-SA'' means the Creative Commons Attribution-Share Alike 3.0
++license published by Creative Commons Corporation, a not-for-profit
++corporation with a principal place of business in San Francisco,
++California, as well as future copyleft versions of that license
++published by that same organization.
++
++``Incorporate'' means to publish or republish a Document, in whole or
++in part, as part of another Document.
++
++An MMC is ``eligible for relicensing'' if it is licensed under this
++License, and if all works that were first published under this License
++somewhere other than this MMC, and subsequently incorporated in whole
++or in part into the MMC, (1) had no cover texts or invariant sections,
++and (2) were thus incorporated prior to November 1, 2008.
++
++The operator of an MMC Site may republish an MMC contained in the site
++under CC-BY-SA on the same site at any time before August 1, 2009,
++provided the MMC is eligible for relicensing.
++
+ @end enumerate
+
+ @page
+-@appendixsubsec ADDENDUM: How to use this License for your documents
++@heading ADDENDUM: How to use this License for your documents
+
+ To use this License in a document you have written, include a copy of
+ the License in the document and put the following copyright and
+@@ -418,16 +472,16 @@ license notices just after the title pag
+ @group
+ Copyright (C) @var{year} @var{your name}.
+ Permission is granted to copy, distribute and/or modify this document
+- under the terms of the GNU Free Documentation License, Version 1.2
++ under the terms of the GNU Free Documentation License, Version 1.3
+ or any later version published by the Free Software Foundation;
+- with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
+- A copy of the license is included in the section entitled ``GNU
++ with no Invariant Sections, no Front-Cover Texts, and no Back-Cover
++ Texts. A copy of the license is included in the section entitled ``GNU
+ Free Documentation License''.
+ @end group
+ @end smallexample
+
+ If you have Invariant Sections, Front-Cover Texts and Back-Cover Texts,
+-replace the ``with...Texts.'' line with this:
++replace the ``with@dots{}Texts.'' line with this:
+
+ @smallexample
+ @group
+Index: gdb-7.2.90.20110703/readline/doc/history.3
+===================================================================
+--- gdb-7.2.90.20110703.orig/readline/doc/history.3 2011-07-03 10:40:53.000000000 +0200
++++ gdb-7.2.90.20110703/readline/doc/history.3 2011-07-03 10:41:21.000000000 +0200
+@@ -6,9 +6,9 @@
+ .\" Case Western Reserve University
+ .\" chet@ins.CWRU.Edu
+ .\"
+-.\" Last Change: Thu Jul 31 08:46:08 EDT 2003
++.\" Last Change: Thu Aug 12 22:24:41 EDT 2010
+ .\"
+-.TH HISTORY 3 "2003 July 31" "GNU History 5.0"
++.TH HISTORY 3 "2010 August 12" "GNU History 6.2"
+ .\"
+ .\" File Name macro. This used to be `.PN', for Path Name,
+ .\" but Sun doesn't seem to like that very much.
+@@ -40,8 +40,8 @@
+ .SH NAME
+ history \- GNU History Library
+ .SH COPYRIGHT
+-.if t The GNU History Library is Copyright \(co 1989-2002 by the Free Software Foundation, Inc.
+-.if n The GNU History Library is Copyright (C) 1989-2002 by the Free Software Foundation, Inc.
++.if t The GNU History Library is Copyright \(co 1989-2011 by the Free Software Foundation, Inc.
++.if n The GNU History Library is Copyright (C) 1989-2011 by the Free Software Foundation, Inc.
+ .SH DESCRIPTION
+ Many programs read input from the user a line at a time. The GNU
+ History library is able to keep track of those lines, associate arbitrary
+@@ -83,6 +83,8 @@ the history expansion character.
+ .PP
+ An event designator is a reference to a command line entry in the
+ history list.
++Unless the reference is absolute, events are relative to the current
++position in the history list.
+ .PP
+ .PD 0
+ .TP
+@@ -96,18 +98,22 @@ Refer to command line
+ .IR n .
+ .TP
+ .B !\-\fIn\fR
+-Refer to the current command line minus
++Refer to the current command minus
+ .IR n .
+ .TP
+ .B !!
+ Refer to the previous command. This is a synonym for `!\-1'.
+ .TP
+ .B !\fIstring\fR
+-Refer to the most recent command starting with
++Refer to the most recent command
++preceding the current position in the history list
++starting with
+ .IR string .
+ .TP
+ .B !?\fIstring\fR\fB[?]\fR
+-Refer to the most recent command containing
++Refer to the most recent command
++preceding the current postition in the history list
++containing
+ .IR string .
+ The trailing \fB?\fP may be omitted if
+ .I string
+@@ -569,10 +575,13 @@ The number of entries currently stored i
+ The maximum number of history entries. This must be changed using
+ \fBstifle_history()\fP.
+
+-.Vb int history_write_timestamps
++.Vb int history_wite_timestamps
+ If non-zero, timestamps are written to the history file, so they can be
+ preserved between sessions. The default value is 0, meaning that
+ timestamps are not saved.
++The current timestamp format uses the value of \fIhistory_comment_char\fP
++to delimit timestamp entries in the history file. If that variable does
++not have a value (the default), timestamps will not be written.
+
+ .Vb char history_expansion_char
+ The character that introduces a history event. The default is \fB!\fP.
+Index: gdb-7.2.90.20110703/readline/doc/history.texi
+===================================================================
+--- gdb-7.2.90.20110703.orig/readline/doc/history.texi 2011-07-03 10:40:53.000000000 +0200
++++ gdb-7.2.90.20110703/readline/doc/history.texi 2011-07-03 10:41:21.000000000 +0200
+@@ -4,8 +4,6 @@
+ @settitle GNU History Library
+ @c %**end of header (This is for running Texinfo on a region.)
+
+-@setchapternewpage odd
+-
+ @include version.texi
+
+ @copying
+@@ -14,7 +12,7 @@ This document describes the GNU History
+ a programming tool that provides a consistent user interface for
+ recalling lines of previously typed input.
+
+-Copyright @copyright{} 1988-2004 Free Software Foundation, Inc.
++Copyright @copyright{} 1988--2011 Free Software Foundation, Inc.
+
+ Permission is granted to make and distribute verbatim copies of
+ this manual provided the copyright notice and this permission notice
+@@ -22,15 +20,16 @@ are preserved on all copies.
+
+ @quotation
+ Permission is granted to copy, distribute and/or modify this document
+-under the terms of the GNU Free Documentation License, Version 1.1 or
++under the terms of the GNU Free Documentation License, Version 1.3 or
+ any later version published by the Free Software Foundation; with no
+-Invariant Sections, with the Front-Cover texts being ``A GNU Manual,''
++Invariant Sections, with the Front-Cover texts being ``A GNU Manual'',
+ and with the Back-Cover Texts as in (a) below. A copy of the license is
+-included in the section entitled ``GNU Free Documentation License.''
++included in the section entitled ``GNU Free Documentation License''.
++
++(a) The FSF's Back-Cover Text is: You are free to copy and modify
++this GNU manual. Buying copies from GNU Press supports the FSF in
++developing GNU and promoting software freedom.''
+
+-(a) The FSF's Back-Cover Text is: ``You have freedom to copy and modify
+-this GNU Manual, like GNU software. Copies published by the Free
+-Software Foundation raise funds for GNU development.''
+ @end quotation
+ @end copying
+
+@@ -72,7 +71,7 @@ typed input.
+ @menu
+ * Using History Interactively:: GNU History User's Manual.
+ * Programming with GNU History:: GNU History Programmer's Manual.
+-* Copying This Manual:: Copying This Manual.
++* GNU Free Documentation License:: License for copying this manual.
+ * Concept Index:: Index of concepts described in this manual.
+ * Function and Variable Index:: Index of externally visible functions
+ and variables.
+@@ -84,12 +83,8 @@ typed input.
+ @include hsuser.texi
+ @include hstech.texi
+
+-@node Copying This Manual
+-@appendix Copying This Manual
+-
+-@menu
+-* GNU Free Documentation License:: License for copying this manual.
+-@end menu
++@node GNU Free Documentation License
++@appendix GNU Free Documentation License
+
+ @include fdl.texi
+
+Index: gdb-7.2.90.20110703/readline/doc/hstech.texi
+===================================================================
+--- gdb-7.2.90.20110703.orig/readline/doc/hstech.texi 2011-07-03 10:40:53.000000000 +0200
++++ gdb-7.2.90.20110703/readline/doc/hstech.texi 2011-07-03 10:41:21.000000000 +0200
+@@ -1,7 +1,7 @@
+ @ignore
+ This file documents the user interface to the GNU History library.
+
+-Copyright (C) 1988-2002 Free Software Foundation, Inc.
++Copyright (C) 1988-2011 Free Software Foundation, Inc.
+ Authored by Brian Fox and Chet Ramey.
+
+ Permission is granted to make and distribute verbatim copies of this manual
+@@ -426,6 +426,10 @@ The maximum number of history entries.
+ If non-zero, timestamps are written to the history file, so they can be
+ preserved between sessions. The default value is 0, meaning that
+ timestamps are not saved.
++
++The current timestamp format uses the value of @var{history_comment_char}
++to delimit timestamp entries in the history file. If that variable does
++not have a value (the default), timestamps will not be written.
+ @end deftypevar
+
+ @deftypevar char history_expansion_char
+Index: gdb-7.2.90.20110703/readline/doc/hsuser.texi
+===================================================================
+--- gdb-7.2.90.20110703.orig/readline/doc/hsuser.texi 2011-07-03 10:40:53.000000000 +0200
++++ gdb-7.2.90.20110703/readline/doc/hsuser.texi 2011-07-03 10:41:21.000000000 +0200
+@@ -1,7 +1,7 @@
+ @ignore
+ This file documents the user interface to the GNU History library.
+
+-Copyright (C) 1988-2002 Free Software Foundation, Inc.
++Copyright (C) 1988--2011 Free Software Foundation, Inc.
+ Authored by Brian Fox and Chet Ramey.
+
+ Permission is granted to make and distribute verbatim copies of this manual
+@@ -97,7 +97,11 @@ to contain no more than @env{$HISTFILESI
+ lines. If @env{HISTFILESIZE} is not set, no truncation is performed.
+
+ If the @env{HISTTIMEFORMAT} is set, the time stamp information
+-associated with each history entry is written to the history file.
++associated with each history entry is written to the history file,
++marked with the history comment character.
++When the history file is read, lines beginning with the history
++comment character followed immediately by a digit are interpreted
++as timestamps for the previous history line.
+
+ The builtin command @code{fc} may be used to list or edit and re-execute
+ a portion of the history list.
+@@ -133,7 +137,7 @@ history list and history file.
+ @item fc
+ @btindex fc
+ @example
+-@code{fc [-e @var{ename}] [-nlr] [@var{first}] [@var{last}]}
++@code{fc [-e @var{ename}] [-lnr] [@var{first}] [@var{last}]}
+ @code{fc -s [@var{pat}=@var{rep}] [@var{command}]}
+ @end example
+
+@@ -277,7 +281,10 @@ them, so that they are available for sub
+ This is most useful in conjunction with Readline.
+
+ The shell allows control of the various characters used by the
+-history expansion mechanism with the @code{histchars} variable.
++history expansion mechanism with the @code{histchars} variable,
++as explained above (@pxref{Bash Variables}). The shell uses
++the history comment character to mark history timestamps when
++writing the history file.
+ @end ifset
+
+ @menu
+@@ -292,6 +299,8 @@ history expansion mechanism with the @co
+
+ An event designator is a reference to a command line entry in the
+ history list.
++Unless the reference is absolute, events are relative to the current
++position in the history list.
+ @cindex history events
+
+ @table @asis
+@@ -317,10 +326,15 @@ Refer to the command @var{n} lines back.
+ Refer to the previous command. This is a synonym for @samp{!-1}.
+
+ @item @code{!@var{string}}
+-Refer to the most recent command starting with @var{string}.
++Refer to the most recent command
++preceding the current position in the history list
++starting with @var{string}.
+
+ @item @code{!?@var{string}[?]}
+-Refer to the most recent command containing @var{string}. The trailing
++Refer to the most recent command
++preceding the current position in the history list
++containing @var{string}.
++The trailing
+ @samp{?} may be omitted if the @var{string} is followed immediately by
+ a newline.
+
+@@ -412,7 +426,7 @@ of the following modifiers, each precede
+ Remove a trailing pathname component, leaving only the head.
+
+ @item t
+-Remove all leading pathname components, leaving the tail.
++Remove all leading pathname components, leaving the tail.
+
+ @item r
+ Remove a trailing suffix of the form @samp{.@var{suffix}}, leaving
+Index: gdb-7.2.90.20110703/readline/doc/inc-hist.texinfo
+===================================================================
+--- gdb-7.2.90.20110703.orig/readline/doc/inc-hist.texinfo 2011-07-03 10:40:53.000000000 +0200
++++ /dev/null 1970-01-01 00:00:00.000000000 +0000
+@@ -1,457 +0,0 @@
+-@ignore
+-This file documents the user interface to the GNU History library.
+-
+-Copyright (C) 1988-2002 Free Software Foundation, Inc.
+-Authored by Brian Fox and Chet Ramey.
+-
+-Permission is granted to make and distribute verbatim copies of this manual
+-provided the copyright notice and this permission notice are preserved on
+-all copies.
+-
+-Permission is granted to process this file through Tex and print the
+-results, provided the printed document carries copying permission notice
+-identical to this one except for the removal of this paragraph (this
+-paragraph not being relevant to the printed manual).
+-
+-Permission is granted to copy and distribute modified versions of this
+-manual under the conditions for verbatim copying, provided also that the
+-GNU Copyright statement is available to the distributee, and provided that
+-the entire resulting derived work is distributed under the terms of a
+-permission notice identical to this one.
+-
+-Permission is granted to copy and distribute translations of this manual
+-into another language, under the above conditions for modified versions.
+-@end ignore
+-
+-@node Using History Interactively
+-@chapter Using History Interactively
+-
+-@c @ifclear BashFeatures
+-@c @defcodeindex bt
+-@c @end ifclear
+-
+-@ifset BashFeatures
+-This chapter describes how to use the @sc{gnu} History Library
+-interactively, from a user's standpoint.
+-It should be considered a user's guide.
+-For information on using the @sc{gnu} History Library in other programs,
+-see the @sc{gnu} Readline Library Manual.
+-@end ifset
+-@ifclear BashFeatures
+-This chapter describes how to use the @sc{gnu} History Library interactively,
+-from a user's standpoint. It should be considered a user's guide.
+-For information on using the @sc{gnu} History Library in other programs,
+-see the @sc{gnu} Readline Library Manual.
+-@end ifclear
+-
+-@ifset BashFeatures
+-@menu
+-* Bash History Facilities:: How Bash lets you manipulate your command
+- history.
+-* Bash History Builtins:: The Bash builtin commands that manipulate
+- the command history.
+-* History Interaction:: What it feels like using History as a user.
+-@end menu
+-@end ifset
+-@ifclear BashFeatures
+-@menu
+-* History Interaction:: What it feels like using History as a user.
+-@end menu
+-@end ifclear
+-
+-@ifset BashFeatures
+-@node Bash History Facilities
+-@section Bash History Facilities
+-@cindex command history
+-@cindex history list
+-
+-When the @option{-o history} option to the @code{set} builtin
+-is enabled (@pxref{The Set Builtin}),
+-the shell provides access to the @dfn{command history},
+-the list of commands previously typed.
+-The value of the @env{HISTSIZE} shell variable is used as the
+-number of commands to save in a history list.
+-The text of the last @env{$HISTSIZE}
+-commands (default 500) is saved.
+-The shell stores each command in the history list prior to
+-parameter and variable expansion
+-but after history expansion is performed, subject to the
+-values of the shell variables
+-@env{HISTIGNORE} and @env{HISTCONTROL}.
+-
+-When the shell starts up, the history is initialized from the
+-file named by the @env{HISTFILE} variable (default @file{~/.bash_history}).
+-The file named by the value of @env{HISTFILE} is truncated, if
+-necessary, to contain no more than the number of lines specified by
+-the value of the @env{HISTFILESIZE} variable.
+-When an interactive shell exits, the last
+-@env{$HISTSIZE} lines are copied from the history list to the file
+-named by @env{$HISTFILE}.
+-If the @code{histappend} shell option is set (@pxref{Bash Builtins}),
+-the lines are appended to the history file,
+-otherwise the history file is overwritten.
+-If @env{HISTFILE}
+-is unset, or if the history file is unwritable, the history is
+-not saved. After saving the history, the history file is truncated
+-to contain no more than @env{$HISTFILESIZE}
+-lines. If @env{HISTFILESIZE} is not set, no truncation is performed.
+-
+-If the @env{HISTTIMEFORMAT} is set, the time stamp information
+-associated with each history entry is written to the history file.
+-
+-The builtin command @code{fc} may be used to list or edit and re-execute
+-a portion of the history list.
+-The @code{history} builtin may be used to display or modify the history
+-list and manipulate the history file.
+-When using command-line editing, search commands
+-are available in each editing mode that provide access to the
+-history list (@pxref{Commands For History}).
+-
+-The shell allows control over which commands are saved on the history
+-list. The @env{HISTCONTROL} and @env{HISTIGNORE}
+-variables may be set to cause the shell to save only a subset of the
+-commands entered.
+-The @code{cmdhist}
+-shell option, if enabled, causes the shell to attempt to save each
+-line of a multi-line command in the same history entry, adding
+-semicolons where necessary to preserve syntactic correctness.
+-The @code{lithist}
+-shell option causes the shell to save the command with embedded newlines
+-instead of semicolons.
+-The @code{shopt} builtin is used to set these options.
+-@xref{Bash Builtins}, for a description of @code{shopt}.
+-
+-@node Bash History Builtins
+-@section Bash History Builtins
+-@cindex history builtins
+-
+-Bash provides two builtin commands which manipulate the
+-history list and history file.
+-
+-@table @code
+-
+-@item fc
+-@btindex fc
+-@example
+-@code{fc [-e @var{ename}] [-nlr] [@var{first}] [@var{last}]}
+-@code{fc -s [@var{pat}=@var{rep}] [@var{command}]}
+-@end example
+-
+-Fix Command. In the first form, a range of commands from @var{first} to
+-@var{last} is selected from the history list. Both @var{first} and
+-@var{last} may be specified as a string (to locate the most recent
+-command beginning with that string) or as a number (an index into the
+-history list, where a negative number is used as an offset from the
+-current command number). If @var{last} is not specified it is set to
+-@var{first}. If @var{first} is not specified it is set to the previous
+-command for editing and @minus{}16 for listing. If the @option{-l} flag is
+-given, the commands are listed on standard output. The @option{-n} flag
+-suppresses the command numbers when listing. The @option{-r} flag
+-reverses the order of the listing. Otherwise, the editor given by
+-@var{ename} is invoked on a file containing those commands. If
+-@var{ename} is not given, the value of the following variable expansion
+-is used: @code{$@{FCEDIT:-$@{EDITOR:-vi@}@}}. This says to use the
+-value of the @env{FCEDIT} variable if set, or the value of the
+-@env{EDITOR} variable if that is set, or @code{vi} if neither is set.
+-When editing is complete, the edited commands are echoed and executed.
+-
+-In the second form, @var{command} is re-executed after each instance
+-of @var{pat} in the selected command is replaced by @var{rep}.
+-
+-A useful alias to use with the @code{fc} command is @code{r='fc -s'}, so
+-that typing @samp{r cc} runs the last command beginning with @code{cc}
+-and typing @samp{r} re-executes the last command (@pxref{Aliases}).
+-
+-@item history
+-@btindex history
+-@example
+-history [@var{n}]
+-history -c
+-history -d @var{offset}
+-history [-anrw] [@var{filename}]
+-history -ps @var{arg}
+-@end example
+-
+-With no options, display the history list with line numbers.
+-Lines prefixed with a @samp{*} have been modified.
+-An argument of @var{n} lists only the last @var{n} lines.
+-If the shell variable @env{HISTTIMEFORMAT} is set and not null,
+-it is used as a format string for @var{strftime} to display
+-the time stamp associated with each displayed history entry.
+-No intervening blank is printed between the formatted time stamp
+-and the history line.
+-
+-Options, if supplied, have the following meanings:
+-
+-@table @code
+-@item -c
+-Clear the history list. This may be combined
+-with the other options to replace the history list completely.
+-
+-@item -d @var{offset}
+-Delete the history entry at position @var{offset}.
+-@var{offset} should be specified as it appears when the history is
+-displayed.
+-
+-@item -a
+-Append the new
+-history lines (history lines entered since the beginning of the
+-current Bash session) to the history file.
+-
+-@item -n
+-Append the history lines not already read from the history file
+-to the current history list. These are lines appended to the history
+-file since the beginning of the current Bash session.
+-
+-@item -r
+-Read the current history file and append its contents to
+-the history list.
+-
+-@item -w
+-Write out the current history to the history file.
+-
+-@item -p
+-Perform history substitution on the @var{arg}s and display the result
+-on the standard output, without storing the results in the history list.
+-
+-@item -s
+-The @var{arg}s are added to the end of
+-the history list as a single entry.
+-
+-@end table
+-
+-When any of the @option{-w}, @option{-r}, @option{-a}, or @option{-n} options is
+-used, if @var{filename}
+-is given, then it is used as the history file. If not, then
+-the value of the @env{HISTFILE} variable is used.
+-
+-@end table
+-@end ifset
+-
+-@node History Interaction
+-@section History Expansion
+-@cindex history expansion
+-
+-The History library provides a history expansion feature that is similar
+-to the history expansion provided by @code{csh}. This section
+-describes the syntax used to manipulate the history information.
+-
+-History expansions introduce words from the history list into
+-the input stream, making it easy to repeat commands, insert the
+-arguments to a previous command into the current input line, or
+-fix errors in previous commands quickly.
+-
+-History expansion takes place in two parts. The first is to determine
+-which line from the history list should be used during substitution.
+-The second is to select portions of that line for inclusion into the
+-current one. The line selected from the history is called the
+-@dfn{event}, and the portions of that line that are acted upon are
+-called @dfn{words}. Various @dfn{modifiers} are available to manipulate
+-the selected words. The line is broken into words in the same fashion
+-that Bash does, so that several words
+-surrounded by quotes are considered one word.
+-History expansions are introduced by the appearance of the
+-history expansion character, which is @samp{!} by default.
+-@ifset BashFeatures
+-Only @samp{\} and @samp{'} may be used to escape the history expansion
+-character.
+-@end ifset
+-
+-@ifset BashFeatures
+-Several shell options settable with the @code{shopt}
+-builtin (@pxref{Bash Builtins}) may be used to tailor
+-the behavior of history expansion. If the
+-@code{histverify} shell option is enabled, and Readline
+-is being used, history substitutions are not immediately passed to
+-the shell parser.
+-Instead, the expanded line is reloaded into the Readline
+-editing buffer for further modification.
+-If Readline is being used, and the @code{histreedit}
+-shell option is enabled, a failed history expansion will be
+-reloaded into the Readline editing buffer for correction.
+-The @option{-p} option to the @code{history} builtin command
+-may be used to see what a history expansion will do before using it.
+-The @option{-s} option to the @code{history} builtin may be used to
+-add commands to the end of the history list without actually executing
+-them, so that they are available for subsequent recall.
+-This is most useful in conjunction with Readline.
+-
+-The shell allows control of the various characters used by the
+-history expansion mechanism with the @code{histchars} variable.
+-@end ifset
+-
+-@menu
+-* Event Designators:: How to specify which history line to use.
+-* Word Designators:: Specifying which words are of interest.
+-* Modifiers:: Modifying the results of substitution.
+-@end menu
+-
+-@node Event Designators
+-@subsection Event Designators
+-@cindex event designators
+-
+-An event designator is a reference to a command line entry in the
+-history list.
+-@cindex history events
+-
+-@table @asis
+-
+-@item @code{!}
+-@ifset BashFeatures
+-Start a history substitution, except when followed by a space, tab,
+-the end of the line, @samp{=} or @samp{(} (when the
+-@code{extglob} shell option is enabled using the @code{shopt} builtin).
+-@end ifset
+-@ifclear BashFeatures
+-Start a history substitution, except when followed by a space, tab,
+-the end of the line, or @samp{=}.
+-@end ifclear
+-
+-@item @code{!@var{n}}
+-Refer to command line @var{n}.
+-
+-@item @code{!-@var{n}}
+-Refer to the command @var{n} lines back.
+-
+-@item @code{!!}
+-Refer to the previous command. This is a synonym for @samp{!-1}.
+-
+-@item @code{!@var{string}}
+-Refer to the most recent command starting with @var{string}.
+-
+-@item @code{!?@var{string}[?]}
+-Refer to the most recent command containing @var{string}. The trailing
+-@samp{?} may be omitted if the @var{string} is followed immediately by
+-a newline.
+-
+-@item @code{^@var{string1}^@var{string2}^}
+-Quick Substitution. Repeat the last command, replacing @var{string1}
+-with @var{string2}. Equivalent to
+-@code{!!:s/@var{string1}/@var{string2}/}.
+-
+-@item @code{!#}
+-The entire command line typed so far.
+-
+-@end table
+-
+-@node Word Designators
+-@subsection Word Designators
+-
+-Word designators are used to select desired words from the event.
+-A @samp{:} separates the event specification from the word designator. It
+-may be omitted if the word designator begins with a @samp{^}, @samp{$},
+-@samp{*}, @samp{-}, or @samp{%}. Words are numbered from the beginning
+-of the line, with the first word being denoted by 0 (zero). Words are
+-inserted into the current line separated by single spaces.
+-
+-@need 0.75
+-For example,
+-
+-@table @code
+-@item !!
+-designates the preceding command. When you type this, the preceding
+-command is repeated in toto.
+-
+-@item !!:$
+-designates the last argument of the preceding command. This may be
+-shortened to @code{!$}.
+-
+-@item !fi:2
+-designates the second argument of the most recent command starting with
+-the letters @code{fi}.
+-@end table
+-
+-@need 0.75
+-Here are the word designators:
+-
+-@table @code
+-
+-@item 0 (zero)
+-The @code{0}th word. For many applications, this is the command word.
+-
+-@item @var{n}
+-The @var{n}th word.
+-
+-@item ^
+-The first argument; that is, word 1.
+-
+-@item $
+-The last argument.
+-
+-@item %
+-The word matched by the most recent @samp{?@var{string}?} search.
+-
+-@item @var{x}-@var{y}
+-A range of words; @samp{-@var{y}} abbreviates @samp{0-@var{y}}.
+-
+-@item *
+-All of the words, except the @code{0}th. This is a synonym for @samp{1-$}.
+-It is not an error to use @samp{*} if there is just one word in the event;
+-the empty string is returned in that case.
+-
+-@item @var{x}*
+-Abbreviates @samp{@var{x}-$}
+-
+-@item @var{x}-
+-Abbreviates @samp{@var{x}-$} like @samp{@var{x}*}, but omits the last word.
+-
+-@end table
+-
+-If a word designator is supplied without an event specification, the
+-previous command is used as the event.
+-
+-@node Modifiers
+-@subsection Modifiers
+-
+-After the optional word designator, you can add a sequence of one or more
+-of the following modifiers, each preceded by a @samp{:}.
+-
+-@table @code
+-
+-@item h
+-Remove a trailing pathname component, leaving only the head.
+-
+-@item t
+-Remove all leading pathname components, leaving the tail.
+-
+-@item r
+-Remove a trailing suffix of the form @samp{.@var{suffix}}, leaving
+-the basename.
+-
+-@item e
+-Remove all but the trailing suffix.
+-
+-@item p
+-Print the new command but do not execute it.
+-
+-@ifset BashFeatures
+-@item q
+-Quote the substituted words, escaping further substitutions.
+-
+-@item x
+-Quote the substituted words as with @samp{q},
+-but break into words at spaces, tabs, and newlines.
+-@end ifset
+-
+-@item s/@var{old}/@var{new}/
+-Substitute @var{new} for the first occurrence of @var{old} in the
+-event line. Any delimiter may be used in place of @samp{/}.
+-The delimiter may be quoted in @var{old} and @var{new}
+-with a single backslash. If @samp{&} appears in @var{new},
+-it is replaced by @var{old}. A single backslash will quote
+-the @samp{&}. The final delimiter is optional if it is the last
+-character on the input line.
+-
+-@item &
+-Repeat the previous substitution.
+-
+-@item g
+-@itemx a
+-Cause changes to be applied over the entire event line. Used in
+-conjunction with @samp{s}, as in @code{gs/@var{old}/@var{new}/},
+-or with @samp{&}.
+-
+-@item G
+-Apply the following @samp{s} modifier once to each word in the event.
+-
+-@end table
+Index: gdb-7.2.90.20110703/readline/doc/readline.3
+===================================================================
+--- gdb-7.2.90.20110703.orig/readline/doc/readline.3 2011-07-03 10:40:53.000000000 +0200
++++ gdb-7.2.90.20110703/readline/doc/readline.3 2011-07-03 10:41:21.000000000 +0200
+@@ -6,9 +6,9 @@
+ .\" Case Western Reserve University
+ .\" chet@ins.CWRU.Edu
+ .\"
+-.\" Last Change: Tue Sep 13 12:07:26 EDT 2005
++.\" Last Change: Sat Aug 28 18:56:32 EDT 2010
+ .\"
+-.TH READLINE 3 "2005 Sep 13" "GNU Readline 5.1-beta1"
++.TH READLINE 3 "2010 August 28" "GNU Readline 6.2"
+ .\"
+ .\" File Name macro. This used to be `.PN', for Path Name,
+ .\" but Sun doesn't seem to like that very much.
+@@ -34,8 +34,8 @@ readline \- get a line from a user with
+ \fBreadline\fP (\fIconst char *prompt\fP);
+ .fi
+ .SH COPYRIGHT
+-.if n Readline is Copyright (C) 1989\-2004 by the Free Software Foundation, Inc.
+-.if t Readline is Copyright \(co 1989\-2004 by the Free Software Foundation, Inc.
++.if n Readline is Copyright (C) 1989\-2011 Free Software Foundation, Inc.
++.if t Readline is Copyright \(co 1989\-2011 Free Software Foundation, Inc.
+ .SH DESCRIPTION
+ .LP
+ .B readline
+@@ -76,7 +76,7 @@ is read with a non\-empty line, it is
+ treated as a newline.
+ .SH NOTATION
+ .LP
+-An emacs-style notation is used to denote
++An Emacs-style notation is used to denote
+ keystrokes. Control keys are denoted by C\-\fIkey\fR, e.g., C\-n
+ means Control\-N. Similarly,
+ .I meta
+@@ -116,6 +116,8 @@ The name of this file is taken from the
+ .B INPUTRC
+ environment variable. If that variable is unset, the default is
+ .IR ~/.inputrc .
++If that file does not exist or cannot be read, the ultimate default is
++.IR /etc/inputrc .
+ When a program which uses the readline library starts up, the
+ init file is read, and the key bindings and variables are set.
+ There are only a few basic constructs allowed in the
+@@ -168,6 +170,8 @@ command or the text of a macro and a key
+ it should be bound. The name may be specified in one of two ways:
+ as a symbolic key name, possibly with \fIMeta\-\fP or \fIControl\-\fP
+ prefixes, or as a key sequence.
++The name and key sequence are separated by a colon. There can be no
++whitespace between the name and the colon.
+ .PP
+ When using the form \fBkeyname\fP:\^\fIfunction-name\fP or \fImacro\fP,
+ .I keyname
+@@ -356,11 +360,30 @@ This command is bound to
+ in emacs mode and to
+ .B #
+ in vi command mode.
++.TP
++.B completion\-display\-width (-1)
++The number of screen columns used to display possible matches
++when performing completion.
++The value is ignored if it is less than 0 or greater than the terminal
++screen width.
++A value of 0 will cause matches to be displayed one per line.
++The default value is -1.
+ .TP
+ .B completion\-ignore\-case (Off)
+ If set to \fBOn\fP, readline performs filename matching and completion
+ in a case\-insensitive fashion.
+ .TP
++.B completion\-map\-case (Off)
++If set to \fBOn\fP, and \fBcompletion\-ignore\-case\fP is enabled, readline
++treats hyphens (\fI\-\fP) and underscores (\fI_\fP) as equivalent when
++performing case\-insensitive filename matching and completion.
++.TP
++.B completion\-prefix\-display\-length (0)
++The length in characters of the common prefix of a list of possible
++completions that is displayed without modification. When set to a
++value greater than zero, common prefixes longer than this value are
++replaced with an ellipsis when displaying possible completions.
++.TP
+ .B completion\-query\-items (100)
+ This determines when the user is queried about viewing
+ the number of possible completions
+@@ -384,27 +407,41 @@ mapped to \fBself-insert\fP.
+ .TP
+ .B editing\-mode (emacs)
+ Controls whether readline begins with a set of key bindings similar
+-to emacs or vi.
++to \fIEmacs\fP or \fIvi\fP.
+ .B editing\-mode
+ can be set to either
+ .B emacs
+ or
+ .BR vi .
+ .TP
++.B echo\-control\-characters (On)
++When set to \fBOn\fP, on operating systems that indicate they support it,
++readline echoes a character corresponding to a signal generated from the
++keyboard.
++.TP
+ .B enable\-keypad (Off)
+ When set to \fBOn\fP, readline will try to enable the application
+ keypad when it is called. Some systems need this to enable the
+ arrow keys.
+ .TP
++.B enable\-meta\-key (On)
++When set to \fBOn\fP, readline will try to enable any meta modifier
++key the terminal claims to support when it is called. On many terminals,
++the meta key is used to send eight-bit characters.
++.TP
+ .B expand\-tilde (Off)
+-If set to \fBon\fP, tilde expansion is performed when readline
++If set to \fBOn\fP, tilde expansion is performed when readline
+ attempts word completion.
+ .TP
+ .B history\-preserve\-point (Off)
+-If set to \fBon\fP, the history code attempts to place point at the
++If set to \fBOn\fP, the history code attempts to place point at the
+ same location on each history line retrieved with \fBprevious-history\fP
+ or \fBnext-history\fP.
+ .TP
++.B history\-size (0)
++Set the maximum number of history entries saved in the history list. If
++set to zero, the number of entries in the history list is not limited.
++.TP
+ .B horizontal\-scroll\-mode (Off)
+ When set to \fBOn\fP, makes readline use a single line for display,
+ scrolling the input horizontally on a single screen line when it
+@@ -451,9 +488,15 @@ have a slash appended (subject to the va
+ .B match\-hidden\-files (On)
+ This variable, when set to \fBOn\fP, causes readline to match files whose
+ names begin with a `.' (hidden files) when performing filename
+-completion, unless the leading `.' is
++completion.
++If set to \fBOff\fP, the leading `.' must be
+ supplied by the user in the filename to be completed.
+ .TP
++.B menu\-complete\-display\-prefix (Off)
++If set to \fBOn\fP, menu completion displays the common prefix of the
++list of possible completions (which may be empty) before cycling through
++the list.
++.TP
+ .B output\-meta (Off)
+ If set to \fBOn\fP, readline will display characters with the
+ eighth bit set directly rather than as a meta-prefixed escape
+@@ -467,10 +510,16 @@ to display a screenful of possible compl
+ If set to \fBOn\fP, readline will display completions with matches
+ sorted horizontally in alphabetical order, rather than down the screen.
+ .TP
++.B revert\-all\-at\-newline (Off)
++If set to \fBOn\fP, readline will undo all changes to history lines
++before returning when \fBaccept\-line\fP is executed. By default,
++history lines may be modified and retain individual undo lists across
++calls to \fBreadline\fP.
++.TP
+ .B show\-all\-if\-ambiguous (Off)
+ This alters the default behavior of the completion functions. If
+ set to
+-.BR on ,
++.BR On ,
+ words which have more than one possible completion cause the
+ matches to be listed immediately instead of ringing the bell.
+ .TP
+@@ -478,12 +527,20 @@ matches to be listed immediately instead
+ This alters the default behavior of the completion functions in
+ a fashion similar to \fBshow\-all\-if\-ambiguous\fP.
+ If set to
+-.BR on ,
++.BR On ,
+ words which have more than one possible completion without any
+ possible partial completion (the possible completions don't share
+ a common prefix) cause the matches to be listed immediately instead
+ of ringing the bell.
+ .TP
++.B skip\-completed\-text (Off)
++If set to \fBOn\fP, this alters the default completion behavior when
++inserting a single match into the line. It's only active when
++performing completion in the middle of a word. If enabled, readline
++does not insert characters from the completion that match characters
++after point in the word being completed, so portions of the word
++following the cursor are not duplicated.
++.TP
+ .B visible\-stats (Off)
+ If set to \fBOn\fP, a character denoting a file's type as reported
+ by \fIstat\fP(2) is appended to the filename when listing possible
+@@ -530,7 +587,7 @@ library sets the \fIapplication name\fP,
+ file can test for a particular value.
+ This could be used to bind key sequences to functions useful for
+ a specific program. For instance, the following command adds a
+-key sequence that quotes the current or previous word in Bash:
++key sequence that quotes the current or previous word in \fBbash\fP:
+ .sp 1
+ .RS
+ .nf
+@@ -706,10 +763,14 @@ as if the "!\fIn\fP" history expansion h
+ .B
+ yank\-last\-arg (M\-.\^, M\-_\^)
+ Insert the last argument to the previous command (the last word of
+-the previous history entry). With an argument,
+-behave exactly like \fByank\-nth\-arg\fP.
++the previous history entry).
++With a numeric argument, behave exactly like \fByank\-nth\-arg\fP.
+ Successive calls to \fByank\-last\-arg\fP move back through the history
+-list, inserting the last argument of each line in turn.
++list, inserting the last word (or the word specified by the argument to
++the first call) of each line in turn.
++Any numeric argument supplied to these successive calls determines
++the direction to move through the history. A negative argument switches
++the direction through the history (back or forward).
+ The history expansion facilities are used to extract the last argument,
+ as if the "!$" history expansion had been specified.
+ .PD
+@@ -884,6 +945,12 @@ only attempts filename completion under
+ .TP
+ .B possible\-completions (M\-?)
+ List the possible completions of the text before point.
++When displaying completions, readline sets the number of columns used
++for display to the value of \fBcompletion-display-width\fP, the value of
++the environment variable
++.SM
++.BR COLUMNS ,
++or the screen width, in that order.
+ .TP
+ .B insert\-completions (M\-*)
+ Insert all completions of the text before point
+@@ -904,6 +971,11 @@ through the list.
+ This command is intended to be bound to \fBTAB\fP, but is unbound
+ by default.
+ .TP
++.B menu\-complete\-backward
++Identical to \fBmenu\-complete\fP, but moves backward through the list
++of possible completions, as if \fBmenu\-complete\fP had been given a
++negative argument. This command is unbound by default.
++.TP
+ .B delete\-char\-or\-list
+ Deletes the character under the cursor if not at the beginning or
+ end of the line (like \fBdelete-char\fP).
+@@ -977,6 +1049,15 @@ character. A negative count searches fo
+ A character is read and point is moved to the previous occurrence of that
+ character. A negative count searches for subsequent occurrences.
+ .TP
++.B skip\-csi\-sequence
++Read enough characters to consume a multi-key sequence such as those
++defined for keys like Home and End. Such sequences begin with a
++Control Sequence Indicator (CSI), usually ESC\-[. If this sequence is
++bound to "\e[", keys producing such sequences will have no effect
++unless explicitly bound to a readline command, instead of inserting
++stray characters into the editing buffer. This is unbound by default,
++but usually bound to ESC\-[.
++.TP
+ .B insert\-comment (M\-#)
+ Without a numeric argument, the value of the readline
+ .B comment\-begin
+Index: gdb-7.2.90.20110703/readline/doc/rlman.texi
+===================================================================
+--- gdb-7.2.90.20110703.orig/readline/doc/rlman.texi 2011-07-03 10:40:53.000000000 +0200
++++ gdb-7.2.90.20110703/readline/doc/rlman.texi 2011-07-03 10:41:21.000000000 +0200
+@@ -4,7 +4,6 @@
+ @settitle GNU Readline Library
+ @comment %**end of header (This is for running Texinfo on a region.)
+ @synindex vr fn
+-@setchapternewpage odd
+
+ @include version.texi
+
+@@ -14,7 +13,7 @@ This manual describes the GNU Readline L
+ consistency of user interface across discrete programs which provide
+ a command line interface.
+
+-Copyright @copyright{} 1988-2004 Free Software Foundation, Inc.
++Copyright @copyright{} 1988--2011 Free Software Foundation, Inc.
+
+ Permission is granted to make and distribute verbatim copies of
+ this manual provided the copyright notice and this permission notice
+@@ -22,15 +21,16 @@ are preserved on all copies.
+
+ @quotation
+ Permission is granted to copy, distribute and/or modify this document
+-under the terms of the GNU Free Documentation License, Version 1.1 or
++under the terms of the GNU Free Documentation License, Version 1.3 or
+ any later version published by the Free Software Foundation; with no
+-Invariant Sections, with the Front-Cover texts being ``A GNU Manual,''
++Invariant Sections, with the Front-Cover texts being ``A GNU Manual'',
+ and with the Back-Cover Texts as in (a) below. A copy of the license is
+-included in the section entitled ``GNU Free Documentation License.''
++included in the section entitled ``GNU Free Documentation License''.
++
++(a) The FSF's Back-Cover Text is: You are free to copy and modify
++this GNU manual. Buying copies from GNU Press supports the FSF in
++developing GNU and promoting software freedom.''
+
+-(a) The FSF's Back-Cover Text is: ``You have freedom to copy and modify
+-this GNU Manual, like GNU software. Copies published by the Free
+-Software Foundation raise funds for GNU development.''
+ @end quotation
+ @end copying
+
+@@ -71,7 +71,7 @@ provide a command line interface.
+ @menu
+ * Command Line Editing:: GNU Readline User's Manual.
+ * Programming with GNU Readline:: GNU Readline Programmer's Manual.
+-* Copying This Manual:: Copying this manual.
++* GNU Free Documentation License:: License for copying this manual.
+ * Concept Index:: Index of concepts described in this manual.
+ * Function and Variable Index:: Index of externally visible functions
+ and variables.
+@@ -81,12 +81,8 @@ provide a command line interface.
+ @include rluser.texi
+ @include rltech.texi
+
+-@node Copying This Manual
+-@appendix Copying This Manual
+-
+-@menu
+-* GNU Free Documentation License:: License for copying this manual.
+-@end menu
++@node GNU Free Documentation License
++@appendix GNU Free Documentation License
+
+ @include fdl.texi
+
+Index: gdb-7.2.90.20110703/readline/doc/rltech.texi
+===================================================================
+--- gdb-7.2.90.20110703.orig/readline/doc/rltech.texi 2011-07-03 10:40:53.000000000 +0200
++++ gdb-7.2.90.20110703/readline/doc/rltech.texi 2011-07-03 10:41:21.000000000 +0200
+@@ -1,14 +1,13 @@
+ @comment %**start of header (This is for running Texinfo on a region.)
+ @setfilename rltech.info
+ @comment %**end of header (This is for running Texinfo on a region.)
+-@setchapternewpage odd
+
+ @ifinfo
+ This document describes the GNU Readline Library, a utility for aiding
+ in the consistency of user interface across discrete programs that need
+ to provide a command line interface.
+
+-Copyright (C) 1988-2005 Free Software Foundation, Inc.
++Copyright (C) 1988--2011 Free Software Foundation, Inc.
+
+ Permission is granted to make and distribute verbatim copies of
+ this manual provided the copyright notice and this permission notice
+@@ -351,6 +350,12 @@ The @code{rl_set_prompt()} function (@px
+ be used to modify the prompt string after calling @code{readline()}.
+ @end deftypevar
+
++@deftypevar {char *} rl_display_prompt
++The string displayed as the prompt. This is usually identical to
++@var{rl_prompt}, but may be changed temporarily by functions that
++use the prompt string as a message area, such as incremental search.
++@end deftypevar
++
+ @deftypevar int rl_already_prompted
+ If an application wishes to display the prompt itself, rather than have
+ Readline do it the first time @code{readline()} is called, it should set
+@@ -518,6 +523,20 @@ Readline is performing word completion.
+ Readline is currently executing the readline signal handler.
+ @item RL_STATE_UNDOING
+ Readline is performing an undo.
++@item RL_STATE_INPUTPENDING
++Readline has input pending due to a call to @code{rl_execute_next()}.
++@item RL_STATE_TTYCSAVED
++Readline has saved the values of the terminal's special characters.
++@item RL_STATE_CALLBACK
++Readline is currently using the alternate (callback) interface
++(@pxref{Alternate Interface}).
++@item RL_STATE_VIMOTION
++Readline is reading the argument to a vi-mode "motion" command.
++@item RL_STATE_MULTIKEY
++Readline is reading a multiple-keystroke command.
++@item RL_STATE_VICMDONCE
++Readline has entered vi command (movement) mode at least one time during
++the current call to @code{readline()}.
+ @item RL_STATE_DONE
+ Readline has read a key sequence bound to @code{accept-line}
+ and is about to return the line to the caller.
+@@ -603,7 +622,7 @@ Readline which keymap to use.
+ @deftypefun Keymap rl_make_bare_keymap (void)
+ Returns a new, empty keymap. The space for the keymap is allocated with
+ @code{malloc()}; the caller should free it by calling
+-@code{rl_discard_keymap()} when done.
++@code{rl_free_keymap()} when done.
+ @end deftypefun
+
+ @deftypefun Keymap rl_copy_keymap (Keymap map)
+@@ -617,7 +636,13 @@ the Meta digits bound to produce numeric
+ @end deftypefun
+
+ @deftypefun void rl_discard_keymap (Keymap keymap)
+-Free the storage associated with @var{keymap}.
++Free the storage associated with the data in @var{keymap}.
++The caller should free @var{keymap}.
++@end deftypefun
++
++@deftypefun void rl_free_keymap (Keymap keymap)
++Free all storage associated with @var{keymap}. This calls
++@code{rl_discard_keymap} to free subordindate keymaps and macros.
+ @end deftypefun
+
+ Readline has several internal keymaps. These functions allow you to
+@@ -793,7 +818,8 @@ Print the names of all bindable Readline
+ @deftypefun {const char **} rl_funmap_names (void)
+ Return a NULL terminated array of known function names. The array is
+ sorted. The array itself is allocated, but not the strings inside. You
+-should @code{free()} the array when you are done, but not the pointers.
++should free the array, but not the pointers, using @code{free} or
++@code{rl_free} when you are done.
+ @end deftypefun
+
+ @deftypefun int rl_add_funmap_entry (const char *name, rl_command_func_t *function)
+@@ -1033,8 +1059,10 @@ pending input has not already been read
+ @deftypefun int rl_set_keyboard_input_timeout (int u)
+ While waiting for keyboard input in @code{rl_read_key()}, Readline will
+ wait for @var{u} microseconds for input before calling any function
+-assigned to @code{rl_event_hook}. The default waiting period is
+-one-tenth of a second. Returns the old timeout value.
++assigned to @code{rl_event_hook}. @var{u} must be greater than or equal
++to zero (a zero-length timeout is equivalent to a poll).
++The default waiting period is one-tenth of a second.
++Returns the old timeout value.
+ @end deftypefun
+
+ @node Terminal Management
+@@ -1075,6 +1103,26 @@ environment variable is used.
+ @node Utility Functions
+ @subsection Utility Functions
+
++@deftypefun int rl_save_state (struct readline_state *sp)
++Save a snapshot of Readline's internal state to @var{sp}.
++The contents of the @var{readline_state} structure are documented
++in @file{readline.h}.
++The caller is responsible for allocating the structure.
++@end deftypefun
++
++@deftypefun int rl_restore_state (struct readline_state *sp)
++Restore Readline's internal state to that stored in @var{sp}, which must
++have been saved by a call to @code{rl_save_state}.
++The contents of the @var{readline_state} structure are documented
++in @file{readline.h}.
++The caller is responsible for freeing the structure.
++@end deftypefun
++
++@deftypefun void rl_free (void *mem)
++Deallocate the memory pointed to by @var{mem}. @var{mem} must have been
++allocated by @code{malloc}.
++@end deftypefun
++
+ @deftypefun void rl_replace_line (const char *text, int clear_undo)
+ Replace the contents of @code{rl_line_buffer} with @var{text}.
+ The point and mark are preserved, if possible.
+@@ -1082,7 +1130,7 @@ If @var{clear_undo} is non-zero, the und
+ current line is cleared.
+ @end deftypefun
+
+-@deftypefun int rl_extend_line_buffer (int len)
++@deftypefun void rl_extend_line_buffer (int len)
+ Ensure that @code{rl_line_buffer} has enough space to hold @var{len}
+ characters, possibly reallocating it if necessary.
+ @end deftypefun
+@@ -1109,6 +1157,9 @@ of strings, in argv format, such as a li
+ is the length of the longest string in @code{matches}. This function uses
+ the setting of @code{print-completions-horizontally} to select how the
+ matches are displayed (@pxref{Readline Init File Syntax}).
++When displaying completions, this function sets the number of columns used
++for display to the value of @code{completion-display-width}, the value of
++the environment variable @env{COLUMNS}, or the screen width, in that order.
+ @end deftypefun
+
+ The following are implemented as macros, defined in @code{chardefs.h}.
+@@ -1392,6 +1443,13 @@ call @code{rl_resize_terminal()} or @cod
+ Readline to update its idea of the terminal size when a @code{SIGWINCH}
+ is received.
+
++@deftypefun void rl_echo_signal_char (int sig)
++If an application wishes to install its own signal handlers, but still
++have readline display characters that generate signals, calling this
++function with @var{sig} set to @code{SIGINT}, @code{SIGQUIT}, or
++@code{SIGTSTP} will display the character generating that signal.
++@end deftypefun
++
+ @deftypefun void rl_resize_terminal (void)
+ Update Readline's internal screen size by reading values from the kernel.
+ @end deftypefun
+@@ -1659,15 +1717,49 @@ from the array must be freed.
+
+ @deftypevar {rl_icppfunc_t *} rl_directory_completion_hook
+ This function, if defined, is allowed to modify the directory portion
+-of filenames Readline completes. It is called with the address of a
+-string (the current directory name) as an argument, and may modify that string.
++of filenames Readline completes.
++It could be used to expand symbolic links or shell variables in pathnames.
++It is called with the address of a string (the current directory name) as an
++argument, and may modify that string.
+ If the string is replaced with a new string, the old value should be freed.
+ Any modified directory name should have a trailing slash.
+-The modified value will be displayed as part of the completion, replacing
++The modified value will be used as part of the completion, replacing
+ the directory portion of the pathname the user typed.
+-It returns an integer that should be non-zero if the function modifies
+-its directory argument.
+-It could be used to expand symbolic links or shell variables in pathnames.
++At the least, even if no other expansion is performed, this function should
++remove any quote characters from the directory name, because its result will
++be passed directly to @code{opendir()}.
++The directory completion hook returns an integer that should be non-zero if
++the function modifies its directory argument.
++The function should not modify the directory argument if it returns 0.
++@end deftypevar
++
++@ignore
++@deftypevar extern rl_icppfunc_t *rl_directory_rewrite_hook;
++If non-zero, this is the address of a function to call when completing
++a directory name. This function takes the address of the directory name
++to be modified as an argument. Unlike @code{rl_directory_completion_hook},
++it only modifies the directory name used in @code{opendir}, not what is
++displayed when the possible completions are printed or inserted. It is
++called before rl_directory_completion_hook.
++
++I'm not happy with how this works yet, so it's undocumented.
++@end deftypevar
++@end ignore
++
++@deftypevar {rl_dequote_func_t *} rl_filename_rewrite_hook
++If non-zero, this is the address of a function called when reading
++directory entries from the filesystem for completion and comparing
++them to the partial word to be completed. The function should
++perform any necesary application or system-specific conversion on
++the filename, such as converting between character sets or converting
++from a filesystem format to a character input format.
++The function takes two arguments: @var{fname}, the filename to be converted,
++and @var{fnlen}, its length in bytes.
++It must either return its first argument (if no conversion takes place)
++or the converted filename in newly-allocated memory. The converted
++form is used to compare against the word to be completed, and, if it
++matches, is added to the list of matches. Readline will free the
++allocated string.
+ @end deftypevar
+
+ @deftypevar {rl_compdisp_func_t *} rl_completion_display_matches_hook
+@@ -1822,6 +1914,15 @@ if the application's completion function
+ It should be set only by an application's completion function.
+ @end deftypevar
+
++@deftypevar int rl_sort_completion_matches
++If an application sets this variable to 0, Readline will not sort the
++list of completions (which implies that it cannot remove any duplicate
++completions). The default value is 1, which means that Readline will
++sort the completions and, depending on the value of
++@code{rl_ignore_completion_duplicates}, will attempt to remove duplicate
++matches.
++@end deftypevar
++
+ @deftypevar int rl_completion_type
+ Set to a character describing the type of completion Readline is currently
+ attempting; see the description of @code{rl_complete_internal()}
+@@ -1831,6 +1932,13 @@ completion function is called, allowing
+ the same interface as @code{rl_complete()}.
+ @end deftypevar
+
++@deftypevar int rl_completion_invoking_key
++Set to the final character in the key sequence that invoked one of the
++completion functions that call @code{rl_complete_internal()}. This is
++set to the appropriate value before any application-specific completion
++function is called.
++@end deftypevar
++
+ @deftypevar int rl_inhibit_completion
+ If this variable is non-zero, completion is inhibited. The completion
+ character will be inserted as any other bound to @code{self-insert}.
+@@ -1851,27 +1959,51 @@ history list.
+ GNU Readline library. This application interactively allows users
+ to manipulate files and their modes. */
+
+-#include <stdio.h>
++#ifdef HAVE_CONFIG_H
++# include <config.h>
++#endif
++
+ #include <sys/types.h>
+-#include <sys/file.h>
++#ifdef HAVE_SYS_FILE_H
++# include <sys/file.h>
++#endif
+ #include <sys/stat.h>
+-#include <sys/errno.h>
++
++#ifdef HAVE_UNISTD_H
++# include <unistd.h>
++#endif
++
++#include <fcntl.h>
++#include <stdio.h>
++#include <errno.h>
++
++#if defined (HAVE_STRING_H)
++# include <string.h>
++#else /* !HAVE_STRING_H */
++# include <strings.h>
++#endif /* !HAVE_STRING_H */
++
++#ifdef HAVE_STDLIB_H
++# include <stdlib.h>
++#endif
++
++#include <time.h>
+
+ #include <readline/readline.h>
+ #include <readline/history.h>
+
+-extern char *xmalloc ();
++extern char *xmalloc PARAMS((size_t));
+
+ /* The names of functions that actually do the manipulation. */
+-int com_list __P((char *));
+-int com_view __P((char *));
+-int com_rename __P((char *));
+-int com_stat __P((char *));
+-int com_pwd __P((char *));
+-int com_delete __P((char *));
+-int com_help __P((char *));
+-int com_cd __P((char *));
+-int com_quit __P((char *));
++int com_list PARAMS((char *));
++int com_view PARAMS((char *));
++int com_rename PARAMS((char *));
++int com_stat PARAMS((char *));
++int com_pwd PARAMS((char *));
++int com_delete PARAMS((char *));
++int com_help PARAMS((char *));
++int com_cd PARAMS((char *));
++int com_quit PARAMS((char *));
+
+ /* A structure which contains information on the commands this program
+ can understand. */
+@@ -1904,12 +2036,12 @@ COMMAND *find_command ();
+ /* The name of this program, as taken from argv[0]. */
+ char *progname;
+
+-/* When non-zero, this means the user is done using this program. */
++/* When non-zero, this global means the user is done using this program. */
+ int done;
+
+ char *
+ dupstr (s)
+- int s;
++ char *s;
+ @{
+ char *r;
+
+@@ -2034,12 +2166,12 @@ stripwhite (string)
+ /* */
+ /* **************************************************************** */
+
+-char *command_generator __P((const char *, int));
+-char **fileman_completion __P((const char *, int, int));
++char *command_generator PARAMS((const char *, int));
++char **fileman_completion PARAMS((const char *, int, int));
+
+-/* Tell the GNU Readline library how to complete. We want to try to
+- complete on command names if this is the first word in the line, or
+- on filenames if not. */
++/* Tell the GNU Readline library how to complete. We want to try to complete
++ on command names if this is the first word in the line, or on filenames
++ if not. */
+ initialize_readline ()
+ @{
+ /* Allow conditional parsing of the ~/.inputrc file. */
+@@ -2049,11 +2181,11 @@ initialize_readline ()
+ rl_attempted_completion_function = fileman_completion;
+ @}
+
+-/* Attempt to complete on the contents of TEXT. START and END
+- bound the region of rl_line_buffer that contains the word to
+- complete. TEXT is the word to complete. We can use the entire
+- contents of rl_line_buffer in case we want to do some simple
+- parsing. Returnthe array of matches, or NULL if there aren't any. */
++/* Attempt to complete on the contents of TEXT. START and END bound the
++ region of rl_line_buffer that contains the word to complete. TEXT is
++ the word to complete. We can use the entire contents of rl_line_buffer
++ in case we want to do some simple parsing. Return the array of matches,
++ or NULL if there aren't any. */
+ char **
+ fileman_completion (text, start, end)
+ const char *text;
+@@ -2072,9 +2204,9 @@ fileman_completion (text, start, end)
+ return (matches);
+ @}
+
+-/* Generator function for command completion. STATE lets us
+- know whether to start from scratch; without any state
+- (i.e. STATE == 0), then we start at the top of the list. */
++/* Generator function for command completion. STATE lets us know whether
++ to start from scratch; without any state (i.e. STATE == 0), then we
++ start at the top of the list. */
+ char *
+ command_generator (text, state)
+ const char *text;
+@@ -2083,17 +2215,16 @@ command_generator (text, state)
+ static int list_index, len;
+ char *name;
+
+- /* If this is a new word to complete, initialize now. This
+- includes saving the length of TEXT for efficiency, and
+- initializing the index variable to 0. */
++ /* If this is a new word to complete, initialize now. This includes
++ saving the length of TEXT for efficiency, and initializing the index
++ variable to 0. */
+ if (!state)
+ @{
+ list_index = 0;
+ len = strlen (text);
+ @}
+
+- /* Return the next name which partially matches from the
+- command list. */
++ /* Return the next name which partially matches from the command list. */
+ while (name = commands[list_index].name)
+ @{
+ list_index++;
+@@ -2133,7 +2264,12 @@ com_view (arg)
+ if (!valid_argument ("view", arg))
+ return 1;
+
++#if defined (__MSDOS__)
++ /* more.com doesn't grok slashes in pathnames */
++ sprintf (syscom, "less %s", arg);
++#else
+ sprintf (syscom, "more %s", arg);
++#endif
+ return (system (syscom));
+ @}
+
+@@ -2160,7 +2296,8 @@ com_stat (arg)
+
+ printf ("Statistics for `%s':\n", arg);
+
+- printf ("%s has %d link%s, and is %d byte%s in length.\n", arg,
++ printf ("%s has %d link%s, and is %d byte%s in length.\n",
++ arg,
+ finfo.st_nlink,
+ (finfo.st_nlink == 1) ? "" : "s",
+ finfo.st_size,
+@@ -2249,8 +2386,7 @@ com_pwd (ignore)
+ return 0;
+ @}
+
+-/* The user wishes to quit using this program. Just set DONE
+- non-zero. */
++/* The user wishes to quit using this program. Just set DONE non-zero. */
+ com_quit (arg)
+ char *arg;
+ @{
+@@ -2263,13 +2399,12 @@ too_dangerous (caller)
+ char *caller;
+ @{
+ fprintf (stderr,
+- "%s: Too dangerous for me to distribute.\n",
++ "%s: Too dangerous for me to distribute. Write it yourself.\n",
+ caller);
+- fprintf (stderr, "Write it yourself.\n");
+ @}
+
+-/* Return non-zero if ARG is a valid argument for CALLER,
+- else print an error message and return zero. */
++/* Return non-zero if ARG is a valid argument for CALLER, else print
++ an error message and return zero. */
+ int
+ valid_argument (caller, arg)
+ char *caller, *arg;
+Index: gdb-7.2.90.20110703/readline/doc/rluser.texi
+===================================================================
+--- gdb-7.2.90.20110703.orig/readline/doc/rluser.texi 2011-07-03 10:40:53.000000000 +0200
++++ gdb-7.2.90.20110703/readline/doc/rluser.texi 2011-07-03 10:41:21.000000000 +0200
+@@ -1,7 +1,6 @@
+ @comment %**start of header (This is for running Texinfo on a region.)
+ @setfilename rluser.info
+ @comment %**end of header (This is for running Texinfo on a region.)
+-@setchapternewpage odd
+
+ @ignore
+ This file documents the end user interface to the GNU command line
+@@ -10,7 +9,7 @@ use these features. There is a document
+ which contains both end-user and programmer documentation for the
+ GNU Readline Library.
+
+-Copyright (C) 1988-2005 Free Software Foundation, Inc.
++Copyright (C) 1988--2011 Free Software Foundation, Inc.
+
+ Authored by Brian Fox and Chet Ramey.
+
+@@ -48,6 +47,16 @@ command line editing interface.
+ @ifset BashFeatures
+ Command line editing is provided by the Readline library, which is
+ used by several different programs, including Bash.
++Command line editing is enabled by default when using an interactive shell,
++unless the @option{--noediting} option is supplied at shell invocation.
++Line editing is also used when using the @option{-e} option to the
++@code{read} builtin command (@pxref{Bash Builtins}).
++By default, the line editing commands are similar to those of Emacs.
++A vi-style line editing interface is also available.
++Line editing can be enabled at any time using the @option{-o emacs} or
++@option{-o vi} options to the @code{set} builtin command
++(@pxref{The Set Builtin}), or disabled using the @option{+o emacs} or
++@option{+o vi} options to @code{set}.
+ @end ifset
+
+ @menu
+@@ -336,7 +345,9 @@ file is taken from the value of the shel
+ @ifclear BashFeatures
+ file is taken from the value of the environment variable @env{INPUTRC}. If
+ @end ifclear
+-that variable is unset, the default is @file{~/.inputrc}.
++that variable is unset, the default is @file{~/.inputrc}. If that
++file does not exist or cannot be read, the ultimate default is
++@file{/etc/inputrc}.
+
+ When a program which uses the Readline library starts up, the
+ init file is read, and the key bindings are set.
+@@ -420,11 +431,34 @@ The string to insert at the beginning of
+ @code{insert-comment} command is executed. The default value
+ is @code{"#"}.
+
++@item completion-display-width
++@vindex completion-display-width
++The number of screen columns used to display possible matches
++when performing completion.
++The value is ignored if it is less than 0 or greater than the terminal
++screen width.
++A value of 0 will cause matches to be displayed one per line.
++The default value is -1.
++
+ @item completion-ignore-case
++@vindex completion-ignore-case
+ If set to @samp{on}, Readline performs filename matching and completion
+ in a case-insensitive fashion.
+ The default value is @samp{off}.
+
++@item completion-map-case
++@vindex completion-map-case
++If set to @samp{on}, and @var{completion-ignore-case} is enabled, Readline
++treats hyphens (@samp{-}) and underscores (@samp{_}) as equivalent when
++performing case-insensitive filename matching and completion.
++
++@item completion-prefix-display-length
++@vindex completion-prefix-display-length
++The length in characters of the common prefix of a list of possible
++completions that is displayed without modification. When set to a
++value greater than zero, common prefixes longer than this value are
++replaced with an ellipsis when displaying possible completions.
++
+ @item completion-query-items
+ @vindex completion-query-items
+ The number of possible completions that determines when the user is
+@@ -456,12 +490,23 @@ key bindings is used. By default, Readl
+ mode, where the keystrokes are most similar to Emacs. This variable can be
+ set to either @samp{emacs} or @samp{vi}.
+
++@item echo-control-characters
++When set to @samp{on}, on operating systems that indicate they support it,
++readline echoes a character corresponding to a signal generated from the
++keyboard. The default is @samp{on}.
++
+ @item enable-keypad
+ @vindex enable-keypad
+ When set to @samp{on}, Readline will try to enable the application
+ keypad when it is called. Some systems need this to enable the
+ arrow keys. The default is @samp{off}.
+
++@item enable-meta-key
++When set to @samp{on}, Readline will try to enable any meta modifier
++key the terminal claims to support when it is called. On many terminals,
++the meta key is used to send eight-bit characters.
++The default is @samp{on}.
++
+ @item expand-tilde
+ @vindex expand-tilde
+ If set to @samp{on}, tilde expansion is performed when Readline
+@@ -469,10 +514,16 @@ attempts word completion. The default i
+
+ @item history-preserve-point
+ @vindex history-preserve-point
+-If set to @samp{on}, the history code attempts to place point at the
++If set to @samp{on}, the history code attempts to place the point (the
++current cursor position) at the
+ same location on each history line retrieved with @code{previous-history}
+ or @code{next-history}. The default is @samp{off}.
+
++@item history-size
++@vindex history-size
++Set the maximum number of history entries saved in the history list. If
++set to zero, the number of entries in the history list is not limited.
++
+ @item horizontal-scroll-mode
+ @vindex horizontal-scroll-mode
+ This variable can be set to either @samp{on} or @samp{off}. Setting it
+@@ -535,10 +586,17 @@ The default is @samp{off}.
+ @vindex match-hidden-files
+ This variable, when set to @samp{on}, causes Readline to match files whose
+ names begin with a @samp{.} (hidden files) when performing filename
+-completion, unless the leading @samp{.} is
++completion.
++If set to @samp{off}, the leading @samp{.} must be
+ supplied by the user in the filename to be completed.
+ This variable is @samp{on} by default.
+
++@item menu-complete-display-prefix
++@vindex menu-complete-display-prefix
++If set to @samp{on}, menu completion displays the common prefix of the
++list of possible completions (which may be empty) before cycling through
++the list. The default is @samp{off}.
++
+ @item output-meta
+ @vindex output-meta
+ If set to @samp{on}, Readline will display characters with the
+@@ -556,6 +614,13 @@ If set to @samp{on}, Readline will displ
+ sorted horizontally in alphabetical order, rather than down the screen.
+ The default is @samp{off}.
+
++@item revert-all-at-newline
++@vindex revert-all-at-newline
++If set to @samp{on}, Readline will undo all changes to history lines
++before returning when @code{accept-line} is executed. By default,
++history lines may be modified and retain individual undo lists across
++calls to @code{readline}. The default is @samp{off}.
++
+ @item show-all-if-ambiguous
+ @vindex show-all-if-ambiguous
+ This alters the default behavior of the completion functions. If
+@@ -575,6 +640,20 @@ a common prefix) cause the matches to be
+ of ringing the bell.
+ The default value is @samp{off}.
+
++@item skip-completed-text
++@vindex skip-completed-text
++If set to @samp{on}, this alters the default completion behavior when
++inserting a single match into the line. It's only active when
++performing completion in the middle of a word. If enabled, readline
++does not insert characters from the completion that match characters
++after point in the word being completed, so portions of the word
++following the cursor are not duplicated.
++For instance, if this is enabled, attempting completion when the cursor
++is after the @samp{e} in @samp{Makefile} will result in @samp{Makefile}
++rather than @samp{Makefilefile}, assuming there is a single possible
++completion.
++The default value is @samp{off}.
++
+ @item visible-stats
+ @vindex visible-stats
+ If set to @samp{on}, a character denoting a file's type
+@@ -593,9 +672,11 @@ the command does.
+ Once you know the name of the command, simply place on a line
+ in the init file the name of the key
+ you wish to bind the command to, a colon, and then the name of the
+-command. The name of the key
+-can be expressed in different ways, depending on what you find most
+-comfortable.
++command.
++There can be no space between the key name and the colon -- that will be
++interpreted as part of the key name.
++The name of the key can be expressed in different ways, depending on
++what you find most comfortable.
+
+ In addition to command names, readline allows keys to be bound
+ to a string that is inserted when the key is pressed (a @var{macro}).
+@@ -937,12 +1018,22 @@ Move forward a character.
+ Move back a character.
+
+ @item forward-word (M-f)
+-Move forward to the end of the next word. Words are composed of
+-letters and digits.
++Move forward to the end of the next word.
++Words are composed of letters and digits.
+
+ @item backward-word (M-b)
+-Move back to the start of the current or previous word. Words are
+-composed of letters and digits.
++Move back to the start of the current or previous word.
++Words are composed of letters and digits.
++
++@ifset BashFeatures
++@item shell-forward-word ()
++Move forward to the end of the next word.
++Words are delimited by non-quoted shell metacharacters.
++
++@item shell-backward-word ()
++Move back to the start of the current or previous word.
++Words are delimited by non-quoted shell metacharacters.
++@end ifset
+
+ @item clear-screen (C-l)
+ Clear the screen and redraw the current line,
+@@ -1029,10 +1120,14 @@ as if the @samp{!@var{n}} history expans
+
+ @item yank-last-arg (M-. or M-_)
+ Insert last argument to the previous command (the last word of the
+-previous history entry). With an
+-argument, behave exactly like @code{yank-nth-arg}.
++previous history entry).
++With a numeric argument, behave exactly like @code{yank-nth-arg}.
+ Successive calls to @code{yank-last-arg} move back through the history
+-list, inserting the last argument of each line in turn.
++list, inserting the last word (or the word specified by the argument to
++the first call) of each line in turn.
++Any numeric argument supplied to these successive calls determines
++the direction to move through the history. A negative argument switches
++the direction through the history (back or forward).
+ The history expansion facilities are used to extract the last argument,
+ as if the @samp{!$} history expansion had been specified.
+
+@@ -1138,6 +1233,17 @@ Word boundaries are the same as @code{fo
+ Kill the word behind point.
+ Word boundaries are the same as @code{backward-word}.
+
++@ifset BashFeatures
++@item shell-kill-word ()
++Kill from point to the end of the current word, or if between
++words, to the end of the next word.
++Word boundaries are the same as @code{shell-forward-word}.
++
++@item shell-backward-kill-word ()
++Kill the word behind point.
++Word boundaries are the same as @code{shell-backward-word}.
++@end ifset
++
+ @item unix-word-rubout (C-w)
+ Kill the word behind point, using white space as a word boundary.
+ The killed text is saved on the kill-ring.
+@@ -1219,6 +1325,9 @@ The default is filename completion.
+
+ @item possible-completions (M-?)
+ List the possible completions of the text before point.
++When displaying completions, Readline sets the number of columns used
++for display to the value of @code{completion-display-width}, the value of
++the environment variable @env{COLUMNS}, or the screen width, in that order.
+
+ @item insert-completions (M-*)
+ Insert all completions of the text before point that would have
+@@ -1238,6 +1347,11 @@ through the list.
+ This command is intended to be bound to @key{TAB}, but is unbound
+ by default.
+
++@item menu-complete-backward ()
++Identical to @code{menu-complete}, but moves backward through the list
++of possible completions, as if @code{menu-complete} had been given a
++negative argument.
++
+ @item delete-char-or-list ()
+ Deletes the character under the cursor if not at the beginning or
+ end of the line (like @code{delete-char}).
+@@ -1293,6 +1407,11 @@ Attempt completion on the text before po
+ the text against lines from the history list for possible
+ completion matches.
+
++@item dabbrev-expand ()
++Attempt menu completion on the text before point, comparing
++the text against lines from the history list for possible
++completion matches.
++
+ @item complete-into-braces (M-@{)
+ Perform filename completion and insert the list of possible completions
+ enclosed within braces so the list is available to the shell
+@@ -1372,6 +1491,15 @@ A character is read and point is moved t
+ of that character. A negative count searches for subsequent
+ occurrences.
+
++@item skip-csi-sequence ()
++Read enough characters to consume a multi-key sequence such as those
++defined for keys like Home and End. Such sequences begin with a
++Control Sequence Indicator (CSI), usually ESC-[. If this sequence is
++bound to "\e[", keys producing such sequences will have no effect
++unless explicitly bound to a readline command, instead of inserting
++stray characters into the editing buffer. This is unbound by default,
++but usually bound to ESC-[.
++
+ @item insert-comment (M-#)
+ Without a numeric argument, the value of the @code{comment-begin}
+ variable is inserted at the beginning of the current line.
+@@ -1481,7 +1609,7 @@ editing mode.
+ While the Readline library does not have a full set of @code{vi}
+ editing functions, it does contain enough to allow simple editing
+ of the line. The Readline @code{vi} mode behaves as specified in
+-the @sc{posix} 1003.2 standard.
++the @sc{posix} standard.
+
+ @ifset BashFeatures
+ In order to switch interactively between @code{emacs} and @code{vi}
+@@ -1515,10 +1643,15 @@ the programmable completion facilities a
+ First, the command name is identified.
+ If a compspec has been defined for that command, the
+ compspec is used to generate the list of possible completions for the word.
++If the command word is the empty string (completion attempted at the
++beginning of an empty line), any compspec defined with
++the @option{-E} option to @code{complete} is used.
+ If the command word is a full pathname, a compspec for the full
+ pathname is searched for first.
+ If no compspec is found for the full pathname, an attempt is made to
+ find a compspec for the portion following the final slash.
++If those searches do not result in a compspec, any compspec defined with
++the @option{-D} option to @code{complete} is used as the default.
+
+ Once a compspec has been found, it is used to generate the list of
+ matching words.
+@@ -1555,9 +1688,9 @@ completed, and the matching words become
+
+ After these matches have been generated, any shell function or command
+ specified with the @option{-F} and @option{-C} options is invoked.
+-When the command or function is invoked, the @env{COMP_LINE} and
+-@env{COMP_POINT} variables are assigned values as described above
+-(@pxref{Bash Variables}).
++When the command or function is invoked, the @env{COMP_LINE},
++@env{COMP_POINT}, @env{COMP_KEY}, and @env{COMP_TYPE} variables are
++assigned values as described above (@pxref{Bash Variables}).
+ If a shell function is being invoked, the @env{COMP_WORDS} and
+ @env{COMP_CWORD} variables are also set.
+ When the function or command is invoked, the first argument is the
+@@ -1570,7 +1703,7 @@ the matches.
+
+ Any function specified with @option{-F} is invoked first.
+ The function may use any of the shell facilities, including the
+-@code{compgen} builtin described below
++@code{compgen} and @code{compopt} builtins described below
+ (@pxref{Programmable Completion Builtins}), to generate the matches.
+ It must put the possible completions in the @env{COMPREPLY} array
+ variable.
+@@ -1622,6 +1755,30 @@ to completed names which are symbolic li
+ the value of the @var{mark-directories} Readline variable, regardless
+ of the setting of the @var{mark-symlinked-directories} Readline variable.
+
++There is some support for dynamically modifying completions. This is
++most useful when used in combination with a default completion specified
++with @option{-D}. It's possible for shell functions executed as completion
++handlers to indicate that completion should be retried by returning an
++exit status of 124. If a shell function returns 124, and changes
++the compspec associated with the command on which completion is being
++attempted (supplied as the first argument when the function is executed),
++programmable completion restarts from the beginning, with an
++attempt to find a new compspec for that command. This allows a set of
++completions to be built dynamically as completion is attempted, rather than
++being loaded all at once.
++
++For instance, assuming that there is a library of compspecs, each kept in a
++file corresponding to the name of the command, the following default
++completion function would load completions dynamically:
++
++@example
++_completion_loader()
++@{
++ . "/etc/bash_completion.d/$1.sh" >/dev/null 2>&1 && return 124
++@}
++complete -D -F _completion_loader
++@end example
++
+ @node Programmable Completion Builtins
+ @section Programmable Completion Builtins
+ @cindex completion builtins
+@@ -1657,10 +1814,10 @@ matches were generated.
+ @item complete
+ @btindex complete
+ @example
+-@code{complete [-abcdefgjksuv] [-o @var{comp-option}] [-A @var{action}] [-G @var{globpat}] [-W @var{wordlist}]
+-[-P @var{prefix}] [-S @var{suffix}] [-X @var{filterpat}] [-F @var{function}]
+-[-C @var{command}] @var{name} [@var{name} @dots{}]}
+-@code{complete -pr [@var{name} @dots{}]}
++@code{complete [-abcdefgjksuv] [-o @var{comp-option}] [-DE] [-A @var{action}] [-G @var{globpat}] [-W @var{wordlist}]
++[-F @var{function}] [-C @var{command}] [-X @var{filterpat}]
++[-P @var{prefix}] [-S @var{suffix}] @var{name} [@var{name} @dots{}]}
++@code{complete -pr [-DE] [@var{name} @dots{}]}
+ @end example
+
+ Specify how arguments to each @var{name} should be completed.
+@@ -1670,9 +1827,16 @@ reused as input.
+ The @option{-r} option removes a completion specification for
+ each @var{name}, or, if no @var{name}s are supplied, all
+ completion specifications.
++The @option{-D} option indicates that the remaining options and actions should
++apply to the ``default'' command completion; that is, completion attempted
++on a command for which no completion has previously been defined.
++The @option{-E} option indicates that the remaining options and actions should
++apply to ``empty'' command completion; that is, completion attempted on a
++blank line.
+
+ The process of applying these completion specifications when word completion
+-is attempted is described above (@pxref{Programmable Completion}).
++is attempted is described above (@pxref{Programmable Completion}). The
++@option{-D} option takes precedence over @option{-E}.
+
+ Other options, if specified, have the following meanings.
+ The arguments to the @option{-G}, @option{-W}, and @option{-X} options
+@@ -1702,9 +1866,10 @@ Perform directory name completion if the
+
+ @item filenames
+ Tell Readline that the compspec generates filenames, so it can perform any
+-filename-specific processing (like adding a slash to directory names or
+-suppressing trailing spaces). This option is intended to be used with
+-shell functions specified with @option{-F}.
++filename-specific processing (like adding a slash to directory names
++quoting special characters, or suppressing trailing spaces).
++This option is intended to be used with shell functions specified
++with @option{-F}.
+
+ @item nospace
+ Tell Readline not to append a space (the default) to words completed at
+@@ -1798,17 +1963,6 @@ User names. May also be specified as @o
+ Names of all shell variables. May also be specified as @option{-v}.
+ @end table
+
+-@item -G @var{globpat}
+-The filename expansion pattern @var{globpat} is expanded to generate
+-the possible completions.
+-
+-@item -W @var{wordlist}
+-The @var{wordlist} is split using the characters in the
+-@env{IFS} special variable as delimiters, and each resultant word
+-is expanded.
+-The possible completions are the members of the resultant list which
+-match the word being completed.
+-
+ @item -C @var{command}
+ @var{command} is executed in a subshell environment, and its output is
+ used as the possible completions.
+@@ -1819,13 +1973,9 @@ environment.
+ When it finishes, the possible completions are retrieved from the value
+ of the @env{COMPREPLY} array variable.
+
+-@item -X @var{filterpat}
+-@var{filterpat} is a pattern as used for filename expansion.
+-It is applied to the list of possible completions generated by the
+-preceding options and arguments, and each completion matching
+-@var{filterpat} is removed from the list.
+-A leading @samp{!} in @var{filterpat} negates the pattern; in this
+-case, any completion not matching @var{filterpat} is removed.
++@item -G @var{globpat}
++The filename expansion pattern @var{globpat} is expanded to generate
++the possible completions.
+
+ @item -P @var{prefix}
+ @var{prefix} is added at the beginning of each possible completion
+@@ -1834,6 +1984,21 @@ after all other options have been applie
+ @item -S @var{suffix}
+ @var{suffix} is appended to each possible completion
+ after all other options have been applied.
++
++@item -W @var{wordlist}
++The @var{wordlist} is split using the characters in the
++@env{IFS} special variable as delimiters, and each resultant word
++is expanded.
++The possible completions are the members of the resultant list which
++match the word being completed.
++
++@item -X @var{filterpat}
++@var{filterpat} is a pattern as used for filename expansion.
++It is applied to the list of possible completions generated by the
++preceding options and arguments, and each completion matching
++@var{filterpat} is removed from the list.
++A leading @samp{!} in @var{filterpat} negates the pattern; in this
++case, any completion not matching @var{filterpat} is removed.
+ @end table
+
+ The return value is true unless an invalid option is supplied, an option
+@@ -1842,5 +2007,31 @@ argument, an attempt is made to remove a
+ a @var{name} for which no specification exists, or
+ an error occurs adding a completion specification.
+
++@item compopt
++@btindex compopt
++@example
++@code{compopt} [-o @var{option}] [-DE] [+o @var{option}] [@var{name}]
++@end example
++Modify completion options for each @var{name} according to the
++@var{option}s, or for the currently-executing completion if no @var{name}s
++are supplied.
++If no @var{option}s are given, display the completion options for each
++@var{name} or the current completion.
++The possible values of @var{option} are those valid for the @code{complete}
++builtin described above.
++The @option{-D} option indicates that the remaining options should
++apply to the ``default'' command completion; that is, completion attempted
++on a command for which no completion has previously been defined.
++The @option{-E} option indicates that the remaining options should
++apply to ``empty'' command completion; that is, completion attempted on a
++blank line.
++
++The @option{-D} option takes precedence over @option{-E}.
++
++The return value is true unless an invalid option is supplied, an attempt
++is made to modify the options for a @var{name} for which no completion
++specification exists, or an output error occurs.
++
+ @end table
++
+ @end ifset
+Index: gdb-7.2.90.20110703/readline/doc/rluserman.texi
+===================================================================
+--- gdb-7.2.90.20110703.orig/readline/doc/rluserman.texi 2011-07-03 10:40:53.000000000 +0200
++++ gdb-7.2.90.20110703/readline/doc/rluserman.texi 2011-07-03 10:41:21.000000000 +0200
+@@ -4,8 +4,6 @@
+ @settitle GNU Readline Library
+ @comment %**end of header (This is for running Texinfo on a region.)
+
+-@setchapternewpage odd
+-
+ @include version.texi
+
+ @copying
+@@ -14,7 +12,7 @@ This manual describes the end user inter
+ consistency of user interface across discrete programs which provide
+ a command line interface.
+
+-Copyright @copyright{} 1988-2005 Free Software Foundation, Inc.
++Copyright @copyright{} 1988--2011 Free Software Foundation, Inc.
+
+ Permission is granted to make and distribute verbatim copies of
+ this manual provided the copyright notice and this permission notice
+@@ -22,15 +20,16 @@ are preserved on all copies.
+
+ @quotation
+ Permission is granted to copy, distribute and/or modify this document
+-under the terms of the GNU Free Documentation License, Version 1.1 or
++under the terms of the GNU Free Documentation License, Version 1.3 or
+ any later version published by the Free Software Foundation; with no
+-Invariant Sections, with the Front-Cover texts being ``A GNU Manual,''
++Invariant Sections, with the Front-Cover texts being ``A GNU Manual'',
+ and with the Back-Cover Texts as in (a) below. A copy of the license is
+-included in the section entitled ``GNU Free Documentation License.''
++included in the section entitled ``GNU Free Documentation License''.
++
++(a) The FSF's Back-Cover Text is: You are free to copy and modify
++this GNU manual. Buying copies from GNU Press supports the FSF in
++developing GNU and promoting software freedom.''
+
+-(a) The FSF's Back-Cover Text is: ``You have freedom to copy and modify
+-this GNU Manual, like GNU software. Copies published by the Free
+-Software Foundation raise funds for GNU development.''
+ @end quotation
+ @end copying
+
+@@ -70,18 +69,14 @@ programs which provide a command line in
+
+ @menu
+ * Command Line Editing:: GNU Readline User's Manual.
+-* Copying This Manual:: Copying This Manual.
++* GNU Free Documentation License:: License for copying this manual.
+ @end menu
+ @end ifnottex
+
+ @include rluser.texi
+
+-@node Copying This Manual
+-@appendix Copying This Manual
+-
+-@menu
+-* GNU Free Documentation License:: License for copying this manual.
+-@end menu
++@node GNU Free Documentation License
++@appendix GNU Free Documentation License
+
+ @include fdl.texi
+
+Index: gdb-7.2.90.20110703/readline/doc/texi2dvi
+===================================================================
+--- gdb-7.2.90.20110703.orig/readline/doc/texi2dvi 2011-07-03 10:40:53.000000000 +0200
++++ gdb-7.2.90.20110703/readline/doc/texi2dvi 2011-07-03 10:41:21.000000000 +0200
+@@ -5,20 +5,18 @@
+ # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2001,
+ # 2002, 2003 Free Software Foundation, Inc.
+ #
+-# This program is free software; you can redistribute it and/or modify
+-# it under the terms of the GNU General Public License as published by
+-# the Free Software Foundation; either version 2, or (at your option)
+-# any later version.
++# This program is free software: you can redistribute it and/or modify
++# it under the terms of the GNU General Public License as published by
++# the Free Software Foundation, either version 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.
++# 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, you can either send email to this
+-# program's maintainer or write to: The Free Software Foundation,
+-# Inc.; 59 Temple Place, Suite 330; Boston, MA 02111-1307, USA.
++# You should have received a copy of the GNU General Public License
++# along with this program. If not, see <http://www.gnu.org/licenses/>.
+ #
+ # Original author: Noah Friedman <friedman@gnu.org>.
+ #
+Index: gdb-7.2.90.20110703/readline/doc/texi2html
+===================================================================
+--- gdb-7.2.90.20110703.orig/readline/doc/texi2html 2011-07-03 10:40:53.000000000 +0200
++++ gdb-7.2.90.20110703/readline/doc/texi2html 2011-07-03 10:41:21.000000000 +0200
+@@ -7,20 +7,19 @@
+ #
+ # Copyright (C) 1999, 2000 Free Software Foundation, Inc.
+ #
+-# This program is free software; you can redistribute it and/or modify
+-# it under the terms of the GNU General Public License as published by
+-# the Free Software Foundation; either version 2 of the License, or
+-# (at your option) any later version.
+-#
+-# This program is distributed in the hope that it will be useful,
+-# but WITHOUT ANY WARRANTY; without even the implied warranty of
+-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+-# GNU General Public License for more details.
+-#
+-# You should have received a copy of the GNU General Public License
+-# along with this program; if not, write to the Free Software
+-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+-#
++# This program is free software: you can redistribute it and/or modify
++# it under the terms of the GNU General Public License as published by
++# the Free Software Foundation, either version 3 of the License, or
++# (at your option) any later version.
++#
++# This program is distributed in the hope that it will be useful,
++# but WITHOUT ANY WARRANTY; without even the implied warranty of
++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++# GNU General Public License for more details.
++#
++# You should have received a copy of the GNU General Public License
++# along with this program. If not, see <http://www.gnu.org/licenses/>.
++#
+ #-##############################################################################
+
+ # This requires perl version 5 or higher
+@@ -3564,7 +3563,7 @@ INPUT_LINE: while ($_ = &next_line) {
+ $name = &normalise_node($name);
+ $level = $sec2level{$tag};
+ # check for index
+- $first_index_chapter = $name
++ $first_index_chapter = $node
+ if ($level == 1 && !$first_index_chapter &&
+ $name =~ /index/i);
+ if ($in_top && /heading/){
+Index: gdb-7.2.90.20110703/readline/doc/version.texi
+===================================================================
+--- gdb-7.2.90.20110703.orig/readline/doc/version.texi 2011-07-03 10:40:53.000000000 +0200
++++ gdb-7.2.90.20110703/readline/doc/version.texi 2011-07-03 10:41:21.000000000 +0200
+@@ -1,10 +1,10 @@
+ @ignore
+-Copyright (C) 1988-2005 Free Software Foundation, Inc.
++Copyright (C) 1988-2011 Free Software Foundation, Inc.
+ @end ignore
+
+-@set EDITION 5.1-beta1
+-@set VERSION 5.1-beta1
+-@set UPDATED 11 November 2005
+-@set UPDATED-MONTH November 2005
++@set EDITION 6.2
++@set VERSION 6.2
++@set UPDATED September 6 2010
++@set UPDATED-MONTH September 2010
+
+-@set LASTCHANGE Fri Nov 11 19:50:51 EST 2005
++@set LASTCHANGE Mon Sep 6 22:07:10 EDT 2010
+Index: gdb-7.2.90.20110703/readline/emacs_keymap.c
+===================================================================
+--- gdb-7.2.90.20110703.orig/readline/emacs_keymap.c 2011-07-03 10:40:53.000000000 +0200
++++ gdb-7.2.90.20110703/readline/emacs_keymap.c 2011-07-03 10:41:21.000000000 +0200
+@@ -1,24 +1,23 @@
+ /* emacs_keymap.c -- the keymap for emacs_mode in readline (). */
+
+-/* Copyright (C) 1987, 1989, 1992 Free Software Foundation, Inc.
++/* Copyright (C) 1987-2009 Free Software Foundation, Inc.
+
+- This file is part of the GNU Readline Library, a library for
+- reading lines of text with interactive input and history editing.
++ This file is part of the GNU Readline Library (Readline), a library
++ for reading lines of text with interactive input and history editing.
+
+- The GNU Readline Library is free software; you can redistribute it
+- and/or modify it under the terms of the GNU General Public License
+- as published by the Free Software Foundation; either version 2, or
++ Readline 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.
+
+- The GNU Readline Library is distributed in the hope that it will be
+- useful, but WITHOUT ANY WARRANTY; without even the implied warranty
+- of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ Readline 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.
+
+- The GNU General Public License is often shipped with GNU software, and
+- is generally kept in a file called COPYING or LICENSE. If you do not
+- have a copy of the license, write to the Free Software Foundation,
+- 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
++ You should have received a copy of the GNU General Public License
++ along with Readline. If not, see <http://www.gnu.org/licenses/>.
++*/
+
+ #if !defined (BUFSIZ)
+ #include <stdio.h>
+Index: gdb-7.2.90.20110703/readline/examples/ChangeLog.gdb
+===================================================================
+--- gdb-7.2.90.20110703.orig/readline/examples/ChangeLog.gdb 2011-07-03 10:40:53.000000000 +0200
++++ gdb-7.2.90.20110703/readline/examples/ChangeLog.gdb 2011-07-03 10:41:21.000000000 +0200
+@@ -1,3 +1,7 @@
++2011-04-25 Jan Kratochvil <jan.kratochvil@redhat.com>
++
++ Imported readline 6.2, and upstream patch 001.
++
+ 2006-04-24 Daniel Jacobowitz <dan@codesourcery.com>
+
+ Imported readline 5.1, and upstream patches 001-004.
+Index: gdb-7.2.90.20110703/readline/examples/Inputrc
+===================================================================
+--- gdb-7.2.90.20110703.orig/readline/examples/Inputrc 2011-07-03 10:40:53.000000000 +0200
++++ gdb-7.2.90.20110703/readline/examples/Inputrc 2011-07-03 10:41:21.000000000 +0200
+@@ -4,21 +4,21 @@
+ # on which program is running, or what terminal is active.
+ #
+
+-# Copyright (C) 1989-2002 Free Software Foundation, Inc.
++# Copyright (C) 1989-2009 Free Software Foundation, Inc.
+ #
+-# This program is free software; you can redistribute it and/or modify
+-# it under the terms of the GNU General Public License as published by
+-# the Free Software Foundation; either version 2, or (at your option)
+-# any later version.
++# This program is free software: you can redistribute it and/or modify
++# it under the terms of the GNU General Public License as published by
++# the Free Software Foundation, either version 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.
++# This program is distributed in the hope that it will be useful,
++# but WITHOUT ANY WARRANTY; without even the implied warranty of
++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++# GNU General Public License for more details.
++#
++# You should have received a copy of the GNU General Public License
++# along with this program. If not, see <http://www.gnu.org/licenses/>.
+ #
+-# You should have received a copy of the GNU General Public License
+-# along with this program; if not, write to the Free Software
+-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA.
+
+ # In all programs, all terminals, make sure this is bound.
+ "\C-x\C-r": re-read-init-file
+Index: gdb-7.2.90.20110703/readline/examples/Makefile.in
+===================================================================
+--- gdb-7.2.90.20110703.orig/readline/examples/Makefile.in 2011-07-03 10:40:53.000000000 +0200
++++ gdb-7.2.90.20110703/readline/examples/Makefile.in 2011-07-03 10:41:21.000000000 +0200
+@@ -1,30 +1,46 @@
+ #
+ # This is the Makefile for the readline examples subdirectory.
+ #
+-# Copyright (C) 1994 Free Software Foundation, Inc.
++# Copyright (C) 1994,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 <http://www.gnu.org/licenses/>.
+
+-# This program is free software; you can redistribute it and/or modify
+-# it under the terms of the GNU General Public License as published by
+-# the Free Software Foundation; either version 2, or (at your option)
+-# any later version.
+-
+-# This program is distributed in the hope that it will be useful,
+-# but WITHOUT ANY WARRANTY; without even the implied warranty of
+-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+-# GNU General Public License for more details.
+-
+-# You should have received a copy of the GNU General Public License
+-# along with this program; if not, write to the Free Software
+-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA.
+ RL_LIBRARY_VERSION = @LIBVERSION@
+
+ SHELL = @MAKE_SHELL@
+ RM = rm -f
+
++prefix = @prefix@
++exec_prefix = @exec_prefix@
++
++datarootdir = @datarootdir@
++
++bindir = @bindir@
+ srcdir = @srcdir@
+-VPATH = .:@srcdir@
++datadir = @datadir@
++VPATH = @srcdir@
+ top_srcdir = @top_srcdir@
+-BUILD_DIR = .
++#BUILD_DIR = .
++BUILD_DIR = @BUILD_DIR@
++installdir = $(datadir)/readline
++
++INSTALL = @INSTALL@
++INSTALL_PROGRAM = @INSTALL_PROGRAM@
++INSTALL_DATA = @INSTALL_DATA@
++
++EXEEXT = @EXEEXT@
++OBJEXT = @OBJEXT@
+
+ # Support an alternate destination root directory for package building
+ DESTDIR =
+@@ -51,31 +67,56 @@ TERMCAP_LIB = @TERMCAP_LIB@
+ ${RM} $@
+ $(CC) $(CCFLAGS) -c $<
+
+-EXECUTABLES = fileman rltest rl rlcat rlversion histexamp
+-OBJECTS = fileman.o rltest.o rl.o rlcat.o rlversion.o histexamp.o
++SOURCES = excallback.c fileman.c histexamp.c manexamp.c rl-fgets.c rl.c \
++ rlcat.c rlevent.c rlptytest.c rltest.c rlversion.c
++
++EXECUTABLES = fileman$(EXEEXT) rltest$(EXEEXT) rl$(EXEEXT) rlcat$(EXEEXT) \
++ rlevent$(EXEEXT) rlversion$(EXEEXT) histexamp$(EXEEXT)
++OBJECTS = fileman.o rltest.o rl.o rlevent.o rlcat.o rlversion.o histexamp.o
+
+ all: $(EXECUTABLES)
+ everything: all
+
+-rl: rl.o $(READLINE_LIB)
++check: rlversion$(EXEEXT)
++ @echo Readline version: `rlversion$(EXEEXT)`
++
++installdirs:
++ -$(SHELL) $(top_srcdir)/support/mkdirs $(DESTDIR)$(installdir)
++
++install: installdirs
++ @for f in $(SOURCES); do \
++ $(RM) $(DESTDIR)$(installdir)/$$f ; \
++ $(INSTALL_DATA) $(srcdir)/$$f $(DESTDIR)$(installdir) ; \
++ done
++
++uninstall:
++ @for f in $(SOURCES); do \
++ $(RM) $(DESTDIR)$(installdir)/$$f ; \
++ done
++ -rmdir $(DESTDIR)$(installdir)
++
++rl$(EXEEXT): rl.o $(READLINE_LIB)
+ $(PURIFY) $(CC) $(LDFLAGS) -o $@ rl.o $(READLINE_LIB) $(TERMCAP_LIB)
+
+-rlcat: rlcat.o $(READLINE_LIB)
++rlcat$(EXEEXT): rlcat.o $(READLINE_LIB)
+ $(PURIFY) $(CC) $(LDFLAGS) -o $@ rlcat.o $(READLINE_LIB) $(TERMCAP_LIB)
+
+-fileman: fileman.o $(READLINE_LIB)
++rlevent$(EXEEXT): rlevent.o $(READLINE_LIB)
++ $(PURIFY) $(CC) $(LDFLAGS) -o $@ rlevent.o $(READLINE_LIB) $(TERMCAP_LIB)
++
++fileman$(EXEEXT): fileman.o $(READLINE_LIB)
+ $(PURIFY) $(CC) $(LDFLAGS) -o $@ fileman.o $(READLINE_LIB) $(TERMCAP_LIB)
+
+-rltest: rltest.o $(READLINE_LIB)
++rltest$(EXEEXT): rltest.o $(READLINE_LIB)
+ $(PURIFY) $(CC) $(LDFLAGS) -o $@ rltest.o $(READLINE_LIB) $(TERMCAP_LIB)
+
+-rlptytest: rlptytest.o $(READLINE_LIB)
++rlptytest$(EXEEXT): rlptytest.o $(READLINE_LIB)
+ $(PURIFY) $(CC) $(LDFLAGS) -o $@ rlptytest.o $(READLINE_LIB) $(TERMCAP_LIB)
+
+-rlversion: rlversion.o $(READLINE_LIB)
++rlversion$(EXEEXT): rlversion.o $(READLINE_LIB)
+ $(CC) $(LDFLAGS) -o $@ rlversion.o $(READLINE_LIB) $(TERMCAP_LIB)
+
+-histexamp: histexamp.o $(HISTORY_LIB)
++histexamp$(EXEEXT): histexamp.o $(HISTORY_LIB)
+ $(PURIFY) $(CC) $(LDFLAGS) -o $@ histexamp.o -lhistory $(TERMCAP_LIB)
+
+ clean mostlyclean:
+Index: gdb-7.2.90.20110703/readline/examples/autoconf/BASH_CHECK_LIB_TERMCAP
+===================================================================
+--- /dev/null 1970-01-01 00:00:00.000000000 +0000
++++ gdb-7.2.90.20110703/readline/examples/autoconf/BASH_CHECK_LIB_TERMCAP 2011-07-03 10:41:21.000000000 +0200
+@@ -0,0 +1,40 @@
++AC_DEFUN([BASH_CHECK_LIB_TERMCAP],
++[
++if test "X$bash_cv_termcap_lib" = "X"; then
++_bash_needmsg=yes
++else
++AC_MSG_CHECKING(which library has the termcap functions)
++_bash_needmsg=
++fi
++AC_CACHE_VAL(bash_cv_termcap_lib,
++[AC_CHECK_FUNC(tgetent, bash_cv_termcap_lib=libc,
++ [AC_CHECK_LIB(termcap, tgetent, bash_cv_termcap_lib=libtermcap,
++ [AC_CHECK_LIB(tinfo, tgetent, bash_cv_termcap_lib=libtinfo,
++ [AC_CHECK_LIB(curses, tgetent, bash_cv_termcap_lib=libcurses,
++ [AC_CHECK_LIB(ncurses, tgetent, bash_cv_termcap_lib=libncurses,
++ bash_cv_termcap_lib=gnutermcap)])])])])])
++if test "X$_bash_needmsg" = "Xyes"; then
++AC_MSG_CHECKING(which library has the termcap functions)
++fi
++AC_MSG_RESULT(using $bash_cv_termcap_lib)
++if test $bash_cv_termcap_lib = gnutermcap && test -z "$prefer_curses"; then
++LDFLAGS="$LDFLAGS -L./lib/termcap"
++TERMCAP_LIB="./lib/termcap/libtermcap.a"
++TERMCAP_DEP="./lib/termcap/libtermcap.a"
++elif test $bash_cv_termcap_lib = libtermcap && test -z "$prefer_curses"; then
++TERMCAP_LIB=-ltermcap
++TERMCAP_DEP=
++elif test $bash_cv_termcap_lib = libtinfo; then
++TERMCAP_LIB=-ltinfo
++TERMCAP_DEP=
++elif test $bash_cv_termcap_lib = libncurses; then
++TERMCAP_LIB=-lncurses
++TERMCAP_DEP=
++elif test $bash_cv_termcap_lib = libc; then
++TERMCAP_LIB=
++TERMCAP_DEP=
++else
++TERMCAP_LIB=-lcurses
++TERMCAP_DEP=
++fi
++])
+Index: gdb-7.2.90.20110703/readline/examples/autoconf/RL_LIB_READLINE_VERSION
+===================================================================
+--- /dev/null 1970-01-01 00:00:00.000000000 +0000
++++ gdb-7.2.90.20110703/readline/examples/autoconf/RL_LIB_READLINE_VERSION 2011-07-03 10:41:21.000000000 +0200
+@@ -0,0 +1,118 @@
++dnl need: prefix exec_prefix libdir includedir CC TERMCAP_LIB
++dnl require:
++dnl AC_PROG_CC
++dnl BASH_CHECK_LIB_TERMCAP
++
++AC_DEFUN([RL_LIB_READLINE_VERSION],
++[
++AC_REQUIRE([BASH_CHECK_LIB_TERMCAP])
++
++AC_MSG_CHECKING([version of installed readline library])
++
++# What a pain in the ass this is.
++
++# save cpp and ld options
++_save_CFLAGS="$CFLAGS"
++_save_LDFLAGS="$LDFLAGS"
++_save_LIBS="$LIBS"
++
++# Don't set ac_cv_rl_prefix if the caller has already assigned a value. This
++# allows the caller to do something like $_rl_prefix=$withval if the user
++# specifies --with-installed-readline=PREFIX as an argument to configure
++
++if test -z "$ac_cv_rl_prefix"; then
++test "x$prefix" = xNONE && ac_cv_rl_prefix=$ac_default_prefix || ac_cv_rl_prefix=${prefix}
++fi
++
++eval ac_cv_rl_includedir=${ac_cv_rl_prefix}/include
++eval ac_cv_rl_libdir=${ac_cv_rl_prefix}/lib
++
++LIBS="$LIBS -lreadline ${TERMCAP_LIB}"
++CFLAGS="$CFLAGS -I${ac_cv_rl_includedir}"
++LDFLAGS="$LDFLAGS -L${ac_cv_rl_libdir}"
++
++AC_CACHE_VAL(ac_cv_rl_version,
++[AC_TRY_RUN([
++#include <stdio.h>
++#include <readline/readline.h>
++
++extern int rl_gnu_readline_p;
++
++main()
++{
++ FILE *fp;
++ fp = fopen("conftest.rlv", "w");
++ if (fp == 0)
++ exit(1);
++ if (rl_gnu_readline_p != 1)
++ fprintf(fp, "0.0\n");
++ else
++ fprintf(fp, "%s\n", rl_library_version ? rl_library_version : "0.0");
++ fclose(fp);
++ exit(0);
++}
++],
++ac_cv_rl_version=`cat conftest.rlv`,
++ac_cv_rl_version='0.0',
++ac_cv_rl_version='4.2')])
++
++CFLAGS="$_save_CFLAGS"
++LDFLAGS="$_save_LDFLAGS"
++LIBS="$_save_LIBS"
++
++RL_MAJOR=0
++RL_MINOR=0
++
++# (
++case "$ac_cv_rl_version" in
++2*|3*|4*|5*|6*|7*|8*|9*)
++ RL_MAJOR=`echo $ac_cv_rl_version | sed 's:\..*$::'`
++ RL_MINOR=`echo $ac_cv_rl_version | sed -e 's:^.*\.::' -e 's:[[a-zA-Z]]*$::'`
++ ;;
++esac
++
++# (((
++case $RL_MAJOR in
++[[0-9][0-9]]) _RL_MAJOR=$RL_MAJOR ;;
++[[0-9]]) _RL_MAJOR=0$RL_MAJOR ;;
++*) _RL_MAJOR=00 ;;
++esac
++
++# (((
++case $RL_MINOR in
++[[0-9][0-9]]) _RL_MINOR=$RL_MINOR ;;
++[[0-9]]) _RL_MINOR=0$RL_MINOR ;;
++*) _RL_MINOR=00 ;;
++esac
++
++RL_VERSION="0x${_RL_MAJOR}${_RL_MINOR}"
++
++# Readline versions greater than 4.2 have these defines in readline.h
++
++if test $ac_cv_rl_version = '0.0' ; then
++ AC_MSG_WARN([Could not test version of installed readline library.])
++elif test $RL_MAJOR -gt 4 || { test $RL_MAJOR = 4 && test $RL_MINOR -gt 2 ; } ; then
++ # set these for use by the caller
++ RL_PREFIX=$ac_cv_rl_prefix
++ RL_LIBDIR=$ac_cv_rl_libdir
++ RL_INCLUDEDIR=$ac_cv_rl_includedir
++ AC_MSG_RESULT($ac_cv_rl_version)
++else
++
++AC_DEFINE_UNQUOTED(RL_READLINE_VERSION, $RL_VERSION, [encoded version of the installed readline library])
++AC_DEFINE_UNQUOTED(RL_VERSION_MAJOR, $RL_MAJOR, [major version of installed readline library])
++AC_DEFINE_UNQUOTED(RL_VERSION_MINOR, $RL_MINOR, [minor version of installed readline library])
++
++AC_SUBST(RL_VERSION)
++AC_SUBST(RL_MAJOR)
++AC_SUBST(RL_MINOR)
++
++# set these for use by the caller
++RL_PREFIX=$ac_cv_rl_prefix
++RL_LIBDIR=$ac_cv_rl_libdir
++RL_INCLUDEDIR=$ac_cv_rl_includedir
++
++AC_MSG_RESULT($ac_cv_rl_version)
++
++fi
++])
+Index: gdb-7.2.90.20110703/readline/examples/autoconf/wi_LIB_READLINE
+===================================================================
+--- /dev/null 1970-01-01 00:00:00.000000000 +0000
++++ gdb-7.2.90.20110703/readline/examples/autoconf/wi_LIB_READLINE 2011-07-03 10:41:21.000000000 +0200
+@@ -0,0 +1,76 @@
++dnl Borut Razem
++dnl
++dnl This macro checks for the presence of the readline library.
++dnl It works also in cross-compilation environment.
++dnl
++dnl To get it into the aclocal.m4 dnl file, do this:
++dnl aclocal -I . --verbose
++dnl
++dnl The --verbose will show all of the files that are searched
++dnl for .m4 macros.
++
++AC_DEFUN([wi_LIB_READLINE], [
++ dnl check for the readline.h header file
++
++ AC_CHECK_HEADER(readline/readline.h)
++
++ if test "$ac_cv_header_readline_readline_h" = yes; then
++ dnl check the readline version
++
++ cat > conftest.$ac_ext <<EOF
++#include <stdio.h>
++#include <readline/readline.h>
++wi_LIB_READLINE_VERSION RL_VERSION_MAJOR RL_VERSION_MINOR
++EOF
++
++ wi_READLINE_VERSION=$($CPP $CPPFLAGS conftest.$ac_ext | sed -n -e "s/^wi_LIB_READLINE_VERSION *\([[0-9\]][[0-9\]]*\) *\([[0-9\]][[0-9\]]*\)$/\1.\2/p")
++ rm -rf conftest*
++
++ if test -n "$wi_READLINE_VERSION"; then
++ wi_MAJOR=$(expr $wi_READLINE_VERSION : '\([[0-9]][[0-9]]*\)\.')
++ wi_MINOR=$(expr $wi_READLINE_VERSION : '[[0-9]][[0-9]]*\.\([[0-9]][[0-9]]*$\)')
++ if test $wi_MINOR -lt 10; then
++ wi_MINOR=$(expr $wi_MINOR \* 10)
++ fi
++ wi_READLINE_VERSION=$(expr $wi_MAJOR \* 100 + $wi_MINOR)
++ else
++ wi_READLINE_VERSION=-1
++ fi
++
++ dnl check for the readline library
++
++ ac_save_LIBS="$LIBS"
++ # Note: $LIBCURSES is permitted to be empty.
++
++ for LIBREADLINE in "-lreadline.dll" "-lreadline" "-lreadline $LIBCURSES" "-lreadline -ltermcap" "-lreadline -lncurses" "-lreadline -lcurses"
++ do
++ AC_MSG_CHECKING([for GNU Readline library $LIBREADLINE])
++
++ LIBS="$ac_save_LIBS $LIBREADLINE"
++
++ AC_TRY_LINK([
++ /* includes */
++ #include <stdio.h>
++ #include <readline/readline.h>
++ ],[
++ /* function-body */
++ int dummy = rl_completion_append_character; /* rl_completion_append_character appeared in version 2.1 */
++ readline(NULL);
++ ],[
++ wi_cv_lib_readline=yes
++ AC_MSG_RESULT(yes)
++ ],[
++ wi_cv_lib_readline=no
++ AC_MSG_RESULT(no)
++ ])
++
++ if test "$wi_cv_lib_readline" = yes; then
++ AC_SUBST(LIBREADLINE)
++ AC_DEFINE_UNQUOTED(HAVE_LIBREADLINE, $wi_READLINE_VERSION, [Readline])
++ break
++ fi
++ done
++
++ LIBS="$ac_save_LIBS"
++ fi
++])
+Index: gdb-7.2.90.20110703/readline/examples/excallback.c
+===================================================================
+--- gdb-7.2.90.20110703.orig/readline/examples/excallback.c 2011-07-03 10:40:53.000000000 +0200
++++ gdb-7.2.90.20110703/readline/examples/excallback.c 2011-07-03 10:41:21.000000000 +0200
+@@ -32,6 +32,9 @@ Let me know what you think.
+
+ Jeff
+ */
++/*
++Copyright (C) 1999 Jeff Solomon
++*/
+
+ #if defined (HAVE_CONFIG_H)
+ #include <config.h>
+Index: gdb-7.2.90.20110703/readline/examples/fileman.c
+===================================================================
+--- gdb-7.2.90.20110703.orig/readline/examples/fileman.c 2011-07-03 10:40:53.000000000 +0200
++++ gdb-7.2.90.20110703/readline/examples/fileman.c 2011-07-03 10:41:21.000000000 +0200
+@@ -1,22 +1,23 @@
+-/* Copyright (C) 1987-2002 Free Software Foundation, Inc.
++/* fileman.c - file manager example for readline library. */
+
+- This file is part of the GNU Readline Library, a library for
++/* Copyright (C) 1987-2009 Free Software Foundation, Inc.
++
++ This file is part of the GNU Readline Library (Readline), a library for
+ reading lines of text with interactive input and history editing.
+
+- The GNU Readline Library is free software; you can redistribute it
+- and/or modify it under the terms of the GNU General Public License
+- as published by the Free Software Foundation; either version 2, or
++ Readline 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.
+
+- The GNU Readline Library is distributed in the hope that it will be
+- useful, but WITHOUT ANY WARRANTY; without even the implied warranty
+- of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ Readline 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.
+
+- The GNU General Public License is often shipped with GNU software, and
+- is generally kept in a file called COPYING or LICENSE. If you do not
+- have a copy of the license, write to the Free Software Foundation,
+- 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
++ You should have received a copy of the GNU General Public License
++ along with Readline. If not, see <http://www.gnu.org/licenses/>.
++*/
+
+ /* fileman.c -- A tiny application which demonstrates how to use the
+ GNU Readline library. This application interactively allows users
+@@ -50,6 +51,8 @@
+ # include <stdlib.h>
+ #endif
+
++#include <time.h>
++
+ #ifdef READLINE_LIBRARY
+ # include "readline.h"
+ # include "history.h"
+@@ -58,7 +61,7 @@
+ # include <readline/history.h>
+ #endif
+
+-extern char *xmalloc ();
++extern char *xmalloc PARAMS((size_t));
+
+ /* The names of functions that actually do the manipulation. */
+ int com_list PARAMS((char *));
+Index: gdb-7.2.90.20110703/readline/examples/histexamp.c
+===================================================================
+--- gdb-7.2.90.20110703.orig/readline/examples/histexamp.c 2011-07-03 10:40:53.000000000 +0200
++++ gdb-7.2.90.20110703/readline/examples/histexamp.c 2011-07-03 10:41:21.000000000 +0200
+@@ -1,22 +1,23 @@
+-/* Copyright (C) 1987-2002 Free Software Foundation, Inc.
++/* histexamp.c - history library example program. */
+
+- This file is part of the GNU Readline Library, a library for
++/* Copyright (C) 1987-2009 Free Software Foundation, Inc.
++
++ This file is part of the GNU Readline Library (Readline), a library for
+ reading lines of text with interactive input and history editing.
+
+- The GNU Readline Library is free software; you can redistribute it
+- and/or modify it under the terms of the GNU General Public License
+- as published by the Free Software Foundation; either version 2, or
++ Readline 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.
+
+- The GNU Readline Library is distributed in the hope that it will be
+- useful, but WITHOUT ANY WARRANTY; without even the implied warranty
+- of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ Readline 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.
+
+- The GNU General Public License is often shipped with GNU software, and
+- is generally kept in a file called COPYING or LICENSE. If you do not
+- have a copy of the license, write to the Free Software Foundation,
+- 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
++ You should have received a copy of the GNU General Public License
++ along with Readline. If not, see <http://www.gnu.org/licenses/>.
++*/
+
+ #include <stdio.h>
+
+Index: gdb-7.2.90.20110703/readline/examples/manexamp.c
+===================================================================
+--- gdb-7.2.90.20110703.orig/readline/examples/manexamp.c 2011-07-03 10:40:53.000000000 +0200
++++ gdb-7.2.90.20110703/readline/examples/manexamp.c 2011-07-03 10:41:21.000000000 +0200
+@@ -1,24 +1,23 @@
+ /* manexamp.c -- The examples which appear in the documentation are here. */
+
+-/* Copyright (C) 1987-2002 Free Software Foundation, Inc.
++/* Copyright (C) 1987-2009 Free Software Foundation, Inc.
+
+- This file is part of the GNU Readline Library, a library for
++ This file is part of the GNU Readline Library (Readline), a library for
+ reading lines of text with interactive input and history editing.
+
+- The GNU Readline Library is free software; you can redistribute it
+- and/or modify it under the terms of the GNU General Public License
+- as published by the Free Software Foundation; either version 2, or
++ Readline 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.
+
+- The GNU Readline Library is distributed in the hope that it will be
+- useful, but WITHOUT ANY WARRANTY; without even the implied warranty
+- of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ Readline 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.
+
+- The GNU General Public License is often shipped with GNU software, and
+- is generally kept in a file called COPYING or LICENSE. If you do not
+- have a copy of the license, write to the Free Software Foundation,
+- 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
++ You should have received a copy of the GNU General Public License
++ along with Readline. If not, see <http://www.gnu.org/licenses/>.
++*/
+
+ #include <stdio.h>
+ #include <readline/readline.h>
+Index: gdb-7.2.90.20110703/readline/examples/readlinebuf.h
+===================================================================
+--- gdb-7.2.90.20110703.orig/readline/examples/readlinebuf.h 2011-07-03 10:40:53.000000000 +0200
++++ gdb-7.2.90.20110703/readline/examples/readlinebuf.h 2011-07-03 10:41:21.000000000 +0200
+@@ -8,7 +8,7 @@
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+- * the Free Software Foundation; either version 2 of the License, or
++ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+Index: gdb-7.2.90.20110703/readline/examples/rl.c
+===================================================================
+--- gdb-7.2.90.20110703.orig/readline/examples/rl.c 2011-07-03 10:40:53.000000000 +0200
++++ gdb-7.2.90.20110703/readline/examples/rl.c 2011-07-03 10:41:21.000000000 +0200
+@@ -5,25 +5,24 @@
+ * usage: rl [-p prompt] [-u unit] [-d default] [-n nchars]
+ */
+
+-/* Copyright (C) 1987-2002 Free Software Foundation, Inc.
++/* Copyright (C) 1987-2009 Free Software Foundation, Inc.
+
+- This file is part of the GNU Readline Library, a library for
++ This file is part of the GNU Readline Library (Readline), a library for
+ reading lines of text with interactive input and history editing.
+
+- The GNU Readline Library is free software; you can redistribute it
+- and/or modify it under the terms of the GNU General Public License
+- as published by the Free Software Foundation; either version 2, or
++ Readline 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.
+
+- The GNU Readline Library is distributed in the hope that it will be
+- useful, but WITHOUT ANY WARRANTY; without even the implied warranty
+- of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ Readline 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.
+
+- The GNU General Public License is often shipped with GNU software, and
+- is generally kept in a file called COPYING or LICENSE. If you do not
+- have a copy of the license, write to the Free Software Foundation,
+- 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
++ You should have received a copy of the GNU General Public License
++ along with Readline. If not, see <http://www.gnu.org/licenses/>.
++*/
+
+ #if defined (HAVE_CONFIG_H)
+ # include <config.h>
+Index: gdb-7.2.90.20110703/readline/examples/rlcat.c
+===================================================================
+--- gdb-7.2.90.20110703.orig/readline/examples/rlcat.c 2011-07-03 10:40:53.000000000 +0200
++++ gdb-7.2.90.20110703/readline/examples/rlcat.c 2011-07-03 10:41:21.000000000 +0200
+@@ -4,25 +4,24 @@
+ * usage: rlcat
+ */
+
+-/* Copyright (C) 1987-2002 Free Software Foundation, Inc.
++/* Copyright (C) 1987-2009 Free Software Foundation, Inc.
+
+- This file is part of the GNU Readline Library, a library for
++ This file is part of the GNU Readline Library (Readline), a library for
+ reading lines of text with interactive input and history editing.
+
+- The GNU Readline Library is free software; you can redistribute it
+- and/or modify it under the terms of the GNU General Public License
+- as published by the Free Software Foundation; either version 2, or
++ Readline 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.
+
+- The GNU Readline Library is distributed in the hope that it will be
+- useful, but WITHOUT ANY WARRANTY; without even the implied warranty
+- of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ Readline 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.
+
+- The GNU General Public License is often shipped with GNU software, and
+- is generally kept in a file called COPYING or LICENSE. If you do not
+- have a copy of the license, write to the Free Software Foundation,
+- 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
++ You should have received a copy of the GNU General Public License
++ along with Readline. If not, see <http://www.gnu.org/licenses/>.
++*/
+
+ #if defined (HAVE_CONFIG_H)
+ # include <config.h>
+Index: gdb-7.2.90.20110703/readline/examples/rlevent.c
+===================================================================
+--- /dev/null 1970-01-01 00:00:00.000000000 +0000
++++ gdb-7.2.90.20110703/readline/examples/rlevent.c 2011-07-03 10:41:21.000000000 +0200
+@@ -0,0 +1,166 @@
++/*
++ * rl - command-line interface to read a line from the standard input
++ * (or another fd) using readline.
++ *
++ * usage: rl [-p prompt] [-u unit] [-d default] [-n nchars]
++ */
++
++/* Copyright (C) 1987-2009 Free Software Foundation, Inc.
++
++ This file is part of the GNU Readline Library (Readline), a library for
++ reading lines of text with interactive input and history editing.
++
++ Readline 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.
++
++ Readline 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 Readline. If not, see <http://www.gnu.org/licenses/>.
++*/
++
++#if defined (HAVE_CONFIG_H)
++# include <config.h>
++#endif
++
++#include <stdio.h>
++#include <sys/types.h>
++
++#ifdef HAVE_STDLIB_H
++# include <stdlib.h>
++#else
++extern void exit();
++#endif
++
++#if defined (READLINE_LIBRARY)
++# include "posixstat.h"
++# include "readline.h"
++# include "history.h"
++#else
++# include <sys/stat.h>
++# include <readline/readline.h>
++# include <readline/history.h>
++#endif
++
++extern int optind;
++extern char *optarg;
++
++#if !defined (strchr) && !defined (__STDC__)
++extern char *strrchr();
++#endif
++
++static char *progname;
++static char *deftext;
++
++static int
++event_hook ()
++{
++ fprintf (stderr, "ding!\n");
++ sleep (1);
++ return 0;
++}
++
++static int
++set_deftext ()
++{
++ if (deftext)
++ {
++ rl_insert_text (deftext);
++ deftext = (char *)NULL;
++ rl_startup_hook = (rl_hook_func_t *)NULL;
++ }
++ return 0;
++}
++
++static void
++usage()
++{
++ fprintf (stderr, "%s: usage: %s [-p prompt] [-u unit] [-d default] [-n nchars]\n",
++ progname, progname);
++}
++
++int
++main (argc, argv)
++ int argc;
++ char **argv;
++{
++ char *temp, *prompt;
++ struct stat sb;
++ int opt, fd, nch;
++ FILE *ifp;
++
++ progname = strrchr(argv[0], '/');
++ if (progname == 0)
++ progname = argv[0];
++ else
++ progname++;
++
++ /* defaults */
++ prompt = "readline$ ";
++ fd = nch = 0;
++ deftext = (char *)0;
++
++ while ((opt = getopt(argc, argv, "p:u:d:n:")) != EOF)
++ {
++ switch (opt)
++ {
++ case 'p':
++ prompt = optarg;
++ break;
++ case 'u':
++ fd = atoi(optarg);
++ if (fd < 0)
++ {
++ fprintf (stderr, "%s: bad file descriptor `%s'\n", progname, optarg);
++ exit (2);
++ }
++ break;
++ case 'd':
++ deftext = optarg;
++ break;
++ case 'n':
++ nch = atoi(optarg);
++ if (nch < 0)
++ {
++ fprintf (stderr, "%s: bad value for -n: `%s'\n", progname, optarg);
++ exit (2);
++ }
++ break;
++ default:
++ usage ();
++ exit (2);
++ }
++ }
++
++ if (fd != 0)
++ {
++ if (fstat (fd, &sb) < 0)
++ {
++ fprintf (stderr, "%s: %d: bad file descriptor\n", progname, fd);
++ exit (1);
++ }
++ ifp = fdopen (fd, "r");
++ rl_instream = ifp;
++ }
++
++ if (deftext && *deftext)
++ rl_startup_hook = set_deftext;
++
++ if (nch > 0)
++ rl_num_chars_to_read = nch;
++
++ rl_event_hook = event_hook;
++ temp = readline (prompt);
++
++ /* Test for EOF. */
++ if (temp == 0)
++ exit (1);
++
++ printf ("%s\n", temp);
++ exit (0);
++}
+Index: gdb-7.2.90.20110703/readline/examples/rlfe/ChangeLog
+===================================================================
+--- gdb-7.2.90.20110703.orig/readline/examples/rlfe/ChangeLog 2011-07-03 10:40:53.000000000 +0200
++++ gdb-7.2.90.20110703/readline/examples/rlfe/ChangeLog 2011-07-03 10:41:21.000000000 +0200
+@@ -1,14 +1,3 @@
+-2009-08-22 Ralf Wildenhues <Ralf.Wildenhues@gmx.de>
+-
+- * configure: Regenerate.
+-
+- * configure.in: m4_include toplevel config/override.m4.
+- * configure: Regenerate.
+-
+-2009-07-30 Ralf Wildenhues <Ralf.Wildenhues@gmx.de>
+-
+- * configure.in: Correctly quote AC_PROGRAM_SOURCE definition.
+-
+ 2004-11-04 Per Bothner <per@bothner.com>
+
+ * pty.c: Import from screen-4.0.2.
+Index: gdb-7.2.90.20110703/readline/examples/rlfe/Makefile.in
+===================================================================
+--- gdb-7.2.90.20110703.orig/readline/examples/rlfe/Makefile.in 2011-07-03 10:40:53.000000000 +0200
++++ gdb-7.2.90.20110703/readline/examples/rlfe/Makefile.in 2011-07-03 10:41:21.000000000 +0200
+@@ -25,7 +25,7 @@ CFLAGS = @CFLAGS@
+ CPPFLAGS = @CPPFLAGS@
+ #LDFLAGS = -L$(READLINE_DIR)
+ LDFLAGS = @LDFLAGS@
+-LIBS = -lreadline -lhistory -lncurses
++LIBS = -lreadline -lhistory @LIBS@
+
+ CPP=@CPP@
+ CPP_DEPEND=$(CC) -MM
+@@ -55,7 +55,7 @@ rlfe-$(VERSION).tar.gz:
+ tar czf $@ $(CFILES) $(HFILES) $(EXTRA_DIST)
+
+ .c.o:
+- $(CC) -c -I. -I$(srcdir) $(M_CFLAGS) $(DEFS) $(OPTIONS) $(CFLAGS) $<
++ $(CC) -c -I. -I$(srcdir) $(CPPFLAGS) $(M_CFLAGS) $(DEFS) $(OPTIONS) $(CFLAGS) $<
+
+ install_bin: .version screen
+ -if [ -f $(DESTDIR)$(bindir)/$(SCREEN) ] && [ ! -f $(DESTDIR)$(bindir)/$(SCREEN).old ]; \
+@@ -68,7 +68,6 @@ install_bin: .version screen
+ (cd $(DESTDIR)$(bindir) && ln -sf $(SCREEN) screen)
+ cp $(srcdir)/utf8encodings/?? $(DESTDIR)$(SCREENENCODINGS)
+
+-
+ uninstall: .version
+ rm -f $(DESTDIR)$(bindir)/$(SCREEN)
+ rm -f $(DESTDIR)$(bindir)/screen
+@@ -170,6 +169,15 @@ depend.in: $(CFILES) term.h
+ for i in $(CFILES); do echo $$i; $(CPP_DEPEND) $$i >> tmp_make; done
+ mv tmp_make Makefile.in
+
++Makefile makefile: config.status $(srcdir)/Makefile.in
++ CONFIG_FILES=Makefile CONFIG_HEADERS= $(SHELL) ./config.status
++
++config.status: $(srcdir)/configure
++ $(SHELL) ./config.status --recheck
++
++$(srcdir)/configure: $(srcdir)/configure.in
++ cd $(srcdir) && autoconf
++
+ ###############################################################################
+
+ ### Dependencies:
+Index: gdb-7.2.90.20110703/readline/examples/rlfe/config.h.in
+===================================================================
+--- gdb-7.2.90.20110703.orig/readline/examples/rlfe/config.h.in 2011-07-03 10:40:53.000000000 +0200
++++ gdb-7.2.90.20110703/readline/examples/rlfe/config.h.in 2011-07-03 10:41:21.000000000 +0200
+@@ -373,3 +373,7 @@
+ #undef PTYRANGE1
+
+ #define USEVARARGS
++
++#undef HAVE_SYS_STROPTS_H
++
++#undef HAVE_SYS_WAIT_H
+Index: gdb-7.2.90.20110703/readline/examples/rlfe/configure
+===================================================================
+--- gdb-7.2.90.20110703.orig/readline/examples/rlfe/configure 2011-07-03 10:40:53.000000000 +0200
++++ gdb-7.2.90.20110703/readline/examples/rlfe/configure 2011-07-03 10:41:21.000000000 +0200
+@@ -552,6 +552,42 @@ PACKAGE_BUGREPORT=
+ PACKAGE_URL=
+
+ ac_unique_file="rlfe.c"
++# Factoring default headers for most tests.
++ac_includes_default="\
++#include <stdio.h>
++#ifdef HAVE_SYS_TYPES_H
++# include <sys/types.h>
++#endif
++#ifdef HAVE_SYS_STAT_H
++# include <sys/stat.h>
++#endif
++#ifdef STDC_HEADERS
++# include <stdlib.h>
++# include <stddef.h>
++#else
++# ifdef HAVE_STDLIB_H
++# include <stdlib.h>
++# endif
++#endif
++#ifdef HAVE_STRING_H
++# if !defined STDC_HEADERS && defined HAVE_MEMORY_H
++# include <memory.h>
++# endif
++# include <string.h>
++#endif
++#ifdef HAVE_STRINGS_H
++# include <strings.h>
++#endif
++#ifdef HAVE_INTTYPES_H
++# include <inttypes.h>
++#endif
++#ifdef HAVE_STDINT_H
++# include <stdint.h>
++#endif
++#ifdef HAVE_UNISTD_H
++# include <unistd.h>
++#endif"
++
+ ac_subst_vars='LTLIBOBJS
+ LIBOBJS
+ XTERMPATH
+@@ -1550,6 +1586,124 @@ $as_echo "$ac_res" >&6; }
+ eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;}
+
+ } # ac_fn_c_check_func
++
++# ac_fn_c_check_header_mongrel LINENO HEADER VAR INCLUDES
++# -------------------------------------------------------
++# Tests whether HEADER exists, giving a warning if it cannot be compiled using
++# the include files in INCLUDES and setting the cache variable VAR
++# accordingly.
++ac_fn_c_check_header_mongrel ()
++{
++ as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
++ if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then :
++ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
++$as_echo_n "checking for $2... " >&6; }
++if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then :
++ $as_echo_n "(cached) " >&6
++fi
++eval ac_res=\$$3
++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
++$as_echo "$ac_res" >&6; }
++else
++ # Is the header compilable?
++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 usability" >&5
++$as_echo_n "checking $2 usability... " >&6; }
++cat confdefs.h - <<_ACEOF >conftest.$ac_ext
++/* end confdefs.h. */
++$4
++#include <$2>
++_ACEOF
++if ac_fn_c_try_compile "$LINENO"; then :
++ ac_header_compiler=yes
++else
++ ac_header_compiler=no
++fi
++rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
++{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_compiler" >&5
++$as_echo "$ac_header_compiler" >&6; }
++
++# Is the header present?
++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 presence" >&5
++$as_echo_n "checking $2 presence... " >&6; }
++cat confdefs.h - <<_ACEOF >conftest.$ac_ext
++/* end confdefs.h. */
++#include <$2>
++_ACEOF
++if ac_fn_c_try_cpp "$LINENO"; then :
++ ac_header_preproc=yes
++else
++ ac_header_preproc=no
++fi
++rm -f conftest.err conftest.$ac_ext
++{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_preproc" >&5
++$as_echo "$ac_header_preproc" >&6; }
++
++# So? What about this header?
++case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in #((
++ yes:no: )
++ { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&5
++$as_echo "$as_me: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&2;}
++ { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5
++$as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;}
++ ;;
++ no:yes:* )
++ { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: present but cannot be compiled" >&5
++$as_echo "$as_me: WARNING: $2: present but cannot be compiled" >&2;}
++ { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: check for missing prerequisite headers?" >&5
++$as_echo "$as_me: WARNING: $2: check for missing prerequisite headers?" >&2;}
++ { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: see the Autoconf documentation" >&5
++$as_echo "$as_me: WARNING: $2: see the Autoconf documentation" >&2;}
++ { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&5
++$as_echo "$as_me: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&2;}
++ { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5
++$as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;}
++ ;;
++esac
++ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
++$as_echo_n "checking for $2... " >&6; }
++if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then :
++ $as_echo_n "(cached) " >&6
++else
++ eval "$3=\$ac_header_compiler"
++fi
++eval ac_res=\$$3
++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
++$as_echo "$ac_res" >&6; }
++fi
++ eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;}
++
++} # ac_fn_c_check_header_mongrel
++
++# ac_fn_c_check_header_compile LINENO HEADER VAR INCLUDES
++# -------------------------------------------------------
++# Tests whether HEADER exists and can be compiled using the include files in
++# INCLUDES, setting the cache variable VAR accordingly.
++ac_fn_c_check_header_compile ()
++{
++ as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
++ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
++$as_echo_n "checking for $2... " >&6; }
++if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then :
++ $as_echo_n "(cached) " >&6
++else
++ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
++/* end confdefs.h. */
++$4
++#include <$2>
++_ACEOF
++if ac_fn_c_try_compile "$LINENO"; then :
++ eval "$3=yes"
++else
++ eval "$3=no"
++fi
++rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
++fi
++eval ac_res=\$$3
++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
++$as_echo "$ac_res" >&6; }
++ eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;}
++
++} # ac_fn_c_check_header_compile
+ cat >config.log <<_ACEOF
+ This file contains any messages produced by compilers while
+ running configure, to aid debugging if configure makes a mistake.
+@@ -4003,6 +4157,151 @@ fi
+
+ fi
+
++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5
++$as_echo_n "checking for ANSI C header files... " >&6; }
++if test "${ac_cv_header_stdc+set}" = set; then :
++ $as_echo_n "(cached) " >&6
++else
++ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
++/* end confdefs.h. */
++#include <stdlib.h>
++#include <stdarg.h>
++#include <string.h>
++#include <float.h>
++
++int
++main ()
++{
++
++ ;
++ return 0;
++}
++_ACEOF
++if ac_fn_c_try_compile "$LINENO"; then :
++ ac_cv_header_stdc=yes
++else
++ ac_cv_header_stdc=no
++fi
++rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
++
++if test $ac_cv_header_stdc = yes; then
++ # SunOS 4.x string.h does not declare mem*, contrary to ANSI.
++ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
++/* end confdefs.h. */
++#include <string.h>
++
++_ACEOF
++if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
++ $EGREP "memchr" >/dev/null 2>&1; then :
++
++else
++ ac_cv_header_stdc=no
++fi
++rm -f conftest*
++
++fi
++
++if test $ac_cv_header_stdc = yes; then
++ # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
++ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
++/* end confdefs.h. */
++#include <stdlib.h>
++
++_ACEOF
++if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
++ $EGREP "free" >/dev/null 2>&1; then :
++
++else
++ ac_cv_header_stdc=no
++fi
++rm -f conftest*
++
++fi
++
++if test $ac_cv_header_stdc = yes; then
++ # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi.
++ if test "$cross_compiling" = yes; then :
++ :
++else
++ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
++/* end confdefs.h. */
++#include <ctype.h>
++#include <stdlib.h>
++#if ((' ' & 0x0FF) == 0x020)
++# define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
++# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c))
++#else
++# define ISLOWER(c) \
++ (('a' <= (c) && (c) <= 'i') \
++ || ('j' <= (c) && (c) <= 'r') \
++ || ('s' <= (c) && (c) <= 'z'))
++# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c))
++#endif
++
++#define XOR(e, f) (((e) && !(f)) || (!(e) && (f)))
++int
++main ()
++{
++ int i;
++ for (i = 0; i < 256; i++)
++ if (XOR (islower (i), ISLOWER (i))
++ || toupper (i) != TOUPPER (i))
++ return 2;
++ return 0;
++}
++_ACEOF
++if ac_fn_c_try_run "$LINENO"; then :
++
++else
++ ac_cv_header_stdc=no
++fi
++rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
++ conftest.$ac_objext conftest.beam conftest.$ac_ext
++fi
++
++fi
++fi
++{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdc" >&5
++$as_echo "$ac_cv_header_stdc" >&6; }
++if test $ac_cv_header_stdc = yes; then
++
++$as_echo "#define STDC_HEADERS 1" >>confdefs.h
++
++fi
++
++# On IRIX 5.3, sys/types and inttypes.h are conflicting.
++for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \
++ inttypes.h stdint.h unistd.h
++do :
++ as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
++ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default
++"
++eval as_val=\$$as_ac_Header
++ if test "x$as_val" = x""yes; then :
++ cat >>confdefs.h <<_ACEOF
++#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
++_ACEOF
++
++fi
++
++done
++
++
++for ac_header in sys/stropts.h sys/wait.h
++do :
++ as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
++ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
++eval as_val=\$$as_ac_Header
++ if test "x$as_val" = x""yes; then :
++ cat >>confdefs.h <<_ACEOF
++#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
++_ACEOF
++
++fi
++
++done
++
++
+ ac_config_files="$ac_config_files Makefile"
+
+ cat >confcache <<\_ACEOF
+Index: gdb-7.2.90.20110703/readline/examples/rlfe/configure.in
+===================================================================
+--- gdb-7.2.90.20110703.orig/readline/examples/rlfe/configure.in 2011-07-03 10:40:53.000000000 +0200
++++ gdb-7.2.90.20110703/readline/examples/rlfe/configure.in 2011-07-03 10:41:21.000000000 +0200
+@@ -437,4 +437,6 @@ main()
+
+ fi
+
++AC_CHECK_HEADERS(sys/stropts.h sys/wait.h)
++
+ AC_OUTPUT(Makefile)
+Index: gdb-7.2.90.20110703/readline/examples/rlfe/extern.h
+===================================================================
+--- gdb-7.2.90.20110703.orig/readline/examples/rlfe/extern.h 2011-07-03 10:40:53.000000000 +0200
++++ gdb-7.2.90.20110703/readline/examples/rlfe/extern.h 2011-07-03 10:41:21.000000000 +0200
+@@ -27,7 +27,14 @@
+ #define __attribute__(x)
+ #endif
+
++#if !defined (__P)
++# if defined (__STDC__) || defined (__GNUC__) || defined (__cplusplus)
++# define __P(protos) protos
++# else
++# define __P(protos) ()
++# endif
++#endif
++
+ /* pty.c */
+ extern int OpenPTY __P((char **));
+ extern void InitPTY __P((int));
+-
+Index: gdb-7.2.90.20110703/readline/examples/rlfe/os.h
+===================================================================
+--- gdb-7.2.90.20110703.orig/readline/examples/rlfe/os.h 2011-07-03 10:40:53.000000000 +0200
++++ gdb-7.2.90.20110703/readline/examples/rlfe/os.h 2011-07-03 10:41:21.000000000 +0200
+@@ -186,7 +186,7 @@ extern int errno;
+ * terminal handling
+ */
+
+-#ifdef POSIX
++#if defined (POSIX) || defined (__FreeBSD__)
+ # include <termios.h>
+ # ifdef hpux
+ # include <bsdtty.h>
+@@ -527,4 +527,3 @@ typedef struct fd_set { int fds_bits[1];
+ * how many characters your pty's can buffer.
+ */
+ #define IOSIZE 4096
+-
+Index: gdb-7.2.90.20110703/readline/examples/rlfe/pty.c
+===================================================================
+--- gdb-7.2.90.20110703.orig/readline/examples/rlfe/pty.c 2011-07-03 10:40:53.000000000 +0200
++++ gdb-7.2.90.20110703/readline/examples/rlfe/pty.c 2011-07-03 10:41:21.000000000 +0200
+@@ -20,13 +20,15 @@
+ *
+ ****************************************************************
+ */
++#include "config.h"
+
+ #include <sys/types.h>
+ #include <sys/stat.h>
+ #include <fcntl.h>
+ #include <signal.h>
+
+-#include "config.h"
++#include <unistd.h>
++
+ #include "screen.h"
+
+ #ifndef sun
+@@ -34,7 +36,7 @@
+ #endif
+
+ /* for solaris 2.1, Unixware (SVR4.2) and possibly others */
+-#ifdef HAVE_SVR4_PTYS
++#if defined (HAVE_SVR4_PTYS) && defined (HAVE_SYS_STROPTS_H)
+ # include <sys/stropts.h>
+ #endif
+
+@@ -384,4 +386,3 @@ char **ttyn;
+ return -1;
+ }
+ #endif
+-
+Index: gdb-7.2.90.20110703/readline/examples/rlfe/rlfe.c
+===================================================================
+--- gdb-7.2.90.20110703.orig/readline/examples/rlfe/rlfe.c 2011-07-03 10:40:53.000000000 +0200
++++ gdb-7.2.90.20110703/readline/examples/rlfe/rlfe.c 2011-07-03 10:41:21.000000000 +0200
+@@ -73,6 +73,11 @@
+ #include <termios.h>
+
+ #include "config.h"
++#include "extern.h"
++
++#if defined (HAVE_SYS_WAIT_H)
++# include <sys/wait.h>
++#endif
+
+ #ifdef READLINE_LIBRARY
+ # include "readline.h"
+@@ -588,7 +593,7 @@ main(int argc, char** argv)
+ }
+ if (FD_ISSET (in_from_tty_fd, &in_set))
+ {
+- extern int readline_echoing_p;
++ extern int _rl_echoing_p;
+ struct termios term_master;
+ int do_canon = 1;
+ int do_icrnl = 1;
+@@ -605,9 +610,9 @@ main(int argc, char** argv)
+ {
+ do_canon = (term_master.c_lflag & ICANON) != 0;
+ do_icrnl = (term_master.c_lflag & ICRNL) != 0;
+- readline_echoing_p = (term_master.c_lflag & ECHO) != 0;
++ _rl_echoing_p = (term_master.c_lflag & ECHO) != 0;
+ DPRINT1 ("echo,canon,crnl:%03d\n",
+- 100 * readline_echoing_p
++ 100 * _rl_echoing_p
+ + 10 * do_canon
+ + 1 * do_icrnl);
+ }
+@@ -757,7 +762,7 @@ static void set_edit_mode ()
+ vi = 1;
+ break;
+ }
+- shellopts = index (shellopts + 1, ':');
++ shellopts = strchr (shellopts + 1, ':');
+ }
+
+ if (!vi)
+Index: gdb-7.2.90.20110703/readline/examples/rltest.c
+===================================================================
+--- gdb-7.2.90.20110703.orig/readline/examples/rltest.c 2011-07-03 10:40:53.000000000 +0200
++++ gdb-7.2.90.20110703/readline/examples/rltest.c 2011-07-03 10:41:21.000000000 +0200
+@@ -4,25 +4,24 @@
+ /* */
+ /* **************************************************************** */
+
+-/* Copyright (C) 1987-2002 Free Software Foundation, Inc.
++/* Copyright (C) 1987-2009 Free Software Foundation, Inc.
+
+- This file is part of the GNU Readline Library, a library for
++ This file is part of the GNU Readline Library (Readline), a library for
+ reading lines of text with interactive input and history editing.
+
+- The GNU Readline Library is free software; you can redistribute it
+- and/or modify it under the terms of the GNU General Public License
+- as published by the Free Software Foundation; either version 2, or
++ Readline 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.
+
+- The GNU Readline Library is distributed in the hope that it will be
+- useful, but WITHOUT ANY WARRANTY; without even the implied warranty
+- of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ Readline 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.
+
+- The GNU General Public License is often shipped with GNU software, and
+- is generally kept in a file called COPYING or LICENSE. If you do not
+- have a copy of the license, write to the Free Software Foundation,
+- 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
++ You should have received a copy of the GNU General Public License
++ along with Readline. If not, see <http://www.gnu.org/licenses/>.
++*/
+
+ #if defined (HAVE_CONFIG_H)
+ #include <config.h>
+Index: gdb-7.2.90.20110703/readline/examples/rlversion.c
+===================================================================
+--- gdb-7.2.90.20110703.orig/readline/examples/rlversion.c 2011-07-03 10:40:53.000000000 +0200
++++ gdb-7.2.90.20110703/readline/examples/rlversion.c 2011-07-03 10:41:21.000000000 +0200
+@@ -2,25 +2,24 @@
+ * rlversion -- print out readline's version number
+ */
+
+-/* Copyright (C) 1987-2002 Free Software Foundation, Inc.
++/* Copyright (C) 1987-2009 Free Software Foundation, Inc.
+
+- This file is part of the GNU Readline Library, a library for
++ This file is part of the GNU Readline Library (Readline), a library for
+ reading lines of text with interactive input and history editing.
+
+- The GNU Readline Library is free software; you can redistribute it
+- and/or modify it under the terms of the GNU General Public License
+- as published by the Free Software Foundation; either version 2, or
++ Readline 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.
+
+- The GNU Readline Library is distributed in the hope that it will be
+- useful, but WITHOUT ANY WARRANTY; without even the implied warranty
+- of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ Readline 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.
+
+- The GNU General Public License is often shipped with GNU software, and
+- is generally kept in a file called COPYING or LICENSE. If you do not
+- have a copy of the license, write to the Free Software Foundation,
+- 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
++ You should have received a copy of the GNU General Public License
++ along with Readline. If not, see <http://www.gnu.org/licenses/>.
++*/
+
+ #if defined (HAVE_CONFIG_H)
+ # include <config.h>
+Index: gdb-7.2.90.20110703/readline/funmap.c
+===================================================================
+--- gdb-7.2.90.20110703.orig/readline/funmap.c 2011-07-03 10:40:53.000000000 +0200
++++ gdb-7.2.90.20110703/readline/funmap.c 2011-07-03 10:41:21.000000000 +0200
+@@ -1,24 +1,24 @@
+ /* funmap.c -- attach names to functions. */
+
+-/* Copyright (C) 1987, 1989, 1992 Free Software Foundation, Inc.
++/* Copyright (C) 1987-2010 Free Software Foundation, Inc.
+
+- This file is part of the GNU Readline Library, a library for
+- reading lines of text with interactive input and history editing.
++ This file is part of the GNU Readline Library (Readline), a library
++ for reading lines of text with interactive input and history editing.
+
+- The GNU Readline Library is free software; you can redistribute it
+- and/or modify it under the terms of the GNU General Public License
+- as published by the Free Software Foundation; either version 2, or
++ Readline 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.
+
+- The GNU Readline Library is distributed in the hope that it will be
+- useful, but WITHOUT ANY WARRANTY; without even the implied warranty
+- of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ Readline 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.
+
+- The GNU General Public License is often shipped with GNU software, and
+- is generally kept in a file called COPYING or LICENSE. If you do not
+- have a copy of the license, write to the Free Software Foundation,
+- 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
++ You should have received a copy of the GNU General Public License
++ along with Readline. If not, see <http://www.gnu.org/licenses/>.
++*/
++
+ #define READLINE_LIBRARY
+
+ #if defined (HAVE_CONFIG_H)
+@@ -56,7 +56,7 @@ static int funmap_entry;
+ program specific function. */
+ int funmap_program_specific_entry_start;
+
+-static FUNMAP default_funmap[] = {
++static const FUNMAP default_funmap[] = {
+ { "abort", rl_abort },
+ { "accept-line", rl_newline },
+ { "arrow-key-prefix", rl_arrow_keys },
+@@ -105,11 +105,13 @@ static FUNMAP default_funmap[] = {
+ { "kill-region", rl_kill_region },
+ { "kill-word", rl_kill_word },
+ { "menu-complete", rl_menu_complete },
++ { "menu-complete-backward", rl_backward_menu_complete },
+ { "next-history", rl_get_next_history },
+ { "non-incremental-forward-search-history", rl_noninc_forward_search },
+ { "non-incremental-reverse-search-history", rl_noninc_reverse_search },
+ { "non-incremental-forward-search-history-again", rl_noninc_forward_search_again },
+ { "non-incremental-reverse-search-history-again", rl_noninc_reverse_search_again },
++ { "old-menu-complete", rl_old_menu_complete },
+ { "overwrite-mode", rl_overwrite_mode },
+ #ifdef __CYGWIN__
+ { "paste-from-clipboard", rl_paste_from_clipboard },
+@@ -123,6 +125,7 @@ static FUNMAP default_funmap[] = {
+ { "revert-line", rl_revert_line },
+ { "self-insert", rl_insert },
+ { "set-mark", rl_set_mark },
++ { "skip-csi-sequence", rl_skip_csi_sequence },
+ { "start-kbd-macro", rl_start_kbd_macro },
+ { "tab-insert", rl_tab_insert },
+ { "tilde-expand", rl_tilde_expand },
+@@ -145,6 +148,8 @@ static FUNMAP default_funmap[] = {
+ { "vi-append-mode", rl_vi_append_mode },
+ { "vi-arg-digit", rl_vi_arg_digit },
+ { "vi-back-to-indent", rl_vi_back_to_indent },
++ { "vi-backward-bigword", rl_vi_bWord },
++ { "vi-backward-word", rl_vi_bword },
+ { "vi-bWord", rl_vi_bWord },
+ { "vi-bword", rl_vi_bword },
+ { "vi-change-case", rl_vi_change_case },
+@@ -157,12 +162,15 @@ static FUNMAP default_funmap[] = {
+ { "vi-delete-to", rl_vi_delete_to },
+ { "vi-eWord", rl_vi_eWord },
+ { "vi-editing-mode", rl_vi_editing_mode },
++ { "vi-end-bigword", rl_vi_eWord },
+ { "vi-end-word", rl_vi_end_word },
+ { "vi-eof-maybe", rl_vi_eof_maybe },
+ { "vi-eword", rl_vi_eword },
+ { "vi-fWord", rl_vi_fWord },
+ { "vi-fetch-history", rl_vi_fetch_history },
+ { "vi-first-print", rl_vi_first_print },
++ { "vi-forward-bigword", rl_vi_fWord },
++ { "vi-forward-word", rl_vi_fword },
+ { "vi-fword", rl_vi_fword },
+ { "vi-goto-mark", rl_vi_goto_mark },
+ { "vi-insert-beg", rl_vi_insert_beg },
+Index: gdb-7.2.90.20110703/readline/histexpand.c
+===================================================================
+--- gdb-7.2.90.20110703.orig/readline/histexpand.c 2011-07-03 10:40:53.000000000 +0200
++++ gdb-7.2.90.20110703/readline/histexpand.c 2011-07-03 10:41:21.000000000 +0200
+@@ -1,24 +1,23 @@
+ /* histexpand.c -- history expansion. */
+
+-/* Copyright (C) 1989-2004 Free Software Foundation, Inc.
++/* Copyright (C) 1989-2010 Free Software Foundation, Inc.
+
+- This file contains the GNU History Library (the Library), a set of
++ This file contains the GNU History Library (History), a set of
+ routines for managing the text of previously typed lines.
+
+- The Library is free software; you can redistribute it and/or modify
++ History is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+- the Free Software Foundation; either version 2, or (at your option)
+- any later version.
++ the Free Software Foundation, either version 3 of the License, or
++ (at your option) any later version.
+
+- The Library is distributed in the hope that it will be useful, but
+- WITHOUT ANY WARRANTY; without even the implied warranty of
+- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+- General Public License for more details.
+-
+- The GNU General Public License is often shipped with GNU software, and
+- is generally kept in a file called COPYING or LICENSE. If you do not
+- have a copy of the license, write to the Free Software Foundation,
+- 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
++ History 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 History. If not, see <http://www.gnu.org/licenses/>.
++*/
+
+ #define READLINE_LIBRARY
+
+@@ -56,8 +55,6 @@
+
+ typedef int _hist_search_func_t PARAMS((const char *, int));
+
+-extern int rl_byte_oriented; /* declared in mbutil.c */
+-
+ static char error_pointer;
+
+ static char *subst_lhs;
+@@ -66,9 +63,11 @@ static int subst_lhs_len;
+ static int subst_rhs_len;
+
+ static char *get_history_word_specifier PARAMS((char *, char *, int *));
+-static char *history_find_word PARAMS((char *, int));
+ static int history_tokenize_word PARAMS((const char *, int));
++static char **history_tokenize_internal PARAMS((const char *, int, int *));
+ static char *history_substring PARAMS((const char *, int, int));
++static void freewords PARAMS((char **, int));
++static char *history_find_word PARAMS((char *, int));
+
+ static char *quote_breaks PARAMS((char *));
+
+@@ -246,7 +245,7 @@ get_history_event (string, caller_index,
+
+ #define FAIL_SEARCH() \
+ do { \
+- history_offset = history_length; free (temp) ; return (char *)NULL; \
++ history_offset = history_length; xfree (temp) ; return (char *)NULL; \
+ } while (0)
+
+ /* If there is no search string, try to use the previous search string,
+@@ -255,7 +254,7 @@ get_history_event (string, caller_index,
+ {
+ if (search_string)
+ {
+- free (temp);
++ xfree (temp);
+ temp = savestring (search_string);
+ }
+ else
+@@ -286,7 +285,7 @@ get_history_event (string, caller_index,
+ search_match = history_find_word (entry->line, local_index);
+ }
+ else
+- free (temp);
++ xfree (temp);
+
+ return (entry->line);
+ }
+@@ -306,16 +305,20 @@ get_history_event (string, caller_index,
+ /* Extract the contents of STRING as if it is enclosed in single quotes.
+ SINDEX, when passed in, is the offset of the character immediately
+ following the opening single quote; on exit, SINDEX is left pointing
+- to the closing single quote. */
++ to the closing single quote. FLAGS currently used to allow backslash
++ to escape a single quote (e.g., for bash $'...'). */
+ static void
+-hist_string_extract_single_quoted (string, sindex)
++hist_string_extract_single_quoted (string, sindex, flags)
+ char *string;
+- int *sindex;
++ int *sindex, flags;
+ {
+ register int i;
+
+ for (i = *sindex; string[i] && string[i] != '\''; i++)
+- ;
++ {
++ if ((flags & 1) && string[i] == '\\' && string[i+1])
++ i++;
++ }
+
+ *sindex = i;
+ }
+@@ -505,7 +508,7 @@ postproc_subst_rhs ()
+ }
+ }
+ new[j] = '\0';
+- free (subst_rhs);
++ xfree (subst_rhs);
+ subst_rhs = new;
+ subst_rhs_len = j;
+ }
+@@ -564,12 +567,12 @@ history_expand_internal (string, start,
+ #if defined (HANDLE_MULTIBYTE)
+ if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
+ {
+- int c, l;
++ int ch, l;
+ l = _rl_find_prev_mbchar (string, i, MB_FIND_ANY);
+- c = string[l];
++ ch = string[l];
+ /* XXX - original patch had i - 1 ??? If i == 0 it would fail. */
+- if (i && (c == '\'' || c == '"'))
+- quoted_search_delimiter = c;
++ if (i && (ch == '\'' || ch == '"'))
++ quoted_search_delimiter = ch;
+ }
+ else
+ #endif /* HANDLE_MULTIBYTE */
+@@ -582,7 +585,7 @@ history_expand_internal (string, start,
+ if (event == 0)
+ {
+ *ret_string = hist_error (string, start, i, EVENT_NOT_FOUND);
+- free (result);
++ xfree (result);
+ return (-1);
+ }
+
+@@ -596,7 +599,7 @@ history_expand_internal (string, start,
+ if (word_spec == (char *)&error_pointer)
+ {
+ *ret_string = hist_error (string, starting_index, i, BAD_WORD_SPEC);
+- free (result);
++ xfree (result);
+ return (-1);
+ }
+
+@@ -629,8 +632,8 @@ history_expand_internal (string, start,
+ {
+ default:
+ *ret_string = hist_error (string, i+1, i+2, BAD_MODIFIER);
+- free (result);
+- free (temp);
++ xfree (result);
++ xfree (temp);
+ return -1;
+
+ case 'q':
+@@ -655,7 +658,7 @@ history_expand_internal (string, start,
+ {
+ tstr++;
+ t = savestring (tstr);
+- free (temp);
++ xfree (temp);
+ temp = t;
+ }
+ break;
+@@ -680,7 +683,7 @@ history_expand_internal (string, start,
+ if (tstr)
+ {
+ t = savestring (tstr);
+- free (temp);
++ xfree (temp);
+ temp = t;
+ }
+ break;
+@@ -756,8 +759,8 @@ history_expand_internal (string, start,
+ if (subst_lhs_len == 0)
+ {
+ *ret_string = hist_error (string, starting_index, i, NO_PREV_SUBST);
+- free (result);
+- free (temp);
++ xfree (result);
++ xfree (temp);
+ return -1;
+ }
+
+@@ -766,8 +769,8 @@ history_expand_internal (string, start,
+ if (subst_lhs_len > l_temp)
+ {
+ *ret_string = hist_error (string, starting_index, i, SUBST_FAILED);
+- free (result);
+- free (temp);
++ xfree (result);
++ xfree (temp);
+ return (-1);
+ }
+
+@@ -808,7 +811,7 @@ history_expand_internal (string, start,
+ temp + si + subst_lhs_len,
+ l_temp - (si + subst_lhs_len));
+ new_event[len] = '\0';
+- free (temp);
++ xfree (temp);
+ temp = new_event;
+
+ failed = 0;
+@@ -844,8 +847,8 @@ history_expand_internal (string, start,
+ continue; /* don't want to increment i */
+
+ *ret_string = hist_error (string, starting_index, i, SUBST_FAILED);
+- free (result);
+- free (temp);
++ xfree (result);
++ xfree (temp);
+ return (-1);
+ }
+ }
+@@ -866,7 +869,7 @@ history_expand_internal (string, start,
+ else
+ x = savestring (temp);
+
+- free (temp);
++ xfree (temp);
+ temp = x;
+ }
+
+@@ -874,7 +877,7 @@ history_expand_internal (string, start,
+ if (n >= result_len)
+ result = (char *)xrealloc (result, n + 2);
+ strcpy (result, temp);
+- free (temp);
++ xfree (temp);
+
+ *end_index_ptr = i;
+ *ret_string = result;
+@@ -925,7 +928,7 @@ history_expand (hstring, output)
+ char **output;
+ {
+ register int j;
+- int i, r, l, passc, cc, modified, eindex, only_printing, dquote;
++ int i, r, l, passc, cc, modified, eindex, only_printing, dquote, flag;
+ char *string;
+
+ /* The output string, and its length. */
+@@ -1017,7 +1020,7 @@ history_expand (hstring, output)
+ }
+ else if (string[i] == history_expansion_char)
+ {
+- if (!cc || member (cc, history_no_expand_chars))
++ if (cc == 0 || member (cc, history_no_expand_chars))
+ continue;
+ /* If the calling application has set
+ history_inhibit_expansion_function to a function that checks
+@@ -1045,8 +1048,9 @@ history_expand (hstring, output)
+ else if (dquote == 0 && history_quotes_inhibit_expansion && string[i] == '\'')
+ {
+ /* If this is bash, single quotes inhibit history expansion. */
++ flag = (i > 0 && string[i - 1] == '$');
+ i++;
+- hist_string_extract_single_quoted (string, &i);
++ hist_string_extract_single_quoted (string, &i, flag);
+ }
+ else if (history_quotes_inhibit_expansion && string[i] == '\\')
+ {
+@@ -1060,7 +1064,7 @@ history_expand (hstring, output)
+
+ if (string[i] != history_expansion_char)
+ {
+- free (result);
++ xfree (result);
+ *output = savestring (string);
+ return (0);
+ }
+@@ -1097,7 +1101,7 @@ history_expand (hstring, output)
+ if (strlen (mb) > 1)
+ {
+ ADD_STRING (mb);
+- break;
++ continue;
+ }
+ }
+ #endif /* HANDLE_MULTIBYTE */
+@@ -1131,15 +1135,16 @@ history_expand (hstring, output)
+ {
+ int quote, slen;
+
++ flag = (i > 0 && string[i - 1] == '$');
+ quote = i++;
+- hist_string_extract_single_quoted (string, &i);
++ hist_string_extract_single_quoted (string, &i, flag);
+
+ slen = i - quote + 2;
+ temp = (char *)xmalloc (slen);
+ strncpy (temp, string + quote, slen);
+ temp[slen - 1] = '\0';
+ ADD_STRING (temp);
+- free (temp);
++ xfree (temp);
+ }
+ else
+ ADD_CHAR (string[i]);
+@@ -1152,7 +1157,7 @@ history_expand (hstring, output)
+ temp = (char *)xmalloc (l - i + 1);
+ strcpy (temp, string + i);
+ ADD_STRING (temp);
+- free (temp);
++ xfree (temp);
+ i = l;
+ }
+ else
+@@ -1165,7 +1170,8 @@ history_expand (hstring, output)
+ /* If the history_expansion_char is followed by one of the
+ characters in history_no_expand_chars, then it is not a
+ candidate for expansion of any kind. */
+- if (member (cc, history_no_expand_chars))
++ if (cc == 0 || member (cc, history_no_expand_chars) ||
++ (history_inhibit_expansion_function && (*history_inhibit_expansion_function) (string, i)))
+ {
+ ADD_CHAR (string[i]);
+ break;
+@@ -1184,7 +1190,7 @@ history_expand (hstring, output)
+ temp = (char *)xmalloc (1 + strlen (result));
+ strcpy (temp, result);
+ ADD_STRING (temp);
+- free (temp);
++ xfree (temp);
+ }
+ i++;
+ break;
+@@ -1195,9 +1201,9 @@ history_expand (hstring, output)
+ if (r < 0)
+ {
+ *output = temp;
+- free (result);
++ xfree (result);
+ if (string != hstring)
+- free (string);
++ xfree (string);
+ return -1;
+ }
+ else
+@@ -1207,7 +1213,7 @@ history_expand (hstring, output)
+ modified++;
+ if (*temp)
+ ADD_STRING (temp);
+- free (temp);
++ xfree (temp);
+ }
+ only_printing = r == 1;
+ i = eindex;
+@@ -1218,7 +1224,7 @@ history_expand (hstring, output)
+
+ *output = result;
+ if (string != hstring)
+- free (string);
++ xfree (string);
+
+ if (only_printing)
+ {
+@@ -1399,8 +1405,8 @@ history_arg_extract (first, last, string
+ }
+
+ for (i = 0; i < len; i++)
+- free (list[i]);
+- free (list);
++ xfree (list[i]);
++ xfree (list);
+
+ return (result);
+ }
+@@ -1411,10 +1417,10 @@ history_tokenize_word (string, ind)
+ int ind;
+ {
+ register int i;
+- int delimiter;
++ int delimiter, nestdelim, delimopen;
+
+ i = ind;
+- delimiter = 0;
++ delimiter = nestdelim = 0;
+
+ if (member (string[i], "()\n"))
+ {
+@@ -1430,20 +1436,34 @@ history_tokenize_word (string, ind)
+ {
+ if (peek == '<' && string[i + 2] == '-')
+ i++;
++ else if (peek == '<' && string[i + 2] == '<')
++ i++;
+ i += 2;
+ return i;
+ }
+- else
++ else if ((peek == '&' && (string[i] == '>' || string[i] == '<')) ||
++ (peek == '>' && string[i] == '&'))
+ {
+- if ((peek == '&' && (string[i] == '>' || string[i] == '<')) ||
+- (peek == '>' && string[i] == '&') ||
+- (peek == '(' && (string[i] == '>' || string[i] == '<')) || /* ) */
+- (peek == '(' && string[i] == '$')) /* ) */
+- {
+- i += 2;
+- return i;
+- }
++ i += 2;
++ return i;
++ }
++ /* XXX - separated out for later -- bash-4.2 */
++ else if ((peek == '(' && (string[i] == '>' || string[i] == '<')) || /* ) */
++ (peek == '(' && string[i] == '$')) /*)*/
++ {
++ i += 2;
++ delimopen = '(';
++ delimiter = ')';
++ nestdelim = 1;
++ goto get_word;
+ }
++#if 0
++ else if (peek == '\'' && string[i] == '$')
++ {
++ i += 2; /* XXX */
++ return i;
++ }
++#endif
+
+ if (string[i] != '$')
+ {
+@@ -1452,9 +1472,25 @@ history_tokenize_word (string, ind)
+ }
+ }
+
++ /* same code also used for $(...)/<(...)/>(...) above */
++ if (member (string[i], "!@?+*"))
++ {
++ int peek = string[i + 1];
++
++ if (peek == '(') /*)*/
++ {
++ /* Shell extended globbing patterns */
++ i += 2;
++ delimopen = '(';
++ delimiter = ')'; /* XXX - not perfect */
++ nestdelim = 1;
++ }
++ }
++
++get_word:
+ /* Get word from string + i; */
+
+- if (member (string[i], HISTORY_QUOTE_CHARACTERS))
++ if (delimiter == 0 && member (string[i], HISTORY_QUOTE_CHARACTERS))
+ delimiter = string[i++];
+
+ for (; string[i]; i++)
+@@ -1472,16 +1508,31 @@ history_tokenize_word (string, ind)
+ continue;
+ }
+
++ /* delimiter must be set and set to something other than a quote if
++ nestdelim is set, so these tests are safe. */
++ if (nestdelim && string[i] == delimopen)
++ {
++ nestdelim++;
++ continue;
++ }
++ if (nestdelim && string[i] == delimiter)
++ {
++ nestdelim--;
++ if (nestdelim == 0)
++ delimiter = 0;
++ continue;
++ }
++
+ if (delimiter && string[i] == delimiter)
+ {
+ delimiter = 0;
+ continue;
+ }
+
+- if (!delimiter && (member (string[i], history_word_delimiters)))
++ if (delimiter == 0 && (member (string[i], history_word_delimiters)))
+ break;
+
+- if (!delimiter && member (string[i], HISTORY_QUOTE_CHARACTERS))
++ if (delimiter == 0 && member (string[i], HISTORY_QUOTE_CHARACTERS))
+ delimiter = string[i];
+ }
+
+@@ -1569,6 +1620,18 @@ history_tokenize (string)
+ return (history_tokenize_internal (string, -1, (int *)NULL));
+ }
+
++/* Free members of WORDS from START to an empty string */
++static void
++freewords (words, start)
++ char **words;
++ int start;
++{
++ register int i;
++
++ for (i = start; words[i]; i++)
++ xfree (words[i]);
++}
++
+ /* Find and return the word which contains the character at index IND
+ in the history line LINE. Used to save the word matched by the
+ last history !?string? search. */
+@@ -1582,12 +1645,16 @@ history_find_word (line, ind)
+
+ words = history_tokenize_internal (line, ind, &wind);
+ if (wind == -1 || words == 0)
+- return ((char *)NULL);
++ {
++ if (words)
++ freewords (words, 0);
++ FREE (words);
++ return ((char *)NULL);
++ }
+ s = words[wind];
+ for (i = 0; i < wind; i++)
+- free (words[i]);
+- for (i = wind + 1; words[i]; i++)
+- free (words[i]);
+- free (words);
++ xfree (words[i]);
++ freewords (words, wind + 1);
++ xfree (words);
+ return s;
+ }
+Index: gdb-7.2.90.20110703/readline/histfile.c
+===================================================================
+--- gdb-7.2.90.20110703.orig/readline/histfile.c 2011-07-03 10:40:53.000000000 +0200
++++ gdb-7.2.90.20110703/readline/histfile.c 2011-07-03 10:41:21.000000000 +0200
+@@ -1,24 +1,23 @@
+ /* histfile.c - functions to manipulate the history file. */
+
+-/* Copyright (C) 1989-2003 Free Software Foundation, Inc.
++/* Copyright (C) 1989-2010 Free Software Foundation, Inc.
+
+- This file contains the GNU History Library (the Library), a set of
++ This file contains the GNU History Library (History), a set of
+ routines for managing the text of previously typed lines.
+
+- The Library is free software; you can redistribute it and/or modify
++ History is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+- the Free Software Foundation; either version 2, or (at your option)
+- any later version.
++ the Free Software Foundation, either version 3 of the License, or
++ (at your option) any later version.
+
+- The Library is distributed in the hope that it will be useful, but
+- WITHOUT ANY WARRANTY; without even the implied warranty of
+- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+- General Public License for more details.
+-
+- The GNU General Public License is often shipped with GNU software, and
+- is generally kept in a file called COPYING or LICENSE. If you do not
+- have a copy of the license, write to the Free Software Foundation,
+- 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
++ History 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 History. If not, see <http://www.gnu.org/licenses/>.
++*/
+
+ /* The goal is to make the implementation transparent, so that you
+ don't have to know what data types are used, just what functions
+@@ -53,7 +52,9 @@
+ # include <unistd.h>
+ #endif
+
+-#if defined (__EMX__) || defined (__CYGWIN__)
++#include <ctype.h>
++
++#if defined (__EMX__)
+ # undef HAVE_MMAP
+ #endif
+
+@@ -103,7 +104,7 @@ int history_write_timestamps = 0;
+
+ /* Does S look like the beginning of a history timestamp entry? Placeholder
+ for more extensive tests. */
+-#define HIST_TIMESTAMP_START(s) (*(s) == history_comment_char)
++#define HIST_TIMESTAMP_START(s) (*(s) == history_comment_char && isdigit ((s)[1]) )
+
+ /* Return the string that should be used in the place of this
+ filename. This only matters when you don't specify the
+@@ -125,8 +126,12 @@ history_filename (filename)
+
+ if (home == 0)
+ {
++#if 0
+ home = ".";
+ home_len = 1;
++#else
++ return (NULL);
++#endif
+ }
+ else
+ home_len = strlen (home);
+@@ -178,7 +183,7 @@ read_history_range (filename, from, to)
+
+ buffer = last_ts = (char *)NULL;
+ input = history_filename (filename);
+- file = open (input, O_RDONLY|O_BINARY, 0666);
++ file = input ? open (input, O_RDONLY|O_BINARY, 0666) : -1;
+
+ if ((file < 0) || (fstat (file, &finfo) == -1))
+ goto error_and_exit;
+@@ -256,8 +261,9 @@ read_history_range (filename, from, to)
+ for (line_end = line_start; line_end < bufend; line_end++)
+ if (*line_end == '\n')
+ {
+- if (line_end - 1 >= line_start && *(line_end - 1) == '\r')
+- *(line_end - 1) = '\0';
++ /* Change to allow Windows-like \r\n end of line delimiter. */
++ if (line_end > line_start && line_end[-1] == '\r')
++ line_end[-1] = '\0';
+ else
+ *line_end = '\0';
+
+@@ -312,7 +318,7 @@ history_truncate_file (fname, lines)
+
+ buffer = (char *)NULL;
+ filename = history_filename (fname);
+- file = open (filename, O_RDONLY|O_BINARY, 0666);
++ file = filename ? open (filename, O_RDONLY|O_BINARY, 0666) : -1;
+ rv = 0;
+
+ /* Don't try to truncate non-regular files. */
+@@ -411,7 +417,7 @@ history_truncate_file (fname, lines)
+
+ FREE (buffer);
+
+- free (filename);
++ xfree (filename);
+ return rv;
+ }
+
+@@ -434,9 +440,10 @@ history_do_write (filename, nelements, o
+ mode = overwrite ? O_WRONLY|O_CREAT|O_TRUNC|O_BINARY : O_WRONLY|O_APPEND|O_BINARY;
+ #endif
+ output = history_filename (filename);
++ file = output ? open (output, mode, 0600) : -1;
+ rv = 0;
+
+- if ((file = open (output, mode, 0600)) == -1)
++ if (file == -1)
+ {
+ FREE (output);
+ return (errno);
+@@ -513,7 +520,7 @@ mmap_error:
+ #else
+ if (write (file, buffer, buffer_size) < 0)
+ rv = errno;
+- free (buffer);
++ xfree (buffer);
+ #endif
+ }
+
+Index: gdb-7.2.90.20110703/readline/histlib.h
+===================================================================
+--- gdb-7.2.90.20110703.orig/readline/histlib.h 2011-07-03 10:40:53.000000000 +0200
++++ gdb-7.2.90.20110703/readline/histlib.h 2011-07-03 10:41:21.000000000 +0200
+@@ -1,23 +1,23 @@
+ /* histlib.h -- internal definitions for the history library. */
+-/* Copyright (C) 1989, 1992 Free Software Foundation, Inc.
+
+- This file contains the GNU History Library (the Library), a set of
++/* Copyright (C) 1989-2009 Free Software Foundation, Inc.
++
++ This file contains the GNU History Library (History), a set of
+ routines for managing the text of previously typed lines.
+
+- The Library is free software; you can redistribute it and/or modify
++ History is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+- the Free Software Foundation; either version 2, or (at your option)
+- any later version.
++ the Free Software Foundation, either version 3 of the License, or
++ (at your option) any later version.
+
+- The Library is distributed in the hope that it will be useful, but
+- WITHOUT ANY WARRANTY; without even the implied warranty of
+- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+- General Public License for more details.
+-
+- The GNU General Public License is often shipped with GNU software, and
+- is generally kept in a file called COPYING or LICENSE. If you do not
+- have a copy of the license, write to the Free Software Foundation,
+- 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
++ History 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 History. If not, see <http://www.gnu.org/licenses/>.
++*/
+
+ #if !defined (_HISTLIB_H_)
+ #define _HISTLIB_H_
+Index: gdb-7.2.90.20110703/readline/history.c
+===================================================================
+--- gdb-7.2.90.20110703.orig/readline/history.c 2011-07-03 10:40:53.000000000 +0200
++++ gdb-7.2.90.20110703/readline/history.c 2011-07-03 10:41:21.000000000 +0200
+@@ -1,24 +1,23 @@
+ /* history.c -- standalone history library */
+
+-/* Copyright (C) 1989-2005 Free Software Foundation, Inc.
++/* Copyright (C) 1989-2009 Free Software Foundation, Inc.
+
+- This file contains the GNU History Library (the Library), a set of
++ This file contains the GNU History Library (History), a set of
+ routines for managing the text of previously typed lines.
+
+- The Library is free software; you can redistribute it and/or modify
++ History is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+- the Free Software Foundation; either version 2, or (at your option)
+- any later version.
++ the Free Software Foundation, either version 3 of the License, or
++ (at your option) any later version.
+
+- The Library is distributed in the hope that it will be useful, but
+- WITHOUT ANY WARRANTY; without even the implied warranty of
+- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+- General Public License for more details.
+-
+- The GNU General Public License is often shipped with GNU software, and
+- is generally kept in a file called COPYING or LICENSE. If you do not
+- have a copy of the license, write to the Free Software Foundation,
+- 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
++ History 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 History. If not, see <http://www.gnu.org/licenses/>.
++*/
+
+ /* The goal is to make the implementation transparent, so that you
+ don't have to know what data types are used, just what functions
+@@ -158,7 +157,7 @@ history_set_pos (pos)
+ return (1);
+ }
+
+-/* Return the current history array. The caller has to be carefull, since this
++/* Return the current history array. The caller has to be careful, since this
+ is the actual array of data, and could be bashed or made corrupt easily.
+ The array is terminated with a NULL pointer. */
+ HIST_ENTRY **
+@@ -209,6 +208,22 @@ history_get (offset)
+ : the_history[local_index];
+ }
+
++HIST_ENTRY *
++alloc_history_entry (string, ts)
++ char *string;
++ char *ts;
++{
++ HIST_ENTRY *temp;
++
++ temp = (HIST_ENTRY *)xmalloc (sizeof (HIST_ENTRY));
++
++ temp->line = string ? savestring (string) : string;
++ temp->data = (char *)NULL;
++ temp->timestamp = ts;
++
++ return temp;
++}
++
+ time_t
+ history_get_time (hist)
+ HIST_ENTRY *hist;
+@@ -290,11 +305,7 @@ add_history (string)
+ }
+ }
+
+- temp = (HIST_ENTRY *)xmalloc (sizeof (HIST_ENTRY));
+- temp->line = savestring (string);
+- temp->data = (char *)NULL;
+-
+- temp->timestamp = hist_inittime ();
++ temp = alloc_history_entry (string, hist_inittime ());
+
+ the_history[history_length] = (HIST_ENTRY *)NULL;
+ the_history[history_length - 1] = temp;
+@@ -307,6 +318,8 @@ add_history_time (string)
+ {
+ HIST_ENTRY *hs;
+
++ if (string == 0)
++ return;
+ hs = the_history[history_length - 1];
+ FREE (hs->timestamp);
+ hs->timestamp = savestring (string);
+@@ -325,9 +338,29 @@ free_history_entry (hist)
+ FREE (hist->line);
+ FREE (hist->timestamp);
+ x = hist->data;
+- free (hist);
++ xfree (hist);
+ return (x);
+ }
++
++HIST_ENTRY *
++copy_history_entry (hist)
++ HIST_ENTRY *hist;
++{
++ HIST_ENTRY *ret;
++ char *ts;
++
++ if (hist == 0)
++ return hist;
++
++ ret = alloc_history_entry (hist->line, (char *)NULL);
++
++ ts = hist->timestamp ? savestring (hist->timestamp) : hist->timestamp;
++ ret->timestamp = ts;
++
++ ret->data = hist->data;
++
++ return ret;
++}
+
+ /* Make the history entry at WHICH have LINE and DATA. This returns
+ the old entry so you can dispose of the data. In the case of an
+@@ -354,6 +387,51 @@ replace_history_entry (which, line, data
+ return (old_value);
+ }
+
++/* Replace the DATA in the specified history entries, replacing OLD with
++ NEW. WHICH says which one(s) to replace: WHICH == -1 means to replace
++ all of the history entries where entry->data == OLD; WHICH == -2 means
++ to replace the `newest' history entry where entry->data == OLD; and
++ WHICH >= 0 means to replace that particular history entry's data, as
++ long as it matches OLD. */
++void
++replace_history_data (which,old, new)
++ int which;
++ histdata_t *old, *new;
++{
++ HIST_ENTRY *entry;
++ register int i, last;
++
++ if (which < -2 || which >= history_length || history_length == 0 || the_history == 0)
++ return;
++
++ if (which >= 0)
++ {
++ entry = the_history[which];
++ if (entry && entry->data == old)
++ entry->data = new;
++ return;
++ }
++
++ last = -1;
++ for (i = 0; i < history_length; i++)
++ {
++ entry = the_history[i];
++ if (entry == 0)
++ continue;
++ if (entry->data == old)
++ {
++ last = i;
++ if (which == -1)
++ entry->data = new;
++ }
++ }
++ if (which == -2 && last >= 0)
++ {
++ entry = the_history[last];
++ entry->data = new; /* XXX - we don't check entry->old */
++ }
++}
++
+ /* Remove history element WHICH from the history. The removed
+ element is returned to you so you can free the line, data,
+ and containing structure. */
+@@ -406,7 +484,7 @@ stifle_history (max)
+
+ /* Stop stifling the history. This returns the previous maximum
+ number of history entries. The value is positive if the history
+- was stifled, negative if it wasn't. */
++ was stifled, negative if it wasn't. */
+ int
+ unstifle_history ()
+ {
+Index: gdb-7.2.90.20110703/readline/history.h
+===================================================================
+--- gdb-7.2.90.20110703.orig/readline/history.h 2011-07-03 10:40:53.000000000 +0200
++++ gdb-7.2.90.20110703/readline/history.h 2011-07-03 10:41:21.000000000 +0200
+@@ -1,23 +1,23 @@
+ /* history.h -- the names of functions that you can call in history. */
+-/* Copyright (C) 1989-2003 Free Software Foundation, Inc.
+
+- This file contains the GNU History Library (the Library), a set of
++/* Copyright (C) 1989-2009 Free Software Foundation, Inc.
++
++ This file contains the GNU History Library (History), a set of
+ routines for managing the text of previously typed lines.
+
+- The Library is free software; you can redistribute it and/or modify
++ History is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+- the Free Software Foundation; either version 2, or (at your option)
+- any later version.
++ the Free Software Foundation, either version 3 of the License, or
++ (at your option) any later version.
+
+- The Library is distributed in the hope that it will be useful, but
+- WITHOUT ANY WARRANTY; without even the implied warranty of
+- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+- General Public License for more details.
+-
+- The GNU General Public License is often shipped with GNU software, and
+- is generally kept in a file called COPYING or LICENSE. If you do not
+- have a copy of the license, write to the Free Software Foundation,
+- 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
++ History 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 History. If not, see <http://www.gnu.org/licenses/>.
++*/
+
+ #ifndef _HISTORY_H_
+ #define _HISTORY_H_
+Index: gdb-7.2.90.20110703/readline/histsearch.c
+===================================================================
+--- gdb-7.2.90.20110703.orig/readline/histsearch.c 2011-07-03 10:40:53.000000000 +0200
++++ gdb-7.2.90.20110703/readline/histsearch.c 2011-07-03 10:41:21.000000000 +0200
+@@ -1,24 +1,23 @@
+ /* histsearch.c -- searching the history list. */
+
+-/* Copyright (C) 1989, 1992 Free Software Foundation, Inc.
++/* Copyright (C) 1989, 1992-2009 Free Software Foundation, Inc.
+
+- This file contains the GNU History Library (the Library), a set of
++ This file contains the GNU History Library (History), a set of
+ routines for managing the text of previously typed lines.
+
+- The Library is free software; you can redistribute it and/or modify
++ History is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+- the Free Software Foundation; either version 2, or (at your option)
+- any later version.
++ the Free Software Foundation, either version 3 of the License, or
++ (at your option) any later version.
+
+- The Library is distributed in the hope that it will be useful, but
+- WITHOUT ANY WARRANTY; without even the implied warranty of
+- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+- General Public License for more details.
+-
+- The GNU General Public License is often shipped with GNU software, and
+- is generally kept in a file called COPYING or LICENSE. If you do not
+- have a copy of the license, write to the Free Software Foundation,
+- 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
++ History 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 History. If not, see <http://www.gnu.org/licenses/>.
++*/
+
+ #define READLINE_LIBRARY
+
+Index: gdb-7.2.90.20110703/readline/input.c
+===================================================================
+--- gdb-7.2.90.20110703.orig/readline/input.c 2011-07-03 10:40:53.000000000 +0200
++++ gdb-7.2.90.20110703/readline/input.c 2011-07-03 10:41:21.000000000 +0200
+@@ -1,24 +1,24 @@
+ /* input.c -- character input functions for readline. */
+
+-/* Copyright (C) 1994-2005 Free Software Foundation, Inc.
++/* Copyright (C) 1994-2010 Free Software Foundation, Inc.
+
+- This file is part of the GNU Readline Library, a library for
+- reading lines of text with interactive input and history editing.
++ This file is part of the GNU Readline Library (Readline), a library
++ for reading lines of text with interactive input and history editing.
+
+- The GNU Readline Library is free software; you can redistribute it
+- and/or modify it under the terms of the GNU General Public License
+- as published by the Free Software Foundation; either version 2, or
++ Readline 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.
+
+- The GNU Readline Library is distributed in the hope that it will be
+- useful, but WITHOUT ANY WARRANTY; without even the implied warranty
+- of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ Readline 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.
+
+- The GNU General Public License is often shipped with GNU software, and
+- is generally kept in a file called COPYING or LICENSE. If you do not
+- have a copy of the license, write to the Free Software Foundation,
+- 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
++ You should have received a copy of the GNU General Public License
++ along with Readline. If not, see <http://www.gnu.org/licenses/>.
++*/
++
+ #define READLINE_LIBRARY
+
+ #if defined (__TANDEM)
+@@ -45,14 +45,7 @@
+ # include "ansi_stdlib.h"
+ #endif /* HAVE_STDLIB_H */
+
+-#if defined (HAVE_SELECT)
+-# if !defined (HAVE_SYS_SELECT_H) || !defined (M_UNIX)
+-# include <sys/time.h>
+-# endif
+-#endif /* HAVE_SELECT */
+-#if defined (HAVE_SYS_SELECT_H)
+-# include <sys/select.h>
+-#endif
++#include "posixselect.h"
+
+ #if defined (FIONREAD_IN_SYS_IOCTL)
+ # include <sys/ioctl.h>
+@@ -133,8 +126,11 @@ rl_get_char (key)
+ return (0);
+
+ *key = ibuffer[pop_index++];
+-
++#if 0
+ if (pop_index >= ibuffer_len)
++#else
++ if (pop_index > ibuffer_len)
++#endif
+ pop_index = 0;
+
+ return (1);
+@@ -151,7 +147,7 @@ _rl_unget_char (key)
+ {
+ pop_index--;
+ if (pop_index < 0)
+- pop_index = ibuffer_len - 1;
++ pop_index = ibuffer_len;
+ ibuffer[pop_index] = key;
+ return (1);
+ }
+@@ -179,6 +175,7 @@ rl_gather_tyi ()
+ struct timeval timeout;
+ #endif
+
++ chars_avail = 0;
+ tty = fileno (rl_instream);
+
+ #if defined (HAVE_SELECT)
+@@ -186,8 +183,7 @@ rl_gather_tyi ()
+ FD_ZERO (&exceptfds);
+ FD_SET (tty, &readfds);
+ FD_SET (tty, &exceptfds);
+- timeout.tv_sec = 0;
+- timeout.tv_usec = _keyboard_input_timeout;
++ USEC_TO_TIMEVAL (_keyboard_input_timeout, timeout);
+ result = select (tty + 1, &readfds, (fd_set *)NULL, &exceptfds, &timeout);
+ if (result <= 0)
+ return 0; /* Nothing to read. */
+@@ -221,13 +217,10 @@ rl_gather_tyi ()
+ #endif /* O_NDELAY */
+
+ #if defined (__MINGW32__)
+- /* We use getch to read console input, so use the same
+- mechanism to check for more. Otherwise, we don't know. */
+- if (isatty (fileno (rl_instream)))
+- chars_avail = _kbhit ();
+- else
+- chars_avail = 0;
+- result = 0;
++ /* Use getch/_kbhit to check for available console input, in the same way
++ that we read it normally. */
++ chars_avail = isatty (tty) ? _kbhit () : 0;
++ result = 0;
+ #endif
+
+ /* If there's nothing available, don't waste time trying to read
+@@ -251,8 +244,10 @@ rl_gather_tyi ()
+ {
+ while (chars_avail--)
+ {
++ RL_CHECK_SIGNALS ();
+ k = (*rl_getc_function) (rl_instream);
+- rl_stuff_char (k);
++ if (rl_stuff_char (k) == 0)
++ break; /* some problem; no more room */
+ if (k == NEWLINE || k == RETURN)
+ break;
+ }
+@@ -273,7 +268,7 @@ rl_set_keyboard_input_timeout (u)
+ int o;
+
+ o = _keyboard_input_timeout;
+- if (u > 0)
++ if (u >= 0)
+ _keyboard_input_timeout = u;
+ return (o);
+ }
+@@ -316,10 +311,8 @@ _rl_input_available ()
+ #endif
+
+ #if defined (__MINGW32__)
+- /* We use getch to read console input, so use the same
+- mechanism to check for more. Otherwise, we don't know. */
+- if (isatty (fileno (rl_instream)))
+- return _kbhit ();
++ if (isatty (tty))
++ return (_kbhit ());
+ #endif
+
+ return 0;
+@@ -358,7 +351,7 @@ _rl_insert_typein (c)
+
+ string[i] = '\0';
+ rl_insert_text (string);
+- free (string);
++ xfree (string);
+ }
+
+ /* Add KEY to the buffer of characters to be read. Returns 1 if the
+@@ -377,7 +370,11 @@ rl_stuff_char (key)
+ RL_SETSTATE (RL_STATE_INPUTPENDING);
+ }
+ ibuffer[push_index++] = key;
++#if 0
+ if (push_index >= ibuffer_len)
++#else
++ if (push_index > ibuffer_len)
++#endif
+ push_index = 0;
+
+ return 1;
+@@ -430,22 +427,26 @@ rl_read_key ()
+ /* If the user has an event function, then call it periodically. */
+ if (rl_event_hook)
+ {
+- while (rl_event_hook && rl_get_char (&c) == 0)
++ while (rl_event_hook)
+ {
+- (*rl_event_hook) ();
+- if (rl_done) /* XXX - experimental */
+- return ('\n');
+ if (rl_gather_tyi () < 0) /* XXX - EIO */
+ {
+ rl_done = 1;
+ return ('\n');
+ }
++ RL_CHECK_SIGNALS ();
++ if (rl_get_char (&c) != 0)
++ break;
++ if (rl_done) /* XXX - experimental */
++ return ('\n');
++ (*rl_event_hook) ();
+ }
+ }
+ else
+ {
+ if (rl_get_char (&c) == 0)
+ c = (*rl_getc_function) (rl_instream);
++ RL_CHECK_SIGNALS ();
+ }
+ }
+
+@@ -461,6 +462,8 @@ rl_getc (stream)
+
+ while (1)
+ {
++ RL_CHECK_SIGNALS ();
++
+ #if defined (__MINGW32__)
+ if (isatty (fileno (stream)))
+ return (getch ());
+@@ -506,7 +509,7 @@ rl_getc (stream)
+ this is simply an interrupted system call to read ().
+ Otherwise, some error ocurred, also signifying EOF. */
+ if (errno != EINTR)
+- return (EOF);
++ return (RL_ISSTATE (RL_STATE_READCMD) ? READERR : EOF);
+ }
+ }
+
+@@ -517,20 +520,26 @@ _rl_read_mbchar (mbchar, size)
+ char *mbchar;
+ int size;
+ {
+- int mb_len = 0;
++ int mb_len, c;
+ size_t mbchar_bytes_length;
+ wchar_t wc;
+ mbstate_t ps, ps_back;
+
+ memset(&ps, 0, sizeof (mbstate_t));
+ memset(&ps_back, 0, sizeof (mbstate_t));
+-
++
++ mb_len = 0;
+ while (mb_len < size)
+ {
+ RL_SETSTATE(RL_STATE_MOREINPUT);
+- mbchar[mb_len++] = rl_read_key ();
++ c = rl_read_key ();
+ RL_UNSETSTATE(RL_STATE_MOREINPUT);
+
++ if (c < 0)
++ break;
++
++ mbchar[mb_len++] = c;
++
+ mbchar_bytes_length = mbrtowc (&wc, mbchar, mb_len, &ps);
+ if (mbchar_bytes_length == (size_t)(-1))
+ break; /* invalid byte sequence for the current locale */
+@@ -554,21 +563,21 @@ _rl_read_mbchar (mbchar, size)
+ }
+
+ /* Read a multibyte-character string whose first character is FIRST into
+- the buffer MB of length MBLEN. Returns the last character read, which
++ the buffer MB of length MLEN. Returns the last character read, which
+ may be FIRST. Used by the search functions, among others. Very similar
+ to _rl_read_mbchar. */
+ int
+-_rl_read_mbstring (first, mb, mblen)
++_rl_read_mbstring (first, mb, mlen)
+ int first;
+ char *mb;
+- int mblen;
++ int mlen;
+ {
+ int i, c;
+ mbstate_t ps;
+
+ c = first;
+- memset (mb, 0, mblen);
+- for (i = 0; i < mblen; i++)
++ memset (mb, 0, mlen);
++ for (i = 0; c >= 0 && i < mlen; i++)
+ {
+ mb[i] = (char)c;
+ memset (&ps, 0, sizeof (mbstate_t));
+Index: gdb-7.2.90.20110703/readline/isearch.c
+===================================================================
+--- gdb-7.2.90.20110703.orig/readline/isearch.c 2011-07-03 10:40:53.000000000 +0200
++++ gdb-7.2.90.20110703/readline/isearch.c 2011-07-03 10:41:21.000000000 +0200
+@@ -1,29 +1,30 @@
++/* isearch.c - incremental searching */
++
+ /* **************************************************************** */
+ /* */
+ /* I-Search and Searching */
+ /* */
+ /* **************************************************************** */
+
+-/* Copyright (C) 1987-2005 Free Software Foundation, Inc.
++/* Copyright (C) 1987-2009 Free Software Foundation, Inc.
+
+- This file contains the Readline Library (the Library), a set of
+- routines for providing Emacs style line input to programs that ask
+- for it.
++ This file is part of the GNU Readline Library (Readline), a library
++ for reading lines of text with interactive input and history editing.
+
+- The Library is free software; you can redistribute it and/or modify
++ Readline is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+- the Free Software Foundation; either version 2, or (at your option)
+- any later version.
++ the Free Software Foundation, either version 3 of the License, or
++ (at your option) any later version.
++
++ Readline 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 Readline. If not, see <http://www.gnu.org/licenses/>.
++*/
+
+- The Library is distributed in the hope that it will be useful, but
+- WITHOUT ANY WARRANTY; without even the implied warranty of
+- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+- General Public License for more details.
+-
+- The GNU General Public License is often shipped with GNU software, and
+- is generally kept in a file called COPYING or LICENSE. If you do not
+- have a copy of the license, write to the Free Software Foundation,
+- 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
+ #define READLINE_LIBRARY
+
+ #if defined (HAVE_CONFIG_H)
+@@ -68,14 +69,14 @@ static void _rl_isearch_fini PARAMS((_rl
+ static int _rl_isearch_cleanup PARAMS((_rl_search_cxt *, int));
+
+ /* Last line found by the current incremental search, so we don't `find'
+- identical lines many times in a row. */
+-static char *prev_line_found;
++ identical lines many times in a row. Now part of isearch context. */
++/* static char *prev_line_found; */
+
+ /* Last search string and its length. */
+ static char *last_isearch_string;
+ static int last_isearch_string_len;
+
+-static char *default_isearch_terminators = "\033\012";
++static char * const default_isearch_terminators = "\033\012";
+
+ _rl_search_cxt *
+ _rl_scxt_alloc (type, flags)
+@@ -103,6 +104,9 @@ _rl_scxt_alloc (type, flags)
+
+ cxt->save_undo_list = 0;
+
++ cxt->keymap = _rl_keymap;
++ cxt->okeymap = _rl_keymap;
++
+ cxt->history_pos = 0;
+ cxt->direction = 0;
+
+@@ -125,7 +129,7 @@ _rl_scxt_dispose (cxt, flags)
+ FREE (cxt->allocated_line);
+ FREE (cxt->lines);
+
+- free (cxt);
++ xfree (cxt);
+ }
+
+ /* Search backwards through the history looking for a string which is typed
+@@ -192,7 +196,7 @@ rl_display_search (search_string, revers
+ strcpy (message + msglen, "': ");
+
+ rl_message ("%s", message);
+- free (message);
++ xfree (message);
+ (*rl_redisplay_function) ();
+ }
+
+@@ -327,11 +331,30 @@ _rl_isearch_dispatch (cxt, c)
+ rl_command_func_t *f;
+
+ f = (rl_command_func_t *)NULL;
+-
+- /* Translate the keys we do something with to opcodes. */
+- if (c >= 0 && _rl_keymap[c].type == ISFUNC)
++
++ if (c < 0)
+ {
+- f = _rl_keymap[c].function;
++ cxt->sflags |= SF_FAILED;
++ cxt->history_pos = cxt->last_found_line;
++ return -1;
++ }
++
++ /* If we are moving into a new keymap, modify cxt->keymap and go on.
++ This can be a problem if c == ESC and we want to terminate the
++ incremental search, so we check */
++ if (c >= 0 && cxt->keymap[c].type == ISKMAP && strchr (cxt->search_terminators, cxt->lastc) == 0)
++ {
++ cxt->keymap = FUNCTION_TO_KEYMAP (cxt->keymap, c);
++ cxt->sflags |= SF_CHGKMAP;
++ /* XXX - we should probably save this sequence, so we can do
++ something useful if this doesn't end up mapping to a command. */
++ return 1;
++ }
++
++ /* Translate the keys we do something with to opcodes. */
++ if (c >= 0 && cxt->keymap[c].type == ISFUNC)
++ {
++ f = cxt->keymap[c].function;
+
+ if (f == rl_reverse_search_history)
+ cxt->lastc = (cxt->sflags & SF_REVERSE) ? -1 : -2;
+@@ -339,19 +362,27 @@ _rl_isearch_dispatch (cxt, c)
+ cxt->lastc = (cxt->sflags & SF_REVERSE) ? -2 : -1;
+ else if (f == rl_rubout)
+ cxt->lastc = -3;
+- else if (c == CTRL ('G'))
++ else if (c == CTRL ('G') || f == rl_abort)
+ cxt->lastc = -4;
+- else if (c == CTRL ('W')) /* XXX */
++ else if (c == CTRL ('W') || f == rl_unix_word_rubout) /* XXX */
+ cxt->lastc = -5;
+- else if (c == CTRL ('Y')) /* XXX */
++ else if (c == CTRL ('Y') || f == rl_yank) /* XXX */
+ cxt->lastc = -6;
+ }
+
++ /* If we changed the keymap earlier while translating a key sequence into
++ a command, restore it now that we've succeeded. */
++ if (cxt->sflags & SF_CHGKMAP)
++ {
++ cxt->keymap = cxt->okeymap;
++ cxt->sflags &= ~SF_CHGKMAP;
++ }
++
+ /* The characters in isearch_terminators (set from the user-settable
+ variable isearch-terminators) are used to terminate the search but
+ not subsequently execute the character as a command. The default
+ value is "\033\012" (ESC and C-J). */
+- if (strchr (cxt->search_terminators, cxt->lastc))
++ if (cxt->lastc > 0 && strchr (cxt->search_terminators, cxt->lastc))
+ {
+ /* ESC still terminates the search, but if there is pending
+ input or if input arrives within 0.1 seconds (on systems
+@@ -375,7 +406,7 @@ _rl_isearch_dispatch (cxt, c)
+ {
+ if (cxt->lastc >= 0 && (cxt->mb[0] && cxt->mb[1] == '\0') && ENDSRCH_CHAR (cxt->lastc))
+ {
+- /* This sets rl_pending_input to c; it will be picked up the next
++ /* This sets rl_pending_input to LASTC; it will be picked up the next
+ time rl_read_key is called. */
+ rl_execute_next (cxt->lastc);
+ return (0);
+Index: gdb-7.2.90.20110703/readline/keymaps.c
+===================================================================
+--- gdb-7.2.90.20110703.orig/readline/keymaps.c 2011-07-03 10:40:53.000000000 +0200
++++ gdb-7.2.90.20110703/readline/keymaps.c 2011-07-03 10:41:21.000000000 +0200
+@@ -1,23 +1,24 @@
+ /* keymaps.c -- Functions and keymaps for the GNU Readline library. */
+
+-/* Copyright (C) 1988,1989 Free Software Foundation, Inc.
++/* Copyright (C) 1988,1989-2009 Free Software Foundation, Inc.
+
+- This file is part of GNU Readline, a library for reading lines
+- of text with interactive input and history editing.
++ This file is part of the GNU Readline Library (Readline), a library
++ for reading lines of text with interactive input and history editing.
+
+- Readline is free software; you can redistribute it and/or modify it
+- under the terms of the GNU General Public License as published by the
+- Free Software Foundation; either version 2, or (at your option) any
+- later version.
+-
+- Readline 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.
++ Readline 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.
++
++ Readline 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 Readline; see the file COPYING. If not, write to the Free
+- Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
++ along with Readline. If not, see <http://www.gnu.org/licenses/>.
++*/
++
+ #define READLINE_LIBRARY
+
+ #if defined (HAVE_CONFIG_H)
+@@ -56,8 +57,9 @@ Keymap
+ rl_make_bare_keymap ()
+ {
+ register int i;
+- Keymap keymap = (Keymap)xmalloc (KEYMAP_SIZE * sizeof (KEYMAP_ENTRY));
++ Keymap keymap;
+
++ keymap = (Keymap)xmalloc (KEYMAP_SIZE * sizeof (KEYMAP_ENTRY));
+ for (i = 0; i < KEYMAP_SIZE; i++)
+ {
+ keymap[i].type = ISFUNC;
+@@ -75,7 +77,8 @@ rl_make_bare_keymap ()
+ return (keymap);
+ }
+
+-/* Return a new keymap which is a copy of MAP. */
++/* Return a new keymap which is a copy of MAP. Just copies pointers, does
++ not copy text of macros or descend into child keymaps. */
+ Keymap
+ rl_copy_keymap (map)
+ Keymap map;
+@@ -127,7 +130,7 @@ rl_discard_keymap (map)
+ {
+ int i;
+
+- if (!map)
++ if (map == 0)
+ return;
+
+ for (i = 0; i < KEYMAP_SIZE; i++)
+@@ -139,11 +142,21 @@ rl_discard_keymap (map)
+
+ case ISKMAP:
+ rl_discard_keymap ((Keymap)map[i].function);
++ xfree ((char *)map[i].function);
+ break;
+
+ case ISMACR:
+- free ((char *)map[i].function);
++ xfree ((char *)map[i].function);
+ break;
+ }
+ }
+ }
++
++/* Convenience function that discards, then frees, MAP. */
++void
++rl_free_keymap (map)
++ Keymap map;
++{
++ rl_discard_keymap (map);
++ xfree ((char *)map);
++}
+Index: gdb-7.2.90.20110703/readline/keymaps.h
+===================================================================
+--- gdb-7.2.90.20110703.orig/readline/keymaps.h 2011-07-03 10:40:53.000000000 +0200
++++ gdb-7.2.90.20110703/readline/keymaps.h 2011-07-03 10:41:21.000000000 +0200
+@@ -2,23 +2,22 @@
+
+ /* Copyright (C) 1987, 1989, 1992 Free Software Foundation, Inc.
+
+- This file is part of the GNU Readline Library, a library for
+- reading lines of text with interactive input and history editing.
++ This file is part of the GNU Readline Library (Readline), a library
++ for reading lines of text with interactive input and history editing.
+
+- The GNU Readline Library is free software; you can redistribute it
+- and/or modify it under the terms of the GNU General Public License
+- as published by the Free Software Foundation; either version 2, or
++ Readline 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.
+
+- The GNU Readline Library is distributed in the hope that it will be
+- useful, but WITHOUT ANY WARRANTY; without even the implied warranty
+- of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ Readline 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.
+
+- The GNU General Public License is often shipped with GNU software, and
+- is generally kept in a file called COPYING or LICENSE. If you do not
+- have a copy of the license, write to the Free Software Foundation,
+- 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
++ You should have received a copy of the GNU General Public License
++ along with Readline. If not, see <http://www.gnu.org/licenses/>.
++*/
+
+ #ifndef _KEYMAPS_H_
+ #define _KEYMAPS_H_
+@@ -53,11 +52,6 @@ typedef struct _keymap_entry {
+ #define KEYMAP_SIZE 257
+ #define ANYOTHERKEY KEYMAP_SIZE-1
+
+-/* I wanted to make the above structure contain a union of:
+- union { rl_command_func_t *function; struct _keymap_entry *keymap; } value;
+- but this made it impossible for me to create a static array.
+- Maybe I need C lessons. */
+-
+ typedef KEYMAP_ENTRY KEYMAP_ENTRY_ARRAY[KEYMAP_SIZE];
+ typedef KEYMAP_ENTRY *Keymap;
+
+Index: gdb-7.2.90.20110703/readline/kill.c
+===================================================================
+--- gdb-7.2.90.20110703.orig/readline/kill.c 2011-07-03 10:40:53.000000000 +0200
++++ gdb-7.2.90.20110703/readline/kill.c 2011-07-03 10:41:21.000000000 +0200
+@@ -2,23 +2,23 @@
+
+ /* Copyright (C) 1994 Free Software Foundation, Inc.
+
+- This file is part of the GNU Readline Library, a library for
+- reading lines of text with interactive input and history editing.
++ This file is part of the GNU Readline Library (Readline), a library
++ for reading lines of text with interactive input and history editing.
+
+- The GNU Readline Library is free software; you can redistribute it
+- and/or modify it under the terms of the GNU General Public License
+- as published by the Free Software Foundation; either version 2, or
++ Readline 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.
+
+- The GNU Readline Library is distributed in the hope that it will be
+- useful, but WITHOUT ANY WARRANTY; without even the implied warranty
+- of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ Readline 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.
+
+- The GNU General Public License is often shipped with GNU software, and
+- is generally kept in a file called COPYING or LICENSE. If you do not
+- have a copy of the license, write to the Free Software Foundation,
+- 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
++ You should have received a copy of the GNU General Public License
++ along with Readline. If not, see <http://www.gnu.org/licenses/>.
++*/
++
+ #define READLINE_LIBRARY
+
+ #if defined (HAVE_CONFIG_H)
+@@ -115,7 +115,7 @@ _rl_copy_to_kill_ring (text, append)
+ if (slot == rl_max_kills)
+ {
+ register int i;
+- free (rl_kill_ring[0]);
++ xfree (rl_kill_ring[0]);
+ for (i = 0; i < slot; i++)
+ rl_kill_ring[i] = rl_kill_ring[i + 1];
+ }
+@@ -146,8 +146,8 @@ _rl_copy_to_kill_ring (text, append)
+ strcpy (new, text);
+ strcat (new, old);
+ }
+- free (old);
+- free (text);
++ xfree (old);
++ xfree (text);
+ rl_kill_ring[slot] = new;
+ }
+ else
+@@ -582,6 +582,7 @@ rl_yank_nth_arg_internal (count, ignore,
+ if (!arg || !*arg)
+ {
+ rl_ding ();
++ FREE (arg);
+ return -1;
+ }
+
+@@ -600,7 +601,7 @@ rl_yank_nth_arg_internal (count, ignore,
+ #endif /* VI_MODE */
+
+ rl_insert_text (arg);
+- free (arg);
++ xfree (arg);
+
+ rl_end_undo_group ();
+ return 0;
+@@ -639,7 +640,7 @@ rl_yank_last_arg (count, key)
+ {
+ if (undo_needed)
+ rl_do_undo ();
+- if (count < 1)
++ if (count < 0) /* XXX - was < 1 */
+ direction = -direction;
+ history_skip += direction;
+ if (history_skip < 0)
+@@ -685,7 +686,7 @@ rl_paste_from_clipboard (count, key)
+ _rl_set_mark_at_pos (rl_point);
+ rl_insert_text (ptr);
+ if (ptr != data)
+- free (ptr);
++ xfree (ptr);
+ CloseClipboard ();
+ }
+ return (0);
+Index: gdb-7.2.90.20110703/readline/macro.c
+===================================================================
+--- gdb-7.2.90.20110703.orig/readline/macro.c 2011-07-03 10:40:53.000000000 +0200
++++ gdb-7.2.90.20110703/readline/macro.c 2011-07-03 10:41:21.000000000 +0200
+@@ -1,24 +1,24 @@
+ /* macro.c -- keyboard macros for readline. */
+
+-/* Copyright (C) 1994 Free Software Foundation, Inc.
++/* Copyright (C) 1994-2009 Free Software Foundation, Inc.
+
+- This file is part of the GNU Readline Library, a library for
+- reading lines of text with interactive input and history editing.
++ This file is part of the GNU Readline Library (Readline), a library
++ for reading lines of text with interactive input and history editing.
+
+- The GNU Readline Library is free software; you can redistribute it
+- and/or modify it under the terms of the GNU General Public License
+- as published by the Free Software Foundation; either version 2, or
++ Readline 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.
+
+- The GNU Readline Library is distributed in the hope that it will be
+- useful, but WITHOUT ANY WARRANTY; without even the implied warranty
+- of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ Readline 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.
+
+- The GNU General Public License is often shipped with GNU software, and
+- is generally kept in a file called COPYING or LICENSE. If you do not
+- have a copy of the license, write to the Free Software Foundation,
+- 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
++ You should have received a copy of the GNU General Public License
++ along with Readline. If not, see <http://www.gnu.org/licenses/>.
++*/
++
+ #define READLINE_LIBRARY
+
+ #if defined (HAVE_CONFIG_H)
+@@ -113,7 +113,7 @@ _rl_next_macro_key ()
+
+ #if defined (READLINE_CALLBACKS)
+ c = rl_executing_macro[executing_macro_index++];
+- if (RL_ISSTATE (RL_STATE_CALLBACK) && RL_ISSTATE (RL_STATE_READCMD) && rl_executing_macro[executing_macro_index] == 0)
++ if (RL_ISSTATE (RL_STATE_CALLBACK) && RL_ISSTATE (RL_STATE_READCMD|RL_STATE_MOREINPUT) && rl_executing_macro[executing_macro_index] == 0)
+ _rl_pop_executing_macro ();
+ return c;
+ #else
+@@ -152,7 +152,7 @@ _rl_pop_executing_macro ()
+ rl_executing_macro = macro_list->string;
+ executing_macro_index = macro_list->sindex;
+ macro_list = macro_list->next;
+- free (macro);
++ xfree (macro);
+ }
+
+ if (rl_executing_macro == 0)
+@@ -181,7 +181,7 @@ _rl_kill_kbd_macro ()
+ {
+ if (current_macro)
+ {
+- free (current_macro);
++ xfree (current_macro);
+ current_macro = (char *) NULL;
+ }
+ current_macro_size = current_macro_index = 0;
+Index: gdb-7.2.90.20110703/readline/mbutil.c
+===================================================================
+--- gdb-7.2.90.20110703.orig/readline/mbutil.c 2011-07-03 10:40:53.000000000 +0200
++++ gdb-7.2.90.20110703/readline/mbutil.c 2011-07-03 10:41:21.000000000 +0200
+@@ -1,24 +1,24 @@
+ /* mbutil.c -- readline multibyte character utility functions */
+
+-/* Copyright (C) 2001-2005 Free Software Foundation, Inc.
++/* Copyright (C) 2001-2009 Free Software Foundation, Inc.
+
+- This file is part of the GNU Readline Library, a library for
+- reading lines of text with interactive input and history editing.
++ This file is part of the GNU Readline Library (Readline), a library
++ for reading lines of text with interactive input and history editing.
+
+- The GNU Readline Library is free software; you can redistribute it
+- and/or modify it under the terms of the GNU General Public License
+- as published by the Free Software Foundation; either version 2, or
++ Readline 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.
+
+- The GNU Readline Library is distributed in the hope that it will be
+- useful, but WITHOUT ANY WARRANTY; without even the implied warranty
+- of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ Readline 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.
+
+- The GNU General Public License is often shipped with GNU software, and
+- is generally kept in a file called COPYING or LICENSE. If you do not
+- have a copy of the license, write to the Free Software Foundation,
+- 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
++ You should have received a copy of the GNU General Public License
++ along with Readline. If not, see <http://www.gnu.org/licenses/>.
++*/
++
+ #define READLINE_LIBRARY
+
+ #if defined (HAVE_CONFIG_H)
+@@ -77,7 +77,7 @@ _rl_find_next_mbchar_internal (string, s
+ char *string;
+ int seed, count, find_non_zero;
+ {
+- size_t tmp;
++ size_t tmp, len;
+ mbstate_t ps;
+ int point;
+ wchar_t wc;
+@@ -91,17 +91,21 @@ _rl_find_next_mbchar_internal (string, s
+ return seed;
+
+ point = seed + _rl_adjust_point (string, seed, &ps);
+- /* if this is true, means that seed was not pointed character
+- started byte. So correct the point and consume count */
++ /* if this is true, means that seed was not pointing to a byte indicating
++ the beginning of a multibyte character. Correct the point and consume
++ one char. */
+ if (seed < point)
+ count--;
+
+ while (count > 0)
+ {
+- tmp = mbrtowc (&wc, string+point, strlen(string + point), &ps);
++ len = strlen (string + point);
++ if (len == 0)
++ break;
++ tmp = mbrtowc (&wc, string+point, len, &ps);
+ if (MB_INVALIDCH ((size_t)tmp))
+ {
+- /* invalid bytes. asume a byte represents a character */
++ /* invalid bytes. assume a byte represents a character */
+ point++;
+ count--;
+ /* reset states. */
+@@ -128,12 +132,10 @@ _rl_find_next_mbchar_internal (string, s
+ if (find_non_zero)
+ {
+ tmp = mbrtowc (&wc, string + point, strlen (string + point), &ps);
+- while (tmp > 0 && wcwidth (wc) == 0)
++ while (MB_NULLWCH (tmp) == 0 && MB_INVALIDCH (tmp) == 0 && wcwidth (wc) == 0)
+ {
+ point += tmp;
+ tmp = mbrtowc (&wc, string + point, strlen (string + point), &ps);
+- if (MB_NULLWCH (tmp) || MB_INVALIDCH (tmp))
+- break;
+ }
+ }
+
+Index: gdb-7.2.90.20110703/readline/misc.c
+===================================================================
+--- gdb-7.2.90.20110703.orig/readline/misc.c 2011-07-03 10:40:53.000000000 +0200
++++ gdb-7.2.90.20110703/readline/misc.c 2011-07-03 10:41:21.000000000 +0200
+@@ -1,24 +1,24 @@
+ /* misc.c -- miscellaneous bindable readline functions. */
+
+-/* Copyright (C) 1987-2005 Free Software Foundation, Inc.
++/* Copyright (C) 1987-2009 Free Software Foundation, Inc.
+
+- This file is part of the GNU Readline Library, a library for
+- reading lines of text with interactive input and history editing.
++ This file is part of the GNU Readline Library (Readline), a library
++ for reading lines of text with interactive input and history editing.
+
+- The GNU Readline Library is free software; you can redistribute it
+- and/or modify it under the terms of the GNU General Public License
+- as published by the Free Software Foundation; either version 2, or
++ Readline 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.
+
+- The GNU Readline Library is distributed in the hope that it will be
+- useful, but WITHOUT ANY WARRANTY; without even the implied warranty
+- of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ Readline 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.
+
+- The GNU General Public License is often shipped with GNU software, and
+- is generally kept in a file called COPYING or LICENSE. If you do not
+- have a copy of the license, write to the Free Software Foundation,
+- 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
++ You should have received a copy of the GNU General Public License
++ along with Readline. If not, see <http://www.gnu.org/licenses/>.
++*/
++
+ #define READLINE_LIBRARY
+
+ #if defined (HAVE_CONFIG_H)
+@@ -146,6 +146,8 @@ _rl_arg_dispatch (cxt, c)
+ rl_restore_prompt ();
+ rl_clear_message ();
+ RL_UNSETSTATE(RL_STATE_NUMERICARG);
++ if (key < 0)
++ return -1;
+ return (_rl_dispatch (key, _rl_keymap));
+ }
+ }
+@@ -212,6 +214,8 @@ rl_digit_loop ()
+ if (r <= 0 || (RL_ISSTATE (RL_STATE_NUMERICARG) == 0))
+ break;
+ }
++
++ return r;
+ }
+
+ /* Create a default argument. */
+@@ -324,7 +328,7 @@ _rl_free_history_entry (entry)
+ FREE (entry->line);
+ FREE (entry->timestamp);
+
+- free (entry);
++ xfree (entry);
+ }
+
+ /* Perhaps put back the current line if it has changed. */
+@@ -338,9 +342,9 @@ rl_maybe_replace_line ()
+ if (temp && ((UNDO_LIST *)(temp->data) != rl_undo_list))
+ {
+ temp = replace_history_entry (where_history (), rl_line_buffer, (histdata_t)rl_undo_list);
+- free (temp->line);
++ xfree (temp->line);
+ FREE (temp->timestamp);
+- free (temp);
++ xfree (temp);
+ }
+ return 0;
+ }
+@@ -427,6 +431,56 @@ rl_replace_from_history (entry, flags)
+ rl_mark = rl_end;
+ }
+ #endif
++}
++
++/* Process and free undo lists attached to each history entry prior to the
++ current entry, inclusive, reverting each line to its saved state. This
++ is destructive, and state about the current line is lost. This is not
++ intended to be called while actively editing, and the current line is
++ not assumed to have been added to the history list. */
++void
++_rl_revert_all_lines ()
++{
++ int hpos;
++ HIST_ENTRY *entry;
++ UNDO_LIST *ul, *saved_undo_list;
++ char *lbuf;
++
++ lbuf = savestring (rl_line_buffer);
++ saved_undo_list = rl_undo_list;
++ hpos = where_history ();
++
++ entry = (hpos == history_length) ? previous_history () : current_history ();
++ while (entry)
++ {
++ if (ul = (UNDO_LIST *)entry->data)
++ {
++ if (ul == saved_undo_list)
++ saved_undo_list = 0;
++ /* Set up rl_line_buffer and other variables from history entry */
++ rl_replace_from_history (entry, 0); /* entry->line is now current */
++ /* Undo all changes to this history entry */
++ while (rl_undo_list)
++ rl_do_undo ();
++ /* And copy the reverted line back to the history entry, preserving
++ the timestamp. */
++ FREE (entry->line);
++ entry->line = savestring (rl_line_buffer);
++ entry->data = 0;
++ }
++ entry = previous_history ();
++ }
++
++ /* Restore history state */
++ rl_undo_list = saved_undo_list; /* may have been set to null */
++ history_set_pos (hpos);
++
++ /* reset the line buffer */
++ rl_replace_line (lbuf, 0);
++ _rl_set_the_line ();
++
++ /* and clean up */
++ xfree (lbuf);
+ }
+
+ /* **************************************************************** */
+@@ -556,7 +610,7 @@ rl_vi_editing_mode (count, key)
+ #if defined (VI_MODE)
+ _rl_set_insert_mode (RL_IM_INSERT, 1); /* vi mode ignores insert mode */
+ rl_editing_mode = vi_mode;
+- rl_vi_insertion_mode (1, key);
++ rl_vi_insert_mode (1, key);
+ #endif /* VI_MODE */
+
+ return 0;
+Index: gdb-7.2.90.20110703/readline/nls.c
+===================================================================
+--- gdb-7.2.90.20110703.orig/readline/nls.c 2011-07-03 10:40:53.000000000 +0200
++++ gdb-7.2.90.20110703/readline/nls.c 2011-07-03 10:41:21.000000000 +0200
+@@ -1,24 +1,24 @@
+ /* nls.c -- skeletal internationalization code. */
+
+-/* Copyright (C) 1996 Free Software Foundation, Inc.
++/* Copyright (C) 1996-2009 Free Software Foundation, Inc.
+
+- This file is part of the GNU Readline Library, a library for
+- reading lines of text with interactive input and history editing.
++ This file is part of the GNU Readline Library (Readline), a library
++ for reading lines of text with interactive input and history editing.
+
+- The GNU Readline Library is free software; you can redistribute it
+- and/or modify it under the terms of the GNU General Public License
+- as published by the Free Software Foundation; either version 2, or
++ Readline 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.
+
+- The GNU Readline Library is distributed in the hope that it will be
+- useful, but WITHOUT ANY WARRANTY; without even the implied warranty
+- of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ Readline 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.
+
+- The GNU General Public License is often shipped with GNU software, and
+- is generally kept in a file called COPYING or LICENSE. If you do not
+- have a copy of the license, write to the Free Software Foundation,
+- 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
++ You should have received a copy of the GNU General Public License
++ along with Readline. If not, see <http://www.gnu.org/licenses/>.
++*/
++
+ #define READLINE_LIBRARY
+
+ #if defined (HAVE_CONFIG_H)
+@@ -145,7 +145,7 @@ _rl_init_eightbit ()
+ _rl_output_meta_chars = 1;
+ break;
+ }
+- free (t);
++ xfree (t);
+ return (legal_lang_values[i] ? 1 : 0);
+
+ #endif /* !HAVE_SETLOCALE */
+Index: gdb-7.2.90.20110703/readline/parens.c
+===================================================================
+--- gdb-7.2.90.20110703.orig/readline/parens.c 2011-07-03 10:40:53.000000000 +0200
++++ gdb-7.2.90.20110703/readline/parens.c 2011-07-03 10:41:21.000000000 +0200
+@@ -1,24 +1,24 @@
+-/* parens.c -- Implementation of matching parentheses feature. */
++/* parens.c -- implementation of matching parentheses feature. */
+
+-/* Copyright (C) 1987, 1989, 1992 Free Software Foundation, Inc.
++/* Copyright (C) 1987, 1989, 1992-2009 Free Software Foundation, Inc.
+
+- This file is part of the GNU Readline Library, a library for
+- reading lines of text with interactive input and history editing.
++ This file is part of the GNU Readline Library (Readline), a library
++ for reading lines of text with interactive input and history editing.
+
+- The GNU Readline Library is free software; you can redistribute it
+- and/or modify it under the terms of the GNU General Public License
+- as published by the Free Software Foundation; either version 2, or
++ Readline 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.
+
+- The GNU Readline Library is distributed in the hope that it will be
+- useful, but WITHOUT ANY WARRANTY; without even the implied warranty
+- of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ Readline 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.
+
+- The GNU General Public License is often shipped with GNU software, and
+- is generally kept in a file called COPYING or LICENSE. If you do not
+- have a copy of the license, write to the Free Software Foundation,
+- 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
++ You should have received a copy of the GNU General Public License
++ along with Readline. If not, see <http://www.gnu.org/licenses/>.
++*/
++
+ #define READLINE_LIBRARY
+
+ #if defined (__TANDEM)
+@@ -38,16 +38,7 @@
+ # include <unistd.h>
+ #endif
+
+-#if defined (FD_SET) && !defined (HAVE_SELECT)
+-# define HAVE_SELECT
+-#endif
+-
+-#if defined (HAVE_SELECT)
+-# include <sys/time.h>
+-#endif /* HAVE_SELECT */
+-#if defined (HAVE_SYS_SELECT_H)
+-# include <sys/select.h>
+-#endif
++#include "posixselect.h"
+
+ #if defined (HAVE_STRING_H)
+ # include <string.h>
+@@ -130,8 +121,7 @@ rl_insert_close (count, invoking_key)
+
+ FD_ZERO (&readfds);
+ FD_SET (fileno (rl_instream), &readfds);
+- timer.tv_sec = 0;
+- timer.tv_usec = _paren_blink_usec;
++ USEC_TO_TIMEVAL (_paren_blink_usec, timer);
+
+ orig_point = rl_point;
+ rl_point = match_point;
+Index: gdb-7.2.90.20110703/readline/patchlevel
+===================================================================
+--- /dev/null 1970-01-01 00:00:00.000000000 +0000
++++ gdb-7.2.90.20110703/readline/patchlevel 2011-07-03 10:41:21.000000000 +0200
+@@ -0,0 +1,3 @@
++# Do not edit -- exists only for use by patch
++
++1
+Index: gdb-7.2.90.20110703/readline/posixdir.h
+===================================================================
+--- gdb-7.2.90.20110703.orig/readline/posixdir.h 2011-07-03 10:40:53.000000000 +0200
++++ gdb-7.2.90.20110703/readline/posixdir.h 2011-07-03 10:41:21.000000000 +0200
+@@ -4,19 +4,19 @@
+
+ This file is part of GNU Bash, the Bourne Again SHell.
+
+- Bash is free software; you can redistribute it and/or modify it
+- under the terms of the GNU General Public License as published by
+- the Free Software Foundation; either version 2, or (at your option)
+- any later version.
+-
+- Bash 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.
++ Bash 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.
++
++ Bash 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 Bash; see the file COPYING. If not, write to the Free
+- Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
++ along with Bash. If not, see <http://www.gnu.org/licenses/>.
++*/
+
+ /* This file should be included instead of <dirent.h> or <sys/dir.h>. */
+
+Index: gdb-7.2.90.20110703/readline/posixjmp.h
+===================================================================
+--- gdb-7.2.90.20110703.orig/readline/posixjmp.h 2011-07-03 10:40:53.000000000 +0200
++++ gdb-7.2.90.20110703/readline/posixjmp.h 2011-07-03 10:41:21.000000000 +0200
+@@ -4,19 +4,19 @@
+
+ This file is part of GNU Bash, the Bourne Again SHell.
+
+- Bash is free software; you can redistribute it and/or modify it
+- under the terms of the GNU General Public License as published by
+- the Free Software Foundation; either version 2, or (at your option)
+- any later version.
+-
+- Bash 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.
++ Bash 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.
++
++ Bash 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 Bash; see the file COPYING. If not, write to the Free
+- Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
++ along with Bash. If not, see <http://www.gnu.org/licenses/>.
++*/
+
+ #ifndef _POSIXJMP_H_
+ #define _POSIXJMP_H_
+Index: gdb-7.2.90.20110703/readline/posixselect.h
+===================================================================
+--- /dev/null 1970-01-01 00:00:00.000000000 +0000
++++ gdb-7.2.90.20110703/readline/posixselect.h 2011-07-03 10:41:21.000000000 +0200
+@@ -0,0 +1,47 @@
++/* posixselect.h -- wrapper for select(2) includes and definitions */
++
++/* Copyright (C) 2009 Free Software Foundation, Inc.
++
++ This file is part of GNU Bash, the Bourne Again SHell.
++
++ Bash 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.
++
++ Bash 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 Bash. If not, see <http://www.gnu.org/licenses/>.
++*/
++
++#ifndef _POSIXSELECT_H_
++#define _POSIXSELECT_H_
++
++#if defined (FD_SET) && !defined (HAVE_SELECT)
++# define HAVE_SELECT 1
++#endif
++
++#if defined (HAVE_SELECT)
++# if !defined (HAVE_SYS_SELECT_H) || !defined (M_UNIX)
++# include <sys/time.h>
++# endif
++#endif /* HAVE_SELECT */
++#if defined (HAVE_SYS_SELECT_H)
++# include <sys/select.h>
++#endif
++
++#ifndef USEC_PER_SEC
++# define USEC_PER_SEC 1000000
++#endif
++
++#define USEC_TO_TIMEVAL(us, tv) \
++do { \
++ (tv).tv_sec = (us) / USEC_PER_SEC; \
++ (tv).tv_usec = (us) % USEC_PER_SEC; \
++} while (0)
++
++#endif /* _POSIXSELECT_H_ */
+Index: gdb-7.2.90.20110703/readline/posixstat.h
+===================================================================
+--- gdb-7.2.90.20110703.orig/readline/posixstat.h 2011-07-03 10:40:53.000000000 +0200
++++ gdb-7.2.90.20110703/readline/posixstat.h 2011-07-03 10:41:21.000000000 +0200
+@@ -5,19 +5,19 @@
+
+ This file is part of GNU Bash, the Bourne Again SHell.
+
+- Bash is free software; you can redistribute it and/or modify it
+- under the terms of the GNU General Public License as published by
+- the Free Software Foundation; either version 2, or (at your option)
+- any later version.
+-
+- Bash 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.
++ Bash 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.
++
++ Bash 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 Bash; see the file COPYING. If not, write to the Free
+- Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
++ along with Bash. If not, see <http://www.gnu.org/licenses/>.
++*/
+
+ /* This file should be included instead of <sys/stat.h>.
+ It relies on the local sys/stat.h to work though. */
+Index: gdb-7.2.90.20110703/readline/readline.c
+===================================================================
+--- gdb-7.2.90.20110703.orig/readline/readline.c 2011-07-03 10:40:53.000000000 +0200
++++ gdb-7.2.90.20110703/readline/readline.c 2011-07-03 10:41:21.000000000 +0200
+@@ -1,25 +1,25 @@
+ /* readline.c -- a general facility for reading lines of input
+ with emacs style editing and completion. */
+
+-/* Copyright (C) 1987-2005 Free Software Foundation, Inc.
++/* Copyright (C) 1987-2009 Free Software Foundation, Inc.
+
+- This file is part of the GNU Readline Library, a library for
+- reading lines of text with interactive input and history editing.
++ This file is part of the GNU Readline Library (Readline), a library
++ for reading lines of text with interactive input and history editing.
+
+- The GNU Readline Library is free software; you can redistribute it
+- and/or modify it under the terms of the GNU General Public License
+- as published by the Free Software Foundation; either version 2, or
++ Readline 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.
+
+- The GNU Readline Library is distributed in the hope that it will be
+- useful, but WITHOUT ANY WARRANTY; without even the implied warranty
+- of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ Readline 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.
+
+- The GNU General Public License is often shipped with GNU software, and
+- is generally kept in a file called COPYING or LICENSE. If you do not
+- have a copy of the license, write to the Free Software Foundation,
+- 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
++ You should have received a copy of the GNU General Public License
++ along with Readline. If not, see <http://www.gnu.org/licenses/>.
++*/
++
+ #define READLINE_LIBRARY
+
+ #if defined (HAVE_CONFIG_H)
+@@ -49,6 +49,11 @@
+
+ #include <stdio.h>
+ #include "posixjmp.h"
++#include <errno.h>
++
++#if !defined (errno)
++extern int errno;
++#endif /* !errno */
+
+ /* System-specific feature definitions and include files. */
+ #include "rldefs.h"
+@@ -158,7 +163,7 @@ int rl_done;
+ rl_command_func_t *rl_last_func = (rl_command_func_t *)NULL;
+
+ /* Top level environment for readline_internal (). */
+-procenv_t readline_top_level;
++procenv_t _rl_top_level;
+
+ /* The streams we interact with. */
+ FILE *_rl_in_stream, *_rl_out_stream;
+@@ -171,7 +176,7 @@ FILE *rl_outstream = (FILE *)NULL;
+ set to 1 if there is a controlling terminal, we can get its attributes,
+ and the attributes include `echo'. Look at rltty.c:prepare_terminal_settings
+ for the code that sets it. */
+-int readline_echoing_p = 0;
++int _rl_echoing_p = 0;
+
+ /* Current prompt. */
+ char *rl_prompt = (char *)NULL;
+@@ -265,6 +270,15 @@ int _rl_output_meta_chars = 0;
+ them to equivalent readline functions at startup. */
+ int _rl_bind_stty_chars = 1;
+
++/* Non-zero means to go through the history list at every newline (or
++ whenever rl_done is set and readline returns) and revert each line to
++ its initial state. */
++int _rl_revert_all_at_newline = 0;
++
++/* Non-zero means to honor the termios ECHOCTL bit and echo control
++ characters corresponding to keyboard-generated signals. */
++int _rl_echo_control_chars = 1;
++
+ /* **************************************************************** */
+ /* */
+ /* Top Level Functions */
+@@ -295,6 +309,9 @@ readline (prompt)
+ const char *prompt;
+ {
+ char *value;
++#if 0
++ int in_callback;
++#endif
+
+ /* If we are at EOF return a NULL string. */
+ if (rl_pending_input == EOF)
+@@ -303,6 +320,15 @@ readline (prompt)
+ return ((char *)NULL);
+ }
+
++#if 0
++ /* If readline() is called after installing a callback handler, temporarily
++ turn off the callback state to avoid ensuing messiness. Patch supplied
++ by the gdb folks. XXX -- disabled. This can be fooled and readline
++ left in a strange state by a poorly-timed longjmp. */
++ if (in_callback = RL_ISSTATE (RL_STATE_CALLBACK))
++ RL_UNSETSTATE (RL_STATE_CALLBACK);
++#endif
++
+ rl_set_prompt (prompt);
+
+ rl_initialize ();
+@@ -321,6 +347,11 @@ readline (prompt)
+ rl_clear_signals ();
+ #endif
+
++#if 0
++ if (in_callback)
++ RL_SETSTATE (RL_STATE_CALLBACK);
++#endif
++
+ return (value);
+ }
+
+@@ -344,14 +375,14 @@ readline_internal_setup ()
+ /* If we're not echoing, we still want to at least print a prompt, because
+ rl_redisplay will not do it for us. If the calling application has a
+ custom redisplay function, though, let that function handle it. */
+- if (readline_echoing_p == 0 && rl_redisplay_function == rl_redisplay)
++ if (_rl_echoing_p == 0 && rl_redisplay_function == rl_redisplay)
+ {
+ if (rl_prompt && rl_already_prompted == 0)
+ {
+ nprompt = _rl_strip_prompt (rl_prompt);
+ fprintf (_rl_out_stream, "%s", nprompt);
+ fflush (_rl_out_stream);
+- free (nprompt);
++ xfree (nprompt);
+ }
+ }
+ else
+@@ -365,11 +396,13 @@ readline_internal_setup ()
+
+ #if defined (VI_MODE)
+ if (rl_editing_mode == vi_mode)
+- rl_vi_insertion_mode (1, 'i');
++ rl_vi_insert_mode (1, 'i');
+ #endif /* VI_MODE */
+
+ if (rl_pre_input_hook)
+ (*rl_pre_input_hook) ();
++
++ RL_CHECK_SIGNALS ();
+ }
+
+ STATIC_CALLBACK char *
+@@ -379,6 +412,8 @@ readline_internal_teardown (eof)
+ char *temp;
+ HIST_ENTRY *entry;
+
++ RL_CHECK_SIGNALS ();
++
+ /* Restore the original of this history line, iff the line that we
+ are editing was originally in the history, AND the line has changed. */
+ entry = current_history ();
+@@ -391,9 +426,12 @@ readline_internal_teardown (eof)
+ _rl_free_history_entry (entry);
+
+ strcpy (the_line, temp);
+- free (temp);
++ xfree (temp);
+ }
+
++ if (_rl_revert_all_at_newline)
++ _rl_revert_all_lines ();
++
+ /* At any rate, it is highly likely that this line has an undo list. Get
+ rid of it now. */
+ if (rl_undo_list)
+@@ -454,7 +492,7 @@ readline_internal_charloop ()
+ #endif
+ lk = _rl_last_command_was_kill;
+
+- code = setjmp (readline_top_level);
++ code = setjmp (_rl_top_level);
+
+ if (code)
+ {
+@@ -462,7 +500,7 @@ readline_internal_charloop ()
+ _rl_want_redisplay = 0;
+ /* If we get here, we're not being called from something dispatched
+ from _rl_callback_read_char(), which sets up its own value of
+- readline_top_level (saving and restoring the old, of course), so
++ _rl_top_level (saving and restoring the old, of course), so
+ we can just return here. */
+ if (RL_ISSTATE (RL_STATE_CALLBACK))
+ return (0);
+@@ -479,6 +517,20 @@ readline_internal_charloop ()
+ c = rl_read_key ();
+ RL_UNSETSTATE(RL_STATE_READCMD);
+
++ /* look at input.c:rl_getc() for the circumstances under which this will
++ be returned; punt immediately on read error without converting it to
++ a newline. */
++ if (c == READERR)
++ {
++#if defined (READLINE_CALLBACKS)
++ RL_SETSTATE(RL_STATE_DONE);
++ return (rl_done = 1);
++#else
++ eof_found = 1;
++ break;
++#endif
++ }
++
+ /* EOF typed to a non-blank line is a <NL>. */
+ if (c == EOF && rl_end)
+ c = NEWLINE;
+@@ -498,6 +550,7 @@ readline_internal_charloop ()
+
+ lastc = c;
+ _rl_dispatch ((unsigned char)c, _rl_keymap);
++ RL_CHECK_SIGNALS ();
+
+ /* If there was no change in _rl_last_command_was_kill, then no kill
+ has taken place. Note that if input is pending we are reading
+@@ -576,7 +629,7 @@ void
+ _rl_keyseq_cxt_dispose (cxt)
+ _rl_keyseq_cxt *cxt;
+ {
+- free (cxt);
++ xfree (cxt);
+ }
+
+ void
+@@ -618,7 +671,6 @@ _rl_dispatch_callback (cxt)
+ int nkey, r;
+
+ /* For now */
+-#if 1
+ /* The first time this context is used, we want to read input and dispatch
+ on it. When traversing the chain of contexts back `up', we want to use
+ the value from the next context down. We're simulating recursion using
+@@ -626,18 +678,22 @@ _rl_dispatch_callback (cxt)
+ if ((cxt->flags & KSEQ_DISPATCHED) == 0)
+ {
+ nkey = _rl_subseq_getchar (cxt->okey);
++ if (nkey < 0)
++ {
++ _rl_abort_internal ();
++ return -1;
++ }
+ r = _rl_dispatch_subseq (nkey, cxt->dmap, cxt->subseq_arg);
+ cxt->flags |= KSEQ_DISPATCHED;
+ }
+ else
+ r = cxt->childval;
+-#else
+- r = _rl_dispatch_subseq (nkey, cxt->dmap, cxt->subseq_arg);
+-#endif
+
+ /* For now */
+- r = _rl_subseq_result (r, cxt->oldmap, cxt->okey, (cxt->flags & KSEQ_SUBSEQ));
++ if (r != -3) /* don't do this if we indicate there will be other matches */
++ r = _rl_subseq_result (r, cxt->oldmap, cxt->okey, (cxt->flags & KSEQ_SUBSEQ));
+
++ RL_CHECK_SIGNALS ();
+ if (r == 0) /* success! */
+ {
+ _rl_keyseq_chain_dispose ();
+@@ -724,6 +780,8 @@ _rl_dispatch_subseq (key, map, got_subse
+ remember the last command executed in this variable. */
+ if (rl_pending_input == 0 && map[key].function != rl_digit_argument)
+ rl_last_func = map[key].function;
++
++ RL_CHECK_SIGNALS ();
+ }
+ else if (map[ANYOTHERKEY].function)
+ {
+@@ -778,7 +836,7 @@ _rl_dispatch_subseq (key, map, got_subse
+ {
+ /* Return 0 only the first time, to indicate success to
+ _rl_callback_read_char. The rest of the time, we're called
+- from _rl_dispatch_callback, so we return 3 to indicate
++ from _rl_dispatch_callback, so we return -3 to indicate
+ special handling is necessary. */
+ r = RL_ISSTATE (RL_STATE_MULTIKEY) ? -3 : 0;
+ cxt = _rl_keyseq_cxt_alloc ();
+@@ -842,7 +900,7 @@ _rl_subseq_result (r, map, key, got_subs
+ Keymap m;
+ int type, nt;
+ rl_command_func_t *func, *nf;
+-
++
+ if (r == -2)
+ /* We didn't match anything, and the keymap we're indexed into
+ shadowed a function previously bound to that prefix. Call
+@@ -1116,6 +1174,10 @@ bind_arrow_keys ()
+
+ #if defined (VI_MODE)
+ bind_arrow_keys_internal (vi_movement_keymap);
++ /* Unbind vi_movement_keymap[ESC] to allow users to repeatedly hit ESC
++ in vi command mode while still allowing the arrow keys to work. */
++ if (vi_movement_keymap[ESC].type == ISKMAP)
++ rl_bind_keyseq_in_map ("\033", (rl_command_func_t *)NULL, vi_movement_keymap);
+ bind_arrow_keys_internal (vi_insertion_keymap);
+ #endif
+ }
+Index: gdb-7.2.90.20110703/readline/readline.h
+===================================================================
+--- gdb-7.2.90.20110703.orig/readline/readline.h 2011-07-03 10:40:53.000000000 +0200
++++ gdb-7.2.90.20110703/readline/readline.h 2011-07-03 10:41:21.000000000 +0200
+@@ -1,24 +1,23 @@
+ /* Readline.h -- the names of functions callable from within readline. */
+
+-/* Copyright (C) 1987-2005 Free Software Foundation, Inc.
++/* Copyright (C) 1987-2011 Free Software Foundation, Inc.
+
+- This file is part of the GNU Readline Library, a library for
+- reading lines of text with interactive input and history editing.
++ This file is part of the GNU Readline Library (Readline), a library
++ for reading lines of text with interactive input and history editing.
+
+- The GNU Readline Library is free software; you can redistribute it
+- and/or modify it under the terms of the GNU General Public License
+- as published by the Free Software Foundation; either version 2, or
++ Readline 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.
+
+- The GNU Readline Library is distributed in the hope that it will be
+- useful, but WITHOUT ANY WARRANTY; without even the implied warranty
+- of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ Readline 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.
+
+- The GNU General Public License is often shipped with GNU software, and
+- is generally kept in a file called COPYING or LICENSE. If you do not
+- have a copy of the license, write to the Free Software Foundation,
+- 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
++ You should have received a copy of the GNU General Public License
++ along with Readline. If not, see <http://www.gnu.org/licenses/>.
++*/
+
+ #if !defined (_READLINE_H_)
+ #define _READLINE_H_
+@@ -40,9 +39,9 @@ extern "C" {
+ #endif
+
+ /* Hex-encoded Readline version number. */
+-#define RL_READLINE_VERSION 0x0501 /* Readline 5.1 */
+-#define RL_VERSION_MAJOR 5
+-#define RL_VERSION_MINOR 1
++#define RL_READLINE_VERSION 0x0602 /* Readline 6.2 */
++#define RL_VERSION_MAJOR 6
++#define RL_VERSION_MINOR 2
+
+ /* Readline data structures. */
+
+@@ -96,6 +95,7 @@ extern int rl_forward_word PARAMS((int,
+ extern int rl_backward_word PARAMS((int, int));
+ extern int rl_refresh_line PARAMS((int, int));
+ extern int rl_clear_screen PARAMS((int, int));
++extern int rl_skip_csi_sequence PARAMS((int, int));
+ extern int rl_arrow_keys PARAMS((int, int));
+
+ /* Bindable commands for inserting and deleting text. */
+@@ -151,7 +151,9 @@ extern int rl_dump_variables PARAMS((int
+ extern int rl_complete PARAMS((int, int));
+ extern int rl_possible_completions PARAMS((int, int));
+ extern int rl_insert_completions PARAMS((int, int));
++extern int rl_old_menu_complete PARAMS((int, int));
+ extern int rl_menu_complete PARAMS((int, int));
++extern int rl_backward_menu_complete PARAMS((int, int));
+
+ /* Bindable commands for killing and yanking text, and managing the kill ring. */
+ extern int rl_kill_word PARAMS((int, int));
+@@ -233,6 +235,7 @@ extern int rl_vi_append_mode PARAMS((int
+ extern int rl_vi_append_eol PARAMS((int, int));
+ extern int rl_vi_eof_maybe PARAMS((int, int));
+ extern int rl_vi_insertion_mode PARAMS((int, int));
++extern int rl_vi_insert_mode PARAMS((int, int));
+ extern int rl_vi_movement_mode PARAMS((int, int));
+ extern int rl_vi_arg_digit PARAMS((int, int));
+ extern int rl_vi_change_case PARAMS((int, int));
+@@ -420,6 +423,7 @@ extern int rl_set_keyboard_input_timeout
+ extern void rl_extend_line_buffer PARAMS((int));
+ extern int rl_ding PARAMS((void));
+ extern int rl_alphabetic PARAMS((int));
++extern void rl_free PARAMS((void *));
+
+ /* Readline signal handling, from signals.c */
+ extern int rl_set_signals PARAMS((void));
+@@ -427,7 +431,9 @@ extern int rl_clear_signals PARAMS((void
+ extern void rl_cleanup_after_signal PARAMS((void));
+ extern void rl_reset_after_signal PARAMS((void));
+ extern void rl_free_line_state PARAMS((void));
+-
++
++extern void rl_echo_signal_char PARAMS((int));
++
+ extern int rl_set_paren_blink_timeout PARAMS((int));
+
+ /* Undocumented. */
+@@ -493,6 +499,10 @@ extern const char *rl_readline_name;
+ readline (), and should not be assigned to directly. */
+ extern char *rl_prompt;
+
++/* The prompt string that is actually displayed by rl_redisplay. Public so
++ applications can more easily supply their own redisplay functions. */
++extern char *rl_display_prompt;
++
+ /* The line buffer that is in use. */
+ extern char *rl_line_buffer;
+
+@@ -599,6 +609,10 @@ extern int rl_catch_sigwinch;
+ filename completer. */
+ extern rl_compentry_func_t *rl_completion_entry_function;
+
++/* Optional generator for menu completion. Default is
++ rl_completion_entry_function (rl_filename_completion_function). */
++ extern rl_compentry_func_t *rl_menu_completion_entry_function;
++
+ /* If rl_ignore_some_completions_function is non-NULL it is the address
+ of a function to call after all of the possible matches have been
+ generated, but before the actual completion is done to the input line.
+@@ -652,18 +666,37 @@ extern const char *rl_special_prefixes;
+ completing on a directory name. The function is called with
+ the address of a string (the current directory name) as an arg. It
+ changes what is displayed when the possible completions are printed
+- or inserted. */
++ or inserted. The directory completion hook should perform
++ any necessary dequoting. This function should return 1 if it modifies
++ the directory name pointer passed as an argument. If the directory
++ completion hook returns 0, it should not modify the directory name
++ pointer passed as an argument. */
+ extern rl_icppfunc_t *rl_directory_completion_hook;
+
+ /* If non-zero, this is the address of a function to call when completing
+ a directory name. This function takes the address of the directory name
+ to be modified as an argument. Unlike rl_directory_completion_hook, it
+ only modifies the directory name used in opendir(2), not what is displayed
+- when the possible completions are printed or inserted. It is called
+- before rl_directory_completion_hook. I'm not happy with how this works
+- yet, so it's undocumented. */
++ when the possible completions are printed or inserted. If set, it takes
++ precedence over rl_directory_completion_hook. The directory rewrite
++ hook should perform any necessary dequoting. This function has the same
++ return value properties as the directory_completion_hook.
++
++ I'm not happy with how this works yet, so it's undocumented. I'm trying
++ it in bash to see how well it goes. */
+ extern rl_icppfunc_t *rl_directory_rewrite_hook;
+
++/* If non-zero, this is the address of a function to call when reading
++ directory entries from the filesystem for completion and comparing
++ them to the partial word to be completed. The function should
++ either return its first argument (if no conversion takes place) or
++ newly-allocated memory. This can, for instance, convert filenames
++ between character sets for comparison against what's typed at the
++ keyboard. The returned value is what is added to the list of
++ matches. The second argument is the length of the filename to be
++ converted. */
++extern rl_dequote_func_t *rl_filename_rewrite_hook;
++
+ /* Backwards compatibility with previous versions of readline. */
+ #define rl_symbolic_link_hook rl_directory_completion_hook
+
+@@ -713,6 +746,9 @@ extern int rl_attempted_completion_over;
+ functions. */
+ extern int rl_completion_type;
+
++/* Set to the last key used to invoke one of the completion functions */
++extern int rl_completion_invoking_key;
++
+ /* Up to this many items will be displayed in response to a
+ possible-completions call. After that, we ask the user if she
+ is sure she wants to see them all. The default value is 100. */
+@@ -739,6 +775,9 @@ extern int rl_completion_found_quote;
+ application-specific completion function. */
+ extern int rl_completion_suppress_quote;
+
++/* If non-zero, readline will sort the completion matches. On by default. */
++extern int rl_sort_completion_matches;
++
+ /* If non-zero, a slash will be appended to completed filenames that are
+ symbolic links to directory names, subject to the value of the
+ mark-directories variable (which is user-settable). This exists so
+@@ -757,6 +796,10 @@ extern int rl_ignore_completion_duplicat
+ completion character will be inserted as any other. */
+ extern int rl_inhibit_completion;
+
++/* Input error; can be returned by (*rl_getc_function) if readline is reading
++ a top-level command (RL_ISSTATE (RL_STATE_READCMD)). */
++#define READERR (-2)
++
+ /* Definitions available for use by readline clients. */
+ #define RL_PROMPT_START_IGNORE '\001'
+ #define RL_PROMPT_END_IGNORE '\002'
+@@ -770,31 +813,32 @@ extern int rl_inhibit_completion;
+ /* Possible state values for rl_readline_state */
+ #define RL_STATE_NONE 0x000000 /* no state; before first call */
+
+-#define RL_STATE_INITIALIZING 0x000001 /* initializing */
+-#define RL_STATE_INITIALIZED 0x000002 /* initialization done */
+-#define RL_STATE_TERMPREPPED 0x000004 /* terminal is prepped */
+-#define RL_STATE_READCMD 0x000008 /* reading a command key */
+-#define RL_STATE_METANEXT 0x000010 /* reading input after ESC */
+-#define RL_STATE_DISPATCHING 0x000020 /* dispatching to a command */
+-#define RL_STATE_MOREINPUT 0x000040 /* reading more input in a command function */
+-#define RL_STATE_ISEARCH 0x000080 /* doing incremental search */
+-#define RL_STATE_NSEARCH 0x000100 /* doing non-inc search */
+-#define RL_STATE_SEARCH 0x000200 /* doing a history search */
+-#define RL_STATE_NUMERICARG 0x000400 /* reading numeric argument */
+-#define RL_STATE_MACROINPUT 0x000800 /* getting input from a macro */
+-#define RL_STATE_MACRODEF 0x001000 /* defining keyboard macro */
+-#define RL_STATE_OVERWRITE 0x002000 /* overwrite mode */
+-#define RL_STATE_COMPLETING 0x004000 /* doing completion */
+-#define RL_STATE_SIGHANDLER 0x008000 /* in readline sighandler */
+-#define RL_STATE_UNDOING 0x010000 /* doing an undo */
+-#define RL_STATE_INPUTPENDING 0x020000 /* rl_execute_next called */
+-#define RL_STATE_TTYCSAVED 0x040000 /* tty special chars saved */
+-#define RL_STATE_CALLBACK 0x080000 /* using the callback interface */
+-#define RL_STATE_VIMOTION 0x100000 /* reading vi motion arg */
+-#define RL_STATE_MULTIKEY 0x200000 /* reading multiple-key command */
+-#define RL_STATE_VICMDONCE 0x400000 /* entered vi command mode at least once */
++#define RL_STATE_INITIALIZING 0x0000001 /* initializing */
++#define RL_STATE_INITIALIZED 0x0000002 /* initialization done */
++#define RL_STATE_TERMPREPPED 0x0000004 /* terminal is prepped */
++#define RL_STATE_READCMD 0x0000008 /* reading a command key */
++#define RL_STATE_METANEXT 0x0000010 /* reading input after ESC */
++#define RL_STATE_DISPATCHING 0x0000020 /* dispatching to a command */
++#define RL_STATE_MOREINPUT 0x0000040 /* reading more input in a command function */
++#define RL_STATE_ISEARCH 0x0000080 /* doing incremental search */
++#define RL_STATE_NSEARCH 0x0000100 /* doing non-inc search */
++#define RL_STATE_SEARCH 0x0000200 /* doing a history search */
++#define RL_STATE_NUMERICARG 0x0000400 /* reading numeric argument */
++#define RL_STATE_MACROINPUT 0x0000800 /* getting input from a macro */
++#define RL_STATE_MACRODEF 0x0001000 /* defining keyboard macro */
++#define RL_STATE_OVERWRITE 0x0002000 /* overwrite mode */
++#define RL_STATE_COMPLETING 0x0004000 /* doing completion */
++#define RL_STATE_SIGHANDLER 0x0008000 /* in readline sighandler */
++#define RL_STATE_UNDOING 0x0010000 /* doing an undo */
++#define RL_STATE_INPUTPENDING 0x0020000 /* rl_execute_next called */
++#define RL_STATE_TTYCSAVED 0x0040000 /* tty special chars saved */
++#define RL_STATE_CALLBACK 0x0080000 /* using the callback interface */
++#define RL_STATE_VIMOTION 0x0100000 /* reading vi motion arg */
++#define RL_STATE_MULTIKEY 0x0200000 /* reading multiple-key command */
++#define RL_STATE_VICMDONCE 0x0400000 /* entered vi command mode at least once */
++#define RL_STATE_REDISPLAYING 0x0800000 /* updating terminal display */
+
+-#define RL_STATE_DONE 0x800000 /* done; accepted line */
++#define RL_STATE_DONE 0x1000000 /* done; accepted line */
+
+ #define RL_SETSTATE(x) (rl_readline_state |= (x))
+ #define RL_UNSETSTATE(x) (rl_readline_state &= ~(x))
+Index: gdb-7.2.90.20110703/readline/rlconf.h
+===================================================================
+--- gdb-7.2.90.20110703.orig/readline/rlconf.h 2011-07-03 10:40:53.000000000 +0200
++++ gdb-7.2.90.20110703/readline/rlconf.h 2011-07-03 10:41:21.000000000 +0200
+@@ -1,25 +1,23 @@
+ /* rlconf.h -- readline configuration definitions */
+
+-/* Copyright (C) 1994 Free Software Foundation, Inc.
++/* Copyright (C) 1992-2009 Free Software Foundation, Inc.
+
+- This file contains the Readline Library (the Library), a set of
+- routines for providing Emacs style line input to programs that ask
+- for it.
++ This file is part of the GNU Readline Library (Readline), a library
++ for reading lines of text with interactive input and history editing.
+
+- The Library is free software; you can redistribute it and/or modify
++ Readline is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+- the Free Software Foundation; either version 2, or (at your option)
+- any later version.
++ the Free Software Foundation, either version 3 of the License, or
++ (at your option) any later version.
+
+- The Library is distributed in the hope that it will be useful, but
+- WITHOUT ANY WARRANTY; without even the implied warranty of
+- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+- General Public License for more details.
+-
+- The GNU General Public License is often shipped with GNU software, and
+- is generally kept in a file called COPYING or LICENSE. If you do not
+- have a copy of the license, write to the Free Software Foundation,
+- 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
++ Readline 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 Readline. If not, see <http://www.gnu.org/licenses/>.
++*/
+
+ #if !defined (_RLCONF_H_)
+ #define _RLCONF_H_
+@@ -37,9 +35,12 @@
+ /* Ugly but working hack for binding prefix meta. */
+ #define PREFIX_META_HACK
+
+-/* The final, last-ditch effort file name for an init file. */
++/* The next-to-last-ditch effort file name for a user-specific init file. */
+ #define DEFAULT_INPUTRC "~/.inputrc"
+
++/* The ultimate last-ditch filenname for an init file -- system-wide. */
++#define SYS_INPUTRC "/etc/inputrc"
++
+ /* If defined, expand tabs to spaces. */
+ #define DISPLAY_TABS
+
+Index: gdb-7.2.90.20110703/readline/rldefs.h
+===================================================================
+--- gdb-7.2.90.20110703.orig/readline/rldefs.h 2011-07-03 10:40:53.000000000 +0200
++++ gdb-7.2.90.20110703/readline/rldefs.h 2011-07-03 10:41:21.000000000 +0200
+@@ -2,26 +2,24 @@
+ for readline. This should be included after any files that define
+ system-specific constants like _POSIX_VERSION or USG. */
+
+-/* Copyright (C) 1987-2005 Free Software Foundation, Inc.
++/* Copyright (C) 1987-2009 Free Software Foundation, Inc.
+
+- This file contains the Readline Library (the Library), a set of
+- routines for providing Emacs style line input to programs that ask
+- for it.
++ This file is part of the GNU Readline Library (Readline), a library
++ for reading lines of text with interactive input and history editing.
+
+- The Library is free software; you can redistribute it and/or modify
++ Readline is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+- the Free Software Foundation; either version 2, or (at your option)
+- any later version.
++ the Free Software Foundation, either version 3 of the License, or
++ (at your option) any later version.
+
+- The Library is distributed in the hope that it will be useful, but
+- WITHOUT ANY WARRANTY; without even the implied warranty of
+- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+- General Public License for more details.
+-
+- The GNU General Public License is often shipped with GNU software, and
+- is generally kept in a file called COPYING or LICENSE. If you do not
+- have a copy of the license, write to the Free Software Foundation,
+- 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
++ Readline 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 Readline. If not, see <http://www.gnu.org/licenses/>.
++*/
+
+ #if !defined (_RLDEFS_H_)
+ #define _RLDEFS_H_
+@@ -32,6 +30,10 @@
+
+ #include "rlstdc.h"
+
++#if defined (STRCOLL_BROKEN)
++# undef HAVE_STRCOLL
++#endif
++
+ #if defined (_POSIX_VERSION) && !defined (TERMIOS_MISSING)
+ # define TERMIOS_TTY_DRIVER
+ #else
+Index: gdb-7.2.90.20110703/readline/rlmbutil.h
+===================================================================
+--- gdb-7.2.90.20110703.orig/readline/rlmbutil.h 2011-07-03 10:40:53.000000000 +0200
++++ gdb-7.2.90.20110703/readline/rlmbutil.h 2011-07-03 10:41:21.000000000 +0200
+@@ -1,24 +1,23 @@
+ /* rlmbutil.h -- utility functions for multibyte characters. */
+
+-/* Copyright (C) 2001, 2003 Free Software Foundation, Inc.
++/* Copyright (C) 2001-2009 Free Software Foundation, Inc.
+
+- This file is part of the GNU Readline Library, a library for
+- reading lines of text with interactive input and history editing.
++ This file is part of the GNU Readline Library (Readline), a library
++ for reading lines of text with interactive input and history editing.
+
+- The GNU Readline Library is free software; you can redistribute it
+- and/or modify it under the terms of the GNU General Public License
+- as published by the Free Software Foundation; either version 2, or
++ Readline 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.
+
+- The GNU Readline Library is distributed in the hope that it will be
+- useful, but WITHOUT ANY WARRANTY; without even the implied warranty
+- of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ Readline 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.
+
+- The GNU General Public License is often shipped with GNU software, and
+- is generally kept in a file called COPYING or LICENSE. If you do not
+- have a copy of the license, write to the Free Software Foundation,
+- 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
++ You should have received a copy of the GNU General Public License
++ along with Readline. If not, see <http://www.gnu.org/licenses/>.
++*/
+
+ #if !defined (_RL_MBUTIL_H_)
+ #define _RL_MBUTIL_H_
+@@ -30,22 +29,21 @@
+ /************************************************/
+
+ /* For platforms which support the ISO C amendement 1 functionality we
+- support user defined character classes.
+-
+- Some platforms have the multibyte functions such as mbsrtowcs but
+- are lacking the multitype type mbstate_t. BeOS (unknown version)
+- and HP/UX 11.23 without _XOPEN_SOURCE=500 are like this.
+-
+- We really need mbstate_t type to operate properly. For example, see
+- compute_lcd_of_matches, where two mbstate_t's are active at the same
+- time. So we require both the functions and the mbstate_t type in
+- order to enable multibyte support. */
+-
++ support user defined character classes. */
+ /* Solaris 2.5 has a bug: <wchar.h> must be included before <wctype.h>. */
+-#if defined (HAVE_WCTYPE_H) && defined (HAVE_WCHAR_H)
++#if defined (HAVE_WCTYPE_H) && defined (HAVE_WCHAR_H) && defined (HAVE_LOCALE_H)
+ # include <wchar.h>
+ # include <wctype.h>
+-# if defined (HAVE_MBSTATE_T) && defined (HAVE_MBSRTOWCS) && defined (HAVE_MBRTOWC) && defined (HAVE_MBRLEN) && defined (HAVE_WCWIDTH)
++# if defined (HAVE_ISWCTYPE) && \
++ defined (HAVE_ISWLOWER) && \
++ defined (HAVE_ISWUPPER) && \
++ defined (HAVE_MBSRTOWCS) && \
++ defined (HAVE_MBRTOWC) && \
++ defined (HAVE_MBRLEN) && \
++ defined (HAVE_TOWLOWER) && \
++ defined (HAVE_TOWUPPER) && \
++ defined (HAVE_WCHAR_T) && \
++ defined (HAVE_WCWIDTH)
+ /* system is supposed to support XPG5 */
+ # define HANDLE_MULTIBYTE 1
+ # endif
+Index: gdb-7.2.90.20110703/readline/rlprivate.h
+===================================================================
+--- gdb-7.2.90.20110703.orig/readline/rlprivate.h 2011-07-03 10:40:53.000000000 +0200
++++ gdb-7.2.90.20110703/readline/rlprivate.h 2011-07-03 10:41:21.000000000 +0200
+@@ -1,25 +1,24 @@
+ /* rlprivate.h -- functions and variables global to the readline library,
+ but not intended for use by applications. */
+
+-/* Copyright (C) 1999-2005 Free Software Foundation, Inc.
++/* Copyright (C) 1999-2010 Free Software Foundation, Inc.
+
+- This file is part of the GNU Readline Library, a library for
+- reading lines of text with interactive input and history editing.
++ This file is part of the GNU Readline Library (Readline), a library
++ for reading lines of text with interactive input and history editing.
+
+- The GNU Readline Library is free software; you can redistribute it
+- and/or modify it under the terms of the GNU General Public License
+- as published by the Free Software Foundation; either version 2, or
++ Readline 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.
+
+- The GNU Readline Library is distributed in the hope that it will be
+- useful, but WITHOUT ANY WARRANTY; without even the implied warranty
+- of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ Readline 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.
+
+- The GNU General Public License is often shipped with GNU software, and
+- is generally kept in a file called COPYING or LICENSE. If you do not
+- have a copy of the license, write to the Free Software Foundation,
+- 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
++ You should have received a copy of the GNU General Public License
++ along with Readline. If not, see <http://www.gnu.org/licenses/>.
++*/
+
+ #if !defined (_RL_PRIVATE_H_)
+ #define _RL_PRIVATE_H_
+@@ -30,6 +29,21 @@
+
+ /*************************************************************************
+ * *
++ * Convenience definitions *
++ * *
++ *************************************************************************/
++
++#define EMACS_MODE() (rl_editing_mode == emacs_mode)
++#define VI_COMMAND_MODE() (rl_editing_mode == vi_mode && _rl_keymap == vi_movement_keymap)
++#define VI_INSERT_MODE() (rl_editing_mode == vi_mode && _rl_keymap == vi_insertion_keymap)
++
++#define RL_CHECK_SIGNALS() \
++ do { \
++ if (_rl_caught_signal) _rl_signal_handler (_rl_caught_signal); \
++ } while (0)
++
++/*************************************************************************
++ * *
+ * Global structs undocumented in texinfo manual and not in readline.h *
+ * *
+ *************************************************************************/
+@@ -42,6 +56,7 @@
+ #define SF_REVERSE 0x01
+ #define SF_FOUND 0x02
+ #define SF_FAILED 0x04
++#define SF_CHGKMAP 0x08
+
+ typedef struct __rl_search_context
+ {
+@@ -65,6 +80,9 @@ typedef struct __rl_search_context
+
+ UNDO_LIST *save_undo_list;
+
++ Keymap keymap; /* used when dispatching commands in search string */
++ Keymap okeymap; /* original keymap */
++
+ int history_pos;
+ int direction;
+
+@@ -106,7 +124,28 @@ typedef struct __rl_keyseq_context
+ int childval;
+ } _rl_keyseq_cxt;
+
+- /* fill in more as needed */
++/* vi-mode commands that use result of motion command to define boundaries */
++#define VIM_DELETE 0x01
++#define VIM_CHANGE 0x02
++#define VIM_YANK 0x04
++
++/* various states for vi-mode commands that use motion commands. reflects
++ RL_READLINE_STATE */
++#define VMSTATE_READ 0x01
++#define VMSTATE_NUMARG 0x02
++
++typedef struct __rl_vimotion_context
++{
++ int op;
++ int state;
++ int flags; /* reserved */
++ _rl_arg_cxt ncxt;
++ int numeric_arg;
++ int start, end; /* rl_point, rl_end */
++ int key, motion; /* initial key, motion command */
++} _rl_vimotion_cxt;
++
++/* fill in more as needed */
+ /* `Generic' callback data and functions */
+ typedef struct __rl_callback_generic_arg
+ {
+@@ -139,12 +178,9 @@ extern int rl_visible_stats;
+ extern int rl_line_buffer_len;
+ extern int rl_arg_sign;
+ extern int rl_visible_prompt_length;
+-extern int readline_echoing_p;
+ extern int rl_key_sequence_length;
+ extern int rl_byte_oriented;
+
+-extern _rl_keyseq_cxt *_rl_kscxt;
+-
+ /* display.c */
+ extern int rl_display_fixed;
+
+@@ -206,6 +242,7 @@ extern void _rl_callback_data_dispose PA
+ /* bind.c */
+
+ /* complete.c */
++extern void _rl_reset_completion_state PARAMS((void));
+ extern char _rl_find_completion_word PARAMS((int *, int *));
+ extern void _rl_free_match_list PARAMS((char **));
+
+@@ -261,6 +298,8 @@ extern void _rl_start_using_history PARA
+ extern int _rl_free_saved_history_line PARAMS((void));
+ extern void _rl_set_insert_mode PARAMS((int, int));
+
++extern void _rl_revert_all_lines PARAMS((void));
++
+ /* nls.c */
+ extern int _rl_init_eightbit PARAMS((void));
+
+@@ -281,6 +320,14 @@ extern int _rl_restore_tty_signals PARAM
+ /* search.c */
+ extern int _rl_nsearch_callback PARAMS((_rl_search_cxt *));
+
++/* signals.c */
++extern void _rl_signal_handler PARAMS((int));
++
++extern void _rl_block_sigint PARAMS((void));
++extern void _rl_release_sigint PARAMS((void));
++extern void _rl_block_sigwinch PARAMS((void));
++extern void _rl_release_sigwinch PARAMS((void));
++
+ /* terminal.c */
+ extern void _rl_get_screen_size PARAMS((int, int));
+ extern int _rl_init_terminal_io PARAMS((const char *));
+@@ -298,6 +345,7 @@ extern void _rl_set_cursor PARAMS((int,
+ /* text.c */
+ extern void _rl_fix_point PARAMS((int));
+ extern int _rl_replace_text PARAMS((const char *, int, int));
++extern int _rl_forward_char_internal PARAMS((int));
+ extern int _rl_insert_char PARAMS((int, int));
+ extern int _rl_overwrite_char PARAMS((int, int));
+ extern int _rl_overwrite_rubout PARAMS((int, int));
+@@ -309,8 +357,25 @@ extern int _rl_char_search_internal PARA
+ #endif
+ extern int _rl_set_mark_at_pos PARAMS((int));
+
++/* undo.c */
++extern UNDO_LIST *_rl_copy_undo_entry PARAMS((UNDO_LIST *));
++extern UNDO_LIST *_rl_copy_undo_list PARAMS((UNDO_LIST *));
++
+ /* util.c */
++#if defined (USE_VARARGS) && defined (PREFER_STDARG)
++extern void _rl_ttymsg (const char *, ...) __attribute__((__format__ (printf, 1, 2)));
++extern void _rl_errmsg (const char *, ...) __attribute__((__format__ (printf, 1, 2)));
++extern void _rl_trace (const char *, ...) __attribute__((__format__ (printf, 1, 2)));
++#else
++extern void _rl_ttymsg ();
++extern void _rl_errmsg ();
++extern void _rl_trace ();
++#endif
++
++extern int _rl_tropen PARAMS((void));
++
+ extern int _rl_abort_internal PARAMS((void));
++extern int _rl_null_function PARAMS((int, int));
+ extern char *_rl_strindex PARAMS((const char *, const char *));
+ extern int _rl_qsort_string_compare PARAMS((char **, char **));
+ extern int (_rl_uppercase_p) PARAMS((int));
+@@ -327,14 +392,15 @@ extern void _rl_vi_reset_last PARAMS((vo
+ extern void _rl_vi_set_last PARAMS((int, int, int));
+ extern int _rl_vi_textmod_command PARAMS((int));
+ extern void _rl_vi_done_inserting PARAMS((void));
++extern int _rl_vi_domove_callback PARAMS((_rl_vimotion_cxt *));
+
+ /*************************************************************************
+ * Undocumented private variables *
+ *************************************************************************/
+
+ /* bind.c */
+-extern const char *_rl_possible_control_prefixes[];
+-extern const char *_rl_possible_meta_prefixes[];
++extern const char * const _rl_possible_control_prefixes[];
++extern const char * const _rl_possible_meta_prefixes[];
+
+ /* callback.c */
+ extern _rl_callback_func_t *_rl_callback_func;
+@@ -345,17 +411,21 @@ extern int _rl_complete_show_all;
+ extern int _rl_complete_show_unmodified;
+ extern int _rl_complete_mark_directories;
+ extern int _rl_complete_mark_symlink_dirs;
++extern int _rl_completion_prefix_display_length;
++extern int _rl_completion_columns;
+ extern int _rl_print_completions_horizontally;
+ extern int _rl_completion_case_fold;
++extern int _rl_completion_case_map;
+ extern int _rl_match_hidden_files;
+ extern int _rl_page_completions;
++extern int _rl_skip_completed_text;
++extern int _rl_menu_complete_prefix_first;
+
+ /* display.c */
+ extern int _rl_vis_botlin;
+ extern int _rl_last_c_pos;
+ extern int _rl_suppress_redisplay;
+ extern int _rl_want_redisplay;
+-extern char *rl_display_prompt;
+
+ /* isearch.c */
+ extern char *_rl_isearch_terminators;
+@@ -372,6 +442,7 @@ extern int _rl_history_saved_point;
+ extern _rl_arg_cxt _rl_argcxt;
+
+ /* readline.c */
++extern int _rl_echoing_p;
+ extern int _rl_horizontal_scroll_mode;
+ extern int _rl_mark_modified_lines;
+ extern int _rl_bell_preference;
+@@ -379,6 +450,8 @@ extern int _rl_meta_flag;
+ extern int _rl_convert_meta_chars_to_ascii;
+ extern int _rl_output_meta_chars;
+ extern int _rl_bind_stty_chars;
++extern int _rl_revert_all_at_newline;
++extern int _rl_echo_control_chars;
+ extern char *_rl_comment_begin;
+ extern unsigned char _rl_parsing_conditionalized_out;
+ extern Keymap _rl_keymap;
+@@ -386,11 +459,22 @@ extern FILE *_rl_in_stream;
+ extern FILE *_rl_out_stream;
+ extern int _rl_last_command_was_kill;
+ extern int _rl_eof_char;
+-extern procenv_t readline_top_level;
++extern procenv_t _rl_top_level;
++extern _rl_keyseq_cxt *_rl_kscxt;
+
+ /* search.c */
+ extern _rl_search_cxt *_rl_nscxt;
+
++/* signals.c */
++extern int _rl_interrupt_immediately;
++extern int volatile _rl_caught_signal;
++
++extern int _rl_echoctl;
++
++extern int _rl_intr_char;
++extern int _rl_quit_char;
++extern int _rl_susp_char;
++
+ /* terminal.c */
+ extern int _rl_enable_keypad;
+ extern int _rl_enable_meta;
+@@ -404,6 +488,7 @@ extern char *_rl_term_up;
+ extern char *_rl_term_dc;
+ extern char *_rl_term_cr;
+ extern char *_rl_term_IC;
++extern char *_rl_term_forward_char;
+ extern int _rl_screenheight;
+ extern int _rl_screenwidth;
+ extern int _rl_screenchars;
+@@ -416,5 +501,6 @@ extern int _rl_undo_group_level;
+
+ /* vi_mode.c */
+ extern int _rl_vi_last_command;
++extern _rl_vimotion_cxt *_rl_vimvcxt;
+
+ #endif /* _RL_PRIVATE_H_ */
+Index: gdb-7.2.90.20110703/readline/rlshell.h
+===================================================================
+--- gdb-7.2.90.20110703.orig/readline/rlshell.h 2011-07-03 10:40:53.000000000 +0200
++++ gdb-7.2.90.20110703/readline/rlshell.h 2011-07-03 10:41:21.000000000 +0200
+@@ -1,24 +1,23 @@
+ /* rlshell.h -- utility functions normally provided by bash. */
+
+-/* Copyright (C) 1999 Free Software Foundation, Inc.
++/* Copyright (C) 1999-2009 Free Software Foundation, Inc.
+
+- This file is part of the GNU Readline Library, a library for
+- reading lines of text with interactive input and history editing.
++ This file is part of the GNU Readline Library (Readline), a library
++ for reading lines of text with interactive input and history editing.
+
+- The GNU Readline Library is free software; you can redistribute it
+- and/or modify it under the terms of the GNU General Public License
+- as published by the Free Software Foundation; either version 2, or
++ Readline 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.
+
+- The GNU Readline Library is distributed in the hope that it will be
+- useful, but WITHOUT ANY WARRANTY; without even the implied warranty
+- of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ Readline 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.
+
+- The GNU General Public License is often shipped with GNU software, and
+- is generally kept in a file called COPYING or LICENSE. If you do not
+- have a copy of the license, write to the Free Software Foundation,
+- 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
++ You should have received a copy of the GNU General Public License
++ along with Readline. If not, see <http://www.gnu.org/licenses/>.
++*/
+
+ #if !defined (_RL_SHELL_H_)
+ #define _RL_SHELL_H_
+Index: gdb-7.2.90.20110703/readline/rlstdc.h
+===================================================================
+--- gdb-7.2.90.20110703.orig/readline/rlstdc.h 2011-07-03 10:40:53.000000000 +0200
++++ gdb-7.2.90.20110703/readline/rlstdc.h 2011-07-03 10:41:21.000000000 +0200
+@@ -1,23 +1,23 @@
+-/* stdc.h -- macros to make source compile on both ANSI C and K&R C
+- compilers. */
++/* stdc.h -- macros to make source compile on both ANSI C and K&R C compilers. */
+
+-/* Copyright (C) 1993 Free Software Foundation, Inc.
++/* Copyright (C) 1993-2009 Free Software Foundation, Inc.
+
+- This file is part of GNU Bash, the Bourne Again SHell.
++ This file is part of the GNU Readline Library (Readline), a library
++ for reading lines of text with interactive input and history editing.
+
+- Bash is free software; you can redistribute it and/or modify it
+- under the terms of the GNU General Public License as published by
+- the Free Software Foundation; either version 2, or (at your option)
+- any later version.
+-
+- Bash 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.
++ Readline 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.
++
++ Readline 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 Bash; see the file COPYING. If not, write to the Free
+- Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
++ along with Readline. If not, see <http://www.gnu.org/licenses/>.
++*/
+
+ #if !defined (_RL_STDC_H_)
+ #define _RL_STDC_H_
+Index: gdb-7.2.90.20110703/readline/rltty.c
+===================================================================
+--- gdb-7.2.90.20110703.orig/readline/rltty.c 2011-07-03 10:40:53.000000000 +0200
++++ gdb-7.2.90.20110703/readline/rltty.c 2011-07-03 10:41:21.000000000 +0200
+@@ -3,23 +3,23 @@
+
+ /* Copyright (C) 1992-2005 Free Software Foundation, Inc.
+
+- This file is part of the GNU Readline Library, a library for
+- reading lines of text with interactive input and history editing.
++ This file is part of the GNU Readline Library (Readline), a library
++ for reading lines of text with interactive input and history editing.
+
+- The GNU Readline Library is free software; you can redistribute it
+- and/or modify it under the terms of the GNU General Public License
+- as published by the Free Software Foundation; either version 2, or
++ Readline 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.
+
+- The GNU Readline Library is distributed in the hope that it will be
+- useful, but WITHOUT ANY WARRANTY; without even the implied warranty
+- of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ Readline 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.
+
+- The GNU General Public License is often shipped with GNU software, and
+- is generally kept in a file called COPYING or LICENSE. If you do not
+- have a copy of the license, write to the Free Software Foundation,
+- 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
++ You should have received a copy of the GNU General Public License
++ along with Readline. If not, see <http://www.gnu.org/licenses/>.
++*/
++
+ #define READLINE_LIBRARY
+
+ #if defined (HAVE_CONFIG_H)
+@@ -52,77 +52,10 @@ extern int errno;
+ rl_vintfunc_t *rl_prep_term_function = rl_prep_terminal;
+ rl_voidfunc_t *rl_deprep_term_function = rl_deprep_terminal;
+
+-void _rl_block_sigint PARAMS((void));
+-void _rl_release_sigint PARAMS((void));
+-
+ static void set_winsize PARAMS((int));
+
+ /* **************************************************************** */
+ /* */
+-/* Signal Management */
+-/* */
+-/* **************************************************************** */
+-
+-#if defined (HAVE_POSIX_SIGNALS)
+-static sigset_t sigint_set, sigint_oset;
+-#else /* !HAVE_POSIX_SIGNALS */
+-# if defined (HAVE_BSD_SIGNALS)
+-static int sigint_oldmask;
+-# endif /* HAVE_BSD_SIGNALS */
+-#endif /* !HAVE_POSIX_SIGNALS */
+-
+-static int sigint_blocked;
+-
+-/* Cause SIGINT to not be delivered until the corresponding call to
+- _rl_release_sigint(). */
+-void
+-_rl_block_sigint ()
+-{
+- if (sigint_blocked)
+- return;
+-
+-#if defined (HAVE_POSIX_SIGNALS)
+- sigemptyset (&sigint_set);
+- sigemptyset (&sigint_oset);
+- sigaddset (&sigint_set, SIGINT);
+- sigprocmask (SIG_BLOCK, &sigint_set, &sigint_oset);
+-#else /* !HAVE_POSIX_SIGNALS */
+-# if defined (HAVE_BSD_SIGNALS)
+- sigint_oldmask = sigblock (sigmask (SIGINT));
+-# else /* !HAVE_BSD_SIGNALS */
+-# if defined (HAVE_USG_SIGHOLD)
+- sighold (SIGINT);
+-# endif /* HAVE_USG_SIGHOLD */
+-# endif /* !HAVE_BSD_SIGNALS */
+-#endif /* !HAVE_POSIX_SIGNALS */
+-
+- sigint_blocked = 1;
+-}
+-
+-/* Allow SIGINT to be delivered. */
+-void
+-_rl_release_sigint ()
+-{
+- if (sigint_blocked == 0)
+- return;
+-
+-#if defined (HAVE_POSIX_SIGNALS)
+- sigprocmask (SIG_SETMASK, &sigint_oset, (sigset_t *)NULL);
+-#else
+-# if defined (HAVE_BSD_SIGNALS)
+- sigsetmask (sigint_oldmask);
+-# else /* !HAVE_BSD_SIGNALS */
+-# if defined (HAVE_USG_SIGHOLD)
+- sigrelse (SIGINT);
+-# endif /* HAVE_USG_SIGHOLD */
+-# endif /* !HAVE_BSD_SIGNALS */
+-#endif /* !HAVE_POSIX_SIGNALS */
+-
+- sigint_blocked = 0;
+-}
+-
+-/* **************************************************************** */
+-/* */
+ /* Saving and Restoring the TTY */
+ /* */
+ /* **************************************************************** */
+@@ -204,8 +137,9 @@ save_tty_chars (tiop)
+
+ if (tiop->flags & TCHARS_SET)
+ {
+- _rl_tty_chars.t_intr = tiop->tchars.t_intrc;
+- _rl_tty_chars.t_quit = tiop->tchars.t_quitc;
++ _rl_intr_char = _rl_tty_chars.t_intr = tiop->tchars.t_intrc;
++ _rl_quit_char = _rl_tty_chars.t_quit = tiop->tchars.t_quitc;
++
+ _rl_tty_chars.t_start = tiop->tchars.t_startc;
+ _rl_tty_chars.t_stop = tiop->tchars.t_stopc;
+ _rl_tty_chars.t_eof = tiop->tchars.t_eofc;
+@@ -215,7 +149,8 @@ save_tty_chars (tiop)
+
+ if (tiop->flags & LTCHARS_SET)
+ {
+- _rl_tty_chars.t_susp = tiop->ltchars.t_suspc;
++ _rl_susp_char = _rl_tty_chars.t_susp = tiop->ltchars.t_suspc;
++
+ _rl_tty_chars.t_dsusp = tiop->ltchars.t_dsuspc;
+ _rl_tty_chars.t_reprint = tiop->ltchars.t_rprntc;
+ _rl_tty_chars.t_flush = tiop->ltchars.t_flushc;
+@@ -268,7 +203,7 @@ set_tty_settings (tty, tiop)
+ ioctl (tty, TIOCSETN, &(tiop->sgttyb));
+ tiop->flags &= ~SGTTY_SET;
+ }
+- readline_echoing_p = 1;
++ _rl_echoing_p = 1;
+
+ #if defined (TIOCLSET)
+ if (tiop->flags & LFLAG_SET)
+@@ -302,7 +237,8 @@ prepare_terminal_settings (meta_flag, ol
+ int meta_flag;
+ TIOTYPE oldtio, *tiop;
+ {
+- readline_echoing_p = (oldtio.sgttyb.sg_flags & ECHO);
++ _rl_echoing_p = (oldtio.sgttyb.sg_flags & ECHO);
++ _rl_echoctl = (oldtio.sgttyb.sg_flags & ECHOCTL);
+
+ /* Copy the original settings to the structure we're going to use for
+ our settings. */
+@@ -433,10 +369,10 @@ save_tty_chars (tiop)
+ #ifdef VREPRINT
+ _rl_tty_chars.t_reprint = tiop->c_cc[VREPRINT];
+ #endif
+- _rl_tty_chars.t_intr = tiop->c_cc[VINTR];
+- _rl_tty_chars.t_quit = tiop->c_cc[VQUIT];
++ _rl_intr_char = _rl_tty_chars.t_intr = tiop->c_cc[VINTR];
++ _rl_quit_char = _rl_tty_chars.t_quit = tiop->c_cc[VQUIT];
+ #ifdef VSUSP
+- _rl_tty_chars.t_susp = tiop->c_cc[VSUSP];
++ _rl_susp_char = _rl_tty_chars.t_susp = tiop->c_cc[VSUSP];
+ #endif
+ #ifdef VDSUSP
+ _rl_tty_chars.t_dsusp = tiop->c_cc[VDSUSP];
+@@ -464,7 +400,7 @@ static void
+ rltty_warning (msg)
+ char *msg;
+ {
+- fprintf (stderr, "readline: warning: %s\n", msg);
++ _rl_errmsg ("warning: %s", msg);
+ }
+ #endif
+
+@@ -475,7 +411,7 @@ TIOTYPE *tp;
+ {
+ if ((tp->c_oflag & OPOST) == 0)
+ {
+- rltty_warning ("turning on OPOST for terminal\r");
++ _rl_errmsg ("warning: turning on OPOST for terminal\r");
+ tp->c_oflag |= OPOST|ONLCR;
+ }
+ }
+@@ -500,8 +436,8 @@ _get_tty_settings (tty, tiop)
+ }
+ if (OUTPUT_BEING_FLUSHED (tiop))
+ {
+-#if defined (FLUSHO) && defined (_AIX41)
+- rltty_warning ("turning off output flushing");
++#if defined (FLUSHO)
++ _rl_errmsg ("warning: turning off output flushing");
+ tiop->c_lflag &= ~FLUSHO;
+ break;
+ #else
+@@ -580,7 +516,10 @@ prepare_terminal_settings (meta_flag, ol
+ int meta_flag;
+ TIOTYPE oldtio, *tiop;
+ {
+- readline_echoing_p = (oldtio.c_lflag & ECHO);
++ _rl_echoing_p = (oldtio.c_lflag & ECHO);
++#if defined (ECHOCTL)
++ _rl_echoctl = (oldtio.c_lflag & ECHOCTL);
++#endif
+
+ tiop->c_lflag &= ~(ICANON | ECHO);
+
+@@ -643,7 +582,7 @@ void
+ rl_prep_terminal (meta_flag)
+ int meta_flag;
+ {
+- readline_echoing_p = 1;
++ _rl_echoing_p = 1;
+ }
+
+ void
+@@ -665,17 +604,19 @@ rl_prep_terminal (meta_flag)
+ /* Try to keep this function from being INTerrupted. */
+ _rl_block_sigint ();
+
+- tty = fileno (rl_instream);
++ tty = rl_instream ? fileno (rl_instream) : fileno (stdin);
+
+ if (get_tty_settings (tty, &tio) < 0)
+ {
+ #if defined (ENOTSUP)
+- /* MacOS X, at least, lies about the value of errno if tcgetattr fails. */
+- if (errno == ENOTTY || errno == ENOTSUP)
++ /* MacOS X and Linux, at least, lie about the value of errno if
++ tcgetattr fails. */
++ if (errno == ENOTTY || errno == EINVAL || errno == ENOTSUP)
+ #else
+- if (errno == ENOTTY)
++ if (errno == ENOTTY || errno == EINVAL)
+ #endif
+- readline_echoing_p = 1; /* XXX */
++ _rl_echoing_p = 1; /* XXX */
++
+ _rl_release_sigint ();
+ return;
+ }
+@@ -737,7 +678,7 @@ rl_deprep_terminal ()
+ /* Try to keep this function from being interrupted. */
+ _rl_block_sigint ();
+
+- tty = fileno (rl_instream);
++ tty = rl_instream ? fileno (rl_instream) : fileno (stdout);
+
+ if (_rl_enable_keypad)
+ _rl_control_keypad (0);
+@@ -862,7 +803,7 @@ set_special_char (kmap, tiop, sc, func)
+ }
+
+ #define RESET_SPECIAL(c) \
+- if (c != -1 && kmap[(unsigned char)c].type == ISFUNC)
++ if (c != -1 && kmap[(unsigned char)c].type == ISFUNC) \
+ kmap[(unsigned char)c].function = rl_insert;
+
+ static void
+@@ -933,7 +874,6 @@ rltty_set_default_bindings (kmap)
+ #if !defined (NO_TTY_DRIVER)
+ TIOTYPE ttybuff;
+ int tty;
+- static int called = 0;
+
+ tty = fileno (rl_instream);
+
+Index: gdb-7.2.90.20110703/readline/rltty.h
+===================================================================
+--- gdb-7.2.90.20110703.orig/readline/rltty.h 2011-07-03 10:40:53.000000000 +0200
++++ gdb-7.2.90.20110703/readline/rltty.h 2011-07-03 10:41:21.000000000 +0200
+@@ -1,25 +1,23 @@
+ /* rltty.h - tty driver-related definitions used by some library files. */
+
+-/* Copyright (C) 1995 Free Software Foundation, Inc.
++/* Copyright (C) 1995-2009 Free Software Foundation, Inc.
+
+- This file contains the Readline Library (the Library), a set of
+- routines for providing Emacs style line input to programs that ask
+- for it.
++ This file is part of the GNU Readline Library (Readline), a library
++ for reading lines of text with interactive input and history editing.
+
+- The Library is free software; you can redistribute it and/or modify
++ Readline is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+- the Free Software Foundation; either version 2, or (at your option)
+- any later version.
++ the Free Software Foundation, either version 3 of the License, or
++ (at your option) any later version.
+
+- The Library is distributed in the hope that it will be useful, but
+- WITHOUT ANY WARRANTY; without even the implied warranty of
+- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+- General Public License for more details.
+-
+- The GNU General Public License is often shipped with GNU software, and
+- is generally kept in a file called COPYING or LICENSE. If you do not
+- have a copy of the license, write to the Free Software Foundation,
+- 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
++ Readline 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 Readline. If not, see <http://www.gnu.org/licenses/>.
++*/
+
+ #if !defined (_RLTTY_H_)
+ #define _RLTTY_H_
+@@ -79,7 +77,4 @@ typedef struct _rl_tty_chars {
+ unsigned char t_status;
+ } _RL_TTY_CHARS;
+
+-extern void _rl_block_sigint PARAMS((void));
+-extern void _rl_release_sigint PARAMS((void));
+-
+ #endif /* _RLTTY_H_ */
+Index: gdb-7.2.90.20110703/readline/rltypedefs.h
+===================================================================
+--- gdb-7.2.90.20110703.orig/readline/rltypedefs.h 2011-07-03 10:40:53.000000000 +0200
++++ gdb-7.2.90.20110703/readline/rltypedefs.h 2011-07-03 10:41:21.000000000 +0200
+@@ -1,24 +1,23 @@
+ /* rltypedefs.h -- Type declarations for readline functions. */
+
+-/* Copyright (C) 2000-2004 Free Software Foundation, Inc.
++/* Copyright (C) 2000-2009 Free Software Foundation, Inc.
+
+- This file is part of the GNU Readline Library, a library for
+- reading lines of text with interactive input and history editing.
++ This file is part of the GNU Readline Library (Readline), a library
++ for reading lines of text with interactive input and history editing.
+
+- The GNU Readline Library is free software; you can redistribute it
+- and/or modify it under the terms of the GNU General Public License
+- as published by the Free Software Foundation; either version 2, or
++ Readline 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.
+
+- The GNU Readline Library is distributed in the hope that it will be
+- useful, but WITHOUT ANY WARRANTY; without even the implied warranty
+- of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ Readline 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.
+
+- The GNU General Public License is often shipped with GNU software, and
+- is generally kept in a file called COPYING or LICENSE. If you do not
+- have a copy of the license, write to the Free Software Foundation,
+- 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
++ You should have received a copy of the GNU General Public License
++ along with Readline. If not, see <http://www.gnu.org/licenses/>.
++*/
+
+ #ifndef _RL_TYPEDEFS_H_
+ #define _RL_TYPEDEFS_H_
+Index: gdb-7.2.90.20110703/readline/rlwinsize.h
+===================================================================
+--- gdb-7.2.90.20110703.orig/readline/rlwinsize.h 2011-07-03 10:40:53.000000000 +0200
++++ gdb-7.2.90.20110703/readline/rlwinsize.h 2011-07-03 10:41:21.000000000 +0200
+@@ -1,26 +1,24 @@
+ /* rlwinsize.h -- an attempt to isolate some of the system-specific defines
+ for `struct winsize' and TIOCGWINSZ. */
+
+-/* Copyright (C) 1997 Free Software Foundation, Inc.
++/* Copyright (C) 1997-2009 Free Software Foundation, Inc.
+
+- This file contains the Readline Library (the Library), a set of
+- routines for providing Emacs style line input to programs that ask
+- for it.
++ This file is part of the GNU Readline Library (Readline), a library
++ for reading lines of text with interactive input and history editing.
+
+- The Library is free software; you can redistribute it and/or modify
++ Readline is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+- the Free Software Foundation; either version 2, or (at your option)
+- any later version.
++ the Free Software Foundation, either version 3 of the License, or
++ (at your option) any later version.
+
+- The Library is distributed in the hope that it will be useful, but
+- WITHOUT ANY WARRANTY; without even the implied warranty of
+- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+- General Public License for more details.
+-
+- The GNU General Public License is often shipped with GNU software, and
+- is generally kept in a file called COPYING or LICENSE. If you do not
+- have a copy of the license, write to the Free Software Foundation,
+- 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
++ Readline 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 Readline. If not, see <http://www.gnu.org/licenses/>.
++*/
+
+ #if !defined (_RLWINSIZE_H_)
+ #define _RLWINSIZE_H_
+@@ -53,5 +51,8 @@
+ # endif /* HAVE_SYS_PTE_H */
+ #endif /* !STRUCT_WINSIZE_IN_TERMIOS && !STRUCT_WINSIZE_IN_SYS_IOCTL */
+
+-#endif /* _RL_WINSIZE_H */
++#if defined (M_UNIX) && !defined (_SCO_DS) && !defined (tcflow)
++# define tcflow(fd, action) ioctl(fd, TCXONC, action)
++#endif
+
++#endif /* _RL_WINSIZE_H */
+Index: gdb-7.2.90.20110703/readline/savestring.c
+===================================================================
+--- gdb-7.2.90.20110703.orig/readline/savestring.c 2011-07-03 10:40:53.000000000 +0200
++++ gdb-7.2.90.20110703/readline/savestring.c 2011-07-03 10:41:21.000000000 +0200
+@@ -1,24 +1,24 @@
+-/* savestring.c */
++/* savestring.c - function version of savestring for backwards compatibility */
+
+ /* Copyright (C) 1998,2003 Free Software Foundation, Inc.
+
+- This file is part of the GNU Readline Library, a library for
+- reading lines of text with interactive input and history editing.
++ This file is part of the GNU Readline Library (Readline), a library
++ for reading lines of text with interactive input and history editing.
+
+- The GNU Readline Library is free software; you can redistribute it
+- and/or modify it under the terms of the GNU General Public License
+- as published by the Free Software Foundation; either version 2, or
++ Readline 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.
+
+- The GNU Readline Library is distributed in the hope that it will be
+- useful, but WITHOUT ANY WARRANTY; without even the implied warranty
+- of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ Readline 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.
+
+- The GNU General Public License is often shipped with GNU software, and
+- is generally kept in a file called COPYING or LICENSE. If you do not
+- have a copy of the license, write to the Free Software Foundation,
+- 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
++ You should have received a copy of the GNU General Public License
++ along with Readline. If not, see <http://www.gnu.org/licenses/>.
++*/
++
+ #define READLINE_LIBRARY
+
+ #include <config.h>
+@@ -33,5 +33,9 @@ char *
+ savestring (s)
+ const char *s;
+ {
+- return ((char *)strcpy ((char *)xmalloc (1 + strlen (s)), (s)));
++ char *ret;
++
++ ret = (char *)xmalloc (strlen (s) + 1);
++ strcpy (ret, s);
++ return ret;
+ }
+Index: gdb-7.2.90.20110703/readline/search.c
+===================================================================
+--- gdb-7.2.90.20110703.orig/readline/search.c 2011-07-03 10:40:53.000000000 +0200
++++ gdb-7.2.90.20110703/readline/search.c 2011-07-03 10:41:21.000000000 +0200
+@@ -1,25 +1,24 @@
+ /* search.c - code for non-incremental searching in emacs and vi modes. */
+
+-/* Copyright (C) 1992-2005 Free Software Foundation, Inc.
++/* Copyright (C) 1992-2009 Free Software Foundation, Inc.
+
+- This file is part of the Readline Library (the Library), a set of
+- routines for providing Emacs style line input to programs that ask
+- for it.
++ This file is part of the GNU Readline Library (Readline), a library
++ for reading lines of text with interactive input and history editing.
+
+- The Library is free software; you can redistribute it and/or modify
++ Readline is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+- the Free Software Foundation; either version 2, or (at your option)
+- any later version.
++ the Free Software Foundation, either version 3 of the License, or
++ (at your option) any later version.
++
++ Readline 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 Readline. If not, see <http://www.gnu.org/licenses/>.
++*/
+
+- The Library is distributed in the hope that it will be useful, but
+- WITHOUT ANY WARRANTY; without even the implied warranty of
+- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+- General Public License for more details.
+-
+- The GNU General Public License is often shipped with GNU software, and
+- is generally kept in a file called COPYING or LICENSE. If you do not
+- have a copy of the license, write to the Free Software Foundation,
+- 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
+ #define READLINE_LIBRARY
+
+ #if defined (HAVE_CONFIG_H)
+@@ -70,7 +69,6 @@ static int rl_history_search_pos;
+ static char *history_search_string;
+ static int history_string_size;
+
+-static UNDO_LIST *noninc_saved_undo_list;
+ static void make_history_line_current PARAMS((HIST_ENTRY *));
+ static int noninc_search_from_pos PARAMS((char *, int, int));
+ static int noninc_dosearch PARAMS((char *, int));
+@@ -212,8 +210,8 @@ _rl_nsearch_init (dir, pchar)
+ rl_end = rl_point = 0;
+
+ p = _rl_make_prompt_for_search (pchar ? pchar : ':');
+- rl_message (p, 0, 0);
+- free (p);
++ rl_message ("%s", p, 0);
++ xfree (p);
+
+ RL_SETSTATE(RL_STATE_NSEARCH);
+
+Index: gdb-7.2.90.20110703/readline/shell.c
+===================================================================
+--- gdb-7.2.90.20110703.orig/readline/shell.c 2011-07-03 10:40:53.000000000 +0200
++++ gdb-7.2.90.20110703/readline/shell.c 2011-07-03 10:41:21.000000000 +0200
+@@ -1,25 +1,25 @@
+ /* shell.c -- readline utility functions that are normally provided by
+ bash when readline is linked as part of the shell. */
+
+-/* Copyright (C) 1997 Free Software Foundation, Inc.
++/* Copyright (C) 1997-2009 Free Software Foundation, Inc.
+
+- This file is part of the GNU Readline Library, a library for
+- reading lines of text with interactive input and history editing.
++ This file is part of the GNU Readline Library (Readline), a library
++ for reading lines of text with interactive input and history editing.
+
+- The GNU Readline Library is free software; you can redistribute it
+- and/or modify it under the terms of the GNU General Public License
+- as published by the Free Software Foundation; either version 2, or
++ Readline 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.
+
+- The GNU Readline Library is distributed in the hope that it will be
+- useful, but WITHOUT ANY WARRANTY; without even the implied warranty
+- of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ Readline 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.
+
+- The GNU General Public License is often shipped with GNU software, and
+- is generally kept in a file called COPYING or LICENSE. If you do not
+- have a copy of the license, write to the Free Software Foundation,
+- 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
++ You should have received a copy of the GNU General Public License
++ along with Readline. If not, see <http://www.gnu.org/licenses/>.
++*/
++
+ #define READLINE_LIBRARY
+
+ #if defined (HAVE_CONFIG_H)
+@@ -130,12 +130,12 @@ sh_set_lines_and_columns (lines, cols)
+ b = (char *)xmalloc (INT_STRLEN_BOUND (int) + 1);
+ sprintf (b, "%d", lines);
+ setenv ("LINES", b, 1);
+- free (b);
++ xfree (b);
+
+ b = (char *)xmalloc (INT_STRLEN_BOUND (int) + 1);
+ sprintf (b, "%d", cols);
+ setenv ("COLUMNS", b, 1);
+- free (b);
++ xfree (b);
+ #else /* !HAVE_SETENV */
+ # if defined (HAVE_PUTENV)
+ b = (char *)xmalloc (INT_STRLEN_BOUND (int) + sizeof ("LINES=") + 1);
+Index: gdb-7.2.90.20110703/readline/shlib/Makefile.in
+===================================================================
+--- gdb-7.2.90.20110703.orig/readline/shlib/Makefile.in 2011-07-03 10:40:53.000000000 +0200
++++ gdb-7.2.90.20110703/readline/shlib/Makefile.in 2011-07-03 10:41:21.000000000 +0200
+@@ -1,21 +1,20 @@
+ ## -*- text -*- ##
+ # Makefile for the GNU readline library shared library support.
+ #
+-# Copyright (C) 1998-2003 Free Software Foundation, Inc.
++# Copyright (C) 1998-2009 Free Software Foundation, Inc.
+
+-# This program is free software; you can redistribute it and/or modify
+-# it under the terms of the GNU General Public License as published by
+-# the Free Software Foundation; either version 2, or (at your option)
+-# any later version.
+-
+-# This program is distributed in the hope that it will be useful,
+-# but WITHOUT ANY WARRANTY; without even the implied warranty of
+-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+-# GNU General Public License for more details.
+-
+-# You should have received a copy of the GNU General Public License
+-# along with this program; if not, write to the Free Software
+-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA.
++# This program is free software: you can redistribute it and/or modify
++# it under the terms of the GNU General Public License as published by
++# the Free Software Foundation, either version 3 of the License, or
++# (at your option) any later version.
++
++# This program is distributed in the hope that it will be useful,
++# but WITHOUT ANY WARRANTY; without even the implied warranty of
++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++# GNU General Public License for more details.
++
++# You should have received a copy of the GNU General Public License
++# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+ PACKAGE = @PACKAGE_NAME@
+ VERSION = @PACKAGE_VERSION@
+@@ -31,7 +30,7 @@ RL_LIBRARY_NAME = readline
+ datarootdir = @datarootdir@
+
+ srcdir = @srcdir@
+-VPATH = .:@top_srcdir@
++VPATH = @top_srcdir@
+ topdir = @top_srcdir@
+ BUILD_DIR = @BUILD_DIR@
+
+@@ -51,6 +50,7 @@ LN = ln
+ SHELL = @MAKE_SHELL@
+
+ host_os = @host_os@
++host_vendor = @host_vendor@
+
+ prefix = @prefix@
+ exec_prefix = @exec_prefix@
+@@ -58,7 +58,7 @@ includedir = @includedir@
+ bindir = @bindir@
+ libdir = @libdir@
+ datadir = @datadir@
+-localedir = $(datadir)/locale
++localedir = @localedir@
+
+ # Support an alternate destination root directory for package building
+ DESTDIR =
+@@ -122,8 +122,6 @@ SHARED_READLINE = $(SHLIB_LIBPREF)readli
+ SHARED_HISTORY = $(SHLIB_LIBPREF)history$(SHLIB_DOT)$(SHLIB_LIBVERSION)
+ SHARED_LIBS = $(SHARED_READLINE) $(SHARED_HISTORY)
+
+-WCWIDTH_OBJ = @WCWIDTH_OBJ@
+-
+ # The C code source files for this library.
+ CSOURCES = $(topdir)/readline.c $(topdir)/funmap.c $(topdir)/keymaps.c \
+ $(topdir)/vi_mode.c $(topdir)/parens.c $(topdir)/rltty.c \
+@@ -131,12 +129,12 @@ CSOURCES = $(topdir)/readline.c $(topdir
+ $(topdir)/display.c $(topdir)/signals.c $(topdir)/emacs_keymap.c \
+ $(topdir)/vi_keymap.c $(topdir)/util.c $(topdir)/kill.c \
+ $(topdir)/undo.c $(topdir)/macro.c $(topdir)/input.c \
+- $(topdir)/callback.c $(topdir)/terminal.c $(topdir)/xmalloc.c \
++ $(topdir)/callback.c $(topdir)/terminal.c $(topdir)/xmalloc.c $(topdir)/xfree.c \
+ $(topdir)/history.c $(topdir)/histsearch.c $(topdir)/histexpand.c \
+ $(topdir)/histfile.c $(topdir)/nls.c $(topdir)/search.c \
+ $(topdir)/shell.c $(topdir)/savestring.c $(topdir)/tilde.c \
+ $(topdir)/text.c $(topdir)/misc.c $(topdir)/compat.c \
+- $(topdir)/mbutil.c $(topdir)/support/wcwidth.c
++ $(topdir)/mbutil.c
+
+ # The header files for this library.
+ HSOURCES = readline.h rldefs.h chardefs.h keymaps.h history.h histlib.h \
+@@ -149,8 +147,8 @@ SHARED_TILDEOBJ = tilde.so
+ SHARED_OBJ = readline.so vi_mode.so funmap.so keymaps.so parens.so search.so \
+ rltty.so complete.so bind.so isearch.so display.so signals.so \
+ util.so kill.so undo.so macro.so input.so callback.so terminal.so \
+- text.so nls.so misc.so xmalloc.so $(SHARED_HISTOBJ) $(SHARED_TILDEOBJ) \
+- compat.so $(WCWIDTH_OBJ)
++ text.so nls.so misc.so xmalloc.so xfree.so $(SHARED_HISTOBJ) $(SHARED_TILDEOBJ) \
++ compat.so
+
+ ##########################################################################
+
+@@ -170,13 +168,9 @@ $(SHARED_READLINE): $(SHARED_OBJ)
+ $(RM) $@
+ $(SHOBJ_LD) ${SHOBJ_LDFLAGS} ${SHLIB_XLDFLAGS} -o $@ $(SHARED_OBJ) $(SHLIB_LIBS)
+
+-$(SHARED_HISTORY): $(SHARED_HISTOBJ) xmalloc.so
+- $(RM) $@
+- $(SHOBJ_LD) ${SHOBJ_LDFLAGS} ${SHLIB_XLDFLAGS} -o $@ $(SHARED_HISTOBJ) xmalloc.so $(SHLIB_LIBS)
+-
+-wcwidth.o: $(srcdir)/support/wcwidth.c
++$(SHARED_HISTORY): $(SHARED_HISTOBJ) xmalloc.so xfree.so
+ $(RM) $@
+- $(SHOBJ_CC) -c $(CCFLAGS) $(SHOBJ_FLAGS) $(srcdir)/support/wcwidth.c
++ $(SHOBJ_LD) ${SHOBJ_LDFLAGS} ${SHLIB_XLDFLAGS} -o $@ $(SHARED_HISTOBJ) xmalloc.so xfree.so $(SHLIB_LIBS)
+
+ # Since tilde.c is shared between readline and bash, make sure we compile
+ # it with the right flags when it's built as part of readline
+@@ -187,15 +181,16 @@ tilde.so: tilde.c
+
+ installdirs: $(topdir)/support/mkdirs
+ -$(SHELL) $(topdir)/support/mkdirs $(DESTDIR)$(libdir)
++ -$(SHELL) $(topdir)/support/mkdirs $(DESTDIR)$(bindir)
+
+ install: installdirs $(SHLIB_STATUS)
+- $(SHELL) $(topdir)/support/shlib-install -O $(host_os) -d $(DESTDIR)$(libdir) -b $(DESTDIR)$(bindir) -i "$(INSTALL_DATA)" $(SHARED_HISTORY)
+- $(SHELL) $(topdir)/support/shlib-install -O $(host_os) -d $(DESTDIR)$(libdir) -b $(DESTDIR)$(bindir) -i "$(INSTALL_DATA)" $(SHARED_READLINE)
++ $(SHELL) $(topdir)/support/shlib-install -O $(host_os) -V $(host_vendor) -d $(DESTDIR)$(libdir) -b $(DESTDIR)$(bindir) -i "$(INSTALL_DATA)" $(SHARED_HISTORY)
++ $(SHELL) $(topdir)/support/shlib-install -O $(host_os) -V $(host_vendor) -d $(DESTDIR)$(libdir) -b $(DESTDIR)$(bindir) -i "$(INSTALL_DATA)" $(SHARED_READLINE)
+ @echo install: you may need to run ldconfig
+
+ uninstall:
+- $(SHELL) $(topdir)/support/shlib-install -O $(host_os) -d $(DESTDIR)$(libdir) -b $(DESTDIR)$(bindir) -U $(SHARED_HISTORY)
+- $(SHELL) $(topdir)/support/shlib-install -O $(host_os) -d $(DESTDIR)$(libdir) -b $(DESTDIR)$(bindir) -U $(SHARED_READLINE)
++ $(SHELL) $(topdir)/support/shlib-install -O $(host_os) -V $(host_vendor) -d $(DESTDIR)$(libdir) -b $(DESTDIR)$(bindir) -U $(SHARED_HISTORY)
++ $(SHELL) $(topdir)/support/shlib-install -O $(host_os) -V $(host_vendor) -d $(DESTDIR)$(libdir) -b $(DESTDIR)$(bindir) -U $(SHARED_READLINE)
+ @echo uninstall: you may need to run ldconfig
+
+ clean mostlyclean: force
+@@ -322,6 +317,8 @@ vi_mode.so: $(topdir)/rldefs.h ${BUILD_D
+ vi_mode.so: $(topdir)/readline.h $(topdir)/keymaps.h $(topdir)/chardefs.h
+ vi_mode.so: $(topdir)/history.h $(topdir)/ansi_stdlib.h $(topdir)/tilde.h
+ vi_mode.so: $(topdir)/rltypedefs.h
++xfree.so: ${BUILD_DIR}/config.h
++xfree.so: $(topdir)/ansi_stdlib.h
+ xmalloc.so: ${BUILD_DIR}/config.h
+ xmalloc.so: $(topdir)/ansi_stdlib.h
+
+@@ -379,6 +376,7 @@ tilde.so: $(topdir)/xmalloc.h
+ undo.so: $(topdir)/xmalloc.h
+ util.so: $(topdir)/xmalloc.h
+ vi_mode.so: $(topdir)/xmalloc.h
++xfree.so: $(topdir)/xmalloc.h
+ xmalloc.so: $(topdir)/xmalloc.h
+
+ complete.o: $(topdir)/rlmbutil.h
+@@ -420,6 +418,7 @@ tilde.so: $(topdir)/tilde.c
+ undo.so: $(topdir)/undo.c
+ util.so: $(topdir)/util.c
+ vi_mode.so: $(topdir)/vi_mode.c
++xfree.so: $(topdir)/xfree.c
+ xmalloc.so: $(topdir)/xmalloc.c
+
+ histexpand.so: $(topdir)/histexpand.c
+@@ -454,6 +453,7 @@ tilde.so: tilde.c
+ undo.so: undo.c
+ util.so: util.c
+ vi_mode.so: vi_mode.c
++xfree.so: xfree.c
+ xmalloc.so: xmalloc.c
+
+ histexpand.so: histexpand.c
+Index: gdb-7.2.90.20110703/readline/signals.c
+===================================================================
+--- gdb-7.2.90.20110703.orig/readline/signals.c 2011-07-03 10:40:53.000000000 +0200
++++ gdb-7.2.90.20110703/readline/signals.c 2011-07-03 10:41:21.000000000 +0200
+@@ -1,24 +1,24 @@
+ /* signals.c -- signal handling support for readline. */
+
+-/* Copyright (C) 1987-2005 Free Software Foundation, Inc.
++/* Copyright (C) 1987-2009 Free Software Foundation, Inc.
+
+- This file is part of the GNU Readline Library, a library for
+- reading lines of text with interactive input and history editing.
++ This file is part of the GNU Readline Library (Readline), a library
++ for reading lines of text with interactive input and history editing.
+
+- The GNU Readline Library is free software; you can redistribute it
+- and/or modify it under the terms of the GNU General Public License
+- as published by the Free Software Foundation; either version 2, or
++ Readline 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.
+
+- The GNU Readline Library is distributed in the hope that it will be
+- useful, but WITHOUT ANY WARRANTY; without even the implied warranty
+- of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ Readline 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.
+
+- The GNU General Public License is often shipped with GNU software, and
+- is generally kept in a file called COPYING or LICENSE. If you do not
+- have a copy of the license, write to the Free Software Foundation,
+- 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
++ You should have received a copy of the GNU General Public License
++ along with Readline. If not, see <http://www.gnu.org/licenses/>.
++*/
++
+ #define READLINE_LIBRARY
+
+ #if defined (HAVE_CONFIG_H)
+@@ -40,13 +40,14 @@
+ # include <sys/ioctl.h>
+ #endif /* GWINSZ_IN_SYS_IOCTL */
+
+-#if defined (HANDLE_SIGNALS)
+ /* Some standard library routines. */
+ #include "readline.h"
+ #include "history.h"
+
+ #include "rlprivate.h"
+
++#if defined (HANDLE_SIGNALS)
++
+ #if !defined (RETSIGTYPE)
+ # if defined (VOID_SIGHANDLER)
+ # define RETSIGTYPE void
+@@ -80,6 +81,9 @@ typedef struct { SigHandler *sa_handler;
+ static SigHandler *rl_set_sighandler PARAMS((int, SigHandler *, sighandler_cxt *));
+ static void rl_maybe_set_sighandler PARAMS((int, SigHandler *, sighandler_cxt *));
+
++static RETSIGTYPE rl_signal_handler PARAMS((int));
++static RETSIGTYPE _rl_handle_signal PARAMS((int));
++
+ /* Exported variables for use by applications. */
+
+ /* If non-zero, readline will install its own signal handlers for
+@@ -93,6 +97,18 @@ int rl_catch_sigwinch = 1;
+ int rl_catch_sigwinch = 0; /* for the readline state struct in readline.c */
+ #endif
+
++/* Private variables. */
++int _rl_interrupt_immediately = 0;
++int volatile _rl_caught_signal = 0; /* should be sig_atomic_t, but that requires including <signal.h> everywhere */
++
++/* If non-zero, print characters corresponding to received signals as long as
++ the user has indicated his desire to do so (_rl_echo_control_chars). */
++int _rl_echoctl = 0;
++
++int _rl_intr_char = 0;
++int _rl_quit_char = 0;
++int _rl_susp_char = 0;
++
+ static int signals_set_flag;
+ static int sigwinch_set_flag;
+
+@@ -112,10 +128,36 @@ static sighandler_cxt old_winch;
+
+ /* Readline signal handler functions. */
+
++/* Called from RL_CHECK_SIGNALS() macro */
++RETSIGTYPE
++_rl_signal_handler (sig)
++ int sig;
++{
++ _rl_caught_signal = 0; /* XXX */
++
++ _rl_handle_signal (sig);
++ SIGHANDLER_RETURN;
++}
++
+ static RETSIGTYPE
+ rl_signal_handler (sig)
+ int sig;
+ {
++ if (_rl_interrupt_immediately || RL_ISSTATE(RL_STATE_CALLBACK))
++ {
++ _rl_interrupt_immediately = 0;
++ _rl_handle_signal (sig);
++ }
++ else
++ _rl_caught_signal = sig;
++
++ SIGHANDLER_RETURN;
++}
++
++static RETSIGTYPE
++_rl_handle_signal (sig)
++ int sig;
++{
+ #if defined (HAVE_POSIX_SIGNALS)
+ sigset_t set;
+ #else /* !HAVE_POSIX_SIGNALS */
+@@ -142,6 +184,7 @@ rl_signal_handler (sig)
+ switch (sig)
+ {
+ case SIGINT:
++ _rl_reset_completion_state ();
+ rl_free_line_state ();
+ /* FALLTHROUGH */
+
+@@ -157,9 +200,11 @@ rl_signal_handler (sig)
+ #if defined (SIGQUIT)
+ case SIGQUIT:
+ #endif
++ rl_echo_signal_char (sig);
+ rl_cleanup_after_signal ();
+
+ #if defined (HAVE_POSIX_SIGNALS)
++ sigemptyset (&set);
+ sigprocmask (SIG_BLOCK, (sigset_t *)NULL, &set);
+ sigdelset (&set, sig);
+ #else /* !HAVE_POSIX_SIGNALS */
+@@ -251,11 +296,11 @@ rl_set_sighandler (sig, handler, ohandle
+ struct sigaction act;
+
+ act.sa_handler = handler;
+-#if defined (SIGWINCH)
++# if defined (SIGWINCH)
+ act.sa_flags = (sig == SIGWINCH) ? SA_RESTART : 0;
+-#else
++# else
+ act.sa_flags = 0;
+-#endif
++# endif /* SIGWINCH */
+ sigemptyset (&act.sa_mask);
+ sigemptyset (&ohandler->sa_mask);
+ sigaction (sig, &act, &old_handler);
+@@ -292,9 +337,44 @@ rl_set_signals ()
+ {
+ sighandler_cxt dummy;
+ SigHandler *oh;
++#if defined (HAVE_POSIX_SIGNALS)
++ static int sigmask_set = 0;
++ static sigset_t bset, oset;
++#endif
++
++#if defined (HAVE_POSIX_SIGNALS)
++ if (rl_catch_signals && sigmask_set == 0)
++ {
++ sigemptyset (&bset);
++
++ sigaddset (&bset, SIGINT);
++ sigaddset (&bset, SIGTERM);
++#if defined (SIGQUIT)
++ sigaddset (&bset, SIGQUIT);
++#endif
++#if defined (SIGALRM)
++ sigaddset (&bset, SIGALRM);
++#endif
++#if defined (SIGTSTP)
++ sigaddset (&bset, SIGTSTP);
++#endif
++#if defined (SIGTTIN)
++ sigaddset (&bset, SIGTTIN);
++#endif
++#if defined (SIGTTOU)
++ sigaddset (&bset, SIGTTOU);
++#endif
++ sigmask_set = 1;
++ }
++#endif /* HAVE_POSIX_SIGNALS */
+
+ if (rl_catch_signals && signals_set_flag == 0)
+ {
++#if defined (HAVE_POSIX_SIGNALS)
++ sigemptyset (&oset);
++ sigprocmask (SIG_BLOCK, &bset, &oset);
++#endif
++
+ rl_maybe_set_sighandler (SIGINT, rl_signal_handler, &old_int);
+ rl_maybe_set_sighandler (SIGTERM, rl_signal_handler, &old_term);
+ #if defined (SIGQUIT)
+@@ -328,6 +408,10 @@ rl_set_signals ()
+ #endif /* SIGTTIN */
+
+ signals_set_flag = 1;
++
++#if defined (HAVE_POSIX_SIGNALS)
++ sigprocmask (SIG_SETMASK, &oset, (sigset_t *)NULL);
++#endif
+ }
+
+ #if defined (SIGWINCH)
+@@ -394,8 +478,8 @@ rl_cleanup_after_signal ()
+ _rl_clean_up_for_exit ();
+ if (rl_deprep_term_function)
+ (*rl_deprep_term_function) ();
+- rl_clear_signals ();
+ rl_clear_pending_input ();
++ rl_clear_signals ();
+ }
+
+ /* Reset the terminal and readline state after a signal handler returns. */
+@@ -428,3 +512,160 @@ rl_free_line_state ()
+ }
+
+ #endif /* HANDLE_SIGNALS */
++
++/* **************************************************************** */
++/* */
++/* SIGINT Management */
++/* */
++/* **************************************************************** */
++
++#if defined (HAVE_POSIX_SIGNALS)
++static sigset_t sigint_set, sigint_oset;
++static sigset_t sigwinch_set, sigwinch_oset;
++#else /* !HAVE_POSIX_SIGNALS */
++# if defined (HAVE_BSD_SIGNALS)
++static int sigint_oldmask;
++static int sigwinch_oldmask;
++# endif /* HAVE_BSD_SIGNALS */
++#endif /* !HAVE_POSIX_SIGNALS */
++
++static int sigint_blocked;
++static int sigwinch_blocked;
++
++/* Cause SIGINT to not be delivered until the corresponding call to
++ release_sigint(). */
++void
++_rl_block_sigint ()
++{
++ if (sigint_blocked)
++ return;
++
++#if defined (HAVE_POSIX_SIGNALS)
++ sigemptyset (&sigint_set);
++ sigemptyset (&sigint_oset);
++ sigaddset (&sigint_set, SIGINT);
++ sigprocmask (SIG_BLOCK, &sigint_set, &sigint_oset);
++#else /* !HAVE_POSIX_SIGNALS */
++# if defined (HAVE_BSD_SIGNALS)
++ sigint_oldmask = sigblock (sigmask (SIGINT));
++# else /* !HAVE_BSD_SIGNALS */
++# if defined (HAVE_USG_SIGHOLD)
++ sighold (SIGINT);
++# endif /* HAVE_USG_SIGHOLD */
++# endif /* !HAVE_BSD_SIGNALS */
++#endif /* !HAVE_POSIX_SIGNALS */
++
++ sigint_blocked = 1;
++}
++
++/* Allow SIGINT to be delivered. */
++void
++_rl_release_sigint ()
++{
++ if (sigint_blocked == 0)
++ return;
++
++#if defined (HAVE_POSIX_SIGNALS)
++ sigprocmask (SIG_SETMASK, &sigint_oset, (sigset_t *)NULL);
++#else
++# if defined (HAVE_BSD_SIGNALS)
++ sigsetmask (sigint_oldmask);
++# else /* !HAVE_BSD_SIGNALS */
++# if defined (HAVE_USG_SIGHOLD)
++ sigrelse (SIGINT);
++# endif /* HAVE_USG_SIGHOLD */
++# endif /* !HAVE_BSD_SIGNALS */
++#endif /* !HAVE_POSIX_SIGNALS */
++
++ sigint_blocked = 0;
++}
++
++/* Cause SIGWINCH to not be delivered until the corresponding call to
++ release_sigwinch(). */
++void
++_rl_block_sigwinch ()
++{
++ if (sigwinch_blocked)
++ return;
++
++#if defined (HAVE_POSIX_SIGNALS)
++ sigemptyset (&sigwinch_set);
++ sigemptyset (&sigwinch_oset);
++ sigaddset (&sigwinch_set, SIGWINCH);
++ sigprocmask (SIG_BLOCK, &sigwinch_set, &sigwinch_oset);
++#else /* !HAVE_POSIX_SIGNALS */
++# if defined (HAVE_BSD_SIGNALS)
++ sigwinch_oldmask = sigblock (sigmask (SIGWINCH));
++# else /* !HAVE_BSD_SIGNALS */
++# if defined (HAVE_USG_SIGHOLD)
++ sighold (SIGWINCH);
++# endif /* HAVE_USG_SIGHOLD */
++# endif /* !HAVE_BSD_SIGNALS */
++#endif /* !HAVE_POSIX_SIGNALS */
++
++ sigwinch_blocked = 1;
++}
++
++/* Allow SIGWINCH to be delivered. */
++void
++_rl_release_sigwinch ()
++{
++ if (sigwinch_blocked == 0)
++ return;
++
++#if defined (HAVE_POSIX_SIGNALS)
++ sigprocmask (SIG_SETMASK, &sigwinch_oset, (sigset_t *)NULL);
++#else
++# if defined (HAVE_BSD_SIGNALS)
++ sigsetmask (sigwinch_oldmask);
++# else /* !HAVE_BSD_SIGNALS */
++# if defined (HAVE_USG_SIGHOLD)
++ sigrelse (SIGWINCH);
++# endif /* HAVE_USG_SIGHOLD */
++# endif /* !HAVE_BSD_SIGNALS */
++#endif /* !HAVE_POSIX_SIGNALS */
++
++ sigwinch_blocked = 0;
++}
++
++/* **************************************************************** */
++/* */
++/* Echoing special control characters */
++/* */
++/* **************************************************************** */
++void
++rl_echo_signal_char (sig)
++ int sig;
++{
++ char cstr[3];
++ int cslen, c;
++
++ if (_rl_echoctl == 0 || _rl_echo_control_chars == 0)
++ return;
++
++ switch (sig)
++ {
++ case SIGINT: c = _rl_intr_char; break;
++#if defined (SIGQUIT)
++ case SIGQUIT: c = _rl_quit_char; break;
++#endif
++#if defined (SIGTSTP)
++ case SIGTSTP: c = _rl_susp_char; break;
++#endif
++ default: return;
++ }
++
++ if (CTRL_CHAR (c) || c == RUBOUT)
++ {
++ cstr[0] = '^';
++ cstr[1] = CTRL_CHAR (c) ? UNCTRL (c) : '?';
++ cstr[cslen = 2] = '\0';
++ }
++ else
++ {
++ cstr[0] = c;
++ cstr[cslen = 1] = '\0';
++ }
++
++ _rl_output_some_chars (cstr, cslen);
++}
+Index: gdb-7.2.90.20110703/readline/support/config.guess
+===================================================================
+--- gdb-7.2.90.20110703.orig/readline/support/config.guess 2011-07-03 10:40:53.000000000 +0200
++++ gdb-7.2.90.20110703/readline/support/config.guess 2011-07-03 10:41:21.000000000 +0200
+@@ -1,9 +1,10 @@
+ #! /bin/sh
+ # Attempt to guess a canonical system name.
+ # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
+-# 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
++# 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
++# Free Software Foundation, Inc.
+
+-timestamp='2004-02-16'
++timestamp='2008-03-12'
+
+ # This file is free software; you can redistribute it and/or modify it
+ # under the terms of the GNU General Public License as published by
+@@ -17,13 +18,15 @@ timestamp='2004-02-16'
+ #
+ # You should have received a copy of the GNU General Public License
+ # along with this program; if not, write to the Free Software
+-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
++# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA
++# 02110-1301, USA.
+ #
+ # As a special exception to the GNU General Public License, if you
+ # distribute this file as part of a program that contains a
+ # configuration script generated by Autoconf, you may include it under
+ # the same distribution terms that you use for the rest of that program.
+
++
+ # Originally written by Per Bothner <per@bothner.com>.
+ # Please send patches to <config-patches@gnu.org>. Submit a context
+ # diff and a properly formatted ChangeLog entry.
+@@ -53,8 +56,8 @@ version="\
+ GNU config.guess ($timestamp)
+
+ Originally written by Per Bothner.
+-Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001
+-Free Software Foundation, Inc.
++Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001,
++2002, 2003, 2004, 2005, 2006, 2007, 2008,2009 Free Software Foundation, Inc.
+
+ This is free software; see the source for copying conditions. There is NO
+ warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
+@@ -66,11 +69,11 @@ Try \`$me --help' for more information."
+ while test $# -gt 0 ; do
+ case $1 in
+ --time-stamp | --time* | -t )
+- echo "$timestamp" ; exit 0 ;;
++ echo "$timestamp" ; exit ;;
+ --version | -v )
+- echo "$version" ; exit 0 ;;
++ echo "$version" ; exit ;;
+ --help | --h* | -h )
+- echo "$usage"; exit 0 ;;
++ echo "$usage"; exit ;;
+ -- ) # Stop option processing
+ shift; break ;;
+ - ) # Use stdin as input.
+@@ -104,7 +107,7 @@ set_cc_for_build='
+ trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ;
+ trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ;
+ : ${TMPDIR=/tmp} ;
+- { tmp=`(umask 077 && mktemp -d -q "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } ||
++ { tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } ||
+ { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } ||
+ { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir $tmp) && echo "Warning: creating insecure temp directory" >&2 ; } ||
+ { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ;
+@@ -123,7 +126,7 @@ case $CC_FOR_BUILD,$HOST_CC,$CC in
+ ;;
+ ,,*) CC_FOR_BUILD=$CC ;;
+ ,*,*) CC_FOR_BUILD=$HOST_CC ;;
+-esac ;'
++esac ; set_cc_for_build= ;'
+
+ # This is needed to find uname on a Pyramid OSx when run in the BSD universe.
+ # (ghazi@noc.rutgers.edu 1994-08-24)
+@@ -158,6 +161,7 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:$
+ arm*) machine=arm-unknown ;;
+ sh3el) machine=shl-unknown ;;
+ sh3eb) machine=sh-unknown ;;
++ sh5el) machine=sh5le-unknown ;;
+ *) machine=${UNAME_MACHINE_ARCH}-unknown ;;
+ esac
+ # The Operating System including object format, if it has switched
+@@ -196,68 +200,32 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:$
+ # contains redundant information, the shorter form:
+ # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used.
+ echo "${machine}-${os}${release}"
+- exit 0 ;;
+- amd64:OpenBSD:*:*)
+- echo x86_64-unknown-openbsd${UNAME_RELEASE}
+- exit 0 ;;
+- amiga:OpenBSD:*:*)
+- echo m68k-unknown-openbsd${UNAME_RELEASE}
+- exit 0 ;;
+- arc:OpenBSD:*:*)
+- echo mipsel-unknown-openbsd${UNAME_RELEASE}
+- exit 0 ;;
+- cats:OpenBSD:*:*)
+- echo arm-unknown-openbsd${UNAME_RELEASE}
+- exit 0 ;;
+- hp300:OpenBSD:*:*)
+- echo m68k-unknown-openbsd${UNAME_RELEASE}
+- exit 0 ;;
+- mac68k:OpenBSD:*:*)
+- echo m68k-unknown-openbsd${UNAME_RELEASE}
+- exit 0 ;;
+- macppc:OpenBSD:*:*)
+- echo powerpc-unknown-openbsd${UNAME_RELEASE}
+- exit 0 ;;
+- mvme68k:OpenBSD:*:*)
+- echo m68k-unknown-openbsd${UNAME_RELEASE}
+- exit 0 ;;
+- mvme88k:OpenBSD:*:*)
+- echo m88k-unknown-openbsd${UNAME_RELEASE}
+- exit 0 ;;
+- mvmeppc:OpenBSD:*:*)
+- echo powerpc-unknown-openbsd${UNAME_RELEASE}
+- exit 0 ;;
+- pegasos:OpenBSD:*:*)
+- echo powerpc-unknown-openbsd${UNAME_RELEASE}
+- exit 0 ;;
+- pmax:OpenBSD:*:*)
+- echo mipsel-unknown-openbsd${UNAME_RELEASE}
+- exit 0 ;;
+- sgi:OpenBSD:*:*)
+- echo mipseb-unknown-openbsd${UNAME_RELEASE}
+- exit 0 ;;
+- sun3:OpenBSD:*:*)
+- echo m68k-unknown-openbsd${UNAME_RELEASE}
+- exit 0 ;;
+- wgrisc:OpenBSD:*:*)
+- echo mipsel-unknown-openbsd${UNAME_RELEASE}
+- exit 0 ;;
++ exit ;;
+ *:OpenBSD:*:*)
+- echo ${UNAME_MACHINE}-unknown-openbsd${UNAME_RELEASE}
+- exit 0 ;;
++ UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'`
++ echo ${UNAME_MACHINE_ARCH}-unknown-openbsd${UNAME_RELEASE}
++ exit ;;
+ *:ekkoBSD:*:*)
+ echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE}
+- exit 0 ;;
++ exit ;;
++ *:SolidBSD:*:*)
++ echo ${UNAME_MACHINE}-unknown-solidbsd${UNAME_RELEASE}
++ exit ;;
+ macppc:MirBSD:*:*)
+- echo powerppc-unknown-mirbsd${UNAME_RELEASE}
+- exit 0 ;;
++ echo powerpc-unknown-mirbsd${UNAME_RELEASE}
++ exit ;;
+ *:MirBSD:*:*)
+ echo ${UNAME_MACHINE}-unknown-mirbsd${UNAME_RELEASE}
+- exit 0 ;;
++ exit ;;
+ alpha:OSF1:*:*)
+- if test $UNAME_RELEASE = "V4.0"; then
++ case $UNAME_RELEASE in
++ *4.0)
+ UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'`
+- fi
++ ;;
++ *5.*)
++ UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'`
++ ;;
++ esac
+ # According to Compaq, /usr/sbin/psrinfo has been available on
+ # OSF/1 and Tru64 systems produced since 1995. I hope that
+ # covers most systems running today. This code pipes the CPU
+@@ -295,45 +263,49 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:$
+ "EV7.9 (21364A)")
+ UNAME_MACHINE="alphaev79" ;;
+ esac
++ # A Pn.n version is a patched version.
+ # A Vn.n version is a released version.
+ # A Tn.n version is a released field test version.
+ # A Xn.n version is an unreleased experimental baselevel.
+ # 1.2 uses "1.2" for uname -r.
+- echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[VTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
+- exit 0 ;;
+- Alpha*:OpenVMS:*:*)
+- echo alpha-hp-vms
+- exit 0 ;;
++ echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
++ exit ;;
+ Alpha\ *:Windows_NT*:*)
+ # How do we know it's Interix rather than the generic POSIX subsystem?
+ # Should we change UNAME_MACHINE based on the output of uname instead
+ # of the specific Alpha model?
+ echo alpha-pc-interix
+- exit 0 ;;
++ exit ;;
+ 21064:Windows_NT:50:3)
+ echo alpha-dec-winnt3.5
+- exit 0 ;;
++ exit ;;
+ Amiga*:UNIX_System_V:4.0:*)
+ echo m68k-unknown-sysv4
+- exit 0;;
++ exit ;;
+ *:[Aa]miga[Oo][Ss]:*:*)
+ echo ${UNAME_MACHINE}-unknown-amigaos
+- exit 0 ;;
++ exit ;;
+ *:[Mm]orph[Oo][Ss]:*:*)
+ echo ${UNAME_MACHINE}-unknown-morphos
+- exit 0 ;;
++ exit ;;
+ *:OS/390:*:*)
+ echo i370-ibm-openedition
+- exit 0 ;;
++ exit ;;
++ *:z/VM:*:*)
++ echo s390-ibm-zvmoe
++ exit ;;
+ *:OS400:*:*)
+ echo powerpc-ibm-os400
+- exit 0 ;;
++ exit ;;
+ arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*)
+ echo arm-acorn-riscix${UNAME_RELEASE}
+- exit 0;;
++ exit ;;
++ arm:riscos:*:*|arm:RISCOS:*:*)
++ echo arm-unknown-riscos
++ exit ;;
+ SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*)
+ echo hppa1.1-hitachi-hiuxmpp
+- exit 0;;
++ exit ;;
+ Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*)
+ # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE.
+ if test "`(/bin/universe) 2>/dev/null`" = att ; then
+@@ -341,32 +313,32 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:$
+ else
+ echo pyramid-pyramid-bsd
+ fi
+- exit 0 ;;
++ exit ;;
+ NILE*:*:*:dcosx)
+ echo pyramid-pyramid-svr4
+- exit 0 ;;
++ exit ;;
+ DRS?6000:unix:4.0:6*)
+ echo sparc-icl-nx6
+- exit 0 ;;
+- DRS?6000:UNIX_SV:4.2*:7*)
++ exit ;;
++ DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*)
+ case `/usr/bin/uname -p` in
+- sparc) echo sparc-icl-nx7 && exit 0 ;;
++ sparc) echo sparc-icl-nx7; exit ;;
+ esac ;;
+ sun4H:SunOS:5.*:*)
+ echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+- exit 0 ;;
++ exit ;;
+ sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*)
+ echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+- exit 0 ;;
+- i86pc:SunOS:5.*:*)
++ exit ;;
++ i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*)
+ echo i386-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+- exit 0 ;;
++ exit ;;
+ sun4*:SunOS:6*:*)
+ # According to config.sub, this is the proper way to canonicalize
+ # SunOS6. Hard to guess exactly what SunOS6 will be like, but
+ # it's likely to be more like Solaris than SunOS4.
+ echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+- exit 0 ;;
++ exit ;;
+ sun4*:SunOS:*:*)
+ case "`/usr/bin/arch -k`" in
+ Series*|S4*)
+@@ -375,10 +347,10 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:$
+ esac
+ # Japanese Language versions have a version number like `4.1.3-JL'.
+ echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'`
+- exit 0 ;;
++ exit ;;
+ sun3*:SunOS:*:*)
+ echo m68k-sun-sunos${UNAME_RELEASE}
+- exit 0 ;;
++ exit ;;
+ sun*:*:4.2BSD:*)
+ UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null`
+ test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3
+@@ -390,10 +362,10 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:$
+ echo sparc-sun-sunos${UNAME_RELEASE}
+ ;;
+ esac
+- exit 0 ;;
++ exit ;;
+ aushp:SunOS:*:*)
+ echo sparc-auspex-sunos${UNAME_RELEASE}
+- exit 0 ;;
++ exit ;;
+ # The situation for MiNT is a little confusing. The machine name
+ # can be virtually everything (everything which is not
+ # "atarist" or "atariste" at least should have a processor
+@@ -404,40 +376,40 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:$
+ # be no problem.
+ atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*)
+ echo m68k-atari-mint${UNAME_RELEASE}
+- exit 0 ;;
++ exit ;;
+ atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*)
+ echo m68k-atari-mint${UNAME_RELEASE}
+- exit 0 ;;
++ exit ;;
+ *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*)
+ echo m68k-atari-mint${UNAME_RELEASE}
+- exit 0 ;;
++ exit ;;
+ milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*)
+ echo m68k-milan-mint${UNAME_RELEASE}
+- exit 0 ;;
++ exit ;;
+ hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*)
+ echo m68k-hades-mint${UNAME_RELEASE}
+- exit 0 ;;
++ exit ;;
+ *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*)
+ echo m68k-unknown-mint${UNAME_RELEASE}
+- exit 0 ;;
++ exit ;;
+ m68k:machten:*:*)
+ echo m68k-apple-machten${UNAME_RELEASE}
+- exit 0 ;;
++ exit ;;
+ powerpc:machten:*:*)
+ echo powerpc-apple-machten${UNAME_RELEASE}
+- exit 0 ;;
++ exit ;;
+ RISC*:Mach:*:*)
+ echo mips-dec-mach_bsd4.3
+- exit 0 ;;
++ exit ;;
+ RISC*:ULTRIX:*:*)
+ echo mips-dec-ultrix${UNAME_RELEASE}
+- exit 0 ;;
++ exit ;;
+ VAX*:ULTRIX*:*:*)
+ echo vax-dec-ultrix${UNAME_RELEASE}
+- exit 0 ;;
++ exit ;;
+ 2020:CLIX:*:* | 2430:CLIX:*:*)
+ echo clipper-intergraph-clix${UNAME_RELEASE}
+- exit 0 ;;
++ exit ;;
+ mips:*:*:UMIPS | mips:*:*:RISCos)
+ eval $set_cc_for_build
+ sed 's/^ //' << EOF >$dummy.c
+@@ -461,32 +433,33 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:$
+ exit (-1);
+ }
+ EOF
+- $CC_FOR_BUILD -o $dummy $dummy.c \
+- && $dummy `echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` \
+- && exit 0
++ $CC_FOR_BUILD -o $dummy $dummy.c &&
++ dummyarg=`echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` &&
++ SYSTEM_NAME=`$dummy $dummyarg` &&
++ { echo "$SYSTEM_NAME"; exit; }
+ echo mips-mips-riscos${UNAME_RELEASE}
+- exit 0 ;;
++ exit ;;
+ Motorola:PowerMAX_OS:*:*)
+ echo powerpc-motorola-powermax
+- exit 0 ;;
++ exit ;;
+ Motorola:*:4.3:PL8-*)
+ echo powerpc-harris-powermax
+- exit 0 ;;
++ exit ;;
+ Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*)
+ echo powerpc-harris-powermax
+- exit 0 ;;
++ exit ;;
+ Night_Hawk:Power_UNIX:*:*)
+ echo powerpc-harris-powerunix
+- exit 0 ;;
++ exit ;;
+ m88k:CX/UX:7*:*)
+ echo m88k-harris-cxux7
+- exit 0 ;;
++ exit ;;
+ m88k:*:4*:R4*)
+ echo m88k-motorola-sysv4
+- exit 0 ;;
++ exit ;;
+ m88k:*:3*:R3*)
+ echo m88k-motorola-sysv3
+- exit 0 ;;
++ exit ;;
+ AViiON:dgux:*:*)
+ # DG/UX returns AViiON for all architectures
+ UNAME_PROCESSOR=`/usr/bin/uname -p`
+@@ -502,29 +475,29 @@ EOF
+ else
+ echo i586-dg-dgux${UNAME_RELEASE}
+ fi
+- exit 0 ;;
++ exit ;;
+ M88*:DolphinOS:*:*) # DolphinOS (SVR3)
+ echo m88k-dolphin-sysv3
+- exit 0 ;;
++ exit ;;
+ M88*:*:R3*:*)
+ # Delta 88k system running SVR3
+ echo m88k-motorola-sysv3
+- exit 0 ;;
++ exit ;;
+ XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3)
+ echo m88k-tektronix-sysv3
+- exit 0 ;;
++ exit ;;
+ Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD)
+ echo m68k-tektronix-bsd
+- exit 0 ;;
++ exit ;;
+ *:IRIX*:*:*)
+ echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'`
+- exit 0 ;;
++ exit ;;
+ ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX.
+- echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id
+- exit 0 ;; # Note that: echo "'`uname -s`'" gives 'AIX '
++ echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id
++ exit ;; # Note that: echo "'`uname -s`'" gives 'AIX '
+ i*86:AIX:*:*)
+ echo i386-ibm-aix
+- exit 0 ;;
++ exit ;;
+ ia64:AIX:*:*)
+ if [ -x /usr/bin/oslevel ] ; then
+ IBM_REV=`/usr/bin/oslevel`
+@@ -532,7 +505,7 @@ EOF
+ IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE}
+ fi
+ echo ${UNAME_MACHINE}-ibm-aix${IBM_REV}
+- exit 0 ;;
++ exit ;;
+ *:AIX:2:3)
+ if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then
+ eval $set_cc_for_build
+@@ -547,15 +520,19 @@ EOF
+ exit(0);
+ }
+ EOF
+- $CC_FOR_BUILD -o $dummy $dummy.c && $dummy && exit 0
+- echo rs6000-ibm-aix3.2.5
++ if $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy`
++ then
++ echo "$SYSTEM_NAME"
++ else
++ echo rs6000-ibm-aix3.2.5
++ fi
+ elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then
+ echo rs6000-ibm-aix3.2.4
+ else
+ echo rs6000-ibm-aix3.2
+ fi
+- exit 0 ;;
+- *:AIX:*:[45])
++ exit ;;
++ *:AIX:*:[456])
+ IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'`
+ if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then
+ IBM_ARCH=rs6000
+@@ -568,28 +545,28 @@ EOF
+ IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE}
+ fi
+ echo ${IBM_ARCH}-ibm-aix${IBM_REV}
+- exit 0 ;;
++ exit ;;
+ *:AIX:*:*)
+ echo rs6000-ibm-aix
+- exit 0 ;;
++ exit ;;
+ ibmrt:4.4BSD:*|romp-ibm:BSD:*)
+ echo romp-ibm-bsd4.4
+- exit 0 ;;
++ exit ;;
+ ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and
+ echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to
+- exit 0 ;; # report: romp-ibm BSD 4.3
++ exit ;; # report: romp-ibm BSD 4.3
+ *:BOSX:*:*)
+ echo rs6000-bull-bosx
+- exit 0 ;;
++ exit ;;
+ DPX/2?00:B.O.S.:*:*)
+ echo m68k-bull-sysv3
+- exit 0 ;;
++ exit ;;
+ 9000/[34]??:4.3bsd:1.*:*)
+ echo m68k-hp-bsd
+- exit 0 ;;
++ exit ;;
+ hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*)
+ echo m68k-hp-bsd4.4
+- exit 0 ;;
++ exit ;;
+ 9000/[34678]??:HP-UX:*:*)
+ HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'`
+ case "${UNAME_MACHINE}" in
+@@ -651,9 +628,19 @@ EOF
+ esac
+ if [ ${HP_ARCH} = "hppa2.0w" ]
+ then
+- # avoid double evaluation of $set_cc_for_build
+- test -n "$CC_FOR_BUILD" || eval $set_cc_for_build
+- if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E -) | grep __LP64__ >/dev/null
++ eval $set_cc_for_build
++
++ # hppa2.0w-hp-hpux* has a 64-bit kernel and a compiler generating
++ # 32-bit code. hppa64-hp-hpux* has the same kernel and a compiler
++ # generating 64-bit code. GNU and HP use different nomenclature:
++ #
++ # $ CC_FOR_BUILD=cc ./config.guess
++ # => hppa2.0w-hp-hpux11.23
++ # $ CC_FOR_BUILD="cc +DA2.0w" ./config.guess
++ # => hppa64-hp-hpux11.23
++
++ if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) |
++ grep __LP64__ >/dev/null
+ then
+ HP_ARCH="hppa2.0w"
+ else
+@@ -661,11 +648,11 @@ EOF
+ fi
+ fi
+ echo ${HP_ARCH}-hp-hpux${HPUX_REV}
+- exit 0 ;;
++ exit ;;
+ ia64:HP-UX:*:*)
+ HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'`
+ echo ia64-hp-hpux${HPUX_REV}
+- exit 0 ;;
++ exit ;;
+ 3050*:HI-UX:*:*)
+ eval $set_cc_for_build
+ sed 's/^ //' << EOF >$dummy.c
+@@ -693,163 +680,192 @@ EOF
+ exit (0);
+ }
+ EOF
+- $CC_FOR_BUILD -o $dummy $dummy.c && $dummy && exit 0
++ $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` &&
++ { echo "$SYSTEM_NAME"; exit; }
+ echo unknown-hitachi-hiuxwe2
+- exit 0 ;;
++ exit ;;
+ 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* )
+ echo hppa1.1-hp-bsd
+- exit 0 ;;
++ exit ;;
+ 9000/8??:4.3bsd:*:*)
+ echo hppa1.0-hp-bsd
+- exit 0 ;;
++ exit ;;
+ *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*)
+ echo hppa1.0-hp-mpeix
+- exit 0 ;;
++ exit ;;
+ hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* )
+ echo hppa1.1-hp-osf
+- exit 0 ;;
++ exit ;;
+ hp8??:OSF1:*:*)
+ echo hppa1.0-hp-osf
+- exit 0 ;;
++ exit ;;
+ i*86:OSF1:*:*)
+ if [ -x /usr/sbin/sysversion ] ; then
+ echo ${UNAME_MACHINE}-unknown-osf1mk
+ else
+ echo ${UNAME_MACHINE}-unknown-osf1
+ fi
+- exit 0 ;;
++ exit ;;
+ parisc*:Lites*:*:*)
+ echo hppa1.1-hp-lites
+- exit 0 ;;
++ exit ;;
+ C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*)
+ echo c1-convex-bsd
+- exit 0 ;;
++ exit ;;
+ C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*)
+ if getsysinfo -f scalar_acc
+ then echo c32-convex-bsd
+ else echo c2-convex-bsd
+ fi
+- exit 0 ;;
++ exit ;;
+ C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*)
+ echo c34-convex-bsd
+- exit 0 ;;
++ exit ;;
+ C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*)
+ echo c38-convex-bsd
+- exit 0 ;;
++ exit ;;
+ C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*)
+ echo c4-convex-bsd
+- exit 0 ;;
++ exit ;;
+ CRAY*Y-MP:*:*:*)
+ echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+- exit 0 ;;
++ exit ;;
+ CRAY*[A-Z]90:*:*:*)
+ echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \
+ | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \
+ -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \
+ -e 's/\.[^.]*$/.X/'
+- exit 0 ;;
++ exit ;;
+ CRAY*TS:*:*:*)
+ echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+- exit 0 ;;
++ exit ;;
+ CRAY*T3E:*:*:*)
+ echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+- exit 0 ;;
++ exit ;;
+ CRAY*SV1:*:*:*)
+ echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+- exit 0 ;;
++ exit ;;
+ *:UNICOS/mp:*:*)
+- echo nv1-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+- exit 0 ;;
++ echo craynv-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
++ exit ;;
+ F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*)
+ FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
+ FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'`
+ FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'`
+ echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
+- exit 0 ;;
++ exit ;;
+ 5000:UNIX_System_V:4.*:*)
+ FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'`
+ FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'`
+ echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
+- exit 0 ;;
++ exit ;;
+ i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*)
+ echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE}
+- exit 0 ;;
++ exit ;;
+ sparc*:BSD/OS:*:*)
+ echo sparc-unknown-bsdi${UNAME_RELEASE}
+- exit 0 ;;
++ exit ;;
+ *:BSD/OS:*:*)
+ echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE}
+- exit 0 ;;
++ exit ;;
+ *:FreeBSD:*:*)
+- # Determine whether the default compiler uses glibc.
+- eval $set_cc_for_build
+- sed 's/^ //' << EOF >$dummy.c
+- #include <features.h>
+- #if __GLIBC__ >= 2
+- LIBC=gnu
+- #else
+- LIBC=
+- #endif
+-EOF
+- eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^LIBC=`
+- # GNU/KFreeBSD systems have a "k" prefix to indicate we are using
+- # FreeBSD's kernel, but not the complete OS.
+- case ${LIBC} in gnu) kernel_only='k' ;; esac
+- echo ${UNAME_MACHINE}-unknown-${kernel_only}freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`${LIBC:+-$LIBC}
+- exit 0 ;;
++ case ${UNAME_MACHINE} in
++ pc98)
++ echo i386-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;;
++ amd64)
++ echo x86_64-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;;
++ *)
++ echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;;
++ esac
++ exit ;;
+ i*:CYGWIN*:*)
+ echo ${UNAME_MACHINE}-pc-cygwin
+- exit 0 ;;
+- i*:MINGW*:*)
++ exit ;;
++ *:MINGW*:*)
+ echo ${UNAME_MACHINE}-pc-mingw32
+- exit 0 ;;
++ exit ;;
++ i*:windows32*:*)
++ # uname -m includes "-pc" on this system.
++ echo ${UNAME_MACHINE}-mingw32
++ exit ;;
+ i*:PW*:*)
+ echo ${UNAME_MACHINE}-pc-pw32
+- exit 0 ;;
+- x86:Interix*:[34]*)
+- echo i586-pc-interix${UNAME_RELEASE}|sed -e 's/\..*//'
+- exit 0 ;;
++ exit ;;
++ *:Interix*:[3456]*)
++ case ${UNAME_MACHINE} in
++ x86)
++ echo i586-pc-interix${UNAME_RELEASE}
++ exit ;;
++ EM64T | authenticamd)
++ echo x86_64-unknown-interix${UNAME_RELEASE}
++ exit ;;
++ IA64)
++ echo ia64-unknown-interix${UNAME_RELEASE}
++ exit ;;
++ esac ;;
+ [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*)
+ echo i${UNAME_MACHINE}-pc-mks
+- exit 0 ;;
++ exit ;;
+ i*:Windows_NT*:* | Pentium*:Windows_NT*:*)
+ # How do we know it's Interix rather than the generic POSIX subsystem?
+ # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we
+ # UNAME_MACHINE based on the output of uname instead of i386?
+ echo i586-pc-interix
+- exit 0 ;;
++ exit ;;
+ i*:UWIN*:*)
+ echo ${UNAME_MACHINE}-pc-uwin
+- exit 0 ;;
++ exit ;;
++ amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*)
++ echo x86_64-unknown-cygwin
++ exit ;;
+ p*:CYGWIN*:*)
+ echo powerpcle-unknown-cygwin
+- exit 0 ;;
++ exit ;;
+ prep*:SunOS:5.*:*)
+ echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+- exit 0 ;;
++ exit ;;
+ *:GNU:*:*)
+ # the GNU system
+ echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'`
+- exit 0 ;;
++ exit ;;
+ *:GNU/*:*:*)
+ # other systems with GNU libc and userland
+ echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-gnu
+- exit 0 ;;
++ exit ;;
+ i*86:Minix:*:*)
+ echo ${UNAME_MACHINE}-pc-minix
+- exit 0 ;;
++ exit ;;
+ arm*:Linux:*:*)
++ eval $set_cc_for_build
++ if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \
++ | grep -q __ARM_EABI__
++ then
++ echo ${UNAME_MACHINE}-unknown-linux-gnu
++ else
++ echo ${UNAME_MACHINE}-unknown-linux-gnueabi
++ fi
++ exit ;;
++ avr32*:Linux:*:*)
+ echo ${UNAME_MACHINE}-unknown-linux-gnu
+- exit 0 ;;
++ exit ;;
+ cris:Linux:*:*)
+ echo cris-axis-linux-gnu
+- exit 0 ;;
++ exit ;;
++ crisv32:Linux:*:*)
++ echo crisv32-axis-linux-gnu
++ exit ;;
++ frv:Linux:*:*)
++ echo frv-unknown-linux-gnu
++ exit ;;
+ ia64:Linux:*:*)
+ echo ${UNAME_MACHINE}-unknown-linux-gnu
+- exit 0 ;;
++ exit ;;
++ m32r*:Linux:*:*)
++ echo ${UNAME_MACHINE}-unknown-linux-gnu
++ exit ;;
+ m68*:Linux:*:*)
+ echo ${UNAME_MACHINE}-unknown-linux-gnu
+- exit 0 ;;
++ exit ;;
+ mips:Linux:*:*)
+ eval $set_cc_for_build
+ sed 's/^ //' << EOF >$dummy.c
+@@ -866,8 +882,12 @@ EOF
+ #endif
+ #endif
+ EOF
+- eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^CPU=`
+- test x"${CPU}" != x && echo "${CPU}-unknown-linux-gnu" && exit 0
++ eval "`$CC_FOR_BUILD -E $dummy.c 2>/dev/null | sed -n '
++ /^CPU/{
++ s: ::g
++ p
++ }'`"
++ test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; }
+ ;;
+ mips64:Linux:*:*)
+ eval $set_cc_for_build
+@@ -885,15 +905,22 @@ EOF
+ #endif
+ #endif
+ EOF
+- eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^CPU=`
+- test x"${CPU}" != x && echo "${CPU}-unknown-linux-gnu" && exit 0
++ eval "`$CC_FOR_BUILD -E $dummy.c 2>/dev/null | sed -n '
++ /^CPU/{
++ s: ::g
++ p
++ }'`"
++ test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; }
+ ;;
++ or32:Linux:*:*)
++ echo or32-unknown-linux-gnu
++ exit ;;
+ ppc:Linux:*:*)
+ echo powerpc-unknown-linux-gnu
+- exit 0 ;;
++ exit ;;
+ ppc64:Linux:*:*)
+ echo powerpc64-unknown-linux-gnu
+- exit 0 ;;
++ exit ;;
+ alpha:Linux:*:*)
+ case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in
+ EV5) UNAME_MACHINE=alphaev5 ;;
+@@ -907,7 +934,7 @@ EOF
+ objdump --private-headers /bin/sh | grep ld.so.1 >/dev/null
+ if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi
+ echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC}
+- exit 0 ;;
++ exit ;;
+ parisc:Linux:*:* | hppa:Linux:*:*)
+ # Look for CPU level
+ case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in
+@@ -915,25 +942,31 @@ EOF
+ PA8*) echo hppa2.0-unknown-linux-gnu ;;
+ *) echo hppa-unknown-linux-gnu ;;
+ esac
+- exit 0 ;;
++ exit ;;
+ parisc64:Linux:*:* | hppa64:Linux:*:*)
+ echo hppa64-unknown-linux-gnu
+- exit 0 ;;
++ exit ;;
+ s390:Linux:*:* | s390x:Linux:*:*)
+ echo ${UNAME_MACHINE}-ibm-linux
+- exit 0 ;;
++ exit ;;
+ sh64*:Linux:*:*)
+ echo ${UNAME_MACHINE}-unknown-linux-gnu
+- exit 0 ;;
++ exit ;;
+ sh*:Linux:*:*)
+ echo ${UNAME_MACHINE}-unknown-linux-gnu
+- exit 0 ;;
++ exit ;;
+ sparc:Linux:*:* | sparc64:Linux:*:*)
+ echo ${UNAME_MACHINE}-unknown-linux-gnu
+- exit 0 ;;
++ exit ;;
++ vax:Linux:*:*)
++ echo ${UNAME_MACHINE}-dec-linux-gnu
++ exit ;;
+ x86_64:Linux:*:*)
+ echo x86_64-unknown-linux-gnu
+- exit 0 ;;
++ exit ;;
++ xtensa*:Linux:*:*)
++ echo ${UNAME_MACHINE}-unknown-linux-gnu
++ exit ;;
+ i*86:Linux:*:*)
+ # The BFD linker knows what the default object file format is, so
+ # first see if it will tell us. cd to the root directory to prevent
+@@ -951,15 +984,15 @@ EOF
+ ;;
+ a.out-i386-linux)
+ echo "${UNAME_MACHINE}-pc-linux-gnuaout"
+- exit 0 ;;
++ exit ;;
+ coff-i386)
+ echo "${UNAME_MACHINE}-pc-linux-gnucoff"
+- exit 0 ;;
++ exit ;;
+ "")
+ # Either a pre-BFD a.out linker (linux-gnuoldld) or
+ # one that does not give us useful --help.
+ echo "${UNAME_MACHINE}-pc-linux-gnuoldld"
+- exit 0 ;;
++ exit ;;
+ esac
+ # Determine whether the default compiler is a.out or elf
+ eval $set_cc_for_build
+@@ -976,7 +1009,7 @@ EOF
+ LIBC=gnulibc1
+ # endif
+ #else
+- #ifdef __INTEL_COMPILER
++ #if defined(__INTEL_COMPILER) || defined(__PGI) || defined(__SUNPRO_C) || defined(__SUNPRO_CC)
+ LIBC=gnu
+ #else
+ LIBC=gnuaout
+@@ -986,16 +1019,23 @@ EOF
+ LIBC=dietlibc
+ #endif
+ EOF
+- eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^LIBC=`
+- test x"${LIBC}" != x && echo "${UNAME_MACHINE}-pc-linux-${LIBC}" && exit 0
+- test x"${TENTATIVE}" != x && echo "${TENTATIVE}" && exit 0
++ eval "`$CC_FOR_BUILD -E $dummy.c 2>/dev/null | sed -n '
++ /^LIBC/{
++ s: ::g
++ p
++ }'`"
++ test x"${LIBC}" != x && {
++ echo "${UNAME_MACHINE}-pc-linux-${LIBC}"
++ exit
++ }
++ test x"${TENTATIVE}" != x && { echo "${TENTATIVE}"; exit; }
+ ;;
+ i*86:DYNIX/ptx:4*:*)
+ # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there.
+ # earlier versions are messed up and put the nodename in both
+ # sysname and nodename.
+ echo i386-sequent-sysv4
+- exit 0 ;;
++ exit ;;
+ i*86:UNIX_SV:4.2MP:2.*)
+ # Unixware is an offshoot of SVR4, but it has its own version
+ # number series starting with 2...
+@@ -1003,27 +1043,27 @@ EOF
+ # I just have to hope. -- rms.
+ # Use sysv4.2uw... so that sysv4* matches it.
+ echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION}
+- exit 0 ;;
++ exit ;;
+ i*86:OS/2:*:*)
+ # If we were able to find `uname', then EMX Unix compatibility
+ # is probably installed.
+ echo ${UNAME_MACHINE}-pc-os2-emx
+- exit 0 ;;
++ exit ;;
+ i*86:XTS-300:*:STOP)
+ echo ${UNAME_MACHINE}-unknown-stop
+- exit 0 ;;
++ exit ;;
+ i*86:atheos:*:*)
+ echo ${UNAME_MACHINE}-unknown-atheos
+- exit 0 ;;
+- i*86:syllable:*:*)
++ exit ;;
++ i*86:syllable:*:*)
+ echo ${UNAME_MACHINE}-pc-syllable
+- exit 0 ;;
++ exit ;;
+ i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.0*:*)
+ echo i386-unknown-lynxos${UNAME_RELEASE}
+- exit 0 ;;
++ exit ;;
+ i*86:*DOS:*:*)
+ echo ${UNAME_MACHINE}-pc-msdosdjgpp
+- exit 0 ;;
++ exit ;;
+ i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*)
+ UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'`
+ if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then
+@@ -1031,15 +1071,16 @@ EOF
+ else
+ echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL}
+ fi
+- exit 0 ;;
+- i*86:*:5:[78]*)
++ exit ;;
++ i*86:*:5:[678]*)
++ # UnixWare 7.x, OpenUNIX and OpenServer 6.
+ case `/bin/uname -X | grep "^Machine"` in
+ *486*) UNAME_MACHINE=i486 ;;
+ *Pentium) UNAME_MACHINE=i586 ;;
+ *Pent*|*Celeron) UNAME_MACHINE=i686 ;;
+ esac
+ echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION}
+- exit 0 ;;
++ exit ;;
+ i*86:*:3.2:*)
+ if test -f /usr/options/cb.name; then
+ UNAME_REL=`sed -n 's/.*Version //p' </usr/options/cb.name`
+@@ -1057,73 +1098,73 @@ EOF
+ else
+ echo ${UNAME_MACHINE}-pc-sysv32
+ fi
+- exit 0 ;;
++ exit ;;
+ pc:*:*:*)
+ # Left here for compatibility:
+ # uname -m prints for DJGPP always 'pc', but it prints nothing about
+ # the processor, so we play safe by assuming i386.
+ echo i386-pc-msdosdjgpp
+- exit 0 ;;
++ exit ;;
+ Intel:Mach:3*:*)
+ echo i386-pc-mach3
+- exit 0 ;;
++ exit ;;
+ paragon:*:*:*)
+ echo i860-intel-osf1
+- exit 0 ;;
++ exit ;;
+ i860:*:4.*:*) # i860-SVR4
+ if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then
+ echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4
+ else # Add other i860-SVR4 vendors below as they are discovered.
+ echo i860-unknown-sysv${UNAME_RELEASE} # Unknown i860-SVR4
+ fi
+- exit 0 ;;
++ exit ;;
+ mini*:CTIX:SYS*5:*)
+ # "miniframe"
+ echo m68010-convergent-sysv
+- exit 0 ;;
++ exit ;;
+ mc68k:UNIX:SYSTEM5:3.51m)
+ echo m68k-convergent-sysv
+- exit 0 ;;
++ exit ;;
+ M680?0:D-NIX:5.3:*)
+ echo m68k-diab-dnix
+- exit 0 ;;
+- M68*:*:R3V[567]*:*)
+- test -r /sysV68 && echo 'm68k-motorola-sysv' && exit 0 ;;
+- 3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0)
++ exit ;;
++ M68*:*:R3V[5678]*:*)
++ test -r /sysV68 && { echo 'm68k-motorola-sysv'; exit; } ;;
++ 3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0 | S7501*:*:4.0:3.0)
+ OS_REL=''
+ test -r /etc/.relid \
+ && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid`
+ /bin/uname -p 2>/dev/null | grep 86 >/dev/null \
+- && echo i486-ncr-sysv4.3${OS_REL} && exit 0
++ && { echo i486-ncr-sysv4.3${OS_REL}; exit; }
+ /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \
+- && echo i586-ncr-sysv4.3${OS_REL} && exit 0 ;;
++ && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;;
+ 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*)
+ /bin/uname -p 2>/dev/null | grep 86 >/dev/null \
+- && echo i486-ncr-sysv4 && exit 0 ;;
++ && { echo i486-ncr-sysv4; exit; } ;;
+ m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*)
+ echo m68k-unknown-lynxos${UNAME_RELEASE}
+- exit 0 ;;
++ exit ;;
+ mc68030:UNIX_System_V:4.*:*)
+ echo m68k-atari-sysv4
+- exit 0 ;;
++ exit ;;
+ TSUNAMI:LynxOS:2.*:*)
+ echo sparc-unknown-lynxos${UNAME_RELEASE}
+- exit 0 ;;
++ exit ;;
+ rs6000:LynxOS:2.*:*)
+ echo rs6000-unknown-lynxos${UNAME_RELEASE}
+- exit 0 ;;
++ exit ;;
+ PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.0*:*)
+ echo powerpc-unknown-lynxos${UNAME_RELEASE}
+- exit 0 ;;
++ exit ;;
+ SM[BE]S:UNIX_SV:*:*)
+ echo mips-dde-sysv${UNAME_RELEASE}
+- exit 0 ;;
++ exit ;;
+ RM*:ReliantUNIX-*:*:*)
+ echo mips-sni-sysv4
+- exit 0 ;;
++ exit ;;
+ RM*:SINIX-*:*:*)
+ echo mips-sni-sysv4
+- exit 0 ;;
++ exit ;;
+ *:SINIX-*:*:*)
+ if uname -p 2>/dev/null >/dev/null ; then
+ UNAME_MACHINE=`(uname -p) 2>/dev/null`
+@@ -1131,68 +1172,84 @@ EOF
+ else
+ echo ns32k-sni-sysv
+ fi
+- exit 0 ;;
++ exit ;;
+ PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort
+ # says <Richard.M.Bartel@ccMail.Census.GOV>
+ echo i586-unisys-sysv4
+- exit 0 ;;
++ exit ;;
+ *:UNIX_System_V:4*:FTX*)
+ # From Gerald Hewes <hewes@openmarket.com>.
+ # How about differentiating between stratus architectures? -djm
+ echo hppa1.1-stratus-sysv4
+- exit 0 ;;
++ exit ;;
+ *:*:*:FTX*)
+ # From seanf@swdc.stratus.com.
+ echo i860-stratus-sysv4
+- exit 0 ;;
++ exit ;;
++ i*86:VOS:*:*)
++ # From Paul.Green@stratus.com.
++ echo ${UNAME_MACHINE}-stratus-vos
++ exit ;;
+ *:VOS:*:*)
+ # From Paul.Green@stratus.com.
+ echo hppa1.1-stratus-vos
+- exit 0 ;;
++ exit ;;
+ mc68*:A/UX:*:*)
+ echo m68k-apple-aux${UNAME_RELEASE}
+- exit 0 ;;
++ exit ;;
+ news*:NEWS-OS:6*:*)
+ echo mips-sony-newsos6
+- exit 0 ;;
++ exit ;;
+ R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*)
+ if [ -d /usr/nec ]; then
+ echo mips-nec-sysv${UNAME_RELEASE}
+ else
+ echo mips-unknown-sysv${UNAME_RELEASE}
+ fi
+- exit 0 ;;
++ exit ;;
+ BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only.
+ echo powerpc-be-beos
+- exit 0 ;;
++ exit ;;
+ BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only.
+ echo powerpc-apple-beos
+- exit 0 ;;
++ exit ;;
+ BePC:BeOS:*:*) # BeOS running on Intel PC compatible.
+ echo i586-pc-beos
+- exit 0 ;;
++ exit ;;
++ BePC:Haiku:*:*) # Haiku running on Intel PC compatible.
++ echo i586-pc-haiku
++ exit ;;
+ SX-4:SUPER-UX:*:*)
+ echo sx4-nec-superux${UNAME_RELEASE}
+- exit 0 ;;
++ exit ;;
+ SX-5:SUPER-UX:*:*)
+ echo sx5-nec-superux${UNAME_RELEASE}
+- exit 0 ;;
++ exit ;;
+ SX-6:SUPER-UX:*:*)
+ echo sx6-nec-superux${UNAME_RELEASE}
+- exit 0 ;;
++ exit ;;
++ SX-7:SUPER-UX:*:*)
++ echo sx7-nec-superux${UNAME_RELEASE}
++ exit ;;
++ SX-8:SUPER-UX:*:*)
++ echo sx8-nec-superux${UNAME_RELEASE}
++ exit ;;
++ SX-8R:SUPER-UX:*:*)
++ echo sx8r-nec-superux${UNAME_RELEASE}
++ exit ;;
+ Power*:Rhapsody:*:*)
+ echo powerpc-apple-rhapsody${UNAME_RELEASE}
+- exit 0 ;;
++ exit ;;
+ *:Rhapsody:*:*)
+ echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE}
+- exit 0 ;;
++ exit ;;
+ *:Darwin:*:*)
+- case `uname -p` in
+- *86) UNAME_PROCESSOR=i686 ;;
+- powerpc) UNAME_PROCESSOR=powerpc ;;
++ UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown
++ case $UNAME_PROCESSOR in
++ unknown) UNAME_PROCESSOR=powerpc ;;
+ esac
+ echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE}
+- exit 0 ;;
++ exit ;;
+ *:procnto*:*:* | *:QNX:[0123456789]*:*)
+ UNAME_PROCESSOR=`uname -p`
+ if test "$UNAME_PROCESSOR" = "x86"; then
+@@ -1200,22 +1257,25 @@ EOF
+ UNAME_MACHINE=pc
+ fi
+ echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE}
+- exit 0 ;;
++ exit ;;
+ *:QNX:*:4*)
+ echo i386-pc-qnx
+- exit 0 ;;
++ exit ;;
++ NSE-?:NONSTOP_KERNEL:*:*)
++ echo nse-tandem-nsk${UNAME_RELEASE}
++ exit ;;
+ NSR-?:NONSTOP_KERNEL:*:*)
+ echo nsr-tandem-nsk${UNAME_RELEASE}
+- exit 0 ;;
++ exit ;;
+ *:NonStop-UX:*:*)
+ echo mips-compaq-nonstopux
+- exit 0 ;;
++ exit ;;
+ BS2000:POSIX*:*:*)
+ echo bs2000-siemens-sysv
+- exit 0 ;;
++ exit ;;
+ DS/*:UNIX_System_V:*:*)
+ echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE}
+- exit 0 ;;
++ exit ;;
+ *:Plan9:*:*)
+ # "uname -m" is not consistent, so use $cputype instead. 386
+ # is converted to i386 for consistency with other x86
+@@ -1226,31 +1286,47 @@ EOF
+ UNAME_MACHINE="$cputype"
+ fi
+ echo ${UNAME_MACHINE}-unknown-plan9
+- exit 0 ;;
++ exit ;;
+ *:TOPS-10:*:*)
+ echo pdp10-unknown-tops10
+- exit 0 ;;
++ exit ;;
+ *:TENEX:*:*)
+ echo pdp10-unknown-tenex
+- exit 0 ;;
++ exit ;;
+ KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*)
+ echo pdp10-dec-tops20
+- exit 0 ;;
++ exit ;;
+ XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*)
+ echo pdp10-xkl-tops20
+- exit 0 ;;
++ exit ;;
+ *:TOPS-20:*:*)
+ echo pdp10-unknown-tops20
+- exit 0 ;;
++ exit ;;
+ *:ITS:*:*)
+ echo pdp10-unknown-its
+- exit 0 ;;
++ exit ;;
+ SEI:*:*:SEIUX)
+ echo mips-sei-seiux${UNAME_RELEASE}
+- exit 0 ;;
++ exit ;;
+ *:DragonFly:*:*)
+ echo ${UNAME_MACHINE}-unknown-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`
+- exit 0 ;;
++ exit ;;
++ *:*VMS:*:*)
++ UNAME_MACHINE=`(uname -p) 2>/dev/null`
++ case "${UNAME_MACHINE}" in
++ A*) echo alpha-dec-vms ; exit ;;
++ I*) echo ia64-dec-vms ; exit ;;
++ V*) echo vax-dec-vms ; exit ;;
++ esac ;;
++ *:XENIX:*:SysV)
++ echo i386-pc-xenix
++ exit ;;
++ i*86:skyos:*:*)
++ echo ${UNAME_MACHINE}-pc-skyos`echo ${UNAME_RELEASE}` | sed -e 's/ .*$//'
++ exit ;;
++ i*86:rdos:*:*)
++ echo ${UNAME_MACHINE}-pc-rdos
++ exit ;;
+ esac
+
+ #echo '(No uname command or uname output not recognized.)' 1>&2
+@@ -1282,7 +1358,7 @@ main ()
+ #endif
+
+ #if defined (__arm) && defined (__acorn) && defined (__unix)
+- printf ("arm-acorn-riscix"); exit (0);
++ printf ("arm-acorn-riscix\n"); exit (0);
+ #endif
+
+ #if defined (hp300) && !defined (hpux)
+@@ -1371,11 +1447,12 @@ main ()
+ }
+ EOF
+
+-$CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null && $dummy && exit 0
++$CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null && SYSTEM_NAME=`$dummy` &&
++ { echo "$SYSTEM_NAME"; exit; }
+
+ # Apollos put the system type in the environment.
+
+-test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit 0; }
++test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit; }
+
+ # Convex versions that predate uname can use getsysinfo(1)
+
+@@ -1384,22 +1461,22 @@ then
+ case `getsysinfo -f cpu_type` in
+ c1*)
+ echo c1-convex-bsd
+- exit 0 ;;
++ exit ;;
+ c2*)
+ if getsysinfo -f scalar_acc
+ then echo c32-convex-bsd
+ else echo c2-convex-bsd
+ fi
+- exit 0 ;;
++ exit ;;
+ c34*)
+ echo c34-convex-bsd
+- exit 0 ;;
++ exit ;;
+ c38*)
+ echo c38-convex-bsd
+- exit 0 ;;
++ exit ;;
+ c4*)
+ echo c4-convex-bsd
+- exit 0 ;;
++ exit ;;
+ esac
+ fi
+
+@@ -1410,7 +1487,9 @@ This script, last modified $timestamp, h
+ the operating system you are using. It is advised that you
+ download the most up to date version of the config scripts from
+
+- ftp://ftp.gnu.org/pub/gnu/config/
++ http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD
++and
++ http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD
+
+ If the version you run ($0) is already up to date, please
+ send the following data and any information you think might be
+Index: gdb-7.2.90.20110703/readline/support/config.rpath
+===================================================================
+--- gdb-7.2.90.20110703.orig/readline/support/config.rpath 2011-07-03 10:40:53.000000000 +0200
++++ gdb-7.2.90.20110703/readline/support/config.rpath 2011-07-03 10:41:21.000000000 +0200
+@@ -6,19 +6,18 @@
+ # Taken from GNU libtool, 2001
+ # Originally by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
+ #
+-# This program is free software; you can redistribute it and/or modify
++# This program is free software: you can redistribute it and/or modify
+ # it under the terms of the GNU General Public License as published by
+-# the Free Software Foundation; either version 2 of the License, or
++# the Free Software Foundation, either version 3 of the License, or
+ # (at your option) any later version.
+ #
+-# This program is distributed in the hope that it will be useful, but
+-# WITHOUT ANY WARRANTY; without even the implied warranty of
+-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+-# General Public License for more details.
++# This program is distributed in the hope that it will be useful,
++# but WITHOUT ANY WARRANTY; without even the implied warranty of
++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++# GNU General Public License for more details.
+ #
+ # You should have received a copy of the GNU General Public License
+-# along with this program; if not, write to the Free Software
+-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
++# along with this program. If not, see <http://www.gnu.org/licenses/>.
+ #
+ # As a special exception to the GNU General Public License, if you
+ # distribute this file as part of a program that contains a
+Index: gdb-7.2.90.20110703/readline/support/config.sub
+===================================================================
+--- gdb-7.2.90.20110703.orig/readline/support/config.sub 2011-07-03 10:40:53.000000000 +0200
++++ gdb-7.2.90.20110703/readline/support/config.sub 2011-07-03 10:41:21.000000000 +0200
+@@ -1,9 +1,10 @@
+ #! /bin/sh
+ # Configuration validation subroutine script.
+ # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
+-# 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
++# 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 20098
++# Free Software Foundation, Inc.
+
+-timestamp='2004-02-16'
++timestamp='2008-03-26'
+
+ # This file is (in principle) common to ALL GNU software.
+ # The presence of a machine in this file suggests that SOME GNU software
+@@ -21,14 +22,15 @@ timestamp='2004-02-16'
+ #
+ # You should have received a copy of the GNU General Public License
+ # along with this program; if not, write to the Free Software
+-# Foundation, Inc., 59 Temple Place - Suite 330,
+-# Boston, MA 02111-1307, USA.
+-
++# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA
++# 02110-1301, USA.
++#
+ # As a special exception to the GNU General Public License, if you
+ # distribute this file as part of a program that contains a
+ # configuration script generated by Autoconf, you may include it under
+ # the same distribution terms that you use for the rest of that program.
+
++
+ # Please send patches to <config-patches@gnu.org>. Submit a context
+ # diff and a properly formatted ChangeLog entry.
+ #
+@@ -70,8 +72,8 @@ Report bugs and patches to <config-patch
+ version="\
+ GNU config.sub ($timestamp)
+
+-Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001
+-Free Software Foundation, Inc.
++Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001,
++2002, 2003, 2004, 2005, 2006, 2007, 2008,2009 Free Software Foundation, Inc.
+
+ This is free software; see the source for copying conditions. There is NO
+ warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
+@@ -83,11 +85,11 @@ Try \`$me --help' for more information."
+ while test $# -gt 0 ; do
+ case $1 in
+ --time-stamp | --time* | -t )
+- echo "$timestamp" ; exit 0 ;;
++ echo "$timestamp" ; exit ;;
+ --version | -v )
+- echo "$version" ; exit 0 ;;
++ echo "$version" ; exit ;;
+ --help | --h* | -h )
+- echo "$usage"; exit 0 ;;
++ echo "$usage"; exit ;;
+ -- ) # Stop option processing
+ shift; break ;;
+ - ) # Use stdin as input.
+@@ -99,7 +101,7 @@ while test $# -gt 0 ; do
+ *local*)
+ # First pass through any local machine types.
+ echo $1
+- exit 0;;
++ exit ;;
+
+ * )
+ break ;;
+@@ -118,8 +120,9 @@ esac
+ # Here we must recognize all the valid KERNEL-OS combinations.
+ maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'`
+ case $maybe_os in
+- nto-qnx* | linux-gnu* | linux-dietlibc | linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | \
+- kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* | storm-chaos* | os2-emx* | rtmk-nova*)
++ nto-qnx* | linux-gnu* | linux-dietlibc | linux-newlib* | linux-uclibc* | \
++ uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* | \
++ storm-chaos* | os2-emx* | rtmk-nova*)
+ os=-$maybe_os
+ basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`
+ ;;
+@@ -145,7 +148,7 @@ case $os in
+ -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\
+ -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \
+ -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \
+- -apple | -axis)
++ -apple | -axis | -knuth | -cray)
+ os=
+ basic_machine=$1
+ ;;
+@@ -170,6 +173,10 @@ case $os in
+ -hiux*)
+ os=-hiuxwe2
+ ;;
++ -sco6)
++ os=-sco5v6
++ basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
++ ;;
+ -sco5)
+ os=-sco3.2v5
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+@@ -186,6 +193,10 @@ case $os in
+ # Don't forget version if it is 3.2v4 or newer.
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+ ;;
++ -sco5v6*)
++ # Don't forget version if it is 3.2v4 or newer.
++ basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
++ ;;
+ -sco*)
+ os=-sco3.2v2
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+@@ -230,22 +241,27 @@ case $basic_machine in
+ | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \
+ | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \
+ | am33_2.0 \
+- | arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr \
++ | arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr | avr32 \
++ | bfin \
+ | c4x | clipper \
+ | d10v | d30v | dlx | dsp16xx \
+- | fr30 | frv \
++ | fido | fr30 | frv \
+ | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \
+ | i370 | i860 | i960 | ia64 \
+ | ip2k | iq2000 \
+- | m32r | m68000 | m68k | m88k | mcore \
++ | m32c | m32r | m32rle | m68000 | m68k | m88k \
++ | maxq | mb | microblaze | mcore | mep | metag \
+ | mips | mipsbe | mipseb | mipsel | mipsle \
+ | mips16 \
+ | mips64 | mips64el \
+- | mips64vr | mips64vrel \
++ | mips64octeon | mips64octeonel \
+ | mips64orion | mips64orionel \
++ | mips64r5900 | mips64r5900el \
++ | mips64vr | mips64vrel \
+ | mips64vr4100 | mips64vr4100el \
+ | mips64vr4300 | mips64vr4300el \
+ | mips64vr5000 | mips64vr5000el \
++ | mips64vr5900 | mips64vr5900el \
+ | mipsisa32 | mipsisa32el \
+ | mipsisa32r2 | mipsisa32r2el \
+ | mipsisa64 | mipsisa64el \
+@@ -254,20 +270,24 @@ case $basic_machine in
+ | mipsisa64sr71k | mipsisa64sr71kel \
+ | mipstx39 | mipstx39el \
+ | mn10200 | mn10300 \
++ | mt \
+ | msp430 \
++ | nios | nios2 \
+ | ns16k | ns32k \
+- | openrisc | or32 \
++ | or32 \
+ | pdp10 | pdp11 | pj | pjl \
+ | powerpc | powerpc64 | powerpc64le | powerpcle | ppcbe \
+ | pyramid \
+- | sh | sh[1234] | sh[23]e | sh[34]eb | shbe | shle | sh[1234]le | sh3ele \
++ | score \
++ | sh | sh[1234] | sh[24]a | sh[23]e | sh[34]eb | sheb | shbe | shle | sh[1234]le | sh3ele \
+ | sh64 | sh64le \
+- | sparc | sparc64 | sparc86x | sparclet | sparclite | sparcv9 | sparcv9b \
+- | strongarm \
++ | sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \
++ | sparcv8 | sparcv9 | sparcv9b | sparcv9v \
++ | spu | strongarm \
+ | tahoe | thumb | tic4x | tic80 | tron \
+ | v850 | v850e \
+ | we32k \
+- | x86 | xscale | xstormy16 | xtensa \
++ | x86 | xc16x | xscale | xscalee[bl] | xstormy16 | xtensa \
+ | z8k)
+ basic_machine=$basic_machine-unknown
+ ;;
+@@ -278,6 +298,9 @@ case $basic_machine in
+ ;;
+ m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k)
+ ;;
++ ms1)
++ basic_machine=mt-unknown
++ ;;
+
+ # We use `pc' rather than `unknown'
+ # because (1) that's what they normally are, and
+@@ -297,28 +320,31 @@ case $basic_machine in
+ | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \
+ | alphapca5[67]-* | alpha64pca5[67]-* | arc-* \
+ | arm-* | armbe-* | armle-* | armeb-* | armv*-* \
+- | avr-* \
+- | bs2000-* \
++ | avr-* | avr32-* \
++ | bfin-* | bs2000-* \
+ | c[123]* | c30-* | [cjt]90-* | c4x-* | c54x-* | c55x-* | c6x-* \
+- | clipper-* | cydra-* \
++ | clipper-* | craynv-* | cydra-* \
+ | d10v-* | d30v-* | dlx-* \
+ | elxsi-* \
+- | f30[01]-* | f700-* | fr30-* | frv-* | fx80-* \
++ | f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \
+ | h8300-* | h8500-* \
+ | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \
+ | i*86-* | i860-* | i960-* | ia64-* \
+ | ip2k-* | iq2000-* \
+- | m32r-* \
++ | m32c-* | m32r-* | m32rle-* \
+ | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \
+- | m88110-* | m88k-* | mcore-* \
++ | m88110-* | m88k-* | maxq-* | mcore-* | metag-* \
+ | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \
+ | mips16-* \
+ | mips64-* | mips64el-* \
+- | mips64vr-* | mips64vrel-* \
++ | mips64octeon-* | mips64octeonel-* \
+ | mips64orion-* | mips64orionel-* \
++ | mips64r5900-* | mips64r5900el-* \
++ | mips64vr-* | mips64vrel-* \
+ | mips64vr4100-* | mips64vr4100el-* \
+ | mips64vr4300-* | mips64vr4300el-* \
+ | mips64vr5000-* | mips64vr5000el-* \
++ | mips64vr5900-* | mips64vr5900el-* \
+ | mipsisa32-* | mipsisa32el-* \
+ | mipsisa32r2-* | mipsisa32r2el-* \
+ | mipsisa64-* | mipsisa64el-* \
+@@ -326,27 +352,35 @@ case $basic_machine in
+ | mipsisa64sb1-* | mipsisa64sb1el-* \
+ | mipsisa64sr71k-* | mipsisa64sr71kel-* \
+ | mipstx39-* | mipstx39el-* \
++ | mmix-* \
++ | mt-* \
+ | msp430-* \
+- | none-* | np1-* | nv1-* | ns16k-* | ns32k-* \
++ | nios-* | nios2-* \
++ | none-* | np1-* | ns16k-* | ns32k-* \
+ | orion-* \
+ | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \
+ | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* | ppcbe-* \
+ | pyramid-* \
+ | romp-* | rs6000-* \
+- | sh-* | sh[1234]-* | sh[23]e-* | sh[34]eb-* | shbe-* \
++ | sh-* | sh[1234]-* | sh[24]a-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \
+ | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \
+- | sparc-* | sparc64-* | sparc86x-* | sparclet-* | sparclite-* \
+- | sparcv9-* | sparcv9b-* | strongarm-* | sv1-* | sx?-* \
++ | sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \
++ | sparclite-* \
++ | sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | strongarm-* | sv1-* | sx?-* \
+ | tahoe-* | thumb-* \
+- | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \
++ | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* | tile-* \
+ | tron-* \
+ | v850-* | v850e-* | vax-* \
+ | we32k-* \
+- | x86-* | x86_64-* | xps100-* | xscale-* | xstormy16-* \
+- | xtensa-* \
++ | x86-* | x86_64-* | xc16x-* | xps100-* | xscale-* | xscalee[bl]-* \
++ | xstormy16-* | xtensa*-* \
+ | ymp-* \
+ | z8k-*)
+ ;;
++ # Recognize the basic CPU types without company name, with glob match.
++ xtensa*)
++ basic_machine=$basic_machine-unknown
++ ;;
+ # Recognize the various machine names and aliases which stand
+ # for a CPU type and a company and sometimes even an OS.
+ 386bsd)
+@@ -417,6 +451,14 @@ case $basic_machine in
+ basic_machine=ns32k-sequent
+ os=-dynix
+ ;;
++ blackfin)
++ basic_machine=bfin-unknown
++ os=-linux
++ ;;
++ blackfin-*)
++ basic_machine=bfin-`echo $basic_machine | sed 's/^[^-]*-//'`
++ os=-linux
++ ;;
+ c90)
+ basic_machine=c90-cray
+ os=-unicos
+@@ -445,16 +487,27 @@ case $basic_machine in
+ basic_machine=j90-cray
+ os=-unicos
+ ;;
+- cr16c)
+- basic_machine=cr16c-unknown
++ craynv)
++ basic_machine=craynv-cray
++ os=-unicosmp
++ ;;
++ cr16)
++ basic_machine=cr16-unknown
+ os=-elf
+ ;;
+ crds | unos)
+ basic_machine=m68k-crds
+ ;;
++ crisv32 | crisv32-* | etraxfs*)
++ basic_machine=crisv32-axis
++ ;;
+ cris | cris-* | etrax*)
+ basic_machine=cris-axis
+ ;;
++ crx)
++ basic_machine=crx-unknown
++ os=-elf
++ ;;
+ da30 | da30-*)
+ basic_machine=m68k-da30
+ ;;
+@@ -477,6 +530,10 @@ case $basic_machine in
+ basic_machine=m88k-motorola
+ os=-sysv3
+ ;;
++ djgpp)
++ basic_machine=i586-pc
++ os=-msdosdjgpp
++ ;;
+ dpx20 | dpx20-*)
+ basic_machine=rs6000-bull
+ os=-bosx
+@@ -627,6 +684,14 @@ case $basic_machine in
+ basic_machine=m68k-isi
+ os=-sysv
+ ;;
++ m68knommu)
++ basic_machine=m68k-unknown
++ os=-linux
++ ;;
++ m68knommu-*)
++ basic_machine=m68k-`echo $basic_machine | sed 's/^[^-]*-//'`
++ os=-linux
++ ;;
+ m88k-omron*)
+ basic_machine=m88k-omron
+ ;;
+@@ -642,6 +707,10 @@ case $basic_machine in
+ basic_machine=i386-pc
+ os=-mingw32
+ ;;
++ mingw32ce)
++ basic_machine=arm-unknown
++ os=-mingw32ce
++ ;;
+ miniframe)
+ basic_machine=m68000-convergent
+ ;;
+@@ -655,10 +724,6 @@ case $basic_machine in
+ mips3*)
+ basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown
+ ;;
+- mmix*)
+- basic_machine=mmix-knuth
+- os=-mmixware
+- ;;
+ monitor)
+ basic_machine=m68k-rom68k
+ os=-coff
+@@ -671,6 +736,9 @@ case $basic_machine in
+ basic_machine=i386-pc
+ os=-msdos
+ ;;
++ ms1-*)
++ basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'`
++ ;;
+ mvs)
+ basic_machine=i370-ibm
+ os=-mvs
+@@ -739,9 +807,8 @@ case $basic_machine in
+ np1)
+ basic_machine=np1-gould
+ ;;
+- nv1)
+- basic_machine=nv1-cray
+- os=-unicosmp
++ nse-tandem)
++ basic_machine=nse-tandem
+ ;;
+ nsr-tandem)
+ basic_machine=nsr-tandem
+@@ -750,9 +817,8 @@ case $basic_machine in
+ basic_machine=hppa1.1-oki
+ os=-proelf
+ ;;
+- or32 | or32-*)
++ openrisc | openrisc-*)
+ basic_machine=or32-unknown
+- os=-coff
+ ;;
+ os400)
+ basic_machine=powerpc-ibm
+@@ -774,6 +840,14 @@ case $basic_machine in
+ basic_machine=i860-intel
+ os=-osf
+ ;;
++ parisc)
++ basic_machine=hppa-unknown
++ os=-linux
++ ;;
++ parisc-*)
++ basic_machine=hppa-`echo $basic_machine | sed 's/^[^-]*-//'`
++ os=-linux
++ ;;
+ pbd)
+ basic_machine=sparc-tti
+ ;;
+@@ -783,6 +857,12 @@ case $basic_machine in
+ pc532 | pc532-*)
+ basic_machine=ns32k-pc532
+ ;;
++ pc98)
++ basic_machine=i386-pc
++ ;;
++ pc98-*)
++ basic_machine=i386-`echo $basic_machine | sed 's/^[^-]*-//'`
++ ;;
+ pentium | p5 | k5 | k6 | nexgen | viac3)
+ basic_machine=i586-pc
+ ;;
+@@ -839,6 +919,10 @@ case $basic_machine in
+ basic_machine=i586-unknown
+ os=-pw32
+ ;;
++ rdos)
++ basic_machine=i386-pc
++ os=-rdos
++ ;;
+ rom68k)
+ basic_machine=m68k-rom68k
+ os=-coff
+@@ -865,6 +949,10 @@ case $basic_machine in
+ sb1el)
+ basic_machine=mipsisa64sb1el-unknown
+ ;;
++ sde)
++ basic_machine=mipsisa32-sde
++ os=-elf
++ ;;
+ sei)
+ basic_machine=mips-sei
+ os=-seiux
+@@ -876,6 +964,9 @@ case $basic_machine in
+ basic_machine=sh-hitachi
+ os=-hms
+ ;;
++ sh5el)
++ basic_machine=sh5le-unknown
++ ;;
+ sh64)
+ basic_machine=sh64-unknown
+ ;;
+@@ -965,6 +1056,10 @@ case $basic_machine in
+ basic_machine=tic6x-unknown
+ os=-coff
+ ;;
++ tile*)
++ basic_machine=tile-unknown
++ os=-linux-gnu
++ ;;
+ tx39)
+ basic_machine=mipstx39-unknown
+ ;;
+@@ -1025,6 +1120,10 @@ case $basic_machine in
+ basic_machine=hppa1.1-winbond
+ os=-proelf
+ ;;
++ xbox)
++ basic_machine=i686-pc
++ os=-mingw32
++ ;;
+ xps | xps100)
+ basic_machine=xps100-honeywell
+ ;;
+@@ -1055,6 +1154,9 @@ case $basic_machine in
+ romp)
+ basic_machine=romp-ibm
+ ;;
++ mmix)
++ basic_machine=mmix-knuth
++ ;;
+ rs6000)
+ basic_machine=rs6000-ibm
+ ;;
+@@ -1071,13 +1173,10 @@ case $basic_machine in
+ we32k)
+ basic_machine=we32k-att
+ ;;
+- sh3 | sh4 | sh[34]eb | sh[1234]le | sh[23]ele)
++ sh[1234] | sh[24]a | sh[34]eb | sh[1234]le | sh[23]ele)
+ basic_machine=sh-unknown
+ ;;
+- sh64)
+- basic_machine=sh64-unknown
+- ;;
+- sparc | sparcv9 | sparcv9b)
++ sparc | sparcv8 | sparcv9 | sparcv9b | sparcv9v)
+ basic_machine=sparc-sun
+ ;;
+ cydra)
+@@ -1150,20 +1249,23 @@ case $os in
+ | -aos* \
+ | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \
+ | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \
+- | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* | -openbsd* \
++ | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \
++ | -openbsd* | -solidbsd* \
+ | -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \
+ | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \
+ | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \
+ | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \
+ | -chorusos* | -chorusrdb* \
+ | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
+- | -mingw32* | -linux-gnu* | -linux-uclibc* | -uxpv* | -beos* | -mpeix* | -udk* \
++ | -mingw32* | -linux-gnu* | -linux-newlib* | -linux-uclibc* \
++ | -uxpv* | -beos* | -mpeix* | -udk* \
+ | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \
+ | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \
+ | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \
+ | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \
+ | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \
+- | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly*)
++ | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \
++ | -skyos* | -haiku* | -rdos* | -toppers* | -drops*)
+ # Remember, each alternative MUST END IN *, to match a version number.
+ ;;
+ -qnx*)
+@@ -1181,7 +1283,7 @@ case $os in
+ os=`echo $os | sed -e 's|nto|nto-qnx|'`
+ ;;
+ -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \
+- | -windows* | -osx | -abug | -netware* | -os9* | -beos* \
++ | -windows* | -osx | -abug | -netware* | -os9* | -beos* | -haiku* \
+ | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*)
+ ;;
+ -mac*)
+@@ -1290,6 +1392,9 @@ case $os in
+ -kaos*)
+ os=-kaos
+ ;;
++ -zvmoe)
++ os=-zvmoe
++ ;;
+ -none)
+ ;;
+ *)
+@@ -1312,6 +1417,12 @@ else
+ # system, and we'll never get to this point.
+
+ case $basic_machine in
++ score-*)
++ os=-elf
++ ;;
++ spu-*)
++ os=-elf
++ ;;
+ *-acorn)
+ os=-riscix1.2
+ ;;
+@@ -1321,9 +1432,9 @@ case $basic_machine in
+ arm*-semi)
+ os=-aout
+ ;;
+- c4x-* | tic4x-*)
+- os=-coff
+- ;;
++ c4x-* | tic4x-*)
++ os=-coff
++ ;;
+ # This must come before the *-dec entry.
+ pdp10-*)
+ os=-tops20
+@@ -1349,6 +1460,9 @@ case $basic_machine in
+ m68*-cisco)
+ os=-aout
+ ;;
++ mep-*)
++ os=-elf
++ ;;
+ mips*-cisco)
+ os=-elf
+ ;;
+@@ -1367,9 +1481,15 @@ case $basic_machine in
+ *-be)
+ os=-beos
+ ;;
++ *-haiku)
++ os=-haiku
++ ;;
+ *-ibm)
+ os=-aix
+ ;;
++ *-knuth)
++ os=-mmixware
++ ;;
+ *-wec)
+ os=-proelf
+ ;;
+@@ -1535,7 +1655,7 @@ case $basic_machine in
+ esac
+
+ echo $basic_machine$os
+-exit 0
++exit
+
+ # Local variables:
+ # eval: (add-hook 'write-file-hooks 'time-stamp)
+Index: gdb-7.2.90.20110703/readline/support/mkdirs
+===================================================================
+--- gdb-7.2.90.20110703.orig/readline/support/mkdirs 2011-07-03 10:40:53.000000000 +0200
++++ gdb-7.2.90.20110703/readline/support/mkdirs 2011-07-03 10:41:21.000000000 +0200
+@@ -7,19 +7,18 @@
+
+ # Copyright (C) 1996-2002 Free Software Foundation, Inc.
+ #
+-# This program is free software; you can redistribute it and/or modify
+-# it under the terms of the GNU General Public License as published by
+-# the Free Software Foundation; either version 2, or (at your option)
+-# any later version.
++# This program is free software: you can redistribute it and/or modify
++# it under the terms of the GNU General Public License as published by
++# the Free Software Foundation, either version 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.
++# This program is distributed in the hope that it will be useful,
++# but WITHOUT ANY WARRANTY; without even the implied warranty of
++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++# GNU General Public License for more details.
+ #
+-# You should have received a copy of the GNU General Public License
+-# along with this program; if not, write to the Free Software
+-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA.
++# You should have received a copy of the GNU General Public License
++# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+ for dir
+ do
+Index: gdb-7.2.90.20110703/readline/support/mkdist
+===================================================================
+--- gdb-7.2.90.20110703.orig/readline/support/mkdist 2011-07-03 10:40:53.000000000 +0200
++++ gdb-7.2.90.20110703/readline/support/mkdist 2011-07-03 10:41:21.000000000 +0200
+@@ -12,19 +12,19 @@
+
+ # Copyright (C) 1996-2002 Free Software Foundation, Inc.
+ #
+-# This program is free software; you can redistribute it and/or modify
+-# it under the terms of the GNU General Public License as published by
+-# the Free Software Foundation; either version 2, or (at your option)
+-# any later version.
++# This program is free software: you can redistribute it and/or modify
++# it under the terms of the GNU General Public License as published by
++# the Free Software Foundation, either version 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.
++# This program is distributed in the hope that it will be useful,
++# but WITHOUT ANY WARRANTY; without even the implied warranty of
++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++# GNU General Public License for more details.
++#
++# You should have received a copy of the GNU General Public License
++# along with this program. If not, see <http://www.gnu.org/licenses/>.
+ #
+-# You should have received a copy of the GNU General Public License
+-# along with this program; if not, write to the Free Software
+-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA.
+
+ SRCDIR=src
+ ROOTNAME=bash
+Index: gdb-7.2.90.20110703/readline/support/shlib-install
+===================================================================
+--- gdb-7.2.90.20110703.orig/readline/support/shlib-install 2011-07-03 10:40:53.000000000 +0200
++++ gdb-7.2.90.20110703/readline/support/shlib-install 2011-07-03 10:41:21.000000000 +0200
+@@ -3,7 +3,7 @@
+ # shlib-install - install a shared library and do any necessary host-specific
+ # post-installation configuration (like ldconfig)
+ #
+-# usage: shlib-install [-D] -O host_os -d installation-dir [-b bin-dir] -i install-prog [-U] library
++# usage: shlib-install [-D] -O host_os [-V host_vendor] -d installation-dir [-b bin-dir] -i install-prog [-U] library
+ #
+ # Chet Ramey
+ # chet@po.cwru.edu
+@@ -15,13 +15,14 @@ INSTALLDIR=/usr/local/lib
+ LDCONFIG=ldconfig
+
+ PROGNAME=`basename $0`
+-USAGE="$PROGNAME [-D] -O host_os -d installation-dir [-b bin-dir] -i install-prog [-U] library"
++USAGE="$PROGNAME [-D] -O host_os [-V host_vendor] -d installation-dir [-b bin-dir] -i install-prog [-U] library"
+
+ # process options
+
+ while [ $# -gt 0 ]; do
+ case "$1" in
+ -O) shift; host_os="$1"; shift ;;
++ -V) shift; host_vendor="$1"; shift ;;
+ -d) shift; INSTALLDIR="$1"; shift ;;
+ -b) shift; BINDIR="$1" ; shift ;;
+ -i) shift; INSTALLPROG="$1" ; shift ;;
+@@ -65,14 +66,15 @@ fi
+ # post-install/uninstall
+
+ # HP-UX and Darwin/MacOS X require that a shared library have execute permission
++# Linux does, too, and ldd warns about it
+ # Cygwin installs both a dll (which must go in $BINDIR) and an implicit
+ # link library (in $libdir)
+ case "$host_os" in
+-hpux*|darwin*|macosx*)
++hpux*|darwin*|macosx*|linux*)
+ if [ -z "$uninstall" ]; then
+ chmod 555 ${INSTALLDIR}/${LIBNAME}
+ fi ;;
+-cygwin*)
++cygwin*|mingw*)
+ IMPLIBNAME=`echo ${LIBNAME} \
+ | sed -e 's,^cyg,lib,' -e 's,[0-9]*.dll$,.dll.a,'`
+ if [ -z "$uninstall" ]; then
+@@ -114,8 +116,8 @@ INSTALL_LINK2='${echo} cd $INSTALLDIR &&
+ #
+ # Create symlinks to the installed library. This section is incomplete.
+ #
+-case "$host_os" in
+-*linux*)
++case "$host_os-$host_vendor" in
++*linux*|freebsd*-gentoo)
+ # libname.so.M -> libname.so.M.N
+ ${echo} ${RM} ${INSTALLDIR}/$LINK2
+ if [ -z "$uninstall" ]; then
+@@ -129,7 +131,7 @@ case "$host_os" in
+ fi
+ ;;
+
+-bsdi4*|*gnu*|darwin*|macosx*|k*bsd*-gnu)
++bsdi4*|*gnu*|darwin*|macosx*|netbsd*)
+ # libname.so.M -> libname.so.M.N
+ ${echo} ${RM} ${INSTALLDIR}/$LINK2
+ if [ -z "$uninstall" ]; then
+@@ -143,7 +145,7 @@ bsdi4*|*gnu*|darwin*|macosx*|k*bsd*-gnu)
+ fi
+ ;;
+
+-solaris2*|aix4.[2-9]*|osf*|irix[56]*|sysv[45]*|dgux*)
++solaris2*|aix4.[2-9]*|aix[5-9]*|osf*|irix[56]*|sysv[45]*|dgux*|interix*)
+ # libname.so -> libname.so.M
+ ${echo} ${RM} ${INSTALLDIR}/$LINK1
+ if [ -z "$uninstall" ]; then
+@@ -153,7 +155,7 @@ solaris2*|aix4.[2-9]*|osf*|irix[56]*|sys
+
+
+ # FreeBSD 3.x and above can have either a.out or ELF shared libraries
+-freebsd[3-9]*|freebsdelf[3-9]*|freebsdaout[3-9]*)
++freebsd3*|freebsdaout*)
+ if [ -x /usr/bin/objformat ] && [ "`/usr/bin/objformat`" = "elf" ]; then
+ # libname.so -> libname.so.M
+ ${echo} ${RM} ${INSTALLDIR}/$LINK1
+@@ -175,6 +177,14 @@ freebsd[3-9]*|freebsdelf[3-9]*|freebsdao
+ fi
+ ;;
+
++freebsd[4-9]*|freebsdelf*|dragonfly*)
++ # libname.so -> libname.so.M
++ ${echo} ${RM} ${INSTALLDIR}/$LINK1
++ if [ -z "$uninstall" ]; then
++ eval $INSTALL_LINK1
++ fi
++ ;;
++
+ hpux1*)
+ # libname.sl -> libname.M
+ ${echo} ${RM} ${INSTALLDIR}/$LINK1.sl
+@@ -183,7 +193,7 @@ hpux1*)
+ fi
+ ;;
+
+-cygwin*)
++cygwin*|mingw*)
+ # Links to .dlls don't work. Hence shobj-conf used DLLVERSION.dll
+ # instead of so.SHLIB_MAJOR.SHLIB_MINOR. The postinstall above
+ # took care of everything else.
+Index: gdb-7.2.90.20110703/readline/support/shobj-conf
+===================================================================
+--- gdb-7.2.90.20110703.orig/readline/support/shobj-conf 2011-07-03 10:40:53.000000000 +0200
++++ gdb-7.2.90.20110703/readline/support/shobj-conf 2011-07-03 10:41:21.000000000 +0200
+@@ -10,21 +10,23 @@
+ # Chet Ramey
+ # chet@po.cwru.edu
+
+-# Copyright (C) 1996-2002 Free Software Foundation, Inc.
++# Copyright (C) 1996-2009 Free Software Foundation, Inc.
++#
++# This file is part of GNU Bash, the Bourne Again SHell.
++#
++# This program is free software: you can redistribute it and/or modify
++# it under the terms of the GNU General Public License as published by
++# the Free Software Foundation, either version 3 of the License, or
++# (at your option) any later version.
++#
++# This program is distributed in the hope that it will be useful,
++# but WITHOUT ANY WARRANTY; without even the implied warranty of
++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++# GNU General Public License for more details.
++#
++# You should have received a copy of the GNU General Public License
++# along with this program. If not, see <http://www.gnu.org/licenses/>.
+ #
+-# This program is free software; you can redistribute it and/or modify
+-# it under the terms of the GNU General Public License as published by
+-# the Free Software Foundation; either version 2, or (at your option)
+-# any later version.
+-#
+-# This program is distributed in the hope that it will be useful,
+-# but WITHOUT ANY WARRANTY; without even the implied warranty of
+-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+-# GNU General Public License for more details.
+-#
+-# You should have received a copy of the GNU General Public License
+-# along with this program; if not, write to the Free Software
+-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA.
+
+ #
+ # defaults
+@@ -62,7 +64,7 @@ while [ $# -gt 0 ]; do
+ esac
+ done
+
+-case "${host_os}-${SHOBJ_CC}" in
++case "${host_os}-${SHOBJ_CC}-${host_vendor}" in
+ sunos4*-*gcc*)
+ SHOBJ_CFLAGS=-fpic
+ SHOBJ_LD=/usr/bin/ld
+@@ -80,15 +82,17 @@ sunos4*)
+ ;;
+
+ sunos5*-*gcc*|solaris2*-*gcc*)
+- SHOBJ_CFLAGS=-fpic
+ SHOBJ_LD='${CC}'
+ ld_used=`gcc -print-prog-name=ld`
+ if ${ld_used} -V 2>&1 | grep GNU >/dev/null 2>&1; then
+ # This line works for the GNU ld
+ SHOBJ_LDFLAGS='-shared -Wl,-h,$@'
++ # http://sourceware.org/ml/binutils/2001-08/msg00361.html
++ SHOBJ_CFLAGS=-fPIC
+ else
+ # This line works for the Solaris linker in /usr/ccs/bin/ld
+ SHOBJ_LDFLAGS='-shared -Wl,-i -Wl,-h,$@'
++ SHOBJ_CFLAGS=-fpic
+ fi
+
+ # SHLIB_XLDFLAGS='-R $(libdir)'
+@@ -104,8 +108,8 @@ sunos5*|solaris2*)
+ SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)'
+ ;;
+
+-# All versions of Linux or the semi-mythical GNU Hurd.
+-linux*-*|gnu*-*|k*bsd*-gnu-*)
++# All versions of Linux (including Gentoo/FreeBSD) or the semi-mythical GNU Hurd.
++linux*-*|gnu*-*|k*bsd*-gnu-*|freebsd*-gentoo)
+ SHOBJ_CFLAGS=-fPIC
+ SHOBJ_LD='${CC}'
+ SHOBJ_LDFLAGS='-shared -Wl,-soname,$@'
+@@ -114,7 +118,7 @@ linux*-*|gnu*-*|k*bsd*-gnu-*)
+ SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)$(SHLIB_MINOR)'
+ ;;
+
+-freebsd2* | netbsd*)
++freebsd2*)
+ SHOBJ_CFLAGS=-fpic
+ SHOBJ_LD=ld
+ SHOBJ_LDFLAGS='-x -Bshareable'
+@@ -124,8 +128,8 @@ freebsd2* | netbsd*)
+ ;;
+
+ # FreeBSD-3.x ELF
+-freebsd[3-9]*|freebsdelf[3-9]*|freebsdaout[3-9]*|dragonfly*)
+- SHOBJ_CFLAGS=-fpic
++freebsd3*|freebsdaout*)
++ SHOBJ_CFLAGS=-fPIC
+ SHOBJ_LD='${CC}'
+
+ if [ -x /usr/bin/objformat ] && [ "`/usr/bin/objformat`" = "elf" ]; then
+@@ -141,7 +145,35 @@ freebsd[3-9]*|freebsdelf[3-9]*|freebsdao
+ fi
+ ;;
+
++# FreeBSD-4.x and later have only ELF
++freebsd[4-9]*|freebsdelf*|dragonfly*)
++ SHOBJ_CFLAGS=-fPIC
++ SHOBJ_LD='${CC}'
++
++ SHOBJ_LDFLAGS='-shared -Wl,-soname,$@'
++ SHLIB_XLDFLAGS='-Wl,-rpath,$(libdir)'
++
++ SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)'
++ ;;
++
+ # Darwin/MacOS X
++darwin[89]*|darwin10*)
++ SHOBJ_STATUS=supported
++ SHLIB_STATUS=supported
++
++ SHOBJ_CFLAGS='-fno-common'
++
++ SHOBJ_LD='MACOSX_DEPLOYMENT_TARGET=10.3 ${CC}'
++
++ SHLIB_LIBVERSION='$(SHLIB_MAJOR)$(SHLIB_MINOR).$(SHLIB_LIBSUFF)'
++ SHLIB_LIBSUFF='dylib'
++
++ SHOBJ_LDFLAGS='-dynamiclib -dynamic -undefined dynamic_lookup -arch_only `/usr/bin/arch`'
++ SHLIB_XLDFLAGS='-dynamiclib -arch_only `/usr/bin/arch` -install_name $(libdir)/$@ -current_version $(SHLIB_MAJOR)$(SHLIB_MINOR) -compatibility_version $(SHLIB_MAJOR) -v'
++
++ SHLIB_LIBS='-lncurses' # see if -lcurses works on MacOS X 10.1
++ ;;
++
+ darwin*|macosx*)
+ SHOBJ_STATUS=unsupported
+ SHLIB_STATUS=supported
+@@ -154,7 +186,7 @@ darwin*|macosx*)
+ SHLIB_LIBSUFF='dylib'
+
+ case "${host_os}" in
+- darwin[78]*) SHOBJ_LDFLAGS=''
++ darwin[789]*|darwin10*) SHOBJ_LDFLAGS=''
+ SHLIB_XLDFLAGS='-dynamiclib -arch_only `/usr/bin/arch` -install_name $(libdir)/$@ -current_version $(SHLIB_MAJOR)$(SHLIB_MINOR) -compatibility_version $(SHLIB_MAJOR) -v'
+ ;;
+ *) SHOBJ_LDFLAGS='-dynamic'
+@@ -165,7 +197,7 @@ darwin*|macosx*)
+ SHLIB_LIBS='-lncurses' # see if -lcurses works on MacOS X 10.1
+ ;;
+
+-openbsd*)
++openbsd*|netbsd*)
+ SHOBJ_CFLAGS=-fPIC
+ SHOBJ_LD='${CC}'
+ SHOBJ_LDFLAGS='-shared'
+@@ -230,7 +262,7 @@ osf*)
+ SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)'
+ ;;
+
+-aix4.[2-9]*-*gcc*) # lightly tested by jik@cisco.com
++aix4.[2-9]*-*gcc*|aix[5-9].*-*gcc*) # lightly tested by jik@cisco.com
+ SHOBJ_CFLAGS=-fpic
+ SHOBJ_LD='ld'
+ SHOBJ_LDFLAGS='-bdynamic -bnoentry -bexpall'
+@@ -241,7 +273,7 @@ aix4.[2-9]*-*gcc*) # lightly tested by
+ SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)'
+ ;;
+
+-aix4.[2-9]*)
++aix4.[2-9]*|aix[5-9].*)
+ SHOBJ_CFLAGS=-K
+ SHOBJ_LD='ld'
+ SHOBJ_LDFLAGS='-bdynamic -bnoentry -bexpall'
+@@ -312,7 +344,7 @@ hpux10*-*gcc*)
+ SHOBJ_LD='${CC}'
+ # if you have problems linking here, moving the `-Wl,+h,$@' from
+ # SHLIB_XLDFLAGS to SHOBJ_LDFLAGS has been reported to work
+- SHOBJ_LDFLAGS='-shared -Wl,-b -Wl,+s'
++ SHOBJ_LDFLAGS='-shared -fpic -Wl,-b -Wl,+s'
+
+ SHLIB_XLDFLAGS='-Wl,+h,$@ -Wl,+b,$(libdir)'
+ SHLIB_LIBSUFF='sl'
+@@ -472,20 +504,37 @@ msdos*)
+
+ cygwin*)
+ SHOBJ_LD='$(CC)'
+- SHOBJ_LDFLAGS='-shared -Wl,--enable-auto-import -Wl,--enable-auto-image-base -Wl,--export-all -Wl,--out-implib=$(@).a'
+- SHLIB_LIBPREF='cyg'
+- SHLIB_LIBSUFF='dll'
+- SHLIB_LIBVERSION='$(SHLIB_DLLVERSION).$(SHLIB_LIBSUFF)'
+- SHLIB_LIBS='$(TERMCAP_LIB)'
++ SHOBJ_LDFLAGS='-shared -Wl,--enable-auto-import -Wl,--enable-auto-image-base -Wl,--export-all -Wl,--out-implib=$(@).a'
++ SHLIB_LIBPREF='cyg'
++ SHLIB_LIBSUFF='dll'
++ SHLIB_LIBVERSION='$(SHLIB_DLLVERSION).$(SHLIB_LIBSUFF)'
++ SHLIB_LIBS='$(TERMCAP_LIB)'
+
+ SHLIB_DOT=
+- # For official cygwin releases, DLLVERSION will be defined in the
+- # environment of configure, and will be incremented any time the API
+- # changes in a non-backwards compatible manner. Otherwise, it is just
+- # SHLIB_MAJOR.
+- if [ -n "$DLLVERSION" ] ; then
++ # For official cygwin releases, DLLVERSION will be defined in the
++ # environment of configure, and will be incremented any time the API
++ # changes in a non-backwards compatible manner. Otherwise, it is just
++ # SHLIB_MAJOR.
++ if [ -n "$DLLVERSION" ] ; then
+ SHLIB_DLLVERSION="$DLLVERSION"
+- fi
++ fi
++ ;;
++
++mingw*)
++ SHOBJ_LD='$(CC)'
++ SHOBJ_LDFLAGS='-shared -Wl,--enable-auto-import -Wl,--enable-auto-image-base -Wl,--export-all -Wl,--out-implib=$(@).a'
++ SHLIB_LIBSUFF='dll'
++ SHLIB_LIBVERSION='$(SHLIB_DLLVERSION).$(SHLIB_LIBSUFF)'
++ SHLIB_LIBS='$(TERMCAP_LIB)'
++
++ SHLIB_DOT=
++ # For official cygwin releases, DLLVERSION will be defined in the
++ # environment of configure, and will be incremented any time the API
++ # changes in a non-backwards compatible manner. Otherwise, it is just
++ # SHLIB_MAJOR.
++ if [ -n "$DLLVERSION" ] ; then
++ SHLIB_DLLVERSION="$DLLVERSION"
++ fi
+ ;;
+
+ #
+Index: gdb-7.2.90.20110703/readline/support/wcwidth.c
+===================================================================
+--- gdb-7.2.90.20110703.orig/readline/support/wcwidth.c 2011-07-03 10:40:53.000000000 +0200
++++ gdb-7.2.90.20110703/readline/support/wcwidth.c 2011-07-03 10:41:21.000000000 +0200
+@@ -1,21 +1,73 @@
+ /*
+- * This is an implementation of wcwidth() and wcswidth() as defined in
+- * "The Single UNIX Specification, Version 2, The Open Group, 1997"
+- * <http://www.UNIX-systems.org/online.html>
++ * This is an implementation of wcwidth() and wcswidth() (defined in
++ * IEEE Std 1002.1-2001) for Unicode.
+ *
+- * Markus Kuhn -- 2001-09-08 -- public domain
++ * http://www.opengroup.org/onlinepubs/007904975/functions/wcwidth.html
++ * http://www.opengroup.org/onlinepubs/007904975/functions/wcswidth.html
++ *
++ * In fixed-width output devices, Latin characters all occupy a single
++ * "cell" position of equal width, whereas ideographic CJK characters
++ * occupy two such cells. Interoperability between terminal-line
++ * applications and (teletype-style) character terminals using the
++ * UTF-8 encoding requires agreement on which character should advance
++ * the cursor by how many cell positions. No established formal
++ * standards exist at present on which Unicode character shall occupy
++ * how many cell positions on character terminals. These routines are
++ * a first attempt of defining such behavior based on simple rules
++ * applied to data provided by the Unicode Consortium.
++ *
++ * For some graphical characters, the Unicode standard explicitly
++ * defines a character-cell width via the definition of the East Asian
++ * FullWidth (F), Wide (W), Half-width (H), and Narrow (Na) classes.
++ * In all these cases, there is no ambiguity about which width a
++ * terminal shall use. For characters in the East Asian Ambiguous (A)
++ * class, the width choice depends purely on a preference of backward
++ * compatibility with either historic CJK or Western practice.
++ * Choosing single-width for these characters is easy to justify as
++ * the appropriate long-term solution, as the CJK practice of
++ * displaying these characters as double-width comes from historic
++ * implementation simplicity (8-bit encoded characters were displayed
++ * single-width and 16-bit ones double-width, even for Greek,
++ * Cyrillic, etc.) and not any typographic considerations.
++ *
++ * Much less clear is the choice of width for the Not East Asian
++ * (Neutral) class. Existing practice does not dictate a width for any
++ * of these characters. It would nevertheless make sense
++ * typographically to allocate two character cells to characters such
++ * as for instance EM SPACE or VOLUME INTEGRAL, which cannot be
++ * represented adequately with a single-width glyph. The following
++ * routines at present merely assign a single-cell width to all
++ * neutral characters, in the interest of simplicity. This is not
++ * entirely satisfactory and should be reconsidered before
++ * establishing a formal standard in this area. At the moment, the
++ * decision which Not East Asian (Neutral) characters should be
++ * represented by double-width glyphs cannot yet be answered by
++ * applying a simple rule from the Unicode database content. Setting
++ * up a proper standard for the behavior of UTF-8 character terminals
++ * will require a careful analysis not only of each Unicode character,
++ * but also of each presentation form, something the author of these
++ * routines has avoided to do so far.
++ *
++ * http://www.unicode.org/unicode/reports/tr11/
++ *
++ * Markus Kuhn -- 2007-05-26 (Unicode 5.0)
++ *
++ * Permission to use, copy, modify, and distribute this software
++ * for any purpose and without fee is hereby granted. The author
++ * disclaims all warranties with regard to this software.
++ *
++ * Latest version: http://www.cl.cam.ac.uk/~mgk25/ucs/wcwidth.c
+ */
+
+ #ifdef __GO32__
+-/* DJGPP needs to include this before including wchar.h. */
+-# include <wctype.h>
++# include <wctype.h>
+ #endif
+
+ #include <wchar.h>
+
+ struct interval {
+- unsigned short first;
+- unsigned short last;
++ int first;
++ int last;
+ };
+
+ /* auxiliary function for binary search in interval table */
+@@ -39,7 +91,7 @@ static int bisearch(wchar_t ucs, const s
+ }
+
+
+-/* The following functions define the column width of an ISO 10646
++/* The following two functions define the column width of an ISO 10646
+ * character as follows:
+ *
+ * - The null character (U+0000) has a column width of 0.
+@@ -51,6 +103,8 @@ static int bisearch(wchar_t ucs, const s
+ * category code Mn or Me in the Unicode database) have a
+ * column width of 0.
+ *
++ * - SOFT HYPHEN (U+00AD) has a column width of 1.
++ *
+ * - Other format characters (general category code Cf in the Unicode
+ * database) and ZERO WIDTH SPACE (U+200B) have a column width of 0.
+ *
+@@ -58,7 +112,7 @@ static int bisearch(wchar_t ucs, const s
+ * have a column width of 0.
+ *
+ * - Spacing characters in the East Asian Wide (W) or East Asian
+- * FullWidth (F) category as defined in Unicode Technical
++ * Full-width (F) category as defined in Unicode Technical
+ * Report #11 have a column width of 2.
+ *
+ * - All remaining characters (including all printable
+@@ -69,44 +123,59 @@ static int bisearch(wchar_t ucs, const s
+ * in ISO 10646.
+ */
+
+-int wcwidth(wchar_t ucs)
++int mk_wcwidth(wchar_t ucs)
+ {
+ /* sorted list of non-overlapping intervals of non-spacing characters */
++ /* generated by "uniset +cat=Me +cat=Mn +cat=Cf -00AD +1160-11FF +200B c" */
+ static const struct interval combining[] = {
+- { 0x0300, 0x034E }, { 0x0360, 0x0362 }, { 0x0483, 0x0486 },
+- { 0x0488, 0x0489 }, { 0x0591, 0x05A1 }, { 0x05A3, 0x05B9 },
+- { 0x05BB, 0x05BD }, { 0x05BF, 0x05BF }, { 0x05C1, 0x05C2 },
+- { 0x05C4, 0x05C4 }, { 0x064B, 0x0655 }, { 0x0670, 0x0670 },
++ { 0x0300, 0x036F }, { 0x0483, 0x0486 }, { 0x0488, 0x0489 },
++ { 0x0591, 0x05BD }, { 0x05BF, 0x05BF }, { 0x05C1, 0x05C2 },
++ { 0x05C4, 0x05C5 }, { 0x05C7, 0x05C7 }, { 0x0600, 0x0603 },
++ { 0x0610, 0x0615 }, { 0x064B, 0x065E }, { 0x0670, 0x0670 },
+ { 0x06D6, 0x06E4 }, { 0x06E7, 0x06E8 }, { 0x06EA, 0x06ED },
+ { 0x070F, 0x070F }, { 0x0711, 0x0711 }, { 0x0730, 0x074A },
+- { 0x07A6, 0x07B0 }, { 0x0901, 0x0902 }, { 0x093C, 0x093C },
+- { 0x0941, 0x0948 }, { 0x094D, 0x094D }, { 0x0951, 0x0954 },
+- { 0x0962, 0x0963 }, { 0x0981, 0x0981 }, { 0x09BC, 0x09BC },
+- { 0x09C1, 0x09C4 }, { 0x09CD, 0x09CD }, { 0x09E2, 0x09E3 },
+- { 0x0A02, 0x0A02 }, { 0x0A3C, 0x0A3C }, { 0x0A41, 0x0A42 },
+- { 0x0A47, 0x0A48 }, { 0x0A4B, 0x0A4D }, { 0x0A70, 0x0A71 },
+- { 0x0A81, 0x0A82 }, { 0x0ABC, 0x0ABC }, { 0x0AC1, 0x0AC5 },
+- { 0x0AC7, 0x0AC8 }, { 0x0ACD, 0x0ACD }, { 0x0B01, 0x0B01 },
+- { 0x0B3C, 0x0B3C }, { 0x0B3F, 0x0B3F }, { 0x0B41, 0x0B43 },
+- { 0x0B4D, 0x0B4D }, { 0x0B56, 0x0B56 }, { 0x0B82, 0x0B82 },
+- { 0x0BC0, 0x0BC0 }, { 0x0BCD, 0x0BCD }, { 0x0C3E, 0x0C40 },
+- { 0x0C46, 0x0C48 }, { 0x0C4A, 0x0C4D }, { 0x0C55, 0x0C56 },
++ { 0x07A6, 0x07B0 }, { 0x07EB, 0x07F3 }, { 0x0901, 0x0902 },
++ { 0x093C, 0x093C }, { 0x0941, 0x0948 }, { 0x094D, 0x094D },
++ { 0x0951, 0x0954 }, { 0x0962, 0x0963 }, { 0x0981, 0x0981 },
++ { 0x09BC, 0x09BC }, { 0x09C1, 0x09C4 }, { 0x09CD, 0x09CD },
++ { 0x09E2, 0x09E3 }, { 0x0A01, 0x0A02 }, { 0x0A3C, 0x0A3C },
++ { 0x0A41, 0x0A42 }, { 0x0A47, 0x0A48 }, { 0x0A4B, 0x0A4D },
++ { 0x0A70, 0x0A71 }, { 0x0A81, 0x0A82 }, { 0x0ABC, 0x0ABC },
++ { 0x0AC1, 0x0AC5 }, { 0x0AC7, 0x0AC8 }, { 0x0ACD, 0x0ACD },
++ { 0x0AE2, 0x0AE3 }, { 0x0B01, 0x0B01 }, { 0x0B3C, 0x0B3C },
++ { 0x0B3F, 0x0B3F }, { 0x0B41, 0x0B43 }, { 0x0B4D, 0x0B4D },
++ { 0x0B56, 0x0B56 }, { 0x0B82, 0x0B82 }, { 0x0BC0, 0x0BC0 },
++ { 0x0BCD, 0x0BCD }, { 0x0C3E, 0x0C40 }, { 0x0C46, 0x0C48 },
++ { 0x0C4A, 0x0C4D }, { 0x0C55, 0x0C56 }, { 0x0CBC, 0x0CBC },
+ { 0x0CBF, 0x0CBF }, { 0x0CC6, 0x0CC6 }, { 0x0CCC, 0x0CCD },
+- { 0x0D41, 0x0D43 }, { 0x0D4D, 0x0D4D }, { 0x0DCA, 0x0DCA },
+- { 0x0DD2, 0x0DD4 }, { 0x0DD6, 0x0DD6 }, { 0x0E31, 0x0E31 },
+- { 0x0E34, 0x0E3A }, { 0x0E47, 0x0E4E }, { 0x0EB1, 0x0EB1 },
+- { 0x0EB4, 0x0EB9 }, { 0x0EBB, 0x0EBC }, { 0x0EC8, 0x0ECD },
+- { 0x0F18, 0x0F19 }, { 0x0F35, 0x0F35 }, { 0x0F37, 0x0F37 },
+- { 0x0F39, 0x0F39 }, { 0x0F71, 0x0F7E }, { 0x0F80, 0x0F84 },
+- { 0x0F86, 0x0F87 }, { 0x0F90, 0x0F97 }, { 0x0F99, 0x0FBC },
+- { 0x0FC6, 0x0FC6 }, { 0x102D, 0x1030 }, { 0x1032, 0x1032 },
+- { 0x1036, 0x1037 }, { 0x1039, 0x1039 }, { 0x1058, 0x1059 },
+- { 0x1160, 0x11FF }, { 0x17B7, 0x17BD }, { 0x17C6, 0x17C6 },
+- { 0x17C9, 0x17D3 }, { 0x180B, 0x180E }, { 0x18A9, 0x18A9 },
+- { 0x200B, 0x200F }, { 0x202A, 0x202E }, { 0x206A, 0x206F },
+- { 0x20D0, 0x20E3 }, { 0x302A, 0x302F }, { 0x3099, 0x309A },
+- { 0xFB1E, 0xFB1E }, { 0xFE20, 0xFE23 }, { 0xFEFF, 0xFEFF },
+- { 0xFFF9, 0xFFFB }
++ { 0x0CE2, 0x0CE3 }, { 0x0D41, 0x0D43 }, { 0x0D4D, 0x0D4D },
++ { 0x0DCA, 0x0DCA }, { 0x0DD2, 0x0DD4 }, { 0x0DD6, 0x0DD6 },
++ { 0x0E31, 0x0E31 }, { 0x0E34, 0x0E3A }, { 0x0E47, 0x0E4E },
++ { 0x0EB1, 0x0EB1 }, { 0x0EB4, 0x0EB9 }, { 0x0EBB, 0x0EBC },
++ { 0x0EC8, 0x0ECD }, { 0x0F18, 0x0F19 }, { 0x0F35, 0x0F35 },
++ { 0x0F37, 0x0F37 }, { 0x0F39, 0x0F39 }, { 0x0F71, 0x0F7E },
++ { 0x0F80, 0x0F84 }, { 0x0F86, 0x0F87 }, { 0x0F90, 0x0F97 },
++ { 0x0F99, 0x0FBC }, { 0x0FC6, 0x0FC6 }, { 0x102D, 0x1030 },
++ { 0x1032, 0x1032 }, { 0x1036, 0x1037 }, { 0x1039, 0x1039 },
++ { 0x1058, 0x1059 }, { 0x1160, 0x11FF }, { 0x135F, 0x135F },
++ { 0x1712, 0x1714 }, { 0x1732, 0x1734 }, { 0x1752, 0x1753 },
++ { 0x1772, 0x1773 }, { 0x17B4, 0x17B5 }, { 0x17B7, 0x17BD },
++ { 0x17C6, 0x17C6 }, { 0x17C9, 0x17D3 }, { 0x17DD, 0x17DD },
++ { 0x180B, 0x180D }, { 0x18A9, 0x18A9 }, { 0x1920, 0x1922 },
++ { 0x1927, 0x1928 }, { 0x1932, 0x1932 }, { 0x1939, 0x193B },
++ { 0x1A17, 0x1A18 }, { 0x1B00, 0x1B03 }, { 0x1B34, 0x1B34 },
++ { 0x1B36, 0x1B3A }, { 0x1B3C, 0x1B3C }, { 0x1B42, 0x1B42 },
++ { 0x1B6B, 0x1B73 }, { 0x1DC0, 0x1DCA }, { 0x1DFE, 0x1DFF },
++ { 0x200B, 0x200F }, { 0x202A, 0x202E }, { 0x2060, 0x2063 },
++ { 0x206A, 0x206F }, { 0x20D0, 0x20EF }, { 0x302A, 0x302F },
++ { 0x3099, 0x309A }, { 0xA806, 0xA806 }, { 0xA80B, 0xA80B },
++ { 0xA825, 0xA826 }, { 0xFB1E, 0xFB1E }, { 0xFE00, 0xFE0F },
++ { 0xFE20, 0xFE23 }, { 0xFEFF, 0xFEFF }, { 0xFFF9, 0xFFFB },
++ { 0x10A01, 0x10A03 }, { 0x10A05, 0x10A06 }, { 0x10A0C, 0x10A0F },
++ { 0x10A38, 0x10A3A }, { 0x10A3F, 0x10A3F }, { 0x1D167, 0x1D169 },
++ { 0x1D173, 0x1D182 }, { 0x1D185, 0x1D18B }, { 0x1D1AA, 0x1D1AD },
++ { 0x1D242, 0x1D244 }, { 0xE0001, 0xE0001 }, { 0xE0020, 0xE007F },
++ { 0xE0100, 0xE01EF }
+ };
+
+ /* test for 8-bit control characters */
+@@ -125,23 +194,26 @@ int wcwidth(wchar_t ucs)
+ return 1 +
+ (ucs >= 0x1100 &&
+ (ucs <= 0x115f || /* Hangul Jamo init. consonants */
+- (ucs >= 0x2e80 && ucs <= 0xa4cf && (ucs & ~0x0011) != 0x300a &&
++ ucs == 0x2329 || ucs == 0x232a ||
++ (ucs >= 0x2e80 && ucs <= 0xa4cf &&
+ ucs != 0x303f) || /* CJK ... Yi */
+ (ucs >= 0xac00 && ucs <= 0xd7a3) || /* Hangul Syllables */
+ (ucs >= 0xf900 && ucs <= 0xfaff) || /* CJK Compatibility Ideographs */
++ (ucs >= 0xfe10 && ucs <= 0xfe19) || /* Vertical forms */
+ (ucs >= 0xfe30 && ucs <= 0xfe6f) || /* CJK Compatibility Forms */
+- (ucs >= 0xff00 && ucs <= 0xff5f) || /* Fullwidth Forms */
++ (ucs >= 0xff00 && ucs <= 0xff60) || /* Fullwidth Forms */
+ (ucs >= 0xffe0 && ucs <= 0xffe6) ||
+- (ucs >= 0x20000 && ucs <= 0x2ffff)));
++ (ucs >= 0x20000 && ucs <= 0x2fffd) ||
++ (ucs >= 0x30000 && ucs <= 0x3fffd)));
+ }
+
+
+-int wcswidth(const wchar_t *pwcs, size_t n)
++int mk_wcswidth(const wchar_t *pwcs, size_t n)
+ {
+ int w, width = 0;
+
+ for (;*pwcs && n-- > 0; pwcs++)
+- if ((w = wcwidth(*pwcs)) < 0)
++ if ((w = mk_wcwidth(*pwcs)) < 0)
+ return -1;
+ else
+ width += w;
+@@ -151,20 +223,21 @@ int wcswidth(const wchar_t *pwcs, size_t
+
+
+ /*
+- * The following function is the same as wcwidth(), except that
+- * spacing characters in the East Asian Ambiguous (A) category as
+- * defined in Unicode Technical Report #11 have a column width of 2.
+- * This experimental variant might be useful for users of CJK legacy
+- * encodings who want to migrate to UCS. It is not otherwise
+- * recommended for general use.
++ * The following functions are the same as mk_wcwidth() and
++ * mk_wcswidth(), except that spacing characters in the East Asian
++ * Ambiguous (A) category as defined in Unicode Technical Report #11
++ * have a column width of 2. This variant might be useful for users of
++ * CJK legacy encodings who want to migrate to UCS without changing
++ * the traditional terminal character-width behaviour. It is not
++ * otherwise recommended for general use.
+ */
+-static int wcwidth_cjk(wchar_t ucs)
++int mk_wcwidth_cjk(wchar_t ucs)
+ {
+ /* sorted list of non-overlapping intervals of East Asian Ambiguous
+- * characters */
++ * characters, generated by "uniset +WIDTH-A -cat=Me -cat=Mn -cat=Cf c" */
+ static const struct interval ambiguous[] = {
+ { 0x00A1, 0x00A1 }, { 0x00A4, 0x00A4 }, { 0x00A7, 0x00A8 },
+- { 0x00AA, 0x00AA }, { 0x00AD, 0x00AE }, { 0x00B0, 0x00B4 },
++ { 0x00AA, 0x00AA }, { 0x00AE, 0x00AE }, { 0x00B0, 0x00B4 },
+ { 0x00B6, 0x00BA }, { 0x00BC, 0x00BF }, { 0x00C6, 0x00C6 },
+ { 0x00D0, 0x00D0 }, { 0x00D7, 0x00D8 }, { 0x00DE, 0x00E1 },
+ { 0x00E6, 0x00E6 }, { 0x00E8, 0x00EA }, { 0x00EC, 0x00ED },
+@@ -180,42 +253,41 @@ static int wcwidth_cjk(wchar_t ucs)
+ { 0x01DC, 0x01DC }, { 0x0251, 0x0251 }, { 0x0261, 0x0261 },
+ { 0x02C4, 0x02C4 }, { 0x02C7, 0x02C7 }, { 0x02C9, 0x02CB },
+ { 0x02CD, 0x02CD }, { 0x02D0, 0x02D0 }, { 0x02D8, 0x02DB },
+- { 0x02DD, 0x02DD }, { 0x02DF, 0x02DF }, { 0x0300, 0x034E },
+- { 0x0360, 0x0362 }, { 0x0391, 0x03A1 }, { 0x03A3, 0x03A9 },
+- { 0x03B1, 0x03C1 }, { 0x03C3, 0x03C9 }, { 0x0401, 0x0401 },
+- { 0x0410, 0x044F }, { 0x0451, 0x0451 }, { 0x2010, 0x2010 },
+- { 0x2013, 0x2016 }, { 0x2018, 0x2019 }, { 0x201C, 0x201D },
+- { 0x2020, 0x2022 }, { 0x2024, 0x2027 }, { 0x2030, 0x2030 },
+- { 0x2032, 0x2033 }, { 0x2035, 0x2035 }, { 0x203B, 0x203B },
+- { 0x203E, 0x203E }, { 0x2074, 0x2074 }, { 0x207F, 0x207F },
+- { 0x2081, 0x2084 }, { 0x20AC, 0x20AC }, { 0x2103, 0x2103 },
+- { 0x2105, 0x2105 }, { 0x2109, 0x2109 }, { 0x2113, 0x2113 },
+- { 0x2116, 0x2116 }, { 0x2121, 0x2122 }, { 0x2126, 0x2126 },
+- { 0x212B, 0x212B }, { 0x2153, 0x2155 }, { 0x215B, 0x215E },
+- { 0x2160, 0x216B }, { 0x2170, 0x2179 }, { 0x2190, 0x2199 },
+- { 0x21B8, 0x21B9 }, { 0x21D2, 0x21D2 }, { 0x21D4, 0x21D4 },
+- { 0x21E7, 0x21E7 }, { 0x2200, 0x2200 }, { 0x2202, 0x2203 },
+- { 0x2207, 0x2208 }, { 0x220B, 0x220B }, { 0x220F, 0x220F },
+- { 0x2211, 0x2211 }, { 0x2215, 0x2215 }, { 0x221A, 0x221A },
+- { 0x221D, 0x2220 }, { 0x2223, 0x2223 }, { 0x2225, 0x2225 },
+- { 0x2227, 0x222C }, { 0x222E, 0x222E }, { 0x2234, 0x2237 },
+- { 0x223C, 0x223D }, { 0x2248, 0x2248 }, { 0x224C, 0x224C },
+- { 0x2252, 0x2252 }, { 0x2260, 0x2261 }, { 0x2264, 0x2267 },
+- { 0x226A, 0x226B }, { 0x226E, 0x226F }, { 0x2282, 0x2283 },
+- { 0x2286, 0x2287 }, { 0x2295, 0x2295 }, { 0x2299, 0x2299 },
+- { 0x22A5, 0x22A5 }, { 0x22BF, 0x22BF }, { 0x2312, 0x2312 },
+- { 0x2329, 0x232A }, { 0x2460, 0x24BF }, { 0x24D0, 0x24E9 },
+- { 0x2500, 0x254B }, { 0x2550, 0x2574 }, { 0x2580, 0x258F },
+- { 0x2592, 0x2595 }, { 0x25A0, 0x25A1 }, { 0x25A3, 0x25A9 },
+- { 0x25B2, 0x25B3 }, { 0x25B6, 0x25B7 }, { 0x25BC, 0x25BD },
+- { 0x25C0, 0x25C1 }, { 0x25C6, 0x25C8 }, { 0x25CB, 0x25CB },
+- { 0x25CE, 0x25D1 }, { 0x25E2, 0x25E5 }, { 0x25EF, 0x25EF },
+- { 0x2605, 0x2606 }, { 0x2609, 0x2609 }, { 0x260E, 0x260F },
++ { 0x02DD, 0x02DD }, { 0x02DF, 0x02DF }, { 0x0391, 0x03A1 },
++ { 0x03A3, 0x03A9 }, { 0x03B1, 0x03C1 }, { 0x03C3, 0x03C9 },
++ { 0x0401, 0x0401 }, { 0x0410, 0x044F }, { 0x0451, 0x0451 },
++ { 0x2010, 0x2010 }, { 0x2013, 0x2016 }, { 0x2018, 0x2019 },
++ { 0x201C, 0x201D }, { 0x2020, 0x2022 }, { 0x2024, 0x2027 },
++ { 0x2030, 0x2030 }, { 0x2032, 0x2033 }, { 0x2035, 0x2035 },
++ { 0x203B, 0x203B }, { 0x203E, 0x203E }, { 0x2074, 0x2074 },
++ { 0x207F, 0x207F }, { 0x2081, 0x2084 }, { 0x20AC, 0x20AC },
++ { 0x2103, 0x2103 }, { 0x2105, 0x2105 }, { 0x2109, 0x2109 },
++ { 0x2113, 0x2113 }, { 0x2116, 0x2116 }, { 0x2121, 0x2122 },
++ { 0x2126, 0x2126 }, { 0x212B, 0x212B }, { 0x2153, 0x2154 },
++ { 0x215B, 0x215E }, { 0x2160, 0x216B }, { 0x2170, 0x2179 },
++ { 0x2190, 0x2199 }, { 0x21B8, 0x21B9 }, { 0x21D2, 0x21D2 },
++ { 0x21D4, 0x21D4 }, { 0x21E7, 0x21E7 }, { 0x2200, 0x2200 },
++ { 0x2202, 0x2203 }, { 0x2207, 0x2208 }, { 0x220B, 0x220B },
++ { 0x220F, 0x220F }, { 0x2211, 0x2211 }, { 0x2215, 0x2215 },
++ { 0x221A, 0x221A }, { 0x221D, 0x2220 }, { 0x2223, 0x2223 },
++ { 0x2225, 0x2225 }, { 0x2227, 0x222C }, { 0x222E, 0x222E },
++ { 0x2234, 0x2237 }, { 0x223C, 0x223D }, { 0x2248, 0x2248 },
++ { 0x224C, 0x224C }, { 0x2252, 0x2252 }, { 0x2260, 0x2261 },
++ { 0x2264, 0x2267 }, { 0x226A, 0x226B }, { 0x226E, 0x226F },
++ { 0x2282, 0x2283 }, { 0x2286, 0x2287 }, { 0x2295, 0x2295 },
++ { 0x2299, 0x2299 }, { 0x22A5, 0x22A5 }, { 0x22BF, 0x22BF },
++ { 0x2312, 0x2312 }, { 0x2460, 0x24E9 }, { 0x24EB, 0x254B },
++ { 0x2550, 0x2573 }, { 0x2580, 0x258F }, { 0x2592, 0x2595 },
++ { 0x25A0, 0x25A1 }, { 0x25A3, 0x25A9 }, { 0x25B2, 0x25B3 },
++ { 0x25B6, 0x25B7 }, { 0x25BC, 0x25BD }, { 0x25C0, 0x25C1 },
++ { 0x25C6, 0x25C8 }, { 0x25CB, 0x25CB }, { 0x25CE, 0x25D1 },
++ { 0x25E2, 0x25E5 }, { 0x25EF, 0x25EF }, { 0x2605, 0x2606 },
++ { 0x2609, 0x2609 }, { 0x260E, 0x260F }, { 0x2614, 0x2615 },
+ { 0x261C, 0x261C }, { 0x261E, 0x261E }, { 0x2640, 0x2640 },
+ { 0x2642, 0x2642 }, { 0x2660, 0x2661 }, { 0x2663, 0x2665 },
+ { 0x2667, 0x266A }, { 0x266C, 0x266D }, { 0x266F, 0x266F },
+- { 0x273D, 0x273D }, { 0x3008, 0x300B }, { 0x3014, 0x3015 },
+- { 0x3018, 0x301B }, { 0xFFFD, 0xFFFD }
++ { 0x273D, 0x273D }, { 0x2776, 0x277F }, { 0xE000, 0xF8FF },
++ { 0xFFFD, 0xFFFD }, { 0xF0000, 0xFFFFD }, { 0x100000, 0x10FFFD }
+ };
+
+ /* binary search in table of non-spacing characters */
+@@ -223,16 +295,16 @@ static int wcwidth_cjk(wchar_t ucs)
+ sizeof(ambiguous) / sizeof(struct interval) - 1))
+ return 2;
+
+- return wcwidth(ucs);
++ return mk_wcwidth(ucs);
+ }
+
+
+-int wcswidth_cjk(const wchar_t *pwcs, size_t n)
++int mk_wcswidth_cjk(const wchar_t *pwcs, size_t n)
+ {
+ int w, width = 0;
+
+ for (;*pwcs && n-- > 0; pwcs++)
+- if ((w = wcwidth_cjk(*pwcs)) < 0)
++ if ((w = mk_wcwidth_cjk(*pwcs)) < 0)
+ return -1;
+ else
+ width += w;
+Index: gdb-7.2.90.20110703/readline/tcap.h
+===================================================================
+--- gdb-7.2.90.20110703.orig/readline/tcap.h 2011-07-03 10:40:53.000000000 +0200
++++ gdb-7.2.90.20110703/readline/tcap.h 2011-07-03 10:41:21.000000000 +0200
+@@ -1,25 +1,23 @@
+ /* tcap.h -- termcap library functions and variables. */
+
+-/* Copyright (C) 1996 Free Software Foundation, Inc.
++/* Copyright (C) 1996-2009 Free Software Foundation, Inc.
+
+- This file contains the Readline Library (the Library), a set of
+- routines for providing Emacs style line input to programs that ask
+- for it.
++ This file is part of the GNU Readline Library (Readline), a library
++ for reading lines of text with interactive input and history editing.
+
+- The Library is free software; you can redistribute it and/or modify
++ Readline is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+- the Free Software Foundation; either version 2, or (at your option)
+- any later version.
++ the Free Software Foundation, either version 3 of the License, or
++ (at your option) any later version.
+
+- The Library is distributed in the hope that it will be useful, but
+- WITHOUT ANY WARRANTY; without even the implied warranty of
+- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+- General Public License for more details.
+-
+- The GNU General Public License is often shipped with GNU software, and
+- is generally kept in a file called COPYING or LICENSE. If you do not
+- have a copy of the license, write to the Free Software Foundation,
+- 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
++ Readline 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 Readline. If not, see <http://www.gnu.org/licenses/>.
++*/
+
+ #if !defined (_RLTCAP_H_)
+ #define _RLTCAP_H_
+Index: gdb-7.2.90.20110703/readline/terminal.c
+===================================================================
+--- gdb-7.2.90.20110703.orig/readline/terminal.c 2011-07-03 10:40:53.000000000 +0200
++++ gdb-7.2.90.20110703/readline/terminal.c 2011-07-03 10:41:21.000000000 +0200
+@@ -1,24 +1,24 @@
+ /* terminal.c -- controlling the terminal with termcap. */
+
+-/* Copyright (C) 1996-2005 Free Software Foundation, Inc.
++/* Copyright (C) 1996-2009 Free Software Foundation, Inc.
+
+- This file is part of the GNU Readline Library, a library for
+- reading lines of text with interactive input and history editing.
++ This file is part of the GNU Readline Library (Readline), a library
++ for reading lines of text with interactive input and history editing.
+
+- The GNU Readline Library is free software; you can redistribute it
+- and/or modify it under the terms of the GNU General Public License
+- as published by the Free Software Foundation; either version 2, or
++ Readline 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.
+
+- The GNU Readline Library is distributed in the hope that it will be
+- useful, but WITHOUT ANY WARRANTY; without even the implied warranty
+- of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ Readline 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.
+
+- The GNU General Public License is often shipped with GNU software, and
+- is generally kept in a file called COPYING or LICENSE. If you do not
+- have a copy of the license, write to the Free Software Foundation,
+- 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
++ You should have received a copy of the GNU General Public License
++ along with Readline. If not, see <http://www.gnu.org/licenses/>.
++*/
++
+ #define READLINE_LIBRARY
+
+ #if defined (HAVE_CONFIG_H)
+@@ -71,6 +71,17 @@
+ #include "xmalloc.h"
+
+ #if defined (__MINGW32__)
++# include <windows.h>
++# include <wincon.h>
++
++static void _win_get_screensize PARAMS((int *, int *));
++#endif
++
++#if defined (__EMX__)
++static void _emx_get_screensize PARAMS((int *, int *));
++#endif
++
++#if defined (__MINGW32__)
+ # include <windows.h>
+ # include <wincon.h>
+ #endif
+@@ -78,7 +89,10 @@
+ #define CUSTOM_REDISPLAY_FUNC() (rl_redisplay_function != rl_redisplay)
+ #define CUSTOM_INPUT_FUNC() (rl_getc_function != rl_getc)
+
+-int rl_prefer_env_winsize;
++/* If the calling application sets this to a non-zero value, readline will
++ use the $LINES and $COLUMNS environment variables to set its idea of the
++ window size before interrogating the kernel. */
++int rl_prefer_env_winsize = 0;
+
+ /* **************************************************************** */
+ /* */
+@@ -93,12 +107,12 @@ static char *term_string_buffer = (char
+
+ static int tcap_initialized;
+
+-#if !defined (__linux__)
++#if !defined (__linux__) && !defined (NCURSES_VERSION)
+ # if defined (__EMX__) || defined (NEED_EXTERN_PC)
+ extern
+ # endif /* __EMX__ || NEED_EXTERN_PC */
+ char PC, *BC, *UP;
+-#endif /* __linux__ */
++#endif /* !__linux__ && !NCURSES_VERSION */
+
+ /* Some strings to control terminal actions. These are output by tputs (). */
+ char *_rl_term_clreol;
+@@ -122,9 +136,7 @@ char *_rl_term_IC;
+ char *_rl_term_dc;
+ char *_rl_term_DC;
+
+-#if defined (HACK_TERMCAP_MOTION)
+ char *_rl_term_forward_char;
+-#endif /* HACK_TERMCAP_MOTION */
+
+ /* How to go up a line. */
+ char *_rl_term_up;
+@@ -195,6 +207,26 @@ _emx_get_screensize (swp, shp)
+ }
+ #endif
+
++#if defined (__MINGW32__)
++static void
++_win_get_screensize (swp, shp)
++ int *swp, *shp;
++{
++ HANDLE hConOut;
++ CONSOLE_SCREEN_BUFFER_INFO scr;
++
++ hConOut = GetStdHandle (STD_OUTPUT_HANDLE);
++ if (hConOut != INVALID_HANDLE_VALUE)
++ {
++ if (GetConsoleScreenBufferInfo (hConOut, &scr))
++ {
++ *swp = scr.dwSize.X;
++ *shp = scr.srWindow.Bottom - scr.srWindow.Top + 1;
++ }
++ }
++}
++#endif
++
+ /* Get readline's idea of the screen size. TTY is a file descriptor open
+ to the terminal. If IGNORE_ENV is true, we do not pay attention to the
+ values of $LINES and $COLUMNS. The tests for TERM_STRING_BUFFER being
+@@ -233,7 +265,9 @@ _rl_get_screen_size (tty, ignore_env)
+ #endif
+
+ #if defined (__EMX__)
+- _emx_get_screensize (&_rl_screenwidth, &_rl_screenheight);
++ _emx_get_screensize (&wc, &wr);
++#elif defined (__MINGW32__)
++ _win_get_screensize (&wc, &wr);
+ #endif
+
+ if (ignore_env || rl_prefer_env_winsize == 0)
+@@ -347,24 +381,24 @@ rl_reset_screen_size ()
+ void
+ rl_resize_terminal ()
+ {
+- if (readline_echoing_p)
++ _rl_get_screen_size (fileno (rl_instream), 1);
++ if (_rl_echoing_p)
+ {
+- _rl_get_screen_size (fileno (rl_instream), 1);
+ if (CUSTOM_REDISPLAY_FUNC ())
+ rl_forced_update_display ();
+- else
++ else if (RL_ISSTATE(RL_STATE_REDISPLAYING) == 0)
+ _rl_redisplay_after_sigwinch ();
+ }
+ }
+
+ struct _tc_string {
+- const char *tc_var;
++ const char * const tc_var;
+ char **tc_value;
+ };
+
+ /* This should be kept sorted, just in case we decide to change the
+ search algorithm to something smarter. */
+-static struct _tc_string tc_strings[] =
++static const struct _tc_string tc_strings[] =
+ {
+ { "@7", &_rl_term_at7 },
+ { "DC", &_rl_term_DC },
+@@ -389,9 +423,7 @@ static struct _tc_string tc_strings[] =
+ { "le", &_rl_term_backspace },
+ { "mm", &_rl_term_mm },
+ { "mo", &_rl_term_mo },
+-#if defined (HACK_TERMCAP_MOTION)
+ { "nd", &_rl_term_forward_char },
+-#endif
+ { "pc", &_rl_term_pc },
+ { "up", &_rl_term_up },
+ { "vb", &_rl_visible_bell },
+@@ -505,9 +537,7 @@ _rl_init_terminal_io (terminal_name)
+ _rl_term_ks = _rl_term_ke = _rl_term_at7 = (char *)NULL;
+ _rl_term_mm = _rl_term_mo = (char *)NULL;
+ _rl_term_ve = _rl_term_vs = (char *)NULL;
+-#if defined (HACK_TERMCAP_MOTION)
+- term_forward_char = (char *)NULL;
+-#endif
++ _rl_term_forward_char = (char *)NULL;
+ _rl_terminal_can_insert = term_has_meta = 0;
+
+ /* Reasonable defaults for tgoto(). Readline currently only uses
+@@ -546,8 +576,8 @@ _rl_init_terminal_io (terminal_name)
+
+ /* Check to see if this terminal has a meta key and clear the capability
+ variables if there is none. */
+- term_has_meta = (tgetflag ("km") || tgetflag ("MT"));
+- if (!term_has_meta)
++ term_has_meta = tgetflag ("km") != 0;
++ if (term_has_meta == 0)
+ _rl_term_mm = _rl_term_mo = (char *)NULL;
+
+ #endif /* !__MSDOS__ */
+@@ -663,10 +693,10 @@ _rl_backspace (count)
+ int
+ rl_crlf ()
+ {
+-#if defined (NEW_TTY_DRIVER)
++#if defined (NEW_TTY_DRIVER) || defined (__MINT__)
+ if (_rl_term_cr)
+ tputs (_rl_term_cr, 1, _rl_output_character_function);
+-#endif /* NEW_TTY_DRIVER */
++#endif /* NEW_TTY_DRIVER || __MINT__ */
+ putc ('\n', _rl_out_stream);
+ return 0;
+ }
+@@ -675,7 +705,7 @@ rl_crlf ()
+ int
+ rl_ding ()
+ {
+- if (readline_echoing_p)
++ if (_rl_echoing_p)
+ {
+ switch (_rl_bell_preference)
+ {
+Index: gdb-7.2.90.20110703/readline/text.c
+===================================================================
+--- gdb-7.2.90.20110703.orig/readline/text.c 2011-07-03 10:40:53.000000000 +0200
++++ gdb-7.2.90.20110703/readline/text.c 2011-07-03 10:41:21.000000000 +0200
+@@ -1,24 +1,24 @@
+ /* text.c -- text handling commands for readline. */
+
+-/* Copyright (C) 1987-2005 Free Software Foundation, Inc.
++/* Copyright (C) 1987-2010 Free Software Foundation, Inc.
+
+- This file is part of the GNU Readline Library, a library for
+- reading lines of text with interactive input and history editing.
++ This file is part of the GNU Readline Library (Readline), a library
++ for reading lines of text with interactive input and history editing.
+
+- The GNU Readline Library is free software; you can redistribute it
+- and/or modify it under the terms of the GNU General Public License
+- as published by the Free Software Foundation; either version 2, or
++ Readline 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.
+
+- The GNU Readline Library is distributed in the hope that it will be
+- useful, but WITHOUT ANY WARRANTY; without even the implied warranty
+- of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ Readline 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.
+
+- The GNU General Public License is often shipped with GNU software, and
+- is generally kept in a file called COPYING or LICENSE. If you do not
+- have a copy of the license, write to the Free Software Foundation,
+- 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
++ You should have received a copy of the GNU General Public License
++ along with Readline. If not, see <http://www.gnu.org/licenses/>.
++*/
++
+ #define READLINE_LIBRARY
+
+ #if defined (HAVE_CONFIG_H)
+@@ -67,6 +67,10 @@ static int _rl_insert_next_callback PARA
+ static int _rl_char_search_callback PARAMS((_rl_callback_generic_arg *));
+ #endif
+
++/* The largest chunk of text that can be inserted in one call to
++ rl_insert_text. Text blocks larger than this are divided. */
++#define TEXT_COUNT_MAX 1024
++
+ /* **************************************************************** */
+ /* */
+ /* Insert and Delete */
+@@ -146,7 +150,7 @@ rl_delete_text (from, to)
+ if (_rl_doing_an_undo == 0)
+ rl_add_undo (UNDO_DELETE, from, to, text);
+ else
+- free (text);
++ xfree (text);
+
+ rl_end -= diff;
+ rl_line_buffer[rl_end] = '\0';
+@@ -185,10 +189,13 @@ _rl_replace_text (text, start, end)
+ {
+ int n;
+
++ n = 0;
+ rl_begin_undo_group ();
+- rl_delete_text (start, end + 1);
++ if (start <= end)
++ rl_delete_text (start, end + 1);
+ rl_point = start;
+- n = rl_insert_text (text);
++ if (*text)
++ n = rl_insert_text (text);
+ rl_end_undo_group ();
+
+ return n;
+@@ -258,11 +265,13 @@ rl_forward_byte (count, key)
+
+ if (count > 0)
+ {
+- int end = rl_point + count;
++ int end, lend;
++
++ end = rl_point + count;
+ #if defined (VI_MODE)
+- int lend = rl_end > 0 ? rl_end - (rl_editing_mode == vi_mode) : rl_end;
++ lend = rl_end > 0 ? rl_end - (VI_COMMAND_MODE()) : rl_end;
+ #else
+- int lend = rl_end;
++ lend = rl_end;
+ #endif
+
+ if (end > lend)
+@@ -280,6 +289,31 @@ rl_forward_byte (count, key)
+ return 0;
+ }
+
++int
++_rl_forward_char_internal (count)
++ int count;
++{
++ int point;
++
++#if defined (HANDLE_MULTIBYTE)
++ point = _rl_find_next_mbchar (rl_line_buffer, rl_point, count, MB_FIND_NONZERO);
++
++#if defined (VI_MODE)
++ if (point >= rl_end && VI_COMMAND_MODE())
++ point = _rl_find_prev_mbchar (rl_line_buffer, rl_end, MB_FIND_NONZERO);
++#endif
++
++ if (rl_end < 0)
++ rl_end = 0;
++#else
++ point = rl_point + count;
++ if (point > rl_end)
++ point = rl_end;
++#endif
++
++ return (point);
++}
++
+ #if defined (HANDLE_MULTIBYTE)
+ /* Move forward COUNT characters. */
+ int
+@@ -296,20 +330,18 @@ rl_forward_char (count, key)
+
+ if (count > 0)
+ {
+- point = _rl_find_next_mbchar (rl_line_buffer, rl_point, count, MB_FIND_NONZERO);
++ if (rl_point == rl_end && EMACS_MODE())
++ {
++ rl_ding ();
++ return 0;
++ }
+
+-#if defined (VI_MODE)
+- if (rl_end <= point && rl_editing_mode == vi_mode)
+- point = _rl_find_prev_mbchar (rl_line_buffer, rl_end, MB_FIND_NONZERO);
+-#endif
++ point = _rl_forward_char_internal (count);
+
+ if (rl_point == point)
+ rl_ding ();
+
+ rl_point = point;
+-
+- if (rl_end < 0)
+- rl_end = 0;
+ }
+
+ return 0;
+@@ -565,6 +597,21 @@ rl_clear_screen (count, key)
+ }
+
+ int
++rl_skip_csi_sequence (count, key)
++ int count, key;
++{
++ int ch;
++
++ RL_SETSTATE (RL_STATE_MOREINPUT);
++ do
++ ch = rl_read_key ();
++ while (ch >= 0x20 && ch < 0x40);
++ RL_UNSETSTATE (RL_STATE_MOREINPUT);
++
++ return 0;
++}
++
++int
+ rl_arrow_keys (count, c)
+ int count, c;
+ {
+@@ -701,7 +748,7 @@ _rl_insert_char (count, c)
+
+ /* If we can optimize, then do it. But don't let people crash
+ readline because of extra large arguments. */
+- if (count > 1 && count <= 1024)
++ if (count > 1 && count <= TEXT_COUNT_MAX)
+ {
+ #if defined (HANDLE_MULTIBYTE)
+ string_size = count * incoming_length;
+@@ -724,16 +771,16 @@ _rl_insert_char (count, c)
+
+ string[i] = '\0';
+ rl_insert_text (string);
+- free (string);
++ xfree (string);
+
+ return 0;
+ }
+
+- if (count > 1024)
++ if (count > TEXT_COUNT_MAX)
+ {
+ int decreaser;
+ #if defined (HANDLE_MULTIBYTE)
+- string_size = incoming_length * 1024;
++ string_size = incoming_length * TEXT_COUNT_MAX;
+ string = (char *)xmalloc (1 + string_size);
+
+ i = 0;
+@@ -745,24 +792,24 @@ _rl_insert_char (count, c)
+
+ while (count)
+ {
+- decreaser = (count > 1024) ? 1024 : count;
++ decreaser = (count > TEXT_COUNT_MAX) ? TEXT_COUNT_MAX : count;
+ string[decreaser*incoming_length] = '\0';
+ rl_insert_text (string);
+ count -= decreaser;
+ }
+
+- free (string);
++ xfree (string);
+ incoming_length = 0;
+ stored_count = 0;
+ #else /* !HANDLE_MULTIBYTE */
+- char str[1024+1];
++ char str[TEXT_COUNT_MAX+1];
+
+- for (i = 0; i < 1024; i++)
++ for (i = 0; i < TEXT_COUNT_MAX; i++)
+ str[i] = c;
+
+ while (count)
+ {
+- decreaser = (count > 1024 ? 1024 : count);
++ decreaser = (count > TEXT_COUNT_MAX ? TEXT_COUNT_MAX : count);
+ str[decreaser] = '\0';
+ rl_insert_text (str);
+ count -= decreaser;
+@@ -777,8 +824,9 @@ _rl_insert_char (count, c)
+ /* We are inserting a single character.
+ If there is pending input, then make a string of all of the
+ pending characters that are bound to rl_insert, and insert
+- them all. */
+- if (_rl_any_typein ())
++ them all. Don't do this if we're current reading input from
++ a macro. */
++ if ((RL_ISSTATE (RL_STATE_MACROINPUT) == 0) && _rl_any_typein ())
+ _rl_insert_typein (c);
+ else
+ {
+@@ -857,6 +905,9 @@ _rl_insert_next (count)
+ c = rl_read_key ();
+ RL_UNSETSTATE(RL_STATE_MOREINPUT);
+
++ if (c < 0)
++ return -1;
++
+ #if defined (HANDLE_SIGNALS)
+ if (RL_ISSTATE (RL_STATE_CALLBACK) == 0)
+ _rl_restore_tty_signals ();
+@@ -940,7 +991,7 @@ rl_newline (count, key)
+ if (rl_erase_empty_line && rl_point == 0 && rl_end == 0)
+ return 0;
+
+- if (readline_echoing_p)
++ if (_rl_echoing_p)
+ _rl_update_final ();
+ return 0;
+ }
+@@ -1071,6 +1122,8 @@ int
+ rl_delete (count, key)
+ int count, key;
+ {
++ int xpoint;
++
+ if (count < 0)
+ return (_rl_rubout_char (-count, key));
+
+@@ -1082,21 +1135,19 @@ rl_delete (count, key)
+
+ if (count > 1 || rl_explicit_arg)
+ {
+- int orig_point = rl_point;
++ xpoint = rl_point;
+ if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
+ rl_forward_char (count, key);
+ else
+ rl_forward_byte (count, key);
+
+- rl_kill_text (orig_point, rl_point);
+- rl_point = orig_point;
++ rl_kill_text (xpoint, rl_point);
++ rl_point = xpoint;
+ }
+ else
+ {
+- int new_point;
+-
+- new_point = MB_NEXTCHAR (rl_line_buffer, rl_point, 1, MB_FIND_NONZERO);
+- rl_delete_text (rl_point, new_point);
++ xpoint = MB_NEXTCHAR (rl_line_buffer, rl_point, 1, MB_FIND_NONZERO);
++ rl_delete_text (rl_point, xpoint);
+ }
+ return 0;
+ }
+@@ -1120,7 +1171,7 @@ int
+ rl_delete_horizontal_space (count, ignore)
+ int count, ignore;
+ {
+- int start = rl_point;
++ int start;
+
+ while (rl_point && whitespace (rl_line_buffer[rl_point - 1]))
+ rl_point--;
+@@ -1237,8 +1288,9 @@ rl_change_case (count, op)
+ #if defined (HANDLE_MULTIBYTE)
+ wchar_t wc, nwc;
+ char mb[MB_LEN_MAX+1];
+- int mblen, p;
+- mbstate_t ps;
++ int mlen;
++ size_t m;
++ mbstate_t mps;
+ #endif
+
+ start = rl_point;
+@@ -1255,7 +1307,7 @@ rl_change_case (count, op)
+ SWAP (start, end);
+
+ #if defined (HANDLE_MULTIBYTE)
+- memset (&ps, 0, sizeof (mbstate_t));
++ memset (&mps, 0, sizeof (mbstate_t));
+ #endif
+
+ /* We are going to modify some text, so let's prepare to undo it. */
+@@ -1290,15 +1342,19 @@ rl_change_case (count, op)
+ #if defined (HANDLE_MULTIBYTE)
+ else
+ {
+- mbrtowc (&wc, rl_line_buffer + start, end - start, &ps);
++ m = mbrtowc (&wc, rl_line_buffer + start, end - start, &mps);
++ if (MB_INVALIDCH (m))
++ wc = (wchar_t)rl_line_buffer[start];
++ else if (MB_NULLWCH (m))
++ wc = L'\0';
+ nwc = (nop == UpCase) ? _rl_to_wupper (wc) : _rl_to_wlower (wc);
+ if (nwc != wc) /* just skip unchanged characters */
+ {
+- mblen = wcrtomb (mb, nwc, &ps);
+- if (mblen > 0)
+- mb[mblen] = '\0';
++ mlen = wcrtomb (mb, nwc, &mps);
++ if (mlen > 0)
++ mb[mlen] = '\0';
+ /* Assume the same width */
+- strncpy (rl_line_buffer + start, mb, mblen);
++ strncpy (rl_line_buffer + start, mb, mlen);
+ }
+ }
+ #endif
+@@ -1371,8 +1427,8 @@ rl_transpose_words (count, key)
+
+ /* I think that does it. */
+ rl_end_undo_group ();
+- free (word1);
+- free (word2);
++ xfree (word1);
++ xfree (word2);
+
+ return 0;
+ }
+@@ -1431,7 +1487,7 @@ rl_transpose_chars (count, key)
+ rl_end_undo_group ();
+
+ #if defined (HANDLE_MULTIBYTE)
+- free (dummy);
++ xfree (dummy);
+ #endif
+
+ return 0;
+@@ -1459,6 +1515,9 @@ _rl_char_search_internal (count, dir, sc
+ int prepos;
+ #endif
+
++ if (dir == 0)
++ return -1;
++
+ pos = rl_point;
+ inc = (dir < 0) ? -1 : 1;
+ while (count)
+@@ -1520,6 +1579,9 @@ _rl_char_search (count, fdir, bdir)
+
+ mb_len = _rl_read_mbchar (mbchar, MB_LEN_MAX);
+
++ if (mb_len <= 0)
++ return -1;
++
+ if (count < 0)
+ return (_rl_char_search_internal (-count, bdir, mbchar, mb_len));
+ else
+@@ -1536,6 +1598,9 @@ _rl_char_search (count, fdir, bdir)
+ c = rl_read_key ();
+ RL_UNSETSTATE(RL_STATE_MOREINPUT);
+
++ if (c < 0)
++ return -1;
++
+ if (count < 0)
+ return (_rl_char_search_internal (-count, bdir, c));
+ else
+Index: gdb-7.2.90.20110703/readline/tilde.c
+===================================================================
+--- gdb-7.2.90.20110703.orig/readline/tilde.c 2011-07-03 10:40:53.000000000 +0200
++++ gdb-7.2.90.20110703/readline/tilde.c 2011-07-03 10:41:21.000000000 +0200
+@@ -1,23 +1,23 @@
+ /* tilde.c -- Tilde expansion code (~/foo := $HOME/foo). */
+
+-/* Copyright (C) 1988,1989 Free Software Foundation, Inc.
++/* Copyright (C) 1988-2009 Free Software Foundation, Inc.
+
+- This file is part of GNU Readline, a library for reading lines
+- of text with interactive input and history editing.
++ This file is part of the GNU Readline Library (Readline), a library
++ for reading lines of text with interactive input and history editing.
+
+- Readline is free software; you can redistribute it and/or modify it
+- under the terms of the GNU General Public License as published by the
+- Free Software Foundation; either version 2, or (at your option) any
+- later version.
+-
+- Readline 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.
++ Readline 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.
++
++ Readline 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 Readline; see the file COPYING. If not, write to the Free
+- Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
++ along with Readline. If not, see <http://www.gnu.org/licenses/>.
++*/
+
+ #if defined (HAVE_CONFIG_H)
+ # include <config.h>
+@@ -236,7 +236,7 @@ tilde_expand (string)
+ string += end;
+
+ expansion = tilde_expand_word (tilde_word);
+- free (tilde_word);
++ xfree (tilde_word);
+
+ len = strlen (expansion);
+ #ifdef __CYGWIN__
+@@ -251,7 +251,7 @@ tilde_expand (string)
+ strcpy (result + result_index, expansion);
+ result_index += len;
+ }
+- free (expansion);
++ xfree (expansion);
+ }
+
+ result[result_index] = '\0';
+@@ -377,8 +377,8 @@ tilde_expand_word (filename)
+ if (expansion)
+ {
+ dirname = glue_prefix_and_suffix (expansion, filename, user_len);
+- free (username);
+- free (expansion);
++ xfree (username);
++ xfree (expansion);
+ return (dirname);
+ }
+ }
+@@ -401,10 +401,9 @@ tilde_expand_word (filename)
+ if (expansion)
+ {
+ dirname = glue_prefix_and_suffix (expansion, filename, user_len);
+- free (expansion);
++ xfree (expansion);
+ }
+ }
+- free (username);
+ /* If we don't have a failure hook, or if the failure hook did not
+ expand the tilde, return a copy of what we were passed. */
+ if (dirname == 0)
+@@ -412,10 +411,11 @@ tilde_expand_word (filename)
+ }
+ #if defined (HAVE_GETPWENT)
+ else
+- {
+- free (username);
+- dirname = glue_prefix_and_suffix (user_entry->pw_dir, filename, user_len);
+- }
++ dirname = glue_prefix_and_suffix (user_entry->pw_dir, filename, user_len);
++#endif
++
++ xfree (username);
++#if defined (HAVE_GETPWENT)
+ endpwent ();
+ #endif
+ return (dirname);
+Index: gdb-7.2.90.20110703/readline/tilde.h
+===================================================================
+--- gdb-7.2.90.20110703.orig/readline/tilde.h 2011-07-03 10:40:53.000000000 +0200
++++ gdb-7.2.90.20110703/readline/tilde.h 2011-07-03 10:41:21.000000000 +0200
+@@ -1,25 +1,24 @@
+ /* tilde.h: Externally available variables and function in libtilde.a. */
+
+-/* Copyright (C) 1992 Free Software Foundation, Inc.
++/* Copyright (C) 1992-2009 Free Software Foundation, Inc.
+
+- This file contains the Readline Library (the Library), a set of
++ This file contains the Readline Library (Readline), a set of
+ routines for providing Emacs style line input to programs that ask
+ for it.
+
+- The Library is free software; you can redistribute it and/or modify
++ Readline is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+- the Free Software Foundation; either version 2, or (at your option)
+- any later version.
++ the Free Software Foundation, either version 3 of the License, or
++ (at your option) any later version.
+
+- The Library is distributed in the hope that it will be useful, but
+- WITHOUT ANY WARRANTY; without even the implied warranty of
+- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+- General Public License for more details.
+-
+- The GNU General Public License is often shipped with GNU software, and
+- is generally kept in a file called COPYING or LICENSE. If you do not
+- have a copy of the license, write to the Free Software Foundation,
+- 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
++ Readline 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 Readline. If not, see <http://www.gnu.org/licenses/>.
++*/
+
+ #if !defined (_TILDE_H_)
+ # define _TILDE_H_
+Index: gdb-7.2.90.20110703/readline/undo.c
+===================================================================
+--- gdb-7.2.90.20110703.orig/readline/undo.c 2011-07-03 10:40:53.000000000 +0200
++++ gdb-7.2.90.20110703/readline/undo.c 2011-07-03 10:41:21.000000000 +0200
+@@ -1,25 +1,25 @@
+ /* readline.c -- a general facility for reading lines of input
+ with emacs style editing and completion. */
+
+-/* Copyright (C) 1987, 1989, 1992 Free Software Foundation, Inc.
++/* Copyright (C) 1987-2009 Free Software Foundation, Inc.
+
+- This file is part of the GNU Readline Library, a library for
+- reading lines of text with interactive input and history editing.
++ This file is part of the GNU Readline Library (Readline), a library
++ for reading lines of text with interactive input and history editing.
+
+- The GNU Readline Library is free software; you can redistribute it
+- and/or modify it under the terms of the GNU General Public License
+- as published by the Free Software Foundation; either version 2, or
++ Readline 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.
+
+- The GNU Readline Library is distributed in the hope that it will be
+- useful, but WITHOUT ANY WARRANTY; without even the implied warranty
+- of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ Readline 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.
+
+- The GNU General Public License is often shipped with GNU software, and
+- is generally kept in a file called COPYING or LICENSE. If you do not
+- have a copy of the license, write to the Free Software Foundation,
+- 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
++ You should have received a copy of the GNU General Public License
++ along with Readline. If not, see <http://www.gnu.org/licenses/>.
++*/
++
+ #define READLINE_LIBRARY
+
+ #if defined (HAVE_CONFIG_H)
+@@ -50,6 +50,8 @@
+ #include "rlprivate.h"
+ #include "xmalloc.h"
+
++extern void replace_history_data PARAMS((int, histdata_t *, histdata_t *));
++
+ /* Non-zero tells rl_delete_text and rl_insert_text to not add to
+ the undo list. */
+ int _rl_doing_an_undo = 0;
+@@ -66,19 +68,35 @@ UNDO_LIST *rl_undo_list = (UNDO_LIST *)N
+ /* */
+ /* **************************************************************** */
+
+-/* Remember how to undo something. Concatenate some undos if that
+- seems right. */
+-void
+-rl_add_undo (what, start, end, text)
++static UNDO_LIST *
++alloc_undo_entry (what, start, end, text)
+ enum undo_code what;
+ int start, end;
+ char *text;
+ {
+- UNDO_LIST *temp = (UNDO_LIST *)xmalloc (sizeof (UNDO_LIST));
++ UNDO_LIST *temp;
++
++ temp = (UNDO_LIST *)xmalloc (sizeof (UNDO_LIST));
+ temp->what = what;
+ temp->start = start;
+ temp->end = end;
+ temp->text = text;
++
++ temp->next = (UNDO_LIST *)NULL;
++ return temp;
++}
++
++/* Remember how to undo something. Concatenate some undos if that
++ seems right. */
++void
++rl_add_undo (what, start, end, text)
++ enum undo_code what;
++ int start, end;
++ char *text;
++{
++ UNDO_LIST *temp;
++
++ temp = alloc_undo_entry (what, start, end, text);
+ temp->next = rl_undo_list;
+ rl_undo_list = temp;
+ }
+@@ -87,17 +105,60 @@ rl_add_undo (what, start, end, text)
+ void
+ rl_free_undo_list ()
+ {
++ UNDO_LIST *release, *orig_list;
++
++ orig_list = rl_undo_list;
+ while (rl_undo_list)
+ {
+- UNDO_LIST *release = rl_undo_list;
++ release = rl_undo_list;
+ rl_undo_list = rl_undo_list->next;
+
+ if (release->what == UNDO_DELETE)
+- free (release->text);
++ xfree (release->text);
+
+- free (release);
++ xfree (release);
+ }
+ rl_undo_list = (UNDO_LIST *)NULL;
++ replace_history_data (-1, (histdata_t *)orig_list, (histdata_t *)NULL);
++}
++
++UNDO_LIST *
++_rl_copy_undo_entry (entry)
++ UNDO_LIST *entry;
++{
++ UNDO_LIST *new;
++
++ new = alloc_undo_entry (entry->what, entry->start, entry->end, (char *)NULL);
++ new->text = entry->text ? savestring (entry->text) : 0;
++ return new;
++}
++
++UNDO_LIST *
++_rl_copy_undo_list (head)
++ UNDO_LIST *head;
++{
++ UNDO_LIST *list, *new, *roving, *c;
++
++ if (head == 0)
++ return head;
++
++ list = head;
++ new = 0;
++ while (list)
++ {
++ c = _rl_copy_undo_entry (list);
++ if (new == 0)
++ roving = new = c;
++ else
++ {
++ roving->next = c;
++ roving = roving->next;
++ }
++ list = list->next;
++ }
++
++ roving->next = 0;
++ return new;
+ }
+
+ /* Undo the next thing in the list. Return 0 if there
+@@ -113,7 +174,7 @@ rl_do_undo ()
+ start = end = waiting_for_begin = 0;
+ do
+ {
+- if (!rl_undo_list)
++ if (rl_undo_list == 0)
+ return (0);
+
+ _rl_doing_an_undo = 1;
+@@ -133,7 +194,7 @@ rl_do_undo ()
+ case UNDO_DELETE:
+ rl_point = start;
+ rl_insert_text (rl_undo_list->text);
+- free (rl_undo_list->text);
++ xfree (rl_undo_list->text);
+ break;
+
+ /* Undoing inserts means deleting some text. */
+@@ -161,7 +222,9 @@ rl_do_undo ()
+
+ release = rl_undo_list;
+ rl_undo_list = rl_undo_list->next;
+- free (release);
++ replace_history_data (-1, (histdata_t *)release, (histdata_t *)rl_undo_list);
++
++ xfree (release);
+ }
+ while (waiting_for_begin);
+
+@@ -231,7 +294,7 @@ int
+ rl_revert_line (count, key)
+ int count, key;
+ {
+- if (!rl_undo_list)
++ if (rl_undo_list == 0)
+ rl_ding ();
+ else
+ {
+Index: gdb-7.2.90.20110703/readline/util.c
+===================================================================
+--- gdb-7.2.90.20110703.orig/readline/util.c 2011-07-03 10:40:53.000000000 +0200
++++ gdb-7.2.90.20110703/readline/util.c 2011-07-03 10:41:21.000000000 +0200
+@@ -1,24 +1,24 @@
+ /* util.c -- readline utility functions */
+
+-/* Copyright (C) 1987-2005 Free Software Foundation, Inc.
++/* Copyright (C) 1987-2010 Free Software Foundation, Inc.
+
+- This file is part of the GNU Readline Library, a library for
+- reading lines of text with interactive input and history editing.
++ This file is part of the GNU Readline Library (Readline), a library
++ for reading lines of text with interactive input and history editing.
+
+- The GNU Readline Library is free software; you can redistribute it
+- and/or modify it under the terms of the GNU General Public License
+- as published by the Free Software Foundation; either version 2, or
++ Readline 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.
+
+- The GNU Readline Library is distributed in the hope that it will be
+- useful, but WITHOUT ANY WARRANTY; without even the implied warranty
+- of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ Readline 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.
+
+- The GNU General Public License is often shipped with GNU software, and
+- is generally kept in a file called COPYING or LICENSE. If you do not
+- have a copy of the license, write to the Free Software Foundation,
+- 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
++ You should have received a copy of the GNU General Public License
++ along with Readline. If not, see <http://www.gnu.org/licenses/>.
++*/
++
+ #define READLINE_LIBRARY
+
+ #if defined (HAVE_CONFIG_H)
+@@ -66,7 +66,7 @@
+ in words, or 1 if it is. */
+
+ int _rl_allow_pathname_alphabetic_chars = 0;
+-static const char *pathname_alphabetic_chars = "/-_=~.#$";
++static const char * const pathname_alphabetic_chars = "/-_=~.#$";
+
+ int
+ rl_alphabetic (c)
+@@ -81,8 +81,7 @@ rl_alphabetic (c)
+
+ #if defined (HANDLE_MULTIBYTE)
+ int
+-_rl_walphabetic (wc)
+- wchar_t wc;
++_rl_walphabetic (wchar_t wc)
+ {
+ int c;
+
+@@ -109,7 +108,7 @@ _rl_abort_internal ()
+ _rl_pop_executing_macro ();
+
+ rl_last_func = (rl_command_func_t *)NULL;
+- longjmp (readline_top_level, 1);
++ longjmp (_rl_top_level, 1);
+ return (0);
+ }
+
+@@ -121,6 +120,13 @@ rl_abort (count, key)
+ }
+
+ int
++_rl_null_function (count, key)
++ int count, key;
++{
++ return 0;
++}
++
++int
+ rl_tty_status (count, key)
+ int count, key;
+ {
+@@ -185,6 +191,7 @@ rl_tilde_expand (ignore, key)
+ {
+ homedir = tilde_expand ("~");
+ _rl_replace_text (homedir, start, end);
++ xfree (homedir);
+ return (0);
+ }
+ else if (rl_line_buffer[start] != '~')
+@@ -212,14 +219,96 @@ rl_tilde_expand (ignore, key)
+ strncpy (temp, rl_line_buffer + start, len);
+ temp[len] = '\0';
+ homedir = tilde_expand (temp);
+- free (temp);
++ xfree (temp);
+
+ _rl_replace_text (homedir, start, end);
++ xfree (homedir);
+ }
+
+ return (0);
+ }
+
++#if defined (USE_VARARGS)
++void
++#if defined (PREFER_STDARG)
++_rl_ttymsg (const char *format, ...)
++#else
++_rl_ttymsg (va_alist)
++ va_dcl
++#endif
++{
++ va_list args;
++#if defined (PREFER_VARARGS)
++ char *format;
++#endif
++
++#if defined (PREFER_STDARG)
++ va_start (args, format);
++#else
++ va_start (args);
++ format = va_arg (args, char *);
++#endif
++
++ fprintf (stderr, "readline: ");
++ vfprintf (stderr, format, args);
++ fprintf (stderr, "\n");
++ fflush (stderr);
++
++ va_end (args);
++
++ rl_forced_update_display ();
++}
++
++void
++#if defined (PREFER_STDARG)
++_rl_errmsg (const char *format, ...)
++#else
++_rl_errmsg (va_alist)
++ va_dcl
++#endif
++{
++ va_list args;
++#if defined (PREFER_VARARGS)
++ char *format;
++#endif
++
++#if defined (PREFER_STDARG)
++ va_start (args, format);
++#else
++ va_start (args);
++ format = va_arg (args, char *);
++#endif
++
++ fprintf (stderr, "readline: ");
++ vfprintf (stderr, format, args);
++ fprintf (stderr, "\n");
++ fflush (stderr);
++
++ va_end (args);
++}
++
++#else /* !USE_VARARGS */
++void
++_rl_ttymsg (format, arg1, arg2)
++ char *format;
++{
++ fprintf (stderr, "readline: ");
++ fprintf (stderr, format, arg1, arg2);
++ fprintf (stderr, "\n");
++
++ rl_forced_update_display ();
++}
++
++void
++_rl_errmsg (format, arg1, arg2)
++ char *format;
++{
++ fprintf (stderr, "readline: ");
++ fprintf (stderr, format, arg1, arg2);
++ fprintf (stderr, "\n");
++}
++#endif /* !USE_VARARGS */
++
+ /* **************************************************************** */
+ /* */
+ /* String Utility Functions */
+@@ -277,41 +366,56 @@ _rl_strpbrk (string1, string2)
+
+ #if !defined (HAVE_STRCASECMP)
+ /* Compare at most COUNT characters from string1 to string2. Case
+- doesn't matter. */
++ doesn't matter (strncasecmp). */
+ int
+ _rl_strnicmp (string1, string2, count)
+ char *string1, *string2;
+ int count;
+ {
+- register char ch1, ch2;
++ register char *s1, *s2;
++ int d;
++
++ if (count <= 0 || (string1 == string2))
++ return 0;
+
+- while (count)
++ s1 = string1;
++ s2 = string2;
++ do
+ {
+- ch1 = *string1++;
+- ch2 = *string2++;
+- if (_rl_to_upper(ch1) == _rl_to_upper(ch2))
+- count--;
+- else
++ d = _rl_to_lower (*s1) - _rl_to_lower (*s2); /* XXX - cast to unsigned char? */
++ if (d != 0)
++ return d;
++ if (*s1++ == '\0')
+ break;
++ s2++;
+ }
+- return (count);
++ while (--count != 0)
++
++ return (0);
+ }
+
+-/* strcmp (), but caseless. */
++/* strcmp (), but caseless (strcasecmp). */
+ int
+ _rl_stricmp (string1, string2)
+ char *string1, *string2;
+ {
+- register char ch1, ch2;
++ register char *s1, *s2;
++ int d;
++
++ s1 = string1;
++ s2 = string2;
++
++ if (s1 == s2)
++ return 0;
+
+- while (*string1 && *string2)
++ while ((d = _rl_to_lower (*s1) - _rl_to_lower (*s2)) == 0)
+ {
+- ch1 = *string1++;
+- ch2 = *string2++;
+- if (_rl_to_upper(ch1) != _rl_to_upper(ch2))
+- return (1);
++ if (*s1++ == '\0')
++ return 0;
++ s2++;
+ }
+- return (*string1 - *string2);
++
++ return (d);
+ }
+ #endif /* !HAVE_STRCASECMP */
+
+@@ -344,6 +448,16 @@ FUNCTION_FOR_MACRO (_rl_to_lower)
+ FUNCTION_FOR_MACRO (_rl_to_upper)
+ FUNCTION_FOR_MACRO (_rl_uppercase_p)
+
++/* A convenience function, to force memory deallocation to be performed
++ by readline. DLLs on Windows apparently require this. */
++void
++rl_free (mem)
++ void *mem;
++{
++ if (mem)
++ free (mem);
++}
++
+ /* Backwards compatibility, now that savestring has been removed from
+ all `public' readline header files. */
+ #undef _rl_savestring
+@@ -353,3 +467,60 @@ _rl_savestring (s)
+ {
+ return (strcpy ((char *)xmalloc (1 + (int)strlen (s)), (s)));
+ }
++
++#if defined (USE_VARARGS)
++static FILE *_rl_tracefp;
++
++void
++#if defined (PREFER_STDARG)
++_rl_trace (const char *format, ...)
++#else
++_rl_trace (va_alist)
++ va_dcl
++#endif
++{
++ va_list args;
++#if defined (PREFER_VARARGS)
++ char *format;
++#endif
++
++#if defined (PREFER_STDARG)
++ va_start (args, format);
++#else
++ va_start (args);
++ format = va_arg (args, char *);
++#endif
++
++ if (_rl_tracefp == 0)
++ _rl_tropen ();
++ vfprintf (_rl_tracefp, format, args);
++ fprintf (_rl_tracefp, "\n");
++ fflush (_rl_tracefp);
++
++ va_end (args);
++}
++
++int
++_rl_tropen ()
++{
++ char fnbuf[128];
++
++ if (_rl_tracefp)
++ fclose (_rl_tracefp);
++ sprintf (fnbuf, "/var/tmp/rltrace.%ld", getpid());
++ unlink(fnbuf);
++ _rl_tracefp = fopen (fnbuf, "w+");
++ return _rl_tracefp != 0;
++}
++
++int
++_rl_trclose ()
++{
++ int r;
++
++ r = fclose (_rl_tracefp);
++ _rl_tracefp = 0;
++ return r;
++}
++
++#endif
+Index: gdb-7.2.90.20110703/readline/vi_keymap.c
+===================================================================
+--- gdb-7.2.90.20110703.orig/readline/vi_keymap.c 2011-07-03 10:40:53.000000000 +0200
++++ gdb-7.2.90.20110703/readline/vi_keymap.c 2011-07-03 10:41:21.000000000 +0200
+@@ -1,24 +1,23 @@
+ /* vi_keymap.c -- the keymap for vi_mode in readline (). */
+
+-/* Copyright (C) 1987, 1989, 1992 Free Software Foundation, Inc.
++/* Copyright (C) 1987-2009 Free Software Foundation, Inc.
+
+- This file is part of the GNU Readline Library, a library for
+- reading lines of text with interactive input and history editing.
++ This file is part of the GNU Readline Library (Readline), a library
++ for reading lines of text with interactive input and history editing.
+
+- The GNU Readline Library is free software; you can redistribute it
+- and/or modify it under the terms of the GNU General Public License
+- as published by the Free Software Foundation; either version 2, or
++ Readline 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.
+
+- The GNU Readline Library is distributed in the hope that it will be
+- useful, but WITHOUT ANY WARRANTY; without even the implied warranty
+- of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ Readline 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.
+
+- The GNU General Public License is often shipped with GNU software, and
+- is generally kept in a file called COPYING or LICENSE. If you do not
+- have a copy of the license, write to the Free Software Foundation,
+- 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
++ You should have received a copy of the GNU General Public License
++ along with Readline. If not, see <http://www.gnu.org/licenses/>.
++*/
+
+ #if !defined (BUFSIZ)
+ #include <stdio.h>
+@@ -151,7 +150,7 @@ KEYMAP_ENTRY_ARRAY vi_movement_keymap =
+ { ISFUNC, rl_vi_char_search }, /* f */
+ { ISFUNC, (rl_command_func_t *)0x0 }, /* g */
+ { ISFUNC, rl_backward_char }, /* h */
+- { ISFUNC, rl_vi_insertion_mode }, /* i */
++ { ISFUNC, rl_vi_insert_mode }, /* i */
+ { ISFUNC, rl_get_next_history }, /* j */
+ { ISFUNC, rl_get_previous_history }, /* k */
+ { ISFUNC, rl_forward_char }, /* l */
+@@ -327,9 +326,9 @@ KEYMAP_ENTRY_ARRAY vi_insertion_keymap =
+ { ISFUNC, rl_insert }, /* Control-k */
+ { ISFUNC, rl_insert }, /* Control-l */
+ { ISFUNC, rl_newline }, /* Control-m */
+- { ISFUNC, rl_insert }, /* Control-n */
++ { ISFUNC, rl_menu_complete}, /* Control-n */
+ { ISFUNC, rl_insert }, /* Control-o */
+- { ISFUNC, rl_insert }, /* Control-p */
++ { ISFUNC, rl_backward_menu_complete }, /* Control-p */
+ { ISFUNC, rl_insert }, /* Control-q */
+ { ISFUNC, rl_reverse_search_history }, /* Control-r */
+ { ISFUNC, rl_forward_search_history }, /* Control-s */
+Index: gdb-7.2.90.20110703/readline/vi_mode.c
+===================================================================
+--- gdb-7.2.90.20110703.orig/readline/vi_mode.c 2011-07-03 10:40:53.000000000 +0200
++++ gdb-7.2.90.20110703/readline/vi_mode.c 2011-07-03 10:41:21.000000000 +0200
+@@ -1,25 +1,25 @@
+ /* vi_mode.c -- A vi emulation mode for Bash.
+ Derived from code written by Jeff Sparkes (jsparkes@bnr.ca). */
+
+-/* Copyright (C) 1987-2005 Free Software Foundation, Inc.
++/* Copyright (C) 1987-2010 Free Software Foundation, Inc.
+
+- This file is part of the GNU Readline Library, a library for
+- reading lines of text with interactive input and history editing.
++ This file is part of the GNU Readline Library (Readline), a library
++ for reading lines of text with interactive input and history editing.
+
+- The GNU Readline Library is free software; you can redistribute it
+- and/or modify it under the terms of the GNU General Public License
+- as published by the Free Software Foundation; either version 2, or
++ Readline 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.
+
+- The GNU Readline Library is distributed in the hope that it will be
+- useful, but WITHOUT ANY WARRANTY; without even the implied warranty
+- of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ Readline 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.
+
+- The GNU General Public License is often shipped with GNU software, and
+- is generally kept in a file called COPYING or LICENSE. If you do not
+- have a copy of the license, write to the Free Software Foundation,
+- 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
++ You should have received a copy of the GNU General Public License
++ along with Readline. If not, see <http://www.gnu.org/licenses/>.
++*/
++
+ #define READLINE_LIBRARY
+
+ /* **************************************************************** */
+@@ -65,11 +65,13 @@
+
+ int _rl_vi_last_command = 'i'; /* default `.' puts you in insert mode */
+
++_rl_vimotion_cxt *_rl_vimvcxt = 0;
++
+ /* Non-zero means enter insertion mode. */
+ static int _rl_vi_doing_insert;
+
+ /* Command keys which do movement for xxx_to commands. */
+-static const char *vi_motion = " hl^$0ftFT;,%wbeWBE|";
++static const char * const vi_motion = " hl^$0ftFT;,%wbeWBE|`";
+
+ /* Keymap used for vi replace characters. Created dynamically since
+ rarely used. */
+@@ -101,7 +103,7 @@ static int _rl_vi_last_key_before_insert
+ static int vi_redoing;
+
+ /* Text modification commands. These are the `redoable' commands. */
+-static const char *vi_textmod = "_*\\AaIiCcDdPpYyRrSsXx~";
++static const char * const vi_textmod = "_*\\AaIiCcDdPpYyRrSsXx~";
+
+ /* Arrays for the saved marks. */
+ static int vi_mark_chars['z' - 'a' + 1];
+@@ -109,12 +111,16 @@ static int vi_mark_chars['z' - 'a' + 1];
+ static void _rl_vi_stuff_insert PARAMS((int));
+ static void _rl_vi_save_insert PARAMS((UNDO_LIST *));
+
++static void _rl_vi_backup PARAMS((void));
++
+ static int _rl_vi_arg_dispatch PARAMS((int));
+ static int rl_digit_loop1 PARAMS((void));
+
+ static int _rl_vi_set_mark PARAMS((void));
+ static int _rl_vi_goto_mark PARAMS((void));
+
++static void _rl_vi_append_forward PARAMS((int));
++
+ static int _rl_vi_callback_getchar PARAMS((char *, int));
+
+ #if defined (READLINE_CALLBACKS)
+@@ -124,12 +130,23 @@ static int _rl_vi_callback_change_char P
+ static int _rl_vi_callback_char_search PARAMS((_rl_callback_generic_arg *));
+ #endif
+
++static int rl_domove_read_callback PARAMS((_rl_vimotion_cxt *));
++static int rl_domove_motion_callback PARAMS((_rl_vimotion_cxt *));
++static int rl_vi_domove_getchar PARAMS((_rl_vimotion_cxt *));
++
++static int vi_change_dispatch PARAMS((_rl_vimotion_cxt *));
++static int vi_delete_dispatch PARAMS((_rl_vimotion_cxt *));
++static int vi_yank_dispatch PARAMS((_rl_vimotion_cxt *));
++
++static int vidomove_dispatch PARAMS((_rl_vimotion_cxt *));
++
+ void
+ _rl_vi_initialize_line ()
+ {
+- register int i;
++ register int i, n;
+
+- for (i = 0; i < sizeof (vi_mark_chars) / sizeof (int); i++)
++ n = sizeof (vi_mark_chars) / sizeof (vi_mark_chars[0]);
++ for (i = 0; i < n; i++)
+ vi_mark_chars[i] = -1;
+
+ RL_UNSETSTATE(RL_STATE_VICMDONCE);
+@@ -205,7 +222,34 @@ rl_vi_redo (count, c)
+ _rl_vi_stuff_insert (count);
+ /* And back up point over the last character inserted. */
+ if (rl_point > 0)
+- rl_point--;
++ _rl_vi_backup ();
++ }
++ /* Ditto for redoing an insert with `I', but move to the beginning of the
++ line like the `I' command does. */
++ else if (_rl_vi_last_command == 'I' && vi_insert_buffer && *vi_insert_buffer)
++ {
++ rl_beg_of_line (1, 'I');
++ _rl_vi_stuff_insert (count);
++ if (rl_point > 0)
++ _rl_vi_backup ();
++ }
++ /* Ditto for redoing an insert with `a', but move forward a character first
++ like the `a' command does. */
++ else if (_rl_vi_last_command == 'a' && vi_insert_buffer && *vi_insert_buffer)
++ {
++ _rl_vi_append_forward ('a');
++ _rl_vi_stuff_insert (count);
++ if (rl_point > 0)
++ _rl_vi_backup ();
++ }
++ /* Ditto for redoing an insert with `A', but move to the end of the line
++ like the `A' command does. */
++ else if (_rl_vi_last_command == 'A' && vi_insert_buffer && *vi_insert_buffer)
++ {
++ rl_end_of_line (1, 'A');
++ _rl_vi_stuff_insert (count);
++ if (rl_point > 0)
++ _rl_vi_backup ();
+ }
+ else
+ r = _rl_dispatch (_rl_vi_last_command, _rl_keymap);
+@@ -571,27 +615,40 @@ rl_vi_insert_beg (count, key)
+ int count, key;
+ {
+ rl_beg_of_line (1, key);
+- rl_vi_insertion_mode (1, key);
++ rl_vi_insert_mode (1, key);
+ return (0);
+ }
+
+-int
+-rl_vi_append_mode (count, key)
+- int count, key;
++static void
++_rl_vi_append_forward (key)
++ int key;
+ {
++ int point;
++
+ if (rl_point < rl_end)
+ {
+ if (MB_CUR_MAX == 1 || rl_byte_oriented)
+ rl_point++;
+ else
+- {
+- int point = rl_point;
+- rl_forward_char (1, key);
+- if (point == rl_point)
+- rl_point = rl_end;
+- }
++ {
++ point = rl_point;
++#if 0
++ rl_forward_char (1, key);
++#else
++ rl_point = _rl_forward_char_internal (1);
++#endif
++ if (point == rl_point)
++ rl_point = rl_end;
++ }
+ }
+- rl_vi_insertion_mode (1, key);
++}
++
++int
++rl_vi_append_mode (count, key)
++ int count, key;
++{
++ _rl_vi_append_forward (key);
++ rl_vi_start_inserting (key, 1, rl_arg_sign);
+ return (0);
+ }
+
+@@ -625,13 +682,21 @@ rl_vi_insertion_mode (count, key)
+ return (0);
+ }
+
++int
++rl_vi_insert_mode (count, key)
++ int count, key;
++{
++ rl_vi_start_inserting (key, 1, rl_arg_sign);
++ return (0);
++}
++
+ static void
+ _rl_vi_save_insert (up)
+ UNDO_LIST *up;
+ {
+ int len, start, end;
+
+- if (up == 0)
++ if (up == 0 || up->what != UNDO_INSERT)
+ {
+ if (vi_insert_buffer_size >= 1)
+ vi_insert_buffer[0] = '\0';
+@@ -668,8 +733,11 @@ _rl_vi_done_inserting ()
+ }
+ else
+ {
+- if ((_rl_vi_last_key_before_insert == 'i' || _rl_vi_last_key_before_insert == 'a') && rl_undo_list)
+- _rl_vi_save_insert (rl_undo_list);
++ if (rl_undo_list && (_rl_vi_last_key_before_insert == 'i' ||
++ _rl_vi_last_key_before_insert == 'a' ||
++ _rl_vi_last_key_before_insert == 'I' ||
++ _rl_vi_last_key_before_insert == 'A'))
++ _rl_vi_save_insert (rl_undo_list);
+ /* XXX - Other keys probably need to be checked. */
+ else if (_rl_vi_last_key_before_insert == 'C')
+ rl_end_undo_group ();
+@@ -716,7 +784,8 @@ _rl_vi_change_mbchar_case (count)
+ {
+ wchar_t wc;
+ char mb[MB_LEN_MAX+1];
+- int mblen, p;
++ int mlen, p;
++ size_t m;
+ mbstate_t ps;
+
+ memset (&ps, 0, sizeof (mbstate_t));
+@@ -724,7 +793,11 @@ _rl_vi_change_mbchar_case (count)
+ count--;
+ while (count-- && rl_point < rl_end)
+ {
+- mbrtowc (&wc, rl_line_buffer + rl_point, rl_end - rl_point, &ps);
++ m = mbrtowc (&wc, rl_line_buffer + rl_point, rl_end - rl_point, &ps);
++ if (MB_INVALIDCH (m))
++ wc = (wchar_t)rl_line_buffer[rl_point];
++ else if (MB_NULLWCH (m))
++ wc = L'\0';
+ if (iswupper (wc))
+ wc = towlower (wc);
+ else if (iswlower (wc))
+@@ -740,9 +813,9 @@ _rl_vi_change_mbchar_case (count)
+ if (wc)
+ {
+ p = rl_point;
+- mblen = wcrtomb (mb, wc, &ps);
+- if (mblen >= 0)
+- mb[mblen] = '\0';
++ mlen = wcrtomb (mb, wc, &ps);
++ if (mlen >= 0)
++ mb[mlen] = '\0';
+ rl_begin_undo_group ();
+ rl_vi_delete (1, 0);
+ if (rl_point < p) /* Did we retreat at EOL? */
+@@ -752,7 +825,7 @@ _rl_vi_change_mbchar_case (count)
+ rl_vi_check ();
+ }
+ else
+- rl_forward_char (1, 0);
++ rl_forward_char (1, 0);
+ }
+
+ return 0;
+@@ -799,7 +872,7 @@ rl_vi_change_case (count, ignore)
+ _rl_insert_char (1, c);
+ rl_end_undo_group ();
+ rl_vi_check ();
+- }
++ }
+ else
+ rl_forward_char (1, c);
+ }
+@@ -820,6 +893,15 @@ rl_vi_put (count, key)
+ return (0);
+ }
+
++static void
++_rl_vi_backup ()
++{
++ if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
++ rl_point = _rl_find_prev_mbchar (rl_line_buffer, rl_point, MB_FIND_NONZERO);
++ else
++ rl_point--;
++}
++
+ int
+ rl_vi_check ()
+ {
+@@ -828,7 +910,7 @@ rl_vi_check ()
+ if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
+ rl_point = _rl_find_prev_mbchar (rl_line_buffer, rl_point, MB_FIND_NONZERO);
+ else
+- rl_point--;
++ rl_point--;
+ }
+ return (0);
+ }
+@@ -844,47 +926,106 @@ rl_vi_column (count, key)
+ return (0);
+ }
+
+-int
+-rl_vi_domove (key, nextkey)
+- int key, *nextkey;
++/* Process C as part of the current numeric argument. Return -1 if the
++ argument should be aborted, 0 if we should not read any more chars, and
++ 1 if we should continue to read chars. */
++static int
++_rl_vi_arg_dispatch (c)
++ int c;
+ {
+- int c, save;
+- int old_end;
++ int key;
+
+- rl_mark = rl_point;
+- RL_SETSTATE(RL_STATE_MOREINPUT);
+- c = rl_read_key ();
+- RL_UNSETSTATE(RL_STATE_MOREINPUT);
+- *nextkey = c;
++ key = c;
++ if (c >= 0 && _rl_keymap[c].type == ISFUNC && _rl_keymap[c].function == rl_universal_argument)
++ {
++ rl_numeric_arg *= 4;
++ return 1;
++ }
++
++ c = UNMETA (c);
+
+- if (!member (c, vi_motion))
++ if (_rl_digit_p (c))
+ {
+- if (_rl_digit_p (c))
+- {
+- save = rl_numeric_arg;
+- rl_numeric_arg = _rl_digit_value (c);
+- rl_explicit_arg = 1;
+- RL_SETSTATE (RL_STATE_NUMERICARG|RL_STATE_VIMOTION);
+- rl_digit_loop1 ();
+- RL_UNSETSTATE (RL_STATE_VIMOTION);
+- rl_numeric_arg *= save;
+- RL_SETSTATE(RL_STATE_MOREINPUT);
+- c = rl_read_key (); /* real command */
+- RL_UNSETSTATE(RL_STATE_MOREINPUT);
+- *nextkey = c;
+- }
+- else if (key == c && (key == 'd' || key == 'y' || key == 'c'))
+- {
+- rl_mark = rl_end;
+- rl_beg_of_line (1, c);
+- _rl_vi_last_motion = c;
+- return (0);
+- }
++ if (rl_explicit_arg)
++ rl_numeric_arg = (rl_numeric_arg * 10) + _rl_digit_value (c);
+ else
+- return (-1);
++ rl_numeric_arg = _rl_digit_value (c);
++ rl_explicit_arg = 1;
++ return 1; /* keep going */
+ }
++ else
++ {
++ rl_clear_message ();
++ rl_stuff_char (key);
++ return 0; /* done */
++ }
++}
++
++/* A simplified loop for vi. Don't dispatch key at end.
++ Don't recognize minus sign?
++ Should this do rl_save_prompt/rl_restore_prompt? */
++static int
++rl_digit_loop1 ()
++{
++ int c, r;
++
++ while (1)
++ {
++ if (_rl_arg_overflow ())
++ return 1;
++
++ c = _rl_arg_getchar ();
++
++ r = _rl_vi_arg_dispatch (c);
++ if (r <= 0)
++ break;
++ }
++
++ RL_UNSETSTATE(RL_STATE_NUMERICARG);
++ return (0);
++}
++
++static void
++_rl_mvcxt_init (m, op, key)
++ _rl_vimotion_cxt *m;
++ int op, key;
++{
++ m->op = op;
++ m->state = m->flags = 0;
++ m->ncxt = 0;
++ m->numeric_arg = -1;
++ m->start = rl_point;
++ m->end = rl_end;
++ m->key = key;
++ m->motion = -1;
++}
++
++static _rl_vimotion_cxt *
++_rl_mvcxt_alloc (op, key)
++ int op, key;
++{
++ _rl_vimotion_cxt *m;
++
++ m = xmalloc (sizeof (_rl_vimotion_cxt));
++ _rl_mvcxt_init (m, op, key);
++ return m;
++}
++
++static void
++_rl_mvcxt_dispose (m)
++ _rl_vimotion_cxt *m;
++{
++ xfree (m);
++}
+
+- _rl_vi_last_motion = c;
++static int
++rl_domove_motion_callback (m)
++ _rl_vimotion_cxt *m;
++{
++ int c, save, r;
++ int old_end;
++
++ _rl_vi_last_motion = c = m->motion;
+
+ /* Append a blank character temporarily so that the motion routines
+ work right at the end of the line. */
+@@ -913,7 +1054,7 @@ rl_vi_domove (key, nextkey)
+
+ /* If cw or cW, back up to the end of a word, so the behaviour of ce
+ or cE is the actual result. Brute-force, no subtlety. */
+- if (key == 'c' && rl_point >= rl_mark && (_rl_to_upper (c) == 'W'))
++ if (m->key == 'c' && rl_point >= rl_mark && (_rl_to_upper (c) == 'W'))
+ {
+ /* Don't move farther back than where we started. */
+ while (rl_point > rl_mark && whitespace (rl_line_buffer[rl_point]))
+@@ -922,7 +1063,7 @@ rl_vi_domove (key, nextkey)
+ /* Posix.2 says that if cw or cW moves the cursor towards the end of
+ the line, the character under the cursor should be deleted. */
+ if (rl_point == rl_mark)
+- rl_point++;
++ rl_point++;
+ else
+ {
+ /* Move past the end of the word so that the kill doesn't
+@@ -936,88 +1077,142 @@ rl_vi_domove (key, nextkey)
+ if (rl_mark < rl_point)
+ SWAP (rl_point, rl_mark);
+
+- return (0);
++#if defined (READLINE_CALLBACKS)
++ if (RL_ISSTATE (RL_STATE_CALLBACK))
++ (*rl_redisplay_function)(); /* make sure motion is displayed */
++#endif
++
++ r = vidomove_dispatch (m);
++
++ return (r);
+ }
+
+-/* Process C as part of the current numeric argument. Return -1 if the
+- argument should be aborted, 0 if we should not read any more chars, and
+- 1 if we should continue to read chars. */
++#define RL_VIMOVENUMARG() (RL_ISSTATE (RL_STATE_VIMOTION) && RL_ISSTATE (RL_STATE_NUMERICARG))
++
+ static int
+-_rl_vi_arg_dispatch (c)
+- int c;
++rl_domove_read_callback (m)
++ _rl_vimotion_cxt *m;
+ {
+- int key;
++ int c, save;
+
+- key = c;
+- if (c >= 0 && _rl_keymap[c].type == ISFUNC && _rl_keymap[c].function == rl_universal_argument)
++ c = m->motion;
++
++ if (member (c, vi_motion))
+ {
+- rl_numeric_arg *= 4;
+- return 1;
++#if defined (READLINE_CALLBACKS)
++ /* If we just read a vi-mode motion command numeric argument, turn off
++ the `reading numeric arg' state */
++ if (RL_ISSTATE (RL_STATE_CALLBACK) && RL_VIMOVENUMARG())
++ RL_UNSETSTATE (RL_STATE_NUMERICARG);
++#endif
++ /* Should do everything, including turning off RL_STATE_VIMOTION */
++ return (rl_domove_motion_callback (m));
++ }
++ else if (m->key == c && (m->key == 'd' || m->key == 'y' || m->key == 'c'))
++ {
++ rl_mark = rl_end;
++ rl_beg_of_line (1, c);
++ _rl_vi_last_motion = c;
++ RL_UNSETSTATE (RL_STATE_VIMOTION);
++ return (vidomove_dispatch (m));
+ }
+-
+- c = UNMETA (c);
+-
+- if (_rl_digit_p (c))
++#if defined (READLINE_CALLBACKS)
++ /* XXX - these need to handle rl_universal_argument bindings */
++ /* Reading vi motion char continuing numeric argument */
++ else if (_rl_digit_p (c) && RL_ISSTATE (RL_STATE_CALLBACK) && RL_VIMOVENUMARG())
+ {
+- if (rl_explicit_arg)
+- rl_numeric_arg = (rl_numeric_arg * 10) + _rl_digit_value (c);
+- else
+- rl_numeric_arg = _rl_digit_value (c);
++ return (_rl_vi_arg_dispatch (c));
++ }
++ /* Readine vi motion char starting numeric argument */
++ else if (_rl_digit_p (c) && RL_ISSTATE (RL_STATE_CALLBACK) && RL_ISSTATE (RL_STATE_VIMOTION) && (RL_ISSTATE (RL_STATE_NUMERICARG) == 0))
++ {
++ RL_SETSTATE (RL_STATE_NUMERICARG);
++ return (_rl_vi_arg_dispatch (c));
++ }
++#endif
++ else if (_rl_digit_p (c))
++ {
++ /* This code path taken when not in callback mode */
++ save = rl_numeric_arg;
++ rl_numeric_arg = _rl_digit_value (c);
+ rl_explicit_arg = 1;
+- return 1;
++ RL_SETSTATE (RL_STATE_NUMERICARG);
++ rl_digit_loop1 ();
++ rl_numeric_arg *= save;
++ c = rl_vi_domove_getchar (m);
++ if (c < 0)
++ {
++ m->motion = 0;
++ return -1;
++ }
++ m->motion = c;
++ return (rl_domove_motion_callback (m));
+ }
+ else
+ {
+- rl_clear_message ();
+- rl_stuff_char (key);
+- return 0;
++ RL_UNSETSTATE (RL_STATE_VIMOTION);
++ RL_UNSETSTATE (RL_STATE_NUMERICARG);
++ return (1);
+ }
+ }
+
+-/* A simplified loop for vi. Don't dispatch key at end.
+- Don't recognize minus sign?
+- Should this do rl_save_prompt/rl_restore_prompt? */
+ static int
+-rl_digit_loop1 ()
++rl_vi_domove_getchar (m)
++ _rl_vimotion_cxt *m;
+ {
+- int c, r;
++ int c;
+
+- while (1)
+- {
+- if (_rl_arg_overflow ())
+- return 1;
++ RL_SETSTATE(RL_STATE_MOREINPUT);
++ c = rl_read_key ();
++ RL_UNSETSTATE(RL_STATE_MOREINPUT);
+
+- c = _rl_arg_getchar ();
++ return c;
++}
+
+- r = _rl_vi_arg_dispatch (c);
+- if (r <= 0)
+- break;
+- }
++#if defined (READLINE_CALLBACKS)
++int
++_rl_vi_domove_callback (m)
++ _rl_vimotion_cxt *m;
++{
++ int c, r;
+
+- RL_UNSETSTATE(RL_STATE_NUMERICARG);
+- return (0);
++ m->motion = c = rl_vi_domove_getchar (m);
++ /* XXX - what to do if this returns -1? Should we return 1 for eof to
++ callback code? */
++ r = rl_domove_read_callback (m);
++
++ return ((r == 0) ? r : 1); /* normalize return values */
+ }
++#endif
+
++/* This code path taken when not in callback mode. */
+ int
+-rl_vi_delete_to (count, key)
+- int count, key;
++rl_vi_domove (x, ignore)
++ int x, *ignore;
+ {
+- int c;
++ int r;
++ _rl_vimotion_cxt *m;
+
+- if (_rl_uppercase_p (key))
+- rl_stuff_char ('$');
+- else if (vi_redoing)
+- rl_stuff_char (_rl_vi_last_motion);
++ m = _rl_vimvcxt;
++ *ignore = m->motion = rl_vi_domove_getchar (m);
+
+- if (rl_vi_domove (key, &c))
++ if (m->motion < 0)
+ {
+- rl_ding ();
++ m->motion = 0;
+ return -1;
+ }
+
++ return (rl_domove_read_callback (m));
++}
++
++static int
++vi_delete_dispatch (m)
++ _rl_vimotion_cxt *m;
++{
+ /* These are the motion commands that do not require adjusting the
+ mark. */
+- if ((strchr (" l|h^0bB", c) == 0) && (rl_mark < rl_end))
++ if (((strchr (" l|h^0bBFT`", m->motion) == 0) && (rl_point >= m->start)) &&
++ (rl_mark < rl_end))
+ rl_mark++;
+
+ rl_kill_text (rl_point, rl_mark);
+@@ -1025,33 +1220,61 @@ rl_vi_delete_to (count, key)
+ }
+
+ int
+-rl_vi_change_to (count, key)
++rl_vi_delete_to (count, key)
+ int count, key;
+ {
+- int c, start_pos;
++ int c, r;
+
++ _rl_vimvcxt = _rl_mvcxt_alloc (VIM_DELETE, key);
++ _rl_vimvcxt->start = rl_point;
++
++ rl_mark = rl_point;
+ if (_rl_uppercase_p (key))
+- rl_stuff_char ('$');
++ {
++ _rl_vimvcxt->motion = '$';
++ r = rl_domove_motion_callback (_rl_vimvcxt);
++ }
+ else if (vi_redoing)
+- rl_stuff_char (_rl_vi_last_motion);
+-
+- start_pos = rl_point;
++ {
++ _rl_vimvcxt->motion = _rl_vi_last_motion;
++ r = rl_domove_motion_callback (_rl_vimvcxt);
++ }
++#if defined (READLINE_CALLBACKS)
++ else if (RL_ISSTATE (RL_STATE_CALLBACK))
++ {
++ RL_SETSTATE (RL_STATE_VIMOTION);
++ return (0);
++ }
++#endif
++ else
++ r = rl_vi_domove (key, &c);
+
+- if (rl_vi_domove (key, &c))
++ if (r < 0)
+ {
+ rl_ding ();
+- return -1;
++ r = -1;
+ }
+
++ _rl_mvcxt_dispose (_rl_vimvcxt);
++ _rl_vimvcxt = 0;
++
++ return r;
++}
++
++static int
++vi_change_dispatch (m)
++ _rl_vimotion_cxt *m;
++{
+ /* These are the motion commands that do not require adjusting the
+ mark. c[wW] are handled by special-case code in rl_vi_domove(),
+ and already leave the mark at the correct location. */
+- if ((strchr (" l|hwW^0bB", c) == 0) && (rl_mark < rl_end))
++ if (((strchr (" l|hwW^0bBFT`", m->motion) == 0) && (rl_point >= m->start)) &&
++ (rl_mark < rl_end))
+ rl_mark++;
+
+ /* The cursor never moves with c[wW]. */
+- if ((_rl_to_upper (c) == 'W') && rl_point < start_pos)
+- rl_point = start_pos;
++ if ((_rl_to_upper (m->motion) == 'W') && rl_point < m->start)
++ rl_point = m->start;
+
+ if (vi_redoing)
+ {
+@@ -1069,49 +1292,145 @@ rl_vi_change_to (count, key)
+ rl_begin_undo_group (); /* to make the `u' command work */
+ rl_kill_text (rl_point, rl_mark);
+ /* `C' does not save the text inserted for undoing or redoing. */
+- if (_rl_uppercase_p (key) == 0)
+- _rl_vi_doing_insert = 1;
+- rl_vi_start_inserting (key, rl_numeric_arg, rl_arg_sign);
++ if (_rl_uppercase_p (m->key) == 0)
++ _rl_vi_doing_insert = 1;
++ /* XXX -- TODO -- use m->numericarg? */
++ rl_vi_start_inserting (m->key, rl_numeric_arg, rl_arg_sign);
+ }
+
+ return (0);
+ }
+
+ int
+-rl_vi_yank_to (count, key)
++rl_vi_change_to (count, key)
+ int count, key;
+ {
+- int c, save;
++ int c, r;
++
++ _rl_vimvcxt = _rl_mvcxt_alloc (VIM_CHANGE, key);
++ _rl_vimvcxt->start = rl_point;
+
+- save = rl_point;
++ rl_mark = rl_point;
+ if (_rl_uppercase_p (key))
+- rl_stuff_char ('$');
++ {
++ _rl_vimvcxt->motion = '$';
++ r = rl_domove_motion_callback (_rl_vimvcxt);
++ }
++ else if (vi_redoing)
++ {
++ _rl_vimvcxt->motion = _rl_vi_last_motion;
++ r = rl_domove_motion_callback (_rl_vimvcxt);
++ }
++#if defined (READLINE_CALLBACKS)
++ else if (RL_ISSTATE (RL_STATE_CALLBACK))
++ {
++ RL_SETSTATE (RL_STATE_VIMOTION);
++ return (0);
++ }
++#endif
++ else
++ r = rl_vi_domove (key, &c);
+
+- if (rl_vi_domove (key, &c))
++ if (r < 0)
+ {
+ rl_ding ();
+- return -1;
++ r = -1; /* normalize return value */
+ }
+
++ _rl_mvcxt_dispose (_rl_vimvcxt);
++ _rl_vimvcxt = 0;
++
++ return r;
++}
++
++static int
++vi_yank_dispatch (m)
++ _rl_vimotion_cxt *m;
++{
+ /* These are the motion commands that do not require adjusting the
+ mark. */
+- if ((strchr (" l|h^0%bB", c) == 0) && (rl_mark < rl_end))
++ if (((strchr (" l|h^0%bBFT`", m->motion) == 0) && (rl_point >= m->start)) &&
++ (rl_mark < rl_end))
+ rl_mark++;
+
+ rl_begin_undo_group ();
+ rl_kill_text (rl_point, rl_mark);
+ rl_end_undo_group ();
+ rl_do_undo ();
+- rl_point = save;
++ rl_point = m->start;
+
+ return (0);
+ }
+
+ int
++rl_vi_yank_to (count, key)
++ int count, key;
++{
++ int c, r;
++
++ _rl_vimvcxt = _rl_mvcxt_alloc (VIM_YANK, key);
++ _rl_vimvcxt->start = rl_point;
++
++ rl_mark = rl_point;
++ if (_rl_uppercase_p (key))
++ {
++ _rl_vimvcxt->motion = '$';
++ r = rl_domove_motion_callback (_rl_vimvcxt);
++ }
++#if defined (READLINE_CALLBACKS)
++ else if (RL_ISSTATE (RL_STATE_CALLBACK))
++ {
++ RL_SETSTATE (RL_STATE_VIMOTION);
++ return (0);
++ }
++#endif
++ else
++ r = rl_vi_domove (key, &c);
++
++ if (r < 0)
++ {
++ rl_ding ();
++ r = -1;
++ }
++
++ _rl_mvcxt_dispose (_rl_vimvcxt);
++ _rl_vimvcxt = 0;
++
++ return r;
++}
++
++static int
++vidomove_dispatch (m)
++ _rl_vimotion_cxt *m;
++{
++ int r;
++
++ switch (m->op)
++ {
++ case VIM_DELETE:
++ r = vi_delete_dispatch (m);
++ break;
++ case VIM_CHANGE:
++ r = vi_change_dispatch (m);
++ break;
++ case VIM_YANK:
++ r = vi_yank_dispatch (m);
++ break;
++ default:
++ _rl_errmsg ("vidomove_dispatch: unknown operator %d", m->op);
++ r = 1;
++ break;
++ }
++
++ RL_UNSETSTATE (RL_STATE_VIMOTION);
++ return r;
++}
++
++int
+ rl_vi_rubout (count, key)
+ int count, key;
+ {
+- int p, opoint;
++ int opoint;
+
+ if (count < 0)
+ return (rl_vi_delete (-count, key));
+@@ -1193,14 +1512,22 @@ static int
+ _rl_vi_callback_char_search (data)
+ _rl_callback_generic_arg *data;
+ {
++ int c;
+ #if defined (HANDLE_MULTIBYTE)
+- _rl_vi_last_search_mblen = _rl_read_mbchar (_rl_vi_last_search_mbchar, MB_LEN_MAX);
++ c = _rl_vi_last_search_mblen = _rl_read_mbchar (_rl_vi_last_search_mbchar, MB_LEN_MAX);
+ #else
+ RL_SETSTATE(RL_STATE_MOREINPUT);
+- _rl_vi_last_search_char = rl_read_key ();
++ c = rl_read_key ();
+ RL_UNSETSTATE(RL_STATE_MOREINPUT);
+ #endif
+
++ if (c <= 0)
++ return -1;
++
++#if !defined (HANDLE_MULTIBYTE)
++ _rl_vi_last_search_char = c;
++#endif
++
+ _rl_callback_func = 0;
+ _rl_want_redisplay = 1;
+
+@@ -1216,6 +1543,7 @@ int
+ rl_vi_char_search (count, key)
+ int count, key;
+ {
++ int c;
+ #if defined (HANDLE_MULTIBYTE)
+ static char *target;
+ static int tlen;
+@@ -1224,27 +1552,38 @@ rl_vi_char_search (count, key)
+ #endif
+
+ if (key == ';' || key == ',')
+- _rl_cs_dir = (key == ';') ? _rl_cs_orig_dir : -_rl_cs_orig_dir;
++ {
++ if (_rl_cs_orig_dir == 0)
++ return -1;
++#if defined (HANDLE_MULTIBYTE)
++ if (_rl_vi_last_search_mblen == 0)
++ return -1;
++#else
++ if (_rl_vi_last_search_char == 0)
++ return -1;
++#endif
++ _rl_cs_dir = (key == ';') ? _rl_cs_orig_dir : -_rl_cs_orig_dir;
++ }
+ else
+ {
+ switch (key)
+- {
+- case 't':
+- _rl_cs_orig_dir = _rl_cs_dir = FTO;
+- break;
+-
+- case 'T':
+- _rl_cs_orig_dir = _rl_cs_dir = BTO;
+- break;
+-
+- case 'f':
+- _rl_cs_orig_dir = _rl_cs_dir = FFIND;
+- break;
+-
+- case 'F':
+- _rl_cs_orig_dir = _rl_cs_dir = BFIND;
+- break;
+- }
++ {
++ case 't':
++ _rl_cs_orig_dir = _rl_cs_dir = FTO;
++ break;
++
++ case 'T':
++ _rl_cs_orig_dir = _rl_cs_dir = BTO;
++ break;
++
++ case 'f':
++ _rl_cs_orig_dir = _rl_cs_dir = FFIND;
++ break;
++
++ case 'F':
++ _rl_cs_orig_dir = _rl_cs_dir = BFIND;
++ break;
++ }
+
+ if (vi_redoing)
+ {
+@@ -1252,21 +1591,27 @@ rl_vi_char_search (count, key)
+ }
+ #if defined (READLINE_CALLBACKS)
+ else if (RL_ISSTATE (RL_STATE_CALLBACK))
+- {
+- _rl_callback_data = _rl_callback_data_alloc (count);
+- _rl_callback_data->i1 = _rl_cs_dir;
+- _rl_callback_func = _rl_vi_callback_char_search;
+- return (0);
+- }
++ {
++ _rl_callback_data = _rl_callback_data_alloc (count);
++ _rl_callback_data->i1 = _rl_cs_dir;
++ _rl_callback_func = _rl_vi_callback_char_search;
++ return (0);
++ }
+ #endif
+ else
+ {
+ #if defined (HANDLE_MULTIBYTE)
+- _rl_vi_last_search_mblen = _rl_read_mbchar (_rl_vi_last_search_mbchar, MB_LEN_MAX);
++ c = _rl_read_mbchar (_rl_vi_last_search_mbchar, MB_LEN_MAX);
++ if (c <= 0)
++ return -1;
++ _rl_vi_last_search_mblen = c;
+ #else
+ RL_SETSTATE(RL_STATE_MOREINPUT);
+- _rl_vi_last_search_char = rl_read_key ();
++ c = rl_read_key ();
+ RL_UNSETSTATE(RL_STATE_MOREINPUT);
++ if (c < 0)
++ return -1;
++ _rl_vi_last_search_char = c;
+ #endif
+ }
+ }
+@@ -1302,7 +1647,7 @@ rl_vi_match (ignore, key)
+ pre = rl_point;
+ rl_forward_char (1, key);
+ if (pre == rl_point)
+- break;
++ break;
+ }
+ }
+ else
+@@ -1331,7 +1676,7 @@ rl_vi_match (ignore, key)
+ {
+ pos = _rl_find_prev_mbchar (rl_line_buffer, pos, MB_FIND_ANY);
+ if (tmp == pos)
+- pos--;
++ pos--;
+ }
+ if (pos >= 0)
+ {
+@@ -1426,9 +1771,9 @@ _rl_vi_change_char (count, c, mb)
+ }
+
+ static int
+-_rl_vi_callback_getchar (mb, mblen)
++_rl_vi_callback_getchar (mb, mlen)
+ char *mb;
+- int mblen;
++ int mlen;
+ {
+ int c;
+
+@@ -1436,9 +1781,12 @@ _rl_vi_callback_getchar (mb, mblen)
+ c = rl_read_key ();
+ RL_UNSETSTATE(RL_STATE_MOREINPUT);
+
++ if (c < 0)
++ return -1;
++
+ #if defined (HANDLE_MULTIBYTE)
+ if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
+- c = _rl_read_mbstring (c, mb, mblen);
++ c = _rl_read_mbstring (c, mb, mlen);
+ #endif
+
+ return c;
+@@ -1454,6 +1802,9 @@ _rl_vi_callback_change_char (data)
+
+ _rl_vi_last_replacement = c = _rl_vi_callback_getchar (mb, MB_LEN_MAX);
+
++ if (c < 0)
++ return -1;
++
+ _rl_callback_func = 0;
+ _rl_want_redisplay = 1;
+
+@@ -1485,6 +1836,9 @@ rl_vi_change_char (count, key)
+ else
+ _rl_vi_last_replacement = c = _rl_vi_callback_getchar (mb, MB_LEN_MAX);
+
++ if (c < 0)
++ return -1;
++
+ return (_rl_vi_change_char (count, c, mb));
+ }
+
+@@ -1570,8 +1924,8 @@ rl_vi_replace (count, key)
+ vi_replace_map[NEWLINE].function = rl_newline;
+
+ /* If the normal vi insertion keymap has ^H bound to erase, do the
+- same here. Probably should remove the assignment to RUBOUT up
+- there, but I don't think it will make a difference in real life. */
++ same here. Probably should remove the assignment to RUBOUT up
++ there, but I don't think it will make a difference in real life. */
+ if (vi_insertion_keymap[CTRL ('H')].type == ISFUNC &&
+ vi_insertion_keymap[CTRL ('H')].function == rl_rubout)
+ vi_replace_map[CTRL ('H')].function = rl_vi_overstrike_delete;
+@@ -1619,7 +1973,7 @@ _rl_vi_set_mark ()
+ ch = rl_read_key ();
+ RL_UNSETSTATE(RL_STATE_MOREINPUT);
+
+- if (ch < 'a' || ch > 'z')
++ if (ch < 0 || ch < 'a' || ch > 'z') /* make test against 0 explicit */
+ {
+ rl_ding ();
+ return -1;
+@@ -1671,7 +2025,7 @@ _rl_vi_goto_mark ()
+ rl_point = rl_mark;
+ return 0;
+ }
+- else if (ch < 'a' || ch > 'z')
++ else if (ch < 0 || ch < 'a' || ch > 'z') /* make test against 0 explicit */
+ {
+ rl_ding ();
+ return -1;
+Index: gdb-7.2.90.20110703/readline/xfree.c
+===================================================================
+--- /dev/null 1970-01-01 00:00:00.000000000 +0000
++++ gdb-7.2.90.20110703/readline/xfree.c 2011-07-03 10:44:45.000000000 +0200
+@@ -0,0 +1,57 @@
++/* xfree.c -- safe version of free that ignores attempts to free NUL */
++
++/* Copyright (C) 1991-2010 Free Software Foundation, Inc.
++
++ This file is part of the GNU Readline Library (Readline), a library
++ for reading lines of text with interactive input and history editing.
++
++ Readline 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.
++
++ Readline 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 Readline. If not, see <http://www.gnu.org/licenses/>.
++*/
++
++#define READLINE_LIBRARY
++
++#if defined (HAVE_CONFIG_H)
++#include <config.h>
++#endif
++
++#if defined (HAVE_STDLIB_H)
++# include <stdlib.h>
++#else
++# include "ansi_stdlib.h"
++#endif /* HAVE_STDLIB_H */
++
++#include <stdio.h>
++
++#include "xmalloc.h"
++#include "readline.h"
++
++/* **************************************************************** */
++/* */
++/* Memory Deallocation. */
++/* */
++/* **************************************************************** */
++
++/* Use this as the function to call when adding unwind protects so we
++ don't need to know what free() returns. */
++void
++xfree (string)
++ PTR_T string;
++{
++ /* Leak a bit. */
++ if (RL_ISSTATE(RL_STATE_SIGHANDLER))
++ return;
++
++ if (string)
++ free (string);
++}
+Index: gdb-7.2.90.20110703/readline/xmalloc.c
+===================================================================
+--- gdb-7.2.90.20110703.orig/readline/xmalloc.c 2011-07-03 10:40:53.000000000 +0200
++++ gdb-7.2.90.20110703/readline/xmalloc.c 2011-07-03 10:43:54.000000000 +0200
+@@ -1,23 +1,24 @@
+ /* xmalloc.c -- safe versions of malloc and realloc */
+
+-/* Copyright (C) 1991 Free Software Foundation, Inc.
++/* Copyright (C) 1991-2009 Free Software Foundation, Inc.
+
+- This file is part of GNU Readline, a library for reading lines
+- of text with interactive input and history editing.
++ This file is part of the GNU Readline Library (Readline), a library
++ for reading lines of text with interactive input and history editing.
+
+- Readline is free software; you can redistribute it and/or modify it
+- under the terms of the GNU General Public License as published by the
+- Free Software Foundation; either version 2, or (at your option) any
+- later version.
+-
+- Readline 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.
++ Readline 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.
++
++ Readline 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 Readline; see the file COPYING. If not, write to the Free
+- Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
++ along with Readline. If not, see <http://www.gnu.org/licenses/>.
++*/
++
+ #define READLINE_LIBRARY
+
+ #if defined (HAVE_CONFIG_H)
+@@ -33,7 +34,6 @@
+ #endif /* HAVE_STDLIB_H */
+
+ #include "xmalloc.h"
+-#include "readline.h"
+
+ /* **************************************************************** */
+ /* */
+@@ -41,9 +41,6 @@
+ /* */
+ /* **************************************************************** */
+
+-/* xmalloc and xrealloc are provided by GDB. */
+-#if 0
+-
+ static void
+ memory_error_and_abort (fname)
+ char *fname;
+@@ -80,21 +77,3 @@ xrealloc (pointer, bytes)
+ memory_error_and_abort ("xrealloc");
+ return (temp);
+ }
+-
+-/* xmalloc and xrealloc are provided by GDB. */
+-#endif /* 0 */
+-
+-/* Use this as the function to call when adding unwind protects so we
+- don't need to know what free() returns. */
+-void
+-xfree (string)
+- PTR_T string;
+-{
+- /* Leak a bit. */
+- if (RL_ISSTATE(RL_STATE_SIGHANDLER))
+- return;
+-
+-#undef free
+- if (string)
+- free (string);
+-}
+Index: gdb-7.2.90.20110703/readline/xmalloc.h
+===================================================================
+--- gdb-7.2.90.20110703.orig/readline/xmalloc.h 2011-07-03 10:40:53.000000000 +0200
++++ gdb-7.2.90.20110703/readline/xmalloc.h 2011-07-03 10:41:21.000000000 +0200
+@@ -1,24 +1,23 @@
+ /* xmalloc.h -- memory allocation that aborts on errors. */
+
+-/* Copyright (C) 1999 Free Software Foundation, Inc.
++/* Copyright (C) 1999-2009 Free Software Foundation, Inc.
+
+- This file is part of the GNU Readline Library, a library for
+- reading lines of text with interactive input and history editing.
++ This file is part of the GNU Readline Library (Readline), a library
++ for reading lines of text with interactive input and history editing.
+
+- The GNU Readline Library is free software; you can redistribute it
+- and/or modify it under the terms of the GNU General Public License
+- as published by the Free Software Foundation; either version 2, or
++ Readline 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.
+
+- The GNU Readline Library is distributed in the hope that it will be
+- useful, but WITHOUT ANY WARRANTY; without even the implied warranty
+- of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ Readline 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.
+
+- The GNU General Public License is often shipped with GNU software, and
+- is generally kept in a file called COPYING or LICENSE. If you do not
+- have a copy of the license, write to the Free Software Foundation,
+- 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
++ You should have received a copy of the GNU General Public License
++ along with Readline. If not, see <http://www.gnu.org/licenses/>.
++*/
+
+ #if !defined (_XMALLOC_H_)
+ #define _XMALLOC_H_
+@@ -42,9 +41,6 @@
+ /* xmalloc and xrealloc should be also protected from RL_STATE_SIGHANDLER. */
+ #define xfree xfree_readline
+
+-/* readline-5.1 backport. */
+-#define free xfree
+-
+ extern PTR_T xmalloc PARAMS((size_t));
+ extern PTR_T xrealloc PARAMS((void *, size_t));
+ extern void xfree PARAMS((void *));
--- /dev/null
+http://sourceware.org/ml/gdb-patches/2011-05/msg00002.html
+Subject: [patch] testsuite: Test readline-6.2 "ask" regression
+
+Hi,
+
+this problem does not affect default FSF GDB build as it is using bundled
+readline-5.1. But with system readline-6.2 and build using:
+ --with-system-readline use installed readline library
+
+GDB will no longer ask about displaying too many symbols and dumps them all
+immediately.
+PASS:
+ $ gdb gdb
+ (gdb) p <tab><tab>
+ Display all 21482 possibilities? (y or n)_
+FAIL:
+ $ gdb gdb
+ (gdb) p <tab><tab>
+ Display all 22129 possibilities? (y or n)
+ ../../bfd/aout-target.h cs_to_section
+ ../../bfd/aout32.c ctime
+ <screens and screens of dumps without any question>
+
+This regression will soon start affecting distros:
+ FSF GDB HEAD - PASS - using bundled readline-5.1
+ fedora-15 - FAIL - using system readline-6.2
+ fedora-14 - PASS - using system readline-6.1
+ debian-6.0 - PASS - using system readline-6.1
+ kubuntu-10.10 - PASS - using system readline-6.1
+
+I have asked about it on readline ml:
+ Re: [Bug-readline] callback mode pager disable status
+ https://lists.gnu.org/archive/html/bug-readline/2011-04/msg00012.html
+The suggested workaround (in fact the readline-5.1 code state) going to patch
+into the proposed FSF GDB bundled readline-6.2. Distros then can stop using
+--with-system-readline to still feature recent and system matching readline
+until readline-7.0 gets released.
+
+This regression has been so far caught only with system debug infos installed:
+ -PASS: gdb.base/completion.exp: complete (2) 'p no_var_named_this-'
+ -PASS: gdb.base/completion.exp: complete 'p values[0].a'
+ -PASS: gdb.base/completion.exp: complete 'p values[0] . a'
+ -PASS: gdb.base/completion.exp: complete 'p &values[0] -> a'
+ -PASS: gdb.base/completion.exp: copmletion of field in anonymous union
+ +FAIL: gdb.base/completion.exp: (timeout) complete (2) 'p no_var_named_this-'
+ +FAIL: gdb.base/completion.exp: (timeout) complete 'p values[0].a' 2
+ +FAIL: gdb.base/completion.exp: (timeout) complete 'p values[0] . a' 2
+ +FAIL: gdb.base/completion.exp: (timeout) complete 'p &values[0] -> a' 2
+ +FAIL: gdb.base/completion.exp: copmletion of field in anonymous union
+
+I will check it in with no comments.
+
+
+Thanks,
+Jan
+
+
+gdb/testsuite/
+2011-05-01 Jan Kratochvil <jan.kratochvil@redhat.com>
+
+ * gdb.base/readline-ask.c: New file.
+ * gdb.base/readline-ask.exp: New file.
+ * gdb.base/readline-ask.inputrc: New file.
+
+--- /dev/null
++++ b/gdb/testsuite/gdb.base/readline-ask.c
+@@ -0,0 +1,23 @@
++/* This testcase is part of GDB, the GNU debugger.
++
++ Copyright 2011 Free Software Foundation, Inc.
++
++ This program is free software; you can redistribute it and/or modify
++ it under the terms of the GNU General Public License as published by
++ the Free Software Foundation; either version 3 of the License, or
++ (at your option) any later version.
++
++ This program is distributed in the hope that it will be useful,
++ but WITHOUT ANY WARRANTY; without even the implied warranty of
++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ GNU General Public License for more details.
++
++ You should have received a copy of the GNU General Public License
++ along with this program. If not, see <http://www.gnu.org/licenses/>. */
++
++int
++symbol_01_length_40_____________________,
++symbol_02_length_40_____________________,
++symbol_03_length_40_____________________,
++symbol_04_length_40_____________________,
++symbol_10_length_40_____________________;
+--- /dev/null
++++ b/gdb/testsuite/gdb.base/readline-ask.exp
+@@ -0,0 +1,118 @@
++# Copyright (C) 2011 Free Software Foundation, Inc.
++#
++# This program is free software; you can redistribute it and/or modify
++# it under the terms of the GNU General Public License as published by
++# the Free Software Foundation; either version 3 of the License, or
++# (at your option) any later version.
++#
++# This program is distributed in the hope that it will be useful,
++# but WITHOUT ANY WARRANTY; without even the implied warranty of
++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++# GNU General Public License for more details.
++#
++# You should have received a copy of the GNU General Public License
++# along with this program. If not, see <http://www.gnu.org/licenses/>.
++
++set testfile readline-ask
++set executable ${testfile}.x
++set srcfile ${testfile}.c
++set binfile ${objdir}/${subdir}/${executable}
++set inputrc ${srcdir}/${subdir}/${testfile}.inputrc
++
++if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" object {debug}] != "" } {
++ untested ${testfile}.exp
++ return -1
++}
++
++# INPUTRC gets reset for the next testfile.
++setenv INPUTRC $inputrc
++clean_restart ${executable}
++
++gdb_test_no_output "set width 50"
++gdb_test_no_output "set height 3"
++
++set cmd "p symbol_0"
++send_gdb "$cmd\t"
++set test "bell for more message"
++gdb_test_multiple "" $test {
++ -re "$cmd\007$" {
++ pass $test
++ }
++}
++
++send_gdb "\t"
++set test "more message for 01 and 02"
++gdb_test_multiple "" $test {
++ -re "^\r\nsymbol_01_length_40_____________________\r\nsymbol_02_length_40_____________________\r\n--More--$" {
++ pass $test
++ }
++ -re "$gdb_prompt " {
++ fail $test
++ }
++}
++
++# There get some VT100 characters printed.
++
++send_gdb "\r"
++set test "more message for 03"
++gdb_test_multiple "" $test {
++ -re "\rsymbol_03_length_40_____________________\r\n--More--$" {
++ pass $test
++ }
++}
++
++# "$gdb_prompt $" will not match as $cmd gets output: $gdb_prompt p symbol_0
++# And "$gdb_prompt p symbol_0" cannot be matched as the default "$gdb_prompt $"
++# string from gdb_test_multiple could match earlier.
++
++send_gdb "\r"
++set test "more finish for 04"
++gdb_test_multiple "" $test {
++ -re "\rsymbol_04_length_40_____________________\r\n$gdb_prompt " {
++ pass $test
++ }
++}
++
++gdb_test "foo" {No symbol "symbol_0foo" in current context\.} "abort more message"
++
++set cmd "p symbol_"
++send_gdb "$cmd\t"
++set test "bell for ask message"
++gdb_test_multiple "" $test {
++ -re "$cmd\007$" {
++ pass $test
++ }
++}
++
++send_gdb "\t"
++set test "ask message"
++gdb_test_multiple "" $test {
++ -re "^\r\nDisplay all 5 possibilities\\? \\(y or n\\)$" {
++ pass $test
++ }
++ -re "$gdb_prompt " {
++ fail $test
++ return 0
++ }
++}
++
++send_gdb "y"
++set test "ask message for 01 and 02"
++gdb_test_multiple "" $test {
++ -re "^\r\nsymbol_01_length_40_____________________\r\nsymbol_02_length_40_____________________\r\n--More--$" {
++ pass $test
++ }
++}
++
++# There get some VT100 characters printed.
++# See the "$gdb_prompt " match like in "more finish for 04".
++
++send_gdb "n"
++set test "ask message no"
++gdb_test_multiple "" $test {
++ -re "\r$gdb_prompt " {
++ pass $test
++ }
++}
++
++gdb_test "foo" {No symbol "symbol_foo" in current context\.} "abort ask message"
+--- /dev/null
++++ b/gdb/testsuite/gdb.base/readline-ask.inputrc
+@@ -0,0 +1,16 @@
++# Copyright (C) 2011 Free Software Foundation, Inc.
++#
++# This program is free software; you can redistribute it and/or modify
++# it under the terms of the GNU General Public License as published by
++# the Free Software Foundation; either version 3 of the License, or
++# (at your option) any later version.
++#
++# This program is distributed in the hope that it will be useful,
++# but WITHOUT ANY WARRANTY; without even the implied warranty of
++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++# GNU General Public License for more details.
++#
++# You should have received a copy of the GNU General Public License
++# along with this program. If not, see <http://www.gnu.org/licenses/>.
++
++set completion-query-items 5
+
--- /dev/null
+http://sourceware.org/ml/gdb-patches/2011-05/msg00010.html
+Subject: [patch 4/3] readline-6.2: Substitute inc-hist.texinfo
+
+Hi,
+
+forgot the patchset had a `make doc' regression:
+make: *** No rule to make target `../../../gdb/doc/../../readline/doc/inc-hist.texinfo', needed by `gdb.info'. Stop.
+
+There was a copy hsuser.texi -> inc-hist.texinfo before with this diff:
+ @@ -26,9 +26,9 @@ into another language, under the above c
+ @node Using History Interactively
+ @chapter Using History Interactively
+
+ -@ifclear BashFeatures
+ -@defcodeindex bt
+ -@end ifclear
+ +@c @ifclear BashFeatures
+ +@c @defcodeindex bt
+ +@c @end ifclear
+
+ @ifset BashFeatures
+ This chapter describes how to use the @sc{gnu} History Library
+ @@ -39,9 +39,9 @@ see the @sc{gnu} Readline Library Manual
+ @end ifset
+ @ifclear BashFeatures
+ This chapter describes how to use the @sc{gnu} History Library interactively,
+ -from a user's standpoint. It should be considered a user's guide. For
+ -information on using the @sc{gnu} History Library in your own programs,
+ -@pxref{Programming with GNU History}.
+ +from a user's standpoint. It should be considered a user's guide.
+ +For information on using the @sc{gnu} History Library in other programs,
+ +see the @sc{gnu} Readline Library Manual.
+ @end ifclear
+
+ @ifset BashFeatures
+
+Used slightly alternative one with IMO better reference and I have also kept
+hsuser.texi in place as readline/ in src/ is no longer a standalone readline
+distribution anyway.
+
+
+Sorry,
+Jan
+
+
+gdb/doc/
+2011-05-02 Jan Kratochvil <jan.kratochvil@redhat.com>
+
+ * Makefile.in (GDB_DOC_SOURCE_INCLUDES): Rename inc-hist.texinfo to
+ hsuser.texi.
+ * gdb.texinfo <!SYSTEM_READLINE>: Rename inc-hist.texinfo inclusion and
+ comment to hsuser.texi. Change rluser.texi name in the comment.
+
+readline/doc/
+2011-05-02 Jan Kratochvil <jan.kratochvil@redhat.com>
+
+ * hsuser.texi (Using History Interactively): Disable !BashFeatures
+ @defcodeindex. Make the `Programming with GNU History' reference
+ external.
+
+Index: gdb-7.2.90.20110525/gdb/doc/Makefile.in
+===================================================================
+--- gdb-7.2.90.20110525.orig/gdb/doc/Makefile.in 2011-01-03 14:01:05.000000000 +0100
++++ gdb-7.2.90.20110525/gdb/doc/Makefile.in 2011-05-25 19:16:35.000000000 +0200
+@@ -117,7 +117,7 @@ GDB_DOC_SOURCE_INCLUDES = \
+ $(srcdir)/gpl.texi \
+ $(srcdir)/agentexpr.texi \
+ $(READLINE_DIR)/rluser.texi \
+- $(READLINE_DIR)/inc-hist.texinfo
++ $(READLINE_DIR)/hsuser.texi
+ GDB_DOC_BUILD_INCLUDES = \
+ gdb-cfg.texi \
+ GDBvn.texi
+Index: gdb-7.2.90.20110525/gdb/doc/gdb.texinfo
+===================================================================
+--- gdb-7.2.90.20110525.orig/gdb/doc/gdb.texinfo 2011-05-25 19:14:36.000000000 +0200
++++ gdb-7.2.90.20110525/gdb/doc/gdb.texinfo 2011-05-25 19:17:01.000000000 +0200
+@@ -31095,13 +31095,13 @@ things without first using the debugger
+
+ @c The readline documentation is distributed with the readline code
+ @c and consists of the two following files:
+-@c rluser.texinfo
+-@c inc-hist.texinfo
++@c rluser.texi
++@c hsuser.texi
+ @c Use -I with makeinfo to point to the appropriate directory,
+ @c environment var TEXINPUTS with TeX.
+ @ifclear SYSTEM_READLINE
+ @include rluser.texi
+-@include inc-hist.texinfo
++@include hsuser.texi
+ @end ifclear
+
+ @node In Memoriam
+Index: gdb-7.2.90.20110525/readline/doc/hsuser.texi
+===================================================================
+--- gdb-7.2.90.20110525.orig/readline/doc/hsuser.texi 2011-05-25 19:16:17.000000000 +0200
++++ gdb-7.2.90.20110525/readline/doc/hsuser.texi 2011-05-25 19:16:35.000000000 +0200
+@@ -26,9 +26,10 @@ into another language, under the above c
+ @node Using History Interactively
+ @chapter Using History Interactively
+
+-@ifclear BashFeatures
+-@defcodeindex bt
+-@end ifclear
++@c GDB bundling modification:
++@c @ifclear BashFeatures
++@c @defcodeindex bt
++@c @end ifclear
+
+ @ifset BashFeatures
+ This chapter describes how to use the @sc{gnu} History Library
+@@ -41,7 +42,8 @@ see the @sc{gnu} Readline Library Manual
+ This chapter describes how to use the @sc{gnu} History Library interactively,
+ from a user's standpoint. It should be considered a user's guide. For
+ information on using the @sc{gnu} History Library in your own programs,
+-@pxref{Programming with GNU History}.
++@c GDB bundling modification:
++@pxref{Programming with GNU History, , , history, GNU History Library}.
+ @end ifclear
+
+ @ifset BashFeatures
--- /dev/null
+http://sourceware.org/ml/gdb-patches/2011-02/msg00679.html
+Subject: Re: [patch 1/3] Code cleanup: gdb.threads/gcore-thread.exp
+
+On Thu, 24 Feb 2011 08:20:09 +0100, Joel Brobecker wrote:
+> Just a thought: Do we really need to worry about restoring
+> the timeout at the end of the testcase, given that this is
+> automatically done at the start of each testcase (see gdb.exp:
+> gdb_init)?
+
+I see now:
+ Re: [RFA/testsuite] Reset the timeout duration at the start of each testcase.
+ http://sourceware.org/ml/gdb-patches/2010-02/msg00202.html
+ commit 501c57da40fd27c8036a5fc995f750b0559272ad
+
+Patch updated.
+
+
+Thanks,
+Jan
+
+
+gdb/testsuite/
+2011-02-24 Jan Kratochvil <jan.kratochvil@redhat.com>
+
+ * gdb.threads/gcore-thread.exp ($testfile): Match it the .exp
+ filename.
+ ($srcfile): Preserve the original value.
+ ($testfile): Match it the .exp filename.
+ ($corefile): New variable. Substitute it around.
+ Use clean_restart.
+ ($prev_timeout): Remove.
+ (load_core): Move core loading into this proc.
+ Fix restore of $timeout if load_core fails.
+
+--- a/gdb/testsuite/gdb.threads/gcore-thread.exp
++++ b/gdb/testsuite/gdb.threads/gcore-thread.exp
+@@ -21,11 +21,11 @@ if $tracelevel then {
+ strace $tracelevel
+ }
+
+-
+ # Single-threaded test case
+-set testfile "pthreads"
+-set srcfile ${testfile}.c
+-set binfile ${objdir}/${subdir}/gcore-${testfile}
++set testfile "gcore-thread"
++set srcfile pthreads.c
++set binfile ${objdir}/${subdir}/${testfile}
++set corefile ${objdir}/${subdir}/${testfile}.test
+
+ if [istarget "*-*-linux"] then {
+ set target_cflags "-D_MIT_POSIX_THREADS"
+@@ -41,10 +41,7 @@ if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executab
+
+ # Start with a fresh gdb.
+
+-gdb_exit
+-gdb_start
+-gdb_reinitialize_dir $srcdir/$subdir
+-gdb_load ${binfile}
++clean_restart ${testfile}
+
+ # regexp for "horizontal" text (i.e. doesn't include newline or
+ # carriage return)
+@@ -53,7 +50,6 @@ set horiz "\[^\n\r\]*"
+ # regexp for newline
+ set nl "\[\r\n\]+"
+
+-set prev_timeout $timeout
+ set timeout 30
+
+ gdb_test_multiple "help gcore" "help gcore" {
+@@ -92,10 +88,9 @@ delete_breakpoints
+ gdb_breakpoint "thread2"
+ gdb_test "continue" "Continuing.*Breakpoint.* thread2 .*" "thread 2 is running"
+
+-set escapedfilename [string_to_regexp ${objdir}/${subdir}/gcore.test]
++set escapedfilename [string_to_regexp $corefile]
+ # Drop corefile
+-gdb_test_multiple "gcore ${objdir}/${subdir}/gcore.test" \
+- "save a corefile" \
++gdb_test_multiple "gcore $corefile" "save a corefile" \
+ {
+ -re "Saved corefile ${escapedfilename}\[\r\n\]+$gdb_prompt $" {
+ pass "save a corefile"
+@@ -114,31 +109,38 @@ if {!$core_supported} {
+ return -1
+ }
+
++
+ # Now restart gdb and load the corefile.
+-gdb_exit
+-gdb_start
+-gdb_reinitialize_dir $srcdir/$subdir
+-gdb_load ${binfile}
+-
+-gdb_test_multiple "core ${objdir}/${subdir}/gcore.test" \
+- "re-load generated corefile" {
+- -re ".* is not a core dump:.*$gdb_prompt $" {
+- fail "re-load generated corefile (bad file format)"
+- # No use proceeding from here.
+- return;
+- }
+- -re ".*: No such file or directory.*$gdb_prompt $" {
+- fail "re-load generated corefile (file not found)"
+- # No use proceeding from here.
+- return;
+- }
+- -re ".*Couldn't find .* registers in core file.*$gdb_prompt $" {
+- fail "re-load generated corefile (incomplete note section)"
+- }
+- -re "Core was generated by .*$gdb_prompt $" {
+- pass "re-load generated corefile"
++clean_restart ${testfile}
++
++proc load_core { corefile } {
++ global gdb_prompt
++
++ gdb_test_multiple "core $corefile" \
++ "re-load generated corefile" {
++ -re " is not a core dump:.*\r\n$gdb_prompt $" {
++ fail "re-load generated corefile (bad file format)"
++ # No use proceeding from here.
++ return 0;
++ }
++ -re ": No such file or directory.*\r\n$gdb_prompt $" {
++ fail "re-load generated corefile (file not found)"
++ # No use proceeding from here.
++ return 0;
++ }
++ -re "Couldn't find .* registers in core file.*\r\n$gdb_prompt $" {
++ fail "re-load generated corefile (incomplete note section)"
++ }
++ -re "Core was generated by .*\r\n$gdb_prompt $" {
++ pass "re-load generated corefile"
++ }
+ }
+- }
++ return 1
++}
++
++if ![load_core $corefile] {
++ return
++}
+
+ # FIXME: now what can we test about the thread state?
+ # We do not know for certain that there should be at least
+@@ -158,5 +160,3 @@ gdb_test "info threads" ".* thread2 .*" \
+
+ gdb_test "info threads" ".*${nl}\\* ${horiz} thread2 .*" \
+ "thread2 is current thread in corefile"
+-
+-set timeout $prev_timeout
+
--- /dev/null
+http://sourceware.org/ml/gdb-patches/2011-02/msg00680.html
+Subject: [patch 2/3] Fix threading internal error on corrupted memory [rediff]
+
+[rediff]
+
+gdb/
+2011-02-24 Jan Kratochvil <jan.kratochvil@redhat.com>
+
+ * linux-thread-db.c (find_new_threads_callback): Exit on zero TI_TID
+ even if !TARGET_HAS_EXECUTION.
+
+gdb/testsuite/
+2011-02-24 Jan Kratochvil <jan.kratochvil@redhat.com>
+
+ * gdb.threads/gcore-thread.exp ($core0file): New variable.
+ (clear __stack_user.next, clear stack_used.next)
+ (save a zeroed-threads corefile): New test.
+ Call core_load for $core0file.
+ (zeroed-threads cannot be listed): New test.
+
+--- a/gdb/linux-thread-db.c
++++ b/gdb/linux-thread-db.c
+@@ -1335,7 +1335,7 @@ find_new_threads_callback (const td_thrhandle_t *th_p, void *data)
+ if (ti.ti_state == TD_THR_UNKNOWN || ti.ti_state == TD_THR_ZOMBIE)
+ return 0; /* A zombie -- ignore. */
+
+- if (ti.ti_tid == 0 && target_has_execution)
++ if (ti.ti_tid == 0)
+ {
+ /* A thread ID of zero means that this is the main thread, but
+ glibc has not yet initialized thread-local storage and the
+@@ -1347,10 +1347,13 @@ find_new_threads_callback (const td_thrhandle_t *th_p, void *data)
+ need this glibc bug workaround. */
+ info->need_stale_parent_threads_check = 0;
+
+- err = info->td_thr_event_enable_p (th_p, 1);
+- if (err != TD_OK)
+- error (_("Cannot enable thread event reporting for LWP %d: %s"),
+- (int) ti.ti_lid, thread_db_err_str (err));
++ if (target_has_execution)
++ {
++ err = info->td_thr_event_enable_p (th_p, 1);
++ if (err != TD_OK)
++ error (_("Cannot enable thread event reporting for LWP %d: %s"),
++ (int) ti.ti_lid, thread_db_err_str (err));
++ }
+
+ return 0;
+ }
+--- a/gdb/testsuite/gdb.threads/gcore-thread.exp
++++ b/gdb/testsuite/gdb.threads/gcore-thread.exp
+@@ -26,6 +26,7 @@ set testfile "gcore-thread"
+ set srcfile pthreads.c
+ set binfile ${objdir}/${subdir}/${testfile}
+ set corefile ${objdir}/${subdir}/${testfile}.test
++set core0file ${objdir}/${subdir}/${testfile}0.test
+
+ if [istarget "*-*-linux"] then {
+ set target_cflags "-D_MIT_POSIX_THREADS"
+@@ -110,6 +111,29 @@ if {!$core_supported} {
+ }
+
+
++# Test the uninitialized thread list.
++# Provide the case of glibc td_thr_get_info handling of:
++# /* Special case for the main thread before initialization. */
++
++foreach symbol {__stack_user stack_used} {
++ set test "clear ${symbol}.next"
++ gdb_test_multiple "p *(void **) &${symbol} = 0" $test {
++ -re " = \\(void \\*\\) 0x0\r\n$gdb_prompt $" {
++ pass $test
++ }
++ -re "No symbol \"${symbol}\" in current context\\.\r\n$gdb_prompt $" {
++ xfail $test
++ # Do not do the verification.
++ set core0file ""
++ }
++ }
++}
++
++if {"$core0file" != ""} {
++ gdb_test "gcore $core0file" "Saved corefile .*" "save a zeroed-threads corefile"
++}
++
++
+ # Now restart gdb and load the corefile.
+ clean_restart ${testfile}
+
+@@ -160,3 +184,11 @@ gdb_test "info threads" ".* thread2 .*" \
+
+ gdb_test "info threads" ".*${nl}\\* ${horiz} thread2 .*" \
+ "thread2 is current thread in corefile"
++
++
++# Test the uninitialized thread list.
++
++if {"$core0file" != "" && [load_core $core0file]} {
++
++ gdb_test "info threads" "Cannot find new threads: .*" "zeroed-threads cannot be listed"
++}
+
--- /dev/null
+http://sourceware.org/ml/gdb-patches/2011-02/msg00675.html
+Subject: [patch 3/3] Display core reasons even during thread error
+
+[ rediff ]
+
+Hi,
+
+this is mostly unrelated. But after the patch 2/3 it will still FAIL:
+ Loaded symbols for /lib64/ld-linux-x86-64.so.2
+ Cannot find new threads: debugger service failed
+ (gdb) FAIL: gdb.threads/gcore-thread.exp: re-load generated corefile
+
+as it is a common bug I dislike for years I have fixed it here:
+ Loaded symbols for /lib64/ld-linux-x86-64.so.2
+ Cannot find new threads: debugger service failed
+ Core was generated by `.../gdb/testsuite/gdb.threads/gcore-thread'.
+ Program terminated with signal 5, Trace/breakpoint trap.
+ #0 thread2 (arg=0xdeadbeef) at ./gdb.threads/pthreads.c:91
+ 91 int k = 0;
+ (gdb) PASS: gdb.threads/gcore-thread.exp: re-load generated corefile
+
+No regressions on {x86_64,x86_64-m32,i686}-fedora15-linux-gnu.
+
+
+Thanks,
+Jan
+
+
+gdb/
+2011-02-24 Jan Kratochvil <jan.kratochvil@redhat.com>
+
+ * corelow.c: Include wrapper.h.
+ (core_open): Call now gdb_target_find_new_threads.
+ * wrapper.c: Include target.h.
+ (gdb_target_find_new_threads): New.
+ * wrapper.h (gdb_target_find_new_threads): New declaration.
+
+--- a/gdb/corelow.c
++++ b/gdb/corelow.c
+@@ -47,6 +47,7 @@
+ #include "auxv.h"
+ #include "elf/common.h"
+ #include "gdbcmd.h"
++#include "wrapper.h"
+
+
+ #ifndef O_LARGEFILE
+@@ -428,7 +429,7 @@ core_open (char *filename, int from_tty)
+ may be a thread_stratum target loaded on top of target core by
+ now. The layer above should claim threads found in the BFD
+ sections. */
+- target_find_new_threads ();
++ gdb_target_find_new_threads ();
+
+ p = bfd_core_file_failing_command (core_bfd);
+ if (p)
+--- a/gdb/wrapper.c
++++ b/gdb/wrapper.c
+@@ -21,6 +21,7 @@
+ #include "exceptions.h"
+ #include "wrapper.h"
+ #include "ui-out.h"
++#include "target.h"
+
+ int
+ gdb_parse_exp_1 (char **stringptr, struct block *block, int comma,
+@@ -161,3 +162,24 @@ gdb_value_struct_elt (struct ui_out *uiout, struct value **result,
+ return GDB_RC_FAIL;
+ return GDB_RC_OK;
+ }
++
++/* Call target_find_new_threads without throwing exception. Exception is
++ printed if it got thrown. */
++
++int
++gdb_target_find_new_threads (void)
++{
++ volatile struct gdb_exception except;
++
++ TRY_CATCH (except, RETURN_MASK_ERROR)
++ {
++ target_find_new_threads ();
++ }
++
++ if (except.reason < 0)
++ {
++ exception_print (gdb_stderr, except);
++ return 0;
++ }
++ return 1;
++}
+--- a/gdb/wrapper.h
++++ b/gdb/wrapper.h
+@@ -48,4 +48,6 @@ extern int gdb_value_ind (struct value *val, struct value ** rval);
+
+ extern int gdb_parse_and_eval_type (char *, int, struct type **);
+
++extern int gdb_target_find_new_threads (void);
++
+ #endif /* wrapper.h */
+
-Index: gdb-7.1.90.20100711/gdb/f-lang.c
+Index: gdb-7.2.50.20110117/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.20110117.orig/gdb/f-lang.c 2011-01-07 20:36:16.000000000 +0100
++++ gdb-7.2.50.20110117/gdb/f-lang.c 2011-01-17 15:56:07.000000000 +0100
+@@ -57,20 +57,6 @@ typedef struct saved_bf_symnum SAVED_BF,
/* Local functions */
extern void _initialize_f_language (void);
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);
}
-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 */
+- in macros. */
-
-/* The following function simply enters a given common block onto
-- the global common block chain */
+- the global common block chain. */
-
-static void
-add_common_block (char *name, CORE_ADDR offset, int secnum, char *func_stab)
- /* If the COMMON block we are trying to add has a blank
- name (i.e. "#BLNK_COM") then we set it to __BLANK
- because the darn "#" character makes GDB's input
-- parser have fits. */
+- parser have fits. */
-
-
- if (strcmp (name, BLANK_COMMON_NAME_ORIGINAL) == 0
- tmp->name = xmalloc (strlen (name) + 1);
-
- /* local_copy_func_stab is a stabstring, let us first extract the
-- function name from the stab by NULLing out the ':' character. */
+- function name from the stab by NULLing out the ':' character. */
-
-
- c = NULL;
-#endif
-
-/* The following function simply enters a given common entry onto
-- the "current_common" block that has been saved away. */
+- the "current_common" block that has been saved away. */
-
-#if 0
-static void
-
- /* The order of this list is important, since
- we expect the entries to appear in decl.
-- order when we later issue "info common" calls */
+- order when we later issue "info common" calls. */
-
- tmp = allocate_common_entry_node ();
-
-}
-#endif
-
--/* This routine finds the first encountred COMMON block named "name" */
+-/* This routine finds the first encountred COMMON block named "name". */
-
-#if 0
-static SAVED_F77_COMMON_PTR
-#endif
/* This routine finds the first encountred COMMON block named "name"
- that belongs to function funcname */
-@@ -659,193 +467,3 @@ find_common_for_function (char *name, ch
+ that belongs to function funcname. */
+@@ -662,193 +470,3 @@ find_common_for_function (char *name, ch
}
return (NULL);
}
-{
- COMMON_ENTRY_PTR entry;
-
-- blk->offset = offset; /* Keep this around for future use. */
+- blk->offset = offset; /* Keep this around for future use. */
-
- entry = blk->entries;
-
- blocks occur with relative infrequency, we simply do a linear scan on
- the name. Eventually, the best way to do this will be a
- hashed-lookup. Secnum is the section number for the .bss section
-- (which is where common data lives). */
+- (which is where common data lives). */
-
-static void
-patch_all_commons_by_name (char *name, CORE_ADDR offset, int secnum)
- #line pragmas sometimes cause line ranges to get messed up
- we simply create a linear list. This list can then be searched
- first by a queueing algorithm and upon failure fall back to
-- a linear scan. */
+- a linear scan. */
-
-#if 0
-#define ADD_BF_SYMNUM(bf_sym,fcn_sym) \
- }
-#endif
-
--/* This function frees the entire (.bf,function) list */
+-/* This function frees the entire (.bf,function) list. */
-
-#if 0
-static void
- int nprobes = 0;
-
- /* First use a simple queuing algorithm (i.e. look and see if the
-- item at the head of the queue is the one you want) */
+- item at the head of the queue is the one you want). */
-
- if (saved_bf_list == NULL)
- internal_error (__FILE__, __LINE__,
-
- /* If the above did not work (probably because #line directives were
- used in the sourcefile and they messed up our internal tables) we now do
-- the ugly linear scan */
+- the ugly linear scan. */
-
- if (global_remote_debug)
- fprintf_unfiltered (gdb_stderr, "\ndefaulting to linear scan\n");
- saved_function_list = NULL;
-}
-#endif
-Index: gdb-7.1.90.20100711/gdb/f-lang.h
+Index: gdb-7.2.50.20110117/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.20110117.orig/gdb/f-lang.h 2011-01-17 15:47:37.000000000 +0100
++++ gdb-7.2.50.20110117/gdb/f-lang.h 2011-01-17 15:54:14.000000000 +0100
@@ -76,14 +76,9 @@ typedef struct saved_f77_common SAVED_F7
typedef struct common_entry COMMON_ENTRY, *COMMON_ENTRY_PTR;
#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.20110117/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.20110117.orig/gdb/f-valprint.c 2011-01-17 15:47:37.000000000 +0100
++++ gdb-7.2.50.20110117/gdb/f-valprint.c 2011-01-17 15:54:36.000000000 +0100
@@ -35,10 +35,6 @@
#include "command.h"
#include "block.h"
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);
}
-/* This function is used to determine whether there is a
-- F77 common block visible at the current scope called 'comname'. */
+- F77 common block visible at the current scope called 'comname'. */
-
-#if 0
-static int
- fi = get_selected_frame (_("No frame selected"));
-
- /* The following is generally ripped off from stack.c's routine
-- print_frame_info() */
+- print_frame_info(). */
-
- func = find_pc_function (fi->pc);
- if (func)
- up with a larger address for the function use that instead.
- I don't think this can ever cause any problems; there shouldn't
- be any minimal symbols in the middle of a function.
-- FIXME: (Not necessarily true. What about text labels) */
+- FIXME: (Not necessarily true. What about text labels?) */
-
- struct minimal_symbol *msymbol = lookup_minimal_symbol_by_pc (fi->pc);
-
-Index: gdb-7.1.90.20100711/gdb/dwarf2read.c
+Index: gdb-7.2.90.20110525/gdb/dwarf2read.c
===================================================================
---- gdb-7.1.90.20100711.orig/gdb/dwarf2read.c 2010-07-13 00:13:02.000000000 +0200
-+++ gdb-7.1.90.20100711/gdb/dwarf2read.c 2010-07-13 00:26:25.000000000 +0200
-@@ -5727,12 +5727,14 @@ read_set_type (struct die_info *die, str
+--- gdb-7.2.90.20110525.orig/gdb/dwarf2read.c 2011-05-25 17:06:19.000000000 +0200
++++ gdb-7.2.90.20110525/gdb/dwarf2read.c 2011-05-25 17:10:46.000000000 +0200
+@@ -7665,12 +7665,14 @@ read_set_type (struct die_info *die, str
return set_die_type (die, set_type, cu);
}
struct attribute *attr;
struct symbol *sym;
CORE_ADDR base = (CORE_ADDR) 0;
-@@ -5757,10 +5759,40 @@ read_common_block (struct die_info *die,
+@@ -7695,20 +7697,67 @@ read_common_block (struct die_info *die,
}
if (die->child != NULL)
{
child_die = die->child;
while (child_die && child_die->tag)
{
+ LONGEST offset;
+
+ /* Create the symbol in the DW_TAG_common_block block in the current
+ symbol scope. */
sym = new_symbol (child_die, NULL, cu);
+
+ /* Undocumented in DWARF3, when it can be present? */
- attr = dwarf2_attr (child_die, DW_AT_data_member_location, cu);
- if (attr)
+ if (sym != NULL
+ && handle_data_member_location (child_die, cu, &offset))
{
-@@ -5778,8 +5810,25 @@ read_common_block (struct die_info *die,
- SYMBOL_VALUE_ADDRESS (sym) = base + byte_offset;
+ SYMBOL_VALUE_ADDRESS (sym) = base + offset;
add_symbol_to_list (sym, &global_symbols);
}
+
}
}
-@@ -9106,6 +9155,13 @@ new_symbol (struct die_info *die, struct
+@@ -11376,6 +11425,13 @@ new_symbol_full (struct die_info *die, s
{
var_decode_location (attr, sym, cu);
attr2 = dwarf2_attr (die, DW_AT_external, cu);
+ && die->parent->tag == DW_TAG_common_block)
+ attr2 = NULL;
+
- if (attr2 && (DW_UNSND (attr2) != 0))
- {
- struct pending **list_to_add;
-@@ -9277,6 +9333,11 @@ new_symbol (struct die_info *die, struct
+ if (SYMBOL_CLASS (sym) == LOC_STATIC
+ && SYMBOL_VALUE_ADDRESS (sym) == 0
+ && !dwarf2_per_objfile->has_section_at_zero)
+@@ -11548,6 +11604,11 @@ new_symbol_full (struct die_info *die, s
SYMBOL_CLASS (sym) = LOC_TYPEDEF;
- add_symbol_to_list (sym, &global_symbols);
+ list_to_add = &global_symbols;
break;
+ case DW_TAG_common_block:
+ SYMBOL_CLASS (sym) = LOC_STATIC;
default:
/* Not a tag we recognize. Hopefully we aren't processing
trash data, but since we must specifically ignore things
-Index: gdb-7.1.90.20100711/gdb/f-lang.c
+Index: gdb-7.2.90.20110525/gdb/f-lang.c
===================================================================
---- gdb-7.1.90.20100711.orig/gdb/f-lang.c 2010-07-13 00:24:04.000000000 +0200
-+++ gdb-7.1.90.20100711/gdb/f-lang.c 2010-07-13 00:25:56.000000000 +0200
-@@ -443,27 +443,3 @@ _initialize_f_language (void)
+--- gdb-7.2.90.20110525.orig/gdb/f-lang.c 2011-05-25 17:06:22.000000000 +0200
++++ gdb-7.2.90.20110525/gdb/f-lang.c 2011-05-25 17:07:02.000000000 +0200
+@@ -446,27 +446,3 @@ _initialize_f_language (void)
add_language (&f_language_defn);
}
-SAVED_F77_COMMON_PTR head_common_list = NULL; /* Ptr to 1st saved COMMON */
-
-/* This routine finds the first encountred COMMON block named "name"
-- that belongs to function funcname */
+- that belongs to function funcname. */
-
-SAVED_F77_COMMON_PTR
-find_common_for_function (char *name, char *funcname)
- }
- return (NULL);
-}
-Index: gdb-7.1.90.20100711/gdb/f-lang.h
+Index: gdb-7.2.90.20110525/gdb/f-lang.h
===================================================================
---- gdb-7.1.90.20100711.orig/gdb/f-lang.h 2010-07-13 00:24:04.000000000 +0200
-+++ gdb-7.1.90.20100711/gdb/f-lang.h 2010-07-13 00:25:56.000000000 +0200
+--- gdb-7.2.90.20110525.orig/gdb/f-lang.h 2011-05-25 17:06:22.000000000 +0200
++++ gdb-7.2.90.20110525/gdb/f-lang.h 2011-05-25 17:07:02.000000000 +0200
@@ -52,36 +52,8 @@ enum f90_range_type
NONE_BOUND_DEFAULT /* "(low:high)" */
};
/* When reasonable array bounds cannot be fetched, such as when
you ask to 'mt print symbols' and there is no stack frame and
-Index: gdb-7.1.90.20100711/gdb/f-valprint.c
+Index: gdb-7.2.90.20110525/gdb/f-valprint.c
===================================================================
---- gdb-7.1.90.20100711.orig/gdb/f-valprint.c 2010-07-13 00:24:25.000000000 +0200
-+++ gdb-7.1.90.20100711/gdb/f-valprint.c 2010-07-13 00:32:05.000000000 +0200
+--- gdb-7.2.90.20110525.orig/gdb/f-valprint.c 2011-05-25 17:06:22.000000000 +0200
++++ gdb-7.2.90.20110525/gdb/f-valprint.c 2011-05-25 17:07:02.000000000 +0200
@@ -34,6 +34,8 @@
#include "gdbcore.h"
#include "command.h"
extern void _initialize_f_valprint (void);
static void info_common_command (char *, int);
-@@ -486,22 +488,54 @@ f_val_print (struct type *type, const gd
+@@ -501,22 +503,54 @@ f_val_print (struct type *type, const gd
return 0;
}
}
/* This function is used to print out the values in a given COMMON
-@@ -511,11 +545,9 @@ list_all_visible_commons (char *funname)
+@@ -526,11 +560,9 @@ list_all_visible_commons (char *funname)
static void
info_common_command (char *comname, int from_tty)
{
/* We have been told to display the contents of F77 COMMON
block supposedly visible in this function. Let us
-@@ -527,74 +559,31 @@ info_common_command (char *comname, int
+@@ -542,74 +574,31 @@ info_common_command (char *comname, int
/* The following is generally ripped off from stack.c's routine
- print_frame_info() */
+ print_frame_info(). */
- func = find_pc_function (get_frame_pc (fi));
- if (func)
- up with a larger address for the function use that instead.
- I don't think this can ever cause any problems; there shouldn't
- be any minimal symbols in the middle of a function.
-- FIXME: (Not necessarily true. What about text labels) */
+- FIXME: (Not necessarily true. What about text labels?) */
-
- struct minimal_symbol *msymbol =
- lookup_minimal_symbol_by_pc (get_frame_pc (fi));
}
- /* If comname is NULL, we assume the user wishes to see the
-- which COMMON blocks are visible here and then return */
+- which COMMON blocks are visible here and then return. */
-
- if (comname == 0)
+ while (block)
}
void
-Index: gdb-7.1.90.20100711/gdb/stack.c
+Index: gdb-7.2.90.20110525/gdb/stack.c
===================================================================
---- gdb-7.1.90.20100711.orig/gdb/stack.c 2010-07-01 17:36:17.000000000 +0200
-+++ gdb-7.1.90.20100711/gdb/stack.c 2010-07-13 00:29:49.000000000 +0200
-@@ -1484,6 +1484,8 @@ iterate_over_block_locals (struct block
+--- gdb-7.2.90.20110525.orig/gdb/stack.c 2011-05-25 17:05:21.000000000 +0200
++++ gdb-7.2.90.20110525/gdb/stack.c 2011-05-25 17:07:02.000000000 +0200
+@@ -1525,6 +1525,8 @@ iterate_over_block_locals (struct block
case LOC_COMPUTED:
if (SYMBOL_IS_ARGUMENT (sym))
break;
(*cb) (SYMBOL_PRINT_NAME (sym), sym, cb_data);
break;
-Index: gdb-7.1.90.20100711/gdb/symtab.h
+Index: gdb-7.2.90.20110525/gdb/symtab.h
===================================================================
---- gdb-7.1.90.20100711.orig/gdb/symtab.h 2010-07-12 23:07:33.000000000 +0200
-+++ gdb-7.1.90.20100711/gdb/symtab.h 2010-07-13 00:27:02.000000000 +0200
-@@ -396,7 +396,10 @@ typedef enum domain_enum_tag
- FUNCTIONS_DOMAIN,
+--- gdb-7.2.90.20110525.orig/gdb/symtab.h 2011-05-25 17:05:21.000000000 +0200
++++ gdb-7.2.90.20110525/gdb/symtab.h 2011-05-25 17:07:02.000000000 +0200
+@@ -411,7 +411,10 @@ typedef enum domain_enum_tag
+ TYPES_DOMAIN,
- /* All defined types */
-- TYPES_DOMAIN
-+ TYPES_DOMAIN,
+ /* Any type. */
+- ALL_DOMAIN
++ ALL_DOMAIN,
+
+ /* Fortran common blocks. Their naming must be separate from VAR_DOMAIN. */
+ COMMON_BLOCK_DOMAIN
}
domain_enum;
-Index: gdb-7.1.90.20100711/gdb/testsuite/gdb.fortran/common-block.exp
+Index: gdb-7.2.90.20110525/gdb/testsuite/gdb.fortran/common-block.exp
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
-+++ gdb-7.1.90.20100711/gdb/testsuite/gdb.fortran/common-block.exp 2010-07-13 00:25:56.000000000 +0200
++++ gdb-7.2.90.20110525/gdb/testsuite/gdb.fortran/common-block.exp 2011-05-25 17:07:02.000000000 +0200
@@ -0,0 +1,101 @@
+# Copyright 2008 Free Software Foundation, Inc.
+
+gdb_test "p ix_x" " = 1 *" "p ix_x in"
+gdb_test "p iy_y" " = 2 *" "p iy_y in"
+gdb_test "p iz_z2" " = 3 *" "p iz_z2 in"
-Index: gdb-7.1.90.20100711/gdb/testsuite/gdb.fortran/common-block.f90
+Index: gdb-7.2.90.20110525/gdb/testsuite/gdb.fortran/common-block.f90
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
-+++ gdb-7.1.90.20100711/gdb/testsuite/gdb.fortran/common-block.f90 2010-07-13 00:25:56.000000000 +0200
++++ gdb-7.2.90.20110525/gdb/testsuite/gdb.fortran/common-block.f90 2011-05-25 17:07:02.000000000 +0200
@@ -0,0 +1,67 @@
+! Copyright 2008 Free Software Foundation, Inc.
+!
--- /dev/null
+http://sourceware.org/ml/gdb-patches/2011-07/msg00645.html
+Subject: [patch] workaround gcc46: prologue skip skips too far (PR 12435) #2
+
+Hi,
+
+this is an improved patch of a former:
+ [patch] workaround gcc46: prologue skip skips too far (PR 12435)
+ http://sourceware.org/ml/gdb-patches/2011-03/msg01108.html
+ cancel/FYI: Re: [patch] workaround gcc46: prologue skip skips too far (PR 12435)
+ http://sourceware.org/ml/gdb-patches/2011-03/msg01123.html
+
+For example `break error' does not work for debugging GDB with gcc-4.6.x.
+
+As gcc-4.6.0 and now even 4.6.1 still has this bug and I have seen a user(s?)
+on non-Fedora platform asking about this bug and as there may be enough
+binaries out there (although it affects only -O0 -g compilation) coded it
+properly I have coded the workaround properly this time.
+
+It does not solve overlays well, but the code just does not work for overlays,
+it has no other negative effect.
+
+I will update the code after FSF gcc gets fixed to minimize the workaround.
+
+No regressions on {x86_64,x86_64-m32,i686}-fedora16pre-linux-gnu.
+
+I would welcome a comment whether it is suitable for FSF GDB.
+
+
+Thanks,
+Jan
+
+
+gdb/
+2011-07-22 Jan Kratochvil <jan.kratochvil@redhat.com>
+
+ PR breakpoints/12435
+ * amd64-tdep.c (amd64_skip_prologue): New variables start_pc_sal,
+ next_sal, buf, offset and xmmreg. Advance PC if it sees the PR.
+ * dwarf2read.c (process_full_comp_unit): Initialize
+ amd64_prologue_line_bug.
+ * symtab.h (struct symtab): New field amd64_prologue_line_bug.
+
+gdb/testsuite/
+2011-07-22 Jan Kratochvil <jan.kratochvil@redhat.com>
+
+ PR breakpoints/12435
+ * gdb.arch/amd64-prologue-xmm.c: New file.
+ * gdb.arch/amd64-prologue-xmm.exp: New file.
+ * gdb.arch/amd64-prologue-xmm.s: New file.
+
+Index: gdb-7.3/gdb/amd64-tdep.c
+===================================================================
+--- gdb-7.3.orig/gdb/amd64-tdep.c 2011-03-18 19:52:29.000000000 +0100
++++ gdb-7.3/gdb/amd64-tdep.c 2011-07-26 22:09:15.000000000 +0200
+@@ -1902,6 +1902,9 @@ amd64_skip_prologue (struct gdbarch *gdb
+ {
+ struct amd64_frame_cache cache;
+ CORE_ADDR pc;
++ struct symtab_and_line start_pc_sal, next_sal;
++ gdb_byte buf[4 + 8 * 7];
++ int offset, xmmreg;
+
+ amd64_init_frame_cache (&cache);
+ pc = amd64_analyze_prologue (gdbarch, start_pc, 0xffffffffffffffffLL,
+@@ -1909,7 +1912,71 @@ amd64_skip_prologue (struct gdbarch *gdb
+ if (cache.frameless_p)
+ return start_pc;
+
+- return pc;
++ /* GCC PR debug/48827 produced false prologue end:
++ 84 c0 test %al,%al
++ 74 23 je after
++ <-- here is 0 lines advance - the false prologue end marker.
++ 0f 29 85 70 ff ff ff movaps %xmm0,-0x90(%rbp)
++ 0f 29 4d 80 movaps %xmm1,-0x80(%rbp)
++ 0f 29 55 90 movaps %xmm2,-0x70(%rbp)
++ 0f 29 5d a0 movaps %xmm3,-0x60(%rbp)
++ 0f 29 65 b0 movaps %xmm4,-0x50(%rbp)
++ 0f 29 6d c0 movaps %xmm5,-0x40(%rbp)
++ 0f 29 75 d0 movaps %xmm6,-0x30(%rbp)
++ 0f 29 7d e0 movaps %xmm7,-0x20(%rbp)
++ after: */
++
++ if (pc == start_pc)
++ return pc;
++
++ start_pc_sal = find_pc_sect_line (start_pc, NULL, 0);
++ if (start_pc_sal.symtab == NULL
++ || !start_pc_sal.symtab->amd64_prologue_line_bug
++ || start_pc_sal.pc != start_pc || pc >= start_pc_sal.end)
++ return pc;
++
++ next_sal = find_pc_sect_line (start_pc_sal.end, NULL, 0);
++ if (next_sal.line != start_pc_sal.line)
++ return pc;
++
++ /* START_PC can be from overlayed memory, ignored here. */
++ if (target_read_memory (next_sal.pc - 4, buf, sizeof (buf)) != 0)
++ return pc;
++
++ /* test %al,%al */
++ if (buf[0] != 0x84 || buf[1] != 0xc0)
++ return pc;
++ /* je AFTER */
++ if (buf[2] != 0x74)
++ return pc;
++
++ offset = 4;
++ for (xmmreg = 0; xmmreg < 8; xmmreg++)
++ {
++ /* movaps %xmmreg?,-0x??(%rbp) */
++ if (buf[offset] != 0x0f || buf[offset + 1] != 0x29
++ || (buf[offset + 2] & 0b00111111) != (xmmreg << 3 | 0b101))
++ return pc;
++
++ if ((buf[offset + 2] & 0b11000000) == 0b01000000)
++ {
++ /* 8-bit displacement. */
++ offset += 4;
++ }
++ else if ((buf[offset + 2] & 0b11000000) == 0b10000000)
++ {
++ /* 32-bit displacement. */
++ offset += 7;
++ }
++ else
++ return pc;
++ }
++
++ /* je AFTER */
++ if (offset - 4 != buf[3])
++ return pc;
++
++ return next_sal.end;
+ }
+ \f
+
+Index: gdb-7.3/gdb/dwarf2read.c
+===================================================================
+--- gdb-7.3.orig/gdb/dwarf2read.c 2011-07-26 22:08:59.000000000 +0200
++++ gdb-7.3/gdb/dwarf2read.c 2011-07-26 22:11:07.000000000 +0200
+@@ -4647,6 +4647,42 @@ producer_is_gcc_ge_4_0 (struct dwarf2_cu
+ return major >= 4;
+ }
+
++static int
++producer_is_gcc_ge_4_6 (struct dwarf2_cu *cu)
++{
++ const char *cs;
++ int major, minor;
++
++ if (cu->producer == NULL)
++ {
++ /* For unknown compilers expect their behavior is not compliant. For GCC
++ this case can also happen for -gdwarf-4 type units supported since
++ gcc-4.5. */
++
++ return 0;
++ }
++
++ /* Skip any identifier after "GNU " - such as "C++" or "Java". */
++
++ if (strncmp (cu->producer, "GNU ", strlen ("GNU ")) != 0)
++ {
++ /* For non-GCC compilers expect their behavior is not compliant. */
++
++ return 0;
++ }
++ cs = &cu->producer[strlen ("GNU ")];
++ while (*cs && !isdigit (*cs))
++ cs++;
++ if (sscanf (cs, "%d.%d", &major, &minor) != 2)
++ {
++ /* Not recognized as GCC. */
++
++ return 0;
++ }
++
++ return major >= 4 && minor >= 6;
++}
++
+ /* Generate full symbol information for PST and CU, whose DIEs have
+ already been loaded into memory. */
+
+@@ -4706,6 +4742,9 @@ process_full_comp_unit (struct dwarf2_pe
+ */
+ if (cu->has_loclist && producer_is_gcc_ge_4_0 (cu))
+ symtab->locations_valid = 1;
++
++ if (producer_is_gcc_ge_4_6 (cu))
++ symtab->amd64_prologue_line_bug = 1;
+ }
+
+ if (dwarf2_per_objfile->using_index)
+Index: gdb-7.3/gdb/symtab.h
+===================================================================
+--- gdb-7.3.orig/gdb/symtab.h 2011-07-26 22:08:57.000000000 +0200
++++ gdb-7.3/gdb/symtab.h 2011-07-26 22:09:39.000000000 +0200
+@@ -779,6 +779,11 @@ struct symtab
+
+ unsigned int locations_valid : 1;
+
++ /* At least GCC 4.6.0 and 4.6.1 can produce invalid false prologue and marker
++ on amd64. This flag is set independently of the symtab arch. */
++
++ unsigned amd64_prologue_line_bug : 1;
++
+ /* The macro table for this symtab. Like the blockvector, this
+ may be shared between different symtabs --- and normally is for
+ all the symtabs in a given compilation unit. */
+Index: gdb-7.3/gdb/testsuite/gdb.arch/amd64-prologue-xmm.c
+===================================================================
+--- /dev/null 1970-01-01 00:00:00.000000000 +0000
++++ gdb-7.3/gdb/testsuite/gdb.arch/amd64-prologue-xmm.c 2011-07-26 22:09:15.000000000 +0200
+@@ -0,0 +1,38 @@
++/* This testcase is part of GDB, the GNU debugger.
++
++ Copyright 2011 Free Software Foundation, Inc.
++
++ This program is free software; you can redistribute it and/or modify
++ it under the terms of the GNU General Public License as published by
++ the Free Software Foundation; either version 3 of the License, or
++ (at your option) any later version.
++
++ This program is distributed in the hope that it will be useful,
++ but WITHOUT ANY WARRANTY; without even the implied warranty of
++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ GNU General Public License for more details.
++
++ You should have received a copy of the GNU General Public License
++ along with this program. If not, see <http://www.gnu.org/licenses/>. */
++
++static volatile int v, fail;
++
++static void
++func (int i, ...)
++{
++ v = i;
++}
++
++static void
++marker (void)
++{
++}
++
++int
++main (void)
++{
++ func (1);
++ fail = 1;
++ marker ();
++ return 0;
++}
+Index: gdb-7.3/gdb/testsuite/gdb.arch/amd64-prologue-xmm.exp
+===================================================================
+--- /dev/null 1970-01-01 00:00:00.000000000 +0000
++++ gdb-7.3/gdb/testsuite/gdb.arch/amd64-prologue-xmm.exp 2011-07-26 22:09:15.000000000 +0200
+@@ -0,0 +1,46 @@
++# Copyright 2011 Free Software Foundation, Inc.
++#
++# This program is free software; you can redistribute it and/or modify
++# it under the terms of the GNU General Public License as published by
++# the Free Software Foundation; either version 3 of the License, or
++# (at your option) any later version.
++#
++# This program is distributed in the hope that it will be useful,
++# but WITHOUT ANY WARRANTY; without even the implied warranty of
++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++# GNU General Public License for more details.
++#
++# You should have received a copy of the GNU General Public License
++# along with this program. If not, see <http://www.gnu.org/licenses/>.
++
++# Test GCC PR debug/48827 workaround in GDB.
++
++set testfile "amd64-prologue-xmm"
++set srcfile ${testfile}.s
++set csrcfile ${testfile}.c
++set binfile ${objdir}/${subdir}/${testfile}.x
++set opts {}
++
++if [info exists COMPILE] {
++ # make check RUNTESTFLAGS='gdb.arch/amd64-prologue-xmm.exp COMPILE=1'
++ set srcfile ${csrcfile}
++ lappend opts debug optimize=-O0
++} elseif { ![istarget x86_64-*-* ] || ![is_lp64_target] } {
++ verbose "Skipping amd64-prologue-xmm test."
++ return 0
++}
++
++if {[prepare_for_testing ${testfile}.exp ${testfile} $srcfile $opts]} {
++ return -1
++}
++
++if ![runto_main] {
++ return -1
++}
++
++gdb_breakpoint "func"
++gdb_breakpoint "marker"
++
++gdb_continue_to_breakpoint "func"
++
++gdb_test "p fail" " = 0" "stopped at func"
+Index: gdb-7.3/gdb/testsuite/gdb.arch/amd64-prologue-xmm.s
+===================================================================
+--- /dev/null 1970-01-01 00:00:00.000000000 +0000
++++ gdb-7.3/gdb/testsuite/gdb.arch/amd64-prologue-xmm.s 2011-07-26 22:09:15.000000000 +0200
+@@ -0,0 +1,400 @@
++/* This testcase is part of GDB, the GNU debugger.
++
++ Copyright 2011 Free Software Foundation, Inc.
++
++ This program is free software; you can redistribute it and/or modify
++ it under the terms of the GNU General Public License as published by
++ the Free Software Foundation; either version 3 of the License, or
++ (at your option) any later version.
++
++ This program is distributed in the hope that it will be useful,
++ but WITHOUT ANY WARRANTY; without even the implied warranty of
++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ GNU General Public License for more details.
++
++ You should have received a copy of the GNU General Public License
++ along with this program. If not, see <http://www.gnu.org/licenses/>. */
++
++/* This file is compiled from gdb.arch/amd64-prologue-xmm.c
++ using -g -dA -S. */
++
++ .file "amd64-prologue-xmm.c"
++ .text
++.Ltext0:
++ .local v
++ .comm v,4,4
++ .local fail
++ .comm fail,4,4
++ .type func, @function
++func:
++.LFB0:
++ .file 1 "gdb.arch/amd64-prologue-xmm.c"
++ # gdb.arch/amd64-prologue-xmm.c:22
++ .loc 1 22 0
++ .cfi_startproc
++ # basic block 2
++ pushq %rbp
++ .cfi_def_cfa_offset 16
++ .cfi_offset 6, -16
++ movq %rsp, %rbp
++ .cfi_def_cfa_register 6
++ subq $72, %rsp
++ movq %rsi, -168(%rbp)
++ movq %rdx, -160(%rbp)
++ movq %rcx, -152(%rbp)
++ movq %r8, -144(%rbp)
++ movq %r9, -136(%rbp)
++ testb %al, %al
++ je .L2
++ # basic block 3
++ # gdb.arch/amd64-prologue-xmm.c:22
++ .loc 1 22 0
++ movaps %xmm0, -128(%rbp)
++ movaps %xmm1, -112(%rbp)
++ movaps %xmm2, -96(%rbp)
++ movaps %xmm3, -80(%rbp)
++ movaps %xmm4, -64(%rbp)
++ movaps %xmm5, -48(%rbp)
++ movaps %xmm6, -32(%rbp)
++ movaps %xmm7, -16(%rbp)
++.L2:
++ # basic block 4
++ movl %edi, -180(%rbp)
++ # gdb.arch/amd64-prologue-xmm.c:23
++ .loc 1 23 0
++ movl -180(%rbp), %eax
++ movl %eax, v(%rip)
++ # gdb.arch/amd64-prologue-xmm.c:24
++ .loc 1 24 0
++ leave
++ .cfi_def_cfa 7, 8
++ ret
++ .cfi_endproc
++.LFE0:
++ .size func, .-func
++ .type marker, @function
++marker:
++.LFB1:
++ # gdb.arch/amd64-prologue-xmm.c:28
++ .loc 1 28 0
++ .cfi_startproc
++ # basic block 2
++ pushq %rbp
++ .cfi_def_cfa_offset 16
++ .cfi_offset 6, -16
++ movq %rsp, %rbp
++ .cfi_def_cfa_register 6
++ # gdb.arch/amd64-prologue-xmm.c:29
++ .loc 1 29 0
++ popq %rbp
++ .cfi_def_cfa 7, 8
++ ret
++ .cfi_endproc
++.LFE1:
++ .size marker, .-marker
++ .globl main
++ .type main, @function
++main:
++.LFB2:
++ # gdb.arch/amd64-prologue-xmm.c:33
++ .loc 1 33 0
++ .cfi_startproc
++ # basic block 2
++ pushq %rbp
++ .cfi_def_cfa_offset 16
++ .cfi_offset 6, -16
++ movq %rsp, %rbp
++ .cfi_def_cfa_register 6
++ # gdb.arch/amd64-prologue-xmm.c:34
++ .loc 1 34 0
++ movl $1, %edi
++ movl $0, %eax
++ call func
++ # gdb.arch/amd64-prologue-xmm.c:35
++ .loc 1 35 0
++ movl $1, fail(%rip)
++ # gdb.arch/amd64-prologue-xmm.c:36
++ .loc 1 36 0
++ call marker
++ # gdb.arch/amd64-prologue-xmm.c:37
++ .loc 1 37 0
++ movl $0, %eax
++ # gdb.arch/amd64-prologue-xmm.c:38
++ .loc 1 38 0
++ popq %rbp
++ .cfi_def_cfa 7, 8
++ ret
++ .cfi_endproc
++.LFE2:
++ .size main, .-main
++.Letext0:
++ .section .debug_info,"",@progbits
++.Ldebug_info0:
++ .long 0xc0 # Length of Compilation Unit Info
++ .value 0x4 # DWARF version number
++ .long .Ldebug_abbrev0 # Offset Into Abbrev. Section
++ .byte 0x8 # Pointer Size (in bytes)
++ .uleb128 0x1 # (DIE (0xb) DW_TAG_compile_unit)
++ .long .LASF1 # DW_AT_producer: "GNU C 4.6.1 20110715 (Red Hat 4.6.1-3)"
++ .byte 0x1 # DW_AT_language
++ .long .LASF2 # DW_AT_name: "gdb.arch/amd64-prologue-xmm.c"
++ .long .LASF3 # DW_AT_comp_dir: ""
++ .quad .Ltext0 # DW_AT_low_pc
++ .quad .Letext0 # DW_AT_high_pc
++ .long .Ldebug_line0 # DW_AT_stmt_list
++ .uleb128 0x2 # (DIE (0x2d) DW_TAG_subprogram)
++ .long .LASF4 # DW_AT_name: "func"
++ .byte 0x1 # DW_AT_decl_file (gdb.arch/amd64-prologue-xmm.c)
++ .byte 0x15 # DW_AT_decl_line
++ # DW_AT_prototyped
++ .quad .LFB0 # DW_AT_low_pc
++ .quad .LFE0 # DW_AT_high_pc
++ .uleb128 0x1 # DW_AT_frame_base
++ .byte 0x9c # DW_OP_call_frame_cfa
++ # DW_AT_GNU_all_call_sites
++ .long 0x59 # DW_AT_sibling
++ .uleb128 0x3 # (DIE (0x4a) DW_TAG_formal_parameter)
++ .ascii "i\0" # DW_AT_name
++ .byte 0x1 # DW_AT_decl_file (gdb.arch/amd64-prologue-xmm.c)
++ .byte 0x15 # DW_AT_decl_line
++ .long 0x59 # DW_AT_type
++ .uleb128 0x3 # DW_AT_location
++ .byte 0x91 # DW_OP_fbreg
++ .sleb128 -196
++ .uleb128 0x4 # (DIE (0x57) DW_TAG_unspecified_parameters)
++ .byte 0 # end of children of DIE 0x2d
++ .uleb128 0x5 # (DIE (0x59) DW_TAG_base_type)
++ .byte 0x4 # DW_AT_byte_size
++ .byte 0x5 # DW_AT_encoding
++ .ascii "int\0" # DW_AT_name
++ .uleb128 0x6 # (DIE (0x60) DW_TAG_subprogram)
++ .long .LASF5 # DW_AT_name: "marker"
++ .byte 0x1 # DW_AT_decl_file (gdb.arch/amd64-prologue-xmm.c)
++ .byte 0x1b # DW_AT_decl_line
++ # DW_AT_prototyped
++ .quad .LFB1 # DW_AT_low_pc
++ .quad .LFE1 # DW_AT_high_pc
++ .uleb128 0x1 # DW_AT_frame_base
++ .byte 0x9c # DW_OP_call_frame_cfa
++ # DW_AT_GNU_all_call_sites
++ .uleb128 0x7 # (DIE (0x79) DW_TAG_subprogram)
++ # DW_AT_external
++ .long .LASF6 # DW_AT_name: "main"
++ .byte 0x1 # DW_AT_decl_file (gdb.arch/amd64-prologue-xmm.c)
++ .byte 0x20 # DW_AT_decl_line
++ # DW_AT_prototyped
++ .long 0x59 # DW_AT_type
++ .quad .LFB2 # DW_AT_low_pc
++ .quad .LFE2 # DW_AT_high_pc
++ .uleb128 0x1 # DW_AT_frame_base
++ .byte 0x9c # DW_OP_call_frame_cfa
++ # DW_AT_GNU_all_tail_call_sites
++ .uleb128 0x8 # (DIE (0x96) DW_TAG_variable)
++ .ascii "v\0" # DW_AT_name
++ .byte 0x1 # DW_AT_decl_file (gdb.arch/amd64-prologue-xmm.c)
++ .byte 0x12 # DW_AT_decl_line
++ .long 0xa9 # DW_AT_type
++ .uleb128 0x9 # DW_AT_location
++ .byte 0x3 # DW_OP_addr
++ .quad v
++ .uleb128 0x9 # (DIE (0xa9) DW_TAG_volatile_type)
++ .long 0x59 # DW_AT_type
++ .uleb128 0xa # (DIE (0xae) DW_TAG_variable)
++ .long .LASF0 # DW_AT_name: "fail"
++ .byte 0x1 # DW_AT_decl_file (gdb.arch/amd64-prologue-xmm.c)
++ .byte 0x12 # DW_AT_decl_line
++ .long 0xa9 # DW_AT_type
++ .uleb128 0x9 # DW_AT_location
++ .byte 0x3 # DW_OP_addr
++ .quad fail
++ .byte 0 # end of children of DIE 0xb
++ .section .debug_abbrev,"",@progbits
++.Ldebug_abbrev0:
++ .uleb128 0x1 # (abbrev code)
++ .uleb128 0x11 # (TAG: DW_TAG_compile_unit)
++ .byte 0x1 # DW_children_yes
++ .uleb128 0x25 # (DW_AT_producer)
++ .uleb128 0xe # (DW_FORM_strp)
++ .uleb128 0x13 # (DW_AT_language)
++ .uleb128 0xb # (DW_FORM_data1)
++ .uleb128 0x3 # (DW_AT_name)
++ .uleb128 0xe # (DW_FORM_strp)
++ .uleb128 0x1b # (DW_AT_comp_dir)
++ .uleb128 0xe # (DW_FORM_strp)
++ .uleb128 0x11 # (DW_AT_low_pc)
++ .uleb128 0x1 # (DW_FORM_addr)
++ .uleb128 0x12 # (DW_AT_high_pc)
++ .uleb128 0x1 # (DW_FORM_addr)
++ .uleb128 0x10 # (DW_AT_stmt_list)
++ .uleb128 0x17 # (DW_FORM_sec_offset)
++ .byte 0
++ .byte 0
++ .uleb128 0x2 # (abbrev code)
++ .uleb128 0x2e # (TAG: DW_TAG_subprogram)
++ .byte 0x1 # DW_children_yes
++ .uleb128 0x3 # (DW_AT_name)
++ .uleb128 0xe # (DW_FORM_strp)
++ .uleb128 0x3a # (DW_AT_decl_file)
++ .uleb128 0xb # (DW_FORM_data1)
++ .uleb128 0x3b # (DW_AT_decl_line)
++ .uleb128 0xb # (DW_FORM_data1)
++ .uleb128 0x27 # (DW_AT_prototyped)
++ .uleb128 0x19 # (DW_FORM_flag_present)
++ .uleb128 0x11 # (DW_AT_low_pc)
++ .uleb128 0x1 # (DW_FORM_addr)
++ .uleb128 0x12 # (DW_AT_high_pc)
++ .uleb128 0x1 # (DW_FORM_addr)
++ .uleb128 0x40 # (DW_AT_frame_base)
++ .uleb128 0x18 # (DW_FORM_exprloc)
++ .uleb128 0x2117 # (DW_AT_GNU_all_call_sites)
++ .uleb128 0x19 # (DW_FORM_flag_present)
++ .uleb128 0x1 # (DW_AT_sibling)
++ .uleb128 0x13 # (DW_FORM_ref4)
++ .byte 0
++ .byte 0
++ .uleb128 0x3 # (abbrev code)
++ .uleb128 0x5 # (TAG: DW_TAG_formal_parameter)
++ .byte 0 # DW_children_no
++ .uleb128 0x3 # (DW_AT_name)
++ .uleb128 0x8 # (DW_FORM_string)
++ .uleb128 0x3a # (DW_AT_decl_file)
++ .uleb128 0xb # (DW_FORM_data1)
++ .uleb128 0x3b # (DW_AT_decl_line)
++ .uleb128 0xb # (DW_FORM_data1)
++ .uleb128 0x49 # (DW_AT_type)
++ .uleb128 0x13 # (DW_FORM_ref4)
++ .uleb128 0x2 # (DW_AT_location)
++ .uleb128 0x18 # (DW_FORM_exprloc)
++ .byte 0
++ .byte 0
++ .uleb128 0x4 # (abbrev code)
++ .uleb128 0x18 # (TAG: DW_TAG_unspecified_parameters)
++ .byte 0 # DW_children_no
++ .byte 0
++ .byte 0
++ .uleb128 0x5 # (abbrev code)
++ .uleb128 0x24 # (TAG: DW_TAG_base_type)
++ .byte 0 # DW_children_no
++ .uleb128 0xb # (DW_AT_byte_size)
++ .uleb128 0xb # (DW_FORM_data1)
++ .uleb128 0x3e # (DW_AT_encoding)
++ .uleb128 0xb # (DW_FORM_data1)
++ .uleb128 0x3 # (DW_AT_name)
++ .uleb128 0x8 # (DW_FORM_string)
++ .byte 0
++ .byte 0
++ .uleb128 0x6 # (abbrev code)
++ .uleb128 0x2e # (TAG: DW_TAG_subprogram)
++ .byte 0 # DW_children_no
++ .uleb128 0x3 # (DW_AT_name)
++ .uleb128 0xe # (DW_FORM_strp)
++ .uleb128 0x3a # (DW_AT_decl_file)
++ .uleb128 0xb # (DW_FORM_data1)
++ .uleb128 0x3b # (DW_AT_decl_line)
++ .uleb128 0xb # (DW_FORM_data1)
++ .uleb128 0x27 # (DW_AT_prototyped)
++ .uleb128 0x19 # (DW_FORM_flag_present)
++ .uleb128 0x11 # (DW_AT_low_pc)
++ .uleb128 0x1 # (DW_FORM_addr)
++ .uleb128 0x12 # (DW_AT_high_pc)
++ .uleb128 0x1 # (DW_FORM_addr)
++ .uleb128 0x40 # (DW_AT_frame_base)
++ .uleb128 0x18 # (DW_FORM_exprloc)
++ .uleb128 0x2117 # (DW_AT_GNU_all_call_sites)
++ .uleb128 0x19 # (DW_FORM_flag_present)
++ .byte 0
++ .byte 0
++ .uleb128 0x7 # (abbrev code)
++ .uleb128 0x2e # (TAG: DW_TAG_subprogram)
++ .byte 0 # DW_children_no
++ .uleb128 0x3f # (DW_AT_external)
++ .uleb128 0x19 # (DW_FORM_flag_present)
++ .uleb128 0x3 # (DW_AT_name)
++ .uleb128 0xe # (DW_FORM_strp)
++ .uleb128 0x3a # (DW_AT_decl_file)
++ .uleb128 0xb # (DW_FORM_data1)
++ .uleb128 0x3b # (DW_AT_decl_line)
++ .uleb128 0xb # (DW_FORM_data1)
++ .uleb128 0x27 # (DW_AT_prototyped)
++ .uleb128 0x19 # (DW_FORM_flag_present)
++ .uleb128 0x49 # (DW_AT_type)
++ .uleb128 0x13 # (DW_FORM_ref4)
++ .uleb128 0x11 # (DW_AT_low_pc)
++ .uleb128 0x1 # (DW_FORM_addr)
++ .uleb128 0x12 # (DW_AT_high_pc)
++ .uleb128 0x1 # (DW_FORM_addr)
++ .uleb128 0x40 # (DW_AT_frame_base)
++ .uleb128 0x18 # (DW_FORM_exprloc)
++ .uleb128 0x2116 # (DW_AT_GNU_all_tail_call_sites)
++ .uleb128 0x19 # (DW_FORM_flag_present)
++ .byte 0
++ .byte 0
++ .uleb128 0x8 # (abbrev code)
++ .uleb128 0x34 # (TAG: DW_TAG_variable)
++ .byte 0 # DW_children_no
++ .uleb128 0x3 # (DW_AT_name)
++ .uleb128 0x8 # (DW_FORM_string)
++ .uleb128 0x3a # (DW_AT_decl_file)
++ .uleb128 0xb # (DW_FORM_data1)
++ .uleb128 0x3b # (DW_AT_decl_line)
++ .uleb128 0xb # (DW_FORM_data1)
++ .uleb128 0x49 # (DW_AT_type)
++ .uleb128 0x13 # (DW_FORM_ref4)
++ .uleb128 0x2 # (DW_AT_location)
++ .uleb128 0x18 # (DW_FORM_exprloc)
++ .byte 0
++ .byte 0
++ .uleb128 0x9 # (abbrev code)
++ .uleb128 0x35 # (TAG: DW_TAG_volatile_type)
++ .byte 0 # DW_children_no
++ .uleb128 0x49 # (DW_AT_type)
++ .uleb128 0x13 # (DW_FORM_ref4)
++ .byte 0
++ .byte 0
++ .uleb128 0xa # (abbrev code)
++ .uleb128 0x34 # (TAG: DW_TAG_variable)
++ .byte 0 # DW_children_no
++ .uleb128 0x3 # (DW_AT_name)
++ .uleb128 0xe # (DW_FORM_strp)
++ .uleb128 0x3a # (DW_AT_decl_file)
++ .uleb128 0xb # (DW_FORM_data1)
++ .uleb128 0x3b # (DW_AT_decl_line)
++ .uleb128 0xb # (DW_FORM_data1)
++ .uleb128 0x49 # (DW_AT_type)
++ .uleb128 0x13 # (DW_FORM_ref4)
++ .uleb128 0x2 # (DW_AT_location)
++ .uleb128 0x18 # (DW_FORM_exprloc)
++ .byte 0
++ .byte 0
++ .byte 0
++ .section .debug_aranges,"",@progbits
++ .long 0x2c # Length of Address Ranges Info
++ .value 0x2 # DWARF Version
++ .long .Ldebug_info0 # Offset of Compilation Unit Info
++ .byte 0x8 # Size of Address
++ .byte 0 # Size of Segment Descriptor
++ .value 0 # Pad to 16 byte boundary
++ .value 0
++ .quad .Ltext0 # Address
++ .quad .Letext0-.Ltext0 # Length
++ .quad 0
++ .quad 0
++ .section .debug_line,"",@progbits
++.Ldebug_line0:
++ .section .debug_str,"MS",@progbits,1
++.LASF3:
++ .string ""
++.LASF0:
++ .string "fail"
++.LASF4:
++ .string "func"
++.LASF1:
++ .string "GNU C 4.6.1 20110715 (Red Hat 4.6.1-3)"
++.LASF2:
++ .string "gdb.arch/amd64-prologue-xmm.c"
++.LASF5:
++ .string "marker"
++.LASF6:
++ .string "main"
++ .ident "GCC: (GNU) 4.6.1 20110715 (Red Hat 4.6.1-3)"
++ .section .note.GNU-stack,"",@progbits
--- /dev/null
+http://sourceware.org/ml/gdb-patches/2011-04/msg00154.html
+Subject: [patch] Workaround buggy GCC PR 47510 produced code
+
+Hi,
+
+GCC PR debug/47510 is already fixed and GDB has the proper support for it:
+ RFC: update for GCC PR 47510
+ http://sourceware.org/ml/gdb-patches/2011-03/msg00916.html
+
+Still FSF GDB HEAD will crash on a binary produced by older/buggy GCC:
+ Reading symbols from .../gcc46.o...dwarf2read.c:9329: internal-error: could not find partial DIE 0x9a in cache [from module .../gcc46.o]
+
+Which may not give much clue to the user.
+
+The proposed patch could make false warnings if any code out there has
+DW_TAG_typedef with children, it does not check for specific GCC versions.
+Still such DWARF is invalid, although in such case complaint() would be more
+appropriate than warning(). Does it make sense to differentiate it?
+
+No regressions on {x86_64,x86_64-m32,i686}-fedora15-linux-gnu.
+
+
+Thanks,
+Jan
+
+
+gdb/
+2011-04-11 Jan Kratochvil <jan.kratochvil@redhat.com>
+
+ * dwarf2read.c (struct dwarf2_per_objfile): New field
+ typedef_children_warning_printed.
+ (load_partial_dies): Read in any children of DW_TAG_typedef with
+ a warning in such case.
+
+gdb/testsuite/
+2011-04-11 Jan Kratochvil <jan.kratochvil@redhat.com>
+
+ * gdb.dwarf2/dw2-typedef-children.S: New file.
+ * gdb.dwarf2/dw2-typedef-children.exp: New file.
+
+--- a/gdb/dwarf2read.c
++++ b/gdb/dwarf2read.c
+@@ -209,6 +209,9 @@ struct dwarf2_per_objfile
+ or we are faking it for OBJF_READNOW's sake. */
+ unsigned char using_index;
+
++ /* Print the GCC PR debug/47510 warning only once per objfile. */
++ unsigned typedef_children_warning_printed : 1;
++
+ /* The mapped index, or NULL if .gdb_index is missing or not being used. */
+ struct mapped_index *index_table;
+
+@@ -8951,7 +8954,7 @@ load_partial_dies (bfd *abfd, gdb_byte *buffer, gdb_byte *info_ptr,
+ if (parent_die == NULL
+ && part_die->has_specification == 0
+ && part_die->is_declaration == 0
+- && (part_die->tag == DW_TAG_typedef
++ && ((part_die->tag == DW_TAG_typedef && !part_die->has_children)
+ || part_die->tag == DW_TAG_base_type
+ || part_die->tag == DW_TAG_subrange_type))
+ {
+@@ -8964,6 +8967,20 @@ load_partial_dies (bfd *abfd, gdb_byte *buffer, gdb_byte *info_ptr,
+ continue;
+ }
+
++ /* The exception for DW_TAG_typedef with has_children above is
++ a workaround of GCC PR debug/47510. GDB crashed on broken GCC output
++ as it skipped children of DW_TAG_typedef by the shortcut above and
++ then it could not find the child DIEs referenced later. */
++
++ if (!dwarf2_per_objfile->typedef_children_warning_printed
++ && part_die->tag == DW_TAG_typedef && part_die->has_children)
++ {
++ warning (_("DW_TAG_typedef has childen - GCC PR debug/47510 bug "
++ "- DIE at 0x%x [in module %s]"),
++ part_die->offset, cu->objfile->name);
++ dwarf2_per_objfile->typedef_children_warning_printed = 1;
++ }
++
+ /* If we're at the second level, and we're an enumerator, and
+ our parent has no specification (meaning possibly lives in a
+ namespace elsewhere), then we can add the partial symbol now
+--- /dev/null
++++ b/gdb/testsuite/gdb.dwarf2/dw2-typedef-children.S
+@@ -0,0 +1,92 @@
++/* This testcase is part of GDB, the GNU debugger.
++
++ Copyright 2011 Free Software Foundation, Inc.
++
++ This program is free software; you can redistribute it and/or modify
++ it under the terms of the GNU General Public License as published by
++ the Free Software Foundation; either version 3 of the License, or
++ (at your option) any later version.
++
++ This program is distributed in the hope that it will be useful,
++ but WITHOUT ANY WARRANTY; without even the implied warranty of
++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ GNU General Public License for more details.
++
++ You should have received a copy of the GNU General Public License
++ along with this program. If not, see <http://www.gnu.org/licenses/>. */
++
++/* Debug information */
++
++ .section .debug_info
++.Lcu1_begin:
++ /* CU header */
++ .4byte .Lcu1_end - .Lcu1_start /* Length of Compilation Unit */
++.Lcu1_start:
++ .2byte 2 /* DWARF Version */
++ .4byte .Labbrev1_begin /* Offset into abbrev section */
++ .byte 4 /* Pointer size */
++
++ /* CU die */
++ .uleb128 1 /* Abbrev: DW_TAG_compile_unit */
++ .ascii "file1.txt\0" /* DW_AT_name */
++ .ascii "GNU C 3.3.3\0" /* DW_AT_producer */
++ .byte 1 /* DW_AT_language (C) */
++
++.Ltype_int:
++ .uleb128 2 /* Abbrev: DW_TAG_base_type */
++ .ascii "int\0" /* DW_AT_name */
++ .byte 4 /* DW_AT_byte_size */
++ .byte 5 /* DW_AT_encoding */
++
++ .uleb128 0x3 /* (DIE (0x38) DW_TAG_typedef) */
++ .ascii "new\0" /* DW_AT_name */
++ .long .Ltype_int - .Lcu1_begin /* DW_AT_type */
++
++ .uleb128 2 /* Abbrev: DW_TAG_base_type */
++ .ascii "int\0" /* DW_AT_name */
++ .byte 4 /* DW_AT_byte_size */
++ .byte 5 /* DW_AT_encoding */
++
++ .uleb128 0 /* End of DW_TAG_typedef */
++ .uleb128 0 /* End of DW_TAG_compile_unit */
++.Lcu1_end:
++
++/* Abbrev table */
++ .section .debug_abbrev
++.Labbrev1_begin:
++ .uleb128 1 /* Abbrev code */
++ .uleb128 0x11 /* DW_TAG_compile_unit */
++ .byte 1 /* has_children */
++ .uleb128 0x3 /* DW_AT_name */
++ .uleb128 0x8 /* DW_FORM_string */
++ .uleb128 0x25 /* DW_AT_producer */
++ .uleb128 0x8 /* DW_FORM_string */
++ .uleb128 0x13 /* DW_AT_language */
++ .uleb128 0xb /* DW_FORM_data1 */
++ .byte 0x0 /* Terminator */
++ .byte 0x0 /* Terminator */
++
++ .uleb128 2 /* Abbrev code */
++ .uleb128 0x24 /* DW_TAG_base_type */
++ .byte 0 /* has_children */
++ .uleb128 0x3 /* DW_AT_name */
++ .uleb128 0x8 /* DW_FORM_string */
++ .uleb128 0xb /* DW_AT_byte_size */
++ .uleb128 0xb /* DW_FORM_data1 */
++ .uleb128 0x3e /* DW_AT_encoding */
++ .uleb128 0xb /* DW_FORM_data1 */
++ .byte 0x0 /* Terminator */
++ .byte 0x0 /* Terminator */
++
++ .uleb128 0x3 /* (abbrev code) */
++ .uleb128 0x16 /* (TAG: DW_TAG_typedef) */
++ .byte 0x1 /* DW_children_yes */
++ .uleb128 0x3 /* (DW_AT_name) */
++ .uleb128 0x8 /* (DW_FORM_string) */
++ .uleb128 0x49 /* (DW_AT_type) */
++ .uleb128 0x13 /* (DW_FORM_ref4) */
++ .byte 0x0
++ .byte 0x0
++
++ .byte 0x0 /* Terminator */
++ .byte 0x0 /* Terminator */
+--- /dev/null
++++ b/gdb/testsuite/gdb.dwarf2/dw2-typedef-children.exp
+@@ -0,0 +1,37 @@
++# Copyright 2011 Free Software Foundation, Inc.
++
++# This program is free software; you can redistribute it and/or modify
++# it under the terms of the GNU General Public License as published by
++# the Free Software Foundation; either version 3 of the License, or
++# (at your option) any later version.
++#
++# This program is distributed in the hope that it will be useful,
++# but WITHOUT ANY WARRANTY; without even the implied warranty of
++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++# GNU General Public License for more details.
++#
++# You should have received a copy of the GNU General Public License
++# along with this program. If not, see <http://www.gnu.org/licenses/>.
++load_lib dwarf.exp
++
++# Note: Inspired from dw2-basic.exp.
++
++# This test can only be run on targets which support DWARF-2 and use gas.
++if {![dwarf2_support]} {
++ return 0
++}
++
++set testfile "dw2-typedef-children"
++set srcfile ${testfile}.S
++set binfile ${objdir}/${subdir}/${testfile}.x
++
++if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" object {nodebug}] != "" } {
++ return -1
++}
++
++gdb_exit
++gdb_start
++
++gdb_test "file $binfile" \
++ "warning: DW_TAG_typedef has childen - GCC PR debug/47510 bug - DIE at .*" \
++ "warning message"
+
5 files changed, 57 insertions(+), 1 deletions(-)
create mode 100755 gdb/gdb-add-index
-diff --git a/gdb/Makefile.in b/gdb/Makefile.in
-index 6dbb284..8210a2c 100644
---- a/gdb/Makefile.in
-+++ b/gdb/Makefile.in
-@@ -1018,7 +1018,16 @@ install-only: $(CONFIG_INSTALL) xml-syscall-install
+Index: gdb-7.2.50.20101116/gdb/Makefile.in
+===================================================================
+--- gdb-7.2.50.20101116.orig/gdb/Makefile.in 2010-11-16 08:03:17.000000000 +0100
++++ gdb-7.2.50.20101116/gdb/Makefile.in 2010-11-16 08:47:45.000000000 +0100
+@@ -986,7 +986,16 @@ install-only: install-gstack $(CONFIG_IN
$(SHELL) $(srcdir)/../mkinstalldirs \
$(DESTDIR)$(man1dir) ; \
$(INSTALL_DATA) $(srcdir)/gdb.1 \
@$(MAKE) DO=install "DODIRS=$(SUBDIRS)" $(FLAGS_TO_PASS) subdir_do
.PHONY: install-tui
install-tui:
-diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
-index 69141e3..457e6b4 100644
---- a/gdb/doc/gdb.texinfo
-+++ b/gdb/doc/gdb.texinfo
-@@ -15045,6 +15045,14 @@ There are currently some limitation on indices. They only work when
+Index: gdb-7.2.50.20101116/gdb/doc/gdb.texinfo
+===================================================================
+--- gdb-7.2.50.20101116.orig/gdb/doc/gdb.texinfo 2010-11-16 08:04:18.000000000 +0100
++++ gdb-7.2.50.20101116/gdb/doc/gdb.texinfo 2010-11-16 08:56:30.000000000 +0100
+@@ -15500,6 +15500,14 @@ There are currently some limitation on i
for DWARF debugging information, not stabs. And, they do not
currently work for programs using Ada.
+$ gdb-add-index symfile
+@end smallexample
+
-
@node Symbol Errors
@section Errors Reading Symbol Files
-diff --git a/gdb/gdb-add-index b/gdb/gdb-add-index
-new file mode 100755
-index 0000000..c9a03b0
---- /dev/null
-+++ b/gdb/gdb-add-index
+
+Index: gdb-7.2.50.20101116/gdb/gdb-add-index
+===================================================================
+--- /dev/null 1970-01-01 00:00:00.000000000 +0000
++++ gdb-7.2.50.20101116/gdb/gdb-add-index 2010-11-16 08:47:45.000000000 +0100
@@ -0,0 +1,30 @@
+#! /bin/sh
+
+fi
+
+exit 0
---
-1.6.2.5
-
--- /dev/null
+http://sourceware.org/ml/gdb-patches/2011-09/msg00450.html
+Subject: [patch 1/2] Code cleanup: Unify dwarf2_per_cu_addr_size, dwarf2_per_cu_offset_size
+
+Hi,
+
+this is more rather for patch 2/2, it has positive LoC change but still
+I would find it applicable even on its own.
+
+No functionality change intended.
+
+
+Thanks,
+Jan
+
+
+gdb/
+2011-09-26 Jan Kratochvil <jan.kratochvil@redhat.com>
+
+ Code cleanup.
+ * dwarf2read.c (per_cu_header_read_in): New function.
+ (dwarf2_per_cu_addr_size, dwarf2_per_cu_offset_size): Use it, with new
+ variables cu_header_local and cu_headerp.
+
+--- a/gdb/dwarf2read.c
++++ b/gdb/dwarf2read.c
+@@ -15187,26 +15187,42 @@ dwarf2_per_cu_objfile (struct dwarf2_per_cu_data *per_cu)
+ return objfile;
+ }
+
++/* Return comp_unit_head for PER_CU, either already available in PER_CU->CU
++ (CU_HEADERP is unused in such case) or prepare a temporary copy at
++ CU_HEADERP first. */
++
++static const struct comp_unit_head *
++per_cu_header_read_in (struct comp_unit_head *cu_headerp,
++ struct dwarf2_per_cu_data *per_cu)
++{
++ struct objfile *objfile;
++ struct dwarf2_per_objfile *per_objfile;
++ gdb_byte *info_ptr;
++
++ if (per_cu->cu)
++ return &per_cu->cu->header;
++
++ objfile = per_cu->objfile;
++ per_objfile = objfile_data (objfile, dwarf2_objfile_data_key);
++ info_ptr = per_objfile->info.buffer + per_cu->offset;
++
++ memset (cu_headerp, 0, sizeof (*cu_headerp));
++ read_comp_unit_head (cu_headerp, info_ptr, objfile->obfd);
++
++ return cu_headerp;
++}
++
+ /* Return the address size given in the compilation unit header for CU. */
+
+ CORE_ADDR
+ dwarf2_per_cu_addr_size (struct dwarf2_per_cu_data *per_cu)
+ {
+- if (per_cu->cu)
+- return per_cu->cu->header.addr_size;
+- else
+- {
+- /* If the CU is not currently read in, we re-read its header. */
+- struct objfile *objfile = per_cu->objfile;
+- struct dwarf2_per_objfile *per_objfile
+- = objfile_data (objfile, dwarf2_objfile_data_key);
+- gdb_byte *info_ptr = per_objfile->info.buffer + per_cu->offset;
+- struct comp_unit_head cu_header;
++ struct comp_unit_head cu_header_local;
++ const struct comp_unit_head *cu_headerp;
+
+- memset (&cu_header, 0, sizeof cu_header);
+- read_comp_unit_head (&cu_header, info_ptr, objfile->obfd);
+- return cu_header.addr_size;
+- }
++ cu_headerp = per_cu_header_read_in (&cu_header_local, per_cu);
++
++ return cu_headerp->addr_size;
+ }
+
+ /* Return the offset size given in the compilation unit header for CU. */
+@@ -15214,21 +15230,12 @@ dwarf2_per_cu_addr_size (struct dwarf2_per_cu_data *per_cu)
+ int
+ dwarf2_per_cu_offset_size (struct dwarf2_per_cu_data *per_cu)
+ {
+- if (per_cu->cu)
+- return per_cu->cu->header.offset_size;
+- else
+- {
+- /* If the CU is not currently read in, we re-read its header. */
+- struct objfile *objfile = per_cu->objfile;
+- struct dwarf2_per_objfile *per_objfile
+- = objfile_data (objfile, dwarf2_objfile_data_key);
+- gdb_byte *info_ptr = per_objfile->info.buffer + per_cu->offset;
+- struct comp_unit_head cu_header;
++ struct comp_unit_head cu_header_local;
++ const struct comp_unit_head *cu_headerp;
+
+- memset (&cu_header, 0, sizeof cu_header);
+- read_comp_unit_head (&cu_header, info_ptr, objfile->obfd);
+- return cu_header.offset_size;
+- }
++ cu_headerp = per_cu_header_read_in (&cu_header_local, per_cu);
++
++ return cu_headerp->offset_size;
+ }
+
+ /* Return the text offset of the CU. The returned offset comes from
+
--- /dev/null
+http://sourceware.org/ml/gdb-patches/2011-09/msg00451.html
+Subject: [patch 2/2] Fix DW_OP_GNU_implicit_pointer for DWARF32 v3+ on 64-bit arches
+
+Hi,
+
+on 64-bit targets DWARF-3+ is used DW_OP_GNU_implicit_pointer does not work.
+
+DWARF-2 says:
+ This type of reference (DW_FORM_ref_addr) is the size of an address on
+ the target architecture;
+DWARF-3 says:
+ 1.5.1 Upward Compatibility
+ References that use the attribute form DW_FORM_ref_addr are specified
+ to be four bytes in the DWARF 32-bit format and eight bytes in the
+ DWARF 64-bit format, while DWARF Version 2 specifies that such
+ references have the same size as an address on the target system (see
+ Sections 7.4 and 7.5.4).
+
+ (DW_FORM_ref_addr)
+ In the 32-bit DWARF format, this offset is a 4-byte unsigned value; in
+ the 64-bit DWARF format, it is an 8-byte unsigned value (see Section
+ 7.4).
+
+GDB currently parsed DW_OP_GNU_implicit_pointer the DWARF-2 way, being
+incompatible with DWARF-3+.
+
+I think DW_OP_GNU_implicit_pointer does not make sense to be used from
+.debug_frame (DWARF-5 is not yet released to say more) so for .debug_frame its
+use is just not permitted (the code would be more complicated otherwise).
+
+No regressions on {x86_64,x86_64-m32,i686}-fedora16pre-linux-gnu.
+
+
+Thanks,
+Jan
+
+
+gdb/
+2011-09-26 Jan Kratochvil <jan.kratochvil@redhat.com>
+
+ Fix DW_OP_GNU_implicit_pointer for DWARF32 v3+ on 64-bit arches.
+ * dwarf2-frame.c (execute_stack_op): Initialize ctx->ref_addr_size.
+ * dwarf2expr.c (execute_stack_op) <DW_OP_GNU_implicit_pointer>: Use
+ ctx->ref_addr_size. Handle its invalid value.
+ * dwarf2expr.h (struct dwarf_expr_context): New field ref_addr_size.
+ * dwarf2loc.c (dwarf2_evaluate_loc_desc_full)
+ (dwarf2_loc_desc_needs_frame): Initialize ctx->ref_addr_size.
+ * dwarf2loc.h (dwarf2_per_cu_ref_addr_size): New declaration.
+ * dwarf2read.c (decode_locdesc): Initialize ctx->ref_addr_size.
+ (dwarf2_per_cu_ref_addr_size): New function.
+
+gdb/testsuite/
+2011-09-26 Jan Kratochvil <jan.kratochvil@redhat.com>
+
+ Fix DW_OP_GNU_implicit_pointer for DWARF32 v3+ on 64-bit arches.
+ * gdb.dwarf2/implptr-64bit.S: New file.
+ * gdb.dwarf2/implptr-64bit.exp: New file.
+
+Index: gdb-7.3/gdb/dwarf2-frame.c
+===================================================================
+--- gdb-7.3.orig/gdb/dwarf2-frame.c 2011-03-18 19:52:30.000000000 +0100
++++ gdb-7.3/gdb/dwarf2-frame.c 2011-09-26 22:38:52.000000000 +0200
+@@ -397,6 +397,7 @@ execute_stack_op (const gdb_byte *exp, U
+
+ ctx->gdbarch = get_frame_arch (this_frame);
+ ctx->addr_size = addr_size;
++ ctx->ref_addr_size = -1;
+ ctx->offset = offset;
+ ctx->baton = this_frame;
+ ctx->read_reg = read_reg;
+Index: gdb-7.3/gdb/dwarf2expr.c
+===================================================================
+--- gdb-7.3.orig/gdb/dwarf2expr.c 2011-09-26 22:38:34.000000000 +0200
++++ gdb-7.3/gdb/dwarf2expr.c 2011-09-26 22:38:52.000000000 +0200
+@@ -539,10 +539,14 @@ execute_stack_op (struct dwarf_expr_cont
+ ULONGEST die;
+ LONGEST len;
+
++ if (ctx->ref_addr_size == -1)
++ error (_("DWARF-2 expression error: DW_OP_GNU_implicit_pointer "
++ "is not allowed in frame context"));
++
+ /* The referred-to DIE. */
+- ctx->len = extract_unsigned_integer (op_ptr, ctx->addr_size,
++ ctx->len = extract_unsigned_integer (op_ptr, ctx->ref_addr_size,
+ byte_order);
+- op_ptr += ctx->addr_size;
++ op_ptr += ctx->ref_addr_size;
+
+ /* The byte offset into the data. */
+ op_ptr = read_sleb128 (op_ptr, op_end, &len);
+Index: gdb-7.3/gdb/dwarf2expr.h
+===================================================================
+--- gdb-7.3.orig/gdb/dwarf2expr.h 2011-09-26 22:38:34.000000000 +0200
++++ gdb-7.3/gdb/dwarf2expr.h 2011-09-26 22:38:52.000000000 +0200
+@@ -78,6 +78,10 @@ struct dwarf_expr_context
+ /* Target address size in bytes. */
+ int addr_size;
+
++ /* DW_FORM_ref_addr size in bytes. If -1 DWARF is executed from a frame
++ context and operations depending on DW_FORM_ref_addr are not allowed. */
++ int ref_addr_size;
++
+ /* Offset used to relocate DW_OP_addr argument. */
+ CORE_ADDR offset;
+
+Index: gdb-7.3/gdb/dwarf2loc.c
+===================================================================
+--- gdb-7.3.orig/gdb/dwarf2loc.c 2011-09-26 22:38:34.000000000 +0200
++++ gdb-7.3/gdb/dwarf2loc.c 2011-09-26 22:39:12.000000000 +0200
+@@ -372,6 +372,7 @@ dwarf_expr_prep_ctx (struct frame_info *
+
+ ctx->gdbarch = get_objfile_arch (objfile);
+ ctx->addr_size = dwarf2_per_cu_addr_size (per_cu);
++ ctx->ref_addr_size = dwarf2_per_cu_ref_addr_size (per_cu);
+ ctx->offset = dwarf2_per_cu_text_offset (per_cu);
+ ctx->baton = &baton;
+ ctx->read_reg = dwarf_expr_read_reg;
+@@ -1507,6 +1508,7 @@ dwarf2_loc_desc_needs_frame (const gdb_b
+
+ ctx->gdbarch = get_objfile_arch (objfile);
+ ctx->addr_size = dwarf2_per_cu_addr_size (per_cu);
++ ctx->ref_addr_size = dwarf2_per_cu_ref_addr_size (per_cu);
+ ctx->offset = dwarf2_per_cu_text_offset (per_cu);
+ ctx->baton = &baton;
+ ctx->read_reg = needs_frame_read_reg;
+Index: gdb-7.3/gdb/dwarf2loc.h
+===================================================================
+--- gdb-7.3.orig/gdb/dwarf2loc.h 2011-09-26 22:38:34.000000000 +0200
++++ gdb-7.3/gdb/dwarf2loc.h 2011-09-26 22:38:52.000000000 +0200
+@@ -39,6 +39,10 @@ struct objfile *dwarf2_per_cu_objfile (s
+ /* Return the address size given in the compilation unit header for CU. */
+ CORE_ADDR dwarf2_per_cu_addr_size (struct dwarf2_per_cu_data *cu);
+
++/* Return the DW_FORM_ref_addr size given in the compilation unit header for
++ CU. */
++int dwarf2_per_cu_ref_addr_size (struct dwarf2_per_cu_data *cu);
++
+ /* Return the offset size given in the compilation unit header for CU. */
+ int dwarf2_per_cu_offset_size (struct dwarf2_per_cu_data *cu);
+
+Index: gdb-7.3/gdb/dwarf2read.c
+===================================================================
+--- gdb-7.3.orig/gdb/dwarf2read.c 2011-09-26 22:38:38.000000000 +0200
++++ gdb-7.3/gdb/dwarf2read.c 2011-09-26 22:38:52.000000000 +0200
+@@ -15277,6 +15277,22 @@ dwarf2_per_cu_offset_size (struct dwarf2
+ return cu_headerp->offset_size;
+ }
+
++/* See its dwarf2loc.h declaration. */
++
++int
++dwarf2_per_cu_ref_addr_size (struct dwarf2_per_cu_data *per_cu)
++{
++ struct comp_unit_head cu_header_local;
++ const struct comp_unit_head *cu_headerp;
++
++ cu_headerp = per_cu_header_read_in (&cu_header_local, per_cu);
++
++ if (cu_headerp->version == 2)
++ return cu_headerp->addr_size;
++ else
++ return cu_headerp->offset_size;
++}
++
+ /* Return the text offset of the CU. The returned offset comes from
+ this CU's objfile. If this objfile came from a separate debuginfo
+ file, then the offset may be different from the corresponding
+Index: gdb-7.3/gdb/testsuite/gdb.dwarf2/implptr-64bit.S
+===================================================================
+--- /dev/null 1970-01-01 00:00:00.000000000 +0000
++++ gdb-7.3/gdb/testsuite/gdb.dwarf2/implptr-64bit.S 2011-09-26 22:38:52.000000000 +0200
+@@ -0,0 +1,197 @@
++/* Copyright 2010, 2011 Free Software Foundation, Inc.
++
++ This program is free software; you can redistribute it and/or modify
++ it under the terms of the GNU General Public License as published by
++ the Free Software Foundation; either version 3 of the License, or
++ (at your option) any later version.
++
++ This program is distributed in the hope that it will be useful,
++ but WITHOUT ANY WARRANTY; without even the implied warranty of
++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ GNU General Public License for more details.
++
++ You should have received a copy of the GNU General Public License
++ along with this program. If not, see <http://www.gnu.org/licenses/>. */
++
++ .section .debug_info
++d:
++ /* Length of Compilation Unit Info */
++#if OFFSET_SIZE == 4
++# define OFFSET .4byte
++ .4byte debug_end - 1f
++#elif OFFSET_SIZE == 8
++# define OFFSET .8byte
++ .4byte 0xffffffff
++ .8byte debug_end - 1f
++#else
++# error
++#endif
++#if ADDR_SIZE == 4
++# define ADDR .4byte
++#elif ADDR_SIZE == 8
++# define ADDR .8byte
++#else
++# error
++#endif
++#if REF_ADDR_SIZE == 4
++# define REF_ADDR .4byte
++#elif REF_ADDR_SIZE == 8
++# define REF_ADDR .8byte
++#else
++# error
++#endif
++1:
++ .2byte DWARF_VERSION /* DWARF version number */
++ OFFSET .Ldebug_abbrev0 /* Offset Into Abbrev. Section */
++ .byte ADDR_SIZE /* Pointer Size (in bytes) */
++
++ .uleb128 0x1 /* (DIE (0xb) DW_TAG_compile_unit) */
++ .ascii "GNU C 4.4.3\0" /* DW_AT_producer */
++ .byte 0x1 /* DW_AT_language */
++ .ascii "1.c\0" /* DW_AT_name */
++
++.Ltype_int:
++ .uleb128 0x7 /* DW_TAG_base_type */
++ .byte 0x4 /* DW_AT_byte_size */
++ .byte 0x5 /* DW_AT_encoding */
++ .ascii "int\0" /* DW_AT_name */
++
++.Ltype_struct:
++ .uleb128 0x2 /* DW_TAG_structure_type */
++ .ascii "s\0" /* DW_AT_name */
++ .byte 4 /* DW_AT_byte_size */
++
++ .uleb128 0x3 /* DW_TAG_member */
++ .ascii "f\0" /* DW_AT_name */
++ .4byte .Ltype_int - d /* DW_AT_type */
++ .byte 0 /* DW_AT_data_member_location */
++
++ .byte 0x0 /* end of children of DW_TAG_structure_type */
++
++ .uleb128 6 /* Abbrev: DW_TAG_subprogram */
++ .ascii "main\0" /* DW_AT_name */
++ ADDR main /* DW_AT_low_pc */
++ ADDR main + 0x100 /* DW_AT_high_pc */
++ .4byte .Ltype_int - d /* DW_AT_type */
++ .byte 1 /* DW_AT_external */
++
++.Ltype_structptr:
++ .uleb128 0x5 /* DW_TAG_pointer_type */
++ .byte ADDR_SIZE /* DW_AT_byte_size */
++ .4byte .Ltype_struct - d /* DW_AT_type */
++
++.Lvar_out:
++ .uleb128 0x4 /* (DW_TAG_variable) */
++ .ascii "v\0" /* DW_AT_name */
++ .byte 2f - 1f /* DW_AT_location: DW_FORM_block1 */
++1:
++ .byte 0x9e /* DW_OP_implicit_value */
++ .uleb128 2f - 3f
++3:
++ .byte 1, 1, 1, 1
++2:
++ .4byte .Ltype_struct - d /* DW_AT_type */
++
++ .uleb128 0x4 /* (DW_TAG_variable) */
++ .ascii "p\0" /* DW_AT_name */
++ .byte 2f - 1f /* DW_AT_location: DW_FORM_block1 */
++1:
++ .byte 0xf2 /* DW_OP_GNU_implicit_pointer */
++ REF_ADDR .Lvar_out - d /* referenced DIE */
++ .sleb128 0 /* offset */
++2:
++ .4byte .Ltype_structptr - d /* DW_AT_type */
++
++ .byte 0x0 /* end of children of main */
++
++ .byte 0x0 /* end of children of CU */
++debug_end:
++
++ .section .debug_abbrev
++.Ldebug_abbrev0:
++
++ .uleb128 0x1 /* (abbrev code) */
++ .uleb128 0x11 /* (TAG: DW_TAG_compile_unit) */
++ .byte 0x1 /* DW_children_yes */
++ .uleb128 0x25 /* (DW_AT_producer) */
++ .uleb128 0x8 /* (DW_FORM_string) */
++ .uleb128 0x13 /* (DW_AT_language) */
++ .uleb128 0xb /* (DW_FORM_data1) */
++ .uleb128 0x3 /* (DW_AT_name) */
++ .uleb128 0x8 /* (DW_FORM_string) */
++ .byte 0x0
++ .byte 0x0
++
++ .uleb128 0x2 /* (abbrev code) */
++ .uleb128 0x13 /* (TAG: DW_TAG_structure_type) */
++ .byte 0x1 /* DW_children_yes */
++ .uleb128 0x3 /* (DW_AT_name) */
++ .uleb128 0x8 /* (DW_FORM_string) */
++ .uleb128 0xb /* (DW_AT_byte_size) */
++ .uleb128 0xb /* (DW_FORM_data1) */
++ .byte 0
++ .byte 0
++
++ .uleb128 0x3 /* (abbrev code) */
++ .uleb128 0xd /* (TAG: DW_TAG_member) */
++ .byte 0 /* DW_children_no */
++ .uleb128 0x3 /* (DW_AT_name) */
++ .uleb128 0x8 /* (DW_FORM_string) */
++ .uleb128 0x49 /* (DW_AT_type) */
++ .uleb128 0x13 /* (DW_FORM_ref4) */
++ .uleb128 0x38 /* (DW_AT_data_member_location) */
++ .uleb128 0xb /* (DW_FORM_data1) */
++ .byte 0
++ .byte 0
++
++ .uleb128 0x4 /* (abbrev code) */
++ .uleb128 0x34 /* (TAG: DW_TAG_variable) */
++ .byte 0x0 /* DW_children_yes */
++ .uleb128 0x3 /* (DW_AT_name) */
++ .uleb128 0x8 /* (DW_FORM_string) */
++ .uleb128 0x02 /* (DW_AT_location) */
++ .uleb128 0xa /* (DW_FORM_block1) */
++ .uleb128 0x49 /* (DW_AT_type) */
++ .uleb128 0x13 /* (DW_FORM_ref4) */
++ .byte 0x0
++ .byte 0x0
++
++ .uleb128 0x5 /* (abbrev code) */
++ .uleb128 0xf /* (TAG: DW_TAG_pointer_type) */
++ .byte 0x0 /* DW_children_no */
++ .uleb128 0xb /* (DW_AT_byte_size) */
++ .uleb128 0xb /* (DW_FORM_data1) */
++ .uleb128 0x49 /* (DW_AT_type) */
++ .uleb128 0x13 /* (DW_FORM_ref4) */
++ .byte 0x0
++ .byte 0x0
++
++ .uleb128 6 /* Abbrev code */
++ .uleb128 0x2e /* DW_TAG_subprogram */
++ .byte 1 /* has_children */
++ .uleb128 0x3 /* DW_AT_name */
++ .uleb128 0x8 /* DW_FORM_string */
++ .uleb128 0x11 /* DW_AT_low_pc */
++ .uleb128 0x1 /* DW_FORM_addr */
++ .uleb128 0x12 /* DW_AT_high_pc */
++ .uleb128 0x1 /* DW_FORM_addr */
++ .uleb128 0x49 /* DW_AT_type */
++ .uleb128 0x13 /* DW_FORM_ref4 */
++ .uleb128 0x3f /* DW_AT_external */
++ .uleb128 0xc /* DW_FORM_flag */
++ .byte 0x0 /* Terminator */
++ .byte 0x0 /* Terminator */
++
++ .uleb128 0x7 /* (abbrev code) */
++ .uleb128 0x24 /* (TAG: DW_TAG_base_type) */
++ .byte 0 /* DW_children_no */
++ .uleb128 0xb /* (DW_AT_byte_size) */
++ .uleb128 0xb /* (DW_FORM_data1) */
++ .uleb128 0x3e /* (DW_AT_encoding) */
++ .uleb128 0xb /* (DW_FORM_data1) */
++ .uleb128 0x3 /* (DW_AT_name) */
++ .uleb128 0x8 /* (DW_FORM_string) */
++ .byte 0
++ .byte 0
++
++ .byte 0x0
+Index: gdb-7.3/gdb/testsuite/gdb.dwarf2/implptr-64bit.exp
+===================================================================
+--- /dev/null 1970-01-01 00:00:00.000000000 +0000
++++ gdb-7.3/gdb/testsuite/gdb.dwarf2/implptr-64bit.exp 2011-09-26 22:38:52.000000000 +0200
+@@ -0,0 +1,51 @@
++# Copyright 2011 Free Software Foundation, Inc.
++
++# This program is free software; you can redistribute it and/or modify
++# it under the terms of the GNU General Public License as published by
++# the Free Software Foundation; either version 3 of the License, or
++# (at your option) any later version.
++#
++# This program is distributed in the hope that it will be useful,
++# but WITHOUT ANY WARRANTY; without even the implied warranty of
++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++# GNU General Public License for more details.
++#
++# You should have received a copy of the GNU General Public License
++# along with this program. If not, see <http://www.gnu.org/licenses/>.
++load_lib dwarf.exp
++
++# This test can only be run on targets which support DWARF-2 and use gas.
++if {![dwarf2_support]} {
++ return 0
++}
++
++set testfile "implptr-64bit"
++set srcfile ${testfile}.S
++set mainfile main.c
++
++proc test { dwarf_version offset_size addr_size ref_addr_size } {
++ global testfile srcfile mainfile
++
++ set opts {}
++ foreach n { dwarf_version offset_size addr_size ref_addr_size } {
++ lappend opts "additional_flags=-D[string toupper $n]=[expr "\$$n"]"
++ }
++
++ set name "d${dwarf_version}o${offset_size}a${addr_size}r${ref_addr_size}"
++ set executable ${testfile}-${name}
++ if [prepare_for_testing ${testfile}.exp $executable "${srcfile} ${mainfile}" $opts] {
++ return -1
++ }
++
++ if ![runto_main] {
++ return -1
++ }
++
++ gdb_test "p/x p->f" " = 0x1010101" $name
++}
++
++# DWARF_VERSION OFFSET_SIZE ADDR_SIZE REF_ADDR_SIZE
++test 2 8 4 4
++test 2 4 8 8
++test 3 8 4 8
++test 3 4 8 4
--- /dev/null
+http://sourceware.org/ml/gdb-patches/2011-02/msg00630.html
+Subject: [patch] [i386] Fix {,un}prelinked libraries for attach/core-load
+
+Hi,
+
+please see comments in the patch. The adjusted testcase FAILs on i386.
+
+"Prelink", March 4, 2004 - by Jakub Jelinek:
+ http://people.redhat.com/jakub/prelink.pdf
+ primarily section 7 - REL to RELA conversion
+
+An example of unprelinked -> prelinked library change:
+ Program Headers:
+ Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align
+- LOAD 0x000000 0x00000000 0x00000000 0x00538 0x00538 R E 0x1000
+- LOAD 0x000538 0x00001538 0x00001538 0x00100 0x00110 RW 0x1000
+- DYNAMIC 0x000550 0x00001550 0x00001550 0x000c8 0x000c8 RW 0x4
+- NOTE 0x0000f4 0x000000f4 0x000000f4 0x00024 0x00024 R 0x4
+- GNU_EH_FRAME 0x0004e8 0x000004e8 0x000004e8 0x00014 0x00014 R 0x4
++ LOAD 0x000000 0x411b3000 0x411b3000 0x00558 0x00558 R E 0x1000
++ LOAD 0x000558 0x411b4558 0x411b4558 0x00100 0x00110 RW 0x1000
++ DYNAMIC 0x000570 0x411b4570 0x411b4570 0x000c8 0x000c8 RW 0x4
++ NOTE 0x0000f4 0x411b30f4 0x411b30f4 0x00024 0x00024 R 0x4
++ GNU_EH_FRAME 0x000508 0x411b3508 0x411b3508 0x00014 0x00014 R 0x4
+ GNU_STACK 0x000000 0x00000000 0x00000000 0x00000 0x00000 RW 0x4
+
+So far GDB expected all such displacements will be always PAGE_SIZE aligned.
+This applies for example for re-prelinking of an already prelinked file.
+But it does not apply for prelinking of an unprelinked file or unprelinking of
+a prelinked file, there can be arbitrary displacement.
+
+It affects i386 (=i686, prelink doc reports also ARM and MIPS) which uses REL.
+x86_64 always uses RELA, therefore I have not noticed it so far. i386 still
+has to be supported.
+
+This affects both attachment to a PID and core file loads.
+
+This applies in real world if you transfer a core file between hosts and try to
+backtrace them, libraries of both hosts may differ whether they are / are not
+prelinked.
+
+I could implement some (displacement-forgiving and prelink-modifications
+forgiving) comparison of both DYNAMIC segments found. But I do not think it is
+useful, if the DYNAMIC address from linkmap vs. bfd do not match it is still a
+better chance to try a displacement to make them match. Keeping the file
+relocation cannot work anyway when the DYNAMIC address is verified as wrong.
+
+No regressions on {x86_64,x86_64-m32,i686}-fedora15-linux-gnu.
+
+Mostly do you agree the DYNAMIC content does not have to be verifed?
+Do you have any comments on the in-code long comments?
+
+
+Thanks,
+Jan
+
+
+gdb/
+2011-02-22 Jan Kratochvil <jan.kratochvil@redhat.com>
+
+ Fix libraries displacement if they change whether they were prelinked.
+ * solib-svr4.c (LM_ADDR_CHECK): Set L_ADDR even if the DYNAMIC pointer
+ does not match. Comment why.
+
+gdb/testsuite/
+2011-02-22 Jan Kratochvil <jan.kratochvil@redhat.com>
+
+ * gdb.base/break-interp-lib.c (v, vptr): New variables.
+ * gdb.base/break-interp.exp (test_attach): New comment.
+
+--- a/gdb/solib-svr4.c
++++ b/gdb/solib-svr4.c
+@@ -237,11 +237,11 @@ LM_ADDR_CHECK (struct so_list *so, bfd *abfd)
+
+ Even on PPC it must be zero-aligned at least for MINPAGESIZE. */
+
++ l_addr = l_dynaddr - dynaddr;
++
+ if ((l_addr & (minpagesize - 1)) == 0
+ && (l_addr & align) == ((l_dynaddr - dynaddr) & align))
+ {
+- l_addr = l_dynaddr - dynaddr;
+-
+ if (info_verbose)
+ printf_unfiltered (_("Using PIC (Position Independent Code) "
+ "prelink displacement %s for \"%s\".\n"),
+@@ -249,9 +249,20 @@ LM_ADDR_CHECK (struct so_list *so, bfd *abfd)
+ so->so_name);
+ }
+ else
+- warning (_(".dynamic section for \"%s\" "
+- "is not at the expected address "
+- "(wrong library or version mismatch?)"), so->so_name);
++ {
++ /* There is no way to verify the library file matches. prelink
++ can during prelinking of an unprelinked file (or unprelinking
++ of a prelinked file) shift the DYNAMIC segment by arbitrary
++ offset without any page size alignment. There is no way to
++ find out the ELF header and/or Program Headers for a limited
++ verification if it they match. One could do a verification
++ of the DYNAMIC segment. Still the found address is the best
++ one GDB could find. */
++
++ warning (_(".dynamic section for \"%s\" "
++ "is not at the expected address "
++ "(wrong library or version mismatch?)"), so->so_name);
++ }
+ }
+
+ set_addr:
+--- a/gdb/testsuite/gdb.base/break-interp-lib.c
++++ b/gdb/testsuite/gdb.base/break-interp-lib.c
+@@ -20,6 +20,10 @@
+ #include <assert.h>
+ #include <stdio.h>
+
++/* Force REL->RELA conversion on i386, see "Prelink", March 4, 2004. */
++volatile int v[2];
++volatile int *vptr = &v[1];
++
+ void
+ libfunc (const char *action)
+ {
+--- a/gdb/testsuite/gdb.base/break-interp.exp
++++ b/gdb/testsuite/gdb.base/break-interp.exp
+@@ -352,6 +352,14 @@ proc test_attach {file displacement {relink_args ""}} {
+ # test simplicity, we merged this test and the test above by not
+ # restoring $INTERP after $EXEC prelink. $INTERP gets restored
+ # later below.
++ #
++ # `(wrong library or version mismatch?)' messages are printed for
++ # $binfile_lib on platforms converting REL->RELA relocations by
++ # prelink (such as on i386). There is no reliable way to verify
++ # the library file matches the running library in such case but
++ # GDB at least attempts to set the right displacement. We test
++ # `libfunc' is present in the backtrace and therefore the
++ # displacement has been guessed right.
+
+ if [prelink$relink $relink_args [file tail $exec]] {
+ # /proc/PID/exe cannot be loaded as it is "EXECNAME (deleted)".
+
--- /dev/null
+gdb/linux-nat.c:
+- Workaround RHEL-5 kernels for detaching SIGSTOPped processes (BZ 498595).
+
+Index: gdb-7.2.50.20110328/gdb/elfread.c
+===================================================================
+--- gdb-7.2.50.20110328.orig/gdb/elfread.c 2011-03-28 18:46:16.000000000 +0200
++++ gdb-7.2.50.20110328/gdb/elfread.c 2011-03-28 18:48:19.000000000 +0200
+@@ -1083,7 +1083,7 @@ elf_gnu_ifunc_resolver_return_stop (stru
+ #define BUILD_ID_VERBOSE_NONE 0
+ #define BUILD_ID_VERBOSE_FILENAMES 1
+ #define BUILD_ID_VERBOSE_BINARY_PARSE 2
+-static int build_id_verbose = BUILD_ID_VERBOSE_FILENAMES;
++static int build_id_verbose = BUILD_ID_VERBOSE_NONE;
+ static void
+ show_build_id_verbose (struct ui_file *file, int from_tty,
+ struct cmd_list_element *c, const char *value)
+@@ -2173,8 +2173,10 @@ find_separate_debug_file_by_buildid (str
+ if (build_id_name != NULL
+ && filename_cmp (build_id_name, objfile->name) == 0)
+ {
++#if 0 /* RHEL-5 backward behavior compatibility. */
+ warning (_("\"%s\": separate debug info file has no debug info"),
+ build_id_name);
++#endif
+ xfree (build_id_name);
+ }
+ else if (build_id_name != NULL)
+Index: gdb-7.2.50.20110328/gdb/corelow.c
+===================================================================
+--- gdb-7.2.50.20110328.orig/gdb/corelow.c 2011-03-28 18:46:16.000000000 +0200
++++ gdb-7.2.50.20110328/gdb/corelow.c 2011-03-28 18:47:56.000000000 +0200
+@@ -282,7 +282,7 @@ add_to_thread_list (bfd *abfd, asection
+ inferior_ptid = ptid; /* Yes, make it current. */
+ }
+
+-static int build_id_core_loads = 1;
++static int build_id_core_loads = 0;
+
+ static void
+ build_id_locate_exec (int from_tty)
+Index: gdb-7.2.50.20110328/gdb/linux-nat.c
+===================================================================
+--- gdb-7.2.50.20110328.orig/gdb/linux-nat.c 2011-03-28 18:46:16.000000000 +0200
++++ gdb-7.2.50.20110328/gdb/linux-nat.c 2011-03-28 18:47:56.000000000 +0200
+@@ -1774,8 +1774,22 @@ get_pending_status (struct lwp_info *lp,
+ target_signal_to_string (signo));
+ }
+
+- if (*status == 0 && GET_PID (lp->ptid) == pid_was_stopped)
+- *status = W_STOPCODE (SIGSTOP);
++ /* Workaround RHEL-5 kernel which has unreliable PTRACE_DETACH, SIGSTOP (that
++ many TIDs are left unstopped). See RH Bug 496732. */
++ if (GET_PID (lp->ptid) == pid_was_stopped)
++ {
++ int err;
++
++ errno = 0;
++ err = kill_lwp (GET_LWP (lp->ptid), SIGSTOP);
++ if (debug_linux_nat)
++ {
++ fprintf_unfiltered (gdb_stdlog,
++ "SC: lwp kill %d %s\n",
++ err,
++ errno ? safe_strerror (errno) : "ERRNO-OK");
++ }
++ }
+
+ return 0;
+ }
--- /dev/null
+Some functionality is available on RHEL-5.4+ only with gcc44 and gfortran44 as
+the default gcc and gfortran binaries are from gcc-4.1.
+
+Index: gdb-7.2.50.20101116/gdb/testsuite/gdb.base/vla.exp
+===================================================================
+--- gdb-7.2.50.20101116.orig/gdb/testsuite/gdb.base/vla.exp 2010-11-16 09:26:50.000000000 +0100
++++ gdb-7.2.50.20101116/gdb/testsuite/gdb.base/vla.exp 2010-11-16 09:27:20.000000000 +0100
+@@ -16,7 +16,25 @@
+ set testfile vla
+ set srcfile ${testfile}.c
+ set binfile ${objdir}/${subdir}/${testfile}
+-if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
++# Temporarily provide compiler=gcc44 saving the original value around.
++
++set board [target_info name]
++if [board_info $board exists compiler] {
++ set old_compiler [board_info $board compiler]
++ unset_board_info compiler
++} elseif [info exists old_compiler] {
++ unset old_compiler
++}
++set_board_info compiler gcc44
++
++set err [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug quiet}]
++
++unset_board_info compiler
++if [info exists old_compiler] {
++ set_board_info compiler $old_compiler
++}
++
++if { $err != "" } {
+ untested "Couldn't compile test program"
+ return -1
+ }
+Index: gdb-7.2.50.20101116/gdb/testsuite/gdb.base/break-interp.exp
+===================================================================
+--- gdb-7.2.50.20101116.orig/gdb/testsuite/gdb.base/break-interp.exp 2010-10-12 20:41:06.000000000 +0200
++++ gdb-7.2.50.20101116/gdb/testsuite/gdb.base/break-interp.exp 2010-11-16 09:28:40.000000000 +0100
+@@ -33,9 +33,29 @@ if [get_compiler_info ${binfile_lib}] {
+ return -1
+ }
+
++# Temporarily provide compiler=gcc44 saving the original value around.
++# RHEL-5 workaround of its:
++# gcc: -soname: linker input file unused because linking not done
++
++set board [target_info name]
++if [board_info $board exists compiler] {
++ set old_compiler [board_info $board compiler]
++ unset_board_info compiler
++} elseif [info exists old_compiler] {
++ unset old_compiler
++}
++set_board_info compiler gcc44
++
+ # Use -soname so that the new library gets copied by build_executable_own_libs.
+
+-if {[gdb_compile_shlib ${srcdir}/${subdir}/${srcfile_lib} ${binfile_lib} [list debug ldflags=-Wl,-soname,${test}.so]] != ""} {
++set err [gdb_compile_shlib ${srcdir}/${subdir}/${srcfile_lib} ${binfile_lib} [list debug ldflags=-Wl,-soname,${test}.so]]
++
++unset_board_info compiler
++if [info exists old_compiler] {
++ set_board_info compiler $old_compiler
++}
++
++if { $err != "" } {
+ return -1
+ }
+
+Index: gdb-7.2.50.20101116/gdb/testsuite/gdb.fortran/common-block.exp
+===================================================================
+--- gdb-7.2.50.20101116.orig/gdb/testsuite/gdb.fortran/common-block.exp 2010-11-16 09:26:54.000000000 +0100
++++ gdb-7.2.50.20101116/gdb/testsuite/gdb.fortran/common-block.exp 2010-11-16 09:27:20.000000000 +0100
+@@ -20,7 +20,25 @@ set testfile "common-block"
+ set srcfile ${testfile}.f90
+ set binfile ${objdir}/${subdir}/${testfile}
+
+-if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug f77 quiet}] != "" } {
++# Temporarily provide f77compiler=gfortran44 saving the original value around.
++
++set board [target_info name]
++if [board_info $board exists f77compiler] {
++ set old_f77compiler [board_info $board f77compiler]
++ unset_board_info f77compiler
++} elseif [info exists old_f77compiler] {
++ unset old_f77compiler
++}
++set_board_info f77compiler gfortran44
++
++set err [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug f77 quiet}]
++
++unset_board_info f77compiler
++if [info exists old_f77compiler] {
++ set_board_info f77compiler $old_f77compiler
++}
++
++if { $err != "" } {
+ untested "Couldn't compile ${srcfile}"
+ return -1
+ }
+Index: gdb-7.2.50.20101116/gdb/testsuite/gdb.fortran/dwarf-stride.exp
+===================================================================
+--- gdb-7.2.50.20101116.orig/gdb/testsuite/gdb.fortran/dwarf-stride.exp 2010-11-16 09:26:50.000000000 +0100
++++ gdb-7.2.50.20101116/gdb/testsuite/gdb.fortran/dwarf-stride.exp 2010-11-16 09:27:20.000000000 +0100
+@@ -27,7 +27,25 @@
+ set testfile dwarf-stride
+ set srcfile ${testfile}.f90
+
+-if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} {debug f77}] } {
++# Temporarily provide f77compiler=gfortran44 saving the original value around.
++
++set board [target_info name]
++if [board_info $board exists f77compiler] {
++ set old_f77compiler [board_info $board f77compiler]
++ unset_board_info f77compiler
++} elseif [info exists old_f77compiler] {
++ unset old_f77compiler
++}
++set_board_info f77compiler gfortran44
++
++set err [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} {debug f77}]
++
++unset_board_info f77compiler
++if [info exists old_f77compiler] {
++ set_board_info f77compiler $old_f77compiler
++}
++
++if $err {
+ return -1
+ }
+
+Index: gdb-7.2.50.20101116/gdb/testsuite/gdb.fortran/dynamic.exp
+===================================================================
+--- gdb-7.2.50.20101116.orig/gdb/testsuite/gdb.fortran/dynamic.exp 2010-11-16 09:26:50.000000000 +0100
++++ gdb-7.2.50.20101116/gdb/testsuite/gdb.fortran/dynamic.exp 2010-11-16 09:27:20.000000000 +0100
+@@ -25,7 +25,25 @@ set testfile "dynamic"
+ set srcfile ${testfile}.f90
+ set binfile ${objdir}/${subdir}/${testfile}
+
+-if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug f77 quiet}] != "" } {
++# Temporarily provide f77compiler=gfortran44 saving the original value around.
++
++set board [target_info name]
++if [board_info $board exists f77compiler] {
++ set old_f77compiler [board_info $board f77compiler]
++ unset_board_info f77compiler
++} elseif [info exists old_f77compiler] {
++ unset old_f77compiler
++}
++set_board_info f77compiler gfortran44
++
++set err [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug f77 quiet}]
++
++unset_board_info f77compiler
++if [info exists old_f77compiler] {
++ set_board_info f77compiler $old_f77compiler
++}
++
++if { $err != "" } {
+ untested "Couldn't compile ${srcfile}"
+ return -1
+ }
+Index: gdb-7.2.50.20101116/gdb/testsuite/gdb.fortran/library-module.exp
+===================================================================
+--- gdb-7.2.50.20101116.orig/gdb/testsuite/gdb.fortran/library-module.exp 2010-06-03 00:41:56.000000000 +0200
++++ gdb-7.2.50.20101116/gdb/testsuite/gdb.fortran/library-module.exp 2010-11-16 09:27:20.000000000 +0100
+@@ -25,16 +25,34 @@ if [get_compiler_info not-used] {
+ return -1
+ }
+
+-if { [gdb_compile_shlib "${srcdir}/${subdir}/${srclibfile}" $objdir/$subdir/$libfile {debug f77}] != "" } {
+- untested "Couldn't compile ${srclibfile}"
+- return -1
++# Temporarily provide f77compiler=gfortran44 saving the original value around.
++
++set board [target_info name]
++if [board_info $board exists f77compiler] {
++ set old_f77compiler [board_info $board f77compiler]
++ unset_board_info f77compiler
++} elseif [info exists old_f77compiler] {
++ unset old_f77compiler
+ }
++set_board_info f77compiler gfortran44
+
+ # prepare_for_testing cannot be used as linking with $libfile cannot be passed
+ # just for the linking phase (and not the source compilation phase). And any
+ # warnings on ignored $libfile abort the process.
+
+-if { [gdb_compile [list $srcdir/$subdir/$srcfile $objdir/$subdir/$libfile] $objdir/$subdir/$binfile executable {debug f77}] != "" } {
++set err1 [gdb_compile_shlib "${srcdir}/${subdir}/${srclibfile}" $objdir/$subdir/$libfile {debug f77}]
++set err2 [gdb_compile [list $srcdir/$subdir/$srcfile $objdir/$subdir/$libfile] $objdir/$subdir/$binfile executable {debug f77}]
++
++unset_board_info f77compiler
++if [info exists old_f77compiler] {
++ set_board_info f77compiler $old_f77compiler
++}
++
++if { $err1 != "" } {
++ untested "Couldn't compile ${srclibfile}"
++ return -1
++}
++if { $err2 != "" } {
+ untested "Couldn't compile ${srcfile}"
+ return -1
+ }
+Index: gdb-7.2.50.20101116/gdb/testsuite/gdb.fortran/module.exp
+===================================================================
+--- gdb-7.2.50.20101116.orig/gdb/testsuite/gdb.fortran/module.exp 2010-09-22 21:22:44.000000000 +0200
++++ gdb-7.2.50.20101116/gdb/testsuite/gdb.fortran/module.exp 2010-11-16 09:27:20.000000000 +0100
+@@ -16,7 +16,25 @@
+ set testfile "module"
+ set srcfile ${testfile}.f90
+
+-if { [prepare_for_testing $testfile.exp $testfile $srcfile {debug f77}] } {
++# Temporarily provide f77compiler=gfortran44 saving the original value around.
++
++set board [target_info name]
++if [board_info $board exists f77compiler] {
++ set old_f77compiler [board_info $board f77compiler]
++ unset_board_info f77compiler
++} elseif [info exists old_f77compiler] {
++ unset old_f77compiler
++}
++set_board_info f77compiler gfortran44
++
++set err [prepare_for_testing $testfile.exp $testfile $srcfile {debug f77}]
++
++unset_board_info f77compiler
++if [info exists old_f77compiler] {
++ set_board_info f77compiler $old_f77compiler
++}
++
++if $err {
+ return -1
+ }
+
+Index: gdb-7.2.50.20101116/gdb/testsuite/gdb.fortran/string.exp
+===================================================================
+--- gdb-7.2.50.20101116.orig/gdb/testsuite/gdb.fortran/string.exp 2010-11-16 09:26:50.000000000 +0100
++++ gdb-7.2.50.20101116/gdb/testsuite/gdb.fortran/string.exp 2010-11-16 09:27:20.000000000 +0100
+@@ -23,7 +23,25 @@ set testfile "string"
+ set srcfile ${testfile}.f90
+ set binfile ${objdir}/${subdir}/${testfile}
+
+-if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug f77 quiet}] != "" } {
++# Temporarily provide f77compiler=gfortran44 saving the original value around.
++
++set board [target_info name]
++if [board_info $board exists f77compiler] {
++ set old_f77compiler [board_info $board f77compiler]
++ unset_board_info f77compiler
++} elseif [info exists old_f77compiler] {
++ unset old_f77compiler
++}
++set_board_info f77compiler gfortran44
++
++set err [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug f77 quiet}]
++
++unset_board_info f77compiler
++if [info exists old_f77compiler] {
++ set_board_info f77compiler $old_f77compiler
++}
++
++if { $err != "" } {
+ untested "Couldn't compile ${srcfile}"
+ return -1
+ }
+Index: gdb-7.2.50.20101116/gdb/testsuite/gdb.fortran/omp-step.exp
+===================================================================
+--- gdb-7.2.50.20101116.orig/gdb/testsuite/gdb.fortran/omp-step.exp 2010-11-16 09:26:54.000000000 +0100
++++ gdb-7.2.50.20101116/gdb/testsuite/gdb.fortran/omp-step.exp 2010-11-16 09:27:20.000000000 +0100
+@@ -15,7 +15,26 @@
+
+ set testfile "omp-step"
+ set srcfile ${testfile}.f90
+-if { [prepare_for_testing $testfile.exp $testfile $srcfile {debug f77 additional_flags=-fopenmp}] } {
++
++# Temporarily provide f77compiler=gfortran44 saving the original value around.
++
++set board [target_info name]
++if [board_info $board exists f77compiler] {
++ set old_f77compiler [board_info $board f77compiler]
++ unset_board_info f77compiler
++} elseif [info exists old_f77compiler] {
++ unset old_f77compiler
++}
++set_board_info f77compiler gfortran44
++
++set err [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} {debug f77 additional_flags=-fopenmp}]
++
++unset_board_info f77compiler
++if [info exists old_f77compiler] {
++ set_board_info f77compiler $old_f77compiler
++}
++
++if $err {
+ return -1
+ }
+
+Index: gdb-7.2.50.20101116/gdb/testsuite/gdb.fortran/derived-type.exp
+===================================================================
+--- gdb-7.2.50.20101116.orig/gdb/testsuite/gdb.fortran/derived-type.exp 2010-01-01 08:32:02.000000000 +0100
++++ gdb-7.2.50.20101116/gdb/testsuite/gdb.fortran/derived-type.exp 2010-11-16 09:27:20.000000000 +0100
+@@ -28,8 +28,26 @@ set testfile "derived-type"
+ set srcfile ${testfile}.f90
+ set binfile ${objdir}/${subdir}/${testfile}
+
+-if {[gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" \
+- executable {debug f77}] != ""} {
++# Temporarily provide f77compiler=gfortran44 saving the original value around.
++
++set board [target_info name]
++if [board_info $board exists f77compiler] {
++ set old_f77compiler [board_info $board f77compiler]
++ unset_board_info f77compiler
++} elseif [info exists old_f77compiler] {
++ unset old_f77compiler
++}
++set_board_info f77compiler gfortran44
++
++set err [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" \
++ executable {debug f77}]
++
++unset_board_info f77compiler
++if [info exists old_f77compiler] {
++ set_board_info f77compiler $old_f77compiler
++}
++
++if { $err != "" } {
+ return -1
+ }
+
+Index: gdb-7.2.50.20101116/gdb/testsuite/gdb.fortran/subarray.exp
+===================================================================
+--- gdb-7.2.50.20101116.orig/gdb/testsuite/gdb.fortran/subarray.exp 2010-01-01 08:32:02.000000000 +0100
++++ gdb-7.2.50.20101116/gdb/testsuite/gdb.fortran/subarray.exp 2010-11-16 09:27:20.000000000 +0100
+@@ -28,8 +28,26 @@ set testfile "subarray"
+ set srcfile ${testfile}.f
+ set binfile ${objdir}/${subdir}/${testfile}
+
+-if {[gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" \
+- executable {debug f77}] != ""} {
++# Temporarily provide f77compiler=gfortran44 saving the original value around.
++
++set board [target_info name]
++if [board_info $board exists f77compiler] {
++ set old_f77compiler [board_info $board f77compiler]
++ unset_board_info f77compiler
++} elseif [info exists old_f77compiler] {
++ unset old_f77compiler
++}
++set_board_info f77compiler gfortran44
++
++set err [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" \
++ executable {debug f77}]
++
++unset_board_info f77compiler
++if [info exists old_f77compiler] {
++ set_board_info f77compiler $old_f77compiler
++}
++
++if { $err != "" } {
+ return -1
+ }
+
+Index: gdb-7.2.50.20101116/gdb/testsuite/gdb.threads/tls-sepdebug.exp
+===================================================================
+--- gdb-7.2.50.20101116.orig/gdb/testsuite/gdb.threads/tls-sepdebug.exp 2010-11-16 09:26:51.000000000 +0100
++++ gdb-7.2.50.20101116/gdb/testsuite/gdb.threads/tls-sepdebug.exp 2010-11-16 09:27:20.000000000 +0100
+@@ -32,7 +32,25 @@ set binshareddebugfile ${objdir}/${subdi
+
+ # FIXME: gcc dependency (-Wl,-soname).
+
+-if { [gdb_compile_shlib "${srcdir}/${subdir}/${srcsharedfile}" "${binsharedfile}" [list debug additional_flags=-Wl,-soname=${binsharedbase}]] != "" } {
++# Temporarily provide compiler=gcc44 saving the original value around.
++
++set board [target_info name]
++if [board_info $board exists compiler] {
++ set old_compiler [board_info $board compiler]
++ unset_board_info compiler
++} elseif [info exists old_compiler] {
++ unset old_compiler
++}
++set_board_info compiler gcc44
++
++set err [gdb_compile_shlib "${srcdir}/${subdir}/${srcsharedfile}" "${binsharedfile}" [list debug additional_flags=-Wl,-soname=${binsharedbase}]]
++
++unset_board_info compiler
++if [info exists old_compiler] {
++ set_board_info compiler $old_compiler
++}
++
++if { $err != "" } {
+ untested "Couldn't compile test library"
+ return -1
+ }
+Index: gdb-7.2.50.20101116/gdb/testsuite/lib/prelink-support.exp
+===================================================================
+--- gdb-7.2.50.20101116.orig/gdb/testsuite/lib/prelink-support.exp 2010-10-12 20:12:49.000000000 +0200
++++ gdb-7.2.50.20101116/gdb/testsuite/lib/prelink-support.exp 2010-11-16 09:27:20.000000000 +0100
+@@ -118,9 +118,31 @@ proc file_copy {src dest} {
+ proc build_executable_own_libs {testname executable sources options {interp ""} {dir ""}} {
+ global objdir subdir
+
+- if {[build_executable $testname $executable $sources $options] == -1} {
+- return ""
++ # Temporarily provide compiler=gcc44 saving the original value around.
++ # RHEL-5 workaround of its:
++ # gcc: -rpath: linker input file unused because linking not done
++ # gcc: --dynamic-linker: linker input file unused because linking not done
++
++ set board [target_info name]
++ if [board_info $board exists compiler] {
++ set old_compiler [board_info $board compiler]
++ unset_board_info compiler
++ } elseif [info exists old_compiler] {
++ unset old_compiler
+ }
++ set_board_info compiler gcc44
++
++ set err [build_executable $testname $executable $sources $options]
++
++ unset_board_info compiler
++ if [info exists old_compiler] {
++ set_board_info compiler $old_compiler
++ }
++
++ if { $err == -1 } {
++ return ""
++ }
++
+ set binfile ${objdir}/${subdir}/${executable}
+
+ set command "ldd $binfile"
--- /dev/null
+--- a/gdb/stap-probe.c
++++ b/gdb/stap-probe.c
+@@ -355,9 +355,7 @@ stap_free_args_info (void *args_info_ptr)
+ int i;
+
+ for (i = 0; i < a->n_args; i++)
+- {
+- xfree (a->arg[i].arg_str);
+- }
++ xfree (a->arg[i].arg_str);
+
+ xfree (a->arg);
+ xfree (a);
+@@ -401,6 +399,7 @@ stap_parse_probe_arguments (struct stap_probe *probe)
+ return;
+
+ args_info = xmalloc (sizeof (struct stap_args_info));
++ args_info->n_args = 0;
+ back_to = make_cleanup (stap_free_args_info, args_info);
+ args_info->arg = xcalloc (STAP_MAX_ARGS, sizeof (struct stap_probe_arg));
+
+@@ -493,6 +492,7 @@ stap_parse_probe_arguments (struct stap_probe *probe)
+
+ args_info->arg[current_arg].arg_str
+ = savestring (start, cur - start);
++ ++args_info->n_args;
+ /* Start it over again. */
+ cur = skip_spaces ((char *) cur);
+ current_state = NEW_ARG;
+@@ -513,7 +513,6 @@ stap_parse_probe_arguments (struct stap_probe *probe)
+ }
+ }
+
+- args_info->n_args = current_arg + 1;
+ args_info->arg = xrealloc (args_info->arg,
+ args_info->n_args
+ * sizeof (struct stap_probe_arg));
+@@ -1526,8 +1525,9 @@ stap_free_parsed_args (struct stap_args_info *parsed_args)
+ return;
+
+ for (i = 0; i < parsed_args->n_args; i++)
+- xfree (parsed_args->arg);
++ xfree (parsed_args->arg[i].arg_str);
+
++ xfree (parsed_args->arg);
+ xfree (parsed_args);
+ }
+
+@@ -1859,7 +1859,7 @@ parse_stap_probe (char **argptr, struct linespec_result *canonical)
+ if (canonical)
+ {
+ canonical->canonical = xrealloc (canonical->canonical,
+- result.nelts * sizeof (char **));
++ result.nelts * sizeof (char *));
+ canonical->canonical[result.nelts - 1] = xstrdup (full_arg);
+ }
+ }
--- /dev/null
+http://sourceware.org/ml/archer/2010-q3/msg00028.html
+Subject: [delayed-symfile] [commit] Fix a regression on CFI without DIE [Re:
+
+On Wed, 25 Feb 2009 00:14:29 +0100, Jan Kratochvil wrote:
+> commit 6a37c2b9962258ecf9299cc34a650e64a06acaa5
+>
+> There was a regression on gdb.base/savedregs.exp.
+>
+> quick_addrmap/require_partial_symbols should be used even for the unwind debug
+> info checking as its load has been also delayed by this branch.
+[...]
+> --- a/gdb/dwarf2-frame.c
+> +++ b/gdb/dwarf2-frame.c
+[...]
+> @@ -1499,6 +1500,14 @@ dwarf2_frame_find_fde (CORE_ADDR *pc)
+> struct dwarf2_fde *fde;
+> CORE_ADDR offset;
+>
+> + if (objfile->quick_addrmap)
+> + {
+> + if (!addrmap_find (objfile->quick_addrmap, *pc))
+> + continue;
+> + }
+> + /* FIXME: Read-in only .debug_frame/.eh_frame without .debug_info? */
+> + require_partial_symbols (objfile);
+> +
+
+but this has caused a different regression (as discussed in the confcall).
+
+QUICK_ADDRMAP is built only from .debug_aranges. But we can have existing
+built .debug_aranges for CUs in OBJFILE but still some CUs do not need to have
+DWARF at all while they can feature CFIs (.eh_frame or .debug_frame).
+It has been described by Daniel Jacobowitz at:
+ Re: [2/4] RFC: check psymtabs_addrmap before reading FDEs
+ http://sourceware.org/ml/gdb-patches/2010-07/msg00012.html
+
+Sorry for this regression by me (in that fix of a different regression).
+
+Fixed it the "slow way" as this branch is now obsoleted by .gdb-index.
+
+No regressions on {x86_64,x86_64-m32,i686}-fedora13-linux-gnu.
+
+Checked-in.
+
+
+Thanks,
+Jan
+
+
+eb8df8566acc1ed963e3e9b77c13b9c2c3db03fb
+
+Test CFI is parsed even for range (function) not described by any DIE.
+
+https://bugzilla.redhat.com/show_bug.cgi?id=614028
+
+gdb/
+ * dwarf2-frame.c (dwarf2_frame_find_fde): Remove the
+ OBJFILE->QUICK_ADDRMAP check. New comment why.
+
+gdb/testsuite/
+ * gdb.base/cfi-without-die.exp, gdb.base/cfi-without-die-main.c,
+ gdb.base/cfi-without-die-caller.c: New files.
+---
+ gdb/dwarf2-frame.c | 8 +--
+ gdb/testsuite/gdb.base/cfi-without-die-caller.c | 28 ++++++++++
+ gdb/testsuite/gdb.base/cfi-without-die-main.c | 32 +++++++++++
+ gdb/testsuite/gdb.base/cfi-without-die.exp | 67 +++++++++++++++++++++++
+ 4 files changed, 130 insertions(+), 5 deletions(-)
+ create mode 100644 gdb/testsuite/gdb.base/cfi-without-die-caller.c
+ create mode 100644 gdb/testsuite/gdb.base/cfi-without-die-main.c
+ create mode 100644 gdb/testsuite/gdb.base/cfi-without-die.exp
+
+diff --git a/gdb/testsuite/gdb.base/cfi-without-die-caller.c b/gdb/testsuite/gdb.base/cfi-without-die-caller.c
+new file mode 100644
+index 0000000..afdfd53
+--- /dev/null
++++ b/gdb/testsuite/gdb.base/cfi-without-die-caller.c
+@@ -0,0 +1,28 @@
++/* This testcase is part of GDB, the GNU debugger.
++
++ Copyright 2005, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
++
++ This program is free software; you can redistribute it and/or modify
++ it under the terms of the GNU General Public License as published by
++ the Free Software Foundation; either version 3 of the License, or
++ (at your option) any later version.
++
++ This program is distributed in the hope that it will be useful,
++ but WITHOUT ANY WARRANTY; without even the implied warranty of
++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ GNU General Public License for more details.
++
++ You should have received a copy of the GNU General Public License
++ along with this program. If not, see <http://www.gnu.org/licenses/>. */
++
++typedef int (*callback_t) (void);
++
++int
++caller (callback_t callback)
++{
++ /* Ensure some frame content to push away the return address. */
++ volatile const long one = 1;
++
++ /* Modify the return value to prevent any tail-call optimization. */
++ return (*callback) () - one;
++}
+diff --git a/gdb/testsuite/gdb.base/cfi-without-die-main.c b/gdb/testsuite/gdb.base/cfi-without-die-main.c
+new file mode 100644
+index 0000000..8451c4b
+--- /dev/null
++++ b/gdb/testsuite/gdb.base/cfi-without-die-main.c
+@@ -0,0 +1,32 @@
++/* This testcase is part of GDB, the GNU debugger.
++
++ Copyright 2005, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
++
++ This program is free software; you can redistribute it and/or modify
++ it under the terms of the GNU General Public License as published by
++ the Free Software Foundation; either version 3 of the License, or
++ (at your option) any later version.
++
++ This program is distributed in the hope that it will be useful,
++ but WITHOUT ANY WARRANTY; without even the implied warranty of
++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ GNU General Public License for more details.
++
++ You should have received a copy of the GNU General Public License
++ along with this program. If not, see <http://www.gnu.org/licenses/>. */
++
++typedef int (*callback_t) (void);
++
++extern int caller (callback_t callback);
++
++int
++callback (void)
++{
++ return 1;
++}
++
++int
++main (void)
++{
++ return caller (callback);
++}
+diff --git a/gdb/testsuite/gdb.base/cfi-without-die.exp b/gdb/testsuite/gdb.base/cfi-without-die.exp
+new file mode 100644
+index 0000000..db6d248
+--- /dev/null
++++ b/gdb/testsuite/gdb.base/cfi-without-die.exp
+@@ -0,0 +1,67 @@
++# Copyright 2010 Free Software Foundation, Inc.
++
++# This program is free software; you can redistribute it and/or modify
++# it under the terms of the GNU General Public License as published by
++# the Free Software Foundation; either version 3 of the License, or
++# (at your option) any later version.
++#
++# This program is distributed in the hope that it will be useful,
++# but WITHOUT ANY WARRANTY; without even the implied warranty of
++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++# GNU General Public License for more details.
++#
++# You should have received a copy of the GNU General Public License
++# along with this program. If not, see <http://www.gnu.org/licenses/>.
++
++# Test CFI is parsed even for range (function) not described by any DIE.
++
++set testfile cfi-without-die
++set srcmainfile ${testfile}-main.c
++set srccallerfile ${testfile}-caller.c
++set executable ${testfile}
++set objmainfile ${objdir}/${subdir}/${testfile}-main.o
++set objcallerfile ${objdir}/${subdir}/${testfile}-caller.o
++set binfile ${objdir}/${subdir}/${executable}
++
++if { [gdb_compile "${srcdir}/${subdir}/${srccallerfile}" ${objcallerfile} \
++ object [list {additional_flags=-fomit-frame-pointer -fno-unwind-tables -fno-asynchronous-unwind-tables}]] != ""
++ || [gdb_compile "${srcdir}/${subdir}/${srcmainfile}" ${objmainfile} object {debug}] != ""
++ || [gdb_compile "${objmainfile} ${objcallerfile}" ${binfile} executable {}] != "" } {
++ untested ${testfile}.exp
++ return -1
++}
++
++clean_restart $executable
++
++if ![runto callback] then {
++ fail "verify unwinding: Can't run to callback"
++ return 0
++}
++set test "verify unwinding breaks without CFI"
++gdb_test_multiple "bt" $test {
++ -re " in main .*\r\n$gdb_prompt $" {
++ fail $test
++ }
++ -re "\r\n$gdb_prompt $" {
++ pass $test
++ }
++}
++
++if { [gdb_compile "${srcdir}/${subdir}/${srccallerfile}" ${objcallerfile} \
++ object [list {additional_flags=-fomit-frame-pointer -funwind-tables -fasynchronous-unwind-tables}]] != ""
++ || [gdb_compile "${srcdir}/${subdir}/${srcmainfile}" ${objmainfile} object {debug}] != ""
++ || [gdb_compile "${objmainfile} ${objcallerfile}" ${binfile} executable {}] != "" } {
++ untested ${testfile}.exp
++ return -1
++}
++
++clean_restart $executable
++
++if ![runto callback] then {
++ fail "test CFI without DIEs: Can't run to callback"
++ return 0
++}
++# #0 callback () at ...
++# #1 0x00000000004004e9 in caller ()
++# #2 0x00000000004004cd in main () at ...
++gdb_test "bt" "#0 +callback \[^\r\n\]+\r\n#1 \[^\r\n\]+ in caller \[^\r\n\]+\r\n#2 \[^\r\n\]+ in main \[^\r\n\]+" "verify unwindin works for CFI without DIEs"
+--
+1.7.1.1
+
--- /dev/null
+[archer-tromey-delayed-symfile]
+
+commit 77fa7778a37b0d28a7e4e5235f074a10ecf1815d
+Author: Jan Kratochvil <jkratoch@host1.dyn.jankratochvil.net>
+Date: Sat Aug 15 15:05:54 2009 +0200
+
+ Test for "handle incorrect aranges".
+
+ readelf:
+ Contents of the .debug_aranges section:
+
+ Length: 8
+ Version: 2
+ Offset into .debug_info: 0x0
+ Pointer Size: 0
+ Segment Size: 0
+
+ Address Length
+ Floating point exception
+
+ * gdb.dwarf2/dw2-aranges.exp, gdb.dwarf2/dw2-aranges.S: New files.
+
+diff --git a/gdb/testsuite/gdb.dwarf2/dw2-aranges.S b/gdb/testsuite/gdb.dwarf2/dw2-aranges.S
+new file mode 100644
+index 0000000..d5b9ca5a
+--- /dev/null
++++ b/gdb/testsuite/gdb.dwarf2/dw2-aranges.S
+@@ -0,0 +1,140 @@
++/* This testcase is part of GDB, the GNU debugger.
++
++ Copyright 2004, 2007, 2008, 2009 Free Software Foundation, Inc.
++
++ This program is free software; you can redistribute it and/or modify
++ it under the terms of the GNU General Public License as published by
++ the Free Software Foundation; either version 3 of the License, or
++ (at your option) any later version.
++
++ This program is distributed in the hope that it will be useful,
++ but WITHOUT ANY WARRANTY; without even the implied warranty of
++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ GNU General Public License for more details.
++
++ You should have received a copy of the GNU General Public License
++ along with this program. If not, see <http://www.gnu.org/licenses/>. */
++
++/* Test .debug_aranges containing zero address_size. */
++
++/* Dummy function to provide debug information for. */
++
++ .text
++.Lbegin_text1:
++ .globl main
++ .type main, %function
++main:
++.Lbegin_main:
++ .int 0
++.Lend_main:
++ .size main, .-main
++.Lend_text1:
++
++/* Debug information */
++
++ .section .debug_info
++.Lcu1_begin:
++ /* CU header */
++ .4byte .Lcu1_end - .Lcu1_start /* Length of Compilation Unit */
++.Lcu1_start:
++ .2byte 2 /* DWARF Version */
++ .4byte .Labbrev1_begin /* Offset into abbrev section */
++ .byte 4 /* Pointer size */
++
++ /* CU die */
++ .uleb128 1 /* Abbrev: DW_TAG_compile_unit */
++ .4byte .Lend_text1 /* DW_AT_high_pc */
++ .4byte .Lbegin_text1 /* DW_AT_low_pc */
++ .ascii "file1.txt\0" /* DW_AT_name */
++ .ascii "GNU C 3.3.3\0" /* DW_AT_producer */
++ .byte 1 /* DW_AT_language (C) */
++
++ /* main */
++ .uleb128 2 /* Abbrev: DW_TAG_subprogram */
++ .byte 1 /* DW_AT_external */
++ .byte 1 /* DW_AT_decl_file */
++ .byte 2 /* DW_AT_decl_line */
++ .ascii "main\0" /* DW_AT_name */
++ .4byte .Ltype_int-.Lcu1_begin /* DW_AT_type */
++ .4byte .Lbegin_main /* DW_AT_low_pc */
++ .4byte .Lend_main /* DW_AT_high_pc */
++ .byte 1 /* DW_AT_frame_base: length */
++ .byte 0x55 /* DW_AT_frame_base: DW_OP_reg5 */
++
++.Ltype_int:
++ .uleb128 3 /* Abbrev: DW_TAG_base_type */
++ .ascii "int\0" /* DW_AT_name */
++ .byte 4 /* DW_AT_byte_size */
++ .byte 5 /* DW_AT_encoding */
++
++ .byte 0 /* End of children of CU */
++
++.Lcu1_end:
++
++/* Abbrev table */
++ .section .debug_abbrev
++.Labbrev1_begin:
++ .uleb128 1 /* Abbrev code */
++ .uleb128 0x11 /* DW_TAG_compile_unit */
++ .byte 1 /* has_children */
++ .uleb128 0x12 /* DW_AT_high_pc */
++ .uleb128 0x1 /* DW_FORM_addr */
++ .uleb128 0x11 /* DW_AT_low_pc */
++ .uleb128 0x1 /* DW_FORM_addr */
++ .uleb128 0x3 /* DW_AT_name */
++ .uleb128 0x8 /* DW_FORM_string */
++ .uleb128 0x25 /* DW_AT_producer */
++ .uleb128 0x8 /* DW_FORM_string */
++ .uleb128 0x13 /* DW_AT_language */
++ .uleb128 0xb /* DW_FORM_data1 */
++ .byte 0x0 /* Terminator */
++ .byte 0x0 /* Terminator */
++
++ .uleb128 2 /* Abbrev code */
++ .uleb128 0x2e /* DW_TAG_subprogram */
++ .byte 0 /* has_children */
++ .uleb128 0x3f /* DW_AT_external */
++ .uleb128 0xc /* DW_FORM_flag */
++ .uleb128 0x3a /* DW_AT_decl_file */
++ .uleb128 0xb /* DW_FORM_data1 */
++ .uleb128 0x3b /* DW_AT_decl_line */
++ .uleb128 0xb /* DW_FORM_data1 */
++ .uleb128 0x3 /* DW_AT_name */
++ .uleb128 0x8 /* DW_FORM_string */
++ .uleb128 0x49 /* DW_AT_type */
++ .uleb128 0x13 /* DW_FORM_ref4 */
++ .uleb128 0x11 /* DW_AT_low_pc */
++ .uleb128 0x1 /* DW_FORM_addr */
++ .uleb128 0x12 /* DW_AT_high_pc */
++ .uleb128 0x1 /* DW_FORM_addr */
++ .uleb128 0x40 /* DW_AT_frame_base */
++ .uleb128 0xa /* DW_FORM_block1 */
++ .byte 0x0 /* Terminator */
++ .byte 0x0 /* Terminator */
++
++ .uleb128 3 /* Abbrev code */
++ .uleb128 0x24 /* DW_TAG_base_type */
++ .byte 0 /* has_children */
++ .uleb128 0x3 /* DW_AT_name */
++ .uleb128 0x8 /* DW_FORM_string */
++ .uleb128 0xb /* DW_AT_byte_size */
++ .uleb128 0xb /* DW_FORM_data1 */
++ .uleb128 0x3e /* DW_AT_encoding */
++ .uleb128 0xb /* DW_FORM_data1 */
++ .byte 0x0 /* Terminator */
++ .byte 0x0 /* Terminator */
++
++ .byte 0x0 /* Terminator */
++ .byte 0x0 /* Terminator */
++
++/* aranges table */
++ .section .debug_aranges
++ .long .Laranges_end - 1f
++1:
++ .2byte 2 /* aranges Version */
++ .4byte .Lcu1_begin - .debug_info /* Offset into .debug_info section */
++ /* The GDB crasher is this zero value. */
++ .byte 0 /* aranges address_size */
++ .byte 0 /* aranges segment_size */
++
++.Laranges_end:
+diff --git a/gdb/testsuite/gdb.dwarf2/dw2-aranges.exp b/gdb/testsuite/gdb.dwarf2/dw2-aranges.exp
+new file mode 100644
+index 0000000..39632d5
+--- /dev/null
++++ b/gdb/testsuite/gdb.dwarf2/dw2-aranges.exp
+@@ -0,0 +1,40 @@
++# Copyright 2004, 2005, 2007, 2008, 2009 Free Software Foundation, Inc.
++
++# This program is free software; you can redistribute it and/or modify
++# it under the terms of the GNU General Public License as published by
++# the Free Software Foundation; either version 3 of the License, or
++# (at your option) any later version.
++#
++# This program is distributed in the hope that it will be useful,
++# but WITHOUT ANY WARRANTY; without even the implied warranty of
++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++# GNU General Public License for more details.
++#
++# You should have received a copy of the GNU General Public License
++# along with this program. If not, see <http://www.gnu.org/licenses/>.
++
++# Test .debug_aranges containing zero address_size.
++
++# This test can only be run on targets which support DWARF-2 and use gas.
++# For now pick a sampling of likely targets.
++if {![istarget *-*-linux*]
++ && ![istarget *-*-gnu*]
++ && ![istarget *-*-elf*]
++ && ![istarget *-*-openbsd*]
++ && ![istarget arm-*-eabi*]
++ && ![istarget powerpc-*-eabi*]} {
++ return 0
++}
++
++set testfile "dw2-aranges"
++set srcfile ${testfile}.S
++set binfile ${objdir}/${subdir}/${testfile}
++
++if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {nodebug}] != "" } {
++ return -1
++}
++
++clean_restart $testfile
++
++# Failed gdb_load would abort the testcase execution earlier.
++pass "file loaded"
--- /dev/null
+archer archer-keiths-expr-cumulative
+b5a7497340b24199f0c7ba7fdf0d54d4df44d6bc
+
+--- /dev/null 2011-01-12 06:28:36.282000001 +0100
++++ ./gdb/testsuite/gdb.cp/namespace-nested-imports.cc 2009-09-25 06:50:38.000000000 +0200
+@@ -0,0 +1,36 @@
++namespace A
++{
++ namespace B
++ {
++ int ab = 11;
++ }
++}
++
++namespace C
++{
++ namespace D
++ {
++ using namespace A::B;
++
++ int
++ second()
++ {
++ ab;
++ return 0;
++ }
++ }
++
++ int
++ first()
++ {
++ //ab;
++ return D::second();
++ }
++}
++
++int
++main()
++{
++ //ab;
++ return C::first();
++}
+--- /dev/null 2011-01-12 06:28:36.282000001 +0100
++++ ./gdb/testsuite/gdb.cp/namespace-nested-imports.exp 2009-09-25 06:50:38.000000000 +0200
+@@ -0,0 +1,50 @@
++# Copyright 2008 Free Software Foundation, Inc.
++
++# This program is free software; you can redistribute it and/or modify
++# it under the terms of the GNU General Public License as published by
++# the Free Software Foundation; either version 3 of the License, or
++# (at your option) any later version.
++#
++# This program is distributed in the hope that it will be useful,
++# but WITHOUT ANY WARRANTY; without even the implied warranty of
++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++# GNU General Public License for more details.
++#
++# You should have received a copy of the GNU General Public License
++# along with this program. If not, see <http://www.gnu.org/licenses/>.
++
++set testfile namespace-nested-imports
++set srcfile ${testfile}.cc
++set binfile ${objdir}/${subdir}/${testfile}
++if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } {
++ untested "Couldn't compile test program"
++ return -1
++}
++
++# Get things started.
++
++gdb_exit
++gdb_start
++gdb_reinitialize_dir $srcdir/$subdir
++gdb_load ${binfile}
++
++############################################
++if ![runto_main] then {
++ perror "couldn't run to breakpoint main"
++ continue
++}
++
++gdb_test "print ab" "No symbol .* in current context."
++
++############################################
++gdb_breakpoint C::first
++gdb_continue_to_breakpoint "C::first"
++
++gdb_test "print ab" "No symbol .* in current context."
++gdb_test "print C::D::ab" "= 11"
++
++############################################
++gdb_breakpoint C::D::second
++gdb_continue_to_breakpoint "C::D::second"
++
++gdb_test "print ab" "= 11"
+--- /dev/null 2011-01-12 06:28:36.282000001 +0100
++++ ./gdb/testsuite/gdb.cp/namespace-no-imports.cc 2009-09-25 06:50:38.000000000 +0200
+@@ -0,0 +1,37 @@
++
++namespace A
++{
++ int _a = 11;
++
++ namespace B{
++
++ int ab = 22;
++
++ namespace C{
++
++ int abc = 33;
++
++ int second(){
++ return 0;
++ }
++
++ }
++
++ int first(){
++ _a;
++ ab;
++ C::abc;
++ return C::second();
++ }
++ }
++}
++
++
++int
++main()
++{
++ A::_a;
++ A::B::ab;
++ A::B::C::abc;
++ return A::B::first();
++}
+--- /dev/null 2011-01-12 06:28:36.282000001 +0100
++++ ./gdb/testsuite/gdb.cp/namespace-no-imports.exp 2009-09-25 06:50:38.000000000 +0200
+@@ -0,0 +1,69 @@
++# Copyright 2008 Free Software Foundation, Inc.
++
++# This program is free software; you can redistribute it and/or modify
++# it under the terms of the GNU General Public License as published by
++# the Free Software Foundation; either version 3 of the License, or
++# (at your option) any later version.
++#
++# This program is distributed in the hope that it will be useful,
++# but WITHOUT ANY WARRANTY; without even the implied warranty of
++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++# GNU General Public License for more details.
++#
++# You should have received a copy of the GNU General Public License
++# along with this program. If not, see <http://www.gnu.org/licenses/>.
++
++set testfile namespace-no-imports
++set srcfile ${testfile}.cc
++set binfile ${objdir}/${subdir}/${testfile}
++if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } {
++ untested "Couldn't compile test program"
++ return -1
++}
++
++# Get things started.
++
++gdb_exit
++gdb_start
++gdb_reinitialize_dir $srcdir/$subdir
++gdb_load ${binfile}
++
++############################################
++if ![runto_main] then {
++ perror "couldn't run to breakpoint main"
++ continue
++}
++
++gdb_test "print A::_a" "= 11"
++gdb_test "print A::B::ab" "= 22"
++gdb_test "print A::B::C::abc" "= 33"
++
++gdb_test "print _a" "No symbol .* in current context."
++gdb_test "print ab" "No symbol .* in current context."
++gdb_test "print abc" "No symbol .* in current context."
++
++############################################
++gdb_breakpoint A::B::first
++gdb_continue_to_breakpoint "A::B::first"
++
++gdb_test "print A::_a" "= 11"
++gdb_test "print A::B::ab" "= 22"
++gdb_test "print A::B::C::abc" "= 33"
++
++gdb_test "print _a" "= 11"
++gdb_test "print ab" "= 22"
++gdb_test "print C::abc" "= 33"
++
++gdb_test "print abc" "No symbol .* in current context."
++
++############################################
++gdb_breakpoint A::B::C::second
++gdb_continue_to_breakpoint "A::B::C::second"
++
++gdb_test "print A::_a" "= 11"
++gdb_test "print A::B::ab" "= 22"
++gdb_test "print A::B::C::abc" "= 33"
++
++gdb_test "print _a" "= 11"
++gdb_test "print ab" "= 22"
++gdb_test "print abc" "= 33"
--- /dev/null
+https://bugzilla.redhat.com/show_bug.cgi?id=611435
+
+Fix:
+Re: [RFA]corelow.c: Add tid to add_to_thread_list
+http://sourceware.org/ml/gdb-patches/2010-08/msg00085.html
+http://sourceware.org/ml/gdb-cvs/2010-08/msg00026.html
+2e5bcfdef1ec3883d48c3f87a4be5c0dff25e17e
+
+--- /dev/null
++++ b/gdb/testsuite/gdb.arch/x86_64-pid0-core.core.bz2.uu
+@@ -0,0 +1,20 @@
++begin 600 x86_64-pid0-core.core.bz2
++M0EIH.3%!629362,CA>P!$/'_____^*#EZ-A!SP36P&_:G0#=14``04A&8,'U
++M2*9`>$$)P`*RN"#*;#4R()IJ8C$TT&FC3$&@`T`#:C1H8C0T,@,FC,D"4T2!
++M"/2CU'B90]31ZAD#U`&AZF@/4:``!HT&F@!H<`#0-`-#0``#3$-&F@```#0R
++M``#")2FD]2>4]0TTT-!HTT--,0,"#$`R!I@AD`#1H,3&GZT.4TO$#H40/`0C
++M2$IRXS,<55!8T,&&,R.Z441"?J9I%G6GUA2!.[]Z"C5S[&19,%VS7E6[3"60
++M@`-*2G)QEQ(;?0Y<=MK]/U?Q)LB%+F37TJ9BI*46)H'*Z@V"`"$"P7]&<Q<?
++M>XZ:JE0E<*:#1M$P3G]>VCI)(A!O$64`5$4`E$$-.``7&(09`8HO`B6K!Q^&
++M562%N)2+0@*HB@%D@5$%!*0!L1&0D4D6\:-$A`)`+<6D82PP*H(J(H!?F;0$
++M%PXB7N!2D4!44`W7"ADEQM6<B]J<B(%1GF'5*0;_00KO55=43LPR0,Q?N72`
++M8"W*_;DV<AN#,XRU]Q-J2FDAFKAQ(9A+ZK$MCY#EI8:W-(15>O9TBO5,_]1)
++M($Q2))#),UE,QQK)E$,3D\W.>!4)QO8A_@^Z_SXS<OEHM*+"M8I1)-C(=DIJ
++MW+@WN)O)YO;3:I9YW-A$)N'2<A`F3),R3"3-'"S3E1;6VE*_95KD<!0050(G
++M,JV"N(Z:@0E#)50BSF)$T6_IN)#"Z8PLQ4UQ9]@Z'+;T]990-:Y:2`P26#!D
++MV+0L6"X@C9`GHAGSY7)%LWOY+E[2/>4;Q8=HV6[:&$@2$@$R29IBW)K%3"O`
++M9^Y0YJ&BXY1U2HTZ5)2H-V\_(.DZHWE+C#WS($(!I"3CUH2#(+(OWUV"*<<9
++MJ%A!J[%O.P&V%GI.`L7<1@0>,^1F\MY=V5UT,&NOG%7TTZ[03!@BHB@&)<A^
++4B.Z!/,0-IZ^W_Q=R13A0D",CA>P`
++`
++end
+--- /dev/null
++++ b/gdb/testsuite/gdb.arch/x86_64-pid0-core.exp
+@@ -0,0 +1,46 @@
++# This testcase is part of GDB, the GNU debugger.
++#
++# Copyright 2010 Free Software Foundation, Inc.
++#
++# This program is free software; you can redistribute it and/or modify
++# it under the terms of the GNU General Public License as published by
++# the Free Software Foundation; either version 2 of the License, or
++# (at your option) any later version.
++#
++# This program is distributed in the hope that it will be useful,
++# but WITHOUT ANY WARRANTY; without even the implied warranty of
++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++# GNU General Public License for more details.
++#
++# You should have received a copy of the GNU General Public License
++# along with this program; if not, write to the Free Software
++# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
++
++# Some kernel core files have PID 0 - for the idle task.
++
++if ![istarget "x86_64-*-*"] {
++ verbose "Skipping x86_64-pid0-core test."
++ return
++}
++
++set testfile "x86_64-pid0-core"
++set corebz2uufile ${srcdir}/${subdir}/${testfile}.core.bz2.uu
++set corefile ${objdir}/${subdir}/${testfile}.core
++
++if {[catch "system \"uudecode -o - ${corebz2uufile} | bzip2 -dc >${corefile}\""] != 0} {
++ untested "failed uudecode or bzip2"
++ return -1
++}
++file stat ${corefile} corestat
++if {$corestat(size) != 8798208} {
++ untested "uudecode or bzip2 produce invalid result"
++ return -1
++}
++
++gdb_exit
++gdb_start
++gdb_reinitialize_dir $srcdir/$subdir
++
++# Former crash was:
++# thread.c:884: internal-error: switch_to_thread: Assertion `inf != NULL' failed.
++gdb_test "core-file ${corefile}" "Program terminated with signal 11, Segmentation fault\\.\r\n.*"
--- /dev/null
+http://sourceware.org/ml/gdb-patches/2011-01/msg00016.html
+Subject: [patch] New testcase: py-prettyprint.exp: print hint_error
+
+Hi,
+
+PASS: gdb.python/py-prettyprint.exp: print hint_error
+for
+ FYI: fix buglet in gdbpy_get_display_hint
+ http://sourceware.org/ml/gdb-patches/2010-07/msg00190.html
+ http://sourceware.org/ml/gdb-cvs/2010-07/msg00061.html
+
+I would check it in as obvious but the 2011 ChangeLog move process has to be
+done first. So to be checked in later.
+
+
+Thanks,
+Jan
+
+
+gdb/testsuite/
+2011-01-01 Jan Kratochvil <jan.kratochvil@redhat.com>
+
+ * gdb.python/py-prettyprint.c (struct hint_error): New.
+ (main): New variable hint_error.
+ * gdb.python/py-prettyprint.exp (run_lang_tests): New testcase
+ "print hint_error".
+ * gdb.python/py-prettyprint.py (class pp_hint_error): New.
+ (register_pretty_printers): Register it.
+
+Index: gdb-7.2.90.20110411/gdb/testsuite/gdb.python/py-prettyprint.c
+===================================================================
+--- gdb-7.2.90.20110411.orig/gdb/testsuite/gdb.python/py-prettyprint.c 2011-03-31 21:59:26.000000000 +0200
++++ gdb-7.2.90.20110411/gdb/testsuite/gdb.python/py-prettyprint.c 2011-04-11 19:42:10.000000000 +0200
+@@ -44,6 +44,10 @@ struct lazystring {
+ const char *lazy_str;
+ };
+
++struct hint_error {
++ int x;
++};
++
+ #ifdef __cplusplus
+ struct S : public s {
+ int zs;
+@@ -215,6 +219,7 @@ main ()
+ nostring_type nstype, nstype2;
+ struct ns ns, ns2;
+ struct lazystring estring, estring2;
++ struct hint_error hint_error;
+
+ nstype.elements = narray;
+ nstype.len = 0;
+Index: gdb-7.2.90.20110411/gdb/testsuite/gdb.python/py-prettyprint.exp
+===================================================================
+--- gdb-7.2.90.20110411.orig/gdb/testsuite/gdb.python/py-prettyprint.exp 2011-03-07 17:03:03.000000000 +0100
++++ gdb-7.2.90.20110411/gdb/testsuite/gdb.python/py-prettyprint.exp 2011-04-11 19:41:56.000000000 +0200
+@@ -97,6 +97,8 @@ proc run_lang_tests {lang} {
+ gdb_test_no_output "python pp_ls_encoding = 'UTF-8'"
+ gdb_test "print estring2" "\"embedded \", <incomplete sequence \\\\302>"
+
++ gdb_test "print hint_error" "Exception: hint failed\r\nhint_error_val"
++
+ 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}"
+Index: gdb-7.2.90.20110411/gdb/testsuite/gdb.python/py-prettyprint.py
+===================================================================
+--- gdb-7.2.90.20110411.orig/gdb/testsuite/gdb.python/py-prettyprint.py 2011-03-31 21:59:26.000000000 +0200
++++ gdb-7.2.90.20110411/gdb/testsuite/gdb.python/py-prettyprint.py 2011-04-11 19:41:56.000000000 +0200
+@@ -161,6 +161,18 @@ class pp_ls:
+ def display_hint (self):
+ return 'string'
+
++class pp_hint_error:
++ "Throw error from display_hint"
++
++ def __init__(self, val):
++ self.val = val
++
++ def to_string(self):
++ return 'hint_error_val'
++
++ def display_hint (self):
++ raise Exception("hint failed")
++
+ class pp_outer:
+ "Print struct outer"
+
+@@ -246,6 +258,9 @@ def register_pretty_printers ():
+ pretty_printers_dict[re.compile ('^struct outerstruct$')] = pp_outer
+ pretty_printers_dict[re.compile ('^outerstruct$')] = pp_outer
+
++ pretty_printers_dict[re.compile ('^struct hint_error$')] = pp_hint_error
++ pretty_printers_dict[re.compile ('^hint_error$')] = pp_hint_error
++
+ pretty_printers_dict = {}
+
+ register_pretty_printers ()
--- /dev/null
+commit 51dab9e418741ac7065cd5a6ec9b57285e90227c
+https://bugzilla.redhat.com/show_bug.cgi?id=738482
+
+--- a/gdb/printcmd.c
++++ b/gdb/printcmd.c
+@@ -1981,6 +1981,10 @@ print_variable_and_value (const char *name, struct symbol *var,
+ struct value_print_options opts;
+
+ val = read_var_value (var, frame);
++
++ make_cleanup_restore_selected_frame ();
++ select_frame (frame);
++
+ get_user_print_options (&opts);
+ common_val_print (val, stream, indent, &opts, current_language);
+ }
+--- /dev/null
++++ b/gdb/testsuite/gdb.base/vla-frame.c
+@@ -0,0 +1,31 @@
++/* This testcase is part of GDB, the GNU debugger.
++
++ Copyright 2011 Free Software Foundation, Inc.
++
++ This program is free software; you can redistribute it and/or modify
++ it under the terms of the GNU General Public License as published by
++ the Free Software Foundation; either version 3 of the License, or
++ (at your option) any later version.
++
++ This program is distributed in the hope that it will be useful,
++ but WITHOUT ANY WARRANTY; without even the implied warranty of
++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ GNU General Public License for more details.
++
++ You should have received a copy of the GNU General Public License
++ along with this program. If not, see <http://www.gnu.org/licenses/>. */
++
++#include <string.h>
++
++int
++main (int argc, char **argv)
++{
++ char s[2 + argc];
++ void (*f) (char *) = 0;
++
++ memset (s, 0, sizeof (s));
++ s[0] = 'X';
++
++ f (s);
++ return 0;
++}
+--- /dev/null
++++ b/gdb/testsuite/gdb.base/vla-frame.exp
+@@ -0,0 +1,38 @@
++# Copyright 2011 Free Software Foundation, Inc.
++#
++# This program is free software; you can redistribute it and/or modify
++# it under the terms of the GNU General Public License as published by
++# the Free Software Foundation; either version 3 of the License, or
++# (at your option) any later version.
++#
++# This program is distributed in the hope that it will be useful,
++# but WITHOUT ANY WARRANTY; without even the implied warranty of
++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++# GNU General Public License for more details.
++#
++# You should have received a copy of the GNU General Public License
++# along with this program. If not, see <http://www.gnu.org/licenses/>.
++
++set testfile vla-frame
++set executable ${testfile}
++
++if { [prepare_for_testing ${testfile}.exp ${executable}] } {
++ return -1
++}
++
++if ![runto_main] {
++ return -1
++}
++
++set test "continue"
++gdb_test_multiple $test $test {
++ -re "Continuing\\.\r\n\r\nProgram received signal SIGSEGV, Segmentation fault\\.\r\n0x0+ in \\?\\? \\(\\)\r\n$gdb_prompt $" {
++ pass $test
++ }
++ -re "\r\n$gdb_prompt $" {
++ untested ${testfile}.exp
++ return
++ }
++}
++
++gdb_test "bt full" "\r\n +s = \"X\\\\000\"\r\n.*"
Summary(zh_CN.UTF-8): [开发]C和其他语言的调试器
Summary(zh_TW.UTF-8): [.-A開發]C和.$)B其.-A他語.$)B言的調試器
Name: gdb
-Version: 7.2
-Release: 7
+Version: 7.3.1
+Release: 1
License: GPL v3+
Group: Development/Debuggers
Source0: http://ftp.gnu.org/gnu/gdb/%{name}-%{version}.tar.bz2
-# Source0-md5: 64260e6c56979ee750a01055f16091a5
+# Source0-md5: b89a5fac359c618dda97b88645ceab47
Source1: http://www.mif.pg.gda.pl/homepages/ankry/man-PLD/%{name}-non-english-man-pages.tar.bz2
# Source1-md5: 2e8a48939ae282c12bbacdd54e398247
Source3: %{name}-gstack.man
Patch3: %{name}-6.3-rh-testlibunwind-20041202.patch
Patch104: %{name}-6.3-ppcdotsolib-20041022.patch
Patch105: %{name}-6.3-ppc64syscall-20040622.patch
-Patch106: %{name}-6.3-framepczero-20040927.patch
Patch111: %{name}-6.3-ppc64displaysymbol-20041124.patch
Patch112: %{name}-6.6-scheduler_locking-step-sw-watchpoints2.patch
Patch260: %{name}-6.6-scheduler_locking-step-is-default.patch
Patch140: %{name}-6.3-gcore-thread-20050204.patch
Patch141: %{name}-6.6-step-thread-exit.patch
Patch259: %{name}-6.3-step-thread-exit-20050211-test.patch
-Patch142: %{name}-6.3-terminal-fix-20050214.patch
Patch145: %{name}-6.3-threaded-watchpoints2-20050225.patch
-Patch148: %{name}-6.3-inheritance-20050324.patch
Patch153: %{name}-6.3-ia64-gcore-page0-20050421.patch
Patch157: %{name}-6.3-security-errata-20050610.patch
Patch158: %{name}-6.3-ia64-sigtramp-frame-20050708.patch
Patch163: %{name}-6.3-inheritancetest-20050726.patch
Patch164: %{name}-6.3-readnever-20050907.patch
Patch169: %{name}-6.3-ia64-sigill-20051115.patch
-Patch170: %{name}-6.3-bt-past-zero-20051201.patch
-Patch176: %{name}-6.3-large-core-20051206.patch
Patch188: %{name}-6.5-bz203661-emit-relocs.patch
-Patch190: %{name}-6.5-dwarf-stack-overflow.patch
Patch194: %{name}-6.5-bz185337-resolve-tls-without-debuginfo-v2.patch
Patch196: %{name}-6.5-sharedlibrary-path.patch
Patch199: %{name}-6.5-bz190810-gdbserver-arch-advice.patch
Patch211: %{name}-6.5-last-address-space-byte-test.patch
Patch208: %{name}-6.5-BEA-testsuite.patch
-Patch209: %{name}-6.5-readline-long-line-crash.patch
Patch213: %{name}-6.5-readline-long-line-crash-test.patch
Patch214: %{name}-6.5-bz216711-clone-is-outermost.patch
Patch216: %{name}-6.5-bz218379-ppc-solib-trampoline-test.patch
Patch225: %{name}-6.5-bz109921-DW_AT_decl_file-test.patch
Patch229: %{name}-6.3-bz140532-ppc-unwinding-test.patch
Patch231: %{name}-6.3-bz202689-exec-from-pthread-test.patch
-Patch232: %{name}-upstream.patch
+#Patch232: %{name}-upstream.patch
Patch234: %{name}-6.6-bz230000-power6-disassembly-test.patch
Patch235: %{name}-6.3-bz231832-obstack-2gb.patch
-Patch241: %{name}-6.6-bz225783-gdb-debuginfo-paths.patch
Patch245: %{name}-6.6-bz229517-gcore-without-terminal.patch
Patch247: %{name}-6.6-bz235197-fork-detach-info.patch
Patch254: %{name}-6.6-testsuite-timeouts.patch
Patch258: %{name}-6.6-bz237572-ppc-atomic-sequence-test.patch
-Patch261: %{name}-6.6-readline-system.patch
Patch263: %{name}-6.3-attach-see-vdso-test.patch
Patch265: %{name}-6.6-bz247354-leader-exit-fix.patch
Patch266: %{name}-6.6-bz247354-leader-exit-test.patch
Patch274: %{name}-6.6-buildid-locate.patch
Patch353: %{name}-6.6-buildid-locate-rpm.patch
Patch415: %{name}-6.6-buildid-locate-core-as-arg.patch
+Patch519: %{name}-6.6-buildid-locate-rpm-librpm-workaround.patch
Patch282: %{name}-6.7-charsign-test.patch
Patch284: %{name}-6.7-ppc-clobbered-registers-O2-test.patch
Patch287: %{name}-6.7-testsuite-stable-results.patch
Patch289: %{name}-6.5-ia64-libunwind-leak-test.patch
Patch290: %{name}-6.5-missed-trap-on-step-test.patch
-Patch293: %{name}-6.7-bz426600-DW_TAG_interface_type-fix.patch
Patch294: %{name}-6.7-bz426600-DW_TAG_interface_type-test.patch
Patch296: %{name}-6.5-gcore-buffer-limit-test.patch
Patch298: %{name}-6.6-threads-static-test.patch
-Patch304: %{name}-6.7-kernel-headers-compat.patch
Patch309: %{name}-6.3-mapping-zero-inode-test.patch
Patch311: %{name}-6.3-focus-cmd-prev-test.patch
Patch315: %{name}-6.8-bz442765-threaded-exec-test.patch
Patch317: %{name}-6.8-sparc64-silence-memcpy-check.patch
-Patch318: %{name}-6.8-gcc35998-ada-memory-trash.patch
Patch320: %{name}-6.5-section-num-fixup-test.patch
-Patch324: %{name}-6.8-glibc-headers-compat.patch
Patch326: %{name}-6.8-tui-singlebinary.patch
Patch329: %{name}-6.8-bz254229-gcore-prpsinfo.patch
Patch330: %{name}-6.8-bz436037-reg-no-longer-active.patch
Patch331: %{name}-6.8-quit-never-aborts.patch
-Patch332: %{name}-6.8-fortran-tag-constant.patch
Patch337: %{name}-6.8-attach-signalled-detach-stopped.patch
Patch343: %{name}-6.8-watchpoint-conditionals-test.patch
Patch348: %{name}-6.8-bz466901-backtrace-full-prelinked.patch
Patch349: %{name}-archer.patch
-Patch420: %{name}-archer-ada.patch
Patch360: %{name}-6.8-bz457187-largefile-test.patch
Patch381: %{name}-simultaneous-step-resume-breakpoint-test.patch
Patch382: %{name}-core-open-vdso-warning.patch
Patch391: %{name}-x86_64-i386-syscall-restart.patch
Patch392: %{name}-bz533176-fortran-omp-step.patch
+Patch393: %{name}-rhel5-gcc44.patch
+Patch335: %{name}-rhel5-compat.patch
Patch397: %{name}-follow-child-stale-parent.patch
Patch403: %{name}-ccache-workaround.patch
Patch404: %{name}-fortran-common-reduce.patch
Patch408: %{name}-ppc-power7-test.patch
Patch412: %{name}-unused-revert.patch
Patch417: %{name}-bz541866-rwatch-before-run.patch
-Patch451: %{name}-bz575292-delayed-physname.patch
-Patch454: %{name}-bz539590-gnu-ifunc-fix-cond.patch
Patch459: %{name}-moribund-utrace-workaround.patch
-Patch461: %{name}-bz594560-core-vs-process.patch
Patch470: %{name}-archer-next-over-throw-cxx-exec.patch
Patch475: %{name}-bz601887-dwarf4-rh-test.patch
Patch486: %{name}-bz562763-pretty-print-2d-vectors.patch
-Patch489: %{name}-bz614659-prelink-dynbss.patch
+Patch487: %{name}-bz562763-pretty-print-2d-vectors-libstdcxx.patch
+Patch490: %{name}-test-bt-cfi-without-die.patch
Patch491: %{name}-gdb-add-index-script.patch
-Patch493: %{name}-bz555076-gcore-small-height.patch
Patch496: %{name}-bz568248-oom-is-error.patch
-Patch497: %{name}-false-gcc-warning.patch
-Patch499: %{name}-bz631575-gdb-index-nobits.patch
-Patch500: %{name}-bz631158-cxx-this-lookup.patch
-Patch501: %{name}-gdbindex-ada-regression.patch
-Patch502: %{name}-bz634660-gdbpy-load-on-attach.patch
-Patch503: %{name}-pr12028-double-free.patch
Patch504: %{name}-bz623749-gcore-relro.patch
-Patch506: %{name}-bz627432-loop-static-self-class.patch
-Patch507: %{name}-bz592031-siginfo-lost-1of5.patch
-Patch508: %{name}-bz592031-siginfo-lost-2of5.patch
-Patch509: %{name}-bz592031-siginfo-lost-3of5.patch
Patch510: %{name}-bz592031-siginfo-lost-4of5.patch
Patch511: %{name}-bz592031-siginfo-lost-5of5.patch
-Patch512: %{name}-gdbindex-bigendian.patch
-Patch513: %{name}-bz637770-ifunc-watchpoint-delete.patch
+Patch526: %{name}-bz634108-solib_address.patch
+Patch541: %{name}-test-pp-hint-error.patch
+Patch542: %{name}-test-pid0-core.patch
+Patch547: %{name}-test-dw2-aranges.patch
+Patch548: %{name}-test-expr-cumulative-archer.patch
+Patch555: %{name}-gcc46-typedef.patch
+Patch556: %{name}-gcc46-stdarg-prologue.patch
+Patch571: %{name}-prelink-rela.patch
+Patch572: %{name}-core-thread-internalerr-1of3.patch
+Patch573: %{name}-core-thread-internalerr-2of3.patch
+Patch574: %{name}-core-thread-internalerr-3of3.patch
+Patch579: %{name}-7.2.50-sparc-add-workaround-to-broken-debug-files.patch
+Patch580: %{name}-bz645773-case-insensitive-1of5.patch
+Patch581: %{name}-bz645773-case-insensitive-2of5.patch
+Patch582: %{name}-bz645773-case-insensitive-3of5.patch
+Patch583: %{name}-bz645773-case-insensitive-4of5.patch
+Patch591: %{name}-bz701131-readline62-1of3.patch
+Patch592: %{name}-bz701131-readline62-2of3.patch
+Patch593: %{name}-bz701131-readline62-3of3.patch
+Patch594: %{name}-stap-double-free.patch
+Patch629: %{name}-vla-frame-set.patch
+Patch630: %{name}-implptr-64bit-1of2.patch
+Patch631: %{name}-implptr-64bit-2of2.patch
# PLD patches
Patch1000: %{name}-readline.patch
BuildRequires: flex
BuildRequires: gettext-devel
BuildRequires: libtool
+BuildRequires: libunwind-devel >= 0.97
BuildRequires: ncurses-devel >= 5.2
BuildRequires: pkgconfig
BuildRequires: readline-devel
%if %{with python}
BuildRequires: python-devel
BuildRequires: rpm-pythonprov
+Obsoletes: python-gdb
%endif
+Requires: libunwind >= 0.97
BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
%description
debugged.
%description gdbserver -l pl.UTF-8
-GDB (GNU debugger) pozwala śledzić programy napisane w C, C++, Javie
-i innych językach programowania poprzez wykonywanie ich w sposób
+GDB (GNU debugger) pozwala śledzić programy napisane w C, C++, Javie i
+innych językach programowania poprzez wykonywanie ich w sposób
kontrolowany oraz wypisywanie ich danych.
Ten pakiet zawiera program pozwalający uruchamiać GDB na innej
maszynie niż ta, na której działa śledzony program.
-%package -n python-%{name}
-Summary: GDB Python bindings
-Summary(pl.UTF-8): Wiązania GDB dla Pythona
-Group: Development/Languages/Python
-Requires: python-libs
-
-%description -n python-%{name}
-GDB Python bindings.
-
-%description -n python-%{name} -l pl.UTF-8
-Wiązania GDB dla Pythona.
-
%package lib
Summary: GDB in the form of a static library
Summary(pl.UTF-8): GDB w postaci biblioteki statycznej
rm -f gdb/jv-exp.c gdb/m2-exp.c gdb/objc-exp.c gdb/p-exp.c
# FEDORA PATCHES -- keep them in same order they do
+# Apply patches defined above.
+
+# Match the Fedora's version info.
%patch2 -p1
-%patch232 -p1
+
+#patch232 -p1
%patch349 -p1
-%patch420 -p1
%patch1 -p1
%patch3 -p1
+
%patch104 -p1
%patch105 -p1
-%patch106 -p1
%patch111 -p1
%patch112 -p1
%patch118 -p1
%patch140 -p1
%patch141 -p1
%patch259 -p1
-%patch142 -p1
%patch145 -p1
-%patch148 -p1
%patch153 -p1
%patch157 -p1
%patch158 -p1
%patch163 -p1
%patch164 -p1
%patch169 -p1
-%patch170 -p1
-%patch176 -p1
%patch188 -p1
-%patch190 -p1
%patch194 -p1
%patch196 -p1
%patch199 -p1
%patch208 -p1
-%patch209 -p1
%patch211 -p1
%patch213 -p1
%patch214 -p1
%patch231 -p1
%patch234 -p1
%patch235 -p1
-%patch241 -p1
%patch245 -p1
%patch247 -p1
%patch254 -p1
%patch258 -p1
%patch260 -p1
-%patch261 -p1
%patch263 -p1
%patch265 -p1
%patch266 -p1
%patch287 -p1
%patch289 -p1
%patch290 -p1
-%patch293 -p1
%patch294 -p1
%patch296 -p1
%patch298 -p1
-%patch304 -p1
%patch309 -p1
%patch311 -p1
%patch315 -p1
%patch317 -p1
-%patch318 -p1
%patch320 -p1
-%patch324 -p1
%patch326 -p1
%patch329 -p1
%patch330 -p1
%patch331 -p1
-%patch332 -p1
%patch337 -p1
%patch343 -p1
%patch348 -p1
%patch408 -p1
%patch412 -p1
%patch417 -p1
-%patch451 -p1
-%patch454 -p1
%patch459 -p1
-%patch461 -p1
%patch470 -p1
%patch475 -p1
%patch486 -p1
%patch415 -p1
-%patch489 -p1
+%patch519 -p1
+%patch490 -p1
%patch491 -p1
-%patch493 -p1
%patch496 -p1
-%patch497 -p1
-%patch499 -p1
-%patch500 -p1
-%patch501 -p1
-%patch502 -p1
-%patch503 -p1
%patch504 -p1
-%patch506 -p1
-%patch507 -p1
-%patch508 -p1
-%patch509 -p1
%patch510 -p1
%patch511 -p1
-%patch512 -p1
-%patch513 -p1
+%patch526 -p1
+%patch541 -p1
+%patch542 -p1
+%patch547 -p1
+%patch548 -p1
+%patch555 -p1
+%patch556 -p1
+%patch571 -p1
+%patch572 -p1
+%patch573 -p1
+%patch574 -p1
+%patch579 -p1
+%patch580 -p1
+%patch581 -p1
+%patch582 -p1
+%patch583 -p1
+%patch591 -p1
+%patch592 -p1
+%patch593 -p1
+%patch594 -p1
+%patch629 -p1
+%patch630 -p1
+%patch631 -p1
+
+%patch393 -p1
+%patch335 -p1
# PLD patches
%patch1000 -p1
--with-gdb-datadir=%{_datadir}/gdb \
--with-separate-debug-dir=/usr/lib/debug \
%if %{with python}
- --with-python \
+ --with-python=yes \
--with-pythondir=%{py_sitescriptdir} \
%else
--without-python \
%attr(755,root,root) %{_bindir}/gstack
%dir %{_datadir}/gdb
%{_datadir}/gdb/syscalls
+%{_datadir}/gdb/python
%{_mandir}/man1/gdb.1*
%{_mandir}/man1/gdbtui.1*
%{_mandir}/man1/gstack.1*
%{_mandir}/man1/gdbserver.1*
%attr(755,root,root) %{_libdir}/libinproctrace.so
-%if %{with python}
-%files -n python-%{name}
-%defattr(644,root,root,755)
-%dir %{py_sitescriptdir}/gdb
-%{py_sitescriptdir}/gdb/*.py[co]
-%dir %{py_sitescriptdir}/gdb/command
-%{py_sitescriptdir}/gdb/command/*.py[co]
-%dir %{py_sitescriptdir}/gdb/function
-%{py_sitescriptdir}/gdb/function/*.py[co]
-# container for 3-rd party stuff.
-%{_datadir}/gdb/auto-load
-%endif
-
%files lib
%defattr(644,root,root,755)
%{_libdir}/libdecnumber.a