Skip to content

Debugging Scripts

starkos edited this page Apr 10, 2021 · 3 revisions

⚠️ We have a new website! Visit now for the most update to date documentation.
       This wiki is no longer being maintained.


ZeroBrane Studio

Since Premake's update to 5.3, the only debugger that seems to be able to debug premake is the free ZeroBrane Studio IDE.

  • Download ZeroBrane Studio and install it
  • Compile a debug build of Premake. Your premake build should have built luasocket.dll, and there is a mobdebug.lua file in the root. Copy both alongside your premake executable to the location where you intend to run premake.
  • Run ZeroBrane Studio and in the Project dropdown, select Start Debugger Server.
  • There's also a Project tab. Right-click the root folder and select Project Directory > Choose... to select the root of the premake repository. Open the lua file you want to debug (you can start with _premake_init.lua) and set a breakpoint.
  • Run premake with your desired command line and append --scripts=path_to_premake --debugger path_to_premake is the root of the repository where src lives. This isn't necessary if you run premake in the same directory as the src folder. If all goes well premake should think for a moment and the debugger should flash indicating that it has broken execution.
  • An example command line would be C:/my_project_folder/premake5.exe vs2015 --scripts=C:/premake_repo/ --debugger

Old Methods

Decoda

You can debug your Premake project and module scripts using the free Decoda IDE.

Configure your project debugging settings:

  • Command is the path to your Premake executable. This needs to be a debug build of Premake, as Decoda needs access to the executable's symbol table.

  • Command Arguments are the arguments to pass to Premake. You will need to specify the location of Premake's own scripts via --scripts=path/to/premake5. If you project script is not named premake5.lua or is not located in the working directory (below), you should also specify --file=path/to/premake5.lua.

  • Working Directory is the directory that should be made current before Premake is launched.

  • Symbols Directory is the path to Premake's PDB file, which is usually located in the bin/debug directory within Premake's source tree (the same directory which contains the debug executable).

Now open the _premake_main.lua script, and set a breakpoint in the _premake_main() function.

Hit F5, and you're good to go. You can add files in the "project explorer", but they will eventually be added automatically as the script executes.

Visual Studio

Install babelua extension from here https://babelua.codeplex.com/

Go to the lua menu ..create a new project just like in decoda ... This project will appear in your solution. Set it as the default one and run it

Of course this will not work with embedded scripts. So you will need to pass the /scripts paramaters

Note that after using the plugin i noticed some issues

  • visual studio tends to stall a lot when loading a project
  • i had some issues with another extension that i had installed ... a custom highlighter

Other Options

It may also be possible to debug Premake scripts with SLED or Eclipse LDT. If you give either of these a try, let us know what you find out!.

Clone this wiki locally