Sponsored Content
Operating Systems Solaris How to create core through program at the time of crash by handling signals? Post 302740211 by jim mcnamara on Wednesday 5th of December 2012 07:38:34 PM
Old 12-05-2012
The simple way to get a core that "starts" at the fault is not to block signals. Obviously this has some very bad downsides.

Otherwise with what you have done you have to traverse stack frames back to the problem, in gdb this is the
Code:
backtrace

command. Signal receipt when blocked causes an immediate interrupt to the executing code, pushing the state of the process and kernel onto the interrupt stack. Working backwards can be fun.

Some example code for gaddr2line():

c - How to get BACKTRACE (function + line number) on Solaris? - Stack Overflow. Note that you should consider libelf instead of the python library.
 

10 More Discussions You Might Find Interesting

1. Programming

handling-create new SIGNALS

Hi, i cannot find in which file and function the signals are handled by default.Can anyone help me? How can i create a 33th signal? Thanks (3 Replies)
Discussion started by: Panos
3 Replies

2. UNIX for Dummies Questions & Answers

Smart Crash Handling

Hi, Is there anything you can do to a *nix (SuSE Linux actually) which allows it to *try* to do a reboot if something crashes the system? I know they have something at work (but I don't work with the servers myself) which makes the server reboot if it crashes/locks (works about 80% of the... (0 Replies)
Discussion started by: d11wtq
0 Replies

3. Shell Programming and Scripting

Shel program file handling

Hi, Iam having the file as follows: QWASEDRF1234567890098765 abc@quebex.com 000000000-932333 678394-56=3 9033894 QWASEDRF1234567890098765 abc@quebex.com 000000000-932333 678394-56=3 9033894 OPIUYTREE0986666544443322 dcsx@olivaa.net ... (14 Replies)
Discussion started by: nivas
14 Replies

4. Filesystems, Disks and Memory

/dev/core "link to program crash data"

Hi there, I found a link to a file /dev/core of 17 GB Is it ok??? I couldn't find many information about it. Any suggestion would be appreciated!!! Thanks in advance, Giordano Bruno PS: I'm working with FEDORA 6 (2 Replies)
Discussion started by: Giordano Bruno
2 Replies

5. Programming

detached thread is causing program crash

Hi All, I have scenario where my callback function data_update() can be called anytime. I have written the function data_update() such that it will create detached thread for processing the data sent to this function. data_update() { pthread_attr_t attr_thread; ... (1 Reply)
Discussion started by: wonderman
1 Replies

6. Programming

Memory Fault (core dumped) in ttpy program

I´m writing this program in QNX , I`m kinda new to UNIX and programing in general, and when I try to run it it gives me the Memory Fault error. Can anyone help? #include <stdio.h> #include <fcntl.h> void main(void) {int a,ter; char buf; printf("a="); scanf("%d",a); ter=open... (6 Replies)
Discussion started by: GiganteAsesino
6 Replies

7. Programming

Please help:program hang stuck there signal handling on POSIX Message Queue UNIX C programming

in a single main() function,so need signal handling. Use Posix Message Queue IPC mechanism , can ignore the priority and other linked list message,to implement the scenario: client:Knock Knock server:who's there client: Eric Server:Eric,Welcome. client:exit all process terminated ... (1 Reply)
Discussion started by: ouou
1 Replies

8. UNIX for Dummies Questions & Answers

handling signals without race conditions

Greetings, I am writing a small program in C on UNIX, in which I am using (POSIX reliable) signals. 1. Suppose I have a signal : SIGX, and the corresponding signal handler : sigx_handler. It is possible to receive SIGX in my process, and, while executing sigx_handler, to receive again... (0 Replies)
Discussion started by: aigoia
0 Replies

9. AIX

How to create core through program at the time of crash by handling signals?

I am in process of writing a library which can make any application of my product capable of creating core in the application's log folder with a product friendly core file name programatically. In my library I am registering for certain signals e.g. SIGILL, SIGFPE, SIGBUS, SIGSEGV, SIGSYS, SIGABRT... (1 Reply)
Discussion started by: rajeev_ks
1 Replies

10. UNIX for Advanced & Expert Users

Handling Signals in System Calls

What will happen if signal comes while a system call is being executed? How it will be handled? (1 Reply)
Discussion started by: rupeshkp728
1 Replies
BACKTRACE(3)						     Linux Programmer's Manual						      BACKTRACE(3)

NAME
backtrace, backtrace_symbols, backtrace_symbols_fd - support for application self-debugging SYNOPSIS
#include <execinfo.h> int backtrace(void **buffer, int size); char **backtrace_symbols(void *const *buffer, int size); void backtrace_symbols_fd(void *const *buffer, int size, int fd); DESCRIPTION
backtrace() returns a backtrace for the calling program, in the array pointed to by buffer. A backtrace is the series of currently active function calls for the program. Each item in the array pointed to by buffer is of type void *, and is the return address from the corre- sponding stack frame. The size argument specifies the maximum number of addresses that can be stored in buffer. If the backtrace is larger than size, then the addresses corresponding to the size most recent function calls are returned; to obtain the complete backtrace, make sure that buffer and size are large enough. Given the set of addresses returned by backtrace() in buffer, backtrace_symbols() translates the addresses into an array of strings that describe the addresses symbolically. The size argument specifies the number of addresses in buffer. The symbolic representation of each address consists of the function name (if this can be determined), a hexadecimal offset into the function, and the actual return address (in hexadecimal). The address of the array of string pointers is returned as the function result of backtrace_symbols(). This array is malloc(3)ed by backtrace_symbols(), and must be freed by the caller. (The strings pointed to by the array of pointers need not and should not be freed.) backtrace_symbols_fd() takes the same buffer and size arguments as backtrace_symbols(), but instead of returning an array of strings to the caller, it writes the strings, one per line, to the file descriptor fd. backtrace_symbols_fd() does not call malloc(3), and so can be employed in situations where the latter function might fail. RETURN VALUE
backtrace() returns the number of addresses returned in buffer, which is not greater than size. If the return value is less than size, then the full backtrace was stored; if it is equal to size, then it may have been truncated, in which case the addresses of the oldest stack frames are not returned. On success, backtrace_symbols() returns a pointer to the array malloc(3)ed by the call; on error, NULL is returned. VERSIONS
backtrace(), backtrace_symbols(), and backtrace_symbols_fd() are provided in glibc since version 2.1. CONFORMING TO
These functions are GNU extensions. NOTES
These functions make some assumptions about how a function's return address is stored on the stack. Note the following: * Omission of the frame pointers (as implied by any of gcc(1)'s nonzero optimization levels) may cause these assumptions to be violated. * Inlined functions do not have stack frames. * Tail-call optimization causes one stack frame to replace another. The symbol names may be unavailable without the use of special linker options. For systems using the GNU linker, it is necessary to use the -rdynamic linker option. Note that names of "static" functions are not exposed, and won't be available in the backtrace. EXAMPLE
The program below demonstrates the use of backtrace() and backtrace_symbols(). The following shell session shows what we might see when running the program: $ cc -rdynamic prog.c -o prog $ ./prog 3 backtrace() returned 8 addresses ./prog(myfunc3+0x5c) [0x80487f0] ./prog [0x8048871] ./prog(myfunc+0x21) [0x8048894] ./prog(myfunc+0x1a) [0x804888d] ./prog(myfunc+0x1a) [0x804888d] ./prog(main+0x65) [0x80488fb] /lib/libc.so.6(__libc_start_main+0xdc) [0xb7e38f9c] ./prog [0x8048711] Program source #include <execinfo.h> #include <stdio.h> #include <stdlib.h> #include <unistd.h> void myfunc3(void) { int j, nptrs; #define SIZE 100 void *buffer[100]; char **strings; nptrs = backtrace(buffer, SIZE); printf("backtrace() returned %d addresses ", nptrs); /* The call backtrace_symbols_fd(buffer, nptrs, STDOUT_FILENO) would produce similar output to the following: */ strings = backtrace_symbols(buffer, nptrs); if (strings == NULL) { perror("backtrace_symbols"); exit(EXIT_FAILURE); } for (j = 0; j < nptrs; j++) printf("%s ", strings[j]); free(strings); } static void /* "static" means don't export the symbol... */ myfunc2(void) { myfunc3(); } void myfunc(int ncalls) { if (ncalls > 1) myfunc(ncalls - 1); else myfunc2(); } int main(int argc, char *argv[]) { if (argc != 2) { fprintf(stderr, "%s num-calls ", argv[0]); exit(EXIT_FAILURE); } myfunc(atoi(argv[1])); exit(EXIT_SUCCESS); } SEE ALSO
gcc(1), ld(1), dlopen(3), malloc(3) COLOPHON
This page is part of release 3.27 of the Linux man-pages project. A description of the project, and information about reporting bugs, can be found at http://www.kernel.org/doc/man-pages/. GNU
2008-06-14 BACKTRACE(3)
All times are GMT -4. The time now is 12:53 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy