BSD: Add register defines for ARM/PPC/MIPS in Logger.c, completely untested though

Also add register defines for SPARC for Solaris
This commit is contained in:
UnknownShadow200 2022-11-07 20:28:28 +11:00
parent 6743b3574f
commit 273d2901a5
3 changed files with 103 additions and 11 deletions

View file

@ -125,7 +125,6 @@ RPI64_CC=~/rpi64/cross-pi-gcc-9.4.0-64/bin/aarch64-linux-gnu-gcc
build_rpi32() {
echo "Building rpi32.."
cp $ROOT_DIR/misc/CCIcon_X11 $ROOT_DIR/src/CCIcon_X11
rm cc-rpi
$RPI32_CC *.c $ALL_FLAGS $RPI_FLAGS -I ~/rpi/include -L ~/rpi/lib -DCC_COMMIT_SHA=\"$LATEST\" -o cc-rpi -lGLESv2 -lEGL -lX11 -lXi -lm -lpthread -ldl -lrt -Wl,-rpath-link ~/rpi/lib
if [ $? -ne 0 ]; then echo "Failed to compile Raspberry Pi 32 bit" >> "$ERRS_FILE"; fi
@ -133,7 +132,6 @@ build_rpi32() {
build_rpi64() {
echo "Building rpi64.."
cp $ROOT_DIR/misc/CCIcon_X11 $ROOT_DIR/src/CCIcon_X11
rm cc-rpi64
$RPI64_CC *.c $ALL_FLAGS $RPI_FLAGS -DCC_COMMIT_SHA=\"$LATEST\" -o cc-rpi64 -lGLESv2 -lEGL -lX11 -lXi -lm -lpthread -ldl
if [ $? -ne 0 ]; then echo "Failed to compile Raspberry Pi 64 bit" >> "$ERRS_FILE"; fi

View file

@ -590,22 +590,24 @@ static void PrintRegisters(cc_string* str, void* ctx) {
#define REG_GET_LR() &r.gp_regs[35]
#define REG_GET_CTR() &r.gp_regs[34]
Dump_PPC()
#elif defined __riscv
#define REG_GNUM(num) &r.__gregs[num]
#define REG_GET_PC() &r.__gregs[REG_PC]
Dump_RISCV()
#elif defined __mips__
#define REG_GNUM(num) &r.gregs[num]
#define REG_GET_PC() &r.pc
#define REG_GET_LO() &r.mdlo
#define REG_GET_HI() &r.mdhi
Dump_MIPS()
#elif defined __riscv
#define REG_GNUM(num) &r.__gregs[num]
#define REG_GET_PC() &r.__gregs[REG_PC]
Dump_RISCV()
#else
#error "Unknown CPU architecture"
#endif
}
#elif defined CC_BUILD_SOLARIS
/* See /usr/include/sys/regset.h */
/* -> usr/src/uts/[ARCH]/sys/mcontext.h */
/* -> usr/src/uts/[ARCH]/sys/regset.h */
static void PrintRegisters(cc_string* str, void* ctx) {
mcontext_t r = ((ucontext_t*)ctx)->uc_mcontext;
@ -615,12 +617,16 @@ static void PrintRegisters(cc_string* str, void* ctx) {
#elif defined __x86_64__
#define REG_GET(ign, reg) &r.gregs[REG_R##reg]
Dump_X64()
#elif defined __sparc__
#define REG_GET(ign, reg) &r.gregs[REG_##reg]
Dump_SPARC()
#else
#error "Unknown CPU architecture"
#endif
}
#elif defined CC_BUILD_NETBSD
/* See /usr/include/i386/mcontext.h */
/* See /usr/include/[ARCH]/mcontext.h */
/* -> src/sys/arch/[ARCH]/include/mcontext.h */
static void PrintRegisters(cc_string* str, void* ctx) {
mcontext_t r = ((ucontext_t*)ctx)->uc_mcontext;
#if defined __i386__
@ -629,12 +635,44 @@ static void PrintRegisters(cc_string* str, void* ctx) {
#elif defined __x86_64__
#define REG_GET(ign, reg) &r.__gregs[_REG_R##reg]
Dump_X64()
#elif defined __aarch64__
#define REG_GNUM(num) &r.__gregs[num]
#define REG_GET_FP() &r.__gregs[_REG_FP]
#define REG_GET_LR() &r.__gregs[_REG_LR]
#define REG_GET_SP() &r.__gregs[_REG_SP]
#define REG_GET_PC() &r.__gregs[_REG_PC]
Dump_ARM64()
#elif defined __arm__
#define REG_GNUM(num) &r.__gregs[num]
#define REG_GET_FP() &r.__gregs[_REG_FP]
#define REG_GET_IP() &r.__gregs[12]
#define REG_GET_SP() &r.__gregs[_REG_SP]
#define REG_GET_LR() &r.__gregs[_REG_LR]
#define REG_GET_PC() &r.__gregs[_REG_PC]
Dump_ARM32()
#elif defined __powerpc__
#define REG_GNUM(num) &r.__gregs[num]
#define REG_GET_PC() &r.__gregs[_REG_PC]
#define REG_GET_LR() &r.__gregs[_REG_LR]
#define REG_GET_CTR() &r.__gregs[_REG_CTR]
Dump_PPC()
#elif defined __mips__
#define REG_GNUM(num) &r.__gregs[num]
#define REG_GET_PC() &r.__gregs[_REG_EPC]
#define REG_GET_LO() &r.__gregs[_REG_MDLO]
#define REG_GET_HI() &r.__gregs[_REG_MDHI]
Dump_MIPS()
#elif defined __riscv
#define REG_GNUM(num) &r.__gregs[num]
#define REG_GET_PC() &r.__gregs[_REG_PC]
Dump_RISCV()
#else
#error "Unknown CPU architecture"
#endif
}
#elif defined CC_BUILD_FREEBSD
/* See /usr/include/machine/ucontext.h */
/* -> src/sys/[ARCH]/include/ucontext.h */
static void PrintRegisters(cc_string* str, void* ctx) {
mcontext_t r = ((ucontext_t*)ctx)->uc_mcontext;
#if defined __i386__
@ -643,20 +681,75 @@ static void PrintRegisters(cc_string* str, void* ctx) {
#elif defined __x86_64__
#define REG_GET(reg, ign) &r.mc_r##reg
Dump_X64()
#elif defined __aarch64__
#define REG_GNUM(num) &r.mc_gpregs.gp_x[num]
#define REG_GET_FP() &r.mc_gpregs.gp_x[29]
#define REG_GET_LR() &r.mc_gpregs.gp_lr
#define REG_GET_SP() &r.mc_gpregs.gp_sp
#define REG_GET_PC() &r.mc_gpregs.gp_elr
Dump_ARM64()
#elif defined __arm__
#define REG_GNUM(num) &r.__gregs[num]
#define REG_GET_FP() &r.__gregs[_REG_FP]
#define REG_GET_IP() &r.__gregs[12]
#define REG_GET_SP() &r.__gregs[_REG_SP]
#define REG_GET_LR() &r.__gregs[_REG_LR]
#define REG_GET_PC() &r.__gregs[_REG_PC]
Dump_ARM32()
#elif defined __powerpc__
#define REG_GNUM(num) &r.mc_frame[##num]
#define REG_GET_PC() &r.mc_srr0
#define REG_GET_LR() &r.mc_lr
#define REG_GET_CTR() &r.mc_ctr
Dump_PPC()
#elif defined __mips__
#define REG_GNUM(num) &r.mc_regs[num]
#define REG_GET_PC() &r.mc_pc
#define REG_GET_LO() &r.mullo
#define REG_GET_HI() &r.mulhi
Dump_MIPS()
#else
#error "Unknown CPU architecture"
#endif
}
#elif defined CC_BUILD_OPENBSD
/* See /usr/include/machine/signal.h */
/* -> src/sys/arch/[ARCH]/include/signal.h */
static void PrintRegisters(cc_string* str, void* ctx) {
struct sigcontext r = *((ucontext_t*)ctx);
ucontext_t* r = (ucontext_t*)ctx;
#if defined __i386__
#define REG_GET(reg, ign) &r.sc_e##reg
#define REG_GET(reg, ign) &r->sc_e##reg
Dump_X86()
#elif defined __x86_64__
#define REG_GET(reg, ign) &r.sc_r##reg
#define REG_GET(reg, ign) &r->sc_r##reg
Dump_X64()
#elif defined __aarch64__
#define REG_GNUM(num) &r->sc_x[num]
#define REG_GET_FP() &r->sc_x[29]
#define REG_GET_LR() &r->sc_lr
#define REG_GET_SP() &r->sc_sp
#define REG_GET_PC() &r->sc_elr
Dump_ARM64()
#elif defined __arm__
#define REG_GNUM(num) &r->sc_r##num
#define REG_GET_FP() &r->sc_r11
#define REG_GET_IP() &r->sc_r12
#define REG_GET_SP() &r->sc_usr_sp
#define REG_GET_LR() &r->sc_usr_lr
#define REG_GET_PC() &r->sc_pc
Dump_ARM32()
#elif defined __powerpc__
#define REG_GNUM(num) &r->sc_frame.fixreg[num]
#define REG_GET_PC() &r->sc_frame.srr0
#define REG_GET_LR() &r->sc_frame.lr
#define REG_GET_CTR() &r->sc_frame.ctr
Dump_PPC()
#elif defined __mips__
#define REG_GNUM(num) &r->sc_regs[num]
#define REG_GET_PC() &r->sc_pc
#define REG_GET_LO() &r->mullo
#define REG_GET_HI() &r->mulhi
Dump_MIPS()
#else
#error "Unknown CPU architecture"
#endif
@ -675,6 +768,7 @@ static void PrintRegisters(cc_string* str, void* ctx) {
#endif
}
#endif
static void DumpRegisters(void* ctx) {
cc_string str; char strBuffer[768];
String_InitArray(str, strBuffer);

View file

@ -251,7 +251,7 @@ void Window_Init(void) {
Display* display = XOpenDisplay(NULL);
int screen;
if (!display) Logger_Abort("Failed to open display");
if (!display) Logger_Abort("Failed to open the X11 display. No X server running?");
screen = DefaultScreen(display);
HookXErrors();