NO-OP: whitespace & revert samples -> [stack]frames
authorRobin Gareus <robin@gareus.org>
Sun, 7 Apr 2019 22:35:00 +0000 (00:35 +0200)
committerRobin Gareus <robin@gareus.org>
Sun, 7 Apr 2019 22:35:00 +0000 (00:35 +0200)
libs/pbd/pbd/stacktrace.h
libs/pbd/stacktrace.cc

index 99fc9d5c574f742e400532f8fb8144928fee9b2c..bf0c20867ab8f379bdae658d1b164e248fd218a2 100644 (file)
@@ -45,71 +45,71 @@ namespace PBD {
 template<typename T>
 class /*LIBPBD_API*/ thing_with_backtrace
 {
-  public:
-    thing_with_backtrace () {
-           trace_twb();
+public:
+       thing_with_backtrace () {
+               trace_twb();
 #ifdef HAVE_EXECINFO
-           allocation_backtrace = new void*[50];
-           allocation_backtrace_size = backtrace (allocation_backtrace, 50);
+               allocation_backtrace = new void*[50];
+               allocation_backtrace_size = backtrace (allocation_backtrace, 50);
 #else
-           allocation_backtrace_size = 0;
+               allocation_backtrace_size = 0;
 #endif
-           Glib::Threads::Mutex::Lock lm (all_mutex);
-           all.push_back (this);
-    }
+               Glib::Threads::Mutex::Lock lm (all_mutex);
+               all.push_back (this);
+       }
 
-    thing_with_backtrace (const thing_with_backtrace<T>& other) {
-           trace_twb();
+       thing_with_backtrace (const thing_with_backtrace<T>& other) {
+               trace_twb();
 #ifdef HAVE_EXECINFO
-           allocation_backtrace = new void*[50];
-           allocation_backtrace_size = backtrace (allocation_backtrace, 50);
+               allocation_backtrace = new void*[50];
+               allocation_backtrace_size = backtrace (allocation_backtrace, 50);
 #else
-           allocation_backtrace_size = 0;
+               allocation_backtrace_size = 0;
 #endif
-           Glib::Threads::Mutex::Lock lm (all_mutex);
-           all.push_back (this);
-    }
-
-    ~thing_with_backtrace() {
-           if (allocation_backtrace_size) {
-                   delete [] allocation_backtrace;
-           }
-           Glib::Threads::Mutex::Lock lm (all_mutex);
-           all.remove (this);
-    }
-
-    thing_with_backtrace<T>& operator= (const thing_with_backtrace<T>& other) {
-           /* no copyable members */
-           return *this;
-    }
-
-    static void peek_a_boo (std::ostream& stream) {
+               Glib::Threads::Mutex::Lock lm (all_mutex);
+               all.push_back (this);
+       }
+
+       ~thing_with_backtrace() {
+               if (allocation_backtrace_size) {
+                       delete [] allocation_backtrace;
+               }
+               Glib::Threads::Mutex::Lock lm (all_mutex);
+               all.remove (this);
+       }
+
+       thing_with_backtrace<T>& operator= (const thing_with_backtrace<T>& other) {
+               /* no copyable members */
+               return *this;
+       }
+
+       static void peek_a_boo (std::ostream& stream) {
 #ifdef HAVE_EXECINFO
-           typename std::list<thing_with_backtrace<T>*>::iterator x;
-           for (x = all.begin(); x != all.end(); ++x) {
-                   char **strings;
-                   size_t i;
-
-                   strings = backtrace_symbols ((*x)->allocation_backtrace, (*x)->allocation_backtrace_size);
-
-                   if (strings) {
-                           stream << "--- ALLOCATED SHARED_PTR @ " << (*x) << std::endl;
-                           for (i = 0; i < (*x)->allocation_backtrace_size && i < 50U; i++) {
-                                   stream << strings[i] << std::endl;
-                           }
-                           free (strings);
-                   }
-           }
+               typename std::list<thing_with_backtrace<T>*>::iterator x;
+               for (x = all.begin(); x != all.end(); ++x) {
+                       char **strings;
+                       size_t i;
+
+                       strings = backtrace_symbols ((*x)->allocation_backtrace, (*x)->allocation_backtrace_size);
+
+                       if (strings) {
+                               stream << "--- ALLOCATED SHARED_PTR @ " << (*x) << std::endl;
+                               for (i = 0; i < (*x)->allocation_backtrace_size && i < 50U; i++) {
+                                       stream << strings[i] << std::endl;
+                               }
+                               free (strings);
+                       }
+               }
 #else
-           stream << "execinfo not defined for this platform" << std::endl;
+               stream << "execinfo not defined for this platform" << std::endl;
 #endif
-    }
+       }
 
 private:
-    void** allocation_backtrace;
-    int allocation_backtrace_size;
-    static std::list<thing_with_backtrace<T>* > all;
-    static Glib::Threads::Mutex all_mutex;
+       void** allocation_backtrace;
+       int allocation_backtrace_size;
+       static std::list<thing_with_backtrace<T>* > all;
+       static Glib::Threads::Mutex all_mutex;
 };
 
 template<typename T> /*LIBPBD_API*/ std::list<PBD::thing_with_backtrace<T> *> PBD::thing_with_backtrace<T>::all;
index 3b308f7db2dea749695a72036706880054d37182..a1af1585dd0b8959c8025c10b5df66f87b05e67c 100644 (file)
@@ -77,48 +77,46 @@ PBD::stacktrace (std::ostream& out, int levels)
 #define CaptureStackBackTrace RtlCaptureStackBackTrace
 
 extern "C" {
-    __declspec(dllimport) USHORT WINAPI CaptureStackBackTrace (
-                                 ULONG  SamplesToSkip,
-                                 ULONG  SamplesToCapture,
-                                 PVOID  *BackTrace,
-                                 PULONG BackTraceHash
-                             );
+       __declspec(dllimport) USHORT WINAPI CaptureStackBackTrace (
+                                    ULONG  FramesToSkip,
+                                    ULONG  FramesToCapture,
+                                    PVOID  *BackTrace,
+                                    PULONG BackTraceHash);
 }
 #endif
 
 void
-PBD::stacktracestd::ostream& out, int)
+PBD::stacktrace (std::ostream& out, int)
 {
 #ifdef DEBUG
        const size_t levels = 62; // does not support more then 62 levels of stacktrace
        unsigned int   i;
        void         * stack[ levels ];
-       unsigned short samples;
+       unsigned short frames;
        SYMBOL_INFO  * symbol;
        HANDLE         process;
 
        process = GetCurrentProcess();
        out << "+++++Backtrace process: " <<  DEBUG_THREAD_SELF << std::endl;
 
-       SymInitialize( process, NULL, TRUE );
+       SymInitialize (process, NULL, TRUE);
 
-       samples               = CaptureStackBackTrace( 0, levels, stack, NULL );
+       frames = CaptureStackBackTrace (0, levels, stack, NULL);
 
-       out << "+++++Backtrace samples: " <<  samples << std::endl;
+       out << "+++++Backtrace frames: " << frames << std::endl;
 
-       symbol               = ( SYMBOL_INFO * )calloc( sizeof( SYMBOL_INFO ) + 256 * sizeof( char ), 1 );
+       symbol               = (SYMBOL_INFO*)calloc (sizeof (SYMBOL_INFO) + 256 * sizeof (char), 1);
        symbol->MaxNameLen   = 255;
-       symbol->SizeOfStruct = sizeof( SYMBOL_INFO );
+       symbol->SizeOfStruct = sizeof (SYMBOL_INFO);
 
-       for( i = 0; i < samples; i++ )
-       {
-               SymFromAddr( process, ( DWORD64 )( stack[ i ] ), 0, symbol );
-               out << string_compose( "%1: %2 - %3\n", samples - i - 1, symbol->Name, symbol->Address );
+       for (i = 0; i < frames; ++i) {
+               SymFromAddr (process, (DWORD64)(stack[i]), 0, symbol);
+               out << string_compose ("%1: %2 - %3\n", samples - i - 1, symbol->Name, symbol->Address);
        }
 
-       out.flush();
+       out.flush ();
 
-       free( symbol );
+       free (symbol);
 #endif
 }