Class: LLDB::LaunchInfo

Inherits:
Object
  • Object
show all
Includes:
NativeLifecycle
Defined in:
lib/lldb/launch_info.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from NativeLifecycle

#close, #closed?, #context, #context!, #ensure_open!, #initialize_native_object

Constructor Details

#initialize(args = nil, context: nil) ⇒ LaunchInfo

Returns a new instance of LaunchInfo.

RBS:

  • args: Array[String]?

  • return: void



29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/lldb/launch_info.rb', line 29

def initialize(args = nil, context: nil)
  @arguments = if args && !args.empty?
                 NativeStringArray.new(args)
               end

  ptr = FFIBindings.lldb_launch_info_create(@arguments&.to_ptr)
  initialize_native_object(
    ptr,
    release: ->(released) { FFIBindings.lldb_launch_info_destroy(released) },
    context: context
  )
end

Class Method Details

.release(ptr) ⇒ Object

RBS:

  • ptr: FFI::Pointer

  • return: ^(Integer) -> void



44
45
46
# File 'lib/lldb/launch_info.rb', line 44

def self.release(ptr)
  ->(_id) { FFIBindings.lldb_launch_info_destroy(ptr) unless ptr.null? }
end

Instance Method Details

#add_close_file_action(fd) ⇒ Object

RBS:

  • fd: Integer

  • return: bool



166
167
168
# File 'lib/lldb/launch_info.rb', line 166

def add_close_file_action(fd)
  FFIBindings.lldb_launch_info_add_close_file_action(@ptr, fd) != 0
end

#add_duplicate_file_action(fd, dup_fd) ⇒ Object

RBS:

  • fd: Integer

  • dup_fd: Integer

  • return: bool



173
174
175
# File 'lib/lldb/launch_info.rb', line 173

def add_duplicate_file_action(fd, dup_fd)
  FFIBindings.lldb_launch_info_add_duplicate_file_action(@ptr, fd, dup_fd) != 0
end

#add_open_file_action(fd, path, read: false, write: false) ⇒ Object

RBS:

  • fd: Integer

  • path: String

  • read: bool

  • write: bool

  • return: bool



182
183
184
185
# File 'lib/lldb/launch_info.rb', line 182

def add_open_file_action(fd, path, read: false, write: false)
  NativeStringArray.validate!(path)
  FFIBindings.lldb_launch_info_add_open_file_action(@ptr, fd, path, read ? 1 : 0, write ? 1 : 0) != 0
end

#add_suppress_file_action(fd, read: false, write: false) ⇒ Object

RBS:

  • fd: Integer

  • read: bool

  • write: bool

  • return: bool



191
192
193
# File 'lib/lldb/launch_info.rb', line 191

def add_suppress_file_action(fd, read: false, write: false)
  FFIBindings.lldb_launch_info_add_suppress_file_action(@ptr, fd, read ? 1 : 0, write ? 1 : 0) != 0
end

#argumentsObject

RBS:

  • return: Array[String]



94
95
96
97
# File 'lib/lldb/launch_info.rb', line 94

def arguments
  count = FFIBindings.lldb_launch_info_get_num_arguments(@ptr)
  (0...count).map { |index| FFIBindings.lldb_launch_info_get_argument_at_index(@ptr, index).to_s }
end

#arguments=(args, append: false) ⇒ Object

RBS:

  • args: Array[String]

  • append: bool

  • return: void

Raises:

  • (ArgumentError)


86
87
88
89
90
91
# File 'lib/lldb/launch_info.rb', line 86

def arguments=(args, append: false)
  raise ArgumentError, 'arguments must be an Array' unless args.is_a?(Array)

  @arguments = NativeStringArray.new(args)
  FFIBindings.lldb_launch_info_set_arguments(@ptr, @arguments.to_ptr, append ? 1 : 0)
end

#environment_entriesObject

RBS:

  • return: Array[String]



100
101
102
103
104
105
# File 'lib/lldb/launch_info.rb', line 100

def environment_entries
  count = FFIBindings.lldb_launch_info_get_num_environment_entries(@ptr)
  (0...count).map do |index|
    FFIBindings.lldb_launch_info_get_environment_entry_at_index(@ptr, index).to_s
  end
end

#executable_fileObject

RBS:

  • return: FileSpec?



108
109
110
111
112
113
# File 'lib/lldb/launch_info.rb', line 108

def executable_file
  file_ptr = FFIBindings.lldb_launch_info_get_executable_file(@ptr)
  return nil if file_ptr.nil? || file_ptr.null?

  FileSpec.from_ptr(file_ptr, context: context)
end

#executable_file=(file, add_as_first_arg: false) ⇒ Object

RBS:

  • file: FileSpec

  • add_as_first_arg: bool

  • return: void

Raises:

  • (ArgumentError)


118
119
120
121
122
# File 'lib/lldb/launch_info.rb', line 118

def executable_file=(file, add_as_first_arg: false)
  raise ArgumentError, 'file must be a FileSpec' unless file.is_a?(FileSpec)

  FFIBindings.lldb_launch_info_set_executable_file(@ptr, file.to_ptr, add_as_first_arg ? 1 : 0)
end

#launch_flagsObject

RBS:

  • return: Integer



196
197
198
# File 'lib/lldb/launch_info.rb', line 196

def launch_flags
  FFIBindings.lldb_launch_info_get_launch_flags(@ptr)
end

#launch_flags=(flags) ⇒ Object

RBS:

  • flags: Integer

  • return: void



202
203
204
# File 'lib/lldb/launch_info.rb', line 202

def launch_flags=(flags)
  FFIBindings.lldb_launch_info_set_launch_flags(@ptr, flags)
end

#listenerObject

RBS:

  • return: Listener?



125
126
127
128
129
130
# File 'lib/lldb/launch_info.rb', line 125

def listener
  listener_ptr = FFIBindings.lldb_launch_info_get_listener(@ptr)
  return nil if listener_ptr.nil? || listener_ptr.null?

  Listener.from_ptr(listener_ptr, context: context)
end

#listener=(value) ⇒ Object

RBS:

  • value: Listener

  • return: void

Raises:

  • (ArgumentError)


134
135
136
137
138
# File 'lib/lldb/launch_info.rb', line 134

def listener=(value)
  raise ArgumentError, 'listener must be a Listener' unless value.is_a?(Listener)

  FFIBindings.lldb_launch_info_set_listener(@ptr, value.to_ptr)
end

#process_plugin_nameObject

RBS:

  • return: String?



141
142
143
# File 'lib/lldb/launch_info.rb', line 141

def process_plugin_name
  FFIBindings.lldb_launch_info_get_process_plugin_name(@ptr)
end

#process_plugin_name=(value) ⇒ Object

RBS:

  • value: String

  • return: void



147
148
149
150
# File 'lib/lldb/launch_info.rb', line 147

def process_plugin_name=(value)
  NativeStringArray.validate!(value)
  FFIBindings.lldb_launch_info_set_process_plugin_name(@ptr, value)
end

#set_environment(env, append: true) ⇒ Object

RBS:

  • env: Hash[String, String]?

  • append: bool

  • return: void

Raises:

  • (ArgumentError)


68
69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/lldb/launch_info.rb', line 68

def set_environment(env, append: true)
  return if env.nil?
  raise ArgumentError, 'environment must be a Hash' unless env.is_a?(Hash)

  entries = env.map do |key, value|
    key = NativeStringArray.validate!(key)
    value = NativeStringArray.validate!(value)
    raise ArgumentError, 'environment keys must not contain =' if key.include?('=')

    "#{key}=#{value}"
  end
  strings = NativeStringArray.new(entries)
  FFIBindings.lldb_launch_info_set_environment_entries(@ptr, strings.to_ptr, append ? 1 : 0)
end

#shellObject

RBS:

  • return: String?



153
154
155
# File 'lib/lldb/launch_info.rb', line 153

def shell
  FFIBindings.lldb_launch_info_get_shell(@ptr)
end

#shell=(value) ⇒ Object

RBS:

  • value: String

  • return: void



159
160
161
162
# File 'lib/lldb/launch_info.rb', line 159

def shell=(value)
  NativeStringArray.validate!(value)
  FFIBindings.lldb_launch_info_set_shell(@ptr, value)
end

#to_ptrObject

RBS:

  • return: FFI::Pointer



207
208
209
# File 'lib/lldb/launch_info.rb', line 207

def to_ptr
  @ptr
end

#valid?Boolean

RBS:

  • return: bool

Returns:

  • (Boolean)


49
50
51
# File 'lib/lldb/launch_info.rb', line 49

def valid?
  !@ptr.null?
end

#working_directoryObject

RBS:

  • return: String?



61
62
63
# File 'lib/lldb/launch_info.rb', line 61

def working_directory
  FFIBindings.lldb_launch_info_get_working_directory(@ptr)
end

#working_directory=(dir) ⇒ Object

RBS:

  • dir: String

  • return: void



55
56
57
58
# File 'lib/lldb/launch_info.rb', line 55

def working_directory=(dir)
  NativeStringArray.validate!(dir)
  FFIBindings.lldb_launch_info_set_working_directory(@ptr, dir)
end