Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2010-10

setting variables with DWARF in gdb

13 messages · 5 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Seth Grover

When I compile an FPC program for debug with DWARF symbols, GDB seemingly ignores my commands to set variables or registers when debugging:

With STABS (or whatever the default is, ie., -gw is not set):

Breakpoint 1, DOIT () at /home/tlacuache/tmp/project1.lpr:14 14 writeln(MYVAR);
(gdb) print MYVAR
$1 = 1
(gdb) set MYVAR=32
(gdb) print MYVAR
$2 = 32

With DWARF:

Breakpoint 1, DOIT () at project1.lpr:14
14 writeln(MYVAR);
(gdb) print MYVAR
$1 = 1
(gdb) SET MYVAR=32
(gdb) print MYVAR
$2 = 1

Am I doing something wrong? Should I log a bug in mantis?

-SG

This email is fiction. Any resemblance to actual events or persons living or dead is purely coincidental. Seth Grover sethdgrover[at]gmail[dot]com
Seth Grover
to Seth Grover
I *was* doing something wrong... doing a ":=" (pascal-style
assignment) rather than just "=" seems to work Ok.

-SG

This email is fiction. Any resemblance to actual events or persons living or dead is purely coincidental. Seth Grover sethdgrover[at]gmail[dot]com On Fri, Oct 29, 2010 at 10:58 AM, Seth Grover wrote: > When I compile an FPC program for debug with DWARF symbols, GDB > seemingly ignores my commands to set variables or registers when > debugging: > > With STABS (or whatever the default is, ie., -gw is not set): > > Breakpoint 1, DOIT () at /home/tlacuache/tmp/project1.lpr:14 > 14          writeln(MYVAR); > (gdb) print MYVAR > $1 = 1 > (gdb) set MYVAR=32 > (gdb) print MYVAR > $2 = 32 > > With DWARF: > > Breakpoint 1, DOIT () at project1.lpr:14 > 14          writeln(MYVAR); > (gdb) print MYVAR > $1 = 1 > (gdb) SET MYVAR=32 > (gdb) print MYVAR > $2 = 1 > > Am I doing something wrong? Should I log a bug in mantis? > > -SG > > -- > This email is fiction. Any resemblance to actual events > or persons living or dead is purely coincidental. > > Seth Grover > sethdgrover[at]gmail[dot]com >
Graeme Geldenhuys
to Seth Grover

Hi Seth,

Seth Grover wrote
I *was* doing something wrong... doing a ":=" (pascal-style assignment) rather than just "=" seems to work Ok.

I was battling with this too, thanks. Do you know how to move the execution point back to an earlier line? eg: I want to execute the program to call the same procedure, but with a different variable, so I want to set execution back a few source lines, change the variable, and then step forward again.

Regards,   - Graeme - _______________________________________________ fpGUI - a cross-platform Free Pascal GUI toolkit http://opensoft.homeip.net:8080/fpgui/
Jonas Maebe
to Graeme Geldenhuys
Graeme Geldenhuys wrote 5 lines
Do you know how to move the execution point back to an earlier line? eg: I want to execute the program to call the same procedure, but with a different variable, so I want to set execution back a few source lines, change the variable, and then step forward again.

Reverse execution is a new feature that was added to gdb 7.0, although you probably want to use 7.2 for the extra bug fixes. The supported targets are listed at http://www.gnu.org/software/gdb/news/reversible.html (nobody has added support for Windows yet) and the instructions on how to use it are on the wiki page linked from that page.

Jonas

Graeme Geldenhuys
to Jonas Maebe
Jonas Maebe wrote
Reverse execution is a new feature that was added to gdb 7.0, although you probably want to use 7.2 for the extra bug fixes. The supported targets are listed at http://www.gnu.org/software/gdb/news/reversible.html (nobody has added support for Windows yet) and the instructions on how to use it are on the wiki page linked from that page.

That's not exactly what I meant. I remember back in Delphi 7 (maybe even as far back as D5), that I changed the execution point, so it can re-execute a procedure but with different values - no need to recompile or restart the application.

Delphi 2010 has improved on that by simply dragging and dropping the execution point while in debug mode. I did some googleing and remember I fiddled with the CPU registers to accomplish what I did, but couldn't remember what registers.

