Lines Matching full:stack

3 /*--- Stack management.                                 m_stacks.c ---*/
45 The stack
47 The stack's segment seems to be dynamically extended downwards by
48 the kernel as the stack pointer moves down. Initially, a 1-page
49 (4k) stack is allocated. When SP moves below that for the first
52 upwards to the current valid stack. It then extends the stack
57 That means that Valgrind can't spot when the stack segment is being
59 update stack permissions around SP, so we need to spot all writes
62 The deal is: when SP is assigned a lower value, the stack is being
64 between the old stack ptr and this one, if necessary. Then mark
73 the stack. All addresses below SP - VG_STACK_REDZONE_SZB are not
82 * registered stacks. There's always at least one stack registered:
83 * the main process stack. It will be the first stack registered and
84 * so will have a stack id of 0. The user does not need to register
85 * this stack: Valgrind does it automatically right before it starts
91 Addr start; // Lowest stack byte, included.
92 Addr end; // Highest stack byte, included.
94 } Stack; typedef
96 static Stack *stacks;
97 static UWord next_id; /* Next id we hand out to a newly registered stack */
100 * These are the id, start and end values of the current stack. If the
101 * stack pointer falls outside the range of the current stack, we search
102 * the stacks list above for a matching stack.
104 static Stack *current_stack;
109 static void move_Stack_one_step_forward ( Stack* st ) in move_Stack_one_step_forward()
111 Stack *st0, *st1, *st2; in move_Stack_one_step_forward()
126 Stack* tmp; in move_Stack_one_step_forward()
148 /* Find what stack an address falls into. */
149 static Stack* find_stack_by_addr(Addr sp) in find_stack_by_addr()
154 Stack *i = stacks; in find_stack_by_addr()
178 * Register a new stack from start - end. This is invoked from the
180 * we start the client running, to register the main process stack.
184 Stack *i; in VG_()
195 i = VG_(malloc)("stacks.rs.1", sizeof(Stack)); in VG_()
206 VG_(debugLog)(2, "stacks", "register [start-end] [%p-%p] as stack %lu\n", in VG_()
213 * Deregister a stack. This is invoked from the VALGRIND_STACK_DEREGISTER
218 Stack *i = stacks; in VG_()
219 Stack *prev = NULL; in VG_()
221 VG_(debugLog)(2, "stacks", "deregister stack %lu\n", id); in VG_()
243 * Change a stack. This is invoked from the VALGRIND_STACK_CHANGE client
244 * request and from the stack growth stuff the signals module when
245 * extending the main process stack.
249 Stack *i = stacks; in VG_()
254 "change stack %lu from [%p-%p] to [%p-%p]\n", in VG_()
267 * Find the bounds of the stack (if any) which includes the
268 * specified stack pointer.
272 Stack* stack = find_stack_by_addr(SP); in VG_() local
275 if (LIKELY(stack)) { in VG_()
276 *start = stack->start; in VG_()
277 *end = stack->end; in VG_()
281 extensible stack (normally, only the main thread has an extensible in VG_()
282 stack segment). in VG_()
284 stack for SP, and set *start and *end to 0. in VG_()
285 Otherwise, possibly reduce the stack limits using the boundaries of in VG_()
306 /* SP is in a RW segment, or in the SkResvn of an extensible stack. in VG_()
307 We can use the seg start as the stack start limit. */ in VG_()
310 "segment for SP %p changed stack start limit" in VG_()
316 /* Now, determine the stack end limit. If the stackseg is SkResvn, in VG_()
333 /* Limit the stack end limit, using the found segment. */ in VG_()
336 "segment for SP %p changed stack end limit" in VG_()
346 "stack for SP %p start %p after end %p\n", in VG_()
355 application is switching to a new stack, for whatever reason.
357 JRS 20021001: following discussions with John Regehr, if a stack
360 only remaining difficulty is knowing exactly when a stack switch is
390 // preamble + check if stack has switched.
400 /* Check if the stack pointer is still in the same stack as before. */ \
403 Stack* new_stack = find_stack_by_addr(new_SP); \
406 /* The stack pointer is now in another stack. Update the current */ \
407 /* stack information and return without doing anything else. */ \