* Setting registers
@ 2007-06-13 10:28 Indira
2007-06-13 13:45 ` Dave Korn
0 siblings, 1 reply; 11+ messages in thread
From: Indira @ 2007-06-13 10:28 UTC (permalink / raw)
To: gdb
Hi,
I was writing a macro in which i was trying to the variable ebp and eip as,
set variable $ebp = *(int *)($sp+8)
set variable $eip = *(int *)($sp+36)
but, even though by doing this th eregister values dont get updated.
Why is this so? Can anyone help me on this?
Thanks in advance
--
Indu :)
Smile.... & Make others Smile :)
^ permalink raw reply [flat|nested] 11+ messages in thread
* RE: Setting registers
2007-06-13 10:28 Setting registers Indira
@ 2007-06-13 13:45 ` Dave Korn
2007-06-15 12:55 ` Indira
0 siblings, 1 reply; 11+ messages in thread
From: Dave Korn @ 2007-06-13 13:45 UTC (permalink / raw)
To: 'Indira', gdb
On 13 June 2007 11:28, Indira wrote:
> Hi,
>
> I was writing a macro in which i was trying to the variable ebp and eip as,
>
> set variable $ebp = *(int *)($sp+8)
> set variable $eip = *(int *)($sp+36)
>
> but, even though by doing this th eregister values dont get updated.
> Why is this so? Can anyone help me on this?
Dunno, works fine for me:
Breakpoint 1, main () at time.c:13
13 { double t0 = get_time(), t1 = get_time();
(gdb) info regis
eax 0x10 16
ecx 0x401080 4198528
edx 0x4c 76
ebx 0x0 0
esp 0x23cc80 0x23cc80
ebp 0x23ccb8 0x23ccb8
esi 0x611001a0 1628438944
edi 0x401430 4199472
eip 0x40108b 0x40108b <main+11>
eflags 0x202 [ IF ]
cs 0x1b 27
ss 0x23 35
ds 0x23 35
es 0x23 35
fs 0x3b 59
gs 0x0 0
(gdb) set variable $ebp = *(int *)($sp+8)
(gdb) set variable $eip = *(int *)($sp+36)
(gdb) info regis
eax 0x10 16
ecx 0x401080 4198528
edx 0x4c 76
ebx 0x0 0
esp 0x23cc80 0x23cc80
ebp 0x61166a78 0x61166a78
esi 0x611001a0 1628438944
edi 0x401430 4199472
eip 0x2f 0x2f
eflags 0x202 [ IF ]
cs 0x1b 27
ss 0x23 35
ds 0x23 35
es 0x23 35
fs 0x3b 59
gs 0x0 0
(gdb)
You're not by any chance trying to debug a core file are you?
cheers,
DaveK
--
Can't think of a witty .sigline today....
^ permalink raw reply [flat|nested] 11+ messages in thread* Re: Setting registers
2007-06-13 13:45 ` Dave Korn
@ 2007-06-15 12:55 ` Indira
2007-06-15 14:37 ` Eli Zaretskii
0 siblings, 1 reply; 11+ messages in thread
From: Indira @ 2007-06-15 12:55 UTC (permalink / raw)
To: Dave Korn; +Cc: gdb
Yes I am debuggin a core file. We cant set registers while debuggin a core file?
On 6/13/07, Dave Korn <dave.korn@artimi.com> wrote:
> On 13 June 2007 11:28, Indira wrote:
>
> > Hi,
> >
> > I was writing a macro in which i was trying to the variable ebp and eip as,
> >
> > set variable $ebp = *(int *)($sp+8)
> > set variable $eip = *(int *)($sp+36)
> >
> > but, even though by doing this th eregister values dont get updated.
> > Why is this so? Can anyone help me on this?
>
> Dunno, works fine for me:
>
> Breakpoint 1, main () at time.c:13
> 13 { double t0 = get_time(), t1 = get_time();
> (gdb) info regis
> eax 0x10 16
> ecx 0x401080 4198528
> edx 0x4c 76
> ebx 0x0 0
> esp 0x23cc80 0x23cc80
> ebp 0x23ccb8 0x23ccb8
> esi 0x611001a0 1628438944
> edi 0x401430 4199472
> eip 0x40108b 0x40108b <main+11>
> eflags 0x202 [ IF ]
> cs 0x1b 27
> ss 0x23 35
> ds 0x23 35
> es 0x23 35
> fs 0x3b 59
> gs 0x0 0
> (gdb) set variable $ebp = *(int *)($sp+8)
> (gdb) set variable $eip = *(int *)($sp+36)
> (gdb) info regis
> eax 0x10 16
> ecx 0x401080 4198528
> edx 0x4c 76
> ebx 0x0 0
> esp 0x23cc80 0x23cc80
> ebp 0x61166a78 0x61166a78
> esi 0x611001a0 1628438944
> edi 0x401430 4199472
> eip 0x2f 0x2f
> eflags 0x202 [ IF ]
> cs 0x1b 27
> ss 0x23 35
> ds 0x23 35
> es 0x23 35
> fs 0x3b 59
> gs 0x0 0
> (gdb)
>
>
> You're not by any chance trying to debug a core file are you?
>
> cheers,
> DaveK
> --
> Can't think of a witty .sigline today....
>
>
--
Indu :)
Smile.... & Make others Smile :)
^ permalink raw reply [flat|nested] 11+ messages in thread* Re: Setting registers
2007-06-15 12:55 ` Indira
@ 2007-06-15 14:37 ` Eli Zaretskii
2007-06-15 14:43 ` Paul Koning
2007-06-18 12:01 ` Indira
0 siblings, 2 replies; 11+ messages in thread
From: Eli Zaretskii @ 2007-06-15 14:37 UTC (permalink / raw)
To: Indira; +Cc: dave.korn, gdb
> Date: Fri, 15 Jun 2007 18:25:53 +0530
> From: Indira <yoursindu@gmail.com>
> Cc: gdb@sourceware.org
>
> Yes I am debuggin a core file. We cant set registers while debuggin a core file?
No, you can't. The program is dead, all you have is the last snapshot
of its memory. Even if you could set registers (and other variables),
it would be of no practical use, since you cannot run the program.
All you can do is examine its memory and call stack.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Setting registers
2007-06-15 14:37 ` Eli Zaretskii
@ 2007-06-15 14:43 ` Paul Koning
2007-06-15 14:48 ` Daniel Jacobowitz
2007-06-18 12:01 ` Indira
1 sibling, 1 reply; 11+ messages in thread
From: Paul Koning @ 2007-06-15 14:43 UTC (permalink / raw)
To: eliz; +Cc: yoursindu, dave.korn, gdb
>>>>> "Eli" == Eli Zaretskii <eliz@gnu.org> writes:
>> Date: Fri, 15 Jun 2007 18:25:53 +0530 From: Indira
>> <yoursindu@gmail.com> Cc: gdb@sourceware.org
>>
>> Yes I am debuggin a core file. We cant set registers while
>> debuggin a core file?
Eli> No, you can't. The program is dead, all you have is the last
Eli> snapshot of its memory. Even if you could set registers (and
Eli> other variables), it would be of no practical use, since you
Eli> cannot run the program. All you can do is examine its memory
Eli> and call stack.
Sometimes it would be useful to be able to. If the stack is corrupt,
or the return address (for processor types that have such a thing) and
you can figure out the correct values, it would be very handy to be
able to tell gdb "here is the right value" and let it use that for
subsequent analysis.
Right now, that's not possible. So if I have a smashed stack, I have
to walk it by hand -- which means looking at local variables is
essentially undoable. It's not always simply a matter of giving the
right SP to gdb, but often it is.
paul
^ permalink raw reply [flat|nested] 11+ messages in thread* Re: Setting registers
2007-06-15 14:43 ` Paul Koning
@ 2007-06-15 14:48 ` Daniel Jacobowitz
2007-06-15 15:24 ` Paul Koning
0 siblings, 1 reply; 11+ messages in thread
From: Daniel Jacobowitz @ 2007-06-15 14:48 UTC (permalink / raw)
To: Paul Koning; +Cc: eliz, yoursindu, dave.korn, gdb
On Fri, Jun 15, 2007 at 10:41:38AM -0400, Paul Koning wrote:
> Sometimes it would be useful to be able to. If the stack is corrupt,
> or the return address (for processor types that have such a thing) and
> you can figure out the correct values, it would be very handy to be
> able to tell gdb "here is the right value" and let it use that for
> subsequent analysis.
We do get requests for this so frequently that I'm tempted to allow
modifiable registers... memory, though, would be hard.
--
Daniel Jacobowitz
CodeSourcery
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Setting registers
2007-06-15 14:48 ` Daniel Jacobowitz
@ 2007-06-15 15:24 ` Paul Koning
2007-06-15 15:33 ` Daniel Jacobowitz
2007-06-15 16:00 ` Joel Brobecker
0 siblings, 2 replies; 11+ messages in thread
From: Paul Koning @ 2007-06-15 15:24 UTC (permalink / raw)
To: drow; +Cc: eliz, yoursindu, dave.korn, gdb
>>>>> "Daniel" == Daniel Jacobowitz <drow@false.org> writes:
Daniel> On Fri, Jun 15, 2007 at 10:41:38AM -0400, Paul Koning wrote:
>> Sometimes it would be useful to be able to. If the stack is
>> corrupt, or the return address (for processor types that have such
>> a thing) and you can figure out the correct values, it would be
>> very handy to be able to tell gdb "here is the right value" and
>> let it use that for subsequent analysis.
Daniel> We do get requests for this so frequently that I'm tempted to
Daniel> allow modifiable registers... memory, though, would be hard.
Not really, you'd just have to allow writing to the corefile. I think
you'd want to disable that by default -- otherwise a slip of the
finger would mess up your carefully collected data. But after an
explicit enable it could be done.
And it's necessary if you're trying to change a register for an inner
frame.
paul
^ permalink raw reply [flat|nested] 11+ messages in thread* Re: Setting registers
2007-06-15 15:24 ` Paul Koning
@ 2007-06-15 15:33 ` Daniel Jacobowitz
2007-06-15 16:00 ` Joel Brobecker
1 sibling, 0 replies; 11+ messages in thread
From: Daniel Jacobowitz @ 2007-06-15 15:33 UTC (permalink / raw)
To: Paul Koning; +Cc: eliz, yoursindu, dave.korn, gdb
On Fri, Jun 15, 2007 at 11:21:37AM -0400, Paul Koning wrote:
> Not really, you'd just have to allow writing to the corefile. I think
> you'd want to disable that by default -- otherwise a slip of the
> finger would mess up your carefully collected data. But after an
> explicit enable it could be done.
Um, no. We'd also have to maintain shadow buffers in memory for the
contents of RAM instead of reading it from disk.
--
Daniel Jacobowitz
CodeSourcery
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Setting registers
2007-06-15 15:24 ` Paul Koning
2007-06-15 15:33 ` Daniel Jacobowitz
@ 2007-06-15 16:00 ` Joel Brobecker
1 sibling, 0 replies; 11+ messages in thread
From: Joel Brobecker @ 2007-06-15 16:00 UTC (permalink / raw)
To: Paul Koning; +Cc: drow, eliz, yoursindu, dave.korn, gdb
> Not really, you'd just have to allow writing to the corefile. I think
> you'd want to disable that by default -- otherwise a slip of the
> finger would mess up your carefully collected data. But after an
> explicit enable it could be done.
Actually, this is already possible with "set write on".
--
Joel
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Setting registers
2007-06-15 14:37 ` Eli Zaretskii
2007-06-15 14:43 ` Paul Koning
@ 2007-06-18 12:01 ` Indira
2007-06-18 12:41 ` Dave Korn
1 sibling, 1 reply; 11+ messages in thread
From: Indira @ 2007-06-18 12:01 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: dave.korn, gdb
I just want to set the esp, eip and ebp registers and print backtrace.
Can i do so while debugging a core file?
On 6/15/07, Eli Zaretskii <eliz@gnu.org> wrote:
> > Date: Fri, 15 Jun 2007 18:25:53 +0530
> > From: Indira <yoursindu@gmail.com>
> > Cc: gdb@sourceware.org
> >
> > Yes I am debuggin a core file. We cant set registers while debuggin a core file?
>
> No, you can't. The program is dead, all you have is the last snapshot
> of its memory. Even if you could set registers (and other variables),
> it would be of no practical use, since you cannot run the program.
> All you can do is examine its memory and call stack.
>
--
Indu :)
Smile.... & Make others Smile :)
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2007-06-18 12:41 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-06-13 10:28 Setting registers Indira
2007-06-13 13:45 ` Dave Korn
2007-06-15 12:55 ` Indira
2007-06-15 14:37 ` Eli Zaretskii
2007-06-15 14:43 ` Paul Koning
2007-06-15 14:48 ` Daniel Jacobowitz
2007-06-15 15:24 ` Paul Koning
2007-06-15 15:33 ` Daniel Jacobowitz
2007-06-15 16:00 ` Joel Brobecker
2007-06-18 12:01 ` Indira
2007-06-18 12:41 ` Dave Korn
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox