Sponsored Content
Top Forums Programming what is stack winding and stack unwinding Post 302130667 by jim mcnamara on Tuesday 7th of August 2007 10:05:50 AM
Old 08-07-2007
Sounds a little like homework. However:
When program run, each function(data, registers, program counter, etc) is mapped onto the stack as it is called. Because the function calls other functions, they too are mapped onto the stack. This is stack winding.

Unwinding is the removal of the functions from the stack in the reverse order.
 

7 More Discussions You Might Find Interesting

1. Programming

The stack layout

I try to solve the problem https://www.unix.com/showthread.php?p=86595 use stack hack method, I am puzzled the stack layout. under vc6.0, the following code work(in release mode). #include <stdio.h> void change() { int x; int j; (&x) = 5; // if in debug mode, change to (&x) = 5;... (1 Reply)
Discussion started by: ChenMing
1 Replies

2. UNIX for Advanced & Expert Users

stack region

how can i determine that what percentage of stack region is currently is used? (i am using tru64 unix) (2 Replies)
Discussion started by: yakari
2 Replies

3. UNIX for Dummies Questions & Answers

memory stack

Hello everbody: when issuing the ulimit -a, on my tru64 machone, I get the following: root@billing4# ulimit -a time(seconds) unlimited file(blocks) unlimited data(kbytes) 10485760 stack(kbytes) 32768 memory(kbytes) 10190528 coredump(blocks) 0... (1 Reply)
Discussion started by: aladdin
1 Replies

4. Programming

Regarding stack analysis

I would like to know how I could do the following : void func(){ int a = 100; b=0; int c = a/b; } void sig_handler (int sig,siginfo_t *info,void *context){ //signal handling function //here I want to access the variables of func() } int main(){ struct sigaction *act =... (7 Replies)
Discussion started by: vpraveen84
7 Replies

5. UNIX for Dummies Questions & Answers

Kernel Stack vs User Mode Stack

Hi, I am new to the linux kernel development area. I want to know what is the difference between kernel mode stack and user mode stack? Does each process has a user mode stack and a kernel mode stack?? Or Each process has a user mode stack and there is only one kernel mode stack that is shared by... (4 Replies)
Discussion started by: saurabhkoar
4 Replies

6. Shell Programming and Scripting

Stack Trace

Hi All Thought it would be kind of fun to implement a stack trace for a shell script that calls functions within a sub shell. This is for bash under Linux and probably not portable - #! /bin/bash error_exit() { echo "=======================" echo $1 echo... (4 Replies)
Discussion started by: steadyonabix
4 Replies

7. UNIX for Dummies Questions & Answers

What happens to the stack?

Consider this bad code, edited in Windows and run via CygWin after dos2unix so be aware of any hidden "\r" charatcers... #!/bin/bash n=0 stackit() { eval $1 if then exit 0 fi n=$ echo "$n" stackit stackit } stackit stackit Run under CygWin:- AMIGA:~> cd /tmp AMIGA:/tmp>... (2 Replies)
Discussion started by: wisecracker
2 Replies
UNW_RESUME(3)						       Programming Library						     UNW_RESUME(3)

NAME
unw_resume -- resume execution in a particular stack frame SYNOPSIS
#include <libunwind.h> int unw_resume(unw_cursor_t *cp); DESCRIPTION
The unw_resume() routine resumes execution at the stack frame identified by cp. The behavior of this routine differs slightly for local and remote unwinding. For local unwinding, unw_resume() restores the machine state and then directly resumes execution in the target stack frame. Thus unw_resume() does not return in this case. Restoring the machine state normally involves restoring the ``preserved'' (callee-saved) regis- ters. However, if execution in any of the stack frames younger (more deeply nested) than the one identified by cp was interrupted by a sig- nal, then unw_resume() will restore all registers as well as the signal mask. Attempting to call unw_resume() on a cursor which identifies the stack frame of another thread results in undefined behavior (e.g., the program may crash). For remote unwinding, unw_resume() installs the machine state identified by the cursor by calling the access_reg and access_fpreg accessor callbacks as needed. Once that is accomplished, the resume accessor callback is invoked. The unw_resume routine then returns normally (that is, unlikely for local unwinding, unw_resume will always return for remote unwinding). Most platforms reserve some registers to pass arguments to exception handlers (e.g., IA-64 uses r15-r18 for this purpose). These registers are normally treated like ``scratch'' registers. However, if libunwind is used to set an exception argument register to a particular value (e.g., via unw_set_reg()), then unw_resume() will install this value as the contents of the register. In other words, the exception han- dling arguments are installed even in cases where normally only the ``preserved'' registers are restored. Note that unw_resume() does not invoke any unwind handlers (aka, ``personality routines''). If a program needs this, it will have to do so on its own by obtaining the unw_proc_info_t of each unwound frame and appropriately processing its unwind handler and language-specific data area (lsda). These steps are generally dependent on the target-platform and are regulated by the processor-specific ABI (applica- tion-binary interface). RETURN VALUE
For local unwinding, unw_resume() does not return on success. For remote unwinding, it returns 0 on success. On failure, the negative value of one of the errors below is returned. THREAD AND SIGNAL SAFETY
unw_resume() is thread-safe. If cursor cp is in the local address-space, this routine is also safe to use from a signal handler. ERRORS
UNW_EUNSPEC An unspecified error occurred. UNW_EBADREG A register needed by unw_resume() wasn't accessible. UNW_EINVALIDIP The instruction pointer identified by cp is not valid. UNW_BADFRAME The stack frame identified by cp is not valid. SEE ALSO
libunwind(3), unw_set_reg(3), sigprocmask(2) AUTHOR
David Mosberger-Tang Email: dmosberger@gmail.com WWW: http://www.nongnu.org/libunwind/. Programming Library 16 August 2007 UNW_RESUME(3)
All times are GMT -4. The time now is 04:55 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy