[Lldb-commits] [PATCH] D126057: [lldb] Fix that empty target.run-args are not actually used when launching process

Raphael Isemann via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Fri May 20 03:04:46 PDT 2022


teemperor created this revision.
teemperor added reviewers: JDevlieghere, kastiglione.
teemperor added a project: LLDB.
Herald added a project: All.
teemperor requested review of this revision.
Herald added a subscriber: lldb-commits.

`GetPropertyAtIndexAsArgs` returns true on success and false on failure. Right
now it returns the converted `size_t` returned from `GetArgs` which describes
the number of arguments in the argument list. So for empty argument lists
(`(size_t)0` -> `(bool)false`) this function always fails.

The only observable effect of this seems to be that empty arguments are never
propagated to the internal LaunchInfo for a process. This causes that once any
argument has been added to `target.run-args`, clearing `target.run-args` doesn't
have any effect.

Fixes issue #55568


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D126057

Files:
  lldb/source/Interpreter/OptionValueProperties.cpp
  lldb/test/API/python_api/target/TestTargetAPI.py


Index: lldb/test/API/python_api/target/TestTargetAPI.py
===================================================================
--- lldb/test/API/python_api/target/TestTargetAPI.py
+++ lldb/test/API/python_api/target/TestTargetAPI.py
@@ -196,6 +196,15 @@
         self.assertIn('arg: foo', output)
         self.assertIn('env: bar=baz', output)
 
+        # Clear all the run args set above.
+        self.runCmd("setting clear target.run-args")
+        process = target.LaunchSimple(None, None,
+                                      self.get_process_working_directory())
+        process.Continue()
+        self.assertEqual(process.GetState(), lldb.eStateExited)
+        output = process.GetSTDOUT(9999)
+        self.assertNotIn('arg: foo', output)
+
         self.runCmd("settings set target.disable-stdio true")
         process = target.LaunchSimple(
             None, None, self.get_process_working_directory())
Index: lldb/source/Interpreter/OptionValueProperties.cpp
===================================================================
--- lldb/source/Interpreter/OptionValueProperties.cpp
+++ lldb/source/Interpreter/OptionValueProperties.cpp
@@ -248,16 +248,22 @@
     return false;
 
   const OptionValueArgs *arguments = value->GetAsArgs();
-  if (arguments)
-    return arguments->GetArgs(args);
+  if (arguments) {
+    arguments->GetArgs(args);
+    return true;
+  }
 
   const OptionValueArray *array = value->GetAsArray();
-  if (array)
-    return array->GetArgs(args);
+  if (array) {
+    array->GetArgs(args);
+    return true;
+  }
 
   const OptionValueDictionary *dict = value->GetAsDictionary();
-  if (dict)
-    return dict->GetArgs(args);
+  if (dict) {
+    dict->GetArgs(args);
+    return true;
+  }
 
   return false;
 }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D126057.430930.patch
Type: text/x-patch
Size: 1754 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20220520/15c8a07e/attachment-0001.bin>


More information about the lldb-commits mailing list