summaryrefslogtreecommitdiffstats
path: root/src/vppinfra.am
blob: 25cf14460417676ad2fa05ad8b93e1d94f531b83 (plain)
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
# Copyright (c) 2015 Cisco and/or its affiliates.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at:
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

lib_LTLIBRARIES += libvppinfra.la

TESTS = 

if ENABLE_TESTS
TESTS  +=  test_bihash_template \
           test_bihash_vec88 \
	   test_cuckoo_bihash \
	   test_cuckoo_template\
	   test_dlist \
	   test_elf \
	   test_elog \
	   test_fifo \
	   test_format \
	   test_fpool \
	   test_hash \
	   test_heap \
	   test_longjmp \
	   test_macros \
	   test_md5 \
	   test_mheap \
	   test_pool_iterate \
	   test_ptclosure \
	   test_random \
	   test_random_isaac \
	   test_serialize \
	   test_slist \
	   test_socket \
	   test_time \
	   test_timing_wheel \
	   test_tw_timer \
	   test_vec \
	   test_zvec
endif

noinst_PROGRAMS = $(TESTS)
check_PROGRAMS	= $(TESTS)

test_bihash_template_SOURCES = vppinfra/test_bihash_template.c
test_bihash_vec88_SOURCES = vppinfra/test_bihash_vec88.c
test_cuckoo_template_SOURCES = vppinfra/test_cuckoo_template.c
test_cuckoo_bihash_SOURCES = vppinfra/test_cuckoo_bihash.c
test_dlist_SOURCES = vppinfra/test_dlist.c
test_elf_SOURCES = vppinfra/test_elf.c
test_elog_SOURCES = vppinfra/test_elog.c
test_fifo_SOURCES = vppinfra/test_fifo.c
test_format_SOURCES = vppinfra/test_format.c
test_fpool_SOURCES = vppinfra/test_fpool.c
test_hash_SOURCES = vppinfra/test_hash.c
test_heap_SOURCES = vppinfra/test_heap.c
test_longjmp_SOURCES = vppinfra/test_longjmp.c
test_macros_SOURCES = vppinfra/test_macros.c
test_md5_SOURCES = vppinfra/test_md5.c
test_mheap_SOURCES = vppinfra/test_mheap.c
test_pool_iterate_SOURCES = vppinfra/test_pool_iterate.c
test_ptclosure_SOURCES = vppinfra/test_ptclosure.c
test_random_isaac_SOURCES = vppinfra/test_random_isaac.c
test_random_SOURCES = vppinfra/test_random.c
test_serialize_SOURCES = vppinfra/test_serialize.c
test_slist_SOURCES = vppinfra/test_slist.c
test_socket_SOURCES = vppinfra/test_socket.c
test_time_SOURCES = vppinfra/test_time.c
test_timing_wheel_SOURCES = vppinfra/test_timing_wheel.c
test_tw_timer_SOURCES = vppinfra/test_tw_timer.c
test_vec_SOURCES = vppinfra/test_vec.c
test_zvec_SOURCES = vppinfra/test_zvec.c

