Skip to content

Commit b0fbfbb

Browse files
authored
[compiler-rt]: DumpAllRegs on NetBSD arm64. (#102826)
all 35 registers are stored in one unique array. for simplicity sake, we do not bother using _REG_X* constants.
1 parent 1f02be2 commit b0fbfbb

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2312,11 +2312,11 @@ static const char *RegNumToRegName(int reg) {
23122312
return NULL;
23132313
}
23142314

2315-
# if SANITIZER_LINUX && SANITIZER_GLIBC && \
2315+
# if ((SANITIZER_LINUX && SANITIZER_GLIBC) || SANITIZER_NETBSD) && \
23162316
(defined(__arm__) || defined(__aarch64__))
23172317
static uptr GetArmRegister(ucontext_t *ctx, int RegNum) {
23182318
switch (RegNum) {
2319-
# if defined(__arm__)
2319+
# if defined(__arm__) && !SANITIZER_NETBSD
23202320
# ifdef MAKE_CASE
23212321
# undef MAKE_CASE
23222322
# endif
@@ -2345,10 +2345,15 @@ static uptr GetArmRegister(ucontext_t *ctx, int RegNum) {
23452345
case REG_R15:
23462346
return ctx->uc_mcontext.arm_pc;
23472347
# elif defined(__aarch64__)
2348+
# if SANITIZER_LINUX
23482349
case 0 ... 30:
23492350
return ctx->uc_mcontext.regs[RegNum];
23502351
case 31:
23512352
return ctx->uc_mcontext.sp;
2353+
# elif SANITIZER_NETBSD
2354+
case 0 ... 31:
2355+
return ctx->uc_mcontext.__gregs[RegNum];
2356+
# endif
23522357
# endif
23532358
default:
23542359
return 0;
@@ -2456,7 +2461,7 @@ void SignalContext::DumpAllRegisters(void *context) {
24562461
DumpSingleReg(ucontext, REG_R14);
24572462
DumpSingleReg(ucontext, REG_R15);
24582463
Printf("\n");
2459-
# elif defined(__aarch64__) && !SANITIZER_NETBSD
2464+
# elif defined(__aarch64__)
24602465
Report("Register values:\n");
24612466
for (int i = 0; i <= 31; ++i) {
24622467
DumpSingleReg(ucontext, i);

0 commit comments

Comments
 (0)