- Set the breakpoints always to all the ctors/dtors variants (BZ 301701).

- Fix a TUI visual corruption due to the build-id warnings (BZ 320061).
- Fixed the kernel i386-on-x86_64 VDSO loading (producing `Lowest section
    in').
This commit is contained in:
Jan Kratochvil 2007-10-08 19:12:38 +00:00
parent ddc50f97e3
commit cafa2ff0c1
5 changed files with 345 additions and 13 deletions

View File

@ -5,10 +5,28 @@
* linespec.c (add_minsym_members): Support also the `$allocate' and
`$delete' variants.
2007-10-05 Jan Kratochvil <jan.kratochvil@redhat.com>
* linespec.c (add_minsym_members): Support also the `$allocate' and
`$delete' variants.
(decode_variable): Renamed to ...
(decode_variable_1) ... here, its parameter NOT_FOUND_PTR and its
exception throwing was moved to ...
(decode_variable_not_found): ... a new function here.
(decode_variable): New function.
Index: gdb-6.5/gdb/linespec.c
===================================================================
--- gdb-6.5.orig/gdb/linespec.c 2006-01-10 20:14:43.000000000 -0200
+++ gdb-6.5/gdb/linespec.c 2006-07-07 01:04:56.000000000 -0300
@@ -37,6 +37,7 @@
#include "objc-lang.h"
#include "linespec.h"
#include "exceptions.h"
+#include "gdb_assert.h"
/* We share this one with symtab.c, but it is not exported widely. */
@@ -75,7 +75,8 @@ static struct symtabs_and_lines find_met
struct symbol *sym_class);
@ -438,3 +456,191 @@ Index: gdb-6.5/gdb/linespec.c
return i1;
}
@@ -1976,12 +2021,13 @@ decode_dollar (char *copy, int funfirstl
and do not issue an error message. */
static struct symtabs_and_lines
-decode_variable (char *copy, int funfirstline, char ***canonical,
- struct symtab *file_symtab, int *not_found_ptr)
+decode_variable_1 (char *copy, int funfirstline, char ***canonical,
+ struct symtab *file_symtab)
{
struct symbol *sym;
/* The symtab that SYM was found in. */
struct symtab *sym_symtab;
+ struct symtabs_and_lines retval;
struct minimal_symbol *msymbol;
@@ -2001,8 +2047,25 @@ decode_variable (char *copy, int funfirs
msymbol = lookup_minimal_symbol (copy, NULL, NULL);
if (msymbol != NULL)
- return minsym_found (funfirstline, msymbol);
+ {
+ retval = minsym_found (funfirstline, msymbol);
+
+ /* Create a `filename:linkage_symbol_name' reference. */
+ if (file_symtab == 0)
+ build_canonical_line_spec (retval.sals, SYMBOL_LINKAGE_NAME (msymbol),
+ canonical);
+
+ return retval;
+ }
+ retval.nelts = 0;
+ retval.sals = NULL;
+ return retval;
+}
+
+static void
+decode_variable_not_found (char *copy, int *not_found_ptr)
+{
if (!have_full_symbols () &&
!have_partial_symbols () && !have_minimal_symbols ())
error (_("No symbol table is loaded. Use the \"file\" command."));
@@ -2010,6 +2064,132 @@ decode_variable (char *copy, int funfirs
throw_error (NOT_FOUND_ERROR, _("Function \"%s\" not defined."), copy);
}
+/* Wrapper of DECODE_VARIABLE_1 collecting the results for all the found
+ VARIANTS of the symbol COPY. */
+
+static struct symtabs_and_lines
+decode_variable (char *copy, int funfirstline, char ***canonical,
+ struct symtab *file_symtab, int *not_found_ptr)
+{
+ char *src;
+ char *src_point;
+ char *s, *point;
+ /* Keep "" last as the trimming part always matches it. */
+ const char *variants[] = {"$base","$allocate","$delete",""};
+ int i;
+ char *dst, *dst_point;
+ struct
+ {
+ struct symtabs_and_lines sals;
+ char **canonical;
+ } found[ARRAY_SIZE (variants)];
+ struct symtabs_and_lines retval_sals;
+ char **retval_canonical = NULL; /* Shut up GCC. */
+ int filled;
+ int canonicals = 0; /* Shut up GCC. */
+
+ src = copy;
+ src_point = strchr (src, '(');
+ if (src_point == NULL)
+ {
+ struct symtabs_and_lines sals;
+
+ sals = decode_variable_1 (src, funfirstline, canonical, file_symtab);
+ if (sals.nelts > 0)
+ return sals;
+ decode_variable_not_found (copy, not_found_ptr);
+ /* NOTREACHED */
+ }
+
+ dst = xmalloc (strlen (src) + strlen ("$allocate") + 1);
+ dst_point = dst + (src_point - src);
+
+ memcpy (dst, src, src_point - src);
+
+ /* Trim out any variant markers there first. */
+ for (i = 0; i < ARRAY_SIZE (variants); i++)
+ {
+ size_t len = strlen (variants[i]);
+
+ if (dst_point - dst >= len
+ && memcmp (dst_point - len, variants[i], len) == 0)
+ {
+ dst_point -= len;
+ /* In fact it should not be needed here. */
+ break;
+ }
+ }
+
+ filled = 0;
+ /* And now try to append all of them. */
+ for (i = 0; i < ARRAY_SIZE (variants); i++)
+ {
+ size_t len = strlen (variants[i]);
+ struct minimal_symbol *minsym2;
+
+ memcpy (dst_point, variants[i], len);
+ strcpy (dst_point + len, src_point);
+
+ found[i].canonical = NULL;
+ found[i].sals = decode_variable_1 (dst, funfirstline,
+ (canonical == NULL ? NULL
+ : &found[i].canonical),
+ file_symtab);
+ filled += found[i].sals.nelts;
+ }
+ xfree (dst);
+ if (filled == 0)
+ {
+ decode_variable_not_found (copy, not_found_ptr);
+ /* NOTREACHED */
+ }
+
+ retval_sals.nelts = filled;
+ retval_sals.sals = xmalloc (filled * sizeof *retval_sals.sals);
+ if (canonical != NULL)
+ {
+ retval_canonical = xmalloc (filled * sizeof *retval_canonical);
+ canonicals = 0;
+ }
+ filled = 0;
+ for (i = 0; i < ARRAY_SIZE (variants); i++)
+ {
+ memcpy (&retval_sals.sals[filled], found[i].sals.sals,
+ found[i].sals.nelts * sizeof *retval_sals.sals);
+ xfree (found[i].sals.sals);
+ if (canonical != NULL)
+ {
+ if (found[i].canonical == NULL)
+ memset (&retval_canonical[filled], 0,
+ found[i].sals.nelts * sizeof *retval_canonical);
+ else
+ {
+ int j;
+
+ memcpy (&retval_canonical[filled], found[i].canonical,
+ found[i].sals.nelts * sizeof *retval_canonical);
+ for (j = 0; j < found[i].sals.nelts; j++)
+ if (found[i].canonical[j] != NULL)
+ canonicals++;
+ xfree (found[i].canonical);
+ }
+ }
+ filled += found[i].sals.nelts;
+ }
+ gdb_assert (filled == retval_sals.nelts);
+
+ if (canonical != NULL)
+ {
+ if (canonicals != 0)
+ *canonical = retval_canonical;
+ else
+ {
+ *canonical = NULL;
+ xfree (retval_canonical);
+ }
+ }
+ return retval_sals;
+}
diff -u -rup gdb-6.6-orig/gdb/Makefile.in gdb-6.6/gdb/Makefile.in
--- gdb-6.6-orig/gdb/Makefile.in 2007-10-05 15:22:37.000000000 +0200
+++ gdb-6.6/gdb/Makefile.in 2007-10-05 16:29:10.000000000 +0200
@@ -2266,7 +2266,7 @@ libunwind-frame.o: libunwind-frame.c $(d
linespec.o: linespec.c $(defs_h) $(symtab_h) $(frame_h) $(command_h) \
$(symfile_h) $(objfiles_h) $(source_h) $(demangle_h) $(value_h) \
$(completer_h) $(cp_abi_h) $(parser_defs_h) $(block_h) \
- $(objc_lang_h) $(linespec_h) $(exceptions_h)
+ $(objc_lang_h) $(linespec_h) $(exceptions_h) $(gdb_assert_h)
linux-fork.o: linux-fork.c $(defs_h) $(inferior_h) $(regcache_h) $(gdbcmd_h) \
$(infcall_h) $(gdb_assert_h) $(gdb_string_h) $(linux_fork_h) \
$(linux_nat_h)

View File

@ -19,6 +19,8 @@ Index: gdb/testsuite/ChangeLog
* gdb.cp/constructortest.exp: Test BREAKPOINT_RE_SET for multiple PCs
by PIE.
* gdb.cp/constructortest.exp: Handle the change of settings breakpoints
always at all the ctor/dtor variants.
--- gdb-6.3/gdb/testsuite/gdb.cp/constructortest.cc.fix Fri Jan 21 17:06:56 2005
+++ gdb-6.3/gdb/testsuite/gdb.cp/constructortest.cc Fri Jan 21 17:05:18 2005
@ -124,7 +126,7 @@ Index: gdb/testsuite/ChangeLog
+}
--- gdb-6.3/gdb/testsuite/gdb.cp/constructortest.exp.fix Fri Jan 21 17:07:02 2005
+++ gdb-6.3/gdb/testsuite/gdb.cp/constructortest.exp Fri Jan 21 17:05:29 2005
@@ -0,0 +1,145 @@
@@ -0,0 +1,148 @@
+# This testcase is part of GDB, the GNU debugger.
+
+# Copyright 2005, 2007 Free Software Foundation, Inc.
@ -222,6 +224,9 @@ Index: gdb/testsuite/ChangeLog
+gdb_test "break $second_line_dtor" ".*$second_line_dtor.*$second_line_dtor.*Multiple breakpoints were set.*" "break by line in destructor"
+gdb_continue_to_breakpoint "Second line ~A"
+gdb_test "bt" "#0.*A.*#1.*main.*" "Verify in in-charge A::~A second line"
+# FIXME: Analyse this case better.
+gdb_continue_to_breakpoint "Second line ~A"
+gdb_test "bt" "#0.*A.*#1.*main.*" "Verify in A::~A second line #2"
+gdb_continue_to_breakpoint "Second line ~A"
+gdb_test "bt" "#0.*A.*#1.*B.*#2.*main.*" "Verify in not-in-charge A::~A second line"
+

View File

@ -35,7 +35,7 @@ diff -u -rup gdb-6.6-orig/gdb/corelow.c gdb-6.6/gdb/corelow.c
#ifndef O_LARGEFILE
@@ -253,6 +257,63 @@ add_to_thread_list (bfd *abfd, asection
@@ -253,6 +257,66 @@ add_to_thread_list (bfd *abfd, asection
inferior_ptid = pid_to_ptid (thread_id); /* Yes, make it current */
}
@ -70,7 +70,9 @@ diff -u -rup gdb-6.6-orig/gdb/corelow.c gdb-6.6/gdb/corelow.c
+ if (exec_filename != NULL)
+ exec_file_attach (exec_filename, from_tty);
+ else
+ warning (_("Missing the matching executable file: %s"), build_id_filename);
+ fprintf_unfiltered (gdb_stdlog,
+ _("\nwarning: Missing the matching executable file: %s\n"),
+ build_id_filename);
+ xfree (build_id_filename);
+
+ /* `.note.gnu.build-id' section exists even for files without a separate
@ -86,8 +88,9 @@ diff -u -rup gdb-6.6-orig/gdb/corelow.c gdb-6.6/gdb/corelow.c
+ if (exec_filename != NULL)
+ symbol_file_add_main (exec_filename, from_tty);
+ if (symfile_objfile == NULL)
+ warning (_("Missing the matching executable's debug info file: %s"),
+ build_id_filename);
+ fprintf_unfiltered (gdb_stdlog,
+ _("\nwarning: Missing the matching executable's debug info file: %s\n"),
+ build_id_filename);
+ }
+ xfree (build_id_filename);
+
@ -132,7 +135,7 @@ diff -u -rup gdb-6.6-orig/gdb/corelow.c gdb-6.6/gdb/corelow.c
diff -u -rup gdb-6.6-orig/gdb/solib-svr4.c gdb-6.6/gdb/solib-svr4.c
--- gdb-6.6-orig/gdb/solib-svr4.c 2007-08-28 15:31:19.000000000 +0200
+++ gdb-6.6/gdb/solib-svr4.c 2007-08-28 15:34:02.000000000 +0200
@@ -943,10 +943,34 @@ svr4_current_sos (void)
@@ -943,10 +943,35 @@ svr4_current_sos (void)
}
else
{
@ -162,8 +165,9 @@ diff -u -rup gdb-6.6-orig/gdb/solib-svr4.c gdb-6.6/gdb/solib-svr4.c
+ xfree (name);
+ }
+ else
+ warning (_("Missing the matching library file: %s"),
+ build_id_filename);
+ fprintf_unfiltered (gdb_stdlog,
+ _("\nwarning: Missing the matching library file: %s\n"),
+ build_id_filename);
+ xfree (build_id_filename);
+ xfree (build_id);
+ }
@ -728,7 +732,7 @@ diff -u -rup gdb-6.6-orig/gdb/symfile.c gdb-6.6/gdb/symfile.c
xfree (basename);
xfree (dir);
return xstrdup (debugfile);
@@ -1384,11 +1795,19 @@ find_separate_debug_file (struct objfile
@@ -1384,11 +1795,20 @@ find_separate_debug_file (struct objfile
if (separate_debug_file_exists (debugfile, crc32, objfile->name))
{
@ -740,8 +744,9 @@ diff -u -rup gdb-6.6-orig/gdb/symfile.c gdb-6.6/gdb/symfile.c
+ if (build_id_filename != NULL)
+ {
+ warning (_("Missing the separate debug info file: %s"),
+ build_id_filename);
+ fprintf_unfiltered (gdb_stdlog,
+ _("\nwarning: Missing the separate debug info file: %s\n"),
+ build_id_filename);
+ xfree (build_id_filename);
+ }
+

View File

@ -0,0 +1,107 @@
Fix i386-on-x86_64 debugging giving the warning:
warning: Lowest section in system-supplied DSO at 0xffffe000 is .hash at ffffe0b4
[ Backport for RH GDB-6.6. ]
--- gdb-6.6/gdb/symfile.c 2007-10-08 19:52:06.000000000 +0200
+++ gdb-6.6/gdb/symfile.c 2007-10-08 19:49:27.000000000 +0200
@@ -597,6 +597,37 @@ default_symfile_offsets (struct objfile
init_objfile_sect_indices (objfile);
}
+/* Find lowest loadable section to be used as starting point for continguous
+ sections. FIXME!! won't work without call to find .text first, but this
+ assumes text is lowest section. vDSO was seen for i386-on-amd64 processes
+ to have no `.text' as it has `.text.vsyscall', `.text.sigreturn' etc.
+ instead. Execution of this function has been delayed till it is really
+ needed as it is broken for vDSOs, fortunately it is never needed on
+ GNU/Linux. */
+
+static CORE_ADDR
+find_lower_offset (struct objfile *objfile)
+{
+ asection *lower_sect;
+
+ lower_sect = bfd_get_section_by_name (objfile->obfd, ".text");
+ if (lower_sect == NULL)
+ bfd_map_over_sections (objfile->obfd, find_lowest_section,
+ &lower_sect);
+ if (lower_sect == NULL)
+ warning (_("no loadable sections found in added symbol-file %s"),
+ objfile->name);
+ else
+ if ((bfd_get_section_flags (objfile->obfd, lower_sect) & SEC_CODE) == 0)
+ warning (_("Lowest section in %s is %s at %s"),
+ objfile->name,
+ bfd_section_name (objfile->obfd, lower_sect),
+ paddr (bfd_section_vma (objfile->obfd, lower_sect)));
+ if (lower_sect != NULL)
+ return bfd_section_vma (objfile->obfd, lower_sect);
+ else
+ return 0;
+}
/* Process a symbol file, as either the main file or as a dynamically
loaded file.
@@ -696,32 +727,11 @@ syms_from_objfile (struct objfile *objfi
happens for the PA64 port. */
if (/*!mainline &&*/ addrs && addrs->other[0].name)
{
- asection *lower_sect;
asection *sect;
- CORE_ADDR lower_offset;
+ CORE_ADDR lower_offset = 0; /* Shut up the GCC warning. */
+ int lower_offset_set = 0;
int i;
- /* Find lowest loadable section to be used as starting point for
- continguous sections. FIXME!! won't work without call to find
- .text first, but this assumes text is lowest section. */
- lower_sect = bfd_get_section_by_name (objfile->obfd, ".text");
- if (lower_sect == NULL)
- bfd_map_over_sections (objfile->obfd, find_lowest_section,
- &lower_sect);
- if (lower_sect == NULL)
- warning (_("no loadable sections found in added symbol-file %s"),
- objfile->name);
- else
- if ((bfd_get_section_flags (objfile->obfd, lower_sect) & SEC_CODE) == 0)
- warning (_("Lowest section in %s is %s at %s"),
- objfile->name,
- bfd_section_name (objfile->obfd, lower_sect),
- paddr (bfd_section_vma (objfile->obfd, lower_sect)));
- if (lower_sect != NULL)
- lower_offset = bfd_section_vma (objfile->obfd, lower_sect);
- else
- lower_offset = 0;
-
/* Calculate offsets for the loadable sections.
FIXME! Sections must be in order of increasing loadable section
so that contiguous sections can use the lower-offset!!!
@@ -743,6 +753,7 @@ syms_from_objfile (struct objfile *objfi
addrs->other[i].addr
-= bfd_section_vma (objfile->obfd, sect);
lower_offset = addrs->other[i].addr;
+ lower_offset_set = 1;
/* This is the index used by BFD. */
addrs->other[i].sectindex = sect->index ;
}
@@ -755,7 +766,17 @@ syms_from_objfile (struct objfile *objfi
}
}
else
- addrs->other[i].addr = lower_offset;
+ {
+ /* Delay finding LOWER_OFFSET only if it is needed. Otherwise
+ we would print a warning to detect a values never used. */
+ if (!lower_offset_set)
+ {
+ lower_offset = find_lower_offset (objfile);
+ lower_offset_set = 1;
+ }
+
+ addrs->other[i].addr = lower_offset;
+ }
}
}

