public inbox for gdb@sourceware.org
 help / color / mirror / Atom feed
* Doubt using "set" command with registers
@ 2014-10-28 16:02 joaoandreferro
  2014-10-29  0:52 ` Pete Delaney
  2014-10-30 10:59 ` Pedro Alves
  0 siblings, 2 replies; 7+ messages in thread
From: joaoandreferro @ 2014-10-28 16:02 UTC (permalink / raw)
  To: gdb

Hello all,

I've been using GDB (in fact, conjuged with KGDB) lately to do some  
kernel debugging. I've been testing some GDB commands, and a doubt  
arised while using the "set" command, trying to change the value of  
some registers. I've been able to successfully change the value of all  
the registers provided by the "info registers" command (i. e., in my  
case $eax, $ecx, $edx, $ebx, $esp, $ebp, $esi, $edi, $eip, $eflags,  
$cs, $ss, $ds, $es, $fs and $gs) *except* for $esp, $ss, $fs and $gs.  
Why is it so? I've been making these tests after hitting a hardware  
breakpoint, then I set the values with e. g. "set $es = 0xf1c2007c",  
and verifiy the assignemt with "info reg $es". As I've pointed out, it  
works with the majority of the registers, except for that four (in  
this particular case, the first command doesn't output any error, but  
the second command shows me that the registers remain with the initial  
value). By the way, I've started GDB with the -write option (checked  
it inside GDb with the "show write" command). My GDB version is 7.2.

If someone knows something about this situation and can share it with  
me, it would be great.

Best regards,
João


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

* RE: Doubt using "set" command with registers
  2014-10-28 16:02 Doubt using "set" command with registers joaoandreferro
@ 2014-10-29  0:52 ` Pete Delaney
  2014-10-29 19:05   ` joaoandreferro
  2014-10-30 10:59 ` Pedro Alves
  1 sibling, 1 reply; 7+ messages in thread
From: Pete Delaney @ 2014-10-29  0:52 UTC (permalink / raw)
  To: joaoandreferro, gdb; +Cc: Pete Delaney, piet.delaney

Had any luck using KGDB during the early boot code?

I haven't been able to get the ekgdboe working with the keyboard via a serial interface, thought it does start early enough.
Can't get ekgdboe working with tty0/ttyS0; starts way to late to debug a boot problem I'm looking at.

This use to be trivial with the old SunOS 4.1.4 kgdb patch, and I think the pre-KDB version of KGDB seemed
To do early boot code ok. With old 2 page SunOS 4.1.4 patch switching between task was just a matter of
Getting the SP and PC from the proc  structure, changing $PS and $PC in gdb and restarting GDB so it would
Reload it's cache.

JTAG based debugging shouldn't be necessary to debug early boot code
And JTAG isn't readily available for large PCs.

-piet

--
Pete/Piet Delaney                                               
O: +1 408 935-1813
C: +1 408 646-8557
H: +1 408 243-8872
Home Email: piet.delaney@gmail.com




-----Original Message-----
From: gdb-owner@sourceware.org [mailto:gdb-owner@sourceware.org] On Behalf Of joaoandreferro@sapo.pt
Sent: Tuesday, October 28, 2014 9:02 AM
To: gdb@sourceware.org
Subject: Doubt using "set" command with registers

Hello all,

I've been using GDB (in fact, conjuged with KGDB) lately to do some kernel debugging. I've been testing some GDB commands, and a doubt arised while using the "set" command, trying to change the value of some registers. I've been able to successfully change the value of all the registers provided by the "info registers" command (i. e., in my case $eax, $ecx, $edx, $ebx, $esp, $ebp, $esi, $edi, $eip, $eflags, $cs, $ss, $ds, $es, $fs and $gs) *except* for $esp, $ss, $fs and $gs.  
Why is it so? I've been making these tests after hitting a hardware breakpoint, then I set the values with e. g. "set $es = 0xf1c2007c", and verifiy the assignemt with "info reg $es". As I've pointed out, it works with the majority of the registers, except for that four (in this particular case, the first command doesn't output any error, but the second command shows me that the registers remain with the initial value). By the way, I've started GDB with the -write option (checked it inside GDb with the "show write" command). My GDB version is 7.2.

If someone knows something about this situation and can share it with me, it would be great.

Best regards,
João



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

* Re: Doubt using "set" command with registers
  2014-10-29  0:52 ` Pete Delaney
