deivid-rodriguez / byebug

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

Skip gems and rubies code from the backtrace command #480

Open leandrogoe opened 6 years ago

leandrogoe commented 6 years ago

Problem description

This is not an issue, but an enhancement. It would be nice to have a option for the backtrace command, so that code in gems and rubies is skipped.

I tested the following, patch, which works (but I doubt you would like to merge as is):

    def print_backtrace
      relevant_context = (0...context.stack_size).reject { |index| context.frame_file(index) =~ /(.gem\/ruby)|(.rubies\/ruby)/  }
      bt = prc('frame.line', relevant_context) do |index, _|
        Frame.new(context, index).to_hash
      end

      print(bt)
    end
emilebosch commented 5 years ago

I also would like to skip code if possible and maybe have a .byebugignore file where we can specify the code that gets removed from the backtrace and the stepping into.

.byebugignore

*/gems/*
justin808 commented 4 years ago

Has anybody made any progress on this one? I'd love to be able to see a hack that I could put in my .pryrc to provide a command that gives a truncated backtrace.

0x2c7 commented 4 years ago

I think this could solve your issue: https://rubyjard.org/. It's a wrapper around byebug, with a nice Terminal UI, and plenty of features. One of the key feature is frame filtering that allow you to debug application code only. All unwanted backtrace are hidden.