Commit | Line | Data |
---|---|---|
a80b95ba | 1 | /* Common things used by the various darwin files |
28e7fd62 | 2 | Copyright (C) 1995-2013 Free Software Foundation, Inc. |
a80b95ba TG |
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 | ||
18 | #ifndef __DARWIN_NAT_H__ | |
19 | #define __DARWIN_NAT_H__ | |
20 | ||
21 | #include <mach/mach.h> | |
22 | #include "gdb_assert.h" | |
23 | ||
a80b95ba TG |
24 | /* Describe the mach exception handling state for a task. This state is saved |
25 | before being changed and restored when a process is detached. | |
26 | For more information on these fields see task_get_exception_ports manual | |
27 | page. */ | |
28 | struct darwin_exception_info | |
29 | { | |
30 | /* Exceptions handled by the port. */ | |
31 | exception_mask_t masks[EXC_TYPES_COUNT]; | |
32 | ||
33 | /* Ports receiving exception messages. */ | |
34 | mach_port_t ports[EXC_TYPES_COUNT]; | |
35 | ||
36 | /* Type of messages sent. */ | |
37 | exception_behavior_t behaviors[EXC_TYPES_COUNT]; | |
38 | ||
39 | /* Type of state to be sent. */ | |
40 | thread_state_flavor_t flavors[EXC_TYPES_COUNT]; | |
41 | ||
42 | /* Number of elements set. */ | |
43 | mach_msg_type_number_t count; | |
44 | }; | |
45 | typedef struct darwin_exception_info darwin_exception_info; | |
46 | ||
bb00b29d | 47 | struct darwin_exception_msg |
a80b95ba | 48 | { |
bb00b29d TG |
49 | mach_msg_header_t header; |
50 | ||
51 | /* Thread and task taking the exception. */ | |
52 | mach_port_t thread_port; | |
53 | mach_port_t task_port; | |
54 | ||
55 | /* Type of the exception. */ | |
56 | exception_type_t ex_type; | |
57 | ||
58 | /* Machine dependent details. */ | |
59 | mach_msg_type_number_t data_count; | |
60 | integer_t ex_data[2]; | |
61 | }; | |
62 | ||
637fd620 TG |
63 | enum darwin_msg_state |
64 | { | |
65 | /* The thread is running. */ | |
66 | DARWIN_RUNNING, | |
67 | ||
68 | /* The thread is stopped. */ | |
69 | DARWIN_STOPPED, | |
70 | ||
71 | /* The thread has sent a message and waits for a reply. */ | |
72 | DARWIN_MESSAGE | |
73 | }; | |
bb00b29d TG |
74 | |
75 | struct private_thread_info | |
76 | { | |
77 | /* The thread port from a GDB point of view. */ | |
78 | thread_t gdb_port; | |
79 | ||
80 | /* The thread port from the inferior point of view. Not to be used inside | |
81 | gdb except for get_ada_task_ptid. */ | |
82 | thread_t inf_port; | |
83 | ||
84 | /* Current message state. | |
85 | If the kernel has sent a message it expects a reply and the inferior | |
86 | can't be killed before. */ | |
87 | enum darwin_msg_state msg_state; | |
88 | ||
89 | /* True if this thread is single-stepped. */ | |
90 | unsigned char single_step; | |
a80b95ba | 91 | |
bb00b29d TG |
92 | /* True if a signal was manually sent to the thread. */ |
93 | unsigned char signaled; | |
94 | ||
95 | /* The last exception received. */ | |
96 | struct darwin_exception_msg event; | |
97 | }; | |
98 | typedef struct private_thread_info darwin_thread_t; | |
99 | ||
100 | /* Define the threads vector type. */ | |
101 | DEF_VEC_O (darwin_thread_t); | |
102 | ||
103 | ||
104 | /* Describe an inferior. */ | |
105 | struct private_inferior | |
106 | { | |
a80b95ba TG |
107 | /* Corresponding task port. */ |
108 | task_t task; | |
109 | ||
bb00b29d TG |
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; | |
a80b95ba TG |
113 | |
114 | /* Initial exception handling. */ | |
115 | darwin_exception_info exception_info; | |
116 | ||
bb00b29d TG |
117 | /* Number of messages that have been received but not yet replied. */ |
118 | unsigned int pending_messages; | |
119 | ||
120 | /* Set if inferior is not controlled by ptrace(2) but through Mach. */ | |
121 | unsigned char no_ptrace; | |
122 | ||
123 | /* True if this task is suspended. */ | |
124 | unsigned char suspended; | |
125 | ||
a80b95ba | 126 | /* Sorted vector of known threads. */ |
bb00b29d | 127 | VEC(darwin_thread_t) *threads; |
a80b95ba | 128 | }; |
bb00b29d | 129 | typedef struct private_inferior darwin_inferior; |
a80b95ba TG |
130 | |
131 | /* Exception port. */ | |
132 | extern mach_port_t darwin_ex_port; | |
133 | ||
a80b95ba TG |
134 | /* Port set. */ |
135 | extern mach_port_t darwin_port_set; | |
136 | ||
137 | /* A copy of mach_host_self (). */ | |
138 | extern mach_port_t darwin_host_self; | |
139 | ||
140 | /* ASSERT_FUNCTION is defined in gdb_assert.h (or not). */ | |
141 | #ifdef ASSERT_FUNCTION | |
142 | #define MACH_CHECK_ERROR(ret) \ | |
143 | mach_check_error (ret, __FILE__, __LINE__, ASSERT_FUNCTION) | |
144 | #else | |
145 | #define MACH_CHECK_ERROR(ret) \ | |
146 | mach_check_error (ret, __FILE__, __LINE__, "??") | |
147 | #endif | |
148 | ||
149 | extern void mach_check_error (kern_return_t ret, const char *file, | |
150 | unsigned int line, const char *func); | |
151 | ||
152 | void darwin_set_sstep (thread_t thread, int enable); | |
153 | ||
154 | /* This one is called in darwin-nat.c, but needs to be provided by the | |
155 | platform specific nat code. It allows each platform to add platform specific | |
156 | stuff to the darwin_ops. */ | |
157 | extern void darwin_complete_target (struct target_ops *target); | |
158 | ||
159 | void darwin_check_osabi (darwin_inferior *inf, thread_t thread); | |
160 | ||
161 | #endif /* __DARWIN_NAT_H__ */ |