xref: /freebsd/sys/sys/procfs.h (revision 95ee2897e98f5d444f26ed2334cc7c439f9c16c6)
18c64af4fSJohn Polstra /*-
2*4d846d26SWarner Losh  * SPDX-License-Identifier: BSD-2-Clause
3c4e20cadSPedro F. Giffuni  *
48c64af4fSJohn Polstra  * Copyright (c) 1998 John D. Polstra.
58c64af4fSJohn Polstra  * All rights reserved.
68c64af4fSJohn Polstra  *
78c64af4fSJohn Polstra  * Redistribution and use in source and binary forms, with or without
88c64af4fSJohn Polstra  * modification, are permitted provided that the following conditions
98c64af4fSJohn Polstra  * are met:
108c64af4fSJohn Polstra  * 1. Redistributions of source code must retain the above copyright
118c64af4fSJohn Polstra  *    notice, this list of conditions and the following disclaimer.
128c64af4fSJohn Polstra  * 2. Redistributions in binary form must reproduce the above copyright
138c64af4fSJohn Polstra  *    notice, this list of conditions and the following disclaimer in the
148c64af4fSJohn Polstra  *    documentation and/or other materials provided with the distribution.
158c64af4fSJohn Polstra  *
168c64af4fSJohn Polstra  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
178c64af4fSJohn Polstra  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
188c64af4fSJohn Polstra  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
198c64af4fSJohn Polstra  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
208c64af4fSJohn Polstra  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
218c64af4fSJohn Polstra  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
228c64af4fSJohn Polstra  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
238c64af4fSJohn Polstra  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
248c64af4fSJohn Polstra  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
258c64af4fSJohn Polstra  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
268c64af4fSJohn Polstra  * SUCH DAMAGE.
278c64af4fSJohn Polstra  */
288c64af4fSJohn Polstra 
298c64af4fSJohn Polstra #ifndef _SYS_PROCFS_H_
308c64af4fSJohn Polstra #define _SYS_PROCFS_H_
318c64af4fSJohn Polstra 
328c64af4fSJohn Polstra #include <sys/param.h>
338c64af4fSJohn Polstra #include <machine/reg.h>
348c64af4fSJohn Polstra 
358c64af4fSJohn Polstra typedef struct reg gregset_t;
368c64af4fSJohn Polstra typedef struct fpreg fpregset_t;
378c64af4fSJohn Polstra 
388c64af4fSJohn Polstra /*
398c64af4fSJohn Polstra  * These structures define an interface between core files and the debugger.
408c64af4fSJohn Polstra  * Never change or delete any elements.  If you add elements, add them to
418c64af4fSJohn Polstra  * the end of the structure, and increment the value of its version field.
428c64af4fSJohn Polstra  * This will help to ensure that today's core dump will still be usable
438c64af4fSJohn Polstra  * with next year's debugger.
448c64af4fSJohn Polstra  *
458c64af4fSJohn Polstra  * A lot more things should be added to these structures.  At present,
468c64af4fSJohn Polstra  * they contain the absolute bare minimum required to allow GDB to work
478c64af4fSJohn Polstra  * with ELF core dumps.
488c64af4fSJohn Polstra  */
498c64af4fSJohn Polstra 
508c64af4fSJohn Polstra /*
518c64af4fSJohn Polstra  * The parenthsized numbers like (1) indicate the minimum version number
52ccb83afdSJohn Baldwin  * for which each element exists in the structure.  The version number is
53ccb83afdSJohn Baldwin  * not bumped when adding new fields to the end, only if the meaning of
54ccb83afdSJohn Baldwin  * an existing field changes.  Additional fields are annotated as (1a),
55ccb83afdSJohn Baldwin  * (1b), etc. to indicate the groupings of additions.
568c64af4fSJohn Polstra  */
578c64af4fSJohn Polstra 
588c64af4fSJohn Polstra #define PRSTATUS_VERSION	1	/* Current version of prstatus_t */
598c64af4fSJohn Polstra 
608c64af4fSJohn Polstra typedef struct prstatus {
618c64af4fSJohn Polstra     int		pr_version;	/* Version number of struct (1) */
628c64af4fSJohn Polstra     size_t	pr_statussz;	/* sizeof(prstatus_t) (1) */
638c64af4fSJohn Polstra     size_t	pr_gregsetsz;	/* sizeof(gregset_t) (1) */
648c64af4fSJohn Polstra     size_t	pr_fpregsetsz;	/* sizeof(fpregset_t) (1) */
658c64af4fSJohn Polstra     int		pr_osreldate;	/* Kernel version (1) */
668c64af4fSJohn Polstra     int		pr_cursig;	/* Current signal (1) */
67ccb83afdSJohn Baldwin     pid_t	pr_pid;		/* LWP (Thread) ID (1) */
688c64af4fSJohn Polstra     gregset_t	pr_reg;		/* General purpose registers (1) */
698c64af4fSJohn Polstra } prstatus_t;
708c64af4fSJohn Polstra 
71b8732336SDavid Xu typedef gregset_t prgregset_t[1];
728c64af4fSJohn Polstra typedef fpregset_t prfpregset_t;
738c64af4fSJohn Polstra 
746eef6816SPeter Wemm #define PRFNAMESZ	16	/* Maximum command length saved */
758c64af4fSJohn Polstra #define PRARGSZ		80	/* Maximum argument bytes saved */
768c64af4fSJohn Polstra 
778c64af4fSJohn Polstra #define PRPSINFO_VERSION	1	/* Current version of prpsinfo_t */
788c64af4fSJohn Polstra 
798c64af4fSJohn Polstra typedef struct prpsinfo {
808c64af4fSJohn Polstra     int		pr_version;	/* Version number of struct (1) */
818c64af4fSJohn Polstra     size_t	pr_psinfosz;	/* sizeof(prpsinfo_t) (1) */
826eef6816SPeter Wemm     char	pr_fname[PRFNAMESZ+1];	/* Command name, null terminated (1) */
838c64af4fSJohn Polstra     char	pr_psargs[PRARGSZ+1];	/* Arguments, null terminated (1) */
84ccb83afdSJohn Baldwin     pid_t	pr_pid;		/* Process ID (1a) */
858c64af4fSJohn Polstra } prpsinfo_t;
868c64af4fSJohn Polstra 
877f08176eSAttilio Rao typedef struct thrmisc {
887f08176eSAttilio Rao     char	pr_tname[MAXCOMLEN+1];	/* Thread name, null terminated (1) */
897f08176eSAttilio Rao     u_int	_pad;			/* Convenience pad, 0-filled (1) */
907f08176eSAttilio Rao } thrmisc_t;
917f08176eSAttilio Rao 
9293898f2bSMarcel Moolenaar typedef uint64_t psaddr_t;	/* An address in the target process. */
93cfdb160eSMarcel Moolenaar 
94dbee5c67SJohn Baldwin #ifdef __HAVE_REG32
95dbee5c67SJohn Baldwin typedef struct prstatus32 {
96dbee5c67SJohn Baldwin 	int32_t	pr_version;
97dbee5c67SJohn Baldwin 	uint32_t pr_statussz;
98dbee5c67SJohn Baldwin 	uint32_t pr_gregsetsz;
99dbee5c67SJohn Baldwin 	uint32_t pr_fpregsetsz;
100dbee5c67SJohn Baldwin 	int32_t	pr_osreldate;
101dbee5c67SJohn Baldwin 	int32_t	pr_cursig;
102dbee5c67SJohn Baldwin 	int32_t	pr_pid;
103dbee5c67SJohn Baldwin 	struct reg32 pr_reg;
104dbee5c67SJohn Baldwin } prstatus32_t;
105dbee5c67SJohn Baldwin 
106dbee5c67SJohn Baldwin typedef struct prpsinfo32 {
107dbee5c67SJohn Baldwin 	int32_t	pr_version;
108dbee5c67SJohn Baldwin 	uint32_t pr_psinfosz;
109dbee5c67SJohn Baldwin 	char	pr_fname[PRFNAMESZ+1];
110dbee5c67SJohn Baldwin 	char	pr_psargs[PRARGSZ+1];
111ccb83afdSJohn Baldwin 	int32_t	pr_pid;
112dbee5c67SJohn Baldwin } prpsinfo32_t;
113dbee5c67SJohn Baldwin 
114dbee5c67SJohn Baldwin struct thrmisc32 {
115dbee5c67SJohn Baldwin 	char	pr_tname[MAXCOMLEN+1];
116dbee5c67SJohn Baldwin 	uint32_t _pad;
117dbee5c67SJohn Baldwin };
118dbee5c67SJohn Baldwin #endif /* __HAVE_REG32 */
119dbee5c67SJohn Baldwin 
1208c64af4fSJohn Polstra #endif /* _SYS_PROCFS_H_ */
121