Add some possibly-useful markers for debugging threads from coredumps.
authorCarl Hetherington <cth@carlh.net>
Tue, 20 Apr 2021 10:27:40 +0000 (12:27 +0200)
committerCarl Hetherington <cth@carlh.net>
Tue, 20 Apr 2021 22:52:07 +0000 (00:52 +0200)
src/lib/butler.cc
src/lib/encode_server_finder.cc
src/lib/hints.cc
src/lib/j2k_encoder.cc
src/lib/job.cc
src/lib/job_manager.cc
src/lib/util.cc
src/lib/util.h
src/lib/writer.cc
src/wx/gl_video_view.cc

index 37e8c95443021e3c7d70c174e3839f12fbcb24fa..6de5d57904efb7ecb32dfb167aff7f9112db953d 100644 (file)
@@ -179,6 +179,8 @@ void
 Butler::thread ()
 try
 {
+       start_of_thread ("Butler");
+
        while (true) {
                boost::mutex::scoped_lock lm (_mutex);
 
index 396d67623d6801d4cad459b7c59931ff5dab3139..2fab210c94838fe03e53a77ebea5ab0efcb87f87 100644 (file)
@@ -96,6 +96,8 @@ void
 EncodeServerFinder::search_thread ()
 try
 {
+       start_of_thread ("EncodeServerFinder-search");
+
        boost::system::error_code error;
        boost::asio::io_service io_service;
        boost::asio::ip::udp::socket socket (io_service);
@@ -168,6 +170,8 @@ catch (...)
 void
 EncodeServerFinder::listen_thread ()
 try {
+       start_of_thread ("EncodeServerFinder-listen");
+
        using namespace boost::asio::ip;
 
        try {
index b23f32238182e1f603655ada06a2e24d51bc1807..52debf3ef313c44f3d4b745810e2964fe28cb28e 100644 (file)
@@ -370,6 +370,8 @@ void
 Hints::thread ()
 try
 {
+       start_of_thread ("Hints");
+
        auto film = _film.lock ();
        if (!film) {
                return;
index c2553854bf5241e193e139987c1f6503956f7892..5dee5ca35af998c07ed1ebcc76684b25c946563c 100644 (file)
@@ -283,6 +283,8 @@ void
 J2KEncoder::encoder_thread (optional<EncodeServerDescription> server)
 try
 {
+       start_of_thread ("J2KEncoder");
+
        if (server) {
                LOG_TIMING ("start-encoder-thread thread=%1 server=%2", thread_id (), server->host_name ());
        } else {
index b1ff0fb32f23f82134fb3b461e4a821cfa5d50ba..b0ca8a7375b5679718efb13a58c6762831e7cbe9 100644 (file)
@@ -95,6 +95,8 @@ Job::start ()
 void
 Job::run_wrapper ()
 {
+       start_of_thread (String::compose("Job-%1", json_name()));
+
        try {
 
                run ();
index 2839bce30c379f8c98c85cffe5af54e0bd36cb50..4ed360bed4b913b595f2ff4184816a6032690a0c 100644 (file)
@@ -153,6 +153,8 @@ JobManager::errors () const
 void
 JobManager::scheduler ()
 {
+       start_of_thread ("JobManager");
+
        while (true) {
 
                boost::mutex::scoped_lock lm (_mutex);
index d3511e8c7e34e0b1c5f5744147b18d83fb944837..65bfd4534b4b9ae51be736e258275e306e5d341c 100644 (file)
@@ -1176,3 +1176,20 @@ to_upper (string s)
        return s;
 }
 
+
+/* Set to 1 to print the IDs of some of our threads to stdout on creation */
+#define DCPOMATIC_DEBUG_THREADS 0
+
+#if DCPOMATIC_DEBUG_THREADS
+void
+start_of_thread (string name)
+{
+       std::cout << "THREAD:" << name << ":" << std::hex << pthread_self() << "\n";
+}
+#else
+void
+start_of_thread (string)
+{
+
+}
+#endif
index 7f8106f3c543775bfb10e62a04c00af7422fa9bd..a6b010e43a6011c9e256af37e2489b79173cc609 100644 (file)
@@ -123,6 +123,7 @@ extern dcp::Size scale_for_display (dcp::Size s, dcp::Size display_container, dc
 extern dcp::DecryptedKDM decrypt_kdm_with_helpful_error (dcp::EncryptedKDM kdm);
 extern boost::filesystem::path default_font_file ();
 extern std::string to_upper (std::string s);
+extern void start_of_thread (std::string name);
 
 template <class T>
 std::list<T>
index 81b77d5cea62a5219257368af0711660e69ccfcf..7208402e45704002fc3f635bd2d3e16755ff47b4 100644 (file)
@@ -393,6 +393,8 @@ void
 Writer::thread ()
 try
 {
+       start_of_thread ("Writer");
+
        while (true)
        {
                boost::mutex::scoped_lock lock (_state_mutex);
index 076cb49ecedf2ec2a0fccdc13d0cb202c8504c7a..ad0ff38a741027bf57fc5de81762742a7a54f0a9 100644 (file)
@@ -356,6 +356,8 @@ void
 GLVideoView::thread ()
 try
 {
+       start_of_thread ("GLVideoView");
+
        {
                boost::mutex::scoped_lock lm (_canvas_mutex);