lua_debug - ryzom/ryzomcore GitHub Wiki


title: Debugging Lua Scripts description: Set up remote debugging for Lua scripts in the Ryzom client published: true date: 2023-03-01T05:14:06.399Z tags: editor: markdown dateCreated: 2020-11-13T06:52:53.867Z

Remote Debugging Lua

⚠️ This only works with the client_dev configuration (as generated by the build pipeline), or any client that has the script paths redirected to Y:\ryzomcore4\code\, whichever your development path is...

Copy https://raw.githubusercontent.com/pkulchenko/MobDebug/master/src/mobdebug.lua directly into the client directory Y:\ryzomcore4\pipeline\client_dev\.

Add AllowDebugLua = 1; to the client.cfg file.

Build luasocket from https://github.com/diegonehab/luasocket, edit Lua.props to match the paths of your Lua build, then just run the build project.

A pre-built binary is available under C:\2022q2_external_v143_x64\luasocket-master\x64\Release in the Quick Start package.

For example:

    <LUAV>5.4</LUAV>
    <LUAPREFIX>C:\2022q2_external_v143_x64\lua\</LUAPREFIX>
    <LUALIB>$(LUAPREFIX)\lib</LUALIB>
    <LUACDIR>$(LUAPREFIX)\bin</LUACDIR>
    <LUALDIR>$(LUAPREFIX)\bin\lua</LUALDIR>
    <LUAINC>$(LUAPREFIX)\include</LUAINC>
    <LUALIBNAME>lua.lib</LUALIBNAME>

For a debug build, change it to luad.lib, or adjust the Debug properties in the project directly, and build in Debug mode.

Copy socket/core.dll to your client directory, Y:\ryzomcore4\pipeline\client_dev\socket\, including the socket folder in the destination path.

Copy socket.lua to your client directory Y:\ryzomcore4\pipeline\client_dev\.

Launch ZeroBrane, or any other Lua editor with remote debugging support.

Set your debugger's project path to Y:\ryzomcore4\code\ryzom.

Add editor.autoactivate = true to the ZeroBrane system preferences.

Open at least one .lua file from the project, otherwise the software will complain.

Start listening in your debugger (Project > Start Debugging Server in ZeroBrane).

Launch the Ryzom Core client.

Run /ah show debug_info to show the debug console.

Run command /ah lua require('mobdebug').start() in the Ryzom client to connect the debugger.

The client may halt, press the resume button in the debugger. Make sure to never push stop or start, or things will break badly.

Then /ah lua debugBreak=require('mobdebug').pause to enable break on assert.

Exit the client to stop debugging, do not use the debugger's stop function.

After a debugging session, the listening debugger needs to be restarted.

⚠️ **GitHub.com Fallback** ⚠️