Sponsored Content
Full Discussion: Regarding stack analysis
Top Forums Programming Regarding stack analysis Post 302208256 by vpraveen84 on Monday 23rd of June 2008 12:09:15 PM
Old 06-23-2008
Quote:
Originally Posted by jim mcnamara
Normally, coders test for division by zero in the function and take corrective action to the values before SIGFPE hits the process. Not after.

With your method, you will need global pointers to the problem value(s), but how do you expect to correct the problem? You have already gone past the division step. Call the function again from the signal handler? Then what happens? The code sets b=0 again and you get another SIGFPE, and you are back where you started.
I understand what you are saying, but my aim is not exception handling. I want to modify certain memory locations before dumping the core , and this is why I want access to the local variables in func().

For instance, we've the ucontext_t (in sigaction) which gives the context of the exception(similar to setjmp env). But I don't know how I can get a mapping between the variables in func() and the context ?

thanks.

Last edited by vpraveen84; 06-23-2008 at 02:26 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
sigfpe(3C)						   Standard C Library Functions 						sigfpe(3C)

NAME
sigfpe - signal handling for specific SIGFPE codes SYNOPSIS
#include <floatingpoint.h> #include <siginfo.h> sigfpe_handler_type sigfpe(sigfpe_code_type code, sigfpe_handler_type hdl); DESCRIPTION
The sigfpe() function allows signal handling to be specified for particular SIGFPE codes. A call to sigfpe() defines a new handler hdl for a particular SIGFPE code and returns the old handler as the value of the function sigfpe(). Normally handlers are specified as pointers to functions; the special cases SIGFPE_IGNORE, SIGFPE_ABORT, and SIGFPE_DEFAULT allow ignoring, dumping core using abort(3C), or default han- dling respectively. Default handling is to dump core using abort(3C). The code argument is usually one of the five IEEE754-related SIGFPE codes: FPE_FLTRES fp_inexact - floating-point inexact result FPE_FLTDIV fp_division - floating-point division by zero FPE_FLTUND fp_underflow - floating-point underflow FPE_FLTOVF fp_overflow - floating-point overflow FPE_FLTINV fp_invalid - floating-point invalid operation Three steps are required to intercept an IEEE754-related SIGFPE code with sigfpe(): 1. Set up a handler with sigfpe(). 2. Enable the relevant IEEE754 trapping capability in the hardware, perhaps by using assembly-language instructions. 3. Perform a floating-point operation that generates the intended IEEE754 exception. The sigfpe() function never changes floating-point hardware mode bits affecting IEEE754 trapping. No IEEE754-related SIGFPE signals will be generated unless those hardware mode bits are enabled. SIGFPE signals can be handled using sigfpe(), sigaction(2) or signal(3C). In a particular program, to avoid confusion, use only one of these interfaces to handle SIGFPE signals. EXAMPLES
Example 1: Example Of A User-Specified Signal Handler A user-specified signal handler might look like this: #include <floatingpoint.h> #include <siginfo.h> #include <ucontext.h> /* * The sample_handler prints out a message then commits suicide. */ void sample_handler(int sig, siginfo_t *sip, ucontext_t *uap) { char *label; switch (sip->si_code) { case FPE_FLTINV: label = "invalid operand"; break; case FPE_FLTRES: label = "inexact"; break; case FPE_FLTDIV: label = "division-by-zero"; break; case FPE_FLTUND: label = "underflow"; break; case FPE_FLTOVF: label = "overflow"; break; default: label = "???"; break; } fprintf(stderr, "FP exception %s (0x%x) occurred at address %p. ", label, sip->si_code, (void *) sip->si_addr); abort(); } and it might be set up like this: #include <floatingpoint.h> #include <siginfo.h> #include <ucontext.h> extern void sample_handler(int, siginfo_t *, ucontext_t *); main(void) { sigfpe_handler_type hdl, old_handler1, old_handler2; /* * save current fp_overflow and fp_invalid handlers; set the new * fp_overflow handler to sample_handler() and set the new * fp_invalid handler to SIGFPE_ABORT (abort on invalid) */ hdl = (sigfpe_handler_type) sample_handler; old_handler1 = sigfpe(FPE_FLTOVF, hdl); old_handler2 = sigfpe(FPE_FLTINV, SIGFPE_ABORT); ... /* * restore old fp_overflow and fp_invalid handlers */ sigfpe(FPE_FLTOVF, old_handler1); sigfpe(FPE_FLTINV, old_handler2); } FILES
/usr/include/floatingpoint.h /usr/include/siginfo.h ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |MT-Level |Safe | +-----------------------------+-----------------------------+ SEE ALSO
sigaction(2), abort(3C), signal(3C), attributes(5), floatingpoint.h(3HEAD) DIAGNOSTICS
The sigfpe() function returns (void(*)())-1 if code is not zero or a defined SIGFPE code. SunOS 5.10 4 May 2004 sigfpe(3C)
All times are GMT -4. The time now is 12:58 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy