1 // ============================================================================
7 // This program exercises the ACE_Stack_Trace class.
10 // Chris Cleeland <cleeland @ ociweb . com>
12 // ============================================================================
14 #include "ace/Stack_Trace.h"
15 #include "ace/OS_NS_string.h"
16 #include "test_config.h"
21 * Ultra-basic test of stack trace.
23 * Other things to test:
24 * - throwing exceptions that contain the stack trace, and catching
25 * - capturing multiple traces
26 * - capture traces with different numbers of frames
27 * - capture traces with different numbers of skipped frames
33 static const ssize_t SKIP
= 1; //@TODO: #ifdef this for MACOSX which needs 2
34 SomeException () : where_(SKIP
), explanation_ ("") { }
35 SomeException (const char *explanation
)
36 : where_(SKIP
), explanation_(explanation
) { }
37 ACE_Stack_Trace where_
;
38 const char *explanation_
;
44 throw SomeException();
48 run_main (int, ACE_TCHAR
*[])
50 ACE_START_TEST (ACE_TEXT ("Stack_Trace_Test"));
53 ACE_DEBUG ((LM_DEBUG
, "t1 trace is %C\n", t1
.c_str()));
55 ACE_Stack_Trace
t2(t1
);
56 ACE_DEBUG ((LM_DEBUG
, "t2 (copied) trace is %C\n",
57 (ACE_OS::strcmp (t1
.c_str(), t2
.c_str()) == 0) ? "same" : "different"));
60 ACE_DEBUG ((LM_DEBUG
, "t3 trace before assignment is %C\n",
61 (ACE_OS::strcmp (t1
.c_str(), t3
.c_str()) == 0) ? "same" : "different"));
63 ACE_DEBUG ((LM_DEBUG
, "t3 trace after assignment is %C\n",
64 (ACE_OS::strcmp (t1
.c_str(), t3
.c_str()) == 0) ? "same" : "different"));
69 catch (SomeException
& e
) {
71 "SomeException caught at\n%?\n; thrown at\n%C",
75 ACE_Stack_Trace
one_frame_only(0, 1);
77 "stack trace of only one frame:\n%C",
78 one_frame_only
.c_str()));
80 ACE_DEBUG ((LM_DEBUG
, "getting ready to end the test at %?\n"));