Fix type of DAP hitCondition
authorTom Tromey <tromey@adacore.com>
Wed, 24 May 2023 20:24:13 +0000 (14:24 -0600)
committerTom Tromey <tromey@adacore.com>
Thu, 22 Jun 2023 15:46:23 +0000 (09:46 -0600)
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.

gdb/python/lib/gdb/dap/breakpoint.py
gdb/testsuite/gdb.dap/cond-bp.exp

index 20e65aa0e61825e9f5e48b77479e807ce22d130b..2cb8db689071c00d83d6a8d77183cda6e38a3364 100644 (file)
@@ -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))
index 376db4b3548259043492d7b27f007a679aff4e0b..6369b6f579c275366ce77d57a62d47d1821517a4 100644 (file)
@@ -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]