This is the mail archive of the mailing list for the Archer project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [python][patch] Preserve string length, and embedded-nulls in pretty-print string emission.

Phil> This function returns a struct value. If that value contains a
Phil> string with embedded nulls, is there a way to determine the size
Phil> of the "gdb_byte *contents"?

I think: TYPE_LENGTH (value_type (value))
That should get you the size in bytes.
You may need to convert to characters, I'm not sure.

Tom> Why do we need LA_GET_STRING here?  Aren't the string contents already
Tom> in the value?

Phil> I'll look at this a little more closely. But I use this to extract a
Phil> string with embedded nulls with a concrete length. Do I misread your
Phil> thoughts here? Or are you suggesting we just pass in value->contents

Yeah, I think that would be the way to go.

Tom> A test relying on std::string is not very robust -- std::string may
Tom> change over time, breaking the test.  Instead, it is better to write
Tom> custom test code and a printer to match.  That way, we control the
Tom> implementation.

Phil> Ok thanks for the pointer. Can you please elaborate a bit more?

Suppose std::string changes in some future libstdc++.  In that case,
we would have a printer in the test suite that would be incorrect.
This would lead to test failures, even though the gdb code under test
is actually functioning perfectly.

So, rather than using std::string, just write a simple counted string
object of some kind and use it in the test.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]