Google found my exact answer. I see I can modify the CPU registers in MSEide, but I don't think this is possible with Lazarus IDE. Just tried, and it seems to work in MSEide - I'll do more testing to confirm. The register in question was EIP.

Here is the google link I found.

http://www.deltics.co.nz/blog/?p=606

Regards,   - Graeme - _______________________________________________ fpGUI - a cross-platform Free Pascal GUI toolkit http://opensoft.homeip.net:8080/fpgui/
Graeme Geldenhuys
to Graeme Geldenhuys
Graeme Geldenhuys wrote
Google found my exact answer. I see I can modify the CPU registers in MSEide, but I don't think this is possible with Lazarus IDE. Just tried, and it seems to work in MSEide - I'll do more testing to confirm. The register in question was EIP.

Definitely not possible with Lazarus IDE, and definitely works with MSEide. The Watches window in MSEide also allows me to modify variable values by simply typing in another value. I successfully repeated the same procedure call over and over using different values in MSEide and resetting the EIP register without problems. :-) Kudos to Martin Schreiber for a excellent job he has done with MSEide!

Regards,   - Graeme - _______________________________________________ fpGUI - a cross-platform Free Pascal GUI toolkit http://opensoft.homeip.net:8080/fpgui/
Jonas Maebe
to Graeme Geldenhuys: That's not exactly what I meant. I remember back in Delphi 7 (maybe even as far back as…
Graeme Geldenhuys wrote 8 lines
On 30 October 2010 11:26, Jonas Maebe wrote: > > Reverse execution is a new feature that was added to gdb 7.0, although you probably want to use 7.2 for the extra bug fixes. The supported targets are listed at http://www.gnu.org/software/gdb/news/reversible.html (nobody has added support for Windows yet) and the instructions on how to use it are on the wiki page linked from that page. That's not exactly what I meant. I remember back in Delphi 7 (maybe even as far back as D5), that I changed the execution point, so it can re-execute a procedure but with different values - no need to recompile or restart the application.

Reverse execution does not involve recompiling nor restarting the application either.

Show quoted text 9 lines
Delphi 2010 has improved on that by simply dragging and dropping the execution point while in debug mode. I did some googleing and remember I fiddled with the CPU registers to accomplish what I did, but couldn't remember what registers. Google found my exact answer. I see I can modify the CPU registers in MSEide, but I don't think this is possible with Lazarus IDE. Just tried, and it seems to work in MSEide - I'll do more testing to confirm. The register in question was EIP.

Simply changing EIP is less safe that reverse execution, because it does not roll back changes to memory or other registers that may be important.

Jonas

Graeme Geldenhuys
to Graeme Geldenhuys: Definitely not possible with Lazarus IDE, and definitely works with MSEide. The Watches…
Graeme Geldenhuys wrote 7 lines
Definitely not possible with Lazarus IDE, and definitely works with MSEide. The Watches window in MSEide also allows me to modify variable values by simply typing in another value. I successfully repeated the same procedure call over and over using different values in MSEide and resetting the EIP register without problems. :-)   Kudos to Martin Schreiber for a excellent job he has done with MSEide!

And I was using GDB 6.8-ubuntu on my laptop (running Ubuntu 8.04 32-bit).

Regards,   - Graeme - _______________________________________________ fpGUI - a cross-platform Free Pascal GUI toolkit http://opensoft.homeip.net:8080/fpgui/
Graeme Geldenhuys
to Jonas Maebe: Reverse execution does not involve recompiling nor restarting the application either.…
Jonas Maebe wrote
Reverse execution does not involve recompiling nor restarting the application either.

Yes I understand that, but what I have done, should work on Windows as well as Linux, irrespective in GDB supports it or not.

Simply changing EIP is less safe that reverse execution, because it does not roll back changes to memory or other registers that may be important.

True, but for what I need it, simply changing the value of a variable, and re-executing a function using that variable, it works perfectly. This is a quick and easy way to test a function using different values, while you are debugging a issue with that function.

