aboutsummaryrefslogtreecommitdiff
path: root/sys/contrib/ia64/libuwx/src.diff
blob: 7f5c84944ee2fd9e333bb327f9c20f2ff6d8d9dc (plain) (blame)
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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
Only in /sys/contrib/ia64/libuwx/src: CVS
diff -u ./uwx.h /sys/contrib/ia64/libuwx/src/uwx.h
--- ./uwx.h	Tue Apr 27 10:42:48 2004
+++ /sys/contrib/ia64/libuwx/src/uwx.h	Thu May  6 18:10:15 2004
@@ -25,8 +25,13 @@
 #ifndef __UWX_INCLUDED
 #define __UWX_INCLUDED 1
 
+#ifndef _KERNEL
 #include <stdlib.h>
 #include <inttypes.h>
+#else
+#include <sys/param.h>
+#include <sys/systm.h>
+#endif
 
 #if defined(__cplusplus)
 #define __EXTERN_C extern "C"
diff -u ./uwx_bstream.c /sys/contrib/ia64/libuwx/src/uwx_bstream.c
--- ./uwx_bstream.c	Tue Apr 27 10:42:52 2004
+++ /sys/contrib/ia64/libuwx/src/uwx_bstream.c	Thu May  6 18:12:11 2004
@@ -64,8 +64,6 @@
     int len;
     int n;
     int b;
-    uint32_t *wp;
-    uint64_t *dp;
 
     if (bstream->peekc >= 0) {
 	b = bstream->peekc;
@@ -131,6 +129,7 @@
     return 0;
 }
 
+#if 0
 int uwx_get_uleb128_alt(struct uwx_bstream *bstream, uint64_t *valp)
 {
     uint64_t val;
@@ -179,3 +178,4 @@
     *valp = val;
     return 0;
 }
+#endif
diff -u ./uwx_context.c /sys/contrib/ia64/libuwx/src/uwx_context.c
--- ./uwx_context.c	Tue Apr 27 10:42:52 2004
+++ /sys/contrib/ia64/libuwx/src/uwx_context.c	Thu May  6 19:04:36 2004
@@ -200,7 +200,6 @@
     int sor;
     int rrb_gr;
     uint64_t bsp;
-    int n;
 
     if (env == 0)
 	return UWX_ERR_NOENV;
@@ -274,7 +273,6 @@
 
 int uwx_set_fr(struct uwx_env *env, int regid, uint64_t *val)
 {
-    int status;
 
     if (regid >= UWX_REG_FR(2) && regid <= UWX_REG_FR(5))
 	regid -= UWX_REG_FR(2);
@@ -340,6 +338,7 @@
     return bsp + nslots * DWORDSZ;
 }
 
+#if 0
 int uwx_selftest_bsp_arithmetic()
 {
     int i;
@@ -398,3 +397,4 @@
 
     return failed;
 }
+#endif
diff -u ./uwx_env.c /sys/contrib/ia64/libuwx/src/uwx_env.c
--- ./uwx_env.c	Tue Apr 27 10:42:53 2004
+++ /sys/contrib/ia64/libuwx/src/uwx_env.c	Thu May  6 21:31:55 2004
@@ -22,13 +22,21 @@
 OTHER DEALINGS IN THE SOFTWARE.
 */
 
+#ifndef _KERNEL
 #include <stdlib.h>
+#endif
 
 #include "uwx_env.h"
 #include "uwx_scoreboard.h"
 #include "uwx_str.h"
 #include "uwx_trace.h"
 
+#ifdef _KERNEL
+static struct uwx_env uwx_env;
+#define	free(p)		/* nullified */
+#define	malloc(sz)	((sz == sizeof(uwx_env)) ? &uwx_env : NULL)
+#endif
+
 alloc_cb uwx_allocate_cb = 0;
 free_cb uwx_free_cb = 0;
 
