[Lazarus] Building a project with generics in libraries Laz1.9, FPC 3.0.2.

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

[Lazarus] Building a project with generics in libraries Laz1.9, FPC 3.0.2.

Free Pascal - Lazarus mailing list

Hi All!

I have a rather large project that I have been refactoring from an earlier version that works. It is implemented in Laz 1.6.2.  The new version takes considerable advantage of generics (which I learned first from Ada in the 1970s, then from C++ in the 1980s).  The resulting code is much smaller and cleaner than the old code.

During the development process I noticed some strangeness while debugging.  Frequently I will step through code and the debugger behaves as if recent changes have not been made (even though the source shows the changes).  This has cost me days of debugging before the problem miraculously seems to be cured.  In other words I could not figure out why all of my earlier edits seemed to take effect without my doing anything explicitly to fix the problem.  (One other side effect is that gdb will occasionally crash when I let the mouse hover over certain identifiers after a breakpoint).

I have finally discovered the apparent cause and a magic (but annoying) workaround.

The steps in the cause:

A)

a1) Edit a library routine that contains generic code.

a2) Run with or without Debug.  (The IDE recompiles the library first).  The code executes as if the edits never were made.

or

B)

b1) Edit a library routine that contains generic code.

b2) Compile the library using the Library Inspector.

b3) Run with or without Debug.  The code executes as if the edits never were made.


The magic workaround is very simple:

C)

c1) Edit a library routine that contains generic code.

c2) Compile the library using the Library Inspector.

c3) Build the program using "Run | Cleanup and build..." or sometimes just "Run | Build"  (I haven't found a pattern to decide which needs to be used so I currently use the Cleanup and build option).

c4) Run with or without Debug.  The edited code executes as written.


Note that the workaround is only necessary if the library's generic code is edited.  If the generic code is in the main code tree, the normal process of edit, run, debug, ... builds and runs correctly.

I think the problem is that the modules in the main source tree that instantiate the generics are not being updated unless the project is re-built explicitly (why? I don't know).

I will try to submit a bug report with a sample project after my current refactoring job is done (tight schedule, needs to be installed by the end of June).

Don Ziesig




--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus-ide.org/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] Building a project with generics in libraries Laz1.9, FPC 3.0.2.

Free Pascal - Lazarus mailing list

Am 22.05.2017 18:36 schrieb "Donald Ziesig via Lazarus" <[hidden email]>:
> I will try to submit a bug report with a sample project after my current refactoring job is done (tight schedule, needs to be installed by the end of June).

A bug report with a small, self contained example would indeed be nice as generic problems are sometimes a PITA to pinpoint otherwise.
If you can manage you could also try with 3.1.1 if that changes anything.

Regards,
Sven


--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus-ide.org/listinfo/lazarus