From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22705 invoked by alias); 19 Aug 2011 11:03:50 -0000 Received: (qmail 22678 invoked by uid 22791); 19 Aug 2011 11:03:49 -0000 X-SWARE-Spam-Status: No, hits=-2.8 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from localhost (HELO sourceware.org) (127.0.0.1) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 19 Aug 2011 11:03:34 +0000 From: "developer at audioranger dot com" To: gdb-prs@sourceware.org Subject: [Bug python/13111] New: "-var-update" command incorrect when using pretty printers Date: Fri, 19 Aug 2011 15:46:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gdb X-Bugzilla-Component: python X-Bugzilla-Keywords: X-Bugzilla-Severity: minor X-Bugzilla-Who: developer at audioranger dot com X-Bugzilla-Status: NEW X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: unassigned at sourceware dot org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: Message-ID: X-Bugzilla-URL: http://sourceware.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 Mailing-List: contact gdb-prs-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-prs-owner@sourceware.org X-SW-Source: 2011-q3/txt/msg00235.txt.bz2 http://sourceware.org/bugzilla/show_bug.cgi?id=13111 Bug #: 13111 Summary: "-var-update" command incorrect when using pretty printers Product: gdb Version: 7.3 Status: NEW Severity: minor Priority: P2 Component: python AssignedTo: unassigned@sourceware.org ReportedBy: developer@audioranger.com Classification: Unclassified The gdb/mi command "-var-update" may return an incorrect value for "type_changed" when pretty-printers are used. Consider the following example. The struct "printMePretty" should be pretty-printed by using the Python TestPrinter class from below. It should be printed as an integer "array" (it doesn't actually makes sense here, it's just for testing) if the structure's "printAsInt" member is true, and as a floating point "array" otherwise. ****************** File: main.cpp ***************** struct printMePretty { bool printAsInt; int intMember; float floatMember; printMePretty() : printAsInt(true), intMember(0xFF), floatMember(3.1415) { } }; void main() { printMePretty pretty; pretty.printAsInt = false; } ****************** File: printer.py ***************** [...] class TestPrinter: class _iterator: def __init__(self, val): self.val = val self.index = 0 def __iter__(self): return self def next(self): if self.index == 1: raise StopIteration if self.val['printAsInt']: childValue = self.val['intMember'] else: childValue = self.val['floatMember'] self.index += 1 return ('Value', childValue) def __init__(self, val): self.val = val def children(self): return self._iterator(self.val) def display_hint(self): return 'array' ****************** End of file ***************** Using Eclipse CDT to trace gdb/mi commands, one encounters the following until the line "pretty.printAsInt = false;": -var-create --thread 1 --frame 0 - * pretty ^done,name="var1",numchild="0",value="{...}",type="printMePretty",thread-id="1",displayhint="array",dynamic="1",has_more="1" -var-list-children var1 0 1 ^done,numchild="1",displayhint="array",children=[child={name="var1.Value",exp="Value",numchild="0",type="int",thread-id="1"}],has_more="0" OK, so "var1.Value" has type "int". Now, stepping over the line "pretty.printAsInt = false;" results in: -var-update 1 var1 ^done,changelist=[{name="var1.Value",value="3.1415",in_scope="true",type_changed="false",displayhint="array",dynamic="1",has_more="0"}] It now says that "var1.Value" would have a "value" of "3.1415" - that's obviously a strange value for an "int" (since "type_changed" reports "false" - I suppose it should actually report that the type has changed to "float"). This seems like a bug within gdb to me. The same problem may also apply if a pretty-printer's toString() method returns gdb.Values which have different gdb.Types, depending on the data members of the structure which should be pretty-printed. -- 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.