198944Sobrien/* Machine independent support for SVR4 /proc (process file system) for GDB. 298944Sobrien Copyright 1999, 2000 Free Software Foundation, Inc. 398944Sobrien 498944SobrienThis file is part of GDB. 598944Sobrien 698944SobrienThis program is free software; you can redistribute it and/or modify 798944Sobrienit under the terms of the GNU General Public License as published by 898944Sobrienthe Free Software Foundation; either version 2 of the License, or 998944Sobrien(at your option) any later version. 1098944Sobrien 1198944SobrienThis program is distributed in the hope that it will be useful, 1298944Sobrienbut WITHOUT ANY WARRANTY; without even the implied warranty of 1398944SobrienMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1498944SobrienGNU General Public License for more details. 1598944Sobrien 1698944SobrienYou should have received a copy of the GNU General Public License 1798944Sobrienalong with this program; if not, write to the Free Software Foundation, 1898944SobrienInc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ 1998944Sobrien 2098944Sobrien 2198944Sobrien/* 2298944Sobrien * Pretty-print functions for /proc data 2398944Sobrien */ 2498944Sobrien 25130803Smarcelextern void proc_prettyprint_why (unsigned long why, unsigned long what, 26130803Smarcel int verbose); 2798944Sobrien 28130803Smarcelextern void proc_prettyprint_syscalls (sysset_t *sysset, int verbose); 2998944Sobrien 30130803Smarcelextern void proc_prettyprint_syscall (int num, int verbose); 3198944Sobrien 3298944Sobrienextern void proc_prettyprint_flags (unsigned long flags, int verbose); 3398944Sobrien 34130803Smarcelextern void proc_prettyfprint_signalset (FILE *file, sigset_t *sigset, 35130803Smarcel int verbose); 3698944Sobrien 37130803Smarcelextern void proc_prettyfprint_faultset (FILE *file, fltset_t *fltset, 38130803Smarcel int verbose); 3998944Sobrien 40130803Smarcelextern void proc_prettyfprint_syscall (FILE *file, int num, int verbose); 4198944Sobrien 42130803Smarcelextern void proc_prettyfprint_signal (FILE *file, int signo, int verbose); 4398944Sobrien 44130803Smarcelextern void proc_prettyfprint_flags (FILE *file, unsigned long flags, 45130803Smarcel int verbose); 4698944Sobrien 47130803Smarcelextern void proc_prettyfprint_why (FILE *file, unsigned long why, 48130803Smarcel unsigned long what, int verbose); 4998944Sobrien 50130803Smarcelextern void proc_prettyfprint_fault (FILE *file, int faultno, int verbose); 5198944Sobrien 52130803Smarcelextern void proc_prettyfprint_syscalls (FILE *file, sysset_t *sysset, 53130803Smarcel int verbose); 5498944Sobrien 55130803Smarcelextern void proc_prettyfprint_status (long, int, int, int); 5698944Sobrien 5798944Sobrien/* 5898944Sobrien * Trace functions for /proc api. 5998944Sobrien */ 6098944Sobrien 6198944Sobrienextern int write_with_trace (int, void *, size_t, char *, int); 6298944Sobrienextern off_t lseek_with_trace (int, off_t, int, char *, int); 6398944Sobrienextern int ioctl_with_trace (int, long, void *, char *, int); 6498944Sobrienextern pid_t wait_with_trace (int *, char *, int); 6598944Sobrienextern int open_with_trace (char *, int, char *, int); 6698944Sobrienextern int close_with_trace (int, char *, int); 6798944Sobrienextern void procfs_note (char *, char *, int); 6898944Sobrien 6998944Sobrien#ifdef PROCFS_TRACE 7098944Sobrien/* 7198944Sobrien * Debugging code: 7298944Sobrien * 7398944Sobrien * These macros allow me to trace the system calls that we make 7498944Sobrien * to control the child process. This is quite handy for comparing 7598944Sobrien * with the older version of procfs. 7698944Sobrien */ 7798944Sobrien 7898944Sobrien#define write(X,Y,Z) write_with_trace (X, Y, Z, __FILE__, __LINE__) 7998944Sobrien#define lseek(X,Y,Z) lseek_with_trace (X, Y, Z, __FILE__, __LINE__) 8098944Sobrien#define ioctl(X,Y,Z) ioctl_with_trace (X, Y, Z, __FILE__, __LINE__) 8198944Sobrien#define open(X,Y) open_with_trace (X, Y, __FILE__, __LINE__) 8298944Sobrien#define close(X) close_with_trace (X, __FILE__, __LINE__) 8398944Sobrien#define wait(X) wait_with_trace (X, __FILE__, __LINE__) 8498944Sobrien#endif 8598944Sobrien#define PROCFS_NOTE(X) procfs_note (X, __FILE__, __LINE__) 8698944Sobrien#define PROC_PRETTYFPRINT_STATUS(X,Y,Z,T) \ 8798944Sobrien proc_prettyfprint_status (X, Y, Z, T) 8898944Sobrien 8998944Sobrien/* Define the type (and more importantly the width) of the control 9098944Sobrien word used to write to the /proc/PID/ctl file. */ 9198944Sobrien#if defined (PROC_CTL_WORD_TYPE) 9298944Sobrientypedef PROC_CTL_WORD_TYPE procfs_ctl_t; 9398944Sobrien#else 9498944Sobrientypedef long procfs_ctl_t; 9598944Sobrien#endif 96