473,399 Members | 3,888 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

signal.h

I'm attempting to catch bugs in my program using signal.h with sigsegv.
now i know when i'm in gdb i can catch bugs but is there any variable
that stores like the file that caused the bug and possible calling
procs? or would that only be left to something with gdb.
Dec 9 '06 #1
5 1929
David Willoughby wrote:
I'm attempting to catch bugs in my program using signal.h with sigsegv.
now i know when i'm in gdb i can catch bugs but is there any variable
that stores like the file that caused the bug and possible calling
procs? or would that only be left to something with gdb.
You'd better ask in a group or forum dedicated to your platform and
tools. When you, quote an example.

--
Ian Collins.
Dec 9 '06 #2
David Willoughby wrote:
I'm attempting to catch bugs in my program using signal.h with sigsegv.
now i know when i'm in gdb i can catch bugs but is there any variable
that stores like the file that caused the bug and possible calling
procs? or would that only be left to something with gdb.
The standard macros __FILE__ and __LINE__ may do what you want. For
more you'll have to use implementation specific extensions.

Dec 9 '06 #3
On 8 Dec 2006 22:13:36 -0800, "santosh" <sa*********@gmail.comwrote:
>David Willoughby wrote:
>I'm attempting to catch bugs in my program using signal.h with sigsegv.
now i know when i'm in gdb i can catch bugs but is there any variable
that stores like the file that caused the bug and possible calling
procs? or would that only be left to something with gdb.

The standard macros __FILE__ and __LINE__ may do what you want. For
more you'll have to use implementation specific extensions.
I can't think of any way the standard macros __FILE__ and __LINE__
could help in the general case of a SIGSEGV signal.

Moreover, saying that "implementation-specific extensions" could help
in the general case implies to me *compiler* implementation-specific
extensions. But more likely than not, it's things like debuggers,
which are beyond the scope of the ANSI/ISO C standard--which is what
we discuss here--that will help the OP.

I think the spirit of your post was that the OP should look for help
in another, more appropriate newsgroup. If so, indeed the OP should
(and find out, that, that would only be left to something with gdb, as
the OP surmised :^).

Best regards
--
jay
Dec 9 '06 #4
jaysome wrote:
"santosh" <sa*********@gmail.comwrote:
>David Willoughby wrote:
>>I'm attempting to catch bugs in my program using signal.h with
sigsegv. now i know when i'm in gdb i can catch bugs but is there
any variable that stores like the file that caused the bug and
possible calling procs? or would that only be left to something
with gdb.

The standard macros __FILE__ and __LINE__ may do what you want. For
more you'll have to use implementation specific extensions.

I can't think of any way the standard macros __FILE__ and __LINE__
could help in the general case of a SIGSEGV signal.

Moreover, saying that "implementation-specific extensions" could help
in the general case implies to me *compiler* implementation-specific
extensions. But more likely than not, it's things like debuggers,
which are beyond the scope of the ANSI/ISO C standard--which is what
we discuss here--that will help the OP.

I think the spirit of your post was that the OP should look for help
in another, more appropriate newsgroup. If so, indeed the OP should
(and find out, that, that would only be left to something with gdb, as
the OP surmised :^).
Before calling the function that signals SIGSEGV he can emit a
message formed from the __FILE__ and __LINE__ macros. Something
like:

if (evilcondition) {
printf("Fault in %s line #%s\n", __FILE__, __LINE__);
signal(....);
}

--
Chuck F (cbfalconer at maineline dot net)
Available for consulting/temporary embedded and systems.
<http://cbfalconer.home.att.net>

Dec 9 '06 #5
CBFalconer <cb********@yahoo.comwrites:
[...]
Before calling the function that signals SIGSEGV he can emit a
message formed from the __FILE__ and __LINE__ macros. Something
like:

if (evilcondition) {
printf("Fault in %s line #%s\n", __FILE__, __LINE__);
signal(....);
}
I'd add a call to fflush(stdout) after the printf.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Dec 9 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Klaus Neuner | last post by:
Hello, consider the following two programs: # (1) import sys, signal def alarm_handler(signum, frame): raise
3
by: Martin McCormick | last post by:
A C program contains several signal statements to remove a lock file if the program gets killed: /*Set up interrupt handler to catch ctrl-C so that lock file can be removed.*/...
3
by: LeTubs | last post by:
Hi I'm not sure if this is correct ...place to post but here goes This is what i'm trying to do, I want to write a signal / alarm handler ( I don't know which hence the posting here, as once I...
11
by: Jackie | last post by:
Hi everyone, I'd like to know when and how signals are used (e.g. SIGFPE, SIGABRT, SIGTERM, SIGSEGV, SIGINT)? Thank you so much.
7
by: Amit Sharma | last post by:
Hi, I want to write a program, where until we give the value of j as non zero, it should go on asking us values of i and j, displaying the message "Division by zero: Floating point exception" for...
2
by: None | last post by:
Hello, 1. The prototype of function signal in signal.h: void (*signal(int sig, void (*func)(int)))(int); is some complex to me. Would you please explain it to me in detail with the C...
7
by: Stanley S | last post by:
Hi, Are Signal Handling part of ANSI C? I am not able to find any reference of Sig Handling in Stephen Prata's "C Primer Plus". The usage of signals is to trap errors I guess. (It looks...
10
by: Udai Kiran | last post by:
Hi all Iam having trouble with signal handler. Where will the execution return after invoking a signal handler when that particular signal is recieved? will return to the point where we register...
5
by: david | last post by:
I'm developing a program that runs using an asyncore loop. Right now I can adequately terminate it using Control-C, but as things get refined I need a better way to stop it. I've developed...
9
by: thagor2008 | last post by:
Is the behaviour of throwing exceptions in a unix signal handler defined? eg: void sighandler(int sig) { ... do something throw myobj; }
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.