public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug mi/16205] New: hook-run output printed after run finishes
@ 2013-11-22 16:45 finngrimwood at gmail dot com
  0 siblings, 0 replies; only message in thread
From: finngrimwood at gmail dot com @ 2013-11-22 16:45 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=16205

            Bug ID: 16205
           Summary: hook-run output printed after run finishes
           Product: gdb
           Version: HEAD
            Status: NEW
          Severity: minor
          Priority: P2
         Component: mi
          Assignee: unassigned at sourceware dot org
          Reporter: finngrimwood at gmail dot com

I'm having a problem where pre-hooks are behaving unexpectedly when running in
MI mode. Specifically, I want to show a value before 'run' commences. I'm using
a hook-run user defined function to do this, but the result doesn't get
displayed in the terminal until after the command has finished. This all works
fine in CLI mode.

How to repeat:

echo "int main() { }" | gcc -x c -
echo -e "define hook-run\nset remotelogfile test.log\nshow remotelogfile\nend"
> x
gdb -i=mi -x x ./a.out

<... snip GDB startup>

(gdb) 
-exec-run
=thread-group-started,id="i1",pid="12215"
=thread-created,id="1",group-id="i1"
^running
*running,thread-id="all"
(gdb) 
=library-loaded,id="/lib64/ld-linux-x86-64.so.2",target-name="/lib64/ld-linux-x86-64.so.2",host-name="/lib64/ld-linux-x86-64.so.2",symbols-loaded="0",thread-group="i1"
=library-loaded,id="/lib64/libc.so.6",target-name="/lib64/libc.so.6",host-name="/lib64/libc.so.6",symbols-loaded="0",thread-group="i1"
=thread-exited,id="1",group-id="i1"
=thread-group-exited,id="i1"
*stopped,value="test.log",reason="exited",exit-code="0140"
(gdb) 

         ^^^^^^^^^^^^^^^^ I would have expected this to come before any other
output!

I've had a look at the source, and I think the reason that it all works in CLI
mode is because of the call to deprecated_show_value_hack() in
do_show_command(). This forces the result to be printed to the terminal
immediately.

There is, however, no such equivalent for MI mode, and the result only appears
in the terminal once we return to the captured_mi_execute_command() function
and enter the "if(!running_result_record_printed)" conditional. By the time we
get here we're too late to print something out before the run command is
executed. It seems to me that the fix would be to force the contents of hook
commands to be printed out immediately.

I'm happy to put together a diff that fixes this, although exactly where this
fix should go isn't immediately obvious to me. Can someone with more
familiarity with the MI stuff suggest the appropriate location?

Additional info:

GDB Release:
GNU gdb (GDB) 7.6.50.20131121-cvs

Output of uname -a: 
Linux donny 2.6.32-358.el6.x86_64 #1 SMP Fri Feb 22 00:31:26 UTC 2013 x86_64
x86_64 x86_64 GNU/Linux

Output of gcc -v:
gcc version 4.4.7 20120313 (Red Hat 4.4.7-3) (GCC)

And the configuration: 
This GDB was configured as "x86_64-unknown-linux-gnu"

-- 
You are receiving this mail because:
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2013-11-22 16:45 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-11-22 16:45 [Bug mi/16205] New: hook-run output printed after run finishes finngrimwood at gmail 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).