From 1d52c7a3dd93555637bd95caf6c43905e4e1f8fe Mon Sep 17 00:00:00 2001 From: "Yukihiro \"Matz\" Matsumoto" Date: Tue, 24 Feb 2026 09:03:28 +0900 Subject: [PATCH] mrdb.c: extract check_breakpoint_hit() from mrb_code_fetch_hook() Combine method and line breakpoint checks into a single check_breakpoint_hit() helper, simplifying the DBG_RUN case. Co-authored-by: Claude --- mrbgems/mruby-bin-debugger/tools/mrdb/mrdb.c | 27 +++++++++++++------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/mrbgems/mruby-bin-debugger/tools/mrdb/mrdb.c b/mrbgems/mruby-bin-debugger/tools/mrdb/mrdb.c index 9e9281d92..42fa2fa62 100644 --- a/mrbgems/mruby-bin-debugger/tools/mrdb/mrdb.c +++ b/mrbgems/mruby-bin-debugger/tools/mrdb/mrdb.c @@ -559,6 +559,22 @@ check_method_breakpoint(mrb_state *mrb, const mrb_irep *irep, const mrb_code *pc return bpno; } +static int32_t +check_breakpoint_hit(mrb_state *mrb, mrb_debug_context *dbg, + const mrb_irep *irep, const mrb_code *pc, + const char *file, int32_t line, mrb_value *regs) +{ + int32_t bpno; + + bpno = check_method_breakpoint(mrb, irep, pc, regs); + if (bpno > 0) return bpno; + if (dbg->prvfile != file || dbg->prvline != line) { + bpno = mrb_debug_check_breakpoint_line(mrb, dbg, file, line); + if (bpno > 0) return bpno; + } + return 0; +} + static void mrb_code_fetch_hook(mrb_state *mrb, const mrb_irep *irep, const mrb_code *pc, mrb_value *regs) { @@ -608,23 +624,16 @@ mrb_code_fetch_hook(mrb_state *mrb, const mrb_irep *irep, const mrb_code *pc, mr break; case DBG_RUN: - bpno = check_method_breakpoint(mrb, irep, pc, regs); + bpno = check_breakpoint_hit(mrb, dbg, irep, pc, file, line, regs); if (bpno > 0) { dbg->stopped_bpno = bpno; dbg->bm = BRK_BREAK; break; } - if (dbg->prvfile != file || dbg->prvline != line) { - bpno = mrb_debug_check_breakpoint_line(mrb, dbg, file, line); - if (bpno > 0) { - dbg->stopped_bpno = bpno; - dbg->bm = BRK_BREAK; - break; - } - } dbg->prvfile = file; dbg->prvline = line; return; + case DBG_INIT: dbg->root_irep = irep; dbg->bm = BRK_INIT;