lldb 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.rspec +3 -0
- data/CHANGELOG.md +7 -0
- data/LICENSE-APACHE +190 -0
- data/LICENSE-MIT +21 -0
- data/README.md +240 -0
- data/Rakefile +80 -0
- data/Steepfile +11 -0
- data/examples/basic_debug.rb +111 -0
- data/examples/breakpoints.rb +72 -0
- data/examples/expression_eval.rb +84 -0
- data/examples/test_program.c +14 -0
- data/ext/lldb/Makefile +24 -0
- data/ext/lldb/extconf.rb +160 -0
- data/ext/lldb/liblldb_wrapper.dylib +0 -0
- data/ext/lldb/lldb_wrapper.cpp +2051 -0
- data/ext/lldb/lldb_wrapper.h +424 -0
- data/ext/lldb/lldb_wrapper.o +0 -0
- data/ext/lldb/mkmf.log +24 -0
- data/lib/lldb/breakpoint.rb +233 -0
- data/lib/lldb/breakpoint_location.rb +117 -0
- data/lib/lldb/command_interpreter.rb +62 -0
- data/lib/lldb/command_return_object.rb +71 -0
- data/lib/lldb/debugger.rb +179 -0
- data/lib/lldb/error.rb +70 -0
- data/lib/lldb/ffi_bindings.rb +394 -0
- data/lib/lldb/frame.rb +226 -0
- data/lib/lldb/launch_info.rb +85 -0
- data/lib/lldb/module.rb +61 -0
- data/lib/lldb/process.rb +317 -0
- data/lib/lldb/symbol_context.rb +52 -0
- data/lib/lldb/target.rb +427 -0
- data/lib/lldb/thread.rb +226 -0
- data/lib/lldb/type.rb +215 -0
- data/lib/lldb/types.rb +190 -0
- data/lib/lldb/value.rb +334 -0
- data/lib/lldb/value_list.rb +88 -0
- data/lib/lldb/version.rb +7 -0
- data/lib/lldb/watchpoint.rb +145 -0
- data/lib/lldb.rb +64 -0
- data/lldb.gemspec +33 -0
- data/rbs_collection.lock.yaml +220 -0
- data/rbs_collection.yaml +19 -0
- data/sig/lldb/ffi_bindings.rbs +312 -0
- metadata +102 -0
data/lib/lldb/type.rb
ADDED
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# rbs_inline: enabled
|
|
4
|
+
|
|
5
|
+
module LLDB
|
|
6
|
+
class Type
|
|
7
|
+
# @rbs ptr: FFI::Pointer
|
|
8
|
+
# @rbs return: void
|
|
9
|
+
def initialize(ptr)
|
|
10
|
+
@ptr = ptr # : FFI::Pointer
|
|
11
|
+
ObjectSpace.define_finalizer(self, self.class.release(@ptr))
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
# @rbs ptr: FFI::Pointer
|
|
15
|
+
# @rbs return: ^(Integer) -> void
|
|
16
|
+
def self.release(ptr)
|
|
17
|
+
->(_id) { FFIBindings.lldb_type_destroy(ptr) unless ptr.null? }
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
# @rbs return: bool
|
|
21
|
+
def valid?
|
|
22
|
+
!@ptr.null? && FFIBindings.lldb_type_is_valid(@ptr) != 0
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
# @rbs return: String?
|
|
26
|
+
def name
|
|
27
|
+
return nil unless valid?
|
|
28
|
+
|
|
29
|
+
FFIBindings.lldb_type_get_name(@ptr)
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
# @rbs return: String?
|
|
33
|
+
def display_type_name
|
|
34
|
+
return nil unless valid?
|
|
35
|
+
|
|
36
|
+
FFIBindings.lldb_type_get_display_type_name(@ptr)
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
# @rbs return: Integer
|
|
40
|
+
def byte_size
|
|
41
|
+
return 0 unless valid?
|
|
42
|
+
|
|
43
|
+
FFIBindings.lldb_type_get_byte_size(@ptr)
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
# @rbs return: bool
|
|
47
|
+
def pointer_type?
|
|
48
|
+
return false unless valid?
|
|
49
|
+
|
|
50
|
+
FFIBindings.lldb_type_is_pointer_type(@ptr) != 0
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
# @rbs return: bool
|
|
54
|
+
def reference_type?
|
|
55
|
+
return false unless valid?
|
|
56
|
+
|
|
57
|
+
FFIBindings.lldb_type_is_reference_type(@ptr) != 0
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
# @rbs return: bool
|
|
61
|
+
def array_type?
|
|
62
|
+
return false unless valid?
|
|
63
|
+
|
|
64
|
+
FFIBindings.lldb_type_is_array_type(@ptr) != 0
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
# @rbs return: bool
|
|
68
|
+
def vector_type?
|
|
69
|
+
return false unless valid?
|
|
70
|
+
|
|
71
|
+
FFIBindings.lldb_type_is_vector_type(@ptr) != 0
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
# @rbs return: bool
|
|
75
|
+
def typedef_type?
|
|
76
|
+
return false unless valid?
|
|
77
|
+
|
|
78
|
+
FFIBindings.lldb_type_is_typedef_type(@ptr) != 0
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
# @rbs return: bool
|
|
82
|
+
def function_type?
|
|
83
|
+
return false unless valid?
|
|
84
|
+
|
|
85
|
+
FFIBindings.lldb_type_is_function_type(@ptr) != 0
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
# @rbs return: bool
|
|
89
|
+
def polymorphic_class?
|
|
90
|
+
return false unless valid?
|
|
91
|
+
|
|
92
|
+
FFIBindings.lldb_type_is_polymorphic_class(@ptr) != 0
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
# @rbs return: Type?
|
|
96
|
+
def pointer_type
|
|
97
|
+
raise InvalidObjectError, 'Type is not valid' unless valid?
|
|
98
|
+
|
|
99
|
+
ptr = FFIBindings.lldb_type_get_pointer_type(@ptr)
|
|
100
|
+
return nil if ptr.nil? || ptr.null?
|
|
101
|
+
|
|
102
|
+
Type.new(ptr)
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
# @rbs return: Type?
|
|
106
|
+
def pointee_type
|
|
107
|
+
raise InvalidObjectError, 'Type is not valid' unless valid?
|
|
108
|
+
|
|
109
|
+
ptr = FFIBindings.lldb_type_get_pointee_type(@ptr)
|
|
110
|
+
return nil if ptr.nil? || ptr.null?
|
|
111
|
+
|
|
112
|
+
Type.new(ptr)
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
# @rbs return: Type?
|
|
116
|
+
def reference_type
|
|
117
|
+
raise InvalidObjectError, 'Type is not valid' unless valid?
|
|
118
|
+
|
|
119
|
+
ptr = FFIBindings.lldb_type_get_reference_type(@ptr)
|
|
120
|
+
return nil if ptr.nil? || ptr.null?
|
|
121
|
+
|
|
122
|
+
Type.new(ptr)
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
# @rbs return: Type?
|
|
126
|
+
def dereferenced_type
|
|
127
|
+
raise InvalidObjectError, 'Type is not valid' unless valid?
|
|
128
|
+
|
|
129
|
+
ptr = FFIBindings.lldb_type_get_dereferenced_type(@ptr)
|
|
130
|
+
return nil if ptr.nil? || ptr.null?
|
|
131
|
+
|
|
132
|
+
Type.new(ptr)
|
|
133
|
+
end
|
|
134
|
+
|
|
135
|
+
# @rbs return: Type?
|
|
136
|
+
def unqualified_type
|
|
137
|
+
raise InvalidObjectError, 'Type is not valid' unless valid?
|
|
138
|
+
|
|
139
|
+
ptr = FFIBindings.lldb_type_get_unqualified_type(@ptr)
|
|
140
|
+
return nil if ptr.nil? || ptr.null?
|
|
141
|
+
|
|
142
|
+
Type.new(ptr)
|
|
143
|
+
end
|
|
144
|
+
|
|
145
|
+
# @rbs return: Type?
|
|
146
|
+
def canonical_type
|
|
147
|
+
raise InvalidObjectError, 'Type is not valid' unless valid?
|
|
148
|
+
|
|
149
|
+
ptr = FFIBindings.lldb_type_get_canonical_type(@ptr)
|
|
150
|
+
return nil if ptr.nil? || ptr.null?
|
|
151
|
+
|
|
152
|
+
Type.new(ptr)
|
|
153
|
+
end
|
|
154
|
+
|
|
155
|
+
# @rbs return: Type?
|
|
156
|
+
def array_element_type
|
|
157
|
+
raise InvalidObjectError, 'Type is not valid' unless valid?
|
|
158
|
+
|
|
159
|
+
ptr = FFIBindings.lldb_type_get_array_element_type(@ptr)
|
|
160
|
+
return nil if ptr.nil? || ptr.null?
|
|
161
|
+
|
|
162
|
+
Type.new(ptr)
|
|
163
|
+
end
|
|
164
|
+
|
|
165
|
+
# @rbs return: Integer
|
|
166
|
+
def array_size
|
|
167
|
+
return 0 unless valid?
|
|
168
|
+
|
|
169
|
+
FFIBindings.lldb_type_get_array_size(@ptr)
|
|
170
|
+
end
|
|
171
|
+
|
|
172
|
+
# @rbs return: Integer
|
|
173
|
+
def num_fields
|
|
174
|
+
return 0 unless valid?
|
|
175
|
+
|
|
176
|
+
FFIBindings.lldb_type_get_num_fields(@ptr)
|
|
177
|
+
end
|
|
178
|
+
|
|
179
|
+
# @rbs return: Integer
|
|
180
|
+
def num_direct_base_classes
|
|
181
|
+
return 0 unless valid?
|
|
182
|
+
|
|
183
|
+
FFIBindings.lldb_type_get_num_direct_base_classes(@ptr)
|
|
184
|
+
end
|
|
185
|
+
|
|
186
|
+
# @rbs return: Integer
|
|
187
|
+
def num_virtual_base_classes
|
|
188
|
+
return 0 unless valid?
|
|
189
|
+
|
|
190
|
+
FFIBindings.lldb_type_get_num_virtual_base_classes(@ptr)
|
|
191
|
+
end
|
|
192
|
+
|
|
193
|
+
# @rbs return: Integer
|
|
194
|
+
def basic_type
|
|
195
|
+
return BasicType::INVALID unless valid?
|
|
196
|
+
|
|
197
|
+
FFIBindings.lldb_type_get_basic_type(@ptr)
|
|
198
|
+
end
|
|
199
|
+
|
|
200
|
+
# @rbs return: String
|
|
201
|
+
def to_s
|
|
202
|
+
display_type_name || name || '(unknown type)'
|
|
203
|
+
end
|
|
204
|
+
|
|
205
|
+
# @rbs return: String
|
|
206
|
+
def inspect
|
|
207
|
+
"#<LLDB::Type name=#{name.inspect} byte_size=#{byte_size}>"
|
|
208
|
+
end
|
|
209
|
+
|
|
210
|
+
# @rbs return: FFI::Pointer
|
|
211
|
+
def to_ptr
|
|
212
|
+
@ptr
|
|
213
|
+
end
|
|
214
|
+
end
|
|
215
|
+
end
|
data/lib/lldb/types.rb
ADDED
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# rbs_inline: enabled
|
|
4
|
+
|
|
5
|
+
module LLDB
|
|
6
|
+
module State
|
|
7
|
+
INVALID = 0 # : Integer
|
|
8
|
+
UNLOADED = 1 # : Integer
|
|
9
|
+
CONNECTED = 2 # : Integer
|
|
10
|
+
ATTACHING = 3 # : Integer
|
|
11
|
+
LAUNCHING = 4 # : Integer
|
|
12
|
+
STOPPED = 5 # : Integer
|
|
13
|
+
RUNNING = 6 # : Integer
|
|
14
|
+
STEPPING = 7 # : Integer
|
|
15
|
+
CRASHED = 8 # : Integer
|
|
16
|
+
DETACHED = 9 # : Integer
|
|
17
|
+
EXITED = 10 # : Integer
|
|
18
|
+
SUSPENDED = 11 # : Integer
|
|
19
|
+
|
|
20
|
+
NAMES = { # : Hash[Integer, String]
|
|
21
|
+
INVALID => 'invalid',
|
|
22
|
+
UNLOADED => 'unloaded',
|
|
23
|
+
CONNECTED => 'connected',
|
|
24
|
+
ATTACHING => 'attaching',
|
|
25
|
+
LAUNCHING => 'launching',
|
|
26
|
+
STOPPED => 'stopped',
|
|
27
|
+
RUNNING => 'running',
|
|
28
|
+
STEPPING => 'stepping',
|
|
29
|
+
CRASHED => 'crashed',
|
|
30
|
+
DETACHED => 'detached',
|
|
31
|
+
EXITED => 'exited',
|
|
32
|
+
SUSPENDED => 'suspended'
|
|
33
|
+
}.freeze
|
|
34
|
+
|
|
35
|
+
# @rbs state: Integer
|
|
36
|
+
# @rbs return: String
|
|
37
|
+
def self.name(state)
|
|
38
|
+
NAMES[state] || 'unknown'
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
module StopReason
|
|
43
|
+
INVALID = 0 # : Integer
|
|
44
|
+
NONE = 1 # : Integer
|
|
45
|
+
TRACE = 2 # : Integer
|
|
46
|
+
BREAKPOINT = 3 # : Integer
|
|
47
|
+
WATCHPOINT = 4 # : Integer
|
|
48
|
+
SIGNAL = 5 # : Integer
|
|
49
|
+
EXCEPTION = 6 # : Integer
|
|
50
|
+
EXEC = 7 # : Integer
|
|
51
|
+
PLAN_COMPLETE = 8 # : Integer
|
|
52
|
+
THREAD_EXITING = 9 # : Integer
|
|
53
|
+
INSTRUMENTATION = 10 # : Integer
|
|
54
|
+
|
|
55
|
+
NAMES = { # : Hash[Integer, String]
|
|
56
|
+
INVALID => 'invalid',
|
|
57
|
+
NONE => 'none',
|
|
58
|
+
TRACE => 'trace',
|
|
59
|
+
BREAKPOINT => 'breakpoint',
|
|
60
|
+
WATCHPOINT => 'watchpoint',
|
|
61
|
+
SIGNAL => 'signal',
|
|
62
|
+
EXCEPTION => 'exception',
|
|
63
|
+
EXEC => 'exec',
|
|
64
|
+
PLAN_COMPLETE => 'plan complete',
|
|
65
|
+
THREAD_EXITING => 'thread exiting',
|
|
66
|
+
INSTRUMENTATION => 'instrumentation'
|
|
67
|
+
}.freeze
|
|
68
|
+
|
|
69
|
+
# @rbs reason: Integer
|
|
70
|
+
# @rbs return: String
|
|
71
|
+
def self.name(reason)
|
|
72
|
+
NAMES[reason] || 'unknown'
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
module SymbolContextItem
|
|
77
|
+
TARGET = 1 << 0 # : Integer
|
|
78
|
+
MODULE = 1 << 1 # : Integer
|
|
79
|
+
COMPILE_UNIT = 1 << 2 # : Integer
|
|
80
|
+
FUNCTION = 1 << 3 # : Integer
|
|
81
|
+
BLOCK = 1 << 4 # : Integer
|
|
82
|
+
LINE_ENTRY = 1 << 5 # : Integer
|
|
83
|
+
SYMBOL = 1 << 6 # : Integer
|
|
84
|
+
EVERYTHING = 0xFFFF # : Integer
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
module ValueType
|
|
88
|
+
INVALID = 0 # : Integer
|
|
89
|
+
VARIABLE_GLOBAL = 1 # : Integer
|
|
90
|
+
VARIABLE_STATIC = 2 # : Integer
|
|
91
|
+
VARIABLE_ARGUMENT = 3 # : Integer
|
|
92
|
+
VARIABLE_LOCAL = 4 # : Integer
|
|
93
|
+
REGISTER = 5 # : Integer
|
|
94
|
+
REGISTER_SET = 6 # : Integer
|
|
95
|
+
CONSTANT_RESULT = 7 # : Integer
|
|
96
|
+
|
|
97
|
+
NAMES = { # : Hash[Integer, String]
|
|
98
|
+
INVALID => 'invalid',
|
|
99
|
+
VARIABLE_GLOBAL => 'global',
|
|
100
|
+
VARIABLE_STATIC => 'static',
|
|
101
|
+
VARIABLE_ARGUMENT => 'argument',
|
|
102
|
+
VARIABLE_LOCAL => 'local',
|
|
103
|
+
REGISTER => 'register',
|
|
104
|
+
REGISTER_SET => 'register set',
|
|
105
|
+
CONSTANT_RESULT => 'constant result'
|
|
106
|
+
}.freeze
|
|
107
|
+
|
|
108
|
+
# @rbs value_type: Integer
|
|
109
|
+
# @rbs return: String
|
|
110
|
+
def self.name(value_type)
|
|
111
|
+
NAMES[value_type] || 'unknown'
|
|
112
|
+
end
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
module BasicType
|
|
116
|
+
INVALID = 0 # : Integer
|
|
117
|
+
VOID = 1 # : Integer
|
|
118
|
+
CHAR = 2 # : Integer
|
|
119
|
+
SIGNED_CHAR = 3 # : Integer
|
|
120
|
+
UNSIGNED_CHAR = 4 # : Integer
|
|
121
|
+
WCHAR = 5 # : Integer
|
|
122
|
+
SIGNED_WCHAR = 6 # : Integer
|
|
123
|
+
UNSIGNED_WCHAR = 7 # : Integer
|
|
124
|
+
CHAR16 = 8 # : Integer
|
|
125
|
+
CHAR32 = 9 # : Integer
|
|
126
|
+
SHORT = 10 # : Integer
|
|
127
|
+
UNSIGNED_SHORT = 11 # : Integer
|
|
128
|
+
INT = 12 # : Integer
|
|
129
|
+
UNSIGNED_INT = 13 # : Integer
|
|
130
|
+
LONG = 14 # : Integer
|
|
131
|
+
UNSIGNED_LONG = 15 # : Integer
|
|
132
|
+
LONG_LONG = 16 # : Integer
|
|
133
|
+
UNSIGNED_LONG_LONG = 17 # : Integer
|
|
134
|
+
INT128 = 18 # : Integer
|
|
135
|
+
UNSIGNED_INT128 = 19 # : Integer
|
|
136
|
+
BOOL = 20 # : Integer
|
|
137
|
+
HALF = 21 # : Integer
|
|
138
|
+
FLOAT = 22 # : Integer
|
|
139
|
+
DOUBLE = 23 # : Integer
|
|
140
|
+
LONG_DOUBLE = 24 # : Integer
|
|
141
|
+
FLOAT_COMPLEX = 25 # : Integer
|
|
142
|
+
DOUBLE_COMPLEX = 26 # : Integer
|
|
143
|
+
LONG_DOUBLE_COMPLEX = 27 # : Integer
|
|
144
|
+
OBJ_C_ID = 28 # : Integer
|
|
145
|
+
OBJ_C_CLASS = 29 # : Integer
|
|
146
|
+
OBJ_C_SEL = 30 # : Integer
|
|
147
|
+
NULL_PTR = 31 # : Integer
|
|
148
|
+
|
|
149
|
+
NAMES = { # : Hash[Integer, String]
|
|
150
|
+
INVALID => 'invalid',
|
|
151
|
+
VOID => 'void',
|
|
152
|
+
CHAR => 'char',
|
|
153
|
+
SIGNED_CHAR => 'signed char',
|
|
154
|
+
UNSIGNED_CHAR => 'unsigned char',
|
|
155
|
+
WCHAR => 'wchar_t',
|
|
156
|
+
SIGNED_WCHAR => 'signed wchar_t',
|
|
157
|
+
UNSIGNED_WCHAR => 'unsigned wchar_t',
|
|
158
|
+
CHAR16 => 'char16_t',
|
|
159
|
+
CHAR32 => 'char32_t',
|
|
160
|
+
SHORT => 'short',
|
|
161
|
+
UNSIGNED_SHORT => 'unsigned short',
|
|
162
|
+
INT => 'int',
|
|
163
|
+
UNSIGNED_INT => 'unsigned int',
|
|
164
|
+
LONG => 'long',
|
|
165
|
+
UNSIGNED_LONG => 'unsigned long',
|
|
166
|
+
LONG_LONG => 'long long',
|
|
167
|
+
UNSIGNED_LONG_LONG => 'unsigned long long',
|
|
168
|
+
INT128 => '__int128',
|
|
169
|
+
UNSIGNED_INT128 => 'unsigned __int128',
|
|
170
|
+
BOOL => 'bool',
|
|
171
|
+
HALF => 'half',
|
|
172
|
+
FLOAT => 'float',
|
|
173
|
+
DOUBLE => 'double',
|
|
174
|
+
LONG_DOUBLE => 'long double',
|
|
175
|
+
FLOAT_COMPLEX => 'float complex',
|
|
176
|
+
DOUBLE_COMPLEX => 'double complex',
|
|
177
|
+
LONG_DOUBLE_COMPLEX => 'long double complex',
|
|
178
|
+
OBJ_C_ID => 'id',
|
|
179
|
+
OBJ_C_CLASS => 'Class',
|
|
180
|
+
OBJ_C_SEL => 'SEL',
|
|
181
|
+
NULL_PTR => 'nullptr_t'
|
|
182
|
+
}.freeze
|
|
183
|
+
|
|
184
|
+
# @rbs basic_type: Integer
|
|
185
|
+
# @rbs return: String
|
|
186
|
+
def self.name(basic_type)
|
|
187
|
+
NAMES[basic_type] || 'unknown'
|
|
188
|
+
end
|
|
189
|
+
end
|
|
190
|
+
end
|