public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Tom Tromey <tom@tromey.com>
To: Simon Farre via Gdb-patches <gdb-patches@sourceware.org>
Cc: Simon Farre <simon.farre.cx@gmail.com>
Subject: Re: [PATCH v1] gdb/DAP Fix disassemble bug
Date: Mon, 26 Jun 2023 12:34:02 -0600	[thread overview]
Message-ID: <87cz1ixecl.fsf@tromey.com> (raw)
In-Reply-To: <20230626161654.207687-1-simon.farre.cx@gmail.com> (Simon Farre via Gdb-patches's message of "Mon, 26 Jun 2023 18:16:54 +0200")

>>>>> "Simon" == Simon Farre via Gdb-patches <gdb-patches@sourceware.org> writes:

Simon> Fixes disassembleRequest
Simon> The field instructionOffset can be negative. Previous patch made it so
Simon> that sometimes the request got calculated to 0 instructions, when it
Simon> meant to retrieve disasm for -50 to 0 (current position).

I don't think this will work correctly, because this isn't counting by
instruction but rather by byte.

instructionOffset is defined in terms of instructions:

    Offset (in instructions) to be applied after the byte offset (if any)
    before disassembling. Can be negative.

I must have missed the "negative" note, or maybe I just ignored it
without documenting that -- since I wonder how it can possibly work.  it
seems to me that on architectures with variable length instructions, you
can't really disassemble in "reverse" like that.

I guess one idea would be to back up to the previous symbol and start
disassembling from there.  I feel like the TUI did this, though, and ran
into all kinds of weird corner cases.

Simon> -    for elt in arch.disassemble(pc, count=total_count)[skip_insns:]:

I notice now that the current code also neglects this part of the spec:

   * An adapter must return exactly this number of instructions - any
   * unavailable instructions should be replaced with an implementation-defined
   * 'invalid instruction' value.

Tom

  reply	other threads:[~2023-06-26 18:34 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-26 16:16 Simon Farre
2023-06-26 18:34 ` Tom Tromey [this message]
2023-06-26 22:00   ` Simon Farre
2023-06-26 22:11   ` Simon Farre
2023-06-27 15:32     ` Simon Farre

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=87cz1ixecl.fsf@tromey.com \
    --to=tom@tromey.com \
    --cc=gdb-patches@sourceware.org \
    --cc=simon.farre.cx@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 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 read-only IMAP folder(s) and NNTP newsgroup(s).