Commit | Line | Data |
---|---|---|
a80b95ba | 1 | /* Common things used by the various darwin files |
4c38e0a4 | 2 | Copyright (C) 1995, 1996, 1997, 1999, 2000, 2007, 2008, 2009, 2010 |
a80b95ba TG |
3 | Free Software Foundation, Inc. |
4 | ||
5 | This program is free software; you can redistribute it and/or modify | |
6 | it under the terms of the GNU General Public License as published by | |
7 | the Free Software Foundation; either version 3 of the License, or | |
8 | (at your option) any later version. | |
9 | ||
10 | This program is distributed in the hope that it will be useful, | |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 | GNU General Public License for more details. | |
14 | ||
15 | You should have received a copy of the GNU General Public License | |
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | |
17 | */ | |
18 | ||
19 | #ifndef __DARWIN_NAT_H__ | |
20 | #define __DARWIN_NAT_H__ | |
21 | ||
22 | #include <mach/mach.h> | |
23 | #include "gdb_assert.h" | |
24 | ||
a80b95ba TG |
25 | /* Describe the mach exception handling state for a task. This state is saved |
26 | before being changed and restored when a process is detached. | |
27 | For more information on these fields see task_get_exception_ports manual | |
28 | page. */ | |
29 | struct darwin_exception_info | |
30 | { | |
31 | /* Exceptions handled by the port. */ | |
32 | exception_mask_t masks[EXC_TYPES_COUNT]; | |
33 | ||
34 | /* Ports receiving exception messages. */ | |
35 | mach_port_t ports[EXC_TYPES_COUNT]; | |
36 | ||
37 | /* Type of messages sent. */ | |
38 | exception_behavior_t behaviors[EXC_TYPES_COUNT]; | |
39 | ||
40 | /* Type of state to be sent. */ | |
41 | thread_state_flavor_t flavors[EXC_TYPES_COUNT]; | |
42 | ||
43 | /* Number of elements set. */ | |
44 | mach_msg_type_number_t count; | |
45 | }; | |
46 | typedef struct darwin_exception_info darwin_exception_info; | |
47 | ||
bb00b29d | 48 | struct darwin_exception_msg |
a80b95ba | 49 | { |
bb00b29d TG |
50 | mach_msg_header_t header; |
51 | ||
52 | /* Thread and task taking the exception. */ | |
53 | mach_port_t thread_port; | |
54 | mach_port_t task_port; | |
55 | ||
56 | /* Type of the exception. */ | |
57 | exception_type_t ex_type; | |
58 | ||
59 | /* Machine dependent details. */ | |
60 | mach_msg_type_number_t data_count; | |
61 | integer_t ex_data[2]; | |
62 | }; | |
63 | ||
64 | enum darwin_msg_state { DARWIN_RUNNING, DARWIN_STOPPED, DARWIN_MESSAGE }; | |
65 | ||
66 | struct private_thread_info | |
67 | { | |
68 | /* The thread port from a GDB point of view. */ | |
69 | thread_t gdb_port; | |
70 | ||
71 | /* The thread port from the inferior point of view. Not to be used inside | |
72 | gdb except for get_ada_task_ptid. */ | |
73 | thread_t inf_port; | |
74 | ||
75 | /* Current message state. | |
76 | If the kernel has sent a message it expects a reply and the inferior | |
77 | can't be killed before. */ | |
78 | enum darwin_msg_state msg_state; | |
79 | ||
80 | /* True if this thread is single-stepped. */ | |
81 | unsigned char single_step; | |
a80b95ba | 82 | |
bb00b29d TG |
83 | /* True if a signal was manually sent to the thread. */ |
84 | unsigned char signaled; | |
85 | ||
86 | /* The last exception received. */ | |
87 | struct darwin_exception_msg event; | |
88 | }; | |
89 | typedef struct private_thread_info darwin_thread_t; | |
90 | ||
91 | /* Define the threads vector type. */ | |
92 | DEF_VEC_O (darwin_thread_t); | |
93 | ||
94 | ||
95 | /* Describe an inferior. */ | |
96 | struct private_inferior | |
97 | { | |
a80b95ba TG |
98 | /* Corresponding task port. */ |
99 | task_t task; | |
100 | ||
bb00b29d TG |
101 | /* Port which will receive the dead-name notification for the task port. |
102 | This is used to detect the death of the task. */ | |
103 | mach_port_t notify_port; | |
a80b95ba TG |
104 | |
105 | /* Initial exception handling. */ | |
106 | darwin_exception_info exception_info; | |
107 | ||
bb00b29d TG |
108 | /* Number of messages that have been received but not yet replied. */ |
109 | unsigned int pending_messages; | |
110 | ||
111 | /* Set if inferior is not controlled by ptrace(2) but through Mach. */ | |
112 | unsigned char no_ptrace; | |
113 | ||
114 | /* True if this task is suspended. */ | |
115 | unsigned char suspended; | |
116 | ||
a80b95ba | 117 | /* Sorted vector of known threads. */ |
bb00b29d | 118 | VEC(darwin_thread_t) *threads; |
a80b95ba | 119 | }; |
bb00b29d | 120 | typedef struct private_inferior darwin_inferior; |
a80b95ba TG |
121 | |
122 | /* Exception port. */ | |
123 | extern mach_port_t darwin_ex_port; | |
124 | ||
a80b95ba TG |
125 | /* Port set. */ |
126 | extern mach_port_t darwin_port_set; | |
127 | ||
128 | /* A copy of mach_host_self (). */ | |
129 | extern mach_port_t darwin_host_self; | |
130 | ||
131 | /* ASSERT_FUNCTION is defined in gdb_assert.h (or not). */ | |
132 | #ifdef ASSERT_FUNCTION | |
133 | #define MACH_CHECK_ERROR(ret) \ | |
134 | mach_check_error (ret, __FILE__, __LINE__, ASSERT_FUNCTION) | |
135 | #else | |
136 | #define MACH_CHECK_ERROR(ret) \ | |
137 | mach_check_error (ret, __FILE__, __LINE__, "??") | |
138 | #endif | |
139 | ||
140 | extern void mach_check_error (kern_return_t ret, const char *file, | |
141 | unsigned int line, const char *func); | |
142 | ||
143 | void darwin_set_sstep (thread_t thread, int enable); | |
144 | ||
145 | /* This one is called in darwin-nat.c, but needs to be provided by the | |
146 | platform specific nat code. It allows each platform to add platform specific | |
147 | stuff to the darwin_ops. */ | |
148 | extern void darwin_complete_target (struct target_ops *target); | |
149 | ||
150 | void darwin_check_osabi (darwin_inferior *inf, thread_t thread); | |
151 | ||
152 | #endif /* __DARWIN_NAT_H__ */ |