From: Andrew Burgess <aburgess@redhat.com>
To: gdb-patches@sourceware.org
Cc: Andrew Burgess <aburgess@redhat.com>
Subject: [PATCH] gdb/frame: add FRAME_SCOPED_DEBUG_START_END
Date: Wed, 3 Jun 2026 09:52:13 +0100 [thread overview]
Message-ID: <2ce7d5465de836f6180411a699471dc165e61b74.1780476716.git.aburgess@redhat.com> (raw)
Add the FRAME_SCOPED_DEBUG_START_END macro, and make use of it in a
couple of places.
I find the frame debug output a little noisy, and it could be easier
to match up the entry/exit lines, by making use of
FRAME_SCOPED_DEBUG_START_END to print the frame level.
While I was adding the FRAME_SCOPED_DEBUG_START_END calls, there were
a couple of places where I also moved a variable declaration from the
top the a function into the function body. And in another couple of
places there was some debug output that could be removed, where the
existing debug just printed the frame level (this is now handled by
the START/END macro).
There should be no user visible changes after this commit unless 'set
debug frame on' is used of course.
---
gdb/frame.c | 24 ++++++------------------
gdb/frame.h | 5 +++++
2 files changed, 11 insertions(+), 18 deletions(-)
diff --git a/gdb/frame.c b/gdb/frame.c
index 61d37316c6a..179e251eb1f 100644
--- a/gdb/frame.c
+++ b/gdb/frame.c
@@ -619,7 +619,7 @@ skip_tailcall_frames (const frame_info_ptr &initial_frame)
static void
compute_frame_id (const frame_info_ptr &fi)
{
- FRAME_SCOPED_DEBUG_ENTER_EXIT;
+ FRAME_SCOPED_DEBUG_START_END ("fi=%d", fi->level);
gdb_assert (fi->this_id.p == frame_id_status::NOT_COMPUTED);
@@ -630,8 +630,6 @@ compute_frame_id (const frame_info_ptr &fi)
/* Mark this frame's id as "being computed. */
fi->this_id.p = frame_id_status::COMPUTING;
- frame_debug_printf ("fi=%d", fi->level);
-
/* Find the unwinder. */
if (fi->unwind == NULL)
frame_unwind_find_by_frame (fi, &fi->prologue_cache);
@@ -2349,18 +2347,10 @@ get_prev_frame_maybe_check_cycle (const frame_info_ptr &this_frame)
static frame_info_ptr
get_prev_frame_always_1 (const frame_info_ptr &this_frame)
{
- FRAME_SCOPED_DEBUG_ENTER_EXIT;
+ FRAME_SCOPED_DEBUG_START_END ("fi=%d", this_frame->level);
gdb_assert (this_frame != NULL);
- if (frame_debug)
- {
- if (this_frame != NULL)
- frame_debug_printf ("this_frame=%d", this_frame->level);
- else
- frame_debug_printf ("this_frame=nullptr");
- }
-
struct gdbarch *gdbarch = get_frame_arch (this_frame);
/* Only try to do the unwind once. */
@@ -2593,7 +2583,7 @@ get_prev_frame_always (const frame_info_ptr &this_frame)
static frame_info_ptr
get_prev_frame_raw (const frame_info_ptr &this_frame)
{
- frame_info *prev_frame;
+ FRAME_SCOPED_DEBUG_START_END ("fi=%d", this_frame->level);
/* Allocate the new frame but do not wire it in to the frame chain.
Some (bad) code in INIT_FRAME_EXTRA_INFO tries to look along
@@ -2605,7 +2595,7 @@ get_prev_frame_raw (const frame_info_ptr &this_frame)
quickly reclaimed when the frame cache is flushed, and the `we've
been here before' check above will stop repeated memory
allocation calls. */
- prev_frame = frame_obstack_zalloc<frame_info> ();
+ frame_info *prev_frame = frame_obstack_zalloc<frame_info> ();
prev_frame->level = this_frame->level + 1;
/* For now, assume we don't have frame chains crossing address
@@ -2729,16 +2719,14 @@ inside_entry_func (const frame_info_ptr &this_frame)
frame_info_ptr
get_prev_frame (const frame_info_ptr &this_frame)
{
- FRAME_SCOPED_DEBUG_ENTER_EXIT;
-
- std::optional<CORE_ADDR> frame_pc;
+ FRAME_SCOPED_DEBUG_START_END ("fi=%d", this_frame->level);
/* There is always a frame. If this assertion fails, suspect that
something should be calling get_selected_frame() or
get_current_frame(). */
gdb_assert (this_frame != NULL);
- frame_pc = get_frame_pc_if_available (this_frame);
+ std::optional<CORE_ADDR> frame_pc = get_frame_pc_if_available (this_frame);
/* tausq/2004-12-07: Dummy frames are skipped because it doesn't make much
sense to stop unwinding at a dummy frame. One place where a dummy
diff --git a/gdb/frame.h b/gdb/frame.h
index 00485e6d1e2..f6553fb7b6d 100644
--- a/gdb/frame.h
+++ b/gdb/frame.h
@@ -125,6 +125,11 @@ extern bool frame_debug;
#define FRAME_SCOPED_DEBUG_ENTER_EXIT \
scoped_debug_enter_exit (frame_debug, "frame")
+/* Print "frame" start/end debug statements. */
+
+#define FRAME_SCOPED_DEBUG_START_END(fmt, ...) \
+ scoped_debug_start_end (frame_debug, "frame", fmt, ##__VA_ARGS__)
+
/* Construct a frame ID. The first parameter is the frame's constant
stack address (typically the outer-bound), and the second the
frame's constant code address (typically the entry point).
base-commit: 663cb9c0428068165fc98675599442163d302d41
--
2.25.4
next reply other threads:[~2026-06-03 8:52 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-03 8:52 Andrew Burgess [this message]
2026-06-03 12:47 ` Tom Tromey
2026-06-04 9:34 ` Andrew Burgess
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=2ce7d5465de836f6180411a699471dc165e61b74.1780476716.git.aburgess@redhat.com \
--to=aburgess@redhat.com \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox