blob: 71e233a1761f705edbecb9715e4508bc500cca20 [file] [log] [blame]
// Copyright 2022 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef SRC_SYS_EARLY_BOOT_INSTRUMENTATION_COVERAGE_SOURCE_H_
#define SRC_SYS_EARLY_BOOT_INSTRUMENTATION_COVERAGE_SOURCE_H_
#include <lib/zx/channel.h>
#include <lib/zx/status.h>
#include <lib/zx/vmo.h>
#include <string_view>
#include <fbl/unique_fd.h>
#include <sdk/lib/vfs/cpp/pseudo_dir.h>
namespace early_boot_instrumentation {
// Filenames for each exposed profraw/symbolizer files.
// Zircon's profraw and optionally symbolizer log.
static constexpr std::string_view kKernelFile = "zircon.profraw";
// This file may be available, only if, the kernel exposes a symbolizer log as well.
// This might eventually be replaced by self-describing profraw file.
static constexpr std::string_view kKernelSymbolizerFile = "zircon.log";
// Physboot's profraw and optionally symbolizer log.
static constexpr std::string_view kPhysFile = "physboot.profraw";
// This file may be available, only if, the physboot exposes a symbolizer log as well.
// This might eventually be replaced by self-describing profraw file.
static constexpr std::string_view kPhysSymbolizerFile = "physboot.log";
// Given a handle to |kernel_data_dir|, will extract the kernel coverage vmos from it,
// and add them as VMO file into |out_dir|.
//
// Usually |kernel_data_dir| is '/boot/kernel/data'.
zx::status<> ExposeKernelProfileData(fbl::unique_fd& kernel_data_dir, vfs::PseudoDir& out_dir);
// Given a handle to |phys_data_dir|, will extract the physboot's coverage vmos from it,
// and add them as VMO file into |out_dir|.
//
// Usually |phys_data_dir| is '/boot/kernel/data/phys'.
zx::status<> ExposePhysbootProfileData(fbl::unique_fd& physboot_data_dir, vfs::PseudoDir& out_dir);
} // namespace early_boot_instrumentation
#endif // SRC_SYS_EARLY_BOOT_INSTRUMENTATION_COVERAGE_SOURCE_H_