<div dir="ltr">Thanks for the extra info. This still feels a little incomplete in terms of a formal DWARF proposal, though. What specific additions would you make to DWARF to support your desired feature set?<div><br></div><div>-cary</div><div><br></div></div><br><div class="gmail_quote gmail_quote_container"><div dir="ltr" class="gmail_attr">On Fri, Apr 24, 2026 at 3:43 AM Martin via Dwarf-discuss <<a href="mailto:dwarf-discuss@lists.dwarfstd.org">dwarf-discuss@lists.dwarfstd.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Following up my other mail on strings...<br>
<br>
Here are some details on ref-counts in Pascal.<br>
<br>
Note, the compiler devs currently are adding "smart pointers" which to <br>
my understanding will introduce similar refcounts for other types. But I <br>
do not yet have details on that.<br>
<br>
The entire discussion is about "hidden" refcounts. That is refcounts not <br>
added by the user in the declaration of a type, but internally being <br>
part of the type.<br>
I.e. "COM" interfaces do NOT fall into this, as their refcount is <br>
defined as normal field in the underlying object.<br>
<br>
Currently in pascal there are<br>
<br>
Some string types like AnsiStrings.<br>
- the implement copy-on-write if the refcount is greater than 1 (and <br>
they are written to)<br>
<br>
Dynamic arrays (var-length)<br>
- the do not implement copy-on-write<br>
<br>
ref-counts are managed if the data is assigned to other vars, or passed <br>
as parameter.<br>
<br>
There are methods (uniquestring, SetLength) that return a copy with <br>
refcount = 1.<br>
<br>
<br>
<br>
In debugging, this information may be important for a user.<br>
<br>
- When values in an array are changed. (either by code that is stepped, <br>
or by modifying data via the debugger). => The user may need to know if <br>
that has side effects on other copies of an array<br>
<br>
- Debugging code that accesses a string via "PChar" (pointer to char). <br>
This bypasses copy-on-write, this easily leads to bugs, that can only be <br>
found checking the refcount<br>
<br>
- If a debugger allows to modify data in a string, then the debugger <br>
itself needs to know if that string needs to be copied<br>
<br>
<br>
For the debugger itself the information is important when<br>
<br>
- modifying data<br>
- creating instances of the data (e.g. when the user calls a function as <br>
part of inspecting values, and a string needs to be injected as argument)<br>
    p lowercase('AbcDef')<br>
<br>
<br>
Requirements<br>
<br>
DWARF would need to be able to add "refcount" info to different types.<br>
To start with this is DW_TAG_string_type and DW_TAG_array_type.<br>
Other types may later be needed too.<br>
<br>
The info needs to describe<br>
- the (relative) location of the refcount<br>
- the size of the number<br>
<br>
If a debugger also should be able to modify/create/free the data, then <br>
more is needed. I would at first say a list of functions for various <br>
tasks. But in other languages they may not exist, and instead common <br>
actions could be described by other means.<br>
So the actions would need a choice of what the describe (maybe by use of <br>
different forms, maybe nested tags, with attributes?)<br>
Actions might be<br>
- creation (alloc mem)<br>
- init (after alloc mem)<br>
- inc/dec ref => those default to just modifying the field<br>
- get copy that may be modified?<br>
<br>
<br>
<br>
Additional considerations<br>
<br>
I talked about strings being passed as parameters to function (that are <br>
called by the debugger).<br>
<br>
In Pascal some function can be optimised so their string argument does <br>
not get the increment.<br>
This could be covered by either<br>
- a copy of the type, with a "no action" for the inc/dec<br>
- a flag on the variable (allowing the type to be the same, which may be <br>
desirable)<br>
<br>
-- <br>
Dwarf-discuss mailing list<br>
<a href="mailto:Dwarf-discuss@lists.dwarfstd.org" target="_blank">Dwarf-discuss@lists.dwarfstd.org</a><br>
<a href="https://lists.dwarfstd.org/mailman/listinfo/dwarf-discuss" rel="noreferrer" target="_blank">https://lists.dwarfstd.org/mailman/listinfo/dwarf-discuss</a><br>
</blockquote></div>