Skip to content

Commit

Permalink
Improve debug information for ppc64 architecture
Browse files Browse the repository at this point in the history
  • Loading branch information
gut committed Jul 23, 2015
1 parent d87b844 commit e98cf20
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 0 deletions.
38 changes: 38 additions & 0 deletions hphp/runtime/vm/debug/dwarf.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,43 @@ namespace Debug {

using jit::TCA;

#if !defined(__powerpc64__)
typedef enum {
R0,
SP,
TOC,
R3,
R4,
R5,
R6,
R7,
R8,
R9,
R10,
R11,
R12,
TLS,
R14,
R15,
R16,
R17,
R18,
R19,
R20,
R21,
R22,
R23,
R24,
R25,
R26,
R27,
R28,
R29,
R30,
R31,
LR = 65
} ppc64_regnum_t;
#else
typedef enum {
RAX,
RDX,
Expand All @@ -50,6 +87,7 @@ typedef enum {
R15,
RIP
} x86_64_regnum_t;
#endif

const int DWARF_CODE_ALIGN = 1;
const int DWARF_DATA_ALIGN = 8;
Expand Down
12 changes: 12 additions & 0 deletions hphp/runtime/vm/debug/elfwriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,12 @@ namespace HPHP {
namespace Debug {

TRACE_SET_MOD(debuginfo);

#if !defined(__powerpc64__)
static const uint8_t CFA_OFFSET = 8;
#else
static const uint8_t CFA_OFFSET = 16;
#endif

void ElfWriter::logError(const std::string& msg) {
perror("");
Expand Down Expand Up @@ -415,6 +420,12 @@ bool ElfWriter::addFrameInfo(DwarfChunk* d) {
b.clear();
/* Define common set of rules for unwinding frames in the VM stack*/

#if !defined(__powerpc64__)
/* Frame pointer (CFA) for previous frame is in SP */
b.dwarf_cfa_def_cfa(SP, 0);
/* Previous LR is at CFA - 2 . DWARF_DATA_ALIGN (8) */
b.dwarf_cfa_offset_extended_sf(LR, -2);
#else
/* Frame pointer (CFA) for previous frame is in RBP + 16 */
b.dwarf_cfa_def_cfa(RBP, CFA_OFFSET);
/* Previous RIP is at CFA - 1 . DWARF_DATA_ALIGN (8) */
Expand All @@ -431,6 +442,7 @@ bool ElfWriter::addFrameInfo(DwarfChunk* d) {
* to change.
*/
b.dwarf_cfa_same_value(RSP);
#endif

/* register above rules in a CIE (common information entry) */
Dwarf_Signed cie_index = dwarf_add_frame_cie(
Expand Down

0 comments on commit e98cf20

Please sign in to comment.