Pascal Viandier wrote:
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 -.
Sounds good.
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.
Yes, such characters (which can also occur in valid strings) should be escaped, and there are sequences that do worse things than stopping the screen ...
But AFAICS, gdb already does that, even in (Borland) Pascal style -- though for input I use C notation:
(gdb) set language pascal (gdb) print "a\023b" $5 = 'a'#19'b'
Frank