| 1 |
/* Copyright (C) 2006-2020 Free Software Foundation, Inc. |
| 2 |
This file is part of the GNU C Library. |
| 3 |
|
| 4 |
The GNU C Library is free software; you can redistribute it and/or |
| 5 |
modify it under the terms of the GNU Lesser General Public |
| 6 |
License as published by the Free Software Foundation; either |
| 7 |
version 2.1 of the License, or (at your option) any later version. |
| 8 |
|
| 9 |
The GNU C Library is distributed in the hope that it will be useful, |
| 10 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 12 |
Lesser General Public License for more details. |
| 13 |
|
| 14 |
You should have received a copy of the GNU General Public License |
| 15 |
along with this program; if not, write to the Free Software |
| 16 |
Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, |
| 17 |
MA 02110-1301, USA. */ |
| 18 |
|
| 19 |
/* This is somewhat modelled after the file of the same name on SVR4 |
| 20 |
systems. It provides a definition of the core file format for ELF |
| 21 |
used on Linux. It doesn't have anything to do with the /proc file |
| 22 |
system, even though Linux has one. |
| 23 |
|
| 24 |
Anyway, the whole purpose of this file is for GDB and GDB only. |
| 25 |
Don't read too much into it. Don't use it for anything other than |
| 26 |
GDB unless you know what you are doing. */ |
| 27 |
|
| 28 |
#include <features.h> |
| 29 |
#include <sys/time.h> |
| 30 |
#include <sys/types.h> |
| 31 |
|
| 32 |
/* We define here only the symbols differing from their 64-bit variant. */ |
| 33 |
#include <sys/procfs.h> |
| 34 |
|
| 35 |
#ifdef HAVE_STDINT_H |
| 36 |
#include <stdint.h> |
| 37 |
#else |
| 38 |
typedef unsigned int uint32_t; |
| 39 |
typedef unsigned long long int uint64_t; |
| 40 |
#endif |
| 41 |
|
| 42 |
/* Unsigned 64-bit integer aligned to 8 bytes. */ |
| 43 |
typedef uint64_t __attribute__ ((__aligned__ (8))) a8_uint64_t; |
| 44 |
|
| 45 |
#undef HAVE_PRPSINFO32_T |
| 46 |
#define HAVE_PRPSINFO32_T |
| 47 |
#undef HAVE_PRPSINFO32_T_PR_PID |
| 48 |
#define HAVE_PRPSINFO32_T_PR_PID |
| 49 |
|
| 50 |
#undef HAVE_PRSTATUS32_T |
| 51 |
#define HAVE_PRSTATUS32_T |
| 52 |
|
| 53 |
/* These are the 32-bit x86 structures. */ |
| 54 |
|
| 55 |
struct user_regs32_struct |
| 56 |
{ |
| 57 |
int32_t ebx; |
| 58 |
int32_t ecx; |
| 59 |
int32_t edx; |
| 60 |
int32_t esi; |
| 61 |
int32_t edi; |
| 62 |
int32_t ebp; |
| 63 |
int32_t eax; |
| 64 |
int32_t xds; |
| 65 |
int32_t xes; |
| 66 |
int32_t xfs; |
| 67 |
int32_t xgs; |
| 68 |
int32_t orig_eax; |
| 69 |
int32_t eip; |
| 70 |
int32_t xcs; |
| 71 |
int32_t eflags; |
| 72 |
int32_t esp; |
| 73 |
int32_t xss; |
| 74 |
}; |
| 75 |
|
| 76 |
struct user_regs64_struct |
| 77 |
{ |
| 78 |
a8_uint64_t r15; |
| 79 |
a8_uint64_t r14; |
| 80 |
a8_uint64_t r13; |
| 81 |
a8_uint64_t r12; |
| 82 |
a8_uint64_t rbp; |
| 83 |
a8_uint64_t rbx; |
| 84 |
a8_uint64_t r11; |
| 85 |
a8_uint64_t r10; |
| 86 |
a8_uint64_t r9; |
| 87 |
a8_uint64_t r8; |
| 88 |
a8_uint64_t rax; |
| 89 |
a8_uint64_t rcx; |
| 90 |
a8_uint64_t rdx; |
| 91 |
a8_uint64_t rsi; |
| 92 |
a8_uint64_t rdi; |
| 93 |
a8_uint64_t orig_rax; |
| 94 |
a8_uint64_t rip; |
| 95 |
a8_uint64_t cs; |
| 96 |
a8_uint64_t eflags; |
| 97 |
a8_uint64_t rsp; |
| 98 |
a8_uint64_t ss; |
| 99 |
a8_uint64_t fs_base; |
| 100 |
a8_uint64_t gs_base; |
| 101 |
a8_uint64_t ds; |
| 102 |
a8_uint64_t es; |
| 103 |
a8_uint64_t fs; |
| 104 |
a8_uint64_t gs; |
| 105 |
}; |
| 106 |
|
| 107 |
/* Type for a general-purpose register. */ |
| 108 |
typedef uint32_t elf_greg32_t; |
| 109 |
typedef a8_uint64_t elf_greg64_t; |
| 110 |
|
| 111 |
/* And the whole bunch of them. We could have used `struct |
| 112 |
user_regs_struct' directly in the typedef, but tradition says that |
| 113 |
the register set is an array, which does have some peculiar |
| 114 |
semantics, so leave it that way. */ |
| 115 |
#define ELF_NGREG32 (sizeof (struct user_regs32_struct) / sizeof(elf_greg32_t)) |
| 116 |
typedef elf_greg32_t elf_gregset32_t[ELF_NGREG32]; |
| 117 |
#define ELF_NGREG64 (sizeof (struct user_regs64_struct) / sizeof(elf_greg64_t)) |
| 118 |
typedef elf_greg64_t elf_gregset64_t[ELF_NGREG64]; |
| 119 |
|
| 120 |
/* Definitions to generate Intel SVR4-like core files. These mostly |
| 121 |
have the same names as the SVR4 types with "elf_" tacked on the |
| 122 |
front to prevent clashes with Linux definitions, and the typedef |
| 123 |
forms have been avoided. This is mostly like the SVR4 structure, |
| 124 |
but more Linuxy, with things that Linux does not support and which |
| 125 |
GDB doesn't really use excluded. */ |
| 126 |
|
| 127 |
struct prstatus32_timeval |
| 128 |
{ |
| 129 |
int tv_sec; |
| 130 |
int tv_usec; |
| 131 |
}; |
| 132 |
|
| 133 |
struct prstatus64_timeval |
| 134 |
{ |
| 135 |
a8_uint64_t tv_sec; |
| 136 |
a8_uint64_t tv_usec; |
| 137 |
}; |
| 138 |
|
| 139 |
struct elf_prstatus32 |
| 140 |
{ |
| 141 |
struct elf_siginfo pr_info; /* Info associated with signal. */ |
| 142 |
short int pr_cursig; /* Current signal. */ |
| 143 |
unsigned int pr_sigpend; /* Set of pending signals. */ |
| 144 |
unsigned int pr_sighold; /* Set of held signals. */ |
| 145 |
pid_t pr_pid; |
| 146 |
pid_t pr_ppid; |
| 147 |
pid_t pr_pgrp; |
| 148 |
pid_t pr_sid; |
| 149 |
struct prstatus32_timeval pr_utime; /* User time. */ |
| 150 |
struct prstatus32_timeval pr_stime; /* System time. */ |
| 151 |
struct prstatus32_timeval pr_cutime; /* Cumulative user time. */ |
| 152 |
struct prstatus32_timeval pr_cstime; /* Cumulative system time. */ |
| 153 |
elf_gregset32_t pr_reg; /* GP registers. */ |
| 154 |
int pr_fpvalid; /* True if math copro being used. */ |
| 155 |
}; |
| 156 |
|
| 157 |
struct elf_prstatusx32 |
| 158 |
{ |
| 159 |
struct elf_siginfo pr_info; /* Info associated with signal. */ |
| 160 |
short int pr_cursig; /* Current signal. */ |
| 161 |
unsigned int pr_sigpend; /* Set of pending signals. */ |
| 162 |
unsigned int pr_sighold; /* Set of held signals. */ |
| 163 |
pid_t pr_pid; |
| 164 |
pid_t pr_ppid; |
| 165 |
pid_t pr_pgrp; |
| 166 |
pid_t pr_sid; |
| 167 |
struct prstatus32_timeval pr_utime; /* User time. */ |
| 168 |
struct prstatus32_timeval pr_stime; /* System time. */ |
| 169 |
struct prstatus32_timeval pr_cutime; /* Cumulative user time. */ |
| 170 |
struct prstatus32_timeval pr_cstime; /* Cumulative system time. */ |
| 171 |
elf_gregset64_t pr_reg; /* GP registers. */ |
| 172 |
int pr_fpvalid; /* True if math copro being used. */ |
| 173 |
}; |
| 174 |
|
| 175 |
struct elf_prstatus64 |
| 176 |
{ |
| 177 |
struct elf_siginfo pr_info; /* Info associated with signal. */ |
| 178 |
short int pr_cursig; /* Current signal. */ |
| 179 |
a8_uint64_t pr_sigpend; /* Set of pending signals. */ |
| 180 |
a8_uint64_t pr_sighold; /* Set of held signals. */ |
| 181 |
pid_t pr_pid; |
| 182 |
pid_t pr_ppid; |
| 183 |
pid_t pr_pgrp; |
| 184 |
pid_t pr_sid; |
| 185 |
struct prstatus64_timeval pr_utime; /* User time. */ |
| 186 |
struct prstatus64_timeval pr_stime; /* System time. */ |
| 187 |
struct prstatus64_timeval pr_cutime; /* Cumulative user time. */ |
| 188 |
struct prstatus64_timeval pr_cstime; /* Cumulative system time. */ |
| 189 |
elf_gregset64_t pr_reg; /* GP registers. */ |
| 190 |
int pr_fpvalid; /* True if math copro being used. */ |
| 191 |
}; |
| 192 |
|
| 193 |
struct elf_prpsinfo32 |
| 194 |
{ |
| 195 |
char pr_state; /* Numeric process state. */ |
| 196 |
char pr_sname; /* Char for pr_state. */ |
| 197 |
char pr_zomb; /* Zombie. */ |
| 198 |
char pr_nice; /* Nice val. */ |
| 199 |
unsigned int pr_flag; /* Flags. */ |
| 200 |
unsigned short int pr_uid; |
| 201 |
unsigned short int pr_gid; |
| 202 |
int pr_pid, pr_ppid, pr_pgrp, pr_sid; |
| 203 |
/* Lots missing */ |
| 204 |
char pr_fname[16]; /* Filename of executable. */ |
| 205 |
char pr_psargs[ELF_PRARGSZ]; /* Initial part of arg list. */ |
| 206 |
}; |
| 207 |
|
| 208 |
struct elf_prpsinfo64 |
| 209 |
{ |
| 210 |
char pr_state; /* Numeric process state. */ |
| 211 |
char pr_sname; /* Char for pr_state. */ |
| 212 |
char pr_zomb; /* Zombie. */ |
| 213 |
char pr_nice; /* Nice val. */ |
| 214 |
a8_uint64_t pr_flag; /* Flags. */ |
| 215 |
unsigned int pr_uid; |
| 216 |
unsigned int pr_gid; |
| 217 |
int pr_pid, pr_ppid, pr_pgrp, pr_sid; |
| 218 |
/* Lots missing */ |
| 219 |
char pr_fname[16]; /* Filename of executable. */ |
| 220 |
char pr_psargs[ELF_PRARGSZ]; /* Initial part of arg list. */ |
| 221 |
}; |
| 222 |
|
| 223 |
/* The rest of this file provides the types for emulation of the |
| 224 |
Solaris <proc_service.h> interfaces that should be implemented by |
| 225 |
users of libthread_db. */ |
| 226 |
|
| 227 |
/* Process status and info. In the end we do provide typedefs for them. */ |
| 228 |
typedef struct elf_prstatus32 prstatus32_t; |
| 229 |
typedef struct elf_prstatusx32 prstatusx32_t; |
| 230 |
typedef struct elf_prstatus64 prstatus64_t; |
| 231 |
typedef struct elf_prpsinfo32 prpsinfo32_t; |
| 232 |
typedef struct elf_prpsinfo64 prpsinfo64_t; |