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"
20 * Ultra-basic test of stack trace.
22 * Other things to test:
23 * - throwing exceptions that contain the stack trace, and catching
24 * - capturing multiple traces
25 * - capture traces with different numbers of frames
26 * - capture traces with different numbers of skipped frames
32 static const ssize_t SKIP
= 1; //@TODO: #ifdef this for MACOSX which needs 2
33 SomeException () : where_(SKIP
), explanation_ ("") { }
34 SomeException (const char *explanation
)
35 : where_(SKIP
), explanation_(explanation
) { }
36 ACE_Stack_Trace where_
;
37 const char *explanation_
;
43 throw SomeException();
47 run_main (int, ACE_TCHAR
*[])
49 ACE_START_TEST (ACE_TEXT ("Stack_Trace_Test"));
52 ACE_DEBUG ((LM_DEBUG
, "t1 trace is %C\n", t1
.c_str()));
54 ACE_Stack_Trace
t2(t1
);
55 ACE_DEBUG ((LM_DEBUG
, "t2 (copied) trace is %C\n",
56 (ACE_OS::strcmp (t1
.c_str(), t2
.c_str()) == 0) ? "same" : "different"));
59 ACE_DEBUG ((LM_DEBUG
, "t3 trace before assignment is %C\n",
60 (ACE_OS::strcmp (t1
.c_str(), t3
.c_str()) == 0) ? "same" : "different"));
62 ACE_DEBUG ((LM_DEBUG
, "t3 trace after assignment is %C\n",
63 (ACE_OS::strcmp (t1
.c_str(), t3
.c_str()) == 0) ? "same" : "different"));
68 catch (SomeException
& e
) {
70 "SomeException caught at\n%?\n; thrown at\n%C",
74 ACE_Stack_Trace
one_frame_only(0, 1);
76 "stack trace of only one frame:\n%C",
77 one_frame_only
.c_str()));
79 ACE_DEBUG ((LM_DEBUG
, "getting ready to end the test at %?\n"));