From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1726) id F0B3D384188B; Thu, 6 Oct 2022 09:37:46 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org F0B3D384188B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1665049066; bh=cmJmfWIHd8/a6uGUL8ZuwfwFAQ0PiiZp9ebgH36Jx3A=; h=From:To:Subject:Date:From; b=bxCtbmG/QQSLjEVq0m6ojuwiXL80jX+hD9Cn1ftRYGkqS3igrEkOB611qePD+5Djk rmHlKjuTZFrU7tzWc1GpnMWBRNpxC2ajaUHmmIKgzNlMUVTLJb341m+9TUirx3LI9R YGCpM1cKDmcjFNJ1EobynilovDCoc4RO9enV90UM= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Andrew Burgess To: gdb-cvs@sourceware.org Subject: [binutils-gdb] gdb: more infrun debug from breakpoint.c X-Act-Checkin: binutils-gdb X-Git-Author: Andrew Burgess X-Git-Refname: refs/heads/master X-Git-Oldrev: 07443de62b709f91ab9ffe745e53203b7dc02031 X-Git-Newrev: d8a77e4c8043c645c3c7a07a042c112053715e95 Message-Id: <20221006093746.F0B3D384188B@sourceware.org> Date: Thu, 6 Oct 2022 09:37:46 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3Dd8a77e4c8043= c645c3c7a07a042c112053715e95 commit d8a77e4c8043c645c3c7a07a042c112053715e95 Author: Andrew Burgess Date: Tue Oct 4 13:51:46 2022 +0100 gdb: more infrun debug from breakpoint.c =20 This commit adds additional infrun debug from the breakpoint.c file. The new debug output all relates to breakpoint condition evaluation. =20 There is already some infrun debug emitted from the breakpoint.c file, so hopefully, adding more will not be contentious. I think the functions being instrumented make sense as part of the infrun process, the inferior stops, evaluates the condition, and then either stops or continues. This new debug gives more insight into that process. =20 I had to make the bp_location* argument to find_loc_num_by_location const, and add a declaration for find_loc_num_by_location. =20 There should be no user visible changes unless they turn on debug output. Diff: --- gdb/breakpoint.c | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index c8c34120aa0..29a02945234 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -161,6 +161,8 @@ static std::vector bkpt_probe_decode_l= ocation_spec =20 static bool bl_address_is_meaningful (bp_location *loc); =20 +static int find_loc_num_by_location (const bp_location *loc); + /* update_global_location_list's modes of operation wrt to whether to insert locations now. */ enum ugll_insert_mode @@ -5298,6 +5300,8 @@ bpstat_check_watchpoint (bpstat *bs) static void bpstat_check_breakpoint_conditions (bpstat *bs, thread_info *thread) { + INFRUN_SCOPED_DEBUG_ENTER_EXIT; + const struct bp_location *bl; struct breakpoint *b; /* Assume stop. */ @@ -5312,6 +5316,10 @@ bpstat_check_breakpoint_conditions (bpstat *bs, thre= ad_info *thread) b =3D bs->breakpoint_at; gdb_assert (b !=3D NULL); =20 + infrun_debug_printf ("thread =3D %s, breakpoint %d.%d", + thread->ptid.to_string ().c_str (), + b->number, find_loc_num_by_location (bl)); + /* Even if the target evaluated the condition on its end and notified GD= B, we need to do so again since GDB does not know if we stopped due to a breakpoint or a single step breakpoint. */ @@ -5319,6 +5327,9 @@ bpstat_check_breakpoint_conditions (bpstat *bs, threa= d_info *thread) if (frame_id_p (b->frame_id) && !frame_id_eq (b->frame_id, get_stack_frame_id (get_current_frame = ()))) { + infrun_debug_printf ("incorrect frame %s not %s, not stopping", + get_stack_frame_id (get_current_frame ()).to_string ().c_str (), + b->frame_id.to_string ().c_str ()); bs->stop =3D 0; return; } @@ -5329,6 +5340,7 @@ bpstat_check_breakpoint_conditions (bpstat *bs, threa= d_info *thread) if ((b->thread !=3D -1 && b->thread !=3D thread->global_num) || (b->task !=3D 0 && b->task !=3D ada_get_task_number (thread))) { + infrun_debug_printf ("incorrect thread or task, not stopping"); bs->stop =3D 0; return; } @@ -5420,16 +5432,26 @@ bpstat_check_breakpoint_conditions (bpstat *bs, thr= ead_info *thread) =20 if (cond && !condition_result) { + infrun_debug_printf ("condition_result =3D false, not stopping"); bs->stop =3D 0; + return; } else if (b->ignore_count > 0) { + infrun_debug_printf ("ignore count %d, not stopping", + b->ignore_count); b->ignore_count--; bs->stop =3D 0; /* Increase the hit count even though we don't stop. */ ++(b->hit_count); gdb::observers::breakpoint_modified.notify (b); - }=09 + return; + } + + if (bs->stop) + infrun_debug_printf ("stopping at this breakpoint"); + else + infrun_debug_printf ("not stopping at this breakpoint"); } =20 /* Returns true if we need to track moribund locations of LOC's type @@ -13142,7 +13164,7 @@ enable_disable_bp_num_loc (int bp_num, int loc_num,= bool enable) owner. 1-based indexing. -1 signals NOT FOUND. */ =20 static int -find_loc_num_by_location (bp_location *loc) +find_loc_num_by_location (const bp_location *loc) { if (loc !=3D nullptr && loc->owner !=3D nullptr) {