vivarium_usdt 0.1.0 → 0.2.0
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 +4 -4
- data/ext/vivarium_usdt/src/lib.rs +9 -9
- data/lib/vivarium/usdt.rb +24 -7
- data/lib/vivarium/usdt_version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: c76911f6bea49e8566350654970c25f4f78eac5e4a8b27b5302b4fa3a601adeb
|
|
4
|
+
data.tar.gz: ec793930d4cd636ead77368bdb524e303cfd728bae224a839b2968a44adbfcbe
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 0b0d070b76a2667ebfabfe60b626fa1c5206c98933b96a7bef5046b9d66a06843cd6bf4fe33c8a2856be45a61c536e360c729e83bc793cc7525cee1efa79e770
|
|
7
|
+
data.tar.gz: 48caf2ae17b43ed1cf86e49e712d03b7cbe40cef2f023c68121f61c8181b953dfed7321d3cc45b59a7027e8334d5f259413d473fbb67a2aeb70fc13bb7610bd8
|
|
@@ -4,9 +4,9 @@ use magnus::{function, prelude::*, Error, Ruby};
|
|
|
4
4
|
#[magnus::init]
|
|
5
5
|
fn init(ruby: &Ruby) -> Result<(), Error> {
|
|
6
6
|
let module = ruby.define_module("VivariumUsdt")?;
|
|
7
|
-
module.define_singleton_method("invoke_start_probe", function!(invoke_start_probe,
|
|
8
|
-
module.define_singleton_method("invoke_stop_probe", function!(invoke_stop_probe,
|
|
9
|
-
module.define_singleton_method("invoke_raise_probe", function!(invoke_raise_probe,
|
|
7
|
+
module.define_singleton_method("invoke_start_probe", function!(invoke_start_probe, 3))?;
|
|
8
|
+
module.define_singleton_method("invoke_stop_probe", function!(invoke_stop_probe, 3))?;
|
|
9
|
+
module.define_singleton_method("invoke_raise_probe", function!(invoke_raise_probe, 3))?;
|
|
10
10
|
|
|
11
11
|
let kernel = ruby.module_kernel();
|
|
12
12
|
kernel.define_method(
|
|
@@ -16,29 +16,29 @@ fn init(ruby: &Ruby) -> Result<(), Error> {
|
|
|
16
16
|
Ok(())
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
pub(crate) fn invoke_start_probe(method_id: i64) -> Result<(), Error> {
|
|
19
|
+
pub(crate) fn invoke_start_probe(method_id: i64, file_id: i64, lineno: i64) -> Result<(), Error> {
|
|
20
20
|
#[cfg(target_os = "linux")]
|
|
21
21
|
{
|
|
22
22
|
use probe::probe;
|
|
23
|
-
probe::probe!(vivarium_usdt, start_probe, method_id);
|
|
23
|
+
probe::probe!(vivarium_usdt, start_probe, method_id, file_id, lineno);
|
|
24
24
|
}
|
|
25
25
|
Ok(())
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
pub(crate) fn invoke_stop_probe(method_id: i64) -> Result<(), Error> {
|
|
28
|
+
pub(crate) fn invoke_stop_probe(method_id: i64, file_id: i64, lineno: i64) -> Result<(), Error> {
|
|
29
29
|
#[cfg(target_os = "linux")]
|
|
30
30
|
{
|
|
31
31
|
use probe::probe;
|
|
32
|
-
probe::probe!(vivarium_usdt, stop_probe, method_id);
|
|
32
|
+
probe::probe!(vivarium_usdt, stop_probe, method_id, file_id, lineno);
|
|
33
33
|
}
|
|
34
34
|
Ok(())
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
-
pub(crate) fn invoke_raise_probe(error_id: i64) -> Result<(), Error> {
|
|
37
|
+
pub(crate) fn invoke_raise_probe(error_id: i64, file_id: i64, lineno: i64) -> Result<(), Error> {
|
|
38
38
|
#[cfg(target_os = "linux")]
|
|
39
39
|
{
|
|
40
40
|
use probe::probe;
|
|
41
|
-
probe::probe!(vivarium_usdt, raise_probe, error_id);
|
|
41
|
+
probe::probe!(vivarium_usdt, raise_probe, error_id, file_id, lineno);
|
|
42
42
|
}
|
|
43
43
|
Ok(())
|
|
44
44
|
}
|
data/lib/vivarium/usdt.rb
CHANGED
|
@@ -11,6 +11,10 @@ module Vivarium
|
|
|
11
11
|
@__error_id_table ||= {}
|
|
12
12
|
end
|
|
13
13
|
private :__error_id_table
|
|
14
|
+
def __file_id_table
|
|
15
|
+
@__file_id_table ||= {}
|
|
16
|
+
end
|
|
17
|
+
private :__file_id_table
|
|
14
18
|
|
|
15
19
|
def get_method_name(u64)
|
|
16
20
|
__method_id_table[u64]
|
|
@@ -20,29 +24,42 @@ module Vivarium
|
|
|
20
24
|
__error_id_table[u64]
|
|
21
25
|
end
|
|
22
26
|
|
|
27
|
+
def get_file_name(u64)
|
|
28
|
+
__file_id_table[u64]
|
|
29
|
+
end
|
|
30
|
+
|
|
23
31
|
def register_or_resolve_method(method_signature)
|
|
24
32
|
id = __helper_get_hash_from_name(method_signature)
|
|
25
33
|
__method_id_table[id] ||= method_signature
|
|
26
34
|
id
|
|
27
35
|
end
|
|
28
36
|
|
|
29
|
-
def
|
|
37
|
+
def register_or_resolve_file(file_name)
|
|
38
|
+
id = __helper_get_hash_from_name(file_name)
|
|
39
|
+
__file_id_table[id] ||= file_name
|
|
40
|
+
id
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def start(defined_class, method_name, file: nil, lineno: -1)
|
|
30
44
|
method_signature = "#{defined_class}##{method_name}"
|
|
31
45
|
method_id = register_or_resolve_method(method_signature)
|
|
32
|
-
|
|
46
|
+
file_id = file ? register_or_resolve_file(file) : -1
|
|
47
|
+
::VivariumUsdt.invoke_start_probe(method_id, file_id, lineno)
|
|
33
48
|
end
|
|
34
49
|
|
|
35
|
-
def stop(defined_class, method_name)
|
|
50
|
+
def stop(defined_class, method_name, file: nil, lineno: -1)
|
|
36
51
|
method_signature = "#{defined_class}##{method_name}"
|
|
37
52
|
method_id = register_or_resolve_method(method_signature)
|
|
38
|
-
|
|
53
|
+
file_id = file ? register_or_resolve_file(file) : -1
|
|
54
|
+
::VivariumUsdt.invoke_stop_probe(method_id, file_id, lineno)
|
|
39
55
|
end
|
|
40
56
|
|
|
41
|
-
def raise(error_name)
|
|
57
|
+
def raise(error_name, file: nil, lineno: -1)
|
|
42
58
|
error_id = __helper_get_hash_from_name(error_name)
|
|
43
59
|
__error_id_table[error_id] ||= error_name
|
|
44
|
-
|
|
60
|
+
file_id = file ? register_or_resolve_file(file) : -1
|
|
61
|
+
::VivariumUsdt.invoke_raise_probe(error_id, file_id, lineno)
|
|
45
62
|
end
|
|
46
63
|
end
|
|
47
64
|
end
|
|
48
|
-
end
|
|
65
|
+
end
|