backtracie 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile DELETED
@@ -1,29 +0,0 @@
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 "bundler/gem_tasks"
22
- require "rspec/core/rake_task"
23
- require "standard/rake"
24
- require "rake/extensiontask"
25
-
26
- RSpec::Core::RakeTask.new(:spec)
27
- Rake::ExtensionTask.new("backtracie_native_extension")
28
-
29
- task default: [:compile, :spec, :'standard:fix']
data/bin/console DELETED
@@ -1,8 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # frozen_string_literal: true
3
-
4
- require "bundler/setup"
5
- require "backtracie"
6
-
7
- require "pry"
8
- Pry.start
data/bin/setup DELETED
@@ -1,8 +0,0 @@
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
@@ -1,196 +0,0 @@
1
- // backtracie: Ruby gem for beautiful backtraces
2
- // Copyright (C) 2021 Ivo Anjo <ivo@ivoanjo.me>
3
- //
4
- // This file is part of backtracie.
5
- //
6
- // backtracie is free software: you can redistribute it and/or modify
7
- // it under the terms of the GNU Lesser General Public License as published by
8
- // the Free Software Foundation, either version 3 of the License, or
9
- // (at your option) any later version.
10
- //
11
- // backtracie is distributed in the hope that it will be useful,
12
- // but WITHOUT ANY WARRANTY; without even the implied warranty of
13
- // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
- // GNU Lesser General Public License for more details.
15
- //
16
- // You should have received a copy of the GNU Lesser General Public License
17
- // along with backtracie. If not, see <http://www.gnu.org/licenses/>.
18
-
19
- // -----------------------------------------------------------------------------
20
- // The file below has modified versions of code extracted from the Ruby project.
21
- // The Ruby project copyright and license follow:
22
- // -----------------------------------------------------------------------------
23
-
24
- // Ruby is copyrighted free software by Yukihiro Matsumoto <matz@netlab.jp>.
25
- // You can redistribute it and/or modify it under either the terms of the
26
- // 2-clause BSDL (see the file BSDL), or the conditions below:
27
-
28
- // 1. You may make and give away verbatim copies of the source form of the
29
- // software without restriction, provided that you duplicate all of the
30
- // original copyright notices and associated disclaimers.
31
-
32
- // 2. You may modify your copy of the software in any way, provided that
33
- // you do at least ONE of the following:
34
-
35
- // a. place your modifications in the Public Domain or otherwise
36
- // make them Freely Available, such as by posting said
37
- // modifications to Usenet or an equivalent medium, or by allowing
38
- // the author to include your modifications in the software.
39
-
40
- // b. use the modified software only within your corporation or
41
- // organization.
42
-
43
- // c. give non-standard binaries non-standard names, with
44
- // instructions on where to get the original software distribution.
45
-
46
- // d. make other distribution arrangements with the author.
47
-
48
- // 3. You may distribute the software in object code or binary form,
49
- // provided that you do at least ONE of the following:
50
-
51
- // a. distribute the binaries and library files of the software,
52
- // together with instructions (in the manual page or equivalent)
53
- // on where to get the original distribution.
54
-
55
- // b. accompany the distribution with the machine-readable source of
56
- // the software.
57
-
58
- // c. give non-standard binaries non-standard names, with
59
- // instructions on where to get the original software distribution.
60
-
61
- // d. make other distribution arrangements with the author.
62
-
63
- // 4. You may modify and include the part of the software into any other
64
- // software (possibly commercial). But some files in the distribution
65
- // are not written by the author, so that they are not under these terms.
66
-
67
- // For the list of those files and their copying conditions, see the
68
- // file LEGAL.
69
-
70
- // 5. The scripts and library files supplied as input to or produced as
71
- // output from the software do not automatically fall under the
72
- // copyright of the software, but belong to whomever generated them,
73
- // and may be sold commercially, and may be aggregated with this
74
- // software.
75
-
76
- // 6. THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
77
- // IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
78
- // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
79
- // PURPOSE.
80
-
81
- #include "rb_mjit_min_header-3.0.0.h"
82
-
83
- #include "ruby_3.0.0.h"
84
-
85
- /**********************************************************************
86
-
87
- vm_backtrace.c -
88
-
89
- $Author: ko1 $
90
- created at: Sun Jun 03 00:14:20 2012
91
-
92
- Copyright (C) 1993-2012 Yukihiro Matsumoto
93
-
94
- **********************************************************************/
95
-
96
- inline static int
97
- calc_lineno(const rb_iseq_t *iseq, const VALUE *pc)
98
- {
99
- VM_ASSERT(iseq);
100
- VM_ASSERT(iseq->body);
101
- VM_ASSERT(iseq->body->iseq_encoded);
102
- VM_ASSERT(iseq->body->iseq_size);
103
- if (! pc) {
104
- /* This can happen during VM bootup. */
105
- VM_ASSERT(iseq->body->type == ISEQ_TYPE_TOP);
106
- VM_ASSERT(! iseq->body->local_table);
107
- VM_ASSERT(! iseq->body->local_table_size);
108
- return 0;
109
- }
110
- else {
111
- ptrdiff_t n = pc - iseq->body->iseq_encoded;
112
- VM_ASSERT(n <= iseq->body->iseq_size);
113
- VM_ASSERT(n >= 0);
114
- ASSUME(n >= 0);
115
- size_t pos = n; /* no overflow */
116
- if (LIKELY(pos)) {
117
- /* use pos-1 because PC points next instruction at the beginning of instruction */
118
- pos--;
119
- }
120
- #if VMDEBUG && defined(HAVE_BUILTIN___BUILTIN_TRAP)
121
- else {
122
- /* SDR() is not possible; that causes infinite loop. */
123
- rb_print_backtrace();
124
- __builtin_trap();
125
- }
126
- #endif
127
- return rb_iseq_line_no(iseq, pos);
128
- }
129
- }
130
-
131
- int modified_rb_profile_frames_for_execution_context(
132
- rb_execution_context_t *ec,
133
- int start,
134
- int limit,
135
- VALUE *buff,
136
- VALUE *correct_labels,
137
- int *lines
138
- ) {
139
- int i;
140
- const rb_control_frame_t *cfp = ec->cfp, *end_cfp = RUBY_VM_END_CONTROL_FRAME(ec);
141
- const rb_callable_method_entry_t *cme;
142
-
143
- for (i=0; i<limit && cfp != end_cfp;) {
144
- if (VM_FRAME_RUBYFRAME_P(cfp)) {
145
- if (start > 0) {
146
- start--;
147
- continue;
148
- }
149
-
150
- // Stash the iseq so we can use it for the label. Otherwise ./spec/unit/backtracie_spec.rb:53 used to fail with
151
- // expected: "block (3 levels) in fetch_or_store"
152
- // got: "fetch_or_store"
153
- // ...but works with this hack.
154
- correct_labels[i] = (VALUE) cfp->iseq;
155
-
156
- /* record frame info */
157
- cme = rb_vm_frame_method_entry(cfp);
158
- if (cme && cme->def->type == VM_METHOD_TYPE_ISEQ) {
159
- buff[i] = (VALUE)cme;
160
- }
161
- else {
162
- buff[i] = (VALUE)cfp->iseq;
163
- }
164
-
165
- if (lines) lines[i] = calc_lineno(cfp->iseq, cfp->pc);
166
-
167
- i++;
168
- }
169
- else {
170
- cme = rb_vm_frame_method_entry(cfp);
171
- if (cme && cme->def->type == VM_METHOD_TYPE_CFUNC) {
172
- buff[i] = (VALUE)cme;
173
- if (lines) lines[i] = 0;
174
- i++;
175
- }
176
- }
177
-
178
- cfp = RUBY_VM_PREVIOUS_CONTROL_FRAME(cfp);
179
- }
180
-
181
- return i;
182
- }
183
-
184
- int modified_rb_profile_frames(int start, int limit, VALUE *buff, VALUE *correct_labels, int *lines) {
185
- return modified_rb_profile_frames_for_execution_context(GET_EC(), start, limit, buff, correct_labels, lines);
186
- }
187
-
188
- int modified_rb_profile_frames_for_thread(VALUE thread, int start, int limit, VALUE *buff, VALUE *correct_labels, int *lines) {
189
- // In here we're assuming that what we got is really a Thread or its subclass. This assumption NEEDS to be verified by
190
- // the caller, otherwise I see a segfault in your future.
191
- rb_thread_t *thread_pointer = (rb_thread_t*) DATA_PTR(thread);
192
-
193
- if (thread_pointer->to_kill || thread_pointer->status == THREAD_KILLED) return Qnil;
194
-
195
- return modified_rb_profile_frames_for_execution_context(thread_pointer->ec, start, limit, buff, correct_labels, lines);
196
- }
@@ -1,7 +0,0 @@
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 DELETED
@@ -1,15 +0,0 @@
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"