Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add doc about how to debug with martin and vscode #1683

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/src/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,5 @@
- [Diffing/Patching MBTiles](mbtiles-diff.md)
- [Validating MBTiles](mbtiles-validation.md)
- [Development](development.md)
- [Getting involved](getting-involved.md)
- [Martin as a library](martin-as-a-library.md)
114 changes: 114 additions & 0 deletions docs/src/getting-involved.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
# Getting involved

It's time to get involved once you have the [fork and all required software](development.md).

We assume you are working on Ubuntu (or WSL) with Visual Studio Code in this post.

## Editor Plugins

Install plugins below:
* [CodeLLDB](https://marketplace.visualstudio.com/items?itemName=vadimcn.vscode-lldb)

Check failure on line 10 in docs/src/getting-involved.md

View workflow job for this annotation

GitHub Actions / Build Docs

Lists should be surrounded by blank lines

docs/src/getting-involved.md:10 MD032/blanks-around-lists Lists should be surrounded by blank lines [Context: "* [CodeLLDB](https://marketpla..."] https://github.com/DavidAnson/markdownlint/blob/v0.37.4/doc/md032.md
* [rust-analyzer](https://marketplace.visualstudio.com/items?itemName=rust-lang.rust-analyzer)

## Debugging with `launch.json`

Generally, you need to debug martin with specific arguments or a config file to fix issues or add features.

The most convenient way is to generate a launch.json and modify it.

## Generate

Press `F1` on your keyboard, and input "Generate Launch Configurations from Cargo.toml". Execute it and save it to your `.vscode` directory.

## Modify

Check failure on line 23 in docs/src/getting-involved.md

View workflow job for this annotation

GitHub Actions / Build Docs

Trailing spaces

docs/src/getting-involved.md:23:10 MD009/no-trailing-spaces Trailing spaces [Expected: 0 or 2; Actual: 1] https://github.com/DavidAnson/markdownlint/blob/v0.37.4/doc/md009.md

Let's say you want to debugging Martin with this command:
```shell

Check failure on line 26 in docs/src/getting-involved.md

View workflow job for this annotation

GitHub Actions / Build Docs

Fenced code blocks should be surrounded by blank lines

docs/src/getting-involved.md:26 MD031/blanks-around-fences Fenced code blocks should be surrounded by blank lines [Context: "```shell"] https://github.com/DavidAnson/markdownlint/blob/v0.37.4/doc/md031.md
martin postgres://postgres:postgres@localhost:5411/db --default-srid 4490
```

You could find `Debug executable 'martin'` in your `launch.json`, like below:
```json

Check failure on line 31 in docs/src/getting-involved.md

View workflow job for this annotation

GitHub Actions / Build Docs

Fenced code blocks should be surrounded by blank lines

docs/src/getting-involved.md:31 MD031/blanks-around-fences Fenced code blocks should be surrounded by blank lines [Context: "```json"] https://github.com/DavidAnson/markdownlint/blob/v0.37.4/doc/md031.md
{
"type": "lldb",
"request": "launch",
"name": "Debug executable 'martin'",
"cargo": {
"args": [
"build",
"--bin=martin",
"--package=martin"
],
"filter": {
"name": "martin",
"kind": "bin"
}
},
"args": [],
"cwd": "${workspaceFolder}"
},
```

Just copy and paste after it, and modify your pasted like this:

```json
{
"type": "lldb",
"request": "launch",
"name": "my first debug", // name it any as you like
"cargo": {
"args": [
"build",
"--bin=martin",
"--package=martin"
],
"filter": {
"name": "martin",
"kind": "bin"
}
},
"args": ["postgres://postgres:postgres@localhost:5411/db"], // add your arguments here
"env": {
"DEFAULT_SRID": 4490, // add your env here
},
"cwd": "${workspaceFolder}"
},
```

### Add a breakpoint

Go to any part you're interested in of martin code and add a breakpoint.

We add a breakpoint here in the [start of martin](https://github.com/maplibre/martin/blob/e628c3973f193a432d3d1282c5893e2339e806b6/martin/src/bin/martin.rs#L10).

```rust
use clap::Parser;
use log::{error, info, log_enabled};
use martin::args::{Args, OsEnv};
use martin::srv::new_server;
use martin::{read_config, Config, MartinResult};

const VERSION: &str = env!("CARGO_PKG_VERSION");

async fn start(args: Args) -> MartinResult<()> {
info!("Starting Martin v{VERSION}");
```

### Debugging

Click `Run and Debug` on the left panel of `Visual Studio Code`. Choose `my first debug` and press `F5` on your keyboard.

Wait for the breakpoint to be hit.


Check failure on line 103 in docs/src/getting-involved.md

View workflow job for this annotation

GitHub Actions / Build Docs

Multiple consecutive blank lines

docs/src/getting-involved.md:103 MD012/no-multiple-blanks Multiple consecutive blank lines [Expected: 1; Actual: 2] https://github.com/DavidAnson/markdownlint/blob/v0.37.4/doc/md012.md
## Working with Just


Check failure on line 106 in docs/src/getting-involved.md

View workflow job for this annotation

GitHub Actions / Build Docs

Multiple consecutive blank lines

docs/src/getting-involved.md:106 MD012/no-multiple-blanks Multiple consecutive blank lines [Expected: 1; Actual: 2] https://github.com/DavidAnson/markdownlint/blob/v0.37.4/doc/md012.md
//todo


Check failure on line 109 in docs/src/getting-involved.md

View workflow job for this annotation

GitHub Actions / Build Docs

Multiple consecutive blank lines

docs/src/getting-involved.md:109 MD012/no-multiple-blanks Multiple consecutive blank lines [Expected: 1; Actual: 2] https://github.com/DavidAnson/markdownlint/blob/v0.37.4/doc/md012.md

Check failure on line 110 in docs/src/getting-involved.md

View workflow job for this annotation

GitHub Actions / Build Docs

Multiple consecutive blank lines

docs/src/getting-involved.md:110 MD012/no-multiple-blanks Multiple consecutive blank lines [Expected: 1; Actual: 3] https://github.com/DavidAnson/markdownlint/blob/v0.37.4/doc/md012.md

Check failure on line 111 in docs/src/getting-involved.md

View workflow job for this annotation

GitHub Actions / Build Docs

Multiple consecutive blank lines

docs/src/getting-involved.md:111 MD012/no-multiple-blanks Multiple consecutive blank lines [Expected: 1; Actual: 4] https://github.com/DavidAnson/markdownlint/blob/v0.37.4/doc/md012.md

Check failure on line 112 in docs/src/getting-involved.md

View workflow job for this annotation

GitHub Actions / Build Docs

Multiple consecutive blank lines

docs/src/getting-involved.md:112 MD012/no-multiple-blanks Multiple consecutive blank lines [Expected: 1; Actual: 5] https://github.com/DavidAnson/markdownlint/blob/v0.37.4/doc/md012.md