From: Martin Quinson Date: Sat, 27 Oct 2018 15:20:25 +0000 (+0200) Subject: cosmetics around backtraces X-Git-Tag: v3_22~852 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/f98d795d32176ef1b4f9cdaa7f263264e9c85392 cosmetics around backtraces - Use a type hiding the vector - Remove a deprecated function that nobody uses This is the first step toward the rewriting of the backtraces. My motivation is that our ugly hack with addr2line is not working anymore on my Debian while boost::stacktrace entered testing. I plan to convert to that new system. --- diff --git a/include/xbt/asserts.h b/include/xbt/asserts.h index 5e78a3bfe2..07a9ff0504 100644 --- a/include/xbt/asserts.h +++ b/include/xbt/asserts.h @@ -15,6 +15,8 @@ SG_BEGIN_DECL() XBT_PUBLIC_DATA int xbt_log_no_loc; /* Do not show the backtrace on failed backtrace when doing our tests */ +XBT_PUBLIC void xbt_backtrace_display_current(); + /** * @addtogroup XBT_error * @brief Those are the SimGrid version of the good ol' assert macro. diff --git a/include/xbt/backtrace.hpp b/include/xbt/backtrace.hpp index 291f7925a2..15421885dd 100644 --- a/include/xbt/backtrace.hpp +++ b/include/xbt/backtrace.hpp @@ -33,14 +33,13 @@ typedef std::vector Backtrace; XBT_PUBLIC std::unique_ptr demangle(const char* name); /** Get the current backtrace */ -XBT_PUBLIC std::vector backtrace(); +XBT_PUBLIC Backtrace backtrace(); /* Translate the backtrace in a human friendly form * * Try resolve symbols and source code location. */ XBT_PUBLIC std::vector resolve_backtrace(xbt_backtrace_location_t const* loc, std::size_t count); -XBT_ATTRIB_DEPRECATED_v323("Please use xbt::resolve_backtrace()") XBT_PUBLIC std::vector resolveBacktrace(xbt_backtrace_location_t const* loc, std::size_t count); } } diff --git a/include/xbt/sysdep.h b/include/xbt/sysdep.h index 86d62bb7a7..51dcebcd12 100644 --- a/include/xbt/sysdep.h +++ b/include/xbt/sysdep.h @@ -70,8 +70,6 @@ static XBT_ALWAYS_INLINE char *xbt_strdup(const char *s) { return res; } -XBT_PUBLIC void xbt_backtrace_display_current(); - /** @brief Like malloc, but xbt_die() on error @hideinitializer */ static XBT_ALWAYS_INLINE void *xbt_malloc(size_t n) { diff --git a/src/xbt/backtrace.cpp b/src/xbt/backtrace.cpp index 0fc1168abe..5be4b0118a 100644 --- a/src/xbt/backtrace.cpp +++ b/src/xbt/backtrace.cpp @@ -80,12 +80,12 @@ std::unique_ptr demangle(const char* name) return std::unique_ptr(xbt_strdup(name), std::free); } -std::vector backtrace() +Backtrace backtrace() { const std::size_t size = 10; xbt_backtrace_location_t loc[size]; size_t used = xbt_backtrace_current(loc, size); - return std::vector(loc, loc + used); + return Backtrace(loc, loc + used); } } diff --git a/src/xbt/backtrace_dummy.cpp b/src/xbt/backtrace_dummy.cpp index 95bf87aaa8..5f978bbb16 100644 --- a/src/xbt/backtrace_dummy.cpp +++ b/src/xbt/backtrace_dummy.cpp @@ -23,11 +23,6 @@ int xbt_backtrace_no_malloc(void **array, int size) { namespace simgrid { namespace xbt { -std::vector resolveBacktrace(xbt_backtrace_location_t const* loc, std::size_t count) // deprecated -{ - return resolve_backtrace(loc, count); -} - std::vector resolve_backtrace(xbt_backtrace_location_t const* loc, std::size_t count) { return std::vector(); diff --git a/src/xbt/backtrace_linux.cpp b/src/xbt/backtrace_linux.cpp index 80de20ae18..232e1f7a5d 100644 --- a/src/xbt/backtrace_linux.cpp +++ b/src/xbt/backtrace_linux.cpp @@ -136,11 +136,6 @@ static std::string get_binary_path() return ""; } -std::vector resolveBacktrace(xbt_backtrace_location_t const* loc, std::size_t count) // deprecated -{ - return resolve_backtrace(loc, count); -} - //FIXME: This code could be greatly improved/simplifyied with // http://cairo.sourcearchive.com/documentation/1.9.4/backtrace-symbols_8c-source.html std::vector resolve_backtrace(xbt_backtrace_location_t const* loc, std::size_t count)