Compare commits

...

10 Commits
master ... f15

Author SHA1 Message Date
Jan Kratochvil 9586270ab3 Update "set auto-load" patchset and the --with-auto-load-safe-path setting. 2012-04-24 22:24:05 +02:00
Jan Kratochvil dcb8ac2042 Security fix for loading untrusted inferiors, see "set auto-load" (BZ 756117). 2012-04-21 14:37:30 +02:00
Jan Kratochvil ab6e61f8eb Fix loading of core files without build-ids but with build-ids in executables. 2012-03-17 12:41:17 +01:00
Jan Kratochvil ccb21793c3 [python] Fix crash when pretty printer fails (Phil Muldoon, BZ 712715). 2011-12-21 19:07:49 +01:00
Jan Kratochvil b118370a37 Register all available PythonGDB commands (BZ 752095).
Backport fix for crash in cp_scan_for_anonymous_namespace
(Aleksandar Ristovski, BZ 750341).
2011-11-10 02:30:38 +01:00
Jan Kratochvil 4909b1573f Rebase to FSF GDB 7.3.1 release.
Fix `layout regs' (BZ 749379, PR 13073, Pedro Alves).
2011-10-27 01:03:36 +02:00
Jan Kratochvil b37d386529 [vla] Fix VLA arrays displayed in `bt full' (BZ 738482).
Fix DW_OP_GNU_implicit_pointer for DWARF32 v3+ on 64-bit arches.
2011-09-26 22:59:43 +02:00
Jan Kratochvil f999815e29 Fix sleb128 reading (BZ 720332). 2011-08-16 19:19:53 +02:00
Jan Kratochvil 2711a08d3a Python command/function auto-loading (Phil Muldoon, BZ 730976). 2011-08-16 15:42:01 +02:00
Jan Kratochvil 800aeb48a7 Rebase to the final FSF GDB 7.3 release.
Improve gcc-4.6 stdarg false prologue end workaround (GDB PR 12435 + GCC PR 47471).
2011-07-26 22:36:45 +02:00
38 changed files with 8651 additions and 276 deletions

2
.gitignore vendored
View File

@ -1,2 +1,2 @@
/libstdc++-v3-python-r155978.tar.bz2
/gdb-7.2.90.20110703.tar.bz2
/gdb-7.3.1.tar.bz2

View File

