diff options
author | Pedro Alves <palves@redhat.com> | 2016-06-21 01:11:55 +0100 |
---|---|---|
committer | Pedro Alves <palves@redhat.com> | 2016-06-21 01:11:55 +0100 |
commit | 51f77c3704a6e5c28fdcdd6d6e0aeb97ebdb343f (patch) | |
tree | 734f6ec6ef32bede4aafad4614cc2f77d95e5d93 /gdb/testsuite | |
parent | 86f78169c82095eced3a4d1b30f8e002ec841d79 (diff) | |
download | gdb-51f77c3704a6e5c28fdcdd6d6e0aeb97ebdb343f.zip gdb-51f77c3704a6e5c28fdcdd6d6e0aeb97ebdb343f.tar.gz gdb-51f77c3704a6e5c28fdcdd6d6e0aeb97ebdb343f.tar.bz2 |
Add testing infrastruture bits for running with MI on a separate UI
With this, a specific test may can start GDB with MI on a separate UI
by using:
mi_gdb_start separate-mi-tty
In addition, it's also possible to run the whole testsuite with MI on
a separate tty, with:
make check RUNTESTFLAGS="FORCE_SEPARATE_MI_TTY=1"
gdb_main_spawn_id and mi_spawn_id are added so that tests may expect
output from either channel.
While at it, inferior_spawn_id was not being cleared when gdb exits,
unlike the other spawn ids, thus a test that starts gdb more than once
would end up using a stale spawn id.
gdb/testsuite/ChangeLog:
2016-06-21 Pedro Alves <palves@redhat.com>
* README (Testsuite Parameters): Document FORCE_SEPARATE_MI_TTY.
* lib/gdb.exp (default_gdb_exit): Clear inferior_spawn_id.
* lib/mi-support.exp (mi_uncatched_gdb_exit): Unset
gdb_main_spawn_id, mi_spawn_id, unset inferior_spawn_id.
(gdb_main_spawn_id, mi_spawn_id): Declare and
comment.
(mi_create_inferior_pty): New procedure,
factored out from default_mi_gdb_start.
(switch_gdb_spawn_id, mi_gdb_start_separate_mi_tty): New
procedures.
(default_mi_gdb_start): Call mi_gdb_start_separate_mi_tty if the
separate-mi-tty option is specified, or SEPARATE_MI_TTY is set.
Use mi_create_inferior_pty.
(mi_gdb_start): Use eval to pass down args list.
Diffstat (limited to 'gdb/testsuite')
-rw-r--r-- | gdb/testsuite/ChangeLog | 17 | ||||
-rw-r--r-- | gdb/testsuite/README | 6 | ||||
-rw-r--r-- | gdb/testsuite/lib/gdb.exp | 3 | ||||
-rw-r--r-- | gdb/testsuite/lib/mi-support.exp | 159 |
4 files changed, 156 insertions, 29 deletions
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index 9ad93eb..888d6cd 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,5 +1,22 @@ 2016-06-21 Pedro Alves <palves@redhat.com> + * README (Testsuite Parameters): Document FORCE_SEPARATE_MI_TTY. + * lib/gdb.exp (default_gdb_exit): Clear inferior_spawn_id. + * lib/mi-support.exp (mi_uncatched_gdb_exit): Unset + gdb_main_spawn_id, mi_spawn_id, unset inferior_spawn_id. + (gdb_main_spawn_id, mi_spawn_id): Declare and + comment. + (mi_create_inferior_pty): New procedure, + factored out from default_mi_gdb_start. + (switch_gdb_spawn_id, mi_gdb_start_separate_mi_tty): New + procedures. + (default_mi_gdb_start): Call mi_gdb_start_separate_mi_tty if the + separate-mi-tty option is specified, or SEPARATE_MI_TTY is set. + Use mi_create_inferior_pty. + (mi_gdb_start): Use eval to pass down args list. + +2016-06-21 Pedro Alves <palves@redhat.com> + * gdb.opt/inline-cmds.c: Add "set mi break here" marker. * gdb.opt/inline-cmds.exp: Add MI tests. diff --git a/gdb/testsuite/README b/gdb/testsuite/README index 043a8bd..152318a 100644 --- a/gdb/testsuite/README +++ b/gdb/testsuite/README @@ -208,6 +208,12 @@ FORCE_PARALLEL Setting FORCE_PARALLEL to any non-empty value forces parallel testing mode even if RUNTESTFLAGS is not empty. +FORCE_SEPARATE_MI_TTY + +Setting FORCE_MI_SEPARATE_UI to 1 forces all MI testing to start GDB +in console mode, with MI running on a separate TTY, on a secondary UI +started with "new-ui". + GDB_INOTIFY For debugging parallel mode, it is handy to be able to see when a test diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp index 436f708..878da16 100644 --- a/gdb/testsuite/lib/gdb.exp +++ b/gdb/testsuite/lib/gdb.exp @@ -1359,7 +1359,7 @@ proc default_gdb_exit {} { global GDB global INTERNAL_GDBFLAGS GDBFLAGS global verbose - global gdb_spawn_id + global gdb_spawn_id inferior_spawn_id global inotify_log_file gdb_stop_suppressing_tests @@ -1400,6 +1400,7 @@ proc default_gdb_exit {} { remote_close host } unset gdb_spawn_id + unset inferior_spawn_id } # Load a file into the debugger. diff --git a/gdb/testsuite/lib/mi-support.exp b/gdb/testsuite/lib/mi-support.exp index 87ce634..edfc07d 100644 --- a/gdb/testsuite/lib/mi-support.exp +++ b/gdb/testsuite/lib/mi-support.exp @@ -28,6 +28,16 @@ if ![info exists mi_gdb_prompt] then { global mi_inferior_tty_name +# Always points to GDB's main UI spawn ID, even when testing with MI +# running on a secondary UI. +global gdb_main_spawn_id + +# Points to the spawn id of the MI channel. When testing with MI +# running as the primary/main UI, this is the same as +# gdb_main_spawn_id, but will be different when testing with MI +# running on a secondary UI. +global mi_spawn_id + set MIFLAGS "-i=mi" set thread_selected_re "=thread-selected,id=\"\[0-9\]+\"\r\n" @@ -46,7 +56,8 @@ proc mi_uncatched_gdb_exit {} { global GDB global INTERNAL_GDBFLAGS GDBFLAGS global verbose - global gdb_spawn_id + global gdb_spawn_id gdb_main_spawn_id + global mi_spawn_id inferior_spawn_id global gdb_prompt global mi_gdb_prompt global MIFLAGS @@ -83,14 +94,103 @@ proc mi_uncatched_gdb_exit {} { remote_close host } unset gdb_spawn_id + unset gdb_main_spawn_id + unset mi_spawn_id + unset inferior_spawn_id +} + +# Create the PTY for the inferior process and tell GDB about it. + +proc mi_create_inferior_pty {} { + global mi_gdb_prompt + global inferior_spawn_id + global mi_inferior_tty_name + + spawn -pty + set inferior_spawn_id $spawn_id + set tty_name $spawn_out(slave,name) + set mi_inferior_tty_name $tty_name + + send_gdb "102-inferior-tty-set $tty_name\n" + gdb_expect 10 { + -re ".*102\\\^done\r\n$mi_gdb_prompt$" { + verbose "redirect inferior output to new terminal device." + } + timeout { + warning "Couldn't redirect inferior output." 2 + } + } +} + +# Switch the default spawn id to SPAWN_ID, so that mi_gdb_test +# etc. default to using it. + +proc switch_gdb_spawn_id {spawn_id} { + global gdb_spawn_id + global board board_info + + set gdb_spawn_id $spawn_id + set board [host_info name] + set board_info($board,fileid) $spawn_id +} + +proc mi_gdb_start_separate_mi_tty { args } { + global gdb_prompt mi_gdb_prompt + global timeout + global gdb_spawn_id gdb_main_spawn_id mi_spawn_id + global inferior_spawn_id + + set separate_inferior_pty 0 + + foreach arg $args { + if {$arg == "separate-inferior-tty"} { + set separate_inferior_pty 1 + } + } + + gdb_start + + # Create the new PTY for the MI UI. + spawn -pty + set mi_spawn_id $spawn_id + set mi_tty_name $spawn_out(slave,name) + gdb_test_multiple "new-ui mi $mi_tty_name" "new-ui" { + -re "New UI allocated\r\n$gdb_prompt $" { + } + } + + # Switch to the MI channel. + set gdb_main_spawn_id $gdb_spawn_id + switch_gdb_spawn_id $mi_spawn_id + + # Consume pending output and MI prompt. + gdb_expect { + -re "$mi_gdb_prompt$" { + } + default { + perror "MI channel failed" + remote_close host + return -1 + } + } + + if {$separate_inferior_pty} { + mi_create_inferior_pty + } + + mi_detect_async + + return 0 } # -# default_mi_gdb_start [INFERIOR_PTY] -- start gdb running, default procedure +# default_mi_gdb_start [FLAGS] -- start gdb running, default procedure # -# INFERIOR_PTY should be set to separate-inferior-tty to have the inferior work -# with it's own PTY. If set to same-inferior-tty, the inferior shares GDB's PTY. -# The default value is same-inferior-tty. +# If "separate-inferior-tty" is specified, the inferior works with +# it's own PTY. +# +# If "separate-mi-tty" is specified, the gdb starts in CLI mode, with +# MI running on a secondary UI, on its own tty. # # When running over NFS, particularly if running many simultaneous # tests on different hosts all using the same server, things can @@ -103,8 +203,29 @@ proc default_mi_gdb_start { args } { global gdb_prompt global mi_gdb_prompt global timeout - global gdb_spawn_id inferior_spawn_id + global gdb_spawn_id gdb_main_spawn_id inferior_spawn_id mi_spawn_id global MIFLAGS + global SEPARATE_MI_TTY + + if {[info exists FORCE_SEPARATE_MI_TTY]} { + set separate_mi_pty $FORCE_SEPARATE_MI_TTY + } else { + set separate_mi_pty 0 + } + + set separate_inferior_pty 0 + + foreach arg $args { + if {$arg == "separate-mi-tty"} { + set separate_mi_pty 1 + } elseif {$arg == "separate-inferior-tty"} { + set separate_inferior_pty 1 + } + } + + if {$separate_mi_pty} { + return [eval mi_gdb_start_separate_mi_tty $args] + } gdb_stop_suppressing_tests set inferior_pty no-tty @@ -112,12 +233,6 @@ proc default_mi_gdb_start { args } { # Set the default value, it may be overriden later by specific testfile. set use_gdb_stub [target_info exists use_gdb_stub] - if { [llength $args] == 1} { - set inferior_pty [lindex $args 0] - } - - set separate_inferior_pty [string match $inferior_pty separate-inferior-tty] - # Start SID. if { [info procs sid_start] != "" } { verbose "Spawning SID" @@ -182,6 +297,8 @@ proc default_mi_gdb_start { args } { } } set gdb_spawn_id $res + set gdb_main_spawn_id $res + set mi_spawn_id $res # FIXME: mi output does not go through pagers, so these can be removed. # force the height to "unlimited", so no pagers get used @@ -205,22 +322,8 @@ proc default_mi_gdb_start { args } { } } - # Create the new PTY for the inferior process. if { $separate_inferior_pty } { - spawn -pty - global mi_inferior_tty_name - set inferior_spawn_id $spawn_id - set mi_inferior_tty_name $spawn_out(slave,name) - - send_gdb "102-inferior-tty-set $mi_inferior_tty_name\n" - gdb_expect 10 { - -re ".*102\\\^done\r\n$mi_gdb_prompt$" { - verbose "redirect inferior output to new terminal device." - } - timeout { - warning "Couldn't redirect inferior output." 2 - } - } + mi_create_inferior_pty } if {![info exists inferior_spawn_id]} { @@ -237,7 +340,7 @@ proc default_mi_gdb_start { args } { # baseboard file. # proc mi_gdb_start { args } { - return [default_mi_gdb_start $args] + return [eval default_mi_gdb_start $args] } # Many of the tests depend on setting breakpoints at various places and |