Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
tdev committed Nov 18, 2023
2 parents 94352db + bfdbe82 commit 74fb8e5
Show file tree
Hide file tree
Showing 4 changed files with 161 additions and 47 deletions.
6 changes: 3 additions & 3 deletions Readme_BeamNG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ This project consists of a c++ part that is compiled with the game and runs with
# Prerequisites

1) [Install VSCode](https://code.visualstudio.com)
2) Install the [`LRDB` (Lua Remote Debugger) extension](https://marketplace.visualstudio.com/items?itemName=satoren.lrdb) for VScode
2) Install the [`LRDB` (Lua Remote Debugger) extension](https://marketplace.visualstudio.com/items?itemName=beamng.lrdb-beamng) for VScode

# Quickstart

1) Open game folder in VScode as workspace: `File` > `Open Folder...` > `<select game folder>`
2) Place breakpoints in your Lua files. (Highlight a line and press `F9`)
3) Start the game separatly with the command line arguments
3) Start the game separately with the command line arguments (case sensitive!)
`-luadebug -attachOnStart` - The game will hang and wait for VScode to connect.
4) Press `F5` in VScode (Launch in VScode to attach to the game).

Expand Down Expand Up @@ -118,4 +118,4 @@ Run: `extensions.test_debugger.test()`

The debugger is based on [LRDB-0.3.1](https://github.com/satoren/LRDB) but with heavy modifications for compatiblity and speed.

See [LICENSE_1_0.txt](LICENSE_1_0.txt)
See [LICENSE_1_0.txt](LICENSE_1_0.txt)
18 changes: 18 additions & 0 deletions src/debugger/Client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
} from './JsonRpc'

export type DebugRequest =
| InitRequest
| StepRequest
| StepInRequest
| StepOutRequest
Expand Down Expand Up @@ -84,6 +85,16 @@ export class Client {
})
}

init = (
params: InitRequest['params']
): Promise<DebugResponseType<InitRequest>> =>
this.send({
method: 'init',
jsonrpc: '2.0',
id: this.seqId++,
params,
})

step = (): Promise<DebugResponseType<StepRequest>> =>
this.send({ method: 'step', jsonrpc: '2.0', id: this.seqId++ })
stepIn = (): Promise<DebugResponseType<StepInRequest>> =>
Expand Down Expand Up @@ -209,6 +220,12 @@ export interface RunningNotify extends JsonRpcNotify {
params?: never
}

export interface InitRequest extends JsonRpcRequest {
method: 'init'
params: {
protocol_version: string
}
}
interface StepRequest extends JsonRpcRequest {
method: 'step'
params?: never
Expand Down Expand Up @@ -310,6 +327,7 @@ type Breakpoint = {
}

type ResponseResultType = {
init: never
get_stacktrace: StackInfo[]
get_local_variable: Record<string, unknown>
get_upvalues: Record<string, unknown>
Expand Down
2 changes: 1 addition & 1 deletion src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { LuaInstancesTreeViewProvider } from './luaInstancesTreeViewProvider'
// The compile time flag 'runMode' controls how the debug adapter is run.
// Please note: the test suite only supports 'external' mode.
// 'inline' mode is great for debugging.
const runMode: 'external' | 'server' | 'inline' = 'external'
const runMode: 'external' | 'server' | 'inline' = 'server'

export function activate(context: vscode.ExtensionContext): void {

Expand Down
Loading

0 comments on commit 74fb8e5

Please sign in to comment.