- Fix the testsuite run for ia64 (where no -m64 is present).

- Test a crash on libraries missing the .text section.
- Protect development in the build tree by automatic Makefile dependencies.
- Refuse creating watchpoints of an address value, suggested by Martin
    Stransky.
- Disable randomization (such as by setarch -R), suggested by Jakub
    Jelinek.
- Fix compatibility with recent glibc headers.
This commit is contained in:
Jan Kratochvil 2008-06-17 16:24:16 +00:00
parent 2234aa8fd6
commit dd1aa7b0b3
6 changed files with 811 additions and 3 deletions

View File

@ -0,0 +1,111 @@
diff -up -ruNp gdb-6.5-orig/gdb/testsuite/gdb.base/datalib-lib.c gdb-6.5/gdb/testsuite/gdb.base/datalib-lib.c
--- gdb-6.5-orig/gdb/testsuite/gdb.base/datalib-lib.c 1969-12-31 19:00:00.000000000 -0500
+++ gdb-6.5/gdb/testsuite/gdb.base/datalib-lib.c 2008-05-29 13:51:50.000000000 -0400
@@ -0,0 +1,22 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+ Copyright 2008 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 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 */
+
+int var;
diff -up -ruNp gdb-6.5-orig/gdb/testsuite/gdb.base/datalib-main.c gdb-6.5/gdb/testsuite/gdb.base/datalib-main.c
--- gdb-6.5-orig/gdb/testsuite/gdb.base/datalib-main.c 1969-12-31 19:00:00.000000000 -0500
+++ gdb-6.5/gdb/testsuite/gdb.base/datalib-main.c 2008-05-29 13:51:39.000000000 -0400
@@ -0,0 +1,26 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+ Copyright 2008 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 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 */
+
+int
+main (void)
+{
+ return 0;
+}
diff -up -ruNp gdb-6.5-orig/gdb/testsuite/gdb.base/datalib.exp gdb-6.5/gdb/testsuite/gdb.base/datalib.exp
--- gdb-6.5-orig/gdb/testsuite/gdb.base/datalib.exp 1969-12-31 19:00:00.000000000 -0500
+++ gdb-6.5/gdb/testsuite/gdb.base/datalib.exp 2008-05-29 14:58:33.000000000 -0400
@@ -0,0 +1,51 @@
+# Copyright 2008 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+set testfile datalib
+set srcfilemain ${testfile}-main.c
+set srcfilelib ${testfile}-lib.c
+set libfile ${objdir}/${subdir}/${testfile}-lib.so
+set binfile ${objdir}/${subdir}/${testfile}-main
+if { [gdb_compile "${srcdir}/${subdir}/${srcfilelib}" "${libfile}" executable [list debug {additional_flags=-shared -nostdlib}]] != "" } {
+ untested "Couldn't compile test program"
+ return -1
+}
+if { [gdb_compile "${srcdir}/${subdir}/${srcfilemain}" "${binfile} ${libfile}" executable {debug}] != "" } {
+ untested "Couldn't compile test program"
+ return -1
+}
+
+# Get things started.
+
+gdb_exit
+gdb_start
+gdb_reinitialize_dir $srcdir/$subdir
+gdb_load ${binfile}
+
+# We must use a separate library as the main executable is compiled to the
+# address 0 by default and it would get fixed up already at the end of
+# INIT_OBJFILE_SECT_INDICES. We also cannot PRELINK it as PRELINK is missing
+# on ia64. The library must be NOSTDLIB as otherwise some stub code would
+# create the `.text' section there. Also DEBUG option is useful as some of
+# the crashes occur in dwarf2read.c.
+
+# FAIL case:
+# ../../gdb/ia64-tdep.c:2838: internal-error: sect_index_text not initialized
+# A problem internal to GDB has been detected,
+
+gdb_test "start" \
+ "main \\(\\) at .*${srcfilemain}.*" \
+ "start"

View File

