libunwind: fix X86 register numbers for FreeBSD/i386
authorEd Maste <emaste@freebsd.org>
Tue, 30 Aug 2016 15:10:08 +0000 (15:10 +0000)
committerEd Maste <emaste@freebsd.org>
Tue, 30 Aug 2016 15:10:08 +0000 (15:10 +0000)
For historical reasons i386 has ebp and esp swapped in the eh_frame
register numbering on at least Darwin.  That is:

                 Darwin      FreeBSD
        Reg #    eh_frame    eh_frame    DWARF
        =====    ========    ========    =====
          4        ebp         esp        esp
          5        esp         ebp        ebp

Although the UNW_X86_* constants are not intended to be coupled with
DWARF / eh_frame numbering they are currently conflated in libunwind.

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

llvm-svn: 280099

libunwind/include/libunwind.h

index bda561a..3233bfb 100644 (file)
@@ -151,8 +151,13 @@ enum {
   UNW_X86_ECX = 1,
   UNW_X86_EDX = 2,
   UNW_X86_EBX = 3,
+#ifdef __FreeBSD__
+  UNW_X86_ESP = 4,
+  UNW_X86_EBP = 5,
+#else
   UNW_X86_EBP = 4,
   UNW_X86_ESP = 5,
+#endif
   UNW_X86_ESI = 6,
   UNW_X86_EDI = 7
 };