From 6d75ee0e14481bdb0c61b27daa40357abeaaaf2f Mon Sep 17 00:00:00 2001 From: Krzysztof Jackiewicz Date: Mon, 13 Jun 2016 14:36:51 +0200 Subject: [PATCH] Exclude main and std:: entries from gdb backtrace for clarity Change-Id: I235d129f5aa7bc840fca262ffc1df42026f5968d --- src/framework/src/gdbbacktrace.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/framework/src/gdbbacktrace.cpp b/src/framework/src/gdbbacktrace.cpp index 7443252a..44e00afe 100644 --- a/src/framework/src/gdbbacktrace.cpp +++ b/src/framework/src/gdbbacktrace.cpp @@ -43,7 +43,7 @@ namespace DPL { namespace { -const std::string FRAME_PATTERN_DPL("in DPL::Test"); +const char *FRAME_PATTERN = "in DPL::Test|in std::|in main"; const std::string FRAME_GDBBACKTRACE("in DPL::gdbbacktrace"); const std::string DEV_NULL("/dev/null"); const std::string TMP_FILE_PREFIX("/tmp/security-tests_gdbbacktrace-"); @@ -57,12 +57,13 @@ void printColor(const char *err, int errnoNumber = 0) bool backtraceParseLine(const std::string &line, std::ostream &result, size_t lineNumber) { - if (line.find(FRAME_PATTERN_DPL, 0) != std::string::npos) + std::smatch m; + std::regex frame_expr(FRAME_PATTERN); + if (std::regex_search(line, m, frame_expr)) return false; - std::smatch m; std::regex expr("^#\\d+\\s+0x[0-9a-fA-F]+\\s+(.+)"); - if (!std::regex_search (line, m, expr)) + if (!std::regex_search(line, m, expr)) return false; result << "#" << std::left << std::setw(2) << lineNumber << " " << m[m.size()-1] << std::endl; -- 2.34.1