blob: ee88aada8be6611642df5a2886206205eb65f8d2 [file] [log] [blame] [view]
Erik Chen5c80c7a2019-08-29 22:48:151# Usage of tools/lldb/lldbinit.py
2
3Usage of Chromium's [lldbinit.py](../tools/lldb/lldbinit.py) is recommended when
4debugging with lldb. This is necessary for source-level debugging when
Erik Chen87a677d2019-08-29 22:57:225`strip_absolute_paths_from_debug_symbols` is enabled [this is the default].
Erik Chen5c80c7a2019-08-29 22:48:156
7To use, add the following to your `~/.lldbinit`
8
9```
10# So that lldbinit.py takes precedence.
11script sys.path[:0] = ['<.../path/to/chromium/src/tools/lldb>']
12script import lldbinit
13```
Alex Rudenkob27eaeb2020-04-17 07:58:3414
15## How to attach to a process with lldb and start debugging
16
17- Follow the instructions above to create your `~/.lldbinit` file, don't forget to put the correct path to Chromium source in there.
18- Inside of your Chromium checkout, run `lldb out/Default/chrome` (or `out/Debug/chrome`)
19 - On Mac, most likely, `lldb out/Default/Chromium.app/Contents/MacOS/Chromium`
20- Keep lldb running and start Chromium separately with `--no-sandbox` flag:
21 - On Linux, `out/Default/chrome --no-sandbox`
22 - On Mac, `out/Default/Chromium.app/Contents/MacOS/Chromium --no-sandbox`
23 - Note: if you start the process from lldb using `process launch -- --no-sandbox`, you will attach to the main browser process and will not be able to debug tab processes.
24- In Chromium, go to Customize and Control Chromium (three dots) -> More Tools -> Task Manager
25- Depending on what tab or process you want to debug, note the process ID.
26- In the lldb shell:
27 - Execute `process attach -p PID`. PID is the process ID of the tab (process) you want to debug.
28 - Note: it might take a while. Once lldb attaches to the process, you will see a message `Process PID stopped` and some stack traces.
29 - Now you can set breakpoints, for example, `breakpoint set -f inspector_overlay_agent.cc -l 627`.
30 - Execute `cont` to continue the execution of the process.
31 - Perform the actions which would trigger the breakpoint. lldb will stop the execution for you to inspect.
32 - You can pause the execution at any time by pressing Ctrl + C.
33 - Type `help` to learn more about different lldb commands.