backtracie 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ #ifndef RUBY_3_0_0_H
2
+ #define RUBY_3_0_0_H
3
+
4
+ int modified_rb_profile_frames(int start, int limit, VALUE *buff, VALUE *correct_labels, int *lines);
5
+ int modified_rb_profile_frames_for_thread(VALUE thread, int start, int limit, VALUE *buff, VALUE *correct_labels, int *lines);
6
+
7
+ #endif
data/gems.rb ADDED
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gemspec
6
+
7
+ # Development dependencies
8
+ gem "rake", "~> 13.0"
9
+ gem "rake-compiler", "~> 1.1"
10
+ gem "rspec", "~> 3.10"
11
+
12
+ # Tools
13
+ gem "pry"
14
+ gem "pry-byebug"
15
+ gem "standard", "~> 1.0"
data/lib/backtracie.rb ADDED
@@ -0,0 +1,43 @@
1
+ # frozen_string_literal: true
2
+
3
+ # backtracie: Ruby gem for beautiful backtraces
4
+ # Copyright (C) 2021 Ivo Anjo <ivo@ivoanjo.me>
5
+ #
6
+ # This file is part of backtracie.
7
+ #
8
+ # backtracie is free software: you can redistribute it and/or modify
9
+ # it under the terms of the GNU Lesser General Public License as published by
10
+ # the Free Software Foundation, either version 3 of the License, or
11
+ # (at your option) any later version.
12
+ #
13
+ # backtracie is distributed in the hope that it will be useful,
14
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
+ # GNU Lesser General Public License for more details.
17
+ #
18
+ # You should have received a copy of the GNU Lesser General Public License
19
+ # along with backtracie. If not, see <http://www.gnu.org/licenses/>.
20
+
21
+ require "backtracie/version"
22
+ require "backtracie/location"
23
+
24
+ # Note: This should be the last require, because the native extension expects all of the Ruby-defined classes above
25
+ # to exist by the time it gets initialized
26
+ require "backtracie_native_extension"
27
+
28
+ module Backtracie
29
+ module_function
30
+
31
+ def caller_locations
32
+ Primitive.caller_locations
33
+ end
34
+
35
+ # Defined via native code only; not redirecting via Primitive to avoid an extra stack frame on the stack
36
+ # def backtrace_locations(thread); end
37
+
38
+ private_class_method def ensure_object_is_thread(object)
39
+ unless object.is_a?(Thread)
40
+ raise ArgumentError, "Expected to receive instance of Thread or its subclass, got '#{object.inspect}'"
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,51 @@
1
+ # frozen_string_literal: true
2
+
3
+ # backtracie: Ruby gem for beautiful backtraces
4
+ # Copyright (C) 2021 Ivo Anjo <ivo@ivoanjo.me>
5
+ #
6
+ # This file is part of backtracie.
7
+ #
8
+ # backtracie is free software: you can redistribute it and/or modify
9
+ # it under the terms of the GNU Lesser General Public License as published by
10
+ # the Free Software Foundation, either version 3 of the License, or
11
+ # (at your option) any later version.
12
+ #
13
+ # backtracie is distributed in the hope that it will be useful,
14
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
+ # GNU Lesser General Public License for more details.
17
+ #
18
+ # You should have received a copy of the GNU Lesser General Public License
19
+ # along with backtracie. If not, see <http://www.gnu.org/licenses/>.
20
+
21
+ module Backtracie
22
+ # A more advanced version of Ruby's built-in Thread::Backtrace::Location
23
+ class Location
24
+ attr_accessor :absolute_path
25
+ attr_accessor :base_label
26
+ attr_accessor :label
27
+ attr_accessor :lineno
28
+ attr_accessor :path
29
+
30
+ # Note: The order of arguments is hardcoded in the native extension in the `new_location` function --
31
+ # keep them in sync
32
+ def initialize(absolute_path, base_label, label, lineno, path, debug)
33
+ @absolute_path = absolute_path
34
+ @base_label = base_label
35
+ @label = label
36
+ @lineno = lineno
37
+ @path = path
38
+ @debug = debug
39
+
40
+ freeze
41
+ end
42
+
43
+ def to_s
44
+ if @lineno != 0
45
+ "#{@path}:#{@lineno}:in `#{@label}'"
46
+ else
47
+ "#{@path}:in `#{@label}'"
48
+ end
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ # backtracie: Ruby gem for beautiful backtraces
4
+ # Copyright (C) 2021 Ivo Anjo <ivo@ivoanjo.me>
5
+ #
6
+ # This file is part of backtracie.
7
+ #
8
+ # backtracie is free software: you can redistribute it and/or modify
9
+ # it under the terms of the GNU Lesser General Public License as published by
10
+ # the Free Software Foundation, either version 3 of the License, or
11
+ # (at your option) any later version.
12
+ #
13
+ # backtracie is distributed in the hope that it will be useful,
14
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
+ # GNU Lesser General Public License for more details.
17
+ #
18
+ # You should have received a copy of the GNU Lesser General Public License
19
+ # along with backtracie. If not, see <http://www.gnu.org/licenses/>.
20
+
21
+ module Backtracie
22
+ VERSION = "0.1.0"
23
+ end
metadata ADDED
@@ -0,0 +1,66 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: backtracie
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Ivo Anjo
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2021-03-12 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Ruby gem for beautiful backtraces
14
+ email:
15
+ - ivo@ivoanjo.me
16
+ executables: []
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - ".editorconfig"
21
+ - ".gitignore"
22
+ - ".rspec"
23
+ - ".ruby-version"
24
+ - ".standard.yml"
25
+ - CODE_OF_CONDUCT.adoc
26
+ - COPYING
27
+ - COPYING.LESSER
28
+ - DEVELOPMENT_NOTES.adoc
29
+ - README.adoc
30
+ - Rakefile
31
+ - backtracie.gemspec
32
+ - bin/console
33
+ - bin/setup
34
+ - ext/backtracie_native_extension/backtracie.c
35
+ - ext/backtracie_native_extension/extconf.rb
36
+ - ext/backtracie_native_extension/ruby_3.0.0.c
37
+ - ext/backtracie_native_extension/ruby_3.0.0.h
38
+ - gems.rb
39
+ - lib/backtracie.rb
40
+ - lib/backtracie/location.rb
41
+ - lib/backtracie/version.rb
42
+ homepage: https://github.com/ivoanjo/backtracie
43
+ licenses:
44
+ - LGPL-3.0+
45
+ metadata: {}
46
+ post_install_message:
47
+ rdoc_options: []
48
+ require_paths:
49
+ - lib
50
+ - ext
51
+ required_ruby_version: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ version: 3.0.0
56
+ required_rubygems_version: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ version: '0'
61
+ requirements: []
62
+ rubygems_version: 3.2.3
63
+ signing_key:
64
+ specification_version: 4
65
+ summary: Ruby gem for beautiful backtraces
66
+ test_files: []