blob: 3bd9697edc09c495921f99a830dc065f1afa8a44 [file] [log] [blame]
Dave Barachb00b5102019-06-14 12:11:37 -04001/*
Dave Barach52642c32016-02-11 19:28:19 -05002 *------------------------------------------------------------------
3 * Copyright (c) 2005-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/*
18 * typedefs and so forth
19 */
20#include <sys/types.h>
21#include <gtk-2.0/gtk/gtk.h>
22#include <stdio.h>
23#include "props.h"
24
25typedef char boolean;
26typedef unsigned long long ulonglong;
27
28/*
29 * main.c
30 */
31
Dave Barachb00b5102019-06-14 12:11:37 -040032extern GtkWidget *g_mainwindow;
33extern GtkWidget *g_mainvbox;
34extern GtkWidget *g_mainhbox;
Dave Barach52642c32016-02-11 19:28:19 -050035
36/*
37 * pointsel.c
38 */
39void point_selector_init(void);
40boolean read_event_definitions (char *filename);
41char *sxerox(char *);
42void pointsel_about(char *);
43void pointsel_next_snapshot(void);
44void initialize_events(void);
45void finalize_events(void);
46
47#define NEVENTS 100000
48
49typedef struct event_def_ {
50 ulong event;
51 char *name;
52 char *format;
53 boolean selected;
54 boolean is_clib;
55 char pad[2];
56} event_def_t;
57
Dave Barachb00b5102019-06-14 12:11:37 -040058extern event_def_t *find_event_definition (ulong code);
Dave Barach52642c32016-02-11 19:28:19 -050059
Dave Barachb00b5102019-06-14 12:11:37 -040060extern event_def_t g_eventdefs[NEVENTS];
Dave Barach52642c32016-02-11 19:28:19 -050061
62/*
63 * config params
64 */
Dave Barachb00b5102019-06-14 12:11:37 -040065extern int c_maxpointsel; /* max # points shown in selector dlg */
66extern gint c_view1_draw_width;
67extern gint c_view1_draw_height;
Dave Barach52642c32016-02-11 19:28:19 -050068
69/*
70 * menu1.c
71 */
72
73void menu1_init(void);
Dave Barachb00b5102019-06-14 12:11:37 -040074void modal_dialog (char *label_text, char *retry_text, char *default_value,
Dave Barach52642c32016-02-11 19:28:19 -050075 boolean (*cb)(char *));
76void infobox(char *label_text, char *text);
77/*
78 * view1.c
79 */
Dave Barachb00b5102019-06-14 12:11:37 -040080extern GdkFont *g_font;
81extern GdkColor fg_black, bg_white;
Dave Barach52642c32016-02-11 19:28:19 -050082void view1_init(void);
83void view1_display(void);
84void view1_read_events_callback(void);
85void view1_display_when_idle(void);
86void view1_print_callback(GtkToggleButton *item, gpointer data);
87void view1_about(char *);
88void set_pid_ax_width(int width);
89void set_window_title(const char *filename);
90
91enum view1_tbox_fn {
92 TBOX_DRAW_BOXED = 1, /* note: order counts */
93 TBOX_DRAW_EVENT,
94 TBOX_DRAW_PLAIN,
95 TBOX_PRINT_BOXED,
96 TBOX_PRINT_EVENT,
97 TBOX_PRINT_PLAIN, /* end restriction */
98 TBOX_GETRECT_BOXED,
99 TBOX_GETRECT_EVENT,
100 TBOX_GETRECT_PLAIN,
101};
102
103enum view1_line_fn {
104 LINE_DRAW_BLACK = 1,
105 LINE_DRAW_WHITE,
106 LINE_PRINT,
107};
108
109GdkRectangle *tbox (char *s, int x, int y, enum view1_tbox_fn function);
110void line (int x1, int y1, int x2, int y2, enum view1_line_fn function);
111gint view1_handle_key_press_event (GtkWidget *widget, GdkEventKey *event);
112
113/*
114 * events.c
115 */
116
117void events_about (char *);
118
119typedef struct raw_event {
120 unsigned long time[2];
121 unsigned long pid;
122 unsigned long code;
123 unsigned long datum;
124} raw_event_t;
125
126void event_init(void);
127char *mapfile (char *file, ulong *sizep);
128boolean unmapfile (char *addr, ulong size);
129void read_events (char *);
130int find_event_index (ulonglong t);
131int read_cpel_file(char *file);
132int read_clib_file(char *file);
133void cpel_event_init(ulong);
134void add_event_from_cpel_file(ulong, char * , char *);
Dave Barachb00b5102019-06-14 12:11:37 -0400135void add_event_from_clib_file(unsigned int event, char *name,
Dave Barach52642c32016-02-11 19:28:19 -0500136 unsigned int vec_index);
137void add_cpel_event(ulonglong delta, ulong, ulong, ulong);
Dave Barachb00b5102019-06-14 12:11:37 -0400138void add_clib_event(double delta, unsigned short track,
Dave Barach52642c32016-02-11 19:28:19 -0500139 unsigned short event, unsigned int index);
140void cpel_event_finalize(void);
141void *get_clib_event (unsigned int datum);
142
143typedef struct pid_data {
144 struct pid_data *next;
145 ulong pid_value; /* The actual pid value */
146 ulong pid_index; /* Index in pid sort order */
147} pid_data_t;
Dave Barachb00b5102019-06-14 12:11:37 -0400148
Dave Barach52642c32016-02-11 19:28:19 -0500149#define EVENT_FLAG_SELECT 0x00000001 /* This event is selected */
150#define EVENT_FLAG_SEARCHRSLT 0x00000002 /* This event is the search rslt */
151#define EVENT_FLAG_CLIB 0x00000004 /* clib event */
152
153typedef struct pid_sort {
154 struct pid_data *pid;
155 ulong pid_value;
156 /*
157 * This is a bit of a hack, since this is used only by the view:
158 */
159 unsigned color_index;
Dave Barach2c35e582017-04-03 10:22:17 -0400160 int selected;
Dave Barach52642c32016-02-11 19:28:19 -0500161} pid_sort_t;
162
163typedef struct event {
164 ulonglong time;
165 ulong code;
166 pid_data_t *pid;
167 ulong datum;
168 ulong flags;
169} event_t;
170
171
Dave Barachb00b5102019-06-14 12:11:37 -0400172extern boolean g_little_endian;
173extern event_t *g_events;
174extern ulong g_nevents;
175extern pid_sort_t *g_pids;
176extern pid_sort_t *g_original_pids;
177extern int g_npids;
178extern pid_data_t *g_pid_data_list;
Dave Barach52642c32016-02-11 19:28:19 -0500179
180#define PIDHASH_NBUCKETS 20021 /* Should be prime */
181
Dave Barachb00b5102019-06-14 12:11:37 -0400182extern boolean ticks_per_ns_set;
183extern double ticks_per_ns;
Dave Barach52642c32016-02-11 19:28:19 -0500184
185/*
186 * version.c
187 */
Dave Barachb00b5102019-06-14 12:11:37 -0400188extern const char *version_string;
189extern const char *minor_v_string;
Dave Barach52642c32016-02-11 19:28:19 -0500190
191/*
192 * cpel.c
193 */
194char *get_track_label(unsigned long);
Dave Barachb00b5102019-06-14 12:11:37 -0400195extern int widest_track_format;
Dave Barach52642c32016-02-11 19:28:19 -0500196char *strtab_ref(unsigned long);