Skip to content

Commit dcdd051

Browse files
devnexenyuxuanchen1997
authored andcommitted
[compiler-rt] dump registers for FreeBSD/i386 (#99702)
Summary: Test Plan: Reviewers: Subscribers: Tasks: Tags: Differential Revision: https://phabricator.intern.facebook.com/D60251263
1 parent 6488fde commit dcdd051

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2262,6 +2262,18 @@ void SignalContext::DumpAllRegisters(void *context) {
22622262
Printf("r14 = 0x%016llx ", ucontext->uc_mcontext.mc_r14);
22632263
Printf("r15 = 0x%016llx ", ucontext->uc_mcontext.mc_r15);
22642264
Printf("\n");
2265+
# elif defined(__i386__)
2266+
Report("Register values:\n");
2267+
Printf("eax = 0x%08x ", ucontext->uc_mcontext.mc_eax);
2268+
Printf("ebx = 0x%08x ", ucontext->uc_mcontext.mc_ebx);
2269+
Printf("ecx = 0x%08x ", ucontext->uc_mcontext.mc_ecx);
2270+
Printf("edx = 0x%08x ", ucontext->uc_mcontext.mc_edx);
2271+
Printf("\n");
2272+
Printf("edi = 0x%08x ", ucontext->uc_mcontext.mc_edi);
2273+
Printf("esi = 0x%08x ", ucontext->uc_mcontext.mc_esi);
2274+
Printf("ebp = 0x%08x ", ucontext->uc_mcontext.mc_ebp);
2275+
Printf("esp = 0x%08x ", ucontext->uc_mcontext.mc_esp);
2276+
Printf("\n");
22652277
# else
22662278
(void)ucontext;
22672279
# endif
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Check that sanitizer prints registers dump_registers on dump_registers=1
2+
// RUN: %clangxx %s -o %t
3+
// RUN: %env_tool_opts=dump_registers=0 not %run %t 2>&1 | FileCheck %s --check-prefixes=CHECK-NODUMP --strict-whitespace
4+
// RUN: not %run %t 2>&1 | FileCheck %s --check-prefixes=CHECK-DUMP --strict-whitespace
5+
//
6+
// REQUIRES: i386-target-arch
7+
8+
#include <signal.h>
9+
10+
int main() {
11+
raise(SIGSEGV);
12+
// CHECK-DUMP: Register values
13+
// CHECK-DUMP-NEXT: eax = {{0x[0-9a-f]+}} ebx = {{0x[0-9a-f]+}} ecx = {{0x[0-9a-f]+}} edx = {{0x[0-9a-f]+}}
14+
// CHECK-DUMP-NEXT: edi = {{0x[0-9a-f]+}} esi = {{0x[0-9a-f]+}} ebp = {{0x[0-9a-f]+}} esp = {{0x[0-9a-f]+}}
15+
// CHECK-NODUMP-NOT: Register values
16+
return 0;
17+
}

0 commit comments

Comments
 (0)