<snip>
the capacity is used to print out the value.
Perhaps it would be better to print something like "uninitialized string", as the value is really invalid?
I was not sure what to do. In fact, my first goal was to stop gdb from
crashing
each time I was moving the mouse over an uninitialized string variable name
or a
record containing one in ddd. OTOH, this kind of message could be misleading since it is the only Pascal type that would make it pop and I am not ready
to
implement this for all types ;-) - if it is feasible at all -.
For some types it's not possible (e.g., default integer types and Char allow all possible values). For some others, it would be possible (e.g., Boolean, most enum types, real (on most FP systems)), but IMHO one can do it one by one type when someone feels like doing it, it's not necessary to do for all types at once.
IMHO, showing the string contents is sufficient to see if the string was initialized since it is full of "random" characters if not.
But there's a difference between a string with invalid length (and possibly capacity), and a string with valid length and random contents.
In this case, what do you think about the message "invalid data"? If the Capacity and/or length are invalid, the string content is probably invalid too - or at least it cannot be displayed nor handled properly by the running program -. This recalls me an old hairy bug: A program was systematically freezing when displaying data from an external source. It took many hours to discover what was happening: there was a "Control S" character (Chr(19)) embedded in the data. This was freezing the screen when displayed with WriteLn(). So it is probably not a so good idea to display invalid contents. It may contain control characters that could possibly disturb the controlling tty.
Your suggestion (Frank) to check the value of the Capacity is excellent. I will add the check (>= 0) in the patch.
Regards
Pascal