Fix tar.gz build by removing legacy include to ltt directory
[lttv.git] / lttv / modules / gui / resourceview / processlist.h
CommitLineData
9e01e6d4 1/* This file is part of the Linux Trace Toolkit viewer
2 * Copyright (C) 2003-2004 Mathieu Desnoyers
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License Version 2 as
6 * published by the Free Software Foundation;
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
16 * MA 02111-1307, USA.
17 */
18
9e01e6d4 19#ifndef _PROCESS_LIST_H
20#define _PROCESS_LIST_H
21
22#include <gtk/gtk.h>
23#include <gdk/gdk.h>
24#include <lttv/state.h>
9e01e6d4 25
26#include "drawitem.h"
67f72973 27#include "cfv.h"
9e01e6d4 28
29/* The process list
30 *
31 * Tasks :
32 * Create a process list
33 * contains the data for the process list
34 * tells the height of the process list widget
35 * provides methods to add/remove process from the list
36 * note : the sync with drawing is left to the caller.
37 * provides helper function to convert a process unique identifier to
38 * pixels (in height).
39 *
40 */
41
67f72973 42/* Unique identifiers for resource types */
43#define RV_RESOURCE_MACHINE 0
44#define RV_RESOURCE_CPU 1
45#define RV_RESOURCE_IRQ 2
0305fe77 46#define RV_RESOURCE_SOFT_IRQ 3
38726a78 47#define RV_RESOURCE_TRAP 4
48#define RV_RESOURCE_BDEV 5
49#define RV_RESOURCE_COUNT 6
9e01e6d4 50
51/* Enumeration of the columns */
52enum
53{
c4e6f4dc 54 NAME_COLUMN,
67f72973 55 DATA_COLUMN,
9e01e6d4 56 N_COLUMNS
57};
58
67f72973 59/*
c4e6f4dc 60typedef struct _ResourceInfo {
58a9b31b 61 GQuark name;
62 guint trace_num;
44ffb95f 63 guint type;
8743690d 64 guint64 id;
c4e6f4dc 65} ResourceInfo;
67f72973 66*/
67
27274b95 68struct _ResourceType {
69 /* a hashtable containing the data of each resource of this type */
70 GHashTable *hash_table;
71};
72typedef struct _ResourceType ResourceType;
73
74typedef struct _ResourceUnique {
75 ResourceType *type;
76 void *priv;
77} ResourceUnique;
78
67f72973 79typedef struct _ResourceUniqueNumeric {
27274b95 80 ResourceUnique ru;
67f72973 81 guint trace_num;
82 guint id;
83} ResourceUniqueNumeric;
9e01e6d4 84
c4e6f4dc 85typedef struct _HashedResourceData {
67f72973 86 guint type;
9e01e6d4 87
88 GdkPixmap *pixmap; // Pixmap slice containing drawing buffer for the PID
89 gint height; // height of the pixmap
90 GtkTreeIter y_iter; // Access quickly to y pos.
91 // DrawContext *draw_context;
92 /* Information on current drawing */
93 struct {
94 guint over;
95 gboolean over_used; /* inform the user that information is incomplete */
96 gboolean over_marked; /* inform the user that information is incomplete */
97 guint middle;
98 gboolean middle_used; /* inform the user that information is incomplete */
99 gboolean middle_marked;/* inform the user that information is incomplete */
100 guint under;
101 gboolean under_used; /* inform the user that information is incomplete */
102 gboolean under_marked; /* inform the user that information is incomplete */
103 } x; /* last x position saved by after state update */
104
105 LttTime next_good_time; /* precalculate the next time where the next
106 pixel is.*/
27274b95 107 gint hidden;
9e01e6d4 108
c4e6f4dc 109} HashedResourceData;
9e01e6d4 110
111struct _ProcessList {
112
113 GtkWidget *process_list_widget;
67f72973 114 GtkTreeStore *list_store;
9e01e6d4 115 GtkWidget *button; /* one button of the tree view */
116 GtkCellRenderer *renderer;
117
118 /* A hash table by PID to speed up process position find in the list */
67f72973 119// GHashTable *process_hash;
9e01e6d4 120
121 guint number_of_process;
122 gint cell_height;
123
124 /* Current process pointer, one per cpu, one per trace */
58a9b31b 125 HashedResourceData ***current_hash_data;
9e01e6d4 126
127 /* Array containing index -> pixmap correspondance. Must be updated
128 * every time the process list is reordered, process added or removed */
129 GPtrArray * index_to_pixmap;
130
67f72973 131 ResourceType restypes[RV_RESOURCE_COUNT];
9e01e6d4 132};
133
67f72973 134typedef struct _UpdateIndexPixmapArg {
135 ProcessList *process_list;
136 guint count;
137} UpdateIndexPixmapArg;
9e01e6d4 138
67f72973 139#ifndef TYPE_PROCESSLIST_DEFINED
140#define TYPE_PROCESSLIST_DEFINED
9e01e6d4 141typedef struct _ProcessList ProcessList;
67f72973 142#endif //TYPE_PROCESSLIST_DEFINED
9e01e6d4 143
144
145#ifndef TYPE_DRAWING_T_DEFINED
146#define TYPE_DRAWING_T_DEFINED
147typedef struct _Drawing_t Drawing_t;
148#endif //TYPE_DRAWING_T_DEFINED
149
150ProcessList *processlist_construct(void);
151void processlist_destroy(ProcessList *process_list);
152GtkWidget *processlist_get_widget(ProcessList *process_list);
153
154void processlist_clear(ProcessList *process_list);
155
156// out : success (0) and height
157/* CPU num is only used for PID 0 */
67f72973 158//int resourcelist_add( ProcessList *process_list, Drawing_t *drawing, guint trace_num,
159// GQuark name, guint type, guint id, guint *height, ResourceInfo **pm_resource_info,
160// HashedResourceData **pm_hashed_resource_data, GQuark parent);
8743690d 161
9e01e6d4 162// out : success (0) and height
163int processlist_remove(ProcessList *process_list, guint pid, guint cpu,
164 LttTime *birth, guint trace_num);
165
166/* Set the name of a process */
167void processlist_set_name(ProcessList *process_list,
168 GQuark name,
58a9b31b 169 HashedResourceData *hashed_process_data);
9e01e6d4 170
171void processlist_set_brand(ProcessList *process_list,
172 GQuark brand,
58a9b31b 173 HashedResourceData *hashed_process_data);
9e01e6d4 174
175/* Set the ppid of a process */
176void processlist_set_tgid(ProcessList *process_list,
177 guint tgid,
58a9b31b 178 HashedResourceData *hashed_process_data);
9e01e6d4 179void processlist_set_ppid(ProcessList *process_list,
180 guint ppid,
58a9b31b 181 HashedResourceData *hashed_process_data);
9e01e6d4 182
183
184/* Synchronize the list at the left and the drawing */
185void update_index_to_pixmap(ProcessList *process_list);
186
187/* Update the width of each pixmap buffer for each process */
188void update_pixmap_size(ProcessList *process_list, guint width);
189
190
191/* Put src and/or dest to NULL to copy from/to the each PID specific pixmap */
192void copy_pixmap_region(ProcessList *process_list, GdkDrawable *dest,
193 GdkGC *gc, GdkDrawable *src,
194 gint xsrc, gint ysrc,
195 gint xdest, gint ydest, gint width, gint height);
196
197/* If height is -1, the height of each pixmap is used */
198void rectangle_pixmap(ProcessList *process_list, GdkGC *gc,
199 gboolean filled, gint x, gint y, gint width, gint height);
200
201/* Renders each pixmaps into on big drawable */
202void copy_pixmap_to_screen(ProcessList *process_list,
203 GdkDrawable *dest,
204 GdkGC *gc,
205 gint x, gint y,
206 gint width, gint height);
207
9e01e6d4 208static inline gint get_cell_height(GtkTreeView *TreeView)
209{
210 gint height;
211 GtkTreeViewColumn *column = gtk_tree_view_get_column(TreeView, 0);
212
213 gtk_tree_view_column_cell_get_size(column, NULL, NULL, NULL, NULL, &height);
214
215 gint vertical_separator;
216 gtk_widget_style_get (GTK_WIDGET (TreeView),
217 "vertical-separator", &vertical_separator,
218 NULL);
219 height += vertical_separator;
220
221 return height;
222}
223
224static inline guint processlist_get_height(ProcessList *process_list)
225{
226 return process_list->cell_height * process_list->number_of_process ;
227}
228
229
67f72973 230//static inline HashedResourceData *processlist_get_process_data(
231// ProcessList *process_list, GQuark resource_name, guint trace_num)
232//{
233// ResourceInfo resource_info;
234//
235//// process_info.pid = pid;
236//// if(pid == 0)
237//// process_info.cpu = cpu;
238//// else
239//// process_info.cpu = ANY_CPU;
240//// process_info.birth = *birth;
241//// process_info.trace_num = trace_num;
242// resource_info.name = resource_name;
243// resource_info.trace_num = trace_num;
244//
245// return (HashedResourceData*)g_hash_table_lookup(
246// process_list->process_hash,
247// &resource_info);
248//}
249//
9e01e6d4 250
251static inline gint processlist_get_pixels_from_data( ProcessList *process_list,
58a9b31b 252 HashedResourceData *hashed_process_data,
9e01e6d4 253 guint *y,
254 guint *height)
255{
256 gint *path_indices;
257 GtkTreePath *tree_path;
258
259 tree_path = gtk_tree_model_get_path((GtkTreeModel*)process_list->list_store,
260 &hashed_process_data->y_iter);
261 path_indices = gtk_tree_path_get_indices (tree_path);
262
263 *height = get_cell_height((GtkTreeView*)process_list->process_list_widget);
264 *y = *height * path_indices[0];
265 gtk_tree_path_free(tree_path);
266
267 return 0;
268
269}
270
271static inline guint processlist_get_index_from_data(ProcessList *process_list,
58a9b31b 272 HashedResourceData *hashed_process_data)
9e01e6d4 273{
274 gint *path_indices;
275 GtkTreePath *tree_path;
276 guint ret;
67f72973 277 gint depth;
9e01e6d4 278
279 tree_path = gtk_tree_model_get_path((GtkTreeModel*)process_list->list_store,
280 &hashed_process_data->y_iter);
281 path_indices = gtk_tree_path_get_indices (tree_path);
67f72973 282 depth = gtk_tree_path_get_depth(tree_path);
9e01e6d4 283
67f72973 284// ret = path_indices[1]+path_indices[0]+1;
9e01e6d4 285 ret = path_indices[0];
67f72973 286 if(depth>1)
287 ret+= 1+path_indices[1];
9e01e6d4 288
289 gtk_tree_path_free(tree_path);
290
291 return ret;
292}
293
67f72973 294/* Return the hash table used to store the data of each resource of a given resource type */
295
296static inline GHashTable *resourcelist_get_resource_hash_table(ControlFlowData *resourceview_data, guint type)
297{
298 return resourceview_data->process_list->restypes[type].hash_table;
299}
300
43ed82b5 301HashedResourceData *resourcelist_obtain_cpu(ControlFlowData *resourceview_data, guint trace_num, guint id);
302HashedResourceData *resourcelist_obtain_irq(ControlFlowData *resourceview_data, guint trace_num, guint id);
303HashedResourceData *resourcelist_obtain_soft_irq(ControlFlowData *resourceview_data, guint trace_num, guint id);
304HashedResourceData *resourcelist_obtain_trap(ControlFlowData *resourceview_data, guint trace_num, guint id);
305HashedResourceData *resourcelist_obtain_bdev(ControlFlowData *resourceview_data, guint trace_num, guint id);
9e01e6d4 306
307#endif // _PROCESS_LIST_H
This page took 0.056955 seconds and 4 git commands to generate.