[fpc-pascal] FpDebug hands-on: AnsiStrings
Joost van der Sluis
joost at cnoc.nl
Thu May 21 20:19:55 CEST 2020
Op 21-05-2020 om 18:25 schreef Martin Frb:
> On 21/05/2020 17:29, Joost van der Sluis wrote:
>>
>> But that the design is problematic can be seen in a comment in the file:
>>
>> // TODO: XXXXX Dynamic max limit
> This is not really about formatting. A corrupt debug target, could
> return a string length of 2^31, not something that the debugger should
> attempt to read. (newer gdb have similar options, if the data is to
> large they return nothing / for strings we can do better and get the start)
> That can happen when reading locals before the stackframe is set up.
Might be, you could see this as a saveguard. But my goal is to cut-out
the middle part of the string. That's formatting....
> Part 2 is formatting related.... In most cases the user does not need a
> 10kb string, the user may want offset 1500 len 500. Ideally then the
> debugger only reads that part. That part may move to the formatter. But
> also may need an extension to target reading the correct subset of the
> data.
Indeed
> If needed I would rather add the 2 new functions. Though it seems the
> data is actually returned as part of the longstring?
No, it is not, because the result is assigned to an AnsiString, and
therefor the compiler could decide to change it's codepage. In this
function or somewhere further down the line.
> If you need individual calls to retrieve that info, it could be done by
> something like GetMember.
> GetMember has to much overhead. as it returns a big object.
>
> But something like
> GetDataProperty(AnPropId: Integer): Pointer;
> would be generic enough to return any additional data.
> (yes ID is integer. quicker to much than doing string compare)
What you are saying is that the TFpValue doesn't do the formatting. But
it retrieves the data. And indeed it's very suitable for that.
But then, we should be consistent. And do not let any other classes (The
formatter I was talking about, but also the PrettyPrinter and such)
retrieve data. Such a class could always create a TFpValue for their own
use....
Regards,
Joost.
More information about the fpc-pascal
mailing list