From b643095d1ff824c6848191d11cd70bebb7c60d6d Mon Sep 17 00:00:00 2001 From: vdf-git <36852239+vdf-git@users.noreply.github.com> Date: Tue, 19 Jun 2018 15:34:10 +0200 Subject: [PATCH] Fixed breakpoint infinete loop error (#10410) --- libr/debug/debug.c | 34 ++++++++++++++++++++++++++++++++++ libr/include/r_debug.h | 3 +++ 2 files changed, 37 insertions(+) diff --git a/libr/debug/debug.c b/libr/debug/debug.c index 5efe5c5016..f6a12adf26 100644 --- a/libr/debug/debug.c +++ b/libr/debug/debug.c @@ -93,6 +93,40 @@ static int r_debug_bp_hit(RDebug *dbg, RRegItem *pc_ri, ut64 pc, RBreakpointItem # else int pc_off = dbg->bpsize; /* see if we really have a breakpoint here... */ + if (!dbg->pc_at_bp_set) { + b = r_bp_get_at (dbg->bp, pc - dbg->bpsize); + if (!b) { /* we don't. nothing left to do */ + /* Some targets set pc to breakpoint */ + b = r_bp_get_at (dbg->bp, pc); + if (!b) { + /* Couldn't find the break point. Nothing more to do... */ + return true; + } + else { + dbg->pc_at_bp_set = true; + dbg->pc_at_bp = true; + } + } else { + dbg->pc_at_bp_set = true; + dbg->pc_at_bp = false; + } + } + + if (!dbg->pc_at_bp_set) { + eprintf ("failed to determine position of pc after breakpoint"); + } + + if (dbg->pc_at_bp) { + pc_off = 0; + b = r_bp_get_at (dbg->bp, pc); + } else { + b = r_bp_get_at (dbg->bp, pc - dbg->bpsize); + } + + if (!b) { + return true; + } + b = r_bp_get_at (dbg->bp, pc - dbg->bpsize); if (!b) { /* we don't. nothing left to do */ /* Some targets set pc to breakpoint */ diff --git a/libr/include/r_debug.h b/libr/include/r_debug.h index 2e8231c36d..b4e0f5a3bc 100644 --- a/libr/include/r_debug.h +++ b/libr/include/r_debug.h @@ -298,6 +298,9 @@ typedef struct r_debug_t { struct r_debug_plugin_t *h; RList *plugins; + bool pc_at_bp; /* after a breakpoint, is the pc at the bp? */ + bool pc_at_bp_set; /* is the pc_at_bp variable set already? */ + RAnal *anal; RList *maps; // RList *maps_user; //