# All unit tests use ASSERT for failure
# So we'll need -DDEBUG to enable ASSERTs
test_bihash_template_CPPFLAGS =	$(AM_CPPFLAGS) -DCLIB_DEBUG
test_bihash_vec88_CPPFLAGS =	$(AM_CPPFLAGS) -DCLIB_DEBUG
test_cuckoo_template_CPPFLAGS =	$(AM_CPPFLAGS) -DCLIB_DEBUG
test_cuckoo_bihash_CPPFLAGS =	$(AM_CPPFLAGS) -DCLIB_DEBUG
test_dlist_CPPFLAGS =	$(AM_CPPFLAGS) -DCLIB_DEBUG
test_elf_CPPFLAGS =	$(AM_CPPFLAGS) -DCLIB_DEBUG
test_elog_CPPFLAGS =	$(AM_CPPFLAGS) -DCLIB_DEBUG
test_fifo_CPPFLAGS =	$(AM_CPPFLAGS) -DCLIB_DEBUG
test_format_CPPFLAGS =	$(AM_CPPFLAGS) -DCLIB_DEBUG
test_fpool_CPPFLAGS =	$(AM_CPPFLAGS) -DCLIB_DEBUG
test_hash_CPPFLAGS =	$(AM_CPPFLAGS) -DCLIB_DEBUG
test_heap_CPPFLAGS =	$(AM_CPPFLAGS) -DCLIB_DEBUG
test_longjmp_CPPFLAGS =	$(AM_CPPFLAGS) -DCLIB_DEBUG
test_macros_CPPFLAGS =	$(AM_CPPFLAGS) -DCLIB_DEBUG
test_md5_CPPFLAGS =	$(AM_CPPFLAGS) -DCLIB_DEBUG
test_mheap_CPPFLAGS =	$(AM_CPPFLAGS) -DCLIB_DEBUG
test_pool_iterate_CPPFLAGS =	$(AM_CPPFLAGS) -DCLIB_DEBUG
test_ptclosure_CPPFLAGS =	$(AM_CPPFLAGS) -DCLIB_DEBUG
test_random_CPPFLAGS = $(AM_CPPFLAGS) -DCLIB_DEBUG
test_random_isaac_CPPFLAGS = $(AM_CPPFLAGS) -DCLIB_DEBUG
test_serialize_CPPFLAGS = $(AM_CPPFLAGS) -DCLIB_DEBUG
test_slist_CPPFLAGS = $(AM_CPPFLAGS) -DCLIB_DEBUG
test_socket_CPPFLAGS =	$(AM_CPPFLAGS) -DCLIB_DEBUG
test_time_CPPFLAGS =	$(AM_CPPFLAGS) -DCLIB_DEBUG
test_timing_wheel_CPPFLAGS = $(AM_CPPFLAGS) -DCLIB_DEBUG
test_tw_timer_CPPFLAGS =	$(AM_CPPFLAGS) -DCLIB_DEBUG
test_vec_CPPFLAGS =	$(AM_CPPFLAGS) -DCLIB_DEBUG
test_zvec_CPPFLAGS =	$(AM_CPPFLAGS) -DCLIB_DEBUG

test_bihash_template_LDADD =	libvppinfra.la
test_bihash_vec88_LDADD =	libvppinfra.la
test_cuckoo_template_LDADD =	libvppinfra.la
test_cuckoo_bihash_LDADD =	libvppinfra.la
test_dlist_LDADD =	libvppinfra.la
test_elf_LDADD =	libvppinfra.la
test_elog_LDADD =	libvppinfra.la
test_fifo_LDADD =	libvppinfra.la
test_format_LDADD =	libvppinfra.la
test_fpool_LDADD =	libvppinfra.la
test_hash_LDADD =	libvppinfra.la
test_heap_LDADD =	libvppinfra.la
test_longjmp_LDADD =	libvppinfra.la
test_macros_LDADD =	libvppinfra.la
test_md5_LDADD =	libvppinfra.la
test_mheap_LDADD =	libvppinfra.la
test_pool_iterate_LDADD =	libvppinfra.la
test_ptclosure_LDADD =	libvppinfra.la
test_random_isaac_LDADD =	libvppinfra.la
test_random_LDADD =	libvppinfra.la
test_serialize_LDADD =	libvppinfra.la
test_slist_LDADD =	libvppinfra.la
test_socket_LDADD =	libvppinfra.la
test_time_LDADD =	libvppinfra.la -lm
test_timing_wheel_LDADD =	libvppinfra.la -lm
test_tw_timer_LDADD =	libvppinfra.la
test_vec_LDADD =	libvppinfra.la
test_zvec_LDADD =	libvppinfra.la

test_bihash_template_LDFLAGS = -static
test_bihash_vec88_LDFLAGS = -static
test_cuckoo_template_LDFLAGS = -static
test_cuckoo_bihash_LDFLAGS = -static -lpthread
test_dlist_LDFLAGS = -static
test_elf_LDFLAGS = -static
test_elog_LDFLAGS = -static
test_fifo_LDFLAGS = -static
test_format_LDFLAGS = -static
test_fpool_LDFLAGS = -static
test_hash_LDFLAGS = -static
test_heap_LDFLAGS = -static
test_longjmp_LDFLAGS = -static
test_macros_LDFLAGS = -static
test_md5_LDFLAGS = -static
test_mheap_LDFLAGS = -static
test_pool_iterate_LDFLAGS = -static
test_ptclosure_LDFLAGS = -static
test_random_isaac_LDFLAGS = -static
test_random_LDFLAGS = -static
test_serialize_LDFLAGS = -static
test_slist_LDFLAGS = -static
test_socket_LDFLAGS = -static
test_time_LDFLAGS = -static
test_timing_wheel_LDFLAGS = -static
test_tw_timer_LDFLAGS = -static
test_vec_LDFLAGS = -static
test_zvec_LDFLAGS = -static

