Security fix for loading untrusted inferiors, see "set auto-load" (BZ 756117).
This commit is contained in:
		
							parent
							
								
									f289ba9c21
								
							
						
					
					
						commit
						08451779f9
					
				| @ -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.4.50.20111218/gdb/cli/cli-cmds.c
 |  | ||||||
| ===================================================================
 |  | ||||||
| --- gdb-7.4.50.20111218.orig/gdb/cli/cli-cmds.c	2011-12-16 22:17:42.000000000 +0100
 |  | ||||||
| +++ gdb-7.4.50.20111218/gdb/cli/cli-cmds.c	2011-12-19 00:27:16.572468926 +0100
 |  | ||||||
| @@ -40,6 +40,7 @@
 |  | ||||||
|  #include "source.h" |  | ||||||
|  #include "disasm.h" |  | ||||||
|  #include "tracepoint.h" |  | ||||||
| +#include "gdb_stat.h"
 |  | ||||||
|   |  | ||||||
|  #include "ui-out.h" |  | ||||||
|   |  | ||||||
| @@ -485,7 +486,7 @@ show_script_ext_mode (struct ui_file *fi
 |  | ||||||
|   |  | ||||||
|  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; |  | ||||||
| @@ -511,6 +512,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); |  | ||||||
| @@ -572,13 +599,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.4.50.20111218/gdb/testsuite/gdb.base/gdbinit.exp
 |  | ||||||
| ===================================================================
 |  | ||||||
| --- /dev/null	1970-01-01 00:00:00.000000000 +0000
 |  | ||||||
| +++ gdb-7.4.50.20111218/gdb/testsuite/gdb.base/gdbinit.exp	2011-12-19 00:25:26.079891954 +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.4.50.20111218/gdb/testsuite/gdb.base/gdbinit.sample
 |  | ||||||
| ===================================================================
 |  | ||||||
| --- /dev/null	1970-01-01 00:00:00.000000000 +0000
 |  | ||||||
| +++ gdb-7.4.50.20111218/gdb/testsuite/gdb.base/gdbinit.sample	2011-12-19 00:25:26.079891954 +0100
 |  | ||||||
| @@ -0,0 +1 @@
 |  | ||||||
| +echo "\nin gdbinit"
 |  | ||||||
| Index: gdb-7.4.50.20111218/gdb/main.c
 |  | ||||||
| ===================================================================
 |  | ||||||
| --- gdb-7.4.50.20111218.orig/gdb/main.c	2011-11-05 18:08:30.000000000 +0100
 |  | ||||||
| +++ gdb-7.4.50.20111218/gdb/main.c	2011-12-19 00:25:26.080891950 +0100
 |  | ||||||
| @@ -822,7 +822,7 @@ captured_main (void *data)
 |  | ||||||
|       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) |  | ||||||
| @@ -901,7 +901,7 @@ captured_main (void *data)
 |  | ||||||
|    /* Read the .gdbinit file in the current directory, *if* it isn't |  | ||||||
|       the same as the $HOME/.gdbinit file (it should exist, also).  */ |  | ||||||
|    if (local_gdbinit && !inhibit_gdbinit) |  | ||||||
| -    catch_command_errors (source_script, local_gdbinit, 0, RETURN_MASK_ALL);
 |  | ||||||
| +    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.4.50.20111218/gdb/python/py-auto-load.c
 |  | ||||||
| ===================================================================
 |  | ||||||
| --- gdb-7.4.50.20111218.orig/gdb/python/py-auto-load.c	2011-12-10 23:51:47.000000000 +0100
 |  | ||||||
| +++ gdb-7.4.50.20111218/gdb/python/py-auto-load.c	2011-12-19 00:25:26.080891950 +0100
 |  | ||||||
| @@ -284,7 +284,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 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 |  | ||||||
| Index: gdb-7.4.50.20111218/gdb/cli/cli-cmds.h
 |  | ||||||
| ===================================================================
 |  | ||||||
| --- gdb-7.4.50.20111218.orig/gdb/cli/cli-cmds.h	2011-11-01 15:51:23.000000000 +0100
 |  | ||||||
| +++ gdb-7.4.50.20111218/gdb/cli/cli-cmds.h	2011-12-19 00:25:26.080891950 +0100
 |  | ||||||
| @@ -129,7 +129,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.  */ |  | ||||||
|   |  | ||||||
							
								
								
									
										65
									
								
								gdb-autoload-01of12.patch
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										65
									
								
								gdb-autoload-01of12.patch
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,65 @@ | |||||||
|  | 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 | ||||||
|  | --- src/gdb/cli/cli-cmds.c	2012/01/23 16:37:03	1.123
 | ||||||
|  | +++ src/gdb/cli/cli-cmds.c	2012/01/24 20:56:33	1.124
 | ||||||
|  | @@ -527,8 +527,7 @@
 | ||||||
|  |    return 1; | ||||||
|  |  } | ||||||
|  |   | ||||||
|  | -/* Load script FILE, which has already been opened as STREAM.
 | ||||||
|  | -   STREAM is closed before we return.  */
 | ||||||
|  | +/* Load script FILE, which has already been opened as STREAM.  */
 | ||||||
|  |   | ||||||
|  |  static void | ||||||
|  |  source_script_from_stream (FILE *stream, const char *file) | ||||||
|  | @@ -556,12 +555,9 @@
 | ||||||
|  |  	  else | ||||||
|  |  	    { | ||||||
|  |  	      /* Nope, just punt.  */ | ||||||
|  | -	      fclose (stream);
 | ||||||
|  |  	      throw_exception (e); | ||||||
|  |  	    } | ||||||
|  |  	} | ||||||
|  | -      else
 | ||||||
|  | -	fclose (stream);
 | ||||||
|  |      } | ||||||
|  |    else | ||||||
|  |      script_from_file (stream, file); | ||||||
|  | @@ -595,6 +591,7 @@
 | ||||||
|  |      } | ||||||
|  |   | ||||||
|  |    old_cleanups = make_cleanup (xfree, full_path); | ||||||
|  | +  make_cleanup_fclose (stream);
 | ||||||
|  |    /* The python support reopens the file, so we need to pass full_path here | ||||||
|  |       in case the file was found on the search path.  It's useful to do this | ||||||
|  |       anyway so that error messages show the actual file used.  But only do | ||||||
|  | --- src/gdb/cli/cli-script.c	2012/01/04 08:17:17	1.73
 | ||||||
|  | +++ src/gdb/cli/cli-script.c	2012/01/24 20:56:33	1.74
 | ||||||
|  | @@ -1614,11 +1614,9 @@
 | ||||||
|  |    if (stream == NULL) | ||||||
|  |      internal_error (__FILE__, __LINE__, _("called with NULL file pointer!")); | ||||||
|  |   | ||||||
|  | -  old_cleanups = make_cleanup_fclose (stream);
 | ||||||
|  | -
 | ||||||
|  |    old_lines.old_line = source_line_number; | ||||||
|  |    old_lines.old_file = source_file_name; | ||||||
|  | -  make_cleanup (source_cleanup_lines, &old_lines);
 | ||||||
|  | +  old_cleanups = make_cleanup (source_cleanup_lines, &old_lines);
 | ||||||
|  |    source_line_number = 0; | ||||||
|  |    source_file_name = file; | ||||||
|  |    /* This will get set every time we read a line.  So it won't stay "" | ||||||
							
								
								
									
										103
									
								
								gdb-autoload-02of12.patch
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										103
									
								
								gdb-autoload-02of12.patch
									
									
									
									
									
										Normal 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; | ||||||
							
								
								
									
										215
									
								
								gdb-autoload-03of12.patch
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										215
									
								
								gdb-autoload-03of12.patch
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,215 @@ | |||||||
|  | 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.4.50.20120120/gdb/cli/cli-cmds.c
 | ||||||
|  | ===================================================================
 | ||||||
|  | --- gdb-7.4.50.20120120.orig/gdb/cli/cli-cmds.c	2012-01-04 09:17:16.000000000 +0100
 | ||||||
|  | +++ gdb-7.4.50.20120120/gdb/cli/cli-cmds.c	2012-04-18 00:41:42.696855430 +0200
 | ||||||
|  | @@ -529,9 +529,7 @@ source_script_from_stream (FILE *stream,
 | ||||||
|  |   | ||||||
|  |        TRY_CATCH (e, RETURN_MASK_ERROR) | ||||||
|  |  	{ | ||||||
|  | -          /* The python support reopens the file using python functions,
 | ||||||
|  | -             so there's no point in passing STREAM here.  */
 | ||||||
|  | -	  source_python_script (file);
 | ||||||
|  | +	  source_python_script (stream, file);
 | ||||||
