summaryrefslogtreecommitdiff
path: root/libs
diff options
context:
space:
mode:
authorRobin Gareus <robin@gareus.org>2019-04-08 00:35:00 +0200
committerRobin Gareus <robin@gareus.org>2019-04-08 00:35:00 +0200
commite4f18c177161466d28e357bcfc5ad946c6f7634a (patch)
treeaf8872caca55e7c4941fc2533c9a7f08673b5175 /libs
parenteeb2cddd26c67f31318db23cced30aa6c6340e67 (diff)
NO-OP: whitespace & revert samples -> [stack]frames
Diffstat (limited to 'libs')
-rw-r--r--libs/pbd/pbd/stacktrace.h106
-rw-r--r--libs/pbd/stacktrace.cc36
2 files changed, 70 insertions, 72 deletions
diff --git a/libs/pbd/pbd/stacktrace.h b/libs/pbd/pbd/stacktrace.h
index 99fc9d5c57..bf0c20867a 100644
--- a/libs/pbd/pbd/stacktrace.h
+++ b/libs/pbd/pbd/stacktrace.h
@@ -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;
diff --git a/libs/pbd/stacktrace.cc b/libs/pbd/stacktrace.cc
index 3b308f7db2..a1af1585dd 100644
--- a/libs/pbd/stacktrace.cc
+++ b/libs/pbd/stacktrace.cc
@@ -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::stacktrace( std::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
}