Re: [PATCH] add -s option to make -break-insert support dprintf

Pedro Alves
2013-04-12T11:34:35Z

On 04/12/2013 11:38 AM, Hui Zhu wrote:
>> >
>> > I still get:
>> >
>> > $ make check gdbserver RUNTESTFLAGS="--target_board=native-gdbserver mi-dprintf.exp"
> This part is really odd.
> In my part, without "sleep 1" will random get fail with "Set dprintf
> style to agent ".
> The reason of fail is test try to check the output before it call
> send_gdb "set dprintf-style agent\n".
> This is why I add a "sleep 1" for it.
>
> But looks it still not OK in your part, so I change it to:
> mi_gdb_test "pwd" ".*"
>
> If it is still not OK in your part, I suggest remove this part of test
> because it is not very important for this test. The "set
> dprintf-style agent" is tested in "dprintf.exp".
>

No, it's not okay. And it's not okay to just sweep it under the rug.

I believe the problem is that the test is sending CLI resumption commands:

+ mi_gdb_test "continue" ".*At foo entry.*arg=1234, g=1234.*" "mi 1st dprintf"
+ mi_gdb_test "continue" ".*At foo entry.*arg=1235, g=2222.*" "mi 2nd dprintf"

"continue" sent from MI causes two prompts to appear:

(gdb)
continue
&"continue\n"
~"Continuing.\n"
^running
*running,thread-id="all"
(gdb)
=breakpoint-modified,bkpt={number="6",type="breakpoint",disp="keep",enabled="y",addr="0x000000000045a3ff",func="main",file="../../src/gdb/gdb.c",fullname="/home/pedro/gdb/mygit/src/gdb/gdb.c",line="32",thread-groups=["i1"],times="1",original-location="/home/pedro/gdb/mygit/src/gdb/gdb.c:32"}
~"\nBreakpoint "
~"6, main (argc=1, argv=0x7fffffffdc58) at ../../src/gdb/gdb.c:32\n"
~"32\t args.use_windows = 0;\n"
*stopped,reason="breakpoint-hit",disp="keep",bkptno="6",frame={addr="0x000000000045a3ff",func="main",args=[{name="argc",value="1"},{name="argv",value="0x7fffffffdc58"}],file="../../src/gdb/gdb.c",fullname="/home/pedro/gdb/mygit/src/gdb/gdb.c",line="32"},thread-id="1",stopped-threads="all",core="0"
(gdb)

and that is confusing the test (the regex for the prompt is probably stopping
at the first prompt sometimes).

The test should be adjusted to do MI -exec-continue instead, with
mi_execute_to "exec-continue", mi_send_resuming_command "exec-continue"
or something like that.

BTW, you don't need to use gdbserver to trigger the issue. Native
works too. E.g., leave this running, and eventually, it should FAIL
and stop:

$ (set -e; while true; do make check RUNTESTFLAGS="mi-dprintf.exp"; done)

gdb/contrib/expect-read1.sh probably makes this reproducible all
the time, though I haven't tried.

--
Pedro Alves