GDB (xrefs)
/tmp/gdb-8.1/gdb/darwin-nat.h
Go to the documentation of this file.
1 /* Common things used by the various darwin files
2  Copyright (C) 1995-2018 Free Software Foundation, Inc.
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 as published by
6  the Free Software Foundation; either version 3 of the License, or
7  (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, see <http://www.gnu.org/licenses/>. */
16 
17 #ifndef __DARWIN_NAT_H__
18 #define __DARWIN_NAT_H__
19 
20 #include <mach/mach.h>
21 #include "gdbthread.h"
22 
23 /* Describe the mach exception handling state for a task. This state is saved
24  before being changed and restored when a process is detached.
25  For more information on these fields see task_get_exception_ports manual
26  page. */
28 {
29  /* Exceptions handled by the port. */
30  exception_mask_t masks[EXC_TYPES_COUNT] {};
31 
32  /* Ports receiving exception messages. */
33  mach_port_t ports[EXC_TYPES_COUNT] {};
34 
35  /* Type of messages sent. */
36  exception_behavior_t behaviors[EXC_TYPES_COUNT] {};
37 
38  /* Type of state to be sent. */
39  thread_state_flavor_t flavors[EXC_TYPES_COUNT] {};
40 
41  /* Number of elements set. */
42  mach_msg_type_number_t count = 0;
43 };
44 
46 {
47  mach_msg_header_t header;
48 
49  /* Thread and task taking the exception. */
50  mach_port_t thread_port;
51  mach_port_t task_port;
52 
53  /* Type of the exception. */
54  exception_type_t ex_type;
55 
56  /* Machine dependent details. */
57  mach_msg_type_number_t data_count;
58  integer_t ex_data[2];
59 };
60 
62 {
63  /* The thread is running. */
65 
66  /* The thread is stopped. */
68 
69  /* The thread has sent a message and waits for a reply. */
71 };
72 
74 {
75  /* The thread port from a GDB point of view. */
77 
78  /* The thread port from the inferior point of view. Not to be used inside
79  gdb except for get_ada_task_ptid. */
81 
82  /* Current message state.
83  If the kernel has sent a message it expects a reply and the inferior
84  can't be killed before. */
86 
87  /* True if this thread is single-stepped. */
88  unsigned char single_step;
89 
90  /* True if a signal was manually sent to the thread. */
91  unsigned char signaled;
92 
93  /* The last exception received. */
95 };
97 
98 static inline darwin_thread_info *
100 {
101  return static_cast<darwin_thread_info *> (thread->priv.get ());
102 }
103 
104 /* Describe an inferior. */
106 {
107  /* Corresponding task port. */
108  task_t task = 0;
109 
110  /* Port which will receive the dead-name notification for the task port.
111  This is used to detect the death of the task. */
112  mach_port_t notify_port = 0;
113 
114  /* Initial exception handling. */
116 
117  /* Number of messages that have been received but not yet replied. */
118  unsigned int pending_messages = 0;
119 
120  /* Set if inferior is not controlled by ptrace(2) but through Mach. */
121  bool no_ptrace = false;
122 
123  /* True if this task is suspended. */
124  bool suspended = false;
125 
126  /* Sorted vector of known threads. */
127  std::vector<darwin_thread_t *> threads;
128 };
129 
130 /* Return the darwin_inferior attached to INF. */
131 
132 static inline darwin_inferior *
134 {
135  return static_cast<darwin_inferior *> (inf->priv.get ());
136 }
137 
138 /* Exception port. */
139 extern mach_port_t darwin_ex_port;
140 
141 /* Port set. */
142 extern mach_port_t darwin_port_set;
143 
144 /* A copy of mach_host_self (). */
145 extern mach_port_t darwin_host_self;
146 
147 /* FUNCTION_NAME is defined in common-utils.h (or not). */
148 #ifdef FUNCTION_NAME
149 #define MACH_CHECK_ERROR(ret) \
150  mach_check_error (ret, __FILE__, __LINE__, FUNCTION_NAME)
151 #else
152 #define MACH_CHECK_ERROR(ret) \
153  mach_check_error (ret, __FILE__, __LINE__, "??")
154 #endif
155 
156 extern void mach_check_error (kern_return_t ret, const char *file,
157  unsigned int line, const char *func);
158 
159 void darwin_set_sstep (thread_t thread, int enable);
160 
161 /* This one is called in darwin-nat.c, but needs to be provided by the
162  platform specific nat code. It allows each platform to add platform specific
163  stuff to the darwin_ops. */
164 extern void darwin_complete_target (struct target_ops *target);
165 
167 
168 #endif /* __DARWIN_NAT_H__ */
mach_port_t notify_port
Definition: darwin-nat.h:112
unsigned char signaled
Definition: darwin-nat.h:91
thread_state_flavor_t flavors[EXC_TYPES_COUNT]
Definition: darwin-nat.h:39
struct darwin_exception_msg event
Definition: darwin-nat.h:94
void(* func)(char *)
unsigned int pending_messages
Definition: darwin-nat.h:118
void darwin_set_sstep(thread_t thread, int enable)
void mach_check_error(kern_return_t ret, const char *file, unsigned int line, const char *func)
Definition: darwin-nat.c:199
enum darwin_msg_state msg_state
Definition: darwin-nat.h:85
exception_mask_t masks[EXC_TYPES_COUNT]
Definition: darwin-nat.h:30
thread_t inf_port
Definition: darwin-nat.h:80
exception_behavior_t behaviors[EXC_TYPES_COUNT]
Definition: darwin-nat.h:36
mach_port_t ports[EXC_TYPES_COUNT]
Definition: darwin-nat.h:33
darwin_exception_info exception_info
Definition: darwin-nat.h:115
darwin_msg_state
Definition: darwin-nat.h:61
mach_port_t darwin_port_set
Definition: darwin-nat.c:137
mach_msg_header_t header
Definition: darwin-nat.h:47
mach_msg_type_number_t data_count
Definition: darwin-nat.h:57
std::vector< darwin_thread_t * > threads
Definition: darwin-nat.h:127
static darwin_inferior * get_darwin_inferior(inferior *inf)
Definition: darwin-nat.h:133
mach_port_t task_port
Definition: darwin-nat.h:51
unsigned char single_step
Definition: darwin-nat.h:88
#define enable()
Definition: ser-go32.c:239
Definition: gnu-nat.c:174
static darwin_thread_info * get_darwin_thread_info(class thread_info *thread)
Definition: darwin-nat.h:99
pthread_t thread_t
mach_port_t thread_port
Definition: darwin-nat.h:50
std::unique_ptr< private_thread_info > priv
Definition: gdbthread.h:354
mach_port_t darwin_host_self
Definition: darwin-nat.c:131
integer_t ex_data[2]
Definition: darwin-nat.h:58
thread_t gdb_port
Definition: darwin-nat.h:76
void darwin_check_osabi(darwin_inferior *inf, thread_t thread)
exception_type_t ex_type
Definition: darwin-nat.h:54
mach_msg_type_number_t count
Definition: darwin-nat.h:42
void darwin_complete_target(struct target_ops *target)
mach_port_t darwin_ex_port
Definition: darwin-nat.c:134