xref: /netbsd-src/external/gpl3/gdb.old/dist/gdb/proc-utils.h (revision 8b657b0747480f8989760d71343d6dd33f8d4cf9)
1 /* Machine independent support for SVR4 /proc (process file system) for GDB.
2    Copyright (C) 1999-2023 Free Software Foundation, Inc.
3 
4    This file is part of GDB.
5 
6    This program is free software; you can redistribute it and/or modify
7    it under the terms of the GNU General Public License as published by
8    the Free Software Foundation; either version 3 of the License, or
9    (at your option) any later version.
10 
11    This program is distributed in the hope that it will be useful,
12    but WITHOUT ANY WARRANTY; without even the implied warranty of
13    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14    GNU General Public License for more details.
15 
16    You should have received a copy of the GNU General Public License
17    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
18 
19 #ifndef PROC_UTILS_H
20 #define PROC_UTILS_H
21 
22 /* From proc-why.c */
23 
24 /*
25  * Pretty-print functions for /proc data
26  */
27 
28 extern void proc_prettyprint_why (unsigned long why, unsigned long what,
29 				  int verbose);
30 
31 extern void proc_prettyprint_syscalls (sysset_t *sysset, int verbose);
32 
33 extern void proc_prettyprint_syscall (int num, int verbose);
34 
35 extern void proc_prettyprint_signalset (sigset_t *sigset, int verbose);
36 
37 extern void proc_prettyprint_signal (int signo, int verbose);
38 
39 extern void proc_prettyprint_faultset (fltset_t *fltset, int verbose);
40 
41 extern void proc_prettyprint_fault (int faultno, int verbose);
42 
43 extern void proc_prettyprint_actionset (struct sigaction *actions,
44 					int verbose);
45 
46 extern void proc_prettyfprint_signalset (FILE *file, sigset_t *sigset,
47 					 int verbose);
48 
49 extern void proc_prettyfprint_faultset (FILE *file, fltset_t *fltset,
50 					int verbose);
51 
52 extern void proc_prettyfprint_syscall (FILE *file, int num, int verbose);
53 
54 extern void proc_prettyfprint_signal (FILE *file, int signo, int verbose);
55 
56 extern void proc_prettyfprint_flags (FILE *file, unsigned long flags,
57 				     int verbose);
58 
59 extern void proc_prettyfprint_why (FILE *file, unsigned long why,
60 				   unsigned long what, int verbose);
61 
62 extern void proc_prettyfprint_fault (FILE *file, int faultno, int verbose);
63 
64 extern void proc_prettyfprint_syscalls (FILE *file, sysset_t *sysset,
65 					int verbose);
66 
67 extern void proc_prettyfprint_status (long, int, int, int);
68 
69 
70 /* From proc-flags.c */
71 
72 /*
73  * Pretty-print the prstatus flags.
74  */
75 
76 extern void proc_prettyprint_flags (unsigned long flags, int verbose);
77 
78 extern void proc_prettyfprint_flags (FILE *file, unsigned long flags,
79 				     int verbose);
80 
81 
82 /* From proc-api.c */
83 
84 /*
85  * Trace functions for /proc api.
86  */
87 
88 extern  int   write_with_trace (int, void *, size_t, char *, int);
89 extern  off_t lseek_with_trace (int, off_t,  int,    char *, int);
90 extern  int   ioctl_with_trace (int, long, void *, char *, int);
91 extern  pid_t wait_with_trace  (int *, char *, int);
92 extern  int   open_with_trace  (char *, int, char *, int);
93 extern  int   close_with_trace (int, char *, int);
94 extern  void  procfs_note      (const char *, const char *, int);
95 
96 #ifdef PROCFS_TRACE
97 /*
98  * Debugging code:
99  *
100  * These macros allow me to trace the system calls that we make
101  * to control the child process.  This is quite handy for comparing
102  * with the older version of procfs.
103  */
104 
105 #define write(X,Y,Z)   write_with_trace (X, Y, Z, __FILE__, __LINE__)
106 #define lseek(X,Y,Z)   lseek_with_trace (X, Y, Z, __FILE__, __LINE__)
107 #define ioctl(X,Y,Z)   ioctl_with_trace (X, Y, Z, __FILE__, __LINE__)
108 #define open(X,Y)      open_with_trace  (X, Y,    __FILE__, __LINE__)
109 #define close(X)       close_with_trace (X,       __FILE__, __LINE__)
110 #define wait(X)        wait_with_trace  (X,       __FILE__, __LINE__)
111 #endif
112 #define PROCFS_NOTE(X) procfs_note      (X,       __FILE__, __LINE__)
113 #define PROC_PRETTYFPRINT_STATUS(X,Y,Z,T) \
114      proc_prettyfprint_status (X, Y, Z, T)
115 
116 /* Define the type (and more importantly the width) of the control
117    word used to write to the /proc/PID/ctl file.  */
118 typedef long procfs_ctl_t;
119 
120 #endif /* PROC_UTILS_H */
121