Sign in Join

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

Mailing lists / fpc-devel / 2009-12

debug information for Variant type

15 messages · 3 people · –

Reply by email Subscribe to this list Your subscription

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

Paul Ishenin

Hello, FPC developers' list.

Is it known that gdb returns "void" type for the Variant variables when STABS debug info is used?

When DWARF is used Variant = TVarData which is also not perfect. I want to see only variant value, not the whole record when I debug the program in Lazarus. When I need the whole record I can always evaluate TVarData(V).

Is it possible to improve both stabs and dwarf info?

Best regards, Paul Ishenin.

Reply by email

Jonas Maebe
to Paul Ishenin
Paul Ishenin wrote
Is it known that gdb returns "void" type for the Variant variables when STABS debug info is used?

Not that I know. Stabs is pretty much legacy though.

Show quoted text 6 lines
When DWARF is used Variant = TVarData which is also not perfect. I want to see only variant value, not the whole record when I debug the program in Lazarus. When I need the whole record I can always evaluate TVarData(V). Is it possible to improve both stabs and dwarf info?

In Stabs it is impossible to only show the actual variant value, as Stabs does not know a "variant" concept. DWARF does, but GDB doesn't support it yet.

Jonas

Reply by email

Paul Ishenin
to Jonas Maebe
Jonas Maebe wrote
In Stabs it is impossible to only show the actual variant value, as Stabs does not know a "variant" concept.

And lazarus does not need that. I think it would be enough to mark the variant variables somehow (not "void").

DWARF does, but GDB doesn't support it yet.

We only need to disctinct Variant and TVarData. So when user want to watch Variable variable we will perform TVarData() cast and show the value ourself. When TVarData is used we will show as TVarData (iow, as record).

Best regards,
Paul Ishenin.

Reply by email

Jonas Maebe
to Paul Ishenin
Paul Ishenin wrote 8 lines
Jonas Maebe wrote: > DWARF does, but GDB doesn't support it yet. We only need to disctinct Variant and TVarData. So when user want to watch Variable variable we will perform TVarData() cast and show the value ourself. When TVarData is used we will show as TVarData (iow, as record).

Would it be enough if the type name were changed to "variant"? It would not be 100% safe (since "variant" is not a reserved word, anyone can declare a variable/type/... with the name "variant"), but I don't immediately see another solution.

Jonas

Reply by email

Paul Ishenin
to Jonas Maebe
Jonas Maebe wrote
Would it be enough if the type name were changed to "variant"? It would not be 100% safe (since "variant" is not a reserved word, anyone can declare a variable/type/... with the name "variant"), but I don't immediately see another solution.

I think yes.

Best regards,
Paul Ishenin.

Reply by email

Jonas Maebe
to Paul Ishenin
Paul Ishenin wrote 6 lines
Jonas Maebe wrote: > Would it be enough if the type name were changed to "variant"? It > would not be 100% safe (since "variant" is not a reserved word, > anyone can declare a variable/type/... with the name "variant"), > but I don't immediately see another solution. I think yes.

Does the attached patch work for DWARF with Lazarus? "ptype variantvar" still shows tvardata, but "info variantvar" shows "static VARIANT V;", and I don't know what the GDB MI will return for the query that Lazarus uses.

Jonas

Index: dbgdwarf.pas
=================================================================== --- dbgdwarf.pas (revision 14293)
+++ dbgdwarf.pas (working copy)
@@ -3245,8 +3245,11 @@

      procedure TDebugInfoDwarf2.appenddef_variant(list:TAsmList;def:
tvariantdef);
        begin
-        { variants aren't known to dwarf2 but writting tvardata
should be enough }
-        appenddef_record(list,trecorddef(vardatadef));
+        append_entry(DW_TAG_typedef,false,[
+          DW_AT_name,DW_FORM_string,'Variant'#0
+        ]);
+        append_labelentry_ref(DW_AT_type,def_dwarf_lab(vardatadef));
+        finish_entry;
        end;
      function TDebugInfoDwarf2.dwarf_version: Word;

Reply by email

Marc Weustink
to Jonas Maebe
Jonas Maebe wrote 14 lines
On 01 Dec 2009, at 13:42, Paul Ishenin wrote: > Jonas Maebe wrote: >> Would it be enough if the type name were changed to "variant"? It >> would not be 100% safe (since "variant" is not a reserved word, >> anyone can declare a variable/type/... with the name "variant"), but >> I don't immediately see another solution. > I think yes. Does the attached patch work for DWARF with Lazarus? "ptype variantvar" still shows tvardata, but "info variantvar" shows "static VARIANT V;", and I don't know what the GDB MI will return for the query that Lazarus uses.

the mi version of info var.. is not implemented in gdb, so lazarus uses ptype var

So I guess for this case, when a TVarrec is returned we'll inspect further using info.

Thanks Marc

Reply by email

