[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Interests in a breakpoint hook/breakpoint op patch?
- From: "Thomas Jericke" <tjericke@...>
- Date: Fri, 20 Apr 2012 19:26:03 +0200
liam mail wrote on 20-04-2012 17:05
> Subject: Re: Interests in a breakpoint hook/breakpoint op patch?
>
> On 20 April 2012 15:58, liam mail <liam.list@googlemail.com> wrote:
> > On 20 April 2012 15:52, Thomas Jericke <tjericke@indel.ch> wrote:
> >> For our project I have modified the Lua interpreter to support a new hook
> >> type (breakpoint hook) which is called every time the interpreter hits a
> >> breakpoint op.
> >> I could turn my modifications into a patch but I still need some work to do
> >> to have a general solution. My current solution is very adapted to my own
> >> needs. And as it is, the implementation should be improved as well.
> >> Basically I added another type of hooks that can be used with lua_sethook.
> >> Additionally I added a function to add a breakpoint at a source and
> >> linenumber. This function searches for the proto of the according source
> >> code and linenumber and then replaces the op_code at the first bytecode to
> >> op_breakpoint. Once the pc runs to such a op_breakpoint the hook is called
> >> (if it is installed) after the hook returns, the original op is executed.
> >> The reason for this patch is performance only. We tried the current Lua
> >> debuggers which use the line hook and it wasn't performing fast enough to
> >> use it with our system. With the breakpoint hook the impact on the runtime
> >> is close to zero as long as you don't hit a breakpoint. There is a quite big
> >> overhead when you install a breakpoint but this is not such a big problem as
> >> usually the user doesn't change his breakpoints all the time.
> >> Now as I said, I would need to do some work before I can release such a
> >> patch, so I would only do that if someone is actually interested in using
> >> it.
> >>
> >> --
> >> Thomas
> >>
> >>
> >
> > There was such a patch last year sometime from the LightRoom team IIRC.
> > What I would like is for Rio Lua is to either include such an operator
> > or maybe simply not falling through the vm loop on an unknown
> > instruction and instead calling the debug hook if one is present.
> >
> > Liam
>
>
> http://article.gmane.org/gmane.comp.lang.lua.general/69271/match=breakpoint
Thank you for the link. I have to say that I work under Lua 5.2. But I still will be able to improve my code on this basis. There seems to be a major difference between the approach I use to set a breakpoint and the approach of the patch in the link you posted. I search the proto by source file and line number. In the linked patch a function has to be on the stack to be able to install a breakpoint. I don't have this requirement. As I need to be able to add a breakpoint to a "running" interpreter at any time the approach in the linked patch will not work for me. Instead I have to have a structure of all protos running in the interpreter (currently I use a linked list) to find the proto of a given source name and line number.
Once I found the proto the behavior of my patch is very similar to the linked one.
--
Thomas