• Home
  • Raw
  • Download

Lines Matching full:stack

3 /*--- Stack management.                                 m_stacks.c ---*/
49 The stack
51 The stack's segment seems to be dynamically extended downwards by
52 the kernel as the stack pointer moves down. Initially, a 1-page
53 (4k) stack is allocated. When SP moves below that for the first
56 upwards to the current valid stack. It then extends the stack
61 That means that Valgrind can't spot when the stack segment is being
63 update stack permissions around SP, so we need to spot all writes
66 The deal is: when SP is assigned a lower value, the stack is being
68 between the old stack ptr and this one, if necessary. Then mark
77 the stack. All addresses below SP - VG_STACK_REDZONE_SZB are not
86 * registered stacks. There's always at least one stack registered:
87 * the main process stack. It will be the first stack registered and
88 * so will have a stack id of 0. The user does not need to register
89 * this stack: Valgrind does it automatically right before it starts
95 Addr start; // Lowest stack byte, included.
96 Addr end; // Highest stack byte, included.
98 UWord outer_id; /* For an inner valgrind, stack id registered in outer
100 } Stack; typedef
102 static Stack *stacks;
103 static UWord next_id; /* Next id we hand out to a newly registered stack */
106 * These are the id, start and end values of the current stack. If the
107 * stack pointer falls outside the range of the current stack, we search
108 * the stacks list above for a matching stack.
110 static Stack *current_stack;
115 static void move_Stack_one_step_forward ( Stack* st ) in move_Stack_one_step_forward()
117 Stack *st0, *st1, *st2; in move_Stack_one_step_forward()
132 Stack* tmp; in move_Stack_one_step_forward()
154 /* Find what stack an address falls into. */
155 static Stack* find_stack_by_addr(Addr sp) in find_stack_by_addr()
160 Stack *i = stacks; in find_stack_by_addr()
184 * Register a new stack from start - end. This is invoked from the
186 * we start the client running, to register the main process stack.
190 Stack *i; in VG_()
201 i = VG_(malloc)("stacks.rs.1", sizeof(Stack)); in VG_()
212 VG_(debugLog)(2, "stacks", "register [start-end] [%p-%p] as stack %lu\n", in VG_()
219 * Deregister a stack. This is invoked from the VALGRIND_STACK_DEREGISTER
224 Stack *i = stacks; in VG_()
225 Stack *prev = NULL; in VG_()
227 VG_(debugLog)(2, "stacks", "deregister stack %lu\n", id); in VG_()
250 * Change a stack. This is invoked from the VALGRIND_STACK_CHANGE client
251 * request and from the stack growth stuff the signals module when
252 * extending the main process stack.
256 Stack *i = stacks; in VG_()
261 "change stack %lu from [%p-%p] to [%p-%p]\n", in VG_()
275 * Find the bounds of the stack (if any) which includes the
276 * specified stack pointer.
280 Stack* stack = find_stack_by_addr(SP); in VG_() local
283 if (LIKELY(stack)) { in VG_()
284 *start = stack->start; in VG_()
285 *end = stack->end; in VG_()
289 extensible stack (normally, only the main thread has an extensible in VG_()
290 stack segment). in VG_()
292 stack for SP, and set *start and *end to 0. in VG_()
293 Otherwise, possibly reduce the stack limits using the boundaries of in VG_()
314 /* SP is in a RW segment, or in the SkResvn of an extensible stack. in VG_()
315 We can use the seg start as the stack start limit. */ in VG_()
318 "segment for SP %p changed stack start limit" in VG_()
324 /* Now, determine the stack end limit. If the stackseg is SkResvn, in VG_()
341 /* Limit the stack end limit, using the found segment. */ in VG_()
344 "segment for SP %p changed stack end limit" in VG_()
354 "stack for SP %p start %p after end %p\n", in VG_()
363 application is switching to a new stack, for whatever reason.
365 JRS 20021001: following discussions with John Regehr, if a stack
368 only remaining difficulty is knowing exactly when a stack switch is
398 // preamble + check if stack has switched.
408 /* Check if the stack pointer is still in the same stack as before. */ \
411 Stack* new_stack = find_stack_by_addr(new_SP); \
414 /* The stack pointer is now in another stack. Update the current */ \
415 /* stack information and return without doing anything else. */ \