Skip to content

Commit

Permalink
Reland [PPC64] Port to ppc64le - initial version
Browse files Browse the repository at this point in the history
Initial working version of libunwind for PowerPC 64. Tested on
little-endian ppc64 host only.
Based on the existing PowerPC 32 code.

It supports:

- context save/restore (unw_getcontext, unw_init_local, unw_resume)
- read/write from/to saved registers
- backtrace (unw_step)

Patch by Leandro Lupori!

Differential Revision: https://reviews.llvm.org/D41386

Now builds with LIBUNWIND_ENABLE_CROSS_UNWINDING=ON should
work.

llvm-svn: 321680
  • Loading branch information
mstorsjo committed Jan 2, 2018
1 parent ecf9054 commit 7c90706
Show file tree
Hide file tree
Showing 10 changed files with 931 additions and 5 deletions.
11 changes: 9 additions & 2 deletions libunwind/include/__libunwind_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#define _LIBUNWIND_HIGHEST_DWARF_REGISTER_X86 8
#define _LIBUNWIND_HIGHEST_DWARF_REGISTER_X86_64 32
#define _LIBUNWIND_HIGHEST_DWARF_REGISTER_PPC 112
#define _LIBUNWIND_HIGHEST_DWARF_REGISTER_PPC64 110
#define _LIBUNWIND_HIGHEST_DWARF_REGISTER_ARM64 95
#define _LIBUNWIND_HIGHEST_DWARF_REGISTER_ARM 287
#define _LIBUNWIND_HIGHEST_DWARF_REGISTER_OR1K 31
Expand All @@ -39,6 +40,11 @@
# define _LIBUNWIND_CURSOR_SIZE 33
# endif
# define _LIBUNWIND_HIGHEST_DWARF_REGISTER _LIBUNWIND_HIGHEST_DWARF_REGISTER_X86_64
# elif defined(__powerpc64__)
# define _LIBUNWIND_TARGET_PPC64 1
# define _LIBUNWIND_CONTEXT_SIZE 136
# define _LIBUNWIND_CURSOR_SIZE 148
# define _LIBUNWIND_HIGHEST_DWARF_REGISTER _LIBUNWIND_HIGHEST_DWARF_REGISTER_PPC64
# elif defined(__ppc__)
# define _LIBUNWIND_TARGET_PPC 1
# define _LIBUNWIND_CONTEXT_SIZE 117
Expand Down Expand Up @@ -84,13 +90,14 @@
# define _LIBUNWIND_TARGET_I386
# define _LIBUNWIND_TARGET_X86_64 1
# define _LIBUNWIND_TARGET_PPC 1
# define _LIBUNWIND_TARGET_PPC64 1
# define _LIBUNWIND_TARGET_AARCH64 1
# define _LIBUNWIND_TARGET_ARM 1
# define _LIBUNWIND_TARGET_OR1K 1
# define _LIBUNWIND_TARGET_MIPS_O32 1
# define _LIBUNWIND_TARGET_MIPS_N64 1
# define _LIBUNWIND_CONTEXT_SIZE 128
# define _LIBUNWIND_CURSOR_SIZE 140
# define _LIBUNWIND_CONTEXT_SIZE 136
# define _LIBUNWIND_CURSOR_SIZE 148
# define _LIBUNWIND_HIGHEST_DWARF_REGISTER 287
#endif // _LIBUNWIND_IS_NATIVE_ONLY

Expand Down
114 changes: 114 additions & 0 deletions libunwind/include/libunwind.h
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,120 @@ enum {
UNW_PPC_SPEFSCR = 112
};

