diff options
author | Chris Johns <chrisj@rtems.org> | 2018-05-24 18:02:59 +1200 |
---|---|---|
committer | Chris Johns <chrisj@rtems.org> | 2018-06-18 12:26:16 +1000 |
commit | 0f481ad9f139d36e1e9b5b078994396493233aba (patch) | |
tree | a9534eababee949773181badd679161b1a5bd527 /rtemstoolkit | |
parent | 1cab261a783a5aea8c21225d7c9955d5b8135892 (diff) |
rtemstoolkit: Add an output routine for a std::exception.
The output routine is used by a number of tools.
Diffstat (limited to 'rtemstoolkit')
-rw-r--r-- | rtemstoolkit/rld.cpp | 15 | ||||
-rw-r--r-- | rtemstoolkit/rld.h | 5 |
2 files changed, 20 insertions, 0 deletions
diff --git a/rtemstoolkit/rld.cpp b/rtemstoolkit/rld.cpp index acce748..90fb39d 100644 --- a/rtemstoolkit/rld.cpp +++ b/rtemstoolkit/rld.cpp @@ -28,6 +28,7 @@ #include <iostream> +#include <cxxabi.h> #include <sys/stat.h> #include <rld.h> @@ -81,6 +82,20 @@ namespace rld */ static uint64_t _version_revision; + void + output_std_exception (std::exception e, std::ostream& out) + { + int status; + char* realname; + realname = abi::__cxa_demangle (e.what(), 0, 0, &status); + out << "error: exception: " << realname << " ["; + ::free (realname); + const std::type_info &ti = typeid (e); + realname = abi::__cxa_demangle (ti.name(), 0, 0, &status); + out << realname << "] " << e.what () << std::endl; + ::free (realname); + } + bool starts_with(const std::string& s1, const std::string& s2) { diff --git a/rtemstoolkit/rld.h b/rtemstoolkit/rld.h index 2b6a40d..1031a54 100644 --- a/rtemstoolkit/rld.h +++ b/rtemstoolkit/rld.h @@ -105,6 +105,11 @@ namespace rld }; /** + * Handle a standard exception. + */ + void output_std_exception (std::exception e, std::ostream& out); + + /** * A convenience macro to make where a file and line number. */ #define rld_error_at(_what) \ |