WIP: Don't send many outstanding threads requests
This commit is contained in:
parent
ba456e863d
commit
305309dcb1
1 changed files with 27 additions and 10 deletions
|
|
@ -42,6 +42,9 @@ class StackTraceView( object ):
|
||||||
# AWAIT_CONNECTION -- OnServerReady / RequestThreads --> REQUESTING_THREADS
|
# AWAIT_CONNECTION -- OnServerReady / RequestThreads --> REQUESTING_THREADS
|
||||||
# REQUESTING -- OnGotThreads / RequestScopes --> REQUESTING_SCOPES
|
# REQUESTING -- OnGotThreads / RequestScopes --> REQUESTING_SCOPES
|
||||||
#
|
#
|
||||||
|
# When we attach using gdbserver, this whole thing breaks because we request
|
||||||
|
# the threads over and over and get duff data back on later threads.
|
||||||
|
self._requesting_threads = False
|
||||||
|
|
||||||
|
|
||||||
def GetCurrentThreadId( self ):
|
def GetCurrentThreadId( self ):
|
||||||
|
|
@ -58,7 +61,8 @@ class StackTraceView( object ):
|
||||||
utils.ClearBuffer( self._buf )
|
utils.ClearBuffer( self._buf )
|
||||||
|
|
||||||
def ConnectionUp( self, connection ):
|
def ConnectionUp( self, connection ):
|
||||||
self._connection = connection
|
self._connection = connection
|
||||||
|
self._requesting_threads = False
|
||||||
|
|
||||||
def ConnectionClosed( self ):
|
def ConnectionClosed( self ):
|
||||||
self.Clear()
|
self.Clear()
|
||||||
|
|
@ -69,26 +73,38 @@ class StackTraceView( object ):
|
||||||
# TODO: delete the buffer ?
|
# TODO: delete the buffer ?
|
||||||
|
|
||||||
def LoadThreads( self, infer_current_frame ):
|
def LoadThreads( self, infer_current_frame ):
|
||||||
|
pending_request = False
|
||||||
|
if self._requesting_threads:
|
||||||
|
pending_request = True
|
||||||
|
return
|
||||||
|
|
||||||
def consume_threads( message ):
|
def consume_threads( message ):
|
||||||
self._threads.clear()
|
self._requesting_threads = False
|
||||||
|
|
||||||
if not message[ 'body' ][ 'threads' ]:
|
if not message[ 'body' ][ 'threads' ]:
|
||||||
# This is a protocol error. It is required to return at least one!
|
if pending_request:
|
||||||
utils.UserMessage( 'Server returned no threads. Is it running?',
|
# We may have hit a thread event, so try again.
|
||||||
persist = True )
|
self.LoadThreads( infer_current_frame )
|
||||||
return
|
return
|
||||||
|
else:
|
||||||
|
# This is a protocol error. It is required to return at least one!
|
||||||
|
utils.UserMessage( 'Server returned no threads. Is it running?',
|
||||||
|
persist = True )
|
||||||
|
|
||||||
|
self._threads.clear()
|
||||||
|
|
||||||
for thread in message[ 'body' ][ 'threads' ]:
|
for thread in message[ 'body' ][ 'threads' ]:
|
||||||
self._threads.append( thread )
|
self._threads.append( thread )
|
||||||
|
|
||||||
if infer_current_frame and thread[ 'id' ] == self._currentThread:
|
if infer_current_frame and thread[ 'id' ] == self._currentThread:
|
||||||
self._LoadStackTrace( thread, True )
|
self._LoadStackTrace( thread, True )
|
||||||
elif infer_current_frame and not self._currentThread:
|
elif infer_current_frame and self._currentThread is None:
|
||||||
self._currentThread = thread[ 'id' ]
|
self._currentThread = thread[ 'id' ]
|
||||||
self._LoadStackTrace( thread, True )
|
self._LoadStackTrace( thread, True )
|
||||||
|
|
||||||
self._DrawThreads()
|
self._DrawThreads()
|
||||||
|
|
||||||
|
self._requesting_threads = True
|
||||||
self._connection.DoRequest( consume_threads, {
|
self._connection.DoRequest( consume_threads, {
|
||||||
'command': 'threads',
|
'command': 'threads',
|
||||||
} )
|
} )
|
||||||
|
|
@ -155,7 +171,7 @@ class StackTraceView( object ):
|
||||||
elif event.get( 'allThreadsStopped', False ) and self._threads:
|
elif event.get( 'allThreadsStopped', False ) and self._threads:
|
||||||
self._currentThread = self._threads[ 0 ][ 'id' ]
|
self._currentThread = self._threads[ 0 ][ 'id' ]
|
||||||
|
|
||||||
if self._currentThread:
|
if self._currentThread is not None:
|
||||||
for thread in self._threads:
|
for thread in self._threads:
|
||||||
if thread[ 'id' ] == self._currentThread:
|
if thread[ 'id' ] == self._currentThread:
|
||||||
self._LoadStackTrace( thread, True )
|
self._LoadStackTrace( thread, True )
|
||||||
|
|
@ -165,10 +181,11 @@ class StackTraceView( object ):
|
||||||
|
|
||||||
def OnThreadEvent( self, event ):
|
def OnThreadEvent( self, event ):
|
||||||
if event[ 'reason' ] == 'started' and self._currentThread is None:
|
if event[ 'reason' ] == 'started' and self._currentThread is None:
|
||||||
|
self._currentThread = event[ 'threadId' ]
|
||||||
self.LoadThreads( True )
|
self.LoadThreads( True )
|
||||||
|
|
||||||
def Continue( self ):
|
def Continue( self ):
|
||||||
if not self._currentThread:
|
if self._currentThread is None:
|
||||||
utils.UserMessage( 'No current thread', persist = True )
|
utils.UserMessage( 'No current thread', persist = True )
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
@ -183,7 +200,7 @@ class StackTraceView( object ):
|
||||||
self.LoadThreads( True )
|
self.LoadThreads( True )
|
||||||
|
|
||||||
def Pause( self ):
|
def Pause( self ):
|
||||||
if not self._currentThread:
|
if self._currentThread is None:
|
||||||
utils.UserMessage( 'No current thread', persist = True )
|
utils.UserMessage( 'No current thread', persist = True )
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue