[Lldb-commits] [PATCH] D141702: [lldb/crashlog] Make module loading use Scripted Process affordance

2023-01-18 Thread Med Ismail Bennani via Phabricator via lldb-commits
mib added inline comments.



Comment at: lldb/source/Plugins/Process/scripted/ScriptedProcess.cpp:493
 
   if (!loaded_images_sp->ForEach(reload_image))
 return ScriptedInterface::ErrorWithMessage(

I'm just thinking about this but I don't see any reason not to run this loop in 
parallel to accelerate dependency loading ... That could potentially mess up 
the progress reporting but I think in parallel it might not even be needed. 
@JDevlieghere Any objections ?


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D141702/new/

https://reviews.llvm.org/D141702

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


[Lldb-commits] [PATCH] D140630: [lldb-vscode] Add data breakpoint support

2023-01-18 Thread Callum Macmillan via Phabricator via lldb-commits
cimacmillan updated this revision to Diff 490077.
cimacmillan edited the summary of this revision.
cimacmillan added a comment.

Add handling for const and register cases. Setting watchpoint on SBValue rather 
than the 
address.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D140630/new/

https://reviews.llvm.org/D140630

Files:
  lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/lldbvscode_testcase.py
  lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py
  lldb/test/API/tools/lldb-vscode/breakpoint_data/Makefile
  
lldb/test/API/tools/lldb-vscode/breakpoint_data/TestVSCode_setDataBreakpoints.py
  lldb/test/API/tools/lldb-vscode/breakpoint_data/main.cpp
  lldb/test/API/tools/lldb-vscode/breakpoint_data_optimized/Makefile
  
lldb/test/API/tools/lldb-vscode/breakpoint_data_optimized/TestVSCode_setDataBreakpoints.py
  lldb/test/API/tools/lldb-vscode/breakpoint_data_optimized/main.cpp
  lldb/tools/lldb-vscode/CMakeLists.txt
  lldb/tools/lldb-vscode/VSCode.h
  lldb/tools/lldb-vscode/Watchpoint.cpp
  lldb/tools/lldb-vscode/Watchpoint.h
  lldb/tools/lldb-vscode/lldb-vscode.cpp

Index: lldb/tools/lldb-vscode/lldb-vscode.cpp
===
--- lldb/tools/lldb-vscode/lldb-vscode.cpp
+++ lldb/tools/lldb-vscode/lldb-vscode.cpp
@@ -41,6 +41,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 #include "llvm/ADT/ArrayRef.h"
@@ -56,6 +57,8 @@
 #include "llvm/Support/PrettyStackTrace.h"
 #include "llvm/Support/raw_ostream.h"
 
+#include "lldb/API/SBMemoryRegionInfo.h"
+
 #include "JSONUtils.h"
 #include "LLDBUtils.h"
 #include "OutputRedirector.h"
@@ -1541,6 +1544,8 @@
   body.try_emplace("supportsProgressReporting", true);
   // The debug adapter supports 'logMessage' in breakpoint.
   body.try_emplace("supportsLogPoints", true);
+  // The debug adapter supports data breakpoints
+  body.try_emplace("supportsDataBreakpoints", true);
 
   response.try_emplace("body", std::move(body));
   g_vsc.SendJSON(llvm::json::Value(std::move(response)));
@@ -2117,6 +2122,365 @@
   g_vsc.SendJSON(llvm::json::Value(std::move(response)));
 }
 