@ 2014-10-29 19:05   ` joaoandreferro
  0 siblings, 0 replies; 7+ messages in thread
From: joaoandreferro @ 2014-10-29 19:05 UTC (permalink / raw)
  To: Pete Delaney; +Cc: gdb, piet.delaney

Hello Pete,

I didn't use ekgdboe (I'm using a serial connection between the target  
and the host). The only option I used to debug during boot was the  
"kgdbwait" option (in the GRUB configuration file), to hang the target  
at boot, and wait for a "cont" command from the host. I removed this  
option some weeks ago though, because I do no want to do debug during  
boot. But I remember it worked.

Regarding the original thread's subject, do you know anything on why  
some register values can be changed while others can't?

Regards,
João

Citando Pete Delaney <pdelaney@silver-peak.com>:

> Had any luck using KGDB during the early boot code?
>
> I haven't been able to get the ekgdboe working with the keyboard via  
> a serial interface, thought it does start early enough.
> Can't get ekgdboe working with tty0/ttyS0; starts way to late to  
> debug a boot problem I'm looking at.
>
> This use to be trivial with the old SunOS 4.1.4 kgdb patch, and I  
> think the pre-KDB version of KGDB seemed
> To do early boot code ok. With old 2 page SunOS 4.1.4 patch  
> switching between task was just a matter of
> Getting the SP and PC from the proc  structure, changing $PS and $PC  
> in gdb and restarting GDB so it would
> Reload it's cache.
>
> JTAG based debugging shouldn't be necessary to debug early boot code
> And JTAG isn't readily available for large PCs.
>
> -piet
>
> --
> Pete/Piet Delaney
> O: +1 408 935-1813
> C: +1 408 646-8557
> H: +1 408 243-8872
> Home Email: piet.delaney@gmail.com
>
>
>
>
> -----Original Message---though--
> From: gdb-owner@sourceware.org [mailto:gdb-owner@sourceware.org] On  
> Behalf Of joaoandreferro@sapo.pt
> Sent: Tuesday, October 28, 2014 9:02 AM
> To: gdb@sourceware.org
> Subject: Doubt using "set" command with registers
>
> Hello all,
>
> I've been using GDB (in fact, conjuged with KGDB) lately to do some  
> kernel debugging. I've been testing some GDB commands, and a doubt  
> arised while using the "set" command, trying to change the value of  
> some registers. I've been able to successfully change the value of  
> all the registers provided by the "info registers" command (i. e.,  
> in my case $eax, $ecx, $edx, $ebx, $esp, $ebp, $esi, $edi, $eip,  
> $eflags, $cs, $ss, $ds, $es, $fs and $gs) *except* for $esp, $ss,  
> $fs and $gs.though
> Why is it so? I've been making these tests after hitting a hardware  
> breakpoint, then I set the values with e. g. "set $es = 0xf1c2007c",  
> and verifiy the assignemt with "info reg $es". As I've pointed out,  
> it works with the majority of the registers, except for that four  
> (in this particular case, the first command doesn't output any  
> error, but the second command shows me that the registers remain  
> with the initial value). By the way, I've started GDB with the  
> -write option (checked it inside GDb with the "show write" command).  
> My GDB version is 7.2.
>
> If someone knows something about this situation and can share it  
> with me, it would be great.
>
> Best regards,
> João


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

* Re: Doubt using "set" command with registers
  2014-10-28 16:02 Doubt using "set" command with registers joaoandreferro
  2014-10-29  0:52 ` Pete Delaney
