Recent

Author Topic: [SOVED] Debugger use on OBJECT type  (Read 4649 times)

Richard Marriott

  • New Member
  • *
  • Posts: 14
[SOVED] Debugger use on OBJECT type
« on: July 16, 2025, 05:00:39 am »
Hi,
I have a lot of old Turbo Pascal code using the OBJECT type (fields and methods). I have built a Lazarus IDE interface to use it but I can't get the Debugger to show any of the field values. I can set break points and the debugger will stop OK. When I hover the cursor over any variable (say NumData in the following example) I get an error like this (TParser is an OBJECT type):

NumData = <Error: Identifier not found: "NumData" at start of expression>

 
public var TParser.NumData: Int32 = Longint


Is there a debugger setting or compiler directive (I use {$mode objfpc} ) that I am missing, or does the debugger only support Class types (In which case I will have to change all my code).
Thanks if you can help.
« Last Edit: July 19, 2025, 05:16:53 am by Richard Marriott »

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 12170
  • Debugger - SynEdit - and more
    • wiki
Re: Debugger use on OBJECT type
« Reply #1 on: July 16, 2025, 09:14:31 am »
It's a bug in FPC.
It's fixed but only in FPC 3.3.1.

You can use FpcUpDeluxe to install this. Then use 331 for debugging, and 3.2.2 for release builds.



IIRC with FPC 3.2.2 you can workaround, but it's rather awkward...

If you are in an "object" then it wont work.

But, if the caller has the object in a local (or global) var.
e.g. the caller did
   FooObject.SomeMethod

And you are in SomeMethod, then you can select the caller in the callstack window. And FooObject can be inspected.

Marc

  • Administrator
  • Hero Member
  • *
  • Posts: 2673
Re: Debugger use on OBJECT type
« Reply #2 on: July 16, 2025, 10:54:58 am »
Thanks for the tip (I've tons of object which I couln't inspect)
//--
{$I stdsig.inc}
//-I still can't read someones mind
//-Bugs reported here will be forgotten. Use the bug tracker

440bx

  • Hero Member
  • *****
  • Posts: 6118
Re: Debugger use on OBJECT type
« Reply #3 on: July 16, 2025, 11:18:48 am »
Then use 331 for debugging, and 3.2.2 for release builds.
Is there some "reasonably simple" way of having a Lazarus installation (the same installation) switch from using v3.3.1 to v3.2.2 back and forth upon user request ?

FPC v3.2.2 and Lazarus v4.0rc3 on Windows 7 SP1 64bit.

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 12695
  • FPC developer.
Re: Debugger use on OBJECT type
« Reply #4 on: July 16, 2025, 11:55:38 am »
What is the status with 3.2.4RC1 ?

cdbc

  • Hero Member
  • *****
  • Posts: 2664
    • http://www.cdbc.dk
Re: Debugger use on OBJECT type
« Reply #5 on: July 16, 2025, 12:30:53 pm »
Hi
Quote
Is there some "reasonably simple" way of having a Lazarus installation (the same installation) switch from using v3.3.1 to v3.2.2 back and forth upon user request ?
Well, I'm on linux, but maybe you can do something like my setup on your 'winders'...
I simply have a "system-installed-from-pclos-repo" fpc-release / laz-release
...and
A "FpcUpDeluxe-installed-from-source-in-home-directory" fpc-trunk / laz-trunk
It's no hassle at all, to switch between them, on the same project =^  8)
Regards Benny
If it ain't broke, don't fix it ;)
PCLinuxOS(rolling release) 64bit -> KDE6/QT6 -> FPC Release -> Lazarus Release &  FPC Main -> Lazarus Main

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 12170
  • Debugger - SynEdit - and more
    • wiki
Re: Debugger use on OBJECT type
« Reply #6 on: July 16, 2025, 01:07:38 pm »
Then use 331 for debugging, and 3.2.2 for release builds.
Is there some "reasonably simple" way of having a Lazarus installation (the same installation) switch from using v3.3.1 to v3.2.2 back and forth upon user request ?

Assuming you have both versions installed (such that they don't conflict / easy on Windows / needs care of the fpc.cfg on Linux, but there are several ways)....

You can switch either in
- Menu: Tools > Options
- Project Options > Compiler commands

In the latter you can specify an fpc to be used just for the project.
And the project options follows "build mode". So you can set it up per build mode and then toggle via that.

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 12170
  • Debugger - SynEdit - and more
    • wiki
Re: Debugger use on OBJECT type
« Reply #7 on: July 16, 2025, 01:09:23 pm »
A "FpcUpDeluxe-installed-from-source-in-home-directory" fpc-trunk / laz-trunk
It's no hassle at all, to switch between them, on the same project =^  8)

Should be possible via the build mode.

Afaik fpcupdeluxe wraps the fpc installs into a script (to deal with fpc.cfg locations). So you need to specify the full path to that script, if you want to use that fpc.

440bx

  • Hero Member
  • *****
  • Posts: 6118
Re: Debugger use on OBJECT type
« Reply #8 on: July 16, 2025, 02:24:32 pm »
In the latter you can specify an fpc to be used just for the project.
And the project options follows "build mode". So you can set it up per build mode and then toggle via that.
Maybe I'm missing the obvious but, I don't see where I can tell Lazarus which FPC compiler to use.

Please refer to the attachment.  I've gone through every option on the right and corresponding possibility on the left without seeing which one is the one that allows me to select a FPC installation.

If you could point out where/what I'm supposed to change/set I'd appreciate that.
FPC v3.2.2 and Lazarus v4.0rc3 on Windows 7 SP1 64bit.

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 12170
  • Debugger - SynEdit - and more
    • wiki
Re: Debugger use on OBJECT type
« Reply #9 on: July 16, 2025, 03:13:44 pm »
Maybe I'm missing the obvious but, I don't see where I can tell Lazarus which FPC compiler to use.

"Compiler commands"

Then the block in the middle "Compiler" (not before, not after),
in that block "command"
which defaults to: $(CompPath)

440bx

  • Hero Member
  • *****
  • Posts: 6118
Re: Debugger use on OBJECT type
« Reply #10 on: July 16, 2025, 06:24:48 pm »
got it.  Thank you Martin.
FPC v3.2.2 and Lazarus v4.0rc3 on Windows 7 SP1 64bit.

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 12170
  • Debugger - SynEdit - and more
    • wiki
Re: Debugger use on OBJECT type
« Reply #11 on: July 16, 2025, 06:52:21 pm »
I just revisited the old reports on the topic
https://gitlab.com/freepascal.org/fpc/source/-/issues/36017
https://gitlab.com/freepascal.org/fpc/source/-/issues/37661

It may be that this is a DWARF-3 issue only.

You can actually debug them with FPC 3.2.2 when using DWARF-2



What is the status with 3.2.4RC1 ?

Only tested with 3.2.3  420f7af213   

With that and DWARF-3 objects do not have "self" => so not fixed.


Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 12170
  • Debugger - SynEdit - and more
    • wiki
Re: Debugger use on OBJECT type
« Reply #12 on: July 16, 2025, 08:16:43 pm »
Anyone who is aware of noticeable differences between versions of DWARF, please mention them. So that they can be added to the table here: https://wiki.freepascal.org/DWARF#DWARF_version_comparison

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 12695
  • FPC developer.
Re: Debugger use on OBJECT type
« Reply #13 on: July 17, 2025, 10:00:56 am »
Perhaps:

88cf633b973ba2002e8f392ad0748b614bf1f1c9 florian Mon Sep 26 21:28:39 2022

* use append_object_struct also for dwarf-3 when creating dwarf debug info for objects, resolves gitlab 0039920
Commit consists out of

    M compiler/dbgdwarf.pas

Richard Marriott

  • New Member
  • *
  • Posts: 14
Re: Debugger use on OBJECT type
« Reply #14 on: July 19, 2025, 05:14:40 am »
Thanks for the help. It looks a bit tricky to implement for a newbie. It is not a big deal to convert Objects to Class so maybe that is the way to go.

 

TinyPortal © 2005-2018