* * *

Author Topic: Lazarus 9.30 : How can I use the debugger ?  (Read 3233 times)

progamat

  • New member
  • *
  • Posts: 32
Lazarus 9.30 : How can I use the debugger ?
« on: May 31, 2011, 12:01:39 pm »
Hi,

With the 0.9.30, if I do a F4 or F9, there is a my_project.lrs page opening in the IDE, but not really useful for me.

How can I get an highlighten line under the cursor, in the unit.pas window, like with the delphi application, the cursor going on toward the code line, after a F8, and a watch window where I can check some variables ?

Tx a lot for your help

Martin_fr

  • Hero Member
  • *****
  • Posts: 1218
Re: Lazarus 9.30 : How can I use the debugger ?
« Reply #1 on: May 31, 2011, 12:39:50 pm »
You should see such a highlight line with F4 (or F8). F9 only stops at a breakpoint.

So lets check your settings.

First of all: what OS? (win, Linux, Mac)?
32 bit or 64 bit?

For Win 64 bit, and Mac 64 bit please see (you may want to have a look anyway):
http://wiki.lazarus.freepascal.org/GDB_Debugger_Tips

From the menu ("Environments" or "Tools" menu, depends on Lazarus Version) choose "Options". In the dialog, go to the "debugger" page. Ensure the debugger type is gdb, and a debugger exe is selected.
If no exe is selected: On windows it is in a folder called "mingw" in you Lazarus install dir), on linux it is /usr/bin/gdb (well by default)

Next, while your own project is open (needs to be done for each project you work on) from the menu "project" open "project options".
Select the page "Linking" make sure you select one of the debug symbol options (either the one that ends in "(-g)" or "(-gw)".
Ensure you do NOT use smart linking, ensure you do not "strip symbols", ensure you do not have optimization enabled.
Note, your executable size should be several MB ( 10 to 15 MB) for a simple form. For release builds you can unselect those options, or use "strip.exe"

Then rebuild your project.

You can set breakpoints, by clicking on the gutter
Watches and other windows are in the "view" menu, at the bottom, sub-menu: "Debug windows"

progamat

  • New member
  • *
  • Posts: 32
Re: Lazarus 9.30 : How can I use the debugger ?
« Reply #2 on: June 01, 2011, 12:33:51 pm »
Tx a lot for your reply

My system is Vista, and the installed lazarus is win32

I scrupulously followed all your advices, all was fitted good, except the Optimizations for code generation : level1 was checked, now put at level 0.

But a F4 or F9 always opens this unit.lrs page, and the cursor don't stay in unit window, as soon as a F8 or F7

yet, a F8, and the enlighted line is moving in this lrs page, but a
#7#13'ecGotoMarker9'#8'ShortCut'#3'9@'#0#1#7'Command'#7#12'ecSetMarker0'#8'S

is not useful for me.

If I do a F4 on some line of a Button.OnClick method, the exe should have to open the form, with this button, or am I wrong ?

Delphi does, in all cases, but not the lazarus debugger, going forward in this my_project.lrs page

And is it possible to dock the Watches Window with the unit.pas window ?



Martin_fr

  • Hero Member
  • *****
  • Posts: 1218
Re: Lazarus 9.30 : How can I use the debugger ?
« Reply #3 on: June 01, 2011, 01:56:22 pm »
Ok "optimization = -O1" is actually fine too.

The unit1.LRS file? that is very odd.

Which color is the highlight of the line? (red, grey?)
On the left (in the gutter) is there:
- a green arrow? (on the line)
- blue dots (on this or any other line) ?

Using F8 your first stop should be in the LPR file.

I can confirm the "F4 seems to sometime not work. Not sure why. The correct command is send to gdb, yet it does not always stop...

So best to set a breakpoint "F5"

- Does the line-number match the line that should be highlighted in unit1.pas?
- Open the stack window, does that show the correct location? Does a double click in the stack window work (go to correct location)?


- On the linking page, which settings to you use? -g, -gl and or -gw? (see the end of the text for each checkbox)

- And can you please attach the output of the "debug output" window? as described on http://wiki.lazarus.freepascal.org/GDB_Debugger_Tips#Log_info_for_debug_session


---------
In order to dock windows, you must install one of the Docking packages. AnchorDockingDsgn. Try it. Questions about anchor docking please in a separate thread/topic

progamat

  • New member
  • *
  • Posts: 32
Re: Lazarus 9.30 : How can I use the debugger ?
« Reply #4 on: June 03, 2011, 01:31:53 pm »
Tx 4 your reply.

I will reply to your questions asap : I have problems of internet at home, at the moment.


progamat

  • New member
  • *
  • Posts: 32
Re: Lazarus 9.30 : How can I use the debugger ?
« Reply #5 on: June 12, 2011, 12:49:10 am »
Finally,

I found what was wrong : I put a breakpoint, inavertently, between the last end, and the initialization {$I unit.lrs}.

Now, all is working, but is there some way to dock the Watch window and .pas window ?


Martin_fr

  • Hero Member
  • *****
  • Posts: 1218
Re: Lazarus 9.30 : How can I use the debugger ?
« Reply #6 on: June 12, 2011, 04:09:27 am »
install one of the docking packages

AnchorDockingDsgn or EasyDockMgrDsgn

they are both in the list, in the package install dialog (package menu)

progamat

  • New member
  • *
  • Posts: 32
Re: Lazarus 9.30 : How can I use the debugger ?
« Reply #7 on: June 12, 2011, 01:53:40 pm »
Your help is really appreciate.

Those packages are to dock forms at running time, or am I wrong ?

I just need to dock the watch window to the unit.pas window, for a debbuging session, not at runtime of the application.

And if I could save the desk environment for a debbugging session (delphi 2005 does it, and launches the debbugger with windows docked "at the good place", it's very confortable) ....


Martin_fr

  • Hero Member
  • *****
  • Posts: 1218
Re: Lazarus 9.30 : How can I use the debugger ?
« Reply #8 on: June 12, 2011, 02:47:41 pm »
There are 4 docking packages:
2 to add docking to your app,
and 2 (the *Dsgn) to add docking to the IDE

http://wiki.lazarus.freepascal.org/New_IDE_features_since#Docked_IDE

If you need more knowledge about docking, better open a new topic, with new subject. Then you will get the people who know about docking to read it. (It does not make a diff, that you want to dock the watches window. It is the same as every other IDE window)

There are options to hide some windows, on run (see environments/options) but I do not know if they go to the extend you would like....

All debug windows have keyboard shortcuts (which can be changed).
So normally they are quick to open when/if needed.

It does not automatically close them, on debug stop.... Don't think there is a way for that....
(Maybe the docking manager can do it => then someone who knows docking would know, if so)

Then again, using the power buttons, or the new (svn only) history window => they can be used even after the debugging is stopped.
e.g personally, I do not like to edit my source, while the app is running (it can be done, but I just don't like it). So i keep the stack/watches open, and use them after the debug finished...


 

Recent

Get Lazarus at SourceForge.net. Fast, secure and Free Open Source software downloads