1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
|
/* i386 specific core note handling.
Copyright (C) 2002 Red Hat, Inc.
Written by Ulrich Drepper <drepper@redhat.com>, 2002.
This program is Open Source software; you can redistribute it and/or
modify it under the terms of the Open Software License version 1.0 as
published by the Open Source Initiative.
You should have received a copy of the Open Software License along
with this program; if not, you may obtain a copy of the Open Software
License version 1.0 from http://www.opensource.org/licenses/osl.php or
by writing the Open Source Initiative c/o Lawrence Rosen, Esq.,
3001 King Ranch Road, Ukiah, CA 95482. */
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <elf.h>
#include <stddef.h>
#include <stdio.h>
#include <sys/time.h>
#include <libebl_i386.h>
/* We cannot include <sys/procfs.h> since it is available only on x86
systems. */
struct elf_prstatus
{
struct
{
int si_signo; /* Signal number. */
int si_code; /* Extra code. */
int si_errno; /* Errno. */
} pr_info; /* Info associated with signal. */
short int pr_cursig; /* Current signal. */
unsigned long int pr_sigpend; /* Set of pending signals. */
unsigned long int pr_sighold; /* Set of held signals. */
__pid_t pr_pid;
__pid_t pr_ppid;
__pid_t pr_pgrp;
__pid_t pr_sid;
struct timeval pr_utime; /* User time. */
struct timeval pr_stime; /* System time. */
struct timeval pr_cutime; /* Cumulative user time. */
struct timeval pr_cstime; /* Cumulative system time. */
unsigned long int pr_reg[17]; /* GP registers. */
int pr_fpvalid; /* True if math copro being used. */
};
struct elf_prpsinfo
{
char pr_state; /* Numeric process state. */
char pr_sname; /* Char for pr_state. */
char pr_zomb; /* Zombie. */
char pr_nice; /* Nice val. */
unsigned long int pr_flag; /* Flags. */
unsigned short int pr_uid;
unsigned short int pr_gid;
int pr_pid;
int pr_ppid;
int pr_pgrp;
int pr_sid;
/* Lots missing */
char pr_fname[16]; /* Filename of executable. */
char pr_psargs[80]; /* Initial part of arg list. */
};
bool
i386_core_note (name, type, descsz, desc)
const char *name;
uint32_t type;
uint32_t descsz;
const char *desc;
{
bool result = false;
switch (type)
{
case NT_PRSTATUS:
if (descsz < sizeof (struct elf_prstatus))
/* Not enough data. */
break;
struct elf_prstatus *stat = (struct elf_prstatus *) desc;
printf (" SIGINFO: signo: %d, code = %d, errno = %d\n"
" signal: %hd, pending: %#08lx, holding: %#08lx\n"
" pid: %d, ppid = %d, pgrp = %d, sid = %d\n"
" utime: %6ld.%06lds, stime: %6ld.%06lds\n"
" cutime: %6ld.%06lds, cstime: %6ld.%06lds\n"
" eax: %08lx ebx: %08lx ecx: %08lx edx: %08lx\n"
" esi: %08lx edi: %08lx ebp: %08lx esp: %08lx\n"
" eip: %08lx eflags: %08lx, original eax: %08lx\n"
" cs: %04lx ds: %04lx es: %04lx fs: %04lx gs: %04lx"
" ss: %04lx\n\n"
,
stat->pr_info. si_signo,
stat->pr_info. si_code,
stat->pr_info. si_errno,
stat->pr_cursig,
stat->pr_sigpend, stat->pr_sighold,
stat->pr_pid, stat->pr_ppid, stat->pr_pgrp, stat->pr_sid,
stat->pr_utime.tv_sec, (long int) stat->pr_utime.tv_usec,
stat->pr_stime.tv_sec, (long int) stat->pr_stime.tv_usec,
stat->pr_cutime.tv_sec, (long int) stat->pr_cutime.tv_usec,
stat->pr_cstime.tv_sec, (long int) stat->pr_cstime.tv_usec,
stat->pr_reg[6], stat->pr_reg[0], stat->pr_reg[1],
stat->pr_reg[2], stat->pr_reg[3], stat->pr_reg[4],
stat->pr_reg[5], stat->pr_reg[15], stat->pr_reg[12],
stat->pr_reg[14], stat->pr_reg[11], stat->pr_reg[13] & 0xffff,
stat->pr_reg[7] & 0xffff, stat->pr_reg[8] & 0xffff,
stat->pr_reg[9] & 0xffff, stat->pr_reg[10] & 0xffff,
stat->pr_reg[16]);
/* We handled this entry. */
result = true;
break;
case NT_PRPSINFO:
if (descsz < sizeof (struct elf_prpsinfo))
/* Not enough data. */
break;
struct elf_prpsinfo *info = (struct elf_prpsinfo *) desc;
printf (" state: %c (%hhd), zombie: %hhd, nice: %hhd\n"
" flags: %08lx, uid: %hd, gid: %hd\n"
" pid: %d, ppid: %d, pgrp: %d, sid: %d\n"
" fname: %.16s\n"
" args: %.80s\n\n",
info->pr_sname, info->pr_state, info->pr_zomb, info->pr_nice,
info->pr_flag, info->pr_uid, info->pr_gid,
info->pr_pid, info->pr_ppid, info->pr_pgrp, info->pr_sid,
info->pr_fname, info->pr_psargs);
/* We handled this entry. */
result = true;
break;
default:
break;
}
return result;
}
|