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