+static WatchpointType get_watchpoint_type_from_request(std::string type) {
+  if (type == "write") {
+return WatchpointType::Write;
+  } else if (type == "read") {
+return WatchpointType::Read;
+  } else if (type == "readWrite") {
+return WatchpointType::ReadWrite;
+  }
+  std::string unknown_type_error = "Unknown watchpoint type: ";
+  unknown_type_error.append(type);
+  unknown_type_error.append(". Defaulting to ReadWrite.");
+  g_vsc.SendOutput(OutputType::Console, unknown_type_error);
+  return WatchpointType::ReadWrite;
+}
+
+static lldb::SBValue get_variable(std::string variable_name,
+  uint32_t variables_reference) {
+  bool is_duplicated_variable_name =
+  variable_name.find(" @") != llvm::StringRef::npos;
+  lldb::SBValue variable;
+
+  if (lldb::SBValueList *top_scope = GetTopLevelScope(variables_reference)) {
+// variablesReference is one of our scopes, not an actual variable it is
+// asking for a variable in locals or globals or registers
+int64_t end_idx = top_scope->GetSize();
+// Searching backward so that we choose the variable in closest scope
+// among variables of the same name.
+for (int64_t i = end_idx - 1; i >= 0; --i) {
+  lldb::SBValue curr_variable = top_scope->GetValueAtIndex(i);
+  std::string local_variable = CreateUniqueVariableNameForDisplay(
+  curr_variable, is_duplicated_variable_name);
+  if (variable_name == local_variable) {
+variable = curr_variable;
+break;
+  }
+}
+  } else {
+// This is not under the globals or locals scope, so there are no duplicated
+// names.
+
+// We have a named item within an actual variable so we need to find it
+// withing the container variable by name.
+lldb::SBValue container = g_vsc.variables.GetVariable(variables_reference);
+if (!container.IsValid()) {
+  return variable;
+}
+
+variable = container.GetChildMemberWithName(variable_name.data());
+if (!variable.IsValid()) {
+  if (variable_name.size() > 0 && variable_name[0] == '[') {
+llvm::StringRef index_str(std::move(variable_name.substr(1)));
+uint64_t index = 0;
+if (!index_str.consumeInteger(0, index)) {
+  if (index_str == "]")
+variable = container.GetChildAtIndex(index);
+}
+  }
+}
+  }
+
+  return variable;
+}
+
+static std::optional set_data_breakpoint(const llvm::json::Object *breakpoint) {
+  std::string breakpoint_id = GetString(breakpoint, "id").str();
+  std::string data_id = GetString(breakpoint, "dataId").str();
+  bool enabled = GetBoolean(breakpoint, "enabled", false);
+  WatchpointType watchpoint_type = get_watchpoint_type_from_request(
+  GetString(breakpoint, "accessType").str());
+
+  if (g_vsc.watchpoints.find

[Lldb-commits] [PATCH] D142007: [NFC] Fix "form/from" typos

2023-01-18 Thread Piotr Fusik via Phabricator via lldb-commits
pfusik created this revision.
Herald added subscribers: Moerafaat, zero9178, steakhal, bzcheeseman, sdasgup3, 
wenzhicui, wrengr, cota, teijeong, rdzhabarov, tatianashp, msifontes, jurahul, 
Kayjukh, grosul1, martong, Joonsoo, liufengdb, aartbik, mgester, arpith-jacob, 
antiagainst, shauheen, rriddle, mehdi_amini, hiraditya, arichardson.
Herald added a reviewer: NoQ.
Herald added a reviewer: ributzka.
Herald added a project: All.
pfusik requested review of this revision.
Herald added a reviewer: nicolasvasilache.
Herald added subscribers: llvm-commits, libcxx-commits, lldb-commits, 
cfe-commits, stephenneuendorffer, nicolasvasilache.
Herald added projects: clang, LLDB, libc++, MLIR, LLVM.
Herald added a reviewer: libc++.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D142007

Files:
  clang/lib/StaticAnalyzer/Checkers/BasicObjCFoundationChecks.cpp
  libcxx/include/__format/extended_grapheme_cluster_table.h
  libcxx/utils/generate_extended_grapheme_cluster_table.py
  lldb/include/lldb/Host/File.h
  lldb/source/Plugins/CMakeLists.txt
  lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
  llvm/lib/Analysis/IVDescriptors.cpp
  llvm/lib/CodeGen/CodeGenPrepare.cpp
  llvm/lib/Target/AArch64/AArch64ISelDAGToDAG.cpp
  llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
  llvm/lib/Transforms/Scalar/ConstantHoisting.cpp
  llvm/test/DebugInfo/ARM/PR26163.ll
  llvm/tools/llvm-exegesis/lib/Clustering.cpp
  llvm/unittests/ExecutionEngine/MCJIT/MCJITCAPITest.cpp
  llvm/unittests/FuzzMutate/RandomIRBuilderTest.cpp
  mlir/lib/Dialect/Transform/IR/TransformDialect.cpp

Index: mlir/lib/Dialect/Transform/IR/TransformDialect.cpp
===
--- mlir/lib/Dialect/Transform/IR/TransformDialect.cpp
+++ mlir/lib/Dialect/Transform/IR/TransformDialect.cpp
@@ -74,7 +74,7 @@
 
 void transform::TransformDialect::mergeInPDLMatchHooks(
 llvm::StringMap &&constraintFns) {
-  // Steal the constraint functions form the given map.
+  // Steal the constraint functions from the given map.
   for (auto &it : constraintFns)
 pdlMatchHooks.registerConstraintFunction(it.getKey(), std::move(it.second));
 }
Index: llvm/unittests/FuzzMutate/RandomIRBuilderTest.cpp
===
--- llvm/unittests/FuzzMutate/RandomIRBuilderTest.cpp
+++ llvm/unittests/FuzzMutate/RandomIRBuilderTest.cpp
@@ -130,7 +130,7 @@
 }
 
 TEST(RandomIRBuilderTest, ShuffleVectorSink) {
-  // Check that we will never use shuffle vector mask as a sink form the
+  // Check that we will never use shuffle vector mask as a sink from the
   // unrelated operation.
 
   LLVMContext Ctx;
Index: llvm/unittests/ExecutionEngine/MCJIT/MCJITCAPITest.cpp
===
--- llvm/unittests/ExecutionEngine/MCJIT/MCJITCAPITest.cpp
+++ llvm/unittests/ExecutionEngine/MCJIT/MCJITCAPITest.cpp
@@ -6,7 +6,7 @@
 //
 //===--===//
 //
-// This test suite verifies basic MCJIT functionality when invoked form the C
+// This test suite verifies basic MCJIT functionality when invoked from the C
 // API.
 //
 //===--===//
Index: llvm/tools/llvm-exegesis/lib/Clustering.cpp
===
--- llvm/tools/llvm-exegesis/lib/Clustering.cpp
+++ llvm/tools/llvm-exegesis/lib/Clustering.cpp
@@ -314,7 +314,7 @@
   // Actually append to-be-moved points to the new cluster.
   UnstableCluster.PointIndices.insert(UnstableCluster.PointIndices.end(),
   it, OldCluster.PointIndices.end());
-  // And finally, remove "to-be-moved" points form the old cluster.
+  // And finally, remove "to-be-moved" points from the old cluster.
   OldCluster.PointIndices.erase(it, OldCluster.PointIndices.end());
   // Now, the old cluster may end up being empty, but let's just keep it
   // in whatever state it ended up. Purging empty clusters isn't worth it.
Index: llvm/test/DebugInfo/ARM/PR26163.ll
===
--- llvm/test/DebugInfo/ARM/PR26163.ll
+++ llvm/test/DebugInfo/ARM/PR26163.ll
@@ -17,7 +17,7 @@
 ; CHECK-NEXT: DW_AT_location (DW_OP_lit0, DW_OP_stack_value, DW_OP_piece 0x4)
 ; CHECK-NEXT: DW_AT_abstract_origin
 
-; Created form the following test case (PR26163) with
+; Created from the following test case (PR26163) with
 ; clang -cc1 -triple armv4t--freebsd11.0-gnueabi -emit-obj -debug-info-kind=standalone -O2 -x c test.c
 ;
 ; typedef	unsigned int	size_t;
Index: llvm/lib/Transforms/Scalar/ConstantHoisting.cpp
===
--- llvm/lib/Transforms/Scalar/ConstantHoisting.cpp
+++ llvm/lib/Transforms/Scalar/ConstantHoisting.cpp
@@ -722,7 +722,7 @@
 
 /// Updates the operand at Idx in ins

[Lldb-commits] [PATCH] D142007: [NFC] Fix "form/from" typos

2023-01-18 Thread Louis Dionne via Phabricator via lldb-commits
ldionne accepted this revision.
ldionne added a comment.
This revision is now accepted and ready to land.

LGTM, thanks! I don't think you need to wait for other owners to approve before 
landing this, this is pretty clearly an improvement.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D142007/new/

https://reviews.llvm.org/D142007

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


[Lldb-commits] [PATCH] D142007: [NFC] Fix "form/from" typos

2023-01-18 Thread Piotr Fusik via Phabricator via lldb-commits
pfusik added a comment.

In D142007#4062211 , @ldionne wrote:

> LGTM, thanks! I don't think you need to wait for other owners to approve 
> before landing this, this is pretty clearly an improvement.

I have no commit access, could you please commit this for me?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D142007/new/

https://reviews.llvm.org/D142007

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


[Lldb-commits] [PATCH] D142034: [lldb][Language] List supported languages in expr error text

2023-01-18 Thread Michael Buch via Phabricator via lldb-commits
Michael137 created this revision.
Michael137 added reviewers: jingham, aprantl.
Herald added a project: All.
Michael137 requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

Before:

  (lldb) expr --language abc -- 1 + 1
  error: unknown language type: 'abc' for expression

After:

  (lldb) expr --language abc -- 1 + 1
  error: unknown language type: 'abc' for expression. List of supported 
languages:
c++
objective-c
objective-c++

We choose to only list the languages which `expr` will actually
accept instead of all the language constants defined in `Language.cpp`
since that's what the user will most likely need.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D142034

Files:
  lldb/include/lldb/Target/Language.h
  lldb/source/Commands/CommandObjectExpression.cpp
  lldb/source/Target/Language.cpp
  lldb/test/API/commands/expression/invalid-args/TestInvalidArgsExpression.py


Index: 
lldb/test/API/commands/expression/invalid-args/TestInvalidArgsExpression.py
===
--- lldb/test/API/commands/expression/invalid-args/TestInvalidArgsExpression.py
+++ lldb/test/API/commands/expression/invalid-args/TestInvalidArgsExpression.py
@@ -7,7 +7,9 @@
 @no_debug_info_test
 def test_invalid_lang(self):
 self.expect("expression -l foo --", error=True,
-substrs=["error: unknown language type: 'foo' for 
expression"])
+substrs=["error: unknown language type: 'foo' for 
expression",
+ "List of supported languages:",
+ "c++"])
 
 @no_debug_info_test
 def test_invalid_all_thread(self):
Index: lldb/source/Target/Language.cpp
===
--- lldb/source/Target/Language.cpp
+++ lldb/source/Target/Language.cpp
@@ -221,6 +221,16 @@
 return language_names[eLanguageTypeUnknown].name;
 }
 
+void Language::PrintSupportedLanguages(Stream &s, llvm::StringRef prefix,
+   llvm::StringRef suffix) {
+  auto supported = Language::GetSupportedLanguages();
+  for (auto const &lang : supported) {
+s << prefix;
+s << Language::GetNameForLanguageType(lang);
+s << suffix;
+  }
+}
+
 void Language::PrintAllLanguages(Stream &s, const char *prefix,
  const char *suffix) {
   for (uint32_t i = 1; i < num_languages; i++) {
Index: lldb/source/Commands/CommandObjectExpression.cpp
===
--- lldb/source/Commands/CommandObjectExpression.cpp
+++ lldb/source/Commands/CommandObjectExpression.cpp
@@ -42,10 +42,15 @@
   switch (short_option) {
   case 'l':
 language = Language::GetLanguageTypeFromString(option_arg);
-if (language == eLanguageTypeUnknown)
-  error.SetErrorStringWithFormat(
-  "unknown language type: '%s' for expression",
-  option_arg.str().c_str());
+if (language == eLanguageTypeUnknown) {
+  StreamString sstr;
+  sstr.Printf("unknown language type: '%s' for expression. "
+  "List of supported languages:\n",
+  option_arg.str().c_str());
+
+  Language::PrintSupportedLanguages(sstr, "  ", "\n");
+  error.SetErrorString(sstr.GetString());
+}
 break;
 
   case 'a': {
Index: lldb/include/lldb/Target/Language.h
===
--- lldb/include/lldb/Target/Language.h
+++ lldb/include/lldb/Target/Language.h
@@ -279,6 +279,15 @@
   static void PrintAllLanguages(Stream &s, const char *prefix,
 const char *suffix);
 
+  /// Prints each language type that the current target supports
+  /// to the specified stream 's'.
+  ///
+  /// \param[out] s  Stream to which the language types are written.
+  /// \param[in]  prefix String that is prepended to the language type.
+  /// \param[in]  suffix String that is appended to the language type.
+  static void PrintSupportedLanguages(Stream &s, llvm::StringRef prefix,
+  llvm::StringRef suffix);
+
   // return false from callback to stop iterating
   static void ForAllLanguages(std::function 
callback);
 


Index: lldb/test/API/commands/expression/invalid-args/TestInvalidArgsExpression.py
===
--- lldb/test/API/commands/expression/invalid-args/TestInvalidArgsExpression.py
+++ lldb/test/API/commands/expression/invalid-args/TestInvalidArgsExpression.py
@@ -7,7 +7,9 @@
 @no_debug_info_test
 def test_invalid_lang(self):
 self.expect("expression -l foo --", error=True,
-substrs=["error: unknown language type: 'foo' for expression"])
+substrs=["error: unknown language type: 'foo' for expression",
+ "List of support

[Lldb-commits] [PATCH] D142034: [lldb][Language] List supported languages in expr error text

2023-01-18 Thread Michael Buch via Phabricator via lldb-commits
Michael137 updated this revision to Diff 490199.
Michael137 added a comment.

- Use `GetLanguagesSupportingTypeSystemsForExpressions` instead of 
`GetSupportedLanguages`


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D142034/new/

https://reviews.llvm.org/D142034

Files:
  lldb/include/lldb/Target/Language.h
  lldb/source/Commands/CommandObjectExpression.cpp
  lldb/source/Target/Language.cpp
  lldb/test/API/commands/expression/invalid-args/TestInvalidArgsExpression.py


Index: 
lldb/test/API/commands/expression/invalid-args/TestInvalidArgsExpression.py
===
--- lldb/test/API/commands/expression/invalid-args/TestInvalidArgsExpression.py
+++ lldb/test/API/commands/expression/invalid-args/TestInvalidArgsExpression.py
@@ -7,7 +7,9 @@
 @no_debug_info_test
 def test_invalid_lang(self):
 self.expect("expression -l foo --", error=True,
-substrs=["error: unknown language type: 'foo' for 
expression"])
+substrs=["error: unknown language type: 'foo' for 
expression",
+ "List of supported languages:",
+ "c++", "c++11", "c++14"])
 
 @no_debug_info_test
 def test_invalid_all_thread(self):
Index: lldb/source/Target/Language.cpp
===
--- lldb/source/Target/Language.cpp
+++ lldb/source/Target/Language.cpp
@@ -221,6 +221,17 @@
 return language_names[eLanguageTypeUnknown].name;
 }
 
+void Language::PrintSupportedLanguagesForExpressions(Stream &s,
+ llvm::StringRef prefix,
+ llvm::StringRef suffix) {
+  auto supported = Language::GetLanguagesSupportingTypeSystemsForExpressions();
+  for (size_t idx = 0; idx < num_languages; ++idx) {
+auto lang = language_names[idx];
+if (supported[lang.type])
+  s << prefix << lang.name << suffix;
+  }
+}
+
 void Language::PrintAllLanguages(Stream &s, const char *prefix,
  const char *suffix) {
   for (uint32_t i = 1; i < num_languages; i++) {
Index: lldb/source/Commands/CommandObjectExpression.cpp
===
--- lldb/source/Commands/CommandObjectExpression.cpp
+++ lldb/source/Commands/CommandObjectExpression.cpp
@@ -42,10 +42,15 @@
   switch (short_option) {
   case 'l':
 language = Language::GetLanguageTypeFromString(option_arg);
-if (language == eLanguageTypeUnknown)
-  error.SetErrorStringWithFormat(
-  "unknown language type: '%s' for expression",
-  option_arg.str().c_str());
+if (language == eLanguageTypeUnknown) {
+  StreamString sstr;
+  sstr.Printf("unknown language type: '%s' for expression. "
+  "List of supported languages:\n",
+  option_arg.str().c_str());
+
+  Language::PrintSupportedLanguagesForExpressions(sstr, "  ", "\n");
+  error.SetErrorString(sstr.GetString());
+}
 break;
 
   case 'a': {
Index: lldb/include/lldb/Target/Language.h
===
--- lldb/include/lldb/Target/Language.h
+++ lldb/include/lldb/Target/Language.h
@@ -279,6 +279,16 @@
   static void PrintAllLanguages(Stream &s, const char *prefix,
 const char *suffix);
 
+  /// Prints to the specified stream 's' each language type that the
+  /// current target supports for expression evaluation.
+  ///
+  /// \param[out] s  Stream to which the language types are written.
+  /// \param[in]  prefix String that is prepended to the language type.
+  /// \param[in]  suffix String that is appended to the language type.
+  static void PrintSupportedLanguagesForExpressions(Stream &s,
+llvm::StringRef prefix,
+llvm::StringRef suffix);
+
   // return false from callback to stop iterating
   static void ForAllLanguages(std::function 
callback);
 


Index: lldb/test/API/commands/expression/invalid-args/TestInvalidArgsExpression.py
===
--- lldb/test/API/commands/expression/invalid-args/TestInvalidArgsExpression.py
+++ lldb/test/API/commands/expression/invalid-args/TestInvalidArgsExpression.py
@@ -7,7 +7,9 @@
 @no_debug_info_test
 def test_invalid_lang(self):
 self.expect("expression -l foo --", error=True,
-substrs=["error: unknown language type: 'foo' for expression"])
+substrs=["error: unknown language type: 'foo' for expression",
+ "List of supported languages:",
+ "c++", "c++11", "c++14"])
 
 @no_debug_info_test
 def test_invalid_all_thread(self):
Index: lldb/source/Targ

[Lldb-commits] [PATCH] D142034: [lldb][Language] List supported languages in expr error text

2023-01-18 Thread Michael Buch via Phabricator via lldb-commits
Michael137 updated this revision to Diff 490203.
Michael137 added a comment.

- Language name pair can be `const &`


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D142034/new/

https://reviews.llvm.org/D142034

Files:
  lldb/include/lldb/Target/Language.h
  lldb/source/Commands/CommandObjectExpression.cpp
  lldb/source/Target/Language.cpp
  lldb/test/API/commands/expression/invalid-args/TestInvalidArgsExpression.py


Index: 
lldb/test/API/commands/expression/invalid-args/TestInvalidArgsExpression.py
===
--- lldb/test/API/commands/expression/invalid-args/TestInvalidArgsExpression.py
+++ lldb/test/API/commands/expression/invalid-args/TestInvalidArgsExpression.py
@@ -7,7 +7,9 @@
 @no_debug_info_test
 def test_invalid_lang(self):
 self.expect("expression -l foo --", error=True,
-substrs=["error: unknown language type: 'foo' for 
expression"])
+substrs=["error: unknown language type: 'foo' for 
expression",
+ "List of supported languages:",
+ "c++", "c++11", "c++14"])
 
 @no_debug_info_test
 def test_invalid_all_thread(self):
Index: lldb/source/Target/Language.cpp
===
--- lldb/source/Target/Language.cpp
+++ lldb/source/Target/Language.cpp
@@ -221,6 +221,17 @@
 return language_names[eLanguageTypeUnknown].name;
 }
 
+void Language::PrintSupportedLanguagesForExpressions(Stream &s,
+ llvm::StringRef prefix,
+ llvm::StringRef suffix) {
+  auto supported = Language::GetLanguagesSupportingTypeSystemsForExpressions();
+  for (size_t idx = 0; idx < num_languages; ++idx) {
+auto const &lang = language_names[idx];
+if (supported[lang.type])
+  s << prefix << lang.name << suffix;
+  }
+}
+
 void Language::PrintAllLanguages(Stream &s, const char *prefix,
  const char *suffix) {
   for (uint32_t i = 1; i < num_languages; i++) {
Index: lldb/source/Commands/CommandObjectExpression.cpp
===
--- lldb/source/Commands/CommandObjectExpression.cpp
+++ lldb/source/Commands/CommandObjectExpression.cpp
@@ -42,10 +42,15 @@
   switch (short_option) {
   case 'l':
 language = Language::GetLanguageTypeFromString(option_arg);
-if (language == eLanguageTypeUnknown)
-  error.SetErrorStringWithFormat(
-  "unknown language type: '%s' for expression",
-  option_arg.str().c_str());
+if (language == eLanguageTypeUnknown) {
+  StreamString sstr;
+  sstr.Printf("unknown language type: '%s' for expression. "
+  "List of supported languages:\n",
+  option_arg.str().c_str());
+
+  Language::PrintSupportedLanguagesForExpressions(sstr, "  ", "\n");
+  error.SetErrorString(sstr.GetString());
+}
 break;
 
   case 'a': {
Index: lldb/include/lldb/Target/Language.h
===
--- lldb/include/lldb/Target/Language.h
+++ lldb/include/lldb/Target/Language.h
@@ -279,6 +279,16 @@
   static void PrintAllLanguages(Stream &s, const char *prefix,
 const char *suffix);
 
+  /// Prints to the specified stream 's' each language type that the
+  /// current target supports for expression evaluation.
+  ///
+  /// \param[out] s  Stream to which the language types are written.
+  /// \param[in]  prefix String that is prepended to the language type.
+  /// \param[in]  suffix String that is appended to the language type.
+  static void PrintSupportedLanguagesForExpressions(Stream &s,
+llvm::StringRef prefix,
+llvm::StringRef suffix);
+
   // return false from callback to stop iterating
   static void ForAllLanguages(std::function 
callback);
 


Index: lldb/test/API/commands/expression/invalid-args/TestInvalidArgsExpression.py
===
--- lldb/test/API/commands/expression/invalid-args/TestInvalidArgsExpression.py
+++ lldb/test/API/commands/expression/invalid-args/TestInvalidArgsExpression.py
@@ -7,7 +7,9 @@
 @no_debug_info_test
 def test_invalid_lang(self):
 self.expect("expression -l foo --", error=True,
-substrs=["error: unknown language type: 'foo' for expression"])
+substrs=["error: unknown language type: 'foo' for expression",
+ "List of supported languages:",
+ "c++", "c++11", "c++14"])
 
 @no_debug_info_test
 def test_invalid_all_thread(self):
Index: lldb/source/Target/Language.cpp
===

[Lldb-commits] [PATCH] D142034: [lldb][Language] List supported languages in expr error text

2023-01-18 Thread Adrian Prantl via Phabricator via lldb-commits
aprantl accepted this revision.
aprantl added a comment.
This revision is now accepted and ready to land.

Nice. IIUC, this will query every already registered plugin, so it should also 
work without modification for e.g., LLDB with Swift support.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D142034/new/

https://reviews.llvm.org/D142034

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


[Lldb-commits] [lldb] b4a0b9f - [lldb][Language] List supported languages in expr error text

2023-01-18 Thread Michael Buch via lldb-commits

Author: Michael Buch
Date: 2023-01-18T18:18:52Z
New Revision: b4a0b9fab4dcb7b808612b49604709c2aeadf9f8

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

LOG: [lldb][Language] List supported languages in expr error text

Before:
```
(lldb) expr --language abc -- 1 + 1
error: unknown language type: 'abc' for expression
```

After:
```
(lldb) expr --language abc -- 1 + 1
error: unknown language type: 'abc' for expression. List of supported languages:
  c++
  objective-c++
  c++03
  c++11
  c++14
  objc++
```

We choose to only list the languages which `expr` will actually
accept instead of all the language constants defined in `Language.cpp`
since that's what the user will most likely need.

Differential Revision: https://reviews.llvm.org/D142034

Added: 


Modified: 
lldb/include/lldb/Target/Language.h
lldb/source/Commands/CommandObjectExpression.cpp
lldb/source/Target/Language.cpp
lldb/test/API/commands/expression/invalid-args/TestInvalidArgsExpression.py

Removed: 




diff  --git a/lldb/include/lldb/Target/Language.h 
b/lldb/include/lldb/Target/Language.h
index 89136cc5e0ff5..8cc1e72e138a5 100644
--- a/lldb/include/lldb/Target/Language.h
+++ b/lldb/include/lldb/Target/Language.h
@@ -279,6 +279,16 @@ class Language : public PluginInterface {
   static void PrintAllLanguages(Stream &s, const char *prefix,
 const char *suffix);
 
+  /// Prints to the specified stream 's' each language type that the
+  /// current target supports for expression evaluation.
+  ///
+  /// \param[out] s  Stream to which the language types are written.
+  /// \param[in]  prefix String that is prepended to the language type.
+  /// \param[in]  suffix String that is appended to the language type.
+  static void PrintSupportedLanguagesForExpressions(Stream &s,
+llvm::StringRef prefix,
+llvm::StringRef suffix);
+
   // return false from callback to stop iterating
   static void ForAllLanguages(std::function 
callback);
 

diff  --git a/lldb/source/Commands/CommandObjectExpression.cpp 
b/lldb/source/Commands/CommandObjectExpression.cpp
index 49d4976f7d3bf..9cce009f853e6 100644
--- a/lldb/source/Commands/CommandObjectExpression.cpp
+++ b/lldb/source/Commands/CommandObjectExpression.cpp
@@ -42,10 +42,15 @@ Status 
CommandObjectExpression::CommandOptions::SetOptionValue(
   switch (short_option) {
   case 'l':
 language = Language::GetLanguageTypeFromString(option_arg);
-if (language == eLanguageTypeUnknown)
-  error.SetErrorStringWithFormat(
-  "unknown language type: '%s' for expression",
-  option_arg.str().c_str());
+if (language == eLanguageTypeUnknown) {
+  StreamString sstr;
+  sstr.Printf("unknown language type: '%s' for expression. "
+  "List of supported languages:\n",
+  option_arg.str().c_str());
+
+  Language::PrintSupportedLanguagesForExpressions(sstr, "  ", "\n");
+  error.SetErrorString(sstr.GetString());
+}
 break;
 
   case 'a': {

diff  --git a/lldb/source/Target/Language.cpp b/lldb/source/Target/Language.cpp
index 92431005cba91..892d2a86437e3 100644
--- a/lldb/source/Target/Language.cpp
+++ b/lldb/source/Target/Language.cpp
@@ -221,6 +221,17 @@ const char *Language::GetNameForLanguageType(LanguageType 
language) {
 return language_names[eLanguageTypeUnknown].name;
 }
 
+void Language::PrintSupportedLanguagesForExpressions(Stream &s,
+ llvm::StringRef prefix,
+ llvm::StringRef suffix) {
+  auto supported = Language::GetLanguagesSupportingTypeSystemsForExpressions();
+  for (size_t idx = 0; idx < num_languages; ++idx) {
+auto const &lang = language_names[idx];
+if (supported[lang.type])
+  s << prefix << lang.name << suffix;
+  }
+}
+
 void Language::PrintAllLanguages(Stream &s, const char *prefix,
  const char *suffix) {
   for (uint32_t i = 1; i < num_languages; i++) {

diff  --git 
a/lldb/test/API/commands/expression/invalid-args/TestInvalidArgsExpression.py 
b/lldb/test/API/commands/expression/invalid-args/TestInvalidArgsExpression.py
index 859b823071c4a..1c53583fd00cc 100644
--- 
a/lldb/test/API/commands/expression/invalid-args/TestInvalidArgsExpression.py
+++ 
b/lldb/test/API/commands/expression/invalid-args/TestInvalidArgsExpression.py
@@ -7,7 +7,9 @@ class InvalidArgsExpressionTestCase(TestBase):
 @no_debug_info_test
 def test_invalid_lang(self):
 self.expect("expression -l foo --", error=True,
-substrs=["error: unknown language type: 'foo' for 
expression"])
+   

[Lldb-commits] [PATCH] D142034: [lldb][Language] List supported languages in expr error text

2023-01-18 Thread Michael Buch via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGb4a0b9fab4dc: [lldb][Language] List supported languages in 
expr error text (authored by Michael137).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D142034/new/

https://reviews.llvm.org/D142034

Files:
  lldb/include/lldb/Target/Language.h
  lldb/source/Commands/CommandObjectExpression.cpp
  lldb/source/Target/Language.cpp
  lldb/test/API/commands/expression/invalid-args/TestInvalidArgsExpression.py


Index: 
lldb/test/API/commands/expression/invalid-args/TestInvalidArgsExpression.py
===
--- lldb/test/API/commands/expression/invalid-args/TestInvalidArgsExpression.py
+++ lldb/test/API/commands/expression/invalid-args/TestInvalidArgsExpression.py
@@ -7,7 +7,9 @@
 @no_debug_info_test
 def test_invalid_lang(self):
 self.expect("expression -l foo --", error=True,
-substrs=["error: unknown language type: 'foo' for 
expression"])
+substrs=["error: unknown language type: 'foo' for 
expression",
+ "List of supported languages:",
+ "c++", "c++11", "c++14"])
 
 @no_debug_info_test
 def test_invalid_all_thread(self):
Index: lldb/source/Target/Language.cpp
===
--- lldb/source/Target/Language.cpp
+++ lldb/source/Target/Language.cpp
@@ -221,6 +221,17 @@
 return language_names[eLanguageTypeUnknown].name;
 }
 
+void Language::PrintSupportedLanguagesForExpressions(Stream &s,
+ llvm::StringRef prefix,
+ llvm::StringRef suffix) {
+  auto supported = Language::GetLanguagesSupportingTypeSystemsForExpressions();
+  for (size_t idx = 0; idx < num_languages; ++idx) {
+auto const &lang = language_names[idx];
+if (supported[lang.type])
+  s << prefix << lang.name << suffix;
+  }
+}
+
 void Language::PrintAllLanguages(Stream &s, const char *prefix,
  const char *suffix) {
   for (uint32_t i = 1; i < num_languages; i++) {
Index: lldb/source/Commands/CommandObjectExpression.cpp
===
--- lldb/source/Commands/CommandObjectExpression.cpp
+++ lldb/source/Commands/CommandObjectExpression.cpp
@@ -42,10 +42,15 @@
   switch (short_option) {
   case 'l':
 language = Language::GetLanguageTypeFromString(option_arg);
-if (language == eLanguageTypeUnknown)
-  error.SetErrorStringWithFormat(
-  "unknown language type: '%s' for expression",
-  option_arg.str().c_str());
+if (language == eLanguageTypeUnknown) {
+  StreamString sstr;
+  sstr.Printf("unknown language type: '%s' for expression. "
+  "List of supported languages:\n",
+  option_arg.str().c_str());
+
+  Language::PrintSupportedLanguagesForExpressions(sstr, "  ", "\n");
+  error.SetErrorString(sstr.GetString());
+}
 break;
 
   case 'a': {
Index: lldb/include/lldb/Target/Language.h
===
--- lldb/include/lldb/Target/Language.h
+++ lldb/include/lldb/Target/Language.h
@@ -279,6 +279,16 @@
   static void PrintAllLanguages(Stream &s, const char *prefix,
 const char *suffix);
 
+  /// Prints to the specified stream 's' each language type that the
+  /// current target supports for expression evaluation.
+  ///
+  /// \param[out] s  Stream to which the language types are written.
+  /// \param[in]  prefix String that is prepended to the language type.
+  /// \param[in]  suffix String that is appended to the language type.
+  static void PrintSupportedLanguagesForExpressions(Stream &s,
+llvm::StringRef prefix,
+llvm::StringRef suffix);
+
   // return false from callback to stop iterating
   static void ForAllLanguages(std::function 
callback);
 


Index: lldb/test/API/commands/expression/invalid-args/TestInvalidArgsExpression.py
===
--- lldb/test/API/commands/expression/invalid-args/TestInvalidArgsExpression.py
+++ lldb/test/API/commands/expression/invalid-args/TestInvalidArgsExpression.py
@@ -7,7 +7,9 @@
 @no_debug_info_test
 def test_invalid_lang(self):
 self.expect("expression -l foo --", error=True,
-substrs=["error: unknown language type: 'foo' for expression"])
+substrs=["error: unknown language type: 'foo' for expression",
+ "List of supported languages:",
+ "c++", "c++11", "c++14"])
 
 @no_debug_info_test
 def test_invalid_all_thread

[Lldb-commits] [PATCH] D141972: Delay loading of qProcessInfo-informed binaries until later in the Process setup

2023-01-18 Thread Jason Molenda via Phabricator via lldb-commits
jasonmolenda updated this revision to Diff 490232.
jasonmolenda added a comment.

Add a comment about the intentional placement of binary loading/load address 
setting in DidLaunchOrAttach to address Jim's feedback.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D141972/new/

https://reviews.llvm.org/D141972

Files:
  lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
  lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h

Index: lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
===
--- lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
+++ lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
@@ -374,6 +374,7 @@
   bool UpdateThreadIDList();
 
   void DidLaunchOrAttach(ArchSpec &process_arch);
+  void LoadStubBinaries();
   void MaybeLoadExecutableModule();
 
   Status ConnectToDebugserver(llvm::StringRef host_port);
Index: lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
===
--- lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
+++ lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
@@ -555,58 +555,6 @@
 }
   }
 
-  // The remote stub may know about the "main binary" in
-  // the context of a firmware debug session, and can
-  // give us a UUID and an address/slide of where the
-  // binary is loaded in memory.
-  UUID standalone_uuid;
-  addr_t standalone_value;
-  bool standalone_value_is_offset;
-  if (m_gdb_comm.GetProcessStandaloneBinary(
-  standalone_uuid, standalone_value, standalone_value_is_offset)) {
-ModuleSP module_sp;
-
-if (standalone_uuid.IsValid()) {
-  const bool force_symbol_search = true;
-  const bool notify = true;
-  DynamicLoader::LoadBinaryWithUUIDAndAddress(
-  this, llvm::StringRef(), standalone_uuid, standalone_value,
-  standalone_value_is_offset, force_symbol_search, notify);
-}
-  }
-
-  // The remote stub may know about a list of binaries to
-  // force load into the process -- a firmware type situation
-  // where multiple binaries are present in virtual memory,
-  // and we are only given the addresses of the binaries.
-  // Not intended for use with userland debugging when we
-  // a DynamicLoader plugin that knows how to find the loaded
-  // binaries and will track updates as binaries are added.
-
-  std::vector bin_addrs = m_gdb_comm.GetProcessStandaloneBinaries();
-  if (bin_addrs.size()) {
-UUID uuid;
-const bool value_is_slide = false;
-for (addr_t addr : bin_addrs) {
-  const bool notify = true;
-  // First see if this is a special platform
-  // binary that may determine the DynamicLoader and
-  // Platform to be used in this Process/Target in the
-  // process of loading it.
-  if (GetTarget()
-  .GetDebugger()
-  .GetPlatformList()
-  .LoadPlatformBinaryAndSetup(this, addr, notify))
-continue;
-
-  const bool force_symbol_search = true;
-  // Second manually load this binary into the Target.
-  DynamicLoader::LoadBinaryWithUUIDAndAddress(
-  this, llvm::StringRef(), uuid, addr, value_is_slide,
-  force_symbol_search, notify);
-}
-  }
-
   const StateType state = SetThreadStopInfo(response);
   if (state != eStateInvalid) {
 SetPrivateState(state);
@@ -1007,6 +955,9 @@
 }
   }
 
+  // Target and Process are reasonably initailized;
+  // load any binaries we have metadata for / set load address.
+  LoadStubBinaries();
   MaybeLoadExecutableModule();
 
   // Find out which StructuredDataPlugins are supported by the debug monitor.
@@ -1028,6 +979,60 @@
   }
 }
 
+void ProcessGDBRemote::LoadStubBinaries() {
+  // The remote stub may know about the "main binary" in
+  // the context of a firmware debug session, and can
+  // give us a UUID and an address/slide of where the
+  // binary is loaded in memory.
+  UUID standalone_uuid;
+  addr_t standalone_value;
+  bool standalone_value_is_offset;
+  if (m_gdb_comm.GetProcessStandaloneBinary(standalone_uuid, standalone_value,
+standalone_value_is_offset)) {
+ModuleSP module_sp;
+
+if (standalone_uuid.IsValid()) {
+  const bool force_symbol_search = true;
+  const bool notify = true;
+  DynamicLoader::LoadBinaryWithUUIDAndAddress(
+  this, llvm::StringRef(), standalone_uuid, standalone_value,
+  standalone_value_is_offset, force_symbol_search, notify);
+}
+  }
+
+  // The remote stub may know about a list of binaries to
+  // force load into the process -- a firmware type situation
+  // where multiple binaries are present in virtual

[Lldb-commits] [PATCH] D141972: Delay loading of qProcessInfo-informed binaries until later in the Process setup

2023-01-18 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere accepted this revision.
JDevlieghere added a comment.
This revision is now accepted and ready to land.

LGMT




Comment at: lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp:998
+  DynamicLoader::LoadBinaryWithUUIDAndAddress(
+  this, llvm::StringRef(), standalone_uuid, standalone_value,
+  standalone_value_is_offset, force_symbol_search, notify);

I know you just moved this code, but I don't think I've ever seen anyone write 
`llvm::StringRef()` instead of `""`. 



Comment at: 
lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp:1007-1008
+  // and we are only given the addresses of the binaries.
+  // Not intended for use with userland debugging when we
+  // a DynamicLoader plugin that knows how to find the loaded
+  // binaries and will track updates as binaries are added.

I think the word "use" is missing at the end of line 1007.



Comment at: 
lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp:1019-1020
+  // binary that may determine the DynamicLoader and
+  // Platform to be used in this Process/Target in the
+  // process of loading it.
+  if (GetTarget()

I suspect you meant to replace "in this Process/Target" with "in the process of 
loading it"?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D141972/new/

https://reviews.llvm.org/D141972

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


[Lldb-commits] [PATCH] D141972: Delay loading of qProcessInfo-informed binaries until later in the Process setup

2023-01-18 Thread Jason Molenda via Phabricator via lldb-commits
jasonmolenda updated this revision to Diff 490258.
jasonmolenda added a comment.

Thanks for the feedback Jonas, updated patch.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D141972/new/

https://reviews.llvm.org/D141972

Files:
  lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
  lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h

Index: lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
===
--- lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
+++ lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
@@ -374,6 +374,7 @@
   bool UpdateThreadIDList();
 
   void DidLaunchOrAttach(ArchSpec &process_arch);
+  void LoadStubBinaries();
   void MaybeLoadExecutableModule();
 
   Status ConnectToDebugserver(llvm::StringRef host_port);
Index: lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
===
--- lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
+++ lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
@@ -555,58 +555,6 @@
 }
   }
 
-  // The remote stub may know about the "main binary" in
-  // the context of a firmware debug session, and can
-  // give us a UUID and an address/slide of where the
-  // binary is loaded in memory.
-  UUID standalone_uuid;
-  addr_t standalone_value;
-  bool standalone_value_is_offset;
-  if (m_gdb_comm.GetProcessStandaloneBinary(
-  standalone_uuid, standalone_value, standalone_value_is_offset)) {
-ModuleSP module_sp;
-
-if (standalone_uuid.IsValid()) {
-  const bool force_symbol_search = true;
-  const bool notify = true;
-  DynamicLoader::LoadBinaryWithUUIDAndAddress(
-  this, llvm::StringRef(), standalone_uuid, standalone_value,
-  standalone_value_is_offset, force_symbol_search, notify);
-}
-  }
-
-  // The remote stub may know about a list of binaries to
-  // force load into the process -- a firmware type situation
-  // where multiple binaries are present in virtual memory,
-  // and we are only given the addresses of the binaries.
-  // Not intended for use with userland debugging when we
-  // a DynamicLoader plugin that knows how to find the loaded
-  // binaries and will track updates as binaries are added.
-
-  std::vector bin_addrs = m_gdb_comm.GetProcessStandaloneBinaries();
-  if (bin_addrs.size()) {
-UUID uuid;
-const bool value_is_slide = false;
-for (addr_t addr : bin_addrs) {
-  const bool notify = true;
-  // First see if this is a special platform
-  // binary that may determine the DynamicLoader and
-  // Platform to be used in this Process/Target in the
-  // process of loading it.
-  if (GetTarget()
-  .GetDebugger()
-  .GetPlatformList()
-  .LoadPlatformBinaryAndSetup(this, addr, notify))
-continue;
-
-  const bool force_symbol_search = true;
-  // Second manually load this binary into the Target.
-  DynamicLoader::LoadBinaryWithUUIDAndAddress(
-  this, llvm::StringRef(), uuid, addr, value_is_slide,
-  force_symbol_search, notify);
-}
-  }
-
   const StateType state = SetThreadStopInfo(response);
   if (state != eStateInvalid) {
 SetPrivateState(state);
@@ -1007,6 +955,9 @@
 }
   }
 
+  // Target and Process are reasonably initailized;
+  // load any binaries we have metadata for / set load address.
+  LoadStubBinaries();
   MaybeLoadExecutableModule();
 
   // Find out which StructuredDataPlugins are supported by the debug monitor.
@@ -1028,6 +979,59 @@
   }
 }
 
+void ProcessGDBRemote::LoadStubBinaries() {
+  // The remote stub may know about the "main binary" in
+  // the context of a firmware debug session, and can
+  // give us a UUID and an address/slide of where the
+  // binary is loaded in memory.
+  UUID standalone_uuid;
+  addr_t standalone_value;
+  bool standalone_value_is_offset;
+  if (m_gdb_comm.GetProcessStandaloneBinary(standalone_uuid, standalone_value,
+standalone_value_is_offset)) {
+ModuleSP module_sp;
+
+if (standalone_uuid.IsValid()) {
+  const bool force_symbol_search = true;
+  const bool notify = true;
+  DynamicLoader::LoadBinaryWithUUIDAndAddress(
+  this, "", standalone_uuid, standalone_value,
+  standalone_value_is_offset, force_symbol_search, notify);
+}
+  }
+
+  // The remote stub may know about a list of binaries to
+  // force load into the process -- a firmware type situation
+  // where multiple binaries are present in virtual memory,
+  // and we are only given the addresses of the binaries.
+  // Not intended for use with use

[Lldb-commits] [PATCH] D142052: [lldb] Implement SymbolFile::CopyType

2023-01-18 Thread Augusto Noronha via Phabricator via lldb-commits
augusto2112 created this revision.
augusto2112 added a reviewer: clayborg.
Herald added a project: All.
augusto2112 requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

SymbolFiles should be the only point of creation of Types to ensure
that they aren't destroyed prematurely by keeping them in the
SymbolFile's TypeList. This patch hides the copy constructor of Types,
and adds a new CopyType function to SymbolFile, so Types can still be
copied safely.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D142052

Files:
  lldb/include/lldb/Symbol/SymbolFile.h
  lldb/include/lldb/Symbol/SymbolFileOnDemand.h
  lldb/include/lldb/Symbol/Type.h


Index: lldb/include/lldb/Symbol/Type.h
===
--- lldb/include/lldb/Symbol/Type.h
+++ lldb/include/lldb/Symbol/Type.h
@@ -241,6 +241,14 @@
   // This makes an invalid type.  Used for functions that return a Type when
   // they get an error.
   Type();
+
+  Type(Type &t) = default;
+
+  Type(Type &&t) = default;
+
+  Type &operator=(const Type &t) = default;
+
+  Type &operator=(Type &&t) = default;
 };
 
 // the two classes here are used by the public API as a backend to the SBType
Index: lldb/include/lldb/Symbol/SymbolFileOnDemand.h
===
--- lldb/include/lldb/Symbol/SymbolFileOnDemand.h
+++ lldb/include/lldb/Symbol/SymbolFileOnDemand.h
@@ -241,6 +241,10 @@
 compiler_qual_type, compiler_type_resolve_state, opaque_payload);
   }
 
+  lldb::TypeSP CopyType(const lldb::TypeSP &other_type) override {
+return m_sym_file_impl->CopyType(other_type);
+  }
+
 private:
   Log *GetLog() const { return ::lldb_private::GetLog(LLDBLog::OnDemand); }
 
Index: lldb/include/lldb/Symbol/SymbolFile.h
===
--- lldb/include/lldb/Symbol/SymbolFile.h
+++ lldb/include/lldb/Symbol/SymbolFile.h
@@ -421,6 +421,8 @@
Type::ResolveState compiler_type_resolve_state,
uint32_t opaque_payload = 0) = 0;
 
+  virtual lldb::TypeSP CopyType(const lldb::TypeSP &other_type) = 0;
+
 protected:
   void AssertModuleLock();
 
@@ -521,6 +523,12 @@
  return type_sp;
   }
 
+  lldb::TypeSP CopyType(const lldb::TypeSP &other_type) override {
+ lldb::TypeSP type_sp (new Type(*other_type));
+ m_type_list.Insert(type_sp);
+ return type_sp;
+  }
+
 protected:
   virtual uint32_t CalculateNumCompileUnits() = 0;
   virtual lldb::CompUnitSP ParseCompileUnitAtIndex(uint32_t idx) = 0;


Index: lldb/include/lldb/Symbol/Type.h
===
--- lldb/include/lldb/Symbol/Type.h
+++ lldb/include/lldb/Symbol/Type.h
@@ -241,6 +241,14 @@
   // This makes an invalid type.  Used for functions that return a Type when
   // they get an error.
   Type();
+
+  Type(Type &t) = default;
+
+  Type(Type &&t) = default;
+
+  Type &operator=(const Type &t) = default;
+
+  Type &operator=(Type &&t) = default;
 };
 
 // the two classes here are used by the public API as a backend to the SBType
Index: lldb/include/lldb/Symbol/SymbolFileOnDemand.h
===
--- lldb/include/lldb/Symbol/SymbolFileOnDemand.h
+++ lldb/include/lldb/Symbol/SymbolFileOnDemand.h
@@ -241,6 +241,10 @@
 compiler_qual_type, compiler_type_resolve_state, opaque_payload);
   }
 
+  lldb::TypeSP CopyType(const lldb::TypeSP &other_type) override {
+return m_sym_file_impl->CopyType(other_type);
+  }
+
 private:
   Log *GetLog() const { return ::lldb_private::GetLog(LLDBLog::OnDemand); }
 
Index: lldb/include/lldb/Symbol/SymbolFile.h
===
--- lldb/include/lldb/Symbol/SymbolFile.h
+++ lldb/include/lldb/Symbol/SymbolFile.h
@@ -421,6 +421,8 @@
Type::ResolveState compiler_type_resolve_state,
uint32_t opaque_payload = 0) = 0;
 
+  virtual lldb::TypeSP CopyType(const lldb::TypeSP &other_type) = 0;
+
 protected:
   void AssertModuleLock();
 
@@ -521,6 +523,12 @@
  return type_sp;
   }
 
+  lldb::TypeSP CopyType(const lldb::TypeSP &other_type) override {
+ lldb::TypeSP type_sp (new Type(*other_type));
+ m_type_list.Insert(type_sp);
+ return type_sp;
+  }
+
 protected:
   virtual uint32_t CalculateNumCompileUnits() = 0;
   virtual lldb::CompUnitSP ParseCompileUnitAtIndex(uint32_t idx) = 0;
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] db223b7 - Do qProcessInfo-hint binary loading later in Process setup

2023-01-18 Thread Jason Molenda via lldb-commits

Author: Jason Molenda
Date: 2023-01-18T12:33:05-08:00
New Revision: db223b7f01f70cbd8459d0db9b20dfe9a3b099a7

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

LOG: Do qProcessInfo-hint binary loading later in Process setup

The remote stub may give lldb hints about binaries to
be loaded, especially in a firmware type environment, and
relay those hints in the qProcessInfo response.  The
binary loading was done very early in Process setup, before
we had any threads, and this made it complicated for people
to write dSYM python scripts which need access to a thread.
Delay the binary loading until a bit later in the Process
startup.

Differential Revision: https://reviews.llvm.org/D141972
rdar://104235301

Added: 


Modified: 
lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h

Removed: 




diff  --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp 
b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
index 2f3a81fedd0b9..de8f2df52f23b 100644
--- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
@@ -555,58 +555,6 @@ Status ProcessGDBRemote::DoConnectRemote(llvm::StringRef 
remote_url) {
 }
   }
 
-  // The remote stub may know about the "main binary" in
-  // the context of a firmware debug session, and can
-  // give us a UUID and an address/slide of where the
-  // binary is loaded in memory.
-  UUID standalone_uuid;
-  addr_t standalone_value;
-  bool standalone_value_is_offset;
-  if (m_gdb_comm.GetProcessStandaloneBinary(
-  standalone_uuid, standalone_value, standalone_value_is_offset)) {
-ModuleSP module_sp;
-
-if (standalone_uuid.IsValid()) {
-  const bool force_symbol_search = true;
-  const bool notify = true;
-  DynamicLoader::LoadBinaryWithUUIDAndAddress(
-  this, llvm::StringRef(), standalone_uuid, standalone_value,
-  standalone_value_is_offset, force_symbol_search, notify);
-}
-  }
-
-  // The remote stub may know about a list of binaries to
-  // force load into the process -- a firmware type situation
-  // where multiple binaries are present in virtual memory,
-  // and we are only given the addresses of the binaries.
-  // Not intended for use with userland debugging when we
-  // a DynamicLoader plugin that knows how to find the loaded
-  // binaries and will track updates as binaries are added.
-
-  std::vector bin_addrs = 
m_gdb_comm.GetProcessStandaloneBinaries();
-  if (bin_addrs.size()) {
-UUID uuid;
-const bool value_is_slide = false;
-for (addr_t addr : bin_addrs) {
-  const bool notify = true;
-  // First see if this is a special platform
-  // binary that may determine the DynamicLoader and
-  // Platform to be used in this Process/Target in the
-  // process of loading it.
-  if (GetTarget()
-  .GetDebugger()
-  .GetPlatformList()
-  .LoadPlatformBinaryAndSetup(this, addr, notify))
-continue;
-
-  const bool force_symbol_search = true;
-  // Second manually load this binary into the Target.
-  DynamicLoader::LoadBinaryWithUUIDAndAddress(
-  this, llvm::StringRef(), uuid, addr, value_is_slide,
-  force_symbol_search, notify);
-}
-  }
-
   const StateType state = SetThreadStopInfo(response);
   if (state != eStateInvalid) {
 SetPrivateState(state);
@@ -1007,6 +955,9 @@ void ProcessGDBRemote::DidLaunchOrAttach(ArchSpec 
&process_arch) {
 }
   }
 
+  // Target and Process are reasonably initailized;
+  // load any binaries we have metadata for / set load address.
+  LoadStubBinaries();
   MaybeLoadExecutableModule();
 
   // Find out which StructuredDataPlugins are supported by the debug monitor.
@@ -1028,6 +979,59 @@ void ProcessGDBRemote::DidLaunchOrAttach(ArchSpec 
&process_arch) {
   }
 }
 
+void ProcessGDBRemote::LoadStubBinaries() {
+  // The remote stub may know about the "main binary" in
+  // the context of a firmware debug session, and can
+  // give us a UUID and an address/slide of where the
+  // binary is loaded in memory.
+  UUID standalone_uuid;
+  addr_t standalone_value;
+  bool standalone_value_is_offset;
+  if (m_gdb_comm.GetProcessStandaloneBinary(standalone_uuid, standalone_value,
+standalone_value_is_offset)) {
+ModuleSP module_sp;
+
+if (standalone_uuid.IsValid()) {
+  const bool force_symbol_search = true;
+  const bool notify = t

[Lldb-commits] [PATCH] D141972: Delay loading of qProcessInfo-informed binaries until later in the Process setup

2023-01-18 Thread Jason Molenda via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGdb223b7f01f7: Do qProcessInfo-hint binary loading later in 
Process setup (authored by jasonmolenda).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D141972/new/

https://reviews.llvm.org/D141972

Files:
  lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
  lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h

Index: lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
===
--- lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
+++ lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
@@ -374,6 +374,7 @@
   bool UpdateThreadIDList();
 
   void DidLaunchOrAttach(ArchSpec &process_arch);
+  void LoadStubBinaries();
   void MaybeLoadExecutableModule();
 
   Status ConnectToDebugserver(llvm::StringRef host_port);
Index: lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
===
--- lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
+++ lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
@@ -555,58 +555,6 @@
 }
   }
 
-  // The remote stub may know about the "main binary" in
-  // the context of a firmware debug session, and can
-  // give us a UUID and an address/slide of where the
-  // binary is loaded in memory.
-  UUID standalone_uuid;
-  addr_t standalone_value;
-  bool standalone_value_is_offset;
-  if (m_gdb_comm.GetProcessStandaloneBinary(
-  standalone_uuid, standalone_value, standalone_value_is_offset)) {
-ModuleSP module_sp;
-
-if (standalone_uuid.IsValid()) {
-  const bool force_symbol_search = true;
-  const bool notify = true;
-  DynamicLoader::LoadBinaryWithUUIDAndAddress(
-  this, llvm::StringRef(), standalone_uuid, standalone_value,
-  standalone_value_is_offset, force_symbol_search, notify);
-}
-  }
-
-  // The remote stub may know about a list of binaries to
-  // force load into the process -- a firmware type situation
-  // where multiple binaries are present in virtual memory,
-  // and we are only given the addresses of the binaries.
-  // Not intended for use with userland debugging when we
-  // a DynamicLoader plugin that knows how to find the loaded
-  // binaries and will track updates as binaries are added.
-
-  std::vector bin_addrs = m_gdb_comm.GetProcessStandaloneBinaries();
-  if (bin_addrs.size()) {
-UUID uuid;
-const bool value_is_slide = false;
-for (addr_t addr : bin_addrs) {
-  const bool notify = true;
-  // First see if this is a special platform
-  // binary that may determine the DynamicLoader and
-  // Platform to be used in this Process/Target in the
-  // process of loading it.
-  if (GetTarget()
-  .GetDebugger()
-  .GetPlatformList()
-  .LoadPlatformBinaryAndSetup(this, addr, notify))
-continue;
-
-  const bool force_symbol_search = true;
-  // Second manually load this binary into the Target.
-  DynamicLoader::LoadBinaryWithUUIDAndAddress(
-  this, llvm::StringRef(), uuid, addr, value_is_slide,
-  force_symbol_search, notify);
-}
-  }
-
   const StateType state = SetThreadStopInfo(response);
   if (state != eStateInvalid) {
 SetPrivateState(state);
@@ -1007,6 +955,9 @@
 }
   }
 
+  // Target and Process are reasonably initailized;
+  // load any binaries we have metadata for / set load address.
+  LoadStubBinaries();
   MaybeLoadExecutableModule();
 
   // Find out which StructuredDataPlugins are supported by the debug monitor.
@@ -1028,6 +979,59 @@
   }
 }
 
+void ProcessGDBRemote::LoadStubBinaries() {
+  // The remote stub may know about the "main binary" in
+  // the context of a firmware debug session, and can
+  // give us a UUID and an address/slide of where the
+  // binary is loaded in memory.
+  UUID standalone_uuid;
+  addr_t standalone_value;
+  bool standalone_value_is_offset;
+  if (m_gdb_comm.GetProcessStandaloneBinary(standalone_uuid, standalone_value,
+standalone_value_is_offset)) {
+ModuleSP module_sp;
+
+if (standalone_uuid.IsValid()) {
+  const bool force_symbol_search = true;
+  const bool notify = true;
+  DynamicLoader::LoadBinaryWithUUIDAndAddress(
+  this, "", standalone_uuid, standalone_value,
+  standalone_value_is_offset, force_symbol_search, notify);
+}
+  }
+
+  // The remote stub may know about a list of binaries to
+  // force load into the process -- a firmware type situation
+  // where multiple binaries are present in virtual memory,
+  // and we are only given 

[Lldb-commits] [PATCH] D142059: [lldb/Plugins] Add ScriptedProcess::GetCapabilities affordance (NFC)

2023-01-18 Thread Med Ismail Bennani via Phabricator via lldb-commits
mib created this revision.
mib added reviewers: bulbazord, JDevlieghere.
mib added a project: LLDB.
Herald added a project: All.
mib requested review of this revision.
Herald added a subscriber: lldb-commits.

This patch introduces a new method to the Scripted Process interface,
GetCapabilities.

This returns a dictionary that contains a list of flags that the
ScriptedProcess instance supports. This can be used for instance, to
force symbol lookup, when loading dynamic libraries in the scripted process.

Signed-off-by: Med Ismail Bennani 


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D142059

Files:
  lldb/examples/python/scripted_process/scripted_process.py
  lldb/include/lldb/Interpreter/ScriptedProcessInterface.h
  
lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.cpp
  lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.h


Index: 
lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.h
===
--- 
lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.h
+++ 
lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.h
@@ -29,6 +29,8 @@
  StructuredData::DictionarySP args_sp,
  StructuredData::Generic *script_obj = nullptr) override;
 
+  StructuredData::ArraySP GetCapabilities() override;
+
   Status Launch() override;
 
   Status Resume() override;
Index: 
lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.cpp
===
--- 
lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.cpp
+++ 
lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.cpp
@@ -56,6 +56,23 @@
   return m_object_instance_sp;
 }
 
+StructuredData::ArraySP ScriptedProcessPythonInterface::GetCapabilities() {
+  Status error;
+  StructuredData::ArraySP array =
+  Dispatch("get_capabilities", error);
+
+  if (!array || !array->IsValid() || error.Fail()) {
+return ScriptedInterface::ErrorWithMessage(
+LLVM_PRETTY_FUNCTION,
+llvm::Twine("Null or invalid object (" +
+llvm::Twine(error.AsCString()) + llvm::Twine(")."))
+.str(),
+error);
+  }
+
+  return array;
+}
+
 Status ScriptedProcessPythonInterface::Launch() {
   return GetStatusFromMethod("launch");
 }
Index: lldb/include/lldb/Interpreter/ScriptedProcessInterface.h
===
--- lldb/include/lldb/Interpreter/ScriptedProcessInterface.h
+++ lldb/include/lldb/Interpreter/ScriptedProcessInterface.h
@@ -28,6 +28,8 @@
 return {};
   }
 
