90 likes | 235 Views
TPTP 4.4 Thread Profiler Pause/Resume and Attach/Detach Design. Asaf Yaffe Software and Solutions Group Intel Corporation. Agenda. Requirements Martini Runtime Enhancements Thread Profiler Design Changes. Requirements.
E N D
TPTP 4.4 Thread Profiler Pause/Resume and Attach/Detach Design Asaf Yaffe Software and Solutions Group Intel Corporation
Agenda • Requirements • Martini Runtime Enhancements • Thread Profiler Design Changes
Requirements • Support pause/resume and attach/detach commands available in the Profiling Monitor view of the Eclipse Client • Attach • Create a new profiling session • Update all views to reflect up-to-date thread information • Thread “start time” is the attach time • Current state, current stack, wait information (for waiting threads), etc… • Detach • Terminate the profiling session • Do not terminate the profiled application • Pause/resume • During pause – profiler does not transmit data to the client • On Resume – all views are updated to reflect up-to-date thread information
Martini Runtime Enhancements • New data items in GetThreadInfo • DR_THREAD_STATE: Returns one of the following thread states: Unstarted, Running, Sleeping, Blocked (on monitor lock), Waiting (Object.wait), Terminated • DR_CURRENT_MONITOR: Returns the id of the object (if any) whose monitor the thread is waiting for • New API – GetAllThreadsInfo • Similar to GetThreadInfo, but returns the information for all live threads instead of a specific thread • Supports the following data items for each thread: • Thread id • Thread name (optional) • Thread group (optional) • Thread parent group (optional) • Current stack trace (optional) • Thread state (optional)
Thread Profiler Initialization (MPICL_Instantiate) • Register for all the necessary events (thread start, thread end, all monitor events) • If started in “enabled” (detached) mode • Disable the EG_MONITOR event group • Ignore all incoming THREAD_START and THREAD_END events until an “attach” command is received
Processing the “attach” Command • Call GetAllThreadsInfo to obtain a list of all living threads • For each thread in state other than Unstarted: • Write a <threadStart> element to the data channel • Do the following based on the thread’s state: • Enable the EG_MONITOR event group and resume the processing of THREAD_START and THREAD_END events
Processing the “detach” Command • Disable the EG_MONITOR event group • Ignore all incoming THREAD_START and THREAD_END events until an “attach” command is received
Processing the “pause” and “resume” Commands • When “pause” command is received • Stop writing data to the data channel • Keep processing events, and remember the last event received for each thread • When “resume” command is received • Write the element corresponding to the last event received for each thread. Update the timestamp of the event to the time of the “resume” • Resume writing to the data channel