2016-01-01 04:33:14 +00:00
|
|
|
# Copyright 2008-2016 Free Software Foundation, Inc.
|
2008-10-15 19:15:34 +00:00
|
|
|
|
|
|
|
# This program is free software; you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation; either version 3 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
2011-07-18 04:14:21 +00:00
|
|
|
if { ![support_displaced_stepping] } {
|
|
|
|
unsupported "displaced stepping"
|
|
|
|
return -1
|
|
|
|
}
|
|
|
|
|
2008-10-15 19:15:34 +00:00
|
|
|
load_lib mi-support.exp
|
|
|
|
set MIFLAGS "-i=mi"
|
|
|
|
|
|
|
|
gdb_exit
|
|
|
|
if {[mi_gdb_start]} {
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
|
|
|
|
#
|
|
|
|
# Start here
|
|
|
|
#
|
2012-07-10 15:32:52 +00:00
|
|
|
standard_testfile nsmoribund.c
|
2008-10-15 19:15:34 +00:00
|
|
|
|
2012-07-10 15:32:52 +00:00
|
|
|
set options [list debug]
|
2008-10-15 19:15:34 +00:00
|
|
|
if {[gdb_compile_pthreads "$srcdir/$subdir/$srcfile" $binfile executable $options] != "" } {
|
|
|
|
return -1
|
|
|
|
}
|
|
|
|
|
|
|
|
mi_gdb_reinitialize_dir $srcdir/$subdir
|
|
|
|
mi_gdb_load $binfile
|
|
|
|
|
|
|
|
mi_gdb_test "-gdb-set non-stop 1" ".*"
|
enable target async by default; separate MI and target notions of async
This finally makes background execution commands possible by default.
However, in order to do that, there's one last thing we need to do --
we need to separate the MI and target notions of "async". Unlike the
CLI, where the user explicitly requests foreground vs background
execution in the execution command itself (c vs c&), MI chose to treat
"set target-async" specially -- setting it changes the default
behavior of execution commands.
So, we can't simply "set target-async" default to on, as that would
affect MI frontends. Instead we have to make the setting MI-specific,
and teach MI about sync commands on top of an async target.
Because the "target" word in "set target-async" ends up as a potential
source of confusion, the patch adds a "set mi-async" option, and makes
"set target-async" a deprecated alias.
Rather than make the targets always async, this patch introduces a new
"maint set target-async" option so that the GDB developer can control
whether the target is async. This makes it simpler to debug issues
arising only in the synchronous mode; important because sync mode
seems unlikely to go away.
Unlike in previous revisions, "set target-async" does not affect this
new maint parameter. The rationale for this is that then one can
easily run the test suite in the "maint set target-async off" mode and
have tests that enable mi-async fail just like they fail on
non-async-capable targets. This emulation is exactly the point of the
maint option.
I had asked Tom in a previous iteration to split the actual change of
the target async default to a separate patch, but it turns out that
that is quite awkward in this version of the patch, because with MI
async and target async decoupled (unlike in previous versions), if we
don't flip the default at the same time, then just "set target-async
on" alone never actually manages to do anything. It's best to not
have that transitory state in the tree.
Given "set target-async on" now only has effect for MI, the patch goes
through the testsuite removing it from non-MI tests. MI tests are
adjusted to use the new and less confusing "mi-async" spelling.
2014-05-29 Pedro Alves <palves@redhat.com>
Tom Tromey <tromey@redhat.com>
* NEWS: Mention "maint set target-async", "set mi-async", and that
background execution commands are now always available.
* target.h (target_async_permitted): Update comment.
* target.c (target_async_permitted, target_async_permitted_1):
Default to 1.
(set_target_async_command): Rename to ...
(maint_set_target_async_command): ... this.
(show_target_async_command): Rename to ...
(maint_show_target_async_command): ... this.
(_initialize_target): Adjust.
* infcmd.c (prepare_execution_command): Make extern.
* inferior.h (prepare_execution_command): Declare.
* infrun.c (set_observer_mode): Leave target async alone.
* mi/mi-interp.c (mi_interpreter_init): Install
mi_on_sync_execution_done as sync_execution_done observer.
(mi_on_sync_execution_done): New function.
(mi_execute_command_input_handler): Don't print the prompt if we
just started a synchronous command with an async target.
(mi_on_resume): Check sync_execution before printing prompt.
* mi/mi-main.h (mi_async_p): Declare.
* mi/mi-main.c: Include gdbcmd.h.
(mi_async_p): New function.
(mi_async, mi_async_1): New globals.
(set_mi_async_command, show_mi_async_command, mi_async): New
functions.
(exec_continue): Call prepare_execution_command.
(run_one_inferior, mi_cmd_exec_run, mi_cmd_list_target_features)
(mi_execute_async_cli_command): Use mi_async_p.
(_initialize_mi_main): Install "set mi-async". Make
"target-async" a deprecated alias.
2014-05-29 Pedro Alves <palves@redhat.com>
Tom Tromey <tromey@redhat.com>
* gdb.texinfo (Non-Stop Mode): Remove "set target-async 1"
from example.
(Asynchronous and non-stop modes): Document '-gdb-set mi-async'.
Mention that target-async is now deprecated.
(Maintenance Commands): Document maint set/show target-async.
2014-05-29 Pedro Alves <palves@redhat.com>
Tom Tromey <tromey@redhat.com>
* gdb.base/async-shell.exp: Don't enable target-async.
* gdb.base/async.exp
* gdb.base/corefile.exp (corefile_test_attach): Remove 'async'
parameter. Adjust.
(top level): Don't test with "target-async".
* gdb.base/dprintf-non-stop.exp: Don't enable target-async.
* gdb.base/gdb-sigterm.exp: Don't test with "target-async".
* gdb.base/inferior-died.exp: Don't enable target-async.
* gdb.base/interrupt-noterm.exp: Likewise.
* gdb.mi/mi-async.exp: Use "mi-async" instead of "target-async".
* gdb.mi/mi-nonstop-exit.exp: Likewise.
* gdb.mi/mi-nonstop.exp: Likewise.
* gdb.mi/mi-ns-stale-regcache.exp: Likewise.
* gdb.mi/mi-nsintrall.exp: Likewise.
* gdb.mi/mi-nsmoribund.exp: Likewise.
* gdb.mi/mi-nsthrexec.exp: Likewise.
* gdb.mi/mi-watch-nonstop.exp: Likewise.
* gdb.multi/watchpoint-multi.exp: Adjust comment.
* gdb.python/py-evsignal.exp: Don't enable target-async.
* gdb.python/py-evthreads.exp: Likewise.
* gdb.python/py-prompt.exp: Likewise.
* gdb.reverse/break-precsave.exp: Don't test with "target-async".
* gdb.server/solib-list.exp: Don't enable target-async.
* gdb.threads/thread-specific-bp.exp: Likewise.
* lib/mi-support.exp: Adjust to use mi-async.
2014-05-29 18:58:57 +00:00
|
|
|
mi_gdb_test "-gdb-set mi-async 1" ".*"
|
2011-08-09 17:45:19 +00:00
|
|
|
mi_detect_async
|
2008-10-15 19:15:34 +00:00
|
|
|
|
2009-04-02 15:43:10 +00:00
|
|
|
if { [mi_run_to_main] < 0 } {
|
|
|
|
continue
|
2008-10-15 19:15:34 +00:00
|
|
|
}
|
|
|
|
|
2011-04-19 18:04:11 +00:00
|
|
|
# Keep this in sync with THREADS in the $srcfile.
|
2008-10-15 19:15:34 +00:00
|
|
|
set nthreads 10
|
|
|
|
|
|
|
|
# Set a breakpoint and let all threads hit it (except the main
|
|
|
|
# thread).
|
|
|
|
|
|
|
|
set bkpt_line [gdb_get_line_number "set breakpoint here"]
|
|
|
|
|
Introduce some new MI test suite cleanups for breakpoint and
breakpoint table handling. This is a patch in five parts (all committed
here in one commit).
----- 1/5: parse_args
parse_args is a very useful utility function which allows you to do
getopt-y kinds of things in Tcl.
Example:
proc myproc {foo args} {
parse_args {{bar} {baz "abc"} {qux}}
# ...
}
myproc ABC -bar -baz DEF peanut butter
will define the following variables in myproc:
foo (=ABC), bar (=1), baz (=DEF), and qux (=0)
args will be the list {peanut butter}
----- 2/5: mi_build_kv_pairs
build_kv_pairs simply does what it says: given the input list
and an option join string, it combines list elements into kv-pairs
for MI handling. It knows how to handle tuples and other special
MI types.
Example:
mi_build_kv_pairs {a b c d e f g \[.*\]}
returns a=\"b\",c=\"d\",e=\"f\",g=\[.*\]
----- 3/5: mi_make_breakpoint
This function builds breakpoint regexps, such as
"bkpt={number=\".*\", [snip]}".
Note that ONLY the options given to mi_make_breakpoint/mi_create_breakpoint
will actually be tested. So if -number is omitted, the regexp will allow
anything [number=\".*\"]
Examples:
mi_make_breakpoint -number 3
mi_create_breakpoint "myfile.c:21" -file myfile.c -line 21
----- 4/5: mi_make_breakpoint_table
This function builds MI breakpoint table regexps.
Example:
set bps {}
lappend bps [mi_make_breakpoint -number 1 -func "main" \
-file ".*/myfile.c" -line 42
lappend bps [mi_make_breakpoint -number 2 -func "marker" \
-file ".*myfile.c" -line 21
gdb_test "-break-info" "\\^done,[mi_make_breakpoint_table $bps]" \
"breakpoint list"
----- 5/5: Update all callers
Self-explanatory
testsuite/ChangeLog
2014-04-23 Keith Seitz <keiths@redhat.com>
* lib/mi-support.exp (mi_list_breakpoints): Delete.
(mi_make_breakpoint_table): New procedure.
(mi_create_breakpoint): Use mi_make_breakpoint
and return the result.
(mi_make_breakpoint): New procedure.
(mi_build_kv_pairs): New procedure.
* gdb.mi/mi-break.exp: Remove unused globals,
update mi_create_breakpoint usage, and use mi_make_breakpoint_table.
All callers updated.
* gdb.mi/mi-dprintf.exp: Use variable to track command
number.
Update all callers of mi_create_breakpoint and use
mi_make_breakpoint_table.
Remove any unused global variables.
* gdb.mi/mi-nonstop.exp: Likewise.
* gdb.mi/mi-nsintrall.exp: Likewise.
* gdb.mi/mi-nsmoribund.exp: Likewise.
* gdb.mi/mi-nsthrexec.exp: Likewise.
* gdb.mi/mi-reverse.exp: Likewise.
* gdb.mi/mi-simplerun.exp: Likewise.
* gdb.mi/mi-stepn.exp: Likewise.
* gdb.mi/mi-syn-frame.exp: Likewise.
* gdb.mi/mi-until.exp: Likewise.
* gdb.mi/mi-var-cp.exp: Likewise.
* gdb.mi/mi-var-display.exp: Likewise.
* gdb.mi/mi2-amd64-entry-value.exp: Likewise.
* gdb.mi/mi2-var-child.exp: Likewise.
* gdb.mi/mi-vla-c99.exp: Likewise.
* lib/mi-support.exp: Likewise.
From Ian Lance Taylor <iant@cygnus.com>:
* lib/gdb.exp (parse_args): New procedure.
2014-04-23 19:17:31 +00:00
|
|
|
mi_create_breakpoint "$srcfile:$bkpt_line" \
|
|
|
|
"breakpoint at thread_function" \
|
|
|
|
-number 2 -function thread_function
|
2008-10-15 19:15:34 +00:00
|
|
|
|
|
|
|
mi_send_resuming_command "exec-continue --all" "resume all"
|
|
|
|
for {set i 0} {$i < $nthreads} {incr i} {
|
|
|
|
mi_expect_stop "breakpoint-hit" "thread_function" "\[^\n\]*" "$srcfile" \
|
|
|
|
"\[0-9\]*" {"" "disp=\"keep\""} "stop $i"
|
|
|
|
}
|
|
|
|
|
|
|
|
# All but the main thread should have hit it.
|
|
|
|
|
|
|
|
mi_check_thread_states \
|
|
|
|
{"running" "stopped" "stopped" "stopped" "stopped" "stopped" "stopped" "stopped" "stopped" "stopped" "stopped"} \
|
|
|
|
"thread state: all stopped except the main thread"
|
|
|
|
|
|
|
|
# Select a stopped thread to make sure we're able to delete
|
|
|
|
# breakpoints
|
|
|
|
mi_gdb_test "-thread-select 5" "\\^done.*" "select thread 5"
|
|
|
|
|
|
|
|
# Now that we know about all the threads, we can get rid of
|
|
|
|
# breakpoint.
|
|
|
|
mi_delete_breakpoints
|
|
|
|
|
|
|
|
# Recreate the same breakpoint, but this time, specific to thread 5.
|
2013-01-21 23:58:00 +00:00
|
|
|
mi_gdb_test "234-break-insert -p 5 $srcfile:$bkpt_line" \
|
|
|
|
"234\\^done,bkpt=\{number=\"3\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\".*\",func=\"thread_function\",file=\".*\",fullname=\".*\",line=\".*\",thread-groups=\\\[\".*\"\\\],thread=\"5\",thread=\"5\",times=\"0\",original-location=\".*\"\}" \
|
|
|
|
"thread specific breakpoint at thread_function"
|
2008-10-15 19:15:34 +00:00
|
|
|
|
|
|
|
# Resume all threads. Only thread 5 should report a stop.
|
|
|
|
|
|
|
|
set running_re ""
|
2011-06-22 15:38:00 +00:00
|
|
|
for {set i $nthreads} {$i > 1} {incr i -1} {
|
2008-10-15 19:15:34 +00:00
|
|
|
set running_re "$running_re\\*running,thread-id=\"$decimal\"\r\n"
|
|
|
|
}
|
2011-06-22 15:38:00 +00:00
|
|
|
# Don't append \r\n after last line.
|
|
|
|
set running_re "$running_re\\*running,thread-id=\"$decimal\""
|
2008-10-15 19:15:34 +00:00
|
|
|
|
2011-06-22 15:38:00 +00:00
|
|
|
mi_gdb_test "-exec-continue --all" "\[^\n\]*\r\n$running_re" \
|
|
|
|
"resume all, thread specific breakpoint"
|
2008-10-15 19:15:34 +00:00
|
|
|
|
|
|
|
mi_expect_stop "breakpoint-hit" "thread_function" "\[^\n\]*" "$srcfile" \
|
|
|
|
"\[0-9\]*" {"" "disp=\"keep\""} "hit thread specific breakpoint"
|
|
|
|
|
|
|
|
# All threads except both thread 5 (and the main thread) should now be
|
|
|
|
# repeatedly hitting the thread specific breakpoint and stepping over
|
|
|
|
# it transparently. These are internal events, so the frontend should
|
|
|
|
# see those threads as running.
|
|
|
|
|
|
|
|
mi_check_thread_states \
|
|
|
|
{"running" "running" "running" "running" "stopped" "running" "running" "running" "running"} \
|
|
|
|
"thread state: all running except the breakpoint thread"
|
|
|
|
|
|
|
|
# Get rid of the breakpoint while the other threads are stepping over
|
|
|
|
# it, and tell all threads to exit. The program should exit
|
|
|
|
# gracefully shortly. Send all commands in a row, since if something
|
|
|
|
# goes wrong with moribund locations support or displaced stepping (or
|
|
|
|
# a target bug if it can step over breakpoints itself), a spurious
|
|
|
|
# SIGTRAP/SIGSEGV can come at any time after deleting the breakpoint.
|
2010-08-26 14:53:45 +00:00
|
|
|
# Note that this causes multiple prompts to appear before the output
|
|
|
|
# we are interested in, so we can't use mi_gdb_test or
|
|
|
|
# gdb_test_multiple (or an MI equivalent)
|
2008-10-15 19:15:34 +00:00
|
|
|
|
2011-12-26 11:24:55 +00:00
|
|
|
mi_gdb_test "102-break-delete" "102\\^done.*"
|
|
|
|
mi_gdb_test "print done = 1" { = 1"}
|
|
|
|
mi_gdb_test "103-exec-continue --all" "\[^\n\]*\r\n$running_re"
|
2010-08-26 14:53:45 +00:00
|
|
|
|
|
|
|
gdb_expect {
|
|
|
|
-re "\\*stopped,reason=\"exited-normally\"" {
|
|
|
|
pass "resume all, program exited normally"
|
2008-10-15 19:15:34 +00:00
|
|
|
}
|
2010-08-26 14:53:45 +00:00
|
|
|
timeout {
|
|
|
|
fail "resume all, waiting for program exit (timeout)"
|
|
|
|
}
|
|
|
|
}
|
2008-10-15 19:15:34 +00:00
|
|
|
|
|
|
|
mi_gdb_exit
|