[Dwarf-discuss] Discussion: string encoding as part of the type (Pascal)
Ben Woodard
woodard@redhat.com
Sat Apr 25 01:55:43 GMT 2026
I didn’t see a response to this and so here is my take on it.
It would be a member of the structure which represents the Pascal string. That particular member would be marked DW_AT_artificial to separate it from something which is defined in the source code.
I don’t know what type this would be but that would be the type of the member (a int or a enum or whatever) within the aggregate that defines the string structure. You would also give it a location just like any other member of an aggregate.
The tricky part would be giving this semantic meaning in consumers. Generally within a consumer, it would have a language profile from the CU and that would encode language specific things like what to do when it sees one of these Pascal strings and it wants to display it. So you would have to teach whatever consumers you want to use, e.g. gdb, to know to look up that encoding variable within the string structure and how to use it when displaying the string.
-ben
> On Apr 24, 2026, at 3:55 AM, Martin via Dwarf-discuss <dwarf-discuss@lists.dwarfstd.org> wrote:
>
> In Pascal (free pascal) the string type (some of them) have an internal field (not accessible to user code) that stores the encoding.
>
> That can be an ASCII-page, or utf8, or raw (just bytes as they are)....
>
> For a debugger this info is useful to display the string correctly. A debugger would want to convert the string to the encoding used by the terminal before printing it).
>
> I am looking for ways how that could be encoded in DWARF?
>
> The first step would be e.g. some attributes to describe the location and size of that field.
>
> The 2nd part would be a mapping of the values in that field.
>
> That 2nd part may not need to be part of the encoded DWARF description.
> It could be just per language defaults (a debugger would have to know the values that each compiler may use).
> I.e. I am not sure, but this may be compiler rather than language dependent.
>
> Optional, compliers could add a global list of mapping to pre-defined DWARF constants.
> That would be some form of list with pairs of
> - "compiler encoding value"
> - DWARF constant
>
>
> This may affect the encoding used in the base type for the char.
>
>
> --
> Dwarf-discuss mailing list
> Dwarf-discuss@lists.dwarfstd.org
> https://lists.dwarfstd.org/mailman/listinfo/dwarf-discuss
>
More information about the Dwarf-discuss
mailing list