brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.1 KiB · d93b7cd Raw
32 lines · cpp
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-exception6//7//===----------------------------------------------------------------------===//8 9#include "CrashReason.h"10 11#include "lldb/Target/UnixSignals.h"12 13std::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#else20  std::optional<lldb::addr_t> lower;21  std::optional<lldb::addr_t> upper;22#endif23 24  std::string description =25      lldb_private::UnixSignals::CreateForHost()->GetSignalDescription(26          info.si_signo, info.si_code,27          reinterpret_cast<uintptr_t>(info.si_addr), lower, upper);28  assert(description.size() && "unexpected signal");29 30  return "signal " + description;31}32