resourceview remove expanders
[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>
29
30#include "processlist.h"
31#include "drawing.h"
32#include "drawitem.h"
33
34#define g_info(format...) g_log (G_LOG_DOMAIN, G_LOG_LEVEL_INFO, format)
58a9b31b 35//#define g_debug(format...) g_log (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, format)
9e01e6d4 36
37/* Preallocated Size of the index_to_pixmap array */
38#define ALLOCATE_PROCESSES 1000
39
40/*****************************************************************************
41 * Methods to synchronize process list *
42 *****************************************************************************/
43
44
fb93b151 45gint resource_sort_func ( GtkTreeModel *model,
46 GtkTreeIter *it_a,
47 GtkTreeIter *it_b,
48 gpointer user_data)
49{
50 gchar *a_name;
51 gchar *b_name;
52
53 gtk_tree_model_get(model, it_a, NAME_COLUMN, &a_name, -1);
54
55 gtk_tree_model_get(model, it_b, NAME_COLUMN, &b_name, -1);
56
57 return strcmp(a_name, b_name);
58}
9e01e6d4 59
67f72973 60static guint ru_numeric_hash_fct(gconstpointer key)
9e01e6d4 61{
d0e4ae2f 62 ResourceUniqueNumeric *ru = (ResourceUniqueNumeric *)key;
67f72973 63 int tmp = (ru->trace_num << 8) ^ ru->id;
64
65 return g_int_hash(&tmp);
9e01e6d4 66}
67
67f72973 68static gboolean ru_numeric_equ_fct(gconstpointer a, gconstpointer b)
9e01e6d4 69{
67f72973 70 const ResourceUniqueNumeric *pa = (const ResourceUniqueNumeric *)a;
71 const ResourceUniqueNumeric *pb = (const ResourceUniqueNumeric *)b;
9e01e6d4 72
67f72973 73 if(pa->id == pb->id && pa->trace_num == pb->trace_num)
74 return TRUE;
9e01e6d4 75
67f72973 76 return FALSE;
9e01e6d4 77}
78
79void destroy_hash_key(gpointer key);
80
81void destroy_hash_data(gpointer data);
82
83
84gboolean scroll_event(GtkWidget *widget, GdkEventScroll *event, gpointer data)
85{
86 ControlFlowData *control_flow_data =
87 (ControlFlowData*)g_object_get_data(
88 G_OBJECT(widget),
67f72973 89 "resourceview_data");
9e01e6d4 90 Drawing_t *drawing = control_flow_data->drawing;
91 unsigned int cell_height =
92 get_cell_height(GTK_TREE_VIEW(control_flow_data->process_list->process_list_widget));
93
94 switch(event->direction) {
95 case GDK_SCROLL_UP:
96 gtk_adjustment_set_value(control_flow_data->v_adjust,
97 gtk_adjustment_get_value(control_flow_data->v_adjust) - cell_height);
98 break;
99 case GDK_SCROLL_DOWN:
100 gtk_adjustment_set_value(control_flow_data->v_adjust,
101 gtk_adjustment_get_value(control_flow_data->v_adjust) + cell_height);
102 break;
103 default:
104 g_error("should only scroll up and down.");
105 }
106 return TRUE;
107}
108
67f72973 109static gboolean update_index_to_pixmap_each (GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, UpdateIndexPixmapArg *arg)
9e01e6d4 110{
67f72973 111 guint array_index = arg->count;
112 HashedResourceData *hdata;
113 gchar *name;
114
115 gtk_tree_model_get(model, iter, NAME_COLUMN, &name, DATA_COLUMN, &hdata, -1);
116
117 g_assert(array_index < arg->process_list->index_to_pixmap->len);
9e01e6d4 118
67f72973 119 GdkPixmap **pixmap =
120 (GdkPixmap**)&g_ptr_array_index(arg->process_list->index_to_pixmap, array_index);
121 *pixmap = hdata->pixmap;
9e01e6d4 122
67f72973 123 arg->count++;
9e01e6d4 124
67f72973 125 return FALSE;
9e01e6d4 126}
127
9e01e6d4 128void update_index_to_pixmap(ProcessList *process_list)
129{
67f72973 130 int i, items=0;
131 UpdateIndexPixmapArg arg;
132
133 for(i=0; i<RV_RESOURCE_COUNT; i++) {
134 items += g_hash_table_size(process_list->restypes[i].hash_table);
135 }
136
137 g_ptr_array_set_size(process_list->index_to_pixmap, items);
138
139 arg.count = 0;
140 arg.process_list = process_list;
141
d0e4ae2f 142 gtk_tree_model_foreach(GTK_TREE_MODEL(process_list->list_store),
67f72973 143 (GtkTreeModelForeachFunc)update_index_to_pixmap_each, &arg);
9e01e6d4 144}
145
146
67f72973 147static void update_pixmap_size_each(void *key,
58a9b31b 148 HashedResourceData *value,
9e01e6d4 149 guint width)
150{
151 GdkPixmap *old_pixmap = value->pixmap;
152
153 value->pixmap =
154 gdk_pixmap_new(old_pixmap,
155 width,
156 value->height,
157 -1);
158
159 gdk_pixmap_unref(old_pixmap);
160}
161
162
163void update_pixmap_size(ProcessList *process_list, guint width)
164{
67f72973 165 int i;
166 for(i=0; i<RV_RESOURCE_COUNT; i++) {
167 g_hash_table_foreach(process_list->restypes[i].hash_table,
9e01e6d4 168 (GHFunc)update_pixmap_size_each,
169 (gpointer)width);
67f72973 170 }
9e01e6d4 171}
172
173
174typedef struct _CopyPixmap {
175 GdkDrawable *dest;
176 GdkGC *gc;
177 GdkDrawable *src;
178 gint xsrc, ysrc, xdest, ydest, width, height;
179} CopyPixmap;
180
67f72973 181static void copy_pixmap_region_each(void *key,
58a9b31b 182 HashedResourceData *value,
9e01e6d4 183 CopyPixmap *cp)
184{
185 GdkPixmap *src = cp->src;
186 GdkPixmap *dest = cp->dest;
187
188 if(dest == NULL)
189 dest = value->pixmap;
190 if(src == NULL)
191 src = value->pixmap;
192
193 gdk_draw_drawable (dest,
194 cp->gc,
195 src,
196 cp->xsrc, cp->ysrc,
197 cp->xdest, cp->ydest,
198 cp->width, cp->height);
199}
200
9e01e6d4 201void copy_pixmap_region(ProcessList *process_list, GdkDrawable *dest,
202 GdkGC *gc, GdkDrawable *src,
203 gint xsrc, gint ysrc,
204 gint xdest, gint ydest, gint width, gint height)
205{
67f72973 206 int i;
9e01e6d4 207 CopyPixmap cp = { dest, gc, src, xsrc, ysrc, xdest, ydest, width, height };
208
67f72973 209 for(i=0; i<RV_RESOURCE_COUNT; i++) {
210 g_hash_table_foreach(process_list->restypes[i].hash_table,
9e01e6d4 211 (GHFunc)copy_pixmap_region_each,
212 &cp);
67f72973 213 }
9e01e6d4 214}
215
216
217
218typedef struct _RectanglePixmap {
219 gboolean filled;
220 gint x, y, width, height;
221 GdkGC *gc;
222} RectanglePixmap;
223
67f72973 224static void rectangle_pixmap_each(void *key,
58a9b31b 225 HashedResourceData *value,
9e01e6d4 226 RectanglePixmap *rp)
227{
228 if(rp->height == -1)
229 rp->height = value->height;
230
231 gdk_draw_rectangle (value->pixmap,
232 rp->gc,
233 rp->filled,
234 rp->x, rp->y,
235 rp->width, rp->height);
236}
237
9e01e6d4 238void rectangle_pixmap(ProcessList *process_list, GdkGC *gc,
239 gboolean filled, gint x, gint y, gint width, gint height)
240{
67f72973 241 int i;
9e01e6d4 242 RectanglePixmap rp = { filled, x, y, width, height, gc };
243
67f72973 244 for(i=0; i<RV_RESOURCE_COUNT; i++) {
245 g_hash_table_foreach(process_list->restypes[i].hash_table,
9e01e6d4 246 (GHFunc)rectangle_pixmap_each,
247 &rp);
67f72973 248 }
9e01e6d4 249}
250
9e01e6d4 251/* Renders each pixmaps into on big drawable */
252void copy_pixmap_to_screen(ProcessList *process_list,
253 GdkDrawable *dest,
254 GdkGC *gc,
255 gint x, gint y,
256 gint width, gint height)
257{
258 if(process_list->index_to_pixmap->len == 0) return;
259 guint cell_height = process_list->cell_height;
260
261 /* Get indexes */
262 gint begin = floor(y/(double)cell_height);
263 gint end = MIN(ceil((y+height)/(double)cell_height),
264 process_list->index_to_pixmap->len);
265 gint i;
266
267 for(i=begin; i<end; i++) {
268 g_assert(i<process_list->index_to_pixmap->len);
269 /* Render the pixmap to the screen */
270 GdkPixmap *pixmap =
271 //(GdkPixmap*)g_ptr_array_index(process_list->index_to_pixmap, i);
272 GDK_PIXMAP(g_ptr_array_index(process_list->index_to_pixmap, i));
273
274 gdk_draw_drawable (dest,
275 gc,
276 pixmap,
277 x, 0,
278 x, i*cell_height,
279 width, cell_height);
280
281 }
9e01e6d4 282}
283
9e01e6d4 284ProcessList *processlist_construct(void)
285{
286 GtkTreeViewColumn *column;
287 GtkCellRenderer *renderer;
288
289 ProcessList* process_list = g_new(ProcessList,1);
290
291 process_list->number_of_process = 0;
292
293 process_list->current_hash_data = NULL;
294
295 /* Create the Process list */
67f72973 296 process_list->list_store = gtk_tree_store_new ( N_COLUMNS, G_TYPE_STRING, G_TYPE_POINTER);
9e01e6d4 297
298 process_list->process_list_widget =
299 gtk_tree_view_new_with_model
300 (GTK_TREE_MODEL (process_list->list_store));
43805632 301
302 gtk_tree_view_set_show_expanders(
303 GTK_TREE_VIEW(process_list->process_list_widget), FALSE);
304 gtk_tree_view_set_level_indentation(
305 process_list->process_list_widget, 20);
306
307 gtk_tree_view_set_enable_tree_lines(process_list->process_list_widget, TRUE);
9e01e6d4 308
309 g_object_unref (G_OBJECT (process_list->list_store));
310
fb93b151 311 gtk_tree_sortable_set_default_sort_func(
312 GTK_TREE_SORTABLE(process_list->list_store),
313 resource_sort_func,
314 NULL,
315 NULL);
316
fb93b151 317 gtk_tree_sortable_set_sort_column_id(
318 GTK_TREE_SORTABLE(process_list->list_store),
319 GTK_TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID,
320 GTK_SORT_ASCENDING);
9e01e6d4 321
9e01e6d4 322 gtk_tree_view_set_headers_visible(
323 GTK_TREE_VIEW(process_list->process_list_widget), TRUE);
324
325 /* Create a column, associating the "text" attribute of the
326 * cell_renderer to the first column of the model */
327 /* Columns alignment : 0.0 : Left 0.5 : Center 1.0 : Right */
328 renderer = gtk_cell_renderer_text_new ();
329 process_list->renderer = renderer;
330
331 gint vertical_separator;
332 gtk_widget_style_get (GTK_WIDGET (process_list->process_list_widget),
333 "vertical-separator", &vertical_separator,
334 NULL);
335 gtk_cell_renderer_get_size(renderer,
336 GTK_WIDGET(process_list->process_list_widget),
337 NULL,
338 NULL,
339 NULL,
340 NULL,
341 &process_list->cell_height);
342
343#if GTK_CHECK_VERSION(2,4,15)
344 guint ypad;
345 g_object_get(G_OBJECT(renderer), "ypad", &ypad, NULL);
346
347 process_list->cell_height += ypad;
348#endif
349 process_list->cell_height += vertical_separator;
350
351
c4e6f4dc 352 column = gtk_tree_view_column_new_with_attributes ( "Resource",
9e01e6d4 353 renderer,
354 "text",
58a9b31b 355 NAME_COLUMN,
9e01e6d4 356 NULL);
357 gtk_tree_view_column_set_alignment (column, 0.0);
358 gtk_tree_view_column_set_fixed_width (column, 45);
359 gtk_tree_view_append_column (
360 GTK_TREE_VIEW (process_list->process_list_widget), column);
361
362 process_list->button = column->button;
9e01e6d4 363
364 g_object_set_data_full(
365 G_OBJECT(process_list->process_list_widget),
366 "process_list_Data",
367 process_list,
368 (GDestroyNotify)processlist_destroy);
369
370 process_list->index_to_pixmap = g_ptr_array_sized_new(ALLOCATE_PROCESSES);
67f72973 371
372 process_list->restypes[RV_RESOURCE_MACHINE].hash_table = g_hash_table_new(ru_numeric_hash_fct, ru_numeric_equ_fct);
373 process_list->restypes[RV_RESOURCE_CPU].hash_table = g_hash_table_new(ru_numeric_hash_fct, ru_numeric_equ_fct);
374 process_list->restypes[RV_RESOURCE_IRQ].hash_table = g_hash_table_new(ru_numeric_hash_fct, ru_numeric_equ_fct);
375 process_list->restypes[RV_RESOURCE_BDEV].hash_table = g_hash_table_new(ru_numeric_hash_fct, ru_numeric_equ_fct);
43805632 376
9e01e6d4 377 return process_list;
378}
379
380void processlist_destroy(ProcessList *process_list)
381{
67f72973 382 int i;
383
9e01e6d4 384 g_debug("processlist_destroy %p", process_list);
67f72973 385
386 for(i=0; i<RV_RESOURCE_COUNT; i++) {
387 g_hash_table_destroy(process_list->restypes[i].hash_table);
388 process_list->restypes[i].hash_table = NULL;
389 }
9e01e6d4 390 g_ptr_array_free(process_list->index_to_pixmap, TRUE);
391
392 g_free(process_list);
393 g_debug("processlist_destroy end");
394}
395
67f72973 396static gboolean remove_hash_item(void *key,
58a9b31b 397 HashedResourceData *hashed_process_data,
9e01e6d4 398 ProcessList *process_list)
399{
400 GtkTreeIter iter;
401
402 iter = hashed_process_data->y_iter;
403
67f72973 404 gtk_tree_store_remove (process_list->list_store, &iter);
9e01e6d4 405 gdk_pixmap_unref(hashed_process_data->pixmap);
406
58a9b31b 407// TODO pmf: check this; might be needed
408// if(likely(process_list->current_hash_data != NULL)) {
409// if(likely(hashed_process_data ==
410// process_list->current_hash_data[process_info->trace_num][process_info->cpu]))
411// process_list->current_hash_data[process_info->trace_num][process_info->cpu] = NULL;
412// }
9e01e6d4 413 return TRUE; /* remove the element from the hash table */
414}
415
416void processlist_clear(ProcessList *process_list)
417{
67f72973 418 int i;
419
9e01e6d4 420 g_info("processlist_clear %p", process_list);
421
67f72973 422 for(i=RV_RESOURCE_COUNT-1; i>=0; i--) {
423 g_hash_table_foreach_remove(process_list->restypes[i].hash_table,
424 (GHRFunc)remove_hash_item,
425 (gpointer)process_list);
426 }
9e01e6d4 427 process_list->number_of_process = 0;
428 update_index_to_pixmap(process_list);
429}
430
431
432GtkWidget *processlist_get_widget(ProcessList *process_list)
433{
434 return process_list->process_list_widget;
435}
436
437
438void destroy_hash_key(gpointer key)
439{
440 g_free(key);
441}
442
443void destroy_hash_data(gpointer data)
444{
445 g_free(data);
446}
447
67f72973 448HashedResourceData *resourcelist_obtain_machine(ControlFlowData *resourceview_data, guint trace_num, guint id)
9e01e6d4 449{
67f72973 450 ResourceUniqueNumeric *ru = g_new(ResourceUniqueNumeric, 1);
451 HashedResourceData *data = g_new(HashedResourceData, 1);
452
453 /* Prepare hash key */
454 ru->trace_num = trace_num;
455 ru->id = id;
456
457 /* Search within hash table */
458 GHashTable *ht = resourceview_data->process_list->restypes[RV_RESOURCE_MACHINE].hash_table;
459 data = g_hash_table_lookup(ht, ru);
460
461 /* If not found in hash table, add it */
462 if(data == NULL) {
463 GQuark name;
464
465 data = g_malloc(sizeof(HashedResourceData));
466 /* Prepare hashed data */
467 data->type = RV_RESOURCE_MACHINE;
468 data->x.over = 0;
469 data->x.over_used = FALSE;
470 data->x.over_marked = FALSE;
471 data->x.middle = 0; // last
472 data->x.middle_used = FALSE;
473 data->x.middle_marked = FALSE;
474 data->x.under = 0;
475 data->x.under_used = FALSE;
476 data->x.under_marked = FALSE;
477 data->next_good_time = ltt_time_zero;
478
479 data->height = resourceview_data->process_list->cell_height;
480 data->pixmap =
481 gdk_pixmap_new(resourceview_data->drawing->drawing_area->window,
482 resourceview_data->drawing->alloc_width,
483 data->height,
484 -1);
485 g_assert(data->pixmap);
58a9b31b 486
67f72973 487 gdk_draw_rectangle (data->pixmap,
488 resourceview_data->drawing->drawing_area->style->black_gc,
489 TRUE,
490 0, 0,
491 resourceview_data->drawing->alloc_width,
492 data->height);
493
494 /* add to hash table */
495 g_hash_table_insert(ht, ru, data);
496 resourceview_data->process_list->number_of_process++; // TODO: check
497
498 /* add to process list */
499 {
500 gchar *str;
501 str = g_strdup_printf("Trace %u", id);
502 name = g_quark_from_string(str);
503 g_free(str);
504 }
505
506 gtk_tree_store_append(resourceview_data->process_list->list_store, &data->y_iter, NULL);
507 gtk_tree_store_set(resourceview_data->process_list->list_store, &data->y_iter,
508 NAME_COLUMN, g_quark_to_string(name), DATA_COLUMN, data,
509 -1);
510
511 update_index_to_pixmap(resourceview_data->process_list);
512
513 int heightall = data->height * resourceview_data->process_list->number_of_process;
514
515 gtk_widget_set_size_request(resourceview_data->drawing->drawing_area,
516 -1,
517 heightall);
9e01e6d4 518
67f72973 519 gtk_widget_queue_draw(resourceview_data->drawing->drawing_area);
520 }
521
d0e4ae2f 522 gtk_tree_view_expand_all(GTK_TREE_VIEW(resourceview_data->process_list->process_list_widget));
67f72973 523
524 return data;
525}
526
527HashedResourceData *resourcelist_obtain_cpu(ControlFlowData *resourceview_data, guint trace_num, guint id)
528{
529 ResourceUniqueNumeric *ru = g_new(ResourceUniqueNumeric, 1);
530 HashedResourceData *data = g_new(HashedResourceData, 1);
9e01e6d4 531
67f72973 532 /* Prepare hash key */
533 ru->trace_num = trace_num;
534 ru->id = id;
9e01e6d4 535
67f72973 536 /* Search within hash table */
537 GHashTable *ht = resourceview_data->process_list->restypes[RV_RESOURCE_CPU].hash_table;
538 data = g_hash_table_lookup(ht, ru);
539
540 /* If not found in hash table, add it */
541 if(data == NULL) {
542 GQuark name;
543 HashedResourceData *parent;
544
545 /* Find the parent machine */
546 parent = resourcelist_obtain_machine(resourceview_data, trace_num, trace_num);
547
548 /* Prepare hashed data */
549 data = g_malloc(sizeof(HashedResourceData));
550
551 data->type = RV_RESOURCE_CPU;
552 data->x.over = 0;
553 data->x.over_used = FALSE;
554 data->x.over_marked = FALSE;
555 data->x.middle = 0; // last
556 data->x.middle_used = FALSE;
557 data->x.middle_marked = FALSE;
558 data->x.under = 0;
559 data->x.under_used = FALSE;
560 data->x.under_marked = FALSE;
561 data->next_good_time = ltt_time_zero;
562
563 data->height = resourceview_data->process_list->cell_height;
564 data->pixmap =
565 gdk_pixmap_new(resourceview_data->drawing->drawing_area->window,
566 resourceview_data->drawing->alloc_width,
567 data->height,
568 -1);
569
570 gdk_draw_rectangle (data->pixmap,
571 resourceview_data->drawing->drawing_area->style->black_gc,
572 TRUE,
573 0, 0,
574 resourceview_data->drawing->alloc_width,
575 data->height);
9e01e6d4 576
67f72973 577 /* add to hash table */
578 g_hash_table_insert(ht, ru, data);
579 resourceview_data->process_list->number_of_process++; // TODO: check
9e01e6d4 580
67f72973 581 /* add to process list */
582 {
583 gchar *str;
584 str = g_strdup_printf("CPU%u", id);
585 name = g_quark_from_string(str);
586 g_free(str);
587 }
9e01e6d4 588
67f72973 589 gtk_tree_store_append(resourceview_data->process_list->list_store, &data->y_iter, &parent->y_iter);
590 gtk_tree_store_set(resourceview_data->process_list->list_store, &data->y_iter,
591 NAME_COLUMN, g_quark_to_string(name), DATA_COLUMN, data,
592 -1);
9e01e6d4 593
67f72973 594 update_index_to_pixmap(resourceview_data->process_list);
595
596 int heightall = data->height * resourceview_data->process_list->number_of_process;
597
598 gtk_widget_set_size_request(resourceview_data->drawing->drawing_area,
599 -1,
600 heightall);
601
602 gtk_widget_queue_draw(resourceview_data->drawing->drawing_area);
603 }
604
605 return data;
606}
607
608HashedResourceData *resourcelist_obtain_irq(ControlFlowData *resourceview_data, guint trace_num, guint id)
609{
610 ResourceUniqueNumeric *ru = g_new(ResourceUniqueNumeric, 1);
611 HashedResourceData *data = g_new(HashedResourceData, 1);
612
613 /* Prepare hash key */
614 ru->trace_num = trace_num;
615 ru->id = id;
9e01e6d4 616
67f72973 617 /* Search within hash table */
618 GHashTable *ht = resourceview_data->process_list->restypes[RV_RESOURCE_IRQ].hash_table;
619 data = g_hash_table_lookup(ht, ru);
620
621 /* If not found in hash table, add it */
622 if(data == NULL) {
623 GQuark name;
624 HashedResourceData *parent;
625
626 /* Find the parent machine */
627 parent = resourcelist_obtain_machine(resourceview_data, trace_num, trace_num);
628
629 /* Prepare hashed data */
630 data = g_malloc(sizeof(HashedResourceData));
631
632 data->type = RV_RESOURCE_IRQ;
633 data->x.over = 0;
634 data->x.over_used = FALSE;
635 data->x.over_marked = FALSE;
636 data->x.middle = 0; // last
637 data->x.middle_used = FALSE;
638 data->x.middle_marked = FALSE;
639 data->x.under = 0;
640 data->x.under_used = FALSE;
641 data->x.under_marked = FALSE;
642 data->next_good_time = ltt_time_zero;
643
644 data->height = resourceview_data->process_list->cell_height;
645 data->pixmap =
646 gdk_pixmap_new(resourceview_data->drawing->drawing_area->window,
647 resourceview_data->drawing->alloc_width,
648 data->height,
649 -1);
650
651 gdk_draw_rectangle (data->pixmap,
652 resourceview_data->drawing->drawing_area->style->black_gc,
9e01e6d4 653 TRUE,
654 0, 0,
67f72973 655 resourceview_data->drawing->alloc_width,
656 data->height);
9e01e6d4 657
67f72973 658 /* add to hash table */
659 g_hash_table_insert(ht, ru, data);
660 resourceview_data->process_list->number_of_process++; // TODO: check
9e01e6d4 661
67f72973 662 /* add to process list */
663 {
664 gchar *str;
665 str = g_strdup_printf("IRQ %u", id);
666 name = g_quark_from_string(str);
667 g_free(str);
668 }
669
670 gtk_tree_store_append(resourceview_data->process_list->list_store, &data->y_iter, &parent->y_iter);
671 gtk_tree_store_set(resourceview_data->process_list->list_store, &data->y_iter,
672 NAME_COLUMN, g_quark_to_string(name), DATA_COLUMN, data,
673 -1);
674
675 update_index_to_pixmap(resourceview_data->process_list);
9e01e6d4 676
67f72973 677 int heightall = data->height * resourceview_data->process_list->number_of_process;
678
679 gtk_widget_set_size_request(resourceview_data->drawing->drawing_area,
680 -1,
681 heightall);
682
683 gtk_widget_queue_draw(resourceview_data->drawing->drawing_area);
684 }
685
686 return data;
687}
9e01e6d4 688
67f72973 689HashedResourceData *resourcelist_obtain_bdev(ControlFlowData *resourceview_data, guint trace_num, guint id)
9e01e6d4 690{
67f72973 691 ResourceUniqueNumeric *ru = g_new(ResourceUniqueNumeric, 1);
692 HashedResourceData *data = g_new(HashedResourceData, 1);
693
694 /* Prepare hash key */
695 ru->trace_num = trace_num;
696 ru->id = id;
697
698 /* Search within hash table */
699 GHashTable *ht = resourceview_data->process_list->restypes[RV_RESOURCE_BDEV].hash_table;
700 data = g_hash_table_lookup(ht, ru);
701
702 /* If not found in hash table, add it */
703 if(data == NULL) {
704 GQuark name;
705 HashedResourceData *parent;
706
707 /* Find the parent machine */
708 parent = resourcelist_obtain_machine(resourceview_data, trace_num, trace_num);
709
710 /* Prepare hashed data */
711 data = g_malloc(sizeof(HashedResourceData));
712
713 data->type = RV_RESOURCE_BDEV;
714 data->x.over = 0;
715 data->x.over_used = FALSE;
716 data->x.over_marked = FALSE;
717 data->x.middle = 0; // last
718 data->x.middle_used = FALSE;
719 data->x.middle_marked = FALSE;
720 data->x.under = 0;
721 data->x.under_used = FALSE;
722 data->x.under_marked = FALSE;
723 data->next_good_time = ltt_time_zero;
724
725 data->height = resourceview_data->process_list->cell_height;
726 data->pixmap =
727 gdk_pixmap_new(resourceview_data->drawing->drawing_area->window,
728 resourceview_data->drawing->alloc_width,
729 data->height,
730 -1);
9e01e6d4 731
67f72973 732 gdk_draw_rectangle (data->pixmap,
733 resourceview_data->drawing->drawing_area->style->black_gc,
734 TRUE,
735 0, 0,
736 resourceview_data->drawing->alloc_width,
737 data->height);
9e01e6d4 738
67f72973 739 /* add to hash table */
740 g_hash_table_insert(ht, ru, data);
741 resourceview_data->process_list->number_of_process++; // TODO: check
9e01e6d4 742
67f72973 743 /* add to process list */
744 {
745 gchar *str;
746 str = g_strdup_printf("Block (%u,%u)", MAJOR(id), MINOR(id));
747 name = g_quark_from_string(str);
748 g_free(str);
749 }
9e01e6d4 750
67f72973 751 gtk_tree_store_append(resourceview_data->process_list->list_store, &data->y_iter, &parent->y_iter);
752 gtk_tree_store_set(resourceview_data->process_list->list_store, &data->y_iter,
753 NAME_COLUMN, g_quark_to_string(name), DATA_COLUMN, data,
754 -1);
755
756 update_index_to_pixmap(resourceview_data->process_list);
757
758 int heightall = data->height * resourceview_data->process_list->number_of_process;
759
760 gtk_widget_set_size_request(resourceview_data->drawing->drawing_area,
761 -1,
762 heightall);
763
764 gtk_widget_queue_draw(resourceview_data->drawing->drawing_area);
765 }
9e01e6d4 766
67f72973 767 return data;
9e01e6d4 768}
This page took 0.056585 seconds and 4 git commands to generate.