Mirror of the gdb mailing list
 help / color / mirror / Atom feed
* GDB remote debugging stub: Question about memory read
@ 2010-09-27  8:54 Niklas Quarfot Nielsen
  2010-09-27  9:16 ` Pedro Alves
  0 siblings, 1 reply; 3+ messages in thread
From: Niklas Quarfot Nielsen @ 2010-09-27  8:54 UTC (permalink / raw)
  To: gdb

[-- Attachment #1: Type: text/plain, Size: 1750 bytes --]

Hi everyone,

I just subscribed to this list, so if I do not follow your mailing list conventions - please let me know.

I am implementing a remote debugging stub for a research operating system at the technical university of Denmark.
GDB can connect and if I disable memory reads, single stepping and hardware breakpointing works fine.  So serial communication and initialization should be in order.
The problem arises when GDB requests memory read of the stack (right after the g-packet as been received).

The registers contains the following:

rax            0x0
rbx            0xb816a
rcx            0x6e
rdx            0x8
rsi            0xffff8000000b8000
rdi            0xb8000
rbp            0xffffffff6efffff0
rsp            0xffffffff6effffd0
r8             0x5
r9             0x78bfbff
r10            0x0
r11            0x0
r12            0x0
r13            0x0
r14            0x0
r15            0x0
rip            0xffffffff80200293 <system_start+223>
eflags         0x46	[ PF ZF ]
cs             0x18
ss             0x0
ds             0x0
es             0x0
fs             0x0

GDB tries to read 0x40 bytes starting at address 0xffffffff6effffc0, which (I guess) is from the RSP.
Packet: mffffffff6effffc0,40

My question is:
Why does GDB try to read 0x40 bytes, when there is only 0x20 bytes on the stack (RBP-RSP)?

The architecture is an AMD64 and the version of GDB is 7.1(x86_64-gnu-linux).

I appreciate any answer and/or clue to why GDB behaves like this.
I have tried to look through the remote debugging source code of GDB, but this has not given me any answers.
If needed, I can post debugging information from the target code in GDB.


Best regards

Niklas Quarfot Nielsen


[-- Attachment #2: smime.p7s --]
[-- Type: application/pkcs7-signature, Size: 1925 bytes --]

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

* Re: GDB remote debugging stub: Question about memory read
  2010-09-27  8:54 GDB remote debugging stub: Question about memory read Niklas Quarfot Nielsen
@ 2010-09-27  9:16 ` Pedro Alves
  2010-09-27  9:20   ` Niklas Quarfot Nielsen
  0 siblings, 1 reply; 3+ messages in thread
From: Pedro Alves @ 2010-09-27  9:16 UTC (permalink / raw)
  To: gdb; +Cc: Niklas Quarfot Nielsen

On Monday 27 September 2010 09:54:04, Niklas Quarfot Nielsen wrote:
> GDB tries to read 0x40 bytes starting at address 0xffffffff6effffc0, which (I guess) is from the RSP.
> Packet: mffffffff6effffc0,40
> 
> My question is:
> Why does GDB try to read 0x40 bytes, when there is only 0x20 bytes on the stack (RBP-RSP)?
> 
> The architecture is an AMD64 and the version of GDB is 7.1(x86_64-gnu-linux).
> 
> I appreciate any answer and/or clue to why GDB behaves like this.
> I have tried to look through the remote debugging source code of GDB, but this has not given me any answers.
> If needed, I can post debugging information from the target code in GDB.
> 

0x40 bytes is GDB's stack cache line size (dcache.c).
Try "(gdb) set stack-cache off".

-- 
Pedro Alves


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

* Re: GDB remote debugging stub: Question about memory read
  2010-09-27  9:16 ` Pedro Alves
@ 2010-09-27  9:20   ` Niklas Quarfot Nielsen
  0 siblings, 0 replies; 3+ messages in thread
From: Niklas Quarfot Nielsen @ 2010-09-27  9:20 UTC (permalink / raw)
  To: Pedro Alves; +Cc: gdb

[-- Attachment #1: Type: text/plain, Size: 983 bytes --]

That worked! Thank you so much - you saved my day. (Probably a couple of days to be more exact).

Cheers,

Niklas

On Sep 27, 2010, at 11:16 , Pedro Alves wrote:

> On Monday 27 September 2010 09:54:04, Niklas Quarfot Nielsen wrote:
>> GDB tries to read 0x40 bytes starting at address 0xffffffff6effffc0, which (I guess) is from the RSP.
>> Packet: mffffffff6effffc0,40
>> 
>> My question is:
>> Why does GDB try to read 0x40 bytes, when there is only 0x20 bytes on the stack (RBP-RSP)?
>> 
>> The architecture is an AMD64 and the version of GDB is 7.1(x86_64-gnu-linux).
>> 
>> I appreciate any answer and/or clue to why GDB behaves like this.
>> I have tried to look through the remote debugging source code of GDB, but this has not given me any answers.
>> If needed, I can post debugging information from the target code in GDB.
>> 
> 
> 0x40 bytes is GDB's stack cache line size (dcache.c).
> Try "(gdb) set stack-cache off".
> 
> -- 
> Pedro Alves


[-- Attachment #2: smime.p7s --]
[-- Type: application/pkcs7-signature, Size: 1925 bytes --]

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

end of thread, other threads:[~2010-09-27  9:20 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-09-27  8:54 GDB remote debugging stub: Question about memory read Niklas Quarfot Nielsen
2010-09-27  9:16 ` Pedro Alves
2010-09-27  9:20   ` Niklas Quarfot Nielsen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox