From: Tom Tromey <tromey@redhat.com>
To: Jan Kratochvil <jan.kratochvil@redhat.com>
Cc: Joel Brobecker <brobecker@adacore.com>, gdb-patches@sourceware.org
Subject: Re: Crash regression for gdb.base/ending-run.exp [Re: creating the gdb-7.4 branch tomorrow (?)]
Date: Fri, 09 Dec 2011 19:05:00 -0000 [thread overview]
Message-ID: <m38vmlfv2g.fsf@fleche.redhat.com> (raw)
In-Reply-To: <20111209164653.GA22642@host2.jankratochvil.net> (Jan Kratochvil's message of "Fri, 9 Dec 2011 17:46:53 +0100")
>>>>> "Jan" == Jan Kratochvil <jan.kratochvil@redhat.com> writes:
Jan> Regression on Fedoras, such as F-15 x86_64 using .debug_types:
Jan> DEJAGNU=$HOME/src/runtest-valgrind/site.exp runtest CC_FOR_TARGET="gcc -gdwarf-4 -fdebug-types-section -g0" CXX_FOR_TARGET="g++ -gdwarf-4 -fdebug-types-section -g0" --target_board valgrind gdb.base/ending-run.exp
Thanks.
I'm checking in the appended.
The bug was that a given breakpoint could end up on the 'found' list
more than once. My fix is to remove duplicates from the list.
Also I noticed that the VEC created in clear_command was never freed.
This patch fixes that as well.
Built and regtested on x86-64 F15. I also ran the test above before and
after the patch.
Tom
2011-12-09 Tom Tromey <tromey@redhat.com>
* breakpoint.c (compare_breakpoints): New function.
(clear_command): Remove duplicate breakpoints. Properly clean
up.
diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index d9d5bbe..6f4f2d6 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -10028,18 +10028,41 @@ tcatch_command (char *arg, int from_tty)
error (_("Catch requires an event name."));
}
+/* A qsort comparison function that sorts breakpoints in order. */
+
+static int
+compare_breakpoints (const void *a, const void *b)
+{
+ const breakpoint_p *ba = a;
+ uintptr_t ua = (uintptr_t) *ba;
+ const breakpoint_p *bb = b;
+ uintptr_t ub = (uintptr_t) *bb;
+
+ if ((*ba)->number < (*bb)->number)
+ return -1;
+ else if ((*ba)->number > (*bb)->number)
+ return 1;
+
+ /* Now sort by address, in case we see, e..g, two breakpoints with
+ the number 0. */
+ if (ua < ub)
+ return -1;
+ return ub > ub ? 1 : 0;
+}
+
/* Delete breakpoints by address or line. */
static void
clear_command (char *arg, int from_tty)
{
- struct breakpoint *b;
+ struct breakpoint *b, *prev;
VEC(breakpoint_p) *found = 0;
int ix;
int default_match;
struct symtabs_and_lines sals;
struct symtab_and_line sal;
int i;
+ struct cleanup *cleanups = make_cleanup (null_cleanup, NULL);
if (arg)
{
@@ -10090,6 +10113,7 @@ clear_command (char *arg, int from_tty)
breakpoint. */
found = NULL;
+ make_cleanup (VEC_cleanup (breakpoint_p), &found);
for (i = 0; i < sals.nelts; i++)
{
/* If exact pc given, clear bpts at that pc.
@@ -10143,6 +10167,7 @@ clear_command (char *arg, int from_tty)
VEC_safe_push(breakpoint_p, found, b);
}
}
+
/* Now go thru the 'found' chain and delete them. */
if (VEC_empty(breakpoint_p, found))
{
@@ -10152,6 +10177,21 @@ clear_command (char *arg, int from_tty)
error (_("No breakpoint at this line."));
}
+ /* Remove duplicates from the vec. */
+ qsort (VEC_address (breakpoint_p, found),
+ VEC_length (breakpoint_p, found),
+ sizeof (breakpoint_p),
+ compare_breakpoints);
+ prev = VEC_index (breakpoint_p, found, 0);
+ for (ix = 1; VEC_iterate (breakpoint_p, found, ix, b); ++ix)
+ {
+ if (b == prev)
+ {
+ VEC_ordered_remove (breakpoint_p, found, ix);
+ --ix;
+ }
+ }
+
if (VEC_length(breakpoint_p, found) > 1)
from_tty = 1; /* Always report if deleted more than one. */
if (from_tty)
@@ -10171,6 +10211,8 @@ clear_command (char *arg, int from_tty)
}
if (from_tty)
putchar_unfiltered ('\n');
+
+ do_cleanups (cleanups);
}
\f
/* Delete breakpoint in BS if they are `delete' breakpoints and
next prev parent reply other threads:[~2011-12-09 18:40 UTC|newest]
Thread overview: 49+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-12-05 8:19 creating the gdb-7.4 branch tomorrow (?) Joel Brobecker
2011-12-06 18:45 ` Tom Tromey
2011-12-06 18:53 ` Tom Tromey
2011-12-06 18:54 ` Tom Tromey
2011-12-06 19:05 ` Tom Tromey
2011-12-06 19:05 ` Tom Tromey
2011-12-06 19:07 ` Tom Tromey
2011-12-06 19:10 ` Tom Tromey
2011-12-07 4:09 ` Hui Zhu
2011-12-07 9:54 ` Joel Brobecker
2011-12-07 16:24 ` Stan Shebs
2011-12-07 23:50 ` Stan Shebs
2011-12-08 8:22 ` Joel Brobecker
2011-12-07 9:11 ` Jan Kratochvil
2011-12-07 10:01 ` Joel Brobecker
2011-12-08 15:33 ` FYI: fixlet in ovsrch.exp (Was: creating the gdb-7.4 branch tomorrow (?)) Tom Tromey
2011-12-09 17:17 ` Regression for gdb.base/sigstep.exp with .debug_types [Re: creating the gdb-7.4 branch tomorrow (?)] Jan Kratochvil
2011-12-09 17:26 ` Regression for gdb.base/sigstep.exp with .debug_types Jan Kratochvil
2011-12-09 20:50 ` Tom Tromey
2011-12-09 21:55 ` Jan Kratochvil
2011-12-10 9:46 ` Tom Tromey
2011-12-10 19:27 ` [commit] testsuite: KFAIL gdb.cp/static-method.exp [Re: Regression for gdb.base/sigstep.exp with .debug_types] Jan Kratochvil
2011-12-11 9:26 ` Joel Brobecker
2011-12-11 12:42 ` Jan Kratochvil
2011-12-11 12:46 ` Joel Brobecker
2011-12-14 19:02 ` [patch] gcc KFAILs to XFAILs [Re: [commit] testsuite: KFAIL gdb.cp/static-method.exp] Jan Kratochvil
2011-12-14 19:43 ` Doug Evans
2011-12-14 19:51 ` [doc patch] gdbint: XFAIL vs. KFAIL [Re: [patch] gcc KFAILs to XFAILs] Jan Kratochvil
2011-12-15 5:33 ` Eli Zaretskii
2011-12-19 11:16 ` Jan Kratochvil
2011-12-19 13:41 ` Eli Zaretskii
2011-12-19 13:42 ` [commit] " Jan Kratochvil
2011-12-19 13:43 ` [commit] [patch] gcc KFAILs to XFAILs [Re: [commit] testsuite: KFAIL gdb.cp/static-method.exp] Jan Kratochvil
2011-12-09 20:17 ` Regression for gdb.base/sigstep.exp with .debug_types [Re: creating the gdb-7.4 branch tomorrow (?)] Tom Tromey
2011-12-09 20:20 ` Jan Kratochvil
2011-12-09 17:17 ` Crash regression for gdb.base/ending-run.exp " Jan Kratochvil
2011-12-09 19:05 ` Tom Tromey [this message]
2011-12-09 21:00 ` Jan Kratochvil
2011-12-14 11:52 ` creating the gdb-7.4 branch tomorrow (?) Andreas Schwab
2011-12-14 13:20 ` Joel Brobecker
2011-12-14 13:34 ` Andreas Schwab
2011-12-14 19:28 ` Joel Brobecker
2011-12-14 21:16 ` Andreas Schwab
2011-12-14 21:31 ` Joel Brobecker
2011-12-14 22:06 ` Andreas Schwab
2011-12-15 17:43 ` Tom Tromey
2012-07-22 19:41 ` Andreas Schwab
2012-08-15 19:34 ` Tom Tromey
2012-08-22 14:23 ` Tom Tromey
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=m38vmlfv2g.fsf@fleche.redhat.com \
--to=tromey@redhat.com \
--cc=brobecker@adacore.com \
--cc=gdb-patches@sourceware.org \
--cc=jan.kratochvil@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).