[Lldb-commits] [lldb] 03a3f86 - [lldb] Fix compilation by adjusting to the new ASTContext signature.

2021-07-11 Thread Vassil Vassilev via lldb-commits

Author: Vassil Vassilev
Date: 2021-07-11T10:53:36Z
New Revision: 03a3f86071c10a1f6cbbf7375aa6fe9d94168972

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

LOG: [lldb] Fix compilation by adjusting to the new ASTContext signature.

This change was introduced in https://reviews.llvm.org/D104918

Added: 


Modified: 
lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp

Removed: 




diff  --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp 
b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
index 306573e06250e..137cba40e1d65 100644
--- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -746,7 +746,7 @@ void TypeSystemClang::CreateASTContext() {
   *m_diagnostics_engine_up, *m_file_manager_up);
   m_ast_up = std::make_unique(
   *m_language_options_up, *m_source_manager_up, *m_identifier_table_up,
-  *m_selector_table_up, *m_builtins_up);
+  *m_selector_table_up, *m_builtins_up, TU_Complete);
 
   m_diagnostic_consumer_up = std::make_unique();
   m_ast_up->getDiagnostics().setClient(m_diagnostic_consumer_up.get(), false);



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


[Lldb-commits] [PATCH] D105779: RFC: [lldb] Fix editline unicode on Linux

2021-07-11 Thread Jan Kratochvil via Phabricator via lldb-commits
jankratochvil created this revision.
jankratochvil added reviewers: teemperor, nealsid, labath.
jankratochvil added a project: LLDB.
Herald added a subscriber: JDevlieghere.
jankratochvil requested review of this revision.

[[ https://lists.llvm.org/pipermail/lldb-dev/2021-July/016961.html | [lldb-dev] 
proposed change to remove conditional WCHAR support in libedit wrapper ]]
There is already `setlocale` in lldb/source/Core/IOHandlerCursesGUI.cpp 

 but that does not apply for Editline GUI editing.
Unaware how to make automated test for this, it requires pty.
Also maybe it is not needed on OSX so it should be excluded there?


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D105779

Files:
  lldb/source/Host/common/Editline.cpp


Index: lldb/source/Host/common/Editline.cpp
===
--- lldb/source/Host/common/Editline.cpp
+++ lldb/source/Host/common/Editline.cpp
@@ -1401,6 +1401,9 @@
 }
   }
 #endif
+
+  // Required for libedit unicode as it uses iswprint.
+  ::setlocale(LC_CTYPE, "");
 }
 
 Editline::~Editline() {


Index: lldb/source/Host/common/Editline.cpp
===
--- lldb/source/Host/common/Editline.cpp
+++ lldb/source/Host/common/Editline.cpp
@@ -1401,6 +1401,9 @@
 }
   }
 #endif
+
+  // Required for libedit unicode as it uses iswprint.
+  ::setlocale(LC_CTYPE, "");
 }
 
 Editline::~Editline() {
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D105779: RFC: [lldb] Fix editline unicode on Linux

2021-07-11 Thread Jan Kratochvil via Phabricator via lldb-commits
jankratochvil updated this revision to Diff 357799.
jankratochvil edited the summary of this revision.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105779

Files:
  lldb/source/Core/IOHandlerCursesGUI.cpp
  lldb/tools/driver/Driver.cpp


Index: lldb/tools/driver/Driver.cpp
===
--- lldb/tools/driver/Driver.cpp
+++ lldb/tools/driver/Driver.cpp
@@ -31,6 +31,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -867,6 +868,9 @@
 }
 
 int main(int argc, char const *argv[]) {
+  ::setlocale(LC_ALL, "");
+  ::setlocale(LC_CTYPE, "");
+
   // Setup LLVM signal handlers and make sure we call llvm_shutdown() on
   // destruction.
   llvm::InitLLVM IL(argc, argv, /*InstallPipeSignalExitHandler=*/false);
Index: lldb/source/Core/IOHandlerCursesGUI.cpp
===
--- lldb/source/Core/IOHandlerCursesGUI.cpp
+++ lldb/source/Core/IOHandlerCursesGUI.cpp
@@ -67,7 +67,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -2627,8 +2626,6 @@
   }
 
   void Initialize() {
-::setlocale(LC_ALL, "");
-::setlocale(LC_CTYPE, "");
 m_screen = ::newterm(nullptr, m_out, m_in);
 ::start_color();
 ::curs_set(0);


Index: lldb/tools/driver/Driver.cpp
===
--- lldb/tools/driver/Driver.cpp
+++ lldb/tools/driver/Driver.cpp
@@ -31,6 +31,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -867,6 +868,9 @@
 }
 
 int main(int argc, char const *argv[]) {
+  ::setlocale(LC_ALL, "");
+  ::setlocale(LC_CTYPE, "");
+
   // Setup LLVM signal handlers and make sure we call llvm_shutdown() on
   // destruction.
   llvm::InitLLVM IL(argc, argv, /*InstallPipeSignalExitHandler=*/false);
Index: lldb/source/Core/IOHandlerCursesGUI.cpp
===
--- lldb/source/Core/IOHandlerCursesGUI.cpp
+++ lldb/source/Core/IOHandlerCursesGUI.cpp
@@ -67,7 +67,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -2627,8 +2626,6 @@
   }
 
   void Initialize() {
-::setlocale(LC_ALL, "");
-::setlocale(LC_CTYPE, "");
 m_screen = ::newterm(nullptr, m_out, m_in);
 ::start_color();
 ::curs_set(0);
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] 5922f23 - Revert "[clang-repl] Implement partial translation units and error recovery."

