[lldb-dev] break on exceptions/windows
Jim Ingham via lldb-dev
lldb-dev at lists.llvm.org
Mon Apr 4 12:20:01 PDT 2016
> On Apr 4, 2016, at 11:48 AM, Carlo Kok <ck at remobjects.com> wrote:
> Op 2016-04-04 om 20:41 schreef Greg Clayton:
>>> On Apr 4, 2016, at 11:36 AM, Carlo Kok <ck at remobjects.com> wrote:
>>> There should be a way then to do a "break on every exception", instead of just 1 specific code.
>> That would be easy with the --exception-name:
>> (lldb) breakpoint set --exception-name=all
>>> and some way for the api to get the payload (which can have a variable number of parameters)
>> What are you thinking here? Example?
> I have a frontend language (and I imagine lots of others have one) where I can throw exceptions. Windows has no predefined way of how an exception object is formatted, you give it a list of pointer sized ints and a count, and that's what it fills the exception object with, for example I pass:
>  Return address
>  frame pointer
>  Class instance of the exception object
> with my custom exception code.
> msvc does the same with completely different values. Other languages will have their own values. When using the api I would want access to the code (To know of it's mine, these are the cods Zachery Turner mentioned) and the payload (to get access to the object) so that I show what exception occurred and turn it into a string representation.
Language exceptions are a general class of thing, and those should all be treated similarly if possible.
The way you would do this for your new language is to would add a LanguageRuntime for your language, and that would implement CreateExceptionBreakpoint using a BreakpointResolverWindowsException for the correct exception code. The Object filtering is done using "BreakpointPreconditions", which are a way for a breakpoint to stick some code that gets called right when the breakpoint is hit before any of the other ShouldStop machinery takes over. When you make the breakpoint you would pass the "thrown object specifier" to the breakpoint, which would make an appropriate precondition that would know how to dig out the object and compare.
So you would see:
(lldb) breakpoint set -E MyNewLanguage -O MyObjectName
This is currently only implemented in Swift, though the needed infrastructure is present in the llvm tree.
If there are other things you want to do that aren't generalizable, then we should treat them as opaque data that gets passed to the platform and it will know how to make the resolver & if needed precondition to do the filtering.
> Carlo Kok
> RemObjects Software
More information about the lldb-dev