Regards,   - Graeme - _______________________________________________ fpGUI - a cross-platform Free Pascal GUI toolkit http://opensoft.homeip.net:8080/fpgui/
ABorka
to Graeme Geldenhuys: That's not exactly what I meant. I remember back in Delphi 7 (maybe even as far back as…
Graeme Geldenhuys wrote 9 lines
On 30 October 2010 11:26, Jonas Maebe wrote: > > Reverse execution is a new feature that was added to gdb 7.0, although you probably want to use 7.2 for the extra bug fixes. The supported targets are listed at http://www.gnu.org/software/gdb/news/reversible.html (nobody has added support for Windows yet) and the instructions on how to use it are on the wiki page linked from that page. > That's not exactly what I meant. I remember back in Delphi 7 (maybe even as far back as D5), that I changed the execution point, so it can re-execute a procedure but with different values - no need to recompile or restart the application.

.
.snip
.

This was there back in Delphi 5 already. All you needed to do is to switch to CPU view, and "Set new CS:IP" and you could re-execute that part of the code. It is one of the things I really really miss (it saved hours of wasted time when debugging of the handling of different conditions in the code)

Not to mention to see every variable and object property value I want, without a doctorate in GDB and Lazarus internals.

AB

Graeme Geldenhuys
to ABorka
ABorka wrote
This was there back in Delphi 5 already. All you needed to do is to switch

I thought so, because the project I remember working on was written in D5 (many years back), and I was pretty sure I use this feature then.

code. It is one of the things I really really miss (it saved hours of wasted time when debugging of the handling of different conditions in the code)

My point exactly.

Not to mention to see every variable and object property value I want, without a doctorate in GDB and Lazarus internals.

I'd suggest you try MSEide for debugging then. Yes it still uses GDB, but its debugging support (breakpoints, breakpoints with counters, breakpoints at assembly level, watchpoints, CPU view (editable), Watches (also editable), Assembly view etc are years ahead of Lazarus. Debugging support in Lazarus is actually quite terrible. The Lazarus team have totally lost their focus and are obsessed with eye-candy only. The sad thing is, Lazarus is what most people use when they start using FPC, and just get used to the crappiness over time and think there is nothing better out there. They are wrong.

MSEide takes some getting used too (simply because it's not trying to be a Delphi clone), but once you understand the basics and worked with it for a few days, the way the projects and other settings are managed actually seems very logical. It took me a while to figure out how to setup my ideal project templates too - this now saves me a lot of time, and all code is navigateable inside the source editor too. I don't use the LCL or MSEgui toolkits, but even if you did use LCL, you can still use MSEide for debugging purposes - as good _working_ GUI frontend for GDB and an editor that knows about Object Pascal. I frequently switch between the two IDE's while working on the same project, but lately spend more and more time in MSEide.

Regards,   - Graeme - _______________________________________________ fpGUI - a cross-platform Free Pascal GUI toolkit http://opensoft.homeip.net:8080/fpgui/
Michael Van Canneyt
to ABorka: . .snip . This was there back in Delphi 5 already. All you needed to do is to switch to…
ABorka wrote 23 lines
On 10/30/2010 04:07, Graeme Geldenhuys wrote: > On 30 October 2010 11:26, Jonas Maebe wrote: >> >> Reverse execution is a new feature that was added to gdb 7.0, although you >> probably want to use 7.2 for the extra bug fixes. The supported targets >> are listed at http://www.gnu.org/software/gdb/news/reversible.html (nobody >> has added support for Windows yet) and the instructions on how to use it >> are on the wiki page linked from that page. >> > > That's not exactly what I meant. I remember back in Delphi 7 (maybe > even as far back as D5), that I changed the execution point, so it can > re-execute a procedure but with different values - no need to > recompile or restart the application. . .snip . This was there back in Delphi 5 already. All you needed to do is to switch to CPU view, and "Set new CS:IP" and you could re-execute that part of the code. It is one of the things I really really miss (it saved hours of wasted time when debugging of the handling of different conditions in the code)

Strange. Never even knew it was there, let alone used it, despite working with Delphi every day since 15 years... Use cases vary indeed !

Michael.

Graeme Geldenhuys
to Michael Van Canneyt
Michael Van Canneyt wrote
Strange. Never even knew it was there, let alone used it, despite working with Delphi every day since 15 years... Use cases vary indeed !

Something I knew about Delphi you didn't! :-) What do you keep telling me: "You are never to old to learn." ;-)

Regards,   - Graeme - _______________________________________________ fpGUI - a cross-platform Free Pascal GUI toolkit http://opensoft.homeip.net:8080/fpgui/