Bug 10584 - MI vars with Python pretty-printers don't get updated
Summary: MI vars with Python pretty-printers don't get updated
Status: RESOLVED FIXED
Alias: None
Product: gdb
Classification: Unclassified
Component: gdb (show other bugs)
Version: 6.8
: P2 normal
Target Milestone: 7.0
Assignee: Tom Tromey
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-09-01 08:16 UTC by Noam Yorav-Raphael
Modified: 2009-09-03 18:14 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Last reconfirmed: 2009-09-03 16:15:35


Attachments
C Source needed to recreate the bug (71 bytes, text/x-csrc)
2009-09-01 08:16 UTC, Noam Yorav-Raphael
Details
Python source needed to recreate the bug (160 bytes, text/x-python)
2009-09-01 08:17 UTC, Noam Yorav-Raphael
Details
Patch to half-fix the bug (301 bytes, patch)
2009-09-01 09:13 UTC, Noam Yorav-Raphael
Details | Diff
Workaround which works when the patch is applied (183 bytes, text/x-python)
2009-09-01 09:14 UTC, Noam Yorav-Raphael
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Noam Yorav-Raphael 2009-09-01 08:16:10 UTC
Hello,

If I create a Python pretty-printer, it doesn't get updated in GUI using gdb.
This is because the MI var doesn't get updated. To recreate:

Download bug.c, bug.py which I will attach in a minute.
> gcc -g bug.c
> gdb --int mi2
(gdb) python execfile("bug.py") # Install pretty-printer for type "MyInt"
(gdb) break main
(gdb) run
(gdb) next # do x = 3
(gdb) -var-create x * x
(gdb) next # x = 5
(gdb) -var-update * # Doesn't report x changing.

This was tested on a current CVS: 6.8.50.20090831

Thanks,
Noam
Comment 1 Noam Yorav-Raphael 2009-09-01 08:16:57 UTC
Created attachment 4162 [details]
C Source needed to recreate the bug
Comment 2 Noam Yorav-Raphael 2009-09-01 08:17:21 UTC
Created attachment 4163 [details]
Python source needed to recreate the bug
Comment 3 Noam Yorav-Raphael 2009-09-01 09:12:49 UTC
Ok, here's a workaround/half-fix:

Apply the patch. It simply comments out two lines which avoid updating a value
which has a pretty printer and for which -var-list-children was not called.
Python pretty-printers get updated without calling -var-list-children - the
attached bug.py is an example.

Now, use bug-workaround.py instead of bug.py. It seems that gdb doesn't update
the value before getting its string. bug-workaround.py references and
dereferences the value, with the effect of re-evaluating it.
Comment 4 Noam Yorav-Raphael 2009-09-01 09:13:50 UTC
Created attachment 4165 [details]
Patch to half-fix the bug
Comment 5 Noam Yorav-Raphael 2009-09-01 09:14:28 UTC
Created attachment 4166 [details]
Workaround which works when the patch is applied
Comment 6 Tom Tromey 2009-09-01 16:06:19 UTC
This code has been extensively reworked on the python branch in
the archer repository.  We've also discussed the design quite a bit
on the archer and gdb lists.
If you could try that branch, it would help.
We'll be pushing this code into CVS as soon as we all agree it is ready.
Comment 7 Noam Yorav-Raphael 2009-09-03 07:45:01 UTC
I just checked it with the archer-tromey-python branch, and it works with no
workarounds needed!
Comment 8 Noam Yorav-Raphael 2009-09-03 13:26:19 UTC
Sorry, I was mistaken. The variable was updated because the pretty-printer
wasn't used at all...
Comment 9 Noam Yorav-Raphael 2009-09-03 13:37:25 UTC
Ok. If I do -enable-pretty-printing (in the python branch), we return to the
original bug - even bug-workaround doesn't work. :-(
Comment 10 Tom Tromey 2009-09-03 16:15:34 UTC
I'm looking at it.
Comment 11 Tom Tromey 2009-09-03 18:14:25 UTC
I fixed this on the archer-tromey-python branch.