deivid-rodriguez / byebug

Debugging in Ruby 2
BSD 2-Clause "Simplified" License
3.34k stars 328 forks source link

Exceptions when running `frame` or `backtrace` on a Sinatra application #833

Open arbesulo opened 2 years ago

arbesulo commented 2 years ago

Problem description

When debugging an application, exceptions are raised when issuing some commands like frame or backtrace.
Evaluating expressions, viewing variables or moving up and down work normally.

The environment:

Expected behavior

The frame/backtrace information is displayed.

Actual behavior

An exception is raised

(byebug) frame
*** undefined method `GET /' for class `Sinatra::Application'
Did you mean?  get
               gets
(byebug) 

Steps to reproduce the problem

I have created a demo repository with a minimal setup that demonstrates the problem.

#Gemfile
source 'https://rubygems.org'

gem 'sinatra'
gem 'byebug'
# app.rb

#!/bin/env ruby
require 'sinatra'
require 'byebug'

get '/' do
  debugger
  [200, {'content-type' => 'text/plain'}, 'Hello world!']
end
# Install the gems
bundle install

# Start the server
ruby app.rb -o 0.0.0.0

#Perform a request
curl localhost:4567

After hitting the debugger call frame or backtrace

# This is an old output, but the problem remains with the most up-to-date versions

== Sinatra (v2.2.0) has taken the stage on 4567 for development with backup from Puma
Puma starting in single mode...
* Puma version: 5.6.2 (ruby 2.7.5-p203) ("Birdie's Version")
*  Min threads: 0
*  Max threads: 5
*  Environment: development
*          PID: 30836
* Listening on http://0.0.0.0:4567
Use Ctrl-C to stop

[1, 9] in /Users/fer/wokspace/sinatra-byebug/app.rb
   1: #!/bin/env ruby
   2: 
   3: require 'sinatra'
   4: require 'byebug'
   5: 
   6: get '/' do
   7:   debugger
=> 8:   [200, {'content-type' => 'text/plain'}, 'Hello world!']
   9: end
(byebug) frame
*** undefined method `GET /' for class `Sinatra::Application'
Did you mean?  get
               gets
(byebug) 

Thanks in advance!