10SN/A# Copyright 2017-2023 Free Software Foundation, Inc. 217580Ssspitsyn 30SN/A# This program is free software; you can redistribute it and/or modify 40SN/A# it under the terms of the GNU General Public License as published by 50SN/A# the Free Software Foundation; either version 3 of the License, or 60SN/A# (at your option) any later version. 72362SN/A# 80SN/A# This program is distributed in the hope that it will be useful, 92362SN/A# but WITHOUT ANY WARRANTY; without even the implied warranty of 100SN/A# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 110SN/A# GNU General Public License for more details. 120SN/A# 130SN/A# You should have received a copy of the GNU General Public License 140SN/A# along with this program. If not, see <http://www.gnu.org/licenses/>. 150SN/A 160SN/A# Test "info inferiors" and "info connections" with multiple targets. 170SN/A 180SN/Aload_lib gdb-python.exp 190SN/A 200SN/Asource $srcdir/$subdir/multi-target.exp.tcl 212362SN/A 222362SN/Aif {![multi_target_prepare]} { 232362SN/A return 240SN/A} 250SN/A 260SN/A# Cache the result of calling skip_python_tests into a local variable. 270SN/Aset run_python_tests [expr ! [skip_python_tests]] 280SN/A 290SN/A# Test "info inferiors" and "info connections". MULTI_PROCESS 300SN/A# indicates whether the multi-process feature of remote targets is 310SN/A# turned off or on. 320SN/Aproc test_info_inferiors {multi_process} { 330SN/A setup "off" 340SN/A 350SN/A if { $::run_python_tests } { 360SN/A gdb_test_no_output "source ${::remote_python_file}" "load python file" 370SN/A } 380SN/A 390SN/A gdb_test_no_output \ 400SN/A "set remote multiprocess-feature-packet $multi_process" 410SN/A 420SN/A # Get the description for inferior INF for when the current 430SN/A # inferior id is CURRENT. 440SN/A proc inf_desc {inf current} { 450SN/A set ws "\[ \t\]+" 460SN/A global decimal 470SN/A upvar multi_process multi_process 480SN/A 490SN/A if {($multi_process == "off") && ($inf == 2 || $inf == 5)} { 500SN/A set desc "Remote target" 510SN/A } else { 520SN/A set desc "process ${decimal}" 530SN/A } 540SN/A 550SN/A set desc "${inf}${ws}${desc}${ws}" 560SN/A if {$inf == $current} { 570SN/A return "\\* $desc" 580SN/A } else { 590SN/A return " $desc" 600SN/A } 610SN/A } 620SN/A 630SN/A # Get the "Num" column for CONNECTION for when the current 640SN/A # inferior id is CURRENT_INF. 650SN/A proc connection_num {connection current_inf} { 660SN/A switch $current_inf { 670SN/A "4" { set current_connection "1"} 680SN/A "5" { set current_connection "4"} 690SN/A "6" { set current_connection "5"} 700SN/A default { set current_connection $current_inf} 710SN/A } 720SN/A if {$connection == $current_connection} { 730SN/A return "\\* $connection" 740SN/A } else { 750SN/A return " $connection" 760SN/A } 770SN/A } 780SN/A 790SN/A set ws "\[ \t\]+" 800SN/A global decimal binfile 810SN/A 820SN/A # Test "info connections" and "info inferior" by switching to each 830SN/A # inferior one by one. 840SN/A for {set inf 1} {$inf <= 6} {incr inf} { 850SN/A with_test_prefix "inferior $inf" { 860SN/A gdb_test "inferior $inf" "Switching to inferior $inf.*" 870SN/A 880SN/A gdb_test "info connections" \ 890SN/A [multi_line \ 900SN/A "Num${ws}What${ws}Description${ws}" \ 910SN/A "[connection_num 1 $inf]${ws}native${ws}Native process${ws}" \ 920SN/A "[connection_num 2 $inf]${ws}extended-remote localhost:$decimal${ws}Extended remote target using gdb-specific protocol${ws}" \ 930SN/A "[connection_num 3 $inf]${ws}core${ws}Local core dump file${ws}" \ 940SN/A "[connection_num 4 $inf]${ws}extended-remote localhost:$decimal${ws}Extended remote target using gdb-specific protocol${ws}" \ 950SN/A "[connection_num 5 $inf]${ws}core${ws}Local core dump file${ws}" \ 960SN/A ] 970SN/A 980SN/A if { $::run_python_tests } { 990SN/A gdb_test "python info_connections()" \ 1000SN/A [multi_line \ 1010SN/A "Num${ws}What${ws}Description" \ 1020SN/A "[connection_num 1 $inf]${ws}native${ws}Native process" \ 1030SN/A "[connection_num 2 $inf]${ws}extended-remote localhost:$decimal${ws}Extended remote target using gdb-specific protocol" \ 1040SN/A "[connection_num 3 $inf]${ws}core${ws}Local core dump file" \ 1050SN/A "[connection_num 4 $inf]${ws}extended-remote localhost:$decimal${ws}Extended remote target using gdb-specific protocol" \ 1060SN/A "[connection_num 5 $inf]${ws}core${ws}Local core dump file" \ 1070SN/A ] 1080SN/A } 1090SN/A 1100SN/A gdb_test "info inferiors" \ 1110SN/A [multi_line \ 1120SN/A "Num${ws}Description${ws}Connection${ws}Executable${ws}" \ 1130SN/A "[inf_desc 1 $inf]1 \\(native\\)${ws}${binfile}${ws}" \ 1140SN/A "[inf_desc 2 $inf]2 \\(extended-remote localhost:$decimal\\)${ws}${binfile}${ws}" \ 1150SN/A "[inf_desc 3 $inf]3 \\(core\\)${ws}${binfile}${ws}" \ 1160SN/A "[inf_desc 4 $inf]1 \\(native\\)${ws}${binfile}${ws}" \ 1170SN/A "[inf_desc 5 $inf]4 \\(extended-remote localhost:$decimal\\)${ws}${binfile}${ws}" \ 1180SN/A "[inf_desc 6 $inf]5 \\(core\\)${ws}${binfile}${ws}" \ 1190SN/A ] 1200SN/A 1210SN/A if { $::run_python_tests } { 1220SN/A gdb_test "python info_inferiors()" \ 1230SN/A [multi_line \ 1240SN/A "Inferior 1, Connection #1: native" \ 1250SN/A "Inferior 2, Connection #2: extended-remote localhost:$decimal" \ 1260SN/A "Inferior 3, Connection #3: core" \ 1270SN/A "Inferior 4, Connection #1: native" \ 1280SN/A "Inferior 5, Connection #4: extended-remote localhost:$decimal" \ 1290SN/A "Inferior 6, Connection #5: core" \ 1300SN/A ] 1310SN/A } 1320SN/A } 1330SN/A } 1340SN/A} 1350SN/A 1360SN/Aif { $run_python_tests } { 1370SN/A set remote_python_file [gdb_remote_download host \ 1380SN/A ${srcdir}/${subdir}/${testfile}.py] 1390SN/A} 1400SN/A 1410SN/A# Test "info inferiors" and "info connections" commands. 1420SN/Awith_test_prefix "info-inferiors" { 1430SN/A foreach_with_prefix multi_process {"on" "off"} { 1440SN/A test_info_inferiors $multi_process 1450SN/A } 1460SN/A} 1470SN/A 1480SN/Amulti_target_cleanup 1490SN/A