# noinst_PROGRAMS += test_vhash
# test_vhash_SOURCES = vppinfra/test_vhash.c vppinfra/vhash.c
# test_vhash_CPPFLAGS = $(AM_CPPFLAGS) -DCLIB_DEBUG
# test_vhash_LDADD = libvppinfra.la
# test_vhash_LDFLAGS = -static

nobase_include_HEADERS = \
  vppinfra/asm_mips.h \
  vppinfra/asm_x86.h \
  vppinfra/bihash_8_8.h \
  vppinfra/bihash_vec8_8.h \
  vppinfra/bihash_16_8.h \
  vppinfra/bihash_24_8.h \
  vppinfra/bihash_48_8.h \
  vppinfra/bihash_template.h \
  vppinfra/bihash_template.c \
  vppinfra/bitmap.h \
  vppinfra/bitops.h \
  vppinfra/byte_order.h \
  vppinfra/cache.h \
  vppinfra/clib.h \
  vppinfra/clib_error.h \
  vppinfra/cpu.h \
  vppinfra/crc32.h \
  vppinfra/dlist.h \
  vppinfra/elf.h \
  vppinfra/elf_clib.h \
  vppinfra/elog.h \
  vppinfra/fheap.h \
  vppinfra/error.h \
  vppinfra/error_bootstrap.h \
  vppinfra/fifo.h \
  vppinfra/file.h \
  vppinfra/format.h \
  vppinfra/graph.h \
  vppinfra/hash.h \
  vppinfra/heap.h \
  vppinfra/linux/sysfs.h \
  vppinfra/linux/syscall.h \
  vppinfra/lock.h \
  vppinfra/longjmp.h \
  vppinfra/macros.h \
  vppinfra/math.h \
  vppinfra/md5.h \
  vppinfra/mem.h \
  vppinfra/memcpy_sse3.h \
  vppinfra/memcpy_avx.h \
  vppinfra/mhash.h \
  vppinfra/mheap.h \
  vppinfra/mheap_bootstrap.h \
  vppinfra/os.h \
  vppinfra/pipeline.h \
  vppinfra/pool.h \
  vppinfra/ptclosure.h \
  vppinfra/random.h \
  vppinfra/random_buffer.h \
  vppinfra/random_isaac.h \
  vppinfra/serialize.h \
  vppinfra/slist.h \
  vppinfra/smp.h \
  vppinfra/socket.h \
  vppinfra/sparse_vec.h \
  vppinfra/string.h \
  vppinfra/time.h \
  vppinfra/timing_wheel.h \
  vppinfra/timer.h \
  vppinfra/tw_timer_2t_1w_2048sl.h \
  vppinfra/tw_timer_16t_2w_512sl.h \
  vppinfra/tw_timer_16t_1w_2048sl.h \
  vppinfra/tw_timer_4t_3w_256sl.h \
  vppinfra/tw_timer_1t_3w_1024sl_ov.h \
  vppinfra/tw_timer_template.h \
  vppinfra/tw_timer_template.c \
  vppinfra/types.h \
  vppinfra/unix.h \
  vppinfra/vec.h \
  vppinfra/vec_bootstrap.h \
  vppinfra/vector.h \
  vppinfra/vector_altivec.h \
  vppinfra/vector_funcs.h \
  vppinfra/vector_iwmmxt.h \
  vppinfra/vector_neon.h \
  vppinfra/vector_sse2.h \
  vppinfra/valgrind.h \
  vppinfra/xxhash.h \
  vppinfra/xy.h \
  vppinfra/zvec.h

