aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite
diff options
context:
space:
mode:
authorPedro Alves <palves@redhat.com>2020-01-10 20:06:14 +0000
committerPedro Alves <palves@redhat.com>2020-01-10 20:06:14 +0000
commit121b3efd49f98e4049281b3ba7a258e650e40b38 (patch)
tree6cc76edd8054a1270597adc9fa668562eba78d82 /gdb/testsuite
parent4f83758119ddf0f114477760d79bdde7bbc76835 (diff)
downloadgdb-121b3efd49f98e4049281b3ba7a258e650e40b38.zip
gdb-121b3efd49f98e4049281b3ba7a258e650e40b38.tar.gz
gdb-121b3efd49f98e4049281b3ba7a258e650e40b38.tar.bz2
Add "info connections" command, "info inferiors" connection number/string
This commit extends the CLI a bit for multi-target, in three ways. #1 - New "info connections" command. This is a new command that lists the open connections (process_stratum targets). For example, if you're debugging two remote connections, a couple local/native processes, and a core dump, all at the same time, you might see something like this: (gdb) info connections Num What Description 1 remote 192.168.0.1:9999 Remote serial target in gdb-specific protocol 2 remote 192.168.0.2:9998 Remote serial target in gdb-specific protocol * 3 native Native process 4 core Local core dump file #2 - New "info inferiors" "Connection" column You'll also see a new matching "Connection" column in "info inferiors", showing you which connection an inferior is bound to: (gdb) info inferiors Num Description Connection Executable 1 process 18526 1 (remote 192.168.0.1:9999) target:/tmp/a.out 2 process 18531 2 (remote 192.168.0.2:9998) target:/tmp/a.out 3 process 19115 3 (native) /tmp/prog1 4 process 6286 4 (core) myprogram * 5 process 19122 3 (native) /bin/hello #3 - Makes "add-inferior" show the inferior's target connection "add-inferior" now shows you the connection you've just bound the inferior to, which is the current process_stratum target: (gdb) add-inferior [New inferior 2] Added inferior 2 on connection 1 (extended-remote localhost:2346) gdb/ChangeLog: 2020-01-10 Pedro Alves <palves@redhat.com> * Makefile.in (COMMON_SFILES): Add target-connection.c. * inferior.c (uiout_field_connection): New function. (print_inferior): Add new "connection-id" column. (add_inferior_command): Show connection number/string of added inferior. * process-stratum-target.h (process_stratum_target::connection_string): New virtual method. (process_stratum_target::connection_number): New field. * remote.c (remote_target::connection_string): New override. * target-connection.c: New file. * target-connection.h: New file. * target.c (decref_target): Remove process_stratum targets from the connection list. (target_stack::push): Add process_stratum targets to the connection list. gdb/testsuite/ChangeLog: 2020-01-10 Pedro Alves <palves@redhat.com> * gdb.base/kill-detach-inferiors-cmd.exp: Adjust expected output of "add-inferior". * gdb.base/quit-live.exp: Likewise. * gdb.base/remote-exec-file.exp: Likewise. * gdb.guile/scm-progspace.exp: Likewise. * gdb.linespec/linespec.exp: Likewise. * gdb.mi/new-ui-mi-sync.exp: Likewise. * gdb.mi/user-selected-context-sync.exp: Likewise. * gdb.multi/multi-target.exp (setup): Add "info connection" and "info inferiors" tests. * gdb.multi/remove-inferiors.exp: Adjust expected output of "add-inferior". * gdb.multi/watchpoint-multi.exp: Likewise. * gdb.python/py-inferior.exp: Likewise. * gdb.server/extended-remote-restart.exp: Likewise. * gdb.threads/fork-plus-threads.exp: Adjust expected output of "info inferiors". * gdb.threads/forking-threads-plus-breakpoint.exp: Likewise. * gdb.trace/report.exp: Likewise.
Diffstat (limited to 'gdb/testsuite')
-rw-r--r--gdb/testsuite/ChangeLog22
-rw-r--r--gdb/testsuite/gdb.base/kill-detach-inferiors-cmd.exp4
-rw-r--r--gdb/testsuite/gdb.base/quit-live.exp2
-rw-r--r--gdb/testsuite/gdb.base/remote-exec-file.exp2
-rw-r--r--gdb/testsuite/gdb.guile/scm-progspace.exp2
-rw-r--r--gdb/testsuite/gdb.linespec/linespec.exp2
-rw-r--r--gdb/testsuite/gdb.mi/new-ui-mi-sync.exp2
-rw-r--r--gdb/testsuite/gdb.mi/user-selected-context-sync.exp2
-rw-r--r--gdb/testsuite/gdb.multi/multi-target.exp28
-rw-r--r--gdb/testsuite/gdb.multi/remove-inferiors.exp2
-rw-r--r--gdb/testsuite/gdb.multi/watchpoint-multi.exp2
-rw-r--r--gdb/testsuite/gdb.python/py-inferior.exp4
-rw-r--r--gdb/testsuite/gdb.server/extended-remote-restart.exp18
-rw-r--r--gdb/testsuite/gdb.threads/fork-plus-threads.exp2
-rw-r--r--gdb/testsuite/gdb.threads/forking-threads-plus-breakpoint.exp2
-rw-r--r--gdb/testsuite/gdb.trace/report.exp2
16 files changed, 75 insertions, 23 deletions
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index 9297fa2..e7bd05a 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,5 +1,27 @@
2020-01-10 Pedro Alves <palves@redhat.com>
+ * gdb.base/kill-detach-inferiors-cmd.exp: Adjust expected output
+ of "add-inferior".
+ * gdb.base/quit-live.exp: Likewise.
+ * gdb.base/remote-exec-file.exp: Likewise.
+ * gdb.guile/scm-progspace.exp: Likewise.
+ * gdb.linespec/linespec.exp: Likewise.
+ * gdb.mi/new-ui-mi-sync.exp: Likewise.
+ * gdb.mi/user-selected-context-sync.exp: Likewise.
+ * gdb.multi/multi-target.exp (setup): Add "info connection" and
+ "info inferiors" tests.
+ * gdb.multi/remove-inferiors.exp: Adjust expected output of
+ "add-inferior".
+ * gdb.multi/watchpoint-multi.exp: Likewise.
+ * gdb.python/py-inferior.exp: Likewise.
+ * gdb.server/extended-remote-restart.exp: Likewise.
+ * gdb.threads/fork-plus-threads.exp: Adjust expected output of
+ "info inferiors".
+ * gdb.threads/forking-threads-plus-breakpoint.exp: Likewise.
+ * gdb.trace/report.exp: Likewise.
+
+2020-01-10 Pedro Alves <palves@redhat.com>
+
* gdb.multi/multi-target.c: New file.
* gdb.multi/multi-target.exp: New file.
* lib/gdbserver-support.exp (gdb_target_cmd): Handle "Non-stop
diff --git a/gdb/testsuite/gdb.base/kill-detach-inferiors-cmd.exp b/gdb/testsuite/gdb.base/kill-detach-inferiors-cmd.exp
index 600de9c..82e0c71 100644
--- a/gdb/testsuite/gdb.base/kill-detach-inferiors-cmd.exp
+++ b/gdb/testsuite/gdb.base/kill-detach-inferiors-cmd.exp
@@ -32,7 +32,7 @@ if [prepare_for_testing "failed to prepare" $executable] {
runto_main
# Add another forked inferior process.
-gdb_test "add-inferior" "Added inferior 2" "add inferior 2"
+gdb_test "add-inferior" "Added inferior 2 on connection .*" "add inferior 2"
gdb_test "inferior 2" "Switching to inferior 2.*"
gdb_test "file $binfile" "Reading symbols from .*" "load binary"
gdb_test "start" "Temporary breakpoint.*Starting program.*"
@@ -40,7 +40,7 @@ gdb_test "start" "Temporary breakpoint.*Starting program.*"
# Add an attached inferior process.
set test_spawn_id [spawn_wait_for_attach $binfile]
set test_pid [spawn_id_get_pid $test_spawn_id]
-gdb_test "add-inferior" "Added inferior 3" "add inferior 3"
+gdb_test "add-inferior" "Added inferior 3 on connection .*" "add inferior 3"
gdb_test "inferior 3" "Switching to inferior 3.*"
gdb_test "attach $test_pid" "Attaching to process.*" "attach to pid"
diff --git a/gdb/testsuite/gdb.base/quit-live.exp b/gdb/testsuite/gdb.base/quit-live.exp
index 109c5e9..c8e2f01 100644
--- a/gdb/testsuite/gdb.base/quit-live.exp
+++ b/gdb/testsuite/gdb.base/quit-live.exp
@@ -120,7 +120,7 @@ proc quit_with_live_inferior {appear_how extra_inferior quit_how} {
}
if {$extra_inferior} {
- gdb_test "add-inferior" "Added inferior 2*" \
+ gdb_test "add-inferior" "Added inferior 2 on connection .*" \
"add empty inferior 2"
gdb_test "inferior 2" "Switching to inferior 2.*" \
"switch to inferior 2"
diff --git a/gdb/testsuite/gdb.base/remote-exec-file.exp b/gdb/testsuite/gdb.base/remote-exec-file.exp
index 277e405..a479a79 100644
--- a/gdb/testsuite/gdb.base/remote-exec-file.exp
+++ b/gdb/testsuite/gdb.base/remote-exec-file.exp
@@ -27,7 +27,7 @@ with_test_prefix "set inf 1" {
# Set remote exec-file in inferior 2.
with_test_prefix "set inf 2" {
- gdb_test "add-inferior" "Added inferior 2" "add inferior 2"
+ gdb_test "add-inferior" "Added inferior 2.*" "add inferior 2"
gdb_test "inferior 2" "Switching to inferior 2.*"
gdb_test_no_output "set remote exec-file prog2"
}
diff --git a/gdb/testsuite/gdb.guile/scm-progspace.exp b/gdb/testsuite/gdb.guile/scm-progspace.exp
index 9b89ef4..91a78e2 100644
--- a/gdb/testsuite/gdb.guile/scm-progspace.exp
+++ b/gdb/testsuite/gdb.guile/scm-progspace.exp
@@ -73,7 +73,7 @@ with_test_prefix "program unloaded" {
# deleted. We need to, for example, delete an inferior to get the progspace
# to go away.
-gdb_test "add-inferior" "Added inferior 2" "create new inferior"
+gdb_test "add-inferior" "Added inferior 2.*" "create new inferior"
gdb_test "inferior 2" ".*" "switch to new inferior"
gdb_test_no_output "remove-inferiors 1" "remove first inferior"
diff --git a/gdb/testsuite/gdb.linespec/linespec.exp b/gdb/testsuite/gdb.linespec/linespec.exp
index 38f1cf0..be1b918 100644
--- a/gdb/testsuite/gdb.linespec/linespec.exp
+++ b/gdb/testsuite/gdb.linespec/linespec.exp
@@ -201,7 +201,7 @@ gdb_test "break lspec.h:$line" \
# Multi-inferior tests.
#
-gdb_test "add-inferior" "Added inferior 2" \
+gdb_test "add-inferior" "Added inferior 2.*" \
"add inferior for linespec tests"
gdb_test "inferior 2" "Switching to inferior 2 .*" \
diff --git a/gdb/testsuite/gdb.mi/new-ui-mi-sync.exp b/gdb/testsuite/gdb.mi/new-ui-mi-sync.exp
index b94f3f9..a55fae6 100644
--- a/gdb/testsuite/gdb.mi/new-ui-mi-sync.exp
+++ b/gdb/testsuite/gdb.mi/new-ui-mi-sync.exp
@@ -83,7 +83,7 @@ proc do_test {sync_command} {
# in the separate MI UI. Note the "run" variant usually triggers
# =thread-group-started/=thread-created/=library-loaded as well.
with_spawn_id $gdb_main_spawn_id {
- gdb_test "add-inferior" "Added inferior 2"
+ gdb_test "add-inferior" "Added inferior 2 on connection .*"
}
# Interrupt the program.
diff --git a/gdb/testsuite/gdb.mi/user-selected-context-sync.exp b/gdb/testsuite/gdb.mi/user-selected-context-sync.exp
index 8a752b0..390df00 100644
--- a/gdb/testsuite/gdb.mi/user-selected-context-sync.exp
+++ b/gdb/testsuite/gdb.mi/user-selected-context-sync.exp
@@ -415,7 +415,7 @@ proc_with_prefix test_setup { mode } {
# Add the second inferior now. While this is not mandatory, it allows
# us to assume that per-inferior thread numbering will be used,
# simplifying test_continue_to_start a bit (Thread 1.2 and not Thread 2).
- gdb_test "add-inferior" "Added inferior 2" "add inferior 2"
+ gdb_test "add-inferior" "Added inferior 2 on connection .*" "add inferior 2"
# Prepare the first inferior for the test.
test_continue_to_start $mode 1
diff --git a/gdb/testsuite/gdb.multi/multi-target.exp b/gdb/testsuite/gdb.multi/multi-target.exp
index cd0db12..903831c 100644
--- a/gdb/testsuite/gdb.multi/multi-target.exp
+++ b/gdb/testsuite/gdb.multi/multi-target.exp
@@ -137,8 +137,34 @@ proc setup {non-stop} {
return 0
}
+ set ws "\[ \t\]+"
+ global decimal
+
+ # Test "info connections" and "info inferior"'s "Connection"
+ # column, while at it.
+
+ gdb_test "info connections" \
+ [multi_line \
+ "Num${ws}What${ws}Description${ws}" \
+ " 1${ws}native${ws}Native process${ws}" \
+ " 2${ws}extended-remote localhost:$decimal${ws}Extended remote serial target in gdb-specific protocol${ws}" \
+ " 3${ws}core${ws}Local core dump file${ws}" \
+ " 4${ws}extended-remote localhost:$decimal${ws}Extended remote serial target in gdb-specific protocol${ws}" \
+ "\\* 5${ws}core${ws}Local core dump file${ws}" \
+ ]
+
+ gdb_test "info inferiors" \
+ [multi_line \
+ "Num${ws}Description${ws}Connection${ws}Executable${ws}" \
+ " 1${ws}process ${decimal}${ws}1 \\(native\\)${ws}${binfile}${ws}" \
+ " 2${ws}process ${decimal}${ws}2 \\(extended-remote localhost:$decimal\\)${ws}${binfile}${ws}" \
+ " 3${ws}process ${decimal}${ws}3 \\(core\\)${ws}${binfile}${ws}" \
+ " 4${ws}process ${decimal}${ws}1 \\(native\\)${ws}${binfile}${ws}" \
+ " 5${ws}process ${decimal}${ws}4 \\(extended-remote localhost:$decimal\\)${ws}${binfile}${ws}" \
+ "\\* 6${ws}process ${decimal}${ws}5 \\(core\\)${ws}${binfile}${ws}" \
+ ]
+
# For debugging.
- gdb_test "info inferiors" ".*"
gdb_test "info threads" ".*"
# Make "continue" resume all inferiors.
diff --git a/gdb/testsuite/gdb.multi/remove-inferiors.exp b/gdb/testsuite/gdb.multi/remove-inferiors.exp
index 27a94b8..54c2c00 100644
--- a/gdb/testsuite/gdb.multi/remove-inferiors.exp
+++ b/gdb/testsuite/gdb.multi/remove-inferiors.exp
@@ -26,7 +26,7 @@ proc switch_to_inferior { num message } {
}
proc add_inferior { expected_num message } {
- gdb_test "add-inferior" "Added inferior ${expected_num}" "${message}"
+ gdb_test "add-inferior" "Added inferior ${expected_num}( on connection .*)?" "${message}"
}
proc test_remove_inferiors { } {
diff --git a/gdb/testsuite/gdb.multi/watchpoint-multi.exp b/gdb/testsuite/gdb.multi/watchpoint-multi.exp
index 4ff24ee..2d48b70 100644
--- a/gdb/testsuite/gdb.multi/watchpoint-multi.exp
+++ b/gdb/testsuite/gdb.multi/watchpoint-multi.exp
@@ -53,7 +53,7 @@ if [support_displaced_stepping] {
gdb_breakpoint main {temporary}
gdb_test "run" "Temporary breakpoint.* main .*" "start to main inferior 1"
-gdb_test "add-inferior" "Added inferior 2" "add inferior 2"
+gdb_test "add-inferior" "Added inferior 2 on connection .*" "add inferior 2"
gdb_test "inferior 2" "witching to inferior 2 .*" "switch to inferior 2, first time"
gdb_load $binfile
diff --git a/gdb/testsuite/gdb.python/py-inferior.exp b/gdb/testsuite/gdb.python/py-inferior.exp
index a9a36b4..997da19 100644
--- a/gdb/testsuite/gdb.python/py-inferior.exp
+++ b/gdb/testsuite/gdb.python/py-inferior.exp
@@ -279,7 +279,7 @@ with_test_prefix "selected_inferior" {
gdb_test "inferior 1" ".*" "switch to first inferior"
gdb_test "py print (gdb.selected_inferior().num)" "1" "first inferior selected"
- gdb_test "add-inferior" "Added inferior 3" "create new inferior"
+ gdb_test "add-inferior" "Added inferior 3 on connection .*" "create new inferior"
gdb_test "inferior 3" ".*" "switch to third inferior"
gdb_test "py print (gdb.selected_inferior().num)" "3" "third inferior selected"
gdb_test "inferior 1" ".*" "switch back to first inferior"
@@ -288,7 +288,7 @@ with_test_prefix "selected_inferior" {
# Test repr()/str()
with_test_prefix "__repr__" {
- gdb_test "add-inferior" "Added inferior 4" "add inferior 4"
+ gdb_test "add-inferior" "Added inferior 4 on connection .*" "add inferior 4"
gdb_py_test_silent_cmd "python infs = gdb.inferiors()" "get inferior list" 1
gdb_test "python print (infs\[0\])" "<gdb.Inferior num=1, pid=$decimal>"
gdb_test "python print (infs)" \
diff --git a/gdb/testsuite/gdb.server/extended-remote-restart.exp b/gdb/testsuite/gdb.server/extended-remote-restart.exp
index 3ce0f0b..11f8a28 100644
--- a/gdb/testsuite/gdb.server/extended-remote-restart.exp
+++ b/gdb/testsuite/gdb.server/extended-remote-restart.exp
@@ -88,12 +88,16 @@ proc test_reload { do_kill_p follow_child_p } {
gdb_breakpoint "breakpt"
gdb_continue_to_breakpoint "breakpt"
- # Check we have the expected inferiors.
+ set ws "\[ \t\]+"
+ set any_re "\[^\r\n\]+"
+ set connection_re $any_re
+ set executable_re $any_re
+
gdb_test "info inferiors" \
[multi_line \
- " Num Description Executable.*" \
- "${parent_prefix} 1 +${live_inf_ptn} \[^\r\n\]+" \
- "${child_prefix} 2 +${live_inf_ptn} \[^\r\n\]+" ] \
+ " Num${ws}Description${ws}Connection${ws}Executable${ws}" \
+ "${parent_prefix} 1${ws}${live_inf_ptn}${ws}${connection_re}${executable_re}" \
+ "${child_prefix} 2${ws}${live_inf_ptn}${ws}${connection_re}${executable_re}" ] \
"Check inferiors at breakpoint"
if { $do_kill_p } {
@@ -107,9 +111,9 @@ proc test_reload { do_kill_p follow_child_p } {
# Check the first inferior really did die.
gdb_test "info inferiors" \
[multi_line \
- " Num Description Executable.*" \
- "${parent_prefix} 1 +${parent_inf_after_kill_ptn} \[^\r\n\]+" \
- "${child_prefix} 2 +${child_inf_after_kill_ptn} \[^\r\n\]+" ] \
+ " Num${ws}Description${ws}Connection${ws}Executable${ws}" \
+ "${parent_prefix} 1${ws}${parent_inf_after_kill_ptn}${ws}${connection_re}${executable_re}" \
+ "${child_prefix} 2${ws}${child_inf_after_kill_ptn}${ws}${connection_re}${executable_re}" ] \
"Check inferior was killed"
}
diff --git a/gdb/testsuite/gdb.threads/fork-plus-threads.exp b/gdb/testsuite/gdb.threads/fork-plus-threads.exp
index 9db964a..8d36b96 100644
--- a/gdb/testsuite/gdb.threads/fork-plus-threads.exp
+++ b/gdb/testsuite/gdb.threads/fork-plus-threads.exp
@@ -109,7 +109,7 @@ proc do_test { detach_on_fork } {
"no threads left"
gdb_test "info inferiors" \
- "Num\[ \t\]+Description\[ \t\]+Executable\[ \t\]+\r\n\\* 1 \[^\r\n\]+" \
+ "Num\[ \t\]+Description\[ \t\]+Connection\[ \t\]+Executable\[ \t\]+\r\n\\* 1 \[^\r\n\]+" \
"only inferior 1 left"
}
diff --git a/gdb/testsuite/gdb.threads/forking-threads-plus-breakpoint.exp b/gdb/testsuite/gdb.threads/forking-threads-plus-breakpoint.exp
index 17efbc7..c4c9596 100644
--- a/gdb/testsuite/gdb.threads/forking-threads-plus-breakpoint.exp
+++ b/gdb/testsuite/gdb.threads/forking-threads-plus-breakpoint.exp
@@ -142,7 +142,7 @@ proc do_test { cond_bp_target detach_on_fork displaced } {
"no threads left"
gdb_test "info inferiors" \
- "Num\[ \t\]+Description\[ \t\]+Executable\[ \t\]+\r\n\\* 1 \[^\r\n\]+" \
+ "Num\[ \t\]+Description\[ \t\]+Connection\[ \t\]+Executable\[ \t\]+\r\n\\* 1 \[^\r\n\]+" \
"only inferior 1 left"
}
diff --git a/gdb/testsuite/gdb.trace/report.exp b/gdb/testsuite/gdb.trace/report.exp
index 05ccc04..9302975 100644
--- a/gdb/testsuite/gdb.trace/report.exp
+++ b/gdb/testsuite/gdb.trace/report.exp
@@ -391,7 +391,7 @@ proc use_collected_data { data_source } {
# There is always a thread of an inferior, either a live one or
# a faked one.
gdb_test "info threads" "\\* ${decimal} (process|Thread) \[0-9\.\]+\[ \t\].*"
- gdb_test "info inferiors" "\\* 1 process ${decimal} \[ \t\]+${binfile}.*"
+ gdb_test "info inferiors" "\\* 1 process ${decimal} \[ \t\]+\[^\r\n\]*\[ \t\]+${binfile}.*"
}
}