public inbox for gdb@sourceware.org
 help / color / mirror / Atom feed
* Re: Some question about gdb unknown memory
       [not found] <tencent_98EA26F6337C692F0FDB6F523161F884D909@qq.com>
@ 2022-06-17 10:40 ` Luis Machado
  2022-06-17 13:03   ` Pedro Alves
  0 siblings, 1 reply; 2+ messages in thread
From: Luis Machado @ 2022-06-17 10:40 UTC (permalink / raw)
  To: joe jo, gdb

[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
> 
> 
> 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.

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Some question about gdb unknown memory
  2022-06-17 10:40 ` Some question about gdb unknown memory Luis Machado
@ 2022-06-17 13:03   ` Pedro Alves
  0 siblings, 0 replies; 2+ messages in thread
From: Pedro Alves @ 2022-06-17 13:03 UTC (permalink / raw)
  To: Luis Machado, joe jo, gdb

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.


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-06-17 13:03 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <tencent_98EA26F6337C692F0FDB6F523161F884D909@qq.com>
2022-06-17 10:40 ` Some question about gdb unknown memory Luis Machado
2022-06-17 13:03   ` Pedro Alves

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).