CLIB_CORE = \
  vppinfra/asm_x86.c \
  vppinfra/backtrace.c \
  vppinfra/bihash_8_8.h \
  vppinfra/bihash_vec8_8.h \
  vppinfra/bihash_24_8.h \
  vppinfra/bihash_template.h \
  vppinfra/cpu.c \
  vppinfra/elf.c \
  vppinfra/elog.c \
  vppinfra/error.c \
  vppinfra/fifo.c \
  vppinfra/fheap.c \
  vppinfra/format.c \
  vppinfra/pool.c \
  vppinfra/graph.c \
  vppinfra/hash.c \
  vppinfra/heap.c \
  vppinfra/longjmp.S \
  vppinfra/macros.c \
  vppinfra/mhash.c \
  vppinfra/mheap.c \
  vppinfra/md5.c \
  vppinfra/mem_mheap.c \
  vppinfra/ptclosure.c \
  vppinfra/random.c \
  vppinfra/random_buffer.c \
  vppinfra/random_isaac.c \
  vppinfra/serialize.c \
  vppinfra/slist.c \
  vppinfra/std-formats.c \
  vppinfra/string.c \
  vppinfra/time.c \
  vppinfra/timing_wheel.c \
  vppinfra/tw_timer_template.h \
  vppinfra/tw_timer_2t_1w_2048sl.h \
  vppinfra/tw_timer_2t_1w_2048sl.c \
  vppinfra/tw_timer_16t_2w_512sl.h \
  vppinfra/tw_timer_16t_2w_512sl.c \
  vppinfra/tw_timer_16t_1w_2048sl.h \
  vppinfra/tw_timer_16t_1w_2048sl.c \
  vppinfra/tw_timer_4t_3w_256sl.h \
  vppinfra/tw_timer_4t_3w_256sl.c \
  vppinfra/tw_timer_1t_3w_1024sl_ov.h \
  vppinfra/tw_timer_1t_3w_1024sl_ov.c \
  vppinfra/unformat.c \
  vppinfra/vec.c \
  vppinfra/vector.c \
  vppinfra/zvec.c

# Core plus Unix additions
libvppinfra_la_SOURCES =			\
  $(CLIB_CORE)					\
  vppinfra/elf_clib.c				\
  vppinfra/linux/mem.c				\
  vppinfra/linux/sysfs.c			\
  vppinfra/socket.c				\
  vppinfra/timer.c				\
  vppinfra/unix-formats.c			\
  vppinfra/unix-misc.c

bin_PROGRAMS = elftool

elftool_SOURCES = tools/elftool/elftool.c
elftool_CPPFLAGS = $(AM_CPPFLAGS)
elftool_LDADD = libvppinfra.la -lpthread -lrt -lm

