e5f44a3f01c7b670e9870c69ace443ef4aa81feb
[lttv.git] / lttv / modules / gui / controlflow / processlist.c
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
19 #ifdef HAVE_CONFIG_H
20 #include <config.h>
21 #endif
22
23 #include <gtk/gtk.h>
24 #include <gdk/gdk.h>
25 #include <glib.h>
26 #include <string.h>
27 #include <stdlib.h>
28 #include <math.h>
29
30 #include "processlist.h"
31 #include "drawing.h"
32 #include "drawitem.h"
33
34 #define g_info(format...) g_log (G_LOG_DOMAIN, G_LOG_LEVEL_INFO, format)
35
36 /* Preallocated Size of the index_to_pixmap array */
37 #define ALLOCATE_PROCESSES 1000
38
39 /*****************************************************************************
40 * Methods to synchronize process list *
41 *****************************************************************************/
42
43
44 gint process_sort_func ( GtkTreeModel *model,
45 GtkTreeIter *it_a,
46 GtkTreeIter *it_b,
47 gpointer user_data)
48 {
49 gchar *a_name;
50 gchar *a_brand;
51 guint a_pid, a_tgid, a_ppid, a_cpu;
52 gulong a_birth_s, a_birth_ns;
53 guint a_trace;
54
55 gchar *b_name;
56 gchar *b_brand;
57 guint b_pid, b_tgid, b_ppid, b_cpu;
58 gulong b_birth_s, b_birth_ns;
59 guint b_trace;
60
61 gtk_tree_model_get(model,
62 it_a,
63 PROCESS_COLUMN, &a_name,
64 BRAND_COLUMN, &a_brand,
65 PID_COLUMN, &a_pid,
66 TGID_COLUMN, &a_tgid,
67 PPID_COLUMN, &a_ppid,
68 CPU_COLUMN, &a_cpu,
69 BIRTH_S_COLUMN, &a_birth_s,
70 BIRTH_NS_COLUMN, &a_birth_ns,
71 TRACE_COLUMN, &a_trace,
72 -1);
73
74 gtk_tree_model_get(model,
75 it_b,
76 PROCESS_COLUMN, &b_name,
77 BRAND_COLUMN, &b_brand,
78 PID_COLUMN, &b_pid,
79 TGID_COLUMN, &b_tgid,
80 PPID_COLUMN, &b_ppid,
81 CPU_COLUMN, &b_cpu,
82 BIRTH_S_COLUMN, &b_birth_s,
83 BIRTH_NS_COLUMN, &b_birth_ns,
84 TRACE_COLUMN, &b_trace,
85 -1);
86
87
88 /* Order by PID */
89 if(a_pid == 0 && b_pid == 0) {
90 /* If 0, order by CPU */
91 if(a_cpu > b_cpu) return 1;
92 if(a_cpu < b_cpu) return -1;
93
94 } else { /* if not 0, order by pid */
95
96 if(a_pid > b_pid) return 1;
97 if(a_pid < b_pid) return -1;
98 }
99
100 /* Order by birth second */
101
102 if(a_birth_s > b_birth_s) return 1;
103 if(a_birth_s < b_birth_s) return -1;
104
105
106 /* Order by birth nanosecond */
107 if(a_birth_ns > b_birth_ns) return 1;
108 if(a_birth_ns < b_birth_ns) return -1;
109
110 /* Order by trace_num */
111 if(a_trace > b_trace) return 1;
112 if(a_trace < b_trace) return -1;
113
114 return 0;
115
116 }
117
118 static guint process_list_hash_fct(gconstpointer key)
119 {
120 guint pid = ((const ProcessInfo*)key)->pid;
121 return ((pid>>8 ^ pid>>4 ^ pid>>2 ^ pid) ^ ((const ProcessInfo*)key)->cpu);
122 }
123
124 /* If hash is good, should be different */
125 static gboolean process_list_equ_fct(gconstpointer a, gconstpointer b)
126 {
127 const ProcessInfo *pa = (const ProcessInfo*)a;
128 const ProcessInfo *pb = (const ProcessInfo*)b;
129
130 gboolean ret = TRUE;
131
132 if(likely(pa->pid != pb->pid))
133 ret = FALSE;
134 if(likely((pa->pid == 0 && (pa->cpu != pb->cpu))))
135 ret = FALSE;
136 if(unlikely(ltt_time_compare(pa->birth, pb->birth) != 0))
137 ret = FALSE;
138 if(unlikely(pa->trace_num != pb->trace_num))
139 ret = FALSE;
140
141 return ret;
142 }
143
144 void destroy_hash_key(gpointer key);
145
146 void destroy_hash_data(gpointer data);
147
148
149 gboolean scroll_event(GtkWidget *widget, GdkEventScroll *event, gpointer data)
150 {
151 ControlFlowData *control_flow_data =
152 (ControlFlowData*)g_object_get_data(
153 G_OBJECT(widget),
154 "control_flow_data");
155 unsigned int cell_height =
156 get_cell_height(GTK_TREE_VIEW(control_flow_data->process_list->process_list_widget));
157
158 switch(event->direction) {
159 case GDK_SCROLL_UP:
160 gtk_adjustment_set_value(control_flow_data->v_adjust,
161 gtk_adjustment_get_value(control_flow_data->v_adjust) - cell_height);
162 break;
163 case GDK_SCROLL_DOWN:
164 gtk_adjustment_set_value(control_flow_data->v_adjust,
165 gtk_adjustment_get_value(control_flow_data->v_adjust) + cell_height);
166 break;
167 default:
168 g_error("should only scroll up and down.");
169 }
170 return TRUE;
171 }
172
173
174 static void update_index_to_pixmap_each(ProcessInfo *key,
175 HashedProcessData *value,
176 ProcessList *process_list)
177 {
178 guint array_index = processlist_get_index_from_data(process_list, value);
179
180 g_assert(array_index < process_list->index_to_pixmap->len);
181
182 GdkPixmap **pixmap =
183 (GdkPixmap**)&g_ptr_array_index(process_list->index_to_pixmap, array_index);
184
185 *pixmap = value->pixmap;
186 }
187
188
189 void update_index_to_pixmap(ProcessList *process_list)
190 {
191 g_ptr_array_set_size(process_list->index_to_pixmap,
192 g_hash_table_size(process_list->process_hash));
193 g_hash_table_foreach(process_list->process_hash,
194 (GHFunc)update_index_to_pixmap_each,
195 process_list);
196 }
197
198
199 static void update_pixmap_size_each(ProcessInfo *key,
200 HashedProcessData *value,
201 guint width)
202 {
203 GdkPixmap *old_pixmap = value->pixmap;
204
205 value->pixmap =
206 gdk_pixmap_new(old_pixmap,
207 width,
208 value->height,
209 -1);
210
211 gdk_pixmap_unref(old_pixmap);
212 }
213
214
215 void update_pixmap_size(ProcessList *process_list, guint width)
216 {
217 g_hash_table_foreach(process_list->process_hash,
218 (GHFunc)update_pixmap_size_each,
219 GUINT_TO_POINTER(width));
220 }
221
222
223 typedef struct _CopyPixmap {
224 GdkDrawable *dest;
225 GdkGC *gc;
226 GdkDrawable *src;
227 gint xsrc, ysrc, xdest, ydest, width, height;
228 } CopyPixmap;
229
230 static void copy_pixmap_region_each(ProcessInfo *key,
231 HashedProcessData *value,
232 CopyPixmap *cp)
233 {
234 GdkPixmap *src = cp->src;
235 GdkPixmap *dest = cp->dest;
236
237 if(dest == NULL)
238 dest = value->pixmap;
239 if(src == NULL)
240 src = value->pixmap;
241
242 gdk_draw_drawable (dest,
243 cp->gc,
244 src,
245 cp->xsrc, cp->ysrc,
246 cp->xdest, cp->ydest,
247 cp->width, cp->height);
248 }
249
250
251
252
253 void copy_pixmap_region(ProcessList *process_list, GdkDrawable *dest,
254 GdkGC *gc, GdkDrawable *src,
255 gint xsrc, gint ysrc,
256 gint xdest, gint ydest, gint width, gint height)
257 {
258 CopyPixmap cp = { dest, gc, src, xsrc, ysrc, xdest, ydest, width, height };
259
260 g_hash_table_foreach(process_list->process_hash,
261 (GHFunc)copy_pixmap_region_each,
262 &cp);
263 }
264
265
266
267 typedef struct _RectanglePixmap {
268 gboolean filled;
269 gint x, y, width, height;
270 GdkGC *gc;
271 } RectanglePixmap;
272
273 static void rectangle_pixmap_each(ProcessInfo *key,
274 HashedProcessData *value,
275 RectanglePixmap *rp)
276 {
277 if(rp->height == -1)
278 rp->height = value->height;
279
280 gdk_draw_rectangle (value->pixmap,
281 rp->gc,
282 rp->filled,
283 rp->x, rp->y,
284 rp->width, rp->height);
285 }
286
287
288
289
290 void rectangle_pixmap(ProcessList *process_list, GdkGC *gc,
291 gboolean filled, gint x, gint y, gint width, gint height)
292 {
293 RectanglePixmap rp = { filled, x, y, width, height, gc };
294
295 g_hash_table_foreach(process_list->process_hash,
296 (GHFunc)rectangle_pixmap_each,
297 &rp);
298 }
299
300
301 /* Renders each pixmaps into on big drawable */
302 void copy_pixmap_to_screen(ProcessList *process_list,
303 GdkDrawable *dest,
304 GdkGC *gc,
305 gint x, gint y,
306 gint width, gint height)
307 {
308 if(process_list->index_to_pixmap->len == 0) return;
309 guint cell_height = process_list->cell_height;
310
311 /* Get indexes */
312 gint begin = floor(y/(double)cell_height);
313 gint end = MIN(ceil((y+height)/(double)cell_height),
314 process_list->index_to_pixmap->len);
315 gint i;
316
317 for(i=begin; i<end; i++) {
318 g_assert(i<process_list->index_to_pixmap->len);
319 /* Render the pixmap to the screen */
320 GdkPixmap *pixmap =
321 //(GdkPixmap*)g_ptr_array_index(process_list->index_to_pixmap, i);
322 GDK_PIXMAP(g_ptr_array_index(process_list->index_to_pixmap, i));
323
324 gdk_draw_drawable (dest,
325 gc,
326 pixmap,
327 x, 0,
328 x, i*cell_height,
329 width, cell_height);
330
331 }
332
333
334 }
335
336
337
338
339
340
341
342
343
344 ProcessList *processlist_construct(void)
345 {
346 GtkTreeViewColumn *column;
347 GtkCellRenderer *renderer;
348
349 ProcessList* process_list = g_new(ProcessList,1);
350
351 process_list->number_of_process = 0;
352
353 process_list->current_hash_data = NULL;
354
355 /* Create the Process list */
356 process_list->list_store = gtk_list_store_new ( N_COLUMNS,
357 G_TYPE_STRING,
358 G_TYPE_STRING,
359 G_TYPE_UINT,
360 G_TYPE_UINT,
361 G_TYPE_UINT,
362 G_TYPE_UINT,
363 G_TYPE_ULONG,
364 G_TYPE_ULONG,
365 G_TYPE_UINT);
366
367
368 process_list->process_list_widget =
369 gtk_tree_view_new_with_model
370 (GTK_TREE_MODEL (process_list->list_store));
371
372 g_object_unref (G_OBJECT (process_list->list_store));
373
374 gtk_tree_sortable_set_default_sort_func(
375 GTK_TREE_SORTABLE(process_list->list_store),
376 process_sort_func,
377 NULL,
378 NULL);
379
380
381 gtk_tree_sortable_set_sort_column_id(
382 GTK_TREE_SORTABLE(process_list->list_store),
383 GTK_TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID,
384 GTK_SORT_ASCENDING);
385
386
387 process_list->process_hash = g_hash_table_new_full(
388 process_list_hash_fct, process_list_equ_fct,
389 destroy_hash_key, destroy_hash_data
390 );
391
392
393 gtk_tree_view_set_headers_visible(
394 GTK_TREE_VIEW(process_list->process_list_widget), TRUE);
395
396 /* Create a column, associating the "text" attribute of the
397 * cell_renderer to the first column of the model */
398 /* Columns alignment : 0.0 : Left 0.5 : Center 1.0 : Right */
399 renderer = gtk_cell_renderer_text_new ();
400 process_list->renderer = renderer;
401
402 /* Add a temporary row to the model to get the cell size when the first
403 * real process is added. */
404 GtkTreeIter iter;
405 GtkTreePath *path;
406 path = gtk_tree_path_new_first();
407 gtk_tree_model_get_iter (gtk_tree_view_get_model(GTK_TREE_VIEW(process_list->process_list_widget)), &iter, path);
408 gtk_list_store_append(process_list->list_store, &iter);
409 gtk_tree_path_free(path);
410
411 process_list->cell_height = 0; // not ready to get size yet.
412
413 column = gtk_tree_view_column_new_with_attributes ( "Process",
414 renderer,
415 "text",
416 PROCESS_COLUMN,
417 NULL);
418 gtk_tree_view_column_set_alignment (column, 0.0);
419 gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_GROW_ONLY);
420 gtk_tree_view_column_set_resizable(column, TRUE);
421 gtk_tree_view_append_column (
422 GTK_TREE_VIEW (process_list->process_list_widget), column);
423
424 process_list->button = column->button;
425
426 column = gtk_tree_view_column_new_with_attributes ( "Brand",
427 renderer,
428 "text",
429 BRAND_COLUMN,
430 NULL);
431 gtk_tree_view_column_set_alignment (column, 0.0);
432 gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_GROW_ONLY);
433 gtk_tree_view_column_set_resizable(column, TRUE);
434 gtk_tree_view_append_column (
435 GTK_TREE_VIEW (process_list->process_list_widget), column);
436
437 column = gtk_tree_view_column_new_with_attributes ( "PID",
438 renderer,
439 "text",
440 PID_COLUMN,
441 NULL);
442 gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_GROW_ONLY);
443 gtk_tree_view_column_set_resizable(column, TRUE);
444 gtk_tree_view_append_column (
445 GTK_TREE_VIEW (process_list->process_list_widget), column);
446
447 column = gtk_tree_view_column_new_with_attributes ( "TGID",
448 renderer,
449 "text",
450 TGID_COLUMN,
451 NULL);
452 gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_GROW_ONLY);
453 gtk_tree_view_column_set_resizable(column, TRUE);
454 gtk_tree_view_append_column (
455 GTK_TREE_VIEW (process_list->process_list_widget), column);
456
457 column = gtk_tree_view_column_new_with_attributes ( "PPID",
458 renderer,
459 "text",
460 PPID_COLUMN,
461 NULL);
462 gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_GROW_ONLY);
463 gtk_tree_view_column_set_resizable(column, TRUE);
464 gtk_tree_view_append_column (
465 GTK_TREE_VIEW (process_list->process_list_widget), column);
466
467 column = gtk_tree_view_column_new_with_attributes ( "CPU",
468 renderer,
469 "text",
470 CPU_COLUMN,
471 NULL);
472 gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_GROW_ONLY);
473 gtk_tree_view_column_set_resizable(column, TRUE);
474 gtk_tree_view_append_column (
475 GTK_TREE_VIEW (process_list->process_list_widget), column);
476
477 column = gtk_tree_view_column_new_with_attributes ( "Birth sec",
478 renderer,
479 "text",
480 BIRTH_S_COLUMN,
481 NULL);
482 gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_GROW_ONLY);
483 gtk_tree_view_column_set_resizable(column, TRUE);
484 gtk_tree_view_append_column (
485 GTK_TREE_VIEW (process_list->process_list_widget), column);
486
487 //gtk_tree_view_column_set_visible(column, 0);
488 //
489 column = gtk_tree_view_column_new_with_attributes ( "Birth nsec",
490 renderer,
491 "text",
492 BIRTH_NS_COLUMN,
493 NULL);
494 gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_GROW_ONLY);
495 gtk_tree_view_column_set_resizable(column, TRUE);
496 gtk_tree_view_append_column (
497 GTK_TREE_VIEW (process_list->process_list_widget), column);
498
499 column = gtk_tree_view_column_new_with_attributes ( "TRACE",
500 renderer,
501 "text",
502 TRACE_COLUMN,
503 NULL);
504 gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_GROW_ONLY);
505 gtk_tree_view_column_set_resizable(column, TRUE);
506 gtk_tree_view_append_column (
507 GTK_TREE_VIEW (process_list->process_list_widget), column);
508
509
510 //gtk_tree_view_column_set_visible(column, 0);
511
512 g_object_set_data_full(
513 G_OBJECT(process_list->process_list_widget),
514 "process_list_Data",
515 process_list,
516 (GDestroyNotify)processlist_destroy);
517
518 process_list->index_to_pixmap = g_ptr_array_sized_new(ALLOCATE_PROCESSES);
519
520 return process_list;
521 }
522
523 void processlist_destroy(ProcessList *process_list)
524 {
525 g_debug("processlist_destroy %p", process_list);
526 g_hash_table_destroy(process_list->process_hash);
527 process_list->process_hash = NULL;
528 g_ptr_array_free(process_list->index_to_pixmap, TRUE);
529
530 g_free(process_list);
531 g_debug("processlist_destroy end");
532 }
533
534 static gboolean remove_hash_item(ProcessInfo *process_info,
535 HashedProcessData *hashed_process_data,
536 ProcessList *process_list)
537 {
538 GtkTreeIter iter;
539
540 iter = hashed_process_data->y_iter;
541
542 gtk_list_store_remove (process_list->list_store, &iter);
543 gdk_pixmap_unref(hashed_process_data->pixmap);
544
545 if(likely(process_list->current_hash_data != NULL)) {
546 if(likely(hashed_process_data ==
547 process_list->current_hash_data[process_info->trace_num][process_info->cpu]))
548 process_list->current_hash_data[process_info->trace_num][process_info->cpu] = NULL;
549 }
550 return TRUE; /* remove the element from the hash table */
551 }
552
553 void processlist_clear(ProcessList *process_list)
554 {
555 g_info("processlist_clear %p", process_list);
556
557 g_hash_table_foreach_remove(process_list->process_hash,
558 (GHRFunc)remove_hash_item,
559 (gpointer)process_list);
560 process_list->number_of_process = 0;
561 update_index_to_pixmap(process_list);
562 }
563
564
565 GtkWidget *processlist_get_widget(ProcessList *process_list)
566 {
567 return process_list->process_list_widget;
568 }
569
570
571 void destroy_hash_key(gpointer key)
572 {
573 g_free(key);
574 }
575
576 void destroy_hash_data(gpointer data)
577 {
578 g_free(data);
579 }
580
581
582 void processlist_set_name(ProcessList *process_list,
583 GQuark name,
584 HashedProcessData *hashed_process_data)
585 {
586 gtk_list_store_set ( process_list->list_store, &hashed_process_data->y_iter,
587 PROCESS_COLUMN, g_quark_to_string(name),
588 -1);
589 }
590
591 void processlist_set_brand(ProcessList *process_list,
592 GQuark brand,
593 HashedProcessData *hashed_process_data)
594 {
595 gtk_list_store_set ( process_list->list_store, &hashed_process_data->y_iter,
596 BRAND_COLUMN, g_quark_to_string(brand),
597 -1);
598 }
599
600 void processlist_set_tgid(ProcessList *process_list,
601 guint tgid,
602 HashedProcessData *hashed_process_data)
603 {
604 gtk_list_store_set ( process_list->list_store, &hashed_process_data->y_iter,
605 TGID_COLUMN, tgid,
606 -1);
607 }
608
609 void processlist_set_ppid(ProcessList *process_list,
610 guint ppid,
611 HashedProcessData *hashed_process_data)
612 {
613 gtk_list_store_set ( process_list->list_store, &hashed_process_data->y_iter,
614 PPID_COLUMN, ppid,
615 -1);
616 }
617
618
619 int processlist_add( ProcessList *process_list,
620 Drawing_t *drawing,
621 guint pid,
622 guint tgid,
623 guint cpu,
624 guint ppid,
625 LttTime *birth,
626 guint trace_num,
627 GQuark name,
628 GQuark brand,
629 guint *height,
630 ProcessInfo **pm_process_info,
631 HashedProcessData **pm_hashed_process_data)
632 {
633 ProcessInfo *Process_Info = g_new(ProcessInfo, 1);
634 HashedProcessData *hashed_process_data = g_new(HashedProcessData, 1);
635 *pm_hashed_process_data = hashed_process_data;
636 *pm_process_info = Process_Info;
637
638 Process_Info->pid = pid;
639 Process_Info->tgid = tgid;
640 if(pid == 0)
641 Process_Info->cpu = cpu;
642 else
643 Process_Info->cpu = 0;
644 Process_Info->ppid = ppid;
645 Process_Info->birth = *birth;
646 Process_Info->trace_num = trace_num;
647
648 /* When we create it from before state update, we are sure that the
649 * last event occured before the beginning of the global area.
650 *
651 * If it is created after state update, this value (0) will be
652 * overriden by the new state before anything is drawn.
653 */
654 hashed_process_data->x.over = 0;
655 hashed_process_data->x.over_used = FALSE;
656 hashed_process_data->x.over_marked = FALSE;
657 hashed_process_data->x.middle = 0;
658 hashed_process_data->x.middle_used = FALSE;
659 hashed_process_data->x.middle_marked = FALSE;
660 hashed_process_data->x.under = 0;
661 hashed_process_data->x.under_used = FALSE;
662 hashed_process_data->x.under_marked = FALSE;
663 hashed_process_data->next_good_time = ltt_time_zero;
664
665 if (process_list->cell_height == 0) {
666 GtkTreePath *path;
667 GdkRectangle rect;
668 GtkTreeIter iter;
669
670 path = gtk_tree_path_new_first();
671 gtk_tree_model_get_iter (gtk_tree_view_get_model(GTK_TREE_VIEW(process_list->process_list_widget)), &iter, path);
672 gtk_tree_view_get_background_area(
673 GTK_TREE_VIEW(process_list->process_list_widget),
674 path, NULL, &rect);
675 gtk_list_store_remove(process_list->list_store, &iter);
676 gtk_tree_path_free (path);
677 process_list->cell_height = rect.height;
678 }
679
680 /* Add a new row to the model */
681 gtk_list_store_append ( process_list->list_store,
682 &hashed_process_data->y_iter);
683
684 gtk_list_store_set ( process_list->list_store, &hashed_process_data->y_iter,
685 PROCESS_COLUMN, g_quark_to_string(name),
686 BRAND_COLUMN, g_quark_to_string(brand),
687 PID_COLUMN, pid,
688 TGID_COLUMN, tgid,
689 PPID_COLUMN, ppid,
690 CPU_COLUMN, cpu,
691 BIRTH_S_COLUMN, birth->tv_sec,
692 BIRTH_NS_COLUMN, birth->tv_nsec,
693 TRACE_COLUMN, trace_num,
694 -1);
695 //gtk_tree_view_set_model(GTK_TREE_VIEW(process_list->process_list_widget),
696 // GTK_TREE_MODEL(process_list->list_store));
697 //gtk_container_resize_children(GTK_CONTAINER(process_list->process_list_widget));
698
699 g_hash_table_insert(process_list->process_hash,
700 (gpointer)Process_Info,
701 (gpointer)hashed_process_data);
702
703 process_list->number_of_process++;
704 #if 0
705 GtkTreePath *path;
706 GdkRectangle rect;
707 gtk_widget_queue_draw(process_list->process_list_widget);
708 path = gtk_tree_path_new_first();
709 gtk_tree_view_get_background_area(GTK_TREE_VIEW(process_list->process_list_widget),
710 path, NULL, &rect);
711 gtk_tree_path_free (path);
712 process_list->cell_height = rect.height;
713 #endif //0
714
715
716 hashed_process_data->height = process_list->cell_height;
717 g_assert(hashed_process_data->height != 0);
718
719 *height = hashed_process_data->height * process_list->number_of_process;
720
721 hashed_process_data->pixmap =
722 gdk_pixmap_new(drawing->drawing_area->window,
723 drawing->alloc_width,
724 hashed_process_data->height,
725 -1);
726
727 // Clear the image
728 gdk_draw_rectangle (hashed_process_data->pixmap,
729 drawing->drawing_area->style->black_gc,
730 TRUE,
731 0, 0,
732 drawing->alloc_width,
733 hashed_process_data->height);
734
735 update_index_to_pixmap(process_list);
736
737
738 return 0;
739 }
740
741 int processlist_remove( ProcessList *process_list,
742 guint pid,
743 guint cpu,
744 LttTime *birth,
745 guint trace_num)
746 {
747 ProcessInfo process_info;
748 HashedProcessData *hashed_process_data;
749 GtkTreeIter iter;
750
751 process_info.pid = pid;
752 if(pid == 0)
753 process_info.cpu = cpu;
754 else
755 process_info.cpu = 0;
756 process_info.birth = *birth;
757 process_info.trace_num = trace_num;
758
759
760 hashed_process_data =
761 (HashedProcessData*)g_hash_table_lookup(
762 process_list->process_hash,
763 &process_info);
764 if(likely(hashed_process_data != NULL))
765 {
766 iter = hashed_process_data->y_iter;
767
768 gtk_list_store_remove (process_list->list_store, &iter);
769
770 g_hash_table_remove(process_list->process_hash,
771 &process_info);
772
773 if(likely(process_list->current_hash_data != NULL)) {
774 if(likely(hashed_process_data == process_list->current_hash_data[trace_num][cpu])) {
775 process_list->current_hash_data[trace_num][cpu] = NULL;
776 }
777 }
778
779 gdk_pixmap_unref(hashed_process_data->pixmap);
780
781 update_index_to_pixmap(process_list);
782
783 process_list->number_of_process--;
784
785 return 0;
786 } else {
787 return 1;
788 }
789 }
790
791
792 #if 0
793 static inline guint get_cpu_number_from_name(GQuark name)
794 {
795 const gchar *string;
796 char *begin;
797 guint cpu;
798
799 string = g_quark_to_string(name);
800
801 begin = strrchr(string, '/');
802 begin++;
803
804 g_assert(begin != '\0');
805
806 cpu = strtoul(begin, NULL, 10);
807
808 return cpu;
809 }
810 #endif //0
This page took 0.043956 seconds and 3 git commands to generate.