v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
stack_trace.cc
Go to the documentation of this file.
1// Copyright 2016 the V8 project authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
6
7#include <string.h>
8
9#include <algorithm>
10#include <sstream>
11
12#include "src/base/macros.h"
13
14namespace v8 {
15namespace base {
16namespace debug {
17
18StackTrace::StackTrace(const void* const* trace, size_t count) {
19 count = std::min(count, arraysize(trace_));
20 if (count) memcpy(trace_, trace, count * sizeof(trace_[0]));
21 count_ = count;
22}
23
24StackTrace::~StackTrace() = default;
25
26const void* const* StackTrace::Addresses(size_t* count) const {
27 *count = count_;
28 if (count_) return trace_;
29 return nullptr;
30}
31
32std::string StackTrace::ToString() const {
33 std::stringstream stream;
34 OutputToStream(&stream);
35 return stream.str();
36}
37
38} // namespace debug
39} // namespace base
40} // namespace v8
void OutputToStream(std::ostream *os) const
std::string ToString() const
const void *const * Addresses(size_t *count) const
void * trace_[kMaxTraces]
Definition stack_trace.h:87
uint32_t count
#define arraysize(array)
Definition macros.h:67