mirror of
https://github.com/Ed94/raddebugger.git
synced 2026-11-29 00:53:20 -08:00
only inc x64 into base by default on linux, where we actually apparently need it - ideally we do not just pull in all of x64 just for a few enum codes'
This commit is contained in:
1 parent
4e4639c2a0
commit
9796328ffa
3 files changed
+50
-41
No files matched your search
@@ -1151,15 +1151,15 @@ lnx_dispatch_memory_read_fault(int sig, siginfo_t *info, void *context)
|
|||||||
|
|
||||||
#if ARCH_X64 || ARCH_X86
|
#if ARCH_X64 || ARCH_X86
|
||||||
if(sig != SIGSEGV || info == 0 || context == 0 ||
|
if(sig != SIGSEGV || info == 0 || context == 0 ||
|
||||||
(info->si_code != SEGV_ACCERR && info->si_code != SEGV_MAPERR) ||
|
(info->si_code != SEGV_ACCERR && info->si_code != SEGV_MAPERR) ||
|
||||||
lnx_in_memory_fault_callback ||
|
lnx_in_memory_fault_callback ||
|
||||||
ins_atomic_u32_eval(&memory->active) == 0)
|
ins_atomic_u32_eval(&memory->active) == 0)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
ucontext_t *state = context;
|
ucontext_t *state = context;
|
||||||
if((state->uc_mcontext.gregs[REG_TRAPNO] != X64_Exception_PF) ||
|
if((state->uc_mcontext.gregs[REG_TRAPNO] != X64_ExceptionCode_PF) ||
|
||||||
(state->uc_mcontext.gregs[REG_ERR] & X64_PageFaultError_Write) ||
|
(state->uc_mcontext.gregs[REG_ERR] & X64_PageFaultError_Write) ||
|
||||||
(state->uc_mcontext.gregs[REG_ERR] & X64_PageFaultError_InstructionFetch) ||
|
(state->uc_mcontext.gregs[REG_ERR] & X64_PageFaultError_InstructionFetch) ||
|
||||||
memory->owner_pid != getpid())
|
memory->owner_pid != getpid())
|
||||||
|
|||||||
@@ -35,6 +35,13 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <ucontext.h>
|
#include <ucontext.h>
|
||||||
|
|
||||||
|
// NOTE(rjf): this is required because we need to use architecture-specific code for "base"
|
||||||
|
// OS functionality - we may want to reevaluate if such things should be in base - but for
|
||||||
|
// now just pulling in the whole x64 layer, just for linux.
|
||||||
|
#if ARCH_X64 || ARCH_X86
|
||||||
|
# include "x64/x64.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
pid_t gettid(void);
|
pid_t gettid(void);
|
||||||
int pthread_setname_np(pthread_t thread, const char *name);
|
int pthread_setname_np(pthread_t thread, const char *name);
|
||||||
int pthread_getname_np(pthread_t thread, char *name, size_t size);
|
int pthread_getname_np(pthread_t thread, char *name, size_t size);
|
||||||
@@ -46,13 +53,13 @@ typedef struct timespec timespec;
|
|||||||
//~ rjf: Linux Call Interruption Retry Helper
|
//~ rjf: Linux Call Interruption Retry Helper
|
||||||
|
|
||||||
#define LNX_RETRY_ON_EINTR(expr) \
|
#define LNX_RETRY_ON_EINTR(expr) \
|
||||||
(__extension__({ \
|
(__extension__({ \
|
||||||
__typeof__(expr) __ret; \
|
__typeof__(expr) __ret; \
|
||||||
do { \
|
do { \
|
||||||
__ret = (expr); \
|
__ret = (expr); \
|
||||||
} while ((__ret == -1) && errno == EINTR); \
|
} while ((__ret == -1) && errno == EINTR); \
|
||||||
__ret; \
|
__ret; \
|
||||||
}))
|
}))
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
|
|||||||
+32
-30
@@ -212,39 +212,40 @@ X64_DebugControlFlags;
|
|||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
//~ Exception Codes
|
//~ Exception Codes
|
||||||
|
|
||||||
typedef enum
|
typedef enum X64_ExceptionCode
|
||||||
{
|
{
|
||||||
X64_Exception_DE = 0, // Divide error: division by zero or quotient overflow
|
X64_ExceptionCode_DE = 0, // Divide error: division by zero or quotient overflow
|
||||||
X64_Exception_DB = 1, // Debug exception (single stepping, hardware breakpoint)
|
X64_ExceptionCode_DB = 1, // Debug exception (single stepping, hardware breakpoint)
|
||||||
X64_Exception_NMI = 2, // Non-maskable interrupt
|
X64_ExceptionCode_NMI = 2, // Non-maskable interrupt
|
||||||
X64_Exception_BP = 3, // Breakpoint (int3)
|
X64_ExceptionCode_BP = 3, // Breakpoint (int3)
|
||||||
X64_Exception_OF = 4, // Overflow
|
X64_ExceptionCode_OF = 4, // Overflow
|
||||||
X64_Exception_BR = 5, // Bound range exceeded
|
X64_ExceptionCode_BR = 5, // Bound range exceeded
|
||||||
X64_Exception_UD = 6, // Invalid opcode
|
X64_ExceptionCode_UD = 6, // Invalid opcode
|
||||||
X64_Exception_NM = 7, // Device not available
|
X64_ExceptionCode_NM = 7, // Device not available
|
||||||
X64_Exception_DF = 8, // Double fault
|
X64_ExceptionCode_DF = 8, // Double fault
|
||||||
X64_Exception_9 = 9, // Coprocessor segment overrun (obsolete)
|
X64_ExceptionCode_9 = 9, // Coprocessor segment overrun (obsolete)
|
||||||
X64_Exception_TS = 10, // Invalid task-state segment
|
X64_ExceptionCode_TS = 10, // Invalid task-state segment
|
||||||
X64_Exception_NP = 11, // Segment not present
|
X64_ExceptionCode_NP = 11, // Segment not present
|
||||||
X64_Exception_SS = 12, // Stack-segment fault
|
X64_ExceptionCode_SS = 12, // Stack-segment fault
|
||||||
X64_Exception_GP = 13, // General-protection fault
|
X64_ExceptionCode_GP = 13, // General-protection fault
|
||||||
X64_Exception_PF = 14, // Page fault
|
X64_ExceptionCode_PF = 14, // Page fault
|
||||||
X64_Exception_15 = 15, // Reserved; Linux names it X86_TRAP_SPURIOUS
|
X64_ExceptionCode_15 = 15, // Reserved; Linux names it X86_TRAP_SPURIOUS
|
||||||
X64_Exception_MF = 16, // x87 floating-point exception
|
X64_ExceptionCode_MF = 16, // x87 floating-point exception
|
||||||
X64_Exception_AC = 17, // Alignment check
|
X64_ExceptionCode_AC = 17, // Alignment check
|
||||||
X64_Exception_MC = 18, // Machine check
|
X64_ExceptionCode_MC = 18, // Machine check
|
||||||
X64_Exception_XF = 19, // SIMD floating-point exception
|
X64_ExceptionCode_XF = 19, // SIMD floating-point exception
|
||||||
X64_Exception_VE = 20, // Virtualization exception
|
X64_ExceptionCode_VE = 20, // Virtualization exception
|
||||||
X64_Exception_CP = 21, // Control-protection exception
|
X64_ExceptionCode_CP = 21, // Control-protection exception
|
||||||
X64_Exception_Amd_HV = 28, // Hypervisor injection exception
|
X64_ExceptionCode_Amd_HV = 28, // Hypervisor injection exception
|
||||||
X64_Exception_Amd_VC = 29, // VMM communication exception
|
X64_ExceptionCode_Amd_VC = 29, // VMM communication exception
|
||||||
X64_Exception_Amd_SX = 30, // Security exception
|
X64_ExceptionCode_Amd_SX = 30, // Security exception
|
||||||
} X64_ExceptionCode;
|
}
|
||||||
|
X64_ExceptionCode;
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
//~ Page Fault Flags
|
//~ Page Fault Flags
|
||||||
|
|
||||||
typedef enum
|
typedef enum X64_PageFaultError
|
||||||
{
|
{
|
||||||
X64_PageFaultError_Protection = (1u << 0),
|
X64_PageFaultError_Protection = (1u << 0),
|
||||||
X64_PageFaultError_Write = (1u << 1),
|
X64_PageFaultError_Write = (1u << 1),
|
||||||
@@ -253,7 +254,8 @@ typedef enum
|
|||||||
X64_PageFaultError_InstructionFetch = (1u << 4),
|
X64_PageFaultError_InstructionFetch = (1u << 4),
|
||||||
X64_PageFaultError_ProtectionKey = (1u << 5),
|
X64_PageFaultError_ProtectionKey = (1u << 5),
|
||||||
X64_PageFaultError_ShadowStack = (1u << 6),
|
X64_PageFaultError_ShadowStack = (1u << 6),
|
||||||
} X64_PageFaultError;
|
}
|
||||||
|
X64_PageFaultError;
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
//~ rjf: Generated
|
//~ rjf: Generated
|
||||||
@@ -280,4 +282,4 @@ internal X64_XSaveLayout x64_get_xsave_layout(U64 xcr0);
|
|||||||
|
|
||||||
internal void x64_set_debug_break(U64 *drs, U64 trap_idx, U64 addr, U64 size, X64_BreakpointType bp_type, X64_DebugBreakType break_type);
|
internal void x64_set_debug_break(U64 *drs, U64 trap_idx, U64 addr, U64 size, X64_BreakpointType bp_type, X64_DebugBreakType break_type);
|
||||||
|
|
||||||
#endif // BASE_X64_H
|
#endif // X64_H
|
||||||
Reference in new issue
Block a user