+  virtual StructuredData::ArraySP GetCapabilities() { return {}; }
+
   virtual Status Launch() { return Status("ScriptedProcess did not launch"); }
 
   virtual Status Resume() { return Status("ScriptedProcess did not resume"); }
Index: lldb/examples/python/scripted_process/scripted_process.py
===
--- lldb/examples/python/scripted_process/scripted_process.py
+++ lldb/examples/python/scripted_process/scripted_process.py
@@ -14,6 +14,7 @@
 THE METHODS EXPOSED MIGHT CHANGE IN THE FUTURE.
 """
 
+capabilities = None
 memory_regions = None
 loaded_images = None
 threads = None
@@ -45,6 +46,11 @@
 self.threads = {}
 self.loaded_images = []
 self.metadata = {}
+self.capabilities = {}
+
+@abstractmethod
+def get_capabilities(self):
+return self.capabilities
 
 @abstractmethod
 def get_memory_region_containing_address(self, addr):


Index: lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.h
===
--- lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.h
+++ lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.h
@@ -29,6 +29,8 @@
  StructuredData::DictionarySP args_sp,
  StructuredData::Generic *script_obj = nullptr) override;
 
+  StructuredData::ArraySP GetCapabilities() override;
+
   Status Launch() override;
 
   Status Resume() override;
Index: lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.cpp
===
--- lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.cpp
+++ lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.cpp
@@ -56,6 +56,23 @@
   return m_object_instance_sp;
 }
 
+StructuredData::ArraySP ScriptedProcessPythonInterface::GetCapabilities() {
+  Status error;
+  StructuredData::ArraySP array =
+  Dispatch("get_capabilities", error);
+
+  if (!array || !array->IsValid() || error.Fail()) {
+return ScriptedInterf

[Lldb-commits] [PATCH] D142059: [lldb/Plugins] Add ScriptedProcess::GetCapabilities affordance (NFC)

2023-01-18 Thread Med Ismail Bennani via Phabricator via lldb-commits
mib updated this revision to Diff 490301.
mib added a comment.

Add python docstring


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D142059/new/

https://reviews.llvm.org/D142059

Files:
  lldb/examples/python/scripted_process/scripted_process.py
  lldb/include/lldb/Interpreter/ScriptedProcessInterface.h
  
lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.cpp
  lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.h


Index: 
lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.h
===
--- 
lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.h
+++ 
lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.h
@@ -29,6 +29,8 @@
  StructuredData::DictionarySP args_sp,
  StructuredData::Generic *script_obj = nullptr) override;
 
+  StructuredData::ArraySP GetCapabilities() override;
+
   Status Launch() override;
 
   Status Resume() override;
Index: 
lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.cpp
===
--- 
lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.cpp
+++ 
lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.cpp
@@ -56,6 +56,23 @@
   return m_object_instance_sp;
 }
 
+StructuredData::ArraySP ScriptedProcessPythonInterface::GetCapabilities() {
+  Status error;
+  StructuredData::ArraySP array =
+  Dispatch("get_capabilities", error);
+
+  if (!array || !array->IsValid() || error.Fail()) {
+return ScriptedInterface::ErrorWithMessage(
+LLVM_PRETTY_FUNCTION,
+llvm::Twine("Null or invalid object (" +
+llvm::Twine(error.AsCString()) + llvm::Twine(")."))
+.str(),
+error);
+  }
+
+  return array;
+}
+
 Status ScriptedProcessPythonInterface::Launch() {
   return GetStatusFromMethod("launch");
 }
Index: lldb/include/lldb/Interpreter/ScriptedProcessInterface.h
===
--- lldb/include/lldb/Interpreter/ScriptedProcessInterface.h
+++ lldb/include/lldb/Interpreter/ScriptedProcessInterface.h
@@ -28,6 +28,8 @@
 return {};
   }
 
+  virtual StructuredData::ArraySP GetCapabilities() { return {}; }
+
   virtual Status Launch() { return Status("ScriptedProcess did not launch"); }
 
   virtual Status Resume() { return Status("ScriptedProcess did not resume"); }
Index: lldb/examples/python/scripted_process/scripted_process.py
===
--- lldb/examples/python/scripted_process/scripted_process.py
+++ lldb/examples/python/scripted_process/scripted_process.py
@@ -14,6 +14,7 @@
 THE METHODS EXPOSED MIGHT CHANGE IN THE FUTURE.
 """
 
