Accepting request 43722 from devel:gcc

Copy from devel:gcc/gdb based on submit request 43722 from user rguenther

OBS-URL: https://build.opensuse.org/request/show/43722
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/gdb?expand=0&rev=77
This commit is contained in:
OBS User autobuild 2010-07-23 19:40:40 +00:00 committed by Git OBS Bridge
parent 8ed182f504
commit 44b0b264f9
37 changed files with 8746 additions and 733 deletions

View File

@ -1,190 +0,0 @@
http://sourceware.org/ml/gdb-patches/2010-01/msg00558.html
Subject: Re: [patch] print a more useful error message for "gdb core"
[ Fixed up since the mail. ]
On Thu, 21 Jan 2010 18:17:15 +0100, Doug Evans wrote:
> Not an exhaustive list, but if we go down the path of converting "gdb
> corefile" to "gdb -c corefile", then we also need to think about "file
> corefile" being converted to "core corefile" [or "target core
> corefile", "core" is apparently deprecated in favor of "target core"]
> and "target exec corefile" -> "target core corefile". Presumably
> "file corefile" (and "target exec corefile") would discard the
> currently selected executable. But maybe not. Will that be confusing
> for users? I don't know.
While thinking about it overriding some GDB _commands_ was not my intention.
There is a general assumption if I have a shell COMMAND and some FILE I can do
$ COMMAND FILE
and COMMAND will appropriately load the FILE.
FSF GDB currently needs to specify also the executable file for core files
which already inhibits this intuitive expectation. OTOH with the build-id
locating patch which could allow such intuitive start notneeding the
executable file. Still it currently did not work due to the required "-c":
$ COMMAND -c COREFILE
Entering "file", "core-file" or "attach" commands is already explicit enough
so that it IMO should do what the command name says without any
autodetections. The second command line argument
(captured_main->pid_or_core_arg) is also autodetected (for PID or CORE) but
neither "attach" accepts a core file nor "core-file" accepts a PID.
The patch makes sense only with the build-id patchset so this is not submit
for FSF GDB inclusion yet. I am fine with your patch (+/- Hui Zhu's pending
bfd_check_format_matches) as the patch below is its natural extension.
Sorry for the delay,
Jan
2010-01-25 Jan Kratochvil <jan.kratochvil@redhat.com>
* exceptions.h (enum errors <IS_CORE_ERROR>): New.
* exec.c: Include exceptions.h.
(exec_file_attach <bfd_core>): Call throw_error (IS_CORE_ERROR, ...).
* main.c (exec_or_core_file_attach): New.
(captured_main <optind < argc>): Set also corearg.
(captured_main <strcmp (execarg, symarg) == 0>): New variable func.
Call exec_or_core_file_attach if COREARG matches EXECARG. Call
symbol_file_add_main only if CORE_BFD remained NULL.
Http://sourceware.org/ml/gdb-patches/2010-01/msg00517.html
2010-01-20 Doug Evans <dje@google.com>
* exec.c (exec_file_attach): Print a more useful error message if the
user did "gdb core".
--- ./gdb/exceptions.h 2010-04-11 22:31:30.000000000 +0200
+++ ./gdb/exceptions.h 2010-04-11 22:31:47.000000000 +0200
@@ -78,6 +78,9 @@ enum errors {
/* Feature is not supported in this copy of GDB. */
UNSUPPORTED_ERROR,
+ /* Attempt to load a core file as executable. */
+ IS_CORE_ERROR,
+
/* Add more errors here. */
NR_ERRORS
};
--- ./gdb/exec.c 2010-04-11 22:31:30.000000000 +0200
+++ ./gdb/exec.c 2010-04-11 22:41:26.000000000 +0200
@@ -34,6 +34,7 @@
#include "arch-utils.h"
#include "gdbthread.h"
#include "progspace.h"
+#include "exceptions.h"
#include <fcntl.h>
#include "readline/readline.h"
@@ -256,12 +257,27 @@ exec_file_attach (char *filename, int fr
if (!bfd_check_format_matches (exec_bfd, bfd_object, &matching))
{
+ int is_core;
+
+ /* If the user accidentally did "gdb core", print a useful
+ error message. Check it only after bfd_object has been checked as
+ a valid executable may get recognized for example also as
+ "trad-core". */
+ is_core = bfd_check_format (exec_bfd, bfd_core);
+
/* Make sure to close exec_bfd, or else "run" might try to use
it. */
exec_close ();
- error (_("\"%s\": not in executable format: %s"),
- scratch_pathname,
- gdb_bfd_errmsg (bfd_get_error (), matching));
+
+ if (is_core != 0)
+ throw_error (IS_CORE_ERROR,
+ _("\"%s\" is a core file.\n"
+ "Please specify an executable to debug."),
+ scratch_pathname);
+ else
+ error (_("\"%s\": not in executable format: %s"),
+ scratch_pathname,
+ gdb_bfd_errmsg (bfd_get_error (), matching));
}
/* FIXME - This should only be run for RS6000, but the ifdef is a poor
--- ./gdb/main.c 2010-04-11 22:31:30.000000000 +0200
+++ ./gdb/main.c 2010-04-11 22:31:47.000000000 +0200
@@ -241,6 +241,36 @@ captured_command_loop (void *data)
return 1;
}
+/* Call exec_file_attach. If it detected FILENAME is a core file call
+ core_file_command. Print the original exec_file_attach error only if
+ core_file_command failed to find a matching executable. */
+
+static void
+exec_or_core_file_attach (char *filename, int from_tty)
+{
+ volatile struct gdb_exception e;
+
+ gdb_assert (exec_bfd == NULL);
+
+ TRY_CATCH (e, RETURN_MASK_ALL)
+ {
+ exec_file_attach (filename, from_tty);
+ }
+ if (e.reason < 0)
+ {
+ if (e.error == IS_CORE_ERROR)
+ {
+ core_file_command (filename, from_tty);
+
+ /* Iff the core file found its executable suppress the error message
+ from exec_file_attach. */
+ if (exec_bfd != NULL)
+ return;
+ }
+ throw_exception (e);
+ }
+}
+
static int
captured_main (void *data)
{
@@ -703,6 +733,8 @@ extern int gdbtk_test (char *);
{
symarg = argv[optind];
execarg = argv[optind];
+ if (optind + 1 == argc && corearg == NULL)
+ corearg = argv[optind];
optind++;
}
@@ -835,10 +867,25 @@ Excess command line arguments ignored. (
&& symarg != NULL
&& strcmp (execarg, symarg) == 0)
{
+ catch_command_errors_ftype *func;
+
+ /* Call exec_or_core_file_attach only if the file was specified as
+ a command line argument (and not an a command line option). */
+ if (corearg != NULL && strcmp (corearg, execarg) == 0)
+ {
+ func = exec_or_core_file_attach;
+ corearg = NULL;
+ }
+ else
+ func = exec_file_attach;
+
/* The exec file and the symbol-file are the same. If we can't
- open it, better only print one error message.
- catch_command_errors returns non-zero on success! */
- if (catch_command_errors (exec_file_attach, execarg, !batch, RETURN_MASK_ALL))
+ open it, better only print one error message.
+ catch_command_errors returns non-zero on success!
+ Do not load EXECARG as a symbol file if it has been already processed
+ as a core file. */
+ if (catch_command_errors (func, execarg, !batch, RETURN_MASK_ALL)
+ && core_bfd == NULL)
catch_command_errors (symbol_file_add_main, symarg, !batch, RETURN_MASK_ALL);
}
else

View File

@ -1,8 +1,8 @@
Index: gdb-7.0.50.20100203/bfd/elf-bfd.h
Index: gdb-7.1/bfd/elf-bfd.h
===================================================================
--- gdb-7.0.50.20100203.orig/bfd/elf-bfd.h 2010-02-02 13:37:39.000000000 +0100
+++ gdb-7.0.50.20100203/bfd/elf-bfd.h 2010-02-03 07:28:20.000000000 +0100
@@ -2140,7 +2140,7 @@ extern Elf_Internal_Phdr * _bfd_elf_find
--- gdb-7.1.orig/bfd/elf-bfd.h 2010-02-09 13:14:42.000000000 +0100
+++ gdb-7.1/bfd/elf-bfd.h 2010-05-16 20:22:38.000000000 +0200
@@ -2160,7 +2160,7 @@ extern Elf_Internal_Phdr * _bfd_elf_find
extern char *elfcore_write_note
(bfd *, char *, int *, const char *, int, const void *, int);
extern char *elfcore_write_prpsinfo
@ -11,11 +11,11 @@ Index: gdb-7.0.50.20100203/bfd/elf-bfd.h
extern char *elfcore_write_prstatus
(bfd *, char *, int *, long, int, const void *);
extern char * elfcore_write_pstatus
Index: gdb-7.0.50.20100203/bfd/elf.c
Index: gdb-7.1/bfd/elf.c
===================================================================
--- gdb-7.0.50.20100203.orig/bfd/elf.c 2010-02-02 13:37:39.000000000 +0100
+++ gdb-7.0.50.20100203/bfd/elf.c 2010-02-03 07:28:20.000000000 +0100
@@ -8459,6 +8459,7 @@ char *
--- gdb-7.1.orig/bfd/elf.c 2010-02-18 01:09:06.000000000 +0100
+++ gdb-7.1/bfd/elf.c 2010-05-16 20:25:15.000000000 +0200
@@ -8545,6 +8545,7 @@ char *
elfcore_write_prpsinfo (bfd *abfd,
char *buf,
int *bufsiz,
@ -23,7 +23,7 @@ Index: gdb-7.0.50.20100203/bfd/elf.c
const char *fname,
const char *psargs)
{
@@ -8485,9 +8486,15 @@ elfcore_write_prpsinfo (bfd *abfd,
@@ -8571,26 +8572,40 @@ elfcore_write_prpsinfo (bfd *abfd,
int note_type = NT_PRPSINFO;
#endif
@ -42,7 +42,16 @@ Index: gdb-7.0.50.20100203/bfd/elf.c
return elfcore_write_note (abfd, buf, bufsiz,
note_name, note_type, &data, sizeof (data));
}
@@ -8502,9 +8509,15 @@ elfcore_write_prpsinfo (bfd *abfd,
else
#endif
{
+/* gdb-6.8-bz254229-gcore-prpsinfo.patch misapplication glue. */
#if defined (HAVE_PSINFO_T)
psinfo_t data;
+/* gdb-6.8-bz254229-gcore-prpsinfo.patch misapplication glue. */
int note_type = NT_PSINFO;
#else
prpsinfo_t data;
int note_type = NT_PRPSINFO;
#endif
@ -61,10 +70,10 @@ Index: gdb-7.0.50.20100203/bfd/elf.c
return elfcore_write_note (abfd, buf, bufsiz,
note_name, note_type, &data, sizeof (data));
}
Index: gdb-7.0.50.20100203/gdb/amd64-linux-nat.c
Index: gdb-7.1/gdb/amd64-linux-nat.c
===================================================================
--- gdb-7.0.50.20100203.orig/gdb/amd64-linux-nat.c 2010-02-03 07:28:20.000000000 +0100
+++ gdb-7.0.50.20100203/gdb/amd64-linux-nat.c 2010-02-03 07:28:20.000000000 +0100
--- gdb-7.1.orig/gdb/amd64-linux-nat.c 2010-05-16 20:22:38.000000000 +0200
+++ gdb-7.1/gdb/amd64-linux-nat.c 2010-05-16 20:22:38.000000000 +0200
@@ -140,6 +140,7 @@ static int amd64_linux_gregset32_reg_off
static char *
@ -98,10 +107,10 @@ Index: gdb-7.0.50.20100203/gdb/amd64-linux-nat.c
}
static void
Index: gdb-7.0.50.20100203/gdb/fbsd-nat.c
Index: gdb-7.1/gdb/fbsd-nat.c
===================================================================
--- gdb-7.0.50.20100203.orig/gdb/fbsd-nat.c 2010-01-01 08:31:31.000000000 +0100
+++ gdb-7.0.50.20100203/gdb/fbsd-nat.c 2010-02-03 07:28:20.000000000 +0100
--- gdb-7.1.orig/gdb/fbsd-nat.c 2010-01-01 08:31:31.000000000 +0100
+++ gdb-7.1/gdb/fbsd-nat.c 2010-05-16 20:22:38.000000000 +0200
@@ -211,6 +211,7 @@ fbsd_make_corefile_notes (bfd *obfd, int
psargs = reconcat (psargs, psargs, " ", get_inferior_args (), NULL);
@ -110,10 +119,10 @@ Index: gdb-7.0.50.20100203/gdb/fbsd-nat.c
fname, psargs);
}
Index: gdb-7.0.50.20100203/gdb/linux-nat.c
Index: gdb-7.1/gdb/linux-nat.c
===================================================================
--- gdb-7.0.50.20100203.orig/gdb/linux-nat.c 2010-02-03 07:28:20.000000000 +0100
+++ gdb-7.0.50.20100203/gdb/linux-nat.c 2010-02-03 07:28:20.000000000 +0100
--- gdb-7.1.orig/gdb/linux-nat.c 2010-05-16 20:22:38.000000000 +0200
+++ gdb-7.1/gdb/linux-nat.c 2010-05-16 20:22:38.000000000 +0200
@@ -56,6 +56,7 @@
#include "terminal.h"
#include <sys/vfs.h>
@ -131,7 +140,7 @@ Index: gdb-7.0.50.20100203/gdb/linux-nat.c
char *(*linux_elfcore_write_prstatus)
(bfd *, char *, int *, long, int, const void *) = elfcore_write_prstatus;
static char *
@@ -4422,6 +4423,159 @@ linux_spu_make_corefile_notes (bfd *obfd
@@ -4507,6 +4508,159 @@ linux_spu_make_corefile_notes (bfd *obfd
return args.note_data;
}
@ -291,7 +300,7 @@ Index: gdb-7.0.50.20100203/gdb/linux-nat.c
/* Fills the "to_make_corefile_note" target vector. Builds the note
section for a corefile, and returns it in a malloc buffer. */
@@ -4442,8 +4596,14 @@ linux_nat_make_corefile_notes (bfd *obfd
@@ -4527,8 +4681,14 @@ linux_nat_make_corefile_notes (bfd *obfd
if (get_exec_file (0))
{
@ -306,7 +315,7 @@ Index: gdb-7.0.50.20100203/gdb/linux-nat.c
if (get_inferior_args ())
{
char *string_end;
@@ -4459,9 +4619,15 @@ linux_nat_make_corefile_notes (bfd *obfd
@@ -4544,9 +4704,15 @@ linux_nat_make_corefile_notes (bfd *obfd
psargs_end - string_end);
}
}
@ -324,10 +333,10 @@ Index: gdb-7.0.50.20100203/gdb/linux-nat.c
}
/* Dump information for threads. */
Index: gdb-7.0.50.20100203/gdb/linux-nat.h
Index: gdb-7.1/gdb/linux-nat.h
===================================================================
--- gdb-7.0.50.20100203.orig/gdb/linux-nat.h 2010-02-03 07:28:19.000000000 +0100
+++ gdb-7.0.50.20100203/gdb/linux-nat.h 2010-02-03 07:28:20.000000000 +0100
--- gdb-7.1.orig/gdb/linux-nat.h 2010-05-16 20:22:37.000000000 +0200
+++ gdb-7.1/gdb/linux-nat.h 2010-05-16 20:22:38.000000000 +0200
@@ -173,7 +173,7 @@ int linux_nat_core_of_thread_1 (ptid_t p
/* These functions make elfcore note sections.
They may get overriden by code adjusting data for multi-target builds. */
@ -337,11 +346,11 @@ Index: gdb-7.0.50.20100203/gdb/linux-nat.h
extern char *(*linux_elfcore_write_prstatus)
(bfd *, char *, int *, long, int, const void *);
extern char *(*linux_elfcore_write_prfpreg)
Index: gdb-7.0.50.20100203/gdb/procfs.c
Index: gdb-7.1/gdb/procfs.c
===================================================================
--- gdb-7.0.50.20100203.orig/gdb/procfs.c 2010-01-28 09:19:29.000000000 +0100
+++ gdb-7.0.50.20100203/gdb/procfs.c 2010-02-03 07:28:20.000000000 +0100
@@ -6186,6 +6186,7 @@ procfs_make_note_section (bfd *obfd, int
--- gdb-7.1.orig/gdb/procfs.c 2010-02-15 18:35:49.000000000 +0100
+++ gdb-7.1/gdb/procfs.c 2010-05-16 20:22:38.000000000 +0200
@@ -6184,6 +6184,7 @@ procfs_make_note_section (bfd *obfd, int
note_data = (char *) elfcore_write_prpsinfo (obfd,
note_data,
note_size,

View File

@ -0,0 +1,104 @@
Archer-upstreamed:
http://sourceware.org/ml/archer/2010-q2/msg00031.html
--- ./gdb/breakpoint.c 2010-05-29 01:12:32.000000000 +0200
+++ ./gdb/breakpoint.c 2010-05-29 01:22:21.000000000 +0200
@@ -1679,14 +1679,11 @@ create_exception_master_breakpoint (void
debug_hook = lookup_minimal_symbol_text ("_Unwind_DebugHook", objfile);
if (debug_hook != NULL)
{
- CORE_ADDR pc;
struct breakpoint *b;
- pc = find_function_start_pc (get_objfile_arch (objfile),
- SYMBOL_VALUE_ADDRESS (debug_hook),
- SYMBOL_OBJ_SECTION (debug_hook));
b = create_internal_breakpoint (get_objfile_arch (objfile),
- pc, bp_exception_master);
+ SYMBOL_VALUE_ADDRESS (debug_hook),
+ bp_exception_master);
b->addr_string = xstrdup ("_Unwind_DebugHook");
b->enable_state = bp_disabled;
}
--- ./gdb/testsuite/gdb.cp/cxxexec.cc 1970-01-01 01:00:00.000000000 +0100
+++ ./gdb/testsuite/gdb.cp/cxxexec.cc 2010-05-29 01:18:56.000000000 +0200
@@ -0,0 +1,25 @@
+/* This test script is part of GDB, the GNU debugger.
+
+ 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/>. */
+
+#include <unistd.h>
+
+int
+main()
+{
+ execlp ("true", "true", NULL);
+ return 1;
+}
--- ./gdb/testsuite/gdb.cp/cxxexec.exp 1970-01-01 01:00:00.000000000 +0100
+++ ./gdb/testsuite/gdb.cp/cxxexec.exp 2010-05-29 01:29:25.000000000 +0200
@@ -0,0 +1,51 @@
+# 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/>.
+
+if { [skip_cplus_tests] } { continue }
+
+set testfile cxxexec
+if { [prepare_for_testing ${testfile}.exp ${testfile} ${testfile}.cc {c++ debug}] } {
+ return -1
+}
+
+runto_main
+
+# We could stop after `continue' again at `main'.
+delete_breakpoints
+
+set test "p _Unwind_DebugHook"
+gdb_test_multiple $test $test {
+ -re " = .* 0x\[0-9a-f\].*\r\n$gdb_prompt $" {
+ pass $test
+ }
+ -re "\r\nNo symbol .*\r\n$gdb_prompt $" {
+ xfail $test
+ untested ${testfile}.exp
+ return -1
+ }
+}
+
+set test continue
+gdb_test_multiple $test $test {
+ -re "Cannot access memory at address 0x\[0-9a-f\]+\r\n$gdb_prompt $" {
+ fail $test
+ }
+ -re "\r\n$gdb_prompt $" {
+ pass $test
+ }
+}
+
+# `info inferiors' can show <null> on older GDBs.
+gdb_test "info threads" "info threads" "program finished"

View File

@ -0,0 +1,43 @@
2010-06-01 Chris Moller <cmoller@redhat.com>
* python/libstdcxx/v6/printers.py (StdVectorPrinter): Add
detection for matrices as nested vectors.
Index: libstdc++-v3/python/libstdcxx/v6/printers.py
===================================================================
--- ./libstdc++-v3-python-r155978/libstdcxx/v6/printers.py (revision 159937)
+++ ./libstdc++-v3-python-r155978/libstdcxx/v6/printers.py (working copy)
@@ -19,6 +19,9 @@
import itertools
import re
+vector_sig = 'std::vector'
+vector_regex = re.compile('^' + vector_sig + '<.*>$')
+
class StdPointerPrinter:
"Print a smart pointer of some kind"
@@ -186,7 +189,13 @@
% (self.typename, int (finish - start), int (end - start)))
def display_hint(self):
- return 'array'
+ itype0 = self.val.type.template_argument(0)
+ itag = itype0.tag
+ if itag and re.match(vector_regex, itag):
+ rc = 'matrix'
+ else:
+ rc = 'array'
+ return rc
class StdVectorIteratorPrinter:
"Print std::vector::iterator"
@@ -692,7 +701,7 @@
pretty_printers_dict[re.compile('^std::set<.*>$')] = lambda val: StdSetPrinter("std::set", val)
pretty_printers_dict[re.compile('^std::stack<.*>$')] = lambda val: StdStackOrQueuePrinter("std::stack", val)
pretty_printers_dict[re.compile('^std::unique_ptr<.*>$')] = UniquePointerPrinter
- pretty_printers_dict[re.compile('^std::vector<.*>$')] = lambda val: StdVectorPrinter("std::vector", val)
+ pretty_printers_dict[vector_regex] = lambda val: StdVectorPrinter(vector_sig, val)
# vector<bool>
# Printer registrations for classes compiled with -D_GLIBCXX_DEBUG.

View File

@ -0,0 +1,427 @@
commit e5ea8d026015c2a0c7774788b425914857de1ffb
Author: pmuldoon <pmuldoon>
Date: Wed Apr 14 12:02:42 2010 +0000
2010-04-14 Phil Muldoon <pmuldoon@redhat.com>
PR python/11381
* python/py-prettyprint.c (pretty_print_one_value): Test for
Py_None.
(print_string_repr): Test for Py_None. Set flags accordingly.
Return value depending on return type.
(print_children): Take a value indicating whether data was printed
before this function was called. Alter output accordingly.
(apply_val_pretty_printer): Capture return value from
print_string_repr and pass to print_children.
2010-04-14 Phil Muldoon <pmuldoon@redhat.com>
* gdb.python/py-prettyprint.py (NoStringContainerPrinter): New printer.
* gdb.python/py-prettyprint.c: Add justchildren struct, typedefs.
* gdb.python/py-prettyprint.exp: New test for to_string returning None.
* gdb.python/py-mi.exp: New test for to_string returning None.
2010-04-14 Phil Muldoon <pmuldoon@redhat.com>
* gdb.texinfo (Pretty Printing): Document behaviour when to_string
returns None.
### a/gdb/ChangeLog
### b/gdb/ChangeLog
## -1,3 +1,16 @@
+2010-04-14 Phil Muldoon <pmuldoon@redhat.com>
+
+ PR python/11381
+
+ * python/py-prettyprint.c (pretty_print_one_value): Test for
+ Py_None.
+ (print_string_repr): Test for Py_None. Set flags accordingly.
+ Return value depending on return type.
+ (print_children): Take a value indicating whether data was printed
+ before this function was called. Alter output accordingly.
+ (apply_val_pretty_printer): Capture return value from
+ print_string_repr and pass to print_children.
+
2010-04-13 Mark Kettenis <kettenis@gnu.org>
PR corefiles/11481
### a/gdb/doc/ChangeLog
### b/gdb/doc/ChangeLog
## -1,3 +1,8 @@
+2010-04-14 Phil Muldoon <pmuldoon@redhat.com>
+
+ * gdb.texinfo (Pretty Printing): Document behaviour when to_string
+ returns None.
+
2010-04-09 Stan Shebs <stan@codesourcery.com>
* gdb.texinfo (gdb/mi Tracepoint Commands) <-trace-status>:
Index: gdb-7.1/gdb/doc/gdb.texinfo
===================================================================
--- gdb-7.1.orig/gdb/doc/gdb.texinfo 2010-06-30 03:22:07.000000000 +0200
+++ gdb-7.1/gdb/doc/gdb.texinfo 2010-06-30 03:22:20.000000000 +0200
@@ -20344,6 +20344,9 @@ the resulting value. Again, this may re
pretty-printer. Python scalars (integers, floats, and booleans) and
strings are convertible to @code{gdb.Value}; other types are not.
+Finally, if this method returns @code{None} then no further operations
+are peformed in this method and nothing is printed.
+
If the result is not one of these types, an exception is raised.
@end defop
Index: gdb-7.1/gdb/python/py-prettyprint.c
===================================================================
--- gdb-7.1.orig/gdb/python/py-prettyprint.c 2010-06-30 03:22:02.000000000 +0200
+++ gdb-7.1/gdb/python/py-prettyprint.c 2010-06-30 03:23:38.000000000 +0200
@@ -125,9 +125,12 @@ find_pretty_printer (PyObject *value)
/* Pretty-print a single value, via the printer object PRINTER.
If the function returns a string, a PyObject containing the string
- is returned. Otherwise, if the function returns a value,
- *OUT_VALUE is set to the value, and NULL is returned. On error,
- *OUT_VALUE is set to NULL, and NULL is returned. */
+ is returned. If the function returns Py_NONE that means the pretty
+ printer returned the Python None as a value. Otherwise, if the
+ function returns a value, *OUT_VALUE is set to the value, and NULL
+ is returned. On error, *OUT_VALUE is set to NULL, and NULL is
+ returned. */
+
static PyObject *
pretty_print_one_value (PyObject *printer, struct value **out_value)
{
@@ -140,7 +143,8 @@ pretty_print_one_value (PyObject *printe
result = PyObject_CallMethodObjArgs (printer, gdbpy_to_string_cst, NULL);
if (result)
{
- if (! gdbpy_is_string (result) && ! gdbpy_is_lazy_string (result))
+ if (! gdbpy_is_string (result) && ! gdbpy_is_lazy_string (result)
+ && result != Py_None)
{
*out_value = convert_value_from_python (result);
if (PyErr_Occurred ())
@@ -184,8 +188,11 @@ gdbpy_get_display_hint (PyObject *printe
}
/* Helper for apply_val_pretty_printer which calls to_string and
- formats the result. */
-static void
+ formats the result. If the value returnd is Py_None, nothing is
+ printed and the function returns a 1; in all other cases data is
+ printed as given by the pretty printer and the function returns 0.
+*/
+static int
print_string_repr (PyObject *printer, const char *hint,
struct ui_file *stream, int recurse,
const struct value_print_options *options,
@@ -194,52 +201,58 @@ print_string_repr (PyObject *printer, co
{
struct value *replacement = NULL;
PyObject *py_str = NULL;
+ int is_py_none = 0;
py_str = pretty_print_one_value (printer, &replacement);
if (py_str)
{
- gdb_byte *output = NULL;
- long length;
- struct type *type;
- char *encoding = NULL;
- PyObject *string = NULL;
- int is_lazy;
-
- is_lazy = gdbpy_is_lazy_string (py_str);
- if (is_lazy)
- output = gdbpy_extract_lazy_string (py_str, &type, &length, &encoding);
+ if (py_str == Py_None)
+ is_py_none = 1;
else
{
- string = python_string_to_target_python_string (py_str);
- if (string)
+ gdb_byte *output = NULL;
+ long length;
+ struct type *type;
+ char *encoding = NULL;
+ PyObject *string = NULL;
+ int is_lazy;
+
+ is_lazy = gdbpy_is_lazy_string (py_str);
+ if (is_lazy)
+ output = gdbpy_extract_lazy_string (py_str, &type, &length, &encoding);
+ else
{
- output = PyString_AsString (string);
- length = PyString_Size (string);
- type = builtin_type (gdbarch)->builtin_char;
+ string = python_string_to_target_python_string (py_str);
+ if (string)
+ {
+ output = PyString_AsString (string);
+ length = PyString_Size (string);
+ type = builtin_type (gdbarch)->builtin_char;
+ }
+ else
+ gdbpy_print_stack ();
+
+ }
+
+ if (output)
+ {
+ if (is_lazy || (hint && !strcmp (hint, "string")))
+ LA_PRINT_STRING (stream, type, output, length, encoding,
+ 0, options);
+ else
+ fputs_filtered (output, stream);
}
else
gdbpy_print_stack ();
- }
-
- if (output)
- {
- if (is_lazy || (hint && !strcmp (hint, "string")))
- LA_PRINT_STRING (stream, type, output, length, encoding,
- 0, options);
+ if (string)
+ Py_DECREF (string);
else
- fputs_filtered (output, stream);
- }
- else
- gdbpy_print_stack ();
-
- if (string)
- Py_DECREF (string);
- else
- xfree (output);
+ xfree (output);
- xfree (encoding);
- Py_DECREF (py_str);
+ xfree (encoding);
+ Py_DECREF (py_str);
+ }
}
else if (replacement)
{
@@ -250,6 +263,8 @@ print_string_repr (PyObject *printer, co
}
else
gdbpy_print_stack ();
+
+ return is_py_none;
}
static void
@@ -328,12 +343,14 @@ push_dummy_python_frame ()
}
/* Helper for apply_val_pretty_printer that formats children of the
- printer, if any exist. */
+ printer, if any exist. If is_py_none is true, then nothing has
+ been printed by to_string, and format output accordingly. */
static void
print_children (PyObject *printer, const char *hint,
struct ui_file *stream, int recurse,
const struct value_print_options *options,
- const struct language_defn *language)
+ const struct language_defn *language,
+ int is_py_none)
{
int is_map, is_array, done_flag, pretty;
unsigned int i;
@@ -413,7 +430,13 @@ print_children (PyObject *printer, const
2. Arrays. Always print a ",".
3. Other. Always print a ",". */
if (i == 0)
- fputs_filtered (" = {", stream);
+ {
+ if (is_py_none)
+ fputs_filtered ("{", stream);
+ else
+ fputs_filtered (" = {", stream);
+ }
+
else if (! is_map || i % 2 == 0)
fputs_filtered (pretty ? "," : ", ", stream);
@@ -537,7 +560,7 @@ apply_val_pretty_printer (struct type *t
char *hint = NULL;
struct cleanup *cleanups;
int result = 0;
-
+ int is_py_none = 0;
cleanups = ensure_python_env (gdbarch, language);
/* Instantiate the printer. */
@@ -562,9 +585,11 @@ apply_val_pretty_printer (struct type *t
make_cleanup (free_current_contents, &hint);
/* Print the section */
- print_string_repr (printer, hint, stream, recurse, options, language,
- gdbarch);
- print_children (printer, hint, stream, recurse, options, language);
+ is_py_none = print_string_repr (printer, hint, stream, recurse,
+ options, language, gdbarch);
+ print_children (printer, hint, stream, recurse, options, language,
+ is_py_none);
+
result = 1;
Index: gdb-7.1/gdb/testsuite/gdb.python/py-mi.exp
===================================================================
--- gdb-7.1.orig/gdb/testsuite/gdb.python/py-mi.exp 2010-01-14 09:03:37.000000000 +0100
+++ gdb-7.1/gdb/testsuite/gdb.python/py-mi.exp 2010-06-30 03:22:20.000000000 +0200
@@ -61,6 +61,16 @@ mi_list_varobj_children container {
mi_delete_varobj container "delete varobj"
+mi_create_dynamic_varobj nscont nstype \
+ "create nscont varobj, no pretty-printing"
+
+mi_list_varobj_children nscont {
+ { nscont.len len 0 int }
+ { nscont.elements elements 1 "int ." }
+} "examine nscont children=0, no pretty-printing"
+
+mi_delete_varobj nscont "delete varobj"
+
mi_gdb_test "-enable-pretty-printing" ""
mi_create_varobj_checked string string_1 \
@@ -239,4 +249,29 @@ mi_continue_to_line \
mi_varobj_update_with_type_change container int 0 "update after type change"
+
+mi_continue_to_line \
+ [gdb_get_line_number {break to inspect struct and union} ${testfile}.c] \
+ "step to outer breakpoint"
+
+mi_create_dynamic_varobj nscont nstype \
+ "create nstype varobj"
+
+mi_list_varobj_children nscont {
+ { {nscont.\[0\]} {\[0\]} 0 int }
+ { {nscont.\[1\]} {\[1\]} 0 int }
+} "list children after setting update range"
+
+mi_gdb_test "-var-set-visualizer nscont None" \
+ "\\^done" \
+ "clear visualizer"
+
+mi_gdb_test "-var-update nscont" \
+ "\\^done,changelist=\\\[\\\]" \
+ "varobj update after clearing"
+
+mi_gdb_test "-var-set-visualizer nscont gdb.default_visualizer" \
+ "\\^done" \
+ "choose default visualizer"
+
remote_file host delete ${remote_python_file}
Index: gdb-7.1/gdb/testsuite/gdb.python/py-prettyprint.c
===================================================================
--- gdb-7.1.orig/gdb/testsuite/gdb.python/py-prettyprint.c 2010-01-14 09:03:37.000000000 +0100
+++ gdb-7.1/gdb/testsuite/gdb.python/py-prettyprint.c 2010-06-30 03:22:20.000000000 +0200
@@ -119,6 +119,15 @@ typedef struct string_repr
/* This lets us avoid malloc. */
int array[100];
+int narray[10];
+
+struct justchildren
+{
+ int len;
+ int *elements;
+};
+
+typedef struct justchildren nostring_type;
struct container
{
@@ -196,7 +205,9 @@ main ()
const struct string_repr cstring = { { "const string" } };
/* Clearing by being `static' could invoke an other GDB C++ bug. */
struct nullstr nullstr;
-
+ nostring_type nstype;
+ nstype.elements = narray;
+ nstype.len = 0;
init_ss(&ss, 1, 2);
init_ss(ssa+0, 3, 4);
@@ -249,5 +260,9 @@ main ()
do_nothing ();
#endif
+ nstype.elements[0] = 7;
+ nstype.elements[1] = 42;
+ nstype.len = 2;
+
return 0; /* break to inspect struct and union */
}
Index: gdb-7.1/gdb/testsuite/gdb.python/py-prettyprint.exp
===================================================================
--- gdb-7.1.orig/gdb/testsuite/gdb.python/py-prettyprint.exp 2010-06-30 03:22:02.000000000 +0200
+++ gdb-7.1/gdb/testsuite/gdb.python/py-prettyprint.exp 2010-06-30 03:24:14.000000000 +0200
@@ -115,6 +115,7 @@ proc run_lang_tests {lang} {
gdb_test "print nullstr" "RuntimeError: Error reading string from inferior.*"
+ gdb_test "print nstype" " = {$nl *.0. = 7,$nl *.1. = 42$nl}"
gdb_test "continue" "Program exited normally\."
remote_file host delete ${remote_python_file}
Index: gdb-7.1/gdb/testsuite/gdb.python/py-prettyprint.py
===================================================================
--- gdb-7.1.orig/gdb/testsuite/gdb.python/py-prettyprint.py 2010-01-14 09:03:37.000000000 +0100
+++ gdb-7.1/gdb/testsuite/gdb.python/py-prettyprint.py 2010-06-30 03:22:20.000000000 +0200
@@ -53,6 +53,33 @@ class ContainerPrinter:
def children(self):
return self._iterator(self.val['elements'], self.val['len'])
+# Test a printer where to_string is None
+class NoStringContainerPrinter:
+ class _iterator:
+ def __init__ (self, pointer, len):
+ self.start = pointer
+ self.pointer = pointer
+ self.end = pointer + len
+
+ def __iter__(self):
+ return self
+
+ def next(self):
+ if self.pointer == self.end:
+ raise StopIteration
+ result = self.pointer
+ self.pointer = self.pointer + 1
+ return ('[%d]' % int (result - self.start), result.dereference())
+
+ def __init__(self, val):
+ self.val = val
+
+ def to_string(self):
+ return None
+
+ def children(self):
+ return self._iterator(self.val['elements'], self.val['len'])
+
class pp_s:
def __init__(self, val):
self.val = val
@@ -190,8 +217,10 @@ def register_pretty_printers ():
# both the C and C++ cases.
pretty_printers_dict[re.compile ('^struct string_repr$')] = string_print
pretty_printers_dict[re.compile ('^struct container$')] = ContainerPrinter
+ pretty_printers_dict[re.compile ('^struct justchildren$')] = NoStringContainerPrinter
pretty_printers_dict[re.compile ('^string_repr$')] = string_print
pretty_printers_dict[re.compile ('^container$')] = ContainerPrinter
+ pretty_printers_dict[re.compile ('^justchildren$')] = NoStringContainerPrinter
pretty_printers_dict[re.compile ('^struct ns$')] = pp_ns
pretty_printers_dict[re.compile ('^ns$')] = pp_ns

View File

@ -0,0 +1,404 @@
2010-05-31 Chris Moller <cmoller@redhat.com>
* python/py-prettyprint.c (print_children): Add formatting for
matrices. (apply_val_pretty_printer): Detect and deal with matrix
hints.
2010-05-31 Chris Moller <cmoller@redhat.com>
* gdb.python/Makefile.in (EXECUTABLES): Added pr10659.
* gdb.python/pr10659.cc: New file.
* gdb.python/pr10659.exp. New file.
* gdb.python/pr10659.py: New file.
Index: gdb-7.1/gdb/valprint.h
===================================================================
--- gdb-7.1.orig/gdb/valprint.h 2010-06-30 14:02:16.000000000 +0200
+++ gdb-7.1/gdb/valprint.h 2010-06-30 14:35:24.000000000 +0200
@@ -90,6 +90,9 @@ struct value_print_options
/* If nonzero, print the value in "summary" form. */
int summary;
+
+ /* Affects pretty printing of matrices. */
+ int prettyprint_matrix;
};
/* The global print options set by the user. In general this should
Index: gdb-7.1/gdb/python/py-prettyprint.c
===================================================================
--- gdb-7.1.orig/gdb/python/py-prettyprint.c 2010-06-30 14:01:40.000000000 +0200
+++ gdb-7.1/gdb/python/py-prettyprint.c 2010-06-30 14:34:49.000000000 +0200
@@ -385,7 +385,8 @@ print_children (PyObject *printer, const
/* Use the prettyprint_arrays option if we are printing an array,
and the pretty option otherwise. */
- pretty = is_array ? options->prettyprint_arrays : options->pretty;
+ pretty = (is_array || options->prettyprint_matrix) ?
+ options->prettyprint_arrays : options->pretty;
/* Manufacture a dummy Python frame to work around Python 2.4 bug,
where it insists on having a non-NULL tstate->frame when
@@ -397,6 +398,9 @@ print_children (PyObject *printer, const
goto done;
}
make_cleanup_py_decref (frame);
+
+ if (options->prettyprint_matrix && recurse == 0)
+ fputs_filtered ("\n", stream);
done_flag = 0;
for (i = 0; i < options->print_max; ++i)
@@ -431,12 +435,23 @@ print_children (PyObject *printer, const
3. Other. Always print a ",". */
if (i == 0)
{
- if (is_py_none)
- fputs_filtered ("{", stream);
- else
- fputs_filtered (" = {", stream);
+ if (options->prettyprint_matrix && recurse == 0)
+ print_spaces_filtered (2 + 2 * recurse, stream);
+ if (is_py_none)
+ {
+ if (options->prettyprint_matrix && strcmp (hint, "array"))
+ {
+ fputs_filtered ("{\n", stream);
+ print_spaces_filtered (4 + 2 * recurse, stream);
+ }
+ else
+ fputs_filtered ("{", stream);
+ }
+ else
+ fputs_filtered (" = {", stream);
}
-
+ else if (options->prettyprint_matrix)
+ print_spaces_filtered (4 + 2 * recurse, stream);
else if (! is_map || i % 2 == 0)
fputs_filtered (pretty ? "," : ", ", stream);
@@ -465,6 +480,10 @@ print_children (PyObject *printer, const
if (is_map && i % 2 == 0)
fputs_filtered ("[", stream);
+ else if (options->prettyprint_matrix)
+ {
+ /* Force a do-nothing. */
+ }
else if (is_array)
{
/* We print the index, not whatever the child method
@@ -539,7 +558,12 @@ print_children (PyObject *printer, const
fputs_filtered ("\n", stream);
print_spaces_filtered (2 * recurse, stream);
}
- fputs_filtered ("}", stream);
+ if (options->prettyprint_matrix)
+ {
+ print_spaces_filtered (4 * recurse, stream);
+ fputs_filtered ("}\n", stream);
+ }
+ else fputs_filtered ("}", stream);
}
done:
@@ -561,6 +585,7 @@ apply_val_pretty_printer (struct type *t
struct cleanup *cleanups;
int result = 0;
int is_py_none = 0;
+ struct value_print_options *options_copy;
cleanups = ensure_python_env (gdbarch, language);
/* Instantiate the printer. */
@@ -582,12 +607,23 @@ apply_val_pretty_printer (struct type *t
/* If we are printing a map, we want some special formatting. */
hint = gdbpy_get_display_hint (printer);
+
+ if (recurse == 0)
+ {
+ options_copy = alloca (sizeof (struct value_print_options));
+ memcpy (options_copy, options, sizeof (struct value_print_options));
+ options_copy->prettyprint_matrix = hint && !strcmp (hint, "matrix");
+ }
+ else options_copy = (struct value_print_options *)options;
+
make_cleanup (free_current_contents, &hint);
/* Print the section */
- is_py_none = print_string_repr (printer, hint, stream, recurse,
- options, language, gdbarch);
- print_children (printer, hint, stream, recurse, options, language,
+ is_py_none = options_copy->prettyprint_matrix ?
+ 1 : print_string_repr (printer, hint, stream,
+ recurse, options_copy,
+ language, gdbarch);
+ print_children (printer, hint, stream, recurse, options_copy, language,
is_py_none);
result = 1;
Index: gdb-7.1/gdb/testsuite/gdb.python/pr10659.cc
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ gdb-7.1/gdb/testsuite/gdb.python/pr10659.cc 2010-06-30 14:34:49.000000000 +0200
@@ -0,0 +1,43 @@
+#include <list>
+#include <vector> // /usr/include/c++/4.4.1/bits/vector.tcc
+#include <iostream>
+
+using namespace std;
+
+int use_windows = 9999;
+
+int
+main(){
+ vector<int> test1(2,0);
+ test1[0]=8;
+ test1[1]=9;
+
+ vector< vector<int> > test2(3, vector<int>(2,0));
+ test2[0][0]=0;
+ test2[0][1]=1;
+ test2[1][0]=2;
+ test2[1][1]=3;
+ test2[2][0]=4;
+ test2[2][1]=5;
+
+#define NR_ROWS 2
+#define NR_COLS 3
+#define NR_PLANES 4
+ vector<int> rows(NR_ROWS, 0);
+ vector< vector<int> > columns(NR_COLS, rows);
+ vector< vector < vector<int> > > test3(NR_PLANES, columns);
+
+ cout << "rows.size() = " << rows.size()
+ << ", columns.size() = " << columns.size()
+ << ", test3.size() = " << test3.size() << "\n";
+
+ for (int i = 0; i < rows.size(); i++) {
+ for (int j = 0; j < columns.size(); j++) {
+ for (int k = 0; k < test3.size(); k++) {
+ test3[k][j][i] = k * 100 + j * 10 + i;
+ }
+ }
+ }
+
+ return 0; // break
+}
Index: gdb-7.1/gdb/testsuite/gdb.python/pr10659.exp
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ gdb-7.1/gdb/testsuite/gdb.python/pr10659.exp 2010-06-30 14:34:49.000000000 +0200
@@ -0,0 +1,82 @@
+#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 nl "\[\r\n\]+"
+
+set testfile pr10659
+set srcfile ${testfile}.cc
+if [prepare_for_testing $testfile.exp $testfile $srcfile {debug c++}] {
+ return -1
+}
+
+#if { [skip_python_tests] } { continue }
+
+gdb_test "python execfile(\"$srcdir/$subdir/pr10659.py\")" ""
+gdb_test "python gdb.pretty_printers = \[lookup_function\]" ""
+
+if ![runto_main] then {
+ fail "Can't run to main"
+ return
+}
+
+gdb_breakpoint [gdb_get_line_number "break"]
+gdb_continue_to_breakpoint "break"
+
+gdb_test "p test1" "vector of length 2, capacity 2 =.*"
+
+gdb_test "p test2" "= $nl {$nl {.*"
+
+# Complete result is:
+#
+# (gdb) p test2
+# $2 =
+# {
+# {0 1 }
+# {2 3 }
+# {4 5 }
+# }
+
+
+gdb_test "p test3" "= $nl {$nl {$nl {.*"
+
+# Complete result is:
+#
+# (gdb) p test3
+# $3 =
+# {
+# {
+# {0 1 }
+# {10 11 }
+# {20 21 }
+# }
+# {
+# {100 101 }
+# {110 111 }
+# {120 121 }
+# }
+# {
+# {200 201 }
+# {210 211 }
+# {220 221 }
+# }
+# {
+# {300 301 }
+# {310 311 }
+# {320 321 }
+# }
+# }
+#
+
+
Index: gdb-7.1/gdb/testsuite/gdb.python/pr10659.py
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ gdb-7.1/gdb/testsuite/gdb.python/pr10659.py 2010-06-30 14:34:49.000000000 +0200
@@ -0,0 +1,109 @@
+# Copyright (C) 2008, 2009 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/>.
+
+import gdb
+import itertools
+import re
+
+vector_sig = 'std::vector'
+vector_regex = re.compile('^' + vector_sig + '<.*>$')
+
+class FakeVectorPrinter:
+ "Print a std::vector"
+
+ class _iterator:
+ def __init__ (self, start, finish):
+ self.item = start
+ self.finish = finish
+ self.count = 0
+
+ def __iter__(self):
+ return self
+
+ def next(self):
+ if self.item == self.finish:
+ raise StopIteration
+ count = self.count
+ self.count = self.count + 1
+ elt = self.item.dereference()
+ self.item = self.item + 1
+ return ('[%d]' % count, elt)
+
+ def __init__(self, typename, val):
+ self.typename = typename
+ self.val = val
+
+ def children(self):
+ return self._iterator(self.val['_M_impl']['_M_start'],
+ self.val['_M_impl']['_M_finish'])
+
+ def to_string(self):
+ start = self.val['_M_impl']['_M_start']
+ finish = self.val['_M_impl']['_M_finish']
+ end = self.val['_M_impl']['_M_end_of_storage']
+ return ('std::vector of length %d, capacity %d'
+ % (int (finish - start), int (end - start)))
+
+ def display_hint(self):
+ itype0 = self.val.type.template_argument(0)
+ itag = itype0.tag
+ if itag and re.match(vector_regex, itag):
+ rc = 'matrix'
+ else:
+ rc = 'array'
+ return rc
+
+def register_libstdcxx_printers (obj):
+ "Register libstdc++ pretty-printers with objfile Obj."
+
+ if obj == None:
+ obj = gdb
+
+ obj.pretty_printers.append (lookup_function)
+
+def lookup_function (val):
+ "Look-up and return a pretty-printer that can print val."
+
+ # Get the type.
+ type = val.type;
+
+ # If it points to a reference, get the reference.
+ if type.code == gdb.TYPE_CODE_REF:
+ type = type.target ()
+
+ # Get the unqualified type, stripped of typedefs.
+ type = type.unqualified ().strip_typedefs ()
+
+ # Get the type name.
+ typename = type.tag
+ if typename == None:
+ return None
+
+ # Iterate over local dictionary of types to determine
+ # if a printer is registered for that type. Return an
+ # instantiation of the printer if found.
+ for function in fake_pretty_printers_dict:
+ if function.search (typename):
+ return fake_pretty_printers_dict[function] (val)
+
+ # Cannot find a pretty printer. Return None.
+ return None
+
+def build_libfakecxx_dictionary ():
+ fake_pretty_printers_dict[vector_regex] = lambda val: FakeVectorPrinter(vector_sig, val)
+
+fake_pretty_printers_dict = {}
+
+build_libfakecxx_dictionary ()
Index: gdb-7.1/gdb/valprint.c
===================================================================
--- gdb-7.1.orig/gdb/valprint.c 2010-06-30 13:51:26.000000000 +0200
+++ gdb-7.1/gdb/valprint.c 2010-06-30 14:35:41.000000000 +0200
@@ -83,7 +83,8 @@ struct value_print_options user_print_op
1, /* static_field_print */
1, /* pascal_static_field_print */
0, /* raw */
- 0 /* summary */
+ 0, /* summary */
+ 0 /* prettyprint_matrix */
};
/* Initialize *OPTS to be a copy of the user print options. */

View File

@ -0,0 +1,59 @@
06e357f534abcf8912e4fd597daae8f1387d631c
Fix compatibility with: FYI: fix BINOP_SUBSCRIPT with pieced arrays
http://sourceware.org/ml/gdb-patches/2010-05/msg00281.html
2010-05-30 Jan Kratochvil <jan.kratochvil@redhat.com>
* valarith.c (binop_user_defined_p): Return 0 on ARG1 or ARG2 being
TYPE_DYNAMIC.
* value.c (coerce_ref): Use object_address_get_data resolution for
TYPE_DYNAMIC ARG.
[ Backported. ]
Index: gdb-7.1/gdb/valarith.c
===================================================================
--- gdb-7.1.orig/gdb/valarith.c 2010-05-30 18:54:28.000000000 +0200
+++ gdb-7.1/gdb/valarith.c 2010-05-30 18:54:43.000000000 +0200
@@ -309,6 +309,10 @@ int
binop_user_defined_p (enum exp_opcode op,
struct value *arg1, struct value *arg2)
{
+ /* FIXME: We should support user defined ops for dynamic types. */
+ if (TYPE_DYNAMIC (value_type (arg1)) || TYPE_DYNAMIC (value_type (arg2)))
+ return 0;
+
return binop_types_user_defined_p (op, value_type (arg1), value_type (arg2));
}
Index: gdb-7.1/gdb/value.c
===================================================================
--- gdb-7.1.orig/gdb/value.c 2010-05-30 18:54:36.000000000 +0200
+++ gdb-7.1/gdb/value.c 2010-05-30 18:55:52.000000000 +0200
@@ -2400,7 +2400,24 @@ value_from_decfloat (struct type *type,
struct value *
coerce_ref (struct value *arg)
{
- struct type *value_type_arg_tmp = check_typedef (value_type (arg));
+ struct type *value_type_arg_tmp;
+
+ if (TYPE_DYNAMIC (value_type (arg)))
+ {
+ struct cleanup *cleanups = make_cleanup (null_cleanup, NULL);
+ CORE_ADDR address;
+
+ value_type_arg_tmp = value_type (arg);
+ address = value_raw_address (arg);
+ if (! object_address_get_data (value_type_arg_tmp, &address))
+ error (_("Attempt to coerce non-valid value."));
+ CHECK_TYPEDEF (value_type_arg_tmp);
+ arg = value_at_lazy (value_type_arg_tmp, address);
+ do_cleanups (cleanups);
+ }
+ else
+ value_type_arg_tmp = check_typedef (value_type (arg));
+
if (TYPE_CODE (value_type_arg_tmp) == TYPE_CODE_REF)
arg = value_at_lazy (TYPE_TARGET_TYPE (value_type_arg_tmp),
unpack_pointer (value_type (arg),

View File

@ -0,0 +1,80 @@
commit 96c23bfd2863bcca7388653a7bc4c9f8a64a03be
Author: Ulrich Weigand <uweigand@de.ibm.com>
Date: Fri Feb 26 12:48:17 2010 +0000
* dwarf2loc.c (struct piece_closure): Remove ARCH member,
add ADDR_SIZE member.
(allocate_piece_closure): Update.
(copy_pieced_value_closure): Likewise.
(dwarf2_evaluate_loc_desc): Likewise.
(read_pieced_value): Use DWARF address size instead of
GDB's gdbarch_addr_bit as size of values on the DWARF stack.
diff --git a/gdb/dwarf2loc.c b/gdb/dwarf2loc.c
index 1c4d057..20ede3e 100644
--- a/gdb/dwarf2loc.c
+++ b/gdb/dwarf2loc.c
@@ -232,8 +232,8 @@ struct piece_closure
/* The number of pieces used to describe this variable. */
int n_pieces;
- /* The architecture, used only for DWARF_VALUE_STACK. */
- struct gdbarch *arch;
+ /* The target address size, used only for DWARF_VALUE_STACK. */
+ int addr_size;
/* The pieces themselves. */
struct dwarf_expr_piece *pieces;
@@ -244,12 +244,12 @@ struct piece_closure
static struct piece_closure *
allocate_piece_closure (int n_pieces, struct dwarf_expr_piece *pieces,
- struct gdbarch *arch)
+ int addr_size)
{
struct piece_closure *c = XZALLOC (struct piece_closure);
c->n_pieces = n_pieces;
- c->arch = arch;
+ c->addr_size = addr_size;
c->pieces = XCALLOC (n_pieces, struct dwarf_expr_piece);
memcpy (c->pieces, pieces, n_pieces * sizeof (struct dwarf_expr_piece));
@@ -298,13 +298,12 @@ read_pieced_value (struct value *v)
case DWARF_VALUE_STACK:
{
- size_t n;
- int addr_size = gdbarch_addr_bit (c->arch) / 8;
- n = p->size;
- if (n > addr_size)
- n = addr_size;
+ struct gdbarch *gdbarch = get_type_arch (value_type (v));
+ size_t n = p->size;
+ if (n > c->addr_size)
+ n = c->addr_size;
store_unsigned_integer (contents + offset, n,
- gdbarch_byte_order (c->arch),
+ gdbarch_byte_order (gdbarch),
p->v.expr.value);
}
break;
@@ -377,7 +376,7 @@ copy_pieced_value_closure (struct value *v)
{
struct piece_closure *c = (struct piece_closure *) value_computed_closure (v);
- return allocate_piece_closure (c->n_pieces, c->pieces, c->arch);
+ return allocate_piece_closure (c->n_pieces, c->pieces, c->addr_size);
}
static void
@@ -439,7 +438,8 @@ dwarf2_evaluate_loc_desc (struct symbol *var, struct frame_info *frame,
struct piece_closure *c;
struct frame_id frame_id = get_frame_id (frame);
- c = allocate_piece_closure (ctx->num_pieces, ctx->pieces, ctx->gdbarch);
+ c = allocate_piece_closure (ctx->num_pieces, ctx->pieces,
+ ctx->addr_size);
retval = allocate_computed_value (type, &pieced_value_funcs, c);
VALUE_FRAME_ID (retval) = frame_id;
}

View File

@ -0,0 +1,68 @@
commit 60d15ff6d78921d080aee681e60372abe6627570
Author: mgretton <mgretton>
Date: Tue May 4 09:54:17 2010 +0000
* gdb/dwarf2loc.c (read_pieced_value, write_pieced_value,
dwarf2_evaluate_loc_desc): Handle not being able to access DWARF
registers gracefully.
Index: gdb-7.1/gdb/dwarf2loc.c
===================================================================
--- gdb-7.1.orig/gdb/dwarf2loc.c 2010-05-25 21:35:10.000000000 +0200
+++ gdb-7.1/gdb/dwarf2loc.c 2010-05-25 21:37:32.000000000 +0200
@@ -458,8 +458,16 @@ read_pieced_value (struct value *v)
/* Big-endian, and we want less than full size. */
reg_offset = register_size (arch, gdb_regnum) - p->size;
- get_frame_register_bytes (frame, gdb_regnum, reg_offset, p->size,
- contents + offset);
+ if (gdb_regnum != -1)
+ {
+ get_frame_register_bytes (frame, gdb_regnum, reg_offset,
+ p->size, contents + offset);
+ }
+ else
+ {
+ error (_("Unable to access DWARF register number %s"),
+ paddress (arch, p->v.expr.value));
+ }
}
break;
@@ -531,8 +539,16 @@ write_pieced_value (struct value *to, st
/* Big-endian, and we want less than full size. */
reg_offset = register_size (arch, gdb_regnum) - p->size;
- put_frame_register_bytes (frame, gdb_regnum, reg_offset, p->size,
- contents + offset);
+ if (gdb_regnum != -1)
+ {
+ put_frame_register_bytes (frame, gdb_regnum, reg_offset,
+ p->size, contents + offset);
+ }
+ else
+ {
+ error (_("Unable to write to DWARF register number %s"),
+ paddress (arch, p->v.expr.value));
+ }
}
break;
case DWARF_VALUE_MEMORY:
@@ -611,7 +627,16 @@ dwarf2_evaluate_loc_desc (struct type *t
struct gdbarch *arch = get_frame_arch (frame);
CORE_ADDR dwarf_regnum = dwarf_expr_fetch (ctx, 0);
int gdb_regnum = gdbarch_dwarf2_reg_to_regnum (arch, dwarf_regnum);
- retval = value_from_register (type, gdb_regnum, frame);
+ if (gdb_regnum != -1)
+ {
+ retval = value_from_register (type,
+ gdb_regnum, frame);
+ }
+ else
+ {
+ error (_("Unable to access DWARF register number %s"),
+ paddress (arch, dwarf_regnum));
+ }
}
break;

View File

@ -0,0 +1,99 @@
commit dacd66a53b559be9c26d2c523f168f1ef0261f4d
Author: Michael Snyder <msnyder@specifix.com>
Date: Fri May 14 17:53:11 2010 +0000
2010-05-14 Michael Snyder <msnyder@vmware.com>
* dbxread.c: White space.
* dcache.c: White space.
* disasm.c: White space.
* doublest.c: White space.
* dsrec.c: White space.
* dummy-frame.c: White space.
* dwarf2expr.c: White space.
* dwarf2-frame.c: White space.
* dwarf2loc.c: White space.
* dwarf2read.c: White space.
--- gdb-7.1/gdb/dwarf2loc.c.orig 2010-05-25 23:06:46.000000000 +0200
+++ gdb-7.1/gdb/dwarf2loc.c 2010-05-25 23:06:46.000000000 +0200
@@ -236,6 +236,7 @@ static CORE_ADDR
dwarf_expr_frame_cfa (void *baton)
{
struct dwarf_expr_baton *debaton = (struct dwarf_expr_baton *) baton;
+
return dwarf2_frame_cfa (debaton->frame);
}
@@ -444,6 +445,7 @@ read_pieced_value (struct value *v)
for (i = 0; i < c->n_pieces; i++)
{
struct dwarf_expr_piece *p = &c->pieces[i];
+
switch (p->location)
{
case DWARF_VALUE_REGISTER:
@@ -482,6 +484,7 @@ read_pieced_value (struct value *v)
{
struct gdbarch *gdbarch = get_type_arch (value_type (v));
size_t n = p->size;
+
if (n > c->addr_size)
n = c->addr_size;
store_unsigned_integer (contents + offset, n,
@@ -493,6 +496,7 @@ read_pieced_value (struct value *v)
case DWARF_VALUE_LITERAL:
{
size_t n = p->size;
+
if (n > p->v.literal.length)
n = p->v.literal.length;
memcpy (contents + offset, p->v.literal.data, n);
@@ -525,6 +529,7 @@ write_pieced_value (struct value *to, st
for (i = 0; i < c->n_pieces; i++)
{
struct dwarf_expr_piece *p = &c->pieces[i];
+
switch (p->location)
{
case DWARF_VALUE_REGISTER:
@@ -712,6 +717,7 @@ static CORE_ADDR
needs_frame_read_reg (void *baton, int regnum)
{
struct needs_frame_baton *nf_baton = baton;
+
nf_baton->needs_frame = 1;
return 1;
}
@@ -742,6 +748,7 @@ static CORE_ADDR
needs_frame_frame_cfa (void *baton)
{
struct needs_frame_baton *nf_baton = baton;
+
nf_baton->needs_frame = 1;
return 1;
}
@@ -751,6 +758,7 @@ static CORE_ADDR
needs_frame_tls_address (void *baton, CORE_ADDR offset)
{
struct needs_frame_baton *nf_baton = baton;
+
nf_baton->needs_frame = 1;
return 1;
}
@@ -907,6 +915,7 @@ locexpr_read_variable (struct symbol *sy
{
struct dwarf2_locexpr_baton *dlbaton = SYMBOL_LOCATION_BATON (symbol);
struct value *val;
+
val = dwarf2_evaluate_loc_desc (SYMBOL_TYPE (symbol), frame, dlbaton->data,
dlbaton->size, dlbaton->per_cu);
@@ -918,6 +927,7 @@ static int
locexpr_read_needs_frame (struct symbol *symbol)
{
struct dwarf2_locexpr_baton *dlbaton = SYMBOL_LOCATION_BATON (symbol);
+
return dwarf2_loc_desc_needs_frame (dlbaton->data, dlbaton->size,
dlbaton->per_cu);
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,53 @@
http://sourceware.org/ml/gdb-cvs/2010-05/msg00188.html
http://sourceware.org/ml/gdb-cvs/2010-05/msg00189.html
### src/gdb/ChangeLog 2010/05/21 20:45:18 1.11830
### src/gdb/ChangeLog 2010/05/21 20:56:48 1.11831
## -1,3 +1,8 @@
+2010-05-21 Tom Tromey <tromey@redhat.com>
+
+ * eval.c (evaluate_subexp_standard) <BINOP_SUBSCRIPT>: Call
+ evaluate_subexp, not evaluate_subexp_with_coercion.
+
### src/gdb/testsuite/ChangeLog 2010/05/21 20:39:50 1.2273
### src/gdb/testsuite/ChangeLog 2010/05/21 20:56:49 1.2274
## -1,5 +1,10 @@
2010-05-21 Tom Tromey <tromey@redhat.com>
+ * gdb.dwarf2/pieces.exp (pieces_test_f2): New proc.
+ Call it.
+
--- src/gdb/eval.c 2010/05/14 18:35:11 1.134
+++ src/gdb/eval.c 2010/05/21 20:56:49 1.135
@@ -2059,8 +2059,8 @@
error (_("':' operator used in invalid context"));
case BINOP_SUBSCRIPT:
- arg1 = evaluate_subexp_with_coercion (exp, pos, noside);
- arg2 = evaluate_subexp_with_coercion (exp, pos, noside);
+ arg1 = evaluate_subexp (NULL_TYPE, exp, pos, noside);
+ arg2 = evaluate_subexp (NULL_TYPE, exp, pos, noside);
if (noside == EVAL_SKIP)
goto nosideret;
if (binop_user_defined_p (op, arg1, arg2))
--- src/gdb/testsuite/gdb.dwarf2/pieces.exp 2010/05/21 20:39:50 1.1
+++ src/gdb/testsuite/gdb.dwarf2/pieces.exp 2010/05/21 21:00:27 1.2
@@ -54,4 +54,18 @@
gdb_test "print a.j" " = 14" "print a.j in pieces:f1"
}
+# Function f2 tests for a bug when indexing into an array created
+# using DW_OP_piece.
+proc pieces_test_f2 {} {
+ global csrcfile
+ set line [gdb_get_line_number "f2 breakpoint" $csrcfile]
+ gdb_test "break pieces.c:$line" "Breakpoint 3.*" \
+ "set f2 breakpoint for pieces"
+ gdb_continue_to_breakpoint "continue to f2 breakpoint for pieces"
+ gdb_test "print a" " = .4, 14." "print a in pieces:f2"
+ gdb_test "print a\[0\]" " = 4" "print a\[0\] in pieces:f2"
+ gdb_test "print a\[1\]" " = 14" "print a\[1\] in pieces:f2"
+}
+
pieces_test_f1
+pieces_test_f2

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,820 @@
http://sourceware.org/ml/gdb-cvs/2010-05/msg00191.html
### src/gdb/ChangeLog 2010/05/21 21:01:46 1.11832
### src/gdb/ChangeLog 2010/05/21 21:13:10 1.11833
## -1,5 +1,20 @@
2010-05-21 Tom Tromey <tromey@redhat.com>
+ * dwarf2loc.c (extract_bits_primitive): New function.
+ (extract_bits): Likewise.
+ (insert_bits): Likewise.
+ (copy_bitwise): Likewise.
+ (read_pieced_value): Do all operations in bits.
+ (write_pieced_value): Likewise.
+ * dwarf2expr.h (struct dwarf_expr_piece) <offset>: New field.
+ * dwarf2expr.c (add_piece): New arguments bit_piece, offset.
+ Always use xrealloc to resize piece array.
+ (execute_stack_op) <DW_OP_reg0>: Handle DW_OP_bit_piece.
+ <DW_OP_piece>: Update.
+ <DW_OP_bit_piece>: New case.
+
### src/gdb/testsuite/ChangeLog 2010/05/21 21:01:46 1.2275
### src/gdb/testsuite/ChangeLog 2010/05/21 21:13:13 1.2276
## -1,5 +1,12 @@
2010-05-21 Tom Tromey <tromey@redhat.com>
+ * gdb.dwarf2/pieces.exp (pieces_test_f3): New proc.
+ Call it.
+ * gdb.dwarf2/pieces.S: Update.
+ * gdb.dwarf2/pieces.c (struct B): Remove initial field.
+
--- src/gdb/dwarf2expr.c 2010/05/21 21:01:46 1.43
+++ src/gdb/dwarf2expr.c 2010/05/21 21:13:10 1.44
@@ -153,23 +153,21 @@
/* Add a new piece to CTX's piece list. */
static void
-add_piece (struct dwarf_expr_context *ctx, ULONGEST size)
+add_piece (struct dwarf_expr_context *ctx, ULONGEST size, ULONGEST offset)
{
struct dwarf_expr_piece *p;
ctx->num_pieces++;
- if (ctx->pieces)
- ctx->pieces = xrealloc (ctx->pieces,
- (ctx->num_pieces
- * sizeof (struct dwarf_expr_piece)));
- else
- ctx->pieces = xmalloc (ctx->num_pieces
- * sizeof (struct dwarf_expr_piece));
+ ctx->pieces = xrealloc (ctx->pieces,
+ (ctx->num_pieces
+ * sizeof (struct dwarf_expr_piece)));
p = &ctx->pieces[ctx->num_pieces - 1];
p->location = ctx->location;
p->size = size;
+ p->offset = offset;
+
if (p->location == DWARF_VALUE_LITERAL)
{
p->v.literal.data = ctx->data;
@@ -499,9 +497,11 @@
case DW_OP_reg31:
if (op_ptr != op_end
&& *op_ptr != DW_OP_piece
+ && *op_ptr != DW_OP_bit_piece
&& *op_ptr != DW_OP_GNU_uninit)
error (_("DWARF-2 expression error: DW_OP_reg operations must be "
- "used either alone or in conjuction with DW_OP_piece."));
+ "used either alone or in conjuction with DW_OP_piece "
+ "or DW_OP_bit_piece."));
result = op - DW_OP_reg0;
ctx->location = DWARF_VALUE_REGISTER;
@@ -872,7 +872,7 @@
/* Record the piece. */
op_ptr = read_uleb128 (op_ptr, op_end, &size);
- add_piece (ctx, size);
+ add_piece (ctx, 8 * size, 0);
/* Pop off the address/regnum, and reset the location
type. */
@@ -883,6 +883,24 @@
}
goto no_push;
+ case DW_OP_bit_piece:
+ {
+ ULONGEST size, offset;
+
+ /* Record the piece. */
+ op_ptr = read_uleb128 (op_ptr, op_end, &size);
+ op_ptr = read_uleb128 (op_ptr, op_end, &offset);
+ add_piece (ctx, size, offset);
+
+ /* Pop off the address/regnum, and reset the location
+ type. */
+ if (ctx->location != DWARF_VALUE_LITERAL
+ && ctx->location != DWARF_VALUE_OPTIMIZED_OUT)
+ dwarf_expr_pop (ctx);
+ ctx->location = DWARF_VALUE_MEMORY;
+ }
+ goto no_push;
+
case DW_OP_GNU_uninit:
if (op_ptr != op_end)
error (_("DWARF-2 expression error: DW_OP_GNU_uninit must always "
--- src/gdb/dwarf2expr.h 2010/05/21 21:01:46 1.21
+++ src/gdb/dwarf2expr.h 2010/05/21 21:13:11 1.22
@@ -155,7 +155,7 @@
};
-/* A piece of an object, as recorded by DW_OP_piece. */
+/* A piece of an object, as recorded by DW_OP_piece or DW_OP_bit_piece. */
struct dwarf_expr_piece
{
enum dwarf_value_location location;
@@ -181,8 +181,10 @@
} literal;
} v;
- /* The length of the piece, in bytes. */
+ /* The length of the piece, in bits. */
ULONGEST size;
+ /* The piece offset, in bits. */
+ ULONGEST offset;
};
struct dwarf_expr_context *new_dwarf_expr_context (void);
--- src/gdb/dwarf2loc.c 2010/05/21 21:01:46 1.80
+++ src/gdb/dwarf2loc.c 2010/05/21 21:13:11 1.81
@@ -259,52 +259,245 @@
return c;
}
+/* The lowest-level function to extract bits from a byte buffer.
+ SOURCE is the buffer. It is updated if we read to the end of a
+ byte.
+ SOURCE_OFFSET_BITS is the offset of the first bit to read. It is
+ updated to reflect the number of bits actually read.
+ NBITS is the number of bits we want to read. It is updated to
+ reflect the number of bits actually read. This function may read
+ fewer bits.
+ BITS_BIG_ENDIAN is taken directly from gdbarch.
+ This function returns the extracted bits. */
+
+static unsigned int
+extract_bits_primitive (const gdb_byte **source,
+ unsigned int *source_offset_bits,
+ int *nbits, int bits_big_endian)
+{
+ unsigned int avail, mask, datum;
+
+ gdb_assert (*source_offset_bits < 8);
+
+ avail = 8 - *source_offset_bits;
+ if (avail > *nbits)
+ avail = *nbits;
+
+ mask = (1 << avail) - 1;
+ datum = **source;
+ if (bits_big_endian)
+ datum >>= 8 - (*source_offset_bits + *nbits);
+ else
+ datum >>= *source_offset_bits;
+ datum &= mask;
+
+ *nbits -= avail;
+ *source_offset_bits += avail;
+ if (*source_offset_bits >= 8)
+ {
+ *source_offset_bits -= 8;
+ ++*source;
+ }
+
+ return datum;
+}
+
+/* Extract some bits from a source buffer and move forward in the
+ buffer.
+
+ SOURCE is the source buffer. It is updated as bytes are read.
+ SOURCE_OFFSET_BITS is the offset into SOURCE. It is updated as
+ bits are read.
+ NBITS is the number of bits to read.
+ BITS_BIG_ENDIAN is taken directly from gdbarch.
+
+ This function returns the bits that were read. */
+
+static unsigned int
+extract_bits (const gdb_byte **source, unsigned int *source_offset_bits,
+ int nbits, int bits_big_endian)
+{
+ unsigned int datum;
+
+ gdb_assert (nbits > 0 && nbits <= 8);
+
+ datum = extract_bits_primitive (source, source_offset_bits, &nbits,
+ bits_big_endian);
+ if (nbits > 0)
+ {
+ unsigned int more;
+
+ more = extract_bits_primitive (source, source_offset_bits, &nbits,
+ bits_big_endian);
+ if (bits_big_endian)
+ datum <<= nbits;
+ else
+ more <<= nbits;
+ datum |= more;
+ }
+
+ return datum;
+}
+
+/* Write some bits into a buffer and move forward in the buffer.
+
+ DATUM is the bits to write. The low-order bits of DATUM are used.
+ DEST is the destination buffer. It is updated as bytes are
+ written.
+ DEST_OFFSET_BITS is the bit offset in DEST at which writing is
+ done.
+ NBITS is the number of valid bits in DATUM.
+ BITS_BIG_ENDIAN is taken directly from gdbarch. */
+
+static void
+insert_bits (unsigned int datum,
+ gdb_byte *dest, unsigned int dest_offset_bits,
+ int nbits, int bits_big_endian)
+{
+ unsigned int mask;
+
+ gdb_assert (dest_offset_bits >= 0 && dest_offset_bits + nbits <= 8);
+
+ mask = (1 << nbits) - 1;
+ if (bits_big_endian)
+ {
+ datum <<= 8 - (dest_offset_bits + nbits);
+ mask <<= 8 - (dest_offset_bits + nbits);
+ }
+ else
+ {
+ datum <<= dest_offset_bits;
+ mask <<= dest_offset_bits;
+ }
+
+ gdb_assert ((datum & ~mask) == 0);
+
+ *dest = (*dest & ~mask) | datum;
+}
+
+/* Copy bits from a source to a destination.
+
+ DEST is where the bits should be written.
+ DEST_OFFSET_BITS is the bit offset into DEST.
+ SOURCE is the source of bits.
+ SOURCE_OFFSET_BITS is the bit offset into SOURCE.
+ BIT_COUNT is the number of bits to copy.
+ BITS_BIG_ENDIAN is taken directly from gdbarch. */
+
+static void
+copy_bitwise (gdb_byte *dest, unsigned int dest_offset_bits,
+ const gdb_byte *source, unsigned int source_offset_bits,
+ unsigned int bit_count,
+ int bits_big_endian)
+{
+ unsigned int dest_avail;
+ int datum;
+
+ /* Reduce everything to byte-size pieces. */
+ dest += dest_offset_bits / 8;
+ dest_offset_bits %= 8;
+ source += source_offset_bits / 8;
+ source_offset_bits %= 8;
+
+ dest_avail = 8 - dest_offset_bits % 8;
+
+ /* See if we can fill the first destination byte. */
+ if (dest_avail < bit_count)
+ {
+ datum = extract_bits (&source, &source_offset_bits, dest_avail,
+ bits_big_endian);
+ insert_bits (datum, dest, dest_offset_bits, dest_avail, bits_big_endian);
+ ++dest;
+ dest_offset_bits = 0;
+ bit_count -= dest_avail;
+ }
+
+ /* Now, either DEST_OFFSET_BITS is byte-aligned, or we have fewer
+ than 8 bits remaining. */
+ gdb_assert (dest_offset_bits % 8 == 0 || bit_count < 8);
+ for (; bit_count >= 8; bit_count -= 8)
+ {
+ datum = extract_bits (&source, &source_offset_bits, 8, bits_big_endian);
+ *dest++ = (gdb_byte) datum;
+ }
+
+ /* Finally, we may have a few leftover bits. */
+ gdb_assert (bit_count <= 8 - dest_offset_bits % 8);
+ if (bit_count > 0)
+ {
+ datum = extract_bits (&source, &source_offset_bits, bit_count,
+ bits_big_endian);
+ insert_bits (datum, dest, dest_offset_bits, bit_count, bits_big_endian);
+ }
+}
+
static void
read_pieced_value (struct value *v)
{
int i;
long offset = 0;
- ULONGEST bytes_to_skip;
+ ULONGEST bits_to_skip;
gdb_byte *contents;
struct piece_closure *c = (struct piece_closure *) value_computed_closure (v);
struct frame_info *frame = frame_find_by_id (VALUE_FRAME_ID (v));
size_t type_len;
+ size_t buffer_size = 0;
+ char *buffer = NULL;
+ struct cleanup *cleanup;
+ int bits_big_endian
+ = gdbarch_bits_big_endian (get_type_arch (value_type (v)));
if (value_type (v) != value_enclosing_type (v))
internal_error (__FILE__, __LINE__,
_("Should not be able to create a lazy value with "
"an enclosing type"));
+ cleanup = make_cleanup (free_current_contents, &buffer);
+
contents = value_contents_raw (v);
- bytes_to_skip = value_offset (v);
- type_len = TYPE_LENGTH (value_type (v));
+ bits_to_skip = 8 * value_offset (v);
+ type_len = 8 * TYPE_LENGTH (value_type (v));
+
for (i = 0; i < c->n_pieces && offset < type_len; i++)
{
struct dwarf_expr_piece *p = &c->pieces[i];
- size_t this_size;
- long dest_offset, source_offset;
-
- if (bytes_to_skip > 0 && bytes_to_skip >= p->size)
+ size_t this_size, this_size_bits;
+ long dest_offset_bits, source_offset_bits, source_offset;
+ gdb_byte *intermediate_buffer;
+
+ /* Compute size, source, and destination offsets for copying, in
+ bits. */
+ this_size_bits = p->size;
+ if (bits_to_skip > 0 && bits_to_skip >= this_size_bits)
{
- bytes_to_skip -= p->size;
+ bits_to_skip -= this_size_bits;
continue;
}
- this_size = p->size;
- if (this_size > type_len - offset)
- this_size = type_len - offset;
- if (bytes_to_skip > 0)
- {
- dest_offset = 0;
- source_offset = bytes_to_skip;
- this_size -= bytes_to_skip;
- bytes_to_skip = 0;
+ if (this_size_bits > type_len - offset)
+ this_size_bits = type_len - offset;
+ if (bits_to_skip > 0)
+ {
+ dest_offset_bits = 0;
+ source_offset_bits = bits_to_skip;
+ this_size_bits -= bits_to_skip;
+ bits_to_skip = 0;
}
else
{
- dest_offset = offset;
- source_offset = 0;
+ dest_offset_bits = offset;
+ source_offset_bits = 0;
+ }
+
+ this_size = (this_size_bits + source_offset_bits % 8 + 7) / 8;
+ source_offset = source_offset_bits / 8;
+ if (buffer_size < this_size)
+ {
+ buffer_size = this_size;
+ buffer = xrealloc (buffer, buffer_size);
}
+ intermediate_buffer = buffer;
+ /* Copy from the source to DEST_BUFFER. */
switch (p->location)
{
case DWARF_VALUE_REGISTER:
@@ -316,13 +509,18 @@
if (gdbarch_byte_order (arch) == BFD_ENDIAN_BIG
&& this_size < register_size (arch, gdb_regnum))
- /* Big-endian, and we want less than full size. */
- reg_offset = register_size (arch, gdb_regnum) - this_size;
+ {
+ /* Big-endian, and we want less than full size. */
+ reg_offset = register_size (arch, gdb_regnum) - this_size;
+ /* We want the lower-order THIS_SIZE_BITS of the bytes
+ we extract from the register. */
+ source_offset_bits += 8 * this_size - this_size_bits;
+ }
if (gdb_regnum != -1)
{
get_frame_register_bytes (frame, gdb_regnum, reg_offset,
- this_size, contents + dest_offset);
+ this_size, buffer);
}
else
{
@@ -334,11 +532,9 @@
case DWARF_VALUE_MEMORY:
if (p->v.expr.in_stack_memory)
- read_stack (p->v.expr.value + source_offset,
- contents + dest_offset, this_size);
+ read_stack (p->v.expr.value + source_offset, buffer, this_size);
else
- read_memory (p->v.expr.value + source_offset,
- contents + dest_offset, this_size);
+ read_memory (p->v.expr.value + source_offset, buffer, this_size);
break;
case DWARF_VALUE_STACK:
@@ -355,7 +551,7 @@
/* Nothing. */
}
else if (source_offset == 0)
- store_unsigned_integer (contents + dest_offset, n,
+ store_unsigned_integer (buffer, n,
gdbarch_byte_order (gdbarch),
p->v.expr.value);
else
@@ -365,7 +561,7 @@
store_unsigned_integer (bytes, n + source_offset,
gdbarch_byte_order (gdbarch),
p->v.expr.value);
- memcpy (contents + dest_offset, bytes + source_offset, n);
+ memcpy (buffer, bytes + source_offset, n);
}
}
break;
@@ -379,8 +575,7 @@
? p->v.literal.length - source_offset
: 0);
if (n != 0)
- memcpy (contents + dest_offset,
- p->v.literal.data + source_offset, n);
+ intermediate_buffer = p->v.literal.data + source_offset;
}
break;
@@ -388,17 +583,25 @@
/* We just leave the bits empty for now. This is not ideal
but gdb currently does not have a nice way to represent
optimized-out pieces. */
- warning (_("bytes %ld-%ld in computed object were optimized out; "
+ warning (_("bits %ld-%ld in computed object were optimized out; "
"replacing with zeroes"),
offset,
- offset + (long) this_size);
+ offset + (long) this_size_bits);
break;
default:
internal_error (__FILE__, __LINE__, _("invalid location type"));
}
- offset += this_size;
+
+ if (p->location != DWARF_VALUE_OPTIMIZED_OUT)
+ copy_bitwise (contents, dest_offset_bits,
+ intermediate_buffer, source_offset_bits % 8,
+ this_size_bits, bits_big_endian);
+
+ offset += this_size_bits;
}
+
+ do_cleanups (cleanup);
}
static void
@@ -406,11 +609,16 @@
{
int i;
long offset = 0;
- ULONGEST bytes_to_skip;
+ ULONGEST bits_to_skip;
const gdb_byte *contents;
struct piece_closure *c = (struct piece_closure *) value_computed_closure (to);
struct frame_info *frame = frame_find_by_id (VALUE_FRAME_ID (to));
size_t type_len;
+ size_t buffer_size = 0;
+ char *buffer = NULL;
+ struct cleanup *cleanup;
+ int bits_big_endian
+ = gdbarch_bits_big_endian (get_type_arch (value_type (to)));
if (frame == NULL)
{
@@ -418,34 +626,57 @@
return;
}
+ cleanup = make_cleanup (free_current_contents, &buffer);
+
contents = value_contents (from);
- bytes_to_skip = value_offset (to);
- type_len = TYPE_LENGTH (value_type (to));
+ bits_to_skip = 8 * value_offset (to);
+ type_len = 8 * TYPE_LENGTH (value_type (to));
for (i = 0; i < c->n_pieces && offset < type_len; i++)
{
struct dwarf_expr_piece *p = &c->pieces[i];
- size_t this_size;
- long dest_offset, source_offset;
+ size_t this_size_bits, this_size;
+ long dest_offset_bits, source_offset_bits, dest_offset, source_offset;
+ int need_bitwise;
+ const gdb_byte *source_buffer;
- if (bytes_to_skip > 0 && bytes_to_skip >= p->size)
+ this_size_bits = p->size;
+ if (bits_to_skip > 0 && bits_to_skip >= this_size_bits)
{
- bytes_to_skip -= p->size;
+ bits_to_skip -= this_size_bits;
continue;
}
- this_size = p->size;
- if (this_size > type_len - offset)
- this_size = type_len - offset;
- if (bytes_to_skip > 0)
- {
- dest_offset = bytes_to_skip;
- source_offset = 0;
- this_size -= bytes_to_skip;
- bytes_to_skip = 0;
+ if (this_size_bits > type_len - offset)
+ this_size_bits = type_len - offset;
+ if (bits_to_skip > 0)
+ {
+ dest_offset_bits = bits_to_skip;
+ source_offset_bits = 0;
+ this_size_bits -= bits_to_skip;
+ bits_to_skip = 0;
+ }
+ else
+ {
+ dest_offset_bits = 0;
+ source_offset_bits = offset;
+ }
+
+ this_size = (this_size_bits + source_offset_bits % 8 + 7) / 8;
+ source_offset = source_offset_bits / 8;
+ dest_offset = dest_offset_bits / 8;
+ if (dest_offset_bits % 8 == 0 && source_offset_bits % 8 == 0)
+ {
+ source_buffer = contents + source_offset;
+ need_bitwise = 0;
}
else
{
- dest_offset = 0;
- source_offset = offset;
+ if (buffer_size < this_size)
+ {
+ buffer_size = this_size;
+ buffer = xrealloc (buffer, buffer_size);
+ }
+ source_buffer = buffer;
+ need_bitwise = 1;
}
switch (p->location)
@@ -463,8 +694,18 @@
if (gdb_regnum != -1)
{
+ if (need_bitwise)
+ {
+ get_frame_register_bytes (frame, gdb_regnum, reg_offset,
+ this_size, buffer);
+ copy_bitwise (buffer, dest_offset_bits,
+ contents, source_offset_bits,
+ this_size_bits,
+ bits_big_endian);
+ }
+
put_frame_register_bytes (frame, gdb_regnum, reg_offset,
- this_size, contents + source_offset);
+ this_size, source_buffer);
}
else
{
@@ -474,15 +715,31 @@
}
break;
case DWARF_VALUE_MEMORY:
+ if (need_bitwise)
+ {
+ /* Only the first and last bytes can possibly have any
+ bits reused. */
+ read_memory (p->v.expr.value + dest_offset, buffer, 1);
+ read_memory (p->v.expr.value + dest_offset + this_size - 1,
+ buffer + this_size - 1, 1);
+ copy_bitwise (buffer, dest_offset_bits,
+ contents, source_offset_bits,
+ this_size_bits,
+ bits_big_endian);
+ }
+
write_memory (p->v.expr.value + dest_offset,
- contents + source_offset, this_size);
+ source_buffer, this_size);
break;
default:
set_value_optimized_out (to, 1);
- return;
+ goto done;
}
- offset += this_size;
+ offset += this_size_bits;
}
+
+ done:
+ do_cleanups (cleanup);
}
static void *
--- src/gdb/testsuite/gdb.dwarf2/pieces.S 2010/05/21 21:01:46 1.2
+++ src/gdb/testsuite/gdb.dwarf2/pieces.S 2010/05/21 21:13:13 1.3
@@ -989,23 +989,18 @@
.LLST6:
.long .LVL13-.Ltext0 # Location list begin address (*.LLST6)
.long .LVL14-.Ltext0 # Location list end address (*.LLST6)
- .value 0xa # Location expression size
- .byte 0x9d # DW_OP_bit_piece
- .uleb128 0x4
- .uleb128 0
+ .value 0x8 # Location expression size
.byte 0x34 # DW_OP_lit4
.byte 0x9f # DW_OP_stack_value
.byte 0x9d # DW_OP_bit_piece
.uleb128 0xc
.uleb128 0
- .byte 0x93 # DW_OP_piece
- .uleb128 0x2
- .long .LVL14-.Ltext0 # Location list begin address (*.LLST6)
- .long .LVL15-.Ltext0 # Location list end address (*.LLST6)
- .value 0x15 # Location expression size
.byte 0x9d # DW_OP_bit_piece
- .uleb128 0x4
+ .uleb128 0x14
.uleb128 0
+ .long .LVL14-.Ltext0 # Location list begin address (*.LLST6)
+ .long .LVL15-.Ltext0 # Location list end address (*.LLST6)
+ .value 0x11 # Location expression size
.byte 0x34 # DW_OP_lit4
.byte 0x9f # DW_OP_stack_value
.byte 0x9d # DW_OP_bit_piece
@@ -1021,15 +1016,11 @@
.byte 0x9d # DW_OP_bit_piece
.uleb128 0xc
.uleb128 0
- .byte 0x9d # DW_OP_bit_piece
- .uleb128 0x4
- .uleb128 0
+ .byte 0x93 # DW_OP_piece
+ .uleb128 0x1
.long .LVL15-.Ltext0 # Location list begin address (*.LLST6)
.long .LVL16-1-.Ltext0 # Location list end address (*.LLST6)
- .value 0x14 # Location expression size
- .byte 0x9d # DW_OP_bit_piece
- .uleb128 0x4
- .uleb128 0
+ .value 0x10 # Location expression size
.byte 0x52 # DW_OP_reg2
.byte 0x9d # DW_OP_bit_piece
.uleb128 0xc
@@ -1044,15 +1035,11 @@
.byte 0x9d # DW_OP_bit_piece
.uleb128 0xc
.uleb128 0
- .byte 0x9d # DW_OP_bit_piece
- .uleb128 0x4
- .uleb128 0
+ .byte 0x93 # DW_OP_piece
+ .uleb128 0x1
.long .LVL16-1-.Ltext0 # Location list begin address (*.LLST6)
.long .LVL17-.Ltext0 # Location list end address (*.LLST6)
- .value 0x14 # Location expression size
- .byte 0x9d # DW_OP_bit_piece
- .uleb128 0x4
- .uleb128 0
+ .value 0x10 # Location expression size
.byte 0x56 # DW_OP_reg6
.byte 0x9d # DW_OP_bit_piece
.uleb128 0xc
@@ -1067,14 +1054,14 @@
.byte 0x9d # DW_OP_bit_piece
.uleb128 0xc
.uleb128 0
- .byte 0x9d # DW_OP_bit_piece
- .uleb128 0x4
- .uleb128 0
+ .byte 0x93 # DW_OP_piece
+ .uleb128 0x1
.long .LVL17-.Ltext0 # Location list begin address (*.LLST6)
.long .LFE3-.Ltext0 # Location list end address (*.LLST6)
.value 0xf # Location expression size
- .byte 0x93 # DW_OP_piece
- .uleb128 0x2
+ .byte 0x9d # DW_OP_bit_piece
+ .uleb128 0xc
+ .uleb128 0
.byte 0x91 # DW_OP_fbreg
.sleb128 0
.byte 0x94 # DW_OP_deref_size
@@ -1085,9 +1072,8 @@
.byte 0x9d # DW_OP_bit_piece
.uleb128 0xc
.uleb128 0
- .byte 0x9d # DW_OP_bit_piece
- .uleb128 0x4
- .uleb128 0
+ .byte 0x93 # DW_OP_piece
+ .uleb128 0x1
.long 0 # Location list terminator begin (*.LLST6)
.long 0 # Location list terminator end (*.LLST6)
.LLST7:
@@ -1356,7 +1342,7 @@
.long 0x48 # DW_AT_type
.byte 0x4 # DW_AT_byte_size
.byte 0xc # DW_AT_bit_size
- .byte 0x10 # DW_AT_bit_offset
+ .byte 0x14 # DW_AT_bit_offset
.byte 0x2 # DW_AT_data_member_location
.byte 0x23 # DW_OP_plus_uconst
.uleb128 0
@@ -1367,7 +1353,7 @@
.long 0x48 # DW_AT_type
.byte 0x4 # DW_AT_byte_size
.byte 0xc # DW_AT_bit_size
- .byte 0x4 # DW_AT_bit_offset
+ .byte 0x8 # DW_AT_bit_offset
.byte 0x2 # DW_AT_data_member_location
.byte 0x23 # DW_OP_plus_uconst
.uleb128 0
--- src/gdb/testsuite/gdb.dwarf2/pieces.c 2010/05/21 21:01:46 1.2
+++ src/gdb/testsuite/gdb.dwarf2/pieces.c 2010/05/21 21:13:13 1.3
@@ -21,7 +21,7 @@
However, it is used to extract breakpoint line numbers. */
struct A { int i; int j; };
-struct B { int : 4; int i : 12; int j : 12; int : 4; };
+struct B { int i : 12; int j : 12; int : 4; };
struct C { int i; int j; int q; };
__attribute__((noinline)) void
@@ -89,7 +89,7 @@
f6 (int k)
{
int z = 23;
- struct C a = { k, k, z};
+ struct C a = { k, k, z };
asm ("" : "+r" (a.i));
a.j++;
bar (a.i);
--- src/gdb/testsuite/gdb.dwarf2/pieces.exp 2010/05/21 21:01:46 1.3
+++ src/gdb/testsuite/gdb.dwarf2/pieces.exp 2010/05/21 21:13:13 1.4
@@ -67,15 +67,30 @@
gdb_test "print a\[1\]" " = 14" "print a\[1\] in pieces:f2"
}
+# Function f3 tests DW_OP_bit_piece.
+proc pieces_test_f3 {} {
+ global csrcfile
+ set line [gdb_get_line_number "f3 breakpoint" $csrcfile]
+ gdb_test "break pieces.c:$line" "Breakpoint 4.*" \
+ "set f3 breakpoint for pieces"
+ gdb_continue_to_breakpoint "continue to f3 breakpoint for pieces"
+ gdb_test "print a.i" " = 4" "print a.i in pieces:f3"
+ gdb_test "print a.j" " = 14" "print a.j in pieces:f3"
+ # Right now gdb says "value optimized out" here, but that is wrong.
+ setup_kfail "no bug yet" *-*-*
+ gdb_test "print a.i = 7" " = 7" "set a.i in pieces:f3"
+ gdb_test "print a.i" " = 7" "print new a.i in pieces:f3"
+}
+
# Function f6 tests for an empty DW_OP_piece.
proc pieces_test_f6 {} {
global csrcfile
set line [gdb_get_line_number "f6 breakpoint" $csrcfile]
- gdb_test "break pieces.c:$line" "Breakpoint 4.*" \
+ gdb_test "break pieces.c:$line" "Breakpoint 5.*" \
"set f6 breakpoint for pieces"
gdb_continue_to_breakpoint "continue to f6 breakpoint for pieces"
gdb_test "print a" \
- "warning: bytes .* in computed object were.* = {i = 7, j = 8, q = 0}" \
+ "warning: bits .* in computed object were.* = {i = 7, j = 8, q = 0}" \
"print a with optimized out piece"
# Note: no warning for this case.
gdb_test_multiple "print a.i" \
@@ -91,4 +106,5 @@
pieces_test_f1
pieces_test_f2
+pieces_test_f3
pieces_test_f6

View File

@ -0,0 +1,164 @@
--- ./gdb/doc/gdb.texinfo 2010-05-24 19:37:01.000000000 +0200
+++ ./gdb/doc/gdb.texinfo 2010-05-24 19:38:56.000000000 +0200
@@ -14768,33 +14768,21 @@ and @code{show architecture}.
@cindex active targets
@cindex multiple targets
-There are three classes of targets: processes, core files, and
-executable files. @value{GDBN} can work concurrently on up to three
-active targets, one in each class. This allows you to (for example)
-start a process and inspect its activity without abandoning your work on
-a core file.
-
-For example, if you execute @samp{gdb a.out}, then the executable file
-@code{a.out} is the only active target. If you designate a core file as
-well---presumably from a prior run that crashed and coredumped---then
-@value{GDBN} has two active targets and uses them in tandem, looking
-first in the corefile target, then in the executable file, to satisfy
-requests for memory addresses. (Typically, these two classes of target
-are complementary, since core files contain only a program's
-read-write memory---variables and so on---plus machine status, while
-executable files contain only the program text and initialized data.)
-
-When you type @code{run}, your executable file becomes an active process
-target as well. When a process target is active, all @value{GDBN}
-commands requesting memory addresses refer to that target; addresses in
-an active core file or executable file target are obscured while the
-process target is active.
-
-Use the @code{core-file} and @code{exec-file} commands to select a new
-core file or executable target (@pxref{Files, ,Commands to Specify
-Files}). To specify as a target a process that is already running, use
-the @code{attach} command (@pxref{Attach, ,Debugging an Already-running
-Process}).
+There are multiple classes of targets such as: processes, executable files or
+recording sessions. Core files belong to the process class, there can be
+active only one of a core or a running process. Otherwise @value{GDBN} can
+work concurrently on multiple active targets, one in each class. This allows
+you to (for example) start a process and inspect its activity while still
+having access to the executable file after the process finishes. Or if you
+start process recording (@pxref{Reverse Execution}) and @code{reverse-step}
+there you are presented a virtual layer of the recording target while the
+process target remains stopped at the chronologically last point of the process
+execution.
+
+Use the @code{core-file} and @code{exec-file} commands to select a new core
+file or executable target (@pxref{Files, ,Commands to Specify Files}). To
+specify as a target a process that is already running, use the @code{attach}
+command (@pxref{Attach, ,Debugging an Already-running Process}).
@node Target Commands
@section Commands for Managing Targets
--- ./gdb/infcmd.c 2010-05-24 19:37:01.000000000 +0200
+++ ./gdb/infcmd.c 2010-05-24 19:41:21.000000000 +0200
@@ -483,6 +483,13 @@ run_command_1 (char *args, int from_tty,
dont_repeat ();
+ if (core_bfd)
+ {
+ core_file_command (NULL, from_tty);
+ if (core_bfd)
+ warning (_("Core file not unloaded."));
+ }
+
kill_if_already_running (from_tty);
init_wait_for_inferior ();
@@ -2373,6 +2380,13 @@ attach_command (char *args, int from_tty
error (_("Not killed."));
}
+ if (core_bfd)
+ {
+ core_file_command (NULL, from_tty);
+ if (core_bfd)
+ warning (_("Core file not unloaded."));
+ }
+
/* Clean up any leftovers from other runs. Some other things from
this function should probably be moved into target_pre_inferior. */
target_pre_inferior (from_tty);
--- ./gdb/testsuite/gdb.base/corefile.exp 2010-01-09 01:14:11.000000000 +0100
+++ ./gdb/testsuite/gdb.base/corefile.exp 2010-05-24 19:38:56.000000000 +0200
@@ -182,3 +182,62 @@ gdb_load ${binfile}
gdb_test "up" "#\[0-9\]* *\[0-9xa-fH'\]* in .* \\(.*\\).*" "up in corefile.exp (reinit)"
gdb_test "core" "No core file now."
+
+
+# Test a run (start) command will clear any loaded core file.
+
+gdb_test "core-file $corefile" "Core was generated by .*" "run: load core again"
+gdb_test "info files" "\r\nLocal core dump file:\r\n.*" "run: sanity check we see the core file"
+
+set test "run: with core"
+if [runto_main] {
+ pass $test
+} else {
+ fail $test
+}
+
+set test "run: core file is cleared"
+gdb_test_multiple "info files" $test {
+ "\r\nLocal core dump file:\r\n.*\r\n$gdb_prompt $" {
+ fail $test
+ }
+ "\r\n$gdb_prompt $" {
+ pass $test
+ }
+}
+
+gdb_exit
+
+
+# Test an attach command will clear any loaded core file.
+
+if ![is_remote target] {
+ set test "attach: spawn sleep"
+ set res [remote_spawn host "$binfile sleep"];
+ if { $res < 0 || $res == "" } {
+ perror "$test failed."
+ fail $test
+ return
+ }
+ set pid [exp_pid -i $res]
+ # We do not care of the startup phase where it will be caught.
+
+ gdb_start
+
+ gdb_test "core-file $corefile" "Core was generated by .*" "attach: load core again"
+ gdb_test "info files" "\r\nLocal core dump file:\r\n.*" "attach: sanity check we see the core file"
+
+ gdb_test "attach $pid" "Attaching to process $pid\r\n.*" "attach: with core"
+
+ set test "attach: core file is cleared"
+ gdb_test_multiple "info files" $test {
+ "\r\nLocal core dump file:\r\n.*\r\n$gdb_prompt $" {
+ fail $test
+ }
+ "\r\n$gdb_prompt $" {
+ pass $test
+ }
+ }
+
+ gdb_exit
+}
--- ./gdb/testsuite/gdb.base/coremaker.c 2010-01-01 08:32:00.000000000 +0100
+++ ./gdb/testsuite/gdb.base/coremaker.c 2010-05-24 19:38:56.000000000 +0200
@@ -133,8 +133,14 @@ func1 ()
func2 ();
}
-int main ()
+int
+main (int argc, char **argv)
{
+ if (argc == 2 && strcmp (argv[1], "sleep") == 0)
+ {
+ sleep (60);
+ return 0;
+ }
mmapdata ();
func1 ();
return 0;

View File

@ -0,0 +1,79 @@
https://bugzilla.redhat.com/show_bug.cgi?id=586566
http://sourceware.org/ml/gdb-patches/2010-03/msg00746.html
http://sourceware.org/ml/gdb-patches/2010-05/msg00551.html
http://sourceware.org/ml/gdb-cvs/2010-03/msg00194.html
### src/gdb/ChangeLog 2010/03/19 22:00:16 1.11508
### src/gdb/ChangeLog 2010/03/20 05:17:10 1.11509
## -1,3 +1,9 @@
+2010-03-20 Daniel Jacobowitz <dan@codesourcery.com>
+
+ * tui/tui-disasm.c (tui_get_begin_asm_address): Default to
+ get_current_arch.
+ * tui/tui-layout.c (extract_display_start_addr): Likewise.
+
2010-03-19 Stan Shebs <stan@codesourcery.com>
* ax-gdb.c (gen_fetch): Handle bool.
--- src/gdb/tui/tui-disasm.c 2010/01/01 07:32:07 1.33
+++ src/gdb/tui/tui-disasm.c 2010/03/20 05:17:10 1.34
@@ -21,6 +21,7 @@
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include "defs.h"
+#include "arch-utils.h"
#include "symtab.h"
#include "breakpoint.h"
#include "frame.h"
@@ -330,7 +331,7 @@
{
struct tui_gen_win_info *locator;
struct tui_locator_element *element;
- struct gdbarch *gdbarch = NULL;
+ struct gdbarch *gdbarch = get_current_arch ();
CORE_ADDR addr;
locator = tui_locator_win_info_ptr ();
--- src/gdb/tui/tui-layout.c 2010/01/01 07:32:07 1.36
+++ src/gdb/tui/tui-layout.c 2010/03/20 05:17:10 1.37
@@ -21,6 +21,7 @@
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include "defs.h"
+#include "arch-utils.h"
#include "command.h"
#include "symtab.h"
#include "frame.h"
@@ -522,7 +523,7 @@
extract_display_start_addr (struct gdbarch **gdbarch_p, CORE_ADDR *addr_p)
{
enum tui_layout_type cur_layout = tui_current_layout ();
- struct gdbarch *gdbarch = NULL;
+ struct gdbarch *gdbarch = get_current_arch ();
CORE_ADDR addr;
CORE_ADDR pc;
struct symtab_and_line cursal = get_current_source_symtab_and_line ();
--- /dev/null 2010-05-24 04:43:32.632794021 +0200
+++ gdb-7.1/gdb/testsuite/gdb.base/tui-layout.exp 2010-05-24 20:13:30.000000000 +0200
@@ -0,0 +1,21 @@
+# 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 tui-layout
+if { [prepare_for_testing ${testfile}.exp ${testfile} start.c] } {
+ return -1
+}
+
+gdb_test "layout asm"

View File

@ -0,0 +1,66 @@
[patch] Fix ADL anonymous type crash
http://sourceware.org/ml/gdb-patches/2010-06/msg00004.html
http://sourceware.org/ml/gdb-cvs/2010-06/msg00012.html
[ Backported the testcase. ]
### src/gdb/ChangeLog 2010/06/02 06:24:00 1.11862
### src/gdb/ChangeLog 2010/06/02 15:31:29 1.11863
## -1,3 +1,8 @@
+2010-06-02 Sami Wagiaalla <swagiaal@redhat.com>
+
+ * cp-support.c (make_symbol_overload_list_adl_namespace): Handle
+ anonymous type case.
+
2010-06-02 Pierre Muller <muller@ics.u-strasbg.fr>
* dwarf2read.c (read_subrange_type): Handle missing base type
### src/gdb/testsuite/ChangeLog 2010/06/01 21:29:21 1.2298
### src/gdb/testsuite/ChangeLog 2010/06/02 15:31:30 1.2299
## -1,3 +1,8 @@
+2010-06-02 Sami Wagiaalla <swagiaal@redhat.com>
+
+ * gdb.cp/namespace-koenig.exp: Added new test case.
+ * gdb.cp/namespace-koenig.cc: Ditto.
+
2010-06-01 Michael Snyder <msnyder@vmware.com>
* gdb.base/arithmet.exp: Use gdb_test_no_output.
--- src/gdb/cp-support.c 2010/05/13 23:53:32 1.40
+++ src/gdb/cp-support.c 2010/06/02 15:31:30 1.41
@@ -752,6 +752,9 @@
type_name = TYPE_NAME (type);
+ if (type_name == NULL)
+ return;
+
prefix_len = cp_entire_prefix_len (type_name);
if (prefix_len != 0)
--- gdb-7.1/gdb/testsuite/gdb.cp/namespace-koenig.cc.orig 2010-06-09 08:20:14.000000000 +0200
+++ gdb-7.1/gdb/testsuite/gdb.cp/namespace-koenig.cc 2010-06-09 11:09:29.000000000 +0200
@@ -165,6 +165,13 @@ namespace M {
}
//------------
+static union {
+ int a;
+ char b;
+}p_union;
+
+//------------
+
int
main ()
{
--- gdb-7.1/gdb/testsuite/gdb.cp/namespace-koenig.exp.orig 2010-06-09 08:20:14.000000000 +0200
+++ gdb-7.1/gdb/testsuite/gdb.cp/namespace-koenig.exp 2010-06-09 11:09:48.000000000 +0200
@@ -110,3 +111,7 @@ gdb_test "p o + 5.0f" "= 22"
gdb_test "p o + 5" "= 23"
gdb_test "p o++" "= 24"
+
+#test that lookup is not thwarted by anonymous types
+gdb_test "p foo (p_union)" \
+ "Cannot resolve function foo to any overloaded instance"

View File

@ -0,0 +1,329 @@
commit be1f57c90bdf86477b9bc69cc982171d6ad5df56
Author: Tom Tromey <tromey@redhat.com>
Date: Tue Apr 20 17:33:13 2010 +0000
* dwarf2-frame.c (decode_frame_entry_1): Handle CIE version 4.
(struct dwarf2_cie) <segment_size>: New field.
* dwarf2read.c (partial_read_comp_unit_head): Accept DWARF 4.
(skip_one_die): Handle DW_FORM_flag_present, DW_FORM_sec_offset,
DW_FORM_exprloc.
(read_attribute_value): Handle DW_FORM_flag_present,
DW_FORM_sec_offset, DW_FORM_exprloc.
(dump_die_shallow): Likewise.
(attr_form_is_section_offset): Handle DW_FORM_sec_offset.
(dwarf2_const_value): Handle DW_FORM_exprloc.
(attr_form_is_block): Likewise.
(struct line_header) <maximum_ops_per_instruction>: New field.
(dwarf_decode_line_header): Set new field.
(dwarf_decode_lines): Handle new field.
### a/gdb/ChangeLog
### b/gdb/ChangeLog
## -1,3 +1,20 @@
+2010-04-20 Tom Tromey <tromey@redhat.com>
+
+ * dwarf2-frame.c (decode_frame_entry_1): Handle CIE version 4.
+ (struct dwarf2_cie) <segment_size>: New field.
+ * dwarf2read.c (partial_read_comp_unit_head): Accept DWARF 4.
+ (skip_one_die): Handle DW_FORM_flag_present, DW_FORM_sec_offset,
+ DW_FORM_exprloc.
+ (read_attribute_value): Handle DW_FORM_flag_present,
+ DW_FORM_sec_offset, DW_FORM_exprloc.
+ (dump_die_shallow): Likewise.
+ (attr_form_is_section_offset): Handle DW_FORM_sec_offset.
+ (dwarf2_const_value): Handle DW_FORM_exprloc.
+ (attr_form_is_block): Likewise.
+ (struct line_header) <maximum_ops_per_instruction>: New field.
+ (dwarf_decode_line_header): Set new field.
+ (dwarf_decode_lines): Handle new field.
+
2010-04-20 Jan Kratochvil <jan.kratochvil@redhat.com>
* f-exp.y: Add new production to recognize the `logical*8' type.
--- a/gdb/dwarf2-frame.c
+++ b/gdb/dwarf2-frame.c
@@ -85,6 +85,9 @@ struct dwarf2_cie
/* The version recorded in the CIE. */
unsigned char version;
+
+ /* The segment size. */
+ unsigned char segment_size;
};
struct dwarf2_cie_table
@@ -1714,7 +1717,7 @@ decode_frame_entry_1 (struct comp_unit *unit, gdb_byte *start, int eh_frame_p,
/* Check version number. */
cie_version = read_1_byte (unit->abfd, buf);
- if (cie_version != 1 && cie_version != 3)
+ if (cie_version != 1 && cie_version != 3 && cie_version != 4)
return NULL;
cie->version = cie_version;
buf += 1;
@@ -1738,6 +1741,20 @@ decode_frame_entry_1 (struct comp_unit *unit, gdb_byte *start, int eh_frame_p,
augmentation += 2;
}
+ if (cie->version >= 4)
+ {
+ /* FIXME: check that this is the same as from the CU header. */
+ cie->addr_size = read_1_byte (unit->abfd, buf);
+ ++buf;
+ cie->segment_size = read_1_byte (unit->abfd, buf);
+ ++buf;
+ }
+ else
+ {
+ cie->addr_size = gdbarch_ptr_bit (gdbarch) / TARGET_CHAR_BIT;
+ cie->segment_size = 0;
+ }
+
cie->code_alignment_factor =
read_unsigned_leb128 (unit->abfd, buf, &bytes_read);
buf += bytes_read;
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -396,6 +396,7 @@ struct line_header
unsigned short version;
unsigned int header_length;
unsigned char minimum_instruction_length;
+ unsigned char maximum_ops_per_instruction;
unsigned char default_is_stmt;
int line_base;
unsigned char line_range;
@@ -1488,10 +1489,10 @@ partial_read_comp_unit_head (struct comp_unit_head *header, gdb_byte *info_ptr,
info_ptr = read_comp_unit_head (header, info_ptr, abfd);
- if (header->version != 2 && header->version != 3)
+ if (header->version != 2 && header->version != 3 && header->version != 4)
error (_("Dwarf Error: wrong version in compilation unit header "
- "(is %d, should be %d) [in module %s]"), header->version,
- 2, bfd_get_filename (abfd));
+ "(is %d, should be 2, 3, or 4) [in module %s]"), header->version,
+ bfd_get_filename (abfd));
if (header->abbrev_offset >= dwarf2_per_objfile->abbrev.size)
error (_("Dwarf Error: bad offset (0x%lx) in compilation unit header "
@@ -2776,6 +2777,8 @@ skip_one_die (gdb_byte *buffer, gdb_byte *info_ptr,
case DW_FORM_flag:
info_ptr += 1;
break;
+ case DW_FORM_flag_present:
+ break;
case DW_FORM_data2:
case DW_FORM_ref2:
info_ptr += 2;
@@ -2793,9 +2796,11 @@ skip_one_die (gdb_byte *buffer, gdb_byte *info_ptr,
read_string (abfd, info_ptr, &bytes_read);
info_ptr += bytes_read;
break;
+ case DW_FORM_sec_offset:
case DW_FORM_strp:
info_ptr += cu->header.offset_size;
break;
+ case DW_FORM_exprloc:
case DW_FORM_block:
info_ptr += read_unsigned_leb128 (abfd, info_ptr, &bytes_read);
info_ptr += bytes_read;
@@ -7129,6 +7134,10 @@ read_attribute_value (struct attribute *attr, unsigned form,
DW_UNSND (attr) = read_8_bytes (abfd, info_ptr);
info_ptr += 8;
break;
+ case DW_FORM_sec_offset:
+ DW_UNSND (attr) = read_offset (abfd, info_ptr, &cu->header, &bytes_read);
+ info_ptr += bytes_read;
+ break;
case DW_FORM_string:
DW_STRING (attr) = read_string (abfd, info_ptr, &bytes_read);
DW_STRING_IS_CANONICAL (attr) = 0;
@@ -7140,6 +7149,7 @@ read_attribute_value (struct attribute *attr, unsigned form,
DW_STRING_IS_CANONICAL (attr) = 0;
info_ptr += bytes_read;
break;
+ case DW_FORM_exprloc:
case DW_FORM_block:
blk = dwarf_alloc_block (cu);
blk->size = read_unsigned_leb128 (abfd, info_ptr, &bytes_read);
@@ -7164,6 +7174,9 @@ read_attribute_value (struct attribute *attr, unsigned form,
DW_UNSND (attr) = read_1_byte (abfd, info_ptr);
info_ptr += 1;
break;
+ case DW_FORM_flag_present:
+ DW_UNSND (attr) = 1;
+ break;
case DW_FORM_sdata:
DW_SND (attr) = read_signed_leb128 (abfd, info_ptr, &bytes_read);
info_ptr += bytes_read;
@@ -7680,7 +7693,7 @@ dwarf2_attr_no_follow (struct die_info *die, unsigned int name,
/* Return non-zero iff the attribute NAME is defined for the given DIE,
and holds a non-zero value. This function should only be used for
- DW_FORM_flag attributes. */
+ DW_FORM_flag or DW_FORM_flag_present attributes. */
static int
dwarf2_flag_true_p (struct die_info *die, unsigned name, struct dwarf2_cu *cu)
@@ -7862,6 +7875,21 @@ dwarf_decode_line_header (unsigned int offset, bfd *abfd,
line_ptr += offset_size;
lh->minimum_instruction_length = read_1_byte (abfd, line_ptr);
line_ptr += 1;
+ if (lh->version >= 4)
+ {
+ lh->maximum_ops_per_instruction = read_1_byte (abfd, line_ptr);
+ line_ptr += 1;
+ }
+ else
+ lh->maximum_ops_per_instruction = 1;
+
+ if (lh->maximum_ops_per_instruction == 0)
+ {
+ lh->maximum_ops_per_instruction = 1;
+ complaint (&symfile_complaints,
+ _("invalid maximum_ops_per_instruction in `.debug_line' section"));
+ }
+
lh->default_is_stmt = read_1_byte (abfd, line_ptr);
line_ptr += 1;
lh->line_base = read_1_signed_byte (abfd, line_ptr);
@@ -8010,6 +8038,7 @@ dwarf_decode_lines (struct line_header *lh, char *comp_dir, bfd *abfd,
int basic_block = 0;
int end_sequence = 0;
CORE_ADDR addr;
+ unsigned char op_index = 0;
if (!decode_for_pst_p && lh->num_file_names >= file)
{
@@ -8041,12 +8070,17 @@ dwarf_decode_lines (struct line_header *lh, char *comp_dir, bfd *abfd,
{
/* Special operand. */
adj_opcode = op_code - lh->opcode_base;
- address += (adj_opcode / lh->line_range)
- * lh->minimum_instruction_length;
+ address += (((op_index + (adj_opcode / lh->line_range))
+ / lh->maximum_ops_per_instruction)
+ * lh->minimum_instruction_length);
+ op_index = ((op_index + (adj_opcode / lh->line_range))
+ % lh->maximum_ops_per_instruction);
line += lh->line_base + (adj_opcode % lh->line_range);
if (lh->num_file_names < file || file == 0)
dwarf2_debug_line_missing_file_complaint ();
- else
+ /* For now we ignore lines not starting on an
+ instruction boundary. */
+ else if (op_index == 0)
{
lh->file_names[file - 1].included_p = 1;
if (!decode_for_pst_p && is_stmt)
@@ -8081,6 +8115,7 @@ dwarf_decode_lines (struct line_header *lh, char *comp_dir, bfd *abfd,
break;
case DW_LNE_set_address:
address = read_address (abfd, line_ptr, cu, &bytes_read);
+ op_index = 0;
line_ptr += bytes_read;
address += baseaddr;
break;
@@ -8146,9 +8181,17 @@ dwarf_decode_lines (struct line_header *lh, char *comp_dir, bfd *abfd,
basic_block = 0;
break;
case DW_LNS_advance_pc:
- address += lh->minimum_instruction_length
- * read_unsigned_leb128 (abfd, line_ptr, &bytes_read);
- line_ptr += bytes_read;
+ {
+ CORE_ADDR adjust
+ = read_unsigned_leb128 (abfd, line_ptr, &bytes_read);
+
+ address += (((op_index + adjust)
+ / lh->maximum_ops_per_instruction)
+ * lh->minimum_instruction_length);
+ op_index = ((op_index + adjust)
+ % lh->maximum_ops_per_instruction);
+ line_ptr += bytes_read;
+ }
break;
case DW_LNS_advance_line:
line += read_signed_leb128 (abfd, line_ptr, &bytes_read);
@@ -8195,11 +8238,19 @@ dwarf_decode_lines (struct line_header *lh, char *comp_dir, bfd *abfd,
instruction length since special opcode 255 would have
scaled the the increment. */
case DW_LNS_const_add_pc:
- address += (lh->minimum_instruction_length
- * ((255 - lh->opcode_base) / lh->line_range));
+ {
+ CORE_ADDR adjust = (255 - lh->opcode_base) / lh->line_range;
+
+ address += (((op_index + adjust)
+ / lh->maximum_ops_per_instruction)
+ * lh->minimum_instruction_length);
+ op_index = ((op_index + adjust)
+ % lh->maximum_ops_per_instruction);
+ }
break;
case DW_LNS_fixed_advance_pc:
address += read_2_bytes (abfd, line_ptr);
+ op_index = 0;
line_ptr += 2;
break;
default:
@@ -8761,6 +8812,7 @@ dwarf2_const_value (struct attribute *attr, struct symbol *sym,
case DW_FORM_block2:
case DW_FORM_block4:
case DW_FORM_block:
+ case DW_FORM_exprloc:
blk = DW_BLOCK (attr);
if (TYPE_LENGTH (SYMBOL_TYPE (sym)) != blk->size)
dwarf2_const_value_length_mismatch_complaint (SYMBOL_PRINT_NAME (sym),
@@ -10308,6 +10360,10 @@ dump_die_shallow (struct ui_file *f, int indent, struct die_info *die)
case DW_FORM_block1:
fprintf_unfiltered (f, "block: size %d", DW_BLOCK (&die->attrs[i])->size);
break;
+ case DW_FORM_exprloc:
+ fprintf_unfiltered (f, "expression: size %u",
+ DW_BLOCK (&die->attrs[i])->size);
+ break;
case DW_FORM_ref1:
case DW_FORM_ref2:
case DW_FORM_ref4:
@@ -10323,6 +10379,10 @@ dump_die_shallow (struct ui_file *f, int indent, struct die_info *die)
fprintf_unfiltered (f, "constant: %s",
pulongest (DW_UNSND (&die->attrs[i])));
break;
+ case DW_FORM_sec_offset:
+ fprintf_unfiltered (f, "section offset: %s",
+ pulongest (DW_UNSND (&die->attrs[i])));
+ break;
case DW_FORM_sig8:
if (DW_SIGNATURED_TYPE (&die->attrs[i]) != NULL)
fprintf_unfiltered (f, "signatured type, offset: 0x%x",
@@ -10343,6 +10403,9 @@ dump_die_shallow (struct ui_file *f, int indent, struct die_info *die)
else
fprintf_unfiltered (f, "flag: FALSE");
break;
+ case DW_FORM_flag_present:
+ fprintf_unfiltered (f, "flag: TRUE");
+ break;
case DW_FORM_indirect:
/* the reader will have reduced the indirect form to
the "base form" so this form should not occur */
@@ -11520,7 +11583,8 @@ attr_form_is_block (struct attribute *attr)
attr->form == DW_FORM_block1
|| attr->form == DW_FORM_block2
|| attr->form == DW_FORM_block4
- || attr->form == DW_FORM_block);
+ || attr->form == DW_FORM_block
+ || attr->form == DW_FORM_exprloc);
}
/* Return non-zero if ATTR's value is a section offset --- classes
@@ -11535,7 +11599,8 @@ static int
attr_form_is_section_offset (struct attribute *attr)
{
return (attr->form == DW_FORM_data4
- || attr->form == DW_FORM_data8);
+ || attr->form == DW_FORM_data8
+ || attr->form == DW_FORM_sec_offset);
}

View File

@ -0,0 +1,56 @@
commit 669907bd6d54ae8e85b1278f0f16f8641ce6802d
Author: Tom Tromey <tromey@redhat.com>
Date: Tue Apr 20 21:19:07 2010 +0000
* dwarf2read.c (dwarf2_compute_name): Handle DW_AT_linkage_name.
(read_partial_die): Likewise.
(dwarf_attr_name): Likewise.
### a/gdb/ChangeLog
### b/gdb/ChangeLog
## -1,3 +1,9 @@
+2010-04-20 Tom Tromey <tromey@redhat.com>
+
+ * dwarf2read.c (dwarf2_compute_name): Handle DW_AT_linkage_name.
+ (read_partial_die): Likewise.
+ (dwarf_attr_name): Likewise.
+
2010-04-20 Chris Moller <cmoller@redhat.com>
PR 10867
--- gdb-7.1/gdb/dwarf2read.c.orig 2010-06-09 14:38:01.000000000 +0200
+++ gdb-7.1/gdb/dwarf2read.c 2010-06-09 14:49:53.000000000 +0200
@@ -7675,7 +7675,11 @@ read_partial_die (struct partial_die_inf
break;
}
break;
+ case DW_AT_linkage_name:
case DW_AT_MIPS_linkage_name:
+ /* Note that both forms of linkage name might appear. We
+ assume they will be the same, and we only store the last
+ one we see. */
if (cu->language == language_ada)
part_die->name = DW_STRING (&attr);
break;
@@ -10167,7 +10171,11 @@ dwarf2_name (struct die_info *die, struc
struct attribute *attr = NULL;
if (cu->language == language_ada)
- attr = dwarf2_attr (die, DW_AT_MIPS_linkage_name, cu);
+ {
+ attr = dwarf2_attr (die, DW_AT_linkage_name, cu);
+ if (attr == NULL)
+ attr = dwarf2_attr (die, DW_AT_MIPS_linkage_name, cu);
+ }
if (!attr)
attr = dwarf2_attr (die, DW_AT_name, cu);
@@ -10555,6 +10563,8 @@ dwarf_attr_name (unsigned attr)
/* DWARF 4 values. */
case DW_AT_signature:
return "DW_AT_signature";
+ case DW_AT_linkage_name:
+ return "DW_AT_linkage_name";
/* SGI/MIPS extensions. */
#ifdef MIPS /* collides with DW_AT_HP_block_index */
case DW_AT_MIPS_fde:

View File

@ -0,0 +1,240 @@
--- /dev/null 2010-06-08 20:35:46.800278452 +0200
+++ gdb-7.1/gdb/testsuite/gdb.dwarf2/rh-dwarf4-x86_64.S 2010-06-09 15:22:57.000000000 +0200
@@ -0,0 +1,167 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+ 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/>. */
+
+ .file "rh-dwarf4-x86_64.c"
+ .section .debug_abbrev,"",@progbits
+.Ldebug_abbrev0:
+ .section .debug_info,"",@progbits
+.Ldebug_info0:
+ .section .debug_line,"",@progbits
+.Ldebug_line0:
+ .text
+.Ltext0:
+.globl main
+ .type main, @function
+main:
+.LFB0:
+ .file 1 "gdb.dwarf2/rh-dwarf4-x86_64.c"
+ # gdb.dwarf2/rh-dwarf4-x86_64.c:20
+ .loc 1 20 0
+ .cfi_startproc
+ # basic block 2
+ pushq %rbp
+ .cfi_def_cfa_offset 16
+ movq %rsp, %rbp
+ .cfi_offset 6, -16
+ .cfi_def_cfa_register 6
+ # gdb.dwarf2/rh-dwarf4-x86_64.c:21
+ .loc 1 21 0
+ movl $0, %eax
+ # gdb.dwarf2/rh-dwarf4-x86_64.c:22
+ .loc 1 22 0
+ leave
+ .cfi_def_cfa 7, 8
+ ret
+ .cfi_endproc
+.LFE0:
+ .size main, .-main
+.Letext0:
+ .section .debug_info
+ .long 0x4e # Length of Compilation Unit Info
+ .value 0x4 # DWARF version number
+ .long .Ldebug_abbrev0 # Offset Into Abbrev. Section
+ .byte 0x8 # Pointer Size (in bytes)
+ .uleb128 0x1 # (DIE (0xb) DW_TAG_compile_unit)
+ .long .LASF0 # DW_AT_producer: "GNU C 4.4.4 20100503 (Red Hat 4.4.4-2)"
+ .byte 0x1 # DW_AT_language
+ .long .LASF1 # DW_AT_name: "gdb.dwarf2/rh-dwarf4-x86_64.c"
+ .long .LASF2 # DW_AT_comp_dir
+ .quad .Ltext0 # DW_AT_low_pc
+ .quad .Letext0 # DW_AT_high_pc
+ .long .Ldebug_line0 # DW_AT_stmt_list
+ .uleb128 0x2 # (DIE (0x2d) DW_TAG_subprogram)
+ # DW_AT_external
+ .long .LASF3 # DW_AT_name: "main"
+ .byte 0x1 # DW_AT_decl_file (gdb.dwarf2/rh-dwarf4-x86_64.c)
+ .byte 0x13 # DW_AT_decl_line
+ # DW_AT_prototyped
+ .long 0x4a # DW_AT_type
+ .quad .LFB0 # DW_AT_low_pc
+ .quad .LFE0 # DW_AT_high_pc
+ .uleb128 0x1 # DW_AT_frame_base
+ .byte 0x9c # DW_OP_call_frame_cfa
+ .uleb128 0x3 # (DIE (0x4a) DW_TAG_base_type)
+ .byte 0x4 # DW_AT_byte_size
+ .byte 0x5 # DW_AT_encoding
+ .ascii "int\0" # DW_AT_name
+ .byte 0x0 # end of children of DIE 0xb
+ .section .debug_abbrev
+ .uleb128 0x1 # (abbrev code)
+ .uleb128 0x11 # (TAG: DW_TAG_compile_unit)
+ .byte 0x1 # DW_children_yes
+ .uleb128 0x25 # (DW_AT_producer)
+ .uleb128 0xe # (DW_FORM_strp)
+ .uleb128 0x13 # (DW_AT_language)
+ .uleb128 0xb # (DW_FORM_data1)
+ .uleb128 0x3 # (DW_AT_name)
+ .uleb128 0xe # (DW_FORM_strp)
+ .uleb128 0x1b # (DW_AT_comp_dir)
+ .uleb128 0xe # (DW_FORM_strp)
+ .uleb128 0x11 # (DW_AT_low_pc)
+ .uleb128 0x1 # (DW_FORM_addr)
+ .uleb128 0x12 # (DW_AT_high_pc)
+ .uleb128 0x1 # (DW_FORM_addr)
+ .uleb128 0x10 # (DW_AT_stmt_list)
+ .uleb128 0x17 # (DW_FORM_sec_offset)
+ .byte 0x0
+ .byte 0x0
+ .uleb128 0x2 # (abbrev code)
+ .uleb128 0x2e # (TAG: DW_TAG_subprogram)
+ .byte 0x0 # DW_children_no
+ .uleb128 0x3f # (DW_AT_external)
+ .uleb128 0x19 # (DW_FORM_flag_present)
+ .uleb128 0x3 # (DW_AT_name)
+ .uleb128 0xe # (DW_FORM_strp)
+ .uleb128 0x3a # (DW_AT_decl_file)
+ .uleb128 0xb # (DW_FORM_data1)
+ .uleb128 0x3b # (DW_AT_decl_line)
+ .uleb128 0xb # (DW_FORM_data1)
+ .uleb128 0x27 # (DW_AT_prototyped)
+ .uleb128 0x19 # (DW_FORM_flag_present)
+ .uleb128 0x49 # (DW_AT_type)
+ .uleb128 0x13 # (DW_FORM_ref4)
+ .uleb128 0x11 # (DW_AT_low_pc)
+ .uleb128 0x1 # (DW_FORM_addr)
+ .uleb128 0x12 # (DW_AT_high_pc)
+ .uleb128 0x1 # (DW_FORM_addr)
+ .uleb128 0x40 # (DW_AT_frame_base)
+ .uleb128 0x18 # (DW_FORM_exprloc)
+ .byte 0x0
+ .byte 0x0
+ .uleb128 0x3 # (abbrev code)
+ .uleb128 0x24 # (TAG: DW_TAG_base_type)
+ .byte 0x0 # DW_children_no
+ .uleb128 0xb # (DW_AT_byte_size)
+ .uleb128 0xb # (DW_FORM_data1)
+ .uleb128 0x3e # (DW_AT_encoding)
+ .uleb128 0xb # (DW_FORM_data1)
+ .uleb128 0x3 # (DW_AT_name)
+ .uleb128 0x8 # (DW_FORM_string)
+ .byte 0x0
+ .byte 0x0
+ .byte 0x0
+ .section .debug_pubnames,"",@progbits
+ .long 0x17 # Length of Public Names Info
+ .value 0x2 # DWARF Version
+ .long .Ldebug_info0 # Offset of Compilation Unit Info
+ .long 0x52 # Compilation Unit Length
+ .long 0x2d # DIE offset
+ .ascii "main\0" # external name
+ .long 0x0
+ .section .debug_aranges,"",@progbits
+ .long 0x2c # Length of Address Ranges Info
+ .value 0x2 # DWARF Version
+ .long .Ldebug_info0 # Offset of Compilation Unit Info
+ .byte 0x8 # Size of Address
+ .byte 0x0 # Size of Segment Descriptor
+ .value 0x0 # Pad to 16 byte boundary
+ .value 0x0
+ .quad .Ltext0 # Address
+ .quad .Letext0-.Ltext0 # Length
+ .quad 0x0
+ .quad 0x0
+ .section .debug_str,"MS",@progbits,1
+.LASF2:
+ .string "."
+.LASF0:
+ .string "GNU C 4.4.4 20100503 (Red Hat 4.4.4-2)"
+.LASF1:
+ .string "gdb.dwarf2/rh-dwarf4-x86_64.c"
+.LASF3:
+ .string "main"
+ .ident "GCC: (GNU) 4.4.4 20100503 (Red Hat 4.4.4-2)"
+ .section .note.GNU-stack,"",@progbits
--- /dev/null 2010-06-08 20:35:46.800278452 +0200
+++ gdb-7.1/gdb/testsuite/gdb.dwarf2/rh-dwarf4-x86_64.c 2010-06-09 15:21:35.000000000 +0200
@@ -0,0 +1,22 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+ 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/>. */
+
+int
+main (void)
+{
+ return 0;
+}
--- /dev/null 2010-06-08 20:35:46.800278452 +0200
+++ gdb-7.1/gdb/testsuite/gdb.dwarf2/rh-dwarf4-x86_64.exp 2010-06-09 15:26:21.000000000 +0200
@@ -0,0 +1,42 @@
+# 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/>.
+
+# This test can only be run on targets which support DWARF-2 and use gas.
+# For now pick a sampling of likely targets.
+if {![istarget *-*-linux*]
+ && ![istarget *-*-gnu*]
+ && ![istarget *-*-elf*]
+ && ![istarget *-*-openbsd*]
+ && ![istarget arm-*-eabi*]
+ && ![istarget powerpc-*-eabi*]} {
+ return 0
+}
+
+if {![istarget x86_64-*]} {
+ return 0
+}
+
+set testfile "rh-dwarf4-x86_64"
+set srcfile ${testfile}.S
+set executable ${testfile}.x
+set binfile ${objdir}/${subdir}/${executable}
+
+if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" object {}] != "" } {
+ return -1
+}
+
+clean_restart $executable
+
+gdb_test "ptype main" {type = int \(void\)}

View File

@ -0,0 +1,274 @@
commit f49f91e9c3eaba847f75f5c46e77e261a76d9a9b
Author: Jan Kratochvil <jan.kratochvil@redhat.com>
Date: Mon Jun 28 20:35:51 2010 +0000
gdb/
* cp-namespace.c (cp_lookup_nested_type): New variable
concatenated_name. Turn the current return condition into a reverse
one. Call also lookup_static_symbol_aux on the constructed qualified
name.
* symtab.c (lookup_symbol_aux): Move variable objfile and searching in
other files into a called ...
(lookup_static_symbol_aux): ... new function here.
* symtab.h (lookup_static_symbol_aux): New prototype.
* valops.c (value_maybe_namespace_elt): Call also
lookup_static_symbol_aux if we failed otherwise.
gdb/testsuite/
* gdb.cp/namespace.exp (whatis C::cOtherFileType)
(whatis ::C::cOtherFileType, whatis C::cOtherFileVar)
(whatis ::C::cOtherFileVar, print C::cOtherFileVar)
(print ::C::cOtherFileVar)
(whatis C::OtherFileClass::cOtherFileClassType)
(whatis ::C::OtherFileClass::cOtherFileClassType)
(print C::OtherFileClass::cOtherFileClassVar)
(print ::cOtherFileClassVar)
(print ::C::OtherFileClass::cOtherFileClassVar): New tests.
(ptype OtherFileClass, ptype ::C::OtherFileClass): Permit arbitrary
trailing content.
* gdb.cp/namespace1.cc (C::OtherFileClass::cOtherFileClassType)
(C::OtherFileClass::cOtherFileClassVar)
(C::OtherFileClass::cOtherFileClassVar_use, C::cOtherFileType)
(C::cOtherFileVar, C::cOtherFileVar_use): New.
### a/gdb/ChangeLog
### b/gdb/ChangeLog
## -1,5 +1,18 @@
2010-06-28 Jan Kratochvil <jan.kratochvil@redhat.com>
+ * cp-namespace.c (cp_lookup_nested_type): New variable
+ concatenated_name. Turn the current return condition into a reverse
+ one. Call also lookup_static_symbol_aux on the constructed qualified
+ name.
+ * symtab.c (lookup_symbol_aux): Move variable objfile and searching in
+ other files into a called ...
+ (lookup_static_symbol_aux): ... new function here.
+ * symtab.h (lookup_static_symbol_aux): New prototype.
+ * valops.c (value_maybe_namespace_elt): Call also
+ lookup_static_symbol_aux if we failed otherwise.
+
+2010-06-28 Jan Kratochvil <jan.kratochvil@redhat.com>
+
Fix PR c++/11703 and PR gdb/1448.
* c-exp.y (yylex) <last_was_coloncolon && first_was_coloncolon>: Add
FIRST_ITER check.
Index: gdb-7.1/gdb/cp-namespace.c
===================================================================
--- gdb-7.1.orig/gdb/cp-namespace.c 2010-06-29 17:54:17.000000000 +0200
+++ gdb-7.1/gdb/cp-namespace.c 2010-06-29 17:59:32.000000000 +0200
@@ -585,10 +585,24 @@ cp_lookup_nested_type (struct type *pare
nested_name,
block,
VAR_DOMAIN);
- if (sym == NULL || SYMBOL_CLASS (sym) != LOC_TYPEDEF)
- return NULL;
- else
+ char *concatenated_name;
+
+ if (sym != NULL && SYMBOL_CLASS (sym) == LOC_TYPEDEF)
+ return SYMBOL_TYPE (sym);
+
+ /* Now search all static file-level symbols. Not strictly correct,
+ but more useful than an error. We do not try to guess any imported
+ namespace as even the fully specified namespace seach is is already
+ not C++ compliant and more assumptions could make it too magic. */
+
+ concatenated_name = alloca (strlen (parent_name) + 2
+ + strlen (nested_name) + 1);
+ sprintf (concatenated_name, "%s::%s", parent_name, nested_name);
+ sym = lookup_static_symbol_aux (concatenated_name, VAR_DOMAIN);
+ if (sym != NULL && SYMBOL_CLASS (sym) == LOC_TYPEDEF)
return SYMBOL_TYPE (sym);
+
+ return NULL;
}
default:
internal_error (__FILE__, __LINE__,
Index: gdb-7.1/gdb/symtab.h
===================================================================
--- gdb-7.1.orig/gdb/symtab.h 2010-06-29 17:54:16.000000000 +0200
+++ gdb-7.1/gdb/symtab.h 2010-06-29 18:00:37.000000000 +0200
@@ -1036,6 +1036,12 @@ extern struct partial_symbol *lookup_par
const char *, int,
domain_enum);
+/* Lookup a symbol only in the file static scope of all the objfiles. */
+
+struct symbol *lookup_static_symbol_aux (const char *name,
+ const domain_enum domain);
+
+
/* lookup a symbol by name, within a specified block */
extern struct symbol *lookup_block_symbol (const struct block *, const char *,
Index: gdb-7.1/gdb/testsuite/gdb.cp/namespace.exp
===================================================================
--- gdb-7.1.orig/gdb/testsuite/gdb.cp/namespace.exp 2010-06-29 17:54:11.000000000 +0200
+++ gdb-7.1/gdb/testsuite/gdb.cp/namespace.exp 2010-06-29 18:17:17.000000000 +0200
@@ -217,6 +217,70 @@ gdb_expect {
gdb_test "break BBB::Class::xyzq" \
"Breakpoint.*at $hex: file.*namespace.cc, line 68\\."
+# Tests accessing static elements in namespace of other file.
+
+gdb_test "whatis C::cOtherFileType" "type = short"
+gdb_test "whatis ::C::cOtherFileType" "type = short"
+gdb_test "whatis C::cOtherFileVar" "type = const C::cOtherFileType"
+gdb_test "whatis ::C::cOtherFileVar" "type = const C::cOtherFileType"
+gdb_test "print C::cOtherFileVar" "\\$\[0-9\].* = 319"
+gdb_test "print ::C::cOtherFileVar" "\\$\[0-9\].* = 319"
+
+if {[test_compiler_info {gcc-[0-3]-*}]
+ || [test_compiler_info {gcc-4-[0-4]-*}]} {
+ # The type in class is missing in older GCCs.
+ setup_xfail *-*-*
+}
+gdb_test "whatis C::OtherFileClass::cOtherFileClassType" "type = short"
+if {[test_compiler_info {gcc-[0-3]-*}]
+ || [test_compiler_info {gcc-4-[0-4]-*}]} {
+ # The type in class is missing in older GCCs.
+ setup_xfail *-*-*
+}
+gdb_test "whatis ::C::OtherFileClass::cOtherFileClassType" "type = short"
+
+set test "print C::OtherFileClass::cOtherFileClassVar"
+gdb_test_multiple $test $test {
+ -re "\\$\[0-9\].* = 318\r\n$gdb_prompt $" {
+ pass $test
+ }
+ -re "static field cOtherFileClassVar has been optimized out\r\n$gdb_prompt $" {
+ setup_kfail "c++/11702" "*-*-*"
+ fail $test
+ }
+}
+
+# FSF GCC <=4.4 creates unqualified DIE "cOtherFileClassVar" ignoring the
+# namespace the same way older GDB did.
+set test "print ::cOtherFileClassVar"
+set test2 "print ::C::OtherFileClass::cOtherFileClassVar"
+gdb_test_multiple $test $test {
+ -re "No symbol \"cOtherFileClassVar\" in current context\\.\r\n$gdb_prompt $" {
+ pass $test
+
+ gdb_test_multiple $test2 $test2 {
+ -re "\\$\[0-9\].* = 318\r\n$gdb_prompt $" {
+ pass $test2
+ }
+ -re "static field cOtherFileClassVar has been optimized out\r\n$gdb_prompt $" {
+ setup_kfail "c++/11702" "*-*-*"
+ fail $test2
+ }
+ }
+
+ }
+ -re "\\$\[0-9\].* = 318\r\n$gdb_prompt $" {
+ if {[test_compiler_info {gcc-[0-3]-*}]
+ || [test_compiler_info {gcc-4-[0-4]-*}]} {
+ # Do not permit to XFAIL on recent GCCs.
+ setup_xfail *-*-*
+ }
+ fail $test
+
+ unresolved $test2
+ }
+}
+
# Test to see if the appropriate namespaces are in scope when trying
# to print out stuff from within a function defined within a
# namespace.
@@ -260,7 +324,7 @@ gdb_test "ptype C::NestedClass" "No symb
# Tests involving multiple files
gdb_test "print cOtherFile" "\\$\[0-9\].* = 316"
-gdb_test "ptype OtherFileClass" "type = (class C::OtherFileClass \{\r\n public:|struct C::OtherFileClass \{)\r\n int z;\r\n\}"
+gdb_test "ptype OtherFileClass" "type = (class C::OtherFileClass \{\r\n public:|struct C::OtherFileClass \{)\r\n int z;\r\n.*\}"
cp_test_ptype_class \
"ptype ::C::OtherFileClass" "" "class" "C::OtherFileClass" \
{
Index: gdb-7.1/gdb/testsuite/gdb.cp/namespace1.cc
===================================================================
--- gdb-7.1.orig/gdb/testsuite/gdb.cp/namespace1.cc 2010-01-01 08:32:01.000000000 +0100
+++ gdb-7.1/gdb/testsuite/gdb.cp/namespace1.cc 2010-06-29 17:56:42.000000000 +0200
@@ -21,7 +21,15 @@ namespace C
class OtherFileClass {
public:
int z;
+
+ typedef short cOtherFileClassType;
+ static const cOtherFileClassType cOtherFileClassVar = 318;
+ cOtherFileClassType cOtherFileClassVar_use ();
};
+ OtherFileClass::cOtherFileClassType OtherFileClass::cOtherFileClassVar_use ()
+ {
+ return cOtherFileClassVar;
+ }
namespace {
int cXOtherFile = 29;
@@ -35,6 +43,13 @@ namespace C
static OtherFileClass *c = new OtherFileClass();
c->z = cOtherFile + cXOtherFile;
}
+
+ typedef short cOtherFileType;
+ static const cOtherFileType cOtherFileVar = 319;
+ cOtherFileType cOtherFileVar_use ()
+ {
+ return cOtherFileVar;
+ }
}
namespace {
Index: gdb-7.1/gdb/valops.c
===================================================================
--- gdb-7.1.orig/gdb/valops.c 2010-06-29 17:54:16.000000000 +0200
+++ gdb-7.1/gdb/valops.c 2010-06-29 18:15:00.000000000 +0200
@@ -3253,9 +3253,17 @@ value_maybe_namespace_elt (const struct
struct symbol *sym;
struct value *result;
- sym = cp_lookup_symbol_namespace(namespace_name, name,
- get_selected_block (0),
- VAR_DOMAIN);
+ sym = cp_lookup_symbol_namespace (namespace_name, name,
+ get_selected_block (0), VAR_DOMAIN);
+
+ if (sym == NULL)
+ {
+ char *concatenated_name = alloca (strlen (namespace_name) + 2
+ + strlen (name) + 1);
+
+ sprintf (concatenated_name, "%s::%s", namespace_name, name);
+ sym = lookup_static_symbol_aux (concatenated_name, VAR_DOMAIN);
+ }
if (sym == NULL)
return NULL;
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -1122,10 +1121,21 @@ lookup_symbol_aux (const char *name, const struct block *block,
return sym;
/* Now search all static file-level symbols. Not strictly correct,
- but more useful than an error. Do the symtabs first, then check
- the psymtabs. If a psymtab indicates the existence of the
- desired name as a file-level static, then do psymtab-to-symtab
- conversion on the fly and return the found symbol. */
+ but more useful than an error. */
+
+ return lookup_static_symbol_aux (name, domain);
+}
+
+/* Search all static file-level symbols for NAME from DOMAIN. Do the symtabs
+ first, then check the psymtabs. If a psymtab indicates the existence of the
+ desired name as a file-level static, then do psymtab-to-symtab conversion on
+ the fly and return the found symbol. */
+
+struct symbol *
+lookup_static_symbol_aux (const char *name, const domain_enum domain)
+{
+ struct objfile *objfile;
+ struct symbol *sym;
sym = lookup_symbol_aux_symtabs (STATIC_BLOCK, name, domain);
if (sym != NULL)

View File

@ -0,0 +1,308 @@
commit 758a1f7149cb7469c7e6bb30cb572715ee90a6e8
Author: Jan Kratochvil <jan.kratochvil@redhat.com>
Date: Mon Jun 28 20:39:27 2010 +0000
gdb/
* c-typeprint.c (c_type_print_base): For no fields check include also
TYPE_TYPEDEF_FIELD_COUNT. Print new typedefs section.
* dwarf2read.c (struct typedef_field_list)
(struct field_info) <typedef_field_list, typedef_field_list_count>: New.
(dwarf2_add_typedef): New.
(read_structure_type): Call dwarf2_add_typedef for DW_TAG_typedef.
Copy also FI.TYPEDEF_FIELD_LIST.
* gdbtypes.h (struct typedef_field)
(struct cplus_struct_type) <typedef_field, typedef_field_count>
(TYPE_TYPEDEF_FIELD_ARRAY, TYPE_TYPEDEF_FIELD, TYPE_TYPEDEF_FIELD_NAME)
(TYPE_TYPEDEF_FIELD_TYPE, TYPE_TYPEDEF_FIELD_COUNT): New.
gdb/testsuite/
* gdb.cp/namespace.exp (ptype OtherFileClass typedefs)
(ptype ::C::OtherFileClass typedefs): New.
* gdb.cp/namespace1.cc (C::OtherFileClass::cOtherFileClassType2)
(C::OtherFileClass::cOtherFileClassVar2): New.
(C::OtherFileClass::cOtherFileClassVar_use): Use also
cOtherFileClassVar2.
(C::cOtherFileType2, C::cOtherFileVar2): New.
(C::cOtherFileVar_use): use also cOtherFileVar2.
* gdb.cp/userdef.exp (ptype &*c): Permit arbitrary trailing text.
### a/gdb/ChangeLog
### b/gdb/ChangeLog
## -1,5 +1,19 @@
2010-06-28 Jan Kratochvil <jan.kratochvil@redhat.com>
+ * c-typeprint.c (c_type_print_base): For no fields check include also
+ TYPE_TYPEDEF_FIELD_COUNT. Print new typedefs section.
+ * dwarf2read.c (struct typedef_field_list)
+ (struct field_info) <typedef_field_list, typedef_field_list_count>: New.
+ (dwarf2_add_typedef): New.
+ (read_structure_type): Call dwarf2_add_typedef for DW_TAG_typedef.
+ Copy also FI.TYPEDEF_FIELD_LIST.
+ * gdbtypes.h (struct typedef_field)
+ (struct cplus_struct_type) <typedef_field, typedef_field_count>
+ (TYPE_TYPEDEF_FIELD_ARRAY, TYPE_TYPEDEF_FIELD, TYPE_TYPEDEF_FIELD_NAME)
+ (TYPE_TYPEDEF_FIELD_TYPE, TYPE_TYPEDEF_FIELD_COUNT): New.
+
+2010-06-28 Jan Kratochvil <jan.kratochvil@redhat.com>
+
* cp-namespace.c (cp_lookup_nested_type): New variable
concatenated_name. Turn the current return condition into a reverse
one. Call also lookup_static_symbol_aux on the constructed qualified
Index: gdb-7.1/gdb/c-typeprint.c
===================================================================
--- gdb-7.1.orig/gdb/c-typeprint.c 2010-06-29 17:54:09.000000000 +0200
+++ gdb-7.1/gdb/c-typeprint.c 2010-06-29 18:17:48.000000000 +0200
@@ -774,7 +774,8 @@ c_type_print_base (struct type *type, st
cp_type_print_derivation_info (stream, type);
fprintf_filtered (stream, "{\n");
- if ((TYPE_NFIELDS (type) == 0) && (TYPE_NFN_FIELDS (type) == 0))
+ if (TYPE_NFIELDS (type) == 0 && TYPE_NFN_FIELDS (type) == 0
+ && TYPE_TYPEDEF_FIELD_COUNT (type) == 0)
{
if (TYPE_STUB (type))
fprintfi_filtered (level + 4, stream, _("<incomplete type>\n"));
@@ -1060,6 +1061,29 @@ c_type_print_base (struct type *type, st
}
}
+ /* Print typedefs defined in this class. */
+
+ if (TYPE_TYPEDEF_FIELD_COUNT (type) != 0)
+ {
+ if (TYPE_NFIELDS (type) != 0 || TYPE_NFN_FIELDS (type) != 0)
+ fprintf_filtered (stream, "\n");
+
+ for (i = 0; i < TYPE_TYPEDEF_FIELD_COUNT (type); i++)
+ {
+ struct type *target = TYPE_TYPEDEF_FIELD_TYPE (type, i);
+
+ /* Dereference the typedef declaration itself. */
+ gdb_assert (TYPE_CODE (target) == TYPE_CODE_TYPEDEF);
+ target = TYPE_TARGET_TYPE (target);
+
+ print_spaces_filtered (level + 4, stream);
+ fprintf_filtered (stream, "typedef ");
+ c_print_type (target, (char *) TYPE_TYPEDEF_FIELD_NAME (type, i),
+ stream, show - 1, level + 4);
+ fprintf_filtered (stream, ";\n");
+ }
+ }
+
fprintfi_filtered (level, stream, "}");
if (TYPE_LOCALTYPE_PTR (type) && show >= 0)
Index: gdb-7.1/gdb/dwarf2read.c
===================================================================
--- gdb-7.1.orig/gdb/dwarf2read.c 2010-06-29 17:54:28.000000000 +0200
+++ gdb-7.1/gdb/dwarf2read.c 2010-06-29 18:17:48.000000000 +0200
@@ -722,6 +722,16 @@ struct field_info
/* Number of entries in the fnfieldlists array. */
int nfnfields;
+
+ /* typedefs defined inside this class. TYPEDEF_FIELD_LIST contains head of
+ a NULL terminated list of TYPEDEF_FIELD_LIST_COUNT elements. */
+ struct typedef_field_list
+ {
+ struct typedef_field field;
+ struct typedef_field_list *next;
+ }
+ *typedef_field_list;
+ unsigned typedef_field_list_count;
};
/* One item on the queue of compilation units to read in full symbols
@@ -5075,6 +5085,39 @@ dwarf2_add_field (struct field_info *fip
}
}
+/* Add a typedef defined in the scope of the FIP's class. */
+
+static void
+dwarf2_add_typedef (struct field_info *fip, struct die_info *die,
+ struct dwarf2_cu *cu)
+{
+ struct objfile *objfile = cu->objfile;
+ struct gdbarch *gdbarch = get_objfile_arch (objfile);
+ struct typedef_field_list *new_field;
+ struct attribute *attr;
+ struct typedef_field *fp;
+ char *fieldname = "";
+
+ /* Allocate a new field list entry and link it in. */
+ new_field = xzalloc (sizeof (*new_field));
+ make_cleanup (xfree, new_field);
+
+ gdb_assert (die->tag == DW_TAG_typedef);
+
+ fp = &new_field->field;
+
+ /* Get name of field. */
+ fp->name = dwarf2_name (die, cu);
+ if (fp->name == NULL)
+ return;
+
+ fp->type = read_type_die (die, cu);
+
+ new_field->next = fip->typedef_field_list;
+ fip->typedef_field_list = new_field;
+ fip->typedef_field_list_count++;
+}
+
/* Create the vector of fields, and attach it to the type. */
static void
@@ -5600,6 +5643,8 @@ read_structure_type (struct die_info *di
/* C++ base class field. */
dwarf2_add_field (&fi, child_die, cu);
}
+ else if (child_die->tag == DW_TAG_typedef)
+ dwarf2_add_typedef (&fi, child_die, cu);
child_die = sibling_die (child_die);
}
@@ -5673,6 +5718,28 @@ read_structure_type (struct die_info *di
}
}
}
+
+ /* Copy fi.typedef_field_list linked list elements content into the
+ allocated array TYPE_TYPEDEF_FIELD_ARRAY (type). */
+ if (fi.typedef_field_list)
+ {
+ int i = fi.typedef_field_list_count;
+
+ TYPE_TYPEDEF_FIELD_ARRAY (type)
+ = TYPE_ALLOC (type, sizeof (TYPE_TYPEDEF_FIELD (type, 0)) * i);
+ TYPE_TYPEDEF_FIELD_COUNT (type) = i;
+
+ /* Reverse the list order to keep the debug info elements order. */
+ while (--i >= 0)
+ {
+ struct typedef_field *dest, *src;
+
+ dest = &TYPE_TYPEDEF_FIELD (type, i);
+ src = &fi.typedef_field_list->field;
+ fi.typedef_field_list = fi.typedef_field_list->next;
+ *dest = *src;
+ }
+ }
}
quirk_gcc_member_function_pointer (type, cu->objfile);
Index: gdb-7.1/gdb/gdbtypes.h
===================================================================
--- gdb-7.1.orig/gdb/gdbtypes.h 2010-06-29 17:54:17.000000000 +0200
+++ gdb-7.1/gdb/gdbtypes.h 2010-06-29 18:18:29.000000000 +0200
@@ -948,6 +948,19 @@ struct cplus_struct_type
member functions or virtual base classes. Minus one if not
dynamic. Zero if not yet computed. */
int is_dynamic : 2;
+
+ /* typedefs defined inside this class. TYPEDEF_FIELD points to an array of
+ TYPEDEF_FIELD_COUNT elements. */
+ struct typedef_field
+ {
+ /* Unqualified name to be prefixed by owning class qualified name. */
+ const char *name;
+
+ /* Type this typedef named NAME represents. */
+ struct type *type;
+ }
+ *typedef_field;
+ unsigned typedef_field_count;
};
/* Struct used for ranking a function for overload resolution */
@@ -1182,6 +1195,17 @@ extern void allocate_gnat_aux_type (stru
#define TYPE_LOCALTYPE_FILE(thistype) (TYPE_CPLUS_SPECIFIC(thistype)->localtype_ptr->file)
#define TYPE_LOCALTYPE_LINE(thistype) (TYPE_CPLUS_SPECIFIC(thistype)->localtype_ptr->line)
+#define TYPE_TYPEDEF_FIELD_ARRAY(thistype) \
+ TYPE_CPLUS_SPECIFIC (thistype)->typedef_field
+#define TYPE_TYPEDEF_FIELD(thistype, n) \
+ TYPE_CPLUS_SPECIFIC (thistype)->typedef_field[n]
+#define TYPE_TYPEDEF_FIELD_NAME(thistype, n) \
+ TYPE_TYPEDEF_FIELD (thistype, n).name
+#define TYPE_TYPEDEF_FIELD_TYPE(thistype, n) \
+ TYPE_TYPEDEF_FIELD (thistype, n).type
+#define TYPE_TYPEDEF_FIELD_COUNT(thistype) \
+ TYPE_CPLUS_SPECIFIC (thistype)->typedef_field_count
+
#define TYPE_IS_OPAQUE(thistype) (((TYPE_CODE (thistype) == TYPE_CODE_STRUCT) || \
(TYPE_CODE (thistype) == TYPE_CODE_UNION)) && \
(TYPE_NFIELDS (thistype) == 0) && \
Index: gdb-7.1/gdb/testsuite/gdb.cp/namespace.exp
===================================================================
--- gdb-7.1.orig/gdb/testsuite/gdb.cp/namespace.exp 2010-06-29 18:17:17.000000000 +0200
+++ gdb-7.1/gdb/testsuite/gdb.cp/namespace.exp 2010-06-29 18:18:58.000000000 +0200
@@ -332,6 +332,21 @@ cp_test_ptype_class \
}
gdb_test "ptype C::OtherFileClass" "No symbol \"OtherFileClass\" in namespace \"C::C\"."
+# Test class typedefs printing.
+set expect "type = class C::OtherFileClass \{\r\n.*\r\n *typedef short cOtherFileClassType;\r\n *typedef long cOtherFileClassType2;\r\n\}"
+if {[test_compiler_info {gcc-[0-3]-*}]
+ || [test_compiler_info {gcc-4-[0-4]-*}]} {
+ # The type in class is missing in older GCCs.
+ setup_xfail *-*-*
+}
+gdb_test "ptype OtherFileClass" $expect "ptype OtherFileClass typedefs"
+if {[test_compiler_info {gcc-[0-3]-*}]
+ || [test_compiler_info {gcc-4-[0-4]-*}]} {
+ # The type in class is missing in older GCCs.
+ setup_xfail *-*-*
+}
+gdb_test "ptype ::C::OtherFileClass" $expect "ptype ::C::OtherFileClass typedefs"
+
# Some anonymous namespace tests.
gdb_test "print cX" "\\$\[0-9\].* = 6"
Index: gdb-7.1/gdb/testsuite/gdb.cp/namespace1.cc
===================================================================
--- gdb-7.1.orig/gdb/testsuite/gdb.cp/namespace1.cc 2010-06-29 17:56:42.000000000 +0200
+++ gdb-7.1/gdb/testsuite/gdb.cp/namespace1.cc 2010-06-29 18:17:48.000000000 +0200
@@ -23,12 +23,14 @@ namespace C
int z;
typedef short cOtherFileClassType;
+ typedef long cOtherFileClassType2;
static const cOtherFileClassType cOtherFileClassVar = 318;
+ static const cOtherFileClassType2 cOtherFileClassVar2 = 320;
cOtherFileClassType cOtherFileClassVar_use ();
};
OtherFileClass::cOtherFileClassType OtherFileClass::cOtherFileClassVar_use ()
{
- return cOtherFileClassVar;
+ return cOtherFileClassVar + cOtherFileClassVar2;
}
namespace {
@@ -45,10 +47,12 @@ namespace C
}
typedef short cOtherFileType;
+ typedef long cOtherFileType2;
static const cOtherFileType cOtherFileVar = 319;
+ static const cOtherFileType2 cOtherFileVar2 = 321;
cOtherFileType cOtherFileVar_use ()
{
- return cOtherFileVar;
+ return cOtherFileVar + cOtherFileVar2;
}
}
Index: gdb-7.1/gdb/testsuite/gdb.cp/userdef.exp
===================================================================
--- gdb-7.1.orig/gdb/testsuite/gdb.cp/userdef.exp 2010-06-29 17:54:11.000000000 +0200
+++ gdb-7.1/gdb/testsuite/gdb.cp/userdef.exp 2010-06-29 18:17:48.000000000 +0200
@@ -154,7 +154,7 @@ gdb_test "break A2::'operator +'" ".*Bre
gdb_test "print c" "\\\$\[0-9\]* = {m = {z = .*}}"
gdb_test "print *c" "\\\$\[0-9\]* = \\(Member &\\) @$hex: {z = .*}"
gdb_test "print &*c" "\\\$\[0-9\]* = \\(Member \\*\\) $hex"
-gdb_test "ptype &*c" "type = (struct|class) Member {(\[\r\n \]+public:)?\[\r\n \]+int z;\[\r\n\]+} &\\*"
+gdb_test "ptype &*c" "type = (struct|class) Member {(\[\r\n \]+public:)?\[\r\n \]+int z;\[\r\n\].*} &\\*"
gdb_test "print operator== (mem1, mem2)" " = false"
gdb_test "print operator== (mem1, mem1)" " = true"

View File

@ -0,0 +1,38 @@
commit 477c1359b217cdc052a7c9f83cae9c894396894c
Author: Jan Kratochvil <jan.kratochvil@redhat.com>
Date: Mon Jun 28 22:03:31 2010 +0000
gdb/
* dwarf2read.c (read_structure_type) <fi.typedef_field_list>: Call
ALLOCATE_CPLUS_STRUCT_TYPE.
### a/gdb/ChangeLog
### b/gdb/ChangeLog
## -1,3 +1,8 @@
+2010-06-28 Jan Kratochvil <jan.kratochvil@redhat.com>
+
+ * dwarf2read.c (read_structure_type) <fi.typedef_field_list>: Call
+ ALLOCATE_CPLUS_STRUCT_TYPE.
+
2010-06-28 Phil Muldoon <pmuldoon@redhat.com>
Tom Tromey <tromey@redhat.com>
Thiago Jung Bauermann <bauerman@br.ibm.com>
## -27,8 +32,6 @@
* python/py-inferior.c: New File.
* python/py-infthread.c: New File.
-
-
2010-06-28 Jan Kratochvil <jan.kratochvil@redhat.com>
* c-typeprint.c (c_type_print_base): For no fields check include also
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -5327,6 +5327,7 @@ read_structure_type (struct die_info *die, struct dwarf2_cu *cu)
{
int i = fi.typedef_field_list_count;
+ ALLOCATE_CPLUS_STRUCT_TYPE (type);
TYPE_TYPEDEF_FIELD_ARRAY (type)
= TYPE_ALLOC (type, sizeof (TYPE_TYPEDEF_FIELD (type, 0)) * i);
TYPE_TYPEDEF_FIELD_COUNT (type) = i;

View File

@ -0,0 +1,214 @@
commit 78c144e8c3ae7bb36d632f6bfaaaad9c97199ce6
Author: cmoller <cmoller>
Date: Tue Apr 20 20:22:09 2010 +0000
PR 10867
* cp-valprint.c (global): Adding new static array recursion
detection obstack.
(cp_print_value_fields, cp_print_static_field): Added new static
array recursion detection code.
* gdb.cp/Makefile.in (EXECUTABLES): Added pr10687
* gdb.cp/pr10687.cc: New file.
* gdb.cp/pr10687.exp: New file
### a/gdb/ChangeLog
### b/gdb/ChangeLog
## -1,3 +1,12 @@
+2010-04-20 Chris Moller <cmoller@redhat.com>
+
+ PR 10867
+
+ * cp-valprint.c (global): Adding new static array recursion
+ detection obstack.
+ (cp_print_value_fields, cp_print_static_field): Added new static
+ array recursion detection code.
+
2010-04-20 Mark Kettenis <kettenis@gnu.org>
* i386-linux-tdep.c (i386_linux_regset_sections): Size of the
Index: gdb-7.1/gdb/cp-valprint.c
===================================================================
--- gdb-7.1.orig/gdb/cp-valprint.c 2010-02-08 19:04:16.000000000 +0100
+++ gdb-7.1/gdb/cp-valprint.c 2010-06-28 20:21:53.000000000 +0200
@@ -71,6 +71,7 @@ show_static_field_print (struct ui_file
static struct obstack dont_print_vb_obstack;
static struct obstack dont_print_statmem_obstack;
+static struct obstack dont_print_stat_array_obstack;
extern void _initialize_cp_valprint (void);
@@ -155,12 +156,17 @@ cp_print_value_fields (struct type *type
{
int i, len, n_baseclasses;
int fields_seen = 0;
+ static int last_set_recurse = -1;
CHECK_TYPEDEF (type);
- if (recurse == 0
- && obstack_object_size (&dont_print_statmem_obstack) > 0)
- obstack_free (&dont_print_statmem_obstack, NULL);
+ if (recurse == 0)
+ {
+ if (obstack_object_size (&dont_print_statmem_obstack) > 0)
+ obstack_free (&dont_print_statmem_obstack, NULL);
+ if (obstack_object_size (&dont_print_stat_array_obstack) > 0)
+ obstack_free (&dont_print_stat_array_obstack, NULL);
+ }
fprintf_filtered (stream, "{");
len = TYPE_NFIELDS (type);
@@ -181,12 +187,20 @@ cp_print_value_fields (struct type *type
else
{
void *statmem_obstack_top = NULL;
+ void *stat_array_obstack_top = NULL;
if (dont_print_statmem == 0)
{
/* Set the current printed-statics stack top. */
statmem_obstack_top
= obstack_next_free (&dont_print_statmem_obstack);
+
+ if (last_set_recurse != recurse)
+ {
+ stat_array_obstack_top
+ = obstack_next_free (&dont_print_stat_array_obstack);
+ last_set_recurse = recurse;
+ }
}
for (i = n_baseclasses; i < len; i++)
@@ -307,9 +321,16 @@ cp_print_value_fields (struct type *type
if (dont_print_statmem == 0)
{
- /* In effect, a pop of the printed-statics stack. */
if (obstack_object_size (&dont_print_statmem_obstack) > 0)
obstack_free (&dont_print_statmem_obstack, statmem_obstack_top);
+
+ if (last_set_recurse != recurse)
+ {
+ if (obstack_object_size (&dont_print_stat_array_obstack) > 0)
+ obstack_free (&dont_print_stat_array_obstack,
+ stat_array_obstack_top);
+ last_set_recurse = -1;
+ }
}
if (options->pretty)
@@ -508,6 +529,7 @@ cp_print_static_field (struct type *type
const struct value_print_options *options)
{
struct value_print_options opts;
+
if (TYPE_CODE (type) == TYPE_CODE_STRUCT)
{
CORE_ADDR *first_dont_print;
@@ -542,6 +564,32 @@ cp_print_static_field (struct type *type
return;
}
+ if (TYPE_CODE (type) == TYPE_CODE_ARRAY)
+ {
+ struct type **first_dont_print;
+ int i;
+ struct type *target_type = TYPE_TARGET_TYPE (type);
+
+ first_dont_print
+ = (struct type **) obstack_base (&dont_print_stat_array_obstack);
+ i = obstack_object_size (&dont_print_stat_array_obstack)
+ / sizeof (CORE_ADDR);
+
+ while (--i >= 0)
+ {
+ if (target_type == first_dont_print[i])
+ {
+ fputs_filtered ("<same as static member of an already"
+ " seen type>",
+ stream);
+ return;
+ }
+ }
+
+ obstack_grow (&dont_print_stat_array_obstack, (char *) &target_type,
+ sizeof (struct type *));
+ }
+
opts = *options;
opts.deref_ref = 0;
val_print (type, value_contents_all (val),
@@ -672,6 +720,7 @@ Show printing of object's derived type b
show_objectprint,
&setprintlist, &showprintlist);
+ obstack_begin (&dont_print_stat_array_obstack, 32 * sizeof (CORE_ADDR));
obstack_begin (&dont_print_statmem_obstack, 32 * sizeof (CORE_ADDR));
obstack_begin (&dont_print_vb_obstack, 32 * sizeof (struct type *));
}
Index: gdb-7.1/gdb/testsuite/gdb.cp/pr10687.cc
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ gdb-7.1/gdb/testsuite/gdb.cp/pr10687.cc 2010-06-28 20:21:53.000000000 +0200
@@ -0,0 +1,24 @@
+class vec2
+{
+ public:
+ vec2() { _v[0] = _v[1] = 0; }
+ vec2(int x, int y) { _v[0] = x; _v[1] = y; }
+ static vec2 axis[2];
+ static vec2 axis6[6];
+ private:
+ int _v[2];
+};
+
+vec2 vec2::axis[2] = { vec2(1,0), vec2(0,1) };
+vec2 vec2::axis6[6] = {
+ vec2(1,0), vec2(0,1),
+ vec2(2,0), vec2(0,2),
+ vec2(3,0), vec2(0,3)
+};
+
+int main(int argc, char*argv[])
+{
+ vec2 a;
+
+ return 0; // marker
+}
Index: gdb-7.1/gdb/testsuite/gdb.cp/pr10687.exp
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ gdb-7.1/gdb/testsuite/gdb.cp/pr10687.exp 2010-06-28 20:21:53.000000000 +0200
@@ -0,0 +1,31 @@
+#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 pr10687
+set srcfile ${testfile}.cc
+if [prepare_for_testing $testfile.exp $testfile $srcfile {debug c++}] {
+ return -1
+}
+
+if ![runto_main] then {
+ fail "Can't run to main"
+ return
+}
+
+gdb_breakpoint [gdb_get_line_number "marker"]
+gdb_continue_to_breakpoint "marker"
+
+gdb_test "p a" "{static axis = {{static axis = <same as static member of an already.*"
+

View File

@ -0,0 +1,163 @@
commit d54f5671e190a5c0ca8fd1ff070372bf20eb42a8
Author: cmoller <cmoller>
Date: Wed Apr 21 17:33:51 2010 +0000
PR 9167
* cp-valprint.c (cp_print_value_fields): Replaced obstack_base()
method of popping recursion-detection stack with a method based on
obstack_object_size().
* gdb.cp/Makefile.in (EXECUTABLES): Added pr9167.
* gdb.cp/pr9167.cc: New file.
* gdb.cp/pr9167.exp: New file.
### a/gdb/ChangeLog
### b/gdb/ChangeLog
## -1,3 +1,10 @@
+2010-04-21 Chris Moller <cmoller@redhat.com>
+
+ PR 9167
+ * cp-valprint.c (cp_print_value_fields): Replaced obstack_base()
+ method of popping recursion-detection stack with a method based on
+ obstack_object_size().
+
2010-04-21 Pierre Muller <muller@ics.u-strasbg.fr>
PR pascal/11492.
## -3184,7 +3191,7 @@
addr_bit. Adjust LOAD_ADDR sign for cross-arch inferiors.
2010-02-17 Tristan Gingold <gingold@adacore.com>
- Petr Hluzín <petr.hluzin@gmail.com>
+ Petr Hluzín <petr.hluzin@gmail.com>
* avr-tdep.c (avr_scan_prologue): Convert an if statement to a
gdb_assert. Fix info->size for SIG prologue.
Index: gdb-7.1/gdb/cp-valprint.c
===================================================================
--- gdb-7.1.orig/gdb/cp-valprint.c 2010-06-28 20:21:53.000000000 +0200
+++ gdb-7.1/gdb/cp-valprint.c 2010-06-28 20:22:16.000000000 +0200
@@ -186,14 +186,13 @@ cp_print_value_fields (struct type *type
fprintf_filtered (stream, "<No data fields>");
else
{
- void *statmem_obstack_top = NULL;
+ int obstack_initial_size = 0;
void *stat_array_obstack_top = NULL;
if (dont_print_statmem == 0)
{
- /* Set the current printed-statics stack top. */
- statmem_obstack_top
- = obstack_next_free (&dont_print_statmem_obstack);
+ obstack_initial_size =
+ obstack_object_size (&dont_print_statmem_obstack);
if (last_set_recurse != recurse)
{
@@ -321,8 +320,19 @@ cp_print_value_fields (struct type *type
if (dont_print_statmem == 0)
{
- if (obstack_object_size (&dont_print_statmem_obstack) > 0)
- obstack_free (&dont_print_statmem_obstack, statmem_obstack_top);
+ int obstack_final_size =
+ obstack_object_size (&dont_print_statmem_obstack);
+
+ if (obstack_final_size > obstack_initial_size) {
+ /* In effect, a pop of the printed-statics stack. */
+
+ void *free_to_ptr =
+ obstack_next_free (&dont_print_statmem_obstack) -
+ (obstack_final_size - obstack_initial_size);
+
+ obstack_free (&dont_print_statmem_obstack,
+ free_to_ptr);
+ }
if (last_set_recurse != recurse)
{
@@ -555,7 +565,6 @@ cp_print_static_field (struct type *type
addr = value_address (val);
obstack_grow (&dont_print_statmem_obstack, (char *) &addr,
sizeof (CORE_ADDR));
-
CHECK_TYPEDEF (type);
cp_print_value_fields (type, value_enclosing_type (val),
value_contents_all (val),
Index: gdb-7.1/gdb/testsuite/gdb.cp/pr9167.cc
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ gdb-7.1/gdb/testsuite/gdb.cp/pr9167.cc 2010-06-28 20:22:16.000000000 +0200
@@ -0,0 +1,36 @@
+#include <iostream>
+
+template<typename DATA>
+struct ATB
+{
+ int data;
+ ATB() : data(0) {}
+};
+
+
+template<typename DATA,
+ typename DerivedType >
+class A : public ATB<DATA>
+{
+public:
+ static DerivedType const DEFAULT_INSTANCE;
+};
+
+template<typename DATA, typename DerivedType>
+const DerivedType A<DATA, DerivedType>::DEFAULT_INSTANCE;
+
+class B : public A<int, B>
+{
+
+};
+
+int main()
+{
+ B b;
+ // If this if-block is removed then GDB shall
+ // not infinitely recurse when trying to print b.
+
+ return 0; // marker
+}
+
+
Index: gdb-7.1/gdb/testsuite/gdb.cp/pr9167.exp
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ gdb-7.1/gdb/testsuite/gdb.cp/pr9167.exp 2010-06-28 20:22:16.000000000 +0200
@@ -0,0 +1,31 @@
+#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 pr9167
+set srcfile ${testfile}.cc
+if [prepare_for_testing $testfile.exp $testfile $srcfile {debug c++}] {
+ return -1
+}
+
+if ![runto_main] then {
+ fail "Can't run to main"
+ return
+}
+
+gdb_breakpoint [gdb_get_line_number "marker"]
+gdb_continue_to_breakpoint "marker"
+
+gdb_test "p b" "{<A<int, B>> = {<ATB<int>> = {data = 0}, static DEFAULT_INSTANCE = <optimized out>}, <No data fields>}"
+

View File

@ -0,0 +1,85 @@
commit 407cb192dcac2602aebaa7e262419adb580ecca6
Author: cmoller <cmoller>
Date: Thu Apr 22 20:12:06 2010 +0000
* cp-valprint.c (cp_print_value_fields): Replaced obstack_base()
method of popping recursion-detection stack with a method based on
obstack_object_size(). (Similar to the PR9167 patch below, but for
the static array obstack rather than the static member obstack.)
### a/gdb/ChangeLog
### b/gdb/ChangeLog
## -1,3 +1,10 @@
+2010-04-22 Chris Moller <cmoller@redhat.com>
+
+ * cp-valprint.c (cp_print_value_fields): Replaced obstack_base()
+ method of popping recursion-detection stack with a method based on
+ obstack_object_size(). (Similar to the PR9167 patch below, but for
+ the static array obstack rather than the static member obstack.)
+
2010-04-22 H.J. Lu <hongjiu.lu@intel.com>
* amd64-linux-nat.c (amd64_linux_gregset64_reg_offset): Removed.
--- a/gdb/cp-valprint.c
+++ b/gdb/cp-valprint.c
@@ -186,18 +186,18 @@ cp_print_value_fields (struct type *type, struct type *real_type,
fprintf_filtered (stream, "<No data fields>");
else
{
- int obstack_initial_size = 0;
- void *stat_array_obstack_top = NULL;
+ int statmem_obstack_initial_size = 0;
+ int stat_array_obstack_initial_size = 0;
if (dont_print_statmem == 0)
{
- obstack_initial_size =
+ statmem_obstack_initial_size =
obstack_object_size (&dont_print_statmem_obstack);
if (last_set_recurse != recurse)
{
- stat_array_obstack_top
- = obstack_next_free (&dont_print_stat_array_obstack);
+ stat_array_obstack_initial_size =
+ obstack_object_size (&dont_print_stat_array_obstack);
last_set_recurse = recurse;
}
}
@@ -323,12 +323,12 @@ cp_print_value_fields (struct type *type, struct type *real_type,
int obstack_final_size =
obstack_object_size (&dont_print_statmem_obstack);
- if (obstack_final_size > obstack_initial_size) {
+ if (obstack_final_size > statmem_obstack_initial_size) {
/* In effect, a pop of the printed-statics stack. */
void *free_to_ptr =
obstack_next_free (&dont_print_statmem_obstack) -
- (obstack_final_size - obstack_initial_size);
+ (obstack_final_size - statmem_obstack_initial_size);
obstack_free (&dont_print_statmem_obstack,
free_to_ptr);
@@ -336,9 +336,18 @@ cp_print_value_fields (struct type *type, struct type *real_type,
if (last_set_recurse != recurse)
{
- if (obstack_object_size (&dont_print_stat_array_obstack) > 0)
- obstack_free (&dont_print_stat_array_obstack,
- stat_array_obstack_top);
+ int obstack_final_size =
+ obstack_object_size (&dont_print_stat_array_obstack);
+
+ if (obstack_final_size > stat_array_obstack_initial_size)
+ {
+ void *free_to_ptr =
+ obstack_next_free (&dont_print_stat_array_obstack) -
+ (obstack_final_size - stat_array_obstack_initial_size);
+
+ obstack_free (&dont_print_stat_array_obstack,
+ free_to_ptr);
+ }
last_set_recurse = -1;
}
}

View File

@ -0,0 +1,42 @@
commit 744735550d4a4fd6d4be40776069d799dca5ee39
Author: Ulrich Weigand <uweigand@de.ibm.com>
Date: Mon Jun 14 16:09:55 2010 +0000
* cp-valprint.c (cp_print_static_field): Members of
dont_print_stat_array_obstack are of type "struct type *".
(_initialize_cp_valprint): Likewise.
### a/gdb/ChangeLog
### b/gdb/ChangeLog
## -1,5 +1,11 @@
2010-06-14 Ulrich Weigand <uweigand@de.ibm.com>
+ * cp-valprint.c (cp_print_static_field): Members of
+ dont_print_stat_array_obstack are of type "struct type *".
+ (_initialize_cp_valprint): Likewise.
+
+2010-06-14 Ulrich Weigand <uweigand@de.ibm.com>
+
* frame.c (frame_register_unwind): Do not access contents
of "optimized out" unwound register value.
--- a/gdb/cp-valprint.c
+++ b/gdb/cp-valprint.c
@@ -615,7 +615,7 @@ cp_print_static_field (struct type *type,
first_dont_print
= (struct type **) obstack_base (&dont_print_stat_array_obstack);
i = obstack_object_size (&dont_print_stat_array_obstack)
- / sizeof (CORE_ADDR);
+ / sizeof (struct type *);
while (--i >= 0)
{
@@ -764,7 +764,7 @@ Show printing of object's derived type based on vtable info."), NULL,
show_objectprint,
&setprintlist, &showprintlist);
- obstack_begin (&dont_print_stat_array_obstack, 32 * sizeof (CORE_ADDR));
+ obstack_begin (&dont_print_stat_array_obstack, 32 * sizeof (struct type *));
obstack_begin (&dont_print_statmem_obstack, 32 * sizeof (CORE_ADDR));
obstack_begin (&dont_print_vb_obstack, 32 * sizeof (struct type *));
}

View File

@ -0,0 +1,202 @@
commit 47c8c764a9be6d023eca450336e6d9de16970fc0
Author: Jan Kratochvil <jan.kratochvil@redhat.com>
Date: Mon Jun 28 16:59:43 2010 +0000
gdb/
* cp-valprint.c (cp_print_value_fields) <recurse == 0>: Call
obstack_begin after each obstack_free.
gdb/testsuite/
* gdb.cp/static-print-quit.exp, gdb.cp/static-print-quit.cc: New.
### a/gdb/ChangeLog
### b/gdb/ChangeLog
## -1,3 +1,8 @@
+2010-06-28 Jan Kratochvil <jan.kratochvil@redhat.com>
+
+ * cp-valprint.c (cp_print_value_fields) <recurse == 0>: Call
+ obstack_begin after each obstack_free.
+
2010-06-27 Doug Evans <dje@google.com>
* value.c (value_static_field): Use `switch' instead of `if'.
## -12,27 +17,27 @@
2010-06-25 Paul Hilfinger <hilfinger@adacore.com>
- * defs.h (make_command_stats_cleanup): Declare.
- (set_display_time): Declare.
- (set_display_space): Declare.
- * event-top.c (command_handler): Use make_command_stats_cleanup.
- * main.c (display_time, display_space): Move definitions to utils.c.
- (captured_main): Use make_command_stats_cleanup to get start-up
- statistics.
- Use set_display_time and set_display_space for processing OPT_STATISTICS
- case.
- * maint.c (maintenance_time_display): Use set_display_time.
- (maintenance_space_display): Use set_display_space.
- * top.c (execute_command): Remove obsolete 'maint time' code.
- (command_loop): Use make_command_stats_cleanup.
- * utils.c (struct cmd_stats): Structure for storing initial time
- and space usage.
- (display_time, display_space): Move definitions here from utils.c.
- (set_display_time): New function.
- (set_display_space): New function.
- (make_command_stats_cleanup): New function.
- (report_command_stats): New auxiliary function for
- make_command_stats_cleanup.
+ * defs.h (make_command_stats_cleanup): Declare.
+ (set_display_time): Declare.
+ (set_display_space): Declare.
+ * event-top.c (command_handler): Use make_command_stats_cleanup.
+ * main.c (display_time, display_space): Move definitions to utils.c.
+ (captured_main): Use make_command_stats_cleanup to get start-up
+ statistics.
+ Use set_display_time and set_display_space for processing OPT_STATISTICS
+ case.
+ * maint.c (maintenance_time_display): Use set_display_time.
+ (maintenance_space_display): Use set_display_space.
+ * top.c (execute_command): Remove obsolete 'maint time' code.
+ (command_loop): Use make_command_stats_cleanup.
+ * utils.c (struct cmd_stats): Structure for storing initial time
+ and space usage.
+ (display_time, display_space): Move definitions here from utils.c.
+ (set_display_time): New function.
+ (set_display_space): New function.
+ (make_command_stats_cleanup): New function.
+ (report_command_stats): New auxiliary function for
+ make_command_stats_cleanup.
2010-06-25 Ulrich Weigand <uweigand@de.ibm.com>
## -6103,7 +6108,7 @@
PR gdb/9067
* cp-valprint.c (cp_print_value_fields) Fix use of obstacks.
- cp_print_static_field) Fix use of obstacks.
+ (cp_print_static_field) Fix use of obstacks.
2010-02-08 Pedro Alves <pedro@codesourcery.com>
--- a/gdb/cp-valprint.c
+++ b/gdb/cp-valprint.c
@@ -164,10 +164,19 @@ cp_print_value_fields (struct type *type, struct type *real_type,
if (recurse == 0)
{
+ /* Any object can be left on obstacks only during an unexpected error. */
+
if (obstack_object_size (&dont_print_statmem_obstack) > 0)
- obstack_free (&dont_print_statmem_obstack, NULL);
+ {
+ obstack_free (&dont_print_statmem_obstack, NULL);
+ obstack_begin (&dont_print_statmem_obstack, 32 * sizeof (CORE_ADDR));
+ }
if (obstack_object_size (&dont_print_stat_array_obstack) > 0)
- obstack_free (&dont_print_stat_array_obstack, NULL);
+ {
+ obstack_free (&dont_print_stat_array_obstack, NULL);
+ obstack_begin (&dont_print_stat_array_obstack,
+ 32 * sizeof (struct type *));
+ }
}
fprintf_filtered (stream, "{");
### a/gdb/testsuite/ChangeLog
### b/gdb/testsuite/ChangeLog
## -1,3 +1,7 @@
+2010-06-28 Jan Kratochvil <jan.kratochvil@redhat.com>
+
+ * gdb.cp/static-print-quit.exp, gdb.cp/static-print-quit.cc: New.
+
2010-06-28 Doug Evans <dje@google.com>
* gdb.base/break-interp.exp (reach): Relax expected output a bit.
--- /dev/null
+++ b/gdb/testsuite/gdb.cp/static-print-quit.cc
@@ -0,0 +1,32 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+ 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/>. */
+
+class D
+ {
+ public:
+ int loooooooooooooooooooooooooooooooooooooooooooooong;
+ };
+
+class C
+ {
+ public:
+ int loooooooooooooooooooooooooooooooooooooooooooooong;
+ static D field;
+ };
+
+D C::field;
+C c;
--- /dev/null
+++ b/gdb/testsuite/gdb.cp/static-print-quit.exp
@@ -0,0 +1,50 @@
+# 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/>.
+
+if { [skip_cplus_tests] } { continue }
+
+set testfile static-print-quit
+set srcfile ${testfile}.cc
+set executable $testfile.o
+set objfile ${objdir}/${subdir}/${executable}
+
+if { [gdb_compile $srcdir/$subdir/$srcfile $objfile object {debug c++}] != ""} {
+ untested ${testfile}.exp
+ return -1
+}
+
+clean_restart $executable
+
+gdb_test "set width 80"
+gdb_test "set height 2"
+
+set test "print c"
+gdb_test_multiple $test $test {
+ -re " = \{loooooooooooooooooooooooooooooooooooooooooooooong = 0, static field = \{\r\n---Type <return> to continue, or q <return> to quit---$" {
+ pass $test
+ }
+ -re " to quit---$" {
+ fail $test
+ return -1
+ }
+}
+
+gdb_test "q" ".*"
+
+# Now the obstack is uninitialized. Excercise it.
+
+gdb_test "set pagination off"
+gdb_test "print c" ".*" "first print"
+gdb_test "print c" ".*" "second print"

View File

@ -0,0 +1,106 @@
commit bb604f9e70de515b13e2a935d8ad9d2fb0290849
Author: Jan Kratochvil <jan.kratochvil@redhat.com>
Date: Mon Jun 28 20:12:52 2010 +0000
gdb/
Fix modification of cplus_struct_default.
* dwarf2read.c (dwarf2_add_member_fn) <no DW_AT_vtable_elem_location>:
Call ALLOCATE_CPLUS_STRUCT_TYPE.
<removed>
* gdbtypes.c (cplus_struct_default): New empty initializer, comment it.
</removed>
gdb/testsuite/
* gdb.cp/virtbase.cc (class RTTI_base, class RTTI_data)
(main) <rtti_data>: New.
* gdb.cp/virtbase.exp (print rtti_data): New.
### a/gdb/ChangeLog
### b/gdb/ChangeLog
## -1,3 +1,10 @@
+2010-06-28 Jan Kratochvil <jan.kratochvil@redhat.com>
+
+ Fix modification of cplus_struct_default.
+ * dwarf2read.c (dwarf2_add_member_fn) <no DW_AT_vtable_elem_location>:
+ Call ALLOCATE_CPLUS_STRUCT_TYPE.
+ * gdbtypes.c (cplus_struct_default): New empty initializer, comment it.
+
### a/gdb/testsuite/ChangeLog
### b/gdb/testsuite/ChangeLog
## -1,4 +1,10 @@
+2010-06-28 Jan Kratochvil <jan.kratochvil@redhat.com>
+
+ * gdb.cp/virtbase.cc (class RTTI_base, class RTTI_data)
+ (main) <rtti_data>: New.
+ * gdb.cp/virtbase.exp (print rtti_data): New.
+
###--- a/gdb/gdbtypes.c
###+++ b/gdb/gdbtypes.c
###@@ -1733,7 +1733,8 @@ check_stub_method_group (struct type *type, int method_id)
### }
### }
###
###-const struct cplus_struct_type cplus_struct_default;
###+/* Ensure it is in .rodata (if available) by workarounding GCC PR 44690. */
###+const struct cplus_struct_type cplus_struct_default = { };
###
### void
### allocate_cplus_struct_type (struct type *type)
Index: gdb-7.1/gdb/dwarf2read.c
===================================================================
--- gdb-7.1.orig/gdb/dwarf2read.c 2010-06-29 18:26:47.000000000 +0200
+++ gdb-7.1/gdb/dwarf2read.c 2010-06-29 18:39:43.000000000 +0200
@@ -5404,6 +5404,7 @@ dwarf2_add_member_fn (struct field_info
complaint (&symfile_complaints,
_("Member function \"%s\" (offset %d) is virtual but the vtable offset is not specified"),
fieldname, die->offset);
+ ALLOCATE_CPLUS_STRUCT_TYPE (type);
TYPE_CPLUS_DYNAMIC (type) = 1;
}
}
Index: gdb-7.1/gdb/testsuite/gdb.cp/virtbase.cc
===================================================================
--- gdb-7.1.orig/gdb/testsuite/gdb.cp/virtbase.cc 2010-02-03 00:40:28.000000000 +0100
+++ gdb-7.1/gdb/testsuite/gdb.cp/virtbase.cc 2010-06-29 18:39:43.000000000 +0200
@@ -74,8 +74,19 @@ public:
virtual void b() {}
};
+class RTTI_base
+{
+public:
+ virtual ~RTTI_base() {}
+};
-
+class RTTI_data
+{
+public:
+ RTTI_base base;
+ int data;
+ RTTI_data() : data(1) {}
+};
int main() {
ph::Derived tst;
@@ -84,6 +95,7 @@ int main() {
E *e = new E;
RHB *b = new RHC();
+ RTTI_data rtti_data;
return 0; // breakpoint 3
}
Index: gdb-7.1/gdb/testsuite/gdb.cp/virtbase.exp
===================================================================
--- gdb-7.1.orig/gdb/testsuite/gdb.cp/virtbase.exp 2010-02-04 22:04:30.000000000 +0100
+++ gdb-7.1/gdb/testsuite/gdb.cp/virtbase.exp 2010-06-29 18:39:56.000000000 +0200
@@ -60,3 +60,8 @@ gdb_test "print *(D *) e" " = {<C> = {v
# https://bugzilla.redhat.com/show_bug.cgi?id=560741
gdb_test "set print object on" ""
gdb_test "print/x b->mA" " = 0xaaaaaaaa"
+
+# A regression test reported to Red Hat bugzilla, see:
+# https://bugzilla.redhat.com/show_bug.cgi?id=606660
+# `set print object on' is expected.
+gdb_test "print rtti_data" " = .*, data = 1\}"

View File

@ -0,0 +1,239 @@
http://sourceware.org/ml/archer/2010-q3/msg00028.html
Subject: [delayed-symfile] [commit] Fix a regression on CFI without DIE [Re:
On Wed, 25 Feb 2009 00:14:29 +0100, Jan Kratochvil wrote:
> commit 6a37c2b9962258ecf9299cc34a650e64a06acaa5
>
> There was a regression on gdb.base/savedregs.exp.
>
> quick_addrmap/require_partial_symbols should be used even for the unwind debug
> info checking as its load has been also delayed by this branch.
[...]
> --- a/gdb/dwarf2-frame.c
> +++ b/gdb/dwarf2-frame.c
[...]
> @@ -1499,6 +1500,14 @@ dwarf2_frame_find_fde (CORE_ADDR *pc)
> struct dwarf2_fde *fde;
> CORE_ADDR offset;
>
> + if (objfile->quick_addrmap)
> + {
> + if (!addrmap_find (objfile->quick_addrmap, *pc))
> + continue;
> + }
> + /* FIXME: Read-in only .debug_frame/.eh_frame without .debug_info? */
> + require_partial_symbols (objfile);
> +
but this has caused a different regression (as discussed in the confcall).
QUICK_ADDRMAP is built only from .debug_aranges. But we can have existing
built .debug_aranges for CUs in OBJFILE but still some CUs do not need to have
DWARF at all while they can feature CFIs (.eh_frame or .debug_frame).
It has been described by Daniel Jacobowitz at:
Re: [2/4] RFC: check psymtabs_addrmap before reading FDEs
http://sourceware.org/ml/gdb-patches/2010-07/msg00012.html
Sorry for this regression by me (in that fix of a different regression).
Fixed it the "slow way" as this branch is now obsoleted by .gdb-index.
No regressions on {x86_64,x86_64-m32,i686}-fedora13-linux-gnu.
Checked-in.
Thanks,
Jan
eb8df8566acc1ed963e3e9b77c13b9c2c3db03fb
Test CFI is parsed even for range (function) not described by any DIE.
https://bugzilla.redhat.com/show_bug.cgi?id=614028
gdb/
* dwarf2-frame.c (dwarf2_frame_find_fde): Remove the
OBJFILE->QUICK_ADDRMAP check. New comment why.
gdb/testsuite/
* gdb.base/cfi-without-die.exp, gdb.base/cfi-without-die-main.c,
gdb.base/cfi-without-die-caller.c: New files.
---
gdb/dwarf2-frame.c | 8 +--
gdb/testsuite/gdb.base/cfi-without-die-caller.c | 28 ++++++++++
gdb/testsuite/gdb.base/cfi-without-die-main.c | 32 +++++++++++
gdb/testsuite/gdb.base/cfi-without-die.exp | 67 +++++++++++++++++++++++
4 files changed, 130 insertions(+), 5 deletions(-)
create mode 100644 gdb/testsuite/gdb.base/cfi-without-die-caller.c
create mode 100644 gdb/testsuite/gdb.base/cfi-without-die-main.c
create mode 100644 gdb/testsuite/gdb.base/cfi-without-die.exp
diff --git a/gdb/dwarf2-frame.c b/gdb/dwarf2-frame.c
index 5915249..1dc2754 100644
--- a/gdb/dwarf2-frame.c
+++ b/gdb/dwarf2-frame.c
@@ -1583,11 +1583,9 @@ dwarf2_frame_find_fde (CORE_ADDR *pc)
CORE_ADDR offset;
CORE_ADDR seek_pc;
- if (objfile->quick_addrmap)
- {
- if (!addrmap_find (objfile->quick_addrmap, *pc))
- continue;
- }
+ /* OBJFILE->QUICK_ADDRMAP contains offsets only for DIEs. It does not
+ contain ranges of CFIs. */
+
/* FIXME: Read-in only .debug_frame/.eh_frame without .debug_info? */
require_partial_symbols (objfile);
diff --git a/gdb/testsuite/gdb.base/cfi-without-die-caller.c b/gdb/testsuite/gdb.base/cfi-without-die-caller.c
new file mode 100644
index 0000000..afdfd53
--- /dev/null
+++ b/gdb/testsuite/gdb.base/cfi-without-die-caller.c
@@ -0,0 +1,28 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+ Copyright 2005, 2007, 2008, 2009, 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/>. */
+
+typedef int (*callback_t) (void);
+
+int
+caller (callback_t callback)
+{
+ /* Ensure some frame content to push away the return address. */
+ volatile const long one = 1;
+
+ /* Modify the return value to prevent any tail-call optimization. */
+ return (*callback) () - one;
+}
diff --git a/gdb/testsuite/gdb.base/cfi-without-die-main.c b/gdb/testsuite/gdb.base/cfi-without-die-main.c
new file mode 100644
index 0000000..8451c4b
--- /dev/null
+++ b/gdb/testsuite/gdb.base/cfi-without-die-main.c
@@ -0,0 +1,32 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+ Copyright 2005, 2007, 2008, 2009, 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/>. */
+
+typedef int (*callback_t) (void);
+
+extern int caller (callback_t callback);
+
+int
+callback (void)
+{
+ return 1;
+}
+
+int
+main (void)
+{
+ return caller (callback);
+}
diff --git a/gdb/testsuite/gdb.base/cfi-without-die.exp b/gdb/testsuite/gdb.base/cfi-without-die.exp
new file mode 100644
index 0000000..db6d248
--- /dev/null
+++ b/gdb/testsuite/gdb.base/cfi-without-die.exp
@@ -0,0 +1,67 @@
+# 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/>.
+
+# Test CFI is parsed even for range (function) not described by any DIE.
+
+set testfile cfi-without-die
+set srcmainfile ${testfile}-main.c
+set srccallerfile ${testfile}-caller.c
+set executable ${testfile}
+set objmainfile ${objdir}/${subdir}/${testfile}-main.o
+set objcallerfile ${objdir}/${subdir}/${testfile}-caller.o
+set binfile ${objdir}/${subdir}/${executable}
+
+if { [gdb_compile "${srcdir}/${subdir}/${srccallerfile}" ${objcallerfile} \
+ object [list {additional_flags=-fomit-frame-pointer -fno-unwind-tables -fno-asynchronous-unwind-tables}]] != ""
+ || [gdb_compile "${srcdir}/${subdir}/${srcmainfile}" ${objmainfile} object {debug}] != ""
+ || [gdb_compile "${objmainfile} ${objcallerfile}" ${binfile} executable {}] != "" } {
+ untested ${testfile}.exp
+ return -1
+}
+
+clean_restart $executable
+
+if ![runto callback] then {
+ fail "verify unwinding: Can't run to callback"
+ return 0
+}
+set test "verify unwinding breaks without CFI"
+gdb_test_multiple "bt" $test {
+ -re " in main .*\r\n$gdb_prompt $" {
+ fail $test
+ }
+ -re "\r\n$gdb_prompt $" {
+ pass $test
+ }
+}
+
+if { [gdb_compile "${srcdir}/${subdir}/${srccallerfile}" ${objcallerfile} \
+ object [list {additional_flags=-fomit-frame-pointer -funwind-tables -fasynchronous-unwind-tables}]] != ""
+ || [gdb_compile "${srcdir}/${subdir}/${srcmainfile}" ${objmainfile} object {debug}] != ""
+ || [gdb_compile "${objmainfile} ${objcallerfile}" ${binfile} executable {}] != "" } {
+ untested ${testfile}.exp
+ return -1
+}
+
+clean_restart $executable
+
+if ![runto callback] then {
+ fail "test CFI without DIEs: Can't run to callback"
+ return 0
+}
+# #0 callback () at ...
+# #1 0x00000000004004e9 in caller ()
+# #2 0x00000000004004cd in main () at ...
+gdb_test "bt" "#0 +callback \[^\r\n\]+\r\n#1 \[^\r\n\]+ in caller \[^\r\n\]+\r\n#2 \[^\r\n\]+ in main \[^\r\n\]+" "verify unwindin works for CFI without DIEs"
--
1.7.1.1

View File

@ -0,0 +1,204 @@
http://sourceware.org/ml/gdb-patches/2010-07/msg00237.html
Subject: [patch] Fix regression on prelinked executables
Hi,
there is a regression since gdb-7.0 for a combination of:
* prelinked
* main executable
* using separate debug info
* using copy relocations
It is since a patch for both PIE and (AFAIK) OSX support:
[commit] syms_from_objfile: Relativize also MAINLINE
http://sourceware.org/ml/gdb-patches/2010-01/msg00080.html
which started to use problematic addr_info_make_relative even for main
executables. prelink<->gdb discussion at:
https://bugzilla.redhat.com/show_bug.cgi?id=614659
Currently in the unfortunately executables GDB has invalid displcement for
symbols in .bss:
int bssvar, *bssvarp = &bssvar;
(gdb) p &bssvar
$1 = (int *) 0x600b54
(gdb) p bssvarp
$2 = (int *) 0x600b50
<abstract-higher-point-of-view>
addr_info_make_relative could just simply subtract entry point address and
provide single CORE_ADDR objfile->offset (instead of the current
section_offsets array with offsets specific for each section). Linux systems
use always single offset for the whole objfile. AFAIK these per-section
offsets are there for some embedded targets. Curiously GDB already uses at
many places
baseaddr = ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
instead of using offset for the appropriate section at that place and nobody
complains.
</abstract-higher-point-of-view>
No regressions on {x86_64,x86_64-m32,i686}-fedora13-linux-gnu.
Proposing for the gdb-7.2 branch. I had problems fixing up my crashing X.
Thanks,
Jan
gdb/
2010-07-15 Jan Kratochvil <jan.kratochvil@redhat.com>
* symfile.c (addr_section_name): New function.
(addrs_section_compar): Use it.
(addr_info_make_relative): Use it. Move variable sect_name into a more
inner block. Make ".dynbss" and ".sdynbss" checks more strict.
gdb/testsuite/
2010-07-15 Jan Kratochvil <jan.kratochvil@redhat.com>
* gdb.base/prelink-lib.c (copyreloc): New initialized variable.
* gdb.base/prelink.c (copyreloc, bssvar, bssvarp): New variables.
(main): Use copyreloc.
* gdb.base/prelink.exp (split debug of executable)
(.dynbss vs. .bss address shift): New tests.
Index: gdb-7.1/gdb/symfile.c
===================================================================
--- gdb-7.1.orig/gdb/symfile.c 2010-07-19 23:11:10.000000000 +0200
+++ gdb-7.1/gdb/symfile.c 2010-07-20 18:34:50.000000000 +0200
@@ -557,6 +557,23 @@ relative_addr_info_to_section_offsets (s
}
}
+/* Transform section name S for a name comparison. prelink can split section
+ `.bss' into two sections `.dynbss' and `.bss' (in this order). Similarly
+ prelink can split `.sbss' into `.sdynbss' and `.sbss'. Use virtual address
+ of the new `.dynbss' (`.sdynbss') section as the adjacent new `.bss'
+ (`.sbss') section has invalid (increased) virtual address. */
+
+static const char *
+addr_section_name (const char *s)
+{
+ if (strcmp (s, ".dynbss") == 0)
+ return ".bss";
+ if (strcmp (s, ".sdynbss") == 0)
+ return ".sbss";
+
+ return s;
+}
+
/* Relativize absolute addresses in ADDRS into offsets based on ABFD. Fill-in
also SECTINDEXes specific to ABFD there. This function can be used to
rebase ADDRS to start referencing different BFD than before. */
@@ -607,8 +624,17 @@ addr_info_make_relative (struct section_
if (sect && strcmp (sect_name, bfd_get_section_name (abfd, sect)) != 0)
sect = NULL;
- if (sect == NULL)
- sect = bfd_get_section_by_name (abfd, sect_name);
+ /* Prevent the search by name if `.bss' has the address already set from
+ `.dynbss'. */
+ if (sect == NULL
+ && !(0
+ || (strcmp (sect_name, ".bss") == 0
+ && i > 0
+ && strcmp (addrs->other[i - 1].name, ".dynbss") == 0)
+ || (strcmp (sect_name, ".sbss") == 0
+ && i > 0
+ && strcmp (addrs->other[i - 1].name, ".sdynbss") == 0)))
+ sect = bfd_get_section_by_name (abfd, addr_section_name (sect_name));
if (sect)
{
/* This is the index used by BFD. */
@@ -634,12 +660,18 @@ addr_info_make_relative (struct section_
a warning. Shared libraries contain just the section
".gnu.liblist" but it is not marked as loadable there. There is
no other way to identify them than by their name as the sections
- created by prelink have no special flags. */
+ created by prelink have no special flags.
+
+ For the sections `.bss' and `.sbss' see addr_section_name. */
if (!(strcmp (sect_name, ".gnu.liblist") == 0
|| strcmp (sect_name, ".gnu.conflict") == 0
- || strcmp (sect_name, ".dynbss") == 0
- || strcmp (sect_name, ".sdynbss") == 0))
+ || (strcmp (sect_name, ".bss") == 0
+ && i > 0
+ && strcmp (addrs->other[i - 1].name, ".dynbss") == 0)
+ || (strcmp (sect_name, ".sbss") == 0
+ && i > 0
+ && strcmp (addrs->other[i - 1].name, ".sdynbss") == 0)))
warning (_("section %s not found in %s"), sect_name,
bfd_get_filename (abfd));
Index: gdb-7.1/gdb/testsuite/gdb.base/prelink-lib.c
===================================================================
--- gdb-7.1.orig/gdb/testsuite/gdb.base/prelink-lib.c 2010-01-01 08:32:01.000000000 +0100
+++ gdb-7.1/gdb/testsuite/gdb.base/prelink-lib.c 2010-07-19 23:11:56.000000000 +0200
@@ -16,6 +16,8 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+int copyreloc = 1;
+
int
g (void (*p)(void))
{
Index: gdb-7.1/gdb/testsuite/gdb.base/prelink.c
===================================================================
--- gdb-7.1.orig/gdb/testsuite/gdb.base/prelink.c 2010-01-01 08:32:01.000000000 +0100
+++ gdb-7.1/gdb/testsuite/gdb.base/prelink.c 2010-07-19 23:11:56.000000000 +0200
@@ -18,6 +18,11 @@
#include <stdio.h>
+extern int copyreloc;
+
+/* Test GDB itself finds `&bssvar' right. */
+static int bssvar, *bssvarp = &bssvar;
+
extern void (*h (void)) (void (*)(void));
int
@@ -25,5 +30,6 @@ main (void)
{
void (*f) (void (*)(void)) = h ();
printf ("%p\n", f);
+ printf ("%d\n", copyreloc);
f (0);
}
Index: gdb-7.1/gdb/testsuite/gdb.base/prelink.exp
===================================================================
--- gdb-7.1.orig/gdb/testsuite/gdb.base/prelink.exp 2010-07-19 23:11:12.000000000 +0200
+++ gdb-7.1/gdb/testsuite/gdb.base/prelink.exp 2010-07-20 00:06:18.000000000 +0200
@@ -84,6 +84,13 @@ if { [gdb_compile "${srcdir}/${subdir}/$
return -1;
}
+set test "split debug of executable"
+if [gdb_gnu_strip_debug $binfile] {
+ fail $test
+} else {
+ pass $test
+}
+
set found 0
set coredir "${objdir}/${subdir}/coredir.[getpid]"
file mkdir $coredir
@@ -118,7 +125,7 @@ if {[catch "system \"/usr/sbin/prelink -
untested "${testfile}.so was not prelinked, maybe system libraries are not prelinked?"
return 0
}
-catch "system \"/usr/sbin/prelink -qNR --no-exec-shield ${libfile}\""
+catch "system \"/usr/sbin/prelink -qNR --no-exec-shield ${libfile} ${binfile}\""
# Start with a fresh gdb
@@ -131,3 +138,5 @@ gdb_load ${binfile}
gdb_test "set verbose on"
gdb_test "core-file $objdir/$subdir/prelink.core" {Using PIC \(Position Independent Code\) prelink displacement.*} "prelink"
+
+gdb_test "p &bssvar == bssvarp" " = 1" ".dynbss vs. .bss address shift"

11
gdb-hppa.patch Normal file
View File

@ -0,0 +1,11 @@
--- gdb/configure.tgt.orig 2010-06-01 10:21:15.000000000 +0000
+++ gdb/configure.tgt 2010-06-01 10:21:34.000000000 +0000
@@ -134,7 +134,7 @@
hppa*-*-linux*)
# Target: HP PA-RISC running Linux
gdb_target_obs="hppa-tdep.o hppa-linux-tdep.o glibc-tdep.o \
- solib.o solib-svr4.o symfile-mem.o"
+ solib.o solib-svr4.o symfile-mem.o linux-tdep.o"
;;
hppa*-*-netbsd*)
# Target: NetBSD/hppa

View File

@ -1,69 +0,0 @@
gdb/linux-nat.c:
- Workaround RHEL-5 kernels for detaching SIGSTOPped processes (BZ 498595).
Index: gdb-7.0.50.20100115/gdb/elfread.c
===================================================================
--- gdb-7.0.50.20100115.orig/gdb/elfread.c 2010-01-15 22:19:28.000000000 +0100
+++ gdb-7.0.50.20100115/gdb/elfread.c 2010-01-15 22:19:34.000000000 +0100
@@ -582,7 +582,7 @@ elf_symtab_read (struct objfile *objfile
#define BUILD_ID_VERBOSE_NONE 0
#define BUILD_ID_VERBOSE_FILENAMES 1
#define BUILD_ID_VERBOSE_BINARY_PARSE 2
-static int build_id_verbose = BUILD_ID_VERBOSE_FILENAMES;
+static int build_id_verbose = BUILD_ID_VERBOSE_NONE;
static void
show_build_id_verbose (struct ui_file *file, int from_tty,
struct cmd_list_element *c, const char *value)
@@ -1659,8 +1659,10 @@ find_separate_debug_file_by_buildid (str
/* Prevent looping on a stripped .debug file. */
if (build_id_name != NULL && strcmp (build_id_name, objfile->name) == 0)
{
+#if 0 /* RHEL-5 backward behavior compatibility. */
warning (_("\"%s\": separate debug info file has no debug info"),
build_id_name);
+#endif
xfree (build_id_name);
}
else if (build_id_name != NULL)
Index: gdb-7.0.50.20100115/gdb/corelow.c
===================================================================
--- gdb-7.0.50.20100115.orig/gdb/corelow.c 2010-01-15 22:19:27.000000000 +0100
+++ gdb-7.0.50.20100115/gdb/corelow.c 2010-01-15 22:19:34.000000000 +0100
@@ -294,7 +294,7 @@ add_to_thread_list (bfd *abfd, asection
inferior_ptid = ptid; /* Yes, make it current */
}
-static int build_id_core_loads = 1;
+static int build_id_core_loads = 0;
static void
build_id_locate_exec (int from_tty)
Index: gdb-7.0.50.20100115/gdb/linux-nat.c
===================================================================
--- gdb-7.0.50.20100115.orig/gdb/linux-nat.c 2010-01-15 22:19:27.000000000 +0100
+++ gdb-7.0.50.20100115/gdb/linux-nat.c 2010-01-15 22:19:55.000000000 +0100
@@ -1768,8 +1768,22 @@ GPT: lwp %s had signal %s, but it is in
target_signal_to_string (signo));
}
- if (*status == 0 && GET_PID (lp->ptid) == pid_was_stopped)
- *status = W_STOPCODE (SIGSTOP);
+ /* Workaround RHEL-5 kernel which has unreliable PTRACE_DETACH, SIGSTOP (that
+ many TIDs are left unstopped). See RH Bug 496732. */
+ if (GET_PID (lp->ptid) == pid_was_stopped)
+ {
+ int err;
+
+ errno = 0;
+ err = kill_lwp (GET_LWP (lp->ptid), SIGSTOP);
+ if (debug_linux_nat)
+ {
+ fprintf_unfiltered (gdb_stdlog,
+ "SC: lwp kill %d %s\n",
+ err,
+ errno ? safe_strerror (errno) : "ERRNO-OK");
+ }
+ }
return 0;
}

View File

@ -1,433 +0,0 @@
Some functionality is available on RHEL-5.4+ only with gcc44 and gfortran44 as
the default gcc and gfortran binaries are from gcc-4.1.
Index: gdb-7.0.50.20100115/gdb/testsuite/gdb.base/vla.exp
===================================================================
--- gdb-7.0.50.20100115.orig/gdb/testsuite/gdb.base/vla.exp 2010-01-15 22:14:13.000000000 +0100
+++ gdb-7.0.50.20100115/gdb/testsuite/gdb.base/vla.exp 2010-01-15 22:14:51.000000000 +0100
@@ -16,7 +16,25 @@
set testfile vla
set srcfile ${testfile}.c
set binfile ${objdir}/${subdir}/${testfile}
-if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
+# Temporarily provide compiler=gcc44 saving the original value around.
+
+set board [target_info name]
+if [board_info $board exists compiler] {
+ set old_compiler [board_info $board compiler]
+ unset_board_info compiler
+} elseif [info exists old_compiler] {
+ unset old_compiler
+}
+set_board_info compiler gcc44
+
+set err [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug quiet}]
+
+unset_board_info compiler
+if [info exists old_compiler] {
+ set_board_info compiler $old_compiler
+}
+
+if { $err != "" } {
untested "Couldn't compile test program"
return -1
}
Index: gdb-7.0.50.20100115/gdb/testsuite/gdb.base/break-interp.exp
===================================================================
--- gdb-7.0.50.20100115.orig/gdb/testsuite/gdb.base/break-interp.exp 2010-01-14 22:12:00.000000000 +0100
+++ gdb-7.0.50.20100115/gdb/testsuite/gdb.base/break-interp.exp 2010-01-15 22:14:51.000000000 +0100
@@ -31,10 +31,30 @@ if [get_compiler_info ${binfile_lib}] {
return -1
}
+# Temporarily provide compiler=gcc44 saving the original value around.
+# RHEL-5 workaround of its:
+# gcc: -soname: linker input file unused because linking not done
+
+set board [target_info name]
+if [board_info $board exists compiler] {
+ set old_compiler [board_info $board compiler]
+ unset_board_info compiler
+} elseif [info exists old_compiler] {
+ unset old_compiler
+}
+set_board_info compiler gcc44
+
# Use -soname so that it is listed with " => " by ldd and this testcase makes
# a copy of ${binfile_lib} for each prelink variant.
-if {[gdb_compile_shlib ${srcdir}/${subdir}/${srcfile_lib} ${binfile_lib} [list debug additional_flags=-Wl,-soname,${test}.so]] != ""} {
+set err [gdb_compile_shlib ${srcdir}/${subdir}/${srcfile_lib} ${binfile_lib} [list debug additional_flags=-Wl,-soname,${test}.so]]
+
+unset_board_info compiler
+if [info exists old_compiler] {
+ set_board_info compiler $old_compiler
+}
+
+if { $err != "" } {
return -1
}
@@ -480,9 +500,33 @@ foreach ldprelink {NO YES} {
if {$binpie != "NO"} {
lappend opts {additional_flags=-fPIE -pie}
}
- if {[build_executable ${test}.exp [file tail $exec] $srcfile $opts] == -1} {
- continue;
+
+
+ # Temporarily provide compiler=gcc44 saving the original value around.
+ # RHEL-5 workaround of its:
+ # gcc: -rpath: linker input file unused because linking not done
+ # gcc: --dynamic-linker: linker input file unused because linking not done
+
+ set board [target_info name]
+ if [board_info $board exists compiler] {
+ set old_compiler [board_info $board compiler]
+ unset_board_info compiler
+ } elseif [info exists old_compiler] {
+ unset old_compiler
+ }
+ set_board_info compiler gcc44
+
+ set err [build_executable ${test}.exp [file tail $exec] $srcfile $opts]
+
+ unset_board_info compiler
+ if [info exists old_compiler] {
+ set_board_info compiler $old_compiler
}
+
+ if { $err == -1 } {
+ continue
+ }
+
if {$binsepdebug == "SEP"} {
gdb_gnu_strip_debug $exec
# Just a sanity check. As gdb_gnu_strip_debug uses the
Index: gdb-7.0.50.20100115/gdb/testsuite/gdb.fortran/common-block.exp
===================================================================
--- gdb-7.0.50.20100115.orig/gdb/testsuite/gdb.fortran/common-block.exp 2010-01-15 22:14:17.000000000 +0100
+++ gdb-7.0.50.20100115/gdb/testsuite/gdb.fortran/common-block.exp 2010-01-15 22:14:51.000000000 +0100
@@ -20,7 +20,25 @@ set testfile "common-block"
set srcfile ${testfile}.f90
set binfile ${objdir}/${subdir}/${testfile}
-if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug f77 quiet}] != "" } {
+# Temporarily provide f77compiler=gfortran44 saving the original value around.
+
+set board [target_info name]
+if [board_info $board exists f77compiler] {
+ set old_f77compiler [board_info $board f77compiler]
+ unset_board_info f77compiler
+} elseif [info exists old_f77compiler] {
+ unset old_f77compiler
+}
+set_board_info f77compiler gfortran44
+
+set err [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug f77 quiet}]
+
+unset_board_info f77compiler
+if [info exists old_f77compiler] {
+ set_board_info f77compiler $old_f77compiler
+}
+
+if { $err != "" } {
untested "Couldn't compile ${srcfile}"
return -1
}
Index: gdb-7.0.50.20100115/gdb/testsuite/gdb.fortran/dwarf-stride.exp
===================================================================
--- gdb-7.0.50.20100115.orig/gdb/testsuite/gdb.fortran/dwarf-stride.exp 2010-01-15 22:14:13.000000000 +0100
+++ gdb-7.0.50.20100115/gdb/testsuite/gdb.fortran/dwarf-stride.exp 2010-01-15 22:14:51.000000000 +0100
@@ -27,7 +27,25 @@
set testfile dwarf-stride
set srcfile ${testfile}.f90
-if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} {debug f77}] } {
+# Temporarily provide f77compiler=gfortran44 saving the original value around.
+
+set board [target_info name]
+if [board_info $board exists f77compiler] {
+ set old_f77compiler [board_info $board f77compiler]
+ unset_board_info f77compiler
+} elseif [info exists old_f77compiler] {
+ unset old_f77compiler
+}
+set_board_info f77compiler gfortran44
+
+set err [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} {debug f77}]
+
+unset_board_info f77compiler
+if [info exists old_f77compiler] {
+ set_board_info f77compiler $old_f77compiler
+}
+
+if $err {
return -1
}
Index: gdb-7.0.50.20100115/gdb/testsuite/gdb.fortran/dynamic.exp
===================================================================
--- gdb-7.0.50.20100115.orig/gdb/testsuite/gdb.fortran/dynamic.exp 2010-01-15 22:14:13.000000000 +0100
+++ gdb-7.0.50.20100115/gdb/testsuite/gdb.fortran/dynamic.exp 2010-01-15 22:14:51.000000000 +0100
@@ -25,7 +25,25 @@ set testfile "dynamic"
set srcfile ${testfile}.f90
set binfile ${objdir}/${subdir}/${testfile}
-if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug f77 quiet}] != "" } {
+# Temporarily provide f77compiler=gfortran44 saving the original value around.
+
+set board [target_info name]
+if [board_info $board exists f77compiler] {
+ set old_f77compiler [board_info $board f77compiler]
+ unset_board_info f77compiler
+} elseif [info exists old_f77compiler] {
+ unset old_f77compiler
+}
+set_board_info f77compiler gfortran44
+
+set err [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug f77 quiet}]
+
+unset_board_info f77compiler
+if [info exists old_f77compiler] {
+ set_board_info f77compiler $old_f77compiler
+}
+
+if { $err != "" } {
untested "Couldn't compile ${srcfile}"
return -1
}
Index: gdb-7.0.50.20100115/gdb/testsuite/gdb.fortran/library-module.exp
===================================================================
--- gdb-7.0.50.20100115.orig/gdb/testsuite/gdb.fortran/library-module.exp 2010-01-15 22:14:13.000000000 +0100
+++ gdb-7.0.50.20100115/gdb/testsuite/gdb.fortran/library-module.exp 2010-01-15 22:14:51.000000000 +0100
@@ -25,16 +25,34 @@ if [get_compiler_info not-used] {
return -1
}
-if { [gdb_compile_shlib "${srcdir}/${subdir}/${srclibfile}" $objdir/$subdir/$libfile {debug f77}] != "" } {
- untested "Couldn't compile ${srclibfile}"
- return -1
+# Temporarily provide f77compiler=gfortran44 saving the original value around.
+
+set board [target_info name]
+if [board_info $board exists f77compiler] {
+ set old_f77compiler [board_info $board f77compiler]
+ unset_board_info f77compiler
+} elseif [info exists old_f77compiler] {
+ unset old_f77compiler
}
+set_board_info f77compiler gfortran44
# prepare_for_testing cannot be used as linking with $libfile cannot be passed
# just for the linking phase (and not the source compilation phase). And any
# warnings on ignored $libfile abort the process.
-if { [gdb_compile [list $srcdir/$subdir/$srcfile $objdir/$subdir/$libfile] $objdir/$subdir/$binfile executable {debug f77}] != "" } {
+set err1 [gdb_compile_shlib "${srcdir}/${subdir}/${srclibfile}" $objdir/$subdir/$libfile {debug f77}]
+set err2 [gdb_compile [list $srcdir/$subdir/$srcfile $objdir/$subdir/$libfile] $objdir/$subdir/$binfile executable {debug f77}]
+
+unset_board_info f77compiler
+if [info exists old_f77compiler] {
+ set_board_info f77compiler $old_f77compiler
+}
+
+if { $err1 != "" } {
+ untested "Couldn't compile ${srclibfile}"
+ return -1
+}
+if { $err2 != "" } {
untested "Couldn't compile ${srcfile}"
return -1
}
Index: gdb-7.0.50.20100115/gdb/testsuite/gdb.fortran/module.exp
===================================================================
--- gdb-7.0.50.20100115.orig/gdb/testsuite/gdb.fortran/module.exp 2010-01-15 22:14:13.000000000 +0100
+++ gdb-7.0.50.20100115/gdb/testsuite/gdb.fortran/module.exp 2010-01-15 22:14:51.000000000 +0100
@@ -16,7 +16,25 @@
set testfile "module"
set srcfile ${testfile}.f90
-if { [prepare_for_testing $testfile.exp $testfile $srcfile {debug f77}] } {
+# Temporarily provide f77compiler=gfortran44 saving the original value around.
+
+set board [target_info name]
+if [board_info $board exists f77compiler] {
+ set old_f77compiler [board_info $board f77compiler]
+ unset_board_info f77compiler
+} elseif [info exists old_f77compiler] {
+ unset old_f77compiler
+}
+set_board_info f77compiler gfortran44
+
+set err [prepare_for_testing $testfile.exp $testfile $srcfile {debug f77}]
+
+unset_board_info f77compiler
+if [info exists old_f77compiler] {
+ set_board_info f77compiler $old_f77compiler
+}
+
+if $err {
return -1
}
Index: gdb-7.0.50.20100115/gdb/testsuite/gdb.fortran/string.exp
===================================================================
--- gdb-7.0.50.20100115.orig/gdb/testsuite/gdb.fortran/string.exp 2010-01-15 22:14:13.000000000 +0100
+++ gdb-7.0.50.20100115/gdb/testsuite/gdb.fortran/string.exp 2010-01-15 22:14:51.000000000 +0100
@@ -23,7 +23,25 @@ set testfile "string"
set srcfile ${testfile}.f90
set binfile ${objdir}/${subdir}/${testfile}
-if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug f77 quiet}] != "" } {
+# Temporarily provide f77compiler=gfortran44 saving the original value around.
+
+set board [target_info name]
+if [board_info $board exists f77compiler] {
+ set old_f77compiler [board_info $board f77compiler]
+ unset_board_info f77compiler
+} elseif [info exists old_f77compiler] {
+ unset old_f77compiler
+}
+set_board_info f77compiler gfortran44
+
+set err [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug f77 quiet}]
+
+unset_board_info f77compiler
+if [info exists old_f77compiler] {
+ set_board_info f77compiler $old_f77compiler
+}
+
+if { $err != "" } {
untested "Couldn't compile ${srcfile}"
return -1
}
Index: gdb-7.0.50.20100115/gdb/testsuite/gdb.fortran/omp-step.exp
===================================================================
--- gdb-7.0.50.20100115.orig/gdb/testsuite/gdb.fortran/omp-step.exp 2010-01-15 22:14:16.000000000 +0100
+++ gdb-7.0.50.20100115/gdb/testsuite/gdb.fortran/omp-step.exp 2010-01-15 22:14:51.000000000 +0100
@@ -15,7 +15,26 @@
set testfile "omp-step"
set srcfile ${testfile}.f90
-if { [prepare_for_testing $testfile.exp $testfile $srcfile {debug f77 additional_flags=-fopenmp}] } {
+
+# Temporarily provide f77compiler=gfortran44 saving the original value around.
+
+set board [target_info name]
+if [board_info $board exists f77compiler] {
+ set old_f77compiler [board_info $board f77compiler]
+ unset_board_info f77compiler
+} elseif [info exists old_f77compiler] {
+ unset old_f77compiler
+}
+set_board_info f77compiler gfortran44
+
+set err [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} {debug f77 additional_flags=-fopenmp}]
+
+unset_board_info f77compiler
+if [info exists old_f77compiler] {
+ set_board_info f77compiler $old_f77compiler
+}
+
+if $err {
return -1
}
Index: gdb-7.0.50.20100115/gdb/testsuite/gdb.fortran/derived-type.exp
===================================================================
--- gdb-7.0.50.20100115.orig/gdb/testsuite/gdb.fortran/derived-type.exp 2010-01-01 08:32:02.000000000 +0100
+++ gdb-7.0.50.20100115/gdb/testsuite/gdb.fortran/derived-type.exp 2010-01-15 22:16:20.000000000 +0100
@@ -28,8 +28,26 @@ set testfile "derived-type"
set srcfile ${testfile}.f90
set binfile ${objdir}/${subdir}/${testfile}
-if {[gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" \
- executable {debug f77}] != ""} {
+# Temporarily provide f77compiler=gfortran44 saving the original value around.
+
+set board [target_info name]
+if [board_info $board exists f77compiler] {
+ set old_f77compiler [board_info $board f77compiler]
+ unset_board_info f77compiler
+} elseif [info exists old_f77compiler] {
+ unset old_f77compiler
+}
+set_board_info f77compiler gfortran44
+
+set err [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" \
+ executable {debug f77}]
+
+unset_board_info f77compiler
+if [info exists old_f77compiler] {
+ set_board_info f77compiler $old_f77compiler
+}
+
+if { $err != "" } {
return -1
}
Index: gdb-7.0.50.20100115/gdb/testsuite/gdb.fortran/subarray.exp
===================================================================
--- gdb-7.0.50.20100115.orig/gdb/testsuite/gdb.fortran/subarray.exp 2010-01-01 08:32:02.000000000 +0100
+++ gdb-7.0.50.20100115/gdb/testsuite/gdb.fortran/subarray.exp 2010-01-15 22:17:18.000000000 +0100
@@ -28,8 +28,26 @@ set testfile "subarray"
set srcfile ${testfile}.f
set binfile ${objdir}/${subdir}/${testfile}
-if {[gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" \
- executable {debug f77}] != ""} {
+# Temporarily provide f77compiler=gfortran44 saving the original value around.
+
+set board [target_info name]
+if [board_info $board exists f77compiler] {
+ set old_f77compiler [board_info $board f77compiler]
+ unset_board_info f77compiler
+} elseif [info exists old_f77compiler] {
+ unset old_f77compiler
+}
+set_board_info f77compiler gfortran44
+
+set err [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" \
+ executable {debug f77}]
+
+unset_board_info f77compiler
+if [info exists old_f77compiler] {
+ set_board_info f77compiler $old_f77compiler
+}
+
+if { $err != "" } {
return -1
}
Index: gdb-7.0.50.20100115/gdb/testsuite/gdb.threads/tls-sepdebug.exp
===================================================================
--- gdb-7.0.50.20100115.orig/gdb/testsuite/gdb.threads/tls-sepdebug.exp 2010-01-15 22:14:15.000000000 +0100
+++ gdb-7.0.50.20100115/gdb/testsuite/gdb.threads/tls-sepdebug.exp 2010-01-15 22:14:51.000000000 +0100
@@ -32,7 +32,25 @@ set binshareddebugfile ${objdir}/${subdi
# FIXME: gcc dependency (-Wl,-soname).
-if { [gdb_compile_shlib "${srcdir}/${subdir}/${srcsharedfile}" "${binsharedfile}" [list debug additional_flags=-Wl,-soname=${binsharedbase}]] != "" } {
+# Temporarily provide compiler=gcc44 saving the original value around.
+
+set board [target_info name]
+if [board_info $board exists compiler] {
+ set old_compiler [board_info $board compiler]
+ unset_board_info compiler
+} elseif [info exists old_compiler] {
+ unset old_compiler
+}
+set_board_info compiler gcc44
+
+set err [gdb_compile_shlib "${srcdir}/${subdir}/${srcsharedfile}" "${binsharedfile}" [list debug additional_flags=-Wl,-soname=${binsharedbase}]]
+
+unset_board_info compiler
+if [info exists old_compiler] {
+ set_board_info compiler $old_compiler
+}
+
+if { $err != "" } {
untested "Couldn't compile test library"
return -1
}

View File

@ -822,3 +822,358 @@ commit 5e40af195bd74a66d300d8f481cab1f2ba533f3a
{
output[*nextp] = xstrdup (name);
++*nextp;
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 pspace 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"
Re: [patch] Fix crash on /proc/PID/stat race
http://sourceware.org/ml/gdb-patches/2010-05/msg00685.html
http://sourceware.org/ml/gdb-cvs/2010-05/msg00244.html
### src/gdb/ChangeLog 2010/05/28 18:00:41 1.11855
### src/gdb/ChangeLog 2010/05/28 18:23:13 1.11856
## -1,5 +1,10 @@
2010-05-28 Jan Kratochvil <jan.kratochvil@redhat.com>
+ * linux-nat.c (linux_nat_core_of_thread_1): Fix crash on invalid
+ CONTENT.
+
+2010-05-28 Jan Kratochvil <jan.kratochvil@redhat.com>
+
* linux-nat.c (linux_nat_wait_1): Do not call
linux_nat_core_of_thread_1 on TARGET_WAITKIND_EXITED or
TARGET_WAITKIND_SIGNALLED.
--- src/gdb/linux-nat.c 2010/05/28 18:00:46 1.169
+++ src/gdb/linux-nat.c 2010/05/28 18:23:15 1.170
@@ -5509,15 +5509,21 @@
make_cleanup (xfree, content);
p = strchr (content, '(');
- p = strchr (p, ')') + 2; /* skip ")" and a whitespace. */
+
+ /* Skip ")". */
+ if (p != NULL)
+ p = strchr (p, ')');
+ if (p != NULL)
+ p++;
/* If the first field after program name has index 0, then core number is
the field with index 36. There's no constant for that anywhere. */
- p = strtok_r (p, " ", &ts);
- for (i = 0; i != 36; ++i)
+ if (p != NULL)
+ p = strtok_r (p, " ", &ts);
+ for (i = 0; p != NULL && i != 36; ++i)
p = strtok_r (NULL, " ", &ts);
- if (sscanf (p, "%d", &core) == 0)
+ if (p == NULL || sscanf (p, "%d", &core) == 0)
core = -1;
do_cleanups (back_to);
### src/gdb/gdbserver/ChangeLog 2010/05/26 22:40:22 1.386
### src/gdb/gdbserver/ChangeLog 2010/05/28 18:23:15 1.387
## -1,3 +1,8 @@
+2010-05-28 Jan Kratochvil <jan.kratochvil@redhat.com>
+
+ * linux-low.c (linux_core_of_thread): Fix crash on invalid CONTENT.
+ New comment.
+
2010-05-26 Ozkan Sezer <sezeroz@gmail.com>
* gdbreplay.c (remote_open): Check error return from socket() call by
--- src/gdb/gdbserver/linux-low.c 2010/05/03 04:02:20 1.148
+++ src/gdb/gdbserver/linux-low.c 2010/05/28 18:23:15 1.149
@@ -4346,13 +4346,21 @@
}
p = strchr (content, '(');
- p = strchr (p, ')') + 2; /* skip ")" and a whitespace. */
- p = strtok_r (p, " ", &ts);
- for (i = 0; i != 36; ++i)
+ /* Skip ")". */
+ if (p != NULL)
+ p = strchr (p, ')');
+ if (p != NULL)
+ p++;
+
+ /* If the first field after program name has index 0, then core number is
+ the field with index 36. There's no constant for that anywhere. */
+ if (p != NULL)
+ p = strtok_r (p, " ", &ts);
+ for (i = 0; p != NULL && i != 36; ++i)
p = strtok_r (NULL, " ", &ts);
- if (sscanf (p, "%d", &core) == 0)
+ if (p == NULL || sscanf (p, "%d", &core) == 0)
core = -1;
free (content);
Re: [patch] testsuite: watchthreads-reorder: Linux kernel compat.
http://sourceware.org/ml/gdb-patches/2010-05/msg00696.html
http://sourceware.org/ml/gdb-cvs/2010-05/msg00255.html
### src/gdb/testsuite/ChangeLog 2010/05/28 23:47:40 1.2293
### src/gdb/testsuite/ChangeLog 2010/05/31 03:31:16 1.2294
## -1,3 +1,11 @@
+2010-05-31 Jan Kratochvil <jan.kratochvil@redhat.com>
+
+ Accept the new Linux kernel "t (tracing stop)" string.
+ * gdb.threads/watchthreads-reorder.c (thread1_func, thread2_func):
+ Update comment.
+ (state_wait) <T (tracing stop)>: New.
+ (main): Update the state_wait expect string.
+
2010-05-28 Pedro Alves <pedro@codesourcery.com>
* limits.c, limits.exp: Delete files.
--- src/gdb/testsuite/gdb.threads/watchthreads-reorder.c 2010/01/20 21:09:30 1.3
+++ src/gdb/testsuite/gdb.threads/watchthreads-reorder.c 2010/05/31 03:31:17 1.4
@@ -99,7 +99,7 @@
rwatch_store = thread1_rwatch;
- /* Be sure the "T (tracing stop)" test can proceed for both threads. */
+ /* Be sure the "t (tracing stop)" test can proceed for both threads. */
timed_mutex_lock (&terminate_mutex);
i = pthread_mutex_unlock (&terminate_mutex);
assert (i == 0);
@@ -125,7 +125,7 @@
rwatch_store = thread2_rwatch;
- /* Be sure the "T (tracing stop)" test can proceed for both threads. */
+ /* Be sure the "t (tracing stop)" test can proceed for both threads. */
timed_mutex_lock (&terminate_mutex);
i = pthread_mutex_unlock (&terminate_mutex);
assert (i == 0);
@@ -211,6 +211,13 @@
do
{
state = proc_string (filename, "State:\t");
+
+ /* torvalds/linux-2.6.git 464763cf1c6df632dccc8f2f4c7e50163154a2c0
+ has changed "T (tracing stop)" to "t (tracing stop)". Make the GDB
+ testcase backward compatible with older Linux kernels. */
+ if (strcmp (state, "T (tracing stop)") == 0)
+ state = "t (tracing stop)";
+
if (strcmp (state, wanted) == 0)
{
free (filename);
@@ -336,9 +343,9 @@
{
/* s390x-unknown-linux-gnu will fail with "R (running)". */
- state_wait (thread1_tid, "T (tracing stop)");
+ state_wait (thread1_tid, "t (tracing stop)");
- state_wait (thread2_tid, "T (tracing stop)");
+ state_wait (thread2_tid, "t (tracing stop)");
}
cleanup ();

View File

@ -1,3 +1,18 @@
-------------------------------------------------------------------
Thu Jul 22 09:54:36 UTC 2010 - rguenther@novell.com
- Merge from gdb-7.1-29.fc13.src.rpm.
-------------------------------------------------------------------
Tue Jun 1 11:46:20 UTC 2010 - rguenther@novell.com
- Fix build on hppa fix.
-------------------------------------------------------------------
Tue Jun 1 10:57:30 UTC 2010 - bg@novell.com
- Fix build on hppa.
-------------------------------------------------------------------
Fri May 21 12:17:19 UTC 2010 - rguenther@novell.com

100
gdb.spec
View File

@ -24,7 +24,7 @@ Name: gdb
# NOTE: the FSF gdb versions are numbered N.M for official releases, like 6.3
# and, since January 2005, X.Y.Z.date for daily snapshots, like 6.3.50.20050112 # (daily snapshot from mailine), or 6.3.0.20040112 (head of the release branch).
Version: 7.1
Release: 3
Release: 4
# 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.
@ -261,7 +261,6 @@ Patch271: gdb-6.5-bz243845-stale-testing-zombie-test.patch
# New locating of the matching binaries from the pure core file (build-id).
Patch274: gdb-6.6-buildid-locate.patch
Patch353: gdb-6.6-buildid-locate-rpm.patch
Patch415: gdb-6.6-buildid-locate-core-as-arg.patch
# Fix displaying of numeric char arrays as strings (BZ 224128).
Patch282: gdb-6.7-charsign-test.patch
@ -360,13 +359,6 @@ Patch391: gdb-x86_64-i386-syscall-restart.patch
# Fix stepping with OMP parallel Fortran sections (BZ 533176).
Patch392: gdb-bz533176-fortran-omp-step.patch
# Use gfortran44 when running the testsuite on RHEL-5.
Patch393: gdb-rhel5-gcc44.patch
# Disable warning messages new for gdb-6.8+ for RHEL-5 backward compatibility.
# Workaround RHEL-5 kernels for detaching SIGSTOPped processes (BZ 498595).
Patch335: gdb-rhel5-compat.patch
# Fix regression by python on ia64 due to stale current frame.
Patch397: gdb-follow-child-stale-parent.patch
@ -460,12 +452,66 @@ Patch459: gdb-moribund-utrace-workaround.patch
# Fix crash on VLA bound referencing an optimized-out variable (BZ 591879).
Patch460: gdb-archer-vla-ref-optimizedout.patch
# Upstream patch to fix gcc -Werror
Patch1001: gdb-7.1-werror.patch
# Remove core file when starting a process (BZ 594560).
Patch461: gdb-bz594560-core-vs-process.patch
# Import fix of TUI layout internal error (BZ 595475).
Patch462: gdb-bz595475-tui-layout.patch
# Fix and support DW_OP_*piece (Tom Tromey, BZ 589467).
Patch463: gdb-bz589467-pieces01of4.patch
Patch464: gdb-bz589467-pieces02of4.patch
Patch465: gdb-bz589467-pieces03of4.patch
Patch466: gdb-bz589467-pieces1of4.patch
Patch467: gdb-bz589467-pieces2of4.patch
Patch468: gdb-bz589467-pieces3of4.patch
Patch469: gdb-bz589467-pieces4of4.patch
Patch471: gdb-bz589467-pieces-vla-compat.patch
# Fix follow-exec for C++ programs (bugreported by Martin Stransky).
Patch470: gdb-archer-next-over-throw-cxx-exec.patch
# Fix ADL anonymous type crash (BZ 600746, Sami Wagiaalla).
Patch472: gdb-bz600746-koenig-crash.patch
# Backport DWARF-4 support (BZ 601887, Tom Tromey).
Patch473: gdb-bz601887-dwarf4-1of2.patch
Patch474: gdb-bz601887-dwarf4-2of2.patch
Patch475: gdb-bz601887-dwarf4-rh-test.patch
# Fix obstack corruptions on C++ (BZ 606185, Chris Moller, Jan Kratochvil).
Patch476: gdb-bz606185-obstack-1of5.patch
Patch477: gdb-bz606185-obstack-2of5.patch
Patch478: gdb-bz606185-obstack-3of5.patch
Patch479: gdb-bz606185-obstack-4of5.patch
Patch480: gdb-bz606185-obstack-5of5.patch
# Improve support for typedefs in classes (BZ 602314).
Patch481: gdb-bz602314-ptype-class-typedef-1of3.patch
Patch482: gdb-bz602314-ptype-class-typedef-2of3.patch
Patch483: gdb-bz602314-ptype-class-typedef-3of3.patch
# Fix `set print object on' for some non-dynamic classes (BZ 606660).
Patch484: gdb-bz606660-print-object-nonvirtual.patch
# Print 2D C++ vectors as matrices (BZ 562763, sourceware10659, Chris Moller).
Patch485: gdb-bz562763-pretty-print-2d-vectors-prereq.patch
Patch486: gdb-bz562763-pretty-print-2d-vectors.patch
Patch487: gdb-bz562763-pretty-print-2d-vectors-libstdcxx.patch
# Fix prelinked executables with sepdebug and copy relocations (BZ 614659).
Patch489: gdb-bz614659-prelink-dynbss.patch
# [delayed-symfile] Fix a backtrace regression on CFIs without DIE (BZ 614604).
Patch490: gdb-bz614604-bt-cfi-without-die.patch
# Fix readline 5.1 warnings
Patch1000: readline-5.1-random.patch
# Upstream patch to fix gcc -Werror
Patch1001: gdb-7.1-werror.patch
Patch1002: gdb-6.6-buildid-locate-rpm-suse.patch
# Fix build on hppa
Patch1003: gdb-hppa.patch
BuildRequires: bison flex gettext glibc-devel ncurses-devel texinfo zlib-devel
%if %{suse_version} < 1020
@ -701,10 +747,40 @@ rm -f gdb/jv-exp.c gdb/m2-exp.c gdb/objc-exp.c gdb/p-exp.c
%patch458 -p1
%patch459 -p1
%patch460 -p1
%patch461 -p1
%patch462 -p1
%patch463 -p1
%patch464 -p1
%patch465 -p1
%patch466 -p1
%patch467 -p1
%patch468 -p1
%patch469 -p1
%patch471 -p1
%patch470 -p1
%patch472 -p1
%patch473 -p1
%patch474 -p1
%patch475 -p1
%patch476 -p1
%patch477 -p1
%patch478 -p1
%patch479 -p1
%patch480 -p1
%patch481 -p1
%patch482 -p1
%patch483 -p1
%patch484 -p1
%patch485 -p1
%patch486 -p1
%patch487 -p1
%patch489 -p1
%patch490 -p1
%patch1000
%patch1001 -p0
%patch1002 -p1
%patch1003
find -name "*.orig" | xargs rm -f
! find -name "*.rej" # Should not happen.
@ -999,7 +1075,7 @@ fi
# don't include the files in include, they are part of binutils
%ifnarch sparcv9
%ifnarch sparcv9 hppa
%files -n gdbserver
%defattr(-,root,root)