Encapsulate a string representation of a stack trace on supported platforms. Stack traces for code built with optimize=1 (or "Release" configs on Visual Studio) may be misleading (missng frames) due to inlining performed by the compiler, which is indepenent of the inline=0 / inline=1 build option and the __ACE_INLINE__ / ACE_NO_INLINE macros. More...
#include <Stack_Trace.h>
Public Member Functions | |
ACE_Stack_Trace (ssize_t starting_frame_offset=0, size_t num_frames=0) | |
Grab a snapshot of the current stack trace and hold it for later use. | |
const char * | c_str () const |
Return buffer as a C-style string. | |
Static Public Attributes | |
static const size_t | SYMBUFSIZ = ACE_STACK_TRACE_SYMBUFSIZ |
Private Member Functions | |
void | generate_trace (ssize_t starting_frame_offset, size_t num_frames) |
Private Attributes | |
char | buf_ [SYMBUFSIZ] |
size_t | buflen_ |
Static Private Attributes | |
static const char | UNSUPPORTED [] = "<stack traces unsupported platform>" |
static const char | UNABLE_TO_GET_TRACE [] = "<unable to get trace>" |
Encapsulate a string representation of a stack trace on supported platforms. Stack traces for code built with optimize=1 (or "Release" configs on Visual Studio) may be misleading (missng frames) due to inlining performed by the compiler, which is indepenent of the inline=0 / inline=1 build option and the __ACE_INLINE__ / ACE_NO_INLINE macros.
A new conversion character, the question mark, was added to ACE_Log_Msg for stack trace logging. The %? conversion character was added as a convenience so that users need not instantiate an ACE_Stack_Trace instance solely for the purpose of printing it in an ACE logging message. The following are functionally equivalent:
These usage examples were shown in $ACE_ROOT/tests/Stack_Trace_Test.cpp.
ACE_STACK_TRACE_SYMBUFSIZ
), you will not get a complete stack trace if ACE_STACK_TRACE_SYMBUFSIZ
value is less than actual stack trace data length. To get a complete stack trace, you need set ACE_STACK_TRACE_SYMBUFSIZ
with a larger value that is enough for the stack trace data in your config.h
file and rebuild ACE.ACE_Stack_Trace st; ACE_OS::printf("at [%s]\n", st.c_str());
Definition at line 72 of file Stack_Trace.h.
ACE_Stack_Trace::ACE_Stack_Trace | ( | ssize_t | starting_frame_offset = 0 , |
|
size_t | num_frames = 0 | |||
) | [explicit] |
Grab a snapshot of the current stack trace and hold it for later use.
starting_frame_offset | offset into the array of frames to start printing; 0 is the platform-specific offset for the first frame, positive numbers give less frames, negative give more frames | |
num_frames | the number of stack frames to include (0 indicates platform-specific maximum) |
Definition at line 43 of file Stack_Trace.cpp.
: buflen_(0) { // cannot initialize arrays, so we must assign. this->buf_[0] = '\0'; this->generate_trace (starting_frame_offset, num_frames); }
const char * ACE_Stack_Trace::c_str | ( | void | ) | const |
Return buffer as a C-style string.
Definition at line 52 of file Stack_Trace.cpp.
{ return &this->buf_[0]; }
void ACE_Stack_Trace::generate_trace | ( | ssize_t | starting_frame_offset, | |
size_t | num_frames | |||
) | [private] |
Definition at line 712 of file Stack_Trace.cpp.
{ // Call determine_starting_frame() on HP aCC build to resolve declared // method never referenced warning. #if defined (__HP_aCC) size_t starting_frame = determine_starting_frame (0, 0); #endif ACE_OS::strcpy (&this->buf_[0], UNSUPPORTED); }
char ACE_Stack_Trace::buf_[SYMBUFSIZ] [private] |
Definition at line 96 of file Stack_Trace.h.
size_t ACE_Stack_Trace::buflen_ [private] |
Definition at line 97 of file Stack_Trace.h.
const size_t ACE_Stack_Trace::SYMBUFSIZ = ACE_STACK_TRACE_SYMBUFSIZ [static] |
Definition at line 93 of file Stack_Trace.h.
const char ACE_Stack_Trace::UNABLE_TO_GET_TRACE = "<unable to get trace>" [static, private] |
Definition at line 100 of file Stack_Trace.h.
const char ACE_Stack_Trace::UNSUPPORTED = "<stack traces unsupported platform>" [static, private] |
Definition at line 99 of file Stack_Trace.h.