Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-devel / 2021-07

TDef flags

15 messages · 5 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

J. Gareth Moreton

Hi everyone,

I'm trying to fix i38827, and am trying a few things.  One thing I've noticed is that some specializations have both the df_generic and df_specialization flags set, and the def missing from the debug information that raises the linker error is one such def. Manually removing the df_generic fixes the problem (since the presence of the flag stops it from being written to the debug information), but is there a situation where a def can legitimately have both flags set?

To guess, I would say if a generic has multiple parameters and not all of them are specialized, then that makes a def that's both, but then a fully specialized generic type shouldn't have the generic flag any more, right?

Gareth aka. Kit

This email has been checked for viruses by Avast antivirus software. https://www.avast.com/antivirus

Reply by email

J. Gareth Moreton
to denisgolovan

I've posted a patch in the previous bug report, but I'll be the first to admit that it's a little hacky.  Given the linker errors in #39140 are similar to those in #38827, does it fix those too?

Gareth aka. Kit

denisgolovan wrote 9 lines
Thanks, Gareth. I've created another issue, possibly related - https://bugs.freepascal.org/view.php?id=39140 Sven, could you take a look? -- Regards, Denis Golovan
This email has been checked for viruses by Avast antivirus software. https://www.avast.com/antivirus

Reply by email

denisgolovan
to J. Gareth Moreton
I've posted a patch in the previous bug report, but I'll be the first to admit that it's a little hacky. Given the linker errors in #39140 are similar to those in #38827, does it fix those too?

Nope, unfortunately it does not.

-- Regards,
Denis Golovan

Reply by email

J. Gareth Moreton
to denisgolovan

I just double-checked and my patch does fix the code example, at least for me, but there might be you have a Windows code example that still fails that you're testing it against?

Gareth aka. Kit

denisgolovan wrote 8 lines
> I've posted a patch in the previous bug report, but I'll be the first to > admit that it's a little hacky. Given the linker errors in #39140 are > similar to those in #38827, does it fix those too? Nope, unfortunately it does not. -- Regards, Denis Golovan
This email has been checked for viruses by Avast antivirus software. https://www.avast.com/antivirus

Reply by email

Sven Barth
to J. Gareth Moreton: I'm trying to fix i38827, and am trying a few things.  One thing I've noticed is that…
J. Gareth Moreton wrote 14 lines
Hi everyone, I'm trying to fix i38827, and am trying a few things.  One thing I've noticed is that some specializations have both the df_generic and df_specialization flags set, and the def missing from the debug information that raises the linker error is one such def. Manually removing the df_generic fixes the problem (since the presence of the flag stops it from being written to the debug information), but is there a situation where a def can legitimately have both flags set? To guess, I would say if a generic has multiple parameters and not all of them are specialized, then that makes a def that's both, but then a fully specialized generic type shouldn't have the generic flag any more, right?

First of you *do not* modify defs when writing debug information. Period. (except for fields that are *only* related to debug information)

Second df_generic is set for any def *inside* a generic. The TArray<T> is a specialization inside a generic thus it will have both flags set.

Regards,
Sven

Reply by email

J. Gareth Moreton
to Sven Barth

Okay, okay. Not too harsh, please.

I feel I don't yet know enough about defs and generics to properly fix this bug, only that the defs used aren't getting written out as debug information because of the df_generic flag being present.

In the attached .s file, you can search for the reference to .La17 on line 600 that refers to a generic def, related to the line "R.GetArr<single>;" in the source file.

(tw38827.lpr)

program tw38827;
{$mode delphi}
uses tw38827_u;
var R: TRec;
begin
   R.GetArr<single>;
end.

(tw38827_u.pas)

unit tw38827_u;
{$mode delphi}
interface
type
   TRec = record
     C: TArray<single>;
     function GetArr<T>: TArray<T>; inline;
   end;
implementation
function TRec.GetArr<T>: TArray<T>;
begin
   result := nil;
   case GetTypeKind(T) of
     tkFloat:
       if SizeOf(T) = SizeOf(Single) then result := C;
   end;
end;
end.

Gareth aka. Kit

