add state save/restore for bdevs + other fixes
[lttv.git] / ltt / branches / poly / lttv / modules / gui / resourceview / processlist.c
CommitLineData
9e01e6d4 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>
58a9b31b 29#
9e01e6d4 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)
58a9b31b 36//#define g_debug(format...) g_log (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, format)
9e01e6d4 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
58a9b31b 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//}
9e01e6d4 119
58a9b31b 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//}
9e01e6d4 145
58a9b31b 146static guint resource_list_hash_fct(gconstpointer key)
9e01e6d4 147{
58a9b31b 148 gchar *name = g_quark_to_string(((const ResourceInfo*)key)->name);
149 return g_str_hash(name);
9e01e6d4 150}
151
58a9b31b 152static gboolean resource_list_equ_fct(gconstpointer a, gconstpointer b)
9e01e6d4 153{
58a9b31b 154 const ResourceInfo *pa = (const ResourceInfo*)a;
155 const ResourceInfo *pb = (const ResourceInfo*)b;
9e01e6d4 156
157 gboolean ret = TRUE;
158
58a9b31b 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))
9e01e6d4 163 ret = FALSE;
164 if(unlikely(pa->trace_num != pb->trace_num))
165 ret = FALSE;
166
167 return ret;
168}
169
170void destroy_hash_key(gpointer key);
171
172void destroy_hash_data(gpointer data);
173
174
175gboolean 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
58a9b31b 201static void update_index_to_pixmap_each(ResourceInfo *key,
202 HashedResourceData *value,
9e01e6d4 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
216void 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
58a9b31b 226static void update_pixmap_size_each(ResourceInfo *key,
227 HashedResourceData *value,
9e01e6d4 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
242void 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
250typedef struct _CopyPixmap {
251 GdkDrawable *dest;
252 GdkGC *gc;
253 GdkDrawable *src;
254 gint xsrc, ysrc, xdest, ydest, width, height;
255} CopyPixmap;
256
58a9b31b 257static void copy_pixmap_region_each(ResourceInfo *key,
258 HashedResourceData *value,
9e01e6d4 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
9e01e6d4 277void 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
291typedef struct _RectanglePixmap {
292 gboolean filled;
293 gint x, y, width, height;
294 GdkGC *gc;
295} RectanglePixmap;
296
58a9b31b 297static void rectangle_pixmap_each(ResourceInfo *key,
298 HashedResourceData *value,
9e01e6d4 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
314void 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 */
326void 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 }
9e01e6d4 356}
357
9e01e6d4 358ProcessList *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
58a9b31b 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);
9e01e6d4 399
400
401 process_list->process_hash = g_hash_table_new_full(
58a9b31b 402 resource_list_hash_fct, resource_list_equ_fct,
9e01e6d4 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
c4e6f4dc 437 column = gtk_tree_view_column_new_with_attributes ( "Resource",
9e01e6d4 438 renderer,
439 "text",
58a9b31b 440 NAME_COLUMN,
9e01e6d4 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
c4e6f4dc 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);
9e01e6d4 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
531void 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
58a9b31b 542static gboolean remove_hash_item(ResourceInfo *process_info,
543 HashedResourceData *hashed_process_data,
9e01e6d4 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
58a9b31b 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// }
9e01e6d4 559 return TRUE; /* remove the element from the hash table */
560}
561
562void 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
574GtkWidget *processlist_get_widget(ProcessList *process_list)
575{
576 return process_list->process_list_widget;
577}
578
579
580void destroy_hash_key(gpointer key)
581{
582 g_free(key);
583}
584
585void destroy_hash_data(gpointer data)
586{
587 g_free(data);
588}
589
590
58a9b31b 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//}
9e01e6d4 626
c4e6f4dc 627int resourcelist_add( ProcessList *process_list,
9e01e6d4 628 Drawing_t *drawing,
58a9b31b 629 guint trace_num,
9e01e6d4 630 GQuark name,
44ffb95f 631 guint type,
632 guint id,
9e01e6d4 633 guint *height,
58a9b31b 634 ResourceInfo **pm_resource_info,
635 HashedResourceData **pm_hashed_resource_data)
9e01e6d4 636{
58a9b31b 637 ResourceInfo *Resource_Info = g_new(ResourceInfo, 1);
638 HashedResourceData *hashed_resource_data = g_new(HashedResourceData, 1);
c4e6f4dc 639 *pm_hashed_resource_data = hashed_resource_data;
640 *pm_resource_info = Resource_Info;
58a9b31b 641
642 Resource_Info->name = name;
9e01e6d4 643
c4e6f4dc 644// Process_Info->pid = pid;
645// Process_Info->tgid = tgid;
646// if(pid == 0)
647// Process_Info->cpu = cpu;
648// else
649// Process_Info->cpu = 0;
650// Process_Info->ppid = ppid;
651// Process_Info->birth = *birth;
58a9b31b 652 Resource_Info->trace_num = trace_num;
44ffb95f 653 Resource_Info->type = type;
654 Resource_Info->id = id;
9e01e6d4 655
656 /* When we create it from before state update, we are sure that the
657 * last event occured before the beginning of the global area.
658 *
659 * If it is created after state update, this value (0) will be
660 * overriden by the new state before anything is drawn.
c4e6f4dc 661 *
662 * There are 3 potential lines for the each process: one in the middle,
663 * one under it and one over it. The {over,middle,under} fields tell us
664 * the x pixel on the pixmap where we are. The _used fields tell us
665 * whether that pixel was used. The _marked field tells us if we marked a
666 * conflict point.
9e01e6d4 667 */
c4e6f4dc 668 hashed_resource_data->x.over = 0;
669 hashed_resource_data->x.over_used = FALSE;
670 hashed_resource_data->x.over_marked = FALSE;
671 hashed_resource_data->x.middle = 0; // last
672 hashed_resource_data->x.middle_used = FALSE;
673 hashed_resource_data->x.middle_marked = FALSE;
674 hashed_resource_data->x.under = 0;
675 hashed_resource_data->x.under_used = FALSE;
676 hashed_resource_data->x.under_marked = FALSE;
677 hashed_resource_data->next_good_time = ltt_time_zero;
9e01e6d4 678
679 /* Add a new row to the model */
680 gtk_list_store_append ( process_list->list_store,
58a9b31b 681 &hashed_resource_data->y_iter);
9e01e6d4 682
58a9b31b 683 gtk_list_store_set ( process_list->list_store, &hashed_resource_data->y_iter,
684 NAME_COLUMN, g_quark_to_string(name),
9e01e6d4 685 -1);
9e01e6d4 686
687 g_hash_table_insert(process_list->process_hash,
58a9b31b 688 (gpointer)Resource_Info,
689 (gpointer)hashed_resource_data);
9e01e6d4 690
c4e6f4dc 691 process_list->number_of_process++; // of resources
9e01e6d4 692
58a9b31b 693 hashed_resource_data->height = process_list->cell_height;
9e01e6d4 694
58a9b31b 695 g_assert(hashed_resource_data->height != 0);
9e01e6d4 696
58a9b31b 697 *height = hashed_resource_data->height * process_list->number_of_process;
9e01e6d4 698
58a9b31b 699 hashed_resource_data->pixmap =
9e01e6d4 700 gdk_pixmap_new(drawing->drawing_area->window,
701 drawing->alloc_width,
58a9b31b 702 hashed_resource_data->height,
9e01e6d4 703 -1);
704
c4e6f4dc 705 // Clear the image with black background
58a9b31b 706 gdk_draw_rectangle (hashed_resource_data->pixmap,
9e01e6d4 707 drawing->drawing_area->style->black_gc,
708 TRUE,
709 0, 0,
710 drawing->alloc_width,
58a9b31b 711 hashed_resource_data->height);
9e01e6d4 712
713 update_index_to_pixmap(process_list);
714
9e01e6d4 715 return 0;
716}
c4e6f4dc 717//int processlist_add( ProcessList *process_list,
718// Drawing_t *drawing,
719// guint pid,
720// guint tgid,
721// guint cpu,
722// guint ppid,
723// LttTime *birth,
724// guint trace_num,
725// GQuark name,
726// GQuark brand,
727// guint *height,
58a9b31b 728// ResourceInfo **pm_process_info,
729// HashedResourceData **pm_hashed_process_data)
c4e6f4dc 730//{
58a9b31b 731// ResourceInfo *Process_Info = g_new(ResourceInfo, 1);
732// HashedResourceData *hashed_process_data = g_new(HashedResourceData, 1);
c4e6f4dc 733// *pm_hashed_process_data = hashed_process_data;
734// *pm_process_info = Process_Info;
735//
736// Process_Info->pid = pid;
737// Process_Info->tgid = tgid;
738// if(pid == 0)
739// Process_Info->cpu = cpu;
740// else
741// Process_Info->cpu = 0;
742// Process_Info->ppid = ppid;
743// Process_Info->birth = *birth;
744// Process_Info->trace_num = trace_num;
745//
746// /* When we create it from before state update, we are sure that the
747// * last event occured before the beginning of the global area.
748// *
749// * If it is created after state update, this value (0) will be
750// * overriden by the new state before anything is drawn.
751// */
752// hashed_process_data->x.over = 0;
753// hashed_process_data->x.over_used = FALSE;
754// hashed_process_data->x.over_marked = FALSE;
755// hashed_process_data->x.middle = 0;
756// hashed_process_data->x.middle_used = FALSE;
757// hashed_process_data->x.middle_marked = FALSE;
758// hashed_process_data->x.under = 0;
759// hashed_process_data->x.under_used = FALSE;
760// hashed_process_data->x.under_marked = FALSE;
761// hashed_process_data->next_good_time = ltt_time_zero;
762//
763// /* Add a new row to the model */
764// gtk_list_store_append ( process_list->list_store,
765// &hashed_process_data->y_iter);
766//
767// gtk_list_store_set ( process_list->list_store, &hashed_process_data->y_iter,
768// PROCESS_COLUMN, g_quark_to_string(name),
769// BRAND_COLUMN, g_quark_to_string(brand),
770// PID_COLUMN, pid,
771// TGID_COLUMN, tgid,
772// PPID_COLUMN, ppid,
773// CPU_COLUMN, cpu,
774// BIRTH_S_COLUMN, birth->tv_sec,
775// BIRTH_NS_COLUMN, birth->tv_nsec,
776// TRACE_COLUMN, trace_num,
777// -1);
778// //gtk_tree_view_set_model(GTK_TREE_VIEW(process_list->process_list_widget),
779// // GTK_TREE_MODEL(process_list->list_store));
780// //gtk_container_resize_children(GTK_CONTAINER(process_list->process_list_widget));
781//
782// g_hash_table_insert(process_list->process_hash,
783// (gpointer)Process_Info,
784// (gpointer)hashed_process_data);
785//
786// process_list->number_of_process++;
787//
788// hashed_process_data->height = process_list->cell_height;
789//
790// g_assert(hashed_process_data->height != 0);
791//
792// *height = hashed_process_data->height * process_list->number_of_process;
793//
794// hashed_process_data->pixmap =
795// gdk_pixmap_new(drawing->drawing_area->window,
796// drawing->alloc_width,
797// hashed_process_data->height,
798// -1);
799//
800// // Clear the image
801// gdk_draw_rectangle (hashed_process_data->pixmap,
802// drawing->drawing_area->style->black_gc,
803// TRUE,
804// 0, 0,
805// drawing->alloc_width,
806// hashed_process_data->height);
807//
808// update_index_to_pixmap(process_list);
809//
810//
811// return 0;
812//}
9e01e6d4 813
58a9b31b 814// TODO pmf: make this work once again
815//int processlist_remove( ProcessList *process_list,
816// guint pid,
817// guint cpu,
818// LttTime *birth,
819// guint trace_num)
820//{
821// ResourceInfo process_info;
822// HashedResourceData *hashed_process_data;
823// GtkTreeIter iter;
824//
825// process_info.pid = pid;
826// if(pid == 0)
827// process_info.cpu = cpu;
828// else
829// process_info.cpu = 0;
830// process_info.birth = *birth;
831// process_info.trace_num = trace_num;
832//
833//
834// hashed_process_data =
835// (HashedResourceData*)g_hash_table_lookup(
836// process_list->process_hash,
837// &process_info);
838// if(likely(hashed_process_data != NULL))
839// {
840// iter = hashed_process_data->y_iter;
841//
842// gtk_list_store_remove (process_list->list_store, &iter);
843//
844// g_hash_table_remove(process_list->process_hash,
845// &process_info);
846//
847// if(likely(process_list->current_hash_data != NULL)) {
848// if(likely(hashed_process_data == process_list->current_hash_data[trace_num][cpu])) {
849// process_list->current_hash_data[trace_num][cpu] = NULL;
850// }
851// }
852//
853// gdk_pixmap_unref(hashed_process_data->pixmap);
854//
855// update_index_to_pixmap(process_list);
856//
857// process_list->number_of_process--;
858//
859// return 0;
860// } else {
861// return 1;
862// }
863//}
9e01e6d4 864
865
866#if 0
867static inline guint get_cpu_number_from_name(GQuark name)
868{
869 const gchar *string;
870 char *begin;
871 guint cpu;
872
873 string = g_quark_to_string(name);
874
875 begin = strrchr(string, '/');
876 begin++;
877
878 g_assert(begin != '\0');
879
880 cpu = strtoul(begin, NULL, 10);
881
882 return cpu;
883}
884#endif //0
This page took 0.060626 seconds and 4 git commands to generate.