better_rails_debugger 0.1.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: df5a043634855d9b65b83b88acc03be073cfb332
4
- data.tar.gz: 3faf19fa8112b878dfa0e8581cd7e55164ffd1a4
3
+ metadata.gz: ea3a9d9773c3f101fbaa62fa6dd94985659130a6
4
+ data.tar.gz: 903218eabd2eb38c22f7de79e40492d4c437872c
5
5
  SHA512:
6
- metadata.gz: fa232ee5c81f0a4a8c9b8f5f29f1c22c0641a89ede2c6b52bc7a7490c4efd120b9807b276dce4448c968b273192cf25cedbbfd41f478f891d9797ece3488692b
7
- data.tar.gz: 8e3b3231772ddcf096b1bb3d6daec4cd461c055c872be21e8b5f67123ed15144a408ffdf0ed0fda9666abdc11d131c9f90bc8f8c219084cdc75699252cf8ee41
6
+ metadata.gz: 2db324f05660210cefc57bfd68e2c98c97d6bd3c062db6d83ea74ca9657adcbb7293802c1dc8278c12ecfe19ff127787797f3127152ced4fc9f3ed54bc1ac0cc
7
+ data.tar.gz: 0f8cfa858d131b602e1f44b041e1bbfb25ac3af06e0a07cc3703c0e101ec52c60dad71bbe8bd046486bb80e18d5147f0bd8125efc3a091d41ff5630b86da5d1c
@@ -29,7 +29,7 @@ module BetterRailsDebugger
29
29
 
30
30
  def objects
31
31
  begin
32
- @instance = GroupInstance.find params[:id]
32
+ @instance = GroupInstance.find params[:id]
33
33
  rescue Mongoid::Errors::DocumentNotFound
34
34
  redirect_to analysis_groups_path, flash: {error: 'Instance not found'}
35
35
  return
@@ -43,7 +43,7 @@ module BetterRailsDebugger
43
43
 
44
44
  def code
45
45
  begin
46
- @object = ObjectInformation.find(params[:object_id])
46
+ @object = ObjectInformation.find(params[:object_id])
47
47
  rescue Mongoid::Errors::DocumentNotFound
48
48
  redirect_to group_instance_path(params[:id]), flash: {error: 'Object not found'}
49
49
  return
@@ -55,6 +55,17 @@ module BetterRailsDebugger
55
55
  render plain: formatter.format(lexer.lex(@object.source_code || ""))
56
56
  end
57
57
 
58
+ def backtrace
59
+ begin
60
+ @instance = GroupInstance.find params[:id]
61
+ rescue Mongoid::Errors::DocumentNotFound
62
+ redirect_to analysis_groups_path, flash: {error: 'Instance not found'}
63
+ return
64
+ end
65
+ @backtraces = ::BetterRailsDebugger::TracePointItem.backtraces_for(params[:id], params[:file], params[:line].to_i)
66
+ pp @backtraces
67
+ end
68
+
58
69
  private
59
70
  def filter_objects
60
71
  if ['asc', 'desc'].include? params[:order] and ['location', 'memsize', 'class'].include? params[:column]
@@ -7,5 +7,33 @@ module BetterRailsDebugger
7
7
  field :source_file, type: String
8
8
  field :source_line, type: Integer
9
9
  field :method_id, type: String
10
+ field :event, type: String
11
+
12
+ def to_s
13
+ "#{source_file}:#{source_line}"
14
+ end
15
+
16
+ def self.backtraces_for(group_instance_id, file, line)
17
+
18
+ backtraces = []
19
+ last_source = ::BetterRailsDebugger::TracePointItem.where(group_instance_id: group_instance_id).first
20
+ current_backtrace = []
21
+ current_backtrace_sources = []
22
+ ::BetterRailsDebugger::TracePointItem.where(group_instance_id: group_instance_id).to_a[1..-1].each do |bkt|
23
+ if bkt.source_file == file and bkt.source_line == line
24
+ backtraces.push current_backtrace.dup.concat([[file, line, bkt.method_id]])
25
+ # When we detect that we change the file and is not a method return (back to an old source file)
26
+ elsif bkt.source_file != last_source.source_file and (bkt.event.to_s == 'call' or bkt.event.to_s == 'c_call')
27
+ current_backtrace.push([last_source.source_file, last_source.source_line, last_source.method_id])
28
+ current_backtrace_sources.push last_source.source_line
29
+ elsif bkt.source_file != last_source.source_file and (bkt.event.to_s == 'return' or bkt.event.to_s == 'c_return')
30
+ current_backtrace.pop
31
+ current_backtrace_sources.pop
32
+ end
33
+ last_source = bkt
34
+ end
35
+
36
+ backtraces.uniq
37
+ end
10
38
  end
11
39
  end
