GDBserver
inferiors.h
Go to the documentation of this file.
1 /* Inferior process information for the remote server for GDB.
2  Copyright (C) 1993-2015 Free Software Foundation, Inc.
3 
4  This file is part of GDB.
5 
6  This program is free software; you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation; either version 3 of the License, or
9  (at your option) any later version.
10 
11  This program is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with this program. If not, see <http://www.gnu.org/licenses/>. */
18 
19 #ifndef INFERIORS_H
20 #define INFERIORS_H
21 
22 /* Generic information for tracking a list of ``inferiors'' - threads,
23  processes, etc. */
25 {
28 };
30 {
33 };
34 
35 struct thread_info;
36 struct target_desc;
37 struct sym_cache;
38 struct breakpoint;
39 struct raw_breakpoint;
42 
44 {
45  /* This must appear first.
46  The list iterator functions assume it. */
48 
49  /* Nonzero if this child process was attached rather than
50  spawned. */
51  int attached;
52 
53  /* True if GDB asked us to detach from this process, but we remained
54  attached anyway. */
56 
57  /* The symbol cache. */
59 
60  /* The list of memory breakpoints. */
62 
63  /* The list of raw memory breakpoints. */
65 
66  /* The list of installed fast tracepoints. */
68 
69  const struct target_desc *tdesc;
70 
71  /* Private target data. */
73 };
74 
75 #define ptid_of(inf) ((inf)->entry.id)
76 #define pid_of(inf) ptid_get_pid ((inf)->entry.id)
77 #define lwpid_of(inf) ptid_get_lwp ((inf)->entry.id)
78 
79 /* Return a pointer to the process that corresponds to the current
80  thread (current_thread). It is an error to call this if there is
81  no current thread selected. */
82 
83 struct process_info *current_process (void);
85 
86 extern struct inferior_list all_processes;
87 
88 void add_inferior_to_list (struct inferior_list *list,
89  struct inferior_list_entry *new_inferior);
90 void for_each_inferior (struct inferior_list *list,
91  void (*action) (struct inferior_list_entry *));
92 
94  (struct inferior_list *list,
95  void (*action) (struct inferior_list_entry *, void *),
96  void *data);
97 
98 void clear_inferior_list (struct inferior_list *list);
99 
100 int one_inferior_p (struct inferior_list *list);
101 
102 /* Helper for ALL_INFERIORS_TYPE. Gets the next element starting at
103  CUR, if CUR is not NULL. */
104 #define A_I_NEXT(type, list, cur) \
105  ((cur) != NULL \
106  ? (type *) ((struct inferior_list_entry *) cur)->next \
107  : NULL)
108 
109 /* Iterate over all inferiors of type TYPE in LIST, open loop
110  style. */
111 #define ALL_INFERIORS_TYPE(type, list, cur, tmp) \
112  for ((cur) = (type *) (list)->head, (tmp) = A_I_NEXT (type, list, cur); \
113  (cur) != NULL; \
114  (cur) = (tmp), (tmp) = A_I_NEXT (type, list, cur))
115 
116 /* Iterate over all inferiors in LIST, open loop style. */
117 #define ALL_INFERIORS(list, cur, tmp) \
118  ALL_INFERIORS_TYPE (struct inferior_list_entry, list, cur, tmp)
119 
120 /* Iterate over all processes, open loop style. */
121 #define ALL_PROCESSES(cur, tmp) \
122  ALL_INFERIORS_TYPE (struct process_info, &all_processes, cur, tmp)
123 
124 extern struct thread_info *current_thread;
125 void remove_inferior (struct inferior_list *list,
126  struct inferior_list_entry *entry);
127 
129 
130 struct process_info *add_process (int pid, int attached);
131 void remove_process (struct process_info *process);
132 struct process_info *find_process_pid (int pid);
133 int have_started_inferiors_p (void);
134 int have_attached_inferiors_p (void);
135 
138 
139 void clear_inferiors (void);
141  (struct inferior_list *,
142  int (*func) (struct inferior_list_entry *,
143  void *),
144  void *arg);
146  ptid_t id);
147 
148 void *inferior_target_data (struct thread_info *);
149 void set_inferior_target_data (struct thread_info *, void *);
150 void *inferior_regcache_data (struct thread_info *);
151 void set_inferior_regcache_data (struct thread_info *, void *);
152 
153 #endif /* INFERIORS_H */
void * inferior_regcache_data(struct thread_info *)
Definition: inferiors.c:234
int have_attached_inferiors_p(void)
Definition: inferiors.c:342
void for_each_inferior_with_data(struct inferior_list *list, void(*action)(struct inferior_list_entry *, void *), void *data)
ptid_t thread_to_gdb_id(struct thread_info *)
Definition: inferiors.c:127
void add_inferior_to_list(struct inferior_list *list, struct inferior_list_entry *new_inferior)
Definition: inferiors.c:33
struct process_info * get_thread_process(struct thread_info *)
Definition: inferiors.c:349
struct inferior_list_entry entry
Definition: inferiors.h:47
void clear_inferiors(void)
Definition: inferiors.c:263
struct process_info * add_process(int pid, int attached)
Definition: inferiors.c:274
struct raw_breakpoint * raw_breakpoints
Definition: inferiors.h:64
ptid_t id
Definition: inferiors.h:31
void set_inferior_regcache_data(struct thread_info *, void *)
Definition: inferiors.c:240
void set_inferior_target_data(struct thread_info *, void *)
Definition: inferiors.c:228
int attached
Definition: inferiors.h:51
const struct target_desc * tdesc
Definition: inferiors.h:69
ptid_t gdb_id_to_thread_id(ptid_t)
Definition: inferiors.c:147
Definition: ptid.h:35
struct inferior_list_entry entry
Definition: gdbthread.h:30
void for_each_inferior(struct inferior_list *list, void(*action)(struct inferior_list_entry *))
Definition: inferiors.c:47
struct fast_tracepoint_jump * fast_tracepoint_jumps
Definition: inferiors.h:67
struct process_info * find_process_pid(int pid)
Definition: inferiors.c:302
struct process_info * current_process(void)
Definition: inferiors.c:356
struct inferior_list all_processes
Definition: inferiors.c:25
struct inferior_list_entry * tail
Definition: inferiors.h:27
int gdb_detached
Definition: inferiors.h:55
int one_inferior_p(struct inferior_list *list)
Definition: inferiors.c:248
struct inferior_list_entry * find_inferior(struct inferior_list *, int(*func)(struct inferior_list_entry *, void *), void *arg)
struct inferior_list_entry * head
Definition: inferiors.h:26
struct process_info_private * priv
Definition: inferiors.h:72
void remove_inferior(struct inferior_list *list, struct inferior_list_entry *entry)
Definition: inferiors.c:79
struct sym_cache * symbol_cache
Definition: inferiors.h:58
void remove_process(struct process_info *process)
Definition: inferiors.c:293
struct inferior_list_entry * next
Definition: inferiors.h:32
struct inferior_list_entry * find_inferior_id(struct inferior_list *list, ptid_t id)
Definition: inferiors.c:207
struct thread_info * current_thread
Definition: inferiors.c:28
void clear_inferior_list(struct inferior_list *list)
Definition: inferiors.c:256
Definition: inferiors.h:29
struct inferior_list_entry * get_first_inferior(struct inferior_list *list)
Definition: inferiors.c:177
struct breakpoint * breakpoints
Definition: inferiors.h:61
int have_started_inferiors_p(void)
Definition: inferiors.c:323
void * inferior_target_data(struct thread_info *)
Definition: inferiors.c:222