Mercurial > hg > truffle
comparison src/os/bsd/vm/os_bsd.cpp @ 8023:758935f7c23f
8006423: SA: NullPointerException in sun.jvm.hotspot.debugger.bsd.BsdThread.getContext(BsdThread.java:67)
Summary: Do not rely on mach thread port names to identify threads from SA
Reviewed-by: dholmes, minqi, rbackman
author | sla |
---|---|
date | Fri, 08 Feb 2013 12:48:24 +0100 |
parents | 22ba8c8ce6a6 |
children | 5cd2fac2ae70 |
comparison
equal
deleted
inserted
replaced
8021:8d9fc28831cc | 8023:758935f7c23f |
---|---|
655 typedef void (*objc_registerThreadWithCollector_t)(); | 655 typedef void (*objc_registerThreadWithCollector_t)(); |
656 extern "C" objc_registerThreadWithCollector_t objc_registerThreadWithCollectorFunction; | 656 extern "C" objc_registerThreadWithCollector_t objc_registerThreadWithCollectorFunction; |
657 objc_registerThreadWithCollector_t objc_registerThreadWithCollectorFunction = NULL; | 657 objc_registerThreadWithCollector_t objc_registerThreadWithCollectorFunction = NULL; |
658 #endif | 658 #endif |
659 | 659 |
660 #ifdef __APPLE__ | |
661 static uint64_t locate_unique_thread_id() { | |
662 // Additional thread_id used to correlate threads in SA | |
663 thread_identifier_info_data_t m_ident_info; | |
664 mach_msg_type_number_t count = THREAD_IDENTIFIER_INFO_COUNT; | |
665 | |
666 thread_info(::mach_thread_self(), THREAD_IDENTIFIER_INFO, | |
667 (thread_info_t) &m_ident_info, &count); | |
668 return m_ident_info.thread_id; | |
669 } | |
670 #endif | |
671 | |
660 // Thread start routine for all newly created threads | 672 // Thread start routine for all newly created threads |
661 static void *java_start(Thread *thread) { | 673 static void *java_start(Thread *thread) { |
662 // Try to randomize the cache line index of hot stack frames. | 674 // Try to randomize the cache line index of hot stack frames. |
663 // This helps when threads of the same stack traces evict each other's | 675 // This helps when threads of the same stack traces evict each other's |
664 // cache lines. The threads can be either from the same JVM instance, or | 676 // cache lines. The threads can be either from the same JVM instance, or |
683 } | 695 } |
684 | 696 |
685 #ifdef __APPLE__ | 697 #ifdef __APPLE__ |
686 // thread_id is mach thread on macos | 698 // thread_id is mach thread on macos |
687 osthread->set_thread_id(::mach_thread_self()); | 699 osthread->set_thread_id(::mach_thread_self()); |
700 osthread->set_unique_thread_id(locate_unique_thread_id()); | |
688 #else | 701 #else |
689 // thread_id is pthread_id on BSD | 702 // thread_id is pthread_id on BSD |
690 osthread->set_thread_id(::pthread_self()); | 703 osthread->set_thread_id(::pthread_self()); |
691 #endif | 704 #endif |
692 // initialize signal mask for this thread | 705 // initialize signal mask for this thread |
845 } | 858 } |
846 | 859 |
847 // Store pthread info into the OSThread | 860 // Store pthread info into the OSThread |
848 #ifdef __APPLE__ | 861 #ifdef __APPLE__ |
849 osthread->set_thread_id(::mach_thread_self()); | 862 osthread->set_thread_id(::mach_thread_self()); |
863 osthread->set_unique_thread_id(locate_unique_thread_id()); | |
850 #else | 864 #else |
851 osthread->set_thread_id(::pthread_self()); | 865 osthread->set_thread_id(::pthread_self()); |
852 #endif | 866 #endif |
853 osthread->set_pthread_id(::pthread_self()); | 867 osthread->set_pthread_id(::pthread_self()); |
854 | 868 |