proxygen
deadlock.Deadlock Class Reference
Inheritance diagram for deadlock.Deadlock:

Public Member Functions

def __init__ (self)
 
def invoke (self, arg, from_tty)
 

Detailed Description

Detects deadlocks

Definition at line 397 of file deadlock.py.

Constructor & Destructor Documentation

def deadlock.Deadlock.__init__ (   self)

Definition at line 400 of file deadlock.py.

400  def __init__(self):
401  super(Deadlock, self).__init__('deadlock', gdb.COMMAND_NONE)
402 
def __init__(self)
Definition: deadlock.py:400

Member Function Documentation

def deadlock.Deadlock.invoke (   self,
  arg,
  from_tty 
)
Prints the threads and mutexes in a deadlock, if it exists.

Definition at line 403 of file deadlock.py.

References deadlock.find_cycle(), deadlock.get_thread_info(), and deadlock.print_cycle().

403  def invoke(self, arg, from_tty):
404  '''Prints the threads and mutexes in a deadlock, if it exists.'''
405  lwp_to_thread_id, blocked_threads = get_thread_info()
406 
407  # Nodes represent threads. Edge (A,B) exists if thread A
408  # is waiting on a mutex held by thread B.
409  graph = DiGraph()
410 
411  # Go through all the blocked threads and see which threads
412  # they are blocked on, and build the thread wait graph.
413  for thread_lwp, mutex_type in blocked_threads.items():
414  get_owner_and_address_func = \
415  MutexType.get_mutex_owner_and_address_func_for_type(mutex_type)
416  if not get_owner_and_address_func:
417  continue
418  mutex_owner_lwp, mutex_address = get_owner_and_address_func(
419  lwp_to_thread_id, thread_lwp
420  )
421  if mutex_owner_lwp and mutex_address:
422  graph.add_edge(
423  thread_lwp,
424  mutex_owner_lwp,
425  mutex=mutex_address,
426  mutex_type=mutex_type
427  )
428 
429  # A deadlock exists if there is a cycle in the graph.
430  cycle = find_cycle(graph)
431  if cycle:
432  print('Found deadlock!')
433  print_cycle(graph, lwp_to_thread_id, cycle)
434  else:
435  print(
436  'No deadlock detected. '
437  'Do you have debug symbols installed?'
438  )
439 
440 
def get_thread_info()
Definition: deadlock.py:313
def print_cycle(graph, lwp_to_thread_id, cycle)
Definition: deadlock.py:300
def invoke(self, arg, from_tty)
Definition: deadlock.py:403
def find_cycle(graph)
Definition: deadlock.py:213

The documentation for this class was generated from the following file: