[Lldb-commits] [PATCH] D111209: Don't push null ExecutionContext on CommandInterpreter exectx stack

Ted Woodward via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Wed Nov 3 07:16:34 PDT 2021


ted added a comment.

@jasonmolenda I discovered the same issue in another way - create a python command and load it with "command script import".  Here is test.py:

  def __lldb_init_module(debugger, dict):
      debugger.HandleCommand(
          'command script add -f test.test test')
      print("test command loaded")
  
  def test(debugger, register, result, dict):
      result.Clear()
      res = lldb.SBCommandReturnObject()
      command = 'target create /bin/ls'
      debugger.GetCommandInterpreter().HandleCommand(command, res)
      command = 'target modules search-paths add . ' + '/tmp'
      debugger.GetCommandInterpreter().HandleCommand(command, res)
      output = res.GetOutput()
      print(output)
  
      print('test done')

The 2nd HandleCommand uses the execution context of the original command, which doesn't have a target, so the search-paths add fails with no target.

(lldb) command script import test
test command loaded
(lldb) test
Current executable set to '/bin/ls' (x86_64).

test command called
error: error: invalid target, create a target using the 'target create' command

That should be fairly easy to turn into a Shell test, with "REQUIRES: python", because the error happens before the search-path is parsed, so it doesn't have to be valid.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D111209/new/

https://reviews.llvm.org/D111209



More information about the lldb-commits mailing list