1cf2cfa174ca878c144e17e9fc60ca8e9070d7dededisonn@google.com//===-- DNBArch.h -----------------------------------------------*- C++ -*-===// 2cf2cfa174ca878c144e17e9fc60ca8e9070d7dededisonn@google.com// 3cf2cfa174ca878c144e17e9fc60ca8e9070d7dededisonn@google.com// The LLVM Compiler Infrastructure 4cf2cfa174ca878c144e17e9fc60ca8e9070d7dededisonn@google.com// 5cf2cfa174ca878c144e17e9fc60ca8e9070d7dededisonn@google.com// This file is distributed under the University of Illinois Open Source 6cf2cfa174ca878c144e17e9fc60ca8e9070d7dededisonn@google.com// License. See LICENSE.TXT for details. 7cf2cfa174ca878c144e17e9fc60ca8e9070d7dededisonn@google.com// 8cf2cfa174ca878c144e17e9fc60ca8e9070d7dededisonn@google.com//===----------------------------------------------------------------------===// 9cf2cfa174ca878c144e17e9fc60ca8e9070d7dededisonn@google.com// 108cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com// Created by Greg Clayton on 6/24/07. 118cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com// 128cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com//===----------------------------------------------------------------------===// 138cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com 148cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com#ifndef __DebugNubArch_h__ 158cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com#define __DebugNubArch_h__ 168cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com 178cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com#include "DNBDefs.h" 188cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com#include "MacOSX/MachException.h" 198cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com 208cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com#include <mach/mach.h> 218cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com#include <stdio.h> 228cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com 238cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.comstruct DNBRegisterValue; 248cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.comstruct DNBRegisterSetInfo; 258cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.comclass DNBArchProtocol; 268cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.comclass MachThread; 278cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com 288cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.comtypedef DNBArchProtocol * (* DNBArchCallbackCreate)(MachThread *thread); 298cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.comtypedef const DNBRegisterSetInfo * (* DNBArchCallbackGetRegisterSetInfo)(nub_size_t *num_reg_sets); 308cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.comtypedef const uint8_t * const (* DNBArchCallbackGetBreakpointOpcode)(nub_size_t byte_size); 318cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com 328cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.comtypedef struct DNBArchPluginInfoTag 338cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com{ 348cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com uint32_t cpu_type; 358cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com DNBArchCallbackCreate Create; 368cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com DNBArchCallbackGetRegisterSetInfo GetRegisterSetInfo; 378cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com DNBArchCallbackGetBreakpointOpcode GetBreakpointOpcode; 388cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com} DNBArchPluginInfo; 398cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com 408cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.comclass DNBArchProtocol 418cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com{ 428cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.compublic: 438cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com static DNBArchProtocol * 448cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com Create (MachThread *thread); 458cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com 468cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com static const DNBRegisterSetInfo * 478cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com GetRegisterSetInfo (nub_size_t *num_reg_sets); 488cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com 498cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com static const uint8_t * const 508cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com GetBreakpointOpcode (nub_size_t byte_size); 518cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com 528cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com static void 538cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com RegisterArchPlugin (const DNBArchPluginInfo &arch_info); 548cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com 558cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com static uint32_t 568cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com GetArchitecture (); 578cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com 588cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com static bool 598cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com SetArchitecture (uint32_t cpu_type); 608cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com 618cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com virtual bool GetRegisterValue (int set, int reg, DNBRegisterValue *value) = 0; 628cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com virtual bool SetRegisterValue (int set, int reg, const DNBRegisterValue *value) = 0; 638cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com virtual nub_size_t GetRegisterContext (void *buf, nub_size_t buf_len) = 0; 648cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com virtual nub_size_t SetRegisterContext (const void *buf, nub_size_t buf_len) = 0; 658cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com 668cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com virtual kern_return_t GetRegisterState (int set, bool force) = 0; 678cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com virtual kern_return_t SetRegisterState (int set) = 0; 688cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com virtual bool RegisterSetStateIsValid (int set) const = 0; 698cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com 708cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com virtual uint64_t GetPC (uint64_t failValue) = 0; // Get program counter 718cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com virtual kern_return_t SetPC (uint64_t value) = 0; 728cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com virtual uint64_t GetSP (uint64_t failValue) = 0; // Get stack pointer 738cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com virtual void ThreadWillResume () = 0; 748cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com virtual bool ThreadDidStop () = 0; 758cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com virtual bool NotifyException (MachException::Data& exc) { return false; } 768cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com virtual uint32_t NumSupportedHardwareBreakpoints() { return 0; } 778cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com virtual uint32_t NumSupportedHardwareWatchpoints() { return 0; } 788cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com virtual uint32_t EnableHardwareBreakpoint (nub_addr_t addr, nub_size_t size) { return INVALID_NUB_HW_INDEX; } 798cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com virtual uint32_t EnableHardwareWatchpoint (nub_addr_t addr, nub_size_t size, bool read, bool write, bool also_set_on_task) { return INVALID_NUB_HW_INDEX; } 808cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com virtual bool DisableHardwareBreakpoint (uint32_t hw_index) { return false; } 818cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com virtual bool DisableHardwareWatchpoint (uint32_t hw_index, bool also_set_on_task) { return false; } 828cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com virtual uint32_t GetHardwareWatchpointHit() { return INVALID_NUB_HW_INDEX; } 838cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com virtual bool StepNotComplete () { return false; } 848cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com 858cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.comprotected: 868cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com friend class MachThread; 878cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com 888cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com enum 898cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com { 908cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com Trans_Pending = 0, // Transaction is pending, and checkpoint state has been snapshotted. 918cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com Trans_Done = 1, // Transaction is done, the current state is committed, and checkpoint state is irrelevant. 928cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com Trans_Rolled_Back = 2 // Transaction is done, the current state has been rolled back to the checkpoint state. 938cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com }; 948cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com virtual bool StartTransForHWP() { return true; } 958cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com virtual bool RollbackTransForHWP() { return true; } 968cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com virtual bool FinishTransForHWP() { return true; } 978cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com}; 988cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com 998cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com 1008cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com#include "MacOSX/arm/DNBArchImpl.h" 1018cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com#include "MacOSX/i386/DNBArchImplI386.h" 1028cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com#include "MacOSX/x86_64/DNBArchImplX86_64.h" 1038cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com#include "MacOSX/ppc/DNBArchImpl.h" 1048cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com 1058cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com#endif 1068cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com