gdbruby 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d8f60d770afee00f6dcff8f144788e63210a5714
4
- data.tar.gz: 08a8449dc823f8d43403bf09ceca37499e37619f
3
+ metadata.gz: e024dd1c959c6f83b18d0b18ac210a5781344849
4
+ data.tar.gz: 0294874fa3aea22a447396a61c2d9e5a6eecb305
5
5
  SHA512:
6
- metadata.gz: 57c4b47fd4b823cbfcf7461eb5561f9f36b68da821c0c0cad394123514a4cf2ccdf2c18863eea8a3d02e8f1d336646acb78561678bd3d8b7c8762028c32e34bc
7
- data.tar.gz: 6b62783d5847fa6f787bba87739599ec33456d4bce35f1e8eb8eba617f0d47ddcd7e561ebb2dff374fb9ad4851b3a782e005e7719667c1a4e89f0ff7f9f3c058
6
+ metadata.gz: d14eb8cf11f8de4e033ed5e02bd2c9cc1fc5c0c33a117c4615b8dec1ea957284e202bef4f84ca5ce8bc1c813a7e75b1bc0f749524af020debb6185afe044ecd0
7
+ data.tar.gz: 3de6b4d7b54f225a4462b14cf4aa99e18b20b132f0fe4a33ee94f39049d8dde1b7512a91e5d31ea1a84cc226484f1cc395e89ac87aa0f2ecf7fcbc27a480525f
data/README.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # gdbruby.rb
2
2
 
