From bf854d7118c00e99876973fb794c9768440188b9 Mon Sep 17 00:00:00 2001 From: "Fred T. Hamster" Date: Thu, 12 Feb 2026 06:24:53 -0500 Subject: [PATCH] program wide callstack became thread wide --- .../library/application/callstack_tracker.cpp | 23 +++---------- .../library/application/callstack_tracker.h | 6 ++-- .../library/application/memory_checker.cpp | 4 +-- .../structures/static_memory_gremlin.cpp | 34 +------------------ 4 files changed, 9 insertions(+), 58 deletions(-) diff --git a/nucleus/library/application/callstack_tracker.cpp b/nucleus/library/application/callstack_tracker.cpp index 1773ce58..eaae7eb4 100644 --- a/nucleus/library/application/callstack_tracker.cpp +++ b/nucleus/library/application/callstack_tracker.cpp @@ -27,19 +27,7 @@ #include #include -//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 { @@ -68,7 +56,7 @@ basis::mutex &callstack_tracker::__callstack_tracker_synchronizer() 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()); @@ -114,15 +102,12 @@ callstack_tracker::callstack_tracker() _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, @@ -289,7 +274,7 @@ frame_tracking_instance::frame_tracking_instance(const char *class_name, { 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"); } } @@ -310,7 +295,7 @@ void frame_tracking_instance::clean() { 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; @@ -343,7 +328,7 @@ void frame_tracking_instance::assign(const char *class_name, const char *func, 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"); } diff --git a/nucleus/library/application/callstack_tracker.h b/nucleus/library/application/callstack_tracker.h index 0ef6bf44..b01bb9ee 100644 --- a/nucleus/library/application/callstack_tracker.h +++ b/nucleus/library/application/callstack_tracker.h @@ -30,7 +30,7 @@ class callstack_tracker; ////////////// -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! @@ -111,8 +111,8 @@ private: 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! */ \ diff --git a/nucleus/library/application/memory_checker.cpp b/nucleus/library/application/memory_checker.cpp index 85d46dcc..b66e8056 100644 --- a/nucleus/library/application/memory_checker.cpp +++ b/nucleus/library/application/memory_checker.cpp @@ -1,6 +1,4 @@ - - /*****************************************************************************\ * * * Name : memory_checker * @@ -100,7 +98,7 @@ public: } _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 } diff --git a/nucleus/library/structures/static_memory_gremlin.cpp b/nucleus/library/structures/static_memory_gremlin.cpp index 88ba32d4..79184d1c 100644 --- a/nucleus/library/structures/static_memory_gremlin.cpp +++ b/nucleus/library/structures/static_memory_gremlin.cpp @@ -24,38 +24,6 @@ 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 @@ -253,7 +221,7 @@ static_memory_gremlin &static_memory_gremlin::__hoople_globals() #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 -- 2.34.1