blob: fc2fa8162e8a2269335690a864c4a79b4e6bb9c9 [file] [log] [blame]
// Copyright 2018 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.
#pragma once
#include <vector>
#include <zircon/syscalls/exception.h>
#include <zx/thread.h>
#include "garnet/bin/debug_agent/arch_x64.h"
namespace debug_ipc {
struct Register;
} // namespace debug_ipc
namespace debug_agent {
namespace arch {
// Helper functions for defining x86 arch dependent behavior.
// They are on a separate header/implementation so that it can be more easily
// tested.
// Returns the state the debug registers should be if we added a execution HW
// breakpoint for |address|.
// return ZX_ERR_NO_RESOURCES if there are no registers left.
zx_status_t SetupHWBreakpoint(uint64_t address,
zx_thread_state_debug_regs_t*);
// Removes an installed execution HW breakpoint for |address|.
// If the address is not installed, no functional change will happen and
// ZX_ERR_OUT_OF_RANGE will be returned.
zx_status_t RemoveHWBreakpoint(uint64_t address, zx_thread_state_debug_regs_t*);
zx_status_t WriteGeneralRegisters(const std::vector<debug_ipc::Register>&,
zx_thread_state_general_regs_t*);
// Debug functions -------------------------------------------------------------
void PrintGeneralRegisters(const zx_thread_state_general_regs&);
void PrintDebugRegisters(const zx_thread_state_debug_regs_t&);
} // namespace arch
} // namespace debug_agent