[Lldb-commits] [PATCH] D99847: [LLDB] Fix building for aarch64 windows after d6d3d21cd1cb1567eaf7ff8c0867b07227a19d99

2021-04-06 Thread David Spickett via Phabricator via lldb-commits
DavidSpickett accepted this revision.
DavidSpickett added a comment.
This revision is now accepted and ready to land.

LGTM

(we should have caught this on our WoA bots but they've been failing earlier in 
the builds)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99847

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


[Lldb-commits] [PATCH] D99847: [LLDB] Fix building for aarch64 windows after d6d3d21cd1cb1567eaf7ff8c0867b07227a19d99

2021-04-06 Thread Martin Storsjö via Phabricator via lldb-commits
mstorsjo added a comment.

In D99847#2670586 , @DavidSpickett 
wrote:

> LGTM
>
> (we should have caught this on our WoA bots but they've been failing earlier 
> in the builds)

Thanks, and it's good to hear that you've got a bot for testing this too (I 
test a fair bit of things nightly, but I only test building this bit roughly 
once per week).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99847

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


[Lldb-commits] [lldb] f8f4d8f - [lldb] Improve CPUInfo test predicate

2021-04-06 Thread David Spickett via lldb-commits

Author: David Spickett
Date: 2021-04-06T10:46:47+01:00
New Revision: f8f4d8f87ba4c1fbb18a4e7f4a5ea03a8b8ec061

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

LOG: [lldb] Improve CPUInfo test predicate

Use a with block for reading the cpuinfo file.

When loading the file fails (or we're not on Linux)
return an empty string. Since all the callers are
going to do "x in self.getCPUInfo()".

Reviewed By: omjavaid

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

Added: 


Modified: 
lldb/packages/Python/lldbsuite/test/lldbtest.py

Removed: 




diff  --git a/lldb/packages/Python/lldbsuite/test/lldbtest.py 
b/lldb/packages/Python/lldbsuite/test/lldbtest.py
index a9928af677a6..d94f8e9c28b9 100644
--- a/lldb/packages/Python/lldbsuite/test/lldbtest.py
+++ b/lldb/packages/Python/lldbsuite/test/lldbtest.py
@@ -1274,7 +1274,7 @@ def getCPUInfo(self):
 
 # TODO other platforms, please implement this function
 if not re.match(".*-.*-linux", triple):
-return False
+return ""
 
 # Need to do something 
diff erent for non-Linux/Android targets
 cpuinfo_path = self.getBuildArtifact("cpuinfo")
@@ -1284,11 +1284,10 @@ def getCPUInfo(self):
 cpuinfo_path = "/proc/cpuinfo"
 
 try:
-f = open(cpuinfo_path, 'r')
-cpuinfo = f.read()
-f.close()
+with open(cpuinfo_path, 'r') as f:
+cpuinfo = f.read()
 except:
-return False
+return ""
 
 return cpuinfo
 



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


[Lldb-commits] [PATCH] D99729: [lldb] Improve CPUInfo test predicate

2021-04-06 Thread David Spickett via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGf8f4d8f87ba4: [lldb] Improve CPUInfo test predicate 
(authored by DavidSpickett).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99729

Files:
  lldb/packages/Python/lldbsuite/test/lldbtest.py


Index: lldb/packages/Python/lldbsuite/test/lldbtest.py
===
--- lldb/packages/Python/lldbsuite/test/lldbtest.py
+++ lldb/packages/Python/lldbsuite/test/lldbtest.py
@@ -1274,7 +1274,7 @@
 
 # TODO other platforms, please implement this function
 if not re.match(".*-.*-linux", triple):
-return False
+return ""
 
 # Need to do something different for non-Linux/Android targets
 cpuinfo_path = self.getBuildArtifact("cpuinfo")
@@ -1284,11 +1284,10 @@
 cpuinfo_path = "/proc/cpuinfo"
 
 try:
-f = open(cpuinfo_path, 'r')
-cpuinfo = f.read()
-f.close()
+with open(cpuinfo_path, 'r') as f:
+cpuinfo = f.read()
 except:
-return False
+return ""
 
 return cpuinfo
 


Index: lldb/packages/Python/lldbsuite/test/lldbtest.py
===
--- lldb/packages/Python/lldbsuite/test/lldbtest.py
+++ lldb/packages/Python/lldbsuite/test/lldbtest.py
@@ -1274,7 +1274,7 @@
 
 # TODO other platforms, please implement this function
 if not re.match(".*-.*-linux", triple):
-return False
+return ""
 
 # Need to do something different for non-Linux/Android targets
 cpuinfo_path = self.getBuildArtifact("cpuinfo")
@@ -1284,11 +1284,10 @@
 cpuinfo_path = "/proc/cpuinfo"
 
 try:
-f = open(cpuinfo_path, 'r')
-cpuinfo = f.read()
-f.close()
+with open(cpuinfo_path, 'r') as f:
+cpuinfo = f.read()
 except:
-return False
+return ""
 
 return cpuinfo
 
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D99941: [LLDB] Support AArch64 PAC elf-core register read

2021-04-06 Thread Muhammad Omair Javaid via Phabricator via lldb-commits
omjavaid created this revision.
omjavaid added reviewers: labath, DavidSpickett.
Herald added subscribers: danielkiss, kristof.beyls.
omjavaid requested review of this revision.

This adds support for reading AArch64 Pointer Authentication regset
from elf-core file. Also includes a test-case for the same. Furthermore
there is also a slight adjustment of RegisterContextPOSIXCore_arm64
members and constructor.


https://reviews.llvm.org/D99941

Files:
  lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_arm64.cpp
  lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_arm64.h
  lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.h
  lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm64.cpp
  lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm64.h
  lldb/source/Plugins/Process/elf-core/RegisterUtilities.h
  lldb/test/API/functionalities/postmortem/elf-core/TestLinuxCore.py
  lldb/test/API/functionalities/postmortem/elf-core/linux-aarch64-pac.core

Index: lldb/test/API/functionalities/postmortem/elf-core/TestLinuxCore.py
===
--- lldb/test/API/functionalities/postmortem/elf-core/TestLinuxCore.py
+++ lldb/test/API/functionalities/postmortem/elf-core/TestLinuxCore.py
@@ -443,6 +443,23 @@
 
 self.expect("register read --all")
 
+@skipIfLLVMTargetMissing("AArch64")
+def test_aarch64_pac_regs(self):
+# Test AArch64/Linux Pointer Authenication register read
+target = self.dbg.CreateTarget(None)
+self.assertTrue(target, VALID_TARGET)
+process = target.LoadCore("linux-aarch64-pac.core")
+
+values = {}
+values["data_mask"] = "0x007f000"
+values["code_mask"] = "0x007f000"
+
+for regname, value in values.items():
+self.expect("register read {}".format(regname),
+substrs=["{} = {}".format(regname, value)])
+
+self.expect("register read --all")
+
 @skipIfLLVMTargetMissing("ARM")
 def test_arm_core(self):
 # check 32 bit ARM core file
Index: lldb/source/Plugins/Process/elf-core/RegisterUtilities.h
===
--- lldb/source/Plugins/Process/elf-core/RegisterUtilities.h
+++ lldb/source/Plugins/Process/elf-core/RegisterUtilities.h
@@ -111,6 +111,10 @@
 {llvm::Triple::Linux, llvm::Triple::aarch64, llvm::ELF::NT_ARM_SVE},
 };
 
+constexpr RegsetDesc AARCH64_PAC_Desc[] = {
+{llvm::Triple::Linux, llvm::Triple::aarch64, llvm::ELF::NT_ARM_PAC_MASK},
+};
+
 constexpr RegsetDesc PPC_VMX_Desc[] = {
 {llvm::Triple::FreeBSD, llvm::Triple::UnknownArch, llvm::ELF::NT_PPC_VMX},
 {llvm::Triple::Linux, llvm::Triple::UnknownArch, llvm::ELF::NT_PPC_VMX},
Index: lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm64.h
===
--- lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm64.h
+++ lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm64.h
@@ -42,7 +42,6 @@
   lldb_private::Thread &thread,
   std::unique_ptr register_info,
   const lldb_private::DataExtractor &gpregset,
-  const lldb_private::DataExtractor &sveregset,
   llvm::ArrayRef notes);
 
   bool ReadGPR() override;
@@ -54,10 +53,10 @@
   bool WriteFPR() override;
 
 private:
-  lldb::DataBufferSP m_gpr_buffer;
-  lldb_private::DataExtractor m_gpr;
-  lldb_private::DataExtractor m_fpregset;
-  lldb_private::DataExtractor m_sveregset;
+  lldb_private::DataExtractor m_gpr_data;
+  lldb_private::DataExtractor m_fpr_data;
+  lldb_private::DataExtractor m_sve_data;
+  lldb_private::DataExtractor m_pac_data;
 
   SVEState m_sve_state;
   uint16_t m_sve_vector_length = 0;
