2
* Copyright (c) 1991, 1992 Paul Kranenburg <pk@cs.few.eur.nl>
3
* Copyright (c) 1993 Branko Lankester <branko@hacktic.nl>
4
* Copyright (c) 1993, 1994, 1995, 1996 Rick Sladkey <jrs@world.std.com>
5
* Copyright (c) 1996-1999 Wichert Akkerman <wichert@cistron.nl>
8
* Redistribution and use in source and binary forms, with or without
9
* modification, are permitted provided that the following conditions
11
* 1. Redistributions of source code must retain the above copyright
12
* notice, this list of conditions and the following disclaimer.
13
* 2. Redistributions in binary form must reproduce the above copyright
14
* notice, this list of conditions and the following disclaimer in the
15
* documentation and/or other materials provided with the distribution.
16
* 3. The name of the author may not be used to endorse or promote products
17
* derived from this software without specific prior written permission.
19
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
20
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
21
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
22
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
23
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
24
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
28
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
40
#include <sys/resource.h>
41
#include <sys/utsname.h>
43
#include <sys/syscall.h>
46
/* Bits of module.flags. */
48
#define MOD_UNINITIALIZED 0
51
#define MOD_AUTOCLEAN 4
53
#define MOD_USED_ONCE 16
54
#define MOD_JUST_FREED 32
55
#define MOD_INITIALIZING 64
57
/* Values for query_module's which. */
79
static const struct xlat which[] = {
81
{ QM_MODULES, "QM_MODULES" },
82
{ QM_DEPS, "QM_DEPS" },
83
{ QM_REFS, "QM_REFS" },
84
{ QM_SYMBOLS, "QM_SYMBOLS" },
85
{ QM_INFO, "QM_INFO" },
89
static const struct xlat modflags[] = {
90
{ MOD_UNINITIALIZED, "MOD_UNINITIALIZED" },
91
{ MOD_RUNNING, "MOD_RUNNING" },
92
{ MOD_DELETED, "MOD_DELETED" },
93
{ MOD_AUTOCLEAN, "MOD_AUTOCLEAN" },
94
{ MOD_VISITED, "MOD_VISITED" },
95
{ MOD_USED_ONCE, "MOD_USED_ONCE" },
96
{ MOD_JUST_FREED, "MOD_JUST_FREED" },
101
sys_query_module(struct tcb *tcp)
104
printstr(tcp, tcp->u_arg[0], -1);
106
printxval(which, tcp->u_arg[1], "QM_???");
111
if (!verbose(tcp) || syserror(tcp) ||
112
umove(tcp, tcp->u_arg[4], &ret) < 0) {
113
tprintf("%#lx, %lu, %#lx", tcp->u_arg[2],
114
tcp->u_arg[3], tcp->u_arg[4]);
115
} else if (tcp->u_arg[1]==QM_INFO) {
116
struct module_info mi;
117
if (umove(tcp, tcp->u_arg[2], &mi) < 0) {
118
tprintf("%#lx, ", tcp->u_arg[2]);
120
tprintf("{address=%#lx, size=%lu, flags=",
122
printflags(modflags, mi.flags, "MOD_???");
123
tprintf(", usecount=%lu}, ", mi.usecount);
126
} else if ((tcp->u_arg[1]==QM_MODULES) ||
127
(tcp->u_arg[1]==QM_DEPS) ||
128
(tcp->u_arg[1]==QM_REFS)) {
131
char* data = malloc(tcp->u_arg[3]);
136
fprintf(stderr, "out of memory\n");
137
tprintf(" /* %Zu entries */ ", ret);
139
if (umoven(tcp, tcp->u_arg[2],
140
tcp->u_arg[3], data) < 0) {
141
tprintf(" /* %Zu entries */ ", ret);
143
for (idx=0; idx<ret; idx++) {
147
mod += strlen(mod)+1;
153
tprintf(" /* %Zu entries */ ", ret);
154
tprintf("}, %Zu", ret);
155
} else if (tcp->u_arg[1]==QM_SYMBOLS) {
158
char* data = malloc(tcp->u_arg[3]);
159
struct module_symbol* sym = (struct module_symbol*)data;
163
fprintf(stderr, "out of memory\n");
164
tprintf(" /* %Zu entries */ ", ret);
166
if (umoven(tcp, tcp->u_arg[2],
167
tcp->u_arg[3], data) < 0) {
168
tprintf(" /* %Zu entries */ ", ret);
170
for (idx=0; idx<ret; idx++) {
171
tprintf("%s{name=%s, value=%lu}",
173
data+(long)sym->name,
181
tprintf(" /* %Zu entries */ ", ret);
182
tprintf("}, %Zd", ret);
184
printstr(tcp, tcp->u_arg[2], tcp->u_arg[3]);
185
tprintf(", %#lx", tcp->u_arg[4]);
192
sys_create_module(tcp)
196
printpath(tcp, tcp->u_arg[0]);
197
tprintf(", %lu", tcp->u_arg[1]);
207
tprintf("%#lx, ", tcp->u_arg[0]);
208
tprintf("%lu, ", tcp->u_arg[1]);
209
printstr(tcp, tcp->u_arg[2], -1);