blob: 1ab42191ca9bcc9b8c9ed51eab6a5d6d9cf9cc54 [file] [log] [blame]
Dave Barach52642c32016-02-11 19:28:19 -05001/*
2 *------------------------------------------------------------------
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
32GtkWidget *g_mainwindow;
33GtkWidget *g_mainvbox;
34GtkWidget *g_mainhbox;
35
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
58event_def_t *find_event_definition (ulong code);
59
60event_def_t g_eventdefs[NEVENTS];
61
62/*
63 * config params
64 */
65int c_maxpointsel; /* max # points shown in selector dlg */
66gint c_view1_draw_width;
67gint c_view1_draw_height;
68
69/*
70 * menu1.c
71 */
72
73void menu1_init(void);
74void modal_dialog (char *label_text, char *retry_text, char *default_value,
75 boolean (*cb)(char *));
76void infobox(char *label_text, char *text);
77/*
78 * view1.c
79 */
80GdkFont *g_font;
81GdkColor fg_black, bg_white;
82void 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 *);
135void add_event_from_clib_file(unsigned int event, char *name,
136 unsigned int vec_index);
137void add_cpel_event(ulonglong delta, ulong, ulong, ulong);
138void add_clib_event(double delta, unsigned short track,
139 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;
148
149#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;
160} pid_sort_t;
161
162typedef struct event {
163 ulonglong time;
164 ulong code;
165 pid_data_t *pid;
166 ulong datum;
167 ulong flags;
168} event_t;
169
170
171boolean g_little_endian;
172event_t *g_events;
173ulong g_nevents;
174pid_sort_t *g_pids;
175pid_sort_t *g_original_pids;
176int g_npids;
177pid_data_t *g_pid_data_list;
178
179#define PIDHASH_NBUCKETS 20021 /* Should be prime */
180
181boolean ticks_per_ns_set;
182double ticks_per_ns;
183
184/*
185 * version.c
186 */
187const char *version_string;
188const char *minor_v_string;
189
190/*
191 * cpel.c
192 */
193char *get_track_label(unsigned long);
194int widest_track_format;
195char *strtab_ref(unsigned long);