lldb-types.h revision 5f81547fd786584b10999c087528b323b5945896
1//===-- lldb-types.h --------------------------------------------*- C++ -*-===// 2// 3// The LLVM Compiler Infrastructure 4// 5// This file is distributed under the University of Illinois Open Source 6// License. See LICENSE.TXT for details. 7// 8//===----------------------------------------------------------------------===// 9 10#ifndef LLDB_types_h_ 11#define LLDB_types_h_ 12 13#include "lldb/lldb-enumerations.h" 14#include "lldb/lldb-forward.h" 15 16//---------------------------------------------------------------------- 17//---------------------------------------------------------------------- 18// MACOSX START 19//---------------------------------------------------------------------- 20//---------------------------------------------------------------------- 21 22#include <assert.h> 23#include <mach/mach_types.h> 24#include <machine/endian.h> 25#include <pthread.h> 26#include <signal.h> 27#include <stdint.h> 28#include <stdbool.h> 29#include <sys/syslimits.h> 30#include <unistd.h> 31 32#ifndef NO_RTTI 33 34//---------------------------------------------------------------------- 35// And source files that may not have RTTI enabled during their 36// compilation will want to do a "#define NO_RTTI" before including the 37// lldb-include.h file. 38//---------------------------------------------------------------------- 39 40#include <tr1/memory> // for std::tr1::shared_ptr 41 42#endif 43 44//---------------------------------------------------------------------- 45// All host systems must define: 46// liblldb::condition_t The native condition type (or a substitute class) for conditions on the host system. 47// liblldb::mutex_t The native mutex type for mutex objects on the host system. 48// liblldb::thread_t The native thread type for spawned threads on the system 49// liblldb::thread_arg_t The type of the one any only thread creation argument for the host system 50// liblldb::thread_result_t The return type that gets returned when a thread finishes. 51// liblldb::thread_func_t The function prototype used to spawn a thread on the host system. 52// liblldb::SharedPtr The template that wraps up the host version of a reference counted pointer (like boost::shared_ptr) 53// #define LLDB_INVALID_PROCESS_ID ... 54// #define LLDB_INVALID_THREAD_ID ... 55// #define LLDB_INVALID_HOST_THREAD ... 56//---------------------------------------------------------------------- 57 58// TODO: Add a bunch of ifdefs to determine the host system and what 59// things should be defined. Currently MacOSX is being assumed by default 60// since that is what lldb was first developed for. 61 62namespace lldb { 63 //---------------------------------------------------------------------- 64 // MacOSX Types 65 //---------------------------------------------------------------------- 66 typedef ::pthread_mutex_t mutex_t; 67 typedef pthread_cond_t condition_t; 68 typedef pthread_t thread_t; // Host thread type 69 typedef void * thread_arg_t; // Host thread argument type 70 typedef void * thread_result_t; // Host thread result type 71 typedef void * (*thread_func_t)(void *); // Host thread function type 72 73#ifndef NO_RTTI 74 // The template below can be used in a few useful ways: 75 // 76 // // Make a single shared pointer a class Foo 77 // lldb::SharePtr<Foo>::Type foo_sp; 78 // 79 // // Make a typedef to a Foo shared pointer 80 // typedef lldb::SharePtr<Foo>::Type FooSP; 81 // 82 template<typename _Tp> 83 struct SharedPtr 84 { 85 typedef std::tr1::shared_ptr<_Tp> Type; 86 }; 87#endif 88 89} // namespace lldb 90 91#define LLDB_INVALID_HOST_THREAD ((lldb::thread_t)NULL) 92#define LLDB_INVALID_HOST_TIME { 0, 0 } 93 94//---------------------------------------------------------------------- 95//---------------------------------------------------------------------- 96// MACOSX END 97//---------------------------------------------------------------------- 98//---------------------------------------------------------------------- 99 100#ifdef SWIG 101#define CONST_CHAR_PTR char * 102#else 103#define CONST_CHAR_PTR const char * 104#endif 105 106namespace lldb { 107 typedef uint64_t addr_t; 108 typedef uint32_t user_id_t; 109 typedef int32_t pid_t; 110 typedef uint32_t tid_t; 111 typedef int32_t break_id_t; 112 113 //---------------------------------------------------------------------- 114 // Every register is described in detail including its name, alternate 115 // name (optional), encoding, size in bytes and the default display 116 // format. 117 //---------------------------------------------------------------------- 118 typedef struct 119 { 120 CONST_CHAR_PTR name; // Name of this register, can't be NULL 121 CONST_CHAR_PTR alt_name; // Alternate name of this register, can be NULL 122 uint32_t byte_size; // Size in bytes of the register 123 uint32_t byte_offset; // The byte offset in the register context data where this register's value is found 124 lldb::Encoding encoding; // Encoding of the register bits 125 lldb::Format format; // Default display format 126 uint32_t reg; // The native register number for this register 127 uint32_t kinds[kNumRegisterKinds]; // Holds all of the various register numbers for all register kinds 128 } RegisterInfo; 129 130 //---------------------------------------------------------------------- 131 // Registers are grouped into register sets 132 //---------------------------------------------------------------------- 133 typedef struct 134 { 135 CONST_CHAR_PTR name; // Name of this register set 136 CONST_CHAR_PTR short_name; // A short name for this register set 137 size_t num_registers; // The number of registers in REGISTERS array below 138 const uint32_t *registers; // An array of register numbers in this set 139 } RegisterSet; 140 141 typedef struct 142 { 143 int value; 144 CONST_CHAR_PTR string_value; 145 CONST_CHAR_PTR usage; 146 } OptionEnumValueElement; 147 148 typedef struct 149 { 150 uint32_t usage_level; // Used to mark options that can be used together. 151 bool required; // This option is required (in the current usage level) 152 CONST_CHAR_PTR long_option; // Full name for this option. 153 char short_option; // Single character for this option. 154 int option_has_arg; // no_argument, required_argument or optional_argument 155 OptionEnumValueElement *enum_values;// If non-NULL an array of enum values. 156 uint32_t completionType; // Cookie the option class can use to do define the argument completion. 157 CONST_CHAR_PTR argument_name; // Text name to be use in usage text to refer to the option's value. 158 CONST_CHAR_PTR usage_text; // Full text explaining what this options does and what (if any) argument to 159 // pass it. 160 } OptionDefinition; 161 162 163 typedef int (*comparison_function)(const void *, const void *); 164} 165 166#undef CONST_CHAR_PTR 167 168#endif // LLDB_types_h_ 169