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