Recent

Author Topic: Exception message doesn't contain variables in Lazarus popup?  (Read 2484 times)

Eugene Loza

  • Hero Member
  • *****
  • Posts: 729
    • My games in Pascal
I wonder if this is intended behavior or did I setup the debugger (FpDebug) incorrectly?

When I get a popup in Lazarus about an exception, it shows me the "line which triggered the exception" but not the exception message (see attached screenshot).

When I press "Break" and try to see the variables for myself I get "Failed to read data from register".

The only way to get the information on what exactly went wrong is to set a breakpoint at the line, the variables then are showing properly, before the exception happens.
My FOSS games in FreePascal&CastleGameEngine: https://decoherence.itch.io/ (Sources: https://gitlab.com/EugeneLoza)

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 10553
  • Debugger - SynEdit - and more
    • wiki
Re: Exception message doesn't contain variables in Lazarus popup?
« Reply #1 on: June 20, 2024, 02:58:20 pm »
It should show the message (assuming there is one).

Can you check in a simple app (in OnFormCreate)?
Code: Pascal  [Select][+][-]
  1. raise Exception.Create('foo bar '+IntToStr(Random(99)));

Also:
OS?
32/64 bit?
Optimization settings?

FPC version?
Custom FPC build?


Eugene Loza

  • Hero Member
  • *****
  • Posts: 729
    • My games in Pascal
Re: Exception message doesn't contain variables in Lazarus popup?
« Reply #2 on: June 20, 2024, 06:54:52 pm »
Ok, so something seems like really broken on my side  :D It doesn't show the message at all in a "blank project" (neither GUI nor console) - see attachment for GUI project.

OS? 32/64 bit? - Win10x64. I'm almost sure I've had the same issue in Debian12x64, but didn't pay too much attention.
Optimization settings? - Different, usually the "default" Debug mode (the one created in Project Settings). However, now that I think about it the error message in the first post was inside of a LPK, most likely Castle Game Engine (can double check if needed, can be deeper, in FPC's DOM unit), as far as I know the packages use their own optimization settings, and if I read it correctly it should be -O2.
FPC version? - Trunk, around a month or two old.
Custom FPC build? - installed from FPCUpDeluxe.
My FOSS games in FreePascal&CastleGameEngine: https://decoherence.itch.io/ (Sources: https://gitlab.com/EugeneLoza)

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 10553
  • Debugger - SynEdit - and more
    • wiki
Re: Exception message doesn't contain variables in Lazarus popup?
« Reply #3 on: June 20, 2024, 08:17:55 pm »
Fpc 3.3.1 / trunk?

I just tested that, and it seems that it does not work.

I just recall, the fields in TObject may have changed. Since debug info for exceptions is not always available the debugger relies on fixed field locations. So this may need to be updated (this would likely affect gdb and fpdebug).


Eugene Loza

  • Hero Member
  • *****
  • Posts: 729
    • My games in Pascal
Re: Exception message doesn't contain variables in Lazarus popup?
« Reply #4 on: June 20, 2024, 08:45:51 pm »
Fpc 3.3.1 / trunk?
yes, Lazarus 3.99 (rev main_3_99-1744-g0261f3b5ee) FPC 3.3.1 x86_64-win64-win32/win64 / Free Pascal Compiler version 3.3.1-15296-g6a28ac53da [2024/02/27] for x86_64
(I wonder why February? I certainly remember updating somewhere very recently...)
My FOSS games in FreePascal&CastleGameEngine: https://decoherence.itch.io/ (Sources: https://gitlab.com/EugeneLoza)

Marc

  • Administrator
  • Hero Member
  • *
  • Posts: 2615
Re: Exception message doesn't contain variables in Lazarus popup?
« Reply #5 on: June 21, 2024, 11:09:01 am »
Fpc 3.3.1 / trunk?

I just tested that, and it seems that it does not work.

I just recall, the fields in TObject may have changed. Since debug info for exceptions is not always available the debugger relies on fixed field locations. So this may need to be updated (this would likely affect gdb and fpdebug).

Don't know if it is related, on one of the fpc mailinglist there is a thread about an extra field added to TObject.
//--
{$I stdsig.inc}
//-I still can't read someones mind
//-Bugs reported here will be forgotten. Use the bug tracker

Thaddy

  • Hero Member
  • *****
  • Posts: 16194
  • Censorship about opinions does not belong here.
Re: Exception message doesn't contain variables in Lazarus popup?
« Reply #6 on: June 21, 2024, 11:15:18 am »
Marc, can you provide a link to that? Can't find it and I follow the mailing list.
( it sounds unlikely to me )

Such an important change should have shown up in user changes trunk.
Usually Tobject is left alone.
« Last Edit: June 21, 2024, 11:26:28 am by Thaddy »
If I smell bad code it usually is bad code and that includes my own code.

PascalDragon

  • Hero Member
  • *****
  • Posts: 5759
  • Compiler Developer
Re: Exception message doesn't contain variables in Lazarus popup?
« Reply #7 on: June 21, 2024, 11:24:39 am »
Marc, can you provide a link to that? Can't find it and I follow the mailing list.
( it sounds unlikely to me )

Then you don't follow the list close enough ;)

Thaddy

  • Hero Member
  • *****
  • Posts: 16194
  • Censorship about opinions does not belong here.
Re: Exception message doesn't contain variables in Lazarus popup?
« Reply #8 on: June 21, 2024, 11:33:07 am »
I have seen that, but don't believe that it is actually done.. :'(
That is new to me...Is it true?
« Last Edit: June 21, 2024, 11:34:57 am by Thaddy »
If I smell bad code it usually is bad code and that includes my own code.

PascalDragon

  • Hero Member
  • *****
  • Posts: 5759
  • Compiler Developer
Re: Exception message doesn't contain variables in Lazarus popup?
« Reply #9 on: June 21, 2024, 11:50:11 am »
Yes it is.

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 10553
  • Debugger - SynEdit - and more
    • wiki
Re: Exception message doesn't contain variables in Lazarus popup?
« Reply #10 on: June 21, 2024, 11:14:23 pm »
Lazarus 3.99 should now handle the new field.

FpDebug should even be able to deal with future changes in TObject. But relies on the field order in the class "Exception".  (I might add code to check if debug info for that class is available... / But that isn't fool proof either: user code can have added a class of the same name and that would lead to wrong results)

GDB tries to use debug info for Exception, if that is present. Otherwise it will use absolute addresses too. It only checks for the one field, as reading instance size is not (or not reasonable) possible. (It relies on knowing other internals, that also changed with fpc versions, and that afaik requires reading the Dwarf without gdb (if it is dwarf and not stabs).

 

TinyPortal © 2005-2018