3
+ [![Gem Version](https://badge.fury.io/rb/gdbruby.svg)](http://badge.fury.io/rb/gdbruby)
4
+
5
+ [![Build Status](https://travis-ci.org/gunyarakun/gdbruby.svg?branch=master)](https://travis-ci.org/gunyarakun/gdbruby)
6
+
3
7
  ## Overview
4
8
 
5
9
  gdbruby.rb can output these information with live process or core.
@@ -12,7 +16,8 @@ This is Ruby port of gdbperl.pl made by Akira Higuchi.
12
16
 
13
17
  ## Precondition
14
18
 
15
- Your Ruby executable must have debug symbol.
19
+ - Your Ruby executable must have debug symbol.
20
+ - on Linux.
16
21
 
17
22
  ## Usage
18
23
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.1
1
+ 0.0.2
@@ -401,9 +401,9 @@ class GDBRuby
401
401
  map
402
402
  end
403
403
 
404
- def get_ruby_frame(frame_count)
404
+ def get_ruby_frame(frame_count, thread)
405
405
  # Accessor
406
- cfp = "(ruby_current_thread->cfp + #{frame_count})"
406
+ cfp = "(#{thread}->cfp + #{frame_count})"
407
407
  iseq = "#{cfp}->iseq"
408
408
 
409
409
  # Check iseq
@@ -487,39 +487,45 @@ class GDBRuby
487
487
 
488
488
  thread_map = get_map_of_ruby_thread_pointer_to_gdb_thread_id
489
489
 
490
- # Detect ruby running thread and change gdb thread to it
491
- current_thread_pointer = @gdb.cmd_get_pointer('p ruby_current_thread', 'rb_thread_t')
492
- gdb_thread_id = thread_map[current_thread_pointer]
493
- raise 'Cannot find current thread id in gdb' if gdb_thread_id.nil?
494
- @gdb.cmd_exec("thread #{gdb_thread_id}")
495
-
496
- # Show C backtrace
497
- if @config['c_trace', true]
498
- response = @gdb.cmd_exec('bt')
499
- puts 'c_backtrace:'
500
- response.each_line do |line|
501
- break if line == '(gdb) '
502
- puts line
490
+ dump_results = thread_map.map do |ruby_pointer, gdb_thread|
491
+ output_lines = []
492
+
493
+ ruby_thread = "((rb_thread_t *) #{ruby_pointer})"
494
+ @gdb.cmd_exec("thread #{gdb_thread}")
495
+
496
+ output_lines << "thread: #{gdb_thread}"
497
+ output_lines << ''
498
+
499
+ # Show C backtrace
500
+ if @config['c_trace', true]
501
+ c_bt = @gdb.cmd_exec('bt')
502
+ output_lines << 'c_backtrace:'
503
+ c_bt.each_line do |line|
504
+ break if line == '(gdb) '
505
+ output_lines << line
506
+ end
507
+ output_lines << ''
503
508
  end
504
- puts ''
505
- end
506
509
 
507
- # Show Ruby backtrace
508
- puts 'ruby_backtrace:'
509
- cfp_count = @gdb.cmd_get_value('p (rb_control_frame_t *)(ruby_current_thread->stack + ruby_current_thread->stack_size) - ruby_current_thread->cfp').to_i
510
+ # Show Ruby backtrace
511
+ output_lines << "ruby_backtrace:"
512
+ cfp_count = @gdb.cmd_get_value("p (rb_control_frame_t *)(#{ruby_thread}->stack + #{ruby_thread}->stack_size) - #{ruby_thread}->cfp").to_i
510
513
 
511
- frame_infos = []
512
- @prev_location = nil
513
- # NOTE: @prev_location may not be set properly when limited by MAX_FRAMES
514
- ([MAX_FRAMES, cfp_count].min - 1).downto(0).each do |count|
515
- frame_info = get_ruby_frame(count)
516
- frame_infos << frame_info if frame_info
517
- end
518
- frame_infos.reverse.each_with_index do |fi, i|
519
- puts "[#{frame_infos.length - i}] #{fi[:callee]}(#{fi[:args]}) <- #{fi[:source_path_line]}"
514
+ frame_infos = []
515
+ @prev_location = nil
516
+ # NOTE: @prev_location may not be set properly when limited by MAX_FRAMES
517
+ ([MAX_FRAMES, cfp_count].min - 1).downto(0).each do |count|
518
+ frame_info = get_ruby_frame(count, ruby_thread)
519
+ frame_infos << frame_info if frame_info
520
+ end
521
+ frame_infos.reverse.each_with_index do |fi, i|
522
+ output_lines << "[#{frame_infos.length - i}] #{fi[:callee]}(#{fi[:args]}) <- #{fi[:source_path_line]}"
523
+ end
524
+ output_lines.join("\n")
520
525
  end
521
- end
522
526
 
527
+ puts dump_results.join("\n")
528
+ end
523
529
  end
524
530
 
525
531
  def main
@@ -26,6 +26,13 @@ EOF
26
26
  @target_pid = Kernel.spawn(TARGET, :pgroup => true, :out => '/dev/null', :err => '/dev/null')
27
27
  end
28
28
 
29
+ context 'OS' do
30
+ it 'should be linux' do
31
+ host_os = RbConfig::CONFIG['host_os']
32
+ expect(host_os.match(/\Alinux/)).to_not be_nil
33
+ end
34
+ end
35
+
29
36
  context 'With live process' do
30
37
  before(:all) do
31
38
  @output = `#{EXECUTABLE} #{@target_pid}`
@@ -43,7 +50,7 @@ EOF
43
50
  context 'With core file' do
44
51
  before(:all) do
45
52
  @core_path = Tempfile.new('core')
46
- puts "target_pid: #{@target_pid}"
53
+ # puts "target_pid: #{@target_pid}"
47
54
  system('gcore', '-o', @core_path.path, @target_pid.to_s)
48
55
  @output = `#{EXECUTABLE} #{@target_pid}`
49
56
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gdbruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tasuku SUENAGA
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-11-23 00:00:00.000000000 Z
11
+ date: 2015-07-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -77,7 +77,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
77
77
  version: '0'
78
78
  requirements: []
79
79
  rubyforge_project:
80
- rubygems_version: 2.0.3
80
+ rubygems_version: 2.0.14
81
81
  signing_key:
82
82
  specification_version: 4
83
83
  summary: gdbperl for Ruby