llvm/lldb/include/lldb/Utility/TraceIntelPTGDBRemotePackets.h

//===-- TraceIntelPTGDBRemotePackets.h --------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

#ifndef LLDB_UTILITY_TRACEINTELPTGDBREMOTEPACKETS_H
#define LLDB_UTILITY_TRACEINTELPTGDBREMOTEPACKETS_H

#include "lldb/Utility/TraceGDBRemotePackets.h"

#include "llvm/Support/JSON.h"

#include <chrono>
#include <optional>

/// See docs/lldb-gdb-remote.txt for more information.
///
/// Do not use system-dependent types, like size_t, because they might cause
/// issues when compiling on arm.
namespace lldb_private {

// List of data kinds used by jLLDBGetState and jLLDBGetBinaryData.
struct IntelPTDataKinds {};

/// jLLDBTraceStart gdb-remote packet
/// \{
struct TraceIntelPTStartRequest : TraceStartRequest {};

bool fromJSON(const llvm::json::Value &value, TraceIntelPTStartRequest &packet,
              llvm::json::Path path);

llvm::json::Value toJSON(const TraceIntelPTStartRequest &packet);
/// \}

/// Helper structure to help parse long numbers that can't
/// be easily represented by a JSON number that is compatible with
/// Javascript (52 bits) or that can also be represented as hex.
///
/// \{
struct JSONUINT64 {};

llvm::json::Value toJSON(const JSONUINT64 &uint64, bool hex);

bool fromJSON(const llvm::json::Value &value, JSONUINT64 &uint64,
              llvm::json::Path path);
/// \}

/// jLLDBTraceGetState gdb-remote packet
/// \{

/// TSC to wall time conversion values defined in the Linux perf_event_open API
/// when the capibilities cap_user_time and cap_user_time_zero are set. See the
/// See the documentation of `time_zero` in
/// https://man7.org/linux/man-pages/man2/perf_event_open.2.html for more
/// information.
struct LinuxPerfZeroTscConversion {};

struct TraceIntelPTGetStateResponse : TraceGetStateResponse {};

bool fromJSON(const llvm::json::Value &value,
              LinuxPerfZeroTscConversion &packet, llvm::json::Path path);

llvm::json::Value toJSON(const LinuxPerfZeroTscConversion &packet);

bool fromJSON(const llvm::json::Value &value,
              TraceIntelPTGetStateResponse &packet, llvm::json::Path path);

llvm::json::Value toJSON(const TraceIntelPTGetStateResponse &packet);
/// \}

} // namespace lldb_private

#endif // LLDB_UTILITY_TRACEINTELPTGDBREMOTEPACKETS_H