gdb/gdb-7.0-upstream.patch
2010-06-02 11:05:40 +00:00

515 lines
17 KiB
Diff

http://sourceware.org/ml/gdb-patches/2009-11/msg00388.html
http://sourceware.org/ml/gdb-cvs/2009-11/msg00156.html
Subject: [patch] Fix crash on reading stabs
Hi,
there is a crash on reading stabs fpc binary:
https://bugzilla.redhat.com/show_bug.cgi?id=537837
Program received signal SIGSEGV, Segmentation fault.
0x000000000069db3d in read_dbx_symtab (objfile=0x1daf5f0) at dbxread.c:1369
1369 if ((namestring[0] == '-' && namestring[1] == 'l')
(gdb) p/x nlist.n_strx
$7 = 0xfffffff8
(gdb) p sizeof(nlist.n_strx)
$10 = 8
Below the patch context is:
namestring = (nlist->n_strx + file_string_table_offset
+ DBX_STRINGTAB (objfile));
so IMO the `(unsigned)' cast is excessive as it does not match the expression
below. Such cast is there since the GDB "Initial revision" (1999).
`n_strx' type:
struct internal_nlist
{
unsigned long n_strx; /* Index into string table of name. */
...
};
Regression tested on {x86_64,x86_64-m32,i686}-fedora12-linux-gnu which does not
mean anything with the default DWARF debug info. It was hanging for stabs so
tried just a large part of gdb.base/*.exp on x86_64-m32 - `unix/-gstabs+/-m32'.
If it isn't obviously approved please feel free to drop it as one should not
use STABS in the first place.
Regards,
Jan
gdb/
2009-11-17 Jan Kratochvil <jan.kratochvil@redhat.com>
* dbxread.c (set_namestring): Remove cast to unsigned. Check N_STRX
overflow.
--- a/gdb/dbxread.c
+++ b/gdb/dbxread.c
@@ -965,8 +965,9 @@ set_namestring (struct objfile *objfile, const struct internal_nlist *nlist)
{
char *namestring;
- if (((unsigned) nlist->n_strx + file_string_table_offset)
- >= DBX_STRINGTAB_SIZE (objfile))
+ if (nlist->n_strx + file_string_table_offset
+ >= DBX_STRINGTAB_SIZE (objfile)
+ || nlist->n_strx + file_string_table_offset < nlist->n_strx)
{
complaint (&symfile_complaints, _("bad string table offset in symbol %d"),
symnum);
Re: [RFA] Fix "show convenience" test
http://sourceware.org/ml/gdb-patches/2009-09/msg00565.html
http://sourceware.org/ml/gdb-cvs/2009-09/msg00099.html
### src/gdb/testsuite/ChangeLog 2009/09/15 18:51:25 1.1960
### src/gdb/testsuite/ChangeLog 2009/09/17 17:49:46 1.1961
## -1,3 +1,7 @@
+2009-09-17 Paul Pluzhnikov <ppluzhnikov@google.com>
+
+ * gdb.base/default.exp: Fix "show convenience".
+
2009-09-15 Tom Tromey <tromey@redhat.com>
* lib/mi-support.exp (mi_create_varobj): Update.
--- src/gdb/testsuite/gdb.base/default.exp 2009/08/13 14:58:27 1.31
+++ src/gdb/testsuite/gdb.base/default.exp 2009/09/17 17:49:46 1.32
@@ -598,7 +598,7 @@
#test show confirm
gdb_test "show confirm" "Whether to confirm potentially dangerous operations is o\[a-z\]*." "show confirm"
#test show convenience
-gdb_test "show convenience" "No debugger convenience variables now defined.(\[^\r\n\]*\[\r\n\])+Convenience variables have names starting with \".\";(\[^\r\n\]*\[\r\n\])+use \"set\" as in \"set .foo = 5\" to define them." "show convenience"
+gdb_test "show convenience" "\\\$_siginfo = void" "show convenience"
#test show directories
gdb_test "show directories" "Source directories searched: .cdir\[:;\].cwd" "show directories"
#test show editing
### src/gdb/doc/ChangeLog 2009/09/15 18:51:24 1.953
### src/gdb/doc/ChangeLog 2009/09/17 17:49:46 1.954
## -1,3 +1,8 @@
+2009-09-17 Paul Pluzhnikov <ppluzhnikov@google.com>
+
+ * gdb.texinfo (convenince variables): Mention
+ $_siginfo could be empty.
+
2009-09-15 Tom Tromey <tromey@redhat.com>
* gdb.texinfo (GDB/MI Variable Objects): Document
--- src/gdb/doc/gdb.texinfo 2009/09/15 18:51:25 1.624
+++ src/gdb/doc/gdb.texinfo 2009/09/17 17:49:46 1.625
@@ -7819,8 +7819,10 @@
@item $_siginfo
@vindex $_siginfo@r{, convenience variable}
-The variable @code{$_siginfo} is bound to extra signal information
-inspection (@pxref{extra signal information}).
+The variable @code{$_siginfo} contains extra signal information
+(@pxref{extra signal information}). Note that @code{$_siginfo}
+could be empty, if the application has not yet received any signals.
+For example, it will be empty before you execute the @code{run} command.
@end table
On HP-UX systems, if you refer to a function or variable name that
http://sourceware.org/ml/gdb-cvs/2009-12/msg00128.html
### src/gdb/testsuite/ChangeLog 2009/12/23 23:18:08 1.2054
### src/gdb/testsuite/ChangeLog 2009/12/24 21:57:06 1.2055
## -1,3 +1,10 @@
+2009-12-24 Jan Kratochvil <jan.kratochvil@redhat.com>
+
+ Fix compatibility with G++-4.5.
+ * gdb.cp/expand-sals.cc (main): Remove the "exit-line" comment.
+ * gdb.cp/expand-sals.exp: Remove breakpoint on "exit-line".
+ (uncaught return): Remove.
+
2009-12-23 Jan Kratochvil <jan.kratochvil@redhat.com>
Phil Muldoon <pmuldoon@redhat.com>
--- src/gdb/testsuite/gdb.cp/expand-sals.cc 2009/05/11 15:05:56 1.1
+++ src/gdb/testsuite/gdb.cp/expand-sals.cc 2009/12/24 21:57:06 1.2
@@ -49,5 +49,5 @@
A a;
B b;
- return 0; /* exit-line */
+ return 0;
}
--- src/gdb/testsuite/gdb.cp/expand-sals.exp 2009/05/11 15:05:56 1.1
+++ src/gdb/testsuite/gdb.cp/expand-sals.exp 2009/12/24 21:57:06 1.2
@@ -23,8 +23,6 @@
return -1
}
-gdb_breakpoint [gdb_get_line_number "exit-line"]
-
gdb_breakpoint [gdb_get_line_number "func-line"]
gdb_continue_to_breakpoint "func" ".*func-line.*"
@@ -52,7 +50,3 @@
"bt from A"
gdb_continue_to_breakpoint "next caller func" ".*func-line.*"
-
-# Verify GDB really could not catch any other breakpoint location.
-
-gdb_continue_to_breakpoint "uncaught return" ".*exit-line.*"
http://sourceware.org/ml/gdb-cvs/2009-11/msg00213.html
[ cut ]
--- src/gdb/testsuite/gdb.base/condbreak.exp 2009/01/03 05:58:03 1.13
+++ src/gdb/testsuite/gdb.base/condbreak.exp 2009/11/25 20:43:29 1.14
@@ -207,10 +207,10 @@
setup_xfail hppa2.0w-*-* 11512CLLbs
send_gdb "continue\n"
gdb_expect {
- -re "Continuing\\..*Breakpoint \[0-9\]+, marker2 \\(a=43\\) at .*$srcfile1:($bp_location8|$bp_location9).*($bp_location8|$bp_location9)\[\t \]+.*" {
+ -re "Continuing\\..*Breakpoint \[0-9\]+, marker2 \\(a=43\\) at .*$srcfile1:($bp_location8|$bp_location9).*($bp_location8|$bp_location9)\[\t \]+.*$gdb_prompt $" {
pass "run until breakpoint at marker2"
}
- -re "Continuing\\..*Breakpoint \[0-9\]+, $hex in marker2 \\(a=43\\) at .*$srcfile1:($bp_location8|$bp_location9).*($bp_location8|$bp_location9)\[\t \]+.*" {
+ -re "Continuing\\..*Breakpoint \[0-9\]+, $hex in marker2 \\(a=43\\) at .*$srcfile1:($bp_location8|$bp_location9).*($bp_location8|$bp_location9)\[\t \]+.*$gdb_prompt $" {
xfail "run until breakpoint at marker2"
}
-re "$gdb_prompt $" {
Fix for gfortran-4.1:
-PASS: gdb.mi/mi-var-child-f.exp: mi runto MAIN__
+FAIL: gdb.mi/mi-var-child-f.exp: mi runto MAIN__ (unknown output after running)
RFC: Move language-changed message to verbose
http://sourceware.org/ml/gdb-patches/2009-11/msg00031.html
http://sourceware.org/ml/gdb-cvs/2009-11/msg00034.html
### src/gdb/ChangeLog 2009/11/05 19:53:03 1.11030
### src/gdb/ChangeLog 2009/11/05 20:43:52 1.11031
## -1,3 +1,8 @@
+2009-11-05 Daniel Jacobowitz <dan@codesourcery.com>
+
+ * top.c (execute_command): Select a frame before checking the current
+ language. Only output a message if verbose.
+
2009-11-05 Tom Tromey <tromey@redhat.com>
* symtab.h (SYMBOL_SET_LINKAGE_NAME): Update comment.
--- src/gdb/top.c 2009/10/19 09:51:42 1.172
+++ src/gdb/top.c 2009/11/05 20:43:52 1.173
@@ -457,10 +457,13 @@
}
- /* Tell the user if the language has changed (except first time). */
+ /* Tell the user if the language has changed (except first time).
+ First make sure that a new frame has been selected, in case this
+ command or the hooks changed the program state. */
+ deprecated_safe_get_selected_frame ();
if (current_language != expected_language)
{
- if (language_mode == language_mode_auto)
+ if (language_mode == language_mode_auto && info_verbose)
{
language_info (1); /* Print what changed. */
}
https://bugzilla.redhat.com/show_bug.cgi?id=578136
https://bugzilla.redhat.com/show_bug.cgi?id=593926
http://sourceware.org/ml/gdb-patches/2010-04/msg00820.html
http://sourceware.org/ml/gdb-cvs/2010-04/msg00240.html
### src/gdb/ChangeLog 2010/04/23 18:09:16 1.11678
### src/gdb/ChangeLog 2010/04/23 21:44:19 1.11679
## -1,3 +1,14 @@
+2010-04-23 Daniel Jacobowitz <dan@codesourcery.com>
+ Paul Pluzhnikov <ppluzhnikov@google.com>
+ Jan Kratochvil <jan.kratochvil@redhat.com>
+
+ Fix deadlock on looped list of loaded shared objects.
+ * solib-svr4.c (LM_PREV): New function.
+ (IGNORE_FIRST_LINK_MAP_ENTRY): Use it.
+ (svr4_current_sos): Check for correct l_prev. New variables prev_lm
+ and next_lm. Clear prev_lm for solib_svr4_r_ldsomap.
+ * config/djgpp/fnchange.lst: Add translation for solib-corrupted.exp.
+
2010-04-23 Doug Evans <dje@google.com>
* configure.ac (CONFIG_SRCS): Add py-auto-load.o even if not using
--- src/gdb/solib-svr4.c 2010/03/11 22:07:02 1.130
+++ src/gdb/solib-svr4.c 2010/04/23 21:44:19 1.131
@@ -272,6 +272,16 @@
}
static CORE_ADDR
+LM_PREV (struct so_list *so)
+{
+ struct link_map_offsets *lmo = svr4_fetch_link_map_offsets ();
+ struct type *ptr_type = builtin_type (target_gdbarch)->builtin_data_ptr;
+
+ return extract_typed_address (so->lm_info->lm + lmo->l_prev_offset,
+ ptr_type);
+}
+
+static CORE_ADDR
LM_NAME (struct so_list *so)
{
struct link_map_offsets *lmo = svr4_fetch_link_map_offsets ();
@@ -284,16 +294,12 @@
static int
IGNORE_FIRST_LINK_MAP_ENTRY (struct so_list *so)
{
- struct link_map_offsets *lmo = svr4_fetch_link_map_offsets ();
- struct type *ptr_type = builtin_type (target_gdbarch)->builtin_data_ptr;
-
/* Assume that everything is a library if the dynamic loader was loaded
late by a static executable. */
if (exec_bfd && bfd_get_section_by_name (exec_bfd, ".dynamic") == NULL)
return 0;
- return extract_typed_address (so->lm_info->lm + lmo->l_prev_offset,
- ptr_type) == 0;
+ return LM_PREV (so) == 0;
}
/* Per-inferior SVR4 specific data. */
@@ -1101,7 +1107,7 @@
static struct so_list *
svr4_current_sos (void)
{
- CORE_ADDR lm;
+ CORE_ADDR lm, prev_lm;
struct so_list *head = 0;
struct so_list **link_ptr = &head;
CORE_ADDR ldsomap = 0;
@@ -1120,6 +1126,7 @@
/* Walk the inferior's link map list, and build our list of
`struct so_list' nodes. */
+ prev_lm = 0;
lm = solib_svr4_r_map (info);
while (lm)
@@ -1127,6 +1134,7 @@
struct link_map_offsets *lmo = svr4_fetch_link_map_offsets ();
struct so_list *new = XZALLOC (struct so_list);
struct cleanup *old_chain = make_cleanup (xfree, new);
+ CORE_ADDR next_lm;
new->lm_info = xmalloc (sizeof (struct lm_info));
make_cleanup (xfree, new->lm_info);
@@ -1138,14 +1146,21 @@
read_memory (lm, new->lm_info->lm, lmo->link_map_size);
- lm = LM_NEXT (new);
+ next_lm = LM_NEXT (new);
+
+ if (LM_PREV (new) != prev_lm)
+ {
+ warning (_("Corrupted shared library list"));
+ free_so (new);
+ next_lm = 0;
+ }
/* For SVR4 versions, the first entry in the link map is for the
inferior executable, so we must ignore it. For some versions of
SVR4, it has no name. For others (Solaris 2.3 for example), it
does have a name, so we can no longer use a missing name to
decide when to ignore it. */
- if (IGNORE_FIRST_LINK_MAP_ENTRY (new) && ldsomap == 0)
+ else if (IGNORE_FIRST_LINK_MAP_ENTRY (new) && ldsomap == 0)
{
info->main_lm_addr = new->lm_info->lm_addr;
free_so (new);
@@ -1182,12 +1197,18 @@
}
}
+ prev_lm = lm;
+ lm = next_lm;
+
/* On Solaris, the dynamic linker is not in the normal list of
shared objects, so make sure we pick it up too. Having
symbol information for the dynamic linker is quite crucial
for skipping dynamic linker resolver code. */
if (lm == 0 && ldsomap == 0)
- lm = ldsomap = solib_svr4_r_ldsomap (info);
+ {
+ lm = ldsomap = solib_svr4_r_ldsomap (info);
+ prev_lm = 0;
+ }
discard_cleanups (old_chain);
}
--- src/gdb/config/djgpp/fnchange.lst 2010/04/09 15:15:05 1.112
+++ src/gdb/config/djgpp/fnchange.lst 2010/04/23 21:44:19 1.113
@@ -397,6 +397,7 @@
@V@/gdb/testsuite/gdb.base/siginfo-obj.c @V@/gdb/testsuite/gdb.base/si-obj.c
@V@/gdb/testsuite/gdb.base/siginfo-addr.exp @V@/gdb/testsuite/gdb.base/si-addr.exp
@V@/gdb/testsuite/gdb.base/siginfo-obj.exp @V@/gdb/testsuite/gdb.base/si-obj.exp
+@V@/gdb/testsuite/gdb.base/solib-corrupted.exp @V@/gdb/testsuite/gdb.base/so-crptd.exp
@V@/gdb/testsuite/gdb.base/solib-disc.c @V@/gdb/testsuite/gdb.base/so-disc.c
@V@/gdb/testsuite/gdb.base/solib-display-lib.c @V@/gdb/testsuite/gdb.base/so-displib.c
@V@/gdb/testsuite/gdb.base/solib-display-main.c @V@/gdb/testsuite/gdb.base/so-dispmain.c
### src/gdb/testsuite/ChangeLog 2010/04/23 18:03:31 1.2252
### src/gdb/testsuite/ChangeLog 2010/04/23 21:44:20 1.2253
## -1,3 +1,8 @@
+2010-04-23 Jan Kratochvil <jan.kratochvil@redhat.com>
+
+ Fix deadlock on looped list of loaded shared objects.
+ * gdb.base/solib-corrupted.exp: New.
+
2010-04-23 Doug Evans <dje@google.com>
* gdb.python/py-section-script.c: New file.
--- src/gdb/testsuite/gdb.base/solib-corrupted.exp
+++ src/gdb/testsuite/gdb.base/solib-corrupted.exp 2010-05-24 18:00:52.057995000 +0000
@@ -0,0 +1,46 @@
+# Copyright 2010 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+set testfile "solib-corrupted"
+set srcfile start.c
+
+if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile}] } {
+ untested ${testfile}.exp
+ return -1
+}
+
+if ![runto_main] {
+ fail "Can't run to main"
+ return
+}
+
+gdb_test "info sharedlibrary" "" "normal list"
+
+# GDB checks there for matching L_PREV.
+set test "make solibs looping"
+gdb_test_multiple "p/x _r_debug->r_map->l_next = _r_debug->r_map" $test {
+ -re "(No symbol \"_r_debug\" in current context\\.|Attempt to extract a component of a value that is not a structure pointer\\.)\r\n$gdb_prompt $" {
+ # glibc debug info is not available and it is too difficult to find and
+ # parse it from this testcase without the gdb supporting functions.
+ verbose -log "no _r_debug symbol has been found"
+ xfail $test
+ untested ${testfile}.exp
+ return
+ }
+ -re " = 0x\[0-9a-f\]+\r\n$gdb_prompt $" {
+ pass $test
+ }
+}
+gdb_test "info sharedlibrary" "warning: Corrupted shared library list\r\n.*" "corrupted list"
FYI: fix java-related crash
http://sourceware.org/ml/gdb-patches/2010-02/msg00445.html
http://sourceware.org/ml/gdb-cvs/2010-02/msg00142.html
[ Backported. ]
### src/gdb/ChangeLog 2010/02/17 20:54:52 1.11374
### src/gdb/ChangeLog 2010/02/17 22:25:04 1.11375
## -1,3 +1,7 @@
+2010-02-17 Tom Tromey <tromey@redhat.com>
+
+ * objfiles.c (gdb_bfd_ref): Handle abfd==NULL.
+
2010-02-17 Jan Kratochvil <jan.kratochvil@redhat.com>
* symfile.c (build_section_addr_info_from_objfile): Include sections
--- src/gdb/objfiles.c 2010/02/09 10:59:50 1.110
+++ src/gdb/objfiles.c 2010/02/17 22:25:05 1.111
@@ -1504,7 +1504,12 @@
struct bfd *
gdb_bfd_ref (struct bfd *abfd)
{
- int *p_refcount = bfd_usrdata (abfd);
+ int *p_refcount;
+
+ if (abfd == NULL)
+ return NULL;
+
+ p_refcount = bfd_usrdata (abfd);
if (p_refcount != NULL)
{
### src/gdb/testsuite/ChangeLog 2010/02/17 22:09:05 1.2143
### src/gdb/testsuite/ChangeLog 2010/02/17 22:25:05 1.2144
## -1,3 +1,8 @@
+2010-02-17 Tom Tromey <tromey@redhat.com>
+
+ * gdb.java/jprint.java (jprint.props): New field.
+ * gdb.java/jprint.exp (set_lang_java): Add regression test.
+
2010-02-17 Pedro Alves <pedro@codesourcery.com>
* gdb.base/charset.exp: Don't assume new `regsub' syntax
--- src/gdb/testsuite/gdb.java/jprint.exp 2010/01/01 07:32:03 1.10
+++ src/gdb/testsuite/gdb.java/jprint.exp 2010/02/17 22:25:05 1.11
@@ -84,4 +84,7 @@
gdb_test "call x.dothat(55)" "new value is 58\r\n.*= 62.*" "virtual fn call"
gdb_test "p x.addprint(1,2,3)" "sum is 6\r\n.*" "inherited static call"
gdb_test "call x.addk(44)" "adding k gives 121\r\n.*= 121.*" "inherited virtual fn call"
+
+ # Regression test for a crasher.
+ gdb_test "print *jprint.props" " = .*" "print a java.util.Properties"
}
--- gdb-7.0.1/gdb/testsuite/gdb.java/jprint.java.orig 2007-05-14 18:44:27.000000000 +0200
+++ gdb-7.0.1/gdb/testsuite/gdb.java/jprint.java 2010-06-02 12:41:07.000000000 +0200
@@ -1,6 +1,6 @@
// jprint.java test program.
//
-// Copyright 2004
+// Copyright 2004, 2010
// Free Software Foundation, Inc.
//
// Written by Jeff Johnston <jjohnstn@redhat.com>
@@ -23,6 +23,8 @@
// Foundation, Inc., 59 Temple Place - Suite 330,
// Boston, MA 02111-1307, USA.
+import java.util.Properties;
+
class jvclass {
public static int k;
static {
@@ -41,6 +43,8 @@ class jvclass {
}
public class jprint extends jvclass {
+ public static Properties props = new Properties ();
+
public int dothat (int x) {
int y = x + 3;
System.out.println ("new value is " + y);