Class: Byebug::DAP::CommandProcessor
- Inherits:
-
Object
- Object
- Byebug::DAP::CommandProcessor
- Extended by:
- Forwardable
- Includes:
- SafeHelpers
- Defined in:
- lib/byebug/dap/command_processor.rb
Overview
Processes thread-specific commands and handles Byebug/TracePoint events.
Defined Under Namespace
Classes: TimeoutError
Instance Attribute Summary collapse
-
#context ⇒ gem:byebug:Byebug::Context
readonly
The thread context.
-
#last_exception ⇒ std:Exception
readonly
The last exception that occured.
-
#pause_requested ⇒ Boolean
writeonly
private
Indicates that the client requested a pause.
Instance Method Summary collapse
-
#<<(message) ⇒ Object
Send a message to the thread context.
-
#at_breakpoint(breakpoint) ⇒ Object
private
Breakpoint handler.
-
#at_catchpoint(exception) ⇒ Object
private
Catchpoint handler.
-
#at_end ⇒ Object
private
End of class/module handler.
-
#at_line ⇒ Object
private
Line handler.
-
#at_return(return_value) ⇒ Object
private
Return handler.
-
#at_tracing ⇒ Object
private
Tracing handler.
-
#execute { ... } ⇒ Object
Execute a code block in the thread.
-
#initialize(context, session) ⇒ CommandProcessor
constructor
private
Create a new command processor.
-
#log(*args) ⇒ Object
Write a message to the log.
Methods included from SafeHelpers
Constructor Details
#initialize(context, session) ⇒ CommandProcessor
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
This should only be used by Byebug internals
Create a new command processor.
38 39 40 41 42 43 44 |
# File 'lib/byebug/dap/command_processor.rb', line 38 def initialize(context, session) @context = context @session = session @requests = Channel.new @exec_mu = Mutex.new @exec_ch = Channel.new end |
Instance Attribute Details
#context ⇒ gem:byebug:Byebug::Context (readonly)
The thread context.
21 22 23 |
# File 'lib/byebug/dap/command_processor.rb', line 21 def context @context end |
#last_exception ⇒ std:Exception (readonly)
The last exception that occured.
25 26 27 |
# File 'lib/byebug/dap/command_processor.rb', line 25 def last_exception @last_exception end |
#pause_requested=(value) ⇒ Boolean (writeonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
This should only be set by Byebug::DAP::Command::Pause
Indicates that the client requested a pause.
31 32 33 |
# File 'lib/byebug/dap/command_processor.rb', line 31 def pause_requested=(value) @pause_requested = value end |
Instance Method Details
#<<(message) ⇒ Object
Raises a timeout error after 1 second if the thread is not paused or not responding.
Send a message to the thread context.
54 55 56 |
# File 'lib/byebug/dap/command_processor.rb', line 54 def <<() @requests.push(, timeout: 1) { raise TimeoutError.new(context) } end |
#at_breakpoint(breakpoint) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
This should only be called by Byebug internals
Breakpoint handler.
109 110 111 |
# File 'lib/byebug/dap/command_processor.rb', line 109 def at_breakpoint(breakpoint) @last_breakpoint = breakpoint end |
#at_catchpoint(exception) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
This should only be called by Byebug internals
Catchpoint handler.
116 117 118 |
# File 'lib/byebug/dap/command_processor.rb', line 116 def at_catchpoint(exception) @last_exception = exception end |
#at_end ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
This should only be called by Byebug internals
End of class/module handler.
87 88 89 |
# File 'lib/byebug/dap/command_processor.rb', line 87 def at_end stopped! end |
#at_line ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
This should only be called by Byebug internals
Line handler.
80 81 82 |
# File 'lib/byebug/dap/command_processor.rb', line 80 def at_line stopped! end |
#at_return(return_value) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
This should only be called by Byebug internals
Return handler.
94 95 96 97 |
# File 'lib/byebug/dap/command_processor.rb', line 94 def at_return(return_value) @at_return = return_value stopped! end |
#at_tracing ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
This should only be called by Byebug internals
Tracing handler.
102 103 104 |
# File 'lib/byebug/dap/command_processor.rb', line 102 def at_tracing # @session.puts "Tracing: #{context.full_location}" end |
#execute { ... } ⇒ Object
This calls #<< and thus may raise a timeout error.
Execute a code block in the thread.
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/byebug/dap/command_processor.rb', line 61 def execute(&block) raise "Block required" unless block_given? r, err = nil, nil @exec_mu.synchronize { self << block r, err = @exec_ch.pop } if err raise err else r end end |
#log(*args) ⇒ Object
Write a message to the log.
47 48 49 |
# File 'lib/byebug/dap/command_processor.rb', line 47 def log(*args) @session.log(*args) end |