2021-07-11 Thread Vassil Vassilev via lldb-commits

Author: Vassil Vassilev
Date: 2021-07-11T14:40:10Z
New Revision: 5922f234c8c95f61534160a31db15dfc10da9b60

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

LOG: Revert "[clang-repl] Implement partial translation units and error 
recovery."

This reverts commit 6775fc6ffa3ca1c36b20c25fa4e7f48f81213cf2.

It also reverts "[lldb] Fix compilation by adjusting to the new ASTContext 
signature."

This reverts commit 03a3f86071c10a1f6cbbf7375aa6fe9d94168972.

We see some failures on the lldb infrastructure, these changes might play a role
in it. Let's revert it now and see if the bots will become green.

Ref: https://reviews.llvm.org/D104918

Added: 
clang/include/clang/Interpreter/Transaction.h

Modified: 
clang/include/clang/AST/ASTContext.h
clang/include/clang/AST/Decl.h
clang/include/clang/AST/Redeclarable.h
clang/include/clang/Basic/LangOptions.h
clang/include/clang/Interpreter/Interpreter.h
clang/include/clang/Lex/Preprocessor.h
clang/include/clang/Sema/Sema.h
clang/lib/AST/ASTContext.cpp
clang/lib/AST/Decl.cpp
clang/lib/AST/DeclBase.cpp
clang/lib/Frontend/ASTUnit.cpp
clang/lib/Frontend/CompilerInstance.cpp
clang/lib/Interpreter/IncrementalParser.cpp
clang/lib/Interpreter/IncrementalParser.h
clang/lib/Interpreter/Interpreter.cpp
clang/lib/Sema/Sema.cpp
clang/lib/Serialization/ASTReader.cpp
clang/tools/clang-import-test/clang-import-test.cpp
clang/unittests/AST/ASTVectorTest.cpp
clang/unittests/Interpreter/IncrementalProcessingTest.cpp
clang/unittests/Interpreter/InterpreterTest.cpp
clang/unittests/Lex/PPCallbacksTest.cpp
lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp

Removed: 
clang/include/clang/Interpreter/PartialTranslationUnit.h



