Fix dwarf register mapping on darwin/x86.
authorZoltan Varga <vargaz@gmail.com>
Sun, 30 Sep 2012 01:14:38 +0000 (03:14 +0200)
committerZoltan Varga <vargaz@gmail.com>
Sun, 30 Sep 2012 01:14:38 +0000 (03:14 +0200)
mono/mini/unwind.c

index 11caa60166c115018f96ac558e85ac15bbdab1c2..2377e0dd009b5e970a01d2732dc2584f943e4458 100644 (file)
@@ -54,7 +54,16 @@ static int map_hw_reg_to_dwarf_reg [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
 #define DWARF_DATA_ALIGN (-4)
 #define DWARF_PC_REG (mono_hw_reg_to_dwarf_reg (ARMREG_LR))
 #elif defined (TARGET_X86)
+#ifdef __APPLE__
+/*
+ * LLVM seems to generate unwind info where esp is encoded as 5, and ebp as 4, ie see this line:
+ *   def ESP : RegisterWithSubRegs<"esp", [SP]>, DwarfRegNum<[-2, 5, 4]>;
+ * in lib/Target/X86/X86RegisterInfo.td in the llvm sources.
+ */
+static int map_hw_reg_to_dwarf_reg [] = { 0, 1, 2, 3, 5, 4, 6, 7, 8 };
+#else
 static int map_hw_reg_to_dwarf_reg [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8 };
+#endif
 /* + 1 is for IP */
 #define NUM_REGS X86_NREG + 1
 #define DWARF_DATA_ALIGN (-4)