xref: /netbsd-src/external/gpl3/gdb.old/dist/gdb/testsuite/gdb.base/info-proc.exp (revision ae87de8892f277bece3527c15b186ebcfa188227)
1# Copyright 2002-2020 Free Software Foundation, Inc.
2
3# This program is free software; you can redistribute it and/or modify
4# it under the terms of the GNU General Public License as published by
5# the Free Software Foundation; either version 3 of the License, or
6# (at your option) any later version.
7#
8# This program is distributed in the hope that it will be useful,
9# but WITHOUT ANY WARRANTY; without even the implied warranty of
10# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11# GNU General Public License for more details.
12#
13# You should have received a copy of the GNU General Public License
14# along with this program.  If not, see <http://www.gnu.org/licenses/>.
15
16# This file was written by Michael Snyder (msnyder@redhat.com)
17# This is a test for the gdb command "info proc"
18
19set ws "\[ \t\]+"
20
21standard_testfile break.c break1.c
22
23if {[prepare_for_testing "failed to prepare" $testfile \
24	 [list $srcfile $srcfile2] {debug nowarnings}]} {
25    return -1
26}
27
28gdb_test "help info proc" "Show additional information about a process.*"
29
30gdb_test_multiple "info proc" "info proc without a process" {
31    -re "No current process.*$gdb_prompt $" {
32	pass "info proc without a process"
33    }
34    -re "Not supported on this target.*$gdb_prompt $" {
35	# info proc command not supported -- nothing to test here.
36	unsupported "gdb does not support info proc on this target"
37	return -1
38    }
39}
40
41# Set command line arguments to be verified later with "info proc
42# cmdline".  However, if we're using a stub, then "set args" would not
43# have any effect, so then just skip this.
44
45set cmdline ""
46if { ! [use_gdb_stub] } {
47    set cmdline "-i foo bar -o baz 1234"
48    gdb_test_no_output "set args $cmdline" "set args"
49}
50
51if { ! [ runto_main ] } then {
52    untested "could not run to main"
53    return -1
54}
55
56gdb_test "info proc" "process ${decimal}.*" "info proc with process"
57
58gdb_test "info proc mapping" \
59	".*Mapped address spaces:.*${hex}${ws}${hex}${ws}${hex}${ws}${hex}.*"
60
61if {[istarget "*-*-linux*"]} {
62    if { $cmdline != "" } {
63	gdb_test "info proc cmdline" "cmdline = '.* $cmdline'"
64    }
65    set gcorefile [standard_output_file $testfile.gcore]
66    if {[gdb_gcore_cmd $gcorefile "save a core file"]} {
67	clean_restart $binfile
68
69	gdb_test "core $gcorefile" "Core was generated by.*" \
70	    "core [file tail $gcorefile]"
71
72	gdb_test "info proc mapping" \
73	    ".*Mapped address spaces:.*${hex}${ws}${hex}${ws}${hex}${ws}${hex}.*" \
74	    "info proc mapping with core file"
75    }
76}
77