473,796 Members | 2,625 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1948
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*********@gm ail.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 "implementa tion-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*********@gm ail.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 "implementa tion-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********@yah oo.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_Keit h) 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
2302
by: Klaus Neuner | last post by:
Hello, consider the following two programs: # (1) import sys, signal def alarm_handler(signum, frame): raise
3
3526
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.*/ signal(SIGINT,crash); signal(SIGBUS,crash); signal(SIGSEGV,crash); This part works. Those signals cause the "crash.c" module to run and get rid of the lock. Is there a standard way to also print
3
2681
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 know the proper name /useage then I'll use google to try and find out more information ).... Thus any tips or pointers would be helpful (and I'm using a UNIX variant as OS)
11
2977
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
1701
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 every input of j as zero. Once we give the value of both i and j as non-zero, it displays i/j and terminates. This is the sample code i tried: #include <signal.h> void sig_s(int signo);
2
6022
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 language syntax itself. Thank you!
7
2214
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 similiar to the concept of try-catch to me.) It seems to relate more to nix OS. Are signals handling part of Windows too?
10
2150
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 the signal? The following code is recieveing recursive signals. 2 #include <stdio.h> 3 #include <stdlib.h> 4 #include <unistd.h> 5
5
6651
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 another program that executes it as a child process using popen2.Popen4(). I was attempting to use signals to stop it (using os.kill()) but I keep running into a problem where sending the signal causes an infinite loop of printing the message...
9
5841
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
9685
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
1
10187
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7553
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6795
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5446
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5578
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4120
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3735
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2928
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.