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