[tools] Set up source map for lldb

With relative paths in the debug symbols, lldb cannot find the source
files, so set up a source map to direct "../.." to V8 root. This is
similar to what Chromium does in src/tools/lldb/lldbinit.py.

Bug: v8:11879
Change-Id: Ic6126aacafa7e3462c69da538a9528041c92ef00
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2998517
Commit-Queue: Zhi An Ng <zhin@chromium.org>
Reviewed-by: Clemens Backes <clemensb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#75521}
This commit is contained in:
Ng Zhi An 2021-07-01 09:22:40 -07:00 committed by V8 LUCI CQ
parent e8ac1ae424
commit 4a13063eae

View File

@ -8,9 +8,11 @@
# for py2/py3 compatibility
from __future__ import print_function
import lldb
import os
import re
import lldb
#####################
# Helper functions. #
#####################
@ -113,7 +115,19 @@ def bta(debugger, *args):
print("%s -> %s %s (%s)\033[0m" % (
color, prefix, match.group(2), match.group(1)))
def setup_source_map_for_relative_paths(debugger):
# Copied from Chromium's tools/lldb/lldbinit.py.
# When relative paths are used for debug symbols, lldb cannot find source
# files. Set up a source map to point to V8's root.
this_dir = os.path.dirname(os.path.abspath(__file__))
source_dir = os.path.join(this_dir, os.pardir)
debugger.HandleCommand(
'settings set target.source-map ../.. ' + source_dir)
def __lldb_init_module(debugger, dict):
setup_source_map_for_relative_paths(debugger)
debugger.HandleCommand('settings set target.x86-disassembly-flavor intel')
for cmd in ('job', 'jlh', 'jco', 'jld', 'jtt', 'jst', 'jss', 'bta'):
debugger.HandleCommand(