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