@ 2014-10-30 10:59 ` Pedro Alves
  2014-10-31 11:21   ` joaoandreferro
  1 sibling, 1 reply; 7+ messages in thread
From: Pedro Alves @ 2014-10-30 10:59 UTC (permalink / raw)
  To: joaoandreferro, gdb

Hi João,

On 10/28/2014 04:01 PM, joaoandreferro@sapo.pt wrote:
> Hello all,
> 
> I've been using GDB (in fact, conjuged with KGDB) lately to do some  
> kernel debugging. I've been testing some GDB commands, and a doubt  
> arised while using the "set" command, trying to change the value of  
> some registers. I've been able to successfully change the value of all  
> the registers provided by the "info registers" command (i. e., in my  
> case $eax, $ecx, $edx, $ebx, $esp, $ebp, $esi, $edi, $eip, $eflags,  
> $cs, $ss, $ds, $es, $fs and $gs) *except* for $esp, $ss, $fs and $gs.  
> Why is it so? I've been making these tests after hitting a hardware  
> breakpoint, then I set the values with e. g. "set $es = 0xf1c2007c",  
> and verifiy the assignemt with "info reg $es". As I've pointed out, it  
> works with the majority of the registers, except for that four (in  
> this particular case, the first command doesn't output any error, but  
> the second command shows me that the registers remain with the initial  
> value). By the way, I've started GDB with the -write option (checked  
> it inside GDb with the "show write" command). My GDB version is 7.2.
> 
> If someone knows something about this situation and can share it with  
> me, it would be great.

I'd guess that it's kgdb itself that is blocking those writes.

Try "set debug remote 1" before the "set $foo = " command.

Thanks,
Pedro Alves

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

* Re: Doubt using "set" command with registers
  2014-10-30 10:59 ` Pedro Alves
@ 2014-10-31 11:21   ` joaoandreferro
  2014-10-31 11:47     ` Pedro Alves
  0 siblings, 1 reply; 7+ messages in thread
From: joaoandreferro @ 2014-10-31 11:21 UTC (permalink / raw)
  To: gdb; +Cc: Pedro Alves

Citando Pedro Alves <palves@redhat.com>:

> Hi João,
>
> On 10/28/2014 04:01 PM, joaoandreferro@sapo.pt wrote:
>> Hello all,
>>
>> I've been using GDB (in fact, conjuged with KGDB) lately to do some
>> kernel debugging. I've been testing some GDB commands, and a doubt
>> arised while using the "set" command, trying to change the value of
>> some registers. I've been able to successfully change the value of all
>> the registers provided by the "info registers" command (i. e., in my
>> case $eax, $ecx, $edx, $ebx, $esp, $ebp, $esi, $edi, $eip, $eflags,
>> $cs, $ss, $ds, $es, $fs and $gs) *except* for $esp, $ss, $fs and $gs.
>> Why is it so? I've been making these tests after hitting a hardware
>> breakpoint, then I set the values with e. g. "set $es = 0xf1c2007c",
>> and verifiy the assignemt with "info reg $es". As I've pointed out, it
>> works with the majority of the registers, except for that four (in
>> this particular case, the first command doesn't output any error, but
>> the second command shows me that the registers remain with the initial
>> value). By the way, I've started GDB with the -write option (checked
>> it inside GDb with the "show write" command). My GDB version is 7.2.
>>
>> If someone knows something about this situation and can share it with
>> me, it would be great.
>
> I'd guess that it's kgdb itself that is blocking those writes.
>
> Try "set debug remote 1" before the "set $foo = " command.
>
> Thanks,
> Pedro Alves

Hello Pedro,

Thanks for your answer. I turned "set debug remote 1" on again, and  
strangely, the output tells me that "set-register" is not supported,  
but only when I'm able to change the register value (see the output  
below). First, I've tried with a register which I can successfully  
change the value, and then with another one where I wasn't able to do  
it in the past. Do you know why this behaviour occurs? Meanwhile, I'll  
ask the same in the KGDB mailing list. Like I've mentioned, output  
below:

(gdb) info reg $es
es             0x7b	123
(gdb) set $es = 0x7c
Sending packet: $Pd=7c000000#ab...Ack
Packet received:
Packet P (set-register) is NOT supported
Sending packet:  
$G14000000ccb59cc00000000067000000089fcbf10c9fcbf1ac309dc00000000079154ac09600000060000000680000007b009dc07c000000ffff0000ffff0000#61...Ack
Packet received: OK
Sending packet: $g#67...Ack
Packet received:  
14000000ccb59cc00000000067000000089fcbf10c9fcbf1ac309dc00000000079154ac09600000060000000680000007b009dc07c000000ffff0000ffff0000
(gdb) info reg $es
es             0x7c	124
(gdb) info reg $ss
ss             0x68	104
(gdb) set $ss = 0x69
Sending packet:  
$G14000000ccb59cc00000000067000000089fcbf10c9fcbf1ac309dc00000000079154ac09600000060000000690000007b009dc07c000000ffff0000ffff0000#62...Ack
Packet received: OK
Sending packet: $g#67...Ack
Packet received:  
14000000ccb59cc00000000067000000089fcbf10c9fcbf1ac309dc00000000079154ac09600000060000000680000007b009dc07c000000ffff0000ffff0000
(gdb) info reg $ss
ss             0x68	104

Best regards,
João

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

* Re: Doubt using "set" command with registers
  2014-10-31 11:21   ` joaoandreferro
