detailwin.c: Fix possible crash when opening the maps file fails
[memprof.git] / src / profile.h
blob4cf073e5a3a5e3851961bcd8974f456d3b5d287f
1 /* MemProf -- memory profiler and leak detector
2 * Copyright 2002, Soeren Sandmann (sandmann@daimi.au.dk)
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 /*====*/
20 #include "memprof.h"
21 #include "process.h"
22 #include <glib.h>
24 typedef struct ProfileNode ProfileNode;
25 typedef struct Profile Profile;
26 typedef struct ProfileFunc ProfileFunc;
27 typedef struct ProfileDescendantTree ProfileDescendantTree;
28 typedef struct ProfileDescendantTreeNode ProfileDescendantTreeNode;
30 struct ProfileNode {
31 char * symbol;
33 guint total;
34 guint self;
35 gboolean toplevel; /* whether the node is the first for this function
36 * in the stack trace
39 ProfileNode * next; /* chains together nodes with matching symbols */
41 GPtrArray * children;
42 ProfileNode * parent;
45 struct ProfileDescendantTreeNode
47 char * symbol;
49 guint self;
50 guint non_recursion;
51 guint total;
53 GPtrArray * children;
54 ProfileDescendantTreeNode *parent;
56 gint marked_non_recursive;
57 gboolean marked_total;
60 struct ProfileDescendantTree {
61 GPtrArray * roots;
64 struct ProfileFunc {
65 guint total; /* sum of all toplevel totals */
66 guint self; /* sum of all selfs */
68 ProfileNode *node;
71 struct Profile {
72 GPtrArray * roots; /* root nodes of call tree */
73 GPtrArray * functions;
74 guint n_bytes; /* total number of bytes profiled */
76 /* private */
77 MPProcess * process;
78 GHashTable *nodes_by_symbol;
81 Profile * profile_create (MPProcess *process,
82 GSList *skip_funcs);
83 void profile_free (Profile *profile);
84 ProfileDescendantTree *profile_func_create_descendant_tree (ProfileFunc *func);
85 void profile_descendant_tree_free (ProfileDescendantTree *descendant_tree);
86 GPtrArray * profile_func_create_caller_list (ProfileFunc *func);
87 void profile_caller_list_free (GPtrArray *caller_list);
88 void profile_write (Profile *profile, const gchar *outfile);