[Lldb-commits] [PATCH] D140800: [OptTable] Precompute OptTable prefixes union table through tablegen

2023-01-12 Thread Nikita Popov via Phabricator via lldb-commits
nikic accepted this revision.
nikic added a comment.
This revision is now accepted and ready to land.

LGTM

In D140800#4044983 , 
@serge-sans-paille wrote:

> In D140800#4043723 , @nikic wrote:
>
>> Just to check, this isn't going to cause some warning spew about all those 
>> OptTable implementations being non-final?
>
> nope. Why would there be?

Something about missing virtual destructors on a non-final class? Not sure when 
exactly that warning applies.




Comment at: llvm/unittests/Option/OptionParsingTest.cpp:327
 
-TEST(DISABLED_Option, FindNearestFIXME) {
-  TestOptTable T;

serge-sans-paille wrote:
> @nikic: the `DISABLED_` prefix seems to be a gtest convention, see 
> https://github.com/google/googletest/blob/main/docs/advanced.md#temporarily-disabling-tests
Huh, TIL.


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

https://reviews.llvm.org/D140800

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


[Lldb-commits] [PATCH] D140615: [LLDB][LoongArch] Delete the s9 register alias definition

2023-01-12 Thread David Spickett via Phabricator via lldb-commits
DavidSpickett accepted this revision.
DavidSpickett added a comment.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140615

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


[Lldb-commits] [PATCH] D140386: [LLDB][LoongArch] Add unittests for EmulateInstructionLoongArch

2023-01-12 Thread David Spickett via Phabricator via lldb-commits
DavidSpickett accepted this revision.
DavidSpickett added a comment.
This revision is now accepted and ready to land.

LGTM


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

https://reviews.llvm.org/D140386

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


[Lldb-commits] [PATCH] D141245: [LLDB][LoongArch] ObjectFile: add a case for `EM_LOONGARCH`

2023-01-12 Thread David Spickett via Phabricator via lldb-commits
DavidSpickett accepted this revision.
DavidSpickett added a comment.

LGTM.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141245

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


[Lldb-commits] [PATCH] D140759: [LLDB][LoongArch] Add FP branch instructions for EmulateInstructionLoongArch

2023-01-12 Thread David Spickett via Phabricator via lldb-commits
DavidSpickett accepted this revision.
DavidSpickett added a comment.

Thanks for adding the testing in earlier patches.

At this point my review isn't adding much value and @SixWeining has the ISA 
details covered. So changes like this can go in without extra approval in 
future unless there is some major code structure change.


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

https://reviews.llvm.org/D140759

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


[Lldb-commits] [PATCH] D138197: [lldb] Fix bitfield incorrectly printing when field crosses a storage unit

2023-01-12 Thread David Spickett via Phabricator via lldb-commits
DavidSpickett added a comment.

Ping!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D138197

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


[Lldb-commits] [PATCH] D136928: [LLDB] Fix help text for "platform settings"

2023-01-12 Thread David Spickett via Phabricator via lldb-commits
DavidSpickett added a comment.

Ping!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136928

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


[Lldb-commits] [lldb] 07bb29d - [OptTable] Precompute OptTable prefixes union table through tablegen

2023-01-12 Thread via lldb-commits

Author: serge-sans-paille
Date: 2023-01-12T12:08:06+01:00
New Revision: 07bb29d8ffc3b82d5a7bb1217d93e8fa86e6969a

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

LOG: [OptTable] Precompute OptTable prefixes union table through tablegen

This avoid rediscovering this table when reading each options, providing
a sensible 2% speedup when processing and empty file, and a measurable
speedup on typical workloads, see:

This is optional, the legacy, on-the-fly, approach can still be used
through the GenericOptTable class, while the new one is used through
PrecomputedOptTable.

https://llvm-compile-time-tracker.com/compare.php?from=4da6cb3202817ee2897d6b690e4af950459caea4&to=19a492b704e8f5c1dea120b9c0d3859bd78796be&stat=instructions:u

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

Added: 


Modified: 
clang/lib/Driver/DriverOptions.cpp
clang/lib/Driver/ToolChains/Gnu.cpp
clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
lld/COFF/Driver.h
lld/COFF/DriverUtils.cpp
lld/ELF/Driver.h
lld/ELF/DriverUtils.cpp
lld/MachO/Driver.h
lld/MachO/DriverUtils.cpp
lld/MinGW/Driver.cpp
lld/wasm/Driver.cpp
lldb/tools/driver/Driver.cpp
lldb/tools/lldb-server/lldb-gdbserver.cpp
lldb/tools/lldb-vscode/lldb-vscode.cpp
llvm/include/llvm/Option/OptTable.h
llvm/lib/ExecutionEngine/JITLink/COFFDirectiveParser.cpp
llvm/lib/Option/OptTable.cpp
llvm/lib/ToolDrivers/llvm-dlltool/DlltoolDriver.cpp
llvm/lib/ToolDrivers/llvm-lib/LibDriver.cpp
llvm/tools/dsymutil/dsymutil.cpp
llvm/tools/llvm-cvtres/llvm-cvtres.cpp
llvm/tools/llvm-cxxfilt/llvm-cxxfilt.cpp
llvm/tools/llvm-dwarfutil/llvm-dwarfutil.cpp
llvm/tools/llvm-ifs/llvm-ifs.cpp
llvm/tools/llvm-lipo/llvm-lipo.cpp
llvm/tools/llvm-ml/llvm-ml.cpp
llvm/tools/llvm-mt/llvm-mt.cpp
llvm/tools/llvm-nm/llvm-nm.cpp
llvm/tools/llvm-objcopy/ObjcopyOptions.cpp
llvm/tools/llvm-objdump/llvm-objdump.cpp
llvm/tools/llvm-rc/llvm-rc.cpp
llvm/tools/llvm-readobj/llvm-readobj.cpp
llvm/tools/llvm-size/llvm-size.cpp
llvm/tools/llvm-strings/llvm-strings.cpp
llvm/tools/llvm-symbolizer/llvm-symbolizer.cpp
llvm/tools/llvm-tli-checker/llvm-tli-checker.cpp
llvm/unittests/Option/OptionParsingTest.cpp
llvm/utils/TableGen/OptParserEmitter.cpp

Removed: 




diff  --git a/clang/lib/Driver/DriverOptions.cpp 
b/clang/lib/Driver/DriverOptions.cpp
index 0a14749bc1106..2a6868d179159 100644
--- a/clang/lib/Driver/DriverOptions.cpp
+++ b/clang/lib/Driver/DriverOptions.cpp
@@ -27,6 +27,14 @@ using namespace llvm::opt;
 #include "clang/Driver/Options.inc"
 #undef PREFIX
 
+static constexpr const llvm::StringLiteral PrefixTable_init[] =
+#define PREFIX_UNION(VALUES) VALUES
+#include "clang/Driver/Options.inc"
+#undef PREFIX_UNION
+;
+static constexpr const llvm::ArrayRef
+PrefixTable(PrefixTable_init, std::size(PrefixTable_init) - 1);
+
 static constexpr OptTable::Info InfoTable[] = {
 #define OPTION(PREFIX, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM,  
\
HELPTEXT, METAVAR, VALUES)  
\
@@ -38,12 +46,10 @@ static constexpr OptTable::Info InfoTable[] = {
 
 namespace {
 
-class DriverOptTable : public OptTable {
+class DriverOptTable : public PrecomputedOptTable {
 public:
-  DriverOptTable()
-: OptTable(InfoTable) {}
+  DriverOptTable() : PrecomputedOptTable(InfoTable, PrefixTable) {}
 };
-
 }
 
 const llvm::opt::OptTable &clang::driver::getDriverOptTable() {

diff  --git a/clang/lib/Driver/ToolChains/Gnu.cpp 
b/clang/lib/Driver/ToolChains/Gnu.cpp
index e64bf70a06e8d..4f23403166543 100644
--- a/clang/lib/Driver/ToolChains/Gnu.cpp
+++ b/clang/lib/Driver/ToolChains/Gnu.cpp
@@ -23,6 +23,7 @@
 #include "clang/Driver/Options.h"
 #include "clang/Driver/Tool.h"
 #include "clang/Driver/ToolChain.h"
+#include "llvm/ADT/StringSet.h"
 #include "llvm/ADT/Twine.h"
 #include "llvm/Option/ArgList.h"
 #include "llvm/Support/CodeGen.h"

diff  --git a/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp 
b/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
index ad942efb352e8..a6e127c34034f 100644
--- a/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
+++ b/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
@@ -138,9 +138,9 @@ static constexpr OptTable::Info InfoTable[] = {
 #undef OPTION
 };
 
-class WrapperOptTable : public opt::OptTable {
+class WrapperOptTable : public opt::GenericOptTable {
 public:
-  WrapperOptTable() : OptTable(InfoTable) {}
+  WrapperOptTable() : opt::GenericOptTable(InfoTable) {}
 };
 
 const OptTable &getOptTable() {

diff  --git a/lld/COFF/Driver.h b/lld/COFF/Driver.h
index 28bf2cc81ef37..8ec3bb464206e 100644
--- a/lld/COFF/Driver.h
+++ b/lld/COFF

[Lldb-commits] [PATCH] D140800: [OptTable] Precompute OptTable prefixes union table through tablegen

2023-01-12 Thread serge via Phabricator via lldb-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG07bb29d8ffc3: [OptTable] Precompute OptTable prefixes union 
table through tablegen (authored by serge-sans-paille).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140800

Files:
  clang/lib/Driver/DriverOptions.cpp
  clang/lib/Driver/ToolChains/Gnu.cpp
  clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
  lld/COFF/Driver.h
  lld/COFF/DriverUtils.cpp
  lld/ELF/Driver.h
  lld/ELF/DriverUtils.cpp
  lld/MachO/Driver.h
  lld/MachO/DriverUtils.cpp
  lld/MinGW/Driver.cpp
  lld/wasm/Driver.cpp
  lldb/tools/driver/Driver.cpp
  lldb/tools/lldb-server/lldb-gdbserver.cpp
  lldb/tools/lldb-vscode/lldb-vscode.cpp
  llvm/include/llvm/Option/OptTable.h
  llvm/lib/ExecutionEngine/JITLink/COFFDirectiveParser.cpp
  llvm/lib/Option/OptTable.cpp
  llvm/lib/ToolDrivers/llvm-dlltool/DlltoolDriver.cpp
  llvm/lib/ToolDrivers/llvm-lib/LibDriver.cpp
  llvm/tools/dsymutil/dsymutil.cpp
  llvm/tools/llvm-cvtres/llvm-cvtres.cpp
  llvm/tools/llvm-cxxfilt/llvm-cxxfilt.cpp
  llvm/tools/llvm-dwarfutil/llvm-dwarfutil.cpp
  llvm/tools/llvm-ifs/llvm-ifs.cpp
  llvm/tools/llvm-lipo/llvm-lipo.cpp
  llvm/tools/llvm-ml/llvm-ml.cpp
  llvm/tools/llvm-mt/llvm-mt.cpp
  llvm/tools/llvm-nm/llvm-nm.cpp
  llvm/tools/llvm-objcopy/ObjcopyOptions.cpp
  llvm/tools/llvm-objdump/llvm-objdump.cpp
  llvm/tools/llvm-rc/llvm-rc.cpp
  llvm/tools/llvm-readobj/llvm-readobj.cpp
  llvm/tools/llvm-size/llvm-size.cpp
  llvm/tools/llvm-strings/llvm-strings.cpp
  llvm/tools/llvm-symbolizer/llvm-symbolizer.cpp
  llvm/tools/llvm-tli-checker/llvm-tli-checker.cpp
  llvm/unittests/Option/OptionParsingTest.cpp
  llvm/utils/TableGen/OptParserEmitter.cpp

Index: llvm/utils/TableGen/OptParserEmitter.cpp
===
--- llvm/utils/TableGen/OptParserEmitter.cpp
+++ llvm/utils/TableGen/OptParserEmitter.cpp
@@ -237,8 +237,14 @@
   CurPrefix = NewPrefix;
   }
 
-  // Dump prefixes.
+  DenseSet PrefixesUnionSet;
+  for (const auto &Prefix : Prefixes)
+PrefixesUnionSet.insert(Prefix.first.begin(), Prefix.first.end());
+  SmallVector PrefixesUnion(PrefixesUnionSet.begin(),
+   PrefixesUnionSet.end());
+  array_pod_sort(PrefixesUnion.begin(), PrefixesUnion.end());
 
+  // Dump prefixes.
   OS << "/\n";
   OS << "// Prefixes\n\n";
   OS << "#ifdef PREFIX\n";
@@ -259,6 +265,20 @@
   OS << "#undef COMMA\n";
   OS << "#endif // PREFIX\n\n";
 
+  // Dump prefix unions.
+  OS << "/\n";
+  OS << "// Prefix Union\n\n";
+  OS << "#ifdef PREFIX_UNION\n";
+  OS << "#define COMMA ,\n";
+  OS << "PREFIX_UNION({\n";
+  for (const auto &Prefix : PrefixesUnion) {
+OS << "llvm::StringLiteral(\"" << Prefix << "\") COMMA ";
+  }
+  OS << "llvm::StringLiteral(\"\")})\n";
+  OS << "#undef COMMA\n";
+  OS << "#endif // PREFIX_UNION\n\n";
+
+  // Dump groups.
   OS << "/\n";
   OS << "// ValuesCode\n\n";
   OS << "#ifdef OPTTABLE_VALUES_CODE\n";
Index: llvm/unittests/Option/OptionParsingTest.cpp
===
--- llvm/unittests/Option/OptionParsingTest.cpp
+++ llvm/unittests/Option/OptionParsingTest.cpp
@@ -32,6 +32,14 @@
 #include "Opts.inc"
 #undef PREFIX
 
+static constexpr const StringLiteral PrefixTable_init[] =
+#define PREFIX_UNION(VALUES) VALUES
+#include "Opts.inc"
+#undef PREFIX_UNION
+;
+static constexpr const ArrayRef
+PrefixTable(PrefixTable_init, std::size(PrefixTable_init) - 1);
+
 enum OptionFlags {
   OptFlag1 = (1 << 4),
   OptFlag2 = (1 << 5),
@@ -48,10 +56,16 @@
 };
 
 namespace {
-class TestOptTable : public OptTable {
+class TestOptTable : public GenericOptTable {
 public:
   TestOptTable(bool IgnoreCase = false)
-: OptTable(InfoTable, IgnoreCase) {}
+  : GenericOptTable(InfoTable, IgnoreCase) {}
+};
+
+class TestPrecomputedOptTable : public PrecomputedOptTable {
+public:
+  TestPrecomputedOptTable(bool IgnoreCase = false)
+  : PrecomputedOptTable(InfoTable, PrefixTable, IgnoreCase) {}
 };
 }
 
@@ -67,8 +81,20 @@
   "-Gchuu", "2"
   };
 
-TEST(Option, OptionParsing) {
-  TestOptTable T;
+// Test fixture
+template  class OptTableTest : public ::testing::Test {};
+
+template  class DISABLED_OptTableTest : public ::testing::Test {};
+
+// Test both precomputed and computed OptTables with the same suite of tests.
+using OptTableTestTypes =
+::testing::Types;
+
+TYPED_TEST_SUITE(OptTableTest, OptTableTestTypes, );
+TYPED_TEST_SUITE(DISABLED_OptTableTest, OptTableTestTypes, );
+
+TYPED_TEST(OptTableTest, OptionParsing) {
+  TypeParam T;
   unsigned MAI, MAC;
   InputArgList AL = T.ParseArgs(Args, MAI, MAC);
 
@@ -114,8 +140,8 @@
   EXPECT_EQ("desu", StringRef(ASL[1]));
 }
 
-TEST(Option, ParseWithFlagExclusions) {
-  TestOptTable T;
+TYPED_TEST(OptTableTest, P

[Lldb-commits] [PATCH] D139955: [LLDB] Change formatting to use llvm::formatv

2023-01-12 Thread Michael Buch via Phabricator via lldb-commits
Michael137 added a comment.

FYI, this is causing buildbot failures: 
https://green.lab.llvm.org/green/view/LLDB/job/lldb-cmake/49913/execution/node/74/log/

Currently checking what's wrong.

/Users/buildslave/jenkins/workspace/lldb-cmake@2/llvm-project/lldb/test/API/lang/cpp/accelerator-table
 -p TestCPPAccelerator.py
---

Exit Code: -6

Command Output (stdout):


lldb version 16.0.99git (https://github.com/llvm/llvm-project.git revision 
706881825b2470c7176e07355b6ab54d8b4c5f95 
)

  clang revision 706881825b2470c7176e07355b6ab54d8b4c5f95
  llvm revision 706881825b2470c7176e07355b6ab54d8b4c5f95

-

Command Output (stderr):


Assertion failed: (Style.empty() && "Invalid integral format style!"), function 
format, file 
/Users/buildslave/jenkins/workspace/lldb-cmake@2/llvm-project/llvm/include/llvm/Support/FormatProviders.h,
 line 147.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and 
include the crash backtrace.
Stack dump:
0.  HandleCommand(command = "frame variable inner_d")

  frame #39: 0x000195adff34 dyld`start + 2248   




  frame #38: 0x00016050 lldb`main(argc=10, argv=0x00016fdfe8e8) at 
Driver.cpp:820:26   


 
  frame #37: 0x0001558c lldb`Driver::MainLoop(this=0x00016fdfe148) 
at Driver.cpp:577:20
 
  frame #36: 0x00012e38838c 
liblldb.16.0.0git.dylib`lldb::SBDebugger::RunCommandInterpreter(this=0x00016fdfe168,
 options=0x00016fdfde48) at SBDebugger.cpp:1274:14  
  frame #35: 0x00012e8abe54 
liblldb.16.0.0git.dylib`lldb_private::CommandInterpreter::RunCommandInterpreter(this=0x00010410cdb0,
 options=0x60c1d140) at CommandInterpreter.cpp:3364:16
  frame #34: 0x00012e642fbc 
liblldb.16.0.0git.dylib`lldb_private::Debugger::RunIOHandlers(this=0x000104814800)
 at Debugger.cpp:1006:16


  
  frame #33: 0x00012e698ae4 
liblldb.16.0.0git.dylib`lldb_private::IOHandlerEditline::Run(this=0x000100a053d8)
 at IOHandler.cpp:576:22   
  frame #32: 0x00012e8aa708 
liblldb.16.0.0git.dylib`lldb_private::CommandInterpreter::IOHandlerInputComplete(this=0x00010410cdb0,
 io_handler=0x000100a053d8, line="v inner_d") at 
CommandInterpreter.cpp:3110:3
  frame #31: 0x00012e8a5ef0 
liblldb.16.0.0git.dylib`lldb_private::CommandInterpreter::HandleCommand(this=0x00010410cdb0,
 command_line="v inner_d", lazy_add_to_history=eLazyBoolCalculate, 
result=0x00016fdfd8b0) at CommandInterpreter.cpp:2035:14
  frame #30: 0x00012e8d1aec 
liblldb.16.0.0git.dylib`lldb_private::CommandObjectParsed::Execute(this=0x000104833600,
 args_string="inner_d", result=0x00016fdfd8b0) at CommandObject.cpp:747:19
  frame #29: 0x0001325039bc 
liblldb.16.0.0git.dylib`CommandObjectFrameVariable::DoExecute(this=0x000104833600,
 command=0x00016fdfd278, result=0x00016fdfd8b0) at 
CommandObjectFrame.cpp:585:32
  frame #28: 0x00012eab1ff4 
liblldb.16.0.0git.dylib`lldb_private::StackFrame::GetValueForVariableExpressionPath(this=0x000100a06ca8,
 var_expr=(Data = "", Length = 0), use_dynamic=eDynamicDontRunTarget, 
options=49, var_sp=std::__1::shared_ptr::element_type @ 
0x63b28478 strong=5 weak=2, error=0x00016fdfce20) at StackFram
  e.cpp:619:17  


  frame #27: 0x00012eab42b8 
liblldb.16.0.0git.dylib`lldb_private::StackFrame::GetValueObjectForFrameVariable(this=0x000100a06ca8,
 variable_sp=std::__1::shared_ptr::element_type @ 
0x63b28478 strong=5 weak=2, use_dynamic=eDynamicDontRunTarget) at 
StackFrame.cpp:1190:43
  frame #26: 0x00012e76e660 
liblldb.16.0.0git.dylib`lldb_private::ValueObject::GetDynamicValue(this=0x00010189b400,
 use_dynamic=eDynam

[Lldb-commits] [PATCH] D139955: [LLDB] Change formatting to use llvm::formatv

2023-01-12 Thread Michael Buch via Phabricator via lldb-commits
Michael137 added a comment.

Ah I think it's just a lack of curly braces around one of the format specifiers.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139955

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


[Lldb-commits] [lldb] ade3f1c - [lldb] Fix typo in integral format specifier

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

Author: Michael Buch
Date: 2023-01-12T12:09:04Z
New Revision: ade3f1ccd807b00122fdf374ce85987fee60f853

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

LOG: [lldb] Fix typo in integral format specifier

This regressed with `e262b8f48af9fdca8380f2f079e50291956aad71`.

Two issues here:
1. `:16x` is not a valid format specifier and
   we would crash when we encountered this log
   (which was the case in `TestCPPAccelerator.py`)
2. The third argument was missing curly braces so
   the log message itself was malformed.

Added: 


Modified: 
lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp

Removed: 




diff  --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
index 162013f369243..9f042e9893bac 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
@@ -430,7 +430,7 @@ TypeSP DWARFASTParserClang::ParseTypeFromDWARF(const 
SymbolContext &sc,
 log,
 "DWARFASTParserClang::ParseTypeFromDWARF "
 "(die = {0:x16}, decl_ctx = {1:p} (die "
-"{2:16x})) (3:s) name = '{4}')",
+"{2:x16})) {3} name = '{4}')",
 die.GetOffset(), static_cast(context), context_die.GetOffset(),
 die.GetTagAsCString(), die.GetName());
   }



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


[Lldb-commits] [PATCH] D140615: [LLDB][LoongArch] Delete the s9 register alias definition

2023-01-12 Thread WÁNG Xuěruì via Phabricator via lldb-commits
xen0n added a comment.

BTW do we have a way of fixing the bug while preserving the alias?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140615

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


[Lldb-commits] [PATCH] D68655: Trust the arange accelerator tables in dSYMs

2023-01-12 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

In D68655#4045895 , @jasonmolenda 
wrote:

> Both have to be written by the dwarf linker to be correct, but only the 
> former is written ONLY by the dwarf linker.

I don't think that's right:

  $ clang -c -x c - -o - -gdwarf-aranges -g <<<"void f(){}" | llvm-readelf - 
--sections | grep aranges
[ 6] .debug_arangesPROGBITS a0 30 00
  0   0  1
[ 7] .rela.debug_aranges RELA   000380 30 18   
I 20   6  8


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68655

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


[Lldb-commits] [PATCH] D140385: [lldb] Add lldb-server targets to build docs

2023-01-12 Thread David Spickett via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG3fa023970daf: [lldb] Add lldb-server targets to build docs 
(authored by DavidSpickett).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140385

Files:
  lldb/docs/resources/build.rst


Index: lldb/docs/resources/build.rst
===
--- lldb/docs/resources/build.rst
+++ lldb/docs/resources/build.rst
@@ -169,8 +169,15 @@
 subprojects to build in addition to LLVM (for more options see
 :ref:`CommonCMakeOptions` and :ref:`CMakeCaches`). Parts of the LLDB test suite
 require ``lld``. Add it to the list in order to run all tests. Once CMake is 
done,
-run ninja to perform the actual build. We pass ``lldb`` here as the target, so
-it only builds what is necessary to run the lldb driver:
+run ninja to perform the actual build.
+
+::
+
+  $ ninja lldb lldb-server
+
+If you only want lldb, or are on a platform where lldb-server is not supported,
+you can pass just ``lldb``. Ninja will only build what is necessary to run the
+lldb driver:
 
 ::
 
@@ -210,7 +217,10 @@
   $ cmake -B /path/to/lldb-build -G Ninja \
   -DLLVM_DIR=/path/to/llvm-build/lib/cmake/llvm \
   [] /path/to/llvm-project/lldb
-  $ ninja lldb
+  $ ninja lldb lldb-server
+
+If you do not require or cannot build ``lldb-server`` on your platform, simply
+remove it from the Ninja command.
 
 .. note::
 


Index: lldb/docs/resources/build.rst
===
--- lldb/docs/resources/build.rst
+++ lldb/docs/resources/build.rst
@@ -169,8 +169,15 @@
 subprojects to build in addition to LLVM (for more options see
 :ref:`CommonCMakeOptions` and :ref:`CMakeCaches`). Parts of the LLDB test suite
 require ``lld``. Add it to the list in order to run all tests. Once CMake is done,
-run ninja to perform the actual build. We pass ``lldb`` here as the target, so
-it only builds what is necessary to run the lldb driver:
+run ninja to perform the actual build.
+
+::
+
+  $ ninja lldb lldb-server
+
+If you only want lldb, or are on a platform where lldb-server is not supported,
+you can pass just ``lldb``. Ninja will only build what is necessary to run the
+lldb driver:
 
 ::
 
@@ -210,7 +217,10 @@
   $ cmake -B /path/to/lldb-build -G Ninja \
   -DLLVM_DIR=/path/to/llvm-build/lib/cmake/llvm \
   [] /path/to/llvm-project/lldb
-  $ ninja lldb
+  $ ninja lldb lldb-server
+
+If you do not require or cannot build ``lldb-server`` on your platform, simply
+remove it from the Ninja command.
 
 .. note::
 
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] 3fa0239 - [lldb] Add lldb-server targets to build docs

2023-01-12 Thread David Spickett via lldb-commits

Author: David Spickett
Date: 2023-01-12T12:34:58Z
New Revision: 3fa023970dafbbf2aa98ea67123d2e8318dd6916

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

LOG: [lldb] Add lldb-server targets to build docs

The current doc has people just do "ninja lldb" which is
not incorrect, it does build lldb. However it does not build lldb-server.
So you can't just "lldb some-binary" and expect it to work.

I've updated the instructions to reflect that most of the time
you'll want both lldb and lldb-server.

Though there is a use case for building just lldb. I'm assuming
Mac OS (where you have debugserver) and if you only wanted to do
remote debug.

Fixes #59575

Reviewed By: JDevlieghere

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

Added: 


Modified: 
lldb/docs/resources/build.rst

Removed: 




diff  --git a/lldb/docs/resources/build.rst b/lldb/docs/resources/build.rst
index 36b61bcf7899..fdbb4d8a005a 100644
--- a/lldb/docs/resources/build.rst
+++ b/lldb/docs/resources/build.rst
@@ -169,8 +169,15 @@ We used the ``LLVM_ENABLE_PROJECTS`` option here to tell 
the build-system which
 subprojects to build in addition to LLVM (for more options see
 :ref:`CommonCMakeOptions` and :ref:`CMakeCaches`). Parts of the LLDB test suite
 require ``lld``. Add it to the list in order to run all tests. Once CMake is 
done,
-run ninja to perform the actual build. We pass ``lldb`` here as the target, so
-it only builds what is necessary to run the lldb driver:
+run ninja to perform the actual build.
+
+::
+
+  $ ninja lldb lldb-server
+
+If you only want lldb, or are on a platform where lldb-server is not supported,
+you can pass just ``lldb``. Ninja will only build what is necessary to run the
+lldb driver:
 
 ::
 
@@ -210,7 +217,10 @@ build directory for Clang, remember to pass its module 
path via ``Clang_DIR``
   $ cmake -B /path/to/lldb-build -G Ninja \
   -DLLVM_DIR=/path/to/llvm-build/lib/cmake/llvm \
   [] /path/to/llvm-project/lldb
-  $ ninja lldb
+  $ ninja lldb lldb-server
+
+If you do not require or cannot build ``lldb-server`` on your platform, simply
+remove it from the Ninja command.
 
 .. note::
 



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


[Lldb-commits] [PATCH] D141021: [lldb] Remove tools copied into LLDB.framework before install

2023-01-12 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

I don't dispute the value of determinism, but it seems like there ought to be a 
way to achieve this with corrupting the build tree (which in itself is not very 
'deterministic').
What if we had two copies of the framework in the build-tree? One pristine 
copy, which would only contain liblldb (and any stuff that cmake puts there by 
default), and then another one which would be used for running, and which would 
contain all of the manually added stuff (with the right rpaths and all). When 
installing, one would use the pristine copy as the source instead of the 
adulterated one.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141021

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


[Lldb-commits] [PATCH] D140615: [LLDB][LoongArch] Delete the s9 register alias definition

2023-01-12 Thread Hui Li via Phabricator via lldb-commits
lh03061238 added a comment.

In D140615#4047069 , @xen0n wrote:

> BTW do we have a way of fixing the bug while preserving the alias?

The register iscurrently corresponds to only an alias in 
RegisterInfos_loongarch64.h.
So far, no other way has been found, Therefore, We first fixed this bug by 
removing 
the less commonly used name s9


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140615

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


[Lldb-commits] [PATCH] D141330: [lldb] Limit 8b259fe573e1 to dSYMs

2023-01-12 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

Just to clarify: I was responding to the question about the ELF file usage, not 
questioning the overall approach. Given that MachO has a special code for dsym 
files, I think it makes sense to use it.

In D141330#4043807 , @jasonmolenda 
wrote:

>   By scanning the table, a debugger can quickly decide which compilation unit 
> to look in to find the debugging information for an object that has a given 
> address.
>   
>   If the range of addresses covered by the text and/or data of a compilation 
> unit is not contiguous, then there may be multiple address range descriptors 
> for that compilation unit.
>
> (I dislike it when the standard says "there MAY be multiple address range 
> descriptors" -- does this mean if I have a noncontiguous CUs A and B 
> interleaved in the final binary, the debug_aranges can overlap?)

I see what you mean, but I wouldn't really read it that way, and I hope nobody 
produces files like that.

> There's no guarantee for (1) if a debug_aranges table is present, but maybe 
> we can simply assume that any producer producing debug_aranges has done so 
> comprehensively.  I couldn't imagine why it wouldn't be that way.

We can't do that because, as I alluded to in the other comment, the aranges 
section can be produced by the compiler, and there's no guarantee that all CUs 
will be built with the same flags (so some may be missing that section). In the 
elf world a linker will just concatenate those sections without trying to fill 
in the blanks.

A normal binary includes some code from the system runtime (which is built by 
the OS vendor not the user). Typically, that code will not have debug info, but 
sometimes it does, and in that case it's pretty much guaranteed that it will be 
built using different compiler/flags than the user code.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141330

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


[Lldb-commits] [PATCH] D140615: [LLDB][LoongArch] Delete the s9 register alias definition

2023-01-12 Thread Hui Li via Phabricator via lldb-commits
lh03061238 added a comment.

In D140615#4047069 , @xen0n wrote:

> BTW do we have a way of fixing the bug while preserving the alias?

The register information defined in registerinfos_longarch64.h contains only 
one alias.
So far, no other way has been found, Therefore, We first fixed this bug by 
removing the 
less used alias s9


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140615

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


[Lldb-commits] [PATCH] D139250: [lldb] Add ScriptedPlatform python implementation

2023-01-12 Thread Pavel Labath via Phabricator via lldb-commits
labath accepted this revision.
labath added inline comments.
This revision is now accepted and ready to land.



Comment at: lldb/examples/python/scripted_process/scripted_platform.py:31
+def list_processes(self):
+""" Get a list of processes that can be ran on the platform.
+

mib wrote:
> labath wrote:
> > mib wrote:
> > > labath wrote:
> > > > mib wrote:
> > > > > labath wrote:
> > > > > > mib wrote:
> > > > > > > labath wrote:
> > > > > > > > mib wrote:
> > > > > > > > > mib wrote:
> > > > > > > > > > mib wrote:
> > > > > > > > > > > labath wrote:
> > > > > > > > > > > > I am surprised that you want to go down the "run" path 
> > > > > > > > > > > > for this functionality. I think most of the launch 
> > > > > > > > > > > > functionality does not make sense for this use case 
> > > > > > > > > > > > (e.g., you can't provide arguments to these processes, 
> > > > > > > > > > > > when you "run" them, can you?), and it is not 
> > > > > > > > > > > > consistent with what the "process listing" 
> > > > > > > > > > > > functionality does for regular platforms.
> > > > > > > > > > > > 
> > > > > > > > > > > > OTOH, the "attach" flow makes perfect sense here -- you 
> > > > > > > > > > > > take the pid of an existing process, attach to it, and 
> > > > > > > > > > > > stop it at a random point in its execution. You can't 
> > > > > > > > > > > > customize anything about how that process is run 
> > > > > > > > > > > > (because it's already running) -- all you can do is 
> > > > > > > > > > > > choose how you want to select the target process.
> > > > > > > > > > > For now, there is no support for attaching to a scripted 
> > > > > > > > > > > process, because we didn't have any use for it quite yet: 
> > > > > > > > > > > cripted processes were mostly used for doing post-mortem 
> > > > > > > > > > > debugging, so we "ran" them artificially in lldb by 
> > > > > > > > > > > providing some launch options (the name of the class 
> > > > > > > > > > > managing the process and an optional user-provided 
> > > > > > > > > > > dictionary) through the command line or using an 
> > > > > > > > > > > `SBLaunchInfo` object.
> > > > > > > > > > > 
> > > > > > > > > > > I guess I'll need to extend the `platform process 
> > > > > > > > > > > launch/attach` commands and `SBAttachInfo` object to also 
> > > > > > > > > > > support these options since they're required for the 
> > > > > > > > > > > scripted process instantiation.
> > > > > > > > > > > 
> > > > > > > > > > > Note that we aren't really attaching to the real running 
> > > > > > > > > > > process, we're creating a scripted process that knows how 
> > > > > > > > > > > to read memory to mock the real process.
> > > > > > > > > > @labath, I'll do that work on a follow-up patch
> > > > > > > > > @labath here D139945 :) 
> > > > > > > > Thanks. However, are you still planning to use the launch path 
> > > > > > > > for your feature? Because if you're not, then I think this 
> > > > > > > > comment should say "Get a list of processes that **are 
> > > > > > > > running**" (or that **can be attached to**).
> > > > > > > > 
> > > > > > > > And if you are, then I'd like to hear your thoughts on the 
> > > > > > > > discrepancy between what "launching" means for scripted and 
> > > > > > > > non-scripted platforms.
> > > > > > > > 
> > > > > > > The way I see it is that the scripted platform will create a 
> > > > > > > process with the right process plugin. In the case of scripted 
> > > > > > > processes, the `ProcessLaunchInfo` argument should have the 
> > > > > > > script class name set (which automatically sets the process 
> > > > > > > plugin name to "ScriptedProcess" in the launch info). Once the 
> > > > > > > process is instantiated (before the launch), the scripted 
> > > > > > > platform will need to redirect to process stop events through its 
> > > > > > > event multiplexer. So the way I see it essentially, running a 
> > > > > > > regular process with the scripted platform should be totally 
> > > > > > > transparent.
> > > > > > > 
> > > > > > > Something that is also worth discussing IMO, is the discrepancy 
> > > > > > > between launching and attaching from the scripted platform:
> > > > > > > 
> > > > > > > One possibility could be that `platform process launch` would 
> > > > > > > launch all the scripted processes listed by the scripted platform 
> > > > > > > and set them up with the multiplexer, whereas `platform process 
> > > > > > > attach` would just create a scripted process individually. I know 
> > > > > > > this doesn't match the current behavior of the platform commands 
> > > > > > > so if you guys think we should preserve the expected behavior, I 
> > > > > > > guess.
> > > > > > > 
> > > > > > > May be @jingham has some opinion about this ?
> > > > > > Before we do that, maybe we could take a step back. Could you 
> > > > > > explain why you chose to use the "launch" flow for this use case?

[Lldb-commits] [PATCH] D141605: [lldb] Detach the child process when stepping over a fork

2023-01-12 Thread Pavel Labath via Phabricator via lldb-commits
labath created this revision.
labath added reviewers: jingham, mgorny.
Herald added a project: All.
labath requested review of this revision.
Herald added a project: LLDB.

Step over thread plans were claiming to explain the fork stop reasons,
which prevented the default fork logic (detaching from the child
process) from kicking in. This patch changes that.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D141605

Files:
  lldb/source/Target/ThreadPlan.cpp
  lldb/test/API/functionalities/fork/resumes-child/Makefile
  lldb/test/API/functionalities/fork/resumes-child/TestForkResumesChild.py
  lldb/test/API/functionalities/fork/resumes-child/main.cpp


Index: lldb/test/API/functionalities/fork/resumes-child/main.cpp
===
--- /dev/null
+++ lldb/test/API/functionalities/fork/resumes-child/main.cpp
@@ -0,0 +1,29 @@
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+int main() {
+  pid_t fork_result = fork(); // break here
+  assert(fork_result >= 0);
+  if (fork_result == 0) {
+// child
+_exit(47);
+  }
+  // parent
+  // Use polling to avoid blocking if the child is not actually resumed.
+  auto deadline = std::chrono::steady_clock::now() + std::chrono::seconds(10);
+  std::chrono::milliseconds poll_interval{10};
+  while (std::chrono::steady_clock::now() < deadline) {
+int status;
+pid_t waitpid_result = waitpid(fork_result, &status, WNOHANG);
+if (waitpid_result == fork_result)
+  return 0;
+assert(waitpid_result == 0);
+std::this_thread::sleep_for(poll_interval);
+poll_interval *= 2;
+  }
+  abort();
+}
Index: lldb/test/API/functionalities/fork/resumes-child/TestForkResumesChild.py
===
--- /dev/null
+++ lldb/test/API/functionalities/fork/resumes-child/TestForkResumesChild.py
@@ -0,0 +1,22 @@
+"""
+Make sure that the fork child keeps running.
+"""
+
+
+
+import lldb
+import lldbsuite.test.lldbutil as lldbutil
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test.decorators import *
+
+
+class TestForkResumesChild(TestBase):
+
+NO_DEBUG_INFO_TESTCASE = True
+
+@skipIfWindows
+def test_step_over_fork(self):
+self.build()
+lldbutil.run_to_source_breakpoint(self, "// break here", 
lldb.SBFileSpec("main.cpp"))
+self.runCmd("next")
+self.expect("continue", substrs = ["exited with status = 0"])
Index: lldb/test/API/functionalities/fork/resumes-child/Makefile
===
--- /dev/null
+++ lldb/test/API/functionalities/fork/resumes-child/Makefile
@@ -0,0 +1,3 @@
+CXX_SOURCES := main.cpp
+
+include Makefile.rules
Index: lldb/source/Target/ThreadPlan.cpp
===
--- lldb/source/Target/ThreadPlan.cpp
+++ lldb/source/Target/ThreadPlan.cpp
@@ -171,6 +171,9 @@
   case eStopReasonExec:
   case eStopReasonThreadExiting:
   case eStopReasonInstrumentation:
+  case eStopReasonFork:
+  case eStopReasonVFork:
+  case eStopReasonVForkDone:
 return true;
   default:
 return false;


Index: lldb/test/API/functionalities/fork/resumes-child/main.cpp
===
--- /dev/null
+++ lldb/test/API/functionalities/fork/resumes-child/main.cpp
@@ -0,0 +1,29 @@
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+int main() {
+  pid_t fork_result = fork(); // break here
+  assert(fork_result >= 0);
+  if (fork_result == 0) {
+// child
+_exit(47);
+  }
+  // parent
+  // Use polling to avoid blocking if the child is not actually resumed.
+  auto deadline = std::chrono::steady_clock::now() + std::chrono::seconds(10);
+  std::chrono::milliseconds poll_interval{10};
+  while (std::chrono::steady_clock::now() < deadline) {
+int status;
+pid_t waitpid_result = waitpid(fork_result, &status, WNOHANG);
+if (waitpid_result == fork_result)
+  return 0;
+assert(waitpid_result == 0);
+std::this_thread::sleep_for(poll_interval);
+poll_interval *= 2;
+  }
+  abort();
+}
Index: lldb/test/API/functionalities/fork/resumes-child/TestForkResumesChild.py
===
--- /dev/null
+++ lldb/test/API/functionalities/fork/resumes-child/TestForkResumesChild.py
@@ -0,0 +1,22 @@
+"""
+Make sure that the fork child keeps running.
+"""
+
+
+
+import lldb
+import lldbsuite.test.lldbutil as lldbutil
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test.decorators import *
+
+
+class TestForkResumesChild(TestBase):
+
+NO_DEBUG_INFO_TESTCASE = True
+
+@skipIfWindows
+def test_step_over_fork(self):
+self.build()
+lldbutil.run_to_source_breakpoint(self, "// break here", lldb.SBFileSpec("main.cpp"))
+self.runCmd("next")
+self.expect("continue", substrs = ["exited with status = 0"])
Index: lldb/test/API/fu

[Lldb-commits] [PATCH] D141605: [lldb] Detach the child process when stepping over a fork

2023-01-12 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

(The fix seems to make LLDB do the right thing, although I can't claim to fully 
understand what is going on. From what I can tell, we're currently detaching 
from the fork child when the fork event gets pulled off the public event queue, 
and this code is preventing that from happening. Intuitively it seems like the 
public event queue pull is slightly too late to be doing this kind of thing.)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141605

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


[Lldb-commits] [PATCH] D139955: [LLDB] Change formatting to use llvm::formatv

2023-01-12 Thread Alexander Yermolovich via Phabricator via lldb-commits
ayermolo added a comment.

In D139955#4047011 , @Michael137 
wrote:

> Ah it's just a typoed format (and lack of curly braces around one of the 
> format specifiers)
>
> Fixed in https://reviews.llvm.org/rGade3f1ccd807

Thanks, for a fix. Sorry missed it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139955

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


[Lldb-commits] [PATCH] D136565: [clang] Instantiate alias templates with sugar

2023-01-12 Thread Erich Keane via Phabricator via lldb-commits
erichkeane added a comment.

In D136565#4032150 , @erichkeane 
wrote:

> Note that the Clang 16 branch is coming up approximately on January 24, and 
> this needs to be reverted or perf-regression fixed by then.  @mizvekov : If 
> you or someone else don't have a solution/revert to this by January 13th, 
> @aaron.ballman and I will begin the process to revert this ourselves.

I see that this was already reverted in 
a5c18fcf6e7ffeea72aaf079477caf2ac1d641bc 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136565

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


[Lldb-commits] [PATCH] D131858: [clang] Track the templated entity in type substitution.

2023-01-12 Thread Erich Keane via Phabricator via lldb-commits
erichkeane added a comment.

@mizvekov : I'm looking at the revert of this since no work seems to have been 
done to fix @steven_wu 's problem.  Unfortunately, it seems that reverting this 
requires reverting https://reviews.llvm.org/D134604 plus all of the 
"Instantiate" patches, which undoes basically all of your work.

I'm starting it now, but its unfortunate that we are going to lose this much of 
your work.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131858

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


[Lldb-commits] [PATCH] D131858: [clang] Track the templated entity in type substitution.

2023-01-12 Thread Vassil Vassilev via Phabricator via lldb-commits
v.g.vassilev added a comment.

In D131858#4047785 , @erichkeane 
wrote:

> @mizvekov : I'm looking at the revert of this since no work seems to have 
> been done to fix @steven_wu 's problem.  Unfortunately, it seems that 
> reverting this requires reverting https://reviews.llvm.org/D134604 plus all 
> of the "Instantiate" patches, which undoes basically all of your work.
>
> I'm starting it now, but its unfortunate that we are going to lose this much 
> of your work.

That is *really* unfortunate. @mizvekov (@erichkeane) is there any other way 
out here?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131858

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


[Lldb-commits] [PATCH] D131858: [clang] Track the templated entity in type substitution.

2023-01-12 Thread Erich Keane via Phabricator via lldb-commits
erichkeane added a comment.

In D131858#4047799 , @v.g.vassilev 
wrote:

> In D131858#4047785 , @erichkeane 
> wrote:
>
>> @mizvekov : I'm looking at the revert of this since no work seems to have 
>> been done to fix @steven_wu 's problem.  Unfortunately, it seems that 
>> reverting this requires reverting https://reviews.llvm.org/D134604 plus all 
>> of the "Instantiate" patches, which undoes basically all of your work.
>>
>> I'm starting it now, but its unfortunate that we are going to lose this much 
>> of your work.
>
> That is *really* unfortunate. @mizvekov (@erichkeane) is there any other way 
> out here?

@mizvekov said he was working on fixing the issue, and we gave him a deadline 
of Tomorrow for it.  If he (or someone else) manages to fix the problem by 
Tuesday early AM PT, I won't have to do that.  BUT we cannot release with this 
regression.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131858

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


[Lldb-commits] [PATCH] D68655: Trust the arange accelerator tables in dSYMs

2023-01-12 Thread Jason Molenda via Phabricator via lldb-commits
jasonmolenda added a comment.

In D68655#4047126 , @labath wrote:

> In D68655#4045895 , @jasonmolenda 
> wrote:
>
>> Both have to be written by the dwarf linker to be correct, but only the 
>> former is written ONLY by the dwarf linker.
>
> I don't think that's right:
>
>   $ clang -c -x c - -o - -gdwarf-aranges -g <<<"void f(){}" | llvm-readelf - 
> --sections | grep aranges
> [ 6] .debug_arangesPROGBITS a0 30 00  
> 0   0  1
> [ 7] .rela.debug_aranges RELA   000380 30 18  
>  I 20   6  8

Ah thanks Pavel, clang on Darwin doesn't emit this in .o files.  So in this 
case, the .o file has a DW_TAG_compile_unit with a DW_AT_ranges and a 
.debug_aranges, both generated pre-link-time by the compiler.  And Greg is 
saying that the DW_AT_ranges list in the final executable will be better than 
the .debug_aranges?  I don't know how strongly he asserts this - today if a 
.debug_aranges has an entry, we don't look at DW_TAG_compile_unit's 
DW_AT_ranges, or create the ranges ourself via the line table; the 
debug_aranges is trusted above the other methods if it includes CU.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68655

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


[Lldb-commits] [lldb] ba35c27 - [lldb] Limit `nothreadallow` to Python in SWIG bindings

2023-01-12 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2023-01-12T10:19:30-08:00
New Revision: ba35c27ec9aa9807f5b4be2a0c33ca9b045accc7

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

LOG: [lldb] Limit `nothreadallow` to Python in SWIG bindings

SWIG allows you to partially disable thread support for a given function
in Python with `nothreadallow`. This functionality is limited to Python,
but until SWIG 4.1, it would silently ignore this for other languages,
such as Lua. New versions of SWIG are more strict and therefore we need
to guard this with `SWIGPYTHON`.

For more details on the functionality, I recommend reading the commit
message from 070a1d562b30.

Added: 


Modified: 
lldb/bindings/interface/SBValueList.i

Removed: 




diff  --git a/lldb/bindings/interface/SBValueList.i 
b/lldb/bindings/interface/SBValueList.i
index 32543af17413b..e03b5c649db99 100644
--- a/lldb/bindings/interface/SBValueList.i
+++ b/lldb/bindings/interface/SBValueList.i
@@ -105,7 +105,9 @@ public:
 lldb::SBError GetError();
 
 %extend {
+#ifdef SWIGPYTHON
%nothreadallow;
+#endif
std::string lldb::SBValueList::__str__ (){
lldb::SBStream description;
const size_t n = $self->GetSize();
@@ -124,7 +126,9 @@ public:
--desc_len;
return std::string(desc, desc_len);
}
+#ifdef SWIGPYTHON
%clearnothreadallow;
+#endif
 }
 
 #ifdef SWIGPYTHON



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


[Lldb-commits] [lldb] 9ec1159 - [lldb] Fix compile error in Lua typemap

2023-01-12 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2023-01-12T10:51:26-08:00
New Revision: 9ec115978ea2bdfc60800cd3c21264341cdc8b0a

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

LOG: [lldb] Fix compile error in Lua typemap

Fix error "non-const lvalue reference to type 'lldb::FileSP'  cannot
bind to a value of unrelated type" in Lua typemap.

Added: 


Modified: 
lldb/bindings/lua/lua-typemaps.swig

Removed: 




diff  --git a/lldb/bindings/lua/lua-typemaps.swig 
b/lldb/bindings/lua/lua-typemaps.swig
index 15a18deaa3a4a..56756936a532c 100644
--- a/lldb/bindings/lua/lua-typemaps.swig
+++ b/lldb/bindings/lua/lua-typemaps.swig
@@ -247,7 +247,7 @@ LLDB_NUMBER_TYPEMAP(enum SWIGTYPE);
 // Typemap for file handles (e.g. used in SBDebugger::GetOutputFileHandle)
 
 %typemap(out) lldb::FileSP {
-  lldb::FileSP &sp = $1;
+  lldb::FileSP sp = $1;
   if (sp && sp->IsValid()) {
 luaL_Stream *p = (luaL_Stream *)lua_newuserdata(L, sizeof(luaL_Stream));
 p->closef = &LLDBSwigLuaCloseFileHandle;



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


[Lldb-commits] [PATCH] D141624: [fix] Change formatting to use llvm::formatv Summary:

2023-01-12 Thread Alexander Yermolovich via Phabricator via lldb-commits
ayermolo created this revision.
Herald added a reviewer: shafik.
Herald added subscribers: hoy, modimo, wenlei.
Herald added a project: All.
ayermolo requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

Missed one formating that was reversed.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D141624

Files:
  lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp


Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
@@ -677,7 +677,7 @@
   if (log)
 dwarf->GetObjectFile()->GetModule()->LogMessage(
 log,
-"SymbolFileDWARF::ParseType (die = {0:16x}) {1} '{2}' "
+"SymbolFileDWARF::ParseType (die = {0:x16}) {1} '{2}' "
 "is Objective-C 'id' built-in type.",
 die.GetOffset(), die.GetTagAsCString(), die.GetName());
   clang_type = m_ast.GetBasicType(eBasicTypeObjCID);


Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
@@ -677,7 +677,7 @@
   if (log)
 dwarf->GetObjectFile()->GetModule()->LogMessage(
 log,
-"SymbolFileDWARF::ParseType (die = {0:16x}) {1} '{2}' "
+"SymbolFileDWARF::ParseType (die = {0:x16}) {1} '{2}' "
 "is Objective-C 'id' built-in type.",
 die.GetOffset(), die.GetTagAsCString(), die.GetName());
   clang_type = m_ast.GetBasicType(eBasicTypeObjCID);
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D139955: [LLDB] Change formatting to use llvm::formatv

2023-01-12 Thread Alexander Yermolovich via Phabricator via lldb-commits
ayermolo added a comment.

Found another instance: https://reviews.llvm.org/D141624


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139955

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


[Lldb-commits] [lldb] 4e7da80 - [fix] Change formatting to use llvm::formatv Summary:

2023-01-12 Thread Alexander Yermolovich via lldb-commits

Author: Alexander Yermolovich
Date: 2023-01-12T11:18:29-08:00
New Revision: 4e7da8000e2771907609c3fe149dd4b96cfe0b08

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

LOG: [fix] Change formatting to use llvm::formatv Summary:

Missed one formating that was reversed.

Reviewed By: hoy, zhuhan0

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

Added: 


Modified: 
lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp

Removed: 




diff  --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
index 9f042e9893bac..b50c974f9b89f 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
@@ -677,7 +677,7 @@ DWARFASTParserClang::ParseTypeModifier(const SymbolContext 
&sc,
   if (log)
 dwarf->GetObjectFile()->GetModule()->LogMessage(
 log,
-"SymbolFileDWARF::ParseType (die = {0:16x}) {1} '{2}' "
+"SymbolFileDWARF::ParseType (die = {0:x16}) {1} '{2}' "
 "is Objective-C 'id' built-in type.",
 die.GetOffset(), die.GetTagAsCString(), die.GetName());
   clang_type = m_ast.GetBasicType(eBasicTypeObjCID);



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


[Lldb-commits] [PATCH] D141624: [fix] Change formatting to use llvm::formatv Summary:

2023-01-12 Thread Alexander Yermolovich via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG4e7da8000e27: [fix] Change formatting to use llvm::formatv 
Summary: (authored by ayermolo).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141624

Files:
  lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp


Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
@@ -677,7 +677,7 @@
   if (log)
 dwarf->GetObjectFile()->GetModule()->LogMessage(
 log,
-"SymbolFileDWARF::ParseType (die = {0:16x}) {1} '{2}' "
+"SymbolFileDWARF::ParseType (die = {0:x16}) {1} '{2}' "
 "is Objective-C 'id' built-in type.",
 die.GetOffset(), die.GetTagAsCString(), die.GetName());
   clang_type = m_ast.GetBasicType(eBasicTypeObjCID);


Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
@@ -677,7 +677,7 @@
   if (log)
 dwarf->GetObjectFile()->GetModule()->LogMessage(
 log,
-"SymbolFileDWARF::ParseType (die = {0:16x}) {1} '{2}' "
+"SymbolFileDWARF::ParseType (die = {0:x16}) {1} '{2}' "
 "is Objective-C 'id' built-in type.",
 die.GetOffset(), die.GetTagAsCString(), die.GetName());
   clang_type = m_ast.GetBasicType(eBasicTypeObjCID);
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D68655: Trust the arange accelerator tables in dSYMs

2023-01-12 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

In D68655#4048009 , @jasonmolenda 
wrote:

> In D68655#4047126 , @labath wrote:
>
>> In D68655#4045895 , @jasonmolenda 
>> wrote:
>>
>>> Both have to be written by the dwarf linker to be correct, but only the 
>>> former is written ONLY by the dwarf linker.
>>
>> I don't think that's right:
>>
>>   $ clang -c -x c - -o - -gdwarf-aranges -g <<<"void f(){}" | llvm-readelf - 
>> --sections | grep aranges
>> [ 6] .debug_arangesPROGBITS a0 30 00 
>>  0   0  1
>> [ 7] .rela.debug_aranges RELA   000380 30 18 
>>   I 20   6  8
>
> Ah thanks Pavel, clang on Darwin doesn't emit this in .o files.

It does. It just doesn't do it by default -- same as on linux (but not on PS4 I 
believe). You have to use the -gdwarf-aranges flag explicitly (which, quite 
possibly, noone does),

> So in this case, the .o file has a DW_TAG_compile_unit with a DW_AT_ranges 
> and a .debug_aranges, both generated pre-link-time by the compiler.

Yes.

> And Greg is saying that the DW_AT_ranges list in the final executable will be 
> better than the .debug_aranges?  I don't know how strongly he asserts this - 
> today if a .debug_aranges has an entry, we don't look at 
> DW_TAG_compile_unit's DW_AT_ranges, or create the ranges ourself via the line 
> table; the debug_aranges is trusted above the other methods if it includes CU.

That I don't know. Personally, I would expect the two to be equivalent, except 
that the debug_aranges could theoretically be faster to parse (and takes up 
more space).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68655

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


[Lldb-commits] [PATCH] D141626: [lldb-vscode] Include the return value in 'local' variables

2023-01-12 Thread Ivan Hernandez via Phabricator via lldb-commits
ivanhernandez13 created this revision.
Herald added a project: All.
ivanhernandez13 requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

This provides a convenient way for the user to easily inspect a functions 
return value after
stepping out of a function.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D141626

Files:
  lldb/test/API/tools/lldb-vscode/variables/TestVSCode_variables.py
  lldb/tools/lldb-vscode/JSONUtils.cpp
  lldb/tools/lldb-vscode/JSONUtils.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
@@ -2960,6 +2960,19 @@
 reg.SetFormat(lldb::eFormatAddressInfo);
 }
   }
+} else if (variablesReference == VARREF_LOCALS) {
+  auto return_value =
+  g_vsc.target.GetProcess().GetSelectedThread().GetStopReturnValue();
+  if (return_value.IsValid()) {
+int64_t var_ref = 0;
+if (return_value.MightHaveChildren()) {
+  var_ref = g_vsc.variables.InsertExpandableVariable(
+  return_value, /*is_permanent=*/false);
+}
+variables.emplace_back(CreateVariable(
+return_value, var_ref, var_ref != 0 ? var_ref : UINT64_MAX, hex,
+/*is_name_duplicated=*/false, "Return value"));
+  }
 }
 
 num_children = top_scope->GetSize();
Index: lldb/tools/lldb-vscode/JSONUtils.h
===
--- lldb/tools/lldb-vscode/JSONUtils.h
+++ lldb/tools/lldb-vscode/JSONUtils.h
@@ -457,12 +457,17 @@
 /// As VSCode doesn't render two of more variables with the same name, we
 /// apply a suffix to distinguish duplicated variables.
 ///
+/// \param[in] name_override
+/// A name to give the variable when a predetermined name is known.
+/// Otherwise, the name is derived from the variable.
+///
 /// \return
 /// A "Variable" JSON object with that follows the formal JSON
 /// definition outlined by Microsoft.
 llvm::json::Value CreateVariable(lldb::SBValue v, int64_t variablesReference,
  int64_t varID, bool format_hex,
- bool is_name_duplicated = false);
+ bool is_name_duplicated = false,
+ const char *name_override = nullptr);
 
 llvm::json::Value CreateCompileUnit(lldb::SBCompileUnit unit);
 
Index: lldb/tools/lldb-vscode/JSONUtils.cpp
===
--- lldb/tools/lldb-vscode/JSONUtils.cpp
+++ lldb/tools/lldb-vscode/JSONUtils.cpp
@@ -1034,10 +1034,13 @@
 // }
 llvm::json::Value CreateVariable(lldb::SBValue v, int64_t variablesReference,
  int64_t varID, bool format_hex,
- bool is_name_duplicated) {
+ bool is_name_duplicated,
+ const char *name_override) {
   llvm::json::Object object;
-  EmplaceSafeString(object, "name",
-CreateUniqueVariableNameForDisplay(v, is_name_duplicated));
+  auto name = name_override
+  ? name_override
+  : CreateUniqueVariableNameForDisplay(v, is_name_duplicated);
+  EmplaceSafeString(object, "name", name);
 
   if (format_hex)
 v.SetFormat(lldb::eFormatHex);
Index: lldb/test/API/tools/lldb-vscode/variables/TestVSCode_variables.py
===
--- lldb/test/API/tools/lldb-vscode/variables/TestVSCode_variables.py
+++ lldb/test/API/tools/lldb-vscode/variables/TestVSCode_variables.py
@@ -576,3 +576,39 @@
 '''
 initCommands = ['settings set symbols.load-on-demand true']
 self.darwin_dwarf_missing_obj(initCommands)
+
+
+@skipIfWindows
+@skipIfRemote
+def test_return_value(self):
+'''
+Test that local variables include a an entry for the return value
+when stepping out of a function with a return value.
+'''
+program = self.getBuildArtifact("a.out")
+self.build_and_launch(program)
+source = "main.cpp"
+breakpoint4_line = line_number(source, "// breakpoint 4")
+lines = [breakpoint4_line]
+breakpoint_ids = self.set_source_breakpoints(source, lines)
+self.assertEqual(
+len(breakpoint_ids), len(lines), "expect correct number of breakpoints"
+)
+self.continue_to_breakpoints(breakpoint_ids)
+tid = self.vscode.get_thread_id()
+
+# We haven't stepped out of a function with a return value so there
+# should be no variable named 'Return value'.
+locals = self.vscode.get_local_variables()
+names = [var['name'] for var in locals]
+self.assertNotIn('

[Lldb-commits] [lldb] d9f4d1b - [lldb/Interpreter] Make ScriptedProcessInfo more generic

2023-01-12 Thread Med Ismail Bennani via lldb-commits

Author: Med Ismail Bennani
Date: 2023-01-12T12:49:05-08:00
New Revision: d9f4d1b048520c50ca06e24b7886d77d3bb2fc29

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

LOG: [lldb/Interpreter] Make ScriptedProcessInfo more generic

This patch moves the ScriptedProcessInfo class out of the
ScriptedProcess and hoist it as a standalone interpreter class, so it can be
reused with the Scripted Platform.

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

Signed-off-by: Med Ismail Bennani 

Added: 
lldb/include/lldb/Interpreter/ScriptedMetadata.h

Modified: 
lldb/source/Plugins/Process/scripted/ScriptedProcess.cpp
lldb/source/Plugins/Process/scripted/ScriptedProcess.h
lldb/source/Plugins/Process/scripted/ScriptedThread.cpp

Removed: 




diff  --git a/lldb/include/lldb/Interpreter/ScriptedMetadata.h 
b/lldb/include/lldb/Interpreter/ScriptedMetadata.h
new file mode 100644
index 0..00ebce323bf88
--- /dev/null
+++ b/lldb/include/lldb/Interpreter/ScriptedMetadata.h
@@ -0,0 +1,45 @@
+//===-- ScriptedMetadata.h  -*- C++ 
-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef LLDB_INTERPRETER_SCRIPTEDMETADATA_H
+#define LLDB_INTERPRETER_SCRIPTEDMETADATA_H
+
+#include "OptionGroupPythonClassWithDict.h"
+
+#include "lldb/Host/Host.h"
+#include "lldb/Host/ProcessLaunchInfo.h"
+#include "lldb/Utility/StructuredData.h"
+
+namespace lldb_private {
+class ScriptedMetadata {
+public:
+  ScriptedMetadata(llvm::StringRef class_name,
+   StructuredData::DictionarySP dict_sp)
+  : m_class_name(class_name.data()), m_args_sp(dict_sp) {}
+
+  ScriptedMetadata(const ProcessLaunchInfo &launch_info) {
+m_class_name = launch_info.GetScriptedProcessClassName();
+m_args_sp = launch_info.GetScriptedProcessDictionarySP();
+  }
+
+  ScriptedMetadata(const OptionGroupPythonClassWithDict &option_group) {
+auto opt_group = const_cast(option_group);
+m_class_name = opt_group.GetName();
+m_args_sp = opt_group.GetStructuredData();
+  }
+
+  llvm::StringRef GetClassName() const { return m_class_name; }
+  StructuredData::DictionarySP GetArgsSP() const { return m_args_sp; }
+
+private:
+  std::string m_class_name;
+  StructuredData::DictionarySP m_args_sp;
+};
+} // namespace lldb_private
+
+#endif // LLDB_INTERPRETER_SCRIPTEDMETADATA_H

diff  --git a/lldb/source/Plugins/Process/scripted/ScriptedProcess.cpp 
b/lldb/source/Plugins/Process/scripted/ScriptedProcess.cpp
index 855a67aae1b5f..576e620220984 100644
--- a/lldb/source/Plugins/Process/scripted/ScriptedProcess.cpp
+++ b/lldb/source/Plugins/Process/scripted/ScriptedProcess.cpp
@@ -18,6 +18,7 @@
 #include "lldb/Interpreter/OptionArgParser.h"
 #include "lldb/Interpreter/OptionGroupBoolean.h"
 #include "lldb/Interpreter/ScriptInterpreter.h"
+#include "lldb/Interpreter/ScriptedMetadata.h"
 #include "lldb/Target/MemoryRegionInfo.h"
 #include "lldb/Target/RegisterContext.h"
 #include "lldb/Utility/LLDBLog.h"
@@ -58,12 +59,11 @@ lldb::ProcessSP 
ScriptedProcess::CreateInstance(lldb::TargetSP target_sp,
   !IsScriptLanguageSupported(target_sp->GetDebugger().GetScriptLanguage()))
 return nullptr;
 
-  Status error;
-  ScriptedProcess::ScriptedProcessInfo scripted_process_info(
-  target_sp->GetProcessLaunchInfo());
+  ScriptedMetadata scripted_metadata(target_sp->GetProcessLaunchInfo());
 
-  auto process_sp = std::shared_ptr(new ScriptedProcess(
-  target_sp, listener_sp, scripted_process_info, error));
+  Status error;
+  auto process_sp = std::shared_ptr(
+  new ScriptedProcess(target_sp, listener_sp, scripted_metadata, error));
 
   if (error.Fail() || !process_sp || !process_sp->m_script_object_sp ||
   !process_sp->m_script_object_sp->IsValid()) {
@@ -79,12 +79,11 @@ bool ScriptedProcess::CanDebug(lldb::TargetSP target_sp,
   return true;
 }
 
-ScriptedProcess::ScriptedProcess(
-lldb::TargetSP target_sp, lldb::ListenerSP listener_sp,
-const ScriptedProcess::ScriptedProcessInfo &scripted_process_info,
-Status &error)
-: Process(target_sp, listener_sp),
-  m_scripted_process_info(scripted_process_info) {
+ScriptedProcess::ScriptedProcess(lldb::TargetSP target_sp,
+ lldb::ListenerSP listener_sp,
+ const ScriptedMetadata &scripted_metadata,
+ Status &error)
+: Process(target_sp, listener_sp), m_scripted_metadata(scripted_metadata) {
 
   if (!target_sp) {
 error.SetErrorStringWit

[Lldb-commits] [lldb] 3fbc890 - [lldb/Interpreter] Improve ScriptedPythonInterface::GetStatusFromMethod

2023-01-12 Thread Med Ismail Bennani via lldb-commits

Author: Med Ismail Bennani
Date: 2023-01-12T12:49:05-08:00
New Revision: 3fbc89048517e7152cce763db3b1e5738d558113

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

LOG: [lldb/Interpreter] Improve ScriptedPythonInterface::GetStatusFromMethod

This patch makes `ScriptedPythonInterface::GetStatusFromMethod` take a
parameter pack as an argument. That will allow it to pass arbitrary
arguments to the python method.

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

Signed-off-by: Med Ismail Bennani 

Added: 


Modified: 
lldb/source/Plugins/ScriptInterpreter/Python/ScriptedPythonInterface.cpp
lldb/source/Plugins/ScriptInterpreter/Python/ScriptedPythonInterface.h

Removed: 




diff  --git 
a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedPythonInterface.cpp 
b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedPythonInterface.cpp
index 10c22df5475d4..789b39abf5878 100644
--- a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedPythonInterface.cpp
+++ b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedPythonInterface.cpp
@@ -27,14 +27,6 @@ ScriptedPythonInterface::ScriptedPythonInterface(
 ScriptInterpreterPythonImpl &interpreter)
 : ScriptedInterface(), m_interpreter(interpreter) {}
 
-Status
-ScriptedPythonInterface::GetStatusFromMethod(llvm::StringRef method_name) {
-  Status error;
-  Dispatch(method_name, error);
-
-  return error;
-}
-
 template <>
 StructuredData::ArraySP
 ScriptedPythonInterface::ExtractValueFromPythonObject(

diff  --git 
a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedPythonInterface.h 
b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedPythonInterface.h
index cc936e09a6ef2..01dc07b497376 100644
--- a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedPythonInterface.h
+++ b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedPythonInterface.h
@@ -100,7 +100,13 @@ class ScriptedPythonInterface : virtual public 
ScriptedInterface {
 return ExtractValueFromPythonObject(py_return, error);
   }
 
-  Status GetStatusFromMethod(llvm::StringRef method_name);
+  template 
+  Status GetStatusFromMethod(llvm::StringRef method_name, Args &&...args) {
+Status error;
+Dispatch(method_name, error, std::forward(args)...);
+
+return error;
+  }
 
   template  T Transform(T object) {
 // No Transformation for generic usage



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


[Lldb-commits] [PATCH] D139247: [lldb/Interpreter] Make ScriptedProcessInfo more generic

2023-01-12 Thread Med Ismail Bennani via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGd9f4d1b04852: [lldb/Interpreter] Make ScriptedProcessInfo 
more generic (authored by mib).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139247

Files:
  lldb/include/lldb/Interpreter/ScriptedMetadata.h
  lldb/source/Plugins/Process/scripted/ScriptedProcess.cpp
  lldb/source/Plugins/Process/scripted/ScriptedProcess.h
  lldb/source/Plugins/Process/scripted/ScriptedThread.cpp

Index: lldb/source/Plugins/Process/scripted/ScriptedThread.cpp
===
--- lldb/source/Plugins/Process/scripted/ScriptedThread.cpp
+++ lldb/source/Plugins/Process/scripted/ScriptedThread.cpp
@@ -58,8 +58,8 @@
   ExecutionContext exe_ctx(process);
   StructuredData::GenericSP owned_script_object_sp =
   scripted_thread_interface->CreatePluginObject(
-  thread_class_name, exe_ctx,
-  process.m_scripted_process_info.GetArgsSP(), script_object);
+  thread_class_name, exe_ctx, process.m_scripted_metadata.GetArgsSP(),
+  script_object);
 
   if (!owned_script_object_sp)
 return llvm::createStringError(llvm::inconvertibleErrorCode(),
Index: lldb/source/Plugins/Process/scripted/ScriptedProcess.h
===
--- lldb/source/Plugins/Process/scripted/ScriptedProcess.h
+++ lldb/source/Plugins/Process/scripted/ScriptedProcess.h
@@ -9,6 +9,7 @@
 #ifndef LLDB_SOURCE_PLUGINS_SCRIPTED_PROCESS_H
 #define LLDB_SOURCE_PLUGINS_SCRIPTED_PROCESS_H
 
+#include "lldb/Interpreter/ScriptedMetadata.h"
 #include "lldb/Target/Process.h"
 #include "lldb/Utility/ConstString.h"
 #include "lldb/Utility/Status.h"
@@ -18,24 +19,7 @@
 #include 
 
 namespace lldb_private {
-
 class ScriptedProcess : public Process {
-protected:
-  class ScriptedProcessInfo {
-  public:
-ScriptedProcessInfo(const ProcessLaunchInfo &launch_info) {
-  m_class_name = launch_info.GetScriptedProcessClassName();
-  m_args_sp = launch_info.GetScriptedProcessDictionarySP();
-}
-
-std::string GetClassName() const { return m_class_name; }
-StructuredData::DictionarySP GetArgsSP() const { return m_args_sp; }
-
-  private:
-std::string m_class_name;
-StructuredData::DictionarySP m_args_sp;
-  };
-
 public:
   static lldb::ProcessSP CreateInstance(lldb::TargetSP target_sp,
 lldb::ListenerSP listener_sp,
@@ -90,8 +74,7 @@
 
 protected:
   ScriptedProcess(lldb::TargetSP target_sp, lldb::ListenerSP listener_sp,
-  const ScriptedProcess::ScriptedProcessInfo &launch_info,
-  Status &error);
+  const ScriptedMetadata &scripted_metadata, Status &error);
 
   Status DoStop();
 
@@ -111,7 +94,7 @@
   static bool IsScriptLanguageSupported(lldb::ScriptLanguage language);
 
   // Member variables.
-  const ScriptedProcessInfo m_scripted_process_info;
+  const ScriptedMetadata m_scripted_metadata;
   lldb_private::ScriptInterpreter *m_interpreter = nullptr;
   lldb_private::StructuredData::ObjectSP m_script_object_sp = nullptr;
   //@}
Index: lldb/source/Plugins/Process/scripted/ScriptedProcess.cpp
===
--- lldb/source/Plugins/Process/scripted/ScriptedProcess.cpp
+++ lldb/source/Plugins/Process/scripted/ScriptedProcess.cpp
@@ -18,6 +18,7 @@
 #include "lldb/Interpreter/OptionArgParser.h"
 #include "lldb/Interpreter/OptionGroupBoolean.h"
 #include "lldb/Interpreter/ScriptInterpreter.h"
+#include "lldb/Interpreter/ScriptedMetadata.h"
 #include "lldb/Target/MemoryRegionInfo.h"
 #include "lldb/Target/RegisterContext.h"
 #include "lldb/Utility/LLDBLog.h"
@@ -58,12 +59,11 @@
   !IsScriptLanguageSupported(target_sp->GetDebugger().GetScriptLanguage()))
 return nullptr;
 
-  Status error;
-  ScriptedProcess::ScriptedProcessInfo scripted_process_info(
-  target_sp->GetProcessLaunchInfo());
+  ScriptedMetadata scripted_metadata(target_sp->GetProcessLaunchInfo());
 
-  auto process_sp = std::shared_ptr(new ScriptedProcess(
-  target_sp, listener_sp, scripted_process_info, error));
+  Status error;
+  auto process_sp = std::shared_ptr(
+  new ScriptedProcess(target_sp, listener_sp, scripted_metadata, error));
 
   if (error.Fail() || !process_sp || !process_sp->m_script_object_sp ||
   !process_sp->m_script_object_sp->IsValid()) {
@@ -79,12 +79,11 @@
   return true;
 }
 
-ScriptedProcess::ScriptedProcess(
-lldb::TargetSP target_sp, lldb::ListenerSP listener_sp,
-const ScriptedProcess::ScriptedProcessInfo &scripted_process_info,
-Status &error)
-: Process(target_sp, listener_sp),
-  m_scripted_process_info(scripted_process_info) {
+ScriptedProcess::ScriptedProcess(lldb::TargetSP target_sp,
+ lldb::ListenerSP listener_sp,
+ 

[Lldb-commits] [lldb] 2d53527 - [lldb] Add Debugger & ScriptedMetadata reference to Platform::CreateInstance

2023-01-12 Thread Med Ismail Bennani via lldb-commits

Author: Med Ismail Bennani
Date: 2023-01-12T12:49:05-08:00
New Revision: 2d53527e9c64c70c24e1abba74fa0a8c8b3392b1

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

LOG: [lldb] Add Debugger & ScriptedMetadata reference to 
Platform::CreateInstance

This patch is preparatory work for Scripted Platform support and does
multiple things:

First, it introduces new options for the `platform select` command and
`SBPlatform::Create` API, to hold a reference to the debugger object,
the name of the python script managing the Scripted Platform and a
structured data dictionary that the user can use to pass arbitrary data.

Then, it updates the various `Create` and `GetOrCreate` methods for
the `Platform` and `PlatformList` classes to pass down the new parameter
to the `Platform::CreateInstance` callbacks.

Finally, it updates every callback to reflect these changes.

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

Signed-off-by: Med Ismail Bennani 

Added: 


Modified: 
lldb/bindings/interface/SBPlatform.i
lldb/include/lldb/API/SBDebugger.h
lldb/include/lldb/API/SBPlatform.h
lldb/include/lldb/API/SBStructuredData.h
lldb/include/lldb/Interpreter/OptionGroupPlatform.h
lldb/include/lldb/Target/Platform.h
lldb/include/lldb/lldb-private-interfaces.h
lldb/source/API/SBDebugger.cpp
lldb/source/API/SBPlatform.cpp
lldb/source/Commands/CommandObjectPlatform.cpp
lldb/source/Commands/CommandObjectPlatform.h
lldb/source/Core/Debugger.cpp
lldb/source/Interpreter/OptionGroupPlatform.cpp

lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp
lldb/source/Plugins/Platform/Android/PlatformAndroid.cpp
lldb/source/Plugins/Platform/Android/PlatformAndroid.h
lldb/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp
lldb/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.h
lldb/source/Plugins/Platform/Linux/PlatformLinux.cpp
lldb/source/Plugins/Platform/Linux/PlatformLinux.h
lldb/source/Plugins/Platform/MacOSX/PlatformAppleSimulator.cpp
lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.h
lldb/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.cpp
lldb/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.h
lldb/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp
lldb/source/Plugins/Platform/MacOSX/PlatformMacOSX.h
lldb/source/Plugins/Platform/MacOSX/PlatformRemoteAppleBridge.cpp
lldb/source/Plugins/Platform/MacOSX/PlatformRemoteAppleBridge.h
lldb/source/Plugins/Platform/MacOSX/PlatformRemoteAppleTV.cpp
lldb/source/Plugins/Platform/MacOSX/PlatformRemoteAppleTV.h
lldb/source/Plugins/Platform/MacOSX/PlatformRemoteAppleWatch.cpp
lldb/source/Plugins/Platform/MacOSX/PlatformRemoteAppleWatch.h
lldb/source/Plugins/Platform/MacOSX/PlatformRemoteMacOSX.cpp
lldb/source/Plugins/Platform/MacOSX/PlatformRemoteMacOSX.h
lldb/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.cpp
lldb/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.h
lldb/source/Plugins/Platform/NetBSD/PlatformNetBSD.cpp
lldb/source/Plugins/Platform/NetBSD/PlatformNetBSD.h
lldb/source/Plugins/Platform/OpenBSD/PlatformOpenBSD.cpp
lldb/source/Plugins/Platform/OpenBSD/PlatformOpenBSD.h
lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp
lldb/source/Plugins/Platform/QemuUser/PlatformQemuUser.cpp
lldb/source/Plugins/Platform/QemuUser/PlatformQemuUser.h
lldb/source/Plugins/Platform/Windows/PlatformWindows.cpp
lldb/source/Plugins/Platform/Windows/PlatformWindows.h
lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp
lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.h
lldb/source/Target/Platform.cpp
lldb/source/Target/Process.cpp
lldb/source/Target/Target.cpp
lldb/source/Target/TargetList.cpp
lldb/unittests/Core/DiagnosticEventTest.cpp
lldb/unittests/Expression/DWARFExpressionTest.cpp
lldb/unittests/Interpreter/TestCommandPaths.cpp
lldb/unittests/Platform/PlatformAppleSimulatorTest.cpp
lldb/unittests/Platform/PlatformSiginfoTest.cpp
lldb/unittests/Platform/PlatformTest.cpp
lldb/unittests/Process/ProcessEventDataTest.cpp
lldb/unittests/Target/ExecutionContextTest.cpp
lldb/unittests/Target/StackFrameRecognizerTest.cpp
lldb/unittests/Thread/ThreadTest.cpp

Removed: 




diff  --git a/lldb/bindings/interface/SBPlatform.i 
b/lldb/bindings/interface/SBPlatform.i
index 6413784e69e7c..a57deca00e1d8 100644
--- a/lldb/bindings/interface/SBPlatform.i
+++ b/lldb/bindings/interface/SBPlatform.i
@@ -126,6 +126,18 @@ public:
 
 SBPlatform (const char *);
 
+%feature("docstring", "
+Create a platform instance using a specific p

[Lldb-commits] [lldb] b1256f2 - [lldb/Interpreter] Introduce ScriptedPlatform{, Python}Interface

2023-01-12 Thread Med Ismail Bennani via lldb-commits

Author: Med Ismail Bennani
Date: 2023-01-12T12:49:05-08:00
New Revision: b1256f2345f6c48b08cd8691778f39e3e9053f56

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

LOG: [lldb/Interpreter] Introduce ScriptedPlatform{,Python}Interface

This patch introduces both the ScriptedPlatformInterface and the
ScriptedPlatformPythonInterface. As the name suggests, these calls will
be used to call into the Scripted Platform python implementation from
the C++ Scripted Platform plugin instance.

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

Signed-off-by: Med Ismail Bennani 

Added: 
lldb/include/lldb/Interpreter/ScriptedPlatformInterface.h

lldb/source/Plugins/ScriptInterpreter/Python/ScriptedPlatformPythonInterface.cpp

lldb/source/Plugins/ScriptInterpreter/Python/ScriptedPlatformPythonInterface.h

Modified: 
lldb/include/lldb/Interpreter/ScriptInterpreter.h
lldb/include/lldb/lldb-forward.h
lldb/source/Interpreter/ScriptInterpreter.cpp
lldb/source/Plugins/ScriptInterpreter/Python/CMakeLists.txt
lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp

Removed: 




diff  --git a/lldb/include/lldb/Interpreter/ScriptInterpreter.h 
b/lldb/include/lldb/Interpreter/ScriptInterpreter.h
index ec561804c2580..4d073995defb2 100644
--- a/lldb/include/lldb/Interpreter/ScriptInterpreter.h
+++ b/lldb/include/lldb/Interpreter/ScriptInterpreter.h
@@ -18,6 +18,7 @@
 #include "lldb/Core/StreamFile.h"
 #include "lldb/Core/ThreadedCommunication.h"
 #include "lldb/Host/PseudoTerminal.h"
+#include "lldb/Interpreter/ScriptedPlatformInterface.h"
 #include "lldb/Interpreter/ScriptedProcessInterface.h"
 #include "lldb/Utility/Broadcaster.h"
 #include "lldb/Utility/Status.h"
@@ -147,7 +148,9 @@ class ScriptInterpreter : public PluginInterface {
   ScriptInterpreter(
   Debugger &debugger, lldb::ScriptLanguage script_lang,
   lldb::ScriptedProcessInterfaceUP scripted_process_interface_up =
-  std::make_unique());
+  std::make_unique(),
+  lldb::ScriptedPlatformInterfaceUP scripted_platform_interface_up =
+  std::make_unique());
 
   virtual StructuredData::DictionarySP GetInterpreterInfo();
 
@@ -571,6 +574,10 @@ class ScriptInterpreter : public PluginInterface {
 return *m_scripted_process_interface_up;
   }
 
+  ScriptedPlatformInterface &GetScriptedPlatformInterface() {
+return *m_scripted_platform_interface_up;
+  }
+
   lldb::DataExtractorSP
   GetDataExtractorFromSBData(const lldb::SBData &data) const;
 
@@ -583,6 +590,7 @@ class ScriptInterpreter : public PluginInterface {
   Debugger &m_debugger;
   lldb::ScriptLanguage m_script_lang;
   lldb::ScriptedProcessInterfaceUP m_scripted_process_interface_up;
+  lldb::ScriptedPlatformInterfaceUP m_scripted_platform_interface_up;
 };
 
 } // namespace lldb_private

diff  --git a/lldb/include/lldb/Interpreter/ScriptedPlatformInterface.h 
b/lldb/include/lldb/Interpreter/ScriptedPlatformInterface.h
new file mode 100644
index 0..2db1fef0be721
--- /dev/null
+++ b/lldb/include/lldb/Interpreter/ScriptedPlatformInterface.h
@@ -0,0 +1,49 @@
+//===-- ScriptedPlatformInterface.h -*- C++ 
-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef LLDB_INTERPRETER_SCRIPTEDPLATFORMINTERFACE_H
+#define LLDB_INTERPRETER_SCRIPTEDPLATFORMINTERFACE_H
+
+#include "lldb/Core/StructuredDataImpl.h"
+#include "lldb/Interpreter/ScriptedInterface.h"
+
+#include "lldb/lldb-private.h"
+
+#include 
+
+namespace lldb_private {
+class ScriptedPlatformInterface : virtual public ScriptedInterface {
+public:
+  StructuredData::GenericSP
+  CreatePluginObject(llvm::StringRef class_name, ExecutionContext &exe_ctx,
+ StructuredData::DictionarySP args_sp,
+ StructuredData::Generic *script_obj = nullptr) override {
+return {};
+  }
+
+  virtual StructuredData::DictionarySP ListProcesses() { return {}; }
+
+  virtual StructuredData::DictionarySP GetProcessInfo(lldb::pid_t) {
+return {};
+  }
+
+  virtual Status AttachToProcess(lldb::ProcessAttachInfoSP attach_info) {
+return Status("ScriptedPlatformInterface cannot attach to a process");
+  }
+
+  virtual Status LaunchProcess(lldb::ProcessLaunchInfoSP launch_info) {
+return Status("ScriptedPlatformInterface cannot launch process");
+  }
+
+  virtual Status KillProcess(lldb::pid_t pid) {
+return Status("ScriptedPlatformInterface cannot kill process");
+  }
+};
+} // namespace lldb_private
+
+#endif // LLDB_INTERPRETE

[Lldb-commits] [PATCH] D139248: [lldb/Interpreter] Improve ScriptedPythonInterface::GetStatusFromMethod

2023-01-12 Thread Med Ismail Bennani via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG3fbc89048517: [lldb/Interpreter] Improve 
ScriptedPythonInterface::GetStatusFromMethod (authored by mib).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139248

Files:
  lldb/source/Plugins/ScriptInterpreter/Python/ScriptedPythonInterface.cpp
  lldb/source/Plugins/ScriptInterpreter/Python/ScriptedPythonInterface.h


Index: lldb/source/Plugins/ScriptInterpreter/Python/ScriptedPythonInterface.h
===
--- lldb/source/Plugins/ScriptInterpreter/Python/ScriptedPythonInterface.h
+++ lldb/source/Plugins/ScriptInterpreter/Python/ScriptedPythonInterface.h
@@ -100,7 +100,13 @@
 return ExtractValueFromPythonObject(py_return, error);
   }
 
-  Status GetStatusFromMethod(llvm::StringRef method_name);
+  template 
+  Status GetStatusFromMethod(llvm::StringRef method_name, Args &&...args) {
+Status error;
+Dispatch(method_name, error, std::forward(args)...);
+
+return error;
+  }
 
   template  T Transform(T object) {
 // No Transformation for generic usage
Index: lldb/source/Plugins/ScriptInterpreter/Python/ScriptedPythonInterface.cpp
===
--- lldb/source/Plugins/ScriptInterpreter/Python/ScriptedPythonInterface.cpp
+++ lldb/source/Plugins/ScriptInterpreter/Python/ScriptedPythonInterface.cpp
@@ -27,14 +27,6 @@
 ScriptInterpreterPythonImpl &interpreter)
 : ScriptedInterface(), m_interpreter(interpreter) {}
 
-Status
-ScriptedPythonInterface::GetStatusFromMethod(llvm::StringRef method_name) {
-  Status error;
-  Dispatch(method_name, error);
-
-  return error;
-}
-
 template <>
 StructuredData::ArraySP
 ScriptedPythonInterface::ExtractValueFromPythonObject(


Index: lldb/source/Plugins/ScriptInterpreter/Python/ScriptedPythonInterface.h
===
--- lldb/source/Plugins/ScriptInterpreter/Python/ScriptedPythonInterface.h
+++ lldb/source/Plugins/ScriptInterpreter/Python/ScriptedPythonInterface.h
@@ -100,7 +100,13 @@
 return ExtractValueFromPythonObject(py_return, error);
   }
 
-  Status GetStatusFromMethod(llvm::StringRef method_name);
+  template 
+  Status GetStatusFromMethod(llvm::StringRef method_name, Args &&...args) {
+Status error;
+Dispatch(method_name, error, std::forward(args)...);
+
+return error;
+  }
 
   template  T Transform(T object) {
 // No Transformation for generic usage
Index: lldb/source/Plugins/ScriptInterpreter/Python/ScriptedPythonInterface.cpp
===
--- lldb/source/Plugins/ScriptInterpreter/Python/ScriptedPythonInterface.cpp
+++ lldb/source/Plugins/ScriptInterpreter/Python/ScriptedPythonInterface.cpp
@@ -27,14 +27,6 @@
 ScriptInterpreterPythonImpl &interpreter)
 : ScriptedInterface(), m_interpreter(interpreter) {}
 
-Status
-ScriptedPythonInterface::GetStatusFromMethod(llvm::StringRef method_name) {
-  Status error;
-  Dispatch(method_name, error);
-
-  return error;
-}
-
 template <>
 StructuredData::ArraySP
 ScriptedPythonInterface::ExtractValueFromPythonObject(
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] bb4ccc6 - [lldb] Add ScriptedPlatform python implementation

2023-01-12 Thread Med Ismail Bennani via lldb-commits

Author: Med Ismail Bennani
Date: 2023-01-12T12:49:05-08:00
New Revision: bb4ccc6688893d1bf38cfca76620d84f947b9de1

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

LOG: [lldb] Add ScriptedPlatform python implementation

This patch introduces both the Scripted Platform python base
implementation and an example for it.

The base implementation is embedded in lldb python module under
`lldb.plugins.scripted_platform`.

This patch also refactor the various SWIG methods to create scripted
objects into a single method, that is now shared between the Scripted
Platform, Process and Thread. It also replaces the target argument by a
execution context object.

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

Signed-off-by: Med Ismail Bennani 

Added: 
lldb/examples/python/scripted_process/scripted_platform.py
lldb/test/API/functionalities/scripted_platform/my_scripted_platform.py

Modified: 
lldb/bindings/python/CMakeLists.txt
lldb/bindings/python/python-wrapper.swig
lldb/examples/python/scripted_process/crashlog_scripted_process.py
lldb/examples/python/scripted_process/scripted_process.py
lldb/source/Plugins/ScriptInterpreter/Python/SWIGPythonBridge.h

lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.cpp

lldb/source/Plugins/ScriptInterpreter/Python/ScriptedThreadPythonInterface.cpp
lldb/test/API/functionalities/scripted_process/dummy_scripted_process.py
lldb/test/API/functionalities/scripted_process/invalid_scripted_process.py

lldb/test/API/functionalities/scripted_process/stack_core_scripted_process.py
lldb/unittests/ScriptInterpreter/Python/PythonTestSuite.cpp

Removed: 




diff  --git a/lldb/bindings/python/CMakeLists.txt 
b/lldb/bindings/python/CMakeLists.txt
index afad367baa9fa..4f7941e6cff1d 100644
--- a/lldb/bindings/python/CMakeLists.txt
+++ b/lldb/bindings/python/CMakeLists.txt
@@ -109,6 +109,13 @@ function(finish_swig_python swig_target 
lldb_python_bindings_dir lldb_python_tar
 FILES
 "${LLDB_SOURCE_DIR}/examples/python/scripted_process/scripted_process.py")
 
+  create_python_package(
+${swig_target}
+${lldb_python_target_dir}
+"plugins"
+FILES
+"${LLDB_SOURCE_DIR}/examples/python/scripted_process/scripted_platform.py")
+
   if(APPLE)
 create_python_package(
   ${swig_target}

diff  --git a/lldb/bindings/python/python-wrapper.swig 
b/lldb/bindings/python/python-wrapper.swig
index 91b26fff05a1c..9a08c3000b79a 100644
--- a/lldb/bindings/python/python-wrapper.swig
+++ b/lldb/bindings/python/python-wrapper.swig
@@ -229,9 +229,9 @@ PythonObject 
lldb_private::LLDBSwigPythonCreateCommandObject(
   return pfunc(ToSWIGWrapper(std::move(debugger_sp)), dict);
 }
 
-PythonObject lldb_private::LLDBSwigPythonCreateScriptedProcess(
+PythonObject lldb_private::LLDBSwigPythonCreateScriptedObject(
 const char *python_class_name, const char *session_dictionary_name,
-const lldb::TargetSP &target_sp,
+lldb::ExecutionContextRefSP exe_ctx_sp,
 const lldb_private::StructuredDataImpl &args_impl,
 std::string &error_string) {
   if (python_class_name == NULL || python_class_name[0] == '\0' ||
@@ -251,8 +251,6 @@ PythonObject 
lldb_private::LLDBSwigPythonCreateScriptedProcess(
 return PythonObject();
   }
 
-  PythonObject target_arg = ToSWIGWrapper(target_sp);
-
   llvm::Expected arg_info = pfunc.GetArgInfo();
   if (!arg_info) {
 llvm::handleAllErrors(
@@ -266,7 +264,7 @@ PythonObject 
lldb_private::LLDBSwigPythonCreateScriptedProcess(
 
   PythonObject result = {};
   if (arg_info.get().max_positional_args == 2) {
-result = pfunc(target_arg, ToSWIGWrapper(args_impl));
+  result = pfunc(ToSWIGWrapper(exe_ctx_sp), ToSWIGWrapper(args_impl));
   } else {
 error_string.assign("wrong number of arguments in __init__, should be 2 "
 "(not including self)");
@@ -274,46 +272,6 @@ PythonObject 
lldb_private::LLDBSwigPythonCreateScriptedProcess(
   return result;
 }
 
-PythonObject lldb_private::LLDBSwigPythonCreateScriptedThread(
-const char *python_class_name, const char *session_dictionary_name,
-const lldb::ProcessSP &process_sp, const StructuredDataImpl &args_impl,
-std::string &error_string) {
-  if (python_class_name == NULL || python_class_name[0] == '\0' ||
-  !session_dictionary_name)
-return PythonObject();
-
-  PyErr_Cleaner py_err_cleaner(true);
-
-  auto dict = PythonModule::MainModule().ResolveName(
-  session_dictionary_name);
-  auto pfunc = PythonObject::ResolveNameWithDictionary(
-  python_class_name, dict);
-
-  if (!pfunc.IsAllocated()) {
-error_string.append("could not find script class: ");
-error_string.append(python_class_name);
-return PythonObject();
-  }
-
-  llvm:

[Lldb-commits] [PATCH] D139249: [lldb] Add Debugger & ScriptedMetadata reference to Platform::CreateInstance

2023-01-12 Thread Med Ismail Bennani via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG2d53527e9c64: [lldb] Add Debugger & ScriptedMetadata 
reference to Platform::CreateInstance (authored by mib).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139249

Files:
  lldb/bindings/interface/SBPlatform.i
  lldb/include/lldb/API/SBDebugger.h
  lldb/include/lldb/API/SBPlatform.h
  lldb/include/lldb/API/SBStructuredData.h
  lldb/include/lldb/Interpreter/OptionGroupPlatform.h
  lldb/include/lldb/Target/Platform.h
  lldb/include/lldb/lldb-private-interfaces.h
  lldb/source/API/SBDebugger.cpp
  lldb/source/API/SBPlatform.cpp
  lldb/source/Commands/CommandObjectPlatform.cpp
  lldb/source/Commands/CommandObjectPlatform.h
  lldb/source/Core/Debugger.cpp
  lldb/source/Interpreter/OptionGroupPlatform.cpp
  lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp
  lldb/source/Plugins/Platform/Android/PlatformAndroid.cpp
  lldb/source/Plugins/Platform/Android/PlatformAndroid.h
  lldb/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp
  lldb/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.h
  lldb/source/Plugins/Platform/Linux/PlatformLinux.cpp
  lldb/source/Plugins/Platform/Linux/PlatformLinux.h
  lldb/source/Plugins/Platform/MacOSX/PlatformAppleSimulator.cpp
  lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
  lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.h
  lldb/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.cpp
  lldb/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.h
  lldb/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp
  lldb/source/Plugins/Platform/MacOSX/PlatformMacOSX.h
  lldb/source/Plugins/Platform/MacOSX/PlatformRemoteAppleBridge.cpp
  lldb/source/Plugins/Platform/MacOSX/PlatformRemoteAppleBridge.h
  lldb/source/Plugins/Platform/MacOSX/PlatformRemoteAppleTV.cpp
  lldb/source/Plugins/Platform/MacOSX/PlatformRemoteAppleTV.h
  lldb/source/Plugins/Platform/MacOSX/PlatformRemoteAppleWatch.cpp
  lldb/source/Plugins/Platform/MacOSX/PlatformRemoteAppleWatch.h
  lldb/source/Plugins/Platform/MacOSX/PlatformRemoteMacOSX.cpp
  lldb/source/Plugins/Platform/MacOSX/PlatformRemoteMacOSX.h
  lldb/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.cpp
  lldb/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.h
  lldb/source/Plugins/Platform/NetBSD/PlatformNetBSD.cpp
  lldb/source/Plugins/Platform/NetBSD/PlatformNetBSD.h
  lldb/source/Plugins/Platform/OpenBSD/PlatformOpenBSD.cpp
  lldb/source/Plugins/Platform/OpenBSD/PlatformOpenBSD.h
  lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp
  lldb/source/Plugins/Platform/QemuUser/PlatformQemuUser.cpp
  lldb/source/Plugins/Platform/QemuUser/PlatformQemuUser.h
  lldb/source/Plugins/Platform/Windows/PlatformWindows.cpp
  lldb/source/Plugins/Platform/Windows/PlatformWindows.h
  lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp
  lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.h
  lldb/source/Target/Platform.cpp
  lldb/source/Target/Process.cpp
  lldb/source/Target/Target.cpp
  lldb/source/Target/TargetList.cpp
  lldb/unittests/Core/DiagnosticEventTest.cpp
  lldb/unittests/Expression/DWARFExpressionTest.cpp
  lldb/unittests/Interpreter/TestCommandPaths.cpp
  lldb/unittests/Platform/PlatformAppleSimulatorTest.cpp
  lldb/unittests/Platform/PlatformSiginfoTest.cpp
  lldb/unittests/Platform/PlatformTest.cpp
  lldb/unittests/Process/ProcessEventDataTest.cpp
  lldb/unittests/Target/ExecutionContextTest.cpp
  lldb/unittests/Target/StackFrameRecognizerTest.cpp
  lldb/unittests/Thread/ThreadTest.cpp

Index: lldb/unittests/Thread/ThreadTest.cpp
===
--- lldb/unittests/Thread/ThreadTest.cpp
+++ lldb/unittests/Thread/ThreadTest.cpp
@@ -91,8 +91,9 @@
 TEST_F(ThreadTest, SetStopInfo) {
   ArchSpec arch("powerpc64-pc-linux");
 
-  Platform::SetHostPlatform(
-  platform_linux::PlatformLinux::CreateInstance(true, &arch));
+  Platform::SetHostPlatform(platform_linux::PlatformLinux::CreateInstance(
+  true, &arch, /*debugger=*/nullptr,
+  /*metadata=*/nullptr));
 
   DebuggerSP debugger_sp = Debugger::CreateInstance();
   ASSERT_TRUE(debugger_sp);
@@ -126,8 +127,9 @@
 TEST_F(ThreadTest, GetPrivateStopInfo) {
   ArchSpec arch("powerpc64-pc-linux");
 
-  Platform::SetHostPlatform(
-  platform_linux::PlatformLinux::CreateInstance(true, &arch));
+  Platform::SetHostPlatform(platform_linux::PlatformLinux::CreateInstance(
+  true, &arch, /*debugger=*/nullptr,
+  /*metadata=*/nullptr));
 
   DebuggerSP debugger_sp = Debugger::CreateInstance();
   ASSERT_TRUE(debugger_sp);
Index: lldb/unittests/Target/StackFrameRecognizerTest.cpp
===
--- lldb/unittests/Target/StackFrameRecognizerTest.cpp
+++ lldb/unittests/Target/StackFrameRecognizerTest.cpp
@@ -32,8 +32,9 @@
 // Pretend Linux is the host platform.
 

[Lldb-commits] [PATCH] D139251: [lldb/Interpreter] Introduce ScriptedPlatform{, Python}Interface

2023-01-12 Thread Med Ismail Bennani via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGb1256f2345f6: [lldb/Interpreter] Introduce 
ScriptedPlatform{,Python}Interface (authored by mib).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139251

Files:
  lldb/include/lldb/Interpreter/ScriptInterpreter.h
  lldb/include/lldb/Interpreter/ScriptedPlatformInterface.h
  lldb/include/lldb/lldb-forward.h
  lldb/source/Interpreter/ScriptInterpreter.cpp
  lldb/source/Plugins/ScriptInterpreter/Python/CMakeLists.txt
  lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
  
lldb/source/Plugins/ScriptInterpreter/Python/ScriptedPlatformPythonInterface.cpp
  lldb/source/Plugins/ScriptInterpreter/Python/ScriptedPlatformPythonInterface.h

Index: lldb/source/Plugins/ScriptInterpreter/Python/ScriptedPlatformPythonInterface.h
===
--- /dev/null
+++ lldb/source/Plugins/ScriptInterpreter/Python/ScriptedPlatformPythonInterface.h
@@ -0,0 +1,44 @@
+//===-- ScriptedPlatformPythonInterface.h ---*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef LLDB_PLUGINS_SCRIPTINTERPRETER_PYTHON_SCRIPTEDPLATFORMPYTHONINTERFACE_H
+#define LLDB_PLUGINS_SCRIPTINTERPRETER_PYTHON_SCRIPTEDPLATFORMPYTHONINTERFACE_H
+
+#include "lldb/Host/Config.h"
+
+#if LLDB_ENABLE_PYTHON
+
+#include "ScriptedPythonInterface.h"
+#include "lldb/Interpreter/ScriptedPlatformInterface.h"
+
+namespace lldb_private {
+class ScriptedPlatformPythonInterface : public ScriptedPlatformInterface,
+public ScriptedPythonInterface {
+public:
+  ScriptedPlatformPythonInterface(ScriptInterpreterPythonImpl &interpreter);
+
+  StructuredData::GenericSP
+  CreatePluginObject(const llvm::StringRef class_name,
+ ExecutionContext &exe_ctx,
+ StructuredData::DictionarySP args_sp,
+ StructuredData::Generic *script_obj = nullptr) override;
+
+  StructuredData::DictionarySP ListProcesses() override;
+
+  StructuredData::DictionarySP GetProcessInfo(lldb::pid_t) override;
+
+  Status AttachToProcess(lldb::ProcessAttachInfoSP attach_info) override;
+
+  Status LaunchProcess(lldb::ProcessLaunchInfoSP launch_info) override;
+
+  Status KillProcess(lldb::pid_t pid) override;
+};
+} // namespace lldb_private
+
+#endif // LLDB_ENABLE_PYTHON
+#endif // LLDB_PLUGINS_SCRIPTINTERPRETER_PYTHON_SCRIPTEDPLATFORMPYTHONINTERFACE_H
Index: lldb/source/Plugins/ScriptInterpreter/Python/ScriptedPlatformPythonInterface.cpp
===
--- /dev/null
+++ lldb/source/Plugins/ScriptInterpreter/Python/ScriptedPlatformPythonInterface.cpp
@@ -0,0 +1,108 @@
+//===-- ScriptedPlatformPythonInterface.cpp ---===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "lldb/Host/Config.h"
+#include "lldb/Utility/Log.h"
+#include "lldb/Utility/Status.h"
+#include "lldb/lldb-enumerations.h"
+
+#if LLDB_ENABLE_PYTHON
+
+// LLDB Python header must be included first
+#include "lldb-python.h"
+
+#include "SWIGPythonBridge.h"
+#include "ScriptInterpreterPythonImpl.h"
+#include "ScriptedPlatformPythonInterface.h"
+
+using namespace lldb;
+using namespace lldb_private;
+using namespace lldb_private::python;
+using Locker = ScriptInterpreterPythonImpl::Locker;
+
+ScriptedPlatformPythonInterface::ScriptedPlatformPythonInterface(
+ScriptInterpreterPythonImpl &interpreter)
+: ScriptedPlatformInterface(), ScriptedPythonInterface(interpreter) {}
+
+StructuredData::GenericSP ScriptedPlatformPythonInterface::CreatePluginObject(
+llvm::StringRef class_name, ExecutionContext &exe_ctx,
+StructuredData::DictionarySP args_sp, StructuredData::Generic *script_obj) {
+  if (class_name.empty())
+return {};
+
+  StructuredDataImpl args_impl(args_sp);
+  std::string error_string;
+
+  Locker py_lock(&m_interpreter, Locker::AcquireLock | Locker::NoSTDIN,
+ Locker::FreeLock);
+
+  lldb::ExecutionContextRefSP exe_ctx_ref_sp =
+  std::make_shared(exe_ctx);
+
+  PythonObject ret_val = LLDBSwigPythonCreateScriptedObject(
+  class_name.str().c_str(), m_interpreter.GetDictionaryName(),
+  exe_ctx_ref_sp, args_impl, error_string);
+
+  m_object_instance_sp =
+  StructuredData::GenericSP(new StructuredPythonObject(std::move(ret_val)));
+
+ 

[Lldb-commits] [PATCH] D139250: [lldb] Add ScriptedPlatform python implementation

2023-01-12 Thread Med Ismail Bennani via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGbb4ccc668889: [lldb] Add ScriptedPlatform python 
implementation (authored by mib).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139250

Files:
  lldb/bindings/python/CMakeLists.txt
  lldb/bindings/python/python-wrapper.swig
  lldb/examples/python/scripted_process/crashlog_scripted_process.py
  lldb/examples/python/scripted_process/scripted_platform.py
  lldb/examples/python/scripted_process/scripted_process.py
  lldb/source/Plugins/ScriptInterpreter/Python/SWIGPythonBridge.h
  
lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.cpp
  lldb/source/Plugins/ScriptInterpreter/Python/ScriptedThreadPythonInterface.cpp
  lldb/test/API/functionalities/scripted_platform/my_scripted_platform.py
  lldb/test/API/functionalities/scripted_process/dummy_scripted_process.py
  lldb/test/API/functionalities/scripted_process/invalid_scripted_process.py
  lldb/test/API/functionalities/scripted_process/stack_core_scripted_process.py
  lldb/unittests/ScriptInterpreter/Python/PythonTestSuite.cpp

Index: lldb/unittests/ScriptInterpreter/Python/PythonTestSuite.cpp
===
--- lldb/unittests/ScriptInterpreter/Python/PythonTestSuite.cpp
+++ lldb/unittests/ScriptInterpreter/Python/PythonTestSuite.cpp
@@ -200,16 +200,9 @@
   return python::PythonObject();
 }
 
-python::PythonObject lldb_private::LLDBSwigPythonCreateScriptedProcess(
+python::PythonObject lldb_private::LLDBSwigPythonCreateScriptedObject(
 const char *python_class_name, const char *session_dictionary_name,
-const lldb::TargetSP &target_sp, const StructuredDataImpl &args_impl,
-std::string &error_string) {
-  return python::PythonObject();
-}
-
-python::PythonObject lldb_private::LLDBSwigPythonCreateScriptedThread(
-const char *python_class_name, const char *session_dictionary_name,
-const lldb::ProcessSP &process_sp, const StructuredDataImpl &args_impl,
+lldb::ExecutionContextRefSP exe_ctx_sp, const StructuredDataImpl &args_impl,
 std::string &error_string) {
   return python::PythonObject();
 }
Index: lldb/test/API/functionalities/scripted_process/stack_core_scripted_process.py
===
--- lldb/test/API/functionalities/scripted_process/stack_core_scripted_process.py
+++ lldb/test/API/functionalities/scripted_process/stack_core_scripted_process.py
@@ -13,8 +13,8 @@
 return module
 return None
 
-def __init__(self, target: lldb.SBTarget, args : lldb.SBStructuredData):
-super().__init__(target, args)
+def __init__(self, exe_ctx: lldb.SBExecutionContext, args : lldb.SBStructuredData):
+super().__init__(exe_ctx, args)
 
 self.corefile_target = None
 self.corefile_process = None
@@ -25,7 +25,7 @@
 idx = self.backing_target_idx.GetIntegerValue(42)
 if self.backing_target_idx.GetType() == lldb.eStructuredDataTypeString:
 idx = int(self.backing_target_idx.GetStringValue(100))
-self.corefile_target = target.GetDebugger().GetTargetAtIndex(idx)
+self.corefile_target = self.target.GetDebugger().GetTargetAtIndex(idx)
 self.corefile_process = self.corefile_target.GetProcess()
 for corefile_thread in self.corefile_process:
 structured_data = lldb.SBStructuredData()
Index: lldb/test/API/functionalities/scripted_process/invalid_scripted_process.py
===
--- lldb/test/API/functionalities/scripted_process/invalid_scripted_process.py
+++ lldb/test/API/functionalities/scripted_process/invalid_scripted_process.py
@@ -7,8 +7,8 @@
 from lldb.plugins.scripted_process import ScriptedThread
 
 class InvalidScriptedProcess(ScriptedProcess):
-def __init__(self, target: lldb.SBTarget, args : lldb.SBStructuredData):
-super().__init__(target, args)
+def __init__(self, exe_ctx: lldb.SBExecutionContext, args : lldb.SBStructuredData):
+super().__init__(exe_ctx, args)
 self.threads[0] = InvalidScriptedThread(self, None)
 
 def get_memory_region_containing_address(self, addr: int) -> lldb.SBMemoryRegionInfo:
Index: lldb/test/API/functionalities/scripted_process/dummy_scripted_process.py
===
--- lldb/test/API/functionalities/scripted_process/dummy_scripted_process.py
+++ lldb/test/API/functionalities/scripted_process/dummy_scripted_process.py
@@ -7,8 +7,8 @@
 from lldb.plugins.scripted_process import ScriptedThread
 
 class DummyScriptedProcess(ScriptedProcess):
-def __init__(self, target: lldb.SBTarget, args : lldb.SBStructuredData):
-super().__init__(target, args)
+def __init__(self, exe_ctx: lldb.SBExecutionContext

[Lldb-commits] [PATCH] D141629: Run address expression argument values through ABI::FixCodeAddress to strip TBI/pointer auth bytes on AArch64

2023-01-12 Thread Jason Molenda via Phabricator via lldb-commits
jasonmolenda created this revision.
jasonmolenda added a reviewer: DavidSpickett.
jasonmolenda added a project: LLDB.
Herald added subscribers: Michael137, kristof.beyls.
Herald added a project: All.
jasonmolenda requested review of this revision.
Herald added a subscriber: lldb-commits.

This is a different way of accomplishing the phab @DavidSpickett put up a few 
months ago, https://reviews.llvm.org/D136938 , which cleared these bits 
specifically for breakpoints in Target::GetBreakableLoadAddress.

I don't have an actual test case for this; this phabracator includes a test, 
but it actually won't run and I'm undecided about committing it (@JDevlieghere 
thinks landing a test that can't run any time soon is a bad idea).  The 
llvm.org clang doesn't support generating the (not yet finalized) arm64e ABI on 
Darwin systems (ARMv8.3+ using a ptrauth ABI), although it can be forced to 
output a non-ptrauth codegen in an arm64e mach-o file.  Even if the in-tree 
llvm.org clang could generate correct arm64e binaries, macOS won't allow you to 
run them without setting a boot-arg (`-arm64e_preview_abi`) on the test system 
& rebooting for it to be enabled.  I included the test case in this phabracator 
to show an example of how it could be tested if these things weren't true. :)


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D141629

Files:
  lldb/packages/Python/lldbsuite/test/lldbtest.py
  lldb/source/Interpreter/OptionArgParser.cpp
  lldb/test/API/macosx/ptrauth-address-expressions/Makefile
  
lldb/test/API/macosx/ptrauth-address-expressions/TestPtrauthAddressExpressions.py
  lldb/test/API/macosx/ptrauth-address-expressions/main.c


Index: lldb/test/API/macosx/ptrauth-address-expressions/main.c
===
--- /dev/null
+++ lldb/test/API/macosx/ptrauth-address-expressions/main.c
@@ -0,0 +1,10 @@
+#include 
+
+int foo () { return 10; }
+
+int main () 
+{
+  int (*fptr)() = foo;
+  printf ("%p\n", fptr); // break here
+  return fptr();
+}
Index: 
lldb/test/API/macosx/ptrauth-address-expressions/TestPtrauthAddressExpressions.py
===
--- /dev/null
+++ 
lldb/test/API/macosx/ptrauth-address-expressions/TestPtrauthAddressExpressions.py
@@ -0,0 +1,28 @@
+"""Test that AArch64 PAC bits are stripped from address expression arguments"""
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+class TestPtrauthAddressExpressions(TestBase):
+
+NO_DEBUG_INFO_TESTCASE = True
+
+# On Darwin systems, arch arm64e means ARMv8.3 with ptrauth
+# ABI used.
+@skipIf(archs=no_match(['arm64e']))
+
+def test(self):
+
+# Skip this test if not running on AArch64 target that supports PAC
+if not self.isAArch64PAuth():
+self.skipTest('Target must support pointer authentication.')
+self.source = 'main.c'
+self.build()
+(self.target, process, thread, bkpt) = 
lldbutil.run_to_source_breakpoint(self,
+   "break here", lldb.SBFileSpec(self.source, False))
+
+self.expect("p fptr", substrs=[self.source])
+self.expect("ima loo -va fptr", substrs=[self.source])
+self.expect("break set -a fptr", substrs=[self.source])
Index: lldb/test/API/macosx/ptrauth-address-expressions/Makefile
===
--- /dev/null
+++ lldb/test/API/macosx/ptrauth-address-expressions/Makefile
@@ -0,0 +1,3 @@
+C_SOURCES := main.c
+
+include Makefile.rules
Index: lldb/source/Interpreter/OptionArgParser.cpp
===
--- lldb/source/Interpreter/OptionArgParser.cpp
+++ lldb/source/Interpreter/OptionArgParser.cpp
@@ -8,6 +8,7 @@
 
 #include "lldb/Interpreter/OptionArgParser.h"
 #include "lldb/DataFormatters/FormatManager.h"
+#include "lldb/Target/ABI.h"
 #include "lldb/Target/Target.h"
 #include "lldb/Utility/Status.h"
 #include "lldb/Utility/StreamString.h"
@@ -157,6 +158,10 @@
   if (!s.getAsInteger(0, addr)) {
 if (error_ptr)
   error_ptr->Clear();
+Process *process = exe_ctx->GetProcessPtr();
+if (process)
+  if (ABISP abi_sp = process->GetABI())
+addr = abi_sp->FixCodeAddress(addr);
 return addr;
   }
 
Index: lldb/packages/Python/lldbsuite/test/lldbtest.py
===
--- lldb/packages/Python/lldbsuite/test/lldbtest.py
+++ lldb/packages/Python/lldbsuite/test/lldbtest.py
@@ -1243,6 +1243,8 @@
 return self.isAArch64() and "mte" in self.getCPUInfo()
 
 def isAArch64PAuth(self):
+if self.getArchitecture() == "arm64e":
+return True
 return self.isAArch64() and "paca" in self.getCPUInfo()
 
 def getArchitecture(self):


Index: lldb/test/API/macosx/ptrauth-address-expressions/main.c
==

[Lldb-commits] [PATCH] D139249: [lldb] Add Debugger & ScriptedMetadata reference to Platform::CreateInstance

2023-01-12 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere added a comment.

This seems very intrusive: I don't think every plugin should have to be aware 
of this metadata that only one plugin needs. Is there a way to avoid this? For 
example, could we initialize a generic scripted platform first, with no backing 
Python class, and then have that set after the fact? My concern here is how the 
scripted process/platform is slowly creeping into all the generic code. Maybe 
that will require bigger design changes or maybe it's entirely unavoidable to 
achieve what we need, but I'd like to make sure we've given fair consideration 
to potential alternatives.

(Requesting changes so this shows up in my review queue)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139249

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


[Lldb-commits] [lldb] d69e5df - [lldb/test] Disable TestScriptedProcess.py on linux while investigating the issue

2023-01-12 Thread Med Ismail Bennani via lldb-commits

Author: Med Ismail Bennani
Date: 2023-01-12T14:11:36-08:00
New Revision: d69e5dfa234f8af7fb1c3bdbceb5c101c300bab1

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

LOG: [lldb/test] Disable TestScriptedProcess.py on linux while investigating 
the issue

Signed-off-by: Med Ismail Bennani 

Added: 


Modified: 
lldb/test/API/functionalities/scripted_process/TestScriptedProcess.py

Removed: 




diff  --git 
a/lldb/test/API/functionalities/scripted_process/TestScriptedProcess.py 
b/lldb/test/API/functionalities/scripted_process/TestScriptedProcess.py
index 619e47cfe4834..9cb33fb832010 100644
--- a/lldb/test/API/functionalities/scripted_process/TestScriptedProcess.py
+++ b/lldb/test/API/functionalities/scripted_process/TestScriptedProcess.py
@@ -14,6 +14,7 @@ class ScriptedProcesTestCase(TestBase):
 
 NO_DEBUG_INFO_TESTCASE = True
 
+@skipUnlessDarwin
 def test_python_plugin_package(self):
 """Test that the lldb python module has a `plugins.scripted_process`
 package."""



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


[Lldb-commits] [PATCH] D141633: [lldb-vscode] Use SBFrame.GetDisplayFunctionName() instead of SBFrame.GetFunctionName()

2023-01-12 Thread Ivan Hernandez via Phabricator via lldb-commits
ivanhernandez13 created this revision.
Herald added a project: All.
ivanhernandez13 requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

This change replaces calls to SBFrame.GetFunctionName() with
SBFrame.GetDisplayFunctionName() which can return much more user
friendly names in some cases, particularly for Swift code.

A trivial example:

main.swift

  class Doer {
  static func doTheThing() {
  print("Hello World!")
  }
  }
  Doer.doTheThing()

lldb

  (lldb) script 
lldb.debugger.GetSelectedTarget().GetProcess().GetSelectedThread().GetSelectedFrame().GetDisplayFunctionName()
  'static Doer.doTheThing()'
  (lldb) script 
lldb.debugger.GetSelectedTarget().GetProcess().GetSelectedThread().GetSelectedFrame().GetFunctionName()
  'static main.Doer.doTheThing() -> ()'


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D141633

Files:
  lldb/tools/lldb-vscode/JSONUtils.cpp


Index: lldb/tools/lldb-vscode/JSONUtils.cpp
===
--- lldb/tools/lldb-vscode/JSONUtils.cpp
+++ lldb/tools/lldb-vscode/JSONUtils.cpp
@@ -650,7 +650,7 @@
   }
   const auto num_insts = insts.GetSize();
   if (low_pc != LLDB_INVALID_ADDRESS && num_insts > 0) {
-EmplaceSafeString(object, "name", frame.GetFunctionName());
+EmplaceSafeString(object, "name", frame.GetDisplayFunctionName());
 SourceReference source;
 llvm::raw_string_ostream src_strm(source.content);
 std::string line;
@@ -759,7 +759,7 @@
   object.try_emplace("id", frame_id);
 
   std::string frame_name;
-  const char *func_name = frame.GetFunctionName();
+  const char *func_name = frame.GetDisplayFunctionName();
   if (func_name)
 frame_name = func_name;
   else


Index: lldb/tools/lldb-vscode/JSONUtils.cpp
===
--- lldb/tools/lldb-vscode/JSONUtils.cpp
+++ lldb/tools/lldb-vscode/JSONUtils.cpp
@@ -650,7 +650,7 @@
   }
   const auto num_insts = insts.GetSize();
   if (low_pc != LLDB_INVALID_ADDRESS && num_insts > 0) {
-EmplaceSafeString(object, "name", frame.GetFunctionName());
+EmplaceSafeString(object, "name", frame.GetDisplayFunctionName());
 SourceReference source;
 llvm::raw_string_ostream src_strm(source.content);
 std::string line;
@@ -759,7 +759,7 @@
   object.try_emplace("id", frame_id);
 
   std::string frame_name;
-  const char *func_name = frame.GetFunctionName();
+  const char *func_name = frame.GetDisplayFunctionName();
   if (func_name)
 frame_name = func_name;
   else
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D141637: [lldb-vscode] Fix an issue where lldb-vscode tries to display a source file for generated code

2023-01-12 Thread Ivan Hernandez via Phabricator via lldb-commits
ivanhernandez13 created this revision.
Herald added a project: All.
ivanhernandez13 requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

According to
https://github.com/llvm/llvm-project/blob/fbcefff9d0a3f5e97270ef8e7b8e0f2afc33dc1c/lldb/source/Symbol/LineEntry.cpp#L215,
a line entry of 0 indicates compiler generated code. Despite it
being generated code, the SBLineEntry.GetFileSpec().IsValid() check
can be true in which case lldb-vscode responds with a non-existent
file named "". This patch will instead have
lldb-vscode return the disassembly of the generated code.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D141637

Files:
  lldb/tools/lldb-vscode/JSONUtils.cpp


Index: lldb/tools/lldb-vscode/JSONUtils.cpp
===
--- lldb/tools/lldb-vscode/JSONUtils.cpp
+++ lldb/tools/lldb-vscode/JSONUtils.cpp
@@ -613,7 +613,7 @@
 llvm::json::Value CreateSource(lldb::SBFrame &frame, int64_t &disasm_line) {
   disasm_line = 0;
   auto line_entry = frame.GetLineEntry();
-  if (line_entry.GetFileSpec().IsValid())
+  if (line_entry.GetFileSpec().IsValid() && line_entry.GetLine() != 0)
 return CreateSource(line_entry);
 
   llvm::json::Object object;


Index: lldb/tools/lldb-vscode/JSONUtils.cpp
===
--- lldb/tools/lldb-vscode/JSONUtils.cpp
+++ lldb/tools/lldb-vscode/JSONUtils.cpp
@@ -613,7 +613,7 @@
 llvm::json::Value CreateSource(lldb::SBFrame &frame, int64_t &disasm_line) {
   disasm_line = 0;
   auto line_entry = frame.GetLineEntry();
-  if (line_entry.GetFileSpec().IsValid())
+  if (line_entry.GetFileSpec().IsValid() && line_entry.GetLine() != 0)
 return CreateSource(line_entry);
 
   llvm::json::Object object;
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D139951: [lldb/crashlog] Refactor CrashLogParser into a Factory patern

2023-01-12 Thread Med Ismail Bennani via Phabricator via lldb-commits
mib updated this revision to Diff 488796.
mib marked 2 inline comments as done.
mib edited the summary of this revision.
mib added a comment.

Address @kastiglione & @JDevlieghere comments:

- rename the factory method to `create`


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

https://reviews.llvm.org/D139951

Files:
  lldb/examples/python/crashlog.py
  lldb/examples/python/scripted_process/crashlog_scripted_process.py


Index: lldb/examples/python/scripted_process/crashlog_scripted_process.py
===
--- lldb/examples/python/scripted_process/crashlog_scripted_process.py
+++ lldb/examples/python/scripted_process/crashlog_scripted_process.py
@@ -10,7 +10,7 @@
 
 class CrashLogScriptedProcess(ScriptedProcess):
 def parse_crashlog(self):
-crashlog_parser = CrashLogParser(self.dbg, self.crashlog_path, False)
+crashlog_parser = CrashLogParser.create(self.dbg, self.crashlog_path, 
False)
 crash_log = crashlog_parser.parse()
 
 self.pid = crash_log.process_id
Index: lldb/examples/python/crashlog.py
===
--- lldb/examples/python/crashlog.py
+++ lldb/examples/python/crashlog.py
@@ -417,15 +417,15 @@
 pass
 
 class CrashLogParser:
-"CrashLog parser base class and factory."
-def __new__(cls, debugger, path, verbose):
+@staticmethod
+def create(debugger, path, verbose):
 data = JSONCrashLogParser.is_valid_json(path)
 if data:
-self = object.__new__(JSONCrashLogParser)
-self.data = data
-return self
+parser = JSONCrashLogParser(debugger, path, verbose)
+parser.data = data
+return parser
 else:
-return object.__new__(TextCrashLogParser)
+return TextCrashLogParser(debugger, path, verbose)
 
 def __init__(self, debugger, path, verbose):
 self.path = os.path.expanduser(path)
@@ -1076,7 +1076,7 @@
 if not os.path.exists(crashlog_path):
 raise InteractiveCrashLogException("crashlog file %s does not exist" % 
crashlog_path)
 
-crashlog = CrashLogParser(debugger, crashlog_path, False).parse()
+crashlog = CrashLogParser.create(debugger, crashlog_path, False).parse()
 
 target = lldb.SBTarget()
 # 1. Try to use the user-provided target
@@ -1332,7 +1332,7 @@
 except InteractiveCrashLogException as e:
 result.SetError(str(e))
 else:
-crash_log = CrashLogParser(debugger, crash_log_file, 
options.verbose).parse()
+crash_log = CrashLogParser.create(debugger, crash_log_file, 
options.verbose).parse()
 SymbolicateCrashLog(crash_log, options)
 
 if __name__ == '__main__':


Index: lldb/examples/python/scripted_process/crashlog_scripted_process.py
===
--- lldb/examples/python/scripted_process/crashlog_scripted_process.py
+++ lldb/examples/python/scripted_process/crashlog_scripted_process.py
@@ -10,7 +10,7 @@
 
 class CrashLogScriptedProcess(ScriptedProcess):
 def parse_crashlog(self):
-crashlog_parser = CrashLogParser(self.dbg, self.crashlog_path, False)
+crashlog_parser = CrashLogParser.create(self.dbg, self.crashlog_path, False)
 crash_log = crashlog_parser.parse()
 
 self.pid = crash_log.process_id
Index: lldb/examples/python/crashlog.py
===
--- lldb/examples/python/crashlog.py
+++ lldb/examples/python/crashlog.py
@@ -417,15 +417,15 @@
 pass
 
 class CrashLogParser:
-"CrashLog parser base class and factory."
-def __new__(cls, debugger, path, verbose):
+@staticmethod
+def create(debugger, path, verbose):
 data = JSONCrashLogParser.is_valid_json(path)
 if data:
-self = object.__new__(JSONCrashLogParser)
-self.data = data
-return self
+parser = JSONCrashLogParser(debugger, path, verbose)
+parser.data = data
+return parser
 else:
-return object.__new__(TextCrashLogParser)
+return TextCrashLogParser(debugger, path, verbose)
 
 def __init__(self, debugger, path, verbose):
 self.path = os.path.expanduser(path)
@@ -1076,7 +1076,7 @@
 if not os.path.exists(crashlog_path):
 raise InteractiveCrashLogException("crashlog file %s does not exist" % crashlog_path)
 
-crashlog = CrashLogParser(debugger, crashlog_path, False).parse()
+crashlog = CrashLogParser.create(debugger, crashlog_path, False).parse()
 
 target = lldb.SBTarget()
 # 1. Try to use the user-provided target
@@ -1332,7 +1332,7 @@
 except InteractiveCrashLogException as e:
 result.SetError(str(e))
 else:
-crash_log = CrashLogParser(debugg

[Lldb-commits] [PATCH] D139951: [lldb/crashlog] Refactor CrashLogParser into a Factory pattern

2023-01-12 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.

Ship it


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

https://reviews.llvm.org/D139951

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


[Lldb-commits] [PATCH] D130586: [cmake] Use `CMAKE_INSTALL_LIBDIR` too

2023-01-12 Thread Roman Lebedev via Phabricator via lldb-commits
lebedev.ri resigned from this revision.
lebedev.ri added a comment.
Herald added a subscriber: StephenFan.

What's the status here? Should this be abandoned?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130586

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


[Lldb-commits] [PATCH] D131858: [clang] Track the templated entity in type substitution.

2023-01-12 Thread Richard Smith - zygoloid via Phabricator via lldb-commits
rsmith added a comment.

In D131858#3957630 , @arphaman wrote:

> This change has caused a failure in Clang's stage 2 CI on the green dragon 
> Darwin CI: 
> https://green.lab.llvm.org/green/job/clang-stage2-Rthinlto/6390/console.
>
>   Assertion failed: (lvaluePath->getType() == elemTy && "Unexpected type 
> reference!"), function readAPValue, file 
> /Users/buildslave/jenkins/workspace/clang-stage1-RA/clang-build/tools/clang/include/clang/AST/AbstractBasicReader.inc,
>  line 736.

This assert is simply wrong, and I've removed it in 
rG2009f2450532450a99c1a03d5e2c30f478121839 
 -- that 
change should be safe to cherry-pick into the release branch. It's possible for 
the recomputation of the type after deserialization to result in a different 
type than what we saw when serializing, because redeclarations of the same 
entity can use the same type with different sugar -- or even slightly different 
types in some cases, such as when an array bound is added in a redeclaration. 
The dumps of the types provided by @steven_wu confirms that we were just seeing 
a difference in type sugar in this case.

>   Assertion failed: (BlockScope.empty() && CurAbbrevs.empty() && "Block 
> imbalance"), function ~BitstreamWriter, file 
> /Users/buildslave/jenkins/workspace/clang-stage1-RA/llvm-project/llvm/include/llvm/Bitstream/BitstreamWriter.h,
>  line 119.

Is this still happening? If so, this looks more serious, and will need further 
investigation.

Can we undo the workaround in https://reviews.llvm.org/D139956 and see if the 
bot is now happy? Or can someone who was seeing problems before (@steven_wu?) 
run a test?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131858

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


[Lldb-commits] [lldb] d52582b - [LLDB][LoongArch] ObjectFile: add a case for `EM_LOONGARCH`

2023-01-12 Thread Weining Lu via lldb-commits

Author: Hui Li
Date: 2023-01-13T10:17:31+08:00
New Revision: d52582b6b7dfff5538008ad1ebb141da283d9206

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

LOG: [LLDB][LoongArch] ObjectFile: add a case for `EM_LOONGARCH`

This adds the jump slot mapping for LoongArch. This is a simple
change that ensures lldb running properly.

 Note that this problem was found only when CMake variables
 "DLLVM_ENABLE_ASSERTIONS=ON" is selected.

Without this patch,

```
$ build/bin/lldb  test

../ELFHeader::GetRelocationJumpSlotType() const: Assertion `false && 
"architecture not supported"' fail

```
With this patch

```
$ build/bin/lldb  test
(lldb) target create "test"
Current executable set to '../test' (loongarch64).

```

Reviewed By: SixWeining, DavidSpickett

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

Added: 


Modified: 
lldb/source/Plugins/ObjectFile/ELF/ELFHeader.cpp

Removed: 




diff  --git a/lldb/source/Plugins/ObjectFile/ELF/ELFHeader.cpp 
b/lldb/source/Plugins/ObjectFile/ELF/ELFHeader.cpp
index abda0cd0e9a38..a6e385f70709b 100644
--- a/lldb/source/Plugins/ObjectFile/ELF/ELFHeader.cpp
+++ b/lldb/source/Plugins/ObjectFile/ELF/ELFHeader.cpp
@@ -211,6 +211,9 @@ unsigned ELFHeader::GetRelocationJumpSlotType() const {
   case EM_RISCV:
 slot = R_RISCV_JUMP_SLOT;
 break;
+  case EM_LOONGARCH:
+slot = R_LARCH_JUMP_SLOT;
+break;
   }
 
   return slot;



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


[Lldb-commits] [lldb] 1eaadae - [LLDB][LoongArch] Add unittests for EmulateInstructionLoongArch

2023-01-12 Thread Weining Lu via lldb-commits

Author: Hui Li
Date: 2023-01-13T10:17:55+08:00
New Revision: 1eaadaea5090f88d4e26331a5046a1a07f15a6ea

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

LOG: [LLDB][LoongArch] Add unittests for EmulateInstructionLoongArch

Add unit tests For EmulateInstructionLoongArch existing branch instruction.
Add 19 test cases in total.

Without this patch:

```
$ ninja check-lldb-unit
[0/1] Running lldb unit test suite

Testing Time: 10.55s
  Passed: 1025
```

With this patch:

```
$ ninja check-lldb-unit
[0/1] Running lldb unit test suite

Testing Time: 10.45s
  Passed: 1044
```

Reviewed By: DavidSpickett

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

Added: 
lldb/unittests/Instruction/LoongArch/TestLoongArchEmulator.cpp

Modified: 
lldb/source/Plugins/Instruction/LoongArch/EmulateInstructionLoongArch.cpp
lldb/source/Plugins/Instruction/LoongArch/EmulateInstructionLoongArch.h
lldb/unittests/Instruction/CMakeLists.txt

Removed: 




diff  --git 
a/lldb/source/Plugins/Instruction/LoongArch/EmulateInstructionLoongArch.cpp 
b/lldb/source/Plugins/Instruction/LoongArch/EmulateInstructionLoongArch.cpp
index fb0317acc91af..c17da8b25aa31 100644
--- a/lldb/source/Plugins/Instruction/LoongArch/EmulateInstructionLoongArch.cpp
+++ b/lldb/source/Plugins/Instruction/LoongArch/EmulateInstructionLoongArch.cpp
@@ -68,6 +68,16 @@ 
EmulateInstructionLoongArch::GetOpcodeForInstruction(uint32_t inst) {
   return nullptr;
 }
 
+bool EmulateInstructionLoongArch::TestExecute(uint32_t inst) {
+  Opcode *opcode_data = GetOpcodeForInstruction(inst);
+  if (!opcode_data)
+return false;
+  // Call the Emulate... function.
+  if (!(this->*opcode_data->callback)(inst))
+return false;
+  return true;
+}
+
 bool EmulateInstructionLoongArch::EvaluateInstruction(uint32_t options) {
   uint32_t inst_size = m_opcode.GetByteSize();
   uint32_t inst = m_opcode.GetOpcode32();

diff  --git 
a/lldb/source/Plugins/Instruction/LoongArch/EmulateInstructionLoongArch.h 
b/lldb/source/Plugins/Instruction/LoongArch/EmulateInstructionLoongArch.h
index e5193dfad7db0..15da499261b05 100644
--- a/lldb/source/Plugins/Instruction/LoongArch/EmulateInstructionLoongArch.h
+++ b/lldb/source/Plugins/Instruction/LoongArch/EmulateInstructionLoongArch.h
@@ -60,6 +60,7 @@ class EmulateInstructionLoongArch : public EmulateInstruction 
{
   lldb::addr_t ReadPC(bool *success);
   bool WritePC(lldb::addr_t pc);
   bool IsLoongArch64() { return m_arch_subtype == llvm::Triple::loongarch64; }
+  bool TestExecute(uint32_t inst);
 
 private:
   struct Opcode {

diff  --git a/lldb/unittests/Instruction/CMakeLists.txt 
b/lldb/unittests/Instruction/CMakeLists.txt
index 1d011d5f7c5b8..7b1f8afce6b29 100644
--- a/lldb/unittests/Instruction/CMakeLists.txt
+++ b/lldb/unittests/Instruction/CMakeLists.txt
@@ -1,5 +1,6 @@
 add_lldb_unittest(EmulatorTests
   ARM64/TestAArch64Emulator.cpp
+  LoongArch/TestLoongArchEmulator.cpp
   RISCV/TestRISCVEmulator.cpp
 
   LINK_LIBS
@@ -7,8 +8,9 @@ add_lldb_unittest(EmulatorTests
 lldbSymbol
 lldbTarget
 lldbPluginInstructionARM64
+lldbPluginInstructionLoongArch
 lldbPluginInstructionRISCV
 
   LINK_COMPONENTS
 Support
-  )
\ No newline at end of file
+  )

diff  --git a/lldb/unittests/Instruction/LoongArch/TestLoongArchEmulator.cpp 
b/lldb/unittests/Instruction/LoongArch/TestLoongArchEmulator.cpp
new file mode 100644
index 0..af16559161507
--- /dev/null
+++ b/lldb/unittests/Instruction/LoongArch/TestLoongArchEmulator.cpp
@@ -0,0 +1,230 @@
+//===-- TestLoongArchEmulator.cpp 
-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "lldb/Core/Address.h"
+#include "lldb/Core/Disassembler.h"
+#include "lldb/Core/PluginManager.h"
+#include "lldb/Target/ExecutionContext.h"
+#include "lldb/Utility/ArchSpec.h"
+#include "lldb/Utility/RegisterValue.h"
+#include "gtest/gtest.h"
+
+#include "Plugins/Instruction/LoongArch/EmulateInstructionLoongArch.h"
+#include "Plugins/Process/Utility/RegisterInfoPOSIX_loongarch64.h"
+#include "Plugins/Process/Utility/lldb-loongarch-register-enums.h"
+
+using namespace llvm;
+using namespace lldb;
+using namespace lldb_private;
+
+#define GEN_BCOND_TEST(bit, name, rj_val, rd_val_branched, rd_val_continued)   
\
+  TEST_F(LoongArch##bit##EmulatorTester, test##name##branched) {   
\
+testBcondBranch(this, name, true, rj_val, rd_val_branched);
\
+  }
\
+

[Lldb-commits] [PATCH] D141245: [LLDB][LoongArch] ObjectFile: add a case for `EM_LOONGARCH`

2023-01-12 Thread Lu Weining via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGd52582b6b7df: [LLDB][LoongArch] ObjectFile: add a case for 
`EM_LOONGARCH` (authored by lh03061238, committed by SixWeining).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141245

Files:
  lldb/source/Plugins/ObjectFile/ELF/ELFHeader.cpp


Index: lldb/source/Plugins/ObjectFile/ELF/ELFHeader.cpp
===
--- lldb/source/Plugins/ObjectFile/ELF/ELFHeader.cpp
+++ lldb/source/Plugins/ObjectFile/ELF/ELFHeader.cpp
@@ -211,6 +211,9 @@
   case EM_RISCV:
 slot = R_RISCV_JUMP_SLOT;
 break;
+  case EM_LOONGARCH:
+slot = R_LARCH_JUMP_SLOT;
+break;
   }
 
   return slot;


Index: lldb/source/Plugins/ObjectFile/ELF/ELFHeader.cpp
===
--- lldb/source/Plugins/ObjectFile/ELF/ELFHeader.cpp
+++ lldb/source/Plugins/ObjectFile/ELF/ELFHeader.cpp
@@ -211,6 +211,9 @@
   case EM_RISCV:
 slot = R_RISCV_JUMP_SLOT;
 break;
+  case EM_LOONGARCH:
+slot = R_LARCH_JUMP_SLOT;
+break;
   }
 
   return slot;
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D140386: [LLDB][LoongArch] Add unittests for EmulateInstructionLoongArch

2023-01-12 Thread Lu Weining via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG1eaadaea5090: [LLDB][LoongArch] Add unittests for 
EmulateInstructionLoongArch (authored by lh03061238, committed by SixWeining).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140386

Files:
  lldb/source/Plugins/Instruction/LoongArch/EmulateInstructionLoongArch.cpp
  lldb/source/Plugins/Instruction/LoongArch/EmulateInstructionLoongArch.h
  lldb/unittests/Instruction/CMakeLists.txt
  lldb/unittests/Instruction/LoongArch/TestLoongArchEmulator.cpp

Index: lldb/unittests/Instruction/LoongArch/TestLoongArchEmulator.cpp
===
--- /dev/null
+++ lldb/unittests/Instruction/LoongArch/TestLoongArchEmulator.cpp
@@ -0,0 +1,230 @@
+//===-- TestLoongArchEmulator.cpp -===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "lldb/Core/Address.h"
+#include "lldb/Core/Disassembler.h"
+#include "lldb/Core/PluginManager.h"
+#include "lldb/Target/ExecutionContext.h"
+#include "lldb/Utility/ArchSpec.h"
+#include "lldb/Utility/RegisterValue.h"
+#include "gtest/gtest.h"
+
+#include "Plugins/Instruction/LoongArch/EmulateInstructionLoongArch.h"
+#include "Plugins/Process/Utility/RegisterInfoPOSIX_loongarch64.h"
+#include "Plugins/Process/Utility/lldb-loongarch-register-enums.h"
+
+using namespace llvm;
+using namespace lldb;
+using namespace lldb_private;
+
+#define GEN_BCOND_TEST(bit, name, rj_val, rd_val_branched, rd_val_continued)   \
+  TEST_F(LoongArch##bit##EmulatorTester, test##name##branched) {   \
+testBcondBranch(this, name, true, rj_val, rd_val_branched);\
+  }\
+  TEST_F(LoongArch##bit##EmulatorTester, test##name##continued) {  \
+testBcondBranch(this, name, false, rj_val, rd_val_continued);  \
+  }
+
+#define GEN_BZCOND_TEST(bit, name, rj_val_branched, rj_val_continued)  \
+  TEST_F(LoongArch##bit##EmulatorTester, test##name##branched) {   \
+testBZcondBranch(this, name, true, rj_val_branched);   \
+  }\
+  TEST_F(LoongArch##bit##EmulatorTester, test##name##continued) {  \
+testBZcondBranch(this, name, false, rj_val_continued); \
+  }
+
+struct LoongArch64EmulatorTester : public EmulateInstructionLoongArch,
+   testing::Test {
+  RegisterInfoPOSIX_loongarch64::GPR gpr;
+  RegisterInfoPOSIX_loongarch64::FPR fpr;
+
+  LoongArch64EmulatorTester(
+  std::string triple = "loongarch64-unknown-linux-gnu")
+  : EmulateInstructionLoongArch(ArchSpec(triple)) {
+EmulateInstruction::SetReadRegCallback(ReadRegisterCallback);
+EmulateInstruction::SetWriteRegCallback(WriteRegisterCallback);
+  }
+
+  static bool ReadRegisterCallback(EmulateInstruction *instruction, void *baton,
+   const RegisterInfo *reg_info,
+   RegisterValue ®_value) {
+LoongArch64EmulatorTester *tester =
+(LoongArch64EmulatorTester *)instruction;
+uint32_t reg = reg_info->kinds[eRegisterKindLLDB];
+if (reg >= gpr_r0_loongarch && reg <= gpr_r31_loongarch)
+  reg_value.SetUInt(tester->gpr.gpr[reg], reg_info->byte_size);
+else if (reg == gpr_orig_a0_loongarch)
+  reg_value.SetUInt(tester->gpr.orig_a0, reg_info->byte_size);
+else if (reg == gpr_pc_loongarch)
+  reg_value.SetUInt(tester->gpr.csr_era, reg_info->byte_size);
+else if (reg == gpr_badv_loongarch)
+  reg_value.SetUInt(tester->gpr.csr_badv, reg_info->byte_size);
+else if (reg == fpr_first_loongarch + 32)
+  // fcc0
+  reg_value.SetUInt(tester->fpr.fcc, reg_info->byte_size);
+return true;
+  }
+
+  static bool WriteRegisterCallback(EmulateInstruction *instruction,
+void *baton, const Context &context,
+const RegisterInfo *reg_info,
+const RegisterValue ®_value) {
+LoongArch64EmulatorTester *tester =
+(LoongArch64EmulatorTester *)instruction;
+uint32_t reg = reg_info->kinds[eRegisterKindLLDB];
+if (reg >= gpr_r0_loongarch && reg <= gpr_r31_loongarch)
+  tester->gpr.gpr[reg] = reg_value.GetAsUInt64();
+else if (reg == gpr_orig_a0_loongarch)
+  tester->gpr.orig_a0 = reg_value.GetAsUInt64();
+else if (reg == gpr_pc_loongarch)
+  tester->gpr.csr_era = reg_value.GetAsUInt64();
+

[Lldb-commits] [PATCH] D140615: [LLDB][LoongArch] Delete the s9 register alias definition

2023-01-12 Thread Hui Li via Phabricator via lldb-commits
lh03061238 added a comment.



In D140615#4047171 , @lh03061238 
wrote:

> In D140615#4047069 , @xen0n wrote:
>
>> BTW do we have a way of fixing the bug while preserving the alias?
>
> The register information defined in registerinfos_longarch64.h contains only 
> one alias.
> So far, no other way has been found, Therefore, We first fixed this bug by 
> removing the 
> less used alias s9

At this stage, we want to ensure that register number mappings are correct in 
all relevant register definition files.
So make this change to ensure that the register access is correct. 
is this ok ?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140615

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


[Lldb-commits] [PATCH] D140800: [OptTable] Precompute OptTable prefixes union table through tablegen

2023-01-12 Thread Nico Weber via Phabricator via lldb-commits
thakis added a comment.

Thanks for this change :)




Comment at: clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp:141
 
-class WrapperOptTable : public opt::OptTable {
+class WrapperOptTable : public opt::GenericOptTable {
 public:

C



Comment at: llvm/include/llvm/Option/OptTable.h:257
+/// Specialization of OptTable
+class GenericOptTable : public OptTable {
+  SmallVector PrefixesUnionBuffer;

(nit, kind of too late now: I would've renamed the base class to `BaseOptTable` 
or what and kept `OptTable` for this one, so that all the tools wouldn't have 
to be touched at all.)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140800

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


[Lldb-commits] [PATCH] D140800: [OptTable] Precompute OptTable prefixes union table through tablegen

2023-01-12 Thread Nico Weber via Phabricator via lldb-commits
thakis added inline comments.



Comment at: clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp:141
 
-class WrapperOptTable : public opt::OptTable {
+class WrapperOptTable : public opt::GenericOptTable {
 public:

thakis wrote:
> C
…not sure what this was, please ignore :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140800

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


[Lldb-commits] [lldb] 6b26e1d - [lldb/crashlog] Refactor CrashLogParser into a Factory pattern

2023-01-12 Thread Med Ismail Bennani via lldb-commits

Author: Med Ismail Bennani
Date: 2023-01-12T19:20:51-08:00
New Revision: 6b26e1dad9608ec188446dcdc0734a7b41cf145b

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

LOG: [lldb/crashlog] Refactor CrashLogParser into a Factory pattern

This patch should fix an undefined behaviour that's happening when
parsing a crash report from an IDE. In the previous implementation, the
CrashLogParser base class would use the `__new__` static class method to
create the right parser instance depending on the crash report type.

For some reasons, the derived parser initializer wouldn't be called when
running the command from an IDE, so this patch refactors the
CrashLogParser code to replace the use of the `__new__` method with a
factory `create` static method.

rdar://100527640

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

Signed-off-by: Med Ismail Bennani 

Added: 


Modified: 
lldb/examples/python/crashlog.py
lldb/examples/python/scripted_process/crashlog_scripted_process.py

Removed: 




diff  --git a/lldb/examples/python/crashlog.py 
b/lldb/examples/python/crashlog.py
index b62ebd758f22..d9e037057e67 100755
--- a/lldb/examples/python/crashlog.py
+++ b/lldb/examples/python/crashlog.py
@@ -417,15 +417,15 @@ class InteractiveCrashLogException(Exception):
 pass
 
 class CrashLogParser:
-"CrashLog parser base class and factory."
-def __new__(cls, debugger, path, verbose):
+@staticmethod
+def create(debugger, path, verbose):
 data = JSONCrashLogParser.is_valid_json(path)
 if data:
-self = object.__new__(JSONCrashLogParser)
-self.data = data
-return self
+parser = JSONCrashLogParser(debugger, path, verbose)
+parser.data = data
+return parser
 else:
-return object.__new__(TextCrashLogParser)
+return TextCrashLogParser(debugger, path, verbose)
 
 def __init__(self, debugger, path, verbose):
 self.path = os.path.expanduser(path)
@@ -1076,7 +1076,7 @@ def load_crashlog_in_scripted_process(debugger, 
crash_log_file, options, result)
 if not os.path.exists(crashlog_path):
 raise InteractiveCrashLogException("crashlog file %s does not exist" % 
crashlog_path)
 
-crashlog = CrashLogParser(debugger, crashlog_path, False).parse()
+crashlog = CrashLogParser.create(debugger, crashlog_path, False).parse()
 
 target = lldb.SBTarget()
 # 1. Try to use the user-provided target
@@ -1332,7 +1332,7 @@ def should_run_in_interactive_mode(options, ci):
 except InteractiveCrashLogException as e:
 result.SetError(str(e))
 else:
-crash_log = CrashLogParser(debugger, crash_log_file, 
options.verbose).parse()
+crash_log = CrashLogParser.create(debugger, crash_log_file, 
options.verbose).parse()
 SymbolicateCrashLog(crash_log, options)
 
 if __name__ == '__main__':

diff  --git 
a/lldb/examples/python/scripted_process/crashlog_scripted_process.py 
b/lldb/examples/python/scripted_process/crashlog_scripted_process.py
index eddf96786d9e..dfb32aae6d3f 100644
--- a/lldb/examples/python/scripted_process/crashlog_scripted_process.py
+++ b/lldb/examples/python/scripted_process/crashlog_scripted_process.py
@@ -10,7 +10,7 @@
 
 class CrashLogScriptedProcess(ScriptedProcess):
 def parse_crashlog(self):
-crashlog_parser = CrashLogParser(self.dbg, self.crashlog_path, False)
+crashlog_parser = CrashLogParser.create(self.dbg, self.crashlog_path, 
False)
 crash_log = crashlog_parser.parse()
 
 self.pid = crash_log.process_id



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


[Lldb-commits] [lldb] 44b81f6 - [lldb/Process] Populate queues in Scripted Process

2023-01-12 Thread Med Ismail Bennani via lldb-commits

Author: Med Ismail Bennani
Date: 2023-01-12T19:20:51-08:00
New Revision: 44b81f621c41ce21b1a1352d9bd7b7e7a8b0179e

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

LOG: [lldb/Process] Populate queues in Scripted Process

This patch enhances queue support in Scripted Processes.

Scripted Threads could already report their queue name if they had one,
but this information was only surfaced when getting the process and
thread status.

However, no queue was create and added to the scripted process queue
list. This patch improves that by creating a queue from the scripted
thread queue name. For now, it uses an invalid queue id, since the
scripted thread doesn't expose this capability yet, but this could
easily be supported if the queue id information is available.

rdar://98844004

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

Signed-off-by: Med Ismail Bennani 

Added: 


Modified: 
lldb/include/lldb/Target/Process.h
lldb/source/Plugins/Process/scripted/ScriptedProcess.cpp
lldb/source/Plugins/Process/scripted/ScriptedProcess.h

Removed: 




diff  --git a/lldb/include/lldb/Target/Process.h 
b/lldb/include/lldb/Target/Process.h
index 8bb8b85e22fb..ca7f4b545e31 100644
--- a/lldb/include/lldb/Target/Process.h
+++ b/lldb/include/lldb/Target/Process.h
@@ -2116,7 +2116,7 @@ class Process : public 
std::enable_shared_from_this,
 
   // Queue Queries
 
-  void UpdateQueueListIfNeeded();
+  virtual void UpdateQueueListIfNeeded();
 
   QueueList &GetQueueList() {
 UpdateQueueListIfNeeded();

diff  --git a/lldb/source/Plugins/Process/scripted/ScriptedProcess.cpp 
b/lldb/source/Plugins/Process/scripted/ScriptedProcess.cpp
index 576e62022098..58629a5406f6 100644
--- a/lldb/source/Plugins/Process/scripted/ScriptedProcess.cpp
+++ b/lldb/source/Plugins/Process/scripted/ScriptedProcess.cpp
@@ -20,6 +20,7 @@
 #include "lldb/Interpreter/ScriptInterpreter.h"
 #include "lldb/Interpreter/ScriptedMetadata.h"
 #include "lldb/Target/MemoryRegionInfo.h"
+#include "lldb/Target/Queue.h"
 #include "lldb/Target/RegisterContext.h"
 #include "lldb/Utility/LLDBLog.h"
 #include "lldb/Utility/State.h"
@@ -497,6 +498,17 @@ lldb_private::StructuredData::DictionarySP 
ScriptedProcess::GetMetadata() {
   return metadata_sp;
 }
 
+void ScriptedProcess::UpdateQueueListIfNeeded() {
+  CheckInterpreterAndScriptObject();
+  for (ThreadSP thread_sp : Threads()) {
+if (const char *queue_name = thread_sp->GetQueueName()) {
+  QueueSP queue_sp = std::make_shared(
+  m_process->shared_from_this(), thread_sp->GetQueueID(), queue_name);
+  m_queue_list.AddQueue(queue_sp);
+}
+  }
+}
+
 ScriptedProcessInterface &ScriptedProcess::GetInterface() const {
   return m_interpreter->GetScriptedProcessInterface();
 }

diff  --git a/lldb/source/Plugins/Process/scripted/ScriptedProcess.h 
b/lldb/source/Plugins/Process/scripted/ScriptedProcess.h
index 350c42772476..6e13e68c4828 100644
--- a/lldb/source/Plugins/Process/scripted/ScriptedProcess.h
+++ b/lldb/source/Plugins/Process/scripted/ScriptedProcess.h
@@ -72,6 +72,8 @@ class ScriptedProcess : public Process {
 
   lldb_private::StructuredData::DictionarySP GetMetadata() override;
 
+  void UpdateQueueListIfNeeded() override;
+
 protected:
   ScriptedProcess(lldb::TargetSP target_sp, lldb::ListenerSP listener_sp,
   const ScriptedMetadata &scripted_metadata, Status &error);



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


[Lldb-commits] [lldb] c3b471c - [lldb] Force override when adding crashlog command

2023-01-12 Thread Med Ismail Bennani via lldb-commits

Author: Med Ismail Bennani
Date: 2023-01-12T19:20:51-08:00
New Revision: c3b471c0be4f6b5a22afe10f95ff75bf1744d66e

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

LOG: [lldb] Force override when adding crashlog command

When using interactive crashlog from an IDE, it can happen that the user
already have the `command script import lldb.macosx.crashlog` command on
their `lldbinit` file.

That leads to showing some message:

```
error: cannot add command: user command exists and force replace not set
error: cannot add command: user command exists and force replace not set
```

This leads to confusion because the crashlog symbolication continues and
succeeds even after these errors.

To address that, the crashlog commands get overridden everytime the
script get re-imported.

rdar://103403943

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

Signed-off-by: Med Ismail Bennani 

Added: 


Modified: 
lldb/examples/python/crashlog.py

Removed: 




diff  --git a/lldb/examples/python/crashlog.py 
b/lldb/examples/python/crashlog.py
index d9e037057e67..6a5c560238ee 100755
--- a/lldb/examples/python/crashlog.py
+++ b/lldb/examples/python/crashlog.py
@@ -1344,8 +1344,8 @@ def should_run_in_interactive_mode(options, ci):
 
 def __lldb_init_module(debugger, internal_dict):
 debugger.HandleCommand(
-'command script add -c lldb.macosx.crashlog.Symbolicate crashlog')
+'command script add -o -c lldb.macosx.crashlog.Symbolicate crashlog')
 debugger.HandleCommand(
-'command script add -f lldb.macosx.crashlog.save_crashlog 
save_crashlog')
+'command script add -o -f lldb.macosx.crashlog.save_crashlog 
save_crashlog')
 print('"crashlog" and "save_crashlog" commands have been installed, use '
   'the "--help" options on these commands for detailed help.')



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


[Lldb-commits] [lldb] e3930e7 - [lldb] Update custom commands to always be overrriden

2023-01-12 Thread Med Ismail Bennani via lldb-commits

Author: Med Ismail Bennani
Date: 2023-01-12T19:20:51-08:00
New Revision: e3930e77fc5b626a3c6b95f08ed25a3f8807c579

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

LOG: [lldb] Update custom commands to always be overrriden

This is a follow-up patch to 6f7835f309b9.

As explained previously, when running from an IDE, it can happen that
the IDE imports some lldb scripts by itself. If the user also tries to
import these commands, lldb will show the following message:

```
error: cannot add command: user command exists and force replace not set
```

This message is confusing to the user, because it suggests that the
command import failed and that the execution should stop. However, in
this case, lldb will continue the execution with the command added
previously by the user.

To prevent that, this patch updates every first-party lldb-packaged
custom commands to override commands that were pre-imported in lldb.

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

Signed-off-by: Med Ismail Bennani 

Added: 


Modified: 
lldb/examples/darwin/heap_find/heap.py
lldb/examples/python/bsd.py
lldb/examples/python/cmdtemplate.py
lldb/examples/python/delta.py
lldb/examples/python/diagnose_nsstring.py
lldb/examples/python/diagnose_unwind.py
lldb/examples/python/disassembly_mode.py
lldb/examples/python/gdb_disassemble.py
lldb/examples/python/gdbremote.py
lldb/examples/python/jump.py
lldb/examples/python/lldb_module_utils.py
lldb/examples/python/memory.py
lldb/examples/python/sources.py
lldb/examples/python/stacks.py
lldb/examples/python/step_and_print.py
lldb/examples/python/types.py

Removed: 




diff  --git a/lldb/examples/darwin/heap_find/heap.py 
b/lldb/examples/darwin/heap_find/heap.py
index 2021b9ebc8e2..38b549ca330b 100644
--- a/lldb/examples/darwin/heap_find/heap.py
+++ b/lldb/examples/darwin/heap_find/heap.py
@@ -1503,19 +1503,19 @@ def __lldb_init_module(debugger, internal_dict):
 malloc_info.__doc__ = get_malloc_info_options().format_help()
 objc_refs.__doc__ = get_objc_refs_options().format_help()
 debugger.HandleCommand(
-'command script add -f %s.ptr_refs ptr_refs' %
+'command script add -o -f %s.ptr_refs ptr_refs' %
 __name__)
 debugger.HandleCommand(
-'command script add -f %s.cstr_refs cstr_refs' %
+'command script add -o -f %s.cstr_refs cstr_refs' %
 __name__)
 debugger.HandleCommand(
-'command script add -f %s.malloc_info malloc_info' %
+'command script add -o -f %s.malloc_info malloc_info' %
 __name__)
 debugger.HandleCommand(
-'command script add -f %s.find_variable find_variable' %
+'command script add -o -f %s.find_variable find_variable' %
 __name__)
-# debugger.HandleCommand('command script add -f %s.section_ptr_refs 
section_ptr_refs' % package_name)
+# debugger.HandleCommand('command script add -o -f %s.section_ptr_refs 
section_ptr_refs' % package_name)
 debugger.HandleCommand(
-'command script add -f %s.objc_refs objc_refs' %
+'command script add -o -f %s.objc_refs objc_refs' %
 __name__)
 print('"malloc_info", "ptr_refs", "cstr_refs", "find_variable", and 
"objc_refs" commands have been installed, use the "--help" options on these 
commands for detailed help.')

diff  --git a/lldb/examples/python/bsd.py b/lldb/examples/python/bsd.py
index 34716a3d9003..6dc5f735dc98 100755
--- a/lldb/examples/python/bsd.py
+++ b/lldb/examples/python/bsd.py
@@ -558,7 +558,7 @@ def __lldb_init_module(debugger, dict):
 # interpreter.
 # Add any commands contained in this module to LLDB
 debugger.HandleCommand(
-'command script add -c %s.VerifyDebugMapCommand %s' % (
+'command script add -o -c %s.VerifyDebugMapCommand %s' % (
 __name__, VerifyDebugMapCommand.name))
 print('The "%s" command has been installed, type "help %s" for detailed '
   'help.' % (VerifyDebugMapCommand.name, VerifyDebugMapCommand.name))

diff  --git a/lldb/examples/python/cmdtemplate.py 
b/lldb/examples/python/cmdtemplate.py
index 9ce930d4ef76..439452a86cad 100644
--- a/lldb/examples/python/cmdtemplate.py
+++ b/lldb/examples/python/cmdtemplate.py
@@ -24,7 +24,7 @@ def register_lldb_command(cls, debugger, module_name):
 parser = cls.create_options()
 cls.__doc__ = parser.format_help()
 # Add any commands contained in this module to LLDB
-command = 'command script add -c %s.%s %s' % (module_name,
+command = 'command script add -o -c %s.%s %s' % (module_name,
   cls.__name__,
   cls.program)
 deb

[Lldb-commits] [lldb] 8f549c5 - [lldb/test] Fix data racing issue in TestStackCoreScriptedProcess

2023-01-12 Thread Med Ismail Bennani via lldb-commits

Author: Med Ismail Bennani
Date: 2023-01-12T19:20:51-08:00
New Revision: 8f549c5329275293ced1d5eb87a1cf8b3d52a794

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

LOG: [lldb/test] Fix data racing issue in TestStackCoreScriptedProcess

This patch should fix an nondeterministic error in TestStackCoreScriptedProcess.

In order to test both the multithreading capability and shared library
loading in Scripted Processes, the test would create multiple threads
that would take the same variable as a reference.

The first thread would alter the value and the second thread would
monitor the value until it gets altered. This assumed a certain ordering
regarding the `std::thread` spawning, however the ordering was not
always guaranteed at runtime.

To fix that, the test now makes use of a `std::condition_variable`
shared between the each thread. On the former, it will notify the other
thread when the variable gets initialized or updated and on the latter,
it will wait until the variable it receives a new notification.

This should fix the data racing issue while preserving the testing
coverage.

rdar://98678134

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

Signed-off-by: Med Ismail Bennani 

Added: 
lldb/test/API/functionalities/scripted_process/baz.cpp

Modified: 
lldb/test/API/functionalities/scripted_process/Makefile

lldb/test/API/functionalities/scripted_process/TestStackCoreScriptedProcess.py
lldb/test/API/functionalities/scripted_process/baz.h
lldb/test/API/functionalities/scripted_process/main.cpp

Removed: 
lldb/test/API/functionalities/scripted_process/baz.c



diff  --git a/lldb/test/API/functionalities/scripted_process/Makefile 
b/lldb/test/API/functionalities/scripted_process/Makefile
index ca7f8f7d6d82..c23310226d87 100644
--- a/lldb/test/API/functionalities/scripted_process/Makefile
+++ b/lldb/test/API/functionalities/scripted_process/Makefile
@@ -6,8 +6,8 @@ override ARCH := $(shell uname -m)
 
 all: libbaz.dylib a.out
 
-libbaz.dylib: baz.c
+libbaz.dylib: baz.cpp
$(MAKE) -f $(MAKEFILE_RULES) ARCH=$(ARCH) \
-   DYLIB_ONLY=YES DYLIB_NAME=baz DYLIB_C_SOURCES=baz.c
+   DYLIB_ONLY=YES DYLIB_NAME=baz DYLIB_CXX_SOURCES=baz.cpp
 
 include Makefile.rules

diff  --git 
a/lldb/test/API/functionalities/scripted_process/TestStackCoreScriptedProcess.py
 
b/lldb/test/API/functionalities/scripted_process/TestStackCoreScriptedProcess.py
index 7a6a7ddb4b77..8555faf67226 100644
--- 
a/lldb/test/API/functionalities/scripted_process/TestStackCoreScriptedProcess.py
+++ 
b/lldb/test/API/functionalities/scripted_process/TestStackCoreScriptedProcess.py
@@ -17,7 +17,7 @@ class StackCoreScriptedProcesTestCase(TestBase):
 def create_stack_skinny_corefile(self, file):
 self.build()
 target, process, thread, _ = lldbutil.run_to_source_breakpoint(self, 
"// break here",
-   
lldb.SBFileSpec("baz.c"))
+   
lldb.SBFileSpec("baz.cpp"))
 self.assertTrue(process.IsValid(), "Process is invalid.")
 # FIXME: Use SBAPI to save the process corefile.
 self.runCmd("process save-core -s stack  " + file)
@@ -109,9 +109,9 @@ def cleanup():
 self.assertTrue(func, "Invalid function.")
 
 self.assertIn("baz", frame.GetFunctionName())
-self.assertEqual(frame.vars.GetSize(), 2)
-self.assertEqual(int(frame.vars.GetFirstValueByName('j').GetValue()), 
42 * 42)
+self.assertGreater(frame.vars.GetSize(), 0)
 self.assertEqual(int(frame.vars.GetFirstValueByName('k').GetValue()), 
42)
+
self.assertEqual(int(frame.vars.GetFirstValueByName('j').Dereference().GetValue()),
 42 * 42)
 
 corefile_dylib = self.get_module_with_name(corefile_target, 
'libbaz.dylib')
 self.assertTrue(corefile_dylib, "Dynamic library libbaz.dylib not 
found.")

diff  --git a/lldb/test/API/functionalities/scripted_process/baz.c 
b/lldb/test/API/functionalities/scripted_process/baz.c
deleted file mode 100644
index cfd452e7779c..
--- a/lldb/test/API/functionalities/scripted_process/baz.c
+++ /dev/null
@@ -1,8 +0,0 @@
-#include "baz.h"
-
-#include 
-
-int baz(int j) {
-  int k = sqrt(j);
-  return k; // break here
-}

diff  --git a/lldb/test/API/functionalities/scripted_process/baz.cpp 
b/lldb/test/API/functionalities/scripted_process/baz.cpp
new file mode 100644
index ..e94b99454009
--- /dev/null
+++ b/lldb/test/API/functionalities/scripted_process/baz.cpp
@@ -0,0 +1,10 @@
+#include "baz.h"
+
+#include 
+
+int baz(int &j, std::mutex &mutex, std::condition_variable &cv) {
+  std::unique_lock lock(mutex);
+  cv.wait(lock, [&j] { return j

[Lldb-commits] [PATCH] D139951: [lldb/crashlog] Refactor CrashLogParser into a Factory pattern

2023-01-12 Thread Med Ismail Bennani via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG6b26e1dad960: [lldb/crashlog] Refactor CrashLogParser into a 
Factory pattern (authored by mib).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139951

Files:
  lldb/examples/python/crashlog.py
  lldb/examples/python/scripted_process/crashlog_scripted_process.py


Index: lldb/examples/python/scripted_process/crashlog_scripted_process.py
===
--- lldb/examples/python/scripted_process/crashlog_scripted_process.py
+++ lldb/examples/python/scripted_process/crashlog_scripted_process.py
@@ -10,7 +10,7 @@
 
 class CrashLogScriptedProcess(ScriptedProcess):
 def parse_crashlog(self):
-crashlog_parser = CrashLogParser(self.dbg, self.crashlog_path, False)
+crashlog_parser = CrashLogParser.create(self.dbg, self.crashlog_path, 
False)
 crash_log = crashlog_parser.parse()
 
 self.pid = crash_log.process_id
Index: lldb/examples/python/crashlog.py
===
--- lldb/examples/python/crashlog.py
+++ lldb/examples/python/crashlog.py
@@ -417,15 +417,15 @@
 pass
 
 class CrashLogParser:
-"CrashLog parser base class and factory."
-def __new__(cls, debugger, path, verbose):
+@staticmethod
+def create(debugger, path, verbose):
 data = JSONCrashLogParser.is_valid_json(path)
 if data:
-self = object.__new__(JSONCrashLogParser)
-self.data = data
-return self
+parser = JSONCrashLogParser(debugger, path, verbose)
+parser.data = data
+return parser
 else:
-return object.__new__(TextCrashLogParser)
+return TextCrashLogParser(debugger, path, verbose)
 
 def __init__(self, debugger, path, verbose):
 self.path = os.path.expanduser(path)
@@ -1076,7 +1076,7 @@
 if not os.path.exists(crashlog_path):
 raise InteractiveCrashLogException("crashlog file %s does not exist" % 
crashlog_path)
 
-crashlog = CrashLogParser(debugger, crashlog_path, False).parse()
+crashlog = CrashLogParser.create(debugger, crashlog_path, False).parse()
 
 target = lldb.SBTarget()
 # 1. Try to use the user-provided target
@@ -1332,7 +1332,7 @@
 except InteractiveCrashLogException as e:
 result.SetError(str(e))
 else:
-crash_log = CrashLogParser(debugger, crash_log_file, 
options.verbose).parse()
+crash_log = CrashLogParser.create(debugger, crash_log_file, 
options.verbose).parse()
 SymbolicateCrashLog(crash_log, options)
 
 if __name__ == '__main__':


Index: lldb/examples/python/scripted_process/crashlog_scripted_process.py
===
--- lldb/examples/python/scripted_process/crashlog_scripted_process.py
+++ lldb/examples/python/scripted_process/crashlog_scripted_process.py
@@ -10,7 +10,7 @@
 
 class CrashLogScriptedProcess(ScriptedProcess):
 def parse_crashlog(self):
-crashlog_parser = CrashLogParser(self.dbg, self.crashlog_path, False)
+crashlog_parser = CrashLogParser.create(self.dbg, self.crashlog_path, False)
 crash_log = crashlog_parser.parse()
 
 self.pid = crash_log.process_id
Index: lldb/examples/python/crashlog.py
===
--- lldb/examples/python/crashlog.py
+++ lldb/examples/python/crashlog.py
@@ -417,15 +417,15 @@
 pass
 
 class CrashLogParser:
-"CrashLog parser base class and factory."
-def __new__(cls, debugger, path, verbose):
+@staticmethod
+def create(debugger, path, verbose):
 data = JSONCrashLogParser.is_valid_json(path)
 if data:
-self = object.__new__(JSONCrashLogParser)
-self.data = data
-return self
+parser = JSONCrashLogParser(debugger, path, verbose)
+parser.data = data
+return parser
 else:
-return object.__new__(TextCrashLogParser)
+return TextCrashLogParser(debugger, path, verbose)
 
 def __init__(self, debugger, path, verbose):
 self.path = os.path.expanduser(path)
@@ -1076,7 +1076,7 @@
 if not os.path.exists(crashlog_path):
 raise InteractiveCrashLogException("crashlog file %s does not exist" % crashlog_path)
 
-crashlog = CrashLogParser(debugger, crashlog_path, False).parse()
+crashlog = CrashLogParser.create(debugger, crashlog_path, False).parse()
 
 target = lldb.SBTarget()
 # 1. Try to use the user-provided target
@@ -1332,7 +1332,7 @@
 except InteractiveCrashLogException as e:
 result.SetError(str(e))
 else:
-crash_log = CrashLogParser(debugger,

[Lldb-commits] [PATCH] D139853: [lldb/Process] Populate queues in Scripted Process

2023-01-12 Thread Med Ismail Bennani via Phabricator via lldb-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG44b81f621c41: [lldb/Process] Populate queues in Scripted 
Process (authored by mib).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139853

Files:
  lldb/include/lldb/Target/Process.h
  lldb/source/Plugins/Process/scripted/ScriptedProcess.cpp
  lldb/source/Plugins/Process/scripted/ScriptedProcess.h


Index: lldb/source/Plugins/Process/scripted/ScriptedProcess.h
===
--- lldb/source/Plugins/Process/scripted/ScriptedProcess.h
+++ lldb/source/Plugins/Process/scripted/ScriptedProcess.h
@@ -72,6 +72,8 @@
 
   lldb_private::StructuredData::DictionarySP GetMetadata() override;
 
+  void UpdateQueueListIfNeeded() override;
+
 protected:
   ScriptedProcess(lldb::TargetSP target_sp, lldb::ListenerSP listener_sp,
   const ScriptedMetadata &scripted_metadata, Status &error);
Index: lldb/source/Plugins/Process/scripted/ScriptedProcess.cpp
===
--- lldb/source/Plugins/Process/scripted/ScriptedProcess.cpp
+++ lldb/source/Plugins/Process/scripted/ScriptedProcess.cpp
@@ -20,6 +20,7 @@
 #include "lldb/Interpreter/ScriptInterpreter.h"
 #include "lldb/Interpreter/ScriptedMetadata.h"
 #include "lldb/Target/MemoryRegionInfo.h"
+#include "lldb/Target/Queue.h"
 #include "lldb/Target/RegisterContext.h"
 #include "lldb/Utility/LLDBLog.h"
 #include "lldb/Utility/State.h"
@@ -497,6 +498,17 @@
   return metadata_sp;
 }
 
+void ScriptedProcess::UpdateQueueListIfNeeded() {
+  CheckInterpreterAndScriptObject();
+  for (ThreadSP thread_sp : Threads()) {
+if (const char *queue_name = thread_sp->GetQueueName()) {
+  QueueSP queue_sp = std::make_shared(
+  m_process->shared_from_this(), thread_sp->GetQueueID(), queue_name);
+  m_queue_list.AddQueue(queue_sp);
+}
+  }
+}
+
 ScriptedProcessInterface &ScriptedProcess::GetInterface() const {
   return m_interpreter->GetScriptedProcessInterface();
 }
Index: lldb/include/lldb/Target/Process.h
===
--- lldb/include/lldb/Target/Process.h
+++ lldb/include/lldb/Target/Process.h
@@ -2116,7 +2116,7 @@
 
   // Queue Queries
 
-  void UpdateQueueListIfNeeded();
+  virtual void UpdateQueueListIfNeeded();
 
   QueueList &GetQueueList() {
 UpdateQueueListIfNeeded();


Index: lldb/source/Plugins/Process/scripted/ScriptedProcess.h
===
--- lldb/source/Plugins/Process/scripted/ScriptedProcess.h
+++ lldb/source/Plugins/Process/scripted/ScriptedProcess.h
@@ -72,6 +72,8 @@
 
   lldb_private::StructuredData::DictionarySP GetMetadata() override;
 
+  void UpdateQueueListIfNeeded() override;
+
 protected:
   ScriptedProcess(lldb::TargetSP target_sp, lldb::ListenerSP listener_sp,
   const ScriptedMetadata &scripted_metadata, Status &error);
Index: lldb/source/Plugins/Process/scripted/ScriptedProcess.cpp
===
--- lldb/source/Plugins/Process/scripted/ScriptedProcess.cpp
+++ lldb/source/Plugins/Process/scripted/ScriptedProcess.cpp
@@ -20,6 +20,7 @@
 #include "lldb/Interpreter/ScriptInterpreter.h"
 #include "lldb/Interpreter/ScriptedMetadata.h"
 #include "lldb/Target/MemoryRegionInfo.h"
+#include "lldb/Target/Queue.h"
 #include "lldb/Target/RegisterContext.h"
 #include "lldb/Utility/LLDBLog.h"
 #include "lldb/Utility/State.h"
@@ -497,6 +498,17 @@
   return metadata_sp;
 }
 
+void ScriptedProcess::UpdateQueueListIfNeeded() {
+  CheckInterpreterAndScriptObject();
+  for (ThreadSP thread_sp : Threads()) {
+if (const char *queue_name = thread_sp->GetQueueName()) {
+  QueueSP queue_sp = std::make_shared(
+  m_process->shared_from_this(), thread_sp->GetQueueID(), queue_name);
+  m_queue_list.AddQueue(queue_sp);
+}
+  }
+}
+
 ScriptedProcessInterface &ScriptedProcess::GetInterface() const {
   return m_interpreter->GetScriptedProcessInterface();
 }
Index: lldb/include/lldb/Target/Process.h
===
--- lldb/include/lldb/Target/Process.h
+++ lldb/include/lldb/Target/Process.h
@@ -2116,7 +2116,7 @@
 
   // Queue Queries
 
-  void UpdateQueueListIfNeeded();
+  virtual void UpdateQueueListIfNeeded();
 
   QueueList &GetQueueList() {
 UpdateQueueListIfNeeded();
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D140293: [lldb] Update custom commands to always be overrriden

2023-01-12 Thread Med Ismail Bennani via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGe3930e77fc5b: [lldb] Update custom commands to always be 
overrriden (authored by mib).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140293

Files:
  lldb/examples/darwin/heap_find/heap.py
  lldb/examples/python/bsd.py
  lldb/examples/python/cmdtemplate.py
  lldb/examples/python/delta.py
  lldb/examples/python/diagnose_nsstring.py
  lldb/examples/python/diagnose_unwind.py
  lldb/examples/python/disassembly_mode.py
  lldb/examples/python/gdb_disassemble.py
  lldb/examples/python/gdbremote.py
  lldb/examples/python/jump.py
  lldb/examples/python/lldb_module_utils.py
  lldb/examples/python/memory.py
  lldb/examples/python/sources.py
  lldb/examples/python/stacks.py
  lldb/examples/python/step_and_print.py
  lldb/examples/python/types.py

Index: lldb/examples/python/types.py
===
--- lldb/examples/python/types.py
+++ lldb/examples/python/types.py
@@ -351,5 +351,5 @@
 
 def __lldb_init_module(debugger, internal_dict):
 debugger.HandleCommand(
-'command script add -f types.check_padding_command check_padding')
+'command script add -o -f types.check_padding_command check_padding')
 print('"check_padding" command installed, use the "--help" option for detailed help')
Index: lldb/examples/python/step_and_print.py
===
--- lldb/examples/python/step_and_print.py
+++ lldb/examples/python/step_and_print.py
@@ -21,4 +21,4 @@
 return "Does a step-over then runs frame variable passing the command args to it\n"
 
 def __lldb_init_module(debugger, unused):
-debugger.HandleCommand("command script add -c step_and_print.StepAndPrint sap")
+debugger.HandleCommand("command script add -o -c step_and_print.StepAndPrint sap")
Index: lldb/examples/python/stacks.py
===
--- lldb/examples/python/stacks.py
+++ lldb/examples/python/stacks.py
@@ -64,5 +64,5 @@
 
 def __lldb_init_module(debugger, internal_dict):
 debugger.HandleCommand(
-"command script add -f stacks.stack_frames stack_frames")
+"command script add -o -f stacks.stack_frames stack_frames")
 print("A new command called 'stack_frames' was added, type 'stack_frames --help' for more information.")
Index: lldb/examples/python/sources.py
===
--- lldb/examples/python/sources.py
+++ lldb/examples/python/sources.py
@@ -27,5 +27,5 @@
 def __lldb_init_module(debugger, dict):
 # Add any commands contained in this module to LLDB
 debugger.HandleCommand(
-'command script add -f sources.info_sources info_sources')
+'command script add -o -f sources.info_sources info_sources')
 print('The "info_sources" command has been installed, type "help info_sources" or "info_sources --help" for detailed help.')
Index: lldb/examples/python/memory.py
===
--- lldb/examples/python/memory.py
+++ lldb/examples/python/memory.py
@@ -272,5 +272,5 @@
 def __lldb_init_module(debugger, internal_dict):
 memfind_command.__doc__ = create_memfind_options().format_help()
 debugger.HandleCommand(
-'command script add -f memory.memfind_command memfind')
+'command script add -o -f memory.memfind_command memfind')
 print('"memfind" command installed, use the "--help" option for detailed help')
Index: lldb/examples/python/lldb_module_utils.py
===
--- lldb/examples/python/lldb_module_utils.py
+++ lldb/examples/python/lldb_module_utils.py
@@ -183,9 +183,9 @@
 
 # Add any commands contained in this module to LLDB
 debugger.HandleCommand(
-'command script add -c %s.DumpLineTables %s' % (__name__,
+'command script add -o -c %s.DumpLineTables %s' % (__name__,
 DumpLineTables.command_name))
 debugger.HandleCommand(
-'command script add -c %s.DumpFiles %s' % (__name__, DumpFiles.command_name))
+'command script add -o -c %s.DumpFiles %s' % (__name__, DumpFiles.command_name))
 print('The "%s" and "%s" commands have been installed.' % (DumpLineTables.command_name,
DumpFiles.command_name))
Index: lldb/examples/python/jump.py
===
--- lldb/examples/python/jump.py
+++ lldb/examples/python/jump.py
@@ -192,5 +192,5 @@
 def __lldb_init_module(debugger, internal_dict):
 # Module is being run inside the LLDB interpreter
 jump.__doc__ = usage_string()
-debugger.HandleCommand('command script add -f jump.jump jump')
+debugger.Handl

[Lldb-commits] [PATCH] D140113: [lldb] Force override when adding crashlog command

2023-01-12 Thread Med Ismail Bennani via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGc3b471c0be4f: [lldb] Force override when adding crashlog 
command (authored by mib).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140113

Files:
  lldb/examples/python/crashlog.py


Index: lldb/examples/python/crashlog.py
===
--- lldb/examples/python/crashlog.py
+++ lldb/examples/python/crashlog.py
@@ -1344,8 +1344,8 @@
 
 def __lldb_init_module(debugger, internal_dict):
 debugger.HandleCommand(
-'command script add -c lldb.macosx.crashlog.Symbolicate crashlog')
+'command script add -o -c lldb.macosx.crashlog.Symbolicate crashlog')
 debugger.HandleCommand(
-'command script add -f lldb.macosx.crashlog.save_crashlog 
save_crashlog')
+'command script add -o -f lldb.macosx.crashlog.save_crashlog 
save_crashlog')
 print('"crashlog" and "save_crashlog" commands have been installed, use '
   'the "--help" options on these commands for detailed help.')


Index: lldb/examples/python/crashlog.py
===
--- lldb/examples/python/crashlog.py
+++ lldb/examples/python/crashlog.py
@@ -1344,8 +1344,8 @@
 
 def __lldb_init_module(debugger, internal_dict):
 debugger.HandleCommand(
-'command script add -c lldb.macosx.crashlog.Symbolicate crashlog')
+'command script add -o -c lldb.macosx.crashlog.Symbolicate crashlog')
 debugger.HandleCommand(
-'command script add -f lldb.macosx.crashlog.save_crashlog save_crashlog')
+'command script add -o -f lldb.macosx.crashlog.save_crashlog save_crashlog')
 print('"crashlog" and "save_crashlog" commands have been installed, use '
   'the "--help" options on these commands for detailed help.')
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D139484: [lldb/test] Fix data racing issue in TestStackCoreScriptedProcess

2023-01-12 Thread Med Ismail Bennani via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG8f549c532927: [lldb/test] Fix data racing issue in 
TestStackCoreScriptedProcess (authored by mib).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139484

Files:
  lldb/test/API/functionalities/scripted_process/Makefile
  lldb/test/API/functionalities/scripted_process/TestStackCoreScriptedProcess.py
  lldb/test/API/functionalities/scripted_process/baz.c
  lldb/test/API/functionalities/scripted_process/baz.cpp
  lldb/test/API/functionalities/scripted_process/baz.h
  lldb/test/API/functionalities/scripted_process/main.cpp

Index: lldb/test/API/functionalities/scripted_process/main.cpp
===
--- lldb/test/API/functionalities/scripted_process/main.cpp
+++ lldb/test/API/functionalities/scripted_process/main.cpp
@@ -1,10 +1,9 @@
-#include 
-#include 
 #include 
 
-extern "C" {
-int baz(int);
-}
+#include "baz.h"
+
+std::condition_variable cv;
+std::mutex mutex;
 
 int bar(int i) {
   int j = i * i;
@@ -13,23 +12,20 @@
 
 int foo(int i) { return bar(i); }
 
-void call_and_wait(int &n) {
-  std::cout << "waiting for computation!" << std::endl;
-  while (baz(n) != 42)
-;
-  std::cout << "finished computation!" << std::endl;
+void compute_pow(int &n) {
+  std::unique_lock lock(mutex);
+  n = foo(n);
+  lock.unlock();
+  cv.notify_one(); // waiting thread is notified with n == 42 * 42, cv.wait
+   // returns
 }
 
-void compute_pow(int &n) { n = foo(n); }
+void call_and_wait(int &n) { baz(n, mutex, cv); }
 
 int main() {
   int n = 42;
-  std::mutex mutex;
-  std::unique_lock lock(mutex);
-
   std::thread thread_1(call_and_wait, std::ref(n));
   std::thread thread_2(compute_pow, std::ref(n));
-  lock.unlock();
 
   thread_1.join();
   thread_2.join();
Index: lldb/test/API/functionalities/scripted_process/baz.h
===
--- lldb/test/API/functionalities/scripted_process/baz.h
+++ lldb/test/API/functionalities/scripted_process/baz.h
@@ -1,3 +1,6 @@
 #pragma once
 
-int baz(int j);
+#include 
+#include 
+
+int baz(int &j, std::mutex &mutex, std::condition_variable &cv);
Index: lldb/test/API/functionalities/scripted_process/baz.cpp
===
--- /dev/null
+++ lldb/test/API/functionalities/scripted_process/baz.cpp
@@ -0,0 +1,10 @@
+#include "baz.h"
+
+#include 
+
+int baz(int &j, std::mutex &mutex, std::condition_variable &cv) {
+  std::unique_lock lock(mutex);
+  cv.wait(lock, [&j] { return j == 42 * 42; });
+  int k = sqrt(j);
+  return k; // break here
+}
Index: lldb/test/API/functionalities/scripted_process/baz.c
===
--- lldb/test/API/functionalities/scripted_process/baz.c
+++ /dev/null
@@ -1,8 +0,0 @@
-#include "baz.h"
-
-#include 
-
-int baz(int j) {
-  int k = sqrt(j);
-  return k; // break here
-}
Index: lldb/test/API/functionalities/scripted_process/TestStackCoreScriptedProcess.py
===
--- lldb/test/API/functionalities/scripted_process/TestStackCoreScriptedProcess.py
+++ lldb/test/API/functionalities/scripted_process/TestStackCoreScriptedProcess.py
@@ -17,7 +17,7 @@
 def create_stack_skinny_corefile(self, file):
 self.build()
 target, process, thread, _ = lldbutil.run_to_source_breakpoint(self, "// break here",
-   lldb.SBFileSpec("baz.c"))
+   lldb.SBFileSpec("baz.cpp"))
 self.assertTrue(process.IsValid(), "Process is invalid.")
 # FIXME: Use SBAPI to save the process corefile.
 self.runCmd("process save-core -s stack  " + file)
@@ -109,9 +109,9 @@
 self.assertTrue(func, "Invalid function.")
 
 self.assertIn("baz", frame.GetFunctionName())
-self.assertEqual(frame.vars.GetSize(), 2)
-self.assertEqual(int(frame.vars.GetFirstValueByName('j').GetValue()), 42 * 42)
+self.assertGreater(frame.vars.GetSize(), 0)
 self.assertEqual(int(frame.vars.GetFirstValueByName('k').GetValue()), 42)
+self.assertEqual(int(frame.vars.GetFirstValueByName('j').Dereference().GetValue()), 42 * 42)
 
 corefile_dylib = self.get_module_with_name(corefile_target, 'libbaz.dylib')
 self.assertTrue(corefile_dylib, "Dynamic library libbaz.dylib not found.")
Index: lldb/test/API/functionalities/scripted_process/Makefile
===
--- lldb/test/API/functionalities/scripted_process/Makefile
+++ lldb/test/API/functionalities/scripted_process/Makefile
@@ -6,8 +6,8 @@
 
 all: libbaz.dylib a.out
 
-libbaz.dylib: baz.c
+libbaz.dylib: baz.cpp
 	$(MAKE) -f $(

[Lldb-commits] [PATCH] D141658: [lldb/crashlog] Make interactive mode a default & report progress on image loading

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

This patch makes interactive mode as the default when using the crashlog
command. The legacy mode is still available using the (-b|--batch) flag
and is still used when running the crashlog script out of lldb.

This also adds some railguards to prevent users from using interactive
only options with the batch mode and updates the tests accordingly.

Finally, this patch moves the crashlog image dependencies loading to use
the scripted process affordances. This allows it to take advantage of
other lldb features such as external symbol fetching and progress reporting.

rdar://97801509

Signed-off-by: Med Ismail Bennani 


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D141658

Files:
  lldb/examples/python/crashlog.py
  lldb/examples/python/scripted_process/crashlog_scripted_process.py
  lldb/source/Plugins/Process/scripted/ScriptedProcess.cpp
  
lldb/test/Shell/ScriptInterpreter/Python/Crashlog/app_specific_backtrace_crashlog.test
  
lldb/test/Shell/ScriptInterpreter/Python/Crashlog/interactive_crashlog_invalid_target.test
  lldb/test/Shell/ScriptInterpreter/Python/Crashlog/json.test
  lldb/test/Shell/ScriptInterpreter/Python/Crashlog/no_threadState.test
  lldb/test/Shell/ScriptInterpreter/Python/Crashlog/scripted_crashlog_json.test
  
lldb/test/Shell/ScriptInterpreter/Python/Crashlog/skipped_status_interactive_crashlog.test
  lldb/test/Shell/ScriptInterpreter/Python/Crashlog/text.test

Index: lldb/test/Shell/ScriptInterpreter/Python/Crashlog/text.test
===
--- lldb/test/Shell/ScriptInterpreter/Python/Crashlog/text.test
+++ lldb/test/Shell/ScriptInterpreter/Python/Crashlog/text.test
@@ -1,7 +1,7 @@
 # RUN: %clang_host -g %S/Inputs/test.c -o %t.out
 # RUN: cp %S/Inputs/a.out.crash %t.crash
 # RUN: %python %S/patch-crashlog.py --binary %t.out --crashlog %t.crash --offsets '{"main":20, "bar":9, "foo":16}'
-# RUN: %lldb %t.out -o 'command script import lldb.macosx.crashlog' -o 'crashlog %t.crash' 2>&1 | FileCheck %s
+# RUN: %lldb %t.out -o 'command script import lldb.macosx.crashlog' -o 'crashlog -b %t.crash' 2>&1 | FileCheck %s
 
 # CHECK: "crashlog" {{.*}} commands have been installed, use the "--help" options on these commands
 
Index: lldb/test/Shell/ScriptInterpreter/Python/Crashlog/skipped_status_interactive_crashlog.test
===
--- lldb/test/Shell/ScriptInterpreter/Python/Crashlog/skipped_status_interactive_crashlog.test
+++ lldb/test/Shell/ScriptInterpreter/Python/Crashlog/skipped_status_interactive_crashlog.test
@@ -3,7 +3,7 @@
 # RUN: mkdir -p %t.dir
 # RUN: yaml2obj %S/Inputs/interactive_crashlog/multithread-test.yaml > %t.dir/multithread-test
 # RUN: %lldb -b -o 'command script import lldb.macosx.crashlog' \
-# RUN: -o 'crashlog -a -i -s -t %t.dir/multithread-test %S/Inputs/interactive_crashlog/multithread-test.ips' \
+# RUN: -o 'crashlog -a -s -t %t.dir/multithread-test %S/Inputs/interactive_crashlog/multithread-test.ips' \
 # RUN: -o 'command source -s 0 %s' 2>&1 | FileCheck %s
 
 # CHECK: "crashlog" {{.*}} commands have been installed, use the "--help" options on these commands
Index: lldb/test/Shell/ScriptInterpreter/Python/Crashlog/scripted_crashlog_json.test
===
--- lldb/test/Shell/ScriptInterpreter/Python/Crashlog/scripted_crashlog_json.test
+++ lldb/test/Shell/ScriptInterpreter/Python/Crashlog/scripted_crashlog_json.test
@@ -3,7 +3,7 @@
 # RUN: mkdir -p %t.dir
 # RUN: yaml2obj %S/Inputs/interactive_crashlog/multithread-test.yaml > %t.dir/multithread-test
 # RUN: %lldb -o 'command script import lldb.macosx.crashlog' \
-# RUN: -o 'crashlog -a -i -t %t.dir/multithread-test %S/Inputs/interactive_crashlog/multithread-test.ips' \
+# RUN: -o 'crashlog -a -t %t.dir/multithread-test %S/Inputs/interactive_crashlog/multithread-test.ips' \
 # RUN: -o "thread list" -o "bt all" 2>&1 | FileCheck %s
 
 # CHECK: "crashlog" {{.*}} commands have been installed, use the "--help" options on these commands
Index: lldb/test/Shell/ScriptInterpreter/Python/Crashlog/no_threadState.test
===
--- lldb/test/Shell/ScriptInterpreter/Python/Crashlog/no_threadState.test
+++ lldb/test/Shell/ScriptInterpreter/Python/Crashlog/no_threadState.test
@@ -2,7 +2,7 @@
 
 # RUN: cp %S/Inputs/no_threadState.ips %t.crash
 # RUN: %python %S/patch-crashlog.py --binary %t.out --crashlog %t.crash --offsets '{"main":20, "bar":9, "foo":16}' --json
-# RUN: %lldb %t.out -o 'command script import lldb.macosx.crashlog' -o 'crashlog %t.crash' 2>&1 | FileCheck %s
+# RUN: %lldb %t.out -o 'command script import lldb.macosx.crashlog' -o 'crashlog -b %t.crash' 2>&1 | FileCh