|  |  	} | ||||||
|  |        if (e.reason < 0) | ||||||
|  |  	{ | ||||||
|  | Index: gdb-7.4.50.20120120/gdb/python/py-auto-load.c
 | ||||||
|  | ===================================================================
 | ||||||
|  | --- gdb-7.4.50.20120120.orig/gdb/python/py-auto-load.c	2012-01-04 09:17:25.000000000 +0100
 | ||||||
|  | +++ gdb-7.4.50.20120120/gdb/python/py-auto-load.c	2012-04-18 00:41:42.696855430 +0200
 | ||||||
|  | @@ -312,7 +312,7 @@ Use `info auto-load-scripts [REGEXP]' to
 | ||||||
|  |  	{ | ||||||
|  |  	  /* If this file is not currently loaded, load it.  */ | ||||||
|  |  	  if (! in_hash_table) | ||||||
|  | -	    source_python_script_for_objfile (objfile, full_path);
 | ||||||
|  | +	    source_python_script_for_objfile (objfile, stream, full_path);
 | ||||||
|  |  	  fclose (stream); | ||||||
|  |  	  xfree (full_path); | ||||||
|  |  	} | ||||||
|  | @@ -431,7 +431,7 @@ auto_load_objfile_script (struct objfile
 | ||||||
|  |  	 It's highly unlikely that we'd ever load it twice, | ||||||
|  |  	 and these scripts are required to be idempotent under multiple | ||||||
|  |  	 loads anyway.  */ | ||||||
|  | -      source_python_script_for_objfile (objfile, debugfile);
 | ||||||
|  | +      source_python_script_for_objfile (objfile, input, debugfile);
 | ||||||
|  |        fclose (input); | ||||||
|  |      } | ||||||
|  |   | ||||||
|  | Index: gdb-7.4.50.20120120/gdb/python/python-internal.h
 | ||||||
|  | ===================================================================
 | ||||||
|  | --- gdb-7.4.50.20120120.orig/gdb/python/python-internal.h	2012-01-04 09:17:25.000000000 +0100
 | ||||||
|  | +++ gdb-7.4.50.20120120/gdb/python/python-internal.h	2012-04-18 00:41:42.696855430 +0200
 | ||||||
|  | @@ -289,8 +289,8 @@ extern const struct language_defn *pytho
 | ||||||
|  |   | ||||||
|  |  void gdbpy_print_stack (void); | ||||||
|  |   | ||||||
|  | -void source_python_script_for_objfile (struct objfile *objfile,
 | ||||||
|  | -				       const char *file);
 | ||||||
|  | +void source_python_script_for_objfile (struct objfile *objfile, FILE *file,
 | ||||||
|  | +				       const char *filename);
 | ||||||
|  |   | ||||||
|  |  PyObject *python_string_to_unicode (PyObject *obj); | ||||||
|  |  char *unicode_to_target_string (PyObject *unicode_str); | ||||||
|  | Index: gdb-7.4.50.20120120/gdb/python/python.c
 | ||||||
|  | ===================================================================
 | ||||||
|  | --- gdb-7.4.50.20120120.orig/gdb/python/python.c	2012-04-18 00:41:30.000000000 +0200
 | ||||||
|  | +++ gdb-7.4.50.20120120/gdb/python/python.c	2012-04-18 00:41:42.696855430 +0200
 | ||||||
|  | @@ -154,34 +154,31 @@ ensure_python_env (struct gdbarch *gdbar
 | ||||||
|  |    return make_cleanup (restore_python_env, env); | ||||||
|  |  } | ||||||
|  |   | ||||||
|  | -/* A wrapper around PyRun_SimpleFile.  FILENAME is the name of
 | ||||||
|  | -   the Python script to run.
 | ||||||
|  | +/* A wrapper around PyRun_SimpleFile.  FILE is the Python script to run
 | ||||||
|  | +   named FILENAME.
 | ||||||
|  |   | ||||||
|  | -   One of the parameters of PyRun_SimpleFile is a FILE *.
 | ||||||
|  | -   The problem is that type FILE is extremely system and compiler
 | ||||||
|  | -   dependent.  So, unless the Python library has been compiled using
 | ||||||
|  | -   the same build environment as GDB, we run the risk of getting
 | ||||||
|  | -   a crash due to inconsistencies between the definition used by GDB,
 | ||||||
|  | -   and the definition used by Python.  A mismatch can very likely
 | ||||||
|  | -   lead to a crash.
 | ||||||
|  | -
 | ||||||
|  | -   There is also the situation where the Python library and GDB
 | ||||||
|  | -   are using two different versions of the C runtime library.
 | ||||||
|  | -   This is particularly visible on Windows, where few users would
 | ||||||
|  | -   build Python themselves (this is no trivial task on this platform),
 | ||||||
|  | -   and thus use binaries built by someone else instead. Python,
 | ||||||
|  | -   being built with VC, would use one version of the msvcr DLL
 | ||||||
|  | -   (Eg. msvcr100.dll), while MinGW uses msvcrt.dll.  A FILE *
 | ||||||
|  | -   from one runtime does not necessarily operate correctly in
 | ||||||
|  | +   On Windows hosts few users would build Python themselves (this is no
 | ||||||
|  | +   trivial task on this platform), and thus use binaries built by
 | ||||||
|  | +   someone else instead.  There may happen situation where the Python
 | ||||||
|  | +   library and GDB are using two different versions of the C runtime
 | ||||||
|  | +   library.  Python, being built with VC, would use one version of the
 | ||||||
|  | +   msvcr DLL (Eg. msvcr100.dll), while MinGW uses msvcrt.dll.
 | ||||||
|  | +   A FILE * from one runtime does not necessarily operate correctly in
 | ||||||
|  |     the other runtime. | ||||||
|  |   | ||||||
|  | -   To work around this potential issue, we create the FILE object
 | ||||||
|  | -   using Python routines, thus making sure that it is compatible
 | ||||||
|  | -   with the Python library.  */
 | ||||||
|  | +   To work around this potential issue, we create on Windows hosts the
 | ||||||
|  | +   FILE object using Python routines, thus making sure that it is
 | ||||||
|  | +   compatible with the Python library.  */
 | ||||||
|  |   | ||||||
|  |  static void | ||||||
|  | -python_run_simple_file (const char *filename)
 | ||||||
|  | +python_run_simple_file (FILE *file, const char *filename)
 | ||||||
|  |  { | ||||||
|  | +#ifndef _WIN32
 | ||||||
|  | +
 | ||||||
|  | +  PyRun_SimpleFile (file, filename);
 | ||||||
|  | +
 | ||||||
|  | +#else /* _WIN32 */
 | ||||||
|  | +
 | ||||||
|  |    char *full_path; | ||||||
|  |    PyObject *python_file; | ||||||
|  |    struct cleanup *cleanup; | ||||||
|  | @@ -201,6 +198,8 @@ python_run_simple_file (const char *file
 | ||||||
|  |    make_cleanup_py_decref (python_file); | ||||||
|  |    PyRun_SimpleFile (PyFile_AsFile (python_file), filename); | ||||||
|  |    do_cleanups (cleanup); | ||||||
|  | +
 | ||||||
|  | +#endif /* _WIN32 */
 | ||||||
|  |  } | ||||||
|  |   | ||||||
|  |  /* Given a command_line, return a command string suitable for passing | ||||||
|  | @@ -623,17 +622,17 @@ gdbpy_parse_and_eval (PyObject *self, Py
 | ||||||
|  |  } | ||||||
|  |   | ||||||
|  |  /* Read a file as Python code. | ||||||
|  | -   FILE is the name of the file.
 | ||||||
|  | +   FILE is the file to run.  FILENAME is name of the file FILE.
 | ||||||
|  |     This does not throw any errors.  If an exception occurs python will print | ||||||
|  |     the traceback and clear the error indicator.  */ | ||||||
|  |   | ||||||
|  |  void | ||||||
|  | -source_python_script (const char *file)
 | ||||||
|  | +source_python_script (FILE *file, const char *filename)
 | ||||||
|  |  { | ||||||
|  |    struct cleanup *cleanup; | ||||||
|  |   | ||||||
|  |    cleanup = ensure_python_env (get_current_arch (), current_language); | ||||||
|  | -  python_run_simple_file (file);
 | ||||||
|  | +  python_run_simple_file (file, filename);
 | ||||||
|  |    do_cleanups (cleanup); | ||||||
|  |  } | ||||||
|  |   | ||||||
|  | @@ -1041,19 +1040,20 @@ gdbpy_progspaces (PyObject *unused1, PyO
 | ||||||
|  |     source_python_script_for_objfile; it is NULL at other times.  */ | ||||||
|  |  static struct objfile *gdbpy_current_objfile; | ||||||
|  |   | ||||||
|  | -/* Set the current objfile to OBJFILE and then read FILE as Python code.
 | ||||||
|  | -   This does not throw any errors.  If an exception occurs python will print
 | ||||||
|  | -   the traceback and clear the error indicator.  */
 | ||||||
|  | +/* Set the current objfile to OBJFILE and then read FILE named FILENAME
 | ||||||
|  | +   as Python code.  This does not throw any errors.  If an exception
 | ||||||
|  | +   occurs python will print the traceback and clear the error indicator.  */
 | ||||||
|  |   | ||||||
|  |  void | ||||||
|  | -source_python_script_for_objfile (struct objfile *objfile, const char *file)
 | ||||||
|  | +source_python_script_for_objfile (struct objfile *objfile, FILE *file,
 | ||||||
|  | +                                  const char *filename)
 | ||||||
|  |  { | ||||||
|  |    struct cleanup *cleanups; | ||||||
|  |   | ||||||
|  |    cleanups = ensure_python_env (get_objfile_arch (objfile), current_language); | ||||||
|  |    gdbpy_current_objfile = objfile; | ||||||
|  |   | ||||||
|  | -  python_run_simple_file (file);
 | ||||||
|  | +  python_run_simple_file (file, filename);
 | ||||||
|  |   | ||||||
|  |    do_cleanups (cleanups); | ||||||
|  |    gdbpy_current_objfile = NULL; | ||||||
|  | @@ -1129,7 +1129,7 @@ eval_python_from_control_command (struct
 | ||||||
|  |  } | ||||||
|  |   | ||||||
|  |  void | ||||||
|  | -source_python_script (const char *file)
 | ||||||
|  | +source_python_script (FILE *file, const char *filename)
 | ||||||
|  |  { | ||||||
|  |    throw_error (UNSUPPORTED_ERROR, | ||||||
|  |  	       _("Python scripting is not supported in this copy of GDB.")); | ||||||
|  | Index: gdb-7.4.50.20120120/gdb/python/python.h
 | ||||||
|  | ===================================================================
 | ||||||
|  | --- gdb-7.4.50.20120120.orig/gdb/python/python.h	2012-04-18 00:41:30.000000000 +0200
 | ||||||
|  | +++ gdb-7.4.50.20120120/gdb/python/python.h	2012-04-18 00:41:42.697855427 +0200
 | ||||||
|  | @@ -30,7 +30,7 @@ extern void finish_python_initialization
 | ||||||
|  |   | ||||||
|  |  void eval_python_from_control_command (struct command_line *); | ||||||
|  |   | ||||||
|  | -void source_python_script (const char *file);
 | ||||||
|  | +void source_python_script (FILE *file, const char *filename);
 | ||||||
|  |   | ||||||
|  |  void run_python_script (int argc, char **argv); | ||||||
|  |   | ||||||
							
								
								
									
										141
									
								
								gdb-autoload-04of12.patch
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										141
									
								
								gdb-autoload-04of12.patch
									
									
									
									
									
										Normal 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.4.50.20120120/gdb/main.c
 | ||||||
|  | ===================================================================
 | ||||||
|  | --- gdb-7.4.50.20120120.orig/gdb/main.c	2012-04-18 00:41:31.000000000 +0200
 | ||||||
|  | +++ gdb-7.4.50.20120120/gdb/main.c	2012-04-18 00:42:15.354772337 +0200
 | ||||||
|  | @@ -277,6 +277,25 @@ exec_or_core_file_attach (char *filename
 | ||||||
|  |      } | ||||||
|  |  } | ||||||
|  |   | ||||||
|  | +/* Arguments of --command option and its counterpart.  */
 | ||||||
|  | +typedef struct cmdarg {
 | ||||||
|  | +  /* Type of this option.  */
 | ||||||
|  | +  enum {
 | ||||||
|  | +    /* Option type -x.  */
 | ||||||
|  | +    CMDARG_FILE,
 | ||||||
|  | +
 | ||||||
|  | +    /* Option type -ex.  */
 | ||||||
|  | +    CMDARG_COMMAND
 | ||||||
|  | +  } type;
 | ||||||
|  | +
 | ||||||
|  | +  /* Value of this option - filename or the GDB command itself.  String memory
 | ||||||
|  | +     is not owned by this structure despite it is 'const'.  */
 | ||||||
|  | +  char *string;
 | ||||||
|  | +} cmdarg_s;
 | ||||||
|  | +
 | ||||||
|  | +/* Define type VEC (cmdarg_s).  */
 | ||||||
|  | +DEF_VEC_O (cmdarg_s);
 | ||||||
|  | +
 | ||||||
|  |  static int | ||||||
|  |  captured_main (void *data) | ||||||
|  |  { | ||||||
|  | @@ -303,17 +322,8 @@ captured_main (void *data)
 | ||||||
|  |    static int print_version; | ||||||
|  |   | ||||||
|  |    /* Pointers to all arguments of --command option.  */ | ||||||
|  | -  struct cmdarg {
 | ||||||
|  | -    enum {
 | ||||||
|  | -      CMDARG_FILE,
 | ||||||
|  | -      CMDARG_COMMAND
 | ||||||
|  | -    } type;
 | ||||||
|  | -    char *string;
 | ||||||
|  | -  } *cmdarg;
 | ||||||
|  | -  /* Allocated size of cmdarg.  */
 | ||||||
|  | -  int cmdsize;
 | ||||||
|  | -  /* Number of elements of cmdarg used.  */
 | ||||||
|  | -  int ncmd;
 | ||||||
|  | +  VEC (cmdarg_s) *cmdarg_vec = NULL;
 | ||||||
|  | +  struct cmdarg *cmdarg_p;
 | ||||||
|  |   | ||||||
|  |    /* Indices of all arguments of --directory option.  */ | ||||||
|  |    char **dirarg; | ||||||
|  | @@ -349,9 +359,7 @@ captured_main (void *data)
 | ||||||
|  |    bindtextdomain (PACKAGE, LOCALEDIR); | ||||||
|  |    textdomain (PACKAGE); | ||||||
|  |   | ||||||
|  | -  cmdsize = 1;
 | ||||||
|  | -  cmdarg = (struct cmdarg *) xmalloc (cmdsize * sizeof (*cmdarg));
 | ||||||
|  | -  ncmd = 0;
 | ||||||
|  | +  make_cleanup (VEC_cleanup (cmdarg_s), &cmdarg_vec);
 | ||||||
|  |    dirsize = 1; | ||||||
|  |    dirarg = (char **) xmalloc (dirsize * sizeof (*dirarg)); | ||||||
|  |    ndir = 0; | ||||||
|  | @@ -582,24 +590,19 @@ captured_main (void *data)
 | ||||||
|  |  	    pidarg = optarg; | ||||||
|  |  	    break; | ||||||
|  |  	  case 'x': | ||||||
|  | -	    cmdarg[ncmd].type = CMDARG_FILE;
 | ||||||
|  | -	    cmdarg[ncmd++].string = optarg;
 | ||||||
|  | -	    if (ncmd >= cmdsize)
 | ||||||
|  | -	      {
 | ||||||
|  | -		cmdsize *= 2;
 | ||||||
|  | -		cmdarg = xrealloc ((char *) cmdarg,
 | ||||||
|  | -				   cmdsize * sizeof (*cmdarg));
 | ||||||
|  | -	      }
 | ||||||
|  | +	    {
 | ||||||
|  | +	      struct cmdarg cmdarg = { CMDARG_FILE, optarg };
 | ||||||
|  | +
 | ||||||
|  | +	      VEC_safe_push (cmdarg_s, cmdarg_vec, &cmdarg);
 | ||||||
|  | +	    }
 | ||||||
|  |  	    break; | ||||||
|  |  	  case 'X': | ||||||
|  | -	    cmdarg[ncmd].type = CMDARG_COMMAND;
 | ||||||
|  | -	    cmdarg[ncmd++].string = optarg;
 | ||||||
|  | -	    if (ncmd >= cmdsize)
 | ||||||
|  | -	      {
 | ||||||
|  | -		cmdsize *= 2;
 | ||||||
|  | -		cmdarg = xrealloc ((char *) cmdarg,
 | ||||||
|  | -				   cmdsize * sizeof (*cmdarg));
 | ||||||
|  | -	      }
 | ||||||
|  | +	    {
 | ||||||
|  | +	      struct cmdarg cmdarg = { CMDARG_COMMAND, optarg };
 | ||||||
|  | +
 | ||||||
|  | +	      VEC_safe_push (cmdarg_s, cmdarg_vec, &cmdarg);
 | ||||||
|  | +	    }
 | ||||||
|  | +	    break;
 | ||||||
|  |  	    break; | ||||||
|  |  	  case 'B': | ||||||
|  |  	    batch_flag = batch_silent = 1; | ||||||
|  | @@ -990,16 +993,18 @@ captured_main (void *data)
 | ||||||
|  |    ALL_OBJFILES (objfile) | ||||||
|  |      load_auto_scripts_for_objfile (objfile); | ||||||
|  |   | ||||||
|  | -  for (i = 0; i < ncmd; i++)
 | ||||||
|  | +  for (i = 0; VEC_iterate (cmdarg_s, cmdarg_vec, i, cmdarg_p); i++)
 | ||||||
|  | +    switch (cmdarg_p->type)
 | ||||||
|  |      { | ||||||
|  | -      if (cmdarg[i].type == CMDARG_FILE)
 | ||||||
|  | -        catch_command_errors (source_script, cmdarg[i].string,
 | ||||||
|  | +      case CMDARG_FILE:
 | ||||||
|  | +        catch_command_errors (source_script, cmdarg_p->string,
 | ||||||
|  |  			      !batch_flag, RETURN_MASK_ALL); | ||||||
|  | -      else  /* cmdarg[i].type == CMDARG_COMMAND */
 | ||||||
|  | -        catch_command_errors (execute_command, cmdarg[i].string,
 | ||||||
|  | +	break;
 | ||||||
|  | +      case CMDARG_COMMAND:
 | ||||||
|  | +        catch_command_errors (execute_command, cmdarg_p->string,
 | ||||||
|  |  			      !batch_flag, RETURN_MASK_ALL); | ||||||
|  | +	break;
 | ||||||
|  |      } | ||||||
|  | -  xfree (cmdarg);
 | ||||||
|  |   | ||||||
|  |    /* Read in the old history after all the command files have been | ||||||
|  |       read.  */ | ||||||
							
								
								
									
										244
									
								
								gdb-autoload-05of12.patch
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										244
									
								
								gdb-autoload-05of12.patch
									
									
									
									
									
										Normal 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.4.50.20120120/gdb/NEWS
 | ||||||
|  | ===================================================================
 | ||||||
|  | --- gdb-7.4.50.20120120.orig/gdb/NEWS	2012-04-18 00:41:30.000000000 +0200
 | ||||||
|  | +++ gdb-7.4.50.20120120/gdb/NEWS	2012-04-18 00:42:51.226681068 +0200
 | ||||||
|  | @@ -28,6 +28,13 @@
 | ||||||
|  |    now set a breakpoint in build/gcc/expr.c, but not | ||||||
|  |    build/libcpp/expr.c. | ||||||
|  |   | ||||||
|  | +* New command line options
 | ||||||
|  | +
 | ||||||
|  | +--init-command=FILE, -ix          Like --command, -x but execute it
 | ||||||
|  | +                                  before loading inferior.
 | ||||||
|  | +--init-eval-command=COMMAND, -iex Like --eval-command=COMMAND, -ex but
 | ||||||
|  | +                                  execute it before loading inferior.
 | ||||||
|  | +
 | ||||||
|  |  *** Changes in GDB 7.4 | ||||||
|  |   | ||||||
|  |  * GDB now handles ambiguous linespecs more consistently; the existing | ||||||
|  | Index: gdb-7.4.50.20120120/gdb/main.c
 | ||||||
|  | ===================================================================
 | ||||||
|  | --- gdb-7.4.50.20120120.orig/gdb/main.c	2012-04-18 00:42:15.000000000 +0200
 | ||||||
|  | +++ gdb-7.4.50.20120120/gdb/main.c	2012-04-18 00:42:51.226681068 +0200
 | ||||||
|  | @@ -285,7 +285,13 @@ typedef struct cmdarg {
 | ||||||
|  |      CMDARG_FILE, | ||||||
|  |   | ||||||
|  |      /* Option type -ex.  */ | ||||||
|  | -    CMDARG_COMMAND
 | ||||||
|  | +    CMDARG_COMMAND,
 | ||||||
|  | +
 | ||||||
|  | +    /* Option type -ix.  */
 | ||||||
|  | +    CMDARG_INIT_FILE,
 | ||||||
|  | +    
 | ||||||
|  | +    /* Option type -iex.  */
 | ||||||
|  | +    CMDARG_INIT_COMMAND
 | ||||||
|  |    } type; | ||||||
|  |   | ||||||
|  |    /* Value of this option - filename or the GDB command itself.  String memory | ||||||
|  | @@ -434,7 +440,9 @@ captured_main (void *data)
 | ||||||
|  |        OPT_STATISTICS, | ||||||
|  |        OPT_TUI, | ||||||
|  |        OPT_NOWINDOWS, | ||||||
|  | -      OPT_WINDOWS
 | ||||||
|  | +      OPT_WINDOWS,
 | ||||||
|  | +      OPT_IX,
 | ||||||
|  | +      OPT_IEX
 | ||||||
|  |      }; | ||||||
|  |      static struct option long_options[] = | ||||||
|  |      { | ||||||
|  | @@ -475,6 +483,10 @@ captured_main (void *data)
 | ||||||
|  |        {"version", no_argument, &print_version, 1}, | ||||||
|  |        {"x", required_argument, 0, 'x'}, | ||||||
|  |        {"ex", required_argument, 0, 'X'}, | ||||||
|  | +      {"init-command", required_argument, 0, OPT_IX},
 | ||||||
|  | +      {"init-eval-command", required_argument, 0, OPT_IEX},
 | ||||||
|  | +      {"ix", required_argument, 0, OPT_IX},
 | ||||||
|  | +      {"iex", required_argument, 0, OPT_IEX},
 | ||||||
|  |  #ifdef GDBTK | ||||||
|  |        {"tclcommand", required_argument, 0, 'z'}, | ||||||
|  |        {"enable-external-editor", no_argument, 0, 'y'}, | ||||||
|  | @@ -603,6 +615,19 @@ captured_main (void *data)
 | ||||||
|  |  	      VEC_safe_push (cmdarg_s, cmdarg_vec, &cmdarg); | ||||||
|  |  	    } | ||||||
|  |  	    break; | ||||||
|  | +	  case OPT_IX:
 | ||||||
|  | +	    {
 | ||||||
|  | +	      struct cmdarg cmdarg = { CMDARG_INIT_FILE, optarg };
 | ||||||
|  | +
 | ||||||
|  | +	      VEC_safe_push (cmdarg_s, cmdarg_vec, &cmdarg);
 | ||||||
|  | +	    }
 | ||||||
|  | +	    break;
 | ||||||
|  | +	  case OPT_IEX:
 | ||||||
|  | +	    {
 | ||||||
|  | +	      struct cmdarg cmdarg = { CMDARG_INIT_COMMAND, optarg };
 | ||||||
|  | +
 | ||||||
|  | +	      VEC_safe_push (cmdarg_s, cmdarg_vec, &cmdarg);
 | ||||||
|  | +	    }
 | ||||||
|  |  	    break; | ||||||
|  |  	  case 'B': | ||||||
|  |  	    batch_flag = batch_silent = 1; | ||||||
|  | @@ -877,6 +902,20 @@ captured_main (void *data)
 | ||||||
|  |    quit_pre_print = error_pre_print; | ||||||
|  |    warning_pre_print = _("\nwarning: "); | ||||||
|  |   | ||||||
|  | +  /* Process '-ix' and '-iex' options early.  */
 | ||||||
|  | +  for (i = 0; VEC_iterate (cmdarg_s, cmdarg_vec, i, cmdarg_p); i++)
 | ||||||
|  | +    switch (cmdarg_p->type)
 | ||||||
|  | +    {
 | ||||||
|  | +      case CMDARG_INIT_FILE:
 | ||||||
|  | +        catch_command_errors (source_script, cmdarg_p->string,
 | ||||||
|  | +			      !batch_flag, RETURN_MASK_ALL);
 | ||||||
|  | +	break;
 | ||||||
|  | +      case CMDARG_INIT_COMMAND:
 | ||||||
|  | +        catch_command_errors (execute_command, cmdarg_p->string,
 | ||||||
|  | +			      !batch_flag, RETURN_MASK_ALL);
 | ||||||
|  | +	break;
 | ||||||
|  | +    }
 | ||||||
|  | +
 | ||||||
|  |    /* Read and execute the system-wide gdbinit file, if it exists. | ||||||
|  |       This is done *before* all the command line arguments are | ||||||
|  |       processed; it sets global parameters, which are independent of | ||||||
|  | @@ -993,6 +1032,7 @@ captured_main (void *data)
 | ||||||
|  |    ALL_OBJFILES (objfile) | ||||||
|  |      load_auto_scripts_for_objfile (objfile); | ||||||
|  |   | ||||||
|  | +  /* Process '-x' and '-ex' options.  */
 | ||||||
|  |    for (i = 0; VEC_iterate (cmdarg_s, cmdarg_vec, i, cmdarg_p); i++) | ||||||
|  |      switch (cmdarg_p->type) | ||||||
|  |      { | ||||||
|  | @@ -1093,6 +1133,8 @@ Options:\n\n\
 | ||||||
|  |                       Execute a single GDB command.\n\ | ||||||
|  |                       May be used multiple times and in conjunction\n\ | ||||||
|  |                       with --command.\n\ | ||||||
|  | +  --init-command=FILE, -ix Like -x but execute it before loading inferior.\n\
 | ||||||
|  | +  --init-eval-command=COMMAND, -iex Like -ex but before loading inferior.\n\
 | ||||||
|  |    --core=COREFILE    Analyze the core dump COREFILE.\n\ | ||||||
|  |    --pid=PID          Attach to running process PID.\n\ | ||||||
|  |  "), stream); | ||||||
|  | Index: gdb-7.4.50.20120120/gdb/doc/gdb.texinfo
 | ||||||
|  | ===================================================================
 | ||||||
|  | --- gdb-7.4.50.20120120.orig/gdb/doc/gdb.texinfo	2012-04-18 00:41:31.000000000 +0200
 | ||||||
|  | +++ gdb-7.4.50.20120120/gdb/doc/gdb.texinfo	2012-04-18 00:42:51.232681052 +0200
 | ||||||
|  | @@ -989,6 +989,22 @@ also be interleaved with @samp{-command}
 | ||||||
|  |     -x setbreakpoints -ex 'run' a.out | ||||||
|  |  @end smallexample | ||||||
|  |   | ||||||
|  | +@item -init-command @var{file}
 | ||||||
|  | +@itemx -ix @var{file}
 | ||||||
|  | +@cindex @code{--init-command}
 | ||||||
|  | +@cindex @code{-ix}
 | ||||||
|  | +Execute commands from file @var{file} before loading gdbinit files or the
 | ||||||
|  | +inferior.
 | ||||||
|  | +@xref{Startup}.
 | ||||||
|  | +
 | ||||||
|  | +@item -init-eval-command @var{command}
 | ||||||
|  | +@itemx -iex @var{command}
 | ||||||
|  | +@cindex @code{--init-eval-command}
 | ||||||
|  | +@cindex @code{-iex}
 | ||||||
|  | +Execute a single @value{GDBN} command before loading gdbinit files or the
 | ||||||
|  | +inferior.
 | ||||||
|  | +@xref{Startup}.
 | ||||||
|  | +
 | ||||||
|  |  @item -directory @var{directory} | ||||||
|  |  @itemx -d @var{directory} | ||||||
|  |  @cindex @code{--directory} | ||||||
|  | @@ -1250,6 +1266,13 @@ Sets up the command interpreter as speci
 | ||||||
|  |  (@pxref{Mode Options, interpreter}). | ||||||
|  |   | ||||||
|  |  @item | ||||||
|  | +Executes commands and command files specified by the @samp{-iex} and
 | ||||||
|  | +@samp{-ix} options in their specified order.  Usually you should use the
 | ||||||
|  | +@samp{-ex} and @samp{-x} options instead, but this way you can apply
 | ||||||
|  | +settings before @value{GDBN} init files get executed and before inferior
 | ||||||
|  | +gets loaded.
 | ||||||
|  | +
 | ||||||
|  | +@item
 | ||||||
|  |  @cindex init file | ||||||
|  |  Reads the system-wide @dfn{init file} (if @option{--with-system-gdbinit} was | ||||||
|  |  used when building @value{GDBN}; @pxref{System-wide configuration, | ||||||
|  | @@ -1283,14 +1306,11 @@ If you wish to disable the auto-loading
 | ||||||
|  |  you must do something like the following: | ||||||
|  |   | ||||||
|  |  @smallexample | ||||||
|  | -$ gdb -ex "set auto-load-scripts off" -ex "file myprogram"
 | ||||||
|  | +$ gdb -iex "set auto-load-scripts off" myprogram
 | ||||||
|  |  @end smallexample | ||||||
|  |   | ||||||
|  | -The following does not work because the auto-loading is turned off too late:
 | ||||||
|  | -
 | ||||||
|  | -@smallexample
 | ||||||
|  | -$ gdb -ex "set auto-load-scripts off" myprogram
 | ||||||
|  | -@end smallexample
 | ||||||
|  | +Option @samp{-ex} does not work because the auto-loading is then turned
 | ||||||
|  | +off too late.
 | ||||||
|  |   | ||||||
|  |  @item | ||||||
|  |  Reads command files specified by the @samp{-x} option.  @xref{Command | ||||||
|  | Index: gdb-7.4.50.20120120/gdb/testsuite/gdb.gdb/selftest.exp
 | ||||||
|  | ===================================================================
 | ||||||
|  | --- gdb-7.4.50.20120120.orig/gdb/testsuite/gdb.gdb/selftest.exp	2012-04-18 00:41:31.000000000 +0200
 | ||||||
|  | +++ gdb-7.4.50.20120120/gdb/testsuite/gdb.gdb/selftest.exp	2012-04-18 00:42:51.232681052 +0200
 | ||||||
|  | @@ -92,6 +92,10 @@ proc do_steps_and_nexts {} {
 | ||||||
|  |  		set description "step over python_script initialization" | ||||||
|  |  		set command "step" | ||||||
|  |  	    } | ||||||
|  | +	    -re ".*cmdarg_vec = NULL.*$gdb_prompt $" {
 | ||||||
|  | +		set description "step over cmdarg_vec initialization"
 | ||||||
|  | +		set command "step"
 | ||||||
|  | +	    }
 | ||||||
|  |  	    -re ".*pre_stat_chain = make_command_stats_cleanup.*$gdb_prompt $" { | ||||||
|  |  		set description "next over make_command_stats_cleanup and everything it calls" | ||||||
|  |  		set command "next" | ||||||
|  | @@ -128,18 +132,6 @@ proc do_steps_and_nexts {} {
 | ||||||
|  |  		set description "next over conditional stack alignment alloca" | ||||||
|  |  		set command "next" | ||||||
|  |  	    } | ||||||
|  | -	    -re ".*cmdsize = 1.*$gdb_prompt $" {
 | ||||||
|  | -		set description "step over cmdsize initialization"
 | ||||||
|  | -		set command "next"
 | ||||||
|  | -	    }
 | ||||||
|  | -	    -re ".*cmdarg = .* xmalloc.*$gdb_prompt $" {
 | ||||||
|  | -		set description "next over cmdarg initialization via xmalloc"
 | ||||||
|  | -		set command "next"
 | ||||||
|  | -	    }
 | ||||||
|  | -	    -re ".*ncmd = 0.*$gdb_prompt $" {
 | ||||||
|  | -		set description "next over ncmd initialization"
 | ||||||
|  | -		set command "next"
 | ||||||
|  | -	    }
 | ||||||
|  |  	    -re ".*dirsize = 1.*$gdb_prompt $" { | ||||||
|  |  		set description "next over dirsize initialization" | ||||||
|  |  		set command "next" | ||||||
|  | @@ -163,6 +155,10 @@ proc do_steps_and_nexts {} {
 | ||||||
|  |  		set description "next over textdomain PACKAGE" | ||||||
|  |  		set command "next" | ||||||
|  |  	    } | ||||||
|  | +	    -re ".*VEC_cleanup .cmdarg_s.*$gdb_prompt $" {
 | ||||||
|  | +		set description "next over cmdarg_s VEC_cleanup"
 | ||||||
|  | +		set command "next"
 | ||||||
|  | +	    }
 | ||||||
|  |  	    -re "\[0-9\]+\[\t \]+\{\r\n$gdb_prompt $" { | ||||||
|  |  		set description "step over initial brace" | ||||||
|  |  		set command "step" | ||||||
							
								
								
									
										71
									
								
								gdb-autoload-06of12.patch
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										71
									
								
								gdb-autoload-06of12.patch
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,71 @@ | |||||||
|  | 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 | ||||||
|  | --- src/gdb/python/py-auto-load.c	2012/01/26 21:54:45	1.18
 | ||||||
|  | +++ src/gdb/python/py-auto-load.c	2012/03/19 18:23:52	1.19
 | ||||||
|  | @@ -254,6 +254,7 @@
 | ||||||
|  |        FILE *stream; | ||||||
|  |        char *full_path; | ||||||
|  |        int opened, in_hash_table; | ||||||
|  | +      struct cleanup *back_to;
 | ||||||
|  |   | ||||||
|  |        if (*p != 1) | ||||||
|  |  	{ | ||||||
|  | @@ -286,6 +287,13 @@
 | ||||||
|  |        opened = find_and_open_script (file, 1 /*search_path*/, | ||||||
|  |  				     &stream, &full_path); | ||||||
|  |   | ||||||
|  | +      back_to = make_cleanup (null_cleanup, NULL);
 | ||||||
|  | +      if (opened)
 | ||||||
|  | +	{
 | ||||||
|  | +	  make_cleanup_fclose (stream);
 | ||||||
|  | +	  make_cleanup (xfree, full_path);
 | ||||||
|  | +	}
 | ||||||
|  | +
 | ||||||
|  |        /* If one script isn't found it's not uncommon for more to not be | ||||||
|  |  	 found either.  We don't want to print an error message for each | ||||||
|  |  	 script, too much noise.  Instead, we print the warning once and tell | ||||||
|  | @@ -313,9 +321,9 @@
 | ||||||
|  |  	  /* If this file is not currently loaded, load it.  */ | ||||||
|  |  	  if (! in_hash_table) | ||||||
|  |  	    source_python_script_for_objfile (objfile, stream, full_path); | ||||||
|  | -	  fclose (stream);
 | ||||||
|  | -	  xfree (full_path);
 | ||||||
|  |  	} | ||||||
|  | +
 | ||||||
|  | +      do_cleanups (back_to);
 | ||||||
|  |      } | ||||||
|  |  } | ||||||
|  |   | ||||||
|  | @@ -420,6 +428,8 @@
 | ||||||
|  |      { | ||||||
|  |        struct auto_load_pspace_info *pspace_info; | ||||||
|  |   | ||||||
|  | +      make_cleanup_fclose (input);
 | ||||||
|  | +
 | ||||||
|  |        /* Add this script to the hash table too so "info auto-load-scripts" | ||||||
|  |  	 can print it.  */ | ||||||
|  |        pspace_info = | ||||||
|  | @@ -432,7 +442,6 @@
 | ||||||
|  |  	 and these scripts are required to be idempotent under multiple | ||||||
|  |  	 loads anyway.  */ | ||||||
|  |        source_python_script_for_objfile (objfile, input, debugfile); | ||||||
|  | -      fclose (input);
 | ||||||
|  |      } | ||||||
|  |   | ||||||
|  |    do_cleanups (cleanups); | ||||||
							
								
								
									
										57
									
								
								gdb-autoload-07of12.patch
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										57
									
								
								gdb-autoload-07of12.patch
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,57 @@ | |||||||
|  | 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 | ||||||
|  | --- src/gdb/doc/gdb.texinfo	2012/03/22 08:10:41	1.936
 | ||||||
|  | +++ src/gdb/doc/gdb.texinfo	2012/03/27 20:15:20	1.937
 | ||||||
|  | @@ -24717,8 +24717,8 @@
 | ||||||
|  |  @file{@var{objfile}-gdb.py} and @code{.debug_gdb_scripts} section. | ||||||
|  |   | ||||||
|  |  @menu | ||||||
|  | -* objfile-gdb.py file::         The @file{@var{objfile}-gdb.py} file
 | ||||||
|  | -* .debug_gdb_scripts section::  The @code{.debug_gdb_scripts} section
 | ||||||
|  | +* objfile-gdb.py file::          The @file{@var{objfile}-gdb.py} file
 | ||||||
|  | +* dotdebug_gdb_scripts section:: The @code{.debug_gdb_scripts} section
 | ||||||
|  |  * Which flavor to choose?:: | ||||||
|  |  @end menu | ||||||
|  |   | ||||||
|  | @@ -24744,7 +24744,7 @@
 | ||||||
|  |   | ||||||
|  |  Also printed is the list of scripts that were mentioned in | ||||||
|  |  the @code{.debug_gdb_scripts} section and were not found | ||||||
|  | -(@pxref{.debug_gdb_scripts section}).
 | ||||||
|  | +(@pxref{dotdebug_gdb_scripts section}).
 | ||||||
|  |  This is useful because their names are not printed when @value{GDBN} | ||||||
|  |  tries to load them and fails.  There may be many of them, and printing | ||||||
|  |  an error message for each one is problematic. | ||||||
|  | @@ -24795,7 +24795,7 @@
 | ||||||
|  |  So your @file{-gdb.py} file should be careful to avoid errors if it | ||||||
|  |  is evaluated more than once. | ||||||
|  |   | ||||||
|  | -@node .debug_gdb_scripts section
 | ||||||
|  | +@node dotdebug_gdb_scripts section
 | ||||||
|  |  @subsubsection The @code{.debug_gdb_scripts} section | ||||||
|  |  @cindex @code{.debug_gdb_scripts} section | ||||||
|  |   | ||||||
|  | @@ -33475,7 +33475,7 @@
 | ||||||
|  |  matching @var{regexp}. | ||||||
|  |  For each script, this command prints its name as specified in the objfile, | ||||||
|  |  and the full path if known. | ||||||
|  | -@xref{.debug_gdb_scripts section}.
 | ||||||
|  | +@xref{dotdebug_gdb_scripts section}.
 | ||||||
|  |   | ||||||
|  |  @kindex maint print statistics | ||||||
|  |  @cindex bcache statistics | ||||||
							
								
								
									
										171
									
								
								gdb-autoload-08of12.patch
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										171
									
								
								gdb-autoload-08of12.patch
									
									
									
									
									
										Normal 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.4.50.20120120/gdb/gdb_vecs.h
 | ||||||
|  | ===================================================================
 | ||||||
|  | --- gdb-7.4.50.20120120.orig/gdb/gdb_vecs.h	2012-04-18 00:40:12.067086016 +0200
 | ||||||
|  | +++ gdb-7.4.50.20120120/gdb/gdb_vecs.h	2012-04-18 00:40:23.474056993 +0200
 | ||||||
|  | @@ -25,4 +25,16 @@
 | ||||||
|  |   | ||||||
|  |  DEF_VEC_P (char_ptr); | ||||||
|  |   | ||||||
|  | +/* From utils.c: */
 | ||||||
|  | +
 | ||||||
|  | +extern void free_char_ptr_vec (VEC (char_ptr) *char_ptr_vec);
 | ||||||
|  | +
 | ||||||
|  | +extern struct cleanup *
 | ||||||
|  | +  make_cleanup_free_char_ptr_vec (VEC (char_ptr) *char_ptr_vec);
 | ||||||
|  | +
 | ||||||
|  | +extern void dirnames_to_char_ptr_vec_append (VEC (char_ptr) **vecp,
 | ||||||
|  | +					     const char *dirnames);
 | ||||||
|  | +
 | ||||||
|  | +extern VEC (char_ptr) *dirnames_to_char_ptr_vec (const char *dirnames);
 | ||||||
|  | +
 | ||||||
|  |  #endif /* GDB_VECS_H */ | ||||||
|  | Index: gdb-7.4.50.20120120/gdb/utils.c
 | ||||||
|  | ===================================================================
 | ||||||
|  | --- gdb-7.4.50.20120120.orig/gdb/utils.c	2012-04-18 00:40:12.068086013 +0200
 | ||||||
|  | +++ gdb-7.4.50.20120120/gdb/utils.c	2012-04-18 00:40:49.862989855 +0200
 | ||||||
|  | @@ -29,6 +29,7 @@
 | ||||||
|  |  #ifdef HAVE_SYS_RESOURCE_H | ||||||
|  |  #include <sys/resource.h> | ||||||
|  |  #endif /* HAVE_SYS_RESOURCE_H */ | ||||||
|  | +#include "gdb_vecs.h"
 | ||||||
|  |   | ||||||
|  |  #ifdef TUI | ||||||
|  |  #include "tui/tui.h"		/* For tui_get_command_dimension.   */ | ||||||
|  | @@ -3835,6 +3836,95 @@ producer_is_gcc_ge_4 (const char *produc
 | ||||||
|  |    return minor; | ||||||
|  |  } | ||||||
|  |   | ||||||
|  | +/* Call xfree for each element of CHAR_PTR_VEC and final VEC_free for
 | ||||||
|  | +   CHAR_PTR_VEC itself.
 | ||||||
|  | +
 | ||||||
|  | +   You must not modify CHAR_PTR_VEC after it got registered with this function
 | ||||||
|  | +   by make_cleanup as the CHAR_PTR_VEC base address may change on its updates.
 | ||||||
|  | +   Contrary to VEC_free this function does not (cannot) clear the pointer.  */
 | ||||||
|  | +
 | ||||||
|  | +void
 | ||||||
|  | +free_char_ptr_vec (VEC (char_ptr) *char_ptr_vec)
 | ||||||
|  | +{
 | ||||||
|  | +  int ix;
 | ||||||
|  | +  char *name;
 | ||||||
|  | +
 | ||||||
|  | +  for (ix = 0; VEC_iterate (char_ptr, char_ptr_vec, ix, name); ++ix)
 | ||||||
|  | +    xfree (name);
 | ||||||
|  | +  VEC_free (char_ptr, char_ptr_vec);
 | ||||||
|  | +}
 | ||||||
|  | +
 | ||||||
|  | +/* Helper for make_cleanup_free_char_ptr_vec.  */
 | ||||||
|  | +
 | ||||||
|  | +static void
 | ||||||
|  | +do_free_char_ptr_vec (void *arg)
 | ||||||
|  | +{
 | ||||||
|  | +  VEC (char_ptr) *char_ptr_vec = arg;
 | ||||||
|  | +
 | ||||||
|  | +  free_char_ptr_vec (char_ptr_vec);
 | ||||||
|  | +}
 | ||||||
|  | +
 | ||||||
|  | +/* Make cleanup handler calling xfree for each element of CHAR_PTR_VEC and
 | ||||||
|  | +   final VEC_free for CHAR_PTR_VEC itself.
 | ||||||
|  | +
 | ||||||
|  | +   You must not modify CHAR_PTR_VEC after this cleanup registration as the
 | ||||||
|  | +   CHAR_PTR_VEC base address may change on its updates.  Contrary to VEC_free
 | ||||||
|  | +   this function does not (cannot) clear the pointer.  */
 | ||||||
|  | +
 | ||||||
|  | +struct cleanup *
 | ||||||
|  | +make_cleanup_free_char_ptr_vec (VEC (char_ptr) *char_ptr_vec)
 | ||||||
|  | +{
 | ||||||
|  | +  return make_cleanup (do_free_char_ptr_vec, char_ptr_vec);
 | ||||||
|  | +}
 | ||||||
|  | +
 | ||||||
|  | +/* Extended version of dirnames_to_char_ptr_vec - additionally if *VECP is
 | ||||||
|  | +   non-NULL the new list elements from DIRNAMES are appended to the existing
 | ||||||
|  | +   *VECP list of entries.  *VECP address will be updated by this call.  */
 | ||||||
|  | +
 | ||||||
|  | +void
 | ||||||
|  | +dirnames_to_char_ptr_vec_append (VEC (char_ptr) **vecp, const char *dirnames)
 | ||||||
|  | +{
 | ||||||
|  | +  do
 | ||||||
|  | +    {
 | ||||||
|  | +      size_t this_len;
 | ||||||
|  | +      char *next_dir, *this_dir;
 | ||||||
|  | +
 | ||||||
|  | +      next_dir = strchr (dirnames, DIRNAME_SEPARATOR);
 | ||||||
|  | +      if (next_dir == NULL)
 | ||||||
|  | +	this_len = strlen (dirnames);
 | ||||||
|  | +      else
 | ||||||
|  | +	{
 | ||||||
|  | +	  this_len = next_dir - dirnames;
 | ||||||
|  | +	  next_dir++;
 | ||||||
|  | +	}
 | ||||||
|  | +
 | ||||||
|  | +      this_dir = xmalloc (this_len + 1);
 | ||||||
|  | +      memcpy (this_dir, dirnames, this_len);
 | ||||||
|  | +      this_dir[this_len] = '\0';
 | ||||||
|  | +      VEC_safe_push (char_ptr, *vecp, this_dir);
 | ||||||
|  | +
 | ||||||
|  | +      dirnames = next_dir;
 | ||||||
|  | +    }
 | ||||||
|  | +  while (dirnames != NULL);
 | ||||||
|  | +}
 | ||||||
|  | +
 | ||||||
|  | +/* Split DIRNAMES by DIRNAME_SEPARATOR delimiter and return a list of all the
 | ||||||
|  | +   elements in their original order.  For empty string ("") DIRNAMES return
 | ||||||
|  | +   list of one empty string ("") element.
 | ||||||
|  | +   
 | ||||||
|  | +   You may modify the returned strings.
 | ||||||
|  | +   Read free_char_ptr_vec for its cleanup.  */
 | ||||||
|  | +
 | ||||||
|  | +VEC (char_ptr) *
 | ||||||
|  | +dirnames_to_char_ptr_vec (const char *dirnames)
 | ||||||
|  | +{
 | ||||||
|  | +  VEC (char_ptr) *retval = NULL;
 | ||||||
|  | +  
 | ||||||
|  | +  dirnames_to_char_ptr_vec_append (&retval, dirnames);
 | ||||||
|  | +
 | ||||||
|  | +  return retval;
 | ||||||
|  | +}
 | ||||||
|  | +
 | ||||||
|  |  #ifdef HAVE_WAITPID | ||||||
|  |   | ||||||
|  |  #ifdef SIGALRM | ||||||
							
								
								
									
										1168
									
								
								gdb-autoload-09of12.patch
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1168
									
								
								gdb-autoload-09of12.patch
									
									
									
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
							
								
								
									
										1704
									
								
								gdb-autoload-10of12.patch
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1704
									
								
								gdb-autoload-10of12.patch
									
									
									
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
							
								
								
									
										744
									
								
								gdb-autoload-11of12.patch
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										744
									
								
								gdb-autoload-11of12.patch
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,744 @@ | |||||||
|  | [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.4.50.20120120/gdb/NEWS
 | ||||||
|  | ===================================================================
 | ||||||
|  | --- gdb-7.4.50.20120120.orig/gdb/NEWS	2012-04-18 00:49:02.000000000 +0200
 | ||||||
|  | +++ gdb-7.4.50.20120120/gdb/NEWS	2012-04-18 00:49:33.282706319 +0200
 | ||||||
|  | @@ -67,6 +67,11 @@ set auto-load libthread-db on|off
 | ||||||
|  |  show auto-load libthread-db | ||||||
|  |    Control auto-loading of inferior specific thread debugging shared library. | ||||||
|  |   | ||||||
|  | +set auto-load safe-path <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 | ||||||
|  |   | ||||||
|  |  --init-command=FILE, -ix          Like --command, -x but execute it | ||||||
|  | Index: gdb-7.4.50.20120120/gdb/auto-load.c
 | ||||||
|  | ===================================================================
 | ||||||
|  | --- gdb-7.4.50.20120120.orig/gdb/auto-load.c	2012-04-18 00:46:47.000000000 +0200
 | ||||||
|  | +++ gdb-7.4.50.20120120/gdb/auto-load.c	2012-04-18 00:49:21.607736020 +0200
 | ||||||
|  | @@ -32,6 +32,9 @@
 | ||||||
|  |  #include "gdbcmd.h" | ||||||
|  |  #include "cli/cli-decode.h" | ||||||
|  |  #include "cli/cli-setshow.h" | ||||||
|  | +#include "gdb_vecs.h"
 | ||||||
|  | +#include "readline/tilde.h"
 | ||||||
|  | +#include "completer.h"
 | ||||||
|  |   | ||||||
|  |  /* The suffix of per-objfile scripts to auto-load as non-Python command files. | ||||||
|  |     E.g. When the program loads libfoo.so, look for libfoo-gdb.gdb.  */ | ||||||
|  | @@ -90,6 +93,181 @@ show_auto_load_local_gdbinit (struct ui_
 | ||||||
|  |  		    value); | ||||||
|  |  } | ||||||
|  |   | ||||||
|  | +/* Directory list safe to hold auto-loaded files.  It is not checked for
 | ||||||
|  | +   absolute paths but they are strongly recommended.  It is initialized by
 | ||||||
|  | +   _initialize_auto_load.  */
 | ||||||
|  | +static char *auto_load_safe_path;
 | ||||||
|  | +
 | ||||||
|  | +/* Vector of directory elements of AUTO_LOAD_SAFE_PATH with each one normalized
 | ||||||
|  | +   by tilde_expand and possibly each entries has added its gdb_realpath
 | ||||||
|  | +   counterpart.  */
 | ||||||
|  | +static VEC (char_ptr) *auto_load_safe_path_vec;
 | ||||||
|  | +
 | ||||||
|  | +/* Update auto_load_safe_path_vec from current AUTO_LOAD_SAFE_PATH.  */
 | ||||||
|  | +
 | ||||||
|  | +static void
 | ||||||
|  | +auto_load_safe_path_vec_update (void)
 | ||||||
|  | +{
 | ||||||
|  | +  VEC (char_ptr) *dir_vec = NULL;
 | ||||||
|  | +  unsigned len;
 | ||||||
|  | +  int ix;
 | ||||||
|  | +
 | ||||||
|  | +  free_char_ptr_vec (auto_load_safe_path_vec);
 | ||||||
|  | +
 | ||||||
|  | +  auto_load_safe_path_vec = dirnames_to_char_ptr_vec (auto_load_safe_path);
 | ||||||
|  | +  len = VEC_length (char_ptr, auto_load_safe_path_vec);
 | ||||||
|  | +
 | ||||||
|  | +  /* Apply tilde_expand and gdb_realpath to each AUTO_LOAD_SAFE_PATH_VEC
 | ||||||
|  | +     element.  */
 | ||||||
|  | +  for (ix = 0; ix < len; ix++)
 | ||||||
|  | +    {
 | ||||||
|  | +      char *dir = VEC_index (char_ptr, auto_load_safe_path_vec, ix);
 | ||||||
|  | +      char *expanded = tilde_expand (dir);
 | ||||||
|  | +      char *real_path = gdb_realpath (expanded);
 | ||||||
|  | +
 | ||||||
|  | +      /* Ensure the current entry is at least tilde_expand-ed.  */
 | ||||||
|  | +      xfree (dir);
 | ||||||
|  | +      VEC_replace (char_ptr, auto_load_safe_path_vec, ix, expanded);
 | ||||||
|  | +
 | ||||||
|  | +      /* If gdb_realpath returns a different content, append it.  */
 | ||||||
|  | +      if (strcmp (real_path, expanded) == 0)
 | ||||||
|  | +	xfree (real_path);
 | ||||||
|  | +      else
 | ||||||
|  | +	VEC_safe_push (char_ptr, auto_load_safe_path_vec, real_path);
 | ||||||
|  | +    }
 | ||||||
|  | +}
 | ||||||
|  | +
 | ||||||
|  | +/* "set" command for the auto_load_safe_path configuration variable.  */
 | ||||||
|  | +
 | ||||||
|  | +static void
 | ||||||
|  | +set_auto_load_safe_path (char *args, int from_tty, struct cmd_list_element *c)
 | ||||||
|  | +{
 | ||||||
|  | +  auto_load_safe_path_vec_update ();
 | ||||||
|  | +}
 | ||||||
|  | +
 | ||||||
|  | +/* "show" command for the auto_load_safe_path configuration variable.  */
 | ||||||
|  | +
 | ||||||
|  | +static void
 | ||||||
|  | +show_auto_load_safe_path (struct ui_file *file, int from_tty,
 | ||||||
|  | +			  struct cmd_list_element *c, const char *value)
 | ||||||
|  | +{
 | ||||||
|  | +  if (*value == 0)
 | ||||||
|  | +    fprintf_filtered (file, _("Auto-load files are safe to load from any "
 | ||||||
|  | +			      "directory.\n"));
 | ||||||
|  | +  else
 | ||||||
|  | +    fprintf_filtered (file, _("List of directories from which it is safe to "
 | ||||||
|  | +			      "auto-load files is %s.\n"),
 | ||||||
|  | +		      value);
 | ||||||
|  | +}
 | ||||||
|  | +
 | ||||||
|  | +/* "add-auto-load-safe-path" command for the auto_load_safe_path configuration
 | ||||||
|  | +   variable.  */
 | ||||||
|  | +
 | ||||||
|  | +static void
 | ||||||
|  | +add_auto_load_safe_path (char *args, int from_tty)
 | ||||||
|  | +{
 | ||||||
|  | +  char *s;
 | ||||||
|  | +
 | ||||||
|  | +  if (args == NULL || *args == 0)
 | ||||||
|  | +    error (_("\
 | ||||||
|  | +Adding empty directory element disables the auto-load safe-path security.  \
 | ||||||
|  | +Use 'set auto-load safe-path' instead if you mean that."));
 | ||||||
|  | +
 | ||||||
|  | +  s = xstrprintf ("%s%c%s", auto_load_safe_path, DIRNAME_SEPARATOR, args);
 | ||||||
|  | +  xfree (auto_load_safe_path);
 | ||||||
|  | +  auto_load_safe_path = s;
 | ||||||
|  | +
 | ||||||
|  | +  auto_load_safe_path_vec_update ();
 | ||||||
|  | +}
 | ||||||
|  | +
 | ||||||
|  | +/* Return 1 if FILENAME is equal to DIR or if FILENAME belongs to the
 | ||||||
|  | +   subdirectory DIR.  Return 0 otherwise.  gdb_realpath normalization is never
 | ||||||
|  | +   done here.  */
 | ||||||
|  | +
 | ||||||
|  | +static ATTRIBUTE_PURE int
 | ||||||
|  | +filename_is_in_dir (const char *filename, const char *dir)
 | ||||||
|  | +{
 | ||||||
|  | +  size_t dir_len = strlen (dir);
 | ||||||
|  | +
 | ||||||
|  | +  while (dir_len && IS_DIR_SEPARATOR (dir[dir_len - 1]))
 | ||||||
|  | +    dir_len--;
 | ||||||
|  | +
 | ||||||
|  | +  return (filename_ncmp (dir, filename, dir_len) == 0
 | ||||||
|  | +	  && (IS_DIR_SEPARATOR (filename[dir_len])
 | ||||||
|  | +	      || filename[dir_len] == '\0'));
 | ||||||
|  | +}
 | ||||||
|  | +
 | ||||||
|  | +/* Return 1 if FILENAME belongs to one of directory components of
 | ||||||
|  | +   AUTO_LOAD_SAFE_PATH_VEC.  Return 0 otherwise.
 | ||||||
|  | +   auto_load_safe_path_vec_update is never called.
 | ||||||
|  | +   *FILENAME_REALP may be updated by gdb_realpath of FILENAME - it has to be
 | ||||||
|  | +   freed by the caller.  */
 | ||||||
|  | +
 | ||||||
|  | +static int
 | ||||||
|  | +filename_is_in_auto_load_safe_path_vec (const char *filename,
 | ||||||
|  | +					char **filename_realp)
 | ||||||
|  | +{
 | ||||||
|  | +  char *dir;
 | ||||||
|  | +  int ix;
 | ||||||
|  | +
 | ||||||
|  | +  for (ix = 0; VEC_iterate (char_ptr, auto_load_safe_path_vec, ix, dir); ++ix)
 | ||||||
|  | +    if (*filename_realp == NULL && filename_is_in_dir (filename, dir))
 | ||||||
|  | +      break;
 | ||||||
|  | +  
 | ||||||
|  | +  if (dir == NULL)
 | ||||||
|  | +    {
 | ||||||
|  | +      if (*filename_realp == NULL)
 | ||||||
|  | +	*filename_realp = gdb_realpath (filename);
 | ||||||
|  | +
 | ||||||
|  | +      for (ix = 0; VEC_iterate (char_ptr, auto_load_safe_path_vec, ix, dir);
 | ||||||
|  | +	   ++ix)
 | ||||||
|  | +	if (filename_is_in_dir (*filename_realp, dir))
 | ||||||
|  | +	  break;
 | ||||||
|  | +    }
 | ||||||
|  | +
 | ||||||
|  | +  if (dir != NULL)
 | ||||||
|  | +    return 1;
 | ||||||
|  | +
 | ||||||
|  | +  return 0;
 | ||||||
|  | +}
 | ||||||
|  | +
 | ||||||
|  | +/* Return 1 if FILENAME is located in one of the directories of
 | ||||||
|  | +   AUTO_LOAD_SAFE_PATH.  Otherwise call warning and return 0.  FILENAME does
 | ||||||
|  | +   not have to be an absolute path.
 | ||||||
|  | +
 | ||||||
|  | +   Existence of FILENAME is not checked.  Function will still give a warning
 | ||||||
|  | +   even if the caller would quietly skip non-existing file in unsafe
 | ||||||
|  | +   directory.  */
 | ||||||
|  | +
 | ||||||
|  | +int
 | ||||||
|  | +file_is_auto_load_safe (const char *filename)
 | ||||||
|  | +{
 | ||||||
|  | +  char *filename_real = NULL;
 | ||||||
|  | +  struct cleanup *back_to;
 | ||||||
|  | +
 | ||||||
|  | +  back_to = make_cleanup (free_current_contents, &filename_real);
 | ||||||
|  | +
 | ||||||
|  | +  if (filename_is_in_auto_load_safe_path_vec (filename, &filename_real))
 | ||||||
|  | +    {
 | ||||||
|  | +      do_cleanups (back_to);
 | ||||||
|  | +      return 1;
 | ||||||
|  | +    }
 | ||||||
|  | +
 | ||||||
|  | +  auto_load_safe_path_vec_update ();
 | ||||||
|  | +  if (filename_is_in_auto_load_safe_path_vec (filename, &filename_real))
 | ||||||
|  | +    {
 | ||||||
|  | +      do_cleanups (back_to);
 | ||||||
|  | +      return 1;
 | ||||||
|  | +    }
 | ||||||
|  | +
 | ||||||
|  | +  warning (_("File \"%s\" auto-loading has been declined by your "
 | ||||||
|  | +	     "`auto-load safe-path' set to \"%s\"."),
 | ||||||
|  | +	   filename_real, auto_load_safe_path);
 | ||||||