+capabilities = None
 memory_regions = None
 loaded_images = None
 threads = None
@@ -45,6 +46,18 @@
 self.threads = {}
 self.loaded_images = []
 self.metadata = {}
+self.capabilities = {}
+
+@abstractmethod
+def get_capabilities(self):
+""" Get a dictionary containing the process capabilities.
+
+Returns:
+Dict[str:bool]: The dictionary of capability, with the capability
+name as the key and a boolean flag as the value.
+The dictionary can be empty.
+"""
+return self.capabilities
 
 @abstractmethod
 def get_memory_region_containing_address(self, addr):


Index: lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.h
===
--- lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.h
+++ lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.h
@@ -29,6 +29,8 @@
  StructuredData::DictionarySP args_sp,
  StructuredData::Generic *script_obj = nullptr) override;
 
+  StructuredData::ArraySP GetCapabilities() override;
+
   Status Launch() override;
 
   Status Resume() override;
Index: lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.cpp
===
--- lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.cpp
+++ lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.cpp
@@ -56,6 +56,23 @@
   return m_object_instance_sp;
 }
 
+StructuredData::ArraySP ScriptedProcessPythonInterface::GetCapabilities() {
+  Status error;
+  StructuredData::ArraySP array =
+  Dispatch("get_capabilities", error);
+
+  if (!array || !array->IsValid() || error.Fail()) {
+return ScriptedInterface::ErrorWithMessage(
+LLVM_PRETTY_FUNCTION,
+llvm::Twine("Null or invalid object (" +
+llvm::Twine(error.AsCStr

[Lldb-commits] [PATCH] D142059: [lldb/Plugins] Add ScriptedProcess::GetCapabilities affordance (NFC)

2023-01-18 Thread Alex Langford via Phabricator via lldb-commits
bulbazord accepted this revision.
bulbazord added a comment.
This revision is now accepted and ready to land.

LGTM


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D142059/new/

https://reviews.llvm.org/D142059

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


[Lldb-commits] [PATCH] D142067: Remove the "help" subcommand - its undocumented, undiscoverable and doesn't work....

2023-01-18 Thread Jim Ingham via Phabricator via lldb-commits
jingham created this revision.
jingham added reviewers: JDevlieghere, jasonmolenda.
Herald added a project: All.
jingham requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

For some reason (lost in the mists of time) CommandObjectMultiword will check 
to see if you've passed it an argument with the text value "help" and if it 
sees that, it will print help.

That's not how the lldb help system works, and this is nowhere documented.  
It's not terribly discoverable, and doesn't behave like the rest of the lldb 
command system - doesn't auto-complete, doesn't do shortest unique match, 
etc...  It also doesn't work for anything but the first level in the hierarchy:

  (lldb) break help 
  Commands for operating on breakpoints (see 'help b' for shorthand.)
  
  Syntax: breakpoint  []
  ...

But:

  (lldb) break set help
  error: invalid combination of options for the given command

It is also confusing if you happen across it because then you think that's the 
way the help system works which it isn't.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D142067

Files:
  lldb/source/Commands/CommandObjectMultiword.cpp


Index: lldb/source/Commands/CommandObjectMultiword.cpp
===
--- lldb/source/Commands/CommandObjectMultiword.cpp
+++ lldb/source/Commands/CommandObjectMultiword.cpp
@@ -174,11 +174,6 @@
 return result.Succeeded();
   }
 
-  if (sub_command.equals_insensitive("help")) {
-this->CommandObject::GenerateHelpText(result);
-return result.Succeeded();
-  }
-
   if (m_subcommand_dict.empty()) {
 result.AppendErrorWithFormat("'%s' does not have any subcommands.\n",
  GetCommandName().str().c_str());


Index: lldb/source/Commands/CommandObjectMultiword.cpp
===
--- lldb/source/Commands/CommandObjectMultiword.cpp
+++ lldb/source/Commands/CommandObjectMultiword.cpp
@@ -174,11 +174,6 @@
 return result.Succeeded();
   }
 
-  if (sub_command.equals_insensitive("help")) {
-this->CommandObject::GenerateHelpText(result);
-return result.Succeeded();
-  }
-
   if (m_subcommand_dict.empty()) {
 result.AppendErrorWithFormat("'%s' does not have any subcommands.\n",
  GetCommandName().str().c_str());
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits