backtracie 0.2.0 → 0.2.1
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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 54e3870e49e076db276f5db8ce6fdd4d3678a7dee52b5d7c11c047425cea931a
|
4
|
+
data.tar.gz: da7e2f00f3f569b5e1867c88343b29a68124f3cf005eca650bd32a5d45c3732b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f481358789f4a4577a29fb143c5951bc75cf47f69304094ba3b40361a1c1dce0f4736bda189a547222f65c88a5afb0bc13e7cfdc6bd723a5e21ceb327c32e1f0
|
7
|
+
data.tar.gz: 385384d64fe51ed93d084afa16d10e07565ed7d8f7d2bc25250bfe62c5962f607a061ad385d93203ab9768b878d29bd4ece827ca31d3bd30162ba93c4713d9b2
|
data/README.adoc
CHANGED
@@ -47,7 +47,7 @@ This gem is versioned according to http://semver.org/spec/v2.0.0.html[Semantic V
|
|
47
47
|
Currently, `backtracie` exposes two APIs:
|
48
48
|
|
49
49
|
* `Backtracie.backtrace_locations(thread)`: Returns an array representing the backtrace of the given `thread`. Similar to `Thread#backtrace_locations`.
|
50
|
-
* `Backtracie.caller_locations`: Returns an array representing the backtrace of the current thread, starting from the caller of the current method.
|
50
|
+
* `Backtracie.caller_locations`: Returns an array representing the backtrace of the current thread, starting from the caller of the current method. Similar to `Kernel#caller_locations`.
|
51
51
|
|
52
52
|
These methods, inspired by their original Ruby counterparts, return arrays of `Backtracie::Location` items. These items return A LOT more information than Ruby usually exposes:
|
53
53
|
|
@@ -85,6 +85,7 @@ static VALUE collect_backtrace_locations(VALUE self, VALUE thread, int ignored_s
|
|
85
85
|
stack_depth = backtracie_rb_profile_frames(MAX_STACK_DEPTH, raw_locations);
|
86
86
|
} else {
|
87
87
|
stack_depth = backtracie_rb_profile_frames_for_thread(thread, MAX_STACK_DEPTH, raw_locations);
|
88
|
+
if (stack_depth == 0 && !backtracie_is_thread_alive(thread)) return Qnil;
|
88
89
|
}
|
89
90
|
#else
|
90
91
|
VALUE current_thread = rb_funcall(rb_cThread, current_id, 0);
|
@@ -238,12 +238,20 @@ int backtracie_rb_profile_frames(int limit, raw_location *raw_locations) {
|
|
238
238
|
return backtracie_rb_profile_frames_for_execution_context(GET_EC(), limit, raw_locations);
|
239
239
|
}
|
240
240
|
|
241
|
-
|
241
|
+
bool backtracie_is_thread_alive(VALUE thread) {
|
242
242
|
// In here we're assuming that what we got is really a Thread or its subclass. This assumption NEEDS to be verified by
|
243
243
|
// the caller, otherwise I see a segfault in your future.
|
244
244
|
rb_thread_t *thread_pointer = (rb_thread_t*) DATA_PTR(thread);
|
245
245
|
|
246
|
-
|
246
|
+
return !(thread_pointer->to_kill || thread_pointer->status == THREAD_KILLED);
|
247
|
+
}
|
248
|
+
|
249
|
+
int backtracie_rb_profile_frames_for_thread(VALUE thread, int limit, raw_location *raw_locations) {
|
250
|
+
if (!backtracie_is_thread_alive(thread)) return 0;
|
251
|
+
|
252
|
+
// In here we're assuming that what we got is really a Thread or its subclass. This assumption NEEDS to be verified by
|
253
|
+
// the caller, otherwise I see a segfault in your future.
|
254
|
+
rb_thread_t *thread_pointer = (rb_thread_t*) DATA_PTR(thread);
|
247
255
|
|
248
256
|
return backtracie_rb_profile_frames_for_execution_context(thread_pointer->ec, limit, raw_locations);
|
249
257
|
}
|
@@ -131,6 +131,7 @@ typedef struct {
|
|
131
131
|
#ifndef PRE_MJIT_RUBY
|
132
132
|
int backtracie_rb_profile_frames(int limit, raw_location *raw_locations);
|
133
133
|
int backtracie_rb_profile_frames_for_thread(VALUE thread, int limit, raw_location *raw_locations);
|
134
|
+
bool backtracie_is_thread_alive(VALUE thread);
|
134
135
|
#endif
|
135
136
|
VALUE backtracie_called_id(raw_location *the_location);
|
136
137
|
VALUE backtracie_defined_class(raw_location *the_location);
|
data/lib/backtracie/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: backtracie
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ivo Anjo
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-07-01 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Ruby gem for beautiful backtraces
|
14
14
|
email:
|