@ -1,243 +0,0 @@
http://sourceware.org/ml/gdb-patches/2005-05/threads.html#00637
Proposed upstream but never committed upstream.
2005-06-09 Jeff Johnston <jjohnstn@redhat.com>
* gdb.base/gdbinit.exp: New testcase.
* gdb.base/gdbinit.sample: Sample .gdbinit for gdbinit.exp.
2005-06-08 Daniel Jacobowitz <dan@codesourcery.com>
Jeff Johnston <jjohnstn@redhat.com>
* Makefile.in (cli-cmds.o): Update.
* configure.in: Add check for getuid.
* configure: Regenerated.
* config.in: Ditto.
* main.c (captured_main): Pass -1 to source_command when loading
gdbinit files.
* cli/cli-cmds.c: Include "gdb_stat.h" and <fcntl.h>.
(source_command): Update documentation. Check permissions if
FROM_TTY is -1.
Index: gdb-7.2.50.20101231/gdb/cli/cli-cmds.c
===================================================================
--- gdb-7.2.50.20101231.orig/gdb/cli/cli-cmds.c 2010-12-29 03:11:04.000000000 +0100
+++ gdb-7.2.50.20101231/gdb/cli/cli-cmds.c 2011-01-01 00:53:51.000000000 +0100
@@ -39,6 +39,7 @@
#include "source.h"
#include "disasm.h"
#include "tracepoint.h"
+#include "gdb_stat.h"
#include "ui-out.h"
@@ -488,7 +489,7 @@ Script filename extension recognition is
int
find_and_open_script (const char *script_file, int search_path,
- FILE **streamp, char **full_pathp)
+ FILE **streamp, char **full_pathp, int from_tty)
{
char *file;
int fd;
@@ -514,6 +515,32 @@ find_and_open_script (const char *script
return 0;
}
+#ifdef HAVE_GETUID
+ if (from_tty == -1)
+ {
+ struct stat statbuf;
+
+ if (fstat (fd, &statbuf) < 0)
+ {
+ int save_errno = errno;
+
+ close (fd);
+ do_cleanups (old_cleanups);
+ errno = save_errno;
+ return 0;
+ }
+ if (statbuf.st_uid != getuid () || (statbuf.st_mode & S_IWOTH))
+ {
+ /* FILE gets freed by do_cleanups (old_cleanups). */
+ warning (_("not using untrusted file \"%s\""), file);
+ close (fd);
+ do_cleanups (old_cleanups);
+ errno = EPERM;
+ return 0;
+ }
+ }
+#endif
+
do_cleanups (old_cleanups);
*streamp = fdopen (fd, FOPEN_RT);
@@ -573,13 +600,14 @@ source_script_with_search (const char *f
if (file == NULL || *file == 0)
error (_("source command requires file name of file to source."));
- if (!find_and_open_script (file, search_path, &stream, &full_path))
+ if (!find_and_open_script (file, search_path, &stream, &full_path,
+ from_tty))
{
/* The script wasn't found, or was otherwise inaccessible.
If the source command was invoked interactively, throw an
error. Otherwise (e.g. if it was invoked by a script),
silently ignore the error. */
- if (from_tty)
+ if (from_tty > 0)
perror_with_name (file);
else
return;
Index: gdb-7.2.50.20101231/gdb/testsuite/gdb.base/gdbinit.exp
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ gdb-7.2.50.20101231/gdb/testsuite/gdb.base/gdbinit.exp 2011-01-01 00:53:09.000000000 +0100
@@ -0,0 +1,91 @@
+# Copyright 2005
+# Free Software Foundation, Inc.
+
+# This program is free software; you can 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.
+
+# Please email any bugs, comments, and/or additions to this file to:
+# bug-gdb@prep.ai.mit.edu
+
+# This file was written by Jeff Johnston <jjohnstn@redhat.com>.
+
+# are we on a target board
+if [is_remote target] {
+ return
+}
+
+
+global verbose
+global GDB
+global GDBFLAGS
+global gdb_prompt
+global timeout
+global gdb_spawn_id;
+
+gdb_stop_suppressing_tests;
+
+verbose "Spawning $GDB -nw"
+
+if [info exists gdb_spawn_id] {
+ return 0;
+}
+
+if ![is_remote host] {
+ if { [which $GDB] == 0 } then {
+ perror "$GDB does not exist."
+ exit 1
+ }
+}
+
+set env(HOME) [pwd]
+remote_exec build "rm .gdbinit"
+remote_exec build "cp ${srcdir}/${subdir}/gdbinit.sample .gdbinit"
+remote_exec build "chmod 646 .gdbinit"
+
+set res [remote_spawn host "$GDB -nw [host_info gdb_opts]"];
+if { $res < 0 || $res == "" } {
+ perror "Spawning $GDB failed."
+ return 1;
+}
+gdb_expect 360 {
+ -re "warning: not using untrusted file.*\.gdbinit.*\[\r\n\]$gdb_prompt $" {
+ pass "untrusted .gdbinit caught."
+ }
+ -re "$gdb_prompt $" {
+ fail "untrusted .gdbinit caught."
+ }
+ timeout {
+ fail "(timeout) untrusted .gdbinit caught."
+ }
+}
+
+remote_exec build "chmod 644 .gdbinit"
+set res [remote_spawn host "$GDB -nw [host_info gdb_opts]"];
+if { $res < 0 || $res == "" } {
+ perror "Spawning $GDB failed."
+ return 1;
+}
+gdb_expect 360 {
+ -re "warning: not using untrusted file.*\.gdbinit.*\[\r\n\]$gdb_prompt $" {
+ fail "trusted .gdbinit allowed."
+ }
+ -re "in gdbinit.*$gdb_prompt $" {
+ pass "trusted .gdbinit allowed."
+ }
+ timeout {
+ fail "(timeout) trusted .gdbinit allowed."
+ }
+}
+
+remote_exec build "rm .gdbinit"
Index: gdb-7.2.50.20101231/gdb/testsuite/gdb.base/gdbinit.sample
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ gdb-7.2.50.20101231/gdb/testsuite/gdb.base/gdbinit.sample 2011-01-01 00:53:09.000000000 +0100
@@ -0,0 +1 @@
+echo "\nin gdbinit"
Index: gdb-7.2.50.20101231/gdb/main.c
===================================================================
--- gdb-7.2.50.20101231.orig/gdb/main.c 2010-12-29 01:58:14.000000000 +0100
+++ gdb-7.2.50.20101231/gdb/main.c 2011-01-01 00:53:09.000000000 +0100
@@ -805,7 +805,7 @@ Excess command line arguments ignored. (
debugging or what directory you are in. */
if (home_gdbinit && !inhibit_gdbinit)
- catch_command_errors (source_script, home_gdbinit, 0, RETURN_MASK_ALL);
+ catch_command_errors (source_script, home_gdbinit, -1, RETURN_MASK_ALL);
/* Now perform all the actions indicated by the arguments. */
if (cdarg != NULL)
@@ -880,7 +880,7 @@ Can't attach to process and specify a co
/* Read the .gdbinit file in the current directory, *if* it isn't
the same as the $HOME/.gdbinit file (it should exist, also). */
if (local_gdbinit && !inhibit_gdbinit)
- catch_command_errors (source_script, local_gdbinit, 0, RETURN_MASK_ALL);
+ catch_command_errors (source_script, local_gdbinit, -1, 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.
Index: gdb-7.2.50.20101231/gdb/python/py-auto-load.c
===================================================================
--- gdb-7.2.50.20101231.orig/gdb/python/py-auto-load.c 2010-12-15 18:27:59.000000000 +0100
+++ gdb-7.2.50.20101231/gdb/python/py-auto-load.c 2011-01-01 00:53:09.000000000 +0100
@@ -224,7 +224,7 @@ source_section_scripts (struct objfile *
}
opened = find_and_open_script (file, 1 /*search_path*/,
- &stream, &full_path);
+ &stream, &full_path, 1 /* from_tty */);
/* If the file is not found, we still record the file in the hash table,
we only want to print an error message once.
Index: gdb-7.2.50.20101231/gdb/cli/cli-cmds.h
===================================================================
--- gdb-7.2.50.20101231.orig/gdb/cli/cli-cmds.h 2010-12-29 03:11:04.000000000 +0100
+++ gdb-7.2.50.20101231/gdb/cli/cli-cmds.h 2011-01-01 00:53:09.000000000 +0100
@@ -126,7 +126,8 @@ extern void source_script (char *, int);
/* Exported to objfiles.c. */
extern int find_and_open_script (const char *file, int search_path,
- FILE **streamp, char **full_path);
+ FILE **streamp, char **full_path,
+ int from_tty);
/* Command tracing state. */

View File

@ -0,0 +1,60 @@
--- gdb-7.2/gdb/solib-svr4.c.orig 2012-03-17 09:39:54.874090162 +0100
+++ gdb-7.2/gdb/solib-svr4.c 2012-03-17 09:42:12.561810807 +0100
@@ -1179,14 +1179,30 @@ svr4_current_sos (void)
safe_strerror (errcode));
else
{
- struct build_id *build_id;
+ struct build_id *build_id = NULL;
strncpy (new->so_original_name, buffer, SO_NAME_MAX_PATH_SIZE - 1);
new->so_original_name[SO_NAME_MAX_PATH_SIZE - 1] = '\0';
/* May get overwritten below. */
strcpy (new->so_name, new->so_original_name);
- build_id = build_id_addr_get (LM_DYNAMIC_FROM_LINK_MAP (new));
+ /* In the case the main executable was found according to its
+ build-id (from a core file) prevent loading a different build
+ of a library with accidentally the same SO_NAME.
+
+ It suppresses bogus backtraces (and prints "??" there instead)
+ if the on-disk files no longer match the running program
+ version.
+
+ If the main executable was not loaded according to its
+ build-id do not do any build-id checking of the libraries.
+ There may be missing build-ids dumped in the core file and we
+ would map all the libraries to the only existing file loaded
+ that time - the executable. */
+
+ if (symfile_objfile != NULL
+ && (symfile_objfile->flags & OBJF_BUILD_ID_CORE_LOADED) != 0)
+ build_id = build_id_addr_get (LM_DYNAMIC_FROM_LINK_MAP (new));
if (build_id != NULL)
{
char *name, *build_id_filename;
@@ -1224,23 +1240,7 @@ svr4_current_sos (void)
xfree (name);
}
else
- {
- debug_print_missing (new->so_name, build_id_filename);
-
- /* In the case the main executable was found according to
- its build-id (from a core file) prevent loading
- a different build of a library with accidentally the
- same SO_NAME.
-
- It suppresses bogus backtraces (and prints "??" there
- instead) if the on-disk files no longer match the
- running program version. */
-
- if (symfile_objfile != NULL
- && (symfile_objfile->flags
- & OBJF_BUILD_ID_CORE_LOADED) != 0)
- new->so_name[0] = 0;
- }
+ debug_print_missing (new->so_name, build_id_filename);
xfree (build_id_filename);
xfree (build_id);

View File

@ -0,0 +1,79 @@
Fix for https://bugzilla.redhat.com/show_bug.cgi?id=750341
http://sourceware.org/ml/gdb-patches/2011-10/msg00570.html
http://sourceware.org/ml/gdb-cvs/2011-10/msg00154.html
### src/gdb/ChangeLog 2011/10/20 13:34:13 1.13446
### src/gdb/ChangeLog 2011/10/20 20:06:11 1.13447
## -1,3 +1,15 @@
+2011-10-20 Aleksandar Ristovski <aristovski@qnx.com>
+
+ * cp-namespace.c (cp_scan_for_anonymous_namespaces): Changed function
+ arguments by adding OBJFILE. Instead of getting objfile from
+ symbol's symtab, use new argument OBJFILE.
+ * cp-support.h (cp_scan_for_anonymous_namespaces): Changed function
+ arguments by adding OBJFILE.
+ * gdb/dwarf2read.c (new_symbol_full): Change call to
+ cp_scan_for_anonymous_namespaces to match new signature.
+ * gdb/stabsread.c (define_symbol): Change call to
+ cp_scan_for_anonymous_namespaces to match new signature.
+
2011-10-20 Phil Muldoon <pmuldoon@redhat.com>
PR python/13308
--- src/gdb/cp-namespace.c 2011/06/29 22:05:15 1.54
+++ src/gdb/cp-namespace.c 2011/10/20 20:06:13 1.55
@@ -53,7 +53,8 @@
anonymous namespace; if so, add an appropriate using directive. */
void
-cp_scan_for_anonymous_namespaces (const struct symbol *symbol)
+cp_scan_for_anonymous_namespaces (const struct symbol *const symbol,
+ struct objfile *const objfile)
{
if (SYMBOL_DEMANGLED_NAME (symbol) != NULL)
{
@@ -114,7 +115,7 @@ cp_scan_for_anonymous_namespaces (const
namespace given by the previous component if there is
one, or to the global namespace if there isn't. */
cp_add_using_directive (dest, src, NULL, NULL,
- &SYMBOL_SYMTAB (symbol)->objfile->objfile_obstack);
+ &objfile->objfile_obstack);
}
/* The "+ 2" is for the "::". */
previous_component = next_component + 2;
--- src/gdb/cp-support.h 2011/08/18 16:17:38 1.45
+++ src/gdb/cp-support.h 2011/10/20 20:06:13 1.46
@@ -197,7 +197,8 @@
const char *processing_current_prefix,
int processing_has_namespace_info);
-extern void cp_scan_for_anonymous_namespaces (const struct symbol *symbol);
+extern void cp_scan_for_anonymous_namespaces (const struct symbol *symbol,
+ struct objfile *objfile);
extern struct symbol *cp_lookup_symbol_nonlocal (const char *name,
const struct block *block,
--- src/gdb/dwarf2read.c 2011/10/20 01:11:34 1.576
+++ src/gdb/dwarf2read.c 2011/10/20 20:06:13 1.577
@@ -11992,7 +11992,7 @@
namespaces based on the demangled name. */
if (!processing_has_namespace_info
&& cu->language == language_cplus)
- cp_scan_for_anonymous_namespaces (sym);
+ cp_scan_for_anonymous_namespaces (sym, objfile);
}
return (sym);
}
--- src/gdb/stabsread.c 2011/05/18 16:30:36 1.138
+++ src/gdb/stabsread.c 2011/10/20 20:06:14 1.139
@@ -729,7 +729,7 @@
SYMBOL_SET_NAMES (sym, string, p - string, 1, objfile);
if (SYMBOL_LANGUAGE (sym) == language_cplus)
- cp_scan_for_anonymous_namespaces (sym);
+ cp_scan_for_anonymous_namespaces (sym, objfile);
}
p++;

677
gdb-autoload-01of25.patch Normal file
View File

@ -0,0 +1,677 @@
http://sourceware.org/ml/gdb-cvs/2011-05/msg00101.html
### src/gdb/ChangeLog 2011/05/13 22:07:56 1.13005
### src/gdb/ChangeLog 2011/05/13 22:11:45 1.13006
## -1,3 +1,24 @@
+2011-05-13 Doug Evans <dje@google.com>
+
+ * NEWS: Mention "info auto-load-scripts".
+ * python/py-auto-load.c (struct auto_load_pspace_info): New member
+ script_not_found_warning_printed.
+ (init_loaded_scripts_info): Renamed from create_loaded_scripts_hash,
+ all callers updated. Initialize script_not_found_warning_printed.
+ (get_auto_load_pspace_data_for_loading): New function.
+ (maybe_add_script): New function.
+ (source_section_scripts): Simplify. Only print one warning regardless
+ of the number of auto-load scripts not found.
+ (clear_section_scripts): Clear script_not_found_warning_printed.
+ (auto_load_objfile_script): Record script in hash table.
+ (count_matching_scripts): New function.
+ (maybe_print_script): Renamed from maybe_print_section_script, all
+ callers updated. Rewrite to use ui_out_*.
+ (info_auto_load_scripts): Renamed from
+ maintenance_print_section_scripts, all callers updated.
+ (gdbpy_initialize_auto_load): "maintenance print section-scripts"
+ renamed as "info auto-load-scripts".
+
2011-05-13 Tom Tromey <tromey@redhat.com>
* dwarf2expr.c (read_uleb128): Cast intermediate result.
Index: gdb-7.3.1/gdb/NEWS
===================================================================
--- gdb-7.3.1.orig/gdb/NEWS 2012-04-20 22:33:54.000000000 +0200
+++ gdb-7.3.1/gdb/NEWS 2012-04-20 22:34:14.280929212 +0200
@@ -8,6 +8,10 @@
'data-directory'/python/gdb/function are now automatically loaded
on GDB start-up.
+info auto-load-scripts [REGEXP]
+ This command was formerly named "maintenance print section-scripts".
+ It is now generally useful and is no longer a maintenance-only command.
+
*** Changes in GDB 7.3.1
* The build failure for NetBSD and OpenBSD targets have now been fixed.
Index: gdb-7.3.1/gdb/doc/gdb.texinfo
===================================================================
--- gdb-7.3.1.orig/gdb/doc/gdb.texinfo 2012-04-20 22:33:54.000000000 +0200
+++ gdb-7.3.1/gdb/doc/gdb.texinfo 2012-04-20 22:34:03.663955649 +0200
@@ -23673,7 +23673,8 @@ command, or because the inferior has loa
The auto-loading feature is useful for supplying application-specific
debugging commands and scripts.
-Auto-loading can be enabled or disabled.
+Auto-loading can be enabled or disabled,
+and the list of auto-loaded scripts can be printed.
@table @code
@kindex set auto-load-scripts
@@ -23683,6 +23684,19 @@ Enable or disable the auto-loading of Py
@kindex show auto-load-scripts
@item show auto-load-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 gdb auto-loaded, or tried to auto-load.
+If @var{regexp} is supplied only scripts with matching names are printed.
+
+@smallexample
+(gdb) info auto-load-scripts
+Loaded Script
+ Yes py-section-script.py
+ full name: /tmp/py-section-script.py
+@end smallexample
@end table
When reading an auto-loaded file, @value{GDBN} sets the
Index: gdb-7.3.1/gdb/python/py-auto-load.c
===================================================================
--- gdb-7.3.1.orig/gdb/python/py-auto-load.c 2011-01-06 01:57:04.000000000 +0100
+++ gdb-7.3.1/gdb/python/py-auto-load.c 2012-04-20 22:34:03.664955646 +0200
@@ -18,6 +18,7 @@
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include "defs.h"
+#include "filenames.h"
#include "gdb_string.h"
#include "gdb_regex.h"
#include "top.h"
@@ -68,11 +69,15 @@ 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_entry
+struct loaded_script
{
/* Name as provided by the objfile. */
const char *name;
@@ -132,7 +137,7 @@ get_auto_load_pspace_data (struct progra
static hashval_t
hash_loaded_script_entry (const void *data)
{
- const struct loaded_script_entry *e = data;
+ const struct loaded_script *e = data;
return htab_hash_string (e->name);
}
@@ -142,17 +147,17 @@ hash_loaded_script_entry (const void *da
static int
eq_loaded_script_entry (const void *a, const void *b)
{
- const struct loaded_script_entry *ea = a;
- const struct loaded_script_entry *eb = b;
+ const struct loaded_script *ea = a;
+ const struct loaded_script *eb = b;
return strcmp (ea->name, eb->name) == 0;
}
-/* Create the hash table used for loaded scripts.
+/* Initialize the table to track loaded scripts.
Each entry is hashed by the full path name. */
static void
-create_loaded_scripts_hash (struct auto_load_pspace_info *pspace_info)
+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
@@ -162,6 +167,64 @@ create_loaded_scripts_hash (struct auto_
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.
@@ -182,11 +245,8 @@ source_section_scripts (struct objfile *
{
const char *p;
struct auto_load_pspace_info *pspace_info;
- struct loaded_script_entry **slot, entry;
- pspace_info = get_auto_load_pspace_data (current_program_space);
- if (pspace_info->loaded_scripts == NULL)
- create_loaded_scripts_hash (pspace_info);
+ pspace_info = get_auto_load_pspace_data_for_loading (current_program_space);
for (p = start; p < end; ++p)
{
@@ -226,51 +286,29 @@ source_section_scripts (struct objfile *
opened = find_and_open_script (file, 1 /*search_path*/,
&stream, &full_path);
- /* If the file is not found, we still record the file in the hash table,
- we only want to print an error message once.
- IWBN if complaints.c were more general-purpose. */
+ /* 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
+ the user how to find the list of scripts that weren't loaded.
- entry.name = file;
- if (opened)
- entry.full_path = full_path;
- else
- entry.full_path = NULL;
- slot = ((struct loaded_script_entry **)
- htab_find_slot (pspace_info->loaded_scripts,
- &entry, INSERT));
- in_hash_table = *slot != NULL;
-
- /* If this file is not in the hash table, add it. */
- if (! in_hash_table)
- {
- char *p;
+ IWBN if complaints.c were more general-purpose. */
- *slot = xmalloc (sizeof (**slot)
- + strlen (file) + 1
- + (opened ? (strlen (full_path) + 1) : 0));
- p = ((char*) *slot) + sizeof (**slot);
- strcpy (p, file);
- (*slot)->name = p;
- if (opened)
- {
- p += strlen (p) + 1;
- strcpy (p, full_path);
- (*slot)->full_path = p;
- }
- else
- (*slot)->full_path = NULL;
- }
+ in_hash_table = maybe_add_script (pspace_info->loaded_scripts, file,
+ opened ? full_path : NULL);
if (opened)
free (full_path);
if (! opened)
{
- /* We don't throw an error, the program is still debuggable.
- Check in_hash_table to only print the warning once. */
- if (! in_hash_table)
- warning (_("%s (referenced in %s): %s"),
- file, GDBPY_AUTO_SECTION_NAME, safe_strerror (errno));
+ /* 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 %s.\n\
+Use `info auto-load-scripts [REGEXP]' to list them."),
+ GDBPY_AUTO_SECTION_NAME);
+ pspace_info->script_not_found_warning_printed = TRUE;
+ }
continue;
}
@@ -322,6 +360,7 @@ clear_section_scripts (void)
{
htab_delete (info->loaded_scripts);
info->loaded_scripts = NULL;
+ info->script_not_found_warning_printed = FALSE;
}
}
@@ -378,6 +417,19 @@ auto_load_objfile_script (struct objfile
if (input)
{
+ struct auto_load_pspace_info *pspace_info;
+
+ /* 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);
fclose (input);
}
@@ -416,56 +468,133 @@ 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.
- Print the entry if specified in the regex. */
+ Collect the entry if it matches the regexp. */
static int
-maybe_print_section_script (void **slot, void *info)
+collect_matching_scripts (void **slot, void *info)
+{
+ struct loaded_script *script = *slot;
+ VEC (loaded_script_ptr) *scripts = info;
+
+ if (re_exec (script->name))
+ VEC_safe_push (loaded_script_ptr, scripts, script);
+
+ return 1;
+}
+
+/* Print SCRIPT. */
+
+static void
+print_script (struct loaded_script *script)
{
- struct loaded_script_entry *entry = *slot;
+ struct cleanup *chain;
+
+ chain = make_cleanup_ui_out_tuple_begin_end (uiout, NULL);
- if (re_exec (entry->name))
+ ui_out_field_string (uiout, "loaded", script->full_path ? "Yes" : "No");
+ 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)
{
- printf_filtered (_("Script name: %s\n"), entry->name);
- printf_filtered (_(" Full name: %s\n"),
- entry->full_path ? entry->full_path : _("unknown"));
+ ui_out_text (uiout, "\tfull name: ");
+ ui_out_field_string (uiout, "full_path", script->full_path);
+ ui_out_text (uiout, "\n");
}
- return 1;
+ do_cleanups (chain);
}
-/* "maint print section-scripts" command. */
+/* 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
-maintenance_print_section_scripts (char *pattern, int from_tty)
+info_auto_load_scripts (char *pattern, int from_tty)
{
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);
-
- printf_filtered (_("Objfile scripts matching %s:\n"), pattern);
}
else
{
re_comp ("");
- printf_filtered (_("Objfile scripts:\n"));
}
- pspace_info = get_auto_load_pspace_data (current_program_space);
- if (pspace_info == NULL || pspace_info->loaded_scripts == NULL)
- return;
+ /* 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++;
+ 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");
- immediate_quit++;
- htab_traverse_noresize (pspace_info->loaded_scripts,
- maybe_print_section_script, NULL);
- immediate_quit--;
+ ui_out_table_header (uiout, 6, ui_center, "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
@@ -486,10 +615,10 @@ an executable or shared library."),
&setlist,
&showlist);
- add_cmd ("section-scripts", class_maintenance,
- maintenance_print_section_scripts,
- _("Print dump of auto-loaded section scripts matching REGEXP."),
- &maintenanceprintlist);
+ 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.3.1/gdb/testsuite/gdb.python/py-objfile-script.c
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ gdb-7.3.1/gdb/testsuite/gdb.python/py-objfile-script.c 2012-04-20 22:34:03.664955646 +0200
@@ -0,0 +1,39 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+ Copyright 2011 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+struct ss
+{
+ int a;
+ int b;
+};
+
+void
+init_ss (struct ss *s, int a, int b)
+{
+ s->a = a;
+ s->b = b;
+}
+
+int
+main ()
+{
+ struct ss ss;
+
+ init_ss (&ss, 1, 2);
+
+ return 0; /* break to inspect struct and union */
+}
Index: gdb-7.3.1/gdb/testsuite/gdb.python/py-objfile-script.exp
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ gdb-7.3.1/gdb/testsuite/gdb.python/py-objfile-script.exp 2012-04-20 22:34:03.664955646 +0200
@@ -0,0 +1,60 @@
+# Copyright (C) 2011 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# This file is part of the GDB testsuite. It tests automagic loading of
+# -gdb.py scripts.
+
+if $tracelevel then {
+ strace $tracelevel
+}
+
+set testfile "py-objfile-script"
+set srcfile ${testfile}.c
+set binfile ${objdir}/${subdir}/${testfile}
+if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
+ untested "Couldn't compile ${srcfile}"
+ return -1
+}
+
+# Start with a fresh gdb.
+gdb_exit
+gdb_start
+
+# Skip all tests if Python scripting is not enabled.
+if { [skip_python_tests] } { continue }
+
+# Make the -gdb.py script available to gdb, it is automagically loaded by gdb.
+# Care is taken to put it in the same directory as the binary so that
+# gdb will find it.
+set remote_python_file [remote_download host ${srcdir}/${subdir}/${testfile}-gdb.py ${subdir}/${testfile}-gdb.py]
+
+gdb_reinitialize_dir $srcdir/$subdir
+gdb_load ${binfile}
+
+# Verify gdb loaded the script.
+gdb_test "info auto-load-scripts" "Yes.*/${testfile}-gdb.py.*"
+
+if ![runto_main] {
+ perror "couldn't run to main"
+ return
+}
+
+gdb_test "b [gdb_get_line_number {break to inspect} ${testfile}.c ]" \
+ ".*Breakpoint.*"
+gdb_test "continue" ".*Breakpoint.*"
+
+gdb_test "print ss" " = a=<1> b=<2>"
+
+remote_file host delete ${remote_python_file}
Index: gdb-7.3.1/gdb/testsuite/gdb.python/py-section-script.exp
===================================================================
--- gdb-7.3.1.orig/gdb/testsuite/gdb.python/py-section-script.exp 2011-03-13 14:39:17.000000000 +0100
+++ gdb-7.3.1/gdb/testsuite/gdb.python/py-section-script.exp 2012-04-20 22:34:03.664955646 +0200
@@ -55,6 +55,14 @@ set remote_python_file [remote_download
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.*"
+# Again, with a regexp this time.
+gdb_test "info auto-load-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" \
+ "No auto-load scripts matching no-script-matches-this."
+
if ![runto_main] {
perror "couldn't run to main"
return
diff --git a/gdb/testsuite/gdb.python/py-objfile-script-gdb.py b/gdb/testsuite/gdb.python/py-objfile-script-gdb.py
new file mode 100644
index 0000000..c54e9ec
--- /dev/null
+++ b/gdb/testsuite/gdb.python/py-objfile-script-gdb.py
@@ -0,0 +1,63 @@
+# Copyright (C) 2011 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# This file is part of the GDB testsuite.
+
+import re
+
+class pp_ss:
+ def __init__(self, val):
+ self.val = val
+
+ def to_string(self):
+ return "a=<" + str(self.val["a"]) + "> b=<" + str(self.val["b"]) + ">"
+
+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 pretty_printers_dict:
+ if function.match (typename):
+ return pretty_printers_dict[function] (val)
+
+ # Cannot find a pretty printer. Return None.
+
+ return None
+
+def register_pretty_printers ():
+ pretty_printers_dict[re.compile ('^ss$')] = pp_ss
+
+pretty_printers_dict = {}
+
+register_pretty_printers ()
+gdb.current_progspace().pretty_printers.append (lookup_function)

76
gdb-autoload-02of25.patch Normal file
View File

@ -0,0 +1,76 @@
http://sourceware.org/ml/gdb-cvs/2011-05/msg00112.html
### src/gdb/ChangeLog 2011/05/14 05:44:37 1.13009
### src/gdb/ChangeLog 2011/05/15 18:46:23 1.13010
## -1,3 +1,9 @@
+2011-05-15 Doug Evans <dje@google.com>
+
+ * python/py-autoload.c (print_script): Print "Missing" instead of
+ "No" for missing scripts.
+ (info_auto_load_scripts): Tweak "Loaded" column to fit "Missing".
+
2011-05-13 Doug Evans <dje@google.com>
* ui-file.c (stdio_file_write_async_safe): Add comment.
--- src/gdb/python/py-auto-load.c 2011/05/13 22:11:47 1.9
+++ src/gdb/python/py-auto-load.c 2011/05/15 18:46:24 1.10
@@ -497,7 +497,7 @@
chain = make_cleanup_ui_out_tuple_begin_end (uiout, NULL);
- ui_out_field_string (uiout, "loaded", script->full_path ? "Yes" : "No");
+ ui_out_field_string (uiout, "loaded", script->full_path ? "Yes" : "Missing");
ui_out_field_string (uiout, "script", script->name);
ui_out_text (uiout, "\n");
@@ -569,7 +569,7 @@
make_cleanup_ui_out_table_begin_end (uiout, 2, nr_scripts,
"AutoLoadedScriptsTable");
- ui_out_table_header (uiout, 6, ui_center, "loaded", "Loaded");
+ 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);
### src/gdb/doc/ChangeLog 2011/05/13 22:36:07 1.1190
### src/gdb/doc/ChangeLog 2011/05/15 18:46:25 1.1191
## -1,3 +1,7 @@
+2011-05-15 Doug Evans <dje@google.com>
+
+ * gdb.texinfo (Auto-loading): Document printing of missing scripts.
+
2011-05-13 Doug Evans <dje@google.com>
* gdb.texinfo (Threads): Document $sdir,$pdir.
--- src/gdb/doc/gdb.texinfo 2011/05/13 22:36:07 1.838
+++ src/gdb/doc/gdb.texinfo 2011/05/15 18:46:25 1.839
@@ -23601,14 +23601,25 @@
@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 gdb auto-loaded, or tried to auto-load.
+Print the list of all scripts that @value{GDBN} auto-loaded.
+
+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}).
+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.
+Example:
+
@smallexample
(gdb) info auto-load-scripts
-Loaded Script
- Yes py-section-script.py
- full name: /tmp/py-section-script.py
+Loaded Script
+Yes py-section-script.py
+ full name: /tmp/py-section-script.py
+Missing my-foo-pretty-printers.py
@end smallexample
@end table

28
gdb-autoload-03of25.patch Normal file
View File

@ -0,0 +1,28 @@
http://sourceware.org/ml/gdb-cvs/2011-05/msg00119.html
### src/gdb/ChangeLog 2011/05/16 02:22:34 1.13011
### src/gdb/ChangeLog 2011/05/16 16:33:49 1.13012
## -1,3 +1,8 @@
+2011-05-16 Doug Evans <dje@google.com>
+
+ * python/py-auto-load.c (source_section_scripts): Mention objfile
+ name in warning.
+
2011-05-15 Doug Evans <dje@google.com>
* linux-thread-db.c (try_thread_db_load_from_pdir_1): New function.
--- src/gdb/python/py-auto-load.c 2011/05/15 18:46:24 1.10
+++ src/gdb/python/py-auto-load.c 2011/05/16 16:33:57 1.11
@@ -304,9 +304,10 @@
/* 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 %s.\n\
+ 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);
+ GDBPY_AUTO_SECTION_NAME, objfile->name);
pspace_info->script_not_found_warning_printed = TRUE;
}
continue;

70
gdb-autoload-04of25.patch Normal file
View File

@ -0,0 +1,70 @@
http://sourceware.org/ml/gdb-cvs/2011-09/msg00121.html
### src/gdb/ChangeLog 2011/09/19 10:50:53 1.13352
### src/gdb/ChangeLog 2011/09/19 19:01:38 1.13353
## -1,3 +1,9 @@
+2011-09-19 Doug Evans <dje@google.com>
+
+ * python/py-auto-load.c (source_section_scripts): Fix file
+ descriptor leak.
+ * python/python.c (source_python_script_for_objfile): Tweak comments.
+
2011-09-18 Yao Qi <yao@codesourcery.com>
Ulrich Weigand <ulrich.weigand@linaro.org>
--- src/gdb/python/python.c 2011/09/15 12:42:30 1.72
+++ src/gdb/python/python.c 2011/09/19 19:01:40 1.73
@@ -903,7 +903,10 @@
static struct objfile *gdbpy_current_objfile;
/* Set the current objfile to OBJFILE and then read STREAM,FILE as
- Python code. */
+ Python code.
+ STREAM is left open, it is up to the caller to close it.
+ If an exception occurs python will print the traceback and
+ clear the error indicator. */
void
source_python_script_for_objfile (struct objfile *objfile,
@@ -914,8 +917,6 @@
cleanups = ensure_python_env (get_objfile_arch (objfile), current_language);
gdbpy_current_objfile = objfile;
- /* Note: If an exception occurs python will print the traceback and
- clear the error indicator. */
PyRun_SimpleFile (stream, file);
do_cleanups (cleanups);
--- src/gdb/python/py-auto-load.c 2011/08/04 19:10:14 1.12
+++ src/gdb/python/py-auto-load.c 2011/09/19 19:01:40 1.13
@@ -296,9 +296,6 @@
in_hash_table = maybe_add_script (pspace_info->loaded_scripts, file,
opened ? full_path : NULL);
- if (opened)
- free (full_path);
-
if (! opened)
{
/* We don't throw an error, the program is still debuggable. */
@@ -310,12 +307,15 @@
GDBPY_AUTO_SECTION_NAME, objfile->name);
pspace_info->script_not_found_warning_printed = TRUE;
}
- continue;
}
-
- /* If this file is not currently loaded, load it. */
- if (! in_hash_table)
- source_python_script_for_objfile (objfile, stream, file);
+ else
+ {
+ /* If this file is not currently loaded, load it. */
+ if (! in_hash_table)
+ source_python_script_for_objfile (objfile, stream, file);
+ fclose (stream);
+ free (full_path);
+ }
}
}

81
gdb-autoload-05of25.patch Normal file
View File

@ -0,0 +1,81 @@
http://sourceware.org/ml/gdb-cvs/2011-10/msg00012.html
### src/gdb/ChangeLog 2011/10/03 16:14:39 1.13370
### src/gdb/ChangeLog 2011/10/03 20:46:18 1.13371
## -1,3 +1,10 @@
+2011-10-03 Joel Brobecker <brobecker@adacore.com>
+
+ * python/python.c (python_run_simple_file): New function.
+ (source_python_script, source_python_script_for_objfile):
+ Replace call to PyRun_SimpleFile by call to
+ python_run_simple_file.
+
2011-10-03 Paul Koning <paul_koning@dell.com>
* python/py-value.c (valpy_get_address): Use Py_XINCREF.
--- src/gdb/python/python.c 2011/09/19 19:01:40 1.73
+++ src/gdb/python/python.c 2011/10/03 20:46:19 1.74
@@ -134,6 +134,45 @@
return make_cleanup (restore_python_env, env);
}
+/* A wrapper around PyRun_SimpleFile. FILENAME is the name of
+ the Python script to run.
+
+ 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
+ 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. */
+
+static void
+python_run_simple_file (const char *filename)
+{
+ char *filename_copy;
+ PyObject *python_file;
+ struct cleanup *cleanup;
+
+ filename_copy = xstrdup (filename);
+ cleanup = make_cleanup (xfree, filename_copy);
+ python_file = PyFile_FromString (filename_copy, "r");
+ make_cleanup_py_decref (python_file);
+ PyRun_SimpleFile (PyFile_AsFile (python_file), filename);
+ do_cleanups (cleanup);
+}
/* Given a command_line, return a command string suitable for passing
to Python. Lines in the string are separated by newlines. The
@@ -573,7 +612,7 @@
/* Note: If an exception occurs python will print the traceback and
clear the error indicator. */
- PyRun_SimpleFile (stream, file);
+ python_run_simple_file (file);
do_cleanups (cleanup);
}
@@ -917,7 +956,7 @@
cleanups = ensure_python_env (get_objfile_arch (objfile), current_language);
gdbpy_current_objfile = objfile;
- PyRun_SimpleFile (stream, file);
+ python_run_simple_file (file);
do_cleanups (cleanups);
gdbpy_current_objfile = NULL;

179
gdb-autoload-06of25.patch Normal file
View File

@ -0,0 +1,179 @@
http://sourceware.org/ml/gdb-cvs/2011-10/msg00197.html
### src/gdb/ChangeLog 2011/10/27 15:32:10 1.13467
### src/gdb/ChangeLog 2011/10/27 15:46:07 1.13468
## -1,3 +1,15 @@
+2011-10-27 Doug Evans <dje@google.com>
+
+ * cli/cli-cmds.c (source_script_with_search): Pass full path to
+ source_script_from_stream if it may have been found on the search path.
+ * python/py-auto-load.c (source_section_scripts): Pass full path to
+ source_python_script_for_objfile.
+ * python/python.c (source_python_script): Delete stream parameter.
+ All callers updated.
+ (source_python_script_for_objfile): Ditto.
+ * python/python-internal.h (source_python_script_for_objfile): Update.
+ * python/python.h (source_python_script): Update.
+
2011-10-27 Tom Tromey <tromey@redhat.com>
* ada-lang.h (ada_start_decode_line_1, ada_finish_decode_line_1)
Index: gdb-7.3.50.20110722/gdb/cli/cli-cmds.c
===================================================================
--- gdb-7.3.50.20110722.orig/gdb/cli/cli-cmds.c 2011-06-07 19:26:46.000000000 +0200
+++ gdb-7.3.50.20110722/gdb/cli/cli-cmds.c 2012-04-18 23:38:50.808994431 +0200
@@ -534,7 +534,9 @@ source_script_from_stream (FILE *stream,
TRY_CATCH (e, RETURN_MASK_ERROR)
{
- source_python_script (stream, file);
+ /* The python support reopens the file using python functions,
+ so there's no point in passing STREAM here. */
+ source_python_script (file);
}
if (e.reason < 0)
{
@@ -576,7 +578,7 @@ source_script_with_search (const char *f
if (!find_and_open_script (file, search_path, &stream, &full_path))
{
- /* The script wasn't found, or was otherwise inaccessible.
+ /* The script wasn't found, or was otherwise inaccessible.
If the source command was invoked interactively, throw an
error. Otherwise (e.g. if it was invoked by a script),
silently ignore the error. */
@@ -587,7 +589,12 @@ source_script_with_search (const char *f
}
old_cleanups = make_cleanup (xfree, full_path);
- source_script_from_stream (stream, file);
+ /* 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
+ this if we (may have) used search_path, as printing the full path in
+ errors for the non-search case can be more noise than signal. */
+ source_script_from_stream (stream, search_path ? full_path : file);
do_cleanups (old_cleanups);
}
Index: gdb-7.3.50.20110722/gdb/python/py-auto-load.c
===================================================================
--- gdb-7.3.50.20110722.orig/gdb/python/py-auto-load.c 2012-04-18 23:38:42.000000000 +0200
+++ gdb-7.3.50.20110722/gdb/python/py-auto-load.c 2012-04-18 23:38:50.809994429 +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, stream, file);
+ source_python_script_for_objfile (objfile, full_path);
fclose (stream);
free (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, input, debugfile);
+ source_python_script_for_objfile (objfile, debugfile);
fclose (input);
}
Index: gdb-7.3.50.20110722/gdb/python/python.c
===================================================================
--- gdb-7.3.50.20110722.orig/gdb/python/python.c 2012-04-18 23:38:42.000000000 +0200
+++ gdb-7.3.50.20110722/gdb/python/python.c 2012-04-18 23:38:50.809994429 +0200
@@ -594,21 +594,18 @@ gdbpy_parse_and_eval (PyObject *self, Py
return value_to_value_object (result);
}
-/* Read a file as Python code. STREAM is the input file; FILE is the
- name of the file.
- STREAM is not closed, that is the caller's responsibility. */
+/* Read a file as Python code.
+ FILE is the name of the 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 (FILE *stream, const char *file)
+source_python_script (const char *file)
{
struct cleanup *cleanup;
cleanup = ensure_python_env (get_current_arch (), current_language);
-
- /* Note: If an exception occurs python will print the traceback and
- clear the error indicator. */
python_run_simple_file (file);
-
do_cleanups (cleanup);
}
@@ -983,15 +980,12 @@ 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 STREAM,FILE as
- Python code.
- STREAM is left open, it is up to the caller to close it.
- If an exception occurs python will print the traceback and
- clear the error indicator. */
+/* 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. */
void
-source_python_script_for_objfile (struct objfile *objfile,
- FILE *stream, const char *file)
+source_python_script_for_objfile (struct objfile *objfile, const char *file)
{
struct cleanup *cleanups;
@@ -1074,7 +1068,7 @@ eval_python_from_control_command (struct
}
void
-source_python_script (FILE *stream, const char *file)
+source_python_script (const char *file)
{
throw_error (UNSUPPORTED_ERROR,
_("Python scripting is not supported in this copy of GDB."));
Index: gdb-7.3.50.20110722/gdb/python/python.h
===================================================================
--- gdb-7.3.50.20110722.orig/gdb/python/python.h 2012-04-18 23:38:41.000000000 +0200
+++ gdb-7.3.50.20110722/gdb/python/python.h 2012-04-18 23:38:50.809994429 +0200
@@ -30,7 +30,7 @@ extern void finish_python_initialization
void eval_python_from_control_command (struct command_line *);
-void source_python_script (FILE *stream, const char *file);
+void source_python_script (const char *file);
void run_python_script (int argc, char **argv);
Index: gdb-7.3.50.20110722/gdb/python/python-internal.h
===================================================================
--- gdb-7.3.50.20110722.orig/gdb/python/python-internal.h 2011-06-28 15:09:12.000000000 +0200
+++ gdb-7.3.50.20110722/gdb/python/python-internal.h 2012-04-18 23:38:50.809994429 +0200
@@ -242,7 +242,7 @@ extern const struct language_defn *pytho
void gdbpy_print_stack (void);
void source_python_script_for_objfile (struct objfile *objfile,
- FILE *stream, const char *file);
+ const char *file);
PyObject *python_string_to_unicode (PyObject *obj);
char *unicode_to_target_string (PyObject *unicode_str);
Index: gdb-7.3.50.20110722/gdb/testsuite/gdb.python/python.exp
===================================================================
--- gdb-7.3.50.20110722.orig/gdb/testsuite/gdb.python/python.exp 2011-07-21 13:03:48.000000000 +0200
+++ gdb-7.3.50.20110722/gdb/testsuite/gdb.python/python.exp 2012-04-18 23:38:50.810994427 +0200
@@ -75,6 +75,8 @@ gdb_py_test_multiple "indented multi-lin
gdb_test "source $srcdir/$subdir/source2.py" "yes"
+gdb_test "source -s source2.py" "yes" "source -s source2.py"
+
gdb_test "python print gdb.current_objfile()" "None"
gdb_test "python print gdb.objfiles()" "\\\[\\\]"

40
gdb-autoload-07of25.patch Normal file
View File

@ -0,0 +1,40 @@
http://sourceware.org/ml/gdb-cvs/2011-12/msg00201.html
### src/gdb/ChangeLog 2011/12/19 22:20:05 1.13649
### src/gdb/ChangeLog 2011/12/20 04:29:33 1.13650
## -1,3 +1,9 @@
+2011-12-19 Doug Evans <dje@google.com>
+
+ * python/py-auto-load.c (info_auto_load_scripts): Pass address of
+ scripts vector to collect_matching_scripts.
+ (collect_matching_scripts): Update.
+
2011-12-19 Jan Kratochvil <jan.kratochvil@redhat.com>
* symfile.c (reread_symbols): Move free_objfile_separate_debug,
--- src/gdb/python/py-auto-load.c 2011/12/10 22:51:47 1.15
+++ src/gdb/python/py-auto-load.c 2011/12/20 04:29:35 1.16
@@ -481,10 +481,10 @@
collect_matching_scripts (void **slot, void *info)
{
struct loaded_script *script = *slot;
- VEC (loaded_script_ptr) *scripts = info;
+ VEC (loaded_script_ptr) **scripts_ptr = info;
if (re_exec (script->name))
- VEC_safe_push (loaded_script_ptr, scripts, script);
+ VEC_safe_push (loaded_script_ptr, *scripts_ptr, script);
return 1;
}
@@ -563,8 +563,9 @@
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);
+ collect_matching_scripts, &scripts);
immediate_quit--;
}

