1 /* Machine independent support for SVR4 /proc (process file system) for GDB.
2 Copyright (C) 1991 Free Software Foundation, Inc.
3 Written by Fred Fish at Cygnus Support.
5 This file is part of GDB.
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
24 For information on the details of using /proc consult section proc(4)
25 in the UNIX System V Release 4 System Administrator's Reference Manual.
27 The general register and floating point register sets are manipulated by
28 separate ioctl's. This file makes the assumption that if FP0_REGNUM is
29 defined, then support for the floating point register set is desired,
30 regardless of whether or not the actual target has floating point hardware.
37 #ifdef USE_PROC_FS /* Entire file goes away if not using /proc */
40 #include <sys/procfs.h>
49 #define MAX_SYSCALLS 256 /* Maximum number of syscalls for table */
52 #define PROC_NAME_FMT "/proc/%05d"
55 #if 1 /* FIXME: Gross and ugly hack to resolve coredep.c global */
56 CORE_ADDR kernel_u_addr
;
59 #ifdef BROKEN_SIGINFO_H /* Workaround broken SGS <sys/siginfo.h> */
61 #define si_pid _data._proc.pid
63 #define si_uid _data._proc._pdata._kill.uid
64 #endif /* BROKEN_SIGINFO_H */
66 /* All access to the inferior, either one started by gdb or one that has
67 been attached to, is controlled by an instance of a procinfo structure,
68 defined below. Since gdb currently only handles one inferior at a time,
69 the procinfo structure for the inferior is statically allocated and
70 only one exists at any given time. There is a separate procinfo
71 structure for use by the "info proc" command, so that we can print
72 useful information about any random process without interfering with
73 the inferior's procinfo information. */
76 int valid
; /* Nonzero if pid, fd, & pathname are valid */
77 int pid
; /* Process ID of inferior */
78 int fd
; /* File descriptor for /proc entry */
79 char *pathname
; /* Pathname to /proc entry */
80 int was_stopped
; /* Nonzero if was stopped prior to attach */
81 int nopass_next_sigstop
; /* Don't pass a sigstop on next resume */
82 prrun_t prrun
; /* Control state when it is run */
83 prstatus_t prstatus
; /* Current process status info */
84 gregset_t gregset
; /* General register set */
85 fpregset_t fpregset
; /* Floating point register set */
86 fltset_t fltset
; /* Current traced hardware fault set */
87 sigset_t trace
; /* Current traced signal set */
88 sysset_t exitset
; /* Current traced system call exit set */
89 sysset_t entryset
; /* Current traced system call entry set */
90 fltset_t saved_fltset
; /* Saved traced hardware fault set */
91 sigset_t saved_trace
; /* Saved traced signal set */
92 sigset_t saved_sighold
; /* Saved held signal set */
93 sysset_t saved_exitset
; /* Saved traced system call exit set */
94 sysset_t saved_entryset
; /* Saved traced system call entry set */
97 static struct procinfo pi
; /* Inferior's process information */
99 /* Much of the information used in the /proc interface, particularly for
100 printing status information, is kept as tables of structures of the
101 following form. These tables can be used to map numeric values to
102 their symbolic names and to a string that describes their specific use. */
105 int value
; /* The numeric value */
106 char *name
; /* The equivalent symbolic value */
107 char *desc
; /* Short description of value */
110 /* Translate bits in the pr_flags member of the prstatus structure, into the
111 names and desc information. */
113 static struct trans pr_flag_table
[] =
115 #if defined (PR_STOPPED)
116 PR_STOPPED
, "PR_STOPPED", "Process is stopped",
118 #if defined (PR_ISTOP)
119 PR_ISTOP
, "PR_ISTOP", "Stopped on an event of interest",
121 #if defined (PR_DSTOP)
122 PR_DSTOP
, "PR_DSTOP", "A stop directive is in effect",
124 #if defined (PR_ASLEEP)
125 PR_ASLEEP
, "PR_ASLEEP", "Sleeping in an interruptible system call",
127 #if defined (PR_FORK)
128 PR_FORK
, "PR_FORK", "Inherit-on-fork is in effect",
131 PR_RLC
, "PR_RLC", "Run-on-last-close is in effect",
133 #if defined (PR_PTRACE)
134 PR_PTRACE
, "PR_PTRACE", "Process is being controlled by ptrace",
136 #if defined (PR_PCINVAL)
137 PR_PCINVAL
, "PR_PCINVAL", "PC refers to an invalid virtual address",
139 #if defined (PR_ISSYS)
140 PR_ISSYS
, "PR_ISSYS", "Is a system process",
142 #if defined (PR_STEP)
143 PR_STEP
, "PR_STEP", "Process has single step pending",
146 PR_KLC
, "PR_KLC", "Kill-on-last-close is in effect",
148 #if defined (PR_ASYNC)
149 PR_ASYNC
, "PR_ASYNC", "Asynchronous stop is in effect",
151 #if defined (PR_PCOMPAT)
152 PR_PCOMPAT
, "PR_PCOMPAT", "Ptrace compatibility mode in effect",
157 /* Translate values in the pr_why field of the prstatus struct. */
159 static struct trans pr_why_table
[] =
161 #if defined (PR_REQUESTED)
162 PR_REQUESTED
, "PR_REQUESTED", "Directed to stop via PIOCSTOP/PIOCWSTOP",
164 #if defined (PR_SIGNALLED)
165 PR_SIGNALLED
, "PR_SIGNALLED", "Receipt of a traced signal",
167 #if defined (PR_FAULTED)
168 PR_FAULTED
, "PR_FAULTED", "Incurred a traced hardware fault",
170 #if defined (PR_SYSENTRY)
171 PR_SYSENTRY
, "PR_SYSENTRY", "Entry to a traced system call",
173 #if defined (PR_SYSEXIT)
174 PR_SYSEXIT
, "PR_SYSEXIT", "Exit from a traced system call",
176 #if defined (PR_JOBCONTROL)
177 PR_JOBCONTROL
, "PR_JOBCONTROL", "Default job control stop signal action",
179 #if defined (PR_SUSPENDED)
180 PR_SUSPENDED
, "PR_SUSPENDED", "Process suspended",
185 /* Hardware fault translation table. */
187 static struct trans faults_table
[] =
190 FLTILL
, "FLTILL", "Illegal instruction",
192 #if defined (FLTPRIV)
193 FLTPRIV
, "FLTPRIV", "Privileged instruction",
196 FLTBPT
, "FLTBPT", "Breakpoint trap",
198 #if defined (FLTTRACE)
199 FLTTRACE
, "FLTTRACE", "Trace trap",
201 #if defined (FLTACCESS)
202 FLTACCESS
, "FLTACCESS", "Memory access fault",
204 #if defined (FLTBOUNDS)
205 FLTBOUNDS
, "FLTBOUNDS", "Memory bounds violation",
207 #if defined (FLTIOVF)
208 FLTIOVF
, "FLTIOVF", "Integer overflow",
210 #if defined (FLTIZDIV)
211 FLTIZDIV
, "FLTIZDIV", "Integer zero divide",
214 FLTFPE
, "FLTFPE", "Floating-point exception",
216 #if defined (FLTSTACK)
217 FLTSTACK
, "FLTSTACK", "Unrecoverable stack fault",
219 #if defined (FLTPAGE)
220 FLTPAGE
, "FLTPAGE", "Recoverable page fault",
225 /* Translation table for signal generation information. See UNIX System
226 V Release 4 Programmer's Reference Manual, siginfo(5). */
228 static struct sigcode
{
233 } siginfo_table
[] = {
234 #if defined (SIGILL) && defined (ILL_ILLOPC)
235 SIGILL
, ILL_ILLOPC
, "ILL_ILLOPC", "Illegal opcode",
237 #if defined (SIGILL) && defined (ILL_ILLOPN)
238 SIGILL
, ILL_ILLOPN
, "ILL_ILLOPN", "Illegal operand",
240 #if defined (SIGILL) && defined (ILL_ILLADR)
241 SIGILL
, ILL_ILLADR
, "ILL_ILLADR", "Illegal addressing mode",
243 #if defined (SIGILL) && defined (ILL_ILLTRP)
244 SIGILL
, ILL_ILLTRP
, "ILL_ILLTRP", "Illegal trap",
246 #if defined (SIGILL) && defined (ILL_PRVOPC)
247 SIGILL
, ILL_PRVOPC
, "ILL_PRVOPC", "Privileged opcode",
249 #if defined (SIGILL) && defined (ILL_PRVREG)
250 SIGILL
, ILL_PRVREG
, "ILL_PRVREG", "Privileged register",
252 #if defined (SIGILL) && defined (ILL_COPROC)
253 SIGILL
, ILL_COPROC
, "ILL_COPROC", "Coprocessor error",
255 #if defined (SIGILL) && defined (ILL_BADSTK)
256 SIGILL
, ILL_BADSTK
, "ILL_BADSTK", "Internal stack error",
258 #if defined (SIGFPE) && defined (FPE_INTDIV)
259 SIGFPE
, FPE_INTDIV
, "FPE_INTDIV", "Integer divide by zero",
261 #if defined (SIGFPE) && defined (FPE_INTOVF)
262 SIGFPE
, FPE_INTOVF
, "FPE_INTOVF", "Integer overflow",
264 #if defined (SIGFPE) && defined (FPE_FLTDIV)
265 SIGFPE
, FPE_FLTDIV
, "FPE_FLTDIV", "Floating point divide by zero",
267 #if defined (SIGFPE) && defined (FPE_FLTOVF)
268 SIGFPE
, FPE_FLTOVF
, "FPE_FLTOVF", "Floating point overflow",
270 #if defined (SIGFPE) && defined (FPE_FLTUND)
271 SIGFPE
, FPE_FLTUND
, "FPE_FLTUND", "Floating point underflow",
273 #if defined (SIGFPE) && defined (FPE_FLTRES)
274 SIGFPE
, FPE_FLTRES
, "FPE_FLTRES", "Floating point inexact result",
276 #if defined (SIGFPE) && defined (FPE_FLTINV)
277 SIGFPE
, FPE_FLTINV
, "FPE_FLTINV", "Invalid floating point operation",
279 #if defined (SIGFPE) && defined (FPE_FLTSUB)
280 SIGFPE
, FPE_FLTSUB
, "FPE_FLTSUB", "Subscript out of range",
282 #if defined (SIGSEGV) && defined (SEGV_MAPERR)
283 SIGSEGV
, SEGV_MAPERR
, "SEGV_MAPERR", "Address not mapped to object",
285 #if defined (SIGSEGV) && defined (SEGV_ACCERR)
286 SIGSEGV
, SEGV_ACCERR
, "SEGV_ACCERR", "Invalid permissions for object",
288 #if defined (SIGBUS) && defined (BUS_ADRALN)
289 SIGBUS
, BUS_ADRALN
, "BUS_ADRALN", "Invalid address alignment",
291 #if defined (SIGBUS) && defined (BUS_ADRERR)
292 SIGBUS
, BUS_ADRERR
, "BUS_ADRERR", "Non-existent physical address",
294 #if defined (SIGBUS) && defined (BUS_OBJERR)
295 SIGBUS
, BUS_OBJERR
, "BUS_OBJERR", "Object specific hardware error",
297 #if defined (SIGTRAP) && defined (TRAP_BRKPT)
298 SIGTRAP
, TRAP_BRKPT
, "TRAP_BRKPT", "Process breakpoint",
300 #if defined (SIGTRAP) && defined (TRAP_TRACE)
301 SIGTRAP
, TRAP_TRACE
, "TRAP_TRACE", "Process trace trap",
303 #if defined (SIGCLD) && defined (CLD_EXITED)
304 SIGCLD
, CLD_EXITED
, "CLD_EXITED", "Child has exited",
306 #if defined (SIGCLD) && defined (CLD_KILLED)
307 SIGCLD
, CLD_KILLED
, "CLD_KILLED", "Child was killed",
309 #if defined (SIGCLD) && defined (CLD_DUMPED)
310 SIGCLD
, CLD_DUMPED
, "CLD_DUMPED", "Child has terminated abnormally",
312 #if defined (SIGCLD) && defined (CLD_TRAPPED)
313 SIGCLD
, CLD_TRAPPED
, "CLD_TRAPPED", "Traced child has trapped",
315 #if defined (SIGCLD) && defined (CLD_STOPPED)
316 SIGCLD
, CLD_STOPPED
, "CLD_STOPPED", "Child has stopped",
318 #if defined (SIGCLD) && defined (CLD_CONTINUED)
319 SIGCLD
, CLD_CONTINUED
, "CLD_CONTINUED", "Stopped child had continued",
321 #if defined (SIGPOLL) && defined (POLL_IN)
322 SIGPOLL
, POLL_IN
, "POLL_IN", "Input input available",
324 #if defined (SIGPOLL) && defined (POLL_OUT)
325 SIGPOLL
, POLL_OUT
, "POLL_OUT", "Output buffers available",
327 #if defined (SIGPOLL) && defined (POLL_MSG)
328 SIGPOLL
, POLL_MSG
, "POLL_MSG", "Input message available",
330 #if defined (SIGPOLL) && defined (POLL_ERR)
331 SIGPOLL
, POLL_ERR
, "POLL_ERR", "I/O error",
333 #if defined (SIGPOLL) && defined (POLL_PRI)
334 SIGPOLL
, POLL_PRI
, "POLL_PRI", "High priority input available",
336 #if defined (SIGPOLL) && defined (POLL_HUP)
337 SIGPOLL
, POLL_HUP
, "POLL_HUP", "Device disconnected",
342 static char *syscall_table
[MAX_SYSCALLS
];
344 /* Prototypes for local functions */
347 set_proc_siginfo
PARAMS ((struct procinfo
*, int));
350 init_syscall_table
PARAMS ((void));
353 syscallname
PARAMS ((int));
356 signalname
PARAMS ((int));
359 errnoname
PARAMS ((int));
362 proc_address_to_fd
PARAMS ((CORE_ADDR
, int));
365 open_proc_file
PARAMS ((int, struct procinfo
*));
368 close_proc_file
PARAMS ((struct procinfo
*));
371 unconditionally_kill_inferior
PARAMS ((void));
374 proc_init_failed
PARAMS ((char *));
377 info_proc
PARAMS ((char *, int));
380 info_proc_flags
PARAMS ((struct procinfo
*, int));
383 info_proc_stop
PARAMS ((struct procinfo
*, int));
386 info_proc_siginfo
PARAMS ((struct procinfo
*, int));
389 info_proc_syscalls
PARAMS ((struct procinfo
*, int));
392 info_proc_mappings
PARAMS ((struct procinfo
*, int));
395 info_proc_signals
PARAMS ((struct procinfo
*, int));
398 info_proc_faults
PARAMS ((struct procinfo
*, int));
401 mappingflags
PARAMS ((long));
404 lookupname
PARAMS ((struct trans
*, unsigned int, char *));
407 lookupdesc
PARAMS ((struct trans
*, unsigned int));
409 /* External function prototypes that can't be easily included in any
410 header file because the args are typedefs in system include files. */
413 supply_gregset
PARAMS ((gregset_t
*));
416 fill_gregset
PARAMS ((gregset_t
*, int));
419 supply_fpregset
PARAMS ((fpregset_t
*));
422 fill_fpregset
PARAMS ((fpregset_t
*, int));
428 lookupdesc -- translate a value to a summary desc string
432 static char *lookupdesc (struct trans *transp, unsigned int val);
436 Given a pointer to a translation table and a value to be translated,
437 lookup the desc string and return it.
441 lookupdesc (transp
, val
)
442 struct trans
*transp
;
447 for (desc
= NULL
; transp
-> name
!= NULL
; transp
++)
449 if (transp
-> value
== val
)
451 desc
= transp
-> desc
;
456 /* Didn't find a translation for the specified value, set a default one. */
469 lookupname -- translate a value to symbolic name
473 static char *lookupname (struct trans *transp, unsigned int val,
478 Given a pointer to a translation table, a value to be translated,
479 and a default prefix to return if the value can't be translated,
480 match the value with one of the translation table entries and
481 return a pointer to the symbolic name.
483 If no match is found it just returns the value as a printable string,
484 with the given prefix. The previous such value, if any, is freed
489 lookupname (transp
, val
, prefix
)
490 struct trans
*transp
;
497 for (name
= NULL
; transp
-> name
!= NULL
; transp
++)
499 if (transp
-> value
== val
)
501 name
= transp
-> name
;
506 /* Didn't find a translation for the specified value, build a default
507 one using the specified prefix and return it. The lifetime of
508 the value is only until the next one is needed. */
516 locbuf
= xmalloc (strlen (prefix
) + 16);
517 (void) sprintf (locbuf
, "%s %u", prefix
, val
);
529 static char locbuf
[32];
531 for (scp
= siginfo_table
; scp
-> codename
!= NULL
; scp
++)
533 if ((scp
-> signo
== sip
-> si_signo
) &&
534 (scp
-> code
== sip
-> si_code
))
536 name
= scp
-> codename
;
542 (void) sprintf (locbuf
, "sigcode %u", sip
-> si_signo
);
548 static char *sigcodedesc (sip
)
554 for (scp
= siginfo_table
; scp
-> codename
!= NULL
; scp
++)
556 if ((scp
-> signo
== sip
-> si_signo
) &&
557 (scp
-> code
== sip
-> si_code
))
565 desc
= "Unrecognized signal or trap use";
574 syscallname - translate a system call number into a system call name
578 char *syscallname (int syscallnum)
582 Given a system call number, translate it into the printable name
583 of a system call, or into "syscall <num>" if it is an unknown
588 syscallname (syscallnum
)
591 static char locbuf
[32];
594 if (syscallnum
>= 0 && syscallnum
< MAX_SYSCALLS
)
596 rtnval
= syscall_table
[syscallnum
];
600 (void) sprintf (locbuf
, "syscall %u", syscallnum
);
610 init_syscall_table - initialize syscall translation table
614 void init_syscall_table (void)
618 Dynamically initialize the translation table to convert system
619 call numbers into printable system call names. Done once per
620 gdb run, on initialization.
624 This is awfully ugly, but preprocessor tricks to make it prettier
625 tend to be nonportable.
629 init_syscall_table ()
631 #if defined (SYS_exit)
632 syscall_table
[SYS_exit
] = "exit";
634 #if defined (SYS_fork)
635 syscall_table
[SYS_fork
] = "fork";
637 #if defined (SYS_read)
638 syscall_table
[SYS_read
] = "read";
640 #if defined (SYS_write)
641 syscall_table
[SYS_write
] = "write";
643 #if defined (SYS_open)
644 syscall_table
[SYS_open
] = "open";
646 #if defined (SYS_close)
647 syscall_table
[SYS_close
] = "close";
649 #if defined (SYS_wait)
650 syscall_table
[SYS_wait
] = "wait";
652 #if defined (SYS_creat)
653 syscall_table
[SYS_creat
] = "creat";
655 #if defined (SYS_link)
656 syscall_table
[SYS_link
] = "link";
658 #if defined (SYS_unlink)
659 syscall_table
[SYS_unlink
] = "unlink";
661 #if defined (SYS_exec)
662 syscall_table
[SYS_exec
] = "exec";
664 #if defined (SYS_execv)
665 syscall_table
[SYS_execv
] = "execv";
667 #if defined (SYS_execve)
668 syscall_table
[SYS_execve
] = "execve";
670 #if defined (SYS_chdir)
671 syscall_table
[SYS_chdir
] = "chdir";
673 #if defined (SYS_time)
674 syscall_table
[SYS_time
] = "time";
676 #if defined (SYS_mknod)
677 syscall_table
[SYS_mknod
] = "mknod";
679 #if defined (SYS_chmod)
680 syscall_table
[SYS_chmod
] = "chmod";
682 #if defined (SYS_chown)
683 syscall_table
[SYS_chown
] = "chown";
685 #if defined (SYS_brk)
686 syscall_table
[SYS_brk
] = "brk";
688 #if defined (SYS_stat)
689 syscall_table
[SYS_stat
] = "stat";
691 #if defined (SYS_lseek)
692 syscall_table
[SYS_lseek
] = "lseek";
694 #if defined (SYS_getpid)
695 syscall_table
[SYS_getpid
] = "getpid";
697 #if defined (SYS_mount)
698 syscall_table
[SYS_mount
] = "mount";
700 #if defined (SYS_umount)
701 syscall_table
[SYS_umount
] = "umount";
703 #if defined (SYS_setuid)
704 syscall_table
[SYS_setuid
] = "setuid";
706 #if defined (SYS_getuid)
707 syscall_table
[SYS_getuid
] = "getuid";
709 #if defined (SYS_stime)
710 syscall_table
[SYS_stime
] = "stime";
712 #if defined (SYS_ptrace)
713 syscall_table
[SYS_ptrace
] = "ptrace";
715 #if defined (SYS_alarm)
716 syscall_table
[SYS_alarm
] = "alarm";
718 #if defined (SYS_fstat)
719 syscall_table
[SYS_fstat
] = "fstat";
721 #if defined (SYS_pause)
722 syscall_table
[SYS_pause
] = "pause";
724 #if defined (SYS_utime)
725 syscall_table
[SYS_utime
] = "utime";
727 #if defined (SYS_stty)
728 syscall_table
[SYS_stty
] = "stty";
730 #if defined (SYS_gtty)
731 syscall_table
[SYS_gtty
] = "gtty";
733 #if defined (SYS_access)
734 syscall_table
[SYS_access
] = "access";
736 #if defined (SYS_nice)
737 syscall_table
[SYS_nice
] = "nice";
739 #if defined (SYS_statfs)
740 syscall_table
[SYS_statfs
] = "statfs";
742 #if defined (SYS_sync)
743 syscall_table
[SYS_sync
] = "sync";
745 #if defined (SYS_kill)
746 syscall_table
[SYS_kill
] = "kill";
748 #if defined (SYS_fstatfs)
749 syscall_table
[SYS_fstatfs
] = "fstatfs";
751 #if defined (SYS_pgrpsys)
752 syscall_table
[SYS_pgrpsys
] = "pgrpsys";
754 #if defined (SYS_xenix)
755 syscall_table
[SYS_xenix
] = "xenix";
757 #if defined (SYS_dup)
758 syscall_table
[SYS_dup
] = "dup";
760 #if defined (SYS_pipe)
761 syscall_table
[SYS_pipe
] = "pipe";
763 #if defined (SYS_times)
764 syscall_table
[SYS_times
] = "times";
766 #if defined (SYS_profil)
767 syscall_table
[SYS_profil
] = "profil";
769 #if defined (SYS_plock)
770 syscall_table
[SYS_plock
] = "plock";
772 #if defined (SYS_setgid)
773 syscall_table
[SYS_setgid
] = "setgid";
775 #if defined (SYS_getgid)
776 syscall_table
[SYS_getgid
] = "getgid";
778 #if defined (SYS_signal)
779 syscall_table
[SYS_signal
] = "signal";
781 #if defined (SYS_msgsys)
782 syscall_table
[SYS_msgsys
] = "msgsys";
784 #if defined (SYS_sys3b)
785 syscall_table
[SYS_sys3b
] = "sys3b";
787 #if defined (SYS_acct)
788 syscall_table
[SYS_acct
] = "acct";
790 #if defined (SYS_shmsys)
791 syscall_table
[SYS_shmsys
] = "shmsys";
793 #if defined (SYS_semsys)
794 syscall_table
[SYS_semsys
] = "semsys";
796 #if defined (SYS_ioctl)
797 syscall_table
[SYS_ioctl
] = "ioctl";
799 #if defined (SYS_uadmin)
800 syscall_table
[SYS_uadmin
] = "uadmin";
802 #if defined (SYS_utssys)
803 syscall_table
[SYS_utssys
] = "utssys";
805 #if defined (SYS_fsync)
806 syscall_table
[SYS_fsync
] = "fsync";
808 #if defined (SYS_umask)
809 syscall_table
[SYS_umask
] = "umask";
811 #if defined (SYS_chroot)
812 syscall_table
[SYS_chroot
] = "chroot";
814 #if defined (SYS_fcntl)
815 syscall_table
[SYS_fcntl
] = "fcntl";
817 #if defined (SYS_ulimit)
818 syscall_table
[SYS_ulimit
] = "ulimit";
820 #if defined (SYS_rfsys)
821 syscall_table
[SYS_rfsys
] = "rfsys";
823 #if defined (SYS_rmdir)
824 syscall_table
[SYS_rmdir
] = "rmdir";
826 #if defined (SYS_mkdir)
827 syscall_table
[SYS_mkdir
] = "mkdir";
829 #if defined (SYS_getdents)
830 syscall_table
[SYS_getdents
] = "getdents";
832 #if defined (SYS_sysfs)
833 syscall_table
[SYS_sysfs
] = "sysfs";
835 #if defined (SYS_getmsg)
836 syscall_table
[SYS_getmsg
] = "getmsg";
838 #if defined (SYS_putmsg)
839 syscall_table
[SYS_putmsg
] = "putmsg";
841 #if defined (SYS_poll)
842 syscall_table
[SYS_poll
] = "poll";
844 #if defined (SYS_lstat)
845 syscall_table
[SYS_lstat
] = "lstat";
847 #if defined (SYS_symlink)
848 syscall_table
[SYS_symlink
] = "symlink";
850 #if defined (SYS_readlink)
851 syscall_table
[SYS_readlink
] = "readlink";
853 #if defined (SYS_setgroups)
854 syscall_table
[SYS_setgroups
] = "setgroups";
856 #if defined (SYS_getgroups)
857 syscall_table
[SYS_getgroups
] = "getgroups";
859 #if defined (SYS_fchmod)
860 syscall_table
[SYS_fchmod
] = "fchmod";
862 #if defined (SYS_fchown)
863 syscall_table
[SYS_fchown
] = "fchown";
865 #if defined (SYS_sigprocmask)
866 syscall_table
[SYS_sigprocmask
] = "sigprocmask";
868 #if defined (SYS_sigsuspend)
869 syscall_table
[SYS_sigsuspend
] = "sigsuspend";
871 #if defined (SYS_sigaltstack)
872 syscall_table
[SYS_sigaltstack
] = "sigaltstack";
874 #if defined (SYS_sigaction)
875 syscall_table
[SYS_sigaction
] = "sigaction";
877 #if defined (SYS_sigpending)
878 syscall_table
[SYS_sigpending
] = "sigpending";
880 #if defined (SYS_context)
881 syscall_table
[SYS_context
] = "context";
883 #if defined (SYS_evsys)
884 syscall_table
[SYS_evsys
] = "evsys";
886 #if defined (SYS_evtrapret)
887 syscall_table
[SYS_evtrapret
] = "evtrapret";
889 #if defined (SYS_statvfs)
890 syscall_table
[SYS_statvfs
] = "statvfs";
892 #if defined (SYS_fstatvfs)
893 syscall_table
[SYS_fstatvfs
] = "fstatvfs";
895 #if defined (SYS_nfssys)
896 syscall_table
[SYS_nfssys
] = "nfssys";
898 #if defined (SYS_waitsys)
899 syscall_table
[SYS_waitsys
] = "waitsys";
901 #if defined (SYS_sigsendsys)
902 syscall_table
[SYS_sigsendsys
] = "sigsendsys";
904 #if defined (SYS_hrtsys)
905 syscall_table
[SYS_hrtsys
] = "hrtsys";
907 #if defined (SYS_acancel)
908 syscall_table
[SYS_acancel
] = "acancel";
910 #if defined (SYS_async)
911 syscall_table
[SYS_async
] = "async";
913 #if defined (SYS_priocntlsys)
914 syscall_table
[SYS_priocntlsys
] = "priocntlsys";
916 #if defined (SYS_pathconf)
917 syscall_table
[SYS_pathconf
] = "pathconf";
919 #if defined (SYS_mincore)
920 syscall_table
[SYS_mincore
] = "mincore";
922 #if defined (SYS_mmap)
923 syscall_table
[SYS_mmap
] = "mmap";
925 #if defined (SYS_mprotect)
926 syscall_table
[SYS_mprotect
] = "mprotect";
928 #if defined (SYS_munmap)
929 syscall_table
[SYS_munmap
] = "munmap";
931 #if defined (SYS_fpathconf)
932 syscall_table
[SYS_fpathconf
] = "fpathconf";
934 #if defined (SYS_vfork)
935 syscall_table
[SYS_vfork
] = "vfork";
937 #if defined (SYS_fchdir)
938 syscall_table
[SYS_fchdir
] = "fchdir";
940 #if defined (SYS_readv)
941 syscall_table
[SYS_readv
] = "readv";
943 #if defined (SYS_writev)
944 syscall_table
[SYS_writev
] = "writev";
946 #if defined (SYS_xstat)
947 syscall_table
[SYS_xstat
] = "xstat";
949 #if defined (SYS_lxstat)
950 syscall_table
[SYS_lxstat
] = "lxstat";
952 #if defined (SYS_fxstat)
953 syscall_table
[SYS_fxstat
] = "fxstat";
955 #if defined (SYS_xmknod)
956 syscall_table
[SYS_xmknod
] = "xmknod";
958 #if defined (SYS_clocal)
959 syscall_table
[SYS_clocal
] = "clocal";
961 #if defined (SYS_setrlimit)
962 syscall_table
[SYS_setrlimit
] = "setrlimit";
964 #if defined (SYS_getrlimit)
965 syscall_table
[SYS_getrlimit
] = "getrlimit";
967 #if defined (SYS_lchown)
968 syscall_table
[SYS_lchown
] = "lchown";
970 #if defined (SYS_memcntl)
971 syscall_table
[SYS_memcntl
] = "memcntl";
973 #if defined (SYS_getpmsg)
974 syscall_table
[SYS_getpmsg
] = "getpmsg";
976 #if defined (SYS_putpmsg)
977 syscall_table
[SYS_putpmsg
] = "putpmsg";
979 #if defined (SYS_rename)
980 syscall_table
[SYS_rename
] = "rename";
982 #if defined (SYS_uname)
983 syscall_table
[SYS_uname
] = "uname";
985 #if defined (SYS_setegid)
986 syscall_table
[SYS_setegid
] = "setegid";
988 #if defined (SYS_sysconfig)
989 syscall_table
[SYS_sysconfig
] = "sysconfig";
991 #if defined (SYS_adjtime)
992 syscall_table
[SYS_adjtime
] = "adjtime";
994 #if defined (SYS_systeminfo)
995 syscall_table
[SYS_systeminfo
] = "systeminfo";
997 #if defined (SYS_seteuid)
998 syscall_table
[SYS_seteuid
] = "seteuid";
1006 ptrace -- override library version to force errors for /proc version
1010 int ptrace (int request, int pid, PTRACE_ARG3_TYPE arg3, int arg4)
1014 When gdb is configured to use /proc, it should not be calling
1015 or otherwise attempting to use ptrace. In order to catch errors
1016 where use of /proc is configured, but some routine is still calling
1017 ptrace, we provide a local version of a function with that name
1018 that does nothing but issue an error message.
1022 ptrace (request
, pid
, arg3
, arg4
)
1025 PTRACE_ARG3_TYPE arg3
;
1028 error ("internal error - there is a call to ptrace() somewhere");
1036 kill_inferior_fast -- kill inferior while gdb is exiting
1040 void kill_inferior_fast (void)
1044 This is used when GDB is exiting. It gives less chance of error.
1048 Don't attempt to kill attached inferiors since we may be called
1049 when gdb is in the process of aborting, and killing the attached
1050 inferior may be very anti-social. This is particularly true if we
1051 were attached just so we could use the /proc facilities to get
1052 detailed information about it's status.
1057 kill_inferior_fast ()
1059 if (inferior_pid
!= 0 && !attach_flag
)
1061 unconditionally_kill_inferior ();
1069 kill_inferior - kill any currently inferior
1073 void kill_inferior (void)
1077 Kill any current inferior.
1081 Kills even attached inferiors. Presumably the user has already
1082 been prompted that the inferior is an attached one rather than
1083 one started by gdb. (FIXME?)
1090 if (inferior_pid
!= 0)
1092 unconditionally_kill_inferior ();
1093 target_mourn_inferior ();
1101 unconditionally_kill_inferior - terminate the inferior
1105 static void unconditionally_kill_inferior (void)
1109 Kill the current inferior. Should not be called until it
1110 is at least tested that there is an inferior.
1114 A possibly useful enhancement would be to first try sending
1115 the inferior a terminate signal, politely asking it to commit
1116 suicide, before we murder it.
1121 unconditionally_kill_inferior ()
1126 (void) ioctl (pi
.fd
, PIOCKILL
, &signo
);
1127 close_proc_file (&pi
);
1135 child_xfer_memory -- copy data to or from inferior memory space
1139 int child_xfer_memory (CORE_ADDR memaddr, char *myaddr, int len,
1140 int dowrite, struct target_ops target)
1144 Copy LEN bytes to/from inferior's memory starting at MEMADDR
1145 from/to debugger memory starting at MYADDR. Copy from inferior
1146 if DOWRITE is zero or to inferior if DOWRITE is nonzero.
1148 Returns the length copied, which is either the LEN argument or
1149 zero. This xfer function does not do partial moves, since child_ops
1150 doesn't allow memory operations to cross below us in the target stack
1155 The /proc interface makes this an almost trivial task.
1160 child_xfer_memory (memaddr
, myaddr
, len
, dowrite
, target
)
1165 struct target_ops
*target
; /* ignored */
1169 if (lseek (pi
.fd
, (off_t
) memaddr
, 0) == (off_t
) memaddr
)
1173 nbytes
= write (pi
.fd
, myaddr
, len
);
1177 nbytes
= read (pi
.fd
, myaddr
, len
);
1191 store_inferior_registers -- copy register values back to inferior
1195 void store_inferior_registers (int regno)
1199 Store our current register values back into the inferior. If
1200 REGNO is -1 then store all the register, otherwise store just
1201 the value specified by REGNO.
1205 If we are storing only a single register, we first have to get all
1206 the current values from the process, overwrite the desired register
1207 in the gregset with the one we want from gdb's registers, and then
1208 send the whole set back to the process. For writing all the
1209 registers, all we have to do is generate the gregset and send it to
1212 Also note that the process has to be stopped on an event of interest
1213 for this to work, which basically means that it has to have been
1214 run under the control of one of the other /proc ioctl calls and not
1215 ptrace. Since we don't use ptrace anyway, we don't worry about this
1216 fine point, but it is worth noting for future reference.
1218 Gdb is confused about what this function is supposed to return.
1219 Some versions return a value, others return nothing. Some are
1220 declared to return a value and actually return nothing. Gdb ignores
1221 anything returned. (FIXME)
1226 store_inferior_registers (regno
)
1231 (void) ioctl (pi
.fd
, PIOCGREG
, &pi
.gregset
);
1233 fill_gregset (&pi
.gregset
, regno
);
1234 (void) ioctl (pi
.fd
, PIOCSREG
, &pi
.gregset
);
1236 #if defined (FP0_REGNUM)
1238 /* Now repeat everything using the floating point register set, if the
1239 target has floating point hardware. Since we ignore the returned value,
1240 we'll never know whether it worked or not anyway. */
1244 (void) ioctl (pi
.fd
, PIOCGFPREG
, &pi
.fpregset
);
1246 fill_fpregset (&pi
.fpregset
, regno
);
1247 (void) ioctl (pi
.fd
, PIOCSFPREG
, &pi
.fpregset
);
1249 #endif /* FP0_REGNUM */
1257 inferior_proc_init - initialize access to a /proc entry
1261 void inferior_proc_init (int pid)
1265 When gdb starts an inferior, this function is called in the parent
1266 process immediately after the fork. It waits for the child to stop
1267 on the return from the exec system call (the child itself takes care
1268 of ensuring that this is set up), then sets up the set of signals
1269 and faults that are to be traced.
1273 If proc_init_failed ever gets called, control returns to the command
1274 processing loop via the standard error handling code.
1279 inferior_proc_init (pid
)
1282 if (!open_proc_file (pid
, &pi
))
1284 proc_init_failed ("can't open process file");
1288 (void) memset ((char *) &pi
.prrun
, 0, sizeof (pi
.prrun
));
1289 prfillset (&pi
.prrun
.pr_trace
);
1290 proc_signal_handling_change ();
1291 prfillset (&pi
.prrun
.pr_fault
);
1292 prdelset (&pi
.prrun
.pr_fault
, FLTPAGE
);
1293 if (ioctl (pi
.fd
, PIOCWSTOP
, &pi
.prstatus
) < 0)
1295 proc_init_failed ("PIOCWSTOP failed");
1297 else if (ioctl (pi
.fd
, PIOCSFAULT
, &pi
.prrun
.pr_fault
) < 0)
1299 proc_init_failed ("PIOCSFAULT failed");
1308 proc_signal_handling_change
1312 void proc_signal_handling_change (void);
1316 When the user changes the state of gdb's signal handling via the
1317 "handle" command, this function gets called to see if any change
1318 in the /proc interface is required. It is also called internally
1319 by other /proc interface functions to initialize the state of
1320 the traced signal set.
1322 One thing it does is that signals for which the state is "nostop",
1323 "noprint", and "pass", have their trace bits reset in the pr_trace
1324 field, so that they are no longer traced. This allows them to be
1325 delivered directly to the inferior without the debugger ever being
1330 proc_signal_handling_change ()
1336 for (signo
= 0; signo
< NSIG
; signo
++)
1338 if (signal_stop_state (signo
) == 0 &&
1339 signal_print_state (signo
) == 0 &&
1340 signal_pass_state (signo
) == 1)
1342 prdelset (&pi
.prrun
.pr_trace
, signo
);
1346 praddset (&pi
.prrun
.pr_trace
, signo
);
1349 if (ioctl (pi
.fd
, PIOCSTRACE
, &pi
.prrun
.pr_trace
))
1351 print_sys_errmsg ("PIOCSTRACE failed", errno
);
1360 proc_set_exec_trap -- arrange for exec'd child to halt at startup
1364 void proc_set_exec_trap (void)
1368 This function is called in the child process when starting up
1369 an inferior, prior to doing the exec of the actual inferior.
1370 It sets the child process's exitset to make exit from the exec
1371 system call an event of interest to stop on, and then simply
1372 returns. The child does the exec, the system call returns, and
1373 the child stops at the first instruction, ready for the gdb
1374 parent process to take control of it.
1378 We need to use all local variables since the child may be sharing
1379 it's data space with the parent, if vfork was used rather than
1382 Also note that we want to turn off the inherit-on-fork flag in
1383 the child process so that any grand-children start with all
1384 tracing flags cleared.
1388 proc_set_exec_trap ()
1391 auto char procname
[32];
1394 (void) sprintf (procname
, PROC_NAME_FMT
, getpid ());
1395 if ((fd
= open (procname
, O_RDWR
)) < 0)
1401 premptyset (&exitset
);
1404 Not all systems with /proc have all the exec* syscalls with the same
1405 names. On the SGI, for example, there is no SYS_exec, but there
1406 *is* a SYS_execv. So, we try to account for that. */
1409 praddset (&exitset
, SYS_exec
);
1412 praddset (&exitset
, SYS_execve
);
1415 praddset(&exitset
, SYS_execv
);
1418 if (ioctl (fd
, PIOCSEXIT
, &exitset
) < 0)
1425 /* Turn off inherit-on-fork flag so that all grand-children of gdb
1426 start with tracing flags cleared. */
1428 #if defined (PIOCRESET) /* New method */
1432 (void) ioctl (fd
, PIOCRESET
, &pr_flags
);
1435 #if defined (PIOCRFORK) /* Original method */
1436 (void) ioctl (fd
, PIOCRFORK
, NULL
);
1445 proc_iterate_over_mappings -- call function for every mapped space
1449 int proc_iterate_over_mappings (int (*func)())
1453 Given a pointer to a function, call that function for every
1454 mapped address space, passing it an open file descriptor for
1455 the file corresponding to that mapped address space (if any)
1456 and the base address of the mapped space. Quit when we hit
1457 the end of the mappings or the function returns nonzero.
1461 proc_iterate_over_mappings (func
)
1462 int (*func
) PARAMS ((int, CORE_ADDR
));
1467 struct prmap
*prmaps
;
1468 struct prmap
*prmap
;
1470 if (pi
.valid
&& (ioctl (pi
.fd
, PIOCNMAP
, &nmap
) == 0))
1472 prmaps
= (struct prmap
*) alloca ((nmap
+ 1) * sizeof (*prmaps
));
1473 if (ioctl (pi
.fd
, PIOCMAP
, prmaps
) == 0)
1475 for (prmap
= prmaps
; prmap
-> pr_size
&& funcstat
== 0; ++prmap
)
1477 fd
= proc_address_to_fd ((CORE_ADDR
) prmap
-> pr_vaddr
, 0);
1478 funcstat
= (*func
) (fd
, (CORE_ADDR
) prmap
-> pr_vaddr
);
1490 proc_base_address -- find base address for segment containing address
1494 CORE_ADDR proc_base_address (CORE_ADDR addr)
1498 Given an address of a location in the inferior, find and return
1499 the base address of the mapped segment containing that address.
1501 This is used for example, by the shared library support code,
1502 where we have the pc value for some location in the shared library
1503 where we are stopped, and need to know the base address of the
1504 segment containing that address.
1508 #if 0 /* Currently unused */
1511 proc_base_address (addr
)
1515 struct prmap
*prmaps
;
1516 struct prmap
*prmap
;
1517 CORE_ADDR baseaddr
= 0;
1519 if (pi
.valid
&& (ioctl (pi
.fd
, PIOCNMAP
, &nmap
) == 0))
1521 prmaps
= (struct prmap
*) alloca ((nmap
+ 1) * sizeof (*prmaps
));
1522 if (ioctl (pi
.fd
, PIOCMAP
, prmaps
) == 0)
1524 for (prmap
= prmaps
; prmap
-> pr_size
; ++prmap
)
1526 if ((prmap
-> pr_vaddr
<= (caddr_t
) addr
) &&
1527 (prmap
-> pr_vaddr
+ prmap
-> pr_size
> (caddr_t
) addr
))
1529 baseaddr
= (CORE_ADDR
) prmap
-> pr_vaddr
;
1544 proc_address_to_fd -- return open fd for file mapped to address
1548 int proc_address_to_fd (CORE_ADDR addr, complain)
1552 Given an address in the current inferior's address space, use the
1553 /proc interface to find an open file descriptor for the file that
1554 this address was mapped in from. Return -1 if there is no current
1555 inferior. Print a warning message if there is an inferior but
1556 the address corresponds to no file (IE a bogus address).
1561 proc_address_to_fd (addr
, complain
)
1569 if ((fd
= ioctl (pi
.fd
, PIOCOPENM
, (caddr_t
*) &addr
)) < 0)
1573 print_sys_errmsg (pi
.pathname
, errno
);
1574 warning ("can't find mapped file for address 0x%x", addr
);
1582 #ifdef ATTACH_DETACH
1588 attach -- attach to an already existing process
1592 int attach (int pid)
1596 Attach to an already existing process with the specified process
1597 id. If the process is not already stopped, query whether to
1602 The option of stopping at attach time is specific to the /proc
1603 versions of gdb. Versions using ptrace force the attachee
1612 if (!open_proc_file (pid
, &pi
))
1614 perror_with_name (pi
.pathname
);
1618 /* Get current status of process and if it is not already stopped,
1619 then stop it. Remember whether or not it was stopped when we first
1622 if (ioctl (pi
.fd
, PIOCSTATUS
, &pi
.prstatus
) < 0)
1624 print_sys_errmsg (pi
.pathname
, errno
);
1625 close_proc_file (&pi
);
1626 error ("PIOCSTATUS failed");
1628 if (pi
.prstatus
.pr_flags
& (PR_STOPPED
| PR_ISTOP
))
1635 if (query ("Process is currently running, stop it? "))
1637 if (ioctl (pi
.fd
, PIOCSTOP
, &pi
.prstatus
) < 0)
1639 print_sys_errmsg (pi
.pathname
, errno
);
1640 close_proc_file (&pi
);
1641 error ("PIOCSTOP failed");
1643 pi
.nopass_next_sigstop
= 1;
1647 printf ("Ok, gdb will wait for process %u to stop.\n", pid
);
1651 /* Remember some things about the inferior that we will, or might, change
1652 so that we can restore them when we detach. */
1654 (void) ioctl (pi
.fd
, PIOCGTRACE
, &pi
.saved_trace
);
1655 (void) ioctl (pi
.fd
, PIOCGHOLD
, &pi
.saved_sighold
);
1656 (void) ioctl (pi
.fd
, PIOCGFAULT
, &pi
.saved_fltset
);
1657 (void) ioctl (pi
.fd
, PIOCGENTRY
, &pi
.saved_entryset
);
1658 (void) ioctl (pi
.fd
, PIOCGEXIT
, &pi
.saved_exitset
);
1660 /* Set up trace and fault sets, as gdb expects them. */
1662 (void) memset (&pi
.prrun
, 0, sizeof (pi
.prrun
));
1663 prfillset (&pi
.prrun
.pr_trace
);
1664 proc_signal_handling_change ();
1665 prfillset (&pi
.prrun
.pr_fault
);
1666 prdelset (&pi
.prrun
.pr_fault
, FLTPAGE
);
1667 if (ioctl (pi
.fd
, PIOCSFAULT
, &pi
.prrun
.pr_fault
))
1669 print_sys_errmsg ("PIOCSFAULT failed", errno
);
1671 if (ioctl (pi
.fd
, PIOCSTRACE
, &pi
.prrun
.pr_trace
))
1673 print_sys_errmsg ("PIOCSTRACE failed", errno
);
1683 detach -- detach from an attached-to process
1687 void detach (int signal)
1691 Detach from the current attachee.
1693 If signal is non-zero, the attachee is started running again and sent
1694 the specified signal.
1696 If signal is zero and the attachee was not already stopped when we
1697 attached to it, then we make it runnable again when we detach.
1699 Otherwise, we query whether or not to make the attachee runnable
1700 again, since we may simply want to leave it in the state it was in
1703 We report any problems, but do not consider them errors, since we
1704 MUST detach even if some things don't seem to go right. This may not
1705 be the ideal situation. (FIXME).
1714 set_proc_siginfo (&pi
, signal
);
1716 if (ioctl (pi
.fd
, PIOCSEXIT
, &pi
.saved_exitset
) < 0)
1718 print_sys_errmsg (pi
.pathname
, errno
);
1719 printf ("PIOCSEXIT failed.\n");
1721 if (ioctl (pi
.fd
, PIOCSENTRY
, &pi
.saved_entryset
) < 0)
1723 print_sys_errmsg (pi
.pathname
, errno
);
1724 printf ("PIOCSENTRY failed.\n");
1726 if (ioctl (pi
.fd
, PIOCSTRACE
, &pi
.saved_trace
) < 0)
1728 print_sys_errmsg (pi
.pathname
, errno
);
1729 printf ("PIOCSTRACE failed.\n");
1731 if (ioctl (pi
.fd
, PIOCSHOLD
, &pi
.saved_sighold
) < 0)
1733 print_sys_errmsg (pi
.pathname
, errno
);
1734 printf ("PIOSCHOLD failed.\n");
1736 if (ioctl (pi
.fd
, PIOCSFAULT
, &pi
.saved_fltset
) < 0)
1738 print_sys_errmsg (pi
.pathname
, errno
);
1739 printf ("PIOCSFAULT failed.\n");
1741 if (ioctl (pi
.fd
, PIOCSTATUS
, &pi
.prstatus
) < 0)
1743 print_sys_errmsg (pi
.pathname
, errno
);
1744 printf ("PIOCSTATUS failed.\n");
1748 if (signal
|| (pi
.prstatus
.pr_flags
& (PR_STOPPED
| PR_ISTOP
)))
1750 if (signal
|| !pi
.was_stopped
||
1751 query ("Was stopped when attached, make it runnable again? "))
1753 (void) memset (&pi
.prrun
, 0, sizeof (pi
.prrun
));
1754 pi
.prrun
.pr_flags
= PRCFAULT
;
1755 if (ioctl (pi
.fd
, PIOCRUN
, &pi
.prrun
))
1757 print_sys_errmsg (pi
.pathname
, errno
);
1758 printf ("PIOCRUN failed.\n");
1763 close_proc_file (&pi
);
1767 #endif /* ATTACH_DETACH */
1773 proc_wait -- emulate wait() as much as possible
1777 int proc_wait (int *statloc)
1781 Try to emulate wait() as much as possible. Not sure why we can't
1782 just use wait(), but it seems to have problems when applied to a
1783 process being controlled with the /proc interface.
1787 We have a race problem here with no obvious solution. We need to let
1788 the inferior run until it stops on an event of interest, which means
1789 that we need to use the PIOCWSTOP ioctl. However, we cannot use this
1790 ioctl if the process is already stopped on something that is not an
1791 event of interest, or the call will hang indefinitely. Thus we first
1792 use PIOCSTATUS to see if the process is not stopped. If not, then we
1793 use PIOCWSTOP. But during the window between the two, if the process
1794 stops for any reason that is not an event of interest (such as a job
1795 control signal) then gdb will hang. One possible workaround is to set
1796 an alarm to wake up every minute of so and check to see if the process
1797 is still running, and if so, then reissue the PIOCWSTOP. But this is
1798 a real kludge, so has not been implemented. FIXME: investigate
1801 FIXME: Investigate why wait() seems to have problems with programs
1802 being control by /proc routines.
1816 if (ioctl (pi
.fd
, PIOCSTATUS
, &pi
.prstatus
) < 0)
1820 else if (!(pi
.prstatus
.pr_flags
& (PR_STOPPED
| PR_ISTOP
)))
1822 if (ioctl (pi
.fd
, PIOCWSTOP
, &pi
.prstatus
) < 0)
1829 if (errno
== ENOENT
)
1831 rtnval
= wait (&statval
);
1832 if (rtnval
!= inferior_pid
)
1834 error ("PIOCWSTOP, wait failed, returned %d", rtnval
);
1840 print_sys_errmsg (pi
.pathname
, errno
);
1841 error ("PIOCSTATUS or PIOCWSTOP failed.");
1845 else if (pi
.prstatus
.pr_flags
& (PR_STOPPED
| PR_ISTOP
))
1847 rtnval
= pi
.prstatus
.pr_pid
;
1848 why
= pi
.prstatus
.pr_why
;
1849 what
= pi
.prstatus
.pr_what
;
1850 if (why
== PR_SIGNALLED
)
1852 statval
= (what
<< 8) | 0177;
1854 else if ((why
== PR_SYSEXIT
)
1863 || what
== SYS_execve
1866 || what
== SYS_execv
1870 statval
= (SIGTRAP
<< 8) | 0177;
1872 else if (why
== PR_REQUESTED
)
1874 statval
= (SIGSTOP
<< 8) | 0177;
1876 else if (why
== PR_JOBCONTROL
)
1878 statval
= (what
<< 8) | 0177;
1880 else if (why
== PR_FAULTED
)
1886 statval
= (SIGILL
<< 8) | 0177;
1890 statval
= (SIGTRAP
<< 8) | 0177;
1895 statval
= (SIGSEGV
<< 8) | 0177;
1900 statval
= (SIGFPE
<< 8) | 0177;
1902 case FLTPAGE
: /* Recoverable page fault */
1905 error ("PIOCWSTOP, unknown why %d, what %d", why
, what
);
1912 error ("PIOCWSTOP, unknown why %d, what %d", why
, what
);
1918 error ("PIOCWSTOP, stopped for unknown/unhandled reason, flags %#x",
1919 pi
.prstatus
.pr_flags
);
1933 set_proc_siginfo - set a process's current signal info
1937 void set_proc_siginfo (struct procinfo *pip, int signo);
1941 Given a pointer to a process info struct in PIP and a signal number
1942 in SIGNO, set the process's current signal and its associated signal
1943 information. The signal will be delivered to the process immediately
1944 after execution is resumed, even if it is being held. In addition,
1945 this particular delivery will not cause another PR_SIGNALLED stop
1946 even if the signal is being traced.
1948 If we are not delivering the same signal that the prstatus siginfo
1949 struct contains information about, then synthesize a siginfo struct
1950 to match the signal we are doing to deliver, make it of the type
1951 "generated by a user process", and send this synthesized copy. When
1952 used to set the inferior's signal state, this will be required if we
1953 are not currently stopped because of a traced signal, or if we decide
1954 to continue with a different signal.
1956 Note that when continuing the inferior from a stop due to receipt
1957 of a traced signal, we either have set PRCSIG to clear the existing
1958 signal, or we have to call this function to do a PIOCSSIG with either
1959 the existing siginfo struct from pr_info, or one we have synthesized
1960 appropriately for the signal we want to deliver. Otherwise if the
1961 signal is still being traced, the inferior will immediately stop
1964 See siginfo(5) for more details.
1968 set_proc_siginfo (pip
, signo
)
1969 struct procinfo
*pip
;
1972 struct siginfo newsiginfo
;
1973 struct siginfo
*sip
;
1977 if (signo
== pip
-> prstatus
.pr_info
.si_signo
)
1979 sip
= &pip
-> prstatus
.pr_info
;
1983 (void) memset ((char *) &newsiginfo
, 0, sizeof (newsiginfo
));
1985 sip
-> si_signo
= signo
;
1987 sip
-> si_errno
= 0;
1988 sip
-> si_pid
= getpid ();
1989 sip
-> si_uid
= getuid ();
1991 if (ioctl (pip
-> fd
, PIOCSSIG
, sip
) < 0)
1993 print_sys_errmsg (pip
-> pathname
, errno
);
1994 warning ("PIOCSSIG failed");
2003 child_resume -- resume execution of the inferior process
2007 void child_resume (int step, int signo)
2011 Resume execution of the inferior process. If STEP is nozero, then
2012 just single step it. If SIGNAL is nonzero, restart it with that
2017 It may not be absolutely necessary to specify the PC value for
2018 restarting, but to be safe we use the value that gdb considers
2019 to be current. One case where this might be necessary is if the
2020 user explicitly changes the PC value that gdb considers to be
2021 current. FIXME: Investigate if this is necessary or not.
2023 When attaching to a child process, if we forced it to stop with
2024 a PIOCSTOP, then we will have set the nopass_next_sigstop flag.
2025 Upon resuming the first time after such a stop, we explicitly
2026 inhibit sending it another SIGSTOP, which would be the normal
2027 result of default signal handling. One potential drawback to
2028 this is that we will also ignore any attempt to by the user
2029 to explicitly continue after the attach with a SIGSTOP. Ultimately
2030 this problem should be dealt with by making the routines that
2031 deal with the inferior a little smarter, and possibly even allow
2032 an inferior to continue running at the same time as gdb. (FIXME?)
2036 child_resume (step
, signo
)
2041 pi
.prrun
.pr_flags
= PRSTRACE
| PRSFAULT
| PRCFAULT
;
2043 #ifdef PRSVADDR_BROKEN
2044 /* Can't do this under Solaris running on a Sparc, as there seems to be no
2045 place to put nPC. In fact, if you use this, nPC seems to be set to some
2046 random garbage. We have to rely on the fact that PC and nPC have been
2047 written previously via PIOCSREG during a register flush. */
2049 pi
.prrun
.pr_vaddr
= (caddr_t
) *(int *) ®isters
[REGISTER_BYTE (PC_REGNUM
)];
2050 pi
.prrun
.pr_flags
!= PRSVADDR
;
2053 if (signo
&& !(signo
== SIGSTOP
&& pi
.nopass_next_sigstop
))
2055 set_proc_siginfo (&pi
, signo
);
2059 pi
.prrun
.pr_flags
|= PRCSIG
;
2061 pi
.nopass_next_sigstop
= 0;
2064 pi
.prrun
.pr_flags
|= PRSTEP
;
2066 if (ioctl (pi
.fd
, PIOCRUN
, &pi
.prrun
) != 0)
2068 perror_with_name (pi
.pathname
);
2077 fetch_inferior_registers -- fetch current registers from inferior
2081 void fetch_inferior_registers (int regno)
2085 Read the current values of the inferior's registers, both the
2086 general register set and floating point registers (if supported)
2087 and update gdb's idea of their current values.
2092 fetch_inferior_registers (regno
)
2095 if (ioctl (pi
.fd
, PIOCGREG
, &pi
.gregset
) != -1)
2097 supply_gregset (&pi
.gregset
);
2099 #if defined (FP0_REGNUM)
2100 if (ioctl (pi
.fd
, PIOCGFPREG
, &pi
.fpregset
) != -1)
2102 supply_fpregset (&pi
.fpregset
);
2111 fetch_core_registers -- fetch current registers from core file data
2115 void fetch_core_registers (char *core_reg_sect, unsigned core_reg_size,
2116 int which, unsigned in reg_addr)
2120 Read the values of either the general register set (WHICH equals 0)
2121 or the floating point register set (WHICH equals 2) from the core
2122 file data (pointed to by CORE_REG_SECT), and update gdb's idea of
2123 their current values. The CORE_REG_SIZE parameter is ignored.
2127 Use the indicated sizes to validate the gregset and fpregset
2132 fetch_core_registers (core_reg_sect
, core_reg_size
, which
, reg_addr
)
2133 char *core_reg_sect
;
2134 unsigned core_reg_size
;
2136 unsigned int reg_addr
; /* Unused in this version */
2141 if (core_reg_size
!= sizeof (pi
.gregset
))
2143 warning ("wrong size gregset struct in core file");
2147 (void) memcpy ((char *) &pi
.gregset
, core_reg_sect
,
2148 sizeof (pi
.gregset
));
2149 supply_gregset (&pi
.gregset
);
2152 else if (which
== 2)
2154 if (core_reg_size
!= sizeof (pi
.fpregset
))
2156 warning ("wrong size fpregset struct in core file");
2160 (void) memcpy ((char *) &pi
.fpregset
, core_reg_sect
,
2161 sizeof (pi
.fpregset
));
2162 #if defined (FP0_REGNUM)
2163 supply_fpregset (&pi
.fpregset
);
2173 proc_init_failed - called whenever /proc access initialization fails
2177 static void proc_init_failed (char *why)
2181 This function is called whenever initialization of access to a /proc
2182 entry fails. It prints a suitable error message, does some cleanup,
2183 and then invokes the standard error processing routine which dumps
2184 us back into the command loop.
2188 proc_init_failed (why
)
2191 print_sys_errmsg (pi
.pathname
, errno
);
2192 (void) kill (pi
.pid
, SIGKILL
);
2193 close_proc_file (&pi
);
2202 close_proc_file - close any currently open /proc entry
2206 static void close_proc_file (struct procinfo *pip)
2210 Close any currently open /proc entry and mark the process information
2211 entry as invalid. In order to ensure that we don't try to reuse any
2212 stale information, the pid, fd, and pathnames are explicitly
2213 invalidated, which may be overkill.
2218 close_proc_file (pip
)
2219 struct procinfo
*pip
;
2224 (void) close (pip
-> fd
);
2227 if (pip
-> pathname
)
2229 free (pip
-> pathname
);
2230 pip
-> pathname
= NULL
;
2239 open_proc_file - open a /proc entry for a given process id
2243 static int open_proc_file (pid, struct procinfo *pip)
2247 Given a process id, close the existing open /proc entry (if any)
2248 and open one for the new process id. Once it is open, then
2249 mark the local process information structure as valid, which
2250 guarantees that the pid, fd, and pathname fields match an open
2251 /proc entry. Returns zero if the open fails, nonzero otherwise.
2253 Note that the pathname is left intact, even when the open fails,
2254 so that callers can use it to construct meaningful error messages
2255 rather than just "file open failed".
2259 open_proc_file (pid
, pip
)
2261 struct procinfo
*pip
;
2266 (void) close (pip
-> fd
);
2268 if (pip
-> pathname
== NULL
)
2270 pip
-> pathname
= xmalloc (32);
2272 sprintf (pip
-> pathname
, PROC_NAME_FMT
, pid
);
2273 if ((pip
-> fd
= open (pip
-> pathname
, O_RDWR
)) >= 0)
2278 return (pip
-> valid
);
2282 mappingflags (flags
)
2285 static char asciiflags
[8];
2287 strcpy (asciiflags
, "-------");
2288 #if defined (MA_PHYS)
2289 if (flags
& MA_PHYS
) asciiflags
[0] = 'd';
2291 if (flags
& MA_STACK
) asciiflags
[1] = 's';
2292 if (flags
& MA_BREAK
) asciiflags
[2] = 'b';
2293 if (flags
& MA_SHARED
) asciiflags
[3] = 's';
2294 if (flags
& MA_READ
) asciiflags
[4] = 'r';
2295 if (flags
& MA_WRITE
) asciiflags
[5] = 'w';
2296 if (flags
& MA_EXEC
) asciiflags
[6] = 'x';
2297 return (asciiflags
);
2301 info_proc_flags (pip
, summary
)
2302 struct procinfo
*pip
;
2305 struct trans
*transp
;
2307 printf_filtered ("%-32s", "Process status flags:");
2310 printf_filtered ("\n\n");
2312 for (transp
= pr_flag_table
; transp
-> name
!= NULL
; transp
++)
2314 if (pip
-> prstatus
.pr_flags
& transp
-> value
)
2318 printf_filtered ("%s ", transp
-> name
);
2322 printf_filtered ("\t%-16s %s.\n", transp
-> name
, transp
-> desc
);
2326 printf_filtered ("\n");
2330 info_proc_stop (pip
, summary
)
2331 struct procinfo
*pip
;
2334 struct trans
*transp
;
2338 why
= pip
-> prstatus
.pr_why
;
2339 what
= pip
-> prstatus
.pr_what
;
2341 if (pip
-> prstatus
.pr_flags
& PR_STOPPED
)
2343 printf_filtered ("%-32s", "Reason for stopping:");
2346 printf_filtered ("\n\n");
2348 for (transp
= pr_why_table
; transp
-> name
!= NULL
; transp
++)
2350 if (why
== transp
-> value
)
2354 printf_filtered ("%s ", transp
-> name
);
2358 printf_filtered ("\t%-16s %s.\n",
2359 transp
-> name
, transp
-> desc
);
2365 /* Use the pr_why field to determine what the pr_what field means, and
2366 print more information. */
2371 /* pr_what is unused for this case */
2377 printf_filtered ("%s ", signalname (what
));
2381 printf_filtered ("\t%-16s %s.\n", signalname (what
),
2382 safe_strsignal (what
));
2388 printf_filtered ("%s ", syscallname (what
));
2392 printf_filtered ("\t%-16s %s.\n", syscallname (what
),
2393 "Entered this system call");
2399 printf_filtered ("%s ", syscallname (what
));
2403 printf_filtered ("\t%-16s %s.\n", syscallname (what
),
2404 "Returned from this system call");
2410 printf_filtered ("%s ",
2411 lookupname (faults_table
, what
, "fault"));
2415 printf_filtered ("\t%-16s %s.\n",
2416 lookupname (faults_table
, what
, "fault"),
2417 lookupdesc (faults_table
, what
));
2421 printf_filtered ("\n");
2426 info_proc_siginfo (pip
, summary
)
2427 struct procinfo
*pip
;
2430 struct siginfo
*sip
;
2432 if ((pip
-> prstatus
.pr_flags
& PR_STOPPED
) &&
2433 (pip
-> prstatus
.pr_why
== PR_SIGNALLED
||
2434 pip
-> prstatus
.pr_why
== PR_FAULTED
))
2436 printf_filtered ("%-32s", "Additional signal/fault info:");
2437 sip
= &pip
-> prstatus
.pr_info
;
2440 printf_filtered ("%s ", signalname (sip
-> si_signo
));
2441 if (sip
-> si_errno
> 0)
2443 printf_filtered ("%s ", errnoname (sip
-> si_errno
));
2445 if (sip
-> si_code
<= 0)
2447 printf_filtered ("sent by pid %d, uid %d ", sip
-> si_pid
,
2452 printf_filtered ("%s ", sigcodename (sip
));
2453 if ((sip
-> si_signo
== SIGILL
) ||
2454 (sip
-> si_signo
== SIGFPE
) ||
2455 (sip
-> si_signo
== SIGSEGV
) ||
2456 (sip
-> si_signo
== SIGBUS
))
2458 printf_filtered ("addr=%#x ", sip
-> si_addr
);
2460 else if ((sip
-> si_signo
== SIGCHLD
))
2462 printf_filtered ("child pid %u, status %u ",
2466 else if ((sip
-> si_signo
== SIGPOLL
))
2468 printf_filtered ("band %u ", sip
-> si_band
);
2474 printf_filtered ("\n\n");
2475 printf_filtered ("\t%-16s %s.\n", signalname (sip
-> si_signo
),
2476 safe_strsignal (sip
-> si_signo
));
2477 if (sip
-> si_errno
> 0)
2479 printf_filtered ("\t%-16s %s.\n",
2480 errnoname (sip
-> si_errno
),
2481 safe_strerror (sip
-> si_errno
));
2483 if (sip
-> si_code
<= 0)
2485 printf_filtered ("\t%-16u %s\n", sip
-> si_pid
,
2486 "PID of process sending signal");
2487 printf_filtered ("\t%-16u %s\n", sip
-> si_uid
,
2488 "UID of process sending signal");
2492 printf_filtered ("\t%-16s %s.\n", sigcodename (sip
),
2494 if ((sip
-> si_signo
== SIGILL
) ||
2495 (sip
-> si_signo
== SIGFPE
))
2497 printf_filtered ("\t%-16#x %s.\n", sip
-> si_addr
,
2498 "Address of faulting instruction");
2500 else if ((sip
-> si_signo
== SIGSEGV
) ||
2501 (sip
-> si_signo
== SIGBUS
))
2503 printf_filtered ("\t%-16#x %s.\n", sip
-> si_addr
,
2504 "Address of faulting memory reference");
2506 else if ((sip
-> si_signo
== SIGCHLD
))
2508 printf_filtered ("\t%-16u %s.\n", sip
-> si_pid
,
2509 "Child process ID");
2510 printf_filtered ("\t%-16u %s.\n", sip
-> si_status
,
2511 "Child process exit value or signal");
2513 else if ((sip
-> si_signo
== SIGPOLL
))
2515 printf_filtered ("\t%-16u %s.\n", sip
-> si_band
,
2516 "Band event for POLL_{IN,OUT,MSG}");
2520 printf_filtered ("\n");
2525 info_proc_syscalls (pip
, summary
)
2526 struct procinfo
*pip
;
2534 #if 0 /* FIXME: Needs to use gdb-wide configured info about system calls. */
2535 if (pip
-> prstatus
.pr_flags
& PR_ASLEEP
)
2537 int syscallnum
= pip
-> prstatus
.pr_reg
[R_D0
];
2540 printf_filtered ("%-32s", "Sleeping in system call:");
2541 printf_filtered ("%s", syscallname (syscallnum
));
2545 printf_filtered ("Sleeping in system call '%s'.\n",
2546 syscallname (syscallnum
));
2551 if (ioctl (pip
-> fd
, PIOCGENTRY
, &pip
-> entryset
) < 0)
2553 print_sys_errmsg (pip
-> pathname
, errno
);
2554 error ("PIOCGENTRY failed");
2557 if (ioctl (pip
-> fd
, PIOCGEXIT
, &pip
-> exitset
) < 0)
2559 print_sys_errmsg (pip
-> pathname
, errno
);
2560 error ("PIOCGEXIT failed");
2563 printf_filtered ("System call tracing information:\n\n");
2565 printf_filtered ("\t%-12s %-8s %-8s\n",
2569 for (syscallnum
= 0; syscallnum
< MAX_SYSCALLS
; syscallnum
++)
2572 if (syscall_table
[syscallnum
] != NULL
)
2574 printf_filtered ("\t%-12s ", syscall_table
[syscallnum
]);
2575 printf_filtered ("%-8s ",
2576 prismember (&pip
-> entryset
, syscallnum
)
2578 printf_filtered ("%-8s ",
2579 prismember (&pip
-> exitset
, syscallnum
)
2581 printf_filtered ("\n");
2584 printf_filtered ("\n");
2593 static char locbuf
[32];
2595 name
= strsigno (signo
);
2598 sprintf (locbuf
, "Signal %d", signo
);
2602 sprintf (locbuf
, "%s (%d)", name
, signo
);
2612 static char locbuf
[32];
2614 name
= strerrno (errnum
);
2617 sprintf (locbuf
, "Errno %d", errnum
);
2621 sprintf (locbuf
, "%s (%d)", name
, errnum
);
2627 info_proc_signals (pip
, summary
)
2628 struct procinfo
*pip
;
2635 if (ioctl (pip
-> fd
, PIOCGTRACE
, &pip
-> trace
) < 0)
2637 print_sys_errmsg (pip
-> pathname
, errno
);
2638 error ("PIOCGTRACE failed");
2641 printf_filtered ("Disposition of signals:\n\n");
2642 printf_filtered ("\t%-15s %-8s %-8s %-8s %s\n\n",
2643 "Signal", "Trace", "Hold", "Pending", "Description");
2644 for (signo
= 0; signo
< NSIG
; signo
++)
2647 printf_filtered ("\t%-15s ", signalname (signo
));
2648 printf_filtered ("%-8s ",
2649 prismember (&pip
-> trace
, signo
)
2651 printf_filtered ("%-8s ",
2652 prismember (&pip
-> prstatus
.pr_sighold
, signo
)
2654 printf_filtered ("%-8s ",
2655 prismember (&pip
-> prstatus
.pr_sigpend
, signo
)
2657 printf_filtered (" %s\n", safe_strsignal (signo
));
2659 printf_filtered ("\n");
2664 info_proc_faults (pip
, summary
)
2665 struct procinfo
*pip
;
2668 struct trans
*transp
;
2672 if (ioctl (pip
-> fd
, PIOCGFAULT
, &pip
-> fltset
) < 0)
2674 print_sys_errmsg (pip
-> pathname
, errno
);
2675 error ("PIOCGFAULT failed");
2678 printf_filtered ("Current traced hardware fault set:\n\n");
2679 printf_filtered ("\t%-12s %-8s\n", "Fault", "Trace");
2681 for (transp
= faults_table
; transp
-> name
!= NULL
; transp
++)
2684 printf_filtered ("\t%-12s ", transp
-> name
);
2685 printf_filtered ("%-8s", prismember (&pip
-> fltset
, transp
-> value
)
2687 printf_filtered ("\n");
2689 printf_filtered ("\n");
2694 info_proc_mappings (pip
, summary
)
2695 struct procinfo
*pip
;
2699 struct prmap
*prmaps
;
2700 struct prmap
*prmap
;
2704 printf_filtered ("Mapped address spaces:\n\n");
2705 printf_filtered ("\t%10s %10s %10s %10s %7s\n",
2711 if (ioctl (pip
-> fd
, PIOCNMAP
, &nmap
) == 0)
2713 prmaps
= (struct prmap
*) alloca ((nmap
+ 1) * sizeof (*prmaps
));
2714 if (ioctl (pip
-> fd
, PIOCMAP
, prmaps
) == 0)
2716 for (prmap
= prmaps
; prmap
-> pr_size
; ++prmap
)
2718 printf_filtered ("\t%#10x %#10x %#10x %#10x %7s\n",
2720 prmap
-> pr_vaddr
+ prmap
-> pr_size
- 1,
2723 mappingflags (prmap
-> pr_mflags
));
2727 printf_filtered ("\n");
2735 info_proc -- implement the "info proc" command
2739 void info_proc (char *args, int from_tty)
2743 Implement gdb's "info proc" command by using the /proc interface
2744 to print status information about any currently running process.
2746 Examples of the use of "info proc" are:
2748 info proc (prints summary info for current inferior)
2749 info proc 123 (prints summary info for process with pid 123)
2750 info proc mappings (prints address mappings)
2751 info proc times (prints process/children times)
2752 info proc id (prints pid, ppid, gid, sid, etc)
2753 info proc status (prints general process state info)
2754 info proc signals (prints info about signal handling)
2755 info proc all (prints all info)
2760 info_proc (args
, from_tty
)
2765 struct procinfo pii
;
2766 struct procinfo
*pip
;
2767 struct cleanup
*old_chain
;
2781 old_chain
= make_cleanup (null_cleanup
, 0);
2783 /* Default to using the current inferior if no pid specified */
2789 if ((argv
= buildargv (args
)) == NULL
)
2793 make_cleanup (freeargv
, (char *) argv
);
2795 while (*argv
!= NULL
)
2797 argsize
= strlen (*argv
);
2798 if (argsize
>= 1 && strncmp (*argv
, "all", argsize
) == 0)
2803 else if (argsize
>= 2 && strncmp (*argv
, "faults", argsize
) == 0)
2808 else if (argsize
>= 2 && strncmp (*argv
, "flags", argsize
) == 0)
2813 else if (argsize
>= 1 && strncmp (*argv
, "id", argsize
) == 0)
2818 else if (argsize
>= 1 && strncmp (*argv
, "mappings", argsize
) == 0)
2823 else if (argsize
>= 2 && strncmp (*argv
, "signals", argsize
) == 0)
2828 else if (argsize
>= 2 && strncmp (*argv
, "status", argsize
) == 0)
2833 else if (argsize
>= 2 && strncmp (*argv
, "syscalls", argsize
) == 0)
2838 else if (argsize
>= 1 && strncmp (*argv
, "times", argsize
) == 0)
2843 else if ((pii
.pid
= atoi (*argv
)) > 0)
2847 (void) memset (&pii
, 0, sizeof (pii
));
2848 if (!open_proc_file (pid
, pip
))
2850 perror_with_name (pip
-> pathname
);
2853 make_cleanup (close_proc_file
, pip
);
2855 else if (**argv
!= '\000')
2857 error ("Unrecognized or ambiguous keyword `%s'.", *argv
);
2863 /* If we don't have a valid open process at this point, then we have no
2864 inferior or didn't specify a specific pid. */
2868 error ("No process. Run an inferior or specify an explicit pid.");
2870 if (ioctl (pip
-> fd
, PIOCSTATUS
, &(pip
-> prstatus
)) < 0)
2872 print_sys_errmsg (pip
-> pathname
, errno
);
2873 error ("PIOCSTATUS failed");
2876 /* Print verbose information of the requested type(s), or just a summary
2877 of the information for all types. */
2879 printf_filtered ("\nInformation for %s:\n\n", pip
-> pathname
);
2880 if (summary
|| all
|| flags
)
2882 info_proc_flags (pip
, summary
);
2886 info_proc_stop (pip
, summary
);
2888 if (summary
|| all
|| signals
|| faults
)
2890 info_proc_siginfo (pip
, summary
);
2892 if (summary
|| all
|| syscalls
)
2894 info_proc_syscalls (pip
, summary
);
2896 if (summary
|| all
|| mappings
)
2898 info_proc_mappings (pip
, summary
);
2900 if (summary
|| all
|| signals
)
2902 info_proc_signals (pip
, summary
);
2904 if (summary
|| all
|| faults
)
2906 info_proc_faults (pip
, summary
);
2908 printf_filtered ("\n");
2910 /* All done, deal with closing any temporary process info structure,
2911 freeing temporary memory , etc. */
2913 do_cleanups (old_chain
);
2920 _initialize_proc_fs -- initialize the process file system stuff
2924 void _initialize_proc_fs (void)
2928 Do required initializations during gdb startup for using the
2929 /proc file system interface.
2933 static char *proc_desc
=
2934 "Show process status information using /proc entry.\n\
2935 Specify process id or use current inferior by default.\n\
2936 Specify keywords for detailed information; default is summary.\n\
2937 Keywords are: `all', `faults', `flags', `id', `mappings', `signals',\n\
2938 `status', `syscalls', and `times'.\n\
2939 Unambiguous abbreviations may be used.";
2942 _initialize_proc_fs ()
2944 add_info ("proc", info_proc
, proc_desc
);
2945 init_syscall_table ();
2948 #endif /* USE_PROC_FS */