Summary: | python execute(to_string=True) no longer captures certain output since e7ea3ec7 | ||
---|---|---|---|
Product: | gdb | Reporter: | sourceware-bugzilla |
Component: | python | Assignee: | Not yet assigned to anyone <unassigned> |
Status: | NEW --- | ||
Severity: | normal | CC: | autkin, catalin.udma, simark, tromey |
Priority: | P2 | ||
Version: | HEAD | ||
Target Milestone: | --- | ||
Host: | Target: | ||
Build: | Last reconfirmed: | 2017-09-03 00:00:00 | |
Attachments: | a hacky fix |
Description
sourceware-bugzilla
2017-05-20 14:54:59 UTC
I've also noticed this when using my python gdb gui -- the gui uses to_string=True for some commands to suppress output, but gdb still emits the output anyway now. For example in my case it happens in tui_on_normal_stop, which calls print_stop_event for each UI. I'm not sure what can be done about this. if nothing, it's worth noting that the output is sub-par as well: (top) 30 args.argv = argv; 31 args.interpreter_p = INTERP_CONSOLE; ... that is, it doesn't try to erase the prompt first. I don't understand all the interps/uiouts dynamics yet, so I'm not sure what the solution should be, but the problem seems to be that: - We install the "console" interpreter's uiout in execute_gdb_command as the current_uiout. - We set up the redirection on the "tui" interpreter's uiout (in execute_command_to_string). They are two different cli_ui_out instances. When the print is done, the active uiout is therefore the one that doesn't have the redirection. It's probably not the right fix, but just to illustrate, this change makes it work for me (though probably break other stuff): diff --git a/gdb/python/python.c b/gdb/python/python.c index 9eae8a1aef2d..5ca58578040f 100644 --- a/gdb/python/python.c +++ b/gdb/python/python.c @@ -587,7 +587,7 @@ execute_gdb_command (PyObject *self, PyObject *args, PyObject *kw) /* Use the console interpreter uiout to have the same print format for console or MI. */ - interp = interp_lookup (current_ui, "console"); + interp = interp_lookup (current_ui, "tui"); current_uiout = interp_ui_out (interp); scoped_restore preventer = prevent_dont_repeat (); (In reply to Simon Marchi from comment #2) > It's probably not the right fix, but just to illustrate, this change makes > it work for me (though probably break other stuff): Indeed, this patch makes one of our tests work, but causes segfaults in other cases. Program terminated with signal SIGSEGV, Segmentation fault. #0 ui_out::redirect (this=0x0, outstream=outstream@entry=0x7ffc20a6da90) at ui-out.c:611 611 do_redirect (outstream); (gdb) bt #0 ui_out::redirect (this=0x0, outstream=outstream@entry=0x7ffc20a6da90) at ui-out.c:611 #1 0x000055a450e2589f in execute_command_to_string[abi:cxx11](char const*, int) (p=0x7f8ab460bc24 "info proc", from_tty=from_tty@entry=0) at top.c:673 #2 0x000055a450c28368 in execute_gdb_command (self=<optimized out>, args=<optimized out>, kw=<optimized out>) at python/python.c:600 ... Created attachment 11206 [details]
a hacky fix
The patch which I won't recommend to upstream, but it happens to help in this specific situation while not causing noticeable issues in other tests I have run.
Alternative, and perhaps better, solutiuon may be to temporarily replace ui_list.
|