README
¶
what is this?
this is the client side for EmmyLua and supported to debug the gopher-lua's lua code
how to use
- install EmmyLua for goland/idea/... and learn how to debug lua with this plugin
- go get github.com/edolphin-ydf/gopherlua-debugger
- edit your go.mod, add this line
replace github.com/yuin/gopher-lua => github.com/edolphin-ydf/gopher-lua v0.0.0-20191105142246-92ca436742b9
- in your go code, after
L := lua.NewState()
add a new linelua_debugger.Preload(L)
, of course, you should import gopher-lua-debugger - in your lua code, anywhere you want to start debug/break, add the following line
local dbg = require('emmy_core')
dbg.tcpConnect('localhost', 9966)
why need replace gopher-lua?
the original gopher-lua doesn't implement the debug.hook()
func. the replacement implement it and fix a bug for debug.getlocal().
if the author accepted my patch, the replacement won't need anymore. But you need the replace now!!
what is lua_debugger.Preload(L)
do?
this will preload the emmy_core module which support the tcpConnect
, then you can connect to the EmmyLua server to start debug
limitation
the EmmyLua provide two ways to start a debug, the ide as a server and the ide as a client. but the gopherlua-debugger only support ide as server, lua instance as client.
contribution
issue and pr are welcome
Documentation
¶
Index ¶
- Constants
- Variables
- func EnvIndexFunction(L *lua.LState) int
- func FixPath(L *lua.LState) int
- func GoLuaTypeToCLuaType(t lua.LValueType) (int, string)
- func Hook(L *lua.LState) int
- func Loader(L *lua.LState) int
- func LuaError(L *lua.LState, msg string) int
- func ParsePathParts(file string, paths []string) []string
- func Preload(L *lua.LState)
- func TcpConnect(L *lua.LState) int
- type Ar
- type BreakPoint
- type Debugger
- func (d *Debugger) AddBreakPoint(bp *BreakPoint)
- func (d *Debugger) Attach(L *lua.LState)
- func (d *Debugger) CreateEnv(stackLevel int) (*lua.LTable, bool)
- func (d *Debugger) DoAction(action proto.DebugAction)
- func (d *Debugger) DoEval(evalContext *EvalContext) bool
- func (d *Debugger) EnterDebugMode(L *lua.LState)
- func (d *Debugger) Eval(ctx *EvalContext)
- func (d *Debugger) ExitDebugMode()
- func (d *Debugger) FindBreakPoint(L *lua.LState, ar *Ar) *BreakPoint
- func (d *Debugger) FindBreakPointByFile(file string, line int) *BreakPoint
- func (d *Debugger) GetFile(L *lua.LState, ar *Ar) string
- func (d *Debugger) GetStackLevel(L *lua.LState, skipGo bool) int
- func (d *Debugger) GetStacks(L *lua.LState) []*Stack
- func (d *Debugger) GetVariable(name string, value lua.LValue, depth int) *Variable
- func (d *Debugger) HandleBreak(L *lua.LState)
- func (d *Debugger) Hook(L *lua.LState, ar *Ar)
- func (d *Debugger) MatchFileName(chunkName string, fileName string) bool
- func (d *Debugger) RefreshLineSet()
- func (d *Debugger) RemoveAllBreakpoints()
- func (d *Debugger) RemoveBreakPoint(file string, line int)
- func (d *Debugger) SetHookState(L *lua.LState, newState HookStateInter)
- func (d *Debugger) Start(code string)
- func (d *Debugger) UpdateHook(L *lua.LState, mask string)
- type EvalContext
- type Facade
- func (f *Facade) HandleMsg(cmd int, req interface{})
- func (f *Facade) OnActionReq(req *proto.ActionReq)
- func (f *Facade) OnAddBreakPointReq(req *proto.AddBreakPointReq)
- func (f *Facade) OnBreak(L *lua.LState)
- func (f *Facade) OnEvalReq(req *proto.EvalReq)
- func (f *Facade) OnEvalResult(ctx *EvalContext)
- func (f *Facade) OnInitReq(req *proto.InitReq)
- func (f *Facade) OnReadyReq()
- func (f *Facade) OnRemoveBreakPointReq(req *proto.RemoveBreakPointReq)
- func (f *Facade) TcpConnect(L *lua.LState, host string, port int) error
- func (f *Facade) WaiteIDE(force bool)
- type HookState
- type HookStateBreak
- type HookStateContinue
- type HookStateInter
- type HookStateStepIn
- type HookStateStepOut
- type HookStateStepOver
- type HookStateStop
- type Stack
- type StackLevelBasedState
- type Transport
- type Variable
Constants ¶
View Source
const ( Lua_HookCall = iota Lua_HookRet Lua_HookLine Lua_HookCount )
View Source
const ( LUA_TNONE = iota - 1 LUA_TNIL LUA_TBOOLEAN LUA_TLIGHTUSERDATA LUA_TNUMBER LUA_TSTRING LUA_TTABLE LUA_TFUNCTION LUA_TUSERDATA LUA_TTHREAD )
Variables ¶
View Source
var Dbg = newDebugger()
View Source
var Fcd = newFacade()
Functions ¶
func EnvIndexFunction ¶
func GoLuaTypeToCLuaType ¶
func GoLuaTypeToCLuaType(t lua.LValueType) (int, string)
func ParsePathParts ¶
func TcpConnect ¶
Types ¶
type BreakPoint ¶
type Debugger ¶
type Debugger struct { SkipHook bool LineSet map[int]struct{} BreakPoints []*BreakPoint ExtNames []string CurrentState *lua.LState HelperCode string States map[*lua.LState]struct{} HookState HookStateInter // contains filtered or unexported fields }
func (*Debugger) AddBreakPoint ¶
func (d *Debugger) AddBreakPoint(bp *BreakPoint)
func (*Debugger) DoAction ¶
func (d *Debugger) DoAction(action proto.DebugAction)
func (*Debugger) DoEval ¶
func (d *Debugger) DoEval(evalContext *EvalContext) bool
func (*Debugger) EnterDebugMode ¶
func (*Debugger) Eval ¶
func (d *Debugger) Eval(ctx *EvalContext)
func (*Debugger) ExitDebugMode ¶
func (d *Debugger) ExitDebugMode()
func (*Debugger) FindBreakPoint ¶
func (d *Debugger) FindBreakPoint(L *lua.LState, ar *Ar) *BreakPoint
func (*Debugger) FindBreakPointByFile ¶
func (d *Debugger) FindBreakPointByFile(file string, line int) *BreakPoint
func (*Debugger) GetVariable ¶
func (*Debugger) HandleBreak ¶
func (*Debugger) MatchFileName ¶
func (*Debugger) RefreshLineSet ¶
func (d *Debugger) RefreshLineSet()
func (*Debugger) RemoveAllBreakpoints ¶
func (d *Debugger) RemoveAllBreakpoints()
func (*Debugger) RemoveBreakPoint ¶
func (*Debugger) SetHookState ¶
func (d *Debugger) SetHookState(L *lua.LState, newState HookStateInter)
type EvalContext ¶
type Facade ¶
type Facade struct {
// contains filtered or unexported fields
}
func (*Facade) OnActionReq ¶
func (*Facade) OnAddBreakPointReq ¶
func (f *Facade) OnAddBreakPointReq(req *proto.AddBreakPointReq)
func (*Facade) OnEvalResult ¶
func (f *Facade) OnEvalResult(ctx *EvalContext)
func (*Facade) OnReadyReq ¶
func (f *Facade) OnReadyReq()
func (*Facade) OnRemoveBreakPointReq ¶
func (f *Facade) OnRemoveBreakPointReq(req *proto.RemoveBreakPointReq)
type HookState ¶
type HookState struct {
// contains filtered or unexported fields
}
func (*HookState) ProcessHook ¶
type HookStateBreak ¶
type HookStateBreak struct {
HookState
}
func (*HookStateBreak) ProcessHook ¶
func (h *HookStateBreak) ProcessHook(debugger *Debugger, L *lua.LState, ar *Ar)
type HookStateContinue ¶
type HookStateContinue struct {
HookState
}
type HookStateInter ¶
type HookStateStepIn ¶
type HookStateStepIn struct { StackLevelBasedState // contains filtered or unexported fields }
func (*HookStateStepIn) ProcessHook ¶
func (h *HookStateStepIn) ProcessHook(debugger *Debugger, L *lua.LState, ar *Ar)
type HookStateStepOut ¶
type HookStateStepOut struct {
StackLevelBasedState
}
func (*HookStateStepOut) ProcessHook ¶
func (h *HookStateStepOut) ProcessHook(debugger *Debugger, L *lua.LState, ar *Ar)
type HookStateStepOver ¶
type HookStateStepOver struct { StackLevelBasedState // contains filtered or unexported fields }
func (*HookStateStepOver) ProcessHook ¶
func (h *HookStateStepOver) ProcessHook(debugger *Debugger, L *lua.LState, ar *Ar)
type HookStateStop ¶
type HookStateStop struct {
HookState
}
type StackLevelBasedState ¶
type StackLevelBasedState struct { HookState // contains filtered or unexported fields }
func (*StackLevelBasedState) Start ¶
func (h *StackLevelBasedState) Start(debugger *Debugger, current *lua.LState) bool
func (*StackLevelBasedState) UpdateStackLevel ¶
func (h *StackLevelBasedState) UpdateStackLevel(debugger *Debugger, L *lua.LState, ar *Ar)
Source Files
¶
Click to show internal directories.
Click to hide internal directories.