From 309c29241347d67f39e73b208fed92e42b2665d9 Mon Sep 17 00:00:00 2001 From: Ben Jackson Date: Fri, 17 Jan 2020 17:44:44 +0000 Subject: [PATCH 1/4] Store variables supplied _before_ parsing adapter/config varibales --- python3/vimspector/debug_session.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/python3/vimspector/debug_session.py b/python3/vimspector/debug_session.py index 474e3d066..44afd7278 100644 --- a/python3/vimspector/debug_session.py +++ b/python3/vimspector/debug_session.py @@ -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, @@ -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, From 8d4ec3f53a218a473177ed43347baccb94e57a0f Mon Sep 17 00:00:00 2001 From: Ben Jackson Date: Fri, 17 Jan 2020 17:45:02 +0000 Subject: [PATCH 2/4] Supress errors in more appropriate places --- python3/vimspector/debug_session.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/python3/vimspector/debug_session.py b/python3/vimspector/debug_session.py index 44afd7278..cba77f5c8 100644 --- a/python3/vimspector/debug_session.py +++ b/python3/vimspector/debug_session.py @@ -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 ) @@ -279,7 +278,6 @@ def OnServerStderr( self, data ): self._outputView.Print( 'server', data ) - @IfConnected def OnRequestTimeout( self, timer_id ): self._connection.OnRequestTimeout( timer_id ) @@ -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() @@ -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() From 74eb94fe530871093431aac0449bf38c50fbd5f4 Mon Sep 17 00:00:00 2001 From: Ben Jackson Date: Fri, 17 Jan 2020 17:45:18 +0000 Subject: [PATCH 3/4] Allow PID to be set by variables, e.g. shell --- python3/vimspector/debug_session.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/python3/vimspector/debug_session.py b/python3/vimspector/debug_session.py index cba77f5c8..6f65a0b0a 100644 --- a/python3/vimspector/debug_session.py +++ b/python3/vimspector/debug_session.py @@ -605,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 From 018ae05de81c6414402cd460356c4af07f95ca6e Mon Sep 17 00:00:00 2001 From: Ben Jackson Date: Fri, 17 Jan 2020 17:50:54 +0000 Subject: [PATCH 4/4] Add 'example' allowing simple command-line attachment --- support/test/example/attach.vim | 13 +++++++++++++ support/test/example/cpp.json | 24 ++++++++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 support/test/example/attach.vim create mode 100644 support/test/example/cpp.json diff --git a/support/test/example/attach.vim b/support/test/example/attach.vim new file mode 100644 index 000000000..dda00a9ee --- /dev/null +++ b/support/test/example/attach.vim @@ -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 diff --git a/support/test/example/cpp.json b/support/test/example/cpp.json new file mode 100644 index 000000000..ba52fcdbe --- /dev/null +++ b/support/test/example/cpp.json @@ -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 } + ] + } + } + } +}