This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [Patch] Cannot set pending bp if condition set explicitly
- From: Pedro Alves <palves at redhat dot com>
- To: "'gdb-patches at sourceware dot org'" <gdb-patches at sourceware dot org>
- Cc: Marc Khouzam <marc dot khouzam at ericsson dot com>, "'Tom Tromey'" <tromey at redhat dot com>
- Date: Fri, 03 Aug 2012 01:51:29 +0100
- Subject: Re: [Patch] Cannot set pending bp if condition set explicitly
- References: <F7CE05678329534C957159168FA70DEC5C24CAEA18@EUSAACMS0703.eamcs.ericsson.se> <87zk6nkghi.fsf@fleche.redhat.com> <F7CE05678329534C957159168FA70DEC5C2500353F@EUSAACMS0703.eamcs.ericsson.se> <501194E0.5040109@redhat.com>
On 07/26/2012 08:05 PM, Pedro Alves wrote:
> Not sure yet what is the best predicate to put there.
> The whole condition looks a bit in need of TLC. all_locations_are_pending would
> return true if all locations had been shlib_disabled. The condition does
> also check for shlib_disabled, but only on the first location. Especially now
> that breakpoints can have locations anywhere, I think we might need to consider
> what happens and what should happen to when only a few of the conditions
> are shlib_disabled..
>
> WDYT? I'll try to give this predicate a bit more thought (but I'm running
> out of day for today), but these are my thoughts so far.
I left the condition as is for now. A pending breakpoint has no locations, and when
a shared library is unloaded, the locations remain (though disabled), so I think
this should be equivalent to the original intention. So essentially, this is the
same patch as before, now with ChangeLog and with your test.
2012-08-02 Pedro Alves <palves@redhat.com>
Marc Khouzam <marc.khouzam@ericsson.com>
* breakpoint.c (create_breakpoint): Only set condition_not_parsed
if PARSE_CONDITION_AND_THREAD is true.
(addr_string_to_sals): Consider NOT_FOUND_ERROR okay when there
are no locations yet, instead of when CONDITION_NOT_PARSED is
true.
2012-08-02 Marc Khouzam <marc.khouzam@ericsson.com>
* gdb.base/pendshr.c: Extra line to set a new breakpoint.
* gdb.base/pending.exp: Set an enabled pending breakpoint
with an explicit condition.
---
gdb/testsuite/gdb.base/pending.exp | 57 ++++++++++++++++++++++++++++++------
gdb/testsuite/gdb.base/pendshr.c | 1 +
2 files changed, 49 insertions(+), 9 deletions(-)
diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index b8484a7..605dee2 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -9591,7 +9591,10 @@ create_breakpoint (struct gdbarch *gdbarch,
b->addr_string = copy_arg;
if (parse_condition_and_thread)
- b->cond_string = NULL;
+ {
+ b->cond_string = NULL;
+ b->condition_not_parsed = 1;
+ }
else
{
/* Create a private copy of condition string. */
@@ -9605,7 +9608,6 @@ create_breakpoint (struct gdbarch *gdbarch,
b->extra_string = NULL;
b->ignore_count = ignore_count;
b->disposition = tempflag ? disp_del : disp_donttouch;
- b->condition_not_parsed = 1;
b->enable_state = enabled ? bp_enabled : bp_disabled;
if ((type_wanted != bp_breakpoint
&& type_wanted != bp_hardware_breakpoint) || thread != -1)
@@ -14041,7 +14043,7 @@ addr_string_to_sals (struct breakpoint *b, char *addr_string, int *found)
breakpoint being disabled, and don't want to see more
errors. */
if (e.error == NOT_FOUND_ERROR
- && (b->condition_not_parsed
+ && (b->loc == NULL
|| (b->loc && b->loc->shlib_disabled)
|| (b->loc && b->loc->pspace->executing_startup)
|| b->enable_state == bp_disabled))
diff --git a/gdb/testsuite/gdb.base/pending.exp b/gdb/testsuite/gdb.base/pending.exp
index 79c4576..910c917 100644
--- a/gdb/testsuite/gdb.base/pending.exp
+++ b/gdb/testsuite/gdb.base/pending.exp
@@ -209,6 +209,32 @@ gdb_test "info break" \
"multiple pending breakpoints 2"
#
+# Try a pending break with an explicit condition which is enabled at startup
+#
+
+set bp5_loc [gdb_get_line_number "y++" ${libfile}.c]
+gdb_test_multiple "break pendshr.c:$bp5_loc" "Set pending breakpoint 4" {
+ -re ".*Make breakpoint pending.*y or \\\[n\\\]. $" {
+ gdb_test "y" "Breakpoint.*pendshr.c:$bp5_loc.*pending." \
+ "Set pending breakpoint 5"
+ }
+}
+
+gdb_test_no_output "condition 5 k == 1"
+
+gdb_test "info break" \
+ "Num Type\[ \]+Disp Enb Address\[ \]+What.*
+\[0-9\]+\[\t \]+breakpoint keep n.*PENDING.*pendfunc1.*
+\[\t \]+stop only if k == 1.*
+\[\t \]+print k.*
+\[0-9\]+\[\t \]+breakpoint keep y.* in main at .*$srcfile:$mainline.*
+\[0-9\]+\[\t \]+breakpoint keep y.*PENDING.*pendshr.c:$bp2_loc if x > 3.*
+\[0-9\]+\[\t \]+breakpoint keep y.*PENDING.*pendshr.c:$bp3_loc.*ignore next 2 hits.*
+\[0-9\]+\[\t \]+breakpoint keep y.*PENDING.*pendshr.c:$bp5_loc.*
+\[\t \]+stop only if k == 1.*" \
+"multiple pending breakpoints 3"
+
+#
# Run to main which should resolve a pending breakpoint
#
@@ -218,6 +244,24 @@ gdb_test "" \
"running to main"
#
+# Verify that all pending breakpoints have resolved.
+#
+gdb_test "info break" \
+ "Num Type\[ \]+Disp Enb Address\[ \]+What.*
+\[0-9\]+\[\t \]+breakpoint keep n.* in pendfunc1 at .*
+\[\t \]+stop only if k == 1.*
+\[\t \]+print k.*
+\[0-9\]+\[\t \]+breakpoint keep y.* in main at .*$srcfile:$mainline.*
+\[\t \]+breakpoint already hit 1 time.*
+\[0-9\]+\[\t \]+breakpoint keep y.* in pendfunc1 at .*pendshr.c:$bp2_loc.*
+\[\t \]+stop only if x > 3.*
+\[0-9\]+\[\t \]+breakpoint keep y.* in pendfunc1 at .*pendshr.c:$bp3_loc.*
+\[\t \]+ignore next 2 hits.*
+\[0-9\]+\[\t \]+breakpoint keep y.* in pendfunc1 at .*pendshr.c:$bp5_loc.*
+\[\t \]+stop only if k == 1.*" \
+"multiple pending breakpoints 4"
+
+#
# Re-enable the first pending breakpoint which should resolve
#
@@ -237,19 +281,14 @@ gdb_test "continue" \
\[$\]1 = 1." \
"continue to resolved breakpoint 1"
-#
-# Disable the other two breakpoints, and continue to the one with
-# the ignore count. Make sure you hit it the third time, x should
-# be 3 then.
-#
-
-gdb_test "disable 7" "" "Disable other breakpoints"
-gdb_test "disable 5" "" "Disable other breakpoints"
-
gdb_test "continue" \
".*Breakpoint.*pendfunc1.*\\\(x=3\\\) at.*pendshr.c:$bp3_loc.*printf.*;" \
"continue to resolved breakpoint 3"
+gdb_test "continue" \
+ ".*Breakpoint.*pendfunc1.*\\\(x=3\\\) at.*pendshr.c:$bp5_loc.*y\\+\\+;" \
+"continue to resolved breakpoint 5"
+
delete_breakpoints
gdb_breakpoint "main"
diff --git a/gdb/testsuite/gdb.base/pendshr.c b/gdb/testsuite/gdb.base/pendshr.c
index bc3b9e3..c5b40fd 100644
--- a/gdb/testsuite/gdb.base/pendshr.c
+++ b/gdb/testsuite/gdb.base/pendshr.c
@@ -21,6 +21,7 @@ void pendfunc1 (int x)
{
int y = x + 4;
printf ("in pendfunc1, x is %d\n", x);
+ y++;
}
void pendfunc (int x)