Index: lldb/source/Expression/UserExpression.cpp =================================================================== --- lldb/source/Expression/UserExpression.cpp +++ lldb/source/Expression/UserExpression.cpp @@ -39,6 +39,7 @@ #include "lldb/Utility/ConstString.h" #include "lldb/Utility/LLDBLog.h" #include "lldb/Utility/Log.h" +#include "lldb/Utility/State.h" #include "lldb/Utility/StreamString.h" using namespace lldb_private; @@ -205,8 +206,10 @@ // Since we might need to call allocate memory and maybe call code to make // the caller, we need to be stopped. if (process != nullptr && process->GetState() != lldb::eStateStopped) { - error.SetErrorString("Can't make a function caller while the process is " - "running"); + error.SetErrorStringWithFormatv( + "Can't make a function caller while the process is {0}: the process " + "must be stopped to allocate memory.", + StateAsCString(process->GetState())); return execution_results; } Index: lldb/source/Expression/UtilityFunction.cpp =================================================================== --- lldb/source/Expression/UtilityFunction.cpp +++ lldb/source/Expression/UtilityFunction.cpp @@ -21,6 +21,7 @@ #include "lldb/Target/Target.h" #include "lldb/Utility/ConstString.h" #include "lldb/Utility/Log.h" +#include "lldb/Utility/State.h" #include "lldb/Utility/Stream.h" using namespace lldb_private; @@ -67,8 +68,10 @@ // Since we might need to call allocate memory and maybe call code to make // the caller, we need to be stopped. if (process_sp->GetState() != lldb::eStateStopped) { - error.SetErrorString("Can't make a function caller while the process is " - "running"); + error.SetErrorStringWithFormatv( + "Can't make a function caller while the process is {0}: the process " + "must be stopped to allocate memory.", + StateAsCString(process_sp->GetState())); return nullptr; } Index: lldb/test/Shell/Expr/TestFunctionCaller.test =================================================================== --- /dev/null +++ lldb/test/Shell/Expr/TestFunctionCaller.test @@ -0,0 +1,3 @@ +# RUN: %clangxx_host %p/Inputs/call-function.cpp -g -o %t +# RUN: %lldb %t -o 'r' -o 'expr strlen("")' | FileCheck %s +# CHECK: error: Can't make a function caller while the process is exited: the process must be stopped to allocate memory.