char *begin = 0, *end = 0;
// find the parentheses and address offset surrounding the mangled name
+#ifdef __FreeBSD__
+ static constexpr char OPEN = '<';
+#else
+ static constexpr char OPEN = '(';
+#endif
for (char *j = strings[i]; *j; ++j) {
- if (*j == '(')
+ if (*j == OPEN)
begin = j+1;
else if (*j == '+')
end = j;
foo[len] = 0;
int status;
- char *ret = abi::__cxa_demangle(foo, function, &sz, &status);
+ char *ret = nullptr;
+ // only demangle a C++ mangled name
+ if (foo[0] == '_' && foo[1] == 'Z')
+ ret = abi::__cxa_demangle(foo, function, &sz, &status);
if (ret) {
// return value may be a realloc() of the input
function = ret;
strncat(function, "()", sz);
function[sz-1] = 0;
}
- out << " " << (i-skip+1) << ": (" << function << end << std::endl;
+ out << " " << (i-skip+1) << ": " << OPEN << function << end << std::endl;
//fprintf(out, " %s:%s\n", stack.strings[i], function);
free(foo);
} else {
boost::split(lines, bt, boost::is_any_of("\n"));
const unsigned lineno = 1;
ASSERT_GT(lines.size(), lineno);
- ASSERT_EQ(lines[0].find(pretty_version_to_str()), 1);
+ ASSERT_EQ(lines[0].find(pretty_version_to_str()), 1U);
boost::regex e{"^ 1: "
+#ifdef __FreeBSD__
+ "<foo.*>\\s"
+ "at\\s.*$"};
+#else
"\\(foo.*\\)\\s"
"\\[0x[[:xdigit:]]+\\]$"};
+#endif
EXPECT_TRUE(boost::regex_match(lines[lineno], e));
}