how can made lldb server launching a new process without attaching to the existed one?










0















I'm using ios-deploy to launch ios app automatically, it works fine but only a probem: it won't restart the app if it's already running.



I have studied its source code and learned it's using the lldb command to launch the app. the lldb script is (part):



def run_command(debugger, command, result, internal_dict):
device_app = internal_dict['fruitstrap_device_app']
args = command.split('--',1)
error = lldb.SBError()
lldb.target.modules[0].SetPlatformFileSpec(lldb.SBFileSpec(device_app))
args_arr =
if len(args) > 1:
args_arr = shlex.split(args[1])
args_arr = args_arr + shlex.split('args')

launchInfo = lldb.SBLaunchInfo(args_arr)
global listener
launchInfo.SetListener(listener)

#This env variable makes NSLog, CFLog and os_log messages get mirrored to stderr
#https://stackoverflow.com/a/39581193
launchInfo.SetEnvironmentEntries(['OS_ACTIVITY_DT_MODE=enable'], True)

lldb.target.Launch(launchInfo, error)
lockedstr = ': Locked'
if lockedstr in str(error):
print('\nDevice Locked\n')
os._exit(254)
else:
print(str(error))


the start command:




(lldb) command source -s 0
'/tmp/BB1ED2A3-3A3E-413A-935D-323D7A7533D1/fruitstrap-lldb-prep-cmds-6a050aabefc708cb7fc6024c4dd1743080d6e20b'
Executing commands in
'/tmp/BB1ED2A3-3A3E-413A-935D-323D7A7533D1/fruitstrap-lldb-prep-cmds-6a050aabefc708cb7fc6024c4dd1743080d6e20b'.
(lldb) platform select remote-ios --sysroot
'/Users/wellbye/Library/Developer/Xcode/iOS DeviceSupport/12.0
(16A366)/Symbols' Platform: remote-ios Connected: no SDK Path:
"/Users/wellbye/Library/Developer/Xcode/iOS DeviceSupport/12.0
(16A366)/Symbols" (lldb) target create
"/Users/wellbye/git-repo/j/mj3d/Product/build/ios/Build/Products/Release-iphoneos/mj.app" Current executable set to
'/Users/wellbye/git-repo/j/mj3d/Product/build/ios/Build/Products/Release-iphoneos/mj.app' (arm64). (lldb) script
fruitstrap_device_app="/private/var/containers/Bundle/Application/1FB0E7E3-6616-4789-8E6F-598C4F5AAC35/mj.app"
(lldb) script fruitstrap_connect_url="connect://127.0.0.1:62276"

(lldb) target modules search-paths add /usr
"/Users/wellbye/Library/Developer/Xcode/iOS DeviceSupport/12.0
(16A366)/Symbols/usr" /System
"/Users/wellbye/Library/Developer/Xcode/iOS DeviceSupport/12.0
(16A366)/Symbols/System"
"/private/var/containers/Bundle/Application/1FB0E7E3-6616-4789-8E6F-598C4F5AAC35"
"/Users/wellbye/git-repo/j/mj3d/Product/build/ios/Build/Products/Release-iphoneos"
"/var/containers/Bundle/Application/1FB0E7E3-6616-4789-8E6F-598C4F5AAC35"
"/Users/wellbye/git-repo/j/mj3d/Product/build/ios/Build/Products/Release-iphoneos"
/Developer "/Users/wellbye/Library/Developer/Xcode/iOS
DeviceSupport/12.0 (16A366)/Symbols/Developer" (lldb) command
script import
"/tmp/BB1ED2A3-3A3E-413A-935D-323D7A7533D1/fruitstrap_6a050aabefc708cb7fc6024c4dd1743080d6e20b.py"
(lldb) command script add -f
fruitstrap_6a050aabefc708cb7fc6024c4dd1743080d6e20b.connect_command
connect (lldb) command script add -s asynchronous -f
fruitstrap_6a050aabefc708cb7fc6024c4dd1743080d6e20b.run_command run