@@ -64,7 +72,6 @@
 {
     int i;
     struct uwx_env *env;
-    char *tstr;
 
     if (uwx_allocate_cb == 0)
 	env = (struct uwx_env *) malloc(sizeof(struct uwx_env));
diff -u ./uwx_scoreboard.c /sys/contrib/ia64/libuwx/src/uwx_scoreboard.c
--- ./uwx_scoreboard.c	Tue Apr 27 10:42:53 2004
+++ /sys/contrib/ia64/libuwx/src/uwx_scoreboard.c	Thu May  6 21:29:25 2004
@@ -22,12 +22,41 @@
 OTHER DEALINGS IN THE SOFTWARE.
 */
 
+#ifndef _KERNEL
 #include <stdlib.h>
+#endif
 
 #include "uwx_env.h"
 #include "uwx_scoreboard.h"
 #include "uwx_trace.h"
 
+#ifdef _KERNEL
+static unsigned short uwx_allocated;
+static struct uwx_scoreboard uwx_scoreboard[sizeof(uwx_allocated) << 3];
+
+static void
+free(struct uwx_scoreboard *p)
+{
+	int idx = p - uwx_scoreboard;
+	uwx_allocated &= ~(1 << idx);
+}
+
+static struct uwx_scoreboard *
+malloc(size_t sz)
+{
+	int idx;
+	if (sz != sizeof(struct uwx_scoreboard))
+		return (NULL);
+	for (idx = 0; idx < (sizeof(uwx_allocated) << 3); idx++) {
+		if ((uwx_allocated & (1 << idx)) == 0) {
+			uwx_allocated |= 1 << idx;
+			return (uwx_scoreboard + idx);
+		}
+	}
+	return (NULL);
+}
+#endif
+
 
 struct uwx_scoreboard *uwx_alloc_scoreboard(struct uwx_env *env)
 {
@@ -66,6 +95,7 @@
     return sb;
 }
 
+static
 void uwx_reclaim_scoreboards(struct uwx_env *env)
 {
     struct uwx_scoreboard *sb;
@@ -140,6 +170,7 @@
     /* in the "nextstack" field. */
 
     back = 0;
+    new = 0;
     while (sb != 0) {
 	TRACE_B_LABEL_COPY(sb->id)
 	new = uwx_alloc_scoreboard(env);
@@ -223,6 +254,7 @@
     /* Now copy its stack, storing reverse links in the nextstack field. */
 
     back = sb;
+    new = 0;
     for (next = lsb->nextstack; next != 0; next = next->nextstack) {
 	TRACE_B_COPY_COPY(next->id)
 	new = uwx_alloc_scoreboard(env);
diff -u ./uwx_step.c /sys/contrib/ia64/libuwx/src/uwx_step.c
--- ./uwx_step.c	Tue Apr 27 10:42:54 2004
+++ /sys/contrib/ia64/libuwx/src/uwx_step.c	Thu May  6 18:32:03 2004
@@ -66,7 +66,7 @@
 
 
 /* uwx_get_frame_info: Gets unwind info for current frame */
-
+static
 int uwx_get_frame_info(struct uwx_env *env)
 {
     int i;
@@ -77,7 +77,6 @@
     uint64_t *uvec;
     uint64_t *rstate;
     struct uwx_utable_entry uentry;
-    uint64_t uinfop;
     uint64_t uvecout[UVECSIZE];
 
     if (env->copyin == 0 || env->lookupip == 0)
diff -u ./uwx_step.h /sys/contrib/ia64/libuwx/src/uwx_step.h
--- ./uwx_step.h	Tue Apr 27 10:42:50 2004
+++ /sys/contrib/ia64/libuwx/src/uwx_step.h	Thu May  6 18:45:59 2004
@@ -25,4 +25,6 @@
 #define UVECSIZE 20	/* Size of uvec supplied by unwind engine */
 			/* for callback's use. */
 
+extern int uwx_lookupip_hook(int request, uint64_t ip, intptr_t tok,
+    uint64_t **vecp, size_t uvecsize);
 extern int uwx_restore_markers(struct uwx_env *env);
diff -u ./uwx_str.c /sys/contrib/ia64/libuwx/src/uwx_str.c
--- ./uwx_str.c	Tue Apr 27 10:42:55 2004
+++ /sys/contrib/ia64/libuwx/src/uwx_str.c	Thu May  6 21:02:58 2004
@@ -25,6 +25,12 @@
 #include "uwx_env.h"
 #include "uwx_str.h"
 
+#ifdef _KERNEL
+static struct uwx_str_pool	uwx_str_pool;
+#define	free(p)		/* nullified */
+#define	malloc(sz)	((sz == sizeof(uwx_str_pool)) ? &uwx_str_pool : NULL)
+#endif
+
 /*
  *  uwx_str.c
  *
diff -u ./uwx_trace.c /sys/contrib/ia64/libuwx/src/uwx_trace.c
--- ./uwx_trace.c	Tue Apr 27 10:42:55 2004
+++ /sys/contrib/ia64/libuwx/src/uwx_trace.c	Thu May  6 18:36:02 2004
@@ -27,6 +27,8 @@
 #include "uwx_scoreboard.h"
 #include "uwx_trace.h"
 
+#ifdef UWX_TRACE_ENABLE
+
 void uwx_trace_init(struct uwx_env *env)
 {
     char *tstr;
@@ -34,7 +36,7 @@
     tstr = getenv("UWX_TRACE");
     if (tstr != NULL) {
 	while (*tstr != '\0') {
-	    switch (*tstr++) {
+	    switch (*tstr) {
 		case 'i': env->trace |= UWX_TRACE_UINFO; break;
 		case 't': env->trace |= UWX_TRACE_UTABLE; break;
 		case 'b': env->trace |= UWX_TRACE_SB; break;
@@ -44,6 +46,9 @@
 		case 'C': env->trace |= UWX_TRACE_COPYIN; break;
 		case 'L': env->trace |= UWX_TRACE_LOOKUPIP; break;
 		case '?':
+#ifdef _KERNEL
+		    printf("UWX_TRACE flag `%c' unknown.\n", *tstr);
+#else
 		    fprintf(stderr, "UWX_TRACE flags:\n");
 		    fprintf(stderr, "  i: unwind info\n");
 		    fprintf(stderr, "  t: unwind table searching\n");
@@ -54,7 +59,9 @@
 		    fprintf(stderr, "  C: copyin callback\n");
 		    fprintf(stderr, "  L: lookup ip callback\n");
 		    exit(1);
+#endif
 	    }
+	    tstr++;
 	}
     }
 }
@@ -107,7 +114,7 @@
 		printf("    [reg %d]\n", reg);
 	    break;
 	default:
-	    printf("    <%08x>\n", rstate);
+	    printf("    <%08llx>\n", (unsigned long long)rstate);
 	    break;
     }
 }
@@ -133,3 +140,4 @@
 	uwx_dump_rstate(i, scoreboard->rstate[i]);
 }
 
+#endif /* UWX_TRACE_ENABLE */
diff -u ./uwx_uinfo.c /sys/contrib/ia64/libuwx/src/uwx_uinfo.c
--- ./uwx_uinfo.c	Tue Apr 27 10:42:56 2004
+++ /sys/contrib/ia64/libuwx/src/uwx_uinfo.c	Thu May  6 18:46:51 2004
@@ -28,6 +28,7 @@
 #include "uwx_scoreboard.h"
 #include "uwx_bstream.h"
 #include "uwx_trace.h"
+#include "uwx_swap.h"
 
 int uwx_count_ones(unsigned int mask);
 
diff -u ./uwx_utable.c /sys/contrib/ia64/libuwx/src/uwx_utable.c
--- ./uwx_utable.c	Tue Apr 27 10:42:56 2004
+++ /sys/contrib/ia64/libuwx/src/uwx_utable.c	Thu May  6 18:58:55 2004
@@ -76,7 +76,10 @@
     /* Make sure all three required values are given. */
 
     keys = 0;
+    text_base = 0;
     unwind_flags = 0;
+    unwind_start = 0;
+    unwind_end = 0;
     while (*uvec != 0) {
 	switch ((int)*uvec++) {
 	    case UWX_KEY_TBASE:
@@ -139,7 +142,6 @@
     uint32_t unwind_end,
     struct uwx_utable_entry *uentry)
 {
-    int status;
     int lb;
     int ub;
     int mid;
@@ -160,11 +162,13 @@
 
     lb = 0;
     ub = (unwind_end - unwind_start) / (3 * WORDSZ);
+    mid = 0;
     while (ub > lb) {
 	mid = (lb + ub) / 2;
-	len = COPYIN_UINFO_4((char *)&code_start, unwind_start+mid*3*WORDSZ);
+	len = COPYIN_UINFO_4((char *)&code_start,
+	    (uintptr_t)(unwind_start+mid*3*WORDSZ));
 	len += COPYIN_UINFO_4((char *)&code_end,
-			    unwind_start+mid*3*WORDSZ+WORDSZ);
+	    (uintptr_t)(unwind_start+mid*3*WORDSZ+WORDSZ));
 	if (len != 2 * WORDSZ)
 	    return UWX_ERR_COPYIN_UTBL;
 	if (env->byte_swap) {
@@ -182,7 +186,7 @@
     if (ub <= lb)
 	return UWX_ERR_NOUENTRY;
     len = COPYIN_UINFO_4((char *)&unwind_info,
-			    unwind_start+mid*3*WORDSZ+2*WORDSZ);
+	(uintptr_t)(unwind_start+mid*3*WORDSZ+2*WORDSZ));
     if (len != WORDSZ)
 	return UWX_ERR_COPYIN_UTBL;
     if (env->byte_swap)
@@ -210,7 +214,6 @@
     uint64_t unwind_end,
     struct uwx_utable_entry *uentry)
 {
-    int status;
     int lb;
     int ub;
     int mid;
@@ -229,6 +232,7 @@
 
     lb = 0;
     ub = (unwind_end - unwind_start) / (3 * DWORDSZ);
+    mid = 0;
     while (ub > lb) {
 	mid = (lb + ub) / 2;
 	len = COPYIN_UINFO_8((char *)&code_start, unwind_start+mid*3*DWORDSZ);