llgdb.py: Make sure to clean up the debugger on exit.

<rdar://problem/51807962>

llvm-svn: 363611
This commit is contained in:
Adrian Prantl 2019-06-17 20:06:34 +00:00
parent 72adaf3ec8
commit 2d26cf37d7
1 changed files with 6 additions and 1 deletions

View File

@ -58,6 +58,12 @@ args = parser.parse_args()
debugger = lldb.SBDebugger.Create()
debugger.SkipLLDBInitFiles(args.n)
# Make sure to clean up the debugger on exit.
import atexit
def on_exit():
debugger.Terminate()
atexit.register(on_exit)
# Don't return from lldb function calls until the process stops.
debugger.SetAsync(False)
@ -150,7 +156,6 @@ NOTE: There are several reasons why this may happen:
print debugger.HandleCommand(' '.join(cmd))
except SystemExit:
lldb.SBDebugger_Terminate()
raise
except:
print 'Could not handle the command "%s"' % ' '.join(cmd)