danielga / vscode-gmrdb

Garry's Mod Lua debugger for Visual Studio Code
https://github.com/danielga/vscode-gmrdb
Boost Software License 1.0
35 stars 2 forks source link

Tutorial on getting it setup on SRCDS locally #1

Closed johnnyhuy closed 3 years ago

johnnyhuy commented 3 years ago

Hey, this has been the only best method I've seen to debug Lua on Garry's Mod so far.

However, I can't seem to start up the srcds from launch settings defined on the README.md.

{
    "version": "0.2.0",
    "configurations": [
        {
            "type": "gmrdb",
            "request": "launch",
            "name": "Launch Garry's Mod",
            "program": "${workspaceFolder}/srcds_win64.exe",
            "cwd": "${workspaceFolder}",
            "args": [
                "-console",
                "-game",
                "garrysmod",
                "-ip",
                "localhost",
                "-port",
                "27015",
                "+map",
                "gm_construct",
                "+maxplayers",
                "2"
            ],
            "sourceRoot": "${workspaceFolder}/garrysmod",
            "port": 21111,
            "sourceFileMap": {
                "${workspaceFolder}": "addons/gmrdb"
            },
            "stopOnEntry": true
        }
    ]
}

Wrote a small addon hoping it will trigger the remote server based on the gif provided.

require("rdb")
rdb.activate()

I'm getting this error when loading the addon.

Couldn't include file 'includes\modules\rdb.lua' (File not found) (@addons/rdb/lua/autorun/server/rdb.lua (line 1))

[rdb] addons/rdb/lua/autorun/server/rdb.lua:1: Module not found!
  1. require - [C]:-1
   2. unknown - addons/rdb/lua/autorun/server/rdb.lua:1

I've placed the following DDL files in:

garrysmod\lua\bin\gmcl_rdb_win32.dll
garrysmod\lua\bin\gmsv_rdb_win32.dll

I'm happy to write out instructions on this repo if we can get this working. Many thanks.

Update

Found out that the library file can only run on 32-bit SRCDS based on releases found here

However, I'm now getting this on 32-bit SRCDS. Here's an output using gmod_require.

[gmrdb] error loading module 'rdb' from file 'gmsv_rdb_win32.dll':
        The specified procedure could not be found.

  1. error - [C]:-1
   2. searcher - addons/gmrdb/lua/includes/modules/require.lua:65
    3. require - addons/gmrdb/lua/includes/modules/require.lua:148
     4. unknown - addons/gmrdb/lua/autorun/server/gmrdb.lua:3
johnnyhuy commented 3 years ago

Looks like we've got it working with 64-bit with the pre-release artifact. Didn't realise there was were prebuilt artifacts (spent the entire night trying to rebuild the projec tin 64-bit 😅)

This technique is to "launch" the server and then "attach" a debugger to start debugging.

{
    "version": "0.2.0",
    "configurations": [
        {
            "type": "gmrdb",
            "request": "attach",
            "host": "localhost",
            "port": 21111,
            "name": "Attach to Garry's Mod",
            "sourceRoot": "${workspaceFolder}/garrysmod",
            "sourceFileMap": {
                "${workspaceFolder}": "addons/rdb"
            },
            "stopOnEntry": true
        },
        {
            "type": "gmrdb",
            "request": "launch",
            "name": "Launch Garry's Mod",
            "program": "${workspaceFolder}/srcds_win64.exe",
            "cwd": "${workspaceFolder}",
            "args": [
                "-console",
                "-game",
                "garrysmod",
                "-ip",
                "localhost",
                "-port",
                "27015",
                "+map",
                "gm_construct",
                "+maxplayers",
                "2"
            ],
            "sourceRoot": "${workspaceFolder}/garrysmod",
            "port": 21111,
            "sourceFileMap": {
                "${workspaceFolder}": "addons/rdb"
            },
            "stopOnEntry": true
        }
    ]
}

image

64-bit works but the 32-bit error still remains.

[gmrdb] error loading module 'rdb' from file 'gmsv_rdb_win32.dll':
        The specified procedure could not be found.

  1. error - [C]:-1
   2. searcher - addons/gmrdb/lua/includes/modules/require.lua:65
    3. require - addons/gmrdb/lua/includes/modules/require.lua:148
     4. unknown - addons/gmrdb/lua/autorun/server/gmrdb.lua:3