1 // Copyright 2024 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #include "net/third_party/quiche/overrides/quiche_platform_impl/quiche_stack_trace_impl.h"
6 
7 namespace quiche {
8 namespace {
9 static constexpr size_t kMaxStackSize = 256;
10 }  // namespace
11 
CurrentStackTraceImpl()12 std::vector<void*> CurrentStackTraceImpl() {
13   std::vector<void*> stacktrace(kMaxStackSize, nullptr);
14   size_t frame_count = base::debug::CollectStackTrace(
15       const_cast<const void**>(stacktrace.data()), stacktrace.size());
16   if (frame_count <= 0) {
17     return {};
18   }
19   stacktrace.resize(frame_count);
20   return stacktrace;
21 }
22 
SymbolizeStackTraceImpl(absl::Span<void * const> stacktrace)23 std::string SymbolizeStackTraceImpl(absl::Span<void* const> stacktrace) {
24   return base::debug::StackTrace(stacktrace.data(), stacktrace.size())
25       .ToString();
26 }
27 
QuicheStackTraceImpl()28 std::string QuicheStackTraceImpl() {
29   return base::debug::StackTrace().ToString();
30 }
31 
QuicheShouldRunStackTraceTestImpl()32 bool QuicheShouldRunStackTraceTestImpl() {
33   return base::debug::StackTrace::WillSymbolizeToStreamForTesting();
34 }
35 
36 }  // namespace quiche
37