diff  --git a/clang/include/clang/AST/ASTContext.h 
b/clang/include/clang/AST/ASTContext.h
index 34299581d89d4..5032f3194a9b7 100644
--- a/clang/include/clang/AST/ASTContext.h
+++ b/clang/include/clang/AST/ASTContext.h
@@ -459,7 +459,6 @@ class ASTContext : public RefCountedBase {
   friend class ASTWriter;
   template  friend class serialization::AbstractTypeReader;
   friend class CXXRecordDecl;
-  friend class IncrementalParser;
 
   /// A mapping to contain the template or declaration that
   /// a variable declaration describes or was instantiated from,
@@ -568,7 +567,7 @@ class ASTContext : public RefCountedBase {
   ImportDecl *FirstLocalImport = nullptr;
   ImportDecl *LastLocalImport = nullptr;
 
-  TranslationUnitDecl *TUDecl = nullptr;
+  TranslationUnitDecl *TUDecl;
   mutable ExternCContextDecl *ExternCContext = nullptr;
   mutable BuiltinTemplateDecl *MakeIntegerSeqDecl = nullptr;
   mutable BuiltinTemplateDecl *TypePackElementDecl = nullptr;
@@ -625,7 +624,6 @@ class ASTContext : public RefCountedBase {
   IdentifierTable &Idents;
   SelectorTable &Selectors;
   Builtin::Context &BuiltinInfo;
-  const TranslationUnitKind TUKind;
   mutable DeclarationNameTable DeclarationNames;
   IntrusiveRefCntPtr ExternalSource;
   ASTMutationListener *Listener = nullptr;
@@ -1024,18 +1022,7 @@ class ASTContext : public RefCountedBase {
   /// Get the initializations to perform when importing a module, if any.
   ArrayRef getModuleInitializers(Module *M);
 
-  TranslationUnitDecl *getTranslationUnitDecl() const {
-return TUDecl->getMostRecentDecl();
-  }
-  void addTranslationUnitDecl() {
-assert(!TUDecl || TUKind == TU_Incremental);
-TranslationUnitDecl *NewTUDecl = TranslationUnitDecl::Create(*this);
-if (TraversalScope.empty() || TraversalScope.back() == TUDecl)
-  TraversalScope = {NewTUDecl};
-if (TUDecl)
-  NewTUDecl->setPreviousDecl(TUDecl);
-TUDecl = NewTUDecl;
-  }
+  TranslationUnitDecl *getTranslationUnitDecl() const { return TUDecl; }
 
   ExternCContextDecl *getExternCContextDecl() const;
   BuiltinTemplateDecl *getMakeIntegerSeqDecl() const;
@@ -1112,8 +1099,7 @@ class ASTContext : public RefCountedBase {
   llvm::DenseSet CUDADeviceVarODRUsedByHost;
 
   ASTContext(LangOptions &LOpts, SourceManager &SM, IdentifierTable &idents,
- SelectorTable &sels, Builtin::Context &builtins,
- TranslationUnitKind TUKind);
+ SelectorTable &sels, Builtin::Context &builtins);
   ASTContext(const ASTContext &) = delete;
   ASTContext &operator=(const ASTContext &) = delete;
   ~ASTContext();

diff  --git a/clang/include/clang/AST/Decl.h b/clang/include/clang/AST/Decl.h
index 510bf89789851..d22594ae8442a 100644
--- a/clang/include/clang/AST/Decl.h
+++ b/clang/include/clang/AST/Decl.h
@@ -79,23 +79,7 @@ class UnresolvedSetImpl;
 class VarTemplateDecl;
 
 /// The top declaration context.
-class TranslationUnitDecl : public Decl,
-public DeclContext,
-   

Re: [Lldb-commits] [PATCH] D105470: [lldb] Clear children of ValueObject on value update

2021-07-11 Thread Jim Ingham via lldb-commits

> On Jul 10, 2021, at 6:18 AM, Andy Yankovsky via Phabricator 
>  wrote:
> 
> werat added a comment.
> 
> Thanks for the explanation! But at this point I feel I'm a bit confused about 
> how it all _supposed_ to work in the current design :)
> 
> If I understand correctly, there are four "types" of values from the user 
> (API) perspective:
> 
> 1. `ExpressionResult` -- value returned by `SBFrame::EvaluateExpression()`
> 2. `ExpressionPersistentVariable` -- value created by the expression via 
> `auto $name = ...` syntax. Can be obtained by `SBFrame::FindValue("$name", 
> lldb::eValueTypeConstResult)`.
> 3. "Const value" -- value created by `SBTarget::CreateValueFromData()` or 
> `SBTarget::CreateValueFromAddress`
> 4. "Variable reference" -- value returned by `SBFrame::FindVariable()`
> 
> For which of these value the following test is supposed to work?
> 
>  struct Foo { int x; };
>  Foo* f1 = { .x = 1}
>  Foo* f2 = { .x = 2}  # pseudo-C for simplicity
> 
>  f1_ref = ...  # Get a value that holds the value of `f1` using one of the 
> four methods described above
>  print(f1_ref.GetChild(0))  # '1'
>  f1_ref.SetValueFromCString(frame.FindVariable('f2').value)
>  print(f1_ref.GetChild(0))  # '2'
> 
> My experiments show that it works for "variable references" and "const 
> values" created by `CreateValueFromAddress` (but _not_ `CreateValueFromData`).
> If I understand your comment correctly, you're saying it should work only for 
> `ExpressionPersistentVariable` values (#2). Is that right?

No, that is not what I meant to say.  

Of the 4 cases above (there's also Register SBValues BTW) I was only arguing 
that #1 should not be settable.  After all, you might have done:

expr 5 + 5
(int) $0 = 10

I'm not sure what $0 = 11 would mean.  But beyond that, they are useful for 
freezing values for later consultation, so you want to make sure that once the 
process has changed state
they won't try to update themselves, accidentally or on purpose.

ValueObjectVariable objects should definitely be settable.  That's how most 
GUI's would implement choosing a child from a Variables display and changing 
its value, so setting them is
actually a pretty common operation.

Persistent variables also need to be settable, since they are often used as 
scratch counters and so forth, and wouldn't be of nearly as much use if they 
weren't.

CreateValueFromAddress values relate to things in memory (and actually track 
changes in the memory underlying them when the process changes state).  Since 
they are the way
that you can do casts to get a structured access to raw memory at the SB API 
layer, it seems reasonable that they should also be settable.

And objects made from CreateValueFromData are mostly used for artificial tasks 
like making backing ValueObjects for pieces of complex data structures like 
dictionaries, maps, etc
then having them be settable is also appropriate.

The other concern I have is that all these types of values that are used for 
"local variable display" like the Variable, FromAddress & FromData ones need to 
support IsChanged.  
That's why it struck me as wrong that a general sounding method like 
SetNeedsUpdating was throwing away the already made child values.  To do a good 
job of presenting "is changed" 
results you need to know both what children had been fetched (in a GUI this 
corresponds to what values the user has seen, so those are the ones you're 
supposed to check) 
and their old values.  So discarding the children except in cases where you 
know you are going to reset them completely is likely to get in the way of that.

I do agree the current implementation has gotten a little confused, but I think 
what we want to have happen is fairly clear, as evinced by the fact that we 
actually agreed on
the correct behaviors...

Jim


> 
> I don't have the full picture about the internal implementation and all the 
> use cases, but as a user I would expect it to work for at least #2, #3 and 
> #4. Afaik there's no API to fully distinguish between these kinds of values, 
> so I find it confusing why `SBValue::SetData()` would be allowed for some 
> values and not allowed for others. If I can create a value using 
> `CreateValueFromData` and then there's a method `SetValueFromCString`, then I 
> don't see why it should not be allowed (apart from implementation 
> complexity/consistency reasons).
> 
> What do you think? How should we proceed with this?
> 
> 
> Repository:
>  rG LLVM Github Monorepo
> 
> CHANGES SINCE LAST ACTION
>  https://reviews.llvm.org/D105470/new/
> 
> https://reviews.llvm.org/D105470
> 

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


[Lldb-commits] [lldb] 5e6aabd - Support AArch64/Linux watchpoint on tagged addresses

2021-07-11 Thread Muhammad Omair Javaid via lldb-commits

Author: Muhammad Omair Javaid
Date: 2021-07-12T07:39:26+05:00
New Revision: 5e6aabd48e351cf2632c25cb8bdfd0598a5019a6

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

LOG: Support AArch64/Linux watchpoint on tagged addresses

AArch64 architecture support virtual addresses with some of the top bits 
ignored.
These ignored bits can host memory tags or bit masks that can serve to check for
authentication of address integrity. We need to clear away the top ignored bits
from watchpoint address to reliably hit and set watchpoints on addresses
containing tags or masks in their top bits.

This patch adds support to watch tagged addresses on AArch64/Linux.

Reviewed By: DavidSpickett

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

Added: 
lldb/test/API/commands/watchpoints/watch_tagged_addr/Makefile

lldb/test/API/commands/watchpoints/watch_tagged_addr/TestWatchTaggedAddress.py
lldb/test/API/commands/watchpoints/watch_tagged_addr/main.c

Modified: 
lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.cpp
lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.h
lldb/source/Plugins/Process/Utility/NativeRegisterContextDBReg_arm64.cpp
lldb/source/Plugins/Process/Utility/NativeRegisterContextDBReg_arm64.h
lldb/source/Target/Target.cpp

Removed: 




diff  --git 
a/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.cpp 
b/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.cpp
index a0672a635937..34a520edb693 100644
--- a/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.cpp
+++ b/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.cpp
@@ -892,4 +892,19 @@ 
NativeRegisterContextLinux_arm64::GetMemoryTaggingDetails(int32_t type) {
  "Unknown AArch64 memory tag type %d", type);
 }
 
+lldb::addr_t NativeRegisterContextLinux_arm64::FixWatchpointHitAddress(
+lldb::addr_t hit_addr) {
+  // Linux configures user-space virtual addresses with top byte ignored.
+  // We set default value of mask such that top byte is masked out.
+  lldb::addr_t mask = ~((1ULL << 56) - 1);
+
+  // Try to read pointer authentication data_mask register and calculate a
+  // consolidated data address mask after ignoring the top byte.
+  if (ReadPAuthMask().Success())
+mask |= m_pac_mask.data_mask;
+
+  return hit_addr & ~mask;
+  ;
+}
+
 #endif // defined (__arm64__) || defined (__aarch64__)

diff  --git 
a/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.h 
b/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.h
index 6b56660fb80c..4dfc78b5b282 100644
--- a/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.h
+++ b/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.h
@@ -76,6 +76,8 @@ class NativeRegisterContextLinux_arm64
 
   size_t GetFPRSize() override { return sizeof(m_fpr); }
 
+  lldb::addr_t FixWatchpointHitAddress(lldb::addr_t hit_addr) override;
+
 private:
   bool m_gpr_is_valid;
   bool m_fpu_is_valid;

diff  --git 
a/lldb/source/Plugins/Process/Utility/NativeRegisterContextDBReg_arm64.cpp 
b/lldb/source/Plugins/Process/Utility/NativeRegisterContextDBReg_arm64.cpp
index 5c05baf71764..feee857cfe5f 100644
--- a/lldb/source/Plugins/Process/Utility/NativeRegisterContextDBReg_arm64.cpp
+++ b/lldb/source/Plugins/Process/Utility/NativeRegisterContextDBReg_arm64.cpp
@@ -421,6 +421,9 @@ Status 
NativeRegisterContextDBReg_arm64::GetWatchpointHitIndex(
   if (error)
 return Status(std::move(error));
 
+  // Mask off ignored bits from watchpoint trap address.
+  trap_addr = FixWatchpointHitAddress(trap_addr);
+
   uint32_t watch_size;
   lldb::addr_t watch_addr;
 

diff  --git 
a/lldb/source/Plugins/Process/Utility/NativeRegisterContextDBReg_arm64.h 
b/lldb/source/Plugins/Process/Utility/NativeRegisterContextDBReg_arm64.h
index 12ef5571f64c..3da0b0407ce6 100644
--- a/lldb/source/Plugins/Process/Utility/NativeRegisterContextDBReg_arm64.h
+++ b/lldb/source/Plugins/Process/Utility/NativeRegisterContextDBReg_arm64.h
@@ -72,6 +72,9 @@ class NativeRegisterContextDBReg_arm64
 
   virtual llvm::Error ReadHardwareDebugInfo() = 0;
   virtual llvm::Error WriteHardwareDebugRegs(DREGType hwbType) = 0;
+  virtual lldb::addr_t FixWatchpointHitAddress(lldb::addr_t hit_addr) {
+return hit_addr;
+  }
 };
 
 } // namespace lldb_private

diff  --git a/lldb/source/Target/Target.cpp b/lldb/source/Target/Target.cpp
index 839eb5887893..6cb7a9942a5c 100644
--- a/lldb/source/Target/Target.cpp
+++ b/lldb/source/Target/Target.cpp
@@ -41,6 +41,7 @@
 #include "lldb/Symbol/Function.h"
 #include "lldb/Symbol/ObjectFile.h"
 #include "lldb/Symbol/Symbol.h"
+#include "lldb/Target/ABI.h"
 #include "lldb/Target/Language.h"
 #

[Lldb-commits] [PATCH] D101361: [LLDB] Support AArch64/Linux watchpoint on tagged addresses

2021-07-11 Thread Muhammad Omair Javaid 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 rG5e6aabd48e35: Support AArch64/Linux watchpoint on tagged 
addresses (authored by omjavaid).
Herald added a project: LLDB.

Changed prior to commit:
  https://reviews.llvm.org/D101361?vs=357101&id=357831#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101361

Files:
  lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.cpp
  lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.h
  lldb/source/Plugins/Process/Utility/NativeRegisterContextDBReg_arm64.cpp
  lldb/source/Plugins/Process/Utility/NativeRegisterContextDBReg_arm64.h
  lldb/source/Target/Target.cpp
  lldb/test/API/commands/watchpoints/watch_tagged_addr/Makefile
  lldb/test/API/commands/watchpoints/watch_tagged_addr/TestWatchTaggedAddress.py
  lldb/test/API/commands/watchpoints/watch_tagged_addr/main.c

Index: lldb/test/API/commands/watchpoints/watch_tagged_addr/main.c
===
--- /dev/null
+++ lldb/test/API/commands/watchpoints/watch_tagged_addr/main.c
@@ -0,0 +1,29 @@
+#include 
+
+uint32_t global_var = 0; // Watchpoint variable declaration.
+
+int main(int argc, char **argv) {
+  int dummy = 0;
+  // Move address of global variable into tagged_ptr after tagging
+  // Simple tagging scheme where 62nd bit of tagged address is set
+  uint32_t *tagged_ptr = (uint32_t *)((uint64_t)&global_var | (1ULL << 62));
+
+  // pacdza computes and inserts a pointer authentication code for address
+  // stored in tagged_ptr using PAC key A.
+  __asm__ __volatile__("pacdza %0" : "=r"(tagged_ptr) : "r"(tagged_ptr));
+
+  ++dummy; // Set break point at this line.
+
+  // Increment global_var
+  ++global_var;
+
+  ++dummy;
+
+  // autdza authenticates tagged_ptr using PAC key A.
+  __asm__ __volatile__("autdza %0" : "=r"(tagged_ptr) : "r"(tagged_ptr));
+
+  // Increment global_var using tagged_ptr
+  ++*tagged_ptr;
+
+  return 0;
+}
Index: lldb/test/API/commands/watchpoints/watch_tagged_addr/TestWatchTaggedAddress.py
===
--- /dev/null
+++ lldb/test/API/commands/watchpoints/watch_tagged_addr/TestWatchTaggedAddress.py
@@ -0,0 +1,135 @@
+"""
+Test LLDB can set and hit watchpoints on tagged addresses
+"""
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+class TestWatchTaggedAddresses(TestBase):
+
+mydir = TestBase.compute_mydir(__file__)
+NO_DEBUG_INFO_TESTCASE = True
+
+def setUp(self):
+# Call super's setUp().
+TestBase.setUp(self)
+
+# Set source filename.
+self.source = 'main.c'
+
+# Invoke the default build rule.
+self.build()
+
+# Get the path of the executable
+exe = self.getBuildArtifact("a.out")
+
+# Create a target by the debugger.
+self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
+
+@skipIf(archs=no_match(["aarch64"]))
+@skipIf(oslist=no_match(['linux']))
+def test_watch_hit_tagged_ptr_access(self):
+"""
+Test that LLDB hits watchpoint installed on an untagged address with
+memory access by a tagged pointer.
+"""
+if not self.isAArch64PAuth():
+self.skipTest('Target must support pointer authentication.')
+
+# Add a breakpoint to set a watchpoint when stopped on the breakpoint.
+lldbutil.run_break_set_by_symbol(self, 'main')
+
+# Run the program.
+self.runCmd("run", RUN_SUCCEEDED)
+
+# We should be stopped due to the breakpoint.
+self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
+substrs=['stopped',
+ 'stop reason = breakpoint'])
+
+# Set the watchpoint variable declaration line number.
+self.decl = line_number(self.source,
+'// Watchpoint variable declaration.')
+
+# Now let's set a watchpoint on 'global_var'.
+self.expect(
+"watchpoint set variable global_var",
+WATCHPOINT_CREATED,
+substrs=[
+'Watchpoint created',
+'size = 4',
+'type = w',
+'%s:%d' %
+(self.source,
+ self.decl)])
+
+self.verify_watch_hits()
+
+@skipIf(archs=no_match(["aarch64"]))
+@skipIf(oslist=no_match(['linux']))
+def test_watch_set_on_tagged_ptr(self):
+"""Test that LLDB can install and hit watchpoint on a tagged address"""
+
+if not self.isAArch64PAuth():
+self.skipTest('Target must support pointer authentication.')
+
+# Find the line number to break inside main().
+self.line = line_number(self.source, '// Set br

[Lldb-commits] [lldb] 7c7447e - [LLDB] Only build TestWatchTaggedAddress.py on aarch64 PAC targets

2021-07-11 Thread Muhammad Omair Javaid via lldb-commits

Author: Muhammad Omair Javaid
Date: 2021-07-12T08:42:24+05:00
New Revision: 7c7447e3443557f9cc98389682c3f55dd7abb570

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

LOG: [LLDB] Only build TestWatchTaggedAddress.py on aarch64 PAC targets

This patch fixes buildbot failures caused by TestWatchTaggedAddress.py

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

Added: 


Modified: 

lldb/test/API/commands/watchpoints/watch_tagged_addr/TestWatchTaggedAddress.py

Removed: 




diff  --git 
a/lldb/test/API/commands/watchpoints/watch_tagged_addr/TestWatchTaggedAddress.py
 
b/lldb/test/API/commands/watchpoints/watch_tagged_addr/TestWatchTaggedAddress.py
index c7aab63c471f..34fe68aad150 100644
--- 
a/lldb/test/API/commands/watchpoints/watch_tagged_addr/TestWatchTaggedAddress.py
+++ 
b/lldb/test/API/commands/watchpoints/watch_tagged_addr/TestWatchTaggedAddress.py
@@ -16,6 +16,10 @@ def setUp(self):
 # Call super's setUp().
 TestBase.setUp(self)
 
+# Skip this test if not running on AArch64 target that supports PAC
+if not self.isAArch64PAuth():
+self.skipTest('Target must support pointer authentication.')
+
 # Set source filename.
 self.source = 'main.c'
 
@@ -35,8 +39,6 @@ def test_watch_hit_tagged_ptr_access(self):
 Test that LLDB hits watchpoint installed on an untagged address with
 memory access by a tagged pointer.
 """
-if not self.isAArch64PAuth():
-self.skipTest('Target must support pointer authentication.')
 
 # Add a breakpoint to set a watchpoint when stopped on the breakpoint.
 lldbutil.run_break_set_by_symbol(self, 'main')
@@ -72,9 +74,6 @@ def test_watch_hit_tagged_ptr_access(self):
 def test_watch_set_on_tagged_ptr(self):
 """Test that LLDB can install and hit watchpoint on a tagged address"""
 
-if not self.isAArch64PAuth():
-self.skipTest('Target must support pointer authentication.')
-
 # Find the line number to break inside main().
 self.line = line_number(self.source, '// Set break point at this 
line.')
 



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


[Lldb-commits] [PATCH] D105788: [LLDB] Silence warnings from ScriptedProcessPythonInterface.cpp

2021-07-11 Thread Muhammad Omair Javaid via Phabricator via lldb-commits
omjavaid created this revision.
omjavaid added a reviewer: mib.
Herald added a subscriber: kristof.beyls.
omjavaid requested review of this revision.

This patch fixes ScriptedProcessPythonInterface::GetGenericInteger to
avoid compiler warning emitted due to size_t being 32 bit when built
on 32 bit paltform.

  

Tested on 32 Bit Arm (armv8l).


https://reviews.llvm.org/D105788

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


Index: 
lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.cpp
===
--- 
lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.cpp
+++ 
lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.cpp
@@ -130,17 +130,17 @@
 ScriptedProcessPythonInterface::GetGenericInteger(llvm::StringRef method_name) 
{
   Locker py_lock(&m_interpreter, Locker::AcquireLock | Locker::NoSTDIN,
  Locker::FreeLock);
-
+  size_t gen_int_val = std::numeric_limits::max();
   if (!m_object_instance_sp)
-return LLDB_INVALID_ADDRESS;
+return gen_int_val;
 
   if (!m_object_instance_sp)
-return LLDB_INVALID_ADDRESS;
+return gen_int_val;
   PythonObject implementor(PyRefType::Borrowed,
(PyObject *)m_object_instance_sp->GetValue());
 
   if (!implementor.IsAllocated())
-return LLDB_INVALID_ADDRESS;
+return gen_int_val;
 
   PythonObject pmeth(
   PyRefType::Owned,
@@ -150,12 +150,12 @@
 PyErr_Clear();
 
   if (!pmeth.IsAllocated())
-return LLDB_INVALID_ADDRESS;
+return gen_int_val;
 
   if (PyCallable_Check(pmeth.get()) == 0) {
 if (PyErr_Occurred())
   PyErr_Clear();
-return LLDB_INVALID_ADDRESS;
+return gen_int_val;
   }
 
   if (PyErr_Occurred())
@@ -173,9 +173,9 @@
 
   if (py_return.get()) {
 auto size = py_return.AsUnsignedLongLong();
-return (size) ? *size : LLDB_INVALID_ADDRESS;
+return (size) ? *size : gen_int_val;
   }
-  return LLDB_INVALID_ADDRESS;
+  return gen_int_val;
 }
 
 lldb::MemoryRegionInfoSP
@@ -274,7 +274,7 @@
 lldb::pid_t ScriptedProcessPythonInterface::GetProcessID() {
   size_t pid = GetGenericInteger("get_process_id");
 
-  return (pid >= std::numeric_limits::max())
+  return (pid >= std::numeric_limits::max())
  ? LLDB_INVALID_PROCESS_ID
  : pid;
 }


Index: lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.cpp
===
--- lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.cpp
+++ lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.cpp
@@ -130,17 +130,17 @@
 ScriptedProcessPythonInterface::GetGenericInteger(llvm::StringRef method_name) {
   Locker py_lock(&m_interpreter, Locker::AcquireLock | Locker::NoSTDIN,
  Locker::FreeLock);
-
+  size_t gen_int_val = std::numeric_limits::max();
   if (!m_object_instance_sp)
-return LLDB_INVALID_ADDRESS;
+return gen_int_val;
 
   if (!m_object_instance_sp)
-return LLDB_INVALID_ADDRESS;
+return gen_int_val;
   PythonObject implementor(PyRefType::Borrowed,
(PyObject *)m_object_instance_sp->GetValue());
 
   if (!implementor.IsAllocated())
-return LLDB_INVALID_ADDRESS;
+return gen_int_val;
 
   PythonObject pmeth(
   PyRefType::Owned,
@@ -150,12 +150,12 @@
 PyErr_Clear();
 
   if (!pmeth.IsAllocated())
-return LLDB_INVALID_ADDRESS;
+return gen_int_val;
 
   if (PyCallable_Check(pmeth.get()) == 0) {
 if (PyErr_Occurred())
   PyErr_Clear();
-return LLDB_INVALID_ADDRESS;
+return gen_int_val;
   }
 
   if (PyErr_Occurred())
@@ -173,9 +173,9 @@
 
   if (py_return.get()) {
 auto size = py_return.AsUnsignedLongLong();
-return (size) ? *size : LLDB_INVALID_ADDRESS;
+return (size) ? *size : gen_int_val;
   }
-  return LLDB_INVALID_ADDRESS;
+  return gen_int_val;
 }
 
 lldb::MemoryRegionInfoSP
@@ -274,7 +274,7 @@
 lldb::pid_t ScriptedProcessPythonInterface::GetProcessID() {
   size_t pid = GetGenericInteger("get_process_id");
 
-  return (pid >= std::numeric_limits::max())
+  return (pid >= std::numeric_limits::max())
  ? LLDB_INVALID_PROCESS_ID
  : pid;
 }
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D105483: [LLDB] Testsuite: Add helper to check for AArch64 target

2021-07-11 Thread Muhammad Omair Javaid via Phabricator via lldb-commits
omjavaid added inline comments.



Comment at: lldb/packages/Python/lldbsuite/test/lldbtest.py:1296
+"""Returns true if the architecture is AArch64."""
+return self.getArchitecture().lower() in ["aarch64"]
+

DavidSpickett wrote:
> omjavaid wrote:
> > DavidSpickett wrote:
> > > This can be:
> > > ```
> > > return self.getArchitecture().lower() == "aarch64"
> > > ```
> > > 
> > > Unless you're expecting "aarch64_be" or "aarch64_32" as well.
> > > ```
> > > return "aarch64" in self.getArchitecture().lower()
> > > ```
> > > 
> > > Not sure if lldb just has the single name.
> > This was intentional as I wanted to keep this helper checking for platform 
> > architecture regardless of ABI or endianess. For an ILP32 inferior or be 
> > inferior our Native* are same as normal aarch64.
> I still think
> ```
> return self.getArchitecture().lower() == "aarch64"
> ```
> Is the same thing unless you intend to expand the list.
> 
> (but I understand what you're doing and either way works just a bit less neat 
> IMO)
Oh yes agreed, I dunno what I was thinking :) Let me fix this.


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

https://reviews.llvm.org/D105483

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


[Lldb-commits] [PATCH] D105483: [LLDB] Testsuite: Add helper to check for AArch64 target

2021-07-11 Thread Muhammad Omair Javaid via Phabricator via lldb-commits
omjavaid updated this revision to Diff 357837.
omjavaid added a comment.

This fixes issue raised in last rev.


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

https://reviews.llvm.org/D105483

Files:
  lldb/packages/Python/lldbsuite/test/lldbtest.py
  lldb/test/API/functionalities/memory/tag/TestMemoryTag.py
  lldb/test/API/functionalities/return-value/TestReturnValue.py
  
lldb/test/API/tools/lldb-server/registers-target-xml-reading/TestGdbRemoteTargetXmlPacket.py


Index: 
lldb/test/API/tools/lldb-server/registers-target-xml-reading/TestGdbRemoteTargetXmlPacket.py
===
--- 
lldb/test/API/tools/lldb-server/registers-target-xml-reading/TestGdbRemoteTargetXmlPacket.py
+++ 
lldb/test/API/tools/lldb-server/registers-target-xml-reading/TestGdbRemoteTargetXmlPacket.py
@@ -64,7 +64,7 @@
 self.assertEqual(q_info_reg["format"], xml_info_reg.get("format"))
 self.assertEqual(q_info_reg["bitsize"], 
xml_info_reg.get("bitsize"))
 
-if not self.getArchitecture() == 'aarch64':
+if not self.isAArch64():
 self.assertEqual(q_info_reg["offset"], 
xml_info_reg.get("offset"))
 
 self.assertEqual(q_info_reg["encoding"], 
xml_info_reg.get("encoding"))
Index: lldb/test/API/functionalities/return-value/TestReturnValue.py
===
--- lldb/test/API/functionalities/return-value/TestReturnValue.py
+++ lldb/test/API/functionalities/return-value/TestReturnValue.py
@@ -15,8 +15,8 @@
 mydir = TestBase.compute_mydir(__file__)
 
 def affected_by_pr33042(self):
-return ("clang" in self.getCompiler() and self.getArchitecture() ==
-"aarch64" and self.getPlatform() == "linux")
+return ("clang" in self.getCompiler() and self.isAArch64() and
+self.getPlatform() == "linux")
 
 def affected_by_pr44132(self):
 return (self.getArchitecture() in ["aarch64", "arm"] and
Index: lldb/test/API/functionalities/memory/tag/TestMemoryTag.py
===
--- lldb/test/API/functionalities/memory/tag/TestMemoryTag.py
+++ lldb/test/API/functionalities/memory/tag/TestMemoryTag.py
@@ -33,7 +33,7 @@
 # If you're on AArch64 you could have MTE but the remote process
 # must also support it. If you're on any other arhcitecture you
 # won't have any tagging at all. So the error message is different.
-if self.getArchitecture() == "aarch64":
+if self.isAArch64():
 expected = "error: Process does not support memory tagging"
 else:
 expected = "error: This architecture does not support memory 
tagging"
Index: lldb/packages/Python/lldbsuite/test/lldbtest.py
===
--- lldb/packages/Python/lldbsuite/test/lldbtest.py
+++ lldb/packages/Python/lldbsuite/test/lldbtest.py
@@ -1291,14 +1291,18 @@
 
 return cpuinfo
 
+def isAArch64(self):
+"""Returns true if the architecture is AArch64."""
+return self.getArchitecture().lower() == "aarch64"
+
 def isAArch64SVE(self):
-return "sve" in self.getCPUInfo()
+return self.isAArch64() and "sve" in self.getCPUInfo()
 
 def isAArch64MTE(self):
-return "mte" in self.getCPUInfo()
+return self.isAArch64() and "mte" in self.getCPUInfo()
 
 def isAArch64PAuth(self):
-return "paca" in self.getCPUInfo()
+return self.isAArch64() and "paca" in self.getCPUInfo()
 
 def getArchitecture(self):
 """Returns the architecture in effect the test suite is running 
with."""


Index: lldb/test/API/tools/lldb-server/registers-target-xml-reading/TestGdbRemoteTargetXmlPacket.py
===
--- lldb/test/API/tools/lldb-server/registers-target-xml-reading/TestGdbRemoteTargetXmlPacket.py
+++ lldb/test/API/tools/lldb-server/registers-target-xml-reading/TestGdbRemoteTargetXmlPacket.py
@@ -64,7 +64,7 @@
 self.assertEqual(q_info_reg["format"], xml_info_reg.get("format"))
 self.assertEqual(q_info_reg["bitsize"], xml_info_reg.get("bitsize"))
 
-if not self.getArchitecture() == 'aarch64':
+if not self.isAArch64():
 self.assertEqual(q_info_reg["offset"], xml_info_reg.get("offset"))
 
 self.assertEqual(q_info_reg["encoding"], xml_info_reg.get("encoding"))
Index: lldb/test/API/functionalities/return-value/TestReturnValue.py
===
--- lldb/test/API/functionalities/return-value/TestReturnValue.py
+++ lldb/test/API/functionalities/return-value/TestReturnValue.py
@@ -15,8 +15,8 @@
 mydir = TestBase.compute_mydir(__file__)
 
 def affected_by_pr33042(self):
-return ("clang" in self.getCompiler() and self.getArchitecture()