This is an archive of the discontinued LLVM Phabricator instance.

Make sure we are stopped before we try to install functions into the target
ClosedPublic

Authored by jingham on Nov 8 2022, 6:12 PM.

Details

Summary

It's actually fairly hard to get lldb to do this, since most ways you can access the expression evaluator already assert that you have to be stopped. But if you are unlucky you might end up doing that, for instance SBTarget::FindFirstType when called the first time for something that requires types from the ObjC runtime metadata can end up installing and calling the "metadata introspection" UtilityFunction. This fails, mostly in harmless ways, but if you happen to hit a breakpoint and stop while in the middle of making up the expression, you can mess up internal state. I really don't think it's worth the effort to make this work. It's easier to reason about if we just assert that you have to be stopped if you want to cons up a UtilityExpression.

The only subtle bit of this patch is that if code is running on the Internal State Thread, it is governed by the m_private_state, not the m_public_state. So I made Process::GetState behave the same way the target API lock does, with a separate entity for the private & public running code.

Diff Detail

Event Timeline

jingham created this revision.Nov 8 2022, 6:12 PM
Herald added a project: Restricted Project. · View Herald TranscriptNov 8 2022, 6:12 PM
jingham requested review of this revision.Nov 8 2022, 6:12 PM
Herald added a project: Restricted Project. · View Herald TranscriptNov 8 2022, 6:12 PM
jasonmolenda accepted this revision.Nov 9 2022, 8:19 AM

This looks good to me, I like all of the added error messages in FunctionCaller::WriteFunctionWrapper in particular.

This revision is now accepted and ready to land.Nov 9 2022, 8:19 AM