• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2023 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #include "fault_handler.h"
18 
19 #include <sys/ucontext.h>
20 
21 #include "base/logging.h"  // For VLOG.
22 
23 extern "C" void art_quick_throw_stack_overflow();
24 extern "C" void art_quick_throw_null_pointer_exception_from_signal();
25 extern "C" void art_quick_implicit_suspend();
26 
27 // RISCV64 specific fault handler functions (or stubs if unimplemented yet).
28 
29 namespace art {
30 
GetFaultPc(siginfo_t *,void * context)31 uintptr_t FaultManager::GetFaultPc(siginfo_t*, void* context) {
32   ucontext_t* uc = reinterpret_cast<ucontext_t*>(context);
33   mcontext_t* mc = reinterpret_cast<mcontext_t*>(&uc->uc_mcontext);
34   if (mc->__gregs[REG_SP] == 0) {
35     VLOG(signals) << "Missing SP";
36     return 0u;
37   }
38   return mc->__gregs[REG_PC];
39 }
40 
GetFaultSp(void * context)41 uintptr_t FaultManager::GetFaultSp(void* context) {
42   ucontext_t* uc = reinterpret_cast<ucontext_t*>(context);
43   mcontext_t* mc = reinterpret_cast<mcontext_t*>(&uc->uc_mcontext);
44   return mc->__gregs[REG_SP];
45 }
46 
Action(int,siginfo_t *,void *)47 bool NullPointerHandler::Action(int, siginfo_t*, void*) {
48   LOG(FATAL) << "NullPointerHandler::Action is not implemented for RISC-V";
49   return false;
50 }
51 
Action(int,siginfo_t *,void *)52 bool SuspensionHandler::Action(int, siginfo_t*, void*) {
53   LOG(FATAL) << "SuspensionHandler::Action is not implemented for RISC-V";
54   return false;
55 }
56 
Action(int,siginfo_t *,void *)57 bool StackOverflowHandler::Action(int, siginfo_t*, void*) {
58   LOG(FATAL) << "StackOverflowHandler::Action is not implemented for RISC-V";
59   return false;
60 }
61 
62 }  // namespace art
63