From 58ce7251e876ad5b6569e3ee72dfe6c4c5697ca8 Mon Sep 17 00:00:00 2001 From: Sergio Durigan Junior Date: Tue, 7 May 2013 17:04:29 +0000 Subject: [PATCH] gdb/ 2013-05-07 Sergio Durigan Junior 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 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. --- gdb/ChangeLog | 7 +++++++ gdb/breakpoint.c | 25 ++++++------------------- gdb/testsuite/ChangeLog | 8 ++++++++ gdb/testsuite/gdb.base/pending.exp | 3 +++ gdb/testsuite/gdb.linespec/linespec.exp | 4 ++++ 5 files changed, 28 insertions(+), 19 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 40ceae66d7..2506ce5c5a 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,10 @@ +2013-05-07 Sergio Durigan Junior + + PR breakpoints/15413: + * breakpoint.c (condition_completer): Simplify the code to + disconsider multiple locations of breakpoints when completing the + "condition" command. + 2013-05-07 Pierre Muller * common/linux-btrace.c: ARI fix: Include "gdb_wait.h" diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index ef9c23c464..f4f9325ab6 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; + { + char number[50]; - for (loc = b->loc; loc; loc = loc->next) - { - char location[50]; + xsnprintf (number, sizeof (number), "%d", b->number); - if (single) - xsnprintf (location, sizeof (location), "%d", b->number); - else - xsnprintf (location, sizeof (location), "%d.%d", b->number, - count); - - if (strncmp (location, text, len) == 0) - VEC_safe_push (char_ptr, result, xstrdup (location)); - - ++count; - } - } + if (strncmp (number, text, len) == 0) + VEC_safe_push (char_ptr, result, xstrdup (number)); + } return result; } diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index a33d6d0cf6..333bf1c042 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,11 @@ +2013-05-07 Sergio Durigan Junior + + 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. + 2013-05-07 Luis Machado * gdb.threads/wp-replication.c: New file. diff --git a/gdb/testsuite/gdb.base/pending.exp b/gdb/testsuite/gdb.base/pending.exp index 68322f59e4..1ab896abb0 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 741ada0f94..fe023656aa 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"