Recent

Author Topic: Debug Lazarus Code - problem  (Read 1897 times)

J-23

  • Full Member
  • ***
  • Posts: 108
Debug Lazarus Code - problem
« on: June 24, 2020, 10:20:17 pm »
Hello,

I have a problem debugging the Lazarus project.

I have installed:
Code: Pascal  [Select][+][-]
  1. C:\LazarusIDE - development environment;
  2. C:\ Lazarus - second instance (to debug Lazarus code);
  3.  
I put a breakpoint in the file:
Code: Pascal  [Select][+][-]
  1. C: \Lazarus\components\ideintf\PropEdits.pas
  2.  
Run:
Code: Pascal  [Select][+][-]
  1. C:\Lazarus\ ide\lazarus.lpi
  2.  
I stop there where the breakpoint is but open the file with
Code: Pascal  [Select][+][-]
  1. C: \lazarusIDE\components\ideintf\PropEdits.pas
  2.  
and goes after the above file instead of:
Code: Pascal  [Select][+][-]
  1. C:\ Lazarus\ components\ ideintf\PropEdits.pas
  2.  

Why is it like that?

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9908
  • Debugger - SynEdit - and more
    • wiki
Re: Debug Lazarus Code - problem
« Reply #1 on: June 24, 2020, 10:42:05 pm »
First of all, you can debug with just one install.

The debugged instance, can be the same as the debugging one.
If you like you can pass the debugged instance a different primary conf path.

Second, in any case you need to rebuild the IDE you want to debug by hand. F9 will not compile it proper.  (At least I have not found a way...)
That is easier if all is in one install, unless the change you try to debug is crashing. (But even then, just don't restart the main IDE - I do it that way all the time).

I am not 100% sure on your question, but a few pointers, if you want to follow them up....

Maybe the lazarus.lpi contains: $(LazarusDir) Or similar? That would resolve to the development ide.

As for, why in this case, do the breakpoints work?
Well  the debugger falls back to using the filename without path. So it is able to set the breakpoints anyway.


Also not sure, but: You did build the second instance, in its own folder? The compiler would have put the path of the 2nd instance into the debug info?
If you copied the existing exe from the development folder, the debug info may have full path to that folder, and the debugger could report that back to the IDE....

J-23

  • Full Member
  • ***
  • Posts: 108
Re: Debug Lazarus Code - problem
« Reply #2 on: June 24, 2020, 10:59:13 pm »
Also not sure, but: You did build the second instance, in its own folder? The compiler would have put the path of the 2nd instance into the debug info?
If you copied the existing exe from the development folder, the debug info may have full path to that folder, and the debugger could report that back to the IDE....

Steps I took:
1. I installed in C:\LazarusIDE - programming environment
2. I installed in C:\Lazarus - by selecting the second instance of Lazarus in the installer

J-23

  • Full Member
  • ***
  • Posts: 108
Re: Debug Lazarus Code - problem
« Reply #3 on: June 24, 2020, 11:24:57 pm »
One instance debug for me doesn't work at all (probably I am doing something wrong)

Somewhere described step by step how to do it? or some video on Youtube

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9908
  • Debugger - SynEdit - and more
    • wiki
Re: Debug Lazarus Code - problem
« Reply #4 on: June 24, 2020, 11:36:10 pm »
For one install IDE debug:

Outer IDE (OI): the one doing the debugging
Inner IDE (II): the one being debugged.

- Start OI.
- Open project: ide/lazarus.lpi
- If desired: Run > Run Params specify --primary-config-path=..... (for separate conf / also helps remember different window location)

Before each debugging, if any code was changed:
  Tools > Build IDE
This is the one point that can occasionally go wrong. If the last debug session did not exit proper, and lazarus.exe (on windows) is locked, then the IDE can not replace it.
Instead it will build lazarus.new.exe  => In this case you need to restart, to get the exe renamed.
Normally it build lazarus.exe after having renamed the previous exe to lazarus.old.exe
The messages window will show the name for a very short time, while linking.

Now that the lazarus.exe has been compiled => use F9.
II will start in the debugger.


For info: The lazarus.lpi does not have a compiler set. So the project can not be build (that is done via the tools menu / that way it can build with the configured packages). Running works like any other project.

I do this all the time. Its big fun debugging the debugger, while the debugger is debugging. OI -> II -> test-project.

J-23

  • Full Member
  • ***
  • Posts: 108
Re: Debug Lazarus Code - problem
« Reply #5 on: June 25, 2020, 01:41:09 am »
Hi,
Can you write it in points?

Because I tried to do it according to your description but after firing Lazarus.lpi (F9) gets step by step but also gets AV when calling the form.

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9908
  • Debugger - SynEdit - and more
    • wiki
Re: Debug Lazarus Code - problem
« Reply #6 on: June 25, 2020, 03:04:48 am »
1) Open IDE
2) open project ide/lazarus.lpi
2a) optional: set primary conf as param to the IDE, in run-params
3) Tools > Build lazarus
3a) Make sure linking says "lazarus.exe" and not "lazarus.new.exe"
  or check your install folder. There MUST NOT be a "lazarus.new.exe" => if there is, restart IDE, and continue with "4)"
4) RUN  / F9
5) Wait a few secs for the IDE to start.
  Watch the title, the new IDE comes up in the same location, but it will not say "debugging" in the title.
  Move the new IDE window, so you can see both windows


Set breakpoints as needed, before or after starting the debugger.


Which of the 2 IDE gets the access violation?
If the inner (being debugged) IDE has an AV, then isn't that why it runs in the debugger?


About "2a" specifying a diff conf path allows the debugged IDE to remember its window locations, so once you re-arranged all windows (and exited the debugged IDE normally), the windows will appear in their own locations. Making it easier to distinguish the 2 IDEs.

---
I have done the above steps with GDB and fpdebug (fpdebug in lazarus trunk)
« Last Edit: June 25, 2020, 03:09:01 am by Martin_fr »

J-23

  • Full Member
  • ***
  • Posts: 108
Re: Debug Lazarus Code - problem
« Reply #7 on: June 26, 2020, 12:20:40 am »
Hi,
On version 2.0.8, when I opened lazarus.lpi and placed a breakpoint, I got AV at pressing F12 (Showing Form).

I compiled version 2.1.0 (trunk) and everything works as you describe. The IDE debuging is valid.

Thank you for your help and thank you for the movie at PM.

 

TinyPortal © 2005-2018