public inbox for gdb@sourceware.org
 help / color / mirror / Atom feed
From: Pedro Alves <pedro@palves.net>
To: Luis Machado <luis.machado@arm.com>, joe jo <jiu@myself.com>,
	"gdb@sourceware.org" <gdb@sourceware.org>
Subject: Re: Some question about gdb unknown memory
Date: Fri, 17 Jun 2022 14:03:38 +0100	[thread overview]
Message-ID: <e3e2b744-6ae5-2b96-a99d-b05073d451bc@palves.net> (raw)
In-Reply-To: <377d7fb9-445b-12d0-62f6-8c43c254bec8@arm.com>

On 2022-06-17 11:40, Luis Machado via Gdb wrote:
> [switching to gdb@]
> 
> On 5/20/22 07:51, joe jo wrote:
>> Hi
>>
>>
>> I met some questions when I used GDB to debugging my project. I'm writing this mail for some help.
>> At first&nbsp;I set up my one gdb-server and use GDB to connect it.
>> The problem happened when I use 'x' command to observe some unknown memory.
>> In my design, when gdb ask for some unknown memorys or registers, my server will return '?' or some other signal. For instance, when my gdbserver receive command 'm90000000,4' and memory after 90000002 is unknown, the server will return XXXX????. Otherwise, the server will return unknown register like 1234???000?0000 when receive 'g' command
>> However, when recieve ?, GDB will report errors like "Invalid hex digit 63".
>> I have read the source code of binutils-gdb/gdb/remote.c to find the reason of error, but I still don't know how can I notice GDB about those unknown memory.
>> In addition, I wonder how to use MI to sent the information about unknow memory to a eclipse-based front-end

What do you mean exactly by "unknown memory"?

Note this, here:

  https://sourceware.org/gdb/onlinedocs/gdb/Packets.html

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
‘m addr,length’
Read length addressable memory units starting at address addr (...).

(...)

Reply:

‘XX…’
Memory contents; each byte is transmitted as a two-digit hexadecimal number. The reply may contain
                                                                             ^^^^^^^^^^^^^^^^^^^^^
fewer addressable memory units than requested if the server was able to read only part
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
of the region of memory.
^^^^^^^^^^^^^^^^^^^^^^^^
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

So if GDB sends 'm90000000,4', and there's only 2 bytes available to read, you can return those two bytes.
If GDB really needs the remaining 2 bytes, then it will try to read the remaining bytes, with 'm90000002,2',
and if memory at 90000002 isn't accessible, the stub should return an error reply, and GDB will say something
like, "cannot access memory at $ADDR".

>>
>>
>> I look forward to hearing from you soon.
>> Joe Jo
> 
> Only registers can have unknown/unavailable values, marked as lowercase 'x' in the register packet reply. Memory reads don't have such support, so '?' is essentially not recognized as something valid.


      reply	other threads:[~2022-06-17 13:03 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <tencent_98EA26F6337C692F0FDB6F523161F884D909@qq.com>
2022-06-17 10:40 ` Luis Machado
2022-06-17 13:03   ` Pedro Alves [this message]

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=e3e2b744-6ae5-2b96-a99d-b05073d451bc@palves.net \
    --to=pedro@palves.net \
    --cc=gdb@sourceware.org \
    --cc=jiu@myself.com \
    --cc=luis.machado@arm.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).