1# Copyright 2002, 2003, 2004, 2007 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# Please email any bugs, comments, and/or additions to this file to:
17# bug-gdb@prep.ai.mit.edu
18
19# This file was written by Michael Snyder (msnyder@redhat.com)
20# This is a test for the gdb command "info proc"
21
22if $tracelevel then {
23	strace $tracelevel
24}
25
26if { [is_remote target] } then {
27  continue
28}
29
30set prms_id 0
31set bug_id 0
32
33set ws "\[ \t\]+"
34
35set testfile "break"
36set srcfile ${testfile}.c
37set srcfile1 ${testfile}1.c
38set binfile ${objdir}/${subdir}/${testfile}
39
40if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}0.o" object {debug nowarnings}] != "" } {
41     untested info-proc.exp
42     return -1
43}
44
45if  { [gdb_compile "${srcdir}/${subdir}/${srcfile1}" "${binfile}1.o" object {debug nowarnings}] != "" } {
46     untested info-proc.exp
47     return -1
48}
49
50if  { [gdb_compile "${binfile}0.o ${binfile}1.o" "${binfile}" executable {debug nowarnings}] != "" } {
51     untested info-proc.exp
52     return -1
53}
54
55# Start with a fresh gdb.
56
57gdb_exit
58gdb_start
59gdb_reinitialize_dir $srcdir/$subdir
60gdb_load ${binfile}
61
62# Does this gdb support info proc?
63send_gdb "help info proc\n"
64gdb_expect {
65    -re "Undefined info command: .proc..  Try .help info.*$gdb_prompt $" {
66	# info proc command not supported -- nothing to test here.
67	unsupported "gdb does not support info proc on this target"
68	return -1;
69    }
70    -re "Show /proc process information about .*$gdb_prompt $" {
71	pass "help info proc"
72    }
73    -re ".*$gdb_prompt $" {
74	fail "help info proc"
75    }
76    timeout {
77	fail "help info proc (timeout)"
78    }
79}
80
81gdb_test "info proc" "No current process.*" "info proc without a process"
82
83if { ! [ runto_main ] } then {
84    untested info-proc.exp
85    return -1
86}
87
88gdb_test "info proc" "process ${decimal}.*" "info proc with process"
89
90gdb_test "info proc mapping" \
91	".*Mapped address spaces:.*${hex}${ws}${hex}${ws}${hex}${ws}${hex}.*" \
92	"info proc mapping"
93