Skip to content

Commit

Permalink
Merge pull request #107 from puremourning/fixups
Browse files Browse the repository at this point in the history
Improve workflow for launching vimspector from scripts
  • Loading branch information
mergify[bot] authored Jan 31, 2020
2 parents c1851a3 + 018ae05 commit 9c18f3e
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 10 deletions.
26 changes: 16 additions & 10 deletions python3/vimspector/debug_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,12 @@ def splitext( p ):
# working directory.
'cwd': os.getcwd(),
}

# Pretend that vars passed to the launch command were typed in by the user
# (they may have been in theory)
USER_CHOICES.update( launch_variables )
self._variables.update( launch_variables )

self._variables.update(
utils.ParseVariables( adapter.get( 'variables', {} ),
self._variables,
Expand All @@ -180,12 +186,6 @@ def splitext( p ):
self._variables,
USER_CHOICES ) )

# Pretend that vars passed to the launch command were typed in by the user
# (they may have been in theory)
# TODO: Is it right that we do this _after_ ParseVariables, rather than
# before ?
USER_CHOICES.update( launch_variables )
self._variables.update( launch_variables )

utils.ExpandReferencesInDict( configuration,
self._variables,
Expand Down Expand Up @@ -268,7 +268,6 @@ def wrapper(self, *args, **kwargs):
return fct(self, *args, **kwargs)
return wrapper

@IfConnected
def OnChannelData( self, data ):
self._connection.OnData( data )

Expand All @@ -279,7 +278,6 @@ def OnServerStderr( self, data ):
self._outputView.Print( 'server', data )


@IfConnected
def OnRequestTimeout( self, timer_id ):
self._connection.OnRequestTimeout( timer_id )

Expand Down Expand Up @@ -365,20 +363,25 @@ def Continue( self ):
def Pause( self ):
self._stackTraceView.Pause()

@IfConnected
def ExpandVariable( self ):
self._variablesView.ExpandVariable()

@IfConnected
def AddWatch( self, expression ):
self._variablesView.AddWatch( self._stackTraceView.GetCurrentFrame(),
expression )

@IfConnected
def EvaluateConsole( self, expression ):
self._outputView.Evaluate( self._stackTraceView.GetCurrentFrame(),
expression )

@IfConnected
def DeleteWatch( self ):
self._variablesView.DeleteWatch()

@IfConnected
def ShowBalloon( self, winnr, expression ):
"""Proxy: ballonexpr -> variables.ShowBallon"""
frame = self._stackTraceView.GetCurrentFrame()
Expand All @@ -397,6 +400,7 @@ def ShowBalloon( self, winnr, expression ):
# Return variable aware function
return self._variablesView.ShowBalloon( frame, expression )

@IfConnected
def ExpandFrameOrThread( self ):
self._stackTraceView.ExpandFrameOrThread()

Expand Down Expand Up @@ -601,8 +605,10 @@ def _PrepareAttach( self, adapter_config, launch_config ):
self._outputView.RunJobWithOutput( 'Remote', cmd )
else:
if atttach_config[ 'pidSelect' ] == 'ask':
pid = utils.AskForInput( 'Enter PID to attach to: ' )
launch_config[ atttach_config[ 'pidProperty' ] ] = pid
prop = atttach_config[ 'pidProperty' ]
if prop not in launch_config:
pid = utils.AskForInput( 'Enter PID to attach to: ' )
launch_config[ prop ] = pid
return
elif atttach_config[ 'pidSelect' ] == 'none':
return
Expand Down
13 changes: 13 additions & 0 deletions support/test/example/attach.vim
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
if argc() < 2
echom 'Usage:' v:argv[ 0 ] 'processName binary'
cquit!
endif

setfiletype cpp
call vimspector#LaunchWithSettings( #{
\ configuration: "C++ - Attach Local Process",
\ processName: argv( 0 ),
\ binary: argv( 1 ),
\ } )

1,2argd
24 changes: 24 additions & 0 deletions support/test/example/cpp.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"configurations": {
"C++ - Attach Local Process": {
"adapter": "vscode-cpptools",
"variables": {
"PID": {
"shell": [ "GetPIDForProcess", "${processName}" ]
}
},
"configuration": {
"name": "test",
"request": "attach",
"program": "${binary}",
"processId": "${PID}",

"type": "cppdbg",
"stopAtEntry": true,
"setupCommands": [
{ "text": "source ${initFile}", "ignoreFailures": true }
]
}
}
}
}

0 comments on commit 9c18f3e

Please sign in to comment.