lldb-types.h revision d9919d3f46c5069eef065a27f96abc021330d5f3
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_lldb_types_h_ 11#define LLDB_lldb_types_h_ 12 13#include "lldb/lldb-enumerations.h" 14#include "lldb/lldb-forward.h" 15#include "lldb/Utility/SharingPtr.h" 16 17#include <assert.h> 18#include <pthread.h> 19#include <signal.h> 20#include <stdint.h> 21#include <stdbool.h> 22#include <unistd.h> 23 24//---------------------------------------------------------------------- 25// All host systems must define: 26// liblldb::condition_t The native condition type (or a substitute class) for conditions on the host system. 27// liblldb::mutex_t The native mutex type for mutex objects on the host system. 28// liblldb::thread_t The native thread type for spawned threads on the system 29// liblldb::thread_arg_t The type of the one any only thread creation argument for the host system 30// liblldb::thread_result_t The return type that gets returned when a thread finishes. 31// liblldb::thread_func_t The function prototype used to spawn a thread on the host system. 32// liblldb::SharedPtr The template that wraps up the host version of a reference counted pointer (like boost::shared_ptr) 33// #define LLDB_INVALID_PROCESS_ID ... 34// #define LLDB_INVALID_THREAD_ID ... 35// #define LLDB_INVALID_HOST_THREAD ... 36// #define IS_VALID_LLDB_HOST_THREAD ... 37//---------------------------------------------------------------------- 38 39// TODO: Add a bunch of ifdefs to determine the host system and what 40// things should be defined. Currently MacOSX is being assumed by default 41// since that is what lldb was first developed for. 42 43namespace lldb { 44 //---------------------------------------------------------------------- 45 // MacOSX Types 46 //---------------------------------------------------------------------- 47 typedef ::pthread_mutex_t mutex_t; 48 typedef pthread_cond_t condition_t; 49 typedef pthread_t thread_t; // Host thread type 50 typedef void * thread_arg_t; // Host thread argument type 51 typedef void * thread_result_t; // Host thread result type 52 typedef void * (*thread_func_t)(void *); // Host thread function type 53 54 // The template below can be used in a few useful ways: 55 // 56 // // Make a single shared pointer a class Foo 57 // lldb::SharePtr<Foo>::Type foo_sp; 58 // 59 // // Make a typedef to a Foo shared pointer 60 // typedef lldb::SharePtr<Foo>::Type FooSP; 61 // 62 template<typename _Tp> 63 struct SharedPtr 64 { 65 typedef lldb_private::SharingPtr<_Tp> Type; 66 }; 67 template<typename _Tp> 68 struct LoggingSharedPtr 69 { 70 typedef lldb_private::LoggingSharingPtr<_Tp> Type; 71 }; 72 73 template <typename _Tp> 74 struct IntrusiveSharedPtr 75 { 76 typedef lldb_private::IntrusiveSharingPtr<_Tp> Type; 77 }; 78 79} // namespace lldb 80 81#if defined(__MINGW32__) 82 83const lldb::thread_t lldb_invalid_host_thread_const = { NULL, 0 } ; 84#define LLDB_INVALID_HOST_THREAD (lldb_invalid_host_thread_const) 85#define IS_VALID_LLDB_HOST_THREAD(t) (!(NULL == (t).p && 0 == (t).x)) 86 87#else 88 89#define LLDB_INVALID_HOST_THREAD ((lldb::thread_t)NULL) 90#define IS_VALID_LLDB_HOST_THREAD(t) ((t) != LLDB_INVALID_HOST_THREAD) 91 92#endif 93 94#define LLDB_INVALID_HOST_TIME { 0, 0 } 95 96namespace lldb 97{ 98 typedef uint64_t addr_t; 99 typedef uint64_t user_id_t; 100 typedef uint64_t pid_t; 101 typedef uint64_t tid_t; 102 typedef int32_t break_id_t; 103 typedef int32_t watch_id_t; 104 typedef void * clang_type_t; 105} 106 107 108#endif // LLDB_lldb_types_h_ 109