Code Monkey home page Code Monkey logo

Comments (7)

tomblind avatar tomblind commented on September 17, 2024

Thanks for posting this. It looks like in defold, the debug facilities see scripts as existing at absolute paths within the project hierarchy (so /main/main.script instead of main/main.script or ./main/main.script) and this confuses the debugger.
I'd like to try a few things, but it looks like the debugger is pre-compiled into the project as a luac file. Would it be possible to dynamically load the debugger script somehow?

from local-lua-debugger-vscode.

thejustinwalsh avatar thejustinwalsh commented on September 17, 2024

Would it be possible to dynamically load the debugger script somehow?

You could potentially use the same cached module hack I use to get Defold to load the lldebugger script dynamically, or create a native extension that overrides, or replaces it.

It looks like in defold, the debug facilities see scripts as existing at absolute paths within the project hierarchy (so /main/main.script instead of main/main.script or ./main/main.script) and this confuses the debugger.

That makes sense as the scripts are actually contained in an archive at runtime and Defold overrides the loader to read the scripts from that archive file where the paths would be rooted absolute.

Another interesting piece is when you include extensions / libraries, the source doesn't even exist on the file system directly, it is in another archive and loaded directly from that archive, so if you where to try and step into a library script to debug, I don't even know what would happen.

from local-lua-debugger-vscode.

thejustinwalsh avatar thejustinwalsh commented on September 17, 2024

Would it be reasonable to allow for a callback function to be registered when you load the lldebugger module in lua that hints / assists in remapping the paths and something like that. I understand that Defold is a pretty custom integration of lua and maybe a mechanism like that would help other projects that load scripts in even wilder ways work?

Like a path mapping middleware from in memory archive to where that thing might live on disk essentially.

I'll get spun up on debugging vscode extensions so I can be more useful as well in the interim.

from local-lua-debugger-vscode.

tomblind avatar tomblind commented on September 17, 2024

You could potentially use the same cached module hack I use to get Defold to load the lldebugger script dynamically

This is what I was hoping. But main.script is also precompiled so I can't just modify that. Can I recompile those myself with lua5.1, or do I need to use defold?

Another interesting piece is when you include extensions / libraries, the source doesn't even exist on the file system directly, it is in another archive and loaded directly from that archive, so if you where to try and step into a library script to debug, I don't even know what would happen.

Without source the debugger will either skip those calls or step through them while showing a greyed-out callstack. I'm not sure which (this is mostly controlled by vscode).

Would it be reasonable to allow for a callback function to be registered when you load the lldebugger module in lua that hints / assists in remapping the paths and something like that.

This is certainly a possible feature that could be added, but it shouldn't be necessary in this case. The scriptRoots option was made to solve this exact issue and the fact it's not working for this situation is a bug.

from local-lua-debugger-vscode.

thejustinwalsh avatar thejustinwalsh commented on September 17, 2024

This is what I was hoping. But main.script is also precompiled so I can't just modify that. Can I recompile those myself with lua5.1, or do I need to use defold?

Oh, I see, yeah that was compiled by Defold, uses all kinds of custom lua functions / user data exposed by Defold.
The game.project file is what you would open in Defold and then just select Build. If this if going too deep I would be happy to try out anything you want me to test, log, etc as well.

Without source the debugger will either skip those calls or step through them while showing a greyed-out callstack. I'm not sure which (this is mostly controlled by vscode).

Seems reasonable.

This is certainly a possible feature that could be added, but it shouldn't be necessary in this case. The scriptRoots option was made to solve this exact issue and the fact it's not working for this situation is a bug.

True. Scripts roots does indeed seem like the right move for pathing, over a plugin.

from local-lua-debugger-vscode.

tomblind avatar tomblind commented on September 17, 2024

I've committed a fix for the breakpoints and scriptRoots not working (at least it works on the provided example).

Note that scriptRoots must be set for vscode to find the files properly (ex. scriptRoots: ["."]), otherwise your breakpoints will hit but vscode won't actually open the file and goto the line.

from local-lua-debugger-vscode.

thejustinwalsh avatar thejustinwalsh commented on September 17, 2024

Ahhhhh, scriptRoots: ["."]. Thanks again for all your hard work!

from local-lua-debugger-vscode.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.