Commit 32ee1b20 authored by Daniel Cheng's avatar Daniel Cheng Committed by Commit Bot

Add base::debug::TaskTrace::ToString() to match base::debug::StackTrace.

Change-Id: I14139ced0ed1fb23650d976784b723cf48e973ef
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1603488
Commit-Queue: Daniel Cheng <dcheng@chromium.org>
Commit-Queue: Albert J. Wong <ajwong@chromium.org>
Reviewed-by: default avatarAlbert J. Wong <ajwong@chromium.org>
Cr-Commit-Position: refs/heads/master@{#658317}
parent 4f174825
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#include <algorithm> #include <algorithm>
#include <iostream> #include <iostream>
#include <sstream>
#include "base/pending_task.h" #include "base/pending_task.h"
#include "base/task/common/task_annotator.h" #include "base/task/common/task_annotator.h"
...@@ -52,6 +53,12 @@ void TaskTrace::OutputToStream(std::ostream* os) const { ...@@ -52,6 +53,12 @@ void TaskTrace::OutputToStream(std::ostream* os) const {
} }
} }
std::string TaskTrace::ToString() const {
std::stringstream stream;
OutputToStream(&stream);
return stream.str();
}
base::span<const void* const> TaskTrace::AddressesForTesting() const { base::span<const void* const> TaskTrace::AddressesForTesting() const {
if (empty()) if (empty())
return {}; return {};
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#define BASE_DEBUG_TASK_TRACE_H_ #define BASE_DEBUG_TASK_TRACE_H_
#include <iosfwd> #include <iosfwd>
#include <string>
#include "base/base_export.h" #include "base/base_export.h"
#include "base/containers/span.h" #include "base/containers/span.h"
...@@ -45,6 +46,9 @@ class BASE_EXPORT TaskTrace { ...@@ -45,6 +46,9 @@ class BASE_EXPORT TaskTrace {
// Outputs trace to |os|, may be called when empty() is true. // Outputs trace to |os|, may be called when empty() is true.
void OutputToStream(std::ostream* os) const; void OutputToStream(std::ostream* os) const;
// Resolves trace to symbols and returns as string.
std::string ToString() const;
// Returns the list of addresses in the task trace for testing. // Returns the list of addresses in the task trace for testing.
base::span<const void* const> AddressesForTesting() const; base::span<const void* const> AddressesForTesting() const;
......
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