1a9643ea8Slogwang /*- 2*22ce4affSfengbojiang * SPDX-License-Identifier: BSD-2-Clause-FreeBSD 3*22ce4affSfengbojiang * 4a9643ea8Slogwang * Copyright (c) 1998 John D. Polstra. 5a9643ea8Slogwang * All rights reserved. 6a9643ea8Slogwang * 7a9643ea8Slogwang * Redistribution and use in source and binary forms, with or without 8a9643ea8Slogwang * modification, are permitted provided that the following conditions 9a9643ea8Slogwang * are met: 10a9643ea8Slogwang * 1. Redistributions of source code must retain the above copyright 11a9643ea8Slogwang * notice, this list of conditions and the following disclaimer. 12a9643ea8Slogwang * 2. Redistributions in binary form must reproduce the above copyright 13a9643ea8Slogwang * notice, this list of conditions and the following disclaimer in the 14a9643ea8Slogwang * documentation and/or other materials provided with the distribution. 15a9643ea8Slogwang * 16a9643ea8Slogwang * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 17a9643ea8Slogwang * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18a9643ea8Slogwang * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19a9643ea8Slogwang * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 20a9643ea8Slogwang * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21a9643ea8Slogwang * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22a9643ea8Slogwang * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23a9643ea8Slogwang * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24a9643ea8Slogwang * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25a9643ea8Slogwang * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26a9643ea8Slogwang * SUCH DAMAGE. 27a9643ea8Slogwang * 28a9643ea8Slogwang * $FreeBSD$ 29a9643ea8Slogwang */ 30a9643ea8Slogwang 31a9643ea8Slogwang #ifndef _SYS_PROCFS_H_ 32a9643ea8Slogwang #define _SYS_PROCFS_H_ 33a9643ea8Slogwang 34a9643ea8Slogwang #include <sys/param.h> 35a9643ea8Slogwang #include <machine/reg.h> 36a9643ea8Slogwang 37a9643ea8Slogwang typedef struct reg gregset_t; 38a9643ea8Slogwang typedef struct fpreg fpregset_t; 39a9643ea8Slogwang 40a9643ea8Slogwang /* 41a9643ea8Slogwang * These structures define an interface between core files and the debugger. 42a9643ea8Slogwang * Never change or delete any elements. If you add elements, add them to 43a9643ea8Slogwang * the end of the structure, and increment the value of its version field. 44a9643ea8Slogwang * This will help to ensure that today's core dump will still be usable 45a9643ea8Slogwang * with next year's debugger. 46a9643ea8Slogwang * 47a9643ea8Slogwang * A lot more things should be added to these structures. At present, 48a9643ea8Slogwang * they contain the absolute bare minimum required to allow GDB to work 49a9643ea8Slogwang * with ELF core dumps. 50a9643ea8Slogwang */ 51a9643ea8Slogwang 52a9643ea8Slogwang /* 53a9643ea8Slogwang * The parenthsized numbers like (1) indicate the minimum version number 54*22ce4affSfengbojiang * for which each element exists in the structure. The version number is 55*22ce4affSfengbojiang * not bumped when adding new fields to the end, only if the meaning of 56*22ce4affSfengbojiang * an existing field changes. Additional fields are annotated as (1a), 57*22ce4affSfengbojiang * (1b), etc. to indicate the groupings of additions. 58a9643ea8Slogwang */ 59a9643ea8Slogwang 60a9643ea8Slogwang #define PRSTATUS_VERSION 1 /* Current version of prstatus_t */ 61a9643ea8Slogwang 62a9643ea8Slogwang typedef struct prstatus { 63a9643ea8Slogwang int pr_version; /* Version number of struct (1) */ 64a9643ea8Slogwang size_t pr_statussz; /* sizeof(prstatus_t) (1) */ 65a9643ea8Slogwang size_t pr_gregsetsz; /* sizeof(gregset_t) (1) */ 66a9643ea8Slogwang size_t pr_fpregsetsz; /* sizeof(fpregset_t) (1) */ 67a9643ea8Slogwang int pr_osreldate; /* Kernel version (1) */ 68a9643ea8Slogwang int pr_cursig; /* Current signal (1) */ 69*22ce4affSfengbojiang pid_t pr_pid; /* LWP (Thread) ID (1) */ 70a9643ea8Slogwang gregset_t pr_reg; /* General purpose registers (1) */ 71a9643ea8Slogwang } prstatus_t; 72a9643ea8Slogwang 73a9643ea8Slogwang typedef gregset_t prgregset_t[1]; 74a9643ea8Slogwang typedef fpregset_t prfpregset_t; 75a9643ea8Slogwang 76a9643ea8Slogwang #define PRFNAMESZ 16 /* Maximum command length saved */ 77a9643ea8Slogwang #define PRARGSZ 80 /* Maximum argument bytes saved */ 78a9643ea8Slogwang 79a9643ea8Slogwang #define PRPSINFO_VERSION 1 /* Current version of prpsinfo_t */ 80a9643ea8Slogwang 81a9643ea8Slogwang typedef struct prpsinfo { 82a9643ea8Slogwang int pr_version; /* Version number of struct (1) */ 83a9643ea8Slogwang size_t pr_psinfosz; /* sizeof(prpsinfo_t) (1) */ 84a9643ea8Slogwang char pr_fname[PRFNAMESZ+1]; /* Command name, null terminated (1) */ 85a9643ea8Slogwang char pr_psargs[PRARGSZ+1]; /* Arguments, null terminated (1) */ 86*22ce4affSfengbojiang pid_t pr_pid; /* Process ID (1a) */ 87a9643ea8Slogwang } prpsinfo_t; 88a9643ea8Slogwang 89a9643ea8Slogwang typedef struct thrmisc { 90a9643ea8Slogwang char pr_tname[MAXCOMLEN+1]; /* Thread name, null terminated (1) */ 91a9643ea8Slogwang u_int _pad; /* Convenience pad, 0-filled (1) */ 92a9643ea8Slogwang } thrmisc_t; 93a9643ea8Slogwang 94a9643ea8Slogwang typedef uint64_t psaddr_t; /* An address in the target process. */ 95a9643ea8Slogwang 96a9643ea8Slogwang #ifdef __HAVE_REG32 97a9643ea8Slogwang typedef struct prstatus32 { 98a9643ea8Slogwang int32_t pr_version; 99a9643ea8Slogwang uint32_t pr_statussz; 100a9643ea8Slogwang uint32_t pr_gregsetsz; 101a9643ea8Slogwang uint32_t pr_fpregsetsz; 102a9643ea8Slogwang int32_t pr_osreldate; 103a9643ea8Slogwang int32_t pr_cursig; 104a9643ea8Slogwang int32_t pr_pid; 105a9643ea8Slogwang struct reg32 pr_reg; 106a9643ea8Slogwang } prstatus32_t; 107a9643ea8Slogwang 108a9643ea8Slogwang typedef struct prpsinfo32 { 109a9643ea8Slogwang int32_t pr_version; 110a9643ea8Slogwang uint32_t pr_psinfosz; 111a9643ea8Slogwang char pr_fname[PRFNAMESZ+1]; 112a9643ea8Slogwang char pr_psargs[PRARGSZ+1]; 113*22ce4affSfengbojiang int32_t pr_pid; 114a9643ea8Slogwang } prpsinfo32_t; 115a9643ea8Slogwang 116a9643ea8Slogwang struct thrmisc32 { 117a9643ea8Slogwang char pr_tname[MAXCOMLEN+1]; 118a9643ea8Slogwang uint32_t _pad; 119a9643ea8Slogwang }; 120a9643ea8Slogwang #endif /* __HAVE_REG32 */ 121a9643ea8Slogwang 122a9643ea8Slogwang #endif /* _SYS_PROCFS_H_ */ 123