public inbox for gdb-prs@sourceware.org help / color / mirror / Atom feed
From: "zub at linux dot fjfi.cvut.cz" <sourceware-bugzilla@sourceware.org> To: gdb-prs@sourceware.org Subject: [Bug python/14320] New: Strange python script behaviour Date: Sun, 01 Jul 2012 18:43:00 -0000 [thread overview] Message-ID: <bug-14320-4717@http.sourceware.org/bugzilla/> (raw) http://sourceware.org/bugzilla/show_bug.cgi?id=14320 Bug #: 14320 Summary: Strange python script behaviour Product: gdb Version: 7.4 Status: NEW Severity: normal Priority: P2 Component: python AssignedTo: unassigned@sourceware.org ReportedBy: zub@linux.fjfi.cvut.cz Classification: Unclassified Target: x86, x86_64 Created attachment 6506 --> http://sourceware.org/bugzilla/attachment.cgi?id=6506 Standalone testcase. I found a strange behaviour trying to implement a pretty printer. Attached is a test case (just unpack and run make). The issue is reproducible both with 7.4.1 release and with CVS head as of now (7.4.50.20120701-cvs). (It's also present in Debian testing and Ubuntu 12.04.) Assumming a C++ class: struct Foo { int *m_ptr; }; the following pretty printing class: class MyTestPrinter: def __init__(self, val): self.val = val def get_ptr(self): return self.val['m_ptr'] def children(self): print "foo" def to_string(self): return "0x%08x" % self.get_ptr() causes a strange error message: $1 = 0x7fffffffe390Traceback (most recent call last): File "test-printer.py", line 11, in children print "foo" File "<string>", line 13, in write gdb.error: Cannot convert value to int. The body of MyTestPrinter.to_string() might be wrong (using a gdb.Value for a pointer with %08x), but the actual error message complains about the 'print "foo"'. But the print is ok, so the error message is highly confusing. To make this matter more mysterious, doing any of the following makes the error disappear: * remove MyTestPrinter.children() * add a long cast to MyTestPrinter.to_string(): return "0x%08x" % long(self.get_ptr()) So, if MyTestPrinter.to_string() is wrong, it should produce an appropriate error message, and it should be consistent, no matter if there's any MyTestPrinter.children() or not. Or, if MyTestPrinter.to_string() is correct, then the print in MyTestPrinter.children() should not cause any error. It seems that it's not caused by print (in MyTestPrinter.children()) itself, but by the string literal, as I can get the same kind of error message for other things involving string literals in MyTestPrinter.children(). -- Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug.
next reply other threads:[~2012-07-01 18:43 UTC|newest] Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top 2012-07-01 18:43 zub at linux dot fjfi.cvut.cz [this message] 2012-07-01 18:47 ` [Bug python/14320] " zub at linux dot fjfi.cvut.cz 2012-07-01 19:03 ` zub at linux dot fjfi.cvut.cz 2012-07-01 19:22 ` zub at linux dot fjfi.cvut.cz 2012-07-31 16:50 ` tromey at redhat dot com 2012-07-31 20:01 ` tromey at redhat dot com 2012-08-01 16:54 ` tromey at redhat dot com
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-14320-4717@http.sourceware.org/bugzilla/ \ --to=sourceware-bugzilla@sourceware.org \ --cc=gdb-prs@sourceware.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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).