[rtems-tools commit] rtemstoolkit: Add an output routine for a std:: exception.
Chris Johns
chrisj at rtems.org
Tue Jun 19 03:44:28 UTC 2018
Module: rtems-tools
Branch: master
Commit: 0f481ad9f139d36e1e9b5b078994396493233aba
Changeset: http://git.rtems.org/rtems-tools/commit/?id=0f481ad9f139d36e1e9b5b078994396493233aba
Author: Chris Johns <chrisj at rtems.org>
Date: Thu May 24 18:02:59 2018 +1200
rtemstoolkit: Add an output routine for a std::exception.
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
@@ -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) \
More information about the vc
mailing list