This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH] Fix for PR 15413 (segfault when completing "condition" for pending bp)
- From: Sergio Durigan Junior <sergiodj at redhat dot com>
- To: Pedro Alves <palves at redhat dot com>
- Cc: GDB Patches <gdb-patches at sourceware dot org>, "Dr. David Alan Gilbert" <dave at treblig dot org>
- Date: Tue, 07 May 2013 14:06:18 -0300
- Subject: Re: [PATCH] Fix for PR 15413 (segfault when completing "condition" for pending bp)
- References: <m3sj20stjh dot fsf at redhat dot com> <5187ED3A dot 8000108 at redhat dot com> <m3li7rsu6m dot fsf at redhat dot com> <51881BCD dot 7070009 at redhat dot com> <m3li7rqwzt dot fsf at redhat dot com> <518928F2 dot 4080507 at redhat dot com>
On Tuesday, May 07 2013, Pedro Alves wrote:
>> +# Complete the condition (PR 15413).
>> +# This test must come right after we set the first pending breakpoint, and
>> +# before we set any other breakpoint, since we are testing if the "condition"
>> +# command can properly complete its argument. The PR only fails if there
>> +# is only one pending breakpoint set (without anything else).
>
> This last sentence isn't right. You only need a pending breakpoint to
> trigger the crash, it doesn't matter how many breakpoints you have.
Fixed, thanks.
>> +gdb_test "complete condition " "condition 1"
>
> OK with these fixed, mainline and 7.6.
This is what I committed.
http://sourceware.org/ml/gdb-cvs/2013-05/msg00062.html
http://sourceware.org/ml/gdb-cvs/2013-05/msg00063.html
Thanks,
--
Sergio
gdb/
2013-05-07 Sergio Durigan Junior <sergiodj@redhat.com>
PR breakpoints/15413:
* breakpoint.c (condition_completer): Simplify the code to
disconsider multiple locations of breakpoints when completing the
"condition" command.
gdb/testsuite
2013-05-07 Sergio Durigan Junior <sergiodj@redhat.com>
PR breakpoints/15413:
* gdb.base/pending.exp: Add test for completion of the "condition"
command for pending breakpoints.
* gdb.linespec/linespec.ex: Add test for completion of the
"condition" command when dealing with multiple locations.
diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index ef9c23c..f4f9325 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -1012,27 +1012,14 @@ condition_completer (struct cmd_list_element *cmd,
len = strlen (text);
ALL_BREAKPOINTS (b)
- {
- int single = b->loc->next == NULL;
- struct bp_location *loc;
- int count = 1;
-
- for (loc = b->loc; loc; loc = loc->next)
- {
- char location[50];
-
- if (single)
- xsnprintf (location, sizeof (location), "%d", b->number);
- else
- xsnprintf (location, sizeof (location), "%d.%d", b->number,
- count);
+ {
+ char number[50];
- if (strncmp (location, text, len) == 0)
- VEC_safe_push (char_ptr, result, xstrdup (location));
+ xsnprintf (number, sizeof (number), "%d", b->number);
- ++count;
- }
- }
+ if (strncmp (number, text, len) == 0)
+ VEC_safe_push (char_ptr, result, xstrdup (number));
+ }
return result;
}
diff --git a/gdb/testsuite/gdb.base/pending.exp b/gdb/testsuite/gdb.base/pending.exp
index 68322f5..1ab896a 100644
--- a/gdb/testsuite/gdb.base/pending.exp
+++ b/gdb/testsuite/gdb.base/pending.exp
@@ -55,6 +55,9 @@ gdb_test_multiple "break pendfunc1" "set pending breakpoint" {
}
}
+# Complete the condition (PR 15413).
+gdb_test "complete condition " "condition 1"
+
gdb_test "info break" \
"Num Type\[ \]+Disp Enb Address\[ \]+What.*
\[0-9\]+\[\t \]+breakpoint keep y.*PENDING.*pendfunc1.*" \
diff --git a/gdb/testsuite/gdb.linespec/linespec.exp b/gdb/testsuite/gdb.linespec/linespec.exp
index 741ada0..fe02365 100644
--- a/gdb/testsuite/gdb.linespec/linespec.exp
+++ b/gdb/testsuite/gdb.linespec/linespec.exp
@@ -69,6 +69,10 @@ gdb_test "break dupname:label" \
"Breakpoint $decimal at $hex: dupname:label. \[(\]2 locations\[)\]" \
"multi-location break using duplicate function name and label"
+# Testing if the "condition" command completes only the breakpoints,
+# not the locations.
+gdb_test "complete condition " "condition $decimal\r\ncondition $decimal\r\ncondition $decimal"
+
gdb_test_no_output "set breakpoint pending off" \
"disable pending breakpoints for linespec tests"