Index: lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm64.cpp
===
--- lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm64.cpp
+++ lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm64.cpp
@@ -21,32 +21,40 @@
 RegisterContextCorePOSIX_arm64::Create(Thread &thread, const ArchSpec &arch,
const DataExtractor &gpregset,
llvm::ArrayRef notes) {
-  DataExtractor sveregset =
-  getRegset(notes, arch.GetTriple(), AARCH64_SVE_Desc);
-
   Flags opt_regsets = RegisterInfoPOSIX_arm64::eRegsetMaskDefault;
-  if (sveregset.GetByteSize() > sizeof(sve::user_sve_header))
+
+  DataExtractor sve_data = getRegset(notes, arch.GetTriple(), AARCH64_SVE_Desc);
+  if (sve_data.GetByteSize() > sizeof(sve::user_sve_header))
 opt_regsets.Set(RegisterInfoPOSIX_arm64::eRegsetMaskSVE);
+
+  DataExtractor pac_data = getRegset(notes, arch.GetTriple(), AARCH64_PAC_Desc);
+  if (pac_data.GetByteSize() > sizeof(uint64_t))
+opt_regsets.Set(RegisterInfoPOSIX_arm64::eRegsetMaskPAuth);
+
   auto register_info_up =
 

[Lldb-commits] [lldb] 476e087 - [LLDB] Fix building for aarch64 windows after d6d3d21cd1cb1567eaf7ff8c0867b07227a19d99

2021-04-06 Thread Martin Storsjö via lldb-commits

Author: Martin Storsjö
Date: 2021-04-06T14:03:42+03:00
New Revision: 476e087939e4c7cda4de9fa3bc998aea62da4096

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

LOG: [LLDB] Fix building for aarch64 windows after 
d6d3d21cd1cb1567eaf7ff8c0867b07227a19d99

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

Added: 


Modified: 

lldb/source/Plugins/Process/Windows/Common/NativeRegisterContextWindows_arm64.cpp

Removed: 




diff  --git 
a/lldb/source/Plugins/Process/Windows/Common/NativeRegisterContextWindows_arm64.cpp
 
b/lldb/source/Plugins/Process/Windows/Common/NativeRegisterContextWindows_arm64.cpp
index 8205c8ec98dbf..1294928e09a5d 100644
--- 
a/lldb/source/Plugins/Process/Windows/Common/NativeRegisterContextWindows_arm64.cpp
+++ 
b/lldb/source/Plugins/Process/Windows/Common/NativeRegisterContextWindows_arm64.cpp
@@ -98,7 +98,8 @@ static RegisterInfoInterface *
 CreateRegisterInfoInterface(const ArchSpec &target_arch) {
   assert((HostInfo::GetArchitecture().GetAddressByteSize() == 8) &&
  "Register setting path assumes this is a 64-bit host");
-  return new RegisterInfoPOSIX_arm64(target_arch);
+  return new RegisterInfoPOSIX_arm64(
+  target_arch, RegisterInfoPOSIX_arm64::eRegsetMaskDefault);
 }
 
 static Status GetThreadContextHelper(lldb::thread_t thread_handle,



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


[Lldb-commits] [PATCH] D99847: [LLDB] Fix building for aarch64 windows after d6d3d21cd1cb1567eaf7ff8c0867b07227a19d99

2021-04-06 Thread Martin Storsjö via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG476e087939e4: [LLDB] Fix building for aarch64 windows after… 
(authored by mstorsjo).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99847

Files:
  
lldb/source/Plugins/Process/Windows/Common/NativeRegisterContextWindows_arm64.cpp


Index: 
lldb/source/Plugins/Process/Windows/Common/NativeRegisterContextWindows_arm64.cpp
===
--- 
lldb/source/Plugins/Process/Windows/Common/NativeRegisterContextWindows_arm64.cpp
+++ 
lldb/source/Plugins/Process/Windows/Common/NativeRegisterContextWindows_arm64.cpp
@@ -98,7 +98,8 @@
 CreateRegisterInfoInterface(const ArchSpec &target_arch) {
   assert((HostInfo::GetArchitecture().GetAddressByteSize() == 8) &&
  "Register setting path assumes this is a 64-bit host");
-  return new RegisterInfoPOSIX_arm64(target_arch);
+  return new RegisterInfoPOSIX_arm64(
+  target_arch, RegisterInfoPOSIX_arm64::eRegsetMaskDefault);
 }
 
 static Status GetThreadContextHelper(lldb::thread_t thread_handle,


Index: lldb/source/Plugins/Process/Windows/Common/NativeRegisterContextWindows_arm64.cpp
===
--- lldb/source/Plugins/Process/Windows/Common/NativeRegisterContextWindows_arm64.cpp
+++ lldb/source/Plugins/Process/Windows/Common/NativeRegisterContextWindows_arm64.cpp
@@ -98,7 +98,8 @@
 CreateRegisterInfoInterface(const ArchSpec &target_arch) {
   assert((HostInfo::GetArchitecture().GetAddressByteSize() == 8) &&
  "Register setting path assumes this is a 64-bit host");
-  return new RegisterInfoPOSIX_arm64(target_arch);
+  return new RegisterInfoPOSIX_arm64(
+  target_arch, RegisterInfoPOSIX_arm64::eRegsetMaskDefault);
 }
 
 static Status GetThreadContextHelper(lldb::thread_t thread_handle,
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D99941: [LLDB] Support AArch64 PAC elf-core register read

2021-04-06 Thread David Spickett via Phabricator via lldb-commits
DavidSpickett added inline comments.



Comment at: 
lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm64.cpp:32
+  if (pac_data.GetByteSize() > sizeof(uint64_t))
+opt_regsets.Set(RegisterInfoPOSIX_arm64::eRegsetMaskPAuth);
+

How is the `sizeof()` calculated here? Is it the size of the masks themselves, 
or a header block. (SVE above is clearly a header of some kind)



Comment at: 
lldb/test/API/functionalities/postmortem/elf-core/TestLinuxCore.py:451
+self.assertTrue(target, VALID_TARGET)
+process = target.LoadCore("linux-aarch64-pac.core")
+

Do you need anything special to generate the core file? Might be worth noting 
in the commit message.

Though I guess you can just compile a hello world on a Linux system with PAC.



Comment at: 
lldb/test/API/functionalities/postmortem/elf-core/TestLinuxCore.py:453
+
+values = {}
+values["data_mask"] = "0x007f000"

```
values = {
  "data_mask": "...",
  ...
}
```

(or `dict(data_mask="...")`)


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

https://reviews.llvm.org/D99941

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


[Lldb-commits] [lldb] 82b3e28 - [SystemZ][z/OS][Windows] Add new OF_TextWithCRLF flag and use this flag instead of OF_Text

2021-04-06 Thread Abhina Sreeskantharajan via lldb-commits

Author: Abhina Sreeskantharajan
Date: 2021-04-06T07:23:31-04:00
New Revision: 82b3e28e836d2f5c8cfd6e1047b93c088522365a

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

LOG: [SystemZ][z/OS][Windows] Add new OF_TextWithCRLF flag and use this flag 
instead of OF_Text

Problem:
On SystemZ we need to open text files in text mode. On Windows, files opened in 
text mode adds a CRLF '\r\n' which may not be desirable.

Solution:
This patch adds two new flags

  - OF_CRLF which indicates that CRLF translation is used.
  - OF_TextWithCRLF = OF_Text | OF_CRLF indicates that the file is text and 
uses CRLF translation.

Developers should now use either the OF_Text or OF_TextWithCRLF for text files 
and OF_None for binary files. If the developer doesn't want carriage returns on 
Windows, they should use OF_Text, if they do want carriage returns on Windows, 
they should use OF_TextWithCRLF.

So this is the behaviour per platform with my patch:

z/OS:
OF_None: open in binary mode
OF_Text : open in text mode
OF_TextWithCRLF: open in text mode

Windows:
OF_None: open file with no carriage return
OF_Text: open file with no carriage return
OF_TextWithCRLF: open file with carriage return

The Major change is in llvm/lib/Support/Windows/Path.inc to only set text mode 
if the OF_CRLF is set.
```
  if (Flags & OF_CRLF)
CrtOpenFlags |= _O_TEXT;
```

These following files are the ones that still use OF_Text which I left 
unchanged. I modified all these except raw_ostream.cpp in recent patches so I 
know these were previously in Binary mode on Windows.
./llvm/lib/Support/raw_ostream.cpp
./llvm/lib/TableGen/Main.cpp
./llvm/tools/dsymutil/DwarfLinkerForBinary.cpp
./llvm/unittests/Support/Path.cpp
./clang/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp
./clang/lib/Frontend/CompilerInstance.cpp
./clang/lib/Driver/Driver.cpp
./clang/lib/Driver/ToolChains/Clang.cpp

Reviewed By: MaskRay

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

Added: 


Modified: 
clang-tools-extra/clang-move/tool/ClangMove.cpp
clang-tools-extra/modularize/ModuleAssistant.cpp
clang-tools-extra/pp-trace/PPTrace.cpp
clang/lib/ARCMigrate/PlistReporter.cpp
clang/lib/Driver/Compilation.cpp
clang/lib/Driver/ToolChains/Clang.cpp
clang/lib/Frontend/CompilerInstance.cpp
clang/lib/Frontend/DependencyFile.cpp
clang/lib/Frontend/DependencyGraph.cpp
clang/lib/Frontend/FrontendActions.cpp
clang/lib/Frontend/HeaderIncludeGen.cpp
clang/lib/Frontend/ModuleDependencyCollector.cpp
clang/lib/Serialization/ASTReader.cpp
clang/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp
clang/lib/StaticAnalyzer/Core/SarifDiagnostics.cpp
clang/tools/clang-refactor/ClangRefactor.cpp
clang/tools/driver/cc1as_main.cpp
flang/lib/Frontend/CompilerInstance.cpp
lld/COFF/DriverUtils.cpp
lld/lib/ReaderWriter/YAML/ReaderWriterYAML.cpp
lldb/include/lldb/Utility/ReproducerProvider.h
lldb/source/Utility/GDBRemote.cpp
lldb/source/Utility/ReproducerProvider.cpp
lldb/tools/lldb-server/LLDBServerUtilities.cpp
llvm/include/llvm/Analysis/DOTGraphTraitsPass.h
llvm/include/llvm/Support/FileSystem.h
llvm/lib/CodeGen/RegAllocPBQP.cpp
llvm/lib/IR/Core.cpp
llvm/lib/IR/LLVMRemarkStreamer.cpp
llvm/lib/LTO/LTOBackend.cpp
llvm/lib/MC/MCParser/DarwinAsmParser.cpp
llvm/lib/ProfileData/GCOV.cpp
llvm/lib/ProfileData/SampleProfWriter.cpp
llvm/lib/Support/FileCollector.cpp
llvm/lib/Support/MemoryBuffer.cpp
llvm/lib/Support/TimeProfiler.cpp
llvm/lib/Support/Timer.cpp
llvm/lib/Support/Unix/Program.inc
llvm/lib/Support/Windows/Path.inc
llvm/lib/Support/Windows/Program.inc
llvm/lib/Transforms/IPO/Attributor.cpp
llvm/lib/Transforms/IPO/LowerTypeTests.cpp
llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp
llvm/lib/Transforms/Utils/Debugify.cpp
llvm/tools/dsymutil/dsymutil.cpp
llvm/tools/llc/llc.cpp
llvm/tools/lli/lli.cpp
llvm/tools/llvm-cxxmap/llvm-cxxmap.cpp
llvm/tools/llvm-dis/llvm-dis.cpp
llvm/tools/llvm-dwarfdump/llvm-dwarfdump.cpp
llvm/tools/llvm-exegesis/lib/BenchmarkResult.cpp
llvm/tools/llvm-link/llvm-link.cpp
llvm/tools/llvm-mc/llvm-mc.cpp
llvm/tools/llvm-mca/llvm-mca.cpp
llvm/tools/llvm-opt-report/OptReport.cpp
llvm/tools/llvm-profdata/llvm-profdata.cpp
llvm/tools/llvm-xray/xray-account.cpp
llvm/tools/llvm-xray/xray-converter.cpp
llvm/tools/llvm-xray/xray-extract.cpp
llvm/tools/llvm-xray/xray-graph-diff.cpp
llvm/tools/llvm-xray/xray-graph.cpp
llvm/tools/opt/opt.cpp
llvm/tools/verify-uselistorder/verify-uselistorder.cpp
llvm/unittests/Support/Path.cpp
polly/lib/Exchange/JSONExporter.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-move/tool/

[Lldb-commits] [PATCH] D99944: [LLDB] AArch64 PAC elf-core stack unwinder support

2021-04-06 Thread Muhammad Omair Javaid via Phabricator via lldb-commits
omjavaid created this revision.
omjavaid added reviewers: labath, justincohen, jasonmolenda, DavidSpickett.
Herald added subscribers: danielkiss, kristof.beyls.
omjavaid requested review of this revision.

This patch adds a new field to Process class which represents no of bits
used for addresses by the current process. A get/set function is also
added for the same.

This is useful for architectures where not all ptr bits are used for
addressing, rather some of the top bits are used to store extra
information. For example on AArch64 52 bits are maximum possible bits
available for addressing while remaining bits are used to store tags
or pointer authentication code.

This causes problem for unwinder in case return address register
contains extra information in top bits. This patch adds a function to
ABISysV_arm64 which clear those top bits and resulting sign extended
address is returned for use wherever required.

This patch also configures RegisterContextPOSIXCore_arm64 to calcualte
and set address bits currently being used by the process.

This includes elf-core test demonstrating unwinder can successfully
calculate elf-core backtrace in presence of PAC code in return address.

A follow up patch will include AArch64 Linux support for the same.


https://reviews.llvm.org/D99944

Files:
  lldb/include/lldb/Target/Process.h
  lldb/source/Plugins/ABI/AArch64/ABISysV_arm64.cpp
  lldb/source/Plugins/ABI/AArch64/ABISysV_arm64.h
  lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm64.cpp
  lldb/test/API/functionalities/postmortem/elf-core/TestLinuxCore.py
  lldb/test/API/functionalities/postmortem/elf-core/linux-aarch64-pac.out

Index: lldb/test/API/functionalities/postmortem/elf-core/TestLinuxCore.py
===
--- lldb/test/API/functionalities/postmortem/elf-core/TestLinuxCore.py
+++ lldb/test/API/functionalities/postmortem/elf-core/TestLinuxCore.py
@@ -20,6 +20,7 @@
 mydir = TestBase.compute_mydir(__file__)
 
 _aarch64_pid = 37688
+_aarch64_pac_pid = 387
 _i386_pid = 32306
 _x86_64_pid = 32259
 _s390x_pid = 1045
@@ -257,6 +258,18 @@
 
 self.dbg.DeleteTarget(target)
 
+@skipIfLLVMTargetMissing("AArch64")
+def test_aarch64_pac(self):
+"""Test that lldb can find the exe for an AArch64 Linux core file which has PAC enabled."""
+
+target = self.dbg.CreateTarget("linux-aarch64-pac.out")
+self.assertTrue(target, VALID_TARGET)
+process = target.LoadCore("linux-aarch64-pac.core")
+
+self.check_all(process, self._aarch64_pac_pid, self._aarch64_regions, "a.out")
+
+self.dbg.DeleteTarget(target)
+
 @skipIfLLVMTargetMissing("AArch64")
 @expectedFailureAll(archs=["aarch64"], oslist=["freebsd"],
 bugnumber="llvm.org/pr49415")
Index: lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm64.cpp
===
--- lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm64.cpp
+++ lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm64.cpp
@@ -10,6 +10,7 @@
 #include "Plugins/Process/Utility/RegisterInfoPOSIX_arm64.h"
 
 #include "Plugins/Process/elf-core/RegisterUtilities.h"
+#include "lldb/Target/Process.h"
 #include "lldb/Target/Thread.h"
 #include "lldb/Utility/RegisterValue.h"
 
@@ -53,9 +54,24 @@
   if (m_register_info_up->IsSVEEnabled())
 m_sve_data = getRegset(notes, target_triple, AARCH64_SVE_Desc);
 
-  if (m_register_info_up->IsPAuthEnabled())
+  if (m_register_info_up->IsPAuthEnabled()) {
 m_pac_data = getRegset(notes, target_triple, AARCH64_PAC_Desc);
 
+// At this stage we should be able to guess no of address bits
+// being used by target configuration when elf-core was generated.
+// This will either be 48 or 52 bits depending on AArch64 virtual
+// address size configuration. Following code checks if PAC starts
+// from 48th or 52nd bit onwards and accordingly sets address bits
+// in use by the this elf-core process.
+uint64_t pac_masks[2] = {0, 0};
+uint64_t pac_test_mask = 1ULL << 48;
+lldb::offset_t pac_data_offset = 0;
+if (m_pac_data.GetU64(&pac_data_offset, pac_masks, 2) &&
+((pac_masks[0] & pac_test_mask) || (pac_masks[1] & pac_test_mask)))
+  thread.GetProcess()->SetAddressBitsInUse(48);
+else
+  thread.GetProcess()->SetAddressBitsInUse(52);
+  }
   ConfigureRegisterContext();
 }
 
Index: lldb/source/Plugins/ABI/AArch64/ABISysV_arm64.h
===
--- lldb/source/Plugins/ABI/AArch64/ABISysV_arm64.h
+++ lldb/source/Plugins/ABI/AArch64/ABISysV_arm64.h
@@ -67,6 +67,8 @@
 
   bool GetPointerReturnRegister(const char *&name) override;
 
+  lldb::addr_t FixCodeAddress(lldb::addr_t pc) override;
+
   // Static Functions
 
   static void Initialize();
Index: lldb/source/Plugins/ABI/AArch64/ABISysV_arm64.cpp
===

[Lldb-commits] [PATCH] D99947: [LLDB] AArch64 Linux PAC unwinder support

2021-04-06 Thread Muhammad Omair Javaid via Phabricator via lldb-commits
omjavaid created this revision.
omjavaid added reviewers: labath, DavidSpickett.
Herald added subscribers: danielkiss, kristof.beyls.
omjavaid requested review of this revision.

This patch adds support to detect and set address bits in use by the current
AArch64 process. We are going to utilize AArch64SVEReconfigure function
for this purpose which was added to GDBRemoteRegisterContext for
supporting vector length update of SVE registers. This function gets called
on every stop to check for vector length changes and will serve as the
configuration area for address bits in use on first stop.

Default value of used address bits will be set to 52 which is maximum
possible AArch64 virtual address width. Addition logic has been added to
AArch64SVEReconfigure to detect pointer authentication feature for the
current process. If PAC is enabled, address bits in use are configured based on
PAC code/data mask.

This patch also includes a test case to demonstrate successful backtrace
calculation in presence of pointer authentication feature.


https://reviews.llvm.org/D99947

Files:
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp
  lldb/test/API/functionalities/unwind/aarch64_unwind_pac/Makefile
  
lldb/test/API/functionalities/unwind/aarch64_unwind_pac/TestAArch64UnwindPAC.py
  lldb/test/API/functionalities/unwind/aarch64_unwind_pac/main.c

Index: lldb/test/API/functionalities/unwind/aarch64_unwind_pac/main.c
===
--- /dev/null
+++ lldb/test/API/functionalities/unwind/aarch64_unwind_pac/main.c
@@ -0,0 +1,30 @@
+#include 
+
+static void func_a (void) __attribute__((noinline));
+static void func_b (void) __attribute__((noinline));
+static void func_c (void) __attribute__((noinline));
+
+static void
+func_c (void)
+{
+  exit (0); // Frame func_c
+}
+
+static void
+func_b (void)
+{
+  func_c (); // Frame func_b
+}
+
+static void
+func_a (void)
+{
+  func_b (); // Frame func_a
+}
+
+int
+main (int argc, char *argv[])
+{
+  func_a (); // Frame main
+  return 0;
+}
Index: lldb/test/API/functionalities/unwind/aarch64_unwind_pac/TestAArch64UnwindPAC.py
===
--- /dev/null
+++ lldb/test/API/functionalities/unwind/aarch64_unwind_pac/TestAArch64UnwindPAC.py
@@ -0,0 +1,42 @@
+"""
+Test that we can backtrace correctly when AArch64 PAC is enabled
+"""
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class AArch64UnwindPAC(TestBase):
+mydir = TestBase.compute_mydir(__file__)
+
+@skipIf(archs=no_match(["aarch64"]))
+@skipIf(oslist=no_match(['linux']))
+def test(self):
+"""Test that we can backtrace correctly when AArch64 PAC is enabled"""
+self.build()
+
+self.line = line_number('main.c', '// Frame func_c')
+
+exe = self.getBuildArtifact("a.out")
+self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
+
+lldbutil.run_break_set_by_file_and_line(
+self, "main.c", self.line, num_expected_locations=1)
+self.runCmd("run", RUN_SUCCEEDED)
+self.expect("thread backtrace", STOPPED_DUE_TO_BREAKPOINT,
+substrs=["stop reason = breakpoint 1."])
+
+target = self.dbg.GetSelectedTarget()
+process = target.GetProcess()
+thread = process.GetThreadAtIndex(0)
+
+backtrace = ["func_c", "func_b", "func_a", "main"]
+self.assertEqual(thread.GetNumFrames(), len(backtrace))
+for i in range(len(backtrace)):
+frame = thread.GetFrameAtIndex(i)
+self.assertTrue(frame)
+self.assertEqual(frame.GetFunctionName(), backtrace[i])
+self.assertEqual(frame.GetLineEntry().GetLine(),
+ line_number("main.c", "Frame " + backtrace[i]))
Index: lldb/test/API/functionalities/unwind/aarch64_unwind_pac/Makefile
===
--- /dev/null
+++ lldb/test/API/functionalities/unwind/aarch64_unwind_pac/Makefile
@@ -0,0 +1,5 @@
+C_SOURCES := main.c
+
+CFLAGS ?= -g -Os -march=armv8.5-a -mbranch-protection=pac-ret+leaf
+
+include Makefile.rules
Index: lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp
===
--- lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp
+++ lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp
@@ -739,6 +739,40 @@
   if (!m_reg_info_sp)
 return false;
 
+  // In addition to SVE vector length configuration we will use this function
+  // to configure no of address bits being used by the process for addressing.
+  // Default value will be set to 52 which is maximum possible AArch64 virtual
+  // address width.
+  // Code below tries to detect pointer authentication feature for the current
+  // process. If PAC is enabled, address bits in us

[Lldb-commits] [lldb] bdfee7d - [lldb][NFC] Fix misleading indentation in Cocoa.cpp

2021-04-06 Thread Raphael Isemann via lldb-commits

Author: Raphael Isemann
Date: 2021-04-06T14:30:47+02:00
New Revision: bdfee7d5e1924eb5ca7333b1da339cf21a481409

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

LOG: [lldb][NFC] Fix misleading indentation in Cocoa.cpp

Added: 


Modified: 
lldb/source/Plugins/Language/ObjC/Cocoa.cpp

Removed: 




diff  --git a/lldb/source/Plugins/Language/ObjC/Cocoa.cpp 
b/lldb/source/Plugins/Language/ObjC/Cocoa.cpp
index e2367adaa3b13..840b2bc4d8e98 100644
--- a/lldb/source/Plugins/Language/ObjC/Cocoa.cpp
+++ b/lldb/source/Plugins/Language/ObjC/Cocoa.cpp
@@ -522,9 +522,9 @@ bool lldb_private::formatters::NSNumberSummaryProvider(
 
 bool is_preserved_number = cfinfoa & 0x8;
 if (is_preserved_number) {
-if (log) 
-  log->Printf("Unsupported preserved NSNumber tagged pointer 0x%" 
-  PRIu64, valobj_addr);
+  if (log)
+log->Printf("Unsupported preserved NSNumber tagged pointer 0x%"
+PRIu64, valobj_addr);
   return false;
 }
 



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


[Lldb-commits] [PATCH] D99827: Clarifying the documentation for variable formatting wrt to qualifiers and adding a test that demonstrates this

2021-04-06 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor accepted this revision.
teemperor added a comment.
This revision is now accepted and ready to land.

LGTM, thanks! FWIW, there are actually a lot more 'qualifiers' supported in 
Clang that are ignored by the formatters (`restrict`, Obj-C garbage collector 
descriptions, custom address spaces, etc.). Most of them are not even modelled 
in DWARF and users rarely encounter them, so I think const/volatile should 
cover all reasonable workflows.




Comment at: 
lldb/test/API/functionalities/data-formatter/data-formatter-advanced/TestDataFormatterAdv.py:247
 
+self.expect("frame variable constInt", matching=True,
+substrs=['constInt = 0x002a'])

There are test methods for `frame var`:
`self.expect_var_path("constVolatileInt", value="0x002c")`


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

https://reviews.llvm.org/D99827

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


[Lldb-commits] [PATCH] D99890: [lldb] Fix bug where memory read --outfile is not truncating the file

2021-04-06 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor requested changes to this revision.
teemperor added a comment.
This revision now requires changes to proceed.

Thanks for the patch! I'll be extra nit-picky about the test to make up for the 
great meme steal of 2021.




Comment at: lldb/test/API/functionalities/memory/read/TestMemoryRead.py:146
+self.build_run_stop()
+cmd = "memory read -f d -c 1 `&argc`"
+res = lldb.SBCommandReturnObject()

Single use var (I guess you can't reuse that as a common prefix as the address 
expression has to be the last arg).



Comment at: lldb/test/API/functionalities/memory/read/TestMemoryRead.py:149
+self.ci.HandleCommand(cmd, res)
+self.assertTrue(res.Succeeded())
+

`self.assertTrue(res.Succeeded(), "memory read failed:" + res.GetError())`



Comment at: lldb/test/API/functionalities/memory/read/TestMemoryRead.py:154
+
+temp_file = tempfile.NamedTemporaryFile().name
+

I believe usually we use `self.getBuildArtifact("memory-read-output")` for 
that. If you open a named temp file here (and don't close it), then the second 
open can fail on Windows.



Comment at: lldb/test/API/functionalities/memory/read/TestMemoryRead.py:166
+format(i, expected_line, actual_line))
+self.assertEqual(len(expected), len(lines))
+

Can we ever hit this? We just get an exception in the for loop above (and the 
exception won't be very useful to diagnose the failure).

You can do this:
```
lang=python
lines = [s.strip() for s in lines]
expected = [s.strip() for s in expected]
self.assertEqual(lines, expected)
```

(assertEqual actually explains which elements are missing/additional/different 
for lists)



Comment at: lldb/test/API/functionalities/memory/read/TestMemoryRead.py:173
+# Make sure the file is truncated when we run the command again.
+self.runCmd("memory read -f d -c 1 -o '{}' `&argc`".format(temp_file))
+check_file_content([golden_output])

Could you write some garbage into the file between the two tests here?


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

https://reviews.llvm.org/D99890

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


[Lldb-commits] [PATCH] D99484: Use `GNUInstallDirs` to support custom installation dirs.

2021-04-06 Thread John Ericson via Phabricator via lldb-commits
Ericson2314 updated this revision to Diff 335157.
Ericson2314 added a comment.

Don't use CMAKE_INTALL_LIBDIR or convert compiler-rt for now

These steps were suggested by @compnerd, IIUC. The compiler-rt stuff is in flux
because I am now skeptical whether `COMPILER_RT_INSTALL_PATH` can now be so
easily removed (see D99755 ).

Additionally, I have cleaned up the `polly` code so that I need not change it
so much, and it should still work with absolute or relative paths quite
flexibly. If `COMPILER_RT_INSTALL_PATH` or equivalent functionality is in fact
needed (i.e D99755  must be abandoned), I 
think the same method I am now using
for polly could also work there.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99484

Files:
  clang-tools-extra/clang-doc/tool/CMakeLists.txt
  clang-tools-extra/clang-include-fixer/find-all-symbols/tool/CMakeLists.txt
  clang-tools-extra/clang-include-fixer/tool/CMakeLists.txt
  clang-tools-extra/clang-tidy/CMakeLists.txt
  clang-tools-extra/clang-tidy/tool/CMakeLists.txt
  clang-tools-extra/modularize/CMakeLists.txt
  clang/CMakeLists.txt
  clang/cmake/modules/AddClang.cmake
  clang/tools/c-index-test/CMakeLists.txt
  clang/tools/clang-format/CMakeLists.txt
  clang/tools/clang-rename/CMakeLists.txt
  clang/tools/libclang/CMakeLists.txt
  clang/tools/scan-build/CMakeLists.txt
  clang/tools/scan-view/CMakeLists.txt
  clang/utils/hmaptool/CMakeLists.txt
  flang/CMakeLists.txt
  flang/cmake/modules/AddFlang.cmake
  flang/tools/f18/CMakeLists.txt
  flang/tools/flang-driver/CMakeLists.txt
  libc/CMakeLists.txt
  libcxx/CMakeLists.txt
  libcxx/cmake/Modules/HandleLibCXXABI.cmake
  libcxx/include/CMakeLists.txt
  libcxx/src/CMakeLists.txt
  libcxxabi/CMakeLists.txt
  libunwind/CMakeLists.txt
  libunwind/src/CMakeLists.txt
  lld/CMakeLists.txt
  lld/cmake/modules/AddLLD.cmake
  lld/tools/lld/CMakeLists.txt
  lldb/CMakeLists.txt
  lldb/cmake/modules/AddLLDB.cmake
  lldb/cmake/modules/LLDBConfig.cmake
  llvm/CMakeLists.txt
  llvm/cmake/modules/AddLLVM.cmake
  llvm/cmake/modules/AddSphinxTarget.cmake
  llvm/cmake/modules/CMakeLists.txt
  llvm/cmake/modules/LLVMInstallSymlink.cmake
  llvm/docs/CMake.rst
  llvm/examples/Bye/CMakeLists.txt
  llvm/include/llvm/CMakeLists.txt
  llvm/tools/llvm-config/BuildVariables.inc.in
  llvm/tools/llvm-config/llvm-config.cpp
  llvm/tools/lto/CMakeLists.txt
  llvm/tools/opt-viewer/CMakeLists.txt
  llvm/tools/remarks-shlib/CMakeLists.txt
  mlir/CMakeLists.txt
  mlir/cmake/modules/AddMLIR.cmake
  openmp/CMakeLists.txt
  openmp/libomptarget/plugins/amdgpu/CMakeLists.txt
  openmp/libomptarget/plugins/ve/CMakeLists.txt
  openmp/runtime/src/CMakeLists.txt
  openmp/tools/multiplex/CMakeLists.txt
  polly/CMakeLists.txt
  polly/cmake/CMakeLists.txt
  polly/lib/External/CMakeLists.txt
  pstl/CMakeLists.txt

Index: pstl/CMakeLists.txt
===
--- pstl/CMakeLists.txt
+++ pstl/CMakeLists.txt
@@ -7,6 +7,8 @@
 #===--===##
 cmake_minimum_required(VERSION 3.13.4)
 
+include(GNUInstallDirs)
+
 set(PARALLELSTL_VERSION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/include/pstl/internal/pstl_config.h")
 file(STRINGS "${PARALLELSTL_VERSION_FILE}" PARALLELSTL_VERSION_SOURCE REGEX "#define _PSTL_VERSION .*$")
 string(REGEX REPLACE "#define _PSTL_VERSION (.*)$" "\\1" PARALLELSTL_VERSION_SOURCE "${PARALLELSTL_VERSION_SOURCE}")
@@ -81,15 +83,15 @@
 install(EXPORT ParallelSTLTargets
 FILE ParallelSTLTargets.cmake
 NAMESPACE pstl::
-DESTINATION lib/cmake/ParallelSTL)
+DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/ParallelSTL)
 install(FILES "${CMAKE_CURRENT_BINARY_DIR}/ParallelSTLConfig.cmake"
   "${CMAKE_CURRENT_BINARY_DIR}/ParallelSTLConfigVersion.cmake"
-DESTINATION lib/cmake/ParallelSTL)
+DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/ParallelSTL)
 install(DIRECTORY include/
-DESTINATION include
+DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
 PATTERN "*.in" EXCLUDE)
 install(FILES "${PSTL_CONFIG_SITE_PATH}"
-DESTINATION include)
+DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
 
 add_custom_target(install-pstl
   COMMAND "${CMAKE_COMMAND}" -P "${PROJECT_BINARY_DIR}/cmake_install.cmake" -DCOMPONENT=ParallelSTL)
Index: polly/lib/External/CMakeLists.txt
===
--- polly/lib/External/CMakeLists.txt
+++ polly/lib/External/CMakeLists.txt
@@ -275,7 +275,7 @@
 install(DIRECTORY
   ${ISL_SOURCE_DIR}/include/
   ${ISL_BINARY_DIR}/include/
-  DESTINATION include/polly
+  DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/polly
   FILES_MATCHING
   PATTERN "*.h"
   PATTERN "CMakeFiles" EXCLUDE
Index: polly/cmake/CMakeLists.txt
===

[Lldb-commits] [PATCH] D99426: [SystemZ][z/OS][Windows] Add new OF_TextWithCRLF flag and use this flag instead of OF_Text

2021-04-06 Thread Abhina Sree via Phabricator via lldb-commits
abhina.sreeskantharajan added a comment.

In D99426#2666341 , @aganea wrote:

> In D99426#2666141 , 
> @abhina.sreeskantharajan wrote:
>
>> In D99426#2665361 , @aganea wrote:
>>
>>> I am still concerned by the fact that this patch doesn't fix the issue 
>>> mentionned in https://reviews.llvm.org/D96363#2650460
>>> Was the intention to fix that issue? Will the fix be done in a subsequent 
>>> patch?
>>
>> I was fairly confident that if https://reviews.llvm.org/D96363 was the patch 
>> that was causing the issue for you
>
> That is the case! I've confirmed that `git checkout 
> fdb640ea30d416368b76b68b106deda580c6aced~1 && ninja clang -C build` generates 
> a `clang-cl.exe` that works with my above test case. `git revert 
> fdb640ea30d416368b76b68b106deda580c6aced` locally over ToT fixes the issue.

After scratching my head, I realized that I accidentally changed another 
function to Binary in clang/lib/Frontend/Rewrite/FrontendActions.cpp so that 
change was never properly reverted. I fixed this in 
https://reviews.llvm.org/D99837. Hopefully, this will fix your issue. Apologies 
for the confusion on my side.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99426

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


[Lldb-commits] [PATCH] D99426: [SystemZ][z/OS][Windows] Add new OF_TextWithCRLF flag and use this flag instead of OF_Text

2021-04-06 Thread Abhina Sree via Phabricator via lldb-commits
abhina.sreeskantharajan added a comment.

Is there any more feedback on this patch?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99426

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


[Lldb-commits] [PATCH] D99484: Use `GNUInstallDirs` to support custom installation dirs.

2021-04-06 Thread Michael Kruse via Phabricator via lldb-commits
Meinersbur added a comment.

In D99484#2668225 , @Ericson2314 wrote:

> Additionally, I have cleaned up the `polly` code so that I need not change it
> so much, and it should still work with absolute or relative paths quite
> flexibly.

Looks fine to me.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99484

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


[Lldb-commits] [PATCH] D99426: [SystemZ][z/OS][Windows] Add new OF_TextWithCRLF flag and use this flag instead of OF_Text

2021-04-06 Thread Yvan Roux via Phabricator via lldb-commits
yroux added a comment.

Hi,

Sorry I'm bit lost in the various patches proposed to fix the issue introduced 
by https://reviews.llvm.org/D97785 
My understanding is that this is missing one to fix our Windows on ARM bots 
(broken for more than 2 weeks now)
So it'd be great to have it applied


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99426

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


[Lldb-commits] [PATCH] D99426: [SystemZ][z/OS][Windows] Add new OF_TextWithCRLF flag and use this flag instead of OF_Text

2021-04-06 Thread Abhina Sree 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 rG82b3e28e836d: [SystemZ][z/OS][Windows] Add new 
OF_TextWithCRLF flag and use this flag instead… (authored by 
abhina.sreeskantharajan).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99426

Files:
  clang-tools-extra/clang-move/tool/ClangMove.cpp
  clang-tools-extra/modularize/ModuleAssistant.cpp
  clang-tools-extra/pp-trace/PPTrace.cpp
  clang/lib/ARCMigrate/PlistReporter.cpp
  clang/lib/Driver/Compilation.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInstance.cpp
  clang/lib/Frontend/DependencyFile.cpp
  clang/lib/Frontend/DependencyGraph.cpp
  clang/lib/Frontend/FrontendActions.cpp
  clang/lib/Frontend/HeaderIncludeGen.cpp
  clang/lib/Frontend/ModuleDependencyCollector.cpp
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp
  clang/lib/StaticAnalyzer/Core/SarifDiagnostics.cpp
  clang/tools/clang-refactor/ClangRefactor.cpp
  clang/tools/driver/cc1as_main.cpp
  flang/lib/Frontend/CompilerInstance.cpp
  lld/COFF/DriverUtils.cpp
  lld/lib/ReaderWriter/YAML/ReaderWriterYAML.cpp
  lldb/include/lldb/Utility/ReproducerProvider.h
  lldb/source/Utility/GDBRemote.cpp
  lldb/source/Utility/ReproducerProvider.cpp
  lldb/tools/lldb-server/LLDBServerUtilities.cpp
  llvm/include/llvm/Analysis/DOTGraphTraitsPass.h
  llvm/include/llvm/Support/FileSystem.h
  llvm/lib/CodeGen/RegAllocPBQP.cpp
  llvm/lib/IR/Core.cpp
  llvm/lib/IR/LLVMRemarkStreamer.cpp
  llvm/lib/LTO/LTOBackend.cpp
  llvm/lib/MC/MCParser/DarwinAsmParser.cpp
  llvm/lib/ProfileData/GCOV.cpp
  llvm/lib/ProfileData/SampleProfWriter.cpp
  llvm/lib/Support/FileCollector.cpp
  llvm/lib/Support/MemoryBuffer.cpp
  llvm/lib/Support/TimeProfiler.cpp
  llvm/lib/Support/Timer.cpp
  llvm/lib/Support/Unix/Program.inc
  llvm/lib/Support/Windows/Path.inc
  llvm/lib/Support/Windows/Program.inc
  llvm/lib/Transforms/IPO/Attributor.cpp
  llvm/lib/Transforms/IPO/LowerTypeTests.cpp
  llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp
  llvm/lib/Transforms/Utils/Debugify.cpp
  llvm/tools/dsymutil/dsymutil.cpp
  llvm/tools/llc/llc.cpp
  llvm/tools/lli/lli.cpp
  llvm/tools/llvm-cxxmap/llvm-cxxmap.cpp
  llvm/tools/llvm-dis/llvm-dis.cpp
  llvm/tools/llvm-dwarfdump/llvm-dwarfdump.cpp
  llvm/tools/llvm-exegesis/lib/BenchmarkResult.cpp
  llvm/tools/llvm-link/llvm-link.cpp
  llvm/tools/llvm-mc/llvm-mc.cpp
  llvm/tools/llvm-mca/llvm-mca.cpp
  llvm/tools/llvm-opt-report/OptReport.cpp
  llvm/tools/llvm-profdata/llvm-profdata.cpp
  llvm/tools/llvm-xray/xray-account.cpp
  llvm/tools/llvm-xray/xray-converter.cpp
  llvm/tools/llvm-xray/xray-extract.cpp
  llvm/tools/llvm-xray/xray-graph-diff.cpp
  llvm/tools/llvm-xray/xray-graph.cpp
  llvm/tools/opt/opt.cpp
  llvm/tools/verify-uselistorder/verify-uselistorder.cpp
  llvm/unittests/Support/Path.cpp
  polly/lib/Exchange/JSONExporter.cpp

Index: polly/lib/Exchange/JSONExporter.cpp
===
--- polly/lib/Exchange/JSONExporter.cpp
+++ polly/lib/Exchange/JSONExporter.cpp
@@ -178,7 +178,7 @@
 
   // Write to file.
   std::error_code EC;
-  ToolOutputFile F(FileName, EC, llvm::sys::fs::OF_Text);
+  ToolOutputFile F(FileName, EC, llvm::sys::fs::OF_TextWithCRLF);
 
   std::string FunctionName = S.getFunction().getName().str();
   errs() << "Writing JScop '" << S.getNameStr() << "' in function '"
Index: llvm/unittests/Support/Path.cpp
===
--- llvm/unittests/Support/Path.cpp
+++ llvm/unittests/Support/Path.cpp
@@ -1253,7 +1253,7 @@
   path::append(FilePathname, "test");
 
   {
-raw_fd_ostream File(FilePathname, EC, sys::fs::OF_Text);
+raw_fd_ostream File(FilePathname, EC, sys::fs::OF_TextWithCRLF);
 ASSERT_NO_ERROR(EC);
 File << '\n';
   }
Index: llvm/tools/verify-uselistorder/verify-uselistorder.cpp
===
--- llvm/tools/verify-uselistorder/verify-uselistorder.cpp
+++ llvm/tools/verify-uselistorder/verify-uselistorder.cpp
@@ -136,7 +136,7 @@
 bool TempFile::writeAssembly(const Module &M) const {
   LLVM_DEBUG(dbgs() << " - write assembly\n");
   std::error_code EC;
-  raw_fd_ostream OS(Filename, EC, sys::fs::OF_Text);
+  raw_fd_ostream OS(Filename, EC, sys::fs::OF_TextWithCRLF);
   if (EC) {
 errs() << "verify-uselistorder: error: " << EC.message() << "\n";
 return true;
Index: llvm/tools/opt/opt.cpp
===
--- llvm/tools/opt/opt.cpp
+++ llvm/tools/opt/opt.cpp
@@ -700,8 +700,8 @@
   OutputFilename = "-";
 
 std::error_code EC;
-sys::fs::OpenFlags Flags = OutputAssembly ? sys::fs::OF_Text
-  : sys::fs::OF_None;
+sys::fs::OpenFlags Flags =
+   

[Lldb-commits] [PATCH] D99426: [SystemZ][z/OS][Windows] Add new OF_TextWithCRLF flag and use this flag instead of OF_Text

2021-04-06 Thread Yvan Roux via Phabricator via lldb-commits
yroux added a comment.



> I've committed this and it looks like the bot is back to green :) 
> https://lab.llvm.org/buildbot/#/builders/65/builds/1400. Sorry for the 
> delayed fix

Great, thanks a lot


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99426

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


[Lldb-commits] [PATCH] D99426: [SystemZ][z/OS][Windows] Add new OF_TextWithCRLF flag and use this flag instead of OF_Text

2021-04-06 Thread Abhina Sree via Phabricator via lldb-commits
abhina.sreeskantharajan added a comment.

In D99426#2670552 , @yroux wrote:

> Hi,
>
> Sorry I'm bit lost in the various patches proposed to fix the issue 
> introduced by https://reviews.llvm.org/D97785 
> My understanding is that this is missing one to fix our Windows on ARM bots 
> (broken for more than 2 weeks now)
> So it'd be great to have it applied

I've committed this and it looks like the bot is back to green :) 
https://lab.llvm.org/buildbot/#/builders/65/builds/1400. Sorry for the delayed 
fix


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99426

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


[Lldb-commits] [PATCH] D99890: [lldb] Fix bug where memory read --outfile is not truncating the file

2021-04-06 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere marked 5 inline comments as done.
JDevlieghere added a comment.

In D99890#2671042 , @teemperor wrote:

> Thanks for the patch! I'll be extra nit-picky about the test to make up for 
> the great meme steal of 2021.

Credit was given, so I do not consider it theft.


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

https://reviews.llvm.org/D99890

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


[Lldb-commits] [PATCH] D99890: [lldb] Fix bug where memory read --outfile is not truncating the file

2021-04-06 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere updated this revision to Diff 335525.

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

https://reviews.llvm.org/D99890

Files:
  lldb/source/Commands/CommandObjectMemory.cpp
  lldb/test/API/functionalities/memory/read/TestMemoryRead.py

Index: lldb/test/API/functionalities/memory/read/TestMemoryRead.py
===
--- lldb/test/API/functionalities/memory/read/TestMemoryRead.py
+++ lldb/test/API/functionalities/memory/read/TestMemoryRead.py
@@ -2,11 +2,12 @@
 Test the 'memory read' command.
 """
 
-
-
 import lldb
-from lldbsuite.test.lldbtest import *
 import lldbsuite.test.lldbutil as lldbutil
+import tempfile
+
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
 
 
 class MemoryReadTestCase(TestBase):
@@ -19,27 +20,34 @@
 # Find the line number to break inside main().
 self.line = line_number('main.cpp', '// Set break point at this line.')
 
-def test_memory_read(self):
-"""Test the 'memory read' command with plain and vector formats."""
+def build_run_stop(self):
 self.build()
 exe = self.getBuildArtifact("a.out")
 self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
 
 # Break in main() after the variables are assigned values.
-lldbutil.run_break_set_by_file_and_line(
-self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True)
+lldbutil.run_break_set_by_file_and_line(self,
+"main.cpp",
+self.line,
+num_expected_locations=1,
+loc_exact=True)
 
 self.runCmd("run", RUN_SUCCEEDED)
 
 # The stop reason of the thread should be breakpoint.
-self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
+self.expect("thread list",
+STOPPED_DUE_TO_BREAKPOINT,
 substrs=['stopped', 'stop reason = breakpoint'])
 
 # The breakpoint should have a hit count of 1.
-self.expect("breakpoint list -f", BREAKPOINT_HIT_ONCE,
+self.expect("breakpoint list -f",
+BREAKPOINT_HIT_ONCE,
 substrs=[' resolved, hit count = 1'])
 
-# Test the memory read commands.
+@no_debug_info_test
+def test_memory_read(self):
+"""Test the 'memory read' command with plain and vector formats."""
+self.build_run_stop()
 
 # (lldb) memory read -f d -c 1 `&argc`
 # 0x7fff5fbff9a0: 1
@@ -131,3 +139,40 @@
   for o in objects_read:
   self.assertEqual(len(o), expected_object_length)
   self.assertEquals(len(objects_read), 4)
+
+@no_debug_info_test
+def test_memory_read_file(self):
+self.build_run_stop()
+res = lldb.SBCommandReturnObject()
+self.ci.HandleCommand("memory read -f d -c 1 `&argc`", res)
+self.assertTrue(res.Succeeded(), "memory read failed:" + res.GetError())
+
+# Record golden output.
+golden_output = res.GetOutput()
+
+memory_read_file = self.getBuildArtifact("memory-read-output")
+
+def check_file_content(expected):
+with open(memory_read_file) as f:
+lines = f.readlines()
+lines = [s.strip() for s in lines]
+expected = [s.strip() for s in expected]
+self.assertEqual(lines, expected)
+
+# Sanity check.
+self.runCmd("memory read -f d -c 1 -o '{}' `&argc`".format(memory_read_file))
+check_file_content([golden_output])
+
+# Write some garbage to the file.
+with open(memory_read_file, 'w') as f:
+f.write("some garbage")
+
+# Make sure the file is truncated when we run the command again.
+self.runCmd("memory read -f d -c 1 -o '{}' `&argc`".format(memory_read_file))
+check_file_content([golden_output])
+
+# Make sure the file is appended when we run the command with --append-outfile.
+self.runCmd(
+"memory read -f d -c 1 -o '{}' --append-outfile `&argc`".format(
+memory_read_file))
+check_file_content([golden_output, golden_output])
Index: lldb/source/Commands/CommandObjectMemory.cpp
===
--- lldb/source/Commands/CommandObjectMemory.cpp
+++ lldb/source/Commands/CommandObjectMemory.cpp
@@ -767,10 +767,11 @@
 std::string path = outfile_spec.GetPath();
 if (outfile_spec) {
 
-  auto open_options = File::eOpenOptionWrite | File::eOpenOptionCanCreate;
+  File::OpenOptions open_options =
+  File::eOpenOptionWrite | File::eOpenOptionCanCreate;
   const bool append = m_outfile_options.GetAppend().GetCurrentValue();
-  if (append)
-open_options |= File::eOpenOptionAppend;
+  op

[Lldb-commits] [PATCH] D99890: [lldb] Fix bug where memory read --outfile is not truncating the file

2021-04-06 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor accepted this revision.
teemperor added a comment.
This revision is now accepted and ready to land.

LGTM now beside the now redundant import




Comment at: lldb/test/API/functionalities/memory/read/TestMemoryRead.py:7
 import lldbsuite.test.lldbutil as lldbutil
+import tempfile
+

No longer needed



Comment at: lldb/test/API/functionalities/memory/read/TestMemoryRead.py:168
+with open(memory_read_file, 'w') as f:
+f.write("some garbage")
+

I see you have taken my suggestion literally


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

https://reviews.llvm.org/D99890

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


[Lldb-commits] [lldb] 710651c - [lldb] Fix bug where memory read --outfile is not truncating the file

2021-04-06 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2021-04-06T09:16:28-07:00
New Revision: 710651c61dcdb2f969811b9a8c7efb425b5e2918

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

LOG: [lldb] Fix bug where memory read --outfile is not truncating the file

The memory read --outfile command should truncate the output when unless
--append-outfile. Fix the bug and add a test.

rdar://76062318

Differential revision: https://reviews.llvm.org/D99890

Added: 


Modified: 
lldb/source/Commands/CommandObjectMemory.cpp
lldb/test/API/functionalities/memory/read/TestMemoryRead.py

Removed: 




diff  --git a/lldb/source/Commands/CommandObjectMemory.cpp 
b/lldb/source/Commands/CommandObjectMemory.cpp
index ca8487906fd0..a2201c4d8bd9 100644
--- a/lldb/source/Commands/CommandObjectMemory.cpp
+++ b/lldb/source/Commands/CommandObjectMemory.cpp
@@ -767,10 +767,11 @@ class CommandObjectMemoryRead : public 
CommandObjectParsed {
 std::string path = outfile_spec.GetPath();
 if (outfile_spec) {
 
-  auto open_options = File::eOpenOptionWrite | File::eOpenOptionCanCreate;
+  File::OpenOptions open_options =
+  File::eOpenOptionWrite | File::eOpenOptionCanCreate;
   const bool append = m_outfile_options.GetAppend().GetCurrentValue();
-  if (append)
-open_options |= File::eOpenOptionAppend;
+  open_options |=
+  append ? File::eOpenOptionAppend : File::eOpenOptionTruncate;
 
   auto outfile = FileSystem::Instance().Open(outfile_spec, open_options);
 

diff  --git a/lldb/test/API/functionalities/memory/read/TestMemoryRead.py 
b/lldb/test/API/functionalities/memory/read/TestMemoryRead.py
index 19d09a5f2cad..ceea4ab2f067 100644
--- a/lldb/test/API/functionalities/memory/read/TestMemoryRead.py
+++ b/lldb/test/API/functionalities/memory/read/TestMemoryRead.py
@@ -2,12 +2,12 @@
 Test the 'memory read' command.
 """
 
-
-
 import lldb
-from lldbsuite.test.lldbtest import *
 import lldbsuite.test.lldbutil as lldbutil
 
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+
 
 class MemoryReadTestCase(TestBase):
 
@@ -19,27 +19,34 @@ def setUp(self):
 # Find the line number to break inside main().
 self.line = line_number('main.cpp', '// Set break point at this line.')
 
-def test_memory_read(self):
-"""Test the 'memory read' command with plain and vector formats."""
+def build_run_stop(self):
 self.build()
 exe = self.getBuildArtifact("a.out")
 self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
 
 # Break in main() after the variables are assigned values.
-lldbutil.run_break_set_by_file_and_line(
-self, "main.cpp", self.line, num_expected_locations=1, 
loc_exact=True)
+lldbutil.run_break_set_by_file_and_line(self,
+"main.cpp",
+self.line,
+num_expected_locations=1,
+loc_exact=True)
 
 self.runCmd("run", RUN_SUCCEEDED)
 
 # The stop reason of the thread should be breakpoint.
-self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
+self.expect("thread list",
+STOPPED_DUE_TO_BREAKPOINT,
 substrs=['stopped', 'stop reason = breakpoint'])
 
 # The breakpoint should have a hit count of 1.
-self.expect("breakpoint list -f", BREAKPOINT_HIT_ONCE,
+self.expect("breakpoint list -f",
+BREAKPOINT_HIT_ONCE,
 substrs=[' resolved, hit count = 1'])
 
-# Test the memory read commands.
+@no_debug_info_test
+def test_memory_read(self):
+"""Test the 'memory read' command with plain and vector formats."""
+self.build_run_stop()
 
 # (lldb) memory read -f d -c 1 `&argc`
 # 0x7fff5fbff9a0: 1
@@ -131,3 +138,40 @@ def test_memory_read(self):
   for o in objects_read:
   self.assertEqual(len(o), expected_object_length)
   self.assertEquals(len(objects_read), 4)
+
+@no_debug_info_test
+def test_memory_read_file(self):
+self.build_run_stop()
+res = lldb.SBCommandReturnObject()
+self.ci.HandleCommand("memory read -f d -c 1 `&argc`", res)
+self.assertTrue(res.Succeeded(), "memory read failed:" + 
res.GetError())
+
+# Record golden output.
+golden_output = res.GetOutput()
+
+memory_read_file = self.getBuildArtifact("memory-read-output")
+
+def check_file_content(expected):
+with open(memory_read_file) as f:
+lines = f.readlines()
+lines = [s.strip() for s in lines]
+

[Lldb-commits] [PATCH] D99890: [lldb] Fix bug where memory read --outfile is not truncating the file

2021-04-06 Thread Jonas Devlieghere 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 rG710651c61dcd: [lldb] Fix bug where memory read --outfile is 
not truncating the file (authored by JDevlieghere).
Herald added a project: LLDB.

Changed prior to commit:
  https://reviews.llvm.org/D99890?vs=335525&id=335548#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99890

Files:
  lldb/source/Commands/CommandObjectMemory.cpp
  lldb/test/API/functionalities/memory/read/TestMemoryRead.py

Index: lldb/test/API/functionalities/memory/read/TestMemoryRead.py
===
--- lldb/test/API/functionalities/memory/read/TestMemoryRead.py
+++ lldb/test/API/functionalities/memory/read/TestMemoryRead.py
@@ -2,12 +2,12 @@
 Test the 'memory read' command.
 """
 
-
-
 import lldb
-from lldbsuite.test.lldbtest import *
 import lldbsuite.test.lldbutil as lldbutil
 
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+
 
 class MemoryReadTestCase(TestBase):
 
@@ -19,27 +19,34 @@
 # Find the line number to break inside main().
 self.line = line_number('main.cpp', '// Set break point at this line.')
 
-def test_memory_read(self):
-"""Test the 'memory read' command with plain and vector formats."""
+def build_run_stop(self):
 self.build()
 exe = self.getBuildArtifact("a.out")
 self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
 
 # Break in main() after the variables are assigned values.
-lldbutil.run_break_set_by_file_and_line(
-self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True)
+lldbutil.run_break_set_by_file_and_line(self,
+"main.cpp",
+self.line,
+num_expected_locations=1,
+loc_exact=True)
 
 self.runCmd("run", RUN_SUCCEEDED)
 
 # The stop reason of the thread should be breakpoint.
-self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
+self.expect("thread list",
+STOPPED_DUE_TO_BREAKPOINT,
 substrs=['stopped', 'stop reason = breakpoint'])
 
 # The breakpoint should have a hit count of 1.
-self.expect("breakpoint list -f", BREAKPOINT_HIT_ONCE,
+self.expect("breakpoint list -f",
+BREAKPOINT_HIT_ONCE,
 substrs=[' resolved, hit count = 1'])
 
-# Test the memory read commands.
+@no_debug_info_test
+def test_memory_read(self):
+"""Test the 'memory read' command with plain and vector formats."""
+self.build_run_stop()
 
 # (lldb) memory read -f d -c 1 `&argc`
 # 0x7fff5fbff9a0: 1
@@ -131,3 +138,40 @@
   for o in objects_read:
   self.assertEqual(len(o), expected_object_length)
   self.assertEquals(len(objects_read), 4)
+
+@no_debug_info_test
+def test_memory_read_file(self):
+self.build_run_stop()
+res = lldb.SBCommandReturnObject()
+self.ci.HandleCommand("memory read -f d -c 1 `&argc`", res)
+self.assertTrue(res.Succeeded(), "memory read failed:" + res.GetError())
+
+# Record golden output.
+golden_output = res.GetOutput()
+
+memory_read_file = self.getBuildArtifact("memory-read-output")
+
+def check_file_content(expected):
+with open(memory_read_file) as f:
+lines = f.readlines()
+lines = [s.strip() for s in lines]
+expected = [s.strip() for s in expected]
+self.assertEqual(lines, expected)
+
+# Sanity check.
+self.runCmd("memory read -f d -c 1 -o '{}' `&argc`".format(memory_read_file))
+check_file_content([golden_output])
+
+# Write some garbage to the file.
+with open(memory_read_file, 'w') as f:
+f.write("some garbage")
+
+# Make sure the file is truncated when we run the command again.
+self.runCmd("memory read -f d -c 1 -o '{}' `&argc`".format(memory_read_file))
+check_file_content([golden_output])
+
+# Make sure the file is appended when we run the command with --append-outfile.
+self.runCmd(
+"memory read -f d -c 1 -o '{}' --append-outfile `&argc`".format(
+memory_read_file))
+check_file_content([golden_output, golden_output])
Index: lldb/source/Commands/CommandObjectMemory.cpp
===
--- lldb/source/Commands/CommandObjectMemory.cpp
+++ lldb/source/Commands/CommandObjectMemory.cpp
@@ -767,10 +767,11 @@
 std::string path = outfile_spec.GetPath();
 if (outfile

[Lldb-commits] [PATCH] D99694: Add support for getting signed ObjC tagged pointer values

2021-04-06 Thread Stella Stamenova via Phabricator via lldb-commits
stella.stamenova added a comment.

The latest change (commit be0ced03 
) issues 
the following warning:

  /usr/bin/clang++ -DGTEST_HAS_RTTI=0 -DHAVE_ROUND -D_DEBUG -D_GNU_SOURCE 
-D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS 
-Itools/lldb/source/Plugins/Language/ObjC 
-I/mnt/vss/_work/2/s/lldb/source/Plugins/Language/ObjC -Itools/lldb/source 
-I/mnt/vss/_work/2/s/lldb/include -Itools/lldb/include -Iinclude 
-I/mnt/vss/_work/2/s/llvm/include -I/usr/include/python3.8 
-I/mnt/vss/_work/2/s/llvm/../clang/include -Itools/lldb/../clang/include 
-I/usr/include/libxml2 -I/mnt/vss/_work/2/s/lldb/source/. -fPIC 
-fvisibility-inlines-hidden -Werror -Werror=date-time 
-Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter 
-Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic 
-Wno-long-long -Wc++98-compat-extra-semi -Wimplicit-fallthrough 
-Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor 
-Wdelete-non-virtual-dtor -Wstring-conversion -fdiagnostics-color 
-ffunction-sections -fdata-sections -Wno-deprecated-declarations 
-Wno-unknown-pragmas -Wno-strict-aliasing -Wno-deprecated-register 
-Wno-vla-extension -O3   -fno-exceptions -fno-rtti -UNDEBUG -std=c++14 -MD -MT 
tools/lldb/source/Plugins/Language/ObjC/CMakeFiles/lldbPluginObjCLanguage.dir/Cocoa.cpp.o
 -MF 
tools/lldb/source/Plugins/Language/ObjC/CMakeFiles/lldbPluginObjCLanguage.dir/Cocoa.cpp.o.d
 -o 
tools/lldb/source/Plugins/Language/ObjC/CMakeFiles/lldbPluginObjCLanguage.dir/Cocoa.cpp.o
 -c /mnt/vss/_work/2/s/lldb/source/Plugins/Language/ObjC/Cocoa.cpp
  /mnt/vss/_work/2/s/lldb/source/Plugins/Language/ObjC/Cocoa.cpp:528:11: error: 
misleading indentation; statement is not part of the previous 'if' 
[-Werror,-Wmisleading-indentation]
return false;
^
  /mnt/vss/_work/2/s/lldb/source/Plugins/Language/ObjC/Cocoa.cpp:525:9: note: 
previous statement is here
  if (log) 

For this badly indented code:

  if (is_preserved_number) {
  if (log) 
log->Printf("Unsupported preserved NSNumber tagged pointer 0x%" 
PRIu64, valobj_addr);
return false;
  }


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99694

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


[Lldb-commits] [PATCH] D99694: Add support for getting signed ObjC tagged pointer values

2021-04-06 Thread Stella Stamenova via Phabricator via lldb-commits
stella.stamenova added a subscriber: teemperor.
stella.stamenova added a comment.

It looks like @teemperor fixed it already!

In D99694#2671640 , @stella.stamenova 
wrote:

> The latest change (commit be0ced03 
> ) issues 
> the following warning:
>
>   /usr/bin/clang++ -DGTEST_HAS_RTTI=0 -DHAVE_ROUND -D_DEBUG -D_GNU_SOURCE 
> -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS 
> -Itools/lldb/source/Plugins/Language/ObjC 
> -I/mnt/vss/_work/2/s/lldb/source/Plugins/Language/ObjC -Itools/lldb/source 
> -I/mnt/vss/_work/2/s/lldb/include -Itools/lldb/include -Iinclude 
> -I/mnt/vss/_work/2/s/llvm/include -I/usr/include/python3.8 
> -I/mnt/vss/_work/2/s/llvm/../clang/include -Itools/lldb/../clang/include 
> -I/usr/include/libxml2 -I/mnt/vss/_work/2/s/lldb/source/. -fPIC 
> -fvisibility-inlines-hidden -Werror -Werror=date-time 
> -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter 
> -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic 
> -Wno-long-long -Wc++98-compat-extra-semi -Wimplicit-fallthrough 
> -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor 
> -Wdelete-non-virtual-dtor -Wstring-conversion -fdiagnostics-color 
> -ffunction-sections -fdata-sections -Wno-deprecated-declarations 
> -Wno-unknown-pragmas -Wno-strict-aliasing -Wno-deprecated-register 
> -Wno-vla-extension -O3   -fno-exceptions -fno-rtti -UNDEBUG -std=c++14 -MD 
> -MT 
> tools/lldb/source/Plugins/Language/ObjC/CMakeFiles/lldbPluginObjCLanguage.dir/Cocoa.cpp.o
>  -MF 
> tools/lldb/source/Plugins/Language/ObjC/CMakeFiles/lldbPluginObjCLanguage.dir/Cocoa.cpp.o.d
>  -o 
> tools/lldb/source/Plugins/Language/ObjC/CMakeFiles/lldbPluginObjCLanguage.dir/Cocoa.cpp.o
>  -c /mnt/vss/_work/2/s/lldb/source/Plugins/Language/ObjC/Cocoa.cpp
>   /mnt/vss/_work/2/s/lldb/source/Plugins/Language/ObjC/Cocoa.cpp:528:11: 
> error: misleading indentation; statement is not part of the previous 'if' 
> [-Werror,-Wmisleading-indentation]
> return false;
> ^
>   /mnt/vss/_work/2/s/lldb/source/Plugins/Language/ObjC/Cocoa.cpp:525:9: note: 
> previous statement is here
>   if (log) 
>
> For this badly indented code:
>
>   if (is_preserved_number) {
>   if (log) 
> log->Printf("Unsupported preserved NSNumber tagged pointer 0x%" 
> PRIu64, valobj_addr);
> return false;
>   }




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99694

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


[Lldb-commits] [lldb] dc8d63d - [lldb] Format Plugins/Language/ObjC/Cocoa.cpp (NFC)

2021-04-06 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2021-04-06T09:47:46-07:00
New Revision: dc8d63de5d5ec987b89256564a038cb580cae607

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

LOG: [lldb] Format Plugins/Language/ObjC/Cocoa.cpp (NFC)

Added: 


Modified: 
lldb/source/Plugins/Language/ObjC/Cocoa.cpp

Removed: 




diff  --git a/lldb/source/Plugins/Language/ObjC/Cocoa.cpp 
b/lldb/source/Plugins/Language/ObjC/Cocoa.cpp
index 840b2bc4d8e98..a0b1b01359ccd 100644
--- a/lldb/source/Plugins/Language/ObjC/Cocoa.cpp
+++ b/lldb/source/Plugins/Language/ObjC/Cocoa.cpp
@@ -367,10 +367,10 @@ static void NSNumber_FormatLong(ValueObject &valobj, 
Stream &stream,
 }
 
 static void NSNumber_FormatInt128(ValueObject &valobj, Stream &stream,
- const llvm::APInt &value,
- lldb::LanguageType lang) {
+  const llvm::APInt &value,
+  lldb::LanguageType lang) {
   static ConstString g_TypeHint("NSNumber:int128_t");
-  
+
   std::string prefix, suffix;
   if (Language *language = Language::FindPlugin(lang)) {
 if (!language->GetFormatterPrefixSuffix(valobj, g_TypeHint, prefix,
@@ -379,7 +379,7 @@ static void NSNumber_FormatInt128(ValueObject &valobj, 
Stream &stream,
   suffix.clear();
 }
   }
-  
+
   stream.PutCString(prefix.c_str());
   const int radix = 10;
   const bool isSigned = true;
@@ -426,8 +426,7 @@ bool lldb_private::formatters::NSNumberSummaryProvider(
   if (!process_sp)
 return false;
 
-  Log * log 
-  = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_DATAFORMATTERS);
+  Log *log = 
lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_DATAFORMATTERS);
   ObjCLanguageRuntime *runtime = ObjCLanguageRuntime::Get(*process_sp);
 
   if (!runtime)
@@ -463,9 +462,10 @@ bool lldb_private::formatters::NSNumberSummaryProvider(
 if (descriptor->GetTaggedPointerInfoSigned(&i_bits, &value)) {
   // Check for "preserved" numbers.  We still don't support them yet.
   if (i_bits & 0x8) {
-if (log) 
-  log->Printf("Unsupported (preserved) NSNumber tagged pointer 0x%"
-  PRIu64, valobj_addr);
+if (log)
+  log->Printf(
+  "Unsupported (preserved) NSNumber tagged pointer 0x%" PRIu64,
+  valobj_addr);
 return false;
   }
 
@@ -508,51 +508,66 @@ bool lldb_private::formatters::NSNumberSummaryProvider(
 f64 = 0x5,
 sint128 = 0x6
   };
-  
+
   uint64_t data_location = valobj_addr + 2 * ptr_size;
   TypeCodes type_code;
-  
+
   if (new_format) {
-uint64_t cfinfoa =
-process_sp->ReadUnsignedIntegerFromMemory(valobj_addr + ptr_size,
-  ptr_size, 0, error);
-
+uint64_t cfinfoa = process_sp->ReadUnsignedIntegerFromMemory(
+valobj_addr + ptr_size, ptr_size, 0, error);
+
 if (error.Fail())
   return false;
 
 bool is_preserved_number = cfinfoa & 0x8;
 if (is_preserved_number) {
   if (log)
-log->Printf("Unsupported preserved NSNumber tagged pointer 0x%"
-PRIu64, valobj_addr);
+log->Printf(
+"Unsupported preserved NSNumber tagged pointer 0x%" PRIu64,
+valobj_addr);
   return false;
 }
 
 type_code = static_cast(cfinfoa & 0x7);
   } else {
-uint8_t data_type =
-process_sp->ReadUnsignedIntegerFromMemory(valobj_addr + ptr_size, 1,
-  0, error) & 0x1F;
-
+uint8_t data_type = process_sp->ReadUnsignedIntegerFromMemory(
+valobj_addr + ptr_size, 1, 0, error) &
+0x1F;
+
 if (error.Fail())
   return false;
-
+
 switch (data_type) {
-  case 1: type_code = TypeCodes::sint8; break;
-  case 2: type_code = TypeCodes::sint16; break;
-  case 3: type_code = TypeCodes::sint32; break;
-  case 17: data_location += 8; LLVM_FALLTHROUGH;
-  case 4: type_code = TypeCodes::sint64; break;
-  case 5: type_code = TypeCodes::f32; break;
-  case 6: type_code = TypeCodes::f64; break;
-  default: return false;
+case 1:
+  type_code = TypeCodes::sint8;
+  break;
+case 2:
+  type_code = TypeCodes::sint16;
+  break;
+case 3:
+  type_code = TypeCodes::sint32;
+  break;
+case 17:
+  data_location += 8;
+  LLVM_FALLTHROUGH;
+case 4:
+  type_code = TypeCodes::sint64;
+  break;
+case 5:
+  type_co

[Lldb-commits] [lldb] 801cea2 - [lldb] Fix else-after-return in AppleObjCRuntimeV2 (NFC)

2021-04-06 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2021-04-06T10:07:22-07:00
New Revision: 801cea2ce9515cc6b6c9b59dfac6e48074737da1

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

LOG: [lldb] Fix else-after-return in AppleObjCRuntimeV2 (NFC)

Use early returns to associate the error message with the corresponding
condition and eliminate some else-after-returns in the process.

Added: 


Modified: 

lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp

Removed: 




diff  --git 
a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
 
b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
index debdfeaf909a7..752162109468f 100644
--- 
a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
+++ 
b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
@@ -454,30 +454,33 @@ ExtractRuntimeGlobalSymbol(Process *process, ConstString 
name,
 error.SetErrorString("no process");
 return default_value;
   }
+
   if (!module_sp) {
 error.SetErrorString("no module");
 return default_value;
   }
+
   if (!byte_size)
 byte_size = process->GetAddressByteSize();
   const Symbol *symbol =
   module_sp->FindFirstSymbolWithNameAndType(name, lldb::eSymbolTypeData);
-  if (symbol && symbol->ValueIsAddress()) {
-lldb::addr_t symbol_load_addr =
-symbol->GetAddressRef().GetLoadAddress(&process->GetTarget());
-if (symbol_load_addr != LLDB_INVALID_ADDRESS) {
-  if (read_value)
-return process->ReadUnsignedIntegerFromMemory(
-symbol_load_addr, byte_size, default_value, error);
-  return symbol_load_addr;
-} else {
-  error.SetErrorString("symbol address invalid");
-  return default_value;
-}
-  } else {
+
+  if (!symbol || !symbol->ValueIsAddress()) {
 error.SetErrorString("no symbol");
 return default_value;
   }
+
+  lldb::addr_t symbol_load_addr =
+  symbol->GetAddressRef().GetLoadAddress(&process->GetTarget());
+  if (symbol_load_addr == LLDB_INVALID_ADDRESS) {
+error.SetErrorString("symbol address invalid");
+return default_value;
+  }
+
+  if (read_value)
+return process->ReadUnsignedIntegerFromMemory(symbol_load_addr, byte_size,
+  default_value, error);
+  return symbol_load_addr;
 }
 
 static void RegisterObjCExceptionRecognizer(Process *process);
@@ -571,8 +574,8 @@ LanguageRuntime *AppleObjCRuntimeV2::CreateInstance(Process 
*process,
 ObjCRuntimeVersions::eAppleObjC_V2)
   return new AppleObjCRuntimeV2(process, objc_module_sp);
 return nullptr;
-  } else
-return nullptr;
+  }
+  return nullptr;
 }
 
 static constexpr OptionDefinition g_objc_classtable_dump_options[] = {



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


[Lldb-commits] [PATCH] D96715: [lldb] Decouple IsMasterPlan and OkayToDiscard (NFC)

2021-04-06 Thread Dave Lee via Phabricator via lldb-commits
kastiglione added a comment.

friendly ping @jingham


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96715

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


[Lldb-commits] [PATCH] D96715: [lldb] Decouple IsMasterPlan and OkayToDiscard (NFC)

2021-04-06 Thread Jim Ingham via Phabricator via lldb-commits
jingham added a comment.

I don't understand how DiscardPlansConsultingMasterPlan in this patch works.

With your changes, every plan but the ObjC trampoline finder returns false from 
OkayToDiscard.  So if you are trying to discard plans up to the innermost 
master plan, you start from the youngest plan asking it if is "OkayToDiscard".  
Since no plans return false, the iteration will go all the way to the Base 
thread plan regardless of whether there were intervening master plans, which 
isn't right.  Why didn't you ask IsMasterPlan in that loop rather than 
OkayToDiscard?

Was there a problem with just saying "Everything but master plans can be 
discarded when we are discarding plans."  I'm not sure why the ObjC Trampoline 
step through thread plan needs to be a Master Plan.  It seems to me it's just 
another subsidiary plan to a step in plan or something like.  Maybe it would be 
better to eliminate the OkayToDiscard altogether, and figure out a better way 
to handle the ObjC trampoline, if that actually needs doing.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96715

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