1 | //===-- CrashReason.cpp ---------------------------------------------------===// |
---|---|
2 | // |
3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
4 | // See https://llvm.org/LICENSE.txt for license information. |
5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
6 | // |
7 | //===----------------------------------------------------------------------===// |
8 | |
9 | #include "CrashReason.h" |
10 | |
11 | #include "lldb/Target/UnixSignals.h" |
12 | |
13 | std::string GetCrashReasonString(const siginfo_t &info) { |
14 | #if defined(si_lower) && defined(si_upper) |
15 | std::optional<lldb::addr_t> lower = |
16 | reinterpret_cast<lldb::addr_t>(info.si_lower); |
17 | std::optional<lldb::addr_t> upper = |
18 | reinterpret_cast<lldb::addr_t>(info.si_upper); |
19 | #else |
20 | std::optional<lldb::addr_t> lower; |
21 | std::optional<lldb::addr_t> upper; |
22 | #endif |
23 | |
24 | std::string description = |
25 | lldb_private::UnixSignals::CreateForHost()->GetSignalDescription( |
26 | signo: info.si_signo, code: info.si_code, |
27 | addr: reinterpret_cast<uintptr_t>(info.si_addr), lower, upper); |
28 | assert(description.size() && "unexpected signal"); |
29 | |
30 | return "signal "+ description; |
31 | } |
32 |