Sven Barth wrote 25 lines
Am 03.07.2021 um 15:01 schrieb J. Gareth Moreton via fpc-devel: > Hi everyone, > > I'm trying to fix i38827, and am trying a few things.  One thing I've > noticed is that some specializations have both the df_generic and > df_specialization flags set, and the def missing from the debug > information that raises the linker error is one such def. Manually > removing the df_generic fixes the problem (since the presence of the > flag stops it from being written to the debug information), but is > there a situation where a def can legitimately have both flags set? > > To guess, I would say if a generic has multiple parameters and not > all of them are specialized, then that makes a def that's both, but > then a fully specialized generic type shouldn't have the generic flag > any more, right? First of you *do not* modify defs when writing debug information. Period. (except for fields that are *only* related to debug information) Second df_generic is set for any def *inside* a generic. The TArray<T> is a specialization inside a generic thus it will have both flags set. Regards, Sven
This email has been checked for viruses by Avast antivirus software. https://www.avast.com/antivirus

Reply by email

Sven Barth
to J. Gareth Moreton
J. Gareth Moreton wrote
Okay, okay. Not too harsh, please.

Better to stop the intention of modifying defs before you can get a taste for them. :P

I feel I don't yet know enough about defs and generics to properly fix this bug, only that the defs used aren't getting written out as debug information because of the df_generic flag being present.

Generics related bugs have the tendency to be more complex and involved. Especially if one doesn't know the necessary parts of the compiler or how those parts are supposed to work together.

Regards,
Sven

Reply by email

J. Gareth Moreton
to Sven Barth

Well, I've been trying to work it out, but this bug I'll have to delegate to someone else to fix until I get a better idea of how it all fits together.

Gareth aka. Kit

Sven Barth wrote 20 lines
Am 04.07.2021 um 12:59 schrieb J. Gareth Moreton: > Okay, okay. Not too harsh, please. Better to stop the intention of modifying defs before you can get a taste for them. :P > I feel I don't yet know enough about defs and generics to properly > fix this bug, only that the defs used aren't getting written out as > debug information because of the df_generic flag being present. Generics related bugs have the tendency to be more complex and involved. Especially if one doesn't know the necessary parts of the compiler or how those parts are supposed to work together. Regards, Sven _______________________________________________ fpc-devel maillist  -  https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
This email has been checked for viruses by Avast antivirus software. https://www.avast.com/antivirus

Reply by email

Zeljko Avramovic
to denisgolovan

BitHelpers are quite mature now and I would like to see them as part of FreePascal. If devs agree to that, then I would like to discuss what is the best way to include them. As mentioned at https://forum.lazarus.freepascal.org/index.php/topic,41672.msg409880.html#msg409880, Thaddy would like to see them available out of the box (added to syshelp*.inc), but I would prefer to see them as a separate package.

What do you think would be the best way? I can do whatever is better, but I would like to hear your thoutghs first.

BitHelpers info can be found at the beginning of that forum thread, at repo https://bitbucket.org/avra/bithelpers, and in the wiki https://wiki.freepascal.org/BitHelpers.

Reply by email

Michael Van Canneyt
to Zeljko Avramovic
Zeljko Avramovic wrote 5 lines
BitHelpers are quite mature now and I would like to see them as part of FreePascal. If devs agree to that, then I would like to discuss what is the best way to include them. As mentioned at https://forum.lazarus.freepascal.org/index.php/topic,41672.msg409880.html#msg409880, Thaddy would like to see them available out of the box (added to syshelp*.inc), but I would prefer to see them as a separate package. What do you think would be the best way? I can do whatever is better, but I would like to hear your thoutghs first. BitHelpers info can be found at the beginning of that forum thread, at repo https://bitbucket.org/avra/bithelpers, and in the wiki https://wiki.freepascal.org/BitHelpers.

There are already bithelpers in the sysutils unit. If you want to extend them, that's fine. Just post a patch in the bugtracker...

Michael.

Reply by email

Zeljko Avramovic
to Michael Van Canneyt

Here is a patch: https://bugs.freepascal.org/view.php?id=39268

Now it is possible to do this:

MyByte.Bit[1] := true;
MyByte.Nibble[0] := MyByte.Nibble[1];

ToBinString and ToHexString are now extended so by customizing DefaultBitFormatSettings, DefaultBinFormatSettings and DefaultHexFormatSettings you can easily get these outputs:

