class RunLoop::LLDB
A class for interacting with the lldb command-line tool
Constants
- LLDB_FIND_PIDS_CMD
@!visibility private
Public Class Methods
is_lldb_process?(ps_details)
click to toggle source
@!visibility private Is the process described an lldb process?
@param [String] ps_details Details about a process as returned by ‘ps` @return [Boolean] True if the details describe an lldb process.
# File lib/run_loop/lldb.rb, line 28 def self.is_lldb_process?(ps_details) return false if ps_details.nil? ps_details[/Contents\/Developer\/usr\/bin\/lldb/, 0] != nil end
kill_lldb_processes()
click to toggle source
Attempts to gracefully kill all running lldb processes.
# File lib/run_loop/lldb.rb, line 34 def self.kill_lldb_processes self.lldb_pids.each do |pid| self.kill_with_signal(pid, 'KILL') end end
lldb_pids()
click to toggle source
Returns a list of lldb pids. @return [Array<Integer>] An array of integer pids.
# File lib/run_loop/lldb.rb, line 8 def self.lldb_pids ps_output = `#{LLDB_FIND_PIDS_CMD}`.strip lines = ps_output.lines("\n").map { |line| line.strip } lldb_processes = lines.select { |line| self.is_lldb_process?(line) } lldb_processes.map do |ps_description| tokens = ps_description.strip.split(' ').map { |token| token.strip } pid = tokens.fetch(0, nil) if pid.nil? nil else pid.to_i end end.compact.sort end
Private Class Methods
kill_with_signal(pid, signal)
click to toggle source
@!visibility private
# File lib/run_loop/lldb.rb, line 46 def self.kill_with_signal(pid, signal) options = {:timeout => 1.0, :delay => 0.1} RunLoop::ProcessTerminator.new(pid, signal, 'lldb', options).kill_process end