rdwarf 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +16 -0
- data/.travis.yml +4 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +28 -0
- data/README.md +39 -0
- data/Rakefile +8 -0
- data/bin/console +14 -0
- data/bin/setup +7 -0
- data/ext/rdwarf/depend +5 -0
- data/ext/rdwarf/extconf.rb +29 -0
- data/ext/rdwarf/libdwarf/CHANGES +102 -0
- data/ext/rdwarf/libdwarf/CODINGSTYLE +71 -0
- data/ext/rdwarf/libdwarf/COPYING +28 -0
- data/ext/rdwarf/libdwarf/ChangeLog +619 -0
- data/ext/rdwarf/libdwarf/ChangeLog2006 +835 -0
- data/ext/rdwarf/libdwarf/ChangeLog2007 +217 -0
- data/ext/rdwarf/libdwarf/ChangeLog2008 +263 -0
- data/ext/rdwarf/libdwarf/ChangeLog2009 +348 -0
- data/ext/rdwarf/libdwarf/ChangeLog2010 +175 -0
- data/ext/rdwarf/libdwarf/ChangeLog2011 +297 -0
- data/ext/rdwarf/libdwarf/ChangeLog2012 +131 -0
- data/ext/rdwarf/libdwarf/ChangeLog2013 +238 -0
- data/ext/rdwarf/libdwarf/ChangeLog2014 +399 -0
- data/ext/rdwarf/libdwarf/LGPL.txt +504 -0
- data/ext/rdwarf/libdwarf/LIBDWARFCOPYRIGHT +40 -0
- data/ext/rdwarf/libdwarf/Makefile.in +220 -0
- data/ext/rdwarf/libdwarf/NEWS +535 -0
- data/ext/rdwarf/libdwarf/README +235 -0
- data/ext/rdwarf/libdwarf/checkexamples.c +1179 -0
- data/ext/rdwarf/libdwarf/cmplrs/dwarf_addr_finder.h +55 -0
- data/ext/rdwarf/libdwarf/common.c +62 -0
- data/ext/rdwarf/libdwarf/common.h +38 -0
- data/ext/rdwarf/libdwarf/config.h.in +146 -0
- data/ext/rdwarf/libdwarf/configure +5581 -0
- data/ext/rdwarf/libdwarf/configure.in +167 -0
- data/ext/rdwarf/libdwarf/dw-linetableheader.txt +39 -0
- data/ext/rdwarf/libdwarf/dwarf.h +1342 -0
- data/ext/rdwarf/libdwarf/dwarf_abbrev.c +291 -0
- data/ext/rdwarf/libdwarf/dwarf_abbrev.h +45 -0
- data/ext/rdwarf/libdwarf/dwarf_addr_finder.c +676 -0
- data/ext/rdwarf/libdwarf/dwarf_alloc.c +685 -0
- data/ext/rdwarf/libdwarf/dwarf_alloc.h +38 -0
- data/ext/rdwarf/libdwarf/dwarf_arange.c +595 -0
- data/ext/rdwarf/libdwarf/dwarf_arange.h +62 -0
- data/ext/rdwarf/libdwarf/dwarf_base_types.h +157 -0
- data/ext/rdwarf/libdwarf/dwarf_die_deliv.c +1802 -0
- data/ext/rdwarf/libdwarf/dwarf_die_deliv.h +46 -0
- data/ext/rdwarf/libdwarf/dwarf_elf_access.c +1348 -0
- data/ext/rdwarf/libdwarf/dwarf_elf_access.h +46 -0
- data/ext/rdwarf/libdwarf/dwarf_error.c +492 -0
- data/ext/rdwarf/libdwarf/dwarf_error.h +53 -0
- data/ext/rdwarf/libdwarf/dwarf_form.c +1302 -0
- data/ext/rdwarf/libdwarf/dwarf_frame.c +2454 -0
- data/ext/rdwarf/libdwarf/dwarf_frame.h +418 -0
- data/ext/rdwarf/libdwarf/dwarf_frame2.c +1533 -0
- data/ext/rdwarf/libdwarf/dwarf_frame3.c +282 -0
- data/ext/rdwarf/libdwarf/dwarf_funcs.c +123 -0
- data/ext/rdwarf/libdwarf/dwarf_funcs.h +33 -0
- data/ext/rdwarf/libdwarf/dwarf_gdbindex.c +520 -0
- data/ext/rdwarf/libdwarf/dwarf_gdbindex.h +97 -0
- data/ext/rdwarf/libdwarf/dwarf_global.c +612 -0
- data/ext/rdwarf/libdwarf/dwarf_global.h +117 -0
- data/ext/rdwarf/libdwarf/dwarf_harmless.c +228 -0
- data/ext/rdwarf/libdwarf/dwarf_harmless.h +31 -0
- data/ext/rdwarf/libdwarf/dwarf_incl.h +61 -0
- data/ext/rdwarf/libdwarf/dwarf_init_finish.c +1263 -0
- data/ext/rdwarf/libdwarf/dwarf_leb.c +159 -0
- data/ext/rdwarf/libdwarf/dwarf_line.c +1822 -0
- data/ext/rdwarf/libdwarf/dwarf_line.h +446 -0
- data/ext/rdwarf/libdwarf/dwarf_line2.c +98 -0
- data/ext/rdwarf/libdwarf/dwarf_line_table_reader_common.c +1583 -0
- data/ext/rdwarf/libdwarf/dwarf_loc.c +1525 -0
- data/ext/rdwarf/libdwarf/dwarf_loc.h +149 -0
- data/ext/rdwarf/libdwarf/dwarf_loc2.c +833 -0
- data/ext/rdwarf/libdwarf/dwarf_macro.c +479 -0
- data/ext/rdwarf/libdwarf/dwarf_macro.h +35 -0
- data/ext/rdwarf/libdwarf/dwarf_opaque.h +778 -0
- data/ext/rdwarf/libdwarf/dwarf_original_elf_init.c +219 -0
- data/ext/rdwarf/libdwarf/dwarf_print_lines.c +631 -0
- data/ext/rdwarf/libdwarf/dwarf_pubtypes.c +132 -0
- data/ext/rdwarf/libdwarf/dwarf_query.c +1594 -0
- data/ext/rdwarf/libdwarf/dwarf_ranges.c +194 -0
- data/ext/rdwarf/libdwarf/dwarf_reloc_arm.h +308 -0
- data/ext/rdwarf/libdwarf/dwarf_reloc_mips.h +117 -0
- data/ext/rdwarf/libdwarf/dwarf_reloc_ppc.h +242 -0
- data/ext/rdwarf/libdwarf/dwarf_reloc_ppc64.h +272 -0
- data/ext/rdwarf/libdwarf/dwarf_reloc_x86_64.h +127 -0
- data/ext/rdwarf/libdwarf/dwarf_sort_line.c +665 -0
- data/ext/rdwarf/libdwarf/dwarf_string.c +82 -0
- data/ext/rdwarf/libdwarf/dwarf_stubs.c +38 -0
- data/ext/rdwarf/libdwarf/dwarf_tied.c +423 -0
- data/ext/rdwarf/libdwarf/dwarf_tsearch.h +125 -0
- data/ext/rdwarf/libdwarf/dwarf_tsearchhash.c +675 -0
- data/ext/rdwarf/libdwarf/dwarf_types.c +121 -0
- data/ext/rdwarf/libdwarf/dwarf_types.h +32 -0
- data/ext/rdwarf/libdwarf/dwarf_util.c +913 -0
- data/ext/rdwarf/libdwarf/dwarf_util.h +324 -0
- data/ext/rdwarf/libdwarf/dwarf_vars.c +125 -0
- data/ext/rdwarf/libdwarf/dwarf_vars.h +29 -0
- data/ext/rdwarf/libdwarf/dwarf_weaks.c +123 -0
- data/ext/rdwarf/libdwarf/dwarf_weaks.h +29 -0
- data/ext/rdwarf/libdwarf/dwarf_xu_index.c +579 -0
- data/ext/rdwarf/libdwarf/dwarf_xu_index.h +68 -0
- data/ext/rdwarf/libdwarf/dwgetopt.c +181 -0
- data/ext/rdwarf/libdwarf/dwgetopt.h +51 -0
- data/ext/rdwarf/libdwarf/gennames.c +531 -0
- data/ext/rdwarf/libdwarf/install.sh +119 -0
- data/ext/rdwarf/libdwarf/libdwarf.h.in +3746 -0
- data/ext/rdwarf/libdwarf/libdwarf2.1.mm +9805 -0
- data/ext/rdwarf/libdwarf/libdwarf2.1.pdf +0 -0
- data/ext/rdwarf/libdwarf/libdwarf2p.1.mm +2807 -0
- data/ext/rdwarf/libdwarf/libdwarf2p.1.pdf +0 -0
- data/ext/rdwarf/libdwarf/libdwarfdefs.h +81 -0
- data/ext/rdwarf/libdwarf/malloc_check.c +327 -0
- data/ext/rdwarf/libdwarf/malloc_check.h +52 -0
- data/ext/rdwarf/libdwarf/mips_extensions.mm +1266 -0
- data/ext/rdwarf/libdwarf/mips_extensions.pdf +0 -0
- data/ext/rdwarf/libdwarf/pro_alloc.c +179 -0
- data/ext/rdwarf/libdwarf/pro_alloc.h +33 -0
- data/ext/rdwarf/libdwarf/pro_arange.c +310 -0
- data/ext/rdwarf/libdwarf/pro_arange.h +51 -0
- data/ext/rdwarf/libdwarf/pro_die.c +431 -0
- data/ext/rdwarf/libdwarf/pro_die.h +59 -0
- data/ext/rdwarf/libdwarf/pro_encode_nm.c +108 -0
- data/ext/rdwarf/libdwarf/pro_encode_nm.h +39 -0
- data/ext/rdwarf/libdwarf/pro_error.c +96 -0
- data/ext/rdwarf/libdwarf/pro_error.h +43 -0
- data/ext/rdwarf/libdwarf/pro_expr.c +575 -0
- data/ext/rdwarf/libdwarf/pro_expr.h +36 -0
- data/ext/rdwarf/libdwarf/pro_finish.c +45 -0
- data/ext/rdwarf/libdwarf/pro_forms.c +1271 -0
- data/ext/rdwarf/libdwarf/pro_frame.c +572 -0
- data/ext/rdwarf/libdwarf/pro_frame.h +120 -0
- data/ext/rdwarf/libdwarf/pro_funcs.c +50 -0
- data/ext/rdwarf/libdwarf/pro_incl.h +91 -0
- data/ext/rdwarf/libdwarf/pro_init.c +327 -0
- data/ext/rdwarf/libdwarf/pro_line.c +373 -0
- data/ext/rdwarf/libdwarf/pro_line.h +112 -0
- data/ext/rdwarf/libdwarf/pro_macinfo.c +457 -0
- data/ext/rdwarf/libdwarf/pro_macinfo.h +31 -0
- data/ext/rdwarf/libdwarf/pro_opaque.h +513 -0
- data/ext/rdwarf/libdwarf/pro_pubnames.c +60 -0
- data/ext/rdwarf/libdwarf/pro_reloc.c +253 -0
- data/ext/rdwarf/libdwarf/pro_reloc.h +38 -0
- data/ext/rdwarf/libdwarf/pro_reloc_stream.c +256 -0
- data/ext/rdwarf/libdwarf/pro_reloc_stream.h +52 -0
- data/ext/rdwarf/libdwarf/pro_reloc_symbolic.c +245 -0
- data/ext/rdwarf/libdwarf/pro_reloc_symbolic.h +45 -0
- data/ext/rdwarf/libdwarf/pro_section.c +2233 -0
- data/ext/rdwarf/libdwarf/pro_section.h +100 -0
- data/ext/rdwarf/libdwarf/pro_types.c +274 -0
- data/ext/rdwarf/libdwarf/pro_types.h +34 -0
- data/ext/rdwarf/libdwarf/pro_util.h +38 -0
- data/ext/rdwarf/libdwarf/pro_vars.c +52 -0
- data/ext/rdwarf/libdwarf/pro_weaks.c +51 -0
- data/ext/rdwarf/rdwarf.c +765 -0
- data/ext/rdwarf/rdwarf.h +52 -0
- data/ext/rdwarf/rdwarf_names_gen.rb +109 -0
- data/lib/rdwarf.rb +181 -0
- data/lib/rdwarf/version.rb +3 -0
- data/rdwarf.gemspec +30 -0
- metadata +251 -0
data/ext/rdwarf/rdwarf.h
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*-
|
2
|
+
*
|
3
|
+
* rdwarf - a ruby module to read DWARF debugging information
|
4
|
+
* https://github.com/kubo/rdwarf
|
5
|
+
*
|
6
|
+
* Copyright (C) 2015 Kubo Takehiro <kubo@jiubao.org>
|
7
|
+
*
|
8
|
+
* Redistribution and use in source and binary forms, with or without
|
9
|
+
* modification, are permitted provided that the following conditions are met:
|
10
|
+
*
|
11
|
+
* 1. Redistributions of source code must retain the above copyright
|
12
|
+
* notice, this list of conditions and the following disclaimer.
|
13
|
+
*
|
14
|
+
* 2. Redistributions in binary form must reproduce the above
|
15
|
+
* copyright notice, this list of conditions and the following
|
16
|
+
* disclaimer in the documentation and/or other materials provided
|
17
|
+
* with the distribution.
|
18
|
+
*
|
19
|
+
* THIS SOFTWARE IS PROVIDED BY THE AUTHORS ''AS IS'' AND ANY EXPRESS OR
|
20
|
+
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
21
|
+
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
22
|
+
* DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> OR CONTRIBUTORS BE
|
23
|
+
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
24
|
+
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
25
|
+
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
|
26
|
+
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
27
|
+
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
28
|
+
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
29
|
+
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
30
|
+
*
|
31
|
+
* The views and conclusions contained in the software and documentation
|
32
|
+
* are those of the authors and should not be interpreted as representing
|
33
|
+
* official policies, either expressed or implied, of the authors.
|
34
|
+
*/
|
35
|
+
#ifndef RDWARF_H
|
36
|
+
#define RDWARF_H 1
|
37
|
+
#include <ruby.h>
|
38
|
+
#include "libdwarf/dwarf.h"
|
39
|
+
#include "libdwarf/libdwarf.h"
|
40
|
+
|
41
|
+
extern VALUE rdwarf_tag2name;
|
42
|
+
extern VALUE rdwarf_form2name;
|
43
|
+
extern VALUE rdwarf_at2name;
|
44
|
+
extern VALUE rdwarf_op2name;
|
45
|
+
extern VALUE rdwarf_lle2name;
|
46
|
+
|
47
|
+
extern VALUE rdwarf_tag2class;
|
48
|
+
extern VALUE rdwarf_at2class;
|
49
|
+
|
50
|
+
void Init_rdwarf_names(VALUE cRDwarf, VALUE mDie, VALUE cDIEBase, VALUE mAttr, VALUE cAttrBase);
|
51
|
+
|
52
|
+
#endif
|
@@ -0,0 +1,109 @@
|
|
1
|
+
# -*- c-file-style: "ruby"; indent-tabs-mode: nil -*-
|
2
|
+
#
|
3
|
+
# rdwarf - a ruby module to read DWARF debugging information
|
4
|
+
# https://github.com/kubo/rdwarf
|
5
|
+
#
|
6
|
+
# Copyright (C) 2015 Kubo Takehiro <kubo@jiubao.org>
|
7
|
+
#
|
8
|
+
# Redistribution and use in source and binary forms, with or without
|
9
|
+
# modification, are permitted provided that the following conditions are met:
|
10
|
+
#
|
11
|
+
# 1. Redistributions of source code must retain the above copyright
|
12
|
+
# notice, this list of conditions and the following disclaimer.
|
13
|
+
#
|
14
|
+
# 2. Redistributions in binary form must reproduce the above
|
15
|
+
# copyright notice, this list of conditions and the following
|
16
|
+
# disclaimer in the documentation and/or other materials provided
|
17
|
+
# with the distribution.
|
18
|
+
#
|
19
|
+
# THIS SOFTWARE IS PROVIDED BY THE AUTHORS ''AS IS'' AND ANY EXPRESS OR
|
20
|
+
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
21
|
+
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
22
|
+
# DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> OR CONTRIBUTORS BE
|
23
|
+
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
24
|
+
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
25
|
+
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
|
26
|
+
# BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
27
|
+
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
28
|
+
# OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
29
|
+
# IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
30
|
+
#
|
31
|
+
# The views and conclusions contained in the software and documentation
|
32
|
+
# are those of the authors and should not be interpreted as representing
|
33
|
+
# official policies, either expressed or implied, of the authors.
|
34
|
+
|
35
|
+
names = {}
|
36
|
+
|
37
|
+
open(ARGV[0], 'r') do |f|
|
38
|
+
while line = f.gets
|
39
|
+
if line =~ /^#define\s+DW_([A-Z]+)_(\w+)/
|
40
|
+
names[$1] ||= []
|
41
|
+
names[$1].push($2)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
puts <<EOS
|
47
|
+
/* This files is generated by #{__FILE__}. */
|
48
|
+
#include "rdwarf.h"
|
49
|
+
|
50
|
+
EOS
|
51
|
+
|
52
|
+
names.each do |key, ary|
|
53
|
+
puts <<EOS
|
54
|
+
VALUE rdwarf_#{key.downcase}2name;
|
55
|
+
EOS
|
56
|
+
end
|
57
|
+
|
58
|
+
puts <<EOS
|
59
|
+
|
60
|
+
VALUE rdwarf_tag2class;
|
61
|
+
VALUE rdwarf_at2class;
|
62
|
+
|
63
|
+
void Init_rdwarf_names(VALUE cRDwarf, VALUE mDie, VALUE cDieBase, VALUE mAttr, VALUE cAttrBase)
|
64
|
+
{
|
65
|
+
EOS
|
66
|
+
|
67
|
+
names.each do |key, ary|
|
68
|
+
puts <<EOS
|
69
|
+
|
70
|
+
rdwarf_#{key.downcase}2name = rb_hash_new();
|
71
|
+
rb_global_variable(&rdwarf_#{key.downcase}2name);
|
72
|
+
EOS
|
73
|
+
ary.each do |val|
|
74
|
+
puts <<EOS
|
75
|
+
rb_hash_aset(rdwarf_#{key.downcase}2name, INT2FIX(DW_#{key}_#{val}), ID2SYM(rb_intern("#{val}")));
|
76
|
+
EOS
|
77
|
+
end
|
78
|
+
puts <<EOS
|
79
|
+
OBJ_FREEZE(rdwarf_#{key.downcase}2name);
|
80
|
+
rb_define_const(cRDwarf, "#{key}_NAMES", rdwarf_#{key.downcase}2name);
|
81
|
+
EOS
|
82
|
+
end
|
83
|
+
|
84
|
+
puts <<EOS
|
85
|
+
|
86
|
+
rdwarf_tag2class = rb_hash_new();
|
87
|
+
rb_global_variable(&rdwarf_tag2class);
|
88
|
+
EOS
|
89
|
+
names['TAG'].each do |val|
|
90
|
+
puts <<EOS
|
91
|
+
rb_hash_aset(rdwarf_tag2class, INT2FIX(DW_TAG_#{val}), rb_define_class_under(mDie, "#{val.downcase.gsub(/(^|_)(.)/) { $2.upcase }}", cDieBase));
|
92
|
+
EOS
|
93
|
+
end
|
94
|
+
puts <<EOS
|
95
|
+
OBJ_FREEZE(rdwarf_tag2class);
|
96
|
+
|
97
|
+
rdwarf_at2class = rb_hash_new();
|
98
|
+
rb_global_variable(&rdwarf_at2class);
|
99
|
+
EOS
|
100
|
+
names['AT'].each do |val|
|
101
|
+
puts <<EOS
|
102
|
+
rb_hash_aset(rdwarf_at2class, INT2FIX(DW_AT_#{val}), rb_define_class_under(mAttr, "#{val.downcase.gsub(/(^|_)(.)/) { $2.upcase }}", cAttrBase));
|
103
|
+
EOS
|
104
|
+
end
|
105
|
+
puts <<EOS
|
106
|
+
OBJ_FREEZE(rdwarf_at2class);
|
107
|
+
}
|
108
|
+
EOS
|
109
|
+
|
data/lib/rdwarf.rb
ADDED
@@ -0,0 +1,181 @@
|
|
1
|
+
require "rdwarf/version"
|
2
|
+
require "rdwarf/rdwarf"
|
3
|
+
|
4
|
+
class RDwarf
|
5
|
+
|
6
|
+
# Find an offset of a structure.
|
7
|
+
#
|
8
|
+
# # On Ubuntu 12.04 x86_64 with libc6-dbg package
|
9
|
+
# rd = RDwarf.new('/usr/lib/debug/lib/x86_64-linux-gnu/libc-2.15.so')
|
10
|
+
# rd.offsetof('struct timeval', 'tv_usec') # => 8
|
11
|
+
def offsetof(type_name, member_name)
|
12
|
+
if type_name =~ /^struct\s+/
|
13
|
+
die_type = DIE::StructureType
|
14
|
+
type_name = $'
|
15
|
+
else
|
16
|
+
die_type = DIE::Typedef
|
17
|
+
end
|
18
|
+
|
19
|
+
die = compile_units.find do |cu|
|
20
|
+
die = cu.children.find do |die|
|
21
|
+
break die if die.is_a? die_type and die.name == type_name
|
22
|
+
end
|
23
|
+
break die if die
|
24
|
+
end
|
25
|
+
|
26
|
+
while die
|
27
|
+
case die
|
28
|
+
when DIE::Typedef
|
29
|
+
die = die.attributes.find do |attr|
|
30
|
+
if attr.is_a? Attribute::Type
|
31
|
+
break attr.value
|
32
|
+
end
|
33
|
+
end
|
34
|
+
when DIE::StructureType
|
35
|
+
die.children.find do |die|
|
36
|
+
if die.name == member_name
|
37
|
+
die.attributes.find do |attr|
|
38
|
+
if attr.is_a? Attribute::DataMemberLocation
|
39
|
+
return attr.value
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
return nil
|
45
|
+
else
|
46
|
+
return nil # never reach here
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
def dump
|
52
|
+
s = []
|
53
|
+
compile_units.each do |cu|
|
54
|
+
s << cu.dump
|
55
|
+
end
|
56
|
+
s.join("\n")
|
57
|
+
end
|
58
|
+
|
59
|
+
module DIE
|
60
|
+
|
61
|
+
class Base
|
62
|
+
def dump(padding = '')
|
63
|
+
s = []
|
64
|
+
s << "#{padding}#{self}"
|
65
|
+
if attributes.size != 0
|
66
|
+
s << "#{padding} attributes:"
|
67
|
+
attributes.each do |attr|
|
68
|
+
s << attr.dump(padding + ' ')
|
69
|
+
end
|
70
|
+
end
|
71
|
+
if source_files
|
72
|
+
s << "#{padding} source_files:"
|
73
|
+
source_files.each_with_index do |file, idx|
|
74
|
+
s << "#{padding} #{idx + 1}: #{file}"
|
75
|
+
end
|
76
|
+
end
|
77
|
+
if children.size != 0
|
78
|
+
s << "#{padding} children:"
|
79
|
+
children.each do |child|
|
80
|
+
s << child.dump(padding + ' ')
|
81
|
+
end
|
82
|
+
end
|
83
|
+
s.join("\n")
|
84
|
+
end # dump
|
85
|
+
end # Base
|
86
|
+
|
87
|
+
end # DIE
|
88
|
+
|
89
|
+
module Attribute
|
90
|
+
|
91
|
+
class Base
|
92
|
+
def dump(padding = '')
|
93
|
+
"#{padding}#{type}(#{form}): #{value}"
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
class DataMemberLocation < Base
|
98
|
+
def raw_value
|
99
|
+
loc_list
|
100
|
+
end
|
101
|
+
|
102
|
+
def value
|
103
|
+
loc = raw_value[0][0].operand1
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
class CallFile < Base
|
108
|
+
def value
|
109
|
+
@cu.source_files[raw_value - 1]
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
class DeclFile < Base
|
114
|
+
def value
|
115
|
+
@cu.source_files[raw_value - 1]
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
class Encoding < Base
|
120
|
+
def value
|
121
|
+
RDwarf::ATE_NAMES[raw_value]
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
class HighPc < Base
|
126
|
+
def value
|
127
|
+
"0x%x" % raw_value
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
class Inline < Base
|
132
|
+
def value
|
133
|
+
RDwarf::INL_NAMES[raw_value]
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
137
|
+
class Language < Base
|
138
|
+
def value
|
139
|
+
RDwarf::LANG_NAMES[raw_value]
|
140
|
+
end
|
141
|
+
end
|
142
|
+
|
143
|
+
class Location < Base
|
144
|
+
def raw_value
|
145
|
+
loc_list
|
146
|
+
end
|
147
|
+
end
|
148
|
+
|
149
|
+
class LowPc < Base
|
150
|
+
def value
|
151
|
+
"0x%x" % raw_value
|
152
|
+
end
|
153
|
+
end
|
154
|
+
|
155
|
+
end # Attribute
|
156
|
+
|
157
|
+
class LocationList < Array
|
158
|
+
attr_reader :lle
|
159
|
+
attr_reader :lowpc
|
160
|
+
attr_reader :hipc
|
161
|
+
attr_reader :source
|
162
|
+
attr_reader :expression_offset
|
163
|
+
attr_reader :locdesc_offset
|
164
|
+
|
165
|
+
def inspect
|
166
|
+
"#<#{self.class}: lle=#@lle, lowpc=#{"0x%x" % @lowpc}, hipc=#{"0x%x" % @hipc}, source=#@source, expression_offset=#{"0x%x" % @expression_offset}, locdesc_offset=#{"0x%x" % @locdesc_offset}, [#{self.collect {|desc| desc.inspect}.join(", ")}]>"
|
167
|
+
end
|
168
|
+
end
|
169
|
+
|
170
|
+
class LocationDescriptor
|
171
|
+
attr_reader :atom
|
172
|
+
attr_reader :operand1
|
173
|
+
attr_reader :operand2
|
174
|
+
attr_reader :operand3
|
175
|
+
attr_reader :offset_for_branch
|
176
|
+
|
177
|
+
def inspect
|
178
|
+
"#<#{self.class}: atom=#@atom, operand1=#{"0x%x" % @operand1}, operand2=#{"0x%x" % @operand2}, operand3=#{"0x%x" % @operand3}, offset_for_branch=#{"0x%x" % @offset_for_branch}>"
|
179
|
+
end
|
180
|
+
end
|
181
|
+
end # RDwarf
|
data/rdwarf.gemspec
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'rdwarf/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "rdwarf"
|
8
|
+
spec.version = Rdwarf::VERSION
|
9
|
+
spec.authors = ["Kubo Takehiro"]
|
10
|
+
spec.email = ["kubo@jiubao.org"]
|
11
|
+
|
12
|
+
spec.summary = %q{A module to read DWARF debugging information}
|
13
|
+
spec.description = <<EOS
|
14
|
+
RDwarf is a module to read DWARF debugging information.
|
15
|
+
|
16
|
+
This module includes libdwarf distributed at http://www.prevanders.net/dwarf.html.
|
17
|
+
EOS
|
18
|
+
spec.homepage = "https://github.com/kubo/rdwarf"
|
19
|
+
spec.license = "LGPL"
|
20
|
+
|
21
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
22
|
+
spec.bindir = "exe"
|
23
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
24
|
+
spec.require_paths = ["lib"]
|
25
|
+
spec.extensions = ["ext/rdwarf/extconf.rb"]
|
26
|
+
|
27
|
+
spec.add_development_dependency "bundler", "~> 1.10"
|
28
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
29
|
+
spec.add_development_dependency "rake-compiler"
|
30
|
+
end
|
metadata
ADDED
@@ -0,0 +1,251 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rdwarf
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Kubo Takehiro
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-11-20 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.10'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.10'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake-compiler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
description: |
|
56
|
+
RDwarf is a module to read DWARF debugging information.
|
57
|
+
|
58
|
+
This module includes libdwarf distributed at http://www.prevanders.net/dwarf.html.
|
59
|
+
email:
|
60
|
+
- kubo@jiubao.org
|
61
|
+
executables: []
|
62
|
+
extensions:
|
63
|
+
- ext/rdwarf/extconf.rb
|
64
|
+
extra_rdoc_files: []
|
65
|
+
files:
|
66
|
+
- ".gitignore"
|
67
|
+
- ".travis.yml"
|
68
|
+
- Gemfile
|
69
|
+
- LICENSE.txt
|
70
|
+
- README.md
|
71
|
+
- Rakefile
|
72
|
+
- bin/console
|
73
|
+
- bin/setup
|
74
|
+
- ext/rdwarf/depend
|
75
|
+
- ext/rdwarf/extconf.rb
|
76
|
+
- ext/rdwarf/libdwarf/CHANGES
|
77
|
+
- ext/rdwarf/libdwarf/CODINGSTYLE
|
78
|
+
- ext/rdwarf/libdwarf/COPYING
|
79
|
+
- ext/rdwarf/libdwarf/ChangeLog
|
80
|
+
- ext/rdwarf/libdwarf/ChangeLog2006
|
81
|
+
- ext/rdwarf/libdwarf/ChangeLog2007
|
82
|
+
- ext/rdwarf/libdwarf/ChangeLog2008
|
83
|
+
- ext/rdwarf/libdwarf/ChangeLog2009
|
84
|
+
- ext/rdwarf/libdwarf/ChangeLog2010
|
85
|
+
- ext/rdwarf/libdwarf/ChangeLog2011
|
86
|
+
- ext/rdwarf/libdwarf/ChangeLog2012
|
87
|
+
- ext/rdwarf/libdwarf/ChangeLog2013
|
88
|
+
- ext/rdwarf/libdwarf/ChangeLog2014
|
89
|
+
- ext/rdwarf/libdwarf/LGPL.txt
|
90
|
+
- ext/rdwarf/libdwarf/LIBDWARFCOPYRIGHT
|
91
|
+
- ext/rdwarf/libdwarf/Makefile.in
|
92
|
+
- ext/rdwarf/libdwarf/NEWS
|
93
|
+
- ext/rdwarf/libdwarf/README
|
94
|
+
- ext/rdwarf/libdwarf/checkexamples.c
|
95
|
+
- ext/rdwarf/libdwarf/cmplrs/dwarf_addr_finder.h
|
96
|
+
- ext/rdwarf/libdwarf/common.c
|
97
|
+
- ext/rdwarf/libdwarf/common.h
|
98
|
+
- ext/rdwarf/libdwarf/config.h.in
|
99
|
+
- ext/rdwarf/libdwarf/configure
|
100
|
+
- ext/rdwarf/libdwarf/configure.in
|
101
|
+
- ext/rdwarf/libdwarf/dw-linetableheader.txt
|
102
|
+
- ext/rdwarf/libdwarf/dwarf.h
|
103
|
+
- ext/rdwarf/libdwarf/dwarf_abbrev.c
|
104
|
+
- ext/rdwarf/libdwarf/dwarf_abbrev.h
|
105
|
+
- ext/rdwarf/libdwarf/dwarf_addr_finder.c
|
106
|
+
- ext/rdwarf/libdwarf/dwarf_alloc.c
|
107
|
+
- ext/rdwarf/libdwarf/dwarf_alloc.h
|
108
|
+
- ext/rdwarf/libdwarf/dwarf_arange.c
|
109
|
+
- ext/rdwarf/libdwarf/dwarf_arange.h
|
110
|
+
- ext/rdwarf/libdwarf/dwarf_base_types.h
|
111
|
+
- ext/rdwarf/libdwarf/dwarf_die_deliv.c
|
112
|
+
- ext/rdwarf/libdwarf/dwarf_die_deliv.h
|
113
|
+
- ext/rdwarf/libdwarf/dwarf_elf_access.c
|
114
|
+
- ext/rdwarf/libdwarf/dwarf_elf_access.h
|
115
|
+
- ext/rdwarf/libdwarf/dwarf_error.c
|
116
|
+
- ext/rdwarf/libdwarf/dwarf_error.h
|
117
|
+
- ext/rdwarf/libdwarf/dwarf_form.c
|
118
|
+
- ext/rdwarf/libdwarf/dwarf_frame.c
|
119
|
+
- ext/rdwarf/libdwarf/dwarf_frame.h
|
120
|
+
- ext/rdwarf/libdwarf/dwarf_frame2.c
|
121
|
+
- ext/rdwarf/libdwarf/dwarf_frame3.c
|
122
|
+
- ext/rdwarf/libdwarf/dwarf_funcs.c
|
123
|
+
- ext/rdwarf/libdwarf/dwarf_funcs.h
|
124
|
+
- ext/rdwarf/libdwarf/dwarf_gdbindex.c
|
125
|
+
- ext/rdwarf/libdwarf/dwarf_gdbindex.h
|
126
|
+
- ext/rdwarf/libdwarf/dwarf_global.c
|
127
|
+
- ext/rdwarf/libdwarf/dwarf_global.h
|
128
|
+
- ext/rdwarf/libdwarf/dwarf_harmless.c
|
129
|
+
- ext/rdwarf/libdwarf/dwarf_harmless.h
|
130
|
+
- ext/rdwarf/libdwarf/dwarf_incl.h
|
131
|
+
- ext/rdwarf/libdwarf/dwarf_init_finish.c
|
132
|
+
- ext/rdwarf/libdwarf/dwarf_leb.c
|
133
|
+
- ext/rdwarf/libdwarf/dwarf_line.c
|
134
|
+
- ext/rdwarf/libdwarf/dwarf_line.h
|
135
|
+
- ext/rdwarf/libdwarf/dwarf_line2.c
|
136
|
+
- ext/rdwarf/libdwarf/dwarf_line_table_reader_common.c
|
137
|
+
- ext/rdwarf/libdwarf/dwarf_loc.c
|
138
|
+
- ext/rdwarf/libdwarf/dwarf_loc.h
|
139
|
+
- ext/rdwarf/libdwarf/dwarf_loc2.c
|
140
|
+
- ext/rdwarf/libdwarf/dwarf_macro.c
|
141
|
+
- ext/rdwarf/libdwarf/dwarf_macro.h
|
142
|
+
- ext/rdwarf/libdwarf/dwarf_opaque.h
|
143
|
+
- ext/rdwarf/libdwarf/dwarf_original_elf_init.c
|
144
|
+
- ext/rdwarf/libdwarf/dwarf_print_lines.c
|
145
|
+
- ext/rdwarf/libdwarf/dwarf_pubtypes.c
|
146
|
+
- ext/rdwarf/libdwarf/dwarf_query.c
|
147
|
+
- ext/rdwarf/libdwarf/dwarf_ranges.c
|
148
|
+
- ext/rdwarf/libdwarf/dwarf_reloc_arm.h
|
149
|
+
- ext/rdwarf/libdwarf/dwarf_reloc_mips.h
|
150
|
+
- ext/rdwarf/libdwarf/dwarf_reloc_ppc.h
|
151
|
+
- ext/rdwarf/libdwarf/dwarf_reloc_ppc64.h
|
152
|
+
- ext/rdwarf/libdwarf/dwarf_reloc_x86_64.h
|
153
|
+
- ext/rdwarf/libdwarf/dwarf_sort_line.c
|
154
|
+
- ext/rdwarf/libdwarf/dwarf_string.c
|
155
|
+
- ext/rdwarf/libdwarf/dwarf_stubs.c
|
156
|
+
- ext/rdwarf/libdwarf/dwarf_tied.c
|
157
|
+
- ext/rdwarf/libdwarf/dwarf_tsearch.h
|
158
|
+
- ext/rdwarf/libdwarf/dwarf_tsearchhash.c
|
159
|
+
- ext/rdwarf/libdwarf/dwarf_types.c
|
160
|
+
- ext/rdwarf/libdwarf/dwarf_types.h
|
161
|
+
- ext/rdwarf/libdwarf/dwarf_util.c
|
162
|
+
- ext/rdwarf/libdwarf/dwarf_util.h
|
163
|
+
- ext/rdwarf/libdwarf/dwarf_vars.c
|
164
|
+
- ext/rdwarf/libdwarf/dwarf_vars.h
|
165
|
+
- ext/rdwarf/libdwarf/dwarf_weaks.c
|
166
|
+
- ext/rdwarf/libdwarf/dwarf_weaks.h
|
167
|
+
- ext/rdwarf/libdwarf/dwarf_xu_index.c
|
168
|
+
- ext/rdwarf/libdwarf/dwarf_xu_index.h
|
169
|
+
- ext/rdwarf/libdwarf/dwgetopt.c
|
170
|
+
- ext/rdwarf/libdwarf/dwgetopt.h
|
171
|
+
- ext/rdwarf/libdwarf/gennames.c
|
172
|
+
- ext/rdwarf/libdwarf/install.sh
|
173
|
+
- ext/rdwarf/libdwarf/libdwarf.h.in
|
174
|
+
- ext/rdwarf/libdwarf/libdwarf2.1.mm
|
175
|
+
- ext/rdwarf/libdwarf/libdwarf2.1.pdf
|
176
|
+
- ext/rdwarf/libdwarf/libdwarf2p.1.mm
|
177
|
+
- ext/rdwarf/libdwarf/libdwarf2p.1.pdf
|
178
|
+
- ext/rdwarf/libdwarf/libdwarfdefs.h
|
179
|
+
- ext/rdwarf/libdwarf/malloc_check.c
|
180
|
+
- ext/rdwarf/libdwarf/malloc_check.h
|
181
|
+
- ext/rdwarf/libdwarf/mips_extensions.mm
|
182
|
+
- ext/rdwarf/libdwarf/mips_extensions.pdf
|
183
|
+
- ext/rdwarf/libdwarf/pro_alloc.c
|
184
|
+
- ext/rdwarf/libdwarf/pro_alloc.h
|
185
|
+
- ext/rdwarf/libdwarf/pro_arange.c
|
186
|
+
- ext/rdwarf/libdwarf/pro_arange.h
|
187
|
+
- ext/rdwarf/libdwarf/pro_die.c
|
188
|
+
- ext/rdwarf/libdwarf/pro_die.h
|
189
|
+
- ext/rdwarf/libdwarf/pro_encode_nm.c
|
190
|
+
- ext/rdwarf/libdwarf/pro_encode_nm.h
|
191
|
+
- ext/rdwarf/libdwarf/pro_error.c
|
192
|
+
- ext/rdwarf/libdwarf/pro_error.h
|
193
|
+
- ext/rdwarf/libdwarf/pro_expr.c
|
194
|
+
- ext/rdwarf/libdwarf/pro_expr.h
|
195
|
+
- ext/rdwarf/libdwarf/pro_finish.c
|
196
|
+
- ext/rdwarf/libdwarf/pro_forms.c
|
197
|
+
- ext/rdwarf/libdwarf/pro_frame.c
|
198
|
+
- ext/rdwarf/libdwarf/pro_frame.h
|
199
|
+
- ext/rdwarf/libdwarf/pro_funcs.c
|
200
|
+
- ext/rdwarf/libdwarf/pro_incl.h
|
201
|
+
- ext/rdwarf/libdwarf/pro_init.c
|
202
|
+
- ext/rdwarf/libdwarf/pro_line.c
|
203
|
+
- ext/rdwarf/libdwarf/pro_line.h
|
204
|
+
- ext/rdwarf/libdwarf/pro_macinfo.c
|
205
|
+
- ext/rdwarf/libdwarf/pro_macinfo.h
|
206
|
+
- ext/rdwarf/libdwarf/pro_opaque.h
|
207
|
+
- ext/rdwarf/libdwarf/pro_pubnames.c
|
208
|
+
- ext/rdwarf/libdwarf/pro_reloc.c
|
209
|
+
- ext/rdwarf/libdwarf/pro_reloc.h
|
210
|
+
- ext/rdwarf/libdwarf/pro_reloc_stream.c
|
211
|
+
- ext/rdwarf/libdwarf/pro_reloc_stream.h
|
212
|
+
- ext/rdwarf/libdwarf/pro_reloc_symbolic.c
|
213
|
+
- ext/rdwarf/libdwarf/pro_reloc_symbolic.h
|
214
|
+
- ext/rdwarf/libdwarf/pro_section.c
|
215
|
+
- ext/rdwarf/libdwarf/pro_section.h
|
216
|
+
- ext/rdwarf/libdwarf/pro_types.c
|
217
|
+
- ext/rdwarf/libdwarf/pro_types.h
|
218
|
+
- ext/rdwarf/libdwarf/pro_util.h
|
219
|
+
- ext/rdwarf/libdwarf/pro_vars.c
|
220
|
+
- ext/rdwarf/libdwarf/pro_weaks.c
|
221
|
+
- ext/rdwarf/rdwarf.c
|
222
|
+
- ext/rdwarf/rdwarf.h
|
223
|
+
- ext/rdwarf/rdwarf_names_gen.rb
|
224
|
+
- lib/rdwarf.rb
|
225
|
+
- lib/rdwarf/version.rb
|
226
|
+
- rdwarf.gemspec
|
227
|
+
homepage: https://github.com/kubo/rdwarf
|
228
|
+
licenses:
|
229
|
+
- LGPL
|
230
|
+
metadata: {}
|
231
|
+
post_install_message:
|
232
|
+
rdoc_options: []
|
233
|
+
require_paths:
|
234
|
+
- lib
|
235
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
236
|
+
requirements:
|
237
|
+
- - ">="
|
238
|
+
- !ruby/object:Gem::Version
|
239
|
+
version: '0'
|
240
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
241
|
+
requirements:
|
242
|
+
- - ">="
|
243
|
+
- !ruby/object:Gem::Version
|
244
|
+
version: '0'
|
245
|
+
requirements: []
|
246
|
+
rubyforge_project:
|
247
|
+
rubygems_version: 2.4.5
|
248
|
+
signing_key:
|
249
|
+
specification_version: 4
|
250
|
+
summary: A module to read DWARF debugging information
|
251
|
+
test_files: []
|