Skip to content

[lldb] Improve error message for script commands when there's no interpreter #73321

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 27, 2023

Conversation

DavidSpickett
Copy link
Collaborator

@DavidSpickett DavidSpickett commented Nov 24, 2023

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.

@llvmbot
Copy link
Member

llvmbot commented Nov 24, 2023

@llvm/pr-subscribers-lldb

Author: David Spickett (DavidSpickett)

Changes

…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.


Full diff: https://github.com/llvm/llvm-project/pull/73321.diff

1 Files Affected:

  • (modified) lldb/source/Plugins/ScriptInterpreter/None/ScriptInterpreterNone.cpp (+6-4)
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() {

@DavidSpickett
Copy link
Collaborator Author

I might be butchering the meaning of the message, but you see what I'm going for.

@DavidSpickett DavidSpickett changed the title [lldb] Improve error message for script commands when there's no inte… [lldb] Improve error message for script commands when there's no interpreter Nov 24, 2023
Copy link
Member

@bulbazord bulbazord left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think overall this is a better error message. I think "mode" probably refers to the configuration LLDB was built with (e.g. LLDB_ENABLE_PYTHON) but that's really unhelpful for developers actually using LLDB. This message has been around since 2015 (Looks like 2c1f46dcc609a introduced it) so this is pretty overdue.

Thank you for changing this! :)

Copy link
Member

@JDevlieghere JDevlieghere left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for improving the error message. I left a suggestion inline, but happy to see this merged regardless of the concrete wording.

…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 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.
@DavidSpickett DavidSpickett merged commit 8167934 into llvm:main Nov 27, 2023
@DavidSpickett DavidSpickett deleted the lldb-script branch November 27, 2023 09:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants