Module: LLDB::APISupport

Defined in:
lib/lldb/api_support.rb

Overview

Module for checking API availability across different LLDB versions and lldb-ruby binding implementations.

Constant Summary collapse

FEATURES =

Legacy method-backed feature mappings are kept for compatibility. Optional LLDB APIs must be listed in CAPABILITIES instead of inferred from FFI symbols.

{
  breakpoint_by_address: :lldb_target_breakpoint_create_by_address,
  breakpoint_by_regex: :lldb_target_breakpoint_create_by_regex,
  memory_read: :lldb_process_read_memory,
  memory_write: :lldb_process_write_memory,
  thread_by_id: :lldb_process_get_thread_by_id,
  memory_region_info: :lldb_process_get_memory_region_info,
  step_into: :lldb_thread_step_into,
  step_over: :lldb_thread_step_over,
  step_out: :lldb_thread_step_out,
  step_instruction: :lldb_thread_step_instruction,
  registers: :lldb_frame_get_registers,
  find_variable: :lldb_frame_find_variable,
  evaluate_expression: :lldb_frame_evaluate_expression
}.freeze
CAPABILITIES =
{
  watchpoint_access_kind: :watchpoint_access_kind
}.freeze

Class Method Summary collapse

Class Method Details

.feature_supported?(feature) ⇒ Boolean

RBS:

  • return: bool

Returns:

  • (Boolean)


66
67
68
69
70
71
72
73
74
# File 'lib/lldb/api_support.rb', line 66

def feature_supported?(feature)
  capability = CAPABILITIES[feature]
  return FFIBindings.capability_supported?(capability) if capability

  method_name = FEATURES[feature]
  return false unless method_name

  method_available?(method_name)
end

.method_available?(method_name) ⇒ Boolean

RBS:

  • return: bool

Returns:

  • (Boolean)


36
37
38
# File 'lib/lldb/api_support.rb', line 36

def method_available?(method_name)
  FFIBindings.respond_to?(method_name)
end

.require_feature!(feature) ⇒ Object

RBS:

  • return: void

Raises:



55
56
57
58
59
60
# File 'lib/lldb/api_support.rb', line 55

def require_feature!(feature)
  return if feature_supported?(feature)

  raise UnsupportedAPIError,
        "Feature '#{feature}' is not supported by the loaded LLDB wrapper"
end

.require_method!(method_name, feature_name = nil) ⇒ Object

RBS:

  • feature_name: String?

  • return: void

Raises:



45
46
47
48
49
50
51
# File 'lib/lldb/api_support.rb', line 45

def require_method!(method_name, feature_name = nil)
  return if method_available?(method_name)

  feature = feature_name || method_name.to_s
  raise UnsupportedAPIError,
        "API '#{feature}' is not supported in this LLDB version or binding"
end

.supported_featuresObject

RBS:

  • return: Array[::Symbol]



79
80
81
# File 'lib/lldb/api_support.rb', line 79

def supported_features
  FEATURES.keys.select { |f| feature_supported?(f) }
end

.unsupported_featuresObject

RBS:

  • return: Array[::Symbol]



86
87
88
# File 'lib/lldb/api_support.rb', line 86

def unsupported_features
  FEATURES.keys.reject { |f| feature_supported?(f) }
end