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 +4 -4
- data/README.md +6 -1
- data/VERSION +1 -1
- data/bin/gdbruby.rb +36 -30
- data/spec/gdbruby_spec.rb +8 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e024dd1c959c6f83b18d0b18ac210a5781344849
|
4
|
+
data.tar.gz: 0294874fa3aea22a447396a61c2d9e5a6eecb305
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d14eb8cf11f8de4e033ed5e02bd2c9cc1fc5c0c33a117c4615b8dec1ea957284e202bef4f84ca5ce8bc1c813a7e75b1bc0f749524af020debb6185afe044ecd0
|
7
|
+
data.tar.gz: 3de6b4d7b54f225a4462b14cf4aa99e18b20b132f0fe4a33ee94f39049d8dde1b7512a91e5d31ea1a84cc226484f1cc395e89ac87aa0f2ecf7fcbc27a480525f
|
data/README.md
CHANGED
@@ -1,5 +1,9 @@
|
|
1
1
|
# gdbruby.rb
|
2
2
|
|
3
|
+
[](http://badge.fury.io/rb/gdbruby)
|
4
|
+
|
5
|
+
[](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
|
+
0.0.2
|
data/bin/gdbruby.rb
CHANGED
@@ -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 = "(
|
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
|
-
|
491
|
-
|
492
|
-
|
493
|
-
|
494
|
-
|
495
|
-
|
496
|
-
|
497
|
-
|
498
|
-
|
499
|
-
|
500
|
-
|
501
|
-
|
502
|
-
|
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
|
-
|
508
|
-
|
509
|
-
|
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
|
-
|
512
|
-
|
513
|
-
|
514
|
-
|
515
|
-
|
516
|
-
|
517
|
-
|
518
|
-
|
519
|
-
|
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
|
data/spec/gdbruby_spec.rb
CHANGED
@@ -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.
|
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:
|
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.
|
80
|
+
rubygems_version: 2.0.14
|
81
81
|
signing_key:
|
82
82
|
specification_version: 4
|
83
83
|
summary: gdbperl for Ruby
|