Sponsored Content
Full Discussion: Regarding stack analysis
Top Forums Programming Regarding stack analysis Post 302208042 by vpraveen84 on Sunday 22nd of June 2008 07:48:43 PM
Old 06-22-2008
Regarding stack analysis

I would like to know how I could do the following :

Code:
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 = (struct sigaction *)malloc(sizeof(struct sigaction));
  act->sa_flags = SA_SIGINFO;
  act->sa_sigaction = sig_handler; 
  sigaction(SIGFPE,act,NULL); 
  func();
}

As expected, this program should give an exception. But I use sigaction to catch the signal (arithmetric exception) and send control to another function(sig_handler), where I want to handle this signal.

I would like to access the variables inside func() and modify them. How can I do this ?

thank you,

Last edited by vpraveen84; 06-22-2008 at 10:54 PM..
 

6 More Discussions You Might Find Interesting

1. Solaris

Catalina Analysis

How can I make analysis for catalina.out (2 Replies)
Discussion started by: Burhan
2 Replies

2. Programming

what is stack winding and stack unwinding

helo can u tell me what do you mean by stack winding and stack unwinding Regards, Amit (2 Replies)
Discussion started by: amitpansuria
2 Replies

3. Shell Programming and Scripting

Metacharacters analysis

:confused:Hi , Can someone please advise what is the meaning of metacharacters in below code? a_PROCESS=${0##*/} a_DPFX=${a_PROCESS%.*} a_LPFX="a_DPFX : $$ : " a_UPFX="Usage: $a_PROCESS" Regards, gehlnar (3 Replies)
Discussion started by: gehlnar
3 Replies

4. UNIX for Dummies Questions & Answers

Text analysis

Hey Guys, Does anyone know how to count the separate amount of words in a text file? e.g the 5 and 20 Furthermore does anyone know how to convert whole numbers in decimals? Thanks (24 Replies)
Discussion started by: John0101
24 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. Infrastructure Monitoring

Nmon Analysis

Dear All, I am an performance tester. Now i am working in project where we are using linux 2.6.32. Now I got an oppurtunity to learn the monitoring the server. As part of this task i need to do analysis of the Nmon report. I was completely blank in this. So please suggest me how to start... (0 Replies)
Discussion started by: iamsengu
0 Replies
CPU_LWP_FORK(9) 					   BSD Kernel Developer's Manual					   CPU_LWP_FORK(9)

NAME
cpu_lwp_fork, child_return, proc_trampoline -- finish a fork operation SYNOPSIS
#include <sys/proc.h> void cpu_lwp_fork(struct lwp *l1, struct lwp *l2, void *stack, size_t stacksize, void (*func)(void *), void *arg); void child_return(void *arg); DESCRIPTION
cpu_lwp_fork() is the machine-dependent portion of fork1() which finishes a fork operation, with child lwp l2 nearly set up. It copies and updates the PCB and trap frame from the parent l1, making the child ready to run. cpu_lwp_fork() rigs the child's kernel stack so that it will start in proc_trampoline(). proc_trampoline() does not have a normal calling sequence and is entered by cpu_switch(). If an alternate user-level stack is requested (with non-zero values in both the stack and stacksize arguments), the user stack pointer is set up accordingly. After being entered by cpu_switch() and while running in user context (within the kernel) proc_trampoline() will invoke the function func with the argument arg. If a kernel thread is being created, the return path and argument are specified with func and arg. If a user process is being created, fork1() will pass child_return() and l2 to cpu_lwp_fork() as func and arg respectively. This causes the newly-created child process to go directly to user level with an apparent return value of 0 from fork(2), while the parent process returns normally. SEE ALSO
fork(2), cpu_switchto(9), fork1(9) BSD
April 13, 2010 BSD
All times are GMT -4. The time now is 08:51 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy