All of lore.kernel.org
 help / color / mirror / Atom feed
From: Daniel Thompson <danielt@kernel.org>
To: Amal Raj T <tjarlama@gmail.com>
Cc: dianders@chromium.org, jason.wessel@windriver.com,
	stephen.s.brennan@oracle.com, amalrajt@meta.com,
	osandov@osandov.com, linux-debuggers@vger.kernel.org,
	linux-serial@vger.kernel.org,
	kgdb-bugreport@lists.sourceforge.net
Subject: Re: [PATCH v2 1/3] kgdb: Add kgdb_mem2ebin function for converting memory to binary format
Date: Wed, 8 Jan 2025 11:40:28 +0000	[thread overview]
Message-ID: <Z35kLN5mkekkfgql@aspen.lan> (raw)
In-Reply-To: <20241211153955.33518-2-tjarlama@gmail.com>

On Wed, Dec 11, 2024 at 07:39:53AM -0800, Amal Raj T wrote:
> From: Amal Raj T <amalrajt@meta.com>
>
> Add a new function kgdb_mem2ebin that converts memory
> to binary format, escaping special characters
> ('$', '#', and '}').

What about the '*' character?

The gdb docs say "Responses sent by the stub must also escape 0x2a
(ASCII ‘*’), so that it is not interpreted as the start of a run-length
encoded sequence".


> kgdb_mem2ebin function ensures
> that memory data is properly formatted and escaped
> before being sent over the wire. Additionally, this
> function reduces the amount of data exchanged between
> debugger compared to hex.
>
> Signed-off-by: Amal Raj T <amalrajt@meta.com>
> ---
>  include/linux/kgdb.h   |  1 +
>  kernel/debug/gdbstub.c | 31 +++++++++++++++++++++++++++++++
>  2 files changed, 32 insertions(+)
>
> diff --git a/include/linux/kgdb.h b/include/linux/kgdb.h
> index 76e891ee9e37..fa3cf38a14de 100644
> --- a/include/linux/kgdb.h
> +++ b/include/linux/kgdb.h
> @@ -322,6 +322,7 @@ extern struct kgdb_io *dbg_io_ops;
>
>  extern int kgdb_hex2long(char **ptr, unsigned long *long_val);
>  extern char *kgdb_mem2hex(char *mem, char *buf, int count);
> +extern char *kgdb_mem2ebin(char *mem, char *buf, int count);
>  extern int kgdb_hex2mem(char *buf, char *mem, int count);
>
>  extern int kgdb_isremovedbreak(unsigned long addr);
> diff --git a/kernel/debug/gdbstub.c b/kernel/debug/gdbstub.c
> index f625172d4b67..6198d2eb49c4 100644
> --- a/kernel/debug/gdbstub.c
> +++ b/kernel/debug/gdbstub.c
> @@ -257,6 +257,37 @@ char *kgdb_mem2hex(char *mem, char *buf, int count)
>  	return buf;
>  }
>
> +/*
> + * Convert memory to binary format for GDB remote protocol
> + * transmission, escaping special characters ($, #, and }).
> + */

It would be good to include a link to the following in this comment:
https://sourceware.org/gdb/current/onlinedocs/gdb.html/Overview.html#Binary-Data

Doug already mentioned putting buffer size expectations in this comment.
Maybe also mention that the worst case packing is identical to
kgdb_mem2hex() (e.g. 2*count + 1).


Daniel.

  parent reply	other threads:[~2025-01-08 11:40 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <gmail>
2024-12-10 13:34 ` [PATCH 0/3] Add a new command in kgdb for vmcoreinfo Amal Raj T
2024-12-10 13:34   ` [PATCH 1/3] kgdb: Add kgdb_mem2ebin function for converting memory to binary format Amal Raj T
2024-12-10 13:34   ` [PATCH 2/3] serial: Move LF -> CRLF replacement from serial console to kdb Amal Raj T
2024-12-10 15:16     ` Daniel Thompson
2024-12-11 15:40       ` Amal
2024-12-10 13:34   ` [PATCH 3/3] kgdb: Add command linux.vmcoreinfo to kgdb Amal Raj T
2024-12-11 15:39 ` [PATCH v2 0/3] Add a new command in kgdb for vmcoreinfo Amal Raj T
2024-12-11 15:39   ` [PATCH v2 1/3] kgdb: Add kgdb_mem2ebin function for converting memory to binary format Amal Raj T
2024-12-13  0:55     ` Doug Anderson
     [not found]       ` <CAOfKSRMBYp6dSbhRqQXm09QUoJTaLjQr0XFqzqGVGeJ-KKoMuQ@mail.gmail.com>
2025-01-24 23:17         ` Doug Anderson
2025-01-08 11:40     ` Daniel Thompson [this message]
2024-12-11 15:39   ` [PATCH v2 2/3] serial: Move LF -> CRLF replacement from serial console to kdb Amal Raj T
2024-12-13  0:55     ` Doug Anderson
2024-12-11 15:39   ` [PATCH v2 3/3] kgdb: Add command linux.vmcoreinfo to kgdb Amal Raj T
2024-12-13  0:56     ` Doug Anderson
2025-01-13 17:29 ` [PATCH v3 0/3] Add a new command in kgdb for vmcoreinfo Amal Raj T
2025-01-13 17:29   ` [PATCH v3 1/3] kgdb: Add kgdb_mem2ebin function for converting memory to binary format Amal Raj T
2025-01-13 20:38     ` Stephen Brennan
2025-01-13 17:29   ` [PATCH v3 2/3] kgdb: Add command linux.vmcoreinfo to kgdb Amal Raj T
2025-01-13 23:24     ` Stephen Brennan
2025-01-13 17:29   ` [PATCH v3 2/3] serial: Move LF -> CRLF replacement from serial console to kdb Amal Raj T
2025-01-13 21:29     ` Stephen Brennan
2025-01-24 22:55     ` Doug Anderson
2025-01-13 17:29   ` [PATCH v3 3/3] kgdb: Add command linux.vmcoreinfo to kgdb Amal Raj T
2025-01-13 23:22     ` Stephen Brennan
2025-01-14 21:18       ` Stephen Brennan

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=Z35kLN5mkekkfgql@aspen.lan \
    --to=danielt@kernel.org \
    --cc=amalrajt@meta.com \
    --cc=dianders@chromium.org \
    --cc=jason.wessel@windriver.com \
    --cc=kgdb-bugreport@lists.sourceforge.net \
    --cc=linux-debuggers@vger.kernel.org \
    --cc=linux-serial@vger.kernel.org \
    --cc=osandov@osandov.com \
    --cc=stephen.s.brennan@oracle.com \
    --cc=tjarlama@gmail.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.