|  | +
 | ||||||
|  | +  do_cleanups (back_to);
 | ||||||
|  | +  return 0;
 | ||||||
|  | +}
 | ||||||
|  | +
 | ||||||
|  |  /* Definition of script language for GDB canned sequences of commands.  */ | ||||||
|  |   | ||||||
|  |  static const struct script_language script_language_gdb | ||||||
|  | @@ -99,13 +277,20 @@ static void
 | ||||||
|  |  source_gdb_script_for_objfile (struct objfile *objfile, FILE *file, | ||||||
|  |  			       const char *filename) | ||||||
|  |  { | ||||||
|  | +  int is_safe;
 | ||||||
|  |    struct auto_load_pspace_info *pspace_info; | ||||||
|  |    volatile struct gdb_exception e; | ||||||
|  |   | ||||||
|  | +  is_safe = file_is_auto_load_safe (filename);
 | ||||||
|  | +
 | ||||||
|  |    /* Add this script to the hash table too so "info auto-load gdb-scripts" | ||||||
|  |       can print it.  */ | ||||||
|  |    pspace_info = get_auto_load_pspace_data_for_loading (current_program_space); | ||||||
|  | -  maybe_add_script (pspace_info, filename, filename, &script_language_gdb);
 | ||||||
|  | +  maybe_add_script (pspace_info, is_safe, filename, filename,
 | ||||||
|  | +		    &script_language_gdb);
 | ||||||
|  | +
 | ||||||
|  | +  if (!is_safe)
 | ||||||
|  | +    return;
 | ||||||
|  |   | ||||||
|  |    TRY_CATCH (e, RETURN_MASK_ALL) | ||||||
|  |      { | ||||||
|  | @@ -140,6 +325,9 @@ struct loaded_script
 | ||||||
|  |       inaccessible).  */ | ||||||
|  |    const char *full_path; | ||||||
|  |   | ||||||
|  | +  /* Non-zero if this script has been loaded.  */
 | ||||||
|  | +  int loaded;
 | ||||||
|  | +
 | ||||||
|  |    const struct script_language *language; | ||||||
|  |  }; | ||||||
|  |   | ||||||
|  | @@ -232,12 +420,13 @@ get_auto_load_pspace_data_for_loading (s
 | ||||||
|  |    return info; | ||||||
|  |  } | ||||||
|  |   | ||||||
|  | -/* Add script NAME in LANGUAGE to hash table of PSPACE_INFO.
 | ||||||
|  | -   FULL_PATH is NULL if the script wasn't found.  The result is
 | ||||||
|  | +/* Add script NAME in LANGUAGE to hash table of PSPACE_INFO.  LOADED 1 if the
 | ||||||
|  | +   script has been (is going to) be loaded, 0 otherwise (such as if it has not
 | ||||||
|  | +   been found).  FULL_PATH is NULL if the script wasn't found.  The result is
 | ||||||
|  |     true if the script was already in the hash table.  */ | ||||||
|  |   | ||||||
|  |  int | ||||||
|  | -maybe_add_script (struct auto_load_pspace_info *pspace_info,
 | ||||||
|  | +maybe_add_script (struct auto_load_pspace_info *pspace_info, int loaded,
 | ||||||
|  |  		  const char *name, const char *full_path, | ||||||
|  |  		  const struct script_language *language) | ||||||
|  |  { | ||||||
|  | @@ -271,6 +460,7 @@ maybe_add_script (struct auto_load_pspac
 | ||||||
|  |  	} | ||||||
|  |        else | ||||||
|  |  	(*slot)->full_path = NULL; | ||||||
|  | +      (*slot)->loaded = loaded;
 | ||||||
|  |        (*slot)->language = language; | ||||||
|  |      } | ||||||
|  |   | ||||||
|  | @@ -432,7 +622,7 @@ print_script (struct loaded_script *scri
 | ||||||
|  |   | ||||||
|  |    chain = make_cleanup_ui_out_tuple_begin_end (uiout, NULL); | ||||||
|  |   | ||||||
|  | -  ui_out_field_string (uiout, "loaded", script->full_path ? "Yes" : "Missing");
 | ||||||
|  | +  ui_out_field_string (uiout, "loaded", script->loaded ? "Yes" : "No");
 | ||||||
|  |    ui_out_field_string (uiout, "script", script->name); | ||||||
|  |    ui_out_text (uiout, "\n"); | ||||||
|  |   | ||||||
|  | @@ -718,6 +908,8 @@ void _initialize_auto_load (void);
 | ||||||
|  |  void | ||||||
|  |  _initialize_auto_load (void) | ||||||
|  |  { | ||||||
|  | +  struct cmd_list_element *cmd;
 | ||||||
|  | +
 | ||||||
|  |    auto_load_pspace_data | ||||||
|  |      = register_program_space_data_with_cleanup (auto_load_pspace_data_cleanup); | ||||||
|  |   | ||||||
|  | @@ -757,4 +949,30 @@ This options has security implications f
 | ||||||
|  |  	   _("Print whether current directory .gdbinit file has been loaded.\n\ | ||||||
|  |  Usage: info auto-load local-gdbinit"), | ||||||
|  |  	   auto_load_info_cmdlist_get ()); | ||||||
|  | +
 | ||||||
|  | +  auto_load_safe_path = xstrdup (DEFAULT_AUTO_LOAD_SAFE_PATH);
 | ||||||
|  | +  auto_load_safe_path_vec_update ();
 | ||||||
|  | +  add_setshow_optional_filename_cmd ("safe-path", class_support,
 | ||||||
|  | +				     &auto_load_safe_path, _("\
 | ||||||
|  | +Set the list of directories from which it is safe to auto-load files."), _("\
 | ||||||
|  | +Show the list of directories from which it is safe to auto-load files."), _("\
 | ||||||
|  | +Various files loaded automatically for the 'set auto-load ...' options must\n\
 | ||||||
|  | +be located in one of the directories listed by this option.  Warning will be\n\
 | ||||||
|  | +printed and file will not be used otherwise.  Use empty string (or even\n\
 | ||||||
|  | +empty directory entry) to allow any file for the 'set auto-load ...' options.\n\
 | ||||||
|  | +This option is ignored for the kinds of files having 'set auto-load ... off'.\n\
 | ||||||
|  | +This options has security implications for untrusted inferiors."),
 | ||||||
|  | +				     set_auto_load_safe_path,
 | ||||||
|  | +				     show_auto_load_safe_path,
 | ||||||
|  | +				     auto_load_set_cmdlist_get (),
 | ||||||
|  | +				     auto_load_show_cmdlist_get ());
 | ||||||
|  | +
 | ||||||
|  | +  cmd = add_cmd ("add-auto-load-safe-path", class_support,
 | ||||||
|  | +		 add_auto_load_safe_path,
 | ||||||
|  | +		 _("Add entries to the list of directories from which it is safe "
 | ||||||
|  | +		   "to auto-load files.\n\
 | ||||||
|  | +See the commands 'set auto-load safe-path' and 'show auto-load safe-path' to\n\
 | ||||||
|  | +access the current full list setting."),
 | ||||||
|  | +		 &cmdlist);
 | ||||||
|  | +  set_cmd_completer (cmd, filename_completer);
 | ||||||
|  |  } | ||||||
|  | Index: gdb-7.4.50.20120120/gdb/auto-load.h
 | ||||||
|  | ===================================================================
 | ||||||
|  | --- gdb-7.4.50.20120120.orig/gdb/auto-load.h	2012-04-18 00:46:47.000000000 +0200
 | ||||||
|  | +++ gdb-7.4.50.20120120/gdb/auto-load.h	2012-04-18 00:49:21.607736020 +0200
 | ||||||
|  | @@ -39,7 +39,8 @@ extern int auto_load_local_gdbinit_loade
 | ||||||
|  |  extern struct auto_load_pspace_info * | ||||||
|  |    get_auto_load_pspace_data_for_loading (struct program_space *pspace); | ||||||
|  |  extern int maybe_add_script (struct auto_load_pspace_info *pspace_info, | ||||||
|  | -			     const char *name, const char *full_path,
 | ||||||
|  | +			     int loaded, const char *name,
 | ||||||
|  | +			     const char *full_path,
 | ||||||
|  |  			     const struct script_language *language); | ||||||
|  |  extern void auto_load_objfile_script (struct objfile *objfile, | ||||||
|  |  				      const struct script_language *language); | ||||||
|  | @@ -54,4 +55,6 @@ extern struct cmd_list_element **auto_lo
 | ||||||
|  |  extern struct cmd_list_element **auto_load_show_cmdlist_get (void); | ||||||
|  |  extern struct cmd_list_element **auto_load_info_cmdlist_get (void); | ||||||
|  |   | ||||||
|  | +extern int file_is_auto_load_safe (const char *filename);
 | ||||||
|  | +
 | ||||||
|  |  #endif /* AUTO_LOAD_H */ | ||||||
|  | Index: gdb-7.4.50.20120120/gdb/config.in
 | ||||||
|  | ===================================================================
 | ||||||
|  | --- gdb-7.4.50.20120120.orig/gdb/config.in	2012-04-18 00:46:47.000000000 +0200
 | ||||||
|  | +++ gdb-7.4.50.20120120/gdb/config.in	2012-04-18 00:49:21.607736020 +0200
 | ||||||
|  | @@ -43,6 +43,9 @@
 | ||||||
|  |     moved. */ | ||||||
|  |  #undef DEBUGDIR_RELOCATABLE | ||||||
|  |   | ||||||
|  | +/* Directories safe to hold auto-loaded files. */
 | ||||||
|  | +#undef DEFAULT_AUTO_LOAD_SAFE_PATH
 | ||||||
|  | +
 | ||||||
|  |  /* Define to BFD's default architecture. */ | ||||||
|  |  #undef DEFAULT_BFD_ARCH | ||||||
|  |   | ||||||
|  | Index: gdb-7.4.50.20120120/gdb/configure
 | ||||||
|  | ===================================================================
 | ||||||
|  | --- gdb-7.4.50.20120120.orig/gdb/configure	2012-04-18 00:46:47.000000000 +0200
 | ||||||
|  | +++ gdb-7.4.50.20120120/gdb/configure	2012-04-18 00:49:21.611736010 +0200
 | ||||||
|  | @@ -955,6 +955,7 @@ with_separate_debug_dir
 | ||||||
|  |  with_gdb_datadir | ||||||
|  |  with_relocated_sources | ||||||
|  |  with_rpm | ||||||
|  | +with_auto_load_safe_path
 | ||||||
|  |  enable_targets | ||||||
|  |  enable_64_bit_bfd | ||||||
|  |  enable_gdbcli | ||||||
|  | @@ -1666,6 +1667,10 @@ Optional Packages:
 | ||||||
|  |                            automatically relocate this path for source files | ||||||
|  |    --with-rpm              query rpm database for missing debuginfos (yes/no, | ||||||
|  |                            def. auto=librpm.so) | ||||||
|  | +  --with-auto-load-safe-path=PATH
 | ||||||
|  | +                          directories safe to hold auto-loaded files
 | ||||||
|  | +  --without-auto-load-safe-path
 | ||||||
|  | +                          do not restrict auto-loaded files locations
 | ||||||
|  |    --with-libunwind        use libunwind frame unwinding support | ||||||
|  |    --with-curses           use the curses library instead of the termcap | ||||||
|  |                            library | ||||||
|  | @@ -8477,6 +8482,32 @@ $as_echo "$as_me: WARNING: $RPM_PKG_ERRO
 | ||||||
|  |    fi | ||||||
|  |  fi | ||||||
|  |   | ||||||
|  | +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for default auto-load safe-path" >&5
 | ||||||
|  | +$as_echo_n "checking for default auto-load safe-path... " >&6; }
 | ||||||
|  | +
 | ||||||
|  | +# Check whether --with-auto-load-safe-path was given.
 | ||||||
|  | +if test "${with_auto_load_safe_path+set}" = set; then :
 | ||||||
|  | +  withval=$with_auto_load_safe_path; if test "$with_auto_load_safe_path" = "no"; then
 | ||||||
|  | +   with_auto_load_safe_path=""
 | ||||||
|  | + fi
 | ||||||
|  | +else
 | ||||||
|  | +  with_auto_load_safe_path="$prefix"
 | ||||||
|  | +fi
 | ||||||
|  | +
 | ||||||
|  | +
 | ||||||
|  | +  test "x$prefix" = xNONE && prefix="$ac_default_prefix"
 | ||||||
|  | +  test "x$exec_prefix" = xNONE && exec_prefix='${prefix}'
 | ||||||
|  | +  ac_define_dir=`eval echo $with_auto_load_safe_path`
 | ||||||
|  | +  ac_define_dir=`eval echo $ac_define_dir`
 | ||||||
|  | +
 | ||||||
|  | +cat >>confdefs.h <<_ACEOF
 | ||||||
|  | +#define DEFAULT_AUTO_LOAD_SAFE_PATH "$ac_define_dir"
 | ||||||
|  | +_ACEOF
 | ||||||
|  | +
 | ||||||
|  | +
 | ||||||
|  | +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $with_auto_load_safe_path" >&5
 | ||||||
|  | +$as_echo "$with_auto_load_safe_path" >&6; }
 | ||||||
|  | +
 | ||||||
|  |   | ||||||
|  |   | ||||||
|  |  subdirs="$subdirs testsuite" | ||||||
|  | Index: gdb-7.4.50.20120120/gdb/configure.ac
 | ||||||
|  | ===================================================================
 | ||||||
|  | --- gdb-7.4.50.20120120.orig/gdb/configure.ac	2012-04-18 00:46:47.000000000 +0200
 | ||||||
|  | +++ gdb-7.4.50.20120120/gdb/configure.ac	2012-04-18 00:49:21.611736010 +0200
 | ||||||
|  | @@ -339,6 +339,18 @@ extern rpmdbMatchIterator rpmtsInitItera
 | ||||||
|  |    fi | ||||||
|  |  fi | ||||||
|  |    | ||||||
|  | +AC_MSG_CHECKING([for default auto-load safe-path])
 | ||||||
|  | +AC_ARG_WITH(auto-load-safe-path,
 | ||||||
|  | +AS_HELP_STRING([--with-auto-load-safe-path=PATH], [directories safe to hold auto-loaded files])
 | ||||||
|  | +AS_HELP_STRING([--without-auto-load-safe-path], [do not restrict auto-loaded files locations]),
 | ||||||
|  | +[if test "$with_auto_load_safe_path" = "no"; then
 | ||||||
|  | +   with_auto_load_safe_path=""
 | ||||||
|  | + fi],
 | ||||||
|  | +[with_auto_load_safe_path="$prefix"])
 | ||||||
|  | +AC_DEFINE_DIR(DEFAULT_AUTO_LOAD_SAFE_PATH, with_auto_load_safe_path,
 | ||||||
|  | +	      [Directories safe to hold auto-loaded files.])
 | ||||||
|  | +AC_MSG_RESULT([$with_auto_load_safe_path])
 | ||||||
|  | +
 | ||||||
|  |  AC_CONFIG_SUBDIRS(testsuite) | ||||||
|  |   | ||||||
|  |  # Check whether to support alternative target configurations | ||||||
|  | Index: gdb-7.4.50.20120120/gdb/linux-thread-db.c
 | ||||||
|  | ===================================================================
 | ||||||
|  | --- gdb-7.4.50.20120120.orig/gdb/linux-thread-db.c	2012-04-18 00:46:47.000000000 +0200
 | ||||||
|  | +++ gdb-7.4.50.20120120/gdb/linux-thread-db.c	2012-04-18 00:49:21.612736007 +0200
 | ||||||
|  | @@ -868,7 +868,11 @@ try_thread_db_load_from_pdir_1 (struct o
 | ||||||
|  |    /* This should at minimum hit the first character.  */ | ||||||
|  |    gdb_assert (cp != NULL); | ||||||
|  |    strcpy (cp + 1, LIBTHREAD_DB_SO); | ||||||
|  | -  result = try_thread_db_load (path);
 | ||||||
|  | +
 | ||||||
|  | +  if (!file_is_auto_load_safe (path))
 | ||||||
|  | +    result = 0;
 | ||||||
|  | +  else
 | ||||||
|  | +    result = try_thread_db_load (path);
 | ||||||
|  |   | ||||||
|  |    do_cleanups (cleanup); | ||||||
|  |    return result; | ||||||
|  | @@ -934,7 +938,11 @@ try_thread_db_load_from_dir (const char
 | ||||||
|  |    memcpy (path, dir, dir_len); | ||||||
|  |    path[dir_len] = '/'; | ||||||
|  |    strcpy (path + dir_len + 1, LIBTHREAD_DB_SO); | ||||||
|  | -  result = try_thread_db_load (path);
 | ||||||
|  | +
 | ||||||
|  | +  if (!file_is_auto_load_safe (path))
 | ||||||
|  | +    result = 0;
 | ||||||
|  | +  else
 | ||||||
|  | +    result = try_thread_db_load (path);
 | ||||||
|  |   | ||||||
|  |    do_cleanups (cleanup); | ||||||
|  |    return result; | ||||||
|  | Index: gdb-7.4.50.20120120/gdb/main.c
 | ||||||
|  | ===================================================================
 | ||||||
|  | --- gdb-7.4.50.20120120.orig/gdb/main.c	2012-04-18 00:46:47.000000000 +0200
 | ||||||
|  | +++ gdb-7.4.50.20120120/gdb/main.c	2012-04-18 00:49:21.612736007 +0200
 | ||||||
|  | @@ -1026,7 +1026,8 @@ captured_main (void *data)
 | ||||||
|  |      { | ||||||
|  |        auto_load_local_gdbinit_pathname = gdb_realpath (local_gdbinit); | ||||||
|  |   | ||||||
|  | -      if (!inhibit_gdbinit && auto_load_local_gdbinit)
 | ||||||
|  | +      if (!inhibit_gdbinit && auto_load_local_gdbinit
 | ||||||
|  | +	  && file_is_auto_load_safe (local_gdbinit))
 | ||||||
|  |  	{ | ||||||
|  |  	  auto_load_local_gdbinit_loaded = 1; | ||||||
|  |   | ||||||
|  | Index: gdb-7.4.50.20120120/gdb/doc/gdb.texinfo
 | ||||||
|  | ===================================================================
 | ||||||
|  | --- gdb-7.4.50.20120120.orig/gdb/doc/gdb.texinfo	2012-04-18 00:46:47.000000000 +0200
 | ||||||
|  | +++ gdb-7.4.50.20120120/gdb/doc/gdb.texinfo	2012-04-18 00:49:21.620735987 +0200
 | ||||||
|  | @@ -20801,6 +20801,8 @@ gdb-scripts:  Auto-loading of canned seq
 | ||||||
|  |  libthread-db:  Auto-loading of inferior specific libthread_db is on. | ||||||
|  |  local-gdbinit:  Auto-loading of .gdbinit script from current directory is on. | ||||||
|  |  python-scripts:  Auto-loading of Python scripts is on. | ||||||
|  | +safe-path:  List of directories from which it is safe to auto-load files
 | ||||||
|  | +            is /usr/local.
 | ||||||
|  |  @end smallexample | ||||||
|  |   | ||||||
|  |  @anchor{info auto-load} | ||||||
|  | @@ -20872,12 +20874,19 @@ These are @value{GDBN} control commands
 | ||||||
|  |  @tab Show setting of thread debugging library. | ||||||
|  |  @item @xref{info auto-load libthread-db}. | ||||||
|  |  @tab Show state of thread debugging library. | ||||||
|  | +@item @xref{set auto-load safe-path}.
 | ||||||
|  | +@tab Control directories trusted for automatic loading.
 | ||||||
|  | +@item @xref{show auto-load safe-path}.
 | ||||||
|  | +@tab Show directories trusted for automatic loading.
 | ||||||
|  | +@item @xref{add-auto-load-safe-path}.
 | ||||||
|  | +@tab Add directory trusted for automatic loading.
 | ||||||
|  |  @end multitable | ||||||
|  |   | ||||||
|  |  @menu | ||||||
|  |  * Init File in the Current Directory:: @samp{set/show/info auto-load local-gdbinit} | ||||||
|  |  * libthread_db.so.1 file::             @samp{set/show/info auto-load libthread-db} | ||||||
|  |  * objfile-gdb.gdb file::               @samp{set/show/info auto-load gdb-script} | ||||||
|  | +* Auto-loading safe path::             @samp{set/show/info auto-load safe-path}
 | ||||||
|  |  @xref{Python Auto-loading}. | ||||||
|  |  @end menu | ||||||
|  |   | ||||||
|  | @@ -20978,6 +20987,104 @@ auto-loaded.
 | ||||||
|  |  If @var{regexp} is supplied only canned sequences of commands scripts with | ||||||
|  |  matching names are printed. | ||||||
|  |   | ||||||
|  | +@node Auto-loading safe path
 | ||||||
|  | +@subsection Security restriction for auto-loading
 | ||||||
|  | +@cindex auto-loading safe-path
 | ||||||
|  | +
 | ||||||
|  | +As the files of inferior can come from untrusted source (such as submitted by
 | ||||||
|  | +an application user) @value{GDBN} does not always load any files automatically.
 | ||||||
|  | +@value{GDBN} provides the @samp{set auto-load safe-path} setting to list
 | ||||||
|  | +directories trusted for loading files not explicitly requested by user.
 | ||||||
|  | +
 | ||||||
|  | +If the path is not set properly you will see a warning and the file will not
 | ||||||
|  | +get loaded:
 | ||||||
|  | +
 | ||||||
|  | +@smallexample
 | ||||||
|  | +$ ./gdb -q ./gdb
 | ||||||
|  | +Reading symbols from /home/user/gdb/gdb...done.
 | ||||||
|  | +warning: File "/home/user/gdb/gdb-gdb.gdb" auto-loading has been
 | ||||||
|  | +         declined by your `auto-load safe-path' set to "/usr/local".
 | ||||||
|  | +warning: File "/home/user/gdb/gdb-gdb.py" auto-loading has been
 | ||||||
|  | +         declined by your `auto-load safe-path' set to "/usr/local".
 | ||||||
|  | +@end smallexample
 | ||||||
|  | +
 | ||||||
|  | +The list of trusted directories is controlled by the following commands:
 | ||||||
|  | +
 | ||||||
|  | +@table @code
 | ||||||
|  | +@anchor{set auto-load safe-path}
 | ||||||
|  | +@kindex set auto-load safe-path
 | ||||||
|  | +@item set auto-load safe-path @var{directories}
 | ||||||
|  | +Set the list of directories (and their subdirectories) trusted for automatic
 | ||||||
|  | +loading and execution of scripts.  You can also enter a specific trusted file.
 | ||||||
|  | +The list of directories uses directory separator (@samp{:} on GNU and Unix
 | ||||||
|  | +systems, @samp{;} on MS-Windows and MS-DOS) to separate directories, similarly
 | ||||||
|  | +to the @env{PATH} environment variable.
 | ||||||
|  | +
 | ||||||
|  | +@anchor{show auto-load safe-path}
 | ||||||
|  | +@kindex show auto-load safe-path
 | ||||||
|  | +@item show auto-load safe-path
 | ||||||
|  | +Show the list of directories trusted for automatic loading and execution of
 | ||||||
|  | +scripts.
 | ||||||
|  | +
 | ||||||
|  | +@anchor{add-auto-load-safe-path}
 | ||||||
|  | +@kindex add-auto-load-safe-path
 | ||||||
|  | +@item add-auto-load-safe-path
 | ||||||
|  | +Add an entry (or list of entries) the list of directories trusted for automatic
 | ||||||
|  | +loading and execution of scripts.  Multiple entries may be delimited by the
 | ||||||
|  | +host platform directory separator in use.
 | ||||||
|  | +@end table
 | ||||||
|  | +
 | ||||||
|  | +Setting this variable to an empty string disables this security protection.
 | ||||||
|  | +This variable is supposed to be set to the system directories writable by the
 | ||||||
|  | +system superuser only.  Users can add their source directories in init files in
 | ||||||
|  | +their home directories (@pxref{Home Directory Init File}).  See also deprecated
 | ||||||
|  | +init file in the current directory
 | ||||||
|  | +(@pxref{Init File in the Current Directory during Startup}).
 | ||||||
|  | +
 | ||||||
|  | +To force @value{GDBN} to load the files it declined to load in the previous
 | ||||||
|  | +example, you could use one of the following ways:
 | ||||||
|  | +
 | ||||||
|  | +@itemize @bullet
 | ||||||
|  | +@item ~/.gdbinit: add-auto-load-safe-path ~/src/gdb
 | ||||||
|  | +Specify this trusted directory (or a file) as additional component of the list.
 | ||||||
|  | +You have to specify also any existing directories displayed by
 | ||||||
|  | +by @samp{show auto-load safe-path} (such as @samp{/usr:/bin} in this example).
 | ||||||
|  | +
 | ||||||
|  | +@item @kbd{gdb -iex "set auto-load safe-path /usr:/bin:~/src/gdb" [@dots{}]}
 | ||||||
|  | +Specify this directory as in the previous case but just for a single
 | ||||||
|  | +@value{GDBN} session.
 | ||||||
|  | +
 | ||||||
|  | +@item @kbd{gdb -iex "set auto-load safe-path" [@dots{}]}
 | ||||||
|  | +Disable auto-loading safety for a single @value{GDBN} session.
 | ||||||
|  | +This assumes all the files you debug during this @value{GDBN} session will come
 | ||||||
|  | +from trusted sources.
 | ||||||
|  | +
 | ||||||
|  | +@item @kbd{./configure --without-auto-load-safe-path}
 | ||||||
|  | +During compilation of @value{GDBN} you may disable any auto-loading safety.
 | ||||||
|  | +This assumes all the files you will ever debug with this @value{GDBN} come from
 | ||||||
|  | +trusted sources.
 | ||||||
|  | +@end itemize
 | ||||||
|  | +
 | ||||||
|  | +On the other hand you can also explicitly forbid automatic files loading which
 | ||||||
|  | +also suppresses any such warning messages:
 | ||||||
|  | +
 | ||||||
|  | +@itemize @bullet
 | ||||||
|  | +@item @kbd{gdb -iex "set auto-load no" [@dots{}]}
 | ||||||
|  | +You can use @value{GDBN} command-line option for a single @value{GDBN} session.
 | ||||||
|  | +
 | ||||||
|  | +@item @samp{~/.gdbinit}: @samp{set auto-load no}
 | ||||||
|  | +Disable auto-loading globally for the user
 | ||||||
|  | +(@pxref{Home Directory Init File}).  While it is improbable, you could also
 | ||||||
|  | +use system init file instead (@pxref{System-wide configuration}).
 | ||||||
|  | +@end itemize
 | ||||||
|  | +
 | ||||||
|  | +This setting applies to the file names as entered by user.  If no entry matches
 | ||||||
|  | +@value{GDBN} tries as a last resort to also resolve all the file names into
 | ||||||
|  | +their canonical form (typically resolving symbolic links) and compare the
 | ||||||
|  | +entries again.  @value{GDBN} already canonicalizes most of the filenames on its
 | ||||||
|  | +own before starting the comparison so a canonical form of directories is
 | ||||||
|  | +recommended to be entered.
 | ||||||
|  | +
 | ||||||
|  |  @node Messages/Warnings | ||||||
|  |  @section Optional Warnings and Messages | ||||||
|  |   | ||||||
|  | @@ -24955,10 +25062,10 @@ Example:
 | ||||||
|  |   | ||||||
|  |  @smallexample | ||||||
|  |  (gdb) info auto-load python-scripts | ||||||
|  | -Loaded  Script
 | ||||||
|  | -Yes     py-section-script.py
 | ||||||
|  | -        full name: /tmp/py-section-script.py
 | ||||||
|  | -Missing my-foo-pretty-printers.py
 | ||||||
|  | +Loaded Script
 | ||||||
|  | +Yes    py-section-script.py
 | ||||||
|  | +       full name: /tmp/py-section-script.py
 | ||||||
|  | +No     my-foo-pretty-printers.py
 | ||||||
|  |  @end smallexample | ||||||
|  |  @end table | ||||||
|  |   | ||||||
|  | Index: gdb-7.4.50.20120120/gdb/python/py-auto-load.c
 | ||||||
|  | ===================================================================
 | ||||||
|  | --- gdb-7.4.50.20120120.orig/gdb/python/py-auto-load.c	2012-04-18 00:46:47.000000000 +0200
 | ||||||
|  | +++ gdb-7.4.50.20120120/gdb/python/py-auto-load.c	2012-04-18 00:49:21.621735985 +0200
 | ||||||
|  | @@ -72,14 +72,19 @@ static void
 | ||||||
|  |  gdbpy_load_auto_script_for_objfile (struct objfile *objfile, FILE *file, | ||||||
|  |  				    const char *filename) | ||||||
|  |  { | ||||||
|  | +  int is_safe;
 | ||||||
|  |    struct auto_load_pspace_info *pspace_info; | ||||||
|  |   | ||||||
|  | +  is_safe = file_is_auto_load_safe (filename);
 | ||||||
|  | +
 | ||||||
|  |    /* Add this script to the hash table too so "info auto-load python-scripts" | ||||||
|  |       can print it.  */ | ||||||
|  |    pspace_info = get_auto_load_pspace_data_for_loading (current_program_space); | ||||||
|  | -  maybe_add_script (pspace_info, filename, filename, &script_language_python);
 | ||||||
|  | +  maybe_add_script (pspace_info, is_safe, filename, filename,
 | ||||||
|  | +		    &script_language_python);
 | ||||||
|  |   | ||||||
|  | -  source_python_script_for_objfile (objfile, file, filename);
 | ||||||
|  | +  if (is_safe)
 | ||||||
|  | +    source_python_script_for_objfile (objfile, file, filename);
 | ||||||
|  |  } | ||||||
|  |   | ||||||
|  |  /* Load scripts specified in OBJFILE. | ||||||
|  | @@ -147,6 +152,9 @@ source_section_scripts (struct objfile *
 | ||||||
|  |  	{ | ||||||
|  |  	  make_cleanup_fclose (stream); | ||||||
|  |  	  make_cleanup (xfree, full_path); | ||||||
|  | +
 | ||||||
|  | +	  if (!file_is_auto_load_safe (full_path))
 | ||||||
|  | +	    opened = 0;
 | ||||||
|  |  	} | ||||||
|  |        else | ||||||
|  |  	{ | ||||||
|  | @@ -167,7 +175,7 @@ Use `info auto-load python [REGEXP]' to
 | ||||||
|  |   | ||||||
|  |  	 IWBN if complaints.c were more general-purpose.  */ | ||||||
|  |   | ||||||
|  | -      in_hash_table = maybe_add_script (pspace_info, file, full_path,
 | ||||||
|  | +      in_hash_table = maybe_add_script (pspace_info, opened, file, full_path,
 | ||||||
|  |  					&script_language_python); | ||||||
|  |   | ||||||
|  |        /* If this file is not currently loaded, load it.  */ | ||||||
|  | Index: gdb-7.4.50.20120120/gdb/testsuite/gdb.python/py-objfile-script.exp
 | ||||||
|  | ===================================================================
 | ||||||
|  | --- gdb-7.4.50.20120120.orig/gdb/testsuite/gdb.python/py-objfile-script.exp	2012-04-18 00:46:47.000000000 +0200
 | ||||||
|  | +++ gdb-7.4.50.20120120/gdb/testsuite/gdb.python/py-objfile-script.exp	2012-04-18 00:49:21.621735985 +0200
 | ||||||
|  | @@ -37,6 +37,7 @@ if { [skip_python_tests] } { continue }
 | ||||||
|  |  set remote_python_file [remote_download host ${srcdir}/${subdir}/${testfile}-gdb.py.in ${subdir}/${testfile}-gdb.py] | ||||||
|  |   | ||||||
|  |  gdb_reinitialize_dir $srcdir/$subdir | ||||||
|  | +gdb_test_no_output "set auto-load safe-path ${remote_python_file}" "set auto-load safe-path"
 | ||||||
|  |  gdb_load ${binfile} | ||||||
|  |   | ||||||
|  |  # Verify gdb loaded the script. | ||||||
|  | Index: gdb-7.4.50.20120120/gdb/testsuite/gdb.python/py-section-script.exp
 | ||||||
|  | ===================================================================
 | ||||||
|  | --- gdb-7.4.50.20120120.orig/gdb/testsuite/gdb.python/py-section-script.exp	2012-04-18 00:46:47.000000000 +0200
 | ||||||
|  | +++ gdb-7.4.50.20120120/gdb/testsuite/gdb.python/py-section-script.exp	2012-04-18 00:49:21.621735985 +0200
 | ||||||
|  | @@ -49,6 +49,7 @@ if { [skip_python_tests] } { continue }
 | ||||||
|  |  set remote_python_file [remote_download host ${srcdir}/${subdir}/${testfile}.py] | ||||||
|  |   | ||||||
|  |  gdb_reinitialize_dir $srcdir/$subdir | ||||||
|  | +gdb_test_no_output "set auto-load safe-path ${remote_python_file}" "set auto-load safe-path"
 | ||||||
|  |  gdb_load ${binfile} | ||||||
|  |   | ||||||
|  |  # Verify gdb loaded the script. | ||||||
							
								
								
									
										352
									
								
								gdb-autoload-12of12.patch
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										352
									
								
								gdb-autoload-12of12.patch
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,352 @@ | |||||||
|  | [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.4.50.20120120/gdb/NEWS
 | ||||||
|  | ===================================================================
 | ||||||
|  | --- gdb-7.4.50.20120120.orig/gdb/NEWS	2012-04-18 00:49:33.000000000 +0200
 | ||||||
|  | +++ gdb-7.4.50.20120120/gdb/NEWS	2012-04-18 00:50:15.018600282 +0200
 | ||||||
|  | @@ -72,6 +72,10 @@ show auto-load safe-path
 | ||||||
|  |    Set a list of directories from which it is safe to auto-load files. | ||||||
|  |    The delimiter (':' above) may differ according to the host platform. | ||||||
|  |   | ||||||
|  | +set debug auto-load on|off
 | ||||||
|  | +show debug auto-load
 | ||||||
|  | +  Control display of debugging info for auto-loading the files above.
 | ||||||
|  | +
 | ||||||
|  |  * New command line options | ||||||
|  |   | ||||||
|  |  --init-command=FILE, -ix          Like --command, -x but execute it | ||||||
|  | Index: gdb-7.4.50.20120120/gdb/auto-load.c
 | ||||||
|  | ===================================================================
 | ||||||
|  | --- gdb-7.4.50.20120120.orig/gdb/auto-load.c	2012-04-18 00:49:21.000000000 +0200
 | ||||||
|  | +++ gdb-7.4.50.20120120/gdb/auto-load.c	2012-04-18 00:50:04.801626235 +0200
 | ||||||
|  | @@ -43,6 +43,20 @@
 | ||||||
|  |  static void source_gdb_script_for_objfile (struct objfile *objfile, FILE *file, | ||||||
|  |  					   const char *filename); | ||||||
|  |   | ||||||
|  | +/* Value of the 'set debug auto-load' configuration variable.  */
 | ||||||
|  | +static int debug_auto_load = 0;
 | ||||||
|  | +
 | ||||||
|  | +/* "show" command for the debug_auto_load configuration variable.  */
 | ||||||
|  | +
 | ||||||
|  | +static void
 | ||||||
|  | +show_debug_auto_load (struct ui_file *file, int from_tty,
 | ||||||
|  | +		      struct cmd_list_element *c, const char *value)
 | ||||||
|  | +{
 | ||||||
|  | +  fprintf_filtered (file, _("Debugging output for files "
 | ||||||
|  | +			    "of 'set auto-load ...' is %s.\n"),
 | ||||||
|  | +		    value);
 | ||||||
|  | +}
 | ||||||
|  | +
 | ||||||
|  |  /* User-settable option to enable/disable auto-loading of GDB_AUTO_FILE_NAME | ||||||
|  |     scripts: | ||||||
|  |     set auto-load gdb-scripts on|off | ||||||
|  | @@ -112,6 +126,11 @@ auto_load_safe_path_vec_update (void)
 | ||||||
|  |    unsigned len; | ||||||
|  |    int ix; | ||||||
|  |   | ||||||
|  | +  if (debug_auto_load)
 | ||||||
|  | +    fprintf_unfiltered (gdb_stdlog,
 | ||||||
|  | +			_("auto-load: Updating directories of \"%s\".\n"),
 | ||||||
|  | +			auto_load_safe_path);
 | ||||||
|  | +
 | ||||||
|  |    free_char_ptr_vec (auto_load_safe_path_vec); | ||||||
|  |   | ||||||
|  |    auto_load_safe_path_vec = dirnames_to_char_ptr_vec (auto_load_safe_path); | ||||||
|  | @@ -126,14 +145,34 @@ auto_load_safe_path_vec_update (void)
 | ||||||
|  |        char *real_path = gdb_realpath (expanded); | ||||||
|  |   | ||||||
|  |        /* Ensure the current entry is at least tilde_expand-ed.  */ | ||||||
|  | -      xfree (dir);
 | ||||||
|  |        VEC_replace (char_ptr, auto_load_safe_path_vec, ix, expanded); | ||||||
|  |   | ||||||
|  | +      if (debug_auto_load)
 | ||||||
|  | +	{
 | ||||||
|  | +	  if (strcmp (expanded, dir) == 0)
 | ||||||
|  | +	    fprintf_unfiltered (gdb_stdlog,
 | ||||||
|  | +				_("auto-load: Using directory \"%s\".\n"),
 | ||||||
|  | +				expanded);
 | ||||||
|  | +	  else
 | ||||||
|  | +	    fprintf_unfiltered (gdb_stdlog,
 | ||||||
|  | +				_("auto-load: Resolved directory \"%s\" "
 | ||||||
|  | +				  "as \"%s\".\n"),
 | ||||||
|  | +				dir, expanded);
 | ||||||
|  | +	}
 | ||||||
|  | +      xfree (dir);
 | ||||||
|  | +
 | ||||||
|  |        /* If gdb_realpath returns a different content, append it.  */ | ||||||
|  |        if (strcmp (real_path, expanded) == 0) | ||||||
|  |  	xfree (real_path); | ||||||
|  |        else | ||||||
|  | -	VEC_safe_push (char_ptr, auto_load_safe_path_vec, real_path);
 | ||||||
|  | +	{
 | ||||||
|  | +	  VEC_safe_push (char_ptr, auto_load_safe_path_vec, real_path);
 | ||||||
|  | +
 | ||||||
|  | +	  if (debug_auto_load)
 | ||||||
|  | +	    fprintf_unfiltered (gdb_stdlog,
 | ||||||
|  | +				_("auto-load: And canonicalized as \"%s\".\n"),
 | ||||||
|  | +				real_path);
 | ||||||
|  | +	}
 | ||||||
|  |      } | ||||||
|  |  } | ||||||
|  |   | ||||||
|  | @@ -217,16 +256,30 @@ filename_is_in_auto_load_safe_path_vec (
 | ||||||
|  |    if (dir == NULL) | ||||||
|  |      { | ||||||
|  |        if (*filename_realp == NULL) | ||||||
|  | -	*filename_realp = gdb_realpath (filename);
 | ||||||
|  | +	{
 | ||||||
|  | +	  *filename_realp = gdb_realpath (filename);
 | ||||||
|  | +	  if (debug_auto_load && strcmp (*filename_realp, filename) != 0)
 | ||||||
|  | +	    fprintf_unfiltered (gdb_stdlog,
 | ||||||
|  | +				_("auto-load: Resolved "
 | ||||||
|  | +				  "file \"%s\" as \"%s\".\n"),
 | ||||||
|  | +				filename, *filename_realp);
 | ||||||
|  | +	}
 | ||||||
|  |   | ||||||
|  | -      for (ix = 0; VEC_iterate (char_ptr, auto_load_safe_path_vec, ix, dir);
 | ||||||
|  | -	   ++ix)
 | ||||||
|  | -	if (filename_is_in_dir (*filename_realp, dir))
 | ||||||
|  | -	  break;
 | ||||||
|  | +      if (strcmp (*filename_realp, filename) != 0)
 | ||||||
|  | +	for (ix = 0; VEC_iterate (char_ptr, auto_load_safe_path_vec, ix, dir);
 | ||||||
|  | +	     ++ix)
 | ||||||
|  | +	  if (filename_is_in_dir (*filename_realp, dir))
 | ||||||
|  | +	    break;
 | ||||||
|  |      } | ||||||
|  |   | ||||||
|  |    if (dir != NULL) | ||||||
|  | -    return 1;
 | ||||||
|  | +    {
 | ||||||
|  | +      if (debug_auto_load)
 | ||||||
|  | +	fprintf_unfiltered (gdb_stdlog, _("auto-load: File \"%s\" matches "
 | ||||||
|  | +					  "directory \"%s\".\n"),
 | ||||||
|  | +			    filename, dir);
 | ||||||
|  | +      return 1;
 | ||||||
|  | +    }
 | ||||||
|  |   | ||||||
|  |    return 0; | ||||||
|  |  } | ||||||
|  | @@ -240,11 +293,20 @@ filename_is_in_auto_load_safe_path_vec (
 | ||||||
|  |     directory.  */ | ||||||
|  |   | ||||||
|  |  int | ||||||
|  | -file_is_auto_load_safe (const char *filename)
 | ||||||
|  | +file_is_auto_load_safe (const char *filename, const char *debug_fmt, ...)
 | ||||||
|  |  { | ||||||
|  |    char *filename_real = NULL; | ||||||
|  |    struct cleanup *back_to; | ||||||
|  |   | ||||||
|  | +  if (debug_auto_load)
 | ||||||
|  | +    {
 | ||||||
|  | +      va_list debug_args;
 | ||||||
|  | +
 | ||||||
|  | +      va_start (debug_args, debug_fmt);
 | ||||||
|  | +      vfprintf_unfiltered (gdb_stdlog, debug_fmt, debug_args);
 | ||||||
|  | +      va_end (debug_args);
 | ||||||
|  | +    }
 | ||||||
|  | +
 | ||||||
|  |    back_to = make_cleanup (free_current_contents, &filename_real); | ||||||
|  |   | ||||||
|  |    if (filename_is_in_auto_load_safe_path_vec (filename, &filename_real)) | ||||||
|  | @@ -281,7 +343,10 @@ source_gdb_script_for_objfile (struct ob
 | ||||||
|  |    struct auto_load_pspace_info *pspace_info; | ||||||
|  |    volatile struct gdb_exception e; | ||||||
|  |   | ||||||
|  | -  is_safe = file_is_auto_load_safe (filename);
 | ||||||
|  | +  is_safe = file_is_auto_load_safe (filename, _("auto-load: Loading canned "
 | ||||||
|  | +						"sequences of commands script "
 | ||||||
|  | +						"\"%s\" for objfile \"%s\".\n"),
 | ||||||
|  | +				    filename, objfile->name);
 | ||||||
|  |   | ||||||
|  |    /* Add this script to the hash table too so "info auto-load gdb-scripts" | ||||||
|  |       can print it.  */ | ||||||
|  | @@ -975,4 +1040,13 @@ See the commands 'set auto-load safe-pat
 | ||||||
|  |  access the current full list setting."), | ||||||
|  |  		 &cmdlist); | ||||||
|  |    set_cmd_completer (cmd, filename_completer); | ||||||
|  | +
 | ||||||
|  | +  add_setshow_boolean_cmd ("auto-load", class_maintenance,
 | ||||||
|  | +			   &debug_auto_load, _("\
 | ||||||
|  | +Set auto-load verifications debugging."), _("\
 | ||||||
|  | +Show auto-load verifications debugging."), _("\
 | ||||||
|  | +When non-zero, debugging output for files of 'set auto-load ...'\n\
 | ||||||
|  | +is displayed."),
 | ||||||
|  | +			    NULL, show_debug_auto_load,
 | ||||||
|  | +			    &setdebuglist, &showdebuglist);
 | ||||||
|  |  } | ||||||
|  | Index: gdb-7.4.50.20120120/gdb/auto-load.h
 | ||||||
|  | ===================================================================
 | ||||||
|  | --- gdb-7.4.50.20120120.orig/gdb/auto-load.h	2012-04-18 00:49:21.000000000 +0200
 | ||||||
|  | +++ gdb-7.4.50.20120120/gdb/auto-load.h	2012-04-18 00:50:04.801626235 +0200
 | ||||||
|  | @@ -55,6 +55,7 @@ extern struct cmd_list_element **auto_lo
 | ||||||
|  |  extern struct cmd_list_element **auto_load_show_cmdlist_get (void); | ||||||
|  |  extern struct cmd_list_element **auto_load_info_cmdlist_get (void); | ||||||
|  |   | ||||||
|  | -extern int file_is_auto_load_safe (const char *filename);
 | ||||||
|  | +extern int file_is_auto_load_safe (const char *filename,
 | ||||||
|  | +				   const char *debug_fmt, ...);
 | ||||||
|  |   | ||||||
|  |  #endif /* AUTO_LOAD_H */ | ||||||
|  | Index: gdb-7.4.50.20120120/gdb/linux-thread-db.c
 | ||||||
|  | ===================================================================
 | ||||||
|  | --- gdb-7.4.50.20120120.orig/gdb/linux-thread-db.c	2012-04-18 00:49:21.000000000 +0200
 | ||||||
|  | +++ gdb-7.4.50.20120120/gdb/linux-thread-db.c	2012-04-18 00:50:04.801626235 +0200
 | ||||||
|  | @@ -869,7 +869,9 @@ try_thread_db_load_from_pdir_1 (struct o
 | ||||||
|  |    gdb_assert (cp != NULL); | ||||||
|  |    strcpy (cp + 1, LIBTHREAD_DB_SO); | ||||||
|  |   | ||||||
|  | -  if (!file_is_auto_load_safe (path))
 | ||||||
|  | +  if (!file_is_auto_load_safe (path, _("auto-load: Loading libthread-db "
 | ||||||
|  | +				       "library \"%s\" from $pdir.\n"),
 | ||||||
|  | +			       path))
 | ||||||
|  |      result = 0; | ||||||
|  |    else | ||||||
|  |      result = try_thread_db_load (path); | ||||||
|  | @@ -939,7 +941,10 @@ try_thread_db_load_from_dir (const char
 | ||||||
|  |    path[dir_len] = '/'; | ||||||
|  |    strcpy (path + dir_len + 1, LIBTHREAD_DB_SO); | ||||||
|  |   | ||||||
|  | -  if (!file_is_auto_load_safe (path))
 | ||||||
|  | +  if (!file_is_auto_load_safe (path, _("auto-load: Loading libthread-db "
 | ||||||
|  | +				       "library \"%s\" from explicit "
 | ||||||
|  | +				       "directory.\n"),
 | ||||||
|  | +			       path))
 | ||||||
|  |      result = 0; | ||||||
|  |    else | ||||||
|  |      result = try_thread_db_load (path); | ||||||
|  | Index: gdb-7.4.50.20120120/gdb/main.c
 | ||||||
|  | ===================================================================
 | ||||||
|  | --- gdb-7.4.50.20120120.orig/gdb/main.c	2012-04-18 00:49:21.000000000 +0200
 | ||||||
|  | +++ gdb-7.4.50.20120120/gdb/main.c	2012-04-18 00:50:04.801626235 +0200
 | ||||||
|  | @@ -1027,7 +1027,10 @@ captured_main (void *data)
 | ||||||
|  |        auto_load_local_gdbinit_pathname = gdb_realpath (local_gdbinit); | ||||||
|  |   | ||||||
|  |        if (!inhibit_gdbinit && auto_load_local_gdbinit | ||||||
|  | -	  && file_is_auto_load_safe (local_gdbinit))
 | ||||||
|  | +	  && file_is_auto_load_safe (local_gdbinit,
 | ||||||
|  | +				     _("auto-load: Loading .gdbinit "
 | ||||||
|  | +				       "file \"%s\".\n"),
 | ||||||
|  | +				     local_gdbinit))
 | ||||||
|  |  	{ | ||||||
|  |  	  auto_load_local_gdbinit_loaded = 1; | ||||||
|  |   | ||||||
|  | Index: gdb-7.4.50.20120120/gdb/doc/gdb.texinfo
 | ||||||
|  | ===================================================================
 | ||||||
|  | --- gdb-7.4.50.20120120.orig/gdb/doc/gdb.texinfo	2012-04-18 00:49:21.000000000 +0200
 | ||||||
|  | +++ gdb-7.4.50.20120120/gdb/doc/gdb.texinfo	2012-04-18 00:50:04.809626215 +0200
 | ||||||
|  | @@ -20887,6 +20887,7 @@ These are @value{GDBN} control commands
 | ||||||
|  |  * libthread_db.so.1 file::             @samp{set/show/info auto-load libthread-db} | ||||||
|  |  * objfile-gdb.gdb file::               @samp{set/show/info auto-load gdb-script} | ||||||
|  |  * Auto-loading safe path::             @samp{set/show/info auto-load safe-path} | ||||||
|  | +* Auto-loading verbose mode::          @samp{set/show debug auto-load}
 | ||||||
|  |  @xref{Python Auto-loading}. | ||||||
|  |  @end menu | ||||||
|  |   | ||||||
|  | @@ -21085,6 +21086,45 @@ entries again.  @value{GDBN} already can
 | ||||||
|  |  own before starting the comparison so a canonical form of directories is | ||||||
|  |  recommended to be entered. | ||||||
|  |   | ||||||
|  | +@node Auto-loading verbose mode
 | ||||||
|  | +@subsection Displaying files tried for auto-load
 | ||||||
|  | +@cindex auto-loading verbose mode
 | ||||||
|  | +
 | ||||||
|  | +For better visibility of all the file locations where you can place scripts to
 | ||||||
|  | +be auto-loaded with inferior --- or to protect yourself against accidental
 | ||||||
|  | +execution of untrusted scripts --- @value{GDBN} provides a feature for printing
 | ||||||
|  | +all the files attempted to be loaded.  Both existing and non-existing files may
 | ||||||
|  | +be printed.
 | ||||||
|  | +
 | ||||||
|  | +For example the list of directories from which it is safe to auto-load files
 | ||||||
|  | +(@pxref{Auto-loading safe path}) applies also to canonicalized filenames which
 | ||||||
|  | +may not be too obvious while setting it up.
 | ||||||
|  | +
 | ||||||
|  | +@smallexample
 | ||||||
|  | +(gdb) set debug auto-load ues
 | ||||||
|  | +(gdb) file ~/src/t/true
 | ||||||
|  | +auto-load: Loading canned sequences of commands script "/tmp/true-gdb.gdb"
 | ||||||
|  | +           for objfile "/tmp/true".
 | ||||||
|  | +auto-load: Updating directories of "/usr:/opt".
 | ||||||
|  | +auto-load: Using directory "/usr".
 | ||||||
|  | +auto-load: Using directory "/opt".
 | ||||||
|  | +warning: File "/tmp/true-gdb.gdb" auto-loading has been declined
 | ||||||
|  | +         by your `auto-load safe-path' set to "/usr:/opt".
 | ||||||
|  | +@end smallexample
 | ||||||
|  | +
 | ||||||
|  | +@table @code
 | ||||||
|  | +@anchor{set debug auto-load}
 | ||||||
|  | +@kindex set debug auto-load
 | ||||||
|  | +@item set debug auto-load [on|off]
 | ||||||
|  | +Set whether to print the filenames attempted to be auto-loaded.
 | ||||||
|  | +
 | ||||||
|  | +@anchor{show debug auto-load}
 | ||||||
|  | +@kindex show debug auto-load
 | ||||||
|  | +@item show debug auto-load
 | ||||||
|  | +Show whether printing of the filenames attempted to be auto-loaded is turned
 | ||||||
|  | +on or off.
 | ||||||
|  | +@end table
 | ||||||
|  | +
 | ||||||
|  |  @node Messages/Warnings | ||||||
|  |  @section Optional Warnings and Messages | ||||||
|  |   | ||||||
|  | Index: gdb-7.4.50.20120120/gdb/python/py-auto-load.c
 | ||||||
|  | ===================================================================
 | ||||||
|  | --- gdb-7.4.50.20120120.orig/gdb/python/py-auto-load.c	2012-04-18 00:49:21.000000000 +0200
 | ||||||
|  | +++ gdb-7.4.50.20120120/gdb/python/py-auto-load.c	2012-04-18 00:50:04.810626212 +0200
 | ||||||
|  | @@ -75,7 +75,10 @@ gdbpy_load_auto_script_for_objfile (stru
 | ||||||
|  |    int is_safe; | ||||||
|  |    struct auto_load_pspace_info *pspace_info; | ||||||
|  |   | ||||||
|  | -  is_safe = file_is_auto_load_safe (filename);
 | ||||||
|  | +  is_safe = file_is_auto_load_safe (filename,
 | ||||||
|  | +				    _("auto-load: Loading Python script \"%s\" "
 | ||||||
|  | +				      "by extension for objfile \"%s\".\n"),
 | ||||||
|  | +				    filename, objfile->name);
 | ||||||
|  |   | ||||||
|  |    /* Add this script to the hash table too so "info auto-load python-scripts" | ||||||
|  |       can print it.  */ | ||||||
|  | @@ -153,7 +156,12 @@ source_section_scripts (struct objfile *
 | ||||||
|  |  	  make_cleanup_fclose (stream); | ||||||
|  |  	  make_cleanup (xfree, full_path); | ||||||
|  |   | ||||||
|  | -	  if (!file_is_auto_load_safe (full_path))
 | ||||||
|  | +	  if (!file_is_auto_load_safe (full_path,
 | ||||||
|  | +				       _("auto-load: Loading Python script "
 | ||||||
|  | +					 "\"%s\" from section \"%s\" of "
 | ||||||
|  | +					 "objfile \"%s\".\n"),
 | ||||||
|  | +				       full_path, GDBPY_AUTO_SECTION_NAME,
 | ||||||
|  | +				       objfile->name))
 | ||||||
|  |  	    opened = 0; | ||||||
|  |  	} | ||||||
|  |        else | ||||||
							
								
								
									
										42
									
								
								gdb.spec
									
									
									
									
									
								
							
							
						
						
									
										42
									
								
								gdb.spec
									
									
									
									
									
								
							| @ -33,7 +33,7 @@ Version: 7.4.50.%{snap} | |||||||
| 
 | 
 | ||||||
| # The release always contains a leading reserved number, start it at 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. | # `upstream' is not a part of `name' to stay fully rpm dependencies compatible for the testing. | ||||||
| Release: 39%{?dist} | Release: 40%{?dist} | ||||||
| 
 | 
 | ||||||
| License: GPLv3+ and GPLv3+ with exceptions and GPLv2+ and GPLv2+ with exceptions and GPL+ and LGPLv2+ and BSD and Public Domain | License: GPLv3+ and GPLv3+ with exceptions and GPLv2+ and GPLv2+ with exceptions and GPL+ and LGPLv2+ and BSD and Public Domain | ||||||
| Group: Development/Debuggers | Group: Development/Debuggers | ||||||
| @ -174,10 +174,6 @@ Patch145: gdb-6.3-threaded-watchpoints2-20050225.patch | |||||||
| #=ia64 | #=ia64 | ||||||
| Patch153: gdb-6.3-ia64-gcore-page0-20050421.patch | 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 sigtramp prev register patch | ||||||
| #=ia64 | #=ia64 | ||||||
| Patch158: gdb-6.3-ia64-sigtramp-frame-20050708.patch | Patch158: gdb-6.3-ia64-sigtramp-frame-20050708.patch | ||||||
| @ -569,19 +565,38 @@ Patch653: gdb-attach-fail-reasons-5of5.patch | |||||||
| Patch657: gdb-attach-fail-reasons-5of5configure.patch | Patch657: gdb-attach-fail-reasons-5of5configure.patch | ||||||
| 
 | 
 | ||||||
| # Fix inferior calls, particularly uncaught thrown exceptions (BZ 799531). | # Fix inferior calls, particularly uncaught thrown exceptions (BZ 799531). | ||||||
|  | #=push+work | ||||||
| Patch654: gdb-x86-onstack-1of2.patch | Patch654: gdb-x86-onstack-1of2.patch | ||||||
| Patch658: gdb-x86-onstack-2of2.patch | Patch658: gdb-x86-onstack-2of2.patch | ||||||
| 
 | 
 | ||||||
| # Fix DWARF DIEs CU vs. section relative offsets (Joel Brobecker, me). | # Fix DWARF DIEs CU vs. section relative offsets (Joel Brobecker, me). | ||||||
|  | #=push | ||||||
| Patch655: gdb-die-cu-offset-1of2.patch | Patch655: gdb-die-cu-offset-1of2.patch | ||||||
| Patch656: gdb-die-cu-offset-2of2.patch | Patch656: gdb-die-cu-offset-2of2.patch | ||||||
| 
 | 
 | ||||||
| # [vla] Fix regression on no type for subrange from IBM XLF Fortran (BZ 806920). | # [vla] Fix regression on no type for subrange from IBM XLF Fortran (BZ 806920). | ||||||
|  | #=push | ||||||
| Patch660: gdb-subrange-no-type.patch | Patch660: gdb-subrange-no-type.patch | ||||||
| 
 | 
 | ||||||
| # Workaround crashes from stale frame_info pointer (BZ 804256). | # Workaround crashes from stale frame_info pointer (BZ 804256). | ||||||
|  | #=push+work | ||||||
| Patch661: gdb-stale-frame_info.patch | Patch661: gdb-stale-frame_info.patch | ||||||
| 
 | 
 | ||||||
|  | # Security fix for loading untrusted inferiors, see "set auto-load" (BZ 756117). | ||||||
|  | #=push | ||||||
|  | Patch662: gdb-autoload-01of12.patch | ||||||
|  | Patch663: gdb-autoload-02of12.patch | ||||||
|  | Patch664: gdb-autoload-03of12.patch | ||||||
|  | Patch665: gdb-autoload-04of12.patch | ||||||
|  | Patch666: gdb-autoload-05of12.patch | ||||||
|  | Patch667: gdb-autoload-06of12.patch | ||||||
|  | Patch668: gdb-autoload-07of12.patch | ||||||
|  | Patch669: gdb-autoload-08of12.patch | ||||||
|  | Patch670: gdb-autoload-09of12.patch | ||||||
|  | Patch671: gdb-autoload-10of12.patch | ||||||
|  | Patch672: gdb-autoload-11of12.patch | ||||||
|  | Patch673: gdb-autoload-12of12.patch | ||||||
|  | 
 | ||||||
| %if 0%{!?rhel:1} || 0%{?rhel} > 6 | %if 0%{!?rhel:1} || 0%{?rhel} > 6 | ||||||
| # RL_STATE_FEDORA_GDB would not be found for: | # RL_STATE_FEDORA_GDB would not be found for: | ||||||
| # Patch642: gdb-readline62-ask-more-rh.patch | # Patch642: gdb-readline62-ask-more-rh.patch | ||||||
| @ -768,7 +783,6 @@ rm -f gdb/jv-exp.c gdb/m2-exp.c gdb/objc-exp.c gdb/p-exp.c | |||||||
| %patch140 -p1 | %patch140 -p1 | ||||||
| %patch145 -p1 | %patch145 -p1 | ||||||
| %patch153 -p1 | %patch153 -p1 | ||||||
| %patch157 -p1 |  | ||||||
| %patch158 -p1 | %patch158 -p1 | ||||||
| %patch160 -p1 | %patch160 -p1 | ||||||
| %patch161 -p1 | %patch161 -p1 | ||||||
| @ -873,6 +887,18 @@ rm -f gdb/jv-exp.c gdb/m2-exp.c gdb/objc-exp.c gdb/p-exp.c | |||||||
| %patch656 -p1 | %patch656 -p1 | ||||||
| %patch660 -p1 | %patch660 -p1 | ||||||
| %patch661 -p1 | %patch661 -p1 | ||||||
|  | %patch662 -p1 | ||||||
|  | %patch663 -p1 | ||||||
|  | %patch664 -p1 | ||||||
|  | %patch665 -p1 | ||||||
|  | %patch666 -p1 | ||||||
|  | %patch667 -p1 | ||||||
|  | %patch668 -p1 | ||||||
|  | %patch669 -p1 | ||||||
|  | %patch670 -p1 | ||||||
|  | %patch671 -p1 | ||||||
|  | %patch672 -p1 | ||||||
|  | %patch673 -p1 | ||||||
| 
 | 
 | ||||||
| %patch393 -p1 | %patch393 -p1 | ||||||
| %if 0%{!?el5:1} || 0%{?scl:1} | %if 0%{!?el5:1} || 0%{?scl:1} | ||||||
| @ -992,6 +1018,7 @@ $(: RHEL-5 librpm has incompatible API. )			\ | |||||||
| %else # !%{have_inproctrace} | %else # !%{have_inproctrace} | ||||||
| 	--disable-inprocess-agent				\ | 	--disable-inprocess-agent				\ | ||||||
| %endif # !%{have_inproctrace} | %endif # !%{have_inproctrace} | ||||||
|  | 	--with-auto-load-safe-path=%{_prefix}			\ | ||||||
| %ifarch sparc sparcv9 | %ifarch sparc sparcv9 | ||||||
| 	sparc-%{_vendor}-%{_target_os}%{?_gnu} | 	sparc-%{_vendor}-%{_target_os}%{?_gnu} | ||||||
| %else | %else | ||||||
| @ -1352,6 +1379,9 @@ fi | |||||||
| %endif # 0%{!?el5:1} || "%{_target_cpu}" == "noarch" | %endif # 0%{!?el5:1} || "%{_target_cpu}" == "noarch" | ||||||
| 
 | 
 | ||||||
| %changelog | %changelog | ||||||
|  | * Wed Apr 18 2012 Jan Kratochvil <jan.kratochvil@redhat.com> - 7.4.50.20120120-40.fc17 | ||||||
|  | - Security fix for loading untrusted inferiors, see "set auto-load" (BZ 756117). | ||||||
|  | 
 | ||||||
| * Fri Apr 13 2012 Jan Kratochvil <jan.kratochvil@redhat.com> - 7.4.50.20120120-39.fc17 | * Fri Apr 13 2012 Jan Kratochvil <jan.kratochvil@redhat.com> - 7.4.50.20120120-39.fc17 | ||||||
| - [RHEL7] Fix/remove readline-devel BuildRequires redundant distro suffic .fc17. | - [RHEL7] Fix/remove readline-devel BuildRequires redundant distro suffic .fc17. | ||||||
| 
 | 
 | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user