@@ -32,35 +32,6 @@ using namespace Rcpp;
3232#include < cxxabi.h>
3333#endif
3434
35- #if defined(__GNUC__) || defined(__clang__)
36- #if defined(_WIN32) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__CYGWIN__) || defined(__sun) || defined(_AIX) || defined(__MUSL__) || defined(__HAIKU__) || defined(__ANDROID__)
37- // do nothing
38- #else
39- #include < execinfo.h>
40-
41- // Extract mangled name e.g. ./test(baz+0x14)[0x400962]
42- static std::string demangler_one (const char * input) {
43- static std::string buffer;
44- buffer = input;
45- size_t last_open = buffer.find_last_of (' (' );
46- size_t last_close = buffer.find_last_of (' )' );
47- if (last_open == std::string::npos ||
48- last_close == std::string::npos) {
49- return input; // #nocov
50- }
51- std::string function_name = buffer.substr (last_open + 1 , last_close - last_open - 1 );
52- // Strip the +0x14 (if it exists, which it does not in earlier versions of gcc)
53- size_t function_plus = function_name.find_last_of (' +' );
54- if (function_plus != std::string::npos) {
55- function_name.resize (function_plus);
56- }
57- buffer.replace (last_open + 1 , function_name.size (), demangle (function_name));
58- return buffer;
59- }
60- #endif
61- #endif
62-
63-
6435namespace Rcpp {
6536
6637 namespace internal {
@@ -280,44 +251,6 @@ SEXP rcpp_can_use_cxx11() { // #nocov start
280251} // #nocov end
281252
282253
283- // [[Rcpp::register]]
284- SEXP stack_trace (const char * file, int line) {
285- #if defined(__GNUC__) || defined(__clang__)
286- #if defined(_WIN32) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__CYGWIN__) || defined(__sun) || defined(_AIX) || defined(__MUSL__) || defined(__HAIKU__) || defined(__ANDROID__)
287- // Simpler version for Windows and *BSD
288- List trace = List::create (_[" file" ] = file,
289- _[ " line" ] = line,
290- _[ " stack" ] = " C++ stack not available on this system" );
291- trace.attr (" class" ) = " Rcpp_stack_trace" ;
292- return trace;
293- #else // ! (defined(_WIN32) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__CYGWIN__) || defined(__sun) || defined(_AIX) || defined(__ANDROID__)
294-
295- /* inspired from http://tombarta.wordpress.com/2008/08/01/c-stack-traces-with-gcc/ */
296- const size_t max_depth = 100 ;
297- int stack_depth;
298- void *stack_addrs[max_depth];
299- char **stack_strings;
300-
301- stack_depth = backtrace (stack_addrs, max_depth);
302- stack_strings = backtrace_symbols (stack_addrs, stack_depth);
303-
304- std::string current_line;
305-
306- CharacterVector res (stack_depth - 1 );
307- std::transform (stack_strings + 1 , stack_strings + stack_depth, res.begin (), demangler_one);
308- free (stack_strings); // malloc()ed by backtrace_symbols
309-
310- List trace = List::create (_[" file" ] = file,
311- _[" line" ] = line,
312- _[" stack" ] = res);
313- trace.attr (" class" ) = " Rcpp_stack_trace" ;
314- return trace;
315- #endif
316- #else /* !defined( __GNUC__ ) */
317- return R_NilValue;
318- #endif
319- }
320-
321254// // [ [ Rcpp::register ] ]
322255// void print(SEXP s) {
323256// Rf_PrintValue(s); // defined in Rinternals.h
0 commit comments