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