Compare commits
7 Commits
Author | SHA1 | Date |
---|---|---|
Jan Kratochvil | f690fd519c | |
Jan Kratochvil | d653a9c5b4 | |
Sergio Durigan Junior | 8b367b2286 | |
Sergio Durigan Junior | 2ef6d5f976 | |
Jan Kratochvil | cdd3b0a2c3 | |
Jan Kratochvil | 5979e98c06 | |
Jan Kratochvil | fc812bc536 |
|
@ -0,0 +1,276 @@
|
|||
Last year a patch was submitted/approved/commited to eliminate
|
||||
symbol_matches_domain which was causing this problem. It was later reverted
|
||||
because it introduced a (severe) performance regression.
|
||||
|
||||
Recap:
|
||||
|
||||
(gdb) list
|
||||
1 enum e {A,B,C} e;
|
||||
2 int main (void) { return 0; }
|
||||
3
|
||||
(gdb) p e
|
||||
Attempt to use a type name as an expression
|
||||
|
||||
The parser attempts to find a symbol named "e" of VAR_DOMAIN.
|
||||
This gets passed down through lookup_symbol and (eventually) into
|
||||
block_lookup_symbol_primary, which iterates over the block's dictionary
|
||||
of symbols:
|
||||
|
||||
for (sym = dict_iter_name_first (block->dict, name, &dict_iter);
|
||||
sym != NULL;
|
||||
sym = dict_iter_name_next (name, &dict_iter))
|
||||
{
|
||||
if (symbol_matches_domain (SYMBOL_LANGUAGE (sym),
|
||||
SYMBOL_DOMAIN (sym), domain))
|
||||
return sym;
|
||||
}
|
||||
|
||||
The problem here is that we have a symbol named "e" in both STRUCT_DOMAIN
|
||||
and VAR_DOMAIN, and for languages like C++, Java, and Ada, where a tag name
|
||||
may be used as an implicit typedef of the type, symbol_matches_domain ignores
|
||||
the difference between VAR_DOMAIN and STRUCT_DOMAIN. As it happens, the
|
||||
STRUCT_DOMAIN symbol is found first, considered a match, and that symbol is
|
||||
returned to the parser, eliciting the (now dreaded) error message.
|
||||
|
||||
Since this bug exists specifically because we have both STRUCT and VAR_DOMAIN
|
||||
symbols in a given block/CU, this patch rather simply/naively changes
|
||||
block_lookup_symbol_primary so that it continues to search for an exact
|
||||
domain match on the symbol if symbol_matches_domain returns a symbol
|
||||
[RFC] Revisit PR 16253 ("Attempt to use a type name...")
|
||||
|
||||
which does not exactly match the requested domain.
|
||||
|
||||
This "fixes" the immediate problem, but admittedly might uncover other,
|
||||
related bugs. [Paranoia?] However, it causes no regressions (functional
|
||||
or performance) in the test suite.
|
||||
|
||||
I have also resurrected the tests from the previous submission. However
|
||||
since we can still be given a matching symbol with a different domain than
|
||||
requested, we cannot say that a symbol "was not found." The error messages
|
||||
today will still be the (dreaded) "Attempt to use a type name..." I've
|
||||
updated the tests to reflect this.
|
||||
|
||||
ChangeLog
|
||||
|
||||
PR 16253
|
||||
* block.c (block_lookup_symbol_primary): If a symbol is found
|
||||
which does not exactly match the requested domain, keep searching
|
||||
for an exact match. Otherwise, return the previously found "best"
|
||||
symbol.
|
||||
|
||||
testsuite/ChangeLog
|
||||
|
||||
PR 16253
|
||||
* gdb.cp/var-tag.cc: New file.
|
||||
* gdb.cp/var-tag.exp: New file.
|
||||
---
|
||||
gdb/ChangeLog | 8 ++++
|
||||
gdb/block.c | 16 +++++--
|
||||
gdb/testsuite/ChangeLog | 6 +++
|
||||
gdb/testsuite/gdb.cp/var-tag.cc | 44 +++++++++++++++++++
|
||||
gdb/testsuite/gdb.cp/var-tag.exp | 94 ++++++++++++++++++++++++++++++++++++++++
|
||||
5 files changed, 165 insertions(+), 3 deletions(-)
|
||||
create mode 100644 gdb/testsuite/gdb.cp/var-tag.cc
|
||||
create mode 100644 gdb/testsuite/gdb.cp/var-tag.exp
|
||||
|
||||
### a/gdb/ChangeLog
|
||||
### b/gdb/ChangeLog
|
||||
## -1,3 +1,11 @@
|
||||
+2015-06-11 Keith Seitz <keiths@redhat.com>
|
||||
+
|
||||
+ PR 16253
|
||||
+ * block.c (block_lookup_symbol_primary): If a symbol is found
|
||||
+ which does not exactly match the requested domain, keep searching
|
||||
+ for an exact match. Otherwise, return the previously found "best"
|
||||
+ symbol.
|
||||
+
|
||||
2015-06-11 Gary Benson <gbenson@redhat.com>
|
||||
|
||||
* nat/linux-namespaces.c (mnsh_send_message): Use pulongest.
|
||||
Index: gdb-7.9.1/gdb/block.c
|
||||
===================================================================
|
||||
--- gdb-7.9.1.orig/gdb/block.c 2015-06-16 16:53:51.720719643 +0200
|
||||
+++ gdb-7.9.1/gdb/block.c 2015-06-16 16:54:42.511031683 +0200
|
||||
@@ -779,21 +779,31 @@ struct symbol *
|
||||
block_lookup_symbol_primary (const struct block *block, const char *name,
|
||||
const domain_enum domain)
|
||||
{
|
||||
- struct symbol *sym;
|
||||
+ struct symbol *sym, *other;
|
||||
struct dict_iterator dict_iter;
|
||||
|
||||
/* Verify BLOCK is STATIC_BLOCK or GLOBAL_BLOCK. */
|
||||
gdb_assert (BLOCK_SUPERBLOCK (block) == NULL
|
||||
|| BLOCK_SUPERBLOCK (BLOCK_SUPERBLOCK (block)) == NULL);
|
||||
|
||||
+ other = NULL;
|
||||
for (sym = dict_iter_name_first (block->dict, name, &dict_iter);
|
||||
sym != NULL;
|
||||
sym = dict_iter_name_next (name, &dict_iter))
|
||||
{
|
||||
+ if (SYMBOL_DOMAIN (sym) == domain)
|
||||
+ return sym;
|
||||
+
|
||||
+ /* This is a bit of a hack, but symbol_matches_domain might ignore
|
||||
+ STRUCT vs VAR domain symbols. So if a matching symbol is found, make
|
||||
+ sure there is no "better" matching symbol, i.e., one with
|
||||
+ exactly the same domain. */
|
||||
if (symbol_matches_domain (SYMBOL_LANGUAGE (sym),
|
||||
SYMBOL_DOMAIN (sym), domain))
|
||||
- return sym;
|
||||
+ {
|
||||
+ other = sym;
|
||||
+ }
|
||||
}
|
||||
|
||||
- return NULL;
|
||||
+ return other;
|
||||
}
|
||||
Index: gdb-7.9.1/gdb/testsuite/gdb.cp/var-tag.cc
|
||||
===================================================================
|
||||
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
|
||||
+++ gdb-7.9.1/gdb/testsuite/gdb.cp/var-tag.cc 2015-06-16 16:53:51.721719649 +0200
|
||||
@@ -0,0 +1,44 @@
|
||||
+/* This testcase is part of GDB, the GNU debugger.
|
||||
+
|
||||
+ Copyright 2014 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 global = 3;
|
||||
+
|
||||
+class C {
|
||||
+public:
|
||||
+ struct C1 {} C1;
|
||||
+ enum E1 {a1, b1, c1} E1;
|
||||
+ union U1 {int a1; char b1;} U1;
|
||||
+
|
||||
+ C () : E1 (b1) {}
|
||||
+ void global (void) const {}
|
||||
+ int f (void) const { global (); return 0; }
|
||||
+} C;
|
||||
+
|
||||
+struct S {} S;
|
||||
+enum E {a, b, c} E;
|
||||
+union U {int a; char b;} U;
|
||||
+
|
||||
+class CC {} cc;
|
||||
+struct SS {} ss;
|
||||
+enum EE {ea, eb, ec} ee;
|
||||
+union UU {int aa; char bb;} uu;
|
||||
+
|
||||
+int
|
||||
+main (void)
|
||||
+{
|
||||
+ return C.f ();
|
||||
+}
|
||||
Index: gdb-7.9.1/gdb/testsuite/gdb.cp/var-tag.exp
|
||||
===================================================================
|
||||
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
|
||||
+++ gdb-7.9.1/gdb/testsuite/gdb.cp/var-tag.exp 2015-06-16 16:53:51.721719649 +0200
|
||||
@@ -0,0 +1,94 @@
|
||||
+# Copyright 2014, 2015 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 file is part of the gdb testsuite
|
||||
+
|
||||
+# Test expressions in which variable names shadow tag names.
|
||||
+
|
||||
+if {[skip_cplus_tests]} { continue }
|
||||
+
|
||||
+standard_testfile .cc
|
||||
+
|
||||
+if {[prepare_for_testing $testfile.exp $testfile $srcfile {debug c++}]} {
|
||||
+ return -1
|
||||
+}
|
||||
+
|
||||
+proc do_global_tests {lang} {
|
||||
+ set invalid_print "Attempt to use a type name as an expression"
|
||||
+ set ptypefmt "type = (class|enum|union|struct) %s {.*}"
|
||||
+
|
||||
+ with_test_prefix $lang {
|
||||
+ gdb_test_no_output "set language $lang"
|
||||
+ gdb_test "ptype C" "type = class C {.*}"
|
||||
+ gdb_test "print E" "= a"
|
||||
+ gdb_test "ptype E" "type = enum E {.*}"
|
||||
+ gdb_test "print S" "= {<No data fields>}"
|
||||
+ gdb_test "ptype S" "type = struct S {.*}"
|
||||
+ gdb_test "print U" "= {.*}"
|
||||
+ gdb_test "ptype U" "type = union U {.*}"
|
||||
+ gdb_test "print cc" "= {.*}"
|
||||
+ gdb_test "ptype cc" "type = class CC {.*}"
|
||||
+ gdb_test "print CC" [format $invalid_print "CC"]
|
||||
+ gdb_test "ptype CC" [format $ptypefmt "CC"]
|
||||
+ gdb_test "print ss" "= {<No data fields>}"
|
||||
+ gdb_test "ptype ss" "type = struct SS {.*}"
|
||||
+ gdb_test "print SS" [format $invalid_print "SS"]
|
||||
+ gdb_test "ptype SS" [format $ptypefmt "SS"]
|
||||
+ gdb_test "print ee" "= .*"
|
||||
+ gdb_test "ptype ee" "type = enum EE {.*}"
|
||||
+ gdb_test "print EE" [format $invalid_print "EE"]
|
||||
+ gdb_test "ptype EE" [format $ptypefmt "EE"]
|
||||
+ gdb_test "print uu" "= {.*}"
|
||||
+ gdb_test "ptype uu" "type = union UU {.*}"
|
||||
+ gdb_test "print UU" [format $invalid_print "UU"]
|
||||
+ gdb_test "ptype UU" [format $ptypefmt "UU"]
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+# First test expressions when there is no context.
|
||||
+with_test_prefix "before start" {
|
||||
+ do_global_tests c++
|
||||
+ do_global_tests c
|
||||
+}
|
||||
+
|
||||
+# Run to main and test again.
|
||||
+if {![runto_main]} {
|
||||
+ perror "couldn't run to main"
|
||||
+ continue
|
||||
+}
|
||||
+
|
||||
+with_test_prefix "in main" {
|
||||
+ do_global_tests c++
|
||||
+ do_global_tests c
|
||||
+}
|
||||
+
|
||||
+# Finally run to C::f and test again
|
||||
+gdb_breakpoint "C::f"
|
||||
+gdb_continue_to_breakpoint "continue to C::f"
|
||||
+with_test_prefix "in C::f" {
|
||||
+ do_global_tests c++
|
||||
+ do_global_tests c
|
||||
+}
|
||||
+
|
||||
+# Another hard-to-guess-the-users-intent bug...
|
||||
+# It would be really nice if we could query the user!
|
||||
+with_test_prefix "global collision" {
|
||||
+ gdb_test_no_output "set language c++"
|
||||
+ setup_kfail "c++/16463" "*-*-*"
|
||||
+ gdb_test "print global" "= 3"
|
||||
+
|
||||
+ # ... with a simple workaround:
|
||||
+ gdb_test "print ::global" "= 3"
|
||||
+}
|
|
@ -0,0 +1,43 @@
|
|||
commit f0ee78c5ccefe388a64273353ecd5c99dae62558
|
||||
Author: Jan Kratochvil <jan.kratochvil@redhat.com>
|
||||
Date: Fri Sep 18 20:54:22 2015 +0200
|
||||
|
||||
pahole.py: Fix the Python3 port.
|
||||
- https://bugzilla.redhat.com/show_bug.cgi?id=1264532
|
||||
|
||||
diff --git a/gdb/python/lib/gdb/command/pahole.py b/gdb/python/lib/gdb/command/pahole.py
|
||||
index dee04f5..e08eaf5 100644
|
||||
--- a/gdb/python/lib/gdb/command/pahole.py
|
||||
+++ b/gdb/python/lib/gdb/command/pahole.py
|
||||
@@ -55,19 +55,19 @@ It prints the type and displays comments showing where holes are."""
|
||||
fieldsize = 8 * ftype.sizeof
|
||||
|
||||
# TARGET_CHAR_BIT
|
||||
- print (' /* %3d %3d */' % (int (bitpos / 8), int (fieldsize / 8)))
|
||||
+ print (' /* %3d %3d */' % (int (bitpos / 8), int (fieldsize / 8)), end = "")
|
||||
bitpos = bitpos + fieldsize
|
||||
|
||||
if ftype.code == gdb.TYPE_CODE_STRUCT:
|
||||
self.pahole (ftype, level + 1, field.name)
|
||||
else:
|
||||
- print (' ' * (2 + 2 * level))
|
||||
+ print (' ' * (2 + 2 * level), end = "")
|
||||
print ('%s %s' % (str (ftype), field.name))
|
||||
|
||||
if level == 0:
|
||||
self.maybe_print_hole(bitpos, 8 * type.sizeof)
|
||||
|
||||
- print (' ' * (14 + 2 * level))
|
||||
+ print (' ' * (14 + 2 * level), end = "")
|
||||
print ('} %s' % name)
|
||||
|
||||
def invoke (self, arg, from_tty):
|
||||
@@ -75,7 +75,7 @@ It prints the type and displays comments showing where holes are."""
|
||||
type = type.strip_typedefs ()
|
||||
if type.code != gdb.TYPE_CODE_STRUCT:
|
||||
raise (TypeError, '%s is not a struct type' % arg)
|
||||
- print (' ' * 14)
|
||||
+ print (' ' * 14, end = "")
|
||||
self.pahole (type, 0, '')
|
||||
|
||||
Pahole()
|
|
@ -0,0 +1,175 @@
|
|||
From f469e8ce11672e26feb5ba6f9a134275fcfd5b4f Mon Sep 17 00:00:00 2001
|
||||
From: Sergio Durigan Junior <sergiodj@redhat.com>
|
||||
Date: Fri, 21 Aug 2015 18:13:46 -0400
|
||||
Subject: [PATCH 1/4] Improve error reporting when handling SystemTap SDT
|
||||
probes
|
||||
|
||||
This patch improves the error reporting when handling SystemTap SDT
|
||||
probes. "Handling", in this case, mostly means "parsing".
|
||||
|
||||
On gdb/probe.h, only trivial changes on functions' comments in order
|
||||
to explicitly mention that some of them can throw exceptions. This is
|
||||
just to make the API a bit more clear.
|
||||
|
||||
On gdb/stap-probe.c, I have s/internal_error/error/ on two functions
|
||||
that are responsible for parsing specific bits of the probes'
|
||||
arguments: stap_get_opcode and stap_get_expected_argument_type. It is
|
||||
not correct to call internal_error on such situations because it is
|
||||
not really GDB's fault if the probes have malformed arguments. I also
|
||||
improved the error reported on stap_get_expected_argument_type by also
|
||||
including the probe name on it.
|
||||
|
||||
Aside from that, and perhaps most importantly, I added a check on
|
||||
stap_get_arg to make sure that we don't try to extract an argument
|
||||
from a probe that has no arguments. This check issues an
|
||||
internal_error, because it really means that GDB is doing something it
|
||||
shouldn't.
|
||||
|
||||
Although it can be considered almost trivial, and despite the fact
|
||||
that I am the maintainer for this part of the code, I am posting this
|
||||
patch for review. I will wait a few days, and if nobody has anything
|
||||
to say, I will go ahead and push it.
|
||||
|
||||
gdb/ChangeLog:
|
||||
2015-09-01 Sergio Durigan Junior <sergiodj@redhat.com>
|
||||
|
||||
* probe.h (struct probe_ops) <get_probe_argument_count,
|
||||
evaluate_probe_argument, enable_probe, disable_probe>: Mention in
|
||||
the comment that the function can throw an exception.
|
||||
(get_probe_argument_count): Likewise.
|
||||
(evaluate_probe_argument): Likewise.
|
||||
* stap-probe.c (stap_get_opcode): Call error instead of
|
||||
internal_error.
|
||||
(stap_get_expected_argument_type): Likewise. Add argument
|
||||
'probe'. Improve error message by mentioning the probe's name.
|
||||
(stap_parse_probe_arguments): Adjust call to
|
||||
stap_get_expected_argument_type.
|
||||
(stap_get_arg): Add comment. Assert that 'probe->args_parsed' is
|
||||
not zero. Call internal_error if GDB requests an argument but the
|
||||
probe has no arguments.
|
||||
---
|
||||
gdb/ChangeLog | 17 +++++++++++++++++
|
||||
gdb/probe.h | 20 ++++++++++++++------
|
||||
gdb/stap-probe.c | 29 ++++++++++++++++++++++-------
|
||||
3 files changed, 53 insertions(+), 13 deletions(-)
|
||||
|
||||
Index: gdb-7.9.1/gdb/probe.h
|
||||
===================================================================
|
||||
--- gdb-7.9.1.orig/gdb/probe.h
|
||||
+++ gdb-7.9.1/gdb/probe.h
|
||||
@@ -70,7 +70,8 @@ struct probe_ops
|
||||
CORE_ADDR (*get_probe_address) (struct probe *probe,
|
||||
struct objfile *objfile);
|
||||
|
||||
- /* Return the number of arguments of PROBE. */
|
||||
+ /* Return the number of arguments of PROBE. This function can
|
||||
+ throw an exception. */
|
||||
|
||||
unsigned (*get_probe_argument_count) (struct probe *probe,
|
||||
struct frame_info *frame);
|
||||
@@ -82,7 +83,8 @@ struct probe_ops
|
||||
int (*can_evaluate_probe_arguments) (struct probe *probe);
|
||||
|
||||
/* Evaluate the Nth argument from the PROBE, returning a value
|
||||
- corresponding to it. The argument number is represented N. */
|
||||
+ corresponding to it. The argument number is represented N.
|
||||
+ This function can throw an exception. */
|
||||
|
||||
struct value *(*evaluate_probe_argument) (struct probe *probe,
|
||||
unsigned n,
|
||||
@@ -246,7 +248,9 @@ extern struct cmd_list_element **info_pr
|
||||
extern CORE_ADDR get_probe_address (struct probe *probe,
|
||||
struct objfile *objfile);
|
||||
|
||||
-/* Return the argument count of the specified probe. */
|
||||
+/* Return the argument count of the specified probe.
|
||||
+
|
||||
+ This function can throw an exception. */
|
||||
|
||||
extern unsigned get_probe_argument_count (struct probe *probe,
|
||||
struct frame_info *frame);
|
||||
@@ -258,7 +262,9 @@ extern unsigned get_probe_argument_count
|
||||
extern int can_evaluate_probe_arguments (struct probe *probe);
|
||||
|
||||
/* Evaluate argument N of the specified probe. N must be between 0
|
||||
- inclusive and get_probe_argument_count exclusive. */
|
||||
+ inclusive and get_probe_argument_count exclusive.
|
||||
+
|
||||
+ This function can throw an exception. */
|
||||
|
||||
extern struct value *evaluate_probe_argument (struct probe *probe,
|
||||
unsigned n,
|
||||
Index: gdb-7.9.1/gdb/stap-probe.c
|
||||
===================================================================
|
||||
--- gdb-7.9.1.orig/gdb/stap-probe.c
|
||||
+++ gdb-7.9.1/gdb/stap-probe.c
|
||||
@@ -313,9 +313,8 @@ stap_get_opcode (const char **s)
|
||||
break;
|
||||
|
||||
default:
|
||||
- internal_error (__FILE__, __LINE__,
|
||||
- _("Invalid opcode in expression `%s' for SystemTap"
|
||||
- "probe"), *s);
|
||||
+ error (_("Invalid opcode in expression `%s' for SystemTap"
|
||||
+ "probe"), *s);
|
||||
}
|
||||
|
||||
return op;
|
||||
@@ -326,7 +325,8 @@ stap_get_opcode (const char **s)
|
||||
|
||||
static struct type *
|
||||
stap_get_expected_argument_type (struct gdbarch *gdbarch,
|
||||
- enum stap_arg_bitness b)
|
||||
+ enum stap_arg_bitness b,
|
||||
+ const struct stap_probe *probe)
|
||||
{
|
||||
switch (b)
|
||||
{
|
||||
@@ -361,8 +361,8 @@ stap_get_expected_argument_type (struct
|
||||
return builtin_type (gdbarch)->builtin_uint64;
|
||||
|
||||
default:
|
||||
- internal_error (__FILE__, __LINE__,
|
||||
- _("Undefined bitness for probe."));
|
||||
+ error (_("Undefined bitness for probe '%s'."),
|
||||
+ probe->p.name);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -1172,7 +1172,8 @@ stap_parse_probe_arguments (struct stap_
|
||||
else
|
||||
arg.bitness = STAP_ARG_BITNESS_UNDEFINED;
|
||||
|
||||
- arg.atype = stap_get_expected_argument_type (gdbarch, arg.bitness);
|
||||
+ arg.atype = stap_get_expected_argument_type (gdbarch, arg.bitness,
|
||||
+ probe);
|
||||
|
||||
expr = stap_parse_argument (&cur, arg.atype, gdbarch);
|
||||
|
||||
@@ -1278,12 +1279,26 @@ stap_is_operator (const char *op)
|
||||
return ret;
|
||||
}
|
||||
|
||||
+/* Return argument N of probe PROBE.
|
||||
+
|
||||
+ If the probe's arguments have not been parsed yet, parse them. If
|
||||
+ there are no arguments, throw an exception (error). Otherwise,
|
||||
+ return the requested argument. */
|
||||
+
|
||||
static struct stap_probe_arg *
|
||||
stap_get_arg (struct stap_probe *probe, unsigned n, struct gdbarch *gdbarch)
|
||||
{
|
||||
if (!probe->args_parsed)
|
||||
stap_parse_probe_arguments (probe, gdbarch);
|
||||
|
||||
+ gdb_assert (probe->args_parsed);
|
||||
+ if (probe->args_u.vec == NULL)
|
||||
+ internal_error (__FILE__, __LINE__,
|
||||
+ _("Probe '%s' apparently does not have arguments, but \n"
|
||||
+ "GDB is requesting its argument number %u anyway. "
|
||||
+ "This should not happen. Please report this bug."),
|
||||
+ probe->p.name, n);
|
||||
+
|
||||
return VEC_index (stap_probe_arg_s, probe->args_u.vec, n);
|
||||
}
|
||||
|
|
@ -0,0 +1,151 @@
|
|||
From 3bd7e5b7ee5ea0b3bbb4030ca841f66faad74f0f Mon Sep 17 00:00:00 2001
|
||||
From: Sergio Durigan Junior <sergiodj@redhat.com>
|
||||
Date: Fri, 21 Aug 2015 18:28:07 -0400
|
||||
Subject: [PATCH 2/4] Catching errors on probes-based dynamic linker interface
|
||||
|
||||
This patch is intended to make the interaction between the
|
||||
probes-based dynamic linker interface and the SystemTap SDT probe code
|
||||
on GDB more robust. It does that by wrapping the calls to the probe
|
||||
API with TRY...CATCH'es, so that any exception thrown will be caught
|
||||
and handled properly.
|
||||
|
||||
The idea for this patch came from
|
||||
<https://bugzilla.redhat.com/show_bug.cgi?id=1196181>, which is a bug
|
||||
initially filed against Fedora GDB (but now under Fedora GLIBC). This
|
||||
bug happens on armhfp (although it could happen on other targets as
|
||||
well), and is triggered because GCC generates a strange argument for
|
||||
one of the probes used by GDB in the dynamic linker interface. As can
|
||||
be seen in the bug, this argument is "-4@.L1052".
|
||||
|
||||
I don't want to discuss the reasons for this argument to be there
|
||||
(this discussion belongs to the bug, or to another thread), but GDB
|
||||
could definitely do a better error handling here. Currently, one sees
|
||||
the following message when there is an error in the probes-based
|
||||
dynamic linker interface:
|
||||
|
||||
(gdb) run
|
||||
Starting program: /bin/inferior
|
||||
warning: Probes-based dynamic linker interface failed.
|
||||
Reverting to original interface.
|
||||
|
||||
Cannot parse expression `.L976 4@r4'.
|
||||
(gdb)
|
||||
|
||||
Which means that one needs to explicitly issue a "continue" command to
|
||||
make GDB continue running the inferior, even though this error is not
|
||||
fatal and GDB will fallback to the old interface automatically.
|
||||
|
||||
This is where this patch helps: it makes GDB still print the necessary
|
||||
warnings or error messages, but it *also* does not stop the inferior
|
||||
unnecessarily.
|
||||
|
||||
I have tested this patch on the systems where this error happens, but
|
||||
I could not come up with a way to create a testcase for it.
|
||||
Nevertheless, it should be straightforward to see that this patch does
|
||||
improve the current situation.
|
||||
|
||||
gdb/ChangeLog:
|
||||
2015-09-01 Sergio Durigan Junior <sergiodj@redhat.com>
|
||||
|
||||
* solib-svr4.c (solib_event_probe_action): Call
|
||||
get_probe_argument_count using TRY...CATCH.
|
||||
(svr4_handle_solib_event): Likewise, for evaluate_probe_argument.
|
||||
---
|
||||
gdb/ChangeLog | 6 ++++++
|
||||
gdb/solib-svr4.c | 43 ++++++++++++++++++++++++++++++++++++++++---
|
||||
2 files changed, 46 insertions(+), 3 deletions(-)
|
||||
|
||||
Index: gdb-7.9.1/gdb/solib-svr4.c
|
||||
===================================================================
|
||||
--- gdb-7.9.1.orig/gdb/solib-svr4.c
|
||||
+++ gdb-7.9.1/gdb/solib-svr4.c
|
||||
@@ -1769,8 +1769,9 @@ static enum probe_action
|
||||
solib_event_probe_action (struct probe_and_action *pa)
|
||||
{
|
||||
enum probe_action action;
|
||||
- unsigned probe_argc;
|
||||
+ unsigned probe_argc = 0;
|
||||
struct frame_info *frame = get_current_frame ();
|
||||
+ volatile struct gdb_exception ex;
|
||||
|
||||
action = pa->action;
|
||||
if (action == DO_NOTHING || action == PROBES_INTERFACE_FAILED)
|
||||
@@ -1783,7 +1784,23 @@ solib_event_probe_action (struct probe_a
|
||||
arg0: Lmid_t lmid (mandatory)
|
||||
arg1: struct r_debug *debug_base (mandatory)
|
||||
arg2: struct link_map *new (optional, for incremental updates) */
|
||||
- probe_argc = get_probe_argument_count (pa->probe, frame);
|
||||
+ TRY_CATCH (ex, RETURN_MASK_ERROR)
|
||||
+ {
|
||||
+ probe_argc = get_probe_argument_count (pa->probe, frame);
|
||||
+ }
|
||||
+
|
||||
+ if (ex.reason < 0)
|
||||
+ {
|
||||
+ exception_print (gdb_stderr, ex);
|
||||
+ probe_argc = 0;
|
||||
+ }
|
||||
+
|
||||
+ /* If get_probe_argument_count throws an exception, probe_argc will
|
||||
+ be set to zero. However, if pa->probe does not have arguments,
|
||||
+ then get_probe_argument_count will succeed but probe_argc will
|
||||
+ also be zero. Both cases happen because of different things, but
|
||||
+ they are treated equally here: action will be set to
|
||||
+ PROBES_INTERFACE_FAILED. */
|
||||
if (probe_argc == 2)
|
||||
action = FULL_RELOAD;
|
||||
else if (probe_argc < 2)
|
||||
@@ -1889,10 +1906,11 @@ svr4_handle_solib_event (void)
|
||||
struct probe_and_action *pa;
|
||||
enum probe_action action;
|
||||
struct cleanup *old_chain, *usm_chain;
|
||||
- struct value *val;
|
||||
+ struct value *val = NULL;
|
||||
CORE_ADDR pc, debug_base, lm = 0;
|
||||
int is_initial_ns;
|
||||
struct frame_info *frame = get_current_frame ();
|
||||
+ volatile struct gdb_exception ex;
|
||||
|
||||
/* Do nothing if not using the probes interface. */
|
||||
if (info->probes_table == NULL)
|
||||
@@ -1937,7 +1955,17 @@ svr4_handle_solib_event (void)
|
||||
usm_chain = make_cleanup (resume_section_map_updates_cleanup,
|
||||
current_program_space);
|
||||
|
||||
- val = evaluate_probe_argument (pa->probe, 1, frame);
|
||||
+ TRY_CATCH (ex, RETURN_MASK_ERROR)
|
||||
+ {
|
||||
+ val = evaluate_probe_argument (pa->probe, 1, frame);
|
||||
+ }
|
||||
+
|
||||
+ if (ex.reason < 0)
|
||||
+ {
|
||||
+ exception_print (gdb_stderr, ex);
|
||||
+ val = NULL;
|
||||
+ }
|
||||
+
|
||||
if (val == NULL)
|
||||
{
|
||||
do_cleanups (old_chain);
|
||||
@@ -1968,7 +1996,20 @@ svr4_handle_solib_event (void)
|
||||
|
||||
if (action == UPDATE_OR_RELOAD)
|
||||
{
|
||||
- val = evaluate_probe_argument (pa->probe, 2, frame);
|
||||
+ volatile struct gdb_exception ex;
|
||||
+
|
||||
+ TRY_CATCH (ex, RETURN_MASK_ERROR)
|
||||
+ {
|
||||
+ val = evaluate_probe_argument (pa->probe, 2, frame);
|
||||
+ }
|
||||
+
|
||||
+ if (ex.reason < 0)
|
||||
+ {
|
||||
+ exception_print (gdb_stderr, ex);
|
||||
+ do_cleanups (old_chain);
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
if (val != NULL)
|
||||
lm = value_as_address (val);
|
||||
|
|
@ -0,0 +1,220 @@
|
|||
http://sourceware.org/ml/gdb-patches/2015-10/msg00166.html
|
||||
Subject: [patch] Fix internal error on DW_OP_bregx(-1)
|
||||
|
||||
|
||||
--ibTvN161/egqYuK8
|
||||
Content-Type: text/plain; charset=us-ascii
|
||||
Content-Disposition: inline
|
||||
|
||||
Hi,
|
||||
|
||||
https://bugzilla.redhat.com/show_bug.cgi?id=1270564#c15
|
||||
https://bugzilla.redhat.com/attachment.cgi?id=1081772
|
||||
|
||||
clang-3.5.0-9.fc22.x86_64
|
||||
<3><22b2>: Abbrev Number: 69 (DW_TAG_variable)
|
||||
<22b3> DW_AT_location : 7 byte block: 92 ff ff ff ff f 0 (DW_OP_bregx: 4294967295 (r-1) 0)
|
||||
<22bb> DW_AT_name : (indirect string, offset: 0x2a36): texture_data
|
||||
<22c1> DW_AT_type : <0x1d3>
|
||||
|
||||
(gdb) p variable
|
||||
warning: Unmapped DWARF Register #-1 encountered.
|
||||
regcache.c:177: internal-error: register_size: Assertion `regnum >= 0 && regnum < (gdbarch_num_regs (gdbarch) + gdbarch_num_pseudo_regs (gdbarch))' failed.
|
||||
[...]
|
||||
Quit this debugging session? (y or n) FAIL: gdb.dwarf2/dw2-regno-invalid.exp: p variable (GDB internal error)
|
||||
|
||||
-> (x86_64)
|
||||
(gdb) p variable
|
||||
warning: Unmapped DWARF Register #-1 encountered.
|
||||
Invalid register #-1, expecting 0 <= # < 220
|
||||
(gdb) PASS: gdb.dwarf2/dw2-regno-invalid.exp: p variable
|
||||
-> (i386)
|
||||
(gdb) p variable
|
||||
Invalid register #104, expecting 0 <= # < 104
|
||||
(gdb) PASS: gdb.dwarf2/dw2-regno-invalid.exp: p variable
|
||||
|
||||
GDB calls gdbarch_dwarf2_reg_to_regnum() first which returns -1 in the x86_64
|
||||
case
|
||||
if (regnum == -1)
|
||||
warning (_("Unmapped DWARF Register #%d encountered."), reg);
|
||||
but in i386 case it does:
|
||||
/* This will hopefully provoke a warning. */
|
||||
return gdbarch_num_regs (gdbarch) + gdbarch_num_pseudo_regs (gdbarch);
|
||||
and the default implementation is a nop, leaving whatever register number
|
||||
the DWARF specified.
|
||||
|
||||
No regressions on {x86_64,x86_64-m32,i686}-fedorarawhide-linux-gnu.
|
||||
|
||||
|
||||
Jan
|
||||
|
||||
--ibTvN161/egqYuK8
|
||||
Content-Type: text/plain; charset=us-ascii
|
||||
Content-Disposition: inline; filename="undefreg.patch"
|
||||
|
||||
gdb/ChangeLog
|
||||
2015-10-12 Jan Kratochvil <jan.kratochvil@redhat.com>
|
||||
|
||||
* findvar.c (address_from_register): Check REGNUM validity.
|
||||
|
||||
gdb/testsuite/ChangeLog
|
||||
2015-10-12 Jan Kratochvil <jan.kratochvil@redhat.com>
|
||||
|
||||
* gdb.dwarf2/dw2-regno-invalid.S: New file.
|
||||
* gdb.dwarf2/dw2-regno-invalid.exp: New file.
|
||||
|
||||
diff --git a/gdb/findvar.c b/gdb/findvar.c
|
||||
index 0f46e53..855947d 100644
|
||||
--- a/gdb/findvar.c
|
||||
+++ b/gdb/findvar.c
|
||||
@@ -927,6 +927,12 @@ address_from_register (int regnum, struct frame_info *frame)
|
||||
struct type *type = builtin_type (gdbarch)->builtin_data_ptr;
|
||||
struct value *value;
|
||||
CORE_ADDR result;
|
||||
+ int regnum_max_excl = (gdbarch_num_regs (gdbarch)
|
||||
+ + gdbarch_num_pseudo_regs (gdbarch));
|
||||
+
|
||||
+ if (regnum < 0 || regnum >= regnum_max_excl)
|
||||
+ error (_("Invalid register #%d, expecting 0 <= # < %d"), regnum,
|
||||
+ regnum_max_excl);
|
||||
|
||||
/* This routine may be called during early unwinding, at a time
|
||||
where the ID of FRAME is not yet known. Calling value_from_register
|
||||
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-regno-invalid.S b/gdb/testsuite/gdb.dwarf2/dw2-regno-invalid.S
|
||||
new file mode 100644
|
||||
index 0000000..075bfd6
|
||||
--- /dev/null
|
||||
+++ b/gdb/testsuite/gdb.dwarf2/dw2-regno-invalid.S
|
||||
@@ -0,0 +1,91 @@
|
||||
+/* Copyright 2015 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/>. */
|
||||
+
|
||||
+ .section .debug_info
|
||||
+debug_start:
|
||||
+ .4byte debug_end - 1f /* Length of Compilation Unit Info */
|
||||
+1:
|
||||
+ .2byte 0x3 /* DWARF version number */
|
||||
+ .4byte .Ldebug_abbrev0 /* Offset Into Abbrev. Section */
|
||||
+ .byte 0x4 /* Pointer Size (in bytes) */
|
||||
+ .uleb128 0x1 /* (DIE (0xb) DW_TAG_compile_unit) */
|
||||
+ .ascii "clang-3.5.0-9.fc22.x86_64\0" /* DW_AT_producer */
|
||||
+ .byte 0x1 /* DW_AT_language */
|
||||
+ .ascii "1.c\0" /* DW_AT_name */
|
||||
+ .4byte main_label /* DW_AT_low_pc */
|
||||
+ .4byte main_label+0x10000 /* DW_AT_high_pc */
|
||||
+
|
||||
+ .uleb128 2 /* Abbrev: DW_TAG_subprogram */
|
||||
+ .byte 1 /* DW_AT_external */
|
||||
+ .ascii "main\0" /* DW_AT_name */
|
||||
+ .4byte main_label /* DW_AT_low_pc */
|
||||
+ .4byte main_label+0x10000 /* DW_AT_high_pc */
|
||||
+
|
||||
+ .uleb128 0x4 /* (DW_TAG_variable) */
|
||||
+ .ascii "variable\0" /* DW_AT_name */
|
||||
+ .2byte 2f - 1f /* DW_AT_location: DW_FORM_block2 */
|
||||
+1:
|
||||
+ .byte 0x92 /* DW_OP_bregx */
|
||||
+ .uleb128 0xffffffff
|
||||
+ .sleb128 0
|
||||
+2:
|
||||
+
|
||||
+ .byte 0x0 /* end of children of main */
|
||||
+ .byte 0x0 /* end of children of CU */
|
||||
+debug_end:
|
||||
+
|
||||
+ .section .debug_abbrev
|
||||
+.Ldebug_abbrev0:
|
||||
+ .uleb128 0x1 /* (abbrev code) */
|
||||
+ .uleb128 0x11 /* (TAG: DW_TAG_compile_unit) */
|
||||
+ .byte 0x1 /* DW_children_yes */
|
||||
+ .uleb128 0x25 /* (DW_AT_producer) */
|
||||
+ .uleb128 0x8 /* (DW_FORM_string) */
|
||||
+ .uleb128 0x13 /* (DW_AT_language) */
|
||||
+ .uleb128 0xb /* (DW_FORM_data1) */
|
||||
+ .uleb128 0x3 /* (DW_AT_name) */
|
||||
+ .uleb128 0x8 /* (DW_FORM_string) */
|
||||
+ .uleb128 0x11 /* DW_AT_low_pc */
|
||||
+ .uleb128 0x1 /* DW_FORM_addr */
|
||||
+ .uleb128 0x12 /* DW_AT_high_pc */
|
||||
+ .uleb128 0x1 /* DW_FORM_addr */
|
||||
+ .byte 0x0
|
||||
+ .byte 0x0
|
||||
+
|
||||
+ .uleb128 2 /* Abbrev code */
|
||||
+ .uleb128 0x2e /* DW_TAG_subprogram */
|
||||
+ .byte 1 /* has_children */
|
||||
+ .uleb128 0x3f /* DW_AT_external */
|
||||
+ .uleb128 0xc /* DW_FORM_flag */
|
||||
+ .uleb128 0x3 /* DW_AT_name */
|
||||
+ .uleb128 0x8 /* DW_FORM_string */
|
||||
+ .uleb128 0x11 /* DW_AT_low_pc */
|
||||
+ .uleb128 0x1 /* DW_FORM_addr */
|
||||
+ .uleb128 0x12 /* DW_AT_high_pc */
|
||||
+ .uleb128 0x1 /* DW_FORM_addr */
|
||||
+ .byte 0x0 /* Terminator */
|
||||
+ .byte 0x0 /* Terminator */
|
||||
+
|
||||
+
|
||||
+ .uleb128 0x4 /* (abbrev code) */
|
||||
+ .uleb128 0x34 /* (TAG: DW_TAG_variable) */
|
||||
+ .byte 0x0 /* DW_children_yes */
|
||||
+ .uleb128 0x3 /* (DW_AT_name) */
|
||||
+ .uleb128 0x8 /* (DW_FORM_string) */
|
||||
+ .uleb128 0x02 /* (DW_AT_location) */
|
||||
+ .uleb128 0x3 /* (DW_FORM_block2) */
|
||||
+ .byte 0x0
|
||||
+ .byte 0x0
|
||||
+ .byte 0x0
|
||||
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-regno-invalid.exp b/gdb/testsuite/gdb.dwarf2/dw2-regno-invalid.exp
|
||||
new file mode 100644
|
||||
index 0000000..7c3a404
|
||||
--- /dev/null
|
||||
+++ b/gdb/testsuite/gdb.dwarf2/dw2-regno-invalid.exp
|
||||
@@ -0,0 +1,32 @@
|
||||
+# Copyright 2015 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/>.
|
||||
+load_lib dwarf.exp
|
||||
+
|
||||
+# This test can only be run on targets which support DWARF-2 and use gas.
|
||||
+if {![dwarf2_support]} {
|
||||
+ return 0
|
||||
+}
|
||||
+
|
||||
+standard_testfile .S main.c
|
||||
+
|
||||
+if { [gdb_compile "${srcdir}/${subdir}/${srcfile} ${srcdir}/${subdir}/${srcfile2}" \
|
||||
+ "${binfile}" executable {}] != "" } {
|
||||
+ return -1
|
||||
+}
|
||||
+
|
||||
+clean_restart ${binfile}
|
||||
+runto_main
|
||||
+
|
||||
+gdb_test "p variable"
|
||||
|
||||
--ibTvN161/egqYuK8--
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
https://bugzilla.redhat.com/show_bug.cgi?id=1085576
|
||||
|
||||
--- gdb-7.8.2/gdb/python/lib/gdb/command/type_printers.py-orig 2015-01-15 11:58:12.000000000 +0100
|
||||
+++ gdb-7.8.2/gdb/python/lib/gdb/command/type_printers.py 2015-06-26 15:33:43.972460415 +0200
|
||||
@@ -47,7 +47,7 @@ class InfoTypePrinter(gdb.Command):
|
||||
sep = ''
|
||||
for objfile in gdb.objfiles():
|
||||
if objfile.type_printers:
|
||||
- print ("%sType printers for %s:" % (sep, objfile.name))
|
||||
+ print ("%sType printers for %s:" % (sep, objfile.filename))
|
||||
self.list_type_printers(objfile.type_printers)
|
||||
sep = '\n'
|
||||
if gdb.current_progspace().type_printers:
|
|
@ -51,3 +51,191 @@ Date: Tue Jan 27 19:56:45 2015 +0200
|
|||
|
||||
if (!overlay_debugging)
|
||||
error (_("Overlay debugging not enabled. "
|
||||
|
||||
|
||||
|
||||
commit 253828f102691732d014e8f1d62f9b5dc779b39c
|
||||
Author: Jan Kratochvil <jan.kratochvil@redhat.com>
|
||||
Date: Thu Jan 22 21:04:53 2015 +0100
|
||||
|
||||
Sort threads for thread apply all
|
||||
|
||||
downstream Fedora request:
|
||||
Please make it easier to find the backtrace of the crashing thread
|
||||
https://bugzilla.redhat.com/show_bug.cgi?id=1024504
|
||||
|
||||
Currently after loading a core file GDB prints:
|
||||
|
||||
Core was generated by `./threadcrash1'.
|
||||
Program terminated with signal SIGSEGV, Segmentation fault.
|
||||
8 *(volatile int *)0=0;
|
||||
(gdb) _
|
||||
|
||||
there is nowhere seen which of the threads had crashed. In reality GDB always
|
||||
numbers that thread as #1 and it is the current thread that time. But after
|
||||
dumping all the info into a file for later analysis it is no longer obvious.
|
||||
'thread apply all bt' even puts the thread #1 to the _end_ of the output!!!
|
||||
|
||||
I find maybe as good enough and with no risk of UI change flamewar to just
|
||||
sort the threads by their number. Currently they are printed as they happen
|
||||
in the internal GDB list which has no advantage. Printing thread #1 as the
|
||||
first one with assumed 'thread apply all bt' (after the core file is loaded)
|
||||
should make the complaint resolved I guess.
|
||||
|
||||
On Thu, 15 Jan 2015 20:29:07 +0100, Doug Evans wrote:
|
||||
No objection to sorting the list, but if thread #1 is the important one,
|
||||
then a concern could be it'll have scrolled off the screen (such a
|
||||
concern has been voiced in another thread in another context),
|
||||
and if not lost (say it's in an emacs buffer) one would still have
|
||||
to scroll back to see it.
|
||||
So one *could* still want #1 to be last.
|
||||
Do we want an option to choose the sort direction?
|
||||
|
||||
gdb/ChangeLog
|
||||
2015-01-22 Jan Kratochvil <jan.kratochvil@redhat.com>
|
||||
|
||||
* NEWS (Changes since GDB 7.9): Add 'thread apply all' option
|
||||
'-ascending'.
|
||||
* thread.c (tp_array_compar_ascending, tp_array_compar): New.
|
||||
(thread_apply_all_command): Parse CMD for tp_array_compar_ascending.
|
||||
Sort tp_array using tp_array_compar.
|
||||
(_initialize_thread): Extend thread_apply_all_command help.
|
||||
|
||||
gdb/doc/ChangeLog
|
||||
2015-01-22 Jan Kratochvil <jan.kratochvil@redhat.com>
|
||||
|
||||
* gdb.texinfo (Threads): Describe -ascending for thread apply all.
|
||||
|
||||
### a/gdb/ChangeLog
|
||||
### b/gdb/ChangeLog
|
||||
## -1,5 +1,14 @@
|
||||
2015-01-22 Jan Kratochvil <jan.kratochvil@redhat.com>
|
||||
|
||||
+ * NEWS (Changes since GDB 7.9): Add 'thread apply all' option
|
||||
+ '-ascending'.
|
||||
+ * thread.c (tp_array_compar_ascending, tp_array_compar): New.
|
||||
+ (thread_apply_all_command): Parse CMD for tp_array_compar_ascending.
|
||||
+ Sort tp_array using tp_array_compar.
|
||||
+ (_initialize_thread): Extend thread_apply_all_command help.
|
||||
+
|
||||
+2015-01-22 Jan Kratochvil <jan.kratochvil@redhat.com>
|
||||
+
|
||||
* corelow.c (core_open): Call also thread_command.
|
||||
* gdbthread.h (thread_command): New prototype moved from ...
|
||||
* thread.c (thread_command): ... here.
|
||||
--- gdb-7.9.1/gdb/NEWS.orig 2015-06-19 15:45:57.614937084 +0200
|
||||
+++ gdb-7.9.1/gdb/NEWS 2015-06-19 15:46:26.352104210 +0200
|
||||
@@ -1,6 +1,13 @@
|
||||
What has changed in GDB?
|
||||
(Organized release by release)
|
||||
|
||||
+*** Changes since GDB 7.9.1
|
||||
+
|
||||
+* New options
|
||||
+
|
||||
+* The command 'thread apply all' can now support new option '-ascending'
|
||||
+ to call its specified command for all threads in ascending order.
|
||||
+
|
||||
*** Changes in GDB 7.9.1
|
||||
|
||||
* Python Scripting
|
||||
### a/gdb/doc/ChangeLog
|
||||
### b/gdb/doc/ChangeLog
|
||||
## -1,3 +1,7 @@
|
||||
+2015-01-22 Jan Kratochvil <jan.kratochvil@redhat.com>
|
||||
+
|
||||
+ * gdb.texinfo (Threads): Describe -ascending for thread apply all.
|
||||
+
|
||||
2015-01-16 Eli Zaretskii <eliz@gnu.org>
|
||||
|
||||
* doc/gdb.texinfo (TUI Commands): Document the possible
|
||||
--- a/gdb/doc/gdb.texinfo
|
||||
+++ b/gdb/doc/gdb.texinfo
|
||||
@@ -2959,14 +2959,17 @@ information on convenience variables.
|
||||
|
||||
@kindex thread apply
|
||||
@cindex apply command to several threads
|
||||
-@item thread apply [@var{threadno} | all] @var{command}
|
||||
+@item thread apply [@var{threadno} | all [-ascending]] @var{command}
|
||||
The @code{thread apply} command allows you to apply the named
|
||||
@var{command} to one or more threads. Specify the numbers of the
|
||||
threads that you want affected with the command argument
|
||||
@var{threadno}. It can be a single thread number, one of the numbers
|
||||
shown in the first field of the @samp{info threads} display; or it
|
||||
-could be a range of thread numbers, as in @code{2-4}. To apply a
|
||||
-command to all threads, type @kbd{thread apply all @var{command}}.
|
||||
+could be a range of thread numbers, as in @code{2-4}. To apply
|
||||
+a command to all threads in descending order, type @kbd{thread apply all
|
||||
+@var{command}}. To apply a command to all threads in ascending order,
|
||||
+type @kbd{thread apply all -ascending @var{command}}.
|
||||
+
|
||||
|
||||
@kindex thread name
|
||||
@cindex name a thread
|
||||
--- a/gdb/thread.c
|
||||
+++ b/gdb/thread.c
|
||||
@@ -1381,6 +1381,24 @@ make_cleanup_restore_current_thread (void)
|
||||
restore_current_thread_cleanup_dtor);
|
||||
}
|
||||
|
||||
+/* If non-zero tp_array_compar should sort in ascending order, otherwise in
|
||||
+ descending order. */
|
||||
+
|
||||
+static int tp_array_compar_ascending;
|
||||
+
|
||||
+/* Sort an array for struct thread_info pointers by their NUM, order is
|
||||
+ determined by TP_ARRAY_COMPAR_ASCENDING. */
|
||||
+
|
||||
+static int
|
||||
+tp_array_compar (const void *ap_voidp, const void *bp_voidp)
|
||||
+{
|
||||
+ const struct thread_info *const *ap = ap_voidp;
|
||||
+ const struct thread_info *const *bp = bp_voidp;
|
||||
+
|
||||
+ return ((((*ap)->num > (*bp)->num) - ((*ap)->num < (*bp)->num))
|
||||
+ * (tp_array_compar_ascending ? +1 : -1));
|
||||
+}
|
||||
+
|
||||
/* Apply a GDB command to a list of threads. List syntax is a whitespace
|
||||
seperated list of numbers, or ranges, or the keyword `all'. Ranges consist
|
||||
of two numbers seperated by a hyphen. Examples:
|
||||
@@ -1397,6 +1415,14 @@ thread_apply_all_command (char *cmd, int from_tty)
|
||||
int tc;
|
||||
struct thread_array_cleanup ta_cleanup;
|
||||
|
||||
+ tp_array_compar_ascending = 0;
|
||||
+ if (cmd != NULL
|
||||
+ && check_for_argument (&cmd, "-ascending", strlen ("-ascending")))
|
||||
+ {
|
||||
+ cmd = skip_spaces (cmd);
|
||||
+ tp_array_compar_ascending = 1;
|
||||
+ }
|
||||
+
|
||||
if (cmd == NULL || *cmd == '\000')
|
||||
error (_("Please specify a command following the thread ID list"));
|
||||
|
||||
@@ -1430,6 +1456,8 @@ thread_apply_all_command (char *cmd, int from_tty)
|
||||
i++;
|
||||
}
|
||||
|
||||
+ qsort (tp_array, i, sizeof (*tp_array), tp_array_compar);
|
||||
+
|
||||
make_cleanup (set_thread_refcount, &ta_cleanup);
|
||||
|
||||
for (k = 0; k != i; k++)
|
||||
@@ -1738,7 +1766,14 @@ The new thread ID must be currently known."),
|
||||
&thread_apply_list, "thread apply ", 1, &thread_cmd_list);
|
||||
|
||||
add_cmd ("all", class_run, thread_apply_all_command,
|
||||
- _("Apply a command to all threads."), &thread_apply_list);
|
||||
+ _("\
|
||||
+Apply a command to all threads.\n\
|
||||
+\n\
|
||||
+Usage: thread apply all [-ascending] <command>\n\
|
||||
+-ascending: Call <command> for all threads in ascending order.\n\
|
||||
+ The default is descending order.\
|
||||
+"),
|
||||
+ &thread_apply_list);
|
||||
|
||||
add_cmd ("name", class_run, thread_name_command,
|
||||
_("Set the current thread's name.\n\
|
||||
|
|
44
gdb.spec
44
gdb.spec
|
@ -26,7 +26,7 @@ Version: 7.9.1
|
|||
|
||||
# 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: 14%{?dist}
|
||||
Release: 20%{?dist}
|
||||
|
||||
License: GPLv3+ and GPLv3+ with exceptions and GPLv2+ and GPLv2+ with exceptions and GPL+ and LGPLv2+ and BSD and Public Domain and GFDL
|
||||
Group: Development/Debuggers
|
||||
|
@ -538,6 +538,23 @@ Patch984: gdb-python3-py_hash_t-32bit.patch
|
|||
# Fix Python 3 testsuite regressions.
|
||||
Patch985: gdb-python3-testsuite.patch
|
||||
|
||||
# Fix enum e e 'Attempt to use a type name as an expr.' (Keith Seitz, PR 16253).
|
||||
Patch991: gdb-cxx-enum-tag.patch
|
||||
|
||||
# Fix 'info type-printers' Python error (Clem Dickey, RH BZ 1085576).
|
||||
Patch992: gdb-type-printers-error.patch
|
||||
|
||||
# Fix 'Make the probes-based dynamic linker interface more robust to
|
||||
# errors' (Sergio Durigan Junior, RH BZ 1259132).
|
||||
Patch1031: gdb-probes-based-interface-robust-1of2.patch
|
||||
Patch1032: gdb-probes-based-interface-robust-2of2.patch
|
||||
|
||||
# Fix the pahole command breakage due to its Python3 port (RH BZ 1264532).
|
||||
Patch1044: gdb-pahole-python3fix.patch
|
||||
|
||||
# Fix internal error on DW_OP_bregx(-1) (RH BZ 1270564).
|
||||
Patch1052: gdb-rhbz1270564-invalid-dwarf-regno.patch
|
||||
|
||||
%if 0%{!?rhel:1} || 0%{?rhel} > 6
|
||||
# RL_STATE_FEDORA_GDB would not be found for:
|
||||
# Patch642: gdb-readline62-ask-more-rh.patch
|
||||
|
@ -826,6 +843,12 @@ find -name "*.info*"|xargs rm -f
|
|||
%patch982 -p1
|
||||
%patch984 -p1
|
||||
%patch985 -p1
|
||||
%patch991 -p1
|
||||
%patch992 -p1
|
||||
%patch1031 -p1
|
||||
%patch1032 -p1
|
||||
%patch1044 -p1
|
||||
%patch1052 -p1
|
||||
|
||||
%patch848 -p1
|
||||
%if 0%{!?el6:1}
|
||||
|
@ -1326,6 +1349,25 @@ then
|
|||
fi
|
||||
|
||||
%changelog
|
||||
* Mon Oct 12 2015 Jan Kratochvil <jan.kratochvil@redhat.com> - 7.9.1-20.fc22
|
||||
- Fix internal error on DW_OP_bregx(-1) (RH BZ 1270564).
|
||||
|
||||
* Fri Sep 18 2015 Jan Kratochvil <jan.kratochvil@redhat.com> - 7.9.1-19.fc22
|
||||
- Fix the pahole command breakage due to its Python3 port (RH BZ 1264532).
|
||||
|
||||
* Wed Sep 2 2015 Sergio Durigan Junior <sergiodj@redhat.com> - 7.9.1-18.fc22
|
||||
- Fix 'Make the probes-based dynamic linker interface more robust to
|
||||
errors' (Sergio Durigan Junior, RH BZ 1259132).
|
||||
|
||||
* Fri Jun 26 2015 Jan Kratochvil <jan.kratochvil@redhat.com> - 7.9.1-17.fc22
|
||||
- Fix 'info type-printers' Python error (Clem Dickey, RH BZ 1085576).
|
||||
|
||||
* Fri Jun 19 2015 Jan Kratochvil <jan.kratochvil@redhat.com> - 7.9.1-16.fc22
|
||||
- Backport 'thread apply all' option '-ascending' for ABRT.
|
||||
|
||||
* Tue Jun 16 2015 Jan Kratochvil <jan.kratochvil@redhat.com> - 7.9.1-15.fc22
|
||||
- Fix enum e e 'Attempt to use a type name as an expr.' (Keith Seitz, PR 16253).
|
||||
|
||||
* Fri May 15 2015 Jan Kratochvil <jan.kratochvil@redhat.com> - 7.9.1-14.fc22
|
||||
- Fix ignored Requires for gdb-doc (RH BZ 1221814).
|
||||
|
||||
|
|
Loading…
Reference in New Issue