[binutils-gdb] Fix type of DAP hitCondition

Tom Tromey tromey@sourceware.org
Thu Jun 22 15:51:42 GMT 2023


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=32594d975aa9d886face03ee146fe82aa34a3145

commit 32594d975aa9d886face03ee146fe82aa34a3145
Author: Tom Tromey <tromey@adacore.com>
Date:   Wed May 24 14:24:13 2023 -0600

    Fix type of DAP hitCondition
    
    DAP specifies a breakpoint's hitCondition as a string, meaning it is
    an expression to be evaluated.  However, gdb implemented this as if it
    were an integer instead.  This patch fixes this oversight.

Diff:
---
 gdb/python/lib/gdb/dap/breakpoint.py | 11 +++++++----
 gdb/testsuite/gdb.dap/cond-bp.exp    |  2 +-
 2 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/gdb/python/lib/gdb/dap/breakpoint.py b/gdb/python/lib/gdb/dap/breakpoint.py
index 20e65aa0e61..2cb8db68907 100644
--- a/gdb/python/lib/gdb/dap/breakpoint.py
+++ b/gdb/python/lib/gdb/dap/breakpoint.py
@@ -95,10 +95,13 @@ def _set_breakpoints_callback(kind, specs, creator):
             # FIXME handle exceptions here
             bp = creator(**spec)
 
-        if condition is not None:
-            bp.condition = condition
-        if hit_condition is not None:
-            bp.ignore_count = hit_condition
+        bp.condition = condition
+        if hit_condition is None:
+            bp.ignore_count = 0
+        else:
+            bp.ignore_count = int(
+                gdb.parse_and_eval(hit_condition, global_context=True)
+            )
 
         breakpoint_map[kind][keyspec] = bp
         result.append(breakpoint_descriptor(bp))
diff --git a/gdb/testsuite/gdb.dap/cond-bp.exp b/gdb/testsuite/gdb.dap/cond-bp.exp
index 376db4b3548..6369b6f579c 100644
--- a/gdb/testsuite/gdb.dap/cond-bp.exp
+++ b/gdb/testsuite/gdb.dap/cond-bp.exp
@@ -35,7 +35,7 @@ set obj [dap_check_request_and_response "set conditional breakpoint" \
 	     [format {o source [o path [%s]] \
 			  breakpoints [a [o line [i %d] \
 					      condition [s "i == 3"] \
-					      hitCondition [i 3]]]} \
+					      hitCondition [s 3]]]} \
 		  [list s $srcfile] $line]]
 set fn_bpno [dap_get_breakpoint_number $obj]


More information about the Gdb-cvs mailing list