// 64-bit ppc register numbers
enum {
UNW_PPC64_R0 = 0,
UNW_PPC64_R1 = 1,
UNW_PPC64_R2 = 2,
UNW_PPC64_R3 = 3,
UNW_PPC64_R4 = 4,
UNW_PPC64_R5 = 5,
UNW_PPC64_R6 = 6,
UNW_PPC64_R7 = 7,
UNW_PPC64_R8 = 8,
UNW_PPC64_R9 = 9,
UNW_PPC64_R10 = 10,
UNW_PPC64_R11 = 11,
UNW_PPC64_R12 = 12,
UNW_PPC64_R13 = 13,
UNW_PPC64_R14 = 14,
UNW_PPC64_R15 = 15,
UNW_PPC64_R16 = 16,
UNW_PPC64_R17 = 17,
UNW_PPC64_R18 = 18,
UNW_PPC64_R19 = 19,
UNW_PPC64_R20 = 20,
UNW_PPC64_R21 = 21,
UNW_PPC64_R22 = 22,
UNW_PPC64_R23 = 23,
UNW_PPC64_R24 = 24,
UNW_PPC64_R25 = 25,
UNW_PPC64_R26 = 26,
UNW_PPC64_R27 = 27,
UNW_PPC64_R28 = 28,
UNW_PPC64_R29 = 29,
UNW_PPC64_R30 = 30,
UNW_PPC64_R31 = 31,
UNW_PPC64_F0 = 32,
UNW_PPC64_F1 = 33,
UNW_PPC64_F2 = 34,
UNW_PPC64_F3 = 35,
UNW_PPC64_F4 = 36,
UNW_PPC64_F5 = 37,
UNW_PPC64_F6 = 38,
UNW_PPC64_F7 = 39,
UNW_PPC64_F8 = 40,
UNW_PPC64_F9 = 41,
UNW_PPC64_F10 = 42,
UNW_PPC64_F11 = 43,
UNW_PPC64_F12 = 44,
UNW_PPC64_F13 = 45,
UNW_PPC64_F14 = 46,
UNW_PPC64_F15 = 47,
UNW_PPC64_F16 = 48,
UNW_PPC64_F17 = 49,
UNW_PPC64_F18 = 50,
UNW_PPC64_F19 = 51,
UNW_PPC64_F20 = 52,
UNW_PPC64_F21 = 53,
UNW_PPC64_F22 = 54,
UNW_PPC64_F23 = 55,
UNW_PPC64_F24 = 56,
UNW_PPC64_F25 = 57,
UNW_PPC64_F26 = 58,
UNW_PPC64_F27 = 59,
UNW_PPC64_F28 = 60,
UNW_PPC64_F29 = 61,
UNW_PPC64_F30 = 62,
UNW_PPC64_F31 = 63,
UNW_PPC64_LR = 64,
UNW_PPC64_CTR = 65,
UNW_PPC64_CR0 = 66,
UNW_PPC64_CR1 = 67,
UNW_PPC64_CR2 = 68,
UNW_PPC64_CR3 = 69,
UNW_PPC64_CR4 = 70,
UNW_PPC64_CR5 = 71,
UNW_PPC64_CR6 = 72,
UNW_PPC64_CR7 = 73,
UNW_PPC64_XER = 74,
UNW_PPC64_V0 = 75,
UNW_PPC64_V1 = 76,
UNW_PPC64_V2 = 77,
UNW_PPC64_V3 = 78,
UNW_PPC64_V4 = 79,
UNW_PPC64_V5 = 80,
UNW_PPC64_V6 = 81,
UNW_PPC64_V7 = 82,
UNW_PPC64_V8 = 83,
UNW_PPC64_V9 = 84,
UNW_PPC64_V10 = 85,
UNW_PPC64_V11 = 86,
UNW_PPC64_V12 = 87,
UNW_PPC64_V13 = 88,
UNW_PPC64_V14 = 89,
UNW_PPC64_V15 = 90,
UNW_PPC64_V16 = 91,
UNW_PPC64_V17 = 92,
UNW_PPC64_V18 = 93,
UNW_PPC64_V19 = 94,
UNW_PPC64_V20 = 95,
UNW_PPC64_V21 = 96,
UNW_PPC64_V22 = 97,
UNW_PPC64_V23 = 98,
UNW_PPC64_V24 = 99,
UNW_PPC64_V25 = 100,
UNW_PPC64_V26 = 101,
UNW_PPC64_V27 = 102,
UNW_PPC64_V28 = 103,
UNW_PPC64_V29 = 104,
UNW_PPC64_V30 = 105,
UNW_PPC64_V31 = 106,
UNW_PPC64_VRSAVE = 107,
UNW_PPC64_VSCR = 108,
UNW_PPC64_FPSCR = 109
};

// 64-bit ARM64 registers
enum {
UNW_ARM64_X0 = 0,
Expand Down
7 changes: 7 additions & 0 deletions libunwind/src/AddressSpace.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -697,6 +697,13 @@ struct unw_addr_space_ppc : public unw_addr_space {
RemoteAddressSpace<Pointer32<BigEndian>> oas;
};

/// unw_addr_space_ppc is the concrete instance that a unw_addr_space_t points
/// to when examining a 64-bit PowerPC process.
struct unw_addr_space_ppc64 : public unw_addr_space {
unw_addr_space_ppc64(task_t task) : oas(task) {}
RemoteAddressSpace<Pointer64<LittleEndian>> oas;
};

#endif // UNW_REMOTE

} // namespace libunwind
Expand Down
Loading

0 comments on commit 7c90706

Please sign in to comment.