diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2006-02-15 15:55:48 +0000 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2006-02-15 15:55:48 +0000 |
commit | ae14f6c7eb9564d8b644a7c6a376f1c202870cd1 (patch) | |
tree | 524134ecad48d1abb08359e228425b5ded7701f9 | |
parent | 69c9f3d7ce4643c75e1490661d51247b699b606a (diff) |
new stacktrace function in libpbd3; variable size GUI request thread queues
git-svn-id: svn://localhost/trunk/ardour2@330 d708f5d6-7413-0410-9779-e7cbd77b26cf
-rw-r--r-- | libs/ardour/audioengine.cc | 2 | ||||
-rw-r--r-- | libs/ardour/session_midi.cc | 2 | ||||
-rw-r--r-- | libs/gtkmm2ext/gtk_ui.cc | 10 | ||||
-rw-r--r-- | libs/gtkmm2ext/gtkmm2ext/gtk_ui.h | 2 | ||||
-rw-r--r-- | libs/pbd3/SConscript | 3 | ||||
-rw-r--r-- | libs/pbd3/pbd/pthread_utils.h | 1 | ||||
-rw-r--r-- | libs/pbd3/pbd/stacktrace.h | 10 | ||||
-rw-r--r-- | libs/pbd3/pthread_utils.cc | 2 | ||||
-rw-r--r-- | libs/pbd3/stacktrace.cc | 42 |
9 files changed, 71 insertions, 3 deletions
diff --git a/libs/ardour/audioengine.cc b/libs/ardour/audioengine.cc index e3c9549663..c64b4d6429 100644 --- a/libs/ardour/audioengine.cc +++ b/libs/ardour/audioengine.cc @@ -80,7 +80,7 @@ _thread_init_callback (void *arg) knows about it. */ - PBD::ThreadCreated (pthread_self(), X_("Audioengine")); + PBD::ThreadCreatedWithRequestSize (pthread_self(), X_("Audioengine"), 4096); #ifdef VST_SUPPORT if (Config->get_use_vst()) { diff --git a/libs/ardour/session_midi.cc b/libs/ardour/session_midi.cc index 2b7afa354a..b2b1d263a7 100644 --- a/libs/ardour/session_midi.cc +++ b/libs/ardour/session_midi.cc @@ -1272,7 +1272,7 @@ Session::midi_thread_work () bool restart; vector<MIDI::Port*> ports; - PBD::ThreadCreated (pthread_self(), X_("MIDI")); + PBD::ThreadCreatedWithRequestSize (pthread_self(), X_("MIDI"), 2048); memset (&rtparam, 0, sizeof (rtparam)); rtparam.sched_priority = 9; /* XXX should be relative to audio (JACK) thread */ diff --git a/libs/gtkmm2ext/gtk_ui.cc b/libs/gtkmm2ext/gtk_ui.cc index 1a46e1b900..8dd5a18526 100644 --- a/libs/gtkmm2ext/gtk_ui.cc +++ b/libs/gtkmm2ext/gtk_ui.cc @@ -31,6 +31,7 @@ #include <pbd/touchable.h> #include <pbd/failed_constructor.h> #include <pbd/pthread_utils.h> +#include <pbd/stacktrace.h> #include <gtkmm2ext/gtk_ui.h> #include <gtkmm2ext/textviewer.h> @@ -59,6 +60,7 @@ UI::UI (string name, int *argc, char ***argv, string rcfile) } PBD::ThreadCreated.connect (mem_fun (*this, &UI::register_thread)); + PBD::ThreadCreatedWithRequestSize.connect (mem_fun (*this, &UI::register_thread_with_request_count)); _ok = false; _active = false; @@ -370,7 +372,13 @@ UI::timeout_add (unsigned int timeout, int (*func)(void *), void *arg) void UI::register_thread (pthread_t thread_id, string name) { - RingBufferNPT<Request>* b = new RingBufferNPT<Request> (128); + register_thread_with_request_count (thread_id, name, 256); +} + +void +UI::register_thread_with_request_count (pthread_t thread_id, string name, uint32_t num_requests) +{ + RingBufferNPT<Request>* b = new RingBufferNPT<Request> (num_requests); { PBD::LockMonitor lm (request_buffer_map_lock, __LINE__, __FILE__); diff --git a/libs/gtkmm2ext/gtkmm2ext/gtk_ui.h b/libs/gtkmm2ext/gtkmm2ext/gtk_ui.h index 1ea4515284..4e63af7924 100644 --- a/libs/gtkmm2ext/gtkmm2ext/gtk_ui.h +++ b/libs/gtkmm2ext/gtkmm2ext/gtk_ui.h @@ -70,7 +70,9 @@ class UI : public AbstractUI void call_slot_locked (sigc::slot<void>); void touch_display (Touchable *); void receive (Transmitter::Channel, const char *); + void register_thread (pthread_t, string); + void register_thread_with_request_count (pthread_t, string, uint32_t num_requests); bool caller_is_gui_thread () { return pthread_equal (gui_thread, pthread_self()); diff --git a/libs/pbd3/SConscript b/libs/pbd3/SConscript index f4b7bf24a8..995bc8b933 100644 --- a/libs/pbd3/SConscript +++ b/libs/pbd3/SConscript @@ -18,6 +18,7 @@ pathscanner.cc pool.cc pthread_utils.cc receiver.cc +stacktrace.cc strsplit.cc textreceiver.cc transmitter.cc @@ -31,6 +32,8 @@ xml++.cc conf = Configure(pbd3) if conf.CheckFunc('getmntent'): conf.env.Append(CCFLAGS="-DHAVE_GETMNTENT") +if conf.CheckCHeader('execinfo.h'): + conf.env.Append(CXXFLAGS="-DHAVE_EXECINFO") pbd3 = conf.Finish() pbd3.Merge ([ libraries['sigc2'], libraries['xml'] ]) diff --git a/libs/pbd3/pbd/pthread_utils.h b/libs/pbd3/pbd/pthread_utils.h index 9c7cefd3e4..258604fc74 100644 --- a/libs/pbd3/pbd/pthread_utils.h +++ b/libs/pbd3/pbd/pthread_utils.h @@ -16,6 +16,7 @@ std::string pthread_name (); namespace PBD { extern sigc::signal<void,pthread_t,std::string> ThreadCreated; + extern sigc::signal<void,pthread_t,std::string,uint32_t> ThreadCreatedWithRequestSize; } #endif /* __pbd_pthread_utils__ */ diff --git a/libs/pbd3/pbd/stacktrace.h b/libs/pbd3/pbd/stacktrace.h new file mode 100644 index 0000000000..d7278bd35a --- /dev/null +++ b/libs/pbd3/pbd/stacktrace.h @@ -0,0 +1,10 @@ +#ifndef __libpbd_stacktrace_h__ +#define __libpbd_stacktrace_h__ + +#include <ostream> + +namespace PBD { + void stacktrace (std::ostream& out); +} + +#endif /* __libpbd_stacktrace_h__ */ diff --git a/libs/pbd3/pthread_utils.cc b/libs/pbd3/pthread_utils.cc index 6ef29e3605..1fc9227ba5 100644 --- a/libs/pbd3/pthread_utils.cc +++ b/libs/pbd3/pthread_utils.cc @@ -21,6 +21,7 @@ #include <map> #include <iostream> #include <string> +#include <stdint.h> #include <pbd/pthread_utils.h> @@ -34,6 +35,7 @@ static pthread_mutex_t thread_map_lock = PTHREAD_MUTEX_INITIALIZER; namespace PBD { sigc::signal<void,pthread_t,std::string> ThreadCreated; + sigc::signal<void,pthread_t,std::string,uint32_t> ThreadCreatedWithRequestSize; } using namespace PBD; diff --git a/libs/pbd3/stacktrace.cc b/libs/pbd3/stacktrace.cc new file mode 100644 index 0000000000..1e7dfa08e9 --- /dev/null +++ b/libs/pbd3/stacktrace.cc @@ -0,0 +1,42 @@ +#include <pbd/stacktrace.h> +#include <iostream> + +/* Obtain a backtrace and print it to stdout. */ + +#ifdef HAVE_EXECINFO + +#include <execinfo.h> +#include <stdlib.h> + +void +PBD::stacktrace (std::ostream& out) +{ + void *array[200]; + size_t size; + char **strings; + size_t i; + + size = backtrace (array, 200); + strings = backtrace_symbols (array, size); + + if (strings) { + + printf ("Obtained %zd stack frames.\n", size); + + for (i = 0; i < size; i++) { + out << strings[i] << std::endl; + } + + free (strings); + } +} + +#else + +void +PBD::stacktrace (std::ostream& out) +{ + out << "stack tracing is not enabled on this platform" << std::endl; +} + +#endif /* HAVE_EXECINFO */ |