Jonas Maebe
to Marc Weustink
Marc Weustink wrote 18 lines
Jonas Maebe wrote: > On 01 Dec 2009, at 13:42, Paul Ishenin wrote: >> Jonas Maebe wrote: >>> Would it be enough if the type name were changed to "variant"? It >>> would not be 100% safe (since "variant" is not a reserved word, >>> anyone can declare a variable/type/... with the name "variant"), >>> but I don't immediately see another solution. >> I think yes. > Does the attached patch work for DWARF with Lazarus? "ptype > variantvar" still shows tvardata, but "info variantvar" shows > "static VARIANT V;", and I don't know what the GDB MI will return > for the query that Lazarus uses. the mi version of info var.. is not implemented in gdb, so lazarus uses ptype var So I guess for this case, when a TVarrec is returned we'll inspect further using info.

It's also possible to create another definition of tvarrec with "variant" as name. It's just slightly less clean to implement. Also note that "info var" takes a regular expression, so make sure to use "info var ^varname$", otherwise you'll get info about a lot of unrelated matches.

Jonas

Reply by email

Marc Weustink
to Jonas Maebe
Jonas Maebe wrote 24 lines
On 03 Dec 2009, at 14:29, Marc Weustink wrote: > Jonas Maebe wrote: >> On 01 Dec 2009, at 13:42, Paul Ishenin wrote: >>> Jonas Maebe wrote: >>>> Would it be enough if the type name were changed to "variant"? It >>>> would not be 100% safe (since "variant" is not a reserved word, >>>> anyone can declare a variable/type/... with the name "variant"), >>>> but I don't immediately see another solution. >>> I think yes. >> Does the attached patch work for DWARF with Lazarus? "ptype >> variantvar" still shows tvardata, but "info variantvar" shows "static >> VARIANT V;", and I don't know what the GDB MI will return for the >> query that Lazarus uses. > > the mi version of info var.. is not implemented in gdb, so lazarus > uses ptype var > > So I guess for this case, when a TVarrec is returned we'll inspect > further using info. It's also possible to create another definition of tvarrec with "variant" as name.

In that case I think I prefer a full dwarf variant :)

It's just slightly less clean to implement. Also note that "info var" takes a regular expression, so make sure to use "info var ^varname$", otherwise you'll get info about a lot of unrelated matches.

:)

Thanks.

Marc

Reply by email

Jonas Maebe
to Marc Weustink
Marc Weustink wrote 5 lines
Jonas Maebe wrote: > It's also possible to create another definition of tvarrec with > "variant" as name. In that case I think I prefer a full dwarf variant :)

Ok, it's now called "Variant". As an extra advantage, I think that this cannot clash with user-defined types, because afaik those type names are always uppercased.

Jonas

Reply by email

Paul Ishenin
to Jonas Maebe
Jonas Maebe wrote
Ok, it's now called "Variant". As an extra advantage, I think that this cannot clash with user-defined types, because afaik those type names are always uppercased.

Thanks. This is what I asked. Can it be similar for STABS?

Best regards,
Paul Ishenin.

Reply by email

Paul Ishenin
to Paul Ishenin
Paul Ishenin wrote 5 lines
Jonas Maebe wrote: > Ok, it's now called "Variant". As an extra advantage, I think that > this cannot clash with user-defined types, because afaik those type > names are always uppercased. Thanks. This is what I asked. Can it be similar for STABS?

Jonas, using your change I implemented variant variables showing in Lazarus. It works fine on my big test. For stabs it still shows 'void'.

Best regards,
Paul Ishenin.

Reply by email

Jonas Maebe
to Paul Ishenin
Paul Ishenin wrote
Jonas, using your change I implemented variant variables showing in Lazarus. It works fine on my big test. For stabs it still shows 'void'.

That's because I did not change anything to Stabs. Stabs is old and legacy (not deprecated, but not actively developed anymore either). If someone else wants to fix it in Stabs, be my guest.

Jonas

Reply by email

Paul Ishenin
to Jonas Maebe
Jonas Maebe wrote
That's because I did not change anything to Stabs. Stabs is old and legacy (not deprecated, but not actively developed anymore either). If someone else wants to fix it in Stabs, be my guest.

Can I be your guest?

The patch do the job. Althought it writes VARIANT to the debug info. But in Lazarus there is no problem to check for both 'Variant' and 'VARIANT'. If you apply it (or allow me to apply it) then I will fix lazarus too.

Best regards,
Paul Ishenin.

Reply by email

Jonas Maebe
to Paul Ishenin
Paul Ishenin wrote
Jonas Maebe wrote: > That's because I did not change anything to Stabs. Stabs is old and legacy (not deprecated, but not actively developed anymore either). If someone else wants to fix it in Stabs, be my guest. Can I be your guest?

Sure!

The patch do the job. Althought it writes VARIANT to the debug info. But in Lazarus there is no problem to check for both 'Variant' and 'VARIANT'. If you apply it (or allow me to apply it) then I will fix lazarus too.
It looks fine (but please change the two empty lines after vardatadef:=trecorddef(..) to one), feel free to commit it.

Thanks,

Jonas

Reply by email