Sponsored Content
Special Forums Hardware Filesystems, Disks and Memory get stack trace from C program on Solaris 8 Post 302111950 by Perderabo on Friday 23rd of March 2007 01:36:10 PM
Old 03-23-2007
Ok, then, popen rather than system.
 

10 More Discussions You Might Find Interesting

1. Programming

Core file without a readable stack trace

I am using gdb to examine a core file but the output contains only the method addresses in hex. Is there anyway to translate these addresses to a human-readable form? :confused: (0 Replies)
Discussion started by: ciregbu
0 Replies

2. Programming

printing a stack trace with backtrace

I am trying to print a stack trace programatically using backtrace and backtrace_symbols. The problem is that the stack being printed in a mangled format. Is there a way to get the output in more of a human readable form? I am using Red Hat and the program is written in c++. (2 Replies)
Discussion started by: dmirza
2 Replies

3. Shell Programming and Scripting

Need to capture ERROR msg and stack trace

Hi all, I was hoping someone can point me in the right direction. I'm trying to filter out errors from a web log- any lines with ERROR in it. I know I could simply use the grep command to do this. However, there are times when a stack trace follows the error line. I would like to capture these... (2 Replies)
Discussion started by: gswhoops
2 Replies

4. UNIX for Advanced & Expert Users

help required - stack trace

Hi all, One of our programs written in Java, produced this logfile. This job runs 48 threads and only one thread failed with this error. The code is a blackbox(external product), so cant look at the source code. From what I can infer from the log, the job was trying to write the log messages into... (9 Replies)
Discussion started by: ranj@chn
9 Replies

5. Solaris

Need to retrieve stack trace from core using mdb

Hello , I use Solaris 5.10 . I have huge core file , 48 GB , resulted from an application that was running and got crashed with SIGSEGV. On my system only mdb works. Please help me to retrieve the stack trace from this core file. I am novice to mdb and its nuaunces. Please help me with... (2 Replies)
Discussion started by: rmv
2 Replies

6. AIX

How to get the stack trace using kdb?

Hi All, I am trying to debug my core file using kdb. When I try to get the stack trace I am facing this error. core mapped from @ 700000000000000 to @ 70000000306fc04 Preserving 1680415 bytes of symbol table Dump does not start with valid magic number WARNING: Possibly truncated or... (2 Replies)
Discussion started by: Sachin1987
2 Replies

7. Shell Programming and Scripting

Stack Trace

Hi All Thought it would be kind of fun to implement a stack trace for a shell script that calls functions within a sub shell. This is for bash under Linux and probably not portable - #! /bin/bash error_exit() { echo "=======================" echo $1 echo... (4 Replies)
Discussion started by: steadyonabix
4 Replies

8. Programming

View Stack Trace of different cores

I have a C program which is running as daemon and has some threads. The program is running on dual core cpu and it may happen that different threads may run on different cpu core. The problem is sometimes it crashes with some heap memory corruption probably between threads. GDB command(t a a... (2 Replies)
Discussion started by: rupeshkp728
2 Replies

9. Linux

Server hung, is this a stack trace?

Hi everyone, Our Red Hat server hung yesterday, and I managed to log into the console and see the following message: RIP: 0010: mwait_idle_with_hints+0x66/ 0x67 RSP: 0018:ffffffff80457f40 EFLAGS: 00000046 RAX: 0000000000000010 RBX: ffff810c20075910 RCX: 0000000000000001 RDX:... (6 Replies)
Discussion started by: badoshi
6 Replies

10. Shell Programming and Scripting

Java stack trace parser in awk

I want the developers to get a mail with Java stack traces on a daily bases. When something is flaged as known issue and will get a fix but mean while this does not need to get sent each dayl. This is what I got so far. It's a bash script that runs some AWK in it. To get the files that needs to... (6 Replies)
Discussion started by: chipmunken
6 Replies
walkcontext(3C) 					   Standard C Library Functions 					   walkcontext(3C)

NAME
walkcontext, addrtosymstr, printstack, backtrace, backtrace_symbols, backtrace_symbols_fd - walk stack pointed to by ucontext SYNOPSIS
#include <ucontext.h> int walkcontext(const ucontext_t *uptr, int (*operate_func)(uintptr_t, int, void *), void *usrarg); int addrtosymstr(uintptr_t addr, char *buffer, int len); int printstack(int fd); #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
The walkcontext() function walks the call stack pointed to by uptr, which can be obtained by a call to getcontext(2) or from a signal han- dler installed with the SA_SIGINFO flag. The walkcontext() function calls the user-supplied function operate_func for each routine found on the call stack and each signal handler invoked. The user function is passed three arguments: the PC at which the call or signal occurred, the signal number that occurred at this PC (0 if no signal occurred), and the third argument passed to walkcontext(). If the user function returns a non-zero value, walkcontext() returns without completing the callstack walk. The addrtosymstr() function attempts to convert a PC into a symbolic representation of the form objname'funcname+0xoffset[0xPC] where objname is the module in which the PC is located, funcname is the name of the function, and offset is the offset from the beginning of the function. The objname, funcname, and offset values are obtained from dladdr(3C) and might not always be present. The resulting string is written to the user-supplied buffer. Should the length of the string be larger than the user-supplied buffer, only the portion of the string that will fit is written and null-terminated. The printstack() function uses walkcontext() to print a symbolic stack trace to the specified file descriptor. This is useful for reporting errors from signal handlers. The printstack() function uses dladdr1() (see dladdr(3C)) to obtain symbolic symbol names. As a result, only global symbols are reported as symbol names by printstack(). The backtrace() function uses walkcontext() to generate a stack's program counter values for the calling thread and place these values into the array specified by the buffer argument. The size argument specifies the maximum number of program counters that will be recorded. This function is provided for compatibility with the GNU libc used on Linux systems, glibc. The backtrace_symbols() function translates the numerical program counter values previously recorded by a call to backtrace() in the buffer argument, and converts, where possible, each PC to a string indicating the module, function and offset of each call site. The number of symbols present in the array must be passed in with the size argument. The set of strings is returned in an array obtained from a call to malloc(3C). It is the responsibility of the caller to pass the returned pointer to free(). The individual strings must not be freed. Since malloc() is used to obtain the needed space, this function is MT-Safe rather than Async-Signal-Safe and cannot be used reliably from a signal handler. This function is provided for glibc compatibility. The backtrace_symbols_fd() function translates the numerical program counter values previously recorded by a call to backtrace() in the buffer argument, and converts, where possible, each PC to a string indicating the module, function, and offset of each call site. These strings are written to the file descriptor specified in the fd argument. This function is provided for glibc compatibility. RETURN VALUES
Upon successful completion, walkcontext() and printstack() return 0. If walkcontext() cannot read the stack or the stack trace appears corrupted, both functions return -1. The addrtosymstr() function returns the number of characters necessary to hold the entire string representation of the passed in address, irrespective of the size of the user-supplied buffer. The backtrace() function returns the number of stack frames captured. The backtrace_symbols() function returns a pointer to an array containing string representations of the calling sequence. ERRORS
No error values are defined. USAGE
The walkcontext() function is typically used to obtain information about the call stack for error reporting, performance analysis, or diag- nostic purposes. Many library functions are not Async-Signal-Safe and should not be used from a signal handler. If walkcontext() is to be called from a signal handler, careful programming is required. In particular, stdio(3C) and malloc(3C) cannot be used. The walkstack(), addrtosymstr(), printstack(), backtrace(), and backtrace_symbols_fd() functions are Async-Signal-Safe and can be called from a signal handler. The string representation generated by addrtosymstr() and displayed by printstack(), backtrace_symbols() and backtrace_symbols_fd() is unstable and will change depending on the information available in the modules that comprise the stack trace. Tail-call optimizations on SPARC eliminate stack frames that would otherwise be present. For example, if the code is of the form #include <stdio.h> main() { bar(); exit(0); } bar() { int a; a = foo(fileno(stdout)); return (a); } foo(int file) { printstack(file); } compiling without optimization will yield a stack trace of the form /tmp/q:foo+0x8 /tmp/q:bar+0x14 /tmp/q:main+0x4 /tmp/q:_start+0xb8 whereas with higher levels of optimization the output is /tmp/q:main+0x10 /tmp/q:_start+0xb8 since both the call to foo() in main and the call to bar() in foo() are handled as tail calls that perform a return or restore in the delay slot. For further information, see The SPARC Architecture Manual. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Interface Stability |Stable | +-----------------------------+-----------------------------+ |MT-Level |See below. | +-----------------------------+-----------------------------+ The backtrace_symbols() function is MT-Safe. The remaining functions are Async-Signal-Safe. SEE ALSO
Intro(2), getcontext(2), sigaction(2), dladdr(3C), siginfo.h(3HEAD), attributes(5) Weaver, David L. and Tom Germond, eds. The SPARC Architecture Manual, Version 9. Santa Clara: Prentice Hall, 2000. SunOS 5.11 10 Apr 2007 walkcontext(3C)
All times are GMT -4. The time now is 04:48 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy