I am trying to use the ruby debugger in a Rails app.
What command do I need to type at the (rdb:1) prompt in order to display a stack trace? I've tried backtrace
, but it only lists the topmost frame.
I am trying to use the ruby debugger in a Rails app.
What command do I need to type at the (rdb:1) prompt in order to display a stack trace? I've tried backtrace
, but it only lists the topmost frame.
http://apidock.com/ruby/Kernel/caller
caller(0) # Returns the stack trace, omitting 0 initial entry.
Pry gem does have a plugin pry-stack_explorer
can display stack
Example: Moving around between frames
[8] pry(J)> show-stack
Showing all accessible frames in stack:
--
=> #0 [method] c <Object#c()>
#1 [block] block in b <Object#b()>
#2 [method] b <Object#b()>
#3 [method] alphabet <Object#alphabet(y)>
#4 [class] <class:J>
#5 [block] block in <main>
#6 [eval] <main>
#7 [top] <main>
[9] pry(J)> frame 3
Frame number: 3/7
Frame type: method
From: /Users/john/ruby/projects/pry-stack_explorer/examples/example.rb @ line 10 in Object#alphabet:
5:
6: require 'pry-stack_explorer'
7:
8: def alphabet(y)
9: x = 20
=> 10: b
11: end
12:
13: def b
14: x = 30
15: proc {
[10] pry(J)> x
=> 20
Further, it has lot of other features that are missing from ruby debugger. so I would suggest you try pry
& its plugins
© 2022 - 2024 — McMap. All rights reserved.