Stackdb
Stackdb is a stackable, multi-target and -level source debugger and memory forensics library.
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
target_process.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2013, 2014 The University of Utah
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License as
6  * published by the Free Software Foundation; either version 2 of
7  * the License, or (at your option) any later version.
8  *
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.
13  *
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, 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
17  */
18 
19 #ifndef __TARGET_PROCESS_H__
20 #define __TARGET_PROCESS_H__
21 
22 #include <glib.h>
23 
24 #include "target_api.h"
25 
26 typedef enum {
30 
31 #define SAFE_TARGET_PROCESS_OP(target,op,errval,...) \
32  do { \
33  if (target->personality != TARGET_PERSONALITY_PROCESS) { \
34  verror("target %s is not a process!\n",target->name); \
35  errno = EINVAL; \
36  return (errval); \
37  } \
38  else if (!target->process_ops || !target->process_ops->op) { \
39  verror("target %s does not support process operation '%s'!\n", \
40  target->name,#op); \
41  errno = ENOSYS; \
42  return (errval); \
43  } \
44  else { \
45  return target->process_ops->op(__VA_ARGS__); \
46  } \
47  } while (0);
48 
50  struct target *target;
51  /*
52  * The primary thread.
53  */
56 
60 
61  /*
62  * A hashtable of tid_t to struct target_thread *.
63  */
64  GHashTable *threads;
65 
66  /*
67  * A hashtable of tid_t to struct target_thread *.
68  */
69  GHashTable *children;
70 
71  /*
72  * An addrspace containing regions. This isn't very good, because
73  * individual threads in the process might have their own address
74  * spaces. However, we don't tend to see this much in practice, so
75  * for now it's good enough.
76  */
77  struct addrspace *space;
78 
80 };
81 
82 /*
83  * Helper functions for backend builders.
84  */
85 
87  struct target_thread *tthread,
88  struct addrspace *space);
89 REFCNT target_process_free(struct target_process *process,int force);
90 
91 /*
92  * The intent here is to provide a generic interface to common
93  * process-level abstractions.
94  */
96  int (*init)(struct target *target);
97  int (*fini)(struct target *target);
98 
100 
101 };
102 
103 #endif /* __TARGET_PROCESS_H__ */
struct addrspace * space
int32_t tid_t
Definition: common.h:36
GHashTable * children
int(* init)(struct target *target)
REFCNT target_process_free(struct target_process *process, int force)
target_process_type_t
obj_flags_t
Definition: object.h:43
struct target * target
obj_flags_t obj_flags
int(* fini)(struct target *target)
GHashTable * threads
uint32_t REFCNT
Definition: common.h:124
struct target_process * parent
target_process_type_t(* type)(struct target *target)
struct target_process * target_process_create(struct target *target, struct target_thread *tthread, struct addrspace *space)
struct target_thread * thread