# vi:syntax=automake
pan class="p">{ int (*pass1)(cpel_section_header_t *, int, FILE *); int (*pass2)(cpel_section_header_t *, int, FILE *); } section_processor_t; int bad_section(cpel_section_header_t *sh, int verbose, FILE *ofp) { fprintf(ofp, "Bad (type 0) section, skipped...\n"); return(0); } int noop_pass(cpel_section_header_t *sh, int verbose, FILE *ofp) { return(0); } int strtab_pass1(cpel_section_header_t *sh, int verbose, FILE *ofp) { uword *p; u8 *strtab_data_area = (u8 *)(sh+1); /* Multiple string tables with the same name are Bad... */ p = hash_get_mem(the_strtab_hash, strtab_data_area); if (p) { fprintf(ofp, "Duplicate string table name %s", strtab_data_area); } /* * Looks funny, but we really do want key = first string in the * table, value = address(first string in the table) */ hash_set_mem(the_strtab_hash, strtab_data_area, strtab_data_area); if (verbose) { fprintf(ofp, "String Table %s\n", strtab_data_area); } return(0); } int evtdef_pass1(cpel_section_header_t *sh, int verbose, FILE *ofp) { int i, nevents; event_definition_section_header_t *edh; event_definition_t *ep; u8 *this_strtab; u32 event_code; uword *p; bound_event_t *bp; edh = (event_definition_section_header_t *)(sh+1); nevents = ntohl(edh->number_of_event_definitions); if (verbose) { fprintf(ofp, "Event Definition Section: %d definitions\n", nevents); } p = hash_get_mem(the_strtab_hash, edh->string_table_name); if (!p) { fprintf(ofp, "Fatal: couldn't find string table\n"); return(1); } this_strtab = (u8 *)p[0]; initialize_events(); ep = (event_definition_t *)(edh+1); for (i = 0; i < nevents; i++) { event_code = ntohl(ep->event); p = hash_get(the_evtdef_hash, event_code); if (p) { fprintf(ofp, "Event %d redefined, retain first definition\n", event_code); continue; } vec_add2(bound_events, bp, 1); bp->event_code = event_code; bp->event_str = this_strtab + ntohl(ep->event_format); bp->datum_str = this_strtab + ntohl(ep->datum_format); hash_set(the_evtdef_hash, event_code, bp - bound_events); add_event_from_cpel_file(event_code, (char *) bp->event_str, (char *)bp->datum_str); ep++; } finalize_events(); return (0); } int trackdef_pass1(cpel_section_header_t *sh, int verbose, FILE *ofp) { int i, nevents; track_definition_section_header_t *tdh; track_definition_t *tp; u8 *this_strtab; u32 track_code; uword *p; bound_track_t *btp; int track_strlen; tdh = (track_definition_section_header_t *)(sh+1); nevents = ntohl(tdh->number_of_track_definitions); if (verbose) { fprintf(ofp, "Track Definition Section: %d definitions\n", nevents); } p = hash_get_mem(the_strtab_hash, tdh->string_table_name); if (!p) { fprintf(ofp, "Fatal: couldn't find string table\n"); return(1); } this_strtab = (u8 *)p[0]; tp = (track_definition_t *)(tdh+1); for (i = 0; i < nevents; i++) { track_code = ntohl(tp->track); p = hash_get(the_trackdef_hash, track_code); if (p) { fprintf(ofp, "track %d redefined, retain first definition\n", track_code); continue; } vec_add2(bound_tracks, btp, 1); btp->track = track_code; btp->track_str = this_strtab + ntohl(tp->track_format); hash_set(the_trackdef_hash, track_code, btp - bound_tracks); track_strlen = strlen((char *)btp->track_str); if (track_strlen > widest_track_format) widest_track_format = track_strlen; tp++; } return (0); } int unsupported_pass (cpel_section_header_t *sh, int verbose, FILE *ofp) { if (verbose) { fprintf(ofp, "Unsupported type %d section\n", ntohl(sh->section_type)); } return(0); } int event_pass2(cpel_section_header_t *sh, int verbose, FILE *ofp) { event_section_header_t *eh; u32 event_code, track_code, datum; u64 starttime = ~0ULL; int nevents; int i; event_entry_t *ep; u64 now; u64 delta; u32 time0, time1; double d; uword *p; eh = (event_section_header_t *)(sh+1); nevents = ntohl(eh->number_of_events); ticks_per_ns = ntohl(eh->clock_ticks_per_second)/1e9; ep = (event_entry_t *)(eh+1); p = hash_get_mem(the_strtab_hash, eh->string_table_name); if (!p) { fprintf(ofp, "Fatal: couldn't find string table\n"); return(1); } event_strtab = (u8 *)p[0]; cpel_event_init(nevents); for (i = 0; i < nevents; i++) { time0 = ntohl (ep->time[0]); time1 = ntohl (ep->time[1]); now = (((u64) time0)<<32) | time1; /* Convert from bus ticks to usec */ d = now; d /= ticks_per_ns; now = d; if (starttime == ~0ULL) starttime = now; delta = now - starttime; /* Delta = time since first event, in usec */ event_code = ntohl(ep->event_code); track_code = ntohl(ep->track); datum = ntohl(ep->event_datum); add_cpel_event(delta, track_code, event_code, datum); ep++; } cpel_event_finalize(); return(0); } char *strtab_ref(unsigned long datum) { return ((char *)(event_strtab + datum)); } /* * Note: If necessary, add passes / columns to this table to * handle section order dependencies. */ section_processor_t processors[CPEL_NUM_SECTION_TYPES+1] = { {bad_section, noop_pass}, /* type 0 -- f**ked */ {strtab_pass1, noop_pass}, /* type 1 -- STRTAB */ {unsupported_pass, noop_pass}, /* type 2 -- SYMTAB */ {evtdef_pass1, noop_pass}, /* type 3 -- EVTDEF */ {trackdef_pass1, noop_pass}, /* type 4 -- TRACKDEF */ {noop_pass, event_pass2}, /* type 5 -- EVENTS */ }; int process_section(cpel_section_header_t *sh, int verbose, FILE *ofp, pass_t pass) { u32 type; type = ntohl(sh->section_type); int rv; int (*fp)(cpel_section_header_t *, int, FILE *); if (type > CPEL_NUM_SECTION_TYPES) { fprintf(stderr, "Unknown section type %d\n", type); return(1); } switch(pass) { case PASS1: fp = processors[type].pass1; break; case PASS2: fp = processors[type].pass2; break; default: fprintf(stderr, "Unknown pass %d\n", pass); return(1); } rv = (*fp)(sh, verbose, ofp); return(rv); } int cpel_dump_file_header(cpel_file_header_t *fh, int verbose, FILE *ofp) { time_t file_time; if (verbose) { fprintf(ofp, "CPEL file: %s-endian, version %d\n", ((fh->endian_version & CPEL_FILE_LITTLE_ENDIAN) ? "little" : "big"), fh->endian_version & CPEL_FILE_VERSION_MASK); file_time = ntohl(fh->file_date); fprintf(ofp, "File created %s", ctime(&file_time)); } return(0); } int cpel_process(u8 *cpel, int verbose, FILE *ofp) { cpel_file_header_t *fh; cpel_section_header_t *sh; u16 nsections; u32 section_size; int i; /* First, the file header */ fh = (cpel_file_header_t *)cpel; if (fh->endian_version != CPEL_FILE_VERSION) { if (fh->endian_version & CPEL_FILE_LITTLE_ENDIAN) { fprintf(stderr, "Little endian data format not supported\n"); return(1); } fprintf(stderr, "Unsupported file version 0x%x\n", fh->endian_version); return(1); } cpel_dump_file_header(fh, verbose, ofp); nsections = ntohs(fh->nsections); /* * Take two passes through the file. PASS1 builds * data structures, PASS2 actually dumps the file. * Just in case the sections are in an unobvious order. */ sh = (cpel_section_header_t *)(fh+1); for (i = 0; i < nsections; i++) { section_size = ntohl(sh->data_length); if(verbose) { fprintf(ofp, "Section type %d, size %d\n", ntohl(sh->section_type), section_size); } if(process_section(sh, verbose, ofp, PASS1)) return(1); sh++; sh = (cpel_section_header_t *)(((u8 *)sh)+section_size); } sh = (cpel_section_header_t *)(fh+1); for (i = 0; i < nsections; i++) { if(process_section(sh, verbose, ofp, PASS2)) return(1); section_size = ntohl(sh->data_length); sh++; sh = (cpel_section_header_t *)(((u8 *)sh)+section_size); } return(0); } /* * read_cpel_file */ int read_cpel_file(char *cpel_file) { int verbose = 0; int rv; static u8 *cpel; static unsigned long size; static FILE *ofp; if (cpel) { unmapfile((char *)cpel, size); hash_free(the_strtab_hash); the_strtab_hash = 0; hash_free(the_evtdef_hash); the_evtdef_hash = 0; hash_free(the_trackdef_hash); the_trackdef_hash = 0; } cpel = (u8 *)mapfile((char *)cpel_file, &size); if (cpel == 0) { fprintf(stderr, "Couldn't map %s...\n", cpel_file); exit(1); } if (ofp == NULL) { ofp = fdopen(2, "w"); if (ofp == NULL) { fprintf(stderr, "Couldn't fdopen(2)?\n"); exit(1); } } the_strtab_hash = hash_create_string (0, sizeof (uword)); the_evtdef_hash = hash_create (0, sizeof (uword)); the_trackdef_hash = hash_create (0, sizeof (uword)); rv = cpel_process(cpel, verbose, ofp); set_pid_ax_width(8*widest_track_format); return(rv); } static bound_track_t generic_hex_track = {0, (u8 *) "0x%08x"}; static bound_track_t generic_decimal_track = {0, (u8 *) "%8ld"}; /* * get_track_label */ char *get_track_label(unsigned long track) { uword *p; bound_track_t *tp; p = hash_get(the_trackdef_hash, track); if (p) { tp = &bound_tracks[p[0]]; } else { if (track > 65535) tp = &generic_hex_track; else tp = &generic_decimal_track; } return((char *)tp->track_str); }