linux-debuggers.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Omar Sandoval <osandov@osandov.com>
To: Doug Anderson <dianders@chromium.org>
Cc: Jason Wessel <jason.wessel@windriver.com>,
	Daniel Thompson <daniel.thompson@linaro.org>,
	Amal Raj T <amalrajt@meta.com>,
	Stephen Brennan <stephen.s.brennan@oracle.com>,
	kgdb-bugreport@lists.sourceforge.net,
	linux-serial@vger.kernel.org, linux-debuggers@vger.kernel.org
Subject: Re: kgdb replacing newline with CRLF in custom query response
Date: Fri, 8 Nov 2024 08:17:28 -0800	[thread overview]
Message-ID: <Zy45mCCGZ9sHsXTT@telecaster> (raw)
In-Reply-To: <CAD=FV=U2eiG1TuTq48VL+kNCxN6qp_ZcDk3o_6p3B_ENOspQ9Q@mail.gmail.com>

On Fri, Nov 08, 2024 at 07:31:19AM -0800, Doug Anderson wrote:
> Hi,
> 
> On Thu, Nov 7, 2024 at 5:13 PM Omar Sandoval <osandov@osandov.com> wrote:
> >
> > On Thu, Nov 07, 2024 at 05:08:58PM -0800, Doug Anderson wrote:
> > > Hi,
> > >
> > > On Thu, Nov 7, 2024 at 2:23 PM Omar Sandoval <osandov@osandov.com> wrote:
> > > >
> > > > Hi everyone,
> > > >
> > > > Amal is working on adding a custom query packet to kgdb for getting the
> > > > kernel's vmcoreinfo. The rationale and details are available here:
> > > > https://github.com/osandov/drgn/wiki/GDB-Remote-Protocol-proposal:-linux.vmcoreinfo-query-packet
> > > >
> > > > vmcoreinfo is about 3kB, so we were hoping to avoid hex-encoding the
> > > > response and doubling the time it takes to transmit over a slow serial
> > > > connection. Instead, we were hoping to use the escaped binary format,
> > > > which escapes the characters #$}* and leaves other bytes untouched.
> > > >
> > > > We ran into a problem, though: vmcoreinfo contains newline characters,
> > > > which the serial core replaces with CRLF; see commit c7d44a02ac60
> > > > ("serial_core: Commonalize crlf when working w/ a non open console
> > > > port").
> > >
> > > FWIW, the problem predates that commit, but that commit at least moved
> > > it to be someplace common. Before that some serial drivers were
> > > hardcoding it... ;-)
> > >
> > >
> > > > This effectively corrupts the data and causes a checksum
> > > > mismatch.
> > > >
> > > > We'd love some input on how to work around this, especially from the
> > > > kgdb maintainers. Here are a few options, in descending order of my
> > > > preference:
> > > >
> > > > 1. Disable the LF -> CRLF replacement while sending binary data.
> > > > 2. Escape the newlines using some other custom scheme.
> > > > 3. Give up and hex-encode the response.
> > >
> > > I haven't tried prototyping it, but what about moving the LR -> CRLF
> > > code to kdb_msg_write(). It would be really easy to do this in the
> > > case where we're doing "dbg_io_ops->write_char()" since we're already
> > > processing character at a time. It would be harder to do this when
> > > also sending the output to the various console, but may not _too_
> > > hard? You could loop searching for "\n" and send all the characters
> > > before the "\n", then send a "\r", then send the "\n" and all the
> > > characters up to the next "\n".
> > >
> > > If you did this then you'd lose the "\n" to "\r\n" combination in the
> > > gdb stub, but _probably_ that doesn't matter?
> >
> > That sounds reasonable. I was concerned whether this would affect
> > anything else using the ->poll_put_char() tty operation, but kgdb seems
> > to be the only user, does that sound right?
> 
> Right. As far as I can tell, kgdb is the only user of poll_put_char().

Ah, one other concern, though: only uart_poll_put_char() does the CRLF
replacement, but there are other tty_operations that don't, like
hvc_poll_put_char(). So if we move that to kdb_msg_write(), then we'll
be adding extra '\r' for other tty types. Would that be a problem?

Thanks,
Omar

  reply	other threads:[~2024-11-08 16:17 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-07 22:23 kgdb replacing newline with CRLF in custom query response Omar Sandoval
2024-11-08  1:08 ` Doug Anderson
2024-11-08  1:13   ` Omar Sandoval
2024-11-08 15:31     ` Doug Anderson
2024-11-08 16:17       ` Omar Sandoval [this message]
2024-11-08 17:37         ` Doug Anderson
2024-11-15 14:49           ` Daniel Thompson
2024-11-15 17:57             ` Omar Sandoval

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=Zy45mCCGZ9sHsXTT@telecaster \
    --to=osandov@osandov.com \
    --cc=amalrajt@meta.com \
    --cc=daniel.thompson@linaro.org \
    --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=stephen.s.brennan@oracle.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).