1 //===--------------------- Unwind_AIXExtras.cpp -------------------------===//
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
8 //===----------------------------------------------------------------------===//
10 // This file is only used for AIX.
14 #include "libunwind_ext.h"
15 #include <sys/debug.h>
18 // getFuncNameFromTBTable
19 // Get the function name from its traceback table.
20 char *getFuncNameFromTBTable(uintptr_t Pc
, uint16_t &NameLen
,
22 uint32_t *p
= reinterpret_cast<uint32_t *>(Pc
);
25 // Keep looking forward until a word of 0 is found. The traceback
26 // table starts at the following word.
29 tbtable
*TBTable
= reinterpret_cast<tbtable
*>(p
+ 1);
31 if (!TBTable
->tb
.name_present
)
34 // Get to the name of the function.
35 p
= reinterpret_cast<uint32_t *>(&TBTable
->tb_ext
);
37 // Skip field parminfo if it exists.
38 if (TBTable
->tb
.fixedparms
|| TBTable
->tb
.floatparms
)
41 // If the tb_offset field exists, get the offset from the start of
42 // the function to pc. Skip the field.
43 if (TBTable
->tb
.has_tboff
) {
45 reinterpret_cast<uintptr_t>(TBTable
) - *p
- sizeof(uint32_t);
46 *Offset
= Pc
- StartIp
;
50 // Skip field hand_mask if it exists.
51 if (TBTable
->tb
.int_hndl
)
54 // Skip fields ctl_info and ctl_info_disp if they exist.
55 if (TBTable
->tb
.has_ctl
) {
59 NameLen
= *(reinterpret_cast<uint16_t *>(p
));
60 return reinterpret_cast<char *>(p
) + sizeof(uint16_t);
62 } // namespace libunwind
63 #endif // defined(_AIX)