Recent

Author Topic: Debug into lazarus source code  (Read 4698 times)

calebs

  • Full Member
  • ***
  • Posts: 200
Debug into lazarus source code
« on: December 18, 2024, 06:41:03 pm »
Hello all, i've noticed this some time a go, now im using lazarus 3.7 (fixes) with fpc 3.2.2 build with fpcupdeluxe. Im using fpdebug and when i put some breakpoint on my code the execution stops as intended but when i press f8 to advance to the next line sometimes opens ASM window si have to iterate several times with f8 on asm window.
Then, someitmes iterates inside the lazarus sources and, for example, if im using Zeos, and f8 enters to debug zeos units also.
So im eternally pressing f8 to skip those units.
I could put another breakpoint in the next line  of the first and press f9 but if need to debug line by line for sure it will open asm window and other units again.
I dont remember this happen when i download the lazarus installer from the page, i recall readed in somewhere that this behaviour is because i have the unit sources of zeos and lazarus and thats the reason for this in-deep debug but the solution i've readed doesn't solved the problem.
Do you know how can i do to avoid that? i just want to debug and trace my code.
Thanks!

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 10792
  • Debugger - SynEdit - and more
    • wiki
Re: Debug into lazarus source code
« Reply #1 on: December 18, 2024, 07:48:14 pm »
As a workaround you might try Shift-F8 which should be "Step out".

But there shouldn't be an asm window as result of doing F8.
Without a lot of details, it will be very hard to guess what may cause it.

Quote
f im using Zeos, and f8 enters to debug zeos units also.
Opening the source? Not the asm. So doing correct stepping? Just into code you don't want to step?

Also is that F8 "Step over" or F7 "Step into"?

F7 might step into Zeos, if Zeos is compiled with debug info.

Open the package, and look into the package's options. It has a debug page, like the project, and if that has debug info enabled, then "Step in" will go there.
Same if "Custom Options" has -gw or similar, or if it has "$(IDEBuildOptions)" and the IDE settings have -gw or similar.

Also, if it has (by any of those, or even other means) debug info, and it is compiled with -O2 or higher, then you may see really unexpected stepping.


Of course stepping can be interrupted by exceptions. Though then there should be a notification.

However, if an ignored exception (that is not shown by the debugger) is only caught in the caller of your current function, then that is like leaving the current function, and stepping will end. (in the finally/except block of the caller).
If it can't find the source for that, then that may open the asm window.


Otherwise, as for the asm Window, I am not sure what might cause it.

Please check what the "Stack Window", and report what the top 5 frames look like, when anything unexpected happens.
Is the function in which you started in the stack? At which position? And what is at the very top?

-------------------------
Are there generics involved?




calebs

  • Full Member
  • ***
  • Posts: 200
Re: Debug into lazarus source code
« Reply #2 on: December 27, 2024, 01:37:36 am »
Hello martin! thanks for the reply!

This is what happens when i debug.
Put a breakpoint on some line and do f9
then click on a button and stops in the break (image1)
then press f8 and keeps going on each line until i get to line 1177 (dbwqsl.open) and then after f8 it opens assembler window (image2)
dbwqsl is a  TZReadOnlyQuery
if i press f8 or shift f8 it goes on debugging some lines in assembler window and then starts to open zeosdbo units (image3) that wasnt opened before as you seen on previous captures.
if i keep pressing f8 or shift f8 it keeps debugging zeosdbo files and reopening asm window and even opening lazarus source files as
win32callback.inc or application.inc or buttons.inc.
If i grow tired and put another breakpoint on line 1183 of image 1 ( listview2.clear) and press f9 and stops there, so there was debugging inside zeos and even lazarus files and all the inside files.
I haven't tried yet what you suggested yet but i don't remember this happens on previous versions of lazarus installation package downloaded from lazarus homepage. I've using fpcupdeluxe to build fixes lazarus on stable fpc and it seems that this behaviour started there.
Thanks!

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 10792
  • Debugger - SynEdit - and more
    • wiki
Re: Debug into lazarus source code
« Reply #3 on: December 27, 2024, 10:43:52 am »
I think it's the following issue https://gitlab.com/freepascal.org/lazarus/lazarus/-/issues/41226

There is a try/finally in the code you are stepping over (that does happen all the time). And for some reason it is stopping at the finally, when it should not. That finally happens to be in system.TEncoding....

This is currently only fixed in 4.0. (not sure if it is in the RC1 or only in the fixes-4 branch. Probably only the branch.

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 10792
  • Debugger - SynEdit - and more
    • wiki
Re: Debug into lazarus source code
« Reply #4 on: December 27, 2024, 10:47:25 am »
Actually, it should also be fixed in 3.7
https://gitlab.com/freepascal.org/lazarus/lazarus/-/commit/f39025ab189655bc1ac37a8682932e5821691378
since Nov, 6th.

Are you sure you 3.7 is that recent?

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 10792
  • Debugger - SynEdit - and more
    • wiki
Re: Debug into lazarus source code
« Reply #5 on: December 27, 2024, 11:47:06 am »
If you are certain that your 3.7 is newer, then please run the log as described in https://gitlab.com/freepascal.org/lazarus/lazarus/-/issues/41226#note_2194703851
And once it has happened provide
- the log
- the callstack
- the asm screenshot

Thanks.

calebs

  • Full Member
  • ***
  • Posts: 200
Re: Debug into lazarus source code
« Reply #6 on: December 29, 2024, 12:18:54 am »
thank you all!
My version is dated 2024-10-21
fpc 3.2.2
rev: lazarus_3_6_20-gc30f99e7e0x x86_64-win64-win32/win64
i downladed the 4rc1 but i readed that it can cause problems to open modified projects on 3.x so i didnt use with my projects.
I will download and build a new fixes 3.7 with fpcupdeluxe and tryagain
Thanks!!

 

TinyPortal © 2005-2018