(lldb) command script add -s asynchronous -f
fruitstrap_6a050aabefc708cb7fc6024c4dd1743080d6e20b.autoexit_command
autoexit (lldb) command script add -s asynchronous -f
fruitstrap_6a050aabefc708cb7fc6024c4dd1743080d6e20b.safequit_command
safequit (lldb) connect (lldb) run




I have searched the lldb's python api reference, but haven't seen anything (args or flags) I could use for my purpose.



so how could we let the lldb server know it should kill the exist process and start a new one?










share|improve this question


























    0















    I'm using ios-deploy to launch ios app automatically, it works fine but only a probem: it won't restart the app if it's already running.



    I have studied its source code and learned it's using the lldb command to launch the app. the lldb script is (part):



    def run_command(debugger, command, result, internal_dict):
    device_app = internal_dict['fruitstrap_device_app']
    args = command.split('--',1)
    error = lldb.SBError()
    lldb.target.modules[0].SetPlatformFileSpec(lldb.SBFileSpec(device_app))
    args_arr =
    if len(args) > 1:
    args_arr = shlex.split(args[1])
    args_arr = args_arr + shlex.split('args')

    launchInfo = lldb.SBLaunchInfo(args_arr)
    global listener
    launchInfo.SetListener(listener)

    #This env variable makes NSLog, CFLog and os_log messages get mirrored to stderr
    #https://stackoverflow.com/a/39581193
    launchInfo.SetEnvironmentEntries(['OS_ACTIVITY_DT_MODE=enable'], True)

    lldb.target.Launch(launchInfo, error)
    lockedstr = ': Locked'
    if lockedstr in str(error):
    print('\nDevice Locked\n')
    os._exit(254)
    else:
    print(str(error))


    the start command:




    (lldb) command source -s 0
    '/tmp/BB1ED2A3-3A3E-413A-935D-323D7A7533D1/fruitstrap-lldb-prep-cmds-6a050aabefc708cb7fc6024c4dd1743080d6e20b'
    Executing commands in
    '/tmp/BB1ED2A3-3A3E-413A-935D-323D7A7533D1/fruitstrap-lldb-prep-cmds-6a050aabefc708cb7fc6024c4dd1743080d6e20b'.
    (lldb) platform select remote-ios --sysroot
    '/Users/wellbye/Library/Developer/Xcode/iOS DeviceSupport/12.0
    (16A366)/Symbols' Platform: remote-ios Connected: no SDK Path:
    "/Users/wellbye/Library/Developer/Xcode/iOS DeviceSupport/12.0
    (16A366)/Symbols" (lldb) target create
    "/Users/wellbye/git-repo/j/mj3d/Product/build/ios/Build/Products/Release-iphoneos/mj.app" Current executable set to
    '/Users/wellbye/git-repo/j/mj3d/Product/build/ios/Build/Products/Release-iphoneos/mj.app' (arm64). (lldb) script
    fruitstrap_device_app="/private/var/containers/Bundle/Application/1FB0E7E3-6616-4789-8E6F-598C4F5AAC35/mj.app"
    (lldb) script fruitstrap_connect_url="connect://127.0.0.1:62276"

    (lldb) target modules search-paths add /usr
    "/Users/wellbye/Library/Developer/Xcode/iOS DeviceSupport/12.0
    (16A366)/Symbols/usr" /System
    "/Users/wellbye/Library/Developer/Xcode/iOS DeviceSupport/12.0
    (16A366)/Symbols/System"
    "/private/var/containers/Bundle/Application/1FB0E7E3-6616-4789-8E6F-598C4F5AAC35"
    "/Users/wellbye/git-repo/j/mj3d/Product/build/ios/Build/Products/Release-iphoneos"
    "/var/containers/Bundle/Application/1FB0E7E3-6616-4789-8E6F-598C4F5AAC35"
    "/Users/wellbye/git-repo/j/mj3d/Product/build/ios/Build/Products/Release-iphoneos"
    /Developer "/Users/wellbye/Library/Developer/Xcode/iOS
    DeviceSupport/12.0 (16A366)/Symbols/Developer" (lldb) command
    script import
    "/tmp/BB1ED2A3-3A3E-413A-935D-323D7A7533D1/fruitstrap_6a050aabefc708cb7fc6024c4dd1743080d6e20b.py"
    (lldb) command script add -f
    fruitstrap_6a050aabefc708cb7fc6024c4dd1743080d6e20b.connect_command
    connect (lldb) command script add -s asynchronous -f
    fruitstrap_6a050aabefc708cb7fc6024c4dd1743080d6e20b.run_command run

    (lldb) command script add -s asynchronous -f
    fruitstrap_6a050aabefc708cb7fc6024c4dd1743080d6e20b.autoexit_command
    autoexit (lldb) command script add -s asynchronous -f
    fruitstrap_6a050aabefc708cb7fc6024c4dd1743080d6e20b.safequit_command
    safequit (lldb) connect (lldb) run




    I have searched the lldb's python api reference, but haven't seen anything (args or flags) I could use for my purpose.



    so how could we let the lldb server know it should kill the exist process and start a new one?










    share|improve this question
























      0












      0








      0








      I'm using ios-deploy to launch ios app automatically, it works fine but only a probem: it won't restart the app if it's already running.



      I have studied its source code and learned it's using the lldb command to launch the app. the lldb script is (part):



      def run_command(debugger, command, result, internal_dict):
      device_app = internal_dict['fruitstrap_device_app']
      args = command.split('--',1)
      error = lldb.SBError()
      lldb.target.modules[0].SetPlatformFileSpec(lldb.SBFileSpec(device_app))
      args_arr =
      if len(args) > 1:
      args_arr = shlex.split(args[1])
      args_arr = args_arr + shlex.split('args')

      launchInfo = lldb.SBLaunchInfo(args_arr)
      global listener
      launchInfo.SetListener(listener)

      #This env variable makes NSLog, CFLog and os_log messages get mirrored to stderr
      #https://stackoverflow.com/a/39581193
      launchInfo.SetEnvironmentEntries(['OS_ACTIVITY_DT_MODE=enable'], True)

      lldb.target.Launch(launchInfo, error)
      lockedstr = ': Locked'
      if lockedstr in str(error):
      print('\nDevice Locked\n')
      os._exit(254)
      else:
      print(str(error))


      the start command:




      (lldb) command source -s 0
      '/tmp/BB1ED2A3-3A3E-413A-935D-323D7A7533D1/fruitstrap-lldb-prep-cmds-6a050aabefc708cb7fc6024c4dd1743080d6e20b'
      Executing commands in
      '/tmp/BB1ED2A3-3A3E-413A-935D-323D7A7533D1/fruitstrap-lldb-prep-cmds-6a050aabefc708cb7fc6024c4dd1743080d6e20b'.
      (lldb) platform select remote-ios --sysroot
      '/Users/wellbye/Library/Developer/Xcode/iOS DeviceSupport/12.0
      (16A366)/Symbols' Platform: remote-ios Connected: no SDK Path:
      "/Users/wellbye/Library/Developer/Xcode/iOS DeviceSupport/12.0
      (16A366)/Symbols" (lldb) target create
      "/Users/wellbye/git-repo/j/mj3d/Product/build/ios/Build/Products/Release-iphoneos/mj.app" Current executable set to
      '/Users/wellbye/git-repo/j/mj3d/Product/build/ios/Build/Products/Release-iphoneos/mj.app' (arm64). (lldb) script
      fruitstrap_device_app="/private/var/containers/Bundle/Application/1FB0E7E3-6616-4789-8E6F-598C4F5AAC35/mj.app"
      (lldb) script fruitstrap_connect_url="connect://127.0.0.1:62276"

      (lldb) target modules search-paths add /usr
      "/Users/wellbye/Library/Developer/Xcode/iOS DeviceSupport/12.0
      (16A366)/Symbols/usr" /System
      "/Users/wellbye/Library/Developer/Xcode/iOS DeviceSupport/12.0
      (16A366)/Symbols/System"
      "/private/var/containers/Bundle/Application/1FB0E7E3-6616-4789-8E6F-598C4F5AAC35"
      "/Users/wellbye/git-repo/j/mj3d/Product/build/ios/Build/Products/Release-iphoneos"
      "/var/containers/Bundle/Application/1FB0E7E3-6616-4789-8E6F-598C4F5AAC35"
      "/Users/wellbye/git-repo/j/mj3d/Product/build/ios/Build/Products/Release-iphoneos"
      /Developer "/Users/wellbye/Library/Developer/Xcode/iOS
      DeviceSupport/12.0 (16A366)/Symbols/Developer" (lldb) command
      script import
      "/tmp/BB1ED2A3-3A3E-413A-935D-323D7A7533D1/fruitstrap_6a050aabefc708cb7fc6024c4dd1743080d6e20b.py"
      (lldb) command script add -f
      fruitstrap_6a050aabefc708cb7fc6024c4dd1743080d6e20b.connect_command
      connect (lldb) command script add -s asynchronous -f
      fruitstrap_6a050aabefc708cb7fc6024c4dd1743080d6e20b.run_command run

      (lldb) command script add -s asynchronous -f
      fruitstrap_6a050aabefc708cb7fc6024c4dd1743080d6e20b.autoexit_command
      autoexit (lldb) command script add -s asynchronous -f
      fruitstrap_6a050aabefc708cb7fc6024c4dd1743080d6e20b.safequit_command
      safequit (lldb) connect (lldb) run




      I have searched the lldb's python api reference, but haven't seen anything (args or flags) I could use for my purpose.



      so how could we let the lldb server know it should kill the exist process and start a new one?










      share|improve this question














      I'm using ios-deploy to launch ios app automatically, it works fine but only a probem: it won't restart the app if it's already running.



      I have studied its source code and learned it's using the lldb command to launch the app. the lldb script is (part):



      def run_command(debugger, command, result, internal_dict):
      device_app = internal_dict['fruitstrap_device_app']
      args = command.split('--',1)
      error = lldb.SBError()
      lldb.target.modules[0].SetPlatformFileSpec(lldb.SBFileSpec(device_app))
      args_arr =
      if len(args) > 1:
      args_arr = shlex.split(args[1])
      args_arr = args_arr + shlex.split('args')

      launchInfo = lldb.SBLaunchInfo(args_arr)
      global listener
      launchInfo.SetListener(listener)

      #This env variable makes NSLog, CFLog and os_log messages get mirrored to stderr
      #https://stackoverflow.com/a/39581193
      launchInfo.SetEnvironmentEntries(['OS_ACTIVITY_DT_MODE=enable'], True)

      lldb.target.Launch(launchInfo, error)
      lockedstr = ': Locked'
      if lockedstr in str(error):
      print('\nDevice Locked\n')
      os._exit(254)
      else:
      print(str(error))


      the start command:




      (lldb) command source -s 0
      '/tmp/BB1ED2A3-3A3E-413A-935D-323D7A7533D1/fruitstrap-lldb-prep-cmds-6a050aabefc708cb7fc6024c4dd1743080d6e20b'
      Executing commands in
      '/tmp/BB1ED2A3-3A3E-413A-935D-323D7A7533D1/fruitstrap-lldb-prep-cmds-6a050aabefc708cb7fc6024c4dd1743080d6e20b'.
      (lldb) platform select remote-ios --sysroot
      '/Users/wellbye/Library/Developer/Xcode/iOS DeviceSupport/12.0
      (16A366)/Symbols' Platform: remote-ios Connected: no SDK Path:
      "/Users/wellbye/Library/Developer/Xcode/iOS DeviceSupport/12.0
      (16A366)/Symbols" (lldb) target create
      "/Users/wellbye/git-repo/j/mj3d/Product/build/ios/Build/Products/Release-iphoneos/mj.app" Current executable set to
      '/Users/wellbye/git-repo/j/mj3d/Product/build/ios/Build/Products/Release-iphoneos/mj.app' (arm64). (lldb) script
      fruitstrap_device_app="/private/var/containers/Bundle/Application/1FB0E7E3-6616-4789-8E6F-598C4F5AAC35/mj.app"
      (lldb) script fruitstrap_connect_url="connect://127.0.0.1:62276"

      (lldb) target modules search-paths add /usr
      "/Users/wellbye/Library/Developer/Xcode/iOS DeviceSupport/12.0
      (16A366)/Symbols/usr" /System
      "/Users/wellbye/Library/Developer/Xcode/iOS DeviceSupport/12.0
      (16A366)/Symbols/System"
      "/private/var/containers/Bundle/Application/1FB0E7E3-6616-4789-8E6F-598C4F5AAC35"
      "/Users/wellbye/git-repo/j/mj3d/Product/build/ios/Build/Products/Release-iphoneos"
      "/var/containers/Bundle/Application/1FB0E7E3-6616-4789-8E6F-598C4F5AAC35"
      "/Users/wellbye/git-repo/j/mj3d/Product/build/ios/Build/Products/Release-iphoneos"
      /Developer "/Users/wellbye/Library/Developer/Xcode/iOS
      DeviceSupport/12.0 (16A366)/Symbols/Developer" (lldb) command
      script import
      "/tmp/BB1ED2A3-3A3E-413A-935D-323D7A7533D1/fruitstrap_6a050aabefc708cb7fc6024c4dd1743080d6e20b.py"
      (lldb) command script add -f
      fruitstrap_6a050aabefc708cb7fc6024c4dd1743080d6e20b.connect_command
      connect (lldb) command script add -s asynchronous -f
      fruitstrap_6a050aabefc708cb7fc6024c4dd1743080d6e20b.run_command run

      (lldb) command script add -s asynchronous -f
      fruitstrap_6a050aabefc708cb7fc6024c4dd1743080d6e20b.autoexit_command
      autoexit (lldb) command script add -s asynchronous -f
      fruitstrap_6a050aabefc708cb7fc6024c4dd1743080d6e20b.safequit_command
      safequit (lldb) connect (lldb) run




      I have searched the lldb's python api reference, but haven't seen anything (args or flags) I could use for my purpose.



      so how could we let the lldb server know it should kill the exist process and start a new one?







      ios lldb






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 15 '18 at 15:35









      fatfatsonfatfatson

      16110




      16110






















          1 Answer
          1






          active

          oldest

          votes


















          2














          It depends on whether you are trying to support rerun behavior (i.e. you make a target, launch the process, then use the same target to re-run) or if you just want to kill off some instance of the app that was running - maybe because it was finger-launched on the device or whatever.



          In the first case, since you are reusing the SBTarget, you can just check whether your target has a process (call target.process.IsValid()) and if does kill it with target.process.Kill() before launching.



          But if lldb is not responsible for launching the extant copy of the app, then it won't know anything about it, and doesn't really have a way to kill it off.






          share|improve this answer























          • I have add the checking and killing code before launching, but after killing, the lldb says:Process 0 exited with status = 9 (0x00000009) error: the platform is not currently connected and doesn't launch the new process.

            – fatfatson
            Nov 16 '18 at 19:54












          • even the app is not running, lldb.target.process.IsValid return true, print the process shows SBProcess: pid = 0, state = connected, threads = 0, executable = mj

            – fatfatson
            Nov 16 '18 at 20:03












          • An exited process stays around (so you could check the exit status for instance.) But process.state will be lldb.eStateExited. You don't need to kill those...

            – Jim Ingham
            Nov 16 '18 at 20:07











          • I don't know anything about how ios-deploy works, however, so I can't help with how you would make a new connection to the device if you really did have to kill off the current process.

            – Jim Ingham
            Nov 16 '18 at 20:08











          • thanks anyway~ @Jim Ingham

            – fatfatson
            Nov 16 '18 at 20:24










          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53322853%2fhow-can-made-lldb-server-launching-a-new-process-without-attaching-to-the-existe%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          2














          It depends on whether you are trying to support rerun behavior (i.e. you make a target, launch the process, then use the same target to re-run) or if you just want to kill off some instance of the app that was running - maybe because it was finger-launched on the device or whatever.



          In the first case, since you are reusing the SBTarget, you can just check whether your target has a process (call target.process.IsValid()) and if does kill it with target.process.Kill() before launching.



          But if lldb is not responsible for launching the extant copy of the app, then it won't know anything about it, and doesn't really have a way to kill it off.






          share|improve this answer























          • I have add the checking and killing code before launching, but after killing, the lldb says:Process 0 exited with status = 9 (0x00000009) error: the platform is not currently connected and doesn't launch the new process.

            – fatfatson
            Nov 16 '18 at 19:54












          • even the app is not running, lldb.target.process.IsValid return true, print the process shows SBProcess: pid = 0, state = connected, threads = 0, executable = mj

            – fatfatson
            Nov 16 '18 at 20:03












          • An exited process stays around (so you could check the exit status for instance.) But process.state will be lldb.eStateExited. You don't need to kill those...

            – Jim Ingham
            Nov 16 '18 at 20:07











          • I don't know anything about how ios-deploy works, however, so I can't help with how you would make a new connection to the device if you really did have to kill off the current process.

            – Jim Ingham
            Nov 16 '18 at 20:08











          • thanks anyway~ @Jim Ingham

            – fatfatson
            Nov 16 '18 at 20:24















          2














          It depends on whether you are trying to support rerun behavior (i.e. you make a target, launch the process, then use the same target to re-run) or if you just want to kill off some instance of the app that was running - maybe because it was finger-launched on the device or whatever.



          In the first case, since you are reusing the SBTarget, you can just check whether your target has a process (call target.process.IsValid()) and if does kill it with target.process.Kill() before launching.



          But if lldb is not responsible for launching the extant copy of the app, then it won't know anything about it, and doesn't really have a way to kill it off.






          share|improve this answer























          • I have add the checking and killing code before launching, but after killing, the lldb says:Process 0 exited with status = 9 (0x00000009) error: the platform is not currently connected and doesn't launch the new process.

            – fatfatson
            Nov 16 '18 at 19:54












          • even the app is not running, lldb.target.process.IsValid return true, print the process shows SBProcess: pid = 0, state = connected, threads = 0, executable = mj

            – fatfatson
            Nov 16 '18 at 20:03












          • An exited process stays around (so you could check the exit status for instance.) But process.state will be lldb.eStateExited. You don't need to kill those...

            – Jim Ingham
            Nov 16 '18 at 20:07











          • I don't know anything about how ios-deploy works, however, so I can't help with how you would make a new connection to the device if you really did have to kill off the current process.

            – Jim Ingham
            Nov 16 '18 at 20:08











          • thanks anyway~ @Jim Ingham

            – fatfatson
            Nov 16 '18 at 20:24













          2












          2








          2







          It depends on whether you are trying to support rerun behavior (i.e. you make a target, launch the process, then use the same target to re-run) or if you just want to kill off some instance of the app that was running - maybe because it was finger-launched on the device or whatever.



          In the first case, since you are reusing the SBTarget, you can just check whether your target has a process (call target.process.IsValid()) and if does kill it with target.process.Kill() before launching.



          But if lldb is not responsible for launching the extant copy of the app, then it won't know anything about it, and doesn't really have a way to kill it off.






          share|improve this answer













          It depends on whether you are trying to support rerun behavior (i.e. you make a target, launch the process, then use the same target to re-run) or if you just want to kill off some instance of the app that was running - maybe because it was finger-launched on the device or whatever.



          In the first case, since you are reusing the SBTarget, you can just check whether your target has a process (call target.process.IsValid()) and if does kill it with target.process.Kill() before launching.



          But if lldb is not responsible for launching the extant copy of the app, then it won't know anything about it, and doesn't really have a way to kill it off.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 16 '18 at 1:40









          Jim InghamJim Ingham

          14.2k13034




          14.2k13034












          • I have add the checking and killing code before launching, but after killing, the lldb says:Process 0 exited with status = 9 (0x00000009) error: the platform is not currently connected and doesn't launch the new process.

            – fatfatson
            Nov 16 '18 at 19:54












          • even the app is not running, lldb.target.process.IsValid return true, print the process shows SBProcess: pid = 0, state = connected, threads = 0, executable = mj

            – fatfatson
            Nov 16 '18 at 20:03












          • An exited process stays around (so you could check the exit status for instance.) But process.state will be lldb.eStateExited. You don't need to kill those...

            – Jim Ingham
            Nov 16 '18 at 20:07











          • I don't know anything about how ios-deploy works, however, so I can't help with how you would make a new connection to the device if you really did have to kill off the current process.

            – Jim Ingham
            Nov 16 '18 at 20:08











          • thanks anyway~ @Jim Ingham

            – fatfatson
            Nov 16 '18 at 20:24

















          • I have add the checking and killing code before launching, but after killing, the lldb says:Process 0 exited with status = 9 (0x00000009) error: the platform is not currently connected and doesn't launch the new process.

            – fatfatson
            Nov 16 '18 at 19:54












          • even the app is not running, lldb.target.process.IsValid return true, print the process shows SBProcess: pid = 0, state = connected, threads = 0, executable = mj

            – fatfatson
            Nov 16 '18 at 20:03












          • An exited process stays around (so you could check the exit status for instance.) But process.state will be lldb.eStateExited. You don't need to kill those...

            – Jim Ingham
            Nov 16 '18 at 20:07











          • I don't know anything about how ios-deploy works, however, so I can't help with how you would make a new connection to the device if you really did have to kill off the current process.

            – Jim Ingham
            Nov 16 '18 at 20:08











          • thanks anyway~ @Jim Ingham

            – fatfatson
            Nov 16 '18 at 20:24
















          I have add the checking and killing code before launching, but after killing, the lldb says:Process 0 exited with status = 9 (0x00000009) error: the platform is not currently connected and doesn't launch the new process.

          – fatfatson
          Nov 16 '18 at 19:54






          I have add the checking and killing code before launching, but after killing, the lldb says:Process 0 exited with status = 9 (0x00000009) error: the platform is not currently connected and doesn't launch the new process.

          – fatfatson
          Nov 16 '18 at 19:54














          even the app is not running, lldb.target.process.IsValid return true, print the process shows SBProcess: pid = 0, state = connected, threads = 0, executable = mj

          – fatfatson
          Nov 16 '18 at 20:03






          even the app is not running, lldb.target.process.IsValid return true, print the process shows SBProcess: pid = 0, state = connected, threads = 0, executable = mj

          – fatfatson
          Nov 16 '18 at 20:03














          An exited process stays around (so you could check the exit status for instance.) But process.state will be lldb.eStateExited. You don't need to kill those...

          – Jim Ingham
          Nov 16 '18 at 20:07





          An exited process stays around (so you could check the exit status for instance.) But process.state will be lldb.eStateExited. You don't need to kill those...

          – Jim Ingham
          Nov 16 '18 at 20:07













          I don't know anything about how ios-deploy works, however, so I can't help with how you would make a new connection to the device if you really did have to kill off the current process.

          – Jim Ingham
          Nov 16 '18 at 20:08





          I don't know anything about how ios-deploy works, however, so I can't help with how you would make a new connection to the device if you really did have to kill off the current process.

          – Jim Ingham
          Nov 16 '18 at 20:08













          thanks anyway~ @Jim Ingham

          – fatfatson
          Nov 16 '18 at 20:24





          thanks anyway~ @Jim Ingham

          – fatfatson
          Nov 16 '18 at 20:24



















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53322853%2fhow-can-made-lldb-server-launching-a-new-process-without-attaching-to-the-existe%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Top Tejano songwriter Luis Silva dead of heart attack at 64

          ReactJS Fetched API data displays live - need Data displayed static

          政党