public inbox for gdb-prs@sourceware.org help / color / mirror / Atom feed
* [Bug python/11417] New: lazy string of zero length requires a valid pointer @ 2010-03-22 15:29 zilla at kayari dot org 2010-03-24 17:23 ` [Bug python/11417] " pmuldoon at redhat dot com 2010-04-08 10:30 ` pmuldoon at redhat dot com 0 siblings, 2 replies; 3+ messages in thread From: zilla at kayari dot org @ 2010-03-22 15:29 UTC (permalink / raw) To: gdb-prs I don't know if this behaviour is intentional, but it used to work when I was using gdb.Value.string and fails with gdb.Value.lazy_string I have a pretty printer for a string-like C++ class holding a char pointer and a length. The pointer can be NULL, in which case the length will be 0. struct Str { Str(const char* s = 0) : str(s), len(s ? strlen(s) : 0) { } const char* str; int len; }; Previously my pretty printer looked like: class StrPrinter: "Print a Str" def __init__ (self, val): self.val = val def to_string (self): return '"' + self.val['str'].string('', 'ignore', self.val['len']) + '"' If the pointer was null this printed "" (gdb) p/r null $5 = {str = 0x0, len = 0} (gdb) p null $6 = "" (this despite the docs for Value.string saying "The string is assumed to be terminated by a zero of the appropriate width.") I changed the printer to: class Str2Printer: "Print a Str2" def __init__ (self, val): self.val = val def to_string (self): return self.val['str'].lazy_string('', self.val['len']) I like that I don't need to add double-quotes now, but it seems I now need to handle NULL explicitly because lazy string doesn't like NULL even when the length is zero: (gdb) p/r null2 $2 = {str = 0x0, len = 0} (gdb) p null2 $3 = Traceback (most recent call last): File "/home/wakelj/src/tests/pretty/str-gdb.py", line 23, in to_string return self.val['str'].lazy_string('', self.val['len']) MemoryError: Cannot create a lazy string from a GDB-side string. Are these differences between Value.string and Value.lazy_string intentional? -- Summary: lazy string of zero length requires a valid pointer Product: gdb Version: 7.1 Status: UNCONFIRMED Severity: normal Priority: P2 Component: python AssignedTo: unassigned at sourceware dot org ReportedBy: zilla at kayari dot org CC: gdb-prs at sourceware dot org http://sourceware.org/bugzilla/show_bug.cgi?id=11417 ------- You are receiving this mail because: ------- You are on the CC list for the bug, or are watching someone who is. ^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug python/11417] lazy string of zero length requires a valid pointer 2010-03-22 15:29 [Bug python/11417] New: lazy string of zero length requires a valid pointer zilla at kayari dot org @ 2010-03-24 17:23 ` pmuldoon at redhat dot com 2010-04-08 10:30 ` pmuldoon at redhat dot com 1 sibling, 0 replies; 3+ messages in thread From: pmuldoon at redhat dot com @ 2010-03-24 17:23 UTC (permalink / raw) To: gdb-prs ------- Additional Comments From pmuldoon at redhat dot com 2010-03-24 17:23 ------- This looks bogus. The lazy string code seems to be incorrectly identifying the string as a GDB side string (ie not in the inferior, has no address in the inferior and is stored in GDB). Patch forthcoming. -- What |Removed |Added ---------------------------------------------------------------------------- AssignedTo|unassigned at sourceware dot|pmuldoon at redhat dot com |org | Status|UNCONFIRMED |ASSIGNED Ever Confirmed| |1 http://sourceware.org/bugzilla/show_bug.cgi?id=11417 ------- You are receiving this mail because: ------- You are on the CC list for the bug, or are watching someone who is. ^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug python/11417] lazy string of zero length requires a valid pointer 2010-03-22 15:29 [Bug python/11417] New: lazy string of zero length requires a valid pointer zilla at kayari dot org 2010-03-24 17:23 ` [Bug python/11417] " pmuldoon at redhat dot com @ 2010-04-08 10:30 ` pmuldoon at redhat dot com 1 sibling, 0 replies; 3+ messages in thread From: pmuldoon at redhat dot com @ 2010-04-08 10:30 UTC (permalink / raw) To: gdb-prs ------- Additional Comments From cvs-commit at gcc dot gnu dot org 2010-04-08 10:28 ------- Subject: Bug 11417 CVSROOT: /cvs/src Module name: src Changes by: pmuldoon@sourceware.org 2010-04-08 10:28:42 Modified files: gdb : ChangeLog gdb/python : py-lazy-string.c gdb/testsuite : ChangeLog gdb/testsuite/gdb.python: py-value.c py-value.exp Log message: 2010-04-08 Phil Muldoon <pmuldoon@redhat.com> PR python/11417 * python/py-lazy-string.c (stpy_convert_to_value): Check for a NULL address. (gdbpy_create_lazy_string_object): Allow strings with a NULL address and a zero length. 2010-04-08 Phil Muldoon <pmuldoon@redhat.com> * gdb.python/py-value: Add null string variable. (test_lazy_string): Test zero length, NULL address lazy strings. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/ChangeLog.diff?cvsroot=src&r1=1.11587&r2=1.11588 http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/python/py-lazy-string.c.diff?cvsroot=src&r1=1.2&r2=1.3 http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/testsuite/ChangeLog.diff?cvsroot=src&r1=1.2226&r2=1.2227 http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/testsuite/gdb.python/py-value.c.diff?cvsroot=src&r1=1.4&r2=1.5 http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/testsuite/gdb.python/py-value.exp.diff?cvsroot=src&r1=1.7&r2=1.8 ------- Additional Comments From pmuldoon at redhat dot com 2010-04-08 10:30 ------- Commited fix upstream, see comment #2. -- What |Removed |Added ---------------------------------------------------------------------------- Status|ASSIGNED |RESOLVED Resolution| |FIXED Target Milestone|7.1 |7.2 http://sourceware.org/bugzilla/show_bug.cgi?id=11417 ------- You are receiving this mail because: ------- You are on the CC list for the bug, or are watching someone who is. ^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2010-04-08 10:30 UTC | newest] Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2010-03-22 15:29 [Bug python/11417] New: lazy string of zero length requires a valid pointer zilla at kayari dot org 2010-03-24 17:23 ` [Bug python/11417] " pmuldoon at redhat dot com 2010-04-08 10:30 ` pmuldoon at redhat dot com
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).