Add offset support, sort of

This commit is contained in:
Ben Jackson 2021-06-08 22:45:59 +01:00
commit 4d4f85233d
2 changed files with 15 additions and 4 deletions

View file

@ -295,7 +295,7 @@ class CodeView( object ):
return self._terminal.buffer_number return self._terminal.buffer_number
def ShowMemory( self, memoryReference, length, msg ): def ShowMemory( self, memoryReference, length, offset, msg ):
if not self._window.valid: if not self._window.valid:
return False return False
@ -308,7 +308,8 @@ class CodeView( object ):
# equivalent output of say xxd # equivalent output of say xxd
data = msg.get( 'body', {} ).get( 'data', '' ) data = msg.get( 'body', {} ).get( 'data', '' )
utils.SetBufferContents( buf, [ utils.SetBufferContents( buf, [
f'Memory Dump for Reference {memoryReference} Length: {length} bytes', f'Memory Dump for Reference {memoryReference} Length: {length} bytes'
f' Offset: {offset}',
'-' * 80, '-' * 80,
'Offset Bytes Text', 'Offset Bytes Text',
'-' * 80, '-' * 80,
@ -318,3 +319,6 @@ class CodeView( object ):
utils.SetSyntax( '', 'xxd', buf ) utils.SetSyntax( '', 'xxd', buf )
utils.JumpToWindow( self._window ) utils.JumpToWindow( self._window )
utils.OpenFileInCurrentWindow( buf_name ) utils.OpenFileInCurrentWindow( buf_name )
# TODO: Need to set up some mappings here that allow the user to browse
# around by setting the offset

View file

@ -536,7 +536,7 @@ class DebugSession( object ):
self._variablesView.SetVariableValue( new_value, buf, line_num ) self._variablesView.SetVariableValue( new_value, buf, line_num )
@IfConnected() @IfConnected()
def ReadMemory( self, buf = None, line_num = None ): def ReadMemory( self, offset = None, buf = None, line_num = None ):
if not self._server_capabilities.get( 'supportsReadMemoryRequest' ): if not self._server_capabilities.get( 'supportsReadMemoryRequest' ):
utils.UserMessage( "Server does not support memory request", utils.UserMessage( "Server does not support memory request",
error = True ) error = True )
@ -554,15 +554,22 @@ class DebugSession( object ):
if length is None: if length is None:
return return
offset = utils.AskForInput( 'Location offset? ',
default_value = '0' )
if offset is None:
return
def handler( msg ): def handler( msg ):
self._codeView.ShowMemory( memoryReference, length, msg ) self._codeView.ShowMemory( memoryReference, length, offset, msg )
self._connection.DoRequest( handler, { self._connection.DoRequest( handler, {
'command': 'readMemory', 'command': 'readMemory',
'arguments': { 'arguments': {
'memoryReference': memoryReference, 'memoryReference': memoryReference,
'count': int( length ), 'count': int( length ),
'offset': int( offset )
} }
} ) } )