[PATCH v3 16/22] rtemstoolkit: Add an output routine for a std::exception.
Chris Johns
chrisj at rtems.org
Mon Jun 18 02:29:14 UTC 2018
The output routine is used by a number of tools.
---
rtemstoolkit/rld.cpp | 15 +++++++++++++++
rtemstoolkit/rld.h | 5 +++++
2 files changed, 20 insertions(+)
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
@@ -104,6 +104,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.
*/
--
2.15.1
More information about the devel
mailing list