chromium/base/debug/task_trace.cc

// Copyright 2019 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "base/debug/task_trace.h"

#include <algorithm>
#include <iostream>
#include <sstream>

#include "base/pending_task.h"
#include "base/ranges/algorithm.h"
#include "base/task/common/task_annotator.h"
#include "build/build_config.h"

#if BUILDFLAG(IS_ANDROID)
#include <android/log.h>

#include "base/no_destructor.h"
#endif  // BUILDFLAG(IS_ANDROID)

namespace base {
namespace debug {
namespace {
#if BUILDFLAG(IS_ANDROID)
// Android sends stdout and stderr to /dev/null; logging should be done through
// the __android_log_write() function. Here we create an override of
// std::stringbuf that writes to the Android log.
class AndroidErrBuffer : public std::stringbuf {
 protected:
  int sync() override {
    __android_log_write(ANDROID_LOG_ERROR, "chromium", str().c_str());
    return 0;
  }
};

std::ostream& DefaultOutputStream() {
  static NoDestructor<AndroidErrBuffer> buf;
  static NoDestructor<std::ostream> out(buf.get());
  return *out;
}
#else
// Use stderr by default.
std::ostream& DefaultOutputStream() {}
#endif  // BUILDFLAG(IS_ANDROID)
}  // namespace

TaskTrace::TaskTrace() {}

bool TaskTrace::empty() const {}

void TaskTrace::Print() const {}

void TaskTrace::OutputToStream(std::ostream* os) const {}

std::string TaskTrace::ToString() const {}

size_t TaskTrace::GetAddresses(span<const void*> addresses) const {}

std::ostream& operator<<(std::ostream& os, const TaskTrace& task_trace) {}

}  // namespace debug
}  // namespace base