From 3c5bb150c5df9a1dc6fc47462f2d6e20f6054413 Mon Sep 17 00:00:00 2001 From: Nico Flaig Date: Wed, 22 May 2024 15:45:41 +0300 Subject: [PATCH] chore: review debugging section PR (#6807) --- .vscode/README.md | 5 +++-- .vscode/launch.template.json | 2 +- docs/pages/tools/debugging.md | 13 +++++++++---- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/.vscode/README.md b/.vscode/README.md index 0e7781ad11b1..982806622c7d 100644 --- a/.vscode/README.md +++ b/.vscode/README.md @@ -1,2 +1,3 @@ -Adapt to your needs `launch.template.json` and copy as `launch.json`. -Follow `docs/pages/tools/debugging.md` for more details. +Copy `launch.template.json` as `launch.json` and adapt to your needs. + +See [Debugging](../docs/pages/tools/debugging.md) for more details. diff --git a/.vscode/launch.template.json b/.vscode/launch.template.json index 7f8c7a70484c..b617723a0066 100644 --- a/.vscode/launch.template.json +++ b/.vscode/launch.template.json @@ -76,4 +76,4 @@ "description": "Enter the test name to run, leave empty to run all" } ] -} \ No newline at end of file +} diff --git a/docs/pages/tools/debugging.md b/docs/pages/tools/debugging.md index ab884dd1b5e5..0775a3feb0b2 100644 --- a/docs/pages/tools/debugging.md +++ b/docs/pages/tools/debugging.md @@ -1,10 +1,15 @@ ---- -title: Debugging ---- +# Debugging + +This page describes different approaches for debugging Lodestar. + +## VS Code launch config + +The simplest way to debug is to use the provided [launch.template.json](https://github.com/ChainSafe/lodestar/blob/unstable/.vscode/launch.template.json) `configurations`. Copy them as `.vscode/launch.json` and they will be made available in the `Run and Debug` section in VS Code. Adapt as needed, e.g. by adding additional arguments to the beacon [configuration](https://github.com/ChainSafe/lodestar/blob/unstable/.vscode/launch.template.json#L22) to match your needs. -The simplest way to debug is to use the provided [launch.template.json](https://github.com/ChainSafe/lodestar/blob/unstable/.vscode/launch.template.json) `configurations`. Adapt and copy them as `.vscode/launch.json`, and they will be made available in the `Run and Debug` section. Note that users probably want to adapt the arguments of the beacon [configuration](https://github.com/ChainSafe/lodestar/blob/unstable/.vscode/launch.json#L11) to match their needs. VS Code supports debugging Workers out of the box when using those configurations. +## Attach to running process + Remote `lodestar` processes can also be debugged by leveraging [node:inspector](https://nodejs.org/api/inspector.html). Adding `--inspect` to the node CLI (e.g. `NODE_OPTIONS=--inspect ./lodestar beacon`) allows to debug the main thread. To debug a specific `Worker`, follow those steps: - remove `--inspect` from `node` CLI