IEDA远程调试工具使用

comradexiao / 2024-11-09 / 原文

配置IDEA

  • 选择Lua Remote(Mobdebug)进行设置

  • 端口默认为8172,如无特殊需求不建议修改。

  • realRequire("mobdebug").start("XXXX", 8172)添加到Lua代码入口处,一般默认为Init.lua中,XXXX为本地ip地址。

  • 左侧列表中选中Lua文件夹并右键-Mark Directory as-Sources Root

  • 如果准备进行远程或真机调试,则选择Lua Remote(Mobdebug)配置进行添加。
    可以将下列代码拷贝到Init.lua

local function Debug(isLocal)
    --package.cpath = package.cpath .. ';C:/Users/admin/.IntelliJIdea2018.3/config/plugins/intellij-emmylua/classes/debugger/emmy/windows/x64/?.dll'
    --local dbg = require('emmy_core')
    --dbg.tcpListen('localhost', 9966)
    if isLocal then
        package.cpath = package.cpath .. ';C:/Users/admin/AppData/Roaming/JetBrains/IntelliJIdea2021.1/plugins/EmmyLua/debugger/emmy/windows/x64/?.dll'
        local dbg = require('emmy_core')
        dbg.tcpConnect('localhost', 9966)
    else
        require("mobdebug").start("192.168.8.7", 8172)
    end
end

if _G.IsEditor then
    Logger.Info('Connect local debugger')
    --_G.tryCatch(Debug(true))
    _G.tryCatch(Debug,true)
else
    Logger.Info('Connect remote debugger')
    --Debug(false)
    _G.tryCatch(Debug,false)
end

  • 开启Debugger,Console中显示Start mobdebug server at port:8172 Waiting for process connection...表明IDE启动成功。