@ 2014-10-31 11:47     ` Pedro Alves
  2014-10-31 13:42       ` joaoandreferro
  0 siblings, 1 reply; 7+ messages in thread
From: Pedro Alves @ 2014-10-31 11:47 UTC (permalink / raw)
  To: joaoandreferro, gdb

On 10/31/2014 11:21 AM, joaoandreferro@sapo.pt wrote:
> Citando Pedro Alves <palves@redhat.com>:

>> I'd guess that it's kgdb itself that is blocking those writes.
>>
>> Try "set debug remote 1" before the "set $foo = " command.

> Thanks for your answer. I turned "set debug remote 1" on again, and  
> strangely, the output tells me that "set-register" is not supported,  
> but only when I'm able to change the register value (see the output  
> below). First, I've tried with a register which I can successfully  
> change the value, and then with another one where I wasn't able to do  
> it in the past. Do you know why this behaviour occurs? Meanwhile, I'll  
> ask the same in the KGDB mailing list. Like I've mentioned, output  
> below:
> 
> (gdb) info reg $es
> es             0x7b	123
> (gdb) set $es = 0x7c
> Sending packet: $Pd=7c000000#ab...Ack
> Packet received:
> Packet P (set-register) is NOT supported

If the P packet (write one register) is not supported, then ...

> Sending packet:  
> $G14000000ccb59cc00000000067000000089fcbf10c9fcbf1ac309dc00000000079154ac09600000060000000680000007b009dc07c000000ffff0000ffff0000#61...Ack
> Packet received: OK

... GDB tries the G packet (writes the whole set of registers in one block),
and doesn't try P again.  That's normal.

> Sending packet: $g#67...Ack
> Packet received:  
> 14000000ccb59cc00000000067000000089fcbf10c9fcbf1ac309dc00000000079154ac09600000060000000680000007b009dc07c000000ffff0000ffff0000
> (gdb) info reg $es
> es             0x7c	124
> (gdb) info reg $ss
> ss             0x68	104
> (gdb) set $ss = 0x69
> Sending packet:  
> $G14000000ccb59cc00000000067000000089fcbf10c9fcbf1ac309dc00000000079154ac09600000060000000690000007b009dc07c000000ffff0000ffff0000#62...Ack
> Packet received: OK

Here GDB went straight to the G packet, because it now knows P is
not supported.  The target accepted the write ...

> Sending packet: $g#67...Ack
> Packet received:  
> 14000000ccb59cc00000000067000000089fcbf10c9fcbf1ac309dc00000000079154ac09600000060000000680000007b009dc07c000000ffff0000ffff0000
> (gdb) info reg $ss
> ss             0x68	104

