#include <stdio.h>
#include <string.h>
-//using namespace application;
using namespace basis;
-//using namespace configuration;
-//using namespace mathematics;
-//using namespace filesystem;
-//using namespace loggers;
-//using namespace structures;
-//using namespace textual;
-//using namespace timely;
-//using namespace unit_test;
-
-////#undef new
-//is this right way to clean that out..?
namespace application {
as the memory checker. it can allocate c++ objects and that kind of thing
just fine.
*/
-callstack_tracker &program_wide_stack_trace()
+callstack_tracker &thread_wide_stack_trace()
{
auto_synchronizer l(callstack_tracker::__callstack_tracker_synchronizer());
_highest(0),
_unusable(false)
{
-//printf("callstack ctor\n");
}
callstack_tracker::~callstack_tracker()
{
-//printf("!!!!!!!!!!!!!!!!!! callstack dtor in\n");
_unusable = true;
WHACK(_bt);
-//printf("!!!!!!!!!!!!!!!!!! callstack dtor out\n");
}
bool callstack_tracker::push_frame(const char *class_name, const char *func,
{
if (_frame_involved) {
//printf("frametrackinst ctor in class=%s func=%s\n", class_name, func);
- program_wide_stack_trace().push_frame(class_name, func, file, line);
+ thread_wide_stack_trace().push_frame(class_name, func, file, line);
//printf("frametrackinst ctor out\n");
}
}
{
if (_frame_involved) {
//printf("frametrackinst clean\n");
- program_wide_stack_trace().pop_frame();
+ thread_wide_stack_trace().pop_frame();
}
_frame_involved = false;
free(_class); _class = NULL_POINTER;
void update_current_stack_frame_line_number(int line)
{
//printf("frametrackinst updatelinenum in\n");
- program_wide_stack_trace().update_line(line);
+ thread_wide_stack_trace().update_line(line);
//printf("frametrackinst updatelinenum out\n");
}
//////////////
-callstack_tracker &program_wide_stack_trace();
+callstack_tracker &thread_wide_stack_trace();
//!< a global object that can be used to track the runtime callstack.
//hmmm: maybe borked on basis of the conflict between a global stack tracker and the fact that each thread has its own callstack! argh!
from the embedding function.
*/
#define GET_AND_TEST_STACK_TRACE(header, failure_return) { \
- int trace_size = program_wide_stack_trace().full_trace_size(); \
- char *stack_trace = program_wide_stack_trace().full_trace(); \
+ int trace_size = thread_wide_stack_trace().full_trace_size(); \
+ char *stack_trace = thread_wide_stack_trace().full_trace(); \
ASSERT_TRUE(trace_size >= strlen(stack_trace) + 1, "insufficient estimated stack trace size"); \
if (trace_size < strlen(stack_trace) + 1) { \
/* error condition here; we are supposed to get the actual size we would need to allocate! */ \
-
-
/*****************************************************************************\
* *
* Name : memory_checker *
}
_line = line;
#ifdef ENABLE_CALLSTACK_TRACKING
- _stack = program_wide_stack_trace().full_trace();
+ _stack = thread_wide_stack_trace().full_trace();
///printf("stack here:\n%s", _stack);
#endif
}
using namespace application;
using namespace basis;
-/* no.
-namespace application {
-
-//! the single instance of callstack_tracker.
-/ *! this is also an ultra low-level object, although it's not as far down
-as the memory checker. it can allocate c++ objects and that kind of thing
-just fine. the object must be stored here rather than in the static basis
-library due to issues in windows dlls.
-NOTE: this is also not thread safe; it must be initialized before any threads
-have started. * /
-
-//hmmm: why is this here? because it needs to interact with the progwide memories?
-callstack_tracker &program_wide_stack_trace()
-{
- static callstack_tracker *_hidden_trace = NULL_POINTER;
- if (!_hidden_trace) {
-#ifdef ENABLE_MEMORY_HOOK
- program_wide_memories().disable();
- // we don't want infinite loops tracking the call stack during this
- // object's construction.
-#endif
- _hidden_trace = new callstack_tracker;
-#ifdef ENABLE_MEMORY_HOOK
- program_wide_memories().enable();
-#endif
- }
- return *_hidden_trace;
-}
-
-} //namespace.
-*/
-
namespace structures {
//#define DEBUG_STATIC_MEMORY_GREMLIN
#endif
#ifdef ENABLE_CALLSTACK_TRACKING
- application::program_wide_stack_trace().full_trace_size();
+ application::thread_wide_stack_trace().full_trace_size();
// invoke now to get callback tracking instantiated.
#endif