69
gdb-autoload-08of25.patch Normal file
View File

@ -0,0 +1,69 @@
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 <jan.kratochvil@redhat.com>
+
+ 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 <palves@redhat.com>
* breakpoint.c (bpstat_stop_status): Moving clearing print_it
Index: gdb-7.3.50.20110722/gdb/cli/cli-cmds.c
===================================================================
--- gdb-7.3.50.20110722.orig/gdb/cli/cli-cmds.c 2012-04-18 23:38:50.000000000 +0200
+++ gdb-7.3.50.20110722/gdb/cli/cli-cmds.c 2012-04-18 23:39:52.709847704 +0200
@@ -521,8 +521,7 @@ find_and_open_script (const char *script
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)
@@ -550,12 +549,9 @@ source_script_from_stream (FILE *stream,
else
{
/* Nope, just punt. */
- fclose (stream);
throw_exception (e);
}
}
- else
- fclose (stream);
}
else
script_from_file (stream, file);
@@ -589,6 +585,7 @@ source_script_with_search (const char *f
}
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
Index: gdb-7.3.50.20110722/gdb/cli/cli-script.c
===================================================================
--- gdb-7.3.50.20110722.orig/gdb/cli/cli-script.c 2011-06-27 21:21:50.000000000 +0200
+++ gdb-7.3.50.20110722/gdb/cli/cli-script.c 2012-04-18 23:39:22.845918492 +0200
@@ -1600,11 +1600,9 @@ script_from_file (FILE *stream, const ch
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 ""

103
gdb-autoload-09of25.patch Normal file
View File

@ -0,0 +1,103 @@
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 <http://www.gnu.org/licenses/>. */
+
+
+#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 <tromey@redhat.com>
+
+ * 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 <pedro@codesourcery.com>
* 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 <stddef.h>
#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;

216
gdb-autoload-10of25.patch Normal file
View File

@ -0,0 +1,216 @@
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 <jan.kratochvil@redhat.com>
+
+ 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 <palves@redhat.com>
* corelow.c (core_has_fake_pid): Delete.
Index: gdb-7.3.50.20110722/gdb/cli/cli-cmds.c
===================================================================
--- gdb-7.3.50.20110722.orig/gdb/cli/cli-cmds.c 2012-04-18 23:39:52.000000000 +0200
+++ gdb-7.3.50.20110722/gdb/cli/cli-cmds.c 2012-04-18 23:40:19.179784960 +0200
@@ -533,9 +533,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.3.50.20110722/gdb/python/py-auto-load.c
===================================================================
--- gdb-7.3.50.20110722.orig/gdb/python/py-auto-load.c 2012-04-18 23:38:50.000000000 +0200
+++ gdb-7.3.50.20110722/gdb/python/py-auto-load.c 2012-04-18 23:40:45.197723289 +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);
free (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.3.50.20110722/gdb/python/python-internal.h
===================================================================
--- gdb-7.3.50.20110722.orig/gdb/python/python-internal.h 2012-04-18 23:38:50.000000000 +0200
+++ gdb-7.3.50.20110722/gdb/python/python-internal.h 2012-04-18 23:40:19.180784958 +0200
@@ -241,8 +241,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.3.50.20110722/gdb/python/python.c
===================================================================
--- gdb-7.3.50.20110722.orig/gdb/python/python.c 2012-04-18 23:38:50.000000000 +0200
+++ gdb-7.3.50.20110722/gdb/python/python.c 2012-04-18 23:42:01.188543162 +0200
@@ -136,34 +136,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 *filename_copy;
PyObject *python_file;
struct cleanup *cleanup;
@@ -174,6 +171,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
@@ -595,17 +594,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);
}
@@ -980,19 +979,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;
@@ -1068,7 +1068,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.3.50.20110722/gdb/python/python.h
===================================================================
--- gdb-7.3.50.20110722.orig/gdb/python/python.h 2012-04-18 23:38:50.000000000 +0200
+++ gdb-7.3.50.20110722/gdb/python/python.h 2012-04-18 23:40:19.181784956 +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);

141
gdb-autoload-11of25.patch Normal file
View File

@ -0,0 +1,141 @@
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 <jan.kratochvil@redhat.com>
+
+ 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 <tromey@redhat.com>
* gnu-v3-abi.c (gnuv3_print_vtable): Initialize 'result_vec'.
Index: gdb-7.3.50.20110722/gdb/main.c
===================================================================
--- gdb-7.3.50.20110722.orig/gdb/main.c 2012-04-18 23:38:42.000000000 +0200
+++ gdb-7.3.50.20110722/gdb/main.c 2012-04-18 23:42:28.152479249 +0200
@@ -275,6 +275,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)
{
@@ -301,17 +320,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;
@@ -344,9 +354,7 @@ captured_main (void *data)
lim_at_start = (char *) sbrk (0);
#endif
- 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;
@@ -577,24 +585,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;
@@ -985,16 +988,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. */

244
gdb-autoload-12of25.patch Normal file
View File

@ -0,0 +1,244 @@
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 <jan.kratochvil@redhat.com>
+ * 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 <jan.kratochvil@redhat.com>
+
Code cleanup.
* main.c (struct cmdarg): Move it here from main. Add more comments.
(cmdarg_s, VEC (cmdarg_s)): New.
Index: gdb-7.3.1/gdb/NEWS
===================================================================
--- gdb-7.3.1.orig/gdb/NEWS 2012-04-20 22:34:14.000000000 +0200
+++ gdb-7.3.1/gdb/NEWS 2012-04-20 22:36:12.239635484 +0200
@@ -12,6 +12,13 @@ info auto-load-scripts [REGEXP]
This command was formerly named "maintenance print section-scripts".
It is now generally useful and is no longer a maintenance-only command.
+* 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.3.1
* The build failure for NetBSD and OpenBSD targets have now been fixed.
Index: gdb-7.3.1/gdb/main.c
===================================================================
--- gdb-7.3.1.orig/gdb/main.c 2012-04-20 22:35:34.000000000 +0200
+++ gdb-7.3.1/gdb/main.c 2012-04-20 22:35:59.377667511 +0200
@@ -281,7 +281,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
@@ -428,7 +434,9 @@ captured_main (void *data)
OPT_STATISTICS,
OPT_TUI,
OPT_NOWINDOWS,
- OPT_WINDOWS
+ OPT_WINDOWS,
+ OPT_IX,
+ OPT_IEX
};
static struct option long_options[] =
{
@@ -469,6 +477,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'},
@@ -597,6 +609,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;
@@ -871,6 +896,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
@@ -987,6 +1026,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)
{
@@ -1087,6 +1127,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.3.1/gdb/doc/gdb.texinfo
===================================================================
--- gdb-7.3.1.orig/gdb/doc/gdb.texinfo 2012-04-20 22:34:26.000000000 +0200
+++ gdb-7.3.1/gdb/doc/gdb.texinfo 2012-04-20 22:35:59.383667495 +0200
@@ -993,6 +993,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}
@@ -1255,6 +1271,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,
@@ -1288,14 +1311,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.3.1/gdb/testsuite/gdb.gdb/selftest.exp
===================================================================
--- gdb-7.3.1.orig/gdb/testsuite/gdb.gdb/selftest.exp 2012-04-20 22:33:53.000000000 +0200
+++ gdb-7.3.1/gdb/testsuite/gdb.gdb/selftest.exp 2012-04-20 22:35:59.383667495 +0200
@@ -96,6 +96,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"
@@ -132,18 +136,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"
@@ -167,6 +159,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"

73
gdb-autoload-13of25.patch Normal file
View File

@ -0,0 +1,73 @@
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 <jan.kratochvil@redhat.com>
+ 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 <jan.kratochvil@redhat.com>
+
* 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
Index: gdb-7.3.50.20110722/gdb/python/py-auto-load.c
===================================================================
--- gdb-7.3.50.20110722.orig/gdb/python/py-auto-load.c 2012-04-18 23:40:45.000000000 +0200
+++ gdb-7.3.50.20110722/gdb/python/py-auto-load.c 2012-04-18 23:43:59.643262382 +0200
@@ -254,6 +254,7 @@ source_section_scripts (struct objfile *
FILE *stream;
char *full_path;
int opened, in_hash_table;
+ struct cleanup *back_to;
if (*p != 1)
{
@@ -286,6 +287,13 @@ source_section_scripts (struct objfile *
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 @@ 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, stream, full_path);
- fclose (stream);
- free (full_path);
}
+
+ do_cleanups (back_to);
}
}
@@ -420,6 +428,8 @@ auto_load_objfile_script (struct objfile
{
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 @@ auto_load_objfile_script (struct objfile
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);

59
gdb-autoload-14of25.patch Normal file
View File

@ -0,0 +1,59 @@
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 <jan.kratochvil@redhat.com>
+
+ * 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 <sivachandra@google.com>
* gdb.texinfo (Python API/Values From Inferior): Add description
Index: gdb-7.3.1/gdb/doc/gdb.texinfo
===================================================================
--- gdb-7.3.1.orig/gdb/doc/gdb.texinfo 2012-04-20 23:35:29.206571276 +0200
+++ gdb-7.3.1/gdb/doc/gdb.texinfo 2012-04-20 23:35:53.052511630 +0200
@@ -23685,8 +23685,8 @@ command, or because the inferior has loa
@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
@@ -23712,7 +23712,7 @@ Print the list of all scripts that @valu
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.
@@ -23763,7 +23763,7 @@ is the object file's real name, as descr
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
@@ -31959,7 +31959,7 @@ If @var{regexp} is specified, only print
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

171
gdb-autoload-15of25.patch Normal file
View File

@ -0,0 +1,171 @@
[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 <jan.kratochvil@redhat.com>
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 <jan.kratochvil@redhat.com>
+
+ Code cleanup.
* source.c (add_path): Remove always true conditional 'p == 0' and
unindent its code block.
Index: gdb-7.3.50.20110722/gdb/gdb_vecs.h
===================================================================
--- gdb-7.3.50.20110722.orig/gdb/gdb_vecs.h 2012-04-18 23:40:04.000000000 +0200
+++ gdb-7.3.50.20110722/gdb/gdb_vecs.h 2012-04-18 23:44:35.195178113 +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.3.50.20110722/gdb/utils.c
===================================================================
--- gdb-7.3.50.20110722.orig/gdb/utils.c 2012-04-18 23:38:42.000000000 +0200
+++ gdb-7.3.50.20110722/gdb/utils.c 2012-04-18 23:45:43.106017137 +0200
@@ -29,6 +29,7 @@
#ifdef HAVE_SYS_RESOURCE_H
#include <sys/resource.h>
#endif /* HAVE_SYS_RESOURCE_H */
+#include "gdb_vecs.h"
#ifdef TUI
#include "tui/tui.h" /* For tui_get_command_dimension. */
@@ -3707,6 +3708,95 @@ parse_pid_to_attach (char *args)
return pid;
}
+/* 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;
+}
+
/* Provide a prototype to silence -Wmissing-prototypes. */
extern initialize_file_ftype _initialize_utils;

1164
gdb-autoload-16of25.patch Normal file

File diff suppressed because it is too large Load Diff

1697
gdb-autoload-17of25.patch Normal file

File diff suppressed because it is too large Load Diff

737
gdb-autoload-18of25.patch Normal file
View File

@ -0,0 +1,737 @@
[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 <jan.kratochvil@redhat.com>
+ 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 <jan.kratochvil@redhat.com>
+
auto-load: Implementation.
* NEWS: New descriptions for "info auto-load",
"info auto-load gdb-scripts", "info auto-load python-scripts",
Index: gdb-7.3.1/gdb/NEWS
===================================================================
--- gdb-7.3.1.orig/gdb/NEWS 2012-04-20 23:04:26.000000000 +0200
+++ gdb-7.3.1/gdb/NEWS 2012-04-20 23:05:22.712029423 +0200
@@ -73,6 +73,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 <dir1>[:<dir2>...]
+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
-data-directory DIR Specify DIR as the "data-directory".
Index: gdb-7.3.1/gdb/auto-load.c
===================================================================
--- gdb-7.3.1.orig/gdb/auto-load.c 2012-04-20 23:04:26.000000000 +0200
+++ gdb-7.3.1/gdb/auto-load.c 2012-04-20 23:05:22.712029423 +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;
}
@@ -431,7 +621,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");
@@ -715,6 +905,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);
@@ -754,4 +946,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.3.1/gdb/auto-load.h
===================================================================
--- gdb-7.3.1.orig/gdb/auto-load.h 2012-04-20 23:04:26.000000000 +0200
+++ gdb-7.3.1/gdb/auto-load.h 2012-04-20 23:05:22.712029423 +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.3.1/gdb/config.in
===================================================================
--- gdb-7.3.1.orig/gdb/config.in 2012-04-20 23:04:26.000000000 +0200
+++ gdb-7.3.1/gdb/config.in 2012-04-20 23:05:22.713029421 +0200
@@ -40,6 +40,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.3.1/gdb/configure
===================================================================
--- gdb-7.3.1.orig/gdb/configure 2012-04-20 23:04:26.000000000 +0200
+++ gdb-7.3.1/gdb/configure 2012-04-20 23:05:22.715029416 +0200
@@ -952,6 +952,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
@@ -1661,6 +1662,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
@@ -8376,6 +8381,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.3.1/gdb/configure.ac
===================================================================
--- gdb-7.3.1.orig/gdb/configure.ac 2012-04-20 23:04:26.000000000 +0200
+++ gdb-7.3.1/gdb/configure.ac 2012-04-20 23:05:22.715029416 +0200
@@ -301,6 +301,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.3.1/gdb/linux-thread-db.c
===================================================================
--- gdb-7.3.1.orig/gdb/linux-thread-db.c 2012-04-20 23:05:16.000000000 +0200
+++ gdb-7.3.1/gdb/linux-thread-db.c 2012-04-20 23:05:42.837979053 +0200
@@ -879,7 +879,8 @@ thread_db_load_search (void)
}
strcat (path, "/");
strcat (path, LIBTHREAD_DB_SO);
- if (auto_load_thread_db && try_thread_db_load (path))
+ if (auto_load_thread_db && file_is_auto_load_safe (path)
+ && try_thread_db_load (path))
{
rc = 1;
break;
@@ -945,7 +946,7 @@ thread_db_load (void)
else
{
strcpy (cp + 1, LIBTHREAD_DB_SO);
- if (try_thread_db_load (path))
+ if (file_is_auto_load_safe (path) && try_thread_db_load (path))
return 1;
}
warning (_("Unable to find libthread_db matching inferior's thread"
Index: gdb-7.3.1/gdb/main.c
===================================================================
--- gdb-7.3.1.orig/gdb/main.c 2012-04-20 23:04:26.000000000 +0200
+++ gdb-7.3.1/gdb/main.c 2012-04-20 23:05:22.716029413 +0200
@@ -1020,7 +1020,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.3.1/gdb/doc/gdb.texinfo
===================================================================
--- gdb-7.3.1.orig/gdb/doc/gdb.texinfo 2012-04-20 23:04:26.000000000 +0200
+++ gdb-7.3.1/gdb/doc/gdb.texinfo 2012-04-20 23:05:22.721029400 +0200
@@ -20024,6 +20024,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}
@@ -20095,12 +20097,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
@@ -20201,6 +20210,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
@@ -23962,10 +24069,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.3.1/gdb/python/py-auto-load.c
===================================================================
--- gdb-7.3.1.orig/gdb/python/py-auto-load.c 2012-04-20 23:04:26.000000000 +0200
+++ gdb-7.3.1/gdb/python/py-auto-load.c 2012-04-20 23:05:22.721029400 +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.3.1/gdb/testsuite/gdb.python/py-objfile-script.exp
===================================================================
--- gdb-7.3.1.orig/gdb/testsuite/gdb.python/py-objfile-script.exp 2012-04-20 23:04:26.000000000 +0200
+++ gdb-7.3.1/gdb/testsuite/gdb.python/py-objfile-script.exp 2012-04-20 23:05:22.722029398 +0200
@@ -41,6 +41,7 @@ if { [skip_python_tests] } { continue }
set remote_python_file [remote_download host ${srcdir}/${subdir}/${testfile}-gdb.py ${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.3.1/gdb/testsuite/gdb.python/py-section-script.exp
===================================================================
--- gdb-7.3.1.orig/gdb/testsuite/gdb.python/py-section-script.exp 2012-04-20 23:04:26.000000000 +0200
+++ gdb-7.3.1/gdb/testsuite/gdb.python/py-section-script.exp 2012-04-20 23:05:22.722029398 +0200
@@ -53,6 +53,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.

350
gdb-autoload-19of25.patch Normal file
View File

@ -0,0 +1,350 @@
[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 <jan.kratochvil@redhat.com>
+ 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 <jan.kratochvil@redhat.com>
+
New option "set auto-load safe-path".
* NEWS: New commands "set auto-load safe-path"
and "show auto-load safe-path".
Index: gdb-7.3.1/gdb/NEWS
===================================================================
--- gdb-7.3.1.orig/gdb/NEWS 2012-04-20 23:05:22.000000000 +0200
+++ gdb-7.3.1/gdb/NEWS 2012-04-20 23:07:15.697746730 +0200
@@ -78,6 +78,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
-data-directory DIR Specify DIR as the "data-directory".
Index: gdb-7.3.1/gdb/auto-load.c
===================================================================
--- gdb-7.3.1.orig/gdb/auto-load.c 2012-04-20 23:05:22.000000000 +0200
+++ gdb-7.3.1/gdb/auto-load.c 2012-04-20 23:07:15.698746727 +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. */
@@ -972,4 +1037,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.3.1/gdb/auto-load.h
===================================================================
--- gdb-7.3.1.orig/gdb/auto-load.h 2012-04-20 23:05:22.000000000 +0200
+++ gdb-7.3.1/gdb/auto-load.h 2012-04-20 23:07:15.698746727 +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.3.1/gdb/linux-thread-db.c
===================================================================
--- gdb-7.3.1.orig/gdb/linux-thread-db.c 2012-04-20 23:05:42.000000000 +0200
+++ gdb-7.3.1/gdb/linux-thread-db.c 2012-04-20 23:11:35.315097181 +0200
@@ -879,7 +879,8 @@ thread_db_load_search (void)
}
strcat (path, "/");
strcat (path, LIBTHREAD_DB_SO);
- if (auto_load_thread_db && file_is_auto_load_safe (path)
+ if (auto_load_thread_db && file_is_auto_load_safe (path, _("auto-load: Loading libthread-db "
+"library \"%s\" from explicit " "directory.\n"), path)
&& try_thread_db_load (path))
{
rc = 1;
@@ -946,7 +947,9 @@ thread_db_load (void)
else
{
strcpy (cp + 1, LIBTHREAD_DB_SO);
- if (file_is_auto_load_safe (path) && try_thread_db_load (path))
+ if (file_is_auto_load_safe (path, _("auto-load: Loading libthread-db "
+"library \"%s\" from $pdir.\n"), path)
+ && try_thread_db_load (path))
return 1;
}
warning (_("Unable to find libthread_db matching inferior's thread"
Index: gdb-7.3.1/gdb/main.c
===================================================================
--- gdb-7.3.1.orig/gdb/main.c 2012-04-20 23:05:22.000000000 +0200
+++ gdb-7.3.1/gdb/main.c 2012-04-20 23:07:15.699746724 +0200
@@ -1021,7 +1021,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.3.1/gdb/doc/gdb.texinfo
===================================================================
--- gdb-7.3.1.orig/gdb/doc/gdb.texinfo 2012-04-20 23:05:22.000000000 +0200
+++ gdb-7.3.1/gdb/doc/gdb.texinfo 2012-04-20 23:07:15.705746710 +0200
@@ -20110,6 +20110,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
@@ -20308,6 +20309,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.3.1/gdb/python/py-auto-load.c
===================================================================
--- gdb-7.3.1.orig/gdb/python/py-auto-load.c 2012-04-20 23:05:22.000000000 +0200
+++ gdb-7.3.1/gdb/python/py-auto-load.c 2012-04-20 23:07:15.706746707 +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

23
gdb-autoload-20of25.patch Normal file
View File

@ -0,0 +1,23 @@
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 <jan.kratochvil@redhat.com>
+
+ * gdb.texinfo (Auto-loading verbose mode): Fix smallexample typo.
+
2012-04-17 Jan Kratochvil <jan.kratochvil@redhat.com>
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".

51
gdb-autoload-21of25.patch Normal file
View File

@ -0,0 +1,51 @@
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 <jan.kratochvil@redhat.com>
+
+ * gdb.texinfo (Auto-loading safe path): Replace @itemize @bullet
+ by @table @asis. Fix formatting of one item.
+
2012-04-18 Jan Kratochvil <jan.kratochvil@redhat.com>
* 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

38
gdb-autoload-22of25.patch Normal file
View File

@ -0,0 +1,38 @@
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 <jan.kratochvil@redhat.com>
+
+ * gdb.texinfo (Auto-loading safe path): Remove trailing [@dots{}].
+ Three times.
+
2012-04-22 Jan Kratochvil <jan.kratochvil@redhat.com>
* 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}

39
gdb-autoload-23of25.patch Normal file
View File

@ -0,0 +1,39 @@
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 <jan.kratochvil@redhat.com>
* 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}

158
gdb-autoload-24of25.patch Normal file
View File

@ -0,0 +1,158 @@
http://sourceware.org/ml/gdb-patches/2012-04/msg00756.html
Subject: Re: [patch] auto-load safe-path reset back by set ""
- Patched out "(without the quotes)".
On Sun, 22 Apr 2012 22:16:32 +0200, Eli Zaretskii wrote:
> > +@item set auto-load safe-path [@var{directories}]
>
> You need @r{} around [ and ].
>
> > +Setting this variable to @code{"/"} (without the quotes) disables this security
> ^^^^^^^^^^
> Why not @file{/}? The quotes are not needed in any case.
done.
In fact this patch is unrelated to the Doug's suggestion, reposting it only
with the doc update.
Thanks,
Jan
gdb/
2012-04-23 Jan Kratochvil <jan.kratochvil@redhat.com>
* 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 /.
gdb/doc/
2012-04-23 Jan Kratochvil <jan.kratochvil@redhat.com>
* 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.
diff --git a/gdb/auto-load.c b/gdb/auto-load.c
index 9d19179..6c1309f 100644
--- a/gdb/auto-load.c
+++ b/gdb/auto-load.c
@@ -181,6 +181,12 @@ auto_load_safe_path_vec_update (void)
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 @@ 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)
+ if (strcmp (value, "/") == 0)
fprintf_filtered (file, _("Auto-load files are safe to load from any "
"directory.\n"));
else
@@ -209,8 +215,9 @@ add_auto_load_safe_path (char *args, int from_tty)
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);
@@ -1023,8 +1030,10 @@ 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\
+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,
diff --git a/gdb/configure b/gdb/configure
index 54c2399..42d2fbd 100755
--- a/gdb/configure
+++ b/gdb/configure
@@ -4949,7 +4949,7 @@ $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=""
+ with_auto_load_safe_path="/"
fi
else
with_auto_load_safe_path="$prefix"
diff --git a/gdb/configure.ac b/gdb/configure.ac
index a40c2e5..9bde18f 100644
--- a/gdb/configure.ac
+++ b/gdb/configure.ac
@@ -140,7 +140,7 @@ 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=""
+ 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,
diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
index a2a4eb3..46dde27 100644
--- a/gdb/doc/gdb.texinfo
+++ b/gdb/doc/gdb.texinfo
@@ -21105,9 +21105,12 @@ 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}
+@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.
@@ -21126,7 +21129,8 @@ 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.
+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
@@ -21146,7 +21150,7 @@ by @samp{show auto-load safe-path} (such as @samp{/usr:/bin} in this example).
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.

231
gdb-autoload-25of25.patch Normal file
View File

@ -0,0 +1,231 @@
http://sourceware.org/ml/gdb-patches/2012-04/msg00758.html
Subject: [patch] auto-load safe-path default=$ddir/auto-load [Re: [patch] auto-load safe-path reset back by set ""]
On Sun, 22 Apr 2012 23:26:16 +0200, Doug Evans wrote:
> A thought occurred to me regarding the default value of auto-load-path
> = ${prefix}.
This is unrelated to this patch but thanks for the suggestion.
> So I was wondering if we really want security to be on by default,
> should the default value be gdb's data-directory (e.g.,
> $prefix/share/gdb) + $exec_prefix/lib{,32,64} + ???
Made it therefore $ddir/auto-load, on an ideal system/distro we can change all
the auto-loaded GDB files to be located under $ddir/auto-load. I have filed
for the only remaining violation (/usr/bin/mono-gdb.py) known to me:
https://bugzilla.redhat.com/show_bug.cgi?id=815501
(Sure I will ask about upstreaming of the change.)
> Plus, it seems like at least data-directory should be relocatable.
> Implementing this might be cumbersome unless data-directory was
> represented as something like "$ddir".
Done. Unfortunately this still does not fix the "./gdb" run for a newly built
GDB. Newly built GDB probably could use "-data-directory $PWD/data-directory"
(if GDB's program dir contains "data-directory" sort of relocation).
We could then change current
gdb-gdb.gdb.in -> gdb-gdb.gdb
to
gdb-gdb.gdb.in -> data-directory/auto-load/$PWD/gdb-gdb.gdb
and even install the file (with proper installation directories) as:
/usr/share/gdb/usr/bin/gdb-gdb.gdb
(additionally ensuring for example in Fedora - in its .spec file
@srcdir@ gets substituted right for Fedora *-debuginfo.rpm)
Would it make everyone happy?
Thanks,
Jan
gdb/
2012-04-23 Jan Kratochvil <jan.kratochvil@redhat.com>
Change auto-load safe-path default to $ddir/auto-load.
* auto-load.c (auto_load_safe_path_vec_update): Call
substitute_path_component for $ddir.
* configure: Regenerate.
* configure.ac (--with-auto-load-safe-path): Suggest $ddir syntax.
Change the default to \\\$ddir/auto-load.
* defs.h (substitute_path_component): New declaration.
* utils.c (substitute_path_component): New function.
gdb/doc/
2012-04-23 Jan Kratochvil <jan.kratochvil@redhat.com>
Change auto-load safe-path default to $ddir/auto-load.
* gdb.texinfo (Auto-loading): Change shown safe-path default to
$ddir/auto-load.
(Auto-loading safe path): Change the sample warning to $ddir/auto-load.
Twice. Mention the $ddir substitution.
Index: gdb-7.3.50.20110722/gdb/auto-load.c
===================================================================
--- gdb-7.3.50.20110722.orig/gdb/auto-load.c 2012-04-24 20:37:48.000000000 +0200
+++ gdb-7.3.50.20110722/gdb/auto-load.c 2012-04-24 20:37:53.902703805 +0200
@@ -141,8 +141,12 @@ 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 *expanded, *real_path;
+
+ expanded = tilde_expand (dir);
+ substitute_path_component (&expanded, "$ddir", gdb_datadir);
+
+ real_path = gdb_realpath (expanded);
/* Ensure the current entry is at least tilde_expand-ed. */
VEC_replace (char_ptr, auto_load_safe_path_vec, ix, expanded);
Index: gdb-7.3.50.20110722/gdb/configure
===================================================================
--- gdb-7.3.50.20110722.orig/gdb/configure 2012-04-24 20:37:48.000000000 +0200
+++ gdb-7.3.50.20110722/gdb/configure 2012-04-24 20:37:53.904703800 +0200
@@ -1664,7 +1664,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 -data-directory
--without-auto-load-safe-path
do not restrict auto-loaded files locations
--with-libunwind use libunwind frame unwinding support
@@ -8392,7 +8393,7 @@ if test "${with_auto_load_safe_path+set}
with_auto_load_safe_path="/"
fi
else
- with_auto_load_safe_path="$prefix"
+ with_auto_load_safe_path='\\\$ddir/auto-load'
fi
Index: gdb-7.3.50.20110722/gdb/configure.ac
===================================================================
--- gdb-7.3.50.20110722.orig/gdb/configure.ac 2012-04-24 20:37:48.000000000 +0200
+++ gdb-7.3.50.20110722/gdb/configure.ac 2012-04-24 20:37:53.904703800 +0200
@@ -303,12 +303,13 @@ 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([--with-auto-load-safe-path=PATH],
+ [directories safe to hold auto-loaded files, use '\\\$ddir' for -data-directory])
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"])
+[with_auto_load_safe_path='\\\$ddir/auto-load'])
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])
Index: gdb-7.3.50.20110722/gdb/defs.h
===================================================================
--- gdb-7.3.50.20110722.orig/gdb/defs.h 2012-04-24 20:37:47.000000000 +0200
+++ gdb-7.3.50.20110722/gdb/defs.h 2012-04-24 20:38:42.944581730 +0200
@@ -432,6 +432,9 @@ extern const char *gdb_bfd_errmsg (bfd_e
extern int parse_pid_to_attach (char *args);
+extern void substitute_path_component (char **stringp, const char *from,
+ const char *to);
+
/* From demangle.c */
extern void set_demangling_style (char *);
Index: gdb-7.3.50.20110722/gdb/doc/gdb.texinfo
===================================================================
--- gdb-7.3.50.20110722.orig/gdb/doc/gdb.texinfo 2012-04-24 20:37:48.000000000 +0200
+++ gdb-7.3.50.20110722/gdb/doc/gdb.texinfo 2012-04-24 20:37:53.909703788 +0200
@@ -20113,7 +20113,7 @@ libthread-db: Auto-loading of inferior
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.
+ is $ddir/auto-load.
@end smallexample
@anchor{info auto-load}
@@ -20315,9 +20315,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:
@@ -20349,6 +20349,11 @@ loading and execution of scripts. Multi
host platform directory separator in use.
@end table
+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.
This variable is supposed to be set to the system directories writable by the
Index: gdb-7.3.50.20110722/gdb/utils.c
===================================================================
--- gdb-7.3.50.20110722.orig/gdb/utils.c 2012-04-24 20:37:48.000000000 +0200
+++ gdb-7.3.50.20110722/gdb/utils.c 2012-04-24 20:39:12.745507543 +0200
@@ -3797,6 +3797,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;
+}
+
/* Provide a prototype to silence -Wmissing-prototypes. */
extern initialize_file_ftype _initialize_utils;

