Author: Ebuka Ezike
Date: 2025-06-04T11:33:35+01:00
New Revision: 7214a3d3da851018a96ac85060a2f9aeb7715f7f

URL: 
https://github.com/llvm/llvm-project/commit/7214a3d3da851018a96ac85060a2f9aeb7715f7f
DIFF: 
https://github.com/llvm/llvm-project/commit/7214a3d3da851018a96ac85060a2f9aeb7715f7f.diff

LOG: [lldb] Do not accept invalid `process save-core` plugins (#142684)

Fixes #142581

Added: 
    lldb/test/Shell/Commands/command-process-save-core-not-a-plugin.test

Modified: 
    lldb/source/Commands/CommandObjectProcess.cpp
    lldb/source/Symbol/SaveCoreOptions.cpp

Removed: 
    


################################################################################
diff  --git a/lldb/source/Commands/CommandObjectProcess.cpp 
b/lldb/source/Commands/CommandObjectProcess.cpp
index d0f5eaf2dfd9a..b1f243c9e2777 100644
--- a/lldb/source/Commands/CommandObjectProcess.cpp
+++ b/lldb/source/Commands/CommandObjectProcess.cpp
@@ -1303,7 +1303,7 @@ class CommandObjectProcessSaveCore : public 
CommandObjectParsed {
         llvm_unreachable("Unimplemented option");
       }
 
-      return {};
+      return error;
     }
 
     void OptionParsingStarting(ExecutionContext *execution_context) override {

diff  --git a/lldb/source/Symbol/SaveCoreOptions.cpp 
b/lldb/source/Symbol/SaveCoreOptions.cpp
index e51ae27954934..d884b00a47b00 100644
--- a/lldb/source/Symbol/SaveCoreOptions.cpp
+++ b/lldb/source/Symbol/SaveCoreOptions.cpp
@@ -24,7 +24,6 @@ Status SaveCoreOptions::SetPluginName(const char *name) {
   if (!PluginManager::IsRegisteredObjectFilePluginName(name)) {
     return Status::FromErrorStringWithFormat(
         "plugin name '%s' is not a valid ObjectFile plugin name", name);
-    return error;
   }
 
   m_plugin_name = name;

diff  --git 
a/lldb/test/Shell/Commands/command-process-save-core-not-a-plugin.test 
b/lldb/test/Shell/Commands/command-process-save-core-not-a-plugin.test
new file mode 100644
index 0000000000000..c034c8ebbf87d
--- /dev/null
+++ b/lldb/test/Shell/Commands/command-process-save-core-not-a-plugin.test
@@ -0,0 +1,19 @@
+# This checks that lldb returns an error if process save-core is called
+# with a plugin that does not exist.
+
+# RUN: %clang_host -g %S/Inputs/main.c -o %t
+# RUN: %lldb %t -s %s -o exit 2>&1 | FileCheck %s
+
+b main
+# CHECK-LABEL: b main
+# CHECK: Breakpoint 1: where = {{.*}}`main
+
+run
+# CHECK-LABEL: run
+# CHECK: Process {{.*}} stopped
+# CHECK: stop reason = breakpoint 1
+# CHECK:   frame #0: {{.*}}`main at main.c
+
+process save-core --plugin-name=notaplugin dump
+# CHECK-LABEL: process save-core --plugin-name=notaplugin dump
+# CHECK: error: plugin name 'notaplugin' is not a valid ObjectFile plugin name


        
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to