Dave Barach | 52642c3 | 2016-02-11 19:28:19 -0500 | [diff] [blame] | 1 | /* |
| 2 | *------------------------------------------------------------------ |
| 3 | * Copyright (c) 2006-2016 Cisco and/or its affiliates. |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at: |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | #ifndef __cpel_util_h__ |
| 18 | #define __cpel_util_h__ |
| 19 | |
| 20 | /* |
| 21 | * Our idea of an event, as opposed to a CPEL event |
| 22 | */ |
| 23 | typedef struct evt_ { |
| 24 | u64 timestamp; |
| 25 | u32 track_id; |
| 26 | u32 event_id; |
| 27 | u32 datum; |
| 28 | } evt_t; |
| 29 | |
| 30 | evt_t *the_events; |
| 31 | |
| 32 | /* |
| 33 | * Track object, so we can sort the tracks alphabetically and |
| 34 | * fix the events later |
| 35 | */ |
| 36 | typedef struct track_ { |
| 37 | u32 original_index; |
| 38 | u32 strtab_offset; |
| 39 | } track_t; |
| 40 | |
| 41 | track_t *the_tracks; |
| 42 | u32 *track_alpha_map; |
| 43 | |
| 44 | event_definition_t *the_event_definitions; |
| 45 | i64 min_timestamp; |
| 46 | |
| 47 | /* Hash tables, used to find previous instances of the same items */ |
| 48 | uword *the_track_hash; |
| 49 | uword *the_msg_event_hash; |
| 50 | uword *the_strtab_hash; |
| 51 | uword *the_pidtid_hash; |
| 52 | uword *the_pid_to_name_hash; |
| 53 | u8 *the_strtab; |
| 54 | |
| 55 | u32 find_or_add_strtab(void *s_arg); |
| 56 | u32 find_or_add_track(void *s_arg); |
| 57 | u32 find_or_add_event(void *s_arg, char *datum_format); |
| 58 | int write_string_table(FILE *ofp); |
| 59 | int write_cpel_header(FILE *ofp, u32 nsections); |
| 60 | int write_event_defs(FILE *ofp); |
| 61 | u64 ntohll (u64 x); |
| 62 | int write_events(FILE *ofp, u64 clock_ticks_per_second); |
| 63 | int write_track_defs(FILE *ofp); |
| 64 | void cpel_util_init (void); |
| 65 | void alpha_sort_tracks(void); |
| 66 | void fixup_event_tracks(void); |
| 67 | |
| 68 | #endif /* __cpel_util_h__ */ |