forked from sorbet/sorbet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlldbinit.py
24 lines (20 loc) · 870 Bytes
/
lldbinit.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
if __name__ == "__main__":
print("Run only as script from LLDB... Not as standalone program!")
try:
import lldb
except:
pass
import re
import os
# Bazel builds all binaries from a username-specific cache location
# for lldb to work properly we need to map that path back to our main source
project_root = os.path.dirname(os.path.realpath(__file__))
bazel_workspace = os.path.realpath(os.path.join(project_root, "bazel-sorbet"))
if not(os.path.isdir(bazel_workspace)):
print("You need to compile Sorbet first before loading this file")
else:
print("(lldb) Mapping paths in ./bazel-sorbet to the project root")
source_map_command = 'settings set -- target.source-map "%s" "%s"' % (bazel_workspace, project_root)
ci = lldb.debugger.GetCommandInterpreter()
res = lldb.SBCommandReturnObject()
ci.HandleCommand(source_map_command, res)