In my app, if it crashes on a user, it generates a crash report which gets sent to me.
i have a class that's created on different threads
i want to differentiate between each thread, so i can READ which thread it is by looking at the call stack
in my debug version, the thread stacks look like this:
thread 3 3 com.kjams.kjams 0x001095d4 CSemaphore::wait(long) + 1288 4 com.kjams.kjams 0x00287835 CMutex_ThreadQue::CB_ActualRunQue() + 471 5 com.kjams.kjams 0x00237d71 CMutex_ThreadQue_PushMeta::CB_RunQue() + 17 6 com.kjams.kjams 0x0028547d CMutex_ThreadQue::CB_S_RunQue(void*, long) + 17 7 com.kjams.kjams 0x00286617 CThreads::CB_Fork(APP_ForkInfo*) + 703 8 com.kjams.kjams 0x00286a71 CB_S_Fork_Preemptive(void*) + 25 9 com.kjams.kjams 0x00289ccd boost::detail::thread_data<CFork_Preemptive>::run() + 23 10 libboost_thread.dylib 0x007bca3a thread_proxy + 138 11 libSystem.B.dylib 0x95a6b85d _pthread_start + 345 12 libSystem.B.dylib 0x95a6b6e2 thread_start + 34
3 com.kjams.kjams 0x001095d4 CSemaphore::wait(long) + 1288 4 com.kjams.kjams 0x00287835 CMutex_ThreadQue::CB_ActualRunQue() + 471 5 com.kjams.kjams 0x00237d85 CMutex_ThreadQue_DiscEvent::CB_RunQue() + 17 6 com.kjams.kjams 0x0028547d CMutex_ThreadQue::CB_S_RunQue(void*, long) + 17 7 com.kjams.kjams 0x00286617 CThreads::CB_Fork(APP_ForkInfo*) + 703 8 com.kjams.kjams 0x00286a71 CB_S_Fork_Preemptive(void*) + 25 9 com.kjams.kjams 0x00289ccd boost::detail::thread_data<CFork_Preemptive>::run() + 23 10 libboost_thread.dylib 0x007bca3a thread_proxy + 138 11 libSystem.B.dylib 0x95a6b85d _pthread_start + 345 12 libSystem.B.dylib 0x95a6b6e2 thread_start + 34
see how you can see the difference?
but in the release version, that is optimized out! looks like this:
thread 3 4 com.kjams.kjams 0x001095d4 CSemaphore::wait(long) + 1288 5 com.kjams.kjams 0x00287835 CMutex_ThreadQue::CB_ActualRunQue() + 471 6 com.kjams.kjams 0x0028547d CMutex_ThreadQue::CB_S_RunQue(void*, long) + 17 7 com.kjams.kjams 0x00286617 CThreads::CB_Fork(APP_ForkInfo*) + 703 8 com.kjams.kjams 0x00286a71 CB_S_Fork_Preemptive(void*) + 25 9 com.kjams.kjams 0x00289ccd boost::detail::thread_data<CFork_Preemptive>::run() + 23 10 libboost_thread.dylib 0x007bca3a thread_proxy + 138 11 libSystem.B.dylib 0x95a6b85d _pthread_start + 345 12 libSystem.B.dylib 0x95a6b6e2 thread_start + 34
4 com.kjams.kjams 0x001095d4 CSemaphore::wait(long) + 1288 5 com.kjams.kjams 0x00287835 CMutex_ThreadQue::CB_ActualRunQue() + 471 6 com.kjams.kjams 0x0028547d CMutex_ThreadQue::CB_S_RunQue(void*, long) + 17 7 com.kjams.kjams 0x00286617 CThreads::CB_Fork(APP_ForkInfo*) + 703 8 com.kjams.kjams 0x00286a71 CB_S_Fork_Preemptive(void*) + 25 9 com.kjams.kjams 0x00289ccd boost::detail::thread_data<CFork_Preemptive>::run() + 23 10 libboost_thread.dylib 0x007bca3a thread_proxy + 138 11 libSystem.B.dylib 0x95a6b85d _pthread_start + 345 12 libSystem.B.dylib 0x95a6b6e2 thread_start + 34
looks the same. :( so i tried really hard to force it to NOT inline:
class CMutex_ThreadQue_PushMeta : public CMutex_ThreadQue { #pragma no_inline void CB_RunQue() __attribute__ ((noinline)) { CB_ActualRunQue(); } #pragma inline
public: CMutex_ThreadQue_PushMeta() : CMutex_ThreadQue("Push Meta Que", false, true) {} };
i also tried turning off "inline methods hidden" all TO NO AVAIL! so maybe this isn't an inlining issue?
so then i tried turning down the optimizations: started with: -Os - fail
so, i have to dial down all the way to -O1?
this is for my release app, so i'd definitely rather not do that.
is there any way i can keep "-Os" and still see that function name in the call stack of each thread?
|