Re: [RFC PATCH 1/8] gdb/ctf: add debug logging in ctfread.c

Eli Zaretskii
2026-02-03T12:41:20Z

> From: simon.marchi@polymtl.ca
> Cc: Nick Alcock <nick.alcock@oracle.com>, Weimin Pan <weimin.pan@oracle.com>,
> Simon Marchi <simon.marchi@polymtl.ca>
> Date: Tue, 3 Feb 2026 01:45:42 -0500
>
> From: Simon Marchi <simon.marchi@polymtl.ca>
>
> Add some debug statements, to be able to visualize what is happening
> when loading CTF debug info. Add a new "set debug ctf" command, with
> the usual logging macros.
>
> Here's an example of the result, when reading the binary from test
> gdb.ctf/cruss-tu-cyclic:
>
> [ctf] elfctf_build_psymtabs: start: building psymtabs for /home/simark/build/binutils-gdb/gdb/testsuite/outputs/gdb.ctf/cross-tu-cyclic/cross-tu-cyclic
> [ctf] scan_partial_symbols: start: fname='.ctf'
> [ctf] scan_partial_symbols: is parent, using fname='/home/simark/build/binutils-gdb/gdb/testsuite/outputs/gdb.ctf/cross-tu-cyclic/cross-tu-cyclic'
> [ctf] ctf_psymtab_type_cb: adding type tid=0x1 kind=INTEGER name='int'
> [ctf] ctf_psymtab_type_cb: adding type tid=0x2 kind=INTEGER name='long int'
> [ctf] ctf_psymtab_type_cb: adding type tid=0x3 kind=FORWARD name='B'
> [ctf] ctf_psymtab_type_cb: adding type tid=0x5 kind=FORWARD name='A'
> [ctf] ctf_psymtab_type_cb: adding type tid=0x8 kind=STRUCT name='C'
> [ctf] ctf_psymtab_add_stt_entries: adding function psym 'main' tid=0x7 kind=FUNCTION
> [ctf] scan_partial_symbols: end: fname='.ctf'
> [ctf] scan_partial_symbols: start: fname='/home/simark/src/binutils-gdb/gdb/testsuite/gdb.ctf/cross-tu-cyclic-1.c'
> [ctf] ctf_psymtab_type_cb: adding type tid=0x80000001 kind=STRUCT name='B'
> [ctf] ctf_psymtab_type_cb: adding type tid=0x80000002 kind=STRUCT name='A'
> [ctf] scan_partial_symbols: end: fname='/home/simark/src/binutils-gdb/gdb/testsuite/gdb.ctf/cross-tu-cyclic-1.c'
> [ctf] scan_partial_symbols: start: fname='/home/simark/src/binutils-gdb/gdb/testsuite/gdb.ctf/cross-tu-cyclic-2.c'
> [ctf] ctf_psymtab_type_cb: adding type tid=0x80000001 kind=STRUCT name='A'
> [ctf] scan_partial_symbols: end: fname='/home/simark/src/binutils-gdb/gdb/testsuite/gdb.ctf/cross-tu-cyclic-2.c'
> [ctf] scan_partial_symbols: start: fname='/home/simark/src/binutils-gdb/gdb/testsuite/gdb.ctf/cross-tu-cyclic-3.c'
> [ctf] ctf_psymtab_type_cb: adding type tid=0x80000001 kind=STRUCT name='A'
> [ctf] scan_partial_symbols: end: fname='/home/simark/src/binutils-gdb/gdb/testsuite/gdb.ctf/cross-tu-cyclic-3.c'
> [ctf] scan_partial_symbols: start: fname='/home/simark/src/binutils-gdb/gdb/testsuite/gdb.ctf/cross-tu-cyclic-4.c'
> [ctf] ctf_psymtab_type_cb: adding type tid=0x80000001 kind=STRUCT name='A'
> [ctf] ctf_psymtab_type_cb: adding type tid=0x80000002 kind=STRUCT name='B'
> [ctf] scan_partial_symbols: end: fname='/home/simark/src/binutils-gdb/gdb/testsuite/gdb.ctf/cross-tu-cyclic-4.c'
> [ctf] elfctf_build_psymtabs: end: building psymtabs for /home/simark/build/binutils-gdb/gdb/testsuite/outputs/gdb.ctf/cross-tu-cyclic/cross-tu-cyclic
>
> Change-Id: If3800d14dd965ccefa67a24ef5c4481aef70ffa4
> ---
> gdb/NEWS | 4 ++
> gdb/ctfread.c | 95 ++++++++++++++++++++++++++++++++++++++++++++-
> gdb/doc/gdb.texinfo | 7 ++++
> 3 files changed, 104 insertions(+), 2 deletions(-)

Thanks.

> diff --git a/gdb/NEWS b/gdb/NEWS
> index fa6e7ca61219..af04fa1e67ae 100644
> --- a/gdb/NEWS
> +++ b/gdb/NEWS
> @@ -91,6 +91,10 @@ show progress-bars enabled
> content, to be disabled (the set command), or to see if
> progress-bars are currently enabled or not (the show command).
>
> +set debug ctf on|off
> +show debug ctf
> + Print debug messages about CTF reading.
> +
> * Changed commands

This part is okay.

> +@item set debug ctf
> +@cindex CTF debug messages
> +Turns on or off display of debugging messages related to reading CTF

Please always put the indexing commands _before_ the @item line to
which they refer. This way, following the index entry in the Info
reader will place the cursor on the @item line, not after it.

Reviewed-By: Eli Zaretskii <eliz@gnu.org>