[Lldb-commits] [PATCH] D98529: [lldb] Strip pointer authentication codes from aarch64 pc.

2021-03-23 Thread Jason Molenda via Phabricator via lldb-commits
jasonmolenda added a comment.

In D98529#2631946 , @DavidSpickett 
wrote:

> TCR_ELx begins at 1 (see `D13.2.123 TCR_EL1, Translation Control Register 
> (EL1)` in the armarm) and covers EL0 and 1. Looking at the pseudocode access 
> to this is undefined at EL0.

I updated my local documentation & impl to only record the shared EL0/EL1 T0SZ 
value, thanks.

> So the OS would have to provide you some other way to read that, I know this 
> is missing on Linux at the moment. A user setting might be good for us 
> supporting Linux too. (though I realise your immediate concern is MacOS)

OK we may need to retain the manual setting when I upstream this, instead of 
going with the pure Process-maintained value determined dynamically by gdb 
packet or corefile metadata.  If this is something you need for your own 
FixCodeAddress prelim patch, I can upstream the 
target.process.virtual-addressable-bits setting (I think the name is fine, even 
once Process can determine this dynamically).  We'll need to decide at some 
point what the correct behavior is when they conflict, but if only one is set 
the choice is straightforward.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98529

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


[Lldb-commits] [PATCH] D98529: [lldb] Strip pointer authentication codes from aarch64 pc.

2021-03-23 Thread Muhammad Omair Javaid via Phabricator via lldb-commits
omjavaid added a comment.

In D98529#2643850 , @jasonmolenda 
wrote:

> In D98529#2631946 , @DavidSpickett 
> wrote:
>
>> TCR_ELx begins at 1 (see `D13.2.123 TCR_EL1, Translation Control Register 
>> (EL1)` in the armarm) and covers EL0 and 1. Looking at the pseudocode access 
>> to this is undefined at EL0.
>
> I updated my local documentation & impl to only record the shared EL0/EL1 
> T0SZ value, thanks.
>
>> So the OS would have to provide you some other way to read that, I know this 
>> is missing on Linux at the moment. A user setting might be good for us 
>> supporting Linux too. (though I realise your immediate concern is MacOS)
>
> OK we may need to retain the manual setting when I upstream this, instead of 
> going with the pure Process-maintained value determined dynamically by gdb 
> packet or corefile metadata.  If this is something you need for your own 
> FixCodeAddress prelim patch, I can upstream the 
> target.process.virtual-addressable-bits setting (I think the name is fine, 
> even once Process can determine this dynamically).  We'll need to decide at 
> some point what the correct behavior is when they conflict, but if only one 
> is set the choice is straightforward.

I guess it would be important to host FixCodeAddress function in target.process 
given it may be needed for cleaning up top byte from breakpoint/watchpoint 
addresses and memory access address. I am thinking of adding FixCodeAddress to 
Process::CreateBreakpointSite and Process::ReadMemory which means it would be 
best to host a virtual-addressable-bits member in Process class and provide 
facility to update it dynamically otherwise set to architecture default. If you 
have your code handy may be you upstream it and we ll take it forward from 
there.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98529

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


[Lldb-commits] [PATCH] D98529: [lldb] Strip pointer authentication codes from aarch64 pc.

2021-03-23 Thread David Spickett via Phabricator via lldb-commits
DavidSpickett added a comment.

> OK we may need to retain the manual setting when I upstream this, instead of 
> going with the pure Process-maintained value determined dynamically by gdb 
> packet or corefile metadata. If this is something you need for your own 
> FixCodeAddress prelim patch, I can upstream the 
> target.process.virtual-addressable-bits setting (I think the name is fine, 
> even once Process can determine this dynamically). We'll need to decide at 
> some point what the correct behavior is when they conflict, but if only one 
> is set the choice is straightforward.

From what pcc said, I was mistaken. So I don't think a setting would be needed 
(thanks for the offer though). The combination of top byte ignore and the PAC 
mask registers should give us what we need for Linux.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98529

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


[Lldb-commits] [PATCH] D96460: [LLDB] Arm64/Linux Add MTE and Pointer Authentication registers

2021-03-23 Thread Muhammad Omair Javaid via Phabricator via lldb-commits
omjavaid updated this revision to Diff 332617.
omjavaid added a comment.
Herald added a subscriber: emaste.

Pulling GetAuxValue from NativeProcessELF. @labath what do you think.


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

https://reviews.llvm.org/D96460

Files:
  lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.cpp
  lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.h
  lldb/source/Plugins/Process/POSIX/NativeProcessELF.h
  lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.cpp
  lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.h
  lldb/source/Plugins/Process/Utility/RegisterInfos_arm64.h

Index: lldb/source/Plugins/Process/Utility/RegisterInfos_arm64.h
===
--- lldb/source/Plugins/Process/Utility/RegisterInfos_arm64.h
+++ lldb/source/Plugins/Process/Utility/RegisterInfos_arm64.h
@@ -470,6 +470,13 @@
 LLDB_INVALID_REGNUM, lldb_kind \
   }
 
+// Generates register kinds array for registers with only lldb kind
+#define KIND_ALL_INVALID   \
+  {\
+LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, \
+LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM   \
+  }
+
 // Generates register kinds array for vector registers
 #define GPR64_KIND(reg, generic_kind) MISC_KIND(reg, gpr, generic_kind)
 #define VREG_KIND(reg) MISC_KIND(reg, fpu, LLDB_INVALID_REGNUM)
@@ -526,6 +533,13 @@
 nullptr, 0 \
   }
 
+// Defines pointer authentication mask registers
+#define DEFINE_EXTENSION_REG(reg)  \
+  {\
+#reg, nullptr, 8, 0, lldb::eEncodingUint, lldb::eFormatHex,\
+KIND_ALL_INVALID, nullptr, nullptr, nullptr, 0 \
+  }
+
 static lldb_private::RegisterInfo g_register_infos_arm64_le[] = {
 // DEFINE_GPR64(name, GENERIC KIND)
 DEFINE_GPR64(x0, LLDB_REGNUM_GENERIC_ARG1),
@@ -772,7 +786,12 @@
 {DEFINE_DBG(wcr, 13)},
 {DEFINE_DBG(wcr, 14)},
 {DEFINE_DBG(wcr, 15)}
-// clang-format on
 };
+// clang-format on
+static lldb_private::RegisterInfo g_register_infos_pauth[] = {
+DEFINE_EXTENSION_REG(data_mask), DEFINE_EXTENSION_REG(code_mask)};
+
+static lldb_private::RegisterInfo g_register_infos_mte[] = {
+DEFINE_EXTENSION_REG(mte_ctrl)};
 
 #endif // DECLARE_REGISTER_INFOS_ARM64_STRUCT
Index: lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.h
===
--- lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.h
+++ lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.h
@@ -26,6 +26,8 @@
   enum {
 eRegsetMaskDefault = 0,
 eRegsetMaskSVE = 1,
+eRegsetMaskPAuth = 2,
+eRegsetMaskMTE = 4,
 eRegsetMaskDynamic = ~1,
   };
 
@@ -94,6 +96,10 @@
 
   size_t GetRegisterSetFromRegisterIndex(uint32_t reg_index) const override;
 
+  void AddRegSetPAuth();
+
+  void AddRegSetMTE();
+
   uint32_t ConfigureVectorLength(uint32_t sve_vq);
 
   bool VectorSizeIsValid(uint32_t vq) {
@@ -108,12 +114,16 @@
   bool IsSVEZReg(unsigned reg) const;
   bool IsSVEPReg(unsigned reg) const;
   bool IsSVERegVG(unsigned reg) const;
+  bool IsPAuthReg(unsigned reg) const;
+  bool IsMTEReg(unsigned reg) const;
 
   uint32_t GetRegNumSVEZ0() const;
   uint32_t GetRegNumSVEFFR() const;
   uint32_t GetRegNumFPCR() const;
   uint32_t GetRegNumFPSR() const;
   uint32_t GetRegNumSVEVG() const;
+  uint32_t GetPAuthOffset() const;
+  uint32_t GetMTEOffset() const;
 
 private:
   typedef std::map>
@@ -137,6 +147,9 @@
 
   std::vector m_dynamic_reg_infos;
   std::vector m_dynamic_reg_sets;
+
+  std::vector pauth_regnum_collection;
+  std::vector m_mte_regnum_collection;
 };
 
 #endif
Index: lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.cpp
===
--- lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.cpp
+++ lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.cpp
@@ -77,6 +77,8 @@
   k_num_gpr_registers = gpr_w28 - gpr_x0 + 1,
   k_num_fpr_registers = fpu_fpcr - fpu_v0 + 1,
   k_num_sve_registers = sve_ffr - sve_vg + 1,
+  k_num_mte_register = 1,
+  k_num_pauth_register = 2,
   k_num_register_sets_default = 2,
   k_num_register_sets = 3
 };
@@ -175,6 +177,12 @@
 {"Scalable Vector Extension Registers", "sve", k_num_sve_registers,
  g_sve_regnums_arm64}};
 
+static const lldb_private::RegisterSet g_reg_set_pauth_arm64 = {
+"Pointer Authentication Registers", "pauth", k_num_pauth_register, NULL};
+
+static const lldb_private::RegisterSet g_reg_set_mte_

[Lldb-commits] [lldb] 2f18e51 - [lldb] Silence GCC warnings about format not being a string literal in LLDB_SCOPED_TIMER

2021-03-23 Thread Martin Storsjö via lldb-commits

Author: Martin Storsjö
Date: 2021-03-23T14:11:50+02:00
New Revision: 2f18e51d8b9e02d689efc522a0784caed5b5a386

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

LOG: [lldb] Silence GCC warnings about format not being a string literal in 
LLDB_SCOPED_TIMER

Pass "%s" as the format string literal and LLVM_PRETTY_FUNCTION as
argument to it.

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

Added: 


Modified: 
lldb/include/lldb/Utility/Timer.h

Removed: 




diff  --git a/lldb/include/lldb/Utility/Timer.h 
b/lldb/include/lldb/Utility/Timer.h
index edc064b23b574..32422b34b1adf 100644
--- a/lldb/include/lldb/Utility/Timer.h
+++ b/lldb/include/lldb/Utility/Timer.h
@@ -76,7 +76,7 @@ class Timer {
 
 #define LLDB_SCOPED_TIMER()
\
   static ::lldb_private::Timer::Category _cat(LLVM_PRETTY_FUNCTION);   
\
-  ::lldb_private::Timer _scoped_timer(_cat, LLVM_PRETTY_FUNCTION)
+  ::lldb_private::Timer _scoped_timer(_cat, "%s", LLVM_PRETTY_FUNCTION)
 #define LLDB_SCOPED_TIMERF(...)
\
   static ::lldb_private::Timer::Category _cat(LLVM_PRETTY_FUNCTION);   
\
   ::lldb_private::Timer _scoped_timer(_cat, __VA_ARGS__)



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


[Lldb-commits] [PATCH] D99120: [lldb] Silence GCC warnings about format not being a string literal in LLDB_SCOPED_TIMER

2021-03-23 Thread Martin Storsjö 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 rG2f18e51d8b9e: [lldb] Silence GCC warnings about format not 
being a string literal in… (authored by mstorsjo).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99120

Files:
  lldb/include/lldb/Utility/Timer.h


Index: lldb/include/lldb/Utility/Timer.h
===
--- lldb/include/lldb/Utility/Timer.h
+++ lldb/include/lldb/Utility/Timer.h
@@ -76,7 +76,7 @@
 
 #define LLDB_SCOPED_TIMER()
\
   static ::lldb_private::Timer::Category _cat(LLVM_PRETTY_FUNCTION);   
\
-  ::lldb_private::Timer _scoped_timer(_cat, LLVM_PRETTY_FUNCTION)
+  ::lldb_private::Timer _scoped_timer(_cat, "%s", LLVM_PRETTY_FUNCTION)
 #define LLDB_SCOPED_TIMERF(...)
\
   static ::lldb_private::Timer::Category _cat(LLVM_PRETTY_FUNCTION);   
\
   ::lldb_private::Timer _scoped_timer(_cat, __VA_ARGS__)


Index: lldb/include/lldb/Utility/Timer.h
===
--- lldb/include/lldb/Utility/Timer.h
+++ lldb/include/lldb/Utility/Timer.h
@@ -76,7 +76,7 @@
 
 #define LLDB_SCOPED_TIMER()\
   static ::lldb_private::Timer::Category _cat(LLVM_PRETTY_FUNCTION);   \
-  ::lldb_private::Timer _scoped_timer(_cat, LLVM_PRETTY_FUNCTION)
+  ::lldb_private::Timer _scoped_timer(_cat, "%s", LLVM_PRETTY_FUNCTION)
 #define LLDB_SCOPED_TIMERF(...)\
   static ::lldb_private::Timer::Category _cat(LLVM_PRETTY_FUNCTION);   \
   ::lldb_private::Timer _scoped_timer(_cat, __VA_ARGS__)
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D99182: [NFC] Reordering parameters in getFile and getFileOrSTDIN

2021-03-23 Thread Abhina Sree via Phabricator via lldb-commits
abhina.sreeskantharajan created this revision.
Herald added subscribers: dexonsmith, thopre, rupprecht, steven_wu, hiraditya, 
arichardson, emaste.
Herald added a reviewer: jhenderson.
Herald added a reviewer: MaskRay.
abhina.sreeskantharajan requested review of this revision.
Herald added projects: clang, LLDB, LLVM.
Herald added subscribers: llvm-commits, lldb-commits, cfe-commits.

In future patches I will be setting the OF_Flag parameter frequently so I will 
refactor the args to be in the following order:

  getFile(const Twine &Filename, bool IsText = false,
  bool RequiresNullTerminator = true, int64_t FileSize = -1,
  bool IsVolatile = false);
  
  getFileOrSTDIN(const Twine &Filename, bool IsText = false,
 bool RequiresNullTerminator = true, int64_t FileSize = -1);


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D99182

Files:
  clang/lib/Tooling/JSONCompilationDatabase.cpp
  clang/tools/arcmt-test/arcmt-test.cpp
  lld/COFF/Driver.cpp
  lld/COFF/DriverUtils.cpp
  lld/ELF/InputFiles.cpp
  lldb/source/Plugins/ObjectFile/PDB/ObjectFilePDB.cpp
  lldb/unittests/TestingSupport/TestUtilities.cpp
  llvm/include/llvm/Support/MemoryBuffer.h
  llvm/lib/BinaryFormat/Magic.cpp
  llvm/lib/DebugInfo/PDB/Native/NativeSession.cpp
  llvm/lib/FuzzMutate/FuzzerCLI.cpp
  llvm/lib/IRReader/IRReader.cpp
  llvm/lib/LTO/LTOCodeGenerator.cpp
  llvm/lib/Object/Binary.cpp
  llvm/lib/ProfileData/GCOV.cpp
  llvm/lib/Support/MemoryBuffer.cpp
  llvm/lib/TableGen/Main.cpp
  llvm/lib/ToolDrivers/llvm-lib/LibDriver.cpp
  llvm/tools/lli/lli.cpp
  llvm/tools/llvm-ar/llvm-ar.cpp
  llvm/tools/llvm-cov/gcov.cpp
  llvm/tools/llvm-libtool-darwin/llvm-libtool-darwin.cpp
  llvm/tools/llvm-pdbutil/InputFile.cpp
  llvm/tools/llvm-pdbutil/llvm-pdbutil.cpp
  llvm/tools/llvm-rc/ResourceFileWriter.cpp
  llvm/tools/llvm-readobj/llvm-readobj.cpp
  llvm/tools/obj2yaml/obj2yaml.cpp
  llvm/tools/sanstats/sanstats.cpp
  llvm/utils/FileCheck/FileCheck.cpp

Index: llvm/utils/FileCheck/FileCheck.cpp
===
--- llvm/utils/FileCheck/FileCheck.cpp
+++ llvm/utils/FileCheck/FileCheck.cpp
@@ -821,9 +821,7 @@
 
   // Read the expected strings from the check file.
   ErrorOr> CheckFileOrErr =
-  MemoryBuffer::getFileOrSTDIN(CheckFilename, /*FileSize=*/-1,
-   /*RequiresNullTerminator=*/true,
-   /*IsText=*/true);
+  MemoryBuffer::getFileOrSTDIN(CheckFilename, /*IsText=*/true);
   if (std::error_code EC = CheckFileOrErr.getError()) {
 errs() << "Could not open check file '" << CheckFilename
<< "': " << EC.message() << '\n';
@@ -845,9 +843,7 @@
 
   // Open the file to check and add it to SourceMgr.
   ErrorOr> InputFileOrErr =
-  MemoryBuffer::getFileOrSTDIN(InputFilename, /*FileSize=*/-1,
-   /*RequiresNullTerminator=*/true,
-   /*IsText=*/true);
+  MemoryBuffer::getFileOrSTDIN(InputFilename, /*IsText=*/true);
   if (InputFilename == "-")
 InputFilename = ""; // Overwrite for improved diagnostic messages
   if (std::error_code EC = InputFileOrErr.getError()) {
Index: llvm/tools/sanstats/sanstats.cpp
===
--- llvm/tools/sanstats/sanstats.cpp
+++ llvm/tools/sanstats/sanstats.cpp
@@ -125,8 +125,8 @@
   cl::ParseCommandLineOptions(argc, argv,
   "Sanitizer Statistics Processing Tool");
 
-  ErrorOr> MBOrErr =
-  MemoryBuffer::getFile(ClInputFile, -1, false);
+  ErrorOr> MBOrErr = MemoryBuffer::getFile(
+  ClInputFile, /*IsText=*/false, /*RequiresNullTerminator=*/false);
   if (!MBOrErr) {
 errs() << argv[0] << ": " << ClInputFile << ": "
<< MBOrErr.getError().message() << '\n';
Index: llvm/tools/obj2yaml/obj2yaml.cpp
===
--- llvm/tools/obj2yaml/obj2yaml.cpp
+++ llvm/tools/obj2yaml/obj2yaml.cpp
@@ -36,7 +36,7 @@
 
 static Error dumpInput(StringRef File) {
   ErrorOr> FileOrErr =
-  MemoryBuffer::getFileOrSTDIN(File, /*FileSize=*/-1,
+  MemoryBuffer::getFileOrSTDIN(File, /*IsText=*/false,
/*RequiresNullTerminator=*/false);
   if (std::error_code EC = FileOrErr.getError())
 return errorCodeToError(EC);
Index: llvm/tools/llvm-readobj/llvm-readobj.cpp
===
--- llvm/tools/llvm-readobj/llvm-readobj.cpp
+++ llvm/tools/llvm-readobj/llvm-readobj.cpp
@@ -653,7 +653,7 @@
 /// Opens \a File and dumps it.
 static void dumpInput(StringRef File, ScopedPrinter &Writer) {
   ErrorOr> FileOrErr =
-  MemoryBuffer::getFileOrSTDIN(File, /*FileSize=*/-1,
+  MemoryBuffer::getFileOrSTDIN(File, /*IsText=*/false,
/*RequiresNullTerminator=*/false);
   if (std::error_code EC = FileOrErr.getError())

[Lldb-commits] [PATCH] D99182: [NFC] Reordering parameters in getFile and getFileOrSTDIN

2021-03-23 Thread Abhina Sree via Phabricator via lldb-commits
abhina.sreeskantharajan updated this revision to Diff 332644.
abhina.sreeskantharajan edited the summary of this revision.
abhina.sreeskantharajan added a comment.
Herald added a subscriber: JDevlieghere.

Move FileSize to the end because it is never used.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99182

Files:
  clang/lib/Tooling/JSONCompilationDatabase.cpp
  clang/tools/arcmt-test/arcmt-test.cpp
  lld/COFF/Driver.cpp
  lld/COFF/DriverUtils.cpp
  lld/ELF/InputFiles.cpp
  lldb/source/Plugins/ObjectFile/PDB/ObjectFilePDB.cpp
  lldb/unittests/TestingSupport/TestUtilities.cpp
  llvm/include/llvm/Support/MemoryBuffer.h
  llvm/lib/BinaryFormat/Magic.cpp
  llvm/lib/DebugInfo/PDB/Native/NativeSession.cpp
  llvm/lib/FuzzMutate/FuzzerCLI.cpp
  llvm/lib/IRReader/IRReader.cpp
  llvm/lib/LTO/LTOCodeGenerator.cpp
  llvm/lib/Object/Binary.cpp
  llvm/lib/ProfileData/GCOV.cpp
  llvm/lib/Support/MemoryBuffer.cpp
  llvm/lib/TableGen/Main.cpp
  llvm/lib/ToolDrivers/llvm-lib/LibDriver.cpp
  llvm/tools/lli/lli.cpp
  llvm/tools/llvm-ar/llvm-ar.cpp
  llvm/tools/llvm-cov/gcov.cpp
  llvm/tools/llvm-libtool-darwin/llvm-libtool-darwin.cpp
  llvm/tools/llvm-pdbutil/InputFile.cpp
  llvm/tools/llvm-pdbutil/llvm-pdbutil.cpp
  llvm/tools/llvm-rc/ResourceFileWriter.cpp
  llvm/tools/llvm-readobj/llvm-readobj.cpp
  llvm/tools/obj2yaml/obj2yaml.cpp
  llvm/tools/sanstats/sanstats.cpp
  llvm/utils/FileCheck/FileCheck.cpp

Index: llvm/utils/FileCheck/FileCheck.cpp
===
--- llvm/utils/FileCheck/FileCheck.cpp
+++ llvm/utils/FileCheck/FileCheck.cpp
@@ -821,9 +821,7 @@
 
   // Read the expected strings from the check file.
   ErrorOr> CheckFileOrErr =
-  MemoryBuffer::getFileOrSTDIN(CheckFilename, /*FileSize=*/-1,
-   /*RequiresNullTerminator=*/true,
-   /*IsText=*/true);
+  MemoryBuffer::getFileOrSTDIN(CheckFilename, /*IsText=*/true);
   if (std::error_code EC = CheckFileOrErr.getError()) {
 errs() << "Could not open check file '" << CheckFilename
<< "': " << EC.message() << '\n';
@@ -845,9 +843,7 @@
 
   // Open the file to check and add it to SourceMgr.
   ErrorOr> InputFileOrErr =
-  MemoryBuffer::getFileOrSTDIN(InputFilename, /*FileSize=*/-1,
-   /*RequiresNullTerminator=*/true,
-   /*IsText=*/true);
+  MemoryBuffer::getFileOrSTDIN(InputFilename, /*IsText=*/true);
   if (InputFilename == "-")
 InputFilename = ""; // Overwrite for improved diagnostic messages
   if (std::error_code EC = InputFileOrErr.getError()) {
Index: llvm/tools/sanstats/sanstats.cpp
===
--- llvm/tools/sanstats/sanstats.cpp
+++ llvm/tools/sanstats/sanstats.cpp
@@ -125,8 +125,8 @@
   cl::ParseCommandLineOptions(argc, argv,
   "Sanitizer Statistics Processing Tool");
 
-  ErrorOr> MBOrErr =
-  MemoryBuffer::getFile(ClInputFile, -1, false);
+  ErrorOr> MBOrErr = MemoryBuffer::getFile(
+  ClInputFile, /*IsText=*/false, /*RequiresNullTerminator=*/false);
   if (!MBOrErr) {
 errs() << argv[0] << ": " << ClInputFile << ": "
<< MBOrErr.getError().message() << '\n';
Index: llvm/tools/obj2yaml/obj2yaml.cpp
===
--- llvm/tools/obj2yaml/obj2yaml.cpp
+++ llvm/tools/obj2yaml/obj2yaml.cpp
@@ -36,7 +36,7 @@
 
 static Error dumpInput(StringRef File) {
   ErrorOr> FileOrErr =
-  MemoryBuffer::getFileOrSTDIN(File, /*FileSize=*/-1,
+  MemoryBuffer::getFileOrSTDIN(File, /*IsText=*/false,
/*RequiresNullTerminator=*/false);
   if (std::error_code EC = FileOrErr.getError())
 return errorCodeToError(EC);
Index: llvm/tools/llvm-readobj/llvm-readobj.cpp
===
--- llvm/tools/llvm-readobj/llvm-readobj.cpp
+++ llvm/tools/llvm-readobj/llvm-readobj.cpp
@@ -653,7 +653,7 @@
 /// Opens \a File and dumps it.
 static void dumpInput(StringRef File, ScopedPrinter &Writer) {
   ErrorOr> FileOrErr =
-  MemoryBuffer::getFileOrSTDIN(File, /*FileSize=*/-1,
+  MemoryBuffer::getFileOrSTDIN(File, /*IsText=*/false,
/*RequiresNullTerminator=*/false);
   if (std::error_code EC = FileOrErr.getError())
 return reportError(errorCodeToError(EC), File);
Index: llvm/tools/llvm-rc/ResourceFileWriter.cpp
===
--- llvm/tools/llvm-rc/ResourceFileWriter.cpp
+++ llvm/tools/llvm-rc/ResourceFileWriter.cpp
@@ -1524,14 +1524,16 @@
   // properly though, so if using that to append paths below, this early
   // exception case could be removed.)
   if (sys::path::has_root_directory(File))
-return errorOrToExpected(MemoryBuffer::getFi

[Lldb-commits] [PATCH] D97739: Add a progress class that can track and report long running operations that happen in LLDB.

2021-03-23 Thread Jim Ingham via Phabricator via lldb-commits
jingham accepted this revision.
jingham added a comment.

This looks good to me.




Comment at: lldb/source/API/SBDebugger.cpp:857
+error = m_opaque_sp->GetTargetList().CreateTarget(
+*m_opaque_sp, filename, arch, eLoadDependentsYes, platform_sp,
+target_sp);

dblaikie wrote:
> jingham wrote:
> > clayborg wrote:
> > > I submit with "arc diff" and it will cause lint errors if I don't allow 
> > > it to fix the lint errors it finds.
> > I'm 100% not in favor of tools that force irrelevant changes to be 
> > included.  But that is a suggested tool so somebody must like that.
> They aren't forced - you can submit with linter errors if they don't seem 
> helpful.
> 
> Pre-committing format changes in standalone NFC commits would generally be 
> preferable. & the linter shouldn't be flagging untouched lines - is it?
It looks like the file had changes 700 lines before & 900 lines after, but 
these lines weren't changed except by the linter... 



Comment at: lldb/source/Core/Debugger.cpp:1188
+(*pos)->ReportProgressPrivate(progress_id, message, completed, total,
+  is_debugger_specific);
+}

jingham wrote:
> clayborg wrote:
> > In the Progress class I currently only store a pointer to the debugger if 
> > one was specified. This means there is a lifetime issue that can arise. If 
> > I do the callback for Debugger::ReportProgress(...) above, then we will 
> > only notify debugger instances that are still around and in the global 
> > list. If not then we need to either store a DebuggerSP or DebuggerWP in the 
> > Progress object, which we can do if truly needed, but I don't like 
> > DebuggerSP as I don't want a Progress to keep a debugger around. DebuggerWP 
> > is possible if we really need this. Let me know what you think. 
> > Debugger::ReportProgressPrivate() could be make into a static function if 
> > needed so that no one sees it from Debugger.h.
> I think it's fine to drop progress notifications on the floor if they were 
> debugger specific and that debugger is no longer around.  I don't think it 
> makes sense for the Progress to keep Debugger alive.  As long as you check on 
> the existence as you do here, you won't end up calling into a bad debugger, 
> so the way you've done it looks fine.  You might want to have an:
> 
>   if (is_debugger_specific) break;
> 
> After the call to ReportProgressPrivate.  It's unlikely we'll ever have 
> enough debugger's that this a performance issue, but still looks weird to 
> keep checking after we found the one we want.
> 
> BTW, it might be better to have the Progress store the DebuggerID rather than 
> the pointer.  It would make it clear we aren't making claims about keeping 
> the debugger alive..  That would simplify this code, since you could:
> 
>if (debugger_id != LLDB_INVALID_DEBUGGER_ID) {
> DebuggerSP debugger_sp = Debugger::FindDebuggerWithID(debugger_id)
> if (debugger_sp) debugger_sp->ReportProgressPrivate(..., true);
> return;
>}
> 
> Then your original loop just calling ReportProgressPrivate on all the 
> debuggers, passing false for "debugger_specific".
BTW, I made up LLDB_INVALID_DEBUGGER_ID, apparently...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97739

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


[Lldb-commits] [lldb] 3e0ad11 - [lldb/Commands] Add command options for ScriptedProcess to ProcessLaunch

2021-03-23 Thread Med Ismail Bennani via lldb-commits

Author: Med Ismail Bennani
Date: 2021-03-23T18:24:47+01:00
New Revision: 3e0ad115439622b9c3e6ca9fd64c7fb07a679f1a

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

LOG: [lldb/Commands] Add command options for ScriptedProcess to ProcessLaunch

This patch adds a new command options to the CommandObjectProcessLaunch
for scripted processes.

Among the options, the user need to specify the class name managing the
scripted process. The user can also use a key-value dictionary holding
arbitrary data that will be passed to the managing class.

This patch also adds getters and setters to `SBLaunchInfo` for the
class name managing the scripted process and the dictionary.

rdar://65508855

Differential Review: https://reviews.llvm.org/D95710

Signed-off-by: Med Ismail Bennani 

Added: 


Modified: 
lldb/bindings/interface/SBLaunchInfo.i
lldb/include/lldb/API/SBLaunchInfo.h
lldb/include/lldb/API/SBStream.h
lldb/include/lldb/API/SBStructuredData.h
lldb/include/lldb/Host/ProcessLaunchInfo.h
lldb/source/API/SBLaunchInfo.cpp
lldb/source/Commands/CommandObjectPlatform.cpp
lldb/source/Commands/CommandObjectProcess.cpp
lldb/source/Commands/CommandOptionsProcessLaunch.cpp
lldb/source/Commands/CommandOptionsProcessLaunch.h
lldb/source/Host/common/ProcessLaunchInfo.cpp
lldb/source/Target/Target.cpp

Removed: 




diff  --git a/lldb/bindings/interface/SBLaunchInfo.i 
b/lldb/bindings/interface/SBLaunchInfo.i
index d76656ddd493..535ed3b79060 100644
--- a/lldb/bindings/interface/SBLaunchInfo.i
+++ b/lldb/bindings/interface/SBLaunchInfo.i
@@ -135,6 +135,16 @@ public:
 
 void
 SetDetachOnError(bool enable);
+
+const char *
+GetScriptedProcessClassName() const;
+
+void SetScriptedProcessClassName(const char *class_name);
+
+lldb::SBStructuredData
+GetScriptedProcessDictionary() const;
+
+void SetScriptedProcessDictionary(lldb::SBStructuredData dict);
 };
 
 } // namespace lldb

diff  --git a/lldb/include/lldb/API/SBLaunchInfo.h 
b/lldb/include/lldb/API/SBLaunchInfo.h
index 04ebb5707688..eb4f4a65833c 100644
--- a/lldb/include/lldb/API/SBLaunchInfo.h
+++ b/lldb/include/lldb/API/SBLaunchInfo.h
@@ -171,6 +171,14 @@ class LLDB_API SBLaunchInfo {
 
   void SetDetachOnError(bool enable);
 
+  const char *GetScriptedProcessClassName() const;
+
+  void SetScriptedProcessClassName(const char *class_name);
+
+  lldb::SBStructuredData GetScriptedProcessDictionary() const;
+
+  void SetScriptedProcessDictionary(lldb::SBStructuredData dict);
+
 protected:
   friend class SBPlatform;
   friend class SBTarget;

diff  --git a/lldb/include/lldb/API/SBStream.h 
b/lldb/include/lldb/API/SBStream.h
index f44b87bb4c98..f39bf13f2bf7 100644
--- a/lldb/include/lldb/API/SBStream.h
+++ b/lldb/include/lldb/API/SBStream.h
@@ -72,6 +72,7 @@ class LLDB_API SBStream {
   friend class SBFunction;
   friend class SBInstruction;
   friend class SBInstructionList;
+  friend class SBLaunchInfo;
   friend class SBLineEntry;
   friend class SBMemoryRegionInfo;
   friend class SBModule;

diff  --git a/lldb/include/lldb/API/SBStructuredData.h 
b/lldb/include/lldb/API/SBStructuredData.h
index 44a86bdabe25..07763f2de52b 100644
--- a/lldb/include/lldb/API/SBStructuredData.h
+++ b/lldb/include/lldb/API/SBStructuredData.h
@@ -88,6 +88,7 @@ class SBStructuredData {
   size_t GetStringValue(char *dst, size_t dst_len) const;
 
 protected:
+  friend class SBLaunchInfo;
   friend class SBTraceOptions;
   friend class SBDebugger;
   friend class SBTarget;

diff  --git a/lldb/include/lldb/Host/ProcessLaunchInfo.h 
b/lldb/include/lldb/Host/ProcessLaunchInfo.h
index ee9755580825..883133776214 100644
--- a/lldb/include/lldb/Host/ProcessLaunchInfo.h
+++ b/lldb/include/lldb/Host/ProcessLaunchInfo.h
@@ -20,6 +20,7 @@
 #include "lldb/Host/PseudoTerminal.h"
 #include "lldb/Utility/FileSpec.h"
 #include "lldb/Utility/ProcessInfo.h"
+#include "lldb/Utility/StructuredData.h"
 
 namespace lldb_private {
 
@@ -146,6 +147,28 @@ class ProcessLaunchInfo : public ProcessInfo {
 return m_flags.Test(lldb::eLaunchFlagDetachOnError);
   }
 
+  bool IsScriptedProcess() const {
+return !m_scripted_process_class_name.empty();
+  }
+
+  std::string GetScriptedProcessClassName() const {
+return m_scripted_process_class_name;
+  }
+
+  void SetScriptedProcessClassName(std::string name) {
+m_scripted_process_class_name = name;
+  }
+
+  lldb_private::StructuredData::DictionarySP
+  GetScriptedProcessDictionarySP() const {
+return m_scripted_process_dictionary_sp;
+  }
+
+  void SetScriptedProcessDictionarySP(
+  lldb_private::StructuredData::DictionarySP dictionary_sp) {
+m_scripted_process_dictionary_sp = dictionary_sp;
+  }
+
 protected:
   FileSpec m_working_dir;
   std::string m_p

[Lldb-commits] [lldb] f3176f5 - [lldb/bindings] Add Python ScriptedProcess base class to lldb module

2021-03-23 Thread Med Ismail Bennani via lldb-commits

Author: Med Ismail Bennani
Date: 2021-03-23T18:24:47+01:00
New Revision: f3176f5fede202985ab51d215f4d0a58b6c91d83

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

LOG: [lldb/bindings] Add Python ScriptedProcess base class to lldb module

In order to facilitate the writting of Scripted Processes, this patch
introduces a `ScriptedProcess` python base class in the lldb module.

The base class holds the python interface with all the - abstract -
methods that need to be implemented by the inherited class but also some
methods that can be overwritten.

This patch also provides an example of a Scripted Process with the
`MyScriptedProcess` class.

rdar://65508855

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

Signed-off-by: Med Ismail Bennani 

Added: 
lldb/examples/python/scripted_process/my_scripted_process.py
lldb/examples/python/scripted_process/scripted_process.py
lldb/test/API/functionalities/scripted_process/Makefile
lldb/test/API/functionalities/scripted_process/TestScriptedProcess.py
lldb/test/API/functionalities/scripted_process/main.c

Modified: 
lldb/bindings/python/CMakeLists.txt

Removed: 




diff  --git a/lldb/bindings/python/CMakeLists.txt 
b/lldb/bindings/python/CMakeLists.txt
index 2b14ee339d0d..9422ee00cb5f 100644
--- a/lldb/bindings/python/CMakeLists.txt
+++ b/lldb/bindings/python/CMakeLists.txt
@@ -104,6 +104,13 @@ function(finish_swig_python swig_target 
lldb_python_bindings_dir lldb_python_tar
 FILES "${LLDB_SOURCE_DIR}/examples/python/in_call_stack.py"
   "${LLDB_SOURCE_DIR}/examples/python/symbolication.py")
 
+  create_python_package(
+${swig_target}
+${lldb_python_target_dir}
+"plugins"
+FILES
+"${LLDB_SOURCE_DIR}/examples/python/scripted_process/scripted_process.py")
+
   if(APPLE)
 create_python_package(
   ${swig_target}

diff  --git a/lldb/examples/python/scripted_process/my_scripted_process.py 
b/lldb/examples/python/scripted_process/my_scripted_process.py
new file mode 100644
index ..d769e137d3f3
--- /dev/null
+++ b/lldb/examples/python/scripted_process/my_scripted_process.py
@@ -0,0 +1,42 @@
+import os
+
+import lldb
+from lldb.plugins.scripted_process import ScriptedProcess
+
+class MyScriptedProcess(ScriptedProcess):
+def __init__(self, target: lldb.SBTarget, args : lldb.SBStructuredData):
+super().__init__(target, args)
+
+def get_memory_region_containing_address(self, addr: int) -> 
lldb.SBMemoryRegionInfo:
+return self.memory_regions[0]
+
+def get_thread_with_id(self, tid: int):
+return {}
+
+def get_registers_for_thread(self, tid: int):
+return {}
+
+def read_memory_at_address(self, addr: int, size: int) -> lldb.SBData:
+data = lldb.SBData().CreateDataFromCString(
+self.target.GetByteOrder(),
+self.target.GetCodeByteSize(),
+"Hello, world!")
+return data
+
+def get_loaded_images(self):
+return self.loaded_images
+
+def get_process_id(self) -> int:
+return 42
+
+def is_alive(self) -> bool:
+return True
+
+def __lldb_init_module(debugger, dict):
+if not 'SKIP_SCRIPTED_PROCESS_LAUNCH' in os.environ:
+debugger.HandleCommand(
+"process launch -C %s.%s" % (__name__,
+ MyScriptedProcess.__name__))
+else:
+print("Name of the class that will manage the scripted process: 
'%s.%s'"
+% (__name__, MyScriptedProcess.__name__))
\ No newline at end of file

diff  --git a/lldb/examples/python/scripted_process/scripted_process.py 
b/lldb/examples/python/scripted_process/scripted_process.py
new file mode 100644
index ..354b20cfa7f9
--- /dev/null
+++ b/lldb/examples/python/scripted_process/scripted_process.py
@@ -0,0 +1,147 @@
+from abc import ABCMeta, abstractmethod
+import six
+
+import lldb
+
+@six.add_metaclass(ABCMeta)
+class ScriptedProcess:
+
+"""
+The base class for a scripted process.
+
+Most of the base class methods are `@abstractmethod` that need to be
+overwritten by the inheriting class.
+
+DISCLAIMER: THIS INTERFACE IS STILL UNDER DEVELOPMENT AND NOT STABLE.
+THE METHODS EXPOSED MIGHT CHANGE IN THE FUTURE.
+"""
+
+@abstractmethod
+def __init__(self, target, args):
+""" Construct a scripted process.
+
+Args:
+target (lldb.SBTarget): The target launching the scripted process.
+args (lldb.SBStructuredData): A Dictionary holding arbitrary
+key/value pairs used by the scripted process.
+"""
+self.target = None
+self.args = None
+if isinst

[Lldb-commits] [lldb] 1f6a57c - [lldb/Interpreter] Add ScriptInterpreter Wrapper for ScriptedProcess

2021-03-23 Thread Med Ismail Bennani via lldb-commits

Author: Med Ismail Bennani
Date: 2021-03-23T18:24:47+01:00
New Revision: 1f6a57c1a0fad922e04a2b1f414b092d4b0cd8b0

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

LOG: [lldb/Interpreter] Add ScriptInterpreter Wrapper for ScriptedProcess

This patch adds a ScriptedProcess interface to the ScriptInterpreter and
more specifically, to the ScriptInterpreterPython.

This interface will be used in the C++ `ScriptProcess` Process Plugin to
call the script methods.

At the moment, not all methods are implemented, they will upstreamed in
upcoming patches.

This patch also adds helper methods to the ScriptInterpreter to
convert `SBAPI` Types (SBData & SBError) to `lldb_private` types
(DataExtractor & Status).

rdar://65508855

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

Signed-off-by: Med Ismail Bennani 

Added: 
lldb/include/lldb/Interpreter/ScriptedProcessInterface.h
lldb/source/Plugins/ScriptInterpreter/Python/SWIGPythonBridge.cpp
lldb/source/Plugins/ScriptInterpreter/Python/SWIGPythonBridge.h

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

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

Modified: 
lldb/bindings/python/python-wrapper.swig
lldb/include/lldb/API/SBData.h
lldb/include/lldb/API/SBError.h
lldb/include/lldb/API/SBThreadPlan.h
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
lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.h
lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPythonImpl.h
lldb/unittests/ScriptInterpreter/Python/PythonTestSuite.cpp

Removed: 




diff  --git a/lldb/bindings/python/python-wrapper.swig 
b/lldb/bindings/python/python-wrapper.swig
index b189bfd7b9ebf..4c39e9c2c776a 100644
--- a/lldb/bindings/python/python-wrapper.swig
+++ b/lldb/bindings/python/python-wrapper.swig
@@ -275,6 +275,72 @@ LLDBSwigPythonCreateCommandObject
 Py_RETURN_NONE;
 }
 
+SWIGEXPORT void*
+LLDBSwigPythonCreateScriptedProcess
+(
+const char *python_class_name,
+const char *session_dictionary_name,
+const lldb::TargetSP& target_sp,
+lldb_private::StructuredDataImpl *args_impl,
+std::string &error_string
+)
+{
+if (python_class_name == NULL || python_class_name[0] == '\0' || 
!session_dictionary_name)
+Py_RETURN_NONE;
+
+
+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 nullptr;
+}
+
+// I do not want the SBTarget to be deallocated when going out of scope
+// because python has ownership of it and will manage memory for this
+// object by itself
+PythonObject target_arg(PyRefType::Owned, SBTypeToSWIGWrapper(new 
lldb::SBTarget(target_sp)));
+
+if (!target_arg.IsAllocated())
+Py_RETURN_NONE;
+
+llvm::Expected arg_info = pfunc.GetArgInfo();
+if (!arg_info) {
+llvm::handleAllErrors(
+arg_info.takeError(),
+[&](PythonException &E) {
+error_string.append(E.ReadBacktrace());
+},
+[&](const llvm::ErrorInfoBase &E) {
+error_string.append(E.message());
+});
+Py_RETURN_NONE;
+}
+
+PythonObject result = {};
+if (arg_info.get().max_positional_args == 2) {
+if (args_impl != nullptr) {
+   error_string.assign("args passed, but __init__ does not take an 
args dictionary");
+   Py_RETURN_NONE;
+}
+result = pfunc(target_arg, dict);
+} else if (arg_info.get().max_positional_args >= 3) {
+PythonObject args_arg(PyRefType::Owned, SBTypeToSWIGWrapper(new 
lldb::SBStructuredData(args_impl)));
+result = pfunc(target_arg, args_arg, dict);
+} else {
+error_string.assign("wrong number of arguments in __init__, should be 
2 or 3 (not including self)");
+Py_RETURN_NONE;
+}
+
+if (result.IsAllocated())
+return result.release();
+Py_RETURN_NONE;
+}
+
 SWIGEXPORT void*
 LLDBSwigPythonCreateScriptedThreadPlan
 (
@@ -802,6 +868,40 @@ LLDBSwigPython_GetValueSynthProviderInstance
 return ret_val;
 }
 
+SWIGEXPORT void*
+LLDBSWIGPython_CastPyObjectToSBData
+(
+PyObject* data
+)
+{
+lldb::SBData* sb_ptr = nullptr;
+
+in

[Lldb-commits] [lldb] dd391e1 - [lldb/Plugins] Add ScriptedProcess Process Plugin

2021-03-23 Thread Med Ismail Bennani via lldb-commits

Author: Med Ismail Bennani
Date: 2021-03-23T18:24:47+01:00
New Revision: dd391e1ef762d79f86112dc2480a89c9be066ce1

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

LOG: [lldb/Plugins] Add ScriptedProcess Process Plugin

This patch introduces Scripted Processes to lldb.

The goal, here, is to be able to attach in the debugger to fake processes
that are backed by script files (in Python, Lua, Swift, etc ...) and
inspect them statically.

Scripted Processes can be used in cooperative multithreading environments
like the XNU Kernel or other real-time operating systems, but it can
also help us improve the debugger testing infrastructure by writting
synthetic tests that simulates hard-to-reproduce process/thread states.

Although ScriptedProcess is not feature-complete at the moment, it has
basic execution capabilities and will improve in the following patches.

rdar://65508855

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

Signed-off-by: Med Ismail Bennani 

Added: 
lldb/source/Plugins/Process/scripted/CMakeLists.txt
lldb/source/Plugins/Process/scripted/ScriptedProcess.cpp
lldb/source/Plugins/Process/scripted/ScriptedProcess.h

Modified: 
lldb/bindings/python/CMakeLists.txt
lldb/include/lldb/Target/Process.h
lldb/source/Plugins/Process/CMakeLists.txt
lldb/source/Target/Target.cpp
lldb/test/API/functionalities/scripted_process/TestScriptedProcess.py

Removed: 




diff  --git a/lldb/bindings/python/CMakeLists.txt 
b/lldb/bindings/python/CMakeLists.txt
index 9422ee00cb5f..b5c75f5ab650 100644
--- a/lldb/bindings/python/CMakeLists.txt
+++ b/lldb/bindings/python/CMakeLists.txt
@@ -111,6 +111,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_process.py")
+
   if(APPLE)
 create_python_package(
   ${swig_target}

diff  --git a/lldb/include/lldb/Target/Process.h 
b/lldb/include/lldb/Target/Process.h
index fbdb5069b39f..127f03f3619c 100644
--- a/lldb/include/lldb/Target/Process.h
+++ b/lldb/include/lldb/Target/Process.h
@@ -2561,8 +2561,6 @@ void PruneThreadPlans();
   virtual size_t DoReadMemory(lldb::addr_t vm_addr, void *buf, size_t size,
   Status &error) = 0;
 
-  void SetState(lldb::EventSP &event_sp);
-
   lldb::StateType GetPrivateState();
 
   /// The "private" side of resuming a process.  This doesn't alter the state

diff  --git a/lldb/source/Plugins/Process/CMakeLists.txt 
b/lldb/source/Plugins/Process/CMakeLists.txt
index fdeb211fe7a2..bea5bac9eb21 100644
--- a/lldb/source/Plugins/Process/CMakeLists.txt
+++ b/lldb/source/Plugins/Process/CMakeLists.txt
@@ -12,6 +12,7 @@ elseif (CMAKE_SYSTEM_NAME MATCHES "Windows")
 elseif (CMAKE_SYSTEM_NAME MATCHES "Darwin")
   add_subdirectory(MacOSX-Kernel)
 endif()
+add_subdirectory(scripted)
 add_subdirectory(gdb-remote)
 add_subdirectory(Utility)
 add_subdirectory(elf-core)

diff  --git a/lldb/source/Plugins/Process/scripted/CMakeLists.txt 
b/lldb/source/Plugins/Process/scripted/CMakeLists.txt
new file mode 100644
index ..e2cfd058e278
--- /dev/null
+++ b/lldb/source/Plugins/Process/scripted/CMakeLists.txt
@@ -0,0 +1,13 @@
+add_lldb_library(lldbPluginScriptedProcess PLUGIN
+  ScriptedProcess.cpp
+
+  LINK_LIBS
+lldbCore
+lldbTarget
+lldbUtility
+lldbPluginProcessUtility
+  LINK_COMPONENTS
+BinaryFormat
+Object
+Support
+  )

diff  --git a/lldb/source/Plugins/Process/scripted/ScriptedProcess.cpp 
b/lldb/source/Plugins/Process/scripted/ScriptedProcess.cpp
new file mode 100644
index ..72be0f9d7831
--- /dev/null
+++ b/lldb/source/Plugins/Process/scripted/ScriptedProcess.cpp
@@ -0,0 +1,245 @@
+//===-- ScriptedProcess.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 "ScriptedProcess.h"
+
+#include "lldb/Core/Debugger.h"
+#include "lldb/Core/Module.h"
+#include "lldb/Core/PluginManager.h"
+
+#include "lldb/Host/OptionParser.h"
+
+#include "lldb/Interpreter/OptionArgParser.h"
+#include "lldb/Interpreter/OptionGroupBoolean.h"
+#include "lldb/Interpreter/ScriptInterpreter.h"
+#include "lldb/Target/MemoryRegionInfo.h"
+
+LLDB_PLUGIN_DEFINE(ScriptedProcess)
+
+using namespace lldb;
+using namespace lldb_private;
+
+ConstString Scr

[Lldb-commits] [lldb] 2c6710a - Teach DWARFExpression about DWARF 4+ Location Descriptions

2021-03-23 Thread Adrian Prantl via lldb-commits

Author: Adrian Prantl
Date: 2021-03-23T10:29:51-07:00
New Revision: 2c6710a5e10021387e47cf133a9929209c8e0415

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

LOG: Teach DWARFExpression about DWARF 4+ Location Descriptions

DWARFExpression implements the DWARF2 expression model that left
ambiguity on whether the result of an expression was a value or an
address. This patch implements the DWARF location description model
introduces in DWARF 4 and sets the result Value's kind accordingly, if
the expression comes from a DWARF v4+ compile unit. The nomenclature
is taken from DWARF 5, chapter 2.6 "Location Descriptions".

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

Added: 


Modified: 
lldb/source/Expression/DWARFExpression.cpp
lldb/unittests/Expression/DWARFExpressionTest.cpp

Removed: 




diff  --git a/lldb/source/Expression/DWARFExpression.cpp 
b/lldb/source/Expression/DWARFExpression.cpp
index a8843ca0543b..12fe76ee95d2 100644
--- a/lldb/source/Expression/DWARFExpression.cpp
+++ b/lldb/source/Expression/DWARFExpression.cpp
@@ -904,6 +904,52 @@ bool DWARFExpression::Evaluate(ExecutionContext *exe_ctx,
object_address_ptr, result, error_ptr);
 }
 
+namespace {
+/// The location description kinds described by the DWARF v5
+/// specification.  Composite locations are handled out-of-band and
+/// thus aren't part of the enum.
+enum LocationDescriptionKind {
+  Empty,
+  Memory,
+  Register,
+  Implicit
+  /* Composite*/
+};
+/// Adjust value's ValueType according to the kind of location description.
+void UpdateValueTypeFromLocationDescription(Log *log, const DWARFUnit 
*dwarf_cu,
+LocationDescriptionKind kind,
+Value *value = nullptr) {
+  // Note that this function is conflating DWARF expressions with
+  // DWARF location descriptions. Perhaps it would be better to define
+  // a wrapper for DWARFExpresssion::Eval() that deals with DWARF
+  // location descriptions (which consist of one or more DWARF
+  // expressions). But doing this would mean we'd also need factor the
+  // handling of DW_OP_(bit_)piece out of this function.
+  if (dwarf_cu && dwarf_cu->GetVersion() >= 4) {
+const char *log_msg = "DWARF location description kind: %s";
+switch (kind) {
+case Empty:
+  LLDB_LOGF(log, log_msg, "Empty");
+  break;
+case Memory:
+  LLDB_LOGF(log, log_msg, "Memory");
+  if (value->GetValueType() == Value::ValueType::Scalar)
+value->SetValueType(Value::ValueType::LoadAddress);
+  break;
+case Register:
+  LLDB_LOGF(log, log_msg, "Register");
+  value->SetValueType(Value::ValueType::Scalar);
+  break;
+case Implicit:
+  LLDB_LOGF(log, log_msg, "Implicit");
+  if (value->GetValueType() == Value::ValueType::LoadAddress)
+value->SetValueType(Value::ValueType::Scalar);
+  break;
+}
+  }
+}
+} // namespace
+
 bool DWARFExpression::Evaluate(
 ExecutionContext *exe_ctx, RegisterContext *reg_ctx,
 lldb::ModuleSP module_sp, const DataExtractor &opcodes,
@@ -952,6 +998,11 @@ bool DWARFExpression::Evaluate(
 !is_signed));
   };
 
+  // The default kind is a memory location. This is updated by any
+  // operation that changes this, such as DW_OP_stack_value, and reset
+  // by composition operations like DW_OP_piece.
+  LocationDescriptionKind dwarf4_location_description_kind = Memory;
+
   while (opcodes.ValidOffset(offset)) {
 const lldb::offset_t op_offset = offset;
 const uint8_t op = opcodes.GetU8(&offset);
@@ -1950,6 +2001,7 @@ bool DWARFExpression::Evaluate(
 case DW_OP_reg29:
 case DW_OP_reg30:
 case DW_OP_reg31: {
+  dwarf4_location_description_kind = Register;
   reg_num = op - DW_OP_reg0;
 
   if (ReadRegisterValueAsScalar(reg_ctx, reg_kind, reg_num, error_ptr, 
tmp))
@@ -1962,6 +2014,7 @@ bool DWARFExpression::Evaluate(
 //  ULEB128 literal operand that encodes the register.
 // DESCRIPTION: Push the value in register on the top of the stack.
 case DW_OP_regx: {
+  dwarf4_location_description_kind = Register;
   reg_num = opcodes.GetULEB128(&offset);
   if (ReadRegisterValueAsScalar(reg_ctx, reg_kind, reg_num, error_ptr, 
tmp))
 stack.push_back(tmp);
@@ -2085,12 +2138,18 @@ bool DWARFExpression::Evaluate(
 // provides a way of describing how large a part of a variable a particular
 // DWARF expression refers to.
 case DW_OP_piece: {
+  LocationDescriptionKind piece_locdesc = dwarf4_location_description_kind;
+  // Reset for the next piece.
+  dwarf4_location_description_kind = Memory;
+
   const uint64_t piece_byte_size = opcodes.GetULEB128(&offset);
 

[Lldb-commits] [PATCH] D98996: Teach DWARFExpression about DWARF 4+ Location Descriptions

2021-03-23 Thread Adrian Prantl 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 rG2c6710a5e100: Teach DWARFExpression about DWARF 4+ Location 
Descriptions (authored by aprantl).
Herald added a project: LLDB.

Changed prior to commit:
  https://reviews.llvm.org/D98996?vs=332493&id=332717#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98996

Files:
  lldb/source/Expression/DWARFExpression.cpp
  lldb/unittests/Expression/DWARFExpressionTest.cpp

Index: lldb/unittests/Expression/DWARFExpressionTest.cpp
===
--- lldb/unittests/Expression/DWARFExpressionTest.cpp
+++ lldb/unittests/Expression/DWARFExpressionTest.cpp
@@ -213,42 +213,45 @@
   //
 
   // Leave as is.
-  EXPECT_THAT_EXPECTED(t.Eval({DW_OP_const4u, 0x11, 0x22, 0x33, 0x44, //
-   DW_OP_convert, offs_uint32_t}),
-   llvm::HasValue(GetScalar(64, 0x44332211, not_signed)));
+  EXPECT_THAT_EXPECTED(
+  t.Eval({DW_OP_const4u, 0x11, 0x22, 0x33, 0x44, //
+  DW_OP_convert, offs_uint32_t, DW_OP_stack_value}),
+  llvm::HasValue(GetScalar(64, 0x44332211, not_signed)));
 
   // Zero-extend to 64 bits.
-  EXPECT_THAT_EXPECTED(t.Eval({DW_OP_const4u, 0x11, 0x22, 0x33, 0x44, //
-   DW_OP_convert, offs_uint64_t}),
-   llvm::HasValue(GetScalar(64, 0x44332211, not_signed)));
+  EXPECT_THAT_EXPECTED(
+  t.Eval({DW_OP_const4u, 0x11, 0x22, 0x33, 0x44, //
+  DW_OP_convert, offs_uint64_t, DW_OP_stack_value}),
+  llvm::HasValue(GetScalar(64, 0x44332211, not_signed)));
 
   // Sign-extend to 64 bits.
   EXPECT_THAT_EXPECTED(
   t.Eval({DW_OP_const4s, 0xcc, 0xdd, 0xee, 0xff, //
-  DW_OP_convert, offs_sint64_t}),
+  DW_OP_convert, offs_sint64_t, DW_OP_stack_value}),
   llvm::HasValue(GetScalar(64, 0xffeeddcc, is_signed)));
 
   // Sign-extend, then truncate.
-  EXPECT_THAT_EXPECTED(t.Eval({DW_OP_const4s, 0xcc, 0xdd, 0xee, 0xff, //
-   DW_OP_convert, offs_sint64_t,  //
-   DW_OP_convert, offs_uint32_t}),
-   llvm::HasValue(GetScalar(32, 0xffeeddcc, not_signed)));
+  EXPECT_THAT_EXPECTED(
+  t.Eval({DW_OP_const4s, 0xcc, 0xdd, 0xee, 0xff, //
+  DW_OP_convert, offs_sint64_t,  //
+  DW_OP_convert, offs_uint32_t, DW_OP_stack_value}),
+  llvm::HasValue(GetScalar(32, 0xffeeddcc, not_signed)));
 
   // Truncate to default unspecified (pointer-sized) type.
   EXPECT_THAT_EXPECTED(t.Eval({DW_OP_const4s, 0xcc, 0xdd, 0xee, 0xff, //
DW_OP_convert, offs_sint64_t,  //
-   DW_OP_convert, 0x00}),
+   DW_OP_convert, 0x00, DW_OP_stack_value}),
llvm::HasValue(GetScalar(32, 0xffeeddcc, not_signed)));
 
   // Truncate to 8 bits.
-  EXPECT_THAT_EXPECTED(
-  t.Eval({DW_OP_const4s, 'A', 'B', 'C', 'D', DW_OP_convert, offs_uchar}),
-  llvm::HasValue(GetScalar(8, 'A', not_signed)));
+  EXPECT_THAT_EXPECTED(t.Eval({DW_OP_const4s, 'A', 'B', 'C', 'D', DW_OP_convert,
+   offs_uchar, DW_OP_stack_value}),
+   llvm::HasValue(GetScalar(8, 'A', not_signed)));
 
   // Also truncate to 8 bits.
-  EXPECT_THAT_EXPECTED(
-  t.Eval({DW_OP_const4s, 'A', 'B', 'C', 'D', DW_OP_convert, offs_schar}),
-  llvm::HasValue(GetScalar(8, 'A', is_signed)));
+  EXPECT_THAT_EXPECTED(t.Eval({DW_OP_const4s, 'A', 'B', 'C', 'D', DW_OP_convert,
+   offs_schar, DW_OP_stack_value}),
+   llvm::HasValue(GetScalar(8, 'A', is_signed)));
 
   //
   // Errors.
@@ -354,4 +357,13 @@
   // Evaluate returns LLDB_INVALID_ADDRESS for all load addresses.
   EXPECT_THAT_EXPECTED(Evaluate({DW_OP_lit4, DW_OP_deref}, {}, {}, &exe_ctx),
llvm::HasValue(Scalar(LLDB_INVALID_ADDRESS)));
+  // Memory location: *0x4.
+  // Evaluate returns LLDB_INVALID_ADDRESS for all load addresses.
+  EXPECT_THAT_EXPECTED(Evaluate({DW_OP_lit4}, {}, {}, &exe_ctx),
+   llvm::HasValue(Scalar(4)));
+  // Implicit location: *0x4.
+  // Evaluate returns LLDB_INVALID_ADDRESS for all load addresses.
+  EXPECT_THAT_EXPECTED(
+  Evaluate({DW_OP_lit4, DW_OP_deref, DW_OP_stack_value}, {}, {}, &exe_ctx),
+  llvm::HasValue(GetScalar(32, 0x07060504, false)));
 }
Index: lldb/source/Expression/DWARFExpression.cpp
===
--- lldb/source/Expression/DWARFExpression.cpp
+++ lldb/source/Expression/DWARFExpression.cpp
@@ -904,6 +904,52 @@
object_address_ptr, result, error_ptr);
 }
 
+namespace {
+/// The location descripti

[Lldb-commits] [PATCH] D97739: Add a progress class that can track and report long running operations that happen in LLDB.

2021-03-23 Thread David Blaikie via Phabricator via lldb-commits
dblaikie added inline comments.



Comment at: lldb/source/API/SBDebugger.cpp:857
+error = m_opaque_sp->GetTargetList().CreateTarget(
+*m_opaque_sp, filename, arch, eLoadDependentsYes, platform_sp,
+target_sp);

clayborg wrote:
> jingham wrote:
> > dblaikie wrote:
> > > jingham wrote:
> > > > clayborg wrote:
> > > > > I submit with "arc diff" and it will cause lint errors if I don't 
> > > > > allow it to fix the lint errors it finds.
> > > > I'm 100% not in favor of tools that force irrelevant changes to be 
> > > > included.  But that is a suggested tool so somebody must like that.
> > > They aren't forced - you can submit with linter errors if they don't seem 
> > > helpful.
> > > 
> > > Pre-committing format changes in standalone NFC commits would generally 
> > > be preferable. & the linter shouldn't be flagging untouched lines - is it?
> > It looks like the file had changes 700 lines before & 900 lines after, but 
> > these lines weren't changed except by the linter... 
> Actually come to thing about it, it is probably because my editor removes 
> trailing newlines and then the linter deems those lines fair game...
Yeah, if your editor is touching otherwise unmodified lines that'll be a 
problem (for the linter, or without the linter - you'd end up with unrelated 
changes in the diff, etc).

clang-format can be integrated into some editors (vim, for instance) to 
auto-format only changed lines on save, which is what I use - not sure if 
there's an option to use that in your workflow.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97739

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


[Lldb-commits] [PATCH] D98822: [lldb] [Process/Linux] Watch for fork notifications

2021-03-23 Thread Michał Górny via Phabricator via lldb-commits
mgorny updated this revision to Diff 332792.
mgorny retitled this revision from "[lldb] follow-fork/vfork support [WIP]" to 
"[lldb] [Process/Linux] Watch for fork notifications".
mgorny edited the summary of this revision.
mgorny added a comment.

So I've decided to circle back a bit and start by adding server-side 
detaching-on-fork support. This means that this patch doesn't depend on 
multiprocess support anymore.

It includes refactoring clone/fork/vfork event monitoring into a single 
function. Right now, only forks are supported — the handler creates a local 
`NativeProcessLinux` instance (@labath, any suggestions how to make this less 
hacky?), duplicates parent's breakpoints into it (just like the child gets 
parent's memory) and uses it to clear these breakpoints and detach the child 
process. I suppose this will make things easier when we want to make the class 
more persistent in the future.

TODO: vfork, clone


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

https://reviews.llvm.org/D98822

Files:
  lldb/include/lldb/Host/common/NativeProcessProtocol.h
  lldb/source/Host/common/NativeProcessProtocol.cpp
  lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp
  lldb/source/Plugins/Process/Linux/NativeProcessLinux.h
  lldb/test/Shell/Subprocess/Inputs/fork.c
  lldb/test/Shell/Subprocess/fork-follow-parent-softbp.test
  lldb/test/Shell/Subprocess/fork-follow-parent.test

Index: lldb/test/Shell/Subprocess/fork-follow-parent.test
===
--- /dev/null
+++ lldb/test/Shell/Subprocess/fork-follow-parent.test
@@ -0,0 +1,12 @@
+# Verify that the debugger continues tracing the parent after fork().
+# REQUIRES: native
+# RUN: %clang_host %p/Inputs/fork.c -o %t
+# RUN: %lldb -b -s %s %t | FileCheck %s
+b parent_func
+process launch
+# CHECK: function run in child
+# CHECK-NOT: function run in parent
+# CHECK: stop reason = breakpoint
+continue
+# CHECK: function run in parent
+# CHECK: child exited: 0
Index: lldb/test/Shell/Subprocess/fork-follow-parent-softbp.test
===
--- /dev/null
+++ lldb/test/Shell/Subprocess/fork-follow-parent-softbp.test
@@ -0,0 +1,13 @@
+# Verify that the debugger continues tracing the parent after fork().
+# REQUIRES: native
+# RUN: %clang_host %p/Inputs/fork.c -o %t
+# RUN: %lldb -b -s %s %t | FileCheck %s
+b parent_func
+b child_func
+process launch
+# CHECK: function run in child
+# CHECK-NOT: function run in parent
+# CHECK: stop reason = breakpoint
+continue
+# CHECK: function run in parent
+# CHECK: child exited: 0
Index: lldb/test/Shell/Subprocess/Inputs/fork.c
===
--- /dev/null
+++ lldb/test/Shell/Subprocess/Inputs/fork.c
@@ -0,0 +1,37 @@
+#include 
+#include 
+#include 
+#include 
+#include 
+
+void common_func() {
+  printf("common function\n");
+}
+
+void parent_func() {
+  printf("function run in parent\n");
+}
+
+void child_func() {
+  printf("function run in child\n");
+}
+
+int main() {
+  pid_t pid = fork();
+  assert(pid != -1);
+
+  common_func();
+  if (pid == 0) {
+child_func();
+_exit(0);
+  }
+
+  parent_func();
+  int status;
+  pid_t waited = waitpid(pid, &status, 0);
+  assert(waited == pid);
+  assert(WIFEXITED(status));
+  printf("child exited: %d\n", WEXITSTATUS(status));
+
+  return 0;
+}
Index: lldb/source/Plugins/Process/Linux/NativeProcessLinux.h
===
--- lldb/source/Plugins/Process/Linux/NativeProcessLinux.h
+++ lldb/source/Plugins/Process/Linux/NativeProcessLinux.h
@@ -158,7 +158,7 @@
 
   void MonitorCallback(lldb::pid_t pid, bool exited, WaitStatus status);
 
-  void WaitForNewThread(::pid_t tid);
+  void WaitForCloneNotification(::pid_t pid);
 
   void MonitorSIGTRAP(const siginfo_t &info, NativeThreadLinux &thread);
 
@@ -248,6 +248,21 @@
 
   lldb::user_id_t m_pt_proces_trace_id = LLDB_INVALID_UID;
   TraceOptions m_pt_process_trace_config;
+
+  struct CloneInfo {
+uint32_t event;
+lldb::tid_t parent_tid;
+  };
+
+  // Map of child processes that have been signaled once, and we are
+  // waiting for the second signal.
+  llvm::DenseMap> m_pending_pid_map;
+
+  // Handle a clone()-like event.  If received by parent, clone_info contains
+  // additional info.  Returns true if the event is handled, or false if it
+  // is pending second notification.
+  bool MonitorClone(lldb::pid_t child_pid,
+llvm::Optional clone_info);
 };
 
 } // namespace process_linux
Index: lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp
===
--- lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp
+++ lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp
@@ -383,14 +383,15 @@
   ptrace_opts |= PTRACE_O_TRACEEXIT;
 
   // Have the tracer trace threads which spawn in the inferior process.
-  /

[Lldb-commits] [lldb] ec00502 - [NFC][LLDB] Removing extra semicolons to silence -Wc++98-compat-extra-semi diagnostics

2021-03-23 Thread Shafik Yaghmour via lldb-commits

Author: Shafik Yaghmour
Date: 2021-03-23T14:32:36-07:00
New Revision: ec00502b9f4021112c22b87ff849ecb5505763dd

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

LOG: [NFC][LLDB] Removing extra semicolons to silence -Wc++98-compat-extra-semi 
diagnostics

Added: 


Modified: 
lldb/source/Plugins/Process/scripted/ScriptedProcess.cpp
lldb/source/Plugins/ScriptInterpreter/Python/SWIGPythonBridge.h
lldb/tools/debugserver/source/MacOSX/ThreadInfo.h

Removed: 




diff  --git a/lldb/source/Plugins/Process/scripted/ScriptedProcess.cpp 
b/lldb/source/Plugins/Process/scripted/ScriptedProcess.cpp
index 72be0f9d7831..b4ec4c7124d2 100644
--- a/lldb/source/Plugins/Process/scripted/ScriptedProcess.cpp
+++ b/lldb/source/Plugins/Process/scripted/ScriptedProcess.cpp
@@ -123,7 +123,7 @@ Status ScriptedProcess::DoLaunch(Module *exe_module,
   }
 
   return status;
-};
+}
 
 void ScriptedProcess::DidLaunch() {
   if (m_interpreter)

diff  --git a/lldb/source/Plugins/ScriptInterpreter/Python/SWIGPythonBridge.h 
b/lldb/source/Plugins/ScriptInterpreter/Python/SWIGPythonBridge.h
index 1843d9237d82..1ef792bcf303 100644
--- a/lldb/source/Plugins/ScriptInterpreter/Python/SWIGPythonBridge.h
+++ b/lldb/source/Plugins/ScriptInterpreter/Python/SWIGPythonBridge.h
@@ -50,7 +50,7 @@ extern "C" void *LLDBSWIGPython_CastPyObjectToSBData(void 
*data);
 extern "C" void *LLDBSWIGPython_CastPyObjectToSBError(void *data);
 extern "C" void *LLDBSWIGPython_CastPyObjectToSBValue(void *data);
 
-}; // namespace lldb_private
+} // namespace lldb_private
 
 #endif // LLDB_ENABLE_PYTHON
 #endif // LLDB_PLUGINS_SCRIPTINTERPRETER_PYTHON_SWIGPYTHONBRIDGE_H

diff  --git a/lldb/tools/debugserver/source/MacOSX/ThreadInfo.h 
b/lldb/tools/debugserver/source/MacOSX/ThreadInfo.h
index a114a47eaab8..592d50fd4284 100644
--- a/lldb/tools/debugserver/source/MacOSX/ThreadInfo.h
+++ b/lldb/tools/debugserver/source/MacOSX/ThreadInfo.h
@@ -20,6 +20,6 @@ class QoS {
   std::string printable_name;
   uint32_t enum_value;
 };
-};
+}
 
 #endif // LLDB_TOOLS_DEBUGSERVER_SOURCE_MACOSX_THREADINFO_H



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


[Lldb-commits] [PATCH] D95713: [lldb/Plugins] Add ScriptedProcess Process Plugin

2021-03-23 Thread David Zarzycki via Phabricator via lldb-commits
davezarzycki added a comment.

An auto-bisecting cron job has identified this change as a regression on Fedora 
33 (x86-64). Can we get a quick fix or revert this? Here is the build output:

https://znu.io/dd391e1ef762d79f86112dc2480a89c9be066ce1-bisect.txt


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95713

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


[Lldb-commits] [lldb] a0793cb - Update SafeMachO.h to #undefine more names

2021-03-23 Thread Jason Molenda via lldb-commits

Author: Jason Molenda
Date: 2021-03-23T23:34:22-07:00
New Revision: a0793cb1f1a64f61675767d551bbd26ea41a4e93

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

LOG: Update SafeMachO.h to #undefine more names

Depending on include order, these can cause build errors when
including the llvm MachO.h where these are defined as enums.
Update the list to include some more names.

Added: 


Modified: 
lldb/include/lldb/Host/SafeMachO.h

Removed: 




diff  --git a/lldb/include/lldb/Host/SafeMachO.h 
b/lldb/include/lldb/Host/SafeMachO.h
index d7c376d23a4a..0540383b8c52 100644
--- a/lldb/include/lldb/Host/SafeMachO.h
+++ b/lldb/include/lldb/Host/SafeMachO.h
@@ -23,6 +23,7 @@
 
 #undef CPU_ARCH_MASK
 #undef CPU_ARCH_ABI64
+#undef CPU_ARCH_ABI64_32
 
 #undef CPU_TYPE_ANY
 #undef CPU_TYPE_X86
@@ -31,12 +32,13 @@
 #undef CPU_TYPE_MC98000
 #undef CPU_TYPE_ARM
 #undef CPU_TYPE_ARM64
+#undef CPU_TYPE_ARM64_32
 #undef CPU_TYPE_SPARC
 #undef CPU_TYPE_POWERPC
 #undef CPU_TYPE_POWERPC64
 
-#undef CPU_SUB_TYPE_MASK
-#undef CPU_SUB_TYPE_LIB64
+#undef CPU_SUBTYPE_MASK
+#undef CPU_SUBTYPE_LIB64
 
 #undef CPU_SUBTYPE_MULTIPLE
 
@@ -88,6 +90,9 @@
 #undef CPU_SUBTYPE_ARM_V7M
 #undef CPU_SUBTYPE_ARM_V7EM
 
+#undef CPU_SUBTYPE_ARM64E
+#undef CPU_SUBTYPE_ARM64_32_V8
+#undef CPU_SUBTYPE_ARM64_V8
 #undef CPU_SUBTYPE_ARM64_ALL
 
 #undef CPU_SUBTYPE_SPARC_ALL
@@ -110,6 +115,47 @@
 #undef CPU_SUBTYPE_MC98_ALL
 #undef CPU_SUBTYPE_MC98601
 
+#undef VM_PROT_READ
+#undef VM_PROT_WRITE
+#undef VM_PROT_EXECUTE
+
+#undef ARM_DEBUG_STATE
+#undef ARM_EXCEPTION_STATE
+#undef ARM_EXCEPTION_STATE64
+#undef ARM_EXCEPTION_STATE64_COUNT
+#undef ARM_THREAD_STATE
+#undef ARM_THREAD_STATE64
+#undef ARM_THREAD_STATE64_COUNT
+#undef ARM_THREAD_STATE_COUNT
+#undef ARM_VFP_STATE
+#undef ARN_THREAD_STATE_NONE
+#undef PPC_EXCEPTION_STATE
+#undef PPC_EXCEPTION_STATE64
+#undef PPC_FLOAT_STATE
+#undef PPC_THREAD_STATE
+#undef PPC_THREAD_STATE64
+#undef PPC_THREAD_STATE_NONE
+#undef PPC_VECTOR_STATE
+#undef x86_DEBUG_STATE
+#undef x86_DEBUG_STATE32
+#undef x86_DEBUG_STATE64
+#undef x86_EXCEPTION_STATE
+#undef x86_EXCEPTION_STATE32
+#undef x86_EXCEPTION_STATE64
+#undef x86_EXCEPTION_STATE64_COUNT
+#undef x86_EXCEPTION_STATE_COUNT
+#undef x86_FLOAT_STATE
+#undef x86_FLOAT_STATE32
+#undef x86_FLOAT_STATE64
+#undef x86_FLOAT_STATE64_COUNT
+#undef x86_FLOAT_STATE_COUNT
+#undef x86_THREAD_STATE
+#undef x86_THREAD_STATE32
+#undef x86_THREAD_STATE32_COUNT
+#undef x86_THREAD_STATE64
+#undef x86_THREAD_STATE64_COUNT
+#undef x86_THREAD_STATE_COUNT
+
 #include "llvm/BinaryFormat/MachO.h"
 
 #endif // LLDB_HOST_SAFEMACHO_H



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