actboy168 / lua-debug

Lua Debug Adapter for Visual Studio Code
MIT License
435 stars 94 forks source link

Shebang on first line causes breakpoint to be ignored #153

Closed jradxl closed 2 years ago

jradxl commented 2 years ago

Describe the bug Shebang on first line causes breakpoint to be ignored

To Reproduce Steps to reproduce the behavior:

Uncomment the first line in the files like this, add a breakpoint, and the breakpoint is ignored $cat hello1.lua --#!/usr/bin/env -S lua -E -W print("Lua Script Test File 1") print("Test 1") print("Test 2")

$cat hello2.lua --#!/usr/local/bin/lua print("Lua Script Test File 2") print("Test 1") print("Test 2")

Expected behavior It would be nice that the #! shebang line did not prevent the breakpoint from working

Screenshots If applicable, add screenshots to help explain your problem. Not applicable

Environment (please complete the following information): Linux Ubuntu 21.10, mate VSCode 1.62.0 Lua Language Server 2.4.7 Lua Debug 1.50.1

launch.json

{
    "version": "0.2.0",
    "configurations": [
        {
            "type": "lua",
            "request": "launch",
            "name": "Debug Lua File",
            "stopOnEntry": false,
            "program": "${relativeFile}"
        }
    ]
}
actboy168 commented 2 years ago

This is a bug in lua. Lua's parser always adds some bytecode to the first line, so the first line is always a valid line, no matter what the code is.

jradxl commented 2 years ago

Thank you for saying. It's a pity. But just to say, the other Lua extension that offers debugging support, "Lua Helper" v0.2.1 by yinfei, doesn't have this issue. But perhaps, it acheives debugging support in a different way. Thx

actboy168 commented 2 years ago

Fixed in 6a7390777eacc4b25010a2434cfdddaf656033f9 and 7a1bc23d170b5a135b57aa7d797fce13c59536e0

s6mike commented 2 years ago

Hi, I'm using this extension for the first time, and I'm getting this issue too.

To reproduce, add breakpoint to this file:

!/usr/bin/env lua

print(_VERSION) print 'Hello, World!' print 'Hello, World2!'

breakpoints grey out as soon as I launch debugger.

Commenting out #! line fixes this.

Environment:

launch.json: { "arg": [], "name": "launch", "program": "${file}", "request": "launch", "stopOnEntry": false, "type": "lua" },

Extension: v1.58.2 Lua v5.3.4

VSCode: Version: 1.68.1 Commit: 30d9c6cd9483b2cc586687151bcbcd635f373630 Date: 2022-06-15T02:58:26.441Z Electron: 17.4.7 Chromium: 98.0.4758.141 Node.js: 16.13.0 V8: 9.8.177.13-electron.0 OS: Linux x64 5.10.110-15808-ge5740beba59b

s6mike commented 2 years ago

Raised as new issue: https://github.com/actboy168/lua-debug/issues/189