[fpc-devel] Question: ref counts / strings, smart pointers...

Tomas Hajny XHajT03 at hajny.biz
Wed May 27 12:29:39 CEST 2026


On 2026-05-27 12:11, Martin Frb via fpc-devel wrote:
> I know how refcount internally work on strings and dyn array.
> 
> I am thinking about formulating a request to the DWARF specs. So I want 
> to check the details, and also get information how they
> - will work for smart pointers,
> - where else they may occur?
> 
> Background, refcounts may be of interest for the debugger in at least 
> the following cases.
> - A user modifies a variable (or an indexed value) via the debugger.
>   ~ The debugger may additionally need info, if it should "copy on 
> write" / though that can be derived....
>   ~ The debugger could inform the user about "side effects on other 
> references to the value"
  .
  .

I can't imagine a reasonable scenario when a user might want to perform 
a modification of a refcounted variable of the program being debugged by 
using "copy on write". I strongly believe that such an option should not 
be offered to the user at all. As far as modifying the already existing 
instance is concerned, the debugger should probably always check whether 
the shared reference is still valid and having the original value at the 
time of trying to modify it - trying to add the debugger as another 
reference of an existing refcounted variable might IMHO lead to 
unexpected/unwanted effects on the program being debugged and thus 
should be avoided as well.

Just my 2 cents

Tomas


More information about the fpc-devel mailing list