[Lldb-commits] [lldb] 8632931 - [DWARFYAML] Make the length field of compilation units optional. NFC.

2020-07-21 Thread Xing GUO via lldb-commits

Author: Xing GUO
Date: 2020-07-22T12:16:19+08:00
New Revision: 86329317873e46f8bc094b05437a44a1f65c55d6

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

LOG: [DWARFYAML] Make the length field of compilation units optional. NFC.

This patch makes the length field of compilation units optional (0 by
default).

Added: 


Modified: 
lldb/unittests/Expression/DWARFExpressionTest.cpp
lldb/unittests/SymbolFile/DWARF/DWARFASTParserClangTests.cpp
llvm/lib/ObjectYAML/DWARFYAML.cpp
llvm/unittests/DebugInfo/DWARF/DWARFDebugInfoTest.cpp
llvm/unittests/DebugInfo/DWARF/DWARFDieTest.cpp

Removed: 




diff  --git a/lldb/unittests/Expression/DWARFExpressionTest.cpp 
b/lldb/unittests/Expression/DWARFExpressionTest.cpp
index 78c400c33d4e..ffa3775a6113 100644
--- a/lldb/unittests/Expression/DWARFExpressionTest.cpp
+++ b/lldb/unittests/Expression/DWARFExpressionTest.cpp
@@ -94,8 +94,7 @@ TEST(DWARFExpression, DW_OP_convert) {
   "  - Attribute:   DW_AT_byte_size\n"
   "Form:DW_FORM_data1\n"
   "debug_info:\n"
-  "  - Length:  0\n"
-  "Version: 4\n"
+  "  - Version: 4\n"
   "AbbrOffset:  0\n"
   "AddrSize:8\n"
   "Entries:\n"

diff  --git a/lldb/unittests/SymbolFile/DWARF/DWARFASTParserClangTests.cpp 
b/lldb/unittests/SymbolFile/DWARF/DWARFASTParserClangTests.cpp
index 858aa61b19bb..6b84a21c9d7f 100644
--- a/lldb/unittests/SymbolFile/DWARF/DWARFASTParserClangTests.cpp
+++ b/lldb/unittests/SymbolFile/DWARF/DWARFASTParserClangTests.cpp
@@ -56,8 +56,7 @@ TEST_F(DWARFASTParserClangTests,
   "  - Attribute:   DW_AT_byte_size\n"
   "Form:DW_FORM_data1\n"
   "debug_info:\n"
-  "  - Length:  0\n"
-  "Version: 4\n"
+  "  - Version: 4\n"
   "AbbrOffset:  0\n"
   "AddrSize:8\n"
   "Entries:\n"

diff  --git a/llvm/lib/ObjectYAML/DWARFYAML.cpp 
b/llvm/lib/ObjectYAML/DWARFYAML.cpp
index 4cef29a6b428..11eb5779da0e 100644
--- a/llvm/lib/ObjectYAML/DWARFYAML.cpp
+++ b/llvm/lib/ObjectYAML/DWARFYAML.cpp
@@ -143,7 +143,7 @@ void MappingTraits::mapping(
 
 void MappingTraits::mapping(IO , DWARFYAML::Unit ) {
   IO.mapOptional("Format", Unit.Format, dwarf::DWARF32);
-  IO.mapRequired("Length", Unit.Length);
+  IO.mapOptional("Length", Unit.Length, 0);
   IO.mapRequired("Version", Unit.Version);
   if (Unit.Version >= 5)
 IO.mapRequired("UnitType", Unit.Type);

diff  --git a/llvm/unittests/DebugInfo/DWARF/DWARFDebugInfoTest.cpp 
b/llvm/unittests/DebugInfo/DWARF/DWARFDebugInfoTest.cpp
index 6825981de0c3..459d68b57d8b 100644
--- a/llvm/unittests/DebugInfo/DWARF/DWARFDebugInfoTest.cpp
+++ b/llvm/unittests/DebugInfo/DWARF/DWARFDebugInfoTest.cpp
@@ -1368,8 +1368,7 @@ TEST(DWARFDebugInfo, TestEmptyChildren) {
  "Children:DW_CHILDREN_yes\n"
  "Attributes:\n"
  "debug_info:\n"
- "  - Length:  0\n"
- "Version: 4\n"
+ "  - Version: 4\n"
  "AbbrOffset:  0\n"
  "AddrSize:8\n"
  "Entries:\n"

diff  --git a/llvm/unittests/DebugInfo/DWARF/DWARFDieTest.cpp 
b/llvm/unittests/DebugInfo/DWARF/DWARFDieTest.cpp
index 983f0624939a..d87f68e2f740 100644
--- a/llvm/unittests/DebugInfo/DWARF/DWARFDieTest.cpp
+++ b/llvm/unittests/DebugInfo/DWARF/DWARFDieTest.cpp
@@ -34,8 +34,7 @@ TEST(DWARFDie, getLocations) {
   - Attribute:   DW_AT_call_data_location
 Form:DW_FORM_sec_offset
 debug_info:
-  - Length:  0
-Version: 5
+  - Version: 5
 UnitType:DW_UT_compile
 AbbrOffset:  0
 AddrSize:4



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


[Lldb-commits] [PATCH] D84267: Thread ExecutionContextScope through GetByteSize where possible (NFC-ish)

2020-07-21 Thread Jim Ingham via Phabricator via lldb-commits
jingham accepted this revision.
jingham added a comment.
This revision is now accepted and ready to land.

I think you missed two more places to pass a target, then this looks good to 
me.  How tedious, thanks for doing it...




Comment at: lldb/source/Commands/CommandObjectTarget.cpp:1666
+typedefed_type_sp->GetDescription(, eDescriptionLevelFull, true,
+  nullptr);
 typedef_type_sp = typedefed_type_sp;

You should be able to use the same target here that you did just above, right?



Comment at: lldb/source/Commands/CommandObjectTarget.cpp:1710
   typedefed_type_sp->GetFullCompilerType();
-  typedefed_type_sp->GetDescription(, eDescriptionLevelFull, true);
+  typedefed_type_sp->GetDescription(, eDescriptionLevelFull, true,
+nullptr);

Here too.


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

https://reviews.llvm.org/D84267



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


[Lldb-commits] [PATCH] D84285: Unify the return value of GetByteSize to an llvm::Optional (NFC-ish)

2020-07-21 Thread Adrian Prantl via Phabricator via lldb-commits
aprantl marked an inline comment as done.
aprantl added inline comments.



Comment at: lldb/source/Target/StackFrame.cpp:1445
+int64_t index = offset / pointee->GetByteSize().getValueOr(1);
+offset = offset % pointee->GetByteSize().getValueOr(1);
 const bool can_create = true;

Yeah, I know.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84285



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


[Lldb-commits] [PATCH] D84285: Unify the return value of GetByteSize to an llvm::Optional (NFC-ish)

2020-07-21 Thread Adrian Prantl via Phabricator via lldb-commits
aprantl created this revision.
aprantl added reviewers: jingham, shafik, teemperor.
Herald added a project: LLDB.

This cleanup patch unifies all methods called GetByteSize in the ValueObject 
hierarchy to return an optional, like the methods in CompilerType do. This 
means fewer magic `0` values, which could fix bugs down the road in languages 
where types can have a size of zero, such as Swift and C (but not C++).


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D84285

Files:
  lldb/include/lldb/Core/ValueObject.h
  lldb/include/lldb/Core/ValueObjectCast.h
  lldb/include/lldb/Core/ValueObjectChild.h
  lldb/include/lldb/Core/ValueObjectConstResult.h
  lldb/include/lldb/Core/ValueObjectDynamicValue.h
  lldb/include/lldb/Core/ValueObjectMemory.h
  lldb/include/lldb/Core/ValueObjectRegister.h
  lldb/include/lldb/Core/ValueObjectSyntheticFilter.h
  lldb/include/lldb/Core/ValueObjectVariable.h
  lldb/include/lldb/Expression/ExpressionVariable.h
  lldb/include/lldb/Target/StackFrameRecognizer.h
  lldb/source/API/SBValue.cpp
  lldb/source/Commands/CommandObjectWatchpoint.cpp
  lldb/source/Core/ValueObject.cpp
  lldb/source/Core/ValueObjectCast.cpp
  lldb/source/Core/ValueObjectConstResult.cpp
  lldb/source/Core/ValueObjectDynamicValue.cpp
  lldb/source/Core/ValueObjectMemory.cpp
  lldb/source/Core/ValueObjectRegister.cpp
  lldb/source/Core/ValueObjectSyntheticFilter.cpp
  lldb/source/Core/ValueObjectVariable.cpp
  lldb/source/Expression/ExpressionVariable.cpp
  lldb/source/Expression/Materializer.cpp
  lldb/source/Target/StackFrame.cpp

Index: lldb/source/Target/StackFrame.cpp
===
--- lldb/source/Target/StackFrame.cpp
+++ lldb/source/Target/StackFrame.cpp
@@ -1408,7 +1408,7 @@
 }
 
 int64_t child_offset = child_sp->GetByteOffset();
-int64_t child_size = child_sp->GetByteSize();
+int64_t child_size = child_sp->GetByteSize().getValueOr(0);
 
 if (offset >= child_offset && offset < (child_offset + child_size)) {
   return GetValueForOffset(frame, child_sp, offset - child_offset);
@@ -1441,8 +1441,8 @@
   }
 
   if (offset >= 0 && uint64_t(offset) >= pointee->GetByteSize()) {
-int64_t index = offset / pointee->GetByteSize();
-offset = offset % pointee->GetByteSize();
+int64_t index = offset / pointee->GetByteSize().getValueOr(1);
+offset = offset % pointee->GetByteSize().getValueOr(1);
 const bool can_create = true;
 pointee = base->GetSyntheticArrayMember(index, can_create);
   }
Index: lldb/source/Expression/Materializer.cpp
===
--- lldb/source/Expression/Materializer.cpp
+++ lldb/source/Expression/Materializer.cpp
@@ -67,7 +67,7 @@
 const bool zero_memory = false;
 
 lldb::addr_t mem = map.Malloc(
-m_persistent_variable_sp->GetByteSize(), 8,
+m_persistent_variable_sp->GetByteSize().getValueOr(0), 8,
 lldb::ePermissionsReadable | lldb::ePermissionsWritable,
 IRMemoryMap::eAllocationPolicyMirror, zero_memory, allocate_error);
 
@@ -106,7 +106,8 @@
 Status write_error;
 
 map.WriteMemory(mem, m_persistent_variable_sp->GetValueBytes(),
-m_persistent_variable_sp->GetByteSize(), write_error);
+m_persistent_variable_sp->GetByteSize().getValueOr(0),
+write_error);
 
 if (!write_error.Success()) {
   err.SetErrorStringWithFormat(
@@ -234,7 +235,7 @@
 map.GetBestExecutionContextScope(),
 m_persistent_variable_sp.get()->GetCompilerType(),
 m_persistent_variable_sp->GetName(), location, eAddressTypeLoad,
-m_persistent_variable_sp->GetByteSize());
+m_persistent_variable_sp->GetByteSize().getValueOr(0));
 
 if (frame_top != LLDB_INVALID_ADDRESS &&
 frame_bottom != LLDB_INVALID_ADDRESS && location >= frame_bottom &&
@@ -279,7 +280,8 @@
 LLDB_LOGF(log, "Dematerializing %s from 0x%" PRIx64 " (size = %llu)",
   m_persistent_variable_sp->GetName().GetCString(),
   (uint64_t)mem,
-  (unsigned long long)m_persistent_variable_sp->GetByteSize());
+  (unsigned long long)m_persistent_variable_sp->GetByteSize()
+  .getValueOr(0));
 
 // Read the contents of the spare memory area
 
@@ -288,7 +290,7 @@
 Status read_error;
 
 map.ReadMemory(m_persistent_variable_sp->GetValueBytes(), mem,
-   m_persistent_variable_sp->GetByteSize(), read_error);
+   m_persistent_variable_sp->GetByteSize().getValueOr(0), read_error);
 
 if (!read_error.Success()) {
   err.SetErrorStringWithFormat(
@@ -369,10 +371,11 @@
   if (!err.Success()) {
 dump_stream.Printf("  \n");
   } else {
-DataBufferHeap data(m_persistent_variable_sp->GetByteSize(), 0);
+DataBufferHeap data(
+  

[Lldb-commits] [PATCH] D84267: Thread ExecutionContextScope through GetByteSize where possible (NFC-ish)

2020-07-21 Thread Adrian Prantl via Phabricator via lldb-commits
aprantl updated this revision to Diff 279675.
aprantl marked 6 inline comments as done.
aprantl added a comment.

Added missed opportunities pointed out by Jim!


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

https://reviews.llvm.org/D84267

Files:
  lldb/include/lldb/Symbol/CompilerType.h
  lldb/include/lldb/Symbol/Type.h
  lldb/include/lldb/Symbol/TypeSystem.h
  lldb/source/API/SBType.cpp
  lldb/source/Commands/CommandObjectTarget.cpp
  lldb/source/Core/Value.cpp
  lldb/source/Core/ValueObjectMemory.cpp
  lldb/source/DataFormatters/FormatManager.cpp
  lldb/source/Expression/Materializer.cpp
  lldb/source/Plugins/ABI/AArch64/ABIMacOSX_arm64.cpp
  lldb/source/Plugins/ABI/AArch64/ABISysV_arm64.cpp
  lldb/source/Plugins/ABI/ARC/ABISysV_arc.cpp
  lldb/source/Plugins/ABI/ARM/ABISysV_arm.cpp
  lldb/source/Plugins/ABI/Mips/ABISysV_mips64.cpp
  lldb/source/Plugins/ABI/PowerPC/ABISysV_ppc.cpp
  lldb/source/Plugins/ABI/PowerPC/ABISysV_ppc64.cpp
  lldb/source/Plugins/ABI/SystemZ/ABISysV_s390x.cpp
  lldb/source/Plugins/ABI/X86/ABISysV_i386.cpp
  lldb/source/Plugins/ABI/X86/ABISysV_x86_64.cpp
  lldb/source/Plugins/ABI/X86/ABIWindows_x86_64.cpp
  lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
  lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp
  lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
  lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
  lldb/source/Symbol/CompilerType.cpp
  lldb/source/Symbol/SymbolContext.cpp
  lldb/source/Symbol/Type.cpp

Index: lldb/source/Symbol/Type.cpp
===
--- lldb/source/Symbol/Type.cpp
+++ lldb/source/Symbol/Type.cpp
@@ -170,7 +170,7 @@
 }
 
 void Type::GetDescription(Stream *s, lldb::DescriptionLevel level,
-  bool show_name) {
+  bool show_name, ExecutionContextScope *exe_scope) {
   *s << "id = " << (const UserID &)*this;
 
   // Call the name accessor to make sure we resolve the type name
@@ -186,7 +186,7 @@
   }
 
   // Call the get byte size accesor so we resolve our byte size
-  if (GetByteSize())
+  if (GetByteSize(exe_scope))
 s->Printf(", byte-size = %" PRIu64, m_byte_size);
   bool show_fullpaths = (level == lldb::eDescriptionLevelVerbose);
   m_decl.Dump(s, show_fullpaths);
@@ -323,7 +323,9 @@
 
 GetForwardCompilerType().DumpValue(
 exe_ctx, s, format == lldb::eFormatDefault ? GetFormat() : format, data,
-data_byte_offset, GetByteSize().getValueOr(0),
+data_byte_offset,
+GetByteSize(exe_ctx ? exe_ctx->GetBestExecutionContextScope() : nullptr)
+.getValueOr(0),
 0, // Bitfield bit size
 0, // Bitfield bit offset
 show_types, show_summary, verbose, 0);
@@ -336,7 +338,7 @@
   return m_encoding_type;
 }
 
-llvm::Optional Type::GetByteSize() {
+llvm::Optional Type::GetByteSize(ExecutionContextScope *exe_scope) {
   if (m_byte_size_has_value)
 return m_byte_size;
 
@@ -352,14 +354,14 @@
   case eEncodingIsTypedefUID: {
 Type *encoding_type = GetEncodingType();
 if (encoding_type)
-  if (llvm::Optional size = encoding_type->GetByteSize()) {
+  if (llvm::Optional size = encoding_type->GetByteSize(exe_scope)) {
 m_byte_size = *size;
 m_byte_size_has_value = true;
 return m_byte_size;
   }
 
 if (llvm::Optional size =
-GetLayoutCompilerType().GetByteSize(nullptr)) {
+GetLayoutCompilerType().GetByteSize(exe_scope)) {
   m_byte_size = *size;
   m_byte_size_has_value = true;
 return m_byte_size;
@@ -430,7 +432,9 @@
 return false;
   }
 
-  const uint64_t byte_size = GetByteSize().getValueOr(0);
+  const uint64_t byte_size =
+  GetByteSize(exe_ctx ? exe_ctx->GetBestExecutionContextScope() : nullptr)
+  .getValueOr(0);
   if (data.GetByteSize() < byte_size) {
 lldb::DataBufferSP data_sp(new DataBufferHeap(byte_size, '\0'));
 data.SetData(data_sp);
Index: lldb/source/Symbol/SymbolContext.cpp
===
--- lldb/source/Symbol/SymbolContext.cpp
+++ lldb/source/Symbol/SymbolContext.cpp
@@ -204,7 +204,7 @@
 Type *func_type = function->GetType();
 if (func_type) {
   s->Indent("   FuncType: ");
-  func_type->GetDescription(s, level, false);
+  func_type->GetDescription(s, level, false, target);
   s->EOL();
 }
   }
Index: lldb/source/Symbol/CompilerType.cpp
===
--- lldb/source/Symbol/CompilerType.cpp
+++ lldb/source/Symbol/CompilerType.cpp
@@ -317,9 +317,10 @@
 
 // Creating related types
 
-CompilerType CompilerType::GetArrayElementType(uint64_t *stride) const {
+CompilerType CompilerType::GetArrayElementType(ExecutionContextScope *exe_scope,
+   

[Lldb-commits] [PATCH] D84267: Thread ExecutionContextScope through GetByteSize where possible (NFC-ish)

2020-07-21 Thread Adrian Prantl via Phabricator via lldb-commits
aprantl updated this revision to Diff 279670.
aprantl added a comment.

Add another PPC syntax failure.


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

https://reviews.llvm.org/D84267

Files:
  lldb/include/lldb/Symbol/CompilerType.h
  lldb/include/lldb/Symbol/Type.h
  lldb/include/lldb/Symbol/TypeSystem.h
  lldb/source/API/SBType.cpp
  lldb/source/Commands/CommandObjectTarget.cpp
  lldb/source/Core/Value.cpp
  lldb/source/Core/ValueObjectMemory.cpp
  lldb/source/DataFormatters/FormatManager.cpp
  lldb/source/Expression/Materializer.cpp
  lldb/source/Plugins/ABI/AArch64/ABIMacOSX_arm64.cpp
  lldb/source/Plugins/ABI/AArch64/ABISysV_arm64.cpp
  lldb/source/Plugins/ABI/ARC/ABISysV_arc.cpp
  lldb/source/Plugins/ABI/ARM/ABISysV_arm.cpp
  lldb/source/Plugins/ABI/Mips/ABISysV_mips64.cpp
  lldb/source/Plugins/ABI/PowerPC/ABISysV_ppc.cpp
  lldb/source/Plugins/ABI/PowerPC/ABISysV_ppc64.cpp
  lldb/source/Plugins/ABI/SystemZ/ABISysV_s390x.cpp
  lldb/source/Plugins/ABI/X86/ABISysV_i386.cpp
  lldb/source/Plugins/ABI/X86/ABISysV_x86_64.cpp
  lldb/source/Plugins/ABI/X86/ABIWindows_x86_64.cpp
  lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
  lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp
  lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
  lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
  lldb/source/Symbol/CompilerType.cpp
  lldb/source/Symbol/SymbolContext.cpp
  lldb/source/Symbol/Type.cpp

Index: lldb/source/Symbol/Type.cpp
===
--- lldb/source/Symbol/Type.cpp
+++ lldb/source/Symbol/Type.cpp
@@ -170,7 +170,7 @@
 }
 
 void Type::GetDescription(Stream *s, lldb::DescriptionLevel level,
-  bool show_name) {
+  bool show_name, ExecutionContextScope *exe_scope) {
   *s << "id = " << (const UserID &)*this;
 
   // Call the name accessor to make sure we resolve the type name
@@ -186,7 +186,7 @@
   }
 
   // Call the get byte size accesor so we resolve our byte size
-  if (GetByteSize())
+  if (GetByteSize(exe_scope))
 s->Printf(", byte-size = %" PRIu64, m_byte_size);
   bool show_fullpaths = (level == lldb::eDescriptionLevelVerbose);
   m_decl.Dump(s, show_fullpaths);
@@ -323,7 +323,9 @@
 
 GetForwardCompilerType().DumpValue(
 exe_ctx, s, format == lldb::eFormatDefault ? GetFormat() : format, data,
-data_byte_offset, GetByteSize().getValueOr(0),
+data_byte_offset,
+GetByteSize(exe_ctx ? exe_ctx->GetBestExecutionContextScope() : nullptr)
+.getValueOr(0),
 0, // Bitfield bit size
 0, // Bitfield bit offset
 show_types, show_summary, verbose, 0);
@@ -336,7 +338,7 @@
   return m_encoding_type;
 }
 
-llvm::Optional Type::GetByteSize() {
+llvm::Optional Type::GetByteSize(ExecutionContextScope *exe_scope) {
   if (m_byte_size_has_value)
 return m_byte_size;
 
@@ -352,14 +354,14 @@
   case eEncodingIsTypedefUID: {
 Type *encoding_type = GetEncodingType();
 if (encoding_type)
-  if (llvm::Optional size = encoding_type->GetByteSize()) {
+  if (llvm::Optional size = encoding_type->GetByteSize(exe_scope)) {
 m_byte_size = *size;
 m_byte_size_has_value = true;
 return m_byte_size;
   }
 
 if (llvm::Optional size =
-GetLayoutCompilerType().GetByteSize(nullptr)) {
+GetLayoutCompilerType().GetByteSize(exe_scope)) {
   m_byte_size = *size;
   m_byte_size_has_value = true;
 return m_byte_size;
@@ -430,7 +432,9 @@
 return false;
   }
 
-  const uint64_t byte_size = GetByteSize().getValueOr(0);
+  const uint64_t byte_size =
+  GetByteSize(exe_ctx ? exe_ctx->GetBestExecutionContextScope() : nullptr)
+  .getValueOr(0);
   if (data.GetByteSize() < byte_size) {
 lldb::DataBufferSP data_sp(new DataBufferHeap(byte_size, '\0'));
 data.SetData(data_sp);
Index: lldb/source/Symbol/SymbolContext.cpp
===
--- lldb/source/Symbol/SymbolContext.cpp
+++ lldb/source/Symbol/SymbolContext.cpp
@@ -204,7 +204,7 @@
 Type *func_type = function->GetType();
 if (func_type) {
   s->Indent("   FuncType: ");
-  func_type->GetDescription(s, level, false);
+  func_type->GetDescription(s, level, false, target);
   s->EOL();
 }
   }
Index: lldb/source/Symbol/CompilerType.cpp
===
--- lldb/source/Symbol/CompilerType.cpp
+++ lldb/source/Symbol/CompilerType.cpp
@@ -317,9 +317,10 @@
 
 // Creating related types
 
-CompilerType CompilerType::GetArrayElementType(uint64_t *stride) const {
+CompilerType CompilerType::GetArrayElementType(ExecutionContextScope *exe_scope,
+   uint64_t *stride) const {
   if 

[Lldb-commits] [PATCH] D84267: Thread ExecutionContextScope through GetByteSize where possible (NFC-ish)

2020-07-21 Thread Jim Ingham via Phabricator via lldb-commits
jingham added a comment.

I pointed out a couple of places where you have either at hand or near at hand 
a useful exe_ctx that you could pass instead of nullptr.

Other than that, this seems good to me.  Thanks for pushing this through.




Comment at: lldb/source/API/SBType.cpp:210
 
 SBType SBType::GetArrayElementType() {
   LLDB_RECORD_METHOD_NO_ARGS(lldb::SBType, SBType, GetArrayElementType);

This changes makes it obvious we should add 

SBType::GetByteSize(SBExecutionContext _ctx)
SBType::GetArrayElementType(SBExecutionContext _ctx)

but I don't think you need to do that in this patch.



Comment at: lldb/source/Commands/CommandObjectTarget.cpp:1655
   type_sp->GetFullCompilerType();
-  type_sp->GetDescription(, eDescriptionLevelFull, true);
+  type_sp->GetDescription(, eDescriptionLevelFull, true, nullptr);
   // Print all typedef chains

LookupTypeInModule is called by LookupInModule which is only ever called when 
we have a target on hand.  Maybe it would be better to thread the target 
through so we can get better type descriptions if the target has a live 
process?  Or make it a member function of CommandObjectTargetModulesLookup and 
it could use m_exe_ctx.  It doesn't seem to be gaining anything by being a 
stand-alone function.



Comment at: lldb/source/Commands/CommandObjectTarget.cpp:1700
 type_sp->GetFullCompilerType();
-type_sp->GetDescription(, eDescriptionLevelFull, true);
-// Print all typedef chains
+type_sp->GetDescription(, eDescriptionLevelFull, true, nullptr);
+// Print all typedef chains.

Ditto with this one.  Our only caller (the method called LookupTypeHere) 
definitely had a better ExecutionContextScope (from m_exe_ctx).  Be nice to 
pass it in here.



Comment at: lldb/source/DataFormatters/FormatManager.cpp:240
   if (compiler_type.IsArrayType(nullptr, _size, nullptr)) {
-CompilerType element_type = compiler_type.GetArrayElementType();
+CompilerType element_type = compiler_type.GetArrayElementType(nullptr);
 if (element_type.IsTypedefType()) {

We have the ValueObject we are working on in this scope.  ValueObjects always 
have an ExecutionContextRef (GetExecutionContextRef) so you can pass in a 
better ExecutionContextScope here.


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

https://reviews.llvm.org/D84267



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


[Lldb-commits] [PATCH] D84267: Thread ExecutionContextScope through GetByteSize where possible (NFC-ish)

2020-07-21 Thread Adrian Prantl via Phabricator via lldb-commits
aprantl updated this revision to Diff 279660.
aprantl marked an inline comment as done.
aprantl added a comment.

Upload the *entire* patch m(


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

https://reviews.llvm.org/D84267

Files:
  lldb/include/lldb/Symbol/CompilerType.h
  lldb/include/lldb/Symbol/Type.h
  lldb/include/lldb/Symbol/TypeSystem.h
  lldb/source/API/SBType.cpp
  lldb/source/Commands/CommandObjectTarget.cpp
  lldb/source/Core/Value.cpp
  lldb/source/Core/ValueObjectMemory.cpp
  lldb/source/DataFormatters/FormatManager.cpp
  lldb/source/Expression/Materializer.cpp
  lldb/source/Plugins/ABI/AArch64/ABIMacOSX_arm64.cpp
  lldb/source/Plugins/ABI/AArch64/ABISysV_arm64.cpp
  lldb/source/Plugins/ABI/ARC/ABISysV_arc.cpp
  lldb/source/Plugins/ABI/ARM/ABISysV_arm.cpp
  lldb/source/Plugins/ABI/Mips/ABISysV_mips64.cpp
  lldb/source/Plugins/ABI/PowerPC/ABISysV_ppc.cpp
  lldb/source/Plugins/ABI/PowerPC/ABISysV_ppc64.cpp
  lldb/source/Plugins/ABI/SystemZ/ABISysV_s390x.cpp
  lldb/source/Plugins/ABI/X86/ABISysV_i386.cpp
  lldb/source/Plugins/ABI/X86/ABISysV_x86_64.cpp
  lldb/source/Plugins/ABI/X86/ABIWindows_x86_64.cpp
  lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
  lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp
  lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
  lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
  lldb/source/Symbol/CompilerType.cpp
  lldb/source/Symbol/SymbolContext.cpp
  lldb/source/Symbol/Type.cpp

Index: lldb/source/Symbol/Type.cpp
===
--- lldb/source/Symbol/Type.cpp
+++ lldb/source/Symbol/Type.cpp
@@ -170,7 +170,7 @@
 }
 
 void Type::GetDescription(Stream *s, lldb::DescriptionLevel level,
-  bool show_name) {
+  bool show_name, ExecutionContextScope *exe_scope) {
   *s << "id = " << (const UserID &)*this;
 
   // Call the name accessor to make sure we resolve the type name
@@ -186,7 +186,7 @@
   }
 
   // Call the get byte size accesor so we resolve our byte size
-  if (GetByteSize())
+  if (GetByteSize(exe_scope))
 s->Printf(", byte-size = %" PRIu64, m_byte_size);
   bool show_fullpaths = (level == lldb::eDescriptionLevelVerbose);
   m_decl.Dump(s, show_fullpaths);
@@ -323,7 +323,9 @@
 
 GetForwardCompilerType().DumpValue(
 exe_ctx, s, format == lldb::eFormatDefault ? GetFormat() : format, data,
-data_byte_offset, GetByteSize().getValueOr(0),
+data_byte_offset,
+GetByteSize(exe_ctx ? exe_ctx->GetBestExecutionContextScope() : nullptr)
+.getValueOr(0),
 0, // Bitfield bit size
 0, // Bitfield bit offset
 show_types, show_summary, verbose, 0);
@@ -336,7 +338,7 @@
   return m_encoding_type;
 }
 
-llvm::Optional Type::GetByteSize() {
+llvm::Optional Type::GetByteSize(ExecutionContextScope *exe_scope) {
   if (m_byte_size_has_value)
 return m_byte_size;
 
@@ -352,14 +354,14 @@
   case eEncodingIsTypedefUID: {
 Type *encoding_type = GetEncodingType();
 if (encoding_type)
-  if (llvm::Optional size = encoding_type->GetByteSize()) {
+  if (llvm::Optional size = encoding_type->GetByteSize(exe_scope)) {
 m_byte_size = *size;
 m_byte_size_has_value = true;
 return m_byte_size;
   }
 
 if (llvm::Optional size =
-GetLayoutCompilerType().GetByteSize(nullptr)) {
+GetLayoutCompilerType().GetByteSize(exe_scope)) {
   m_byte_size = *size;
   m_byte_size_has_value = true;
 return m_byte_size;
@@ -430,7 +432,9 @@
 return false;
   }
 
-  const uint64_t byte_size = GetByteSize().getValueOr(0);
+  const uint64_t byte_size =
+  GetByteSize(exe_ctx ? exe_ctx->GetBestExecutionContextScope() : nullptr)
+  .getValueOr(0);
   if (data.GetByteSize() < byte_size) {
 lldb::DataBufferSP data_sp(new DataBufferHeap(byte_size, '\0'));
 data.SetData(data_sp);
Index: lldb/source/Symbol/SymbolContext.cpp
===
--- lldb/source/Symbol/SymbolContext.cpp
+++ lldb/source/Symbol/SymbolContext.cpp
@@ -204,7 +204,7 @@
 Type *func_type = function->GetType();
 if (func_type) {
   s->Indent("   FuncType: ");
-  func_type->GetDescription(s, level, false);
+  func_type->GetDescription(s, level, false, target);
   s->EOL();
 }
   }
Index: lldb/source/Symbol/CompilerType.cpp
===
--- lldb/source/Symbol/CompilerType.cpp
+++ lldb/source/Symbol/CompilerType.cpp
@@ -317,9 +317,10 @@
 
 // Creating related types
 
-CompilerType CompilerType::GetArrayElementType(uint64_t *stride) const {
+CompilerType CompilerType::GetArrayElementType(ExecutionContextScope *exe_scope,
+ 

[Lldb-commits] [PATCH] D84272: Add checks for ValueObjectSP in Cocoa summary providers

2020-07-21 Thread Jim Ingham via Phabricator via lldb-commits
jingham added a comment.

The `!text` test is correct, since you intend to pass `*text` in as a 
`ValueObject &`.  But I wouldn't add the GetValueAsUnsigned check, that seems 
confusing.  The NSStringSummaryProvider is returning a bool to tell you whether 
it succeeded or not, so it seems odd to pre-judge one of it's error states.


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

https://reviews.llvm.org/D84272



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


[Lldb-commits] [PATCH] D84267: Thread ExecutionContextScope through GetByteSize where possible (NFC-ish)

2020-07-21 Thread Jim Ingham via Phabricator via lldb-commits
jingham added a comment.

The patch lost seems to have lost everything but the PPC, SystemZ and MIPS 
code...


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

https://reviews.llvm.org/D84267



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


[Lldb-commits] [PATCH] D84272: Add checks for ValueObjectSP in Cocoa summary providers

2020-07-21 Thread Shafik Yaghmour via Phabricator via lldb-commits
shafik created this revision.
shafik added a reviewer: jingham.

We saw a crash recently that looks related to we had good `ValueObjectSP` for 
some Cocoa summary providers. This adds checks before we use them when calling 
`NSStringSummaryProvider`.


https://reviews.llvm.org/D84272

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


Index: lldb/source/Plugins/Language/ObjC/Cocoa.cpp
===
--- lldb/source/Plugins/Language/ObjC/Cocoa.cpp
+++ lldb/source/Plugins/Language/ObjC/Cocoa.cpp
@@ -72,6 +72,9 @@
 valobj.GetCompilerType().GetBasicTypeFromAST(lldb::eBasicTypeObjCID),
 true));
 
+if (!text || text->GetValueAsUnsigned(0) == 0)
+  return false;
+
 StreamString summary_stream;
 bool was_nsstring_ok =
 NSStringSummaryProvider(*text, summary_stream, options);
@@ -117,6 +120,10 @@
 uint64_t offset = ptr_size;
 ValueObjectSP text(valobj.GetSyntheticChildAtOffset(
 offset, valobj.GetCompilerType(), true));
+
+if (!text || text->GetValueAsUnsigned(0) == 0)
+  return false;
+
 StreamString summary_stream;
 bool was_nsstring_ok =
 NSStringSummaryProvider(*text, summary_stream, options);
@@ -162,6 +169,10 @@
 uint64_t offset = ptr_size;
 ValueObjectSP text(valobj.GetSyntheticChildAtOffset(
 offset, valobj.GetCompilerType(), true));
+
+if (!text || text->GetValueAsUnsigned(0) == 0)
+  return false;
+
 StreamString summary_stream;
 bool was_nsstring_ok =
 NSStringSummaryProvider(*text, summary_stream, options);


Index: lldb/source/Plugins/Language/ObjC/Cocoa.cpp
===
--- lldb/source/Plugins/Language/ObjC/Cocoa.cpp
+++ lldb/source/Plugins/Language/ObjC/Cocoa.cpp
@@ -72,6 +72,9 @@
 valobj.GetCompilerType().GetBasicTypeFromAST(lldb::eBasicTypeObjCID),
 true));
 
+if (!text || text->GetValueAsUnsigned(0) == 0)
+  return false;
+
 StreamString summary_stream;
 bool was_nsstring_ok =
 NSStringSummaryProvider(*text, summary_stream, options);
@@ -117,6 +120,10 @@
 uint64_t offset = ptr_size;
 ValueObjectSP text(valobj.GetSyntheticChildAtOffset(
 offset, valobj.GetCompilerType(), true));
+
+if (!text || text->GetValueAsUnsigned(0) == 0)
+  return false;
+
 StreamString summary_stream;
 bool was_nsstring_ok =
 NSStringSummaryProvider(*text, summary_stream, options);
@@ -162,6 +169,10 @@
 uint64_t offset = ptr_size;
 ValueObjectSP text(valobj.GetSyntheticChildAtOffset(
 offset, valobj.GetCompilerType(), true));
+
+if (!text || text->GetValueAsUnsigned(0) == 0)
+  return false;
+
 StreamString summary_stream;
 bool was_nsstring_ok =
 NSStringSummaryProvider(*text, summary_stream, options);
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D82155: [lldb/interpreter] Add ability to save lldb session to a file

2020-07-21 Thread Med Ismail Bennani via Phabricator via lldb-commits
mib updated this revision to Diff 279639.
mib added a comment.

Reformat patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82155

Files:
  lldb/include/lldb/Interpreter/CommandInterpreter.h
  lldb/source/Commands/CMakeLists.txt
  lldb/source/Commands/CommandObjectQuit.cpp
  lldb/source/Commands/CommandObjectSession.cpp
  lldb/source/Commands/CommandObjectSession.h
  lldb/source/Interpreter/CommandInterpreter.cpp
  lldb/source/Interpreter/InterpreterProperties.td
  lldb/test/API/commands/session/save/TestSessionSave.py

Index: lldb/test/API/commands/session/save/TestSessionSave.py
===
--- /dev/null
+++ lldb/test/API/commands/session/save/TestSessionSave.py
@@ -0,0 +1,70 @@
+"""
+Test the session save feature
+"""
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class SessionSaveTestCase(TestBase):
+
+mydir = TestBase.compute_mydir(__file__)
+
+def setUp(self):
+  configuration.settings.append(("interpreter.echo-commands", "true"))
+  configuration.settings.append(("interpreter.echo-comment-commands", "true"))
+  configuration.settings.append(("interpreter.stop-command-source-on-error", "false"))
+  TestBase.setUp(self)
+
+
+def raw_transcript_builder(self, cmd, res):
+raw = "(lldb) " + cmd + "\n"
+if res.GetOutputSize():
+  raw += res.GetOutput()
+if res.GetErrorSize():
+  raw += res.GetError()
+return raw
+
+
+@skipIfWindows
+@skipIfReproducer
+@no_debug_info_test
+def test_session_save(self):
+raw = ""
+inputs = [
+  '# This is a comment',  # Comment
+  'help session', # Valid command
+  'Lorem ipsum'   # Invalid command
+]
+
+import tempfile
+tf = tempfile.NamedTemporaryFile()
+
+interpreter = self.dbg.GetCommandInterpreter()
+for cmd in inputs:
+  res = lldb.SBCommandReturnObject()
+  interpreter.HandleCommand(cmd, res)
+  raw += self.raw_transcript_builder(cmd, res)
+
+self.assertTrue(interpreter.HasCommands())
+self.assertTrue(len(raw) != 0)
+
+# Check for error
+cmd = 'session save /root/file'
+interpreter.HandleCommand(cmd, res)
+self.assertFalse(res.Succeeded())
+raw += self.raw_transcript_builder(cmd, res)
+
+output_file = tf.name
+
+res = lldb.SBCommandReturnObject()
+interpreter.HandleCommand('session save ' + output_file, res)
+self.assertTrue(res.Succeeded())
+raw += self.raw_transcript_builder(cmd, res)
+
+with open(output_file, "r") as file:
+  content = file.read()
+  for line in raw.splitlines():
+self.assertIn(line, content)
Index: lldb/source/Interpreter/InterpreterProperties.td
===
--- lldb/source/Interpreter/InterpreterProperties.td
+++ lldb/source/Interpreter/InterpreterProperties.td
@@ -9,6 +9,10 @@
 Global,
 DefaultTrue,
 Desc<"If true, LLDB will prompt you before quitting if there are any live processes being debugged. If false, LLDB will quit without asking in any case.">;
+  def SaveSessionOnQuit: Property<"save-session-on-quit", "Boolean">,
+Global,
+DefaultFalse,
+Desc<"If true, LLDB will save the session's transcripts before quitting.">;
   def StopCmdSourceOnError: Property<"stop-command-source-on-error", "Boolean">,
 Global,
 DefaultTrue,
Index: lldb/source/Interpreter/CommandInterpreter.cpp
===
--- lldb/source/Interpreter/CommandInterpreter.cpp
+++ lldb/source/Interpreter/CommandInterpreter.cpp
@@ -6,6 +6,7 @@
 //
 //===--===//
 
+#include 
 #include 
 #include 
 #include 
@@ -31,6 +32,7 @@
 #include "Commands/CommandObjectQuit.h"
 #include "Commands/CommandObjectRegister.h"
 #include "Commands/CommandObjectReproducer.h"
+#include "Commands/CommandObjectSession.h"
 #include "Commands/CommandObjectSettings.h"
 #include "Commands/CommandObjectSource.h"
 #include "Commands/CommandObjectStats.h"
@@ -52,6 +54,8 @@
 #if LLDB_ENABLE_LIBEDIT
 #include "lldb/Host/Editline.h"
 #endif
+#include "lldb/Host/File.h"
+#include "lldb/Host/FileCache.h"
 #include "lldb/Host/Host.h"
 #include "lldb/Host/HostInfo.h"
 
@@ -74,6 +78,7 @@
 #include "llvm/Support/FormatAdapters.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/PrettyStackTrace.h"
+#include "llvm/Support/ScopedPrinter.h"
 
 using namespace lldb;
 using namespace lldb_private;
@@ -116,7 +121,7 @@
   m_skip_lldbinit_files(false), m_skip_app_init_files(false),
   m_command_io_handler_sp(), m_comment_char('#'),
   

[Lldb-commits] [PATCH] D82155: [lldb/interpreter] Add ability to save lldb session to a file

2020-07-21 Thread Med Ismail Bennani via Phabricator via lldb-commits
mib updated this revision to Diff 279638.
mib marked 6 inline comments as done.
mib added a comment.

Address @JDevlieghere comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82155

Files:
  lldb/include/lldb/Interpreter/CommandInterpreter.h
  lldb/source/Commands/CMakeLists.txt
  lldb/source/Commands/CommandObjectLog.cpp
  lldb/source/Commands/CommandObjectQuit.cpp
  lldb/source/Commands/CommandObjectSession.cpp
  lldb/source/Commands/CommandObjectSession.h
  lldb/source/Interpreter/CommandInterpreter.cpp
  lldb/source/Interpreter/InterpreterProperties.td
  lldb/test/API/commands/session/save/TestSessionSave.py

Index: lldb/test/API/commands/session/save/TestSessionSave.py
===
--- /dev/null
+++ lldb/test/API/commands/session/save/TestSessionSave.py
@@ -0,0 +1,70 @@
+"""
+Test the session save feature
+"""
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class SessionSaveTestCase(TestBase):
+
+mydir = TestBase.compute_mydir(__file__)
+
+def setUp(self):
+  configuration.settings.append(("interpreter.echo-commands", "true"))
+  configuration.settings.append(("interpreter.echo-comment-commands", "true"))
+  configuration.settings.append(("interpreter.stop-command-source-on-error", "false"))
+  TestBase.setUp(self)
+
+
+def raw_transcript_builder(self, cmd, res):
+raw = "(lldb) " + cmd + "\n"
+if res.GetOutputSize():
+  raw += res.GetOutput()
+if res.GetErrorSize():
+  raw += res.GetError()
+return raw
+
+
+@skipIfWindows
+@skipIfReproducer
+@no_debug_info_test
+def test_session_save(self):
+raw = ""
+inputs = [
+  '# This is a comment',  # Comment
+  'help session', # Valid command
+  'Lorem ipsum'   # Invalid command
+]
+
+import tempfile
+tf = tempfile.NamedTemporaryFile()
+
+interpreter = self.dbg.GetCommandInterpreter()
+for cmd in inputs:
+  res = lldb.SBCommandReturnObject()
+  interpreter.HandleCommand(cmd, res)
+  raw += self.raw_transcript_builder(cmd, res)
+
+self.assertTrue(interpreter.HasCommands())
+self.assertTrue(len(raw) != 0)
+
+# Check for error
+cmd = 'session save /root/file'
+interpreter.HandleCommand(cmd, res)
+self.assertFalse(res.Succeeded())
+raw += self.raw_transcript_builder(cmd, res)
+
+output_file = tf.name
+
+res = lldb.SBCommandReturnObject()
+interpreter.HandleCommand('session save ' + output_file, res)
+self.assertTrue(res.Succeeded())
+raw += self.raw_transcript_builder(cmd, res)
+
+with open(output_file, "r") as file:
+  content = file.read()
+  for line in raw.splitlines():
+self.assertIn(line, content)
Index: lldb/source/Interpreter/InterpreterProperties.td
===
--- lldb/source/Interpreter/InterpreterProperties.td
+++ lldb/source/Interpreter/InterpreterProperties.td
@@ -9,6 +9,10 @@
 Global,
 DefaultTrue,
 Desc<"If true, LLDB will prompt you before quitting if there are any live processes being debugged. If false, LLDB will quit without asking in any case.">;
+  def SaveSessionOnQuit: Property<"save-session-on-quit", "Boolean">,
+Global,
+DefaultFalse,
+Desc<"If true, LLDB will save the session's transcripts before quitting.">;
   def StopCmdSourceOnError: Property<"stop-command-source-on-error", "Boolean">,
 Global,
 DefaultTrue,
Index: lldb/source/Interpreter/CommandInterpreter.cpp
===
--- lldb/source/Interpreter/CommandInterpreter.cpp
+++ lldb/source/Interpreter/CommandInterpreter.cpp
@@ -6,6 +6,7 @@
 //
 //===--===//
 
+#include 
 #include 
 #include 
 #include 
@@ -31,6 +32,7 @@
 #include "Commands/CommandObjectQuit.h"
 #include "Commands/CommandObjectRegister.h"
 #include "Commands/CommandObjectReproducer.h"
+#include "Commands/CommandObjectSession.h"
 #include "Commands/CommandObjectSettings.h"
 #include "Commands/CommandObjectSource.h"
 #include "Commands/CommandObjectStats.h"
@@ -52,6 +54,8 @@
 #if LLDB_ENABLE_LIBEDIT
 #include "lldb/Host/Editline.h"
 #endif
+#include "lldb/Host/File.h"
+#include "lldb/Host/FileCache.h"
 #include "lldb/Host/Host.h"
 #include "lldb/Host/HostInfo.h"
 
@@ -74,6 +78,7 @@
 #include "llvm/Support/FormatAdapters.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/PrettyStackTrace.h"
+#include "llvm/Support/ScopedPrinter.h"
 
 using namespace lldb;
 using namespace lldb_private;
@@ -116,7 +121,7 @@
   

[Lldb-commits] [PATCH] D84267: Thread ExecutionContextScope through GetByteSize where possible (NFC-ish)

2020-07-21 Thread Adrian Prantl via Phabricator via lldb-commits
aprantl marked 3 inline comments as done.
aprantl added inline comments.



Comment at: lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp:308
   lldb::TargetSP target_sp(m_execution_unit.GetTarget());
-  lldb_private::ExecutionContext exe_ctx(target_sp, true);
-  llvm::Optional bit_size =
-  m_result_type.GetBitSize(exe_ctx.GetBestExecutionContextScope());
+  llvm::Optional bit_size = 
m_result_type.GetBitSize(target_sp.get());
   if (!bit_size) {

shafik wrote:
> Is this equivalent to what was being done previously or is this better in 
> some way?
The old code took a `TargetSP`, wrapped it in an `ExecutionContext`, and then 
called `GetBestExecutionContextScope()`, which returns the `Target *`. 
(`Target` inherits from `ExecutionContextScope`)

So the new code does exactly the same thing as the old code but it's much 
shorter.



Comment at: lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp:4092
 TypeSystemClang::GetArrayElementType(lldb::opaque_compiler_type_t type,
- uint64_t *stride) {
   if (type) {

teemperor wrote:
> So we already have this dubious stride extra-output here, but now it also 
> requires us to have an execution context parameter. I think we might as well 
> just remove that parameter (in a separate patch).
Are you saying no one uses `stride`?

Not even a future Fortran lldb Plugin?


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

https://reviews.llvm.org/D84267



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


[Lldb-commits] [PATCH] D84267: Thread ExecutionContextScope through GetByteSize where possible (NFC-ish)

2020-07-21 Thread Adrian Prantl via Phabricator via lldb-commits
aprantl updated this revision to Diff 279634.
aprantl added a comment.

Fix `` copy errors. Good catch!


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

https://reviews.llvm.org/D84267

Files:
  lldb/source/Plugins/ABI/ARC/ABISysV_arc.cpp
  lldb/source/Plugins/ABI/Mips/ABISysV_mips64.cpp
  lldb/source/Plugins/ABI/PowerPC/ABISysV_ppc.cpp
  lldb/source/Plugins/ABI/PowerPC/ABISysV_ppc64.cpp
  lldb/source/Plugins/ABI/SystemZ/ABISysV_s390x.cpp

Index: lldb/source/Plugins/ABI/SystemZ/ABISysV_s390x.cpp
===
--- lldb/source/Plugins/ABI/SystemZ/ABISysV_s390x.cpp
+++ lldb/source/Plugins/ABI/SystemZ/ABISysV_s390x.cpp
@@ -508,7 +508,7 @@
 if (type_flags & eTypeIsInteger) {
   // Extract the register context so we can read arguments from registers.
   llvm::Optional byte_size =
-  return_compiler_type.GetByteSize(thread);
+  return_compiler_type.GetByteSize();
   if (!byte_size)
 return return_valobj_sp;
   uint64_t raw_value = thread.GetRegisterContext()->ReadRegisterAsUnsigned(
@@ -555,7 +555,7 @@
 // Don't handle complex yet.
   } else {
 llvm::Optional byte_size =
-return_compiler_type.GetByteSize(thread);
+return_compiler_type.GetByteSize();
 if (byte_size && *byte_size <= sizeof(long double)) {
   const RegisterInfo *f0_info = reg_ctx->GetRegisterInfoByName("f0", 0);
   RegisterValue f0_value;
Index: lldb/source/Plugins/ABI/PowerPC/ABISysV_ppc64.cpp
===
--- lldb/source/Plugins/ABI/PowerPC/ABISysV_ppc64.cpp
+++ lldb/source/Plugins/ABI/PowerPC/ABISysV_ppc64.cpp
@@ -567,7 +567,7 @@
   ReturnValueExtractor(Thread , CompilerType ,
RegisterContext *reg_ctx, ProcessSP process_sp)
   : m_thread(thread), m_type(type),
-m_byte_size(m_type.GetByteSize(thread).getValueOr(0)),
+m_byte_size(m_type.GetByteSize().getValueOr(0)),
 m_data_up(new DataBufferHeap(m_byte_size, 0)), m_reg_ctx(reg_ctx),
 m_process_sp(process_sp), m_byte_order(process_sp->GetByteOrder()),
 m_addr_size(
@@ -643,7 +643,7 @@
 DataExtractor de(_data, sizeof(raw_data), m_byte_order, m_addr_size);
 
 offset_t offset = 0;
-llvm::Optional byte_size = type.GetByteSize(thread);
+llvm::Optional byte_size = type.GetByteSize();
 if (!byte_size)
   return {};
 switch (*byte_size) {
@@ -777,7 +777,7 @@
 CompilerType elem_type;
 if (m_type.IsHomogeneousAggregate(_type)) {
   uint32_t type_flags = elem_type.GetTypeInfo();
-  llvm::Optional elem_size = elem_type.GetByteSize(thread);
+  llvm::Optional elem_size = elem_type.GetByteSize();
   if (!elem_size)
 return {};
   if (type_flags & eTypeIsComplex || !(type_flags & eTypeIsFloat)) {
Index: lldb/source/Plugins/ABI/PowerPC/ABISysV_ppc.cpp
===
--- lldb/source/Plugins/ABI/PowerPC/ABISysV_ppc.cpp
+++ lldb/source/Plugins/ABI/PowerPC/ABISysV_ppc.cpp
@@ -527,7 +527,7 @@
   // Extract the register context so we can read arguments from registers
 
   llvm::Optional byte_size =
-  return_compiler_type.GetByteSize(thread);
+  return_compiler_type.GetByteSize();
   if (!byte_size)
 return return_valobj_sp;
   uint64_t raw_value = thread.GetRegisterContext()->ReadRegisterAsUnsigned(
@@ -574,7 +574,7 @@
 // Don't handle complex yet.
   } else {
 llvm::Optional byte_size =
-return_compiler_type.GetByteSize(thread);
+return_compiler_type.GetByteSize();
 if (byte_size && *byte_size <= sizeof(long double)) {
   const RegisterInfo *f1_info = reg_ctx->GetRegisterInfoByName("f1", 0);
   RegisterValue f1_value;
@@ -608,7 +608,7 @@
 thread.GetStackFrameAtIndex(0).get(), value, ConstString(""));
   } else if (type_flags & eTypeIsVector) {
 llvm::Optional byte_size =
-return_compiler_type.GetByteSize(thread);
+return_compiler_type.GetByteSize();
 if (byte_size && *byte_size > 0) {
   const RegisterInfo *altivec_reg = reg_ctx->GetRegisterInfoByName("v2", 0);
   if (altivec_reg) {
Index: lldb/source/Plugins/ABI/Mips/ABISysV_mips64.cpp
===
--- lldb/source/Plugins/ABI/Mips/ABISysV_mips64.cpp
+++ lldb/source/Plugins/ABI/Mips/ABISysV_mips64.cpp
@@ -753,7 +753,7 @@
   const ArchSpec target_arch = target->GetArchitecture();
   ByteOrder target_byte_order = target_arch.GetByteOrder();
   llvm::Optional byte_size =
-  return_compiler_type.GetByteSize(thread);
+  return_compiler_type.GetByteSize();
   if (!byte_size)
 return return_valobj_sp;
   const uint32_t type_flags = return_compiler_type.GetTypeInfo(nullptr);
@@ -962,7 +962,7 @@
 return_compiler_type.GetFieldAtIndex(
 

[Lldb-commits] [PATCH] D84267: Thread ExecutionContextScope through GetByteSize where possible (NFC-ish)

2020-07-21 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor added inline comments.



Comment at: lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp:4092
 TypeSystemClang::GetArrayElementType(lldb::opaque_compiler_type_t type,
- uint64_t *stride) {
   if (type) {

So we already have this dubious stride extra-output here, but now it also 
requires us to have an execution context parameter. I think we might as well 
just remove that parameter (in a separate patch).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84267



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


[Lldb-commits] [PATCH] D84263: [debugserver/Apple Silicon] Handoff connections when attaching to translated processes

2020-07-21 Thread Jason Molenda via Phabricator via lldb-commits
jasonmolenda added a comment.

With this patch, debugging a translated app will only work when we invoke 
debugserver with --fd for its communication back to lldb.  e.g. running 
'debugserver localhost:2000 --attach=translated-app' will pass -fd=-1 as a 
command line argument to /Library/Apple/usr/libexec/oah/debugserver.  Doing 
this properly would involve passing the same hostspec:portnum that debugserver 
received in this case -- but could we at least error out in DNBProcessAttach if 
communcation_fd==-1 so it's clear that this is not yet a supported workflow?


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

https://reviews.llvm.org/D84263



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


[Lldb-commits] [PATCH] D84267: Thread ExecutionContextScope through GetByteSize where possible (NFC-ish)

2020-07-21 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor added inline comments.



Comment at: lldb/source/Plugins/ABI/ARC/ABISysV_arc.cpp:461
   if (type_flags & eTypeIsInteger) {
-const size_t byte_size = compiler_type.GetByteSize(nullptr).getValueOr(0);
+const size_t byte_size = compiler_type.GetByteSize(thread).getValueOr(0);
 auto raw_value = ReadRawValue(reg_ctx, byte_size);

shafik wrote:
> Above you use `` in `return_compiler_type.GetByteSize()` ... 
> why do both of these work? 
This doesn't compile (but ARC isn't a default target, so probably no one 
compiled that code).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84267



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


[Lldb-commits] [PATCH] D84267: Thread ExecutionContextScope through GetByteSize where possible (NFC-ish)

2020-07-21 Thread Shafik Yaghmour via Phabricator via lldb-commits
shafik added inline comments.



Comment at: lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp:308
   lldb::TargetSP target_sp(m_execution_unit.GetTarget());
-  lldb_private::ExecutionContext exe_ctx(target_sp, true);
-  llvm::Optional bit_size =
-  m_result_type.GetBitSize(exe_ctx.GetBestExecutionContextScope());
+  llvm::Optional bit_size = 
m_result_type.GetBitSize(target_sp.get());
   if (!bit_size) {

Is this equivalent to what was being done previously or is this better in some 
way?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84267



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


[Lldb-commits] [PATCH] D84267: Thread ExecutionContextScope through GetByteSize where possible (NFC-ish)

2020-07-21 Thread Shafik Yaghmour via Phabricator via lldb-commits
shafik added inline comments.



Comment at: lldb/source/Plugins/ABI/ARC/ABISysV_arc.cpp:461
   if (type_flags & eTypeIsInteger) {
-const size_t byte_size = compiler_type.GetByteSize(nullptr).getValueOr(0);
+const size_t byte_size = compiler_type.GetByteSize(thread).getValueOr(0);
 auto raw_value = ReadRawValue(reg_ctx, byte_size);

Above you use `` in `return_compiler_type.GetByteSize()` ... why 
do both of these work? 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84267



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


[Lldb-commits] [PATCH] D84269: [lldb] Add some example type anotations to python.swig

2020-07-21 Thread Nathan Lanza via Phabricator via lldb-commits
lanza created this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

Python3.5 (3.4?) added type annotations to the python language. This
lets tools such as LSPs provide useful IDE-like completion when writing
python.

Add type annotations throughout the python swig API would make writing
lldb python tooling much more approachable for users. This diff is a
first demonstration of the idea.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D84269

Files:
  lldb/bindings/python.swig


Index: lldb/bindings/python.swig
===
--- lldb/bindings/python.swig
+++ lldb/bindings/python.swig
@@ -137,9 +137,9 @@
 debugger_unique_id = 0
 if _initialize:
SBDebugger.Initialize()
-debugger = None
-target = None
-process = None
-thread = None
-frame = None
+debugger: lldb.SBDebugger = None
+target: lldb.SBTarget = None
+process: lldb.SBProcess = None
+thread: lldb.SBThread = None
+frame: lldb.SBFrame = None
 %}


Index: lldb/bindings/python.swig
===
--- lldb/bindings/python.swig
+++ lldb/bindings/python.swig
@@ -137,9 +137,9 @@
 debugger_unique_id = 0
 if _initialize:
SBDebugger.Initialize()
-debugger = None
-target = None
-process = None
-thread = None
-frame = None
+debugger: lldb.SBDebugger = None
+target: lldb.SBTarget = None
+process: lldb.SBProcess = None
+thread: lldb.SBThread = None
+frame: lldb.SBFrame = None
 %}
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D84267: Thread ExecutionContextScope through GetByteSize where possible (NFC-ish)

2020-07-21 Thread Adrian Prantl via Phabricator via lldb-commits
aprantl created this revision.
aprantl added reviewers: jingham, shafik.
Herald added subscribers: atanasyan, jrtc27, kbarton, nemanjai, sdardis.
Herald added a project: LLDB.

This patch has no effect for C and C++. In more dynamic languages, such as 
Objective-C and Swift GetByteSize() needs to call into the language runtime, so 
it's important to pass one in where possible. My primary motivation for this is 
some work I'm doing on the Swift branch, however, it looks like we are also 
seeing warnings in Objective-C that this may resolve.
Everything in the SymbolFile hierarchy still passes in nullptrs, because we 
don't have an execution context in SymbolFile, since SymbolFile transcends 
processes.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D84267

Files:
  lldb/include/lldb/Symbol/CompilerType.h
  lldb/include/lldb/Symbol/Type.h
  lldb/include/lldb/Symbol/TypeSystem.h
  lldb/source/API/SBType.cpp
  lldb/source/Commands/CommandObjectTarget.cpp
  lldb/source/Core/Value.cpp
  lldb/source/Core/ValueObjectMemory.cpp
  lldb/source/DataFormatters/FormatManager.cpp
  lldb/source/Expression/Materializer.cpp
  lldb/source/Plugins/ABI/AArch64/ABIMacOSX_arm64.cpp
  lldb/source/Plugins/ABI/AArch64/ABISysV_arm64.cpp
  lldb/source/Plugins/ABI/ARC/ABISysV_arc.cpp
  lldb/source/Plugins/ABI/ARM/ABISysV_arm.cpp
  lldb/source/Plugins/ABI/Mips/ABISysV_mips64.cpp
  lldb/source/Plugins/ABI/PowerPC/ABISysV_ppc.cpp
  lldb/source/Plugins/ABI/PowerPC/ABISysV_ppc64.cpp
  lldb/source/Plugins/ABI/SystemZ/ABISysV_s390x.cpp
  lldb/source/Plugins/ABI/X86/ABISysV_i386.cpp
  lldb/source/Plugins/ABI/X86/ABISysV_x86_64.cpp
  lldb/source/Plugins/ABI/X86/ABIWindows_x86_64.cpp
  lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
  lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp
  lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
  lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
  lldb/source/Symbol/CompilerType.cpp
  lldb/source/Symbol/SymbolContext.cpp
  lldb/source/Symbol/Type.cpp

Index: lldb/source/Symbol/Type.cpp
===
--- lldb/source/Symbol/Type.cpp
+++ lldb/source/Symbol/Type.cpp
@@ -170,7 +170,7 @@
 }
 
 void Type::GetDescription(Stream *s, lldb::DescriptionLevel level,
-  bool show_name) {
+  bool show_name, ExecutionContextScope *exe_scope) {
   *s << "id = " << (const UserID &)*this;
 
   // Call the name accessor to make sure we resolve the type name
@@ -186,7 +186,7 @@
   }
 
   // Call the get byte size accesor so we resolve our byte size
-  if (GetByteSize())
+  if (GetByteSize(exe_scope))
 s->Printf(", byte-size = %" PRIu64, m_byte_size);
   bool show_fullpaths = (level == lldb::eDescriptionLevelVerbose);
   m_decl.Dump(s, show_fullpaths);
@@ -323,7 +323,9 @@
 
 GetForwardCompilerType().DumpValue(
 exe_ctx, s, format == lldb::eFormatDefault ? GetFormat() : format, data,
-data_byte_offset, GetByteSize().getValueOr(0),
+data_byte_offset,
+GetByteSize(exe_ctx ? exe_ctx->GetBestExecutionContextScope() : nullptr)
+.getValueOr(0),
 0, // Bitfield bit size
 0, // Bitfield bit offset
 show_types, show_summary, verbose, 0);
@@ -336,7 +338,7 @@
   return m_encoding_type;
 }
 
-llvm::Optional Type::GetByteSize() {
+llvm::Optional Type::GetByteSize(ExecutionContextScope *exe_scope) {
   if (m_byte_size_has_value)
 return m_byte_size;
 
@@ -352,14 +354,14 @@
   case eEncodingIsTypedefUID: {
 Type *encoding_type = GetEncodingType();
 if (encoding_type)
-  if (llvm::Optional size = encoding_type->GetByteSize()) {
+  if (llvm::Optional size = encoding_type->GetByteSize(exe_scope)) {
 m_byte_size = *size;
 m_byte_size_has_value = true;
 return m_byte_size;
   }
 
 if (llvm::Optional size =
-GetLayoutCompilerType().GetByteSize(nullptr)) {
+GetLayoutCompilerType().GetByteSize(exe_scope)) {
   m_byte_size = *size;
   m_byte_size_has_value = true;
 return m_byte_size;
@@ -430,7 +432,9 @@
 return false;
   }
 
-  const uint64_t byte_size = GetByteSize().getValueOr(0);
+  const uint64_t byte_size =
+  GetByteSize(exe_ctx ? exe_ctx->GetBestExecutionContextScope() : nullptr)
+  .getValueOr(0);
   if (data.GetByteSize() < byte_size) {
 lldb::DataBufferSP data_sp(new DataBufferHeap(byte_size, '\0'));
 data.SetData(data_sp);
Index: lldb/source/Symbol/SymbolContext.cpp
===
--- lldb/source/Symbol/SymbolContext.cpp
+++ lldb/source/Symbol/SymbolContext.cpp
@@ -204,7 +204,7 @@
 Type *func_type = function->GetType();
 if (func_type) {
   s->Indent("   FuncType: ");
-  func_type->GetDescription(s, level, 

[Lldb-commits] [PATCH] D84263: [debugserver/Apple Silicon] Handoff connections when attaching to translated processes

2020-07-21 Thread Davide Italiano via Phabricator via lldb-commits
davide created this revision.
davide added a reviewer: jasonmolenda.

When we detect a process that the native debugserver cannot handle, handoff the 
connection fd to the translated debugserver.


https://reviews.llvm.org/D84263

Files:
  lldb/tools/debugserver/source/DNB.cpp
  lldb/tools/debugserver/source/debugserver.cpp


Index: lldb/tools/debugserver/source/debugserver.cpp
===
--- lldb/tools/debugserver/source/debugserver.cpp
+++ lldb/tools/debugserver/source/debugserver.cpp
@@ -878,6 +878,8 @@
// -F localhost:1234 -- /bin/ls"
 {NULL, 0, NULL, 0}};
 
+int communication_fd = -1;
+
 // main
 int main(int argc, char *argv[]) {
   // If debugserver is launched with DYLD_INSERT_LIBRARIES, unset it so we
@@ -944,7 +946,6 @@
   int ch;
   int long_option_index = 0;
   int debug = 0;
-  int communication_fd = -1;
   std::string compile_options;
   std::string waitfor_pid_name; // Wait for a process that starts with this 
name
   std::string attach_pid_name;
Index: lldb/tools/debugserver/source/DNB.cpp
===
--- lldb/tools/debugserver/source/DNB.cpp
+++ lldb/tools/debugserver/source/DNB.cpp
@@ -442,6 +442,33 @@
   if (err_str && err_len > 0)
 err_str[0] = '\0';
 
+  if (getenv("LLDB_DEBUGSERVER_PATH") == NULL) {
+int mib[] = {CTL_KERN, KERN_PROC, KERN_PROC_PID,
+ static_cast(attach_pid)};
+struct kinfo_proc processInfo;
+size_t bufsize = sizeof(processInfo);
+if (sysctl(mib, (unsigned)(sizeof(mib) / sizeof(int)), ,
+   , NULL, 0) == 0 &&
+bufsize > 0) {
+
+  if ((processInfo.kp_proc.p_flag & P_TRANSLATED) == P_TRANSLATED) {
+const char *translated_debugserver =
+"/Library/Apple/usr/libexec/oah/debugserver";
+char fdstr[16];
+char pidstr[16];
+extern int communication_fd;
+
+snprintf(fdstr, sizeof(fdstr), "--fd=%d", communication_fd);
+snprintf(pidstr, sizeof(pidstr), "--attach=%d", attach_pid);
+execl(translated_debugserver, "--native-regs", "--setsid", fdstr,
+  "--handoff-attach-from-native", pidstr, (char *)0);
+DNBLogThreadedIf(LOG_PROCESS, "Failed to launch debugserver for "
+ "translated process: ", errno, strerror(errno));
+__builtin_trap();
+  }
+}
+  }
+
   pid_t pid = INVALID_NUB_PROCESS;
   MachProcessSP processSP(new MachProcess);
   if (processSP.get()) {


Index: lldb/tools/debugserver/source/debugserver.cpp
===
--- lldb/tools/debugserver/source/debugserver.cpp
+++ lldb/tools/debugserver/source/debugserver.cpp
@@ -878,6 +878,8 @@
// -F localhost:1234 -- /bin/ls"
 {NULL, 0, NULL, 0}};
 
+int communication_fd = -1;
+
 // main
 int main(int argc, char *argv[]) {
   // If debugserver is launched with DYLD_INSERT_LIBRARIES, unset it so we
@@ -944,7 +946,6 @@
   int ch;
   int long_option_index = 0;
   int debug = 0;
-  int communication_fd = -1;
   std::string compile_options;
   std::string waitfor_pid_name; // Wait for a process that starts with this name
   std::string attach_pid_name;
Index: lldb/tools/debugserver/source/DNB.cpp
===
--- lldb/tools/debugserver/source/DNB.cpp
+++ lldb/tools/debugserver/source/DNB.cpp
@@ -442,6 +442,33 @@
   if (err_str && err_len > 0)
 err_str[0] = '\0';
 
+  if (getenv("LLDB_DEBUGSERVER_PATH") == NULL) {
+int mib[] = {CTL_KERN, KERN_PROC, KERN_PROC_PID,
+ static_cast(attach_pid)};
+struct kinfo_proc processInfo;
+size_t bufsize = sizeof(processInfo);
+if (sysctl(mib, (unsigned)(sizeof(mib) / sizeof(int)), ,
+   , NULL, 0) == 0 &&
+bufsize > 0) {
+
+  if ((processInfo.kp_proc.p_flag & P_TRANSLATED) == P_TRANSLATED) {
+const char *translated_debugserver =
+"/Library/Apple/usr/libexec/oah/debugserver";
+char fdstr[16];
+char pidstr[16];
+extern int communication_fd;
+
+snprintf(fdstr, sizeof(fdstr), "--fd=%d", communication_fd);
+snprintf(pidstr, sizeof(pidstr), "--attach=%d", attach_pid);
+execl(translated_debugserver, "--native-regs", "--setsid", fdstr,
+  "--handoff-attach-from-native", pidstr, (char *)0);
+DNBLogThreadedIf(LOG_PROCESS, "Failed to launch debugserver for "
+ "translated process: ", errno, strerror(errno));
+__builtin_trap();
+  }
+}
+  }
+
   pid_t pid = INVALID_NUB_PROCESS;
   MachProcessSP processSP(new MachProcess);
   if (processSP.get()) {
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D84257: [lldb] Don't use hardware index to determine whether a breakpoint site is hardware

2020-07-21 Thread Tatyana Krasnukha via Phabricator via lldb-commits
tatyana-krasnukha added a comment.

Probably fixes llvm.org/PR44659, though I cannot check on arm/aarch64.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84257



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


Re: [Lldb-commits] [lldb] cd05406 - [testsuite] Adapt lldb-server base test helper to run on arm64

2020-07-21 Thread Davidino Italiano via lldb-commits


> On Jul 21, 2020, at 5:17 AM, Pavel Labath  wrote:
> 
> On 20/07/2020 23:38, Davide Italiano via lldb-commits wrote:
>> @@ -1601,8 +1601,18 @@ def single_step_only_steps_one_instruction(
>> # variable value
>> if re.match("s390x", arch):
>> expected_step_count = 2
>> +# ARM64 requires "4" instructions: 2 to compute the address (adrp, 
>> add),
>> +# one to materialize the constant (mov) and the store
>> +if re.match("arm64", arch):
>> +expected_step_count = 4
>> +
>> self.assertEqual(step_count, expected_step_count)
>> 
>> +# ARM64: Once addresses and constants are materialized, only one
>> +# instruction is needed.
>> +if re.match("arm64", arch):
>> +expected_step_count = 1
>> +
>> # Verify we hit the next state.
>> args["expected_g_c1"] = "0"
>> args["expected_g_c2"] = "0"
>> 
> 
> I have a feeling this was racing with aa73ee052f -- [lldb/test] Use
> inline assembly for instruction counting tests.
> 
> There should be no need for magic step counts after that patch. (If
> there is, I'd like to know why.)
> 
> pl

Interesting. I’ll try on my device and see whether we can revert this.
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


Re: [Lldb-commits] [lldb] 62ccfb6 - [LLDB] Fix Arm/AArch64 Linux broken build

2020-07-21 Thread Davidino Italiano via lldb-commits


> On Jul 21, 2020, at 1:47 AM, Muhammad Omair Javaid via lldb-commits 
>  wrote:
> 
> 
> Author: Muhammad Omair Javaid
> Date: 2020-07-21T13:46:39+05:00
> New Revision: 62ccfb6ed0bed899f22abc00bec96a372420c5d0
> 
> URL: 
> https://github.com/llvm/llvm-project/commit/62ccfb6ed0bed899f22abc00bec96a372420c5d0
> DIFF: 
> https://github.com/llvm/llvm-project/commit/62ccfb6ed0bed899f22abc00bec96a372420c5d0.diff
> 
> LOG: [LLDB] Fix Arm/AArch64 Linux broken build
> 
> This patch fixes build breakage on LLDB Arm/AArch64 Linux buildbots.
> 
> http://lab.llvm.org:8011/builders/lldb-aarch64-ubuntu/builds/6649
> http://lab.llvm.org:8011/builders/lldb-arm-ubuntu/builds/1919
> 
> This build breakage was introduces by commit: 
> 001c8e1fd9f09d3de9ff6e64bdac4b8ca681dfb4
> 
> Added: 
> 
> 
> Modified: 
>lldb/source/Plugins/Platform/MacOSX/PlatformMacOSX.h
> 
> Removed: 
> 
> 
> 
> 
> diff  --git a/lldb/source/Plugins/Platform/MacOSX/PlatformMacOSX.h 
> b/lldb/source/Plugins/Platform/MacOSX/PlatformMacOSX.h
> index 30b11eb37684..3e9a0b3aab90 100644
> --- a/lldb/source/Plugins/Platform/MacOSX/PlatformMacOSX.h
> +++ b/lldb/source/Plugins/Platform/MacOSX/PlatformMacOSX.h
> @@ -79,6 +79,10 @@ class PlatformMacOSX : public PlatformDarwin {
> private:
>   PlatformMacOSX(const PlatformMacOSX &) = delete;
>   const PlatformMacOSX =(const PlatformMacOSX &) = delete;
> +
> +#if defined(__arm__) || defined(__arm64__) || defined(__aarch64__)
> +  uint32_t m_num_arm_arches = 0;
> +#endif
> };

Uh, I think this is wrong. Let me take a look.

—
Davide

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

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


[Lldb-commits] [PATCH] D84253: OptionValue::Clear should return void not bool

2020-07-21 Thread Jim Ingham via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG8d6aa688eeff: Remove the bool return from 
OptionValue::Clear and its subclasses. (authored by jingham).

Changed prior to commit:
  https://reviews.llvm.org/D84253?vs=279580=279594#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84253

Files:
  lldb/include/lldb/Interpreter/OptionValue.h
  lldb/include/lldb/Interpreter/OptionValueArch.h
  lldb/include/lldb/Interpreter/OptionValueArray.h
  lldb/include/lldb/Interpreter/OptionValueBoolean.h
  lldb/include/lldb/Interpreter/OptionValueChar.h
  lldb/include/lldb/Interpreter/OptionValueDictionary.h
  lldb/include/lldb/Interpreter/OptionValueEnumeration.h
  lldb/include/lldb/Interpreter/OptionValueFileColonLine.h
  lldb/include/lldb/Interpreter/OptionValueFileSpec.h
  lldb/include/lldb/Interpreter/OptionValueFileSpecList.h
  lldb/include/lldb/Interpreter/OptionValueFormat.h
  lldb/include/lldb/Interpreter/OptionValueFormatEntity.h
  lldb/include/lldb/Interpreter/OptionValueLanguage.h
  lldb/include/lldb/Interpreter/OptionValuePathMappings.h
  lldb/include/lldb/Interpreter/OptionValueProperties.h
  lldb/include/lldb/Interpreter/OptionValueRegex.h
  lldb/include/lldb/Interpreter/OptionValueSInt64.h
  lldb/include/lldb/Interpreter/OptionValueString.h
  lldb/include/lldb/Interpreter/OptionValueUInt64.h
  lldb/include/lldb/Interpreter/OptionValueUUID.h
  lldb/source/Interpreter/OptionValueFormatEntity.cpp
  lldb/source/Interpreter/OptionValueProperties.cpp

Index: lldb/source/Interpreter/OptionValueProperties.cpp
===
--- lldb/source/Interpreter/OptionValueProperties.cpp
+++ lldb/source/Interpreter/OptionValueProperties.cpp
@@ -517,11 +517,10 @@
   return false;
 }
 
-bool OptionValueProperties::Clear() {
+void OptionValueProperties::Clear() {
   const size_t num_properties = m_properties.size();
   for (size_t i = 0; i < num_properties; ++i)
 m_properties[i].GetValue()->Clear();
-  return true;
 }
 
 Status OptionValueProperties::SetValueFromString(llvm::StringRef value,
Index: lldb/source/Interpreter/OptionValueFormatEntity.cpp
===
--- lldb/source/Interpreter/OptionValueFormatEntity.cpp
+++ lldb/source/Interpreter/OptionValueFormatEntity.cpp
@@ -29,11 +29,10 @@
   }
 }
 
-bool OptionValueFormatEntity::Clear() {
+void OptionValueFormatEntity::Clear() {
   m_current_entry = m_default_entry;
   m_current_format = m_default_format;
   m_value_was_set = false;
-  return true;
 }
 
 static void EscapeBackticks(llvm::StringRef str, std::string ) {
Index: lldb/include/lldb/Interpreter/OptionValueUUID.h
===
--- lldb/include/lldb/Interpreter/OptionValueUUID.h
+++ lldb/include/lldb/Interpreter/OptionValueUUID.h
@@ -36,10 +36,9 @@
   SetValueFromString(const char *,
  VarSetOperationType = eVarSetOperationAssign) = delete;
 
-  bool Clear() override {
+  void Clear() override {
 m_uuid.Clear();
 m_value_was_set = false;
-return true;
   }
 
   lldb::OptionValueSP DeepCopy() const override;
Index: lldb/include/lldb/Interpreter/OptionValueUInt64.h
===
--- lldb/include/lldb/Interpreter/OptionValueUInt64.h
+++ lldb/include/lldb/Interpreter/OptionValueUInt64.h
@@ -47,10 +47,9 @@
   SetValueFromString(const char *,
  VarSetOperationType = eVarSetOperationAssign) = delete;
 
-  bool Clear() override {
+  void Clear() override {
 m_current_value = m_default_value;
 m_value_was_set = false;
-return true;
   }
 
   lldb::OptionValueSP DeepCopy() const override;
Index: lldb/include/lldb/Interpreter/OptionValueString.h
===
--- lldb/include/lldb/Interpreter/OptionValueString.h
+++ lldb/include/lldb/Interpreter/OptionValueString.h
@@ -85,10 +85,9 @@
   SetValueFromString(const char *,
  VarSetOperationType = eVarSetOperationAssign) = delete;
 
-  bool Clear() override {
+  void Clear() override {
 m_current_value = m_default_value;
 m_value_was_set = false;
-return true;
   }
 
   lldb::OptionValueSP DeepCopy() const override;
Index: lldb/include/lldb/Interpreter/OptionValueSInt64.h
===
--- lldb/include/lldb/Interpreter/OptionValueSInt64.h
+++ lldb/include/lldb/Interpreter/OptionValueSInt64.h
@@ -50,10 +50,9 @@
   SetValueFromString(const char *,
  VarSetOperationType = eVarSetOperationAssign) = delete;
 
-  bool Clear() override {
+  void Clear() override {
 m_current_value = m_default_value;
 m_value_was_set = false;
-return true;
   }
 
   lldb::OptionValueSP DeepCopy() const override;
Index: 

[Lldb-commits] [lldb] 8d6aa68 - Remove the "bool" return from OptionValue::Clear and its subclasses.

2020-07-21 Thread Jim Ingham via lldb-commits

Author: Jim Ingham
Date: 2020-07-21T11:32:55-07:00
New Revision: 8d6aa688eeffea4b9151d1a208ed619ca50c823a

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

LOG: Remove the "bool" return from OptionValue::Clear and its subclasses.

Every override returns true and its return value is never checked.  I can't
see how clearing an OptionValue could fail, or what you would
do if it did.  The return serves no purpose.

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

Added: 


Modified: 
lldb/include/lldb/Interpreter/OptionValue.h
lldb/include/lldb/Interpreter/OptionValueArch.h
lldb/include/lldb/Interpreter/OptionValueArray.h
lldb/include/lldb/Interpreter/OptionValueBoolean.h
lldb/include/lldb/Interpreter/OptionValueChar.h
lldb/include/lldb/Interpreter/OptionValueDictionary.h
lldb/include/lldb/Interpreter/OptionValueEnumeration.h
lldb/include/lldb/Interpreter/OptionValueFileColonLine.h
lldb/include/lldb/Interpreter/OptionValueFileSpec.h
lldb/include/lldb/Interpreter/OptionValueFileSpecList.h
lldb/include/lldb/Interpreter/OptionValueFormat.h
lldb/include/lldb/Interpreter/OptionValueFormatEntity.h
lldb/include/lldb/Interpreter/OptionValueLanguage.h
lldb/include/lldb/Interpreter/OptionValuePathMappings.h
lldb/include/lldb/Interpreter/OptionValueProperties.h
lldb/include/lldb/Interpreter/OptionValueRegex.h
lldb/include/lldb/Interpreter/OptionValueSInt64.h
lldb/include/lldb/Interpreter/OptionValueString.h
lldb/include/lldb/Interpreter/OptionValueUInt64.h
lldb/include/lldb/Interpreter/OptionValueUUID.h
lldb/source/Interpreter/OptionValueFormatEntity.cpp
lldb/source/Interpreter/OptionValueProperties.cpp

Removed: 




diff  --git a/lldb/include/lldb/Interpreter/OptionValue.h 
b/lldb/include/lldb/Interpreter/OptionValue.h
index 27a5ddea116b..a8176e39940a 100644
--- a/lldb/include/lldb/Interpreter/OptionValue.h
+++ b/lldb/include/lldb/Interpreter/OptionValue.h
@@ -85,7 +85,7 @@ class OptionValue {
   SetValueFromString(llvm::StringRef value,
  VarSetOperationType op = eVarSetOperationAssign);
 
-  virtual bool Clear() = 0;
+  virtual void Clear() = 0;
 
   virtual lldb::OptionValueSP DeepCopy() const = 0;
 

diff  --git a/lldb/include/lldb/Interpreter/OptionValueArch.h 
b/lldb/include/lldb/Interpreter/OptionValueArch.h
index 7b63c68fddbf..809261ef22c3 100644
--- a/lldb/include/lldb/Interpreter/OptionValueArch.h
+++ b/lldb/include/lldb/Interpreter/OptionValueArch.h
@@ -47,10 +47,9 @@ class OptionValueArch : public OptionValue {
   SetValueFromString(const char *,
  VarSetOperationType = eVarSetOperationAssign) = delete;
 
-  bool Clear() override {
+  void Clear() override {
 m_current_value = m_default_value;
 m_value_was_set = false;
-return true;
   }
 
   lldb::OptionValueSP DeepCopy() const override;

diff  --git a/lldb/include/lldb/Interpreter/OptionValueArray.h 
b/lldb/include/lldb/Interpreter/OptionValueArray.h
index 000351c2f586..4546bbb80394 100644
--- a/lldb/include/lldb/Interpreter/OptionValueArray.h
+++ b/lldb/include/lldb/Interpreter/OptionValueArray.h
@@ -36,10 +36,9 @@ class OptionValueArray : public OptionValue {
   SetValueFromString(const char *,
  VarSetOperationType = eVarSetOperationAssign) = delete;
 
-  bool Clear() override {
+  void Clear() override {
 m_values.clear();
 m_value_was_set = false;
-return true;
   }
 
   lldb::OptionValueSP DeepCopy() const override;

diff  --git a/lldb/include/lldb/Interpreter/OptionValueBoolean.h 
b/lldb/include/lldb/Interpreter/OptionValueBoolean.h
index d221f6d034c2..1af14a4980ed 100644
--- a/lldb/include/lldb/Interpreter/OptionValueBoolean.h
+++ b/lldb/include/lldb/Interpreter/OptionValueBoolean.h
@@ -37,10 +37,9 @@ class OptionValueBoolean : public OptionValue {
   SetValueFromString(const char *,
  VarSetOperationType = eVarSetOperationAssign) = delete;
 
-  bool Clear() override {
+  void Clear() override {
 m_current_value = m_default_value;
 m_value_was_set = false;
-return true;
   }
 
   void AutoComplete(CommandInterpreter ,

diff  --git a/lldb/include/lldb/Interpreter/OptionValueChar.h 
b/lldb/include/lldb/Interpreter/OptionValueChar.h
index 8d0aa91d7076..a8ecf507a4cf 100644
--- a/lldb/include/lldb/Interpreter/OptionValueChar.h
+++ b/lldb/include/lldb/Interpreter/OptionValueChar.h
@@ -38,10 +38,9 @@ class OptionValueChar : public OptionValue {
   SetValueFromString(const char *,
  VarSetOperationType = eVarSetOperationAssign) = delete;
 
-  bool Clear() override {
+  void Clear() override {
 m_current_value = m_default_value;
 m_value_was_set = false;
-return true;
   }
 
   // Subclass 

[Lldb-commits] [lldb] 46334df - [lldb/test] Skip test in TestBitfieldIvars.py instead of xfailing it

2020-07-21 Thread Vedant Kumar via lldb-commits

Author: Vedant Kumar
Date: 2020-07-21T11:29:09-07:00
New Revision: 46334dfc3ba99ee5300675f8300b9044e350f2ff

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

LOG: [lldb/test] Skip test in TestBitfieldIvars.py instead of xfailing it

The test triggers an ASan exception, causing job failures on the
sanitizer bot.

As suggested by Shafik.

Added: 


Modified: 
lldb/test/API/lang/objc/bitfield_ivars/TestBitfieldIvars.py

Removed: 




diff  --git a/lldb/test/API/lang/objc/bitfield_ivars/TestBitfieldIvars.py 
b/lldb/test/API/lang/objc/bitfield_ivars/TestBitfieldIvars.py
index 0cc3cef76ea1..611885413102 100644
--- a/lldb/test/API/lang/objc/bitfield_ivars/TestBitfieldIvars.py
+++ b/lldb/test/API/lang/objc/bitfield_ivars/TestBitfieldIvars.py
@@ -27,7 +27,9 @@ def test(self):
  'field2 =', '3',
  'field3 =', '4'])
 
-@expectedFailureAll()
+# This test is meant to be xfailed, but running the test triggers an ASan
+# issue, so it must be skipped for now.
+@skipIf
 def testExprWholeObject(self):
 self.build()
 lldbutil.run_to_source_breakpoint(self, "// break here", 
lldb.SBFileSpec("main.m"))



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


[Lldb-commits] [PATCH] D84257: [lldb] Don't use hardware index to determine whether a breakpoint site is hardware

2020-07-21 Thread Tatyana Krasnukha via Phabricator via lldb-commits
tatyana-krasnukha created this revision.
tatyana-krasnukha added reviewers: clayborg, labath, JDevlieghere.
tatyana-krasnukha added a project: LLDB.
Herald added subscribers: lldb-commits, arphaman.

Most process plugins (if not all) don't set hardware index for breakpoints. 
They even are not able to determine this index.
This patch makes StoppointLocation::IsHardware pure virtual and lets 
BreakpointSite override it using more accurate BreakpointSite::Type.

It also adds assertions to be sure that a breakpoint site is hardware when this 
is required.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D84257

Files:
  lldb/include/lldb/Breakpoint/BreakpointLocation.h
  lldb/include/lldb/Breakpoint/BreakpointSite.h
  lldb/include/lldb/Breakpoint/StoppointLocation.h
  lldb/source/Breakpoint/BreakpointLocation.cpp
  lldb/source/Breakpoint/Watchpoint.cpp
  lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp

Index: lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
===
--- lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
+++ lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
@@ -3205,14 +3205,8 @@
   break;
 
 case BreakpointSite::eExternal: {
-  GDBStoppointType stoppoint_type;
-  if (bp_site->IsHardware())
-stoppoint_type = eBreakpointHardware;
-  else
-stoppoint_type = eBreakpointSoftware;
-
-  if (m_gdb_comm.SendGDBStoppointTypePacket(stoppoint_type, false, addr,
-bp_op_size))
+  if (m_gdb_comm.SendGDBStoppointTypePacket(eBreakpointSoftware, false,
+addr, bp_op_size))
 error.SetErrorToGenericError();
 } break;
 }
Index: lldb/source/Breakpoint/Watchpoint.cpp
===
--- lldb/source/Breakpoint/Watchpoint.cpp
+++ lldb/source/Breakpoint/Watchpoint.cpp
@@ -95,7 +95,10 @@
 
 // Override default impl of StoppointLocation::IsHardware() since m_is_hardware
 // member field is more accurate.
-bool Watchpoint::IsHardware() const { return m_is_hardware; }
+bool Watchpoint::IsHardware() const {
+  lldbassert(m_is_hardware || !HardwareRequired());
+  return m_is_hardware;
+}
 
 bool Watchpoint::IsWatchVariable() const { return m_is_watch_variable; }
 
Index: lldb/source/Breakpoint/BreakpointLocation.cpp
===
--- lldb/source/Breakpoint/BreakpointLocation.cpp
+++ lldb/source/Breakpoint/BreakpointLocation.cpp
@@ -68,6 +68,14 @@
 
 Target ::GetTarget() { return m_owner.GetTarget(); }
 
+bool BreakpointLocation::IsHardware() const {
+  if (m_bp_site_sp)
+return m_bp_site_sp->IsHardware();
+
+  // If breakpoint location is not resolved yet, it cannot be hardware.
+  return false;
+}
+
 bool BreakpointLocation::IsEnabled() const {
   if (!m_owner.IsEnabled())
 return false;
Index: lldb/include/lldb/Breakpoint/StoppointLocation.h
===
--- lldb/include/lldb/Breakpoint/StoppointLocation.h
+++ lldb/include/lldb/Breakpoint/StoppointLocation.h
@@ -40,9 +40,7 @@
 
   bool HardwareRequired() const { return m_hardware; }
 
-  virtual bool IsHardware() const {
-return m_hardware_index != LLDB_INVALID_INDEX32;
-  }
+  virtual bool IsHardware() const = 0;
 
   virtual bool ShouldStop(StoppointCallbackContext *context) { return true; }
 
Index: lldb/include/lldb/Breakpoint/BreakpointSite.h
===
--- lldb/include/lldb/Breakpoint/BreakpointSite.h
+++ lldb/include/lldb/Breakpoint/BreakpointSite.h
@@ -15,6 +15,7 @@
 
 #include "lldb/Breakpoint/BreakpointLocationCollection.h"
 #include "lldb/Breakpoint/StoppointLocation.h"
+#include "lldb/Utility/LLDBAssert.h"
 #include "lldb/Utility/UserID.h"
 #include "lldb/lldb-forward.h"
 
@@ -184,6 +185,12 @@
   /// \b false otherwise.
   bool IsInternal() const;
 
+  bool IsHardware() const override {
+lldbassert(BreakpointSite::Type::eHardware == GetType() ||
+   !HardwareRequired());
+return BreakpointSite::Type::eHardware == GetType();
+  }
+
   BreakpointSite::Type GetType() const { return m_type; }
 
   void SetType(BreakpointSite::Type type) { m_type = type; }
Index: lldb/include/lldb/Breakpoint/BreakpointLocation.h
===
--- lldb/include/lldb/Breakpoint/BreakpointLocation.h
+++ lldb/include/lldb/Breakpoint/BreakpointLocation.h
@@ -76,6 +76,12 @@
   /// \b true if the breakpoint is enabled, \b false if disabled.
   bool IsEnabled() const;
 
+  /// Check if it is a hardware breakpoint.
+  ///
+  /// \return
+  /// \b true if the breakpoint is a harware breakpoint.
+  bool IsHardware() const override;
+
   /// If \a auto_continue is \b true, set the breakpoint to continue when hit.
   

[Lldb-commits] [PATCH] D84255: [lldb] Make process plugins check whether a hardware breakpoint is required

2020-07-21 Thread Tatyana Krasnukha via Phabricator via lldb-commits
tatyana-krasnukha created this revision.
tatyana-krasnukha added a reviewer: clayborg.
tatyana-krasnukha added a project: LLDB.
Herald added subscribers: lldb-commits, emaste.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D84255

Files:
  lldb/source/Plugins/Process/FreeBSD/ProcessFreeBSD.cpp
  lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp
  lldb/source/Plugins/Process/Windows/Common/ProcessWindows.cpp


Index: lldb/source/Plugins/Process/Windows/Common/ProcessWindows.cpp
===
--- lldb/source/Plugins/Process/Windows/Common/ProcessWindows.cpp
+++ lldb/source/Plugins/Process/Windows/Common/ProcessWindows.cpp
@@ -150,6 +150,9 @@
 uint32_t ProcessWindows::GetPluginVersion() { return 1; }
 
 Status ProcessWindows::EnableBreakpointSite(BreakpointSite *bp_site) {
+  if (bp_site->HardwareRequired())
+return Status("Hardware breakpoints are not supported.");
+
   Log *log = ProcessWindowsLog::GetLogIfAny(WINDOWS_LOG_BREAKPOINTS);
   LLDB_LOG(log, "bp_site = {0:x}, id={1}, addr={2:x}", bp_site,
bp_site->GetID(), bp_site->GetLoadAddress());
Index: lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp
===
--- lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp
+++ lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp
@@ -644,6 +644,9 @@
 }
 
 Status ProcessKDP::EnableBreakpointSite(BreakpointSite *bp_site) {
+  if (bp_site->HardwareRequired())
+return Status("Hardware breakpoints are not supported.");
+
   if (m_comm.LocalBreakpointsAreSupported()) {
 Status error;
 if (!bp_site->IsEnabled()) {
Index: lldb/source/Plugins/Process/FreeBSD/ProcessFreeBSD.cpp
===
--- lldb/source/Plugins/Process/FreeBSD/ProcessFreeBSD.cpp
+++ lldb/source/Plugins/Process/FreeBSD/ProcessFreeBSD.cpp
@@ -683,6 +683,9 @@
 }
 
 Status ProcessFreeBSD::EnableBreakpointSite(BreakpointSite *bp_site) {
+  if (bp_site->HardwareRequired())
+return Status("Hardware breakpoints are not supported.");
+
   return EnableSoftwareBreakpoint(bp_site);
 }
 


Index: lldb/source/Plugins/Process/Windows/Common/ProcessWindows.cpp
===
--- lldb/source/Plugins/Process/Windows/Common/ProcessWindows.cpp
+++ lldb/source/Plugins/Process/Windows/Common/ProcessWindows.cpp
@@ -150,6 +150,9 @@
 uint32_t ProcessWindows::GetPluginVersion() { return 1; }
 
 Status ProcessWindows::EnableBreakpointSite(BreakpointSite *bp_site) {
+  if (bp_site->HardwareRequired())
+return Status("Hardware breakpoints are not supported.");
+
   Log *log = ProcessWindowsLog::GetLogIfAny(WINDOWS_LOG_BREAKPOINTS);
   LLDB_LOG(log, "bp_site = {0:x}, id={1}, addr={2:x}", bp_site,
bp_site->GetID(), bp_site->GetLoadAddress());
Index: lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp
===
--- lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp
+++ lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp
@@ -644,6 +644,9 @@
 }
 
 Status ProcessKDP::EnableBreakpointSite(BreakpointSite *bp_site) {
+  if (bp_site->HardwareRequired())
+return Status("Hardware breakpoints are not supported.");
+
   if (m_comm.LocalBreakpointsAreSupported()) {
 Status error;
 if (!bp_site->IsEnabled()) {
Index: lldb/source/Plugins/Process/FreeBSD/ProcessFreeBSD.cpp
===
--- lldb/source/Plugins/Process/FreeBSD/ProcessFreeBSD.cpp
+++ lldb/source/Plugins/Process/FreeBSD/ProcessFreeBSD.cpp
@@ -683,6 +683,9 @@
 }
 
 Status ProcessFreeBSD::EnableBreakpointSite(BreakpointSite *bp_site) {
+  if (bp_site->HardwareRequired())
+return Status("Hardware breakpoints are not supported.");
+
   return EnableSoftwareBreakpoint(bp_site);
 }
 
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D84254: [lldb] Skip overlapping hardware and external breakpoints when writing memory

2020-07-21 Thread Tatyana Krasnukha via Phabricator via lldb-commits
tatyana-krasnukha created this revision.
tatyana-krasnukha added a reviewer: clayborg.
tatyana-krasnukha added a project: LLDB.
Herald added a subscriber: lldb-commits.

This fixes the assertion `assert(intersects);` in the Process::WriteMemory 
function.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D84254

Files:
  lldb/source/Breakpoint/BreakpointSite.cpp
  lldb/source/Target/Process.cpp


Index: lldb/source/Target/Process.cpp
===
--- lldb/source/Target/Process.cpp
+++ lldb/source/Target/Process.cpp
@@ -2291,6 +2291,9 @@
 if (error.Fail())
   return;
 
+if (bp->GetType() != BreakpointSite::eSoftware)
+  return;
+
 addr_t intersect_addr;
 size_t intersect_size;
 size_t opcode_offset;
Index: lldb/source/Breakpoint/BreakpointSite.cpp
===
--- lldb/source/Breakpoint/BreakpointSite.cpp
+++ lldb/source/Breakpoint/BreakpointSite.cpp
@@ -167,40 +167,39 @@
  lldb::addr_t *intersect_addr,
  size_t *intersect_size,
  size_t *opcode_offset) const {
-  // We only use software traps for software breakpoints
-  if (!IsHardware()) {
-if (m_byte_size > 0) {
-  const lldb::addr_t bp_end_addr = m_addr + m_byte_size;
-  const lldb::addr_t end_addr = addr + size;
-  // Is the breakpoint end address before the passed in start address?
-  if (bp_end_addr <= addr)
-return false;
-  // Is the breakpoint start address after passed in end address?
-  if (end_addr <= m_addr)
-return false;
-  if (intersect_addr || intersect_size || opcode_offset) {
-if (m_addr < addr) {
-  if (intersect_addr)
-*intersect_addr = addr;
-  if (intersect_size)
-*intersect_size =
-std::min(bp_end_addr, end_addr) - addr;
-  if (opcode_offset)
-*opcode_offset = addr - m_addr;
-} else {
-  if (intersect_addr)
-*intersect_addr = m_addr;
-  if (intersect_size)
-*intersect_size =
-std::min(bp_end_addr, end_addr) - m_addr;
-  if (opcode_offset)
-*opcode_offset = 0;
-}
+  // The function should be called only for software breakpoints.
+  lldbassert(GetType() == Type::eSoftware);
+
+  if (m_byte_size > 0) {
+const lldb::addr_t bp_end_addr = m_addr + m_byte_size;
+const lldb::addr_t end_addr = addr + size;
+// Is the breakpoint end address before the passed in start address?
+if (bp_end_addr <= addr)
+  return false;
+// Is the breakpoint start address after passed in end address?
+if (end_addr <= m_addr)
+  return false;
+if (intersect_addr || intersect_size || opcode_offset) {
+  if (m_addr < addr) {
+if (intersect_addr)
+  *intersect_addr = addr;
+if (intersect_size)
+  *intersect_size =
+  std::min(bp_end_addr, end_addr) - addr;
+if (opcode_offset)
+  *opcode_offset = addr - m_addr;
+  } else {
+if (intersect_addr)
+  *intersect_addr = m_addr;
+if (intersect_size)
+  *intersect_size =
+  std::min(bp_end_addr, end_addr) - m_addr;
+if (opcode_offset)
+  *opcode_offset = 0;
   }
-  return true;
 }
+return true;
   }
-  return false;
 }
 
 size_t


Index: lldb/source/Target/Process.cpp
===
--- lldb/source/Target/Process.cpp
+++ lldb/source/Target/Process.cpp
@@ -2291,6 +2291,9 @@
 if (error.Fail())
   return;
 
+if (bp->GetType() != BreakpointSite::eSoftware)
+  return;
+
 addr_t intersect_addr;
 size_t intersect_size;
 size_t opcode_offset;
Index: lldb/source/Breakpoint/BreakpointSite.cpp
===
--- lldb/source/Breakpoint/BreakpointSite.cpp
+++ lldb/source/Breakpoint/BreakpointSite.cpp
@@ -167,40 +167,39 @@
  lldb::addr_t *intersect_addr,
  size_t *intersect_size,
  size_t *opcode_offset) const {
-  // We only use software traps for software breakpoints
-  if (!IsHardware()) {
-if (m_byte_size > 0) {
-  const lldb::addr_t bp_end_addr = m_addr + m_byte_size;
-  const lldb::addr_t end_addr = addr + size;
-  // Is the breakpoint end address before the passed in start address?
-  if (bp_end_addr <= addr)
-return false;
-  // Is the breakpoint start address after passed in end address?
-  if (end_addr <= m_addr)
-return false;
-  if (intersect_addr || intersect_size || opcode_offset) {
-if (m_addr < addr) {
-  if (intersect_addr)
-*intersect_addr = addr;
-  

[Lldb-commits] [PATCH] D84253: OptionValue::Clear should return void not bool

2020-07-21 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere accepted this revision.
JDevlieghere added a comment.
This revision is now accepted and ready to land.

LGTM!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84253



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


[Lldb-commits] [PATCH] D84253: OptionValue::Clear should return void not bool

2020-07-21 Thread Jim Ingham via Phabricator via lldb-commits
jingham created this revision.
jingham added a reviewer: JDevlieghere.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

I forgot to add a "return true" to the new OptionValueFileColonLine::Clear 
method which the Windows compiler caught (thanks Jonas for fixing that!)

But that made me wonder if returning true was actually doing any good.  How 
could clearing an OptionValue fail?  And what would you do about it.  The 
answer was "nothing" since all the implementations returned true, and none of 
the clients checked the return value.

This is just unsetting some ivars, so it should always succeed and clients 
shouldn't have to worry about that happening.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D84253

Files:
  lldb/include/lldb/Interpreter/OptionValue.h
  lldb/include/lldb/Interpreter/OptionValueArch.h
  lldb/include/lldb/Interpreter/OptionValueArray.h
  lldb/include/lldb/Interpreter/OptionValueBoolean.h
  lldb/include/lldb/Interpreter/OptionValueChar.h
  lldb/include/lldb/Interpreter/OptionValueDictionary.h
  lldb/include/lldb/Interpreter/OptionValueEnumeration.h
  lldb/include/lldb/Interpreter/OptionValueFileColonLine.h
  lldb/include/lldb/Interpreter/OptionValueFileSpec.h
  lldb/include/lldb/Interpreter/OptionValueFileSpecList.h
  lldb/include/lldb/Interpreter/OptionValueFormat.h
  lldb/include/lldb/Interpreter/OptionValueFormatEntity.h
  lldb/include/lldb/Interpreter/OptionValueLanguage.h
  lldb/include/lldb/Interpreter/OptionValuePathMappings.h
  lldb/include/lldb/Interpreter/OptionValueProperties.h
  lldb/include/lldb/Interpreter/OptionValueRegex.h
  lldb/include/lldb/Interpreter/OptionValueSInt64.h
  lldb/include/lldb/Interpreter/OptionValueString.h
  lldb/include/lldb/Interpreter/OptionValueUInt64.h
  lldb/include/lldb/Interpreter/OptionValueUUID.h
  lldb/source/Interpreter/OptionValueFormatEntity.cpp
  lldb/source/Interpreter/OptionValueProperties.cpp

Index: lldb/source/Interpreter/OptionValueProperties.cpp
===
--- lldb/source/Interpreter/OptionValueProperties.cpp
+++ lldb/source/Interpreter/OptionValueProperties.cpp
@@ -517,11 +517,10 @@
   return false;
 }
 
-bool OptionValueProperties::Clear() {
+void OptionValueProperties::Clear() {
   const size_t num_properties = m_properties.size();
   for (size_t i = 0; i < num_properties; ++i)
 m_properties[i].GetValue()->Clear();
-  return true;
 }
 
 Status OptionValueProperties::SetValueFromString(llvm::StringRef value,
Index: lldb/source/Interpreter/OptionValueFormatEntity.cpp
===
--- lldb/source/Interpreter/OptionValueFormatEntity.cpp
+++ lldb/source/Interpreter/OptionValueFormatEntity.cpp
@@ -29,11 +29,10 @@
   }
 }
 
-bool OptionValueFormatEntity::Clear() {
+void OptionValueFormatEntity::Clear() {
   m_current_entry = m_default_entry;
   m_current_format = m_default_format;
   m_value_was_set = false;
-  return true;
 }
 
 static void EscapeBackticks(llvm::StringRef str, std::string ) {
Index: lldb/include/lldb/Interpreter/OptionValueUUID.h
===
--- lldb/include/lldb/Interpreter/OptionValueUUID.h
+++ lldb/include/lldb/Interpreter/OptionValueUUID.h
@@ -36,10 +36,9 @@
   SetValueFromString(const char *,
  VarSetOperationType = eVarSetOperationAssign) = delete;
 
-  bool Clear() override {
+  void Clear() override {
 m_uuid.Clear();
 m_value_was_set = false;
-return true;
   }
 
   lldb::OptionValueSP DeepCopy() const override;
Index: lldb/include/lldb/Interpreter/OptionValueUInt64.h
===
--- lldb/include/lldb/Interpreter/OptionValueUInt64.h
+++ lldb/include/lldb/Interpreter/OptionValueUInt64.h
@@ -47,10 +47,9 @@
   SetValueFromString(const char *,
  VarSetOperationType = eVarSetOperationAssign) = delete;
 
-  bool Clear() override {
+  void Clear() override {
 m_current_value = m_default_value;
 m_value_was_set = false;
-return true;
   }
 
   lldb::OptionValueSP DeepCopy() const override;
Index: lldb/include/lldb/Interpreter/OptionValueString.h
===
--- lldb/include/lldb/Interpreter/OptionValueString.h
+++ lldb/include/lldb/Interpreter/OptionValueString.h
@@ -85,10 +85,9 @@
   SetValueFromString(const char *,
  VarSetOperationType = eVarSetOperationAssign) = delete;
 
-  bool Clear() override {
+  void Clear() override {
 m_current_value = m_default_value;
 m_value_was_set = false;
-return true;
   }
 
   lldb::OptionValueSP DeepCopy() const override;
Index: lldb/include/lldb/Interpreter/OptionValueSInt64.h
===
--- lldb/include/lldb/Interpreter/OptionValueSInt64.h
+++ lldb/include/lldb/Interpreter/OptionValueSInt64.h
@@ -50,10 

[Lldb-commits] [lldb] dd064af - [lldb] Add missing member initialziation list

2020-07-21 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2020-07-21T10:15:38-07:00
New Revision: dd064afe84b3fd01ef3407dec0aeb22720450048

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

LOG: [lldb] Add missing member initialziation list

My previous commit added the default arguments but didn't use them in
the member initialization list...

Added: 


Modified: 
lldb/include/lldb/Interpreter/CommandObject.h

Removed: 




diff  --git a/lldb/include/lldb/Interpreter/CommandObject.h 
b/lldb/include/lldb/Interpreter/CommandObject.h
index b927c7eaf262..d5ad969cda66 100644
--- a/lldb/include/lldb/Interpreter/CommandObject.h
+++ b/lldb/include/lldb/Interpreter/CommandObject.h
@@ -96,7 +96,9 @@ class CommandObject {
 
 CommandArgumentData(lldb::CommandArgumentType type = lldb::eArgTypeNone,
 ArgumentRepetitionType repetition = eArgRepeatPlain,
-uint32_t opt_set = LLDB_OPT_SET_ALL) {}
+uint32_t opt_set = LLDB_OPT_SET_ALL)
+: arg_type(type), arg_repetition(repetition),
+  arg_opt_set_association(opt_set) {}
   };
 
   typedef std::vector



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


[Lldb-commits] [lldb] e031eda - Revert "[lldb] Unify type name matching in FormattersContainer"

2020-07-21 Thread Raphael Isemann via lldb-commits

Author: Raphael Isemann
Date: 2020-07-21T19:03:33+02:00
New Revision: e031eda08df471c67f9a37289072d338517457a9

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

LOG: Revert "[lldb] Unify type name matching in FormattersContainer"

This reverts commit 5b0de5756ccc7a540926e4eeaa3b398539d88cd8.

Apparently that caused some test to get stuck on Linuxx. Reverting for now.

Added: 


Modified: 
lldb/include/lldb/DataFormatters/DataVisualization.h
lldb/include/lldb/DataFormatters/FormatManager.h
lldb/include/lldb/DataFormatters/FormattersContainer.h
lldb/include/lldb/DataFormatters/TypeCategory.h
lldb/include/lldb/DataFormatters/TypeCategoryMap.h
lldb/source/Commands/CommandObjectType.cpp
lldb/source/DataFormatters/DataVisualization.cpp
lldb/source/DataFormatters/FormatManager.cpp
lldb/unittests/DataFormatter/CMakeLists.txt

Removed: 
lldb/unittests/DataFormatter/FormattersContainerTest.cpp



diff  --git a/lldb/include/lldb/DataFormatters/DataVisualization.h 
b/lldb/include/lldb/DataFormatters/DataVisualization.h
index 7be07d65acdd..b053aa074d9e 100644
--- a/lldb/include/lldb/DataFormatters/DataVisualization.h
+++ b/lldb/include/lldb/DataFormatters/DataVisualization.h
@@ -69,9 +69,9 @@ class DataVisualization {
 
 static void Clear();
 
-static void ForEach(std::function
-callback);
+static void
+ForEach(std::function
+callback);
 
 static uint32_t GetCount();
   };

diff  --git a/lldb/include/lldb/DataFormatters/FormatManager.h 
b/lldb/include/lldb/DataFormatters/FormatManager.h
index 98c5b132c203..56a0303f9b02 100644
--- a/lldb/include/lldb/DataFormatters/FormatManager.h
+++ b/lldb/include/lldb/DataFormatters/FormatManager.h
@@ -34,7 +34,7 @@ namespace lldb_private {
 // this file's objects directly
 
 class FormatManager : public IFormatChangeListener {
-  typedef FormatMap NamedSummariesMap;
+  typedef FormatMap NamedSummariesMap;
   typedef TypeCategoryMap::MapType::iterator CategoryMapIterator;
 
 public:
@@ -144,6 +144,13 @@ class FormatManager : public IFormatChangeListener {
 
   static const char *GetFormatAsCString(lldb::Format format);
 
+  // if the user tries to add formatters for, say, "struct Foo" those will not
+  // match any type because of the way we strip qualifiers from typenames this
+  // method looks for the case where the user is adding a
+  // "class","struct","enum" or "union" Foo and strips the unnecessary
+  // qualifier
+  static ConstString GetValidTypeName(ConstString type);
+
   // when DataExtractor dumps a vectorOfT, it uses a predefined format for each
   // item this method returns it, or eFormatInvalid if vector_format is not a
   // vectorOf

diff  --git a/lldb/include/lldb/DataFormatters/FormattersContainer.h 
b/lldb/include/lldb/DataFormatters/FormattersContainer.h
index 69dd1ecf1752..a22cf494bf8a 100644
--- a/lldb/include/lldb/DataFormatters/FormattersContainer.h
+++ b/lldb/include/lldb/DataFormatters/FormattersContainer.h
@@ -37,113 +37,57 @@ class IFormatChangeListener {
   virtual uint32_t GetCurrentRevision() = 0;
 };
 
-/// Class for matching type names.
-class TypeMatcher {
-  RegularExpression m_type_name_regex;
-  ConstString m_type_name;
-  /// False if m_type_name_regex should be used for matching. False if this is
-  /// just matching by comparing with m_type_name string.
-  bool m_is_regex;
-  /// True iff this TypeMatcher is invalid and shouldn't be used for any
-  /// type matching logic.
-  bool m_valid = true;
-
-  // if the user tries to add formatters for, say, "struct Foo" those will not
-  // match any type because of the way we strip qualifiers from typenames this
-  // method looks for the case where the user is adding a
-  // "class","struct","enum" or "union" Foo and strips the unnecessary 
qualifier
-  static ConstString StripTypeName(ConstString type) {
-if (type.IsEmpty())
-  return type;
-
-std::string type_cstr(type.AsCString());
-StringLexer type_lexer(type_cstr);
-
-type_lexer.AdvanceIf("class ");
-type_lexer.AdvanceIf("enum ");
-type_lexer.AdvanceIf("struct ");
-type_lexer.AdvanceIf("union ");
-
-while (type_lexer.NextIf({' ', '\t', '\v', '\f'}).first)
-  ;
-
-return ConstString(type_lexer.GetUnlexed());
-  }
+// if the user tries to add formatters for, say, "struct Foo" those will not
+// match any type because of the way we strip qualifiers from typenames this
+// method looks for the case where the user is adding a "class","struct","enum"
+// or "union" Foo and strips the unnecessary qualifier
+static inline ConstString GetValidTypeName_Impl(ConstString type) {
+  if (type.IsEmpty())
+return type;
 
-public:
-  /// Creates an invalid matcher that should not be used 

[Lldb-commits] [lldb] 98efa3d - [lldb] Change the CommandArgumentData ctor (NFC)

2020-07-21 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2020-07-21T09:50:30-07:00
New Revision: 98efa3d57f0a38c9cd5433640a9abe6e7d9b7513

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

LOG: [lldb] Change the CommandArgumentData ctor (NFC)

By using default arguments the caller can specify a subset without the
need for overloads. This is particularly useful in combination with
emplace_back as these objects are generally stored in a vector.

Added: 


Modified: 
lldb/include/lldb/Interpreter/CommandObject.h

Removed: 




diff  --git a/lldb/include/lldb/Interpreter/CommandObject.h 
b/lldb/include/lldb/Interpreter/CommandObject.h
index cc4d40b23c31..b927c7eaf262 100644
--- a/lldb/include/lldb/Interpreter/CommandObject.h
+++ b/lldb/include/lldb/Interpreter/CommandObject.h
@@ -90,14 +90,13 @@ class CommandObject {
   {
 lldb::CommandArgumentType arg_type;
 ArgumentRepetitionType arg_repetition;
-uint32_t arg_opt_set_association; // This arg might be associated only with
-  // some particular option set(s).
-CommandArgumentData()
-: arg_type(lldb::eArgTypeNone), arg_repetition(eArgRepeatPlain),
-  arg_opt_set_association(LLDB_OPT_SET_ALL) // By default, the arg
-// associates to all option
-// sets.
-{}
+/// This arg might be associated only with some particular option set(s). 
By
+/// default the arg associates to all option sets.
+uint32_t arg_opt_set_association;
+
+CommandArgumentData(lldb::CommandArgumentType type = lldb::eArgTypeNone,
+ArgumentRepetitionType repetition = eArgRepeatPlain,
+uint32_t opt_set = LLDB_OPT_SET_ALL) {}
   };
 
   typedef std::vector



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


[Lldb-commits] [PATCH] D84151: [lldb] Unify type name matching in FormattersContainer

2020-07-21 Thread Raphael Isemann via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG5b0de5756ccc: [lldb] Unify type name matching in 
FormattersContainer (authored by teemperor).
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84151

Files:
  lldb/include/lldb/DataFormatters/DataVisualization.h
  lldb/include/lldb/DataFormatters/FormatManager.h
  lldb/include/lldb/DataFormatters/FormattersContainer.h
  lldb/include/lldb/DataFormatters/TypeCategory.h
  lldb/include/lldb/DataFormatters/TypeCategoryMap.h
  lldb/source/Commands/CommandObjectType.cpp
  lldb/source/DataFormatters/DataVisualization.cpp
  lldb/source/DataFormatters/FormatManager.cpp
  lldb/unittests/DataFormatter/CMakeLists.txt
  lldb/unittests/DataFormatter/FormattersContainerTest.cpp

Index: lldb/unittests/DataFormatter/FormattersContainerTest.cpp
===
--- /dev/null
+++ lldb/unittests/DataFormatter/FormattersContainerTest.cpp
@@ -0,0 +1,159 @@
+//===-- FormattersContainerTests.cpp --===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "lldb/DataFormatters/FormattersContainer.h"
+
+#include "gtest/gtest.h"
+
+using namespace lldb;
+using namespace lldb_private;
+
+// All the prefixes that the exact name matching will strip from the type.
+static const std::vector exact_name_prefixes = {
+"", // no prefix.
+"class ", "struct ", "union ", "enum ",
+};
+
+// TypeMatcher that uses a exact type name string that needs to be matched.
+TEST(TypeMatcherTests, ExactName) {
+  for (const std::string  : exact_name_prefixes) {
+SCOPED_TRACE("Prefix: " + prefix);
+
+TypeMatcher matcher(ConstString(prefix + "Name"));
+EXPECT_TRUE(matcher.Matches(ConstString("class Name")));
+EXPECT_TRUE(matcher.Matches(ConstString("struct Name")));
+EXPECT_TRUE(matcher.Matches(ConstString("union Name")));
+EXPECT_TRUE(matcher.Matches(ConstString("enum Name")));
+EXPECT_TRUE(matcher.Matches(ConstString("Name")));
+
+EXPECT_FALSE(matcher.Matches(ConstString("Name ")));
+EXPECT_FALSE(matcher.Matches(ConstString("ame")));
+EXPECT_FALSE(matcher.Matches(ConstString("Nam")));
+EXPECT_FALSE(matcher.Matches(ConstString("am")));
+EXPECT_FALSE(matcher.Matches(ConstString("a")));
+EXPECT_FALSE(matcher.Matches(ConstString(" ")));
+EXPECT_FALSE(matcher.Matches(ConstString("class N")));
+EXPECT_FALSE(matcher.Matches(ConstString("class ")));
+EXPECT_FALSE(matcher.Matches(ConstString("class")));
+  }
+}
+
+// TypeMatcher that uses a regex to match a type name.
+TEST(TypeMatcherTests, RegexName) {
+  TypeMatcher matcher(RegularExpression("^a[a-z]c$"));
+  EXPECT_TRUE(matcher.Matches(ConstString("abc")));
+  EXPECT_TRUE(matcher.Matches(ConstString("azc")));
+
+  // FIXME: This isn't consistent with the 'exact' type name matches above.
+  EXPECT_FALSE(matcher.Matches(ConstString("class abc")));
+
+  EXPECT_FALSE(matcher.Matches(ConstString("abbc")));
+  EXPECT_FALSE(matcher.Matches(ConstString(" abc")));
+  EXPECT_FALSE(matcher.Matches(ConstString("abc ")));
+  EXPECT_FALSE(matcher.Matches(ConstString(" abc ")));
+  EXPECT_FALSE(matcher.Matches(ConstString("XabcX")));
+  EXPECT_FALSE(matcher.Matches(ConstString("ac")));
+  EXPECT_FALSE(matcher.Matches(ConstString("a[a-z]c")));
+  EXPECT_FALSE(matcher.Matches(ConstString("aAc")));
+  EXPECT_FALSE(matcher.Matches(ConstString("ABC")));
+  EXPECT_FALSE(matcher.Matches(ConstString("")));
+}
+
+// TypeMatcher that only searches the type name.
+TEST(TypeMatcherTests, RegexMatchPart) {
+  TypeMatcher matcher(RegularExpression("a[a-z]c"));
+  EXPECT_TRUE(matcher.Matches(ConstString("class abc")));
+  EXPECT_TRUE(matcher.Matches(ConstString("abc")));
+  EXPECT_TRUE(matcher.Matches(ConstString(" abc ")));
+  EXPECT_TRUE(matcher.Matches(ConstString("azc")));
+  EXPECT_TRUE(matcher.Matches(ConstString("abc ")));
+  EXPECT_TRUE(matcher.Matches(ConstString(" abc ")));
+  EXPECT_TRUE(matcher.Matches(ConstString(" abc")));
+  EXPECT_TRUE(matcher.Matches(ConstString("XabcX")));
+
+  EXPECT_FALSE(matcher.Matches(ConstString("abbc")));
+  EXPECT_FALSE(matcher.Matches(ConstString("ac")));
+  EXPECT_FALSE(matcher.Matches(ConstString("a[a-z]c")));
+  EXPECT_FALSE(matcher.Matches(ConstString("aAc")));
+  EXPECT_FALSE(matcher.Matches(ConstString("ABC")));
+  EXPECT_FALSE(matcher.Matches(ConstString("")));
+}
+
+// GetMatchString for exact type name matchers.
+TEST(TypeMatcherTests, GetMatchStringExactName) {
+  EXPECT_EQ(TypeMatcher(ConstString("aa")).GetMatchString(), "aa");
+  

[Lldb-commits] [PATCH] D83541: Remove Linux sysroot dependencies of SVE PT macros

2020-07-21 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere added a comment.

This broke the Windows build: 
http://lab.llvm.org:8011/builders/lldb-x64-windows-ninja/builds/17701

Can you take a look?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83541



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


[Lldb-commits] [lldb] 5b0de57 - [lldb] Unify type name matching in FormattersContainer

2020-07-21 Thread Raphael Isemann via lldb-commits

Author: Raphael Isemann
Date: 2020-07-21T18:44:50+02:00
New Revision: 5b0de5756ccc7a540926e4eeaa3b398539d88cd8

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

LOG: [lldb] Unify type name matching in FormattersContainer

Summary:

FormattersContainer stores LLDB's formatters. It's implemented as a templated
map-like data structures that supports any kind of value type and only allows
ConstString and RegularExpression as the key types. The keys are used for
matching type names (e.g., the ConstString key `std::vector` matches the type
with the same name while RegularExpression keys match any type where the
RegularExpression instance matches).

The fact that a single FormattersContainer can only match either by string
comparison or regex matching (depending on the KeyType) causes us to always have
two FormatterContainer instances in all the formatting code. This also leads to
us having every type name matching logic in LLDB twice. For example,
TypeCategory has to implement every method twice (one string matching one, one
regex matching one).

This patch changes FormattersContainer to instead have a single `TypeMatcher`
key that wraps the logic for string-based and regex-based type matching and is
now the only possible KeyType for the FormattersContainer. This means that a
single FormattersContainer can now match types with both regex and string
comparison.

To summarize the changes in this patch:
* Remove all the `*_Impl` methods from `FormattersContainer`
* Instead call the FormatMap functions from `FormattersContainer` with a
  `TypeMatcher` type that does the respective matching.
* Replace `ConstString` with `TypeMatcher` in the few places that directly
  interact with `FormattersContainer`.

I'm working on some follow up patches that I split up because they deserve their
own review:

* Unify FormatMap and FormattersContainer (they are nearly identical now).
* Delete the duplicated half of all the type matching code that can now use one
  interface.
* Propagate TypeMatcher through all the formatter code interfaces instead of
  always offering two functions for everything.

There is one ugly design part that I couldn't get rid of yet and that is that we
have to support getting back the string used to construct a `TypeMatcher` later
on. The reason for this is that LLDB only supports referencing existing type
matchers by just typing their respective input string again (without even
supplying if it's a regex or not).

Reviewers: davide, mib

Reviewed By: mib

Subscribers: mgorny, JDevlieghere

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

Added: 
lldb/unittests/DataFormatter/FormattersContainerTest.cpp

Modified: 
lldb/include/lldb/DataFormatters/DataVisualization.h
lldb/include/lldb/DataFormatters/FormatManager.h
lldb/include/lldb/DataFormatters/FormattersContainer.h
lldb/include/lldb/DataFormatters/TypeCategory.h
lldb/include/lldb/DataFormatters/TypeCategoryMap.h
lldb/source/Commands/CommandObjectType.cpp
lldb/source/DataFormatters/DataVisualization.cpp
lldb/source/DataFormatters/FormatManager.cpp
lldb/unittests/DataFormatter/CMakeLists.txt

Removed: 




diff  --git a/lldb/include/lldb/DataFormatters/DataVisualization.h 
b/lldb/include/lldb/DataFormatters/DataVisualization.h
index b053aa074d9e..7be07d65acdd 100644
--- a/lldb/include/lldb/DataFormatters/DataVisualization.h
+++ b/lldb/include/lldb/DataFormatters/DataVisualization.h
@@ -69,9 +69,9 @@ class DataVisualization {
 
 static void Clear();
 
-static void
-ForEach(std::function
-callback);
+static void ForEach(std::function
+callback);
 
 static uint32_t GetCount();
   };

diff  --git a/lldb/include/lldb/DataFormatters/FormatManager.h 
b/lldb/include/lldb/DataFormatters/FormatManager.h
index 56a0303f9b02..98c5b132c203 100644
--- a/lldb/include/lldb/DataFormatters/FormatManager.h
+++ b/lldb/include/lldb/DataFormatters/FormatManager.h
@@ -34,7 +34,7 @@ namespace lldb_private {
 // this file's objects directly
 
 class FormatManager : public IFormatChangeListener {
-  typedef FormatMap NamedSummariesMap;
+  typedef FormatMap NamedSummariesMap;
   typedef TypeCategoryMap::MapType::iterator CategoryMapIterator;
 
 public:
@@ -144,13 +144,6 @@ class FormatManager : public IFormatChangeListener {
 
   static const char *GetFormatAsCString(lldb::Format format);
 
-  // if the user tries to add formatters for, say, "struct Foo" those will not
-  // match any type because of the way we strip qualifiers from typenames this
-  // method looks for the case where the user is adding a
-  // "class","struct","enum" or "union" Foo and strips the unnecessary
-  // qualifier
-  static ConstString GetValidTypeName(ConstString type);
-
  

[Lldb-commits] [PATCH] D82155: [lldb/interpreter] Add ability to save lldb session to a file

2020-07-21 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere added inline comments.



Comment at: lldb/include/lldb/Interpreter/CommandInterpreter.h:532
 
+  bool SaveTranscripts(std::string file_path);
+

 - Is there more than one transcript? 
 - Maybe make the string optional as you have logic to deal with that so you 
can call `SaveTranscripts()` instead of `SaveTranscripts("")` which looks a bit 
messy. 
 - Add a Doxygen comment documenting the empty-string behavior. 



Comment at: lldb/include/lldb/Interpreter/CommandInterpreter.h:630
+
+  StreamString m_session_transcripts;
 };

The current name isn't very descriptive of what this object is exactly, 
especially since it's plural. How about `m_transcript_stream`? 



Comment at: lldb/source/Commands/CommandObjectSession.cpp:25
+// argument entry.
+arg1.push_back(channel_arg);
+

I changed the `CommandArgumentData` constructor so you can do 
```
arg1.emplace_back(eArgTypePath, eArgRepeatOptional)
```



Comment at: lldb/source/Commands/CommandObjectSession.h:16
+
+// CommandObjectSession
+

Redundant. 



Comment at: lldb/source/Interpreter/CommandInterpreter.cpp:2915
+ error_message, output_file, description);
+StreamSP error_stream = GetDebugger().GetErrorStreamSP();
+*error_stream << "Failed to save session's transcripts to " << output_file

Something that's called from a command should not write to the debugger's 
output/error stream directly. This should return an `Error` instead which then 
can be dealt with in the caller. If the caller is a CommandObject, it can write 
it to the return object. If the caller is something else it can still decide to 
write it to the debugger's error stream. 



Comment at: lldb/test/API/commands/session/save/TestSessionSave.py:42
+
+#import pdb
+#pdb.set_trace()

You probably didn't mean to leave this around. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82155



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


[Lldb-commits] [lldb] 1c9cc09 - [lldb] Fix typo that went unnoticed on my case insensitive FS

2020-07-21 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2020-07-21T09:13:26-07:00
New Revision: 1c9cc094d033d3e8dcc1a5e410ddcc973449b5e1

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

LOG: [lldb] Fix typo that went unnoticed on my case insensitive FS

Added: 


Modified: 
lldb/test/Shell/Reproducer/TestWorkingDir.test

Removed: 




diff  --git a/lldb/test/Shell/Reproducer/TestWorkingDir.test 
b/lldb/test/Shell/Reproducer/TestWorkingDir.test
index 92a9ccd7fc74..54266e76c279 100644
--- a/lldb/test/Shell/Reproducer/TestWorkingDir.test
+++ b/lldb/test/Shell/Reproducer/TestWorkingDir.test
@@ -27,6 +27,6 @@
 # RUN: %lldb -x -b -o 'reproducer generate' --capture --capture-path %t.repro
 # RUN: cat %t.repro/cwd.txt | FileCheck %s
 # CHECK: probably_unique
-# RUN: cat %t.repro/files.yaml | FileCHeck %s --check-prefix VFS
+# RUN: cat %t.repro/files.yaml | FileCheck %s --check-prefix VFS
 # VFS: probably_unique
 # VFS-NOT: dont_include_me



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


Re: [Lldb-commits] [lldb] f8df2e1 - [lldb/Reproducers] Always record the current working directory

2020-07-21 Thread Jonas Devlieghere via lldb-commits
On Tue, Jul 21, 2020 at 5:06 AM Pavel Labath  wrote:

> On 20/07/2020 20:54, Jonas Devlieghere via lldb-commits wrote:
> >
> > Author: Jonas Devlieghere
> > Date: 2020-07-20T11:54:11-07:00
> > New Revision: f8df2e1a19913e997d8d6dbe573de977406e736e
> >
> > URL:
> https://github.com/llvm/llvm-project/commit/f8df2e1a19913e997d8d6dbe573de977406e736e
> > DIFF:
> https://github.com/llvm/llvm-project/commit/f8df2e1a19913e997d8d6dbe573de977406e736e.diff
> >
> > LOG: [lldb/Reproducers] Always record the current working directory
> >
> > Setting the current working directory in the VFS will fail if the given
> > path doesn't exist in the YAML mapping or on disk.
> >
> > Added:
> >
> >
> > Modified:
> > lldb/include/lldb/Utility/Reproducer.h
> > lldb/source/API/SBReproducer.cpp
> > lldb/source/Initialization/SystemInitializerCommon.cpp
> > lldb/test/Shell/Reproducer/TestWorkingDir.test
> >
> > Removed:
> >
> >
> >
> >
> 
> > diff  --git a/lldb/include/lldb/Utility/Reproducer.h
> b/lldb/include/lldb/Utility/Reproducer.h
> > index 2714db8d2932..6fcb839684dc 100644
> > --- a/lldb/include/lldb/Utility/Reproducer.h
> > +++ b/lldb/include/lldb/Utility/Reproducer.h
> > @@ -11,6 +11,7 @@
> >
> >  #include "lldb/Utility/FileSpec.h"
> >  #include "llvm/ADT/DenseMap.h"
> > +#include "llvm/ADT/StringRef.h"
> >  #include "llvm/Support/Error.h"
> >  #include "llvm/Support/FileCollector.h"
> >  #include "llvm/Support/YAMLTraits.h"
> > @@ -149,6 +150,7 @@ class WorkingDirectoryProvider : public
> Provider {
> >}
> >
> >void Update(llvm::StringRef path) { m_cwd = std::string(path); }
> > +  llvm::StringRef GetWorkingDirectory() { return m_cwd; }
> >
> >struct Info {
> >  static const char *name;
> >
> > diff  --git a/lldb/source/API/SBReproducer.cpp
> b/lldb/source/API/SBReproducer.cpp
> > index 0eb3429c4fef..9815bf11263c 100644
> > --- a/lldb/source/API/SBReproducer.cpp
> > +++ b/lldb/source/API/SBReproducer.cpp
> > @@ -234,7 +234,10 @@ const char *SBReproducer::GetPath() {
> >
> >  void SBReproducer::SetWorkingDirectory(const char *path) {
> >if (auto *g =
> lldb_private::repro::Reproducer::Instance().GetGenerator()) {
> > -g->GetOrCreate().Update(path);
> > +auto  = g->GetOrCreate();
> > +wp.Update(path);
> > +auto  = g->GetOrCreate();
> > +fp.RecordInterestingDirectory(wp.GetWorkingDirectory());
>
>
> If I'm not mistaken, this will (recursively) record the entire contents
> of the CWD. That could be a _lot_. Are you that's what you wanted?
>

Most certainly not. Thanks for pointing that out. Fixed with a test case
in 9f8d481d6816d620fc0a1f1c510f662c01fdacec.


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


[Lldb-commits] [lldb] 9f8d481 - [lldb/Reproducers] Don't recursively record everything in the CWD

2020-07-21 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2020-07-21T09:02:38-07:00
New Revision: 9f8d481d6816d620fc0a1f1c510f662c01fdacec

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

LOG: [lldb/Reproducers] Don't recursively record everything in the CWD

RecordInterestingDirectory was added to collect dSYM bundles and their
content. For the current working directory we only want the directory to
be part of the VFS, not necessarily its contents. This patch renames the
current method to RecordInterestingDirectoryRecursively and adds a new
one that's not recursive.

Added: 


Modified: 
lldb/include/lldb/Utility/Reproducer.h
lldb/source/Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.cpp
lldb/source/Utility/Reproducer.cpp
lldb/test/Shell/Reproducer/TestWorkingDir.test

Removed: 




diff  --git a/lldb/include/lldb/Utility/Reproducer.h 
b/lldb/include/lldb/Utility/Reproducer.h
index 6fcb839684dc..b3d470702ee5 100644
--- a/lldb/include/lldb/Utility/Reproducer.h
+++ b/lldb/include/lldb/Utility/Reproducer.h
@@ -101,6 +101,7 @@ class FileProvider : public Provider {
   }
 
   void RecordInterestingDirectory(const llvm::Twine );
+  void RecordInterestingDirectoryRecursive(const llvm::Twine );
 
   void Keep() override {
 auto mapping = GetRoot().CopyByAppendingPathComponent(Info::file);

diff  --git a/lldb/source/Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.cpp 
b/lldb/source/Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.cpp
index e510ee2d0225..336538241b6a 100644
--- a/lldb/source/Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.cpp
+++ b/lldb/source/Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.cpp
@@ -299,7 +299,7 @@ SymbolVendorMacOSX::CreateInstance(const lldb::ModuleSP 
_sp,
   if (repro::Generator *g =
   repro::Reproducer::Instance().GetGenerator()) {
 repro::FileProvider  = g->GetOrCreate();
-fp.RecordInterestingDirectory(dsym_root);
+fp.RecordInterestingDirectoryRecursive(dsym_root);
   }
 }
 return symbol_vendor;

diff  --git a/lldb/source/Utility/Reproducer.cpp 
b/lldb/source/Utility/Reproducer.cpp
index 46e909ecdba6..3ad1064cd4c4 100644
--- a/lldb/source/Utility/Reproducer.cpp
+++ b/lldb/source/Utility/Reproducer.cpp
@@ -300,6 +300,11 @@ void WorkingDirectoryProvider::Keep() {
 }
 
 void FileProvider::RecordInterestingDirectory(const llvm::Twine ) {
+  if (m_collector)
+m_collector->addFile(dir);
+}
+
+void FileProvider::RecordInterestingDirectoryRecursive(const llvm::Twine ) 
{
   if (m_collector)
 m_collector->addDirectory(dir);
 }

diff  --git a/lldb/test/Shell/Reproducer/TestWorkingDir.test 
b/lldb/test/Shell/Reproducer/TestWorkingDir.test
index 76df41fbcbbf..92a9ccd7fc74 100644
--- a/lldb/test/Shell/Reproducer/TestWorkingDir.test
+++ b/lldb/test/Shell/Reproducer/TestWorkingDir.test
@@ -20,8 +20,13 @@
 # referenced.
 
 # RUN: rm -rf %t.repro
+# RUN: rm -rf %t
 # RUN: mkdir -p %t/probably_unique
+# RUN: touch %t/probably_unique/dont_include_me
 # RUN: cd %t/probably_unique
 # RUN: %lldb -x -b -o 'reproducer generate' --capture --capture-path %t.repro
 # RUN: cat %t.repro/cwd.txt | FileCheck %s
 # CHECK: probably_unique
+# RUN: cat %t.repro/files.yaml | FileCHeck %s --check-prefix VFS
+# VFS: probably_unique
+# VFS-NOT: dont_include_me



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


[Lldb-commits] [PATCH] D83552: [lldb/test] Do a better job at setting (DY)LD_LIBRARY_PATH

2020-07-21 Thread Frederic Riss via Phabricator via lldb-commits
friss accepted this revision.
friss added a comment.
This revision is now accepted and ready to land.

In D83552#2162782 , @labath wrote:

> In D83552#2162555 , @friss wrote:
>
> > The `lldbtest.py` part LGTM, but I'm failing to see how this interacts with 
> > `TestWeakSymbols.py`? IIRC, `registerSharedLibraryWithTarget` is an API we 
> > call explicitly in the tests, but I don't see it called here.
>
>
> It gets called from `run_to_source_breakpoint`, keying off of the 
> `extra_images` argument.


Which I added... Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83552



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


[Lldb-commits] [PATCH] D82155: [lldb/interpreter] Add ability to save lldb session to a file

2020-07-21 Thread Med Ismail Bennani via Phabricator via lldb-commits
mib updated this revision to Diff 279519.
mib added a comment.

Reformat.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82155

Files:
  lldb/include/lldb/Interpreter/CommandInterpreter.h
  lldb/source/Commands/CMakeLists.txt
  lldb/source/Commands/CommandObjectQuit.cpp
  lldb/source/Commands/CommandObjectSession.cpp
  lldb/source/Commands/CommandObjectSession.h
  lldb/source/Interpreter/CommandInterpreter.cpp
  lldb/source/Interpreter/InterpreterProperties.td
  lldb/test/API/commands/session/save/TestSessionSave.py

Index: lldb/test/API/commands/session/save/TestSessionSave.py
===
--- /dev/null
+++ lldb/test/API/commands/session/save/TestSessionSave.py
@@ -0,0 +1,73 @@
+"""
+Test the session save feature
+"""
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class SessionSaveTestCase(TestBase):
+
+mydir = TestBase.compute_mydir(__file__)
+
+def setUp(self):
+  configuration.settings.append(("interpreter.echo-commands", "true"))
+  configuration.settings.append(("interpreter.echo-comment-commands", "true"))
+  configuration.settings.append(("interpreter.stop-command-source-on-error", "false"))
+  TestBase.setUp(self)
+
+
+def raw_transcript_builder(self, cmd, res):
+raw = "(lldb) " + cmd + "\n"
+if res.GetOutputSize():
+  raw += res.GetOutput()
+if res.GetErrorSize():
+  raw += res.GetError()
+return raw
+
+
+@skipIfWindows
+@skipIfReproducer
+@no_debug_info_test
+def test_session_save(self):
+raw = ""
+inputs = [
+  '# This is a comment',  # Comment
+  'help session', # Valid command
+  'Lorem ipsum'   # Invalid command
+]
+
+#import pdb
+#pdb.set_trace()
+
+import tempfile
+tf = tempfile.NamedTemporaryFile()
+
+interpreter = self.dbg.GetCommandInterpreter()
+for cmd in inputs:
+  res = lldb.SBCommandReturnObject()
+  interpreter.HandleCommand(cmd, res)
+  raw += self.raw_transcript_builder(cmd, res)
+
+self.assertTrue(interpreter.HasCommands())
+self.assertTrue(len(raw) != 0)
+
+# Check for error
+cmd = 'session save /root/file'
+interpreter.HandleCommand(cmd, res)
+self.assertFalse(res.Succeeded())
+raw += self.raw_transcript_builder(cmd, res)
+
+output_file = tf.name
+
+res = lldb.SBCommandReturnObject()
+interpreter.HandleCommand('session save ' + output_file, res)
+self.assertTrue(res.Succeeded())
+raw += self.raw_transcript_builder(cmd, res)
+
+with open(output_file, "r") as file:
+  content = file.read()
+  for line in raw.splitlines():
+self.assertIn(line, content)
Index: lldb/source/Interpreter/InterpreterProperties.td
===
--- lldb/source/Interpreter/InterpreterProperties.td
+++ lldb/source/Interpreter/InterpreterProperties.td
@@ -9,6 +9,10 @@
 Global,
 DefaultTrue,
 Desc<"If true, LLDB will prompt you before quitting if there are any live processes being debugged. If false, LLDB will quit without asking in any case.">;
+  def SaveSessionOnQuit: Property<"save-session-on-quit", "Boolean">,
+Global,
+DefaultFalse,
+Desc<"If true, LLDB will save the session's transcripts before quitting.">;
   def StopCmdSourceOnError: Property<"stop-command-source-on-error", "Boolean">,
 Global,
 DefaultTrue,
Index: lldb/source/Interpreter/CommandInterpreter.cpp
===
--- lldb/source/Interpreter/CommandInterpreter.cpp
+++ lldb/source/Interpreter/CommandInterpreter.cpp
@@ -6,6 +6,7 @@
 //
 //===--===//
 
+#include 
 #include 
 #include 
 #include 
@@ -31,6 +32,7 @@
 #include "Commands/CommandObjectQuit.h"
 #include "Commands/CommandObjectRegister.h"
 #include "Commands/CommandObjectReproducer.h"
+#include "Commands/CommandObjectSession.h"
 #include "Commands/CommandObjectSettings.h"
 #include "Commands/CommandObjectSource.h"
 #include "Commands/CommandObjectStats.h"
@@ -52,6 +54,8 @@
 #if LLDB_ENABLE_LIBEDIT
 #include "lldb/Host/Editline.h"
 #endif
+#include "lldb/Host/File.h"
+#include "lldb/Host/FileCache.h"
 #include "lldb/Host/Host.h"
 #include "lldb/Host/HostInfo.h"
 
@@ -74,6 +78,7 @@
 #include "llvm/Support/FormatAdapters.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/PrettyStackTrace.h"
+#include "llvm/Support/ScopedPrinter.h"
 
 using namespace lldb;
 using namespace lldb_private;
@@ -116,7 +121,7 @@
   m_skip_lldbinit_files(false), m_skip_app_init_files(false),
   

[Lldb-commits] [PATCH] D84070: [LLDB] [COFF] Fix handling of symbols with more than one aux symbol

2020-07-21 Thread Hans Wennborg via Phabricator via lldb-commits
hans added a comment.

In D84070#2162932 , @mstorsjo wrote:

> @hans - I think this one could be a fairly safe backport to the release 
> branch. (Apparently phab lags behind regarding updating the reviews when they 
> are committed at the moment; this was committed as 
> f07ddbc9c4b66e91aa7a106042512ee903b6b3ba 
> .)


Thanks! Pushed to 11.x as bf2f2bffee244318a86fea90a0dfaf9be8a71b8c 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84070



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


[Lldb-commits] [PATCH] D82155: [lldb/interpreter] Add ability to save lldb session to a file

2020-07-21 Thread Med Ismail Bennani via Phabricator via lldb-commits
mib updated this revision to Diff 279505.
mib retitled this revision from "[WIP][lldb/interpreter] Add ability to save 
lldb session to a file" to "[lldb/interpreter] Add ability to save lldb session 
to a file".
mib added a comment.

- Address previous comments
- Add test


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82155

Files:
  lldb/include/lldb/Interpreter/CommandInterpreter.h
  lldb/source/Commands/CMakeLists.txt
  lldb/source/Commands/CommandObjectQuit.cpp
  lldb/source/Commands/CommandObjectSession.cpp
  lldb/source/Commands/CommandObjectSession.h
  lldb/source/Interpreter/CommandInterpreter.cpp
  lldb/source/Interpreter/InterpreterProperties.td
  lldb/test/API/commands/session/save/TestSessionSave.py

Index: lldb/test/API/commands/session/save/TestSessionSave.py
===
--- /dev/null
+++ lldb/test/API/commands/session/save/TestSessionSave.py
@@ -0,0 +1,73 @@
+"""
+Test the session save feature
+"""
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class SessionSaveTestCase(TestBase):
+
+mydir = TestBase.compute_mydir(__file__)
+
+def setUp(self):
+  configuration.settings.append(("interpreter.echo-commands", "true"))
+  configuration.settings.append(("interpreter.echo-comment-commands", "true"))
+  configuration.settings.append(("interpreter.stop-command-source-on-error", "false"))
+  TestBase.setUp(self)
+
+
+def raw_transcript_builder(self, cmd, res):
+raw = "(lldb) " + cmd + "\n"
+if res.GetOutputSize():
+  raw += res.GetOutput()
+if res.GetErrorSize():
+  raw += res.GetError()
+return raw
+
+
+@skipIfWindows
+@skipIfReproducer
+@no_debug_info_test
+def test_session_save(self):
+raw = ""
+inputs = [
+  '# This is a comment',  # Comment
+  'help session', # Valid command
+  'Lorem ipsum'   # Invalid command
+]
+
+#import pdb
+#pdb.set_trace()
+
+import tempfile
+tf = tempfile.NamedTemporaryFile()
+
+interpreter = self.dbg.GetCommandInterpreter()
+for cmd in inputs:
+  res = lldb.SBCommandReturnObject()
+  interpreter.HandleCommand(cmd, res)
+  raw += self.raw_transcript_builder(cmd, res)
+
+self.assertTrue(interpreter.HasCommands())
+self.assertTrue(len(raw) != 0)
+
+# Check for error
+cmd = 'session save /root/file'
+interpreter.HandleCommand(cmd, res)
+self.assertFalse(res.Succeeded())
+raw += self.raw_transcript_builder(cmd, res)
+
+output_file = tf.name
+
+res = lldb.SBCommandReturnObject()
+interpreter.HandleCommand('session save ' + output_file, res)
+self.assertTrue(res.Succeeded())
+raw += self.raw_transcript_builder(cmd, res)
+
+with open(output_file, "r") as file:
+  content = file.read()
+  for line in raw.splitlines():
+self.assertIn(line, content)
Index: lldb/source/Interpreter/InterpreterProperties.td
===
--- lldb/source/Interpreter/InterpreterProperties.td
+++ lldb/source/Interpreter/InterpreterProperties.td
@@ -9,6 +9,10 @@
 Global,
 DefaultTrue,
 Desc<"If true, LLDB will prompt you before quitting if there are any live processes being debugged. If false, LLDB will quit without asking in any case.">;
+  def SaveSessionOnQuit: Property<"save-session-on-quit", "Boolean">,
+Global,
+DefaultFalse,
+Desc<"If true, LLDB will save the session's transcripts before quitting.">;
   def StopCmdSourceOnError: Property<"stop-command-source-on-error", "Boolean">,
 Global,
 DefaultTrue,
Index: lldb/source/Interpreter/CommandInterpreter.cpp
===
--- lldb/source/Interpreter/CommandInterpreter.cpp
+++ lldb/source/Interpreter/CommandInterpreter.cpp
@@ -6,6 +6,7 @@
 //
 //===--===//
 
+#include 
 #include 
 #include 
 #include 
@@ -31,6 +32,7 @@
 #include "Commands/CommandObjectQuit.h"
 #include "Commands/CommandObjectRegister.h"
 #include "Commands/CommandObjectReproducer.h"
+#include "Commands/CommandObjectSession.h"
 #include "Commands/CommandObjectSettings.h"
 #include "Commands/CommandObjectSource.h"
 #include "Commands/CommandObjectStats.h"
@@ -52,6 +54,8 @@
 #if LLDB_ENABLE_LIBEDIT
 #include "lldb/Host/Editline.h"
 #endif
+#include "lldb/Host/File.h"
+#include "lldb/Host/FileCache.h"
 #include "lldb/Host/Host.h"
 #include "lldb/Host/HostInfo.h"
 
@@ -74,6 +78,7 @@
 #include "llvm/Support/FormatAdapters.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/PrettyStackTrace.h"

Re: [Lldb-commits] [lldb] cd05406 - [testsuite] Adapt lldb-server base test helper to run on arm64

2020-07-21 Thread Pavel Labath via lldb-commits
On 20/07/2020 23:38, Davide Italiano via lldb-commits wrote:
> @@ -1601,8 +1601,18 @@ def single_step_only_steps_one_instruction(
>  # variable value
>  if re.match("s390x", arch):
>  expected_step_count = 2
> +# ARM64 requires "4" instructions: 2 to compute the address (adrp, 
> add),
> +# one to materialize the constant (mov) and the store
> +if re.match("arm64", arch):
> +expected_step_count = 4
> +
>  self.assertEqual(step_count, expected_step_count)
>  
> +# ARM64: Once addresses and constants are materialized, only one
> +# instruction is needed.
> +if re.match("arm64", arch):
> +expected_step_count = 1
> +
>  # Verify we hit the next state.
>  args["expected_g_c1"] = "0"
>  args["expected_g_c2"] = "0"
> 

I have a feeling this was racing with aa73ee052f -- [lldb/test] Use
inline assembly for instruction counting tests.

There should be no need for magic step counts after that patch. (If
there is, I'd like to know why.)

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


Re: [Lldb-commits] [lldb] f8df2e1 - [lldb/Reproducers] Always record the current working directory

2020-07-21 Thread Pavel Labath via lldb-commits
On 20/07/2020 20:54, Jonas Devlieghere via lldb-commits wrote:
> 
> Author: Jonas Devlieghere
> Date: 2020-07-20T11:54:11-07:00
> New Revision: f8df2e1a19913e997d8d6dbe573de977406e736e
> 
> URL: 
> https://github.com/llvm/llvm-project/commit/f8df2e1a19913e997d8d6dbe573de977406e736e
> DIFF: 
> https://github.com/llvm/llvm-project/commit/f8df2e1a19913e997d8d6dbe573de977406e736e.diff
> 
> LOG: [lldb/Reproducers] Always record the current working directory
> 
> Setting the current working directory in the VFS will fail if the given
> path doesn't exist in the YAML mapping or on disk.
> 
> Added: 
> 
> 
> Modified: 
> lldb/include/lldb/Utility/Reproducer.h
> lldb/source/API/SBReproducer.cpp
> lldb/source/Initialization/SystemInitializerCommon.cpp
> lldb/test/Shell/Reproducer/TestWorkingDir.test
> 
> Removed: 
> 
> 
> 
> 
> diff  --git a/lldb/include/lldb/Utility/Reproducer.h 
> b/lldb/include/lldb/Utility/Reproducer.h
> index 2714db8d2932..6fcb839684dc 100644
> --- a/lldb/include/lldb/Utility/Reproducer.h
> +++ b/lldb/include/lldb/Utility/Reproducer.h
> @@ -11,6 +11,7 @@
>  
>  #include "lldb/Utility/FileSpec.h"
>  #include "llvm/ADT/DenseMap.h"
> +#include "llvm/ADT/StringRef.h"
>  #include "llvm/Support/Error.h"
>  #include "llvm/Support/FileCollector.h"
>  #include "llvm/Support/YAMLTraits.h"
> @@ -149,6 +150,7 @@ class WorkingDirectoryProvider : public 
> Provider {
>}
>  
>void Update(llvm::StringRef path) { m_cwd = std::string(path); }
> +  llvm::StringRef GetWorkingDirectory() { return m_cwd; }
>  
>struct Info {
>  static const char *name;
> 
> diff  --git a/lldb/source/API/SBReproducer.cpp 
> b/lldb/source/API/SBReproducer.cpp
> index 0eb3429c4fef..9815bf11263c 100644
> --- a/lldb/source/API/SBReproducer.cpp
> +++ b/lldb/source/API/SBReproducer.cpp
> @@ -234,7 +234,10 @@ const char *SBReproducer::GetPath() {
>  
>  void SBReproducer::SetWorkingDirectory(const char *path) {
>if (auto *g = lldb_private::repro::Reproducer::Instance().GetGenerator()) {
> -g->GetOrCreate().Update(path);
> +auto  = g->GetOrCreate();
> +wp.Update(path);
> +auto  = g->GetOrCreate();
> +fp.RecordInterestingDirectory(wp.GetWorkingDirectory());


If I'm not mistaken, this will (recursively) record the entire contents
of the CWD. That could be a _lot_. Are you that's what you wanted?

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


[Lldb-commits] [PATCH] D84154: [lldb] Remove FormattersContainer's name member

2020-07-21 Thread Raphael Isemann via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG5c15426d7c62: [lldb] Remove FormattersContainers name 
member (authored by teemperor).
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84154

Files:
  lldb/include/lldb/DataFormatters/FormattersContainer.h
  lldb/include/lldb/DataFormatters/TypeCategory.h
  lldb/source/DataFormatters/TypeCategory.cpp


Index: lldb/source/DataFormatters/TypeCategory.cpp
===
--- lldb/source/DataFormatters/TypeCategory.cpp
+++ lldb/source/DataFormatters/TypeCategory.cpp
@@ -15,11 +15,9 @@
 
 TypeCategoryImpl::TypeCategoryImpl(IFormatChangeListener *clist,
ConstString name)
-: m_format_cont("format", "regex-format", clist),
-  m_summary_cont("summary", "regex-summary", clist),
-  m_filter_cont("filter", "regex-filter", clist),
-  m_synth_cont("synth", "regex-synth", clist), m_enabled(false),
-  m_change_listener(clist), m_mutex(), m_name(name), m_languages() {}
+: m_format_cont(clist), m_summary_cont(clist), m_filter_cont(clist),
+  m_synth_cont(clist), m_enabled(false), m_change_listener(clist),
+  m_mutex(), m_name(name), m_languages() {}
 
 static bool IsApplicable(lldb::LanguageType category_lang,
  lldb::LanguageType valobj_lang) {
Index: lldb/include/lldb/DataFormatters/TypeCategory.h
===
--- lldb/include/lldb/DataFormatters/TypeCategory.h
+++ lldb/include/lldb/DataFormatters/TypeCategory.h
@@ -42,10 +42,9 @@
   typedef
   typename RegexMatchContainer::ForEachCallback RegexMatchForEachCallback;
 
-  FormatterContainerPair(const char *exact_name, const char *regex_name,
- IFormatChangeListener *clist)
-  : m_exact_sp(new ExactMatchContainer(std::string(exact_name), clist)),
-m_regex_sp(new RegexMatchContainer(std::string(regex_name), clist)) {}
+  FormatterContainerPair(IFormatChangeListener *clist)
+  : m_exact_sp(new ExactMatchContainer(clist)),
+m_regex_sp(new RegexMatchContainer(clist)) {}
 
   ~FormatterContainerPair() = default;
 
Index: lldb/include/lldb/DataFormatters/FormattersContainer.h
===
--- lldb/include/lldb/DataFormatters/FormattersContainer.h
+++ lldb/include/lldb/DataFormatters/FormattersContainer.h
@@ -169,8 +169,7 @@
 
   friend class TypeCategoryImpl;
 
-  FormattersContainer(std::string name, IFormatChangeListener *lst)
-  : m_format_map(lst), m_name(name) {}
+  FormattersContainer(IFormatChangeListener *lst) : m_format_map(lst) {}
 
   void Add(MapKeyType type, const MapValueType ) {
 Add_Impl(std::move(type), entry, static_cast(nullptr));
@@ -205,7 +204,6 @@
 
 protected:
   BackEndType m_format_map;
-  std::string m_name;
 
   FormattersContainer(const FormattersContainer &) = delete;
   const FormattersContainer =(const FormattersContainer &) = delete;


Index: lldb/source/DataFormatters/TypeCategory.cpp
===
--- lldb/source/DataFormatters/TypeCategory.cpp
+++ lldb/source/DataFormatters/TypeCategory.cpp
@@ -15,11 +15,9 @@
 
 TypeCategoryImpl::TypeCategoryImpl(IFormatChangeListener *clist,
ConstString name)
-: m_format_cont("format", "regex-format", clist),
-  m_summary_cont("summary", "regex-summary", clist),
-  m_filter_cont("filter", "regex-filter", clist),
-  m_synth_cont("synth", "regex-synth", clist), m_enabled(false),
-  m_change_listener(clist), m_mutex(), m_name(name), m_languages() {}
+: m_format_cont(clist), m_summary_cont(clist), m_filter_cont(clist),
+  m_synth_cont(clist), m_enabled(false), m_change_listener(clist),
+  m_mutex(), m_name(name), m_languages() {}
 
 static bool IsApplicable(lldb::LanguageType category_lang,
  lldb::LanguageType valobj_lang) {
Index: lldb/include/lldb/DataFormatters/TypeCategory.h
===
--- lldb/include/lldb/DataFormatters/TypeCategory.h
+++ lldb/include/lldb/DataFormatters/TypeCategory.h
@@ -42,10 +42,9 @@
   typedef
   typename RegexMatchContainer::ForEachCallback RegexMatchForEachCallback;
 
-  FormatterContainerPair(const char *exact_name, const char *regex_name,
- IFormatChangeListener *clist)
-  : m_exact_sp(new ExactMatchContainer(std::string(exact_name), clist)),
-m_regex_sp(new RegexMatchContainer(std::string(regex_name), clist)) {}
+  FormatterContainerPair(IFormatChangeListener *clist)
+  : m_exact_sp(new ExactMatchContainer(clist)),
+m_regex_sp(new RegexMatchContainer(clist)) {}
 
   

[Lldb-commits] [lldb] 5c15426 - [lldb] Remove FormattersContainer's name member

2020-07-21 Thread Raphael Isemann via lldb-commits

Author: Raphael Isemann
Date: 2020-07-21T13:54:38+02:00
New Revision: 5c15426d7c62aa8c38547144f28c5a1c6e50549a

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

LOG: [lldb] Remove FormattersContainer's name member

Summary:

FormattersContainer currently has an unused `m_name` member. Usually LLDB allows
giving objects names, but for the FormattersContainer it seems excessive. There
are only 4 FormattersContainer variables in LLDB and they are not usually passed
around, so one can always just go up a few frames when debugging to find out
which FormattersContainer you're dealing with.

Reviewers: mib, davide

Reviewed By: mib

Subscribers: JDevlieghere

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

Added: 


Modified: 
lldb/include/lldb/DataFormatters/FormattersContainer.h
lldb/include/lldb/DataFormatters/TypeCategory.h
lldb/source/DataFormatters/TypeCategory.cpp

Removed: 




diff  --git a/lldb/include/lldb/DataFormatters/FormattersContainer.h 
b/lldb/include/lldb/DataFormatters/FormattersContainer.h
index 2b9c1dcc334f..a22cf494bf8a 100644
--- a/lldb/include/lldb/DataFormatters/FormattersContainer.h
+++ b/lldb/include/lldb/DataFormatters/FormattersContainer.h
@@ -169,8 +169,7 @@ template  class 
FormattersContainer {
 
   friend class TypeCategoryImpl;
 
-  FormattersContainer(std::string name, IFormatChangeListener *lst)
-  : m_format_map(lst), m_name(name) {}
+  FormattersContainer(IFormatChangeListener *lst) : m_format_map(lst) {}
 
   void Add(MapKeyType type, const MapValueType ) {
 Add_Impl(std::move(type), entry, static_cast(nullptr));
@@ -205,7 +204,6 @@ template  class 
FormattersContainer {
 
 protected:
   BackEndType m_format_map;
-  std::string m_name;
 
   FormattersContainer(const FormattersContainer &) = delete;
   const FormattersContainer =(const FormattersContainer &) = delete;

diff  --git a/lldb/include/lldb/DataFormatters/TypeCategory.h 
b/lldb/include/lldb/DataFormatters/TypeCategory.h
index 820872a59bda..11614fc67cd2 100644
--- a/lldb/include/lldb/DataFormatters/TypeCategory.h
+++ b/lldb/include/lldb/DataFormatters/TypeCategory.h
@@ -42,10 +42,9 @@ template  class 
FormatterContainerPair {
   typedef
   typename RegexMatchContainer::ForEachCallback RegexMatchForEachCallback;
 
-  FormatterContainerPair(const char *exact_name, const char *regex_name,
- IFormatChangeListener *clist)
-  : m_exact_sp(new ExactMatchContainer(std::string(exact_name), clist)),
-m_regex_sp(new RegexMatchContainer(std::string(regex_name), clist)) {}
+  FormatterContainerPair(IFormatChangeListener *clist)
+  : m_exact_sp(new ExactMatchContainer(clist)),
+m_regex_sp(new RegexMatchContainer(clist)) {}
 
   ~FormatterContainerPair() = default;
 

diff  --git a/lldb/source/DataFormatters/TypeCategory.cpp 
b/lldb/source/DataFormatters/TypeCategory.cpp
index 8368c91a57f1..f1c6210edd1a 100644
--- a/lldb/source/DataFormatters/TypeCategory.cpp
+++ b/lldb/source/DataFormatters/TypeCategory.cpp
@@ -15,11 +15,9 @@ using namespace lldb_private;
 
 TypeCategoryImpl::TypeCategoryImpl(IFormatChangeListener *clist,
ConstString name)
-: m_format_cont("format", "regex-format", clist),
-  m_summary_cont("summary", "regex-summary", clist),
-  m_filter_cont("filter", "regex-filter", clist),
-  m_synth_cont("synth", "regex-synth", clist), m_enabled(false),
-  m_change_listener(clist), m_mutex(), m_name(name), m_languages() {}
+: m_format_cont(clist), m_summary_cont(clist), m_filter_cont(clist),
+  m_synth_cont(clist), m_enabled(false), m_change_listener(clist),
+  m_mutex(), m_name(name), m_languages() {}
 
 static bool IsApplicable(lldb::LanguageType category_lang,
  lldb::LanguageType valobj_lang) {



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


[Lldb-commits] [lldb] b621e8c - [LLDB] Fix build on windows caused by LinuxPTraceDefines_arm64sve.h

2020-07-21 Thread Muhammad Omair Javaid via lldb-commits

Author: Muhammad Omair Javaid
Date: 2020-07-21T16:47:25+05:00
New Revision: b621e8c787b3e20aa9e9dc940bfd4a792cd2a06c

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

LOG: [LLDB] Fix build on windows caused by LinuxPTraceDefines_arm64sve.h

This patch fixes build on lldb-x64-windows-ninja. The error is caused by
use of two leading underscores.

According to MSVC documentation:
In Microsoft C++, identifiers with two leading underscores are reserved
for compiler implementations.

https://docs.microsoft.com/en-us/cpp/cpp/keywords-cpp?view=vs-2019

Added: 


Modified: 
lldb/source/Plugins/Process/Utility/LinuxPTraceDefines_arm64sve.h

Removed: 




diff  --git a/lldb/source/Plugins/Process/Utility/LinuxPTraceDefines_arm64sve.h 
b/lldb/source/Plugins/Process/Utility/LinuxPTraceDefines_arm64sve.h
index 04d49bf53918..fe3aed96d859 100644
--- a/lldb/source/Plugins/Process/Utility/LinuxPTraceDefines_arm64sve.h
+++ b/lldb/source/Plugins/Process/Utility/LinuxPTraceDefines_arm64sve.h
@@ -16,7 +16,7 @@
 
 #include 
 
-struct _aarch64_context {
+struct aarch64_context {
   uint16_t magic;
   uint16_t size;
 };
@@ -24,9 +24,9 @@ struct _aarch64_context {
 #define SVE_MAGIC 0x53564501
 
 struct sve_context {
-  struct _aarch64_context head;
+  struct aarch64_context head;
   uint16_t vl;
-  uint16_t __reserved[3];
+  uint16_t reserved[3];
 };
 
 /*
@@ -140,7 +140,7 @@ struct user_sve_header {
   uint16_t vl;   /* current vector length */
   uint16_t max_vl;   /* maximum possible vector length */
   uint16_t flags;
-  uint16_t __reserved;
+  uint16_t reserved;
 };
 
 /* Definitions for user_sve_header.flags: */



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


[Lldb-commits] [lldb] 6960e39 - [LLDB] Fix LinuxPTraceDefines_arm64sve.h for AArch64 Linux host

2020-07-21 Thread Muhammad Omair Javaid via lldb-commits

Author: Muhammad Omair Javaid
Date: 2020-07-21T14:31:47+05:00
New Revision: 6960e39eff0a3363ca7dc6b7cf8134180b7d101f

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

LOG: [LLDB] Fix LinuxPTraceDefines_arm64sve.h for AArch64 Linux host

LinuxPTraceDefines_arm64sve.h defines essential macros for manipulating
AArch64 SVE core dump registers. Add guard for aarch64/Linux hosts where
newer versions of ptrace.h or sigcontext.h might already define SVE macros.

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

Added: 


Modified: 
lldb/source/Plugins/Process/Utility/LinuxPTraceDefines_arm64sve.h

Removed: 




diff  --git a/lldb/source/Plugins/Process/Utility/LinuxPTraceDefines_arm64sve.h 
b/lldb/source/Plugins/Process/Utility/LinuxPTraceDefines_arm64sve.h
index bc0b773d1a53..04d49bf53918 100644
--- a/lldb/source/Plugins/Process/Utility/LinuxPTraceDefines_arm64sve.h
+++ b/lldb/source/Plugins/Process/Utility/LinuxPTraceDefines_arm64sve.h
@@ -9,6 +9,11 @@
 #ifndef LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_LINUXPTRACEDEFINES_ARM64SVE_H
 #define LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_LINUXPTRACEDEFINES_ARM64SVE_H
 
+// LinuxPTraceDefines_arm64sve.h defines essential macros for manipulating
+// AArch64 SVE core dump registers. Add guard for aarch64/Linux hosts where
+// newer versions of ptrace.h or sigcontext.h might already define SVE macros.
+#ifndef SVE_SIG_REGS_OFFSET
+
 #include 
 
 struct _aarch64_context {
@@ -257,4 +262,6 @@ struct user_sve_header {
? SVE_PT_SVE_OFFSET + SVE_PT_SVE_SIZE(vq, flags)
\
: SVE_PT_FPSIMD_OFFSET + SVE_PT_FPSIMD_SIZE(vq, flags))
 
+#endif // SVE_SIG_REGS_OFFSET
+
 #endif // LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_LINUXPTRACEDEFINES_ARM64SVE_H



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


[Lldb-commits] [lldb] 510e37c - Revert "Revert "AArch64 SVE register infos and core file support""

2020-07-21 Thread Muhammad Omair Javaid via lldb-commits

Author: Muhammad Omair Javaid
Date: 2020-07-21T14:31:47+05:00
New Revision: 510e37c88c1203de341c23e0878c994478d2594f

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

LOG: Revert "Revert "AArch64 SVE register infos and core file support""

This reverts commit d9920e0199b48734ef305e69ecd5235fff72be25.

Added: 
lldb/source/Plugins/Process/Utility/RegisterInfos_arm64_sve.h

lldb/test/API/functionalities/postmortem/elf-core/linux-aarch64-sve-fpsimd.core

lldb/test/API/functionalities/postmortem/elf-core/linux-aarch64-sve-full.core
lldb/test/API/functionalities/postmortem/elf-core/linux-aarch64-sve.c

Modified: 
lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_arm64.cpp
lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_arm64.h
lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.cpp
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

Removed: 




diff  --git 
a/lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_arm64.cpp 
b/lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_arm64.cpp
index d88695009fdb..3f52501c35f3 100644
--- a/lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_arm64.cpp
+++ b/lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_arm64.cpp
@@ -39,6 +39,13 @@ bool RegisterContextPOSIX_arm64::IsFPR(unsigned reg) {
   return false;
 }
 
+bool RegisterContextPOSIX_arm64::IsSVE(unsigned reg) const {
+  if (m_register_info_up->GetRegisterSetFromRegisterIndex(reg) ==
+  RegisterInfoPOSIX_arm64::SVERegSet)
+return true;
+  return false;
+}
+
 RegisterContextPOSIX_arm64::RegisterContextPOSIX_arm64(
 lldb_private::Thread ,
 std::unique_ptr register_info)
@@ -79,8 +86,8 @@ const lldb_private::RegisterInfo *
 RegisterContextPOSIX_arm64::GetRegisterInfoAtIndex(size_t reg) {
   if (reg < GetRegisterCount())
 return ()[reg];
-  else
-return nullptr;
+
+  return nullptr;
 }
 
 size_t RegisterContextPOSIX_arm64::GetRegisterSetCount() {

diff  --git a/lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_arm64.h 
b/lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_arm64.h
index 01c9fee5be6d..fdb8b9cfeee8 100644
--- a/lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_arm64.h
+++ b/lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_arm64.h
@@ -55,6 +55,21 @@ class RegisterContextPOSIX_arm64 : public 
lldb_private::RegisterContext {
 
   size_t GetFPUSize() { return sizeof(RegisterInfoPOSIX_arm64::FPU); }
 
+  bool IsSVE(unsigned reg) const;
+
+  bool IsSVEZ(unsigned reg) const { return m_register_info_up->IsSVEZReg(reg); 
}
+  bool IsSVEP(unsigned reg) const { return m_register_info_up->IsSVEPReg(reg); 
}
+  bool IsSVEVG(unsigned reg) const {
+return m_register_info_up->IsSVERegVG(reg);
+  }
+
+  uint32_t GetRegNumSVEZ0() const {
+return m_register_info_up->GetRegNumSVEZ0();
+  }
+
+  uint32_t GetRegNumFPCR() const { return m_register_info_up->GetRegNumFPCR(); 
}
+  uint32_t GetRegNumFPSR() const { return m_register_info_up->GetRegNumFPSR(); 
}
+
   virtual bool ReadGPR() = 0;
   virtual bool ReadFPR() = 0;
   virtual bool WriteGPR() = 0;

diff  --git a/lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.cpp 
b/lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.cpp
index 4537cee42ad9..e28e46449b1d 100644
--- a/lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.cpp
+++ b/lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.cpp
@@ -25,6 +25,24 @@
   (LLVM_EXTENSION offsetof(RegisterInfoPOSIX_arm64::FPU, reg) +
\
sizeof(RegisterInfoPOSIX_arm64::GPR))
 
+// This information is based on AArch64 with SVE architecture reference manual.
+// AArch64 with SVE has 32 Z and 16 P vector registers. There is also an FFR
+// (First Fault) register and a VG (Vector Granule) pseudo register.
+
+// SVE 16-byte quad word is the basic unit of expansion in vector length.
+#define SVE_QUAD_WORD_BYTES 16
+
+// Vector length is the multiplier which decides the no of quad words,
+// (multiples of 128-bits or 16-bytes) present in a Z register. Vector length
+// is decided during execution and can change at runtime. SVE AArch64 register
+// infos have modes one for each valid value of vector length. A change in
+// vector length requires register context to update sizes of SVE Z, P and FFR.
+// Also register context needs to update byte offsets of all registers affected
+// by the change in vector length.
+#define SVE_REGS_DEFAULT_OFFSET_LINUX 

[Lldb-commits] [lldb] 62ccfb6 - [LLDB] Fix Arm/AArch64 Linux broken build

2020-07-21 Thread Muhammad Omair Javaid via lldb-commits

Author: Muhammad Omair Javaid
Date: 2020-07-21T13:46:39+05:00
New Revision: 62ccfb6ed0bed899f22abc00bec96a372420c5d0

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

LOG: [LLDB] Fix Arm/AArch64 Linux broken build

This patch fixes build breakage on LLDB Arm/AArch64 Linux buildbots.

http://lab.llvm.org:8011/builders/lldb-aarch64-ubuntu/builds/6649
http://lab.llvm.org:8011/builders/lldb-arm-ubuntu/builds/1919

This build breakage was introduces by commit: 
001c8e1fd9f09d3de9ff6e64bdac4b8ca681dfb4

Added: 


Modified: 
lldb/source/Plugins/Platform/MacOSX/PlatformMacOSX.h

Removed: 




diff  --git a/lldb/source/Plugins/Platform/MacOSX/PlatformMacOSX.h 
b/lldb/source/Plugins/Platform/MacOSX/PlatformMacOSX.h
index 30b11eb37684..3e9a0b3aab90 100644
--- a/lldb/source/Plugins/Platform/MacOSX/PlatformMacOSX.h
+++ b/lldb/source/Plugins/Platform/MacOSX/PlatformMacOSX.h
@@ -79,6 +79,10 @@ class PlatformMacOSX : public PlatformDarwin {
 private:
   PlatformMacOSX(const PlatformMacOSX &) = delete;
   const PlatformMacOSX =(const PlatformMacOSX &) = delete;
+
+#if defined(__arm__) || defined(__arm64__) || defined(__aarch64__)
+  uint32_t m_num_arm_arches = 0;
+#endif
 };
 
 #endif // LLDB_SOURCE_PLUGINS_PLATFORM_MACOSX_PLATFORMMACOSX_H



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


[Lldb-commits] [lldb] cb59267 - [lldb] Make TestOptionValueFileColonLine work on Windows

2020-07-21 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2020-07-20T23:15:03-07:00
New Revision: cb5926795aaf4ca0059e8e4f985fcfd156a71477

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

LOG: [lldb] Make TestOptionValueFileColonLine work on Windows

The colon in the file name is interpreted as a drive name and therefore
the path looks like foo:\\bar.c. Compare FileSpecs instead of their
string representation so we don't have to worry about that.

Added: 


Modified: 
lldb/unittests/Interpreter/TestOptionValueFileColonLine.cpp

Removed: 




diff  --git a/lldb/unittests/Interpreter/TestOptionValueFileColonLine.cpp 
b/lldb/unittests/Interpreter/TestOptionValueFileColonLine.cpp
index 54e31333d835..079c26bdd8ab 100644
--- a/lldb/unittests/Interpreter/TestOptionValueFileColonLine.cpp
+++ b/lldb/unittests/Interpreter/TestOptionValueFileColonLine.cpp
@@ -13,7 +13,7 @@
 
 using namespace lldb_private;
 
-void CheckSetting(const char *input, bool success, const char *path = nullptr,
+void CheckSetting(const char *input, bool success, FileSpec path = {},
   uint32_t line_number = LLDB_INVALID_LINE_NUMBER,
   uint32_t column_number = LLDB_INVALID_COLUMN_NUMBER) {
 
@@ -29,8 +29,7 @@ void CheckSetting(const char *input, bool success, const char 
*path = nullptr,
 
   ASSERT_EQ(value.GetLineNumber(), line_number);
   ASSERT_EQ(value.GetColumnNumber(), column_number);
-  std::string value_path = value.GetFileSpec().GetPath();
-  ASSERT_STREQ(value_path.c_str(), path);
+  ASSERT_EQ(value.GetFileSpec(), path);
 }
 
 TEST(OptionValueFileColonLine, setFromString) {
@@ -48,11 +47,11 @@ TEST(OptionValueFileColonLine, setFromString) {
   CheckSetting("foo.c", false);
 
   // Now try with just a file & line:
-  CheckSetting("foo.c:12", true, "foo.c", 12);
-  CheckSetting("foo.c:12:20", true, "foo.c", 12, 20);
+  CheckSetting("foo.c:12", true, FileSpec("foo.c"), 12);
+  CheckSetting("foo.c:12:20", true, FileSpec("foo.c"), 12, 20);
   // Make sure a colon doesn't mess us up:
-  CheckSetting("foo:bar.c:12", true, "foo:bar.c", 12);
-  CheckSetting("foo:bar.c:12:20", true, "foo:bar.c", 12, 20);
+  CheckSetting("foo:bar.c:12", true, FileSpec("foo:bar.c"), 12);
+  CheckSetting("foo:bar.c:12:20", true, FileSpec("foo:bar.c"), 12, 20);
   // Try errors in the line number:
   CheckSetting("foo.c:12c", false);
   CheckSetting("foo.c:12:20c", false);



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


[Lldb-commits] [lldb] 7926143 - [lldb] Fix redundant newline in AppendError calls.

2020-07-21 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2020-07-20T23:11:56-07:00
New Revision: 7926143fb0a56ae17e06e462d19e0fde48801a5c

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

LOG: [lldb] Fix redundant newline in AppendError calls.

AppendError always appends a newline to the given argument, while
AppendErrorWithFormat does not. I've updated the calls to remove the
extra newline.

Added: 


Modified: 
lldb/source/Breakpoint/BreakpointIDList.cpp
lldb/source/Interpreter/CommandInterpreter.cpp

Removed: 




diff  --git a/lldb/source/Breakpoint/BreakpointIDList.cpp 
b/lldb/source/Breakpoint/BreakpointIDList.cpp
index 95ae60522262..e6a5dceeb93b 100644
--- a/lldb/source/Breakpoint/BreakpointIDList.cpp
+++ b/lldb/source/Breakpoint/BreakpointIDList.cpp
@@ -223,7 +223,7 @@ void BreakpointIDList::FindAndReplaceIDRanges(Args 
_args, Target *target,
   result.AppendError("Invalid breakpoint id range:  Either "
  "both ends of range must specify"
  " a breakpoint location, or neither can "
- "specify a breakpoint location.\n");
+ "specify a breakpoint location.");
   result.SetStatus(eReturnStatusFailed);
   return;
 }

diff  --git a/lldb/source/Interpreter/CommandInterpreter.cpp 
b/lldb/source/Interpreter/CommandInterpreter.cpp
index 963c1ea76ee8..baceeac7fbae 100644
--- a/lldb/source/Interpreter/CommandInterpreter.cpp
+++ b/lldb/source/Interpreter/CommandInterpreter.cpp
@@ -1708,7 +1708,7 @@ bool CommandInterpreter::HandleCommand(const char 
*command_line,
 command_string = command_line;
 original_command_string = command_line;
 if (m_repeat_command.empty()) {
-  result.AppendError("No auto repeat.\n");
+  result.AppendError("No auto repeat.");
   result.SetStatus(eReturnStatusFailed);
   return false;
 }



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


[Lldb-commits] [lldb] 8953376 - [lldb] Remove redundant WithFormat suffixes (NFC)

2020-07-21 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2020-07-20T23:00:32-07:00
New Revision: 895337647896edefda244c7afc4b71eab41ff850

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

LOG: [lldb] Remove redundant WithFormat suffixes (NFC)

Replace calls to FooWithFormat() with calls to Foo() when only one
argument is provided and the given string doesn't need to be formatted.

Added: 


Modified: 
lldb/source/Breakpoint/Breakpoint.cpp
lldb/source/Breakpoint/BreakpointID.cpp
lldb/source/Breakpoint/BreakpointIDList.cpp
lldb/source/Breakpoint/BreakpointOptions.cpp
lldb/source/Breakpoint/BreakpointResolver.cpp
lldb/source/Breakpoint/BreakpointResolverName.cpp
lldb/source/Core/ModuleList.cpp
lldb/source/Core/SearchFilter.cpp
lldb/source/Core/Value.cpp
lldb/source/Expression/DWARFExpression.cpp
lldb/source/Expression/IRInterpreter.cpp
lldb/source/Expression/Materializer.cpp
lldb/source/Interpreter/CommandInterpreter.cpp
lldb/source/Interpreter/OptionValue.cpp
lldb/source/Interpreter/OptionValueFormatEntity.cpp
lldb/source/Interpreter/Options.cpp
lldb/source/Target/Process.cpp

Removed: 




diff  --git a/lldb/source/Breakpoint/Breakpoint.cpp 
b/lldb/source/Breakpoint/Breakpoint.cpp
index 317dfa231094..88c7f3352f42 100644
--- a/lldb/source/Breakpoint/Breakpoint.cpp
+++ b/lldb/source/Breakpoint/Breakpoint.cpp
@@ -144,8 +144,7 @@ lldb::BreakpointSP Breakpoint::CreateFromStructuredData(
   bool success = breakpoint_dict->GetValueForKeyAsDictionary(
   BreakpointResolver::GetSerializationKey(), resolver_dict);
   if (!success) {
-error.SetErrorStringWithFormat(
-"Breakpoint data missing toplevel resolver key");
+error.SetErrorString("Breakpoint data missing toplevel resolver key");
 return result_sp;
   }
 

diff  --git a/lldb/source/Breakpoint/BreakpointID.cpp 
b/lldb/source/Breakpoint/BreakpointID.cpp
index 293baf4ad1c7..a37abcfa52ab 100644
--- a/lldb/source/Breakpoint/BreakpointID.cpp
+++ b/lldb/source/Breakpoint/BreakpointID.cpp
@@ -96,7 +96,7 @@ bool BreakpointID::StringIsBreakpointName(llvm::StringRef 
str, Status ) {
   error.Clear();
   if (str.empty())
   {
-error.SetErrorStringWithFormat("Empty breakpoint names are not allowed");
+error.SetErrorString("Empty breakpoint names are not allowed");
 return false;
   }
 

diff  --git a/lldb/source/Breakpoint/BreakpointIDList.cpp 
b/lldb/source/Breakpoint/BreakpointIDList.cpp
index 705bc5ee1c8d..95ae60522262 100644
--- a/lldb/source/Breakpoint/BreakpointIDList.cpp
+++ b/lldb/source/Breakpoint/BreakpointIDList.cpp
@@ -220,10 +220,10 @@ void BreakpointIDList::FindAndReplaceIDRanges(Args 
_args, Target *target,
 ((start_loc_id != LLDB_INVALID_BREAK_ID) &&
  (end_loc_id == LLDB_INVALID_BREAK_ID))) {
   new_args.Clear();
-  result.AppendErrorWithFormat("Invalid breakpoint id range:  Either "
-   "both ends of range must specify"
-   " a breakpoint location, or neither can "
-   "specify a breakpoint location.\n");
+  result.AppendError("Invalid breakpoint id range:  Either "
+ "both ends of range must specify"
+ " a breakpoint location, or neither can "
+ "specify a breakpoint location.\n");
   result.SetStatus(eReturnStatusFailed);
   return;
 }

diff  --git a/lldb/source/Breakpoint/BreakpointOptions.cpp 
b/lldb/source/Breakpoint/BreakpointOptions.cpp
index 0ce7b0f852e8..f6bb7633d0a9 100644
--- a/lldb/source/Breakpoint/BreakpointOptions.cpp
+++ b/lldb/source/Breakpoint/BreakpointOptions.cpp
@@ -319,7 +319,7 @@ std::unique_ptr 
BreakpointOptions::CreateFromStructuredData(
 else {
   ScriptInterpreter *interp = target.GetDebugger().GetScriptInterpreter();
   if (!interp) {
-error.SetErrorStringWithFormat(
+error.SetErrorString(
 "Can't set script commands - no script interpreter");
 return nullptr;
   }

diff  --git a/lldb/source/Breakpoint/BreakpointResolver.cpp 
b/lldb/source/Breakpoint/BreakpointResolver.cpp
index 7c03a0745ac6..cfd073367b00 100644
--- a/lldb/source/Breakpoint/BreakpointResolver.cpp
+++ b/lldb/source/Breakpoint/BreakpointResolver.cpp
@@ -81,8 +81,7 @@ BreakpointResolverSP 
BreakpointResolver::CreateFromStructuredData(
   GetSerializationSubclassKey(), subclass_name);
 
   if (!success) {
-error.SetErrorStringWithFormat(
-"Resolver data missing subclass resolver key");
+error.SetErrorString("Resolver data missing subclass resolver key");
 return result_sp;
   }
 

diff  --git a/lldb/source/Breakpoint/BreakpointResolverName.cpp