@@ -0,0 +1,47 @@
1
+ .card
2
+ .card-header
3
+ = @instance.identifier
4
+ = "-"
5
+ = @instance.created_at.strftime("%c")
6
+ .card-body
7
+
8
+ - content_for :header_nav do
9
+ %ul.nav.navbar-nav.d-md-down-none
10
+ %li.nav-item
11
+ %a.nav-link.navbar-toggler.sidebar-toggler{:href => "#"} ☰
12
+ %li.nav-item.px-3
13
+ %a.nav-link{:href => group_instance_path(@instance)} List
14
+
15
+ %ul.navbar-nav.ml-md-auto
16
+
17
+
18
+ - content_for :breadcrum do
19
+ %ol.breadcrumb
20
+ %li.breadcrumb-item
21
+ %a{:href => analysis_groups_path} Analysis Groups
22
+ %li.breadcrumb-item
23
+ %a{:href => analysis_group_path(@instance.analysis_group.id)}= @instance.analysis_group.name
24
+ %li.breadcrumb-item
25
+ %a{:href => group_instance_path(@instance)}= @instance.identifier
26
+ %li.breadcrumb-item.active
27
+ %a{:href => "#"}
28
+ Backtrace for
29
+ = "#{params[:file]}:#{params[:line]}"
30
+
31
+ %h2 Backtraces list
32
+ - @backtraces.each do |backtrace|
33
+ %table.table.border.border-secondary.border-top-0
34
+ %thead.bg-secondary.text-white
35
+ %tr.d-flex
36
+ %th.col-8= order_link "Location", 'location', @instance
37
+
38
+ %tbody
39
+ - backtrace.each do |item|
40
+ %tr.d-flex
41
+ %td.col-12
42
+ %span.text-primary
43
+ = item[0]
44
+ %span= ":"
45
+ %span.text-success= item[1]
46
+ \#
47
+ %span.text-warning= item[2]
@@ -61,7 +61,7 @@
61
61
  %td.col-8
62
62
  %i.fa.fa-eye.fa-2x.text-secondary{"aria-controls" => "collapseExample", "aria-expanded" => "false", "data-toggle" => "collapse", :href => "##{object.id}"}
63
63
  %span.text-primary
64
- =object.source_file
64
+ =link_to object.source_file, backtrace_group_instance_path(@instance.id, file: object.source_file, line: object.source_line)
65
65
  %span= ":"
66
66
  %span.text-success=object.source_line
67
67
  %td.col-2= number_to_human_size object.memsize
data/config/routes.rb CHANGED
@@ -7,6 +7,7 @@ BetterRailsDebugger::Engine.routes.draw do
7
7
  get 'objects'
8
8
  get 'tracer'
9
9
  get 'code'
10
+ get 'backtrace'
10
11
  end
11
12
  end
12
13
 
@@ -42,7 +42,7 @@ module BetterRailsDebugger
42
42
  return @tracer if @tracer
43
43
  @tracer = TracePoint.new do |tp|
44
44
  # Record everything but us
45
- @trace_point_history << {source_file: tp.path, source_line: tp.lineno, method_id: tp.method_id} if tp.path !~ /better_rails_debugger/
45
+ @trace_point_history << {source_file: tp.path, source_line: tp.lineno, method_id: tp.method_id, event: tp.event.to_s} if tp.path !~ /better_rails_debugger/
46
46
  end
47
47
  end
48
48
 
@@ -138,4 +138,4 @@ module BetterRailsDebugger
138
138
  @all_valid_classes
139
139
  end
140
140
  end
141
- end
141
+ end
@@ -19,8 +19,9 @@ module BetterRailsDebugger::Parser::Ruby
19
19
 
20
20
  # Subscribe to a particular signal
21
21
  # @param signal_name Symbol
22
+ # @param step Symbol May be :first_pass or :second_pass
22
23
  # @param block Proc
23
- def subscribe_signal(signal_name, &block)
24
+ def subscribe_signal(signal_name, step=:first_pass, &block)
24
25
  key = SecureRandom.hex(5)
25
26
  @subscriptions ||= Hash.new()
26
27
  @subscriptions[signal_name] ||= Hash.new
@@ -1,3 +1,3 @@
1
1
  module BetterRailsDebugger
2
- VERSION = '0.1.1'
2
+ VERSION = '0.2.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: better_rails_debugger
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andres Jose Borek
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-04-06 00:00:00.000000000 Z
11
+ date: 2018-04-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -206,6 +206,7 @@ files:
206
206
  - app/views/better_rails_debugger/group_instances/_memory_summary.html.haml
207
207
  - app/views/better_rails_debugger/group_instances/_method_summary.html.haml
208
208
  - app/views/better_rails_debugger/group_instances/_stats_summary.html.haml
209
+ - app/views/better_rails_debugger/group_instances/backtrace.html.haml
209
210
  - app/views/better_rails_debugger/group_instances/objects.html.haml
210
211
  - app/views/better_rails_debugger/group_instances/show.html.haml
211
212
  - app/views/better_rails_debugger/group_instances/tracer.html.haml
@@ -230,6 +231,7 @@ files:
230
231
  - lib/better_rails_debugger/parser/ruby/module_detector.rb
231
232
  - lib/better_rails_debugger/parser/ruby/parser.rb
232
233
  - lib/better_rails_debugger/parser/ruby/processor.rb
234
+ - lib/better_rails_debugger/trace_object_creation.rb
233
235
  - lib/better_rails_debugger/version.rb
234
236
  - lib/tasks/better_rails_debugger_tasks.rake
235
237
  homepage: ''