Rémi Bernon (@rbernon) commented about dlls/ntdll/unix/signal_x86_64.c:
+#define __ASM_CFI_REG_IS_AT_OFFSET2_FROM_RCX(REG, OFFSET1, OFFSET2) \
- __ASM_CFI_REG_IS_AT_OFFSET2_FROM_BREG(REG, __ASM_CFI_DW_OP_breg2, OFFSET1, OFFSET2)
+#define __ASM_CFI_REG_IS_AT_OFFSET1_FROM_RCX(REG, OFFSET) \
- __ASM_CFI_REG_IS_AT_OFFSET1_FROM_BREG(REG, __ASM_CFI_DW_OP_breg2, OFFSET)
+#define __ASM_CFI_CFA_IS_AT_OFFSET_FROM_RBP(OFFSET) \
- __ASM_CFI_CFA_IS_AT_OFFSET1_FROM_BREG(__ASM_CFI_DW_OP_breg6, OFFSET)
+#define __ASM_CFI_CFA_IS_AT_OFFSET_FROM_RSP(OFFSET) \
- __ASM_CFI_CFA_IS_AT_OFFSET1_FROM_BREG(__ASM_CFI_DW_OP_breg7, OFFSET)
+#define __ASM_CFI_CFA_IS_AT_OFFSET_FROM_RCX(OFFSET1, OFFSET2) \
- __ASM_CFI_CFA_IS_AT_OFFSET2_FROM_BREG(__ASM_CFI_DW_OP_breg2, OFFSET1, OFFSET2)
What about something simpler like, 1) #define the `DW_` constants above in the file instead of the enums, and 2) re-use them here in the expressions, with something like:
```c #define DW_OP_rcx DW_OP_breg2 #define DW_OP_rbp DW_OP_breg6 #define DW_OP_rsp DW_OP_breg7
#define DW_REG_rbx 0x03 #define DW_REG_rsi 0x04 #define DW_REG_rdi 0x05 #define DW_REG_rbp 0x06 #define DW_REG_rsp 0x07 #define DW_REG_r12 0x0c #define DW_REG_r13 0x0d #define DW_REG_r14 0x0e #define DW_REG_r15 0x0f #define DW_REG_rip 0x10
#define __ASM_CFI_STR(...) #__VA_ARGS__ #define __ASM_CFI_ESC(...) __ASM_CFI(".cfi_escape " __ASM_CFI_STR(__VA_ARGS__) "\n\t") #define __ASM_CFI_CFA_IS_AT(base, lo, hi) __ASM_CFI_ESC(DW_CFA_def_cfa_expression, 0x04, DW_OP_ ## base, lo, hi, DW_OP_deref) #define __ASM_CFI_REG_IS_AT(reg, base, lo, hi) __ASM_CFI_ESC(DW_CFA_expression, DW_REG_ ## reg, 0x03, DW_OP_ ## base, lo, hi) ```
And use that below as `__ASM_CFI_CFA_IS_AT(rcx,0x88,0x01)`, `__ASM_CFI_REG_IS_AT(rip,rcx,0xf0,0x00)`, etc...
I think using two bytes offsets everywhere simplifies the macros, although we'll need a bit more offset mangling by hand to encode them.