cxxfilt 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 52cdbe4fed0536858045bf0101740f4122f505b7
4
+ data.tar.gz: 9f90a741d4c2d5cb38bde86390019c9250a4abd6
5
+ SHA512:
6
+ metadata.gz: e385d3fbb752319d09ac1291db3f29b2513a39db1147c90e8ddd41c3c8723aad58bd62e4c209b7bed487b0eb56cd68c918fa870806c479590480e0e355c43dad
7
+ data.tar.gz: 5523c13d2faa3d4a908cc4c11719447e1c638649a87a6835781b2bfee6ed01d17eba615cac69065c96a2d842892aada4f711cebb69a96162988749d4d29fca7f
data/.gitignore ADDED
@@ -0,0 +1,105 @@
1
+
2
+ # Created by https://www.gitignore.io/api/ruby,emacs
3
+
4
+ ### Emacs ###
5
+ # -*- mode: gitignore; -*-
6
+ *~
7
+ \#*\#
8
+ /.emacs.desktop
9
+ /.emacs.desktop.lock
10
+ *.elc
11
+ auto-save-list
12
+ tramp
13
+ .\#*
14
+
15
+ # Org-mode
16
+ .org-id-locations
17
+ *_archive
18
+
19
+ # flymake-mode
20
+ *_flymake.*
21
+
22
+ # eshell files
23
+ /eshell/history
24
+ /eshell/lastdir
25
+
26
+ # elpa packages
27
+ /elpa/
28
+
29
+ # reftex files
30
+ *.rel
31
+
32
+ # AUCTeX auto folder
33
+ /auto/
34
+
35
+ # cask packages
36
+ .cask/
37
+ dist/
38
+
39
+ # Flycheck
40
+ flycheck_*.el
41
+
42
+ # server auth directory
43
+ /server/
44
+
45
+ # projectiles files
46
+ .projectile
47
+
48
+ # directory configuration
49
+ .dir-locals.el
50
+
51
+ ### Ruby ###
52
+ *.gem
53
+ *.rbc
54
+ /.config
55
+ /coverage/
56
+ /InstalledFiles
57
+ /pkg/
58
+ /spec/reports/
59
+ /spec/examples.txt
60
+ /test/tmp/
61
+ /test/version_tmp/
62
+ /tmp/
63
+
64
+ # Used by dotenv library to load environment variables.
65
+ # .env
66
+
67
+ ## Specific to RubyMotion:
68
+ .dat*
69
+ .repl_history
70
+ build/
71
+ *.bridgesupport
72
+ build-iPhoneOS/
73
+ build-iPhoneSimulator/
74
+
75
+ ## Specific to RubyMotion (use of CocoaPods):
76
+ #
77
+ # We recommend against adding the Pods directory to your .gitignore. However
78
+ # you should judge for yourself, the pros and cons are mentioned at:
79
+ # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
80
+ #
81
+ # vendor/Pods/
82
+
83
+ ## Documentation cache and generated files:
84
+ /.yardoc/
85
+ /_yardoc/
86
+ /doc/
87
+ /rdoc/
88
+
89
+ ## Environment normalization:
90
+ /.bundle/
91
+ /vendor/bundle
92
+ /lib/bundler/man/
93
+
94
+ # for a library or gem, you might want to ignore these files since the code is
95
+ # intended to run in multiple environments; otherwise, check them in:
96
+ # Gemfile.lock
97
+ # .ruby-version
98
+ # .ruby-gemset
99
+
100
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
101
+ .rvmrc
102
+
103
+ # End of https://www.gitignore.io/api/ruby,emacs
104
+
105
+ *.so
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.rspec_status ADDED
@@ -0,0 +1,6 @@
1
+ example_id | status | run_time |
2
+ ----------------------------- | ------ | --------------- |
3
+ ./spec/cxxfilt_spec.rb[1:1] | passed | 0.00061 seconds |
4
+ ./spec/cxxfilt_spec.rb[1:2] | passed | 0.00058 seconds |
5
+ ./spec/cxxfilt_spec.rb[1:3] | passed | 0.00009 seconds |
6
+ ./spec/cxxfilt_spec.rb[1:4:1] | passed | 0.00022 seconds |
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.4.1
5
+ before_install: gem install bundler -v 1.15.0
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in cxxfilt.gemspec
4
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,46 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ cxxfilt (0.1.0)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ coderay (1.1.1)
10
+ diff-lcs (1.3)
11
+ method_source (0.8.2)
12
+ pry (0.10.4)
13
+ coderay (~> 1.1.0)
14
+ method_source (~> 0.8.1)
15
+ slop (~> 3.4)
16
+ rake (10.5.0)
17
+ rake-compiler (1.0.4)
18
+ rake
19
+ rspec (3.6.0)
20
+ rspec-core (~> 3.6.0)
21
+ rspec-expectations (~> 3.6.0)
22
+ rspec-mocks (~> 3.6.0)
23
+ rspec-core (3.6.0)
24
+ rspec-support (~> 3.6.0)
25
+ rspec-expectations (3.6.0)
26
+ diff-lcs (>= 1.2.0, < 2.0)
27
+ rspec-support (~> 3.6.0)
28
+ rspec-mocks (3.6.0)
29
+ diff-lcs (>= 1.2.0, < 2.0)
30
+ rspec-support (~> 3.6.0)
31
+ rspec-support (3.6.0)
32
+ slop (3.6.0)
33
+
34
+ PLATFORMS
35
+ ruby
36
+
37
+ DEPENDENCIES
38
+ bundler (~> 1.15)
39
+ cxxfilt!
40
+ pry
41
+ rake (~> 10.0)
42
+ rake-compiler
43
+ rspec (~> 3.0)
44
+
45
+ BUNDLED WITH
46
+ 1.15.1
data/README.md ADDED
@@ -0,0 +1,33 @@
1
+ # CXXFilt
2
+
3
+ TODO: Delete this and the text above, and describe your gem
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'cxxfilt'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install cxxfilt
20
+
21
+ ## Usage
22
+
23
+ TODO: Write usage instructions here
24
+
25
+ ## Development
26
+
27
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
28
+
29
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
30
+
31
+ ## Contributing
32
+
33
+ Bug reports and pull requests are welcome on GitHub at https://github.com/misson20000/cxxfilt.
data/Rakefile ADDED
@@ -0,0 +1,10 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+ require "rake/extensiontask"
4
+
5
+ RSpec::Core::RakeTask.new(:spec)
6
+
7
+ task :default => :spec
8
+
9
+ spec = Gem::Specification.load("cxxfilt.gemspec")
10
+ Rake::ExtensionTask.new("cxxfilt", spec)
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "cxxfilt"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
data/cxxfilt.gemspec ADDED
@@ -0,0 +1,29 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "cxxfilt/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "cxxfilt"
8
+ spec.version = CXXFilt::VERSION
9
+ spec.authors = ["misson20000"]
10
+ spec.email = ["xenotoad@xenotoad.net"]
11
+ spec.licenses = ["MIT"]
12
+
13
+ spec.summary = "Demangle C++ symbols"
14
+ spec.homepage = "https://github.com/misson20000/cxxfilt-rb"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
17
+ f.match(%r{^(test|spec|features)/})
18
+ end
19
+ spec.bindir = "exe"
20
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
21
+ spec.require_paths = ["lib", "ext"]
22
+ spec.extensions = ["ext/cxxfilt/extconf.rb"]
23
+
24
+ spec.add_development_dependency "bundler", "~> 1.15"
25
+ spec.add_development_dependency "rake", "~> 10.0"
26
+ spec.add_development_dependency "rake-compiler"
27
+ spec.add_development_dependency "pry"
28
+ spec.add_development_dependency "rspec", "~> 3.0"
29
+ end
@@ -0,0 +1,73 @@
1
+ #include<ruby.h>
2
+ #include<libiberty/demangle.h>
3
+
4
+ static VALUE c_Demangler = Qnil;
5
+ static VALUE v_auto_demangler = Qnil;
6
+
7
+ static VALUE cxxfilt_demangle(int argc, VALUE *argv, VALUE self) {
8
+ VALUE v_mangled_name;
9
+ VALUE v_mangling_style;
10
+ rb_scan_args(argc, argv, "11", &v_mangled_name, &v_mangling_style);
11
+
12
+ enum demangling_styles style = auto_demangling;
13
+ if(!NIL_P(v_mangling_style)) {
14
+ style = cplus_demangle_name_to_style(StringValueCStr(v_mangling_style));
15
+ }
16
+
17
+ if(style == unknown_demangling) {
18
+ rb_raise(rb_eRuntimeError, "no such demangling style '%s' was found", StringValueCStr(v_mangling_style)); // TODO: make an actual exception class to raise here
19
+ }
20
+
21
+ cplus_demangle_set_style(style);
22
+ char *result;
23
+ result = cplus_demangle(StringValueCStr(v_mangled_name), DMGL_PARAMS | DMGL_ANSI | DMGL_VERBOSE);
24
+ if(result == NULL) {
25
+ return Qnil;
26
+ }
27
+ VALUE v_result = rb_str_new_cstr(result);
28
+ free(result);
29
+ return v_result;
30
+ }
31
+
32
+ static VALUE cxxfilt_demangle_m_demangle(VALUE self, VALUE name) {
33
+ const struct demangler_engine *demangler;
34
+ Data_Get_Struct(self, const struct demangler_engine, demangler);
35
+
36
+ cplus_demangle_set_style(demangler->demangling_style);
37
+ char *result;
38
+ result = cplus_demangle(StringValueCStr(name), DMGL_PARAMS | DMGL_ANSI | DMGL_VERBOSE);
39
+ if(result == NULL) {
40
+ return Qnil;
41
+ }
42
+ VALUE v_result = rb_str_new_cstr(result);
43
+ free(result);
44
+ return v_result;
45
+ }
46
+
47
+ static VALUE cxxfilt_get_auto(VALUE self) {
48
+ return v_auto_demangler;
49
+ }
50
+
51
+ void Init_cxxfilt() {
52
+ VALUE mCXXFilt = rb_define_module("CXXFilt");
53
+ c_Demangler = rb_define_class_under(mCXXFilt, "Demangler", rb_cObject);
54
+ rb_define_module_function(mCXXFilt, "demangle", cxxfilt_demangle, -1);
55
+ //rb_define_module_function(mCXXFilt, "demanglers", cxxfilt_demanglers, 0);
56
+ rb_define_module_function(mCXXFilt, "auto", cxxfilt_get_auto, 0);
57
+ rb_define_method(c_Demangler, "demangle", cxxfilt_demangle_m_demangle, 1);
58
+
59
+ static VALUE v_demanglers = Qnil;
60
+ v_demanglers = rb_ary_new();
61
+ for(const struct demangler_engine *demangler = libiberty_demanglers; demangler->demangling_style != unknown_demangling; demangler++) {
62
+ VALUE v_demangler = Data_Wrap_Struct(c_Demangler, 0, 0, demangler);
63
+ if(demangler->demangling_style == auto_demangling) {
64
+ v_auto_demangler = v_demangler;
65
+ }
66
+ rb_ary_push(v_demanglers, v_demangler);
67
+ rb_iv_set(v_demangler, "@name", rb_str_new_cstr(demangler->demangling_style_name));
68
+ rb_iv_set(v_demangler, "@doc", rb_str_new_cstr(demangler->demangling_style_doc));
69
+ }
70
+ rb_iv_set(mCXXFilt, "@demanglers", v_demanglers);
71
+
72
+ rb_require("cxxfilt/cxxfilt");
73
+ }
@@ -0,0 +1,6 @@
1
+ require "mkmf"
2
+
3
+ extension_name = "cxxfilt"
4
+ dir_config(extension_name)
5
+ have_library("iberty")
6
+ create_makefile extension_name
@@ -0,0 +1,27 @@
1
+ require "cxxfilt/version.rb"
2
+
3
+ module CXXFilt
4
+ class Demangler
5
+ attr_reader :name
6
+ attr_reader :doc
7
+ end
8
+
9
+ demangler_map = Hash[@demanglers.map do |d|
10
+ [d.name.to_sym, d]
11
+ end]
12
+
13
+ def self.demanglers
14
+ @demanglers
15
+ end
16
+
17
+ def method_missing(sym, *args)
18
+ if demangler_map.include?(sym) then
19
+ return demangler_map[sym]
20
+ end
21
+ super
22
+ end
23
+
24
+ def respond_to_missing?(sym, include_private=false)
25
+ demangler_map.include?(sym) || super
26
+ end
27
+ end
@@ -0,0 +1,3 @@
1
+ module CXXFilt
2
+ VERSION = "0.1.0"
3
+ end
metadata ADDED
@@ -0,0 +1,131 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: cxxfilt
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - misson20000
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2017-06-02 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.15'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.15'
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
+ - !ruby/object:Gem::Dependency
56
+ name: pry
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '3.0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '3.0'
83
+ description:
84
+ email:
85
+ - xenotoad@xenotoad.net
86
+ executables: []
87
+ extensions:
88
+ - ext/cxxfilt/extconf.rb
89
+ extra_rdoc_files: []
90
+ files:
91
+ - ".gitignore"
92
+ - ".rspec"
93
+ - ".rspec_status"
94
+ - ".travis.yml"
95
+ - Gemfile
96
+ - Gemfile.lock
97
+ - README.md
98
+ - Rakefile
99
+ - bin/console
100
+ - bin/setup
101
+ - cxxfilt.gemspec
102
+ - ext/cxxfilt/cxxfilt.c
103
+ - ext/cxxfilt/extconf.rb
104
+ - lib/cxxfilt/cxxfilt.rb
105
+ - lib/cxxfilt/version.rb
106
+ homepage: https://github.com/misson20000/cxxfilt-rb
107
+ licenses:
108
+ - MIT
109
+ metadata: {}
110
+ post_install_message:
111
+ rdoc_options: []
112
+ require_paths:
113
+ - lib
114
+ - ext
115
+ required_ruby_version: !ruby/object:Gem::Requirement
116
+ requirements:
117
+ - - ">="
118
+ - !ruby/object:Gem::Version
119
+ version: '0'
120
+ required_rubygems_version: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ requirements: []
126
+ rubyforge_project:
127
+ rubygems_version: 2.6.12
128
+ signing_key:
129
+ specification_version: 4
130
+ summary: Demangle C++ symbols
131
+ test_files: []