diff --git a/.gitignore b/.gitignore index f171a0f..4477a6b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,2 @@ /libstdc++-v3-python-r155978.tar.bz2 -/gdb-7.4.50.20120120.tar.bz2 +/gdb-7.4.50.20120602.tar.bz2 diff --git a/gdb-6.3-readnever-20050907.patch b/gdb-6.3-readnever-20050907.patch index 9f712a7..cffb07b 100644 --- a/gdb-6.3-readnever-20050907.patch +++ b/gdb-6.3-readnever-20050907.patch @@ -11,11 +11,11 @@ * gdb.texinfo (File Options): Document --readnever. -Index: gdb-7.4.50.20111218/gdb/doc/gdb.texinfo +Index: gdb-7.4.50.20120602/gdb/doc/gdb.texinfo =================================================================== ---- gdb-7.4.50.20111218.orig/gdb/doc/gdb.texinfo 2011-12-19 02:52:23.000000000 +0100 -+++ gdb-7.4.50.20111218/gdb/doc/gdb.texinfo 2011-12-19 02:52:25.765407434 +0100 -@@ -1005,6 +1005,12 @@ Read each symbol file's entire symbol ta +--- gdb-7.4.50.20120602.orig/gdb/doc/gdb.texinfo 2012-06-02 18:16:36.000000000 +0200 ++++ gdb-7.4.50.20120602/gdb/doc/gdb.texinfo 2012-06-02 18:25:20.300254019 +0200 +@@ -1020,6 +1020,12 @@ Read each symbol file's entire symbol ta the default, which is to read it incrementally as it is needed. This makes startup slower, but makes future operations faster. @@ -28,11 +28,11 @@ Index: gdb-7.4.50.20111218/gdb/doc/gdb.texinfo @end table @node Mode Options -Index: gdb-7.4.50.20111218/gdb/main.c +Index: gdb-7.4.50.20120602/gdb/main.c =================================================================== ---- gdb-7.4.50.20111218.orig/gdb/main.c 2011-12-19 02:52:23.000000000 +0100 -+++ gdb-7.4.50.20111218/gdb/main.c 2011-12-19 02:52:36.925364438 +0100 -@@ -406,6 +406,7 @@ captured_main (void *data) +--- gdb-7.4.50.20120602.orig/gdb/main.c 2012-06-02 18:16:36.000000000 +0200 ++++ gdb-7.4.50.20120602/gdb/main.c 2012-06-02 18:25:20.302254019 +0200 +@@ -414,6 +414,7 @@ captured_main (void *data) {"xdb", no_argument, &xdb_commands, 1}, {"dbx", no_argument, &dbx_commands, 1}, {"readnow", no_argument, &readnow_symbol_files, 1}, @@ -40,7 +40,7 @@ Index: gdb-7.4.50.20111218/gdb/main.c {"r", no_argument, &readnow_symbol_files, 1}, {"quiet", no_argument, &quiet, 1}, {"q", no_argument, &quiet, 1}, -@@ -1072,6 +1073,7 @@ Options:\n\n\ +@@ -1131,6 +1132,7 @@ Options:\n\n\ fputs_unfiltered (_("\ --quiet Do not print version number on startup.\n\ --readnow Fully read symbol files on first access.\n\ @@ -48,11 +48,11 @@ Index: gdb-7.4.50.20111218/gdb/main.c "), stream); fputs_unfiltered (_("\ --se=FILE Use FILE as symbol file and executable file.\n\ -Index: gdb-7.4.50.20111218/gdb/symfile.c +Index: gdb-7.4.50.20120602/gdb/symfile.c =================================================================== ---- gdb-7.4.50.20111218.orig/gdb/symfile.c 2011-12-15 16:36:55.000000000 +0100 -+++ gdb-7.4.50.20111218/gdb/symfile.c 2011-12-19 02:52:25.767407426 +0100 -@@ -82,6 +82,7 @@ static void clear_symtab_users_cleanup ( +--- gdb-7.4.50.20120602.orig/gdb/symfile.c 2012-05-31 20:44:49.000000000 +0200 ++++ gdb-7.4.50.20120602/gdb/symfile.c 2012-06-02 18:25:20.334254013 +0200 +@@ -80,6 +80,7 @@ static void clear_symtab_users_cleanup ( /* Global variables owned by this file. */ int readnow_symbol_files; /* Read full symbols immediately. */ @@ -60,19 +60,19 @@ Index: gdb-7.4.50.20111218/gdb/symfile.c /* External variables and functions referenced. */ -Index: gdb-7.4.50.20111218/gdb/dwarf2read.c +Index: gdb-7.4.50.20120602/gdb/dwarf2read.c =================================================================== ---- gdb-7.4.50.20111218.orig/gdb/dwarf2read.c 2011-12-19 02:52:23.000000000 +0100 -+++ gdb-7.4.50.20111218/gdb/dwarf2read.c 2011-12-19 02:52:25.769407418 +0100 -@@ -59,6 +59,7 @@ - #include "c-lang.h" +--- gdb-7.4.50.20120602.orig/gdb/dwarf2read.c 2012-06-02 18:16:36.000000000 +0200 ++++ gdb-7.4.50.20120602/gdb/dwarf2read.c 2012-06-02 18:25:32.837250535 +0200 +@@ -63,6 +63,7 @@ #include "valprint.h" + #include "gdbcore.h" /* for gnutarget */ #include +#include "top.h" #include #include "gdb_string.h" -@@ -1405,8 +1406,9 @@ dwarf2_has_info (struct objfile *objfile +@@ -1514,8 +1515,9 @@ dwarf2_has_info (struct objfile *objfile (void *) names); dwarf2_per_objfile->objfile = objfile; } @@ -84,11 +84,11 @@ Index: gdb-7.4.50.20111218/gdb/dwarf2read.c } /* When loading sections, we look either for uncompressed section or for -Index: gdb-7.4.50.20111218/gdb/top.h +Index: gdb-7.4.50.20120602/gdb/top.h =================================================================== ---- gdb-7.4.50.20111218.orig/gdb/top.h 2011-12-16 21:29:28.000000000 +0100 -+++ gdb-7.4.50.20111218/gdb/top.h 2011-12-19 02:52:25.769407418 +0100 -@@ -61,6 +61,7 @@ extern void set_prompt (const char *s); +--- gdb-7.4.50.20120602.orig/gdb/top.h 2012-01-23 18:12:30.000000000 +0100 ++++ gdb-7.4.50.20120602/gdb/top.h 2012-06-02 18:25:20.367254001 +0200 +@@ -60,6 +60,7 @@ extern void set_prompt (const char *s); /* From random places. */ extern int readnow_symbol_files; diff --git a/gdb-6.3-test-pie-20050107.patch b/gdb-6.3-test-pie-20050107.patch index 6111541..f877225 100644 --- a/gdb-6.3-test-pie-20050107.patch +++ b/gdb-6.3-test-pie-20050107.patch @@ -1,8 +1,8 @@ -Index: gdb-7.4.50.20111219/gdb/testsuite/configure.ac +Index: gdb-7.4.50.20120602/gdb/testsuite/configure.ac =================================================================== ---- gdb-7.4.50.20111219.orig/gdb/testsuite/configure.ac 2011-12-19 21:07:02.178472157 +0100 -+++ gdb-7.4.50.20111219/gdb/testsuite/configure.ac 2011-12-19 22:05:02.704432213 +0100 -@@ -97,6 +97,6 @@ AC_OUTPUT([Makefile \ +--- gdb-7.4.50.20120602.orig/gdb/testsuite/configure.ac 2012-04-25 16:07:22.000000000 +0200 ++++ gdb-7.4.50.20120602/gdb/testsuite/configure.ac 2012-06-02 18:24:38.456266545 +0200 +@@ -96,6 +96,6 @@ AC_OUTPUT([Makefile \ gdb.hp/gdb.aCC/Makefile gdb.hp/gdb.compat/Makefile \ gdb.hp/gdb.defects/Makefile gdb.linespec/Makefile \ gdb.mi/Makefile gdb.modula2/Makefile gdb.multi/Makefile \ @@ -10,20 +10,20 @@ Index: gdb-7.4.50.20111219/gdb/testsuite/configure.ac + 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.4.50.20111219/gdb/testsuite/configure +Index: gdb-7.4.50.20120602/gdb/testsuite/configure =================================================================== ---- gdb-7.4.50.20111219.orig/gdb/testsuite/configure 2011-12-19 21:07:02.179472153 +0100 -+++ gdb-7.4.50.20111219/gdb/testsuite/configure 2011-12-19 22:05:02.735432090 +0100 +--- gdb-7.4.50.20120602.orig/gdb/testsuite/configure 2012-04-25 16:07:21.000000000 +0200 ++++ gdb-7.4.50.20120602/gdb/testsuite/configure 2012-06-02 18:25:06.200258240 +0200 @@ -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.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.linespec/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.linespec/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" +-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.go/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.linespec/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.go/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.linespec/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 -@@ -4174,6 +4174,7 @@ do +@@ -4175,6 +4175,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" ;; @@ -31,10 +31,10 @@ Index: gdb-7.4.50.20111219/gdb/testsuite/configure "gdb.python/Makefile") CONFIG_FILES="$CONFIG_FILES gdb.python/Makefile" ;; "gdb.reverse/Makefile") CONFIG_FILES="$CONFIG_FILES gdb.reverse/Makefile" ;; "gdb.stabs/Makefile") CONFIG_FILES="$CONFIG_FILES gdb.stabs/Makefile" ;; -Index: gdb-7.4.50.20111219/gdb/testsuite/gdb.pie/attach.c +Index: gdb-7.4.50.20120602/gdb/testsuite/gdb.pie/attach.c =================================================================== --- /dev/null 1970-01-01 00:00:00.000000000 +0000 -+++ gdb-7.4.50.20111219/gdb/testsuite/gdb.pie/attach.c 2011-12-19 22:05:02.782431905 +0100 ++++ gdb-7.4.50.20120602/gdb/testsuite/gdb.pie/attach.c 2012-06-02 18:24:38.497266532 +0200 @@ -0,0 +1,20 @@ +/* This program is intended to be started outside of gdb, and then + attached to by gdb. Thus, it simply spins in a loop. The loop @@ -56,10 +56,10 @@ Index: gdb-7.4.50.20111219/gdb/testsuite/gdb.pie/attach.c + } + return 0; +} -Index: gdb-7.4.50.20111219/gdb/testsuite/gdb.pie/attach2.c +Index: gdb-7.4.50.20120602/gdb/testsuite/gdb.pie/attach2.c =================================================================== --- /dev/null 1970-01-01 00:00:00.000000000 +0000 -+++ gdb-7.4.50.20111219/gdb/testsuite/gdb.pie/attach2.c 2011-12-19 22:05:02.786431889 +0100 ++++ gdb-7.4.50.20120602/gdb/testsuite/gdb.pie/attach2.c 2012-06-02 18:24:38.504266529 +0200 @@ -0,0 +1,24 @@ +/* This program is intended to be started outside of gdb, and then + attached to by gdb. Thus, it simply spins in a loop. The loop @@ -85,10 +85,10 @@ Index: gdb-7.4.50.20111219/gdb/testsuite/gdb.pie/attach2.c + } + return (0); +} -Index: gdb-7.4.50.20111219/gdb/testsuite/gdb.pie/break.c +Index: gdb-7.4.50.20120602/gdb/testsuite/gdb.pie/break.c =================================================================== --- /dev/null 1970-01-01 00:00:00.000000000 +0000 -+++ gdb-7.4.50.20111219/gdb/testsuite/gdb.pie/break.c 2011-12-19 22:05:02.787431885 +0100 ++++ gdb-7.4.50.20120602/gdb/testsuite/gdb.pie/break.c 2012-06-02 18:24:38.505266529 +0200 @@ -0,0 +1,146 @@ +/* This testcase is part of GDB, the GNU debugger. + @@ -236,10 +236,10 @@ Index: gdb-7.4.50.20111219/gdb/testsuite/gdb.pie/break.c + } + return 0; +} -Index: gdb-7.4.50.20111219/gdb/testsuite/gdb.pie/break1.c +Index: gdb-7.4.50.20120602/gdb/testsuite/gdb.pie/break1.c =================================================================== --- /dev/null 1970-01-01 00:00:00.000000000 +0000 -+++ gdb-7.4.50.20111219/gdb/testsuite/gdb.pie/break1.c 2011-12-19 22:05:02.787431885 +0100 ++++ gdb-7.4.50.20120602/gdb/testsuite/gdb.pie/break1.c 2012-06-02 18:24:38.506266530 +0200 @@ -0,0 +1,44 @@ +/* This testcase is part of GDB, the GNU debugger. + @@ -285,10 +285,10 @@ Index: gdb-7.4.50.20111219/gdb/testsuite/gdb.pie/break1.c +void marker3 (a, b) char *a, *b; {} /* set breakpoint 18 here */ +void marker4 (d) long d; {} /* set breakpoint 13 here */ +#endif -Index: gdb-7.4.50.20111219/gdb/testsuite/gdb.pie/coremaker.c +Index: gdb-7.4.50.20120602/gdb/testsuite/gdb.pie/coremaker.c =================================================================== --- /dev/null 1970-01-01 00:00:00.000000000 +0000 -+++ gdb-7.4.50.20111219/gdb/testsuite/gdb.pie/coremaker.c 2011-12-19 22:05:02.787431885 +0100 ++++ gdb-7.4.50.20120602/gdb/testsuite/gdb.pie/coremaker.c 2012-06-02 18:24:38.506266530 +0200 @@ -0,0 +1,142 @@ +/* Copyright 1992, 1993, 1994, 1995, 1996, 1999 + Free Software Foundation, Inc. @@ -432,10 +432,10 @@ Index: gdb-7.4.50.20111219/gdb/testsuite/gdb.pie/coremaker.c + return 0; +} + -Index: gdb-7.4.50.20111219/gdb/testsuite/gdb.pie/attach.exp +Index: gdb-7.4.50.20120602/gdb/testsuite/gdb.pie/attach.exp =================================================================== --- /dev/null 1970-01-01 00:00:00.000000000 +0000 -+++ gdb-7.4.50.20111219/gdb/testsuite/gdb.pie/attach.exp 2011-12-19 22:05:02.787431885 +0100 ++++ gdb-7.4.50.20120602/gdb/testsuite/gdb.pie/attach.exp 2012-06-02 18:24:38.508266531 +0200 @@ -0,0 +1,417 @@ +# Copyright 1997, 1999, 2002 Free Software Foundation, Inc. + @@ -854,10 +854,10 @@ Index: gdb-7.4.50.20111219/gdb/testsuite/gdb.pie/attach.exp +do_call_attach_tests + +return 0 -Index: gdb-7.4.50.20111219/gdb/testsuite/gdb.pie/break.exp +Index: gdb-7.4.50.20120602/gdb/testsuite/gdb.pie/break.exp =================================================================== --- /dev/null 1970-01-01 00:00:00.000000000 +0000 -+++ gdb-7.4.50.20111219/gdb/testsuite/gdb.pie/break.exp 2011-12-19 23:11:51.092333080 +0100 ++++ gdb-7.4.50.20120602/gdb/testsuite/gdb.pie/break.exp 2012-06-02 18:24:38.510266529 +0200 @@ -0,0 +1,962 @@ +# Copyright 1988, 1990, 1991, 1992, 1994, 1995, 1996, 1997, 1998, 1999, +# 2000, 2002, 2003, 2004 @@ -1374,7 +1374,7 @@ Index: gdb-7.4.50.20111219/gdb/testsuite/gdb.pie/break.exp +# +send_gdb "break $bp_location12 foo\n" +gdb_expect { -+ -re "Junk at end of arguments..*$gdb_prompt $"\ ++ -re "malformed linespec error: unexpected string, \"foo\"\r\n$gdb_prompt $"\ + {pass "breakpoint with trailing garbage disallowed"} + -re "$gdb_prompt $"\ + {fail "breakpoint with trailing garbage disallowed"} @@ -1821,10 +1821,10 @@ Index: gdb-7.4.50.20111219/gdb/testsuite/gdb.pie/break.exp + send_gdb "set args main\n" + gdb_expect -re ".*$gdb_prompt $" {} +} -Index: gdb-7.4.50.20111219/gdb/testsuite/gdb.pie/corefile.exp +Index: gdb-7.4.50.20120602/gdb/testsuite/gdb.pie/corefile.exp =================================================================== --- /dev/null 1970-01-01 00:00:00.000000000 +0000 -+++ gdb-7.4.50.20111219/gdb/testsuite/gdb.pie/corefile.exp 2011-12-19 22:05:02.788431881 +0100 ++++ gdb-7.4.50.20120602/gdb/testsuite/gdb.pie/corefile.exp 2012-06-02 18:24:38.511266528 +0200 @@ -0,0 +1,233 @@ +# Copyright 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000 +# Free Software Foundation, Inc. @@ -2059,10 +2059,10 @@ Index: gdb-7.4.50.20111219/gdb/testsuite/gdb.pie/corefile.exp +gdb_test "up" "#\[0-9\]* *\[0-9xa-fH'\]* in .* \\(.*\\).*" "up in corefile.exp (reinit)" + +gdb_test "core" "No core file now." -Index: gdb-7.4.50.20111219/gdb/testsuite/gdb.pie/Makefile.in +Index: gdb-7.4.50.20120602/gdb/testsuite/gdb.pie/Makefile.in =================================================================== --- /dev/null 1970-01-01 00:00:00.000000000 +0000 -+++ gdb-7.4.50.20111219/gdb/testsuite/gdb.pie/Makefile.in 2011-12-19 22:05:02.788431881 +0100 ++++ gdb-7.4.50.20120602/gdb/testsuite/gdb.pie/Makefile.in 2012-06-02 18:24:38.512266527 +0200 @@ -0,0 +1,19 @@ +VPATH = @srcdir@ +srcdir = @srcdir@ diff --git a/gdb-6.5-bz203661-emit-relocs.patch b/gdb-6.5-bz203661-emit-relocs.patch index 61e0d56..cc8e515 100644 --- a/gdb-6.5-bz203661-emit-relocs.patch +++ b/gdb-6.5-bz203661-emit-relocs.patch @@ -1,14 +1,14 @@ -Index: gdb-7.0.90.20100306/gdb/symfile.c +Index: gdb-7.4.50.20120602/gdb/symfile.c =================================================================== ---- gdb-7.0.90.20100306.orig/gdb/symfile.c 2010-03-06 23:20:35.000000000 +0100 -+++ gdb-7.0.90.20100306/gdb/symfile.c 2010-03-06 23:26:25.000000000 +0100 -@@ -3642,6 +3642,12 @@ default_symfile_relocate (struct objfile - { - bfd *abfd = objfile->obfd; +--- gdb-7.4.50.20120602.orig/gdb/symfile.c 2012-06-02 18:25:20.000000000 +0200 ++++ gdb-7.4.50.20120602/gdb/symfile.c 2012-06-02 18:26:36.145232057 +0200 +@@ -3630,6 +3630,12 @@ default_symfile_relocate (struct objfile + DWO file. */ + bfd *abfd = sectp->owner; + /* Executable files have all the relocations already resolved. -+ * Handle files linked with --emit-relocs. -+ * http://sources.redhat.com/ml/gdb/2006-08/msg00137.html */ ++ Handle files linked with --emit-relocs. ++ http://sources.redhat.com/ml/gdb/2006-08/msg00137.html */ + if ((abfd->flags & EXEC_P) != 0) + return NULL; + diff --git a/gdb-6.5-bz216711-clone-is-outermost.patch b/gdb-6.5-bz216711-clone-is-outermost.patch index debac4e..704e29a 100644 --- a/gdb-6.5-bz216711-clone-is-outermost.patch +++ b/gdb-6.5-bz216711-clone-is-outermost.patch @@ -23,11 +23,11 @@ instead. Port to GDB-6.7. -Index: gdb-7.4.50.20120120/gdb/amd64-linux-tdep.c +Index: gdb-7.4.50.20120602/gdb/amd64-linux-tdep.c =================================================================== ---- gdb-7.4.50.20120120.orig/gdb/amd64-linux-tdep.c 2012-03-02 22:15:48.000000000 +0100 -+++ gdb-7.4.50.20120120/gdb/amd64-linux-tdep.c 2012-03-02 22:16:13.526569163 +0100 -@@ -268,6 +268,80 @@ amd64_linux_register_reggroup_p (struct +--- gdb-7.4.50.20120602.orig/gdb/amd64-linux-tdep.c 2012-06-02 21:05:45.352280128 +0200 ++++ gdb-7.4.50.20120602/gdb/amd64-linux-tdep.c 2012-06-02 21:06:25.536265325 +0200 +@@ -271,6 +271,80 @@ amd64_linux_register_reggroup_p (struct /* Set the program counter for process PTID to PC. */ @@ -87,7 +87,7 @@ Index: gdb-7.4.50.20120120/gdb/amd64-linux-tdep.c +amd64_linux_outermost_frame (struct frame_info *this_frame) +{ + CORE_ADDR pc = get_frame_pc (this_frame); -+ char *name; ++ const char *name; + + find_pc_partial_function (pc, &name, NULL, NULL); + @@ -108,7 +108,7 @@ Index: gdb-7.4.50.20120120/gdb/amd64-linux-tdep.c static void amd64_linux_write_pc (struct regcache *regcache, CORE_ADDR pc) { -@@ -1321,6 +1395,8 @@ amd64_linux_init_abi (struct gdbarch_inf +@@ -1330,6 +1404,8 @@ amd64_linux_init_abi (struct gdbarch_inf tdep->xsave_xcr0_offset = I386_LINUX_XSAVE_XCR0_OFFSET; @@ -117,11 +117,11 @@ Index: gdb-7.4.50.20120120/gdb/amd64-linux-tdep.c /* GNU/Linux uses SVR4-style shared libraries. */ set_solib_svr4_fetch_link_map_offsets (gdbarch, svr4_lp64_fetch_link_map_offsets); -Index: gdb-7.4.50.20120120/gdb/amd64-tdep.c +Index: gdb-7.4.50.20120602/gdb/amd64-tdep.c =================================================================== ---- gdb-7.4.50.20120120.orig/gdb/amd64-tdep.c 2012-01-04 09:16:56.000000000 +0100 -+++ gdb-7.4.50.20120120/gdb/amd64-tdep.c 2012-03-02 22:17:39.133287571 +0100 -@@ -2108,6 +2108,7 @@ amd64_frame_unwind_stop_reason (struct f +--- gdb-7.4.50.20120602.orig/gdb/amd64-tdep.c 2012-06-02 21:05:45.352280128 +0200 ++++ gdb-7.4.50.20120602/gdb/amd64-tdep.c 2012-06-02 21:06:00.437274574 +0200 +@@ -2138,6 +2138,7 @@ amd64_frame_unwind_stop_reason (struct f { struct amd64_frame_cache *cache = amd64_frame_cache (this_frame, this_cache); @@ -129,7 +129,7 @@ Index: gdb-7.4.50.20120120/gdb/amd64-tdep.c if (!cache->base_p) return UNWIND_UNAVAILABLE; -@@ -2116,6 +2117,10 @@ amd64_frame_unwind_stop_reason (struct f +@@ -2146,6 +2147,10 @@ amd64_frame_unwind_stop_reason (struct f if (cache->base == 0) return UNWIND_OUTERMOST; @@ -140,7 +140,7 @@ Index: gdb-7.4.50.20120120/gdb/amd64-tdep.c return UNWIND_NO_REASON; } -@@ -2125,6 +2130,7 @@ amd64_frame_this_id (struct frame_info * +@@ -2155,6 +2160,7 @@ amd64_frame_this_id (struct frame_info * { struct amd64_frame_cache *cache = amd64_frame_cache (this_frame, this_cache); @@ -148,7 +148,7 @@ Index: gdb-7.4.50.20120120/gdb/amd64-tdep.c if (!cache->base_p) return; -@@ -2133,6 +2139,10 @@ amd64_frame_this_id (struct frame_info * +@@ -2163,6 +2169,10 @@ amd64_frame_this_id (struct frame_info * if (cache->base == 0) return; @@ -159,11 +159,11 @@ Index: gdb-7.4.50.20120120/gdb/amd64-tdep.c (*this_id) = frame_id_build (cache->base + 16, cache->pc); } -Index: gdb-7.4.50.20120120/gdb/i386-tdep.c +Index: gdb-7.4.50.20120602/gdb/i386-tdep.c =================================================================== ---- gdb-7.4.50.20120120.orig/gdb/i386-tdep.c 2012-03-02 22:15:48.000000000 +0100 -+++ gdb-7.4.50.20120120/gdb/i386-tdep.c 2012-03-02 22:16:13.528569157 +0100 -@@ -7613,6 +7613,9 @@ i386_gdbarch_init (struct gdbarch_info i +--- gdb-7.4.50.20120602.orig/gdb/i386-tdep.c 2012-06-02 21:05:45.352280128 +0200 ++++ gdb-7.4.50.20120602/gdb/i386-tdep.c 2012-06-02 21:06:00.466274562 +0200 +@@ -7639,6 +7639,9 @@ i386_gdbarch_init (struct gdbarch_info i tdep->xsave_xcr0_offset = -1; @@ -173,10 +173,10 @@ Index: gdb-7.4.50.20120120/gdb/i386-tdep.c tdep->record_regmap = i386_record_regmap; set_gdbarch_long_long_align_bit (gdbarch, 32); -Index: gdb-7.4.50.20120120/gdb/i386-tdep.h +Index: gdb-7.4.50.20120602/gdb/i386-tdep.h =================================================================== ---- gdb-7.4.50.20120120.orig/gdb/i386-tdep.h 2012-03-02 22:15:48.000000000 +0100 -+++ gdb-7.4.50.20120120/gdb/i386-tdep.h 2012-03-02 22:16:13.529569154 +0100 +--- gdb-7.4.50.20120602.orig/gdb/i386-tdep.h 2012-06-02 21:05:45.352280128 +0200 ++++ gdb-7.4.50.20120602/gdb/i386-tdep.h 2012-06-02 21:06:00.486274568 +0200 @@ -219,6 +219,9 @@ struct gdbarch_tdep int (*i386_sysenter_record) (struct regcache *regcache); /* Parse syscall args. */ @@ -187,11 +187,11 @@ Index: gdb-7.4.50.20120120/gdb/i386-tdep.h }; /* Floating-point registers. */ -Index: gdb-7.4.50.20120120/gdb/ia64-tdep.c +Index: gdb-7.4.50.20120602/gdb/ia64-tdep.c =================================================================== ---- gdb-7.4.50.20120120.orig/gdb/ia64-tdep.c 2012-03-02 22:15:48.000000000 +0100 -+++ gdb-7.4.50.20120120/gdb/ia64-tdep.c 2012-03-02 22:16:13.529569154 +0100 -@@ -2181,6 +2181,138 @@ static const struct frame_unwind ia64_fr +--- gdb-7.4.50.20120602.orig/gdb/ia64-tdep.c 2012-06-02 21:05:45.352280128 +0200 ++++ gdb-7.4.50.20120602/gdb/ia64-tdep.c 2012-06-02 21:06:00.490274552 +0200 +@@ -2176,6 +2176,138 @@ static const struct frame_unwind ia64_fr default_frame_sniffer }; @@ -330,7 +330,7 @@ Index: gdb-7.4.50.20120120/gdb/ia64-tdep.c /* Signal trampolines. */ static void -@@ -4153,6 +4285,7 @@ ia64_gdbarch_init (struct gdbarch_info i +@@ -4146,6 +4278,7 @@ ia64_gdbarch_init (struct gdbarch_info i set_gdbarch_dummy_id (gdbarch, ia64_dummy_id); set_gdbarch_unwind_pc (gdbarch, ia64_unwind_pc); @@ -338,10 +338,10 @@ Index: gdb-7.4.50.20120120/gdb/ia64-tdep.c #ifdef HAVE_LIBUNWIND_IA64_H frame_unwind_append_unwinder (gdbarch, &ia64_libunwind_sigtramp_frame_unwind); -Index: gdb-7.4.50.20120120/gdb/testsuite/gdb.threads/bt-clone-stop.c +Index: gdb-7.4.50.20120602/gdb/testsuite/gdb.threads/bt-clone-stop.c =================================================================== --- /dev/null 1970-01-01 00:00:00.000000000 +0000 -+++ gdb-7.4.50.20120120/gdb/testsuite/gdb.threads/bt-clone-stop.c 2012-03-02 22:16:13.530569151 +0100 ++++ gdb-7.4.50.20120602/gdb/testsuite/gdb.threads/bt-clone-stop.c 2012-06-02 21:06:00.514274544 +0200 @@ -0,0 +1,39 @@ +/* This testcase is part of GDB, the GNU debugger. + @@ -382,10 +382,10 @@ Index: gdb-7.4.50.20120120/gdb/testsuite/gdb.threads/bt-clone-stop.c + for (;;) + pause(); +} -Index: gdb-7.4.50.20120120/gdb/testsuite/gdb.threads/bt-clone-stop.exp +Index: gdb-7.4.50.20120602/gdb/testsuite/gdb.threads/bt-clone-stop.exp =================================================================== --- /dev/null 1970-01-01 00:00:00.000000000 +0000 -+++ gdb-7.4.50.20120120/gdb/testsuite/gdb.threads/bt-clone-stop.exp 2012-03-02 22:16:13.530569151 +0100 ++++ gdb-7.4.50.20120602/gdb/testsuite/gdb.threads/bt-clone-stop.exp 2012-06-02 21:06:00.515274547 +0200 @@ -0,0 +1,61 @@ +# Copyright 2006 Free Software Foundation, Inc. + diff --git a/gdb-6.6-buildid-locate-core-as-arg.patch b/gdb-6.6-buildid-locate-core-as-arg.patch index de1ccad..9687712 100644 --- a/gdb-6.6-buildid-locate-core-as-arg.patch +++ b/gdb-6.6-buildid-locate-core-as-arg.patch @@ -58,11 +58,11 @@ Http://sourceware.org/ml/gdb-patches/2010-01/msg00517.html * exec.c (exec_file_attach): Print a more useful error message if the user did "gdb core". -Index: gdb-7.4.50.20111218/gdb/exceptions.h +Index: gdb-7.4.50.20120602/gdb/exceptions.h =================================================================== ---- gdb-7.4.50.20111218.orig/gdb/exceptions.h 2011-10-09 21:21:38.000000000 +0200 -+++ gdb-7.4.50.20111218/gdb/exceptions.h 2011-12-19 01:41:20.900509347 +0100 -@@ -88,6 +88,9 @@ enum errors { +--- gdb-7.4.50.20120602.orig/gdb/exceptions.h 2012-01-04 09:17:01.000000000 +0100 ++++ gdb-7.4.50.20120602/gdb/exceptions.h 2012-06-02 19:59:22.195114052 +0200 +@@ -86,6 +86,9 @@ enum errors { /* DW_OP_GNU_entry_value resolving failed. */ NO_ENTRY_VALUE_ERROR, @@ -72,11 +72,11 @@ Index: gdb-7.4.50.20111218/gdb/exceptions.h /* Add more errors here. */ NR_ERRORS }; -Index: gdb-7.4.50.20111218/gdb/exec.c +Index: gdb-7.4.50.20120602/gdb/exec.c =================================================================== ---- gdb-7.4.50.20111218.orig/gdb/exec.c 2011-03-23 19:23:54.000000000 +0100 -+++ gdb-7.4.50.20111218/gdb/exec.c 2011-12-19 01:41:04.863568846 +0100 -@@ -35,6 +35,7 @@ +--- gdb-7.4.50.20120602.orig/gdb/exec.c 2012-05-29 16:23:39.000000000 +0200 ++++ gdb-7.4.50.20120602/gdb/exec.c 2012-06-02 19:59:22.196114052 +0200 +@@ -33,6 +33,7 @@ #include "arch-utils.h" #include "gdbthread.h" #include "progspace.h" @@ -84,7 +84,7 @@ Index: gdb-7.4.50.20111218/gdb/exec.c #include #include "readline/readline.h" -@@ -254,12 +255,27 @@ exec_file_attach (char *filename, int fr +@@ -251,12 +252,27 @@ exec_file_attach (char *filename, int fr if (!bfd_check_format_matches (exec_bfd, bfd_object, &matching)) { @@ -115,13 +115,13 @@ Index: gdb-7.4.50.20111218/gdb/exec.c } /* FIXME - This should only be run for RS6000, but the ifdef is a poor -Index: gdb-7.4.50.20111218/gdb/main.c +Index: gdb-7.4.50.20120602/gdb/main.c =================================================================== ---- gdb-7.4.50.20111218.orig/gdb/main.c 2011-12-19 00:28:01.000000000 +0100 -+++ gdb-7.4.50.20111218/gdb/main.c 2011-12-19 01:41:04.863568846 +0100 -@@ -248,6 +248,36 @@ captured_command_loop (void *data) - return 1; - } +--- gdb-7.4.50.20120602.orig/gdb/main.c 2012-06-02 19:11:55.000000000 +0200 ++++ gdb-7.4.50.20120602/gdb/main.c 2012-06-02 19:59:42.082107499 +0200 +@@ -266,6 +266,36 @@ typedef struct cmdarg { + /* Define type VEC (cmdarg_s). */ + DEF_VEC_O (cmdarg_s); +/* Call exec_file_attach. If it detected FILENAME is a core file call + core_file_command. Print the original exec_file_attach error only if @@ -156,7 +156,7 @@ Index: gdb-7.4.50.20111218/gdb/main.c static int captured_main (void *data) { -@@ -704,6 +734,8 @@ captured_main (void *data) +@@ -764,6 +794,8 @@ captured_main (void *data) { symarg = argv[optind]; execarg = argv[optind]; @@ -165,7 +165,7 @@ Index: gdb-7.4.50.20111218/gdb/main.c optind++; } -@@ -845,11 +877,25 @@ captured_main (void *data) +@@ -919,11 +951,25 @@ captured_main (void *data) && symarg != NULL && strcmp (execarg, symarg) == 0) { diff --git a/gdb-6.6-buildid-locate-rpm-librpm-workaround.patch b/gdb-6.6-buildid-locate-rpm-librpm-workaround.patch index 5807ace..617bef9 100644 --- a/gdb-6.6-buildid-locate-rpm-librpm-workaround.patch +++ b/gdb-6.6-buildid-locate-rpm-librpm-workaround.patch @@ -1,6 +1,8 @@ ---- ./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 +Index: gdb-7.4.50.20120602/gdb/elfread.c +=================================================================== +--- gdb-7.4.50.20120602.orig/gdb/elfread.c 2012-06-02 21:35:09.669510757 +0200 ++++ gdb-7.4.50.20120602/gdb/elfread.c 2012-06-02 21:35:31.106502660 +0200 +@@ -1658,6 +1658,19 @@ build_id_to_filename (struct build_id *b #include #endif @@ -10,6 +12,7 @@ + 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. */ ++extern int rpmsqEnable (int signum, /* rpmsqAction_t handler */ void *handler); +int +rpmsqEnable (int signum, /* rpmsqAction_t handler */ void *handler) +{ @@ -19,8 +22,10 @@ /* 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 +Index: gdb-7.4.50.20120602/gdb/proc-service.list +=================================================================== +--- gdb-7.4.50.20120602.orig/gdb/proc-service.list 2012-06-02 21:35:09.669510757 +0200 ++++ gdb-7.4.50.20120602/gdb/proc-service.list 2012-06-02 21:35:14.296508989 +0200 @@ -37,4 +37,7 @@ ps_pstop; ps_ptread; diff --git a/gdb-6.6-buildid-locate-rpm.patch b/gdb-6.6-buildid-locate-rpm.patch index 5602e7c..ba64551 100644 --- a/gdb-6.6-buildid-locate-rpm.patch +++ b/gdb-6.6-buildid-locate-rpm.patch @@ -1,7 +1,7 @@ -Index: gdb-7.4.50.20111218/gdb/event-top.c +Index: gdb-7.4.50.20120602/gdb/event-top.c =================================================================== ---- gdb-7.4.50.20111218.orig/gdb/event-top.c 2011-09-21 17:21:28.000000000 +0200 -+++ gdb-7.4.50.20111218/gdb/event-top.c 2011-12-19 01:18:56.087539251 +0100 +--- gdb-7.4.50.20120602.orig/gdb/event-top.c 2012-06-02 21:08:08.651227347 +0200 ++++ gdb-7.4.50.20120602/gdb/event-top.c 2012-06-02 21:08:23.479221885 +0200 @@ -36,6 +36,7 @@ #include "observer.h" #include "continuations.h" @@ -28,11 +28,11 @@ Index: gdb-7.4.50.20111218/gdb/event-top.c /* Each interpreter has its own rules on displaying the command prompt. */ if (!current_interp_display_prompt_p ()) -Index: gdb-7.4.50.20111218/gdb/elfread.c +Index: gdb-7.4.50.20120602/gdb/elfread.c =================================================================== ---- gdb-7.4.50.20111218.orig/gdb/elfread.c 2011-12-19 00:54:09.000000000 +0100 -+++ gdb-7.4.50.20111218/gdb/elfread.c 2011-12-19 01:16:15.248455897 +0100 -@@ -47,6 +47,7 @@ +--- gdb-7.4.50.20120602.orig/gdb/elfread.c 2012-06-02 21:08:08.651227347 +0200 ++++ gdb-7.4.50.20120602/gdb/elfread.c 2012-06-02 21:08:23.482221882 +0200 +@@ -48,6 +48,7 @@ #include "gdbcore.h" #include "gdbcmd.h" #include "observer.h" @@ -40,7 +40,7 @@ Index: gdb-7.4.50.20111218/gdb/elfread.c #include extern void _initialize_elfread (void); -@@ -1622,8 +1623,361 @@ build_id_to_filename (struct build_id *b +@@ -1647,8 +1648,361 @@ build_id_to_filename (struct build_id *b return retval; } @@ -403,7 +403,7 @@ Index: gdb-7.4.50.20111218/gdb/elfread.c avoidance. */ struct missing_filepair -@@ -1677,11 +2031,17 @@ missing_filepair_change (void) +@@ -1702,11 +2056,17 @@ missing_filepair_change (void) /* All their memory came just from missing_filepair_OBSTACK. */ missing_filepair_hash = NULL; } @@ -421,7 +421,7 @@ Index: gdb-7.4.50.20111218/gdb/elfread.c missing_filepair_change (); } -@@ -1748,14 +2108,35 @@ debug_print_missing (const char *binary, +@@ -1773,14 +2133,35 @@ debug_print_missing (const char *binary, *slot = missing_filepair; @@ -464,11 +464,11 @@ Index: gdb-7.4.50.20111218/gdb/elfread.c } static char * -Index: gdb-7.4.50.20111218/gdb/symfile.h +Index: gdb-7.4.50.20120602/gdb/symfile.h =================================================================== ---- gdb-7.4.50.20111218.orig/gdb/symfile.h 2011-12-19 00:54:09.000000000 +0100 -+++ gdb-7.4.50.20111218/gdb/symfile.h 2011-12-19 01:16:15.249455893 +0100 -@@ -568,6 +568,8 @@ extern struct build_id *build_id_addr_ge +--- gdb-7.4.50.20120602.orig/gdb/symfile.h 2012-06-02 21:08:08.651227347 +0200 ++++ gdb-7.4.50.20120602/gdb/symfile.h 2012-06-02 21:08:23.499221877 +0200 +@@ -621,6 +621,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); @@ -477,11 +477,11 @@ Index: gdb-7.4.50.20111218/gdb/symfile.h /* From dwarf2read.c */ -Index: gdb-7.4.50.20111218/gdb/testsuite/lib/gdb.exp +Index: gdb-7.4.50.20120602/gdb/testsuite/lib/gdb.exp =================================================================== ---- gdb-7.4.50.20111218.orig/gdb/testsuite/lib/gdb.exp 2011-12-19 00:54:09.000000000 +0100 -+++ gdb-7.4.50.20111218/gdb/testsuite/lib/gdb.exp 2011-12-19 01:16:15.250455889 +0100 -@@ -1387,7 +1387,7 @@ proc default_gdb_start { } { +--- gdb-7.4.50.20120602.orig/gdb/testsuite/lib/gdb.exp 2012-06-02 21:08:08.651227347 +0200 ++++ gdb-7.4.50.20120602/gdb/testsuite/lib/gdb.exp 2012-06-02 21:08:23.510221873 +0200 +@@ -1388,7 +1388,7 @@ proc default_gdb_start { } { warning "Couldn't set the width to 0." } } @@ -490,11 +490,11 @@ Index: gdb-7.4.50.20111218/gdb/testsuite/lib/gdb.exp send_gdb "set build-id-verbose 0\n" gdb_expect 10 { -re "$gdb_prompt $" { -Index: gdb-7.4.50.20111218/gdb/testsuite/lib/mi-support.exp +Index: gdb-7.4.50.20120602/gdb/testsuite/lib/mi-support.exp =================================================================== ---- gdb-7.4.50.20111218.orig/gdb/testsuite/lib/mi-support.exp 2011-12-19 00:54:49.000000000 +0100 -+++ gdb-7.4.50.20111218/gdb/testsuite/lib/mi-support.exp 2011-12-19 01:20:34.921163977 +0100 -@@ -212,7 +212,7 @@ proc default_mi_gdb_start { args } { +--- gdb-7.4.50.20120602.orig/gdb/testsuite/lib/mi-support.exp 2012-06-02 21:08:08.651227347 +0200 ++++ gdb-7.4.50.20120602/gdb/testsuite/lib/mi-support.exp 2012-06-02 21:08:23.523221869 +0200 +@@ -213,7 +213,7 @@ proc default_mi_gdb_start { args } { warning "Couldn't set the width to 0." } } @@ -503,11 +503,11 @@ Index: gdb-7.4.50.20111218/gdb/testsuite/lib/mi-support.exp send_gdb "190-gdb-set build-id-verbose 0\n" gdb_expect 10 { -re ".*190-gdb-set build-id-verbose 0\r\n190\\\^done\r\n$mi_gdb_prompt$" { -Index: gdb-7.4.50.20111218/gdb/tui/tui-interp.c +Index: gdb-7.4.50.20120602/gdb/tui/tui-interp.c =================================================================== ---- gdb-7.4.50.20111218.orig/gdb/tui/tui-interp.c 2011-09-12 23:24:51.000000000 +0200 -+++ gdb-7.4.50.20111218/gdb/tui/tui-interp.c 2011-12-19 01:16:15.252455883 +0100 -@@ -31,6 +31,7 @@ +--- gdb-7.4.50.20120602.orig/gdb/tui/tui-interp.c 2012-06-02 21:08:08.651227347 +0200 ++++ gdb-7.4.50.20120602/gdb/tui/tui-interp.c 2012-06-02 21:08:23.524221869 +0200 +@@ -30,6 +30,7 @@ #include "tui/tui.h" #include "tui/tui-io.h" #include "exceptions.h" @@ -515,15 +515,16 @@ Index: gdb-7.4.50.20111218/gdb/tui/tui-interp.c /* Set to 1 when the TUI mode must be activated when we first start gdb. */ -Index: gdb-7.4.50.20111218/gdb/aclocal.m4 +Index: gdb-7.4.50.20120602/gdb/aclocal.m4 =================================================================== ---- gdb-7.4.50.20111218.orig/gdb/aclocal.m4 2011-02-15 22:05:53.000000000 +0100 -+++ gdb-7.4.50.20111218/gdb/aclocal.m4 2011-12-19 01:16:15.252455883 +0100 -@@ -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'.])]) +--- gdb-7.4.50.20120602.orig/gdb/aclocal.m4 2012-06-02 21:08:08.651227347 +0200 ++++ gdb-7.4.50.20120602/gdb/aclocal.m4 2012-06-02 21:08:23.545221858 +0200 +@@ -11,6 +11,164 @@ + # even the implied warranty of MERCHANTABILITY or FITNESS FOR A + # PARTICULAR PURPOSE. +# pkg.m4 - Macros to locate and utilise pkg-config. -*- Autoconf -*- ++# serial 1 (pkg-config-0.24) +# +# Copyright © 2004 Scott James Remnant . +# @@ -551,7 +552,10 @@ Index: gdb-7.4.50.20111218/gdb/aclocal.m4 +AC_DEFUN([PKG_PROG_PKG_CONFIG], +[m4_pattern_forbid([^_?PKG_[A-Z_]+$]) +m4_pattern_allow([^PKG_CONFIG(_PATH)?$]) -+AC_ARG_VAR([PKG_CONFIG], [path to pkg-config utility])dnl ++AC_ARG_VAR([PKG_CONFIG], [path to pkg-config utility]) ++AC_ARG_VAR([PKG_CONFIG_PATH], [directories to add to pkg-config's search path]) ++AC_ARG_VAR([PKG_CONFIG_LIBDIR], [path overriding pkg-config's built-in search path]) ++ +if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then + AC_PATH_TOOL([PKG_CONFIG], [pkg-config]) +fi @@ -564,7 +568,6 @@ Index: gdb-7.4.50.20111218/gdb/aclocal.m4 + AC_MSG_RESULT([no]) + PKG_CONFIG="" + fi -+ +fi[]dnl +])# PKG_PROG_PKG_CONFIG + @@ -573,21 +576,20 @@ Index: gdb-7.4.50.20111218/gdb/aclocal.m4 +# Check to see whether a particular set of modules exists. Similar +# to PKG_CHECK_MODULES(), but does not set variables or print errors. +# -+# -+# Similar to PKG_CHECK_MODULES, make sure that the first instance of -+# this or PKG_CHECK_MODULES is called, or make sure to call -+# PKG_CHECK_EXISTS manually ++# Please remember that m4 expands AC_REQUIRE([PKG_PROG_PKG_CONFIG]) ++# only at the first occurence in configure.ac, so if the first place ++# it's called might be skipped (such as if it is within an "if", you ++# have to call PKG_CHECK_EXISTS manually +# -------------------------------------------------------------- +AC_DEFUN([PKG_CHECK_EXISTS], +[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl +if test -n "$PKG_CONFIG" && \ + AC_RUN_LOG([$PKG_CONFIG --exists --print-errors "$1"]); then -+ m4_ifval([$2], [$2], [:]) ++ m4_default([$2], [:]) +m4_ifvaln([$3], [else + $3])dnl +fi]) + -+ +# _PKG_CONFIG([VARIABLE], [COMMAND], [MODULES]) +# --------------------------------------------- +m4_define([_PKG_CONFIG], @@ -640,6 +642,7 @@ Index: gdb-7.4.50.20111218/gdb/aclocal.m4 +See the pkg-config man page for more details.]) + +if test $pkg_failed = yes; then ++ AC_MSG_RESULT([no]) + _PKG_SHORT_ERRORS_SUPPORTED + if test $_pkg_short_errors_supported = yes; then + $1[]_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors "$2" 2>&1` @@ -649,7 +652,7 @@ Index: gdb-7.4.50.20111218/gdb/aclocal.m4 + # Put the nasty error message in config.log where it belongs + echo "$$1[]_PKG_ERRORS" >&AS_MESSAGE_LOG_FD + -+ ifelse([$4], , [AC_MSG_ERROR(dnl ++ m4_default([$4], [AC_MSG_ERROR( +[Package requirements ($2) were not met: + +$$1_PKG_ERRORS @@ -657,36 +660,35 @@ Index: gdb-7.4.50.20111218/gdb/aclocal.m4 +Consider adjusting the PKG_CONFIG_PATH environment variable if you +installed software in a non-standard prefix. + -+_PKG_TEXT -+])], -+ [AC_MSG_RESULT([no]) -+ $4]) ++_PKG_TEXT]) ++ ]) +elif test $pkg_failed = untried; then -+ ifelse([$4], , [AC_MSG_FAILURE(dnl ++ AC_MSG_RESULT([no]) ++ m4_default([$4], [AC_MSG_FAILURE( +[The pkg-config script could not be found or is too old. Make sure it +is in your PATH or set the PKG_CONFIG environment variable to the full +path to pkg-config. + +_PKG_TEXT + -+To get pkg-config, see .])], -+ [$4]) ++To get pkg-config, see .]) ++ ]) +else + $1[]_CFLAGS=$pkg_cv_[]$1[]_CFLAGS + $1[]_LIBS=$pkg_cv_[]$1[]_LIBS + AC_MSG_RESULT([yes]) -+ ifelse([$3], , :, [$3]) ++ $3 +fi[]dnl +])# PKG_CHECK_MODULES + - # Copyright (C) 2002, 2003, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. - # - # This file is free software; the Free Software Foundation -Index: gdb-7.4.50.20111218/gdb/config.in + # AM_CONDITIONAL -*- Autoconf -*- + + # Copyright (C) 1997, 2000, 2001, 2003, 2004, 2005, 2006, 2008 +Index: gdb-7.4.50.20120602/gdb/config.in =================================================================== ---- gdb-7.4.50.20111218.orig/gdb/config.in 2011-11-20 09:59:56.000000000 +0100 -+++ gdb-7.4.50.20111218/gdb/config.in 2011-12-19 01:16:15.253455879 +0100 -@@ -46,6 +46,9 @@ +--- gdb-7.4.50.20120602.orig/gdb/config.in 2012-06-02 21:08:08.651227347 +0200 ++++ gdb-7.4.50.20120602/gdb/config.in 2012-06-02 21:08:23.546221859 +0200 +@@ -36,6 +36,9 @@ /* Define to BFD's default target vector. */ #undef DEFAULT_BFD_VEC @@ -696,70 +698,78 @@ Index: gdb-7.4.50.20111218/gdb/config.in /* Define to 1 if translation of program messages to the user's native language is requested. */ #undef ENABLE_NLS -@@ -233,6 +236,9 @@ +@@ -216,6 +219,9 @@ /* Define if Python 2.7 is being used. */ #undef HAVE_LIBPYTHON2_7 +/* Define if librpm library is being used. */ +#undef HAVE_LIBRPM + - /* Define if libunwind library is being used. */ - #undef HAVE_LIBUNWIND + /* Define to 1 if you have the header file. */ + #undef HAVE_LIBUNWIND_IA64_H -Index: gdb-7.4.50.20111218/gdb/configure +Index: gdb-7.4.50.20120602/gdb/configure =================================================================== ---- gdb-7.4.50.20111218.orig/gdb/configure 2011-11-20 09:59:56.000000000 +0100 -+++ gdb-7.4.50.20111218/gdb/configure 2011-12-19 01:16:15.256455867 +0100 -@@ -684,6 +684,9 @@ REPORT_BUGS_TO +--- gdb-7.4.50.20120602.orig/gdb/configure 2012-06-02 21:08:08.651227347 +0200 ++++ gdb-7.4.50.20120602/gdb/configure 2012-06-02 21:20:53.245838121 +0200 +@@ -680,6 +680,11 @@ REPORT_BUGS_TO PKGVERSION TARGET_OBS subdirs +RPM_LIBS +RPM_CFLAGS ++PKG_CONFIG_LIBDIR ++PKG_CONFIG_PATH +PKG_CONFIG GDB_DATADIR DEBUGDIR - am__fastdepCC_FALSE -@@ -952,6 +955,7 @@ enable_dependency_tracking - with_separate_debug_dir - with_gdb_datadir + MAKEINFO_EXTRA_FLAGS +@@ -780,6 +785,7 @@ with_gdb_datadir with_relocated_sources + with_auto_load_dir + with_auto_load_safe_path +with_rpm enable_targets enable_64_bit_bfd enable_gdbcli -@@ -995,6 +999,9 @@ LDFLAGS - LIBS - CPPFLAGS +@@ -825,6 +831,11 @@ CPPFLAGS CPP + MAKEINFO + MAKEINFOFLAGS +PKG_CONFIG ++PKG_CONFIG_PATH ++PKG_CONFIG_LIBDIR +RPM_CFLAGS +RPM_LIBS YACC YFLAGS XMKMF' -@@ -1658,6 +1665,8 @@ Optional Packages: - [DATADIR/gdb] - --with-relocated-sources=PATH - automatically relocate this path for source files +@@ -1494,6 +1505,8 @@ Optional Packages: + [--with-auto-load-dir] + --without-auto-load-safe-path + do not restrict auto-loaded files locations + --with-rpm query rpm database for missing debuginfos (yes/no, + def. auto=librpm.so) - --with-libunwind use libunwind frame unwinding support + --with-libunwind-ia64 use libunwind frame unwinding for ia64 targets --with-curses use the curses library instead of the termcap library -@@ -1696,6 +1705,9 @@ Some influential environment variables: - CPPFLAGS C/C++/Objective C preprocessor flags, e.g. -I if - you have headers in a nonstandard directory - CPP C preprocessor +@@ -1535,6 +1548,13 @@ Some influential environment variables: + MAKEINFO Parent configure detects if it is of sufficient version. + MAKEINFOFLAGS + Parameters for MAKEINFO. + PKG_CONFIG path to pkg-config utility ++ PKG_CONFIG_PATH ++ directories to add to pkg-config's search path ++ PKG_CONFIG_LIBDIR ++ path overriding pkg-config's built-in search path + RPM_CFLAGS C compiler flags for RPM, overriding pkg-config + RPM_LIBS linker flags for RPM, overriding pkg-config 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. -@@ -7968,6 +7980,486 @@ _ACEOF - fi - +@@ -5015,6 +5035,491 @@ _ACEOF + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $with_auto_load_safe_path" >&5 + $as_echo "$with_auto_load_safe_path" >&6; } +# Integration with rpm library to support missing debuginfo suggestions. +# --without-rpm: Disable any rpm support. @@ -988,6 +998,10 @@ Index: gdb-7.4.50.20111218/gdb/configure + fi + + ++ ++ ++ ++ +if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then + if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}pkg-config", so it can be a program name with args. @@ -1100,7 +1114,6 @@ Index: gdb-7.4.50.20111218/gdb/configure +$as_echo "no" >&6; } + PKG_CONFIG="" + fi -+ +fi + +pkg_failed=no @@ -1143,6 +1156,8 @@ Index: gdb-7.4.50.20111218/gdb/configure + + +if test $pkg_failed = yes; then ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 ++$as_echo "no" >&6; } + +if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then + _pkg_short_errors_supported=yes @@ -1157,10 +1172,10 @@ Index: gdb-7.4.50.20111218/gdb/configure + # Put the nasty error message in config.log where it belongs + echo "$RPM_PKG_ERRORS" >&5 + -+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -+$as_echo "no" >&6; } -+ HAVE_LIBRPM=false ++ HAVE_LIBRPM=false +elif test $pkg_failed = untried; then ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 ++$as_echo "no" >&6; } + HAVE_LIBRPM=false +else + RPM_CFLAGS=$pkg_cv_RPM_CFLAGS @@ -1244,13 +1259,13 @@ Index: gdb-7.4.50.20111218/gdb/configure subdirs="$subdirs testsuite" -Index: gdb-7.4.50.20111218/gdb/configure.ac +Index: gdb-7.4.50.20120602/gdb/configure.ac =================================================================== ---- gdb-7.4.50.20111218.orig/gdb/configure.ac 2011-11-20 09:59:56.000000000 +0100 -+++ gdb-7.4.50.20111218/gdb/configure.ac 2011-12-19 01:16:15.257455863 +0100 -@@ -140,6 +140,199 @@ AS_HELP_STRING([--with-relocated-sources - [Relocated directory for source files. ]) - ]) +--- gdb-7.4.50.20120602.orig/gdb/configure.ac 2012-06-02 21:08:08.651227347 +0200 ++++ gdb-7.4.50.20120602/gdb/configure.ac 2012-06-02 21:08:23.560221855 +0200 +@@ -166,6 +166,199 @@ AC_DEFINE_DIR(AUTO_LOAD_SAFE_PATH, escap + [Directories safe to hold auto-loaded files.]) + AC_MSG_RESULT([$with_auto_load_safe_path]) +# Integration with rpm library to support missing debuginfo suggestions. +# --without-rpm: Disable any rpm support. @@ -1448,30 +1463,11 @@ Index: gdb-7.4.50.20111218/gdb/configure.ac AC_CONFIG_SUBDIRS(testsuite) # Check whether to support alternative target configurations -Index: gdb-7.4.50.20111218/gdb/acinclude.m4 -=================================================================== ---- gdb-7.4.50.20111218.orig/gdb/acinclude.m4 2010-05-27 05:40:45.000000000 +0200 -+++ gdb-7.4.50.20111218/gdb/acinclude.m4 2011-12-19 01:16:15.257455863 +0100 -@@ -1,3 +1,5 @@ -+# serial 1 -+ - dnl written by Rob Savoye for Cygnus Support - dnl major rewriting for Tcl 7.5 by Don Libes - -@@ -81,8 +83,6 @@ AC_MSG_RESULT(yes) - # Foundation, Inc., 51 Franklin Street, Fifth Floor, - # Boston, MA 02110-1301, USA. - --# serial 1 -- - # @defmac AC_PROG_CC_STDC - # @maindex PROG_CC_STDC - # @ovindex CC -Index: gdb-7.4.50.20111218/gdb/corelow.c +Index: gdb-7.4.50.20120602/gdb/corelow.c =================================================================== ---- gdb-7.4.50.20111218.orig/gdb/corelow.c 2011-12-19 00:54:09.000000000 +0100 -+++ gdb-7.4.50.20111218/gdb/corelow.c 2011-12-19 01:16:15.258455859 +0100 -@@ -321,7 +321,7 @@ build_id_locate_exec (int from_tty) +--- gdb-7.4.50.20120602.orig/gdb/corelow.c 2012-06-02 21:08:08.651227347 +0200 ++++ gdb-7.4.50.20120602/gdb/corelow.c 2012-06-02 21:08:23.561221855 +0200 +@@ -317,7 +317,7 @@ build_id_locate_exec (int from_tty) symfile_objfile->flags |= OBJF_BUILD_ID_CORE_LOADED; } else diff --git a/gdb-6.6-buildid-locate.patch b/gdb-6.6-buildid-locate.patch index 7368d8a..0a96035 100644 --- a/gdb-6.6-buildid-locate.patch +++ b/gdb-6.6-buildid-locate.patch @@ -1,7 +1,7 @@ -Index: gdb-7.4.50.20120120/gdb/corelow.c +Index: gdb-7.4.50.20120602/gdb/corelow.c =================================================================== ---- gdb-7.4.50.20120120.orig/gdb/corelow.c 2012-01-10 17:30:44.000000000 +0100 -+++ gdb-7.4.50.20120120/gdb/corelow.c 2012-01-21 00:02:58.720401792 +0100 +--- gdb-7.4.50.20120602.orig/gdb/corelow.c 2012-06-02 21:07:03.695251272 +0200 ++++ gdb-7.4.50.20120602/gdb/corelow.c 2012-06-02 21:07:16.464246569 +0200 @@ -46,6 +46,9 @@ #include "filenames.h" #include "progspace.h" @@ -12,7 +12,7 @@ Index: gdb-7.4.50.20120120/gdb/corelow.c #ifndef O_LARGEFILE #define O_LARGEFILE 0 -@@ -273,6 +276,52 @@ add_to_thread_list (bfd *abfd, asection +@@ -275,6 +278,52 @@ add_to_thread_list (bfd *abfd, asection inferior_ptid = ptid; /* Yes, make it current. */ } @@ -65,7 +65,7 @@ Index: gdb-7.4.50.20120120/gdb/corelow.c /* This routine opens and sets up the core file bfd. */ static void -@@ -375,6 +424,12 @@ core_open (char *filename, int from_tty) +@@ -377,6 +426,12 @@ core_open (char *filename, int from_tty) push_target (&core_ops); discard_cleanups (old_chain); @@ -78,7 +78,7 @@ Index: gdb-7.4.50.20120120/gdb/corelow.c /* Do this before acknowledging the inferior, so if post_create_inferior throws (can happen easilly if you're loading a core file with the wrong exec), we aren't left with threads -@@ -934,4 +989,11 @@ _initialize_corelow (void) +@@ -935,4 +990,11 @@ _initialize_corelow (void) init_core_ops (); add_target (&core_ops); @@ -90,11 +90,11 @@ Index: gdb-7.4.50.20120120/gdb/corelow.c + NULL, NULL, NULL, + &setlist, &showlist); } -Index: gdb-7.4.50.20120120/gdb/doc/gdb.texinfo +Index: gdb-7.4.50.20120602/gdb/doc/gdb.texinfo =================================================================== ---- gdb-7.4.50.20120120.orig/gdb/doc/gdb.texinfo 2012-01-21 00:02:36.000000000 +0100 -+++ gdb-7.4.50.20120120/gdb/doc/gdb.texinfo 2012-01-21 00:02:41.619463607 +0100 -@@ -16015,6 +16015,27 @@ information files. +--- gdb-7.4.50.20120602.orig/gdb/doc/gdb.texinfo 2012-06-02 21:07:03.695251272 +0200 ++++ gdb-7.4.50.20120602/gdb/doc/gdb.texinfo 2012-06-02 21:07:16.480246563 +0200 +@@ -16502,6 +16502,27 @@ information files. @end table @@ -122,10 +122,10 @@ Index: gdb-7.4.50.20120120/gdb/doc/gdb.texinfo @cindex @code{.gnu_debuglink} sections @cindex debug link sections A debug link is a special section of the executable file named -Index: gdb-7.4.50.20120120/gdb/solib-svr4.c +Index: gdb-7.4.50.20120602/gdb/solib-svr4.c =================================================================== ---- gdb-7.4.50.20120120.orig/gdb/solib-svr4.c 2012-01-04 09:17:11.000000000 +0100 -+++ gdb-7.4.50.20120120/gdb/solib-svr4.c 2012-01-21 00:02:41.620463603 +0100 +--- gdb-7.4.50.20120602.orig/gdb/solib-svr4.c 2012-06-02 21:07:03.695251272 +0200 ++++ gdb-7.4.50.20120602/gdb/solib-svr4.c 2012-06-02 21:07:16.510246552 +0200 @@ -1227,9 +1227,52 @@ svr4_read_so_list (CORE_ADDR lm, struct continue; } @@ -182,10 +182,10 @@ Index: gdb-7.4.50.20120120/gdb/solib-svr4.c xfree (buffer); /* If this entry has no name, or its name matches the name -Index: gdb-7.4.50.20120120/gdb/elfread.c +Index: gdb-7.4.50.20120602/gdb/elfread.c =================================================================== ---- gdb-7.4.50.20120120.orig/gdb/elfread.c 2012-01-21 00:02:33.000000000 +0100 -+++ gdb-7.4.50.20120120/gdb/elfread.c 2012-01-21 00:02:41.621463599 +0100 +--- gdb-7.4.50.20120602.orig/gdb/elfread.c 2012-06-02 21:07:03.695251272 +0200 ++++ gdb-7.4.50.20120602/gdb/elfread.c 2012-06-02 21:07:56.264232049 +0200 @@ -44,6 +44,11 @@ #include "gdbthread.h" #include "regcache.h" @@ -198,7 +198,7 @@ Index: gdb-7.4.50.20120120/gdb/elfread.c extern void _initialize_elfread (void); -@@ -1076,16 +1081,65 @@ elf_gnu_ifunc_resolver_return_stop (stru +@@ -1072,16 +1077,65 @@ elf_gnu_ifunc_resolver_return_stop (stru update_breakpoint_locations (b, sals, sals_end); } @@ -223,8 +223,9 @@ Index: gdb-7.4.50.20120120/gdb/elfread.c -/* 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 * + + static struct build_id * +-build_id_bfd_get (bfd *abfd) +build_id_buf_get (bfd *templ, gdb_byte *buf, bfd_size_type size) +{ + bfd_byte *p; @@ -259,14 +260,13 @@ Index: gdb-7.4.50.20120120/gdb/elfread.c + +/* Separate debuginfo files have corrupted PHDR but SHDR is correct there. + Locate NT_GNU_BUILD_ID from ABFD and return its content. */ - - static struct build_id * --build_id_bfd_get (bfd *abfd) ++ ++static struct build_id * +build_id_bfd_shdr_get (bfd *abfd) { struct build_id *retval; -@@ -1101,6 +1155,348 @@ build_id_bfd_get (bfd *abfd) +@@ -1097,6 +1151,348 @@ build_id_bfd_get (bfd *abfd) return retval; } @@ -362,7 +362,7 @@ Index: gdb-7.4.50.20120120/gdb/elfread.c +/* Translate an ELF program header table entry in external format into an + ELF program header table entry in internal format. */ + -+void ++static void +elf_swap_phdr_in (bfd *abfd, + const Elf64_External_Phdr *src64, + Elf_Internal_Phdr *dst) @@ -615,7 +615,7 @@ Index: gdb-7.4.50.20120120/gdb/elfread.c /* Return if FILENAME has NT_GNU_BUILD_ID matching the CHECK value. */ static int -@@ -1115,7 +1511,7 @@ build_id_verify (const char *filename, s +@@ -1111,7 +1507,7 @@ build_id_verify (const char *filename, s if (abfd == NULL) return 0; @@ -624,7 +624,7 @@ Index: gdb-7.4.50.20120120/gdb/elfread.c if (found == NULL) warning (_("File \"%s\" has no build-id, file skipped"), filename); -@@ -1133,14 +1529,15 @@ build_id_verify (const char *filename, s +@@ -1129,17 +1525,18 @@ build_id_verify (const char *filename, s return retval; } @@ -636,6 +636,9 @@ Index: gdb-7.4.50.20120120/gdb/elfread.c { char *link, *debugdir, *retval = NULL; + char *link_all = NULL; + VEC (char_ptr) *debugdir_vec; + struct cleanup *back_to; + int ix; /* DEBUG_FILE_DIRECTORY/.build-id/ab/cdef */ - link = alloca (strlen (debug_file_directory) + (sizeof "/.build-id/" - 1) + 1 @@ -644,30 +647,26 @@ Index: gdb-7.4.50.20120120/gdb/elfread.c /* Keep backward compatibility so that DEBUG_FILE_DIRECTORY being "" will cause "/.build-id/..." lookups. */ -@@ -1151,6 +1548,8 @@ build_id_to_debug_filename (struct build - char *s, *debugdir_end; +@@ -1152,6 +1549,8 @@ build_id_to_debug_filename (struct build + size_t debugdir_len = strlen (debugdir); gdb_byte *data = build_id->data; size_t size = build_id->size; + unsigned seqno; + struct stat statbuf_trash; + char *s; - while (*debugdir == DIRNAME_SEPARATOR) - debugdir++; -@@ -1171,39 +1570,242 @@ build_id_to_debug_filename (struct build + memcpy (link, debugdir, debugdir_len); +@@ -1166,37 +1565,240 @@ build_id_to_debug_filename (struct build *s++ = '/'; while (size-- > 0) s += sprintf (s, "%02x", (unsigned) *data++); - strcpy (s, ".debug"); -- + - /* lrealpath() is expensive even for the usually non-existent files. */ - if (access (link, F_OK) == 0) - retval = lrealpath (link); - -- if (retval != NULL && !build_id_verify (retval, build_id)) + for (seqno = 0;; seqno++) - { -- xfree (retval); -- retval = NULL; ++ { + char *s2; + + if (seqno) @@ -685,7 +684,8 @@ Index: gdb-7.4.50.20120120/gdb/elfread.c + strcpy (s2, ".debug"); + else + *s2 = 0; -+ + +- if (retval != NULL && !build_id_verify (retval, build_id)) + /* `access' automatically dereferences LINK. */ + if (lstat (link, &statbuf_trash) != 0) + { @@ -703,15 +703,16 @@ Index: gdb-7.4.50.20120120/gdb/elfread.c + + if (retval) + break; - } - - if (retval != NULL) -- break; -+ { -+ /* LINK_ALL is not used below in this non-NULL RETVAL case. */ -+ break; + } + ++ if (retval != NULL) + { +- xfree (retval); +- retval = NULL; ++ /* LINK_ALL is not used below in this non-NULL RETVAL case. */ ++ break; + } + + if (link_all == NULL) + link_all = xstrdup (link); + else @@ -726,14 +727,12 @@ Index: gdb-7.4.50.20120120/gdb/elfread.c + + strcpy (&link_all[len_orig + 1], link); + } - - debugdir = debugdir_end; - } - while (*debugdir != 0); - ++ } ++ + if (link_return != NULL) + { -+ if (retval != NULL) + if (retval != NULL) +- break; + { + *link_return = link; + link = NULL; @@ -743,13 +742,14 @@ Index: gdb-7.4.50.20120120/gdb/elfread.c + *link_return = link_all; + link_all = NULL; + } -+ } + } + xfree (link); + xfree (link_all); -+ -+ return retval; -+} -+ + + do_cleanups (back_to); + return retval; + } + +/* This MISSING_FILEPAIR_HASH tracker is used only for the duplicite messages + Try to install the hash file ... + avoidance. */ @@ -772,9 +772,9 @@ Index: gdb-7.4.50.20120120/gdb/elfread.c + + retval = obstack_alloc (&missing_filepair_obstack, size); + memset (retval, 0, size); - return retval; - } - ++ return retval; ++} ++ +static hashval_t +missing_filepair_hash_func (const struct missing_filepair *elem) +{ @@ -908,7 +908,7 @@ Index: gdb-7.4.50.20120120/gdb/elfread.c xfree (build_id); /* Prevent looping on a stripped .debug file. */ if (build_id_name != NULL -@@ -1214,7 +1816,7 @@ find_separate_debug_file_by_buildid (str +@@ -1207,7 +1809,7 @@ find_separate_debug_file_by_buildid (str xfree (build_id_name); } else if (build_id_name != NULL) @@ -917,7 +917,7 @@ Index: gdb-7.4.50.20120120/gdb/elfread.c } return NULL; } -@@ -1434,9 +2036,10 @@ elf_symfile_read (struct objfile *objfil +@@ -1427,9 +2029,10 @@ elf_symfile_read (struct objfile *objfil `.note.gnu.build-id'. */ else if (!objfile_has_partial_symbols (objfile)) { @@ -930,7 +930,7 @@ Index: gdb-7.4.50.20120120/gdb/elfread.c if (debugfile == NULL) debugfile = find_separate_debug_file_by_debuglink (objfile); -@@ -1448,6 +2051,12 @@ elf_symfile_read (struct objfile *objfil +@@ -1441,6 +2044,12 @@ elf_symfile_read (struct objfile *objfil symbol_file_add_separate (abfd, symfile_flags, objfile); xfree (debugfile); } @@ -943,7 +943,7 @@ Index: gdb-7.4.50.20120120/gdb/elfread.c } } -@@ -1931,4 +2540,16 @@ _initialize_elfread (void) +@@ -1770,4 +2379,16 @@ _initialize_elfread (void) elf_objfile_gnu_ifunc_cache_data = register_objfile_data (); gnu_ifunc_fns_p = &elf_gnu_ifunc_fns; @@ -960,11 +960,11 @@ Index: gdb-7.4.50.20120120/gdb/elfread.c + + observer_attach_executable_changed (debug_print_executable_changed); } -Index: gdb-7.4.50.20120120/gdb/symfile.h +Index: gdb-7.4.50.20120602/gdb/symfile.h =================================================================== ---- gdb-7.4.50.20120120.orig/gdb/symfile.h 2012-01-21 00:02:33.000000000 +0100 -+++ gdb-7.4.50.20120120/gdb/symfile.h 2012-01-21 00:02:41.621463599 +0100 -@@ -614,6 +614,13 @@ void free_symfile_segment_data (struct s +--- gdb-7.4.50.20120602.orig/gdb/symfile.h 2012-06-02 21:07:03.695251272 +0200 ++++ gdb-7.4.50.20120602/gdb/symfile.h 2012-06-02 21:07:16.524246547 +0200 +@@ -615,6 +615,13 @@ void free_symfile_segment_data (struct s extern struct cleanup *increment_reading_symtab (void); @@ -978,11 +978,11 @@ Index: gdb-7.4.50.20120120/gdb/symfile.h /* From dwarf2read.c */ /* Names for a dwarf2 debugging section. The field NORMAL is the normal -Index: gdb-7.4.50.20120120/gdb/testsuite/lib/gdb.exp +Index: gdb-7.4.50.20120602/gdb/testsuite/lib/gdb.exp =================================================================== ---- gdb-7.4.50.20120120.orig/gdb/testsuite/lib/gdb.exp 2012-01-21 00:02:36.000000000 +0100 -+++ gdb-7.4.50.20120120/gdb/testsuite/lib/gdb.exp 2012-01-21 00:02:41.622463596 +0100 -@@ -1385,6 +1385,16 @@ proc default_gdb_start { } { +--- gdb-7.4.50.20120602.orig/gdb/testsuite/lib/gdb.exp 2012-06-02 21:07:03.695251272 +0200 ++++ gdb-7.4.50.20120602/gdb/testsuite/lib/gdb.exp 2012-06-02 21:07:16.526246546 +0200 +@@ -1388,6 +1388,16 @@ proc default_gdb_start { } { warning "Couldn't set the width to 0." } } @@ -999,11 +999,11 @@ Index: gdb-7.4.50.20120120/gdb/testsuite/lib/gdb.exp return 0; } -Index: gdb-7.4.50.20120120/gdb/testsuite/lib/mi-support.exp +Index: gdb-7.4.50.20120602/gdb/testsuite/lib/mi-support.exp =================================================================== ---- gdb-7.4.50.20120120.orig/gdb/testsuite/lib/mi-support.exp 2012-01-12 23:28:34.000000000 +0100 -+++ gdb-7.4.50.20120120/gdb/testsuite/lib/mi-support.exp 2012-01-21 00:02:41.622463596 +0100 -@@ -212,6 +212,16 @@ proc default_mi_gdb_start { args } { +--- gdb-7.4.50.20120602.orig/gdb/testsuite/lib/mi-support.exp 2012-06-02 21:07:03.695251272 +0200 ++++ gdb-7.4.50.20120602/gdb/testsuite/lib/mi-support.exp 2012-06-02 21:07:16.535246544 +0200 +@@ -213,6 +213,16 @@ proc default_mi_gdb_start { args } { warning "Couldn't set the width to 0." } } @@ -1020,11 +1020,11 @@ Index: gdb-7.4.50.20120120/gdb/testsuite/lib/mi-support.exp # If allowing the inferior to have its own PTY then assign the inferior # its own terminal device here. if { $separate_inferior_pty } { -Index: gdb-7.4.50.20120120/gdb/objfiles.h +Index: gdb-7.4.50.20120602/gdb/objfiles.h =================================================================== ---- gdb-7.4.50.20120120.orig/gdb/objfiles.h 2012-01-04 09:17:09.000000000 +0100 -+++ gdb-7.4.50.20120120/gdb/objfiles.h 2012-01-21 00:02:41.623463593 +0100 -@@ -433,6 +433,10 @@ struct objfile +--- gdb-7.4.50.20120602.orig/gdb/objfiles.h 2012-06-02 21:07:03.695251272 +0200 ++++ gdb-7.4.50.20120602/gdb/objfiles.h 2012-06-02 21:07:16.539246541 +0200 +@@ -432,6 +432,10 @@ struct objfile #define OBJF_MAINLINE (1 << 5) diff --git a/gdb-6.6-scheduler_locking-step-sw-watchpoints2.patch b/gdb-6.6-scheduler_locking-step-sw-watchpoints2.patch index c7f0d33..c5318e6 100644 --- a/gdb-6.6-scheduler_locking-step-sw-watchpoints2.patch +++ b/gdb-6.6-scheduler_locking-step-sw-watchpoints2.patch @@ -21,15 +21,15 @@ Port to GDB-6.8pre. -Index: gdb-7.4.50.20111218/gdb/inferior.h +Index: gdb-7.4.50.20120602/gdb/inferior.h =================================================================== ---- gdb-7.4.50.20111218.orig/gdb/inferior.h 2011-10-07 14:06:46.000000000 +0200 -+++ gdb-7.4.50.20111218/gdb/inferior.h 2011-12-18 23:40:59.257300451 +0100 -@@ -162,7 +162,15 @@ extern void reopen_exec_file (void); +--- gdb-7.4.50.20120602.orig/gdb/inferior.h 2012-05-24 18:39:09.000000000 +0200 ++++ gdb-7.4.50.20120602/gdb/inferior.h 2012-06-02 18:24:12.875274179 +0200 +@@ -159,7 +159,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. */ --extern void resume (int, enum target_signal); +-extern void resume (int, enum gdb_signal); +enum resume_step + { + /* currently_stepping () should return non-zero for non-continue. */ @@ -38,14 +38,14 @@ Index: gdb-7.4.50.20111218/gdb/inferior.h + RESUME_STEP_NEEDED /* Stepping only for software watchpoints. */ + }; + -+extern void resume (enum resume_step, enum target_signal); ++extern void resume (enum resume_step, enum gdb_signal); extern ptid_t user_visible_resume_ptid (int step); -Index: gdb-7.4.50.20111218/gdb/infrun.c +Index: gdb-7.4.50.20120602/gdb/infrun.c =================================================================== ---- gdb-7.4.50.20111218.orig/gdb/infrun.c 2011-11-22 22:25:17.000000000 +0100 -+++ gdb-7.4.50.20111218/gdb/infrun.c 2011-12-19 00:12:34.470854218 +0100 +--- gdb-7.4.50.20120602.orig/gdb/infrun.c 2012-05-28 22:43:26.000000000 +0200 ++++ gdb-7.4.50.20120602/gdb/infrun.c 2012-06-02 18:23:59.339278268 +0200 @@ -79,7 +79,7 @@ static int follow_fork (void); static void set_schedlock_func (char *args, int from_tty, struct cmd_list_element *c); @@ -55,7 +55,7 @@ Index: gdb-7.4.50.20111218/gdb/infrun.c static int currently_stepping_or_nexting_callback (struct thread_info *tp, void *data); -@@ -1668,7 +1668,8 @@ user_visible_resume_ptid (int step) +@@ -1687,7 +1687,8 @@ user_visible_resume_ptid (int step) } else if ((scheduler_mode == schedlock_on) || (scheduler_mode == schedlock_step @@ -65,16 +65,16 @@ Index: gdb-7.4.50.20111218/gdb/infrun.c { /* User-settable 'scheduler' mode requires solo thread resume. */ resume_ptid = inferior_ptid; -@@ -1686,7 +1687,7 @@ user_visible_resume_ptid (int step) +@@ -1705,7 +1706,7 @@ user_visible_resume_ptid (int step) STEP nonzero if we should step (zero to continue instead). SIG is the signal to give the inferior (zero for none). */ void --resume (int step, enum target_signal sig) -+resume (enum resume_step step, enum target_signal sig) +-resume (int step, enum gdb_signal sig) ++resume (enum resume_step step, enum gdb_signal sig) { int should_resume = 1; struct cleanup *old_cleanups = make_cleanup (resume_cleanups, 0); -@@ -1719,9 +1720,13 @@ resume (int step, enum target_signal sig +@@ -1738,9 +1739,13 @@ resume (int step, enum gdb_signal sig) if (debug_infrun) fprintf_unfiltered (gdb_stdlog, @@ -90,7 +90,7 @@ Index: gdb-7.4.50.20111218/gdb/infrun.c target_pid_to_str (inferior_ptid), paddress (gdbarch, pc)); -@@ -2094,7 +2099,7 @@ proceed (CORE_ADDR addr, enum target_sig +@@ -2117,7 +2122,7 @@ proceed (CORE_ADDR addr, enum gdb_signal struct thread_info *tp; CORE_ADDR pc; struct address_space *aspace; @@ -99,7 +99,7 @@ Index: gdb-7.4.50.20111218/gdb/infrun.c /* If we're stopped at a fork/vfork, follow the branch set by the "set follow-fork-mode" command; otherwise, we'll just proceed -@@ -2134,13 +2139,13 @@ proceed (CORE_ADDR addr, enum target_sig +@@ -2157,13 +2162,13 @@ proceed (CORE_ADDR addr, enum gdb_signal actually be executing the breakpoint insn anyway. We'll be (un-)executing the previous instruction. */ @@ -115,7 +115,7 @@ Index: gdb-7.4.50.20111218/gdb/infrun.c } else { -@@ -2171,13 +2176,13 @@ proceed (CORE_ADDR addr, enum target_sig +@@ -2194,13 +2199,13 @@ proceed (CORE_ADDR addr, enum gdb_signal is required it returns TRUE and sets the current thread to the old thread. */ if (prepare_to_proceed (step)) @@ -131,7 +131,7 @@ Index: gdb-7.4.50.20111218/gdb/infrun.c { tp->control.trap_expected = 1; /* If displaced stepping is enabled, we can step over the -@@ -2264,8 +2269,13 @@ proceed (CORE_ADDR addr, enum target_sig +@@ -2287,8 +2292,13 @@ proceed (CORE_ADDR addr, enum gdb_signal /* Reset to normal state. */ init_infwait_state (); @@ -146,7 +146,7 @@ Index: gdb-7.4.50.20111218/gdb/infrun.c /* Wait for it to stop (if not standalone) and in any case decode why it stopped, and act accordingly. */ -@@ -5223,13 +5233,18 @@ process_event_stop_test: +@@ -5249,13 +5259,18 @@ process_event_stop_test: /* Is thread TP in the middle of single-stepping? */ @@ -170,11 +170,11 @@ Index: gdb-7.4.50.20111218/gdb/infrun.c } /* Returns true if any thread *but* the one passed in "data" is in the -Index: gdb-7.4.50.20111218/gdb/linux-nat.c +Index: gdb-7.4.50.20120602/gdb/linux-nat.c =================================================================== ---- gdb-7.4.50.20111218.orig/gdb/linux-nat.c 2011-12-18 23:35:23.000000000 +0100 -+++ gdb-7.4.50.20111218/gdb/linux-nat.c 2011-12-19 00:08:41.824855353 +0100 -@@ -3036,7 +3036,11 @@ static int +--- gdb-7.4.50.20120602.orig/gdb/linux-nat.c 2012-05-24 18:51:34.000000000 +0200 ++++ gdb-7.4.50.20120602/gdb/linux-nat.c 2012-06-02 18:23:07.409293800 +0200 +@@ -3051,7 +3051,11 @@ static int select_singlestep_lwp_callback (struct lwp_info *lp, void *data) { if (lp->last_resume_kind == resume_step @@ -187,11 +187,11 @@ Index: gdb-7.4.50.20111218/gdb/linux-nat.c return 1; else return 0; -Index: gdb-7.4.50.20111218/gdb/linux-nat.h +Index: gdb-7.4.50.20120602/gdb/linux-nat.h =================================================================== ---- gdb-7.4.50.20111218.orig/gdb/linux-nat.h 2011-12-18 23:35:23.000000000 +0100 -+++ gdb-7.4.50.20111218/gdb/linux-nat.h 2011-12-18 23:40:59.262300431 +0100 -@@ -74,8 +74,8 @@ struct lwp_info +--- gdb-7.4.50.20120602.orig/gdb/linux-nat.h 2012-03-21 14:43:54.000000000 +0100 ++++ gdb-7.4.50.20120602/gdb/linux-nat.h 2012-06-02 18:23:07.411293798 +0200 +@@ -73,8 +73,8 @@ struct lwp_info /* If non-zero, a pending wait status. */ int status; diff --git a/gdb-6.6-testsuite-timeouts.patch b/gdb-6.6-testsuite-timeouts.patch index 7e69740..00f5d85 100644 --- a/gdb-6.6-testsuite-timeouts.patch +++ b/gdb-6.6-testsuite-timeouts.patch @@ -1,26 +1,26 @@ -Index: gdb-7.4.50.20111219/gdb/testsuite/gdb.base/annota1.exp +Index: gdb-7.4.50.20120602/gdb/testsuite/gdb.base/annota1.exp =================================================================== ---- gdb-7.4.50.20111219.orig/gdb/testsuite/gdb.base/annota1.exp 2011-12-13 18:22:08.000000000 +0100 -+++ gdb-7.4.50.20111219/gdb/testsuite/gdb.base/annota1.exp 2011-12-20 00:01:36.518847033 +0100 -@@ -50,6 +50,8 @@ gdb_start +--- gdb-7.4.50.20120602.orig/gdb/testsuite/gdb.base/annota1.exp 2012-03-16 17:47:33.000000000 +0100 ++++ gdb-7.4.50.20120602/gdb/testsuite/gdb.base/annota1.exp 2012-06-02 18:27:46.623210711 +0200 +@@ -45,6 +45,8 @@ gdb_start gdb_reinitialize_dir $srcdir/$subdir gdb_load ${binfile} +gdb_test "set breakpoint pending off" "" "Avoid lockup on nonexisting functions" + - # - # the line at which break main will put the breakpoint - # -Index: gdb-7.4.50.20111219/gdb/testsuite/gdb.base/annota3.exp + # The commands we test here produce many lines of output; disable "press + # to continue" prompts. + gdb_test_no_output "set height 0" +Index: gdb-7.4.50.20120602/gdb/testsuite/gdb.base/annota3.exp =================================================================== ---- gdb-7.4.50.20111219.orig/gdb/testsuite/gdb.base/annota3.exp 2011-12-13 18:22:08.000000000 +0100 -+++ gdb-7.4.50.20111219/gdb/testsuite/gdb.base/annota3.exp 2011-12-20 00:01:36.518847033 +0100 -@@ -50,6 +50,8 @@ gdb_start +--- gdb-7.4.50.20120602.orig/gdb/testsuite/gdb.base/annota3.exp 2012-02-28 23:40:48.000000000 +0100 ++++ gdb-7.4.50.20120602/gdb/testsuite/gdb.base/annota3.exp 2012-06-02 18:28:00.375206457 +0200 +@@ -45,6 +45,8 @@ gdb_start gdb_reinitialize_dir $srcdir/$subdir gdb_load ${binfile} +gdb_test "set breakpoint pending off" "" "Avoid lockup on nonexisting functions" + - # - # the line at which break main will put the breakpoint - # + # The commands we test here produce many lines of output; disable "press + # to continue" prompts. + gdb_test_no_output "set height 0" diff --git a/gdb-6.8-attach-signalled-detach-stopped.patch b/gdb-6.8-attach-signalled-detach-stopped.patch index 175134d..44cc7ba 100644 --- a/gdb-6.8-attach-signalled-detach-stopped.patch +++ b/gdb-6.8-attach-signalled-detach-stopped.patch @@ -1,8 +1,8 @@ -Index: gdb-7.0.50.20100115/gdb/linux-nat.c +Index: gdb-7.4.50.20120602/gdb/linux-nat.c =================================================================== ---- gdb-7.0.50.20100115.orig/gdb/linux-nat.c 2010-01-15 11:53:34.000000000 +0100 -+++ gdb-7.0.50.20100115/gdb/linux-nat.c 2010-01-15 12:13:53.000000000 +0100 -@@ -175,6 +175,9 @@ blocked. */ +--- gdb-7.4.50.20120602.orig/gdb/linux-nat.c 2012-06-02 20:51:58.000000000 +0200 ++++ gdb-7.4.50.20120602/gdb/linux-nat.c 2012-06-02 20:54:30.127529159 +0200 +@@ -180,6 +180,9 @@ blocked. */ static struct target_ops *linux_ops; static struct target_ops linux_ops_saved; @@ -12,7 +12,7 @@ Index: gdb-7.0.50.20100115/gdb/linux-nat.c /* The method to call, if any, when a new thread is attached. */ static void (*linux_nat_new_thread) (struct lwp_info *); -@@ -933,7 +936,14 @@ Attaching after process %d fork to child +@@ -909,7 +912,14 @@ holding the child stopped. Try \"set de parent_inf->waiting_for_vfork_done = 0; } else if (detach_fork) @@ -28,7 +28,7 @@ Index: gdb-7.0.50.20100115/gdb/linux-nat.c /* Note that the detach above makes PARENT_INF dangling. */ -@@ -1427,6 +1437,7 @@ linux_nat_post_attach_wait (ptid_t ptid, +@@ -1377,6 +1387,7 @@ linux_nat_post_attach_wait (ptid_t ptid, if (debug_linux_nat) fprintf_unfiltered (gdb_stdlog, "LNPAW: Attaching to a stopped process\n"); @@ -36,8 +36,8 @@ Index: gdb-7.0.50.20100115/gdb/linux-nat.c /* The process is definitely stopped. It is in a job control stop, unless the kernel predates the TASK_STOPPED / -@@ -1757,6 +1768,9 @@ GPT: lwp %s had signal %s, but it is in - target_signal_to_string (signo)); +@@ -1805,6 +1816,9 @@ get_pending_status (struct lwp_info *lp, + gdb_signal_to_string (signo)); } + if (*status == 0 && GET_PID (lp->ptid) == pid_was_stopped) @@ -46,7 +46,7 @@ Index: gdb-7.0.50.20100115/gdb/linux-nat.c return 0; } -@@ -1866,6 +1880,8 @@ linux_nat_detach (struct target_ops *ops +@@ -1918,6 +1932,8 @@ linux_nat_detach (struct target_ops *ops } else linux_ops->to_detach (ops, args, from_tty); @@ -55,7 +55,7 @@ Index: gdb-7.0.50.20100115/gdb/linux-nat.c } /* Resume LP. */ -@@ -2031,6 +2047,14 @@ linux_nat_resume (struct target_ops *ops +@@ -2083,6 +2099,14 @@ linux_nat_resume (struct target_ops *ops resume_callback. */ lp->stopped = 0; @@ -70,7 +70,7 @@ Index: gdb-7.0.50.20100115/gdb/linux-nat.c if (resume_many) iterate_over_lwps (ptid, resume_callback, NULL); -@@ -3923,6 +3947,8 @@ linux_nat_mourn_inferior (struct target_ +@@ -4132,6 +4156,8 @@ linux_nat_mourn_inferior (struct target_ there are other viable forks to debug. Delete the exiting one and context-switch to the first available. */ linux_fork_mourn_inferior (); @@ -79,11 +79,11 @@ Index: gdb-7.0.50.20100115/gdb/linux-nat.c } /* Convert a native/host siginfo object, into/from the siginfo in the -Index: gdb-7.0.50.20100115/gdb/testsuite/gdb.threads/attach-stopped.exp +Index: gdb-7.4.50.20120602/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 -+++ gdb-7.0.50.20100115/gdb/testsuite/gdb.threads/attach-stopped.exp 2010-01-15 11:54:57.000000000 +0100 -@@ -62,7 +62,65 @@ proc corefunc { threadtype } { +--- gdb-7.4.50.20120602.orig/gdb/testsuite/gdb.threads/attach-stopped.exp 2012-01-04 09:27:55.000000000 +0100 ++++ gdb-7.4.50.20120602/gdb/testsuite/gdb.threads/attach-stopped.exp 2012-06-02 20:52:08.893505403 +0200 +@@ -63,7 +63,65 @@ proc corefunc { threadtype } { gdb_reinitialize_dir $srcdir/$subdir gdb_load ${binfile} diff --git a/gdb-6.8-bz254229-gcore-prpsinfo.patch b/gdb-6.8-bz254229-gcore-prpsinfo.patch index b5eb514..51071f4 100644 --- a/gdb-6.8-bz254229-gcore-prpsinfo.patch +++ b/gdb-6.8-bz254229-gcore-prpsinfo.patch @@ -1,8 +1,8 @@ -Index: gdb-7.2.50.20110320/bfd/elf-bfd.h +Index: gdb-7.4.50.20120602/bfd/elf-bfd.h =================================================================== ---- 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 +--- gdb-7.4.50.20120602.orig/bfd/elf-bfd.h 2012-06-02 21:26:09.928717069 +0200 ++++ gdb-7.4.50.20120602/bfd/elf-bfd.h 2012-06-02 21:27:21.727689625 +0200 +@@ -2221,8 +2221,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); @@ -14,17 +14,11 @@ Index: gdb-7.2.50.20110320/bfd/elf-bfd.h extern char *elfcore_write_prstatus (bfd *, char *, int *, long, int, const void *); extern char * elfcore_write_pstatus -Index: gdb-7.2.50.20110320/bfd/elf.c +Index: gdb-7.4.50.20120602/bfd/elf.c =================================================================== ---- 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; - } - --#if defined (HAVE_PRPSINFO_T) || defined (HAVE_PSINFO_T) -+#if defined (HAVE_PRPSINFO_T) - char * +--- gdb-7.4.50.20120602.orig/bfd/elf.c 2012-06-02 21:26:09.928717069 +0200 ++++ gdb-7.4.50.20120602/bfd/elf.c 2012-06-02 21:27:21.732689623 +0200 +@@ -8917,56 +8917,61 @@ char * elfcore_write_prpsinfo (bfd *abfd, char *buf, int *bufsiz, @@ -32,9 +26,8 @@ Index: gdb-7.2.50.20110320/bfd/elf.c - const char *psargs) + const prpsinfo_t *input) { - const char *note_name = "CORE"; const struct elf_backend_data *bed = get_elf_backend_data (abfd); -@@ -8828,48 +8827,55 @@ elfcore_write_prpsinfo (bfd *abfd, + if (bed->elf_backend_write_core_note != NULL) { char *ret; @@ -52,7 +45,9 @@ Index: gdb-7.2.50.20110320/bfd/elf.c return ret; } +-#if defined (HAVE_PRPSINFO_T) || defined (HAVE_PSINFO_T) -#if defined (HAVE_PRPSINFO32_T) || defined (HAVE_PSINFO32_T) ++#if defined (HAVE_PRPSINFO_T) +#if defined (HAVE_PRPSINFO32_T) if (bed->s->elfclass == ELFCLASS32) { @@ -64,7 +59,7 @@ Index: gdb-7.2.50.20110320/bfd/elf.c int note_type = NT_PRPSINFO; -#endif - memset (&data, 0, sizeof (data)); +- memset (&data, 0, sizeof (data)); - strncpy (data.pr_fname, fname, sizeof (data.pr_fname)); - strncpy (data.pr_psargs, psargs, sizeof (data.pr_psargs)); + data.pr_state = input->pr_state; @@ -83,7 +78,7 @@ Index: gdb-7.2.50.20110320/bfd/elf.c + BFD_ASSERT (sizeof (data.pr_psargs) == sizeof (input->pr_psargs)); + memcpy (data.pr_psargs, input->pr_psargs, sizeof (data.pr_psargs)); return elfcore_write_note (abfd, buf, bufsiz, - note_name, note_type, &data, sizeof (data)); + "CORE", note_type, &data, sizeof (data)); } else #endif @@ -100,21 +95,40 @@ Index: gdb-7.2.50.20110320/bfd/elf.c - strncpy (data.pr_fname, fname, sizeof (data.pr_fname)); - strncpy (data.pr_psargs, psargs, sizeof (data.pr_psargs)); return elfcore_write_note (abfd, buf, bufsiz, -- note_name, note_type, &data, sizeof (data)); -+ note_name, note_type, input, sizeof (*input)); +- "CORE", note_type, &data, sizeof (data)); ++ "CORE", note_type, input, sizeof (*input)); } - } -#endif /* PSINFO_T or PRPSINFO_T */ +#endif /* PRPSINFO_T */ - #if defined (HAVE_PRSTATUS_T) - char * -Index: gdb-7.2.50.20110320/gdb/linux-nat.c + free (buf); + return NULL; +Index: gdb-7.4.50.20120602/gdb/procfs.c +=================================================================== +--- gdb-7.4.50.20120602.orig/gdb/procfs.c 2012-06-02 21:26:09.928717069 +0200 ++++ gdb-7.4.50.20120602/gdb/procfs.c 2012-06-02 21:27:21.745689618 +0200 +@@ -5541,6 +5541,7 @@ procfs_make_note_section (bfd *obfd, int + note_data = (char *) elfcore_write_prpsinfo (obfd, + note_data, + note_size, ++ NULL, + fname, + psargs); + +Index: gdb-7.4.50.20120602/gdb/linux-tdep.c =================================================================== ---- 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; +--- gdb-7.4.50.20120602.orig/gdb/linux-tdep.c 2012-06-02 21:26:09.928717069 +0200 ++++ gdb-7.4.50.20120602/gdb/linux-tdep.c 2012-06-02 21:31:12.051601510 +0200 +@@ -30,6 +30,7 @@ + #include "elf-bfd.h" /* for elfcore_write_* */ + #include "inferior.h" + #include "cli/cli-utils.h" ++#include + + #include + +@@ -769,6 +770,131 @@ linux_corefile_thread_callback (struct t + return !args->note_data; } +/* Should be always true for Linux */ @@ -245,45 +259,22 @@ Index: gdb-7.2.50.20110320/gdb/linux-nat.c /* Fills the "to_make_corefile_note" target vector. Builds the note section for a corefile, and returns it in a malloc buffer. */ -@@ -4621,26 +4746,11 @@ linux_nat_make_corefile_notes (bfd *obfd - +@@ -784,16 +910,9 @@ linux_make_corefile_notes (struct gdbarc + /* Process information. */ if (get_exec_file (0)) { -- strncpy (fname, lbasename (get_exec_file (0)), sizeof (fname)); -- strncpy (psargs, get_exec_file (0), sizeof (psargs)); -- if (get_inferior_args ()) -- { -- char *string_end; -- char *psargs_end = psargs + sizeof (psargs); -- -- /* linux_elfcore_write_prpsinfo () handles zero unterminated -- strings fine. */ -- string_end = memchr (psargs, 0, sizeof (psargs)); -- if (string_end != NULL) -- { -- *string_end++ = ' '; -- strncpy (string_end, get_inferior_args (), -- psargs_end - string_end); -- } -- } +- const char *fname = lbasename (get_exec_file (0)); +- char *psargs = xstrdup (fname); + const prpsinfo_t *data = fill_prpsinfo (); -+ - note_data = (char *) elfcore_write_prpsinfo (obfd, - note_data, -- note_size, fname, psargs); -+ note_size, data); - } - /* Dump information for threads. */ -Index: gdb-7.2.50.20110320/gdb/procfs.c -=================================================================== ---- 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, -+ NULL, - fname, - psargs); +- if (get_inferior_args ()) +- psargs = reconcat (psargs, psargs, " ", get_inferior_args (), +- (char *) NULL); +- +- note_data = elfcore_write_prpsinfo (obfd, note_data, note_size, +- fname, psargs); +- xfree (psargs); ++ note_data = elfcore_write_prpsinfo (obfd, note_data, note_size, data); + if (!note_data) + return NULL; diff --git a/gdb-archer-pie-addons-keep-disabled.patch b/gdb-archer-pie-addons-keep-disabled.patch index 83aa8da..41b9b46 100644 --- a/gdb-archer-pie-addons-keep-disabled.patch +++ b/gdb-archer-pie-addons-keep-disabled.patch @@ -1,8 +1,8 @@ -Index: gdb-7.4.50.20120103/gdb/breakpoint.c +Index: gdb-7.4.50.20120602/gdb/breakpoint.c =================================================================== ---- gdb-7.4.50.20120103.orig/gdb/breakpoint.c 2012-01-03 05:52:15.000000000 +0100 -+++ gdb-7.4.50.20120103/gdb/breakpoint.c 2012-01-03 15:22:56.105405559 +0100 -@@ -13724,6 +13724,50 @@ initialize_breakpoint_ops (void) +--- gdb-7.4.50.20120602.orig/gdb/breakpoint.c 2012-06-02 19:11:54.000000000 +0200 ++++ gdb-7.4.50.20120602/gdb/breakpoint.c 2012-06-02 19:52:58.161226506 +0200 +@@ -15495,6 +15495,50 @@ initialize_breakpoint_ops (void) } void @@ -53,23 +53,23 @@ Index: gdb-7.4.50.20120103/gdb/breakpoint.c _initialize_breakpoint (void) { struct cmd_list_element *c; -Index: gdb-7.4.50.20120103/gdb/breakpoint.h +Index: gdb-7.4.50.20120602/gdb/breakpoint.h =================================================================== ---- gdb-7.4.50.20120103.orig/gdb/breakpoint.h 2012-01-03 05:52:15.000000000 +0100 -+++ gdb-7.4.50.20120103/gdb/breakpoint.h 2012-01-03 15:23:09.444356484 +0100 -@@ -1393,4 +1393,7 @@ extern struct gdbarch *get_sal_arch (str +--- gdb-7.4.50.20120602.orig/gdb/breakpoint.h 2012-05-16 16:35:03.000000000 +0200 ++++ gdb-7.4.50.20120602/gdb/breakpoint.h 2012-06-02 19:53:09.268223263 +0200 +@@ -1503,4 +1503,7 @@ extern struct gdbarch *get_sal_arch (str - extern void modify_semaphore (struct bp_location *location, int set); + extern void handle_solib_event (void); +extern void breakpoints_relocate (struct objfile *objfile, + struct section_offsets *delta); + #endif /* !defined (BREAKPOINT_H) */ -Index: gdb-7.4.50.20120103/gdb/objfiles.c +Index: gdb-7.4.50.20120602/gdb/objfiles.c =================================================================== ---- gdb-7.4.50.20120103.orig/gdb/objfiles.c 2012-01-03 05:52:15.000000000 +0100 -+++ gdb-7.4.50.20120103/gdb/objfiles.c 2012-01-03 15:23:28.141287697 +0100 -@@ -818,6 +818,11 @@ objfile_relocate1 (struct objfile *objfi +--- gdb-7.4.50.20120602.orig/gdb/objfiles.c 2012-05-10 21:50:08.000000000 +0200 ++++ gdb-7.4.50.20120602/gdb/objfiles.c 2012-06-02 19:52:58.202226502 +0200 +@@ -802,6 +802,11 @@ objfile_relocate1 (struct objfile *objfi objfile->sf->sym_probe_fns->sym_relocate_probe (objfile, new_offsets, delta); diff --git a/gdb-archer-pie-addons.patch b/gdb-archer-pie-addons.patch index b18a060..f811964 100644 --- a/gdb-archer-pie-addons.patch +++ b/gdb-archer-pie-addons.patch @@ -1,8 +1,8 @@ -Index: gdb-7.4.50.20111218/gdb/dwarf2read.c +Index: gdb-7.4.50.20120602/gdb/dwarf2read.c =================================================================== ---- gdb-7.4.50.20111218.orig/gdb/dwarf2read.c 2011-12-19 01:31:24.000000000 +0100 -+++ gdb-7.4.50.20111218/gdb/dwarf2read.c 2011-12-19 01:33:25.263238972 +0100 -@@ -8347,7 +8347,12 @@ read_common_block (struct die_info *die, +--- gdb-7.4.50.20120602.orig/gdb/dwarf2read.c 2012-06-02 19:14:38.000000000 +0200 ++++ gdb-7.4.50.20120602/gdb/dwarf2read.c 2012-06-02 19:51:29.977252338 +0200 +@@ -9746,7 +9746,12 @@ read_common_block (struct die_info *die, { struct attribute *attr; struct symbol *sym; @@ -16,7 +16,7 @@ Index: gdb-7.4.50.20111218/gdb/dwarf2read.c attr = dwarf2_attr (die, DW_AT_location, cu); if (attr) -@@ -8356,6 +8361,7 @@ read_common_block (struct die_info *die, +@@ -9755,6 +9760,7 @@ read_common_block (struct die_info *die, if (attr_form_is_block (attr)) { base = decode_locdesc (DW_BLOCK (attr), cu); @@ -24,7 +24,7 @@ Index: gdb-7.4.50.20111218/gdb/dwarf2read.c } else if (attr_form_is_section_offset (attr)) { -@@ -8408,12 +8414,15 @@ read_common_block (struct die_info *die, +@@ -9807,12 +9813,15 @@ read_common_block (struct die_info *die, if (sym != NULL && handle_data_member_location (child_die, cu, &offset)) { @@ -42,7 +42,7 @@ Index: gdb-7.4.50.20111218/gdb/dwarf2read.c else SET_FIELD_PHYSNAME (*field, SYMBOL_LINKAGE_NAME (sym)); FIELD_TYPE (*field) = SYMBOL_TYPE (sym); -@@ -8427,7 +8436,7 @@ read_common_block (struct die_info *die, +@@ -9826,7 +9835,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. */ @@ -51,19 +51,19 @@ Index: gdb-7.4.50.20111218/gdb/dwarf2read.c set_die_type (die, type, cu); } -Index: gdb-7.4.50.20111218/gdb/gdbtypes.h +Index: gdb-7.4.50.20120602/gdb/gdbtypes.h =================================================================== ---- gdb-7.4.50.20111218.orig/gdb/gdbtypes.h 2011-12-18 23:35:23.000000000 +0100 -+++ gdb-7.4.50.20111218/gdb/gdbtypes.h 2011-12-19 01:34:21.448025620 +0100 -@@ -396,6 +396,7 @@ enum type_instance_flag_value - enum field_loc_kind +--- gdb-7.4.50.20120602.orig/gdb/gdbtypes.h 2012-06-02 19:11:54.000000000 +0200 ++++ gdb-7.4.50.20120602/gdb/gdbtypes.h 2012-06-02 19:52:44.990230200 +0200 +@@ -401,6 +401,7 @@ enum field_loc_kind { FIELD_LOC_KIND_BITPOS, /* bitpos */ + FIELD_LOC_KIND_ENUMVAL, /* enumval */ + /* This address is unrelocated by the objfile's ANOFFSET. */ FIELD_LOC_KIND_PHYSADDR, /* physaddr */ FIELD_LOC_KIND_PHYSNAME, /* physname */ FIELD_LOC_KIND_DWARF_BLOCK /* dwarf_block */ -@@ -581,6 +582,7 @@ struct main_type +@@ -595,6 +596,7 @@ struct main_type is the location (in the target) of the static field. Otherwise, physname is the mangled label of the static field. */ @@ -71,15 +71,15 @@ Index: gdb-7.4.50.20111218/gdb/gdbtypes.h CORE_ADDR physaddr; const char *physname; -@@ -1194,6 +1196,7 @@ extern void allocate_gnat_aux_type (stru - #define FIELD_LOC_KIND(thisfld) ((thisfld).loc_kind) - #define FIELD_BITPOS(thisfld) ((thisfld).loc.bitpos) +@@ -1200,6 +1202,7 @@ extern void allocate_gnat_aux_type (stru + #define FIELD_ENUMVAL_LVAL(thisfld) ((thisfld).loc.enumval) + #define FIELD_ENUMVAL(thisfld) (FIELD_ENUMVAL_LVAL (thisfld) + 0) #define FIELD_STATIC_PHYSNAME(thisfld) ((thisfld).loc.physname) +/* This address is unrelocated by the objfile's ANOFFSET. */ #define FIELD_STATIC_PHYSADDR(thisfld) ((thisfld).loc.physaddr) #define FIELD_DWARF_BLOCK(thisfld) ((thisfld).loc.dwarf_block) #define SET_FIELD_BITPOS(thisfld, bitpos) \ -@@ -1202,6 +1205,7 @@ extern void allocate_gnat_aux_type (stru +@@ -1211,6 +1214,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)) @@ -87,19 +87,19 @@ Index: gdb-7.4.50.20111218/gdb/gdbtypes.h #define SET_FIELD_PHYSADDR(thisfld, addr) \ (FIELD_LOC_KIND (thisfld) = FIELD_LOC_KIND_PHYSADDR, \ FIELD_STATIC_PHYSADDR (thisfld) = (addr)) -@@ -1217,6 +1221,7 @@ extern void allocate_gnat_aux_type (stru - #define TYPE_FIELD_LOC_KIND(thistype, n) FIELD_LOC_KIND (TYPE_FIELD (thistype, n)) +@@ -1227,6 +1231,7 @@ extern void allocate_gnat_aux_type (stru #define TYPE_FIELD_BITPOS(thistype, n) FIELD_BITPOS (TYPE_FIELD (thistype, n)) + #define TYPE_FIELD_ENUMVAL(thistype, n) FIELD_ENUMVAL (TYPE_FIELD (thistype, n)) #define TYPE_FIELD_STATIC_PHYSNAME(thistype, n) FIELD_STATIC_PHYSNAME (TYPE_FIELD (thistype, n)) +/* This address is unrelocated by the objfile's ANOFFSET. */ #define TYPE_FIELD_STATIC_PHYSADDR(thistype, n) FIELD_STATIC_PHYSADDR (TYPE_FIELD (thistype, n)) #define TYPE_FIELD_DWARF_BLOCK(thistype, n) FIELD_DWARF_BLOCK (TYPE_FIELD (thistype, n)) #define TYPE_FIELD_ARTIFICIAL(thistype, n) FIELD_ARTIFICIAL(TYPE_FIELD(thistype,n)) -Index: gdb-7.4.50.20111218/gdb/jv-lang.c +Index: gdb-7.4.50.20120602/gdb/jv-lang.c =================================================================== ---- gdb-7.4.50.20111218.orig/gdb/jv-lang.c 2011-12-06 19:54:39.000000000 +0100 -+++ gdb-7.4.50.20111218/gdb/jv-lang.c 2011-12-19 01:33:25.280238908 +0100 -@@ -430,7 +430,8 @@ java_link_class_type (struct gdbarch *gd +--- gdb-7.4.50.20120602.orig/gdb/jv-lang.c 2012-05-10 21:59:12.000000000 +0200 ++++ gdb-7.4.50.20120602/gdb/jv-lang.c 2012-06-02 19:51:53.286245280 +0200 +@@ -431,7 +431,8 @@ java_link_class_type (struct gdbarch *gd fields = NULL; nfields--; /* First set up dummy "class" field. */ @@ -109,7 +109,7 @@ Index: gdb-7.4.50.20111218/gdb/jv-lang.c TYPE_FIELD_NAME (type, nfields) = "class"; TYPE_FIELD_TYPE (type, nfields) = value_type (clas); SET_TYPE_FIELD_PRIVATE (type, nfields); -@@ -478,7 +479,8 @@ java_link_class_type (struct gdbarch *gd +@@ -479,7 +480,8 @@ java_link_class_type (struct gdbarch *gd SET_TYPE_FIELD_PROTECTED (type, i); } if (accflags & 0x0008) /* ACC_STATIC */ @@ -117,13 +117,13 @@ Index: gdb-7.4.50.20111218/gdb/jv-lang.c + SET_FIELD_PHYSADDR (TYPE_FIELD (type, i), boffset + - (TYPE_OBJFILE (type) == NULL ? 0 : ANOFFSET (TYPE_OBJFILE (type)->section_offsets, SECT_OFF_TEXT (TYPE_OBJFILE (type))))); else - TYPE_FIELD_BITPOS (type, i) = 8 * boffset; + SET_FIELD_BITPOS (TYPE_FIELD (type, i), 8 * boffset); if (accflags & 0x8000) /* FIELD_UNRESOLVED_FLAG */ -Index: gdb-7.4.50.20111218/gdb/value.c +Index: gdb-7.4.50.20120602/gdb/value.c =================================================================== ---- gdb-7.4.50.20111218.orig/gdb/value.c 2011-12-18 23:35:23.000000000 +0100 -+++ gdb-7.4.50.20111218/gdb/value.c 2011-12-19 01:33:25.283238896 +0100 -@@ -2481,7 +2481,8 @@ value_static_field (struct type *type, i +--- gdb-7.4.50.20120602.orig/gdb/value.c 2012-06-02 19:11:55.000000000 +0200 ++++ gdb-7.4.50.20120602/gdb/value.c 2012-06-02 19:51:30.031252317 +0200 +@@ -2592,7 +2592,8 @@ value_static_field (struct type *type, i { case FIELD_LOC_KIND_PHYSADDR: retval = value_at_lazy (TYPE_FIELD_TYPE (type, fieldno), diff --git a/gdb-archer-vla-rhel5gcc.patch b/gdb-archer-vla-rhel5gcc.patch deleted file mode 100644 index f64957b..0000000 --- a/gdb-archer-vla-rhel5gcc.patch +++ /dev/null @@ -1,34 +0,0 @@ -commit a999ae2c722b366b94987941f0ce899f95e8d679 -Author: Jan Kratochvil -Date: Fri Mar 2 22:08:49 2012 +0100 - - Fix crash for gdb.fortran/dynamic.exp with gcc-gfortran-4.1.2-51.el5.x86_64. - ---- a/gdb/valops.c -+++ b/gdb/valops.c -@@ -1037,7 +1037,8 @@ int - value_fetch_lazy (struct value *val) - { - gdb_assert (value_lazy (val)); -- allocate_value_contents (val); -+ if (VALUE_LVAL (val) != lval_memory) -+ allocate_value_contents (val); - if (value_bitsize (val)) - { - /* To read a lazy bitfield, read the entire enclosing value. This -@@ -1080,11 +1081,15 @@ value_fetch_lazy (struct value *val) - - if (length) - { -+ /* Delay it after object_address_get_data above. */ -+ allocate_value_contents (val); - addr += value_offset (val); - read_value_memory (val, 0, value_stack (val), - addr, value_contents_all_raw (val), length); - } - } -+ /* Just to be sure it has been called. */ -+ allocate_value_contents (val); - } - else if (VALUE_LVAL (val) == lval_register) - { diff --git a/gdb-archer.patch b/gdb-archer.patch index 5e9b168..6b4e799 100644 --- a/gdb-archer.patch +++ b/gdb-archer.patch @@ -2,49 +2,18 @@ http://sourceware.org/gdb/wiki/ProjectArcher http://sourceware.org/gdb/wiki/ArcherBranchManagement GIT snapshot: -commit 9f8d47f059091333d178bd249507fd25676860e7 +commit d10213220191589814714d71ef0f5ba64fbc3b75 branch `archer' - the merge of branches: archer-jankratochvil-vla -archer-jankratochvil-watchpoint3 archer-tromey-python -archer-sergiodj-stap diff --git a/gdb/Makefile.in b/gdb/Makefile.in -index 38c93c9..3acacdb 100644 +index bf6b0da..f0d46dd 100644 --- a/gdb/Makefile.in +++ b/gdb/Makefile.in -@@ -720,8 +720,8 @@ SFILES = ada-exp.y ada-lang.c ada-typeprint.c ada-valprint.c ada-tasks.c \ - sentinel-frame.c \ - serial.c ser-base.c ser-unix.c skip.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 \ -@@ -817,7 +817,7 @@ osdata.h procfs.h python/py-event.h python/py-events.h python/py-stopevent.h \ - 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 skip.h \ -+gnulib/stddef.in.h inline-frame.h skip.h stap-probe.h \ - common/common-utils.h common/xml-utils.h common/buffer.h common/ptid.h \ - common/linux-osdata.h gdb-dlfcn.h - -@@ -905,7 +905,7 @@ COMMON_OBS = $(DEPFILES) $(CONFIG_OBS) $(YYOBJ) \ - xml-support.o xml-syscall.o xml-utils.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 skip.o \ -+ jit.o progspace.o skip.o stap-probe.o \ - common-utils.o buffer.o ptid.o gdb-dlfcn.o - - TSOBS = inflow.o -@@ -1293,6 +1293,12 @@ stamp-h: $(srcdir)/config.in config.status +@@ -1304,6 +1304,12 @@ stamp-h: $(srcdir)/config.in config.status CONFIG_LINKS= \ $(SHELL) config.status @@ -57,26 +26,11 @@ index 38c93c9..3acacdb 100644 config.status: $(srcdir)/configure configure.tgt configure.host $(SHELL) config.status --recheck -diff --git a/gdb/NEWS b/gdb/NEWS -index 128825e..13dd88c 100644 ---- a/gdb/NEWS -+++ b/gdb/NEWS -@@ -328,6 +328,10 @@ Renesas RL78 rl78-*-elf - Initial support for the OpenCL C language (http://www.khronos.org/opencl) - has been integrated into GDB. - -+* GDB now has support for SystemTap 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'. diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c -index 29956d7..dc1fadd 100644 +index af0fdb5..02c6e6f 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c -@@ -11896,6 +11896,7 @@ ada_operator_length (const struct expression *exp, int pc, int *oplenp, +@@ -12055,6 +12055,7 @@ ada_operator_length (const struct expression *exp, int pc, int *oplenp, static int ada_operator_check (struct expression *exp, int pos, @@ -84,7 +38,7 @@ index 29956d7..dc1fadd 100644 int (*objfile_func) (struct objfile *objfile, void *data), void *data) { -@@ -11910,12 +11911,15 @@ ada_operator_check (struct expression *exp, int pos, +@@ -12069,12 +12070,15 @@ ada_operator_check (struct expression *exp, int pos, break; default: @@ -102,313 +56,13 @@ index 29956d7..dc1fadd 100644 && (*objfile_func) (TYPE_OBJFILE (type), data)) return 1; -diff --git a/gdb/amd64-linux-nat.c b/gdb/amd64-linux-nat.c -index a0bdbd7..98760bf 100644 ---- a/gdb/amd64-linux-nat.c -+++ b/gdb/amd64-linux-nat.c -@@ -336,8 +336,8 @@ amd64_linux_dr_get_status (void) - return amd64_linux_dr_get (inferior_ptid, DR_STATUS); - } - --/* Callback for iterate_over_lwps. Update the debug registers of -- LWP. */ -+/* Callback for linux_nat_iterate_watchpoint_lwps. Update the debug registers -+ of LWP. */ - - static int - update_debug_registers_callback (struct lwp_info *lwp, void *arg) -@@ -363,9 +363,7 @@ update_debug_registers_callback (struct lwp_info *lwp, void *arg) - static void - amd64_linux_dr_set_control (unsigned long control) - { -- ptid_t pid_ptid = pid_to_ptid (ptid_get_pid (inferior_ptid)); -- -- iterate_over_lwps (pid_ptid, update_debug_registers_callback, NULL); -+ linux_nat_iterate_watchpoint_lwps (update_debug_registers_callback, NULL); - } - - /* Set address REGNUM (zero based) to ADDR in all LWPs of the current -@@ -378,7 +376,7 @@ amd64_linux_dr_set_addr (int regnum, CORE_ADDR addr) - - gdb_assert (regnum >= 0 && regnum <= DR_LASTADDR - DR_FIRSTADDR); - -- iterate_over_lwps (pid_ptid, update_debug_registers_callback, NULL); -+ linux_nat_iterate_watchpoint_lwps (update_debug_registers_callback, NULL); - } - - /* Called when resuming a thread. -@@ -400,6 +398,13 @@ amd64_linux_prepare_to_resume (struct lwp_info *lwp) - struct i386_debug_reg_state *state = i386_debug_reg_state (); - int i; - -+ /* On Linux kernel before 2.6.33 commit -+ 72f674d203cd230426437cdcf7dd6f681dad8b0d -+ if you enable a breakpoint by the DR_CONTROL bits you need to have -+ already written the corresponding DR_FIRSTADDR...DR_LASTADDR registers. -+ -+ Ensure DR_CONTROL gets written as the very last register here. */ -+ - for (i = DR_FIRSTADDR; i <= DR_LASTADDR; i++) - if (state->dr_ref_count[i] > 0) - { -diff --git a/gdb/amd64-linux-tdep.c b/gdb/amd64-linux-tdep.c -index ca9ade6..c30185d 100644 ---- a/gdb/amd64-linux-tdep.c -+++ b/gdb/amd64-linux-tdep.c -@@ -1362,6 +1362,15 @@ amd64_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) - set_gdbarch_process_record (gdbarch, i386_process_record); - set_gdbarch_process_record_signal (gdbarch, amd64_linux_record_signal); - -+ /* SystemTap variables and functions. */ -+ set_gdbarch_stap_integer_prefix (gdbarch, "$"); -+ set_gdbarch_stap_register_prefix (gdbarch, "%"); -+ set_gdbarch_stap_register_indirection_prefix (gdbarch, "("); -+ set_gdbarch_stap_register_indirection_sufix (gdbarch, ")"); -+ set_gdbarch_stap_is_single_operand (gdbarch, i386_stap_is_single_operand); -+ set_gdbarch_stap_parse_special_token (gdbarch, -+ i386_stap_parse_special_token); -+ - /* Initialize the amd64_linux_record_tdep. */ - /* These values are the size of the type that will be used in a system - call. They are obtained from Linux Kernel source. */ -diff --git a/gdb/arm-linux-tdep.c b/gdb/arm-linux-tdep.c -index ac4860c..d710682 100644 ---- a/gdb/arm-linux-tdep.c -+++ b/gdb/arm-linux-tdep.c -@@ -43,6 +43,12 @@ - #include "gdbthread.h" - #include "symfile.h" - -+#include "cli/cli-utils.h" -+#include "stap-probe.h" -+#include "parser-defs.h" -+#include "user-regs.h" -+#include -+ - #include "gdb_string.h" - - /* This is defined in on ARM GNU/Linux systems. */ -@@ -1053,6 +1059,122 @@ arm_linux_displaced_step_copy_insn (struct gdbarch *gdbarch, - return dsc; - } - -+static int -+arm_stap_is_single_operand (struct gdbarch *gdbarch, const char *s) -+{ -+ return (*s == '#' /* Literal number. */ -+ || *s == '[' /* Register indirection or -+ displacement. */ -+ || isalpha (*s)); /* Register value. */ -+} -+ -+/* This routine is used to parse a special token in ARM's assembly. -+ -+ The special tokens parsed by it are: -+ -+ - Register displacement (e.g, [fp, #-8]) -+ -+ It returns one if the special token has been parsed successfully, -+ or zero if the current token is not considered special. */ -+ -+static int -+arm_stap_parse_special_token (struct gdbarch *gdbarch, -+ struct stap_parse_info *p) -+{ -+ if (*p->arg == '[') -+ { -+ /* Temporary holder for lookahead. */ -+ const char *tmp = p->arg; -+ /* Used to save the register name. */ -+ const char *start; -+ char *regname; -+ int len, offset; -+ int got_minus = 0; -+ long displacement; -+ struct stoken str; -+ -+ ++tmp; -+ start = tmp; -+ -+ /* Register name. */ -+ while (isalnum (*tmp)) -+ ++tmp; -+ -+ if (*tmp != ',') -+ return 0; -+ -+ len = tmp - start; -+ regname = alloca (len + 2); -+ -+ offset = 0; -+ if (isdigit (*start)) -+ { -+ /* If we are dealing with a register whose name begins with a -+ digit, it means we should prefix the name with the letter -+ `r', because GDB expects this name pattern. Otherwise (e.g., -+ we are dealing with the register `fp'), we don't need to -+ add such a prefix. */ -+ regname[0] = 'r'; -+ offset = 1; -+ } -+ -+ strncpy (regname + offset, start, len); -+ len += offset; -+ regname[len] = '\0'; -+ -+ if (user_reg_map_name_to_regnum (gdbarch, regname, len) == -1) -+ error (_("Invalid register name `%s' on expression `%s'."), -+ regname, p->saved_arg); -+ -+ ++tmp; -+ tmp = skip_spaces_const (tmp); -+ if (*tmp++ != '#') -+ return 0; -+ -+ if (*tmp == '-') -+ { -+ ++tmp; -+ got_minus = 1; -+ } -+ -+ displacement = strtol (tmp, (char **) &tmp, 10); -+ -+ /* Skipping last `]'. */ -+ if (*tmp++ != ']') -+ return 0; -+ -+ /* The displacement. */ -+ write_exp_elt_opcode (OP_LONG); -+ write_exp_elt_type (builtin_type (gdbarch)->builtin_long); -+ write_exp_elt_longcst (displacement); -+ write_exp_elt_opcode (OP_LONG); -+ if (got_minus) -+ write_exp_elt_opcode (UNOP_NEG); -+ -+ /* The register name. */ -+ write_exp_elt_opcode (OP_REGISTER); -+ str.ptr = regname; -+ str.length = len; -+ write_exp_string (str); -+ write_exp_elt_opcode (OP_REGISTER); -+ -+ write_exp_elt_opcode (BINOP_ADD); -+ -+ /* Casting to the expected type. */ -+ write_exp_elt_opcode (UNOP_CAST); -+ write_exp_elt_type (lookup_pointer_type (p->arg_type)); -+ write_exp_elt_opcode (UNOP_CAST); -+ -+ write_exp_elt_opcode (UNOP_IND); -+ -+ p->arg = tmp; -+ } -+ else -+ return 0; -+ -+ return 1; -+} -+ - static void - arm_linux_init_abi (struct gdbarch_info info, - struct gdbarch *gdbarch) -@@ -1152,6 +1274,15 @@ arm_linux_init_abi (struct gdbarch_info info, - simple_displaced_step_free_closure); - set_gdbarch_displaced_step_location (gdbarch, displaced_step_at_entry_point); - -+ /* SystemTap functions. */ -+ set_gdbarch_stap_integer_prefix (gdbarch, "#"); -+ set_gdbarch_stap_register_prefix (gdbarch, "r"); -+ set_gdbarch_stap_register_indirection_prefix (gdbarch, "["); -+ set_gdbarch_stap_register_indirection_sufix (gdbarch, "]"); -+ set_gdbarch_stap_gdb_register_prefix (gdbarch, "r"); -+ set_gdbarch_stap_is_single_operand (gdbarch, arm_stap_is_single_operand); -+ set_gdbarch_stap_parse_special_token (gdbarch, -+ arm_stap_parse_special_token); - - tdep->syscall_next_pc = arm_linux_syscall_next_pc; - } -diff --git a/gdb/ax-gdb.c b/gdb/ax-gdb.c -index 31e91b9..4518f6b 100644 ---- a/gdb/ax-gdb.c -+++ b/gdb/ax-gdb.c -@@ -95,8 +95,6 @@ static void gen_int_literal (struct agent_expr *ax, - struct axs_value *value, - LONGEST k, struct type *type); - -- --static void require_rvalue (struct agent_expr *ax, struct axs_value *value); - static void gen_usual_unary (struct expression *exp, struct agent_expr *ax, - struct axs_value *value); - static int type_wider_than (struct type *type1, struct type *type2); -@@ -157,8 +155,6 @@ static void gen_repeat (struct expression *exp, union exp_element **pc, - static void gen_sizeof (struct expression *exp, union exp_element **pc, - struct agent_expr *ax, struct axs_value *value, - struct type *size_type); --static void gen_expr (struct expression *exp, union exp_element **pc, -- struct agent_expr *ax, struct axs_value *value); - static void gen_expr_binop_rest (struct expression *exp, - enum exp_opcode op, union exp_element **pc, - struct agent_expr *ax, -@@ -789,7 +785,7 @@ gen_int_literal (struct agent_expr *ax, struct axs_value *value, LONGEST k, - /* Take what's on the top of the stack (as described by VALUE), and - try to make an rvalue out of it. Signal an error if we can't do - that. */ --static void -+void - require_rvalue (struct agent_expr *ax, struct axs_value *value) - { - /* Only deal with scalars, structs and such may be too large -@@ -1807,7 +1803,7 @@ gen_sizeof (struct expression *exp, union exp_element **pc, - /* XXX: i18n */ - /* A gen_expr function written by a Gen-X'er guy. - Append code for the subexpression of EXPR starting at *POS_P to AX. */ --static void -+void - gen_expr (struct expression *exp, union exp_element **pc, - struct agent_expr *ax, struct axs_value *value) - { -@@ -2042,7 +2038,8 @@ gen_expr (struct expression *exp, union exp_element **pc, - - 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; -@@ -2056,7 +2053,7 @@ gen_expr (struct expression *exp, union exp_element **pc, - 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); - } -diff --git a/gdb/ax-gdb.h b/gdb/ax-gdb.h -index 48c35a4..09f6889 100644 ---- a/gdb/ax-gdb.h -+++ b/gdb/ax-gdb.h -@@ -110,6 +110,11 @@ extern struct agent_expr *gen_trace_for_return_address (CORE_ADDR, - - extern struct agent_expr *gen_eval_for_expr (CORE_ADDR, struct expression *); - -+extern void gen_expr (struct expression *exp, union exp_element **pc, -+ struct agent_expr *ax, struct axs_value *value); -+ -+extern void require_rvalue (struct agent_expr *ax, struct axs_value *value); -+ - extern int trace_kludge; - extern int trace_string_kludge; - diff --git a/gdb/block.c b/gdb/block.c -index 57ab4c2..573630e 100644 +index 1503730..a522bca 100644 --- a/gdb/block.c +++ b/gdb/block.c -@@ -369,3 +369,21 @@ allocate_block (struct obstack *obstack) +@@ -687,3 +687,21 @@ block_iter_match_next (const char *name, - return bl; + return block_iter_match_step (iterator, name, compare, 0); } + +/* Return OBJFILE in which BLOCK is located or NULL if we cannot find it for @@ -429,238 +83,21 @@ index 57ab4c2..573630e 100644 + return SYMBOL_SYMTAB (func)->objfile; +} diff --git a/gdb/block.h b/gdb/block.h -index 2cbcc1b..104c146 100644 +index 99c4788..6ceb704 100644 --- a/gdb/block.h +++ b/gdb/block.h -@@ -167,4 +167,6 @@ extern const struct block *block_global_block (const struct block *block); - - extern struct block *allocate_block (struct obstack *obstack); +@@ -279,4 +279,6 @@ extern struct symbol *block_iter_match_next (const char *name, + (sym); \ + (sym) = block_iterator_next (&(iter))) +extern struct objfile *block_objfile (const struct block *block); + #endif /* BLOCK_H */ diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c -index f6a0276..e406156 100644 +index a867b10..e41c692 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c -@@ -60,6 +60,8 @@ - #include "jit.h" - #include "xml-syscall.h" - #include "parser-defs.h" -+#include "gdb_regex.h" -+#include "stap-probe.h" - #include "cli/cli-utils.h" - #include "continuations.h" - #include "stack.h" -@@ -1239,9 +1241,10 @@ is_watchpoint (const struct breakpoint *bpt) - static int - watchpoint_in_thread_scope (struct watchpoint *b) - { -- return (ptid_equal (b->watchpoint_thread, null_ptid) -- || (ptid_equal (inferior_ptid, b->watchpoint_thread) -- && !is_executing (inferior_ptid))); -+ return (b->base.pspace == current_program_space -+ && (ptid_equal (b->watchpoint_thread, null_ptid) -+ || (ptid_equal (inferior_ptid, b->watchpoint_thread) -+ && !is_executing (inferior_ptid)))); - } - - /* Set watchpoint B to disp_del_at_next_stop, even including its possible -@@ -1648,6 +1651,40 @@ unduplicated_should_be_inserted (struct bp_location *bl) - return result; - } - -+/* See the comment in breakpoint.h. */ -+ -+void -+modify_semaphore (struct bp_location *loc, int set) -+{ -+ 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; -+ -+ if (address == 0) -+ return; -+ -+ /* Swallow errors. */ -+ if (target_read_memory (address, bytes, TYPE_LENGTH (type)) != 0) -+ return; -+ -+ 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; -+ -+ store_unsigned_integer (bytes, TYPE_LENGTH (type), -+ gdbarch_byte_order (arch), value); -+ -+ target_write_memory (address, bytes, TYPE_LENGTH (type)); -+} -+ - /* 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. -@@ -1741,6 +1778,8 @@ insert_bp_location (struct bp_location *bl, - /* No overlay handling: just set the breakpoint. */ - - val = bl->owner->ops->insert_location (bl); -+ -+ modify_semaphore (bl, 1); - } - else - { -@@ -2224,11 +2263,23 @@ struct breakpoint_objfile_data - /* Minimal symbol(s) for "longjmp", "siglongjmp", etc. (if any). */ - struct minimal_symbol *longjmp_msym[NUM_LONGJMP_NAMES]; - -+ /* True if we have looked for longjmp probes. */ -+ int longjmp_searched; -+ -+ /* SystemTap probe points for longjmp (if any). */ -+ VEC (stap_probe_p) *longjmp_probes; -+ - /* Minimal symbol for "std::terminate()" (if any). */ - struct minimal_symbol *terminate_msym; - - /* Minimal symbol for "_Unwind_DebugHook" (if any). */ - struct minimal_symbol *exception_msym; -+ -+ /* True if we have looked for exception probes. */ -+ int exception_searched; -+ -+ /* SystemTap probe points for unwinding (if any). */ -+ VEC (stap_probe_p) *exception_probes; - }; - - static const struct objfile_data *breakpoint_objfile_key; -@@ -2265,6 +2316,15 @@ get_breakpoint_objfile_data (struct objfile *objfile) - } - - static void -+free_breakpoint_probes (struct objfile *obj, void *data) -+{ -+ struct breakpoint_objfile_data *bp_objfile_data = data; -+ -+ VEC_free (stap_probe_p, bp_objfile_data->longjmp_probes); -+ VEC_free (stap_probe_p, bp_objfile_data->exception_probes); -+} -+ -+static void - create_overlay_event_breakpoint (void) - { - struct objfile *objfile; -@@ -2341,6 +2401,37 @@ create_longjmp_master_breakpoint (void) - - bp_objfile_data = get_breakpoint_objfile_data (objfile); - -+ if (!bp_objfile_data->longjmp_searched) -+ { -+ bp_objfile_data->longjmp_probes -+ = find_probes_in_objfile (objfile, "libc", "longjmp"); -+ bp_objfile_data->longjmp_searched = 1; -+ } -+ -+ if (bp_objfile_data->longjmp_probes != NULL) -+ { -+ int i; -+ struct stap_probe *probe; -+ struct gdbarch *gdbarch = get_objfile_arch (objfile); -+ -+ for (i = 0; -+ VEC_iterate (stap_probe_p, -+ bp_objfile_data->longjmp_probes, -+ i, probe); -+ ++i) -+ { -+ struct breakpoint *b; -+ -+ b = create_internal_breakpoint (gdbarch, probe->address, -+ bp_longjmp_master, -+ &internal_breakpoint_ops); -+ b->addr_string = xstrdup ("-p libc:longjmp"); -+ b->enable_state = bp_disabled; -+ } -+ -+ continue; -+ } -+ - for (i = 0; i < NUM_LONGJMP_NAMES; i++) - { - struct breakpoint *b; -@@ -2451,6 +2542,40 @@ create_exception_master_breakpoint (void) - - bp_objfile_data = get_breakpoint_objfile_data (objfile); - -+ /* We prefer the SystemTap probe point if it exists. */ -+ if (!bp_objfile_data->exception_searched) -+ { -+ bp_objfile_data->exception_probes -+ = find_probes_in_objfile (objfile, "libgcc", "unwind"); -+ bp_objfile_data->exception_searched = 1; -+ } -+ -+ if (bp_objfile_data->exception_probes != NULL) -+ { -+ struct gdbarch *gdbarch = get_objfile_arch (objfile); -+ int i; -+ struct stap_probe *probe; -+ -+ for (i = 0; -+ VEC_iterate (stap_probe_p, -+ bp_objfile_data->exception_probes, -+ i, probe); -+ ++i) -+ { -+ struct breakpoint *b; -+ -+ b = create_internal_breakpoint (gdbarch, probe->address, -+ bp_exception_master, -+ &internal_breakpoint_ops); -+ b->addr_string = xstrdup ("-p libgcc:unwind"); -+ b->enable_state = bp_disabled; -+ } -+ -+ continue; -+ } -+ -+ /* Otherwise, try the hook function. */ -+ - if (msym_not_found_p (bp_objfile_data->exception_msym)) - continue; - -@@ -2666,6 +2791,8 @@ remove_breakpoint_1 (struct bp_location *bl, insertion_state_t is) - { - /* No overlay handling: just remove the breakpoint. */ - val = bl->owner->ops->remove_location (bl); -+ -+ modify_semaphore (bl, 0); - } - else - { -@@ -7111,6 +7238,7 @@ momentary_breakpoint_from_master (struct breakpoint *orig, - 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->loc->source_file != NULL) - copy->loc->source_file = xstrdup (orig->loc->source_file); -@@ -7196,6 +7324,7 @@ add_location_to_breakpoint (struct breakpoint *b, - loc->requested_address = sal->pc; - loc->address = adjusted_address; - loc->pspace = sal->pspace; -+ loc->semaphore = sal->semaphore; - gdb_assert (loc->pspace != NULL); - loc->section = sal->section; - loc->gdbarch = loc_gdbarch; -@@ -13521,6 +13650,24 @@ all_tracepoints (void) +@@ -15154,6 +15154,24 @@ all_tracepoints (void) return tp_vec; } @@ -685,17 +122,7 @@ index f6a0276..e406156 100644 /* This help string is used for the break, hbreak, tbreak and thbreak commands. It is defined as a macro to prevent duplication. -@@ -13815,7 +13962,8 @@ _initialize_breakpoint (void) - observer_attach_inferior_exit (clear_syscall_counts); - observer_attach_memory_changed (invalidate_bp_value_on_memory_change); - -- breakpoint_objfile_key = register_objfile_data (); -+ breakpoint_objfile_key -+ = register_objfile_data_with_cleanup (NULL, free_breakpoint_probes); - - breakpoint_chain = 0; - /* Don't bother to call set_breakpoint_count. $bpnum isn't useful -@@ -14340,4 +14488,7 @@ range (including START-LOCATION and END-LOCATION).")); +@@ -16097,4 +16115,7 @@ Show the channel to use for dynamic printf"), NULL, automatic_hardware_breakpoints = 1; observer_attach_about_to_proceed (breakpoint_about_to_proceed); @@ -703,36 +130,8 @@ index f6a0276..e406156 100644 + observer_attach_mark_used (breakpoint_types_mark_used); +#endif } -diff --git a/gdb/breakpoint.h b/gdb/breakpoint.h -index 8a8d5f2..1e18562 100644 ---- a/gdb/breakpoint.h -+++ b/gdb/breakpoint.h -@@ -379,6 +379,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. */ -@@ -1412,4 +1417,11 @@ extern int user_breakpoint_p (struct breakpoint *); - /* Attempt to determine architecture of location identified by SAL. */ - extern struct gdbarch *get_sal_arch (struct symtab_and_line sal); - -+/* 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) */ diff --git a/gdb/c-typeprint.c b/gdb/c-typeprint.c -index db254dc..181de05 100644 +index a5892b5..2944c2d 100644 --- a/gdb/c-typeprint.c +++ b/gdb/c-typeprint.c @@ -624,9 +624,14 @@ c_type_print_varspec_suffix (struct type *type, @@ -753,106 +152,11 @@ index db254dc..181de05 100644 fprintf_filtered (stream, "]"); c_type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream, -diff --git a/gdb/cli/cli-utils.c b/gdb/cli/cli-utils.c -index a7b2718..a1e5161 100644 ---- a/gdb/cli/cli-utils.c -+++ b/gdb/cli/cli-utils.c -@@ -223,6 +223,18 @@ skip_spaces (char *chp) - return chp; - } - -+/* A const-correct version of the above. */ -+ -+const char * -+skip_spaces_const (const char *chp) -+{ -+ if (chp == NULL) -+ return NULL; -+ while (*chp && isspace (*chp)) -+ chp++; -+ return chp; -+} -+ - /* See documentation in cli-utils.h. */ - - char * -@@ -245,3 +257,32 @@ remove_trailing_whitespace (const char *start, char *s) - - return s; - } -+ -+/* See documentation in cli-utils.h. */ -+ -+char * -+extract_arg (char **arg) -+{ -+ char *result, *copy; -+ -+ if (!*arg) -+ return NULL; -+ -+ /* 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 (result == *arg) -+ return NULL; -+ -+ copy = xmalloc (*arg - result + 1); -+ memcpy (copy, result, *arg - result); -+ copy[*arg - result] = '\0'; -+ -+ return copy; -+} -diff --git a/gdb/cli/cli-utils.h b/gdb/cli/cli-utils.h -index e23c7d8..5f8a91d 100644 ---- a/gdb/cli/cli-utils.h -+++ b/gdb/cli/cli-utils.h -@@ -94,6 +94,10 @@ extern int number_is_in_list (char *list, int number); - - extern char *skip_spaces (char *inp); - -+/* A const-correct version of the above. */ -+ -+extern const char *skip_spaces_const (const char *inp); -+ - /* Skip leading non-whitespace characters in INP, returning an updated - pointer. If INP is NULL, return NULL. */ - -@@ -103,4 +107,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 */ -diff --git a/gdb/coffread.c b/gdb/coffread.c -index c727228..e1fab6d 100644 ---- a/gdb/coffread.c -+++ b/gdb/coffread.c -@@ -2195,6 +2195,7 @@ static const struct sym_fns coff_sym_fns = - - default_symfile_relocate, /* sym_relocate: Relocate a debug - section. */ -+ NULL, /* sym_probe_fns */ - &psym_functions - }; - diff --git a/gdb/data-directory/Makefile.in b/gdb/data-directory/Makefile.in -index 4296e5a..b04d12f 100644 +index 87c6dd4..1c26652 100644 --- a/gdb/data-directory/Makefile.in +++ b/gdb/data-directory/Makefile.in -@@ -52,13 +52,24 @@ SYSCALLS_FILES = \ +@@ -52,14 +52,25 @@ SYSCALLS_FILES = \ PYTHON_DIR = python PYTHON_INSTALL_DIR = $(DESTDIR)$(GDB_DATADIR)/$(PYTHON_DIR) PYTHON_FILES = \ @@ -868,8 +172,9 @@ index 4296e5a..b04d12f 100644 + gdb/command/ignore_errors.py \ + gdb/command/pahole.py \ gdb/command/pretty_printers.py \ -- gdb/command/prompt.py -+ gdb/command/prompt.py \ + gdb/command/prompt.py \ +- gdb/command/explore.py ++ gdb/command/explore.py \ + gdb/command/require.py \ + gdb/command/upto.py \ + gdb/function/__init__.py \ @@ -881,23 +186,11 @@ index 4296e5a..b04d12f 100644 FLAGS_TO_PASS = \ "prefix=$(prefix)" \ -diff --git a/gdb/dbxread.c b/gdb/dbxread.c -index adf8315..c11e4d4 100644 ---- a/gdb/dbxread.c -+++ b/gdb/dbxread.c -@@ -3588,6 +3588,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 - }; - diff --git a/gdb/defs.h b/gdb/defs.h -index 83a716a..7f8752e 100644 +index 03092aa..6d73386 100644 --- a/gdb/defs.h +++ b/gdb/defs.h -@@ -411,6 +411,8 @@ extern struct cleanup *make_cleanup_restore_page_info (void); +@@ -353,6 +353,8 @@ extern struct cleanup *make_cleanup_restore_page_info (void); extern struct cleanup * set_batch_flag_and_make_cleanup_restore_page_info (void); @@ -907,10 +200,10 @@ index 83a716a..7f8752e 100644 extern char *xfullpath (const char *); diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo -index 20b0b67..57068c3 100644 +index 014cfd8..d0a8c51 100644 --- a/gdb/doc/gdb.texinfo +++ b/gdb/doc/gdb.texinfo -@@ -1173,6 +1173,16 @@ for remote debugging. +@@ -1191,6 +1191,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. @@ -927,124 +220,7 @@ index 20b0b67..57068c3 100644 @c resolve the situation of these eventually @item -tui @cindex @code{--tui} -@@ -3301,6 +3311,7 @@ all breakpoints in that range are operated on. - * 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 -@@ -4530,6 +4541,50 @@ and remove the breakpoint definitions you're not interested in, or - that can no longer be recreated. - @end table - -+@node Static Probe Points -+@subsection Static Probe Points -+ -+@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}). -+ -+You can examine the available @code{SystemTap} static probes using -+@code{info probes}: -+ -+@table @code -+@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. -+ -+If given, @var{name} is a regular expression used to select which -+probes to list. If omitted, all probes are listed. -+ -+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 -+ -+@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_arg11}. 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'' -@@ -6555,6 +6610,29 @@ specify the function unambiguously, e.g., if there are several - functions with identical names in different source files. - @end table - -+@cindex SystemTap static probe point -+@item -p @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{-p} 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 - - -@@ -8811,6 +8889,10 @@ to match the format in which the data was printed. - 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_arg11 -+Arguments to a SystemTap static probe. @xref{Static Probe Points}. -+ - @item $_sdata - @vindex $_sdata@r{, inspect, convenience variable} - The variable @code{$_sdata} contains extra collected static tracepoint -@@ -10763,6 +10845,16 @@ Collect all local variables. - Collect the return address. This is helpful if you want to see more - of a backtrace. - -+@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 11. 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 -@@ -21506,8 +21598,6 @@ containing @code{end}. For example: +@@ -22494,8 +22504,6 @@ containing @code{end}. For example: @smallexample (@value{GDBP}) python @@ -1053,7 +229,7 @@ index 20b0b67..57068c3 100644 >print 23 >end 23 -@@ -21521,6 +21611,14 @@ controlled using @code{set python print-stack}: if @code{full}, then +@@ -22509,6 +22517,14 @@ controlled using @code{set python print-stack}: if @code{full}, then full Python stack printing is enabled; if @code{none}, then Python stack and message printing is disabled; if @code{message}, the default, only the message component of the error is printed. @@ -1068,7 +244,7 @@ index 20b0b67..57068c3 100644 @end table It is also possible to execute a Python script from the @value{GDBN} -@@ -21542,6 +21640,14 @@ and thus is always available. +@@ -22530,6 +22546,14 @@ and thus is always available. @cindex python api @cindex programming in python @@ -1084,7 +260,7 @@ index 20b0b67..57068c3 100644 @cindex python pagination At startup, @value{GDBN} overrides Python's @code{sys.stdout} and diff --git a/gdb/doc/gdbint.texinfo b/gdb/doc/gdbint.texinfo -index 026dc59..f0f6ee3 100644 +index 267a6eb..4f159b4 100644 --- a/gdb/doc/gdbint.texinfo +++ b/gdb/doc/gdbint.texinfo @@ -2103,6 +2103,18 @@ time, and so we attempt to handle symbols incrementally. For instance, @@ -1213,11 +389,11 @@ index 026dc59..f0f6ee3 100644 @node Language Support diff --git a/gdb/doc/observer.texi b/gdb/doc/observer.texi -index 24233cb..efb2013 100644 +index 6827ed8..c63b901 100644 --- a/gdb/doc/observer.texi +++ b/gdb/doc/observer.texi -@@ -226,6 +226,11 @@ Called before a top-level prompt is displayed. @var{current_prompt} is - the current top-level prompt. +@@ -230,6 +230,11 @@ the current top-level prompt. + Variable gdb_datadir has been set. The value may not necessarily change. @end deftypefun +@c @deftypefun void mark_used (void) @@ -1229,10 +405,10 @@ index 24233cb..efb2013 100644 This observer is used for internal testing. Do not use. See testsuite/gdb.gdb/observer.exp. diff --git a/gdb/dwarf2expr.c b/gdb/dwarf2expr.c -index 222fcc3..93389e0 100644 +index e0aafc7..7387711 100644 --- a/gdb/dwarf2expr.c +++ b/gdb/dwarf2expr.c -@@ -1449,6 +1449,14 @@ execute_stack_op (struct dwarf_expr_context *ctx, +@@ -1458,6 +1458,14 @@ execute_stack_op (struct dwarf_expr_context *ctx, } break; @@ -1248,16 +424,16 @@ index 222fcc3..93389e0 100644 error (_("Unhandled dwarf expression opcode 0x%x"), op); } diff --git a/gdb/dwarf2expr.h b/gdb/dwarf2expr.h -index fd70bf9..5129c4e 100644 +index f39ef3c..066cb10 100644 --- a/gdb/dwarf2expr.h +++ b/gdb/dwarf2expr.h -@@ -73,12 +73,10 @@ struct dwarf_expr_context_funcs - int dwarf_reg, CORE_ADDR fb_offset, - int deref_size); +@@ -91,12 +91,8 @@ struct dwarf_expr_context_funcs + This can throw an exception if the index is out of range. */ + CORE_ADDR (*get_addr_index) (void *baton, unsigned int index); -#if 0 - /* Not yet implemented. */ - +- /* Not yet implemented. */ +- /* Return the `object address' for DW_OP_push_object_address. */ CORE_ADDR (*get_object_address) (void *baton); -#endif @@ -1265,10 +441,10 @@ index fd70bf9..5129c4e 100644 /* The location of a value. */ diff --git a/gdb/dwarf2loc.c b/gdb/dwarf2loc.c -index 313df7b..35e0766 100644 +index 8c97f19..a6f3e9c 100644 --- a/gdb/dwarf2loc.c +++ b/gdb/dwarf2loc.c -@@ -157,6 +157,9 @@ struct dwarf_expr_baton +@@ -274,6 +274,9 @@ struct dwarf_expr_baton { struct frame_info *frame; struct dwarf2_per_cu_data *per_cu; @@ -1278,7 +454,7 @@ index 313df7b..35e0766 100644 }; /* Helper functions for dwarf2_evaluate_loc_desc. */ -@@ -216,16 +219,14 @@ static void +@@ -333,16 +336,14 @@ static void dwarf_expr_frame_base_1 (struct symbol *framefunc, CORE_ADDR pc, const gdb_byte **start, size_t *length) { @@ -1297,7 +473,7 @@ index 313df7b..35e0766 100644 { struct dwarf2_locexpr_baton *symbaton; -@@ -238,10 +239,23 @@ dwarf_expr_frame_base_1 (struct symbol *framefunc, CORE_ADDR pc, +@@ -355,10 +356,23 @@ dwarf_expr_frame_base_1 (struct symbol *framefunc, CORE_ADDR pc, else *length = 0; } @@ -1322,7 +498,7 @@ index 313df7b..35e0766 100644 } /* Helper function for dwarf2_evaluate_loc_desc. Computes the CFA for -@@ -309,6 +323,85 @@ dwarf_expr_dwarf_call (struct dwarf_expr_context *ctx, size_t die_offset) +@@ -426,6 +440,85 @@ dwarf_expr_dwarf_call (struct dwarf_expr_context *ctx, cu_offset die_offset) ctx->funcs->get_frame_pc, ctx->baton); } @@ -1408,7 +584,7 @@ index 313df7b..35e0766 100644 /* Callback function for dwarf2_evaluate_loc_desc. */ static struct type * -@@ -990,10 +1083,12 @@ dwarf_expr_push_dwarf_reg_entry_value (struct dwarf_expr_context *ctx, +@@ -1105,10 +1198,12 @@ dwarf_expr_push_dwarf_reg_entry_value (struct dwarf_expr_context *ctx, saved_ctx.gdbarch = ctx->gdbarch; saved_ctx.addr_size = ctx->addr_size; @@ -1421,7 +597,7 @@ index 313df7b..35e0766 100644 ctx->offset = dwarf2_per_cu_text_offset (baton_local.per_cu); ctx->baton = &baton_local; -@@ -1001,10 +1096,92 @@ dwarf_expr_push_dwarf_reg_entry_value (struct dwarf_expr_context *ctx, +@@ -1116,10 +1211,95 @@ dwarf_expr_push_dwarf_reg_entry_value (struct dwarf_expr_context *ctx, ctx->gdbarch = saved_ctx.gdbarch; ctx->addr_size = saved_ctx.addr_size; @@ -1430,6 +606,8 @@ index 313df7b..35e0766 100644 ctx->baton = saved_ctx.baton; } ++static CORE_ADDR dwarf_expr_get_addr_index (void *baton, unsigned int index); ++ +/* Virtual method table for dwarf2_evaluate_loc_desc_full below. */ + +static const struct dwarf_expr_context_funcs dwarf_expr_ctx_funcs = @@ -1443,6 +621,7 @@ index 313df7b..35e0766 100644 + dwarf_expr_dwarf_call, + dwarf_expr_get_base_type, + dwarf_expr_push_dwarf_reg_entry_value, ++ dwarf_expr_get_addr_index, + dwarf_expr_object_address +}; + @@ -1511,10 +690,10 @@ index 313df7b..35e0766 100644 + return retval; +} + - /* VALUE must be of type lval_computed with entry_data_value_funcs. Perform - the indirect method on it, that is use its stored target value, the sole - purpose of entry_data_value_funcs.. */ -@@ -1927,21 +2104,6 @@ invalid_synthetic_pointer (void) + /* Callback function for dwarf2_evaluate_loc_desc. + Fetch the address indexed by DW_OP_GNU_addr_index. */ + +@@ -2053,22 +2233,6 @@ invalid_synthetic_pointer (void) "referenced via synthetic pointer")); } @@ -1530,13 +709,14 @@ index 313df7b..35e0766 100644 - dwarf_expr_tls_address, - dwarf_expr_dwarf_call, - dwarf_expr_get_base_type, -- dwarf_expr_push_dwarf_reg_entry_value +- dwarf_expr_push_dwarf_reg_entry_value, +- dwarf_expr_get_addr_index -}; - /* Evaluate a location description, starting at DATA and with length SIZE, to find the current location of variable of TYPE in the context of FRAME. BYTE_OFFSET is applied after the contents are -@@ -1954,7 +2116,6 @@ dwarf2_evaluate_loc_desc_full (struct type *type, struct frame_info *frame, +@@ -2081,7 +2245,6 @@ dwarf2_evaluate_loc_desc_full (struct type *type, struct frame_info *frame, LONGEST byte_offset) { struct value *retval; @@ -1544,7 +724,7 @@ index 313df7b..35e0766 100644 struct dwarf_expr_context *ctx; struct cleanup *old_chain, *value_chain; struct objfile *objfile = dwarf2_per_cu_objfile (per_cu); -@@ -1966,29 +2127,18 @@ dwarf2_evaluate_loc_desc_full (struct type *type, struct frame_info *frame, +@@ -2093,29 +2256,18 @@ dwarf2_evaluate_loc_desc_full (struct type *type, struct frame_info *frame, if (size == 0) return allocate_optimized_out_value (type); @@ -1575,7 +755,7 @@ index 313df7b..35e0766 100644 retval = allocate_value (type); mark_value_bytes_unavailable (retval, 0, TYPE_LENGTH (type)); return retval; -@@ -2052,6 +2202,16 @@ dwarf2_evaluate_loc_desc_full (struct type *type, struct frame_info *frame, +@@ -2179,6 +2331,16 @@ dwarf2_evaluate_loc_desc_full (struct type *type, struct frame_info *frame, int in_stack_memory = dwarf_expr_fetch_in_stack_memory (ctx, 0); do_cleanups (value_chain); @@ -1592,7 +772,7 @@ index 313df7b..35e0766 100644 retval = allocate_value_lazy (type); VALUE_LVAL (retval) = lval_memory; if (in_stack_memory) -@@ -3896,8 +4056,7 @@ loclist_tracepoint_var_ref (struct symbol *symbol, struct gdbarch *gdbarch, +@@ -4048,8 +4210,7 @@ loclist_tracepoint_var_ref (struct symbol *symbol, struct gdbarch *gdbarch, dlbaton->per_cu); } @@ -1602,7 +782,7 @@ index 313df7b..35e0766 100644 const struct symbol_computed_ops dwarf2_loclist_funcs = { loclist_read_variable, loclist_read_variable_at_entry, -@@ -3906,6 +4065,48 @@ const struct symbol_computed_ops dwarf2_loclist_funcs = { +@@ -4058,6 +4219,48 @@ const struct symbol_computed_ops dwarf2_loclist_funcs = { loclist_tracepoint_var_ref }; @@ -1648,14 +828,14 @@ index 313df7b..35e0766 100644 + missing_tracepoint_var_ref +}; + - void - _initialize_dwarf2loc (void) - { + /* Provide a prototype to silence -Wmissing-prototypes. */ + extern initialize_file_ftype _initialize_dwarf2loc; + diff --git a/gdb/dwarf2loc.h b/gdb/dwarf2loc.h -index a7f835f..52a44f1 100644 +index e9d06a3..bfa6776 100644 --- a/gdb/dwarf2loc.h +++ b/gdb/dwarf2loc.h -@@ -118,6 +118,15 @@ struct dwarf2_loclist_baton +@@ -127,6 +127,15 @@ struct dwarf2_loclist_baton extern const struct symbol_computed_ops dwarf2_locexpr_funcs; extern const struct symbol_computed_ops dwarf2_loclist_funcs; @@ -1672,10 +852,10 @@ index a7f835f..52a44f1 100644 /* Compile a DWARF location expression to an agent expression. diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c -index 0ef0a5b..80e5fe4 100644 +index 8dbc53e..b5b7813 100644 --- a/gdb/dwarf2read.c +++ b/gdb/dwarf2read.c -@@ -1209,6 +1209,9 @@ static void fill_in_loclist_baton (struct dwarf2_cu *cu, +@@ -1348,6 +1348,9 @@ static void fill_in_loclist_baton (struct dwarf2_cu *cu, struct dwarf2_loclist_baton *baton, struct attribute *attr); @@ -1685,9 +865,9 @@ index 0ef0a5b..80e5fe4 100644 static void dwarf2_symbol_mark_computed (struct attribute *attr, struct symbol *sym, struct dwarf2_cu *cu); -@@ -1240,6 +1243,9 @@ static void age_cached_comp_units (void); +@@ -1380,6 +1383,9 @@ static void age_cached_comp_units (void); - static void free_one_cached_comp_unit (void *); + static void free_one_cached_comp_unit (struct dwarf2_per_cu_data *); +static void fetch_die_type_attrs (struct die_info *die, struct type *type, + struct dwarf2_cu *cu); @@ -1695,7 +875,7 @@ index 0ef0a5b..80e5fe4 100644 static struct type *set_die_type (struct die_info *, struct type *, struct dwarf2_cu *); -@@ -1263,6 +1269,9 @@ static struct type *get_die_type_at_offset (unsigned int, +@@ -1405,6 +1411,9 @@ static struct type *get_die_type_at_offset (sect_offset, static struct type *get_die_type (struct die_info *die, struct dwarf2_cu *cu); @@ -1704,8 +884,8 @@ index 0ef0a5b..80e5fe4 100644 + static void dwarf2_release_queue (void *dummy); - static void queue_comp_unit (struct dwarf2_per_cu_data *per_cu); -@@ -8001,6 +8010,29 @@ process_enumeration_scope (struct die_info *die, struct dwarf2_cu *cu) + static void queue_comp_unit (struct dwarf2_per_cu_data *per_cu, +@@ -9526,6 +9535,29 @@ process_enumeration_scope (struct die_info *die, struct dwarf2_cu *cu) new_symbol (die, this_type, cu); } @@ -1735,7 +915,7 @@ index 0ef0a5b..80e5fe4 100644 /* Extract all information from a DW_TAG_array_type DIE and put it in the DIE's type field. For now, this only handles one dimensional arrays. */ -@@ -8014,7 +8046,7 @@ read_array_type (struct die_info *die, struct dwarf2_cu *cu) +@@ -9539,7 +9571,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; @@ -1744,7 +924,7 @@ index 0ef0a5b..80e5fe4 100644 struct cleanup *back_to; char *name; -@@ -8067,17 +8099,19 @@ read_array_type (struct die_info *die, struct dwarf2_cu *cu) +@@ -9592,17 +9624,19 @@ read_array_type (struct die_info *die, struct dwarf2_cu *cu) type = element_type; if (read_array_order (die, cu) == DW_ORD_col_major) @@ -1775,7 +955,7 @@ index 0ef0a5b..80e5fe4 100644 /* Understand Dwarf2 support for vector types (like they occur on the PowerPC w/ AltiVec). Gcc just adds another attribute to the -@@ -8561,29 +8595,114 @@ read_tag_string_type (struct die_info *die, struct dwarf2_cu *cu) +@@ -10086,29 +10120,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; @@ -1819,8 +999,8 @@ index 0ef0a5b..80e5fe4 100644 + ULONGEST ulongest; + const gdb_byte *end; + -+ end = read_uleb128 (&blk->data[1], &blk->data[blk->size], -+ &ulongest); ++ end = safe_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); + } @@ -1903,43 +1083,86 @@ index 0ef0a5b..80e5fe4 100644 char_type = language_string_char_type (cu->language_defn, gdbarch); type = create_string_type (NULL, char_type, range_type); -@@ -8887,8 +9006,7 @@ read_subrange_type (struct die_info *die, struct dwarf2_cu *cu) +@@ -10412,7 +10531,7 @@ 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, high; + LONGEST low; + int low_default_is_valid; char *name; LONGEST negative_mask; +@@ -10468,42 +10587,6 @@ read_subrange_type (struct die_info *die, struct dwarf2_cu *cu) + "- DIE at 0x%x [in module %s]"), + die->offset.sect_off, cu->objfile->name); -@@ -8901,53 +9019,126 @@ read_subrange_type (struct die_info *die, struct dwarf2_cu *cu) - if (range_type) - return range_type; - -- if (cu->language == language_fortran) +- attr = dwarf2_attr (die, DW_AT_upper_bound, cu); +- if (attr) +- { +- if (attr_form_is_block (attr) || 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); +- } +- else - { -- /* FORTRAN implies a lower bound of 1, if not given. */ -- low = 1; +- attr = dwarf2_attr (die, DW_AT_count, cu); +- if (attr) +- { +- int count = dwarf2_get_attr_constant_value (attr, 1); +- high = low + count - 1; +- } +- else +- { +- /* Unspecified array length. */ +- high = low - 1; +- } - } +- + /* Dwarf-2 specifications explicitly allows to create subrange types + without specifying a base type. + In that case, the base type must be set to the type of +@@ -10542,24 +10625,163 @@ read_subrange_type (struct die_info *die, struct dwarf2_cu *cu) + } + } + +- negative_mask = + /* 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; + + negative_mask = -+ (LONGEST) -1 << (TYPE_LENGTH (base_type) * TARGET_CHAR_BIT - 1); -+ -+ /* Exclude language_ada from any TYPE_DYNAMIC constructs below. GDB Ada -+ supports implements the dynamic bounds in a non-DWARF way and the + (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); ++ /* Exclude language_ada from any TYPE_DYNAMIC constructs below. GDB Ada ++ supports implements the dynamic bounds in a non-DWARF way and the + existing DWARF dynamic bounds are invalid, leading to memory access + errors. */ -- /* FIXME: For variable sized arrays either of these could be -- a variable rather than a constant value. We'll allow it, -- 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); +- /* 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_is_block (attr)) +- TYPE_HIGH_BOUND_UNDEFINED (range_type) = 1; ++ attr = dwarf2_attr (die, DW_AT_lower_bound, cu); + if (attr && attr_form_is_block (attr) && cu->language != language_ada) + { + TYPE_RANGE_DATA (range_type)->low.kind = RANGE_BOUND_KIND_DWARF_BLOCK; @@ -1954,9 +1177,7 @@ index 0ef0a5b..80e5fe4 100644 + struct die_info *target_die; + struct dwarf2_cu *target_cu = cu; + struct attribute *target_loc_attr; - -- attr = dwarf2_attr (die, DW_AT_upper_bound, cu); -- if (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); @@ -1971,26 +1192,10 @@ index 0ef0a5b..80e5fe4 100644 + low = 0; + } + else - { -- if (attr_form_is_block (attr) || 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); ++ else + { + if (cu->language == language_fortran) + { @@ -2009,24 +1214,22 @@ index 0ef0a5b..80e5fe4 100644 + TYPE_LOW_BOUND (range_type) = low; + if (low >= 0) + TYPE_UNSIGNED (range_type) = 1; - } -- else -+ ++ } + +- /* Ada expects an empty array on no boundary attributes. */ +- if (attr == NULL && cu->language != language_ada) +- TYPE_HIGH_BOUND_UNDEFINED (range_type) = 1; + 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; ++ { ++ 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. */ + } + @@ -2060,32 +1263,18 @@ index 0ef0a5b..80e5fe4 100644 + + if (attr && attr_form_is_constant (attr)) + high = dwarf2_get_attr_constant_value (attr, 0); - else - { -- /* Unspecified array length. */ ++ else ++ { + /* Ada expects an empty array on no boundary attributes. */ + if (cu->language != language_ada) + TYPE_HIGH_BOUND_UNDEFINED (range_type) = 1; - high = low - 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 -@@ -8988,24 +9179,41 @@ read_subrange_type (struct die_info *die, struct dwarf2_cu *cu) - } - } - -- negative_mask = -- (LONGEST) -1 << (TYPE_LENGTH (base_type) * TARGET_CHAR_BIT - 1); -- if (!TYPE_UNSIGNED (base_type) && (low & negative_mask)) -- low |= negative_mask; -- if (!TYPE_UNSIGNED (base_type) && (high & negative_mask)) -- high |= negative_mask; -- -- range_type = create_range_type (NULL, base_type, low, high); ++ } ++ + /* 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) @@ -2101,19 +1290,11 @@ index 0ef0a5b..80e5fe4 100644 + struct die_info *target_die; + struct dwarf2_cu *target_cu = cu; + struct attribute *target_loc_attr; - -- /* 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_is_block (attr)) -- TYPE_HIGH_BOUND_UNDEFINED (range_type) = 1; ++ + 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); - -- /* Ada expects an empty array on no boundary attributes. */ -- if (attr == NULL && cu->language != language_ada) -- 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 @@ -2132,7 +1313,7 @@ index 0ef0a5b..80e5fe4 100644 name = dwarf2_name (die, cu); if (name) -@@ -11545,10 +11753,12 @@ var_decode_location (struct attribute *attr, struct symbol *sym, +@@ -13257,10 +13479,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 @@ -2147,7 +1328,7 @@ index 0ef0a5b..80e5fe4 100644 if (SYMBOL_COMPUTED_OPS (sym) == &dwarf2_loclist_funcs) cu->has_loclist = 1; -@@ -11589,6 +11799,8 @@ new_symbol_full (struct die_info *die, struct type *type, struct dwarf2_cu *cu, +@@ -13301,6 +13525,8 @@ new_symbol_full (struct die_info *die, struct type *type, struct dwarf2_cu *cu, else sym = OBSTACK_ZALLOC (&objfile->objfile_obstack, struct symbol); OBJSTAT (objfile, n_syms++); @@ -2156,7 +1337,7 @@ index 0ef0a5b..80e5fe4 100644 /* Cache this symbol's name and the name's demangled form (if any). */ SYMBOL_SET_LANGUAGE (sym, cu->language); -@@ -12354,6 +12566,9 @@ read_type_die_1 (struct die_info *die, struct dwarf2_cu *cu) +@@ -14075,6 +14301,9 @@ read_type_die_1 (struct die_info *die, struct dwarf2_cu *cu) break; } @@ -2166,8 +1347,8 @@ index 0ef0a5b..80e5fe4 100644 return this_type; } -@@ -15590,62 +15805,100 @@ fill_in_loclist_baton (struct dwarf2_cu *cu, - baton->base_address = cu->base_address; +@@ -16472,62 +16701,100 @@ fill_in_loclist_baton (struct dwarf2_cu *cu, + baton->from_dwo = cu->dwo_unit != NULL; } -static void @@ -2178,26 +1359,16 @@ index 0ef0a5b..80e5fe4 100644 + +static struct dwarf2_locexpr_baton * +dwarf2_attr_to_locexpr_baton (struct attribute *attr, struct dwarf2_cu *cu) - { - struct objfile *objfile = dwarf2_per_objfile->objfile; ++{ ++ struct objfile *objfile = dwarf2_per_objfile->objfile; + struct dwarf2_locexpr_baton *baton; - -- 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 (objfile, -- &dwarf2_per_objfile->loc)) -- { -- struct dwarf2_loclist_baton *baton; ++ + gdb_assert (attr_form_is_block (attr)); + + baton = obstack_alloc (&objfile->objfile_obstack, sizeof (*baton)); + baton->per_cu = cu->per_cu; + gdb_assert (baton->per_cu); - -- baton = obstack_alloc (&objfile->objfile_obstack, -- sizeof (struct dwarf2_loclist_baton)); ++ + /* 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 @@ -2206,18 +1377,15 @@ index 0ef0a5b..80e5fe4 100644 + baton->size = DW_BLOCK (attr)->size; + baton->data = DW_BLOCK (attr)->data; + gdb_assert (baton->size == 0 || baton->data != NULL); - -- fill_in_loclist_baton (cu, baton, attr); ++ + return baton; +} - -- if (cu->base_known == 0) -- complaint (&symfile_complaints, -- _("Location list used without " -- "specifying the CU base address.")); ++ +static struct dwarf2_loclist_baton * +dwarf2_attr_to_loclist_baton (struct attribute *attr, struct dwarf2_cu *cu) -+{ + { + struct objfile *objfile = dwarf2_per_objfile->objfile; + struct dwarf2_section_info *section = cu_debug_loc_section (cu); + struct dwarf2_loclist_baton *baton; + + /* DW_AT_location of the referenced DIE may be missing if the referenced @@ -2225,27 +1393,36 @@ index 0ef0a5b..80e5fe4 100644 + if (!attr) + return NULL; + -+ dwarf2_read_section (dwarf2_per_objfile->objfile, -+ &dwarf2_per_objfile->loc); -+ ++ dwarf2_read_section (dwarf2_per_objfile->objfile, section); + +- if (attr_form_is_section_offset (attr) + 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))) + /* .debug_loc{,.dwo} 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 (objfile, section)) +- { +- struct dwarf2_loclist_baton *baton; ++ && DW_UNSND (attr) < dwarf2_section_size (objfile, section))) + return NULL; -+ -+ baton = obstack_alloc (&cu->objfile->objfile_obstack, + +- baton = obstack_alloc (&objfile->objfile_obstack, +- sizeof (struct dwarf2_loclist_baton)); ++ baton = obstack_alloc (&objfile->objfile_obstack, + sizeof (struct dwarf2_loclist_baton)); -+ + +- fill_in_loclist_baton (cu, baton, attr); + fill_in_loclist_baton (cu, baton, attr); -+ + +- if (cu->base_known == 0) +- complaint (&symfile_complaints, +- _("Location list used without " +- "specifying the CU base address.")); + if (cu->base_known == 0) + complaint (&symfile_complaints, + _("Location list used without " + "specifying the CU base address.")); - ++ + return baton; +} + @@ -2256,7 +1433,7 @@ index 0ef0a5b..80e5fe4 100644 + struct dwarf2_cu *cu) +{ + struct dwarf2_loclist_baton *loclist_baton; -+ + + loclist_baton = dwarf2_attr_to_loclist_baton (attr, cu); + if (loclist_baton) + { @@ -2309,8 +1486,8 @@ index 0ef0a5b..80e5fe4 100644 } } -@@ -16003,6 +16256,25 @@ offset_and_type_eq (const void *item_lhs, const void *item_rhs) - return ofs_lhs->offset == ofs_rhs->offset; +@@ -16895,6 +17162,25 @@ per_cu_offset_and_type_eq (const void *item_lhs, const void *item_rhs) + && ofs_lhs->offset.sect_off == ofs_rhs->offset.sect_off); } +/* Fill in generic attributes applicable for type DIEs. */ @@ -2335,356 +1512,17 @@ index 0ef0a5b..80e5fe4 100644 /* Set the type associated with DIE to TYPE. Save it in CU's hash table if necessary. For convenience, return TYPE. -@@ -16028,6 +16300,8 @@ set_die_type (struct die_info *die, struct type *type, struct dwarf2_cu *cu) +@@ -16919,6 +17205,8 @@ set_die_type (struct die_info *die, struct type *type, struct dwarf2_cu *cu) + struct dwarf2_per_cu_offset_and_type **slot, ofs; struct objfile *objfile = cu->objfile; - htab_t *type_hash_ptr; + 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 -diff --git a/gdb/elfread.c b/gdb/elfread.c -index ddae099..aea443f 100644 ---- a/gdb/elfread.c -+++ b/gdb/elfread.c -@@ -36,6 +36,8 @@ - #include "demangle.h" - #include "psympriv.h" - #include "filenames.h" -+#include "stap-probe.h" -+#include "arch-utils.h" - #include "gdbtypes.h" - #include "value.h" - #include "infcall.h" -@@ -60,6 +62,21 @@ struct elfinfo - asection *mdebugsect; /* Section pointer for .mdebug section */ - }; - -+/* Per-objfile data for SystemTap probe info. */ -+ -+static const struct objfile_data *stap_probe_key = NULL; -+ -+/* Per-objfile data about SystemTap probes. */ -+ -+struct stap_probe_per_objfile -+ { -+ /* The number of probes in this objfile. */ -+ int stap_num_probes; -+ -+ /* The probes themselves. */ -+ struct stap_probe *probes; -+ }; -+ - static void free_elfinfo (void *); - - /* Minimal symbols located at the GOT entries for .plt - that is the real -@@ -1576,7 +1593,270 @@ elfstab_offset_sections (struct objfile *objfile, struct partial_symtab *pst) - complaint (&symfile_complaints, - _("elf/stab section information missing for %s"), filename); - } -+ -+/* Helper function that parses the information contained in a -+ SystemTap's probe. Basically, the information consists in: -+ -+ - 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. */ -+ -+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; -+ -+ ret->gdbarch = gdbarch; -+ -+ /* 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) -+ ++ret->args; -+ 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; -+} -+ -+/* The name of the SystemTap section where we will find information about -+ the probes. */ -+ -+#define STAP_BASE_SECTION_NAME ".stapsdt.base" -+ -+/* Helper function which tries to find the base address of the SystemTap -+ base section named STAP_BASE_SECTION_NAME. */ -+ -+static void -+get_base_address_1 (bfd *abfd, asection *sect, void *obj) -+{ -+ 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; -+} -+ -+/* 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. */ -+ -+static bfd_vma -+get_base_address (bfd *obfd) -+{ -+ bfd_vma base = (bfd_vma) -1; -+ -+ bfd_map_over_sections (obfd, get_base_address_1, (void *) &base); -+ -+ return base; -+} -+ -+/* Implementation of `sym_get_probes', as documented in symfile.h. */ -+ -+static struct stap_probe * -+elf_get_probes (struct objfile *objfile, int *num_probes) -+{ -+ struct stap_probe *ret = NULL; -+ struct stap_probe_per_objfile *probes_per_objfile; -+ -+ /* Initially, no probes. */ -+ *num_probes = 0; -+ -+ /* Have we parsed this objfile's probes already? */ -+ probes_per_objfile -+ = (struct stap_probe_per_objfile *) objfile_data (objfile, -+ stap_probe_key); -+ -+ 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. */ -+ -+ bfd *obfd = objfile->obfd; -+ bfd_vma base = get_base_address (obfd); -+ struct sdt_note *iter; -+ int i; -+ int n = 0; -+ -+ if (! elf_tdata (obfd)->sdt_note_head) -+ /* There isn't any probe here. */ -+ return NULL; -+ -+ /* Allocating space for probe info. */ -+ for (iter = elf_tdata (obfd)->sdt_note_head; -+ iter; -+ iter = iter->next, ++n); -+ -+ ret = xcalloc (n, sizeof (struct stap_probe)); -+ -+ /* 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); -+ -+ /* Creating a cache for these probes in the objfile's registry. */ -+ probes_per_objfile = xmalloc (sizeof (struct stap_probe_per_objfile)); -+ -+ probes_per_objfile->stap_num_probes = n; -+ probes_per_objfile->probes = ret; -+ -+ set_objfile_data (objfile, stap_probe_key, probes_per_objfile); -+ } -+ else -+ ret = probes_per_objfile->probes; -+ -+ *num_probes = probes_per_objfile->stap_num_probes; -+ -+ return ret; -+} -+ -+/* Implementation of `sym_get_probe_argument_count', as documented in -+ symfile.h. */ -+ -+static int -+elf_get_probe_argument_count (struct objfile *objfile, -+ struct stap_probe *probe) -+{ -+ const char *pargs = probe->args; -+ -+ if (!pargs || !*pargs || *pargs == ':') -+ /* No arguments. */ -+ return 0; -+ -+ return stap_get_probe_argument_count (probe); -+} -+ -+/* Implementation of `sym_evaluate_probe_argument', as documented in -+ symfile.h. */ -+ -+static struct value * -+elf_evaluate_probe_argument (struct objfile *objfile, -+ struct stap_probe *probe, -+ struct frame_info *frame, -+ int n) -+{ -+ return stap_evaluate_probe_argument (objfile, probe, frame, n); -+} -+ -+/* Implementation of `sym_compile_to_ax', as documented in symfile.h. */ -+ -+static void -+elf_compile_to_ax (struct objfile *objfile, -+ struct stap_probe *probe, -+ struct agent_expr *expr, -+ struct axs_value *value, -+ int n) -+{ -+ stap_compile_to_ax (objfile, probe, expr, value, n); -+} -+ -+/* Implementation of `sym_relocate_probe', as documented in symfile.h. */ -+ -+static void -+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); -+ -+ if (!p) -+ /* No probe to relocate. */ -+ return; -+ -+ 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 -+stap_probe_key_free (struct objfile *objfile, void *d) -+{ -+ int i; -+ struct stap_probe_per_objfile *data = (struct stap_probe_per_objfile *) d; -+ -+ for (i = 0; i < data->stap_num_probes; i++) -+ stap_free_parsed_args (data->probes[i].parsed_args); -+ xfree (data->probes); -+ xfree (data); -+} -+ - -+ -+/* 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 */ -+}; -+ - /* Register that we are able to handle ELF object file formats. */ - - static const struct sym_fns elf_sym_fns = -@@ -1591,6 +1871,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 - }; - -@@ -1609,6 +1890,7 @@ static const struct sym_fns elf_sym_fns_lazy_psyms = - 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 - }; - -@@ -1626,6 +1908,7 @@ static const struct sym_fns elf_sym_fns_gdb_index = - 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 - }; - -@@ -1642,6 +1925,8 @@ static const struct gnu_ifunc_fns elf_gnu_ifunc_fns = - 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 (); diff --git a/gdb/eval.c b/gdb/eval.c -index 0244f7a..b33d367 100644 +index 7f1dfac..52462bc 100644 --- a/gdb/eval.c +++ b/gdb/eval.c @@ -41,6 +41,7 @@ @@ -2695,7 +1533,7 @@ index 0244f7a..b33d367 100644 #include "gdb_assert.h" -@@ -498,27 +499,217 @@ init_array_element (struct value *array, struct value *element, +@@ -500,27 +501,217 @@ init_array_element (struct value *array, struct value *element, } static struct value * @@ -2929,7 +1767,7 @@ index 0244f7a..b33d367 100644 } -@@ -799,6 +990,7 @@ evaluate_subexp_standard (struct type *expect_type, +@@ -801,6 +992,7 @@ evaluate_subexp_standard (struct type *expect_type, int save_pos1; struct symbol *function = NULL; char *function_name = NULL; @@ -2937,7 +1775,7 @@ index 0244f7a..b33d367 100644 pc = (*pos)++; op = exp->elts[pc].opcode; -@@ -1874,6 +2066,8 @@ evaluate_subexp_standard (struct type *expect_type, +@@ -1875,6 +2067,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); @@ -2946,7 +1784,7 @@ index 0244f7a..b33d367 100644 type = check_typedef (value_type (arg1)); code = TYPE_CODE (type); -@@ -1894,23 +2088,13 @@ evaluate_subexp_standard (struct type *expect_type, +@@ -1895,23 +2089,13 @@ evaluate_subexp_standard (struct type *expect_type, code = TYPE_CODE (type); } } @@ -2972,7 +1810,7 @@ index 0244f7a..b33d367 100644 case TYPE_CODE_PTR: case TYPE_CODE_FUNC: -@@ -2349,49 +2533,6 @@ evaluate_subexp_standard (struct type *expect_type, +@@ -2344,49 +2528,6 @@ evaluate_subexp_standard (struct type *expect_type, } return (arg1); @@ -3022,7 +1860,7 @@ index 0244f7a..b33d367 100644 case BINOP_LOGICAL_AND: arg1 = evaluate_subexp (NULL_TYPE, exp, pos, noside); if (noside == EVAL_SKIP) -@@ -2623,15 +2764,23 @@ evaluate_subexp_standard (struct type *expect_type, +@@ -2618,15 +2759,23 @@ evaluate_subexp_standard (struct type *expect_type, if (expect_type && TYPE_CODE (expect_type) == TYPE_CODE_PTR) expect_type = TYPE_TARGET_TYPE (check_typedef (expect_type)); arg1 = evaluate_subexp (expect_type, exp, pos, noside); @@ -3048,7 +1886,7 @@ index 0244f7a..b33d367 100644 else if (noside == EVAL_AVOID_SIDE_EFFECTS) { type = check_typedef (value_type (arg1)); -@@ -2640,12 +2789,18 @@ evaluate_subexp_standard (struct type *expect_type, +@@ -2635,12 +2784,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 ) @@ -3072,7 +1910,7 @@ index 0244f7a..b33d367 100644 else error (_("Attempt to take contents of a non-pointer value.")); } -@@ -2655,9 +2810,14 @@ evaluate_subexp_standard (struct type *expect_type, +@@ -2650,9 +2805,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) @@ -3090,7 +1928,7 @@ index 0244f7a..b33d367 100644 case UNOP_ADDR: /* C++: check for and handle pointer to members. */ -@@ -2999,7 +3159,7 @@ evaluate_subexp_with_coercion (struct expression *exp, +@@ -2994,7 +3154,7 @@ evaluate_subexp_with_coercion (struct expression *exp, { enum exp_opcode op; int pc; @@ -3099,7 +1937,7 @@ index 0244f7a..b33d367 100644 struct symbol *var; struct type *type; -@@ -3010,13 +3170,18 @@ evaluate_subexp_with_coercion (struct expression *exp, +@@ -3005,13 +3165,18 @@ evaluate_subexp_with_coercion (struct expression *exp, { case OP_VAR_VALUE: var = exp->elts[pc + 2].symbol; @@ -3119,7 +1957,7 @@ index 0244f7a..b33d367 100644 return value_cast (lookup_pointer_type (TYPE_TARGET_TYPE (type)), val); } -@@ -3068,9 +3233,13 @@ evaluate_subexp_for_sizeof (struct expression *exp, int *pos) +@@ -3063,9 +3228,13 @@ evaluate_subexp_for_sizeof (struct expression *exp, int *pos) case OP_VAR_VALUE: (*pos) += 4; @@ -3136,7 +1974,7 @@ index 0244f7a..b33d367 100644 default: val = evaluate_subexp (NULL_TYPE, exp, pos, EVAL_AVOID_SIDE_EFFECTS); -@@ -3101,18 +3270,25 @@ parse_and_eval_type (char *p, int length) +@@ -3096,18 +3265,25 @@ parse_and_eval_type (char *p, int length) int calc_f77_array_dims (struct type *array_type) { @@ -3173,10 +2011,10 @@ index 0244f7a..b33d367 100644 + } diff --git a/gdb/f-exp.y b/gdb/f-exp.y -index b258c0a..1752973 100644 +index 33c7418..4db1bfa 100644 --- a/gdb/f-exp.y +++ b/gdb/f-exp.y -@@ -292,7 +292,9 @@ arglist : subrange +@@ -298,7 +298,9 @@ arglist : subrange { arglist_len = 1; } ; @@ -3188,7 +2026,7 @@ index b258c0a..1752973 100644 ; diff --git a/gdb/f-lang.h b/gdb/f-lang.h -index 3a46ebf..2b73e1f 100644 +index 4aae3c5..51a4e1e 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 */ @@ -3199,9 +2037,9 @@ index 3a46ebf..2b73e1f 100644 + (struct type *type, struct ui_file *stream); +extern void f_object_address_data_valid_or_error (struct type *type); + - extern int f_val_print (struct type *, const gdb_byte *, int, CORE_ADDR, - struct ui_file *, int, - const struct value *, + extern void 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 a95ef84..830917d 100644 --- a/gdb/f-typeprint.c @@ -3271,7 +2109,7 @@ index a95ef84..830917d 100644 { case TYPE_CODE_ARRAY: diff --git a/gdb/f-valprint.c b/gdb/f-valprint.c -index 87b2ed1..5d263f2 100644 +index 8b84b5a..4b240a3 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]; @@ -3399,43 +2237,41 @@ index 87b2ed1..5d263f2 100644 fprintf_filtered (stream, "..."); } } -@@ -260,6 +268,9 @@ f_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset, +@@ -270,6 +278,9 @@ f_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset, CORE_ADDR addr; int index; + if (f_object_address_data_valid_print_to_stream (type, stream) != NULL) -+ return 0; ++ return; + CHECK_TYPEDEF (type); switch (TYPE_CODE (type)) { diff --git a/gdb/findvar.c b/gdb/findvar.c -index 79c4221..1bb7c22 100644 +index ed7903c..e412a3d 100644 --- a/gdb/findvar.c +++ b/gdb/findvar.c -@@ -34,6 +34,7 @@ - #include "user-regs.h" +@@ -35,6 +35,7 @@ #include "block.h" #include "objfiles.h" + #include "language.h" +#include "dwarf2loc.h" /* Basic byte-swapping routines. All 'extract' functions return a host-format integer from a target-format integer at ADDR which is -@@ -407,8 +408,11 @@ 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, throw error. */ -+ and return a (pointer to a) struct value containing the value. -+ If the variable cannot be found, throw error. +@@ -407,7 +408,10 @@ symbol_read_needs_frame (struct symbol *sym) + } + + /* A default implementation for the "la_read_var_value" hook in +- the language vector which should work in most situations. */ ++ the language vector which should work in most situations. + 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. */ struct value * - read_var_value (struct symbol *var, struct frame_info *frame) -@@ -416,16 +420,6 @@ read_var_value (struct symbol *var, struct frame_info *frame) + default_read_var_value (struct symbol *var, struct frame_info *frame) +@@ -415,16 +419,6 @@ default_read_var_value (struct symbol *var, struct frame_info *frame) struct value *v; struct type *type = SYMBOL_TYPE (var); CORE_ADDR addr; @@ -3452,7 +2288,7 @@ index 79c4221..1bb7c22 100644 if (symbol_read_needs_frame (var)) gdb_assert (frame); -@@ -435,7 +429,7 @@ read_var_value (struct symbol *var, struct frame_info *frame) +@@ -434,7 +428,7 @@ default_read_var_value (struct symbol *var, struct frame_info *frame) case LOC_CONST: /* Put the constant back in target format. */ v = allocate_value (type); @@ -3461,7 +2297,7 @@ index 79c4221..1bb7c22 100644 gdbarch_byte_order (get_type_arch (type)), (LONGEST) SYMBOL_VALUE (var)); VALUE_LVAL (v) = not_lval; -@@ -460,12 +454,12 @@ read_var_value (struct symbol *var, struct frame_info *frame) +@@ -459,12 +453,12 @@ default_read_var_value (struct symbol *var, struct frame_info *frame) case LOC_CONST_BYTES: v = allocate_value (type); @@ -3476,7 +2312,7 @@ index 79c4221..1bb7c22 100644 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, struct frame_info *frame) +@@ -478,7 +472,6 @@ default_read_var_value (struct symbol *var, struct frame_info *frame) error (_("Unknown argument list address for `%s'."), SYMBOL_PRINT_NAME (var)); addr += SYMBOL_VALUE (var); @@ -3484,7 +2320,7 @@ index 79c4221..1bb7c22 100644 break; case LOC_REF_ARG: -@@ -494,14 +487,12 @@ read_var_value (struct symbol *var, struct frame_info *frame) +@@ -493,14 +486,12 @@ default_read_var_value (struct symbol *var, struct frame_info *frame) argref += SYMBOL_VALUE (var); ref = value_at (lookup_pointer_type (type), argref); addr = value_as_address (ref); @@ -3499,7 +2335,7 @@ index 79c4221..1bb7c22 100644 break; case LOC_TYPEDEF: -@@ -510,7 +501,6 @@ read_var_value (struct symbol *var, struct frame_info *frame) +@@ -509,7 +500,6 @@ default_read_var_value (struct symbol *var, struct frame_info *frame) break; case LOC_BLOCK: @@ -3507,7 +2343,7 @@ index 79c4221..1bb7c22 100644 if (overlay_debugging) addr = symbol_overlayed_address (BLOCK_START (SYMBOL_BLOCK_VALUE (var)), SYMBOL_OBJ_SECTION (var)); -@@ -536,7 +526,6 @@ read_var_value (struct symbol *var, struct frame_info *frame) +@@ -535,7 +525,6 @@ default_read_var_value (struct symbol *var, struct frame_info *frame) SYMBOL_PRINT_NAME (var)); addr = value_as_address (regval); @@ -3515,7 +2351,7 @@ index 79c4221..1bb7c22 100644 } else { -@@ -576,7 +565,6 @@ read_var_value (struct symbol *var, struct frame_info *frame) +@@ -583,7 +572,6 @@ default_read_var_value (struct symbol *var, struct frame_info *frame) if (obj_section && (obj_section->the_bfd_section->flags & SEC_THREAD_LOCAL) != 0) addr = target_translate_tls_address (obj_section->objfile, addr); @@ -3523,7 +2359,7 @@ index 79c4221..1bb7c22 100644 } break; -@@ -589,6 +577,10 @@ read_var_value (struct symbol *var, struct frame_info *frame) +@@ -596,6 +584,10 @@ default_read_var_value (struct symbol *var, struct frame_info *frame) break; } @@ -3534,7 +2370,7 @@ index 79c4221..1bb7c22 100644 VALUE_LVAL (v) = lval_memory; set_value_address (v, addr); return v; -@@ -671,10 +663,11 @@ struct value * +@@ -691,10 +683,11 @@ struct value * value_from_register (struct type *type, int regnum, struct frame_info *frame) { struct gdbarch *gdbarch = get_frame_arch (frame); @@ -3548,7 +2384,7 @@ index 79c4221..1bb7c22 100644 { int optim, unavail, ok; -@@ -689,7 +682,7 @@ value_from_register (struct type *type, int regnum, struct frame_info *frame) +@@ -709,7 +702,7 @@ value_from_register (struct type *type, int regnum, struct frame_info *frame) VALUE_LVAL (v) = lval_register; VALUE_FRAME_ID (v) = get_frame_id (frame); VALUE_REGNUM (v) = regnum; @@ -3557,553 +2393,12 @@ index 79c4221..1bb7c22 100644 value_contents_raw (v), &optim, &unavail); -diff --git a/gdb/gdbarch.c b/gdb/gdbarch.c -index 1bd2341..431ddcc 100644 ---- a/gdb/gdbarch.c -+++ b/gdb/gdbarch.c -@@ -265,6 +265,16 @@ struct gdbarch - gdbarch_get_siginfo_type_ftype *get_siginfo_type; - gdbarch_record_special_symbol_ftype *record_special_symbol; - gdbarch_get_syscall_number_ftype *get_syscall_number; -+ const char * stap_integer_prefix; -+ const char * stap_integer_sufix; -+ const char * stap_register_prefix; -+ const char * stap_register_sufix; -+ const char * stap_register_indirection_prefix; -+ const char * stap_register_indirection_sufix; -+ const char * stap_gdb_register_prefix; -+ const char * stap_gdb_register_sufix; -+ gdbarch_stap_is_single_operand_ftype *stap_is_single_operand; -+ gdbarch_stap_parse_special_token_ftype *stap_parse_special_token; - int has_global_solist; - int has_global_breakpoints; - gdbarch_has_shared_address_space_ftype *has_shared_address_space; -@@ -423,6 +433,16 @@ struct gdbarch startup_gdbarch = - 0, /* get_siginfo_type */ - 0, /* record_special_symbol */ - 0, /* get_syscall_number */ -+ 0, /* stap_integer_prefix */ -+ 0, /* stap_integer_sufix */ -+ 0, /* stap_register_prefix */ -+ 0, /* stap_register_sufix */ -+ 0, /* stap_register_indirection_prefix */ -+ 0, /* stap_register_indirection_sufix */ -+ 0, /* stap_gdb_register_prefix */ -+ 0, /* stap_gdb_register_sufix */ -+ 0, /* stap_is_single_operand */ -+ 0, /* stap_parse_special_token */ - 0, /* has_global_solist */ - 0, /* has_global_breakpoints */ - default_has_shared_address_space, /* has_shared_address_space */ -@@ -715,6 +735,16 @@ verify_gdbarch (struct gdbarch *gdbarch) - /* Skip verify of get_siginfo_type, has predicate. */ - /* Skip verify of record_special_symbol, has predicate. */ - /* Skip verify of get_syscall_number, has predicate. */ -+ /* Skip verify of stap_integer_prefix, invalid_p == 0 */ -+ /* Skip verify of stap_integer_sufix, invalid_p == 0 */ -+ /* Skip verify of stap_register_prefix, invalid_p == 0 */ -+ /* Skip verify of stap_register_sufix, invalid_p == 0 */ -+ /* Skip verify of stap_register_indirection_prefix, invalid_p == 0 */ -+ /* Skip verify of stap_register_indirection_sufix, invalid_p == 0 */ -+ /* Skip verify of stap_gdb_register_prefix, invalid_p == 0 */ -+ /* Skip verify of stap_gdb_register_sufix, invalid_p == 0 */ -+ /* Skip verify of stap_is_single_operand, has predicate. */ -+ /* Skip verify of stap_parse_special_token, has predicate. */ - /* Skip verify of has_global_solist, invalid_p == 0 */ - /* Skip verify of has_global_breakpoints, invalid_p == 0 */ - /* Skip verify of has_shared_address_space, invalid_p == 0 */ -@@ -1267,6 +1297,42 @@ gdbarch_dump (struct gdbarch *gdbarch, struct ui_file *file) - "gdbarch_dump: stabs_argument_has_addr = <%s>\n", - host_address_to_string (gdbarch->stabs_argument_has_addr)); - fprintf_unfiltered (file, -+ "gdbarch_dump: stap_gdb_register_prefix = %s\n", -+ gdbarch->stap_gdb_register_prefix); -+ fprintf_unfiltered (file, -+ "gdbarch_dump: stap_gdb_register_sufix = %s\n", -+ gdbarch->stap_gdb_register_sufix); -+ fprintf_unfiltered (file, -+ "gdbarch_dump: stap_integer_prefix = %s\n", -+ gdbarch->stap_integer_prefix); -+ fprintf_unfiltered (file, -+ "gdbarch_dump: stap_integer_sufix = %s\n", -+ gdbarch->stap_integer_sufix); -+ fprintf_unfiltered (file, -+ "gdbarch_dump: gdbarch_stap_is_single_operand_p() = %d\n", -+ gdbarch_stap_is_single_operand_p (gdbarch)); -+ fprintf_unfiltered (file, -+ "gdbarch_dump: stap_is_single_operand = <%s>\n", -+ host_address_to_string (gdbarch->stap_is_single_operand)); -+ fprintf_unfiltered (file, -+ "gdbarch_dump: gdbarch_stap_parse_special_token_p() = %d\n", -+ gdbarch_stap_parse_special_token_p (gdbarch)); -+ fprintf_unfiltered (file, -+ "gdbarch_dump: stap_parse_special_token = <%s>\n", -+ host_address_to_string (gdbarch->stap_parse_special_token)); -+ fprintf_unfiltered (file, -+ "gdbarch_dump: stap_register_indirection_prefix = %s\n", -+ gdbarch->stap_register_indirection_prefix); -+ fprintf_unfiltered (file, -+ "gdbarch_dump: stap_register_indirection_sufix = %s\n", -+ gdbarch->stap_register_indirection_sufix); -+ fprintf_unfiltered (file, -+ "gdbarch_dump: stap_register_prefix = %s\n", -+ gdbarch->stap_register_prefix); -+ fprintf_unfiltered (file, -+ "gdbarch_dump: stap_register_sufix = %s\n", -+ gdbarch->stap_register_sufix); -+ fprintf_unfiltered (file, - "gdbarch_dump: gdbarch_static_transform_name_p() = %d\n", - gdbarch_static_transform_name_p (gdbarch)); - fprintf_unfiltered (file, -@@ -3834,6 +3900,190 @@ set_gdbarch_get_syscall_number (struct gdbarch *gdbarch, - gdbarch->get_syscall_number = get_syscall_number; - } - -+const char * -+gdbarch_stap_integer_prefix (struct gdbarch *gdbarch) -+{ -+ gdb_assert (gdbarch != NULL); -+ /* Skip verify of stap_integer_prefix, invalid_p == 0 */ -+ if (gdbarch_debug >= 2) -+ fprintf_unfiltered (gdb_stdlog, "gdbarch_stap_integer_prefix called\n"); -+ return gdbarch->stap_integer_prefix; -+} -+ -+void -+set_gdbarch_stap_integer_prefix (struct gdbarch *gdbarch, -+ const char * stap_integer_prefix) -+{ -+ gdbarch->stap_integer_prefix = stap_integer_prefix; -+} -+ -+const char * -+gdbarch_stap_integer_sufix (struct gdbarch *gdbarch) -+{ -+ gdb_assert (gdbarch != NULL); -+ /* Skip verify of stap_integer_sufix, invalid_p == 0 */ -+ if (gdbarch_debug >= 2) -+ fprintf_unfiltered (gdb_stdlog, "gdbarch_stap_integer_sufix called\n"); -+ return gdbarch->stap_integer_sufix; -+} -+ -+void -+set_gdbarch_stap_integer_sufix (struct gdbarch *gdbarch, -+ const char * stap_integer_sufix) -+{ -+ gdbarch->stap_integer_sufix = stap_integer_sufix; -+} -+ -+const char * -+gdbarch_stap_register_prefix (struct gdbarch *gdbarch) -+{ -+ gdb_assert (gdbarch != NULL); -+ /* Skip verify of stap_register_prefix, invalid_p == 0 */ -+ if (gdbarch_debug >= 2) -+ fprintf_unfiltered (gdb_stdlog, "gdbarch_stap_register_prefix called\n"); -+ return gdbarch->stap_register_prefix; -+} -+ -+void -+set_gdbarch_stap_register_prefix (struct gdbarch *gdbarch, -+ const char * stap_register_prefix) -+{ -+ gdbarch->stap_register_prefix = stap_register_prefix; -+} -+ -+const char * -+gdbarch_stap_register_sufix (struct gdbarch *gdbarch) -+{ -+ gdb_assert (gdbarch != NULL); -+ /* Skip verify of stap_register_sufix, invalid_p == 0 */ -+ if (gdbarch_debug >= 2) -+ fprintf_unfiltered (gdb_stdlog, "gdbarch_stap_register_sufix called\n"); -+ return gdbarch->stap_register_sufix; -+} -+ -+void -+set_gdbarch_stap_register_sufix (struct gdbarch *gdbarch, -+ const char * stap_register_sufix) -+{ -+ gdbarch->stap_register_sufix = stap_register_sufix; -+} -+ -+const char * -+gdbarch_stap_register_indirection_prefix (struct gdbarch *gdbarch) -+{ -+ gdb_assert (gdbarch != NULL); -+ /* Skip verify of stap_register_indirection_prefix, invalid_p == 0 */ -+ if (gdbarch_debug >= 2) -+ fprintf_unfiltered (gdb_stdlog, "gdbarch_stap_register_indirection_prefix called\n"); -+ return gdbarch->stap_register_indirection_prefix; -+} -+ -+void -+set_gdbarch_stap_register_indirection_prefix (struct gdbarch *gdbarch, -+ const char * stap_register_indirection_prefix) -+{ -+ gdbarch->stap_register_indirection_prefix = stap_register_indirection_prefix; -+} -+ -+const char * -+gdbarch_stap_register_indirection_sufix (struct gdbarch *gdbarch) -+{ -+ gdb_assert (gdbarch != NULL); -+ /* Skip verify of stap_register_indirection_sufix, invalid_p == 0 */ -+ if (gdbarch_debug >= 2) -+ fprintf_unfiltered (gdb_stdlog, "gdbarch_stap_register_indirection_sufix called\n"); -+ return gdbarch->stap_register_indirection_sufix; -+} -+ -+void -+set_gdbarch_stap_register_indirection_sufix (struct gdbarch *gdbarch, -+ const char * stap_register_indirection_sufix) -+{ -+ gdbarch->stap_register_indirection_sufix = stap_register_indirection_sufix; -+} -+ -+const char * -+gdbarch_stap_gdb_register_prefix (struct gdbarch *gdbarch) -+{ -+ gdb_assert (gdbarch != NULL); -+ /* Skip verify of stap_gdb_register_prefix, invalid_p == 0 */ -+ if (gdbarch_debug >= 2) -+ fprintf_unfiltered (gdb_stdlog, "gdbarch_stap_gdb_register_prefix called\n"); -+ return gdbarch->stap_gdb_register_prefix; -+} -+ -+void -+set_gdbarch_stap_gdb_register_prefix (struct gdbarch *gdbarch, -+ const char * stap_gdb_register_prefix) -+{ -+ gdbarch->stap_gdb_register_prefix = stap_gdb_register_prefix; -+} -+ -+const char * -+gdbarch_stap_gdb_register_sufix (struct gdbarch *gdbarch) -+{ -+ gdb_assert (gdbarch != NULL); -+ /* Skip verify of stap_gdb_register_sufix, invalid_p == 0 */ -+ if (gdbarch_debug >= 2) -+ fprintf_unfiltered (gdb_stdlog, "gdbarch_stap_gdb_register_sufix called\n"); -+ return gdbarch->stap_gdb_register_sufix; -+} -+ -+void -+set_gdbarch_stap_gdb_register_sufix (struct gdbarch *gdbarch, -+ const char * stap_gdb_register_sufix) -+{ -+ gdbarch->stap_gdb_register_sufix = stap_gdb_register_sufix; -+} -+ -+int -+gdbarch_stap_is_single_operand_p (struct gdbarch *gdbarch) -+{ -+ gdb_assert (gdbarch != NULL); -+ return gdbarch->stap_is_single_operand != NULL; -+} -+ -+int -+gdbarch_stap_is_single_operand (struct gdbarch *gdbarch, const char *s) -+{ -+ gdb_assert (gdbarch != NULL); -+ gdb_assert (gdbarch->stap_is_single_operand != NULL); -+ if (gdbarch_debug >= 2) -+ fprintf_unfiltered (gdb_stdlog, "gdbarch_stap_is_single_operand called\n"); -+ return gdbarch->stap_is_single_operand (gdbarch, s); -+} -+ -+void -+set_gdbarch_stap_is_single_operand (struct gdbarch *gdbarch, -+ gdbarch_stap_is_single_operand_ftype stap_is_single_operand) -+{ -+ gdbarch->stap_is_single_operand = stap_is_single_operand; -+} -+ -+int -+gdbarch_stap_parse_special_token_p (struct gdbarch *gdbarch) -+{ -+ gdb_assert (gdbarch != NULL); -+ return gdbarch->stap_parse_special_token != NULL; -+} -+ -+int -+gdbarch_stap_parse_special_token (struct gdbarch *gdbarch, struct stap_parse_info *p) -+{ -+ gdb_assert (gdbarch != NULL); -+ gdb_assert (gdbarch->stap_parse_special_token != NULL); -+ if (gdbarch_debug >= 2) -+ fprintf_unfiltered (gdb_stdlog, "gdbarch_stap_parse_special_token called\n"); -+ return gdbarch->stap_parse_special_token (gdbarch, p); -+} -+ -+void -+set_gdbarch_stap_parse_special_token (struct gdbarch *gdbarch, -+ gdbarch_stap_parse_special_token_ftype stap_parse_special_token) -+{ -+ gdbarch->stap_parse_special_token = stap_parse_special_token; -+} -+ - int - gdbarch_has_global_solist (struct gdbarch *gdbarch) - { -diff --git a/gdb/gdbarch.h b/gdb/gdbarch.h -index 044281c..294a63f 100644 ---- a/gdb/gdbarch.h -+++ b/gdb/gdbarch.h -@@ -55,6 +55,7 @@ struct core_regset_section; - struct syscall; - struct agent_expr; - struct axs_value; -+struct stap_parse_info; - - /* The architecture associated with the connection to the target. - -@@ -979,6 +980,125 @@ typedef LONGEST (gdbarch_get_syscall_number_ftype) (struct gdbarch *gdbarch, pti - extern LONGEST gdbarch_get_syscall_number (struct gdbarch *gdbarch, ptid_t ptid); - extern void set_gdbarch_get_syscall_number (struct gdbarch *gdbarch, gdbarch_get_syscall_number_ftype *get_syscall_number); - -+/* SystemTap related fields and functions. -+ Prefix used to mark an integer constant on the architecture's assembly -+ For example, on x86 integer constants are written as: -+ -+ $10 ;; integer constant 10 -+ -+ in this case, this prefix would be the character `$'. */ -+ -+extern const char * gdbarch_stap_integer_prefix (struct gdbarch *gdbarch); -+extern void set_gdbarch_stap_integer_prefix (struct gdbarch *gdbarch, const char * stap_integer_prefix); -+ -+/* Sufix used to mark an integer constant on the architecture's assembly. */ -+ -+extern const char * gdbarch_stap_integer_sufix (struct gdbarch *gdbarch); -+extern void set_gdbarch_stap_integer_sufix (struct gdbarch *gdbarch, const char * stap_integer_sufix); -+ -+/* Prefix used to mark a register name on the architecture's assembly. -+ For example, on x86 the register name is written as: -+ -+ %eax ;; register eax -+ -+ in this case, this prefix would be the character `%'. */ -+ -+extern const char * gdbarch_stap_register_prefix (struct gdbarch *gdbarch); -+extern void set_gdbarch_stap_register_prefix (struct gdbarch *gdbarch, const char * stap_register_prefix); -+ -+/* Sufix used to mark a register name on the architecture's assembly */ -+ -+extern const char * gdbarch_stap_register_sufix (struct gdbarch *gdbarch); -+extern void set_gdbarch_stap_register_sufix (struct gdbarch *gdbarch, const char * stap_register_sufix); -+ -+/* Prefix used to mark a register indirection on the architecture's assembly. -+ For example, on x86 the register indirection is written as: -+ -+ (%eax) ;; indirecting eax -+ -+ in this case, this prefix would be the charater `('. -+ -+ Please note that we use the indirection prefix also for register -+ displacement, e.g., `4(%eax)' on x86. */ -+ -+extern const char * gdbarch_stap_register_indirection_prefix (struct gdbarch *gdbarch); -+extern void set_gdbarch_stap_register_indirection_prefix (struct gdbarch *gdbarch, const char * stap_register_indirection_prefix); -+ -+/* Sufix used to mark a register indirection on the architecture's assembly. -+ For example, on x86 the register indirection is written as: -+ -+ (%eax) ;; indirecting eax -+ -+ in this case, this prefix would be the charater `)'. -+ -+ Please note that we use the indirection sufix also for register -+ displacement, e.g., `4(%eax)' on x86. */ -+ -+extern const char * gdbarch_stap_register_indirection_sufix (struct gdbarch *gdbarch); -+extern void set_gdbarch_stap_register_indirection_sufix (struct gdbarch *gdbarch, const char * stap_register_indirection_sufix); -+ -+/* Prefix used to name a register using GDB's nomenclature. -+ -+ For example, on PPC a register is represented by a number in the assembly -+ language (e.g., `10' is the 10th general-purpose register). However, -+ inside GDB this same register has an `r' appended to its name, so the 10th -+ register would be represented as `r10' internally. */ -+ -+extern const char * gdbarch_stap_gdb_register_prefix (struct gdbarch *gdbarch); -+extern void set_gdbarch_stap_gdb_register_prefix (struct gdbarch *gdbarch, const char * stap_gdb_register_prefix); -+ -+/* Sufix used to name a register using GDB's nomenclature. */ -+ -+extern const char * gdbarch_stap_gdb_register_sufix (struct gdbarch *gdbarch); -+extern void set_gdbarch_stap_gdb_register_sufix (struct gdbarch *gdbarch, const char * stap_gdb_register_sufix); -+ -+/* Check if S is a single operand. -+ -+ Single operands can be: -+ - Literal integers, e.g. `$10' on x86 -+ - Register access, e.g. `%eax' on x86 -+ - Register indirection, e.g. `(%eax)' on x86 -+ - Register displacement, e.g. `4(%eax)' on x86 -+ -+ This function should check for these patterns on the string -+ and return 1 if some were found, or zero otherwise. Please try to match -+ as much info as you can from the string, i.e., if you have to match -+ something like `(%', do not match just the `('. */ -+ -+extern int gdbarch_stap_is_single_operand_p (struct gdbarch *gdbarch); -+ -+typedef int (gdbarch_stap_is_single_operand_ftype) (struct gdbarch *gdbarch, const char *s); -+extern int gdbarch_stap_is_single_operand (struct gdbarch *gdbarch, const char *s); -+extern void set_gdbarch_stap_is_single_operand (struct gdbarch *gdbarch, gdbarch_stap_is_single_operand_ftype *stap_is_single_operand); -+ -+/* Function used to handle a "special case" in the parser. -+ -+ A "special case" is considered to be an unknown token, i.e., a token -+ that the parser does not know how to parse. A good example of special -+ case would be ARM's register displacement syntax: -+ -+ [R0, #4] ;; displacing R0 by 4 -+ -+ Since the parser assumes that a register displacement is of the form: -+ -+ -+ -+ it means that it will not be able to recognize and parse this odd syntax. -+ Therefore, we should add a special case function that will handle this token. -+ -+ This function should generate the proper expression form of the expression -+ using GDB's internal expression mechanism (e.g., `write_exp_elt_opcode' -+ and so on). It should also return 1 if the parsing was successful, or zero -+ if the token was not recognized as a special token (in this case, returning -+ zero means that the special parser is deferring the parsing to the generic -+ parser), and should advance the buffer pointer (p->arg). */ -+ -+extern int gdbarch_stap_parse_special_token_p (struct gdbarch *gdbarch); -+ -+typedef int (gdbarch_stap_parse_special_token_ftype) (struct gdbarch *gdbarch, struct stap_parse_info *p); -+extern int gdbarch_stap_parse_special_token (struct gdbarch *gdbarch, struct stap_parse_info *p); -+extern void set_gdbarch_stap_parse_special_token (struct gdbarch *gdbarch, gdbarch_stap_parse_special_token_ftype *stap_parse_special_token); -+ - /* True if the list of shared libraries is one and only for all - processes, as opposed to a list of shared libraries per inferior. - This usually means that all processes, although may or may not share -diff --git a/gdb/gdbarch.sh b/gdb/gdbarch.sh -index 37281ba..879fab7 100755 ---- a/gdb/gdbarch.sh -+++ b/gdb/gdbarch.sh -@@ -792,6 +792,101 @@ M:void:record_special_symbol:struct objfile *objfile, asymbol *sym:objfile, sym - # Get architecture-specific system calls information from registers. - M:LONGEST:get_syscall_number:ptid_t ptid:ptid - -+# SystemTap related fields and functions. -+ -+# Prefix used to mark an integer constant on the architecture's assembly -+# For example, on x86 integer constants are written as: -+# -+# \$10 ;; integer constant 10 -+# -+# in this case, this prefix would be the character \`\$\'. -+v:const char *:stap_integer_prefix:::0:0::0:gdbarch->stap_integer_prefix -+ -+# Sufix used to mark an integer constant on the architecture's assembly. -+v:const char *:stap_integer_sufix:::0:0::0:gdbarch->stap_integer_sufix -+ -+# Prefix used to mark a register name on the architecture's assembly. -+# For example, on x86 the register name is written as: -+# -+# \%eax ;; register eax -+# -+# in this case, this prefix would be the character \`\%\'. -+v:const char *:stap_register_prefix:::0:0::0:gdbarch->stap_register_prefix -+ -+# Sufix used to mark a register name on the architecture's assembly -+v:const char *:stap_register_sufix:::0:0::0:gdbarch->stap_register_sufix -+ -+# Prefix used to mark a register indirection on the architecture's assembly. -+# For example, on x86 the register indirection is written as: -+# -+# \(\%eax\) ;; indirecting eax -+# -+# in this case, this prefix would be the charater \`\(\'. -+# -+# Please note that we use the indirection prefix also for register -+# displacement, e.g., \`4\(\%eax\)\' on x86. -+v:const char *:stap_register_indirection_prefix:::0:0::0:gdbarch->stap_register_indirection_prefix -+ -+# Sufix used to mark a register indirection on the architecture's assembly. -+# For example, on x86 the register indirection is written as: -+# -+# \(\%eax\) ;; indirecting eax -+# -+# in this case, this prefix would be the charater \`\)\'. -+# -+# Please note that we use the indirection sufix also for register -+# displacement, e.g., \`4\(\%eax\)\' on x86. -+v:const char *:stap_register_indirection_sufix:::0:0::0:gdbarch->stap_register_indirection_sufix -+ -+# Prefix used to name a register using GDB's nomenclature. -+# -+# For example, on PPC a register is represented by a number in the assembly -+# language (e.g., \`10\' is the 10th general-purpose register). However, -+# inside GDB this same register has an \`r\' appended to its name, so the 10th -+# register would be represented as \`r10\' internally. -+v:const char *:stap_gdb_register_prefix:::0:0::0:gdbarch->stap_gdb_register_prefix -+ -+# Sufix used to name a register using GDB's nomenclature. -+v:const char *:stap_gdb_register_sufix:::0:0::0:gdbarch->stap_gdb_register_sufix -+ -+# Check if S is a single operand. -+# -+# Single operands can be: -+# \- Literal integers, e.g. \`\$10\' on x86 -+# \- Register access, e.g. \`\%eax\' on x86 -+# \- Register indirection, e.g. \`\(\%eax\)\' on x86 -+# \- Register displacement, e.g. \`4\(\%eax\)\' on x86 -+# -+# This function should check for these patterns on the string -+# and return 1 if some were found, or zero otherwise. Please try to match -+# as much info as you can from the string, i.e., if you have to match -+# something like \`\(\%\', do not match just the \`\(\'. -+M:int:stap_is_single_operand:const char *s:s -+ -+# Function used to handle a "special case" in the parser. -+# -+# A "special case" is considered to be an unknown token, i.e., a token -+# that the parser does not know how to parse. A good example of special -+# case would be ARM's register displacement syntax: -+# -+# [R0, #4] ;; displacing R0 by 4 -+# -+# Since the parser assumes that a register displacement is of the form: -+# -+# -+# -+# it means that it will not be able to recognize and parse this odd syntax. -+# Therefore, we should add a special case function that will handle this token. -+# -+# This function should generate the proper expression form of the expression -+# using GDB\'s internal expression mechanism (e.g., \`write_exp_elt_opcode\' -+# and so on). It should also return 1 if the parsing was successful, or zero -+# if the token was not recognized as a special token (in this case, returning -+# zero means that the special parser is deferring the parsing to the generic -+# parser), and should advance the buffer pointer (p->arg). -+M:int:stap_parse_special_token:struct stap_parse_info *p:p -+ -+ - # True if the list of shared libraries is one and only for all - # processes, as opposed to a list of shared libraries per inferior. - # This usually means that all processes, although may or may not share -@@ -954,6 +1049,7 @@ struct core_regset_section; - struct syscall; - struct agent_expr; - struct axs_value; -+struct stap_parse_info; - - /* The architecture associated with the connection to the target. - -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 +diff --git a/gdb/gdb-gdb.gdb.in b/gdb/gdb-gdb.gdb.in +index ffb7f53..a2e7e94 100644 +--- a/gdb/gdb-gdb.gdb.in ++++ b/gdb/gdb-gdb.gdb.in +@@ -1,5 +1,15 @@ + echo Setting up the environment for debugging gdb.\n +# Set up the Python library and "require" command. +python @@ -4119,7 +2414,7 @@ index ffb7f53..a2e7e94 100644 b internal_error diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c -index b09c1ec..8e0256c 100644 +index e3db1ed..9a346e6 100644 --- a/gdb/gdbtypes.c +++ b/gdb/gdbtypes.c @@ -37,6 +37,9 @@ @@ -4264,7 +2559,7 @@ index b09c1ec..8e0256c 100644 return result_type; } -@@ -1438,6 +1493,105 @@ stub_noname_complaint (void) +@@ -1431,6 +1486,105 @@ stub_noname_complaint (void) complaint (&symfile_complaints, _("stub type has NULL name")); } @@ -4370,7 +2665,7 @@ index b09c1ec..8e0256c 100644 /* 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 -@@ -1604,52 +1758,37 @@ check_typedef (struct type *type) +@@ -1597,52 +1751,37 @@ check_typedef (struct type *type) } } @@ -4444,7 +2739,7 @@ index b09c1ec..8e0256c 100644 TYPE_TARGET_STUB (type) = 0; } else if (TYPE_CODE (type) == TYPE_CODE_RANGE) -@@ -1657,6 +1796,7 @@ check_typedef (struct type *type) +@@ -1650,6 +1789,7 @@ check_typedef (struct type *type) TYPE_LENGTH (type) = TYPE_LENGTH (target_type); TYPE_TARGET_STUB (type) = 0; } @@ -4452,7 +2747,7 @@ index b09c1ec..8e0256c 100644 } type = make_qualified_type (type, instance_flags, NULL); -@@ -3310,33 +3450,42 @@ type_pair_eq (const void *item_lhs, const void *item_rhs) +@@ -3308,33 +3448,42 @@ type_pair_eq (const void *item_lhs, const void *item_rhs) } /* Allocate the hash table used by copy_type_recursive to walk @@ -4510,7 +2805,7 @@ index b09c1ec..8e0256c 100644 return type; /* This type shouldn't be pointing to any types in other objfiles; -@@ -3351,9 +3500,10 @@ copy_type_recursive (struct objfile *objfile, +@@ -3349,9 +3498,10 @@ copy_type_recursive (struct objfile *objfile, new_type = alloc_type_arch (get_type_arch (type)); /* We must add the new type to the hash table immediately, in case @@ -4524,7 +2819,7 @@ index b09c1ec..8e0256c 100644 stored->old = type; stored->new = new_type; *slot = stored; -@@ -3364,6 +3514,21 @@ copy_type_recursive (struct objfile *objfile, +@@ -3362,6 +3512,21 @@ copy_type_recursive (struct objfile *objfile, TYPE_OBJFILE_OWNED (new_type) = 0; TYPE_OWNER (new_type).gdbarch = get_type_arch (type); @@ -4546,7 +2841,7 @@ index b09c1ec..8e0256c 100644 if (TYPE_NAME (type)) TYPE_NAME (new_type) = xstrdup (TYPE_NAME (type)); if (TYPE_TAG_NAME (type)) -@@ -3372,12 +3537,48 @@ copy_type_recursive (struct objfile *objfile, +@@ -3370,12 +3535,48 @@ copy_type_recursive (struct objfile *objfile, TYPE_INSTANCE_FLAGS (new_type) = TYPE_INSTANCE_FLAGS (type); TYPE_LENGTH (new_type) = TYPE_LENGTH (type); @@ -4595,7 +2890,7 @@ index b09c1ec..8e0256c 100644 TYPE_FIELDS (new_type) = XCALLOC (nfields, struct field); for (i = 0; i < nfields; i++) { -@@ -3386,8 +3587,8 @@ copy_type_recursive (struct objfile *objfile, +@@ -3384,8 +3585,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) @@ -4606,7 +2901,7 @@ index b09c1ec..8e0256c 100644 if (TYPE_FIELD_NAME (type, i)) TYPE_FIELD_NAME (new_type, i) = xstrdup (TYPE_FIELD_NAME (type, i)); -@@ -3414,24 +3615,184 @@ copy_type_recursive (struct objfile *objfile, +@@ -3416,24 +3617,184 @@ copy_type_recursive (struct objfile *objfile, } } @@ -4798,7 +3093,7 @@ index b09c1ec..8e0256c 100644 /* Maybe copy the type_specific bits. NOTE drow/2005-12-09: We do not copy the C++-specific bits like -@@ -3448,6 +3809,17 @@ copy_type_recursive (struct objfile *objfile, +@@ -3450,6 +3811,17 @@ copy_type_recursive (struct objfile *objfile, return new_type; } @@ -4816,7 +3111,7 @@ index b09c1ec..8e0256c 100644 /* Make a copy of the given TYPE, except that the pointer & reference types are not preserved. -@@ -3470,6 +3842,201 @@ copy_type (const struct type *type) +@@ -3472,6 +3844,201 @@ copy_type (const struct type *type) return new_type; } @@ -5018,7 +3313,7 @@ index b09c1ec..8e0256c 100644 /* Helper functions to initialize architecture-specific types. */ -@@ -4002,6 +4569,13 @@ void +@@ -4005,6 +4572,13 @@ void _initialize_gdbtypes (void) { gdbtypes_data = gdbarch_data_register_post_init (gdbtypes_post_init); @@ -5033,7 +3328,7 @@ index b09c1ec..8e0256c 100644 add_setshow_zinteger_cmd ("overload", no_class, &overload_debug, diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h -index 2070f00..40db606 100644 +index 887dfdb..6e972d1 100644 --- a/gdb/gdbtypes.h +++ b/gdb/gdbtypes.h @@ -213,6 +213,11 @@ enum type_instance_flag_value @@ -5099,7 +3394,7 @@ index 2070f00..40db606 100644 /* Constant type. If this is set, the corresponding type has a const modifier. */ -@@ -405,6 +454,15 @@ struct main_type +@@ -406,6 +455,15 @@ struct main_type /* True if this type was declared with "class" rather than "struct". */ unsigned int flag_declared_class : 1; @@ -5115,7 +3410,7 @@ index 2070f00..40db606 100644 /* True if this is an enum type with disjoint values. This affects how the enum is printed. */ -@@ -483,6 +541,20 @@ struct main_type +@@ -486,6 +544,20 @@ struct main_type struct type *target_type; @@ -5136,7 +3431,7 @@ index 2070f00..40db606 100644 /* For structure and union types, a description of each field. For set and pascal array types, there is one "field", whose type is the domain type of the set or array. -@@ -563,13 +635,34 @@ struct main_type +@@ -568,13 +640,34 @@ struct main_type struct range_bounds { @@ -5224,7 +3519,7 @@ index 2070f00..40db606 100644 /* C++ */ -@@ -1482,6 +1587,18 @@ extern struct type *create_array_type (struct type *, struct type *, +@@ -1489,6 +1594,18 @@ extern struct type *create_array_type (struct type *, struct type *, struct type *); extern struct type *lookup_array_range_type (struct type *, int, int); @@ -5243,7 +3538,7 @@ index 2070f00..40db606 100644 extern struct type *create_string_type (struct type *, struct type *, struct type *); extern struct type *lookup_string_range_type (struct type *, int, int); -@@ -1527,6 +1644,10 @@ extern int is_public_ancestor (struct type *, struct type *); +@@ -1534,6 +1651,10 @@ extern int is_public_ancestor (struct type *, struct type *); extern int is_unique_ancestor (struct type *, struct value *); @@ -5254,7 +3549,7 @@ index 2070f00..40db606 100644 /* Overload resolution */ #define LENGTH_MATCH(bv) ((bv)->rank[0]) -@@ -1602,10 +1723,13 @@ extern void maintenance_print_type (char *, int); +@@ -1609,10 +1730,13 @@ extern void maintenance_print_type (char *, int); extern htab_t create_copied_types_hash (struct objfile *objfile); @@ -5270,2104 +3565,783 @@ index 2070f00..40db606 100644 +#endif + #endif /* GDBTYPES_H */ -diff --git a/gdb/i386-linux-nat.c b/gdb/i386-linux-nat.c -index 4b1b20f..38e7027 100644 ---- a/gdb/i386-linux-nat.c -+++ b/gdb/i386-linux-nat.c -@@ -708,8 +708,8 @@ i386_linux_dr_get_status (void) - return i386_linux_dr_get (inferior_ptid, DR_STATUS); - } - --/* Callback for iterate_over_lwps. Update the debug registers of -- LWP. */ -+/* Callback for linux_nat_iterate_watchpoint_lwps. Update the debug registers -+ of LWP. */ - - static int - update_debug_registers_callback (struct lwp_info *lwp, void *arg) -@@ -735,9 +735,7 @@ update_debug_registers_callback (struct lwp_info *lwp, void *arg) - static void - i386_linux_dr_set_control (unsigned long control) - { -- ptid_t pid_ptid = pid_to_ptid (ptid_get_pid (inferior_ptid)); -- -- iterate_over_lwps (pid_ptid, update_debug_registers_callback, NULL); -+ linux_nat_iterate_watchpoint_lwps (update_debug_registers_callback, NULL); - } - - /* Set address REGNUM (zero based) to ADDR in all LWPs of the current -@@ -750,7 +748,7 @@ i386_linux_dr_set_addr (int regnum, CORE_ADDR addr) - - gdb_assert (regnum >= 0 && regnum <= DR_LASTADDR - DR_FIRSTADDR); - -- iterate_over_lwps (pid_ptid, update_debug_registers_callback, NULL); -+ linux_nat_iterate_watchpoint_lwps (update_debug_registers_callback, NULL); - } +diff --git a/gdb/main.c b/gdb/main.c +index 3148d72..c5b4826 100644 +--- a/gdb/main.c ++++ b/gdb/main.c +@@ -37,6 +37,7 @@ - /* Called when resuming a thread. -@@ -772,6 +770,9 @@ i386_linux_prepare_to_resume (struct lwp_info *lwp) - struct i386_debug_reg_state *state = i386_debug_reg_state (); - int i; + #include "interps.h" + #include "main.h" ++#include "python/python.h" + #include "source.h" + #include "cli/cli-cmds.h" + #include "python/python.h" +@@ -283,6 +284,8 @@ captured_main (void *data) + char *cdarg = NULL; + char *ttyarg = NULL; -+ /* See amd64_linux_prepare_to_resume for Linux kernel note on -+ i386_linux_dr_set calls ordering. */ ++ int python_script = 0; + - for (i = DR_FIRSTADDR; i <= DR_LASTADDR; i++) - if (state->dr_ref_count[i] > 0) - { -diff --git a/gdb/i386-linux-tdep.c b/gdb/i386-linux-tdep.c -index eb114ef..f80e05a 100644 ---- a/gdb/i386-linux-tdep.c -+++ b/gdb/i386-linux-tdep.c -@@ -903,6 +903,15 @@ i386_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) - i386_linux_get_syscall_number); - - set_gdbarch_get_siginfo_type (gdbarch, linux_get_siginfo_type); -+ -+ /* SystemTap variables and functions. */ -+ set_gdbarch_stap_integer_prefix (gdbarch, "$"); -+ set_gdbarch_stap_register_prefix (gdbarch, "%"); -+ set_gdbarch_stap_register_indirection_prefix (gdbarch, "("); -+ set_gdbarch_stap_register_indirection_sufix (gdbarch, ")"); -+ set_gdbarch_stap_is_single_operand (gdbarch, i386_stap_is_single_operand); -+ set_gdbarch_stap_parse_special_token (gdbarch, -+ i386_stap_parse_special_token); - } + /* These are static so that we can take their address in an + initializer. */ + static int print_help; +@@ -473,10 +476,14 @@ captured_main (void *data) + {"return-child-result", no_argument, &return_child_result, 1}, + {"use-deprecated-index-sections", no_argument, + &use_deprecated_index_sections, 1}, ++#if HAVE_PYTHON ++ {"python", no_argument, 0, 'P'}, ++ {"P", no_argument, 0, 'P'}, ++#endif + {0, no_argument, 0, 0} + }; - /* Provide a prototype to silence -Wmissing-prototypes. */ -diff --git a/gdb/i386-nat.c b/gdb/i386-nat.c -index fa17823..846b2b8 100644 ---- a/gdb/i386-nat.c -+++ b/gdb/i386-nat.c -@@ -25,6 +25,7 @@ - #include "gdbcmd.h" - #include "target.h" - #include "gdb_assert.h" -+#include "inferior.h" +- while (1) ++ while (!python_script) + { + int option_index; - /* Support for hardware watchpoints and breakpoints using the i386 - debug registers. -@@ -170,14 +171,88 @@ i386_init_dregs (struct i386_debug_reg_state *state) - state->dr_status_mirror = 0; - } +@@ -494,6 +501,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; +@@ -701,7 +711,31 @@ captured_main (void *data) --/* The local mirror of the inferior's debug registers. Currently this -- is a global, but it should really be per-inferior. */ --static struct i386_debug_reg_state dr_mirror; -+/* Per-inferior data key. */ -+static const struct inferior_data *i386_inferior_data; -+ -+/* Per-inferior data. */ -+struct i386_inferior_data -+ { -+ /* Copy of i386 hardware debug registers for performance reasons. */ -+ struct i386_debug_reg_state state; -+ }; -+ -+/* Per-inferior hook for register_inferior_data_with_cleanup. */ -+ -+static void -+i386_inferior_data_cleanup (struct inferior *inf, void *arg) -+{ -+ struct i386_inferior_data *inf_data = arg; -+ -+ xfree (inf_data); -+} -+ -+/* Get data specific for INFERIOR_PTID LWP. Return special data area -+ for processes being detached. */ -+ -+static struct i386_inferior_data * -+i386_inferior_data_get (void) -+{ -+ 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); -+ } -+ -+ if (inf->pid != ptid_get_pid (inferior_ptid)) + /* 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) + { -+ /* INFERIOR_PTID is being detached from the inferior INF. -+ Provide local cache specific for the detached LWP. */ -+ -+ static struct i386_inferior_data detached_inf_data_local; -+ static int detached_inf_pid = -1; -+ -+ if (detached_inf_pid != ptid_get_pid (inferior_ptid)) ++ /* The first argument is a python script to evaluate, and ++ subsequent arguments are passed to the script for ++ processing there. */ ++ if (optind >= argc) + { -+ /* Reinitialize the local cache if INFERIOR_PTID is -+ different from the LWP last detached. -+ -+ Linux kernel before 2.6.33 commit -+ 72f674d203cd230426437cdcf7dd6f681dad8b0d -+ will inherit hardware debug registers from parent -+ on fork/vfork/clone. Newer Linux kernels create such tasks with -+ zeroed debug registers. -+ -+ GDB will remove all breakpoints (and watchpoints) from the forked -+ off process. We also need to reset the debug registers in that -+ process to be compatible with the older Linux kernels. -+ -+ Copy the debug registers mirrors into the new process so that all -+ breakpoints and watchpoints can be removed together. The debug -+ registers mirror will become zeroed in the end before detaching -+ the forked off process. */ -+ -+ detached_inf_pid = ptid_get_pid (inferior_ptid); -+ memcpy (&detached_inf_data_local, inf_data, -+ sizeof (detached_inf_data_local)); ++ fprintf_unfiltered (gdb_stderr, ++ _("%s: Python script file name required\n"), ++ argv[0]); ++ exit (1); + } + -+ return &detached_inf_data_local; ++ /* 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; + } -+ -+ return inf_data; -+} -+ -+/* Get debug registers state for INFERIOR_PTID, see -+ i386_inferior_data_get. */ ++ 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 +@@ -981,7 +1015,8 @@ captured_main (void *data) - struct i386_debug_reg_state * - i386_debug_reg_state (void) - { -- return &dr_mirror; -+ return &i386_inferior_data_get ()->state; - } - - /* Whether or not to print the mirrored debug registers. */ -@@ -230,7 +305,9 @@ static int i386_handle_nonaligned_watchpoint (struct i386_debug_reg_state *state - void - i386_cleanup_dregs (void) - { -- i386_init_dregs (&dr_mirror); -+ struct i386_debug_reg_state *state = i386_debug_reg_state (); -+ -+ i386_init_dregs (state); - } - - /* Print the values of the mirrored debug registers. This is called -@@ -494,20 +571,21 @@ Invalid value %d of operation in i386_handle_nonaligned_watchpoint.\n"), - static void - i386_update_inferior_debug_regs (struct i386_debug_reg_state *new_state) - { -+ struct i386_debug_reg_state *state = i386_debug_reg_state (); - int i; + /* Read in the old history after all the command files have been + read. */ +- init_history (); ++ if (!python_script) ++ init_history (); - ALL_DEBUG_REGISTERS (i) + if (batch_flag) { -- if (I386_DR_VACANT (new_state, i) != I386_DR_VACANT (&dr_mirror, i)) -+ if (I386_DR_VACANT (new_state, i) != I386_DR_VACANT (state, i)) - i386_dr_low.set_addr (i, new_state->dr_mirror[i]); - else -- gdb_assert (new_state->dr_mirror[i] == dr_mirror.dr_mirror[i]); -+ gdb_assert (new_state->dr_mirror[i] == state->dr_mirror[i]); - } - -- if (new_state->dr_control_mirror != dr_mirror.dr_control_mirror) -+ if (new_state->dr_control_mirror != state->dr_control_mirror) - i386_dr_low.set_control (new_state->dr_control_mirror); - -- dr_mirror = *new_state; -+ *state = *new_state; - } +@@ -992,13 +1027,25 @@ captured_main (void *data) + /* Show time and/or space usage. */ + do_cleanups (pre_stat_chain); - /* Insert a watchpoint to watch a memory region which starts at -@@ -518,10 +596,11 @@ static int - i386_insert_watchpoint (CORE_ADDR addr, int len, int type, - struct expression *cond) - { -+ struct i386_debug_reg_state *state = i386_debug_reg_state (); - int retval; - /* Work on a local copy of the debug registers, and on success, - commit the change back to the inferior. */ -- struct i386_debug_reg_state local_state = dr_mirror; -+ struct i386_debug_reg_state local_state = *state; - - if (type == hw_read) - return 1; /* unsupported */ -@@ -542,7 +621,7 @@ i386_insert_watchpoint (CORE_ADDR addr, int len, int type, - i386_update_inferior_debug_regs (&local_state); - - if (maint_show_dr) -- i386_show_dr (&dr_mirror, "insert_watchpoint", addr, len, type); -+ i386_show_dr (state, "insert_watchpoint", addr, len, type); - - return retval; - } -@@ -554,10 +633,11 @@ static int - i386_remove_watchpoint (CORE_ADDR addr, int len, int type, - struct expression *cond) - { -+ struct i386_debug_reg_state *state = i386_debug_reg_state (); - int retval; - /* Work on a local copy of the debug registers, and on success, - commit the change back to the inferior. */ -- struct i386_debug_reg_state local_state = dr_mirror; -+ struct i386_debug_reg_state local_state = *state; - - if (((len != 1 && len !=2 && len !=4) && !(TARGET_HAS_DR_LEN_8 && len == 8)) - || addr % len != 0) -@@ -575,7 +655,7 @@ i386_remove_watchpoint (CORE_ADDR addr, int len, int type, - i386_update_inferior_debug_regs (&local_state); - - if (maint_show_dr) -- i386_show_dr (&dr_mirror, "remove_watchpoint", addr, len, type); -+ i386_show_dr (state, "remove_watchpoint", addr, len, type); - - return retval; - } -@@ -586,11 +666,12 @@ i386_remove_watchpoint (CORE_ADDR addr, int len, int type, - static int - i386_region_ok_for_watchpoint (CORE_ADDR addr, int len) - { -+ struct i386_debug_reg_state *state = i386_debug_reg_state (); - int nregs; - - /* Compute how many aligned watchpoints we would need to cover this - region. */ -- nregs = i386_handle_nonaligned_watchpoint (&dr_mirror, -+ nregs = i386_handle_nonaligned_watchpoint (state, - WP_COUNT, addr, len, hw_write); - return nregs <= DR_NADDR ? 1 : 0; - } -@@ -602,6 +683,7 @@ i386_region_ok_for_watchpoint (CORE_ADDR addr, int len) - static int - i386_stopped_data_address (struct target_ops *ops, CORE_ADDR *addr_p) - { -+ struct i386_debug_reg_state *state = i386_debug_reg_state (); - CORE_ADDR addr = 0; - int i; - int rc = 0; -@@ -615,25 +697,24 @@ i386_stopped_data_address (struct target_ops *ops, CORE_ADDR *addr_p) - unsigned control = 0; - - /* In non-stop/async, threads can be running while we change the -- global dr_mirror (and friends). Say, we set a watchpoint, and -- let threads resume. Now, say you delete the watchpoint, or -- add/remove watchpoints such that dr_mirror changes while threads -- are running. On targets that support non-stop, -- inserting/deleting watchpoints updates the global dr_mirror only. -- It does not update the real thread's debug registers; that's only -- done prior to resume. Instead, if threads are running when the -- mirror changes, a temporary and transparent stop on all threads -- is forced so they can get their copy of the debug registers -- updated on re-resume. Now, say, a thread hit a watchpoint before -- having been updated with the new dr_mirror contents, and we -- haven't yet handled the corresponding SIGTRAP. If we trusted -- dr_mirror below, we'd mistake the real trapped address (from the -- last time we had updated debug registers in the thread) with -- whatever was currently in dr_mirror. So to fix this, dr_mirror -- always represents intention, what we _want_ threads to have in -- debug registers. To get at the address and cause of the trap, we -- need to read the state the thread still has in its debug -- registers. -+ STATE (and friends). Say, we set a watchpoint, and let threads -+ resume. Now, say you delete the watchpoint, or add/remove -+ watchpoints such that STATE changes while threads are running. -+ On targets that support non-stop, inserting/deleting watchpoints -+ updates the STATE only. It does not update the real thread's -+ debug registers; that's only done prior to resume. Instead, if -+ threads are running when the mirror changes, a temporary and -+ transparent stop on all threads is forced so they can get their -+ copy of the debug registers updated on re-resume. Now, say, -+ a thread hit a watchpoint before having been updated with the new -+ STATE contents, and we haven't yet handled the corresponding -+ SIGTRAP. If we trusted STATE below, we'd mistake the real -+ trapped address (from the last time we had updated debug -+ registers in the thread) with whatever was currently in STATE. -+ So to fix this, STATE always represents intention, what we _want_ -+ threads to have in debug registers. To get at the address and -+ cause of the trap, we need to read the state the thread still has -+ in its debug registers. - - In sum, always get the current debug register values the current - thread has, instead of trusting the global mirror. If the thread -@@ -663,11 +744,11 @@ i386_stopped_data_address (struct target_ops *ops, CORE_ADDR *addr_p) - addr = i386_dr_low.get_addr (i); - rc = 1; - if (maint_show_dr) -- i386_show_dr (&dr_mirror, "watchpoint_hit", addr, -1, hw_write); -+ i386_show_dr (state, "watchpoint_hit", addr, -1, hw_write); - } +- /* 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); ++ } } - if (maint_show_dr && addr == 0) -- i386_show_dr (&dr_mirror, "stopped_data_addr", 0, 0, hw_write); -+ i386_show_dr (state, "stopped_data_addr", 0, 0, hw_write); - - if (rc) - *addr_p = addr; -@@ -687,11 +768,12 @@ static int - i386_insert_hw_breakpoint (struct gdbarch *gdbarch, - struct bp_target_info *bp_tgt) - { -+ struct i386_debug_reg_state *state = i386_debug_reg_state (); - unsigned len_rw = i386_length_and_rw_bits (1, hw_execute); - CORE_ADDR addr = bp_tgt->placed_address; - /* Work on a local copy of the debug registers, and on success, - commit the change back to the inferior. */ -- struct i386_debug_reg_state local_state = dr_mirror; -+ struct i386_debug_reg_state local_state = *state; - int retval = i386_insert_aligned_watchpoint (&local_state, - addr, len_rw) ? EBUSY : 0; - -@@ -699,7 +781,7 @@ i386_insert_hw_breakpoint (struct gdbarch *gdbarch, - i386_update_inferior_debug_regs (&local_state); - - if (maint_show_dr) -- i386_show_dr (&dr_mirror, "insert_hwbp", addr, 1, hw_execute); -+ i386_show_dr (state, "insert_hwbp", addr, 1, hw_execute); - - return retval; - } -@@ -711,11 +793,12 @@ static int - i386_remove_hw_breakpoint (struct gdbarch *gdbarch, - struct bp_target_info *bp_tgt) - { -+ struct i386_debug_reg_state *state = i386_debug_reg_state (); - unsigned len_rw = i386_length_and_rw_bits (1, hw_execute); - CORE_ADDR addr = bp_tgt->placed_address; - /* Work on a local copy of the debug registers, and on success, - commit the change back to the inferior. */ -- struct i386_debug_reg_state local_state = dr_mirror; -+ struct i386_debug_reg_state local_state = *state; - int retval = i386_remove_aligned_watchpoint (&local_state, - addr, len_rw); - -@@ -723,7 +806,7 @@ i386_remove_hw_breakpoint (struct gdbarch *gdbarch, - i386_update_inferior_debug_regs (&local_state); - - if (maint_show_dr) -- i386_show_dr (&dr_mirror, "remove_hwbp", addr, 1, hw_execute); -+ i386_show_dr (state, "remove_hwbp", addr, 1, hw_execute); - - return retval; - } -@@ -788,6 +871,10 @@ i386_use_watchpoints (struct target_ops *t) - 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); - } - - void -diff --git a/gdb/i386-tdep.c b/gdb/i386-tdep.c -index 549297e..5783c4c 100644 ---- a/gdb/i386-tdep.c -+++ b/gdb/i386-tdep.c -@@ -58,8 +58,14 @@ - #include "features/i386/i386-avx.c" - #include "features/i386/i386-mmx.c" - -+#include "stap-probe.h" - #include "ax.h" - #include "ax-gdb.h" -+#include "user-regs.h" -+#include "cli/cli-utils.h" -+#include "expression.h" -+#include "parser-defs.h" -+#include - - /* Register names. */ - -@@ -7246,6 +7252,312 @@ i386_validate_tdesc_p (struct gdbarch_tdep *tdep, - return valid_p; + /* No exit -- exit is through quit_command. */ } +@@ -1030,7 +1077,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 (_("\ +@@ -1070,7 +1122,13 @@ Options:\n\n\ + --nw Do not use a window interface.\n\ + --nx Do not read "), stream); + fputs_unfiltered (gdbinit, stream); +- fputs_unfiltered (_(" file.\n\ ++ fputs_unfiltered (_(" file.\n"), stream); ++#if HAVE_PYTHON ++ fputs_unfiltered (_("\ ++ --python, -P Following argument is Python script file; remaining\n\ ++ arguments are passed to script.\n"), stream); ++#endif ++ fputs_unfiltered (_("\ + --quiet Do not print version number on startup.\n\ + --readnow Fully read symbol files on first access.\n\ + "), stream); +diff --git a/gdb/p-valprint.c b/gdb/p-valprint.c +index b8434ed..98a076d 100644 +--- a/gdb/p-valprint.c ++++ b/gdb/p-valprint.c +@@ -39,6 +39,7 @@ + #include "cp-abi.h" + #include "cp-support.h" + #include "exceptions.h" ++#include "dwarf2loc.h" + -+int -+i386_stap_is_single_operand (struct gdbarch *gdbarch, const char *s) -+{ -+ return (*s == '$' /* Literal number. */ -+ || (isdigit (*s) && s[1] == '(' && s[2] == '%') /* Displacement. */ -+ || (*s == '(' && s[1] == '%') /* Register indirection. */ -+ || (*s == '%' && isalpha (s[1]))); /* Register access. */ -+} -+ -+int -+i386_stap_parse_special_token (struct gdbarch *gdbarch, -+ struct stap_parse_info *p) -+{ -+ const char *s = p->arg; -+ -+ /* In order to parse special tokens, we use a state-machine that go -+ through every known token and try to get a match. */ -+ enum -+ { -+ TRIPLET, -+ THREE_ARG_DISPLACEMENT, -+ DONE -+ } current_state; -+ -+ current_state = TRIPLET; -+ -+ /* The special tokens to be parsed here are: -+ -+ - `register base + (register index * size) + offset', as represented -+ in `(%rcx,%rax,8)', or `[OFFSET](BASE_REG,INDEX_REG[,SIZE])'. -+ -+ - Operands of the form `-8+3+1(%rbp)', which must be interpreted as -+ `*(-8 + 3 - 1 + (void *) $eax)'. */ -+ -+ while (current_state != DONE) + /* Decorations for Pascal. */ +@@ -74,8 +75,31 @@ pascal_val_print (struct type *type, const gdb_byte *valaddr, + struct type *char_type; + CORE_ADDR addr; + int want_space = 0; ++ 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) + { -+ const char *s = p->arg; -+ -+ switch (current_state) -+ { -+ case TRIPLET: -+ { -+ if (isdigit (*s) || *s == '-' || *s == '+') -+ { -+ int got_minus[3]; -+ int i; -+ long displacements[3]; -+ const char *start; -+ char *regname; -+ int len; -+ struct stoken str; -+ -+ got_minus[0] = 0; -+ if (*s == '+') -+ ++s; -+ else if (*s == '-') -+ { -+ ++s; -+ got_minus[0] = 1; -+ } -+ -+ displacements[0] = strtol (s, (char **) &s, 10); -+ -+ if (*s != '+' && *s != '-') -+ /* We are not dealing with a triplet. */ -+ break; -+ -+ got_minus[1] = 0; -+ if (*s == '+') -+ ++s; -+ else -+ { -+ ++s; -+ got_minus[1] = 1; -+ } -+ -+ displacements[1] = strtol (s, (char **) &s, 10); -+ -+ if (*s != '+' && *s != '-') -+ /* We are not dealing with a triplet. */ -+ break; -+ -+ got_minus[2] = 0; -+ if (*s == '+') -+ ++s; -+ else -+ { -+ ++s; -+ got_minus[2] = 1; -+ } -+ -+ displacements[2] = strtol (s, (char **) &s, 10); -+ -+ if (*s != '(' || s[1] != '%') -+ break; -+ -+ s += 2; -+ start = s; -+ -+ while (isalnum (*s)) -+ ++s; -+ -+ if (*s++ != ')') -+ break; -+ -+ len = s - start; -+ regname = alloca (len + 1); -+ -+ strncpy (regname, start, len); -+ regname[len] = '\0'; -+ -+ if (user_reg_map_name_to_regnum (gdbarch, -+ regname, len) == -1) -+ error (_("Invalid register name `%s' " -+ "on expression `%s'."), -+ regname, p->saved_arg); -+ -+ for (i = 0; i < 3; i++) -+ { -+ write_exp_elt_opcode (OP_LONG); -+ write_exp_elt_type -+ (builtin_type (gdbarch)->builtin_long); -+ write_exp_elt_longcst (displacements[i]); -+ write_exp_elt_opcode (OP_LONG); -+ if (got_minus[i]) -+ write_exp_elt_opcode (UNOP_NEG); -+ } -+ -+ write_exp_elt_opcode (OP_REGISTER); -+ str.ptr = regname; -+ str.length = len; -+ write_exp_string (str); -+ write_exp_elt_opcode (OP_REGISTER); -+ -+ write_exp_elt_opcode (UNOP_CAST); -+ write_exp_elt_type (builtin_type (gdbarch)->builtin_data_ptr); -+ write_exp_elt_opcode (UNOP_CAST); -+ -+ write_exp_elt_opcode (BINOP_ADD); -+ write_exp_elt_opcode (BINOP_ADD); -+ write_exp_elt_opcode (BINOP_ADD); -+ -+ write_exp_elt_opcode (UNOP_CAST); -+ write_exp_elt_type (lookup_pointer_type (p->arg_type)); -+ write_exp_elt_opcode (UNOP_CAST); -+ -+ write_exp_elt_opcode (UNOP_IND); -+ -+ p->arg = s; -+ -+ return 1; -+ } -+ break; -+ } -+ case THREE_ARG_DISPLACEMENT: -+ { -+ if (isdigit (*s) || *s == '(' || *s == '-' || *s == '+') -+ { -+ int offset_minus = 0; -+ long offset = 0; -+ int size_minus = 0; -+ long size = 0; -+ const char *start; -+ char *base; -+ int len_base; -+ char *index; -+ int len_index; -+ struct stoken base_token, index_token; -+ -+ if (*s == '+') -+ ++s; -+ else if (*s == '-') -+ { -+ ++s; -+ offset_minus = 1; -+ } -+ -+ if (offset_minus && !isdigit (*s)) -+ break; -+ -+ if (isdigit (*s)) -+ offset = strtol (s, (char **) &s, 10); -+ -+ if (*s != '(' || s[1] != '%') -+ break; -+ -+ s += 2; -+ start = s; -+ -+ while (isalnum (*s)) -+ ++s; -+ -+ if (*s != ',' || s[1] != '%') -+ break; -+ -+ len_base = s - start; -+ base = alloca (len_base + 1); -+ strncpy (base, start, len_base); -+ base[len_base] = '\0'; -+ -+ if (user_reg_map_name_to_regnum (gdbarch, -+ base, len_base) == -1) -+ error (_("Invalid register name `%s' " -+ "on expression `%s'."), -+ base, p->saved_arg); -+ -+ s += 2; -+ start = s; -+ -+ while (isalnum (*s)) -+ ++s; -+ -+ len_index = s - start; -+ index = alloca (len_index + 1); -+ strncpy (index, start, len_index); -+ index[len_index] = '\0'; -+ -+ if (user_reg_map_name_to_regnum (gdbarch, -+ index, len_index) == -1) -+ error (_("Invalid register name `%s' " -+ "on expression `%s'."), -+ index, p->saved_arg); -+ -+ if (*s != ',' && *s != ')') -+ break; -+ -+ if (*s == ',') -+ { -+ ++s; -+ if (*s == '+') -+ ++s; -+ else if (*s == '-') -+ { -+ ++s; -+ size_minus = 1; -+ } -+ -+ size = strtol (s, (char **) &s, 10); -+ -+ if (*s != ')') -+ break; -+ } -+ -+ ++s; -+ -+ if (offset) -+ { -+ write_exp_elt_opcode (OP_LONG); -+ write_exp_elt_type -+ (builtin_type (gdbarch)->builtin_long); -+ write_exp_elt_longcst (offset); -+ write_exp_elt_opcode (OP_LONG); -+ if (offset_minus) -+ write_exp_elt_opcode (UNOP_NEG); -+ } -+ -+ write_exp_elt_opcode (OP_REGISTER); -+ base_token.ptr = base; -+ base_token.length = len_base; -+ write_exp_string (base_token); -+ write_exp_elt_opcode (OP_REGISTER); -+ -+ if (offset) -+ write_exp_elt_opcode (BINOP_ADD); -+ -+ write_exp_elt_opcode (OP_REGISTER); -+ index_token.ptr = index; -+ index_token.length = len_index; -+ write_exp_string (index_token); -+ write_exp_elt_opcode (OP_REGISTER); -+ -+ if (size) -+ { -+ write_exp_elt_opcode (OP_LONG); -+ write_exp_elt_type -+ (builtin_type (gdbarch)->builtin_long); -+ write_exp_elt_longcst (size); -+ write_exp_elt_opcode (OP_LONG); -+ if (size_minus) -+ write_exp_elt_opcode (UNOP_NEG); -+ write_exp_elt_opcode (BINOP_MUL); -+ } -+ -+ write_exp_elt_opcode (BINOP_ADD); -+ -+ write_exp_elt_opcode (UNOP_CAST); -+ write_exp_elt_type (lookup_pointer_type (p->arg_type)); -+ write_exp_elt_opcode (UNOP_CAST); -+ -+ write_exp_elt_opcode (UNOP_IND); -+ -+ p->arg = s; -+ -+ return 1; -+ } -+ break; -+ } -+ } -+ -+ /* Advancing to the next state. */ -+ ++current_state; ++ fputs_filtered (object_address_data_not_valid (saved_type), stream); ++ gdb_flush (stream); ++ do_cleanups (back_to); ++ return; + } -+ -+ return 0; -+} -+ - - static struct gdbarch * - i386_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) -diff --git a/gdb/i386-tdep.h b/gdb/i386-tdep.h -index 870054f..9ffbe44 100644 ---- a/gdb/i386-tdep.h -+++ b/gdb/i386-tdep.h -@@ -379,6 +379,15 @@ extern void i386_svr4_init_abi (struct gdbarch_info, struct gdbarch *); ++ if (address != saved_address + embedded_offset) ++ { ++ size_t length = TYPE_LENGTH (type); - extern int i386_process_record (struct gdbarch *gdbarch, - struct regcache *regcache, CORE_ADDR addr); -+ -+/* SystemTap related functions. */ -+ -+extern int i386_stap_is_single_operand (struct gdbarch *gdbarch, -+ const char *s); -+ -+extern int i386_stap_parse_special_token (struct gdbarch *gdbarch, -+ struct stap_parse_info *p); -+ - +- 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: +@@ -131,8 +155,8 @@ pascal_val_print (struct type *type, const gdb_byte *valaddr, + { + 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, "}"); + } +@@ -170,6 +194,7 @@ pascal_val_print (struct type *type, const gdb_byte *valaddr, + { + /* Try to print what function it points to. */ + print_address_demangle (options, gdbarch, addr, stream, demangle); ++ do_cleanups (back_to); + return; + } - /* Functions and variables exported from i386bsd-tdep.c. */ -diff --git a/gdb/infrun.c b/gdb/infrun.c -index 24d2720..c516b8b 100644 ---- a/gdb/infrun.c -+++ b/gdb/infrun.c -@@ -55,6 +55,8 @@ - #include "continuations.h" - #include "interps.h" - #include "skip.h" -+#include "stap-probe.h" -+#include "objfiles.h" +@@ -271,6 +296,7 @@ pascal_val_print (struct type *type, const gdb_byte *valaddr, + } + } - /* Prototypes for local functions */ ++ do_cleanups (back_to); + return; -@@ -2379,7 +2381,7 @@ static void handle_step_into_function (struct gdbarch *gdbarch, - static void handle_step_into_function_backward (struct gdbarch *gdbarch, - struct execution_control_state *ecs); - static void check_exception_resume (struct execution_control_state *, -- struct frame_info *, struct symbol *); -+ struct frame_info *); + case TYPE_CODE_REF: +@@ -421,6 +447,7 @@ pascal_val_print (struct type *type, const gdb_byte *valaddr, + TYPE_CODE (type)); + } + gdb_flush (stream); ++ do_cleanups (back_to); + } + + void +diff --git a/gdb/parse.c b/gdb/parse.c +index f54c6f2..70e9a05 100644 +--- a/gdb/parse.c ++++ b/gdb/parse.c +@@ -1516,6 +1516,7 @@ parser_fprintf (FILE *x, const char *y, ...) - static void stop_stepping (struct execution_control_state *ecs); - static void prepare_to_wait (struct execution_control_state *ecs); -@@ -4417,9 +4419,17 @@ process_event_stop_test: + 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) +@@ -1557,7 +1558,7 @@ operator_check_standard (struct expression *exp, int pos, + struct type *type = elts[pos + 2 + arg].type; + struct objfile *objfile = TYPE_OBJFILE (type); - 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, -@@ -4437,12 +4447,7 @@ process_event_stop_test: - insert_longjmp_resume_breakpoint (gdbarch, jmp_buf_pc); +- if (objfile && (*objfile_func) (objfile, data)) ++ if (objfile && objfile_func && (*objfile_func) (objfile, data)) + return 1; } - else -- { -- struct symbol *func = get_frame_function (frame); -- -- if (func) -- check_exception_resume (ecs, frame, func); -- } -+ check_exception_resume (ecs, frame); - keep_going (ecs); - return; + } +@@ -1575,7 +1576,8 @@ operator_check_standard (struct expression *exp, int pos, -@@ -5524,15 +5529,65 @@ insert_exception_resume_breakpoint (struct thread_info *tp, - } - } + /* 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; -+/* A helper for check_exception_resume that sets an -+ exception-breakpoint based on a SystemTap probe. */ -+ -+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; -+ -+ arg_value = stap_safe_evaluate_at_pc (frame, 1); -+ if (!arg_value) -+ return; -+ -+ handler = value_as_address (arg_value); -+ -+ if (debug_infrun) -+ fprintf_unfiltered (gdb_stdlog, -+ "infrun: exception resume at %s\n", -+ paddress (get_objfile_arch (objfile), -+ handler)); -+ -+ 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; -+} -+ - /* 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. */ + /* Check objfile where is placed the code touching the variable. */ +@@ -1588,24 +1590,27 @@ operator_check_standard (struct expression *exp, int pos, - static void - check_exception_resume (struct execution_control_state *ecs, -- struct frame_info *frame, struct symbol *func) -+ struct frame_info *frame) - { - volatile struct gdb_exception e; -+ struct objfile *objfile; -+ const struct stap_probe *probe; -+ struct symbol *func; -+ -+ /* 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; + /* Invoke callbacks for TYPE and OBJFILE if they were set as non-NULL. */ - TRY_CATCH (e, RETURN_MASK_ERROR) - { -@@ -6564,7 +6619,8 @@ static const struct lval_funcs siginfo_value_funcs = - if there's no object available. */ +- 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; - 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) -@@ -7059,6 +7115,15 @@ show_schedule_multiple (struct ui_file *file, int from_tty, - "of all processes is %s.\n"), value); + return 0; } -+/* Implementation of `siginfo' variable. */ -+ -+static const struct internalvar_funcs siginfo_funcs = -+{ -+ siginfo_make_value, -+ NULL, -+ NULL -+}; -+ - void - _initialize_infrun (void) - { -@@ -7347,7 +7412,7 @@ enabled by default on some platforms."), - 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, _("\ -diff --git a/gdb/linespec.c b/gdb/linespec.c -index 0782c54..31bb36c 100644 ---- a/gdb/linespec.c -+++ b/gdb/linespec.c -@@ -43,6 +43,7 @@ - #include "cli/cli-utils.h" - #include "filenames.h" - #include "ada-lang.h" -+#include "stap-probe.h" - - typedef struct symtab *symtab_p; - DEF_VEC_P (symtab_p); -@@ -802,6 +803,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. -+ -p [OBJFILE:][PROVIDER:]NAME -- a systemtap static probe - - This may all be followed by an "if EXPR", which we ignore. - -@@ -872,6 +874,9 @@ decode_line_internal (struct linespec_state *self, char **argptr) - return decode_indirect (self, argptr); - } +-/* 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. */ -+ if (strncmp (*argptr, "-p", 2) == 0 && isspace ((*argptr)[2])) -+ return parse_stap_probe (argptr, self->canonical); -+ - is_quoted = (strchr (get_gdb_completer_quote_characters (), - **argptr) != NULL); + 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) + { +@@ -1620,7 +1625,9 @@ exp_iterate (struct expression *exp, -diff --git a/gdb/linux-nat.c b/gdb/linux-nat.c -index 50d4efd..893b7c4 100644 ---- a/gdb/linux-nat.c -+++ b/gdb/linux-nat.c -@@ -288,6 +288,7 @@ static void restore_child_signals_mask (sigset_t *prev_mask); - struct lwp_info; - static struct lwp_info *add_lwp (ptid_t ptid); - static void purge_lwp_list (int pid); -+static void delete_lwp (ptid_t ptid); - static struct lwp_info *find_lwp_pid (ptid_t ptid); + pos = endpos - oplen; + if (exp->language_defn->la_exp_desc->operator_check (exp, pos, +- objfile_func, data)) ++ type_func, ++ objfile_func, ++ data)) + return 1; - -@@ -584,6 +585,31 @@ linux_child_post_startup_inferior (ptid_t ptid) - linux_enable_tracesysgood (ptid); - } + endpos = pos; +@@ -1651,8 +1658,29 @@ exp_uses_objfile (struct expression *exp, struct objfile *objfile) + { + gdb_assert (objfile->separate_debug_objfile_backlink == NULL); -+/* Return the number of known LWPs in the tgid given by PID. */ +- return exp_iterate (exp, exp_uses_objfile_iter, objfile); ++ return exp_iterate (exp, NULL, exp_uses_objfile_iter, objfile); ++} ++ ++/* Helper for exp_types_mark_used. */ + ++#if 0 +static int -+num_lwps (int pid) ++exp_types_mark_used_iter (struct type *type, void *unused) +{ -+ int count = 0; -+ struct lwp_info *lp; -+ -+ for (lp = lwp_list; lp; lp = lp->next) -+ if (ptid_get_pid (lp->ptid) == pid) -+ count++; ++ type_mark_used (type); + -+ return count; ++ /* Continue the traversal. */ ++ return 0; +} + -+/* Call delete_lwp with prototype compatible for make_cleanup. */ ++/* Call type_mark_used for any type contained in EXP. */ + -+static void -+delete_lwp_cleanup (void *lp_voidp) ++void ++exp_types_mark_used (struct expression *exp) +{ -+ struct lwp_info *lp = lp_voidp; ++ exp_iterate (exp, exp_types_mark_used_iter, NULL, NULL); + } ++#endif + + void + _initialize_parse (void) +diff --git a/gdb/parser-defs.h b/gdb/parser-defs.h +index 72b9e2f..719a652 100644 +--- a/gdb/parser-defs.h ++++ b/gdb/parser-defs.h +@@ -215,6 +215,8 @@ extern void operator_length_standard (const struct expression *, int, int *, + int *); + + 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); +@@ -301,6 +303,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); +@@ -339,4 +342,10 @@ extern void parser_fprintf (FILE *, const char *, ...) ATTRIBUTE_PRINTF (2, 3); + + extern int exp_uses_objfile (struct expression *exp, struct objfile *objfile); + ++extern int exp_uses_objfile (struct expression *exp, struct objfile *objfile); + -+ delete_lwp (lp->ptid); -+} ++#if 0 ++extern void exp_types_mark_used (struct expression *exp); ++#endif + - static int - linux_child_follow_fork (struct target_ops *ops, int follow_child) - { -@@ -630,6 +656,8 @@ holding the child stopped. Try \"set detach-on-fork\" or \ - /* Detach new forked process? */ - if (detach_fork) - { -+ struct cleanup *old_chain; + #endif /* PARSER_DEFS_H */ +diff --git a/gdb/printcmd.c b/gdb/printcmd.c +index 030a4f2..306be18 100644 +--- a/gdb/printcmd.c ++++ b/gdb/printcmd.c +@@ -49,6 +49,7 @@ + #include "charset.h" + #include "arch-utils.h" + #include "cli/cli-utils.h" ++#include "dwarf2loc.h" + + #ifdef TUI + #include "tui/tui.h" /* For tui_active et al. */ +@@ -974,6 +975,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. */ + - /* Before detaching from the child, remove all breakpoints - from it. If we forked, then this has already been taken - care of by infrun.c. If we vforked however, any -@@ -652,7 +680,28 @@ holding the child stopped. Try \"set detach-on-fork\" or \ - child_pid); - } + if (voidprint || (val && value_type (val) && + TYPE_CODE (value_type (val)) != TYPE_CODE_VOID)) + { +@@ -1062,6 +1068,9 @@ output_command (char *exp, int from_tty) + + val = evaluate_expression (expr); -+ old_chain = save_inferior_ptid (); -+ inferior_ptid = ptid_build (child_pid, child_pid, 0); ++ if (VALUE_LVAL (val) == lval_memory) ++ object_address_set (value_raw_address (val)); + -+ child_lp = add_lwp (inferior_ptid); -+ child_lp->stopped = 1; -+ child_lp->last_resume_kind = resume_stop; -+ make_cleanup (delete_lwp_cleanup, child_lp); + annotate_value_begin (value_type (val)); + + get_formatted_print_options (&opts, format); +@@ -1491,6 +1500,24 @@ x_command (char *exp, int from_tty) + set_internalvar (lookup_internalvar ("__"), last_examine_value); + } + } + -+ /* CHILD_LP has new PID, therefore linux_nat_new_thread is not called for it. -+ See i386_inferior_data_get for the Linux kernel specifics. -+ Ensure linux_nat_prepare_to_resume will reset the hardware debug -+ registers. It is done by the linux_nat_new_thread call, which is -+ being skipped in add_lwp above for the first lwp of a pid. */ -+ gdb_assert (num_lwps (GET_PID (child_lp->ptid)) == 1); -+ if (linux_nat_new_thread != NULL) -+ linux_nat_new_thread (child_lp); ++#if 0 ++/* Call type_mark_used for any TYPEs referenced from this GDB source file. */ + -+ if (linux_nat_prepare_to_resume != NULL) -+ linux_nat_prepare_to_resume (child_lp); - ptrace (PTRACE_DETACH, child_pid, 0, 0); ++static void ++print_types_mark_used (void) ++{ ++ struct display *d; + -+ do_cleanups (old_chain); - } - else - { -@@ -670,6 +719,9 @@ holding the child stopped. Try \"set detach-on-fork\" or \ - save_current_program_space (); - - inferior_ptid = ptid_build (child_pid, child_pid, 0); -+ reinit_frame_cache (); -+ registers_changed (); -+ - add_thread (inferior_ptid); - child_lp = add_lwp (inferior_ptid); - child_lp->stopped = 1; -@@ -861,6 +913,9 @@ holding the child stopped. Try \"set detach-on-fork\" or \ - informing the solib layer about this new process. */ - - inferior_ptid = ptid_build (child_pid, child_pid, 0); -+ reinit_frame_cache (); -+ registers_changed (); -+ - add_thread (inferior_ptid); - child_lp = add_lwp (inferior_ptid); - child_lp->stopped = 1; -@@ -1111,21 +1166,6 @@ purge_lwp_list (int pid) - } - } ++ if (last_examine_value) ++ type_mark_used (value_type (last_examine_value)); ++ ++ for (d = display_chain; d; d = d->next) ++ if (d->exp) ++ exp_types_mark_used (d->exp); ++} ++#endif ++ + --/* Return the number of known LWPs in the tgid given by PID. */ -- --static int --num_lwps (int pid) --{ -- int count = 0; -- struct lwp_info *lp; -- -- for (lp = lwp_list; lp; lp = lp->next) -- if (ptid_get_pid (lp->ptid) == pid) -- count++; -- -- return count; --} -- - /* Add the LWP specified by PID to the list. Return a pointer to the - structure describing the new LWP. The LWP should already be stopped - (with an exception for the very first LWP). */ -@@ -1235,6 +1275,46 @@ iterate_over_lwps (ptid_t filter, - return NULL; - } + /* Add an expression to the auto-display chain. +@@ -1986,6 +2013,10 @@ print_variable_and_value (const char *name, struct symbol *var, + struct value_print_options opts; -+/* Iterate like iterate_over_lwps does except when forking-off a child call -+ CALLBACK with CALLBACK_DATA specifically only for that new child PID. */ + val = read_var_value (var, frame); + -+void -+linux_nat_iterate_watchpoint_lwps -+ (linux_nat_iterate_watchpoint_lwps_ftype callback, void *callback_data) -+{ -+ int inferior_pid = ptid_get_pid (inferior_ptid); -+ struct inferior *inf = current_inferior (); ++ make_cleanup_restore_selected_frame (); ++ select_frame (frame); + -+ if (inf->pid == inferior_pid) -+ { -+ /* Iterate all the threads of the current inferior. Without specifying -+ INFERIOR_PID it would iterate all threads of all inferiors, which is -+ inappropriate for watchpoints. */ + get_user_print_options (&opts); + opts.deref_ref = 1; + common_val_print (val, stream, indent, &opts, current_language); +@@ -2899,4 +2930,8 @@ Show printing of source filename and line number with ."), NULL, + add_com ("eval", no_class, eval_command, _("\ + Convert \"printf format string\", arg1, arg2, arg3, ..., argn to\n\ + a command line, and call it.")); + -+ iterate_over_lwps (pid_to_ptid (inferior_pid), callback, callback_data); -+ } -+ else -+ { -+ /* Detaching a new child PID temporarily present in INFERIOR_PID. */ ++#if 0 ++ observer_attach_mark_used (print_types_mark_used); ++#endif + } +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. + -+ struct lwp_info *child_lp; -+ struct cleanup *old_chain; -+ pid_t child_pid = GET_PID (inferior_ptid); -+ ptid_t child_ptid = ptid_build (child_pid, child_pid, 0); ++# Copyright (C) 2008, 2009 Free Software Foundation, Inc. + -+ gdb_assert (!is_lwp (inferior_ptid)); -+ gdb_assert (find_lwp_pid (child_ptid) == NULL); -+ child_lp = add_lwp (child_ptid); -+ child_lp->stopped = 1; -+ child_lp->last_resume_kind = resume_stop; -+ old_chain = make_cleanup (delete_lwp_cleanup, child_lp); ++# This program is free software; you can redistribute it and/or modify ++# it under the terms of the 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 . + -+ callback (child_lp, callback_data); ++class FrameIterator: ++ """An iterator that iterates over frames.""" + -+ do_cleanups (old_chain); -+ } -+} ++ def __init__ (self, frame): ++ "Initialize a FrameIterator. FRAME is the starting frame." ++ self.frame = frame + - /* 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 -diff --git a/gdb/linux-nat.h b/gdb/linux-nat.h -index d9dc71b..6217370 100644 ---- a/gdb/linux-nat.h -+++ b/gdb/linux-nat.h -@@ -158,6 +158,12 @@ struct lwp_info *iterate_over_lwps (ptid_t filter, - void *), - void *data); - -+typedef int (*linux_nat_iterate_watchpoint_lwps_ftype) (struct lwp_info *lwp, -+ void *arg); -+ -+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); -diff --git a/gdb/machoread.c b/gdb/machoread.c -index 9fa97e1..d6f0f38 100644 ---- a/gdb/machoread.c -+++ b/gdb/machoread.c -@@ -1032,6 +1032,7 @@ static const struct sym_fns macho_sym_fns = { - default_symfile_segments, /* Get segment information from a file. */ - NULL, - macho_symfile_relocate, /* Relocate a debug section. */ -+ NULL, /* sym_get_probes */ - &psym_functions - }; - -diff --git a/gdb/main.c b/gdb/main.c -index 8b45c25..c7ea0df 100644 ---- a/gdb/main.c -+++ b/gdb/main.c -@@ -37,6 +37,7 @@ - - #include "interps.h" - #include "main.h" -+#include "python/python.h" - #include "source.h" - #include "cli/cli-cmds.h" - #include "python/python.h" -@@ -264,6 +265,8 @@ captured_main (void *data) - char *cdarg = NULL; - char *ttyarg = NULL; - -+ int python_script = 0; ++ def __iter__ (self): ++ return self + - /* These are static so that we can take their address in an - initializer. */ - static int print_help; -@@ -457,10 +460,14 @@ captured_main (void *data) - {"args", no_argument, &set_args, 1}, - {"l", required_argument, 0, 'l'}, - {"return-child-result", no_argument, &return_child_result, 1}, -+#if HAVE_PYTHON -+ {"python", no_argument, 0, 'P'}, -+ {"P", no_argument, 0, 'P'}, -+#endif - {0, no_argument, 0, 0} - }; - -- while (1) -+ while (!python_script) - { - int option_index; - -@@ -478,6 +485,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; -@@ -673,7 +683,31 @@ captured_main (void *data) - - /* Now that gdb_init has created the initial inferior, we're in - position to set args for that inferior. */ -- if (set_args) -+ if (python_script) -+ { -+ /* The first argument is a python script to evaluate, and -+ subsequent arguments are passed to the script for -+ processing there. */ -+ if (optind >= argc) -+ { -+ fprintf_unfiltered (gdb_stderr, -+ _("%s: Python script file name required\n"), -+ argv[0]); -+ exit (1); -+ } ++ 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. + -+ /* 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 -@@ -922,7 +956,8 @@ captured_main (void *data) - - /* Read in the old history after all the command files have been - read. */ -- init_history (); -+ if (!python_script) -+ init_history (); - - if (batch_flag) - { -@@ -933,13 +968,25 @@ captured_main (void *data) - /* Show time and/or space usage. */ - do_cleanups (pre_stat_chain); - -- /* NOTE: cagney/1999-11-07: There is probably no reason for not -- moving this loop and the code found in captured_command_loop() -- into the command_loop() proper. The main thing holding back that -- change - SET_TOP_LEVEL() - has been eliminated. */ -- while (1) -+#if HAVE_PYTHON -+ if (python_script) - { -- catch_errors (captured_command_loop, 0, "", RETURN_MASK_ALL); -+ extern int pagination_enabled; -+ pagination_enabled = 0; -+ run_python_script (argc - optind, &argv[optind]); -+ return 1; -+ } -+ else -+#endif -+ { -+ /* NOTE: cagney/1999-11-07: There is probably no reason for not -+ moving this loop and the code found in captured_command_loop() -+ into the command_loop() proper. The main thing holding back that -+ change - SET_TOP_LEVEL() - has been eliminated. */ -+ while (1) -+ { -+ catch_errors (captured_command_loop, 0, "", RETURN_MASK_ALL); -+ } - } - /* No exit -- exit is through quit_command. */ - } -@@ -971,7 +1018,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 (_("\ -@@ -1009,7 +1061,13 @@ Options:\n\n\ - --nw Do not use a window interface.\n\ - --nx Do not read "), stream); - fputs_unfiltered (gdbinit, stream); -- fputs_unfiltered (_(" file.\n\ -+ fputs_unfiltered (_(" file.\n"), stream); -+#if HAVE_PYTHON -+ fputs_unfiltered (_("\ -+ --python, -P Following argument is Python script file; remaining\n\ -+ arguments are passed to script.\n"), stream); -+#endif -+ fputs_unfiltered (_("\ - --quiet Do not print version number on startup.\n\ - --readnow Fully read symbol files on first access.\n\ - "), stream); -diff --git a/gdb/mi/mi-cmd-var.c b/gdb/mi/mi-cmd-var.c -index 4de7392..fb0b550 100644 ---- a/gdb/mi/mi-cmd-var.c -+++ b/gdb/mi/mi-cmd-var.c -@@ -721,7 +721,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/mipsread.c b/gdb/mipsread.c -index 5790730..23ceece 100644 ---- a/gdb/mipsread.c -+++ b/gdb/mipsread.c -@@ -401,6 +401,7 @@ static const struct sym_fns ecoff_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 - }; - -diff --git a/gdb/objfiles.c b/gdb/objfiles.c -index 1cf5aee..d1640ef 100644 ---- a/gdb/objfiles.c -+++ b/gdb/objfiles.c -@@ -811,6 +811,11 @@ objfile_relocate1 (struct objfile *objfile, - obj_section_addr (s)); - } - -+ /* Relocating SystemTap probes. */ -+ if (objfile->sf && objfile->sf->sym_probe_fns) -+ objfile->sf->sym_probe_fns->sym_relocate_probe (objfile, -+ new_offsets, delta); ++# Copyright (C) 2008, 2009 Free Software Foundation, Inc. + - /* Data changed. */ - return 1; - } -diff --git a/gdb/p-valprint.c b/gdb/p-valprint.c -index c5bef8a..fc3beb3 100644 ---- a/gdb/p-valprint.c -+++ b/gdb/p-valprint.c -@@ -39,6 +39,7 @@ - #include "cp-abi.h" - #include "cp-support.h" - #include "exceptions.h" -+#include "dwarf2loc.h" - - - /* See val_print for a description of the various parameters of this -@@ -63,8 +64,31 @@ 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); -+ address += embedded_offset; -+ 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 + embedded_offset) -+ { -+ 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, const gdb_byte *valaddr, - { - 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, 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); - } - -@@ -251,6 +276,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; - - break; -@@ -576,6 +602,7 @@ pascal_val_print (struct type *type, const gdb_byte *valaddr, - TYPE_CODE (type)); - } - gdb_flush (stream); -+ do_cleanups (back_to); - return (0); - } - -diff --git a/gdb/parse.c b/gdb/parse.c -index 32a3bd6..9eaf2de 100644 ---- a/gdb/parse.c -+++ b/gdb/parse.c -@@ -113,8 +113,6 @@ show_parserdebug (struct ui_file *file, int from_tty, - - static void free_funcalls (void *ignore); - --static int prefixify_expression (struct expression *); -- - static int prefixify_subexp (struct expression *, struct expression *, int, - int); - -@@ -188,7 +186,7 @@ free_funcalls (void *ignore) - the expout array. LANG is the language used to parse the expression. - And GDBARCH is the gdbarch to use during parsing. */ - --static void -+void - initialize_expout (int initial_size, const struct language_defn *lang, - struct gdbarch *gdbarch) - { -@@ -204,7 +202,7 @@ initialize_expout (int initial_size, const struct language_defn *lang, - It is generally used when the parser has just been parsed and - created. */ - --static void -+void - reallocate_expout (void) - { - /* Record the actual number of expression elements, and then -@@ -811,7 +809,7 @@ copy_name (struct stoken token) - return the index of the subexpression which is the left-hand-side - of the struct operation at EXPOUT_LAST_STRUCT. */ - --static int -+int - prefixify_expression (struct expression *expr) - { - int len = sizeof (struct expression) + EXP_ELEM_TO_BYTES (expr->nelts); -@@ -1529,6 +1527,7 @@ parser_fprintf (FILE *x, const char *y, ...) - - 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) -@@ -1570,7 +1569,7 @@ operator_check_standard (struct expression *exp, int pos, - struct type *type = elts[pos + 2 + arg].type; - struct objfile *objfile = TYPE_OBJFILE (type); - -- if (objfile && (*objfile_func) (objfile, data)) -+ if (objfile && objfile_func && (*objfile_func) (objfile, data)) - return 1; - } - } -@@ -1588,7 +1587,8 @@ operator_check_standard (struct expression *exp, int pos, - - /* Check objfile where the variable itself is placed. - SYMBOL_OBJ_SECTION (symbol) may be NULL. */ -- if ((*objfile_func) (SYMBOL_SYMTAB (symbol)->objfile, data)) -+ if (objfile_func -+ && (*objfile_func) (SYMBOL_SYMTAB (symbol)->objfile, data)) - return 1; - - /* Check objfile where is placed the code touching the variable. */ -@@ -1601,24 +1601,27 @@ operator_check_standard (struct expression *exp, int pos, - - /* Invoke callbacks for TYPE and OBJFILE if they were set as non-NULL. */ - -- if (type && TYPE_OBJFILE (type) -+ if (type && type_func && (*type_func) (type, data)) -+ return 1; -+ if (type && TYPE_OBJFILE (type) && objfile_func - && (*objfile_func) (TYPE_OBJFILE (type), data)) - return 1; -- 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) - { -@@ -1633,7 +1636,9 @@ exp_iterate (struct expression *exp, - - pos = endpos - oplen; - if (exp->language_defn->la_exp_desc->operator_check (exp, pos, -- objfile_func, data)) -+ type_func, -+ objfile_func, -+ data)) - return 1; - - endpos = pos; -@@ -1664,8 +1669,29 @@ exp_uses_objfile (struct expression *exp, struct objfile *objfile) - { - gdb_assert (objfile->separate_debug_objfile_backlink == NULL); - -- return exp_iterate (exp, exp_uses_objfile_iter, objfile); -+ return exp_iterate (exp, NULL, exp_uses_objfile_iter, objfile); -+} -+ -+/* Helper for exp_types_mark_used. */ ++# This program is free software; you can redistribute it and/or modify ++# it under the terms of the GNU General Public License as published by ++# the Free Software Foundation; either version 3 of the License, or ++# (at your option) any later version. ++# ++# This program is distributed in the hope that it will be useful, ++# but WITHOUT ANY WARRANTY; without even the implied warranty of ++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++# GNU General Public License for more details. ++# ++# You should have received a copy of the GNU General Public License ++# along with this program. If not, see . + -+#if 0 -+static int -+exp_types_mark_used_iter (struct type *type, void *unused) -+{ -+ type_mark_used (type); ++import gdb + -+ /* Continue the traversal. */ -+ return 0; -+} ++# FIXME: arguably all this should be on Frame somehow. ++class FrameWrapper: ++ def __init__ (self, frame): ++ self.frame = frame; + -+/* Call type_mark_used for any type contained in EXP. */ ++ 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 + -+void -+exp_types_mark_used (struct expression *exp) -+{ -+ exp_iterate (exp, exp_types_mark_used_iter, NULL, NULL); - } -+#endif - - void - _initialize_parse (void) -diff --git a/gdb/parser-defs.h b/gdb/parser-defs.h -index 16b40ac..c3813ff 100644 ---- a/gdb/parser-defs.h -+++ b/gdb/parser-defs.h -@@ -130,6 +130,24 @@ union type_stack_elt - extern union type_stack_elt *type_stack; - extern int type_stack_depth, type_stack_size; - -+/* Allocate and initialize `expout' and its related variables `expout_size' -+ and `expout_ptr'. ++ 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)) + -+ The first argument is the initial size to be used for xmalloc. The second -+ argument is the language related to the expression. The third argument is -+ corresponding gdbarch. */ ++ def print_frame_locals (self, stream, func): ++ if not func: ++ return + -+extern void initialize_expout (int, const struct language_defn *, -+ struct gdbarch *); ++ first = True ++ block = func.value + -+/* Reallocate `expout' in order to free excessive elements that might have -+ been created during the parsing. Set the number of elements -+ accordingly. */ ++ for sym in block: ++ if sym.is_argument: ++ continue; + -+extern void reallocate_expout (void); ++ self.write_symbol (stream, sym, block) ++ stream.write ('\n') + -+extern int prefixify_expression (struct expression *expr); ++ def print_frame_args (self, stream, func): ++ if not func: ++ return + - extern void write_exp_elt_opcode (enum exp_opcode); - - extern void write_exp_elt_sym (struct symbol *); -@@ -191,6 +209,8 @@ extern void operator_length_standard (const struct expression *, int, int *, - int *); - - 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); -@@ -277,6 +297,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); -@@ -315,4 +336,10 @@ extern void parser_fprintf (FILE *, const char *, ...) ATTRIBUTE_PRINTF (2, 3); - - extern int exp_uses_objfile (struct expression *exp, struct objfile *objfile); - -+extern int exp_uses_objfile (struct expression *exp, struct objfile *objfile); ++ first = True ++ block = func.value + -+#if 0 -+extern void exp_types_mark_used (struct expression *exp); -+#endif ++ for sym in block: ++ if not sym.is_argument: ++ continue; + - #endif /* PARSER_DEFS_H */ -diff --git a/gdb/ppc-linux-nat.c b/gdb/ppc-linux-nat.c -index af80919..3077c4b 100644 ---- a/gdb/ppc-linux-nat.c -+++ b/gdb/ppc-linux-nat.c -@@ -1468,14 +1468,13 @@ ppc_linux_can_use_hw_breakpoint (int type, int cnt, int ot) - if (!have_ptrace_booke_interface ()) - { - int tid; -- ptid_t ptid = inferior_ptid; - - /* We need to know whether ptrace supports PTRACE_SET_DEBUGREG - and whether the target has DABR. If either answer is no, the - ptrace call will return -1. Fail in that case. */ -- tid = TIDGET (ptid); -+ tid = TIDGET (inferior_ptid); - if (tid == 0) -- tid = PIDGET (ptid); -+ tid = PIDGET (inferior_ptid); - - if (ptrace (PTRACE_SET_DEBUGREG, tid, 0, 0) == -1) - return 0; -@@ -1566,8 +1565,9 @@ booke_find_thread_points_by_tid (int tid, int alloc_new) - /* This function is a generic wrapper that is responsible for inserting a - *point (i.e., calling `ptrace' in order to issue the request to the - kernel) and registering it internally in GDB. */ ++ if not first: ++ stream.write (", ") + - static void --booke_insert_point (struct ppc_hw_breakpoint *b, int tid) -+booke_insert_point (struct lwp_info *lp, struct ppc_hw_breakpoint *b) - { - int i; - long slot; -@@ -1580,12 +1580,12 @@ booke_insert_point (struct ppc_hw_breakpoint *b, int tid) - memcpy (p, b, sizeof (struct ppc_hw_breakpoint)); - - errno = 0; -- slot = ptrace (PPC_PTRACE_SETHWDEBUG, tid, 0, p); -+ slot = ptrace (PPC_PTRACE_SETHWDEBUG, TIDGET (lp->ptid), 0, p); - if (slot < 0) - perror_with_name (_("Unexpected error setting breakpoint or watchpoint")); - - /* Everything went fine, so we have to register this *point. */ -- t = booke_find_thread_points_by_tid (tid, 1); -+ t = booke_find_thread_points_by_tid (TIDGET (lp->ptid), 1); - gdb_assert (t != NULL); - hw_breaks = t->hw_breaks; - -@@ -1603,17 +1603,33 @@ booke_insert_point (struct ppc_hw_breakpoint *b, int tid) - discard_cleanups (c); - } - --/* This function is a generic wrapper that is responsible for removing a -- *point (i.e., calling `ptrace' in order to issue the request to the -- kernel), and unregistering it internally at GDB. */ --static void --booke_remove_point (struct ppc_hw_breakpoint *b, int tid) -+/* Callback for linux_nat_iterate_watchpoint_lwps -+ calling booke_insert_point. */ ++ self.write_symbol (stream, sym, block) ++ first = False + -+static int -+booke_insert_point_callback (struct lwp_info *lp, void *b_voidp) - { -+ struct ppc_hw_breakpoint *b = b_voidp; ++ # FIXME: this should probably just be a method on gdb.Frame. ++ # But then we need stream wrappers. ++ def describe (self, stream, full): ++ if self.type () == gdb.DUMMY_FRAME: ++ stream.write (" \n") ++ elif self.type () == gdb.SIGTRAMP_FRAME: ++ stream.write (" \n") ++ else: ++ sal = self.find_sal () ++ pc = self.pc () ++ name = self.name () ++ if not name: ++ name = "??" ++ if pc != sal.pc or not sal.symtab: ++ stream.write (" 0x%08x in" % pc) ++ stream.write (" " + name + " (") + -+ booke_insert_point (lp, b); ++ func = self.function () ++ self.print_frame_args (stream, func) + -+ /* Continue the traversal. */ -+ return 0; -+} ++ stream.write (")") + -+/* This function is a callback for linux_nat_iterate_watchpoint_lwps that is -+ responsible for removing a *point (i.e., calling `ptrace' in order to issue -+ the request to the kernel), and unregistering it internally at GDB. */ ++ if sal.symtab and sal.symtab.filename: ++ stream.write (" at " + sal.symtab.filename) ++ stream.write (":" + str (sal.line)) + -+static int -+booke_remove_point_callback (struct lwp_info *lp, void *b_voidp) -+{ -+ struct ppc_hw_breakpoint *b = b_voidp; - int i; - struct hw_break_tuple *hw_breaks; - struct thread_points *t; - -- t = booke_find_thread_points_by_tid (tid, 0); -+ t = booke_find_thread_points_by_tid (TIDGET (lp->ptid), 0); - gdb_assert (t != NULL); - hw_breaks = t->hw_breaks; - -@@ -1627,13 +1643,17 @@ booke_remove_point (struct ppc_hw_breakpoint *b, int tid) - breakpoints/watchpoints as "one-shot", that is, they are automatically - deleted when hit. */ - errno = 0; -- if (ptrace (PPC_PTRACE_DELHWDEBUG, tid, 0, hw_breaks[i].slot) < 0) -+ if (ptrace (PPC_PTRACE_DELHWDEBUG, TIDGET (lp->ptid), 0, hw_breaks[i].slot) -+ < 0) - if (errno != ENOENT) - perror_with_name (_("Unexpected error deleting " - "breakpoint or watchpoint")); - - xfree (hw_breaks[i].hw_break); - hw_breaks[i].hw_break = NULL; ++ if not self.name () or (not sal.symtab or not sal.symtab.filename): ++ lib = gdb.solib_address (pc) ++ if lib: ++ stream.write (" from " + lib) + -+ /* Continue the traversal. */ -+ return 0; - } - - /* Return the number of registers needed for a ranged breakpoint. */ -@@ -1653,7 +1673,6 @@ static int - ppc_linux_insert_hw_breakpoint (struct gdbarch *gdbarch, - struct bp_target_info *bp_tgt) - { -- struct lwp_info *lp; - struct ppc_hw_breakpoint p; - - if (!have_ptrace_booke_interface ()) -@@ -1679,8 +1698,7 @@ ppc_linux_insert_hw_breakpoint (struct gdbarch *gdbarch, - p.addr2 = 0; - } - -- ALL_LWPS (lp) -- booke_insert_point (&p, TIDGET (lp->ptid)); -+ linux_nat_iterate_watchpoint_lwps (booke_insert_point_callback, &p); - - return 0; - } -@@ -1689,7 +1707,6 @@ static int - ppc_linux_remove_hw_breakpoint (struct gdbarch *gdbarch, - struct bp_target_info *bp_tgt) - { -- struct lwp_info *lp; - struct ppc_hw_breakpoint p; - - if (!have_ptrace_booke_interface ()) -@@ -1715,8 +1732,7 @@ ppc_linux_remove_hw_breakpoint (struct gdbarch *gdbarch, - p.addr2 = 0; - } - -- ALL_LWPS (lp) -- booke_remove_point (&p, TIDGET (lp->ptid)); -+ linux_nat_iterate_watchpoint_lwps (booke_remove_point_callback, &p); - - return 0; - } -@@ -1745,7 +1761,6 @@ static int - ppc_linux_insert_mask_watchpoint (struct target_ops *ops, CORE_ADDR addr, - CORE_ADDR mask, int rw) - { -- struct lwp_info *lp; - struct ppc_hw_breakpoint p; - - gdb_assert (have_ptrace_booke_interface ()); -@@ -1758,8 +1773,7 @@ ppc_linux_insert_mask_watchpoint (struct target_ops *ops, CORE_ADDR addr, - p.addr2 = mask; - p.condition_value = 0; - -- ALL_LWPS (lp) -- booke_insert_point (&p, TIDGET (lp->ptid)); -+ linux_nat_iterate_watchpoint_lwps (booke_insert_point_callback, &p); - - return 0; - } -@@ -1773,7 +1787,6 @@ static int - ppc_linux_remove_mask_watchpoint (struct target_ops *ops, CORE_ADDR addr, - CORE_ADDR mask, int rw) - { -- struct lwp_info *lp; - struct ppc_hw_breakpoint p; - - gdb_assert (have_ptrace_booke_interface ()); -@@ -1786,8 +1799,7 @@ ppc_linux_remove_mask_watchpoint (struct target_ops *ops, CORE_ADDR addr, - p.addr2 = mask; - p.condition_value = 0; - -- ALL_LWPS (lp) -- booke_remove_point (&p, TIDGET (lp->ptid)); -+ linux_nat_iterate_watchpoint_lwps (booke_remove_point_callback, &p); - - return 0; - } -@@ -1797,10 +1809,16 @@ static int - can_use_watchpoint_cond_accel (void) - { - struct thread_points *p; -- int tid = TIDGET (inferior_ptid); - int cnt = booke_debug_info.num_condition_regs, i; - CORE_ADDR tmp_value; - -+ /* Overload thread id onto process id. */ -+ int tid = TIDGET (inferior_ptid); ++ stream.write ("\n") + -+ /* No thread id, just use process id. */ -+ if (tid == 0) -+ tid = PIDGET (inferior_ptid); ++ if full: ++ self.print_frame_locals (stream, func) + - if (!have_ptrace_booke_interface () || cnt == 0) - return 0; - -@@ -1999,6 +2017,22 @@ ppc_linux_can_accel_watchpoint_condition (CORE_ADDR addr, int len, int rw, - && check_condition (addr, cond, &data_value, &len)); - } - -+/* Callback for linux_nat_iterate_watchpoint_lwps setting RETP_VOIDP by -+ PTRACE_SET_DEBUGREG for LP. */ ++ def __getattr__ (self, name): ++ return getattr (self.frame, name) +diff --git a/gdb/python/lib/gdb/backtrace.py b/gdb/python/lib/gdb/backtrace.py +new file mode 100644 +index 0000000..6bb4fb1 +--- /dev/null ++++ b/gdb/python/lib/gdb/backtrace.py +@@ -0,0 +1,42 @@ ++# Filtering backtrace. + -+static int -+set_saved_dabr_value_callback (struct lwp_info *lp, void *retp_voidp) -+{ -+ int *retp = retp_voidp; ++# Copyright (C) 2008, 2011 Free Software Foundation, Inc. + -+ if (ptrace (PTRACE_SET_DEBUGREG, TIDGET (lp->ptid), 0, saved_dabr_value) -+ < 0) -+ *retp = -1; ++# This program is free software; you can redistribute it and/or modify ++# it under the terms of the GNU General Public License as published by ++# the Free Software Foundation; either version 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 . + -+ /* Continue the traversal. */ -+ return 0; -+} ++import gdb ++import itertools + - /* 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 -@@ -2054,7 +2088,6 @@ static int - ppc_linux_insert_watchpoint (CORE_ADDR addr, int len, int rw, - struct expression *cond) - { -- struct lwp_info *lp; - int ret = -1; - - if (have_ptrace_booke_interface ()) -@@ -2063,8 +2096,7 @@ ppc_linux_insert_watchpoint (CORE_ADDR addr, int len, int rw, - - create_watchpoint_request (&p, addr, len, rw, cond, 1); - -- ALL_LWPS (lp) -- booke_insert_point (&p, TIDGET (lp->ptid)); -+ linux_nat_iterate_watchpoint_lwps (booke_insert_point_callback, &p); - - ret = 0; - } -@@ -2107,12 +2139,8 @@ ppc_linux_insert_watchpoint (CORE_ADDR addr, int len, int rw, - - saved_dabr_value = dabr_value; - -- ALL_LWPS (lp) -- if (ptrace (PTRACE_SET_DEBUGREG, TIDGET (lp->ptid), 0, -- saved_dabr_value) < 0) -- return -1; -- - ret = 0; -+ linux_nat_iterate_watchpoint_lwps (set_saved_dabr_value_callback, &ret); - } - - return ret; -@@ -2122,7 +2150,6 @@ static int - ppc_linux_remove_watchpoint (CORE_ADDR addr, int len, int rw, - struct expression *cond) - { -- struct lwp_info *lp; - int ret = -1; - - if (have_ptrace_booke_interface ()) -@@ -2131,20 +2158,16 @@ ppc_linux_remove_watchpoint (CORE_ADDR addr, int len, int rw, - - create_watchpoint_request (&p, addr, len, rw, cond, 0); - -- ALL_LWPS (lp) -- booke_remove_point (&p, TIDGET (lp->ptid)); -+ linux_nat_iterate_watchpoint_lwps (booke_remove_point_callback, &p); - - ret = 0; - } - else - { - saved_dabr_value = 0; -- ALL_LWPS (lp) -- if (ptrace (PTRACE_SET_DEBUGREG, TIDGET (lp->ptid), 0, -- saved_dabr_value) < 0) -- return -1; - - ret = 0; -+ linux_nat_iterate_watchpoint_lwps (set_saved_dabr_value_callback, &ret); - } - - return ret; -@@ -2171,7 +2194,7 @@ ppc_linux_new_thread (struct lwp_info *lp) - /* Copy that thread's breakpoints and watchpoints to the new thread. */ - for (i = 0; i < max_slots_number; i++) - if (hw_breaks[i].hw_break) -- booke_insert_point (hw_breaks[i].hw_break, tid); -+ booke_insert_point (lp, hw_breaks[i].hw_break); - } - else - ptrace (PTRACE_SET_DEBUGREG, tid, 0, saved_dabr_value); -@@ -2229,7 +2252,14 @@ ppc_linux_stopped_data_address (struct target_ops *target, CORE_ADDR *addr_p) - /* The index (or slot) of the *point is passed in the si_errno field. */ - int slot = siginfo_p->si_errno; - -- t = booke_find_thread_points_by_tid (TIDGET (inferior_ptid), 0); -+ /* Overload thread id onto process id. */ -+ int tid = TIDGET (inferior_ptid); -+ -+ /* No thread id, just use process id. */ -+ if (tid == 0) -+ tid = PIDGET (inferior_ptid); -+ -+ t = booke_find_thread_points_by_tid (tid, 0); - - /* Find out if this *point is a hardware breakpoint. - If so, we should return 0. */ -diff --git a/gdb/ppc-linux-tdep.c b/gdb/ppc-linux-tdep.c -index b6470fe..f871309 100644 ---- a/gdb/ppc-linux-tdep.c -+++ b/gdb/ppc-linux-tdep.c -@@ -65,6 +65,14 @@ - #include "features/rs6000/powerpc-isa205-vsx64l.c" - #include "features/rs6000/powerpc-e500l.c" - -+#include "stap-probe.h" -+#include "ax.h" -+#include "ax-gdb.h" -+#include "cli/cli-utils.h" -+#include "parser-defs.h" -+#include "user-regs.h" -+#include -+ - /* The syscall's XML filename for PPC and PPC64. */ - #define XML_SYSCALL_FILENAME_PPC "syscalls/ppc-linux.xml" - #define XML_SYSCALL_FILENAME_PPC64 "syscalls/ppc64-linux.xml" -@@ -1192,6 +1200,65 @@ ppc_linux_core_read_description (struct gdbarch *gdbarch, - } - } - -+static int -+ppc_stap_is_single_operand (struct gdbarch *gdbarch, const char *s) -+{ -+ return (*s == 'i' /* Literal number. */ -+ || (isdigit (*s) && s[1] == '(' -+ && isdigit (s[2])) /* Displacement. */ -+ || (*s == '(' && isdigit (s[1])) /* Register indirection. */ -+ || isdigit (*s)); /* Register value. */ -+} ++# Our only exports. ++__all__ = ['push_frame_filter', 'create_frame_filter'] + -+static int -+ppc_stap_parse_special_token (struct gdbarch *gdbarch, -+ struct stap_parse_info *p) -+{ -+ if (isdigit (*p->arg)) -+ { -+ /* This temporary pointer is needed because we have to do a lookahead. -+ We could be dealing with a register displacement, and in such case -+ we would not need to do anything. */ -+ const char *s = p->arg; -+ char *regname; -+ int len; -+ struct stoken str; -+ -+ while (isdigit (*s)) -+ ++s; -+ -+ if (*s == '(') -+ /* It is a register displacement indeed. Returning 0 means we are -+ deferring the treatment of this case to the generic parser. */ -+ return 0; -+ -+ len = s - p->arg; -+ regname = alloca (len + 2); -+ regname[0] = 'r'; -+ -+ strncpy (regname + 1, p->arg, len); -+ ++len; -+ regname[len] = '\0'; -+ -+ if (user_reg_map_name_to_regnum (gdbarch, regname, len) == -1) -+ error (_("Invalid register name `%s' on expression `%s'."), -+ regname, p->saved_arg); -+ -+ write_exp_elt_opcode (OP_REGISTER); -+ str.ptr = regname; -+ str.length = len; -+ write_exp_string (str); -+ write_exp_elt_opcode (OP_REGISTER); -+ -+ p->arg = s; -+ } -+ else -+ /* All the other tokens should be handled correctly by the generic -+ parser. */ -+ return 0; ++frame_filter = None + -+ return 1; -+} - - /* Cell/B.E. active SPE context tracking support. */ - -@@ -1509,6 +1576,15 @@ ppc_linux_init_abi (struct gdbarch_info info, - /* Get the syscall number from the arch's register. */ - set_gdbarch_get_syscall_number (gdbarch, ppc_linux_get_syscall_number); - -+ /* SystemTap functions. */ -+ set_gdbarch_stap_integer_prefix (gdbarch, "i"); -+ set_gdbarch_stap_register_indirection_prefix (gdbarch, "("); -+ set_gdbarch_stap_register_indirection_sufix (gdbarch, ")"); -+ set_gdbarch_stap_gdb_register_prefix (gdbarch, "r"); -+ set_gdbarch_stap_is_single_operand (gdbarch, ppc_stap_is_single_operand); -+ set_gdbarch_stap_parse_special_token (gdbarch, -+ ppc_stap_parse_special_token); ++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)) + - if (tdep->wordsize == 4) - { - /* Until November 2001, gcc did not comply with the 32 bit SysV -diff --git a/gdb/printcmd.c b/gdb/printcmd.c -index bee8a85..00f332d 100644 ---- a/gdb/printcmd.c -+++ b/gdb/printcmd.c -@@ -49,6 +49,7 @@ - #include "charset.h" - #include "arch-utils.h" - #include "cli/cli-utils.h" -+#include "dwarf2loc.h" - - #ifdef TUI - #include "tui/tui.h" /* For tui_active et al. */ -@@ -971,6 +972,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. */ ++def create_frame_filter (iter): ++ global frame_filter ++ if frame_filter is None: ++ return iter ++ return frame_filter (iter) + - if (voidprint || (val && value_type (val) && - TYPE_CODE (value_type (val)) != TYPE_CODE_VOID)) - { -@@ -1059,6 +1065,9 @@ output_command (char *exp, int from_tty) - - val = evaluate_expression (expr); - -+ if (VALUE_LVAL (val) == lval_memory) -+ object_address_set (value_raw_address (val)); +diff --git a/gdb/python/lib/gdb/command/backtrace.py b/gdb/python/lib/gdb/command/backtrace.py +new file mode 100644 +index 0000000..eeea909 +--- /dev/null ++++ b/gdb/python/lib/gdb/command/backtrace.py +@@ -0,0 +1,106 @@ ++# New backtrace command. + - annotate_value_begin (value_type (val)); - - get_formatted_print_options (&opts, format); -@@ -1472,6 +1481,24 @@ x_command (char *exp, int from_tty) - set_internalvar (lookup_internalvar ("__"), last_examine_value); - } - } ++# Copyright (C) 2008, 2009, 2011 Free Software Foundation, Inc. + -+#if 0 -+/* Call type_mark_used for any TYPEs referenced from this GDB source file. */ ++# This program is free software; you can redistribute it and/or modify ++# it under the terms of the GNU General Public License as published by ++# the Free Software Foundation; either version 3 of the License, or ++# (at your option) any later version. ++# ++# This program is distributed in the hope that it will be useful, ++# but WITHOUT ANY WARRANTY; without even the implied warranty of ++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++# GNU General Public License for more details. ++# ++# You should have received a copy of the GNU General Public License ++# along with this program. If not, see . + -+static void -+print_types_mark_used (void) -+{ -+ struct display *d; ++import gdb ++import gdb.backtrace ++import itertools ++from gdb.FrameIterator import FrameIterator ++from gdb.FrameWrapper import FrameWrapper ++import sys + -+ if (last_examine_value) -+ type_mark_used (value_type (last_examine_value)); ++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.""" + -+ for (d = display_chain; d; d = d->next) -+ if (d->exp) -+ exp_types_mark_used (d->exp); -+} -+#endif ++ set_doc = "Enable or disable reverse backtraces." ++ show_doc = "Show whether backtraces will be printed in reverse order." + - - - /* Add an expression to the auto-display chain. -@@ -1971,6 +1998,10 @@ print_variable_and_value (const char *name, struct symbol *var, - struct value_print_options opts; - - val = read_var_value (var, frame); ++ def __init__(self): ++ gdb.Parameter.__init__ (self, "reverse-backtrace", ++ gdb.COMMAND_STACK, gdb.PARAM_BOOLEAN) ++ # Default to compatibility with gdb. ++ self.value = False + -+ make_cleanup_restore_selected_frame (); -+ select_frame (frame); ++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. ++""" + - get_user_print_options (&opts); - opts.deref_ref = 1; - common_val_print (val, stream, indent, &opts, current_language); -@@ -2884,4 +2915,8 @@ Show printing of source filename and line number with ."), NULL, - add_com ("eval", no_class, eval_command, _("\ - Convert \"printf format string\", arg1, arg2, arg3, ..., argn to\n\ - a command line, and call it.")); ++ 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() + -+#if 0 -+ observer_attach_mark_used (print_types_mark_used); -+#endif - } -diff --git a/gdb/python/lib/gdb/FrameIterator.py b/gdb/python/lib/gdb/FrameIterator.py ++ def reverse_iter (self, iter): ++ result = [] ++ for item in iter: ++ result.append (item) ++ result.reverse() ++ return result ++ ++ def final_n (self, iter, x): ++ result = [] ++ for item in iter: ++ result.append (item) ++ return result[x:] ++ ++ def invoke (self, arg, from_tty): ++ i = 0 ++ count = 0 ++ filter = True ++ full = False ++ ++ for word in arg.split (" "): ++ if word == '': ++ continue ++ elif word == 'raw': ++ filter = False ++ elif word == 'full': ++ full = True ++ else: ++ count = int (word) ++ ++ # FIXME: provide option to start at selected frame ++ # However, should still number as if starting from newest ++ newest_frame = gdb.newest_frame() ++ iter = itertools.imap (FrameWrapper, ++ FrameIterator (newest_frame)) ++ if filter: ++ iter = gdb.backtrace.create_frame_filter (iter) ++ ++ # Now wrap in an iterator that numbers the frames. ++ iter = itertools.izip (itertools.count (0), iter) ++ ++ # Reverse if the user wanted that. ++ if self.reverse.value: ++ iter = self.reverse_iter (iter) ++ ++ # Extract sub-range user wants. ++ if count < 0: ++ iter = self.final_n (iter, count) ++ elif count > 0: ++ iter = itertools.islice (iter, 0, count) ++ ++ for pair in iter: ++ sys.stdout.write ("#%-2d" % pair[0]) ++ pair[1].describe (sys.stdout, full) ++ ++FilteringBacktrace() +diff --git a/gdb/python/lib/gdb/command/ignore_errors.py b/gdb/python/lib/gdb/command/ignore_errors.py new file mode 100644 -index 0000000..5654546 +index 0000000..6fa48ff --- /dev/null -+++ b/gdb/python/lib/gdb/FrameIterator.py -@@ -0,0 +1,33 @@ -+# Iterator over frames. ++++ b/gdb/python/lib/gdb/command/ignore_errors.py +@@ -0,0 +1,37 @@ ++# Ignore errors in user commands. + -+# Copyright (C) 2008, 2009 Free Software Foundation, Inc. ++# Copyright (C) 2008 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by @@ -7382,29 +4356,33 @@ index 0000000..5654546 +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + -+class FrameIterator: -+ """An iterator that iterates over frames.""" ++import gdb + -+ def __init__ (self, frame): -+ "Initialize a FrameIterator. FRAME is the starting frame." -+ self.frame = frame ++class IgnoreErrorsCommand (gdb.Command): ++ """Execute a single command, ignoring all errors. ++Only one-line commands are supported. ++This is primarily useful in scripts.""" + -+ def __iter__ (self): -+ return self ++ def __init__ (self): ++ super (IgnoreErrorsCommand, self).__init__ ("ignore-errors", ++ gdb.COMMAND_OBSCURE, ++ # FIXME... ++ gdb.COMPLETE_COMMAND) + -+ 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 ++ def invoke (self, arg, from_tty): ++ try: ++ gdb.execute (arg, from_tty) ++ except: ++ pass ++ ++IgnoreErrorsCommand () +diff --git a/gdb/python/lib/gdb/command/pahole.py b/gdb/python/lib/gdb/command/pahole.py new file mode 100644 -index 0000000..b790a54 +index 0000000..21a0bf0 --- /dev/null -+++ b/gdb/python/lib/gdb/FrameWrapper.py -@@ -0,0 +1,112 @@ -+# Wrapper API for frames. ++++ b/gdb/python/lib/gdb/command/pahole.py +@@ -0,0 +1,75 @@ ++# pahole command for gdb + +# Copyright (C) 2008, 2009 Free Software Foundation, Inc. + @@ -7423,108 +4401,71 @@ index 0000000..b790a54 + +import gdb + -+# FIXME: arguably all this should be on Frame somehow. -+class FrameWrapper: -+ def __init__ (self, frame): -+ self.frame = frame; ++class Pahole (gdb.Command): ++ """Show the holes in a structure. ++This command takes a single argument, a type name. ++It prints the type and displays comments showing where holes are.""" + -+ def 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 ++ def __init__ (self): ++ super (Pahole, self).__init__ ("pahole", gdb.COMMAND_NONE, ++ gdb.COMPLETE_SYMBOL) + -+ stream.write (sym.print_name + "=") -+ try: -+ val = self.read_var (sym) -+ if val != None: -+ val = str (val) -+ # FIXME: would be nice to have a more precise exception here. -+ except RuntimeError, text: -+ val = text -+ if val == None: -+ stream.write ("???") -+ else: -+ stream.write (str (val)) -+ -+ def print_frame_locals (self, stream, func): -+ if not func: -+ return -+ -+ first = True -+ block = func.value -+ -+ for sym in block: -+ if sym.is_argument: -+ continue; -+ -+ self.write_symbol (stream, sym, block) -+ stream.write ('\n') -+ -+ def print_frame_args (self, stream, func): -+ if not func: -+ return -+ -+ first = True -+ block = func.value -+ -+ for sym in block: -+ if not sym.is_argument: -+ continue; -+ -+ if not first: -+ stream.write (", ") -+ -+ self.write_symbol (stream, sym, block) -+ first = False -+ -+ # FIXME: this should probably just be a method on gdb.Frame. -+ # But then we need stream wrappers. -+ def describe (self, stream, full): -+ if self.type () == gdb.DUMMY_FRAME: -+ stream.write (" \n") -+ elif self.type () == gdb.SIGTRAMP_FRAME: -+ stream.write (" \n") -+ else: -+ sal = self.find_sal () -+ pc = self.pc () -+ name = self.name () -+ if not name: -+ name = "??" -+ if pc != sal.pc or not sal.symtab: -+ stream.write (" 0x%08x in" % pc) -+ stream.write (" " + name + " (") ++ 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 + -+ func = self.function () -+ self.print_frame_args (stream, func) ++ ftype = field.type.strip_typedefs() + -+ stream.write (")") ++ 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 + -+ if sal.symtab and sal.symtab.filename: -+ stream.write (" at " + sal.symtab.filename) -+ stream.write (":" + str (sal.line)) ++ # TARGET_CHAR_BIT ++ print ' /* %3d %3d */' % (int (bitpos / 8), int (fieldsize / 8)), ++ bitpos = bitpos + fieldsize + -+ if not self.name () or (not sal.symtab or not sal.symtab.filename): -+ lib = gdb.solib_address (pc) -+ if lib: -+ stream.write (" from " + lib) ++ 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) + -+ stream.write ("\n") ++ print ' ' * (14 + 2 * level), ++ print '} %s' % name + -+ if full: -+ self.print_frame_locals (stream, func) ++ 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, '') + -+ def __getattr__ (self, name): -+ return getattr (self.frame, name) -diff --git a/gdb/python/lib/gdb/backtrace.py b/gdb/python/lib/gdb/backtrace.py ++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..6bb4fb1 +index 0000000..1fbc1e8 --- /dev/null -+++ b/gdb/python/lib/gdb/backtrace.py -@@ -0,0 +1,42 @@ -+# Filtering backtrace. ++++ b/gdb/python/lib/gdb/command/require.py +@@ -0,0 +1,57 @@ ++# Demand-loading commands. + -+# Copyright (C) 2008, 2011 Free Software Foundation, Inc. ++# Copyright (C) 2008, 2009 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by @@ -7540,39 +4481,54 @@ index 0000000..6bb4fb1 +# along with this program. If not, see . + +import gdb -+import itertools ++import os + -+# Our only exports. -+__all__ = ['push_frame_filter', 'create_frame_filter'] ++class RequireCommand (gdb.Command): ++ """Prefix command for requiring features.""" + -+frame_filter = None ++ def __init__ (self): ++ super (RequireCommand, self).__init__ ("require", ++ gdb.COMMAND_SUPPORT, ++ gdb.COMPLETE_NONE, ++ True) + -+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)) ++class RequireSubcommand (gdb.Command): ++ """Demand-load a command by name.""" + -+def create_frame_filter (iter): -+ global frame_filter -+ if frame_filter is None: -+ return iter -+ return frame_filter (iter) ++ 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 + -diff --git a/gdb/python/lib/gdb/command/backtrace.py b/gdb/python/lib/gdb/command/backtrace.py ++ def invoke (self, arg, from_tty): ++ for cmd in arg.split(): ++ exec ('import gdb.' + self.name + '.' + cmd, globals ()) ++ ++ def complete (self, text, word): ++ dir = gdb.pythondir + '/gdb/' + self.name ++ result = [] ++ for file in os.listdir(dir): ++ if not file.startswith (word) or not file.endswith ('.py'): ++ continue ++ feature = file[0:-3] ++ if feature == 'require' or feature == '__init__': ++ continue ++ result.append (feature) ++ return result ++ ++RequireCommand() ++RequireSubcommand("command") ++RequireSubcommand("function") +diff --git a/gdb/python/lib/gdb/command/upto.py b/gdb/python/lib/gdb/command/upto.py new file mode 100644 -index 0000000..eeea909 +index 0000000..faf54ed --- /dev/null -+++ b/gdb/python/lib/gdb/command/backtrace.py -@@ -0,0 +1,106 @@ -+# New backtrace command. ++++ b/gdb/python/lib/gdb/command/upto.py +@@ -0,0 +1,129 @@ ++# upto command. + -+# Copyright (C) 2008, 2009, 2011 Free Software Foundation, Inc. ++# Copyright (C) 2009 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by @@ -7588,146 +4544,133 @@ index 0000000..eeea909 +# along with this program. If not, see . + +import gdb -+import gdb.backtrace -+import itertools ++import re +from gdb.FrameIterator import FrameIterator +from gdb.FrameWrapper import FrameWrapper -+import sys + -+class ReverseBacktraceParameter (gdb.Parameter): -+ """The new-backtrace command can show backtraces in 'reverse' order. -+This means that the innermost frame will be printed last. -+Note that reverse backtraces are more expensive to compute.""" ++class UptoPrefix (gdb.Command): ++ def __init__ (self): ++ super (UptoPrefix, self).__init__ ("upto", gdb.COMMAND_STACK, ++ prefix = True) + -+ set_doc = "Enable or disable reverse backtraces." -+ show_doc = "Show whether backtraces will be printed in reverse order." ++class UptoImplementation (gdb.Command): ++ def __init__ (self, subcommand): ++ super (UptoImplementation, self).__init__ ("upto " + subcommand, ++ gdb.COMMAND_STACK) + -+ def __init__(self): -+ gdb.Parameter.__init__ (self, "reverse-backtrace", -+ gdb.COMMAND_STACK, gdb.PARAM_BOOLEAN) -+ # Default to compatibility with gdb. -+ self.value = False ++ 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' + -+class FilteringBacktrace (gdb.Command): -+ """Print backtrace of all stack frames, or innermost COUNT frames. -+With a negative argument, print outermost -COUNT frames. -+Use of the 'full' qualifier also prints the values of the local variables. -+Use of the 'raw' qualifier avoids any filtering by loadable modules. -+""" ++ def invoke (self, arg, from_tty): ++ self.rx = re.compile (arg) ++ self.search () + -+ 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() ++class UptoSymbolCommand (UptoImplementation): ++ """Select and print some calling stack frame, based on symbol. ++The argument is a regular expression. This command moves up the ++stack, stopping at the first frame whose symbol matches the regular ++expression.""" + -+ def reverse_iter (self, iter): -+ result = [] -+ for item in iter: -+ result.append (item) -+ result.reverse() -+ return result ++ def __init__ (self): ++ super (UptoSymbolCommand, self).__init__ ("symbol") + -+ def final_n (self, iter, x): -+ result = [] -+ for item in iter: -+ result.append (item) -+ return result[x:] -+ -+ def invoke (self, arg, from_tty): -+ i = 0 -+ count = 0 -+ filter = True -+ full = False -+ -+ for word in arg.split (" "): -+ if word == '': -+ continue -+ elif word == 'raw': -+ filter = False -+ elif word == 'full': -+ full = True -+ else: -+ count = int (word) -+ -+ # FIXME: provide option to start at selected frame -+ # However, should still number as if starting from newest -+ newest_frame = gdb.newest_frame() -+ iter = itertools.imap (FrameWrapper, -+ FrameIterator (newest_frame)) -+ if filter: -+ iter = gdb.backtrace.create_frame_filter (iter) -+ -+ # Now wrap in an iterator that numbers the frames. -+ iter = itertools.izip (itertools.count (0), iter) -+ -+ # Reverse if the user wanted that. -+ if self.reverse.value: -+ iter = self.reverse_iter (iter) ++ def filter (self, frame): ++ name = frame.name () ++ if name is not None: ++ if self.rx.search (name) is not None: ++ return True ++ return False + -+ # Extract sub-range user wants. -+ if count < 0: -+ iter = self.final_n (iter, count) -+ elif count > 0: -+ iter = itertools.islice (iter, 0, count) ++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.""" + -+ for pair in iter: -+ sys.stdout.write ("#%-2d" % pair[0]) -+ pair[1].describe (sys.stdout, full) ++ def __init__ (self): ++ super (UptoSourceCommand, self).__init__ ("source") + -+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. ++ 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 + -+# Copyright (C) 2008 Free Software Foundation, Inc. ++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.""" + -+# This program is free software; you can redistribute it and/or modify -+# it under the terms of the 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 . ++ def __init__ (self): ++ super (UptoObjectCommand, self).__init__ ("object") + -+import gdb ++ def filter (self, frame): ++ name = frame.find_sal ().symtab.objfile.filename ++ if name is not None: ++ if self.rx.search (name) is not None: ++ return True ++ return False + -+class IgnoreErrorsCommand (gdb.Command): -+ """Execute a single command, ignoring all errors. -+Only one-line commands are supported. -+This is primarily useful in scripts.""" ++class UptoWhereCommand (UptoImplementation): ++ """Select and print some calling stack frame, based on expression. ++The argument is an expression. This command moves up the stack, ++parsing and evaluating the expression in each frame. This stops when ++the expression evaluates to a non-zero (true) value.""" + + def __init__ (self): -+ super (IgnoreErrorsCommand, self).__init__ ("ignore-errors", -+ gdb.COMMAND_OBSCURE, -+ # FIXME... -+ gdb.COMPLETE_COMMAND) ++ super (UptoWhereCommand, self).__init__ ("where") + -+ def invoke (self, arg, from_tty): ++ def filter (self, frame): + try: -+ gdb.execute (arg, from_tty) ++ if gdb.parse_and_eval (self.expression): ++ return True + except: + pass ++ return False + -+IgnoreErrorsCommand () -diff --git a/gdb/python/lib/gdb/command/pahole.py b/gdb/python/lib/gdb/command/pahole.py ++ def invoke (self, arg, from_tty): ++ self.expression = arg ++ self.search () ++ ++UptoPrefix () ++UptoSymbolCommand () ++UptoSourceCommand () ++UptoObjectCommand () ++UptoWhereCommand () +diff --git a/gdb/python/lib/gdb/function/__init__.py b/gdb/python/lib/gdb/function/__init__.py new file mode 100644 -index 0000000..21a0bf0 +index 0000000..8b13789 --- /dev/null -+++ b/gdb/python/lib/gdb/command/pahole.py -@@ -0,0 +1,75 @@ -+# pahole command for gdb ++++ b/gdb/python/lib/gdb/function/__init__.py +@@ -0,0 +1 @@ + -+# Copyright (C) 2008, 2009 Free Software Foundation, Inc. +diff --git a/gdb/python/lib/gdb/function/caller_is.py b/gdb/python/lib/gdb/function/caller_is.py +new file mode 100644 +index 0000000..2b9c5c7 +--- /dev/null ++++ b/gdb/python/lib/gdb/function/caller_is.py +@@ -0,0 +1,58 @@ ++# Caller-is functions. ++ ++# Copyright (C) 2008 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by @@ -7743,72 +4686,55 @@ index 0000000..21a0bf0 +# along with this program. If not, see . + +import gdb ++import re + -+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.""" ++class CallerIs (gdb.Function): ++ """Return True if the calling function's name is equal to a string. ++This function takes one or two arguments. ++The first argument is the name of a function; if the calling function's ++name is equal to this argument, this function returns True. ++The optional second argument tells this function how many stack frames ++to traverse to find the calling function. The default is 1.""" + + def __init__ (self): -+ super (Pahole, self).__init__ ("pahole", gdb.COMMAND_NONE, -+ gdb.COMPLETE_SYMBOL) -+ -+ def pahole (self, type, level, name): -+ if name is None: -+ name = '' -+ tag = type.tag -+ if tag is None: -+ tag = '' -+ print '%sstruct %s {' % (' ' * (2 * level), tag) -+ bitpos = 0 -+ for field in type.fields (): -+ # Skip static fields. -+ if not hasattr (field, ('bitpos')): -+ continue -+ -+ ftype = field.type.strip_typedefs() -+ -+ if bitpos != field.bitpos: -+ hole = field.bitpos - bitpos -+ print ' /* XXX %d bit hole, try to pack */' % hole -+ bitpos = field.bitpos -+ if field.bitsize > 0: -+ fieldsize = field.bitsize -+ else: -+ # TARGET_CHAR_BIT here... -+ fieldsize = 8 * ftype.sizeof ++ super (CallerIs, self).__init__ ("caller_is") + -+ # TARGET_CHAR_BIT -+ print ' /* %3d %3d */' % (int (bitpos / 8), int (fieldsize / 8)), -+ bitpos = bitpos + fieldsize ++ def invoke (self, name, nframes = 1): ++ frame = gdb.selected_frame () ++ while nframes > 0: ++ frame = frame.older () ++ nframes = nframes - 1 ++ return frame.name () == name.string () + -+ 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) ++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.""" + -+ print ' ' * (14 + 2 * level), -+ print '} %s' % name ++ def __init__ (self): ++ super (CallerMatches, self).__init__ ("caller_matches") + -+ 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, '') ++ 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 + -+Pahole() -diff --git a/gdb/python/lib/gdb/command/require.py b/gdb/python/lib/gdb/command/require.py ++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..1fbc1e8 +index 0000000..debb3bb --- /dev/null -+++ b/gdb/python/lib/gdb/command/require.py -@@ -0,0 +1,57 @@ -+# Demand-loading commands. ++++ b/gdb/python/lib/gdb/function/in_scope.py +@@ -0,0 +1,47 @@ ++# In-scope function. + -+# Copyright (C) 2008, 2009 Free Software Foundation, Inc. ++# Copyright (C) 2008 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by @@ -7824,4549 +4750,872 @@ index 0000000..1fbc1e8 +# along with this program. If not, see . + +import gdb -+import os + -+class RequireCommand (gdb.Command): -+ """Prefix command for requiring features.""" ++class InScope (gdb.Function): ++ """Return True if all the given variables or macros are in scope. ++Takes one argument for each variable name to be checked.""" + + def __init__ (self): -+ super (RequireCommand, self).__init__ ("require", -+ gdb.COMMAND_SUPPORT, -+ gdb.COMPLETE_NONE, -+ True) ++ super (InScope, self).__init__ ("in_scope") + -+class RequireSubcommand (gdb.Command): -+ """Demand-load a command by name.""" ++ def invoke (self, *vars): ++ if len (vars) == 0: ++ raise TypeError, "in_scope takes at least one argument" + -+ def __init__ (self, name): -+ self.__doc__ = "Demand-load a %s by name." % name -+ super (RequireSubcommand, self).__init__ ("require %s" % name, -+ gdb.COMMAND_SUPPORT) -+ self.name = name -+ -+ def invoke (self, arg, from_tty): -+ for cmd in arg.split(): -+ exec ('import gdb.' + self.name + '.' + cmd, globals ()) -+ -+ def complete (self, text, word): -+ dir = gdb.pythondir + '/gdb/' + self.name -+ result = [] -+ for file in os.listdir(dir): -+ if not file.startswith (word) or not file.endswith ('.py'): -+ continue -+ feature = file[0:-3] -+ if feature == 'require' or feature == '__init__': -+ continue -+ result.append (feature) -+ return result -+ -+RequireCommand() -+RequireSubcommand("command") -+RequireSubcommand("function") -diff --git a/gdb/python/lib/gdb/command/upto.py b/gdb/python/lib/gdb/command/upto.py -new file mode 100644 -index 0000000..faf54ed ---- /dev/null -+++ b/gdb/python/lib/gdb/command/upto.py -@@ -0,0 +1,129 @@ -+# upto command. -+ -+# Copyright (C) 2009 Free Software Foundation, Inc. -+ -+# This program is free software; you can redistribute it and/or modify -+# it under the terms of the GNU General Public License as published by -+# the Free Software Foundation; either version 3 of the License, or -+# (at your option) any later version. -+# -+# This program is distributed in the hope that it will be useful, -+# but WITHOUT ANY WARRANTY; without even the implied warranty of -+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+# GNU General Public License for more details. -+# -+# You should have received a copy of the GNU General Public License -+# along with this program. If not, see . -+ -+import gdb -+import re -+from gdb.FrameIterator import FrameIterator -+from gdb.FrameWrapper import FrameWrapper -+ -+class UptoPrefix (gdb.Command): -+ def __init__ (self): -+ super (UptoPrefix, self).__init__ ("upto", gdb.COMMAND_STACK, -+ prefix = True) ++ # 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) + -+class UptoImplementation (gdb.Command): -+ def __init__ (self, subcommand): -+ super (UptoImplementation, self).__init__ ("upto " + subcommand, -+ gdb.COMMAND_STACK) ++ block = block.superblock + -+ 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' ++ return wanted == found + -+ def invoke (self, arg, from_tty): -+ self.rx = re.compile (arg) -+ self.search () ++InScope () +diff --git a/gdb/python/py-type.c b/gdb/python/py-type.c +index 98030a6..9870eec 100644 +--- a/gdb/python/py-type.c ++++ b/gdb/python/py-type.c +@@ -30,6 +30,8 @@ + #include "vec.h" + #include "bcache.h" + #include "dwarf2loc.h" ++#include "observer.h" ++#include "gdb_assert.h" + + typedef struct pyty_type_object + { +@@ -38,11 +40,19 @@ 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. + -+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.""" ++ 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 + -+ def __init__ (self): -+ super (UptoSymbolCommand, self).__init__ ("symbol") + static PyTypeObject type_object_type; + + /* A Field object. */ +@@ -1166,8 +1176,63 @@ typy_richcompare (PyObject *self, PyObject *other, int op) + + + ++/* 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; + -+ def filter (self, frame): -+ name = frame.name () -+ if name is not None: -+ if self.rx.search (name) is not None: -+ return True -+ return False ++ if (type_obj->type && TYPE_OBJFILE (type_obj->type)) ++ { ++ struct objfile *objfile = TYPE_OBJFILE (type_obj->type); + -+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.""" ++ 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); ++ } ++#if 0 ++ 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; ++ } ++#endif ++ else ++ type_obj->next = NULL; ++} + -+ def __init__ (self): -+ super (UptoSourceCommand, self).__init__ ("source") ++/* 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); + -+ 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 ++ 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 + -+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 (type_obj->next) ++ type_obj->next->prev = type_obj->prev; ++} + -+ def __init__ (self): -+ super (UptoObjectCommand, self).__init__ ("object") + static void + save_objfile_types (struct objfile *objfile, void *datum) + { +@@ -1185,12 +1250,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; + } +@@ -1201,43 +1267,28 @@ 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); + -+ 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 ++ type_obj->ob_type->tp_free (obj); + } + ++#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; + +- 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 + + /* Return number of fields ("length" of the field dictionary). */ + +@@ -1457,7 +1508,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; + } +@@ -1537,6 +1591,10 @@ gdbpy_initialize_types (void) + + Py_INCREF (&field_object_type); + PyModule_AddObject (gdb_module, "Field", (PyObject *) &field_object_type); + -+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.""" ++#if 0 ++ observer_attach_mark_used (typy_types_mark_used); ++#endif + } + + +diff --git a/gdb/python/py-value.c b/gdb/python/py-value.c +index 6f67bdb..5ddd6bc 100644 +--- a/gdb/python/py-value.c ++++ b/gdb/python/py-value.c +@@ -29,6 +29,7 @@ + #include "expression.h" + #include "cp-abi.h" + #include "python.h" ++#include "observer.h" + + #ifdef HAVE_PYTHON + +@@ -1378,6 +1379,19 @@ gdbpy_is_value_object (PyObject *obj) + return PyObject_TypeCheck (obj, &value_object_type); + } + ++#if 0 ++/* Call type_mark_used for any TYPEs referenced from this GDB source file. */ + -+ def __init__ (self): -+ super (UptoWhereCommand, self).__init__ ("where") ++static void ++python_types_mark_used (void) ++{ ++ value_object *iter; + -+ def filter (self, frame): -+ try: -+ if gdb.parse_and_eval (self.expression): -+ return True -+ except: -+ pass -+ return False ++ for (iter = values_in_python; iter; iter = iter->next) ++ type_mark_used (value_type (iter->value)); ++} ++#endif + -+ def invoke (self, arg, from_tty): -+ self.expression = arg -+ self.search () + void + gdbpy_initialize_values (void) + { +@@ -1388,6 +1402,10 @@ gdbpy_initialize_values (void) + PyModule_AddObject (gdb_module, "Value", (PyObject *) &value_object_type); + + values_in_python = NULL; + -+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 @@ ++#if 0 ++ observer_attach_mark_used (python_types_mark_used); ++#endif + } + + +diff --git a/gdb/python/python.c b/gdb/python/python.c +index 19eb7b5..0e7256e 100644 +--- a/gdb/python/python.c ++++ b/gdb/python/python.c +@@ -66,10 +66,13 @@ static const char *gdbpy_should_print_stack = python_excp_message; + #include "linespec.h" + #include "source.h" + #include "version.h" ++#include "inferior.h" ++#include "gdbthread.h" + #include "target.h" + #include "gdbthread.h" + #include "observer.h" + #include "interps.h" ++#include "event-top.h" + + static PyMethodDef GdbMethods[]; + +@@ -974,6 +977,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; + -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. ++/* True if we are currently in a call to 'gdb.cli', false otherwise. */ ++static int in_cli; + -+# Copyright (C) 2008 Free Software Foundation, Inc. ++/* Enter the command loop. */ + -+# This program is free software; you can redistribute it and/or modify -+# it under the terms of the GNU General Public License as published by -+# the Free Software Foundation; either version 3 of the License, or -+# (at your option) any later version. -+# -+# This program is distributed in the hope that it will be useful, -+# but WITHOUT ANY WARRANTY; without even the implied warranty of -+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+# GNU General Public License for more details. -+# -+# You should have received a copy of the GNU General Public License -+# along with this program. If not, see . ++static PyObject * ++gdbpy_cli (PyObject *unused1, PyObject *unused2) ++{ ++ if (! running_python_script || in_cli) ++ return PyErr_Format (PyExc_RuntimeError, "cannot invoke CLI recursively"); + -+import gdb -+import re ++ in_cli = 1; ++ cli_command_loop (); ++ in_cli = 0; + -+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.""" ++ Py_RETURN_NONE; ++} + -+ def __init__ (self): -+ super (CallerIs, self).__init__ ("caller_is") ++/* Set up the Python argument vector and evaluate a script. This is ++ used to implement 'gdb -P'. */ + -+ def invoke (self, name, nframes = 1): -+ frame = gdb.selected_frame () -+ while nframes > 0: -+ frame = frame.older () -+ nframes = nframes - 1 -+ return frame.name () == name.string () ++void ++run_python_script (int argc, char **argv) ++{ ++ FILE *input; + -+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.""" ++ /* We never free this, since we plan to exit at the end. */ ++ ensure_python_env (get_current_arch (), current_language); + -+ def __init__ (self): -+ super (CallerMatches, self).__init__ ("caller_matches") ++ 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); ++} + -+ def invoke (self, name, nframes = 1): -+ frame = gdb.selected_frame () -+ while nframes > 0: -+ frame = frame.older () -+ nframes = nframes - 1 -+ return re.match (name.string (), frame.name ()) is not None ++ + -+CallerIs() -+CallerMatches() -diff --git a/gdb/python/lib/gdb/function/in_scope.py b/gdb/python/lib/gdb/function/in_scope.py -new file mode 100644 -index 0000000..debb3bb ---- /dev/null -+++ b/gdb/python/lib/gdb/function/in_scope.py -@@ -0,0 +1,47 @@ -+# In-scope function. + + static PyObject * + gdbpy_get_current_progspace (PyObject *unused1, PyObject *unused2) +@@ -1415,6 +1465,8 @@ static PyMethodDef GdbMethods[] = + "Get a value from history" }, + { "execute", (PyCFunction) execute_gdb_command, METH_VARARGS | METH_KEYWORDS, + "Execute a gdb command" }, ++ { "cli", gdbpy_cli, METH_NOARGS, ++ "Enter the gdb CLI" }, + { "parameter", gdbpy_parameter, METH_VARARGS, + "Return a gdb parameter's value" }, + +diff --git a/gdb/python/python.h b/gdb/python/python.h +index dd7066f..f0f6e90 100644 +--- a/gdb/python/python.h ++++ b/gdb/python/python.h +@@ -30,6 +30,8 @@ void eval_python_from_control_command (struct command_line *); + + void source_python_script (FILE *file, const char *filename); + ++void run_python_script (int argc, char **argv); + -+# Copyright (C) 2008 Free Software Foundation, Inc. -+ -+# This program is free software; you can redistribute it and/or modify -+# it under the terms of the GNU General Public License as published by -+# the Free Software Foundation; either version 3 of the License, or -+# (at your option) any later version. -+# -+# This program is distributed in the hope that it will be useful, -+# but WITHOUT ANY WARRANTY; without even the implied warranty of -+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+# GNU General Public License for more details. -+# -+# You should have received a copy of the GNU General Public License -+# along with this program. If not, see . -+ -+import gdb -+ -+class InScope (gdb.Function): -+ """Return True if all the given variables or macros are in scope. -+Takes one argument for each variable name to be checked.""" -+ -+ def __init__ (self): -+ super (InScope, self).__init__ ("in_scope") -+ -+ def invoke (self, *vars): -+ if len (vars) == 0: -+ raise TypeError, "in_scope takes at least one argument" -+ -+ # gdb.Value isn't hashable so it can't be put in a map. -+ # Convert to string first. -+ wanted = set (map (lambda x: x.string (), vars)) -+ found = set () -+ block = gdb.selected_frame ().block () -+ while block: -+ for sym in block: -+ if (sym.is_argument or sym.is_constant -+ or sym.is_function or sym.is_variable): -+ if sym.name in wanted: -+ found.add (sym.name) -+ -+ block = block.superblock -+ -+ return wanted == found -+ -+InScope () -diff --git a/gdb/python/py-type.c b/gdb/python/py-type.c -index dadb037..864da99 100644 ---- a/gdb/python/py-type.c -+++ b/gdb/python/py-type.c -@@ -30,6 +30,8 @@ - #include "vec.h" - #include "bcache.h" - #include "dwarf2loc.h" -+#include "observer.h" -+#include "gdb_assert.h" - - typedef struct pyty_type_object - { -@@ -38,11 +40,19 @@ 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; - -+#if 0 -+/* First element of a doubly-linked list of TYPE_DISCARDABLE Types. */ -+static type_object *pyty_objects_discardable; -+#endif -+ - static PyTypeObject type_object_type; - - /* A Field object. */ -@@ -1150,8 +1160,63 @@ typy_richcompare (PyObject *self, PyObject *other, int op) - - - -+/* 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; + 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/stack.c b/gdb/stack.c +index 02e36ca..066407f 100644 +--- a/gdb/stack.c ++++ b/gdb/stack.c +@@ -509,6 +509,10 @@ print_frame_args (struct symbol *func, struct frame_info *frame, + stb = mem_fileopen (); + old_chain = make_cleanup_ui_file_delete (stb); -+/* Link TYPE_OBJ to its appropriate list. Either to its objfile associated one -+ or at least to the global list for TYPE_DISCARDABLE Types. Permanent types -+ do not get linked anywhere. */ -+static void -+typy_link (type_object *type_obj) -+{ -+ type_obj->prev = NULL; -+ -+ if (type_obj->type && TYPE_OBJFILE (type_obj->type)) -+ { -+ struct objfile *objfile = TYPE_OBJFILE (type_obj->type); -+ -+ type_obj->next = objfile_data (objfile, typy_objfile_data_key); -+ if (type_obj->next) -+ type_obj->next->prev = type_obj; -+ set_objfile_data (objfile, typy_objfile_data_key, type_obj); -+ } -+#if 0 -+ 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; -+ } -+#endif -+ else -+ type_obj->next = NULL; -+} -+ -+/* Unlink TYPE_OBJ from its current list. Permanent types are not linked -+ anywhere and this function has no effect on them. */ -+static void -+typy_unlink (type_object *type_obj) -+{ -+ if (type_obj->prev) -+ type_obj->prev->next = type_obj->next; -+ else if (type_obj->type && TYPE_OBJFILE (type_obj->type)) -+ { -+ /* Must reset head of list. */ -+ struct objfile *objfile = TYPE_OBJFILE (type_obj->type); -+ -+ set_objfile_data (objfile, typy_objfile_data_key, type_obj->next); -+ } -+#if 0 -+ else if (pyty_objects_discardable == type_obj) -+ pyty_objects_discardable = type_obj->next; -+#endif -+ -+ if (type_obj->next) -+ type_obj->next->prev = type_obj->prev; -+} ++ /* Frame may be needed for check_typedef of TYPE_DYNAMIC. */ ++ make_cleanup_restore_selected_frame (); ++ select_frame (frame); + - static void - save_objfile_types (struct objfile *objfile, void *datum) - { -@@ -1169,12 +1234,13 @@ save_objfile_types (struct objfile *objfile, void *datum) + if (func) { - 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; + struct block *b = SYMBOL_BLOCK_VALUE (func); +diff --git a/gdb/testsuite/gdb.ada/packed_array.exp b/gdb/testsuite/gdb.ada/packed_array.exp +index 678639c..47a2202 100644 +--- a/gdb/testsuite/gdb.ada/packed_array.exp ++++ b/gdb/testsuite/gdb.ada/packed_array.exp +@@ -60,5 +60,11 @@ gdb_test_multiple "$test" "$test" { + # are. Observed with (FSF GNU Ada 4.5.3 20110124). + xfail $test } -@@ -1185,43 +1251,28 @@ 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); - } - -+#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; - -- 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 - - /* Return number of fields ("length" of the field dictionary). */ - -@@ -1444,7 +1495,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); ++ -re "= \\(\\)\[\r\n\]+$gdb_prompt $" { ++ # archer-jankratochvil-vla resolves it as a dynamic type resolved as an ++ # empty array [0..-1]. ++ # DW_AT_upper_bound : (DW_OP_fbreg: -48; DW_OP_deref) ++ xfail $test + } - - return (PyObject *) type_obj; - } -@@ -1524,6 +1578,10 @@ gdbpy_initialize_types (void) - - 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 } - -diff --git a/gdb/python/py-value.c b/gdb/python/py-value.c -index 760360e..d935f54 100644 ---- a/gdb/python/py-value.c -+++ b/gdb/python/py-value.c -@@ -28,6 +28,7 @@ - #include "infcall.h" - #include "expression.h" - #include "cp-abi.h" -+#include "observer.h" - - #ifdef HAVE_PYTHON - -@@ -1335,6 +1336,19 @@ gdbpy_is_value_object (PyObject *obj) - return PyObject_TypeCheck (obj, &value_object_type); - } - -+#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)); -+} +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 +@@ -0,0 +1,457 @@ ++ .file "x86_64-vla-pointer.c" ++ .section .debug_abbrev,"",@progbits ++.Ldebug_abbrev0: ++ .section .debug_info,"",@progbits ++.Ldebug_info0: ++ .section .debug_line,"",@progbits ++.Ldebug_line0: ++ .text ++.Ltext0: ++.globl foo ++ .type foo, @function ++foo: ++.LFB2: ++ .file 1 "x86_64-vla-pointer.c" ++ .loc 1 22 0 ++ pushq %rbp ++.LCFI0: ++ movq %rsp, %rbp ++.LCFI1: ++ subq $64, %rsp ++.LCFI2: ++ movl %edi, -36(%rbp) ++ .loc 1 22 0 ++ movq %rsp, %rax ++ movq %rax, -48(%rbp) ++ .loc 1 23 0 ++ movl -36(%rbp), %edx ++ movslq %edx,%rax ++ subq $1, %rax ++ movq %rax, -24(%rbp) ++ .loc 1 24 0 ++ movslq %edx,%rax ++ addq $15, %rax ++ addq $15, %rax ++ shrq $4, %rax ++ salq $4, %rax ++ subq %rax, %rsp ++ movq %rsp, -56(%rbp) ++ movq -56(%rbp), %rax ++ addq $15, %rax ++ shrq $4, %rax ++ salq $4, %rax ++ movq %rax, -56(%rbp) ++ movq -56(%rbp), %rax ++ movq %rax, -16(%rbp) ++ .loc 1 27 0 ++ movl $0, -4(%rbp) ++ jmp .L2 ++.L3: ++ .loc 1 28 0 ++ movl -4(%rbp), %esi ++ movl -4(%rbp), %eax ++ movl %eax, %ecx ++ movq -16(%rbp), %rdx ++ movslq %esi,%rax ++ movb %cl, (%rdx,%rax) ++ .loc 1 27 0 ++ addl $1, -4(%rbp) ++.L2: ++ movl -4(%rbp), %eax ++ cmpl -36(%rbp), %eax ++ jl .L3 ++ .loc 1 30 0 ++ .globl break_here ++break_here: ++ movq -16(%rbp), %rax ++ movb $0, (%rax) ++ movq -48(%rbp), %rsp ++ .loc 1 31 0 ++ leave ++ ret ++.LFE2: ++ .size foo, .-foo ++ .section .debug_frame,"",@progbits ++.Lframe0: ++ .long .LECIE0-.LSCIE0 ++.LSCIE0: ++ .long 0xffffffff ++ .byte 0x1 ++ .string "" ++ .uleb128 0x1 ++ .sleb128 -8 ++ .byte 0x10 ++ .byte 0xc ++ .uleb128 0x7 ++ .uleb128 0x8 ++ .byte 0x90 ++ .uleb128 0x1 ++ .align 8 ++.LECIE0: ++.LSFDE0: ++ .long .LEFDE0-.LASFDE0 ++.LASFDE0: ++ .long .Lframe0 ++ .quad .LFB2 ++ .quad .LFE2-.LFB2 ++ .byte 0x4 ++ .long .LCFI0-.LFB2 ++ .byte 0xe ++ .uleb128 0x10 ++ .byte 0x86 ++ .uleb128 0x2 ++ .byte 0x4 ++ .long .LCFI1-.LCFI0 ++ .byte 0xd ++ .uleb128 0x6 ++ .align 8 ++.LEFDE0: ++ .section .eh_frame,"a",@progbits ++.Lframe1: ++ .long .LECIE1-.LSCIE1 ++.LSCIE1: ++ .long 0x0 ++ .byte 0x1 ++ .string "zR" ++ .uleb128 0x1 ++ .sleb128 -8 ++ .byte 0x10 ++ .uleb128 0x1 ++ .byte 0x3 ++ .byte 0xc ++ .uleb128 0x7 ++ .uleb128 0x8 ++ .byte 0x90 ++ .uleb128 0x1 ++ .align 8 ++.LECIE1: ++.LSFDE1: ++ .long .LEFDE1-.LASFDE1 ++.LASFDE1: ++ .long .LASFDE1-.Lframe1 ++ .long .LFB2 ++ .long .LFE2-.LFB2 ++ .uleb128 0x0 ++ .byte 0x4 ++ .long .LCFI0-.LFB2 ++ .byte 0xe ++ .uleb128 0x10 ++ .byte 0x86 ++ .uleb128 0x2 ++ .byte 0x4 ++ .long .LCFI1-.LCFI0 ++ .byte 0xd ++ .uleb128 0x6 ++ .align 8 ++.LEFDE1: ++ .text ++.Letext0: ++ .section .debug_loc,"",@progbits ++.Ldebug_loc0: ++.LLST0: ++ .quad .LFB2-.Ltext0 ++ .quad .LCFI0-.Ltext0 ++ .value 0x2 ++ .byte 0x77 ++ .sleb128 8 ++ .quad .LCFI0-.Ltext0 ++ .quad .LCFI1-.Ltext0 ++ .value 0x2 ++ .byte 0x77 ++ .sleb128 16 ++ .quad .LCFI1-.Ltext0 ++ .quad .LFE2-.Ltext0 ++ .value 0x2 ++ .byte 0x76 ++ .sleb128 16 ++ .quad 0x0 ++ .quad 0x0 ++ .section .debug_info ++.Ldebug_relative: ++ .long .Ldebug_end - .Ldebug_start ++.Ldebug_start: ++ .value 0x2 ++ .long .Ldebug_abbrev0 ++ .byte 0x8 ++ .uleb128 0x1 ++ .long .LASF2 ++ .byte 0x1 ++ .long .LASF3 ++ .long .LASF4 ++ .quad .Ltext0 ++ .quad .Letext0 ++ .long .Ldebug_line0 ++ .uleb128 0x2 ++ .byte 0x1 ++ .string "foo" ++ .byte 0x1 ++ .byte 0x16 ++ .byte 0x1 ++ .quad .LFB2 ++ .quad .LFE2 ++ .long .LLST0 ++ .long .Ltype_int - .Ldebug_relative ++ .uleb128 0x3 ++ .long .LASF5 ++ .byte 0x1 ++ .byte 0x15 ++ .long .Ltype_int - .Ldebug_relative ++ .byte 0x2 ++ .byte 0x91 ++ .sleb128 -52 ++.Ltag_pointer: ++ .uleb128 0x4 ++ .byte 0x8 /* DW_AT_byte_size */ ++ .long .Ltag_array_type - .debug_info /* DW_AT_type */ ++ .uleb128 0x5 /* Abbrev Number: 5 (DW_TAG_variable) */ ++ .long .LASF0 ++ .byte 0x1 ++ .byte 0x18 ++#if 1 ++ .long .Ltag_pointer - .debug_info ++#else ++ /* Debugging only: Skip the typedef indirection. */ ++ .long .Ltag_array_type - .debug_info +#endif -+ - void - gdbpy_initialize_values (void) - { -@@ -1345,6 +1359,10 @@ gdbpy_initialize_values (void) - PyModule_AddObject (gdb_module, "Value", (PyObject *) &value_object_type); - - values_in_python = NULL; -+ ++ /* DW_AT_location: DW_FORM_block1: start */ ++ .byte 0x3 ++ .byte 0x91 ++ .sleb128 -32 +#if 0 -+ observer_attach_mark_used (python_types_mark_used); ++ .byte 0x6 /* DW_OP_deref */ ++#else ++ .byte 0x96 /* DW_OP_nop */ +#endif - } - - -diff --git a/gdb/python/python.c b/gdb/python/python.c -index 5a0d776..af01dfd 100644 ---- a/gdb/python/python.c -+++ b/gdb/python/python.c -@@ -66,10 +66,13 @@ static const char *gdbpy_should_print_stack = python_excp_message; - #include "linespec.h" - #include "source.h" - #include "version.h" -+#include "inferior.h" -+#include "gdbthread.h" - #include "target.h" - #include "gdbthread.h" - #include "observer.h" - #include "interps.h" -+#include "event-top.h" - - static PyMethodDef GdbMethods[]; - -@@ -946,6 +949,53 @@ gdbpy_print_stack (void) - - /* Return the current Progspace. - There always is one. */ -+/* True if 'gdb -P' was used, false otherwise. */ -+static int running_python_script; -+ -+/* True if we are currently in a call to 'gdb.cli', false otherwise. */ -+static int in_cli; -+ -+/* Enter the command loop. */ -+ -+static PyObject * -+gdbpy_cli (PyObject *unused1, PyObject *unused2) -+{ -+ if (! running_python_script || in_cli) -+ return PyErr_Format (PyExc_RuntimeError, "cannot invoke CLI recursively"); -+ -+ in_cli = 1; -+ cli_command_loop (); -+ in_cli = 0; -+ -+ Py_RETURN_NONE; -+} -+ -+/* Set up the Python argument vector and evaluate a script. This is -+ used to implement 'gdb -P'. */ -+ -+void -+run_python_script (int argc, char **argv) -+{ -+ FILE *input; -+ -+ /* We never free this, since we plan to exit at the end. */ -+ ensure_python_env (get_current_arch (), current_language); -+ -+ running_python_script = 1; -+ PySys_SetArgv (argc - 1, argv + 1); -+ input = fopen (argv[0], "r"); -+ if (! input) -+ { -+ fprintf (stderr, "could not open %s: %s\n", argv[0], strerror (errno)); -+ exit (1); -+ } -+ PyRun_SimpleFile (input, argv[0]); -+ fclose (input); -+ exit (0); -+} -+ -+ -+ - - static PyObject * - gdbpy_get_current_progspace (PyObject *unused1, PyObject *unused2) -@@ -1386,6 +1436,8 @@ static PyMethodDef GdbMethods[] = - "Get a value from history" }, - { "execute", (PyCFunction) execute_gdb_command, METH_VARARGS | METH_KEYWORDS, - "Execute a gdb command" }, -+ { "cli", gdbpy_cli, METH_NOARGS, -+ "Enter the gdb CLI" }, - { "parameter", gdbpy_parameter, METH_VARARGS, - "Return a gdb parameter's value" }, - -diff --git a/gdb/python/python.h b/gdb/python/python.h -index 9e461f7..57b21da 100644 ---- a/gdb/python/python.h -+++ b/gdb/python/python.h -@@ -32,6 +32,8 @@ void eval_python_from_control_command (struct command_line *); - - void source_python_script (const char *file); - -+void run_python_script (int argc, char **argv); -+ - int apply_val_pretty_printer (struct type *type, const gdb_byte *valaddr, - int embedded_offset, CORE_ADDR address, - struct ui_file *stream, int recurse, -diff --git a/gdb/remote.c b/gdb/remote.c -index f348536..e20f6bf 100644 ---- a/gdb/remote.c -+++ b/gdb/remote.c -@@ -9948,7 +9948,7 @@ remote_download_tracepoint (struct bp_location *loc) - char **stepping_actions; - int ndx; - struct cleanup *old_chain = NULL; -- struct agent_expr *aexpr; -+ struct agent_expr *aexpr = NULL; - struct cleanup *aexpr_chain = NULL; - char *pkt; - struct breakpoint *b = loc->owner; -diff --git a/gdb/s390-nat.c b/gdb/s390-nat.c -index 2755e58..8df3fd1 100644 ---- a/gdb/s390-nat.c -+++ b/gdb/s390-nat.c -@@ -515,6 +515,17 @@ s390_fix_watch_points (struct lwp_info *lp) - perror_with_name (_("Couldn't modify watchpoint status")); - } - -+/* Callback for iterate_over_lwps, to call s390_fix_watch_points. */ -+ -+static int -+s390_fix_watch_points_iterate (struct lwp_info *lp, void *arg) -+{ -+ s390_fix_watch_points (lp); -+ -+ /* Continue the traversal. */ -+ return 0; -+} -+ - static int - s390_insert_watchpoint (CORE_ADDR addr, int len, int type, - struct expression *cond) -@@ -531,8 +542,8 @@ s390_insert_watchpoint (CORE_ADDR addr, int len, int type, - area->next = watch_base; - watch_base = area; - -- ALL_LWPS (lp) -- s390_fix_watch_points (lp); -+ iterate_over_lwps (minus_one_ptid, s390_fix_watch_points_iterate, NULL); -+ - return 0; - } - -@@ -559,8 +570,8 @@ s390_remove_watchpoint (CORE_ADDR addr, int len, int type, - *parea = area->next; - xfree (area); - -- ALL_LWPS (lp) -- s390_fix_watch_points (lp); -+ iterate_over_lwps (minus_one_ptid, s390_fix_watch_points_iterate, NULL); -+ - return 0; - } - -diff --git a/gdb/s390-tdep.c b/gdb/s390-tdep.c -index ac0c526..dd0e477 100644 ---- a/gdb/s390-tdep.c -+++ b/gdb/s390-tdep.c -@@ -55,6 +55,12 @@ - #include "features/s390x-linux64v1.c" - #include "features/s390x-linux64v2.c" - -+#include "stap-probe.h" -+#include "ax.h" -+#include "ax-gdb.h" -+#include "user-regs.h" -+#include "cli/cli-utils.h" -+#include - - /* The tdep structure. */ - -@@ -2953,6 +2959,15 @@ s390_address_class_name_to_type_flags (struct gdbarch *gdbarch, - return 0; - } - -+static int -+s390_stap_is_single_operand (struct gdbarch *gdbarch, const char *s) -+{ -+ return ((isdigit (*s) && s[1] == '(' && s[2] == '%') /* Displacement -+ or indirection. */ -+ || *s == '%' /* Register access. */ -+ || isdigit (*s)); /* Literal number. */ -+} -+ - /* Set up gdbarch struct. */ - - static struct gdbarch * -@@ -3283,6 +3298,12 @@ s390_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) - - set_gdbarch_get_siginfo_type (gdbarch, linux_get_siginfo_type); - -+ /* SystemTap functions. */ -+ set_gdbarch_stap_register_prefix (gdbarch, "%"); -+ set_gdbarch_stap_register_indirection_prefix (gdbarch, "("); -+ set_gdbarch_stap_register_indirection_sufix (gdbarch, ")"); -+ set_gdbarch_stap_is_single_operand (gdbarch, s390_stap_is_single_operand); -+ - return gdbarch; - } - -diff --git a/gdb/somread.c b/gdb/somread.c -index e621cba..19a15e2 100644 ---- a/gdb/somread.c -+++ b/gdb/somread.c -@@ -427,6 +427,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 - }; - -diff --git a/gdb/stack.c b/gdb/stack.c -index b15b5fc..b2dad29 100644 ---- a/gdb/stack.c -+++ b/gdb/stack.c -@@ -509,6 +509,10 @@ print_frame_args (struct symbol *func, struct frame_info *frame, - stb = ui_out_stream_new (uiout); - old_chain = make_cleanup_ui_out_stream_delete (stb); - -+ /* Frame may be needed for check_typedef of TYPE_DYNAMIC. */ -+ make_cleanup_restore_selected_frame (); -+ select_frame (frame); -+ - if (func) - { - struct block *b = SYMBOL_BLOCK_VALUE (func); -diff --git a/gdb/stap-probe.c b/gdb/stap-probe.c -new file mode 100644 -index 0000000..123530f ---- /dev/null -+++ b/gdb/stap-probe.c -@@ -0,0 +1,1672 @@ -+/* 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 . */ -+ -+#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 "gdbcmd.h" -+#include "filenames.h" -+#include "value.h" -+#include "exceptions.h" -+#include "ax.h" -+#include "ax-gdb.h" -+#include "complaints.h" -+#include "cli/cli-utils.h" -+#include "linespec.h" -+#include "user-regs.h" -+#include "parser-defs.h" -+#include "language.h" -+ -+#include -+ -+/* The maximum number of arguments that a probe can have, -+ as defined in . */ -+ -+#define STAP_MAX_ARGS 12 -+ -+/* Should we display debug information for the probe's argument expression -+ parsing? */ -+ -+static int stap_expression_debug = 0; -+ -+/* The various possibilities of bitness defined for a probe's argument. -+ -+ The relationship is: -+ -+ - 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 -+{ -+ STAP_ARG_BITNESS_UNDEFINED, -+ STAP_ARG_BITNESS_32BIT_UNSIGNED, -+ STAP_ARG_BITNESS_32BIT_SIGNED, -+ STAP_ARG_BITNESS_64BIT_UNSIGNED, -+ STAP_ARG_BITNESS_64BIT_SIGNED, -+}; -+ -+/* The following structure represents a single argument for the probe. */ -+ -+struct stap_probe_arg -+{ -+ /* The bitness of this argument. */ -+ enum stap_arg_bitness bitness; -+ -+ /* The corresponding `struct type *' to the bitness. */ -+ struct type *atype; -+ -+ /* The argument converted to an internal GDB expression. */ -+ struct expression *aexpr; -+}; -+ -+/* Structure that holds information about all arguments of a probe. */ -+ -+struct stap_args_info -+{ -+ /* The number of valid parsed arguments. */ -+ int n_args; -+ -+ /* The probe to which these arguments belong. */ -+ struct stap_probe *probe; -+ -+ /* Information about each argument. This is an array of `stap_probe_arg', -+ with each entry representing one argument. */ -+ struct stap_probe_arg *args; -+}; -+ -+/* When parsing the arguments, we have to establish different precedences -+ for the various kinds of asm operators. This enumeration represents those -+ precedences. -+ -+ This logic behind this is available at -+ , or using -+ the command "info '(as)Infix Ops'". */ -+ -+enum stap_operand_prec -+{ -+ /* Lowest precedence, used for non-recognized operands or for the beginning -+ of the parsing process. */ -+ STAP_OPERAND_PREC_NONE = 0, -+ -+ /* Precedence of logical OR. */ -+ STAP_OPERAND_PREC_LOGICAL_OR, -+ -+ /* Precedence of logical AND. */ -+ STAP_OPERAND_PREC_LOGICAL_AND, -+ -+ /* Precedence of additive (plus, minus) and comparative (equal, less, -+ greater-than, etc) operands. */ -+ STAP_OPERAND_PREC_ADD_CMP, -+ -+ /* Precedence of bitwise operands (bitwise OR, XOR, bitwise AND, -+ logical NOT). */ -+ STAP_OPERAND_PREC_BITWISE, -+ -+ /* Precedence of multiplicative operands (multiplication, division, -+ remainder, left shift and right shift). */ -+ STAP_OPERAND_PREC_MUL -+}; -+ -+/* 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. */ -+ -+static struct stap_args_info dummy_stap_args_info = -+ { 0, NULL, NULL }; -+ -+static void stap_parse_argument_1 (struct stap_parse_info *p, int has_lhs, -+ enum stap_operand_prec prec); -+ -+static void stap_parse_argument_conditionally (struct stap_parse_info *p); -+ -+/* Returns 1 if *S is an operator, zero otherwise. */ -+ -+static int stap_is_operator (char op); -+ -+static void -+show_stapexpressiondebug (struct ui_file *file, int from_tty, -+ struct cmd_list_element *c, const char *value) -+{ -+ fprintf_filtered (file, _("SystemTap Probe expression debugging is %s.\n"), -+ value); -+} -+ -+/* Returns the operator precedence level of OP, or STAP_OPERAND_PREC_NONE -+ if the operator code was not recognized. */ -+ -+static enum stap_operand_prec -+stap_get_operator_prec (enum exp_opcode op) -+{ -+ switch (op) -+ { -+ case BINOP_LOGICAL_OR: -+ return STAP_OPERAND_PREC_LOGICAL_OR; -+ -+ case BINOP_LOGICAL_AND: -+ return STAP_OPERAND_PREC_LOGICAL_AND; -+ -+ 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 STAP_OPERAND_PREC_ADD_CMP; -+ -+ case BINOP_BITWISE_IOR: -+ case BINOP_BITWISE_AND: -+ case BINOP_BITWISE_XOR: -+ case UNOP_LOGICAL_NOT: -+ return STAP_OPERAND_PREC_BITWISE; -+ -+ case BINOP_MUL: -+ case BINOP_DIV: -+ case BINOP_REM: -+ case BINOP_LSH: -+ case BINOP_RSH: -+ return STAP_OPERAND_PREC_MUL; -+ -+ default: -+ return STAP_OPERAND_PREC_NONE; -+ } -+} -+ -+/* Given S, read the operator in it and fills the OP pointer with its code. -+ Return 1 on success, zero if the operator was not recognized. */ -+ -+static int -+stap_get_opcode (const char **s, enum exp_opcode *op) -+{ -+ const char c = **s; -+ int ret = 1; -+ -+ *s += 1; -+ -+ switch (c) -+ { -+ case '*': -+ *op = BINOP_MUL; -+ break; -+ -+ case '/': -+ *op = BINOP_DIV; -+ break; -+ -+ case '%': -+ *op = BINOP_REM; -+ break; -+ -+ 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; -+ -+ case '>': -+ *op = BINOP_GTR; -+ if (**s == '>') -+ { -+ *s += 1; -+ *op = BINOP_RSH; -+ } -+ else if (**s == '=') -+ { -+ *s += 1; -+ *op = BINOP_GEQ; -+ } -+ break; -+ -+ case '|': -+ *op = BINOP_BITWISE_IOR; -+ if (**s == '|') -+ { -+ *s += 1; -+ *op = BINOP_LOGICAL_OR; -+ } -+ break; -+ -+ case '&': -+ *op = BINOP_BITWISE_AND; -+ if (**s == '&') -+ { -+ *s += 1; -+ *op = BINOP_LOGICAL_AND; -+ } -+ break; -+ -+ case '^': -+ *op = BINOP_BITWISE_XOR; -+ break; -+ -+ case '!': -+ *op = UNOP_LOGICAL_NOT; -+ break; -+ -+ case '+': -+ *op = BINOP_ADD; -+ break; -+ -+ case '-': -+ *op = BINOP_SUB; -+ break; -+ -+ case '=': -+ if (**s != '=') -+ { -+ ret = 0; -+ break; -+ } -+ *op = BINOP_EQUAL; -+ break; -+ -+ default: -+ /* We didn't find any operator. */ -+ *s -= 1; -+ return 0; -+ } -+ -+ return ret; -+} -+ -+/* Given the bitness of the argument, represented by B, return the -+ corresponding `struct type *'. */ -+ -+static struct type * -+stap_get_expected_argument_type (struct gdbarch *gdbarch, -+ enum stap_arg_bitness b) -+{ -+ switch (b) -+ { -+ case STAP_ARG_BITNESS_UNDEFINED: -+ if (gdbarch_addr_bit (gdbarch) == 32) -+ return builtin_type (gdbarch)->builtin_uint32; -+ else -+ return builtin_type (gdbarch)->builtin_uint64; -+ -+ case STAP_ARG_BITNESS_32BIT_SIGNED: -+ return builtin_type (gdbarch)->builtin_int32; -+ -+ case STAP_ARG_BITNESS_32BIT_UNSIGNED: -+ return builtin_type (gdbarch)->builtin_uint32; -+ -+ case STAP_ARG_BITNESS_64BIT_SIGNED: -+ return builtin_type (gdbarch)->builtin_int64; -+ -+ case STAP_ARG_BITNESS_64BIT_UNSIGNED: -+ return builtin_type (gdbarch)->builtin_uint64; -+ -+ default: -+ internal_error (__FILE__, __LINE__, -+ _("Undefined bitness for probe.")); -+ break; -+ } -+} -+ -+static void -+stap_parse_register_operand (struct stap_parse_info *p) -+{ -+ /* Simple flag to indicate whether we have seen a minus signal before -+ certain number. */ -+ int got_minus = 0; -+ /* Flags to indicate whether this register access is being displaced and/or -+ indirected. */ -+ int disp_p = 0, indirect_p = 0; -+ struct gdbarch *gdbarch = p->gdbarch; -+ /* Needed to generate the register name as a part of an expression. */ -+ struct stoken str; -+ /* Variables used to extract the register name from the probe's -+ argument. */ -+ const char *start; -+ char *regname; -+ int len; -+ -+ /* Prefixes for the parser. */ -+ const char *reg_prefix = gdbarch_stap_register_prefix (gdbarch); -+ const char *reg_ind_prefix -+ = gdbarch_stap_register_indirection_prefix (gdbarch); -+ const char *gdb_reg_prefix = gdbarch_stap_gdb_register_prefix (gdbarch); -+ int reg_prefix_len = reg_prefix ? strlen (reg_prefix) : 0; -+ int reg_ind_prefix_len = reg_ind_prefix ? strlen (reg_ind_prefix) : 0; -+ int gdb_reg_prefix_len = gdb_reg_prefix ? strlen (gdb_reg_prefix) : 0; -+ -+ /* Sufixes for the parser. */ -+ const char *reg_sufix = gdbarch_stap_register_sufix (gdbarch); -+ const char *reg_ind_sufix -+ = gdbarch_stap_register_indirection_sufix (gdbarch); -+ const char *gdb_reg_sufix = gdbarch_stap_gdb_register_sufix (gdbarch); -+ int reg_sufix_len = reg_sufix ? strlen (reg_sufix) : 0; -+ int reg_ind_sufix_len = reg_ind_sufix ? strlen (reg_ind_sufix) : 0; -+ int gdb_reg_sufix_len = gdb_reg_sufix ? strlen (gdb_reg_sufix) : 0; -+ -+ /* Checking for a displacement argument. */ -+ if (*p->arg == '+') -+ /* If it's a plus sign, we don't need to do anything, just advance the -+ pointer. */ -+ ++p->arg; -+ -+ if (*p->arg == '-') -+ { -+ got_minus = 1; -+ ++p->arg; -+ } -+ -+ if (isdigit (*p->arg)) -+ { -+ /* The value of the displacement. */ -+ long displacement; -+ -+ disp_p = 1; -+ displacement = strtol (p->arg, (char **) &p->arg, 10); -+ -+ /* Generating the expression for the displacement. */ -+ write_exp_elt_opcode (OP_LONG); -+ write_exp_elt_type (builtin_type (gdbarch)->builtin_long); -+ write_exp_elt_longcst (displacement); -+ write_exp_elt_opcode (OP_LONG); -+ if (got_minus) -+ write_exp_elt_opcode (UNOP_NEG); -+ } -+ -+ /* Getting rid of register indirection prefix. */ -+ if (reg_ind_prefix -+ && strncmp (p->arg, reg_ind_prefix, reg_ind_prefix_len) == 0) -+ { -+ indirect_p = 1; -+ p->arg += reg_ind_prefix_len; -+ } -+ -+ if (disp_p && !indirect_p) -+ error (_("Invalid register displacement syntax on expression `%s'."), -+ p->saved_arg); -+ -+ /* Getting rid of register prefix. */ -+ if (reg_prefix && strncmp (p->arg, reg_prefix, reg_prefix_len) == 0) -+ p->arg += reg_prefix_len; -+ -+ /* Now we should have only the register name. Let's extract it and get -+ the associated number. */ -+ start = p->arg; -+ -+ /* We assume the register name is composed by letters and numbers. */ -+ while (isalnum (*p->arg)) -+ ++p->arg; -+ -+ len = p->arg - start; -+ -+ regname = alloca (len + gdb_reg_prefix_len + gdb_reg_sufix_len + 1); -+ regname[0] = '\0'; -+ -+ /* We only add the GDB's register prefix/sufix if we are dealing with -+ a numeric register. */ -+ if (gdb_reg_prefix && isdigit (*start)) -+ { -+ strncpy (regname, gdb_reg_prefix, gdb_reg_prefix_len); -+ strncpy (regname + gdb_reg_prefix_len, start, len); -+ -+ if (gdb_reg_sufix) -+ strncpy (regname + gdb_reg_prefix_len + len, -+ gdb_reg_sufix, gdb_reg_sufix_len); -+ -+ len += gdb_reg_prefix_len + gdb_reg_sufix_len; -+ } -+ else -+ strncpy (regname, start, len); -+ -+ regname[len] = '\0'; -+ /* Is this a valid register name? */ -+ if (user_reg_map_name_to_regnum (gdbarch, regname, len) == -1) -+ error (_("Invalid register name `%s' on expression `%s'."), -+ regname, p->saved_arg); -+ -+ write_exp_elt_opcode (OP_REGISTER); -+ str.ptr = regname; -+ str.length = len; -+ write_exp_string (str); -+ write_exp_elt_opcode (OP_REGISTER); -+ -+ if (indirect_p) -+ { -+ if (disp_p) -+ write_exp_elt_opcode (BINOP_ADD); -+ -+ /* Casting to the expected type. */ -+ write_exp_elt_opcode (UNOP_CAST); -+ write_exp_elt_type (lookup_pointer_type (p->arg_type)); -+ write_exp_elt_opcode (UNOP_CAST); -+ -+ write_exp_elt_opcode (UNOP_IND); -+ } -+ -+ /* Getting rid of the register name sufix. */ -+ if (reg_sufix) -+ { -+ if (strncmp (p->arg, reg_sufix, reg_sufix_len) != 0) -+ error (_("Missing register name sufix `%s' on expression `%s'."), -+ reg_sufix, p->saved_arg); -+ -+ p->arg += reg_sufix_len; -+ } -+ -+ /* Getting rid of the register indirection sufix. */ -+ if (indirect_p && reg_ind_sufix) -+ { -+ if (strncmp (p->arg, reg_ind_sufix, reg_ind_sufix_len) != 0) -+ error (_("Missing indirection sufix `%s' on expression `%s'."), -+ reg_ind_sufix, p->saved_arg); -+ -+ p->arg += reg_ind_sufix_len; -+ } -+} -+ -+static void -+stap_parse_single_operand (struct stap_parse_info *p) -+{ -+ struct gdbarch *gdbarch = p->gdbarch; -+ /* Prefixes for the parser. */ -+ const char *const_prefix = gdbarch_stap_integer_prefix (gdbarch); -+ const char *reg_prefix = gdbarch_stap_register_prefix (gdbarch); -+ const char *reg_ind_prefix -+ = gdbarch_stap_register_indirection_prefix (gdbarch); -+ int const_prefix_len = const_prefix ? strlen (const_prefix) : 0; -+ int reg_prefix_len = reg_prefix ? strlen (reg_prefix) : 0; -+ int reg_ind_prefix_len = reg_ind_prefix ? strlen (reg_ind_prefix) : 0; -+ -+ /* Sufixes for the parser. */ -+ const char *const_sufix = gdbarch_stap_integer_sufix (gdbarch); -+ const char *reg_sufix = gdbarch_stap_register_sufix (gdbarch); -+ const char *reg_ind_sufix -+ = gdbarch_stap_register_indirection_sufix (gdbarch); -+ int const_sufix_len = const_sufix ? strlen (const_sufix) : 0; -+ int reg_sufix_len = reg_sufix ? strlen (reg_sufix) : 0; -+ int reg_ind_sufix_len = reg_ind_sufix ? strlen (reg_ind_sufix) : 0; -+ -+ /* We first try to parse this token as a "special token". */ -+ if (gdbarch_stap_parse_special_token_p (gdbarch)) -+ { -+ int ret = gdbarch_stap_parse_special_token (gdbarch, p); -+ -+ if (ret) -+ /* If the return value of the above function is not zero, -+ it means it successfully parsed the special token. -+ -+ If it is NULL, we try to parse it using our method. */ -+ return; -+ } -+ -+ if (*p->arg == '-' || *p->arg == '~' || *p->arg == '+') -+ { -+ char c = *p->arg; -+ /* We use this variable to do a lookahead. */ -+ const char *tmp = p->arg; -+ -+ ++tmp; -+ -+ /* This is an unary operation. Here is a list of allowed tokens -+ here: -+ -+ - numeric literal; -+ - number (from register displacement) -+ - subexpression (beginning with `(') -+ -+ We handle the register displacement here, and the other cases -+ recursively. */ -+ if (isdigit (*tmp)) -+ { -+ int number = strtol (tmp, (char **) &tmp, 10); -+ -+ if (p->inside_paren_p) -+ tmp = skip_spaces_const (tmp); -+ if (!reg_ind_prefix -+ || strncmp (tmp, reg_ind_prefix, reg_ind_prefix_len) != 0) -+ goto not_displacement; -+ -+ /* If we are here, it means it is a displacement. The only -+ operations allowed here are `-' and `+'. */ -+ if (c == '~') -+ error (_("Invalid operator `%c' for register displacement " -+ "on expression `%s'."), c, p->saved_arg); -+ -+ stap_parse_register_operand (p); -+ } -+ else -+not_displacement: -+ { -+ p->arg = tmp; -+ stap_parse_argument_conditionally (p); -+ if (c == '-') -+ write_exp_elt_opcode (UNOP_NEG); -+ else if (c == '~') -+ write_exp_elt_opcode (UNOP_COMPLEMENT); -+ } -+ } -+ else if (isdigit (*p->arg)) -+ { -+ /* A temporary variable, needed for lookahead. */ -+ const char *tmp = p->arg; -+ long number; -+ -+ /* We can be dealing with a numeric constant (if `const_prefix' is -+ NULL), or with a register displacement. */ -+ number = strtol (tmp, (char **) &tmp, 10); -+ -+ if (p->inside_paren_p) -+ tmp = skip_spaces_const (tmp); -+ if (!const_prefix && reg_ind_prefix -+ && strncmp (tmp, reg_ind_prefix, reg_ind_prefix_len) != 0) -+ { -+ /* We are dealing with a numeric constant. */ -+ write_exp_elt_opcode (OP_LONG); -+ write_exp_elt_type (builtin_type (gdbarch)->builtin_long); -+ write_exp_elt_longcst (number); -+ write_exp_elt_opcode (OP_LONG); -+ -+ p->arg = tmp; -+ -+ if (const_sufix) -+ { -+ if (strncmp (p->arg, const_sufix, const_sufix_len) == 0) -+ p->arg += const_sufix_len; -+ else -+ error (_("Invalid constant sufix on expression `%s'."), -+ p->saved_arg); -+ } -+ } -+ else if (reg_ind_prefix -+ && strncmp (tmp, reg_ind_prefix, reg_ind_prefix_len) == 0) -+ stap_parse_register_operand (p); -+ else -+ error (_("Unknown numeric token on expression `%s'."), -+ p->saved_arg); -+ } -+ else if (const_prefix -+ && strncmp (p->arg, const_prefix, const_prefix_len) == 0) -+ { -+ /* We are dealing with a numeric constant. */ -+ long number; -+ -+ p->arg += const_prefix_len; -+ number = strtol (p->arg, (char **) &p->arg, 10); -+ -+ write_exp_elt_opcode (OP_LONG); -+ write_exp_elt_type (builtin_type (gdbarch)->builtin_long); -+ write_exp_elt_longcst (number); -+ write_exp_elt_opcode (OP_LONG); -+ -+ if (const_sufix) -+ { -+ if (strncmp (p->arg, const_sufix, const_sufix_len) == 0) -+ p->arg += const_sufix_len; -+ else -+ error (_("Invalid constant sufix on expression `%s'."), -+ p->saved_arg); -+ } -+ } -+ else if ((reg_prefix -+ && strncmp (p->arg, reg_prefix, reg_prefix_len) == 0) -+ || (reg_ind_prefix -+ && strncmp (p->arg, reg_ind_prefix, reg_ind_prefix_len) == 0)) -+ stap_parse_register_operand (p); -+ else -+ error (_("Operator `%c' not recognized on expression `%s'."), -+ *p->arg, p->saved_arg); -+} -+ -+static void -+stap_parse_argument_conditionally (struct stap_parse_info *p) -+{ -+ if (*p->arg == '-' || *p->arg == '~' || *p->arg == '+' /* Unary. */ -+ || isdigit (*p->arg) -+ || gdbarch_stap_is_single_operand (p->gdbarch, p->arg)) -+ stap_parse_single_operand (p); -+ else if (*p->arg == '(') -+ { -+ /* We are dealing with a parenthesized operand. It means we -+ have to parse it as it was a separate expression, without -+ left-side or precedence. */ -+ ++p->arg; -+ p->arg = skip_spaces_const (p->arg); -+ ++p->inside_paren_p; -+ -+ stap_parse_argument_1 (p, 0, STAP_OPERAND_PREC_NONE); -+ -+ --p->inside_paren_p; -+ if (*p->arg != ')') -+ error (_("Missign close-paren on expression `%s'."), -+ p->saved_arg); -+ -+ ++p->arg; -+ if (p->inside_paren_p) -+ p->arg = skip_spaces_const (p->arg); -+ } -+ else -+ error (_("Cannot parse expression `%s'."), p->saved_arg); -+} -+ -+static void -+stap_parse_argument_1 (struct stap_parse_info *p, int has_lhs, -+ enum stap_operand_prec prec) -+{ -+ /* This is an operator-precedence parser. -+ -+ We work with left- and right-sides of expressions, and -+ parse them depending on the precedence of the operators -+ we find. */ -+ -+ if (p->inside_paren_p) -+ p->arg = skip_spaces_const (p->arg); -+ -+ if (!has_lhs) -+ /* We were called without a left-side, either because this is the -+ first call, or because we were called to parse a parenthesized -+ expression. It doesn't really matter; we have to parse the -+ left-side in order to continue the process. */ -+ stap_parse_argument_conditionally (p); -+ -+ /* Start to parse 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 (p->arg && *p->arg && *p->arg != ')' && !isspace (*p->arg)) -+ { -+ const char *tmp_exp_buf; -+ enum exp_opcode opcode; -+ enum stap_operand_prec cur_prec; -+ -+ if (!stap_is_operator (*p->arg)) -+ error (_("Invalid operator `%c' on expression `%s'."), *p->arg, -+ p->saved_arg); -+ -+ /* 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 = p->arg; -+ 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 parsing process began, it means we should stop parsing -+ and return. */ -+ break; -+ -+ p->arg = tmp_exp_buf; -+ if (p->inside_paren_p) -+ p->arg = skip_spaces_const (p->arg); -+ -+ /* Parse the right-side of the expression. */ -+ stap_parse_argument_conditionally (p); -+ -+ /* While we still have operators, try to parse another -+ right-side, but using the current right-side as a left-side. */ -+ while (*p->arg && stap_is_operator (*p->arg)) -+ { -+ enum exp_opcode lookahead_opcode; -+ enum stap_operand_prec lookahead_prec; -+ -+ /* Saving the current expression buffer position. The explanation -+ is the same as above. */ -+ tmp_exp_buf = p->arg; -+ 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; -+ -+ /* Parse the right-side of the expression, but since we already -+ have a left-side at this point, set `has_lhs' to 1. */ -+ stap_parse_argument_1 (p, 1, lookahead_prec); -+ } -+ -+ write_exp_elt_opcode (opcode); -+ } -+} -+ -+/* Parse a probe's argument. -+ -+ Assuming that: -+ -+ LP = literal integer prefix -+ LS = literal integer sufix -+ -+ RP = register prefix -+ RS = register sufix -+ -+ RIP = register indirection prefix -+ RIS = register indirection sufix -+ -+ This routine assumes that arguments' tokens are of the form: -+ -+ - [LP] NUMBER [LS] -+ - [RP] REGISTER [RS] -+ - [RIP] [RP] REGISTER [RS] [RIS] -+ - If we find a number without LP, we try to parse it as a literal integer -+ constant (if LP == NULL), or as a register displacement. -+ - We count parenthesis, and only skip whitespaces if we are inside them. -+ - If we find an operator, we skip it. -+ -+ This function can also call a special function that will try to match -+ unknown tokens. It will return 1 if the argument has been parsed -+ successfully, or zero otherwise. */ -+ -+static int -+stap_parse_argument (const char **arg, struct type *atype, -+ struct gdbarch *gdbarch) -+{ -+ struct stap_parse_info p; -+ volatile struct gdb_exception e; -+ -+ /* We need to initialize the expression buffer, in order to begin -+ our parsing efforts. The language here does not matter, since we -+ are using our own parser. */ -+ initialize_expout (10, current_language, gdbarch); -+ -+ p.saved_arg = *arg; -+ p.arg = *arg; -+ p.arg_type = atype; -+ p.gdbarch = gdbarch; -+ p.inside_paren_p = 0; -+ -+ TRY_CATCH (e, RETURN_MASK_ERROR) -+ { -+ stap_parse_argument_1 (&p, 0, STAP_OPERAND_PREC_NONE); -+ } -+ if (e.reason < 0) -+ { -+ xfree (expout); -+ return 0; -+ } -+ -+ gdb_assert (p.inside_paren_p == 0); -+ -+ /* Casting the final expression to the appropriate type. */ -+ write_exp_elt_opcode (UNOP_CAST); -+ write_exp_elt_type (atype); -+ write_exp_elt_opcode (UNOP_CAST); -+ -+ reallocate_expout (); -+ -+ p.arg = skip_spaces_const (p.arg); -+ *arg = p.arg; -+ -+ return 1; -+} -+ -+/* Helper function which is responsible for freeing the space allocated to -+ hold information about a probe's arguments. */ -+ -+static void -+stap_free_args_info (void *args_info_ptr) -+{ -+ struct stap_args_info *a = (struct stap_args_info *) args_info_ptr; -+ int i; -+ -+ for (i = 0; i < a->n_args; i++) -+ xfree (a->args[i].aexpr); -+ -+ xfree (a->args); -+ xfree (a); -+} -+ -+/* Function which parses an argument string from PROBE, correctly splitting -+ the arguments and storing their information in properly ways. -+ -+ Consider the following argument string (x86 syntax): -+ -+ `4@%eax 4@$10' -+ -+ 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. */ -+ -+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; -+ -+ 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->args = xcalloc (STAP_MAX_ARGS, sizeof (struct stap_probe_arg)); -+ -+ /* Ok, let's start. */ -+ current_state = NEW_ARG; -+ -+ while (*cur) -+ { -+ switch (current_state) -+ { -+ case NEW_ARG: -+ ++current_arg; -+ -+ 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; -+ } -+ -+ current_state = BITNESS; -+ break; -+ -+ case BITNESS: -+ { -+ enum stap_arg_bitness b; -+ int got_minus = 0; -+ -+ /* We expect to find something like: -+ -+ N@OP -+ -+ 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->args[current_arg].bitness -+ = STAP_ARG_BITNESS_UNDEFINED; -+ break; -+ } -+ -+ if (*cur == '-') -+ { -+ /* Discard the `-'. */ -+ ++cur; -+ got_minus = 1; -+ } -+ -+ 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; -+ } -+ -+ args_info->args[current_arg].bitness = b; -+ args_info->args[current_arg].atype -+ = stap_get_expected_argument_type (probe->gdbarch, b); -+ /* Discard the number and the `@' sign. */ -+ cur += 2; -+ /* Move on. */ -+ current_state = PARSE_ARG; -+ } -+ break; -+ -+ case PARSE_ARG: -+ { -+ if (!stap_parse_argument (&cur, -+ args_info->args[current_arg].atype, -+ probe->gdbarch)) -+ { -+ /* We have tried to parse this argument, but it's -+ malformed. This is an error. */ -+ complaint (&symfile_complaints, -+ _("malformed argument for probe `%s'"), -+ probe->name); -+ do_cleanups (back_to); -+ return; -+ } -+ -+ if (stap_expression_debug) -+ dump_raw_expression (expout, gdb_stdlog, -+ "before conversion to prefix form"); -+ -+ prefixify_expression (expout); -+ -+ if (stap_expression_debug) -+ dump_prefix_expression (expout, gdb_stdlog); -+ -+ args_info->args[current_arg].aexpr = expout; -+ expout = NULL; -+ -+ ++args_info->n_args; -+ /* Start it over again. */ -+ cur = skip_spaces_const (cur); -+ current_state = NEW_ARG; -+ } -+ break; -+ } -+ -+ 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; -+ } -+ } -+ -+ args_info->args = xrealloc (args_info->args, -+ args_info->n_args -+ * sizeof (struct stap_probe_arg)); -+ args_info->probe = probe; -+ -+ probe->parsed_args = args_info; -+ -+ discard_cleanups (back_to); -+} -+ -+/* See definition in stap-probe.h. */ -+ -+int -+stap_get_probe_argument_count (struct stap_probe *probe) -+{ -+ if (!probe->parsed_args) -+ stap_parse_probe_arguments (probe); -+ -+ return probe->parsed_args->n_args; -+} -+ -+/* Return 1 if OP is a valid operator inside a probe argument, or zero -+ otherwise. */ -+ -+static int -+stap_is_operator (char op) -+{ -+ return (op == '+' || op == '-' || op == '*' || op == '/' -+ || op == '>' || op == '<' || op == '!' || op == '^' -+ || op == '|' || op == '&' || op == '%' || op == '='); -+} -+ -+/* See definition in stap-probe.h. */ -+ -+struct value * -+stap_evaluate_probe_argument (struct objfile *objfile, -+ struct stap_probe *probe, -+ struct frame_info *frame, -+ int n) -+{ -+ int pos = 0; -+ -+ if (!probe->parsed_args) -+ stap_parse_probe_arguments (probe); -+ -+ if (!probe->parsed_args->args -+ || n >= probe->parsed_args->n_args) -+ return NULL; -+ -+ /* This is needed because on some architectures (e.g., ARM) we need -+ the frame's gdbarch in order to compute the value of the frame -+ pointer. */ -+ probe->parsed_args->args[n].aexpr->gdbarch = get_frame_arch (frame); -+ -+ return evaluate_subexp_standard (probe->parsed_args->args[n].atype, -+ probe->parsed_args->args[n].aexpr, -+ &pos, EVAL_NORMAL); -+} -+ -+/* See definition in stap-probe.h. */ -+ -+void -+stap_compile_to_ax (struct objfile *objfile, -+ struct stap_probe *probe, -+ struct agent_expr *expr, -+ struct axs_value *value, -+ int n) -+{ -+ union exp_element *pc; -+ -+ if (!probe->parsed_args) -+ stap_parse_probe_arguments (probe); -+ -+ if (!probe->parsed_args->args -+ || n >= probe->parsed_args->n_args) -+ return; -+ -+ pc = probe->parsed_args->args[n].aexpr->elts; -+ gen_expr (probe->parsed_args->args[n].aexpr, &pc, expr, value); -+ -+ require_rvalue (expr, value); -+ value->type = probe->parsed_args->args[n].atype; -+} -+ -+struct value * -+stap_safe_evaluate_at_pc (struct frame_info *frame, int n) -+{ -+ struct stap_probe *probe; -+ struct objfile *objfile; -+ int n_probes; -+ -+ 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); -+} -+ -+/* This function frees the space allocated to hold information about -+ the probe's parsed arguments. */ -+ -+void -+stap_free_parsed_args (struct stap_args_info *parsed_args) -+{ -+ int i; -+ -+ 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->args[i].aexpr); -+ -+ xfree (parsed_args->args); -+ xfree (parsed_args); -+} -+ -+/* A utility structure. A VEC of these is built when handling "info -+ probes". */ -+ -+struct stap_probe_and_objfile -+{ -+ /* The probe. */ -+ 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) -+{ -+ int code; -+ -+ if (!rx) -+ return; -+ -+ code = regcomp (pattern, rx, REG_NOSUB); -+ if (code == 0) -+ make_regfree_cleanup (pattern); -+ else -+ { -+ 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) -+ { -+ 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; -+ } -+ -+ 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 qsort comparison function for stap_entry objects. */ -+ -+static int -+compare_entries (const void *a, const void *b) -+{ -+ const stap_entry *ea = a; -+ const stap_entry *eb = b; -+ int v; -+ -+ v = strcmp (ea->probe->provider, eb->probe->provider); -+ if (v) -+ return v; -+ -+ v = strcmp (ea->probe->name, eb->probe->name); -+ if (v) -+ return v; -+ -+ if (ea->probe->address < eb->probe->address) -+ return -1; -+ if (ea->probe->address > eb->probe->address) -+ return 1; -+ -+ 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) -+ { -+ make_cleanup (xfree, probe); -+ -+ objname = extract_arg (&arg); -+ if (objname) -+ make_cleanup (xfree, objname); -+ } -+ } -+ -+ items = collect_probes (objname, provider, probe); -+ make_cleanup (VEC_cleanup (stap_entry), &items); -+ make_cleanup_ui_out_table_begin_end (current_uiout, 5, -+ VEC_length (stap_entry, items), -+ "SystemTapProbes"); -+ -+ 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 (current_uiout, 10, ui_left, "provider", _("Provider")); -+ ui_out_table_header (current_uiout, 10, ui_left, "name", _("Name")); -+ ui_out_table_header (current_uiout, addr_width - 1, ui_left, "addr", _("Where")); -+ ui_out_table_header (current_uiout, addr_width - 1, ui_left, "semaphore", -+ _("Semaphore")); -+ ui_out_table_header (current_uiout, 30, ui_left, "object", _("Object")); -+ ui_out_table_body (current_uiout); -+ -+ for (i = 0; VEC_iterate (stap_entry, items, i, entry); ++i) -+ { -+ struct cleanup *inner; -+ -+ inner = make_cleanup_ui_out_tuple_begin_end (current_uiout, "probe"); -+ -+ ui_out_field_string (current_uiout, "provider", entry->probe->provider); -+ ui_out_field_string (current_uiout, "name", entry->probe->name); -+ ui_out_field_core_addr (current_uiout, "addr", get_current_arch (), -+ entry->probe->address); -+ if (entry->probe->sem_addr == 0) -+ ui_out_field_skip (current_uiout, "semaphore"); -+ else -+ ui_out_field_core_addr (current_uiout, "semaphore", get_current_arch (), -+ entry->probe->sem_addr); -+ ui_out_field_string (current_uiout, "object", entry->objfile->name); -+ ui_out_text (current_uiout, "\n"); -+ -+ do_cleanups (inner); -+ } -+ -+ any_found = ! VEC_empty (stap_entry, items); -+ do_cleanups (cleanup); -+ -+ if (! any_found) -+ ui_out_message (current_uiout, 0, _("No probes matched.\n")); -+} -+ -+ -+ -+/* See definition in stap-probe.h. */ -+ -+VEC (stap_probe_p) * -+find_probes_in_objfile (struct objfile *objfile, -+ const char *provider, -+ const char *name) -+{ -+ struct stap_probe *probes; -+ int i, num_probes; -+ VEC (stap_probe_p) *result = NULL; -+ -+ 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; -+ -+ if (strcmp (probes[i].name, name) != 0) -+ continue; -+ -+ VEC_safe_push (stap_probe_p, result, &probes[i]); -+ } -+ -+ return result; -+} -+ -+/* See definition in stap-probe.h. */ -+ -+struct symtabs_and_lines -+parse_stap_probe (char **argptr, struct linespec_result *canonical) -+{ -+ char *arg_start, *arg_end, *arg; -+ char *objfile_name = NULL, *provider = NULL, *name, *p; -+ struct cleanup *cleanup; -+ struct symtabs_and_lines result; -+ struct objfile *objfile; -+ -+ result.sals = NULL; -+ result.nelts = 0; -+ -+ arg_start = *argptr; -+ /* The caller ensured that this starts with '-p'. */ -+ gdb_assert (arg_start && strncmp (arg_start, "-p", 2) == 0); -+ arg_end = arg_start + 2; -+ arg_end = skip_spaces (arg_end); -+ -+ if (!*arg_end) -+ error (_("argument to `-p' missing")); -+ -+ arg = arg_end; -+ arg_end = skip_to_space (arg_end); -+ -+ /* We make a copy here so we can write over parts with impunity. */ -+ arg = savestring (arg, arg_end - arg); -+ cleanup = make_cleanup (xfree, arg); -+ -+ /* Extract each word from the argument, separated by ":"s. */ -+ p = strchr (arg, ':'); -+ if (p == NULL) -+ { -+ /* This is `-p name'. */ -+ name = arg; -+ } -+ else -+ { -+ char *hold = p + 1; -+ -+ *p = '\0'; -+ p = strchr (hold, ':'); -+ if (p == NULL) -+ { -+ /* This is `-p provider:name'. */ -+ provider = arg; -+ name = hold; -+ } -+ else -+ { -+ /* This is `-p 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")); -+ -+ ALL_OBJFILES (objfile) -+ { -+ 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]; -+ -+ init_sal (sal); -+ -+ 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; -+ } -+ } -+ -+ if (result.nelts == 0) -+ { -+ throw_error (NOT_FOUND_ERROR, -+ _("No probe matching objfile=`%s', provider=`%s', name=`%s'"), -+ objfile_name ? objfile_name : _(""), -+ provider ? provider : _(""), -+ name); -+ } -+ -+ if (canonical) -+ { -+ canonical->special_display = 1; -+ canonical->pre_expanded = 1; -+ canonical->addr_string = savestring (*argptr, arg_end - *argptr); -+ } -+ -+ *argptr = arg_end; -+ do_cleanups (cleanup); -+ -+ return result; -+} -+ -+ -+ -+/* See definition in stap-probe.h. */ -+ -+struct stap_probe * -+find_probe_by_pc (CORE_ADDR pc, struct objfile **objfile_out) -+{ -+ struct objfile *objfile; -+ -+ ALL_OBJFILES (objfile) -+ { -+ struct stap_probe *probes; -+ int i, num_probes; -+ stap_entry entry; -+ -+ if (! objfile->sf || ! objfile->sf->sym_probe_fns) -+ continue; -+ -+ /* 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]; -+ } -+ } -+ } -+ -+ return NULL; -+} -+ -+/* This is called to compute the value of one of the $_probe_arg* -+ convenience variables. */ -+ -+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; -+ struct stap_probe *pc_probe; -+ int n_probes; -+ -+ /* SEL==-1 means "_probe_argc". */ -+ gdb_assert (sel >= -1 && 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 == -1) -+ 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); -+} -+ -+/* This is called to compile one of the $_probe_arg* convenience -+ variables into an agent expression. */ -+ -+static void -+compile_probe_arg (struct internalvar *ivar, struct agent_expr *expr, -+ struct axs_value *value, void *data) -+{ -+ CORE_ADDR pc = expr->scope; -+ int sel = (int) (uintptr_t) data; -+ struct objfile *objfile; -+ struct stap_probe *pc_probe; -+ int n_probes; -+ -+ /* SEL==-1 means "_probe_argc". */ -+ gdb_assert (sel >= -1 && 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 == -1) -+ { -+ 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); -+} -+ -+ -+ -+/* 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.")); -+ -+ add_setshow_zinteger_cmd ("stap-expression", class_maintenance, -+ &stap_expression_debug, -+ _("Set SystemTap expression debugging."), -+ _("Show SystemTap expression debugging."), -+ _("When non-zero, the internal representation " -+ "of SystemTap expressions will be printed."), -+ NULL, -+ show_stapexpressiondebug, -+ &setdebuglist, &showdebuglist); -+ -+ create_internalvar_type_lazy ("_probe_argc", &probe_funcs, -+ (void *) (uintptr_t) -1); -+ 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); -+ create_internalvar_type_lazy ("_probe_arg10", &probe_funcs, -+ (void *) (uintptr_t) 10); -+ create_internalvar_type_lazy ("_probe_arg11", &probe_funcs, -+ (void *) (uintptr_t) 11); -+} -diff --git a/gdb/stap-probe.h b/gdb/stap-probe.h -new file mode 100644 -index 0000000..9b6dc7a ---- /dev/null -+++ b/gdb/stap-probe.h -@@ -0,0 +1,144 @@ -+/* 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 . */ -+ -+#if !defined (STAP_PROBE_H) -+#define STAP_PROBE_H 1 -+ -+#include "vec.h" -+ -+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; -+ -+ /* 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; -+ -+ /* gdbarch structure associated with this probe. */ -+ struct gdbarch *gdbarch; -+}; -+ -+/* Structure which holds information about the parsing process of one probe's -+ argument. */ -+ -+struct stap_parse_info -+{ -+ /* The probe's argument in a string format. */ -+ const char *arg; -+ -+ /* A pointer to the full chain of arguments. This is useful for printing -+ error messages. The parser functions should not modify this argument -+ directly; instead, they should use the ARG pointer above. */ -+ const char *saved_arg; -+ -+ /* The expected argument type (bitness), as defined in the probe's -+ argument. For instance, if the argument begins with `-8@', it means -+ the bitness is 64-bit signed. In this case, ARG_TYPE would represent -+ the type `int64_t'. */ -+ struct type *arg_type; -+ -+ /* A pointer to the current gdbarch. */ -+ struct gdbarch *gdbarch; -+ -+ /* Greater than zero if we are inside a parenthesized expression. Useful -+ for knowing when to skip spaces or not. */ -+ int inside_paren_p; -+}; -+ -+typedef struct stap_probe *stap_probe_p; -+DEF_VEC_P (stap_probe_p); -+ -+/* A helper for linespec that decodes a stap probe specification. It -+ returns a symtabs_and_lines object and updates *ARGPTR or throws an -+ error. */ -+ -+extern struct symtabs_and_lines parse_stap_probe (char **argptr, -+ struct linespec_result *canon); -+ -+/* Search OBJFILE for a probe with the given PROVIDER and NAME. -+ Return a VEC of all probes that were found. If no matching probe -+ is found, return NULL. The caller must free the VEC. */ -+ -+extern VEC (stap_probe_p) *find_probes_in_objfile (struct objfile *objfile, -+ const char *provider, -+ const char *name); -+ -+/* 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. */ -+ -+extern struct stap_probe *find_probe_by_pc (CORE_ADDR pc, -+ struct objfile **objfile_out); -+ -+/* Given PROBE, returns the number of arguments present in that probe's -+ argument string. */ -+ -+extern int stap_get_probe_argument_count (struct stap_probe *probe); -+ -+/* Given PARSED_ARGS, frees the space allocated to hold information about -+ the probe's parsed arguments. */ -+ -+extern void stap_free_parsed_args (struct stap_args_info *parsed_args); -+ -+/* Evaluate the probe's argument N, returning a value corresponding -+ to it. */ -+ -+extern struct value *stap_evaluate_probe_argument (struct objfile *objfile, -+ struct stap_probe *probe, -+ struct frame_info *frame, -+ int n); -+ -+/* Compile the probe's argument N to agent expression. */ -+ -+extern void stap_compile_to_ax (struct objfile *objfile, -+ struct stap_probe *probe, -+ struct agent_expr *expr, -+ struct axs_value *value, -+ int n); -+ -+/* 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. */ -+ -+extern struct value *stap_safe_evaluate_at_pc (struct frame_info *frame, -+ int n); -+ -+#endif /* !defined (STAP_PROBE_H) */ -diff --git a/gdb/symfile.h b/gdb/symfile.h -index 6b664cd..6ca797d 100644 ---- a/gdb/symfile.h -+++ b/gdb/symfile.h -@@ -29,6 +29,11 @@ struct objfile; - struct obj_section; - struct obstack; - struct block; -+struct stap_probe; -+struct value; -+struct frame_info; -+struct agent_expr; -+struct axs_value; - - /* Comparison function for symbol look ups. */ - -@@ -299,6 +304,52 @@ struct quick_symbol_functions - int need_fullname); - }; - -+/* 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. */ -+ 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, -+ 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, -+ 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, -+ 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); -+}; -+ - /* Structure to keep track of symbol reading functions for various - object file types. */ - -@@ -369,6 +420,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; -diff --git a/gdb/symtab.c b/gdb/symtab.c -index 1746d69..2abc17f 100644 ---- a/gdb/symtab.c -+++ b/gdb/symtab.c -@@ -869,6 +869,7 @@ init_sal (struct symtab_and_line *sal) - sal->end = 0; - sal->explicit_pc = 0; - sal->explicit_line = 0; -+ sal->semaphore = 0; - } - - -diff --git a/gdb/symtab.h b/gdb/symtab.h -index 4836dd6..668a22b 100644 ---- a/gdb/symtab.h -+++ b/gdb/symtab.h -@@ -1056,6 +1056,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); -diff --git a/gdb/testsuite/gdb.ada/packed_array.exp b/gdb/testsuite/gdb.ada/packed_array.exp -index 678639c..47a2202 100644 ---- a/gdb/testsuite/gdb.ada/packed_array.exp -+++ b/gdb/testsuite/gdb.ada/packed_array.exp -@@ -60,5 +60,11 @@ gdb_test_multiple "$test" "$test" { - # are. Observed with (FSF GNU Ada 4.5.3 20110124). - xfail $test - } -+ -re "= \\(\\)\[\r\n\]+$gdb_prompt $" { -+ # archer-jankratochvil-vla resolves it as a dynamic type resolved as an -+ # empty array [0..-1]. -+ # DW_AT_upper_bound : (DW_OP_fbreg: -48; DW_OP_deref) -+ xfail $test -+ } - } - -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 -@@ -0,0 +1,457 @@ -+ .file "x86_64-vla-pointer.c" -+ .section .debug_abbrev,"",@progbits -+.Ldebug_abbrev0: -+ .section .debug_info,"",@progbits -+.Ldebug_info0: -+ .section .debug_line,"",@progbits -+.Ldebug_line0: -+ .text -+.Ltext0: -+.globl foo -+ .type foo, @function -+foo: -+.LFB2: -+ .file 1 "x86_64-vla-pointer.c" -+ .loc 1 22 0 -+ pushq %rbp -+.LCFI0: -+ movq %rsp, %rbp -+.LCFI1: -+ subq $64, %rsp -+.LCFI2: -+ movl %edi, -36(%rbp) -+ .loc 1 22 0 -+ movq %rsp, %rax -+ movq %rax, -48(%rbp) -+ .loc 1 23 0 -+ movl -36(%rbp), %edx -+ movslq %edx,%rax -+ subq $1, %rax -+ movq %rax, -24(%rbp) -+ .loc 1 24 0 -+ movslq %edx,%rax -+ addq $15, %rax -+ addq $15, %rax -+ shrq $4, %rax -+ salq $4, %rax -+ subq %rax, %rsp -+ movq %rsp, -56(%rbp) -+ movq -56(%rbp), %rax -+ addq $15, %rax -+ shrq $4, %rax -+ salq $4, %rax -+ movq %rax, -56(%rbp) -+ movq -56(%rbp), %rax -+ movq %rax, -16(%rbp) -+ .loc 1 27 0 -+ movl $0, -4(%rbp) -+ jmp .L2 -+.L3: -+ .loc 1 28 0 -+ movl -4(%rbp), %esi -+ movl -4(%rbp), %eax -+ movl %eax, %ecx -+ movq -16(%rbp), %rdx -+ movslq %esi,%rax -+ movb %cl, (%rdx,%rax) -+ .loc 1 27 0 -+ addl $1, -4(%rbp) -+.L2: -+ movl -4(%rbp), %eax -+ cmpl -36(%rbp), %eax -+ jl .L3 -+ .loc 1 30 0 -+ .globl break_here -+break_here: -+ movq -16(%rbp), %rax -+ movb $0, (%rax) -+ movq -48(%rbp), %rsp -+ .loc 1 31 0 -+ leave -+ ret -+.LFE2: -+ .size foo, .-foo -+ .section .debug_frame,"",@progbits -+.Lframe0: -+ .long .LECIE0-.LSCIE0 -+.LSCIE0: -+ .long 0xffffffff -+ .byte 0x1 -+ .string "" -+ .uleb128 0x1 -+ .sleb128 -8 -+ .byte 0x10 -+ .byte 0xc -+ .uleb128 0x7 -+ .uleb128 0x8 -+ .byte 0x90 -+ .uleb128 0x1 -+ .align 8 -+.LECIE0: -+.LSFDE0: -+ .long .LEFDE0-.LASFDE0 -+.LASFDE0: -+ .long .Lframe0 -+ .quad .LFB2 -+ .quad .LFE2-.LFB2 -+ .byte 0x4 -+ .long .LCFI0-.LFB2 -+ .byte 0xe -+ .uleb128 0x10 -+ .byte 0x86 -+ .uleb128 0x2 -+ .byte 0x4 -+ .long .LCFI1-.LCFI0 -+ .byte 0xd -+ .uleb128 0x6 -+ .align 8 -+.LEFDE0: -+ .section .eh_frame,"a",@progbits -+.Lframe1: -+ .long .LECIE1-.LSCIE1 -+.LSCIE1: -+ .long 0x0 -+ .byte 0x1 -+ .string "zR" -+ .uleb128 0x1 -+ .sleb128 -8 -+ .byte 0x10 -+ .uleb128 0x1 -+ .byte 0x3 -+ .byte 0xc -+ .uleb128 0x7 -+ .uleb128 0x8 -+ .byte 0x90 -+ .uleb128 0x1 -+ .align 8 -+.LECIE1: -+.LSFDE1: -+ .long .LEFDE1-.LASFDE1 -+.LASFDE1: -+ .long .LASFDE1-.Lframe1 -+ .long .LFB2 -+ .long .LFE2-.LFB2 -+ .uleb128 0x0 -+ .byte 0x4 -+ .long .LCFI0-.LFB2 -+ .byte 0xe -+ .uleb128 0x10 -+ .byte 0x86 -+ .uleb128 0x2 -+ .byte 0x4 -+ .long .LCFI1-.LCFI0 -+ .byte 0xd -+ .uleb128 0x6 -+ .align 8 -+.LEFDE1: -+ .text -+.Letext0: -+ .section .debug_loc,"",@progbits -+.Ldebug_loc0: -+.LLST0: -+ .quad .LFB2-.Ltext0 -+ .quad .LCFI0-.Ltext0 -+ .value 0x2 -+ .byte 0x77 -+ .sleb128 8 -+ .quad .LCFI0-.Ltext0 -+ .quad .LCFI1-.Ltext0 -+ .value 0x2 -+ .byte 0x77 -+ .sleb128 16 -+ .quad .LCFI1-.Ltext0 -+ .quad .LFE2-.Ltext0 -+ .value 0x2 -+ .byte 0x76 -+ .sleb128 16 -+ .quad 0x0 -+ .quad 0x0 -+ .section .debug_info -+.Ldebug_relative: -+ .long .Ldebug_end - .Ldebug_start -+.Ldebug_start: -+ .value 0x2 -+ .long .Ldebug_abbrev0 -+ .byte 0x8 -+ .uleb128 0x1 -+ .long .LASF2 -+ .byte 0x1 -+ .long .LASF3 -+ .long .LASF4 -+ .quad .Ltext0 -+ .quad .Letext0 -+ .long .Ldebug_line0 -+ .uleb128 0x2 -+ .byte 0x1 -+ .string "foo" -+ .byte 0x1 -+ .byte 0x16 -+ .byte 0x1 -+ .quad .LFB2 -+ .quad .LFE2 -+ .long .LLST0 -+ .long .Ltype_int - .Ldebug_relative -+ .uleb128 0x3 -+ .long .LASF5 -+ .byte 0x1 -+ .byte 0x15 -+ .long .Ltype_int - .Ldebug_relative -+ .byte 0x2 -+ .byte 0x91 -+ .sleb128 -52 -+.Ltag_pointer: -+ .uleb128 0x4 -+ .byte 0x8 /* DW_AT_byte_size */ -+ .long .Ltag_array_type - .debug_info /* DW_AT_type */ -+ .uleb128 0x5 /* Abbrev Number: 5 (DW_TAG_variable) */ -+ .long .LASF0 -+ .byte 0x1 -+ .byte 0x18 -+#if 1 -+ .long .Ltag_pointer - .debug_info -+#else -+ /* Debugging only: Skip the typedef indirection. */ -+ .long .Ltag_array_type - .debug_info -+#endif -+ /* DW_AT_location: DW_FORM_block1: start */ -+ .byte 0x3 -+ .byte 0x91 -+ .sleb128 -32 -+#if 0 -+ .byte 0x6 /* DW_OP_deref */ -+#else -+ .byte 0x96 /* DW_OP_nop */ -+#endif -+ /* DW_AT_location: DW_FORM_block1: end */ -+ .uleb128 0x6 -+ .string "i" -+ .byte 0x1 -+ .byte 0x19 -+ .long .Ltype_int - .Ldebug_relative -+ .byte 0x2 -+ .byte 0x91 -+ .sleb128 -20 -+ .byte 0x0 -+.Ltype_int: -+ .uleb128 0x7 -+ .byte 0x4 -+ .byte 0x5 -+ .string "int" -+.Ltag_array_type: -+ .uleb128 0x8 /* Abbrev Number: 8 (DW_TAG_array_type) */ -+ .long .Ltype_char - .Ldebug_relative -+ .long .Ltype_ulong - .Ldebug_relative /* DW_AT_sibling: DW_FORM_ref4 */ -+1: /* DW_AT_data_location: DW_FORM_block1: start */ -+ .byte 2f - 3f /* length */ -+3: -+ .byte 0x97 /* DW_OP_push_object_address */ -+#if 1 -+ .byte 0x6 /* DW_OP_deref */ -+#else -+ .byte 0x96 /* DW_OP_nop */ -+#endif -+2: /* DW_AT_data_location: DW_FORM_block1: end */ -+ .uleb128 0x9 -+ .long .Ltype_char - .Ldebug_relative /* DW_AT_type: DW_FORM_ref4 */ -+ .byte 0x3 -+ .byte 0x91 -+ .sleb128 -40 -+ .byte 0x6 -+ .byte 0x0 -+.Ltype_ulong: -+ .uleb128 0xa -+ .byte 0x8 -+ .byte 0x7 -+.Ltype_char: -+ .uleb128 0xb -+ .byte 0x1 -+ .byte 0x6 -+ .long .LASF1 -+ .byte 0x0 -+.Ldebug_end: -+ .section .debug_abbrev -+ .uleb128 0x1 -+ .uleb128 0x11 -+ .byte 0x1 -+ .uleb128 0x25 -+ .uleb128 0xe -+ .uleb128 0x13 -+ .uleb128 0xb -+ .uleb128 0x3 -+ .uleb128 0xe -+ .uleb128 0x1b -+ .uleb128 0xe -+ .uleb128 0x11 -+ .uleb128 0x1 -+ .uleb128 0x12 -+ .uleb128 0x1 -+ .uleb128 0x10 -+ .uleb128 0x6 -+ .byte 0x0 -+ .byte 0x0 -+ .uleb128 0x2 -+ .uleb128 0x2e -+ .byte 0x1 -+ .uleb128 0x3f -+ .uleb128 0xc -+ .uleb128 0x3 -+ .uleb128 0x8 -+ .uleb128 0x3a -+ .uleb128 0xb -+ .uleb128 0x3b -+ .uleb128 0xb -+ .uleb128 0x27 -+ .uleb128 0xc -+ .uleb128 0x11 -+ .uleb128 0x1 -+ .uleb128 0x12 -+ .uleb128 0x1 -+ .uleb128 0x40 -+ .uleb128 0x6 -+ .uleb128 0x1 -+ .uleb128 0x13 -+ .byte 0x0 -+ .byte 0x0 -+ .uleb128 0x3 -+ .uleb128 0x5 -+ .byte 0x0 -+ .uleb128 0x3 -+ .uleb128 0xe -+ .uleb128 0x3a -+ .uleb128 0xb -+ .uleb128 0x3b -+ .uleb128 0xb -+ .uleb128 0x49 -+ .uleb128 0x13 -+ .uleb128 0x2 -+ .uleb128 0xa -+ .byte 0x0 -+ .byte 0x0 -+ .uleb128 0x4 /* .Ltag_pointer abbrev */ -+ .uleb128 0x0f /* DW_TAG_pointer_type */ -+ .byte 0x0 -+ .uleb128 0x0b -+ .uleb128 0xb -+ .uleb128 0x49 -+ .uleb128 0x13 -+ .byte 0x0 -+ .byte 0x0 -+ .uleb128 0x5 -+ .uleb128 0x34 -+ .byte 0x0 -+ .uleb128 0x3 -+ .uleb128 0xe -+ .uleb128 0x3a -+ .uleb128 0xb -+ .uleb128 0x3b -+ .uleb128 0xb -+ .uleb128 0x49 -+ .uleb128 0x13 -+ .uleb128 0x2 -+ .uleb128 0xa -+ .byte 0x0 -+ .byte 0x0 -+ .uleb128 0x6 -+ .uleb128 0x34 -+ .byte 0x0 -+ .uleb128 0x3 -+ .uleb128 0x8 -+ .uleb128 0x3a -+ .uleb128 0xb -+ .uleb128 0x3b -+ .uleb128 0xb -+ .uleb128 0x49 -+ .uleb128 0x13 -+ .uleb128 0x2 -+ .uleb128 0xa -+ .byte 0x0 -+ .byte 0x0 -+ .uleb128 0x7 -+ .uleb128 0x24 -+ .byte 0x0 -+ .uleb128 0xb -+ .uleb128 0xb -+ .uleb128 0x3e -+ .uleb128 0xb -+ .uleb128 0x3 -+ .uleb128 0x8 -+ .byte 0x0 -+ .byte 0x0 -+ .uleb128 0x8 /* Abbrev Number: 8 (DW_TAG_array_type) */ -+ .uleb128 0x1 -+ .byte 0x1 -+ .uleb128 0x49 /* DW_AT_type */ -+ .uleb128 0x13 /* DW_FORM_ref4 */ -+ .uleb128 0x1 /* DW_AT_sibling */ -+ .uleb128 0x13 /* DW_FORM_ref4 */ -+ .uleb128 0x50 /* DW_AT_data_location */ -+ .uleb128 0xa /* DW_FORM_block1 */ -+ .byte 0x0 -+ .byte 0x0 -+ .uleb128 0x9 -+ .uleb128 0x21 -+ .byte 0x0 -+ .uleb128 0x49 /* DW_AT_type */ -+ .uleb128 0x13 /* DW_FORM_ref4 */ -+ .uleb128 0x2f -+ .uleb128 0xa -+ .byte 0x0 -+ .byte 0x0 -+ .uleb128 0xa -+ .uleb128 0x24 -+ .byte 0x0 -+ .uleb128 0xb -+ .uleb128 0xb -+ .uleb128 0x3e -+ .uleb128 0xb -+ .byte 0x0 -+ .byte 0x0 -+ .uleb128 0xb -+ .uleb128 0x24 -+ .byte 0x0 -+ .uleb128 0xb -+ .uleb128 0xb -+ .uleb128 0x3e -+ .uleb128 0xb -+ .uleb128 0x3 -+ .uleb128 0xe -+ .byte 0x0 -+ .byte 0x0 -+ .byte 0x0 -+ .section .debug_pubnames,"",@progbits -+ .long 0x16 -+ .value 0x2 -+ .long .Ldebug_info0 -+ .long 0xa8 -+ .long 0x2d -+ .string "foo" -+ .long 0x0 -+ .section .debug_aranges,"",@progbits -+ .long 0x2c -+ .value 0x2 -+ .long .Ldebug_info0 -+ .byte 0x8 -+ .byte 0x0 -+ .value 0x0 -+ .value 0x0 -+ .quad .Ltext0 -+ .quad .Letext0-.Ltext0 -+ .quad 0x0 -+ .quad 0x0 -+ .section .debug_str,"MS",@progbits,1 -+.LASF0: -+ .string "array" -+.LASF5: -+ .string "size" -+.LASF3: -+ .string "x86_64-vla-pointer.c" -+.LASF6: -+ .string "array_t" -+.LASF1: -+ .string "char" -+.LASF4: -+ .string "gdb.arch" -+.LASF2: -+ .string "GNU C 4.3.2 20081105 (Red Hat 4.3.2-7)" -+ .ident "GCC: (GNU) 4.3.2 20081105 (Red Hat 4.3.2-7)" -+ .section .note.GNU-stack,"",@progbits -diff --git a/gdb/testsuite/gdb.arch/x86_64-vla-pointer.c b/gdb/testsuite/gdb.arch/x86_64-vla-pointer.c -new file mode 100644 -index 0000000..fe2c8f7 ---- /dev/null -+++ b/gdb/testsuite/gdb.arch/x86_64-vla-pointer.c -@@ -0,0 +1,43 @@ -+/* This testcase is part of GDB, the GNU debugger. -+ -+ Copyright 2009 Free Software Foundation, Inc. -+ -+ This program is free software; you can redistribute it and/or modify -+ it under the terms of the GNU General Public License as published by -+ the Free Software Foundation; either version 3 of the License, or -+ (at your option) any later version. -+ -+ This program is distributed in the hope that it will be useful, -+ but WITHOUT ANY WARRANTY; without even the implied warranty of -+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+ GNU General Public License for more details. -+ -+ You should have received a copy of the GNU General Public License -+ along with this program. If not, see . */ -+ -+#if 0 -+ -+void -+foo (int size) -+{ -+ typedef char array_t[size]; -+ array_t array; -+ int i; -+ -+ for (i = 0; i < size; i++) -+ array[i] = i; -+ -+ array[0] = 0; /* break-here */ -+} -+ -+#else -+ -+int -+main (void) -+{ -+ foo (26); -+ foo (78); -+ return 0; -+} -+ -+#endif -diff --git a/gdb/testsuite/gdb.arch/x86_64-vla-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 -@@ -0,0 +1,66 @@ -+# Copyright 2009 Free Software Foundation, Inc. -+ -+# This program is free software; you can redistribute it and/or modify -+# it under the terms of the GNU General Public License as published by -+# the Free Software Foundation; either version 3 of the License, or -+# (at your option) any later version. -+# -+# This program is distributed in the hope that it will be useful, -+# but WITHOUT ANY WARRANTY; without even the implied warranty of -+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+# GNU General Public License for more details. -+# -+# You should have received a copy of the GNU General Public License -+# along with this program. If not, see . -+ -+if ![istarget "x86_64-*-*"] then { -+ verbose "Skipping over gdb.arch/x86_64-vla-pointer.exp test made only for x86_64." -+ return -+} -+ -+set testfile x86_64-vla-pointer -+set srcasmfile ${testfile}-foo.S -+set srcfile ${testfile}.c -+set binfile ${objdir}/${subdir}/${testfile} -+set binobjfile ${objdir}/${subdir}/${testfile}-foo.o -+if { [gdb_compile "${srcdir}/${subdir}/${srcasmfile}" "${binobjfile}" object {}] != "" } { -+ untested "Couldn't compile test program" -+ return -1 -+} -+if { [gdb_compile "${srcdir}/${subdir}/${srcfile} ${binobjfile}" "${binfile}" executable {debug}] != "" } { -+ untested "Couldn't compile test program" -+ return -1 -+} -+ -+gdb_exit -+gdb_start -+gdb_reinitialize_dir $srcdir/$subdir -+gdb_load ${binfile} -+ -+if ![runto_main] { -+ untested x86_64-vla-pointer -+ return -1 -+} -+ -+gdb_breakpoint "break_here" -+ -+gdb_continue_to_breakpoint "break_here" -+ -+gdb_test "whatis array" "type = char \\(\\*\\)\\\[variable\\\]" "first: whatis array" -+gdb_test "ptype array" "type = char \\(\\*\\)\\\[26\\\]" "first: ptype array" -+ -+gdb_test "whatis *array" "type = char \\\[26\\\]" "first: whatis *array" -+gdb_test "ptype *array" "type = char \\\[26\\\]" "first: ptype *array" -+ -+gdb_test "p (*array)\[1\]" "\\$\[0-9\] = 1 '\\\\001'" -+gdb_test "p (*array)\[2\]" "\\$\[0-9\] = 2 '\\\\002'" -+gdb_test "p (*array)\[3\]" "\\$\[0-9\] = 3 '\\\\003'" -+gdb_test "p (*array)\[4\]" "\\$\[0-9\] = 4 '\\\\004'" -+ -+gdb_continue_to_breakpoint "break_here" -+ -+gdb_test "whatis array" "type = char \\(\\*\\)\\\[variable\\\]" "second: whatis array" -+gdb_test "ptype array" "type = char \\(\\*\\)\\\[78\\\]" "second: ptype array" -+ -+gdb_test "whatis *array" "type = char \\\[78\\\]" "second: whatis *array" -+gdb_test "ptype *array" "type = char \\\[78\\\]" "second: ptype *array" -diff --git a/gdb/testsuite/gdb.arch/x86_64-vla-typedef-foo.S b/gdb/testsuite/gdb.arch/x86_64-vla-typedef-foo.S -new file mode 100644 -index 0000000..66f7a39 ---- /dev/null -+++ b/gdb/testsuite/gdb.arch/x86_64-vla-typedef-foo.S -@@ -0,0 +1,455 @@ -+ .file "x86_64-vla-typedef.c" -+ .section .debug_abbrev,"",@progbits -+.Ldebug_abbrev0: -+ .section .debug_info,"",@progbits -+.Ldebug_info0: -+ .section .debug_line,"",@progbits -+.Ldebug_line0: -+ .text -+.Ltext0: -+.globl foo -+ .type foo, @function -+foo: -+.LFB2: -+ .file 1 "x86_64-vla-typedef.c" -+ .loc 1 22 0 -+ pushq %rbp -+.LCFI0: -+ movq %rsp, %rbp -+.LCFI1: -+ subq $64, %rsp -+.LCFI2: -+ movl %edi, -36(%rbp) -+ .loc 1 22 0 -+ movq %rsp, %rax -+ movq %rax, -48(%rbp) -+ .loc 1 23 0 -+ movl -36(%rbp), %edx -+ movslq %edx,%rax -+ subq $1, %rax -+ movq %rax, -24(%rbp) -+ .loc 1 24 0 -+ movslq %edx,%rax -+ addq $15, %rax -+ addq $15, %rax -+ shrq $4, %rax -+ salq $4, %rax -+ subq %rax, %rsp -+ movq %rsp, -56(%rbp) -+ movq -56(%rbp), %rax -+ addq $15, %rax -+ shrq $4, %rax -+ salq $4, %rax -+ movq %rax, -56(%rbp) -+ movq -56(%rbp), %rax -+ movq %rax, -16(%rbp) -+ .loc 1 27 0 -+ movl $0, -4(%rbp) -+ jmp .L2 -+.L3: -+ .loc 1 28 0 -+ movl -4(%rbp), %esi -+ movl -4(%rbp), %eax -+ movl %eax, %ecx -+ movq -16(%rbp), %rdx -+ movslq %esi,%rax -+ movb %cl, (%rdx,%rax) -+ .loc 1 27 0 -+ addl $1, -4(%rbp) -+.L2: -+ movl -4(%rbp), %eax -+ cmpl -36(%rbp), %eax -+ jl .L3 -+ .loc 1 30 0 -+ .globl break_here -+break_here: -+ movq -16(%rbp), %rax -+ movb $0, (%rax) -+ movq -48(%rbp), %rsp -+ .loc 1 31 0 -+ leave -+ ret -+.LFE2: -+ .size foo, .-foo -+ .section .debug_frame,"",@progbits -+.Lframe0: -+ .long .LECIE0-.LSCIE0 -+.LSCIE0: -+ .long 0xffffffff -+ .byte 0x1 -+ .string "" -+ .uleb128 0x1 -+ .sleb128 -8 -+ .byte 0x10 -+ .byte 0xc -+ .uleb128 0x7 -+ .uleb128 0x8 -+ .byte 0x90 -+ .uleb128 0x1 -+ .align 8 -+.LECIE0: -+.LSFDE0: -+ .long .LEFDE0-.LASFDE0 -+.LASFDE0: -+ .long .Lframe0 -+ .quad .LFB2 -+ .quad .LFE2-.LFB2 -+ .byte 0x4 -+ .long .LCFI0-.LFB2 -+ .byte 0xe -+ .uleb128 0x10 -+ .byte 0x86 -+ .uleb128 0x2 -+ .byte 0x4 -+ .long .LCFI1-.LCFI0 -+ .byte 0xd -+ .uleb128 0x6 -+ .align 8 -+.LEFDE0: -+ .section .eh_frame,"a",@progbits -+.Lframe1: -+ .long .LECIE1-.LSCIE1 -+.LSCIE1: -+ .long 0x0 -+ .byte 0x1 -+ .string "zR" -+ .uleb128 0x1 -+ .sleb128 -8 -+ .byte 0x10 -+ .uleb128 0x1 -+ .byte 0x3 -+ .byte 0xc -+ .uleb128 0x7 -+ .uleb128 0x8 -+ .byte 0x90 -+ .uleb128 0x1 -+ .align 8 -+.LECIE1: -+.LSFDE1: -+ .long .LEFDE1-.LASFDE1 -+.LASFDE1: -+ .long .LASFDE1-.Lframe1 -+ .long .LFB2 -+ .long .LFE2-.LFB2 -+ .uleb128 0x0 -+ .byte 0x4 -+ .long .LCFI0-.LFB2 -+ .byte 0xe -+ .uleb128 0x10 -+ .byte 0x86 -+ .uleb128 0x2 -+ .byte 0x4 -+ .long .LCFI1-.LCFI0 -+ .byte 0xd -+ .uleb128 0x6 -+ .align 8 -+.LEFDE1: -+ .text -+.Letext0: -+ .section .debug_loc,"",@progbits -+.Ldebug_loc0: -+.LLST0: -+ .quad .LFB2-.Ltext0 -+ .quad .LCFI0-.Ltext0 -+ .value 0x2 -+ .byte 0x77 -+ .sleb128 8 -+ .quad .LCFI0-.Ltext0 -+ .quad .LCFI1-.Ltext0 -+ .value 0x2 -+ .byte 0x77 -+ .sleb128 16 -+ .quad .LCFI1-.Ltext0 -+ .quad .LFE2-.Ltext0 -+ .value 0x2 -+ .byte 0x76 -+ .sleb128 16 -+ .quad 0x0 -+ .quad 0x0 -+ .section .debug_info -+ .long .Ldebug_end - .Ldebug_start -+.Ldebug_start: -+ .value 0x2 -+ .long .Ldebug_abbrev0 -+ .byte 0x8 -+ .uleb128 0x1 -+ .long .LASF2 -+ .byte 0x1 -+ .long .LASF3 -+ .long .LASF4 -+ .quad .Ltext0 -+ .quad .Letext0 -+ .long .Ldebug_line0 -+ .uleb128 0x2 -+ .byte 0x1 -+ .string "foo" -+ .byte 0x1 -+ .byte 0x16 -+ .byte 0x1 -+ .quad .LFB2 -+ .quad .LFE2 -+ .long .LLST0 -+ .long 0x83 -+ .uleb128 0x3 -+ .long .LASF5 -+ .byte 0x1 -+ .byte 0x15 -+ .long 0x83 -+ .byte 0x2 -+ .byte 0x91 -+ .sleb128 -52 -+.Ltag_typedef: -+ .uleb128 0x4 -+ .long .LASF6 -+ .byte 0x1 -+ .byte 0x17 -+ .long .Ltag_array_type - .debug_info -+ .uleb128 0x5 /* Abbrev Number: 5 (DW_TAG_variable) */ -+ .long .LASF0 -+ .byte 0x1 -+ .byte 0x18 -+#if 1 -+ .long .Ltag_typedef - .debug_info -+#else -+ /* Debugging only: Skip the typedef indirection. */ -+ .long .Ltag_array_type - .debug_info -+#endif -+ /* DW_AT_location: DW_FORM_block1: start */ -+ .byte 0x3 -+ .byte 0x91 -+ .sleb128 -32 -+#if 0 -+ .byte 0x6 /* DW_OP_deref */ -+#else -+ .byte 0x96 /* DW_OP_nop */ -+#endif -+ /* DW_AT_location: DW_FORM_block1: end */ -+ .uleb128 0x6 -+ .string "i" -+ .byte 0x1 -+ .byte 0x19 -+ .long 0x83 -+ .byte 0x2 -+ .byte 0x91 -+ .sleb128 -20 -+ .byte 0x0 -+ .uleb128 0x7 -+ .byte 0x4 -+ .byte 0x5 -+ .string "int" -+.Ltag_array_type: -+ .uleb128 0x8 /* Abbrev Number: 8 (DW_TAG_array_type) */ -+ .long 0xa0 + (2f - 1f) /* DW_AT_type: DW_FORM_ref4 */ -+ .long 0x9d + (2f - 1f) /* DW_AT_sibling: DW_FORM_ref4 */ -+1: /* DW_AT_data_location: DW_FORM_block1: start */ -+ .byte 2f - 3f /* length */ -+3: -+ .byte 0x97 /* DW_OP_push_object_address */ -+ .byte 0x6 /* DW_OP_deref */ -+2: /* DW_AT_data_location: DW_FORM_block1: end */ -+ .uleb128 0x9 -+ .long 0x9d + (2b - 1b) /* DW_AT_type: DW_FORM_ref4 */ -+ .byte 0x3 -+ .byte 0x91 -+ .sleb128 -40 -+ .byte 0x6 -+ .byte 0x0 -+ .uleb128 0xa -+ .byte 0x8 -+ .byte 0x7 -+ .uleb128 0xb -+ .byte 0x1 -+ .byte 0x6 -+ .long .LASF1 -+ .byte 0x0 -+.Ldebug_end: -+ .section .debug_abbrev -+ .uleb128 0x1 -+ .uleb128 0x11 -+ .byte 0x1 -+ .uleb128 0x25 -+ .uleb128 0xe -+ .uleb128 0x13 -+ .uleb128 0xb -+ .uleb128 0x3 -+ .uleb128 0xe -+ .uleb128 0x1b -+ .uleb128 0xe -+ .uleb128 0x11 -+ .uleb128 0x1 -+ .uleb128 0x12 -+ .uleb128 0x1 -+ .uleb128 0x10 -+ .uleb128 0x6 -+ .byte 0x0 -+ .byte 0x0 -+ .uleb128 0x2 -+ .uleb128 0x2e -+ .byte 0x1 -+ .uleb128 0x3f -+ .uleb128 0xc -+ .uleb128 0x3 -+ .uleb128 0x8 -+ .uleb128 0x3a -+ .uleb128 0xb -+ .uleb128 0x3b -+ .uleb128 0xb -+ .uleb128 0x27 -+ .uleb128 0xc -+ .uleb128 0x11 -+ .uleb128 0x1 -+ .uleb128 0x12 -+ .uleb128 0x1 -+ .uleb128 0x40 -+ .uleb128 0x6 -+ .uleb128 0x1 -+ .uleb128 0x13 -+ .byte 0x0 -+ .byte 0x0 -+ .uleb128 0x3 -+ .uleb128 0x5 -+ .byte 0x0 -+ .uleb128 0x3 -+ .uleb128 0xe -+ .uleb128 0x3a -+ .uleb128 0xb -+ .uleb128 0x3b -+ .uleb128 0xb -+ .uleb128 0x49 -+ .uleb128 0x13 -+ .uleb128 0x2 -+ .uleb128 0xa -+ .byte 0x0 -+ .byte 0x0 -+ .uleb128 0x4 -+ .uleb128 0x16 -+ .byte 0x0 -+ .uleb128 0x3 -+ .uleb128 0xe -+ .uleb128 0x3a -+ .uleb128 0xb -+ .uleb128 0x3b -+ .uleb128 0xb -+ .uleb128 0x49 -+ .uleb128 0x13 -+ .byte 0x0 -+ .byte 0x0 -+ .uleb128 0x5 -+ .uleb128 0x34 -+ .byte 0x0 -+ .uleb128 0x3 -+ .uleb128 0xe -+ .uleb128 0x3a -+ .uleb128 0xb -+ .uleb128 0x3b -+ .uleb128 0xb -+ .uleb128 0x49 -+ .uleb128 0x13 -+ .uleb128 0x2 -+ .uleb128 0xa -+ .byte 0x0 -+ .byte 0x0 -+ .uleb128 0x6 -+ .uleb128 0x34 -+ .byte 0x0 -+ .uleb128 0x3 -+ .uleb128 0x8 -+ .uleb128 0x3a -+ .uleb128 0xb -+ .uleb128 0x3b -+ .uleb128 0xb -+ .uleb128 0x49 -+ .uleb128 0x13 -+ .uleb128 0x2 -+ .uleb128 0xa -+ .byte 0x0 -+ .byte 0x0 -+ .uleb128 0x7 -+ .uleb128 0x24 -+ .byte 0x0 -+ .uleb128 0xb -+ .uleb128 0xb -+ .uleb128 0x3e -+ .uleb128 0xb -+ .uleb128 0x3 -+ .uleb128 0x8 -+ .byte 0x0 -+ .byte 0x0 -+ .uleb128 0x8 /* Abbrev Number: 8 (DW_TAG_array_type) */ -+ .uleb128 0x1 -+ .byte 0x1 -+ .uleb128 0x49 /* DW_AT_type */ -+ .uleb128 0x13 /* DW_FORM_ref4 */ -+ .uleb128 0x1 /* DW_AT_sibling */ -+ .uleb128 0x13 /* DW_FORM_ref4 */ -+ .uleb128 0x50 /* DW_AT_data_location */ -+ .uleb128 0xa /* DW_FORM_block1 */ -+ .byte 0x0 -+ .byte 0x0 -+ .uleb128 0x9 -+ .uleb128 0x21 -+ .byte 0x0 -+ .uleb128 0x49 /* DW_AT_type */ -+ .uleb128 0x13 /* DW_FORM_ref4 */ -+ .uleb128 0x2f -+ .uleb128 0xa -+ .byte 0x0 -+ .byte 0x0 -+ .uleb128 0xa -+ .uleb128 0x24 -+ .byte 0x0 -+ .uleb128 0xb -+ .uleb128 0xb -+ .uleb128 0x3e -+ .uleb128 0xb -+ .byte 0x0 -+ .byte 0x0 -+ .uleb128 0xb -+ .uleb128 0x24 -+ .byte 0x0 -+ .uleb128 0xb -+ .uleb128 0xb -+ .uleb128 0x3e -+ .uleb128 0xb -+ .uleb128 0x3 -+ .uleb128 0xe -+ .byte 0x0 -+ .byte 0x0 -+ .byte 0x0 -+ .section .debug_pubnames,"",@progbits -+ .long 0x16 -+ .value 0x2 -+ .long .Ldebug_info0 -+ .long 0xa8 -+ .long 0x2d -+ .string "foo" -+ .long 0x0 -+ .section .debug_aranges,"",@progbits -+ .long 0x2c -+ .value 0x2 -+ .long .Ldebug_info0 -+ .byte 0x8 -+ .byte 0x0 -+ .value 0x0 -+ .value 0x0 -+ .quad .Ltext0 -+ .quad .Letext0-.Ltext0 -+ .quad 0x0 -+ .quad 0x0 -+ .section .debug_str,"MS",@progbits,1 -+.LASF0: -+ .string "array" -+.LASF5: -+ .string "size" -+.LASF3: -+ .string "x86_64-vla-typedef.c" -+.LASF6: -+ .string "array_t" -+.LASF1: -+ .string "char" -+.LASF4: -+ .string "gdb.arch" -+.LASF2: -+ .string "GNU C 4.3.2 20081105 (Red Hat 4.3.2-7)" -+ .ident "GCC: (GNU) 4.3.2 20081105 (Red Hat 4.3.2-7)" -+ .section .note.GNU-stack,"",@progbits -diff --git a/gdb/testsuite/gdb.arch/x86_64-vla-typedef.c b/gdb/testsuite/gdb.arch/x86_64-vla-typedef.c -new file mode 100644 -index 0000000..b809c4e ---- /dev/null -+++ b/gdb/testsuite/gdb.arch/x86_64-vla-typedef.c -@@ -0,0 +1,43 @@ -+/* This testcase is part of GDB, the GNU debugger. -+ -+ Copyright 2008 Free Software Foundation, Inc. -+ -+ This program is free software; you can redistribute it and/or modify -+ it under the terms of the GNU General Public License as published by -+ the Free Software Foundation; either version 3 of the License, or -+ (at your option) any later version. -+ -+ This program is distributed in the hope that it will be useful, -+ but WITHOUT ANY WARRANTY; without even the implied warranty of -+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+ GNU General Public License for more details. -+ -+ You should have received a copy of the GNU General Public License -+ along with this program. If not, see . */ -+ -+#if 0 -+ -+void -+foo (int size) -+{ -+ typedef char array_t[size]; -+ array_t array; -+ int i; -+ -+ for (i = 0; i < size; i++) -+ array[i] = i; -+ -+ array[0] = 0; /* break-here */ -+} -+ -+#else -+ -+int -+main (void) -+{ -+ foo (26); -+ foo (78); -+ return 0; -+} -+ -+#endif -diff --git a/gdb/testsuite/gdb.arch/x86_64-vla-typedef.exp b/gdb/testsuite/gdb.arch/x86_64-vla-typedef.exp -new file mode 100644 -index 0000000..b05411e ---- /dev/null -+++ b/gdb/testsuite/gdb.arch/x86_64-vla-typedef.exp -@@ -0,0 +1,64 @@ -+# Copyright 2009 Free Software Foundation, Inc. -+ -+# This program is free software; you can redistribute it and/or modify -+# it under the terms of the GNU General Public License as published by -+# the Free Software Foundation; either version 3 of the License, or -+# (at your option) any later version. -+# -+# This program is distributed in the hope that it will be useful, -+# but WITHOUT ANY WARRANTY; without even the implied warranty of -+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+# GNU General Public License for more details. -+# -+# You should have received a copy of the GNU General Public License -+# along with this program. If not, see . -+ -+# Test DW_AT_data_location accessed through DW_TAG_typedef intermediate. -+ -+if ![istarget "x86_64-*-*"] then { -+ verbose "Skipping over gdb.arch/x86_64-vla-typedef.exp test made only for x86_64." -+ return -+} -+ -+set testfile x86_64-vla-typedef -+set srcasmfile ${testfile}-foo.S -+set srcfile ${testfile}.c -+set binfile ${objdir}/${subdir}/${testfile} -+set binobjfile ${objdir}/${subdir}/${testfile}-foo.o -+if { [gdb_compile "${srcdir}/${subdir}/${srcasmfile}" "${binobjfile}" object {}] != "" } { -+ untested "Couldn't compile test program" -+ return -1 -+} -+if { [gdb_compile "${srcdir}/${subdir}/${srcfile} ${binobjfile}" "${binfile}" executable {debug}] != "" } { -+ untested "Couldn't compile test program" -+ return -1 -+} -+ -+gdb_exit -+gdb_start -+gdb_reinitialize_dir $srcdir/$subdir -+gdb_load ${binfile} -+ -+if ![runto_main] { -+ untested x86_64-vla-typedef -+ return -1 -+} -+ -+gdb_breakpoint "break_here" -+ -+gdb_continue_to_breakpoint "break_here" -+ -+gdb_test "whatis array" "type = array_t" "first: whatis array" -+ -+gdb_test "ptype array" "type = char \\\[26\\\]" "first: ptype array" -+ -+gdb_test "p array\[1\]" "\\$\[0-9\] = 1 '\\\\001'" -+gdb_test "p array\[2\]" "\\$\[0-9\] = 2 '\\\\002'" -+gdb_test "p array\[3\]" "\\$\[0-9\] = 3 '\\\\003'" -+gdb_test "p array\[4\]" "\\$\[0-9\] = 4 '\\\\004'" -+ -+gdb_continue_to_breakpoint "break_here" -+ -+gdb_test "whatis array" "type = array_t" "second: whatis array" -+ -+gdb_test "ptype array" "type = char \\\[78\\\]" "second: ptype array" -diff --git a/gdb/testsuite/gdb.base/arrayidx.c b/gdb/testsuite/gdb.base/arrayidx.c -index a99137e..c3dc2d9 100644 ---- a/gdb/testsuite/gdb.base/arrayidx.c -+++ b/gdb/testsuite/gdb.base/arrayidx.c -@@ -17,6 +17,13 @@ - - int array[] = {1, 2, 3, 4}; - -+#ifdef __GNUC__ -+struct -+ { -+ int a[0]; -+ } unbound; -+#endif -+ - int - main (void) - { -diff --git a/gdb/testsuite/gdb.base/arrayidx.exp b/gdb/testsuite/gdb.base/arrayidx.exp -index cba0024..0dc0e46 100644 ---- a/gdb/testsuite/gdb.base/arrayidx.exp -+++ b/gdb/testsuite/gdb.base/arrayidx.exp -@@ -53,4 +53,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/default.exp b/gdb/testsuite/gdb.base/default.exp -index 9677396..55d03a9 100644 ---- a/gdb/testsuite/gdb.base/default.exp -+++ b/gdb/testsuite/gdb.base/default.exp -@@ -610,6 +610,19 @@ gdb_test_list_exact "show convenience" "show convenience" \ - {$_sdata = void} \ - {$_siginfo = void} \ - {$_thread = 0} \ -+ {$_probe_argc = } \ -+ {$_probe_arg0 = } \ -+ {$_probe_arg1 = } \ -+ {$_probe_arg2 = } \ -+ {$_probe_arg3 = } \ -+ {$_probe_arg4 = } \ -+ {$_probe_arg5 = } \ -+ {$_probe_arg6 = } \ -+ {$_probe_arg7 = } \ -+ {$_probe_arg8 = } \ -+ {$_probe_arg9 = } \ -+ {$_probe_arg10 = } \ -+ {$_probe_arg11 = } \ - } - - #test show directories -diff --git a/gdb/testsuite/gdb.base/internal-var-field-address.c b/gdb/testsuite/gdb.base/internal-var-field-address.c -new file mode 100644 -index 0000000..eeb7b85 ---- /dev/null -+++ b/gdb/testsuite/gdb.base/internal-var-field-address.c -@@ -0,0 +1,20 @@ -+/* This testcase is part of GDB, the GNU debugger. -+ -+ Copyright 2009 Free Software Foundation, Inc. -+ -+ This program is free software; you can redistribute it and/or modify -+ it under the terms of the GNU General Public License as published by -+ the Free Software Foundation; either version 3 of the License, or -+ (at your option) any later version. -+ -+ This program is distributed in the hope that it will be useful, -+ but WITHOUT ANY WARRANTY; without even the implied warranty of -+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+ GNU General Public License for more details. -+ -+ You should have received a copy of the GNU General Public License -+ along with this program. If not, see . */ -+ -+struct { -+ int field; -+} staticstruct = { 1 }; -diff --git a/gdb/testsuite/gdb.base/internal-var-field-address.exp b/gdb/testsuite/gdb.base/internal-var-field-address.exp -new file mode 100644 -index 0000000..6d82e73 ---- /dev/null -+++ b/gdb/testsuite/gdb.base/internal-var-field-address.exp -@@ -0,0 +1,26 @@ -+# Copyright 2009 Free Software Foundation, Inc. -+ -+# This program is free software; you can redistribute it and/or modify -+# it under the terms of the GNU General Public License as published by -+# the Free Software Foundation; either version 3 of the License, or -+# (at your option) any later version. -+# -+# This program is distributed in the hope that it will be useful, -+# but WITHOUT ANY WARRANTY; without even the implied warranty of -+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+# GNU General Public License for more details. -+# -+# You should have received a copy of the GNU General Public License -+# along with this program. If not, see . -+ -+set test internal-var-field-address -+set binfile ${test}.x -+if { [gdb_compile "${srcdir}/${subdir}/${test}.c" "${objdir}/${subdir}/${binfile}" object {debug}] != "" } { -+ untested "Couldn't compile test program" -+ return -1 -+} -+ -+clean_restart $binfile -+ -+gdb_test {set $varstruct = staticstruct} -+gdb_test {p $varstruct.field} " = 1" -diff --git a/gdb/testsuite/gdb.base/stap-probe.c b/gdb/testsuite/gdb.base/stap-probe.c -new file mode 100644 -index 0000000..236da96 ---- /dev/null -+++ b/gdb/testsuite/gdb.base/stap-probe.c -@@ -0,0 +1,108 @@ -+/* 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 . */ -+ -+#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 -+ -+__extension__ unsigned short teste_m4_semaphore __attribute__ ((unused)) __attribute__ ((section (".probes"))); -+ -+__extension__ unsigned short teste_pstr_semaphore __attribute__ ((unused)) __attribute__ ((section (".probes"))); -+ -+__extension__ unsigned short teste_ps_semaphore __attribute__ ((unused)) __attribute__ ((section (".probes"))); -+#else -+ -+#define TEST 1 -+#define TEST2 1 -+ -+#endif -+ -+#include -+ -+/* We only support SystemTap and only the v3 form. */ -+#if _SDT_NOTE_TYPE != 3 -+#error "not using SystemTap v3 probes" -+#endif -+ -+struct funcs -+{ -+ int val; -+ -+ const char *(*ps) (int); -+}; -+ -+static void -+m1 (void) -+{ -+ if (TEST2) -+ STAP_PROBE (teste, two); -+} -+ -+static void -+m2 (void) -+{ -+ if (TEST2) -+ STAP_PROBE (teste, two); -+} -+ -+static int -+f (int x) -+{ -+ if (TEST) -+ STAP_PROBE1 (teste, user, x); -+ return x+5; -+} -+ -+static const char * -+pstr (int val) -+{ -+ const char *a = "This is a test message."; -+ const char *b = "This is another test message."; -+ -+ STAP_PROBE3 (teste, ps, a, b, val); -+ -+ return val == 0 ? a : b; -+} -+ -+static void -+m4 (const struct funcs *fs, int v) -+{ -+ STAP_PROBE3 (teste, m4, fs->val, fs->ps (v), v); -+} -+ -+int -+main() -+{ -+ struct funcs fs; -+ -+ fs.val = 42; -+ fs.ps = pstr; -+ -+ f (f (23)); -+ m1 (); -+ m2 (); -+ -+ m4 (&fs, 0); -+ m4 (&fs, 1); -+ -+ return 0; /* last break here */ -+} -diff --git a/gdb/testsuite/gdb.base/stap-probe.exp b/gdb/testsuite/gdb.base/stap-probe.exp -new file mode 100644 -index 0000000..468efb9 ---- /dev/null -+++ b/gdb/testsuite/gdb.base/stap-probe.exp -@@ -0,0 +1,187 @@ -+# 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 . -+ -+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, not optimized" -+ } else { -+ set addendum ", no semaphore, not optimized" -+ } -+ -+ 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 "-p teste:user"]} { -+ pass "run to -p teste:user$addendum" -+ } else { -+ fail "run to -p teste:user$addendum" -+ } -+ -+ # Test probe arguments. -+ gdb_test "print \$_probe_argc" " = 1" \ -+ "print \$_probe_argc for probe user$addendum" -+ gdb_test "print \$_probe_arg0 == x" " = 1" \ -+ "check \$_probe_arg0 for probe user$addendum" -+ gdb_test "print \$_probe_arg1" \ -+ "Invalid probe argument 1 -- probe has 1 arguments available" \ -+ "check \$_probe_arg1 for probe user$addendum" -+ -+ # Set a breakpoint with multiple probe locations. -+ gdb_test "break -p teste:two" \ -+ "Breakpoint \[0-9\]+ at $hex.*2 locations.*" \ -+ "set multi-location probe breakpoint (probe two)$addendum" -+ -+ # Reinit GDB, set a breakpoint on probe m4. -+ delete_breakpoints -+ rerun_to_main -+ if {[runto "-p teste:m4"]} { -+ pass "run to -p teste:m4$addendum" -+ } else { -+ fail "run to -p teste:m4$addendum" -+ } -+ -+ # Testing probe arguments. -+ gdb_test "print \$_probe_argc" " = 3" \ -+ "print \$_probe_argc for probe m4$addendum" -+ gdb_test "print \$_probe_arg0" " = 42" \ -+ "check \$_probe_arg0 for probe m4$addendum" -+ gdb_test "print (const char *) \$_probe_arg1" \ -+ " = $hex .This is a test message.*" \ -+ "check \$_probe_arg1 for probe m4$addendum" -+ gdb_test "print \$_probe_arg2 == v" " = 1" \ -+ "check \$_probe_arg2 for probe m4$addendum" -+ -+ # Reinit GDB, set a breakpoint on probe ps. -+ delete_breakpoints -+ rerun_to_main -+ if {[runto "-p teste:ps"]} { -+ pass "run to -p teste:m4$addendum" -+ } else { -+ fail "run to -p teste:m4$addendum" -+ } -+ -+ gdb_test "print \$_probe_argc" " = 3" \ -+ "print \$_probe_argc for probe ps$addendum" -+ gdb_test "print (const char *) \$_probe_arg1" \ -+ " = $hex .This is another test message.*" \ -+ "print \$_probe_arg1 for probe ps$addendum" -+ -+ return 0 -+} -+ -+proc stap_test_no_debuginfo {{ arg "" }} { -+ global testfile hex -+ -+ if {$arg != ""} { -+ set arg "additional_flags=$arg" -+ set addendum ", with semaphore, optimized" -+ } else { -+ set addendum ", no semaphore, optimized" -+ } -+ -+ if {[prepare_for_testing ${testfile}.exp ${testfile} ${testfile}.c \ -+ {$arg nodebug optimize=-O2}]} { -+ return -1 -+ } -+ -+ if {[runto "-p teste:user"]} { -+ pass "run to -p teste:user$addendum" -+ } else { -+ fail "run to -p teste:user$addendum" -+ } -+ -+ # Test probe arguments. -+ gdb_test "print \$_probe_argc" " = 1" \ -+ "print \$_probe_argc for probe user$addendum" -+ gdb_test "print \$_probe_arg0 == 23" " = 1" \ -+ "check \$_probe_arg0 for probe user$addendum" -+ gdb_test "print \$_probe_arg1" \ -+ "Invalid probe argument 1 -- probe has 1 arguments available" \ -+ "check \$_probe_arg1 for probe user$addendum" -+ -+ # Set a breakpoint with multiple probe locations. -+ # In this scenario, we may expect more than 2 locations because of -+ # the optimizations (inlining, loop unrolling, etc). -+ gdb_test "break -p teste:two" \ -+ "Breakpoint .* at $hex.*\[0-9\]+ locations.*" \ -+ "set multi-location probe breakpoint (probe two)$addendum" -+ -+ # Reinit GDB, set a breakpoint on probe m4. -+ delete_breakpoints -+ rerun_to_main -+ if {[runto "-p teste:m4"]} { -+ pass "run to -p teste:m4$addendum" -+ } else { -+ fail "run to -p teste:m4$addendum" -+ } -+ -+ # Testing probe arguments. -+ gdb_test "print \$_probe_argc" " = 3" \ -+ "print \$_probe_argc for probe m4$addendum" -+ gdb_test "print \$_probe_arg0" " = 42" \ -+ "check \$_probe_arg0 for probe m4$addendum" -+ gdb_test "print (const char *) \$_probe_arg1" \ -+ " = $hex .This is a test message.*" \ -+ "check \$_probe_arg1 for probe m4$addendum" -+ gdb_test "print \$_probe_arg2 == 0" " = 1" \ -+ "check \$_probe_arg2 for probe m4$addendum" -+ -+ # Reinit GDB, set a breakpoint on probe ps. -+ delete_breakpoints -+ rerun_to_main -+ if {[runto "-p teste:ps"]} { -+ pass "run to -p teste:m4$addendum" -+ } else { -+ fail "run to -p teste:m4$addendum" -+ } -+ -+ gdb_test "print \$_probe_argc" " = 3" \ -+ "print \$_probe_argc for probe ps$addendum" -+ gdb_test "print (const char *) \$_probe_arg1" \ -+ " = $hex .This is another test message.*" \ -+ "print \$_probe_arg1 for probe ps$addendum" -+ -+ return 0 -+} -+ -+if {[stap_test] == -1} { -+ untested stap-probe.exp -+ return -1 -+} -+ -+stap_test "-DUSE_PROBES" -+stap_test_no_debuginfo -+stap_test_no_debuginfo "-DUSE_PROBES" -diff --git a/gdb/testsuite/gdb.base/vla-frame.c b/gdb/testsuite/gdb.base/vla-frame.c -new file mode 100644 -index 0000000..5750f68 ---- /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 . */ -+ -+#include -+ -+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; -+} -diff --git a/gdb/testsuite/gdb.base/vla-frame.exp b/gdb/testsuite/gdb.base/vla-frame.exp -new file mode 100644 -index 0000000..47736c7 ---- /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 . -+ -+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.*" -diff --git a/gdb/testsuite/gdb.base/vla-overflow.c b/gdb/testsuite/gdb.base/vla-overflow.c -new file mode 100644 -index 0000000..c5d5ee0 ---- /dev/null -+++ b/gdb/testsuite/gdb.base/vla-overflow.c -@@ -0,0 +1,30 @@ -+/* This testcase is part of GDB, the GNU debugger. -+ -+ Copyright 2008 Free Software Foundation, Inc. -+ -+ This program is free software; you can redistribute it and/or modify -+ it under the terms of the GNU General Public License as published by -+ the Free Software Foundation; either version 3 of the License, or -+ (at your option) any later version. -+ -+ This program is distributed in the hope that it will be useful, -+ but WITHOUT ANY WARRANTY; without even the implied warranty of -+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+ GNU General Public License for more details. -+ -+ You should have received a copy of the GNU General Public License -+ along with this program. If not, see . */ -+ -+#include -+ -+int -+main (int argc, char **argv) -+{ -+ int array[argc]; -+ -+ array[0] = array[0]; -+ -+ abort (); -+ -+ return 0; -+} -diff --git a/gdb/testsuite/gdb.base/vla-overflow.exp b/gdb/testsuite/gdb.base/vla-overflow.exp -new file mode 100644 -index 0000000..24a608f ---- /dev/null -+++ b/gdb/testsuite/gdb.base/vla-overflow.exp -@@ -0,0 +1,109 @@ -+# Copyright 2008 Free Software Foundation, Inc. -+ -+# This program is free software; you can redistribute it and/or modify -+# it under the terms of the GNU General Public License as published by -+# the Free Software Foundation; either version 3 of the License, or -+# (at your option) any later version. -+# -+# This program is distributed in the hope that it will be useful, -+# but WITHOUT ANY WARRANTY; without even the implied warranty of -+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+# GNU General Public License for more details. -+# -+# You should have received a copy of the GNU General Public License -+# along with this program. If not, see . -+ -+# We could crash in: -+# #0 block_linkage_function (bl=0x0) at ../../gdb/block.c:69 -+# #1 in dwarf_block_get_frame_base (...) at ../../gdb/dwarf2block.c:97 -+# 97 framefunc = block_linkage_function (get_frame_block (frame, NULL)); -+# #2 in execute_stack_op (...) at ../../gdb/dwarf2expr.c:496 -+# #3 in dwarf_block_exec_core () at ../../gdb/dwarf2block.c:156 -+# #4 dwarf_block_exec (...) at ../../gdb/dwarf2block.c:206 -+# #5 in range_type_count_bound_internal (...) at ../../gdb/gdbtypes.c:1430 -+# #6 in create_array_type (...) at ../../gdb/gdbtypes.c:840 -+# ... -+# #21 in psymtab_to_symtab (...) at ../../gdb/symfile.c:292 -+# ... -+# #29 in backtrace_command_1 () at ../../gdb/stack.c:1273 -+ -+set testfile vla-overflow -+set shfile ${objdir}/${subdir}/${testfile}-gdb.sh -+set srcfile ${testfile}.c -+set binfile ${objdir}/${subdir}/${testfile} -+if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } { -+ untested "Couldn't compile test program" -+ return -1 -+} -+ -+set f [open "|getconf PAGESIZE" "r"] -+gets $f pagesize -+close $f -+ -+gdb_exit -+gdb_start -+gdb_reinitialize_dir $srcdir/$subdir -+gdb_load ${binfile} -+ -+set pid_of_gdb [exp_pid -i [board_info host fileid]] -+ -+if { [runto_main] < 0 } { -+ untested vla-overflow -+ return -1 -+} -+ -+# Get the GDB memory size when we stay at main. -+ -+proc memory_v_pages_get {} { -+ global pid_of_gdb pagesize -+ set fd [open "/proc/$pid_of_gdb/statm"] -+ gets $fd line -+ close $fd -+ # number of pages of virtual memory -+ scan $line "%d" drs -+ return $drs -+} -+ -+set pages_found [memory_v_pages_get] -+ -+# s390x with glibc-debuginfo.s390x installed used approx. 16MB. -+set mb_reserve 40 -+verbose -log "pages_found = $pages_found, mb_reserve = $mb_reserve" -+set kb_found [expr $pages_found * $pagesize / 1024] -+set kb_permit [expr $kb_found + 1 * 1024 + $mb_reserve * 1024] -+verbose -log "kb_found = $kb_found, kb_permit = $kb_permit" -+ -+# Create the ulimit wrapper. -+set f [open $shfile "w"] -+puts $f "#! /bin/sh" -+puts $f "ulimit -v $kb_permit" -+puts $f "exec $GDB \"\$@\"" -+close $f -+remote_exec host "chmod +x $shfile" -+ -+gdb_exit -+set GDBold $GDB -+set GDB "$shfile" -+gdb_start -+set GDB $GDBold -+ -+gdb_reinitialize_dir $srcdir/$subdir -+gdb_load ${binfile} -+ -+set pid_of_gdb [exp_pid -i [board_info host fileid]] -+ -+# Check the size again after the second run. -+# We must not stop in main as it would cache `array' and never crash later. -+ -+gdb_run_cmd -+ -+verbose -log "kb_found before abort() = [expr [memory_v_pages_get] * $pagesize / 1024]" -+ -+gdb_test "" "Program received signal SIGABRT, Aborted..*" "Enter abort()" -+ -+verbose -log "kb_found in abort() = [expr [memory_v_pages_get] * $pagesize / 1024]" -+ -+# `abort' can get expressed as `*__GI_abort'. -+gdb_test "bt" "in \[^ \]*abort \\(.* in main \\(.*" "Backtrace after abort()" -+ -+verbose -log "kb_found in bt after abort() = [expr [memory_v_pages_get] * $pagesize / 1024]" -diff --git a/gdb/testsuite/gdb.base/vla.c b/gdb/testsuite/gdb.base/vla.c ++ /* DW_AT_location: DW_FORM_block1: end */ ++ .uleb128 0x6 ++ .string "i" ++ .byte 0x1 ++ .byte 0x19 ++ .long .Ltype_int - .Ldebug_relative ++ .byte 0x2 ++ .byte 0x91 ++ .sleb128 -20 ++ .byte 0x0 ++.Ltype_int: ++ .uleb128 0x7 ++ .byte 0x4 ++ .byte 0x5 ++ .string "int" ++.Ltag_array_type: ++ .uleb128 0x8 /* Abbrev Number: 8 (DW_TAG_array_type) */ ++ .long .Ltype_char - .Ldebug_relative ++ .long .Ltype_ulong - .Ldebug_relative /* DW_AT_sibling: DW_FORM_ref4 */ ++1: /* DW_AT_data_location: DW_FORM_block1: start */ ++ .byte 2f - 3f /* length */ ++3: ++ .byte 0x97 /* DW_OP_push_object_address */ ++#if 1 ++ .byte 0x6 /* DW_OP_deref */ ++#else ++ .byte 0x96 /* DW_OP_nop */ ++#endif ++2: /* DW_AT_data_location: DW_FORM_block1: end */ ++ .uleb128 0x9 ++ .long .Ltype_char - .Ldebug_relative /* DW_AT_type: DW_FORM_ref4 */ ++ .byte 0x3 ++ .byte 0x91 ++ .sleb128 -40 ++ .byte 0x6 ++ .byte 0x0 ++.Ltype_ulong: ++ .uleb128 0xa ++ .byte 0x8 ++ .byte 0x7 ++.Ltype_char: ++ .uleb128 0xb ++ .byte 0x1 ++ .byte 0x6 ++ .long .LASF1 ++ .byte 0x0 ++.Ldebug_end: ++ .section .debug_abbrev ++ .uleb128 0x1 ++ .uleb128 0x11 ++ .byte 0x1 ++ .uleb128 0x25 ++ .uleb128 0xe ++ .uleb128 0x13 ++ .uleb128 0xb ++ .uleb128 0x3 ++ .uleb128 0xe ++ .uleb128 0x1b ++ .uleb128 0xe ++ .uleb128 0x11 ++ .uleb128 0x1 ++ .uleb128 0x12 ++ .uleb128 0x1 ++ .uleb128 0x10 ++ .uleb128 0x6 ++ .byte 0x0 ++ .byte 0x0 ++ .uleb128 0x2 ++ .uleb128 0x2e ++ .byte 0x1 ++ .uleb128 0x3f ++ .uleb128 0xc ++ .uleb128 0x3 ++ .uleb128 0x8 ++ .uleb128 0x3a ++ .uleb128 0xb ++ .uleb128 0x3b ++ .uleb128 0xb ++ .uleb128 0x27 ++ .uleb128 0xc ++ .uleb128 0x11 ++ .uleb128 0x1 ++ .uleb128 0x12 ++ .uleb128 0x1 ++ .uleb128 0x40 ++ .uleb128 0x6 ++ .uleb128 0x1 ++ .uleb128 0x13 ++ .byte 0x0 ++ .byte 0x0 ++ .uleb128 0x3 ++ .uleb128 0x5 ++ .byte 0x0 ++ .uleb128 0x3 ++ .uleb128 0xe ++ .uleb128 0x3a ++ .uleb128 0xb ++ .uleb128 0x3b ++ .uleb128 0xb ++ .uleb128 0x49 ++ .uleb128 0x13 ++ .uleb128 0x2 ++ .uleb128 0xa ++ .byte 0x0 ++ .byte 0x0 ++ .uleb128 0x4 /* .Ltag_pointer abbrev */ ++ .uleb128 0x0f /* DW_TAG_pointer_type */ ++ .byte 0x0 ++ .uleb128 0x0b ++ .uleb128 0xb ++ .uleb128 0x49 ++ .uleb128 0x13 ++ .byte 0x0 ++ .byte 0x0 ++ .uleb128 0x5 ++ .uleb128 0x34 ++ .byte 0x0 ++ .uleb128 0x3 ++ .uleb128 0xe ++ .uleb128 0x3a ++ .uleb128 0xb ++ .uleb128 0x3b ++ .uleb128 0xb ++ .uleb128 0x49 ++ .uleb128 0x13 ++ .uleb128 0x2 ++ .uleb128 0xa ++ .byte 0x0 ++ .byte 0x0 ++ .uleb128 0x6 ++ .uleb128 0x34 ++ .byte 0x0 ++ .uleb128 0x3 ++ .uleb128 0x8 ++ .uleb128 0x3a ++ .uleb128 0xb ++ .uleb128 0x3b ++ .uleb128 0xb ++ .uleb128 0x49 ++ .uleb128 0x13 ++ .uleb128 0x2 ++ .uleb128 0xa ++ .byte 0x0 ++ .byte 0x0 ++ .uleb128 0x7 ++ .uleb128 0x24 ++ .byte 0x0 ++ .uleb128 0xb ++ .uleb128 0xb ++ .uleb128 0x3e ++ .uleb128 0xb ++ .uleb128 0x3 ++ .uleb128 0x8 ++ .byte 0x0 ++ .byte 0x0 ++ .uleb128 0x8 /* Abbrev Number: 8 (DW_TAG_array_type) */ ++ .uleb128 0x1 ++ .byte 0x1 ++ .uleb128 0x49 /* DW_AT_type */ ++ .uleb128 0x13 /* DW_FORM_ref4 */ ++ .uleb128 0x1 /* DW_AT_sibling */ ++ .uleb128 0x13 /* DW_FORM_ref4 */ ++ .uleb128 0x50 /* DW_AT_data_location */ ++ .uleb128 0xa /* DW_FORM_block1 */ ++ .byte 0x0 ++ .byte 0x0 ++ .uleb128 0x9 ++ .uleb128 0x21 ++ .byte 0x0 ++ .uleb128 0x49 /* DW_AT_type */ ++ .uleb128 0x13 /* DW_FORM_ref4 */ ++ .uleb128 0x2f ++ .uleb128 0xa ++ .byte 0x0 ++ .byte 0x0 ++ .uleb128 0xa ++ .uleb128 0x24 ++ .byte 0x0 ++ .uleb128 0xb ++ .uleb128 0xb ++ .uleb128 0x3e ++ .uleb128 0xb ++ .byte 0x0 ++ .byte 0x0 ++ .uleb128 0xb ++ .uleb128 0x24 ++ .byte 0x0 ++ .uleb128 0xb ++ .uleb128 0xb ++ .uleb128 0x3e ++ .uleb128 0xb ++ .uleb128 0x3 ++ .uleb128 0xe ++ .byte 0x0 ++ .byte 0x0 ++ .byte 0x0 ++ .section .debug_pubnames,"",@progbits ++ .long 0x16 ++ .value 0x2 ++ .long .Ldebug_info0 ++ .long 0xa8 ++ .long 0x2d ++ .string "foo" ++ .long 0x0 ++ .section .debug_aranges,"",@progbits ++ .long 0x2c ++ .value 0x2 ++ .long .Ldebug_info0 ++ .byte 0x8 ++ .byte 0x0 ++ .value 0x0 ++ .value 0x0 ++ .quad .Ltext0 ++ .quad .Letext0-.Ltext0 ++ .quad 0x0 ++ .quad 0x0 ++ .section .debug_str,"MS",@progbits,1 ++.LASF0: ++ .string "array" ++.LASF5: ++ .string "size" ++.LASF3: ++ .string "x86_64-vla-pointer.c" ++.LASF6: ++ .string "array_t" ++.LASF1: ++ .string "char" ++.LASF4: ++ .string "gdb.arch" ++.LASF2: ++ .string "GNU C 4.3.2 20081105 (Red Hat 4.3.2-7)" ++ .ident "GCC: (GNU) 4.3.2 20081105 (Red Hat 4.3.2-7)" ++ .section .note.GNU-stack,"",@progbits +diff --git a/gdb/testsuite/gdb.arch/x86_64-vla-pointer.c b/gdb/testsuite/gdb.arch/x86_64-vla-pointer.c new file mode 100644 -index 0000000..e1f3ed1 +index 0000000..fe2c8f7 --- /dev/null -+++ b/gdb/testsuite/gdb.base/vla.c -@@ -0,0 +1,55 @@ ++++ b/gdb/testsuite/gdb.arch/x86_64-vla-pointer.c +@@ -0,0 +1,43 @@ +/* This testcase is part of GDB, the GNU debugger. + -+ Copyright 2008 Free Software Foundation, Inc. ++ Copyright 2009 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by @@ -12381,37 +5630,23 @@ index 0000000..e1f3ed1 + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + -+#include -+ -+void -+marker (void) -+{ -+} -+ -+void -+bar (char *a, char *b, char *c, int size) -+{ -+ memset (a, '1', size); -+ memset (b, '2', size); -+ memset (c, '3', 48); -+} ++#if 0 + +void +foo (int size) +{ -+ char temp1[size]; -+ char temp3[48]; -+ -+ temp1[size - 1] = '\0'; -+ { -+ char temp2[size]; ++ typedef char array_t[size]; ++ array_t array; ++ int i; + -+ bar (temp1, temp2, temp3, size); ++ for (i = 0; i < size; i++) ++ array[i] = i; + -+ marker (); /* break-here */ -+ } ++ array[0] = 0; /* break-here */ +} + ++#else ++ +int +main (void) +{ @@ -12419,13 +5654,15 @@ index 0000000..e1f3ed1 + foo (78); + return 0; +} -diff --git a/gdb/testsuite/gdb.base/vla.exp b/gdb/testsuite/gdb.base/vla.exp ++ ++#endif +diff --git a/gdb/testsuite/gdb.arch/x86_64-vla-pointer.exp b/gdb/testsuite/gdb.arch/x86_64-vla-pointer.exp new file mode 100644 -index 0000000..5da7378 +index 0000000..d243cf1 --- /dev/null -+++ b/gdb/testsuite/gdb.base/vla.exp -@@ -0,0 +1,62 @@ -+# Copyright 2008 Free Software Foundation, Inc. ++++ b/gdb/testsuite/gdb.arch/x86_64-vla-pointer.exp +@@ -0,0 +1,66 @@ ++# Copyright 2009 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by @@ -12440,10 +5677,21 @@ index 0000000..5da7378 +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + -+set testfile vla ++if ![istarget "x86_64-*-*"] then { ++ verbose "Skipping over gdb.arch/x86_64-vla-pointer.exp test made only for x86_64." ++ return ++} ++ ++set testfile x86_64-vla-pointer ++set srcasmfile ${testfile}-foo.S +set srcfile ${testfile}.c +set binfile ${objdir}/${subdir}/${testfile} -+if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } { ++set binobjfile ${objdir}/${subdir}/${testfile}-foo.o ++if { [gdb_compile "${srcdir}/${subdir}/${srcasmfile}" "${binobjfile}" object {}] != "" } { ++ untested "Couldn't compile test program" ++ return -1 ++} ++if { [gdb_compile "${srcdir}/${subdir}/${srcfile} ${binobjfile}" "${binfile}" executable {debug}] != "" } { + untested "Couldn't compile test program" + return -1 +} @@ -12454,70 +5702,502 @@ index 0000000..5da7378 +gdb_load ${binfile} + +if ![runto_main] { -+ untested vla ++ untested x86_64-vla-pointer + 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_breakpoint "break_here" + -+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_continue_to_breakpoint "break_here" + -+gdb_test "p temp1" " = '1' " "first: print temp1" -+gdb_test "p temp2" " = '2' " "first: print temp2" -+gdb_test "p temp3" " = '3' " "first: print temp3" ++gdb_test "whatis array" "type = char \\(\\*\\)\\\[variable\\\]" "first: whatis array" ++gdb_test "ptype array" "type = char \\(\\*\\)\\\[26\\\]" "first: ptype array" + -+gdb_continue_to_breakpoint "break-here" ++gdb_test "whatis *array" "type = char \\\[26\\\]" "first: whatis *array" ++gdb_test "ptype *array" "type = char \\\[26\\\]" "first: ptype *array" + -+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 "p (*array)\[1\]" "\\$\[0-9\] = 1 '\\\\001'" ++gdb_test "p (*array)\[2\]" "\\$\[0-9\] = 2 '\\\\002'" ++gdb_test "p (*array)\[3\]" "\\$\[0-9\] = 3 '\\\\003'" ++gdb_test "p (*array)\[4\]" "\\$\[0-9\] = 4 '\\\\004'" + -+gdb_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_continue_to_breakpoint "break_here" + -+gdb_test "p temp1" " = '1' " "second: print temp1" -+gdb_test "p temp2" " = '2' " "second: print temp2" -+gdb_test "p temp3" " = '3' " "second: print temp3" -diff --git a/gdb/testsuite/gdb.cp/nextoverthrow.exp b/gdb/testsuite/gdb.cp/nextoverthrow.exp -index 7d4a0c5..2dafcab 100644 ---- a/gdb/testsuite/gdb.cp/nextoverthrow.exp -+++ b/gdb/testsuite/gdb.cp/nextoverthrow.exp -@@ -54,6 +54,17 @@ gdb_test_multiple "print _Unwind_DebugHook" "check for unwinder hook" { - } - } - 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 "whatis array" "type = char \\(\\*\\)\\\[variable\\\]" "second: whatis array" ++gdb_test "ptype array" "type = char \\(\\*\\)\\\[78\\\]" "second: ptype array" + -+if {!$ok} { - unsupported "nextoverthrow.exp could not find _Unwind_DebugHook" - return -1 - } -diff --git a/gdb/testsuite/gdb.dwarf2/dw2-bound-loclist.S b/gdb/testsuite/gdb.dwarf2/dw2-bound-loclist.S ++gdb_test "whatis *array" "type = char \\\[78\\\]" "second: whatis *array" ++gdb_test "ptype *array" "type = char \\\[78\\\]" "second: ptype *array" +diff --git a/gdb/testsuite/gdb.arch/x86_64-vla-typedef-foo.S b/gdb/testsuite/gdb.arch/x86_64-vla-typedef-foo.S +new file mode 100644 +index 0000000..66f7a39 +--- /dev/null ++++ b/gdb/testsuite/gdb.arch/x86_64-vla-typedef-foo.S +@@ -0,0 +1,455 @@ ++ .file "x86_64-vla-typedef.c" ++ .section .debug_abbrev,"",@progbits ++.Ldebug_abbrev0: ++ .section .debug_info,"",@progbits ++.Ldebug_info0: ++ .section .debug_line,"",@progbits ++.Ldebug_line0: ++ .text ++.Ltext0: ++.globl foo ++ .type foo, @function ++foo: ++.LFB2: ++ .file 1 "x86_64-vla-typedef.c" ++ .loc 1 22 0 ++ pushq %rbp ++.LCFI0: ++ movq %rsp, %rbp ++.LCFI1: ++ subq $64, %rsp ++.LCFI2: ++ movl %edi, -36(%rbp) ++ .loc 1 22 0 ++ movq %rsp, %rax ++ movq %rax, -48(%rbp) ++ .loc 1 23 0 ++ movl -36(%rbp), %edx ++ movslq %edx,%rax ++ subq $1, %rax ++ movq %rax, -24(%rbp) ++ .loc 1 24 0 ++ movslq %edx,%rax ++ addq $15, %rax ++ addq $15, %rax ++ shrq $4, %rax ++ salq $4, %rax ++ subq %rax, %rsp ++ movq %rsp, -56(%rbp) ++ movq -56(%rbp), %rax ++ addq $15, %rax ++ shrq $4, %rax ++ salq $4, %rax ++ movq %rax, -56(%rbp) ++ movq -56(%rbp), %rax ++ movq %rax, -16(%rbp) ++ .loc 1 27 0 ++ movl $0, -4(%rbp) ++ jmp .L2 ++.L3: ++ .loc 1 28 0 ++ movl -4(%rbp), %esi ++ movl -4(%rbp), %eax ++ movl %eax, %ecx ++ movq -16(%rbp), %rdx ++ movslq %esi,%rax ++ movb %cl, (%rdx,%rax) ++ .loc 1 27 0 ++ addl $1, -4(%rbp) ++.L2: ++ movl -4(%rbp), %eax ++ cmpl -36(%rbp), %eax ++ jl .L3 ++ .loc 1 30 0 ++ .globl break_here ++break_here: ++ movq -16(%rbp), %rax ++ movb $0, (%rax) ++ movq -48(%rbp), %rsp ++ .loc 1 31 0 ++ leave ++ ret ++.LFE2: ++ .size foo, .-foo ++ .section .debug_frame,"",@progbits ++.Lframe0: ++ .long .LECIE0-.LSCIE0 ++.LSCIE0: ++ .long 0xffffffff ++ .byte 0x1 ++ .string "" ++ .uleb128 0x1 ++ .sleb128 -8 ++ .byte 0x10 ++ .byte 0xc ++ .uleb128 0x7 ++ .uleb128 0x8 ++ .byte 0x90 ++ .uleb128 0x1 ++ .align 8 ++.LECIE0: ++.LSFDE0: ++ .long .LEFDE0-.LASFDE0 ++.LASFDE0: ++ .long .Lframe0 ++ .quad .LFB2 ++ .quad .LFE2-.LFB2 ++ .byte 0x4 ++ .long .LCFI0-.LFB2 ++ .byte 0xe ++ .uleb128 0x10 ++ .byte 0x86 ++ .uleb128 0x2 ++ .byte 0x4 ++ .long .LCFI1-.LCFI0 ++ .byte 0xd ++ .uleb128 0x6 ++ .align 8 ++.LEFDE0: ++ .section .eh_frame,"a",@progbits ++.Lframe1: ++ .long .LECIE1-.LSCIE1 ++.LSCIE1: ++ .long 0x0 ++ .byte 0x1 ++ .string "zR" ++ .uleb128 0x1 ++ .sleb128 -8 ++ .byte 0x10 ++ .uleb128 0x1 ++ .byte 0x3 ++ .byte 0xc ++ .uleb128 0x7 ++ .uleb128 0x8 ++ .byte 0x90 ++ .uleb128 0x1 ++ .align 8 ++.LECIE1: ++.LSFDE1: ++ .long .LEFDE1-.LASFDE1 ++.LASFDE1: ++ .long .LASFDE1-.Lframe1 ++ .long .LFB2 ++ .long .LFE2-.LFB2 ++ .uleb128 0x0 ++ .byte 0x4 ++ .long .LCFI0-.LFB2 ++ .byte 0xe ++ .uleb128 0x10 ++ .byte 0x86 ++ .uleb128 0x2 ++ .byte 0x4 ++ .long .LCFI1-.LCFI0 ++ .byte 0xd ++ .uleb128 0x6 ++ .align 8 ++.LEFDE1: ++ .text ++.Letext0: ++ .section .debug_loc,"",@progbits ++.Ldebug_loc0: ++.LLST0: ++ .quad .LFB2-.Ltext0 ++ .quad .LCFI0-.Ltext0 ++ .value 0x2 ++ .byte 0x77 ++ .sleb128 8 ++ .quad .LCFI0-.Ltext0 ++ .quad .LCFI1-.Ltext0 ++ .value 0x2 ++ .byte 0x77 ++ .sleb128 16 ++ .quad .LCFI1-.Ltext0 ++ .quad .LFE2-.Ltext0 ++ .value 0x2 ++ .byte 0x76 ++ .sleb128 16 ++ .quad 0x0 ++ .quad 0x0 ++ .section .debug_info ++ .long .Ldebug_end - .Ldebug_start ++.Ldebug_start: ++ .value 0x2 ++ .long .Ldebug_abbrev0 ++ .byte 0x8 ++ .uleb128 0x1 ++ .long .LASF2 ++ .byte 0x1 ++ .long .LASF3 ++ .long .LASF4 ++ .quad .Ltext0 ++ .quad .Letext0 ++ .long .Ldebug_line0 ++ .uleb128 0x2 ++ .byte 0x1 ++ .string "foo" ++ .byte 0x1 ++ .byte 0x16 ++ .byte 0x1 ++ .quad .LFB2 ++ .quad .LFE2 ++ .long .LLST0 ++ .long 0x83 ++ .uleb128 0x3 ++ .long .LASF5 ++ .byte 0x1 ++ .byte 0x15 ++ .long 0x83 ++ .byte 0x2 ++ .byte 0x91 ++ .sleb128 -52 ++.Ltag_typedef: ++ .uleb128 0x4 ++ .long .LASF6 ++ .byte 0x1 ++ .byte 0x17 ++ .long .Ltag_array_type - .debug_info ++ .uleb128 0x5 /* Abbrev Number: 5 (DW_TAG_variable) */ ++ .long .LASF0 ++ .byte 0x1 ++ .byte 0x18 ++#if 1 ++ .long .Ltag_typedef - .debug_info ++#else ++ /* Debugging only: Skip the typedef indirection. */ ++ .long .Ltag_array_type - .debug_info ++#endif ++ /* DW_AT_location: DW_FORM_block1: start */ ++ .byte 0x3 ++ .byte 0x91 ++ .sleb128 -32 ++#if 0 ++ .byte 0x6 /* DW_OP_deref */ ++#else ++ .byte 0x96 /* DW_OP_nop */ ++#endif ++ /* DW_AT_location: DW_FORM_block1: end */ ++ .uleb128 0x6 ++ .string "i" ++ .byte 0x1 ++ .byte 0x19 ++ .long 0x83 ++ .byte 0x2 ++ .byte 0x91 ++ .sleb128 -20 ++ .byte 0x0 ++ .uleb128 0x7 ++ .byte 0x4 ++ .byte 0x5 ++ .string "int" ++.Ltag_array_type: ++ .uleb128 0x8 /* Abbrev Number: 8 (DW_TAG_array_type) */ ++ .long 0xa0 + (2f - 1f) /* DW_AT_type: DW_FORM_ref4 */ ++ .long 0x9d + (2f - 1f) /* DW_AT_sibling: DW_FORM_ref4 */ ++1: /* DW_AT_data_location: DW_FORM_block1: start */ ++ .byte 2f - 3f /* length */ ++3: ++ .byte 0x97 /* DW_OP_push_object_address */ ++ .byte 0x6 /* DW_OP_deref */ ++2: /* DW_AT_data_location: DW_FORM_block1: end */ ++ .uleb128 0x9 ++ .long 0x9d + (2b - 1b) /* DW_AT_type: DW_FORM_ref4 */ ++ .byte 0x3 ++ .byte 0x91 ++ .sleb128 -40 ++ .byte 0x6 ++ .byte 0x0 ++ .uleb128 0xa ++ .byte 0x8 ++ .byte 0x7 ++ .uleb128 0xb ++ .byte 0x1 ++ .byte 0x6 ++ .long .LASF1 ++ .byte 0x0 ++.Ldebug_end: ++ .section .debug_abbrev ++ .uleb128 0x1 ++ .uleb128 0x11 ++ .byte 0x1 ++ .uleb128 0x25 ++ .uleb128 0xe ++ .uleb128 0x13 ++ .uleb128 0xb ++ .uleb128 0x3 ++ .uleb128 0xe ++ .uleb128 0x1b ++ .uleb128 0xe ++ .uleb128 0x11 ++ .uleb128 0x1 ++ .uleb128 0x12 ++ .uleb128 0x1 ++ .uleb128 0x10 ++ .uleb128 0x6 ++ .byte 0x0 ++ .byte 0x0 ++ .uleb128 0x2 ++ .uleb128 0x2e ++ .byte 0x1 ++ .uleb128 0x3f ++ .uleb128 0xc ++ .uleb128 0x3 ++ .uleb128 0x8 ++ .uleb128 0x3a ++ .uleb128 0xb ++ .uleb128 0x3b ++ .uleb128 0xb ++ .uleb128 0x27 ++ .uleb128 0xc ++ .uleb128 0x11 ++ .uleb128 0x1 ++ .uleb128 0x12 ++ .uleb128 0x1 ++ .uleb128 0x40 ++ .uleb128 0x6 ++ .uleb128 0x1 ++ .uleb128 0x13 ++ .byte 0x0 ++ .byte 0x0 ++ .uleb128 0x3 ++ .uleb128 0x5 ++ .byte 0x0 ++ .uleb128 0x3 ++ .uleb128 0xe ++ .uleb128 0x3a ++ .uleb128 0xb ++ .uleb128 0x3b ++ .uleb128 0xb ++ .uleb128 0x49 ++ .uleb128 0x13 ++ .uleb128 0x2 ++ .uleb128 0xa ++ .byte 0x0 ++ .byte 0x0 ++ .uleb128 0x4 ++ .uleb128 0x16 ++ .byte 0x0 ++ .uleb128 0x3 ++ .uleb128 0xe ++ .uleb128 0x3a ++ .uleb128 0xb ++ .uleb128 0x3b ++ .uleb128 0xb ++ .uleb128 0x49 ++ .uleb128 0x13 ++ .byte 0x0 ++ .byte 0x0 ++ .uleb128 0x5 ++ .uleb128 0x34 ++ .byte 0x0 ++ .uleb128 0x3 ++ .uleb128 0xe ++ .uleb128 0x3a ++ .uleb128 0xb ++ .uleb128 0x3b ++ .uleb128 0xb ++ .uleb128 0x49 ++ .uleb128 0x13 ++ .uleb128 0x2 ++ .uleb128 0xa ++ .byte 0x0 ++ .byte 0x0 ++ .uleb128 0x6 ++ .uleb128 0x34 ++ .byte 0x0 ++ .uleb128 0x3 ++ .uleb128 0x8 ++ .uleb128 0x3a ++ .uleb128 0xb ++ .uleb128 0x3b ++ .uleb128 0xb ++ .uleb128 0x49 ++ .uleb128 0x13 ++ .uleb128 0x2 ++ .uleb128 0xa ++ .byte 0x0 ++ .byte 0x0 ++ .uleb128 0x7 ++ .uleb128 0x24 ++ .byte 0x0 ++ .uleb128 0xb ++ .uleb128 0xb ++ .uleb128 0x3e ++ .uleb128 0xb ++ .uleb128 0x3 ++ .uleb128 0x8 ++ .byte 0x0 ++ .byte 0x0 ++ .uleb128 0x8 /* Abbrev Number: 8 (DW_TAG_array_type) */ ++ .uleb128 0x1 ++ .byte 0x1 ++ .uleb128 0x49 /* DW_AT_type */ ++ .uleb128 0x13 /* DW_FORM_ref4 */ ++ .uleb128 0x1 /* DW_AT_sibling */ ++ .uleb128 0x13 /* DW_FORM_ref4 */ ++ .uleb128 0x50 /* DW_AT_data_location */ ++ .uleb128 0xa /* DW_FORM_block1 */ ++ .byte 0x0 ++ .byte 0x0 ++ .uleb128 0x9 ++ .uleb128 0x21 ++ .byte 0x0 ++ .uleb128 0x49 /* DW_AT_type */ ++ .uleb128 0x13 /* DW_FORM_ref4 */ ++ .uleb128 0x2f ++ .uleb128 0xa ++ .byte 0x0 ++ .byte 0x0 ++ .uleb128 0xa ++ .uleb128 0x24 ++ .byte 0x0 ++ .uleb128 0xb ++ .uleb128 0xb ++ .uleb128 0x3e ++ .uleb128 0xb ++ .byte 0x0 ++ .byte 0x0 ++ .uleb128 0xb ++ .uleb128 0x24 ++ .byte 0x0 ++ .uleb128 0xb ++ .uleb128 0xb ++ .uleb128 0x3e ++ .uleb128 0xb ++ .uleb128 0x3 ++ .uleb128 0xe ++ .byte 0x0 ++ .byte 0x0 ++ .byte 0x0 ++ .section .debug_pubnames,"",@progbits ++ .long 0x16 ++ .value 0x2 ++ .long .Ldebug_info0 ++ .long 0xa8 ++ .long 0x2d ++ .string "foo" ++ .long 0x0 ++ .section .debug_aranges,"",@progbits ++ .long 0x2c ++ .value 0x2 ++ .long .Ldebug_info0 ++ .byte 0x8 ++ .byte 0x0 ++ .value 0x0 ++ .value 0x0 ++ .quad .Ltext0 ++ .quad .Letext0-.Ltext0 ++ .quad 0x0 ++ .quad 0x0 ++ .section .debug_str,"MS",@progbits,1 ++.LASF0: ++ .string "array" ++.LASF5: ++ .string "size" ++.LASF3: ++ .string "x86_64-vla-typedef.c" ++.LASF6: ++ .string "array_t" ++.LASF1: ++ .string "char" ++.LASF4: ++ .string "gdb.arch" ++.LASF2: ++ .string "GNU C 4.3.2 20081105 (Red Hat 4.3.2-7)" ++ .ident "GCC: (GNU) 4.3.2 20081105 (Red Hat 4.3.2-7)" ++ .section .note.GNU-stack,"",@progbits +diff --git a/gdb/testsuite/gdb.arch/x86_64-vla-typedef.c b/gdb/testsuite/gdb.arch/x86_64-vla-typedef.c new file mode 100644 -index 0000000..aac3baa +index 0000000..b809c4e --- /dev/null -+++ b/gdb/testsuite/gdb.dwarf2/dw2-bound-loclist.S -@@ -0,0 +1,246 @@ ++++ b/gdb/testsuite/gdb.arch/x86_64-vla-typedef.c +@@ -0,0 +1,43 @@ +/* This testcase is part of GDB, the GNU debugger. + -+ Copyright 2010 Free Software Foundation, Inc. ++ Copyright 2008 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by @@ -12532,242 +6212,39 @@ index 0000000..aac3baa + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + -+/* Debug information */ -+ -+/* We will `break *main' at the very first instruction. */ -+#define main_length 1 -+ -+ .section .data -+vardata: -+ /* See DW_OP_lit3 + 1 (0-based). */ -+ .string "seennotseen" -+ -+ .section .debug_info -+.Lcu1_begin: -+ .4byte .Lcu1_end - .Lcu1_start /* Length of Compilation Unit */ -+.Lcu1_start: -+ .2byte 2 /* DWARF version number */ -+ .4byte .Ldebug_abbrev0 /* Offset Into Abbrev. Section */ -+ .byte 4 /* Pointer Size (in bytes) */ -+ -+ /* CU die */ -+ .uleb128 1 /* Abbrev: DW_TAG_compile_unit */ -+ .4byte .Lproducer /* DW_AT_producer */ -+ /* Use C++ to exploit a bug in parsing DW_AT_name "". */ -+ .byte 4 /* DW_AT_language (C++) - */ -+ .4byte main /* DW_AT_low_pc */ -+ .byte main_length /* DW_AT_high_pc */ -+ -+.Larray_type: -+ .uleb128 2 /* Abbrev: DW_TAG_array_type */ -+ .4byte .Lchar_type-.Lcu1_begin /* DW_AT_type */ -+ -+ .uleb128 3 /* Abbrev: DW_TAG_subrange_type */ -+ .4byte .Luint_type-.Lcu1_begin /* DW_AT_type */ -+ .byte 0 /* DW_AT_lower_bound */ -+ .4byte .Llen_var-.Lcu1_begin /* DW_AT_upper_bound */ -+ .byte 0 /* End of children of die */ -+ -+ /* DW_AT_upper_bound is referencing an optimized-out variable. */ -+.Larrayb_type: -+ .uleb128 2 /* Abbrev: DW_TAG_array_type */ -+ .4byte .Lchar_type-.Lcu1_begin /* DW_AT_type */ -+ -+ .uleb128 3 /* Abbrev: DW_TAG_subrange_type */ -+ .4byte .Luint_type-.Lcu1_begin /* DW_AT_type */ -+ .byte 0 /* DW_AT_lower_bound */ -+ .4byte .Llenb_var-.Lcu1_begin /* DW_AT_upper_bound */ -+ .byte 0 /* End of children of die */ -+ -+ /* 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 */ -+ .byte 4 /* DW_AT_byte_size */ -+ .byte 7 /* DW_AT_encoding */ -+ -+.Lchar_type: -+ .uleb128 4 /* Abbrev: DW_TAG_base_type */ -+ .4byte .Lchar_str /* DW_AT_name */ -+ .byte 1 /* DW_AT_byte_size */ -+ .byte 6 /* DW_AT_encoding */ -+ -+.Llen_var: -+ .uleb128 5 /* Abbrev: DW_TAG_variable artificial */ -+ .byte 1 /* DW_AT_artificial */ -+ .4byte .Luint_type-.Lcu1_begin /* DW_AT_type */ -+ .4byte .Llen_loclist-.Lloclist /* DW_AT_location */ -+ -+ /* optimized-out variable for b_string. */ -+.Llenb_var: -+ .uleb128 7 /* Abbrev: DW_TAG_variable artificial no DW_AT_location */ -+ .byte 1 /* DW_AT_artificial */ -+ .4byte .Luint_type-.Lcu1_begin /* DW_AT_type */ -+ -+ .uleb128 6 /* Abbrev: DW_TAG_variable DW_FORM_string */ -+ .string "a_string" /* DW_AT_name */ -+ .4byte .Larray_type-.Lcu1_begin /* DW_AT_type */ -+ .byte 2f - 1f /* DW_AT_location */ -+1: .byte 3 /* DW_OP_addr */ -+ .4byte vardata /* */ -+2: -+ -+ /* DW_AT_upper_bound is referencing an optimized-out variable. */ -+ .uleb128 6 /* Abbrev: DW_TAG_variable DW_FORM_string */ -+ .string "b_string" /* DW_AT_name */ -+ .4byte .Larrayb_type-.Lcu1_begin /* DW_AT_type */ -+ .byte 2f - 1f /* DW_AT_location */ -+1: .byte 3 /* DW_OP_addr */ -+ .4byte vardata /* */ -+2: -+ -+ /* 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 /* */ -+2: -+ -+ .byte 0 /* End of children of CU */ -+.Lcu1_end: -+ -+ .section .debug_loc -+.Lloclist: -+.Llen_loclist: -+ .4byte 0 # Location list begin address -+ .4byte main_length # Location list end address -+ .value 2f-1f # Location expression size -+1: .byte 0x33 # DW_OP_lit3 -+ .byte 0x9f # DW_OP_stack_value -+2: -+ .quad 0x0 # Location list terminator begin (*.LLST2) -+ .quad 0x0 # Location list terminator end (*.LLST2) -+ -+ .section .debug_abbrev -+.Ldebug_abbrev0: -+ .uleb128 1 /* Abbrev code */ -+ .uleb128 0x11 /* DW_TAG_compile_unit */ -+ .byte 0x1 /* has_children */ -+ .uleb128 0x25 /* DW_AT_producer */ -+ .uleb128 0xe /* DW_FORM_strp */ -+ .uleb128 0x13 /* DW_AT_language */ -+ .uleb128 0xb /* DW_FORM_data1 */ -+ .uleb128 0x11 /* DW_AT_low_pc */ -+ .uleb128 0x1 /* DW_FORM_addr */ -+ .uleb128 0x12 /* DW_AT_high_pc */ -+ .uleb128 0xb /* DW_FORM_data1 */ -+ .byte 0x0 /* Terminator */ -+ .byte 0x0 /* Terminator */ -+ -+ .uleb128 2 /* Abbrev code */ -+ .uleb128 0x1 /* TAG: DW_TAG_array_type */ -+ .byte 0x1 /* DW_children_yes */ -+ .uleb128 0x49 /* DW_AT_type */ -+ .uleb128 0x13 /* DW_FORM_ref4 */ -+ .byte 0x0 /* Terminator */ -+ .byte 0x0 /* Terminator */ -+ -+ .uleb128 3 /* Abbrev code */ -+ .uleb128 0x21 /* DW_TAG_subrange_type */ -+ .byte 0x0 /* no children */ -+ .uleb128 0x49 /* DW_AT_type */ -+ .uleb128 0x13 /* DW_FORM_ref4 */ -+ .uleb128 0x22 /* DW_AT_lower_bound */ -+ .uleb128 0xb /* DW_FORM_data1 */ -+ .uleb128 0x2f /* DW_AT_upper_bound */ -+ .uleb128 0x13 /* DW_FORM_ref4 */ -+ .byte 0x0 /* Terminator */ -+ .byte 0x0 /* Terminator */ -+ -+ .uleb128 4 /* Abbrev code */ -+ .uleb128 0x24 /* DW_TAG_base_type */ -+ .byte 0x0 /* no_children */ -+ .uleb128 0x3 /* DW_AT_name */ -+ .uleb128 0xe /* DW_FORM_strp */ -+ .uleb128 0xb /* DW_AT_byte_size */ -+ .uleb128 0xb /* DW_FORM_data1 */ -+ .uleb128 0x3e /* DW_AT_encoding */ -+ .uleb128 0xb /* DW_FORM_data1 */ -+ .byte 0x0 /* Terminator */ -+ .byte 0x0 /* Terminator */ ++#if 0 + -+ .uleb128 5 /* Abbrev code */ -+ .uleb128 0x34 /* DW_TAG_variable */ -+ .byte 0x0 /* no_children */ -+ .uleb128 0x34 /* DW_AT_artificial */ -+ .uleb128 0x0c /* DW_FORM_flag */ -+ .uleb128 0x49 /* DW_AT_type */ -+ .uleb128 0x13 /* DW_FORM_ref4 */ -+ .uleb128 0x02 /* DW_AT_location */ -+ .uleb128 0x06 /* DW_FORM_data4 */ -+ .byte 0x0 /* Terminator */ -+ .byte 0x0 /* Terminator */ ++void ++foo (int size) ++{ ++ typedef char array_t[size]; ++ array_t array; ++ int i; + -+ .uleb128 6 /* Abbrev code */ -+ .uleb128 0x34 /* DW_TAG_variable */ -+ .byte 0x0 /* no_children */ -+ .uleb128 0x3 /* DW_AT_name */ -+ .uleb128 0x8 /* DW_FORM_string */ -+ .uleb128 0x49 /* DW_AT_type */ -+ .uleb128 0x13 /* DW_FORM_ref4 */ -+ .uleb128 0x2 /* DW_AT_location */ -+ .uleb128 0xa /* DW_FORM_block1 */ -+ .byte 0x0 /* Terminator */ -+ .byte 0x0 /* Terminator */ ++ for (i = 0; i < size; i++) ++ array[i] = i; + -+ .uleb128 7 /* Abbrev code */ -+ .uleb128 0x34 /* DW_TAG_variable */ -+ .byte 0x0 /* no_children */ -+ .uleb128 0x34 /* DW_AT_artificial */ -+ .uleb128 0x0c /* DW_FORM_flag */ -+ .uleb128 0x49 /* DW_AT_type */ -+ .uleb128 0x13 /* DW_FORM_ref4 */ -+ .byte 0x0 /* Terminator */ -+ .byte 0x0 /* Terminator */ ++ array[0] = 0; /* break-here */ ++} + -+ .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 */ ++#else + -+ .byte 0x0 /* Terminator */ ++int ++main (void) ++{ ++ foo (26); ++ foo (78); ++ return 0; ++} + -+/* String table */ -+ .section .debug_str -+.Lproducer: -+ .string "GNU C 3.3.3" -+.Lchar_str: -+ .string "char" -+.Luint_str: -+ .string "unsigned int" -diff --git a/gdb/testsuite/gdb.dwarf2/dw2-bound-loclist.exp b/gdb/testsuite/gdb.dwarf2/dw2-bound-loclist.exp ++#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..815ed93 +index 0000000..b05411e --- /dev/null -+++ b/gdb/testsuite/gdb.dwarf2/dw2-bound-loclist.exp -@@ -0,0 +1,54 @@ -+# Copyright 2010 Free Software Foundation, Inc. ++++ b/gdb/testsuite/gdb.arch/x86_64-vla-typedef.exp +@@ -0,0 +1,64 @@ ++# Copyright 2009 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by @@ -12782,187 +6259,239 @@ index 0000000..815ed93 +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + -+# Test printing variable with dynamic bounds which reference a different -+# (artificial in the GCC case) variable containing loclist as its location. -+# This testcase uses value (not address) of the referenced variable: -+# http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43762 ++# Test DW_AT_data_location accessed through DW_TAG_typedef intermediate. + -+# This test can only be run on targets which support DWARF-2 and use gas. -+# For now pick a sampling of likely targets. -+if {![istarget *-*-linux*] -+ && ![istarget *-*-gnu*] -+ && ![istarget *-*-elf*] -+ && ![istarget *-*-openbsd*] -+ && ![istarget arm-*-eabi*] -+ && ![istarget powerpc-*-eabi*]} { -+ return 0 ++if ![istarget "x86_64-*-*"] then { ++ verbose "Skipping over gdb.arch/x86_64-vla-typedef.exp test made only for x86_64." ++ return +} + -+set testfile dw2-bound-loclist -+if { [prepare_for_testing ${testfile}.exp ${testfile} [list ${testfile}.S main.c] {}] } { ++set testfile x86_64-vla-typedef ++set srcasmfile ${testfile}-foo.S ++set srcfile ${testfile}.c ++set binfile ${objdir}/${subdir}/${testfile} ++set binobjfile ${objdir}/${subdir}/${testfile}-foo.o ++if { [gdb_compile "${srcdir}/${subdir}/${srcasmfile}" "${binobjfile}" object {}] != "" } { ++ untested "Couldn't compile test program" ++ return -1 ++} ++if { [gdb_compile "${srcdir}/${subdir}/${srcfile} ${binobjfile}" "${binfile}" executable {debug}] != "" } { ++ untested "Couldn't compile test program" + return -1 +} + -+# Verify it behaves at least as an unbound array without inferior. -+ -+gdb_test "p a_string" { = 0x[0-9a-f]+ "seennotseen"} -+gdb_test "ptype a_string" {type = char \[\]} ++gdb_exit ++gdb_start ++gdb_reinitialize_dir $srcdir/$subdir ++gdb_load ${binfile} + -+# Not runto_main as dw2-bound-loclist.S handles only the first byte of main. -+if ![runto "*main"] { ++if ![runto_main] { ++ untested x86_64-vla-typedef + return -1 +} + -+gdb_test "p a_string" { = "seen"} -+gdb_test "ptype a_string" {type = char \[4\]} ++gdb_breakpoint "break_here" + -+gdb_test "p b_string" { = (0x[0-9a-f]+ )?"seennotseen"} -+gdb_test "ptype b_string" {type = char \[\]} ++gdb_continue_to_breakpoint "break_here" + -+# The register contains unpredictable value - the array size. -+gdb_test "ptype reg_string" {type = char \[-?[0-9]+\]} -diff --git a/gdb/testsuite/gdb.dwarf2/dw2-stripped.c b/gdb/testsuite/gdb.dwarf2/dw2-stripped.c ++gdb_test "whatis array" "type = array_t" "first: whatis array" ++ ++gdb_test "ptype array" "type = char \\\[26\\\]" "first: ptype array" ++ ++gdb_test "p array\[1\]" "\\$\[0-9\] = 1 '\\\\001'" ++gdb_test "p array\[2\]" "\\$\[0-9\] = 2 '\\\\002'" ++gdb_test "p array\[3\]" "\\$\[0-9\] = 3 '\\\\003'" ++gdb_test "p array\[4\]" "\\$\[0-9\] = 4 '\\\\004'" ++ ++gdb_continue_to_breakpoint "break_here" ++ ++gdb_test "whatis array" "type = array_t" "second: whatis array" ++ ++gdb_test "ptype array" "type = char \\\[78\\\]" "second: ptype array" +diff --git a/gdb/testsuite/gdb.base/arrayidx.c b/gdb/testsuite/gdb.base/arrayidx.c +index a99137e..c3dc2d9 100644 +--- a/gdb/testsuite/gdb.base/arrayidx.c ++++ b/gdb/testsuite/gdb.base/arrayidx.c +@@ -17,6 +17,13 @@ + + int array[] = {1, 2, 3, 4}; + ++#ifdef __GNUC__ ++struct ++ { ++ int a[0]; ++ } unbound; ++#endif ++ + int + main (void) + { +diff --git a/gdb/testsuite/gdb.base/arrayidx.exp b/gdb/testsuite/gdb.base/arrayidx.exp +index cba0024..0dc0e46 100644 +--- a/gdb/testsuite/gdb.base/arrayidx.exp ++++ b/gdb/testsuite/gdb.base/arrayidx.exp +@@ -53,4 +53,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/internal-var-field-address.c b/gdb/testsuite/gdb.base/internal-var-field-address.c new file mode 100644 -index 0000000..1f02d90 +index 0000000..eeb7b85 --- /dev/null -+++ b/gdb/testsuite/gdb.dwarf2/dw2-stripped.c -@@ -0,0 +1,42 @@ ++++ b/gdb/testsuite/gdb.base/internal-var-field-address.c +@@ -0,0 +1,20 @@ +/* This testcase is part of GDB, the GNU debugger. + -+ Copyright 2004 Free Software Foundation, Inc. ++ Copyright 2009 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by -+ the Free Software Foundation; either version 2 of the License, or ++ the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. -+ ++ + You should have received a copy of the GNU General Public License -+ along with this program; if not, write to the Free Software -+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, -+ USA. */ ++ along with this program. If not, see . */ + ++struct { ++ int field; ++} staticstruct = { 1 }; +diff --git a/gdb/testsuite/gdb.base/internal-var-field-address.exp b/gdb/testsuite/gdb.base/internal-var-field-address.exp +new file mode 100644 +index 0000000..6d82e73 +--- /dev/null ++++ b/gdb/testsuite/gdb.base/internal-var-field-address.exp +@@ -0,0 +1,26 @@ ++# Copyright 2009 Free Software Foundation, Inc. + -+/* The function `func1' traced into must have debug info on offset > 0; -+ (DW_UNSND (attr)). This is the reason of `func0' existence. */ ++# This program is free software; you can redistribute it and/or modify ++# it under the terms of the GNU General Public License as published by ++# the Free Software Foundation; either version 3 of the License, or ++# (at your option) any later version. ++# ++# This program is distributed in the hope that it will be useful, ++# but WITHOUT ANY WARRANTY; without even the implied warranty of ++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++# GNU General Public License for more details. ++# ++# You should have received a copy of the GNU General Public License ++# along with this program. If not, see . + -+void -+func0(int a, int b) -+{ ++set test internal-var-field-address ++set binfile ${test}.x ++if { [gdb_compile "${srcdir}/${subdir}/${test}.c" "${objdir}/${subdir}/${binfile}" object {debug}] != "" } { ++ untested "Couldn't compile test program" ++ return -1 +} + -+/* `func1' being traced into must have some arguments to dump. */ ++clean_restart $binfile + -+void -+func1(int a, int b) -+{ -+ func0 (a,b); -+} ++gdb_test {set $varstruct = staticstruct} ++gdb_test {p $varstruct.field} " = 1" +diff --git a/gdb/testsuite/gdb.base/vla-frame.c b/gdb/testsuite/gdb.base/vla-frame.c +new file mode 100644 +index 0000000..5750f68 +--- /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 . */ ++ ++#include + +int -+main(void) ++main (int argc, char **argv) +{ -+ func1 (1, 2); ++ char s[2 + argc]; ++ void (*f) (char *) = 0; ++ ++ memset (s, 0, sizeof (s)); ++ s[0] = 'X'; ++ ++ f (s); + return 0; +} -diff --git a/gdb/testsuite/gdb.dwarf2/dw2-stripped.exp b/gdb/testsuite/gdb.dwarf2/dw2-stripped.exp +diff --git a/gdb/testsuite/gdb.base/vla-frame.exp b/gdb/testsuite/gdb.base/vla-frame.exp new file mode 100644 -index 0000000..1c6e84a +index 0000000..47736c7 --- /dev/null -+++ b/gdb/testsuite/gdb.dwarf2/dw2-stripped.exp -@@ -0,0 +1,79 @@ -+# Copyright 2006 Free Software Foundation, Inc. -+ ++++ 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 2 of the License, or ++# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. -+# ++# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. -+# ++# +# You should have received a copy of the GNU General Public License -+# along with this program; if not, write to the Free Software -+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -+ -+# Minimal DWARF-2 unit test -+ -+# This test can only be run on targets which support DWARF-2. -+# For now pick a sampling of likely targets. -+if {![istarget *-*-linux*] -+ && ![istarget *-*-gnu*] -+ && ![istarget *-*-elf*] -+ && ![istarget *-*-openbsd*] -+ && ![istarget arm-*-eabi*] -+ && ![istarget powerpc-*-eabi*]} { -+ return 0 -+} -+ -+set testfile "dw2-stripped" -+set srcfile ${testfile}.c -+set binfile ${objdir}/${subdir}/${testfile}.x -+ -+remote_exec build "rm -f ${binfile}" -+ -+# get the value of gcc_compiled -+if [get_compiler_info ${binfile}] { -+ return -1 -+} ++# along with this program. If not, see . + -+# This test can only be run on gcc as we use additional_flags=FIXME -+if {$gcc_compiled == 0} { -+ return 0 -+} ++set testfile vla-frame ++set executable ${testfile} + -+if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-ggdb3}] != "" } { ++if { [prepare_for_testing ${testfile}.exp ${executable}] } { + return -1 +} + -+remote_exec build "objcopy -R .debug_loc ${binfile}" -+set strip_output [remote_exec build "objdump -h ${binfile}"] -+ -+set test "stripping test file preservation" -+if [ regexp ".debug_info " $strip_output] { -+ pass "$test (.debug_info preserved)" -+} else { -+ fail "$test (.debug_info got also stripped)" ++if ![runto_main] { ++ return -1 +} + -+set test "stripping test file functionality" -+if [ regexp ".debug_loc " $strip_output] { -+ fail "$test (.debug_loc still present)" -+} else { -+ pass "$test (.debug_loc stripped)" ++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_exit -+gdb_start -+gdb_reinitialize_dir $srcdir/$subdir -+gdb_load ${binfile} -+ -+# For C programs, "start" should stop in main(). -+ -+gdb_test "start" \ -+ ".*main \\(\\) at .*" \ -+ "start" -+gdb_test "step" \ -+ "func.* \\(.*\\) at .*" \ -+ "step" -diff --git a/gdb/testsuite/gdb.dwarf2/dw2-struct-member-data-location.S b/gdb/testsuite/gdb.dwarf2/dw2-struct-member-data-location.S ++gdb_test "bt full" "\r\n +s = \"X\\\\000\"\r\n.*" +diff --git a/gdb/testsuite/gdb.base/vla-overflow.c b/gdb/testsuite/gdb.base/vla-overflow.c new file mode 100644 -index 0000000..5fcdd84 +index 0000000..c5d5ee0 --- /dev/null -+++ b/gdb/testsuite/gdb.dwarf2/dw2-struct-member-data-location.S -@@ -0,0 +1,83 @@ ++++ b/gdb/testsuite/gdb.base/vla-overflow.c +@@ -0,0 +1,30 @@ +/* This testcase is part of GDB, the GNU debugger. + -+ Copyright 2009 Free Software Foundation, Inc. ++ Copyright 2008 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by @@ -12977,79 +6506,26 @@ index 0000000..5fcdd84 + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + -+/* Debug information */ -+ -+ .section .debug_info -+.Lcu1_begin: -+ /* CU header */ -+ .4byte .Lcu1_end - .Lcu1_start /* Length of Compilation Unit */ -+.Lcu1_start: -+ .2byte 2 /* DWARF Version */ -+ .4byte .Labbrev1_begin /* Offset into abbrev section */ -+ .byte 4 /* Pointer size */ -+ -+ /* CU die */ -+ .uleb128 1 /* Abbrev: DW_TAG_compile_unit */ -+ .ascii "dw2-struct-member-data-location.c\0" /* DW_AT_name */ -+ .ascii "GNU C 4.3.2\0" /* DW_AT_producer */ -+ .byte 1 /* DW_AT_language (C) */ -+ -+.Ltype_uchar: -+ .uleb128 2 /* Abbrev: DW_TAG_structure_type */ -+ .ascii "some_struct\0" /* DW_AT_name */ -+ -+ .uleb128 3 /* Abbrev: DW_TAG_member */ -+ .ascii "field\0" /* DW_AT_name */ -+ .byte 0 /* DW_AT_data_member_location */ -+ -+ .byte 0 /* End of children of some_struct */ -+ -+ .byte 0 /* End of children of CU */ -+ -+.Lcu1_end: ++#include + -+/* 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 */ ++int ++main (int argc, char **argv) ++{ ++ int array[argc]; + -+ .uleb128 2 /* Abbrev code */ -+ .uleb128 0x13 /* DW_TAG_structure_type */ -+ .byte 1 /* has_children */ -+ .uleb128 0x3 /* DW_AT_name */ -+ .uleb128 0x8 /* DW_FORM_string */ -+ .byte 0x0 /* Terminator */ -+ .byte 0x0 /* Terminator */ ++ array[0] = array[0]; + -+ .uleb128 3 /* Abbrev code */ -+ .uleb128 0x0d /* DW_TAG_member */ -+ .byte 0 /* has_children */ -+ .uleb128 0x3 /* DW_AT_name */ -+ .uleb128 0x8 /* DW_FORM_string */ -+ .uleb128 0x38 /* DW_AT_data_member_location */ -+ .uleb128 0x0b /* DW_FORM_data1 */ -+ .byte 0x0 /* Terminator */ -+ .byte 0x0 /* Terminator */ ++ abort (); + -+ .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 ++ 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..c41151c +index 0000000..24a608f --- /dev/null -+++ b/gdb/testsuite/gdb.dwarf2/dw2-struct-member-data-location.exp -@@ -0,0 +1,37 @@ -+# Copyright 2009 Free Software Foundation, Inc. ++++ b/gdb/testsuite/gdb.base/vla-overflow.exp +@@ -0,0 +1,109 @@ ++# Copyright 2008 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by @@ -13064,614 +6540,488 @@ index 0000000..c41151c +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + -+# This test can only be run on targets which support DWARF-2 and use gas. -+# For now pick a sampling of likely targets. -+if {![istarget *-*-linux*] -+ && ![istarget *-*-gnu*] -+ && ![istarget *-*-elf*] -+ && ![istarget *-*-openbsd*] -+ && ![istarget arm-*-eabi*] -+ && ![istarget powerpc-*-eabi*]} { -+ return 0 ++# We could crash in: ++# #0 block_linkage_function (bl=0x0) at ../../gdb/block.c:69 ++# #1 in dwarf_block_get_frame_base (...) at ../../gdb/dwarf2block.c:97 ++# 97 framefunc = block_linkage_function (get_frame_block (frame, NULL)); ++# #2 in execute_stack_op (...) at ../../gdb/dwarf2expr.c:496 ++# #3 in dwarf_block_exec_core () at ../../gdb/dwarf2block.c:156 ++# #4 dwarf_block_exec (...) at ../../gdb/dwarf2block.c:206 ++# #5 in range_type_count_bound_internal (...) at ../../gdb/gdbtypes.c:1430 ++# #6 in create_array_type (...) at ../../gdb/gdbtypes.c:840 ++# ... ++# #21 in psymtab_to_symtab (...) at ../../gdb/symfile.c:292 ++# ... ++# #29 in backtrace_command_1 () at ../../gdb/stack.c:1273 ++ ++set testfile vla-overflow ++set shfile ${objdir}/${subdir}/${testfile}-gdb.sh ++set srcfile ${testfile}.c ++set binfile ${objdir}/${subdir}/${testfile} ++if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } { ++ untested "Couldn't compile test program" ++ return -1 +} + -+set testfile "dw2-struct-member-data-location" -+set srcfile ${testfile}.S -+set binfile ${testfile}.x ++set f [open "|getconf PAGESIZE" "r"] ++gets $f pagesize ++close $f + -+if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${objdir}/${subdir}/${binfile}" object {nodebug}] != "" } { ++gdb_exit ++gdb_start ++gdb_reinitialize_dir $srcdir/$subdir ++gdb_load ${binfile} ++ ++set pid_of_gdb [exp_pid -i [board_info host fileid]] ++ ++if { [runto_main] < 0 } { ++ untested vla-overflow + return -1 +} + -+clean_restart $binfile ++# Get the GDB memory size when we stay at main. + -+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..d7b8bea ---- /dev/null -+++ b/gdb/testsuite/gdb.fortran/dwarf-stride.exp -@@ -0,0 +1,42 @@ -+# Copyright 2009 Free Software Foundation, Inc. ++proc memory_v_pages_get {} { ++ global pid_of_gdb pagesize ++ set fd [open "/proc/$pid_of_gdb/statm"] ++ gets $fd line ++ close $fd ++ # number of pages of virtual memory ++ scan $line "%d" drs ++ return $drs ++} + -+# This program is free software; you can 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 pages_found [memory_v_pages_get] + -+# This file was written by Jan Kratochvil . ++# s390x with glibc-debuginfo.s390x installed used approx. 16MB. ++set mb_reserve 40 ++verbose -log "pages_found = $pages_found, mb_reserve = $mb_reserve" ++set kb_found [expr $pages_found * $pagesize / 1024] ++set kb_permit [expr $kb_found + 1 * 1024 + $mb_reserve * 1024] ++verbose -log "kb_found = $kb_found, kb_permit = $kb_permit" + -+# This file is part of the gdb testsuite. Array element stride must not be -+# specified in the number of elements but in a number of bytes instead. -+# Original problem: -+# (gdb) p c40pt(1) -+# $1 = '0-hello', ' ' -+# (gdb) p c40pt(2) -+# warning: Fortran array stride not divisible by the element size ++# Create the ulimit wrapper. ++set f [open $shfile "w"] ++puts $f "#! /bin/sh" ++puts $f "ulimit -v $kb_permit" ++puts $f "exec $GDB \"\$@\"" ++close $f ++remote_exec host "chmod +x $shfile" ++ ++gdb_exit ++set GDBold $GDB ++set GDB "$shfile" ++gdb_start ++set GDB $GDBold ++ ++gdb_reinitialize_dir $srcdir/$subdir ++gdb_load ${binfile} ++ ++set pid_of_gdb [exp_pid -i [board_info host fileid]] ++ ++# Check the size again after the second run. ++# We must not stop in main as it would cache `array' and never crash later. ++ ++gdb_run_cmd ++ ++verbose -log "kb_found before abort() = [expr [memory_v_pages_get] * $pagesize / 1024]" + -+set testfile dwarf-stride -+set srcfile ${testfile}.f90 ++gdb_test "" "Program received signal SIGABRT, Aborted..*" "Enter abort()" + -+if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} {debug f90}] } { -+ return -1 -+} ++verbose -log "kb_found in abort() = [expr [memory_v_pages_get] * $pagesize / 1024]" + -+if ![runto MAIN__] then { -+ perror "couldn't run to breakpoint MAIN__" -+ continue -+} ++# `abort' can get expressed as `*__GI_abort'. ++gdb_test "bt" "in \[^ \]*abort \\(.* in main \\(.*" "Backtrace after abort()" + -+gdb_breakpoint [gdb_get_line_number "break-here"] -+gdb_continue_to_breakpoint "break-here" ".*break-here.*" -+gdb_test "p c40pt(1)" " = '0-hello.*" -+gdb_test "p c40pt(2)" " = '1-hello.*" -diff --git a/gdb/testsuite/gdb.fortran/dwarf-stride.f90 b/gdb/testsuite/gdb.fortran/dwarf-stride.f90 ++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..e492b3a +index 0000000..e1f3ed1 --- /dev/null -+++ b/gdb/testsuite/gdb.fortran/dwarf-stride.f90 -@@ -0,0 +1,40 @@ -+! Copyright 2009 Free Software Foundation, Inc. -+! -+! This program is free software; you can redistribute it and/or modify -+! it under the terms of the GNU General Public License as published by -+! the Free Software Foundation; either version 2 of the License, or -+! (at your option) any later version. -+! -+! This program is distributed in the hope that it will be useful, -+! but WITHOUT ANY WARRANTY; without even the implied warranty of -+! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+! GNU General Public License for more details. -+! -+! You should have received a copy of the GNU General Public License -+! along with this program; if not, write to the Free Software -+! Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -+! -+! File written by Alan Matsuoka. ++++ b/gdb/testsuite/gdb.base/vla.c +@@ -0,0 +1,55 @@ ++/* This testcase is part of GDB, the GNU debugger. + -+program repro ++ Copyright 2008 Free Software Foundation, Inc. + -+ type small_stride -+ character*40 long_string -+ integer small_pad -+ end type small_stride ++ This program is free software; you can redistribute it and/or modify ++ it under the terms of the GNU General Public License as published by ++ the Free Software Foundation; either version 3 of the License, or ++ (at your option) any later version. + -+ type(small_stride), dimension (20), target :: unpleasant -+ character*40, pointer, dimension(:):: c40pt ++ This program is distributed in the hope that it will be useful, ++ but WITHOUT ANY WARRANTY; without even the implied warranty of ++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++ GNU General Public License for more details. + -+ integer i ++ You should have received a copy of the GNU General Public License ++ along with this program. If not, see . */ + -+ do i = 0,19 -+ unpleasant(i+1)%small_pad = i+1 -+ unpleasant(i+1)%long_string = char (ichar('0') + i) // '-hello' -+ end do ++#include + -+ c40pt => unpleasant%long_string ++void ++marker (void) ++{ ++} + -+ print *, c40pt ! break-here ++void ++bar (char *a, char *b, char *c, int size) ++{ ++ memset (a, '1', size); ++ memset (b, '2', size); ++ memset (c, '3', 48); ++} + -+end program repro -diff --git a/gdb/testsuite/gdb.fortran/dynamic-other-frame-stub.f90 b/gdb/testsuite/gdb.fortran/dynamic-other-frame-stub.f90 -new file mode 100644 -index 0000000..261ce17 ---- /dev/null -+++ b/gdb/testsuite/gdb.fortran/dynamic-other-frame-stub.f90 -@@ -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 . -+! Modified for the GDB testcase by Jan Kratochvil . ++void ++foo (int size) ++{ ++ char temp1[size]; ++ char temp3[48]; + -+subroutine bar -+ real :: dummy -+ dummy = 1 -+end subroutine bar -diff --git a/gdb/testsuite/gdb.fortran/dynamic-other-frame.exp b/gdb/testsuite/gdb.fortran/dynamic-other-frame.exp ++ 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..fa41b80 +index 0000000..5da7378 --- /dev/null -+++ b/gdb/testsuite/gdb.fortran/dynamic-other-frame.exp -@@ -0,0 +1,37 @@ -+# Copyright 2010 Free Software Foundation, Inc. ++++ b/gdb/testsuite/gdb.base/vla.exp +@@ -0,0 +1,62 @@ ++# Copyright 2008 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by -+# the Free Software Foundation; either version 2 of the License, or ++# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. -+# ++# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. -+# ++# +# You should have received a copy of the GNU General Public License -+# along with this program; if not, write to the Free Software -+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -+ -+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} ++# along with this program. If not, see . + -+if { [gdb_compile "${srcdir}/${subdir}/${srcfile2}" "${objfile2}" object {f90}] != "" -+ || [gdb_compile "${srcdir}/${subdir}/${srcfile1} ${objfile2}" "${binfile}" executable {debug f90}] != "" } { -+ untested "Couldn't compile ${srcfile1} or ${srcfile2}" ++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 +} + -+clean_restart ${executable} ++gdb_exit ++gdb_start ++gdb_reinitialize_dir $srcdir/$subdir ++gdb_load ${binfile} + -+if ![runto bar_] then { -+ perror "couldn't run to bar_" -+ continue ++if ![runto_main] { ++ untested vla ++ return -1 +} + -+gdb_test "bt" {foo \(string='hello'.*} -diff --git a/gdb/testsuite/gdb.fortran/dynamic-other-frame.f90 b/gdb/testsuite/gdb.fortran/dynamic-other-frame.f90 -new file mode 100644 -index 0000000..2bc637d ---- /dev/null -+++ b/gdb/testsuite/gdb.fortran/dynamic-other-frame.f90 -@@ -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 . -+! Modified for the GDB testcase by Jan Kratochvil . ++gdb_breakpoint [gdb_get_line_number "break-here"] + -+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 -diff --git a/gdb/testsuite/gdb.fortran/dynamic.exp b/gdb/testsuite/gdb.fortran/dynamic.exp ++gdb_continue_to_breakpoint "break-here" ++ ++gdb_test "whatis temp1" "type = char \\\[variable\\\]" "first: whatis temp1" ++gdb_test "whatis temp2" "type = char \\\[variable\\\]" "first: whatis temp2" ++gdb_test "whatis temp3" "type = char \\\[48\\\]" "first: whatis temp3" ++ ++gdb_test "ptype temp1" "type = char \\\[26\\\]" "first: ptype temp1" ++gdb_test "ptype temp2" "type = char \\\[26\\\]" "first: ptype temp2" ++gdb_test "ptype temp3" "type = char \\\[48\\\]" "first: ptype temp3" ++ ++gdb_test "p temp1" " = '1' " "first: print temp1" ++gdb_test "p temp2" " = '2' " "first: print temp2" ++gdb_test "p temp3" " = '3' " "first: print temp3" ++ ++gdb_continue_to_breakpoint "break-here" ++ ++gdb_test "whatis temp1" "type = char \\\[variable\\\]" "second: whatis temp1" ++gdb_test "whatis temp2" "type = char \\\[variable\\\]" "second: whatis temp2" ++gdb_test "whatis temp3" "type = char \\\[48\\\]" "second: whatis temp3" ++ ++gdb_test "ptype temp1" "type = char \\\[78\\\]" "second: ptype temp1" ++gdb_test "ptype temp2" "type = char \\\[78\\\]" "second: ptype temp2" ++gdb_test "ptype temp3" "type = char \\\[48\\\]" "second: ptype temp3" ++ ++gdb_test "p temp1" " = '1' " "second: print temp1" ++gdb_test "p temp2" " = '2' " "second: print temp2" ++gdb_test "p temp3" " = '3' " "second: print temp3" +diff --git a/gdb/testsuite/gdb.dwarf2/dw2-bound-loclist.S b/gdb/testsuite/gdb.dwarf2/dw2-bound-loclist.S new file mode 100644 -index 0000000..e79e94a ---- /dev/null -+++ b/gdb/testsuite/gdb.fortran/dynamic.exp -@@ -0,0 +1,152 @@ -+# Copyright 2007 Free Software Foundation, Inc. +index 0000000..aac3baa +--- /dev/null ++++ b/gdb/testsuite/gdb.dwarf2/dw2-bound-loclist.S +@@ -0,0 +1,246 @@ ++/* This testcase is part of GDB, the GNU debugger. + -+# This program is free software; you can 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. ++ Copyright 2010 Free Software Foundation, Inc. + -+# This file was written by Jan Kratochvil . ++ This program is free software; you can redistribute it and/or modify ++ it under the terms of the GNU General Public License as published by ++ the Free Software Foundation; either version 3 of the License, or ++ (at your option) any later version. + -+# This file is part of the gdb testsuite. It contains tests for dynamically -+# allocated Fortran arrays. -+# It depends on the GCC dynamic Fortran arrays DWARF support: -+# http://gcc.gnu.org/bugzilla/show_bug.cgi?id=22244 ++ This program is distributed in the hope that it will be useful, ++ but WITHOUT ANY WARRANTY; without even the implied warranty of ++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++ GNU General Public License for more details. + -+set testfile "dynamic" -+set srcfile ${testfile}.f90 -+set binfile ${objdir}/${subdir}/${testfile} ++ You should have received a copy of the GNU General Public License ++ along with this program. If not, see . */ + -+if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug f90 quiet}] != "" } { -+ untested "Couldn't compile ${srcfile}" -+ return -1 -+} ++/* Debug information */ + -+gdb_exit -+gdb_start -+gdb_reinitialize_dir $srcdir/$subdir -+gdb_load ${binfile} ++/* We will `break *main' at the very first instruction. */ ++#define main_length 1 + -+if ![runto MAIN__] then { -+ perror "couldn't run to breakpoint MAIN__" -+ continue -+} ++ .section .data ++vardata: ++ /* See DW_OP_lit3 + 1 (0-based). */ ++ .string "seennotseen" + -+gdb_breakpoint [gdb_get_line_number "varx-init"] -+gdb_continue_to_breakpoint "varx-init" -+gdb_test "p varx" "\\$\[0-9\]* = <(object|the array) is not allocated>" "p varx unallocated" -+gdb_test "ptype varx" "type = <(object|the array) is not allocated>" "ptype varx unallocated" -+gdb_test "p varx(1,5,17)" "(Cannot access it|Unable to access the object) because the (object|array) is not allocated\\." "p varx(1,5,17) unallocated" -+gdb_test "p varx(1,5,17)=1" "(Cannot access it|Unable to access the object) because the (object|array) is not allocated\\." "p varx(1,5,17)=1 unallocated" -+gdb_test "ptype varx(1,5,17)" "(Cannot access it|Unable to access the object) because the (object|array) is not allocated\\." "ptype varx(1,5,17) unallocated" ++ .section .debug_info ++.Lcu1_begin: ++ .4byte .Lcu1_end - .Lcu1_start /* Length of Compilation Unit */ ++.Lcu1_start: ++ .2byte 2 /* DWARF version number */ ++ .4byte .Ldebug_abbrev0 /* Offset Into Abbrev. Section */ ++ .byte 4 /* Pointer Size (in bytes) */ + -+gdb_breakpoint [gdb_get_line_number "varx-allocated"] -+gdb_continue_to_breakpoint "varx-allocated" -+# $1 = (( ( 0, 0, 0, 0, 0, 0) ( 0, 0, 0, 0, 0, 0) --- , 0) ) ( ( 0, 0, ...) ...) ...) -+gdb_test "ptype varx" "type = real(\\(kind=4\\)|\\*4) \\(6,5:15,17:28\\)" "ptype varx allocated" -+# Intel Fortran Compiler 10.1.008 uses -1 there, GCC uses 1. -+gdb_test "p l" "\\$\[0-9\]* = (\\.TRUE\\.|4294967295)" "p l if varx allocated" ++ /* CU die */ ++ .uleb128 1 /* Abbrev: DW_TAG_compile_unit */ ++ .4byte .Lproducer /* DW_AT_producer */ ++ /* Use C++ to exploit a bug in parsing DW_AT_name "". */ ++ .byte 4 /* DW_AT_language (C++) - */ ++ .4byte main /* DW_AT_low_pc */ ++ .byte main_length /* DW_AT_high_pc */ + -+gdb_breakpoint [gdb_get_line_number "varx-filled"] -+gdb_continue_to_breakpoint "varx-filled" -+gdb_test "p varx(2, 5, 17)" "\\$\[0-9\]* = 6" -+gdb_test "p varx(1, 5, 17)" "\\$\[0-9\]* = 7" -+gdb_test "p varx(2, 6, 18)" "\\$\[0-9\]* = 8" -+gdb_test "p varx(6, 15, 28)" "\\$\[0-9\]* = 9" -+# The latter one is for the Intel Fortran Compiler 10.1.008 pointer type. -+gdb_test "p varv" "\\$\[0-9\]* = (<(object|the array) is not associated>|.*(Cannot access it|Unable to access the object) because the object is not associated.)" "p varv unassociated" -+gdb_test "ptype varv" "type = (<(object|the array) is not associated>|.*(Cannot access it|Unable to access the object) because the object is not associated.)" "ptype varv unassociated" ++.Larray_type: ++ .uleb128 2 /* Abbrev: DW_TAG_array_type */ ++ .4byte .Lchar_type-.Lcu1_begin /* DW_AT_type */ + -+set test "output varx" -+gdb_test_multiple $test $test { -+ -re "^output varx\r\n\[() ,6789.\]*$gdb_prompt $" { -+ pass $test -+ } -+} ++ .uleb128 3 /* Abbrev: DW_TAG_subrange_type */ ++ .4byte .Luint_type-.Lcu1_begin /* DW_AT_type */ ++ .byte 0 /* DW_AT_lower_bound */ ++ .4byte .Llen_var-.Lcu1_begin /* DW_AT_upper_bound */ ++ .byte 0 /* End of children of die */ + -+gdb_breakpoint [gdb_get_line_number "varv-associated"] -+gdb_continue_to_breakpoint "varv-associated" -+gdb_test "p varx(3, 7, 19)" "\\$\[0-9\]* = 6" "p varx(3, 7, 19) with varv associated" -+gdb_test "p varv(3, 7, 19)" "\\$\[0-9\]* = 6" "p varv(3, 7, 19) associated" -+# Intel Fortran Compiler 10.1.008 uses -1 there, GCC uses 1. -+gdb_test "p l" "\\$\[0-9\]* = (\\.TRUE\\.|4294967295)" "p l if varv associated" -+gdb_test "ptype varx" "type = real(\\(kind=4\\)|\\*4) \\(6,5:15,17:28\\)" "ptype varx with varv associated" -+# Intel Fortran Compiler 10.1.008 uses the pointer type. -+gdb_test "ptype varv" "type = (PTR TO -> \\( )?real(\\(kind=4\\)|\\*4) \\(6,5:15,17:28\\)\\)?" "ptype varv associated" ++ /* DW_AT_upper_bound is referencing an optimized-out variable. */ ++.Larrayb_type: ++ .uleb128 2 /* Abbrev: DW_TAG_array_type */ ++ .4byte .Lchar_type-.Lcu1_begin /* DW_AT_type */ + -+gdb_breakpoint [gdb_get_line_number "varv-filled"] -+gdb_continue_to_breakpoint "varv-filled" -+gdb_test "p varx(3, 7, 19)" "\\$\[0-9\]* = 10" "p varx(3, 7, 19) with varv filled" -+gdb_test "p varv(3, 7, 19)" "\\$\[0-9\]* = 10" "p varv(3, 7, 19) filled" ++ .uleb128 3 /* Abbrev: DW_TAG_subrange_type */ ++ .4byte .Luint_type-.Lcu1_begin /* DW_AT_type */ ++ .byte 0 /* DW_AT_lower_bound */ ++ .4byte .Llenb_var-.Lcu1_begin /* DW_AT_upper_bound */ ++ .byte 0 /* End of children of die */ + -+gdb_breakpoint [gdb_get_line_number "varv-deassociated"] -+gdb_continue_to_breakpoint "varv-deassociated" -+# The latter one is for the Intel Fortran Compiler 10.1.008 pointer type. -+gdb_test "p varv" "\\$\[0-9\]* = (<(object|the array) is not associated>|.*(Cannot access it|Unable to access the object) because the object is not associated.)" "p varv deassociated" -+gdb_test "ptype varv" "type = (<(object|the array) is not associated>|.*(Cannot access it|Unable to access the object) because the object is not associated.)" "ptype varv deassociated" -+gdb_test "p l" "\\$\[0-9\]* = \\.FALSE\\." "p l if varv deassociated" -+gdb_test "p varv(1,5,17)" "(Cannot access it|Unable to access the object) because the (object|array) is not associated\\." -+gdb_test "ptype varv(1,5,17)" "(Cannot access it|Unable to access the object) because the (object|array) is not associated\\." ++ /* DW_AT_upper_bound is referencing register. */ ++.Larrayreg_type: ++ .uleb128 2 /* Abbrev: DW_TAG_array_type */ ++ .4byte .Lchar_type-.Lcu1_begin /* DW_AT_type */ + -+gdb_breakpoint [gdb_get_line_number "varx-deallocated"] -+gdb_continue_to_breakpoint "varx-deallocated" -+gdb_test "p varx" "\\$\[0-9\]* = <(object|the array) is not allocated>" "p varx deallocated" -+gdb_test "ptype varx" "type = <(object|the array) is not allocated>" "ptype varx deallocated" -+gdb_test "p l" "\\$\[0-9\]* = \\.FALSE\\." "p l if varx deallocated" -+gdb_test "p varx(1,5,17)" "(Cannot access it|Unable to access the object) because the (object|array) is not allocated\\." "p varx(1,5,17) deallocated" -+gdb_test "ptype varx(1,5,17)" "(Cannot access it|Unable to access the object) because the (object|array) is not allocated\\." "ptype varx(1,5,17) deallocated" ++ .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 */ + -+gdb_breakpoint [gdb_get_line_number "vary-passed"] -+gdb_continue_to_breakpoint "vary-passed" -+# $1 = (( ( 1, 1, 1, 1, 1, 1) ( 1, 1, 1, 1, 1, 1) --- , 1) ) ( ( 1, 1, ...) ...) ...) -+gdb_test "p vary" "\\$\[0-9\]* = \\(\[()1, .\]*\\)" ++.Luint_type: ++ .uleb128 4 /* Abbrev: DW_TAG_base_type */ ++ .4byte .Luint_str /* DW_AT_name */ ++ .byte 4 /* DW_AT_byte_size */ ++ .byte 7 /* DW_AT_encoding */ + -+gdb_breakpoint [gdb_get_line_number "vary-filled"] -+gdb_continue_to_breakpoint "vary-filled" -+gdb_test "ptype vary" "type = real(\\(kind=4\\)|\\*4) \\(10,10\\)" -+gdb_test "p vary(1, 1)" "\\$\[0-9\]* = 8" -+gdb_test "p vary(2, 2)" "\\$\[0-9\]* = 9" -+gdb_test "p vary(1, 3)" "\\$\[0-9\]* = 10" -+# $1 = (( ( 3, 3, 3, 3, 3, 3) ( 3, 3, 3, 3, 3, 3) --- , 3) ) ( ( 3, 3, ...) ...) ...) -+gdb_test "p varw" "\\$\[0-9\]* = \\(\[()3, .\]*\\)" ++.Lchar_type: ++ .uleb128 4 /* Abbrev: DW_TAG_base_type */ ++ .4byte .Lchar_str /* DW_AT_name */ ++ .byte 1 /* DW_AT_byte_size */ ++ .byte 6 /* DW_AT_encoding */ + -+gdb_breakpoint [gdb_get_line_number "varw-almostfilled"] -+gdb_continue_to_breakpoint "varw-almostfilled" -+gdb_test "ptype varw" "type = real(\\(kind=4\\)|\\*4) \\(5,4,3\\)" -+gdb_test "p varw(3,1,1)=1" "\\$\[0-9\]* = 1" -+# $1 = (( ( 6, 5, 1, 5, 5, 5) ( 5, 5, 5, 5, 5, 5) --- , 5) ) ( ( 5, 5, ...) ...) ...) -+gdb_test "p varw" "\\$\[0-9\]* = \\( *\\( *\\( *6, *5, *1,\[()5, .\]*\\)" "p varw filled" -+# "up" works with GCC but other Fortran compilers may copy the values into the -+# outer function only on the exit of the inner function. -+# We need both variants as depending on the arch we optionally may still be -+# executing the caller line or not after `finish'. -+gdb_test "finish" ".*(call bar \\(y, x\\)|call foo \\(x, z\\(2:6, 4:7, 6:8\\)\\))" -+gdb_test "p z(2,4,5)" "\\$\[0-9\]* = 3" -+gdb_test "p z(2,4,6)" "\\$\[0-9\]* = 6" -+gdb_test "p z(2,4,7)" "\\$\[0-9\]* = 5" -+gdb_test "p z(4,4,6)" "\\$\[0-9\]* = 1" ++.Llen_var: ++ .uleb128 5 /* Abbrev: DW_TAG_variable artificial */ ++ .byte 1 /* DW_AT_artificial */ ++ .4byte .Luint_type-.Lcu1_begin /* DW_AT_type */ ++ .4byte .Llen_loclist-.Lloclist /* DW_AT_location */ + -+gdb_breakpoint [gdb_get_line_number "varz-almostfilled"] -+gdb_continue_to_breakpoint "varz-almostfilled" -+# GCC uses the pointer type here, Intel Fortran Compiler 10.1.008 does not. -+gdb_test "ptype varz" "type = (PTR TO -> \\( )?real(\\(kind=4\\)|\\*4) \\(\\*\\)\\)?" -+# Intel Fortran Compiler 10.1.008 has a bug here - (2:11,7:7) -+# as it produces DW_AT_lower_bound == DW_AT_upper_bound == 7. -+gdb_test "ptype vart" "type = (PTR TO -> \\( )?real(\\(kind=4\\)|\\*4) \\(2:11,7:\\*\\)\\)?" -+gdb_test "p varz" "\\$\[0-9\]* = \\(\\)" -+gdb_test "p vart" "\\$\[0-9\]* = \\(\\)" -+gdb_test "p varz(3)" "\\$\[0-9\]* = 4" -+# maps to foo::vary(1,1) -+gdb_test "p vart(2,7)" "\\$\[0-9\]* = 8" -+# maps to foo::vary(2,2) -+gdb_test "p vart(3,8)" "\\$\[0-9\]* = 9" -+# maps to foo::vary(1,3) -+gdb_test "p vart(2,9)" "\\$\[0-9\]* = 10" -diff --git a/gdb/testsuite/gdb.fortran/dynamic.f90 b/gdb/testsuite/gdb.fortran/dynamic.f90 -new file mode 100644 -index 0000000..0f43564 ---- /dev/null -+++ b/gdb/testsuite/gdb.fortran/dynamic.f90 -@@ -0,0 +1,98 @@ -+! Copyright 2007 Free Software Foundation, Inc. -+! -+! This program is free software; you can redistribute it and/or modify -+! it under the terms of the GNU General Public License as published by -+! the Free Software Foundation; either version 2 of the License, or -+! (at your option) any later version. -+! -+! This program is distributed in the hope that it will be useful, -+! but WITHOUT ANY WARRANTY; without even the implied warranty of -+! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+! GNU General Public License for more details. -+! -+! You should have received a copy of the GNU General Public License -+! along with this program; if not, write to the Free Software -+! Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -+! -+! Ihis file is the Fortran source file for dynamic.exp. -+! Original file written by Jakub Jelinek . -+! Modified for the GDB testcase by Jan Kratochvil . ++ /* optimized-out variable for b_string. */ ++.Llenb_var: ++ .uleb128 7 /* Abbrev: DW_TAG_variable artificial no DW_AT_location */ ++ .byte 1 /* DW_AT_artificial */ ++ .4byte .Luint_type-.Lcu1_begin /* DW_AT_type */ ++ ++ .uleb128 6 /* Abbrev: DW_TAG_variable DW_FORM_string */ ++ .string "a_string" /* DW_AT_name */ ++ .4byte .Larray_type-.Lcu1_begin /* DW_AT_type */ ++ .byte 2f - 1f /* DW_AT_location */ ++1: .byte 3 /* DW_OP_addr */ ++ .4byte vardata /* */ ++2: ++ ++ /* DW_AT_upper_bound is referencing an optimized-out variable. */ ++ .uleb128 6 /* Abbrev: DW_TAG_variable DW_FORM_string */ ++ .string "b_string" /* DW_AT_name */ ++ .4byte .Larrayb_type-.Lcu1_begin /* DW_AT_type */ ++ .byte 2f - 1f /* DW_AT_location */ ++1: .byte 3 /* DW_OP_addr */ ++ .4byte vardata /* */ ++2: + -+subroutine baz -+ real, target, allocatable :: varx (:, :, :) -+ real, pointer :: varv (:, :, :) -+ real, target :: varu (1, 2, 3) -+ logical :: l -+ allocate (varx (1:6, 5:15, 17:28)) ! varx-init -+ l = allocated (varx) -+ varx(:, :, :) = 6 ! varx-allocated -+ varx(1, 5, 17) = 7 -+ varx(2, 6, 18) = 8 -+ varx(6, 15, 28) = 9 -+ varv => varx ! varx-filled -+ l = associated (varv) -+ varv(3, 7, 19) = 10 ! varv-associated -+ varv => null () ! varv-filled -+ l = associated (varv) -+ deallocate (varx) ! varv-deassociated -+ l = allocated (varx) -+ varu(:, :, :) = 10 ! varx-deallocated -+ allocate (varv (1:6, 5:15, 17:28)) -+ l = associated (varv) -+ varv(:, :, :) = 6 -+ varv(1, 5, 17) = 7 -+ varv(2, 6, 18) = 8 -+ varv(6, 15, 28) = 9 -+ deallocate (varv) -+ l = associated (varv) -+ varv => varu -+ varv(1, 1, 1) = 6 -+ varv(1, 2, 3) = 7 -+ l = associated (varv) -+end subroutine baz -+subroutine foo (vary, varw) -+ real :: vary (:, :) -+ real :: varw (:, :, :) -+ vary(:, :) = 4 ! vary-passed -+ vary(1, 1) = 8 -+ vary(2, 2) = 9 -+ vary(1, 3) = 10 -+ varw(:, :, :) = 5 ! vary-filled -+ varw(1, 1, 1) = 6 -+ varw(2, 2, 2) = 7 ! varw-almostfilled -+end subroutine foo -+subroutine bar (varz, vart) -+ real :: varz (*) -+ real :: vart (2:11, 7:*) -+ varz(1:3) = 4 -+ varz(2) = 5 ! varz-almostfilled -+ vart(2,7) = vart(2,7) -+end subroutine bar -+program test -+ interface -+ subroutine foo (vary, varw) -+ real :: vary (:, :) -+ real :: varw (:, :, :) -+ end subroutine -+ end interface -+ interface -+ subroutine bar (varz, vart) -+ real :: varz (*) -+ real :: vart (2:11, 7:*) -+ end subroutine -+ end interface -+ real :: x (10, 10), y (5), z(8, 8, 8) -+ x(:,:) = 1 -+ y(:) = 2 -+ z(:,:,:) = 3 -+ call baz -+ call foo (x, z(2:6, 4:7, 6:8)) -+ call bar (y, x) -+ if (x (1, 1) .ne. 8 .or. x (2, 2) .ne. 9 .or. x (1, 2) .ne. 4) call abort -+ if (x (1, 3) .ne. 10) call abort -+ if (z (2, 4, 6) .ne. 6 .or. z (3, 5, 7) .ne. 7 .or. z (2, 4, 7) .ne. 5) call abort -+ if (any (y .ne. (/4, 5, 4, 2, 2/))) call abort -+ call foo (transpose (x), z) -+ if (x (1, 1) .ne. 8 .or. x (2, 2) .ne. 9 .or. x (1, 2) .ne. 4) call abort -+ if (x (3, 1) .ne. 10) call abort -+end -diff --git a/gdb/testsuite/gdb.fortran/string.exp b/gdb/testsuite/gdb.fortran/string.exp -new file mode 100644 -index 0000000..39de2c4 ---- /dev/null -+++ b/gdb/testsuite/gdb.fortran/string.exp -@@ -0,0 +1,59 @@ -+# Copyright 2008 Free Software Foundation, Inc. ++ /* 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 /* */ ++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 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. ++ .byte 0 /* End of children of CU */ ++.Lcu1_end: + -+# This file was written by Jan Kratochvil . ++ .section .debug_loc ++.Lloclist: ++.Llen_loclist: ++ .4byte 0 # Location list begin address ++ .4byte main_length # Location list end address ++ .value 2f-1f # Location expression size ++1: .byte 0x33 # DW_OP_lit3 ++ .byte 0x9f # DW_OP_stack_value ++2: ++ .quad 0x0 # Location list terminator begin (*.LLST2) ++ .quad 0x0 # Location list terminator end (*.LLST2) + -+# This file is part of the gdb testsuite. It contains tests for Fortran -+# strings with dynamic length. ++ .section .debug_abbrev ++.Ldebug_abbrev0: ++ .uleb128 1 /* Abbrev code */ ++ .uleb128 0x11 /* DW_TAG_compile_unit */ ++ .byte 0x1 /* has_children */ ++ .uleb128 0x25 /* DW_AT_producer */ ++ .uleb128 0xe /* DW_FORM_strp */ ++ .uleb128 0x13 /* DW_AT_language */ ++ .uleb128 0xb /* DW_FORM_data1 */ ++ .uleb128 0x11 /* DW_AT_low_pc */ ++ .uleb128 0x1 /* DW_FORM_addr */ ++ .uleb128 0x12 /* DW_AT_high_pc */ ++ .uleb128 0xb /* DW_FORM_data1 */ ++ .byte 0x0 /* Terminator */ ++ .byte 0x0 /* Terminator */ + -+set testfile "string" -+set srcfile ${testfile}.f90 -+set binfile ${objdir}/${subdir}/${testfile} ++ .uleb128 2 /* Abbrev code */ ++ .uleb128 0x1 /* TAG: DW_TAG_array_type */ ++ .byte 0x1 /* DW_children_yes */ ++ .uleb128 0x49 /* DW_AT_type */ ++ .uleb128 0x13 /* DW_FORM_ref4 */ ++ .byte 0x0 /* Terminator */ ++ .byte 0x0 /* Terminator */ + -+if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug f90 quiet}] != "" } { -+ untested "Couldn't compile ${srcfile}" -+ return -1 -+} ++ .uleb128 3 /* Abbrev code */ ++ .uleb128 0x21 /* DW_TAG_subrange_type */ ++ .byte 0x0 /* no children */ ++ .uleb128 0x49 /* DW_AT_type */ ++ .uleb128 0x13 /* DW_FORM_ref4 */ ++ .uleb128 0x22 /* DW_AT_lower_bound */ ++ .uleb128 0xb /* DW_FORM_data1 */ ++ .uleb128 0x2f /* DW_AT_upper_bound */ ++ .uleb128 0x13 /* DW_FORM_ref4 */ ++ .byte 0x0 /* Terminator */ ++ .byte 0x0 /* Terminator */ + -+gdb_exit -+gdb_start -+gdb_reinitialize_dir $srcdir/$subdir -+gdb_load ${binfile} ++ .uleb128 4 /* Abbrev code */ ++ .uleb128 0x24 /* DW_TAG_base_type */ ++ .byte 0x0 /* no_children */ ++ .uleb128 0x3 /* DW_AT_name */ ++ .uleb128 0xe /* DW_FORM_strp */ ++ .uleb128 0xb /* DW_AT_byte_size */ ++ .uleb128 0xb /* DW_FORM_data1 */ ++ .uleb128 0x3e /* DW_AT_encoding */ ++ .uleb128 0xb /* DW_FORM_data1 */ ++ .byte 0x0 /* Terminator */ ++ .byte 0x0 /* Terminator */ + -+if ![runto MAIN__] then { -+ perror "couldn't run to breakpoint MAIN__" -+ continue -+} ++ .uleb128 5 /* Abbrev code */ ++ .uleb128 0x34 /* DW_TAG_variable */ ++ .byte 0x0 /* no_children */ ++ .uleb128 0x34 /* DW_AT_artificial */ ++ .uleb128 0x0c /* DW_FORM_flag */ ++ .uleb128 0x49 /* DW_AT_type */ ++ .uleb128 0x13 /* DW_FORM_ref4 */ ++ .uleb128 0x02 /* DW_AT_location */ ++ .uleb128 0x06 /* DW_FORM_data4 */ ++ .byte 0x0 /* Terminator */ ++ .byte 0x0 /* Terminator */ + -+gdb_breakpoint [gdb_get_line_number "var-init"] -+gdb_continue_to_breakpoint "var-init" -+gdb_test "ptype c" "type = character(\\(kind=1\\)|\\*1)" -+gdb_test "ptype d" "type = character(\\(kind=8\\)|\\*8)" -+gdb_test "ptype e" "type = character(\\(kind=4\\)|\\*4)" -+gdb_test "ptype f" "type = character(\\(kind=4\\)|\\*4) \\(7,8:10\\)" -+gdb_test "ptype *e" "Attempt to take contents of a non-pointer value." -+gdb_test "ptype *f" "type = character(\\(kind=4\\)|\\*4) \\(7\\)" -+gdb_test "p c" "\\$\[0-9\]* = 'c'" -+gdb_test "p d" "\\$\[0-9\]* = 'd '" -+gdb_test "p e" "\\$\[0-9\]* = 'g '" -+gdb_test "p f" "\\$\[0-9\]* = \\(\\( 'h ', 'h ', 'h ', 'h ', 'h ', 'h ', 'h '\\) \\( 'h ', 'h ', 'h ', 'h ', 'h ', 'h ', 'h '\\) \\( 'h ', 'h ', 'h ', 'h ', 'h ', 'h ', 'h '\\) \\)" -+gdb_test "p *e" "Attempt to take contents of a non-pointer value." -+gdb_test "p *f" "Attempt to take contents of a non-pointer value." ++ .uleb128 6 /* Abbrev code */ ++ .uleb128 0x34 /* DW_TAG_variable */ ++ .byte 0x0 /* no_children */ ++ .uleb128 0x3 /* DW_AT_name */ ++ .uleb128 0x8 /* DW_FORM_string */ ++ .uleb128 0x49 /* DW_AT_type */ ++ .uleb128 0x13 /* DW_FORM_ref4 */ ++ .uleb128 0x2 /* DW_AT_location */ ++ .uleb128 0xa /* DW_FORM_block1 */ ++ .byte 0x0 /* Terminator */ ++ .byte 0x0 /* Terminator */ + -+gdb_breakpoint [gdb_get_line_number "var-finish"] -+gdb_continue_to_breakpoint "var-finish" -+gdb_test "p e" "\\$\[0-9\]* = 'e '" "p e re-set" -+gdb_test "p f" "\\$\[0-9\]* = \\(\\( 'f ', 'f ', 'f ', 'f ', 'f ', 'f ', 'f '\\) \\( 'f2 ', 'f ', 'f ', 'f ', 'f ', 'f ', 'f '\\) \\( 'f ', 'f ', 'f ', 'f ', 'f ', 'f ', 'f '\\) \\)" "p *f re-set" -diff --git a/gdb/testsuite/gdb.fortran/string.f90 b/gdb/testsuite/gdb.fortran/string.f90 -new file mode 100644 -index 0000000..226dc5d ---- /dev/null -+++ b/gdb/testsuite/gdb.fortran/string.f90 -@@ -0,0 +1,37 @@ -+! Copyright 2008 Free Software Foundation, Inc. -+! -+! This program is free software; you can redistribute it and/or modify -+! it under the terms of the GNU General Public License as published by -+! the Free Software Foundation; either version 2 of the License, or -+! (at your option) any later version. -+! -+! This program is distributed in the hope that it will be useful, -+! but WITHOUT ANY WARRANTY; without even the implied warranty of -+! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+! GNU General Public License for more details. -+! -+! You should have received a copy of the GNU General Public License -+! along with this program; if not, write to the Free Software -+! Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -+! -+! Ihis file is the Fortran source file for dynamic.exp. -+! Original file written by Jakub Jelinek . -+! Modified for the GDB testcase by Jan Kratochvil . ++ .uleb128 7 /* Abbrev code */ ++ .uleb128 0x34 /* DW_TAG_variable */ ++ .byte 0x0 /* no_children */ ++ .uleb128 0x34 /* DW_AT_artificial */ ++ .uleb128 0x0c /* DW_FORM_flag */ ++ .uleb128 0x49 /* DW_AT_type */ ++ .uleb128 0x13 /* DW_FORM_ref4 */ ++ .byte 0x0 /* Terminator */ ++ .byte 0x0 /* Terminator */ + -+subroutine foo (e, f) -+ character (len=1) :: c -+ character (len=8) :: d -+ character (len=*) :: e -+ character (len=*) :: f (1:7, 8:10) -+ c = 'c' -+ d = 'd' -+ e = 'e' ! var-init -+ f = 'f' -+ f(1,9) = 'f2' -+ c = 'c' ! var-finish -+end subroutine foo -+ character (len=4) :: g, h (1:7, 8:10) -+ g = 'g' -+ h = 'h' -+ call foo (g, h) -+end -diff --git a/gdb/testsuite/gdb.fortran/subrange.exp b/gdb/testsuite/gdb.fortran/subrange.exp ++ .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 */ ++ .section .debug_str ++.Lproducer: ++ .string "GNU C 3.3.3" ++.Lchar_str: ++ .string "char" ++.Luint_str: ++ .string "unsigned int" +diff --git a/gdb/testsuite/gdb.dwarf2/dw2-bound-loclist.exp b/gdb/testsuite/gdb.dwarf2/dw2-bound-loclist.exp new file mode 100644 -index 0000000..c819e23 +index 0000000..815ed93 --- /dev/null -+++ b/gdb/testsuite/gdb.fortran/subrange.exp -@@ -0,0 +1,60 @@ -+# Copyright 2011 Free Software Foundation, Inc. ++++ b/gdb/testsuite/gdb.dwarf2/dw2-bound-loclist.exp +@@ -0,0 +1,54 @@ ++# 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 @@ -13686,204 +7036,187 @@ index 0000000..c819e23 +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + -+if { [skip_fortran_tests] } { return -1 } ++# Test printing variable with dynamic bounds which reference a different ++# (artificial in the GCC case) variable containing loclist as its location. ++# This testcase uses value (not address) of the referenced variable: ++# http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43762 + -+set testfile "subrange" -+set srcfile ${testfile}.f90 -+if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} {debug f90}] } { -+ return -1 ++# This test can only be run on targets which support DWARF-2 and use gas. ++# For now pick a sampling of likely targets. ++if {![istarget *-*-linux*] ++ && ![istarget *-*-gnu*] ++ && ![istarget *-*-elf*] ++ && ![istarget *-*-openbsd*] ++ && ![istarget arm-*-eabi*] ++ && ![istarget powerpc-*-eabi*]} { ++ return 0 +} + -+if ![runto MAIN__] { -+ perror "Couldn't run to MAIN__" -+ continue ++set testfile dw2-bound-loclist ++if { [prepare_for_testing ${testfile}.exp ${testfile} [list ${testfile}.S main.c] {}] } { ++ return -1 +} + -+# 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:" ++# Verify it behaves at least as an unbound array without inferior. + -+ 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" ++gdb_test "p a_string" { = 0x[0-9a-f]+ "seennotseen"} ++gdb_test "ptype a_string" {type = char \[\]} + -+ set pf_prefix $old_prefix ++# Not runto_main as dw2-bound-loclist.S handles only the first byte of main. ++if ![runto "*main"] { ++ return -1 +} + -+gdb_test_no_output {set $a=a} -+delete_breakpoints -+gdb_unload -+gdb_test {p $a (3, 2:2)} { = \(23\)} -diff --git a/gdb/testsuite/gdb.fortran/subrange.f90 b/gdb/testsuite/gdb.fortran/subrange.f90 -new file mode 100644 -index 0000000..4747ea9 ---- /dev/null -+++ b/gdb/testsuite/gdb.fortran/subrange.f90 -@@ -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 . ++gdb_test "p a_string" { = "seen"} ++gdb_test "ptype a_string" {type = char \[4\]} + -+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 -diff --git a/gdb/testsuite/gdb.gdb/selftest.exp b/gdb/testsuite/gdb.gdb/selftest.exp -index 21798bc..111f692 100644 ---- a/gdb/testsuite/gdb.gdb/selftest.exp -+++ b/gdb/testsuite/gdb.gdb/selftest.exp -@@ -88,6 +88,10 @@ proc do_steps_and_nexts {} { - set description "step over ttyarg initialization" - set command "step" - } -+ -re ".*python_script = 0.*$gdb_prompt $" { -+ set description "step over python_script initialization" -+ set command "step" -+ } - -re ".*pre_stat_chain = make_command_stats_cleanup.*$gdb_prompt $" { - set description "next over make_command_stats_cleanup and everything it calls" - set command "next" -diff --git a/gdb/testsuite/gdb.mi/mi2-var-stale-type.c b/gdb/testsuite/gdb.mi/mi2-var-stale-type.c ++gdb_test "p b_string" { = (0x[0-9a-f]+ )?"seennotseen"} ++gdb_test "ptype b_string" {type = char \[\]} ++ ++# The register contains unpredictable value - the array size. ++gdb_test "ptype reg_string" {type = char \[-?[0-9]+\]} +diff --git a/gdb/testsuite/gdb.dwarf2/dw2-stripped.c b/gdb/testsuite/gdb.dwarf2/dw2-stripped.c new file mode 100644 -index 0000000..ebced3c +index 0000000..1f02d90 --- /dev/null -+++ b/gdb/testsuite/gdb.mi/mi2-var-stale-type.c -@@ -0,0 +1,26 @@ -+/* Copyright 2011 Free Software Foundation, Inc. ++++ b/gdb/testsuite/gdb.dwarf2/dw2-stripped.c +@@ -0,0 +1,42 @@ ++/* This testcase is part of GDB, the GNU debugger. + -+ This file is part of GDB. ++ Copyright 2004 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 ++ 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, see . */ ++ along with this program; if not, write to the Free Software ++ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, ++ USA. */ + -+int -+main (int argc, char **argv) ++ ++/* The function `func1' traced into must have debug info on offset > 0; ++ (DW_UNSND (attr)). This is the reason of `func0' existence. */ ++ ++void ++func0(int a, int b) +{ -+ char vla[argc]; ++} + -+ vla[0] = 0; /* break-here */ ++/* `func1' being traced into must have some arguments to dump. */ + ++void ++func1(int a, int b) ++{ ++ func0 (a,b); ++} ++ ++int ++main(void) ++{ ++ func1 (1, 2); + return 0; +} -diff --git a/gdb/testsuite/gdb.mi/mi2-var-stale-type.exp b/gdb/testsuite/gdb.mi/mi2-var-stale-type.exp +diff --git a/gdb/testsuite/gdb.dwarf2/dw2-stripped.exp b/gdb/testsuite/gdb.dwarf2/dw2-stripped.exp new file mode 100644 -index 0000000..74a104e +index 0000000..1c6e84a --- /dev/null -+++ b/gdb/testsuite/gdb.mi/mi2-var-stale-type.exp -@@ -0,0 +1,57 @@ -+# Copyright 2011 Free Software Foundation, Inc. -+# ++++ b/gdb/testsuite/gdb.dwarf2/dw2-stripped.exp +@@ -0,0 +1,79 @@ ++# Copyright 2006 Free Software Foundation, Inc. ++ +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by -+# the Free Software Foundation; either version 3 of the License, or ++# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. -+# ++# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR 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 . ++# along with this program; if not, write to the Free Software ++# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + -+load_lib mi-support.exp -+set MIFLAGS "-i=mi2" ++# Minimal DWARF-2 unit test + -+gdb_exit -+if [mi_gdb_start] { -+ continue ++# This test can only be run on targets which support DWARF-2. ++# For now pick a sampling of likely targets. ++if {![istarget *-*-linux*] ++ && ![istarget *-*-gnu*] ++ && ![istarget *-*-elf*] ++ && ![istarget *-*-openbsd*] ++ && ![istarget arm-*-eabi*] ++ && ![istarget powerpc-*-eabi*]} { ++ return 0 +} + -+set testfile "mi2-var-stale-type" ++set testfile "dw2-stripped" +set srcfile ${testfile}.c -+set binfile ${objdir}/${subdir}/${testfile} -+if {[build_executable ${testfile}.exp $testfile $srcfile] == -1} { -+ return -1 -+} ++set binfile ${objdir}/${subdir}/${testfile}.x + -+mi_delete_breakpoints -+mi_gdb_reinitialize_dir $srcdir/$subdir -+mi_gdb_load ${binfile} ++remote_exec build "rm -f ${binfile}" + -+mi_gdb_test {-interpreter-exec console "maintenance set internal-error quit yes"} \ -+ {\^done} \ -+ "maintenance set internal-error quit yes" ++# get the value of gcc_compiled ++if [get_compiler_info ${binfile}] { ++ return -1 ++} + -+mi_gdb_test {-interpreter-exec console "maintenance set internal-error corefile yes"} \ -+ {\^done} \ -+ "maintenance set internal-error corefile yes" ++# This test can only be run on gcc as we use additional_flags=FIXME ++if {$gcc_compiled == 0} { ++ return 0 ++} + -+set line [gdb_get_line_number "break-here"] -+set func "main" ++if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-ggdb3}] != "" } { ++ return -1 ++} + -+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" ++remote_exec build "objcopy -R .debug_loc ${binfile}" ++set strip_output [remote_exec build "objdump -h ${binfile}"] + -+if { [mi_run_cmd] < 0 } { -+ return -1 ++set test "stripping test file preservation" ++if [ regexp ".debug_info " $strip_output] { ++ pass "$test (.debug_info preserved)" ++} else { ++ fail "$test (.debug_info got also stripped)" +} -+mi_expect_stop "breakpoint-hit" $func ".*" ".*" "\[0-9\]+" { "" "disp=\"del\"" } "stop after initializing vla" + -+mi_create_varobj "vla" "vla" "create local variable vla" ++set test "stripping test file functionality" ++if [ regexp ".debug_loc " $strip_output] { ++ fail "$test (.debug_loc still present)" ++} else { ++ pass "$test (.debug_loc stripped)" ++} + -+mi_gdb_test "-var-update *" "\\^done,changelist=.*" "-var-update *" -diff --git a/gdb/testsuite/gdb.multi/watchpoint-multi.c b/gdb/testsuite/gdb.multi/watchpoint-multi.c ++gdb_exit ++gdb_start ++gdb_reinitialize_dir $srcdir/$subdir ++gdb_load ${binfile} ++ ++# For C programs, "start" should stop in main(). ++ ++gdb_test "start" \ ++ ".*main \\(\\) at .*" \ ++ "start" ++gdb_test "step" \ ++ "func.* \\(.*\\) at .*" \ ++ "step" +diff --git a/gdb/testsuite/gdb.dwarf2/dw2-struct-member-data-location.S b/gdb/testsuite/gdb.dwarf2/dw2-struct-member-data-location.S new file mode 100644 -index 0000000..51697b0 +index 0000000..5fcdd84 --- /dev/null -+++ b/gdb/testsuite/gdb.multi/watchpoint-multi.c -@@ -0,0 +1,51 @@ ++++ b/gdb/testsuite/gdb.dwarf2/dw2-struct-member-data-location.S +@@ -0,0 +1,83 @@ +/* This testcase is part of GDB, the GNU debugger. + -+ Copyright 2012 Free Software Foundation, Inc. ++ Copyright 2009 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by @@ -13898,48 +7231,80 @@ index 0000000..51697b0 + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + -+#include -+#include ++/* Debug information */ + -+static volatile int a, b, c; ++ .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 */ + -+static void -+marker_exit (void) -+{ -+ a = 1; -+} ++ /* CU die */ ++ .uleb128 1 /* Abbrev: DW_TAG_compile_unit */ ++ .ascii "dw2-struct-member-data-location.c\0" /* DW_AT_name */ ++ .ascii "GNU C 4.3.2\0" /* DW_AT_producer */ ++ .byte 1 /* DW_AT_language (C) */ + -+static void * -+start (void *arg) -+{ -+ b = 2; -+ c = 3; ++.Ltype_uchar: ++ .uleb128 2 /* Abbrev: DW_TAG_structure_type */ ++ .ascii "some_struct\0" /* DW_AT_name */ + -+ return NULL; -+} ++ .uleb128 3 /* Abbrev: DW_TAG_member */ ++ .ascii "field\0" /* DW_AT_name */ ++ .byte 0 /* DW_AT_data_member_location */ + -+int -+main (void) -+{ -+ pthread_t thread; -+ int i; ++ .byte 0 /* End of children of some_struct */ ++ ++ .byte 0 /* End of children of CU */ + -+ i = pthread_create (&thread, NULL, start, NULL); -+ assert (i == 0); -+ i = pthread_join (thread, NULL); -+ assert (i == 0); ++.Lcu1_end: + -+ marker_exit (); -+ return 0; -+} -diff --git a/gdb/testsuite/gdb.multi/watchpoint-multi.exp b/gdb/testsuite/gdb.multi/watchpoint-multi.exp ++/* Abbrev table */ ++ .section .debug_abbrev ++.Labbrev1_begin: ++ .uleb128 1 /* Abbrev code */ ++ .uleb128 0x11 /* DW_TAG_compile_unit */ ++ .byte 1 /* has_children */ ++ .uleb128 0x3 /* DW_AT_name */ ++ .uleb128 0x8 /* DW_FORM_string */ ++ .uleb128 0x25 /* DW_AT_producer */ ++ .uleb128 0x8 /* DW_FORM_string */ ++ .uleb128 0x13 /* DW_AT_language */ ++ .uleb128 0xb /* DW_FORM_data1 */ ++ .byte 0x0 /* Terminator */ ++ .byte 0x0 /* Terminator */ ++ ++ .uleb128 2 /* Abbrev code */ ++ .uleb128 0x13 /* DW_TAG_structure_type */ ++ .byte 1 /* has_children */ ++ .uleb128 0x3 /* DW_AT_name */ ++ .uleb128 0x8 /* DW_FORM_string */ ++ .byte 0x0 /* Terminator */ ++ .byte 0x0 /* Terminator */ ++ ++ .uleb128 3 /* Abbrev code */ ++ .uleb128 0x0d /* DW_TAG_member */ ++ .byte 0 /* has_children */ ++ .uleb128 0x3 /* DW_AT_name */ ++ .uleb128 0x8 /* DW_FORM_string */ ++ .uleb128 0x38 /* DW_AT_data_member_location */ ++ .uleb128 0x0b /* DW_FORM_data1 */ ++ .byte 0x0 /* Terminator */ ++ .byte 0x0 /* Terminator */ ++ ++ .byte 0x0 /* Terminator */ ++ .byte 0x0 /* Terminator */ +diff --git a/gdb/testsuite/gdb.dwarf2/dw2-struct-member-data-location.exp b/gdb/testsuite/gdb.dwarf2/dw2-struct-member-data-location.exp new file mode 100644 -index 0000000..d7daeec +index 0000000..c41151c --- /dev/null -+++ b/gdb/testsuite/gdb.multi/watchpoint-multi.exp -@@ -0,0 +1,92 @@ -+# Copyright 2012 Free Software Foundation, Inc. -+# ++++ b/gdb/testsuite/gdb.dwarf2/dw2-struct-member-data-location.exp +@@ -0,0 +1,37 @@ ++# Copyright 2009 Free Software Foundation, Inc. ++ +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or @@ -13953,92 +7318,37 @@ index 0000000..d7daeec +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + -+if [is_remote target] { -+ # It is KFAIL. -+ continue ++# This test can only be run on targets which support DWARF-2 and use gas. ++# For now pick a sampling of likely targets. ++if {![istarget *-*-linux*] ++ && ![istarget *-*-gnu*] ++ && ![istarget *-*-elf*] ++ && ![istarget *-*-openbsd*] ++ && ![istarget arm-*-eabi*] ++ && ![istarget powerpc-*-eabi*]} { ++ return 0 +} + -+set testfile "watchpoint-multi" -+ -+set executable ${testfile} -+set srcfile ${testfile}.c -+set binfile ${objdir}/${subdir}/${executable} ++set testfile "dw2-struct-member-data-location" ++set srcfile ${testfile}.S ++set binfile ${testfile}.x + -+if { [gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } { -+ untested ${testfile}.exp ++if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${objdir}/${subdir}/${binfile}" object {nodebug}] != "" } { + 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" -+ -+gdb_breakpoint "marker_exit" -+ -+gdb_test "inferior 1" "witching to inferior 1 .*" -+ -+set have_awatch_b 0 -+set test "awatch b" -+gdb_test_multiple $test $test { -+ -re "Hardware access \\(read/write\\) watchpoint \[0-9\]+: b\r\n$gdb_prompt $" { -+ pass $test -+ set have_awatch_b 1 -+ } -+ -re "There are not enough available hardware resources for this watchpoint\\.\r\n$gdb_prompt $" { -+ untested $test -+ return -+ } -+} -+ -+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" -+ -+gdb_test "continue" "Breakpoint \[0-9\]+, marker_exit .*" "catch marker_exit in inferior 2" -+ -+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" ++clean_restart $binfile + -+gdb_test "continue" "Breakpoint \[0-9\]+, marker_exit .*" "catch marker_exit in inferior 1" -diff --git a/gdb/testsuite/gdb.opt/array-from-register-func.c b/gdb/testsuite/gdb.opt/array-from-register-func.c ++gdb_test "ptype struct some_struct" "type = struct some_struct {\[\r\n \t\]*void field;\[\r\n \t\]*}" +diff --git a/gdb/testsuite/gdb.dwarf2/dw2-subrange-no-type.S b/gdb/testsuite/gdb.dwarf2/dw2-subrange-no-type.S new file mode 100644 -index 0000000..729f457 +index 0000000..9dbbf3c --- /dev/null -+++ b/gdb/testsuite/gdb.opt/array-from-register-func.c -@@ -0,0 +1,22 @@ -+/* This file is part of GDB, the GNU debugger. ++++ b/gdb/testsuite/gdb.dwarf2/dw2-subrange-no-type.S +@@ -0,0 +1,121 @@ ++/* This testcase is part of GDB, the GNU debugger. + -+ Copyright 2009 Free Software Foundation, Inc. ++ Copyright 2012 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 @@ -14053,56 +7363,121 @@ index 0000000..729f457 + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + -+int -+func (int *arr) -+{ -+ return arr[0]; -+} -diff --git a/gdb/testsuite/gdb.opt/array-from-register.c b/gdb/testsuite/gdb.opt/array-from-register.c -new file mode 100644 -index 0000000..3090e7e ---- /dev/null -+++ b/gdb/testsuite/gdb.opt/array-from-register.c -@@ -0,0 +1,28 @@ -+/* This file is part of GDB, the GNU debugger. ++/* Debug information */ + -+ Copyright 2009 Free Software Foundation, Inc. ++ .section .data ++vardata: ++ .rept 129 ++ .ascii "x" ++ .endr ++ .ascii "UNSEEN\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. ++ .section .debug_info ++.Lcu1_begin: ++ .4byte .Lcu1_end - .Lcu1_start /* Length of Compilation Unit */ ++.Lcu1_start: ++ .2byte 2 /* DWARF version number */ ++ .4byte .Ldebug_abbrev0 /* Offset Into Abbrev. Section */ ++ .byte 4 /* Pointer Size (in bytes) */ + -+ This program is distributed in the hope that it will be useful, -+ but WITHOUT ANY WARRANTY; without even the implied warranty of -+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+ GNU General Public License for more details. ++ /* CU die */ ++ .uleb128 1 /* Abbrev: DW_TAG_compile_unit */ ++ .ascii "GNU C 3.3.3\0" /* DW_AT_producer */ ++ .byte 2 /* DW_AT_language (C) - */ ++ ++.Larray_type: ++ .uleb128 2 /* Abbrev: DW_TAG_array_type */ ++ .4byte .Lchar_type-.Lcu1_begin /* DW_AT_type */ ++ ++ .uleb128 8 /* Abbrev: DW_TAG_subrange_type without DW_AT_type */ ++ .byte 0 /* DW_AT_lower_bound */ ++ .byte 128 /* DW_AT_upper_bound */ ++ ++ .byte 0 /* End of children of die */ ++ ++.Lchar_type: ++ .uleb128 4 /* Abbrev: DW_TAG_base_type */ ++ .ascii "char\0" /* DW_AT_name */ ++ .byte 1 /* DW_AT_byte_size */ ++ .byte 6 /* DW_AT_encoding */ ++ ++ .uleb128 6 /* Abbrev: DW_TAG_variable DW_FORM_string */ ++ .ascii "notype_string\0" /* DW_AT_name */ ++ .4byte .Larray_type-.Lcu1_begin /* DW_AT_type */ ++ .byte 2f - 1f /* DW_AT_location */ ++1: .byte 3 /* DW_OP_addr */ ++ .4byte vardata /* */ ++2: ++ ++ .byte 0 /* End of children of CU */ ++.Lcu1_end: ++ ++ .section .debug_abbrev ++.Ldebug_abbrev0: ++ .uleb128 1 /* Abbrev code */ ++ .uleb128 0x11 /* DW_TAG_compile_unit */ ++ .byte 0x1 /* has_children */ ++ .uleb128 0x25 /* DW_AT_producer */ ++ .uleb128 0x8 /* DW_FORM_string */ ++ .uleb128 0x13 /* DW_AT_language */ ++ .uleb128 0xb /* DW_FORM_data1 */ ++ .byte 0x0 /* Terminator */ ++ .byte 0x0 /* Terminator */ + -+ You should have received a copy of the GNU General Public License -+ along with this program. If not, see . */ ++ .uleb128 2 /* Abbrev code */ ++ .uleb128 0x1 /* TAG: DW_TAG_array_type */ ++ .byte 0x1 /* DW_children_yes */ ++ .uleb128 0x49 /* DW_AT_type */ ++ .uleb128 0x13 /* DW_FORM_ref4 */ ++ .byte 0x0 /* Terminator */ ++ .byte 0x0 /* Terminator */ + -+extern int func (int *arr); ++ .uleb128 4 /* Abbrev code */ ++ .uleb128 0x24 /* DW_TAG_base_type */ ++ .byte 0x0 /* no_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 */ + -+int -+main (void) -+{ -+ int arr[] = { 42 }; ++ .uleb128 6 /* Abbrev code */ ++ .uleb128 0x34 /* DW_TAG_variable */ ++ .byte 0x0 /* no_children */ ++ .uleb128 0x3 /* DW_AT_name */ ++ .uleb128 0x8 /* DW_FORM_string */ ++ .uleb128 0x49 /* DW_AT_type */ ++ .uleb128 0x13 /* DW_FORM_ref4 */ ++ .uleb128 0x2 /* DW_AT_location */ ++ .uleb128 0xa /* DW_FORM_block1 */ ++ .byte 0x0 /* Terminator */ ++ .byte 0x0 /* Terminator */ + -+ func (arr); ++ .uleb128 8 /* Abbrev code */ ++ .uleb128 0x21 /* DW_TAG_subrange_type without DW_AT_type */ ++ .byte 0x0 /* no children */ ++ .uleb128 0x22 /* DW_AT_lower_bound */ ++ .uleb128 0xb /* DW_FORM_data1 */ ++ .uleb128 0x2f /* DW_AT_upper_bound */ ++ .uleb128 0xb /* DW_FORM_data1 */ ++ .byte 0x0 /* Terminator */ ++ .byte 0x0 /* Terminator */ + -+ return 0; -+} -diff --git a/gdb/testsuite/gdb.opt/array-from-register.exp b/gdb/testsuite/gdb.opt/array-from-register.exp ++ .byte 0x0 /* Terminator */ +diff --git a/gdb/testsuite/gdb.dwarf2/dw2-subrange-no-type.exp b/gdb/testsuite/gdb.dwarf2/dw2-subrange-no-type.exp new file mode 100644 -index 0000000..f2de718 +index 0000000..a13e346 --- /dev/null -+++ b/gdb/testsuite/gdb.opt/array-from-register.exp -@@ -0,0 +1,33 @@ -+# Copyright 2009 Free Software Foundation, Inc. -+# ++++ b/gdb/testsuite/gdb.dwarf2/dw2-subrange-no-type.exp +@@ -0,0 +1,39 @@ ++# Copyright 2012 Free Software Foundation, Inc. ++ +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by -+# the Free Software Foundation; either version 2 of the License, or ++# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, @@ -14111,681 +7486,739 @@ index 0000000..f2de718 +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License -+# along with this program; if not, write to the Free Software -+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -+# -+# This file is part of the gdb testsuite. ++# along with this program. If not, see . ++load_lib dwarf.exp + -+if { [prepare_for_testing array-from-register.exp "array-from-register" \ -+ {array-from-register.c array-from-register-func.c} \ -+ {debug optimize=-O2}] } { -+ return -1 ++# https://bugzilla.redhat.com/show_bug.cgi?id=806920 ++# read_subrange_type reinitialization ++# of BASE_TYPE was done too late, it affects DW_TAG_subrange_type without ++# specified DW_AT_type, present only in XLF produced code. ++ ++# This test can only be run on targets which support DWARF-2 and use gas. ++if {![dwarf2_support]} { ++ return 0 +} + -+if ![runto func] then { ++set testfile dw2-subrange-no-type ++set srcfile ${testfile}.S ++set executable ${testfile}.x ++set binfile ${objdir}/${subdir}/${executable} ++ ++if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" object {}] != "" } { + return -1 +} + -+gdb_test "p arr" "\\$\[0-9\]+ = \\(int \\*\\) *0x\[0-9a-f\]+" ++clean_restart $executable + -+# 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.pascal/arrays.exp b/gdb/testsuite/gdb.pascal/arrays.exp ++gdb_test "ptype notype_string" {type = char \[129\]} ++gdb_test "p notype_string" " = 'x' " +diff --git a/gdb/testsuite/gdb.fortran/dwarf-stride.exp b/gdb/testsuite/gdb.fortran/dwarf-stride.exp new file mode 100644 -index 0000000..ccc6e1e +index 0000000..d7b8bea --- /dev/null -+++ b/gdb/testsuite/gdb.pascal/arrays.exp -@@ -0,0 +1,104 @@ -+# Copyright 2008, 2009 Free Software Foundation, Inc. -+# ++++ b/gdb/testsuite/gdb.fortran/dwarf-stride.exp +@@ -0,0 +1,42 @@ ++# Copyright 2009 Free Software Foundation, Inc. ++ +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by -+# the Free Software Foundation; either version 3 of the License, or ++# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. -+# ++# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. -+# ++# +# You should have received a copy of the GNU General Public License -+# along with this program. If not, see . -+ -+if $tracelevel then { -+ strace $tracelevel -+} -+ -+load_lib "pascal.exp" -+ -+set testfile "arrays" -+set srcfile ${testfile}.pas -+set binfile ${objdir}/${subdir}/${testfile}$EXEEXT -+ -+# These tests only work with fpc, using the -gw3 compile-option -+pascal_init -+if { $pascal_compiler_is_fpc != 1 } { -+ return -1 -+} -+ -+# Detect if the fpc version is below 2.3.0 -+set fpc_generates_dwarf_for_dynamic_arrays 1 -+if { ($fpcversion_major < 2) || ( ($fpcversion_major == 2) && ($fpcversion_minor < 3))} { -+ set fpc_generates_dwarf_for_dynamic_arrays 0 -+} -+ -+ -+if {[gdb_compile_pascal "-gw3 ${srcdir}/${subdir}/${srcfile}" "${binfile}" executable [list debug ]] != "" } { -+ return -1 -+} -+ -+gdb_exit -+gdb_start -+gdb_reinitialize_dir $srcdir/$subdir -+gdb_load ${binfile} -+set bp_location1 [gdb_get_line_number "set breakpoint 1 here"] -+set bp_location2 [gdb_get_line_number "set breakpoint 2 here"] -+ -+ -+if { [gdb_breakpoint ${srcfile}:${bp_location1}] } { -+ pass "setting breakpoint 1" -+} -+if { [gdb_breakpoint ${srcfile}:${bp_location2}] } { -+ pass "setting breakpoint 2" -+} -+ -+# Verify that "start" lands inside the right procedure. -+if { [gdb_start_cmd] < 0 } { -+ untested start -+ return -1 -+} -+ -+gdb_test "" ".* at .*${srcfile}.*" "start" -+ -+gdb_test "cont" "Breakpoint .*:${bp_location1}.*" "Going to first breakpoint" -+ -+gdb_test "print StatArrInt" ".* = \\{50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61\\}" "Print static array of integer type" -+gdb_test "print StatArrInt_" ".* = \\{50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61\\}" "Print static array of integer" -+ -+gdb_test "cont" "Breakpoint .*:${bp_location2}.*" "Going to second breakpoint" -+ -+gdb_test "print StatArrChar" ".* = 'abcdefghijkl'" "Print static array of char" -+gdb_test "print Stat2dArrInt" ".* = \\{\\{0, 1, 2, 3, 4\\}, \\{1, 2, 3, 4, 5\\}, \\{2, 3, 4, 5, 6\\}, \\{3, 4, 5, 6, 7\\}, \\{4, 5, 6, 7, 8\\}, \\{5, 6, 7, 8, 9\\}, \\{6, 7, 8, 9, 10\\}, \\{7, 8, 9, 10, 11\\}, \\{8, 9, 10, 11, 12\\}, \\{9, 10, 11, 12, 13\\}, \\{10, 11, 12, 13, 14\\}, \\{11, 12, 13, 14, 15\\}\\}" "Print static 2-dimensional array of integer" -+ -+if { $fpc_generates_dwarf_for_dynamic_arrays == 0} { -+ setup_xfail "*-*-*" -+} -+gdb_test "print DynArrInt" ".* = \\{50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62\\}" "Print dynamic array of integer type" -+if { $fpc_generates_dwarf_for_dynamic_arrays == 0} { -+ setup_xfail "*-*-*" -+} -+gdb_test "print DynArrInt_" ".* = \\{50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62\\}" "Print dynamic array of integer" -+ -+if { $fpc_generates_dwarf_for_dynamic_arrays == 0} { -+ setup_xfail "*-*-*" -+} -+gdb_test "print s" ".* = 'test'#0'string'" "Print string containing null-char" -+ -+if { $fpc_generates_dwarf_for_dynamic_arrays == 0} { -+ setup_xfail "*-*-*" -+} -+gdb_test "print DynArrStr" ".* = \\{'dstr0', 'dstr1', 'dstr2', 'dstr3', 'dstr4', 'dstr5', 'dstr6', 'dstr7', 'dstr8', 'dstr9', 'dstr10', 'dstr11', 'dstr12'\\}" "Print dynamic array of string" -+ -+if { $fpc_generates_dwarf_for_dynamic_arrays == 0} { -+ setup_xfail "*-*-*" -+} -+gdb_test "print StatArrStr" ".* = \\{'str0', 'str1', 'str2', 'str3', 'str4', 'str5', 'str6', 'str7', 'str8', 'str9', 'str10', 'str11', 'str12'\\}" "Print static array of string" -+ -+if { $fpc_generates_dwarf_for_dynamic_arrays == 0} { -+ setup_xfail "*-*-*" -+} -+gdb_test "print DynArrChar" ".* = 'abcdefghijklm'" "Print dynamic array of char" -+ -diff --git a/gdb/testsuite/gdb.pascal/arrays.pas b/gdb/testsuite/gdb.pascal/arrays.pas -new file mode 100644 -index 0000000..295602d ---- /dev/null -+++ b/gdb/testsuite/gdb.pascal/arrays.pas -@@ -0,0 +1,82 @@ -+{ -+ Copyright 2008, 2009 Free Software Foundation, Inc. -+ -+ This program is free software; you can redistribute it and/or modify -+ it under the terms of the GNU General Public License as published by -+ the Free Software Foundation; either version 3 of the License, or -+ (at your option) any later version. -+ -+ This program is distributed in the hope that it will be useful, -+ but WITHOUT ANY WARRANTY; without even the implied warranty of -+ MERCHANTABILITY or FITNESS FOR A PARTICULAR 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 . -+} -+ -+program arrays; -+ -+{$mode objfpc}{$h+} -+ -+uses sysutils; -+ -+type TStatArrInt= array[0..11] of integer; -+ TDynArrInt= array of integer; -+ TStatArrStr= array[0..12] of string; -+ TDynArrStr= array of string; -+ TDynArrChar = array of char; -+ TStatArrChar = array [0..11] of char; -+ -+ TStat2dArrInt = array[0..11,0..4] of integer; -+ -+var StatArrInt: TStatArrInt; -+ StatArrInt_: Array[0..11] of integer; -+ DynArrInt: TDynArrInt; -+ DynArrInt_: Array of integer; -+ StatArrStr: TStatArrStr; -+ DynArrStr: TDynArrStr; -+ StatArrChar: TStatArrChar; -+ DynArrChar: TDynArrChar; -+ -+ Stat2dArrInt: TStat2dArrInt; -+ -+ s: string; -+ -+ i,j : integer; -+ -+begin -+ for i := 0 to 11 do -+ begin -+ StatArrInt[i]:= i+50; -+ StatArrInt_[i]:= i+50; -+ StatArrChar[i]:= chr(ord('a')+i); -+ for j := 0 to 4 do -+ Stat2dArrInt[i,j]:=i+j; -+ end; -+ writeln(StatArrInt_[0]); -+ writeln(StatArrInt[0]); { set breakpoint 1 here } -+ writeln(StatArrChar[0]); -+ writeln(Stat2dArrInt[0,0]); ++# along with this program; if not, write to the Free Software ++# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + -+ setlength(DynArrInt,13); -+ setlength(DynArrInt_,13); -+ setlength(DynArrStr,13); -+ setlength(DynArrChar,13); -+ for i := 0 to 12 do -+ begin -+ DynArrInt[i]:= i+50; -+ DynArrInt_[i]:= i+50; -+ DynArrChar[i]:= chr(ord('a')+i); -+ StatArrStr[i]:='str'+inttostr(i); -+ DynArrStr[i]:='dstr'+inttostr(i); -+ end; -+ writeln(DynArrInt_[1]); -+ writeln(DynArrInt[1]); -+ writeln(DynArrStr[1]); -+ writeln(StatArrStr[1]); -+ writeln(DynArrChar[1]); ++# This file was written by Jan Kratochvil . + -+ s := 'test'#0'string'; -+ writeln(s); { set breakpoint 2 here } -+end. -diff --git a/gdb/testsuite/gdb.python/py-frame.exp b/gdb/testsuite/gdb.python/py-frame.exp -index 83ff8fe..bddbf9f 100644 ---- a/gdb/testsuite/gdb.python/py-frame.exp -+++ b/gdb/testsuite/gdb.python/py-frame.exp -@@ -74,8 +74,6 @@ gdb_test "python print bframe == gdb.newest_frame()" True \ - - gdb_test "python print 'result =', f0 == f1" " = False" "test equality comparison (false)" - gdb_test "python print 'result =', f0 == f0" " = True" "test equality comparison (true)" --gdb_test "python print 'result =', f0 != f1" " = True" "test inequality comparison (true)" --gdb_test "python print 'result =', f0 != f0" " = False" "test inequality comparison (false)" - gdb_test "python print 'result =', f0.is_valid ()" " = True" "test Frame.is_valid" - gdb_test "python print 'result =', f0.name ()" " = f2" "test Frame.name" - gdb_test "python print 'result =', f0.type () == gdb.NORMAL_FRAME" " = True" "test Frame.type" -@@ -90,3 +88,5 @@ gdb_test "python print 'result =', f0.read_var ('variable_which_surely_doesnt_ex - gdb_test "python print 'result =', f0.read_var ('a')" " = 1" "test Frame.read_var - success" - - gdb_test "python print 'result =', gdb.selected_frame () == f1" " = True" "test gdb.selected_frame" ++# This file is part of the gdb testsuite. Array element stride must not be ++# specified in the number of elements but in a number of bytes instead. ++# Original problem: ++# (gdb) p c40pt(1) ++# $1 = '0-hello', ' ' ++# (gdb) p c40pt(2) ++# warning: Fortran array stride not divisible by the element size + -+gdb_test "python print 'result =', f0.block ()" "" "test Frame.block" -diff --git a/gdb/testsuite/gdb.python/py-value.exp b/gdb/testsuite/gdb.python/py-value.exp -index c9d8c97..4324db0 100644 ---- a/gdb/testsuite/gdb.python/py-value.exp -+++ b/gdb/testsuite/gdb.python/py-value.exp -@@ -360,6 +360,15 @@ proc test_value_after_death {} { - "print value's type" - } - -+# Regression test for a cast failure. The bug was that if we cast a -+# value to its own type, gdb could crash. This happened because we -+# could end up double-freeing a struct value. -+proc test_cast_regression {} { -+ gdb_test "python v = gdb.Value(5)" "" "create value for cast test" -+ gdb_test "python v = v.cast(v.type)" "" "cast value for cast test" -+ gdb_test "python print v" "5" "print value for cast test" ++set testfile dwarf-stride ++set srcfile ${testfile}.f90 ++ ++if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} {debug f90}] } { ++ return -1 +} + - # 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. -@@ -496,6 +505,7 @@ test_value_in_inferior - test_inferior_function_call - test_lazy_strings - test_value_after_death -+test_cast_regression - - # Test either C or C++ values. - test_subscript_regression "${binfile}" "c" -diff --git a/gdb/testsuite/gdb.threads/watchpoint-fork-child.c b/gdb/testsuite/gdb.threads/watchpoint-fork-child.c ++if ![runto MAIN__] then { ++ perror "couldn't run to breakpoint MAIN__" ++ continue ++} ++ ++gdb_breakpoint [gdb_get_line_number "break-here"] ++gdb_continue_to_breakpoint "break-here" ".*break-here.*" ++gdb_test "p c40pt(1)" " = '0-hello.*" ++gdb_test "p c40pt(2)" " = '1-hello.*" +diff --git a/gdb/testsuite/gdb.fortran/dwarf-stride.f90 b/gdb/testsuite/gdb.fortran/dwarf-stride.f90 new file mode 100644 -index 0000000..7a7e07f +index 0000000..e492b3a --- /dev/null -+++ b/gdb/testsuite/gdb.threads/watchpoint-fork-child.c -@@ -0,0 +1,129 @@ -+/* Test case for forgotten hw-watchpoints after fork()-off of a process. ++++ b/gdb/testsuite/gdb.fortran/dwarf-stride.f90 +@@ -0,0 +1,40 @@ ++! Copyright 2009 Free Software Foundation, Inc. ++! ++! This program is free software; you can redistribute it and/or modify ++! it under the terms of the GNU General Public License as published by ++! the Free Software Foundation; either version 2 of the License, or ++! (at your option) any later version. ++! ++! This program is distributed in the hope that it will be useful, ++! but WITHOUT ANY WARRANTY; without even the implied warranty of ++! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++! GNU General Public License for more details. ++! ++! You should have received a copy of the GNU General Public License ++! along with this program; if not, write to the Free Software ++! Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ++! ++! File written by Alan Matsuoka. + -+ Copyright 2012 Free Software Foundation, Inc. ++program repro + -+ This file is part of GDB. ++ type small_stride ++ character*40 long_string ++ integer small_pad ++ end type small_stride + -+ This program is free software; you can 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. ++ type(small_stride), dimension (20), target :: unpleasant ++ character*40, pointer, dimension(:):: c40pt + -+ This program is distributed in the hope that it will be useful, -+ but WITHOUT ANY WARRANTY; without even the implied warranty of -+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+ GNU General Public License for more details. ++ integer i + -+ 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. */ ++ do i = 0,19 ++ unpleasant(i+1)%small_pad = i+1 ++ unpleasant(i+1)%long_string = char (ichar('0') + i) // '-hello' ++ end do + -+#include -+#include -+#include -+#include -+#include -+#include ++ c40pt => unpleasant%long_string ++ ++ print *, c40pt ! break-here + -+#include "watchpoint-fork.h" ++end program repro +diff --git a/gdb/testsuite/gdb.fortran/dynamic-other-frame-stub.f90 b/gdb/testsuite/gdb.fortran/dynamic-other-frame-stub.f90 +new file mode 100644 +index 0000000..261ce17 +--- /dev/null ++++ b/gdb/testsuite/gdb.fortran/dynamic-other-frame-stub.f90 +@@ -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 . ++! Modified for the GDB testcase by Jan Kratochvil . + -+/* `pid_t' may not be available. */ ++subroutine bar ++ real :: dummy ++ dummy = 1 ++end subroutine bar +diff --git a/gdb/testsuite/gdb.fortran/dynamic-other-frame.exp b/gdb/testsuite/gdb.fortran/dynamic-other-frame.exp +new file mode 100644 +index 0000000..fa41b80 +--- /dev/null ++++ b/gdb/testsuite/gdb.fortran/dynamic-other-frame.exp +@@ -0,0 +1,37 @@ ++# Copyright 2010 Free Software Foundation, Inc. + -+static volatile int usr1_got; ++# This program is free software; you can 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. + -+static void -+handler_usr1 (int signo) -+{ -+ usr1_got++; ++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 {f90}] != "" ++ || [gdb_compile "${srcdir}/${subdir}/${srcfile1} ${objfile2}" "${binfile}" executable {debug f90}] != "" } { ++ untested "Couldn't compile ${srcfile1} or ${srcfile2}" ++ return -1 +} + -+void -+forkoff (int nr) -+{ -+ int child, save_parent = getpid (); -+ int i; -+ struct sigaction act, oldact; -+#ifdef THREAD -+ void *thread_result; -+#endif ++clean_restart ${executable} ++ ++if ![runto bar_] then { ++ perror "couldn't run to bar_" ++ continue ++} ++ ++gdb_test "bt" {foo \(string='hello'.*} +diff --git a/gdb/testsuite/gdb.fortran/dynamic-other-frame.f90 b/gdb/testsuite/gdb.fortran/dynamic-other-frame.f90 +new file mode 100644 +index 0000000..2bc637d +--- /dev/null ++++ b/gdb/testsuite/gdb.fortran/dynamic-other-frame.f90 +@@ -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 . ++! Modified for the GDB testcase by Jan Kratochvil . ++ ++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 +diff --git a/gdb/testsuite/gdb.fortran/dynamic.exp b/gdb/testsuite/gdb.fortran/dynamic.exp +new file mode 100644 +index 0000000..e79e94a +--- /dev/null ++++ b/gdb/testsuite/gdb.fortran/dynamic.exp +@@ -0,0 +1,152 @@ ++# Copyright 2007 Free Software Foundation, Inc. + -+ memset (&act, 0, sizeof act); -+ act.sa_flags = SA_RESTART; -+ act.sa_handler = handler_usr1; -+ sigemptyset (&act.sa_mask); -+ i = sigaction (SIGUSR1, &act, &oldact); -+ assert (i == 0); ++# This program is free software; you can 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. + -+ child = fork (); -+ switch (child) -+ { -+ case -1: -+ assert (0); -+ default: -+ printf ("parent%d: %d\n", nr, (int) child); ++# This file was written by Jan Kratochvil . + -+ /* Sleep for a while to possibly get incorrectly ATTACH_THREADed by GDB -+ tracing the child fork with no longer valid thread/lwp entries of the -+ parent. */ ++# This file is part of the gdb testsuite. It contains tests for dynamically ++# allocated Fortran arrays. ++# It depends on the GCC dynamic Fortran arrays DWARF support: ++# http://gcc.gnu.org/bugzilla/show_bug.cgi?id=22244 + -+ i = sleep (2); -+ assert (i == 0); ++set testfile "dynamic" ++set srcfile ${testfile}.f90 ++set binfile ${objdir}/${subdir}/${testfile} + -+ /* We must not get caught here (against a forgotten breakpoint). */ ++if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug f90 quiet}] != "" } { ++ untested "Couldn't compile ${srcfile}" ++ return -1 ++} + -+ var++; -+ marker (); ++gdb_exit ++gdb_start ++gdb_reinitialize_dir $srcdir/$subdir ++gdb_load ${binfile} + -+#ifdef THREAD -+ /* And neither got caught our thread. */ ++if ![runto MAIN__] then { ++ perror "couldn't run to breakpoint MAIN__" ++ continue ++} + -+ step = 99; -+ i = pthread_join (thread, &thread_result); -+ assert (i == 0); -+ assert (thread_result == (void *) 99UL); -+#endif ++gdb_breakpoint [gdb_get_line_number "varx-init"] ++gdb_continue_to_breakpoint "varx-init" ++gdb_test "p varx" "\\$\[0-9\]* = <(object|the array) is not allocated>" "p varx unallocated" ++gdb_test "ptype varx" "type = <(object|the array) is not allocated>" "ptype varx unallocated" ++gdb_test "p varx(1,5,17)" "(Cannot access it|Unable to access the object) because the (object|array) is not allocated\\." "p varx(1,5,17) unallocated" ++gdb_test "p varx(1,5,17)=1" "(Cannot access it|Unable to access the object) because the (object|array) is not allocated\\." "p varx(1,5,17)=1 unallocated" ++gdb_test "ptype varx(1,5,17)" "(Cannot access it|Unable to access the object) because the (object|array) is not allocated\\." "ptype varx(1,5,17) unallocated" + -+ /* Be sure our child knows we did not get caught above. */ ++gdb_breakpoint [gdb_get_line_number "varx-allocated"] ++gdb_continue_to_breakpoint "varx-allocated" ++# $1 = (( ( 0, 0, 0, 0, 0, 0) ( 0, 0, 0, 0, 0, 0) --- , 0) ) ( ( 0, 0, ...) ...) ...) ++gdb_test "ptype varx" "type = real(\\(kind=4\\)|\\*4) \\(6,5:15,17:28\\)" "ptype varx allocated" ++# Intel Fortran Compiler 10.1.008 uses -1 there, GCC uses 1. ++gdb_test "p l" "\\$\[0-9\]* = (\\.TRUE\\.|4294967295)" "p l if varx allocated" + -+ i = kill (child, SIGUSR1); -+ assert (i == 0); ++gdb_breakpoint [gdb_get_line_number "varx-filled"] ++gdb_continue_to_breakpoint "varx-filled" ++gdb_test "p varx(2, 5, 17)" "\\$\[0-9\]* = 6" ++gdb_test "p varx(1, 5, 17)" "\\$\[0-9\]* = 7" ++gdb_test "p varx(2, 6, 18)" "\\$\[0-9\]* = 8" ++gdb_test "p varx(6, 15, 28)" "\\$\[0-9\]* = 9" ++# The latter one is for the Intel Fortran Compiler 10.1.008 pointer type. ++gdb_test "p varv" "\\$\[0-9\]* = (<(object|the array) is not associated>|.*(Cannot access it|Unable to access the object) because the object is not associated.)" "p varv unassociated" ++gdb_test "ptype varv" "type = (<(object|the array) is not associated>|.*(Cannot access it|Unable to access the object) because the object is not associated.)" "ptype varv unassociated" + -+ /* Sleep for a while to check GDB's `info threads' no longer tracks us in -+ the child fork. */ ++set test "output varx" ++gdb_test_multiple $test $test { ++ -re "^output varx\r\n\[() ,6789.\]*$gdb_prompt $" { ++ pass $test ++ } ++} + -+ i = sleep (2); -+ assert (i == 0); ++gdb_breakpoint [gdb_get_line_number "varv-associated"] ++gdb_continue_to_breakpoint "varv-associated" ++gdb_test "p varx(3, 7, 19)" "\\$\[0-9\]* = 6" "p varx(3, 7, 19) with varv associated" ++gdb_test "p varv(3, 7, 19)" "\\$\[0-9\]* = 6" "p varv(3, 7, 19) associated" ++# Intel Fortran Compiler 10.1.008 uses -1 there, GCC uses 1. ++gdb_test "p l" "\\$\[0-9\]* = (\\.TRUE\\.|4294967295)" "p l if varv associated" ++gdb_test "ptype varx" "type = real(\\(kind=4\\)|\\*4) \\(6,5:15,17:28\\)" "ptype varx with varv associated" ++# Intel Fortran Compiler 10.1.008 uses the pointer type. ++gdb_test "ptype varv" "type = (PTR TO -> \\( )?real(\\(kind=4\\)|\\*4) \\(6,5:15,17:28\\)\\)?" "ptype varv associated" + -+ _exit (0); -+ case 0: -+ printf ("child%d: %d\n", nr, (int) getpid ()); ++gdb_breakpoint [gdb_get_line_number "varv-filled"] ++gdb_continue_to_breakpoint "varv-filled" ++gdb_test "p varx(3, 7, 19)" "\\$\[0-9\]* = 10" "p varx(3, 7, 19) with varv filled" ++gdb_test "p varv(3, 7, 19)" "\\$\[0-9\]* = 10" "p varv(3, 7, 19) filled" + -+ /* Let the parent signal us about its success. Be careful of races. */ ++gdb_breakpoint [gdb_get_line_number "varv-deassociated"] ++gdb_continue_to_breakpoint "varv-deassociated" ++# The latter one is for the Intel Fortran Compiler 10.1.008 pointer type. ++gdb_test "p varv" "\\$\[0-9\]* = (<(object|the array) is not associated>|.*(Cannot access it|Unable to access the object) because the object is not associated.)" "p varv deassociated" ++gdb_test "ptype varv" "type = (<(object|the array) is not associated>|.*(Cannot access it|Unable to access the object) because the object is not associated.)" "ptype varv deassociated" ++gdb_test "p l" "\\$\[0-9\]* = \\.FALSE\\." "p l if varv deassociated" ++gdb_test "p varv(1,5,17)" "(Cannot access it|Unable to access the object) because the (object|array) is not associated\\." ++gdb_test "ptype varv(1,5,17)" "(Cannot access it|Unable to access the object) because the (object|array) is not associated\\." + -+ 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; ++gdb_breakpoint [gdb_get_line_number "varx-deallocated"] ++gdb_continue_to_breakpoint "varx-deallocated" ++gdb_test "p varx" "\\$\[0-9\]* = <(object|the array) is not allocated>" "p varx deallocated" ++gdb_test "ptype varx" "type = <(object|the array) is not allocated>" "ptype varx deallocated" ++gdb_test "p l" "\\$\[0-9\]* = \\.FALSE\\." "p l if varx deallocated" ++gdb_test "p varx(1,5,17)" "(Cannot access it|Unable to access the object) because the (object|array) is not allocated\\." "p varx(1,5,17) deallocated" ++gdb_test "ptype varx(1,5,17)" "(Cannot access it|Unable to access the object) because the (object|array) is not allocated\\." "ptype varx(1,5,17) deallocated" + -+#ifdef THREAD -+ i = pthread_yield (); -+ assert (i == 0); -+#endif -+ } -+ assert (usr1_got); ++gdb_breakpoint [gdb_get_line_number "vary-passed"] ++gdb_continue_to_breakpoint "vary-passed" ++# $1 = (( ( 1, 1, 1, 1, 1, 1) ( 1, 1, 1, 1, 1, 1) --- , 1) ) ( ( 1, 1, ...) ...) ...) ++gdb_test "p vary" "\\$\[0-9\]* = \\(\[()1, .\]*\\)" + -+ /* We must get caught here (against a false watchpoint removal). */ ++gdb_breakpoint [gdb_get_line_number "vary-filled"] ++gdb_continue_to_breakpoint "vary-filled" ++gdb_test "ptype vary" "type = real(\\(kind=4\\)|\\*4) \\(10,10\\)" ++gdb_test "p vary(1, 1)" "\\$\[0-9\]* = 8" ++gdb_test "p vary(2, 2)" "\\$\[0-9\]* = 9" ++gdb_test "p vary(1, 3)" "\\$\[0-9\]* = 10" ++# $1 = (( ( 3, 3, 3, 3, 3, 3) ( 3, 3, 3, 3, 3, 3) --- , 3) ) ( ( 3, 3, ...) ...) ...) ++gdb_test "p varw" "\\$\[0-9\]* = \\(\[()3, .\]*\\)" + -+ marker (); -+ } ++gdb_breakpoint [gdb_get_line_number "varw-almostfilled"] ++gdb_continue_to_breakpoint "varw-almostfilled" ++gdb_test "ptype varw" "type = real(\\(kind=4\\)|\\*4) \\(5,4,3\\)" ++gdb_test "p varw(3,1,1)=1" "\\$\[0-9\]* = 1" ++# $1 = (( ( 6, 5, 1, 5, 5, 5) ( 5, 5, 5, 5, 5, 5) --- , 5) ) ( ( 5, 5, ...) ...) ...) ++gdb_test "p varw" "\\$\[0-9\]* = \\( *\\( *\\( *6, *5, *1,\[()5, .\]*\\)" "p varw filled" ++# "up" works with GCC but other Fortran compilers may copy the values into the ++# outer function only on the exit of the inner function. ++# We need both variants as depending on the arch we optionally may still be ++# executing the caller line or not after `finish'. ++gdb_test "finish" ".*(call bar \\(y, x\\)|call foo \\(x, z\\(2:6, 4:7, 6:8\\)\\))" ++gdb_test "p z(2,4,5)" "\\$\[0-9\]* = 3" ++gdb_test "p z(2,4,6)" "\\$\[0-9\]* = 6" ++gdb_test "p z(2,4,7)" "\\$\[0-9\]* = 5" ++gdb_test "p z(4,4,6)" "\\$\[0-9\]* = 1" + -+ i = sigaction (SIGUSR1, &oldact, NULL); -+ assert (i == 0); -+} -diff --git a/gdb/testsuite/gdb.threads/watchpoint-fork-mt.c b/gdb/testsuite/gdb.threads/watchpoint-fork-mt.c ++gdb_breakpoint [gdb_get_line_number "varz-almostfilled"] ++gdb_continue_to_breakpoint "varz-almostfilled" ++# GCC uses the pointer type here, Intel Fortran Compiler 10.1.008 does not. ++gdb_test "ptype varz" "type = (PTR TO -> \\( )?real(\\(kind=4\\)|\\*4) \\(\\*\\)\\)?" ++# Intel Fortran Compiler 10.1.008 has a bug here - (2:11,7:7) ++# as it produces DW_AT_lower_bound == DW_AT_upper_bound == 7. ++gdb_test "ptype vart" "type = (PTR TO -> \\( )?real(\\(kind=4\\)|\\*4) \\(2:11,7:\\*\\)\\)?" ++gdb_test "p varz" "\\$\[0-9\]* = \\(\\)" ++gdb_test "p vart" "\\$\[0-9\]* = \\(\\)" ++gdb_test "p varz(3)" "\\$\[0-9\]* = 4" ++# maps to foo::vary(1,1) ++gdb_test "p vart(2,7)" "\\$\[0-9\]* = 8" ++# maps to foo::vary(2,2) ++gdb_test "p vart(3,8)" "\\$\[0-9\]* = 9" ++# maps to foo::vary(1,3) ++gdb_test "p vart(2,9)" "\\$\[0-9\]* = 10" +diff --git a/gdb/testsuite/gdb.fortran/dynamic.f90 b/gdb/testsuite/gdb.fortran/dynamic.f90 new file mode 100644 -index 0000000..bfdd89f +index 0000000..0f43564 --- /dev/null -+++ b/gdb/testsuite/gdb.threads/watchpoint-fork-mt.c -@@ -0,0 +1,174 @@ -+/* Test case for forgotten hw-watchpoints after fork()-off of a process. -+ -+ Copyright 2012 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. */ ++++ b/gdb/testsuite/gdb.fortran/dynamic.f90 +@@ -0,0 +1,98 @@ ++! Copyright 2007 Free Software Foundation, Inc. ++! ++! This program is free software; you can redistribute it and/or modify ++! it under the terms of the GNU General Public License as published by ++! the Free Software Foundation; either version 2 of the License, or ++! (at your option) any later version. ++! ++! This program is distributed in the hope that it will be useful, ++! but WITHOUT ANY WARRANTY; without even the implied warranty of ++! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++! GNU General Public License for more details. ++! ++! You should have received a copy of the GNU General Public License ++! along with this program; if not, write to the Free Software ++! Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ++! ++! Ihis file is the Fortran source file for dynamic.exp. ++! Original file written by Jakub Jelinek . ++! Modified for the GDB testcase by Jan Kratochvil . + -+#include -+#include -+#include -+#include -+#include -+#include ++subroutine baz ++ real, target, allocatable :: varx (:, :, :) ++ real, pointer :: varv (:, :, :) ++ real, target :: varu (1, 2, 3) ++ logical :: l ++ allocate (varx (1:6, 5:15, 17:28)) ! varx-init ++ l = allocated (varx) ++ varx(:, :, :) = 6 ! varx-allocated ++ varx(1, 5, 17) = 7 ++ varx(2, 6, 18) = 8 ++ varx(6, 15, 28) = 9 ++ varv => varx ! varx-filled ++ l = associated (varv) ++ varv(3, 7, 19) = 10 ! varv-associated ++ varv => null () ! varv-filled ++ l = associated (varv) ++ deallocate (varx) ! varv-deassociated ++ l = allocated (varx) ++ varu(:, :, :) = 10 ! varx-deallocated ++ allocate (varv (1:6, 5:15, 17:28)) ++ l = associated (varv) ++ varv(:, :, :) = 6 ++ varv(1, 5, 17) = 7 ++ varv(2, 6, 18) = 8 ++ varv(6, 15, 28) = 9 ++ deallocate (varv) ++ l = associated (varv) ++ varv => varu ++ varv(1, 1, 1) = 6 ++ varv(1, 2, 3) = 7 ++ l = associated (varv) ++end subroutine baz ++subroutine foo (vary, varw) ++ real :: vary (:, :) ++ real :: varw (:, :, :) ++ vary(:, :) = 4 ! vary-passed ++ vary(1, 1) = 8 ++ vary(2, 2) = 9 ++ vary(1, 3) = 10 ++ varw(:, :, :) = 5 ! vary-filled ++ varw(1, 1, 1) = 6 ++ varw(2, 2, 2) = 7 ! varw-almostfilled ++end subroutine foo ++subroutine bar (varz, vart) ++ real :: varz (*) ++ real :: vart (2:11, 7:*) ++ varz(1:3) = 4 ++ varz(2) = 5 ! varz-almostfilled ++ vart(2,7) = vart(2,7) ++end subroutine bar ++program test ++ interface ++ subroutine foo (vary, varw) ++ real :: vary (:, :) ++ real :: varw (:, :, :) ++ end subroutine ++ end interface ++ interface ++ subroutine bar (varz, vart) ++ real :: varz (*) ++ real :: vart (2:11, 7:*) ++ end subroutine ++ end interface ++ real :: x (10, 10), y (5), z(8, 8, 8) ++ x(:,:) = 1 ++ y(:) = 2 ++ z(:,:,:) = 3 ++ call baz ++ call foo (x, z(2:6, 4:7, 6:8)) ++ call bar (y, x) ++ if (x (1, 1) .ne. 8 .or. x (2, 2) .ne. 9 .or. x (1, 2) .ne. 4) call abort ++ if (x (1, 3) .ne. 10) call abort ++ if (z (2, 4, 6) .ne. 6 .or. z (3, 5, 7) .ne. 7 .or. z (2, 4, 7) .ne. 5) call abort ++ if (any (y .ne. (/4, 5, 4, 2, 2/))) call abort ++ call foo (transpose (x), z) ++ if (x (1, 1) .ne. 8 .or. x (2, 2) .ne. 9 .or. x (1, 2) .ne. 4) call abort ++ if (x (3, 1) .ne. 10) call abort ++end +diff --git a/gdb/testsuite/gdb.fortran/string.exp b/gdb/testsuite/gdb.fortran/string.exp +new file mode 100644 +index 0000000..39de2c4 +--- /dev/null ++++ b/gdb/testsuite/gdb.fortran/string.exp +@@ -0,0 +1,59 @@ ++# Copyright 2008 Free Software Foundation, Inc. + -+#include -+#include -+#define gettid() syscall (__NR_gettid) ++# This program is free software; you can 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 "watchpoint-fork.h" ++# This file was written by Jan Kratochvil . + -+/* Non-atomic `var++' should not hurt as we synchronize the threads by the STEP -+ variable. Hit-comments need to be duplicite there to catch both at-stops -+ and behind-stops, depending on the target. */ ++# This file is part of the gdb testsuite. It contains tests for Fortran ++# strings with dynamic length. + -+volatile int var; ++set testfile "string" ++set srcfile ${testfile}.f90 ++set binfile ${objdir}/${subdir}/${testfile} + -+void -+marker (void) -+{ ++if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug f90 quiet}] != "" } { ++ untested "Couldn't compile ${srcfile}" ++ return -1 +} + -+static void -+empty (void) -+{ -+} ++gdb_exit ++gdb_start ++gdb_reinitialize_dir $srcdir/$subdir ++gdb_load ${binfile} + -+static void -+mark_exit (void) -+{ ++if ![runto MAIN__] then { ++ perror "couldn't run to breakpoint MAIN__" ++ continue +} + -+pthread_t thread; -+volatile int step; -+ -+static void * -+start (void *arg) -+{ -+ int i; -+ -+ if (step >= 3) -+ goto step_3; -+ -+ while (step != 1) -+ { -+ i = pthread_yield (); -+ assert (i == 0); -+ } -+ -+ var++; /* validity-thread-B */ -+ empty (); /* validity-thread-B */ -+ step = 2; -+ while (step != 3) -+ { -+ if (step == 99) -+ goto step_99; -+ -+ i = pthread_yield (); -+ assert (i == 0); -+ } ++gdb_breakpoint [gdb_get_line_number "var-init"] ++gdb_continue_to_breakpoint "var-init" ++gdb_test "ptype c" "type = character(\\(kind=1\\)|\\*1)" ++gdb_test "ptype d" "type = character(\\(kind=8\\)|\\*8)" ++gdb_test "ptype e" "type = character(\\(kind=4\\)|\\*4)" ++gdb_test "ptype f" "type = character(\\(kind=4\\)|\\*4) \\(7,8:10\\)" ++gdb_test "ptype *e" "Attempt to take contents of a non-pointer value." ++gdb_test "ptype *f" "type = character(\\(kind=4\\)|\\*4) \\(7\\)" ++gdb_test "p c" "\\$\[0-9\]* = 'c'" ++gdb_test "p d" "\\$\[0-9\]* = 'd '" ++gdb_test "p e" "\\$\[0-9\]* = 'g '" ++gdb_test "p f" "\\$\[0-9\]* = \\(\\( 'h ', 'h ', 'h ', 'h ', 'h ', 'h ', 'h '\\) \\( 'h ', 'h ', 'h ', 'h ', 'h ', 'h ', 'h '\\) \\( 'h ', 'h ', 'h ', 'h ', 'h ', 'h ', 'h '\\) \\)" ++gdb_test "p *e" "Attempt to take contents of a non-pointer value." ++gdb_test "p *f" "Attempt to take contents of a non-pointer value." + -+step_3: -+ if (step >= 5) -+ goto step_5; ++gdb_breakpoint [gdb_get_line_number "var-finish"] ++gdb_continue_to_breakpoint "var-finish" ++gdb_test "p e" "\\$\[0-9\]* = 'e '" "p e re-set" ++gdb_test "p f" "\\$\[0-9\]* = \\(\\( 'f ', 'f ', 'f ', 'f ', 'f ', 'f ', 'f '\\) \\( 'f2 ', 'f ', 'f ', 'f ', 'f ', 'f ', 'f '\\) \\( 'f ', 'f ', 'f ', 'f ', 'f ', 'f ', 'f '\\) \\)" "p *f re-set" +diff --git a/gdb/testsuite/gdb.fortran/string.f90 b/gdb/testsuite/gdb.fortran/string.f90 +new file mode 100644 +index 0000000..226dc5d +--- /dev/null ++++ b/gdb/testsuite/gdb.fortran/string.f90 +@@ -0,0 +1,37 @@ ++! Copyright 2008 Free Software Foundation, Inc. ++! ++! This program is free software; you can redistribute it and/or modify ++! it under the terms of the GNU General Public License as published by ++! the Free Software Foundation; either version 2 of the License, or ++! (at your option) any later version. ++! ++! This program is distributed in the hope that it will be useful, ++! but WITHOUT ANY WARRANTY; without even the implied warranty of ++! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++! GNU General Public License for more details. ++! ++! You should have received a copy of the GNU General Public License ++! along with this program; if not, write to the Free Software ++! Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ++! ++! Ihis file is the Fortran source file for dynamic.exp. ++! Original file written by Jakub Jelinek . ++! Modified for the GDB testcase by Jan Kratochvil . + -+ var++; /* after-fork1-B */ -+ empty (); /* after-fork1-B */ -+ step = 4; -+ while (step != 5) -+ { -+ if (step == 99) -+ goto step_99; ++subroutine foo (e, f) ++ character (len=1) :: c ++ character (len=8) :: d ++ character (len=*) :: e ++ character (len=*) :: f (1:7, 8:10) ++ c = 'c' ++ d = 'd' ++ e = 'e' ! var-init ++ f = 'f' ++ f(1,9) = 'f2' ++ c = 'c' ! var-finish ++end subroutine foo ++ character (len=4) :: g, h (1:7, 8:10) ++ g = 'g' ++ h = 'h' ++ call foo (g, h) ++end +diff --git a/gdb/testsuite/gdb.fortran/subrange.exp b/gdb/testsuite/gdb.fortran/subrange.exp +new file mode 100644 +index 0000000..c819e23 +--- /dev/null ++++ b/gdb/testsuite/gdb.fortran/subrange.exp +@@ -0,0 +1,60 @@ ++# Copyright 2011 Free Software Foundation, Inc. + -+ i = pthread_yield (); -+ assert (i == 0); -+ } ++# This program is free software; you can redistribute it and/or modify ++# it under the terms of the GNU General Public License as published by ++# the Free Software Foundation; either version 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 . + -+step_5: -+ var++; /* after-fork2-B */ -+ empty (); /* after-fork2-B */ -+ return (void *) 5UL; ++if { [skip_fortran_tests] } { return -1 } + -+step_99: -+ /* We must not get caught here (against a forgotten breakpoint). */ -+ var++; -+ marker (); -+ return (void *) 99UL; ++set testfile "subrange" ++set srcfile ${testfile}.f90 ++if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} {debug f90}] } { ++ return -1 +} + -+int -+main (void) -+{ -+ int i; -+ void *thread_result; -+ -+ setbuf (stdout, NULL); -+ printf ("main: %d\n", (int) gettid ()); -+ -+ /* General hardware breakpoints and watchpoints validity. */ -+ marker (); -+ var++; /* validity-first */ -+ empty (); /* validity-first */ -+ -+ i = pthread_create (&thread, NULL, start, NULL); -+ assert (i == 0); -+ -+ var++; /* validity-thread-A */ -+ empty (); /* validity-thread-A */ -+ step = 1; -+ while (step != 2) -+ { -+ i = pthread_yield (); -+ assert (i == 0); -+ } -+ -+ /* Hardware watchpoints got disarmed here. */ -+ forkoff (1); ++if ![runto MAIN__] { ++ perror "Couldn't run to MAIN__" ++ continue ++} + -+ var++; /* after-fork1-A */ -+ empty (); /* after-fork1-A */ -+ step = 3; -+#ifdef FOLLOW_CHILD -+ /* Spawn new thread as it was deleted in the child of FORK. */ -+ i = pthread_create (&thread, NULL, start, NULL); -+ assert (i == 0); -+#endif -+ while (step != 4) -+ { -+ i = pthread_yield (); -+ assert (i == 0); -+ } ++# 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\\))" + -+ /* A sanity check for double hardware watchpoints removal. */ -+ forkoff (2); ++gdb_breakpoint [gdb_get_line_number "break-static"] ++gdb_continue_to_breakpoint "break-static" ".*break-static.*" + -+ var++; /* after-fork2-A */ -+ empty (); /* after-fork2-A */ -+ step = 5; -+#ifdef FOLLOW_CHILD -+ /* Spawn new thread as it was deleted in the child of FORK. */ -+ i = pthread_create (&thread, NULL, start, NULL); -+ assert (i == 0); -+#endif ++foreach var {a alloc ptr} { ++ global pf_prefix ++ set old_prefix $pf_prefix ++ lappend pf_prefix "$var:" + -+ i = pthread_join (thread, &thread_result); -+ assert (i == 0); -+ assert (thread_result == (void *) 5UL); ++ 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" + -+ mark_exit (); -+ return 0; ++ set pf_prefix $old_prefix +} -diff --git a/gdb/testsuite/gdb.threads/watchpoint-fork-parent.c b/gdb/testsuite/gdb.threads/watchpoint-fork-parent.c ++ ++gdb_test_no_output {set $a=a} ++delete_breakpoints ++gdb_unload ++gdb_test {p $a (3, 2:2)} { = \(23\)} +diff --git a/gdb/testsuite/gdb.fortran/subrange.f90 b/gdb/testsuite/gdb.fortran/subrange.f90 new file mode 100644 -index 0000000..9bbf438 +index 0000000..4747ea9 --- /dev/null -+++ b/gdb/testsuite/gdb.threads/watchpoint-fork-parent.c -@@ -0,0 +1,74 @@ -+/* Test case for forgotten hw-watchpoints after fork()-off of a process. -+ -+ Copyright 2012 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 -+#include -+#include -+#include -+#include -+#include -+#include -+ -+#include "watchpoint-fork.h" -+ -+void -+forkoff (int nr) -+{ -+ pid_t child, pid_got; -+ int exit_code = 42 + nr; -+ int status, i; ++++ b/gdb/testsuite/gdb.fortran/subrange.f90 +@@ -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 . + -+ 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 (); -+ } -+} -diff --git a/gdb/testsuite/gdb.threads/watchpoint-fork-st.c b/gdb/testsuite/gdb.threads/watchpoint-fork-st.c ++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 +diff --git a/gdb/testsuite/gdb.gdb/selftest.exp b/gdb/testsuite/gdb.gdb/selftest.exp +index 7645caf..f4f9c1f 100644 +--- a/gdb/testsuite/gdb.gdb/selftest.exp ++++ b/gdb/testsuite/gdb.gdb/selftest.exp +@@ -92,6 +92,10 @@ proc do_steps_and_nexts {} { + set description "step over cmdarg_vec initialization" + set command "step" + } ++ -re ".*python_script = 0.*$gdb_prompt $" { ++ set description "step over python_script initialization" ++ set command "step" ++ } + -re ".*pre_stat_chain = make_command_stats_cleanup.*$gdb_prompt $" { + set description "next over make_command_stats_cleanup and everything it calls" + set command "next" +diff --git a/gdb/testsuite/gdb.mi/mi2-var-stale-type.c b/gdb/testsuite/gdb.mi/mi2-var-stale-type.c new file mode 100644 -index 0000000..17cc058 +index 0000000..ebced3c --- /dev/null -+++ b/gdb/testsuite/gdb.threads/watchpoint-fork-st.c -@@ -0,0 +1,61 @@ -+/* Test case for forgotten hw-watchpoints after fork()-off of a process. -+ -+ Copyright 2012 Free Software Foundation, Inc. ++++ b/gdb/testsuite/gdb.mi/mi2-var-stale-type.c +@@ -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 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, @@ -14794,57 +8227,24 @@ index 0000000..17cc058 + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License -+ along with this program; if not, write to the Free Software -+ Foundation, Inc., 59 Temple Place - Suite 330, -+ Boston, MA 02111-1307, USA. */ -+ -+#include -+#include -+#include -+#include -+#include -+ -+#include "watchpoint-fork.h" -+ -+volatile int var; ++ along with this program. If not, see . */ + -+void -+marker (void) ++int ++main (int argc, char **argv) +{ -+} ++ char vla[argc]; + -+static void -+mark_exit (void) -+{ -+} ++ vla[0] = 0; /* break-here */ + -+int -+main (void) -+{ -+ setbuf (stdout, NULL); -+ printf ("main: %d\n", (int) getpid ()); -+ -+ /* General hardware breakpoints and watchpoints validity. */ -+ marker (); -+ var++; -+ /* Hardware watchpoints got disarmed here. */ -+ forkoff (1); -+ /* This watchpoint got lost before. */ -+ var++; -+ /* A sanity check for double hardware watchpoints removal. */ -+ forkoff (2); -+ var++; -+ -+ mark_exit (); + return 0; +} -diff --git a/gdb/testsuite/gdb.threads/watchpoint-fork.exp b/gdb/testsuite/gdb.threads/watchpoint-fork.exp +diff --git a/gdb/testsuite/gdb.mi/mi2-var-stale-type.exp b/gdb/testsuite/gdb.mi/mi2-var-stale-type.exp new file mode 100644 -index 0000000..2e01344 +index 0000000..74a104e --- /dev/null -+++ b/gdb/testsuite/gdb.threads/watchpoint-fork.exp -@@ -0,0 +1,149 @@ -+# Copyright 2012 Free Software Foundation, Inc. ++++ b/gdb/testsuite/gdb.mi/mi2-var-stale-type.exp +@@ -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 @@ -14859,155 +8259,61 @@ index 0000000..2e01344 +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + -+# Test case for forgotten hw-watchpoints after fork()-off of a process. -+ -+proc test {type symbol} { -+ global objdir subdir srcdir gdb_prompt -+ -+ 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 ${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_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" "No\[ \t\]+No\[ \t\]+Yes.*" -+ -+ if ![runto_main] { -+ return -+ } -+ -+ 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. -+ 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" ++load_lib mi-support.exp ++set MIFLAGS "-i=mi2" + -+ gdb_test "continue" \ -+ "reakpoint \[0-9\]+, marker.*" "hardware breakpoints work" -+ gdb_test "continue" \ -+ "atchpoint \[0-9\]+: var.*Old value = 0.*New value = 1.*forkoff *\\(1\\).*" "watchpoints work" -+ gdb_test "continue" \ -+ "reakpoint \[0-9\]+, marker.*" "breakpoint after the first fork" -+ gdb_test "continue" \ -+ "atchpoint \[0-9\]+: var.*Old value = 1.*New value = 2.*forkoff *\\(2\\).*" "watchpoint after the first fork" -+ gdb_test "continue" \ -+ "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" ++gdb_exit ++if [mi_gdb_start] { ++ continue ++} + ++set testfile "mi2-var-stale-type" ++set srcfile ${testfile}.c ++set binfile ${objdir}/${subdir}/${testfile} ++if {[build_executable ${testfile}.exp $testfile $srcfile] == -1} { ++ return -1 ++} + -+ # threads ++mi_delete_breakpoints ++mi_gdb_reinitialize_dir $srcdir/$subdir ++mi_gdb_load ${binfile} + -+ set pf_prefix $prefix_mt -+ lappend pf_prefix "multithreaded:" ++mi_gdb_test {-interpreter-exec console "maintenance set internal-error quit yes"} \ ++ {\^done} \ ++ "maintenance set internal-error quit yes" + -+ 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 ++mi_gdb_test {-interpreter-exec console "maintenance set internal-error corefile yes"} \ ++ {\^done} \ ++ "maintenance set internal-error corefile yes" + -+ 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.*" ++set line [gdb_get_line_number "break-here"] ++set func "main" + -+ if ![runto_main] { -+ return -+ } ++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" + -+ 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 ++if { [mi_run_cmd] < 0 } { ++ return -1 +} ++mi_expect_stop "breakpoint-hit" $func ".*" ".*" "\[0-9\]+" { "" "disp=\"del\"" } "stop after initializing vla" + -+test parent FOLLOW_PARENT ++mi_create_varobj "vla" "vla" "create local variable vla" + -+# 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" -+} -diff --git a/gdb/testsuite/gdb.threads/watchpoint-fork.h b/gdb/testsuite/gdb.threads/watchpoint-fork.h ++mi_gdb_test "-var-update *" "\\^done,changelist=.*" "-var-update *" +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..cb109fa +index 0000000..729f457 --- /dev/null -+++ b/gdb/testsuite/gdb.threads/watchpoint-fork.h -@@ -0,0 +1,32 @@ -+/* Test case for forgotten hw-watchpoints after fork()-off of a process. -+ -+ Copyright 2012 Free Software Foundation, Inc. ++++ b/gdb/testsuite/gdb.opt/array-from-register-func.c +@@ -0,0 +1,22 @@ ++/* This file is part of GDB, the GNU debugger. + -+ This file is part of GDB. ++ Copyright 2009 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by -+ the Free Software Foundation; either version 2 of the License, or ++ the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, @@ -15016,30 +8322,22 @@ index 0000000..cb109fa + 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 -+ -+extern volatile int step; -+extern pthread_t thread; -+#endif /* THREAD */ -+ -+extern volatile int var; ++ along with this program. If not, see . */ + -+extern void marker (void); -+extern void forkoff (int nr); -diff --git a/gdb/testsuite/gdb.trace/stap-trace.c b/gdb/testsuite/gdb.trace/stap-trace.c ++int ++func (int *arr) ++{ ++ return arr[0]; ++} +diff --git a/gdb/testsuite/gdb.opt/array-from-register.c b/gdb/testsuite/gdb.opt/array-from-register.c new file mode 100644 -index 0000000..27f317e +index 0000000..3090e7e --- /dev/null -+++ b/gdb/testsuite/gdb.trace/stap-trace.c -@@ -0,0 +1,71 @@ -+/* This testcase is part of GDB, the GNU debugger. ++++ b/gdb/testsuite/gdb.opt/array-from-register.c +@@ -0,0 +1,28 @@ ++/* This file is part of GDB, the GNU debugger. + -+ Copyright 2011 Free Software Foundation, Inc. ++ Copyright 2009 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by @@ -15054,69 +8352,64 @@ index 0000000..27f317e + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + -+#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 */ ++extern int func (int *arr); + -+#include ++int ++main (void) ++{ ++ int arr[] = { 42 }; + -+/* We only support SystemTap and only the v3 form. */ -+#if _SDT_NOTE_TYPE != 3 -+#error "not using SystemTap v3 probes" -+#endif ++ func (arr); + -+void -+m1 (int x) -+{ -+ if (TEST2) -+ STAP_PROBE1 (teste, two, x); ++ return 0; +} +diff --git a/gdb/testsuite/gdb.opt/array-from-register.exp b/gdb/testsuite/gdb.opt/array-from-register.exp +new file mode 100644 +index 0000000..f2de718 +--- /dev/null ++++ b/gdb/testsuite/gdb.opt/array-from-register.exp +@@ -0,0 +1,33 @@ ++# Copyright 2009 Free Software Foundation, Inc. ++# ++# This program is free software; you can redistribute it and/or modify ++# it under the terms of the GNU General Public License as published by ++# the Free Software Foundation; either version 2 of the License, or ++# (at your option) any later version. ++# ++# This program is distributed in the hope that it will be useful, ++# but WITHOUT ANY WARRANTY; without even the implied warranty of ++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++# GNU General Public License for more details. ++# ++# You should have received a copy of the GNU General Public License ++# along with this program; if not, write to the Free Software ++# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ++# ++# This file is part of the gdb testsuite. + -+int -+f (int x) -+{ -+ if (TEST) -+ STAP_PROBE1(teste, user, x); -+ return x+5; ++if { [prepare_for_testing array-from-register.exp "array-from-register" \ ++ {array-from-register.c array-from-register-func.c} \ ++ {debug optimize=-O2}] } { ++ return -1 +} + -+void -+nothing (void) -+{ -+ int a = 1 + 1; -+ return; ++if ![runto func] then { ++ return -1 +} + -+int -+main() -+{ -+ f (f (23)); -+ m1 (46); -+ nothing (); /* end-here */ ++gdb_test "p arr" "\\$\[0-9\]+ = \\(int \\*\\) *0x\[0-9a-f\]+" + -+ return 0; -+} -diff --git a/gdb/testsuite/gdb.trace/stap-trace.exp b/gdb/testsuite/gdb.trace/stap-trace.exp ++# 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.pascal/arrays.exp b/gdb/testsuite/gdb.pascal/arrays.exp new file mode 100644 -index 0000000..b0f1d7d +index 0000000..ccc6e1e --- /dev/null -+++ b/gdb/testsuite/gdb.trace/stap-trace.exp -@@ -0,0 +1,129 @@ -+# Copyright 2011 -+# Free Software Foundation, Inc. -+ ++++ b/gdb/testsuite/gdb.pascal/arrays.exp +@@ -0,0 +1,104 @@ ++# Copyright 2008, 2009 Free Software Foundation, Inc. ++# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or @@ -15130,124 +8423,235 @@ index 0000000..b0f1d7d +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + -+load_lib "trace-support.exp" -+ +if $tracelevel then { -+ strace $tracelevel ++ strace $tracelevel +} + -+set testfile "stap-trace" -+set srcfile ${testfile}.c -+set executable $testfile -+set binfile $objdir/$subdir/$executable ++load_lib "pascal.exp" ++ ++set testfile "arrays" ++set srcfile ${testfile}.pas ++set binfile ${objdir}/${subdir}/${testfile}$EXEEXT ++ ++# These tests only work with fpc, using the -gw3 compile-option ++pascal_init ++if { $pascal_compiler_is_fpc != 1 } { ++ return -1 ++} ++ ++# Detect if the fpc version is below 2.3.0 ++set fpc_generates_dwarf_for_dynamic_arrays 1 ++if { ($fpcversion_major < 2) || ( ($fpcversion_major == 2) && ($fpcversion_minor < 3))} { ++ set fpc_generates_dwarf_for_dynamic_arrays 0 ++} ++ ++ ++if {[gdb_compile_pascal "-gw3 ${srcdir}/${subdir}/${srcfile}" "${binfile}" executable [list debug ]] != "" } { ++ return -1 ++} ++ ++gdb_exit ++gdb_start ++gdb_reinitialize_dir $srcdir/$subdir ++gdb_load ${binfile} ++set bp_location1 [gdb_get_line_number "set breakpoint 1 here"] ++set bp_location2 [gdb_get_line_number "set breakpoint 2 here"] ++ ++ ++if { [gdb_breakpoint ${srcfile}:${bp_location1}] } { ++ pass "setting breakpoint 1" ++} ++if { [gdb_breakpoint ${srcfile}:${bp_location2}] } { ++ pass "setting breakpoint 2" ++} + -+set ws "\[\r\n\t \]+" -+set cr "\[\r\n\]+" ++# Verify that "start" lands inside the right procedure. ++if { [gdb_start_cmd] < 0 } { ++ untested start ++ return -1 ++} ++ ++gdb_test "" ".* at .*${srcfile}.*" "start" ++ ++gdb_test "cont" "Breakpoint .*:${bp_location1}.*" "Going to first breakpoint" ++ ++gdb_test "print StatArrInt" ".* = \\{50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61\\}" "Print static array of integer type" ++gdb_test "print StatArrInt_" ".* = \\{50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61\\}" "Print static array of integer" ++ ++gdb_test "cont" "Breakpoint .*:${bp_location2}.*" "Going to second breakpoint" ++ ++gdb_test "print StatArrChar" ".* = 'abcdefghijkl'" "Print static array of char" ++gdb_test "print Stat2dArrInt" ".* = \\{\\{0, 1, 2, 3, 4\\}, \\{1, 2, 3, 4, 5\\}, \\{2, 3, 4, 5, 6\\}, \\{3, 4, 5, 6, 7\\}, \\{4, 5, 6, 7, 8\\}, \\{5, 6, 7, 8, 9\\}, \\{6, 7, 8, 9, 10\\}, \\{7, 8, 9, 10, 11\\}, \\{8, 9, 10, 11, 12\\}, \\{9, 10, 11, 12, 13\\}, \\{10, 11, 12, 13, 14\\}, \\{11, 12, 13, 14, 15\\}\\}" "Print static 2-dimensional array of integer" + -+# Only x86 and x86_64 targets are supported for now. ++if { $fpc_generates_dwarf_for_dynamic_arrays == 0} { ++ setup_xfail "*-*-*" ++} ++gdb_test "print DynArrInt" ".* = \\{50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62\\}" "Print dynamic array of integer type" ++if { $fpc_generates_dwarf_for_dynamic_arrays == 0} { ++ setup_xfail "*-*-*" ++} ++gdb_test "print DynArrInt_" ".* = \\{50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62\\}" "Print dynamic array of integer" + -+if { ![istarget "x86_64-*"] && ![istarget "i?86-*"] } { -+ continue ++if { $fpc_generates_dwarf_for_dynamic_arrays == 0} { ++ setup_xfail "*-*-*" +} ++gdb_test "print s" ".* = 'test'#0'string'" "Print string containing null-char" + -+proc compile_stap_bin {{ arg "" }} { -+ global srcfile -+ global binfile -+ global srcdir -+ global subdir ++if { $fpc_generates_dwarf_for_dynamic_arrays == 0} { ++ setup_xfail "*-*-*" ++} ++gdb_test "print DynArrStr" ".* = \\{'dstr0', 'dstr1', 'dstr2', 'dstr3', 'dstr4', 'dstr5', 'dstr6', 'dstr7', 'dstr8', 'dstr9', 'dstr10', 'dstr11', 'dstr12'\\}" "Print dynamic array of string" + -+ if { $arg != "" } { -+ set arg "additional_flags=$arg" -+ } ++if { $fpc_generates_dwarf_for_dynamic_arrays == 0} { ++ setup_xfail "*-*-*" ++} ++gdb_test "print StatArrStr" ".* = \\{'str0', 'str1', 'str2', 'str3', 'str4', 'str5', 'str6', 'str7', 'str8', 'str9', 'str10', 'str11', 'str12'\\}" "Print static array of string" + -+ if { [gdb_compile "$srcdir/$subdir/$srcfile" $binfile \ -+ executable [concat $arg debug nowarnings]] != "" } { -+ untested "Could not compile ${srcfile}" -+ return -1 -+ } ++if { $fpc_generates_dwarf_for_dynamic_arrays == 0} { ++ setup_xfail "*-*-*" +} ++gdb_test "print DynArrChar" ".* = 'abcdefghijklm'" "Print dynamic array of char" + -+proc prepare_for_trace_test {} { -+ global executable +diff --git a/gdb/testsuite/gdb.pascal/arrays.pas b/gdb/testsuite/gdb.pascal/arrays.pas +new file mode 100644 +index 0000000..295602d +--- /dev/null ++++ b/gdb/testsuite/gdb.pascal/arrays.pas +@@ -0,0 +1,82 @@ ++{ ++ Copyright 2008, 2009 Free Software Foundation, Inc. + -+ clean_restart $executable ++ This program is free software; you can redistribute it and/or modify ++ it under the terms of the 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 { ![runto_main] } { -+ perror "Could not run to `main'." -+ continue -+ } ++ This program is distributed in the hope that it will be useful, ++ but WITHOUT ANY WARRANTY; without even the implied warranty of ++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++ GNU General Public License for more details. + -+ gdb_breakpoint [gdb_get_line_number "end-here"] ++ You should have received a copy of the GNU General Public License ++ along with this program. If not, see . +} + -+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" -+ } -+ } ++program arrays; + -+ gdb_test "continue" \ -+ "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" -+} ++{$mode objfpc}{$h+} + -+proc gdb_collect_probe_arg { msg probe val_arg0 } { -+ global gdb_prompt -+ global cr ++uses sysutils; + -+ prepare_for_trace_test ++type TStatArrInt= array[0..11] of integer; ++ TDynArrInt= array of integer; ++ TStatArrStr= array[0..12] of string; ++ TDynArrStr= array of string; ++ TDynArrChar = array of char; ++ TStatArrChar = array [0..11] of char; + -+ gdb_test "trace $probe" \ -+ "Tracepoint \[0-9\]+ at .*" \ -+ "collect $msg: set tracepoint" -+ gdb_trace_setactions "collect $msg: define actions" \ -+ "" \ -+ "collect \$_probe_arg0" "^$" ++ TStat2dArrInt = array[0..11,0..4] of integer; + -+ # Begin the test. -+ run_trace_experiment $msg $probe ++var StatArrInt: TStatArrInt; ++ StatArrInt_: Array[0..11] of integer; ++ DynArrInt: TDynArrInt; ++ DynArrInt_: Array of integer; ++ StatArrStr: TStatArrStr; ++ DynArrStr: TDynArrStr; ++ StatArrChar: TStatArrChar; ++ DynArrChar: TDynArrChar; + -+ gdb_test "print \$_probe_arg0" \ -+ "\\$\[0-9\]+ = $val_arg0$cr" \ -+ "collect $msg: collected probe arg0" -+} ++ Stat2dArrInt: TStat2dArrInt; + -+compile_stap_bin "" ++ s: string; ++ ++ i,j : integer; + -+clean_restart $executable -+if { ![runto_main] } { -+ perror "Could not run to `main'." -+ continue -+} ++begin ++ for i := 0 to 11 do ++ begin ++ StatArrInt[i]:= i+50; ++ StatArrInt_[i]:= i+50; ++ StatArrChar[i]:= chr(ord('a')+i); ++ for j := 0 to 4 do ++ Stat2dArrInt[i,j]:=i+j; ++ end; ++ writeln(StatArrInt_[0]); ++ writeln(StatArrInt[0]); { set breakpoint 1 here } ++ writeln(StatArrChar[0]); ++ writeln(Stat2dArrInt[0,0]); + -+if { ![gdb_target_supports_trace] } { -+ # Test cannot run on this target. -+ return 1; -+} ++ setlength(DynArrInt,13); ++ setlength(DynArrInt_,13); ++ setlength(DynArrStr,13); ++ setlength(DynArrChar,13); ++ for i := 0 to 12 do ++ begin ++ DynArrInt[i]:= i+50; ++ DynArrInt_[i]:= i+50; ++ DynArrChar[i]:= chr(ord('a')+i); ++ StatArrStr[i]:='str'+inttostr(i); ++ DynArrStr[i]:='dstr'+inttostr(i); ++ end; ++ writeln(DynArrInt_[1]); ++ writeln(DynArrInt[1]); ++ writeln(DynArrStr[1]); ++ writeln(StatArrStr[1]); ++ writeln(DynArrChar[1]); + -+gdb_collect_probe_arg "probe args without semaphore" "-p user" "23" -+gdb_exit ++ s := 'test'#0'string'; ++ writeln(s); { set breakpoint 2 here } ++end. +diff --git a/gdb/testsuite/gdb.python/py-frame.exp b/gdb/testsuite/gdb.python/py-frame.exp +index 83ff8fe..bddbf9f 100644 +--- a/gdb/testsuite/gdb.python/py-frame.exp ++++ b/gdb/testsuite/gdb.python/py-frame.exp +@@ -74,8 +74,6 @@ gdb_test "python print bframe == gdb.newest_frame()" True \ + + gdb_test "python print 'result =', f0 == f1" " = False" "test equality comparison (false)" + gdb_test "python print 'result =', f0 == f0" " = True" "test equality comparison (true)" +-gdb_test "python print 'result =', f0 != f1" " = True" "test inequality comparison (true)" +-gdb_test "python print 'result =', f0 != f0" " = False" "test inequality comparison (false)" + gdb_test "python print 'result =', f0.is_valid ()" " = True" "test Frame.is_valid" + gdb_test "python print 'result =', f0.name ()" " = f2" "test Frame.name" + gdb_test "python print 'result =', f0.type () == gdb.NORMAL_FRAME" " = True" "test Frame.type" +@@ -90,3 +88,5 @@ gdb_test "python print 'result =', f0.read_var ('variable_which_surely_doesnt_ex + gdb_test "python print 'result =', f0.read_var ('a')" " = 1" "test Frame.read_var - success" + + gdb_test "python print 'result =', gdb.selected_frame () == f1" " = True" "test gdb.selected_frame" + -+compile_stap_bin "-DUSE_PROBES" -+gdb_collect_probe_arg "probe args with semaphore" "-p two" "46" ++gdb_test "python print 'result =', f0.block ()" "" "test Frame.block" +diff --git a/gdb/testsuite/gdb.python/py-value.exp b/gdb/testsuite/gdb.python/py-value.exp +index c9d8c97..4324db0 100644 +--- a/gdb/testsuite/gdb.python/py-value.exp ++++ b/gdb/testsuite/gdb.python/py-value.exp +@@ -360,6 +360,15 @@ proc test_value_after_death {} { + "print value's type" + } + ++# Regression test for a cast failure. The bug was that if we cast a ++# value to its own type, gdb could crash. This happened because we ++# could end up double-freeing a struct value. ++proc test_cast_regression {} { ++ gdb_test "python v = gdb.Value(5)" "" "create value for cast test" ++ gdb_test "python v = v.cast(v.type)" "" "cast value for cast test" ++ gdb_test "python print v" "5" "print value for cast test" ++} + -+# Finished! -+gdb_test "tfind none" ".*" "" + # 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. +@@ -496,6 +505,7 @@ test_value_in_inferior + test_inferior_function_call + test_lazy_strings + test_value_after_death ++test_cast_regression + + # Test either C or C++ values. + test_subscript_regression "${binfile}" "c" diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp -index 00fe71c..5ca9563 100644 +index 1dfe564..186f9d7 100644 --- a/gdb/testsuite/lib/gdb.exp +++ b/gdb/testsuite/lib/gdb.exp -@@ -139,6 +139,11 @@ proc gdb_unload {} { +@@ -142,6 +142,11 @@ proc gdb_unload {} { send_gdb "y\n" exp_continue } @@ -15294,48 +8698,11 @@ index dd18d37..f973485 100644 } set pascal_init_done 1 } -diff --git a/gdb/thread.c b/gdb/thread.c -index 9a29383..1a49b00 100644 ---- a/gdb/thread.c -+++ b/gdb/thread.c -@@ -1431,7 +1431,8 @@ update_thread_list (void) - no thread is selected, or no threads exist. */ - - 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); - -@@ -1442,6 +1443,15 @@ thread_id_make_value (struct gdbarch *gdbarch, struct internalvar *var) - /* Commands with a prefix of `thread'. */ - struct cmd_list_element *thread_cmd_list = NULL; - -+/* Implementation of `thread' variable. */ -+ -+static struct internalvar_funcs thread_funcs = -+{ -+ thread_id_make_value, -+ NULL, -+ NULL -+}; -+ - void - _initialize_thread (void) - { -@@ -1487,5 +1497,5 @@ Show printing of thread events (such as thread start and exit)."), NULL, - show_print_thread_events, - &setprintlist, &showprintlist); - -- create_internalvar_type_lazy ("_thread", thread_id_make_value); -+ create_internalvar_type_lazy ("_thread", &thread_funcs, NULL); - } diff --git a/gdb/top.c b/gdb/top.c -index c4e913d..5b79983 100644 +index 061ad48..d615cfc 100644 --- a/gdb/top.c +++ b/gdb/top.c -@@ -349,6 +349,9 @@ prepare_execute_command (void) +@@ -352,6 +352,9 @@ prepare_execute_command (void) mark = value_mark (); cleanup = make_cleanup_value_free_to_mark (mark); @@ -15345,112 +8712,8 @@ index c4e913d..5b79983 100644 /* With multiple threads running while the one we're examining is stopped, the dcache can get stale without us being able to detect -diff --git a/gdb/tracepoint.c b/gdb/tracepoint.c -index ede3742..b20f733 100644 ---- a/gdb/tracepoint.c -+++ b/gdb/tracepoint.c -@@ -683,7 +683,7 @@ validate_actionline (char **line, struct breakpoint *b) - struct cleanup *old_chain = NULL; - char *p, *tmp_p; - struct bp_location *loc; -- struct agent_expr *aexpr; -+ struct agent_expr *aexpr = NULL; - struct tracepoint *t = (struct tracepoint *) b; - - /* If EOF is typed, *line is NULL. */ -@@ -1352,7 +1352,7 @@ encode_actions_1 (struct command_line *action, - int i; - struct value *tempval; - struct cmd_list_element *cmd; -- struct agent_expr *aexpr; -+ struct agent_expr *aexpr = NULL; - - for (; action; action = action->next) - { -@@ -1716,6 +1716,7 @@ start_tracing (char *notes) - for (ix = 0; VEC_iterate (breakpoint_p, tp_vec, ix, b); ix++) - { - struct tracepoint *t = (struct tracepoint *) b; -+ struct bp_location *loc; - - if (b->enable_state == bp_enabled) - any_enabled = 1; -@@ -1778,6 +1779,9 @@ start_tracing (char *notes) - } - - t->number_on_target = b->number; -+ -+ for (loc = b->loc; loc; loc = loc->next) -+ modify_semaphore (loc, 1); - } - VEC_free (breakpoint_p, tp_vec); - -@@ -1850,9 +1854,28 @@ void - stop_tracing (char *note) - { - int ret; -+ 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++) -+ { -+ 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); -+ } -+ -+ VEC_free (breakpoint_p, tp_vec); -+ - if (!note) - note = trace_stop_notes; - ret = target_set_trace_notes (NULL, NULL, note); -@@ -4924,7 +4947,8 @@ info_static_tracepoint_markers_command (char *arg, int from_tty) - available. */ - - static struct value * --sdata_make_value (struct gdbarch *gdbarch, struct internalvar *var) -+sdata_make_value (struct gdbarch *gdbarch, struct internalvar *var, -+ void *ignore) - { - LONGEST size; - gdb_byte *buf; -@@ -5103,6 +5127,15 @@ traceframe_available_memory (VEC(mem_range_s) **result, - return 0; - } - -+/* Implementation of `sdata' variable. */ -+ -+static const struct internalvar_funcs sdata_funcs = -+{ -+ sdata_make_value, -+ NULL, -+ NULL -+}; -+ - /* module initialization */ - void - _initialize_tracepoint (void) -@@ -5113,7 +5146,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; diff --git a/gdb/typeprint.c b/gdb/typeprint.c -index de96fd5..75485ff 100644 +index c25e705..498958a 100644 --- a/gdb/typeprint.c +++ b/gdb/typeprint.c @@ -35,6 +35,7 @@ @@ -15462,7 +8725,7 @@ index de96fd5..75485ff 100644 extern void _initialize_typeprint (void); @@ -76,6 +77,9 @@ void - type_print (struct type *type, char *varstring, struct ui_file *stream, + type_print (struct type *type, const char *varstring, struct ui_file *stream, int show) { + if (show >= 0 && current_language->la_language != language_ada) @@ -15496,7 +8759,7 @@ index de96fd5..75485ff 100644 type = value_type (val); get_user_print_options (&opts); -@@ -167,8 +173,7 @@ whatis_exp (char *exp, int show) +@@ -158,8 +164,7 @@ whatis_exp (char *exp, int show) type_print (type, "", gdb_stdout, show); printf_filtered ("\n"); @@ -15507,10 +8770,10 @@ index de96fd5..75485ff 100644 static void diff --git a/gdb/utils.c b/gdb/utils.c -index 4863e41..c1fec82 100644 +index 2d607ef..d67e7dd 100644 --- a/gdb/utils.c +++ b/gdb/utils.c -@@ -1904,6 +1904,36 @@ set_batch_flag_and_make_cleanup_restore_page_info (void) +@@ -1737,6 +1737,36 @@ set_batch_flag_and_make_cleanup_restore_page_info (void) return back_to; } @@ -15548,7 +8811,7 @@ index 4863e41..c1fec82 100644 static void diff --git a/gdb/valarith.c b/gdb/valarith.c -index b8bcc6b..fb83c70 100644 +index 0225339..f775bfc 100644 --- a/gdb/valarith.c +++ b/gdb/valarith.c @@ -197,7 +197,10 @@ value_subscripted_rvalue (struct value *array, LONGEST index, int lowerbound) @@ -15575,7 +8838,7 @@ index b8bcc6b..fb83c70 100644 } diff --git a/gdb/valops.c b/gdb/valops.c -index 5453b1a..5a4a8fa 100644 +index feb47f5..6d14eee 100644 --- a/gdb/valops.c +++ b/gdb/valops.c @@ -45,6 +45,7 @@ @@ -15586,7 +8849,7 @@ index 5453b1a..5a4a8fa 100644 extern int overload_debug; /* Local functions. */ -@@ -915,6 +916,65 @@ value_one (struct type *type) +@@ -919,6 +920,65 @@ value_one (struct type *type) return val; } @@ -15652,7 +8915,17 @@ index 5453b1a..5a4a8fa 100644 /* Helper function for value_at, value_at_lazy, and value_at_lazy_stack. */ static struct value * -@@ -1011,12 +1071,20 @@ value_fetch_lazy (struct value *val) +@@ -981,7 +1041,8 @@ int + value_fetch_lazy (struct value *val) + { + gdb_assert (value_lazy (val)); +- allocate_value_contents (val); ++ if (VALUE_LVAL (val) != lval_memory) ++ allocate_value_contents (val); + if (value_bitsize (val)) + { + /* To read a lazy bitfield, read the entire enclosing value. This +@@ -1015,12 +1076,24 @@ value_fetch_lazy (struct value *val) } else if (VALUE_LVAL (val) == lval_memory) { @@ -15670,15 +8943,19 @@ index 5453b1a..5a4a8fa 100644 + + if (length) + { ++ /* Delay it after object_address_get_data above. */ ++ allocate_value_contents (val); + addr += value_offset (val); + read_value_memory (val, 0, value_stack (val), + addr, value_contents_all_raw (val), length); + } + } ++ /* Just to be sure it has been called. */ ++ allocate_value_contents (val); } else if (VALUE_LVAL (val) == lval_register) { -@@ -1528,7 +1596,18 @@ address_of_variable (struct symbol *var, struct block *b) +@@ -1532,7 +1605,18 @@ address_of_variable (struct symbol *var, struct block *b) if ((VALUE_LVAL (val) == lval_memory && value_lazy (val)) || TYPE_CODE (type) == TYPE_CODE_FUNC) { @@ -15698,7 +8975,7 @@ index 5453b1a..5a4a8fa 100644 return value_from_pointer (lookup_pointer_type (type), addr); } -@@ -1635,6 +1714,7 @@ struct value * +@@ -1639,6 +1723,7 @@ struct value * value_coerce_array (struct value *arg1) { struct type *type = check_typedef (value_type (arg1)); @@ -15706,7 +8983,7 @@ index 5453b1a..5a4a8fa 100644 /* If the user tries to do something requiring a pointer with an array that has not yet been pushed to the target, then this would -@@ -1644,8 +1724,12 @@ value_coerce_array (struct value *arg1) +@@ -1648,8 +1733,12 @@ value_coerce_array (struct value *arg1) if (VALUE_LVAL (arg1) != lval_memory) error (_("Attempt to take address of value not located in memory.")); @@ -15720,7 +8997,7 @@ index 5453b1a..5a4a8fa 100644 } /* Given a value which is a function, return a value which is a pointer -@@ -3694,6 +3778,8 @@ value_slice (struct value *array, int lowbound, int length) +@@ -3772,6 +3861,8 @@ value_slice (struct value *array, int lowbound, int length) TYPE_TARGET_TYPE (range_type), lowbound, lowbound + length - 1); @@ -15730,7 +9007,7 @@ index 5453b1a..5a4a8fa 100644 { int i; diff --git a/gdb/valprint.c b/gdb/valprint.c -index 325cf40..70a98c2 100644 +index fc5942d..8333eb4 100644 --- a/gdb/valprint.c +++ b/gdb/valprint.c @@ -37,6 +37,7 @@ @@ -15741,7 +9018,7 @@ index 325cf40..70a98c2 100644 #include -@@ -240,7 +241,6 @@ scalar_type_p (struct type *type) +@@ -251,7 +252,6 @@ scalar_type_p (struct type *type) case TYPE_CODE_STRUCT: case TYPE_CODE_UNION: case TYPE_CODE_SET: @@ -15749,7 +9026,7 @@ index 325cf40..70a98c2 100644 case TYPE_CODE_BITSTRING: return 0; default: -@@ -1198,6 +1198,7 @@ val_print_array_elements (struct type *type, +@@ -1570,6 +1570,7 @@ val_print_array_elements (struct type *type, { unsigned int things_printed = 0; unsigned len; @@ -15757,7 +9034,7 @@ index 325cf40..70a98c2 100644 struct type *elttype, *index_type; unsigned eltlen; /* Position of the array element we are examining to see -@@ -1206,9 +1207,33 @@ val_print_array_elements (struct type *type, +@@ -1578,9 +1579,33 @@ val_print_array_elements (struct type *type, /* Number of repetitions we have detected so far. */ unsigned int reps; LONGEST low_bound, high_bound; @@ -15793,7 +9070,7 @@ index 325cf40..70a98c2 100644 index_type = TYPE_INDEX_TYPE (type); if (get_array_bounds (type, &low_bound, &high_bound)) -@@ -1295,6 +1320,8 @@ val_print_array_elements (struct type *type, +@@ -1667,6 +1692,8 @@ val_print_array_elements (struct type *type, { fprintf_filtered (stream, "..."); } @@ -15803,18 +9080,18 @@ index 325cf40..70a98c2 100644 /* Read LEN bytes of target memory at address MEMADDR, placing the diff --git a/gdb/value.c b/gdb/value.c -index 583be33..cb73eda 100644 +index c64e55b..cd08a0b 100644 --- a/gdb/value.c +++ b/gdb/value.c -@@ -41,6 +41,7 @@ - #include "python/python.h" +@@ -42,6 +42,7 @@ #include #include "tracepoint.h" + #include "cp-abi.h" +#include "observer.h" /* Prototypes for exported functions. */ -@@ -1385,12 +1386,15 @@ void +@@ -1437,12 +1438,15 @@ void set_value_component_location (struct value *component, const struct value *whole) { @@ -15830,7 +9107,7 @@ index 583be33..cb73eda 100644 if (whole->lval == lval_computed) { const struct lval_funcs *funcs = whole->location.computed.funcs; -@@ -1398,6 +1402,12 @@ set_value_component_location (struct value *component, +@@ -1450,6 +1454,12 @@ set_value_component_location (struct value *component, if (funcs->copy_closure) component->location.computed.closure = funcs->copy_closure (whole); } @@ -15843,7 +9120,7 @@ index 583be33..cb73eda 100644 } -@@ -1531,6 +1541,31 @@ show_values (char *num_exp, int from_tty) +@@ -1583,6 +1593,31 @@ show_values (char *num_exp, int from_tty) num_exp[1] = '\0'; } } @@ -15875,88 +9152,7 @@ index 583be33..cb73eda 100644 /* Internal variables. These are variables within the debugger that hold values assigned by debugger commands. -@@ -1576,7 +1611,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 -@@ -1675,18 +1717,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. - -@@ -1759,7 +1822,8 @@ value_of_internalvar (struct gdbarch *gdbarch, struct internalvar *var) - 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: -@@ -1955,6 +2019,11 @@ clear_internalvar (struct internalvar *var) - 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; - } -@@ -2009,6 +2078,38 @@ call_internal_function (struct gdbarch *gdbarch, +@@ -2095,6 +2130,38 @@ call_internal_function (struct gdbarch *gdbarch, return (*ifn->handler) (gdbarch, language, ifn->cookie, argc, argv); } @@ -15995,7 +9191,7 @@ index 583be33..cb73eda 100644 /* The 'function' command. This does nothing -- it is just a placeholder to let "help function NAME" work. This is also used as the implementation of the sub-command that is created when -@@ -2056,11 +2157,10 @@ preserve_one_value (struct value *value, struct objfile *objfile, +@@ -2142,11 +2209,10 @@ preserve_one_value (struct value *value, struct objfile *objfile, htab_t copied_types) { if (TYPE_OBJFILE (value->type) == objfile) @@ -16009,7 +9205,7 @@ index 583be33..cb73eda 100644 copied_types); } -@@ -2075,7 +2175,7 @@ preserve_one_internalvar (struct internalvar *var, struct objfile *objfile, +@@ -2161,7 +2227,7 @@ preserve_one_internalvar (struct internalvar *var, struct objfile *objfile, case INTERNALVAR_INTEGER: if (var->u.integer.type && TYPE_OBJFILE (var->u.integer.type) == objfile) var->u.integer.type @@ -16018,13 +9214,14 @@ index 583be33..cb73eda 100644 break; case INTERNALVAR_VALUE: -@@ -3137,9 +3237,26 @@ coerce_ref_if_computed (const struct value *arg) +@@ -3253,10 +3319,27 @@ readjust_indirect_value_type (struct value *value, struct type *enc_type, struct value * coerce_ref (struct value *arg) { - struct type *value_type_arg_tmp = check_typedef (value_type (arg)); + struct type *value_type_arg_tmp; struct value *retval; + struct type *enc_type; + if (TYPE_DYNAMIC (value_type (arg))) + { @@ -16046,7 +9243,7 @@ index 583be33..cb73eda 100644 retval = coerce_ref_if_computed (arg); if (retval) return retval; -@@ -3241,4 +3358,10 @@ VARIABLE is already initialized.")); +@@ -3363,4 +3446,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); @@ -16058,10 +9255,10 @@ index 583be33..cb73eda 100644 +#endif } diff --git a/gdb/value.h b/gdb/value.h -index 4727755..d8d22c8 100644 +index b630fc7..2f95db2 100644 --- a/gdb/value.h +++ b/gdb/value.h -@@ -488,6 +488,10 @@ extern struct value *value_from_decfloat (struct type *type, +@@ -533,6 +533,10 @@ extern struct value *value_from_decfloat (struct type *type, const gdb_byte *decbytes); extern struct value *value_from_history_ref (char *, char **); @@ -16072,107 +9269,3 @@ index 4727755..d8d22c8 100644 extern struct value *value_at (struct type *type, CORE_ADDR addr); extern struct value *value_at_lazy (struct type *type, CORE_ADDR addr); -@@ -717,10 +721,52 @@ extern struct internalvar *lookup_only_internalvar (const char *name); - - extern struct internalvar *create_internalvar (const char *name); - --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); - - extern struct internalvar *lookup_internalvar (const char *name); - -diff --git a/gdb/windows-tdep.c b/gdb/windows-tdep.c -index e111d41..18e3180 100644 ---- a/gdb/windows-tdep.c -+++ b/gdb/windows-tdep.c -@@ -268,7 +268,7 @@ static const 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); - } -diff --git a/gdb/xcoffread.c b/gdb/xcoffread.c -index 1a2bb14..d43e946 100644 ---- a/gdb/xcoffread.c -+++ b/gdb/xcoffread.c -@@ -3123,6 +3123,7 @@ static const struct sym_fns xcoff_sym_fns = - 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 - }; - diff --git a/gdb-attach-fail-reasons-1of5.patch b/gdb-attach-fail-reasons-1of5.patch deleted file mode 100644 index 4c547d8..0000000 --- a/gdb-attach-fail-reasons-1of5.patch +++ /dev/null @@ -1,88 +0,0 @@ -http://sourceware.org/ml/gdb-cvs/2012-02/msg00180.html - -### src/gdb/gdbserver/ChangeLog 2012/02/25 19:54:50 1.556 -### src/gdb/gdbserver/ChangeLog 2012/02/27 16:19:19 1.557 -## -1,3 +1,9 @@ -+2012-02-27 Pedro Alves -+ -+ PR server/9684 -+ * linux-low.c (pid_is_stopped): New. -+ (linux_attach_lwp_1): Handle attaching to 'T (stopped)' processes. -+ - 2012-02-25 Luis Machado - - * mem-break.c (clear_gdb_breakpoint_conditions): Fix de-allocation ---- src/gdb/gdbserver/linux-low.c 2012/02/24 15:15:56 1.193 -+++ src/gdb/gdbserver/linux-low.c 2012/02/27 16:19:19 1.194 -@@ -598,6 +598,37 @@ - return pid; - } - -+/* Detect `T (stopped)' in `/proc/PID/status'. -+ Other states including `T (tracing stop)' are reported as false. */ -+ -+static int -+pid_is_stopped (pid_t pid) -+{ -+ FILE *status_file; -+ char buf[100]; -+ int retval = 0; -+ -+ snprintf (buf, sizeof (buf), "/proc/%d/status", (int) pid); -+ status_file = fopen (buf, "r"); -+ if (status_file != NULL) -+ { -+ int have_state = 0; -+ -+ while (fgets (buf, sizeof (buf), status_file)) -+ { -+ if (strncmp (buf, "State:", 6) == 0) -+ { -+ have_state = 1; -+ break; -+ } -+ } -+ if (have_state && strstr (buf, "T (stopped)") != NULL) -+ retval = 1; -+ fclose (status_file); -+ } -+ return retval; -+} -+ - /* Attach to an inferior process. */ - - static void -@@ -643,6 +674,33 @@ - ptrace call on this LWP. */ - new_lwp->must_set_ptrace_flags = 1; - -+ if (pid_is_stopped (lwpid)) -+ { -+ if (debug_threads) -+ fprintf (stderr, -+ "Attached to a stopped process\n"); -+ -+ /* The process is definitely stopped. It is in a job control -+ stop, unless the kernel predates the TASK_STOPPED / -+ TASK_TRACED distinction, in which case it might be in a -+ ptrace stop. Make sure it is in a ptrace stop; from there we -+ can kill it, signal it, et cetera. -+ -+ First make sure there is a pending SIGSTOP. Since we are -+ already attached, the process can not transition from stopped -+ to running without a PTRACE_CONT; so we know this signal will -+ go into the queue. The SIGSTOP generated by PTRACE_ATTACH is -+ probably already in the queue (unless this kernel is old -+ enough to use TASK_STOPPED for ptrace stops); but since -+ SIGSTOP is not an RT signal, it can only be queued once. */ -+ kill_lwp (lwpid, SIGSTOP); -+ -+ /* Finally, resume the stopped process. This will deliver the -+ SIGSTOP (or a higher priority signal, just like normal -+ PTRACE_ATTACH), which we'll catch later on. */ -+ ptrace (PTRACE_CONT, lwpid, 0, 0); -+ } -+ - /* The next time we wait for this LWP we'll see a SIGSTOP as PTRACE_ATTACH - brings it to a halt. - diff --git a/gdb-attach-fail-reasons-2of5.patch b/gdb-attach-fail-reasons-2of5.patch deleted file mode 100644 index 92565b9..0000000 --- a/gdb-attach-fail-reasons-2of5.patch +++ /dev/null @@ -1,178 +0,0 @@ -http://sourceware.org/ml/gdb-cvs/2012-02/msg00181.html - -### src/gdb/ChangeLog 2012/02/24 23:48:37 1.13869 -### src/gdb/ChangeLog 2012/02/27 16:22:06 1.13870 -## -1,3 +1,13 @@ -+2012-02-27 Pedro Alves -+ -+ * linux-nat.c (pid_is_stopped): Delete, moved to common/. -+ (linux_nat_post_attach_wait): Adjust to use -+ linux_proc_pid_is_stopped. -+ * common/linux-procfs.h (linux_proc_pid_is_stopped): Declare. -+ * common/linux-procfs.c (linux_proc_pid_is_stopped): New function, -+ based on pid_is_stopped from both linux-nat.c and -+ gdbserver/linux-low.c, and renamed. -+ - 2012-02-24 Maciej W. Rozycki - - * remote.c (remote_watchpoint_addr_within_range): New function. ---- src/gdb/linux-nat.c 2012/02/16 21:07:20 1.239 -+++ src/gdb/linux-nat.c 2012/02/27 16:22:13 1.240 -@@ -1356,37 +1356,6 @@ - delete_lwp (lp->ptid); - } - --/* Detect `T (stopped)' in `/proc/PID/status'. -- Other states including `T (tracing stop)' are reported as false. */ -- --static int --pid_is_stopped (pid_t pid) --{ -- FILE *status_file; -- char buf[100]; -- int retval = 0; -- -- snprintf (buf, sizeof (buf), "/proc/%d/status", (int) pid); -- status_file = fopen (buf, "r"); -- if (status_file != NULL) -- { -- int have_state = 0; -- -- while (fgets (buf, sizeof (buf), status_file)) -- { -- if (strncmp (buf, "State:", 6) == 0) -- { -- have_state = 1; -- break; -- } -- } -- if (have_state && strstr (buf, "T (stopped)") != NULL) -- retval = 1; -- fclose (status_file); -- } -- return retval; --} -- - /* Wait for the LWP specified by LP, which we have just attached to. - Returns a wait status for that LWP, to cache. */ - -@@ -1397,7 +1366,7 @@ - pid_t new_pid, pid = GET_LWP (ptid); - int status; - -- if (pid_is_stopped (pid)) -+ if (linux_proc_pid_is_stopped (pid)) - { - if (debug_linux_nat) - fprintf_unfiltered (gdb_stdlog, ---- src/gdb/common/linux-procfs.c 2012/01/04 08:17:18 1.2 -+++ src/gdb/common/linux-procfs.c 2012/02/27 16:22:14 1.3 -@@ -53,3 +53,34 @@ - - return tgid; - } -+ -+/* Detect `T (stopped)' in `/proc/PID/status'. -+ Other states including `T (tracing stop)' are reported as false. */ -+ -+int -+linux_proc_pid_is_stopped (pid_t pid) -+{ -+ FILE *status_file; -+ char buf[100]; -+ int retval = 0; -+ -+ snprintf (buf, sizeof (buf), "/proc/%d/status", (int) pid); -+ status_file = fopen (buf, "r"); -+ if (status_file != NULL) -+ { -+ int have_state = 0; -+ -+ while (fgets (buf, sizeof (buf), status_file)) -+ { -+ if (strncmp (buf, "State:", 6) == 0) -+ { -+ have_state = 1; -+ break; -+ } -+ } -+ if (have_state && strstr (buf, "T (stopped)") != NULL) -+ retval = 1; -+ fclose (status_file); -+ } -+ return retval; -+} ---- src/gdb/common/linux-procfs.h 2012/01/04 08:17:18 1.2 -+++ src/gdb/common/linux-procfs.h 2012/02/27 16:22:15 1.3 -@@ -26,4 +26,9 @@ - - extern int linux_proc_get_tgid (int lwpid); - -+/* Detect `T (stopped)' in `/proc/PID/status'. -+ Other states including `T (tracing stop)' are reported as false. */ -+ -+extern int linux_proc_pid_is_stopped (pid_t pid); -+ - #endif /* COMMON_LINUX_PROCFS_H */ -### src/gdb/gdbserver/ChangeLog 2012/02/27 16:19:19 1.557 -### src/gdb/gdbserver/ChangeLog 2012/02/27 16:22:15 1.558 -## -1,5 +1,10 @@ - 2012-02-27 Pedro Alves - -+ * linux-low.c (pid_is_stopped): Delete, moved to common/. -+ (linux_attach_lwp_1): Adjust to use linux_proc_pid_is_stopped. -+ -+2012-02-27 Pedro Alves -+ - PR server/9684 - * linux-low.c (pid_is_stopped): New. - (linux_attach_lwp_1): Handle attaching to 'T (stopped)' processes. ---- src/gdb/gdbserver/linux-low.c 2012/02/27 16:19:19 1.194 -+++ src/gdb/gdbserver/linux-low.c 2012/02/27 16:22:16 1.195 -@@ -598,37 +598,6 @@ - return pid; - } - --/* Detect `T (stopped)' in `/proc/PID/status'. -- Other states including `T (tracing stop)' are reported as false. */ -- --static int --pid_is_stopped (pid_t pid) --{ -- FILE *status_file; -- char buf[100]; -- int retval = 0; -- -- snprintf (buf, sizeof (buf), "/proc/%d/status", (int) pid); -- status_file = fopen (buf, "r"); -- if (status_file != NULL) -- { -- int have_state = 0; -- -- while (fgets (buf, sizeof (buf), status_file)) -- { -- if (strncmp (buf, "State:", 6) == 0) -- { -- have_state = 1; -- break; -- } -- } -- if (have_state && strstr (buf, "T (stopped)") != NULL) -- retval = 1; -- fclose (status_file); -- } -- return retval; --} -- - /* Attach to an inferior process. */ - - static void -@@ -674,7 +643,7 @@ - ptrace call on this LWP. */ - new_lwp->must_set_ptrace_flags = 1; - -- if (pid_is_stopped (lwpid)) -+ if (linux_proc_pid_is_stopped (lwpid)) - { - if (debug_threads) - fprintf (stderr, diff --git a/gdb-attach-fail-reasons-3of5.patch b/gdb-attach-fail-reasons-3of5.patch deleted file mode 100644 index a16618e..0000000 --- a/gdb-attach-fail-reasons-3of5.patch +++ /dev/null @@ -1,583 +0,0 @@ -http://sourceware.org/ml/gdb-patches/2012-03/msg00169.html -Subject: [patch 1/3] attach-fail-reasons: Reshuffle code - -Hi, - -this patch does not make sense on its own but it contains all the -uninteresting code moves / reconfigurations. - - -Thanks, -Jan - - -gdb/ -2012-03-06 Jan Kratochvil - - * Makefile.in (linux-ptrace.o): New. - * common/linux-procfs.c (linux_proc_pid_is_zombie): New, - from linux-nat.c. - * common/linux-procfs.h (linux_proc_pid_is_zombie): New declaration. - * common/linux-ptrace.c: New file. - * config/alpha/alpha-linux.mh (NATDEPFILES): Add linux-ptrace.o. - * config/arm/linux.mh: Likewise. - * config/i386/linux.mh: Likewise. - * config/i386/linux64.mh: Likewise. - * config/ia64/linux.mh: Likewise. - * config/m32r/linux.mh: Likewise. - * config/m68k/linux.mh: Likewise. - * config/mips/linux.mh: Likewise. - * config/pa/linux.mh: Likewise. - * config/powerpc/linux.mh: Likewise. - * config/powerpc/ppc64-linux.mh: Likewise. - * config/powerpc/spu-linux.mh: Likewise. - * config/s390/s390.mh: Likewise. - * config/sparc/linux.mh: Likewise. - * config/sparc/linux64.mh: Likewise. - * config/xtensa/linux.mh: Likewise. - * linux-nat.c (linux_lwp_is_zombie): Remove, move it to - common/linux-procfs.c. - (wait_lwp): Rename linux_lwp_is_zombie to linux_proc_pid_is_zombie. - -gdb/gdbserver/ -2012-03-06 Jan Kratochvil - - * Makefile.in (linux-ptrace.o): New. - * configure.srv (arm*-*-linux*, bfin-*-*linux*, crisv32-*-linux*) - (cris-*-linux*, i[34567]86-*-linux*, ia64-*-linux*, m32r*-*-linux*) - (m68*-*-linux*, m68*-*-uclinux*, mips*-*-linux*, powerpc*-*-linux*) - (s390*-*-linux*, sh*-*-linux*, sparc*-*-linux*, tic6x-*-uclinux) - (x86_64-*-linux*, xtensa*-*-linux*): Add linux-ptrace.o to SRV_TGTOBJ - of these targets. - * linux-low.c (linux_attach_lwp_1): Remove redundent else clause. - -Index: gdb-7.4.50.20120120/gdb/Makefile.in -=================================================================== ---- gdb-7.4.50.20120120.orig/gdb/Makefile.in 2012-03-06 07:39:41.000000000 +0100 -+++ gdb-7.4.50.20120120/gdb/Makefile.in 2012-03-06 07:39:50.771713128 +0100 -@@ -1968,6 +1968,10 @@ linux-procfs.o: $(srcdir)/common/linux-p - $(COMPILE) $(srcdir)/common/linux-procfs.c - $(POSTCOMPILE) - -+linux-ptrace.o: $(srcdir)/common/linux-ptrace.c -+ $(COMPILE) $(srcdir)/common/linux-ptrace.c -+ $(POSTCOMPILE) -+ - # - # gdb/tui/ dependencies - # -Index: gdb-7.4.50.20120120/gdb/common/linux-procfs.c -=================================================================== ---- gdb-7.4.50.20120120.orig/gdb/common/linux-procfs.c 2012-03-06 07:39:41.000000000 +0100 -+++ gdb-7.4.50.20120120/gdb/common/linux-procfs.c 2012-03-06 07:39:50.771713128 +0100 -@@ -84,3 +84,34 @@ linux_proc_pid_is_stopped (pid_t pid) - } - return retval; - } -+ -+/* See linux-procfs.h declaration. */ -+ -+int -+linux_proc_pid_is_zombie (pid_t pid) -+{ -+ char buffer[100]; -+ FILE *procfile; -+ int retval; -+ int have_state; -+ -+ xsnprintf (buffer, sizeof (buffer), "/proc/%d/status", (int) pid); -+ procfile = fopen (buffer, "r"); -+ if (procfile == NULL) -+ { -+ warning (_("unable to open /proc file '%s'"), buffer); -+ return 0; -+ } -+ -+ have_state = 0; -+ while (fgets (buffer, sizeof (buffer), procfile) != NULL) -+ if (strncmp (buffer, "State:", 6) == 0) -+ { -+ have_state = 1; -+ break; -+ } -+ retval = (have_state -+ && strcmp (buffer, "State:\tZ (zombie)\n") == 0); -+ fclose (procfile); -+ return retval; -+} -Index: gdb-7.4.50.20120120/gdb/common/linux-procfs.h -=================================================================== ---- gdb-7.4.50.20120120.orig/gdb/common/linux-procfs.h 2012-03-06 07:39:41.000000000 +0100 -+++ gdb-7.4.50.20120120/gdb/common/linux-procfs.h 2012-03-06 07:39:50.771713128 +0100 -@@ -31,4 +31,8 @@ extern int linux_proc_get_tgid (int lwpi - - extern int linux_proc_pid_is_stopped (pid_t pid); - -+/* Return non-zero if PID is a zombie. */ -+ -+extern int linux_proc_pid_is_zombie (pid_t pid); -+ - #endif /* COMMON_LINUX_PROCFS_H */ -Index: gdb-7.4.50.20120120/gdb/common/linux-ptrace.c -=================================================================== ---- /dev/null 1970-01-01 00:00:00.000000000 +0000 -+++ gdb-7.4.50.20120120/gdb/common/linux-ptrace.c 2012-03-06 07:39:50.771713128 +0100 -@@ -0,0 +1,26 @@ -+/* Linux-specific ptrace manipulation routines. -+ Copyright (C) 2012 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 . */ -+ -+#ifdef GDBSERVER -+#include "server.h" -+#else -+#include "defs.h" -+#include "gdb_string.h" -+#endif -+ -+#include "linux-ptrace.h" -Index: gdb-7.4.50.20120120/gdb/config/alpha/alpha-linux.mh -=================================================================== ---- gdb-7.4.50.20120120.orig/gdb/config/alpha/alpha-linux.mh 2012-01-10 17:30:44.000000000 +0100 -+++ gdb-7.4.50.20120120/gdb/config/alpha/alpha-linux.mh 2012-03-06 07:39:50.771713128 +0100 -@@ -2,7 +2,7 @@ - NAT_FILE= config/nm-linux.h - NATDEPFILES= inf-ptrace.o alpha-linux-nat.o \ - fork-child.o proc-service.o linux-thread-db.o \ -- linux-nat.o linux-osdata.o linux-fork.o linux-procfs.o -+ linux-nat.o linux-osdata.o linux-fork.o linux-procfs.o linux-ptrace.o - NAT_CDEPS = $(srcdir)/proc-service.list - - # The dynamically loaded libthread_db needs access to symbols in the -Index: gdb-7.4.50.20120120/gdb/config/arm/linux.mh -=================================================================== ---- gdb-7.4.50.20120120.orig/gdb/config/arm/linux.mh 2011-08-24 14:07:25.000000000 +0200 -+++ gdb-7.4.50.20120120/gdb/config/arm/linux.mh 2012-03-06 07:39:50.772713125 +0100 -@@ -3,7 +3,7 @@ - NAT_FILE= config/nm-linux.h - NATDEPFILES= inf-ptrace.o fork-child.o arm-linux-nat.o \ - proc-service.o linux-thread-db.o \ -- linux-nat.o linux-osdata.o linux-fork.o linux-procfs.o -+ linux-nat.o linux-osdata.o linux-fork.o linux-procfs.o linux-ptrace.o - NAT_CDEPS = $(srcdir)/proc-service.list - - LOADLIBES= -ldl $(RDYNAMIC) -Index: gdb-7.4.50.20120120/gdb/config/i386/linux.mh -=================================================================== ---- gdb-7.4.50.20120120.orig/gdb/config/i386/linux.mh 2012-03-06 07:39:41.000000000 +0100 -+++ gdb-7.4.50.20120120/gdb/config/i386/linux.mh 2012-03-06 07:39:50.772713125 +0100 -@@ -4,7 +4,7 @@ NAT_FILE= nm-linux.h - NATDEPFILES= inf-ptrace.o fork-child.o \ - i386-nat.o i386-linux-nat.o \ - proc-service.o linux-thread-db.o \ -- linux-nat.o linux-osdata.o linux-fork.o linux-procfs.o -+ linux-nat.o linux-osdata.o linux-fork.o linux-procfs.o linux-ptrace.o - NAT_CDEPS = $(srcdir)/proc-service.list - - # The dynamically loaded libthread_db needs access to symbols in the -Index: gdb-7.4.50.20120120/gdb/config/i386/linux64.mh -=================================================================== ---- gdb-7.4.50.20120120.orig/gdb/config/i386/linux64.mh 2012-03-06 07:39:41.000000000 +0100 -+++ gdb-7.4.50.20120120/gdb/config/i386/linux64.mh 2012-03-06 07:39:50.772713125 +0100 -@@ -3,7 +3,7 @@ NATDEPFILES= inf-ptrace.o fork-child.o \ - i386-nat.o amd64-nat.o amd64-linux-nat.o \ - linux-nat.o linux-osdata.o \ - proc-service.o linux-thread-db.o linux-fork.o \ -- linux-procfs.o -+ linux-procfs.o linux-ptrace.o - NAT_FILE= nm-linux64.h - NAT_CDEPS = $(srcdir)/proc-service.list - -Index: gdb-7.4.50.20120120/gdb/config/ia64/linux.mh -=================================================================== ---- gdb-7.4.50.20120120.orig/gdb/config/ia64/linux.mh 2012-01-10 17:30:44.000000000 +0100 -+++ gdb-7.4.50.20120120/gdb/config/ia64/linux.mh 2012-03-06 07:39:50.772713125 +0100 -@@ -5,7 +5,7 @@ NATDEPFILES= inf-ptrace.o fork-child.o \ - core-regset.o ia64-linux-nat.o \ - proc-service.o linux-thread-db.o \ - linux-nat.o linux-osdata.o linux-fork.o \ -- linux-procfs.o -+ linux-procfs.o linux-ptrace.o - NAT_CDEPS = $(srcdir)/proc-service.list - - LOADLIBES = -ldl $(RDYNAMIC) -Index: gdb-7.4.50.20120120/gdb/config/m32r/linux.mh -=================================================================== ---- gdb-7.4.50.20120120.orig/gdb/config/m32r/linux.mh 2012-01-10 17:30:44.000000000 +0100 -+++ gdb-7.4.50.20120120/gdb/config/m32r/linux.mh 2012-03-06 07:39:50.773713122 +0100 -@@ -3,7 +3,7 @@ - NAT_FILE= config/nm-linux.h - NATDEPFILES= inf-ptrace.o fork-child.o \ - m32r-linux-nat.o proc-service.o linux-thread-db.o \ -- linux-nat.o linux-osdata.o linux-fork.o linux-procfs.o -+ linux-nat.o linux-osdata.o linux-fork.o linux-procfs.o linux-ptrace.o - NAT_CDEPS = $(srcdir)/proc-service.list - - LOADLIBES= -ldl $(RDYNAMIC) -Index: gdb-7.4.50.20120120/gdb/config/m68k/linux.mh -=================================================================== ---- gdb-7.4.50.20120120.orig/gdb/config/m68k/linux.mh 2012-01-10 17:30:45.000000000 +0100 -+++ gdb-7.4.50.20120120/gdb/config/m68k/linux.mh 2012-03-06 07:39:50.773713122 +0100 -@@ -4,7 +4,7 @@ NAT_FILE= config/nm-linux.h - NATDEPFILES= inf-ptrace.o fork-child.o \ - m68klinux-nat.o \ - proc-service.o linux-thread-db.o \ -- linux-nat.o linux-osdata.o linux-fork.o linux-procfs.o -+ linux-nat.o linux-osdata.o linux-fork.o linux-procfs.o linux-ptrace.o - NAT_CDEPS = $(srcdir)/proc-service.list - - # The dynamically loaded libthread_db needs access to symbols in the -Index: gdb-7.4.50.20120120/gdb/config/mips/linux.mh -=================================================================== ---- gdb-7.4.50.20120120.orig/gdb/config/mips/linux.mh 2011-08-24 14:07:26.000000000 +0200 -+++ gdb-7.4.50.20120120/gdb/config/mips/linux.mh 2012-03-06 07:39:50.773713122 +0100 -@@ -3,7 +3,7 @@ NAT_FILE= config/nm-linux.h - NATDEPFILES= inf-ptrace.o fork-child.o mips-linux-nat.o \ - linux-thread-db.o proc-service.o \ - linux-nat.o linux-osdata.o linux-fork.o \ -- linux-procfs.o -+ linux-procfs.o linux-ptrace.o - NAT_CDEPS = $(srcdir)/proc-service.list - - LOADLIBES = -ldl $(RDYNAMIC) -Index: gdb-7.4.50.20120120/gdb/config/pa/linux.mh -=================================================================== ---- gdb-7.4.50.20120120.orig/gdb/config/pa/linux.mh 2012-01-10 17:30:45.000000000 +0100 -+++ gdb-7.4.50.20120120/gdb/config/pa/linux.mh 2012-03-06 07:39:50.773713122 +0100 -@@ -3,7 +3,7 @@ NAT_FILE= config/nm-linux.h - NATDEPFILES= inf-ptrace.o fork-child.o \ - hppa-linux-nat.o proc-service.o linux-thread-db.o \ - linux-nat.o linux-osdata.o linux-fork.o \ -- linux-procfs.o -+ linux-procfs.o linux-ptrace.o - NAT_CDEPS = $(srcdir)/proc-service.list - - LOADLIBES = -ldl $(RDYNAMIC) -Index: gdb-7.4.50.20120120/gdb/config/powerpc/linux.mh -=================================================================== ---- gdb-7.4.50.20120120.orig/gdb/config/powerpc/linux.mh 2011-08-24 14:07:27.000000000 +0200 -+++ gdb-7.4.50.20120120/gdb/config/powerpc/linux.mh 2012-03-06 07:39:50.773713122 +0100 -@@ -5,7 +5,7 @@ XM_CLIBS= - NAT_FILE= config/nm-linux.h - NATDEPFILES= inf-ptrace.o fork-child.o \ - ppc-linux-nat.o proc-service.o linux-thread-db.o \ -- linux-nat.o linux-osdata.o linux-fork.o linux-procfs.o -+ linux-nat.o linux-osdata.o linux-fork.o linux-procfs.o linux-ptrace.o - NAT_CDEPS = $(srcdir)/proc-service.list - - LOADLIBES = -ldl $(RDYNAMIC) -Index: gdb-7.4.50.20120120/gdb/config/powerpc/ppc64-linux.mh -=================================================================== ---- gdb-7.4.50.20120120.orig/gdb/config/powerpc/ppc64-linux.mh 2011-08-24 14:07:27.000000000 +0200 -+++ gdb-7.4.50.20120120/gdb/config/powerpc/ppc64-linux.mh 2012-03-06 07:39:50.774713118 +0100 -@@ -5,7 +5,7 @@ XM_CLIBS= - NAT_FILE= config/nm-linux.h - NATDEPFILES= inf-ptrace.o fork-child.o \ - ppc-linux-nat.o proc-service.o linux-thread-db.o \ -- linux-nat.o linux-osdata.o linux-fork.o linux-procfs.o -+ linux-nat.o linux-osdata.o linux-fork.o linux-procfs.o linux-ptrace.o - NAT_CDEPS = $(srcdir)/proc-service.list - - # The PowerPC has severe limitations on TOC size, and uses them even -Index: gdb-7.4.50.20120120/gdb/config/powerpc/spu-linux.mh -=================================================================== ---- gdb-7.4.50.20120120.orig/gdb/config/powerpc/spu-linux.mh 2011-08-24 14:07:27.000000000 +0200 -+++ gdb-7.4.50.20120120/gdb/config/powerpc/spu-linux.mh 2012-03-06 07:39:50.774713118 +0100 -@@ -4,5 +4,5 @@ - # PPU side of the Cell BE and debugging the SPU side. - - NATDEPFILES = spu-linux-nat.o fork-child.o inf-ptrace.o \ -- linux-procfs.o -+ linux-procfs.o linux-ptrace.o - -Index: gdb-7.4.50.20120120/gdb/config/s390/s390.mh -=================================================================== ---- gdb-7.4.50.20120120.orig/gdb/config/s390/s390.mh 2012-01-05 18:07:05.000000000 +0100 -+++ gdb-7.4.50.20120120/gdb/config/s390/s390.mh 2012-03-06 07:39:50.774713118 +0100 -@@ -2,6 +2,6 @@ - NAT_FILE= config/nm-linux.h - NATDEPFILES= inf-ptrace.o fork-child.o s390-nat.o \ - linux-thread-db.o proc-service.o \ -- linux-nat.o linux-osdata.o linux-fork.o linux-procfs.o -+ linux-nat.o linux-osdata.o linux-fork.o linux-procfs.o linux-ptrace.o - NAT_CDEPS = $(srcdir)/proc-service.list - LOADLIBES = -ldl $(RDYNAMIC) -Index: gdb-7.4.50.20120120/gdb/config/sparc/linux.mh -=================================================================== ---- gdb-7.4.50.20120120.orig/gdb/config/sparc/linux.mh 2012-01-10 17:30:49.000000000 +0100 -+++ gdb-7.4.50.20120120/gdb/config/sparc/linux.mh 2012-03-06 07:39:50.774713118 +0100 -@@ -4,7 +4,7 @@ NATDEPFILES= sparc-nat.o sparc-linux-nat - core-regset.o fork-child.o inf-ptrace.o \ - proc-service.o linux-thread-db.o \ - linux-nat.o linux-osdata.o linux-fork.o \ -- linux-procfs.o -+ linux-procfs.o linux-ptrace.o - NAT_CDEPS = $(srcdir)/proc-service.list - - # The dynamically loaded libthread_db needs access to symbols in the -Index: gdb-7.4.50.20120120/gdb/config/sparc/linux64.mh -=================================================================== ---- gdb-7.4.50.20120120.orig/gdb/config/sparc/linux64.mh 2012-01-10 17:30:49.000000000 +0100 -+++ gdb-7.4.50.20120120/gdb/config/sparc/linux64.mh 2012-03-06 07:39:50.775713114 +0100 -@@ -5,7 +5,7 @@ NATDEPFILES= sparc-nat.o sparc64-nat.o s - fork-child.o inf-ptrace.o \ - proc-service.o linux-thread-db.o \ - linux-nat.o linux-osdata.o linux-fork.o \ -- linux-procfs.o -+ linux-procfs.o linux-ptrace.o - NAT_CDEPS = $(srcdir)/proc-service.list - - # The dynamically loaded libthread_db needs access to symbols in the -Index: gdb-7.4.50.20120120/gdb/config/xtensa/linux.mh -=================================================================== ---- gdb-7.4.50.20120120.orig/gdb/config/xtensa/linux.mh 2011-08-24 14:07:27.000000000 +0200 -+++ gdb-7.4.50.20120120/gdb/config/xtensa/linux.mh 2012-03-06 07:39:50.775713114 +0100 -@@ -4,7 +4,7 @@ NAT_FILE= config/nm-linux.h - - NATDEPFILES= inf-ptrace.o fork-child.o xtensa-linux-nat.o \ - linux-thread-db.o proc-service.o \ -- linux-nat.o linux-osdata.o linux-fork.o linux-procfs.o -+ linux-nat.o linux-osdata.o linux-fork.o linux-procfs.o linux-ptrace.o - NAT_CDEPS = $(srcdir)/proc-service.list - - LOADLIBES = -ldl $(RDYNAMIC) -Index: gdb-7.4.50.20120120/gdb/gdbserver/Makefile.in -=================================================================== ---- gdb-7.4.50.20120120.orig/gdb/gdbserver/Makefile.in 2012-01-04 09:17:23.000000000 +0100 -+++ gdb-7.4.50.20120120/gdb/gdbserver/Makefile.in 2012-03-06 07:39:50.775713114 +0100 -@@ -408,6 +408,9 @@ signals.o: ../common/signals.c $(server_ - linux-procfs.o: ../common/linux-procfs.c $(server_h) - $(CC) -c $(CPPFLAGS) $(INTERNAL_CFLAGS) $< -DGDBSERVER - -+linux-ptrace.o: ../common/linux-ptrace.c $(server_h) -+ $(CC) -c $(CPPFLAGS) $(INTERNAL_CFLAGS) $< -DGDBSERVER -+ - common-utils.o: ../common/common-utils.c $(server_h) - $(CC) -c $(CPPFLAGS) $(INTERNAL_CFLAGS) $< -DGDBSERVER - -Index: gdb-7.4.50.20120120/gdb/gdbserver/configure.srv -=================================================================== ---- gdb-7.4.50.20120120.orig/gdb/gdbserver/configure.srv 2011-12-06 15:14:49.000000000 +0100 -+++ gdb-7.4.50.20120120/gdb/gdbserver/configure.srv 2012-03-06 07:39:50.775713114 +0100 -@@ -47,6 +47,7 @@ case "${target}" in - srv_regobj="${srv_regobj} arm-with-vfpv3.o" - srv_regobj="${srv_regobj} arm-with-neon.o" - srv_tgtobj="linux-low.o linux-osdata.o linux-arm-low.o linux-procfs.o" -+ srv_tgtobj="${srv_tgtobj} linux-ptrace.o" - srv_xmlfiles="arm-with-iwmmxt.xml" - srv_xmlfiles="${srv_xmlfiles} arm-with-vfpv2.xml" - srv_xmlfiles="${srv_xmlfiles} arm-with-vfpv3.xml" -@@ -69,16 +70,19 @@ case "${target}" in - ;; - bfin-*-*linux*) srv_regobj=reg-bfin.o - srv_tgtobj="linux-low.o linux-osdata.o linux-bfin-low.o linux-procfs.o" -+ srv_tgtobj="${srv_tgtobj} linux-ptrace.o" - srv_linux_usrregs=yes - srv_linux_thread_db=yes - ;; - crisv32-*-linux*) srv_regobj=reg-crisv32.o - srv_tgtobj="linux-low.o linux-osdata.o linux-crisv32-low.o linux-procfs.o" -+ srv_tgtobj="${srv_tgtobj} linux-ptrace.o" - srv_linux_regsets=yes - srv_linux_thread_db=yes - ;; - cris-*-linux*) srv_regobj=reg-cris.o - srv_tgtobj="linux-low.o linux-osdata.o linux-cris-low.o linux-procfs.o" -+ srv_tgtobj="${srv_tgtobj} linux-ptrace.o" - srv_linux_usrregs=yes - srv_linux_thread_db=yes - ;; -@@ -93,6 +97,7 @@ case "${target}" in - srv_xmlfiles="${srv_xmlfiles} $srv_amd64_linux_xmlfiles" - fi - srv_tgtobj="linux-low.o linux-osdata.o linux-x86-low.o i386-low.o i387-fp.o linux-procfs.o" -+ srv_tgtobj="${srv_tgtobj} linux-ptrace.o" - srv_linux_usrregs=yes - srv_linux_regsets=yes - srv_linux_thread_db=yes -@@ -124,10 +129,12 @@ case "${target}" in - ;; - ia64-*-linux*) srv_regobj=reg-ia64.o - srv_tgtobj="linux-low.o linux-osdata.o linux-ia64-low.o linux-procfs.o" -+ srv_tgtobj="${srv_tgtobj} linux-ptrace.o" - srv_linux_usrregs=yes - ;; - m32r*-*-linux*) srv_regobj=reg-m32r.o - srv_tgtobj="linux-low.o linux-osdata.o linux-m32r-low.o linux-procfs.o" -+ srv_tgtobj="${srv_tgtobj} linux-ptrace.o" - srv_linux_usrregs=yes - srv_linux_thread_db=yes - ;; -@@ -137,6 +144,7 @@ case "${target}" in - srv_regobj=reg-m68k.o - fi - srv_tgtobj="linux-low.o linux-osdata.o linux-m68k-low.o linux-procfs.o" -+ srv_tgtobj="${srv_tgtobj} linux-ptrace.o" - srv_linux_usrregs=yes - srv_linux_regsets=yes - srv_linux_thread_db=yes -@@ -147,12 +155,14 @@ case "${target}" in - srv_regobj=reg-m68k.o - fi - srv_tgtobj="linux-low.o linux-osdata.o linux-m68k-low.o linux-procfs.o" -+ srv_tgtobj="${srv_tgtobj} linux-ptrace.o" - srv_linux_usrregs=yes - srv_linux_regsets=yes - srv_linux_thread_db=yes - ;; - mips*-*-linux*) srv_regobj="mips-linux.o mips64-linux.o" - srv_tgtobj="linux-low.o linux-osdata.o linux-mips-low.o linux-procfs.o" -+ srv_tgtobj="${srv_tgtobj} linux-ptrace.o" - srv_xmlfiles="mips-linux.xml" - srv_xmlfiles="${srv_xmlfiles} mips-cpu.xml" - srv_xmlfiles="${srv_xmlfiles} mips-cp0.xml" -@@ -181,6 +191,7 @@ case "${target}" in - srv_regobj="${srv_regobj} powerpc-isa205-altivec64l.o" - srv_regobj="${srv_regobj} powerpc-isa205-vsx64l.o" - srv_tgtobj="linux-low.o linux-osdata.o linux-ppc-low.o linux-procfs.o" -+ srv_tgtobj="${srv_tgtobj} linux-ptrace.o" - srv_xmlfiles="rs6000/powerpc-32l.xml" - srv_xmlfiles="${srv_xmlfiles} rs6000/powerpc-altivec32l.xml" - srv_xmlfiles="${srv_xmlfiles} rs6000/powerpc-cell32l.xml" -@@ -223,6 +234,7 @@ case "${target}" in - srv_regobj="${srv_regobj} s390x-linux64v1.o" - srv_regobj="${srv_regobj} s390x-linux64v2.o" - srv_tgtobj="linux-low.o linux-osdata.o linux-s390-low.o linux-procfs.o" -+ srv_tgtobj="${srv_tgtobj} linux-ptrace.o" - srv_xmlfiles="s390-linux32.xml" - srv_xmlfiles="${srv_xmlfiles} s390-linux32v1.xml" - srv_xmlfiles="${srv_xmlfiles} s390-linux32v2.xml" -@@ -243,12 +255,14 @@ case "${target}" in - ;; - sh*-*-linux*) srv_regobj=reg-sh.o - srv_tgtobj="linux-low.o linux-osdata.o linux-sh-low.o linux-procfs.o" -+ srv_tgtobj="${srv_tgtobj} linux-ptrace.o" - srv_linux_usrregs=yes - srv_linux_regsets=yes - srv_linux_thread_db=yes - ;; - sparc*-*-linux*) srv_regobj=reg-sparc64.o - srv_tgtobj="linux-low.o linux-osdata.o linux-sparc-low.o linux-procfs.o" -+ srv_tgtobj="${srv_tgtobj} linux-ptrace.o" - srv_linux_regsets=yes - srv_linux_thread_db=yes - ;; -@@ -265,12 +279,14 @@ case "${target}" in - srv_xmlfiles="${srv_xmlfiles} tic6x-gp.xml" - srv_xmlfiles="${srv_xmlfiles} tic6x-c6xp.xml" - srv_tgtobj="linux-low.o linux-osdata.o linux-tic6x-low.o linux-procfs.o" -+ srv_tgtobj="${srv_tgtobj} linux-ptrace.o" - srv_linux_regsets=yes - srv_linux_usrregs=yes - srv_linux_thread_db=yes - ;; - x86_64-*-linux*) srv_regobj="$srv_amd64_linux_regobj $srv_i386_linux_regobj" - srv_tgtobj="linux-low.o linux-osdata.o linux-x86-low.o i386-low.o i387-fp.o linux-procfs.o" -+ srv_tgtobj="${srv_tgtobj} linux-ptrace.o" - srv_xmlfiles="$srv_i386_linux_xmlfiles $srv_amd64_linux_xmlfiles" - srv_linux_usrregs=yes # This is for i386 progs. - srv_linux_regsets=yes -@@ -285,6 +301,7 @@ case "${target}" in - - xtensa*-*-linux*) srv_regobj=reg-xtensa.o - srv_tgtobj="linux-low.o linux-osdata.o linux-xtensa-low.o linux-procfs.o" -+ srv_tgtobj="${srv_tgtobj} linux-ptrace.o" - srv_linux_regsets=yes - ;; - *) echo "Error: target not supported by gdbserver." -Index: gdb-7.4.50.20120120/gdb/gdbserver/linux-low.c -=================================================================== ---- gdb-7.4.50.20120120.orig/gdb/gdbserver/linux-low.c 2012-03-06 07:39:41.000000000 +0100 -+++ gdb-7.4.50.20120120/gdb/gdbserver/linux-low.c 2012-03-06 07:39:50.776713111 +0100 -@@ -630,10 +630,10 @@ linux_attach_lwp_1 (unsigned long lwpid, - fflush (stderr); - return; - } -- else -- /* If we fail to attach to a process, report an error. */ -- error ("Cannot attach to lwp %ld: %s (%d)\n", lwpid, -- strerror (errno), errno); -+ -+ /* If we fail to attach to a process, report an error. */ -+ error ("Cannot attach to lwp %ld: %s (%d)\n", lwpid, -+ strerror (errno), errno); - } - - if (initial) -Index: gdb-7.4.50.20120120/gdb/linux-nat.c -=================================================================== ---- gdb-7.4.50.20120120.orig/gdb/linux-nat.c 2012-03-06 07:39:41.000000000 +0100 -+++ gdb-7.4.50.20120120/gdb/linux-nat.c 2012-03-06 07:39:50.777713108 +0100 -@@ -2464,37 +2464,6 @@ linux_handle_extended_wait (struct lwp_i - _("unknown ptrace event %d"), event); - } - --/* Return non-zero if LWP is a zombie. */ -- --static int --linux_lwp_is_zombie (long lwp) --{ -- char buffer[MAXPATHLEN]; -- FILE *procfile; -- int retval; -- int have_state; -- -- xsnprintf (buffer, sizeof (buffer), "/proc/%ld/status", lwp); -- procfile = fopen (buffer, "r"); -- if (procfile == NULL) -- { -- warning (_("unable to open /proc file '%s'"), buffer); -- return 0; -- } -- -- have_state = 0; -- while (fgets (buffer, sizeof (buffer), procfile) != NULL) -- if (strncmp (buffer, "State:", 6) == 0) -- { -- have_state = 1; -- break; -- } -- retval = (have_state -- && strcmp (buffer, "State:\tZ (zombie)\n") == 0); -- fclose (procfile); -- return retval; --} -- - /* Wait for LP to stop. Returns the wait status, or 0 if the LWP has - exited. */ - -@@ -2548,10 +2517,10 @@ wait_lwp (struct lwp_info *lp) - - This is racy, what if the tgl becomes a zombie right after we check? - Therefore always use WNOHANG with sigsuspend - it is equivalent to -- waiting waitpid but the linux_lwp_is_zombie is safe this way. */ -+ waiting waitpid but linux_proc_pid_is_zombie is safe this way. */ - - if (GET_PID (lp->ptid) == GET_LWP (lp->ptid) -- && linux_lwp_is_zombie (GET_LWP (lp->ptid))) -+ && linux_proc_pid_is_zombie (GET_LWP (lp->ptid))) - { - thread_dead = 1; - if (debug_linux_nat) -@@ -3431,7 +3400,7 @@ check_zombie_leaders (void) - /* Check if there are other threads in the group, as we may - have raced with the inferior simply exiting. */ - && num_lwps (inf->pid) > 1 -- && linux_lwp_is_zombie (inf->pid)) -+ && linux_proc_pid_is_zombie (inf->pid)) - { - if (debug_linux_nat) - fprintf_unfiltered (gdb_stdlog, diff --git a/gdb-attach-fail-reasons-4of5.patch b/gdb-attach-fail-reasons-4of5.patch deleted file mode 100644 index 564ee72..0000000 --- a/gdb-attach-fail-reasons-4of5.patch +++ /dev/null @@ -1,402 +0,0 @@ -http://sourceware.org/ml/gdb-patches/2012-03/msg00170.html -Subject: [patch 2/3] attach-fail-reasons: Say more than ptrace: Operation not permitted. - -Hi, - -There is a common question on #gdb and also already described: - -http://sourceware.org/gdb/wiki/FAQ -16. Getting an internal error or other error while attaching to processes on - GNU/Linux --> - Try setenforce 0 (SELinux) or echo 0 >/proc/sys/kernel/yama/ptrace_scope - (ptrace scope) to disable system security protections. - -and here is a patch to give some explanations. - -More reasons can be given later, this is a container for them and it contains -some useful ones already. - -No regressions on {x86_64,x86_64-m32,i686}-fedora17-linux-gnu and with -non-extended gdbserver. - -The testcase does not test gdbserver, somehow it is a bit difficult without -having shell on target. - -Attaching to process 27480 -ptrace: Operation not permitted. -(gdb) _ --> -Attaching to process 27480 -warning: process 27480 is already traced by process 29011 -ptrace: Operation not permitted. -(gdb) _ - - -Thanks, -Jan - - -gdb/ -2012-03-06 Jan Kratochvil - - * common/linux-procfs.c (linux_proc_get_int): New, from - linux_proc_get_tgid. - (linux_proc_get_tgid): Only call linux_proc_get_int. - (linux_proc_get_tracerpid): New. - (linux_proc_pid_has_state): New, from linux_proc_pid_is_zombie. - (linux_proc_pid_is_stopped, linux_proc_pid_is_zombie): Only call - linux_proc_pid_has_state. - * common/linux-procfs.h (linux_proc_get_tracerpid): New declaration. - * common/linux-ptrace.c: Include linux-procfs.h. - (linux_ptrace_attach_warnings): New. - * common/linux-ptrace.h (linux_ptrace_attach_warnings): New declaration. - * linux-nat.c: Include exceptions.h and linux-ptrace.h. - (linux_nat_attach): New variable ex. Wrap to_attach by TRY_CATCH and - call linux_ptrace_attach_warnings. - -gdb/gdbserver/ -2012-03-06 Jan Kratochvil - - * linux-low.c (linux_attach_lwp_1): Call linux_ptrace_attach_warnings. - -gdb/testsuite/ -2012-03-06 Jan Kratochvil - - * gdb.base/attach-twice.c: New files. - * gdb.base/attach-twice.exp: New files. - -Index: gdb-7.4.50.20120120/gdb/common/linux-procfs.c -=================================================================== ---- gdb-7.4.50.20120120.orig/gdb/common/linux-procfs.c 2012-03-06 07:34:00.000000000 +0100 -+++ gdb-7.4.50.20120120/gdb/common/linux-procfs.c 2012-03-06 07:34:17.586816449 +0100 -@@ -28,67 +28,54 @@ - /* Return the TGID of LWPID from /proc/pid/status. Returns -1 if not - found. */ - --int --linux_proc_get_tgid (int lwpid) -+static int -+linux_proc_get_int (int lwpid, const char *field) - { -+ size_t field_len = strlen (field); - FILE *status_file; - char buf[100]; -- int tgid = -1; -+ int retval = -1; - - snprintf (buf, sizeof (buf), "/proc/%d/status", (int) lwpid); - status_file = fopen (buf, "r"); -- if (status_file != NULL) -+ if (status_file == NULL) - { -- while (fgets (buf, sizeof (buf), status_file)) -- { -- if (strncmp (buf, "Tgid:", 5) == 0) -- { -- tgid = strtoul (buf + strlen ("Tgid:"), NULL, 10); -- break; -- } -- } -- -- fclose (status_file); -+ warning (_("unable to open /proc file '%s'"), buf); -+ return -1; - } - -- return tgid; -+ while (fgets (buf, sizeof (buf), status_file)) -+ if (strncmp (buf, field, field_len) == 0 && buf[field_len] == ':') -+ { -+ retval = strtol (&buf[field_len + 1], NULL, 10); -+ break; -+ } -+ -+ fclose (status_file); -+ return retval; - } - --/* Detect `T (stopped)' in `/proc/PID/status'. -- Other states including `T (tracing stop)' are reported as false. */ -+/* Return the TGID of LWPID from /proc/pid/status. Returns -1 if not -+ found. */ - - int --linux_proc_pid_is_stopped (pid_t pid) -+linux_proc_get_tgid (int lwpid) - { -- FILE *status_file; -- char buf[100]; -- int retval = 0; -+ return linux_proc_get_int (lwpid, "Tgid"); -+} - -- snprintf (buf, sizeof (buf), "/proc/%d/status", (int) pid); -- status_file = fopen (buf, "r"); -- if (status_file != NULL) -- { -- int have_state = 0; -+/* See linux-procfs.h. */ - -- while (fgets (buf, sizeof (buf), status_file)) -- { -- if (strncmp (buf, "State:", 6) == 0) -- { -- have_state = 1; -- break; -- } -- } -- if (have_state && strstr (buf, "T (stopped)") != NULL) -- retval = 1; -- fclose (status_file); -- } -- return retval; -+pid_t -+linux_proc_get_tracerpid (int lwpid) -+{ -+ return linux_proc_get_int (lwpid, "TracerPid"); - } - --/* See linux-procfs.h declaration. */ -+/* Return non-zero if 'State' of /proc/PID/status contains STATE. */ - --int --linux_proc_pid_is_zombie (pid_t pid) -+static int -+linux_proc_pid_has_state (pid_t pid, const char *state) - { - char buffer[100]; - FILE *procfile; -@@ -110,8 +97,24 @@ linux_proc_pid_is_zombie (pid_t pid) - have_state = 1; - break; - } -- retval = (have_state -- && strcmp (buffer, "State:\tZ (zombie)\n") == 0); -+ retval = (have_state && strstr (buffer, state) != NULL); - fclose (procfile); - return retval; - } -+ -+/* Detect `T (stopped)' in `/proc/PID/status'. -+ Other states including `T (tracing stop)' are reported as false. */ -+ -+int -+linux_proc_pid_is_stopped (pid_t pid) -+{ -+ return linux_proc_pid_has_state (pid, "T (stopped)"); -+} -+ -+/* See linux-procfs.h declaration. */ -+ -+int -+linux_proc_pid_is_zombie (pid_t pid) -+{ -+ return linux_proc_pid_has_state (pid, "Z (zombie)"); -+} -Index: gdb-7.4.50.20120120/gdb/common/linux-procfs.h -=================================================================== ---- gdb-7.4.50.20120120.orig/gdb/common/linux-procfs.h 2012-03-06 07:34:00.000000000 +0100 -+++ gdb-7.4.50.20120120/gdb/common/linux-procfs.h 2012-03-06 07:34:17.586816449 +0100 -@@ -26,6 +26,11 @@ - - extern int linux_proc_get_tgid (int lwpid); - -+/* Return the TracerPid of LWPID from /proc/pid/status. Returns -1 if not -+ found. */ -+ -+extern pid_t linux_proc_get_tracerpid (int lwpid); -+ - /* Detect `T (stopped)' in `/proc/PID/status'. - Other states including `T (tracing stop)' are reported as false. */ - -Index: gdb-7.4.50.20120120/gdb/common/linux-ptrace.c -=================================================================== ---- gdb-7.4.50.20120120.orig/gdb/common/linux-ptrace.c 2012-03-06 07:34:00.000000000 +0100 -+++ gdb-7.4.50.20120120/gdb/common/linux-ptrace.c 2012-03-06 07:34:17.586816449 +0100 -@@ -24,3 +24,21 @@ - #endif - - #include "linux-ptrace.h" -+#include "linux-procfs.h" -+ -+/* Print all possible reasons we could fail to attach PID. */ -+ -+void -+linux_ptrace_attach_warnings (pid_t pid) -+{ -+ pid_t tracerpid; -+ -+ tracerpid = linux_proc_get_tracerpid (pid); -+ if (tracerpid > 0) -+ warning (_("process %d is already traced by process %d"), (int) pid, -+ (int) tracerpid); -+ -+ if (linux_proc_pid_is_zombie (pid)) -+ warning (_("process %d is a zombie - the process has already terminated"), -+ (int) pid); -+} -Index: gdb-7.4.50.20120120/gdb/common/linux-ptrace.h -=================================================================== ---- gdb-7.4.50.20120120.orig/gdb/common/linux-ptrace.h 2012-01-04 09:17:18.000000000 +0100 -+++ gdb-7.4.50.20120120/gdb/common/linux-ptrace.h 2012-03-06 07:34:17.586816449 +0100 -@@ -65,4 +65,6 @@ - #define __WALL 0x40000000 /* Wait for any child. */ - #endif - -+extern void linux_ptrace_attach_warnings (pid_t pid); -+ - #endif /* COMMON_LINUX_PTRACE_H */ -Index: gdb-7.4.50.20120120/gdb/gdbserver/linux-low.c -=================================================================== ---- gdb-7.4.50.20120120.orig/gdb/gdbserver/linux-low.c 2012-03-06 07:34:00.000000000 +0100 -+++ gdb-7.4.50.20120120/gdb/gdbserver/linux-low.c 2012-03-06 07:34:17.587816446 +0100 -@@ -632,6 +632,7 @@ linux_attach_lwp_1 (unsigned long lwpid, - } - - /* If we fail to attach to a process, report an error. */ -+ linux_ptrace_attach_warnings (lwpid); - error ("Cannot attach to lwp %ld: %s (%d)\n", lwpid, - strerror (errno), errno); - } -Index: gdb-7.4.50.20120120/gdb/linux-nat.c -=================================================================== ---- gdb-7.4.50.20120120.orig/gdb/linux-nat.c 2012-03-06 07:34:00.000000000 +0100 -+++ gdb-7.4.50.20120120/gdb/linux-nat.c 2012-03-06 07:34:29.860775803 +0100 -@@ -59,6 +59,8 @@ - #include "solib.h" - #include "linux-osdata.h" - #include "cli/cli-utils.h" -+#include "exceptions.h" -+#include "linux-ptrace.h" - - #ifndef SPUFS_MAGIC - #define SPUFS_MAGIC 0x23c9b64e -@@ -1613,11 +1615,22 @@ linux_nat_attach (struct target_ops *ops - struct lwp_info *lp; - int status; - ptid_t ptid; -+ volatile struct gdb_exception ex; - - /* Make sure we report all signals during attach. */ - linux_nat_pass_signals (0, NULL); - -- linux_ops->to_attach (ops, args, from_tty); -+ TRY_CATCH (ex, RETURN_MASK_ERROR) -+ { -+ linux_ops->to_attach (ops, args, from_tty); -+ } -+ if (ex.reason < 0) -+ { -+ pid_t pid = parse_pid_to_attach (args); -+ -+ linux_ptrace_attach_warnings (pid); -+ throw_exception (ex); -+ } - - /* The ptrace base target adds the main thread with (pid,0,0) - format. Decorate it with lwp info. */ -Index: gdb-7.4.50.20120120/gdb/testsuite/gdb.base/attach-twice.c -=================================================================== ---- /dev/null 1970-01-01 00:00:00.000000000 +0000 -+++ gdb-7.4.50.20120120/gdb/testsuite/gdb.base/attach-twice.c 2012-03-06 07:34:17.589816440 +0100 -@@ -0,0 +1,42 @@ -+/* This testcase is part of GDB, the GNU debugger. -+ -+ Copyright 2011-2012 Free Software Foundation, Inc. -+ -+ This program is free software; you can redistribute it and/or modify -+ it under the terms of the GNU General Public License as published by -+ the Free Software Foundation; either version 3 of the License, or -+ (at your option) any later version. -+ -+ This program is distributed in the hope that it will be useful, -+ but WITHOUT ANY WARRANTY; without even the implied warranty of -+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+ GNU General Public License for more details. -+ -+ You should have received a copy of the GNU General Public License -+ along with this program. If not, see . */ -+ -+#include -+#include -+#include -+#include -+ -+int -+main (void) -+{ -+ long l; -+ -+ switch (fork ()) -+ { -+ case -1: -+ perror ("fork"); -+ exit (1); -+ case 0: -+ errno = 0; -+ ptrace (PTRACE_ATTACH, getppid (), NULL, NULL); -+ if (errno != 0) -+ perror ("PTRACE_ATTACH"); -+ break; -+ } -+ sleep (600); -+ return 0; -+} -Index: gdb-7.4.50.20120120/gdb/testsuite/gdb.base/attach-twice.exp -=================================================================== ---- /dev/null 1970-01-01 00:00:00.000000000 +0000 -+++ gdb-7.4.50.20120120/gdb/testsuite/gdb.base/attach-twice.exp 2012-03-06 07:34:17.589816440 +0100 -@@ -0,0 +1,52 @@ -+# Copyright (C) 2012 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 . -+ -+# Manipulation with PID on target is not supported. -+if [is_remote target] then { -+ return 0 -+} -+ -+set testfile attach-twice -+set executable ${testfile} -+set binfile ${objdir}/${subdir}/${executable} -+ -+if { [prepare_for_testing ${testfile}.exp $executable] } { -+ return -1 -+} -+ -+set testpid [eval exec $binfile &] -+exec sleep 2 -+ -+set parentpid 0 -+ -+set test "attach" -+gdb_test_multiple "attach $testpid" $test { -+ -re "Attaching to program: \[^\r\n\]*, process $testpid\r\n.*warning: process $testpid is already traced by process (\[0-9\]+)\r\n.*ptrace: Operation not permitted\\.\r\n$gdb_prompt $" { -+ set parentpid $expect_out(1,string) -+ pass $test -+ } -+ -re "Attaching to program: \[^\r\n\]*, process $testpid\r\n.*ptrace: Operation not permitted\\.\r\n$gdb_prompt $" { -+ fail $test -+ } -+ -re "\r\n$gdb_prompt $" { -+ xfail $test -+ } -+} -+ -+eval exec ps xfw -+if {$parentpid != 0} { -+ eval exec kill -9 $parentpid -+} -+eval exec kill -9 $testpid diff --git a/gdb-attach-fail-reasons-5of5.patch b/gdb-attach-fail-reasons-5of5.patch index aa4a44f..bf95e7c 100644 --- a/gdb-attach-fail-reasons-5of5.patch +++ b/gdb-attach-fail-reasons-5of5.patch @@ -37,53 +37,60 @@ gdb/gdbserver/ (linux_create_inferior, linux_tracefork_child): Call it instead of direct ptrace. ---- a/gdb/common/linux-ptrace.c -+++ b/gdb/common/linux-ptrace.c -@@ -26,6 +26,10 @@ - #include "linux-ptrace.h" +Index: gdb-7.4.50.20120602/gdb/common/linux-ptrace.c +=================================================================== +--- gdb-7.4.50.20120602.orig/gdb/common/linux-ptrace.c 2012-03-13 16:02:23.000000000 +0100 ++++ gdb-7.4.50.20120602/gdb/common/linux-ptrace.c 2012-06-02 20:37:53.933828570 +0200 +@@ -27,6 +27,10 @@ #include "linux-procfs.h" + #include "buffer.h" +#ifdef HAVE_SELINUX_SELINUX_H +# include +#endif /* HAVE_SELINUX_SELINUX_H */ + - /* Print all possible reasons we could fail to attach PID. */ - - void -@@ -41,4 +45,21 @@ linux_ptrace_attach_warnings (pid_t pid) - if (linux_proc_pid_is_zombie (pid)) - warning (_("process %d is a zombie - the process has already terminated"), - (int) pid); + /* Find all possible reasons we could fail to attach PID and append these + newline terminated reason strings to initialized BUFFER. '\0' termination + of BUFFER must be done by the caller. */ +@@ -46,4 +50,22 @@ linux_ptrace_attach_warnings (pid_t pid, + buffer_xml_printf (buffer, _("warning: process %d is a zombie " + "- the process has already terminated\n"), + (int) pid); + -+ linux_ptrace_create_warnings (); ++ linux_ptrace_create_warnings (buffer); +} + +/* Print all possible reasons we could fail to create a traced process. */ + +void -+linux_ptrace_create_warnings (void) ++linux_ptrace_create_warnings (struct buffer *buffer) +{ +#ifdef HAVE_LIBSELINUX + /* -1 is returned for errors, 0 if it has no effect, 1 if PTRACE_ATTACH is + forbidden. */ + if (security_get_boolean_active ("deny_ptrace") == 1) -+ warning (_("the SELinux boolean 'deny_ptrace' is enabled, " -+ "you can disable this process attach protection by: " -+ "(gdb) shell sudo setsebool deny_ptrace=0")); ++ buffer_xml_printf (buffer, ++ _("the SELinux boolean 'deny_ptrace' is enabled, " ++ "you can disable this process attach protection by: " ++ "(gdb) shell sudo setsebool deny_ptrace=0")); +#endif /* HAVE_LIBSELINUX */ } ---- a/gdb/common/linux-ptrace.h -+++ b/gdb/common/linux-ptrace.h -@@ -66,5 +66,6 @@ +Index: gdb-7.4.50.20120602/gdb/common/linux-ptrace.h +=================================================================== +--- gdb-7.4.50.20120602.orig/gdb/common/linux-ptrace.h 2012-03-13 16:02:23.000000000 +0100 ++++ gdb-7.4.50.20120602/gdb/common/linux-ptrace.h 2012-06-02 20:37:46.565831956 +0200 +@@ -68,5 +68,6 @@ struct buffer; #endif - extern void linux_ptrace_attach_warnings (pid_t pid); -+extern void linux_ptrace_create_warnings (void); + extern void linux_ptrace_attach_warnings (pid_t pid, struct buffer *buffer); ++extern void linux_ptrace_create_warnings (struct buffer *buffer); #endif /* COMMON_LINUX_PTRACE_H */ ---- a/gdb/configure.ac -+++ b/gdb/configure.ac -@@ -1748,6 +1748,10 @@ then +Index: gdb-7.4.50.20120602/gdb/configure.ac +=================================================================== +--- gdb-7.4.50.20120602.orig/gdb/configure.ac 2012-06-02 20:05:08.000000000 +0200 ++++ gdb-7.4.50.20120602/gdb/configure.ac 2012-06-02 20:35:06.379798726 +0200 +@@ -2002,6 +2002,10 @@ then [Define if you support the personality syscall.]) fi @@ -94,9 +101,11 @@ gdb/gdbserver/ dnl Handle optional features that can be enabled. # Support for --with-sysroot is a copy of GDB_AC_WITH_DIR, ---- a/gdb/gdbserver/configure.ac -+++ b/gdb/gdbserver/configure.ac -@@ -411,6 +411,10 @@ if $want_ipa ; then +Index: gdb-7.4.50.20120602/gdb/gdbserver/configure.ac +=================================================================== +--- gdb-7.4.50.20120602.orig/gdb/gdbserver/configure.ac 2012-04-19 21:34:51.000000000 +0200 ++++ gdb-7.4.50.20120602/gdb/gdbserver/configure.ac 2012-06-02 20:35:06.408797663 +0200 +@@ -438,6 +438,10 @@ if $want_ipa ; then fi fi @@ -107,9 +116,11 @@ gdb/gdbserver/ AC_SUBST(GDBSERVER_DEPFILES) AC_SUBST(GDBSERVER_LIBS) AC_SUBST(USE_THREAD_DB) ---- a/gdb/gdbserver/linux-low.c -+++ b/gdb/gdbserver/linux-low.c -@@ -550,6 +550,25 @@ add_lwp (ptid_t ptid) +Index: gdb-7.4.50.20120602/gdb/gdbserver/linux-low.c +=================================================================== +--- gdb-7.4.50.20120602.orig/gdb/gdbserver/linux-low.c 2012-05-30 21:51:38.000000000 +0200 ++++ gdb-7.4.50.20120602/gdb/gdbserver/linux-low.c 2012-06-02 20:39:49.886785355 +0200 +@@ -601,6 +601,28 @@ add_lwp (ptid_t ptid) return lwp; } @@ -119,15 +130,18 @@ gdb/gdbserver/ +linux_traceme (const char *program) +{ + int save_errno; ++ struct buffer buffer; + + errno = 0; + if (ptrace (PTRACE_TRACEME, 0, NULL, NULL) == 0) + return; + + save_errno = errno; -+ linux_ptrace_create_warnings (); -+ fprintf (stderr, _("Cannot trace created process %s: %s.\n"), program, -+ strerror (save_errno)); ++ buffer_init (&buffer); ++ linux_ptrace_create_warnings (&buffer); ++ buffer_grow_str0 (&buffer, ""); ++ fprintf (stderr, _("%sCannot trace created process %s: %s.\n"), ++ buffer_finish (&buffer), program, strerror (save_errno)); + fflush (stderr); + _exit (0177); +} @@ -135,7 +149,7 @@ gdb/gdbserver/ /* Start an inferior process and returns its pid. ALLARGS is a vector of program-name and args. */ -@@ -590,7 +609,7 @@ linux_create_inferior (char *program, char **allargs) +@@ -641,7 +663,7 @@ linux_create_inferior (char *program, ch if (pid == 0) { @@ -144,7 +158,7 @@ gdb/gdbserver/ #ifndef __ANDROID__ /* Bionic doesn't use SIGRTMIN the way glibc does. */ signal (__SIGRTMIN + 1, SIG_DFL); -@@ -4386,7 +4405,7 @@ linux_tracefork_grandchild (void *arg) +@@ -4567,7 +4589,7 @@ linux_tracefork_grandchild (void *arg) static int linux_tracefork_child (void *arg) { @@ -153,8 +167,10 @@ gdb/gdbserver/ kill (getpid (), SIGSTOP); #if !(defined(__UCLIBC__) && defined(HAS_NOMMU)) ---- a/gdb/inf-ptrace.c -+++ b/gdb/inf-ptrace.c +Index: gdb-7.4.50.20120602/gdb/inf-ptrace.c +=================================================================== +--- gdb-7.4.50.20120602.orig/gdb/inf-ptrace.c 2012-05-24 18:51:34.000000000 +0200 ++++ gdb-7.4.50.20120602/gdb/inf-ptrace.c 2012-06-02 20:35:06.428797311 +0200 @@ -105,7 +105,15 @@ static void inf_ptrace_me (void) { @@ -171,9 +187,11 @@ gdb/gdbserver/ } /* Start a new inferior Unix child process. EXEC_FILE is the file to ---- a/gdb/linux-nat.c -+++ b/gdb/linux-nat.c -@@ -1570,6 +1570,7 @@ linux_nat_create_inferior (struct target_ops *ops, +Index: gdb-7.4.50.20120602/gdb/linux-nat.c +=================================================================== +--- gdb-7.4.50.20120602.orig/gdb/linux-nat.c 2012-06-02 20:01:38.000000000 +0200 ++++ gdb-7.4.50.20120602/gdb/linux-nat.c 2012-06-02 20:41:18.101751186 +0200 +@@ -1572,6 +1572,7 @@ linux_nat_create_inferior (struct target #ifdef HAVE_PERSONALITY int personality_orig = 0, personality_set = 0; #endif /* HAVE_PERSONALITY */ @@ -181,7 +199,7 @@ gdb/gdbserver/ /* The fork_child mechanism is synchronous and calls target_wait, so we have to mask the async mode. */ -@@ -1594,7 +1595,10 @@ linux_nat_create_inferior (struct target_ops *ops, +@@ -1596,7 +1597,10 @@ linux_nat_create_inferior (struct target /* Make sure we report all signals during startup. */ linux_nat_pass_signals (0, NULL); @@ -193,17 +211,28 @@ gdb/gdbserver/ #ifdef HAVE_PERSONALITY if (personality_set) -@@ -1606,6 +1610,12 @@ linux_nat_create_inferior (struct target_ops *ops, +@@ -1608,6 +1612,24 @@ linux_nat_create_inferior (struct target safe_strerror (errno)); } #endif /* HAVE_PERSONALITY */ + + if (ex.reason < 0) + { -+ linux_ptrace_create_warnings (); -+ throw_exception (ex); ++ struct buffer buffer; ++ char *message, *buffer_s; ++ ++ message = xstrdup (ex.message); ++ make_cleanup (xfree, message); ++ ++ buffer_init (&buffer); ++ linux_ptrace_create_warnings (&buffer); ++ ++ buffer_grow_str0 (&buffer, ""); ++ buffer_s = buffer_finish (&buffer); ++ make_cleanup (xfree, buffer_s); ++ ++ throw_error (ex.error, "%s%s", buffer_s, message); + } } static void - diff --git a/gdb-attach-fail-reasons-5of5configure.patch b/gdb-attach-fail-reasons-5of5configure.patch index ea1b3fc..6098645 100644 --- a/gdb-attach-fail-reasons-5of5configure.patch +++ b/gdb-attach-fail-reasons-5of5configure.patch @@ -1,16 +1,18 @@ ---- 1/gdb/config.in 2012-03-09 18:40:28.001871023 +0100 -+++ ./gdb/config.in 2012-03-09 18:41:46.552621113 +0100 -@@ -245,6 +245,9 @@ +Index: gdb-7.4.50.20120602/gdb/config.in +=================================================================== +--- gdb-7.4.50.20120602.orig/gdb/config.in 2012-06-02 21:49:26.147399232 +0200 ++++ gdb-7.4.50.20120602/gdb/config.in 2012-06-02 21:49:27.206398845 +0200 +@@ -222,6 +222,9 @@ /* Define if librpm library is being used. */ #undef HAVE_LIBRPM +/* Define to 1 if you have the `selinux' library (-lselinux). */ +#undef HAVE_LIBSELINUX + - /* Define if libunwind library is being used. */ - #undef HAVE_LIBUNWIND + /* Define to 1 if you have the header file. */ + #undef HAVE_LIBUNWIND_IA64_H -@@ -483,6 +486,9 @@ +@@ -363,6 +366,9 @@ /* Define to 1 if you have the `sbrk' function. */ #undef HAVE_SBRK @@ -20,9 +22,11 @@ /* Define to 1 if you have the `setlocale' function. */ #undef HAVE_SETLOCALE ---- 1/gdb/configure 2012-03-09 18:40:28.183870443 +0100 -+++ ./gdb/configure 2012-03-09 18:41:45.783623559 +0100 -@@ -15557,6 +15557,64 @@ $as_echo "#define HAVE_PERSONALITY 1" >> +Index: gdb-7.4.50.20120602/gdb/configure +=================================================================== +--- gdb-7.4.50.20120602.orig/gdb/configure 2012-06-02 21:49:27.139398869 +0200 ++++ gdb-7.4.50.20120602/gdb/configure 2012-06-02 21:49:50.890390179 +0200 +@@ -12745,6 +12745,64 @@ $as_echo "#define HAVE_PERSONALITY 1" >> fi @@ -87,3 +91,96 @@ # Support for --with-sysroot is a copy of GDB_AC_WITH_DIR, # except that the argument to --with-sysroot is optional. +Index: gdb-7.4.50.20120602/gdb/gdbserver/config.in +=================================================================== +--- gdb-7.4.50.20120602.orig/gdb/gdbserver/config.in 2012-04-19 21:34:51.000000000 +0200 ++++ gdb-7.4.50.20120602/gdb/gdbserver/config.in 2012-06-02 21:49:55.945388329 +0200 +@@ -69,6 +69,9 @@ + /* Define to 1 if you have the `dl' library (-ldl). */ + #undef HAVE_LIBDL + ++/* Define to 1 if you have the `selinux' library (-lselinux). */ ++#undef HAVE_LIBSELINUX ++ + /* Define to 1 if you have the header file. */ + #undef HAVE_LINUX_ELF_H + +@@ -130,6 +133,9 @@ + /* Define to 1 if you have the `readlink' function. */ + #undef HAVE_READLINK + ++/* Define to 1 if you have the header file. */ ++#undef HAVE_SELINUX_SELINUX_H ++ + /* Define to 1 if you have the header file. */ + #undef HAVE_SGTTY_H + +Index: gdb-7.4.50.20120602/gdb/gdbserver/configure +=================================================================== +--- gdb-7.4.50.20120602.orig/gdb/gdbserver/configure 2012-04-20 19:58:49.000000000 +0200 ++++ gdb-7.4.50.20120602/gdb/gdbserver/configure 2012-06-02 21:49:54.485388864 +0200 +@@ -5532,6 +5532,64 @@ if $want_ipa ; then + fi + fi + ++for ac_header in selinux/selinux.h ++do : ++ ac_fn_c_check_header_mongrel "$LINENO" "selinux/selinux.h" "ac_cv_header_selinux_selinux_h" "$ac_includes_default" ++if test "x$ac_cv_header_selinux_selinux_h" = x""yes; then : ++ cat >>confdefs.h <<_ACEOF ++#define HAVE_SELINUX_SELINUX_H 1 ++_ACEOF ++ ++fi ++ ++done ++ ++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for security_get_boolean_active in -lselinux" >&5 ++$as_echo_n "checking for security_get_boolean_active in -lselinux... " >&6; } ++if test "${ac_cv_lib_selinux_security_get_boolean_active+set}" = set; then : ++ $as_echo_n "(cached) " >&6 ++else ++ ac_check_lib_save_LIBS=$LIBS ++LIBS="-lselinux $LIBS" ++cat confdefs.h - <<_ACEOF >conftest.$ac_ext ++/* end confdefs.h. */ ++ ++/* Override any GCC internal prototype to avoid an error. ++ Use char because int might match the return type of a GCC ++ builtin and then its argument prototype would still apply. */ ++#ifdef __cplusplus ++extern "C" ++#endif ++char security_get_boolean_active (); ++int ++main () ++{ ++return security_get_boolean_active (); ++ ; ++ return 0; ++} ++_ACEOF ++if ac_fn_c_try_link "$LINENO"; then : ++ ac_cv_lib_selinux_security_get_boolean_active=yes ++else ++ ac_cv_lib_selinux_security_get_boolean_active=no ++fi ++rm -f core conftest.err conftest.$ac_objext \ ++ conftest$ac_exeext conftest.$ac_ext ++LIBS=$ac_check_lib_save_LIBS ++fi ++{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_selinux_security_get_boolean_active" >&5 ++$as_echo "$ac_cv_lib_selinux_security_get_boolean_active" >&6; } ++if test "x$ac_cv_lib_selinux_security_get_boolean_active" = x""yes; then : ++ cat >>confdefs.h <<_ACEOF ++#define HAVE_LIBSELINUX 1 ++_ACEOF ++ ++ LIBS="-lselinux $LIBS" ++ ++fi ++ ++ + + + diff --git a/gdb-autoload-01of28.patch b/gdb-autoload-01of28.patch deleted file mode 100644 index d32b21f..0000000 --- a/gdb-autoload-01of28.patch +++ /dev/null @@ -1,65 +0,0 @@ -http://sourceware.org/ml/gdb-cvs/2012-01/msg00202.html - -### src/gdb/ChangeLog 2012/01/24 19:12:31 1.13771 -### src/gdb/ChangeLog 2012/01/24 20:56:33 1.13772 -## -1,3 +1,12 @@ -+2012-01-24 Jan Kratochvil -+ -+ Code cleanup. -+ * cli/cli-cmds.c (source_script_from_stream): Never fclose STREAM. -+ Update the function comment for it. -+ (source_script_with_search): Call make_cleanup_fclose for STREAM. -+ * cli/cli-script.c (script_from_file): Do not call make_cleanup_fclose -+ for STREAM. -+ - 2012-01-24 Pedro Alves - - * breakpoint.c (bpstat_stop_status): Moving clearing print_it ---- src/gdb/cli/cli-cmds.c 2012/01/23 16:37:03 1.123 -+++ src/gdb/cli/cli-cmds.c 2012/01/24 20:56:33 1.124 -@@ -527,8 +527,7 @@ - return 1; - } - --/* Load script FILE, which has already been opened as STREAM. -- STREAM is closed before we return. */ -+/* Load script FILE, which has already been opened as STREAM. */ - - static void - source_script_from_stream (FILE *stream, const char *file) -@@ -556,12 +555,9 @@ - else - { - /* Nope, just punt. */ -- fclose (stream); - throw_exception (e); - } - } -- else -- fclose (stream); - } - else - script_from_file (stream, file); -@@ -595,6 +591,7 @@ - } - - old_cleanups = make_cleanup (xfree, full_path); -+ make_cleanup_fclose (stream); - /* The python support reopens the file, so we need to pass full_path here - in case the file was found on the search path. It's useful to do this - anyway so that error messages show the actual file used. But only do ---- src/gdb/cli/cli-script.c 2012/01/04 08:17:17 1.73 -+++ src/gdb/cli/cli-script.c 2012/01/24 20:56:33 1.74 -@@ -1614,11 +1614,9 @@ - if (stream == NULL) - internal_error (__FILE__, __LINE__, _("called with NULL file pointer!")); - -- old_cleanups = make_cleanup_fclose (stream); -- - old_lines.old_line = source_line_number; - old_lines.old_file = source_file_name; -- make_cleanup (source_cleanup_lines, &old_lines); -+ old_cleanups = make_cleanup (source_cleanup_lines, &old_lines); - source_line_number = 0; - source_file_name = file; - /* This will get set every time we read a line. So it won't stay "" diff --git a/gdb-autoload-02of28.patch b/gdb-autoload-02of28.patch deleted file mode 100644 index b44c9bb..0000000 --- a/gdb-autoload-02of28.patch +++ /dev/null @@ -1,103 +0,0 @@ -http://sourceware.org/ml/gdb-cvs/2012-01/msg00205.html - ---- src/gdb/gdb_vecs.h -+++ src/gdb/gdb_vecs.h 2012-04-17 22:04:23.818666000 +0000 -@@ -0,0 +1,28 @@ -+/* Some commonly-used VEC types. -+ -+ Copyright (C) 2012 Free Software Foundation, Inc. -+ -+ This file is part of GDB. -+ -+ This program is free software; you can redistribute it and/or modify -+ it under the terms of the GNU General Public License as published by -+ the Free Software Foundation; either version 3 of the License, or -+ (at your option) any later version. -+ -+ This program is distributed in the hope that it will be useful, -+ but WITHOUT ANY WARRANTY; without even the implied warranty of -+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+ GNU General Public License for more details. -+ -+ You should have received a copy of the GNU General Public License -+ along with this program. If not, see . */ -+ -+ -+#ifndef GDB_VECS_H -+#define GDB_VECS_H -+ -+#include "vec.h" -+ -+DEF_VEC_P (char_ptr); -+ -+#endif /* GDB_VECS_H */ -### src/gdb/ChangeLog 2012/01/24 21:32:56 1.13774 -### src/gdb/ChangeLog 2012/01/24 21:36:37 1.13775 -## -1,3 +1,10 @@ -+2012-01-24 Tom Tromey -+ -+ * ada-lang.c: Include gdb_vecs.h. -+ * charset.c: Include gdb_vecs.h. -+ * tracepoint.h: Include gdb_vecs.h. -+ * gdb_vecs.h: New file. -+ - 2012-01-24 Pedro Alves - - * breakpoint.c (breakpoint_hit_catch_fork) ---- src/gdb/ada-lang.c 2012/01/06 03:34:45 1.330 -+++ src/gdb/ada-lang.c 2012/01/24 21:36:37 1.331 -@@ -57,6 +57,7 @@ - #include "observer.h" - #include "vec.h" - #include "stack.h" -+#include "gdb_vecs.h" - - #include "psymtab.h" - #include "value.h" -@@ -5628,8 +5629,6 @@ - return sym_name; - } - --DEF_VEC_P (char_ptr); -- - /* A companion function to ada_make_symbol_completion_list(). - Check if SYM_NAME represents a symbol which name would be suitable - to complete TEXT (TEXT_LEN is the length of TEXT), in which case ---- src/gdb/charset.c 2012/01/04 08:17:00 1.46 -+++ src/gdb/charset.c 2012/01/24 21:36:37 1.47 -@@ -27,6 +27,7 @@ - #include "vec.h" - #include "environ.h" - #include "arch-utils.h" -+#include "gdb_vecs.h" - - #include - #include "gdb_string.h" -@@ -717,8 +718,6 @@ - - extern initialize_file_ftype _initialize_charset; /* -Wmissing-prototype */ - --DEF_VEC_P (char_ptr); -- - static VEC (char_ptr) *charsets; - - #ifdef PHONY_ICONV ---- src/gdb/tracepoint.h 2012/01/04 08:27:57 1.46 -+++ src/gdb/tracepoint.h 2012/01/24 21:36:37 1.47 -@@ -22,6 +22,7 @@ - #include "breakpoint.h" - #include "target.h" - #include "memrange.h" -+#include "gdb_vecs.h" - - /* A trace state variable is a value managed by a target being - traced. A trace state variable (or tsv for short) can be accessed -@@ -143,8 +144,6 @@ - - /* Struct to collect random info about tracepoints on the target. */ - --DEF_VEC_P (char_ptr); -- - struct uploaded_tp - { - int number; diff --git a/gdb-autoload-03of28.patch b/gdb-autoload-03of28.patch deleted file mode 100644 index c0efc8c..0000000 --- a/gdb-autoload-03of28.patch +++ /dev/null @@ -1,215 +0,0 @@ -http://sourceware.org/ml/gdb-cvs/2012-01/msg00219.html - -### src/gdb/ChangeLog 2012/01/26 16:44:29 1.13780 -### src/gdb/ChangeLog 2012/01/26 21:54:42 1.13781 -## -1,3 +1,22 @@ -+2012-01-26 Jan Kratochvil -+ -+ Do not open script filenames twice. -+ * cli/cli-cmds.c (source_script_from_stream): Pass to -+ source_python_script also STREAM. -+ * python/py-auto-load.c (source_section_scripts): Pass to -+ source_python_script_for_objfile also STREAM. -+ (auto_load_objfile_script): Pass to source_python_script_for_objfile -+ also INPUT. -+ * python/python-internal.h (source_python_script_for_objfile): New -+ parameter file, rename parameter file to filename. -+ * python/python.c (python_run_simple_file): Call PyRun_SimpleFile -+ instead if !_WIN32. Update the function comment. -+ (source_python_script, source_python_script_for_objfile) -+ (source_python_script): New parameter file, rename parameter file to -+ filename. Pass FILENAME to python_run_simple_file. -+ * python/python.h (source_python_script): New parameter file, rename -+ parameter file to filename. -+ - 2012-01-26 Pedro Alves - - * corelow.c (core_has_fake_pid): Delete. -Index: gdb-7.4.50.20120120/gdb/cli/cli-cmds.c -=================================================================== ---- gdb-7.4.50.20120120.orig/gdb/cli/cli-cmds.c 2012-01-04 09:17:16.000000000 +0100 -+++ gdb-7.4.50.20120120/gdb/cli/cli-cmds.c 2012-04-18 00:41:42.696855430 +0200 -@@ -529,9 +529,7 @@ source_script_from_stream (FILE *stream, - - TRY_CATCH (e, RETURN_MASK_ERROR) - { -- /* The python support reopens the file using python functions, -- so there's no point in passing STREAM here. */ -- source_python_script (file); -+ source_python_script (stream, file); - } - if (e.reason < 0) - { -Index: gdb-7.4.50.20120120/gdb/python/py-auto-load.c -=================================================================== ---- gdb-7.4.50.20120120.orig/gdb/python/py-auto-load.c 2012-01-04 09:17:25.000000000 +0100 -+++ gdb-7.4.50.20120120/gdb/python/py-auto-load.c 2012-04-18 00:41:42.696855430 +0200 -@@ -312,7 +312,7 @@ Use `info auto-load-scripts [REGEXP]' to - { - /* If this file is not currently loaded, load it. */ - if (! in_hash_table) -- source_python_script_for_objfile (objfile, full_path); -+ source_python_script_for_objfile (objfile, stream, full_path); - fclose (stream); - xfree (full_path); - } -@@ -431,7 +431,7 @@ auto_load_objfile_script (struct objfile - It's highly unlikely that we'd ever load it twice, - and these scripts are required to be idempotent under multiple - loads anyway. */ -- source_python_script_for_objfile (objfile, debugfile); -+ source_python_script_for_objfile (objfile, input, debugfile); - fclose (input); - } - -Index: gdb-7.4.50.20120120/gdb/python/python-internal.h -=================================================================== ---- gdb-7.4.50.20120120.orig/gdb/python/python-internal.h 2012-01-04 09:17:25.000000000 +0100 -+++ gdb-7.4.50.20120120/gdb/python/python-internal.h 2012-04-18 00:41:42.696855430 +0200 -@@ -289,8 +289,8 @@ extern const struct language_defn *pytho - - void gdbpy_print_stack (void); - --void source_python_script_for_objfile (struct objfile *objfile, -- const char *file); -+void source_python_script_for_objfile (struct objfile *objfile, FILE *file, -+ const char *filename); - - PyObject *python_string_to_unicode (PyObject *obj); - char *unicode_to_target_string (PyObject *unicode_str); -Index: gdb-7.4.50.20120120/gdb/python/python.c -=================================================================== ---- gdb-7.4.50.20120120.orig/gdb/python/python.c 2012-04-18 00:41:30.000000000 +0200 -+++ gdb-7.4.50.20120120/gdb/python/python.c 2012-04-18 00:41:42.696855430 +0200 -@@ -154,34 +154,31 @@ ensure_python_env (struct gdbarch *gdbar - return make_cleanup (restore_python_env, env); - } - --/* A wrapper around PyRun_SimpleFile. FILENAME is the name of -- the Python script to run. -+/* A wrapper around PyRun_SimpleFile. FILE is the Python script to run -+ named FILENAME. - -- One of the parameters of PyRun_SimpleFile is a FILE *. -- The problem is that type FILE is extremely system and compiler -- dependent. So, unless the Python library has been compiled using -- the same build environment as GDB, we run the risk of getting -- a crash due to inconsistencies between the definition used by GDB, -- and the definition used by Python. A mismatch can very likely -- lead to a crash. -- -- There is also the situation where the Python library and GDB -- are using two different versions of the C runtime library. -- This is particularly visible on Windows, where few users would -- build Python themselves (this is no trivial task on this platform), -- and thus use binaries built by someone else instead. Python, -- being built with VC, would use one version of the msvcr DLL -- (Eg. msvcr100.dll), while MinGW uses msvcrt.dll. A FILE * -- from one runtime does not necessarily operate correctly in -+ On Windows hosts few users would build Python themselves (this is no -+ trivial task on this platform), and thus use binaries built by -+ someone else instead. There may happen situation where the Python -+ library and GDB are using two different versions of the C runtime -+ library. Python, being built with VC, would use one version of the -+ msvcr DLL (Eg. msvcr100.dll), while MinGW uses msvcrt.dll. -+ A FILE * from one runtime does not necessarily operate correctly in - the other runtime. - -- To work around this potential issue, we create the FILE object -- using Python routines, thus making sure that it is compatible -- with the Python library. */ -+ To work around this potential issue, we create on Windows hosts the -+ FILE object using Python routines, thus making sure that it is -+ compatible with the Python library. */ - - static void --python_run_simple_file (const char *filename) -+python_run_simple_file (FILE *file, const char *filename) - { -+#ifndef _WIN32 -+ -+ PyRun_SimpleFile (file, filename); -+ -+#else /* _WIN32 */ -+ - char *full_path; - PyObject *python_file; - struct cleanup *cleanup; -@@ -201,6 +198,8 @@ python_run_simple_file (const char *file - make_cleanup_py_decref (python_file); - PyRun_SimpleFile (PyFile_AsFile (python_file), filename); - do_cleanups (cleanup); -+ -+#endif /* _WIN32 */ - } - - /* Given a command_line, return a command string suitable for passing -@@ -623,17 +622,17 @@ gdbpy_parse_and_eval (PyObject *self, Py - } - - /* Read a file as Python code. -- FILE is the name of the file. -+ FILE is the file to run. FILENAME is name of the file FILE. - This does not throw any errors. If an exception occurs python will print - the traceback and clear the error indicator. */ - - void --source_python_script (const char *file) -+source_python_script (FILE *file, const char *filename) - { - struct cleanup *cleanup; - - cleanup = ensure_python_env (get_current_arch (), current_language); -- python_run_simple_file (file); -+ python_run_simple_file (file, filename); - do_cleanups (cleanup); - } - -@@ -1041,19 +1040,20 @@ gdbpy_progspaces (PyObject *unused1, PyO - source_python_script_for_objfile; it is NULL at other times. */ - static struct objfile *gdbpy_current_objfile; - --/* Set the current objfile to OBJFILE and then read FILE as Python code. -- This does not throw any errors. If an exception occurs python will print -- the traceback and clear the error indicator. */ -+/* Set the current objfile to OBJFILE and then read FILE named FILENAME -+ as Python code. This does not throw any errors. If an exception -+ occurs python will print the traceback and clear the error indicator. */ - - void --source_python_script_for_objfile (struct objfile *objfile, const char *file) -+source_python_script_for_objfile (struct objfile *objfile, FILE *file, -+ const char *filename) - { - struct cleanup *cleanups; - - cleanups = ensure_python_env (get_objfile_arch (objfile), current_language); - gdbpy_current_objfile = objfile; - -- python_run_simple_file (file); -+ python_run_simple_file (file, filename); - - do_cleanups (cleanups); - gdbpy_current_objfile = NULL; -@@ -1129,7 +1129,7 @@ eval_python_from_control_command (struct - } - - void --source_python_script (const char *file) -+source_python_script (FILE *file, const char *filename) - { - throw_error (UNSUPPORTED_ERROR, - _("Python scripting is not supported in this copy of GDB.")); -Index: gdb-7.4.50.20120120/gdb/python/python.h -=================================================================== ---- gdb-7.4.50.20120120.orig/gdb/python/python.h 2012-04-18 00:41:30.000000000 +0200 -+++ gdb-7.4.50.20120120/gdb/python/python.h 2012-04-18 00:41:42.697855427 +0200 -@@ -30,7 +30,7 @@ extern void finish_python_initialization - - void eval_python_from_control_command (struct command_line *); - --void source_python_script (const char *file); -+void source_python_script (FILE *file, const char *filename); - - void run_python_script (int argc, char **argv); - diff --git a/gdb-autoload-04of28.patch b/gdb-autoload-04of28.patch deleted file mode 100644 index 645ac87..0000000 --- a/gdb-autoload-04of28.patch +++ /dev/null @@ -1,141 +0,0 @@ -http://sourceware.org/ml/gdb-cvs/2012-03/msg00234.html - -### src/gdb/ChangeLog 2012/03/19 18:13:39 1.14025 -### src/gdb/ChangeLog 2012/03/19 18:16:17 1.14026 -## -1,3 +1,14 @@ -+2012-03-19 Jan Kratochvil -+ -+ Code cleanup. -+ * main.c (struct cmdarg): Move it here from main. Add more comments. -+ (cmdarg_s, VEC (cmdarg_s)): New. -+ (main): Move struct cmdarg from here. New variables cmdarg_vec and -+ cmdarg_p. Remove variables cmdsize and ncmd and their initialization. -+ Install cleanup for cmdarg_vec. Update filling for options 'x' and -+ 'X'. Replace cmdarg processing by cmdarg_vec processing. Remove xfree -+ of CMDARG. -+ - 2012-03-19 Tom Tromey - - * gnu-v3-abi.c (gnuv3_print_vtable): Initialize 'result_vec'. -Index: gdb-7.4.50.20120120/gdb/main.c -=================================================================== ---- gdb-7.4.50.20120120.orig/gdb/main.c 2012-04-18 00:41:31.000000000 +0200 -+++ gdb-7.4.50.20120120/gdb/main.c 2012-04-18 00:42:15.354772337 +0200 -@@ -277,6 +277,25 @@ exec_or_core_file_attach (char *filename - } - } - -+/* Arguments of --command option and its counterpart. */ -+typedef struct cmdarg { -+ /* Type of this option. */ -+ enum { -+ /* Option type -x. */ -+ CMDARG_FILE, -+ -+ /* Option type -ex. */ -+ CMDARG_COMMAND -+ } type; -+ -+ /* Value of this option - filename or the GDB command itself. String memory -+ is not owned by this structure despite it is 'const'. */ -+ char *string; -+} cmdarg_s; -+ -+/* Define type VEC (cmdarg_s). */ -+DEF_VEC_O (cmdarg_s); -+ - static int - captured_main (void *data) - { -@@ -303,17 +322,8 @@ captured_main (void *data) - static int print_version; - - /* Pointers to all arguments of --command option. */ -- struct cmdarg { -- enum { -- CMDARG_FILE, -- CMDARG_COMMAND -- } type; -- char *string; -- } *cmdarg; -- /* Allocated size of cmdarg. */ -- int cmdsize; -- /* Number of elements of cmdarg used. */ -- int ncmd; -+ VEC (cmdarg_s) *cmdarg_vec = NULL; -+ struct cmdarg *cmdarg_p; - - /* Indices of all arguments of --directory option. */ - char **dirarg; -@@ -349,9 +359,7 @@ captured_main (void *data) - bindtextdomain (PACKAGE, LOCALEDIR); - textdomain (PACKAGE); - -- cmdsize = 1; -- cmdarg = (struct cmdarg *) xmalloc (cmdsize * sizeof (*cmdarg)); -- ncmd = 0; -+ make_cleanup (VEC_cleanup (cmdarg_s), &cmdarg_vec); - dirsize = 1; - dirarg = (char **) xmalloc (dirsize * sizeof (*dirarg)); - ndir = 0; -@@ -582,24 +590,19 @@ captured_main (void *data) - pidarg = optarg; - break; - case 'x': -- cmdarg[ncmd].type = CMDARG_FILE; -- cmdarg[ncmd++].string = optarg; -- if (ncmd >= cmdsize) -- { -- cmdsize *= 2; -- cmdarg = xrealloc ((char *) cmdarg, -- cmdsize * sizeof (*cmdarg)); -- } -+ { -+ struct cmdarg cmdarg = { CMDARG_FILE, optarg }; -+ -+ VEC_safe_push (cmdarg_s, cmdarg_vec, &cmdarg); -+ } - break; - case 'X': -- cmdarg[ncmd].type = CMDARG_COMMAND; -- cmdarg[ncmd++].string = optarg; -- if (ncmd >= cmdsize) -- { -- cmdsize *= 2; -- cmdarg = xrealloc ((char *) cmdarg, -- cmdsize * sizeof (*cmdarg)); -- } -+ { -+ struct cmdarg cmdarg = { CMDARG_COMMAND, optarg }; -+ -+ VEC_safe_push (cmdarg_s, cmdarg_vec, &cmdarg); -+ } -+ break; - break; - case 'B': - batch_flag = batch_silent = 1; -@@ -990,16 +993,18 @@ captured_main (void *data) - ALL_OBJFILES (objfile) - load_auto_scripts_for_objfile (objfile); - -- for (i = 0; i < ncmd; i++) -+ for (i = 0; VEC_iterate (cmdarg_s, cmdarg_vec, i, cmdarg_p); i++) -+ switch (cmdarg_p->type) - { -- if (cmdarg[i].type == CMDARG_FILE) -- catch_command_errors (source_script, cmdarg[i].string, -+ case CMDARG_FILE: -+ catch_command_errors (source_script, cmdarg_p->string, - !batch_flag, RETURN_MASK_ALL); -- else /* cmdarg[i].type == CMDARG_COMMAND */ -- catch_command_errors (execute_command, cmdarg[i].string, -+ break; -+ case CMDARG_COMMAND: -+ catch_command_errors (execute_command, cmdarg_p->string, - !batch_flag, RETURN_MASK_ALL); -+ break; - } -- xfree (cmdarg); - - /* Read in the old history after all the command files have been - read. */ diff --git a/gdb-autoload-05of28.patch b/gdb-autoload-05of28.patch deleted file mode 100644 index 8dd8cc3..0000000 --- a/gdb-autoload-05of28.patch +++ /dev/null @@ -1,244 +0,0 @@ -http://sourceware.org/ml/gdb-cvs/2012-03/msg00235.html - -### src/gdb/ChangeLog 2012/03/19 18:16:17 1.14026 -### src/gdb/ChangeLog 2012/03/19 18:19:23 1.14027 -## -1,5 +1,18 @@ - 2012-03-19 Jan Kratochvil - -+ * NEWS: Describe new options --init-command=FILE, -ix and -+ --init-eval-command=COMMAND, -iex. -+ * main.c (struct cmdarg): New enum items CMDARG_INIT_FILE and -+ CMDARG_INIT_COMMAND. -+ (captured_main): New enum items OPT_IX and OPT_IEX. Add -+ "init-command", "init-eval-command", "ix" and "iex" to the variable -+ long_options. Handle OPT_IX and OPT_IEX. Process them from CMDARG_VEC. -+ New comment for CMDARG_FILE and CMDARG_COMMAND processing. -+ (print_gdb_help): Describe --init-command=FILE, -ix and -+ --init-eval-command=COMMAND, -iex. -+ -+2012-03-19 Jan Kratochvil -+ - Code cleanup. - * main.c (struct cmdarg): Move it here from main. Add more comments. - (cmdarg_s, VEC (cmdarg_s)): New. -Index: gdb-7.4.50.20120120/gdb/NEWS -=================================================================== ---- gdb-7.4.50.20120120.orig/gdb/NEWS 2012-04-18 00:41:30.000000000 +0200 -+++ gdb-7.4.50.20120120/gdb/NEWS 2012-04-18 00:42:51.226681068 +0200 -@@ -28,6 +28,13 @@ - now set a breakpoint in build/gcc/expr.c, but not - build/libcpp/expr.c. - -+* New command line options -+ -+--init-command=FILE, -ix Like --command, -x but execute it -+ before loading inferior. -+--init-eval-command=COMMAND, -iex Like --eval-command=COMMAND, -ex but -+ execute it before loading inferior. -+ - *** Changes in GDB 7.4 - - * GDB now handles ambiguous linespecs more consistently; the existing -Index: gdb-7.4.50.20120120/gdb/main.c -=================================================================== ---- gdb-7.4.50.20120120.orig/gdb/main.c 2012-04-18 00:42:15.000000000 +0200 -+++ gdb-7.4.50.20120120/gdb/main.c 2012-04-18 00:42:51.226681068 +0200 -@@ -285,7 +285,13 @@ typedef struct cmdarg { - CMDARG_FILE, - - /* Option type -ex. */ -- CMDARG_COMMAND -+ CMDARG_COMMAND, -+ -+ /* Option type -ix. */ -+ CMDARG_INIT_FILE, -+ -+ /* Option type -iex. */ -+ CMDARG_INIT_COMMAND - } type; - - /* Value of this option - filename or the GDB command itself. String memory -@@ -434,7 +440,9 @@ captured_main (void *data) - OPT_STATISTICS, - OPT_TUI, - OPT_NOWINDOWS, -- OPT_WINDOWS -+ OPT_WINDOWS, -+ OPT_IX, -+ OPT_IEX - }; - static struct option long_options[] = - { -@@ -475,6 +483,10 @@ captured_main (void *data) - {"version", no_argument, &print_version, 1}, - {"x", required_argument, 0, 'x'}, - {"ex", required_argument, 0, 'X'}, -+ {"init-command", required_argument, 0, OPT_IX}, -+ {"init-eval-command", required_argument, 0, OPT_IEX}, -+ {"ix", required_argument, 0, OPT_IX}, -+ {"iex", required_argument, 0, OPT_IEX}, - #ifdef GDBTK - {"tclcommand", required_argument, 0, 'z'}, - {"enable-external-editor", no_argument, 0, 'y'}, -@@ -603,6 +615,19 @@ captured_main (void *data) - VEC_safe_push (cmdarg_s, cmdarg_vec, &cmdarg); - } - break; -+ case OPT_IX: -+ { -+ struct cmdarg cmdarg = { CMDARG_INIT_FILE, optarg }; -+ -+ VEC_safe_push (cmdarg_s, cmdarg_vec, &cmdarg); -+ } -+ break; -+ case OPT_IEX: -+ { -+ struct cmdarg cmdarg = { CMDARG_INIT_COMMAND, optarg }; -+ -+ VEC_safe_push (cmdarg_s, cmdarg_vec, &cmdarg); -+ } - break; - case 'B': - batch_flag = batch_silent = 1; -@@ -877,6 +902,20 @@ captured_main (void *data) - quit_pre_print = error_pre_print; - warning_pre_print = _("\nwarning: "); - -+ /* Process '-ix' and '-iex' options early. */ -+ for (i = 0; VEC_iterate (cmdarg_s, cmdarg_vec, i, cmdarg_p); i++) -+ switch (cmdarg_p->type) -+ { -+ case CMDARG_INIT_FILE: -+ catch_command_errors (source_script, cmdarg_p->string, -+ !batch_flag, RETURN_MASK_ALL); -+ break; -+ case CMDARG_INIT_COMMAND: -+ catch_command_errors (execute_command, cmdarg_p->string, -+ !batch_flag, RETURN_MASK_ALL); -+ break; -+ } -+ - /* Read and execute the system-wide gdbinit file, if it exists. - This is done *before* all the command line arguments are - processed; it sets global parameters, which are independent of -@@ -993,6 +1032,7 @@ captured_main (void *data) - ALL_OBJFILES (objfile) - load_auto_scripts_for_objfile (objfile); - -+ /* Process '-x' and '-ex' options. */ - for (i = 0; VEC_iterate (cmdarg_s, cmdarg_vec, i, cmdarg_p); i++) - switch (cmdarg_p->type) - { -@@ -1093,6 +1133,8 @@ Options:\n\n\ - Execute a single GDB command.\n\ - May be used multiple times and in conjunction\n\ - with --command.\n\ -+ --init-command=FILE, -ix Like -x but execute it before loading inferior.\n\ -+ --init-eval-command=COMMAND, -iex Like -ex but before loading inferior.\n\ - --core=COREFILE Analyze the core dump COREFILE.\n\ - --pid=PID Attach to running process PID.\n\ - "), stream); -Index: gdb-7.4.50.20120120/gdb/doc/gdb.texinfo -=================================================================== ---- gdb-7.4.50.20120120.orig/gdb/doc/gdb.texinfo 2012-04-18 00:41:31.000000000 +0200 -+++ gdb-7.4.50.20120120/gdb/doc/gdb.texinfo 2012-04-18 00:42:51.232681052 +0200 -@@ -989,6 +989,22 @@ also be interleaved with @samp{-command} - -x setbreakpoints -ex 'run' a.out - @end smallexample - -+@item -init-command @var{file} -+@itemx -ix @var{file} -+@cindex @code{--init-command} -+@cindex @code{-ix} -+Execute commands from file @var{file} before loading gdbinit files or the -+inferior. -+@xref{Startup}. -+ -+@item -init-eval-command @var{command} -+@itemx -iex @var{command} -+@cindex @code{--init-eval-command} -+@cindex @code{-iex} -+Execute a single @value{GDBN} command before loading gdbinit files or the -+inferior. -+@xref{Startup}. -+ - @item -directory @var{directory} - @itemx -d @var{directory} - @cindex @code{--directory} -@@ -1250,6 +1266,13 @@ Sets up the command interpreter as speci - (@pxref{Mode Options, interpreter}). - - @item -+Executes commands and command files specified by the @samp{-iex} and -+@samp{-ix} options in their specified order. Usually you should use the -+@samp{-ex} and @samp{-x} options instead, but this way you can apply -+settings before @value{GDBN} init files get executed and before inferior -+gets loaded. -+ -+@item - @cindex init file - Reads the system-wide @dfn{init file} (if @option{--with-system-gdbinit} was - used when building @value{GDBN}; @pxref{System-wide configuration, -@@ -1283,14 +1306,11 @@ If you wish to disable the auto-loading - you must do something like the following: - - @smallexample --$ gdb -ex "set auto-load-scripts off" -ex "file myprogram" -+$ gdb -iex "set auto-load-scripts off" myprogram - @end smallexample - --The following does not work because the auto-loading is turned off too late: -- --@smallexample --$ gdb -ex "set auto-load-scripts off" myprogram --@end smallexample -+Option @samp{-ex} does not work because the auto-loading is then turned -+off too late. - - @item - Reads command files specified by the @samp{-x} option. @xref{Command -Index: gdb-7.4.50.20120120/gdb/testsuite/gdb.gdb/selftest.exp -=================================================================== ---- gdb-7.4.50.20120120.orig/gdb/testsuite/gdb.gdb/selftest.exp 2012-04-18 00:41:31.000000000 +0200 -+++ gdb-7.4.50.20120120/gdb/testsuite/gdb.gdb/selftest.exp 2012-04-18 00:42:51.232681052 +0200 -@@ -92,6 +92,10 @@ proc do_steps_and_nexts {} { - set description "step over python_script initialization" - set command "step" - } -+ -re ".*cmdarg_vec = NULL.*$gdb_prompt $" { -+ set description "step over cmdarg_vec 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" -@@ -128,18 +132,6 @@ proc do_steps_and_nexts {} { - set description "next over conditional stack alignment alloca" - set command "next" - } -- -re ".*cmdsize = 1.*$gdb_prompt $" { -- set description "step over cmdsize initialization" -- set command "next" -- } -- -re ".*cmdarg = .* xmalloc.*$gdb_prompt $" { -- set description "next over cmdarg initialization via xmalloc" -- set command "next" -- } -- -re ".*ncmd = 0.*$gdb_prompt $" { -- set description "next over ncmd initialization" -- set command "next" -- } - -re ".*dirsize = 1.*$gdb_prompt $" { - set description "next over dirsize initialization" - set command "next" -@@ -163,6 +155,10 @@ proc do_steps_and_nexts {} { - set description "next over textdomain PACKAGE" - set command "next" - } -+ -re ".*VEC_cleanup .cmdarg_s.*$gdb_prompt $" { -+ set description "next over cmdarg_s VEC_cleanup" -+ set command "next" -+ } - -re "\[0-9\]+\[\t \]+\{\r\n$gdb_prompt $" { - set description "step over initial brace" - set command "step" diff --git a/gdb-autoload-06of28.patch b/gdb-autoload-06of28.patch deleted file mode 100644 index ae121ef..0000000 --- a/gdb-autoload-06of28.patch +++ /dev/null @@ -1,71 +0,0 @@ -http://sourceware.org/ml/gdb-cvs/2012-03/msg00236.html - -### src/gdb/ChangeLog 2012/03/19 18:19:23 1.14027 -### src/gdb/ChangeLog 2012/03/19 18:23:51 1.14028 -## -1,5 +1,13 @@ - 2012-03-19 Jan Kratochvil - -+ Code cleanup. -+ * python/py-auto-load.c (source_section_scripts): New variable back_to. -+ Turn fclose and xfree calls into make_cleanup_fclose and make_cleanup -+ with xfree. -+ (auto_load_objfile_script): Turn fclose into make_cleanup_fclose. -+ -+2012-03-19 Jan Kratochvil -+ - * NEWS: Describe new options --init-command=FILE, -ix and - --init-eval-command=COMMAND, -iex. - * main.c (struct cmdarg): New enum items CMDARG_INIT_FILE and ---- src/gdb/python/py-auto-load.c 2012/01/26 21:54:45 1.18 -+++ src/gdb/python/py-auto-load.c 2012/03/19 18:23:52 1.19 -@@ -254,6 +254,7 @@ - FILE *stream; - char *full_path; - int opened, in_hash_table; -+ struct cleanup *back_to; - - if (*p != 1) - { -@@ -286,6 +287,13 @@ - opened = find_and_open_script (file, 1 /*search_path*/, - &stream, &full_path); - -+ back_to = make_cleanup (null_cleanup, NULL); -+ if (opened) -+ { -+ make_cleanup_fclose (stream); -+ make_cleanup (xfree, full_path); -+ } -+ - /* If one script isn't found it's not uncommon for more to not be - found either. We don't want to print an error message for each - script, too much noise. Instead, we print the warning once and tell -@@ -313,9 +321,9 @@ - /* If this file is not currently loaded, load it. */ - if (! in_hash_table) - source_python_script_for_objfile (objfile, stream, full_path); -- fclose (stream); -- xfree (full_path); - } -+ -+ do_cleanups (back_to); - } - } - -@@ -420,6 +428,8 @@ - { - struct auto_load_pspace_info *pspace_info; - -+ make_cleanup_fclose (input); -+ - /* Add this script to the hash table too so "info auto-load-scripts" - can print it. */ - pspace_info = -@@ -432,7 +442,6 @@ - and these scripts are required to be idempotent under multiple - loads anyway. */ - source_python_script_for_objfile (objfile, input, debugfile); -- fclose (input); - } - - do_cleanups (cleanups); diff --git a/gdb-autoload-07of28.patch b/gdb-autoload-07of28.patch deleted file mode 100644 index 51d129e..0000000 --- a/gdb-autoload-07of28.patch +++ /dev/null @@ -1,57 +0,0 @@ -http://sourceware.org/ml/gdb-cvs/2012-03/msg00296.html - -### src/gdb/doc/ChangeLog 2012/03/22 08:10:41 1.1289 -### src/gdb/doc/ChangeLog 2012/03/27 20:15:20 1.1290 -## -1,3 +1,12 @@ -+2012-03-27 Jan Kratochvil -+ -+ * gdb.texinfo (Auto-loading): Rename node reference -+ '.debug_gdb_scripts section' to 'dotdebug_gdb_scripts section'. -+ Twice. -+ (.debug_gdb_scripts section): Rename the node ... -+ (dotdebug_gdb_scripts section): ... here. -+ (Maintenance Commands): Also rename this node reference. -+ - 2012-03-22 Siva Chandra Reddy - - * gdb.texinfo (Python API/Values From Inferior): Add description ---- src/gdb/doc/gdb.texinfo 2012/03/22 08:10:41 1.936 -+++ src/gdb/doc/gdb.texinfo 2012/03/27 20:15:20 1.937 -@@ -24717,8 +24717,8 @@ - @file{@var{objfile}-gdb.py} and @code{.debug_gdb_scripts} section. - - @menu --* objfile-gdb.py file:: The @file{@var{objfile}-gdb.py} file --* .debug_gdb_scripts section:: The @code{.debug_gdb_scripts} section -+* objfile-gdb.py file:: The @file{@var{objfile}-gdb.py} file -+* dotdebug_gdb_scripts section:: The @code{.debug_gdb_scripts} section - * Which flavor to choose?:: - @end menu - -@@ -24744,7 +24744,7 @@ - - Also printed is the list of scripts that were mentioned in - the @code{.debug_gdb_scripts} section and were not found --(@pxref{.debug_gdb_scripts section}). -+(@pxref{dotdebug_gdb_scripts section}). - This is useful because their names are not printed when @value{GDBN} - tries to load them and fails. There may be many of them, and printing - an error message for each one is problematic. -@@ -24795,7 +24795,7 @@ - So your @file{-gdb.py} file should be careful to avoid errors if it - is evaluated more than once. - --@node .debug_gdb_scripts section -+@node dotdebug_gdb_scripts section - @subsubsection The @code{.debug_gdb_scripts} section - @cindex @code{.debug_gdb_scripts} section - -@@ -33475,7 +33475,7 @@ - matching @var{regexp}. - For each script, this command prints its name as specified in the objfile, - and the full path if known. --@xref{.debug_gdb_scripts section}. -+@xref{dotdebug_gdb_scripts section}. - - @kindex maint print statistics - @cindex bcache statistics diff --git a/gdb-autoload-08of28.patch b/gdb-autoload-08of28.patch deleted file mode 100644 index b48bfc1..0000000 --- a/gdb-autoload-08of28.patch +++ /dev/null @@ -1,171 +0,0 @@ -[patch#4 2/8] Code cleanup: new path to VEC in utils.c -http://sourceware.org/ml/gdb-patches/2012-04/msg00086.html -http://sourceware.org/ml/gdb-cvs/2012-04/msg00111.html - - reduced for the backport - -### src/gdb/ChangeLog 2012/04/17 15:45:05 1.14110 -### src/gdb/ChangeLog 2012/04/17 15:47:08 1.14111 -## -1,6 +1,34 @@ - 2012-04-17 Jan Kratochvil - - Code cleanup. -+ * charset.c (find_charset_names): Remove variables ix and elt. -+ Use free_char_ptr_vec. -+ * elfread.c (build_id_to_debug_filename): New variables debugdir_vec, -+ back_to and ix. Use dirnames_to_char_ptr_vec. Remove variable -+ debugdir_end. New variable debugdir_len. -+ * gdb_vecs.h (free_char_ptr_vec, make_cleanup_free_char_ptr_vec) -+ (dirnames_to_char_ptr_vec_append, dirnames_to_char_ptr_vec): New -+ declarations. -+ * progspace.c (clear_program_space_solib_cache): Remove variables ix -+ and elt. Use free_char_ptr_vec. -+ * source.c (add_path): Remove variables argv, arg and argv_index. -+ New variables dir_vec, back_to, ix and name. -+ Use dirnames_to_char_ptr_vec_append. Use freeargv instead of -+ make_cleanup_freeargv. Remove variable separator. Simplify the code -+ no longer expecting DIRNAME_SEPARATOR. -+ (openp): Remove variable p, p1 and len. New variables dir_vec, -+ back_to, ix and dir. Use dirnames_to_char_ptr_vec. Simplify the code -+ no longer expecting DIRNAME_SEPARATOR. -+ * symfile.c (find_separate_debug_file): New variables debugdir_vec, -+ back_to and ix. Use dirnames_to_char_ptr_vec. Remove variable -+ debugdir_end. -+ * utils.c (free_char_ptr_vec, do_free_char_ptr_vec) -+ (make_cleanup_free_char_ptr_vec, dirnames_to_char_ptr_vec_append) -+ (dirnames_to_char_ptr_vec): New functions. -+ -+2012-04-17 Jan Kratochvil -+ -+ Code cleanup. - * source.c (add_path): Remove always true conditional 'p == 0' and - unindent its code block. - -Index: gdb-7.4.50.20120120/gdb/gdb_vecs.h -=================================================================== ---- gdb-7.4.50.20120120.orig/gdb/gdb_vecs.h 2012-04-18 00:40:12.067086016 +0200 -+++ gdb-7.4.50.20120120/gdb/gdb_vecs.h 2012-04-18 00:40:23.474056993 +0200 -@@ -25,4 +25,16 @@ - - DEF_VEC_P (char_ptr); - -+/* From utils.c: */ -+ -+extern void free_char_ptr_vec (VEC (char_ptr) *char_ptr_vec); -+ -+extern struct cleanup * -+ make_cleanup_free_char_ptr_vec (VEC (char_ptr) *char_ptr_vec); -+ -+extern void dirnames_to_char_ptr_vec_append (VEC (char_ptr) **vecp, -+ const char *dirnames); -+ -+extern VEC (char_ptr) *dirnames_to_char_ptr_vec (const char *dirnames); -+ - #endif /* GDB_VECS_H */ -Index: gdb-7.4.50.20120120/gdb/utils.c -=================================================================== ---- gdb-7.4.50.20120120.orig/gdb/utils.c 2012-04-18 00:40:12.068086013 +0200 -+++ gdb-7.4.50.20120120/gdb/utils.c 2012-04-18 00:40:49.862989855 +0200 -@@ -29,6 +29,7 @@ - #ifdef HAVE_SYS_RESOURCE_H - #include - #endif /* HAVE_SYS_RESOURCE_H */ -+#include "gdb_vecs.h" - - #ifdef TUI - #include "tui/tui.h" /* For tui_get_command_dimension. */ -@@ -3835,6 +3836,95 @@ producer_is_gcc_ge_4 (const char *produc - return minor; - } - -+/* Call xfree for each element of CHAR_PTR_VEC and final VEC_free for -+ CHAR_PTR_VEC itself. -+ -+ You must not modify CHAR_PTR_VEC after it got registered with this function -+ by make_cleanup as the CHAR_PTR_VEC base address may change on its updates. -+ Contrary to VEC_free this function does not (cannot) clear the pointer. */ -+ -+void -+free_char_ptr_vec (VEC (char_ptr) *char_ptr_vec) -+{ -+ int ix; -+ char *name; -+ -+ for (ix = 0; VEC_iterate (char_ptr, char_ptr_vec, ix, name); ++ix) -+ xfree (name); -+ VEC_free (char_ptr, char_ptr_vec); -+} -+ -+/* Helper for make_cleanup_free_char_ptr_vec. */ -+ -+static void -+do_free_char_ptr_vec (void *arg) -+{ -+ VEC (char_ptr) *char_ptr_vec = arg; -+ -+ free_char_ptr_vec (char_ptr_vec); -+} -+ -+/* Make cleanup handler calling xfree for each element of CHAR_PTR_VEC and -+ final VEC_free for CHAR_PTR_VEC itself. -+ -+ You must not modify CHAR_PTR_VEC after this cleanup registration as the -+ CHAR_PTR_VEC base address may change on its updates. Contrary to VEC_free -+ this function does not (cannot) clear the pointer. */ -+ -+struct cleanup * -+make_cleanup_free_char_ptr_vec (VEC (char_ptr) *char_ptr_vec) -+{ -+ return make_cleanup (do_free_char_ptr_vec, char_ptr_vec); -+} -+ -+/* Extended version of dirnames_to_char_ptr_vec - additionally if *VECP is -+ non-NULL the new list elements from DIRNAMES are appended to the existing -+ *VECP list of entries. *VECP address will be updated by this call. */ -+ -+void -+dirnames_to_char_ptr_vec_append (VEC (char_ptr) **vecp, const char *dirnames) -+{ -+ do -+ { -+ size_t this_len; -+ char *next_dir, *this_dir; -+ -+ next_dir = strchr (dirnames, DIRNAME_SEPARATOR); -+ if (next_dir == NULL) -+ this_len = strlen (dirnames); -+ else -+ { -+ this_len = next_dir - dirnames; -+ next_dir++; -+ } -+ -+ this_dir = xmalloc (this_len + 1); -+ memcpy (this_dir, dirnames, this_len); -+ this_dir[this_len] = '\0'; -+ VEC_safe_push (char_ptr, *vecp, this_dir); -+ -+ dirnames = next_dir; -+ } -+ while (dirnames != NULL); -+} -+ -+/* Split DIRNAMES by DIRNAME_SEPARATOR delimiter and return a list of all the -+ elements in their original order. For empty string ("") DIRNAMES return -+ list of one empty string ("") element. -+ -+ You may modify the returned strings. -+ Read free_char_ptr_vec for its cleanup. */ -+ -+VEC (char_ptr) * -+dirnames_to_char_ptr_vec (const char *dirnames) -+{ -+ VEC (char_ptr) *retval = NULL; -+ -+ dirnames_to_char_ptr_vec_append (&retval, dirnames); -+ -+ return retval; -+} -+ - #ifdef HAVE_WAITPID - - #ifdef SIGALRM diff --git a/gdb-autoload-09of28.patch b/gdb-autoload-09of28.patch deleted file mode 100644 index 1244cff..0000000 --- a/gdb-autoload-09of28.patch +++ /dev/null @@ -1,1168 +0,0 @@ -[patch#4 3/8] auto-load: reshuffle code -http://sourceware.org/ml/gdb-patches/2012-04/msg00087.html -http://sourceware.org/ml/gdb-cvs/2012-04/msg00112.html - -Index: gdb-7.4.50.20120120/gdb/auto-load.c -=================================================================== ---- /dev/null 1970-01-01 00:00:00.000000000 +0000 -+++ gdb-7.4.50.20120120/gdb/auto-load.c 2012-04-18 00:26:29.049120212 +0200 -@@ -0,0 +1,472 @@ -+/* GDB routines for supporting auto-loaded scripts. -+ -+ Copyright (C) 2012 Free Software Foundation, Inc. -+ -+ This file is part of GDB. -+ -+ This program is free software; you can redistribute it and/or modify -+ it under the terms of the GNU General Public License as published by -+ the Free Software Foundation; either version 3 of the License, or -+ (at your option) any later version. -+ -+ This program is distributed in the hope that it will be useful, -+ but WITHOUT ANY WARRANTY; without even the implied warranty of -+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+ GNU General Public License for more details. -+ -+ You should have received a copy of the GNU General Public License -+ along with this program. If not, see . */ -+ -+#include "defs.h" -+#include "auto-load.h" -+#include "progspace.h" -+#include "python/python.h" -+#include "gdb_regex.h" -+#include "ui-out.h" -+#include "filenames.h" -+#include "command.h" -+#include "observer.h" -+#include "objfiles.h" -+#include "python/python-internal.h" -+ -+/* Internal-use flag to enable/disable auto-loading. -+ This is true if we should auto-load python code when an objfile is opened, -+ false otherwise. -+ -+ Both auto_load_scripts && gdbpy_global_auto_load must be true to enable -+ auto-loading. -+ -+ This flag exists to facilitate deferring auto-loading during start-up -+ until after ./.gdbinit has been read; it may augment the search directories -+ used to find the scripts. */ -+int gdbpy_global_auto_load = 1; -+ -+/* For scripts specified in .debug_gdb_scripts, multiple objfiles may load -+ the same script. There's no point in loading the script multiple times, -+ and there can be a lot of objfiles and scripts, so we keep track of scripts -+ loaded this way. */ -+ -+struct auto_load_pspace_info -+{ -+ /* For each program space we keep track of loaded scripts. */ -+ struct htab *loaded_scripts; -+ -+ /* Non-zero if we've issued the warning about an auto-load script not being -+ found. We only want to issue this warning once. */ -+ int script_not_found_warning_printed; -+}; -+ -+/* Objects of this type are stored in the loaded script hash table. */ -+ -+struct loaded_script -+{ -+ /* Name as provided by the objfile. */ -+ const char *name; -+ /* Full path name or NULL if script wasn't found (or was otherwise -+ inaccessible). */ -+ const char *full_path; -+}; -+ -+/* Per-program-space data key. */ -+static const struct program_space_data *auto_load_pspace_data; -+ -+static void -+auto_load_pspace_data_cleanup (struct program_space *pspace, void *arg) -+{ -+ struct auto_load_pspace_info *info; -+ -+ info = program_space_data (pspace, auto_load_pspace_data); -+ if (info != NULL) -+ { -+ if (info->loaded_scripts) -+ htab_delete (info->loaded_scripts); -+ xfree (info); -+ } -+} -+ -+/* Get the current autoload data. If none is found yet, add it now. This -+ function always returns a valid object. */ -+ -+static struct auto_load_pspace_info * -+get_auto_load_pspace_data (struct program_space *pspace) -+{ -+ struct auto_load_pspace_info *info; -+ -+ info = program_space_data (pspace, auto_load_pspace_data); -+ if (info == NULL) -+ { -+ info = XZALLOC (struct auto_load_pspace_info); -+ set_program_space_data (pspace, auto_load_pspace_data, info); -+ } -+ -+ return info; -+} -+ -+/* Hash function for the loaded script hash. */ -+ -+static hashval_t -+hash_loaded_script_entry (const void *data) -+{ -+ const struct loaded_script *e = data; -+ -+ return htab_hash_string (e->name); -+} -+ -+/* Equality function for the loaded script hash. */ -+ -+static int -+eq_loaded_script_entry (const void *a, const void *b) -+{ -+ const struct loaded_script *ea = a; -+ const struct loaded_script *eb = b; -+ -+ return strcmp (ea->name, eb->name) == 0; -+} -+ -+/* Initialize the table to track loaded scripts. -+ Each entry is hashed by the full path name. */ -+ -+static void -+init_loaded_scripts_info (struct auto_load_pspace_info *pspace_info) -+{ -+ /* Choose 31 as the starting size of the hash table, somewhat arbitrarily. -+ Space for each entry is obtained with one malloc so we can free them -+ easily. */ -+ -+ pspace_info->loaded_scripts = htab_create (31, -+ hash_loaded_script_entry, -+ eq_loaded_script_entry, -+ xfree); -+ -+ pspace_info->script_not_found_warning_printed = FALSE; -+} -+ -+/* Wrapper on get_auto_load_pspace_data to also allocate the hash table -+ for loading scripts. */ -+ -+struct auto_load_pspace_info * -+get_auto_load_pspace_data_for_loading (struct program_space *pspace) -+{ -+ struct auto_load_pspace_info *info; -+ -+ info = get_auto_load_pspace_data (pspace); -+ if (info->loaded_scripts == NULL) -+ init_loaded_scripts_info (info); -+ -+ return info; -+} -+ -+/* Add script NAME to hash table of PSPACE_INFO. -+ FULL_PATH is NULL if the script wasn't found. -+ The result is true if the script was already in the hash table. */ -+ -+int -+maybe_add_script (struct auto_load_pspace_info *pspace_info, const char *name, -+ const char *full_path) -+{ -+ struct htab *htab = pspace_info->loaded_scripts; -+ struct loaded_script **slot, entry; -+ int in_hash_table; -+ -+ entry.name = name; -+ entry.full_path = full_path; -+ slot = (struct loaded_script **) htab_find_slot (htab, &entry, INSERT); -+ in_hash_table = *slot != NULL; -+ -+ /* If this script is not in the hash table, add it. */ -+ -+ if (! in_hash_table) -+ { -+ char *p; -+ -+ /* Allocate all space in one chunk so it's easier to free. */ -+ *slot = xmalloc (sizeof (**slot) -+ + strlen (name) + 1 -+ + (full_path != NULL ? (strlen (full_path) + 1) : 0)); -+ p = ((char*) *slot) + sizeof (**slot); -+ strcpy (p, name); -+ (*slot)->name = p; -+ if (full_path != NULL) -+ { -+ p += strlen (p) + 1; -+ strcpy (p, full_path); -+ (*slot)->full_path = p; -+ } -+ else -+ (*slot)->full_path = NULL; -+ } -+ -+ return in_hash_table; -+} -+ -+/* Clear the table of loaded section scripts. */ -+ -+static void -+clear_section_scripts (void) -+{ -+ struct program_space *pspace = current_program_space; -+ struct auto_load_pspace_info *info; -+ -+ info = program_space_data (pspace, auto_load_pspace_data); -+ if (info != NULL && info->loaded_scripts != NULL) -+ { -+ htab_delete (info->loaded_scripts); -+ info->loaded_scripts = NULL; -+ info->script_not_found_warning_printed = FALSE; -+ } -+} -+ -+/* Look for the auto-load script associated with OBJFILE and load it. */ -+ -+void -+auto_load_objfile_script (struct objfile *objfile, const char *suffix) -+{ -+ char *realname; -+ char *filename, *debugfile; -+ int len; -+ FILE *input; -+ struct cleanup *cleanups; -+ -+ realname = gdb_realpath (objfile->name); -+ len = strlen (realname); -+ filename = xmalloc (len + strlen (suffix) + 1); -+ memcpy (filename, realname, len); -+ strcpy (filename + len, suffix); -+ -+ cleanups = make_cleanup (xfree, filename); -+ make_cleanup (xfree, realname); -+ -+ input = fopen (filename, "r"); -+ debugfile = filename; -+ -+ if (!input && debug_file_directory) -+ { -+ /* Also try the same file in the separate debug info directory. */ -+ debugfile = xmalloc (strlen (filename) -+ + strlen (debug_file_directory) + 1); -+ strcpy (debugfile, debug_file_directory); -+ /* FILENAME is absolute, so we don't need a "/" here. */ -+ strcat (debugfile, filename); -+ -+ make_cleanup (xfree, debugfile); -+ input = fopen (debugfile, "r"); -+ } -+ -+ if (!input && gdb_datadir) -+ { -+ /* Also try the same file in a subdirectory of gdb's data -+ directory. */ -+ debugfile = xmalloc (strlen (gdb_datadir) + strlen (filename) -+ + strlen ("/auto-load") + 1); -+ strcpy (debugfile, gdb_datadir); -+ strcat (debugfile, "/auto-load"); -+ /* FILENAME is absolute, so we don't need a "/" here. */ -+ strcat (debugfile, filename); -+ -+ make_cleanup (xfree, debugfile); -+ input = fopen (debugfile, "r"); -+ } -+ -+ if (input) -+ { -+ struct auto_load_pspace_info *pspace_info; -+ -+ make_cleanup_fclose (input); -+ -+ /* Add this script to the hash table too so "info auto-load-scripts" -+ can print it. */ -+ pspace_info = -+ get_auto_load_pspace_data_for_loading (current_program_space); -+ maybe_add_script (pspace_info, debugfile, debugfile); -+ -+ /* To preserve existing behaviour we don't check for whether the -+ script was already in the table, and always load it. -+ It's highly unlikely that we'd ever load it twice, -+ and these scripts are required to be idempotent under multiple -+ loads anyway. */ -+ source_python_script_for_objfile (objfile, input, debugfile); -+ } -+ -+ do_cleanups (cleanups); -+} -+ -+/* This is a new_objfile observer callback to auto-load scripts. -+ -+ Two flavors of auto-loaded scripts are supported. -+ 1) based on the path to the objfile -+ 2) from .debug_gdb_scripts section */ -+ -+static void -+auto_load_new_objfile (struct objfile *objfile) -+{ -+ if (!objfile) -+ { -+ /* OBJFILE is NULL when loading a new "main" symbol-file. */ -+ clear_section_scripts (); -+ return; -+ } -+ -+ load_auto_scripts_for_objfile (objfile); -+} -+ -+/* Collect scripts to be printed in a vec. */ -+ -+typedef struct loaded_script *loaded_script_ptr; -+DEF_VEC_P (loaded_script_ptr); -+ -+/* Traversal function for htab_traverse. -+ Collect the entry if it matches the regexp. */ -+ -+static int -+collect_matching_scripts (void **slot, void *info) -+{ -+ struct loaded_script *script = *slot; -+ VEC (loaded_script_ptr) **scripts_ptr = info; -+ -+ if (re_exec (script->name)) -+ VEC_safe_push (loaded_script_ptr, *scripts_ptr, script); -+ -+ return 1; -+} -+ -+/* Print SCRIPT. */ -+ -+static void -+print_script (struct loaded_script *script) -+{ -+ struct ui_out *uiout = current_uiout; -+ struct cleanup *chain; -+ -+ chain = make_cleanup_ui_out_tuple_begin_end (uiout, NULL); -+ -+ ui_out_field_string (uiout, "loaded", script->full_path ? "Yes" : "Missing"); -+ ui_out_field_string (uiout, "script", script->name); -+ ui_out_text (uiout, "\n"); -+ -+ /* If the name isn't the full path, print it too. */ -+ if (script->full_path != NULL -+ && strcmp (script->name, script->full_path) != 0) -+ { -+ ui_out_text (uiout, "\tfull name: "); -+ ui_out_field_string (uiout, "full_path", script->full_path); -+ ui_out_text (uiout, "\n"); -+ } -+ -+ do_cleanups (chain); -+} -+ -+/* Helper for info_auto_load_scripts to sort the scripts by name. */ -+ -+static int -+sort_scripts_by_name (const void *ap, const void *bp) -+{ -+ const struct loaded_script *a = *(const struct loaded_script **) ap; -+ const struct loaded_script *b = *(const struct loaded_script **) bp; -+ -+ return FILENAME_CMP (a->name, b->name); -+} -+ -+/* "info auto-load-scripts" command. */ -+ -+static void -+info_auto_load_scripts (char *pattern, int from_tty) -+{ -+ struct ui_out *uiout = current_uiout; -+ struct auto_load_pspace_info *pspace_info; -+ struct cleanup *script_chain; -+ VEC (loaded_script_ptr) *scripts; -+ int nr_scripts; -+ -+ dont_repeat (); -+ -+ pspace_info = get_auto_load_pspace_data (current_program_space); -+ -+ if (pattern && *pattern) -+ { -+ char *re_err = re_comp (pattern); -+ -+ if (re_err) -+ error (_("Invalid regexp: %s"), re_err); -+ } -+ else -+ { -+ re_comp (""); -+ } -+ -+ /* We need to know the number of rows before we build the table. -+ Plus we want to sort the scripts by name. -+ So first traverse the hash table collecting the matching scripts. */ -+ -+ scripts = VEC_alloc (loaded_script_ptr, 10); -+ script_chain = make_cleanup (VEC_cleanup (loaded_script_ptr), &scripts); -+ -+ if (pspace_info != NULL && pspace_info->loaded_scripts != NULL) -+ { -+ immediate_quit++; -+ /* Pass a pointer to scripts as VEC_safe_push can realloc space. */ -+ htab_traverse_noresize (pspace_info->loaded_scripts, -+ collect_matching_scripts, &scripts); -+ immediate_quit--; -+ } -+ -+ nr_scripts = VEC_length (loaded_script_ptr, scripts); -+ make_cleanup_ui_out_table_begin_end (uiout, 2, nr_scripts, -+ "AutoLoadedScriptsTable"); -+ -+ ui_out_table_header (uiout, 7, ui_left, "loaded", "Loaded"); -+ ui_out_table_header (uiout, 70, ui_left, "script", "Script"); -+ ui_out_table_body (uiout); -+ -+ if (nr_scripts > 0) -+ { -+ int i; -+ loaded_script_ptr script; -+ -+ qsort (VEC_address (loaded_script_ptr, scripts), -+ VEC_length (loaded_script_ptr, scripts), -+ sizeof (loaded_script_ptr), sort_scripts_by_name); -+ for (i = 0; VEC_iterate (loaded_script_ptr, scripts, i, script); ++i) -+ print_script (script); -+ } -+ -+ do_cleanups (script_chain); -+ -+ if (nr_scripts == 0) -+ { -+ if (pattern && *pattern) -+ ui_out_message (uiout, 0, "No auto-load scripts matching %s.\n", -+ pattern); -+ else -+ ui_out_message (uiout, 0, "No auto-load scripts.\n"); -+ } -+} -+ -+/* Return non-zero if SCRIPT_NOT_FOUND_WARNING_PRINTED of PSPACE_INFO was unset -+ before calling this function. Always set SCRIPT_NOT_FOUND_WARNING_PRINTED -+ of PSPACE_INFO. */ -+ -+int -+script_not_found_warning_print (struct auto_load_pspace_info *pspace_info) -+{ -+ int retval = !pspace_info->script_not_found_warning_printed; -+ -+ pspace_info->script_not_found_warning_printed = 1; -+ -+ return retval; -+} -+ -+void _initialize_auto_load (void); -+ -+void -+_initialize_auto_load (void) -+{ -+ auto_load_pspace_data -+ = register_program_space_data_with_cleanup (auto_load_pspace_data_cleanup); -+ -+ observer_attach_new_objfile (auto_load_new_objfile); -+ -+ add_info ("auto-load-scripts", -+ info_auto_load_scripts, -+ _("Print the list of automatically loaded scripts.\n\ -+Usage: info auto-load-scripts [REGEXP]")); -+} -Index: gdb-7.4.50.20120120/gdb/auto-load.h -=================================================================== ---- /dev/null 1970-01-01 00:00:00.000000000 +0000 -+++ gdb-7.4.50.20120120/gdb/auto-load.h 2012-04-18 00:26:29.049120212 +0200 -@@ -0,0 +1,36 @@ -+/* GDB routines for supporting auto-loaded scripts. -+ -+ Copyright (C) 2012 Free Software Foundation, Inc. -+ -+ This file is part of GDB. -+ -+ This program is free software; you can redistribute it and/or modify -+ it under the terms of the GNU General Public License as published by -+ the Free Software Foundation; either version 3 of the License, or -+ (at your option) any later version. -+ -+ This program is distributed in the hope that it will be useful, -+ but WITHOUT ANY WARRANTY; without even the implied warranty of -+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+ GNU General Public License for more details. -+ -+ You should have received a copy of the GNU General Public License -+ along with this program. If not, see . */ -+ -+#ifndef AUTO_LOAD_H -+#define AUTO_LOAD_H 1 -+ -+struct program_space; -+ -+extern int gdbpy_global_auto_load; -+ -+extern struct auto_load_pspace_info * -+ get_auto_load_pspace_data_for_loading (struct program_space *pspace); -+extern int maybe_add_script (struct auto_load_pspace_info *pspace_info, -+ const char *name, const char *full_path); -+extern void auto_load_objfile_script (struct objfile *objfile, -+ const char *suffix); -+extern int -+ script_not_found_warning_print (struct auto_load_pspace_info *pspace_info); -+ -+#endif /* AUTO_LOAD_H */ -Index: gdb-7.4.50.20120120/gdb/gdb-gdb.gdb.in -=================================================================== ---- /dev/null 1970-01-01 00:00:00.000000000 +0000 -+++ gdb-7.4.50.20120120/gdb/gdb-gdb.gdb.in 2012-04-18 00:26:29.049120212 +0200 -@@ -0,0 +1,34 @@ -+echo Setting up the environment for debugging gdb.\n -+ -+set complaints 1 -+ -+b internal_error -+ -+b info_command -+commands -+ silent -+ return -+end -+ -+dir @srcdir@/../libiberty -+dir @srcdir@/../bfd -+dir @srcdir@ -+dir . -+set prompt (top-gdb) -+ -+define pdie -+ if $argc == 1 -+ call dump_die ($arg0, 1) -+ else -+ if $argc == 2 -+ call dump_die ($arg0, $arg1) -+ else -+ printf "Syntax: pdie die [depth]\n" -+ end -+ end -+end -+ -+document pdie -+Pretty print a DWARF DIE. -+Syntax: pdie die [depth] -+end -Index: gdb-7.4.50.20120120/gdb/Makefile.in -=================================================================== ---- gdb-7.4.50.20120120.orig/gdb/Makefile.in 2012-04-18 00:26:14.000000000 +0200 -+++ gdb-7.4.50.20120120/gdb/Makefile.in 2012-04-18 00:26:53.455058037 +0200 -@@ -680,7 +680,7 @@ TARGET_FLAGS_TO_PASS = \ - # SFILES is used in building the distribution archive. - - SFILES = ada-exp.y ada-lang.c ada-typeprint.c ada-valprint.c ada-tasks.c \ -- addrmap.c \ -+ addrmap.c auto-load.c \ - auxv.c ax-general.c ax-gdb.c \ - bcache.c \ - bfd-target.c \ -@@ -819,7 +819,7 @@ solib-darwin.h solib-ia64-hpux.h solib-s - gnulib/extra/arg-nonnull.h gnulib/extra/c++defs.h gnulib/extra/warn-on-use.h \ - gnulib/stddef.in.h inline-frame.h skip.h stap-probe.h \ - common/common-utils.h common/xml-utils.h common/buffer.h common/ptid.h \ --common/linux-osdata.h gdb-dlfcn.h -+common/linux-osdata.h gdb-dlfcn.h auto-load.h - - # Header files that already have srcdir in them, or which are in objdir. - -@@ -851,7 +851,7 @@ COMMON_OBS = $(DEPFILES) $(CONFIG_OBS) $ - version.o \ - annotate.o \ - addrmap.o \ -- auxv.o \ -+ auto-load.o auxv.o \ - bfd-target.o \ - blockframe.o breakpoint.o findvar.o regcache.o \ - charset.o continuations.o corelow.o disasm.o dummy-frame.o dfp.o \ -@@ -1255,7 +1255,7 @@ distclean: clean - rm -f gdbserver/config.status gdbserver/config.log - rm -f gdbserver/tm.h gdbserver/xm.h gdbserver/nm.h - rm -f gdbserver/Makefile gdbserver/config.cache -- rm -f nm.h config.status config.h stamp-h .gdbinit jit-reader.h -+ rm -f nm.h config.status config.h stamp-h gdb-gdb.gdb jit-reader.h - rm -f y.output yacc.acts yacc.tmp y.tab.h - rm -f config.log config.cache - rm -f Makefile -Index: gdb-7.4.50.20120120/gdb/configure -=================================================================== ---- gdb-7.4.50.20120120.orig/gdb/configure 2012-04-18 00:26:14.000000000 +0200 -+++ gdb-7.4.50.20120120/gdb/configure 2012-04-18 00:26:29.053120202 +0200 -@@ -16839,7 +16839,7 @@ ac_config_links="$ac_config_links $ac_co - $as_echo "#define GDB_DEFAULT_HOST_CHARSET \"UTF-8\"" >>confdefs.h - - --ac_config_files="$ac_config_files Makefile .gdbinit:gdbinit.in doc/Makefile gnulib/Makefile data-directory/Makefile" -+ac_config_files="$ac_config_files Makefile gdb-gdb.gdb doc/Makefile gnulib/Makefile data-directory/Makefile" - - ac_config_commands="$ac_config_commands default" - -@@ -17605,7 +17605,7 @@ do - "jit-reader.h") CONFIG_FILES="$CONFIG_FILES jit-reader.h:jit-reader.in" ;; - "$ac_config_links_1") CONFIG_LINKS="$CONFIG_LINKS $ac_config_links_1" ;; - "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;; -- ".gdbinit") CONFIG_FILES="$CONFIG_FILES .gdbinit:gdbinit.in" ;; -+ "gdb-gdb.gdb") CONFIG_FILES="$CONFIG_FILES gdb-gdb.gdb" ;; - "doc/Makefile") CONFIG_FILES="$CONFIG_FILES doc/Makefile" ;; - "gnulib/Makefile") CONFIG_FILES="$CONFIG_FILES gnulib/Makefile" ;; - "data-directory/Makefile") CONFIG_FILES="$CONFIG_FILES data-directory/Makefile" ;; -Index: gdb-7.4.50.20120120/gdb/configure.ac -=================================================================== ---- gdb-7.4.50.20120120.orig/gdb/configure.ac 2012-04-18 00:26:14.000000000 +0200 -+++ gdb-7.4.50.20120120/gdb/configure.ac 2012-04-18 00:26:29.053120202 +0200 -@@ -2422,7 +2422,7 @@ dnl At the moment, we just assume it's - AC_DEFINE(GDB_DEFAULT_HOST_CHARSET, "UTF-8", - [Define to be a string naming the default host character set.]) - --AC_OUTPUT(Makefile .gdbinit:gdbinit.in doc/Makefile gnulib/Makefile data-directory/Makefile, -+AC_OUTPUT(Makefile gdb-gdb.gdb doc/Makefile gnulib/Makefile data-directory/Makefile, - [ - case x$CONFIG_HEADERS in - xconfig.h:config.in) -Index: gdb-7.4.50.20120120/gdb/main.c -=================================================================== ---- gdb-7.4.50.20120120.orig/gdb/main.c 2012-04-18 00:26:14.000000000 +0200 -+++ gdb-7.4.50.20120120/gdb/main.c 2012-04-18 00:26:29.054120199 +0200 -@@ -42,6 +42,7 @@ - #include "cli/cli-cmds.h" - #include "python/python.h" - #include "objfiles.h" -+#include "auto-load.h" - - /* The selected interpreter. This will be used as a set command - variable, so it should always be malloc'ed - since -Index: gdb-7.4.50.20120120/gdb/python/py-auto-load.c -=================================================================== ---- gdb-7.4.50.20120120.orig/gdb/python/py-auto-load.c 2012-04-18 00:26:14.000000000 +0200 -+++ gdb-7.4.50.20120120/gdb/python/py-auto-load.c 2012-04-18 00:26:29.054120199 +0200 -@@ -18,30 +18,14 @@ - along with this program. If not, see . */ - - #include "defs.h" --#include "filenames.h" - #include "gdb_string.h" --#include "gdb_regex.h" - #include "top.h" - #include "exceptions.h" --#include "command.h" - #include "gdbcmd.h" --#include "observer.h" --#include "progspace.h" - #include "objfiles.h" - #include "python.h" - #include "cli/cli-cmds.h" -- --/* Internal-use flag to enable/disable auto-loading. -- This is true if we should auto-load python code when an objfile is opened, -- false otherwise. -- -- Both auto_load_scripts && gdbpy_global_auto_load must be true to enable -- auto-loading. -- -- This flag exists to facilitate deferring auto-loading during start-up -- until after ./.gdbinit has been read; it may augment the search directories -- used to find the scripts. */ --int gdbpy_global_auto_load = 1; -+#include "auto-load.h" - - #ifdef HAVE_PYTHON - -@@ -60,32 +44,6 @@ int gdbpy_global_auto_load = 1; - The leading byte is to allow upward compatible extensions. */ - #define GDBPY_AUTO_SECTION_NAME ".debug_gdb_scripts" - --/* For scripts specified in .debug_gdb_scripts, multiple objfiles may load -- the same script. There's no point in loading the script multiple times, -- and there can be a lot of objfiles and scripts, so we keep track of scripts -- loaded this way. */ -- --struct auto_load_pspace_info --{ -- /* For each program space we keep track of loaded scripts. */ -- struct htab *loaded_scripts; -- -- /* Non-zero if we've issued the warning about an auto-load script not being -- found. We only want to issue this warning once. */ -- int script_not_found_warning_printed; --}; -- --/* Objects of this type are stored in the loaded script hash table. */ -- --struct loaded_script --{ -- /* Name as provided by the objfile. */ -- const char *name; -- /* Full path name or NULL if script wasn't found (or was otherwise -- inaccessible). */ -- const char *full_path; --}; -- - /* User-settable option to enable/disable auto-loading: - set auto-load-scripts on|off - This is true if we should auto-load associated scripts when an objfile -@@ -97,136 +55,6 @@ struct loaded_script - The fact that it lives here is just an implementation detail. */ - static int auto_load_scripts = 1; - --/* Per-program-space data key. */ --static const struct program_space_data *auto_load_pspace_data; -- --static void --auto_load_pspace_data_cleanup (struct program_space *pspace, void *arg) --{ -- struct auto_load_pspace_info *info; -- -- info = program_space_data (pspace, auto_load_pspace_data); -- if (info != NULL) -- { -- if (info->loaded_scripts) -- htab_delete (info->loaded_scripts); -- xfree (info); -- } --} -- --/* Get the current autoload data. If none is found yet, add it now. This -- function always returns a valid object. */ -- --static struct auto_load_pspace_info * --get_auto_load_pspace_data (struct program_space *pspace) --{ -- struct auto_load_pspace_info *info; -- -- info = program_space_data (pspace, auto_load_pspace_data); -- if (info == NULL) -- { -- info = XZALLOC (struct auto_load_pspace_info); -- set_program_space_data (pspace, auto_load_pspace_data, info); -- } -- -- return info; --} -- --/* Hash function for the loaded script hash. */ -- --static hashval_t --hash_loaded_script_entry (const void *data) --{ -- const struct loaded_script *e = data; -- -- return htab_hash_string (e->name); --} -- --/* Equality function for the loaded script hash. */ -- --static int --eq_loaded_script_entry (const void *a, const void *b) --{ -- const struct loaded_script *ea = a; -- const struct loaded_script *eb = b; -- -- return strcmp (ea->name, eb->name) == 0; --} -- --/* Initialize the table to track loaded scripts. -- Each entry is hashed by the full path name. */ -- --static void --init_loaded_scripts_info (struct auto_load_pspace_info *pspace_info) --{ -- /* Choose 31 as the starting size of the hash table, somewhat arbitrarily. -- Space for each entry is obtained with one malloc so we can free them -- easily. */ -- -- pspace_info->loaded_scripts = htab_create (31, -- hash_loaded_script_entry, -- eq_loaded_script_entry, -- xfree); -- -- pspace_info->script_not_found_warning_printed = FALSE; --} -- --/* Wrapper on get_auto_load_pspace_data to also allocate the hash table -- for loading scripts. */ -- --static struct auto_load_pspace_info * --get_auto_load_pspace_data_for_loading (struct program_space *pspace) --{ -- struct auto_load_pspace_info *info; -- -- info = get_auto_load_pspace_data (pspace); -- if (info->loaded_scripts == NULL) -- init_loaded_scripts_info (info); -- -- return info; --} -- --/* Add script NAME to hash table HTAB. -- FULL_PATH is NULL if the script wasn't found. -- The result is true if the script was already in the hash table. */ -- --static int --maybe_add_script (struct htab *htab, const char *name, const char *full_path) --{ -- struct loaded_script **slot, entry; -- int in_hash_table; -- -- entry.name = name; -- entry.full_path = full_path; -- slot = (struct loaded_script **) htab_find_slot (htab, &entry, INSERT); -- in_hash_table = *slot != NULL; -- -- /* If this script is not in the hash table, add it. */ -- -- if (! in_hash_table) -- { -- char *p; -- -- /* Allocate all space in one chunk so it's easier to free. */ -- *slot = xmalloc (sizeof (**slot) -- + strlen (name) + 1 -- + (full_path != NULL ? (strlen (full_path) + 1) : 0)); -- p = ((char*) *slot) + sizeof (**slot); -- strcpy (p, name); -- (*slot)->name = p; -- if (full_path != NULL) -- { -- p += strlen (p) + 1; -- strcpy (p, full_path); -- (*slot)->full_path = p; -- } -- else -- (*slot)->full_path = NULL; -- } -- -- return in_hash_table; --} -- - /* Load scripts specified in OBJFILE. - START,END delimit a buffer containing a list of nul-terminated - file names. -@@ -301,20 +129,17 @@ source_section_scripts (struct objfile * - - IWBN if complaints.c were more general-purpose. */ - -- in_hash_table = maybe_add_script (pspace_info->loaded_scripts, file, -+ in_hash_table = maybe_add_script (pspace_info, file, - opened ? full_path : NULL); - - if (! opened) - { - /* We don't throw an error, the program is still debuggable. */ -- if (! pspace_info->script_not_found_warning_printed) -- { -- warning (_("Missing auto-load scripts referenced in section %s\n\ -+ if (script_not_found_warning_print (pspace_info)) -+ warning (_("Missing auto-load scripts referenced in section %s\n\ - of file %s\n\ - Use `info auto-load-scripts [REGEXP]' to list them."), -- GDBPY_AUTO_SECTION_NAME, objfile->name); -- pspace_info->script_not_found_warning_printed = TRUE; -- } -+ GDBPY_AUTO_SECTION_NAME, objfile->name); - } - else - { -@@ -356,116 +181,6 @@ auto_load_section_scripts (struct objfil - do_cleanups (cleanups); - } - --/* Clear the table of loaded section scripts. */ -- --static void --clear_section_scripts (void) --{ -- struct program_space *pspace = current_program_space; -- struct auto_load_pspace_info *info; -- -- info = program_space_data (pspace, auto_load_pspace_data); -- if (info != NULL && info->loaded_scripts != NULL) -- { -- htab_delete (info->loaded_scripts); -- info->loaded_scripts = NULL; -- info->script_not_found_warning_printed = FALSE; -- } --} -- --/* Look for the auto-load script associated with OBJFILE and load it. */ -- --static void --auto_load_objfile_script (struct objfile *objfile, const char *suffix) --{ -- char *realname; -- char *filename, *debugfile; -- int len; -- FILE *input; -- struct cleanup *cleanups; -- -- realname = gdb_realpath (objfile->name); -- len = strlen (realname); -- filename = xmalloc (len + strlen (suffix) + 1); -- memcpy (filename, realname, len); -- strcpy (filename + len, suffix); -- -- cleanups = make_cleanup (xfree, filename); -- make_cleanup (xfree, realname); -- -- input = fopen (filename, "r"); -- debugfile = filename; -- -- if (!input && debug_file_directory) -- { -- /* Also try the same file in the separate debug info directory. */ -- debugfile = xmalloc (strlen (filename) -- + strlen (debug_file_directory) + 1); -- strcpy (debugfile, debug_file_directory); -- /* FILENAME is absolute, so we don't need a "/" here. */ -- strcat (debugfile, filename); -- -- make_cleanup (xfree, debugfile); -- input = fopen (debugfile, "r"); -- } -- -- if (!input && gdb_datadir) -- { -- /* Also try the same file in a subdirectory of gdb's data -- directory. */ -- debugfile = xmalloc (strlen (gdb_datadir) + strlen (filename) -- + strlen ("/auto-load") + 1); -- strcpy (debugfile, gdb_datadir); -- strcat (debugfile, "/auto-load"); -- /* FILENAME is absolute, so we don't need a "/" here. */ -- strcat (debugfile, filename); -- -- make_cleanup (xfree, debugfile); -- input = fopen (debugfile, "r"); -- } -- -- if (input) -- { -- struct auto_load_pspace_info *pspace_info; -- -- make_cleanup_fclose (input); -- -- /* Add this script to the hash table too so "info auto-load-scripts" -- can print it. */ -- pspace_info = -- get_auto_load_pspace_data_for_loading (current_program_space); -- maybe_add_script (pspace_info->loaded_scripts, debugfile, debugfile); -- -- /* To preserve existing behaviour we don't check for whether the -- script was already in the table, and always load it. -- It's highly unlikely that we'd ever load it twice, -- and these scripts are required to be idempotent under multiple -- loads anyway. */ -- source_python_script_for_objfile (objfile, input, debugfile); -- } -- -- do_cleanups (cleanups); --} -- --/* This is a new_objfile observer callback to auto-load scripts. -- -- Two flavors of auto-loaded scripts are supported. -- 1) based on the path to the objfile -- 2) from .debug_gdb_scripts section */ -- --static void --auto_load_new_objfile (struct objfile *objfile) --{ -- if (!objfile) -- { -- /* OBJFILE is NULL when loading a new "main" symbol-file. */ -- clear_section_scripts (); -- return; -- } -- -- load_auto_scripts_for_objfile (objfile); --} -- - /* Load any auto-loaded scripts for OBJFILE. */ - - void -@@ -478,146 +193,9 @@ load_auto_scripts_for_objfile (struct ob - } - } - --/* Collect scripts to be printed in a vec. */ -- --typedef struct loaded_script *loaded_script_ptr; --DEF_VEC_P (loaded_script_ptr); -- --/* Traversal function for htab_traverse. -- Collect the entry if it matches the regexp. */ -- --static int --collect_matching_scripts (void **slot, void *info) --{ -- struct loaded_script *script = *slot; -- VEC (loaded_script_ptr) **scripts_ptr = info; -- -- if (re_exec (script->name)) -- VEC_safe_push (loaded_script_ptr, *scripts_ptr, script); -- -- return 1; --} -- --/* Print SCRIPT. */ -- --static void --print_script (struct loaded_script *script) --{ -- struct ui_out *uiout = current_uiout; -- struct cleanup *chain; -- -- chain = make_cleanup_ui_out_tuple_begin_end (uiout, NULL); -- -- ui_out_field_string (uiout, "loaded", script->full_path ? "Yes" : "Missing"); -- ui_out_field_string (uiout, "script", script->name); -- ui_out_text (uiout, "\n"); -- -- /* If the name isn't the full path, print it too. */ -- if (script->full_path != NULL -- && strcmp (script->name, script->full_path) != 0) -- { -- ui_out_text (uiout, "\tfull name: "); -- ui_out_field_string (uiout, "full_path", script->full_path); -- ui_out_text (uiout, "\n"); -- } -- -- do_cleanups (chain); --} -- --/* Helper for info_auto_load_scripts to sort the scripts by name. */ -- --static int --sort_scripts_by_name (const void *ap, const void *bp) --{ -- const struct loaded_script *a = *(const struct loaded_script **) ap; -- const struct loaded_script *b = *(const struct loaded_script **) bp; -- -- return FILENAME_CMP (a->name, b->name); --} -- --/* "info auto-load-scripts" command. */ -- --static void --info_auto_load_scripts (char *pattern, int from_tty) --{ -- struct ui_out *uiout = current_uiout; -- struct auto_load_pspace_info *pspace_info; -- struct cleanup *script_chain; -- VEC (loaded_script_ptr) *scripts; -- int nr_scripts; -- -- dont_repeat (); -- -- pspace_info = get_auto_load_pspace_data (current_program_space); -- -- if (pattern && *pattern) -- { -- char *re_err = re_comp (pattern); -- -- if (re_err) -- error (_("Invalid regexp: %s"), re_err); -- } -- else -- { -- re_comp (""); -- } -- -- /* We need to know the number of rows before we build the table. -- Plus we want to sort the scripts by name. -- So first traverse the hash table collecting the matching scripts. */ -- -- scripts = VEC_alloc (loaded_script_ptr, 10); -- script_chain = make_cleanup (VEC_cleanup (loaded_script_ptr), &scripts); -- -- if (pspace_info != NULL && pspace_info->loaded_scripts != NULL) -- { -- immediate_quit++; -- /* Pass a pointer to scripts as VEC_safe_push can realloc space. */ -- htab_traverse_noresize (pspace_info->loaded_scripts, -- collect_matching_scripts, &scripts); -- immediate_quit--; -- } -- -- nr_scripts = VEC_length (loaded_script_ptr, scripts); -- make_cleanup_ui_out_table_begin_end (uiout, 2, nr_scripts, -- "AutoLoadedScriptsTable"); -- -- ui_out_table_header (uiout, 7, ui_left, "loaded", "Loaded"); -- ui_out_table_header (uiout, 70, ui_left, "script", "Script"); -- ui_out_table_body (uiout); -- -- if (nr_scripts > 0) -- { -- int i; -- loaded_script_ptr script; -- -- qsort (VEC_address (loaded_script_ptr, scripts), -- VEC_length (loaded_script_ptr, scripts), -- sizeof (loaded_script_ptr), sort_scripts_by_name); -- for (i = 0; VEC_iterate (loaded_script_ptr, scripts, i, script); ++i) -- print_script (script); -- } -- -- do_cleanups (script_chain); -- -- if (nr_scripts == 0) -- { -- if (pattern && *pattern) -- ui_out_message (uiout, 0, "No auto-load scripts matching %s.\n", -- pattern); -- else -- ui_out_message (uiout, 0, "No auto-load scripts.\n"); -- } --} -- - void - gdbpy_initialize_auto_load (void) - { -- auto_load_pspace_data -- = register_program_space_data_with_cleanup (auto_load_pspace_data_cleanup); -- -- observer_attach_new_objfile (auto_load_new_objfile); -- - add_setshow_boolean_cmd ("auto-load-scripts", class_support, - &auto_load_scripts, _("\ - Set the debugger's behaviour regarding auto-loaded scripts."), _("\ -@@ -627,11 +205,6 @@ an executable or shared library."), - NULL, NULL, - &setlist, - &showlist); -- -- add_info ("auto-load-scripts", -- info_auto_load_scripts, -- _("Print the list of automatically loaded scripts.\n\ --Usage: info auto-load-scripts [REGEXP]")); - } - - #else /* ! HAVE_PYTHON */ -Index: gdb-7.4.50.20120120/gdb/python/python.h -=================================================================== ---- gdb-7.4.50.20120120.orig/gdb/python/python.h 2012-04-18 00:26:14.000000000 +0200 -+++ gdb-7.4.50.20120120/gdb/python/python.h 2012-04-18 00:26:29.054120199 +0200 -@@ -24,8 +24,6 @@ - - struct breakpoint_object; - --extern int gdbpy_global_auto_load; -- - extern void finish_python_initialization (void); - - void eval_python_from_control_command (struct command_line *); diff --git a/gdb-autoload-10of28.patch b/gdb-autoload-10of28.patch deleted file mode 100644 index c596982..0000000 --- a/gdb-autoload-10of28.patch +++ /dev/null @@ -1,1704 +0,0 @@ -[patch#4 4/8] set auto-load * main part -http://sourceware.org/ml/gdb-patches/2012-04/msg00088.html -http://sourceware.org/ml/gdb-cvs/2012-04/msg00113.html - -### src/gdb/ChangeLog 2012/04/17 15:49:11 1.14112 -### src/gdb/ChangeLog 2012/04/17 15:51:41 1.14113 -## -1,5 +1,101 @@ - 2012-04-17 Jan Kratochvil - -+ auto-load: Implementation. -+ * NEWS: New descriptions for "info auto-load", -+ "info auto-load gdb-scripts", "info auto-load python-scripts", -+ "info auto-load local-gdbinit" and "info auto-load libthread-db". -+ Deprecate "info auto-load-scripts", "set auto-load-scripts on|off" -+ and "show auto-load-scripts". New description for "set auto-load", -+ "show auto-load", "set auto-load gdb-scripts", -+ "show auto-load gdb-scripts", "set auto-load python-scripts", -+ "show auto-load python-scripts", "set auto-load local-gdbinit", -+ "show auto-load local-gdbinit", "set auto-load libthread-db" and -+ "show auto-load libthread-db". -+ * auto-load.c: Remove include python/python-internal.h. Add includes -+ exceptions.h, cli/cli-script.h, gdbcmd.h, cli/cli-decode.h and -+ cli/cli-setshow.h. -+ (GDB_AUTO_FILE_NAME, source_gdb_script_for_objfile) -+ (auto_load_gdb_scripts, show_auto_load_gdb_scripts): New. -+ (gdbpy_global_auto_load): Rename to ... -+ (global_auto_load): ... here. -+ (auto_load_local_gdbinit, auto_load_local_gdbinit_pathname) -+ (auto_load_local_gdbinit_loaded, show_auto_load_local_gdbinit) -+ (script_language_gdb, source_gdb_script_for_objfile): New. -+ (struct loaded_script): New field language. -+ (hash_loaded_script_entry, eq_loaded_script_entry): Calculate also -+ LANGUAGE. -+ (maybe_add_script): Add parameter language. Drop redundant -+ entry.full_path initialization. Initialize entry.language and -+ (*slot)->language. -+ (auto_load_objfile_script): Change parameter suffix to language. -+ Remove the call of maybe_add_script. -+ Call language->source_script_for_objfile. -+ (load_auto_scripts_for_objfile, struct collect_matching_scripts_data): -+ New. -+ (collect_matching_scripts): Adjust it for -+ struct collect_matching_scripts_data. -+ (auto_load_info_scripts_pattern_nl): New variable. -+ (info_auto_load_scripts): Rename to ... -+ (auto_load_info_scripts): ... here, add parameter language. Adjust it -+ for struct collect_matching_scripts_data. -+ (info_auto_load_gdb_scripts, info_auto_load_local_gdbinit) -+ (set_auto_load_cmd, auto_load_set_cmdlist_get, show_auto_load_cmd) -+ (auto_load_show_cmdlist_get, info_auto_load_cmd) -+ (auto_load_info_cmdlist_get): New. -+ (_initialize_auto_load): Move add_info of "auto-load-scripts" to -+ python/py-auto-load.c. New installment for "set auto-load gdb-scripts", -+ "info auto-load gdb-scripts", "set auto-load local-gdbinit" and -+ "info auto-load local-gdbinit". -+ * auto-load.h (struct script_language): New. -+ (gdbpy_global_auto_load): Rename to ... -+ (global_auto_load): ... here. -+ (auto_load_local_gdbinit, auto_load_local_gdbinit_pathname) -+ (auto_load_local_gdbinit_loaded): New declarations. -+ (maybe_add_script): New parameter language. -+ (auto_load_objfile_script): Change parameter suffix to language. -+ (load_auto_scripts_for_objfile, auto_load_info_scripts_pattern_nl) -+ (auto_load_info_scripts, auto_load_set_cmdlist_get) -+ (auto_load_show_cmdlist_get, auto_load_info_cmdlist_get): New -+ declarations. -+ * linux-thread-db.c: Include auto-load.h and ctype.h. -+ (auto_load_thread_db, show_auto_load_thread_db): New. -+ (struct thread_db_info): New field filename. -+ (delete_thread_db_info): Call xfree for FILENAME. -+ (try_thread_db_load): Initialize FILENAME. -+ (try_thread_db_load_from_pdir, try_thread_db_load_from_dir): Return -+ if !AUTO_LOAD_THREAD_DB. -+ (info_auto_load_libthread_db_compare, info_auto_load_libthread_db): New. -+ (_initialize_thread_db): Install auto_load_thread_db -+ as "set auto-load libthread-db" and install info_auto_load_libthread_db -+ as "info auto-load libthread-db". -+ * main.c (captured_main): Rename gdbpy_global_auto_load to -+ global_auto_load. Initialize AUTO_LOAD_LOCAL_GDBINIT_PATHNAME and -+ AUTO_LOAD_LOCAL_GDBINIT_LOADED. -+ (print_gdb_help): Extend the help for 'local init file'. -+ * python/py-auto-load.c: Remove a comment about gdb scripts extension. -+ (GDBPY_AUTO_SECTION_NAME): Extend the comment it is Python specific. -+ (auto_load_scripts): Rename to ... -+ (auto_load_python_scripts): ... here, update the comment. -+ (gdbpy_load_auto_script_for_objfile): New declaration. -+ (show_auto_load_python_scripts, script_language_python) -+ (gdbpy_load_auto_script_for_objfile): New. -+ (source_section_scripts): Refactor the code. -+ (load_auto_scripts_for_objfile): Rename to ... -+ (gdbpy_load_auto_scripts_for_objfile): ... here, update the -+ auto_load_objfile_script caller, drop GDBPY_GLOBAL_AUTO_LOAD checking. -+ (info_auto_load_python_scripts): New. -+ (gdbpy_initialize_auto_load): New variables cmd and cmd_name. -+ Rename "set auto-load-scripts" to "set auto-load python-scripts". -+ Register "set auto-load-scripts" as its deprecated alias. Register -+ "info auto-load python-scripts". Register "info auto-load-scripts" as -+ its deprecated alias. -+ (load_auto_scripts_for_objfile): Rename to ... -+ (gdbpy_load_auto_scripts_for_objfile): ... here. -+ * python/python.h (load_auto_scripts_for_objfile): Rename to ... -+ (gdbpy_load_auto_scripts_for_objfile): ... here. -+ -+2012-04-17 Jan Kratochvil -+ - auto-load: Move files. - * Makefile.in (SFILES): Add auto-load.c. - (HFILES_NO_SRCDIR): Add auto-load.h. -Index: gdb-7.4.50.20120120/gdb/NEWS -=================================================================== ---- gdb-7.4.50.20120120.orig/gdb/NEWS 2012-04-18 00:42:51.226681068 +0200 -+++ gdb-7.4.50.20120120/gdb/NEWS 2012-04-18 00:49:02.035737644 +0200 -@@ -28,6 +28,45 @@ - now set a breakpoint in build/gcc/expr.c, but not - build/libcpp/expr.c. - -+* New commands -+ -+ ** "info auto-load" shows status of all kinds of auto-loaded files, -+ "info auto-load gdb-scripts" shows status of auto-loading GDB canned -+ sequences of commands files, "info auto-load python-scripts" -+ shows status of auto-loading Python script files, -+ "info auto-load local-gdbinit" shows status of loading init file -+ (.gdbinit) from current directory and "info auto-load libthread-db" shows -+ status of inferior specific thread debugging shared library loading. -+ -+ ** "info auto-load-scripts", "set auto-load-scripts on|off" -+ and "show auto-load-scripts" commands have been deprecated, use their -+ "info auto-load python-scripts", "set auto-load python-scripts on|off" -+ and "show auto-load python-scripts" counterparts instead. -+ -+* New options -+ -+set auto-load off -+ Disable auto-loading globally. -+ -+show auto-load -+ Show auto-loading setting of all kinds of auto-loaded files. -+ -+set auto-load gdb-scripts on|off -+show auto-load gdb-scripts -+ Control auto-loading of GDB canned sequences of commands files. -+ -+set auto-load python-scripts on|off -+show auto-load python-scripts -+ Control auto-loading of Python script files. -+ -+set auto-load local-gdbinit on|off -+show auto-load local-gdbinit -+ Control loading of init file (.gdbinit) from current directory. -+ -+set auto-load libthread-db on|off -+show auto-load libthread-db -+ Control auto-loading of inferior specific thread debugging shared library. -+ - * New command line options - - --init-command=FILE, -ix Like --command, -x but execute it -Index: gdb-7.4.50.20120120/gdb/auto-load.c -=================================================================== ---- gdb-7.4.50.20120120.orig/gdb/auto-load.c 2012-04-18 00:44:26.950437520 +0200 -+++ gdb-7.4.50.20120120/gdb/auto-load.c 2012-04-18 00:46:47.556079780 +0200 -@@ -27,19 +27,92 @@ - #include "command.h" - #include "observer.h" - #include "objfiles.h" --#include "python/python-internal.h" -+#include "exceptions.h" -+#include "cli/cli-script.h" -+#include "gdbcmd.h" -+#include "cli/cli-decode.h" -+#include "cli/cli-setshow.h" -+ -+/* The suffix of per-objfile scripts to auto-load as non-Python command files. -+ E.g. When the program loads libfoo.so, look for libfoo-gdb.gdb. */ -+#define GDB_AUTO_FILE_NAME "-gdb.gdb" -+ -+static void source_gdb_script_for_objfile (struct objfile *objfile, FILE *file, -+ const char *filename); -+ -+/* User-settable option to enable/disable auto-loading of GDB_AUTO_FILE_NAME -+ scripts: -+ set auto-load gdb-scripts on|off -+ This is true if we should auto-load associated scripts when an objfile -+ is opened, false otherwise. */ -+static int auto_load_gdb_scripts = 1; -+ -+/* "show" command for the auto_load_gdb_scripts configuration variable. */ -+ -+static void -+show_auto_load_gdb_scripts (struct ui_file *file, int from_tty, -+ struct cmd_list_element *c, const char *value) -+{ -+ fprintf_filtered (file, _("Auto-loading of canned sequences of commands " -+ "scripts is %s.\n"), -+ value); -+} - - /* Internal-use flag to enable/disable auto-loading. - This is true if we should auto-load python code when an objfile is opened, - false otherwise. - -- Both auto_load_scripts && gdbpy_global_auto_load must be true to enable -+ Both auto_load_scripts && global_auto_load must be true to enable - auto-loading. - - This flag exists to facilitate deferring auto-loading during start-up - until after ./.gdbinit has been read; it may augment the search directories - used to find the scripts. */ --int gdbpy_global_auto_load = 1; -+int global_auto_load = 1; -+ -+/* Auto-load .gdbinit file from the current directory? */ -+int auto_load_local_gdbinit = 1; -+ -+/* Absolute pathname to the current directory .gdbinit, if it exists. */ -+char *auto_load_local_gdbinit_pathname = NULL; -+ -+/* Boolean value if AUTO_LOAD_LOCAL_GDBINIT_PATHNAME has been loaded. */ -+int auto_load_local_gdbinit_loaded = 0; -+ -+/* "show" command for the auto_load_local_gdbinit configuration variable. */ -+ -+static void -+show_auto_load_local_gdbinit (struct ui_file *file, int from_tty, -+ struct cmd_list_element *c, const char *value) -+{ -+ fprintf_filtered (file, _("Auto-loading of .gdbinit script from current " -+ "directory is %s.\n"), -+ value); -+} -+ -+/* Definition of script language for GDB canned sequences of commands. */ -+ -+static const struct script_language script_language_gdb -+ = { GDB_AUTO_FILE_NAME, source_gdb_script_for_objfile }; -+ -+static void -+source_gdb_script_for_objfile (struct objfile *objfile, FILE *file, -+ const char *filename) -+{ -+ struct auto_load_pspace_info *pspace_info; -+ volatile struct gdb_exception e; -+ -+ /* Add this script to the hash table too so "info auto-load gdb-scripts" -+ can print it. */ -+ pspace_info = get_auto_load_pspace_data_for_loading (current_program_space); -+ maybe_add_script (pspace_info, filename, filename, &script_language_gdb); -+ -+ TRY_CATCH (e, RETURN_MASK_ALL) -+ { -+ script_from_file (file, filename); -+ } -+ exception_print (gdb_stderr, e); -+} - - /* For scripts specified in .debug_gdb_scripts, multiple objfiles may load - the same script. There's no point in loading the script multiple times, -@@ -62,9 +135,12 @@ struct loaded_script - { - /* Name as provided by the objfile. */ - const char *name; -+ - /* Full path name or NULL if script wasn't found (or was otherwise - inaccessible). */ - const char *full_path; -+ -+ const struct script_language *language; - }; - - /* Per-program-space data key. */ -@@ -109,7 +185,7 @@ hash_loaded_script_entry (const void *da - { - const struct loaded_script *e = data; - -- return htab_hash_string (e->name); -+ return htab_hash_string (e->name) ^ htab_hash_pointer (e->language); - } - - /* Equality function for the loaded script hash. */ -@@ -120,7 +196,7 @@ eq_loaded_script_entry (const void *a, c - const struct loaded_script *ea = a; - const struct loaded_script *eb = b; - -- return strcmp (ea->name, eb->name) == 0; -+ return strcmp (ea->name, eb->name) == 0 && ea->language == eb->language; - } - - /* Initialize the table to track loaded scripts. -@@ -156,20 +232,21 @@ get_auto_load_pspace_data_for_loading (s - return info; - } - --/* Add script NAME to hash table of PSPACE_INFO. -- FULL_PATH is NULL if the script wasn't found. -- The result is true if the script was already in the hash table. */ -+/* Add script NAME in LANGUAGE to hash table of PSPACE_INFO. -+ FULL_PATH is NULL if the script wasn't found. The result is -+ true if the script was already in the hash table. */ - - int --maybe_add_script (struct auto_load_pspace_info *pspace_info, const char *name, -- const char *full_path) -+maybe_add_script (struct auto_load_pspace_info *pspace_info, -+ const char *name, const char *full_path, -+ const struct script_language *language) - { - struct htab *htab = pspace_info->loaded_scripts; - struct loaded_script **slot, entry; - int in_hash_table; - - entry.name = name; -- entry.full_path = full_path; -+ entry.language = language; - slot = (struct loaded_script **) htab_find_slot (htab, &entry, INSERT); - in_hash_table = *slot != NULL; - -@@ -194,6 +271,7 @@ maybe_add_script (struct auto_load_pspac - } - else - (*slot)->full_path = NULL; -+ (*slot)->language = language; - } - - return in_hash_table; -@@ -216,10 +294,12 @@ clear_section_scripts (void) - } - } - --/* Look for the auto-load script associated with OBJFILE and load it. */ -+/* Look for the auto-load script in LANGUAGE associated with OBJFILE and load -+ it. */ - - void --auto_load_objfile_script (struct objfile *objfile, const char *suffix) -+auto_load_objfile_script (struct objfile *objfile, -+ const struct script_language *language) - { - char *realname; - char *filename, *debugfile; -@@ -229,9 +309,9 @@ auto_load_objfile_script (struct objfile - - realname = gdb_realpath (objfile->name); - len = strlen (realname); -- filename = xmalloc (len + strlen (suffix) + 1); -+ filename = xmalloc (len + strlen (language->suffix) + 1); - memcpy (filename, realname, len); -- strcpy (filename + len, suffix); -+ strcpy (filename + len, language->suffix); - - cleanups = make_cleanup (xfree, filename); - make_cleanup (xfree, realname); -@@ -269,27 +349,33 @@ auto_load_objfile_script (struct objfile - - if (input) - { -- struct auto_load_pspace_info *pspace_info; -- - make_cleanup_fclose (input); - -- /* Add this script to the hash table too so "info auto-load-scripts" -- can print it. */ -- pspace_info = -- get_auto_load_pspace_data_for_loading (current_program_space); -- maybe_add_script (pspace_info, debugfile, debugfile); -- - /* To preserve existing behaviour we don't check for whether the - script was already in the table, and always load it. - It's highly unlikely that we'd ever load it twice, - and these scripts are required to be idempotent under multiple - loads anyway. */ -- source_python_script_for_objfile (objfile, input, debugfile); -+ language->source_script_for_objfile (objfile, input, debugfile); - } - - do_cleanups (cleanups); - } - -+/* Load any auto-loaded scripts for OBJFILE. */ -+ -+void -+load_auto_scripts_for_objfile (struct objfile *objfile) -+{ -+ if (!global_auto_load) -+ return; -+ -+ if (auto_load_gdb_scripts) -+ auto_load_objfile_script (objfile, &script_language_gdb); -+ -+ gdbpy_load_auto_scripts_for_objfile (objfile); -+} -+ - /* This is a new_objfile observer callback to auto-load scripts. - - Two flavors of auto-loaded scripts are supported. -@@ -314,6 +400,13 @@ auto_load_new_objfile (struct objfile *o - typedef struct loaded_script *loaded_script_ptr; - DEF_VEC_P (loaded_script_ptr); - -+struct collect_matching_scripts_data -+{ -+ VEC (loaded_script_ptr) **scripts_p; -+ -+ const struct script_language *language; -+}; -+ - /* Traversal function for htab_traverse. - Collect the entry if it matches the regexp. */ - -@@ -321,10 +414,10 @@ static int - collect_matching_scripts (void **slot, void *info) - { - struct loaded_script *script = *slot; -- VEC (loaded_script_ptr) **scripts_ptr = info; -+ struct collect_matching_scripts_data *data = info; - -- if (re_exec (script->name)) -- VEC_safe_push (loaded_script_ptr, *scripts_ptr, script); -+ if (script->language == data->language && re_exec (script->name)) -+ VEC_safe_push (loaded_script_ptr, *data->scripts_p, script); - - return 1; - } -@@ -366,10 +459,18 @@ sort_scripts_by_name (const void *ap, co - return FILENAME_CMP (a->name, b->name); - } - --/* "info auto-load-scripts" command. */ -+/* Special internal GDB value of auto_load_info_scripts's PATTERN identify -+ the "info auto-load XXX" command has been executed through the general -+ "info auto-load" invocation. Extra newline will be printed if needed. */ -+char auto_load_info_scripts_pattern_nl[] = ""; -+ -+/* Implementation for "info auto-load gdb-scripts" -+ (and "info auto-load python-scripts"). List scripts in LANGUAGE matching -+ PATTERN. FROM_TTY is the usual GDB boolean for user interactivity. */ - --static void --info_auto_load_scripts (char *pattern, int from_tty) -+void -+auto_load_info_scripts (char *pattern, int from_tty, -+ const struct script_language *language) - { - struct ui_out *uiout = current_uiout; - struct auto_load_pspace_info *pspace_info; -@@ -402,14 +503,22 @@ info_auto_load_scripts (char *pattern, i - - if (pspace_info != NULL && pspace_info->loaded_scripts != NULL) - { -+ struct collect_matching_scripts_data data = { &scripts, language }; -+ - immediate_quit++; - /* Pass a pointer to scripts as VEC_safe_push can realloc space. */ - htab_traverse_noresize (pspace_info->loaded_scripts, -- collect_matching_scripts, &scripts); -+ collect_matching_scripts, &data); - immediate_quit--; - } - - nr_scripts = VEC_length (loaded_script_ptr, scripts); -+ -+ /* Table header shifted right by preceding "gdb-scripts: " would not match -+ its columns. */ -+ if (nr_scripts > 0 && pattern == auto_load_info_scripts_pattern_nl) -+ ui_out_text (uiout, "\n"); -+ - make_cleanup_ui_out_table_begin_end (uiout, 2, nr_scripts, - "AutoLoadedScriptsTable"); - -@@ -441,6 +550,29 @@ info_auto_load_scripts (char *pattern, i - } - } - -+/* Wrapper for "info auto-load gdb-scripts". */ -+ -+static void -+info_auto_load_gdb_scripts (char *pattern, int from_tty) -+{ -+ auto_load_info_scripts (pattern, from_tty, &script_language_gdb); -+} -+ -+/* Implement 'info auto-load local-gdbinit'. */ -+ -+static void -+info_auto_load_local_gdbinit (char *args, int from_tty) -+{ -+ if (auto_load_local_gdbinit_pathname == NULL) -+ printf_filtered (_("Local .gdbinit file was not found.\n")); -+ else if (auto_load_local_gdbinit_loaded) -+ printf_filtered (_("Local .gdbinit file \"%s\" has been loaded.\n"), -+ auto_load_local_gdbinit_pathname); -+ else -+ printf_filtered (_("Local .gdbinit file \"%s\" has not been loaded.\n"), -+ auto_load_local_gdbinit_pathname); -+} -+ - /* Return non-zero if SCRIPT_NOT_FOUND_WARNING_PRINTED of PSPACE_INFO was unset - before calling this function. Always set SCRIPT_NOT_FOUND_WARNING_PRINTED - of PSPACE_INFO. */ -@@ -455,6 +587,132 @@ script_not_found_warning_print (struct a - return retval; - } - -+/* The only valid "set auto-load" argument is off|0|no|disable. */ -+ -+static void -+set_auto_load_cmd (char *args, int from_tty) -+{ -+ struct cmd_list_element *list; -+ size_t length; -+ -+ /* See parse_binary_operation in use by the sub-commands. */ -+ -+ length = args ? strlen (args) : 0; -+ -+ while (length > 0 && (args[length - 1] == ' ' || args[length - 1] == '\t')) -+ length--; -+ -+ if (length == 0 || (strncmp (args, "off", length) != 0 -+ && strncmp (args, "0", length) != 0 -+ && strncmp (args, "no", length) != 0 -+ && strncmp (args, "disable", length) != 0)) -+ error (_("Valid is only global 'set auto-load no'; " -+ "otherwise check the auto-load sub-commands.")); -+ -+ for (list = *auto_load_set_cmdlist_get (); list != NULL; list = list->next) -+ if (list->var_type == var_boolean) -+ { -+ gdb_assert (list->type == set_cmd); -+ do_setshow_command (args, from_tty, list); -+ } -+} -+ -+/* Initialize "set auto-load " commands prefix and return it. */ -+ -+struct cmd_list_element ** -+auto_load_set_cmdlist_get (void) -+{ -+ static struct cmd_list_element *retval; -+ -+ if (retval == NULL) -+ add_prefix_cmd ("auto-load", class_maintenance, set_auto_load_cmd, _("\ -+Auto-loading specific settings.\n\ -+Configure various auto-load-specific variables such as\n\ -+automatic loading of Python scripts."), -+ &retval, "set auto-load ", -+ 1/*allow-unknown*/, &setlist); -+ -+ return &retval; -+} -+ -+/* Command "show auto-load" displays summary of all the current -+ "show auto-load " settings. */ -+ -+static void -+show_auto_load_cmd (char *args, int from_tty) -+{ -+ cmd_show_list (*auto_load_show_cmdlist_get (), from_tty, ""); -+} -+ -+/* Initialize "show auto-load " commands prefix and return it. */ -+ -+struct cmd_list_element ** -+auto_load_show_cmdlist_get (void) -+{ -+ static struct cmd_list_element *retval; -+ -+ if (retval == NULL) -+ add_prefix_cmd ("auto-load", class_maintenance, show_auto_load_cmd, _("\ -+Show auto-loading specific settings.\n\ -+Show configuration of various auto-load-specific variables such as\n\ -+automatic loading of Python scripts."), -+ &retval, "show auto-load ", -+ 0/*allow-unknown*/, &showlist); -+ -+ return &retval; -+} -+ -+/* Command "info auto-load" displays whether the various auto-load files have -+ been loaded. This is reimplementation of cmd_show_list which inserts -+ newlines at proper places. */ -+ -+static void -+info_auto_load_cmd (char *args, int from_tty) -+{ -+ struct cmd_list_element *list; -+ struct cleanup *infolist_chain; -+ struct ui_out *uiout = current_uiout; -+ -+ infolist_chain = make_cleanup_ui_out_tuple_begin_end (uiout, "infolist"); -+ -+ for (list = *auto_load_info_cmdlist_get (); list != NULL; list = list->next) -+ { -+ struct cleanup *option_chain -+ = make_cleanup_ui_out_tuple_begin_end (uiout, "option"); -+ -+ gdb_assert (!list->prefixlist); -+ gdb_assert (list->type == not_set_cmd); -+ -+ ui_out_field_string (uiout, "name", list->name); -+ ui_out_text (uiout, ": "); -+ cmd_func (list, auto_load_info_scripts_pattern_nl, from_tty); -+ -+ /* Close the tuple. */ -+ do_cleanups (option_chain); -+ } -+ -+ /* Close the tuple. */ -+ do_cleanups (infolist_chain); -+} -+ -+/* Initialize "info auto-load " commands prefix and return it. */ -+ -+struct cmd_list_element ** -+auto_load_info_cmdlist_get (void) -+{ -+ static struct cmd_list_element *retval; -+ -+ if (retval == NULL) -+ add_prefix_cmd ("auto-load", class_info, info_auto_load_cmd, _("\ -+Print current status of auto-loaded files.\n\ -+Print whether various files like Python scripts or .gdbinit files have been\n\ -+found and/or loaded."), -+ &retval, "info auto-load ", -+ 0/*allow-unknown*/, &infolist); -+ -+ return &retval; -+} -+ - void _initialize_auto_load (void); - - void -@@ -465,8 +723,38 @@ _initialize_auto_load (void) - - observer_attach_new_objfile (auto_load_new_objfile); - -- add_info ("auto-load-scripts", -- info_auto_load_scripts, -- _("Print the list of automatically loaded scripts.\n\ --Usage: info auto-load-scripts [REGEXP]")); -+ add_setshow_boolean_cmd ("gdb-scripts", class_support, -+ &auto_load_gdb_scripts, _("\ -+Enable or disable auto-loading of canned sequences of commands scripts."), _("\ -+Show whether auto-loading of canned sequences of commands scripts is enabled."), -+ _("\ -+If enabled, canned sequences of commands are loaded when the debugger reads\n\ -+an executable or shared library.\n\ -+This options has security implications for untrusted inferiors."), -+ NULL, show_auto_load_gdb_scripts, -+ auto_load_set_cmdlist_get (), -+ auto_load_show_cmdlist_get ()); -+ -+ add_cmd ("gdb-scripts", class_info, info_auto_load_gdb_scripts, -+ _("Print the list of automatically loaded sequences of commands.\n\ -+Usage: info auto-load gdb-scripts [REGEXP]"), -+ auto_load_info_cmdlist_get ()); -+ -+ add_setshow_boolean_cmd ("local-gdbinit", class_support, -+ &auto_load_local_gdbinit, _("\ -+Enable or disable auto-loading of .gdbinit script in current directory."), _("\ -+Show whether auto-loading .gdbinit script in current directory is enabled."), -+ _("\ -+If enabled, canned sequences of commands are loaded when debugger starts\n\ -+from .gdbinit file in current directory. Such files are deprecated,\n\ -+use a script associated with inferior executable file instead.\n\ -+This options has security implications for untrusted inferiors."), -+ NULL, show_auto_load_local_gdbinit, -+ auto_load_set_cmdlist_get (), -+ auto_load_show_cmdlist_get ()); -+ -+ add_cmd ("local-gdbinit", class_info, info_auto_load_local_gdbinit, -+ _("Print whether current directory .gdbinit file has been loaded.\n\ -+Usage: info auto-load local-gdbinit"), -+ auto_load_info_cmdlist_get ()); - } -Index: gdb-7.4.50.20120120/gdb/auto-load.h -=================================================================== ---- gdb-7.4.50.20120120.orig/gdb/auto-load.h 2012-04-18 00:44:26.951437517 +0200 -+++ gdb-7.4.50.20120120/gdb/auto-load.h 2012-04-18 00:46:47.556079780 +0200 -@@ -22,15 +22,36 @@ - - struct program_space; - --extern int gdbpy_global_auto_load; -+struct script_language -+{ -+ const char *suffix; -+ -+ void (*source_script_for_objfile) (struct objfile *objfile, FILE *file, -+ const char *filename); -+}; -+ -+extern int global_auto_load; -+ -+extern int auto_load_local_gdbinit; -+extern char *auto_load_local_gdbinit_pathname; -+extern int auto_load_local_gdbinit_loaded; - - extern struct auto_load_pspace_info * - get_auto_load_pspace_data_for_loading (struct program_space *pspace); - extern int maybe_add_script (struct auto_load_pspace_info *pspace_info, -- const char *name, const char *full_path); -+ const char *name, const char *full_path, -+ const struct script_language *language); - extern void auto_load_objfile_script (struct objfile *objfile, -- const char *suffix); -+ const struct script_language *language); -+extern void load_auto_scripts_for_objfile (struct objfile *objfile); - extern int - script_not_found_warning_print (struct auto_load_pspace_info *pspace_info); -+extern char auto_load_info_scripts_pattern_nl[]; -+extern void auto_load_info_scripts (char *pattern, int from_tty, -+ const struct script_language *language); -+ -+extern struct cmd_list_element **auto_load_set_cmdlist_get (void); -+extern struct cmd_list_element **auto_load_show_cmdlist_get (void); -+extern struct cmd_list_element **auto_load_info_cmdlist_get (void); - - #endif /* AUTO_LOAD_H */ -Index: gdb-7.4.50.20120120/gdb/linux-thread-db.c -=================================================================== ---- gdb-7.4.50.20120120.orig/gdb/linux-thread-db.c 2012-01-04 09:17:05.000000000 +0100 -+++ gdb-7.4.50.20120120/gdb/linux-thread-db.c 2012-04-18 00:46:47.557079777 +0200 -@@ -40,8 +40,10 @@ - #include "observer.h" - #include "linux-nat.h" - #include "linux-procfs.h" -+#include "auto-load.h" - - #include -+#include - - #ifdef HAVE_GNU_LIBC_VERSION_H - #include -@@ -75,6 +77,21 @@ - - static char *libthread_db_search_path; - -+/* Set to non-zero if thread_db auto-loading is enabled -+ by the "set auto-load libthread-db" command. */ -+static int auto_load_thread_db = 1; -+ -+/* "show" command for the auto_load_thread_db configuration variable. */ -+ -+static void -+show_auto_load_thread_db (struct ui_file *file, int from_tty, -+ struct cmd_list_element *c, const char *value) -+{ -+ fprintf_filtered (file, _("Auto-loading of inferior specific libthread_db " -+ "is %s.\n"), -+ value); -+} -+ - static void - set_libthread_db_search_path (char *ignored, int from_tty, - struct cmd_list_element *c) -@@ -119,6 +136,10 @@ struct thread_db_info - /* Handle from dlopen for libthread_db.so. */ - void *handle; - -+ /* Absolute pathname from gdb_realpath to disk file used for dlopen-ing -+ HANDLE. It may be NULL for system library. */ -+ char *filename; -+ - /* Structure that identifies the child process for the - interface. */ - struct ps_prochandle proc_handle; -@@ -248,6 +269,8 @@ delete_thread_db_info (int pid) - if (info->handle != NULL) - dlclose (info->handle); - -+ xfree (info->filename); -+ - if (info_prev) - info_prev->next = info->next; - else -@@ -807,6 +830,10 @@ try_thread_db_load (const char *library) - - info = add_thread_db_info (handle); - -+ /* Do not save system library name, that one is always trusted. */ -+ if (strchr (library, '/') != NULL) -+ info->filename = gdb_realpath (library); -+ - if (try_thread_db_load_1 (info)) - return 1; - -@@ -856,6 +883,9 @@ try_thread_db_load_from_pdir (void) - { - struct objfile *obj; - -+ if (!auto_load_thread_db) -+ return 0; -+ - ALL_OBJFILES (obj) - if (libpthread_name_p (obj->name)) - { -@@ -895,6 +925,9 @@ try_thread_db_load_from_dir (const char - char *path; - int result; - -+ if (!auto_load_thread_db) -+ return 0; -+ - path = xmalloc (dir_len + 1 + strlen (LIBTHREAD_DB_SO) + 1); - cleanup = make_cleanup (xfree, path); - -@@ -1802,6 +1835,150 @@ thread_db_resume (struct target_ops *ops - beneath->to_resume (beneath, ptid, step, signo); - } - -+/* qsort helper function for info_auto_load_libthread_db, sort the -+ thread_db_info pointers primarily by their FILENAME and secondarily by their -+ PID, both in ascending order. */ -+ -+static int -+info_auto_load_libthread_db_compare (const void *ap, const void *bp) -+{ -+ struct thread_db_info *a = *(struct thread_db_info **) ap; -+ struct thread_db_info *b = *(struct thread_db_info **) bp; -+ int retval; -+ -+ retval = strcmp (a->filename, b->filename); -+ if (retval) -+ return retval; -+ -+ return (a->pid > b->pid) - (a->pid - b->pid); -+} -+ -+/* Implement 'info auto-load libthread-db'. */ -+ -+static void -+info_auto_load_libthread_db (char *args, int from_tty) -+{ -+ struct ui_out *uiout = current_uiout; -+ const char *cs = args ? args : ""; -+ struct thread_db_info *info, **array; -+ unsigned info_count, unique_filenames; -+ size_t max_filename_len, max_pids_len, pids_len; -+ struct cleanup *back_to; -+ char *pids; -+ int i; -+ -+ while (isspace (*cs)) -+ cs++; -+ if (*cs) -+ error (_("'info auto-load libthread-db' does not accept any parameters")); -+ -+ info_count = 0; -+ for (info = thread_db_list; info; info = info->next) -+ if (info->filename != NULL) -+ info_count++; -+ -+ array = xmalloc (sizeof (*array) * info_count); -+ back_to = make_cleanup (xfree, array); -+ -+ info_count = 0; -+ for (info = thread_db_list; info; info = info->next) -+ if (info->filename != NULL) -+ array[info_count++] = info; -+ -+ /* Sort ARRAY by filenames and PIDs. */ -+ -+ qsort (array, info_count, sizeof (*array), -+ info_auto_load_libthread_db_compare); -+ -+ /* Calculate the number of unique filenames (rows) and the maximum string -+ length of PIDs list for the unique filenames (columns). */ -+ -+ unique_filenames = 0; -+ max_filename_len = 0; -+ max_pids_len = 0; -+ pids_len = 0; -+ for (i = 0; i < info_count; i++) -+ { -+ int pid = array[i]->pid; -+ size_t this_pid_len; -+ -+ for (this_pid_len = 0; pid != 0; pid /= 10) -+ this_pid_len++; -+ -+ if (i == 0 || strcmp (array[i - 1]->filename, array[i]->filename) != 0) -+ { -+ unique_filenames++; -+ max_filename_len = max (max_filename_len, -+ strlen (array[i]->filename)); -+ -+ if (i > 0) -+ { -+ pids_len -= strlen (", "); -+ max_pids_len = max (max_pids_len, pids_len); -+ } -+ pids_len = 0; -+ } -+ pids_len += this_pid_len + strlen (", "); -+ } -+ if (i) -+ { -+ pids_len -= strlen (", "); -+ max_pids_len = max (max_pids_len, pids_len); -+ } -+ -+ /* Table header shifted right by preceding "libthread-db: " would not match -+ its columns. */ -+ if (info_count > 0 && args == auto_load_info_scripts_pattern_nl) -+ ui_out_text (uiout, "\n"); -+ -+ make_cleanup_ui_out_table_begin_end (uiout, 2, unique_filenames, -+ "LinuxThreadDbTable"); -+ -+ ui_out_table_header (uiout, max_filename_len, ui_left, "filename", -+ "Filename"); -+ ui_out_table_header (uiout, pids_len, ui_left, "PIDs", "Pids"); -+ ui_out_table_body (uiout); -+ -+ pids = xmalloc (max_pids_len + 1); -+ make_cleanup (xfree, pids); -+ -+ /* Note I is incremented inside the cycle, not at its end. */ -+ for (i = 0; i < info_count;) -+ { -+ struct cleanup *chain = make_cleanup_ui_out_tuple_begin_end (uiout, NULL); -+ char *pids_end; -+ -+ info = array[i]; -+ ui_out_field_string (uiout, "filename", info->filename); -+ pids_end = pids; -+ -+ while (i < info_count && strcmp (info->filename, array[i]->filename) == 0) -+ { -+ if (pids_end != pids) -+ { -+ *pids_end++ = ','; -+ *pids_end++ = ' '; -+ } -+ pids_end += xsnprintf (pids_end, &pids[max_pids_len + 1] - pids_end, -+ "%u", array[i]->pid); -+ gdb_assert (pids_end < &pids[max_pids_len + 1]); -+ -+ i++; -+ } -+ *pids_end = '\0'; -+ -+ ui_out_field_string (uiout, "pids", pids); -+ -+ ui_out_text (uiout, "\n"); -+ do_cleanups (chain); -+ } -+ -+ do_cleanups (back_to); -+ -+ if (info_count == 0) -+ ui_out_message (uiout, 0, _("No auto-loaded libthread-db.\n")); -+} -+ - static void - init_thread_db_ops (void) - { -@@ -1863,6 +2040,23 @@ When non-zero, libthread-db debugging is - show_libthread_db_debug, - &setdebuglist, &showdebuglist); - -+ add_setshow_boolean_cmd ("libthread-db", class_support, -+ &auto_load_thread_db, _("\ -+Enable or disable auto-loading of inferior specific libthread_db."), _("\ -+Show whether auto-loading inferior specific libthread_db is enabled."), _("\ -+If enabled, libthread_db will be searched in 'set libthread-db-search-path'\n\ -+locations to load libthread_db compatible with the inferior.\n\ -+Standard system libthread_db still gets loaded even with this option off.\n\ -+This options has security implications for untrusted inferiors."), -+ NULL, show_auto_load_thread_db, -+ auto_load_set_cmdlist_get (), -+ auto_load_show_cmdlist_get ()); -+ -+ add_cmd ("libthread-db", class_info, info_auto_load_libthread_db, -+ _("Print the list of loaded inferior specific libthread_db.\n\ -+Usage: info auto-load libthread-db"), -+ auto_load_info_cmdlist_get ()); -+ - /* Add ourselves to objfile event chain. */ - observer_attach_new_objfile (thread_db_new_objfile); - -Index: gdb-7.4.50.20120120/gdb/main.c -=================================================================== ---- gdb-7.4.50.20120120.orig/gdb/main.c 2012-04-18 00:44:26.957437503 +0200 -+++ gdb-7.4.50.20120120/gdb/main.c 2012-04-18 00:46:47.557079777 +0200 -@@ -945,8 +945,8 @@ captured_main (void *data) - /* Skip auto-loading section-specified scripts until we've sourced - local_gdbinit (which is often used to augment the source search - path). */ -- save_auto_load = gdbpy_global_auto_load; -- gdbpy_global_auto_load = 0; -+ save_auto_load = global_auto_load; -+ global_auto_load = 0; - - if (execarg != NULL - && symarg != NULL -@@ -1022,14 +1022,24 @@ captured_main (void *data) - - /* Read the .gdbinit file in the current directory, *if* it isn't - the same as the $HOME/.gdbinit file (it should exist, also). */ -- if (local_gdbinit && !inhibit_gdbinit) -- catch_command_errors (source_script, local_gdbinit, 0, RETURN_MASK_ALL); -+ if (local_gdbinit) -+ { -+ auto_load_local_gdbinit_pathname = gdb_realpath (local_gdbinit); -+ -+ if (!inhibit_gdbinit && auto_load_local_gdbinit) -+ { -+ auto_load_local_gdbinit_loaded = 1; -+ -+ catch_command_errors (source_script, local_gdbinit, 0, -+ RETURN_MASK_ALL); -+ } -+ } - - /* Now that all .gdbinit's have been read and all -d options have been - processed, we can read any scripts mentioned in SYMARG. - We wait until now because it is common to add to the source search - path in local_gdbinit. */ -- gdbpy_global_auto_load = save_auto_load; -+ global_auto_load = save_auto_load; - ALL_OBJFILES (objfile) - load_auto_scripts_for_objfile (objfile); - -@@ -1196,7 +1206,7 @@ At startup, GDB reads the following init - "), home_gdbinit); - if (local_gdbinit) - fprintf_unfiltered (stream, _("\ -- * local init file: ./%s\n\ -+ * local init file (see also 'set auto-load local-gdbinit'): ./%s\n\ - "), local_gdbinit); - fputs_unfiltered (_("\n\ - For more information, type \"help\" from within GDB, or consult the\n\ -Index: gdb-7.4.50.20120120/gdb/doc/gdb.texinfo -=================================================================== ---- gdb-7.4.50.20120120.orig/gdb/doc/gdb.texinfo 2012-04-18 00:44:26.928437577 +0200 -+++ gdb-7.4.50.20120120/gdb/doc/gdb.texinfo 2012-04-18 00:46:47.558079774 +0200 -@@ -1034,6 +1034,7 @@ You can run @value{GDBN} in various alte - batch mode or quiet mode. - - @table @code -+@anchor{-nx} - @item -nx - @itemx -n - @cindex @code{--nx} -@@ -1265,6 +1266,7 @@ Here's the description of what @value{GD - Sets up the command interpreter as specified by the command line - (@pxref{Mode Options, interpreter}). - -+@anchor{Option -init-eval-command} - @item - Executes commands and command files specified by the @samp{-iex} and - @samp{-ix} options in their specified order. Usually you should use the -@@ -1279,6 +1281,7 @@ used when building @value{GDBN}; @pxref{ - ,System-wide configuration and settings}) and executes all the commands in - that file. - -+@anchor{Home Directory Init File} - @item - Reads the init file (if any) in your home directory@footnote{On - DOS/Windows systems, the home directory is the one pointed to by the -@@ -1288,9 +1291,12 @@ that file. - @item - Processes command line options and operands. - -+@anchor{Init File in the Current Directory during Startup} - @item - Reads and executes the commands from init file (if any) in the current --working directory. This is only done if the current directory is -+working directory as long as @samp{set auto-load local-gdbinit} is set to -+@samp{on} (@pxref{Init File in the Current Directory}). -+This is only done if the current directory is - different from your home directory. Thus, you can have more than one - init file, one generic in your home directory, and another, specific - to the program you are debugging, in the directory where you invoke -@@ -1306,7 +1312,7 @@ If you wish to disable the auto-loading - you must do something like the following: - - @smallexample --$ gdb -iex "set auto-load-scripts off" myprogram -+$ gdb -iex "set auto-load python-scripts off" myprogram - @end smallexample - - Option @samp{-ex} does not work because the auto-loading is then turned -@@ -2891,6 +2897,7 @@ programs with multiple threads. - @xref{Set Watchpoints,,Setting Watchpoints}, for information about - watchpoints in programs with multiple threads. - -+@anchor{set libthread-db-search-path} - @table @code - @kindex set libthread-db-search-path - @cindex search path for @code{libthread_db} -@@ -2905,11 +2912,15 @@ macro. - On @sc{gnu}/Linux and Solaris systems, @value{GDBN} uses a ``helper'' - @code{libthread_db} library to obtain information about threads in the - inferior process. @value{GDBN} will use @samp{libthread-db-search-path} --to find @code{libthread_db}. -+to find @code{libthread_db}. @value{GDBN} also consults first if inferior -+specific thread debugging library loading is enabled -+by @samp{set auto-load libthread-db} (@pxref{libthread_db.so.1 file}). - - A special entry @samp{$sdir} for @samp{libthread-db-search-path} - refers to the default system directories that are --normally searched for loading shared libraries. -+normally searched for loading shared libraries. The @samp{$sdir} entry -+is the only kind not needing to be enabled by @samp{set auto-load libthread-db} -+(@pxref{libthread_db.so.1 file}). - - A special entry @samp{$pdir} for @samp{libthread-db-search-path} - refers to the directory from which @code{libpthread} -@@ -20320,6 +20331,7 @@ described here. - * Screen Size:: Screen size - * Numbers:: Numbers - * ABI:: Configuring the current ABI -+* Auto-loading:: Automatically loading associated files - * Messages/Warnings:: Optional warnings and messages - * Debugging Output:: Optional messages about internal happenings - * Other Misc Settings:: Other Miscellaneous Settings -@@ -20745,6 +20757,227 @@ With no argument, show the list of suppo - Set the current C@t{++} ABI to @var{abi}, or return to automatic detection. - @end table - -+@node Auto-loading -+@section Automatically loading associated files -+@cindex auto-loading -+ -+@value{GDBN} sometimes reads files with commands and settings automatically, -+without being explicitly told so by the user. We call this feature -+@dfn{auto-loading}. While auto-loading is useful for automatically adapting -+@value{GDBN} to the needs of your project, it can sometimes produce unexpected -+results or introduce security risks (e.g., if the file comes from untrusted -+sources). -+ -+For these reasons, @value{GDBN} includes commands and options to let you -+control when to auto-load files and which files should be auto-loaded. -+ -+@table @code -+@anchor{set auto-load off} -+@kindex set auto-load off -+@item set auto-load off -+Globally disable loading of all auto-loaded files. -+You may want to use this command with the @samp{-iex} option -+(@pxref{Option -init-eval-command}) such as: -+@smallexample -+$ @kbd{gdb -iex "set auto-load off" untrusted-executable corefile} -+@end smallexample -+ -+Be aware that system init file (@pxref{System-wide configuration}) -+and init files from your home directory (@pxref{Home Directory Init File}) -+still get read (as they come from generally trusted directories). -+To prevent @value{GDBN} from auto-loading even those init files, use the -+@option{-nx} option (@pxref{Mode Options}), in addition to -+@code{set auto-load no}. -+ -+@anchor{show auto-load} -+@kindex show auto-load -+@item show auto-load -+Show whether auto-loading of each specific @samp{auto-load} file(s) is enabled -+or disabled. -+ -+@smallexample -+(gdb) show auto-load -+gdb-scripts: Auto-loading of canned sequences of commands scripts is on. -+libthread-db: Auto-loading of inferior specific libthread_db is on. -+local-gdbinit: Auto-loading of .gdbinit script from current directory is on. -+python-scripts: Auto-loading of Python scripts is on. -+@end smallexample -+ -+@anchor{info auto-load} -+@kindex info auto-load -+@item info auto-load -+Print whether each specific @samp{auto-load} file(s) have been auto-loaded or -+not. -+ -+@smallexample -+(gdb) info auto-load -+gdb-scripts: -+Loaded Script -+Yes /home/user/gdb/gdb-gdb.gdb -+libthread-db: No auto-loaded libthread-db. -+local-gdbinit: Local .gdbinit file "/home/user/gdb/.gdbinit" has been loaded. -+python-scripts: -+Loaded Script -+Yes /home/user/gdb/gdb-gdb.py -+@end smallexample -+@end table -+ -+These are various kinds of files @value{GDBN} can automatically load: -+ -+@itemize @bullet -+@item -+@xref{objfile-gdb.py file}, controlled by @ref{set auto-load python-scripts}. -+@item -+@xref{objfile-gdb.gdb file}, controlled by @ref{set auto-load gdb-scripts}. -+@item -+@xref{dotdebug_gdb_scripts section}, -+controlled by @ref{set auto-load python-scripts}. -+@item -+@xref{Init File in the Current Directory}, -+controlled by @ref{set auto-load local-gdbinit}. -+@item -+@xref{libthread_db.so.1 file}, controlled by @ref{set auto-load libthread-db}. -+@end itemize -+ -+These are @value{GDBN} control commands for the auto-loading: -+ -+@multitable @columnfractions .5 .5 -+@item @xref{set auto-load off}. -+@tab Disable auto-loading globally. -+@item @xref{show auto-load}. -+@tab Show setting of all kinds of files. -+@item @xref{info auto-load}. -+@tab Show state of all kinds of files. -+@item @xref{set auto-load gdb-scripts}. -+@tab Control for @value{GDBN} command scripts. -+@item @xref{show auto-load gdb-scripts}. -+@tab Show setting of @value{GDBN} command scripts. -+@item @xref{info auto-load gdb-scripts}. -+@tab Show state of @value{GDBN} command scripts. -+@item @xref{set auto-load python-scripts}. -+@tab Control for @value{GDBN} Python scripts. -+@item @xref{show auto-load python-scripts}. -+@tab Show setting of @value{GDBN} Python scripts. -+@item @xref{info auto-load python-scripts}. -+@tab Show state of @value{GDBN} Python scripts. -+@item @xref{set auto-load local-gdbinit}. -+@tab Control for init file in the current directory. -+@item @xref{show auto-load local-gdbinit}. -+@tab Show setting of init file in the current directory. -+@item @xref{info auto-load local-gdbinit}. -+@tab Show state of init file in the current directory. -+@item @xref{set auto-load libthread-db}. -+@tab Control for thread debugging library. -+@item @xref{show auto-load libthread-db}. -+@tab Show setting of thread debugging library. -+@item @xref{info auto-load libthread-db}. -+@tab Show state of thread debugging library. -+@end multitable -+ -+@menu -+* Init File in the Current Directory:: @samp{set/show/info auto-load local-gdbinit} -+* libthread_db.so.1 file:: @samp{set/show/info auto-load libthread-db} -+* objfile-gdb.gdb file:: @samp{set/show/info auto-load gdb-script} -+@xref{Python Auto-loading}. -+@end menu -+ -+@node Init File in the Current Directory -+@subsection Automatically loading init file in the current directory -+@cindex auto-loading init file in the current directory -+ -+By default, @value{GDBN} reads and executes the canned sequences of commands -+from init file (if any) in the current working directory, -+see @ref{Init File in the Current Directory during Startup}. -+ -+@table @code -+@anchor{set auto-load local-gdbinit} -+@kindex set auto-load local-gdbinit -+@item set auto-load local-gdbinit [on|off] -+Enable or disable the auto-loading of canned sequences of commands -+(@pxref{Sequences}) found in init file in the current directory. -+ -+@anchor{show auto-load local-gdbinit} -+@kindex show auto-load local-gdbinit -+@item show auto-load local-gdbinit -+Show whether auto-loading of canned sequences of commands from init file in the -+current directory is enabled or disabled. -+ -+@anchor{info auto-load local-gdbinit} -+@kindex info auto-load local-gdbinit -+@item info auto-load local-gdbinit -+Print whether canned sequences of commands from init file in the -+current directory have been auto-loaded. -+@end table -+ -+@node libthread_db.so.1 file -+@subsection Automatically loading thread debugging library -+@cindex auto-loading libthread_db.so.1 -+ -+This feature is currently present only on @sc{gnu}/Linux native hosts. -+ -+@value{GDBN} reads in some cases thread debugging library from places specific -+to the inferior (@pxref{set libthread-db-search-path}). -+ -+The special @samp{libthread-db-search-path} entry @samp{$sdir} is processed -+without checking this @samp{set auto-load libthread-db} switch as system -+libraries have to be trusted in general. In all other cases of -+@samp{libthread-db-search-path} entries @value{GDBN} checks first if @samp{set -+auto-load libthread-db} is enabled before trying to open such thread debugging -+library. -+ -+@table @code -+@anchor{set auto-load libthread-db} -+@kindex set auto-load libthread-db -+@item set auto-load libthread-db [on|off] -+Enable or disable the auto-loading of inferior specific thread debugging library. -+ -+@anchor{show auto-load libthread-db} -+@kindex show auto-load libthread-db -+@item show auto-load libthread-db -+Show whether auto-loading of inferior specific thread debugging library is -+enabled or disabled. -+ -+@anchor{info auto-load libthread-db} -+@kindex info auto-load libthread-db -+@item info auto-load libthread-db -+Print the list of all loaded inferior specific thread debugging libraries and -+for each such library print list of inferior @var{pid}s using it. -+@end table -+ -+@node objfile-gdb.gdb file -+@subsection The @file{@var{objfile}-gdb.gdb} file -+@cindex auto-loading @file{@var{objfile}-gdb.gdb} -+ -+@value{GDBN} tries to load an @file{@var{objfile}-gdb.gdb} file containing -+canned sequences of commands (@pxref{Sequences}), as long as @samp{set -+auto-load gdb-scripts} is set to @samp{on}. -+ -+For more background refer to the similar Python scripts auto-loading -+description (@pxref{objfile-gdb.py file}). -+ -+@table @code -+@anchor{set auto-load gdb-scripts} -+@kindex set auto-load gdb-scripts -+@item set auto-load gdb-scripts [on|off] -+Enable or disable the auto-loading of canned sequences of commands scripts. -+ -+@anchor{show auto-load gdb-scripts} -+@kindex show auto-load gdb-scripts -+@item show auto-load gdb-scripts -+Show whether auto-loading of canned sequences of commands scripts is enabled or -+disabled. -+ -+@anchor{info auto-load gdb-scripts} -+@kindex info auto-load gdb-scripts -+@cindex print list of auto-loaded canned sequences of commands scripts -+@item info auto-load gdb-scripts [@var{regexp}] -+Print the list of all canned sequences of commands scripts that @value{GDBN} -+auto-loaded. -+@end table -+ -+If @var{regexp} is supplied only canned sequences of commands scripts with -+matching names are printed. -+ - @node Messages/Warnings - @section Optional Warnings and Messages - -@@ -21616,7 +21849,7 @@ automatically imported when @value{GDBN} - @menu - * Python Commands:: Accessing Python from @value{GDBN}. - * Python API:: Accessing @value{GDBN} from Python. --* Auto-loading:: Automatically loading Python code. -+* Python Auto-loading:: Automatically loading Python code. - * Python modules:: Python modules provided by @value{GDBN}. - @end menu - -@@ -22799,7 +23032,7 @@ This practice will enable @value{GDBN} t - your pretty-printers at the same time, because they will have - different names. - --You should write auto-loaded code (@pxref{Auto-loading}) such that it -+You should write auto-loaded code (@pxref{Python Auto-loading}) such that it - can be evaluated multiple times without changing its meaning. An - ideal auto-load file will consist solely of @code{import}s of your - printer modules, followed by a call to a register pretty-printers with -@@ -23760,7 +23993,7 @@ The following objfile-related functions - - @findex gdb.current_objfile - @defun gdb.current_objfile () --When auto-loading a Python script (@pxref{Auto-loading}), @value{GDBN} -+When auto-loading a Python script (@pxref{Python Auto-loading}), @value{GDBN} - sets the ``current objfile'' to the corresponding objfile. This - function returns the current objfile. If there is no current objfile, - this function returns @code{None}. -@@ -24671,9 +24904,9 @@ resolve this to the lazy string's charac - writable. - @end defvar - --@node Auto-loading --@subsection Auto-loading --@cindex auto-loading, Python -+@node Python Auto-loading -+@subsection Python Auto-loading -+@cindex Python auto-loading - - When a new object file is read (for example, due to the @code{file} - command, or because the inferior has loaded a shared library), -@@ -24693,32 +24926,35 @@ Auto-loading can be enabled or disabled, - and the list of auto-loaded scripts can be printed. - - @table @code --@kindex set auto-load-scripts --@item set auto-load-scripts [yes|no] -+@anchor{set auto-load python-scripts} -+@kindex set auto-load python-scripts -+@item set auto-load python-scripts [on|off] - Enable or disable the auto-loading of Python scripts. - --@kindex show auto-load-scripts --@item show auto-load-scripts -+@anchor{show auto-load python-scripts} -+@kindex show auto-load python-scripts -+@item show auto-load python-scripts - Show whether auto-loading of Python scripts is enabled or disabled. - --@kindex info auto-load-scripts --@cindex print list of auto-loaded scripts --@item info auto-load-scripts [@var{regexp}] --Print the list of all scripts that @value{GDBN} auto-loaded. -+@anchor{info auto-load python-scripts} -+@kindex info auto-load python-scripts -+@cindex print list of auto-loaded Python scripts -+@item info auto-load python-scripts [@var{regexp}] -+Print the list of all Python scripts that @value{GDBN} auto-loaded. - --Also printed is the list of scripts that were mentioned in -+Also printed is the list of Python scripts that were mentioned in - the @code{.debug_gdb_scripts} section and were not found - (@pxref{dotdebug_gdb_scripts section}). - This is useful because their names are not printed when @value{GDBN} - tries to load them and fails. There may be many of them, and printing - an error message for each one is problematic. - --If @var{regexp} is supplied only scripts with matching names are printed. -+If @var{regexp} is supplied only Python scripts with matching names are printed. - - Example: - - @smallexample --(gdb) info auto-load-scripts -+(gdb) info auto-load python-scripts - Loaded Script - Yes py-section-script.py - full name: /tmp/py-section-script.py -Index: gdb-7.4.50.20120120/gdb/python/py-auto-load.c -=================================================================== ---- gdb-7.4.50.20120120.orig/gdb/python/py-auto-load.c 2012-04-18 00:44:26.958437500 +0200 -+++ gdb-7.4.50.20120120/gdb/python/py-auto-load.c 2012-04-18 00:46:47.558079774 +0200 -@@ -31,29 +31,56 @@ - - #include "python-internal.h" - --/* NOTE: It's trivial to also support auto-loading normal gdb scripts. -- There has yet to be a need so it's not implemented. */ -- - /* The suffix of per-objfile scripts to auto-load. - E.g. When the program loads libfoo.so, look for libfoo-gdb.py. */ - #define GDBPY_AUTO_FILE_NAME "-gdb.py" - --/* The section to look for scripts (in file formats that support sections). -+/* The section to look for Python auto-loaded scripts (in file formats that -+ support sections). - Each entry in this section is a byte of value 1, and then the nul-terminated - name of the script. The script name may include a directory. - The leading byte is to allow upward compatible extensions. */ - #define GDBPY_AUTO_SECTION_NAME ".debug_gdb_scripts" - --/* User-settable option to enable/disable auto-loading: -- set auto-load-scripts on|off -- This is true if we should auto-load associated scripts when an objfile -- is opened, false otherwise. -- At the moment, this only affects python scripts, but there's no reason -- one couldn't also have other kinds of auto-loaded scripts, and there's -- no reason to have them each controlled by a separate flag. -- So we elide "python" from the name here and in the option. -- The fact that it lives here is just an implementation detail. */ --static int auto_load_scripts = 1; -+/* User-settable option to enable/disable auto-loading of Python scripts: -+ set auto-load python-scripts on|off -+ This is true if we should auto-load associated Python scripts when an -+ objfile is opened, false otherwise. */ -+static int auto_load_python_scripts = 1; -+ -+static void gdbpy_load_auto_script_for_objfile (struct objfile *objfile, -+ FILE *file, -+ const char *filename); -+ -+/* "show" command for the auto_load_python_scripts configuration variable. */ -+ -+static void -+show_auto_load_python_scripts (struct ui_file *file, int from_tty, -+ struct cmd_list_element *c, const char *value) -+{ -+ fprintf_filtered (file, _("Auto-loading of Python scripts is %s.\n"), value); -+} -+ -+/* Definition of script language for Python scripts. */ -+ -+static const struct script_language script_language_python -+ = { GDBPY_AUTO_FILE_NAME, gdbpy_load_auto_script_for_objfile }; -+ -+/* Wrapper of source_python_script_for_objfile for script_language_python. */ -+ -+static void -+gdbpy_load_auto_script_for_objfile (struct objfile *objfile, FILE *file, -+ const char *filename) -+{ -+ struct auto_load_pspace_info *pspace_info; -+ -+ /* Add this script to the hash table too so "info auto-load python-scripts" -+ can print it. */ -+ pspace_info = get_auto_load_pspace_data_for_loading (current_program_space); -+ maybe_add_script (pspace_info, filename, filename, &script_language_python); -+ -+ source_python_script_for_objfile (objfile, file, filename); -+} - - /* Load scripts specified in OBJFILE. - START,END delimit a buffer containing a list of nul-terminated -@@ -121,6 +148,17 @@ source_section_scripts (struct objfile * - make_cleanup_fclose (stream); - make_cleanup (xfree, full_path); - } -+ else -+ { -+ full_path = NULL; -+ -+ /* We don't throw an error, the program is still debuggable. */ -+ if (script_not_found_warning_print (pspace_info)) -+ warning (_("Missing auto-load scripts referenced in section %s\n\ -+of file %s\n\ -+Use `info auto-load python [REGEXP]' to list them."), -+ GDBPY_AUTO_SECTION_NAME, objfile->name); -+ } - - /* If one script isn't found it's not uncommon for more to not be - found either. We don't want to print an error message for each -@@ -129,24 +167,12 @@ source_section_scripts (struct objfile * - - IWBN if complaints.c were more general-purpose. */ - -- in_hash_table = maybe_add_script (pspace_info, file, -- opened ? full_path : NULL); -+ in_hash_table = maybe_add_script (pspace_info, file, full_path, -+ &script_language_python); - -- if (! opened) -- { -- /* We don't throw an error, the program is still debuggable. */ -- if (script_not_found_warning_print (pspace_info)) -- warning (_("Missing auto-load scripts referenced in section %s\n\ --of file %s\n\ --Use `info auto-load-scripts [REGEXP]' to list them."), -- GDBPY_AUTO_SECTION_NAME, objfile->name); -- } -- else -- { -- /* If this file is not currently loaded, load it. */ -- if (! in_hash_table) -- source_python_script_for_objfile (objfile, stream, full_path); -- } -+ /* If this file is not currently loaded, load it. */ -+ if (opened && !in_hash_table) -+ source_python_script_for_objfile (objfile, stream, full_path); - - do_cleanups (back_to); - } -@@ -181,36 +207,75 @@ auto_load_section_scripts (struct objfil - do_cleanups (cleanups); - } - --/* Load any auto-loaded scripts for OBJFILE. */ -+/* Load any Python auto-loaded scripts for OBJFILE. */ - - void --load_auto_scripts_for_objfile (struct objfile *objfile) -+gdbpy_load_auto_scripts_for_objfile (struct objfile *objfile) - { -- if (auto_load_scripts && gdbpy_global_auto_load) -+ if (auto_load_python_scripts) - { -- auto_load_objfile_script (objfile, GDBPY_AUTO_FILE_NAME); -+ auto_load_objfile_script (objfile, &script_language_python); - auto_load_section_scripts (objfile, GDBPY_AUTO_SECTION_NAME); - } - } -+ -+/* Wrapper for "info auto-load python-scripts". */ -+ -+static void -+info_auto_load_python_scripts (char *pattern, int from_tty) -+{ -+ auto_load_info_scripts (pattern, from_tty, &script_language_python); -+} - - void - gdbpy_initialize_auto_load (void) - { -+ struct cmd_list_element *cmd; -+ char *cmd_name; -+ -+ add_setshow_boolean_cmd ("python-scripts", class_support, -+ &auto_load_python_scripts, _("\ -+Set the debugger's behaviour regarding auto-loaded Python scripts."), _("\ -+Show the debugger's behaviour regarding auto-loaded Python scripts."), _("\ -+If enabled, auto-loaded Python scripts are loaded when the debugger reads\n\ -+an executable or shared library.\n\ -+This options has security implications for untrusted inferiors."), -+ NULL, show_auto_load_python_scripts, -+ auto_load_set_cmdlist_get (), -+ auto_load_show_cmdlist_get ()); -+ - add_setshow_boolean_cmd ("auto-load-scripts", class_support, -- &auto_load_scripts, _("\ --Set the debugger's behaviour regarding auto-loaded scripts."), _("\ --Show the debugger's behaviour regarding auto-loaded scripts."), _("\ --If enabled, auto-loaded scripts are loaded when the debugger reads\n\ --an executable or shared library."), -- NULL, NULL, -- &setlist, -- &showlist); -+ &auto_load_python_scripts, _("\ -+Set the debugger's behaviour regarding auto-loaded Python scripts, " -+ "deprecated."), -+ _("\ -+Show the debugger's behaviour regarding auto-loaded Python scripts, " -+ "deprecated."), -+ NULL, NULL, show_auto_load_python_scripts, -+ &setlist, &showlist); -+ cmd_name = "auto-load-scripts"; -+ cmd = lookup_cmd (&cmd_name, setlist, "", -1, 1); -+ deprecate_cmd (cmd, "set auto-load python-scripts"); -+ -+ /* It is needed because lookup_cmd updates the CMD_NAME pointer. */ -+ cmd_name = "auto-load-scripts"; -+ cmd = lookup_cmd (&cmd_name, showlist, "", -1, 1); -+ deprecate_cmd (cmd, "show auto-load python-scripts"); -+ -+ add_cmd ("python-scripts", class_info, info_auto_load_python_scripts, -+ _("Print the list of automatically loaded Python scripts.\n\ -+Usage: info auto-load python-scripts [REGEXP]"), -+ auto_load_info_cmdlist_get ()); -+ -+ cmd = add_info ("auto-load-scripts", info_auto_load_python_scripts, _("\ -+Print the list of automatically loaded Python scripts, deprecated.")); -+ deprecate_cmd (cmd, "info auto-load python-scripts"); - } - - #else /* ! HAVE_PYTHON */ - - void --load_auto_scripts_for_objfile (struct objfile *objfile) -+gdbpy_load_auto_scripts_for_objfile (struct objfile *objfile) - { - } - -Index: gdb-7.4.50.20120120/gdb/python/python.h -=================================================================== ---- gdb-7.4.50.20120120.orig/gdb/python/python.h 2012-04-18 00:44:26.958437500 +0200 -+++ gdb-7.4.50.20120120/gdb/python/python.h 2012-04-18 00:44:26.979437446 +0200 -@@ -41,7 +41,7 @@ int apply_val_pretty_printer (struct typ - - void preserve_python_values (struct objfile *objfile, htab_t copied_types); - --void load_auto_scripts_for_objfile (struct objfile *objfile); -+void gdbpy_load_auto_scripts_for_objfile (struct objfile *objfile); - - int gdbpy_should_stop (struct breakpoint_object *bp_obj); - -Index: gdb-7.4.50.20120120/gdb/testsuite/gdb.base/help.exp -=================================================================== ---- gdb-7.4.50.20120120.orig/gdb/testsuite/gdb.base/help.exp 2012-01-04 09:17:45.000000000 +0100 -+++ gdb-7.4.50.20120120/gdb/testsuite/gdb.base/help.exp 2012-04-18 00:44:26.980437444 +0200 -@@ -24,7 +24,7 @@ - gdb_start - - # force the height of the debugger to be pretty large so no pagers get used --gdb_test_no_output "set height 400" "test set height" -+gdb_test_no_output "set height 500" "test set height" - - # use a larger expect input buffer for long help outputs. - # test help add-symbol-file -Index: gdb-7.4.50.20120120/gdb/testsuite/gdb.python/py-objfile-script.exp -=================================================================== ---- gdb-7.4.50.20120120.orig/gdb/testsuite/gdb.python/py-objfile-script.exp 2012-01-16 17:21:52.000000000 +0100 -+++ gdb-7.4.50.20120120/gdb/testsuite/gdb.python/py-objfile-script.exp 2012-04-18 00:46:47.558079774 +0200 -@@ -40,7 +40,7 @@ gdb_reinitialize_dir $srcdir/$subdir - gdb_load ${binfile} - - # Verify gdb loaded the script. --gdb_test "info auto-load-scripts" "Yes.*/${testfile}-gdb.py.*" -+gdb_test "info auto-load python-scripts" "Yes.*/${testfile}-gdb.py.*" - - if ![runto_main] { - perror "couldn't run to main" -Index: gdb-7.4.50.20120120/gdb/testsuite/gdb.python/py-section-script.exp -=================================================================== ---- gdb-7.4.50.20120120.orig/gdb/testsuite/gdb.python/py-section-script.exp 2012-01-16 17:21:52.000000000 +0100 -+++ gdb-7.4.50.20120120/gdb/testsuite/gdb.python/py-section-script.exp 2012-04-18 00:46:47.558079774 +0200 -@@ -52,11 +52,11 @@ gdb_reinitialize_dir $srcdir/$subdir - gdb_load ${binfile} - - # Verify gdb loaded the script. --gdb_test "info auto-load-scripts" "Yes.*${testfile}.py.*full name: .*/${testfile}.py.*" -+gdb_test "info auto-load python-scripts" "Yes.*${testfile}.py.*full name: .*/${testfile}.py.*" - # Again, with a regexp this time. --gdb_test "info auto-load-scripts ${testfile}" "Yes.*${testfile}.py.*full name: .*/${testfile}.py.*" -+gdb_test "info auto-load python-scripts ${testfile}" "Yes.*${testfile}.py.*full name: .*/${testfile}.py.*" - # Again, with a regexp that matches no scripts. --gdb_test "info auto-load-scripts no-script-matches-this" \ -+gdb_test "info auto-load python-scripts no-script-matches-this" \ - "No auto-load scripts matching no-script-matches-this." - - if ![runto_main] { diff --git a/gdb-autoload-11of28.patch b/gdb-autoload-11of28.patch deleted file mode 100644 index 4ac68b0..0000000 --- a/gdb-autoload-11of28.patch +++ /dev/null @@ -1,744 +0,0 @@ -[patch#4 5/8] set auto-load safe-path -http://sourceware.org/ml/gdb-patches/2012-04/msg00092.html -http://sourceware.org/ml/gdb-cvs/2012-04/msg00114.html - -### src/gdb/ChangeLog 2012/04/17 15:51:41 1.14113 -### src/gdb/ChangeLog 2012/04/17 15:54:28 1.14114 -## -1,5 +1,39 @@ - 2012-04-17 Jan Kratochvil - -+ New option "set auto-load safe-path". -+ * NEWS: New commands "set auto-load safe-path" -+ and "show auto-load safe-path". -+ * auto-load.c: Include gdb_vecs.h, readline/tilde.h and completer.h. -+ (auto_load_safe_path, auto_load_safe_path_vec) -+ (auto_load_safe_path_vec_update, set_auto_load_safe_path) -+ (show_auto_load_safe_path, add_auto_load_safe_path, filename_is_in_dir) -+ (filename_is_in_auto_load_safe_path_vec, file_is_auto_load_safe): New. -+ (source_gdb_script_for_objfile): New variable is_safe. Call -+ file_is_auto_load_safe. Return if it is not. -+ (struct loaded_script): New field loaded. -+ (maybe_add_script): Add parameter loaded. Initialize SLOT with it. -+ (print_script): Use LOADED indicator instead of FULL_PATH. Change -+ output "Missing" to "No". -+ (_initialize_auto_load): New variable cmd. Initialize -+ auto_load_safe_path. Register "set auto-load safe-path", -+ "show auto-load safe-path" and "add-auto-load-safe-path". -+ * auto-load.h (maybe_add_script): Add parameter loaded. -+ (file_is_auto_load_safe): New declaration. -+ * config.in: Regenerate. -+ * configure: Regenerate. -+ * configure.ac: New parameters --with-auto-load-safe-path -+ and --without-auto-load-safe-path. -+ * linux-thread-db.c (try_thread_db_load_from_pdir_1) -+ (try_thread_db_load_from_dir): Check file_is_auto_load_safe first. -+ * main.c (captured_main): Check file_is_auto_load_safe for -+ LOCAL_GDBINIT. -+ * python/py-auto-load.c (gdbpy_load_auto_script_for_objfile): New -+ variable is_safe. Call file_is_auto_load_safe. Return if it is not. -+ (source_section_scripts): Call file_is_auto_load_safe. Return if it is -+ not. -+ -+2012-04-17 Jan Kratochvil -+ - auto-load: Implementation. - * NEWS: New descriptions for "info auto-load", - "info auto-load gdb-scripts", "info auto-load python-scripts", -Index: gdb-7.4.50.20120120/gdb/NEWS -=================================================================== ---- gdb-7.4.50.20120120.orig/gdb/NEWS 2012-04-18 00:49:02.000000000 +0200 -+++ gdb-7.4.50.20120120/gdb/NEWS 2012-04-18 00:49:33.282706319 +0200 -@@ -67,6 +67,11 @@ set auto-load libthread-db on|off - show auto-load libthread-db - Control auto-loading of inferior specific thread debugging shared library. - -+set auto-load safe-path [:...] -+show auto-load safe-path -+ Set a list of directories from which it is safe to auto-load files. -+ The delimiter (':' above) may differ according to the host platform. -+ - * New command line options - - --init-command=FILE, -ix Like --command, -x but execute it -Index: gdb-7.4.50.20120120/gdb/auto-load.c -=================================================================== ---- gdb-7.4.50.20120120.orig/gdb/auto-load.c 2012-04-18 00:46:47.000000000 +0200 -+++ gdb-7.4.50.20120120/gdb/auto-load.c 2012-04-18 00:49:21.607736020 +0200 -@@ -32,6 +32,9 @@ - #include "gdbcmd.h" - #include "cli/cli-decode.h" - #include "cli/cli-setshow.h" -+#include "gdb_vecs.h" -+#include "readline/tilde.h" -+#include "completer.h" - - /* The suffix of per-objfile scripts to auto-load as non-Python command files. - E.g. When the program loads libfoo.so, look for libfoo-gdb.gdb. */ -@@ -90,6 +93,181 @@ show_auto_load_local_gdbinit (struct ui_ - value); - } - -+/* Directory list safe to hold auto-loaded files. It is not checked for -+ absolute paths but they are strongly recommended. It is initialized by -+ _initialize_auto_load. */ -+static char *auto_load_safe_path; -+ -+/* Vector of directory elements of AUTO_LOAD_SAFE_PATH with each one normalized -+ by tilde_expand and possibly each entries has added its gdb_realpath -+ counterpart. */ -+static VEC (char_ptr) *auto_load_safe_path_vec; -+ -+/* Update auto_load_safe_path_vec from current AUTO_LOAD_SAFE_PATH. */ -+ -+static void -+auto_load_safe_path_vec_update (void) -+{ -+ VEC (char_ptr) *dir_vec = NULL; -+ unsigned len; -+ int ix; -+ -+ free_char_ptr_vec (auto_load_safe_path_vec); -+ -+ auto_load_safe_path_vec = dirnames_to_char_ptr_vec (auto_load_safe_path); -+ len = VEC_length (char_ptr, auto_load_safe_path_vec); -+ -+ /* Apply tilde_expand and gdb_realpath to each AUTO_LOAD_SAFE_PATH_VEC -+ element. */ -+ for (ix = 0; ix < len; ix++) -+ { -+ char *dir = VEC_index (char_ptr, auto_load_safe_path_vec, ix); -+ char *expanded = tilde_expand (dir); -+ char *real_path = gdb_realpath (expanded); -+ -+ /* Ensure the current entry is at least tilde_expand-ed. */ -+ xfree (dir); -+ VEC_replace (char_ptr, auto_load_safe_path_vec, ix, expanded); -+ -+ /* If gdb_realpath returns a different content, append it. */ -+ if (strcmp (real_path, expanded) == 0) -+ xfree (real_path); -+ else -+ VEC_safe_push (char_ptr, auto_load_safe_path_vec, real_path); -+ } -+} -+ -+/* "set" command for the auto_load_safe_path configuration variable. */ -+ -+static void -+set_auto_load_safe_path (char *args, int from_tty, struct cmd_list_element *c) -+{ -+ auto_load_safe_path_vec_update (); -+} -+ -+/* "show" command for the auto_load_safe_path configuration variable. */ -+ -+static void -+show_auto_load_safe_path (struct ui_file *file, int from_tty, -+ struct cmd_list_element *c, const char *value) -+{ -+ if (*value == 0) -+ fprintf_filtered (file, _("Auto-load files are safe to load from any " -+ "directory.\n")); -+ else -+ fprintf_filtered (file, _("List of directories from which it is safe to " -+ "auto-load files is %s.\n"), -+ value); -+} -+ -+/* "add-auto-load-safe-path" command for the auto_load_safe_path configuration -+ variable. */ -+ -+static void -+add_auto_load_safe_path (char *args, int from_tty) -+{ -+ char *s; -+ -+ if (args == NULL || *args == 0) -+ error (_("\ -+Adding empty directory element disables the auto-load safe-path security. \ -+Use 'set auto-load safe-path' instead if you mean that.")); -+ -+ s = xstrprintf ("%s%c%s", auto_load_safe_path, DIRNAME_SEPARATOR, args); -+ xfree (auto_load_safe_path); -+ auto_load_safe_path = s; -+ -+ auto_load_safe_path_vec_update (); -+} -+ -+/* Return 1 if FILENAME is equal to DIR or if FILENAME belongs to the -+ subdirectory DIR. Return 0 otherwise. gdb_realpath normalization is never -+ done here. */ -+ -+static ATTRIBUTE_PURE int -+filename_is_in_dir (const char *filename, const char *dir) -+{ -+ size_t dir_len = strlen (dir); -+ -+ while (dir_len && IS_DIR_SEPARATOR (dir[dir_len - 1])) -+ dir_len--; -+ -+ return (filename_ncmp (dir, filename, dir_len) == 0 -+ && (IS_DIR_SEPARATOR (filename[dir_len]) -+ || filename[dir_len] == '\0')); -+} -+ -+/* Return 1 if FILENAME belongs to one of directory components of -+ AUTO_LOAD_SAFE_PATH_VEC. Return 0 otherwise. -+ auto_load_safe_path_vec_update is never called. -+ *FILENAME_REALP may be updated by gdb_realpath of FILENAME - it has to be -+ freed by the caller. */ -+ -+static int -+filename_is_in_auto_load_safe_path_vec (const char *filename, -+ char **filename_realp) -+{ -+ char *dir; -+ int ix; -+ -+ for (ix = 0; VEC_iterate (char_ptr, auto_load_safe_path_vec, ix, dir); ++ix) -+ if (*filename_realp == NULL && filename_is_in_dir (filename, dir)) -+ break; -+ -+ if (dir == NULL) -+ { -+ if (*filename_realp == NULL) -+ *filename_realp = gdb_realpath (filename); -+ -+ for (ix = 0; VEC_iterate (char_ptr, auto_load_safe_path_vec, ix, dir); -+ ++ix) -+ if (filename_is_in_dir (*filename_realp, dir)) -+ break; -+ } -+ -+ if (dir != NULL) -+ return 1; -+ -+ return 0; -+} -+ -+/* Return 1 if FILENAME is located in one of the directories of -+ AUTO_LOAD_SAFE_PATH. Otherwise call warning and return 0. FILENAME does -+ not have to be an absolute path. -+ -+ Existence of FILENAME is not checked. Function will still give a warning -+ even if the caller would quietly skip non-existing file in unsafe -+ directory. */ -+ -+int -+file_is_auto_load_safe (const char *filename) -+{ -+ char *filename_real = NULL; -+ struct cleanup *back_to; -+ -+ back_to = make_cleanup (free_current_contents, &filename_real); -+ -+ if (filename_is_in_auto_load_safe_path_vec (filename, &filename_real)) -+ { -+ do_cleanups (back_to); -+ return 1; -+ } -+ -+ auto_load_safe_path_vec_update (); -+ if (filename_is_in_auto_load_safe_path_vec (filename, &filename_real)) -+ { -+ do_cleanups (back_to); -+ return 1; -+ } -+ -+ warning (_("File \"%s\" auto-loading has been declined by your " -+ "`auto-load safe-path' set to \"%s\"."), -+ filename_real, auto_load_safe_path); -+ -+ do_cleanups (back_to); -+ return 0; -+} -+ - /* Definition of script language for GDB canned sequences of commands. */ - - static const struct script_language script_language_gdb -@@ -99,13 +277,20 @@ static void - source_gdb_script_for_objfile (struct objfile *objfile, FILE *file, - const char *filename) - { -+ int is_safe; - struct auto_load_pspace_info *pspace_info; - volatile struct gdb_exception e; - -+ is_safe = file_is_auto_load_safe (filename); -+ - /* Add this script to the hash table too so "info auto-load gdb-scripts" - can print it. */ - pspace_info = get_auto_load_pspace_data_for_loading (current_program_space); -- maybe_add_script (pspace_info, filename, filename, &script_language_gdb); -+ maybe_add_script (pspace_info, is_safe, filename, filename, -+ &script_language_gdb); -+ -+ if (!is_safe) -+ return; - - TRY_CATCH (e, RETURN_MASK_ALL) - { -@@ -140,6 +325,9 @@ struct loaded_script - inaccessible). */ - const char *full_path; - -+ /* Non-zero if this script has been loaded. */ -+ int loaded; -+ - const struct script_language *language; - }; - -@@ -232,12 +420,13 @@ get_auto_load_pspace_data_for_loading (s - return info; - } - --/* Add script NAME in LANGUAGE to hash table of PSPACE_INFO. -- FULL_PATH is NULL if the script wasn't found. The result is -+/* Add script NAME in LANGUAGE to hash table of PSPACE_INFO. LOADED 1 if the -+ script has been (is going to) be loaded, 0 otherwise (such as if it has not -+ been found). FULL_PATH is NULL if the script wasn't found. The result is - true if the script was already in the hash table. */ - - int --maybe_add_script (struct auto_load_pspace_info *pspace_info, -+maybe_add_script (struct auto_load_pspace_info *pspace_info, int loaded, - const char *name, const char *full_path, - const struct script_language *language) - { -@@ -271,6 +460,7 @@ maybe_add_script (struct auto_load_pspac - } - else - (*slot)->full_path = NULL; -+ (*slot)->loaded = loaded; - (*slot)->language = language; - } - -@@ -432,7 +622,7 @@ print_script (struct loaded_script *scri - - chain = make_cleanup_ui_out_tuple_begin_end (uiout, NULL); - -- ui_out_field_string (uiout, "loaded", script->full_path ? "Yes" : "Missing"); -+ ui_out_field_string (uiout, "loaded", script->loaded ? "Yes" : "No"); - ui_out_field_string (uiout, "script", script->name); - ui_out_text (uiout, "\n"); - -@@ -718,6 +908,8 @@ void _initialize_auto_load (void); - void - _initialize_auto_load (void) - { -+ struct cmd_list_element *cmd; -+ - auto_load_pspace_data - = register_program_space_data_with_cleanup (auto_load_pspace_data_cleanup); - -@@ -757,4 +949,30 @@ This options has security implications f - _("Print whether current directory .gdbinit file has been loaded.\n\ - Usage: info auto-load local-gdbinit"), - auto_load_info_cmdlist_get ()); -+ -+ auto_load_safe_path = xstrdup (DEFAULT_AUTO_LOAD_SAFE_PATH); -+ auto_load_safe_path_vec_update (); -+ add_setshow_optional_filename_cmd ("safe-path", class_support, -+ &auto_load_safe_path, _("\ -+Set the list of directories from which it is safe to auto-load files."), _("\ -+Show the list of directories from which it is safe to auto-load files."), _("\ -+Various files loaded automatically for the 'set auto-load ...' options must\n\ -+be located in one of the directories listed by this option. Warning will be\n\ -+printed and file will not be used otherwise. Use empty string (or even\n\ -+empty directory entry) to allow any file for the 'set auto-load ...' options.\n\ -+This option is ignored for the kinds of files having 'set auto-load ... off'.\n\ -+This options has security implications for untrusted inferiors."), -+ set_auto_load_safe_path, -+ show_auto_load_safe_path, -+ auto_load_set_cmdlist_get (), -+ auto_load_show_cmdlist_get ()); -+ -+ cmd = add_cmd ("add-auto-load-safe-path", class_support, -+ add_auto_load_safe_path, -+ _("Add entries to the list of directories from which it is safe " -+ "to auto-load files.\n\ -+See the commands 'set auto-load safe-path' and 'show auto-load safe-path' to\n\ -+access the current full list setting."), -+ &cmdlist); -+ set_cmd_completer (cmd, filename_completer); - } -Index: gdb-7.4.50.20120120/gdb/auto-load.h -=================================================================== ---- gdb-7.4.50.20120120.orig/gdb/auto-load.h 2012-04-18 00:46:47.000000000 +0200 -+++ gdb-7.4.50.20120120/gdb/auto-load.h 2012-04-18 00:49:21.607736020 +0200 -@@ -39,7 +39,8 @@ extern int auto_load_local_gdbinit_loade - extern struct auto_load_pspace_info * - get_auto_load_pspace_data_for_loading (struct program_space *pspace); - extern int maybe_add_script (struct auto_load_pspace_info *pspace_info, -- const char *name, const char *full_path, -+ int loaded, const char *name, -+ const char *full_path, - const struct script_language *language); - extern void auto_load_objfile_script (struct objfile *objfile, - const struct script_language *language); -@@ -54,4 +55,6 @@ extern struct cmd_list_element **auto_lo - extern struct cmd_list_element **auto_load_show_cmdlist_get (void); - extern struct cmd_list_element **auto_load_info_cmdlist_get (void); - -+extern int file_is_auto_load_safe (const char *filename); -+ - #endif /* AUTO_LOAD_H */ -Index: gdb-7.4.50.20120120/gdb/config.in -=================================================================== ---- gdb-7.4.50.20120120.orig/gdb/config.in 2012-04-18 00:46:47.000000000 +0200 -+++ gdb-7.4.50.20120120/gdb/config.in 2012-04-18 00:49:21.607736020 +0200 -@@ -43,6 +43,9 @@ - moved. */ - #undef DEBUGDIR_RELOCATABLE - -+/* Directories safe to hold auto-loaded files. */ -+#undef DEFAULT_AUTO_LOAD_SAFE_PATH -+ - /* Define to BFD's default architecture. */ - #undef DEFAULT_BFD_ARCH - -Index: gdb-7.4.50.20120120/gdb/configure -=================================================================== ---- gdb-7.4.50.20120120.orig/gdb/configure 2012-04-18 00:46:47.000000000 +0200 -+++ gdb-7.4.50.20120120/gdb/configure 2012-04-18 00:49:21.611736010 +0200 -@@ -955,6 +955,7 @@ with_separate_debug_dir - with_gdb_datadir - with_relocated_sources - with_rpm -+with_auto_load_safe_path - enable_targets - enable_64_bit_bfd - enable_gdbcli -@@ -1666,6 +1667,10 @@ Optional Packages: - automatically relocate this path for source files - --with-rpm query rpm database for missing debuginfos (yes/no, - def. auto=librpm.so) -+ --with-auto-load-safe-path=PATH -+ directories safe to hold auto-loaded files -+ --without-auto-load-safe-path -+ do not restrict auto-loaded files locations - --with-libunwind use libunwind frame unwinding support - --with-curses use the curses library instead of the termcap - library -@@ -8477,6 +8482,32 @@ $as_echo "$as_me: WARNING: $RPM_PKG_ERRO - fi - fi - -+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for default auto-load safe-path" >&5 -+$as_echo_n "checking for default auto-load safe-path... " >&6; } -+ -+# Check whether --with-auto-load-safe-path was given. -+if test "${with_auto_load_safe_path+set}" = set; then : -+ withval=$with_auto_load_safe_path; if test "$with_auto_load_safe_path" = "no"; then -+ with_auto_load_safe_path="" -+ fi -+else -+ with_auto_load_safe_path="$prefix" -+fi -+ -+ -+ test "x$prefix" = xNONE && prefix="$ac_default_prefix" -+ test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' -+ ac_define_dir=`eval echo $with_auto_load_safe_path` -+ ac_define_dir=`eval echo $ac_define_dir` -+ -+cat >>confdefs.h <<_ACEOF -+#define DEFAULT_AUTO_LOAD_SAFE_PATH "$ac_define_dir" -+_ACEOF -+ -+ -+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $with_auto_load_safe_path" >&5 -+$as_echo "$with_auto_load_safe_path" >&6; } -+ - - - subdirs="$subdirs testsuite" -Index: gdb-7.4.50.20120120/gdb/configure.ac -=================================================================== ---- gdb-7.4.50.20120120.orig/gdb/configure.ac 2012-04-18 00:46:47.000000000 +0200 -+++ gdb-7.4.50.20120120/gdb/configure.ac 2012-04-18 00:49:21.611736010 +0200 -@@ -339,6 +339,18 @@ extern rpmdbMatchIterator rpmtsInitItera - fi - fi - -+AC_MSG_CHECKING([for default auto-load safe-path]) -+AC_ARG_WITH(auto-load-safe-path, -+AS_HELP_STRING([--with-auto-load-safe-path=PATH], [directories safe to hold auto-loaded files]) -+AS_HELP_STRING([--without-auto-load-safe-path], [do not restrict auto-loaded files locations]), -+[if test "$with_auto_load_safe_path" = "no"; then -+ with_auto_load_safe_path="" -+ fi], -+[with_auto_load_safe_path="$prefix"]) -+AC_DEFINE_DIR(DEFAULT_AUTO_LOAD_SAFE_PATH, with_auto_load_safe_path, -+ [Directories safe to hold auto-loaded files.]) -+AC_MSG_RESULT([$with_auto_load_safe_path]) -+ - AC_CONFIG_SUBDIRS(testsuite) - - # Check whether to support alternative target configurations -Index: gdb-7.4.50.20120120/gdb/linux-thread-db.c -=================================================================== ---- gdb-7.4.50.20120120.orig/gdb/linux-thread-db.c 2012-04-18 00:46:47.000000000 +0200 -+++ gdb-7.4.50.20120120/gdb/linux-thread-db.c 2012-04-18 00:49:21.612736007 +0200 -@@ -868,7 +868,11 @@ try_thread_db_load_from_pdir_1 (struct o - /* This should at minimum hit the first character. */ - gdb_assert (cp != NULL); - strcpy (cp + 1, LIBTHREAD_DB_SO); -- result = try_thread_db_load (path); -+ -+ if (!file_is_auto_load_safe (path)) -+ result = 0; -+ else -+ result = try_thread_db_load (path); - - do_cleanups (cleanup); - return result; -@@ -934,7 +938,11 @@ try_thread_db_load_from_dir (const char - memcpy (path, dir, dir_len); - path[dir_len] = '/'; - strcpy (path + dir_len + 1, LIBTHREAD_DB_SO); -- result = try_thread_db_load (path); -+ -+ if (!file_is_auto_load_safe (path)) -+ result = 0; -+ else -+ result = try_thread_db_load (path); - - do_cleanups (cleanup); - return result; -Index: gdb-7.4.50.20120120/gdb/main.c -=================================================================== ---- gdb-7.4.50.20120120.orig/gdb/main.c 2012-04-18 00:46:47.000000000 +0200 -+++ gdb-7.4.50.20120120/gdb/main.c 2012-04-18 00:49:21.612736007 +0200 -@@ -1026,7 +1026,8 @@ captured_main (void *data) - { - auto_load_local_gdbinit_pathname = gdb_realpath (local_gdbinit); - -- if (!inhibit_gdbinit && auto_load_local_gdbinit) -+ if (!inhibit_gdbinit && auto_load_local_gdbinit -+ && file_is_auto_load_safe (local_gdbinit)) - { - auto_load_local_gdbinit_loaded = 1; - -Index: gdb-7.4.50.20120120/gdb/doc/gdb.texinfo -=================================================================== ---- gdb-7.4.50.20120120.orig/gdb/doc/gdb.texinfo 2012-04-18 00:46:47.000000000 +0200 -+++ gdb-7.4.50.20120120/gdb/doc/gdb.texinfo 2012-04-18 00:49:21.620735987 +0200 -@@ -20801,6 +20801,8 @@ gdb-scripts: Auto-loading of canned seq - libthread-db: Auto-loading of inferior specific libthread_db is on. - local-gdbinit: Auto-loading of .gdbinit script from current directory is on. - python-scripts: Auto-loading of Python scripts is on. -+safe-path: List of directories from which it is safe to auto-load files -+ is /usr/local. - @end smallexample - - @anchor{info auto-load} -@@ -20872,12 +20874,19 @@ These are @value{GDBN} control commands - @tab Show setting of thread debugging library. - @item @xref{info auto-load libthread-db}. - @tab Show state of thread debugging library. -+@item @xref{set auto-load safe-path}. -+@tab Control directories trusted for automatic loading. -+@item @xref{show auto-load safe-path}. -+@tab Show directories trusted for automatic loading. -+@item @xref{add-auto-load-safe-path}. -+@tab Add directory trusted for automatic loading. - @end multitable - - @menu - * Init File in the Current Directory:: @samp{set/show/info auto-load local-gdbinit} - * libthread_db.so.1 file:: @samp{set/show/info auto-load libthread-db} - * objfile-gdb.gdb file:: @samp{set/show/info auto-load gdb-script} -+* Auto-loading safe path:: @samp{set/show/info auto-load safe-path} - @xref{Python Auto-loading}. - @end menu - -@@ -20978,6 +20987,104 @@ auto-loaded. - If @var{regexp} is supplied only canned sequences of commands scripts with - matching names are printed. - -+@node Auto-loading safe path -+@subsection Security restriction for auto-loading -+@cindex auto-loading safe-path -+ -+As the files of inferior can come from untrusted source (such as submitted by -+an application user) @value{GDBN} does not always load any files automatically. -+@value{GDBN} provides the @samp{set auto-load safe-path} setting to list -+directories trusted for loading files not explicitly requested by user. -+ -+If the path is not set properly you will see a warning and the file will not -+get loaded: -+ -+@smallexample -+$ ./gdb -q ./gdb -+Reading symbols from /home/user/gdb/gdb...done. -+warning: File "/home/user/gdb/gdb-gdb.gdb" auto-loading has been -+ declined by your `auto-load safe-path' set to "/usr/local". -+warning: File "/home/user/gdb/gdb-gdb.py" auto-loading has been -+ declined by your `auto-load safe-path' set to "/usr/local". -+@end smallexample -+ -+The list of trusted directories is controlled by the following commands: -+ -+@table @code -+@anchor{set auto-load safe-path} -+@kindex set auto-load safe-path -+@item set auto-load safe-path @var{directories} -+Set the list of directories (and their subdirectories) trusted for automatic -+loading and execution of scripts. You can also enter a specific trusted file. -+The list of directories uses directory separator (@samp{:} on GNU and Unix -+systems, @samp{;} on MS-Windows and MS-DOS) to separate directories, similarly -+to the @env{PATH} environment variable. -+ -+@anchor{show auto-load safe-path} -+@kindex show auto-load safe-path -+@item show auto-load safe-path -+Show the list of directories trusted for automatic loading and execution of -+scripts. -+ -+@anchor{add-auto-load-safe-path} -+@kindex add-auto-load-safe-path -+@item add-auto-load-safe-path -+Add an entry (or list of entries) the list of directories trusted for automatic -+loading and execution of scripts. Multiple entries may be delimited by the -+host platform directory separator in use. -+@end table -+ -+Setting this variable to an empty string disables this security protection. -+This variable is supposed to be set to the system directories writable by the -+system superuser only. Users can add their source directories in init files in -+their home directories (@pxref{Home Directory Init File}). See also deprecated -+init file in the current directory -+(@pxref{Init File in the Current Directory during Startup}). -+ -+To force @value{GDBN} to load the files it declined to load in the previous -+example, you could use one of the following ways: -+ -+@itemize @bullet -+@item ~/.gdbinit: add-auto-load-safe-path ~/src/gdb -+Specify this trusted directory (or a file) as additional component of the list. -+You have to specify also any existing directories displayed by -+by @samp{show auto-load safe-path} (such as @samp{/usr:/bin} in this example). -+ -+@item @kbd{gdb -iex "set auto-load safe-path /usr:/bin:~/src/gdb" [@dots{}]} -+Specify this directory as in the previous case but just for a single -+@value{GDBN} session. -+ -+@item @kbd{gdb -iex "set auto-load safe-path" [@dots{}]} -+Disable auto-loading safety for a single @value{GDBN} session. -+This assumes all the files you debug during this @value{GDBN} session will come -+from trusted sources. -+ -+@item @kbd{./configure --without-auto-load-safe-path} -+During compilation of @value{GDBN} you may disable any auto-loading safety. -+This assumes all the files you will ever debug with this @value{GDBN} come from -+trusted sources. -+@end itemize -+ -+On the other hand you can also explicitly forbid automatic files loading which -+also suppresses any such warning messages: -+ -+@itemize @bullet -+@item @kbd{gdb -iex "set auto-load no" [@dots{}]} -+You can use @value{GDBN} command-line option for a single @value{GDBN} session. -+ -+@item @samp{~/.gdbinit}: @samp{set auto-load no} -+Disable auto-loading globally for the user -+(@pxref{Home Directory Init File}). While it is improbable, you could also -+use system init file instead (@pxref{System-wide configuration}). -+@end itemize -+ -+This setting applies to the file names as entered by user. If no entry matches -+@value{GDBN} tries as a last resort to also resolve all the file names into -+their canonical form (typically resolving symbolic links) and compare the -+entries again. @value{GDBN} already canonicalizes most of the filenames on its -+own before starting the comparison so a canonical form of directories is -+recommended to be entered. -+ - @node Messages/Warnings - @section Optional Warnings and Messages - -@@ -24955,10 +25062,10 @@ Example: - - @smallexample - (gdb) info auto-load python-scripts --Loaded Script --Yes py-section-script.py -- full name: /tmp/py-section-script.py --Missing my-foo-pretty-printers.py -+Loaded Script -+Yes py-section-script.py -+ full name: /tmp/py-section-script.py -+No my-foo-pretty-printers.py - @end smallexample - @end table - -Index: gdb-7.4.50.20120120/gdb/python/py-auto-load.c -=================================================================== ---- gdb-7.4.50.20120120.orig/gdb/python/py-auto-load.c 2012-04-18 00:46:47.000000000 +0200 -+++ gdb-7.4.50.20120120/gdb/python/py-auto-load.c 2012-04-18 00:49:21.621735985 +0200 -@@ -72,14 +72,19 @@ static void - gdbpy_load_auto_script_for_objfile (struct objfile *objfile, FILE *file, - const char *filename) - { -+ int is_safe; - struct auto_load_pspace_info *pspace_info; - -+ is_safe = file_is_auto_load_safe (filename); -+ - /* Add this script to the hash table too so "info auto-load python-scripts" - can print it. */ - pspace_info = get_auto_load_pspace_data_for_loading (current_program_space); -- maybe_add_script (pspace_info, filename, filename, &script_language_python); -+ maybe_add_script (pspace_info, is_safe, filename, filename, -+ &script_language_python); - -- source_python_script_for_objfile (objfile, file, filename); -+ if (is_safe) -+ source_python_script_for_objfile (objfile, file, filename); - } - - /* Load scripts specified in OBJFILE. -@@ -147,6 +152,9 @@ source_section_scripts (struct objfile * - { - make_cleanup_fclose (stream); - make_cleanup (xfree, full_path); -+ -+ if (!file_is_auto_load_safe (full_path)) -+ opened = 0; - } - else - { -@@ -167,7 +175,7 @@ Use `info auto-load python [REGEXP]' to - - IWBN if complaints.c were more general-purpose. */ - -- in_hash_table = maybe_add_script (pspace_info, file, full_path, -+ in_hash_table = maybe_add_script (pspace_info, opened, file, full_path, - &script_language_python); - - /* If this file is not currently loaded, load it. */ -Index: gdb-7.4.50.20120120/gdb/testsuite/gdb.python/py-objfile-script.exp -=================================================================== ---- gdb-7.4.50.20120120.orig/gdb/testsuite/gdb.python/py-objfile-script.exp 2012-04-18 00:46:47.000000000 +0200 -+++ gdb-7.4.50.20120120/gdb/testsuite/gdb.python/py-objfile-script.exp 2012-04-18 00:49:21.621735985 +0200 -@@ -37,6 +37,7 @@ if { [skip_python_tests] } { continue } - set remote_python_file [remote_download host ${srcdir}/${subdir}/${testfile}-gdb.py.in ${subdir}/${testfile}-gdb.py] - - gdb_reinitialize_dir $srcdir/$subdir -+gdb_test_no_output "set auto-load safe-path ${remote_python_file}" "set auto-load safe-path" - gdb_load ${binfile} - - # Verify gdb loaded the script. -Index: gdb-7.4.50.20120120/gdb/testsuite/gdb.python/py-section-script.exp -=================================================================== ---- gdb-7.4.50.20120120.orig/gdb/testsuite/gdb.python/py-section-script.exp 2012-04-18 00:46:47.000000000 +0200 -+++ gdb-7.4.50.20120120/gdb/testsuite/gdb.python/py-section-script.exp 2012-04-18 00:49:21.621735985 +0200 -@@ -49,6 +49,7 @@ if { [skip_python_tests] } { continue } - set remote_python_file [remote_download host ${srcdir}/${subdir}/${testfile}.py] - - gdb_reinitialize_dir $srcdir/$subdir -+gdb_test_no_output "set auto-load safe-path ${remote_python_file}" "set auto-load safe-path" - gdb_load ${binfile} - - # Verify gdb loaded the script. diff --git a/gdb-autoload-12of28.patch b/gdb-autoload-12of28.patch deleted file mode 100644 index 392bdbc..0000000 --- a/gdb-autoload-12of28.patch +++ /dev/null @@ -1,352 +0,0 @@ -[patch#4 6/8] set debug auto-load -http://sourceware.org/ml/gdb-patches/2012-04/msg00089.html -http://sourceware.org/ml/gdb-cvs/2012-04/msg00115.html - -### src/gdb/ChangeLog 2012/04/17 15:54:28 1.14114 -### src/gdb/ChangeLog 2012/04/17 15:56:20 1.14115 -## -1,5 +1,27 @@ - 2012-04-17 Jan Kratochvil - -+ New option "set debug auto-load". -+ * NEWS: New commands "set debug auto-load" and "show debug auto-load". -+ * auto-load.c (debug_auto_load, show_debug_auto_load: New. -+ (auto_load_safe_path_vec_update) -+ (filename_is_in_auto_load_safe_path_vec): Call fprintf_unfiltered -+ if DEBUG_AUTO_LOAD. -+ (file_is_auto_load_safe): New parameters debug_fmt and .... -+ Call fprintf_unfiltered if DEBUG_AUTO_LOAD. -+ (source_gdb_script_for_objfile): Extend the file_is_auto_load_safe -+ caller by explanatory string. -+ (_initialize_auto_load): Register "set debug auto-load". -+ * auto-load.h (file_is_auto_load_safe): New parameters debug_fmt -+ and .... -+ * linux-thread-db.c (try_thread_db_load_from_pdir_1) -+ (try_thread_db_load_from_dir): Extend the file_is_auto_load_safe caller -+ by explanatory string. -+ * main.c (captured_main): Likewise. -+ * python/py-auto-load.c (gdbpy_load_auto_script_for_objfile) -+ (source_section_scripts): Likewise. -+ -+2012-04-17 Jan Kratochvil -+ - New option "set auto-load safe-path". - * NEWS: New commands "set auto-load safe-path" - and "show auto-load safe-path". -Index: gdb-7.4.50.20120120/gdb/NEWS -=================================================================== ---- gdb-7.4.50.20120120.orig/gdb/NEWS 2012-04-18 00:49:33.000000000 +0200 -+++ gdb-7.4.50.20120120/gdb/NEWS 2012-04-18 00:50:15.018600282 +0200 -@@ -72,6 +72,10 @@ show auto-load safe-path - Set a list of directories from which it is safe to auto-load files. - The delimiter (':' above) may differ according to the host platform. - -+set debug auto-load on|off -+show debug auto-load -+ Control display of debugging info for auto-loading the files above. -+ - * New command line options - - --init-command=FILE, -ix Like --command, -x but execute it -Index: gdb-7.4.50.20120120/gdb/auto-load.c -=================================================================== ---- gdb-7.4.50.20120120.orig/gdb/auto-load.c 2012-04-18 00:49:21.000000000 +0200 -+++ gdb-7.4.50.20120120/gdb/auto-load.c 2012-04-18 00:50:04.801626235 +0200 -@@ -43,6 +43,20 @@ - static void source_gdb_script_for_objfile (struct objfile *objfile, FILE *file, - const char *filename); - -+/* Value of the 'set debug auto-load' configuration variable. */ -+static int debug_auto_load = 0; -+ -+/* "show" command for the debug_auto_load configuration variable. */ -+ -+static void -+show_debug_auto_load (struct ui_file *file, int from_tty, -+ struct cmd_list_element *c, const char *value) -+{ -+ fprintf_filtered (file, _("Debugging output for files " -+ "of 'set auto-load ...' is %s.\n"), -+ value); -+} -+ - /* User-settable option to enable/disable auto-loading of GDB_AUTO_FILE_NAME - scripts: - set auto-load gdb-scripts on|off -@@ -112,6 +126,11 @@ auto_load_safe_path_vec_update (void) - unsigned len; - int ix; - -+ if (debug_auto_load) -+ fprintf_unfiltered (gdb_stdlog, -+ _("auto-load: Updating directories of \"%s\".\n"), -+ auto_load_safe_path); -+ - free_char_ptr_vec (auto_load_safe_path_vec); - - auto_load_safe_path_vec = dirnames_to_char_ptr_vec (auto_load_safe_path); -@@ -126,14 +145,34 @@ auto_load_safe_path_vec_update (void) - char *real_path = gdb_realpath (expanded); - - /* Ensure the current entry is at least tilde_expand-ed. */ -- xfree (dir); - VEC_replace (char_ptr, auto_load_safe_path_vec, ix, expanded); - -+ if (debug_auto_load) -+ { -+ if (strcmp (expanded, dir) == 0) -+ fprintf_unfiltered (gdb_stdlog, -+ _("auto-load: Using directory \"%s\".\n"), -+ expanded); -+ else -+ fprintf_unfiltered (gdb_stdlog, -+ _("auto-load: Resolved directory \"%s\" " -+ "as \"%s\".\n"), -+ dir, expanded); -+ } -+ xfree (dir); -+ - /* If gdb_realpath returns a different content, append it. */ - if (strcmp (real_path, expanded) == 0) - xfree (real_path); - else -- VEC_safe_push (char_ptr, auto_load_safe_path_vec, real_path); -+ { -+ VEC_safe_push (char_ptr, auto_load_safe_path_vec, real_path); -+ -+ if (debug_auto_load) -+ fprintf_unfiltered (gdb_stdlog, -+ _("auto-load: And canonicalized as \"%s\".\n"), -+ real_path); -+ } - } - } - -@@ -217,16 +256,30 @@ filename_is_in_auto_load_safe_path_vec ( - if (dir == NULL) - { - if (*filename_realp == NULL) -- *filename_realp = gdb_realpath (filename); -+ { -+ *filename_realp = gdb_realpath (filename); -+ if (debug_auto_load && strcmp (*filename_realp, filename) != 0) -+ fprintf_unfiltered (gdb_stdlog, -+ _("auto-load: Resolved " -+ "file \"%s\" as \"%s\".\n"), -+ filename, *filename_realp); -+ } - -- for (ix = 0; VEC_iterate (char_ptr, auto_load_safe_path_vec, ix, dir); -- ++ix) -- if (filename_is_in_dir (*filename_realp, dir)) -- break; -+ if (strcmp (*filename_realp, filename) != 0) -+ for (ix = 0; VEC_iterate (char_ptr, auto_load_safe_path_vec, ix, dir); -+ ++ix) -+ if (filename_is_in_dir (*filename_realp, dir)) -+ break; - } - - if (dir != NULL) -- return 1; -+ { -+ if (debug_auto_load) -+ fprintf_unfiltered (gdb_stdlog, _("auto-load: File \"%s\" matches " -+ "directory \"%s\".\n"), -+ filename, dir); -+ return 1; -+ } - - return 0; - } -@@ -240,11 +293,20 @@ filename_is_in_auto_load_safe_path_vec ( - directory. */ - - int --file_is_auto_load_safe (const char *filename) -+file_is_auto_load_safe (const char *filename, const char *debug_fmt, ...) - { - char *filename_real = NULL; - struct cleanup *back_to; - -+ if (debug_auto_load) -+ { -+ va_list debug_args; -+ -+ va_start (debug_args, debug_fmt); -+ vfprintf_unfiltered (gdb_stdlog, debug_fmt, debug_args); -+ va_end (debug_args); -+ } -+ - back_to = make_cleanup (free_current_contents, &filename_real); - - if (filename_is_in_auto_load_safe_path_vec (filename, &filename_real)) -@@ -281,7 +343,10 @@ source_gdb_script_for_objfile (struct ob - struct auto_load_pspace_info *pspace_info; - volatile struct gdb_exception e; - -- is_safe = file_is_auto_load_safe (filename); -+ is_safe = file_is_auto_load_safe (filename, _("auto-load: Loading canned " -+ "sequences of commands script " -+ "\"%s\" for objfile \"%s\".\n"), -+ filename, objfile->name); - - /* Add this script to the hash table too so "info auto-load gdb-scripts" - can print it. */ -@@ -975,4 +1040,13 @@ See the commands 'set auto-load safe-pat - access the current full list setting."), - &cmdlist); - set_cmd_completer (cmd, filename_completer); -+ -+ add_setshow_boolean_cmd ("auto-load", class_maintenance, -+ &debug_auto_load, _("\ -+Set auto-load verifications debugging."), _("\ -+Show auto-load verifications debugging."), _("\ -+When non-zero, debugging output for files of 'set auto-load ...'\n\ -+is displayed."), -+ NULL, show_debug_auto_load, -+ &setdebuglist, &showdebuglist); - } -Index: gdb-7.4.50.20120120/gdb/auto-load.h -=================================================================== ---- gdb-7.4.50.20120120.orig/gdb/auto-load.h 2012-04-18 00:49:21.000000000 +0200 -+++ gdb-7.4.50.20120120/gdb/auto-load.h 2012-04-18 00:50:04.801626235 +0200 -@@ -55,6 +55,7 @@ extern struct cmd_list_element **auto_lo - extern struct cmd_list_element **auto_load_show_cmdlist_get (void); - extern struct cmd_list_element **auto_load_info_cmdlist_get (void); - --extern int file_is_auto_load_safe (const char *filename); -+extern int file_is_auto_load_safe (const char *filename, -+ const char *debug_fmt, ...); - - #endif /* AUTO_LOAD_H */ -Index: gdb-7.4.50.20120120/gdb/linux-thread-db.c -=================================================================== ---- gdb-7.4.50.20120120.orig/gdb/linux-thread-db.c 2012-04-18 00:49:21.000000000 +0200 -+++ gdb-7.4.50.20120120/gdb/linux-thread-db.c 2012-04-18 00:50:04.801626235 +0200 -@@ -869,7 +869,9 @@ try_thread_db_load_from_pdir_1 (struct o - gdb_assert (cp != NULL); - strcpy (cp + 1, LIBTHREAD_DB_SO); - -- if (!file_is_auto_load_safe (path)) -+ if (!file_is_auto_load_safe (path, _("auto-load: Loading libthread-db " -+ "library \"%s\" from $pdir.\n"), -+ path)) - result = 0; - else - result = try_thread_db_load (path); -@@ -939,7 +941,10 @@ try_thread_db_load_from_dir (const char - path[dir_len] = '/'; - strcpy (path + dir_len + 1, LIBTHREAD_DB_SO); - -- if (!file_is_auto_load_safe (path)) -+ if (!file_is_auto_load_safe (path, _("auto-load: Loading libthread-db " -+ "library \"%s\" from explicit " -+ "directory.\n"), -+ path)) - result = 0; - else - result = try_thread_db_load (path); -Index: gdb-7.4.50.20120120/gdb/main.c -=================================================================== ---- gdb-7.4.50.20120120.orig/gdb/main.c 2012-04-18 00:49:21.000000000 +0200 -+++ gdb-7.4.50.20120120/gdb/main.c 2012-04-18 00:50:04.801626235 +0200 -@@ -1027,7 +1027,10 @@ captured_main (void *data) - auto_load_local_gdbinit_pathname = gdb_realpath (local_gdbinit); - - if (!inhibit_gdbinit && auto_load_local_gdbinit -- && file_is_auto_load_safe (local_gdbinit)) -+ && file_is_auto_load_safe (local_gdbinit, -+ _("auto-load: Loading .gdbinit " -+ "file \"%s\".\n"), -+ local_gdbinit)) - { - auto_load_local_gdbinit_loaded = 1; - -Index: gdb-7.4.50.20120120/gdb/doc/gdb.texinfo -=================================================================== ---- gdb-7.4.50.20120120.orig/gdb/doc/gdb.texinfo 2012-04-18 00:49:21.000000000 +0200 -+++ gdb-7.4.50.20120120/gdb/doc/gdb.texinfo 2012-04-18 00:50:04.809626215 +0200 -@@ -20887,6 +20887,7 @@ These are @value{GDBN} control commands - * libthread_db.so.1 file:: @samp{set/show/info auto-load libthread-db} - * objfile-gdb.gdb file:: @samp{set/show/info auto-load gdb-script} - * Auto-loading safe path:: @samp{set/show/info auto-load safe-path} -+* Auto-loading verbose mode:: @samp{set/show debug auto-load} - @xref{Python Auto-loading}. - @end menu - -@@ -21085,6 +21086,45 @@ entries again. @value{GDBN} already can - own before starting the comparison so a canonical form of directories is - recommended to be entered. - -+@node Auto-loading verbose mode -+@subsection Displaying files tried for auto-load -+@cindex auto-loading verbose mode -+ -+For better visibility of all the file locations where you can place scripts to -+be auto-loaded with inferior --- or to protect yourself against accidental -+execution of untrusted scripts --- @value{GDBN} provides a feature for printing -+all the files attempted to be loaded. Both existing and non-existing files may -+be printed. -+ -+For example the list of directories from which it is safe to auto-load files -+(@pxref{Auto-loading safe path}) applies also to canonicalized filenames which -+may not be too obvious while setting it up. -+ -+@smallexample -+(gdb) set debug auto-load ues -+(gdb) file ~/src/t/true -+auto-load: Loading canned sequences of commands script "/tmp/true-gdb.gdb" -+ for objfile "/tmp/true". -+auto-load: Updating directories of "/usr:/opt". -+auto-load: Using directory "/usr". -+auto-load: Using directory "/opt". -+warning: File "/tmp/true-gdb.gdb" auto-loading has been declined -+ by your `auto-load safe-path' set to "/usr:/opt". -+@end smallexample -+ -+@table @code -+@anchor{set debug auto-load} -+@kindex set debug auto-load -+@item set debug auto-load [on|off] -+Set whether to print the filenames attempted to be auto-loaded. -+ -+@anchor{show debug auto-load} -+@kindex show debug auto-load -+@item show debug auto-load -+Show whether printing of the filenames attempted to be auto-loaded is turned -+on or off. -+@end table -+ - @node Messages/Warnings - @section Optional Warnings and Messages - -Index: gdb-7.4.50.20120120/gdb/python/py-auto-load.c -=================================================================== ---- gdb-7.4.50.20120120.orig/gdb/python/py-auto-load.c 2012-04-18 00:49:21.000000000 +0200 -+++ gdb-7.4.50.20120120/gdb/python/py-auto-load.c 2012-04-18 00:50:04.810626212 +0200 -@@ -75,7 +75,10 @@ gdbpy_load_auto_script_for_objfile (stru - int is_safe; - struct auto_load_pspace_info *pspace_info; - -- is_safe = file_is_auto_load_safe (filename); -+ is_safe = file_is_auto_load_safe (filename, -+ _("auto-load: Loading Python script \"%s\" " -+ "by extension for objfile \"%s\".\n"), -+ filename, objfile->name); - - /* Add this script to the hash table too so "info auto-load python-scripts" - can print it. */ -@@ -153,7 +156,12 @@ source_section_scripts (struct objfile * - make_cleanup_fclose (stream); - make_cleanup (xfree, full_path); - -- if (!file_is_auto_load_safe (full_path)) -+ if (!file_is_auto_load_safe (full_path, -+ _("auto-load: Loading Python script " -+ "\"%s\" from section \"%s\" of " -+ "objfile \"%s\".\n"), -+ full_path, GDBPY_AUTO_SECTION_NAME, -+ objfile->name)) - opened = 0; - } - else diff --git a/gdb-autoload-13of28.patch b/gdb-autoload-13of28.patch deleted file mode 100644 index 26ea153..0000000 --- a/gdb-autoload-13of28.patch +++ /dev/null @@ -1,23 +0,0 @@ -http://sourceware.org/ml/gdb-cvs/2012-04/msg00130.html - -### src/gdb/doc/ChangeLog 2012/04/17 15:56:21 1.1297 -### src/gdb/doc/ChangeLog 2012/04/18 07:03:57 1.1298 -## -1,3 +1,7 @@ -+2012-04-18 Jan Kratochvil -+ -+ * gdb.texinfo (Auto-loading verbose mode): Fix smallexample typo. -+ - 2012-04-17 Jan Kratochvil - - New option "set debug auto-load". ---- src/gdb/doc/gdb.texinfo 2012/04/17 15:56:21 1.944 -+++ src/gdb/doc/gdb.texinfo 2012/04/18 07:03:58 1.945 -@@ -21192,7 +21192,7 @@ - may not be too obvious while setting it up. - - @smallexample --(gdb) set debug auto-load ues -+(gdb) set debug auto-load on - (gdb) file ~/src/t/true - auto-load: Loading canned sequences of commands script "/tmp/true-gdb.gdb" - for objfile "/tmp/true". diff --git a/gdb-autoload-14of28.patch b/gdb-autoload-14of28.patch deleted file mode 100644 index 2acfd0e..0000000 --- a/gdb-autoload-14of28.patch +++ /dev/null @@ -1,51 +0,0 @@ -http://sourceware.org/ml/gdb-cvs/2012-04/msg00178.html - -### src/gdb/doc/ChangeLog 2012/04/18 07:03:57 1.1298 -### src/gdb/doc/ChangeLog 2012/04/22 15:49:21 1.1299 -## -1,3 +1,8 @@ -+2012-04-22 Jan Kratochvil -+ -+ * gdb.texinfo (Auto-loading safe path): Replace @itemize @bullet -+ by @table @asis. Fix formatting of one item. -+ - 2012-04-18 Jan Kratochvil - - * gdb.texinfo (Auto-loading verbose mode): Fix smallexample typo. ---- src/gdb/doc/gdb.texinfo 2012/04/18 07:03:58 1.945 -+++ src/gdb/doc/gdb.texinfo 2012/04/22 15:49:21 1.946 -@@ -21136,8 +21136,8 @@ - To force @value{GDBN} to load the files it declined to load in the previous - example, you could use one of the following ways: - --@itemize @bullet --@item ~/.gdbinit: add-auto-load-safe-path ~/src/gdb -+@table @asis -+@item @file{~/.gdbinit}: @samp{add-auto-load-safe-path ~/src/gdb} - Specify this trusted directory (or a file) as additional component of the list. - You have to specify also any existing directories displayed by - by @samp{show auto-load safe-path} (such as @samp{/usr:/bin} in this example). -@@ -21155,20 +21155,20 @@ - During compilation of @value{GDBN} you may disable any auto-loading safety. - This assumes all the files you will ever debug with this @value{GDBN} come from - trusted sources. --@end itemize -+@end table - - On the other hand you can also explicitly forbid automatic files loading which - also suppresses any such warning messages: - --@itemize @bullet -+@table @asis - @item @kbd{gdb -iex "set auto-load no" [@dots{}]} - You can use @value{GDBN} command-line option for a single @value{GDBN} session. - --@item @samp{~/.gdbinit}: @samp{set auto-load no} -+@item @file{~/.gdbinit}: @samp{set auto-load no} - Disable auto-loading globally for the user - (@pxref{Home Directory Init File}). While it is improbable, you could also - use system init file instead (@pxref{System-wide configuration}). --@end itemize -+@end table - - This setting applies to the file names as entered by user. If no entry matches - @value{GDBN} tries as a last resort to also resolve all the file names into diff --git a/gdb-autoload-15of28.patch b/gdb-autoload-15of28.patch deleted file mode 100644 index de56846..0000000 --- a/gdb-autoload-15of28.patch +++ /dev/null @@ -1,38 +0,0 @@ -http://sourceware.org/ml/gdb-cvs/2012-04/msg00183.html - -### src/gdb/doc/ChangeLog 2012/04/22 15:49:21 1.1299 -### src/gdb/doc/ChangeLog 2012/04/23 17:20:56 1.1300 -## -1,3 +1,8 @@ -+2012-04-23 Jan Kratochvil -+ -+ * gdb.texinfo (Auto-loading safe path): Remove trailing [@dots{}]. -+ Three times. -+ - 2012-04-22 Jan Kratochvil - - * gdb.texinfo (Auto-loading safe path): Replace @itemize @bullet ---- src/gdb/doc/gdb.texinfo 2012/04/22 15:49:21 1.946 -+++ src/gdb/doc/gdb.texinfo 2012/04/23 17:20:56 1.947 -@@ -21142,11 +21142,11 @@ - You have to specify also any existing directories displayed by - by @samp{show auto-load safe-path} (such as @samp{/usr:/bin} in this example). - --@item @kbd{gdb -iex "set auto-load safe-path /usr:/bin:~/src/gdb" [@dots{}]} -+@item @kbd{gdb -iex "set auto-load safe-path /usr:/bin:~/src/gdb"} - Specify this directory as in the previous case but just for a single - @value{GDBN} session. - --@item @kbd{gdb -iex "set auto-load safe-path" [@dots{}]} -+@item @kbd{gdb -iex "set auto-load safe-path"} - Disable auto-loading safety for a single @value{GDBN} session. - This assumes all the files you debug during this @value{GDBN} session will come - from trusted sources. -@@ -21161,7 +21161,7 @@ - also suppresses any such warning messages: - - @table @asis --@item @kbd{gdb -iex "set auto-load no" [@dots{}]} -+@item @kbd{gdb -iex "set auto-load no"} - You can use @value{GDBN} command-line option for a single @value{GDBN} session. - - @item @file{~/.gdbinit}: @samp{set auto-load no} diff --git a/gdb-autoload-16of28.patch b/gdb-autoload-16of28.patch deleted file mode 100644 index afa88e6..0000000 --- a/gdb-autoload-16of28.patch +++ /dev/null @@ -1,39 +0,0 @@ -http://sourceware.org/ml/gdb-cvs/2012-04/msg00184.html - -### src/gdb/doc/ChangeLog 2012/04/23 17:20:56 1.1300 -### src/gdb/doc/ChangeLog 2012/04/23 17:26:00 1.1301 -## -3,6 +3,9 @@ - * gdb.texinfo (Auto-loading safe path): Remove trailing [@dots{}]. - Three times. - -+ * gdb.texinfo (Auto-loading safe path): Add trailing @dots{}. -+ Three times. -+ - 2012-04-22 Jan Kratochvil - - * gdb.texinfo (Auto-loading safe path): Replace @itemize @bullet ---- src/gdb/doc/gdb.texinfo 2012/04/23 17:20:56 1.947 -+++ src/gdb/doc/gdb.texinfo 2012/04/23 17:26:01 1.948 -@@ -21142,11 +21142,11 @@ - You have to specify also any existing directories displayed by - by @samp{show auto-load safe-path} (such as @samp{/usr:/bin} in this example). - --@item @kbd{gdb -iex "set auto-load safe-path /usr:/bin:~/src/gdb"} -+@item @kbd{gdb -iex "set auto-load safe-path /usr:/bin:~/src/gdb" @dots{}} - Specify this directory as in the previous case but just for a single - @value{GDBN} session. - --@item @kbd{gdb -iex "set auto-load safe-path"} -+@item @kbd{gdb -iex "set auto-load safe-path" @dots{}} - Disable auto-loading safety for a single @value{GDBN} session. - This assumes all the files you debug during this @value{GDBN} session will come - from trusted sources. -@@ -21161,7 +21161,7 @@ - also suppresses any such warning messages: - - @table @asis --@item @kbd{gdb -iex "set auto-load no"} -+@item @kbd{gdb -iex "set auto-load no" @dots{}} - You can use @value{GDBN} command-line option for a single @value{GDBN} session. - - @item @file{~/.gdbinit}: @samp{set auto-load no} diff --git a/gdb-autoload-17of28.patch b/gdb-autoload-17of28.patch deleted file mode 100644 index a74f75b..0000000 --- a/gdb-autoload-17of28.patch +++ /dev/null @@ -1,28 +0,0 @@ -http://sourceware.org/ml/gdb-cvs/2012-05/msg00010.html - -### src/gdb/ChangeLog 2012/05/02 17:13:39 1.14194 -### src/gdb/ChangeLog 2012/05/02 20:00:31 1.14195 -## -1,3 +1,8 @@ -+2012-05-02 Jan Kratochvil -+ -+ Fix --without-auto-load-safe-path for MS-Windows host platform. -+ * auto-load.c (filename_is_in_dir): Return 1 for DIR_LEN 0. -+ - 2012-05-02 Eli Zaretskii - - * gdb_curses.h: Undefine KEY_EVENT before including curses ---- src/gdb/auto-load.c 2012/04/17 15:56:21 1.4 -+++ src/gdb/auto-load.c 2012/05/02 20:00:36 1.5 -@@ -231,6 +231,12 @@ - while (dir_len && IS_DIR_SEPARATOR (dir[dir_len - 1])) - dir_len--; - -+ /* Ensure auto_load_safe_path "/" matches any FILENAME. On MS-Windows -+ platform FILENAME even after gdb_realpath does not have to start with -+ IS_DIR_SEPARATOR character, such as the 'C:\x.exe' filename. */ -+ if (dir_len == 0) -+ return 1; -+ - return (filename_ncmp (dir, filename, dir_len) == 0 - && (IS_DIR_SEPARATOR (filename[dir_len]) - || filename[dir_len] == '\0')); diff --git a/gdb-autoload-18of28.patch b/gdb-autoload-18of28.patch deleted file mode 100644 index 690c2e4..0000000 --- a/gdb-autoload-18of28.patch +++ /dev/null @@ -1,136 +0,0 @@ -http://sourceware.org/ml/gdb-cvs/2012-05/msg00038.html - -### src/gdb/ChangeLog 2012/05/05 05:36:23 1.14211 -### src/gdb/ChangeLog 2012/05/06 15:30:59 1.14212 -## -1,3 +1,14 @@ -+2012-05-06 Jan Kratochvil -+ -+ * auto-load.c (set_auto_load_safe_path): Reset AUTO_LOAD_SAFE_PATH -+ back to DEFAULT_AUTO_LOAD_SAFE_PATH if it is being set to "". -+ (show_auto_load_safe_path): Check any-directory by comparison with "/". -+ (add_auto_load_safe_path): Change the error message. -+ (_initialize_auto_load): Change the "safe-path" help text. -+ * configure: Regenerate -+ * configure.ac (--without-auto-load-safe-path): Set -+ WITH_AUTO_LOAD_SAFE_PATH to /. -+ - 2012-05-05 Sergio Durigan Junior - - * stap-probe.h: Do not include unecessary `probe.h'. ---- src/gdb/auto-load.c 2012/05/02 20:00:36 1.5 -+++ src/gdb/auto-load.c 2012/05/06 15:31:02 1.6 -@@ -181,6 +181,12 @@ - static void - set_auto_load_safe_path (char *args, int from_tty, struct cmd_list_element *c) - { -+ if (auto_load_safe_path[0] == '\0') -+ { -+ xfree (auto_load_safe_path); -+ auto_load_safe_path = xstrdup (DEFAULT_AUTO_LOAD_SAFE_PATH); -+ } -+ - auto_load_safe_path_vec_update (); - } - -@@ -190,7 +196,7 @@ - show_auto_load_safe_path (struct ui_file *file, int from_tty, - struct cmd_list_element *c, const char *value) - { -- if (*value == 0) -+ if (strcmp (value, "/") == 0) - fprintf_filtered (file, _("Auto-load files are safe to load from any " - "directory.\n")); - else -@@ -209,8 +215,9 @@ - - if (args == NULL || *args == 0) - error (_("\ --Adding empty directory element disables the auto-load safe-path security. \ --Use 'set auto-load safe-path' instead if you mean that.")); -+Directory argument required.\n\ -+Use 'set auto-load safe-path /' for disabling the auto-load safe-path security.\ -+")); - - s = xstrprintf ("%s%c%s", auto_load_safe_path, DIRNAME_SEPARATOR, args); - xfree (auto_load_safe_path); -@@ -1029,8 +1036,10 @@ - Show the list of directories from which it is safe to auto-load files."), _("\ - Various files loaded automatically for the 'set auto-load ...' options must\n\ - be located in one of the directories listed by this option. Warning will be\n\ --printed and file will not be used otherwise. Use empty string (or even\n\ --empty directory entry) to allow any file for the 'set auto-load ...' options.\n\ -+printed and file will not be used otherwise.\n\ -+Setting this parameter to an empty list resets it to its default value.\n\ -+Setting this parameter to '/' (without the quotes) allows any file\n\ -+for the 'set auto-load ...' options.\n\ - This option is ignored for the kinds of files having 'set auto-load ... off'.\n\ - This options has security implications for untrusted inferiors."), - set_auto_load_safe_path, ---- src/gdb/configure 2012/04/27 20:47:52 1.360 -+++ src/gdb/configure 2012/05/06 15:31:02 1.361 -@@ -4964,7 +4964,7 @@ - # Check whether --with-auto-load-safe-path was given. - if test "${with_auto_load_safe_path+set}" = set; then : - withval=$with_auto_load_safe_path; if test "$with_auto_load_safe_path" = "no"; then -- with_auto_load_safe_path="" -+ with_auto_load_safe_path="/" - fi - else - with_auto_load_safe_path="$prefix" ---- src/gdb/configure.ac 2012/04/27 20:47:53 1.171 -+++ src/gdb/configure.ac 2012/05/06 15:31:03 1.172 -@@ -141,7 +141,7 @@ - AS_HELP_STRING([--with-auto-load-safe-path=PATH], [directories safe to hold auto-loaded files]) - AS_HELP_STRING([--without-auto-load-safe-path], [do not restrict auto-loaded files locations]), - [if test "$with_auto_load_safe_path" = "no"; then -- with_auto_load_safe_path="" -+ with_auto_load_safe_path="/" - fi], - [with_auto_load_safe_path="$prefix"]) - AC_DEFINE_DIR(DEFAULT_AUTO_LOAD_SAFE_PATH, with_auto_load_safe_path, -### src/gdb/doc/ChangeLog 2012/05/03 07:07:24 1.1308 -### src/gdb/doc/ChangeLog 2012/05/06 15:31:04 1.1309 -## -1,3 +1,9 @@ -+2012-05-06 Jan Kratochvil -+ -+ * gdb.texinfo (Auto-loading safe path): Make 'directories' -+ for 'set auto-load safe-path' optional. Mention if it is omitted. -+ Change disabling security protection condition to "/", twice. -+ - 2012-05-03 Siva Chandra Reddy - - * gdb.texinfo (Symbol Tables In Python): Add documentation about ---- src/gdb/doc/gdb.texinfo 2012/05/03 07:07:24 1.954 -+++ src/gdb/doc/gdb.texinfo 2012/05/06 15:31:04 1.955 -@@ -21219,9 +21219,12 @@ - @table @code - @anchor{set auto-load safe-path} - @kindex set auto-load safe-path --@item set auto-load safe-path @var{directories} -+@item set auto-load safe-path @r{[}@var{directories}@r{]} - Set the list of directories (and their subdirectories) trusted for automatic - loading and execution of scripts. You can also enter a specific trusted file. -+If you omit @var{directories}, @samp{auto-load safe-path} will be reset to -+its default value as specified during @value{GDBN} compilation. -+ - The list of directories uses directory separator (@samp{:} on GNU and Unix - systems, @samp{;} on MS-Windows and MS-DOS) to separate directories, similarly - to the @env{PATH} environment variable. -@@ -21240,7 +21243,7 @@ - host platform directory separator in use. - @end table - --Setting this variable to an empty string disables this security protection. -+Setting this variable to @file{/} disables this security protection. - This variable is supposed to be set to the system directories writable by the - system superuser only. Users can add their source directories in init files in - their home directories (@pxref{Home Directory Init File}). See also deprecated -@@ -21260,7 +21263,7 @@ - Specify this directory as in the previous case but just for a single - @value{GDBN} session. - --@item @kbd{gdb -iex "set auto-load safe-path" @dots{}} -+@item @kbd{gdb -iex "set auto-load safe-path /" @dots{}} - Disable auto-loading safety for a single @value{GDBN} session. - This assumes all the files you debug during this @value{GDBN} session will come - from trusted sources. diff --git a/gdb-autoload-19of28.patch b/gdb-autoload-19of28.patch deleted file mode 100644 index f7b1293..0000000 --- a/gdb-autoload-19of28.patch +++ /dev/null @@ -1,45 +0,0 @@ -http://sourceware.org/ml/gdb-cvs/2012-05/msg00060.html - -### src/gdb/doc/ChangeLog 2012/05/09 18:15:58 1.1310 -### src/gdb/doc/ChangeLog 2012/05/09 19:29:25 1.1311 -## -3,6 +3,9 @@ - * gdb.texinfo (Auto-loading): Wrap too long lines in @smallexample. - Twice. - -+ * gdb.texinfo (Separate Debug Files, Auto-loading safe path): Replace -+ directory separator by path separator. -+ - 2012-05-06 Jan Kratochvil - - * gdb.texinfo (Auto-loading safe path): Make 'directories' ---- src/gdb/doc/gdb.texinfo 2012/05/09 18:15:58 1.956 -+++ src/gdb/doc/gdb.texinfo 2012/05/09 19:29:25 1.957 -@@ -16285,8 +16285,8 @@ - @kindex set debug-file-directory - @item set debug-file-directory @var{directories} - Set the directories which @value{GDBN} searches for separate debugging --information files to @var{directory}. Multiple directory components can be set --concatenating them by a directory separator. -+information files to @var{directory}. Multiple path components can be set -+concatenating them by a path separator. - - @kindex show debug-file-directory - @item show debug-file-directory -@@ -21227,7 +21227,7 @@ - If you omit @var{directories}, @samp{auto-load safe-path} will be reset to - its default value as specified during @value{GDBN} compilation. - --The list of directories uses directory separator (@samp{:} on GNU and Unix -+The list of directories uses path separator (@samp{:} on GNU and Unix - systems, @samp{;} on MS-Windows and MS-DOS) to separate directories, similarly - to the @env{PATH} environment variable. - -@@ -21242,7 +21242,7 @@ - @item add-auto-load-safe-path - Add an entry (or list of entries) the list of directories trusted for automatic - loading and execution of scripts. Multiple entries may be delimited by the --host platform directory separator in use. -+host platform path separator in use. - @end table - - Setting this variable to @file{/} disables this security protection. diff --git a/gdb-autoload-20of28.patch b/gdb-autoload-20of28.patch deleted file mode 100644 index a0e944a..0000000 --- a/gdb-autoload-20of28.patch +++ /dev/null @@ -1,35 +0,0 @@ -http://sourceware.org/ml/gdb-cvs/2012-05/msg00059.html - -### src/gdb/doc/ChangeLog 2012/05/06 15:31:04 1.1309 -### src/gdb/doc/ChangeLog 2012/05/09 18:15:58 1.1310 -## -1,3 +1,8 @@ -+2012-05-09 Jan Kratochvil -+ -+ * gdb.texinfo (Auto-loading): Wrap too long lines in @smallexample. -+ Twice. -+ - 2012-05-06 Jan Kratochvil - - * gdb.texinfo (Auto-loading safe path): Make 'directories' ---- src/gdb/doc/gdb.texinfo 2012/05/06 15:31:04 1.955 -+++ src/gdb/doc/gdb.texinfo 2012/05/09 18:15:58 1.956 -@@ -21004,7 +21004,8 @@ - (gdb) show auto-load - gdb-scripts: Auto-loading of canned sequences of commands scripts is on. - libthread-db: Auto-loading of inferior specific libthread_db is on. --local-gdbinit: Auto-loading of .gdbinit script from current directory is on. -+local-gdbinit: Auto-loading of .gdbinit script from current directory -+ is on. - python-scripts: Auto-loading of Python scripts is on. - safe-path: List of directories from which it is safe to auto-load files - is /usr/local. -@@ -21022,7 +21023,8 @@ - Loaded Script - Yes /home/user/gdb/gdb-gdb.gdb - libthread-db: No auto-loaded libthread-db. --local-gdbinit: Local .gdbinit file "/home/user/gdb/.gdbinit" has been loaded. -+local-gdbinit: Local .gdbinit file "/home/user/gdb/.gdbinit" has been -+ loaded. - python-scripts: - Loaded Script - Yes /home/user/gdb/gdb-gdb.py diff --git a/gdb-autoload-21of28.patch b/gdb-autoload-21of28.patch deleted file mode 100644 index 3632e67..0000000 --- a/gdb-autoload-21of28.patch +++ /dev/null @@ -1,57 +0,0 @@ -http://sourceware.org/ml/gdb-cvs/2012-05/msg00079.html - -### src/gdb/ChangeLog 2012/05/10 20:17:46 1.14235 -### src/gdb/ChangeLog 2012/05/11 18:06:26 1.14236 -## -1,3 +1,10 @@ -+2012-05-11 Jan Kratochvil -+ -+ Make auto-load handle multiple components of DEBUG_FILE_DIRECTORY. -+ * auto-load.c (auto_load_objfile_script): Remove check for NULL -+ DEBUG_FILE_DIRECTORY. Handle multiple components of -+ DEBUG_FILE_DIRECTORY. -+ - 2012-05-10 Tom Tromey - - * dwarf2read.c (recursively_write_psymbols): New function. ---- src/gdb/auto-load.c 2012/05/06 15:31:02 1.6 -+++ src/gdb/auto-load.c 2012/05/11 18:06:28 1.7 -@@ -587,17 +587,29 @@ - input = fopen (filename, "r"); - debugfile = filename; - -- if (!input && debug_file_directory) -+ if (!input) - { -- /* Also try the same file in the separate debug info directory. */ -- debugfile = xmalloc (strlen (filename) -- + strlen (debug_file_directory) + 1); -- strcpy (debugfile, debug_file_directory); -- /* FILENAME is absolute, so we don't need a "/" here. */ -- strcat (debugfile, filename); -- -- make_cleanup (xfree, debugfile); -- input = fopen (debugfile, "r"); -+ char *debugdir; -+ VEC (char_ptr) *debugdir_vec; -+ int ix; -+ -+ debugdir_vec = dirnames_to_char_ptr_vec (debug_file_directory); -+ make_cleanup_free_char_ptr_vec (debugdir_vec); -+ -+ for (ix = 0; VEC_iterate (char_ptr, debugdir_vec, ix, debugdir); ++ix) -+ { -+ /* Also try the same file in the separate debug info directory. */ -+ debugfile = xmalloc (strlen (debugdir) + strlen (filename) + 1); -+ strcpy (debugfile, debugdir); -+ -+ /* FILENAME is absolute, so we don't need a "/" here. */ -+ strcat (debugfile, filename); -+ -+ make_cleanup (xfree, debugfile); -+ input = fopen (debugfile, "r"); -+ if (input != NULL) -+ break; -+ } - } - - if (!input && gdb_datadir) diff --git a/gdb-autoload-22of28.patch b/gdb-autoload-22of28.patch deleted file mode 100644 index 769b724..0000000 --- a/gdb-autoload-22of28.patch +++ /dev/null @@ -1,388 +0,0 @@ -http://sourceware.org/ml/gdb-cvs/2012-05/msg00080.html - -### src/gdb/ChangeLog 2012/05/11 18:06:26 1.14236 -### src/gdb/ChangeLog 2012/05/11 18:13:22 1.14237 -## -1,5 +1,29 @@ - 2012-05-11 Jan Kratochvil - -+ Provide $ddir substitution for --with-auto-load-safe-path. -+ * NEWS (--with-auto-load-safe-path, --without-auto-load-safe-path): New -+ entries. -+ * auto-load.c: Include observer.h. -+ (auto_load_safe_path_vec_update): Call substitute_path_component for -+ each component. New variable ddir_subst. -+ (auto_load_gdb_datadir_changed): New function. -+ (set_auto_load_safe_path): Rename DEFAULT_AUTO_LOAD_SAFE_PATH to -+ AUTO_LOAD_SAFE_PATH. New comment. -+ (_initialize_auto_load): Rename DEFAULT_AUTO_LOAD_SAFE_PATH to -+ AUTO_LOAD_SAFE_PATH. Install auto_load_gdb_datadir_changed. -+ * config.in: Regenerate. -+ * configure: Regenerate. -+ * configure.ac (--auto-load-safe-path): Rename -+ DEFAULT_AUTO_LOAD_SAFE_PATH to AUTO_LOAD_SAFE_PATH. Default to -+ GDB_DATADIR/auto-load. -+ * defs.h (substitute_path_component): New declaration. -+ * top.c: Include observer.h. -+ (set_gdb_datadir): New function. -+ (init_main): Install it for "set data-directory". -+ * utils.c (substitute_path_component): New function. -+ -+2012-05-11 Jan Kratochvil -+ - Make auto-load handle multiple components of DEBUG_FILE_DIRECTORY. - * auto-load.c (auto_load_objfile_script): Remove check for NULL - DEBUG_FILE_DIRECTORY. Handle multiple components of -Index: gdb-7.4.50.20120120/gdb/NEWS -=================================================================== ---- gdb-7.4.50.20120120.orig/gdb/NEWS 2012-05-14 14:17:49.000000000 +0200 -+++ gdb-7.4.50.20120120/gdb/NEWS 2012-05-14 14:18:01.915041258 +0200 -@@ -307,6 +307,17 @@ show trace-stop-notes - instance as an explanation, if you are stopping a trace run that was - started by someone else. - -+* New configure options -+ -+--with-auto-load-safe-path -+ Configure default value for the 'set auto-load safe-path' setting -+ above. It defaults to '$ddir/auto-load', $ddir representing GDB's -+ data directory (available via show data-directory). -+ -+--without-auto-load-safe-path -+ Set 'set auto-load safe-path' to '/', effectively disabling this -+ security feature. -+ - * New remote packets - - QTEnable -Index: gdb-7.4.50.20120120/gdb/auto-load.c -=================================================================== ---- gdb-7.4.50.20120120.orig/gdb/auto-load.c 2012-05-14 14:17:49.000000000 +0200 -+++ gdb-7.4.50.20120120/gdb/auto-load.c 2012-05-14 14:18:01.915041258 +0200 -@@ -35,6 +35,7 @@ - #include "gdb_vecs.h" - #include "readline/tilde.h" - #include "completer.h" -+#include "observer.h" - - /* The suffix of per-objfile scripts to auto-load as non-Python command files. - E.g. When the program loads libfoo.so, look for libfoo-gdb.gdb. */ -@@ -141,10 +142,16 @@ auto_load_safe_path_vec_update (void) - for (ix = 0; ix < len; ix++) - { - char *dir = VEC_index (char_ptr, auto_load_safe_path_vec, ix); -- char *expanded = tilde_expand (dir); -- char *real_path = gdb_realpath (expanded); -+ char *ddir_subst, *expanded, *real_path; - -- /* Ensure the current entry is at least tilde_expand-ed. */ -+ ddir_subst = xstrdup (dir); -+ substitute_path_component (&ddir_subst, "$ddir", gdb_datadir); -+ expanded = tilde_expand (ddir_subst); -+ xfree (ddir_subst); -+ real_path = gdb_realpath (expanded); -+ -+ /* Ensure the current entry is at least a valid path (therefore -+ $ddir-expanded and tilde-expanded). */ - VEC_replace (char_ptr, auto_load_safe_path_vec, ix, expanded); - - if (debug_auto_load) -@@ -176,15 +183,24 @@ auto_load_safe_path_vec_update (void) - } - } - -+/* Variable gdb_datadir has been set. Update content depending on $ddir. */ -+ -+static void -+auto_load_gdb_datadir_changed (void) -+{ -+ auto_load_safe_path_vec_update (); -+} -+ - /* "set" command for the auto_load_safe_path configuration variable. */ - - static void - set_auto_load_safe_path (char *args, int from_tty, struct cmd_list_element *c) - { -+ /* Setting the variable to "" resets it to the compile time defaults. */ - if (auto_load_safe_path[0] == '\0') - { - xfree (auto_load_safe_path); -- auto_load_safe_path = xstrdup (DEFAULT_AUTO_LOAD_SAFE_PATH); -+ auto_load_safe_path = xstrdup (AUTO_LOAD_SAFE_PATH); - } - - auto_load_safe_path_vec_update (); -@@ -1040,7 +1056,7 @@ This options has security implications f - Usage: info auto-load local-gdbinit"), - auto_load_info_cmdlist_get ()); - -- auto_load_safe_path = xstrdup (DEFAULT_AUTO_LOAD_SAFE_PATH); -+ auto_load_safe_path = xstrdup (AUTO_LOAD_SAFE_PATH); - auto_load_safe_path_vec_update (); - add_setshow_optional_filename_cmd ("safe-path", class_support, - &auto_load_safe_path, _("\ -@@ -1058,6 +1074,7 @@ This options has security implications f - show_auto_load_safe_path, - auto_load_set_cmdlist_get (), - auto_load_show_cmdlist_get ()); -+ observer_attach_gdb_datadir_changed (auto_load_gdb_datadir_changed); - - cmd = add_cmd ("add-auto-load-safe-path", class_support, - add_auto_load_safe_path, -Index: gdb-7.4.50.20120120/gdb/config.in -=================================================================== ---- gdb-7.4.50.20120120.orig/gdb/config.in 2012-05-14 14:17:49.000000000 +0200 -+++ gdb-7.4.50.20120120/gdb/config.in 2012-05-14 14:18:01.915041258 +0200 -@@ -7,6 +7,9 @@ - /* Define if building universal (internal helper macro) */ - #undef AC_APPLE_UNIVERSAL_BUILD - -+/* Directories safe to hold auto-loaded files. */ -+#undef AUTO_LOAD_SAFE_PATH -+ - /* Directory of programs. */ - #undef BINDIR - -@@ -43,9 +46,6 @@ - moved. */ - #undef DEBUGDIR_RELOCATABLE - --/* Directories safe to hold auto-loaded files. */ --#undef DEFAULT_AUTO_LOAD_SAFE_PATH -- - /* Define to BFD's default architecture. */ - #undef DEFAULT_BFD_ARCH - -Index: gdb-7.4.50.20120120/gdb/configure -=================================================================== ---- gdb-7.4.50.20120120.orig/gdb/configure 2012-05-14 14:17:49.000000000 +0200 -+++ gdb-7.4.50.20120120/gdb/configure 2012-05-14 14:18:01.918041252 +0200 -@@ -1668,7 +1668,8 @@ Optional Packages: - --with-rpm query rpm database for missing debuginfos (yes/no, - def. auto=librpm.so) - --with-auto-load-safe-path=PATH -- directories safe to hold auto-loaded files -+ directories safe to hold auto-loaded files, use -+ $ddir for --with-gdb-datadir path [$ddir/auto-load] - --without-auto-load-safe-path - do not restrict auto-loaded files locations - --with-libunwind use libunwind frame unwinding support -@@ -8488,20 +8489,21 @@ $as_echo_n "checking for default auto-lo - # Check whether --with-auto-load-safe-path was given. - if test "${with_auto_load_safe_path+set}" = set; then : - withval=$with_auto_load_safe_path; if test "$with_auto_load_safe_path" = "no"; then -- with_auto_load_safe_path="/" -- fi -+ with_auto_load_safe_path="/" -+ fi - else -- with_auto_load_safe_path="$prefix" -+ with_auto_load_safe_path='$ddir/auto-load' - fi - -+escape_dir=`echo $with_auto_load_safe_path | sed 's/[$]ddir\>/\\\\\\\\\\\\&/g'` - - test "x$prefix" = xNONE && prefix="$ac_default_prefix" - test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' -- ac_define_dir=`eval echo $with_auto_load_safe_path` -+ ac_define_dir=`eval echo $escape_dir` - ac_define_dir=`eval echo $ac_define_dir` - - cat >>confdefs.h <<_ACEOF --#define DEFAULT_AUTO_LOAD_SAFE_PATH "$ac_define_dir" -+#define AUTO_LOAD_SAFE_PATH "$ac_define_dir" - _ACEOF - - -Index: gdb-7.4.50.20120120/gdb/configure.ac -=================================================================== ---- gdb-7.4.50.20120120.orig/gdb/configure.ac 2012-05-14 14:17:49.000000000 +0200 -+++ gdb-7.4.50.20120120/gdb/configure.ac 2012-05-14 14:18:01.919041250 +0200 -@@ -341,13 +341,16 @@ fi - - AC_MSG_CHECKING([for default auto-load safe-path]) - AC_ARG_WITH(auto-load-safe-path, --AS_HELP_STRING([--with-auto-load-safe-path=PATH], [directories safe to hold auto-loaded files]) --AS_HELP_STRING([--without-auto-load-safe-path], [do not restrict auto-loaded files locations]), --[if test "$with_auto_load_safe_path" = "no"; then -- with_auto_load_safe_path="/" -- fi], --[with_auto_load_safe_path="$prefix"]) --AC_DEFINE_DIR(DEFAULT_AUTO_LOAD_SAFE_PATH, with_auto_load_safe_path, -+AS_HELP_STRING([--with-auto-load-safe-path=PATH], -+ [directories safe to hold auto-loaded files, use $ddir for --with-gdb-datadir path @<:@$ddir/auto-load@:>@]) -+AS_HELP_STRING([--without-auto-load-safe-path], -+ [do not restrict auto-loaded files locations]), -+ [if test "$with_auto_load_safe_path" = "no"; then -+ with_auto_load_safe_path="/" -+ fi], -+[with_auto_load_safe_path='$ddir/auto-load']) -+escape_dir=`echo $with_auto_load_safe_path | sed 's/[[$]]ddir\>/\\\\\\\\\\\\&/g'` -+AC_DEFINE_DIR(AUTO_LOAD_SAFE_PATH, escape_dir, - [Directories safe to hold auto-loaded files.]) - AC_MSG_RESULT([$with_auto_load_safe_path]) - -Index: gdb-7.4.50.20120120/gdb/defs.h -=================================================================== ---- gdb-7.4.50.20120120.orig/gdb/defs.h 2012-05-14 14:17:48.000000000 +0200 -+++ gdb-7.4.50.20120120/gdb/defs.h 2012-05-14 14:18:01.919041250 +0200 -@@ -442,6 +442,9 @@ extern struct cleanup *make_bpstat_clear - - extern int producer_is_gcc_ge_4 (const char *producer); - -+extern void substitute_path_component (char **stringp, const char *from, -+ const char *to); -+ - #ifdef HAVE_WAITPID - extern pid_t wait_to_die_with_timeout (pid_t pid, int *status, int timeout); - #endif -Index: gdb-7.4.50.20120120/gdb/top.c -=================================================================== ---- gdb-7.4.50.20120120.orig/gdb/top.c 2012-05-14 14:17:48.000000000 +0200 -+++ gdb-7.4.50.20120120/gdb/top.c 2012-05-14 14:18:01.919041250 +0200 -@@ -47,6 +47,7 @@ - #include "gdbthread.h" - #include "python/python.h" - #include "interps.h" -+#include "observer.h" - - /* readline include files. */ - #include "readline/readline.h" -@@ -1561,6 +1562,15 @@ show_exec_done_display_p (struct ui_file - "asynchronous execution commands is %s.\n"), - value); - } -+ -+/* "set" command for the gdb_datadir configuration variable. */ -+ -+static void -+set_gdb_datadir (char *args, int from_tty, struct cmd_list_element *c) -+{ -+ observer_notify_gdb_datadir_changed (); -+} -+ - static void - init_main (void) - { -@@ -1668,7 +1678,7 @@ Use \"on\" to enable the notification, a - _("Show GDB's data directory."), - _("\ - When set, GDB uses the specified path to search for data files."), -- NULL, NULL, -+ set_gdb_datadir, NULL, - &setlist, - &showlist); - } -Index: gdb-7.4.50.20120120/gdb/utils.c -=================================================================== ---- gdb-7.4.50.20120120.orig/gdb/utils.c 2012-05-14 14:17:49.000000000 +0200 -+++ gdb-7.4.50.20120120/gdb/utils.c 2012-05-14 14:18:01.920041248 +0200 -@@ -3925,6 +3925,48 @@ dirnames_to_char_ptr_vec (const char *di - return retval; - } - -+/* Substitute all occurences of string FROM by string TO in *STRINGP. *STRINGP -+ must come from xrealloc-compatible allocator and it may be updated. FROM -+ needs to be delimited by IS_DIR_SEPARATOR (or be located at the start or -+ end of *STRINGP. */ -+ -+void -+substitute_path_component (char **stringp, const char *from, const char *to) -+{ -+ char *string = *stringp, *s; -+ const size_t from_len = strlen (from); -+ const size_t to_len = strlen (to); -+ -+ for (s = string;;) -+ { -+ s = strstr (s, from); -+ if (s == NULL) -+ break; -+ -+ if ((s == string || IS_DIR_SEPARATOR (s[-1])) -+ && (s[from_len] == '\0' || IS_DIR_SEPARATOR (s[from_len]))) -+ { -+ char *string_new; -+ -+ string_new = xrealloc (string, (strlen (string) + to_len + 1)); -+ -+ /* Relocate the current S pointer. */ -+ s = s - string + string_new; -+ string = string_new; -+ -+ /* Replace from by to. */ -+ memmove (&s[to_len], &s[from_len], strlen (&s[from_len]) + 1); -+ memcpy (s, to, to_len); -+ -+ s += to_len; -+ } -+ else -+ s++; -+ } -+ -+ *stringp = string; -+} -+ - #ifdef HAVE_WAITPID - - #ifdef SIGALRM -Index: gdb-7.4.50.20120120/gdb/doc/gdb.texinfo -=================================================================== ---- gdb-7.4.50.20120120.orig/gdb/doc/gdb.texinfo 2012-05-14 14:17:49.000000000 +0200 -+++ gdb-7.4.50.20120120/gdb/doc/gdb.texinfo 2012-05-14 14:18:01.925041238 +0200 -@@ -20803,7 +20803,7 @@ local-gdbinit: Auto-loading of .gdbinit - is on. - python-scripts: Auto-loading of Python scripts is on. - safe-path: List of directories from which it is safe to auto-load files -- is /usr/local. -+ is $ddir/auto-load. - @end smallexample - - @anchor{info auto-load} -@@ -21006,9 +21006,9 @@ get loaded: - $ ./gdb -q ./gdb - Reading symbols from /home/user/gdb/gdb...done. - warning: File "/home/user/gdb/gdb-gdb.gdb" auto-loading has been -- declined by your `auto-load safe-path' set to "/usr/local". -+ declined by your `auto-load safe-path' set to "$ddir/auto-load". - warning: File "/home/user/gdb/gdb-gdb.py" auto-loading has been -- declined by your `auto-load safe-path' set to "/usr/local". -+ declined by your `auto-load safe-path' set to "$ddir/auto-load". - @end smallexample - - The list of trusted directories is controlled by the following commands: -@@ -21040,7 +21040,18 @@ loading and execution of scripts. Multi - host platform path separator in use. - @end table - --Setting this variable to @file{/} disables this security protection. -+This variable defaults to @file{$ddir/auto-load}. The default @code{set -+auto-load safe-path} value can be also overriden by @value{GDBN} configuration -+option @option{--with-auto-load-safe-path}. -+ -+Any used string @file{$ddir} will get replaced by @var{data-directory} which is -+determined at @value{GDBN} startup (@pxref{Data Files}). @file{$ddir} must be -+be placed as a directory component --- either alone or delimited by @file{/} or -+@file{\} directory separators, depending on the host platform. -+ -+Setting this variable to @file{/} disables this security protection, -+corresponding @value{GDBN} configuration option is -+@option{--without-auto-load-safe-path}. - This variable is supposed to be set to the system directories writable by the - system superuser only. Users can add their source directories in init files in - their home directories (@pxref{Home Directory Init File}). See also deprecated -Index: gdb-7.4.50.20120120/gdb/doc/observer.texi -=================================================================== ---- gdb-7.4.50.20120120.orig/gdb/doc/observer.texi 2012-05-14 14:17:47.000000000 +0200 -+++ gdb-7.4.50.20120120/gdb/doc/observer.texi 2012-05-14 14:18:01.926041236 +0200 -@@ -231,6 +231,10 @@ the current top-level prompt. - @c collector pass. Currently only @code{type_mark_used} marker is supported. - @c @end deftypefun - -+@deftypefun void gdb_datadir_changed (void) -+Variable gdb_datadir has been set. The value may not necessarily change. -+@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-autoload-23of28.patch b/gdb-autoload-23of28.patch deleted file mode 100644 index bb811f6..0000000 --- a/gdb-autoload-23of28.patch +++ /dev/null @@ -1,424 +0,0 @@ -http://sourceware.org/ml/gdb-cvs/2012-05/msg00081.html - -### src/gdb/ChangeLog 2012/05/11 18:13:22 1.14237 -### src/gdb/ChangeLog 2012/05/11 18:20:25 1.14238 -## -1,5 +1,23 @@ - 2012-05-11 Jan Kratochvil - -+ Implement multi-component --with-auto-load-dir. -+ * NEWS (set auto-load scripts-directory, --with-auto-load-dir): New -+ entries. -+ (--with-auto-load-safe-path): Update the default value description. -+ * auto-load.c (auto_load_dir, set_auto_load_dir, show_auto_load_dir): -+ New. -+ (auto_load_objfile_script): Add DEBUG_AUTO_LOAD output. Remove -+ GDB_DATADIR NULL check. Replace GDB_DATADIR/auto-load by -+ AUTO_LOAD_DIR. Support $ddir and multiple components in it. -+ (_initialize_auto_load): Initialize also auto_load_dir. Install new -+ "set auto-load scripts-directory". -+ * config.in: Regenerate. -+ * configure: Regenerate. -+ * configure.ac (--with-auto-load-dir): New configure option. -+ (--auto-load-safe-path): Change the default to --with-auto-load-dir. -+ -+2012-05-11 Jan Kratochvil -+ - Provide $ddir substitution for --with-auto-load-safe-path. - * NEWS (--with-auto-load-safe-path, --without-auto-load-safe-path): New - entries. -Index: gdb-7.4.50.20120120/gdb/NEWS -=================================================================== ---- gdb-7.4.50.20120120.orig/gdb/NEWS 2012-05-14 14:18:01.000000000 +0200 -+++ gdb-7.4.50.20120120/gdb/NEWS 2012-05-14 14:18:29.712985871 +0200 -@@ -67,6 +67,12 @@ set auto-load libthread-db on|off - show auto-load libthread-db - Control auto-loading of inferior specific thread debugging shared library. - -+set auto-load scripts-directory [:...] -+ Set a list of directories from which to load auto-loaded scripts. -+ Automatically loaded Python scripts and GDB scripts are located in one -+ of the directories listed by this option. -+ The delimiter (':' above) may differ according to the host platform. -+ - set auto-load safe-path [:...] - show auto-load safe-path - Set a list of directories from which it is safe to auto-load files. -@@ -309,10 +315,14 @@ show trace-stop-notes - - * New configure options - -+--with-auto-load-dir -+ Configure default value for the 'set auto-load scripts-directory' -+ setting above. It defaults to '$ddir/auto-load', $ddir representing -+ GDB's data directory (available via show data-directory). -+ - --with-auto-load-safe-path - Configure default value for the 'set auto-load safe-path' setting -- above. It defaults to '$ddir/auto-load', $ddir representing GDB's -- data directory (available via show data-directory). -+ above. It defaults to the --with-auto-load-dir setting. - - --without-auto-load-safe-path - Set 'set auto-load safe-path' to '/', effectively disabling this -Index: gdb-7.4.50.20120120/gdb/auto-load.c -=================================================================== ---- gdb-7.4.50.20120120.orig/gdb/auto-load.c 2012-05-14 14:18:01.000000000 +0200 -+++ gdb-7.4.50.20120120/gdb/auto-load.c 2012-05-14 14:18:29.713985869 +0200 -@@ -108,6 +108,35 @@ show_auto_load_local_gdbinit (struct ui_ - value); - } - -+/* Directory list from which to load auto-loaded scripts. It is not checked -+ for absolute paths but they are strongly recommended. It is initialized by -+ _initialize_auto_load. */ -+static char *auto_load_dir; -+ -+/* "set" command for the auto_load_dir configuration variable. */ -+ -+static void -+set_auto_load_dir (char *args, int from_tty, struct cmd_list_element *c) -+{ -+ /* Setting the variable to "" resets it to the compile time defaults. */ -+ if (auto_load_dir[0] == '\0') -+ { -+ xfree (auto_load_dir); -+ auto_load_dir = xstrdup (AUTO_LOAD_DIR); -+ } -+} -+ -+/* "show" command for the auto_load_dir configuration variable. */ -+ -+static void -+show_auto_load_dir (struct ui_file *file, int from_tty, -+ struct cmd_list_element *c, const char *value) -+{ -+ fprintf_filtered (file, _("List of directories from which to load " -+ "auto-loaded scripts is %s.\n"), -+ value); -+} -+ - /* Directory list safe to hold auto-loaded files. It is not checked for - absolute paths but they are strongly recommended. It is initialized by - _initialize_auto_load. */ -@@ -602,6 +631,9 @@ auto_load_objfile_script (struct objfile - - input = fopen (filename, "r"); - debugfile = filename; -+ if (debug_auto_load) -+ fprintf_unfiltered (gdb_stdlog, _("auto-load: Attempted file \"%s\" %s.\n"), -+ debugfile, input ? _("exists") : _("does not exist")); - - if (!input) - { -@@ -612,6 +644,12 @@ auto_load_objfile_script (struct objfile - debugdir_vec = dirnames_to_char_ptr_vec (debug_file_directory); - make_cleanup_free_char_ptr_vec (debugdir_vec); - -+ if (debug_auto_load) -+ fprintf_unfiltered (gdb_stdlog, -+ _("auto-load: Searching 'set debug-file-directory' " -+ "path \"%s\".\n"), -+ debug_file_directory); -+ - for (ix = 0; VEC_iterate (char_ptr, debugdir_vec, ix, debugdir); ++ix) - { - /* Also try the same file in the separate debug info directory. */ -@@ -623,24 +661,53 @@ auto_load_objfile_script (struct objfile - - make_cleanup (xfree, debugfile); - input = fopen (debugfile, "r"); -+ if (debug_auto_load) -+ fprintf_unfiltered (gdb_stdlog, _("auto-load: Attempted file " -+ "\"%s\" %s.\n"), -+ debugfile, -+ input ? _("exists") : _("does not exist")); - if (input != NULL) - break; - } - } - -- if (!input && gdb_datadir) -+ if (!input) - { -+ VEC (char_ptr) *vec; -+ int ix; -+ char *dir; -+ - /* Also try the same file in a subdirectory of gdb's data - directory. */ -- debugfile = xmalloc (strlen (gdb_datadir) + strlen (filename) -- + strlen ("/auto-load") + 1); -- strcpy (debugfile, gdb_datadir); -- strcat (debugfile, "/auto-load"); -- /* FILENAME is absolute, so we don't need a "/" here. */ -- strcat (debugfile, filename); - -- make_cleanup (xfree, debugfile); -- input = fopen (debugfile, "r"); -+ vec = dirnames_to_char_ptr_vec (auto_load_dir); -+ make_cleanup_free_char_ptr_vec (vec); -+ -+ if (debug_auto_load) -+ fprintf_unfiltered (gdb_stdlog, _("auto-load: Searching 'set auto-load " -+ "scripts-directory' path \"%s\".\n"), -+ auto_load_dir); -+ -+ for (ix = 0; VEC_iterate (char_ptr, vec, ix, dir); ++ix) -+ { -+ debugfile = xstrdup (dir); -+ substitute_path_component (&debugfile, "$ddir", gdb_datadir); -+ debugfile = xrealloc (debugfile, (strlen (debugfile) -+ + strlen (filename) + 1)); -+ -+ /* FILENAME is absolute, so we don't need a "/" here. */ -+ strcat (debugfile, filename); -+ -+ make_cleanup (xfree, debugfile); -+ input = fopen (debugfile, "r"); -+ if (debug_auto_load) -+ fprintf_unfiltered (gdb_stdlog, _("auto-load: Attempted file " -+ "\"%s\" %s.\n"), -+ debugfile, -+ input ? _("exists") : _("does not exist")); -+ if (input != NULL) -+ break; -+ } - } - - if (input) -@@ -1056,6 +1123,19 @@ This options has security implications f - Usage: info auto-load local-gdbinit"), - auto_load_info_cmdlist_get ()); - -+ auto_load_dir = xstrdup (AUTO_LOAD_DIR); -+ add_setshow_optional_filename_cmd ("scripts-directory", class_support, -+ &auto_load_dir, _("\ -+Set the list of directories from which to load auto-loaded scripts."), _("\ -+Show the list of directories from which to load auto-loaded scripts."), _("\ -+Automatically loaded Python scripts and GDB scripts are located in one of the\n\ -+directories listed by this option. This option is ignored for the kinds of\n\ -+scripts having 'set auto-load ... off'. Directories listed here need to be\n\ -+present also in the 'set auto-load safe-path' option."), -+ set_auto_load_dir, show_auto_load_dir, -+ auto_load_set_cmdlist_get (), -+ auto_load_show_cmdlist_get ()); -+ - auto_load_safe_path = xstrdup (AUTO_LOAD_SAFE_PATH); - auto_load_safe_path_vec_update (); - add_setshow_optional_filename_cmd ("safe-path", class_support, -Index: gdb-7.4.50.20120120/gdb/config.in -=================================================================== ---- gdb-7.4.50.20120120.orig/gdb/config.in 2012-05-14 14:18:01.000000000 +0200 -+++ gdb-7.4.50.20120120/gdb/config.in 2012-05-14 14:18:29.713985869 +0200 -@@ -7,6 +7,9 @@ - /* Define if building universal (internal helper macro) */ - #undef AC_APPLE_UNIVERSAL_BUILD - -+/* Directories from which to load auto-loaded scripts. */ -+#undef AUTO_LOAD_DIR -+ - /* Directories safe to hold auto-loaded files. */ - #undef AUTO_LOAD_SAFE_PATH - -Index: gdb-7.4.50.20120120/gdb/configure -=================================================================== ---- gdb-7.4.50.20120120.orig/gdb/configure 2012-05-14 14:18:01.000000000 +0200 -+++ gdb-7.4.50.20120120/gdb/configure 2012-05-14 14:21:13.068849103 +0200 -@@ -955,6 +955,7 @@ with_separate_debug_dir - with_gdb_datadir - with_relocated_sources - with_rpm -+with_auto_load_dir - with_auto_load_safe_path - enable_targets - enable_64_bit_bfd -@@ -1667,9 +1668,13 @@ Optional Packages: - automatically relocate this path for source files - --with-rpm query rpm database for missing debuginfos (yes/no, - def. auto=librpm.so) -+ --with-auto-load-dir=PATH -+ directories from which to load auto-loaded scripts, -+ use '$ddir' for -data-directory [$ddir/auto-load] - --with-auto-load-safe-path=PATH - directories safe to hold auto-loaded files, use -- $ddir for --with-gdb-datadir path [$ddir/auto-load] -+ $ddir for --with-gdb-datadir path -+ [--with-auto-load-dir] - --without-auto-load-safe-path - do not restrict auto-loaded files locations - --with-libunwind use libunwind frame unwinding support -@@ -8483,6 +8488,31 @@ $as_echo "$as_me: WARNING: $RPM_PKG_ERRO - fi - fi - -+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for default auto-load directory" >&5 -+$as_echo_n "checking for default auto-load directory... " >&6; } -+ -+# Check whether --with-auto-load-dir was given. -+if test "${with_auto_load_dir+set}" = set; then : -+ withval=$with_auto_load_dir; -+else -+ with_auto_load_dir='$ddir/auto-load' -+fi -+ -+escape_dir=`echo $with_auto_load_dir | sed 's/[$]ddir\>/\\\\\\\\\\\\&/g'` -+ -+ test "x$prefix" = xNONE && prefix="$ac_default_prefix" -+ test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' -+ ac_define_dir=`eval echo $escape_dir` -+ ac_define_dir=`eval echo $ac_define_dir` -+ -+cat >>confdefs.h <<_ACEOF -+#define AUTO_LOAD_DIR "$ac_define_dir" -+_ACEOF -+ -+ -+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $with_auto_load_dir" >&5 -+$as_echo "$with_auto_load_dir" >&6; } -+ - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for default auto-load safe-path" >&5 - $as_echo_n "checking for default auto-load safe-path... " >&6; } - -@@ -8492,7 +8522,7 @@ if test "${with_auto_load_safe_path+set} - with_auto_load_safe_path="/" - fi - else -- with_auto_load_safe_path='$ddir/auto-load' -+ with_auto_load_safe_path="$with_auto_load_dir" - fi - - escape_dir=`echo $with_auto_load_safe_path | sed 's/[$]ddir\>/\\\\\\\\\\\\&/g'` -Index: gdb-7.4.50.20120120/gdb/configure.ac -=================================================================== ---- gdb-7.4.50.20120120.orig/gdb/configure.ac 2012-05-14 14:18:01.000000000 +0200 -+++ gdb-7.4.50.20120120/gdb/configure.ac 2012-05-14 14:21:01.597871716 +0200 -@@ -339,16 +339,26 @@ extern rpmdbMatchIterator rpmtsInitItera - fi - fi - -+AC_MSG_CHECKING([for default auto-load directory]) -+AC_ARG_WITH(auto-load-dir, -+AS_HELP_STRING([--with-auto-load-dir=PATH], -+ [directories from which to load auto-loaded scripts, use '$ddir' for -data-directory @<:@$ddir/auto-load@:>@]),, -+ [with_auto_load_dir='$ddir/auto-load']) -+escape_dir=`echo $with_auto_load_dir | sed 's/[[$]]ddir\>/\\\\\\\\\\\\&/g'` -+AC_DEFINE_DIR(AUTO_LOAD_DIR, escape_dir, -+ [Directories from which to load auto-loaded scripts.]) -+AC_MSG_RESULT([$with_auto_load_dir]) -+ - AC_MSG_CHECKING([for default auto-load safe-path]) - AC_ARG_WITH(auto-load-safe-path, - AS_HELP_STRING([--with-auto-load-safe-path=PATH], -- [directories safe to hold auto-loaded files, use $ddir for --with-gdb-datadir path @<:@$ddir/auto-load@:>@]) -+ [directories safe to hold auto-loaded files, use $ddir for --with-gdb-datadir path @<:@--with-auto-load-dir@:>@]) - AS_HELP_STRING([--without-auto-load-safe-path], - [do not restrict auto-loaded files locations]), - [if test "$with_auto_load_safe_path" = "no"; then - with_auto_load_safe_path="/" - fi], --[with_auto_load_safe_path='$ddir/auto-load']) -+[with_auto_load_safe_path="$with_auto_load_dir"]) - escape_dir=`echo $with_auto_load_safe_path | sed 's/[[$]]ddir\>/\\\\\\\\\\\\&/g'` - AC_DEFINE_DIR(AUTO_LOAD_SAFE_PATH, escape_dir, - [Directories safe to hold auto-loaded files.]) -Index: gdb-7.4.50.20120120/gdb/doc/gdb.texinfo -=================================================================== ---- gdb-7.4.50.20120120.orig/gdb/doc/gdb.texinfo 2012-05-14 14:18:01.000000000 +0200 -+++ gdb-7.4.50.20120120/gdb/doc/gdb.texinfo 2012-05-14 14:20:13.653966212 +0200 -@@ -20804,6 +20804,8 @@ local-gdbinit: Auto-loading of .gdbinit - python-scripts: Auto-loading of Python scripts is on. - safe-path: List of directories from which it is safe to auto-load files - is $ddir/auto-load. -+scripts-directory: List of directories from which to load auto-loaded scripts -+ is $ddir/auto-load. - @end smallexample - - @anchor{info auto-load} -@@ -20864,6 +20866,10 @@ These are @value{GDBN} control commands - @tab Show setting of @value{GDBN} Python scripts. - @item @xref{info auto-load python-scripts}. - @tab Show state of @value{GDBN} Python scripts. -+@item @xref{set auto-load scripts-directory}. -+@tab Control for @value{GDBN} auto-loaded scripts location. -+@item @xref{show auto-load scripts-directory}. -+@tab Show @value{GDBN} auto-loaded scripts location. - @item @xref{set auto-load local-gdbinit}. - @tab Control for init file in the current directory. - @item @xref{show auto-load local-gdbinit}. -@@ -21040,15 +21046,13 @@ loading and execution of scripts. Multi - host platform path separator in use. - @end table - --This variable defaults to @file{$ddir/auto-load}. The default @code{set -+This variable defaults to what @code{--with-auto-load-dir} has been configured -+to (@pxref{with-auto-load-dir}). @file{$ddir} substituation applies the same -+as for @xref{set auto-load scripts-directory}. -+The default @code{set - auto-load safe-path} value can be also overriden by @value{GDBN} configuration - option @option{--with-auto-load-safe-path}. - --Any used string @file{$ddir} will get replaced by @var{data-directory} which is --determined at @value{GDBN} startup (@pxref{Data Files}). @file{$ddir} must be --be placed as a directory component --- either alone or delimited by @file{/} or --@file{\} directory separators, depending on the host platform. -- - Setting this variable to @file{/} disables this security protection, - corresponding @value{GDBN} configuration option is - @option{--without-auto-load-safe-path}. -@@ -25135,7 +25139,7 @@ registering objfile-specific pretty-prin - @cindex @file{@var{objfile}-gdb.py} - - When a new object file is read, @value{GDBN} looks for --a file named @file{@var{objfile}-gdb.py}, -+a file named @file{@var{objfile}-gdb.py} (we call it @var{script-name} below), - where @var{objfile} is the object file's real name, formed by ensuring - that the file name is absolute, following all symlinks, and resolving - @code{.} and @code{..} components. If this file exists and is -@@ -25143,14 +25147,42 @@ readable, @value{GDBN} will evaluate it - - If this file does not exist, and if the parameter - @code{debug-file-directory} is set (@pxref{Separate Debug Files}), --then @value{GDBN} will look for @var{real-name} in all of the -+then @value{GDBN} will look for @var{script-name} in all of the - directories mentioned in the value of @code{debug-file-directory}. - - Finally, if this file does not exist, then @value{GDBN} will look for --a file named @file{@var{data-directory}/python/auto-load/@var{real-name}}, where --@var{data-directory} is @value{GDBN}'s data directory (available via --@code{show data-directory}, @pxref{Data Files}), and @var{real-name} --is the object file's real name, as described above. -+@var{script-name} file in all of the directories specified by: -+ -+@table @code -+@anchor{set auto-load scripts-directory} -+@kindex set auto-load scripts-directory -+@item set auto-load scripts-directory @r{[}@var{directories}@r{]} -+Control @value{GDBN} auto-loaded scripts location. Multiple directory entries -+may be delimited by the host platform path separator in use -+(@samp{:} on Unix, @samp{;} on MS-Windows and MS-DOS). -+ -+Each entry here needs to be covered also by the security setting -+@code{set auto-load safe-path} (@pxref{set auto-load safe-path}). -+ -+@anchor{with-auto-load-dir} -+This variable defaults to @file{$ddir/auto-load}. The default @code{set -+auto-load safe-path} value can be also overriden by @value{GDBN} configuration -+option @option{--with-auto-load-dir}. -+ -+Any used string @file{$ddir} will get replaced by @var{data-directory} which is -+determined at @value{GDBN} startup (@pxref{Data Files}). @file{$ddir} must be -+be placed as a directory component --- either alone or delimited by @file{/} or -+@file{\} directory separators, depending on the host platform. -+ -+The list of directories uses path separator (@samp{:} on GNU and Unix -+systems, @samp{;} on MS-Windows and MS-DOS) to separate directories, similarly -+to the @env{PATH} environment variable. -+ -+@anchor{show auto-load scripts-directory} -+@kindex show auto-load scripts-directory -+@item show auto-load scripts-directory -+Show @value{GDBN} auto-loaded scripts location. -+@end table - - @value{GDBN} does not track which files it has already auto-loaded this way. - @value{GDBN} will load the associated script every time the corresponding diff --git a/gdb-autoload-24of28.patch b/gdb-autoload-24of28.patch deleted file mode 100644 index 35d601e..0000000 --- a/gdb-autoload-24of28.patch +++ /dev/null @@ -1,82 +0,0 @@ -http://sourceware.org/ml/gdb-cvs/2012-05/msg00082.html - -### src/gdb/doc/ChangeLog 2012/05/11 18:20:26 1.1313 -### src/gdb/doc/ChangeLog 2012/05/11 18:23:11 1.1314 -## -1,5 +1,12 @@ - 2012-05-11 Jan Kratochvil - -+ * gdb.texinfo (Auto-loading, Init File in the Current Directory) -+ (libthread_db.so.1 file, objfile-gdb.gdb file, objfile-gdb.py file) -+ (dotdebug_gdb_scripts section): Add reference -+ to 'Auto-loading safe path'. -+ -+2012-05-11 Jan Kratochvil -+ - Implement multi-component --with-auto-load-dir. - * gdb.texinfo (Auto-loading): New references - for 'set auto-load scripts-directory' ---- src/gdb/doc/gdb.texinfo 2012/05/11 18:20:26 1.959 -+++ src/gdb/doc/gdb.texinfo 2012/05/11 18:23:11 1.960 -@@ -20973,6 +20973,10 @@ - results or introduce security risks (e.g., if the file comes from untrusted - sources). - -+Note that loading of these associated files (including the local @file{.gdbinit} -+file) requires accordingly configured @code{auto-load safe-path} -+(@pxref{Auto-loading safe path}). -+ - For these reasons, @value{GDBN} includes commands and options to let you - control when to auto-load files and which files should be auto-loaded. - -@@ -21112,6 +21116,9 @@ - from init file (if any) in the current working directory, - see @ref{Init File in the Current Directory during Startup}. - -+Note that loading of this local @file{.gdbinit} file also requires accordingly -+configured @code{auto-load safe-path} (@pxref{Auto-loading safe path}). -+ - @table @code - @anchor{set auto-load local-gdbinit} - @kindex set auto-load local-gdbinit -@@ -21148,6 +21155,9 @@ - auto-load libthread-db} is enabled before trying to open such thread debugging - library. - -+Note that loading of this debugging library also requires accordingly configured -+@code{auto-load safe-path} (@pxref{Auto-loading safe path}). -+ - @table @code - @anchor{set auto-load libthread-db} - @kindex set auto-load libthread-db -@@ -21175,6 +21185,9 @@ - canned sequences of commands (@pxref{Sequences}), as long as @samp{set - auto-load gdb-scripts} is set to @samp{on}. - -+Note that loading of this script file also requires accordingly configured -+@code{auto-load safe-path} (@pxref{Auto-loading safe path}). -+ - For more background refer to the similar Python scripts auto-loading - description (@pxref{objfile-gdb.py file}). - -@@ -25465,7 +25478,10 @@ - directories mentioned in the value of @code{debug-file-directory}. - - Finally, if this file does not exist, then @value{GDBN} will look for --@var{script-name} file in all of the directories specified by: -+@var{script-name} file in all of the directories as specified below. -+ -+Note that loading of this script file also requires accordingly configured -+@code{auto-load safe-path} (@pxref{Auto-loading safe path}). - - @table @code - @anchor{set auto-load scripts-directory} -@@ -25542,6 +25558,9 @@ - - The script name may include directories if desired. - -+Note that loading of this script file also requires accordingly configured -+@code{auto-load safe-path} (@pxref{Auto-loading safe path}). -+ - If the macro is put in a header, any application or library - using this header will get a reference to the specified script. - diff --git a/gdb-autoload-25of28.patch b/gdb-autoload-25of28.patch deleted file mode 100644 index ac5939c..0000000 --- a/gdb-autoload-25of28.patch +++ /dev/null @@ -1,64 +0,0 @@ -http://sourceware.org/ml/gdb-cvs/2012-05/msg00091.html - -### src/gdb/doc/ChangeLog 2012/05/11 22:24:22 1.1315 -### src/gdb/doc/ChangeLog 2012/05/12 14:20:30 1.1316 -## -1,3 +1,9 @@ -+2012-05-12 Jan Kratochvil -+ Eli Zaretskii -+ -+ * gdb.texinfo (Separate Debug Files): Use plural form for global -+ debugging information directory. -+ - 2012-05-11 Stan Shebs - Kwok Cheung Yeung - ---- src/gdb/doc/gdb.texinfo 2012/05/11 22:24:22 1.961 -+++ src/gdb/doc/gdb.texinfo 2012/05/12 14:20:31 1.962 -@@ -16287,7 +16287,7 @@ - @cindex debugging information in separate files - @cindex @file{.debug} subdirectories - @cindex debugging information directory, global --@cindex global debugging information directory -+@cindex global debugging information directories - @cindex build ID, and separate debugging files - @cindex @file{.build-id} directory - -@@ -16332,14 +16332,14 @@ - @item - For the ``debug link'' method, @value{GDBN} looks up the named file in - the directory of the executable file, then in a subdirectory of that --directory named @file{.debug}, and finally under the global debug --directory, in a subdirectory whose name is identical to the leading -+directory named @file{.debug}, and finally under each one of the global debug -+directories, in a subdirectory whose name is identical to the leading - directories of the executable's absolute file name. - - @item - For the ``build ID'' method, @value{GDBN} looks in the --@file{.build-id} subdirectory of the global debug directory for a file --named @file{@var{nn}/@var{nnnnnnnn}.debug}, where @var{nn} are the -+@file{.build-id} subdirectory of each one of the global debug directories for -+a file named @file{@var{nn}/@var{nnnnnnnn}.debug}, where @var{nn} are the - first 2 hex characters of the build ID bit string, and @var{nnnnnnnn} - are the rest of the bit string. (Real build ID strings are 32 or more - hex characters, not 10.) -@@ -16348,7 +16348,7 @@ - So, for example, suppose you ask @value{GDBN} to debug - @file{/usr/bin/ls}, which has a debug link that specifies the - file @file{ls.debug}, and a build ID whose value in hex is --@code{abcdef1234}. If the global debug directory is -+@code{abcdef1234}. If the list of the global debug directories includes - @file{/usr/lib/debug}, then @value{GDBN} will look for the following - debug information files, in the indicated order: - -@@ -16363,8 +16363,8 @@ - @file{/usr/lib/debug/usr/bin/ls.debug}. - @end itemize - --You can set the global debugging info directory's name, and view the --name @value{GDBN} is currently using. -+You can set the global debugging info directories, and view the -+list @value{GDBN} is currently using. - - @table @code - diff --git a/gdb-autoload-26of28.patch b/gdb-autoload-26of28.patch deleted file mode 100644 index d88c43d..0000000 --- a/gdb-autoload-26of28.patch +++ /dev/null @@ -1,42 +0,0 @@ -http://sourceware.org/ml/gdb-patches/2012-05/msg00449.html -Subject: [patch] Cosmetic fix 'show auto-load safe-path' for ":" [Re: [patch 1/2] Provide $ddir substitution for --with-auto-load-safe-path] - -On Fri, 11 May 2012 21:33:53 +0200, Jan Kratochvil wrote: -> On Fri, 11 May 2012 21:14:47 +0200, Pedro Alves wrote: -> > Looks like there is some special casing somewhere: -> -> True, I forgot and I agree. But it is only this "cosmetic" message, it has no -> functionality effect. I can fix this "any directory" message conditional. - -Regards, -Jan - - -gdb/ -2012-05-11 Jan Kratochvil - - * auto-load.c (show_auto_load_safe_path): Accept any combination of - DIRNAME_SEPARATOR and IS_DIR_SEPARATOR for wild-match. - -diff --git a/gdb/auto-load.c b/gdb/auto-load.c -index 5ee117f..462ee06 100644 ---- a/gdb/auto-load.c -+++ b/gdb/auto-load.c -@@ -241,7 +241,15 @@ static void - show_auto_load_safe_path (struct ui_file *file, int from_tty, - struct cmd_list_element *c, const char *value) - { -- if (strcmp (value, "/") == 0) -+ const char *cs; -+ -+ /* Check if user has entered either "/" or for example ":". -+ But while more complicate content like ":/foo" would still also -+ permit any location do not hide those. */ -+ -+ for (cs = value; *cs && (*cs == DIRNAME_SEPARATOR || IS_DIR_SEPARATOR (*cs)); -+ cs++); -+ if (*cs == 0) - fprintf_filtered (file, _("Auto-load files are safe to load from any " - "directory.\n")); - else - diff --git a/gdb-autoload-27of28.patch b/gdb-autoload-27of28.patch deleted file mode 100644 index 228d958..0000000 --- a/gdb-autoload-27of28.patch +++ /dev/null @@ -1,225 +0,0 @@ -http://sourceware.org/ml/gdb-patches/2012-05/msg00476.html -Subject: [patch 1/2] auto-load: Rename $ddir to $datadir - -Hi, - -when Doug suggested $ddir for data-directory, similar to $cdir, $pdir and -$sdir already in use, it made sense. - -But currently I need to introduce also a variable for debug-file-directory and -having both $ddir and $debugdir valid in the same string seems to be confusing. - -Therefore proposing to have $datadir and $debugdir instead in the next patch, -this patch is just a machanical rename $ddir -> $datadir. - -I do not think it needs backward compatibiluty as $ddir has not yet been in -any GDB release. - - -Thanks, -Jan - - -gdb/ -2012-05-12 Jan Kratochvil - - Rename $ddir to $datadir. - * NEWS (--with-auto-load-dir): Rename $ddir to $datadir. - * auto-load.c (auto_load_safe_path_vec_update) - (auto_load_gdb_datadir_changed, auto_load_objfile_script): Likewise. - * configure: Regenerate. - * configure.ac (--with-auto-load-dir, --with-auto-load-safe-path): - Likewise. Remove the 'use $ddir' help string. - -gdb/doc/ -2012-05-12 Jan Kratochvil - - Rename $ddir to $datadir. - * gdb.texinfo (Auto-loading, Auto-loading safe path) - (objfile-gdb.py file): Rename $ddir to $datadir. - -Index: gdb-7.4.50.20120120/gdb/NEWS -=================================================================== ---- gdb-7.4.50.20120120.orig/gdb/NEWS 2012-05-14 14:24:15.112490286 +0200 -+++ gdb-7.4.50.20120120/gdb/NEWS 2012-05-14 14:24:20.224480210 +0200 -@@ -317,8 +317,8 @@ show trace-stop-notes - - --with-auto-load-dir - Configure default value for the 'set auto-load scripts-directory' -- setting above. It defaults to '$ddir/auto-load', $ddir representing -- GDB's data directory (available via show data-directory). -+ setting above. It defaults to '$datadir/auto-load', $datadir -+ representing GDB's data directory (available via show data-directory). - - --with-auto-load-safe-path - Configure default value for the 'set auto-load safe-path' setting -Index: gdb-7.4.50.20120120/gdb/auto-load.c -=================================================================== ---- gdb-7.4.50.20120120.orig/gdb/auto-load.c 2012-05-14 14:24:15.112490286 +0200 -+++ gdb-7.4.50.20120120/gdb/auto-load.c 2012-05-14 14:24:20.224480210 +0200 -@@ -174,13 +174,13 @@ auto_load_safe_path_vec_update (void) - char *ddir_subst, *expanded, *real_path; - - ddir_subst = xstrdup (dir); -- substitute_path_component (&ddir_subst, "$ddir", gdb_datadir); -+ substitute_path_component (&ddir_subst, "$datadir", gdb_datadir); - expanded = tilde_expand (ddir_subst); - xfree (ddir_subst); - real_path = gdb_realpath (expanded); - - /* Ensure the current entry is at least a valid path (therefore -- $ddir-expanded and tilde-expanded). */ -+ $datadir-expanded and tilde-expanded). */ - VEC_replace (char_ptr, auto_load_safe_path_vec, ix, expanded); - - if (debug_auto_load) -@@ -212,7 +212,7 @@ auto_load_safe_path_vec_update (void) - } - } - --/* Variable gdb_datadir has been set. Update content depending on $ddir. */ -+/* Variable gdb_datadir has been set. Update content depending on $datadir. */ - - static void - auto_load_gdb_datadir_changed (void) -@@ -699,7 +699,7 @@ auto_load_objfile_script (struct objfile - for (ix = 0; VEC_iterate (char_ptr, vec, ix, dir); ++ix) - { - debugfile = xstrdup (dir); -- substitute_path_component (&debugfile, "$ddir", gdb_datadir); -+ substitute_path_component (&debugfile, "$datadir", gdb_datadir); - debugfile = xrealloc (debugfile, (strlen (debugfile) - + strlen (filename) + 1)); - -Index: gdb-7.4.50.20120120/gdb/configure -=================================================================== ---- gdb-7.4.50.20120120.orig/gdb/configure 2012-05-14 14:24:15.112490286 +0200 -+++ gdb-7.4.50.20120120/gdb/configure 2012-05-14 14:24:38.564444061 +0200 -@@ -1669,11 +1669,10 @@ Optional Packages: - --with-rpm query rpm database for missing debuginfos (yes/no, - def. auto=librpm.so) - --with-auto-load-dir=PATH -- directories from which to load auto-loaded scripts, -- use '$ddir' for -data-directory [$ddir/auto-load] -+ directories from which to load auto-loaded scripts -+ [$datadir/auto-load] - --with-auto-load-safe-path=PATH -- directories safe to hold auto-loaded files, use -- $ddir for --with-gdb-datadir path -+ directories safe to hold auto-loaded files - [--with-auto-load-dir] - --without-auto-load-safe-path - do not restrict auto-loaded files locations -@@ -8495,10 +8494,10 @@ $as_echo_n "checking for default auto-lo - if test "${with_auto_load_dir+set}" = set; then : - withval=$with_auto_load_dir; - else -- with_auto_load_dir='$ddir/auto-load' -+ with_auto_load_dir='$datadir/auto-load' - fi - --escape_dir=`echo $with_auto_load_dir | sed 's/[$]ddir\>/\\\\\\\\\\\\&/g'` -+escape_dir=`echo $with_auto_load_dir | sed 's/[$]datadir\>/\\\\\\\\\\\\&/g'` - - test "x$prefix" = xNONE && prefix="$ac_default_prefix" - test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' -@@ -8525,7 +8524,7 @@ else - with_auto_load_safe_path="$with_auto_load_dir" - fi - --escape_dir=`echo $with_auto_load_safe_path | sed 's/[$]ddir\>/\\\\\\\\\\\\&/g'` -+escape_dir=`echo $with_auto_load_safe_path | sed 's/[$]datadir\>/\\\\\\\\\\\\&/g'` - - test "x$prefix" = xNONE && prefix="$ac_default_prefix" - test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' -Index: gdb-7.4.50.20120120/gdb/configure.ac -=================================================================== ---- gdb-7.4.50.20120120.orig/gdb/configure.ac 2012-05-14 14:24:15.112490286 +0200 -+++ gdb-7.4.50.20120120/gdb/configure.ac 2012-05-14 14:24:20.228480202 +0200 -@@ -342,9 +342,9 @@ fi - AC_MSG_CHECKING([for default auto-load directory]) - AC_ARG_WITH(auto-load-dir, - AS_HELP_STRING([--with-auto-load-dir=PATH], -- [directories from which to load auto-loaded scripts, use '$ddir' for -data-directory @<:@$ddir/auto-load@:>@]),, -- [with_auto_load_dir='$ddir/auto-load']) --escape_dir=`echo $with_auto_load_dir | sed 's/[[$]]ddir\>/\\\\\\\\\\\\&/g'` -+ [directories from which to load auto-loaded scripts @<:@$datadir/auto-load@:>@]),, -+ [with_auto_load_dir='$datadir/auto-load']) -+escape_dir=`echo $with_auto_load_dir | sed 's/[[$]]datadir\>/\\\\\\\\\\\\&/g'` - AC_DEFINE_DIR(AUTO_LOAD_DIR, escape_dir, - [Directories from which to load auto-loaded scripts.]) - AC_MSG_RESULT([$with_auto_load_dir]) -@@ -352,14 +352,14 @@ AC_MSG_RESULT([$with_auto_load_dir]) - AC_MSG_CHECKING([for default auto-load safe-path]) - AC_ARG_WITH(auto-load-safe-path, - AS_HELP_STRING([--with-auto-load-safe-path=PATH], -- [directories safe to hold auto-loaded files, use $ddir for --with-gdb-datadir path @<:@--with-auto-load-dir@:>@]) -+ [directories safe to hold auto-loaded files @<:@--with-auto-load-dir@:>@]) - AS_HELP_STRING([--without-auto-load-safe-path], - [do not restrict auto-loaded files locations]), - [if test "$with_auto_load_safe_path" = "no"; then - with_auto_load_safe_path="/" - fi], - [with_auto_load_safe_path="$with_auto_load_dir"]) --escape_dir=`echo $with_auto_load_safe_path | sed 's/[[$]]ddir\>/\\\\\\\\\\\\&/g'` -+escape_dir=`echo $with_auto_load_safe_path | sed 's/[[$]]datadir\>/\\\\\\\\\\\\&/g'` - AC_DEFINE_DIR(AUTO_LOAD_SAFE_PATH, escape_dir, - [Directories safe to hold auto-loaded files.]) - AC_MSG_RESULT([$with_auto_load_safe_path]) -Index: gdb-7.4.50.20120120/gdb/doc/gdb.texinfo -=================================================================== ---- gdb-7.4.50.20120120.orig/gdb/doc/gdb.texinfo 2012-05-14 14:24:15.113490284 +0200 -+++ gdb-7.4.50.20120120/gdb/doc/gdb.texinfo 2012-05-14 14:24:20.234480190 +0200 -@@ -20807,9 +20807,9 @@ local-gdbinit: Auto-loading of .gdbinit - is on. - python-scripts: Auto-loading of Python scripts is on. - safe-path: List of directories from which it is safe to auto-load files -- is $ddir/auto-load. -+ is $datadir/auto-load. - scripts-directory: List of directories from which to load auto-loaded scripts -- is $ddir/auto-load. -+ is $datadir/auto-load. - @end smallexample - - @anchor{info auto-load} -@@ -21025,9 +21025,9 @@ get loaded: - $ ./gdb -q ./gdb - Reading symbols from /home/user/gdb/gdb...done. - warning: File "/home/user/gdb/gdb-gdb.gdb" auto-loading has been -- declined by your `auto-load safe-path' set to "$ddir/auto-load". -+ declined by your `auto-load safe-path' set to "$datadir/auto-load". - warning: File "/home/user/gdb/gdb-gdb.py" auto-loading has been -- declined by your `auto-load safe-path' set to "$ddir/auto-load". -+ declined by your `auto-load safe-path' set to "$datadir/auto-load". - @end smallexample - - The list of trusted directories is controlled by the following commands: -@@ -21060,7 +21060,7 @@ host platform path separator in use. - @end table - - This variable defaults to what @code{--with-auto-load-dir} has been configured --to (@pxref{with-auto-load-dir}). @file{$ddir} substituation applies the same -+to (@pxref{with-auto-load-dir}). @file{$datadir} substituation applies the same - as for @xref{set auto-load scripts-directory}. - The default @code{set - auto-load safe-path} value can be also overriden by @value{GDBN} configuration -@@ -25181,14 +25181,14 @@ Each entry here needs to be covered also - @code{set auto-load safe-path} (@pxref{set auto-load safe-path}). - - @anchor{with-auto-load-dir} --This variable defaults to @file{$ddir/auto-load}. The default @code{set -+This variable defaults to @file{$datadir/auto-load}. The default @code{set - auto-load safe-path} value can be also overriden by @value{GDBN} configuration - option @option{--with-auto-load-dir}. - --Any used string @file{$ddir} will get replaced by @var{data-directory} which is --determined at @value{GDBN} startup (@pxref{Data Files}). @file{$ddir} must be --be placed as a directory component --- either alone or delimited by @file{/} or --@file{\} directory separators, depending on the host platform. -+Any used string @file{$datadir} will get replaced by @var{data-directory} which -+is determined at @value{GDBN} startup (@pxref{Data Files}). @file{$datadir} -+must be placed as a directory component --- either alone or delimited by -+@file{/} or @file{\} directory separators, depending on the host platform. - - The list of directories uses path separator (@samp{:} on GNU and Unix - systems, @samp{;} on MS-Windows and MS-DOS) to separate directories, similarly diff --git a/gdb-autoload-28of28.patch b/gdb-autoload-28of28.patch deleted file mode 100644 index 06797af..0000000 --- a/gdb-autoload-28of28.patch +++ /dev/null @@ -1,393 +0,0 @@ -http://sourceware.org/ml/gdb-patches/2012-05/msg00477.html -Subject: [patch+doc 2/2] auto-load: Fix default /usr/lib/debug/ loading - -Hi, - -with recent security fix to use only $datadir/auto-load/ directory instead of -anything under $prefix/ (which contains insecure $prefix/tmp/ etc.) it -introduced a regression that GDB's default --with-separate-debug-dir would no -longer be secure; which IMO can be assumed as secure. This is because -I forgot to move into 'set auto-load scripts-directory' (and 'safe-path') also -debug-file-diretory; besides $datadir/auto-load which I have moved there. - -To also solve the problem with relocatability and make it configurable I just -introduce besides $datadir now also $debugdir and add it into -default 'set auto-load scripts-directory'. It also IMO makes it more clear -what everything is being auto-loaded in: - -(gdb) show auto-load -gdb-scripts: Auto-loading of canned sequences of commands scripts is on. -libthread-db: Auto-loading of inferior specific libthread_db is on. -local-gdbinit: Auto-loading of .gdbinit script from current directory is on. -python-scripts: Auto-loading of Python scripts is on. -safe-path: List of directories from which it is safe to auto-load files is $debugdir:$datadir/auto-load. - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -scripts-directory: List of directories from which to load auto-loaded scripts is $debugdir:$datadir/auto-load. - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -No regressions on {x86_64,x86_64-m32,i686}-fedora17-linux-gnu. - -I find it more just a bugfix of a regression by myself. - - -Thanks, -Jan - - -gdb/ -2012-05-12 Jan Kratochvil - - * NEWS (--with-auto-load-dir): Prepend $debugdir to the default path. - Describe it. - * auto-load.c (auto_load_expand_dir_vars): New function. - (auto_load_safe_path_vec_update): Use it, remove the - substitute_path_component call thanks to it. - (auto_load_objfile_script): Remove the debug_file_directory processing. - Use auto_load_expand_dir_vars, remove the substitute_path_component - call thanks to it. - * configure: Regenerate. - * configure.ac (--with-auto-load-dir): Prepend $debugdir to the default - path. Escape $ also for $debugdir. - (--with_auto_load_safe_path): Escape $ also for $debugdir. - * utils.c (substitute_path_component): Accept also DIRNAME_SEPARATOR. - -gdb/doc/ -2012-05-12 Jan Kratochvil - - * gdb.texinfo (Separate Debug Files): New anchor debug-file-directory. - Mention also --with-separate-debug-dir. - (Auto-loading): Prepend $debugdir in the sample output. - (Auto-loading safe path): Likewise. Mention also $debugdir for the - auto-load safe-path variable. - (objfile-gdb.py file): Remove the extra debug-file-directory paragraph. - Mention also $debugdir for 'set auto-load scripts-directory'. - -Index: gdb-7.4.50.20120120/gdb/NEWS -=================================================================== ---- gdb-7.4.50.20120120.orig/gdb/NEWS 2012-05-14 14:24:20.000000000 +0200 -+++ gdb-7.4.50.20120120/gdb/NEWS 2012-05-14 14:24:49.510422485 +0200 -@@ -317,8 +317,10 @@ show trace-stop-notes - - --with-auto-load-dir - Configure default value for the 'set auto-load scripts-directory' -- setting above. It defaults to '$datadir/auto-load', $datadir -- representing GDB's data directory (available via show data-directory). -+ setting above. It defaults to '$debugdir:$datadir/auto-load', -+ $debugdir representing global debugging info directories (available -+ via 'show debug-file-directory') and $datadir representing GDB's data -+ directory (available via 'show data-directory'). - - --with-auto-load-safe-path - Configure default value for the 'set auto-load safe-path' setting -Index: gdb-7.4.50.20120120/gdb/auto-load.c -=================================================================== ---- gdb-7.4.50.20120120.orig/gdb/auto-load.c 2012-05-14 14:24:20.000000000 +0200 -+++ gdb-7.4.50.20120120/gdb/auto-load.c 2012-05-14 14:24:49.511422483 +0200 -@@ -147,6 +147,30 @@ static char *auto_load_safe_path; - counterpart. */ - static VEC (char_ptr) *auto_load_safe_path_vec; - -+/* Expand $datadir and $debugdir in STRING according to the rules of -+ substitute_path_component. Return vector from dirnames_to_char_ptr_vec, -+ this vector must be freed by free_char_ptr_vec by the caller. */ -+ -+static VEC (char_ptr) * -+auto_load_expand_dir_vars (const char *string) -+{ -+ VEC (char_ptr) *dir_vec; -+ char *s; -+ -+ s = xstrdup (string); -+ substitute_path_component (&s, "$datadir", gdb_datadir); -+ substitute_path_component (&s, "$debugdir", debug_file_directory); -+ -+ if (debug_auto_load && strcmp (s, string) != 0) -+ fprintf_unfiltered (gdb_stdlog, -+ _("auto-load: Expanded $-variables to \"%s\".\n"), s); -+ -+ dir_vec = dirnames_to_char_ptr_vec (s); -+ xfree(s); -+ -+ return dir_vec; -+} -+ - /* Update auto_load_safe_path_vec from current AUTO_LOAD_SAFE_PATH. */ - - static void -@@ -163,7 +187,7 @@ auto_load_safe_path_vec_update (void) - - free_char_ptr_vec (auto_load_safe_path_vec); - -- auto_load_safe_path_vec = dirnames_to_char_ptr_vec (auto_load_safe_path); -+ auto_load_safe_path_vec = auto_load_expand_dir_vars (auto_load_safe_path); - len = VEC_length (char_ptr, auto_load_safe_path_vec); - - /* Apply tilde_expand and gdb_realpath to each AUTO_LOAD_SAFE_PATH_VEC -@@ -171,16 +195,10 @@ auto_load_safe_path_vec_update (void) - for (ix = 0; ix < len; ix++) - { - char *dir = VEC_index (char_ptr, auto_load_safe_path_vec, ix); -- char *ddir_subst, *expanded, *real_path; -- -- ddir_subst = xstrdup (dir); -- substitute_path_component (&ddir_subst, "$datadir", gdb_datadir); -- expanded = tilde_expand (ddir_subst); -- xfree (ddir_subst); -- real_path = gdb_realpath (expanded); -+ char *expanded = tilde_expand (dir); -+ char *real_path = gdb_realpath (expanded); - -- /* Ensure the current entry is at least a valid path (therefore -- $datadir-expanded and tilde-expanded). */ -+ /* Ensure the current entry is at least tilde_expand-ed. */ - VEC_replace (char_ptr, auto_load_safe_path_vec, ix, expanded); - - if (debug_auto_load) -@@ -645,42 +663,6 @@ auto_load_objfile_script (struct objfile - - if (!input) - { -- char *debugdir; -- VEC (char_ptr) *debugdir_vec; -- int ix; -- -- debugdir_vec = dirnames_to_char_ptr_vec (debug_file_directory); -- make_cleanup_free_char_ptr_vec (debugdir_vec); -- -- if (debug_auto_load) -- fprintf_unfiltered (gdb_stdlog, -- _("auto-load: Searching 'set debug-file-directory' " -- "path \"%s\".\n"), -- debug_file_directory); -- -- for (ix = 0; VEC_iterate (char_ptr, debugdir_vec, ix, debugdir); ++ix) -- { -- /* Also try the same file in the separate debug info directory. */ -- debugfile = xmalloc (strlen (debugdir) + strlen (filename) + 1); -- strcpy (debugfile, debugdir); -- -- /* FILENAME is absolute, so we don't need a "/" here. */ -- strcat (debugfile, filename); -- -- make_cleanup (xfree, debugfile); -- input = fopen (debugfile, "r"); -- if (debug_auto_load) -- fprintf_unfiltered (gdb_stdlog, _("auto-load: Attempted file " -- "\"%s\" %s.\n"), -- debugfile, -- input ? _("exists") : _("does not exist")); -- if (input != NULL) -- break; -- } -- } -- -- if (!input) -- { - VEC (char_ptr) *vec; - int ix; - char *dir; -@@ -688,7 +670,7 @@ auto_load_objfile_script (struct objfile - /* Also try the same file in a subdirectory of gdb's data - directory. */ - -- vec = dirnames_to_char_ptr_vec (auto_load_dir); -+ vec = auto_load_expand_dir_vars (auto_load_dir); - make_cleanup_free_char_ptr_vec (vec); - - if (debug_auto_load) -@@ -698,10 +680,8 @@ auto_load_objfile_script (struct objfile - - for (ix = 0; VEC_iterate (char_ptr, vec, ix, dir); ++ix) - { -- debugfile = xstrdup (dir); -- substitute_path_component (&debugfile, "$datadir", gdb_datadir); -- debugfile = xrealloc (debugfile, (strlen (debugfile) -- + strlen (filename) + 1)); -+ debugfile = xmalloc (strlen (dir) + strlen (filename) + 1); -+ strcpy (debugfile, dir); - - /* FILENAME is absolute, so we don't need a "/" here. */ - strcat (debugfile, filename); -Index: gdb-7.4.50.20120120/gdb/configure -=================================================================== ---- gdb-7.4.50.20120120.orig/gdb/configure 2012-05-14 14:24:38.000000000 +0200 -+++ gdb-7.4.50.20120120/gdb/configure 2012-05-14 14:24:55.856409977 +0200 -@@ -1670,7 +1670,7 @@ Optional Packages: - def. auto=librpm.so) - --with-auto-load-dir=PATH - directories from which to load auto-loaded scripts -- [$datadir/auto-load] -+ [$debugdir:$datadir/auto-load] - --with-auto-load-safe-path=PATH - directories safe to hold auto-loaded files - [--with-auto-load-dir] -@@ -8494,10 +8494,10 @@ $as_echo_n "checking for default auto-lo - if test "${with_auto_load_dir+set}" = set; then : - withval=$with_auto_load_dir; - else -- with_auto_load_dir='$datadir/auto-load' -+ with_auto_load_dir='$debugdir:$datadir/auto-load' - fi - --escape_dir=`echo $with_auto_load_dir | sed 's/[$]datadir\>/\\\\\\\\\\\\&/g'` -+escape_dir=`echo $with_auto_load_dir | sed 's/[$]\(datadir\|debugdir\)\>/\\\\\\\\\\\\&/g'` - - test "x$prefix" = xNONE && prefix="$ac_default_prefix" - test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' -@@ -8524,7 +8524,7 @@ else - with_auto_load_safe_path="$with_auto_load_dir" - fi - --escape_dir=`echo $with_auto_load_safe_path | sed 's/[$]datadir\>/\\\\\\\\\\\\&/g'` -+escape_dir=`echo $with_auto_load_safe_path | sed 's/[$]\(datadir\|debugdir\)\>/\\\\\\\\\\\\&/g'` - - test "x$prefix" = xNONE && prefix="$ac_default_prefix" - test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' -Index: gdb-7.4.50.20120120/gdb/configure.ac -=================================================================== ---- gdb-7.4.50.20120120.orig/gdb/configure.ac 2012-05-14 14:24:20.000000000 +0200 -+++ gdb-7.4.50.20120120/gdb/configure.ac 2012-05-14 14:24:49.515422477 +0200 -@@ -342,9 +342,9 @@ fi - AC_MSG_CHECKING([for default auto-load directory]) - AC_ARG_WITH(auto-load-dir, - AS_HELP_STRING([--with-auto-load-dir=PATH], -- [directories from which to load auto-loaded scripts @<:@$datadir/auto-load@:>@]),, -- [with_auto_load_dir='$datadir/auto-load']) --escape_dir=`echo $with_auto_load_dir | sed 's/[[$]]datadir\>/\\\\\\\\\\\\&/g'` -+ [directories from which to load auto-loaded scripts @<:@$debugdir:$datadir/auto-load@:>@]),, -+ [with_auto_load_dir='$debugdir:$datadir/auto-load']) -+escape_dir=`echo $with_auto_load_dir | sed 's/[[$]]\(datadir\|debugdir\)\>/\\\\\\\\\\\\&/g'` - AC_DEFINE_DIR(AUTO_LOAD_DIR, escape_dir, - [Directories from which to load auto-loaded scripts.]) - AC_MSG_RESULT([$with_auto_load_dir]) -@@ -359,7 +359,7 @@ AS_HELP_STRING([--without-auto-load-safe - with_auto_load_safe_path="/" - fi], - [with_auto_load_safe_path="$with_auto_load_dir"]) --escape_dir=`echo $with_auto_load_safe_path | sed 's/[[$]]datadir\>/\\\\\\\\\\\\&/g'` -+escape_dir=`echo $with_auto_load_safe_path | sed 's/[[$]]\(datadir\|debugdir\)\>/\\\\\\\\\\\\&/g'` - AC_DEFINE_DIR(AUTO_LOAD_SAFE_PATH, escape_dir, - [Directories safe to hold auto-loaded files.]) - AC_MSG_RESULT([$with_auto_load_safe_path]) -Index: gdb-7.4.50.20120120/gdb/doc/gdb.texinfo -=================================================================== ---- gdb-7.4.50.20120120.orig/gdb/doc/gdb.texinfo 2012-05-14 14:24:20.000000000 +0200 -+++ gdb-7.4.50.20120120/gdb/doc/gdb.texinfo 2012-05-14 14:24:49.520422467 +0200 -@@ -16028,8 +16028,11 @@ debug information files, in the indicate - @file{/usr/lib/debug/usr/bin/ls.debug}. - @end itemize - --You can set the global debugging info directories, and view the --list @value{GDBN} is currently using. -+@anchor{debug-file-directory} -+Global debugging info directories default to what is set by @value{GDBN} -+configure option @option{--with-separate-debug-dir}. During @value{GDBN} run -+you can also set the global debugging info directories, and view the list -+@value{GDBN} is currently using. - - @table @code - -@@ -20807,9 +20810,9 @@ local-gdbinit: Auto-loading of .gdbinit - is on. - python-scripts: Auto-loading of Python scripts is on. - safe-path: List of directories from which it is safe to auto-load files -- is $datadir/auto-load. -+ is $debugdir:$datadir/auto-load. - scripts-directory: List of directories from which to load auto-loaded scripts -- is $datadir/auto-load. -+ is $debugdir:$datadir/auto-load. - @end smallexample - - @anchor{info auto-load} -@@ -21025,9 +21028,11 @@ get loaded: - $ ./gdb -q ./gdb - Reading symbols from /home/user/gdb/gdb...done. - warning: File "/home/user/gdb/gdb-gdb.gdb" auto-loading has been -- declined by your `auto-load safe-path' set to "$datadir/auto-load". -+ declined by your `auto-load safe-path' set -+ to "$debugdir:$datadir/auto-load". - warning: File "/home/user/gdb/gdb-gdb.py" auto-loading has been -- declined by your `auto-load safe-path' set to "$datadir/auto-load". -+ declined by your `auto-load safe-path' set -+ to "$debugdir:$datadir/auto-load". - @end smallexample - - The list of trusted directories is controlled by the following commands: -@@ -21060,11 +21065,10 @@ host platform path separator in use. - @end table - - This variable defaults to what @code{--with-auto-load-dir} has been configured --to (@pxref{with-auto-load-dir}). @file{$datadir} substituation applies the same --as for @xref{set auto-load scripts-directory}. --The default @code{set --auto-load safe-path} value can be also overriden by @value{GDBN} configuration --option @option{--with-auto-load-safe-path}. -+to (@pxref{with-auto-load-dir}). @file{$debugdir} and @file{$datadir} -+substituation applies the same as for @xref{set auto-load scripts-directory}. -+The default @code{set auto-load safe-path} value can be also overriden by -+@value{GDBN} configuration option @option{--with-auto-load-safe-path}. - - Setting this variable to @file{/} disables this security protection, - corresponding @value{GDBN} configuration option is -@@ -25158,12 +25162,7 @@ that the file name is absolute, followin - @code{.} and @code{..} components. If this file exists and is - readable, @value{GDBN} will evaluate it as a Python script. - --If this file does not exist, and if the parameter --@code{debug-file-directory} is set (@pxref{Separate Debug Files}), --then @value{GDBN} will look for @var{script-name} in all of the --directories mentioned in the value of @code{debug-file-directory}. -- --Finally, if this file does not exist, then @value{GDBN} will look for -+If this file does not exist, then @value{GDBN} will look for - @var{script-name} file in all of the directories as specified below. - - Note that loading of this script file also requires accordingly configured -@@ -25181,12 +25180,14 @@ Each entry here needs to be covered also - @code{set auto-load safe-path} (@pxref{set auto-load safe-path}). - - @anchor{with-auto-load-dir} --This variable defaults to @file{$datadir/auto-load}. The default @code{set --auto-load safe-path} value can be also overriden by @value{GDBN} configuration --option @option{--with-auto-load-dir}. -- --Any used string @file{$datadir} will get replaced by @var{data-directory} which --is determined at @value{GDBN} startup (@pxref{Data Files}). @file{$datadir} -+This variable defaults to @file{$debugdir:$datadir/auto-load}. The default -+@code{set auto-load safe-path} value can be also overriden by @value{GDBN} -+configuration option @option{--with-auto-load-dir}. -+ -+Any used string @file{$debugdir} will get replaced by @var{debug-file-directory} -+value (@pxref{Separate Debug Files}) and any used string @file{$datadir} will -+get replaced by @var{data-directory} which is determined at @value{GDBN} startup -+(@pxref{Data Files}). @file{$debugdir} and @file{$datadir} - must be placed as a directory component --- either alone or delimited by - @file{/} or @file{\} directory separators, depending on the host platform. - -Index: gdb-7.4.50.20120120/gdb/utils.c -=================================================================== ---- gdb-7.4.50.20120120.orig/gdb/utils.c 2012-05-14 14:24:11.000000000 +0200 -+++ gdb-7.4.50.20120120/gdb/utils.c 2012-05-14 14:24:49.521422465 +0200 -@@ -3927,8 +3927,8 @@ dirnames_to_char_ptr_vec (const char *di - - /* Substitute all occurences of string FROM by string TO in *STRINGP. *STRINGP - must come from xrealloc-compatible allocator and it may be updated. FROM -- needs to be delimited by IS_DIR_SEPARATOR (or be located at the start or -- end of *STRINGP. */ -+ needs to be delimited by IS_DIR_SEPARATOR or DIRNAME_SEPARATOR (or be -+ located at the start or end of *STRINGP. */ - - void - substitute_path_component (char **stringp, const char *from, const char *to) -@@ -3943,8 +3943,10 @@ substitute_path_component (char **string - if (s == NULL) - break; - -- if ((s == string || IS_DIR_SEPARATOR (s[-1])) -- && (s[from_len] == '\0' || IS_DIR_SEPARATOR (s[from_len]))) -+ if ((s == string || IS_DIR_SEPARATOR (s[-1]) -+ || s[-1] == DIRNAME_SEPARATOR) -+ && (s[from_len] == '\0' || IS_DIR_SEPARATOR (s[from_len]) -+ || s[from_len] == DIRNAME_SEPARATOR)) - { - char *string_new; - diff --git a/gdb-bz541866-rwatch-before-run.patch b/gdb-bz541866-rwatch-before-run.patch index 7cc2a38..74604ba 100644 --- a/gdb-bz541866-rwatch-before-run.patch +++ b/gdb-bz541866-rwatch-before-run.patch @@ -1,20 +1,20 @@ -Index: gdb-7.4.50.20111218/gdb/config/i386/linux64.mh +Index: gdb-7.4.50.20120602/gdb/config/i386/linux64.mh =================================================================== ---- gdb-7.4.50.20111218.orig/gdb/config/i386/linux64.mh 2011-08-24 14:07:26.000000000 +0200 -+++ gdb-7.4.50.20111218/gdb/config/i386/linux64.mh 2011-12-19 01:40:49.492625837 +0100 +--- gdb-7.4.50.20120602.orig/gdb/config/i386/linux64.mh 2012-03-13 16:00:34.000000000 +0100 ++++ gdb-7.4.50.20120602/gdb/config/i386/linux64.mh 2012-06-02 19:56:03.196172503 +0200 @@ -4,7 +4,7 @@ NATDEPFILES= inf-ptrace.o fork-child.o \ linux-nat.o linux-osdata.o \ proc-service.o linux-thread-db.o linux-fork.o \ - linux-procfs.o + linux-procfs.o linux-ptrace.o -NAT_FILE= config/nm-linux.h +NAT_FILE= nm-linux64.h NAT_CDEPS = $(srcdir)/proc-service.list # The dynamically loaded libthread_db needs access to symbols in the -Index: gdb-7.4.50.20111218/gdb/config/i386/linux.mh +Index: gdb-7.4.50.20120602/gdb/config/i386/linux.mh =================================================================== ---- gdb-7.4.50.20111218.orig/gdb/config/i386/linux.mh 2011-08-24 14:07:26.000000000 +0200 -+++ gdb-7.4.50.20111218/gdb/config/i386/linux.mh 2011-12-19 01:40:32.453689006 +0100 +--- gdb-7.4.50.20120602.orig/gdb/config/i386/linux.mh 2012-03-13 16:00:33.000000000 +0100 ++++ gdb-7.4.50.20120602/gdb/config/i386/linux.mh 2012-06-02 19:55:42.418178412 +0200 @@ -1,6 +1,6 @@ # Host: Intel 386 running GNU/Linux. @@ -23,10 +23,10 @@ Index: gdb-7.4.50.20111218/gdb/config/i386/linux.mh NATDEPFILES= inf-ptrace.o fork-child.o \ i386-nat.o i386-linux-nat.o \ proc-service.o linux-thread-db.o \ -Index: gdb-7.4.50.20111218/gdb/config/i386/nm-linux.h +Index: gdb-7.4.50.20120602/gdb/config/i386/nm-linux.h =================================================================== --- /dev/null 1970-01-01 00:00:00.000000000 +0000 -+++ gdb-7.4.50.20111218/gdb/config/i386/nm-linux.h 2011-12-19 01:40:32.454689002 +0100 ++++ gdb-7.4.50.20120602/gdb/config/i386/nm-linux.h 2012-06-02 19:55:42.433178408 +0200 @@ -0,0 +1,28 @@ +/* Native support for GNU/Linux i386. + @@ -56,10 +56,10 @@ Index: gdb-7.4.50.20111218/gdb/config/i386/nm-linux.h +#define target_can_use_hardware_watchpoint(type, cnt, ot) 1 + +#endif /* NM_LINUX64_H */ -Index: gdb-7.4.50.20111218/gdb/config/i386/nm-linux64.h +Index: gdb-7.4.50.20120602/gdb/config/i386/nm-linux64.h =================================================================== --- /dev/null 1970-01-01 00:00:00.000000000 +0000 -+++ gdb-7.4.50.20111218/gdb/config/i386/nm-linux64.h 2011-12-19 01:40:32.455688998 +0100 ++++ gdb-7.4.50.20120602/gdb/config/i386/nm-linux64.h 2012-06-02 19:55:42.434178407 +0200 @@ -0,0 +1,28 @@ +/* Native support for GNU/Linux amd64. + @@ -89,11 +89,11 @@ Index: gdb-7.4.50.20111218/gdb/config/i386/nm-linux64.h +#define target_can_use_hardware_watchpoint(type, cnt, ot) 1 + +#endif /* NM_LINUX64_H */ -Index: gdb-7.4.50.20111218/gdb/target.h +Index: gdb-7.4.50.20120602/gdb/target.h =================================================================== ---- gdb-7.4.50.20111218.orig/gdb/target.h 2011-12-06 21:03:13.000000000 +0100 -+++ gdb-7.4.50.20111218/gdb/target.h 2011-12-19 01:40:32.456688995 +0100 -@@ -1391,8 +1391,10 @@ extern char *target_thread_name (struct +--- gdb-7.4.50.20120602.orig/gdb/target.h 2012-06-01 18:37:59.000000000 +0200 ++++ gdb-7.4.50.20120602/gdb/target.h 2012-06-02 19:55:42.436178407 +0200 +@@ -1470,8 +1470,10 @@ extern char *target_thread_name (struct bp_hardware_breakpoint. CNT is the number of such watchpoints used so far (including this one?). OTHERTYPE is who knows what... */ @@ -104,10 +104,10 @@ Index: gdb-7.4.50.20111218/gdb/target.h /* Returns the number of debug registers needed to watch the given memory region, or zero if not supported. */ -Index: gdb-7.4.50.20111218/gdb/testsuite/gdb.base/watchpoint-hw-before-run.exp +Index: gdb-7.4.50.20120602/gdb/testsuite/gdb.base/watchpoint-hw-before-run.exp =================================================================== --- /dev/null 1970-01-01 00:00:00.000000000 +0000 -+++ gdb-7.4.50.20111218/gdb/testsuite/gdb.base/watchpoint-hw-before-run.exp 2011-12-19 01:40:32.464688965 +0100 ++++ gdb-7.4.50.20120602/gdb/testsuite/gdb.base/watchpoint-hw-before-run.exp 2012-06-02 19:55:42.442178406 +0200 @@ -0,0 +1,40 @@ +# Copyright 2009, 2010 Free Software Foundation, Inc. + diff --git a/gdb-bz562763-pretty-print-2d-vectors-libstdcxx.patch b/gdb-bz562763-pretty-print-2d-vectors-libstdcxx.patch deleted file mode 100644 index 8729a62..0000000 --- a/gdb-bz562763-pretty-print-2d-vectors-libstdcxx.patch +++ /dev/null @@ -1,43 +0,0 @@ -2010-06-01 Chris Moller - - * 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 - - # Printer registrations for classes compiled with -D_GLIBCXX_DEBUG. diff --git a/gdb-bz562763-pretty-print-2d-vectors.patch b/gdb-bz562763-pretty-print-2d-vectors.patch deleted file mode 100644 index 0e3d216..0000000 --- a/gdb-bz562763-pretty-print-2d-vectors.patch +++ /dev/null @@ -1,398 +0,0 @@ -2010-05-31 Chris Moller - - * python/py-prettyprint.c (print_children): Add formatting for - matrices. (apply_val_pretty_printer): Detect and deal with matrix - hints. - - -2010-05-31 Chris Moller - - * gdb.python/Makefile.in (EXECUTABLES): Added pr10659. - * gdb.python/pr10659.cc: New file. - * gdb.python/pr10659.exp. New file. - * gdb.python/pr10659.py: New file. - -Index: gdb-7.2.50.20110218/gdb/valprint.h -=================================================================== ---- 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. */ - int summary; -+ -+ /* Affects pretty printing of matrices. */ -+ int prettyprint_matrix; - }; - - /* The global print options set by the user. In general this should -Index: gdb-7.2.50.20110218/gdb/python/py-prettyprint.c -=================================================================== ---- 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. */ -- 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); -+ -+ if (options->prettyprint_matrix && recurse == 0) -+ fputs_filtered ("\n", stream); - - done_flag = 0; - for (i = 0; i < options->print_max; ++i) -@@ -555,12 +558,23 @@ print_children (PyObject *printer, const - 3. Other. Always print a ",". */ - if (i == 0) - { -- if (is_py_none) -- fputs_filtered ("{", stream); -- else -- fputs_filtered (" = {", stream); -+ if (options->prettyprint_matrix && recurse == 0) -+ print_spaces_filtered (2 + 2 * recurse, stream); -+ if (is_py_none) -+ { -+ if (options->prettyprint_matrix && strcmp (hint, "array")) -+ { -+ fputs_filtered ("{\n", stream); -+ print_spaces_filtered (4 + 2 * recurse, stream); -+ } -+ else -+ fputs_filtered ("{", stream); -+ } -+ else -+ fputs_filtered (" = {", stream); - } -- -+ else if (options->prettyprint_matrix) -+ print_spaces_filtered (4 + 2 * recurse, stream); - else if (! is_map || i % 2 == 0) - fputs_filtered (pretty ? "," : ", ", stream); - -@@ -589,6 +603,10 @@ print_children (PyObject *printer, const - - if (is_map && i % 2 == 0) - fputs_filtered ("[", stream); -+ else if (options->prettyprint_matrix) -+ { -+ /* Force a do-nothing. */ -+ } - else if (is_array) - { - /* We print the index, not whatever the child method -@@ -667,7 +685,12 @@ print_children (PyObject *printer, const - fputs_filtered ("\n", stream); - print_spaces_filtered (2 * recurse, stream); - } -- fputs_filtered ("}", stream); -+ if (options->prettyprint_matrix) -+ { -+ print_spaces_filtered (4 * recurse, stream); -+ fputs_filtered ("}\n", stream); -+ } -+ else fputs_filtered ("}", stream); - } - - done: -@@ -689,6 +712,7 @@ apply_val_pretty_printer (struct type *t - char *hint = NULL; - struct cleanup *cleanups; - int result = 0; -+ struct value_print_options *options_copy; - enum string_repr_result print_result; - - /* 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); -+ -+ if (recurse == 0) -+ { -+ options_copy = alloca (sizeof (struct value_print_options)); -+ memcpy (options_copy, options, sizeof (struct value_print_options)); -+ options_copy->prettyprint_matrix = hint && !strcmp (hint, "matrix"); -+ } -+ else options_copy = (struct value_print_options *)options; -+ - make_cleanup (free_current_contents, &hint); - - /* Print the section */ -+ 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.2.50.20110218/gdb/testsuite/gdb.python/pr10659.cc 2011-02-18 10:44:32.000000000 +0100 -@@ -0,0 +1,43 @@ -+#include -+#include // /usr/include/c++/4.4.1/bits/vector.tcc -+#include -+ -+using namespace std; -+ -+int use_windows = 9999; -+ -+int -+main(){ -+ vector test1(2,0); -+ test1[0]=8; -+ test1[1]=9; -+ -+ vector< vector > test2(3, vector(2,0)); -+ test2[0][0]=0; -+ test2[0][1]=1; -+ test2[1][0]=2; -+ test2[1][1]=3; -+ test2[2][0]=4; -+ test2[2][1]=5; -+ -+#define NR_ROWS 2 -+#define NR_COLS 3 -+#define NR_PLANES 4 -+ vector rows(NR_ROWS, 0); -+ vector< vector > columns(NR_COLS, rows); -+ vector< vector < vector > > test3(NR_PLANES, columns); -+ -+ cout << "rows.size() = " << rows.size() -+ << ", columns.size() = " << columns.size() -+ << ", test3.size() = " << test3.size() << "\n"; -+ -+ for (int i = 0; i < rows.size(); i++) { -+ for (int j = 0; j < columns.size(); j++) { -+ for (int k = 0; k < test3.size(); k++) { -+ test3[k][j][i] = k * 100 + j * 10 + i; -+ } -+ } -+ } -+ -+ return 0; // break -+} -Index: gdb-7.2.50.20110218/gdb/testsuite/gdb.python/pr10659.exp -=================================================================== ---- /dev/null 1970-01-01 00:00:00.000000000 +0000 -+++ 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. -+ -+# This program is free software; you can redistribute it and/or modify -+# it under the terms of the GNU General Public License as published by -+# the Free Software Foundation; either version 3 of the License, or -+# (at your option) any later version. -+# -+# This program is distributed in the hope that it will be useful, -+# but WITHOUT ANY WARRANTY; without even the implied warranty of -+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+# GNU General Public License for more details. -+# -+# You should have received a copy of the GNU General Public License -+# along with this program. If not, see . -+ -+set nl "\[\r\n\]+" -+ -+set testfile pr10659 -+set srcfile ${testfile}.cc -+if [prepare_for_testing $testfile.exp $testfile $srcfile {debug c++}] { -+ return -1 -+} -+ -+#if { [skip_python_tests] } { continue } -+ -+gdb_test "python execfile(\"$srcdir/$subdir/pr10659.py\")" "" -+gdb_test "python gdb.pretty_printers = \[lookup_function\]" "" -+ -+if ![runto_main] then { -+ fail "Can't run to main" -+ return -+} -+ -+gdb_breakpoint [gdb_get_line_number "break"] -+gdb_continue_to_breakpoint "break" -+ -+gdb_test "p test1" "vector of length 2, capacity 2 =.*" -+ -+gdb_test "p test2" "= $nl {$nl {.*" -+ -+# Complete result is: -+# -+# (gdb) p test2 -+# $2 = -+# { -+# {0 1 } -+# {2 3 } -+# {4 5 } -+# } -+ -+ -+gdb_test "p test3" "= $nl {$nl {$nl {.*" -+ -+# Complete result is: -+# -+# (gdb) p test3 -+# $3 = -+# { -+# { -+# {0 1 } -+# {10 11 } -+# {20 21 } -+# } -+# { -+# {100 101 } -+# {110 111 } -+# {120 121 } -+# } -+# { -+# {200 201 } -+# {210 211 } -+# {220 221 } -+# } -+# { -+# {300 301 } -+# {310 311 } -+# {320 321 } -+# } -+# } -+# -+ -+ -Index: gdb-7.2.50.20110218/gdb/testsuite/gdb.python/pr10659.py -=================================================================== ---- /dev/null 1970-01-01 00:00:00.000000000 +0000 -+++ 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. -+ -+# This program is free software; you can redistribute it and/or modify -+# it under the terms of the GNU General Public License as published by -+# the Free Software Foundation; either version 3 of the License, or -+# (at your option) any later version. -+# -+# This program is distributed in the hope that it will be useful, -+# but WITHOUT ANY WARRANTY; without even the implied warranty of -+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+# GNU General Public License for more details. -+# -+# You should have received a copy of the GNU General Public License -+# along with this program. If not, see . -+ -+import gdb -+import itertools -+import re -+ -+vector_sig = 'std::vector' -+vector_regex = re.compile('^' + vector_sig + '<.*>$') -+ -+class FakeVectorPrinter: -+ "Print a std::vector" -+ -+ class _iterator: -+ def __init__ (self, start, finish): -+ self.item = start -+ self.finish = finish -+ self.count = 0 -+ -+ def __iter__(self): -+ return self -+ -+ def next(self): -+ if self.item == self.finish: -+ raise StopIteration -+ count = self.count -+ self.count = self.count + 1 -+ elt = self.item.dereference() -+ self.item = self.item + 1 -+ return ('[%d]' % count, elt) -+ -+ def __init__(self, typename, val): -+ self.typename = typename -+ self.val = val -+ -+ def children(self): -+ return self._iterator(self.val['_M_impl']['_M_start'], -+ self.val['_M_impl']['_M_finish']) -+ -+ def to_string(self): -+ start = self.val['_M_impl']['_M_start'] -+ finish = self.val['_M_impl']['_M_finish'] -+ end = self.val['_M_impl']['_M_end_of_storage'] -+ return ('std::vector of length %d, capacity %d' -+ % (int (finish - start), int (end - start))) -+ -+ def display_hint(self): -+ itype0 = self.val.type.template_argument(0) -+ itag = itype0.tag -+ if itag and re.match(vector_regex, itag): -+ rc = 'matrix' -+ else: -+ rc = 'array' -+ return rc -+ -+def register_libstdcxx_printers (obj): -+ "Register libstdc++ pretty-printers with objfile Obj." -+ -+ if obj == None: -+ obj = gdb -+ -+ obj.pretty_printers.append (lookup_function) -+ -+def lookup_function (val): -+ "Look-up and return a pretty-printer that can print val." -+ -+ # Get the type. -+ type = val.type; -+ -+ # If it points to a reference, get the reference. -+ if type.code == gdb.TYPE_CODE_REF: -+ type = type.target () -+ -+ # Get the unqualified type, stripped of typedefs. -+ type = type.unqualified ().strip_typedefs () -+ -+ # Get the type name. -+ typename = type.tag -+ if typename == None: -+ return None -+ -+ # Iterate over local dictionary of types to determine -+ # if a printer is registered for that type. Return an -+ # instantiation of the printer if found. -+ for function in fake_pretty_printers_dict: -+ if function.search (typename): -+ return fake_pretty_printers_dict[function] (val) -+ -+ # Cannot find a pretty printer. Return None. -+ return None -+ -+def build_libfakecxx_dictionary (): -+ fake_pretty_printers_dict[vector_regex] = lambda val: FakeVectorPrinter(vector_sig, val) -+ -+fake_pretty_printers_dict = {} -+ -+build_libfakecxx_dictionary () -Index: gdb-7.2.50.20110218/gdb/valprint.c -=================================================================== ---- 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 */ -- 0 /* summary */ -+ 0, /* summary */ -+ 0 /* prettyprint_matrix */ - }; - - /* Initialize *OPTS to be a copy of the user print options. */ diff --git a/gdb-bz592031-siginfo-lost-4of5.patch b/gdb-bz592031-siginfo-lost-4of5.patch index 3810fec..dfa122a 100644 --- a/gdb-bz592031-siginfo-lost-4of5.patch +++ b/gdb-bz592031-siginfo-lost-4of5.patch @@ -78,11 +78,11 @@ gdb/testsuite/ * gdb.threads/sigstep-threads.exp: New file. * gdb.threads/sigstep-threads.c: New file. -Index: gdb-7.4.50.20111218/gdb/linux-nat.c +Index: gdb-7.4.50.20120602/gdb/linux-nat.c =================================================================== ---- gdb-7.4.50.20111218.orig/gdb/linux-nat.c 2011-12-19 01:25:42.000000000 +0100 -+++ gdb-7.4.50.20111218/gdb/linux-nat.c 2011-12-19 02:17:05.412607735 +0100 -@@ -2843,6 +2843,8 @@ stop_wait_callback (struct lwp_info *lp, +--- gdb-7.4.50.20120602.orig/gdb/linux-nat.c 2012-06-02 21:34:51.999517510 +0200 ++++ gdb-7.4.50.20120602/gdb/linux-nat.c 2012-06-02 21:35:59.930491577 +0200 +@@ -2856,6 +2856,8 @@ stop_wait_callback (struct lwp_info *lp, { int status; @@ -91,7 +91,7 @@ Index: gdb-7.4.50.20111218/gdb/linux-nat.c status = wait_lwp (lp); if (status == 0) return 0; -@@ -2868,110 +2870,61 @@ stop_wait_callback (struct lwp_info *lp, +@@ -2881,110 +2883,61 @@ stop_wait_callback (struct lwp_info *lp, if (WSTOPSIG (status) != SIGSTOP) { @@ -228,7 +228,7 @@ Index: gdb-7.4.50.20111218/gdb/linux-nat.c + + registers_changed (); + linux_ops->to_resume (linux_ops, pid_to_ptid (GET_LWP (lp->ptid)), -+ 1, TARGET_SIGNAL_0); ++ 1, GDB_SIGNAL_0); + if (debug_linux_nat) + fprintf_unfiltered (gdb_stdlog, + "SWC: %s %s, 0, 0 (discard SIGSTOP)\n", @@ -248,7 +248,7 @@ Index: gdb-7.4.50.20111218/gdb/linux-nat.c lp->signalled = 0; } } -@@ -3627,54 +3580,6 @@ retry: +@@ -3616,54 +3569,6 @@ retry: lp = NULL; } @@ -269,7 +269,7 @@ Index: gdb-7.4.50.20111218/gdb/linux-nat.c - if (linux_nat_prepare_to_resume != NULL) - linux_nat_prepare_to_resume (lp); - linux_ops->to_resume (linux_ops, pid_to_ptid (GET_LWP (lp->ptid)), -- lp->step, TARGET_SIGNAL_0); +- lp->step, GDB_SIGNAL_0); - if (debug_linux_nat) - fprintf_unfiltered (gdb_stdlog, - "LLW: %s %s, 0, 0 (expect SIGSTOP)\n", @@ -303,10 +303,10 @@ Index: gdb-7.4.50.20111218/gdb/linux-nat.c if (!target_can_async_p ()) { /* Causes SIGINT to be passed on to the attached process. */ -Index: gdb-7.4.50.20111218/gdb/testsuite/gdb.threads/siginfo-threads.c +Index: gdb-7.4.50.20120602/gdb/testsuite/gdb.threads/siginfo-threads.c =================================================================== --- /dev/null 1970-01-01 00:00:00.000000000 +0000 -+++ gdb-7.4.50.20111218/gdb/testsuite/gdb.threads/siginfo-threads.c 2011-12-19 02:16:35.236720272 +0100 ++++ gdb-7.4.50.20120602/gdb/testsuite/gdb.threads/siginfo-threads.c 2012-06-02 21:35:40.268499060 +0200 @@ -0,0 +1,447 @@ +/* This testcase is part of GDB, the GNU debugger. + @@ -755,10 +755,10 @@ Index: gdb-7.4.50.20111218/gdb/testsuite/gdb.threads/siginfo-threads.c + + return EXIT_SUCCESS; +} -Index: gdb-7.4.50.20111218/gdb/testsuite/gdb.threads/siginfo-threads.exp +Index: gdb-7.4.50.20120602/gdb/testsuite/gdb.threads/siginfo-threads.exp =================================================================== --- /dev/null 1970-01-01 00:00:00.000000000 +0000 -+++ gdb-7.4.50.20111218/gdb/testsuite/gdb.threads/siginfo-threads.exp 2011-12-19 02:16:35.237720268 +0100 ++++ gdb-7.4.50.20120602/gdb/testsuite/gdb.threads/siginfo-threads.exp 2012-06-02 21:35:40.296499050 +0200 @@ -0,0 +1,94 @@ +# Copyright 2010 Free Software Foundation, Inc. + @@ -854,10 +854,10 @@ Index: gdb-7.4.50.20111218/gdb/testsuite/gdb.threads/siginfo-threads.exp +} + +gdb_continue_to_breakpoint break-at-exit ".*break-at-exit.*" -Index: gdb-7.4.50.20111218/gdb/testsuite/gdb.threads/sigstep-threads.c +Index: gdb-7.4.50.20120602/gdb/testsuite/gdb.threads/sigstep-threads.c =================================================================== --- /dev/null 1970-01-01 00:00:00.000000000 +0000 -+++ gdb-7.4.50.20111218/gdb/testsuite/gdb.threads/sigstep-threads.c 2011-12-19 02:16:35.237720268 +0100 ++++ gdb-7.4.50.20120602/gdb/testsuite/gdb.threads/sigstep-threads.c 2012-06-02 21:35:40.297499050 +0200 @@ -0,0 +1,54 @@ +/* This testcase is part of GDB, the GNU debugger. + @@ -913,10 +913,10 @@ Index: gdb-7.4.50.20111218/gdb/testsuite/gdb.threads/sigstep-threads.c + start (NULL); /* main-start */ + return 0; +} -Index: gdb-7.4.50.20111218/gdb/testsuite/gdb.threads/sigstep-threads.exp +Index: gdb-7.4.50.20120602/gdb/testsuite/gdb.threads/sigstep-threads.exp =================================================================== --- /dev/null 1970-01-01 00:00:00.000000000 +0000 -+++ gdb-7.4.50.20111218/gdb/testsuite/gdb.threads/sigstep-threads.exp 2011-12-19 02:16:35.237720268 +0100 ++++ gdb-7.4.50.20120602/gdb/testsuite/gdb.threads/sigstep-threads.exp 2012-06-02 21:35:40.297499050 +0200 @@ -0,0 +1,74 @@ +# Copyright 2010 Free Software Foundation, Inc. + diff --git a/gdb-bz592031-siginfo-lost-5of5.patch b/gdb-bz592031-siginfo-lost-5of5.patch index 8f4e440..b9fe18f 100644 --- a/gdb-bz592031-siginfo-lost-5of5.patch +++ b/gdb-bz592031-siginfo-lost-5of5.patch @@ -26,19 +26,19 @@ gdb/ (linux_nat_set_siginfo_fixup): Use PTRACE_GETSIGINFO. * linux-nat.h (struct lwp_info) : Remove. -Index: gdb-7.4.50.20111218/gdb/linux-nat.c +Index: gdb-7.4.50.20120602/gdb/linux-nat.c =================================================================== ---- gdb-7.4.50.20111218.orig/gdb/linux-nat.c 2011-12-19 02:17:05.000000000 +0100 -+++ gdb-7.4.50.20111218/gdb/linux-nat.c 2011-12-19 02:17:43.188466854 +0100 -@@ -1883,7 +1883,6 @@ resume_lwp (struct lwp_info *lp, int ste - step, TARGET_SIGNAL_0); +--- gdb-7.4.50.20120602.orig/gdb/linux-nat.c 2012-06-02 21:36:21.067483466 +0200 ++++ gdb-7.4.50.20120602/gdb/linux-nat.c 2012-06-02 21:37:55.345447402 +0200 +@@ -1929,7 +1929,6 @@ resume_lwp (struct lwp_info *lp, int ste + step, GDB_SIGNAL_0); lp->stopped = 0; lp->step = step; - memset (&lp->siginfo, 0, sizeof (lp->siginfo)); lp->stopped_by_watchpoint = 0; } else -@@ -2027,7 +2026,6 @@ linux_nat_resume (struct target_ops *ops +@@ -2071,7 +2070,6 @@ linux_nat_resume (struct target_ops *ops if (linux_nat_prepare_to_resume != NULL) linux_nat_prepare_to_resume (lp); linux_ops->to_resume (linux_ops, ptid, step, signo); @@ -46,7 +46,7 @@ Index: gdb-7.4.50.20111218/gdb/linux-nat.c lp->stopped_by_watchpoint = 0; if (debug_linux_nat) -@@ -2612,22 +2610,6 @@ wait_lwp (struct lwp_info *lp) +@@ -2625,22 +2623,6 @@ wait_lwp (struct lwp_info *lp) return status; } @@ -69,7 +69,7 @@ Index: gdb-7.4.50.20111218/gdb/linux-nat.c /* Send a SIGSTOP to LP. */ static int -@@ -2872,9 +2854,6 @@ stop_wait_callback (struct lwp_info *lp, +@@ -2885,9 +2867,6 @@ stop_wait_callback (struct lwp_info *lp, { /* The thread was stopped with a signal other than SIGSTOP. */ @@ -79,7 +79,7 @@ Index: gdb-7.4.50.20111218/gdb/linux-nat.c save_sigtrap (lp); if (debug_linux_nat) -@@ -3278,12 +3257,7 @@ linux_nat_filter_event (int lwpid, int s +@@ -3291,12 +3270,7 @@ linux_nat_filter_event (int lwpid, int s } if (linux_nat_status_is_event (status)) @@ -93,20 +93,20 @@ Index: gdb-7.4.50.20111218/gdb/linux-nat.c /* Check if the thread has exited. */ if ((WIFEXITED (status) || WIFSIGNALED (status)) -@@ -3961,7 +3935,6 @@ resume_stopped_resumed_lwps (struct lwp_ +@@ -3950,7 +3924,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->step, GDB_SIGNAL_0); lp->stopped = 0; - memset (&lp->siginfo, 0, sizeof (lp->siginfo)); lp->stopped_by_watchpoint = 0; } -@@ -6029,11 +6002,19 @@ linux_nat_set_prepare_to_resume (struct - struct siginfo * +@@ -5227,11 +5200,19 @@ linux_nat_set_prepare_to_resume (struct + siginfo_t * linux_nat_get_siginfo (ptid_t ptid) { - struct lwp_info *lp = find_lwp_pid (ptid); -+ static struct siginfo siginfo; ++ static siginfo_t siginfo; + int pid; - gdb_assert (lp != NULL); @@ -124,17 +124,17 @@ Index: gdb-7.4.50.20111218/gdb/linux-nat.c } /* Provide a prototype to silence -Wmissing-prototypes. */ -Index: gdb-7.4.50.20111218/gdb/linux-nat.h +Index: gdb-7.4.50.20120602/gdb/linux-nat.h =================================================================== ---- gdb-7.4.50.20111218.orig/gdb/linux-nat.h 2011-12-18 23:40:59.000000000 +0100 -+++ gdb-7.4.50.20111218/gdb/linux-nat.h 2011-12-19 02:17:21.355548276 +0100 -@@ -77,10 +77,6 @@ struct lwp_info +--- gdb-7.4.50.20120602.orig/gdb/linux-nat.h 2012-06-02 21:36:21.067483466 +0200 ++++ gdb-7.4.50.20120602/gdb/linux-nat.h 2012-06-02 21:36:27.140481144 +0200 +@@ -76,10 +76,6 @@ struct lwp_info /* The kind of stepping of this LWP. */ enum resume_step step; - /* Non-zero si_signo if this LWP stopped with a trap. si_addr may - be the address of a hardware watchpoint. */ -- struct siginfo siginfo; +- siginfo_t siginfo; - /* STOPPED_BY_WATCHPOINT is non-zero if this LWP stopped with a data watchpoint trap. */ diff --git a/gdb-dejagnu-go.patch b/gdb-dejagnu-go.patch new file mode 100644 index 0000000..ddac07b --- /dev/null +++ b/gdb-dejagnu-go.patch @@ -0,0 +1,42 @@ +http://sourceware.org/ml/gdb-patches/2012-06/msg00050.html +Subject: [patch] dejagnu compat. - missing find_go_linker [Re: [patch, doc RFA] Go language support] + +On Wed, 25 Apr 2012 04:17:35 +0200, Doug Evans wrote: +> +if {[info procs find_go_linker] == ""} { +> + rename gdb_find_go find_go +> + rename gdb_find_go_linker find_go_linker +> + # No need to set use_gdb_compile. +> +} + +Is there a reason for it? With recent Fedora 17 update + https://bugzilla.redhat.com/show_bug.cgi?id=635651 + +dejagnu has started to support 'find_gfortran'. But it still does not support +'find_go_linker'. This has resulted in regression failing to compile any +gdb.go/*.exp files. + + +Thanks, +Jan + + +gdb/testsuite/ +2012-06-02 Jan Kratochvil + + * lib/future.exp: Set $use_gdb_compile even if only find_go_linker is + missing. + +diff --git a/gdb/testsuite/lib/future.exp b/gdb/testsuite/lib/future.exp +index 40456c0..bf47988 100644 +--- a/gdb/testsuite/lib/future.exp ++++ b/gdb/testsuite/lib/future.exp +@@ -514,7 +514,7 @@ if {[info procs find_gfortran] == ""} { + if {[info procs find_go_linker] == ""} { + rename gdb_find_go find_go + rename gdb_find_go_linker find_go_linker +- # No need to set use_gdb_compile. ++ set use_gdb_compile 1 + } + + if {$use_gdb_compile} { + diff --git a/gdb-die-cu-offset-1of2.patch b/gdb-die-cu-offset-1of2.patch deleted file mode 100644 index 2b0e91f..0000000 --- a/gdb-die-cu-offset-1of2.patch +++ /dev/null @@ -1,99 +0,0 @@ -[commit] [patch] Fix CU relative vs. absolute offsets [Re: RFC: problem with DW_OP_GNU_deref_type and dwarf's get_base_type callback] -http://sourceware.org/ml/gdb-patches/2012-03/msg00284.html -http://sourceware.org/ml/gdb-cvs/2012-03/msg00134.html - -### src/gdb/ChangeLog 2012/03/08 19:08:09 1.13979 -### src/gdb/ChangeLog 2012/03/08 19:37:04 1.13980 -## -1,5 +1,15 @@ - 2012-03-08 Jan Kratochvil - -+ Fix CU relative vs. absolute DIE offsets. -+ * dwarf2loc.h (dwarf2_fetch_die_location_block): Rename parameter -+ offset to offset_in_cu. -+ * dwarf2read.c (process_enumeration_scope): Add CU offset to -+ TYPE_OFFSET. -+ (dwarf2_fetch_die_location_block): Rename parameter offset to -+ offset_in_cu. New variable offset, add CU offset to OFFSET_IN_CU. -+ -+2012-03-08 Jan Kratochvil -+ - * libunwind-frame.c: Rename to ... - * ia64-libunwind-tdep.c: ... here. - * libunwind-frame.h: Rename to ... ---- src/gdb/dwarf2loc.h 2012/01/05 21:53:14 1.29 -+++ src/gdb/dwarf2loc.h 2012/03/08 19:37:07 1.30 -@@ -61,7 +61,7 @@ - CORE_ADDR pc); - - struct dwarf2_locexpr_baton dwarf2_fetch_die_location_block -- (unsigned int offset, struct dwarf2_per_cu_data *per_cu, -+ (unsigned int offset_in_cu, struct dwarf2_per_cu_data *per_cu, - CORE_ADDR (*get_frame_pc) (void *baton), - void *baton); - ---- src/gdb/dwarf2read.c 2012/03/06 23:41:50 1.619 -+++ src/gdb/dwarf2read.c 2012/03/08 19:37:07 1.620 -@@ -8031,7 +8031,8 @@ - = lookup_signatured_type_at_offset (dwarf2_per_objfile->objfile, - cu->per_cu->debug_types_section, - cu->per_cu->offset); -- if (type_sig->type_offset != die->offset) -+ if (type_sig->per_cu.offset + type_sig->type_offset -+ != die->offset) - return; - } - -@@ -14202,11 +14203,12 @@ - dwarf2_locexpr_baton->data has lifetime of PER_CU->OBJFILE. */ - - struct dwarf2_locexpr_baton --dwarf2_fetch_die_location_block (unsigned int offset, -+dwarf2_fetch_die_location_block (unsigned int offset_in_cu, - struct dwarf2_per_cu_data *per_cu, - CORE_ADDR (*get_frame_pc) (void *baton), - void *baton) - { -+ unsigned int offset = per_cu->offset + offset_in_cu; - struct dwarf2_cu *cu; - struct die_info *die; - struct attribute *attr; -### src/gdb/testsuite/ChangeLog 2012/03/08 07:42:50 1.3127 -### src/gdb/testsuite/ChangeLog 2012/03/08 19:37:07 1.3128 -## -1,5 +1,11 @@ - 2012-03-08 Jan Kratochvil - -+ Fix CU relative vs. absolute DIE offsets. -+ * gdb.dwarf2/dw2-op-call.S: New compilation unit preceding the existing -+ one. -+ -+2012-03-08 Jan Kratochvil -+ - Fix false FAIL on distros with relro linkage as default. - * gdb.reverse/solib-precsave.exp: Try to compile the test using - -Wl,-z,norelro first. ---- src/gdb/testsuite/gdb.dwarf2/dw2-op-call.S 2012/01/04 08:17:51 1.5 -+++ src/gdb/testsuite/gdb.dwarf2/dw2-op-call.S 2012/03/08 19:37:08 1.6 -@@ -23,6 +23,23 @@ - array3: .2byte 3 - - .section .debug_info -+.Lcu0_begin: -+ /* CU header */ -+ .4byte .Lcu0_end - .Lcu0_start /* Length of Compilation Unit */ -+.Lcu0_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 "file0.txt\0" /* DW_AT_name */ -+ .ascii "GNU C 3.3.3\0" /* DW_AT_producer */ -+ .byte 2 /* DW_LANG_C (C) */ -+ -+ .byte 0 /* End of children of CU */ -+.Lcu0_end: -+ - .Lcu1_begin: - /* CU header */ - .4byte .Lcu1_end - .Lcu1_start /* Length of Compilation Unit */ diff --git a/gdb-die-cu-offset-2of2.patch b/gdb-die-cu-offset-2of2.patch deleted file mode 100644 index 057088c..0000000 --- a/gdb-die-cu-offset-2of2.patch +++ /dev/null @@ -1,26 +0,0 @@ -RFC: problem with DW_OP_GNU_deref_type and dwarf's get_base_type callback -http://sourceware.org/ml/gdb-patches/2012-03/msg00166.html -http://sourceware.org/ml/gdb-cvs/2012-03/msg00118.html - -### src/gdb/ChangeLog 2012/03/06 22:48:49 1.13968 -### src/gdb/ChangeLog 2012/03/06 23:41:47 1.13969 -## -1,3 +1,8 @@ -+2012-03-06 Joel Brobecker -+ -+ * dwarf2read.c (dwarf2_get_die_type): Pass absolute offset -+ in call to get_die_type_at_offset. -+ - 2012-03-06 Stan Shebs - - * mi/mi-cmd-break.c: Enforce coding standards, fix comments. ---- src/gdb/dwarf2read.c 2012/03/02 01:55:15 1.618 -+++ src/gdb/dwarf2read.c 2012/03/06 23:41:50 1.619 -@@ -14269,7 +14269,7 @@ - struct dwarf2_per_cu_data *per_cu) - { - dw2_setup (per_cu->objfile); -- return get_die_type_at_offset (die_offset, per_cu); -+ return get_die_type_at_offset (per_cu->offset + die_offset, per_cu); - } - - /* Follow the signature attribute ATTR in SRC_DIE. diff --git a/gdb-dlopen-stap-probe-test.patch b/gdb-dlopen-stap-probe-test.patch index 99cb62f..be5e76f 100644 --- a/gdb-dlopen-stap-probe-test.patch +++ b/gdb-dlopen-stap-probe-test.patch @@ -4,10 +4,10 @@ Date: Mon Aug 8 12:08:53 2011 +0200 +testcase -Index: gdb-7.3.50.20110722/gdb/testsuite/gdb.threads/dlopen-libpthread-lib.c +Index: gdb-7.4.50.20120602/gdb/testsuite/gdb.threads/dlopen-libpthread-lib.c =================================================================== --- /dev/null 1970-01-01 00:00:00.000000000 +0000 -+++ gdb-7.3.50.20110722/gdb/testsuite/gdb.threads/dlopen-libpthread-lib.c 2011-08-10 18:30:56.000000000 +0200 ++++ gdb-7.4.50.20120602/gdb/testsuite/gdb.threads/dlopen-libpthread-lib.c 2012-06-02 20:03:42.711393776 +0200 @@ -0,0 +1,40 @@ +/* This testcase is part of GDB, the GNU debugger. + @@ -49,10 +49,10 @@ Index: gdb-7.3.50.20110722/gdb/testsuite/gdb.threads/dlopen-libpthread-lib.c + i = pthread_join (t, NULL); + assert (i == 0); +} -Index: gdb-7.3.50.20110722/gdb/testsuite/gdb.threads/dlopen-libpthread.c +Index: gdb-7.4.50.20120602/gdb/testsuite/gdb.threads/dlopen-libpthread.c =================================================================== --- /dev/null 1970-01-01 00:00:00.000000000 +0000 -+++ gdb-7.3.50.20110722/gdb/testsuite/gdb.threads/dlopen-libpthread.c 2011-08-10 18:30:56.000000000 +0200 ++++ gdb-7.4.50.20120602/gdb/testsuite/gdb.threads/dlopen-libpthread.c 2012-06-02 20:03:42.712393775 +0200 @@ -0,0 +1,46 @@ +/* This testcase is part of GDB, the GNU debugger. + @@ -100,10 +100,10 @@ Index: gdb-7.3.50.20110722/gdb/testsuite/gdb.threads/dlopen-libpthread.c + + return 0; +} -Index: gdb-7.3.50.20110722/gdb/testsuite/gdb.threads/dlopen-libpthread.exp +Index: gdb-7.4.50.20120602/gdb/testsuite/gdb.threads/dlopen-libpthread.exp =================================================================== --- /dev/null 1970-01-01 00:00:00.000000000 +0000 -+++ gdb-7.3.50.20110722/gdb/testsuite/gdb.threads/dlopen-libpthread.exp 2011-08-10 18:30:56.000000000 +0200 ++++ gdb-7.4.50.20120602/gdb/testsuite/gdb.threads/dlopen-libpthread.exp 2012-06-02 20:03:42.724393771 +0200 @@ -0,0 +1,74 @@ +# Copyright 2011 Free Software Foundation, Inc. +# @@ -179,11 +179,11 @@ Index: gdb-7.3.50.20110722/gdb/testsuite/gdb.threads/dlopen-libpthread.exp +gdb_continue_to_breakpoint "notify" ".* notify-here .*" + +gdb_test "info sharedlibrary" {/libpthread\.so.*} "libpthread.so found" -Index: gdb-7.3.50.20110722/gdb/testsuite/lib/gdb.exp +Index: gdb-7.4.50.20120602/gdb/testsuite/lib/gdb.exp =================================================================== ---- gdb-7.3.50.20110722.orig/gdb/testsuite/lib/gdb.exp 2011-08-10 18:30:55.000000000 +0200 -+++ gdb-7.3.50.20110722/gdb/testsuite/lib/gdb.exp 2011-08-10 18:30:56.000000000 +0200 -@@ -3563,30 +3563,49 @@ proc build_executable { testname executa +--- gdb-7.4.50.20120602.orig/gdb/testsuite/lib/gdb.exp 2012-06-02 19:11:56.000000000 +0200 ++++ gdb-7.4.50.20120602/gdb/testsuite/lib/gdb.exp 2012-06-02 20:03:42.727393770 +0200 +@@ -3693,30 +3693,49 @@ proc build_executable { testname executa set sources ${executable}.c } @@ -250,10 +250,10 @@ Index: gdb-7.3.50.20110722/gdb/testsuite/lib/gdb.exp return 0 } -Index: gdb-7.3.50.20110722/gdb/testsuite/lib/prelink-support.exp +Index: gdb-7.4.50.20120602/gdb/testsuite/lib/prelink-support.exp =================================================================== ---- gdb-7.3.50.20110722.orig/gdb/testsuite/lib/prelink-support.exp 2011-01-01 16:33:52.000000000 +0100 -+++ gdb-7.3.50.20110722/gdb/testsuite/lib/prelink-support.exp 2011-08-10 19:25:41.000000000 +0200 +--- gdb-7.4.50.20120602.orig/gdb/testsuite/lib/prelink-support.exp 2012-01-04 09:27:56.000000000 +0100 ++++ gdb-7.4.50.20120602/gdb/testsuite/lib/prelink-support.exp 2012-06-02 20:03:42.733393768 +0200 @@ -95,8 +95,9 @@ proc file_copy {src dest} { # Wrap function build_executable so that the resulting executable is fully # self-sufficient (without dependencies on system libraries). Parameter @@ -306,11 +306,11 @@ Index: gdb-7.3.50.20110722/gdb/testsuite/lib/prelink-support.exp return $prelink_args } -Index: gdb-7.3.50.20110722/gdb/testsuite/gdb.base/break-interp.exp +Index: gdb-7.4.50.20120602/gdb/testsuite/gdb.base/break-interp.exp =================================================================== ---- gdb-7.3.50.20110722.orig/gdb/testsuite/gdb.base/break-interp.exp 2011-07-01 21:12:12.000000000 +0200 -+++ gdb-7.3.50.20110722/gdb/testsuite/gdb.base/break-interp.exp 2011-08-10 18:32:21.000000000 +0200 -@@ -108,14 +108,21 @@ proc strip_debug {dest} { +--- gdb-7.4.50.20120602.orig/gdb/testsuite/gdb.base/break-interp.exp 2012-02-24 15:09:08.000000000 +0100 ++++ gdb-7.4.50.20120602/gdb/testsuite/gdb.base/break-interp.exp 2012-06-02 20:04:56.135369687 +0200 +@@ -109,14 +109,21 @@ proc strip_debug {dest} { } } @@ -334,7 +334,7 @@ Index: gdb-7.3.50.20110722/gdb/testsuite/gdb.base/break-interp.exp gdb_test_no_output "set stop-on-solib-events 1" } elseif {! [gdb_breakpoint $func allow-pending]} { return -@@ -141,21 +147,21 @@ proc reach_1 {func command displacement} +@@ -142,21 +149,21 @@ proc reach_1 {func command displacement} exp_continue } -re "Breakpoint \[0-9\]+, \\.?(__GI_)?$func \\(.*\\) at .*:\[0-9\]+\r\n.*$gdb_prompt $" { @@ -353,13 +353,13 @@ Index: gdb-7.3.50.20110722/gdb/testsuite/gdb.base/break-interp.exp pass $test } } - -re "Stopped due to shared library event\r\n$gdb_prompt $" { + -re "Stopped due to (spurious )?shared library event.*\r\n$gdb_prompt $" { - if {$func == "_dl_debug_state"} { + if {$func == $solib_bp} { if {$debug_state_count == 0} { # First stop does not yet relocate the _start function # descriptor on ppc64. -@@ -174,7 +180,7 @@ proc reach_1 {func command displacement} +@@ -175,7 +182,7 @@ proc reach_1 {func command displacement} fail $test_displacement } @@ -368,7 +368,7 @@ Index: gdb-7.3.50.20110722/gdb/testsuite/gdb.base/break-interp.exp gdb_test_no_output "set stop-on-solib-events 0" } } -@@ -373,7 +379,7 @@ proc test_attach {file displacement {rel +@@ -357,7 +364,7 @@ proc test_attach {file displacement {rel } proc test_ld {file ifmain trynosym displacement} { @@ -377,7 +377,7 @@ Index: gdb-7.3.50.20110722/gdb/testsuite/gdb.base/break-interp.exp # First test normal `file'-command loaded $FILE with symbols. -@@ -401,9 +407,9 @@ proc test_ld {file ifmain trynosym displ +@@ -385,9 +392,9 @@ proc test_ld {file ifmain trynosym displ gdb_test_no_output "set args ${objdir}/${subdir}/$binfile_test" "set args OBJDIR/${subdir}/$binfile_test" } @@ -389,7 +389,7 @@ Index: gdb-7.3.50.20110722/gdb/testsuite/gdb.base/break-interp.exp if $ifmain { reach "main" continue "NONE" -@@ -415,7 +421,7 @@ proc test_ld {file ifmain trynosym displ +@@ -399,7 +406,7 @@ proc test_ld {file ifmain trynosym displ # Try re-run if the new PIE displacement takes effect. gdb_test "kill" "" "kill" {Kill the program being debugged\? \(y or n\) } "y" @@ -398,12 +398,12 @@ Index: gdb-7.3.50.20110722/gdb/testsuite/gdb.base/break-interp.exp if $ifmain { test_core $file $displacement -@@ -448,7 +454,7 @@ proc test_ld {file ifmain trynosym displ - gdb_test "exec-file $file" "exec-file $escapedfile" "load" +@@ -431,7 +438,7 @@ proc test_ld {file ifmain trynosym displ + gdb_test "exec-file $file" "exec-file $escapedfile" "load" - if $ifmain { -- reach "_dl_debug_state" run $displacement -+ reach $solib_bp run $displacement + if $ifmain { +- reach "_dl_debug_state" run $displacement ++ reach $solib_bp run $displacement - # Use two separate gdb_test_multiple statements to avoid timeouts due - # to slow processing of wildcard capturing long output + # Use two separate gdb_test_multiple statements to avoid timeouts due + # to slow processing of wildcard capturing long output diff --git a/gdb-dlopen-stap-probe.patch b/gdb-dlopen-stap-probe.patch index 54a3c03..94a4b61 100644 --- a/gdb-dlopen-stap-probe.patch +++ b/gdb-dlopen-stap-probe.patch @@ -2,11 +2,11 @@ From: Gary Benson To: Jan Kratochvil Message-ID: <20110810133605.GB7294@redhat.com> -Index: gdb-7.4.50.20120103/gdb/infrun.c +Index: gdb-7.4.50.20120602/gdb/infrun.c =================================================================== ---- gdb-7.4.50.20120103.orig/gdb/infrun.c 2012-01-04 00:26:15.000000000 +0100 -+++ gdb-7.4.50.20120103/gdb/infrun.c 2012-01-04 00:26:21.960833391 +0100 -@@ -354,6 +354,13 @@ static struct symbol *step_start_functio +--- gdb-7.4.50.20120602.orig/gdb/infrun.c 2012-06-02 21:38:07.236442883 +0200 ++++ gdb-7.4.50.20120602/gdb/infrun.c 2012-06-02 21:38:13.450440507 +0200 +@@ -361,6 +361,13 @@ static struct symbol *step_start_functio /* Nonzero if we want to give control to the user when we're notified of shared library events by the dynamic linker. */ int stop_on_solib_events; @@ -20,7 +20,7 @@ Index: gdb-7.4.50.20120103/gdb/infrun.c static void show_stop_on_solib_events (struct ui_file *file, int from_tty, struct cmd_list_element *c, const char *value) -@@ -7304,7 +7311,7 @@ Show stopping for shared library events. +@@ -7267,7 +7274,7 @@ Show stopping for shared library events. If nonzero, gdb will give control to the user when the dynamic linker\n\ notifies gdb of shared library events. The most common event of interest\n\ to the user would be loading/unloading of a new library."), @@ -29,20 +29,20 @@ Index: gdb-7.4.50.20120103/gdb/infrun.c show_stop_on_solib_events, &setlist, &showlist); -Index: gdb-7.4.50.20120103/gdb/solib-svr4.c +Index: gdb-7.4.50.20120602/gdb/solib-svr4.c =================================================================== ---- gdb-7.4.50.20120103.orig/gdb/solib-svr4.c 2012-01-04 00:26:15.000000000 +0100 -+++ gdb-7.4.50.20120103/gdb/solib-svr4.c 2012-01-04 00:29:56.303014562 +0100 -@@ -48,6 +48,8 @@ +--- gdb-7.4.50.20120602.orig/gdb/solib-svr4.c 2012-06-02 21:38:07.236442883 +0200 ++++ gdb-7.4.50.20120602/gdb/solib-svr4.c 2012-06-02 21:44:23.973298737 +0200 +@@ -47,6 +47,8 @@ #include "auxv.h" #include "exceptions.h" -+#include "stap-probe.h" ++#include "probe.h" + static struct link_map_offsets *svr4_fetch_link_map_offsets (void); static int svr4_have_link_map_offsets (void); static void svr4_relocate_main_executable (void); -@@ -93,6 +95,32 @@ static const char * const solib_break_na +@@ -92,6 +94,32 @@ static const char * const solib_break_na NULL }; @@ -75,20 +75,20 @@ Index: gdb-7.4.50.20120103/gdb/solib-svr4.c static const char * const bkpt_names[] = { "_start", -@@ -314,6 +342,12 @@ struct svr4_info +@@ -313,6 +341,12 @@ struct svr4_info CORE_ADDR interp_text_sect_high; CORE_ADDR interp_plt_sect_low; CORE_ADDR interp_plt_sect_high; + + /* SystemTap probes. */ -+ VEC (stap_probe_p) *probes[NUM_PROBES]; ++ VEC (probe_p) *probes[NUM_PROBES]; + + /* Nonzero if we are using the SystemTap interface. */ + int using_probes; }; /* Per-program-space data key. */ -@@ -323,8 +357,15 @@ static void +@@ -322,8 +356,15 @@ static void svr4_pspace_data_cleanup (struct program_space *pspace, void *arg) { struct svr4_info *info; @@ -99,12 +99,12 @@ Index: gdb-7.4.50.20120103/gdb/solib-svr4.c + return; + + for (i = 0; i < NUM_PROBES; i++) -+ VEC_free (stap_probe_p, info->probes[i]); ++ VEC_free (probe_p, info->probes[i]); + xfree (info); } -@@ -1445,6 +1486,126 @@ exec_entry_point (struct bfd *abfd, stru +@@ -1449,6 +1490,126 @@ exec_entry_point (struct bfd *abfd, stru targ); } @@ -127,11 +127,11 @@ Index: gdb-7.4.50.20120103/gdb/solib-svr4.c + { + if (!probe_info[i].mandatory) + { -+ struct stap_probe *probe; ++ struct probe *probe; + int ix; + + for (ix = 0; -+ VEC_iterate (stap_probe_p, info->probes[i], ix, probe); ++ VEC_iterate (probe_p, info->probes[i], ix, probe); + ++ix) + { + if (loc->pspace == current_program_space @@ -190,13 +190,13 @@ Index: gdb-7.4.50.20120103/gdb/solib-svr4.c + info->probes[i] = find_probes_in_objfile (os->objfile, "rtld", + probe_info[i].name); + -+ if (!VEC_length(stap_probe_p, info->probes[i])) ++ if (!VEC_length(probe_p, info->probes[i])) + { + int j; + + for (j = i - 1; j >= 0; j--) + { -+ VEC_free (stap_probe_p, info->probes[j]); ++ VEC_free (probe_p, info->probes[j]); + info->probes[j] = NULL; + } + @@ -211,11 +211,11 @@ Index: gdb-7.4.50.20120103/gdb/solib-svr4.c + + for (i = 0; i < NUM_PROBES; i++) + { -+ struct stap_probe *probe; ++ struct probe *probe; + int ix; + + for (ix = 0; -+ VEC_iterate (stap_probe_p, info->probes[i], ix, probe); ++ VEC_iterate (probe_p, info->probes[i], ix, probe); + ++ix) + create_solib_event_breakpoint (gdbarch, probe->address); + } @@ -231,7 +231,7 @@ Index: gdb-7.4.50.20120103/gdb/solib-svr4.c /* Helper function for gdb_bfd_lookup_symbol. */ static int -@@ -1493,10 +1654,18 @@ enable_break (struct svr4_info *info, in +@@ -1497,10 +1658,18 @@ enable_break (struct svr4_info *info, in asection *interp_sect; gdb_byte *interp_name; CORE_ADDR sym_addr; @@ -242,7 +242,7 @@ Index: gdb-7.4.50.20120103/gdb/solib-svr4.c + for (i = 0; i < NUM_PROBES; i++) + { -+ VEC_free (stap_probe_p, info->probes[i]); ++ VEC_free (probe_p, info->probes[i]); + info->probes[i] = NULL; + } + info->using_probes = 0; @@ -250,7 +250,7 @@ Index: gdb-7.4.50.20120103/gdb/solib-svr4.c /* If we already have a shared library list in the target, and r_debug contains r_brk, set the breakpoint there - this should mean r_brk has already been relocated. Assume the dynamic linker -@@ -1528,7 +1697,7 @@ enable_break (struct svr4_info *info, in +@@ -1532,7 +1701,7 @@ enable_break (struct svr4_info *info, in That knowledge is encoded in the address, if it's Thumb the low bit is 1. However, we've stripped that info above and it's not clear what all the consequences are of passing a non-addr_bits_remove'd @@ -259,7 +259,7 @@ Index: gdb-7.4.50.20120103/gdb/solib-svr4.c find_pc_section verifies we know about the address and have some hope of computing the right kind of breakpoint to use (via symbol info). It does mean that GDB needs to be pointed at a -@@ -1566,7 +1735,7 @@ enable_break (struct svr4_info *info, in +@@ -1570,7 +1739,7 @@ enable_break (struct svr4_info *info, in + bfd_section_size (tmp_bfd, interp_sect); } @@ -268,7 +268,7 @@ Index: gdb-7.4.50.20120103/gdb/solib-svr4.c return 1; } } -@@ -1721,7 +1890,8 @@ enable_break (struct svr4_info *info, in +@@ -1725,7 +1894,8 @@ enable_break (struct svr4_info *info, in if (sym_addr != 0) { @@ -278,7 +278,7 @@ Index: gdb-7.4.50.20120103/gdb/solib-svr4.c xfree (interp_name); return 1; } -@@ -1747,7 +1917,7 @@ enable_break (struct svr4_info *info, in +@@ -1751,7 +1921,7 @@ enable_break (struct svr4_info *info, in sym_addr = gdbarch_convert_from_func_ptr_addr (target_gdbarch, sym_addr, ¤t_target); @@ -287,7 +287,7 @@ Index: gdb-7.4.50.20120103/gdb/solib-svr4.c return 1; } } -@@ -1763,7 +1933,7 @@ enable_break (struct svr4_info *info, in +@@ -1767,7 +1937,7 @@ enable_break (struct svr4_info *info, in sym_addr = gdbarch_convert_from_func_ptr_addr (target_gdbarch, sym_addr, ¤t_target); @@ -296,17 +296,17 @@ Index: gdb-7.4.50.20120103/gdb/solib-svr4.c return 1; } } -@@ -2539,4 +2709,5 @@ _initialize_svr4_solib (void) +@@ -2543,4 +2713,5 @@ _initialize_svr4_solib (void) svr4_so_ops.lookup_lib_global_symbol = elf_lookup_lib_symbol; svr4_so_ops.same = svr4_same; svr4_so_ops.keep_data_in_core = svr4_keep_data_in_core; + svr4_so_ops.update_breakpoints = svr4_update_solib_event_breakpoints; } -Index: gdb-7.4.50.20120103/gdb/solib.c +Index: gdb-7.4.50.20120602/gdb/solib.c =================================================================== ---- gdb-7.4.50.20120103.orig/gdb/solib.c 2012-01-04 00:26:15.000000000 +0100 -+++ gdb-7.4.50.20120103/gdb/solib.c 2012-01-04 00:29:07.751200038 +0100 -@@ -1214,6 +1214,18 @@ no_shared_libraries (char *ignored, int +--- gdb-7.4.50.20120602.orig/gdb/solib.c 2012-06-02 21:38:07.236442883 +0200 ++++ gdb-7.4.50.20120602/gdb/solib.c 2012-06-02 21:38:13.455440507 +0200 +@@ -1216,6 +1216,18 @@ no_shared_libraries (char *ignored, int objfile_purge_solibs (); } @@ -325,23 +325,23 @@ Index: gdb-7.4.50.20120103/gdb/solib.c /* Reload shared libraries, but avoid reloading the same symbol file we already have loaded. */ -Index: gdb-7.4.50.20120103/gdb/solib.h +Index: gdb-7.4.50.20120602/gdb/solib.h =================================================================== ---- gdb-7.4.50.20120103.orig/gdb/solib.h 2011-08-30 04:48:05.000000000 +0200 -+++ gdb-7.4.50.20120103/gdb/solib.h 2012-01-04 00:27:40.415533686 +0100 -@@ -91,4 +91,8 @@ extern CORE_ADDR bfd_lookup_symbol_from_ - void *), - void *data); +--- gdb-7.4.50.20120602.orig/gdb/solib.h 2012-06-02 21:38:07.236442883 +0200 ++++ gdb-7.4.50.20120602/gdb/solib.h 2012-06-02 21:38:13.464440503 +0200 +@@ -91,4 +91,8 @@ extern CORE_ADDR gdb_bfd_lookup_symbol_f + void *), + void *data); +/* Enable or disable optional solib event breakpoints as appropriate. */ + +extern void update_solib_breakpoints (void); + #endif /* SOLIB_H */ -Index: gdb-7.4.50.20120103/gdb/solist.h +Index: gdb-7.4.50.20120602/gdb/solist.h =================================================================== ---- gdb-7.4.50.20120103.orig/gdb/solist.h 2011-08-09 14:51:47.000000000 +0200 -+++ gdb-7.4.50.20120103/gdb/solist.h 2012-01-04 00:26:21.962833383 +0100 +--- gdb-7.4.50.20120602.orig/gdb/solist.h 2012-06-02 21:38:07.236442883 +0200 ++++ gdb-7.4.50.20120602/gdb/solist.h 2012-06-02 21:38:13.465440503 +0200 @@ -149,6 +149,13 @@ struct target_so_ops core file (in particular, for readonly sections). */ int (*keep_data_in_core) (CORE_ADDR vaddr, diff --git a/gdb-exit-warning.patch b/gdb-exit-warning.patch deleted file mode 100644 index 653cc15..0000000 --- a/gdb-exit-warning.patch +++ /dev/null @@ -1,93 +0,0 @@ -http://sourceware.org/ml/gdb-patches/2012-02/msg00664.html -Subject: RFA: fix PR breakpoints/13776 - -I'd appreciate comments on this patch. -I have no idea whether it is the best way to fix the problem. - -Bug 13776 concerns 'next'ing over an exit. For the trivial: - - #include - int - main (void) - { - exit (0); - } - -We get this behavior: - - (gdb) start - Temporary breakpoint 1, main () at exit0.c:5 - 5 exit (0); - (gdb) next - [Inferior 1 (process 2428) exited normally] - warning: Error removing breakpoint 0 - warning: Error removing breakpoint 0 - warning: Error removing breakpoint 0 - -The bug is that exit_inferior ends up calling delete_longjmp_breakpoint, -which tries to delete the longjmp breakpoints -- but as the inferior is -dead, this fails. - -This patch fixes this problem by moving the breakpoint_init_inferior -call earlier in generic_mourn_inferior. This causes the breakpoints to -be marked as uninserted before they are deleted. - -While doing this I noticed that after the inferior exits, we are left -with a step-resume breakpoint: - -(gdb) maint info b -Num Type Disp Enb Address What -[...] -0 step resume dstp y 0x00000000004004d2 inf 1 thread 1 - stop only in thread 1 - -The breakpoint.c patch causes this to be removed as well. - -Built and regtested on x86-64 Fedora 16. - -Tom - -2012-02-28 Tom Tromey - - PR breakpoints/13776: - * target.c (generic_mourn_inferior): Call breakpoint_init_inferior - earlier. - * breakpoint.c (breakpoint_init_inferior): Delete step-resume - breakpoints. - -diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c -index db05b97..048cc63 100644 ---- a/gdb/breakpoint.c -+++ b/gdb/breakpoint.c -@@ -3341,6 +3341,10 @@ breakpoint_init_inferior (enum inf_context context) - (gdb) tar rem :9999 # remote Windows gdbserver. - */ - -+ case bp_step_resume: -+ -+ /* Also remove step-resume breakpoints. */ -+ - delete_breakpoint (b); - break; - -diff --git a/gdb/target.c b/gdb/target.c -index 1f408f6..65a6c23 100644 ---- a/gdb/target.c -+++ b/gdb/target.c -@@ -3583,13 +3583,14 @@ generic_mourn_inferior (void) - ptid = inferior_ptid; - inferior_ptid = null_ptid; - -+ breakpoint_init_inferior (inf_exited); -+ - if (!ptid_equal (ptid, null_ptid)) - { - int pid = ptid_get_pid (ptid); - exit_inferior (pid); - } - -- breakpoint_init_inferior (inf_exited); - registers_changed (); - - reopen_exec_file (); - diff --git a/gdb-expand-cxx-accel.patch b/gdb-expand-cxx-accel.patch deleted file mode 100644 index 2737bfd..0000000 --- a/gdb-expand-cxx-accel.patch +++ /dev/null @@ -1,46 +0,0 @@ -https://bugzilla.redhat.com/show_bug.cgi?id=787487 -http://sourceware.org/ml/gdb-patches/2012-02/msg00112.html -Subject: RFC: extend symtabs_from_filename skipping for C++ - -I'd appreciate comments on this. Barring comments I will check it in -after a couple days. - -A while ago Doug committed a patch to change linespec to skip -symtabs_from_filename when possible. This was an important performance -improvement. - -We got a bug report in Red Hat bugzilla asking that this be extended to -C++ qualified names: - - https://bugzilla.redhat.com/show_bug.cgi?id=787487 - -This patch implements this idea. - -Built and regtested on x86-64 Fedora 15. - -Tom - -2012-02-08 Tom Tromey - - * linespec.c (decode_line_internal): Skip symtabs_from_filename - when we have a C++ qualified name. - -diff --git a/gdb/linespec.c b/gdb/linespec.c -index da88d17..3f53b8e 100644 ---- a/gdb/linespec.c -+++ b/gdb/linespec.c -@@ -912,9 +912,11 @@ decode_line_internal (struct linespec_state *self, char **argptr) - /* First things first: if ARGPTR starts with a filename, get its - symtab and strip the filename from ARGPTR. - Avoid calling symtab_from_filename if we know can, -- it can be expensive. */ -+ it can be expensive. We know we can avoid the call if we see a -+ single word (e.g., "break NAME") or if we see a qualified C++ -+ name ("break QUAL::NAME"). */ - -- if (*p != '\0') -+ if (*p != '\0' && p[1] != ':') - { - TRY_CATCH (file_exception, RETURN_MASK_ERROR) - { - diff --git a/gdb-fortran-common-reduce.patch b/gdb-fortran-common-reduce.patch index fe1199f..238b355 100644 --- a/gdb-fortran-common-reduce.patch +++ b/gdb-fortran-common-reduce.patch @@ -1,8 +1,8 @@ -Index: gdb-7.2.50.20110117/gdb/f-lang.c +Index: gdb-7.4.50.20120602/gdb/f-lang.c =================================================================== ---- 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, +--- gdb-7.4.50.20120602.orig/gdb/f-lang.c 2012-03-02 20:29:00.000000000 +0100 ++++ gdb-7.4.50.20120602/gdb/f-lang.c 2012-06-02 19:13:31.520050654 +0200 +@@ -59,20 +59,6 @@ typedef struct saved_bf_symnum SAVED_BF, /* Local functions */ extern void _initialize_f_language (void); @@ -23,7 +23,7 @@ Index: gdb-7.2.50.20110117/gdb/f-lang.c static void f_printchar (int c, struct type *type, struct ui_file * stream); static void f_emit_char (int c, struct type *type, -@@ -461,185 +447,7 @@ _initialize_f_language (void) +@@ -385,185 +371,7 @@ _initialize_f_language (void) add_language (&f_language_defn); } @@ -209,7 +209,7 @@ Index: gdb-7.2.50.20110117/gdb/f-lang.c /* This routine finds the first encountred COMMON block named "name" that belongs to function funcname. */ -@@ -662,193 +470,3 @@ find_common_for_function (char *name, ch +@@ -586,193 +394,3 @@ find_common_for_function (const char *na } return (NULL); } @@ -403,18 +403,19 @@ Index: gdb-7.2.50.20110117/gdb/f-lang.c - saved_function_list = NULL; -} -#endif -Index: gdb-7.2.50.20110117/gdb/f-lang.h +Index: gdb-7.4.50.20120602/gdb/f-lang.h =================================================================== ---- 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 +--- gdb-7.4.50.20120602.orig/gdb/f-lang.h 2012-06-02 19:11:54.000000000 +0200 ++++ gdb-7.4.50.20120602/gdb/f-lang.h 2012-06-02 19:13:55.345317970 +0200 +@@ -76,15 +76,10 @@ typedef struct saved_f77_common SAVED_F7 typedef struct common_entry COMMON_ENTRY, *COMMON_ENTRY_PTR; extern SAVED_F77_COMMON_PTR head_common_list; /* Ptr to 1st saved COMMON */ -extern SAVED_F77_COMMON_PTR tail_common_list; /* Ptr to last saved COMMON */ -extern SAVED_F77_COMMON_PTR current_common; /* Ptr to current COMMON */ - extern SAVED_F77_COMMON_PTR find_common_for_function (char *, char *); + extern SAVED_F77_COMMON_PTR find_common_for_function (const char *, + const char *); -#define UNINITIALIZED_SECNUM -1 -#define COMMON_NEEDS_PATCHING(blk) ((blk)->secnum == UNINITIALIZED_SECNUM) @@ -422,10 +423,10 @@ Index: gdb-7.2.50.20110117/gdb/f-lang.h #define BLANK_COMMON_NAME_ORIGINAL "#BLNK_COM" /* XLF assigned */ #define BLANK_COMMON_NAME_MF77 "__BLNK__" /* MF77 assigned */ #define BLANK_COMMON_NAME_LOCAL "__BLANK" /* Local GDB */ -Index: gdb-7.2.50.20110117/gdb/f-valprint.c +Index: gdb-7.4.50.20120602/gdb/f-valprint.c =================================================================== ---- 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 +--- gdb-7.4.50.20120602.orig/gdb/f-valprint.c 2012-06-02 19:11:54.000000000 +0200 ++++ gdb-7.4.50.20120602/gdb/f-valprint.c 2012-06-02 19:14:11.625313432 +0200 @@ -35,10 +35,6 @@ #include "command.h" #include "block.h" @@ -436,8 +437,8 @@ Index: gdb-7.2.50.20110117/gdb/f-valprint.c - extern void _initialize_f_valprint (void); static void info_common_command (char *, int); - static void list_all_visible_commons (char *); -@@ -604,67 +600,6 @@ info_common_command (char *comname, int + static void list_all_visible_commons (const char *); +@@ -535,67 +531,6 @@ info_common_command (char *comname, int comname, funname); } diff --git a/gdb-fortran-common.patch b/gdb-fortran-common.patch index 66d46b9..778c8cf 100644 --- a/gdb-fortran-common.patch +++ b/gdb-fortran-common.patch @@ -1,8 +1,8 @@ -Index: gdb-7.3.50.20110722/gdb/dwarf2read.c +Index: gdb-7.4.50.20120602/gdb/dwarf2read.c =================================================================== ---- gdb-7.3.50.20110722.orig/gdb/dwarf2read.c 2011-07-22 20:12:05.000000000 +0200 -+++ gdb-7.3.50.20110722/gdb/dwarf2read.c 2011-07-22 20:17:22.000000000 +0200 -@@ -7969,12 +7969,14 @@ read_set_type (struct die_info *die, str +--- gdb-7.4.50.20120602.orig/gdb/dwarf2read.c 2012-06-02 21:32:41.746567299 +0200 ++++ gdb-7.4.50.20120602/gdb/dwarf2read.c 2012-06-02 21:32:54.304562500 +0200 +@@ -9736,12 +9736,14 @@ read_set_type (struct die_info *die, str return set_die_type (die, set_type, cu); } @@ -19,7 +19,7 @@ Index: gdb-7.3.50.20110722/gdb/dwarf2read.c struct attribute *attr; struct symbol *sym; CORE_ADDR base = (CORE_ADDR) 0; -@@ -7999,20 +8001,67 @@ read_common_block (struct die_info *die, +@@ -9766,20 +9768,67 @@ read_common_block (struct die_info *die, } if (die->child != NULL) { @@ -87,7 +87,7 @@ Index: gdb-7.3.50.20110722/gdb/dwarf2read.c } } -@@ -11695,6 +11744,13 @@ new_symbol_full (struct die_info *die, s +@@ -13661,6 +13710,13 @@ new_symbol_full (struct die_info *die, s { var_decode_location (attr, sym, cu); attr2 = dwarf2_attr (die, DW_AT_external, cu); @@ -101,7 +101,7 @@ Index: gdb-7.3.50.20110722/gdb/dwarf2read.c if (SYMBOL_CLASS (sym) == LOC_STATIC && SYMBOL_VALUE_ADDRESS (sym) == 0 && !dwarf2_per_objfile->has_section_at_zero) -@@ -11867,6 +11923,11 @@ new_symbol_full (struct die_info *die, s +@@ -13825,6 +13881,11 @@ new_symbol_full (struct die_info *die, s SYMBOL_CLASS (sym) = LOC_TYPEDEF; list_to_add = &global_symbols; break; @@ -113,11 +113,11 @@ Index: gdb-7.3.50.20110722/gdb/dwarf2read.c default: /* Not a tag we recognize. Hopefully we aren't processing trash data, but since we must specifically ignore things -Index: gdb-7.3.50.20110722/gdb/f-lang.c +Index: gdb-7.4.50.20120602/gdb/f-lang.c =================================================================== ---- gdb-7.3.50.20110722.orig/gdb/f-lang.c 2011-07-22 20:17:16.000000000 +0200 -+++ gdb-7.3.50.20110722/gdb/f-lang.c 2011-07-22 20:17:22.000000000 +0200 -@@ -371,27 +371,3 @@ _initialize_f_language (void) +--- gdb-7.4.50.20120602.orig/gdb/f-lang.c 2012-06-02 21:32:41.746567299 +0200 ++++ gdb-7.4.50.20120602/gdb/f-lang.c 2012-06-02 21:32:54.305562499 +0200 +@@ -370,27 +370,3 @@ _initialize_f_language (void) add_language (&f_language_defn); } @@ -128,7 +128,7 @@ Index: gdb-7.3.50.20110722/gdb/f-lang.c - that belongs to function funcname. */ - -SAVED_F77_COMMON_PTR --find_common_for_function (char *name, char *funcname) +-find_common_for_function (const char *name, const char *funcname) -{ - - SAVED_F77_COMMON_PTR tmp; @@ -145,11 +145,11 @@ Index: gdb-7.3.50.20110722/gdb/f-lang.c - } - return (NULL); -} -Index: gdb-7.3.50.20110722/gdb/f-lang.h +Index: gdb-7.4.50.20120602/gdb/f-lang.h =================================================================== ---- gdb-7.3.50.20110722.orig/gdb/f-lang.h 2011-07-22 20:17:16.000000000 +0200 -+++ gdb-7.3.50.20110722/gdb/f-lang.h 2011-07-22 20:17:22.000000000 +0200 -@@ -52,36 +52,8 @@ enum f90_range_type +--- gdb-7.4.50.20120602.orig/gdb/f-lang.h 2012-06-02 21:32:41.746567299 +0200 ++++ gdb-7.4.50.20120602/gdb/f-lang.h 2012-06-02 21:32:54.322562493 +0200 +@@ -52,37 +52,8 @@ enum f90_range_type NONE_BOUND_DEFAULT /* "(low:high)" */ }; @@ -178,7 +178,8 @@ Index: gdb-7.3.50.20110722/gdb/f-lang.h - -extern SAVED_F77_COMMON_PTR head_common_list; /* Ptr to 1st saved COMMON */ - --extern SAVED_F77_COMMON_PTR find_common_for_function (char *, char *); +-extern SAVED_F77_COMMON_PTR find_common_for_function (const char *, +- const char *); - #define BLANK_COMMON_NAME_ORIGINAL "#BLNK_COM" /* XLF assigned */ #define BLANK_COMMON_NAME_MF77 "__BLNK__" /* MF77 assigned */ @@ -186,10 +187,10 @@ Index: gdb-7.3.50.20110722/gdb/f-lang.h /* 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.3.50.20110722/gdb/f-valprint.c +Index: gdb-7.4.50.20120602/gdb/f-valprint.c =================================================================== ---- gdb-7.3.50.20110722.orig/gdb/f-valprint.c 2011-07-22 20:17:16.000000000 +0200 -+++ gdb-7.3.50.20110722/gdb/f-valprint.c 2011-07-22 20:18:26.000000000 +0200 +--- gdb-7.4.50.20120602.orig/gdb/f-valprint.c 2012-06-02 21:32:41.746567299 +0200 ++++ gdb-7.4.50.20120602/gdb/f-valprint.c 2012-06-02 21:33:50.514541286 +0200 @@ -34,10 +34,11 @@ #include "gdbcore.h" #include "command.h" @@ -199,16 +200,16 @@ Index: gdb-7.3.50.20110722/gdb/f-valprint.c extern void _initialize_f_valprint (void); static void info_common_command (char *, int); --static void list_all_visible_commons (char *); +-static void list_all_visible_commons (const char *); static void f77_create_arrayprint_offset_tbl (struct type *, struct ui_file *); static void f77_get_dynamic_length_of_aggregate (struct type *); -@@ -515,22 +516,54 @@ f_val_print (struct type *type, const gd - return 0; +@@ -420,22 +421,54 @@ f_val_print (struct type *type, const gd + gdb_flush (stream); } -static void --list_all_visible_commons (char *funname) +-list_all_visible_commons (const char *funname) +static int +info_common_command_for_block (struct block *block, struct frame_info *frame, + const char *comname) @@ -216,7 +217,7 @@ Index: gdb-7.3.50.20110722/gdb/f-valprint.c - SAVED_F77_COMMON_PTR tmp; - - tmp = head_common_list; -+ struct dict_iterator iter; ++ struct block_iterator iter; + struct symbol *sym; + int values_printed = 0; + const char *name; @@ -271,21 +272,21 @@ Index: gdb-7.3.50.20110722/gdb/f-valprint.c } /* This function is used to print out the values in a given COMMON -@@ -540,11 +573,9 @@ list_all_visible_commons (char *funname) +@@ -445,11 +478,9 @@ list_all_visible_commons (const char *fu static void info_common_command (char *comname, int from_tty) { - SAVED_F77_COMMON_PTR the_common; - COMMON_ENTRY_PTR entry; struct frame_info *fi; -- char *funname = 0; +- const char *funname = 0; - struct symbol *func; + struct block *block; + int values_printed = 0; /* We have been told to display the contents of F77 COMMON block supposedly visible in this function. Let us -@@ -556,74 +587,31 @@ info_common_command (char *comname, int +@@ -461,74 +492,31 @@ info_common_command (char *comname, int /* The following is generally ripped off from stack.c's routine print_frame_info(). */ @@ -376,11 +377,11 @@ Index: gdb-7.3.50.20110722/gdb/f-valprint.c } void -Index: gdb-7.3.50.20110722/gdb/stack.c +Index: gdb-7.4.50.20120602/gdb/stack.c =================================================================== ---- gdb-7.3.50.20110722.orig/gdb/stack.c 2011-07-22 20:12:05.000000000 +0200 -+++ gdb-7.3.50.20110722/gdb/stack.c 2011-07-22 20:17:22.000000000 +0200 -@@ -1524,6 +1524,8 @@ iterate_over_block_locals (struct block +--- gdb-7.4.50.20120602.orig/gdb/stack.c 2012-06-02 21:32:41.746567299 +0200 ++++ gdb-7.4.50.20120602/gdb/stack.c 2012-06-02 21:32:54.335562488 +0200 +@@ -1838,6 +1838,8 @@ iterate_over_block_locals (struct block case LOC_COMPUTED: if (SYMBOL_IS_ARGUMENT (sym)) break; @@ -389,11 +390,11 @@ Index: gdb-7.3.50.20110722/gdb/stack.c (*cb) (SYMBOL_PRINT_NAME (sym), sym, cb_data); break; -Index: gdb-7.3.50.20110722/gdb/symtab.h +Index: gdb-7.4.50.20120602/gdb/symtab.h =================================================================== ---- gdb-7.3.50.20110722.orig/gdb/symtab.h 2011-07-22 20:12:05.000000000 +0200 -+++ gdb-7.3.50.20110722/gdb/symtab.h 2011-07-22 20:18:58.000000000 +0200 -@@ -396,7 +396,10 @@ typedef enum domain_enum_tag +--- gdb-7.4.50.20120602.orig/gdb/symtab.h 2012-06-02 21:32:41.746567299 +0200 ++++ gdb-7.4.50.20120602/gdb/symtab.h 2012-06-02 21:32:54.342562486 +0200 +@@ -389,7 +389,10 @@ typedef enum domain_enum_tag /* LABEL_DOMAIN may be used for names of labels (for gotos). */ @@ -405,10 +406,10 @@ Index: gdb-7.3.50.20110722/gdb/symtab.h } domain_enum; /* Searching domains, used for `search_symbols'. Element numbers are -Index: gdb-7.3.50.20110722/gdb/testsuite/gdb.fortran/common-block.exp +Index: gdb-7.4.50.20120602/gdb/testsuite/gdb.fortran/common-block.exp =================================================================== --- /dev/null 1970-01-01 00:00:00.000000000 +0000 -+++ gdb-7.3.50.20110722/gdb/testsuite/gdb.fortran/common-block.exp 2011-07-22 20:17:22.000000000 +0200 ++++ gdb-7.4.50.20120602/gdb/testsuite/gdb.fortran/common-block.exp 2012-06-02 21:32:54.344562484 +0200 @@ -0,0 +1,101 @@ +# Copyright 2008 Free Software Foundation, Inc. + @@ -511,10 +512,10 @@ Index: gdb-7.3.50.20110722/gdb/testsuite/gdb.fortran/common-block.exp +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.3.50.20110722/gdb/testsuite/gdb.fortran/common-block.f90 +Index: gdb-7.4.50.20120602/gdb/testsuite/gdb.fortran/common-block.f90 =================================================================== --- /dev/null 1970-01-01 00:00:00.000000000 +0000 -+++ gdb-7.3.50.20110722/gdb/testsuite/gdb.fortran/common-block.f90 2011-07-22 20:17:22.000000000 +0200 ++++ gdb-7.4.50.20120602/gdb/testsuite/gdb.fortran/common-block.f90 2012-06-02 21:32:54.345562483 +0200 @@ -0,0 +1,67 @@ +! Copyright 2008 Free Software Foundation, Inc. +! diff --git a/gdb-objfile-order.patch b/gdb-objfile-order.patch new file mode 100644 index 0000000..afd46e7 --- /dev/null +++ b/gdb-objfile-order.patch @@ -0,0 +1,215 @@ +http://sourceware.org/ml/gdb-patches/2012-05/msg01105.html +Subject: [RFA/commit 1/3] Revert "Search global symbols from the expression's block objfile first." + +The search order used in this patch breaks global symbol lookups +for certain symbols when copy-relocation is used. A slightly different +search order will be implemented later. + +gdb/ChangeLog: + + Revert the following patch: + * findvar.c (default_read_var_value): For LOC_UNRESOLVED symbols, + try locating the symbol in the symbol's own objfile first, before + extending the search to all objfiles. + * symtab.c (lookup_symbol_aux_objfile): New function, extracted + out of lookup_symbol_aux_symtabs. + (lookup_symbol_aux_symtabs): Add new parameter "exclude_objfile". + Replace extracted-out code by call to lookup_symbol_aux_objfile. + Do not search EXCLUDE_OBJFILE. + (lookup_static_symbol_aux): Update call to lookup_symbol_aux_symtabs. + (lookup_symbol_global): Search for matches in the block's objfile + first, before searching all other objfiles. + +Will commit if patches #2 & #3 are OK. + +--- + gdb/findvar.c | 10 +----- + gdb/symtab.c | 108 +++++++++++++++++---------------------------------------- + 2 files changed, 33 insertions(+), 85 deletions(-) + +diff --git a/gdb/findvar.c b/gdb/findvar.c +index ed7903c..9009e6f 100644 +--- a/gdb/findvar.c ++++ b/gdb/findvar.c +@@ -562,15 +562,7 @@ default_read_var_value (struct symbol *var, struct frame_info *frame) + struct minimal_symbol *msym; + struct obj_section *obj_section; + +- /* First, try locating the associated minimal symbol within +- the same objfile. This prevents us from selecting another +- symbol with the same name but located in a different objfile. */ +- msym = lookup_minimal_symbol (SYMBOL_LINKAGE_NAME (var), NULL, +- SYMBOL_SYMTAB (var)->objfile); +- /* If the lookup failed, try expanding the search to all +- objfiles. */ +- if (msym == NULL) +- msym = lookup_minimal_symbol (SYMBOL_LINKAGE_NAME (var), NULL, NULL); ++ msym = lookup_minimal_symbol (SYMBOL_LINKAGE_NAME (var), NULL, NULL); + if (msym == NULL) + error (_("No global symbol \"%s\"."), SYMBOL_LINKAGE_NAME (var)); + if (overlay_debugging) +diff --git a/gdb/symtab.c b/gdb/symtab.c +index 85ddd1d..39d8c6f 100644 +--- a/gdb/symtab.c ++++ b/gdb/symtab.c +@@ -95,8 +95,7 @@ struct symbol *lookup_symbol_aux_local (const char *name, + static + struct symbol *lookup_symbol_aux_symtabs (int block_index, + const char *name, +- const domain_enum domain, +- struct objfile *exclude_objfile); ++ const domain_enum domain); + + static + struct symbol *lookup_symbol_aux_quick (struct objfile *objfile, +@@ -1360,7 +1359,7 @@ lookup_static_symbol_aux (const char *name, const domain_enum domain) + struct objfile *objfile; + struct symbol *sym; + +- sym = lookup_symbol_aux_symtabs (STATIC_BLOCK, name, domain, NULL); ++ sym = lookup_symbol_aux_symtabs (STATIC_BLOCK, name, domain); + if (sym != NULL) + return sym; + +@@ -1499,61 +1498,40 @@ lookup_global_symbol_from_objfile (const struct objfile *main_objfile, + return NULL; + } + +-/* Check to see if the symbol is defined in one of the OBJFILE's +- symtabs. BLOCK_INDEX should be either GLOBAL_BLOCK or STATIC_BLOCK, ++/* Check to see if the symbol is defined in one of the symtabs. ++ BLOCK_INDEX should be either GLOBAL_BLOCK or STATIC_BLOCK, + depending on whether or not we want to search global symbols or + static symbols. */ + + static struct symbol * +-lookup_symbol_aux_objfile (struct objfile *objfile, int block_index, +- const char *name, const domain_enum domain) +-{ +- struct symbol *sym = NULL; +- struct blockvector *bv; +- const struct block *block; +- struct symtab *s; +- +- if (objfile->sf) +- objfile->sf->qf->pre_expand_symtabs_matching (objfile, block_index, +- name, domain); +- +- 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; +-} +- +-/* Same as lookup_symbol_aux_objfile, except that it searches all +- objfiles except for EXCLUDE_OBJFILE. Return the first match found. +- +- If EXCLUDE_OBJFILE is NULL, then all objfiles are searched. */ +- +-static struct symbol * + lookup_symbol_aux_symtabs (int block_index, const char *name, +- const domain_enum domain, +- struct objfile *exclude_objfile) ++ const domain_enum domain) + { + struct symbol *sym; + struct objfile *objfile; ++ struct blockvector *bv; ++ const struct block *block; ++ struct symtab *s; + + ALL_OBJFILES (objfile) + { +- if (objfile != exclude_objfile) +- { +- sym = lookup_symbol_aux_objfile (objfile, block_index, name, domain); +- if (sym) +- return sym; +- } ++ if (objfile->sf) ++ objfile->sf->qf->pre_expand_symtabs_matching (objfile, ++ block_index, ++ name, domain); ++ ++ 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; +@@ -1679,46 +1657,24 @@ lookup_symbol_global (const char *name, + const domain_enum domain) + { + struct symbol *sym = NULL; +- struct objfile *block_objfile = NULL; + struct objfile *objfile = NULL; + + /* Call library-specific lookup procedure. */ +- block_objfile = lookup_objfile_from_block (block); +- if (block_objfile != NULL) +- sym = solib_global_lookup (block_objfile, name, domain); ++ objfile = lookup_objfile_from_block (block); ++ if (objfile != NULL) ++ sym = solib_global_lookup (objfile, name, domain); + if (sym != NULL) + return sym; + +- /* If BLOCK_OBJFILE is not NULL, then search this objfile first. +- In case the global symbol is defined in multiple objfiles, +- we have a better chance of finding the most relevant symbol. */ +- +- if (block_objfile != NULL) +- { +- sym = lookup_symbol_aux_objfile (block_objfile, GLOBAL_BLOCK, +- name, domain); +- if (sym == NULL) +- sym = lookup_symbol_aux_quick (block_objfile, GLOBAL_BLOCK, +- name, domain); +- if (sym != NULL) +- return sym; +- } +- +- /* Symbol not found in the BLOCK_OBJFILE, so try all the other +- objfiles, starting with symtabs first, and then partial symtabs. */ +- +- sym = lookup_symbol_aux_symtabs (GLOBAL_BLOCK, name, domain, block_objfile); ++ sym = lookup_symbol_aux_symtabs (GLOBAL_BLOCK, name, domain); + if (sym != NULL) + return sym; + + ALL_OBJFILES (objfile) + { +- if (objfile != block_objfile) +- { +- sym = lookup_symbol_aux_quick (objfile, GLOBAL_BLOCK, name, domain); +- if (sym) +- return sym; +- } ++ sym = lookup_symbol_aux_quick (objfile, GLOBAL_BLOCK, name, domain); ++ if (sym) ++ return sym; + } + + return NULL; +-- +1.7.1 + diff --git a/gdb-ppc-watchpoint.patch b/gdb-ppc-watchpoint.patch deleted file mode 100644 index 1556883..0000000 --- a/gdb-ppc-watchpoint.patch +++ /dev/null @@ -1,50 +0,0 @@ -https://bugzilla.redhat.com/show_bug.cgi?id=827600 -Re: [PATCH] disable ptrace BookE interface for PowerPC server processors -http://sourceware.org/ml/gdb-patches/2012-05/msg01107.html -http://sourceware.org/ml/gdb-cvs/2012-05/msg00221.html - -### src/gdb/ChangeLog 2012/05/31 18:44:47 1.14306 -### src/gdb/ChangeLog 2012/05/31 22:07:29 1.14307 -## -1,3 +1,9 @@ -+2012-05-31 Edjunior Machado -+ -+ * ppc-linux-nat.c (have_ptrace_booke_interface): Disable ptrace -+ BookE interface for PowerPC server processors if not available -+ in the Linux Kernel. -+ - 2012-05-31 Keith Seitz - - * linespec.c (decode_objc): Add cleanup to free ---- src/gdb/ppc-linux-nat.c 2012/05/30 13:37:17 1.112 -+++ src/gdb/ppc-linux-nat.c 2012/05/31 22:07:31 1.113 -@@ -1421,17 +1421,20 @@ - /* Check for kernel support for BOOKE debug registers. */ - if (ptrace (PPC_PTRACE_GETHWDBGINFO, tid, 0, &booke_debug_info) >= 0) - { -- have_ptrace_booke_interface = 1; -- max_slots_number = booke_debug_info.num_instruction_bps -- + booke_debug_info.num_data_bps -- + booke_debug_info.num_condition_regs; -- } -- else -- { -- /* Old school interface and no BOOKE debug registers support. */ -- have_ptrace_booke_interface = 0; -- memset (&booke_debug_info, 0, sizeof (struct ppc_debug_info)); -+ /* Check whether ptrace BOOKE interface is functional and -+ provides any supported feature. */ -+ if (booke_debug_info.features != 0) -+ { -+ have_ptrace_booke_interface = 1; -+ max_slots_number = booke_debug_info.num_instruction_bps -+ + booke_debug_info.num_data_bps -+ + booke_debug_info.num_condition_regs; -+ return have_ptrace_booke_interface; -+ } - } -+ /* Old school interface and no BOOKE debug registers support. */ -+ have_ptrace_booke_interface = 0; -+ memset (&booke_debug_info, 0, sizeof (struct ppc_debug_info)); - } - - return have_ptrace_booke_interface; diff --git a/gdb-prologue-not-skipped.patch b/gdb-prologue-not-skipped.patch deleted file mode 100644 index da5ce13..0000000 --- a/gdb-prologue-not-skipped.patch +++ /dev/null @@ -1,102 +0,0 @@ -http://sourceware.org/ml/gdb-patches/2012-02/msg00673.html -Subject: [patch] Fix regression by me for gcc-4.0...gcc-4.4 i386 -O2 -g parameters (PR 13777) - -Hi, - -http://sourceware.org/bugzilla/show_bug.cgi?id=13777 - -for CentOS-5 i386 ls: - -$ gdb ls -(gdb) start -Temporary breakpoint 1, main (argc=Cannot access memory at address 0x81b7c7cd - -instead of GDB before my PR 12573 fix/change: - -Temporary breakpoint 1, main (argc=1, ... - -I asked before on #gcc since which versions GCC produced DW_AT_location which -is for any PC either optimized-out or it has valid value. I was told since -gcc-4.0. But that is not true. - -I have bisected gcc and I found 4.4.0 was still broken, 4.5.0 was correct, -thanks to: -commit 25e880b1917bd6bbf07e86b5574c698f3e9472d9 -Author: rth -Date: Sat May 30 00:33:46 2009 +0000 -git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@147995 138bc75d-0d04-0410-961f-82ee72b054a4 -unwind info for epilogues - -Curiously 4.4.x branch got later also fixed in this case by: -commit 61db8bd232daeed3751b43570fab16146145e096 -Author: jakub -Date: Tue Jun 2 07:18:16 2009 +0000 -git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-4_4-branch@148070 138bc75d-0d04-0410-961f-82ee72b054a4 -(but that missed 4.4.0) - -As 4.5.0 was first FSF GCC with VTA I was trusting more the validity only -after VTA and these heuristic results seems to confirm that. - -I find the change below definitely safe. - -Someone may object the original PR 12573 (do not try to skip prologue for -O2 --g code as it may cause more confusion than anything else) as while it fixed -some GDB crashes there is no such purpose anymore with Tom's -ambiguous-linespec patch. Still I believe PR 12573 was right to do. - -No regressions on {x86_64,x86_64-m32,i686}-fedora17-linux-gnu. - -I will check it in. - - -Thanks, -Jan - - -gdb/ -2012-02-28 Jan Kratochvil - - PR symtab/13777 - * dwarf2read.c (process_full_comp_unit): Set LOCATIONS_VALID only for - GCC >=4.5. - -gdb/testsuite/ -2012-02-28 Jan Kratochvil - - PR symtab/13777 - * gdb.dwarf2/dw2-skip-prologue.S (DW_AT_producer): Set it to 4.5.0. - ---- a/gdb/dwarf2read.c -+++ b/gdb/dwarf2read.c -@@ -4841,7 +4841,9 @@ process_full_comp_unit (struct dwarf2_per_cu_data *per_cu) - - /* GCC-4.0 has started to support -fvar-tracking. GCC-3.x still can - produce DW_AT_location with location lists but it can be possibly -- invalid without -fvar-tracking. -+ invalid without -fvar-tracking. Still up to GCC-4.4.x incl. 4.4.0 -+ there were bugs in prologue debug info, fixed later in GCC-4.5 -+ by "unwind info for epilogues" patch (which is not directly related). - - For -gdwarf-4 type units LOCATIONS_VALID indication is fortunately not - needed, it would be wrong due to missing DW_AT_producer there. -@@ -4849,7 +4851,7 @@ process_full_comp_unit (struct dwarf2_per_cu_data *per_cu) - Still one can confuse GDB by using non-standard GCC compilation - options - this waits on GCC PR other/32998 (-frecord-gcc-switches). - */ -- if (cu->has_loclist && gcc_4_minor >= 0) -+ if (cu->has_loclist && gcc_4_minor >= 5) - symtab->locations_valid = 1; - - if (gcc_4_minor >= 5) ---- a/gdb/testsuite/gdb.dwarf2/dw2-skip-prologue.S -+++ b/gdb/testsuite/gdb.dwarf2/dw2-skip-prologue.S -@@ -30,7 +30,7 @@ - .4byte func_start /* DW_AT_low_pc */ - .4byte func_end /* DW_AT_high_pc */ - .ascii "main.c\0" /* DW_AT_name */ -- .ascii "GNU C 4.0.0\0" /* DW_AT_producer must be >= 4.0 */ -+ .ascii "GNU C 4.5.0\0" /* DW_AT_producer must be >= 4.5 */ - .byte 2 /* DW_AT_language (DW_LANG_C) */ - - .uleb128 2 /* Abbrev: DW_TAG_subprogram */ - diff --git a/gdb-rhel5-compat.patch b/gdb-rhel5-compat.patch index 921b1a1..2b947d3 100644 --- a/gdb-rhel5-compat.patch +++ b/gdb-rhel5-compat.patch @@ -1,9 +1,9 @@ -Index: gdb-7.2.50.20110328/gdb/linux-nat.c +Index: gdb-7.4.50.20120602/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)); +--- gdb-7.4.50.20120602.orig/gdb/linux-nat.c 2012-06-02 20:54:30.000000000 +0200 ++++ gdb-7.4.50.20120602/gdb/linux-nat.c 2012-06-02 20:56:03.966493352 +0200 +@@ -1816,8 +1816,22 @@ get_pending_status (struct lwp_info *lp, + gdb_signal_to_string (signo)); } - if (*status == 0 && GET_PID (lp->ptid) == pid_was_stopped) diff --git a/gdb-subrange-no-type.patch b/gdb-subrange-no-type.patch deleted file mode 100644 index aa77a0a..0000000 --- a/gdb-subrange-no-type.patch +++ /dev/null @@ -1,265 +0,0 @@ -commit 7d8bdfbdfd0e38fb314d70785b0516181b8d4e77 -Author: Jan Kratochvil -Date: Mon Mar 26 20:49:51 2012 +0200 - - https://bugzilla.redhat.com/show_bug.cgi?id=806920 - gdb.dwarf2/dw2-subrange-no-type.exp - ---- a/gdb/dwarf2read.c -+++ b/gdb/dwarf2read.c -@@ -9014,6 +9014,44 @@ read_subrange_type (struct die_info *die, struct dwarf2_cu *cu) - /* Preserve BASE_TYPE's original type, just set its LENGTH. */ - check_typedef (base_type); - -+ /* Dwarf-2 specifications explicitly allows to create subrange types -+ without specifying a base type. -+ In that case, the base type must be set to the type of -+ the lower bound, upper bound or count, in that order, if any of these -+ three attributes references an object that has a type. -+ If no base type is found, the Dwarf-2 specifications say that -+ a signed integer type of size equal to the size of an address should -+ be used. -+ For the following C code: `extern char gdb_int [];' -+ GCC produces an empty range DIE. -+ FIXME: muller/2010-05-28: Possible references to object for low bound, -+ high bound or count are not yet handled by this code. */ -+ if (TYPE_CODE (base_type) == TYPE_CODE_VOID) -+ { -+ struct objfile *objfile = cu->objfile; -+ struct gdbarch *gdbarch = get_objfile_arch (objfile); -+ int addr_size = gdbarch_addr_bit (gdbarch) /8; -+ struct type *int_type = objfile_type (objfile)->builtin_int; -+ -+ /* Test "int", "long int", and "long long int" objfile types, -+ and select the first one having a size above or equal to the -+ architecture address size. */ -+ if (int_type && TYPE_LENGTH (int_type) >= addr_size) -+ base_type = int_type; -+ else -+ { -+ int_type = objfile_type (objfile)->builtin_long; -+ if (int_type && TYPE_LENGTH (int_type) >= addr_size) -+ base_type = int_type; -+ else -+ { -+ int_type = objfile_type (objfile)->builtin_long_long; -+ if (int_type && TYPE_LENGTH (int_type) >= addr_size) -+ base_type = int_type; -+ } -+ } -+ } -+ - /* The die_type call above may have already set the type for this DIE. */ - range_type = get_die_type (die, cu); - if (range_type) -@@ -9141,44 +9179,6 @@ read_subrange_type (struct die_info *die, struct dwarf2_cu *cu) - TYPE_HIGH_BOUND (range_type) = high; - } - -- /* Dwarf-2 specifications explicitly allows to create subrange types -- without specifying a base type. -- In that case, the base type must be set to the type of -- the lower bound, upper bound or count, in that order, if any of these -- three attributes references an object that has a type. -- If no base type is found, the Dwarf-2 specifications say that -- a signed integer type of size equal to the size of an address should -- be used. -- For the following C code: `extern char gdb_int [];' -- GCC produces an empty range DIE. -- FIXME: muller/2010-05-28: Possible references to object for low bound, -- high bound or count are not yet handled by this code. */ -- if (TYPE_CODE (base_type) == TYPE_CODE_VOID) -- { -- struct objfile *objfile = cu->objfile; -- struct gdbarch *gdbarch = get_objfile_arch (objfile); -- int addr_size = gdbarch_addr_bit (gdbarch) /8; -- struct type *int_type = objfile_type (objfile)->builtin_int; -- -- /* Test "int", "long int", and "long long int" objfile types, -- and select the first one having a size above or equal to the -- architecture address size. */ -- if (int_type && TYPE_LENGTH (int_type) >= addr_size) -- base_type = int_type; -- else -- { -- int_type = objfile_type (objfile)->builtin_long; -- if (int_type && TYPE_LENGTH (int_type) >= addr_size) -- base_type = int_type; -- else -- { -- int_type = objfile_type (objfile)->builtin_long_long; -- if (int_type && TYPE_LENGTH (int_type) >= addr_size) -- base_type = int_type; -- } -- } -- } -- - /* 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) ---- /dev/null -+++ b/gdb/testsuite/gdb.dwarf2/dw2-subrange-no-type.S -@@ -0,0 +1,121 @@ -+/* This testcase is part of GDB, the GNU debugger. -+ -+ Copyright 2012 Free Software Foundation, Inc. -+ -+ This program is free software; you can redistribute it and/or modify -+ it under the terms of the GNU General Public License as published by -+ the Free Software Foundation; either version 3 of the License, or -+ (at your option) any later version. -+ -+ This program is distributed in the hope that it will be useful, -+ but WITHOUT ANY WARRANTY; without even the implied warranty of -+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+ GNU General Public License for more details. -+ -+ You should have received a copy of the GNU General Public License -+ along with this program. If not, see . */ -+ -+/* Debug information */ -+ -+ .section .data -+vardata: -+ .rept 129 -+ .ascii "x" -+ .endr -+ .ascii "UNSEEN\0" -+ -+ .section .debug_info -+.Lcu1_begin: -+ .4byte .Lcu1_end - .Lcu1_start /* Length of Compilation Unit */ -+.Lcu1_start: -+ .2byte 2 /* DWARF version number */ -+ .4byte .Ldebug_abbrev0 /* Offset Into Abbrev. Section */ -+ .byte 4 /* Pointer Size (in bytes) */ -+ -+ /* CU die */ -+ .uleb128 1 /* Abbrev: DW_TAG_compile_unit */ -+ .ascii "GNU C 3.3.3\0" /* DW_AT_producer */ -+ .byte 2 /* DW_AT_language (C) - */ -+ -+.Larray_type: -+ .uleb128 2 /* Abbrev: DW_TAG_array_type */ -+ .4byte .Lchar_type-.Lcu1_begin /* DW_AT_type */ -+ -+ .uleb128 8 /* Abbrev: DW_TAG_subrange_type without DW_AT_type */ -+ .byte 0 /* DW_AT_lower_bound */ -+ .byte 128 /* DW_AT_upper_bound */ -+ -+ .byte 0 /* End of children of die */ -+ -+.Lchar_type: -+ .uleb128 4 /* Abbrev: DW_TAG_base_type */ -+ .ascii "char\0" /* DW_AT_name */ -+ .byte 1 /* DW_AT_byte_size */ -+ .byte 6 /* DW_AT_encoding */ -+ -+ .uleb128 6 /* Abbrev: DW_TAG_variable DW_FORM_string */ -+ .ascii "notype_string\0" /* DW_AT_name */ -+ .4byte .Larray_type-.Lcu1_begin /* DW_AT_type */ -+ .byte 2f - 1f /* DW_AT_location */ -+1: .byte 3 /* DW_OP_addr */ -+ .4byte vardata /* */ -+2: -+ -+ .byte 0 /* End of children of CU */ -+.Lcu1_end: -+ -+ .section .debug_abbrev -+.Ldebug_abbrev0: -+ .uleb128 1 /* Abbrev code */ -+ .uleb128 0x11 /* DW_TAG_compile_unit */ -+ .byte 0x1 /* has_children */ -+ .uleb128 0x25 /* DW_AT_producer */ -+ .uleb128 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 0x1 /* TAG: DW_TAG_array_type */ -+ .byte 0x1 /* DW_children_yes */ -+ .uleb128 0x49 /* DW_AT_type */ -+ .uleb128 0x13 /* DW_FORM_ref4 */ -+ .byte 0x0 /* Terminator */ -+ .byte 0x0 /* Terminator */ -+ -+ .uleb128 4 /* Abbrev code */ -+ .uleb128 0x24 /* DW_TAG_base_type */ -+ .byte 0x0 /* no_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 6 /* Abbrev code */ -+ .uleb128 0x34 /* DW_TAG_variable */ -+ .byte 0x0 /* no_children */ -+ .uleb128 0x3 /* DW_AT_name */ -+ .uleb128 0x8 /* DW_FORM_string */ -+ .uleb128 0x49 /* DW_AT_type */ -+ .uleb128 0x13 /* DW_FORM_ref4 */ -+ .uleb128 0x2 /* DW_AT_location */ -+ .uleb128 0xa /* DW_FORM_block1 */ -+ .byte 0x0 /* Terminator */ -+ .byte 0x0 /* Terminator */ -+ -+ .uleb128 8 /* Abbrev code */ -+ .uleb128 0x21 /* DW_TAG_subrange_type without DW_AT_type */ -+ .byte 0x0 /* no children */ -+ .uleb128 0x22 /* DW_AT_lower_bound */ -+ .uleb128 0xb /* DW_FORM_data1 */ -+ .uleb128 0x2f /* DW_AT_upper_bound */ -+ .uleb128 0xb /* DW_FORM_data1 */ -+ .byte 0x0 /* Terminator */ -+ .byte 0x0 /* Terminator */ -+ -+ .byte 0x0 /* Terminator */ ---- /dev/null -+++ b/gdb/testsuite/gdb.dwarf2/dw2-subrange-no-type.exp -@@ -0,0 +1,39 @@ -+# Copyright 2012 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 . -+load_lib dwarf.exp -+ -+# https://bugzilla.redhat.com/show_bug.cgi?id=806920 -+# read_subrange_type reinitialization -+# of BASE_TYPE was done too late, it affects DW_TAG_subrange_type without -+# specified DW_AT_type, present only in XLF produced code. -+ -+# This test can only be run on targets which support DWARF-2 and use gas. -+if {![dwarf2_support]} { -+ return 0 -+} -+ -+set testfile dw2-subrange-no-type -+set srcfile ${testfile}.S -+set executable ${testfile}.x -+set binfile ${objdir}/${subdir}/${executable} -+ -+if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" object {}] != "" } { -+ return -1 -+} -+ -+clean_restart $executable -+ -+gdb_test "ptype notype_string" {type = char \[129\]} -+gdb_test "p notype_string" " = 'x' " diff --git a/gdb-unused-revert.patch b/gdb-unused-revert.patch deleted file mode 100644 index 2abe3cf..0000000 --- a/gdb-unused-revert.patch +++ /dev/null @@ -1,44 +0,0 @@ -[RFA/commit 5/5] Add -Wunused-function to compile flags. -http://sourceware.org/ml/gdb-patches/2010-01/msg00371.html -http://sourceware.org/ml/gdb-cvs/2010-01/msg00163.html - -REVERTED - ---- src/gdb/configure.ac 2010/01/15 00:34:37 1.112 -+++ src/gdb/configure.ac 2010/01/19 09:52:31 1.113 -@@ -1544,8 +1544,7 @@ - # gdb/doc/gdbint.texinfo. - build_warnings="-Wall -Wdeclaration-after-statement -Wpointer-arith \ - -Wformat-nonliteral -Wno-pointer-sign \ ---Wno-unused -Wunused-value -Wunused-function \ ---Wno-switch -Wno-char-subscripts" -+-Wno-unused -Wunused-value -Wno-switch -Wno-char-subscripts" - - # Enable -Wno-format by default when using gcc on mingw since many - # GCC versions complain about %I64. ---- src/gdb/configure 2010/01/15 00:34:37 1.297 -+++ src/gdb/configure 2010/01/19 09:52:32 1.298 -@@ -13435,8 +13435,7 @@ - # gdb/doc/gdbint.texinfo. - build_warnings="-Wall -Wdeclaration-after-statement -Wpointer-arith \ - -Wformat-nonliteral -Wno-pointer-sign \ ---Wno-unused -Wunused-value -Wunused-function \ ---Wno-switch -Wno-char-subscripts" -+-Wno-unused -Wunused-value -Wno-switch -Wno-char-subscripts" - - # Enable -Wno-format by default when using gcc on mingw since many - # GCC versions complain about %I64. -### src/gdb/ChangeLog 2010/01/19 09:50:48 1.11271 -### src/gdb/ChangeLog 2010/01/19 09:52:33 1.11272 -## -1,11 +1,5 @@ - 2010-01-19 Joel Brobecker - -- Add -Wunused-function to compile flags. -- * configure.ac: Add -Wunused-function to build_warnings. -- * configure: Regenerate. -- --2010-01-19 Joel Brobecker -- - "delete" ada-lex.c:input function, not used. - * ada-lex.l: #define YY_NO_INPUT. - diff --git a/gdb-upstream.patch b/gdb-upstream.patch index e66d245..1594acd 100644 --- a/gdb-upstream.patch +++ b/gdb-upstream.patch @@ -1,299 +1,239 @@ -FYI: fix possible crash in find_charset_names -http://sourceware.org/ml/gdb-patches/2012-02/msg00073.html -http://sourceware.org/ml/gdb-cvs/2012-02/msg00037.html -https://bugzilla.redhat.com/show_bug.cgi?id=786091 - -### src/gdb/ChangeLog 2012/02/07 04:48:14 1.13810 -### src/gdb/ChangeLog 2012/02/07 15:42:33 1.13811 -## -1,3 +1,7 @@ -+2012-02-07 Tom Tromey -+ -+ * charset.c (find_charset_names): Check 'in' against NULL. -+ - 2012-02-06 Doug Evans - - * gdbtypes.h (struct main_type): Change type of name,tag_name, ---- src/gdb/charset.c 2012/01/24 21:36:37 1.47 -+++ src/gdb/charset.c 2012/02/07 15:42:39 1.48 -@@ -839,7 +839,7 @@ - parse the glibc and libiconv formats; feel free to add others - as needed. */ - -- while (!feof (in)) -+ while (in != NULL && !feof (in)) - { - /* The size of buf is chosen arbitrarily. */ - char buf[1024]; - - - -http://sourceware.org/ml/gdb-patches/2012-02/msg00151.html -Subject: [patch] ppc-linux-nat.c: Fix gcc-4.7 aliasing warnings +http://sourceware.org/ml/gdb-patches/2012-06/msg00065.html +Subject: [commit 1/2] testsuite: code_elim.exp: unique names Hi, -ppc-linux-nat.c: In function 'fetch_register': -ppc-linux-nat.c:598:9: error: dereferencing type-punned pointer will break strict-aliasing rules [-Werror=strict-aliasing] -ppc-linux-nat.c: In function 'store_register': -ppc-linux-nat.c:1078:8: error: dereferencing type-punned pointer will break strict-aliasing rules [-Werror=strict-aliasing] +this is just removal of non-unique test names and one small simplification. -gcc-4.7.0-0.10.fc17.ppc64 +Checked in. -Probably clear, I looked at making it using union instead of memcpy but that -would be too ugly. -No regressions on ppc64-fedorarawhide-linux-gnu only for gdb.base/*.exp. +Thanks, +Jan -I will check it in. +http://sourceware.org/ml/gdb-cvs/2012-06/msg00011.html + +### src/gdb/testsuite/ChangeLog 2012/05/28 20:37:29 1.3209 +### src/gdb/testsuite/ChangeLog 2012/06/03 17:06:04 1.3210 +## -1,3 +1,16 @@ ++2012-06-03 Jan Kratochvil ++ ++ * gdb.base/code_elim.exp (add-symbol-file ${testfile1} 0x100000): ++ Simplify it to ... ++ (symbol-file ${testfile1}): ... here. ++ (test eliminated var my_global_symbol) ++ (test eliminated var my_static_symbol) ++ (test eliminated var my_global_func, get address of main): Wrap them to ++ 'single psymtabs' and 'single symtabs' ++ (get address of my_global_symbol, get address of my_static_symbol) ++ (get address of my_global_func, get address of main): Wrap them to ++ 'order1' and 'order2'. ++ + 2012-05-28 Jan Kratochvil + + * gdb.server/solib-list-lib.c: New file. +--- src/gdb/testsuite/gdb.base/code_elim.exp 2012/01/16 16:21:44 1.4 ++++ src/gdb/testsuite/gdb.base/code_elim.exp 2012/06/03 17:06:04 1.5 +@@ -95,16 +95,16 @@ + gdb_exit + gdb_start + +-gdb_test "add-symbol-file ${binfile1} 0x100000" \ ++gdb_test "symbol-file ${binfile1}" \ + "Reading symbols from .*${testfile1}\\.\\.\\.done\\.(|\r\nUsing host libthread_db library .*libthread_db.so.*\\.)" \ +- "add-symbol-file ${testfile1} 0x100000" \ +- "add symbol table from file \".*${testfile1}\" at\[ \t\r\n\]+\.text_addr = 0x100000\[\r\n\]+\\(y or n\\) " \ +- "y" ++ "symbol-file ${testfile1}" + +-test_eliminated_var my_global_symbol +-test_eliminated_var my_static_symbol +-test_eliminated_var my_global_func +-not_null_var_address main ++with_test_prefix "single psymtabs" { ++ test_eliminated_var my_global_symbol ++ test_eliminated_var my_static_symbol ++ test_eliminated_var my_global_func ++ not_null_var_address main ++} + + # Same thing for symtabs + +@@ -115,10 +115,12 @@ + gdb_start + set GDBFLAGS $saved_gdbflags + +-test_eliminated_var my_global_symbol +-test_eliminated_var my_static_symbol +-test_eliminated_var my_global_func +-not_null_var_address main ++with_test_prefix "single symtabs" { ++ test_eliminated_var my_global_symbol ++ test_eliminated_var my_static_symbol ++ test_eliminated_var my_global_func ++ not_null_var_address main ++} + + # binfile2 contains the symbols that have been eliminated in binfile1. Check + # the eliminated symbols does not hide these valid ones. +@@ -138,10 +140,12 @@ + "add symbol table from file \".*${testfile2}\" at\[ \t\r\n\]+\.text_addr = 0x200000\[\r\n\]+\\(y or n\\) " \ + "y" + +-not_null_var_address my_global_symbol +-not_null_var_address my_static_symbol +-not_null_var_address my_global_func +-not_null_var_address main ++with_test_prefix "order1" { ++ not_null_var_address my_global_symbol ++ not_null_var_address my_static_symbol ++ not_null_var_address my_global_func ++ not_null_var_address main ++} + + # Same thing, but loading binfile2 before binfile1. + +@@ -160,9 +164,9 @@ + "add symbol table from file \".*${testfile1}\" at\[ \t\r\n\]+\.text_addr = 0x100000\[\r\n\]+\\(y or n\\) " \ + "y" + +-not_null_var_address my_global_symbol +-not_null_var_address my_static_symbol +-not_null_var_address my_global_func +-not_null_var_address main +- +- ++with_test_prefix "order2" { ++ not_null_var_address my_global_symbol ++ not_null_var_address my_static_symbol ++ not_null_var_address my_global_func ++ not_null_var_address main ++} -Thanks, -Jan -gdb/ -2012-02-09 Jan Kratochvil +http://sourceware.org/ml/gdb-patches/2012-06/msg00066.html +Subject: [commit 2/2] testsuite: code_elim.exp: Fix false FAIL - * ppc-linux-nat.c (fetch_register, store_register): Fix GCC aliasing - compilation warning. +Hi, ---- a/gdb/ppc-linux-nat.c -+++ b/gdb/ppc-linux-nat.c -@@ -593,9 +593,10 @@ fetch_register (struct regcache *regcache, int tid, int regno) - bytes_transferred < register_size (gdbarch, regno); - bytes_transferred += sizeof (long)) - { -+ long l; -+ - errno = 0; -- *(long *) &buf[bytes_transferred] -- = ptrace (PTRACE_PEEKUSER, tid, (PTRACE_TYPE_ARG3) regaddr, 0); -+ l = ptrace (PTRACE_PEEKUSER, tid, (PTRACE_TYPE_ARG3) regaddr, 0); - regaddr += sizeof (long); - if (errno != 0) - { -@@ -604,6 +605,7 @@ fetch_register (struct regcache *regcache, int tid, int regno) - gdbarch_register_name (gdbarch, regno), regno); - perror_with_name (message); - } -+ memcpy (&buf[bytes_transferred], &l, sizeof (l)); - } - - /* Now supply the register. Keep in mind that the regcache's idea -@@ -1073,9 +1075,11 @@ store_register (const struct regcache *regcache, int tid, int regno) - - for (i = 0; i < bytes_to_transfer; i += sizeof (long)) - { -+ long l; -+ -+ memcpy (&l, &buf[i], sizeof (l)); - errno = 0; -- ptrace (PTRACE_POKEUSER, tid, (PTRACE_TYPE_ARG3) regaddr, -- *(long *) &buf[i]); -+ ptrace (PTRACE_POKEUSER, tid, (PTRACE_TYPE_ARG3) regaddr, l); - regaddr += sizeof (long); - - if (errno == EIO +with Fedora 18 x86_64 (Rawhide) there is a false FAIl since: +2167931cf70f91206efb8b01e848a55d82a347ce is the first bad commit +Author: Tom Tromey +Date: Fri May 18 15:31:39 2012 +0000 +http://sourceware.org/bugzilla/show_bug.cgi?id=13907 + print &my_global_symbol +-$1 = (int *) 0x804a004 +-(gdb) PASS: gdb.base/code_elim.exp: get address of my_global_symbol ++$1 = (int *) 0x804a004 ++(gdb) FAIL: gdb.base/code_elim.exp: get address of my_global_symbol +Nothing really changed, just GDB now prints and the testcase +expects either none or suffix. -http://sourceware.org/ml/gdb-patches/2012-02/msg00409.html -Subject: FYI: remove extraneous block from dw2_map_symtabs_matching_filename -http://sourceware.org/ml/gdb-cvs/2012-02/msg00117.html -commit 61d8161b33b1e7dbc80ba6f7a92500a1594da55c +This is because the two symbol files (their sections .data/.bss) have +overlapped so GDB chooses randomly which symbol to display. And since +Fedora 18 GCC puts there that "completed.5732" symbol. -### src/gdb/ChangeLog 2012/02/20 09:42:34 1.13845 -### src/gdb/ChangeLog 2012/02/20 19:24:34 1.13846 -## -1,3 +1,8 @@ -+2012-02-20 Tom Tromey -+ -+ * dwarf2read.c (dw2_map_symtabs_matching_filename): Remove -+ extraneous block. -+ - 2012-02-20 Tristan Gingold - - * darwin-nat.h (enum darwin_msg_state): Add comments. ---- src/gdb/dwarf2read.c 2012/02/07 04:48:19 1.612 -+++ src/gdb/dwarf2read.c 2012/02/20 19:24:39 1.613 -@@ -2437,13 +2437,6 @@ - return 1; - } - -- { -- if (dw2_map_expand_apply (objfile, per_cu, -- name, full_path, real_path, -- callback, data)) -- return 1; -- } -- - /* Before we invoke realpath, which can get expensive when many - files are involved, do a quick comparison of the basenames. */ - if (! basenames_may_differ +This may be because add-symbol-file FILE ADDR relocates to ADDR on the .text +section and leaves other sections at their original place, which is IMO a bit +unexpected; it is a FAQ people expect more ADDR to be relocation displacement +(and not relative to .text and not limited to .text). But this is really +outside of the scope of this testcase false FAIL. +Checked in. -FYI: fix some performance bugs with .gdb_index -http://sourceware.org/ml/gdb-patches/2012-02/msg00413.html -http://sourceware.org/ml/gdb-cvs/2012-02/msg00119.html +Thanks, +Jan -### src/gdb/ChangeLog 2012/02/20 19:44:00 1.13847 -### src/gdb/ChangeLog 2012/02/20 20:56:12 1.13848 -## -1,3 +1,10 @@ -+2012-02-20 Tom Tromey -+ -+ PR gdb/13498: -+ * dwarf2read.c (dw2_expand_symtabs_matching): Only visit a -+ particular set of file names once. -+ (dw2_map_symbol_filenames): Likewise. -+ - 2012-02-20 Jan Kratochvil - - Code cleanup. ---- src/gdb/dwarf2read.c 2012/02/20 19:24:39 1.613 -+++ src/gdb/dwarf2read.c 2012/02/20 20:56:12 1.614 -@@ -2700,32 +2700,63 @@ - index = dwarf2_per_objfile->index_table; - - if (file_matcher != NULL) -- for (i = 0; i < (dwarf2_per_objfile->n_comp_units -- + dwarf2_per_objfile->n_type_units); ++i) -- { -- int j; -- struct dwarf2_per_cu_data *per_cu = dw2_get_cu (i); -- struct quick_file_names *file_data; -+ { -+ struct cleanup *cleanup; -+ htab_t visited_found, visited_not_found; - -- per_cu->v.quick->mark = 0; -+ visited_found = htab_create_alloc (10, -+ htab_hash_pointer, htab_eq_pointer, -+ NULL, xcalloc, xfree); -+ cleanup = make_cleanup_htab_delete (visited_found); -+ visited_not_found = htab_create_alloc (10, -+ htab_hash_pointer, htab_eq_pointer, -+ NULL, xcalloc, xfree); -+ make_cleanup_htab_delete (visited_not_found); - -- /* We only need to look at symtabs not already expanded. */ -- if (per_cu->v.quick->symtab) -- continue; -+ for (i = 0; i < (dwarf2_per_objfile->n_comp_units -+ + dwarf2_per_objfile->n_type_units); ++i) -+ { -+ int j; -+ struct dwarf2_per_cu_data *per_cu = dw2_get_cu (i); -+ struct quick_file_names *file_data; -+ void **slot; - -- file_data = dw2_get_file_names (objfile, per_cu); -- if (file_data == NULL) -- continue; -+ per_cu->v.quick->mark = 0; - -- for (j = 0; j < file_data->num_file_names; ++j) -- { -- if (file_matcher (file_data->file_names[j], data)) -- { -- per_cu->v.quick->mark = 1; -- break; -- } -- } -- } -+ /* We only need to look at symtabs not already expanded. */ -+ if (per_cu->v.quick->symtab) -+ continue; -+ -+ file_data = dw2_get_file_names (objfile, per_cu); -+ if (file_data == NULL) -+ continue; -+ -+ if (htab_find (visited_not_found, file_data) != NULL) -+ continue; -+ else if (htab_find (visited_found, file_data) != NULL) -+ { -+ per_cu->v.quick->mark = 1; -+ continue; -+ } -+ -+ for (j = 0; j < file_data->num_file_names; ++j) -+ { -+ if (file_matcher (file_data->file_names[j], data)) -+ { -+ per_cu->v.quick->mark = 1; -+ break; -+ } -+ } -+ -+ slot = htab_find_slot (per_cu->v.quick->mark -+ ? visited_found -+ : visited_not_found, -+ file_data, INSERT); -+ *slot = file_data; -+ } -+ -+ do_cleanups (cleanup); -+ } - - for (iter = 0; iter < index->symbol_table_slots; ++iter) - { -@@ -2787,15 +2818,35 @@ - void *data, int need_fullname) - { - int i; -+ struct cleanup *cleanup; -+ htab_t visited = htab_create_alloc (10, htab_hash_pointer, htab_eq_pointer, -+ NULL, xcalloc, xfree); - -+ cleanup = make_cleanup_htab_delete (visited); - dw2_setup (objfile); - -+ /* We can ignore file names coming from already-expanded CUs. */ -+ for (i = 0; i < (dwarf2_per_objfile->n_comp_units -+ + dwarf2_per_objfile->n_type_units); ++i) -+ { -+ struct dwarf2_per_cu_data *per_cu = dw2_get_cu (i); -+ -+ if (per_cu->v.quick->symtab) -+ { -+ void **slot = htab_find_slot (visited, per_cu->v.quick->file_names, -+ INSERT); -+ -+ *slot = per_cu->v.quick->file_names; -+ } -+ } -+ - for (i = 0; i < (dwarf2_per_objfile->n_comp_units - + dwarf2_per_objfile->n_type_units); ++i) - { - int j; - struct dwarf2_per_cu_data *per_cu = dw2_get_cu (i); - struct quick_file_names *file_data; -+ void **slot; - - /* We only need to look at symtabs not already expanded. */ - if (per_cu->v.quick->symtab) -@@ -2805,6 +2856,14 @@ - if (file_data == NULL) - continue; - -+ slot = htab_find_slot (visited, file_data, INSERT); -+ if (*slot) -+ { -+ /* Already visited. */ -+ continue; -+ } -+ *slot = file_data; -+ - for (j = 0; j < file_data->num_file_names; ++j) - { - const char *this_real_name; -@@ -2816,6 +2875,8 @@ - (*fun) (file_data->file_names[j], this_real_name, data); - } - } -+ -+ do_cleanups (cleanup); - } - - static int + +http://sourceware.org/ml/gdb-cvs/2012-06/msg00012.html + +### src/gdb/testsuite/ChangeLog 2012/06/03 17:06:04 1.3210 +### src/gdb/testsuite/ChangeLog 2012/06/03 17:10:28 1.3211 +## -11,6 +11,16 @@ + (get address of my_global_func, get address of main): Wrap them to + 'order1' and 'order2'. + ++ * gdb.base/code_elim.exp ++ (add-symbol-file ${testfile1} 0x100000) ++ (add-symbol-file ${testfile2} 0x200000): Wrap them to 'order1' and ++ 'order2'. ++ (order1: add-symbol-file ${testfile1} 0x100000) ++ (order1: add-symbol-file ${testfile2} 0x200000) ++ (order2: add-symbol-file ${testfile2} 0x200000) ++ (order2: add-symbol-file ${testfile1} 0x100000): Add -s .data and -s ++ .bss as appropriate. ++ + 2012-05-28 Jan Kratochvil + + * gdb.server/solib-list-lib.c: New file. +--- src/gdb/testsuite/gdb.base/code_elim.exp 2012/06/03 17:06:04 1.5 ++++ src/gdb/testsuite/gdb.base/code_elim.exp 2012/06/03 17:10:28 1.6 +@@ -128,19 +128,19 @@ + gdb_exit + gdb_start + +-gdb_test "add-symbol-file ${binfile1} 0x100000" \ +- "Reading symbols from .*${testfile1}\\.\\.\\.done\\." \ +- "add-symbol-file ${testfile1} 0x100000" \ +- "add symbol table from file \".*${testfile1}\" at\[ \t\r\n\]+\.text_addr = 0x100000\[\r\n\]+\\(y or n\\) " \ +- "y" +- +-gdb_test "add-symbol-file ${binfile2} 0x200000" \ +- "Reading symbols from .*${testfile2}\\.\\.\\.done\\." \ +- "add-symbol-file ${testfile2} 0x200000" \ +- "add symbol table from file \".*${testfile2}\" at\[ \t\r\n\]+\.text_addr = 0x200000\[\r\n\]+\\(y or n\\) " \ +- "y" +- + with_test_prefix "order1" { ++ gdb_test "add-symbol-file ${binfile1} 0x100000 -s .bss 0x120000" \ ++ "Reading symbols from .*${testfile1}\\.\\.\\.done\\." \ ++ "add-symbol-file ${testfile1} 0x100000" \ ++ "add symbol table from file \".*${testfile1}\" at.*\\(y or n\\) " \ ++ "y" ++ ++ gdb_test "add-symbol-file ${binfile2} 0x200000 -s .data 0x210000 -s .bss 0x220000" \ ++ "Reading symbols from .*${testfile2}\\.\\.\\.done\\." \ ++ "add-symbol-file ${testfile2} 0x200000" \ ++ "add symbol table from file \".*${testfile2}\" at.*\\(y or n\\) " \ ++ "y" ++ + not_null_var_address my_global_symbol + not_null_var_address my_static_symbol + not_null_var_address my_global_func +@@ -152,19 +152,19 @@ + gdb_exit + gdb_start + +-gdb_test "add-symbol-file ${binfile2} 0x200000" \ +- "Reading symbols from .*${testfile2}\\.\\.\\.done\\." \ +- "add-symbol-file ${testfile2} 0x200000" \ +- "add symbol table from file \".*${testfile2}\" at\[ \t\r\n\]+\.text_addr = 0x200000\[\r\n\]+\\(y or n\\) " \ +- "y" +- +-gdb_test "add-symbol-file ${binfile1} 0x100000" \ +- "Reading symbols from .*${testfile1}\\.\\.\\.done\\." \ +- "add-symbol-file ${testfile1} 0x100000" \ +- "add symbol table from file \".*${testfile1}\" at\[ \t\r\n\]+\.text_addr = 0x100000\[\r\n\]+\\(y or n\\) " \ +- "y" +- + with_test_prefix "order2" { ++ gdb_test "add-symbol-file ${binfile2} 0x200000 -s .data 0x210000 -s .bss 0x220000" \ ++ "Reading symbols from .*${testfile2}\\.\\.\\.done\\." \ ++ "add-symbol-file ${testfile2} 0x200000" \ ++ "add symbol table from file \".*${testfile2}\" at.*\\(y or n\\) " \ ++ "y" ++ ++ gdb_test "add-symbol-file ${binfile1} 0x100000 -s .bss 0x120000" \ ++ "Reading symbols from .*${testfile1}\\.\\.\\.done\\." \ ++ "add-symbol-file ${testfile1} 0x100000" \ ++ "add symbol table from file \".*${testfile1}\" at.*\\(y or n\\) " \ ++ "y" ++ + not_null_var_address my_global_symbol + not_null_var_address my_static_symbol + not_null_var_address my_global_func diff --git a/gdb-x86-onstack-1of2.patch b/gdb-x86-onstack-1of2.patch index a7f611d..7d7556c 100644 --- a/gdb-x86-onstack-1of2.patch +++ b/gdb-x86-onstack-1of2.patch @@ -42,8 +42,10 @@ gdb/testsuite/ * gdb.base/call-signal-resume.exp (maintenance print dummy-frames) (maintenance info breakpoints): New tests. ---- a/gdb/dummy-frame.c -+++ b/gdb/dummy-frame.c +Index: gdb-7.4.50.20120602/gdb/dummy-frame.c +=================================================================== +--- gdb-7.4.50.20120602.orig/gdb/dummy-frame.c 2012-01-04 09:17:00.000000000 +0100 ++++ gdb-7.4.50.20120602/gdb/dummy-frame.c 2012-06-02 20:42:40.907720327 +0200 @@ -29,6 +29,7 @@ #include "gdbcmd.h" #include "gdb_string.h" @@ -52,7 +54,7 @@ gdb/testsuite/ /* Dummy frame. This saves the processor state just prior to setting up the inferior function call. Older targets save the registers -@@ -108,19 +109,36 @@ remove_dummy_frame (struct dummy_frame **dummy_ptr) +@@ -108,19 +109,36 @@ remove_dummy_frame (struct dummy_frame * xfree (dummy); } @@ -92,11 +94,13 @@ gdb/testsuite/ *dummy_ptr = dummy->next; xfree (dummy); ---- a/gdb/testsuite/gdb.base/call-signal-resume.exp -+++ b/gdb/testsuite/gdb.base/call-signal-resume.exp +Index: gdb-7.4.50.20120602/gdb/testsuite/gdb.base/call-signal-resume.exp +=================================================================== +--- gdb-7.4.50.20120602.orig/gdb/testsuite/gdb.base/call-signal-resume.exp 2012-01-23 18:11:50.000000000 +0100 ++++ gdb-7.4.50.20120602/gdb/testsuite/gdb.base/call-signal-resume.exp 2012-06-02 20:43:10.523709052 +0200 @@ -101,6 +101,18 @@ gdb_test "frame $frame_number" ".*" gdb_test_no_output "set confirm off" - gdb_test_no_output "return" + gdb_test "return" "" +# Verify there are no remains of the dummy frame. +gdb_test_no_output "maintenance print dummy-frames" diff --git a/gdb.spec b/gdb.spec index 7ed50c8..559869c 100644 --- a/gdb.spec +++ b/gdb.spec @@ -24,13 +24,13 @@ %global _root_bindir %{_bindir} } -Summary: A GNU source-level debugger for C, C++, Fortran and other languages +Summary: A GNU source-level debugger for C, C++, Fortran, Go and other languages Name: %{?scl_prefix}gdb # Set version to contents of gdb/version.in. # NOTE: the FSF gdb versions are numbered N.M for official releases, like 6.3 # and, since January 2005, X.Y.Z.date for daily snapshots, like 6.3.50.20050112 # (daily snapshot from mailine), or 6.3.0.20040112 (head of the release branch). -%global snap 20120120 +%global snap 20120602 Version: 7.4.50.%{snap} # The release always contains a leading reserved number, start it at 1. @@ -133,10 +133,10 @@ Patch105: gdb-6.3-ppc64syscall-20040622.patch Patch111: gdb-6.3-ppc64displaysymbol-20041124.patch # Fix upstream `set scheduler-locking step' vs. upstream PPC atomic seqs. -#=maybepush+work: It is a bit difficult patch, a part is ppc specific. +#=push+work: It is a bit difficult patch, a part is ppc specific. Patch112: gdb-6.6-scheduler_locking-step-sw-watchpoints2.patch # Make upstream `set scheduler-locking step' as default. -#=maybepush+work: How much is scheduler-locking relevant after non-stop? +#=push+work: How much is scheduler-locking relevant after non-stop? Patch260: gdb-6.6-scheduler_locking-step-is-default.patch # Add a wrapper script to GDB that implements pstack using the @@ -147,13 +147,13 @@ Patch118: gdb-6.3-gstack-20050411.patch # VSYSCALL and PIE #=fedoratest Patch122: gdb-6.3-test-pie-20050107.patch -#=maybepush: May get obsoleted by Tom's unrelocated objfiles patch. +#=push: May get obsoleted by Tom's unrelocated objfiles patch. Patch389: gdb-archer-pie-addons.patch #=push+work: Breakpoints disabling matching should not be based on address. Patch394: gdb-archer-pie-addons-keep-disabled.patch # Get selftest working with sep-debug-info -#=maybepush +#=fedoratest Patch125: gdb-6.3-test-self-20050110.patch # Test support of multiple destructors just like multiple constructors @@ -235,7 +235,7 @@ Patch208: gdb-6.5-BEA-testsuite.patch Patch213: gdb-6.5-readline-long-line-crash-test.patch # Fix bogus 0x0 unwind of the thread's topmost function clone(3) (BZ 216711). -#=push +#=fedora Patch214: gdb-6.5-bz216711-clone-is-outermost.patch # Test sideeffects of skipping ppc .so libs trampolines (BZ 218379). @@ -243,7 +243,7 @@ Patch214: gdb-6.5-bz216711-clone-is-outermost.patch Patch216: gdb-6.5-bz218379-ppc-solib-trampoline-test.patch # Fix lockup on trampoline vs. its function lookup; unreproducible (BZ 218379). -#=push +#=fedora Patch217: gdb-6.5-bz218379-solib-trampoline-lookup-lock-fix.patch # Find symbols properly at their original (included) file (BZ 109921). @@ -279,7 +279,7 @@ Patch245: gdb-6.6-bz229517-gcore-without-terminal.patch Patch247: gdb-6.6-bz235197-fork-detach-info.patch # Avoid too long timeouts on failing cases of "annota1.exp annota3.exp". -#=push +#=fedoratest Patch254: gdb-6.6-testsuite-timeouts.patch # Support for stepping over PPC atomic instruction sequences (BZ 237572). @@ -321,7 +321,7 @@ Patch282: gdb-6.7-charsign-test.patch Patch284: gdb-6.7-ppc-clobbered-registers-O2-test.patch # Testsuite fixes for more stable/comparable results. -#=push +#=fedoratest Patch287: gdb-6.7-testsuite-stable-results.patch # Test ia64 memory leaks of the code using libunwind. @@ -428,7 +428,7 @@ Patch393: gdb-rhel5-gcc44.patch Patch397: gdb-follow-child-stale-parent.patch # Workaround ccache making lineno non-zero for command-line definitions. -#=drop: ccache is rarely used and it is even fixed now. +#=fedoratest: ccache is rarely used and it is even fixed now. Patch403: gdb-ccache-workaround.patch # Implement `info common' for Fortran. @@ -445,10 +445,6 @@ Patch407: gdb-lineno-makeup-test.patch #=fedoratest+ppc Patch408: gdb-ppc-power7-test.patch -# Revert: Add -Wunused-function to compile flags. -#=drop -Patch412: gdb-unused-revert.patch - # Fix i386+x86_64 rwatch+awatch before run, regression against 6.8 (BZ 541866). # Fix i386 rwatch+awatch before run (BZ 688788, on top of BZ 541866). #=push+work: It should be fixed properly instead. @@ -466,18 +462,12 @@ Patch470: gdb-archer-next-over-throw-cxx-exec.patch #=fedoratest Patch475: gdb-bz601887-dwarf4-rh-test.patch -# Print 2D C++ vectors as matrices (BZ 562763, sourceware10659, Chris Moller). -#=push+work: There are some outstanding issues, check the mails. -Patch486: gdb-bz562763-pretty-print-2d-vectors.patch -#=push+work: There are some outstanding issues, check the mails. -Patch487: gdb-bz562763-pretty-print-2d-vectors-libstdcxx.patch - # [delayed-symfile] Test a backtrace regression on CFIs without DIE (BZ 614604). #=fedoratest Patch490: gdb-test-bt-cfi-without-die.patch # Provide /usr/bin/gdb-add-index for rpm-build (Tom Tromey). -#=drop: Re-check against the upstream version. +#=fedora: Re-check against the upstream version. Patch491: gdb-gdb-add-index-script.patch # Out of memory is just an error, not fatal (uninitialized VLS vars, BZ 568248). @@ -534,7 +524,7 @@ Patch619: gdb-dlopen-stap-probe-test.patch Patch627: gdb-glibc-vdso-workaround.patch # Hack for proper PIE run of the testsuite. -#=push+work +#=fedoratest Patch634: gdb-runtest-pie-override.patch # Work around readline-6.2 incompatibility not asking for --more-- (BZ 701131). @@ -545,29 +535,10 @@ Patch642: gdb-readline62-ask-more-rh.patch #=push Patch643: gdb-python-rdynamic.patch -# Improve performance for C++ symbols expansion (Tom Tromey, BZ 787487). -#=push -Patch644: gdb-expand-cxx-accel.patch - -# Fix skipping of prologues on RHEL-5 gcc-4.1 -O2 -g code (BZ 797889). -#=push -Patch645: gdb-prologue-not-skipped.patch - -# Fix breakpoint warning during 'next' over exit() (Tom Tromey, BZ 797892). -#=push -Patch646: gdb-exit-warning.patch - -# [vla] Fix crash for dynamic.exp with gcc-gfortran-4.1.2-51.el5.x86_64. -#=push+work -Patch648: gdb-archer-vla-rhel5gcc.patch - # Print reasons for failed attach/spawn incl. SELinux deny_ptrace (BZ 786878). #=push -Patch649: gdb-attach-fail-reasons-1of5.patch -Patch650: gdb-attach-fail-reasons-2of5.patch -Patch651: gdb-attach-fail-reasons-3of5.patch -Patch652: gdb-attach-fail-reasons-4of5.patch Patch653: gdb-attach-fail-reasons-5of5.patch +#=fedora Patch657: gdb-attach-fail-reasons-5of5configure.patch # Fix inferior calls, particularly uncaught thrown exceptions (BZ 799531). @@ -575,55 +546,20 @@ Patch657: gdb-attach-fail-reasons-5of5configure.patch Patch654: gdb-x86-onstack-1of2.patch Patch658: gdb-x86-onstack-2of2.patch -# Fix DWARF DIEs CU vs. section relative offsets (Joel Brobecker, me). -#=push -Patch655: gdb-die-cu-offset-1of2.patch -Patch656: gdb-die-cu-offset-2of2.patch - -# [vla] Fix regression on no type for subrange from IBM XLF Fortran (BZ 806920). -#=push -Patch660: gdb-subrange-no-type.patch - # Workaround crashes from stale frame_info pointer (BZ 804256). #=push+work Patch661: gdb-stale-frame_info.patch -# Security fix for loading untrusted inferiors, see "set auto-load" (BZ 756117). -#=push -Patch662: gdb-autoload-01of28.patch -Patch663: gdb-autoload-02of28.patch -Patch664: gdb-autoload-03of28.patch -Patch665: gdb-autoload-04of28.patch -Patch666: gdb-autoload-05of28.patch -Patch667: gdb-autoload-06of28.patch -Patch668: gdb-autoload-07of28.patch -Patch669: gdb-autoload-08of28.patch -Patch670: gdb-autoload-09of28.patch -Patch671: gdb-autoload-10of28.patch -Patch672: gdb-autoload-11of28.patch -Patch673: gdb-autoload-12of28.patch -Patch674: gdb-autoload-13of28.patch -Patch675: gdb-autoload-14of28.patch -Patch676: gdb-autoload-15of28.patch -Patch677: gdb-autoload-16of28.patch -Patch678: gdb-autoload-17of28.patch -Patch679: gdb-autoload-18of28.patch -Patch680: gdb-autoload-19of28.patch -Patch681: gdb-autoload-20of28.patch -Patch682: gdb-autoload-21of28.patch -Patch683: gdb-autoload-22of28.patch -Patch684: gdb-autoload-23of28.patch -Patch685: gdb-autoload-24of28.patch -Patch686: gdb-autoload-25of28.patch -Patch687: gdb-autoload-26of28.patch -Patch688: gdb-autoload-27of28.patch -Patch689: gdb-autoload-28of28.patch - # Workaround PR libc/14166 for inferior calls of strstr. +#=push+work: But push it to glibc. Patch690: gdb-glibc-strstr-workaround.patch -# [ppc] Fix hardware watchpoints on PowerPC (BZ 827600, Edjunior Machado). -Patch691: gdb-ppc-watchpoint.patch +# Fix dejagnu-1.5-4.fc17 compatibility for Go (for BZ 635651). +#=fedoratest +Patch692: gdb-dejagnu-go.patch + +# Revert recent breakage of UNIX objfiles order for symbols lookup. +Patch693: gdb-objfile-order.patch %if 0%{!?rhel:1} || 0%{?rhel} > 6 # RL_STATE_FEDORA_GDB would not be found for: @@ -682,6 +618,9 @@ ExclusiveArch: noarch i386 x86_64 ppc ppc64 ia64 s390 s390x BuildRequires: sharutils dejagnu # gcc-objc++ is not covered by the GDB testsuite. BuildRequires: gcc gcc-c++ gcc-gfortran gcc-java gcc-objc +%if 0%{!?rhel:1} || 0%{?scl:1} || 0%{?rhel} > 6 +BuildRequires: gcc-go +%endif # archer-sergiodj-stap-patch-split BuildRequires: systemtap-sdt-devel # Copied from prelink-0.4.2-3.fc13. @@ -707,6 +646,9 @@ BuildRequires: libgcc%{bits_local} libgcc%{bits_other} # libstdc++-devel of matching bits is required only for g++ -static. BuildRequires: libstdc++%{bits_local} libstdc++%{bits_other} BuildRequires: libgcj%{bits_local} libgcj%{bits_other} +%if 0%{!?rhel:1} || 0%{?scl:1} || 0%{?rhel} > 6 +BuildRequires: libgo-devel%{bits_local} libgo-devel%{bits_other} +%endif %if 0%{!?el5:1} BuildRequires: glibc-static%{bits_local} %endif @@ -875,12 +817,10 @@ rm -f gdb/jv-exp.c gdb/m2-exp.c gdb/objc-exp.c gdb/p-exp.c %patch394 -p1 %patch407 -p1 %patch408 -p1 -%patch412 -p1 %patch417 -p1 %patch459 -p1 %patch470 -p1 %patch475 -p1 -%patch486 -p1 %patch415 -p1 %patch519 -p1 %patch490 -p1 @@ -899,60 +839,19 @@ rm -f gdb/jv-exp.c gdb/m2-exp.c gdb/objc-exp.c gdb/p-exp.c %patch627 -p1 %patch634 -p1 %patch643 -p1 -%patch644 -p1 -%patch645 -p1 -%patch646 -p1 -%patch648 -p1 -%patch649 -p1 -%patch650 -p1 -%patch651 -p1 -%patch652 -p1 %patch653 -p1 %patch657 -p1 %patch654 -p1 %patch658 -p1 -%patch655 -p1 -%patch656 -p1 -%patch660 -p1 %patch661 -p1 -%patch662 -p1 -%patch663 -p1 -%patch664 -p1 -%patch665 -p1 -%patch666 -p1 -%patch667 -p1 -%patch668 -p1 -%patch669 -p1 -%patch670 -p1 -%patch671 -p1 -%patch672 -p1 -%patch673 -p1 -%patch674 -p1 -%patch675 -p1 -%patch676 -p1 -%patch677 -p1 -%patch678 -p1 -%patch679 -p1 -%patch680 -p1 -%patch681 -p1 -%patch682 -p1 -%patch683 -p1 -%patch684 -p1 -%patch685 -p1 -%patch686 -p1 -%patch687 -p1 -%patch688 -p1 -%patch689 -p1 %patch690 -p1 -%patch691 -p1 +%patch692 -p1 +%patch693 -p1 %patch393 -p1 %if 0%{!?el5:1} || 0%{?scl:1} %patch393 -p1 -R %endif -%if 0%{?rhel:1} && 0%{?rhel} <= 6 -%patch487 -p1 -%endif %patch642 -p1 %if 0%{?rhel:1} && 0%{?rhel} <= 6 %patch642 -p1 -R @@ -1049,7 +948,7 @@ $(: RHEL-5 librpm has incompatible API. ) \ %if 0%{?el6:1} --with-rpm=librpm.so.1 \ %else - --with-rpm=librpm.so.2 \ + --with-rpm=librpm.so.3 \ %endif %endif %ifarch ia64 @@ -1437,6 +1336,14 @@ fi %endif # 0%{!?el5:1} || "%{_target_cpu}" == "noarch" %changelog +* Sun Jun 3 2012 Jan Kratochvil - 7.4.50.20120602-1.fc18 +- Rebase to FSF GDB 7.4.50.20120602. +- [testsuite] BuildRequire gcc-go. +- Drop printing 2D C++ vectors as matrices which no longer worked (BZ 562763). +- Fix dejagnu-1.5-4.fc17 compatibility for Go (for BZ 635651). +- Use librpm.so.3 for rpm-4.10.0 in Fedora 18. +- Revert recent breakage of UNIX objfiles order for symbols lookup. + * Sat Jun 2 2012 Jan Kratochvil - 7.4.50.20120120-48.fc17 - [ppc] Fix hardware watchpoints on PowerPC (BZ 827600, Edjunior Machado). diff --git a/sources b/sources index 583d753..fa203d1 100644 --- a/sources +++ b/sources @@ -1,2 +1,2 @@ 04e5c4b1b9e633422cc48990fe61958d libstdc++-v3-python-r155978.tar.bz2 -9de84a22e4b96c08d8d31a72d7751c60 gdb-7.4.50.20120120.tar.bz2 +2a3a88cc2e92aaaf50f7584331094ad3 gdb-7.4.50.20120602.tar.bz2