1 /* Common core note type descriptions for Linux.
2 Copyright (C) 2007-2010 Red Hat, Inc.
3 This file is part of Red Hat elfutils.
5 Red Hat elfutils is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by the
7 Free Software Foundation; version 2 of the License.
9 Red Hat elfutils is distributed in the hope that it will be useful, but
10 WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 General Public License for more details.
14 You should have received a copy of the GNU General Public License along
15 with Red Hat elfutils; if not, write to the Free Software Foundation,
16 Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA.
18 Red Hat elfutils is an included package of the Open Invention Network.
19 An included package of the Open Invention Network is a package for which
20 Open Invention Network licensees cross-license their patents. No patent
21 license is granted, either expressly or impliedly, by designation as an
22 included package. Should you wish to participate in the Open Invention
23 Network licensing program, please visit www.openinventionnetwork.com
24 <http://www.openinventionnetwork.com>. */
28 /* The including CPU_corenote.c file provides prstatus_regs and
29 defines macros ULONG, [PUG]ID_T, and ALIGN_*, TYPE_*.
31 Here we describe the common layout used in <linux/elfcore.h>. */
35 #define TYPE_CHAR ELF_T_BYTE
36 #define SHORT uint16_t
38 #define TYPE_SHORT ELF_T_HALF
41 #define TYPE_INT ELF_T_SWORD
43 #define FIELD(type, name) type name __attribute__ ((aligned (ALIGN_##type)))
45 struct EBLHOOK(siginfo)
47 FIELD (INT, si_signo);
49 FIELD (INT, si_errno);
52 struct EBLHOOK(timeval)
54 FIELD (ULONG, tv_sec);
55 FIELD (ULONG, tv_usec);
58 /* On sparc64, tv_usec (suseconds_t) is actually 32 bits with 32 bits padding.
59 The 'T'|0x80 value for .format indicates this as a special kludge. */
61 # define TIMEVAL_FIELD(name) FIELD (time, ULONG, name, 'T'|0x80, .count = 2)
63 # define TIMEVAL_FIELD(name) FIELD (time, ULONG, name, 'T', .count = 2)
67 struct EBLHOOK(prstatus)
69 struct EBLHOOK(siginfo) pr_info;
70 FIELD (SHORT, pr_cursig);
71 FIELD (ULONG, pr_sigpend);
72 FIELD (ULONG, pr_sighold);
73 FIELD (PID_T, pr_pid);
74 FIELD (PID_T, pr_ppid);
75 FIELD (PID_T, pr_pgrp);
76 FIELD (PID_T, pr_sid);
77 struct EBLHOOK(timeval) pr_utime;
78 struct EBLHOOK(timeval) pr_stime;
79 struct EBLHOOK(timeval) pr_cutime;
80 struct EBLHOOK(timeval) pr_cstime;
81 FIELD (ULONG, pr_reg[PRSTATUS_REGS_SIZE / sizeof (ULONG)]);
82 FIELD (INT, pr_fpvalid);
88 struct EBLHOOK(prpsinfo)
90 FIELD (CHAR, pr_state);
91 FIELD (CHAR, pr_sname);
92 FIELD (CHAR, pr_zomb);
93 FIELD (CHAR, pr_nice);
94 FIELD (ULONG, pr_flag);
95 FIELD (UID_T, pr_uid);
96 FIELD (GID_T, pr_gid);
97 FIELD (PID_T, pr_pid);
98 FIELD (PID_T, pr_ppid);
99 FIELD (PID_T, pr_pgrp);
100 FIELD (PID_T, pr_sid);
101 FIELD (CHAR, pr_fname[FNAMESZ]);
102 FIELD (CHAR, pr_psargs[PRARGSZ]);
107 #define FIELD(igroup, itype, item, fmt, ...) \
111 .offset = offsetof (struct EBLHOOK(prstatus), pr_##item), \
112 .type = TYPE_##itype, \
117 static const Ebl_Core_Item prstatus_items[] =
119 FIELD (signal, INT, info.si_signo, 'd'),
120 FIELD (signal, INT, info.si_code, 'd'),
121 FIELD (signal, INT, info.si_errno, 'd'),
122 FIELD (signal, SHORT, cursig, 'd'),
123 FIELD (signal, ULONG, sigpend, 'B'),
124 FIELD (signal, ULONG, sighold, 'B'),
125 FIELD (identity, PID_T, pid, 'd', .thread_identifier = true),
126 FIELD (identity, PID_T, ppid, 'd'),
127 FIELD (identity, PID_T, pgrp, 'd'),
128 FIELD (identity, PID_T, sid, 'd'),
129 TIMEVAL_FIELD (utime),
130 TIMEVAL_FIELD (stime),
131 TIMEVAL_FIELD (cutime),
132 TIMEVAL_FIELD (cstime),
133 #ifdef PRSTATUS_REGSET_ITEMS
134 PRSTATUS_REGSET_ITEMS,
136 FIELD (register, INT, fpvalid, 'd'),
141 #define FIELD(igroup, itype, item, fmt, ...) \
145 .offset = offsetof (struct EBLHOOK(prpsinfo), pr_##item), \
146 .type = TYPE_##itype, \
151 static const Ebl_Core_Item prpsinfo_items[] =
153 FIELD (state, CHAR, state, 'd'),
154 FIELD (state, CHAR, sname, 'c'),
155 FIELD (state, CHAR, zomb, 'd'),
156 FIELD (state, CHAR, nice, 'd'),
157 FIELD (state, ULONG, flag, 'x'),
158 FIELD (identity, UID_T, uid, 'd'),
159 FIELD (identity, GID_T, gid, 'd'),
160 FIELD (identity, PID_T, pid, 'd'),
161 FIELD (identity, PID_T, ppid, 'd'),
162 FIELD (identity, PID_T, pgrp, 'd'),
163 FIELD (identity, PID_T, sid, 'd'),
164 FIELD (command, CHAR, fname, 's', .count = FNAMESZ),
165 FIELD (command, CHAR, psargs, 's', .count = PRARGSZ),
168 static const Ebl_Core_Item vmcoreinfo_items[] =
171 .type = ELF_T_BYTE, .format = '\n'
178 EBLHOOK(core_note) (nhdr, name, regs_offset, nregloc, reglocs, nitems, items)
179 const GElf_Nhdr *nhdr;
181 GElf_Word *regs_offset;
183 const Ebl_Register_Location **reglocs;
185 const Ebl_Core_Item **items;
187 switch (nhdr->n_namesz)
189 case sizeof "CORE" - 1: /* Buggy old Linux kernels. */
190 if (memcmp (name, "CORE", nhdr->n_namesz) == 0)
195 if (memcmp (name, "CORE", nhdr->n_namesz) == 0)
197 /* Buggy old Linux kernels didn't terminate "LINUX".
201 if (memcmp (name, "LINUX", nhdr->n_namesz) == 0)
205 case sizeof "VMCOREINFO":
206 if (nhdr->n_type != 0
207 || memcmp (name, "VMCOREINFO", sizeof "VMCOREINFO") != 0)
212 *items = vmcoreinfo_items;
219 switch (nhdr->n_type)
222 if (nhdr->n_descsz != sizeof (struct EBLHOOK(prstatus)))
224 *regs_offset = offsetof (struct EBLHOOK(prstatus), pr_reg);
225 *nregloc = sizeof prstatus_regs / sizeof prstatus_regs[0];
226 *reglocs = prstatus_regs;
227 *nitems = sizeof prstatus_items / sizeof prstatus_items[0];
228 *items = prstatus_items;
232 if (nhdr->n_descsz != sizeof (struct EBLHOOK(prpsinfo)))
237 *nitems = sizeof prpsinfo_items / sizeof prpsinfo_items[0];
238 *items = prpsinfo_items;
241 #define EXTRA_REGSET(type, size, table) \
243 if (nhdr->n_descsz != size) \
246 *nregloc = sizeof table / sizeof table[0]; \
253 EXTRA_REGSET (NT_FPREGSET, FPREGSET_SIZE, fpregset_regs)