Path: blob/main/contrib/llvm-project/libunwind/src/Unwind_AIXExtras.cpp
35148 views
//===--------------------- Unwind_AIXExtras.cpp -------------------------===//1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5//6//7//===----------------------------------------------------------------------===//89// This file is only used for AIX.10#if defined(_AIX)1112#include "config.h"13#include "libunwind_ext.h"14#include <sys/debug.h>1516namespace libunwind {17// getFuncNameFromTBTable18// Get the function name from its traceback table.19char *getFuncNameFromTBTable(uintptr_t Pc, uint16_t &NameLen,20unw_word_t *Offset) {21uint32_t *p = reinterpret_cast<uint32_t *>(Pc);22*Offset = 0;2324// Keep looking forward until a word of 0 is found. The traceback25// table starts at the following word.26while (*p)27p++;28tbtable *TBTable = reinterpret_cast<tbtable *>(p + 1);2930if (!TBTable->tb.name_present)31return NULL;3233// Get to the name of the function.34p = reinterpret_cast<uint32_t *>(&TBTable->tb_ext);3536// Skip field parminfo if it exists.37if (TBTable->tb.fixedparms || TBTable->tb.floatparms)38p++;3940// If the tb_offset field exists, get the offset from the start of41// the function to pc. Skip the field.42if (TBTable->tb.has_tboff) {43unw_word_t StartIp =44reinterpret_cast<uintptr_t>(TBTable) - *p - sizeof(uint32_t);45*Offset = Pc - StartIp;46p++;47}4849// Skip field hand_mask if it exists.50if (TBTable->tb.int_hndl)51p++;5253// Skip fields ctl_info and ctl_info_disp if they exist.54if (TBTable->tb.has_ctl) {55p += 1 + *p;56}5758NameLen = *(reinterpret_cast<uint16_t *>(p));59return reinterpret_cast<char *>(p) + sizeof(uint16_t);60}61} // namespace libunwind62#endif // defined(_AIX)636465