[PATCH] gdb: add debug prints in remote_check_symbols
Luis Machado
luis.machado@linaro.org
Fri Apr 16 15:05:09 GMT 2021
I think the debugging output is great, but I'm not sure if using the
same option that enables RSP debugging output is the best option.
On 4/16/21 12:00 PM, Simon Marchi via Gdb-patches wrote:
> While debugging a libthread_db issue against gdbserver, I added these
> debug prints, which help to read the symbols names (which are
> hex-encoded in the packets). I'd like to merge that upstream, I think
> it may be useful in the future.
>
> Before:
>
> [remote] Sending packet: $qSymbol::#5b
> [remote] Packet received: qSymbol:6764625f6167656e745f6764625f74705f686561705f627566666572
> [remote] Sending packet: $qSymbol::6764625f6167656e745f6764625f74705f686561705f627566666572#1e
> [remote] Packet received: qSymbol:6e70746c5f76657273696f6e
> [remote] Sending packet: $qSymbol::6e70746c5f76657273696f6e#4d
> [remote] Packet received: OK
>
> After:
>
> [remote] remote_check_symbols: enter
> [remote] Sending packet: $qSymbol::#5b
> [remote] Packet received: qSymbol:6764625f6167656e745f6764625f74705f686561705f627566666572
> [remote] remote_check_symbols: asked for symbol: gdb_agent_gdb_tp_heap_buffer
> [remote] remote_check_symbols: -> not found
> [remote] Sending packet: $qSymbol::6764625f6167656e745f6764625f74705f686561705f627566666572#1e
> [remote] Packet received: qSymbol:6e70746c5f76657273696f6e
> [remote] remote_check_symbols: asked for symbol: nptl_version
> [remote] remote_check_symbols: -> not found
> [remote] Sending packet: $qSymbol::6e70746c5f76657273696f6e#4d
> [remote] Packet received: OK
> [remote] remote_check_symbols: exit
>
> gdb/ChangeLog:
>
> * remote.c (remote_target::remote_check_symbols): Add debug
> prints.
>
> Change-Id: Ia05b61285259a7d1570ec6bacfc9700d5baf129e
> ---
> gdb/remote.c | 17 ++++++++++++++---
> 1 file changed, 14 insertions(+), 3 deletions(-)
>
> diff --git a/gdb/remote.c b/gdb/remote.c
> index 7429e1a86b38..96325531d51d 100644
> --- a/gdb/remote.c
> +++ b/gdb/remote.c
> @@ -5035,6 +5035,8 @@ remote_target::remote_check_symbols ()
> char *tmp;
> int end;
>
> + REMOTE_SCOPED_DEBUG_ENTER_EXIT;
> +
> /* The remote side has no concept of inferiors that aren't running
> yet, it only knows about running processes. If we're connected
> but our current inferior is not running, we should not invite the
> @@ -5069,19 +5071,28 @@ remote_target::remote_check_symbols ()
> end = hex2bin (tmp, reinterpret_cast <gdb_byte *> (msg.data ()),
> strlen (tmp) / 2);
> msg[end] = '\0';
> +
> + remote_debug_printf ("asked for symbol: %s", msg.data ());
> +
> sym = lookup_minimal_symbol (msg.data (), NULL, NULL);
> if (sym.minsym == NULL)
> - xsnprintf (msg.data (), get_remote_packet_size (), "qSymbol::%s",
> - &reply[8]);
> + {
> + remote_debug_printf (" -> not found");
> + xsnprintf (msg.data (), get_remote_packet_size (), "qSymbol::%s",
> + &reply[8]);
> + }
> else
> {
> int addr_size = gdbarch_addr_bit (target_gdbarch ()) / 8;
> CORE_ADDR sym_addr = BMSYMBOL_VALUE_ADDRESS (sym);
> + gdbarch *arch = target_gdbarch ();
>
> /* If this is a function address, return the start of code
> instead of any data function descriptor. */
> sym_addr = gdbarch_convert_from_func_ptr_addr
> - (target_gdbarch (), sym_addr, current_inferior ()->top_target ());
> + (arch, sym_addr, current_inferior ()->top_target ());
> +
> + remote_debug_printf (" -> found %s", paddress (arch, sym_addr));
>
> xsnprintf (msg.data (), get_remote_packet_size (), "qSymbol:%s:%s",
> phex_nz (sym_addr, addr_size), &reply[8]);
>
More information about the Gdb-patches
mailing list