Recent

Author Topic: how to debug package?  (Read 822 times)

powerpcer

  • Full Member
  • ***
  • Posts: 100
how to debug package?
« on: January 03, 2023, 08:39:34 am »
i had change IDE to DEBUG MODE, and rebuild IDE, but still cannot set break point on package.

balazsszekely

  • Guest
Re: how to debug package?
« Reply #1 on: January 03, 2023, 11:08:02 am »
i had change IDE to DEBUG MODE, and rebuild IDE, but still cannot set break point on package.
1. Go to Package->Options->Custom Options
2. Add  $(IDEBuildOptions) to the Custom Options memo

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9872
  • Debugger - SynEdit - and more
    • wiki
Re: how to debug package?
« Reply #2 on: January 03, 2023, 02:22:52 pm »
Or just open the option dialog for the package in question, and under debugging enable "debug info" and set it to one of the Dwarf values (depending on what debugger you use).


If by package you refer to the packages that come with fpc, then you need to build your own fpc from scratch.

powerpcer

  • Full Member
  • ***
  • Posts: 100
Re: how to debug package?
« Reply #3 on: January 03, 2023, 03:04:30 pm »
i am debugging the fcl-db, the dbf.pas. it belongs to dbflaz.lpk
@Martin_fr  i check dbflaz.lpk, all debug info was already there.
@GetMem  i check $(IDEBuildOptions) on Custom Options already.
but debugging not work

iret

  • New Member
  • *
  • Posts: 15
Re: how to debug package?
« Reply #4 on: January 03, 2023, 03:36:41 pm »
Quote
i am debugging the fcl-db, the dbf.pas. it belongs to dbflaz.lpk

I guess you can simply do that like this:

  • Remove the dbflaz dependency from your project
  • Add the path to tdbf files to the compiler path
  • recompile

Concerning TDbf in general:








Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9872
  • Debugger - SynEdit - and more
    • wiki
Re: how to debug package?
« Reply #5 on: January 03, 2023, 03:40:10 pm »
"fcl-db" is part of fpc.

The lpk package file is not used. The units are compiled once when fpc is build via its Makefile.

You have to rebuild fpc (using the Makefile / you may have to download fpc sources from git / not sure if the Lazarus install contains all the files needed for a rebuild).

Even if you force-fully rebuild the package, it won't work. Because the resulting ppu will be in the wrong location. And also because any other depending fpc package will not be recompiled.


In some cases, there is a workaround....

---- EDIT: this also suffers from the non debug ppu still being in path - so likely not working...

If you use no other fpc package that includes fcl-db (including not using any lazarus or 3rd party package, that in any way uses any fpc package that uses fcl-db)....

You maybe able to make a copy of fcl-db (and rename it, or you will likely have a whole new lot of troubles), then open that package and recompile it.
Then find any package that uses fcl-db, remove fcl-db from its dependencies, and add your copy instead.

It's still a lot of work.
It only works if all pre-conditions are met.
And you must change some dependencies, which you later have to restore.


iret's idea may also work. But you need to add the path to each package that needs it. And playing with paths is also of the category "you better know what you do".

Mind that you can't easily remove the fcl-db ppu from the include paths. So the may creep in, and cause trouble.



You can easily get a debug build of fpc, if you use FpcUpDeluxe.

At least on Windows it is easy enough to switch between different fpc builds.

On Linux and MacOS that requires some extra steps. Not sure....
« Last Edit: January 03, 2023, 03:46:09 pm by Martin_fr »

balazsszekely

  • Guest
Re: how to debug package?
« Reply #6 on: January 03, 2023, 03:49:50 pm »
@powerpcer
Quote
I am debugging the fcl-db, the dbf.pas
In order to debug fpc packages you need to rebuild fpc with -g -gl -O-
As @Martin_fr already mentioned, the easiest option is to create a secondary installation with fpcupdeluxe, which won't interfere with your current installation:
1. Download fpcupdeluxe: https://github.com/LongDirtyAnimAlf/fpcupdeluxe/releases/latest
2. Before install, got to Setup->FPC Options then type -g -gl -O-(see attached image)

wp

  • Hero Member
  • *****
  • Posts: 11916
Re: how to debug package?
« Reply #7 on: January 03, 2023, 04:33:02 pm »
Entering fcl units with the debugger is one part of the story. The other part is: once you found a bug in the fcl and have an idea how to fix it, you must modify the fcl/rtl unit and rebuild the entire fpc just to test it - this is a lengthy process.

A possibility to speed it up is to do which generally is not recommended: Add the fcl/rtl directory of the unit to be debugged to the search path of your project (Project > Options > Paths > Other unit paths). Try to compile. If no other fpc unit depends on it the compiler will be happy and finish its job. If not, it will give you a message which other unit must be recompiled. Add its directory to the search path, too. Continue until the project compiles -- it can require several iterations, though. Now you can apply your changes and test or refine them as if the fpc unit were part of your project.

You can restore the original fpc by removing the fcl units from your search path and by deleting the output directory of your project.


powerpcer

  • Full Member
  • ***
  • Posts: 100
Re: how to debug package?
« Reply #8 on: January 03, 2023, 04:38:05 pm »
wow....this is not a happy new year news for me.
i just want find the way to fix the Big5 problem on it.
just let me check if it is worth.

 

TinyPortal © 2005-2018