class Lldbrun::ParserARGV

Constants

COUNT_LLDB_VERSIONS
DEFAULT_LLDB
DEFAULT_LLDB_OPTIONS
DEFAULT_START_DIR
PARAMETER_FILE_PATH
PARAMETER_HELP
PARAMETER_LLDB
PARAMETER_LLDB_OPTIONS
PARAMETER_RUN
PARAMETER_SCAN_DIR
PARAMETER_SKIP

Attributes

argv[R]
params[R]

Public Class Methods

new(argv) click to toggle source
# File lib/lldbrun/ParserARGV.rb, line 20
def initialize(argv)
  @argv   = argv
  @params = {}

  check_info
  get_params
end

Public Instance Methods

param_auto_run?() click to toggle source
# File lib/lldbrun/ParserARGV.rb, line 40
def param_auto_run?
  params[PARAMETER_RUN] ? params[PARAMETER_RUN] == 'true' : true
end
param_file_path() click to toggle source
# File lib/lldbrun/ParserARGV.rb, line 28
def param_file_path
  params[PARAMETER_FILE_PATH] or DEFAULT_START_DIR
end
param_lldb() click to toggle source
# File lib/lldbrun/ParserARGV.rb, line 48
def param_lldb
  params[PARAMETER_LLDB] or search_lldb
end
param_lldb_options() click to toggle source
# File lib/lldbrun/ParserARGV.rb, line 36
def param_lldb_options
  params[PARAMETER_LLDB_OPTIONS] or DEFAULT_LLDB_OPTIONS
end
param_scan_dir() click to toggle source
# File lib/lldbrun/ParserARGV.rb, line 32
def param_scan_dir
  params[PARAMETER_SCAN_DIR] or DEFAULT_START_DIR
end
param_skip_first_step?() click to toggle source
# File lib/lldbrun/ParserARGV.rb, line 44
def param_skip_first_step?
  params[PARAMETER_SKIP] ? params[PARAMETER_SKIP] == 'true' : true
end

Private Instance Methods

check_info() click to toggle source
# File lib/lldbrun/ParserARGV.rb, line 54
def check_info
  if argv[0].strip == PARAMETER_HELP || argv.count == 0
    info        
  end
end
error_params() click to toggle source
# File lib/lldbrun/ParserARGV.rb, line 84
def error_params
  p 'LLDBRUN:  BAD PARAMETERS'
  info
end
get_params() click to toggle source
# File lib/lldbrun/ParserARGV.rb, line 70
def get_params
  argv.each_slice(2).to_a.each do |pair|
    error_params if pair.size != 2
    params[pair[0].strip] = pair[1].strip
  end

  self
end
help() click to toggle source
# File lib/lldbrun/ParserARGV.rb, line 60
def help
  descriptions  = []
  descriptions << ["#{PARAMETER_FILE_PATH}  <path> executable file of your program"]
  descriptions << ["#{PARAMETER_SCAN_DIR}  <path> root directory for scan breakpoints. Default - current terminal directory"]
  descriptions << ["#{PARAMETER_LLDB}  <' ... '>standard parameters LLDB in quotes -l '...' "]
  descriptions << ["#{PARAMETER_RUN}  <true/false> auto run LLDB after initialize breakpoints. Default - true"]
  descriptions << ["#{PARAMETER_SKIP}  <true/false> auto skip first breakpoint after run. Default - true"]
  descriptions << ["#{PARAMETER_HELP}  <> this help"]
end
info() click to toggle source
# File lib/lldbrun/ParserARGV.rb, line 79
def info
  help.each { |descr| p descr}
  exit 0
end
lldb_not_found() click to toggle source
# File lib/lldbrun/ParserARGV.rb, line 111
def lldb_not_found
  p "LLDB NOT FOUND!!! PLEASE INSTALL LLDB"
  exit 1
end
search_lldb() click to toggle source
# File lib/lldbrun/ParserARGV.rb, line 89
def search_lldb
  versions = {}
  COUNT_LLDB_VERSIONS.times do |number|
    version = number < 10 ? '' : "-#{number.to_s.split('').join('.')}"
    versions[number] = "lldb#{version}" if which?("lldb#{version}")
  end
  set_lldb_version(versions)
end
set_lldb_version(versions) click to toggle source
# File lib/lldbrun/ParserARGV.rb, line 98
def set_lldb_version(versions)
  number_version, lldb_command = versions.sort.last
  lldb_not_found unless number_version
  warning_lldb_version(lldb_command) if number_version < 40
  params[PARAMETER_LLDB] = lldb_command
end
warning_lldb_version(lldb_command) click to toggle source
# File lib/lldbrun/ParserARGV.rb, line 105
def warning_lldb_version(lldb_command)
  p "---------------------------------------------------------------------------------------------------------------------------"
  p "WARNING!!! PROBABLY YOUR CURRENT VERSION #{lldb_command} MAYBE < lldb-4.0. THIS MAY BE PROBLEM. PLEASE INSTALL lldb-4.0 end above"
  p "---------------------------------------------------------------------------------------------------------------------------"
end
which?(command) click to toggle source
# File lib/lldbrun/ParserARGV.rb, line 116
def which?(command)
  system("which #{command} >/dev/null")
end