View File

@ -37,7 +37,7 @@ Index: gdb-7.1.90.20100711/gdb/solib-svr4.c
===================================================================
--- gdb-7.1.90.20100711.orig/gdb/solib-svr4.c 2010-07-12 23:07:35.000000000 +0200
+++ gdb-7.1.90.20100711/gdb/solib-svr4.c 2010-07-13 00:19:03.000000000 +0200
@@ -1177,8 +1177,18 @@ svr4_current_sos (void)
@@ -1175,8 +1175,18 @@ svr4_current_sos (void)
target_read_string (LM_NAME (new), &buffer,
SO_NAME_MAX_PATH_SIZE - 1, &errcode);
if (errcode != 0)
@ -57,7 +57,7 @@ Index: gdb-7.1.90.20100711/gdb/solib-svr4.c
+ }
else
{
struct build_id *build_id;
struct build_id *build_id = NULL;
Index: gdb-7.1.90.20100711/gdb/solib.c
===================================================================
--- gdb-7.1.90.20100711.orig/gdb/solib.c 2010-05-17 01:49:58.000000000 +0200

View File

@ -1,24 +1,709 @@
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index 6a98d57..9fa9c3c 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -10371,6 +10371,9 @@ dwarf_decode_lines (struct line_header *lh, const char *comp_dir, bfd *abfd,
http://sourceware.org/ml/gdb-patches/2011-07/msg00645.html
Subject: [patch] workaround gcc46: prologue skip skips too far (PR 12435) #2
Hi,
this is an improved patch of a former:
[patch] workaround gcc46: prologue skip skips too far (PR 12435)
http://sourceware.org/ml/gdb-patches/2011-03/msg01108.html
cancel/FYI: Re: [patch] workaround gcc46: prologue skip skips too far (PR 12435)
http://sourceware.org/ml/gdb-patches/2011-03/msg01123.html
For example `break error' does not work for debugging GDB with gcc-4.6.x.
As gcc-4.6.0 and now even 4.6.1 still has this bug and I have seen a user(s?)
on non-Fedora platform asking about this bug and as there may be enough
binaries out there (although it affects only -O0 -g compilation) coded it
properly I have coded the workaround properly this time.
It does not solve overlays well, but the code just does not work for overlays,
it has no other negative effect.
I will update the code after FSF gcc gets fixed to minimize the workaround.
No regressions on {x86_64,x86_64-m32,i686}-fedora16pre-linux-gnu.
I would welcome a comment whether it is suitable for FSF GDB.
Thanks,
Jan
gdb/
2011-07-22 Jan Kratochvil <jan.kratochvil@redhat.com>
PR breakpoints/12435
* amd64-tdep.c (amd64_skip_prologue): New variables start_pc_sal,
next_sal, buf, offset and xmmreg. Advance PC if it sees the PR.
* dwarf2read.c (process_full_comp_unit): Initialize
amd64_prologue_line_bug.
* symtab.h (struct symtab): New field amd64_prologue_line_bug.
gdb/testsuite/
2011-07-22 Jan Kratochvil <jan.kratochvil@redhat.com>
PR breakpoints/12435
* gdb.arch/amd64-prologue-xmm.c: New file.
* gdb.arch/amd64-prologue-xmm.exp: New file.
* gdb.arch/amd64-prologue-xmm.s: New file.
Index: gdb-7.3/gdb/amd64-tdep.c
===================================================================
--- gdb-7.3.orig/gdb/amd64-tdep.c 2011-03-18 19:52:29.000000000 +0100
+++ gdb-7.3/gdb/amd64-tdep.c 2011-07-26 22:09:15.000000000 +0200
@@ -1902,6 +1902,9 @@ amd64_skip_prologue (struct gdbarch *gdb
{
struct amd64_frame_cache cache;
CORE_ADDR pc;
+ struct symtab_and_line start_pc_sal, next_sal;
+ gdb_byte buf[4 + 8 * 7];
+ int offset, xmmreg;
if (op_code >= lh->opcode_base)
{
+ CORE_ADDR saved_address = address;
+ unsigned int saved_line = line;
amd64_init_frame_cache (&cache);
pc = amd64_analyze_prologue (gdbarch, start_pc, 0xffffffffffffffffLL,
@@ -1909,7 +1912,71 @@ amd64_skip_prologue (struct gdbarch *gdb
if (cache.frameless_p)
return start_pc;
- return pc;
+ /* GCC PR debug/48827 produced false prologue end:
+ 84 c0 test %al,%al
+ 74 23 je after
+ <-- here is 0 lines advance - the false prologue end marker.
+ 0f 29 85 70 ff ff ff movaps %xmm0,-0x90(%rbp)
+ 0f 29 4d 80 movaps %xmm1,-0x80(%rbp)
+ 0f 29 55 90 movaps %xmm2,-0x70(%rbp)
+ 0f 29 5d a0 movaps %xmm3,-0x60(%rbp)
+ 0f 29 65 b0 movaps %xmm4,-0x50(%rbp)
+ 0f 29 6d c0 movaps %xmm5,-0x40(%rbp)
+ 0f 29 75 d0 movaps %xmm6,-0x30(%rbp)
+ 0f 29 7d e0 movaps %xmm7,-0x20(%rbp)
+ after: */
+
/* Special operand. */
adj_opcode = op_code - lh->opcode_base;
address += (((op_index + (adj_opcode / lh->line_range))
@@ -10383,7 +10386,8 @@ dwarf_decode_lines (struct line_header *lh, const char *comp_dir, bfd *abfd,
dwarf2_debug_line_missing_file_complaint ();
/* For now we ignore lines not starting on an
instruction boundary. */
- else if (op_index == 0)
+ else if (op_index == 0
+ && (address != saved_address || line != saved_line))
{
lh->file_names[file - 1].included_p = 1;
if (!decode_for_pst_p && is_stmt)
+ if (pc == start_pc)
+ return pc;
+
+ start_pc_sal = find_pc_sect_line (start_pc, NULL, 0);
+ if (start_pc_sal.symtab == NULL
+ || !start_pc_sal.symtab->amd64_prologue_line_bug
+ || start_pc_sal.pc != start_pc || pc >= start_pc_sal.end)
+ return pc;
+
+ next_sal = find_pc_sect_line (start_pc_sal.end, NULL, 0);
+ if (next_sal.line != start_pc_sal.line)
+ return pc;
+
+ /* START_PC can be from overlayed memory, ignored here. */
+ if (target_read_memory (next_sal.pc - 4, buf, sizeof (buf)) != 0)
+ return pc;
+
+ /* test %al,%al */
+ if (buf[0] != 0x84 || buf[1] != 0xc0)
+ return pc;
+ /* je AFTER */
+ if (buf[2] != 0x74)
+ return pc;
+
+ offset = 4;
+ for (xmmreg = 0; xmmreg < 8; xmmreg++)
+ {
+ /* movaps %xmmreg?,-0x??(%rbp) */
+ if (buf[offset] != 0x0f || buf[offset + 1] != 0x29
+ || (buf[offset + 2] & 0b00111111) != (xmmreg << 3 | 0b101))
+ return pc;
+
+ if ((buf[offset + 2] & 0b11000000) == 0b01000000)
+ {
+ /* 8-bit displacement. */
+ offset += 4;
+ }
+ else if ((buf[offset + 2] & 0b11000000) == 0b10000000)
+ {
+ /* 32-bit displacement. */
+ offset += 7;
+ }
+ else
+ return pc;
+ }
+
+ /* je AFTER */
+ if (offset - 4 != buf[3])
+ return pc;
+
+ return next_sal.end;
}
Index: gdb-7.3/gdb/dwarf2read.c
===================================================================
--- gdb-7.3.orig/gdb/dwarf2read.c 2011-07-26 22:08:59.000000000 +0200
+++ gdb-7.3/gdb/dwarf2read.c 2011-07-26 22:11:07.000000000 +0200
@@ -4647,6 +4647,42 @@ producer_is_gcc_ge_4_0 (struct dwarf2_cu
return major >= 4;
}
+static int
+producer_is_gcc_ge_4_6 (struct dwarf2_cu *cu)
+{
+ const char *cs;
+ int major, minor;
+
+ if (cu->producer == NULL)
+ {
+ /* For unknown compilers expect their behavior is not compliant. For GCC
+ this case can also happen for -gdwarf-4 type units supported since
+ gcc-4.5. */
+
+ return 0;
+ }
+
+ /* Skip any identifier after "GNU " - such as "C++" or "Java". */
+
+ if (strncmp (cu->producer, "GNU ", strlen ("GNU ")) != 0)
+ {
+ /* For non-GCC compilers expect their behavior is not compliant. */
+
+ return 0;
+ }
+ cs = &cu->producer[strlen ("GNU ")];
+ while (*cs && !isdigit (*cs))
+ cs++;
+ if (sscanf (cs, "%d.%d", &major, &minor) != 2)
+ {
+ /* Not recognized as GCC. */
+
+ return 0;
+ }
+
+ return major >= 4 && minor >= 6;
+}
+
/* Generate full symbol information for PST and CU, whose DIEs have
already been loaded into memory. */
@@ -4706,6 +4742,9 @@ process_full_comp_unit (struct dwarf2_pe
*/
if (cu->has_loclist && producer_is_gcc_ge_4_0 (cu))
symtab->locations_valid = 1;
+
+ if (producer_is_gcc_ge_4_6 (cu))
+ symtab->amd64_prologue_line_bug = 1;
}
if (dwarf2_per_objfile->using_index)
Index: gdb-7.3/gdb/symtab.h
===================================================================
--- gdb-7.3.orig/gdb/symtab.h 2011-07-26 22:08:57.000000000 +0200
+++ gdb-7.3/gdb/symtab.h 2011-07-26 22:09:39.000000000 +0200
@@ -779,6 +779,11 @@ struct symtab
unsigned int locations_valid : 1;
+ /* At least GCC 4.6.0 and 4.6.1 can produce invalid false prologue and marker
+ on amd64. This flag is set independently of the symtab arch. */
+
+ unsigned amd64_prologue_line_bug : 1;
+
/* The macro table for this symtab. Like the blockvector, this
may be shared between different symtabs --- and normally is for
all the symtabs in a given compilation unit. */
Index: gdb-7.3/gdb/testsuite/gdb.arch/amd64-prologue-xmm.c
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ gdb-7.3/gdb/testsuite/gdb.arch/amd64-prologue-xmm.c 2011-07-26 22:09:15.000000000 +0200
@@ -0,0 +1,38 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+ Copyright 2011 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+static volatile int v, fail;
+
+static void
+func (int i, ...)
+{
+ v = i;
+}
+
+static void
+marker (void)
+{
+}
+
+int
+main (void)
+{
+ func (1);
+ fail = 1;
+ marker ();
+ return 0;
+}
Index: gdb-7.3/gdb/testsuite/gdb.arch/amd64-prologue-xmm.exp
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ gdb-7.3/gdb/testsuite/gdb.arch/amd64-prologue-xmm.exp 2011-07-26 22:09:15.000000000 +0200
@@ -0,0 +1,46 @@
+# Copyright 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# Test GCC PR debug/48827 workaround in GDB.
+
+set testfile "amd64-prologue-xmm"
+set srcfile ${testfile}.s
+set csrcfile ${testfile}.c
+set binfile ${objdir}/${subdir}/${testfile}.x
+set opts {}
+
+if [info exists COMPILE] {
+ # make check RUNTESTFLAGS='gdb.arch/amd64-prologue-xmm.exp COMPILE=1'
+ set srcfile ${csrcfile}
+ lappend opts debug optimize=-O0
+} elseif { ![istarget x86_64-*-* ] || ![is_lp64_target] } {
+ verbose "Skipping amd64-prologue-xmm test."
+ return 0
+}
+
+if {[prepare_for_testing ${testfile}.exp ${testfile} $srcfile $opts]} {
+ return -1
+}
+
+if ![runto_main] {
+ return -1
+}
+
+gdb_breakpoint "func"
+gdb_breakpoint "marker"
+
+gdb_continue_to_breakpoint "func"
+
+gdb_test "p fail" " = 0" "stopped at func"
Index: gdb-7.3/gdb/testsuite/gdb.arch/amd64-prologue-xmm.s
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ gdb-7.3/gdb/testsuite/gdb.arch/amd64-prologue-xmm.s 2011-07-26 22:09:15.000000000 +0200
@@ -0,0 +1,400 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+ Copyright 2011 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+/* This file is compiled from gdb.arch/amd64-prologue-xmm.c
+ using -g -dA -S. */
+
+ .file "amd64-prologue-xmm.c"
+ .text
+.Ltext0:
+ .local v
+ .comm v,4,4
+ .local fail
+ .comm fail,4,4
+ .type func, @function
+func:
+.LFB0:
+ .file 1 "gdb.arch/amd64-prologue-xmm.c"
+ # gdb.arch/amd64-prologue-xmm.c:22
+ .loc 1 22 0
+ .cfi_startproc
+ # basic block 2
+ pushq %rbp
+ .cfi_def_cfa_offset 16
+ .cfi_offset 6, -16
+ movq %rsp, %rbp
+ .cfi_def_cfa_register 6
+ subq $72, %rsp
+ movq %rsi, -168(%rbp)
+ movq %rdx, -160(%rbp)
+ movq %rcx, -152(%rbp)
+ movq %r8, -144(%rbp)
+ movq %r9, -136(%rbp)
+ testb %al, %al
+ je .L2
+ # basic block 3
+ # gdb.arch/amd64-prologue-xmm.c:22
+ .loc 1 22 0
+ movaps %xmm0, -128(%rbp)
+ movaps %xmm1, -112(%rbp)
+ movaps %xmm2, -96(%rbp)
+ movaps %xmm3, -80(%rbp)
+ movaps %xmm4, -64(%rbp)
+ movaps %xmm5, -48(%rbp)
+ movaps %xmm6, -32(%rbp)
+ movaps %xmm7, -16(%rbp)
+.L2:
+ # basic block 4
+ movl %edi, -180(%rbp)
+ # gdb.arch/amd64-prologue-xmm.c:23
+ .loc 1 23 0
+ movl -180(%rbp), %eax
+ movl %eax, v(%rip)
+ # gdb.arch/amd64-prologue-xmm.c:24
+ .loc 1 24 0
+ leave
+ .cfi_def_cfa 7, 8
+ ret
+ .cfi_endproc
+.LFE0:
+ .size func, .-func
+ .type marker, @function
+marker:
+.LFB1:
+ # gdb.arch/amd64-prologue-xmm.c:28
+ .loc 1 28 0
+ .cfi_startproc
+ # basic block 2
+ pushq %rbp
+ .cfi_def_cfa_offset 16
+ .cfi_offset 6, -16
+ movq %rsp, %rbp
+ .cfi_def_cfa_register 6
+ # gdb.arch/amd64-prologue-xmm.c:29
+ .loc 1 29 0
+ popq %rbp
+ .cfi_def_cfa 7, 8
+ ret
+ .cfi_endproc
+.LFE1:
+ .size marker, .-marker
+ .globl main
+ .type main, @function
+main:
+.LFB2:
+ # gdb.arch/amd64-prologue-xmm.c:33
+ .loc 1 33 0
+ .cfi_startproc
+ # basic block 2
+ pushq %rbp
+ .cfi_def_cfa_offset 16
+ .cfi_offset 6, -16
+ movq %rsp, %rbp
+ .cfi_def_cfa_register 6
+ # gdb.arch/amd64-prologue-xmm.c:34
+ .loc 1 34 0
+ movl $1, %edi
+ movl $0, %eax
+ call func
+ # gdb.arch/amd64-prologue-xmm.c:35
+ .loc 1 35 0
+ movl $1, fail(%rip)
+ # gdb.arch/amd64-prologue-xmm.c:36
+ .loc 1 36 0
+ call marker
+ # gdb.arch/amd64-prologue-xmm.c:37
+ .loc 1 37 0
+ movl $0, %eax
+ # gdb.arch/amd64-prologue-xmm.c:38
+ .loc 1 38 0
+ popq %rbp
+ .cfi_def_cfa 7, 8
+ ret
+ .cfi_endproc
+.LFE2:
+ .size main, .-main
+.Letext0:
+ .section .debug_info,"",@progbits
+.Ldebug_info0:
+ .long 0xc0 # Length of Compilation Unit Info
+ .value 0x4 # DWARF version number
+ .long .Ldebug_abbrev0 # Offset Into Abbrev. Section
+ .byte 0x8 # Pointer Size (in bytes)
+ .uleb128 0x1 # (DIE (0xb) DW_TAG_compile_unit)
+ .long .LASF1 # DW_AT_producer: "GNU C 4.6.1 20110715 (Red Hat 4.6.1-3)"
+ .byte 0x1 # DW_AT_language
+ .long .LASF2 # DW_AT_name: "gdb.arch/amd64-prologue-xmm.c"
+ .long .LASF3 # DW_AT_comp_dir: ""
+ .quad .Ltext0 # DW_AT_low_pc
+ .quad .Letext0 # DW_AT_high_pc
+ .long .Ldebug_line0 # DW_AT_stmt_list
+ .uleb128 0x2 # (DIE (0x2d) DW_TAG_subprogram)
+ .long .LASF4 # DW_AT_name: "func"
+ .byte 0x1 # DW_AT_decl_file (gdb.arch/amd64-prologue-xmm.c)
+ .byte 0x15 # DW_AT_decl_line
+ # DW_AT_prototyped
+ .quad .LFB0 # DW_AT_low_pc
+ .quad .LFE0 # DW_AT_high_pc
+ .uleb128 0x1 # DW_AT_frame_base
+ .byte 0x9c # DW_OP_call_frame_cfa
+ # DW_AT_GNU_all_call_sites
+ .long 0x59 # DW_AT_sibling
+ .uleb128 0x3 # (DIE (0x4a) DW_TAG_formal_parameter)
+ .ascii "i\0" # DW_AT_name
+ .byte 0x1 # DW_AT_decl_file (gdb.arch/amd64-prologue-xmm.c)
+ .byte 0x15 # DW_AT_decl_line
+ .long 0x59 # DW_AT_type
+ .uleb128 0x3 # DW_AT_location
+ .byte 0x91 # DW_OP_fbreg
+ .sleb128 -196
+ .uleb128 0x4 # (DIE (0x57) DW_TAG_unspecified_parameters)
+ .byte 0 # end of children of DIE 0x2d
+ .uleb128 0x5 # (DIE (0x59) DW_TAG_base_type)
+ .byte 0x4 # DW_AT_byte_size
+ .byte 0x5 # DW_AT_encoding
+ .ascii "int\0" # DW_AT_name
+ .uleb128 0x6 # (DIE (0x60) DW_TAG_subprogram)
+ .long .LASF5 # DW_AT_name: "marker"
+ .byte 0x1 # DW_AT_decl_file (gdb.arch/amd64-prologue-xmm.c)
+ .byte 0x1b # DW_AT_decl_line
+ # DW_AT_prototyped
+ .quad .LFB1 # DW_AT_low_pc
+ .quad .LFE1 # DW_AT_high_pc
+ .uleb128 0x1 # DW_AT_frame_base
+ .byte 0x9c # DW_OP_call_frame_cfa
+ # DW_AT_GNU_all_call_sites
+ .uleb128 0x7 # (DIE (0x79) DW_TAG_subprogram)
+ # DW_AT_external
+ .long .LASF6 # DW_AT_name: "main"
+ .byte 0x1 # DW_AT_decl_file (gdb.arch/amd64-prologue-xmm.c)
+ .byte 0x20 # DW_AT_decl_line
+ # DW_AT_prototyped
+ .long 0x59 # DW_AT_type
+ .quad .LFB2 # DW_AT_low_pc
+ .quad .LFE2 # DW_AT_high_pc
+ .uleb128 0x1 # DW_AT_frame_base
+ .byte 0x9c # DW_OP_call_frame_cfa
+ # DW_AT_GNU_all_tail_call_sites
+ .uleb128 0x8 # (DIE (0x96) DW_TAG_variable)
+ .ascii "v\0" # DW_AT_name
+ .byte 0x1 # DW_AT_decl_file (gdb.arch/amd64-prologue-xmm.c)
+ .byte 0x12 # DW_AT_decl_line
+ .long 0xa9 # DW_AT_type
+ .uleb128 0x9 # DW_AT_location
+ .byte 0x3 # DW_OP_addr
+ .quad v
+ .uleb128 0x9 # (DIE (0xa9) DW_TAG_volatile_type)
+ .long 0x59 # DW_AT_type
+ .uleb128 0xa # (DIE (0xae) DW_TAG_variable)
+ .long .LASF0 # DW_AT_name: "fail"
+ .byte 0x1 # DW_AT_decl_file (gdb.arch/amd64-prologue-xmm.c)
+ .byte 0x12 # DW_AT_decl_line
+ .long 0xa9 # DW_AT_type
+ .uleb128 0x9 # DW_AT_location
+ .byte 0x3 # DW_OP_addr
+ .quad fail
+ .byte 0 # end of children of DIE 0xb
+ .section .debug_abbrev,"",@progbits
+.Ldebug_abbrev0:
+ .uleb128 0x1 # (abbrev code)
+ .uleb128 0x11 # (TAG: DW_TAG_compile_unit)
+ .byte 0x1 # DW_children_yes
+ .uleb128 0x25 # (DW_AT_producer)
+ .uleb128 0xe # (DW_FORM_strp)
+ .uleb128 0x13 # (DW_AT_language)
+ .uleb128 0xb # (DW_FORM_data1)
+ .uleb128 0x3 # (DW_AT_name)
+ .uleb128 0xe # (DW_FORM_strp)
+ .uleb128 0x1b # (DW_AT_comp_dir)
+ .uleb128 0xe # (DW_FORM_strp)
+ .uleb128 0x11 # (DW_AT_low_pc)
+ .uleb128 0x1 # (DW_FORM_addr)
+ .uleb128 0x12 # (DW_AT_high_pc)
+ .uleb128 0x1 # (DW_FORM_addr)
+ .uleb128 0x10 # (DW_AT_stmt_list)
+ .uleb128 0x17 # (DW_FORM_sec_offset)
+ .byte 0
+ .byte 0
+ .uleb128 0x2 # (abbrev code)
+ .uleb128 0x2e # (TAG: DW_TAG_subprogram)
+ .byte 0x1 # DW_children_yes
+ .uleb128 0x3 # (DW_AT_name)
+ .uleb128 0xe # (DW_FORM_strp)
+ .uleb128 0x3a # (DW_AT_decl_file)
+ .uleb128 0xb # (DW_FORM_data1)
+ .uleb128 0x3b # (DW_AT_decl_line)
+ .uleb128 0xb # (DW_FORM_data1)
+ .uleb128 0x27 # (DW_AT_prototyped)
+ .uleb128 0x19 # (DW_FORM_flag_present)
+ .uleb128 0x11 # (DW_AT_low_pc)
+ .uleb128 0x1 # (DW_FORM_addr)
+ .uleb128 0x12 # (DW_AT_high_pc)
+ .uleb128 0x1 # (DW_FORM_addr)
+ .uleb128 0x40 # (DW_AT_frame_base)
+ .uleb128 0x18 # (DW_FORM_exprloc)
+ .uleb128 0x2117 # (DW_AT_GNU_all_call_sites)
+ .uleb128 0x19 # (DW_FORM_flag_present)
+ .uleb128 0x1 # (DW_AT_sibling)
+ .uleb128 0x13 # (DW_FORM_ref4)
+ .byte 0
+ .byte 0
+ .uleb128 0x3 # (abbrev code)
+ .uleb128 0x5 # (TAG: DW_TAG_formal_parameter)
+ .byte 0 # DW_children_no
+ .uleb128 0x3 # (DW_AT_name)
+ .uleb128 0x8 # (DW_FORM_string)
+ .uleb128 0x3a # (DW_AT_decl_file)
+ .uleb128 0xb # (DW_FORM_data1)
+ .uleb128 0x3b # (DW_AT_decl_line)
+ .uleb128 0xb # (DW_FORM_data1)
+ .uleb128 0x49 # (DW_AT_type)
+ .uleb128 0x13 # (DW_FORM_ref4)
+ .uleb128 0x2 # (DW_AT_location)
+ .uleb128 0x18 # (DW_FORM_exprloc)
+ .byte 0
+ .byte 0
+ .uleb128 0x4 # (abbrev code)
+ .uleb128 0x18 # (TAG: DW_TAG_unspecified_parameters)
+ .byte 0 # DW_children_no
+ .byte 0
+ .byte 0
+ .uleb128 0x5 # (abbrev code)
+ .uleb128 0x24 # (TAG: DW_TAG_base_type)
+ .byte 0 # DW_children_no
+ .uleb128 0xb # (DW_AT_byte_size)
+ .uleb128 0xb # (DW_FORM_data1)
+ .uleb128 0x3e # (DW_AT_encoding)
+ .uleb128 0xb # (DW_FORM_data1)
+ .uleb128 0x3 # (DW_AT_name)
+ .uleb128 0x8 # (DW_FORM_string)
+ .byte 0
+ .byte 0
+ .uleb128 0x6 # (abbrev code)
+ .uleb128 0x2e # (TAG: DW_TAG_subprogram)
+ .byte 0 # DW_children_no
+ .uleb128 0x3 # (DW_AT_name)
+ .uleb128 0xe # (DW_FORM_strp)
+ .uleb128 0x3a # (DW_AT_decl_file)
+ .uleb128 0xb # (DW_FORM_data1)
+ .uleb128 0x3b # (DW_AT_decl_line)
+ .uleb128 0xb # (DW_FORM_data1)
+ .uleb128 0x27 # (DW_AT_prototyped)
+ .uleb128 0x19 # (DW_FORM_flag_present)
+ .uleb128 0x11 # (DW_AT_low_pc)
+ .uleb128 0x1 # (DW_FORM_addr)
+ .uleb128 0x12 # (DW_AT_high_pc)
+ .uleb128 0x1 # (DW_FORM_addr)
+ .uleb128 0x40 # (DW_AT_frame_base)
+ .uleb128 0x18 # (DW_FORM_exprloc)
+ .uleb128 0x2117 # (DW_AT_GNU_all_call_sites)
+ .uleb128 0x19 # (DW_FORM_flag_present)
+ .byte 0
+ .byte 0
+ .uleb128 0x7 # (abbrev code)
+ .uleb128 0x2e # (TAG: DW_TAG_subprogram)
+ .byte 0 # DW_children_no
+ .uleb128 0x3f # (DW_AT_external)
+ .uleb128 0x19 # (DW_FORM_flag_present)
+ .uleb128 0x3 # (DW_AT_name)
+ .uleb128 0xe # (DW_FORM_strp)
+ .uleb128 0x3a # (DW_AT_decl_file)
+ .uleb128 0xb # (DW_FORM_data1)
+ .uleb128 0x3b # (DW_AT_decl_line)
+ .uleb128 0xb # (DW_FORM_data1)
+ .uleb128 0x27 # (DW_AT_prototyped)
+ .uleb128 0x19 # (DW_FORM_flag_present)
+ .uleb128 0x49 # (DW_AT_type)
+ .uleb128 0x13 # (DW_FORM_ref4)
+ .uleb128 0x11 # (DW_AT_low_pc)
+ .uleb128 0x1 # (DW_FORM_addr)
+ .uleb128 0x12 # (DW_AT_high_pc)
+ .uleb128 0x1 # (DW_FORM_addr)
+ .uleb128 0x40 # (DW_AT_frame_base)
+ .uleb128 0x18 # (DW_FORM_exprloc)
+ .uleb128 0x2116 # (DW_AT_GNU_all_tail_call_sites)
+ .uleb128 0x19 # (DW_FORM_flag_present)
+ .byte 0
+ .byte 0
+ .uleb128 0x8 # (abbrev code)
+ .uleb128 0x34 # (TAG: DW_TAG_variable)
+ .byte 0 # DW_children_no
+ .uleb128 0x3 # (DW_AT_name)
+ .uleb128 0x8 # (DW_FORM_string)
+ .uleb128 0x3a # (DW_AT_decl_file)
+ .uleb128 0xb # (DW_FORM_data1)
+ .uleb128 0x3b # (DW_AT_decl_line)
+ .uleb128 0xb # (DW_FORM_data1)
+ .uleb128 0x49 # (DW_AT_type)
+ .uleb128 0x13 # (DW_FORM_ref4)
+ .uleb128 0x2 # (DW_AT_location)
+ .uleb128 0x18 # (DW_FORM_exprloc)
+ .byte 0
+ .byte 0
+ .uleb128 0x9 # (abbrev code)
+ .uleb128 0x35 # (TAG: DW_TAG_volatile_type)
+ .byte 0 # DW_children_no
+ .uleb128 0x49 # (DW_AT_type)
+ .uleb128 0x13 # (DW_FORM_ref4)
+ .byte 0
+ .byte 0
+ .uleb128 0xa # (abbrev code)
+ .uleb128 0x34 # (TAG: DW_TAG_variable)
+ .byte 0 # DW_children_no
+ .uleb128 0x3 # (DW_AT_name)
+ .uleb128 0xe # (DW_FORM_strp)
+ .uleb128 0x3a # (DW_AT_decl_file)
+ .uleb128 0xb # (DW_FORM_data1)
+ .uleb128 0x3b # (DW_AT_decl_line)
+ .uleb128 0xb # (DW_FORM_data1)
+ .uleb128 0x49 # (DW_AT_type)
+ .uleb128 0x13 # (DW_FORM_ref4)
+ .uleb128 0x2 # (DW_AT_location)
+ .uleb128 0x18 # (DW_FORM_exprloc)
+ .byte 0
+ .byte 0
+ .byte 0
+ .section .debug_aranges,"",@progbits
+ .long 0x2c # Length of Address Ranges Info
+ .value 0x2 # DWARF Version
+ .long .Ldebug_info0 # Offset of Compilation Unit Info
+ .byte 0x8 # Size of Address
+ .byte 0 # Size of Segment Descriptor
+ .value 0 # Pad to 16 byte boundary
+ .value 0
+ .quad .Ltext0 # Address
+ .quad .Letext0-.Ltext0 # Length
+ .quad 0
+ .quad 0
+ .section .debug_line,"",@progbits
+.Ldebug_line0:
+ .section .debug_str,"MS",@progbits,1
+.LASF3:
+ .string ""
+.LASF0:
+ .string "fail"
+.LASF4:
+ .string "func"
+.LASF1:
+ .string "GNU C 4.6.1 20110715 (Red Hat 4.6.1-3)"
+.LASF2:
+ .string "gdb.arch/amd64-prologue-xmm.c"
+.LASF5:
+ .string "marker"
+.LASF6:
+ .string "main"
+ .ident "GCC: (GNU) 4.6.1 20110715 (Red Hat 4.6.1-3)"
+ .section .note.GNU-stack,"",@progbits

View File

@ -0,0 +1,110 @@
http://sourceware.org/ml/gdb-patches/2011-09/msg00450.html
Subject: [patch 1/2] Code cleanup: Unify dwarf2_per_cu_addr_size, dwarf2_per_cu_offset_size
Hi,
this is more rather for patch 2/2, it has positive LoC change but still
I would find it applicable even on its own.
No functionality change intended.
Thanks,
Jan
gdb/
2011-09-26 Jan Kratochvil <jan.kratochvil@redhat.com>
Code cleanup.
* dwarf2read.c (per_cu_header_read_in): New function.
(dwarf2_per_cu_addr_size, dwarf2_per_cu_offset_size): Use it, with new
variables cu_header_local and cu_headerp.
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -15187,26 +15187,42 @@ dwarf2_per_cu_objfile (struct dwarf2_per_cu_data *per_cu)
return objfile;
}
+/* Return comp_unit_head for PER_CU, either already available in PER_CU->CU
+ (CU_HEADERP is unused in such case) or prepare a temporary copy at
+ CU_HEADERP first. */
+
+static const struct comp_unit_head *
+per_cu_header_read_in (struct comp_unit_head *cu_headerp,
+ struct dwarf2_per_cu_data *per_cu)
+{
+ struct objfile *objfile;
+ struct dwarf2_per_objfile *per_objfile;
+ gdb_byte *info_ptr;
+
+ if (per_cu->cu)
+ return &per_cu->cu->header;
+
+ objfile = per_cu->objfile;
+ per_objfile = objfile_data (objfile, dwarf2_objfile_data_key);
+ info_ptr = per_objfile->info.buffer + per_cu->offset;
+
+ memset (cu_headerp, 0, sizeof (*cu_headerp));
+ read_comp_unit_head (cu_headerp, info_ptr, objfile->obfd);
+
+ return cu_headerp;
+}
+
/* Return the address size given in the compilation unit header for CU. */
CORE_ADDR
dwarf2_per_cu_addr_size (struct dwarf2_per_cu_data *per_cu)
{
- if (per_cu->cu)
- return per_cu->cu->header.addr_size;
- else
- {
- /* If the CU is not currently read in, we re-read its header. */
- struct objfile *objfile = per_cu->objfile;
- struct dwarf2_per_objfile *per_objfile
- = objfile_data (objfile, dwarf2_objfile_data_key);
- gdb_byte *info_ptr = per_objfile->info.buffer + per_cu->offset;
- struct comp_unit_head cu_header;
+ struct comp_unit_head cu_header_local;
+ const struct comp_unit_head *cu_headerp;
- memset (&cu_header, 0, sizeof cu_header);
- read_comp_unit_head (&cu_header, info_ptr, objfile->obfd);
- return cu_header.addr_size;
- }
+ cu_headerp = per_cu_header_read_in (&cu_header_local, per_cu);
+
+ return cu_headerp->addr_size;
}
/* Return the offset size given in the compilation unit header for CU. */
@@ -15214,21 +15230,12 @@ dwarf2_per_cu_addr_size (struct dwarf2_per_cu_data *per_cu)
int
dwarf2_per_cu_offset_size (struct dwarf2_per_cu_data *per_cu)
{
- if (per_cu->cu)
- return per_cu->cu->header.offset_size;
- else
- {
- /* If the CU is not currently read in, we re-read its header. */
- struct objfile *objfile = per_cu->objfile;
- struct dwarf2_per_objfile *per_objfile
- = objfile_data (objfile, dwarf2_objfile_data_key);
- gdb_byte *info_ptr = per_objfile->info.buffer + per_cu->offset;
- struct comp_unit_head cu_header;
+ struct comp_unit_head cu_header_local;
+ const struct comp_unit_head *cu_headerp;
- memset (&cu_header, 0, sizeof cu_header);
- read_comp_unit_head (&cu_header, info_ptr, objfile->obfd);
- return cu_header.offset_size;
- }
+ cu_headerp = per_cu_header_read_in (&cu_header_local, per_cu);
+
+ return cu_headerp->offset_size;
}
/* Return the text offset of the CU. The returned offset comes from

View File

@ -0,0 +1,426 @@
http://sourceware.org/ml/gdb-patches/2011-09/msg00451.html
Subject: [patch 2/2] Fix DW_OP_GNU_implicit_pointer for DWARF32 v3+ on 64-bit arches
Hi,
on 64-bit targets DWARF-3+ is used DW_OP_GNU_implicit_pointer does not work.
DWARF-2 says:
This type of reference (DW_FORM_ref_addr) is the size of an address on
the target architecture;
DWARF-3 says:
1.5.1 Upward Compatibility
References that use the attribute form DW_FORM_ref_addr are specified
to be four bytes in the DWARF 32-bit format and eight bytes in the
DWARF 64-bit format, while DWARF Version 2 specifies that such
references have the same size as an address on the target system (see
Sections 7.4 and 7.5.4).
(DW_FORM_ref_addr)
In the 32-bit DWARF format, this offset is a 4-byte unsigned value; in
the 64-bit DWARF format, it is an 8-byte unsigned value (see Section
7.4).
GDB currently parsed DW_OP_GNU_implicit_pointer the DWARF-2 way, being
incompatible with DWARF-3+.
I think DW_OP_GNU_implicit_pointer does not make sense to be used from
.debug_frame (DWARF-5 is not yet released to say more) so for .debug_frame its
use is just not permitted (the code would be more complicated otherwise).
No regressions on {x86_64,x86_64-m32,i686}-fedora16pre-linux-gnu.
Thanks,
Jan
gdb/
2011-09-26 Jan Kratochvil <jan.kratochvil@redhat.com>
Fix DW_OP_GNU_implicit_pointer for DWARF32 v3+ on 64-bit arches.
* dwarf2-frame.c (execute_stack_op): Initialize ctx->ref_addr_size.
* dwarf2expr.c (execute_stack_op) <DW_OP_GNU_implicit_pointer>: Use
ctx->ref_addr_size. Handle its invalid value.
* dwarf2expr.h (struct dwarf_expr_context): New field ref_addr_size.
* dwarf2loc.c (dwarf2_evaluate_loc_desc_full)
(dwarf2_loc_desc_needs_frame): Initialize ctx->ref_addr_size.
* dwarf2loc.h (dwarf2_per_cu_ref_addr_size): New declaration.
* dwarf2read.c (decode_locdesc): Initialize ctx->ref_addr_size.
(dwarf2_per_cu_ref_addr_size): New function.
gdb/testsuite/
2011-09-26 Jan Kratochvil <jan.kratochvil@redhat.com>
Fix DW_OP_GNU_implicit_pointer for DWARF32 v3+ on 64-bit arches.
* gdb.dwarf2/implptr-64bit.S: New file.
* gdb.dwarf2/implptr-64bit.exp: New file.
Index: gdb-7.3/gdb/dwarf2-frame.c
===================================================================
--- gdb-7.3.orig/gdb/dwarf2-frame.c 2011-03-18 19:52:30.000000000 +0100
+++ gdb-7.3/gdb/dwarf2-frame.c 2011-09-26 22:38:52.000000000 +0200
@@ -397,6 +397,7 @@ execute_stack_op (const gdb_byte *exp, U
ctx->gdbarch = get_frame_arch (this_frame);
ctx->addr_size = addr_size;
+ ctx->ref_addr_size = -1;
ctx->offset = offset;
ctx->baton = this_frame;
ctx->read_reg = read_reg;
Index: gdb-7.3/gdb/dwarf2expr.c
===================================================================
--- gdb-7.3.orig/gdb/dwarf2expr.c 2011-09-26 22:38:34.000000000 +0200
+++ gdb-7.3/gdb/dwarf2expr.c 2011-09-26 22:38:52.000000000 +0200
@@ -539,10 +539,14 @@ execute_stack_op (struct dwarf_expr_cont
ULONGEST die;
LONGEST len;
+ if (ctx->ref_addr_size == -1)
+ error (_("DWARF-2 expression error: DW_OP_GNU_implicit_pointer "
+ "is not allowed in frame context"));
+
/* The referred-to DIE. */
- ctx->len = extract_unsigned_integer (op_ptr, ctx->addr_size,
+ ctx->len = extract_unsigned_integer (op_ptr, ctx->ref_addr_size,
byte_order);
- op_ptr += ctx->addr_size;
+ op_ptr += ctx->ref_addr_size;
/* The byte offset into the data. */
op_ptr = read_sleb128 (op_ptr, op_end, &len);
Index: gdb-7.3/gdb/dwarf2expr.h
===================================================================
--- gdb-7.3.orig/gdb/dwarf2expr.h 2011-09-26 22:38:34.000000000 +0200
+++ gdb-7.3/gdb/dwarf2expr.h 2011-09-26 22:38:52.000000000 +0200
@@ -78,6 +78,10 @@ struct dwarf_expr_context
/* Target address size in bytes. */
int addr_size;
+ /* DW_FORM_ref_addr size in bytes. If -1 DWARF is executed from a frame
+ context and operations depending on DW_FORM_ref_addr are not allowed. */
+ int ref_addr_size;
+
/* Offset used to relocate DW_OP_addr argument. */
CORE_ADDR offset;
Index: gdb-7.3/gdb/dwarf2loc.c
===================================================================
--- gdb-7.3.orig/gdb/dwarf2loc.c 2011-09-26 22:38:34.000000000 +0200
+++ gdb-7.3/gdb/dwarf2loc.c 2011-09-26 22:39:12.000000000 +0200
@@ -372,6 +372,7 @@ dwarf_expr_prep_ctx (struct frame_info *
ctx->gdbarch = get_objfile_arch (objfile);
ctx->addr_size = dwarf2_per_cu_addr_size (per_cu);
+ ctx->ref_addr_size = dwarf2_per_cu_ref_addr_size (per_cu);
ctx->offset = dwarf2_per_cu_text_offset (per_cu);
ctx->baton = &baton;
ctx->read_reg = dwarf_expr_read_reg;
@@ -1507,6 +1508,7 @@ dwarf2_loc_desc_needs_frame (const gdb_b
ctx->gdbarch = get_objfile_arch (objfile);
ctx->addr_size = dwarf2_per_cu_addr_size (per_cu);
+ ctx->ref_addr_size = dwarf2_per_cu_ref_addr_size (per_cu);
ctx->offset = dwarf2_per_cu_text_offset (per_cu);
ctx->baton = &baton;
ctx->read_reg = needs_frame_read_reg;
Index: gdb-7.3/gdb/dwarf2loc.h
===================================================================
--- gdb-7.3.orig/gdb/dwarf2loc.h 2011-09-26 22:38:34.000000000 +0200
+++ gdb-7.3/gdb/dwarf2loc.h 2011-09-26 22:38:52.000000000 +0200
@@ -39,6 +39,10 @@ struct objfile *dwarf2_per_cu_objfile (s
/* Return the address size given in the compilation unit header for CU. */
CORE_ADDR dwarf2_per_cu_addr_size (struct dwarf2_per_cu_data *cu);
+/* Return the DW_FORM_ref_addr size given in the compilation unit header for
+ CU. */
+int dwarf2_per_cu_ref_addr_size (struct dwarf2_per_cu_data *cu);
+
/* Return the offset size given in the compilation unit header for CU. */
int dwarf2_per_cu_offset_size (struct dwarf2_per_cu_data *cu);
Index: gdb-7.3/gdb/dwarf2read.c
===================================================================
--- gdb-7.3.orig/gdb/dwarf2read.c 2011-09-26 22:38:38.000000000 +0200
+++ gdb-7.3/gdb/dwarf2read.c 2011-09-26 22:38:52.000000000 +0200
@@ -15277,6 +15277,22 @@ dwarf2_per_cu_offset_size (struct dwarf2
return cu_headerp->offset_size;
}
+/* See its dwarf2loc.h declaration. */
+
+int
+dwarf2_per_cu_ref_addr_size (struct dwarf2_per_cu_data *per_cu)
+{
+ struct comp_unit_head cu_header_local;
+ const struct comp_unit_head *cu_headerp;
+
+ cu_headerp = per_cu_header_read_in (&cu_header_local, per_cu);
+
+ if (cu_headerp->version == 2)
+ return cu_headerp->addr_size;
+ else
+ return cu_headerp->offset_size;
+}
+
/* Return the text offset of the CU. The returned offset comes from
this CU's objfile. If this objfile came from a separate debuginfo
file, then the offset may be different from the corresponding
Index: gdb-7.3/gdb/testsuite/gdb.dwarf2/implptr-64bit.S
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ gdb-7.3/gdb/testsuite/gdb.dwarf2/implptr-64bit.S 2011-09-26 22:38:52.000000000 +0200
@@ -0,0 +1,197 @@
+/* Copyright 2010, 2011 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+ .section .debug_info
+d:
+ /* Length of Compilation Unit Info */
+#if OFFSET_SIZE == 4
+# define OFFSET .4byte
+ .4byte debug_end - 1f
+#elif OFFSET_SIZE == 8
+# define OFFSET .8byte
+ .4byte 0xffffffff
+ .8byte debug_end - 1f
+#else
+# error
+#endif
+#if ADDR_SIZE == 4
+# define ADDR .4byte
+#elif ADDR_SIZE == 8
+# define ADDR .8byte
+#else
+# error
+#endif
+#if REF_ADDR_SIZE == 4
+# define REF_ADDR .4byte
+#elif REF_ADDR_SIZE == 8
+# define REF_ADDR .8byte
+#else
+# error
+#endif
+1:
+ .2byte DWARF_VERSION /* DWARF version number */
+ OFFSET .Ldebug_abbrev0 /* Offset Into Abbrev. Section */
+ .byte ADDR_SIZE /* Pointer Size (in bytes) */
+
+ .uleb128 0x1 /* (DIE (0xb) DW_TAG_compile_unit) */
+ .ascii "GNU C 4.4.3\0" /* DW_AT_producer */
+ .byte 0x1 /* DW_AT_language */
+ .ascii "1.c\0" /* DW_AT_name */
+
+.Ltype_int:
+ .uleb128 0x7 /* DW_TAG_base_type */
+ .byte 0x4 /* DW_AT_byte_size */
+ .byte 0x5 /* DW_AT_encoding */
+ .ascii "int\0" /* DW_AT_name */
+
+.Ltype_struct:
+ .uleb128 0x2 /* DW_TAG_structure_type */
+ .ascii "s\0" /* DW_AT_name */
+ .byte 4 /* DW_AT_byte_size */
+
+ .uleb128 0x3 /* DW_TAG_member */
+ .ascii "f\0" /* DW_AT_name */
+ .4byte .Ltype_int - d /* DW_AT_type */
+ .byte 0 /* DW_AT_data_member_location */
+
+ .byte 0x0 /* end of children of DW_TAG_structure_type */
+
+ .uleb128 6 /* Abbrev: DW_TAG_subprogram */
+ .ascii "main\0" /* DW_AT_name */
+ ADDR main /* DW_AT_low_pc */
+ ADDR main + 0x100 /* DW_AT_high_pc */
+ .4byte .Ltype_int - d /* DW_AT_type */
+ .byte 1 /* DW_AT_external */
+
+.Ltype_structptr:
+ .uleb128 0x5 /* DW_TAG_pointer_type */
+ .byte ADDR_SIZE /* DW_AT_byte_size */
+ .4byte .Ltype_struct - d /* DW_AT_type */
+
+.Lvar_out:
+ .uleb128 0x4 /* (DW_TAG_variable) */
+ .ascii "v\0" /* DW_AT_name */
+ .byte 2f - 1f /* DW_AT_location: DW_FORM_block1 */
+1:
+ .byte 0x9e /* DW_OP_implicit_value */
+ .uleb128 2f - 3f
+3:
+ .byte 1, 1, 1, 1
+2:
+ .4byte .Ltype_struct - d /* DW_AT_type */
+
+ .uleb128 0x4 /* (DW_TAG_variable) */
+ .ascii "p\0" /* DW_AT_name */
+ .byte 2f - 1f /* DW_AT_location: DW_FORM_block1 */
+1:
+ .byte 0xf2 /* DW_OP_GNU_implicit_pointer */
+ REF_ADDR .Lvar_out - d /* referenced DIE */
+ .sleb128 0 /* offset */
+2:
+ .4byte .Ltype_structptr - d /* DW_AT_type */
+
+ .byte 0x0 /* end of children of main */
+
+ .byte 0x0 /* end of children of CU */
+debug_end:
+
+ .section .debug_abbrev
+.Ldebug_abbrev0:
+
+ .uleb128 0x1 /* (abbrev code) */
+ .uleb128 0x11 /* (TAG: DW_TAG_compile_unit) */
+ .byte 0x1 /* DW_children_yes */
+ .uleb128 0x25 /* (DW_AT_producer) */
+ .uleb128 0x8 /* (DW_FORM_string) */
+ .uleb128 0x13 /* (DW_AT_language) */
+ .uleb128 0xb /* (DW_FORM_data1) */
+ .uleb128 0x3 /* (DW_AT_name) */
+ .uleb128 0x8 /* (DW_FORM_string) */
+ .byte 0x0
+ .byte 0x0
+
+ .uleb128 0x2 /* (abbrev code) */
+ .uleb128 0x13 /* (TAG: DW_TAG_structure_type) */
+ .byte 0x1 /* DW_children_yes */
+ .uleb128 0x3 /* (DW_AT_name) */
+ .uleb128 0x8 /* (DW_FORM_string) */
+ .uleb128 0xb /* (DW_AT_byte_size) */
+ .uleb128 0xb /* (DW_FORM_data1) */
+ .byte 0
+ .byte 0
+
+ .uleb128 0x3 /* (abbrev code) */
+ .uleb128 0xd /* (TAG: DW_TAG_member) */
+ .byte 0 /* DW_children_no */
+ .uleb128 0x3 /* (DW_AT_name) */
+ .uleb128 0x8 /* (DW_FORM_string) */
+ .uleb128 0x49 /* (DW_AT_type) */
+ .uleb128 0x13 /* (DW_FORM_ref4) */
+ .uleb128 0x38 /* (DW_AT_data_member_location) */
+ .uleb128 0xb /* (DW_FORM_data1) */
+ .byte 0
+ .byte 0
+
+ .uleb128 0x4 /* (abbrev code) */
+ .uleb128 0x34 /* (TAG: DW_TAG_variable) */
+ .byte 0x0 /* DW_children_yes */
+ .uleb128 0x3 /* (DW_AT_name) */
+ .uleb128 0x8 /* (DW_FORM_string) */
+ .uleb128 0x02 /* (DW_AT_location) */
+ .uleb128 0xa /* (DW_FORM_block1) */
+ .uleb128 0x49 /* (DW_AT_type) */
+ .uleb128 0x13 /* (DW_FORM_ref4) */
+ .byte 0x0
+ .byte 0x0
+
+ .uleb128 0x5 /* (abbrev code) */
+ .uleb128 0xf /* (TAG: DW_TAG_pointer_type) */
+ .byte 0x0 /* DW_children_no */
+ .uleb128 0xb /* (DW_AT_byte_size) */
+ .uleb128 0xb /* (DW_FORM_data1) */
+ .uleb128 0x49 /* (DW_AT_type) */
+ .uleb128 0x13 /* (DW_FORM_ref4) */
+ .byte 0x0
+ .byte 0x0
+
+ .uleb128 6 /* Abbrev code */
+ .uleb128 0x2e /* DW_TAG_subprogram */
+ .byte 1 /* has_children */
+ .uleb128 0x3 /* DW_AT_name */
+ .uleb128 0x8 /* DW_FORM_string */
+ .uleb128 0x11 /* DW_AT_low_pc */
+ .uleb128 0x1 /* DW_FORM_addr */
+ .uleb128 0x12 /* DW_AT_high_pc */
+ .uleb128 0x1 /* DW_FORM_addr */
+ .uleb128 0x49 /* DW_AT_type */
+ .uleb128 0x13 /* DW_FORM_ref4 */
+ .uleb128 0x3f /* DW_AT_external */
+ .uleb128 0xc /* DW_FORM_flag */
+ .byte 0x0 /* Terminator */
+ .byte 0x0 /* Terminator */
+
+ .uleb128 0x7 /* (abbrev code) */
+ .uleb128 0x24 /* (TAG: DW_TAG_base_type) */
+ .byte 0 /* DW_children_no */
+ .uleb128 0xb /* (DW_AT_byte_size) */
+ .uleb128 0xb /* (DW_FORM_data1) */
+ .uleb128 0x3e /* (DW_AT_encoding) */
+ .uleb128 0xb /* (DW_FORM_data1) */
+ .uleb128 0x3 /* (DW_AT_name) */
+ .uleb128 0x8 /* (DW_FORM_string) */
+ .byte 0
+ .byte 0
+
+ .byte 0x0
Index: gdb-7.3/gdb/testsuite/gdb.dwarf2/implptr-64bit.exp
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ gdb-7.3/gdb/testsuite/gdb.dwarf2/implptr-64bit.exp 2011-09-26 22:38:52.000000000 +0200
@@ -0,0 +1,51 @@
+# Copyright 2011 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+load_lib dwarf.exp
+
+# This test can only be run on targets which support DWARF-2 and use gas.
+if {![dwarf2_support]} {
+ return 0
+}
+
+set testfile "implptr-64bit"
+set srcfile ${testfile}.S
+set mainfile main.c
+
+proc test { dwarf_version offset_size addr_size ref_addr_size } {
+ global testfile srcfile mainfile
+
+ set opts {}
+ foreach n { dwarf_version offset_size addr_size ref_addr_size } {
+ lappend opts "additional_flags=-D[string toupper $n]=[expr "\$$n"]"
+ }
+
+ set name "d${dwarf_version}o${offset_size}a${addr_size}r${ref_addr_size}"
+ set executable ${testfile}-${name}
+ if [prepare_for_testing ${testfile}.exp $executable "${srcfile} ${mainfile}" $opts] {
+ return -1
+ }
+
+ if ![runto_main] {
+ return -1
+ }
+
+ gdb_test "p/x p->f" " = 0x1010101" $name
+}
+
+# DWARF_VERSION OFFSET_SIZE ADDR_SIZE REF_ADDR_SIZE
+test 2 8 4 4
+test 2 4 8 8
+test 3 8 4 8
+test 3 4 8 4

View File

@ -0,0 +1,203 @@
[patch][python] Fix sigsegv when a printer fails to return a value and string_print is set.
http://sourceware.org/ml/gdb-patches/2011-07/msg00719.html
http://sourceware.org/ml/gdb-cvs/2011-07/msg00234.html
### src/gdb/ChangeLog 2011/07/27 19:31:30 1.13236
### src/gdb/ChangeLog 2011/07/28 10:36:37 1.13237
## -1,3 +1,8 @@
+2011-07-28 Phil Muldoon <pmuldoon@redhat.com>
+
+ * varobj.c (value_get_print_value): Move hint check later into the
+ function. Comment function. Free thevalue before reusing it.
+
2011-07-27 Jan Kratochvil <jan.kratochvil@redhat.com>
Pedro Alves <pedro@codesourcery.com>
--- src/gdb/varobj.c 2011/07/18 09:21:43 1.180
+++ src/gdb/varobj.c 2011/07/28 10:36:40 1.181
@@ -2610,25 +2610,21 @@
if (PyObject_HasAttr (value_formatter, gdbpy_to_string_cst))
{
- char *hint;
struct value *replacement;
PyObject *output = NULL;
- hint = gdbpy_get_display_hint (value_formatter);
- if (hint)
- {
- if (!strcmp (hint, "string"))
- string_print = 1;
- xfree (hint);
- }
-
output = apply_varobj_pretty_printer (value_formatter,
&replacement,
stb);
+
+ /* If we have string like output ... */
if (output)
{
make_cleanup_py_decref (output);
+ /* If this is a lazy string, extract it. For lazy
+ strings we always print as a string, so set
+ string_print. */
if (gdbpy_is_lazy_string (output))
{
gdbpy_extract_lazy_string (output, &str_addr, &type,
@@ -2638,12 +2634,27 @@
}
else
{
+ /* If it is a regular (non-lazy) string, extract
+ it and copy the contents into THEVALUE. If the
+ hint says to print it as a string, set
+ string_print. Otherwise just return the extracted
+ string as a value. */
+
PyObject *py_str
= python_string_to_target_python_string (output);
if (py_str)
{
char *s = PyString_AsString (py_str);
+ char *hint;
+
+ hint = gdbpy_get_display_hint (value_formatter);
+ if (hint)
+ {
+ if (!strcmp (hint, "string"))
+ string_print = 1;
+ xfree (hint);
+ }
len = PyString_Size (py_str);
thevalue = xmemdup (s, len + 1, len + 1);
@@ -2662,6 +2673,9 @@
gdbpy_print_stack ();
}
}
+ /* If the printer returned a replacement value, set VALUE
+ to REPLACEMENT. If there is not a replacement value,
+ just use the value passed to this function. */
if (replacement)
value = replacement;
}
@@ -2672,12 +2686,18 @@
get_formatted_print_options (&opts, format_code[(int) format]);
opts.deref_ref = 0;
opts.raw = 1;
+
+ /* If the THEVALUE has contents, it is a regular string. */
if (thevalue)
LA_PRINT_STRING (stb, type, thevalue, len, encoding, 0, &opts);
else if (string_print)
+ /* Otherwise, if string_print is set, and it is not a regular
+ string, it is a lazy string. */
val_print_string (type, encoding, str_addr, len, stb, &opts);
else
+ /* All other cases. */
common_val_print (value, stb, 0, &opts, current_language);
+
thevalue = ui_file_xstrdup (stb, NULL);
do_cleanups (old_chain);
### src/gdb/testsuite/ChangeLog 2011/07/27 21:18:39 1.2816
### src/gdb/testsuite/ChangeLog 2011/07/28 10:36:40 1.2817
## -1,3 +1,10 @@
+2011-07-28 Phil Muldoon <pmuldoon@redhat.com>
+
+ * gdb.python/py-mi.exp: Test printers returning string hint, and
+ also not returning a value.
+ * gdb.python/py-prettyprint.c: Add testcase for above.
+ * gdb.python/py-prettyprint.py: Add test printer for above.
+
2011-07-27 Jan Kratochvil <jan.kratochvil@redhat.com>
* gdb.dwarf2/dw2-simple-locdesc.S: Change DWARF version to 3.
--- src/gdb/testsuite/gdb.python/py-mi.exp 2011/07/26 18:38:55 1.13
+++ src/gdb/testsuite/gdb.python/py-mi.exp 2011/07/28 10:36:40 1.14
@@ -284,6 +284,13 @@ mi_list_varobj_children nstype2 {
{ {nstype2.<error at 0>} {<error at 0>} 6 {char \[6\]} }
} "list children after setting exception flag"
+mi_create_varobj me me \
+ "create me varobj"
+
+mi_gdb_test "-var-evaluate-expression me" \
+ "\\^done,value=\"<error reading variable: Cannot access memory.>.*\"" \
+ "evaluate me varobj"
+
# C++ MI tests
gdb_exit
if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" \
--- src/gdb/testsuite/gdb.python/py-prettyprint.c 2011/04/29 12:45:46 1.12
+++ src/gdb/testsuite/gdb.python/py-prettyprint.c 2011/07/28 10:36:40 1.13
@@ -149,6 +149,11 @@
typedef struct justchildren nostring_type;
+struct memory_error
+{
+ const char *s;
+};
+
struct container
{
string name;
@@ -227,6 +232,7 @@
/* Clearing by being `static' could invoke an other GDB C++ bug. */
struct nullstr nullstr;
nostring_type nstype, nstype2;
+ struct memory_error me;
struct ns ns, ns2;
struct lazystring estring, estring2;
struct hint_error hint_error;
@@ -234,6 +240,8 @@
nstype.elements = narray;
nstype.len = 0;
+ me.s = "blah";
+
init_ss(&ss, 1, 2);
init_ss(ssa+0, 3, 4);
init_ss(ssa+1, 5, 6);
--- src/gdb/testsuite/gdb.python/py-prettyprint.py 2011/04/11 17:40:41 1.11
+++ src/gdb/testsuite/gdb.python/py-prettyprint.py 2011/07/28 10:36:40 1.12
@@ -17,6 +17,7 @@
# printers.
import re
+import gdb
# Test returning a Value from a printer.
class string_print:
@@ -186,6 +187,18 @@
yield 's', self.val['s']
yield 'x', self.val['x']
+class MemoryErrorString:
+ "Raise an error"
+
+ def __init__(self, val):
+ self.val = val
+
+ def to_string(self):
+ raise gdb.MemoryError ("Cannot access memory.");
+
+ def display_hint (self):
+ return 'string'
+
def lookup_function (val):
"Look-up and return a pretty-printer that can print val."
@@ -261,6 +274,8 @@
pretty_printers_dict[re.compile ('^struct hint_error$')] = pp_hint_error
pretty_printers_dict[re.compile ('^hint_error$')] = pp_hint_error
+ pretty_printers_dict[re.compile ('^memory_error$')] = MemoryErrorString
+
pretty_printers_dict = {}
register_pretty_printers ()

View File

@ -0,0 +1,137 @@
commit 6e962026419305ae6c540eb01a735cf7c2685c20
Author: pmuldoon <pmuldoon>
Date: Tue Aug 9 12:45:39 2011 +0000
2011-08-09 Phil Muldoon <pmuldoon@redhat.com>
* python/lib/gdb/__init__.py: Auto-load files in command and
function directories.
* python/python.c (finish_python_initialization): Use
os.path.join.
* python/lib/gdb/command/pretty_printers.py: Self register
command.
* NEWS: Document auto-loading.
2011-08-09 Phil Muldoon <pmuldoon@redhat.com>
* gdb.texinfo (Python): Document command and function
auto-loading.
### a/gdb/ChangeLog
### b/gdb/ChangeLog
## -1,3 +1,13 @@
+2011-08-09 Phil Muldoon <pmuldoon@redhat.com>
+
+ * python/lib/gdb/__init__.py: Auto-load files in command and
+ function directories.
+ * python/python.c (finish_python_initialization): Use
+ os.path.join.
+ * python/lib/gdb/command/pretty_printers.py: Self register
+ command.
+ * NEWS: Document auto-loading.
+
2011-08-08 Jan Kratochvil <jan.kratochvil@redhat.com>
* dwarf2loc.c (dwarf2_evaluate_loc_desc_full) <DWARF_VALUE_STACK>
--- a/gdb/NEWS
+++ b/gdb/NEWS
@@ -1,6 +1,13 @@
What has changed in GDB?
(Organized release by release)
+*** Changes after GDB 7.3.1
+
+** Python commands and convenience-functions located in
+ 'data-directory'/python/gdb/command and
+ 'data-directory'/python/gdb/function are now automatically loaded
+ on GDB start-up.
+
*** Changes in GDB 7.3.1
* The build failure for NetBSD and OpenBSD targets have now been fixed.
### a/gdb/doc/ChangeLog
### b/gdb/doc/ChangeLog
## -1,3 +1,8 @@
+2011-08-09 Phil Muldoon <pmuldoon@redhat.com>
+
+ * gdb.texinfo (Python): Document command and function
+ auto-loading.
+
2011-07-26 Jan Kratochvil <jan.kratochvil@redhat.com>
Eli Zaretskii <eliz@gnu.org>
--- a/gdb/doc/gdb.texinfo
+++ b/gdb/doc/gdb.texinfo
@@ -20845,6 +20845,12 @@ This directory, known as the @dfn{python directory},
is automatically added to the Python Search Path in order to allow
the Python interpreter to locate all scripts installed at this location.
+Additionally, @value{GDBN} commands and convenience functions which
+are written in Python and are located in the
+@file{@var{data-directory}/python/gdb/command} or
+@file{@var{data-directory}/python/gdb/function} directories are
+automatically imported when @value{GDBN} starts.
+
@menu
* Python Commands:: Accessing Python from @value{GDBN}.
* Python API:: Accessing @value{GDBN} from Python.
--- a/gdb/python/lib/gdb/__init__.py
+++ b/gdb/python/lib/gdb/__init__.py
@@ -13,6 +13,29 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-import gdb.command.pretty_printers
+import traceback
-gdb.command.pretty_printers.register_pretty_printer_commands()
+# Auto-load all functions/commands.
+
+# Modules to auto-load, and the paths where those modules exist.
+
+module_dict = {
+ 'gdb.function': os.path.join(gdb.PYTHONDIR, 'gdb', 'function'),
+ 'gdb.command': os.path.join(gdb.PYTHONDIR, 'gdb', 'command')
+}
+
+# Iterate the dictionary, collating the Python files in each module
+# path. Construct the module name, and import.
+
+for module, location in module_dict.iteritems():
+ if os.path.exists(location):
+ py_files = filter(lambda x: x.endswith('.py') and x != '__init__.py',
+ os.listdir(location))
+
+ for py_file in py_files:
+ # Construct from foo.py, gdb.module.foo
+ py_file = module + '.' + py_file[:-3]
+ try:
+ exec('import ' + py_file)
+ except:
+ print >> sys.stderr, traceback.format_exc()
--- a/gdb/python/lib/gdb/command/pretty_printers.py
+++ b/gdb/python/lib/gdb/command/pretty_printers.py
@@ -368,3 +368,5 @@ def register_pretty_printer_commands():
InfoPrettyPrinter()
EnablePrettyPrinter()
DisablePrettyPrinter()
+
+register_pretty_printer_commands()
--- a/gdb/python/python.c
+++ b/gdb/python/python.c
@@ -1302,13 +1302,13 @@ def GdbSetPythonDirectory (dir):\n\
sys.path.insert (0, gdb.PYTHONDIR)\n\
\n\
# Tell python where to find submodules of gdb.\n\
- gdb.__path__ = [gdb.PYTHONDIR + '/gdb']\n\
+ gdb.__path__ = [os.path.join (gdb.PYTHONDIR, 'gdb')]\n\
\n\
# The gdb module is implemented in C rather than in Python. As a result,\n\
# the associated __init.py__ script is not not executed by default when\n\
# the gdb module gets imported. Execute that script manually if it\n\
# exists.\n\
- ipy = gdb.PYTHONDIR + '/gdb/__init__.py'\n\
+ ipy = os.path.join (gdb.PYTHONDIR, 'gdb', '__init__.py')\n\
if os.path.exists (ipy):\n\
execfile (ipy)\n\
\n\

91
gdb-vla-frame-set.patch Normal file
View File

@ -0,0 +1,91 @@
commit 51dab9e418741ac7065cd5a6ec9b57285e90227c
https://bugzilla.redhat.com/show_bug.cgi?id=738482
--- a/gdb/printcmd.c
+++ b/gdb/printcmd.c
@@ -1981,6 +1981,10 @@ print_variable_and_value (const char *name, struct symbol *var,
struct value_print_options opts;
val = read_var_value (var, frame);
+
+ make_cleanup_restore_selected_frame ();
+ select_frame (frame);
+
get_user_print_options (&opts);
common_val_print (val, stream, indent, &opts, current_language);
}
--- /dev/null
+++ b/gdb/testsuite/gdb.base/vla-frame.c
@@ -0,0 +1,31 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+ Copyright 2011 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#include <string.h>
+
+int
+main (int argc, char **argv)
+{
+ char s[2 + argc];
+ void (*f) (char *) = 0;
+
+ memset (s, 0, sizeof (s));
+ s[0] = 'X';
+
+ f (s);
+ return 0;
+}
--- /dev/null
+++ b/gdb/testsuite/gdb.base/vla-frame.exp
@@ -0,0 +1,38 @@
+# Copyright 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+set testfile vla-frame
+set executable ${testfile}
+
+if { [prepare_for_testing ${testfile}.exp ${executable}] } {
+ return -1
+}
+
+if ![runto_main] {
+ return -1
+}
+
+set test "continue"
+gdb_test_multiple $test $test {
+ -re "Continuing\\.\r\n\r\nProgram received signal SIGSEGV, Segmentation fault\\.\r\n0x0+ in \\?\\? \\(\\)\r\n$gdb_prompt $" {
+ pass $test
+ }
+ -re "\r\n$gdb_prompt $" {
+ untested ${testfile}.exp
+ return
+ }
+}
+
+gdb_test "bt full" "\r\n +s = \"X\\\\000\"\r\n.*"

126
gdb.spec
View File

@ -23,11 +23,11 @@ Name: gdb%{?_with_debug:-debug}
# Set version to contents of gdb/version.in.
# NOTE: the FSF gdb versions are numbered N.M for official releases, like 6.3
# and, since January 2005, X.Y.Z.date for daily snapshots, like 6.3.50.20050112 # (daily snapshot from mailine), or 6.3.0.20040112 (head of the release branch).
Version: 7.2.90.20110703
Version: 7.3.1
# The release always contains a leading reserved number, start it at 1.
# `upstream' is not a part of `name' to stay fully rpm dependencies compatible for the testing.
Release: 40%{?_with_upstream:.upstream}%{?dist}
Release: 50%{?_with_upstream:.upstream}%{?dist}
License: GPLv3+ and GPLv3+ with exceptions and GPLv2+ and GPLv2+ with exceptions and GPL+ and LGPLv2+ and BSD and Public Domain
Group: Development/Debuggers
@ -172,10 +172,6 @@ Patch145: gdb-6.3-threaded-watchpoints2-20050225.patch
#=ia64
Patch153: gdb-6.3-ia64-gcore-page0-20050421.patch
# Security errata for untrusted .gdbinit
#=push
Patch157: gdb-6.3-security-errata-20050610.patch
# IA64 sigtramp prev register patch
#=ia64
Patch158: gdb-6.3-ia64-sigtramp-frame-20050708.patch
@ -303,6 +299,9 @@ Patch271: gdb-6.5-bz243845-stale-testing-zombie-test.patch
# New locating of the matching binaries from the pure core file (build-id).
#=push
Patch274: gdb-6.6-buildid-locate.patch
# Fix loading of core files without build-ids but with build-ids in executables.
#=push
Patch659: gdb-6.6-buildid-locate-solib-missing-ids.patch
#=push
Patch353: gdb-6.6-buildid-locate-rpm.patch
#=push
@ -566,6 +565,51 @@ Patch593: gdb-bz701131-readline62-3of3.patch
# [stap] Fix double free.
Patch594: gdb-stap-double-free.patch
# [vla] Fix VLA arrays displayed in `bt full' (BZ 738482).
Patch629: gdb-vla-frame-set.patch
# Fix DW_OP_GNU_implicit_pointer for DWARF32 v3+ on 64-bit arches.
Patch630: gdb-implptr-64bit-1of2.patch
Patch631: gdb-implptr-64bit-2of2.patch
# Register all available PythonGDB commands (BZ 752095).
Patch635: gdb-python-load-commands.patch
# Backport fix for crash in cp_scan_for_anonymous_namespace
# (Aleksandar Ristovski, BZ 750341).
Patch636: gdb-anon-namespace-crash.patch
# [python] Fix crash when pretty printer fails (Phil Muldoon, BZ 712715).
Patch637: gdb-pretty-printer-crash.patch
# Security fix for loading untrusted inferiors, see "set auto-load" (BZ 756117).
#=push
Patch662: gdb-autoload-01of25.patch
Patch663: gdb-autoload-02of25.patch
Patch664: gdb-autoload-03of25.patch
Patch665: gdb-autoload-04of25.patch
Patch666: gdb-autoload-05of25.patch
Patch667: gdb-autoload-06of25.patch
Patch668: gdb-autoload-07of25.patch
Patch669: gdb-autoload-08of25.patch
Patch670: gdb-autoload-09of25.patch
Patch671: gdb-autoload-10of25.patch
Patch672: gdb-autoload-11of25.patch
Patch673: gdb-autoload-12of25.patch
Patch674: gdb-autoload-13of25.patch
Patch675: gdb-autoload-14of25.patch
Patch676: gdb-autoload-15of25.patch
Patch677: gdb-autoload-16of25.patch
Patch678: gdb-autoload-17of25.patch
Patch679: gdb-autoload-18of25.patch
Patch680: gdb-autoload-19of25.patch
Patch681: gdb-autoload-20of25.patch
Patch682: gdb-autoload-21of25.patch
Patch683: gdb-autoload-22of25.patch
Patch684: gdb-autoload-23of25.patch
Patch685: gdb-autoload-24of25.patch
Patch686: gdb-autoload-25of25.patch
BuildRequires: ncurses-devel%{?_isa} texinfo gettext flex bison expat-devel%{?_isa}
# --without-system-readline
# Requires: readline%{?_isa}
@ -742,7 +786,6 @@ rm -f gdb/jv-exp.c gdb/m2-exp.c gdb/objc-exp.c gdb/p-exp.c
%patch259 -p1
%patch145 -p1
%patch153 -p1
%patch157 -p1
%patch158 -p1
%patch160 -p1
%patch161 -p1
@ -775,6 +818,7 @@ rm -f gdb/jv-exp.c gdb/m2-exp.c gdb/objc-exp.c gdb/p-exp.c
%patch266 -p1
%patch271 -p1
%patch274 -p1
%patch659 -p1
%patch353 -p1
%patch282 -p1
%patch284 -p1
@ -843,6 +887,37 @@ rm -f gdb/jv-exp.c gdb/m2-exp.c gdb/objc-exp.c gdb/p-exp.c
%patch592 -p1
%patch593 -p1
%patch594 -p1
%patch629 -p1
%patch630 -p1
%patch631 -p1
%patch635 -p1
%patch636 -p1
%patch637 -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
%patch393 -p1
%patch335 -p1
@ -956,6 +1031,8 @@ $(: RHEL-5 librpm has incompatible API. ) \
%if 0%{?_with_debug:1}
--enable-static --disable-shared --enable-debug \
%endif
$(: %{_bindir}/mono-gdb.py is workaround for mono BZ 815501. ) \
--with-auto-load-safe-path=%{_datadir}/gdb/auto-load:/usr/lib/debug:%{_bindir}/mono-gdb.py \
%ifarch sparc sparcv9
sparc-%{_vendor}-%{_target_os}%{?_gnu}
%else
@ -1265,6 +1342,41 @@ fi
%{_infodir}/gdb.info*
%changelog
* Tue Apr 24 2012 Jan Kratochvil <jan.kratochvil@redhat.com> - 7.3.1-50.fc15
- Update "set auto-load" patchset and the --with-auto-load-safe-path setting.
* Sat Apr 21 2012 Jan Kratochvil <jan.kratochvil@redhat.com> - 7.3.1-49.fc15
- Security fix for loading untrusted inferiors, see "set auto-load" (BZ 756117).
* Sat Mar 17 2012 Jan Kratochvil <jan.kratochvil@redhat.com> - 7.3.1-48.fc15
- Fix loading of core files without build-ids but with build-ids in executables.
* Wed Dec 21 2011 Jan Kratochvil <jan.kratochvil@redhat.com> - 7.3.1-47.fc15
- [python] Fix crash when pretty printer fails (Phil Muldoon, BZ 712715).
* Thu Nov 10 2011 Jan Kratochvil <jan.kratochvil@redhat.com> - 7.3.1-46.fc15
- Register all available PythonGDB commands (BZ 752095).
- Backport fix for crash in cp_scan_for_anonymous_namespace
(Aleksandar Ristovski, BZ 750341).
* Thu Oct 27 2011 Jan Kratochvil <jan.kratochvil@redhat.com> - 7.3.1-45.fc15
- Rebase to FSF GDB 7.3.1 release.
- Fix `layout regs' (BZ 749379, PR 13073, Pedro Alves).
* Mon Sep 26 2011 Jan Kratochvil <jan.kratochvil@redhat.com> - 7.3-44.fc15
- [vla] Fix VLA arrays displayed in `bt full' (BZ 738482).
- Fix DW_OP_GNU_implicit_pointer for DWARF32 v3+ on 64-bit arches.
* Tue Aug 16 2011 Jan Kratochvil <jan.kratochvil@redhat.com> - 7.3-43.fc15
- Fix sleb128 reading (BZ 720332).
* Tue Aug 16 2011 Jan Kratochvil <jan.kratochvil@redhat.com> - 7.3-42.fc15
- Python command/function auto-loading (Phil Muldoon, BZ 730976).
* Tue Jul 26 2011 Jan Kratochvil <jan.kratochvil@redhat.com> - 7.3-41.fc15
- Rebase to the final FSF GDB 7.3 release.
- Improve gcc-4.6 stdarg false prologue end workaround (GDB PR 12435 + GCC PR 47471).
* Sun Jul 3 2011 Jan Kratochvil <jan.kratochvil@redhat.com> - 7.2.90.20110703-40.fc15
- Rebase to FSF GDB 7.2.90.20110703 (which is a 7.3 pre-release).
- Adjust the `print errno' patch due to the DW_AT_linkage_name following again.

View File

@ -1,2 +1,2 @@
04e5c4b1b9e633422cc48990fe61958d libstdc++-v3-python-r155978.tar.bz2
be6522ade1ac78a16b10ea1612158d0a gdb-7.2.90.20110703.tar.bz2
b89a5fac359c618dda97b88645ceab47 gdb-7.3.1.tar.bz2