OSDN Git Service

2005-06-14 Doug Rupp <rupp@adacore.com>
[pf3gnuchains/gcc-fork.git] / gcc / ada / tracebak.c
index 83d51cc..ddeec9a 100644 (file)
@@ -6,7 +6,7 @@
  *                                                                          *
  *                          C Implementation File                           *
  *                                                                          *
- *           Copyright (C) 2000-2004 Ada Core Technologies, Inc.            *
+ *           Copyright (C) 2000-2005 Ada Core Technologies, Inc.            *
  *                                                                          *
  * GNAT is free software;  you can  redistribute it  and/or modify it under *
  * terms of the  GNU General Public License as published  by the Free Soft- *
@@ -191,9 +191,9 @@ extern void (*Unlock_Task) (void);
 
   */
 
-/*------------------------------ PPC AIX -------------------------------*/
+/*--------------------------- PPC AIX/Darwin ----------------------------*/
 
-#if defined (_AIX)
+#if (defined (__ppc__) && ((defined (_AIX) || defined (__APPLE__))))
 
 #define USE_GENERIC_UNWINDER
 
@@ -212,7 +212,7 @@ struct layout
    function is located in it's caller's frame, and the save operation only
    takes place if the function performs a call.
 
-   To have __gnat_backtrace retrieve it's own return address, we then
+   To have __gnat_backtrace retrieve its own return address, we then
    define ... */
 
 #define FORCE_CALL
@@ -242,7 +242,7 @@ struct layout
 
 #define BASE_SKIP 1
 
-/*-------------------------- Sparc Solaris -----------------------------*/
+/*-------------------------- SPARC Solaris -----------------------------*/
 
 #elif defined (sun) && defined (sparc)
 
@@ -257,8 +257,14 @@ struct layout
   void *return_address;
 };
 
+#ifdef __arch64__
+#define STACK_BIAS 2047 /* V9 ABI */
+#else
+#define STACK_BIAS 0    /* V8 ABI */
+#endif
+
 #define FRAME_LEVEL 0
-#define FRAME_OFFSET (14 * (sizeof (void*)))
+#define FRAME_OFFSET (14 * sizeof (void*) + STACK_BIAS)
 #define PC_ADJUST 0
 #define STOP_FRAME(CURRENT, TOP_STACK) \
   ((CURRENT)->return_address == 0|| (CURRENT)->next == 0 \
@@ -324,12 +330,22 @@ struct layout
         || ((*((ptr) - 1) & 0xff) == 0xff) \
         || (((*(ptr) & 0xd0ff) == 0xd0ff))))
 
-/*------------------------------- mips-irix -------------------------------*/
+/*----------------------------- x86_64 ---------------------------------*/
 
-#elif defined (__mips) && defined (__sgi)
+#elif defined (__x86_64__)
 
 #define USE_GCC_UNWINDER
-#define PC_ADJUST -8
+/* The generic unwinder is not used for this target because it is based
+   on frame layout assumptions that are not reliable on this target (the
+   rbp register is very likely used for something else than storing the
+   frame pointer in optimized code). Hence, we use the GCC unwinder
+   based on DWARF 2 call frame information, although it has the drawback
+   of not being able to unwind through frames compiled without DWARF 2
+   information.
+*/
+
+#define PC_ADJUST -2
+/* The minimum size of call instructions on this architecture is 2 bytes */
 
 #endif
 
@@ -344,7 +360,7 @@ struct layout
    libgcc, and the stage1 compiler is unlikely to be linked against a post 3.3
    library.  It actually disables the support for backtraces in this compiler
    for targets defining USE_GCC_UNWINDER, which is OK since we don't use the
-   traceback capablity in the compiler anyway.
+   traceback capability in the compiler anyway.
 
    The condition is expressed the way above because we cannot reliably rely on
    any other macro from the base compiler when compiling stage1.  */