... but didn't make it really effective.
Note the "68" in the g packet (read registers) reply -- seems like kgdb is
simply ignoring the change to $ss.

Thanks,
Pedro Alves

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

* Re: Doubt using "set" command with registers
  2014-10-31 11:47     ` Pedro Alves
@ 2014-10-31 13:42       ` joaoandreferro
  0 siblings, 0 replies; 7+ messages in thread
From: joaoandreferro @ 2014-10-31 13:42 UTC (permalink / raw)
  To: Pedro Alves; +Cc: gdb






Citando Pedro Alves <palves@redhat.com>:

> On 10/31/2014 11:21 AM, joaoandreferro@sapo.pt wrote:
>> Citando Pedro Alves <palves@redhat.com>:
>
>>> I'd guess that it's kgdb itself that is blocking those writes.
>>>
>>> Try "set debug remote 1" before the "set $foo = " command.
>
>> Thanks for your answer. I turned "set debug remote 1" on again, and
>> strangely, the output tells me that "set-register" is not supported,
>> but only when I'm able to change the register value (see the output
>> below). First, I've tried with a register which I can successfully
>> change the value, and then with another one where I wasn't able to do
>> it in the past. Do you know why this behaviour occurs? Meanwhile, I'll
>> ask the same in the KGDB mailing list. Like I've mentioned, output
>> below:
>>
>> (gdb) info reg $es
>> es             0x7b	123
>> (gdb) set $es = 0x7c
>> Sending packet: $Pd=7c000000#ab...Ack
>> Packet received:
>> Packet P (set-register) is NOT supported
>
> If the P packet (write one register) is not supported, then ...
>
>> Sending packet:
>> $G14000000ccb59cc00000000067000000089fcbf10c9fcbf1ac309dc00000000079154ac09600000060000000680000007b009dc07c000000ffff0000ffff0000#61...Ack
>> Packet received: OK
>
> ... GDB tries the G packet (writes the whole set of registers in one block),
> and doesn't try P again.  That's normal.
>
>> Sending packet: $g#67...Ack
>> Packet received:
>> 14000000ccb59cc00000000067000000089fcbf10c9fcbf1ac309dc00000000079154ac09600000060000000680000007b009dc07c000000ffff0000ffff0000
>> (gdb) info reg $es
>> es             0x7c	124
>> (gdb) info reg $ss
>> ss             0x68	104
>> (gdb) set $ss = 0x69
>> Sending packet:
>> $G14000000ccb59cc00000000067000000089fcbf10c9fcbf1ac309dc00000000079154ac09600000060000000690000007b009dc07c000000ffff0000ffff0000#62...Ack
>> Packet received: OK
>
> Here GDB went straight to the G packet, because it now knows P is
> not supported.  The target accepted the write ...
>
>> Sending packet: $g#67...Ack
>> Packet received:
>> 14000000ccb59cc00000000067000000089fcbf10c9fcbf1ac309dc00000000079154ac09600000060000000680000007b009dc07c000000ffff0000ffff0000
>> (gdb) info reg $ss
>> ss             0x68	104
>
> ... but didn't make it really effective.
> Note the "68" in the g packet (read registers) reply -- seems like kgdb is
> simply ignoring the change to $ss.
>
> Thanks,
> Pedro Alves

Ok Pedro, thanks for the explanations. As I've said before, I'll try  
to obtain support on the KGDB mailing list.

Best regards,
João

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

end of thread, other threads:[~2014-10-31 13:42 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-10-28 16:02 Doubt using "set" command with registers joaoandreferro
2014-10-29  0:52 ` Pete Delaney
2014-10-29 19:05   ` joaoandreferro
2014-10-30 10:59 ` Pedro Alves
2014-10-31 11:21   ` joaoandreferro
2014-10-31 11:47     ` Pedro Alves
2014-10-31 13:42       ` joaoandreferro

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