1 /* This file is part of the Linux Trace Toolkit viewer
2 * Copyright (C) 2003-2004 Mathieu Desnoyers
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;
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.
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,
19 #ifndef _PROCESS_LIST_H
20 #define _PROCESS_LIST_H
24 #include <lttv/state.h>
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
43 /* Enumeration of the columns */
51 typedef struct _ResourceInfo
{
58 typedef struct _HashedResourceData
{
60 GdkPixmap
*pixmap
; // Pixmap slice containing drawing buffer for the PID
61 gint height
; // height of the pixmap
62 GtkTreeIter y_iter
; // Access quickly to y pos.
63 // DrawContext *draw_context;
64 /* Information on current drawing */
67 gboolean over_used
; /* inform the user that information is incomplete */
68 gboolean over_marked
; /* inform the user that information is incomplete */
70 gboolean middle_used
; /* inform the user that information is incomplete */
71 gboolean middle_marked
;/* inform the user that information is incomplete */
73 gboolean under_used
; /* inform the user that information is incomplete */
74 gboolean under_marked
; /* inform the user that information is incomplete */
75 } x
; /* last x position saved by after state update */
77 LttTime next_good_time
; /* precalculate the next time where the next
84 GtkWidget
*process_list_widget
;
85 GtkListStore
*list_store
;
86 GtkWidget
*button
; /* one button of the tree view */
87 GtkCellRenderer
*renderer
;
89 /* A hash table by PID to speed up process position find in the list */
90 GHashTable
*process_hash
;
92 guint number_of_process
;
95 /* Current process pointer, one per cpu, one per trace */
96 HashedResourceData
***current_hash_data
;
98 /* Array containing index -> pixmap correspondance. Must be updated
99 * every time the process list is reordered, process added or removed */
100 GPtrArray
* index_to_pixmap
;
105 typedef struct _ProcessList ProcessList
;
108 #ifndef TYPE_DRAWING_T_DEFINED
109 #define TYPE_DRAWING_T_DEFINED
110 typedef struct _Drawing_t Drawing_t
;
111 #endif //TYPE_DRAWING_T_DEFINED
113 ProcessList
*processlist_construct(void);
114 void processlist_destroy(ProcessList
*process_list
);
115 GtkWidget
*processlist_get_widget(ProcessList
*process_list
);
117 void processlist_clear(ProcessList
*process_list
);
119 // out : success (0) and height
120 /* CPU num is only used for PID 0 */
121 int processlist_add(ProcessList
*process_list
, Drawing_t
* drawing
,
122 guint pid
, guint tgid
, guint cpu
, guint ppid
,
123 LttTime
*birth
, guint trace_num
, GQuark name
, GQuark brand
, guint
*height
,
124 ResourceInfo
**process_info
,
125 HashedResourceData
**hashed_process_data
);
126 // out : success (0) and height
127 int processlist_remove(ProcessList
*process_list
, guint pid
, guint cpu
,
128 LttTime
*birth
, guint trace_num
);
130 /* Set the name of a process */
131 void processlist_set_name(ProcessList
*process_list
,
133 HashedResourceData
*hashed_process_data
);
135 void processlist_set_brand(ProcessList
*process_list
,
137 HashedResourceData
*hashed_process_data
);
139 /* Set the ppid of a process */
140 void processlist_set_tgid(ProcessList
*process_list
,
142 HashedResourceData
*hashed_process_data
);
143 void processlist_set_ppid(ProcessList
*process_list
,
145 HashedResourceData
*hashed_process_data
);
148 /* Synchronize the list at the left and the drawing */
149 void update_index_to_pixmap(ProcessList
*process_list
);
151 /* Update the width of each pixmap buffer for each process */
152 void update_pixmap_size(ProcessList
*process_list
, guint width
);
155 /* Put src and/or dest to NULL to copy from/to the each PID specific pixmap */
156 void copy_pixmap_region(ProcessList
*process_list
, GdkDrawable
*dest
,
157 GdkGC
*gc
, GdkDrawable
*src
,
158 gint xsrc
, gint ysrc
,
159 gint xdest
, gint ydest
, gint width
, gint height
);
161 /* If height is -1, the height of each pixmap is used */
162 void rectangle_pixmap(ProcessList
*process_list
, GdkGC
*gc
,
163 gboolean filled
, gint x
, gint y
, gint width
, gint height
);
165 /* Renders each pixmaps into on big drawable */
166 void copy_pixmap_to_screen(ProcessList
*process_list
,
170 gint width
, gint height
);
173 static inline gint
get_cell_height(GtkTreeView
*TreeView
)
176 GtkTreeViewColumn
*column
= gtk_tree_view_get_column(TreeView
, 0);
178 gtk_tree_view_column_cell_get_size(column
, NULL
, NULL
, NULL
, NULL
, &height
);
180 gint vertical_separator
;
181 gtk_widget_style_get (GTK_WIDGET (TreeView
),
182 "vertical-separator", &vertical_separator
,
184 height
+= vertical_separator
;
189 static inline guint
processlist_get_height(ProcessList
*process_list
)
191 return process_list
->cell_height
* process_list
->number_of_process
;
195 static inline HashedResourceData
*processlist_get_process_data(
196 ProcessList
*process_list
, GQuark resource_name
, guint trace_num
)
198 ResourceInfo resource_info
;
200 // process_info.pid = pid;
202 // process_info.cpu = cpu;
204 // process_info.cpu = ANY_CPU;
205 // process_info.birth = *birth;
206 // process_info.trace_num = trace_num;
207 resource_info
.name
= resource_name
;
208 resource_info
.trace_num
= trace_num
;
210 return (HashedResourceData
*)g_hash_table_lookup(
211 process_list
->process_hash
,
216 static inline gint
processlist_get_pixels_from_data( ProcessList
*process_list
,
217 HashedResourceData
*hashed_process_data
,
222 GtkTreePath
*tree_path
;
224 tree_path
= gtk_tree_model_get_path((GtkTreeModel
*)process_list
->list_store
,
225 &hashed_process_data
->y_iter
);
226 path_indices
= gtk_tree_path_get_indices (tree_path
);
228 *height
= get_cell_height((GtkTreeView
*)process_list
->process_list_widget
);
229 *y
= *height
* path_indices
[0];
230 gtk_tree_path_free(tree_path
);
236 static inline guint
processlist_get_index_from_data(ProcessList
*process_list
,
237 HashedResourceData
*hashed_process_data
)
240 GtkTreePath
*tree_path
;
243 tree_path
= gtk_tree_model_get_path((GtkTreeModel
*)process_list
->list_store
,
244 &hashed_process_data
->y_iter
);
245 path_indices
= gtk_tree_path_get_indices (tree_path
);
247 ret
= path_indices
[0];
249 gtk_tree_path_free(tree_path
);
256 #endif // _PROCESS_LIST_H