Commit c41da451 authored by Gabriel Charette's avatar Gabriel Charette Committed by Commit Bot

[base] Add operator<< support to StackTrace

I found this much more practical when doing some local debugging as

R=kylechar@chromium.org

StackTrace: :OutputToStream() can't be used in conjunction with DCHECK.
Change-Id: If9eb007b914a4a33d6fffb5016e0da3ada1ebc4b
Reviewed-on: https://chromium-review.googlesource.com/c/1481464
Commit-Queue: Gabriel Charette <gab@chromium.org>
Reviewed-by: default avatarkylechar <kylechar@chromium.org>
Cr-Commit-Position: refs/heads/master@{#634477}
parent 2a6cacbe
......@@ -239,6 +239,15 @@ std::string StackTrace::ToStringWithPrefix(const char* prefix_string) const {
return stream.str();
}
std::ostream& operator<<(std::ostream& os, const StackTrace& s) {
#if !defined(__UCLIBC__) & !defined(_AIX)
s.OutputToStream(&os);
#else
os << "StackTrace::OutputToStream not implemented.";
#endif
return os;
}
#if BUILDFLAG(CAN_UNWIND_WITH_FRAME_POINTERS)
size_t TraceStackFramePointers(const void** out_trace,
......
......@@ -124,6 +124,9 @@ class BASE_EXPORT StackTrace {
size_t count_;
};
// Forwards to StackTrace::OutputToStream().
BASE_EXPORT std::ostream& operator<<(std::ostream& os, const StackTrace& s);
// Record a stack trace with up to |count| frames into |trace|. Returns the
// number of frames read.
BASE_EXPORT size_t CollectStackTrace(void** trace, size_t count);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment