Commit e7ad2039 by Eric Botcazou Committed by Arnaud Charlet

tracebak.c (FRAME_OFFSET): Add parameter FP.

2007-04-20  Eric Botcazou  <ebotcazou@adacore.com>

	* tracebak.c (FRAME_OFFSET): Add parameter FP. On SPARC/Solaris, do not
	add the stack bias if the offset is computed from a frame address.
	(__gnat_backtrace): Adjust for above change.

From-SVN: r125472
parent c956c1be
...@@ -34,6 +34,7 @@ ...@@ -34,6 +34,7 @@
functions. functions.
It has been tested on the following configurations: It has been tested on the following configurations:
PowerPC/AiX PowerPC/AiX
PowerPC/Darwin
PowerPC/VxWorks PowerPC/VxWorks
SPARC/Solaris SPARC/Solaris
i386/GNU/Linux i386/GNU/Linux
...@@ -115,7 +116,7 @@ extern void (*Unlock_Task) (void); ...@@ -115,7 +116,7 @@ extern void (*Unlock_Task) (void);
we store in the tracebacks array. The latter allows us to loop over the we store in the tracebacks array. The latter allows us to loop over the
successive frames in the chain. successive frames in the chain.
To initiate the process, we retrieve an initial frame pointer using the To initiate the process, we retrieve an initial frame address using the
appropriate GCC builtin (__builtin_frame_address). appropriate GCC builtin (__builtin_frame_address).
This scheme is unfortunately not applicable on every target because the This scheme is unfortunately not applicable on every target because the
...@@ -125,8 +126,8 @@ extern void (*Unlock_Task) (void); ...@@ -125,8 +126,8 @@ extern void (*Unlock_Task) (void);
o struct layout, describing the expected stack data layout relevant to the o struct layout, describing the expected stack data layout relevant to the
information we are interested in, information we are interested in,
o FRAME_OFFSET, the offset, from a given frame pointer, at which this o FRAME_OFFSET, the offset, from a given frame address or frame pointer
layout will be found, value, at which this layout will be found,
o FRAME_LEVEL, controls how many frames up we get at to start with, o FRAME_LEVEL, controls how many frames up we get at to start with,
from the initial frame pointer we compute by way of the GCC builtin, from the initial frame pointer we compute by way of the GCC builtin,
...@@ -205,7 +206,7 @@ struct layout ...@@ -205,7 +206,7 @@ struct layout
void *return_address; void *return_address;
}; };
#define FRAME_OFFSET 0 #define FRAME_OFFSET(FP) 0
#define PC_ADJUST -4 #define PC_ADJUST -4
#define STOP_FRAME(CURRENT, TOP_STACK) ((void *) (CURRENT) < (TOP_STACK)) #define STOP_FRAME(CURRENT, TOP_STACK) ((void *) (CURRENT) < (TOP_STACK))
...@@ -237,7 +238,7 @@ struct layout ...@@ -237,7 +238,7 @@ struct layout
#define FRAME_LEVEL 1 #define FRAME_LEVEL 1
/* See the PPC AIX case for an explanation of these values. */ /* See the PPC AIX case for an explanation of these values. */
#define FRAME_OFFSET 0 #define FRAME_OFFSET(FP) 0
#define PC_ADJUST -4 #define PC_ADJUST -4
#define STOP_FRAME(CURRENT, TOP_STACK) ((CURRENT)->next == 0) #define STOP_FRAME(CURRENT, TOP_STACK) ((CURRENT)->next == 0)
...@@ -265,13 +266,13 @@ struct layout ...@@ -265,13 +266,13 @@ struct layout
#endif #endif
#define FRAME_LEVEL 0 #define FRAME_LEVEL 0
#define FRAME_OFFSET (14 * sizeof (void*) + STACK_BIAS) #define FRAME_OFFSET(FP) (14 * sizeof (void*) + (FP ? STACK_BIAS : 0))
#define PC_ADJUST 0 #define PC_ADJUST 0
#define STOP_FRAME(CURRENT, TOP_STACK) \ #define STOP_FRAME(CURRENT, TOP_STACK) \
((CURRENT)->return_address == 0|| (CURRENT)->next == 0 \ ((CURRENT)->return_address == 0|| (CURRENT)->next == 0 \
|| (void *) (CURRENT) < (TOP_STACK)) || (void *) (CURRENT) < (TOP_STACK))
/* The sparc register windows need to be flushed before we may access them /* The SPARC register windows need to be flushed before we may access them
from the stack. This is achieved by way of builtin_frame_address only from the stack. This is achieved by way of builtin_frame_address only
when the "count" argument is positive, so force at least one such call. */ when the "count" argument is positive, so force at least one such call. */
#define FETCH_UP_FRAME_ADDRESS #define FETCH_UP_FRAME_ADDRESS
...@@ -306,7 +307,7 @@ struct layout ...@@ -306,7 +307,7 @@ struct layout
return the soft stack pointer, which does not designate a location where a return the soft stack pointer, which does not designate a location where a
backchain and a return address might be found. */ backchain and a return address might be found. */
#define FRAME_OFFSET 0 #define FRAME_OFFSET(FP) 0
#define PC_ADJUST -2 #define PC_ADJUST -2
#define STOP_FRAME(CURRENT, TOP_STACK) \ #define STOP_FRAME(CURRENT, TOP_STACK) \
(IS_BAD_PTR((long)(CURRENT)->return_address) \ (IS_BAD_PTR((long)(CURRENT)->return_address) \
...@@ -432,7 +433,7 @@ __gnat_backtrace (void **array, ...@@ -432,7 +433,7 @@ __gnat_backtrace (void **array,
forced_callee (); forced_callee ();
/* Force a call to builtin_frame_address with a positive argument /* Force a call to builtin_frame_address with a positive argument
if required. This is necessary e.g. on sparc to have the register if required. This is necessary e.g. on SPARC to have the register
windows flushed before we attempt to access them on the stack. */ windows flushed before we attempt to access them on the stack. */
#if defined (FETCH_UP_FRAME_ADDRESS) && (FRAME_LEVEL == 0) #if defined (FETCH_UP_FRAME_ADDRESS) && (FRAME_LEVEL == 0)
__builtin_frame_address (1); __builtin_frame_address (1);
...@@ -440,7 +441,7 @@ __gnat_backtrace (void **array, ...@@ -440,7 +441,7 @@ __gnat_backtrace (void **array,
top_frame = __builtin_frame_address (FRAME_LEVEL); top_frame = __builtin_frame_address (FRAME_LEVEL);
top_stack = CURRENT_STACK_FRAME; top_stack = CURRENT_STACK_FRAME;
current = (struct layout *) ((size_t) top_frame + FRAME_OFFSET); current = (struct layout *) ((size_t) top_frame + FRAME_OFFSET (0));
/* Skip the number of calls we have been requested to skip, accounting for /* Skip the number of calls we have been requested to skip, accounting for
the BASE_SKIP parameter. the BASE_SKIP parameter.
...@@ -453,7 +454,7 @@ __gnat_backtrace (void **array, ...@@ -453,7 +454,7 @@ __gnat_backtrace (void **array,
while (cnt < skip_frames) while (cnt < skip_frames)
{ {
current = (struct layout *) ((size_t) current->next + FRAME_OFFSET); current = (struct layout *) ((size_t) current->next + FRAME_OFFSET (1));
cnt++; cnt++;
} }
...@@ -468,7 +469,7 @@ __gnat_backtrace (void **array, ...@@ -468,7 +469,7 @@ __gnat_backtrace (void **array,
|| current->return_address > exclude_max) || current->return_address > exclude_max)
array[cnt++] = current->return_address + PC_ADJUST; array[cnt++] = current->return_address + PC_ADJUST;
current = (struct layout *) ((size_t) current->next + FRAME_OFFSET); current = (struct layout *) ((size_t) current->next + FRAME_OFFSET (1));
} }
return cnt; return cnt;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment