chromium/third_party/perfetto/src/profiling/symbolizer/local_symbolizer.cc

/*
 * Copyright (C) 2019 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#include "src/profiling/symbolizer/local_symbolizer.h"

#include <fcntl.h>

#include <charconv>
#include <cinttypes>
#include <limits>
#include <memory>
#include <optional>
#include <sstream>
#include <string>
#include <vector>

#include "perfetto/base/build_config.h"
#include "perfetto/base/compiler.h"
#include "perfetto/base/logging.h"
#include "perfetto/ext/base/file_utils.h"
#include "perfetto/ext/base/scoped_file.h"
#include "perfetto/ext/base/scoped_mmap.h"
#include "perfetto/ext/base/string_utils.h"
#include "src/profiling/symbolizer/elf.h"
#include "src/profiling/symbolizer/filesystem.h"

namespace perfetto {
namespace profiling {

// TODO(fmayer): Fix up name. This suggests it always returns a symbolizer or
// dies, which isn't the case.
std::unique_ptr<Symbolizer> LocalSymbolizerOrDie(
    std::vector<std::string> binary_path,
    const char* mode) {}

}  // namespace profiling
}  // namespace perfetto

#if PERFETTO_BUILDFLAG(PERFETTO_LOCAL_SYMBOLIZER)
#include "perfetto/ext/base/string_splitter.h"
#include "perfetto/ext/base/string_utils.h"
#include "perfetto/ext/base/utils.h"

#include <signal.h>
#include <sys/stat.h>
#include <sys/types.h>

#if PERFETTO_BUILDFLAG(PERFETTO_OS_WIN)
constexpr const char* kDefaultSymbolizer = "llvm-symbolizer.exe";
#else
constexpr const char* kDefaultSymbolizer =;
#endif

namespace perfetto {
namespace profiling {

namespace {

std::string GetLine(std::function<int64_t(char*, size_t)> fn_read) {}

bool InRange(const void* base,
             size_t total_size,
             const void* ptr,
             size_t size) {}

template <typename E>
std::optional<uint64_t> GetElfLoadBias(void* mem, size_t size) {}

template <typename E>
std::optional<std::string> GetElfBuildId(void* mem, size_t size) {}

std::string SplitBuildID(const std::string& hex_build_id) {}

bool IsElf(const char* mem, size_t size) {}

constexpr uint32_t kMachO64Magic =;

bool IsMachO64(const char* mem, size_t size) {}

struct mach_header_64 {};

struct load_command {};

struct segment_64_command {};

struct BinaryInfo {};

std::optional<BinaryInfo> GetMachOBinaryInfo(char* mem, size_t size) {}

std::optional<BinaryInfo> GetBinaryInfo(const char* fname, size_t size) {}

std::map<std::string, FoundBinary> BuildIdIndex(std::vector<std::string> dirs) {}

bool ParseJsonString(const char*& it, const char* end, std::string* out) {}

bool ParseJsonNumber(const char*& it, const char* end, double* out) {}

bool ParseJsonArray(
    const char*& it,
    const char* end,
    std::function<bool(const char*&, const char*)> process_value) {}

bool ParseJsonObject(
    const char*& it,
    const char* end,
    std::function<bool(const char*&, const char*, const std::string&)>
        process_value) {}

bool SkipJsonValue(const char*& it, const char* end) {}

}  // namespace

bool ParseLlvmSymbolizerJsonLine(const std::string& line,
                                 std::vector<SymbolizedFrame>* result) {}

BinaryFinder::~BinaryFinder() = default;

LocalBinaryIndexer::LocalBinaryIndexer(std::vector<std::string> roots)
    :{}

std::optional<FoundBinary> LocalBinaryIndexer::FindBinary(
    const std::string& abspath,
    const std::string& build_id) {}

LocalBinaryIndexer::~LocalBinaryIndexer() = default;

LocalBinaryFinder::LocalBinaryFinder(std::vector<std::string> roots)
    :{}

std::optional<FoundBinary> LocalBinaryFinder::FindBinary(
    const std::string& abspath,
    const std::string& build_id) {}

std::optional<FoundBinary> LocalBinaryFinder::IsCorrectFile(
    const std::string& symbol_file,
    const std::string& build_id) {}

std::optional<FoundBinary> LocalBinaryFinder::FindBinaryInRoot(
    const std::string& root_str,
    const std::string& abspath,
    const std::string& build_id) {}

LocalBinaryFinder::~LocalBinaryFinder() = default;

LLVMSymbolizerProcess::LLVMSymbolizerProcess(const std::string& symbolizer_path)
    :{}
#endif

std::vector<SymbolizedFrame> LLVMSymbolizerProcess::Symbolize(
    const std::string& binary,
    uint64_t address) {}
std::vector<std::vector<SymbolizedFrame>> LocalSymbolizer::Symbolize(
    const std::string& mapping_name,
    const std::string& build_id,
    uint64_t load_bias,
    const std::vector<uint64_t>& addresses) {}

LocalSymbolizer::LocalSymbolizer(const std::string& symbolizer_path,
                                 std::unique_ptr<BinaryFinder> finder)
    :{}

LocalSymbolizer::LocalSymbolizer(std::unique_ptr<BinaryFinder> finder)
    :{}

LocalSymbolizer::~LocalSymbolizer() = default;

}  // namespace profiling
}  // namespace perfetto

#endif  // PERFETTO_BUILDFLAG(PERFETTO_LOCAL_SYMBOLIZER)