[Lldb-commits] [lldb] [lldb] Improve error message for script commands when there's no inte… (PR #73321)

David Spickett via lldb-commits lldb-commits at lists.llvm.org
Fri Nov 24 04:10:17 PST 2023


https://github.com/DavidSpickett created https://github.com/llvm/llvm-project/pull/73321

…rpreter

It was:
```
error: there is no embedded script interpreter in this mode.
```

1. What does "mode" mean?
2. It implies there might be an embedded script interpreter for some other "mode", whatever that would be.

So I'm simplifying it and noting the most common reason for this which is that lldb wasn't built with a scripting language enabled in the first place.

There are other tips for dealing with this, but I'm not sure this message is the best place for them.

>From 6183547ff1481bd71f18f44f2083b58cd7084453 Mon Sep 17 00:00:00 2001
From: David Spickett <david.spickett at linaro.org>
Date: Fri, 24 Nov 2023 12:05:41 +0000
Subject: [PATCH] [lldb] Improve error message for script commands when there's
 no interpreter

It was:
```
error: there is no embedded script interpreter in this mode.
```

1. What does "mode" mean?
2. It implies there might be an embedded script interpreter for some
   other "mode", whatever that would be.

So I'm simplifying it and noting the most common reason for this which
is that lldb wasn't built with a scripting lanugage enabled in the
first place.

There are other tips for dealing with this, but I'm not sure this message
is the best place for them.
---
 .../ScriptInterpreter/None/ScriptInterpreterNone.cpp   | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/lldb/source/Plugins/ScriptInterpreter/None/ScriptInterpreterNone.cpp b/lldb/source/Plugins/ScriptInterpreter/None/ScriptInterpreterNone.cpp
index 7df8b55fc7f55b1..9cc1d72eebf06cd 100644
--- a/lldb/source/Plugins/ScriptInterpreter/None/ScriptInterpreterNone.cpp
+++ b/lldb/source/Plugins/ScriptInterpreter/None/ScriptInterpreterNone.cpp
@@ -26,17 +26,19 @@ ScriptInterpreterNone::ScriptInterpreterNone(Debugger &debugger)
 
 ScriptInterpreterNone::~ScriptInterpreterNone() = default;
 
+static const char *no_interpreter_err_msg =
+    "There is no embedded script interpreter. Check that LLDB was built with a "
+    "scripting language enabled.\n";
+
 bool ScriptInterpreterNone::ExecuteOneLine(llvm::StringRef command,
                                            CommandReturnObject *,
                                            const ExecuteScriptOptions &) {
-  m_debugger.GetErrorStream().PutCString(
-      "error: there is no embedded script interpreter in this mode.\n");
+  m_debugger.GetErrorStream().PutCString(no_interpreter_err_msg);
   return false;
 }
 
 void ScriptInterpreterNone::ExecuteInterpreterLoop() {
-  m_debugger.GetErrorStream().PutCString(
-      "error: there is no embedded script interpreter in this mode.\n");
+  m_debugger.GetErrorStream().PutCString(no_interpreter_err_msg);
 }
 
 void ScriptInterpreterNone::Initialize() {



More information about the lldb-commits mailing list