GDB (API)
/home/stan/gdb/src/gdb/darwin-nat.h
Go to the documentation of this file.
00001 /* Common things used by the various darwin files
00002    Copyright (C) 1995-2013 Free Software Foundation, Inc.
00003 
00004    This program is free software; you can redistribute it and/or modify
00005    it under the terms of the GNU General Public License as published by
00006    the Free Software Foundation; either version 3 of the License, or
00007    (at your option) any later version.
00008 
00009    This program is distributed in the hope that it will be useful,
00010    but WITHOUT ANY WARRANTY; without even the implied warranty of
00011    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012    GNU General Public License for more details.
00013 
00014    You should have received a copy of the GNU General Public License
00015    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
00016 
00017 #ifndef __DARWIN_NAT_H__
00018 #define __DARWIN_NAT_H__
00019 
00020 #include <mach/mach.h>
00021 #include "gdb_assert.h"
00022 
00023 /* Describe the mach exception handling state for a task.  This state is saved
00024    before being changed and restored when a process is detached.
00025    For more information on these fields see task_get_exception_ports manual
00026    page.  */
00027 struct darwin_exception_info
00028 {
00029   /* Exceptions handled by the port.  */
00030   exception_mask_t masks[EXC_TYPES_COUNT];
00031 
00032   /* Ports receiving exception messages.  */
00033   mach_port_t ports[EXC_TYPES_COUNT];
00034 
00035   /* Type of messages sent.  */
00036   exception_behavior_t behaviors[EXC_TYPES_COUNT];
00037 
00038   /* Type of state to be sent.  */
00039   thread_state_flavor_t flavors[EXC_TYPES_COUNT];
00040 
00041   /* Number of elements set.  */
00042   mach_msg_type_number_t count;
00043 };
00044 typedef struct darwin_exception_info darwin_exception_info;
00045 
00046 struct darwin_exception_msg
00047 {
00048   mach_msg_header_t header;
00049 
00050   /* Thread and task taking the exception.  */
00051   mach_port_t thread_port;
00052   mach_port_t task_port;
00053 
00054   /* Type of the exception.  */
00055   exception_type_t ex_type;
00056 
00057   /* Machine dependent details.  */
00058   mach_msg_type_number_t data_count;
00059   integer_t ex_data[2];
00060 };
00061 
00062 enum darwin_msg_state
00063 {
00064   /* The thread is running.  */
00065   DARWIN_RUNNING,
00066 
00067   /* The thread is stopped.  */
00068   DARWIN_STOPPED,
00069 
00070   /* The thread has sent a message and waits for a reply.  */
00071   DARWIN_MESSAGE
00072 };
00073 
00074 struct private_thread_info
00075 {
00076   /* The thread port from a GDB point of view.  */
00077   thread_t gdb_port;
00078 
00079   /* The thread port from the inferior point of view.  Not to be used inside
00080      gdb except for get_ada_task_ptid.  */
00081   thread_t inf_port;
00082 
00083   /* Current message state.
00084      If the kernel has sent a message it expects a reply and the inferior
00085      can't be killed before.  */
00086   enum darwin_msg_state msg_state;
00087 
00088   /* True if this thread is single-stepped.  */
00089   unsigned char single_step;
00090 
00091   /* True if a signal was manually sent to the thread.  */
00092   unsigned char signaled;
00093 
00094   /* The last exception received.  */
00095   struct darwin_exception_msg event;
00096 };
00097 typedef struct private_thread_info darwin_thread_t;
00098 
00099 /* Define the threads vector type.  */
00100 DEF_VEC_O (darwin_thread_t);
00101 
00102 
00103 /* Describe an inferior.  */
00104 struct private_inferior
00105 {
00106   /* Corresponding task port.  */
00107   task_t task;
00108 
00109   /* Port which will receive the dead-name notification for the task port.
00110      This is used to detect the death of the task.  */
00111   mach_port_t notify_port;
00112 
00113   /* Initial exception handling.  */
00114   darwin_exception_info exception_info;
00115 
00116   /* Number of messages that have been received but not yet replied.  */
00117   unsigned int pending_messages;
00118 
00119   /* Set if inferior is not controlled by ptrace(2) but through Mach.  */
00120   unsigned char no_ptrace;
00121 
00122   /* True if this task is suspended.  */
00123   unsigned char suspended;
00124 
00125   /* Sorted vector of known threads.  */
00126   VEC(darwin_thread_t) *threads;
00127 };
00128 typedef struct private_inferior darwin_inferior;
00129 
00130 /* Exception port.  */
00131 extern mach_port_t darwin_ex_port;
00132 
00133 /* Port set.  */
00134 extern mach_port_t darwin_port_set;
00135 
00136 /* A copy of mach_host_self ().  */
00137 extern mach_port_t darwin_host_self;
00138 
00139 /* ASSERT_FUNCTION is defined in gdb_assert.h (or not).  */
00140 #ifdef ASSERT_FUNCTION
00141 #define MACH_CHECK_ERROR(ret) \
00142   mach_check_error (ret, __FILE__, __LINE__, ASSERT_FUNCTION)
00143 #else
00144 #define MACH_CHECK_ERROR(ret) \
00145   mach_check_error (ret, __FILE__, __LINE__, "??")
00146 #endif
00147 
00148 extern void mach_check_error (kern_return_t ret, const char *file,
00149                               unsigned int line, const char *func);
00150 
00151 void darwin_set_sstep (thread_t thread, int enable);
00152 
00153 /* This one is called in darwin-nat.c, but needs to be provided by the
00154    platform specific nat code.  It allows each platform to add platform specific
00155    stuff to the darwin_ops.  */
00156 extern void darwin_complete_target (struct target_ops *target);
00157 
00158 void darwin_check_osabi (darwin_inferior *inf, thread_t thread);
00159 
00160 #endif /* __DARWIN_NAT_H__ */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines