-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Fix reporting of callee saved registers with nongnu libuwind #527
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -173,28 +173,8 @@ typedef INT64 StackElemType; | |
// This represents some of the TransitionFrame fields that are | ||
// stored at negative offsets. | ||
//-------------------------------------------------------------------- | ||
typedef DPTR(struct CalleeSavedRegisters) PTR_CalleeSavedRegisters; | ||
struct CalleeSavedRegisters { | ||
#ifndef UNIX_AMD64_ABI | ||
INT_PTR rdi; | ||
INT_PTR rsi; | ||
INT_PTR rbx; | ||
INT_PTR rbp; | ||
#endif | ||
INT_PTR r12; | ||
INT_PTR r13; | ||
INT_PTR r14; | ||
INT_PTR r15; | ||
#ifdef UNIX_AMD64_ABI | ||
INT_PTR rbx; | ||
INT_PTR rbp; | ||
#endif | ||
}; | ||
|
||
struct REGDISPLAY; | ||
|
||
void UpdateRegDisplayFromCalleeSavedRegisters(REGDISPLAY * pRD, CalleeSavedRegisters * pRegs); | ||
|
||
//-------------------------------------------------------------------- | ||
// This represents the arguments that are stored in volatile registers. | ||
// This should not overlap the CalleeSavedRegisters since those are already | ||
|
@@ -215,6 +195,18 @@ void UpdateRegDisplayFromCalleeSavedRegisters(REGDISPLAY * pRD, CalleeSavedRegis | |
|
||
#define NUM_ARGUMENT_REGISTERS 6 | ||
|
||
// The order of registers in this macro is hardcoded in assembly code | ||
// at number of places | ||
#define ENUM_CALLEE_SAVED_REGISTERS() \ | ||
CALLEE_SAVED_REGISTER(R12) \ | ||
CALLEE_SAVED_REGISTER(R13) \ | ||
CALLEE_SAVED_REGISTER(R14) \ | ||
CALLEE_SAVED_REGISTER(R15) \ | ||
CALLEE_SAVED_REGISTER(Rbx) \ | ||
CALLEE_SAVED_REGISTER(Rbp) | ||
|
||
#define NUM_CALLEE_SAVED_REGISTERS 6 | ||
|
||
#else // UNIX_AMD64_ABI | ||
|
||
#define ENUM_ARGUMENT_REGISTERS() \ | ||
|
@@ -225,6 +217,20 @@ void UpdateRegDisplayFromCalleeSavedRegisters(REGDISPLAY * pRD, CalleeSavedRegis | |
|
||
#define NUM_ARGUMENT_REGISTERS 4 | ||
|
||
// The order of registers in this macro is hardcoded in assembly code | ||
// at number of places | ||
#define ENUM_CALLEE_SAVED_REGISTERS() \ | ||
CALLEE_SAVED_REGISTER(Rdi) \ | ||
CALLEE_SAVED_REGISTER(Rsi) \ | ||
CALLEE_SAVED_REGISTER(Rbx) \ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there a reason why the order of registers is different between Windows (..., rbx, rbp, r12, r13, r14, r15) and Unix (r12, r13, r14, r15, rbx, rbp)? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This order is hardcoded in assembly code at number of places, not just the places I am changing. I have added comment about it. The order on Windows is what it used to be for a long time - not worth it to rock the boat to "fix it". We need RBP to be last on Unix to erect proper RBP frames. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thank you for the explanation! I agree, it is not worth changing it. |
||
CALLEE_SAVED_REGISTER(Rbp) \ | ||
CALLEE_SAVED_REGISTER(R12) \ | ||
CALLEE_SAVED_REGISTER(R13) \ | ||
CALLEE_SAVED_REGISTER(R14) \ | ||
CALLEE_SAVED_REGISTER(R15) | ||
|
||
#define NUM_CALLEE_SAVED_REGISTERS 8 | ||
|
||
#endif // UNIX_AMD64_ABI | ||
|
||
typedef DPTR(struct ArgumentRegisters) PTR_ArgumentRegisters; | ||
|
@@ -234,6 +240,19 @@ struct ArgumentRegisters { | |
#undef ARGUMENT_REGISTER | ||
}; | ||
|
||
typedef DPTR(struct CalleeSavedRegisters) PTR_CalleeSavedRegisters; | ||
struct CalleeSavedRegisters { | ||
#define CALLEE_SAVED_REGISTER(regname) INT_PTR regname; | ||
ENUM_CALLEE_SAVED_REGISTERS(); | ||
#undef CALLEE_SAVED_REGISTER | ||
}; | ||
|
||
struct CalleeSavedRegistersPointers { | ||
#define CALLEE_SAVED_REGISTER(regname) PTR_TADDR p##regname; | ||
ENUM_CALLEE_SAVED_REGISTERS(); | ||
#undef CALLEE_SAVED_REGISTER | ||
}; | ||
|
||
#define SCRATCH_REGISTER_X86REG kRAX | ||
|
||
#ifdef UNIX_AMD64_ABI | ||
|
@@ -254,6 +273,9 @@ struct FloatArgumentRegisters { | |
#endif | ||
|
||
|
||
void UpdateRegDisplayFromCalleeSavedRegisters(REGDISPLAY * pRD, CalleeSavedRegisters * pRegs); | ||
|
||
|
||
// Sufficient context for Try/Catch restoration. | ||
struct EHContext { | ||
// Not used | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please add a comment saying that the order of registers here must match the index of the register that is passed into RestoreReg macro?