gdb/darwin-nat.h - gdb

Global variables defined

Data types defined

Macros defined

Source code

  1. /* Common things used by the various darwin files
  2.    Copyright (C) 1995-2015 Free Software Foundation, Inc.

  3.    This program is free software; you can redistribute it and/or modify
  4.    it under the terms of the GNU General Public License as published by
  5.    the Free Software Foundation; either version 3 of the License, or
  6.    (at your option) any later version.

  7.    This program is distributed in the hope that it will be useful,
  8.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  9.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  10.    GNU General Public License for more details.

  11.    You should have received a copy of the GNU General Public License
  12.    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */

  13. #ifndef __DARWIN_NAT_H__
  14. #define __DARWIN_NAT_H__

  15. #include <mach/mach.h>

  16. /* Describe the mach exception handling state for a task.  This state is saved
  17.    before being changed and restored when a process is detached.
  18.    For more information on these fields see task_get_exception_ports manual
  19.    page.  */
  20. struct darwin_exception_info
  21. {
  22.   /* Exceptions handled by the port.  */
  23.   exception_mask_t masks[EXC_TYPES_COUNT];

  24.   /* Ports receiving exception messages.  */
  25.   mach_port_t ports[EXC_TYPES_COUNT];

  26.   /* Type of messages sent.  */
  27.   exception_behavior_t behaviors[EXC_TYPES_COUNT];

  28.   /* Type of state to be sent.  */
  29.   thread_state_flavor_t flavors[EXC_TYPES_COUNT];

  30.   /* Number of elements set.  */
  31.   mach_msg_type_number_t count;
  32. };
  33. typedef struct darwin_exception_info darwin_exception_info;

  34. struct darwin_exception_msg
  35. {
  36.   mach_msg_header_t header;

  37.   /* Thread and task taking the exception.  */
  38.   mach_port_t thread_port;
  39.   mach_port_t task_port;

  40.   /* Type of the exception.  */
  41.   exception_type_t ex_type;

  42.   /* Machine dependent details.  */
  43.   mach_msg_type_number_t data_count;
  44.   integer_t ex_data[2];
  45. };

  46. enum darwin_msg_state
  47. {
  48.   /* The thread is running.  */
  49.   DARWIN_RUNNING,

  50.   /* The thread is stopped.  */
  51.   DARWIN_STOPPED,

  52.   /* The thread has sent a message and waits for a reply.  */
  53.   DARWIN_MESSAGE
  54. };

  55. struct private_thread_info
  56. {
  57.   /* The thread port from a GDB point of view.  */
  58.   thread_t gdb_port;

  59.   /* The thread port from the inferior point of view.  Not to be used inside
  60.      gdb except for get_ada_task_ptid.  */
  61.   thread_t inf_port;

  62.   /* Current message state.
  63.      If the kernel has sent a message it expects a reply and the inferior
  64.      can't be killed before.  */
  65.   enum darwin_msg_state msg_state;

  66.   /* True if this thread is single-stepped.  */
  67.   unsigned char single_step;

  68.   /* True if a signal was manually sent to the thread.  */
  69.   unsigned char signaled;

  70.   /* The last exception received.  */
  71.   struct darwin_exception_msg event;
  72. };
  73. typedef struct private_thread_info darwin_thread_t;

  74. /* Define the threads vector type.  */
  75. DEF_VEC_O (darwin_thread_t);


  76. /* Describe an inferior.  */
  77. struct private_inferior
  78. {
  79.   /* Corresponding task port.  */
  80.   task_t task;

  81.   /* Port which will receive the dead-name notification for the task port.
  82.      This is used to detect the death of the task.  */
  83.   mach_port_t notify_port;

  84.   /* Initial exception handling.  */
  85.   darwin_exception_info exception_info;

  86.   /* Number of messages that have been received but not yet replied.  */
  87.   unsigned int pending_messages;

  88.   /* Set if inferior is not controlled by ptrace(2) but through Mach.  */
  89.   unsigned char no_ptrace;

  90.   /* True if this task is suspended.  */
  91.   unsigned char suspended;

  92.   /* Sorted vector of known threads.  */
  93.   VEC(darwin_thread_t) *threads;
  94. };
  95. typedef struct private_inferior darwin_inferior;

  96. /* Exception port.  */
  97. extern mach_port_t darwin_ex_port;

  98. /* Port set.  */
  99. extern mach_port_t darwin_port_set;

  100. /* A copy of mach_host_self ().  */
  101. extern mach_port_t darwin_host_self;

  102. /* FUNCTION_NAME is defined in common-utils.h (or not).  */
  103. #ifdef FUNCTION_NAME
  104. #define MACH_CHECK_ERROR(ret) \
  105.   mach_check_error (ret, __FILE__, __LINE__, FUNCTION_NAME)
  106. #else
  107. #define MACH_CHECK_ERROR(ret) \
  108.   mach_check_error (ret, __FILE__, __LINE__, "??")
  109. #endif

  110. extern void mach_check_error (kern_return_t ret, const char *file,
  111.                               unsigned int line, const char *func);

  112. void darwin_set_sstep (thread_t thread, int enable);

  113. /* This one is called in darwin-nat.c, but needs to be provided by the
  114.    platform specific nat code.  It allows each platform to add platform specific
  115.    stuff to the darwin_ops.  */
  116. extern void darwin_complete_target (struct target_ops *target);

  117. void darwin_check_osabi (darwin_inferior *inf, thread_t thread);

  118. #endif /* __DARWIN_NAT_H__ */