Improve GDB performance on inferior dlopen calls (Gary Benson, BZ 698001).

[python] Fix crash when pretty printer fails (Phil Muldoon, BZ 712715).
Fix crash on invalid C++ mangled names (BZ 729283).
This commit is contained in:
Jan Kratochvil 2011-08-09 15:18:29 +02:00
parent ebad377b2d
commit b9aa4c4c7b
3 changed files with 378 additions and 1 deletions

View File

@ -0,0 +1,90 @@
diff --git a/gdb/infrun.c b/gdb/infrun.c
index 91e0fc2..1d7c808 100644
--- a/gdb/infrun.c
+++ b/gdb/infrun.c
@@ -3111,6 +3111,56 @@ fill_in_stop_func (struct gdbarch *gdbarch,
}
}
+/* Argument for at_solib_event_breakpoint_helper. */
+
+struct solib_event_breakpoint_helper_arg
+{
+ CORE_ADDR prev_pc;
+ int shlib_bp_count;
+ int other_bp_count;
+};
+
+/* Helper for at_solib_event_breakpoint. */
+
+static int
+at_solib_event_breakpoint_helper (struct breakpoint *b, void *argp)
+{
+ struct solib_event_breakpoint_helper_arg *arg
+ = (struct solib_event_breakpoint_helper_arg *) argp;
+ struct bp_location *loc;
+
+ for (loc = b->loc; loc; loc = loc->next)
+ {
+ if (loc->pspace == current_program_space
+ && (loc->address == stop_pc || loc->address == arg->prev_pc))
+ {
+ if (b->type == bp_shlib_event)
+ arg->shlib_bp_count++;
+ else
+ {
+ arg->other_bp_count++;
+ return 1; /* quick exit */
+ }
+ }
+ }
+
+ return 0; /* carry on looking */
+}
+
+/* Nonzero if the location stopoed at is the shlib event breakpoint. */
+
+static int
+at_solib_event_breakpoint (struct execution_control_state *ecs)
+{
+ struct solib_event_breakpoint_helper_arg arg;
+ arg.prev_pc = ecs->event_thread->prev_pc;
+ arg.shlib_bp_count = arg.other_bp_count = 0;
+
+ iterate_over_breakpoints (at_solib_event_breakpoint_helper, &arg);
+
+ return arg.shlib_bp_count && !arg.other_bp_count;
+}
+
/* Given an execution control state that has been freshly filled in
by an event from the inferior, figure out what it means and take
appropriate action. */
@@ -3964,11 +4014,23 @@ handle_inferior_event (struct execution_control_state *ecs)
ecs->random_signal = 0;
stopped_by_random_signal = 0;
- /* Hide inlined functions starting here, unless we just performed stepi or
- nexti. After stepi and nexti, always show the innermost frame (not any
- inline function call sites). */
- if (ecs->event_thread->control.step_range_end != 1)
- skip_inline_frames (ecs->ptid);
+ /* If we have stopped at the solib event breakpoint and
+ stop_on_solib_events is not set then we can avoid calling
+ anything that calls find_pc_section. This saves a lot
+ of time when the inferior loads a lot of shared libraries,
+ because otherwise the section map gets regenerated every
+ time we stop. */
+ if (stop_on_solib_events
+ || ecs->event_thread->suspend.stop_signal != TARGET_SIGNAL_TRAP
+ || stop_after_trap
+ || !at_solib_event_breakpoint (ecs))
+ {
+ /* Hide inlined functions starting here, unless we just
+ performed stepi or nexti. After stepi and nexti, always show
+ the innermost frame (not any inline function call sites). */
+ if (ecs->event_thread->control.step_range_end != 1)
+ skip_inline_frames (ecs->ptid);
+ }
if (ecs->event_thread->suspend.stop_signal == TARGET_SIGNAL_TRAP
&& ecs->event_thread->control.trap_expected

View File

@ -937,3 +937,281 @@ http://sourceware.org/ml/gdb-cvs/2011-07/msg00224.html
};
static void
[patch][python] Fix sigsegv when a printer fails to return a value and string_print is set.
http://sourceware.org/ml/gdb-patches/2011-07/msg00719.html
http://sourceware.org/ml/gdb-cvs/2011-07/msg00234.html
### src/gdb/ChangeLog 2011/07/27 19:31:30 1.13236
### src/gdb/ChangeLog 2011/07/28 10:36:37 1.13237
## -1,3 +1,8 @@
+2011-07-28 Phil Muldoon <pmuldoon@redhat.com>
+
+ * varobj.c (value_get_print_value): Move hint check later into the
+ function. Comment function. Free thevalue before reusing it.
+
2011-07-27 Jan Kratochvil <jan.kratochvil@redhat.com>
Pedro Alves <pedro@codesourcery.com>
--- src/gdb/varobj.c 2011/07/18 09:21:43 1.180
+++ src/gdb/varobj.c 2011/07/28 10:36:40 1.181
@@ -2610,25 +2610,21 @@
if (PyObject_HasAttr (value_formatter, gdbpy_to_string_cst))
{
- char *hint;
struct value *replacement;
PyObject *output = NULL;
- hint = gdbpy_get_display_hint (value_formatter);
- if (hint)
- {
- if (!strcmp (hint, "string"))
- string_print = 1;
- xfree (hint);
- }
-
output = apply_varobj_pretty_printer (value_formatter,
&replacement,
stb);
+
+ /* If we have string like output ... */
if (output)
{
make_cleanup_py_decref (output);
+ /* If this is a lazy string, extract it. For lazy
+ strings we always print as a string, so set
+ string_print. */
if (gdbpy_is_lazy_string (output))
{
gdbpy_extract_lazy_string (output, &str_addr, &type,
@@ -2638,12 +2634,27 @@
}
else
{
+ /* If it is a regular (non-lazy) string, extract
+ it and copy the contents into THEVALUE. If the
+ hint says to print it as a string, set
+ string_print. Otherwise just return the extracted
+ string as a value. */
+
PyObject *py_str
= python_string_to_target_python_string (output);
if (py_str)
{
char *s = PyString_AsString (py_str);
+ char *hint;
+
+ hint = gdbpy_get_display_hint (value_formatter);
+ if (hint)
+ {
+ if (!strcmp (hint, "string"))
+ string_print = 1;
+ xfree (hint);
+ }
len = PyString_Size (py_str);
thevalue = xmemdup (s, len + 1, len + 1);
@@ -2662,6 +2673,9 @@
gdbpy_print_stack ();
}
}
+ /* If the printer returned a replacement value, set VALUE
+ to REPLACEMENT. If there is not a replacement value,
+ just use the value passed to this function. */
if (replacement)
value = replacement;
}
@@ -2672,12 +2686,18 @@
get_formatted_print_options (&opts, format_code[(int) format]);
opts.deref_ref = 0;
opts.raw = 1;
+
+ /* If the THEVALUE has contents, it is a regular string. */
if (thevalue)
LA_PRINT_STRING (stb, type, thevalue, len, encoding, 0, &opts);
else if (string_print)
+ /* Otherwise, if string_print is set, and it is not a regular
+ string, it is a lazy string. */
val_print_string (type, encoding, str_addr, len, stb, &opts);
else
+ /* All other cases. */
common_val_print (value, stb, 0, &opts, current_language);
+
thevalue = ui_file_xstrdup (stb, NULL);
do_cleanups (old_chain);
### src/gdb/testsuite/ChangeLog 2011/07/27 21:18:39 1.2816
### src/gdb/testsuite/ChangeLog 2011/07/28 10:36:40 1.2817
## -1,3 +1,10 @@
+2011-07-28 Phil Muldoon <pmuldoon@redhat.com>
+
+ * gdb.python/py-mi.exp: Test printers returning string hint, and
+ also not returning a value.
+ * gdb.python/py-prettyprint.c: Add testcase for above.
+ * gdb.python/py-prettyprint.py: Add test printer for above.
+
2011-07-27 Jan Kratochvil <jan.kratochvil@redhat.com>
* gdb.dwarf2/dw2-simple-locdesc.S: Change DWARF version to 3.
--- src/gdb/testsuite/gdb.python/py-mi.exp 2011/07/26 18:38:55 1.13
+++ src/gdb/testsuite/gdb.python/py-mi.exp 2011/07/28 10:36:40 1.14
@@ -284,6 +284,13 @@ mi_list_varobj_children nstype2 {
{ {nstype2.<error at 0>} {<error at 0>} 6 {char \[6\]} }
} "list children after setting exception flag"
+mi_create_varobj me me \
+ "create me varobj"
+
+mi_gdb_test "-var-evaluate-expression me" \
+ "\\^done,value=\"<error reading variable: Cannot access memory.>.*\"" \
+ "evaluate me varobj"
+
# C++ MI tests
gdb_exit
if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" \
--- src/gdb/testsuite/gdb.python/py-prettyprint.c 2011/04/29 12:45:46 1.12
+++ src/gdb/testsuite/gdb.python/py-prettyprint.c 2011/07/28 10:36:40 1.13
@@ -149,6 +149,11 @@
typedef struct justchildren nostring_type;
+struct memory_error
+{
+ const char *s;
+};
+
struct container
{
string name;
@@ -227,6 +232,7 @@
/* Clearing by being `static' could invoke an other GDB C++ bug. */
struct nullstr nullstr;
nostring_type nstype, nstype2;
+ struct memory_error me;
struct ns ns, ns2;
struct lazystring estring, estring2;
struct hint_error hint_error;
@@ -234,6 +240,8 @@
nstype.elements = narray;
nstype.len = 0;
+ me.s = "blah";
+
init_ss(&ss, 1, 2);
init_ss(ssa+0, 3, 4);
init_ss(ssa+1, 5, 6);
--- src/gdb/testsuite/gdb.python/py-prettyprint.py 2011/04/11 17:40:41 1.11
+++ src/gdb/testsuite/gdb.python/py-prettyprint.py 2011/07/28 10:36:40 1.12
@@ -17,6 +17,7 @@
# printers.
import re
+import gdb
# Test returning a Value from a printer.
class string_print:
@@ -186,6 +187,18 @@
yield 's', self.val['s']
yield 'x', self.val['x']
+class MemoryErrorString:
+ "Raise an error"
+
+ def __init__(self, val):
+ self.val = val
+
+ def to_string(self):
+ raise gdb.MemoryError ("Cannot access memory.");
+
+ def display_hint (self):
+ return 'string'
+
def lookup_function (val):
"Look-up and return a pretty-printer that can print val."
@@ -261,6 +274,8 @@
pretty_printers_dict[re.compile ('^struct hint_error$')] = pp_hint_error
pretty_printers_dict[re.compile ('^hint_error$')] = pp_hint_error
+ pretty_printers_dict[re.compile ('^memory_error$')] = MemoryErrorString
+
pretty_printers_dict = {}
register_pretty_printers ()
commit 84be2b4d0a55c95697c9ecc72bb31c2fbd316127
Author: ian <ian@138bc75d-0d04-0410-961f-82ee72b054a4>
Date: Tue Jul 26 14:28:23 2011 +0000
* cp-demangle.c (d_print_init): Initialize pack_index field.
(d_print_comp): Check for NULL template argument.
* testsuite/demangle-expected: Add test case.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@176791 138bc75d-0d04-0410-961f-82ee72b054a4
### a/libiberty/ChangeLog
### b/libiberty/ChangeLog
## -1,3 +1,9 @@
+2011-07-26 Ian Lance Taylor <iant@google.com>
+
+ * cp-demangle.c (d_print_init): Initialize pack_index field.
+ (d_print_comp): Check for NULL template argument.
+ * testsuite/demangle-expected: Add test case.
+
2011-07-22 Gerald Pfeifer <gerald@pfeifer.com>
PR target/49817
--- a/libiberty/cp-demangle.c
+++ b/libiberty/cp-demangle.c
@@ -1,5 +1,5 @@
/* Demangler for g++ V3 ABI.
- Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
+ Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011
Free Software Foundation, Inc.
Written by Ian Lance Taylor <ian@wasabisystems.com>.
@@ -3306,6 +3306,7 @@ d_print_init (struct d_print_info *dpi, demangle_callbackref callback,
dpi->last_char = '\0';
dpi->templates = NULL;
dpi->modifiers = NULL;
+ dpi->pack_index = 0;
dpi->flush_count = 0;
dpi->callback = callback;
@@ -3893,6 +3894,13 @@ d_print_comp (struct d_print_info *dpi, int options,
struct demangle_component *a = d_lookup_template_argument (dpi, sub);
if (a && a->type == DEMANGLE_COMPONENT_TEMPLATE_ARGLIST)
a = d_index_template_argument (a, dpi->pack_index);
+
+ if (a == NULL)
+ {
+ d_print_error (dpi);
+ return;
+ }
+
sub = a;
}
--- a/libiberty/testsuite/demangle-expected
+++ b/libiberty/testsuite/demangle-expected
@@ -4010,6 +4010,12 @@ K<1, &S::m>::f()
_ZN1KILi1EXadL_ZN1S1mEEEE1fEv
K<1, &S::m>::f()
#
+# Used to crash -- binutils PR 13030.
+--format=gnu-v3
+_ZSt10_ConstructI10CellBorderIS0_EEvPT_DpOT0_
+_ZSt10_ConstructI10CellBorderIS0_EEvPT_DpOT0_
+_ZSt10_ConstructI10CellBorderIS0_EEvPT_DpOT0_
+#
# Ada (GNAT) tests.
#
# Simple test.

View File

@ -27,7 +27,7 @@ Version: 7.3.50.20110722
# The release always contains a leading reserved number, start it at 1.
# `upstream' is not a part of `name' to stay fully rpm dependencies compatible for the testing.
Release: 3%{?_with_upstream:.upstream}%{?dist}
Release: 4%{?_with_upstream:.upstream}%{?dist}
License: GPLv3+ and GPLv3+ with exceptions and GPLv2+ and GPLv2+ with exceptions and GPL+ and LGPLv2+ and BSD and Public Domain
Group: Development/Debuggers
@ -530,6 +530,9 @@ Patch556: gdb-gcc46-stdarg-prologue.patch
# rebuild to fix it, we need to be able to use gdb :)
Patch579: gdb-7.2.50-sparc-add-workaround-to-broken-debug-files.patch
# Improve GDB performance on inferior dlopen calls (Gary Benson, BZ 698001).
Patch617: gdb-dlopen-skip_inline_frames-perf.patch
BuildRequires: ncurses-devel%{?_isa} texinfo gettext flex bison expat-devel%{?_isa}
# --without-system-readline
# Requires: readline%{?_isa}
@ -791,6 +794,7 @@ rm -f gdb/jv-exp.c gdb/m2-exp.c gdb/objc-exp.c gdb/p-exp.c
%patch548 -p1
%patch556 -p1
%patch579 -p1
%patch617 -p1
%patch393 -p1
%patch335 -p1
@ -1213,6 +1217,11 @@ fi
%{_infodir}/gdb.info*
%changelog
* Tue Aug 9 2011 Jan Kratochvil <jan.kratochvil@redhat.com> - 7.3.50.20110722-4.fc16
- Improve GDB performance on inferior dlopen calls (Gary Benson, BZ 698001).
- [python] Fix crash when pretty printer fails (Phil Muldoon, BZ 712715).
- Fix crash on invalid C++ mangled names (BZ 729283).
* Fri Jul 29 2011 Jan Kratochvil <jan.kratochvil@redhat.com> - 7.3.50.20110722-3.fc16
- Fix regression from VLA merge affecting -O0 -g watchpoints.