lldb-types.h revision 05faf67f894348849cba4055e76da89f3aa883ab
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 <pthread.h>
24#include <signal.h>
25#include <stdint.h>
26#include <stdbool.h>
27#include <unistd.h>
28
29#ifndef NO_RTTI
30
31//----------------------------------------------------------------------
32// And source files that may not have RTTI enabled during their
33// compilation will want to do a "#define NO_RTTI" before including the
34// lldb-include.h file.
35//----------------------------------------------------------------------
36
37#include <tr1/memory> // for std::tr1::shared_ptr
38
39#endif
40
41//----------------------------------------------------------------------
42// All host systems must define:
43//  liblldb::condition_t       The native condition type (or a substitute class) for conditions on the host system.
44//  liblldb::mutex_t           The native mutex type for mutex objects on the host system.
45//  liblldb::thread_t          The native thread type for spawned threads on the system
46//  liblldb::thread_arg_t      The type of the one any only thread creation argument for the host system
47//  liblldb::thread_result_t   The return type that gets returned when a thread finishes.
48//  liblldb::thread_func_t     The function prototype used to spawn a thread on the host system.
49//  liblldb::SharedPtr         The template that wraps up the host version of a reference counted pointer (like boost::shared_ptr)
50//  #define LLDB_INVALID_PROCESS_ID ...
51//  #define LLDB_INVALID_THREAD_ID ...
52//  #define LLDB_INVALID_HOST_THREAD ...
53//----------------------------------------------------------------------
54
55// TODO: Add a bunch of ifdefs to determine the host system and what
56// things should be defined. Currently MacOSX is being assumed by default
57// since that is what lldb was first developed for.
58
59namespace lldb {
60        //----------------------------------------------------------------------
61        // MacOSX Types
62        //----------------------------------------------------------------------
63        typedef ::pthread_mutex_t   mutex_t;
64        typedef pthread_cond_t      condition_t;
65        typedef pthread_t           thread_t;                   // Host thread type
66        typedef void *              thread_arg_t;               // Host thread argument type
67        typedef void *              thread_result_t;            // Host thread result type
68        typedef void *              (*thread_func_t)(void *);   // Host thread function type
69
70#ifndef NO_RTTI
71        // The template below can be used in a few useful ways:
72        //
73        //      // Make a single shared pointer a class Foo
74        //      lldb::SharePtr<Foo>::Type foo_sp;
75        //
76        //      // Make a typedef to a Foo shared pointer
77        //      typedef lldb::SharePtr<Foo>::Type FooSP;
78        //
79        template<typename _Tp>
80        struct SharedPtr
81        {
82            typedef std::tr1::shared_ptr<_Tp> Type;
83        };
84#endif
85
86} // namespace lldb
87
88#define LLDB_INVALID_HOST_THREAD         ((lldb::thread_t)NULL)
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
110    //----------------------------------------------------------------------
111    // Every register is described in detail including its name, alternate
112    // name (optional), encoding, size in bytes and the default display
113    // format.
114    //----------------------------------------------------------------------
115    typedef struct
116    {
117        CONST_CHAR_PTR  name;           // Name of this register, can't be NULL
118        CONST_CHAR_PTR  alt_name;       // Alternate name of this register, can be NULL
119        uint32_t        byte_size;      // Size in bytes of the register
120        uint32_t        byte_offset;    // The byte offset in the register context data where this register's value is found
121        lldb::Encoding  encoding;       // Encoding of the register bits
122        lldb::Format    format;         // Default display format
123        uint32_t        reg;            // The native register number for this register
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_level;    // Used to mark options that can be used together.
148        bool            required;       // This option is required (in the current usage level)
149        CONST_CHAR_PTR  long_option;    // Full name for this option.
150        char            short_option;   // Single character for this option.
151        int             option_has_arg; // no_argument, required_argument or optional_argument
152        OptionEnumValueElement *enum_values;// If non-NULL an array of enum values.
153        uint32_t        completionType; // Cookie the option class can use to do define the argument completion.
154        CONST_CHAR_PTR  argument_name;  // Text name to be use in usage text to refer to the option's value.
155        CONST_CHAR_PTR  usage_text;     // Full text explaining what this options does and what (if any) argument to
156                                        // pass it.
157    } OptionDefinition;
158
159
160    typedef int (*comparison_function)(const void *, const void *);
161}
162
163#undef CONST_CHAR_PTR
164
165#endif  // LLDB_types_h_
166