[ZeroBrane Studio] Re: Debugger not breaking in external file with relative path

  • From: Derek Bailey <dbaileychess@xxxxxxxxx>
  • To: zerobrane <zerobrane@xxxxxxxxxxxxx>
  • Date: Wed, 4 May 2016 10:51:16 -0700

Hi Paul,

 I just tested this patch out and it work as I wanted, thanks much. I
appreciate it.

Take Care,

    Derek



On Fri, Apr 29, 2016 at 4:03 PM, Paul K <paul@xxxxxxxxxxxxx> wrote:

Hi Derek,

I came up with this patch that should address the issue your saw and
not slow the processing down too much:

diff --git a/lualibs/mobdebug/mobdebug.lua b/lualibs/mobdebug/mobdebug.lua
index 57bd07e..4d0bf52 100644
--- a/lualibs/mobdebug/mobdebug.lua
+++ b/lualibs/mobdebug/mobdebug.lua
@@ -583,6 +583,11 @@ local function debug_hook(event, line)
       -- The following will work if the supplied filename uses Unix path.
       if find(file, "^@") then
         file = gsub(gsub(file, "^@", ""), "\\", "/")
+        -- normalize paths that may include up-dir or same-dir references
+        -- if the path starts from the up-dir or same-dir reference,
+        -- prepend `basedir` to generate absolute path to keep
breakpoints working
+        if file:find("^%.?%./") then file = basedir..file end
+        if file:find("/%.?%./") then file =
file:gsub("[^/]+/%.%./",""):gsub("/%./","/") end
         -- need this conversion to be applied to relative and absolute
         -- file names as you may write "require 'Foo'" to
         -- load "foo.lua" (on a case insensitive file system) and
breakpoints

I've tested it on examples similar to yours and they are all handled
as expected. Let me know if this works for you and I'll check it in.

Paul.


Other related posts: