This is the mail archive of the archer@sourceware.org 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]

[python] StdStringPrinter misleading?


Greetings,

std::string could contain embedded NUL characters, and current
StdStringPrinter hides this (not that the raw printing is any better):

$ cat strnull.cc
#include <string>

using namespace std;
int main()
{
  char foo[] = "abcd\0ghij";
  string s = string(foo, sizeof(foo));
  size_t len = s.length();

  return len == sizeof(foo) ? 0 : 1;
}

(gdb) b 10
Breakpoint 1 at 0x4003b2: file strnull.cc, line 10.
(gdb) r

Breakpoint 1, main () at strnull.cc:10
10        return len == sizeof(foo) ? 0 : 1;
(gdb) print s
$1 = "abcd"
(gdb) print foo
$2 = "abcd\000ghij"


It would be nice if 'print s' and 'print foo' produced the same output,
though it wasn't clear to me how this could be achieved.

--
Paul Pluzhnikov


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