old-cross-binutils/gdb/testsuite/gdb.mi
Pedro Alves 0c7e1a4602 PR gdb/13860: make "-exec-foo"'s MI output equal to "foo"'s MI output.
Part of PR gdb/13860 is about the mi-solib.exp test's output being
different in sync vs async modes.

sync:

  >./gdb -nx -q ./testsuite/gdb.mi/solib-main -ex "set stop-on-solib-events 1" -ex "set target-async off" -i=mi
  =thread-group-added,id="i1"
  ~"Reading symbols from /home/pedro/gdb/mygit/build/gdb/testsuite/gdb.mi/solib-main..."
  ~"done.\n"
  (gdb)
  &"start\n"
  ~"Temporary breakpoint 1 at 0x400608: file ../../../src/gdb/testsuite/gdb.mi/solib-main.c, line 21.\n"
  =breakpoint-created,bkpt={number="1",type="breakpoint",disp="del",enabled="y",addr="0x0000000000400608",func="main",file="../../../src/gdb/testsuite/gdb.mi/solib-main.c",fullname="/home/pedro/gdb/mygit/src/gdb/testsuite/gdb.mi/solib-main.c",line="21",times="0",original-location="main"}
  ~"Starting program: /home/pedro/gdb/mygit/build/gdb/testsuite/gdb.mi/solib-main \n"
  =thread-group-started,id="i1",pid="17724"
  =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"
  ~"Stopped due to shared library event (no libraries added or removed)\n"
  *stopped,reason="solib-event",frame={addr="0x000000379180f990",func="_dl_debug_state",args=[],from="/lib64/ld-linux-x86-64.so.2"},thread-id="1",stopped-threads="all",core="3"
  (gdb)

async:

  >./gdb -nx -q ./testsuite/gdb.mi/solib-main -ex "set stop-on-solib-events 1" -ex "set target-async on" -i=mi
  =thread-group-added,id="i1"
  ~"Reading symbols from /home/pedro/gdb/mygit/build/gdb/testsuite/gdb.mi/solib-main..."
  ~"done.\n"
  (gdb)
  start
  &"start\n"
  ~"Temporary breakpoint 1 at 0x400608: file ../../../src/gdb/testsuite/gdb.mi/solib-main.c, line 21.\n"
  =breakpoint-created,bkpt={number="1",type="breakpoint",disp="del",enabled="y",addr="0x0000000000400608",func="main",file="../../../src/gdb/testsuite/gdb.mi/solib-main.c",fullname="/home/pedro/gdb/mygit/src/gdb/testsuite/gdb.mi/solib-main.c",line="21",times="0",original-location="main"}
  ~"Starting program: /home/pedro/gdb/mygit/build/gdb/testsuite/gdb.mi/solib-main \n"
  =thread-group-started,id="i1",pid="17729"
  =thread-created,id="1",group-id="i1"
  ^running
  *running,thread-id="all"
  =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"
  (gdb)
  *stopped,reason="solib-event",thread-id="1",stopped-threads="all",core="1"

For now, let's focus only on the *stopped event.  We see that the
async output is missing frame info.  And this causes a test failure in
async mode, as "mi_expect_stop solib-event" wants to see the frame
info.

However, if we compare the event output when a real MI execution
command is used, compared to a CLI command (e.g., run vs -exec-run,
next vs -exec-next, etc.), we see:

  >./gdb -nx -q ./testsuite/gdb.mi/solib-main -ex "set stop-on-solib-events 1" -ex "set target-async off" -i=mi
  =thread-group-added,id="i1"
  ~"Reading symbols from /home/pedro/gdb/mygit/build/gdb/testsuite/gdb.mi/solib-main..."
  ~"done.\n"
  (gdb)
  r
  &"r\n"
  ~"Starting program: /home/pedro/gdb/mygit/build/gdb/testsuite/gdb.mi/solib-main \n"
  =thread-group-started,id="i1",pid="17751"
  =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"
  ~"Stopped due to shared library event (no libraries added or removed)\n"
  *stopped,reason="solib-event",frame={addr="0x000000379180f990",func="_dl_debug_state",args=[],from="/lib64/ld-linux-x86-64.so.2"},thread-id="1",stopped-threads="all",core="3"
  (gdb)
  -exec-run
  =thread-exited,id="1",group-id="i1"
  =thread-group-exited,id="i1"
  =library-unloaded,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",thread-group="i1"
  =thread-group-started,id="i1",pid="17754"
  =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"
  *stopped,reason="solib-event",thread-id="1",stopped-threads="all",core="1"
  =thread-selected,id="1"
  (gdb)

As seen above, with MI commands, the *stopped event _doesn't_ have
frame info.  This is because normal_stop, as commanded by the result
of bpstat_print, skips printing frame info in this case (it's an
"event", not a "breakpoint"), and when the interpreter is MI,
mi_on_normal_stop skips calling print_stack_frame, as the normal_stop
call was already done with the MI uiout.  This explains why the async
output is different even with a CLI command.  Its because in async
mode, the mi_on_normal_stop path is always taken; it is always reached
with the MI uiout, because the stop is handled from the event loop,
instead of from within `proceed -> wait_for_inferior -> normal_stop'
with the interpreter overridden, as in sync mode.

This patch fixes the issue by making all cases output the same
*stopped event, by factoring out the print code from normal_stop, and
using it from mi_on_normal_stop as well.  I chose the *stopped output
without a frame, mainly because that is what you already get if you
use MI execution commands, the commands frontends are supposed to use
(except when implementing a console).  This patch makes it simpler to
tweak the MI output differently if desired, as we only have to change
the centralized print_stop_event (taking into account whether the
uiout is MI-like), and all different modes will change accordingly.

Tested on x86_64 Fedora 17, no regressions.  The mi-solib.exp test no
longer fails in async mode with this patch, so the patch removes the
kfail.

2014-03-18  Pedro Alves  <palves@redhat.com>

	PR gdb/13860
	* inferior.h (print_stop_event): Declare.
	* infrun.c (print_stop_event): New, factored out from ...
	(normal_stop): ... this.
	* mi/mi-interp.c (mi_on_normal_stop): Use print_stop_event instead
	of bpstat_print/print_stack_frame.

2014-03-18  Pedro Alves  <palves@redhat.com>

	PR gdb/13860
	* gdb.mi/mi-solib.exp: Remove gdb/13860 kfail.
	* lib/mi-support.exp (mi_expect_stop): Add special handling for
	solib-event.
2014-03-18 17:50:28 +00:00
..
array.f Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
basics.c Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
ChangeLog-1999-2003
dw2-ref-missing-frame-func.c Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
dw2-ref-missing-frame-main.c Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
dw2-ref-missing-frame.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
dw2-ref-missing-frame.S Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
gdb669.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
gdb680.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
gdb701.c
gdb701.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
gdb792.cc
gdb792.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
gdb2549.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
Makefile.in
mi-async.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
mi-basics.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
mi-break.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
mi-breakpoint-changed.exp Test no =breakpoint-modified is emitted for modifications from MI commands 2014-02-08 09:41:01 +08:00
mi-catch-load-so.c Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
mi-catch-load.c Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
mi-catch-load.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
mi-cli.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
mi-cmd-param-changed.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
mi-console.c gdb.mi/mi-console.c, gdb.mi/mi-stack.c: Remove local emacs variables defining change-log-default-name. 2013-10-29 13:48:25 +00:00
mi-console.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
mi-disassemble.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
mi-dprintf.c Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
mi-dprintf.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
mi-eval.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
mi-file-transfer.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
mi-file.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
mi-fill-memory.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
mi-fullname-deleted.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
mi-hack-cli.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
mi-i-cmd.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
mi-info-os.exp gdb.mi/mi-info-os.exp: Fix cross-debugger testing 2014-01-09 19:57:13 +00:00
mi-inheritance-syntax-error.cc
mi-inheritance-syntax-error.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
mi-language.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
mi-logging.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
mi-memory-changed.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
mi-nonstop-exit.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
mi-nonstop.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
mi-ns-stale-regcache.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
mi-nsintrall.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
mi-nsmoribund.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
mi-nsthrexec.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
mi-pending.c Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
mi-pending.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
mi-pendshr.c Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
mi-pthreads.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
mi-read-memory.c
mi-read-memory.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
mi-record-changed.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
mi-reg-undefined.c Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
mi-reg-undefined.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
mi-reg-undefined.S Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
mi-regs.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
mi-return.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
mi-reverse.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
mi-simplerun.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
mi-solib.exp PR gdb/13860: make "-exec-foo"'s MI output equal to "foo"'s MI output. 2014-03-18 17:50:28 +00:00
mi-stack.c Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
mi-stack.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
mi-start.c Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
mi-start.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
mi-stepi.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
mi-stepn.c Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
mi-stepn.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
mi-syn-frame.c
mi-syn-frame.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
mi-undefined-cmd.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
mi-until.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
mi-var-block.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
mi-var-child-f.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
mi-var-child.c Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
mi-var-child.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
mi-var-cmd.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
mi-var-cp.cc Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
mi-var-cp.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
mi-var-create-rtti.c Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
mi-var-create-rtti.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
mi-var-display.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
mi-var-invalidate.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
mi-var-rtti.cc Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
mi-var-rtti.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
mi-watch-nonstop.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
mi-watch.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
mi2-amd64-entry-value.c Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
mi2-amd64-entry-value.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
mi2-amd64-entry-value.s Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
mi2-prompt.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
mi2-var-child.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
non-stop-exit.c Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
non-stop.c Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
ns-stale-regcache.c Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
nsintrall.c Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
nsmoribund.c Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
nsthrexec.c Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
pending.c Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
pendshr1.c Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
pendshr2.c Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
pr11022.c Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
pr11022.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
pthreads.c Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
solib-lib.c Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
solib-main.c Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
testcmds
until.c
var-cmd.c Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
watch-nonstop.c Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00