File: process.h

package info (click to toggle)
memprof 0.5.1-9
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 2,352 kB
  • ctags: 558
  • sloc: sh: 8,368; ansic: 4,904; makefile: 190
file content (142 lines) | stat: -rw-r--r-- 4,811 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
/* -*- mode: C; c-file-style: "linux" -*- */

/* MemProf -- memory profiler and leak detector
 * Copyright 1999, 2000, 2001, Red Hat, Inc.
 * Copyright 2002, Kristian Rietveld
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 */
/*====*/

#ifndef __PROCESS_H__
#define __PROCESS_H__

#include <stdio.h>
#include <glib.h>
#include <unistd.h>

#include <glib-object.h>

#include "memprof.h"

#define MP_TYPE_PROCESS            (mp_process_get_type ())
#define MP_PROCESS(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), MP_TYPE_PROCESS, MPProcess))
#define MP_PROCESS_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), MP_TYPE_PROCESS, MPProcessClass))
#define MP_IS_PROCESS(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MP_TYPE_PROCESS))
#define MP_IS_PROCESS_CLASS(obj)   (G_TYPE_CHECK_CLASS_TYPE ((obj), MP_TYPE_PROCESS))
#define MP_PROCESS_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj), MP_TYPE_PROCESS, MPProcessClass))

/* forward declaration */
typedef struct _MPServer MPServer;

typedef struct _MPProcess MPProcess;
typedef struct _MPProcessClass MPProcessClass;

typedef enum {
	MP_PROCESS_INIT,	/* Newly created */
	MP_PROCESS_STARTING,	/* Run child, waiting for it to connect */
	MP_PROCESS_RUNNING,	/* Child is running */
	MP_PROCESS_EXITING,	/* _exit() has been called in child */
	MP_PROCESS_DEFUNCT,	/* child no longer exists */
	MP_PROCESS_DETACHED	/* we now ignore this child */
} MPProcessStatus;

typedef void (*MPProcessBlockForeachFunc) (Block    *block,
					   gpointer  data);

struct _MPProcess
{
	GObject parent_instance;

	MPProcessStatus status;
	
	pid_t pid;
	gchar *program_name;

	MPServer *server;
	
	MPProcess *clone_of;
	MPProcess *parent;
	guint seqno;	
	
	guint bytes_used;
	guint n_allocations;
	
	gint input_tag;
	GIOChannel *input_channel;
	
	GList *map_list;
	GList *bad_pages;
	GHashTable *block_table;

	StackStash *stack_stash;
	
	GList *command_queue;
	
	gboolean follow_fork;
	gboolean follow_exec;
};

struct _MPProcessClass {
	GObjectClass parent_class;

	void (*status_changed) (MPProcess *process);
	void (*reset)          (MPProcess *process);
};

GType       mp_process_get_type     (void);
MPProcess * process_new             (MPServer           *server);
MPProcess * process_duplicate       (MPProcess          *process);
void        process_set_follow_fork (MPProcess          *process,
				     gboolean            follow_fork);
void        process_set_follow_exec (MPProcess          *process,
				     gboolean            follow_exec);

void  process_run             (MPProcess        *process,
			       const char       *path,
			       char            **args);
void  process_detach          (MPProcess        *process);
void  process_kill            (MPProcess        *process);
void  process_exec_reset      (MPProcess        *process);
void  process_set_status      (MPProcess        *process,
			       MPProcessStatus   status);
char *process_get_status_text (MPProcess        *process);
char *process_get_cmdline     (MPProcess        *process);

void        process_sections        (MPProcess          *process,
				     SectionFunc         func,
				     gpointer            user_data);
GList *     process_get_clones      (MPProcess          *process);
void        process_start_input     (MPProcess          *process);
void        process_stop_input      (MPProcess          *process);
gboolean    process_find_line       (MPProcess          *process,
				     void               *address,
				     const char        **filename,
				     char              **functionname,
				     unsigned int       *line);
void        process_dump_stack      (MPProcess          *process,
				     FILE               *out,
				     StackElement       *stack);
Symbol *    process_locate_symbol   (MPProcess          *process,
				     guint               addr);

char **     process_parse_exec      (const char         *exec_string);
char *      process_find_exec       (char              **args);

void  process_block_foreach (MPProcess                *process,
			     MPProcessBlockForeachFunc foreach_func,
			     gpointer                  data);

#endif /* __PROCESS_H__ */