lua_debugger

package module
v0.1.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 4, 2024 License: MIT Imports: 15 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

what is this?

this is the client side for EmmyLua and supported to debug the gopher-lua's lua code

how to use

  1. install EmmyLua for goland/idea/... and learn how to debug lua with this plugin
  2. go get github.com/gavin-wuz/gopherlua-debugger
  3. edit your go.mod, add this line replace github.com/yuin/gopher-lua => github.com/edolphin-ydf/gopher-lua v0.0.0-20191105142246-92ca436742b9
  4. in your go code, after L := lua.NewState() add a new line lua_debugger.Preload(L), of course, you should import gopher-lua-debugger
  5. 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

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
)
View Source
const (
	KeyDebuggerFcd = "__Debugger_Fcd"
)

Variables

This section is empty.

Functions

func EnvIndexFunction

func EnvIndexFunction(L *lua.LState) int

func FixPath

func FixPath(L *lua.LState) int

func GoLuaTypeToCLuaType

func GoLuaTypeToCLuaType(t lua.LValueType) (int, string)

func Hook

func Hook(L *lua.LState) int

func Loader

func Loader(L *lua.LState) int

func LuaError

func LuaError(L *lua.LState, msg string) int

func ParsePathParts

func ParsePathParts(file string, paths []string) []string

func Preload

func Preload(L *lua.LState)

func TcpConnect

func TcpConnect(L *lua.LState) int

Types

type Ar

type Ar struct {
	lua.Debug
	Event int
}

type BreakPoint

type BreakPoint struct {
	File      string
	Condition string
	PathParts []string
	Line      int
}

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) Attach

func (d *Debugger) Attach(L *lua.LState)

func (*Debugger) CreateEnv

func (d *Debugger) CreateEnv(stackLevel int) (*lua.LTable, bool)

func (*Debugger) DoAction

func (d *Debugger) DoAction(action proto.DebugAction)

func (*Debugger) DoEval

func (d *Debugger) DoEval(evalContext *EvalContext) bool

func (*Debugger) EnterDebugMode

func (d *Debugger) EnterDebugMode(L *lua.LState)

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) GetFile

func (d *Debugger) GetFile(L *lua.LState, ar *Ar) string

func (*Debugger) GetStackLevel

func (d *Debugger) GetStackLevel(L *lua.LState, skipGo bool) int

func (*Debugger) GetStacks

func (d *Debugger) GetStacks(L *lua.LState) []*Stack

func (*Debugger) GetVariable

func (d *Debugger) GetVariable(name string, value lua.LValue, depth int) *Variable

func (*Debugger) HandleBreak

func (d *Debugger) HandleBreak(L *lua.LState)

func (*Debugger) Hook

func (d *Debugger) Hook(L *lua.LState, ar *Ar)

func (*Debugger) MatchFileName

func (d *Debugger) MatchFileName(chunkName string, fileName string) bool

func (*Debugger) RefreshLineSet

func (d *Debugger) RefreshLineSet()

func (*Debugger) RemoveAllBreakpoints

func (d *Debugger) RemoveAllBreakpoints()

func (*Debugger) RemoveBreakPoint

func (d *Debugger) RemoveBreakPoint(file string, line int)

func (*Debugger) SetHookState

func (d *Debugger) SetHookState(L *lua.LState, newState HookStateInter)

func (*Debugger) Start

func (d *Debugger) Start(code string)

func (*Debugger) UpdateHook

func (d *Debugger) UpdateHook(L *lua.LState, mask string)

type EvalContext

type EvalContext struct {
	Expr       string
	Error      string
	Seq        int
	StackLevel int
	Depth      int
	CacheId    int
	Result     *Variable
	Success    bool
}

type Facade

type Facade struct {
	// contains filtered or unexported fields
}

func (*Facade) HandleMsg

func (f *Facade) HandleMsg(cmd int, req interface{})

func (*Facade) OnActionReq

func (f *Facade) OnActionReq(req *proto.ActionReq)

func (*Facade) OnAddBreakPointReq

func (f *Facade) OnAddBreakPointReq(req *proto.AddBreakPointReq)

func (*Facade) OnBreak

func (f *Facade) OnBreak(L *lua.LState)

func (*Facade) OnEvalReq

func (f *Facade) OnEvalReq(req *proto.EvalReq)

func (*Facade) OnEvalResult

func (f *Facade) OnEvalResult(ctx *EvalContext)

func (*Facade) OnInitReq

func (f *Facade) OnInitReq(req *proto.InitReq)

func (*Facade) OnReadyReq

func (f *Facade) OnReadyReq()

func (*Facade) OnRemoveBreakPointReq

func (f *Facade) OnRemoveBreakPointReq(req *proto.RemoveBreakPointReq)

func (*Facade) TcpConnect

func (f *Facade) TcpConnect(L *lua.LState, host string, port int) error

func (*Facade) WaiteIDE

func (f *Facade) WaiteIDE(done chan<- struct{}, force bool)

type HookState

type HookState struct {
	// contains filtered or unexported fields
}

func (*HookState) ProcessHook

func (h *HookState) ProcessHook(debugger *Debugger, L *lua.LState, ar *Ar)

func (*HookState) Start

func (h *HookState) Start(debugger *Debugger, current *lua.LState) bool

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
}

func (*HookStateContinue) Start

func (h *HookStateContinue) Start(debugger *Debugger, current *lua.LState) bool

type HookStateInter

type HookStateInter interface {
	Start(debugger *Debugger, current *lua.LState) bool
	ProcessHook(debugger *Debugger, L *lua.LState, ar *Ar)
}

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)

func (*HookStateStepIn) Start

func (h *HookStateStepIn) Start(debugger *Debugger, current *lua.LState) bool

type HookStateStepOut

type HookStateStepOut struct {
	StackLevelBasedState
}

func (*HookStateStepOut) ProcessHook

func (h *HookStateStepOut) ProcessHook(debugger *Debugger, L *lua.LState, ar *Ar)

func (*HookStateStepOut) Start

func (h *HookStateStepOut) Start(debugger *Debugger, current *lua.LState) bool

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)

func (*HookStateStepOver) Start

func (h *HookStateStepOver) Start(debugger *Debugger, current *lua.LState) bool

type HookStateStop

type HookStateStop struct {
	HookState
}

func (*HookStateStop) Start

func (h *HookStateStop) Start(debugger *Debugger, current *lua.LState) bool

type Stack

type Stack struct {
	File             string
	FunctionName     string
	Level            int
	Line             int
	LocalVariables   []*Variable
	UpvalueVariables []*Variable
}

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)

type Transport

type Transport struct {
	Handler func(int, interface{})
	// contains filtered or unexported fields
}

func (*Transport) Connect

func (t *Transport) Connect(host string, port int) error

func (*Transport) Send

func (t *Transport) Send(cmd int, msg interface{})

type Variable

type Variable struct {
	Name          string
	NameType      int
	Value         string
	ValueType     int
	ValueTypeName string
	Children      []*Variable
	CacheId       int
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
⌂ 换网址