Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include <signal.h> | 5 #include <signal.h> |
| 6 #include <string.h> | 6 #include <string.h> |
| 7 #include <sys/types.h> | 7 #include <sys/types.h> |
| 8 #include <syscall.h> | 8 #include <syscall.h> |
| 9 #include <unistd.h> | 9 #include <unistd.h> |
| 10 | 10 |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 23 char instruction = *reinterpret_cast<char*>(regs[REG_RIP]); | 23 char instruction = *reinterpret_cast<char*>(regs[REG_RIP]); |
| 24 | 24 |
| 25 // Check whether this is the kind of SIGILL we care about. | 25 // Check whether this is the kind of SIGILL we care about. |
| 26 // (info->si_addr can be NULL when we get a SIGILL via other means, | 26 // (info->si_addr can be NULL when we get a SIGILL via other means, |
| 27 // like with kill.) | 27 // like with kill.) |
| 28 if (signum != SIGILL || instruction != kLAHFInstruction) { | 28 if (signum != SIGILL || instruction != kLAHFInstruction) { |
| 29 // Not the problem we're interested in. Reraise the signal. We | 29 // Not the problem we're interested in. Reraise the signal. We |
| 30 // need to be careful to handle threads etc. properly. | 30 // need to be careful to handle threads etc. properly. |
| 31 | 31 |
| 32 struct sigaction sa; | 32 struct sigaction sa; |
| 33 sa.sa_flags = 0; | 33 memset(&sa, 0, sizeof(sa)); |
|
piman
2011/12/27 17:46:20
Do you think struct sigaction sa = {NULL}; would b
groby-ooo-7-16
2011/12/28 20:36:03
Done.
| |
| 34 sigemptyset(&sa.sa_mask); | 34 sigemptyset(&sa.sa_mask); |
| 35 sa.sa_handler = SIG_DFL; | 35 sa.sa_handler = SIG_DFL; |
| 36 sigaction(signum, &sa, NULL); | 36 sigaction(signum, &sa, NULL); |
| 37 | 37 |
| 38 // block the current signal | 38 // block the current signal |
| 39 sigset_t block_set; | 39 sigset_t block_set; |
| 40 sigemptyset(&block_set); | 40 sigemptyset(&block_set); |
| 41 sigaddset(&block_set, signum); | 41 sigaddset(&block_set, signum); |
| 42 sigprocmask(SIG_BLOCK, &block_set, NULL); | 42 sigprocmask(SIG_BLOCK, &block_set, NULL); |
| 43 | 43 |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 63 void WorkaroundFlashLAHF() { | 63 void WorkaroundFlashLAHF() { |
| 64 struct sigaction action; | 64 struct sigaction action; |
| 65 memset(&action, 0, sizeof(action)); | 65 memset(&action, 0, sizeof(action)); |
| 66 action.sa_flags = SA_SIGINFO; | 66 action.sa_flags = SA_SIGINFO; |
| 67 action.sa_sigaction = &SignalHandler; | 67 action.sa_sigaction = &SignalHandler; |
| 68 | 68 |
| 69 sigaction(SIGILL, &action, NULL); | 69 sigaction(SIGILL, &action, NULL); |
| 70 } | 70 } |
| 71 | 71 |
| 72 #endif // defined(ARCH_CPU_64_BITS) | 72 #endif // defined(ARCH_CPU_64_BITS) |
| OLD | NEW |