From: Nir Lichtman Subject: Fix broken count argument in DDB's break command To: tech@openbsd.org Date: Wed, 9 Oct 2024 21:15:26 +0000 Problem: Currently, passing a number higher than 1 as the count to the break command does not affect the breakpoint behavior (breaks as if the count is still 1). This behavior is in contradiction with the DDB man page which documents the count argument as a way to silently break count times before actually hitting the breakpoint. Solution: Fix the break command to skip actually breaking, unless the count is suitable. Also fix the initialization of the count to handle all negative values as a count of 1 =============================== diff --git sys/ddb/db_break.c sys/ddb/db_break.c index bf5253d1d..43448ecf3 100644 --- sys/ddb/db_break.c +++ sys/ddb/db_break.c @@ -248,7 +248,7 @@ db_delete_cmd(db_expr_t addr, int have_addr, db_expr_t count, char *modif) void db_breakpoint_cmd(db_expr_t addr, int have_addr, db_expr_t count, char *modif) { - if (count == -1) + if (count < 1) count = 1; db_set_breakpoint((vaddr_t)addr, count); diff --git sys/ddb/db_run.c sys/ddb/db_run.c index b34a8a065..ce4e1ce09 100644 --- sys/ddb/db_run.c +++ sys/ddb/db_run.c @@ -98,6 +98,8 @@ db_stop_at_pc(db_regs_t *regs, int *is_breakpoint) bkpt->count = bkpt->init_count; *is_breakpoint = 1; return 1; /* stop here */ + } else { + return 0; } } else if (*is_breakpoint #ifdef SOFTWARE_SSTEP