View File

@ -11,7 +11,7 @@ Name: gdb
Version: 6.6
# The release always contains a leading reserved number, start it at 1.
Release: 31%{?dist}
Release: 32%{?dist}
License: GPL
Group: Development/Debuggers
@ -374,9 +374,12 @@ Patch272: gdb-6.6-glibc-open-fcntl2-compat.patch
Patch273: gdb-6.6-buildid-verify.patch
Patch274: gdb-6.6-buildid-locate.patch
# Fixed the kernel VDSO loading (producing `no loadable sections found').
# Fixed the kernel 8KB VDSO loading (producing `no loadable sections found').
Patch276: gdb-6.6-bfd-vdso8k.patch
# Fixed the kernel i386-on-x86_64 VDSO loading (producing `Lowest section in').
Patch277: gdb-6.6-vdso-i386-on-amd64-warning.patch
BuildRequires: ncurses-devel glibc-devel gcc make gzip texinfo dejagnu gettext
BuildRequires: flex bison sharutils expat-devel
Requires: readline
@ -533,6 +536,7 @@ rm -f gdb/jv-exp.c gdb/m2-exp.c gdb/objc-exp.c gdb/p-exp.c
%patch273 -p1
%patch274 -p1
%patch276 -p1
%patch277 -p1
# Change the version that gets printed at GDB startup, so it is RedHat
# specific.
@ -689,6 +693,11 @@ fi
# don't include the files in include, they are part of binutils
%changelog
* Mon Oct 8 2007 Jan Kratochvil <jan.kratochvil@redhat.com> - 6.6-32
- Set the breakpoints always to all the ctors/dtors variants (BZ 301701).
- Fix a TUI visual corruption due to the build-id warnings (BZ 320061).
- Fixed the kernel i386-on-x86_64 VDSO loading (producing `Lowest section in').
* Fri Oct 5 2007 Jan Kratochvil <jan.kratochvil@redhat.com> - 6.6-31
- Fix address changes of the ctors/dtors breakpoints w/multiple PCs (BZ 301701).
- Delete an info doc file on `rpmbuild -bp' later rebuilt during `rpmbuild -bc'.