Page MenuHomePhabricator

[lldb] Fix that running a top level expression without a process fails with a cryptic error
ClosedPublic

Authored by teemperor on Nov 18 2020, 9:29 AM.

Details

Summary

Right now when running expr --top-level -- void foo() {}, LLDB just prints a cryptic
error: Couldn't find $__lldb_expr() in the module error. The reason for that is
that if we don't have a running process, we try to set our execution policy to always use the
IR interpreter (ExecutionPolicyNever) which works even without a process. However
that code didn't consider the special ExecutionPolicyTopLevel which we use for
top-level expressions. By changing the execution policy to ExecutionPolicyNever,
LLDB thinks we're actually trying to interpret a normal expression inside our
$__lldb_expr function and then fails when looking for it.

This just adds an exception for top-level expressions to that code and a bunch of tests.

Diff Detail

Event Timeline

teemperor requested review of this revision.Nov 18 2020, 9:29 AM
teemperor created this revision.

Interesting so we always had the error Top-level code needs to be inserted into a runnable target but we just were not triggering it before?

Interesting so we always had the error Top-level code needs to be inserted into a runnable target but we just were not triggering it before?

Jepp, that error was added in the commit that introduced top-level expressions:

commit 00294b34a3c99f3540214a148c0bd15e68f9d7fd
Author: Sean Callanan <scallanan@apple.com>, Tue Mar 22 21:05:51 2016 +0000 (4 years, 8 months ago)
shafik accepted this revision.Nov 19 2020, 9:51 AM

LGTM

This revision is now accepted and ready to land.Nov 19 2020, 9:51 AM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 11 2021, 8:07 AM