True.ToTrueFalseString = Укључено True.ToString('OnState', 'OffState') = OnState True.ToString('Running', 'Stopped', scfUpperCase) = RUNNING True.ToString('Ради', 'Не ради') = Ради MyDword.Bit[5].ToTrueFalseString = False MyQword.Bit[MQword.MaxBit].ToString(scfUpperCase) = FALSE MyDword.Bit[5].ToOneZeroString = 1 MyDword.Bit[5].ToOnOffString(scfUpperCase) = OFF MyByte.ToBinString = (00100010) MyByte.ToBinString(true) = (00100010) MyByte.ToBinString(false) = (100010) MyByte.ToBinString = 0001_0111 MyNativeInt.ToBinString = %00000000-00000000_00000011-11101000 MyQword.ToBinString = OOOOOOOOOOOOOOOOOOOOXOXOXOXXXXOOXXOXXXXOXXXXXXXXXXXXXXXXXXXXXXXX MyQword.ToBinString(false) = XOXOXOXXXXOOXXOXXXXOXXXXXXXXXXXXXXXXXXXXXXXX MyQword.ToBinString(50) = OOOOOOXOXOXOXXXXOOXXOXXXXOXXXXXXXXXXXXXXXXXXXXXXXX MyQword.ToBinString(MyBinFormatSettings, false) = %XOXO-XOXX.XXOO_-_XXOX.XXXO-XXXX.XXXX_XXXX.XXXX-XXXX.XXXX MyQword.ToBinString(MyBinFormatSettings, 50) = %OO_OOOO.XOXO-XOXX.XXOO_-_XXOX.XXXO-XXXX.XXXX_XXXX.XXXX-XXXX.XXXX MyQword.ToBinString(MyBinFormatSettings, false, 50) = %OO_OOOO.XOXO-XOXX.XXOO_-_XXOX.XXXO-XXXX.XXXX_XXXX.XXXX-XXXX.XXXX MyQword.ToHexString = 00000ABCDEFFFFFF MyQword.ToHexString(13) = 00ABCDEFFFFFF MyQword.ToHexString(true) = 00000ABCDEFFFFFF MyQword.ToHexString(false) = ABCDEFFFFFF MyQword.ToHexString(DefaultHexFormatSettings) = 00000ABCDEFFFFFF MyQword.ToHexString(DefaultHexFormatSettings, false) = ABCDEFFFFFF MyQword.ToHexString(DefaultHexFormatSettings, 13) = 00ABCDEFFFFFF MyQword.ToHexString(DefaultHexFormatSettings, false, 13) = 00ABCDEFFFFFF MyQword.ToHexString(MyHexFormatSettings1) = $0000-0ABC--DEFF-FFFF MyQword.ToHexString(MyHexFormatSettings2, true) = [$0.0^0.0_0.A^B.C--D.E^F.F_F.F^F.F] MyQword.ToHexString(MyHexFormatSettings2, false) = [$A^B.C--D.E^F.F_F.F^F.F]

Compatibility with old behaviour of ToBinString and ToHexString is kept.

Please review the patch.

Show quoted text 20 lines
Sent: Thursday, July 08, 2021 at 9:51 AM From: "Michael Van Canneyt" To: "Zeljko Avramovic via fpc-devel" Cc: "Zeljko Avramovic" Subject: Re: [fpc-devel] BitHelpers On Thu, 8 Jul 2021, Zeljko Avramovic via fpc-devel wrote: > BitHelpers are quite mature now and I would like to see them as part of FreePascal. If devs agree to that, then I would like to discuss what is the best way to include them. As mentioned at https://forum.lazarus.freepascal.org/index.php/topic,41672.msg409880.html#msg409880, Thaddy would like to see them available out of the box (added to syshelp*.inc), but I would prefer to see them as a separate package. > > What do you think would be the best way? I can do whatever is better, but I would like to hear your thoutghs first. > > BitHelpers info can be found at the beginning of that forum thread, at repo https://bitbucket.org/avra/bithelpers, and in the wiki https://wiki.freepascal.org/BitHelpers. There are already bithelpers in the sysutils unit. If you want to extend them, that's fine. Just post a patch in the bugtracker... Michael.

Reply by email