@ -0,0 +1,26 @@
--- gdb-6.8/gdb/Makefile.in-orig 2008-06-17 15:16:20.000000000 +0200
+++ gdb-6.8/gdb/Makefile.in 2008-06-17 15:17:01.000000000 +0200
@@ -1100,16 +1100,22 @@ YYOBJ = c-exp.o \
DISTSTUFF = $(YYFILES)
+DEPDIR = .deps
+
# Prevent Sun make from putting in the machine type. Setting
# TARGET_ARCH to nothing works for SunOS 3, 4.0, but not for 4.1.
.c.o:
- $(CC) -c $(INTERNAL_CFLAGS) $<
+ @mkdir -p $(DEPDIR)
+ $(CC) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c $(INTERNAL_CFLAGS) $<
+ @mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
all: gdb$(EXEEXT) $(CONFIG_ALL)
@$(MAKE) $(FLAGS_TO_PASS) DO=all "DODIRS=`echo $(SUBDIRS) | sed 's/testsuite//'`" subdir_do
.PHONY: all-tui
all-tui: $(TUI)$(EXEEXT)
+-include $(DEPDIR)/*.Po
+
installcheck:
# The check target can not use subdir_do, because subdir_do does not

View File

@ -0,0 +1,96 @@
2008-06-09 Jan Kratochvil <jan.kratochvil@redhat.com>
* breakpoint.c (watch_command_1): New variable VAL_RESULT. Fill in
VAL_RESULT by the existing FETCH_WATCHPOINT_VALUE call. Refuse
constant VAL_RESULT list watchpoints.
2008-06-09 Jan Kratochvil <jan.kratochvil@redhat.com>
* gdb.texinfo (Set Watchpoints): Document constant value watchpoints.
2008-06-09 Jan Kratochvil <jan.kratochvil@redhat.com>
* gdb.base/watchpoint.exp: New test for constant value watchpoints.
[ Ported for Fedora GDB. ]
--- ./gdb/breakpoint.c 6 Jun 2008 20:58:08 -0000 1.324
+++ ./gdb/breakpoint.c 9 Jun 2008 06:00:53 -0000
@@ -5818,7 +5818,7 @@ watch_command_1 (char *arg, int accessfl
struct symtab_and_line sal;
struct expression *exp;
struct block *exp_valid_block;
- struct value *val, *mark;
+ struct value *val, *mark, *val_result;
struct frame_info *frame;
struct frame_info *prev_frame = NULL;
char *exp_start = NULL;
@@ -5903,7 +5903,27 @@ watch_command_1 (char *arg, int accessfl
exp_end = arg;
exp_valid_block = innermost_block;
mark = value_mark ();
- fetch_watchpoint_value (exp, &val, NULL, NULL);
+ fetch_watchpoint_value (exp, &val, &val_result, NULL);
+
+ /* VAL may be unset for unreachable final values. */
+ while (val_result != NULL)
+ {
+ if (VALUE_LVAL (val_result) == lval_memory
+ || VALUE_LVAL (val_result) == lval_register)
+ break;
+ val_result = value_next (val_result);
+ }
+ if (val_result == NULL)
+ {
+ int len;
+
+ len = exp_end - exp_start;
+ while (len > 0 && isspace (exp_start[len - 1]))
+ len--;
+ error (_("Cannot watch constant value %.*s."), len, exp_start);
+ }
+
+ /* Break the VAL_RESULT values chain only after its check above. */
if (val != NULL)
release_value (val);
--- ./gdb/doc/gdb.texinfo 6 Jun 2008 20:58:08 -0000 1.503
+++ ./gdb/doc/gdb.texinfo 9 Jun 2008 06:01:37 -0000
@@ -3375,6 +3375,17 @@ This command prints a list of watchpoint
it is the same as @code{info break} (@pxref{Set Breaks}).
@end table
+If you watch for a change in a numerically entered address you need to
+dereference it as the address itself is just a constant number which will never
+change. @value{GDBN} refuses to create a never invokable watchpoint:
+
+@smallexample
+(@value{GDBP}) watch 0x600850
+Cannot watch constant value 0x600850.
+(@value{GDBP}) watch *(int *) 0x600850
+Watchpoint 1: *(int *) 6293584
+@end smallexample
+
@value{GDBN} sets a @dfn{hardware watchpoint} if possible. Hardware
watchpoints execute very quickly, and the debugger reports a change in
value at the exact instruction where the change occurs. If @value{GDBN}
--- gdb-6.8/gdb/testsuite/gdb.base/watchpoint.exp.orig 2008-06-17 13:42:35.000000000 +0200
+++ gdb-6.8/gdb/testsuite/gdb.base/watchpoint.exp 2008-06-17 13:43:38.000000000 +0200
@@ -679,6 +679,17 @@ set prev_timeout $timeout
set timeout 600
verbose "Timeout now 600 sec.\n"
+# Test constant-value watchpoints.
+gdb_test "watch 123" "Cannot watch constant value 123." "constant watchpoint"
+gdb_test "watch 456 if 1 == 2" "Cannot watch constant value 456." \
+ "constant watchpoint with a condition"
+# For unsupported constant-value watchpoints catching we need to reset the
+# breakpoints counter.
+gdb_exit
+gdb_start
+gdb_reinitialize_dir $srcdir/$subdir
+gdb_load $binfile
+
gdb_test "set debug solib 1"
if [initialize] then {

View File

@ -0,0 +1,530 @@
2008-06-08 Jan Kratochvil <jan.kratochvil@redhat.com>
* configure.ac: Add check for HAVE_PERSONALITY and
HAVE_DECL_ADDR_NO_RANDOMIZE.
* configure, config.in: Regenerate.
* fork-child.c: New include <errno.h>.
[HAVE_PERSONALITY]: New include <sys/personality.h>.
[HAVE_PERSONALITY] (set_disable_randomization): New function.
(disable_randomization, show_disable_randomization): New.
(fork_inferior) [HAVE_PERSONALITY] [!HAVE_DECL_ADDR_NO_RANDOMIZE]: Set
ADDR_NO_RANDOMIZE.
(fork_inferior) [HAVE_PERSONALITY]: Disable randomization upon the
variable DISABLE_RANDOMIZATION.
(_initialize_fork_child): Call ADD_SETSHOW_BOOLEAN_CMD for the variable
DISABLE_RANDOMIZATION.
2008-06-08 Jan Kratochvil <jan.kratochvil@redhat.com>
* gdb.texinfo (Starting): Document "set disable-randomization".
2008-06-08 Jan Kratochvil <jan.kratochvil@redhat.com>
* gdb.base/randomize.exp, gdb.base/randomize.c: New files.
[ Ported for Fedora GDB. ]
--- ./gdb/config.in 5 Jun 2008 22:36:56 -0000 1.100
+++ ./gdb/config.in 8 Jun 2008 11:27:20 -0000
@@ -82,6 +82,10 @@
/* Define to 1 if you have the <curses.h> header file. */
#undef HAVE_CURSES_H
+/* Define to 1 if you have the declaration of `ADDR_NO_RANDOMIZE', and to 0 if
+ you don't. */
+#undef HAVE_DECL_ADDR_NO_RANDOMIZE
+
/* Define to 1 if you have the declaration of `free', and to 0 if you don't.
*/
#undef HAVE_DECL_FREE
@@ -237,6 +241,9 @@
/* Define to 1 if you have the <nlist.h> header file. */
#undef HAVE_NLIST_H
+/* Define if you support the personality syscall. */
+#undef HAVE_PERSONALITY
+
/* Define to 1 if you have the `poll' function. */
#undef HAVE_POLL
--- ./gdb/configure 5 Jun 2008 22:36:56 -0000 1.249
+++ ./gdb/configure 8 Jun 2008 11:27:41 -0000
@@ -26701,6 +26701,188 @@ _ACEOF
fi
+echo "$as_me:$LINENO: checking whether ADDR_NO_RANDOMIZE is declared" >&5
+echo $ECHO_N "checking whether ADDR_NO_RANDOMIZE is declared... $ECHO_C" >&6
+if test "${ac_cv_have_decl_ADDR_NO_RANDOMIZE+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#include <sys/personality.h>
+
+int
+main ()
+{
+#ifndef ADDR_NO_RANDOMIZE
+ char *p = (char *) ADDR_NO_RANDOMIZE;
+#endif
+
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest.$ac_objext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_cv_have_decl_ADDR_NO_RANDOMIZE=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_have_decl_ADDR_NO_RANDOMIZE=no
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+echo "$as_me:$LINENO: result: $ac_cv_have_decl_ADDR_NO_RANDOMIZE" >&5
+echo "${ECHO_T}$ac_cv_have_decl_ADDR_NO_RANDOMIZE" >&6
+if test $ac_cv_have_decl_ADDR_NO_RANDOMIZE = yes; then
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_ADDR_NO_RANDOMIZE 1
+_ACEOF
+
+
+else
+ cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_ADDR_NO_RANDOMIZE 0
+_ACEOF
+
+
+fi
+
+
+
+if test "$cross_compiling" = yes; then
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#include <sys/personality.h>
+int
+main ()
+{
+
+# if !HAVE_DECL_ADDR_NO_RANDOMIZE
+# define ADDR_NO_RANDOMIZE 0x0040000
+# endif
+ /* Test the flag could be set and stays set. */
+ personality (personality (0xffffffff) | ADDR_NO_RANDOMIZE);
+ if (!(personality (personality (0xffffffff)) & ADDR_NO_RANDOMIZE))
+ return 1
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+ (eval $ac_link) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest$ac_exeext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ have_personality=true
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+have_personality=false
+fi
+rm -f conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#include <sys/personality.h>
+int
+main ()
+{
+
+# if !HAVE_DECL_ADDR_NO_RANDOMIZE
+# define ADDR_NO_RANDOMIZE 0x0040000
+# endif
+ /* Test the flag could be set and stays set. */
+ personality (personality (0xffffffff) | ADDR_NO_RANDOMIZE);
+ if (!(personality (personality (0xffffffff)) & ADDR_NO_RANDOMIZE))
+ return 1
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+ (eval $ac_link) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ have_personality=true
+else
+ echo "$as_me: program exited with status $ac_status" >&5
+echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+( exit $ac_status )
+have_personality=false
+fi
+rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
+fi
+if $have_personality
+then
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_PERSONALITY 1
+_ACEOF
+
+fi
+
# Check whether --with-sysroot or --without-sysroot was given.
--- ./gdb/configure.ac 5 Jun 2008 22:36:56 -0000 1.69
+++ ./gdb/configure.ac 8 Jun 2008 11:27:44 -0000
@@ -1266,6 +1266,29 @@ if test "x$gdb_cv_sys_syscall_h_has_tkil
AC_DEFINE(HAVE_TKILL_SYSCALL, 1, [Define if you support the tkill syscall.])
fi
+dnl Check if we can disable the virtual address space randomization.
+dnl The functionality of setarch -R.
+AC_CHECK_DECLS([ADDR_NO_RANDOMIZE],,, [#include <sys/personality.h>])
+define([PERSONALITY_TEST], [AC_LANG_PROGRAM([#include <sys/personality.h>], [
+# if !HAVE_DECL_ADDR_NO_RANDOMIZE
+# define ADDR_NO_RANDOMIZE 0x0040000
+# endif
+ /* Test the flag could be set and stays set. */
+ personality (personality (0xffffffff) | ADDR_NO_RANDOMIZE);
+ if (!(personality (personality (0xffffffff)) & ADDR_NO_RANDOMIZE))
+ return 1])])
+AC_RUN_IFELSE([PERSONALITY_TEST],
+ [have_personality=true],
+ [have_personality=false],
+ [AC_LINK_IFELSE([PERSONALITY_TEST],
+ [have_personality=true],
+ [have_personality=false])])
+if $have_personality
+then
+ AC_DEFINE([HAVE_PERSONALITY], 1,
+ [Define if you support the personality syscall.])
+fi
+
dnl Handle optional features that can be enabled.
AC_ARG_WITH(sysroot,
--- gdb-6.8/gdb/fork-child.c.orig 2008-01-29 22:11:24.000000000 +0100
+++ gdb-6.8/gdb/fork-child.c 2008-06-17 15:15:07.000000000 +0200
@@ -32,12 +32,45 @@
#include "gdbthread.h"
#include "command.h" /* for dont_repeat () */
#include "solib.h"
+#include "gdbcmd.h"
#include <signal.h>
+#include <errno.h>
+#ifdef HAVE_PERSONALITY
+# include <sys/personality.h>
+#endif
/* This just gets used as a default if we can't find SHELL. */
#define SHELL_FILE "/bin/sh"
+static int disable_randomization =
+#ifdef HAVE_PERSONALITY
+ 1;
+#else
+ 0;
+#endif
+
+#ifndef HAVE_PERSONALITY
+static void
+set_disable_randomization (char *args, int from_tty, struct cmd_list_element *c)
+{
+ if (disable_randomization)
+ {
+ disable_randomization = 0;
+ error (_("Unsupported on this platform."));
+ }
+}
+#endif
+
+static void
+show_disable_randomization (struct ui_file *file, int from_tty,
+ struct cmd_list_element *c, const char *value)
+{
+ fprintf_filtered (file, _("\
+Disabling randomization of debuggee's virtual address space is %s.\n"),
+ value);
+}
+
extern char **environ;
/* Break up SCRATCH into an argument vector suitable for passing to
@@ -289,6 +322,24 @@ fork_inferior (char *exec_file_arg, char
if (debug_fork)
sleep (debug_fork);
+#ifdef HAVE_PERSONALITY
+# if !HAVE_DECL_ADDR_NO_RANDOMIZE
+# define ADDR_NO_RANDOMIZE 0x0040000
+# endif
+ if (disable_randomization)
+ {
+ int val;
+
+ errno = 0;
+ val = personality (0xffffffff);
+ if (errno == 0)
+ personality (val | ADDR_NO_RANDOMIZE);
+ if (errno != 0 || !(personality (0xffffffff) & ADDR_NO_RANDOMIZE))
+ warning (_("Currently enabled disable-randomization is unsupported "
+ "on this platform."));
+ }
+#endif /* HAVE_PERSONALITY */
+
/* Run inferior in a separate process group. */
debug_setpgrp = gdb_setpgid ();
if (debug_setpgrp == -1)
@@ -446,3 +497,23 @@ startup_inferior (int ntraps)
}
stop_soon = NO_STOP_QUIETLY;
}
+
+void
+_initialize_fork_child (void)
+{
+
+ add_setshow_boolean_cmd ("disable-randomization", class_support,
+ &disable_randomization, _("\
+Set disabling of debuggee's virtual address space randomization."), _("\
+Show disabling of debuggee's virtual address space randomization."), _("\
+When this mode is on (which is the default), the randomization of\n\
+the virtual address space is disabled. Standalone programs run with the\n\
+randomization enabled by default on some platforms."),
+#ifdef HAVE_PERSONALITY
+ NULL,
+#else
+ &set_disable_randomization,
+#endif
+ &show_disable_randomization,
+ &setlist, &showlist);
+}
--- ./gdb/doc/gdb.texinfo 6 Jun 2008 20:58:08 -0000 1.503
+++ ./gdb/doc/gdb.texinfo 8 Jun 2008 11:28:51 -0000
@@ -1999,6 +1999,57 @@ environment:
This command is available when debugging locally on most targets, excluding
@sc{djgpp}, Cygwin, MS Windows, and QNX Neutrino.
+@kindex set disable-randomization
+@item set disable-randomization
+@itemx set disable-randomization on
+This option (enabled by default in @value{GDBN}) will turn off the native
+randomization of the virtual address space of the started program. This option
+is useful for multiple debugging sessions to make the execution better
+reproducible and memory addresses reusable across debugging sessions.
+
+This feature is implemented at least on @sc{gnu}/Linux and OpenBSD. You can
+get the same behavior using
+
+@smallexample
+(@value{GDBP}) set exec-wrapper setarch `uname -m` -R
+@end smallexample
+
+@item set disable-randomization off
+Leave the behavior of the started executable unchanged. Some bugs rear their
+ugly heads only when the program is loaded at certain addresses. If your bug
+disappears when you run the program under @value{GDBN}, that might be because
+@value{GDBN} by default disables the address randomization on platforms, such
+as @sc{gnu}/Linux, which do that for stand-alone programs. Use @kbd{set
+disable-randomization off} to try to reproduce such elusive bugs.
+
+The virtual address space randomization is implemented at least on
+@sc{gnu}/Linux and OpenBSD. It protects the programs against some kinds of
+security attacks. In these cases the attacker needs to know the exact location
+of a concrete executable code. Randomizing its location makes it impossible to
+inject jumps misusing a code at its expected addresses.
+
+Prelinking shared libraries provides a startup performance advantage but it
+makes addresses in these libraries predictable for privileged processes by
+having just unprivileged access at the target system. Reading the shared
+library binary gives enough information for assembling the malicious code
+misusing it. Still even a prelinked shared library can get loaded a a new
+random address just requiring the regular relocation process during the
+startup. Shared libraries not already prelinked are always loaded at
+a randomly chosen address.
+
+Position independent executables (PIE) contain position independent code
+similar to the shared libraries and therefore such executables get loaded at
+a randomly chosen address upon startup. PIE executables always load even
+already prelinked shared libraries at a random address. You can build such
+executable using @command{gcc -fPIE -pie}.
+
+Heap (malloc storage), stack and custom mmap areas are always placed randomly
+(as long as the randomization is enabled).
+
+@item show disable-randomization
+Show the current setting of the explicit disable of the native randomization of
+the virtual address space of the started program.
+
@end table
@node Arguments
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ ./gdb/testsuite/gdb.base/randomize.c 8 Jun 2008 11:28:53 -0000
@@ -0,0 +1,32 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+ Copyright 2008 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+ Please email any bugs, comments, and/or additions to this file to:
+ bug-gdb@prep.ai.mit.edu */
+
+#include <stdlib.h>
+#include <stdio.h>
+
+int main()
+{
+ void *p;
+
+ p = malloc (1);
+ printf ("address = %p\n", p);
+
+ return 0;
+}
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ ./gdb/testsuite/gdb.base/randomize.exp 8 Jun 2008 11:28:53 -0000
@@ -0,0 +1,63 @@
+# Copyright 2008 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+set testfile randomize
+set srcfile ${testfile}.c
+set binfile ${objdir}/${subdir}/${testfile}
+if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
+ untested "Couldn't compile test program"
+ return -1
+}
+
+# Get things started.
+
+gdb_exit
+gdb_start
+gdb_reinitialize_dir $srcdir/$subdir
+gdb_load ${binfile}
+
+proc address_get { testname } {
+ global gdb_prompt
+
+ if {![runto_main]} {
+ return -1
+ }
+ gdb_test_multiple "continue" $testname {
+ -re "address = (0x\[0-9a-f\]*).*Program exited normally..*$gdb_prompt $" {
+ pass $testname
+ return $expect_out(1,string)
+ }
+ }
+}
+
+gdb_test "set disable-randomization off"
+set addr1 [address_get "randomized first address"]
+set addr2 [address_get "randomized second address"]
+set test "randomized addresses should not match"
+if {$addr1 eq $addr2} {
+ fail $test
+} else {
+ pass $test
+}
+
+gdb_test "set disable-randomization on"
+set addr1 [address_get "fixed first address"]
+set addr2 [address_get "fixed second address"]
+set test "fixed addresses should match"
+if {$addr1 eq $addr2} {
+ pass $test
+} else {
+ fail $test
+}

View File

@ -0,0 +1,14 @@
../../libiberty/strsignal.c:552: error: conflicting types for 'psignal'
/usr/include/signal.h:141: error: previous declaration of 'psignal' was here
--- gdb-6.8/libiberty/strsignal.c-orig 2007-01-31 00:13:04.000000000 +0100
+++ gdb-6.8/libiberty/strsignal.c 2008-06-17 16:30:13.000000000 +0200
@@ -549,7 +549,7 @@ followed by a newline.
#ifndef HAVE_PSIGNAL
void
-psignal (int signo, char *message)
+psignal (int signo, const char *message)
{
if (signal_names == NULL)
{

View File

@ -13,7 +13,7 @@ Version: 6.8
# The release always contains a leading reserved number, start it at 1.
# `upstream' is not a part of `name' to stay fully rpm dependencies compatible for the testing.
Release: 10%{?_with_upstream:.upstream}%{?dist}
Release: 11%{?_with_upstream:.upstream}%{?dist}
License: GPLv3+
Group: Development/Debuggers
@ -358,6 +358,21 @@ Patch317: gdb-6.8-sparc64-silence-memcpy-check.patch
# Fix memory trashing on binaries from GCC Ada (workaround GCC PR 35998).
Patch318: gdb-6.8-gcc35998-ada-memory-trash.patch
# Test a crash on libraries missing the .text section.
Patch320: gdb-6.5-section-num-fixup-test.patch
# Protect development in the build tree by automatic Makefile dependencies.
Patch321: gdb-6.8-auto-dependencies.patch
# Refuse creating watchpoints of an address value, suggested by Martin Stransky.
Patch322: gdb-6.8-constant-watchpoints.patch
# Disable randomization (such as by setarch -R), suggested by Jakub Jelinek.
Patch323: gdb-6.8-disable-randomization.patch
# Fix compatibility with recent glibc headers.
Patch324: gdb-6.8-glibc-headers-compat.patch
BuildRequires: ncurses-devel glibc-devel gcc make gzip texinfo dejagnu gettext
BuildRequires: flex bison sharutils expat-devel
Requires: readline
@ -536,6 +551,11 @@ rm -f gdb/jv-exp.c gdb/m2-exp.c gdb/objc-exp.c gdb/p-exp.c
%patch316 -p1
%patch317 -p1
%patch318 -p1
%patch320 -p1
%patch321 -p1
%patch322 -p1
%patch323 -p1
%patch324 -p1
%patch124 -p1
find -name "*.orig" | xargs rm -f
@ -655,7 +675,10 @@ gcc -o ./orphanripper %{SOURCE2} -Wall -lutil
break
fi
done
CHECK="check`echo " $RPM_OPT_FLAGS "|sed -n 's#^.* \(-m[36][241]\) .*$#//unix/\1#p'`"
# On ia64 there is no -m64 flag while we must not leave a bare `check' here
# as it would switch over some testing scripts to the backward compatibility
# mode - when `make check' was executed from inside the testsuite/ directory.
CHECK="check//unix$(echo " $RPM_OPT_FLAGS "|sed -n 's#^.* \(-m[36][241]\) .*$#/\1#p')"
if ! cmp -s biarch-native biarch
then
CHECK="$CHECK check//unix/$BI"
@ -677,7 +700,7 @@ gcc -o ./orphanripper %{SOURCE2} -Wall -lutil
%if 0%{!?_with_upstream:1}
# Run all the scheduled testsuite runs also in the PIE mode.
# Upstream GDB would lock up the testsuite run for too long on its failures.
CHECK="$(echo $CHECK|sed 's#check//unix/[^ ]*#& &/-fPIE/-pie#g')"
CHECK="$(echo $CHECK|sed 's#check//unix[^ ]*#& &/-fPIE/-pie#g')"
%endif # 0%{!?_with_upstream:1}
for CURRENT in $CHECK
@ -785,6 +808,14 @@ fi
%endif
%changelog
* Tue Jun 17 2008 Jan Kratochvil <jan.kratochvil@redhat.com> - 6.8-11
- Fix the testsuite run for ia64 (where no -m64 is present).
- Test a crash on libraries missing the .text section.
- Protect development in the build tree by automatic Makefile dependencies.
- Refuse creating watchpoints of an address value, suggested by Martin Stransky.
- Disable randomization (such as by setarch -R), suggested by Jakub Jelinek.
- Fix compatibility with recent glibc headers.
* Sun Jun 1 2008 Jan Kratochvil <jan.kratochvil@redhat.com> - 6.8-10
- Fix crash on a watchpoint update on an inferior stop.
- Fix the s390x part of the hardware watchpoints after a fork.