From: Alexander Monakov Date: Fri, 12 Jul 2013 20:17:12 +0000 (+0400) Subject: common: carve out RawStackFrame::dump X-Git-Url: https://git.cworth.org/git?p=apitrace;a=commitdiff_plain;h=a85c9e5b6c6be63a1c40f5be927fcec28f8255e4 common: carve out RawStackFrame::dump --- diff --git a/common/trace_dump.cpp b/common/trace_dump.cpp index 6e67e08..8732d1e 100644 --- a/common/trace_dump.cpp +++ b/common/trace_dump.cpp @@ -229,23 +229,7 @@ public: } void visit(StackFrame *frame) { - if (frame->module != NULL) { - os << frame->module << " "; - } - if (frame->function != NULL) { - os << "at " << frame->function << "() "; - } - if (frame->filename != NULL) { - os << "at " << frame->filename; - if (frame->linenumber >= 0) { - os << ":" << frame->linenumber << " "; - } - } - else { - if (frame->offset >= 0) { - os << "[" << "0x" << std::hex << frame->offset << std::dec << "]"; - } - } + frame->dump(os); } void visit(Backtrace & backtrace) { diff --git a/common/trace_model.hpp b/common/trace_model.hpp index 36f0a03..ba7c845 100644 --- a/common/trace_model.hpp +++ b/common/trace_model.hpp @@ -36,6 +36,7 @@ #include #include +#include namespace trace { @@ -388,6 +389,22 @@ struct RawStackFrame { offset(-1) { } + + void dump(std::ostream &os) { + os << (this->module ? this->module : "?"); + if (this->function != NULL) { + os << ": " << this->function; + } + if (this->offset >= 0) { + os << "+0x" << std::hex << this->offset << std::dec; + } + if (this->filename != NULL) { + os << ": " << this->filename; + if (this->linenumber >= 0) { + os << ":" << this->linenumber; + } + } + } }; class StackFrame : public RawStackFrame {