diff options
author | Karen Arutyunov <karen@codesynthesis.com> | 2019-05-27 22:43:59 +0300 |
---|---|---|
committer | Karen Arutyunov <karen@codesynthesis.com> | 2019-05-28 16:00:00 +0300 |
commit | ebeea3fa9992d5ceb71806b24ae94c8601638717 (patch) | |
tree | 4167dc1ca41c7b84d6d4d89c57c3020560d353da /libbutl/backtrace.mxx | |
parent | a8582e25936da4343966c91761d686c4933e3f6b (diff) |
Add backtrace()
Diffstat (limited to 'libbutl/backtrace.mxx')
-rw-r--r-- | libbutl/backtrace.mxx | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/libbutl/backtrace.mxx b/libbutl/backtrace.mxx new file mode 100644 index 0000000..25d0dcd --- /dev/null +++ b/libbutl/backtrace.mxx @@ -0,0 +1,43 @@ +// file : libbutl/backtrace.mxx -*- C++ -*- +// copyright : Copyright (c) 2014-2019 Code Synthesis Ltd +// license : MIT; see accompanying LICENSE file + +#ifndef __cpp_modules_ts +#pragma once +#endif + +// C includes. + +#ifndef __cpp_lib_modules_ts +#include <string> +#endif + +// Other includes. + +#ifdef __cpp_modules_ts +export module butl.backtrace; +#ifdef __cpp_lib_modules_ts +import std.core; +#endif +#endif + +#include <libbutl/export.hxx> + +LIBBUTL_MODEXPORT namespace butl +{ + // Return the calling thread's backtrace or empty string if this + // functionality is not supported or an error has occurred. The exact + // backtrace format is implementation-defined; it normally contains a line + // with the binary name, address in that binary, and, if available, the + // function name for each stack frame. + // + // Currently this functionality is only available on Linux, FreeBSD, and Mac + // OS. On the first two platforms the address can be mapped to the function + // name and, if built with debug info, to source location using the + // addr2line(1) utility: + // + // $ addr2line -f -C -e <binary> <addr> + // + LIBBUTL_SYMEXPORT std::string + backtrace () noexcept; +} |