Module: DebugSocket::Commands

Defined in:
lib/debug_socket.rb

Class Method Summary collapse

Class Method Details

.backtraceObject

Print the backtrace for every Thread



17
18
19
20
21
22
23
24
25
# File 'lib/debug_socket.rb', line 17

def self.backtrace
  pid = Process.pid
  "#{Time.now.utc.iso8601} #{$PROGRAM_NAME}\n" + Thread.list.map do |thread|
    output = "#{Time.now.utc.iso8601} pid=#{pid} thread.object_id=#{thread.object_id} thread.status=#{thread.status}"
    backtrace = thread.backtrace || []
    output << "\n#{backtrace.join("\n")}" if backtrace
    output
  end.join("\n\n")
end

.isolated_eval(input) ⇒ Object

When running ‘eval`, we don’t want the input to overwrite local variables etc. ‘eval` runs in the current scope, so we have an empty scope here that runs in a module that only has other shortcut commands the client might want to run.



12
13
14
# File 'lib/debug_socket.rb', line 12

def self.isolated_eval(input)
  eval(input) # rubocop:disable Security/Eval
end