This is an archive of the discontinued LLVM Phabricator instance.

Add DidStartExecuting/WillFinishExecuting methods to Expression.
ClosedPublic

Authored by lhames on May 4 2017, 5:52 PM.

Details

Reviewers
jingham
Summary

These methods can be used by the derived expression types to perform expression
specific and/or language specific actions before and after the expression runs.
(ThreadPlanCallUserExpression is modified to call these methods on the
expression immediately before/after execution of the expression).

The immediate motivation is allowing Swift expressions to notify the swift
runtime that exclusivity enforcement should be suspended while the expression
runs (we want LLDB expressions to be able to access variables even when they're
considered exclusively owned by someone else in the original program).

Event Timeline

lhames created this revision.May 4 2017, 5:52 PM
jingham requested changes to this revision.May 4 2017, 6:37 PM

So there's one subtly here that doesn't matter at present but will trip you up if the WillStartExecuting needs to call a function - for instance. The problem is that when you are in the ThreadPlan constructor, the thread plan is not yet on the plan stack of the thread it is going to run on. If you wanted to call a function in WillStartExecuting, then what you'd do in make another ThreadPlanCallFunction and push it on the stack, then when the process continued, that plan would run and do it's job. But since you are still in the parent plan's constructor you would in fact be pushing the subsidiary plan on first, and then the parent plan second, and things wouldn't work.

The ThreadPlan has another method: DidPush that gets called when the plan is actually pushed onto the thread plan stack. That would be a better place to put this hook, since at that point everything is regular.

Other than that, everything is fine.

This revision now requires changes to proceed.May 4 2017, 6:37 PM
lhames updated this revision to Diff 98029.May 5 2017, 3:20 PM
lhames edited edge metadata.
lhames set the repository for this revision to rL LLVM.
lhames added a project: Restricted Project.

Updated based on feedback.

jingham accepted this revision.May 5 2017, 3:29 PM

Yup, that's right.

This revision is now accepted and ready to land.May 5 2017, 3:29 PM
lhames closed this revision.May 5 2017, 3:55 PM

Thanks Jim!

Committed in r302314.