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