File tree Expand file tree Collapse file tree 4 files changed +22
-0
lines changed Expand file tree Collapse file tree 4 files changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ typedef struct SEXPREC *SEXP;
7
7
8
8
const char * ark_print_rs (SEXP x );
9
9
const char * ark_inspect_rs (SEXP x );
10
+ const char * ark_trace_back_rs ();
10
11
const char * ark_display_value_rs (SEXP x );
11
12
12
13
const char * ark_print (SEXP x ) {
@@ -17,6 +18,10 @@ const char* ark_inspect(SEXP x) {
17
18
return ark_inspect_rs (x );
18
19
}
19
20
21
+ const char * ark_trace_back () {
22
+ return ark_trace_back_rs ();
23
+ }
24
+
20
25
const char * ark_display_value (SEXP x ) {
21
26
return ark_display_value_rs (x );
22
27
}
Original file line number Diff line number Diff line change @@ -22,6 +22,18 @@ pub extern "C" fn ark_inspect_rs(x: libr::SEXP) -> *const ffi::c_char {
22
22
} )
23
23
}
24
24
25
+ #[ no_mangle]
26
+ pub extern "C" fn ark_trace_back_rs ( ) -> * const ffi:: c_char {
27
+ capture_console_output ( || {
28
+ // https://github.com/r-lib/rlang/issues/1059
29
+ unsafe {
30
+ let fun =
31
+ libr:: R_GetCCallable ( c"rlang" . as_ptr ( ) , c"rlang_print_backtrace" . as_ptr ( ) ) . unwrap ( ) ;
32
+ fun ( 1 ) ;
33
+ } ;
34
+ } )
35
+ }
36
+
25
37
#[ no_mangle]
26
38
pub extern "C" fn ark_display_value_rs ( x : libr:: SEXP ) -> * const ffi:: c_char {
27
39
let value = unsafe {
Original file line number Diff line number Diff line change @@ -770,13 +770,15 @@ pub fn r_subset_vec(x: SEXP, indices: Vec<i64>) -> Result<SEXP> {
770
770
extern "C" {
771
771
fn ark_print ( x : libr:: SEXP ) -> * const ffi:: c_char ;
772
772
fn ark_inspect ( x : libr:: SEXP ) -> * const ffi:: c_char ;
773
+ fn ark_trace_back ( ) -> * const ffi:: c_char ;
773
774
fn ark_display_value ( x : libr:: SEXP ) -> * const ffi:: c_char ;
774
775
}
775
776
776
777
#[ ensure_used]
777
778
pub extern "C" fn _placeholder ( ) {
778
779
unsafe { ark_print ( libr:: R_NilValue ) } ;
779
780
unsafe { ark_inspect ( libr:: R_NilValue ) } ;
781
+ unsafe { ark_trace_back ( ) } ;
780
782
unsafe { ark_display_value ( libr:: R_NilValue ) } ;
781
783
}
782
784
Original file line number Diff line number Diff line change @@ -41,6 +41,9 @@ functions::generate! {
41
41
externalRoutines: * const R_ExternalMethodDef
42
42
) -> std:: ffi:: c_int;
43
43
44
+ pub fn R_GetCCallable ( pkg: * const std:: ffi:: c_char, fun: * const std:: ffi:: c_char) ->
45
+ Option <unsafe extern "C-unwind" fn ( std:: ffi:: c_int) -> * mut std:: ffi:: c_void>;
46
+
44
47
pub fn vmaxget( ) -> * mut std:: ffi:: c_void;
45
48
46
49
pub fn vmaxset( arg1: * const std:: ffi:: c_void) ;
You can’t perform that action at this time.
0 commit comments