[Lldb-commits] [PATCH] D112658: [lldb] Refactor C/C++ string and char summary providers

2021-10-29 Thread Pavel Labath via Phabricator via lldb-commits
labath accepted this revision.
labath added a comment.
This revision is now accepted and ready to land.

Looks good.

Do you have commit access, or should I check this in for you (I can also fix up 
the formatting in that case)?




Comment at: lldb/source/Plugins/Language/CPlusPlus/CxxStringTypes.cpp:37-40
+static constexpr std::pair 
getElementTraits(StringElementType ElemType)
+{
+  switch(ElemType)
+  {

This isn't the right formatting (brackets don't get their own line, and the 
first line is too long). Could you run the patch through clang-format please?



Comment at: lldb/source/Plugins/Language/CPlusPlus/CxxStringTypes.cpp:76-85
+if (ElemType == StringPrinter::StringElementType::UTF8) {
+  options.SetPrefixToken("u8");
+  valobj.GetValueAsCString(lldb::eFormatUnicode8, value);
+} else if (ElemType == StringPrinter::StringElementType::UTF16) {
+  options.SetPrefixToken("u");
+  valobj.GetValueAsCString(lldb::eFormatUnicode16, value);
+} else if (ElemType == StringPrinter::StringElementType::UTF32) {

ljmf00 wrote:
> labath wrote:
> > Maybe a helper function like `pair 
> > getElementTraits(StringElementType)` would reduce the repetition further? 
> > Or possibly it could be a static array indexed by `ElemType`.
> Done. I used `constexpr auto`, I'm not sure if `auto` is a practice here in 
> the LLVM codebase or I should explicitly specify the pair type.
I'd probably spell out the type (and it looks like you already did).


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

https://reviews.llvm.org/D112658

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


[Lldb-commits] [PATCH] D112632: [lldb] [Host/Terminal] Fix warnings with termios disabled

2021-10-29 Thread Michał Górny via Phabricator via lldb-commits
mgorny marked an inline comment as done.
mgorny added inline comments.



Comment at: lldb/source/Host/common/Terminal.cpp:39
+
 llvm::Expected Terminal::GetData() {
   if (!FileDescriptorIsValid())

thakis wrote:
> nit: should GetData() even exist if `!LLDB_ENABLE_TERMIOS`? Looks like it's 
> only called `#if LLDB_ENABLE_TERMIOS` now. Maybe the whole method definition 
> should be inside an ifdef.
> 
> If it should keep existing, either move the !FileDescriptorIsValid() check 
> into the #if inside it (imho preferred), or move all the callers of it 
> outside that #if. The current mix is a bit self-inconsistent.
I think the goal was to avoid checking `LLDB_ENABLE_TERMIOS` in the header 
file, though I'm not sure if it was an explicit goal or one I've implicitly 
assumed.

I've move the check inside for the time being. We can always change it later.


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

https://reviews.llvm.org/D112632

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


[Lldb-commits] [PATCH] D112632: [lldb] [Host/Terminal] Fix warnings with termios disabled

2021-10-29 Thread Michał Górny via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
mgorny marked an inline comment as done.
Closed by commit rGe9dcd8b37b73: [lldb] [Host/Terminal] Fix warnings with 
termios disabled (authored by mgorny).
Herald added a project: LLDB.

Changed prior to commit:
  https://reviews.llvm.org/D112632?vs=383112&id=383248#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112632

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

Index: lldb/source/Host/common/Terminal.cpp
===
--- lldb/source/Host/common/Terminal.cpp
+++ lldb/source/Host/common/Terminal.cpp
@@ -29,12 +29,19 @@
 
 bool Terminal::IsATerminal() const { return m_fd >= 0 && ::isatty(m_fd); }
 
+#if !LLDB_ENABLE_TERMIOS
+static llvm::Error termiosMissingError() {
+  return llvm::createStringError(llvm::inconvertibleErrorCode(),
+ "termios support missing in LLDB");
+}
+#endif
+
 llvm::Expected Terminal::GetData() {
+#if LLDB_ENABLE_TERMIOS
   if (!FileDescriptorIsValid())
 return llvm::createStringError(llvm::inconvertibleErrorCode(),
"invalid fd");
 
-#if LLDB_ENABLE_TERMIOS
   if (!IsATerminal())
 return llvm::createStringError(llvm::inconvertibleErrorCode(),
"fd not a terminal");
@@ -46,8 +53,7 @@
 "unable to get teletype attributes");
   return data;
 #else // !LLDB_ENABLE_TERMIOS
-  return llvm::createStringError(llvm::inconvertibleErrorCode(),
- "termios support missing in LLDB");
+  return termiosMissingError();
 #endif // LLDB_ENABLE_TERMIOS
 }
 
@@ -62,44 +68,48 @@
 "unable to set teletype attributes");
   return llvm::Error::success();
 #else // !LLDB_ENABLE_TERMIOS
-  llvm_unreachable("SetData() should not be called if !LLDB_ENABLE_TERMIOS");
+  return termiosMissingError();
 #endif // LLDB_ENABLE_TERMIOS
 }
 
 llvm::Error Terminal::SetEcho(bool enabled) {
+#if LLDB_ENABLE_TERMIOS
   llvm::Expected data = GetData();
   if (!data)
 return data.takeError();
 
-#if LLDB_ENABLE_TERMIOS
   struct termios &fd_termios = data->m_termios;
   fd_termios.c_lflag &= ~ECHO;
   if (enabled)
 fd_termios.c_lflag |= ECHO;
   return SetData(data.get());
+#else // !LLDB_ENABLE_TERMIOS
+  return termiosMissingError();
 #endif // LLDB_ENABLE_TERMIOS
 }
 
 llvm::Error Terminal::SetCanonical(bool enabled) {
+#if LLDB_ENABLE_TERMIOS
   llvm::Expected data = GetData();
   if (!data)
 return data.takeError();
 
-#if LLDB_ENABLE_TERMIOS
   struct termios &fd_termios = data->m_termios;
   fd_termios.c_lflag &= ~ICANON;
   if (enabled)
 fd_termios.c_lflag |= ICANON;
   return SetData(data.get());
+#else // !LLDB_ENABLE_TERMIOS
+  return termiosMissingError();
 #endif // LLDB_ENABLE_TERMIOS
 }
 
 llvm::Error Terminal::SetRaw() {
+#if LLDB_ENABLE_TERMIOS
   llvm::Expected data = GetData();
   if (!data)
 return data.takeError();
 
-#if LLDB_ENABLE_TERMIOS
   struct termios &fd_termios = data->m_termios;
   ::cfmakeraw(&fd_termios);
 
@@ -109,7 +119,9 @@
   fd_termios.c_cc[VTIME] = 0;
 
   return SetData(data.get());
-#endif // #if LLDB_ENABLE_TERMIOS
+#else // !LLDB_ENABLE_TERMIOS
+  return termiosMissingError();
+#endif // LLDB_ENABLE_TERMIOS
 }
 
 #if LLDB_ENABLE_TERMIOS
@@ -258,11 +270,11 @@
 #endif
 
 llvm::Error Terminal::SetBaudRate(unsigned int baud_rate) {
+#if LLDB_ENABLE_TERMIOS
   llvm::Expected data = GetData();
   if (!data)
 return data.takeError();
 
-#if LLDB_ENABLE_TERMIOS
   struct termios &fd_termios = data->m_termios;
   llvm::Optional val = baudRateToConst(baud_rate);
   if (!val) // invalid value
@@ -278,15 +290,17 @@
 std::error_code(errno, std::generic_category()),
 "setting output baud rate failed");
   return SetData(data.get());
-#endif // #if LLDB_ENABLE_TERMIOS
+#else // !LLDB_ENABLE_TERMIOS
+  return termiosMissingError();
+#endif // LLDB_ENABLE_TERMIOS
 }
 
 llvm::Error Terminal::SetStopBits(unsigned int stop_bits) {
+#if LLDB_ENABLE_TERMIOS
   llvm::Expected data = GetData();
   if (!data)
 return data.takeError();
 
-#if LLDB_ENABLE_TERMIOS
   struct termios &fd_termios = data->m_termios;
   switch (stop_bits) {
   case 1:
@@ -301,15 +315,17 @@
 "invalid stop bit count: %d (must be 1 or 2)", stop_bits);
   }
   return SetData(data.get());
-#endif // #if LLDB_ENABLE_TERMIOS
+#else // !LLDB_ENABLE_TERMIOS
+  return termiosMissingError();
+#endif // LLDB_ENABLE_TERMIOS
 }
 
 llvm::Error Terminal::SetParity(Terminal::Parity parity) {
+#if LLDB_ENABLE_TERMIOS
   llvm::Expected data = GetData();
   if (!data)
 return data.takeError();
 
-#if LLDB_ENABLE_TERMIOS
   struct termios &fd_termios = data->m_termios;
   fd_termios.c_cflag &= ~(
 #if defined(CMSPAR)
@@ -332,15 +348,17 @@
 }
   }
   return SetData(data.get());
-#endif // #if LLDB_ENABLE_TERMIOS
+#else // !L

[Lldb-commits] [lldb] e9dcd8b - [lldb] [Host/Terminal] Fix warnings with termios disabled

2021-10-29 Thread Michał Górny via lldb-commits

Author: Michał Górny
Date: 2021-10-29T09:58:09+02:00
New Revision: e9dcd8b37b73236f9c1db71c6afa057c181bb0c8

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

LOG: [lldb] [Host/Terminal] Fix warnings with termios disabled

Thanks to Nico Weber for the suggestion.

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

Added: 


Modified: 
lldb/source/Host/common/Terminal.cpp

Removed: 




diff  --git a/lldb/source/Host/common/Terminal.cpp 
b/lldb/source/Host/common/Terminal.cpp
index 1efd1bb9139d3..2a1c12e667bcf 100644
--- a/lldb/source/Host/common/Terminal.cpp
+++ b/lldb/source/Host/common/Terminal.cpp
@@ -29,12 +29,19 @@ struct Terminal::Data {
 
 bool Terminal::IsATerminal() const { return m_fd >= 0 && ::isatty(m_fd); }
 
+#if !LLDB_ENABLE_TERMIOS
+static llvm::Error termiosMissingError() {
+  return llvm::createStringError(llvm::inconvertibleErrorCode(),
+ "termios support missing in LLDB");
+}
+#endif
+
 llvm::Expected Terminal::GetData() {
+#if LLDB_ENABLE_TERMIOS
   if (!FileDescriptorIsValid())
 return llvm::createStringError(llvm::inconvertibleErrorCode(),
"invalid fd");
 
-#if LLDB_ENABLE_TERMIOS
   if (!IsATerminal())
 return llvm::createStringError(llvm::inconvertibleErrorCode(),
"fd not a terminal");
@@ -46,8 +53,7 @@ llvm::Expected Terminal::GetData() {
 "unable to get teletype attributes");
   return data;
 #else // !LLDB_ENABLE_TERMIOS
-  return llvm::createStringError(llvm::inconvertibleErrorCode(),
- "termios support missing in LLDB");
+  return termiosMissingError();
 #endif // LLDB_ENABLE_TERMIOS
 }
 
@@ -62,44 +68,48 @@ llvm::Error Terminal::SetData(const Terminal::Data &data) {
 "unable to set teletype attributes");
   return llvm::Error::success();
 #else // !LLDB_ENABLE_TERMIOS
-  llvm_unreachable("SetData() should not be called if !LLDB_ENABLE_TERMIOS");
+  return termiosMissingError();
 #endif // LLDB_ENABLE_TERMIOS
 }
 
 llvm::Error Terminal::SetEcho(bool enabled) {
+#if LLDB_ENABLE_TERMIOS
   llvm::Expected data = GetData();
   if (!data)
 return data.takeError();
 
-#if LLDB_ENABLE_TERMIOS
   struct termios &fd_termios = data->m_termios;
   fd_termios.c_lflag &= ~ECHO;
   if (enabled)
 fd_termios.c_lflag |= ECHO;
   return SetData(data.get());
+#else // !LLDB_ENABLE_TERMIOS
+  return termiosMissingError();
 #endif // LLDB_ENABLE_TERMIOS
 }
 
 llvm::Error Terminal::SetCanonical(bool enabled) {
+#if LLDB_ENABLE_TERMIOS
   llvm::Expected data = GetData();
   if (!data)
 return data.takeError();
 
-#if LLDB_ENABLE_TERMIOS
   struct termios &fd_termios = data->m_termios;
   fd_termios.c_lflag &= ~ICANON;
   if (enabled)
 fd_termios.c_lflag |= ICANON;
   return SetData(data.get());
+#else // !LLDB_ENABLE_TERMIOS
+  return termiosMissingError();
 #endif // LLDB_ENABLE_TERMIOS
 }
 
 llvm::Error Terminal::SetRaw() {
+#if LLDB_ENABLE_TERMIOS
   llvm::Expected data = GetData();
   if (!data)
 return data.takeError();
 
-#if LLDB_ENABLE_TERMIOS
   struct termios &fd_termios = data->m_termios;
   ::cfmakeraw(&fd_termios);
 
@@ -109,7 +119,9 @@ llvm::Error Terminal::SetRaw() {
   fd_termios.c_cc[VTIME] = 0;
 
   return SetData(data.get());
-#endif // #if LLDB_ENABLE_TERMIOS
+#else // !LLDB_ENABLE_TERMIOS
+  return termiosMissingError();
+#endif // LLDB_ENABLE_TERMIOS
 }
 
 #if LLDB_ENABLE_TERMIOS
@@ -258,11 +270,11 @@ static llvm::Optional baudRateToConst(unsigned 
int baud_rate) {
 #endif
 
 llvm::Error Terminal::SetBaudRate(unsigned int baud_rate) {
+#if LLDB_ENABLE_TERMIOS
   llvm::Expected data = GetData();
   if (!data)
 return data.takeError();
 
-#if LLDB_ENABLE_TERMIOS
   struct termios &fd_termios = data->m_termios;
   llvm::Optional val = baudRateToConst(baud_rate);
   if (!val) // invalid value
@@ -278,15 +290,17 @@ llvm::Error Terminal::SetBaudRate(unsigned int baud_rate) 
{
 std::error_code(errno, std::generic_category()),
 "setting output baud rate failed");
   return SetData(data.get());
-#endif // #if LLDB_ENABLE_TERMIOS
+#else // !LLDB_ENABLE_TERMIOS
+  return termiosMissingError();
+#endif // LLDB_ENABLE_TERMIOS
 }
 
 llvm::Error Terminal::SetStopBits(unsigned int stop_bits) {
+#if LLDB_ENABLE_TERMIOS
   llvm::Expected data = GetData();
   if (!data)
 return data.takeError();
 
-#if LLDB_ENABLE_TERMIOS
   struct termios &fd_termios = data->m_termios;
   switch (stop_bits) {
   case 1:
@@ -301,15 +315,17 @@ llvm::Error Terminal::SetStopBits(unsigned int stop_bits) 
{
 "invalid stop bit count: %d (must be 1 or 2)", stop_bits);
   }
   return SetData(data.get());
-#endif // #if LLDB_ENABLE_TERMIOS
+#else // !LLDB_ENABLE_TERMIOS
+  return 

[Lldb-commits] [lldb] 15b7df4 - [lldb] [Host/Terminal] Remove stale Config.h include from the header

2021-10-29 Thread Michał Górny via lldb-commits

Author: Michał Górny
Date: 2021-10-29T10:02:11+02:00
New Revision: 15b7df49ca1cf4712fd0407b21c490dae357d607

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

LOG: [lldb] [Host/Terminal] Remove stale Config.h include from the header

Added: 


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

Removed: 




diff  --git a/lldb/include/lldb/Host/Terminal.h 
b/lldb/include/lldb/Host/Terminal.h
index 81930cdf02361..8ff6d75657a74 100644
--- a/lldb/include/lldb/Host/Terminal.h
+++ b/lldb/include/lldb/Host/Terminal.h
@@ -10,7 +10,6 @@
 #define LLDB_HOST_TERMINAL_H
 #if defined(__cplusplus)
 
-#include "lldb/Host/Config.h"
 #include "lldb/lldb-private.h"
 #include "llvm/Support/Error.h"
 



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


[Lldb-commits] [PATCH] D112709: [lldb] Fix matchers for char array formatters

2021-10-29 Thread Pavel Labath via Phabricator via lldb-commits
labath added inline comments.



Comment at: 
lldb/test/API/functionalities/data-formatter/stringprinter/main.cpp:21
+MAKE_VARS();
+MAKE_VARS(const);
+

shafik wrote:
> It feels like writing out the decls by hand would have been quicker but 
> perhaps less satisfying...
:D


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112709

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


[Lldb-commits] [PATCH] D112785: Summary:

2021-10-29 Thread Danil Stefaniuc via Phabricator via lldb-commits
danilashtefan created this revision.
danilashtefan requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D112785

Files:
  lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/multiset/Makefile
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/multiset/TestDataFormatterGenericMultiSet.py
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/multiset/main.cpp
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/set/TestDataFormatterGenericSet.py
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/multiset/Makefile
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/multiset/TestDataFormatterLibcxxMultiSet.py
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/multiset/main.cpp

Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/multiset/main.cpp
===
--- lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/multiset/main.cpp
+++ /dev/null
@@ -1,58 +0,0 @@
-#include 
-#include 
-
-int g_the_foo = 0;
-
-int thefoo_rw(int arg = 1)
-{
-	if (arg < 0)
-		arg = 0;
-	if (!arg)
-		arg = 1;
-	g_the_foo += arg;
-	return g_the_foo;
-}
-
-void by_ref_and_ptr(std::multiset &ref, std::multiset *ptr)
-{
-// Stop here to check by ref and ptr
-return;
-} 
-
-int main()
-{
-std::multiset ii;
-thefoo_rw(1);  // Set break point at this line.
-	
-	ii.insert(0);
-	ii.insert(1);
-	ii.insert(2);
-	ii.insert(3);
-	ii.insert(4);
-	ii.insert(5);
-thefoo_rw(1);  // Set break point at this line.
-
-	ii.insert(6);
-	thefoo_rw(1);  // Set break point at this line.
-
-by_ref_and_ptr(ii, &ii);
-
-	ii.clear();
-	thefoo_rw(1);  // Set break point at this line.
-
-	std::multiset ss;
-	thefoo_rw(1);  // Set break point at this line.
-
-	ss.insert("a");
-	ss.insert("a very long string is right here");
-	thefoo_rw(1);  // Set break point at this line.
-
-	ss.insert("b");
-	ss.insert("c");
-	thefoo_rw(1);  // Set break point at this line.
-	
-	ss.erase("b");
-	thefoo_rw(1);  // Set break point at this line.
-
-return 0;
-}
Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/set/TestDataFormatterGenericSet.py
===
--- lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/set/TestDataFormatterGenericSet.py
+++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/set/TestDataFormatterGenericSet.py
@@ -12,7 +12,7 @@
 USE_LIBSTDCPP = "USE_LIBSTDCPP"
 USE_LIBCPP = "USE_LIBCPP"
 
-class LibcxxSetDataFormatterTestCase(TestBase):
+class GenericSetDataFormatterTestCase(TestBase):
 
 mydir = TestBase.compute_mydir(__file__)
 
Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/multiset/main.cpp
===
--- /dev/null
+++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/multiset/main.cpp
@@ -0,0 +1,55 @@
+#include 
+#include 
+
+int g_the_foo = 0;
+
+int thefoo_rw(int arg = 1) {
+  if (arg < 0)
+arg = 0;
+  if (!arg)
+arg = 1;
+  g_the_foo += arg;
+  return g_the_foo;
+}
+
+void by_ref_and_ptr(std::multiset &ref, std::multiset *ptr) {
+  // Stop here to check by ref and ptr
+  return;
+}
+
+int main() {
+  std::multiset ii;
+  thefoo_rw(1); // Set break point at this line.
+
+  ii.insert(0);
+  ii.insert(1);
+  ii.insert(2);
+  ii.insert(3);
+  ii.insert(4);
+  ii.insert(5);
+  thefoo_rw(1); // Set break point at this line.
+
+  ii.insert(6);
+  thefoo_rw(1); // Set break point at this line.
+
+  by_ref_and_ptr(ii, &ii);
+
+  ii.clear();
+  thefoo_rw(1); // Set break point at this line.
+
+  std::multiset ss;
+  thefoo_rw(1); // Set break point at this line.
+
+  ss.insert("a");
+  ss.insert("a very long string is right here");
+  thefoo_rw(1); // Set break point at this line.
+
+  ss.insert("b");
+  ss.insert("c");
+  thefoo_rw(1); // Set break point at this line.
+
+  ss.erase("b");
+  thefoo_rw(1); // Set break point at this line.
+
+  return 0;
+}
Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/multiset/TestDataFormatterGenericMultiSet.py
===
--- lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/multiset/TestDataFormatterGenericMultiSet.py
+++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/multiset/TestDataFormatterGenericMultiSet.py
@@ -9,8 +9,10 @@
 from lldbsuite.test.lldbtest import *
 from lldbsuite.test import lldbutil
 
+USE_LIBSTDCPP = "USE_LIBSTDCPP"
+USE_LIBCPP = "USE_LIBCPP"
 
-class LibcxxMultiSet

[Lldb-commits] [lldb] 3abd063 - [lldb] Make TypeSystemClang::GetFullyUnqualifiedType work for constant arrays

2021-10-29 Thread Pavel Labath via lldb-commits

Author: Pavel Labath
Date: 2021-10-29T11:13:59+02:00
New Revision: 3abd063fc793d2d56fc78287c61b73b2d7843bc5

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

LOG: [lldb] Make TypeSystemClang::GetFullyUnqualifiedType work for constant 
arrays

Unqualify (constant) arrays recursively, just like we do for pointers.
This allows for better pretty printer matching.

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

Added: 


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

lldb/test/API/functionalities/data-formatter/data-formatter-advanced/TestDataFormatterAdv.py

lldb/test/API/functionalities/data-formatter/data-formatter-advanced/main.cpp
lldb/unittests/Symbol/TestTypeSystemClang.cpp

Removed: 




diff  --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp 
b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
index 00daaad41a6e1..aa0a8086cb28c 100644
--- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -4238,7 +4238,13 @@ static clang::QualType 
GetFullyUnqualifiedType_Impl(clang::ASTContext *ast,
   if (qual_type->isPointerType())
 qual_type = ast->getPointerType(
 GetFullyUnqualifiedType_Impl(ast, qual_type->getPointeeType()));
-  else
+  else if (const ConstantArrayType *arr =
+   ast->getAsConstantArrayType(qual_type)) {
+qual_type = ast->getConstantArrayType(
+GetFullyUnqualifiedType_Impl(ast, arr->getElementType()),
+arr->getSize(), arr->getSizeExpr(), arr->getSizeModifier(),
+arr->getIndexTypeQualifiers().getAsOpaqueValue());
+  } else
 qual_type = qual_type.getUnqualifiedType();
   qual_type.removeLocalConst();
   qual_type.removeLocalRestrict();

diff  --git 
a/lldb/test/API/functionalities/data-formatter/data-formatter-advanced/TestDataFormatterAdv.py
 
b/lldb/test/API/functionalities/data-formatter/data-formatter-advanced/TestDataFormatterAdv.py
index 3906e48368054..f089038280e52 100644
--- 
a/lldb/test/API/functionalities/data-formatter/data-formatter-advanced/TestDataFormatterAdv.py
+++ 
b/lldb/test/API/functionalities/data-formatter/data-formatter-advanced/TestDataFormatterAdv.py
@@ -65,10 +65,12 @@ def cleanup():
 self.runCmd("type summary clear")
 
 self.runCmd(
-"type summary add --summary-string \"${var[]}\" -x 
\"int\\[[0-9]\\]")
+"type summary add --summary-string \"${var[]}\" -x 
\"^int\\[[0-9]\\]")
 
 self.expect("frame variable int_array",
 substrs=['1,2,3,4,5'])
+self.expect("frame variable const_int_array",
+substrs=['11,12,13,14,15'])
 
 # this will fail if we don't do [] as regex correctly
 self.runCmd(

diff  --git 
a/lldb/test/API/functionalities/data-formatter/data-formatter-advanced/main.cpp 
b/lldb/test/API/functionalities/data-formatter/data-formatter-advanced/main.cpp
index 857e2493e1a2d..e7a52fe73bd4c 100644
--- 
a/lldb/test/API/functionalities/data-formatter/data-formatter-advanced/main.cpp
+++ 
b/lldb/test/API/functionalities/data-formatter/data-formatter-advanced/main.cpp
@@ -144,7 +144,8 @@ int main (int argc, const char * argv[])
 cool_array[2].character = 'Q';
 
 int int_array[] = {1,2,3,4,5};
-
+const int const_int_array[] = {11, 12, 13, 14, 15};
+
 IWrapPointers wrapper;
 
 *int_array = -1;

diff  --git a/lldb/unittests/Symbol/TestTypeSystemClang.cpp 
b/lldb/unittests/Symbol/TestTypeSystemClang.cpp
index 21ae5b01b0cc9..5b1154d2cd8b9 100644
--- a/lldb/unittests/Symbol/TestTypeSystemClang.cpp
+++ b/lldb/unittests/Symbol/TestTypeSystemClang.cpp
@@ -912,6 +912,32 @@ TEST_F(TestTypeSystemClang, AddMethodToObjCObjectType) {
   EXPECT_EQ(method->getDeclName().getObjCSelector().getAsString(), "foo");
 }
 
+TEST_F(TestTypeSystemClang, GetFullyUnqualifiedType) {
+  CompilerType bool_ = m_ast->GetBasicType(eBasicTypeBool);
+  CompilerType cv_bool = bool_.AddConstModifier().AddVolatileModifier();
+
+  // const volatile bool -> bool
+  EXPECT_EQ(bool_, cv_bool.GetFullyUnqualifiedType());
+
+  // const volatile bool[47] -> bool[47]
+  EXPECT_EQ(bool_.GetArrayType(47),
+cv_bool.GetArrayType(47).GetFullyUnqualifiedType());
+
+  // const volatile bool[47][42] -> bool[47][42]
+  EXPECT_EQ(
+  bool_.GetArrayType(42).GetArrayType(47),
+  cv_bool.GetArrayType(42).GetArrayType(47).GetFullyUnqualifiedType());
+
+  // const volatile bool * -> bool *
+  EXPECT_EQ(bool_.GetPointerType(),
+cv_bool.GetPointerType().GetFullyUnqualifiedType());
+
+  // const volatile bool *[47] -> bool *[47]
+  EXPECT_EQ(
+  bool_.GetPointerType().GetArrayType(47),
+  cv_bool.GetPointerType().GetArrayType(47).GetFu

[Lldb-commits] [PATCH] D112708: [lldb] Make TypeSystemClang::GetFullyUnqualifiedType work for constant arrays

2021-10-29 Thread Pavel Labath via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
labath marked an inline comment as done.
Closed by commit rG3abd063fc793: [lldb] Make 
TypeSystemClang::GetFullyUnqualifiedType work for constant arrays (authored by 
labath).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112708

Files:
  lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
  
lldb/test/API/functionalities/data-formatter/data-formatter-advanced/TestDataFormatterAdv.py
  lldb/test/API/functionalities/data-formatter/data-formatter-advanced/main.cpp
  lldb/unittests/Symbol/TestTypeSystemClang.cpp


Index: lldb/unittests/Symbol/TestTypeSystemClang.cpp
===
--- lldb/unittests/Symbol/TestTypeSystemClang.cpp
+++ lldb/unittests/Symbol/TestTypeSystemClang.cpp
@@ -912,6 +912,32 @@
   EXPECT_EQ(method->getDeclName().getObjCSelector().getAsString(), "foo");
 }
 
+TEST_F(TestTypeSystemClang, GetFullyUnqualifiedType) {
+  CompilerType bool_ = m_ast->GetBasicType(eBasicTypeBool);
+  CompilerType cv_bool = bool_.AddConstModifier().AddVolatileModifier();
+
+  // const volatile bool -> bool
+  EXPECT_EQ(bool_, cv_bool.GetFullyUnqualifiedType());
+
+  // const volatile bool[47] -> bool[47]
+  EXPECT_EQ(bool_.GetArrayType(47),
+cv_bool.GetArrayType(47).GetFullyUnqualifiedType());
+
+  // const volatile bool[47][42] -> bool[47][42]
+  EXPECT_EQ(
+  bool_.GetArrayType(42).GetArrayType(47),
+  cv_bool.GetArrayType(42).GetArrayType(47).GetFullyUnqualifiedType());
+
+  // const volatile bool * -> bool *
+  EXPECT_EQ(bool_.GetPointerType(),
+cv_bool.GetPointerType().GetFullyUnqualifiedType());
+
+  // const volatile bool *[47] -> bool *[47]
+  EXPECT_EQ(
+  bool_.GetPointerType().GetArrayType(47),
+  cv_bool.GetPointerType().GetArrayType(47).GetFullyUnqualifiedType());
+}
+
 TEST(TestScratchTypeSystemClang, InferSubASTFromLangOpts) {
   LangOptions lang_opts;
   EXPECT_EQ(
Index: 
lldb/test/API/functionalities/data-formatter/data-formatter-advanced/main.cpp
===
--- 
lldb/test/API/functionalities/data-formatter/data-formatter-advanced/main.cpp
+++ 
lldb/test/API/functionalities/data-formatter/data-formatter-advanced/main.cpp
@@ -144,7 +144,8 @@
 cool_array[2].character = 'Q';
 
 int int_array[] = {1,2,3,4,5};
-
+const int const_int_array[] = {11, 12, 13, 14, 15};
+
 IWrapPointers wrapper;
 
 *int_array = -1;
Index: 
lldb/test/API/functionalities/data-formatter/data-formatter-advanced/TestDataFormatterAdv.py
===
--- 
lldb/test/API/functionalities/data-formatter/data-formatter-advanced/TestDataFormatterAdv.py
+++ 
lldb/test/API/functionalities/data-formatter/data-formatter-advanced/TestDataFormatterAdv.py
@@ -65,10 +65,12 @@
 self.runCmd("type summary clear")
 
 self.runCmd(
-"type summary add --summary-string \"${var[]}\" -x 
\"int\\[[0-9]\\]")
+"type summary add --summary-string \"${var[]}\" -x 
\"^int\\[[0-9]\\]")
 
 self.expect("frame variable int_array",
 substrs=['1,2,3,4,5'])
+self.expect("frame variable const_int_array",
+substrs=['11,12,13,14,15'])
 
 # this will fail if we don't do [] as regex correctly
 self.runCmd(
Index: lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
===
--- lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -4238,7 +4238,13 @@
   if (qual_type->isPointerType())
 qual_type = ast->getPointerType(
 GetFullyUnqualifiedType_Impl(ast, qual_type->getPointeeType()));
-  else
+  else if (const ConstantArrayType *arr =
+   ast->getAsConstantArrayType(qual_type)) {
+qual_type = ast->getConstantArrayType(
+GetFullyUnqualifiedType_Impl(ast, arr->getElementType()),
+arr->getSize(), arr->getSizeExpr(), arr->getSizeModifier(),
+arr->getIndexTypeQualifiers().getAsOpaqueValue());
+  } else
 qual_type = qual_type.getUnqualifiedType();
   qual_type.removeLocalConst();
   qual_type.removeLocalRestrict();


Index: lldb/unittests/Symbol/TestTypeSystemClang.cpp
===
--- lldb/unittests/Symbol/TestTypeSystemClang.cpp
+++ lldb/unittests/Symbol/TestTypeSystemClang.cpp
@@ -912,6 +912,32 @@
   EXPECT_EQ(method->getDeclName().getObjCSelector().getAsString(), "foo");
 }
 
+TEST_F(TestTypeSystemClang, GetFullyUnqualifiedType) {
+  CompilerType bool_ = m_ast->GetBasicType(eBasicTypeBool);
+  CompilerType cv_bool = bool_.AddConstModifier().AddVolatileModifier();
+
+  // const volatile bool -> bool
+  EXPECT_EQ(bool_, cv_bool.GetFu

[Lldb-commits] [PATCH] D112658: [lldb] Refactor C/C++ string and char summary providers

2021-10-29 Thread Pavel Labath via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG5e316012d0ac: [lldb] Refactor C/C++ string and char summary 
providers (authored by ljmf00, committed by labath).

Changed prior to commit:
  https://reviews.llvm.org/D112658?vs=383121&id=383267#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112658

Files:
  lldb/source/Plugins/Language/CPlusPlus/CxxStringTypes.cpp

Index: lldb/source/Plugins/Language/CPlusPlus/CxxStringTypes.cpp
===
--- lldb/source/Plugins/Language/CPlusPlus/CxxStringTypes.cpp
+++ lldb/source/Plugins/Language/CPlusPlus/CxxStringTypes.cpp
@@ -32,8 +32,24 @@
 using namespace lldb_private;
 using namespace lldb_private::formatters;
 
-bool lldb_private::formatters::Char8StringSummaryProvider(
-ValueObject &valobj, Stream &stream, const TypeSummaryOptions &) {
+using StringElementType = StringPrinter::StringElementType;
+
+static constexpr std::pair
+getElementTraits(StringElementType ElemType) {
+  switch (ElemType) {
+  case StringElementType::UTF8:
+return std::make_pair("u8", lldb::eFormatUnicode8);
+  case StringElementType::UTF16:
+return std::make_pair("u", lldb::eFormatUnicode16);
+  case StringElementType::UTF32:
+return std::make_pair("U", lldb::eFormatUnicode32);
+  default:
+return std::make_pair(nullptr, lldb::eFormatInvalid);
+  }
+}
+
+template 
+static bool CharStringSummaryProvider(ValueObject &valobj, Stream &stream) {
   ProcessSP process_sp = valobj.GetProcessSP();
   if (!process_sp)
 return false;
@@ -46,65 +62,55 @@
   options.SetLocation(valobj_addr);
   options.SetProcessSP(process_sp);
   options.SetStream(&stream);
-  options.SetPrefixToken("u8");
+  options.SetPrefixToken(getElementTraits(ElemType).first);
 
-  if (!StringPrinter::ReadStringAndDumpToStream<
-  StringPrinter::StringElementType::UTF8>(options)) {
+  if (!StringPrinter::ReadStringAndDumpToStream(options))
 stream.Printf("Summary Unavailable");
-return true;
-  }
 
   return true;
 }
 
-bool lldb_private::formatters::Char16StringSummaryProvider(
-ValueObject &valobj, Stream &stream, const TypeSummaryOptions &) {
-  ProcessSP process_sp = valobj.GetProcessSP();
-  if (!process_sp)
-return false;
+template 
+static bool CharSummaryProvider(ValueObject &valobj, Stream &stream) {
+  DataExtractor data;
+  Status error;
+  valobj.GetData(data, error);
 
-  lldb::addr_t valobj_addr = GetArrayAddressOrPointerValue(valobj);
-  if (valobj_addr == 0 || valobj_addr == LLDB_INVALID_ADDRESS)
+  if (error.Fail())
 return false;
 
-  StringPrinter::ReadStringAndDumpToStreamOptions options(valobj);
-  options.SetLocation(valobj_addr);
-  options.SetProcessSP(process_sp);
-  options.SetStream(&stream);
-  options.SetPrefixToken("u");
+  std::string value;
+  StringPrinter::ReadBufferAndDumpToStreamOptions options(valobj);
 
-  if (!StringPrinter::ReadStringAndDumpToStream<
-  StringPrinter::StringElementType::UTF16>(options)) {
-stream.Printf("Summary Unavailable");
-return true;
-  }
+  constexpr auto ElemTraits = getElementTraits(ElemType);
+  valobj.GetValueAsCString(ElemTraits.second, value);
 
-  return true;
-}
+  if (!value.empty())
+stream.Printf("%s ", value.c_str());
 
-bool lldb_private::formatters::Char32StringSummaryProvider(
-ValueObject &valobj, Stream &stream, const TypeSummaryOptions &) {
-  ProcessSP process_sp = valobj.GetProcessSP();
-  if (!process_sp)
-return false;
+  options.SetData(std::move(data));
+  options.SetStream(&stream);
+  options.SetPrefixToken(ElemTraits.first);
+  options.SetQuote('\'');
+  options.SetSourceSize(1);
+  options.SetBinaryZeroIsTerminator(false);
 
-  lldb::addr_t valobj_addr = GetArrayAddressOrPointerValue(valobj);
-  if (valobj_addr == 0 || valobj_addr == LLDB_INVALID_ADDRESS)
-return false;
+  return StringPrinter::ReadBufferAndDumpToStream(options);
+}
 
-  StringPrinter::ReadStringAndDumpToStreamOptions options(valobj);
-  options.SetLocation(valobj_addr);
-  options.SetProcessSP(process_sp);
-  options.SetStream(&stream);
-  options.SetPrefixToken("U");
+bool lldb_private::formatters::Char8StringSummaryProvider(
+ValueObject &valobj, Stream &stream, const TypeSummaryOptions &) {
+  return CharStringSummaryProvider(valobj, stream);
+}
 
-  if (!StringPrinter::ReadStringAndDumpToStream<
-  StringPrinter::StringElementType::UTF32>(options)) {
-stream.Printf("Summary Unavailable");
-return true;
-  }
+bool lldb_private::formatters::Char16StringSummaryProvider(
+ValueObject &valobj, Stream &stream, const TypeSummaryOptions &) {
+  return CharStringSummaryProvider(valobj, stream);
+}
 
-  return true;
+bool lldb_private::formatters::Char32StringSummaryProvider(
+ValueObject &valobj, Stream &stream, const TypeSummaryOptions &) {
+  return CharStringSummaryProvider(va

[Lldb-commits] [lldb] 5e31601 - [lldb] Refactor C/C++ string and char summary providers

2021-10-29 Thread Pavel Labath via lldb-commits

Author: Luís Ferreira
Date: 2021-10-29T11:22:02+02:00
New Revision: 5e316012d0ac2f621b906ef7170696ec83f02409

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

LOG: [lldb] Refactor C/C++ string and char summary providers

This patch refactors C/C++ formatters to avoid repetitive code by using 
templates.

Reviewed By: labath

Differential Revision: https://reviews.llvm.org/D112658
Signed-off-by: Luís Ferreira 

Added: 


Modified: 
lldb/source/Plugins/Language/CPlusPlus/CxxStringTypes.cpp

Removed: 




diff  --git a/lldb/source/Plugins/Language/CPlusPlus/CxxStringTypes.cpp 
b/lldb/source/Plugins/Language/CPlusPlus/CxxStringTypes.cpp
index 45c0cd213e0e6..132306359d518 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/CxxStringTypes.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/CxxStringTypes.cpp
@@ -32,8 +32,24 @@ using namespace lldb;
 using namespace lldb_private;
 using namespace lldb_private::formatters;
 
-bool lldb_private::formatters::Char8StringSummaryProvider(
-ValueObject &valobj, Stream &stream, const TypeSummaryOptions &) {
+using StringElementType = StringPrinter::StringElementType;
+
+static constexpr std::pair
+getElementTraits(StringElementType ElemType) {
+  switch (ElemType) {
+  case StringElementType::UTF8:
+return std::make_pair("u8", lldb::eFormatUnicode8);
+  case StringElementType::UTF16:
+return std::make_pair("u", lldb::eFormatUnicode16);
+  case StringElementType::UTF32:
+return std::make_pair("U", lldb::eFormatUnicode32);
+  default:
+return std::make_pair(nullptr, lldb::eFormatInvalid);
+  }
+}
+
+template 
+static bool CharStringSummaryProvider(ValueObject &valobj, Stream &stream) {
   ProcessSP process_sp = valobj.GetProcessSP();
   if (!process_sp)
 return false;
@@ -46,65 +62,55 @@ bool lldb_private::formatters::Char8StringSummaryProvider(
   options.SetLocation(valobj_addr);
   options.SetProcessSP(process_sp);
   options.SetStream(&stream);
-  options.SetPrefixToken("u8");
+  options.SetPrefixToken(getElementTraits(ElemType).first);
 
-  if (!StringPrinter::ReadStringAndDumpToStream<
-  StringPrinter::StringElementType::UTF8>(options)) {
+  if (!StringPrinter::ReadStringAndDumpToStream(options))
 stream.Printf("Summary Unavailable");
-return true;
-  }
 
   return true;
 }
 
-bool lldb_private::formatters::Char16StringSummaryProvider(
-ValueObject &valobj, Stream &stream, const TypeSummaryOptions &) {
-  ProcessSP process_sp = valobj.GetProcessSP();
-  if (!process_sp)
-return false;
+template 
+static bool CharSummaryProvider(ValueObject &valobj, Stream &stream) {
+  DataExtractor data;
+  Status error;
+  valobj.GetData(data, error);
 
-  lldb::addr_t valobj_addr = GetArrayAddressOrPointerValue(valobj);
-  if (valobj_addr == 0 || valobj_addr == LLDB_INVALID_ADDRESS)
+  if (error.Fail())
 return false;
 
-  StringPrinter::ReadStringAndDumpToStreamOptions options(valobj);
-  options.SetLocation(valobj_addr);
-  options.SetProcessSP(process_sp);
-  options.SetStream(&stream);
-  options.SetPrefixToken("u");
+  std::string value;
+  StringPrinter::ReadBufferAndDumpToStreamOptions options(valobj);
 
-  if (!StringPrinter::ReadStringAndDumpToStream<
-  StringPrinter::StringElementType::UTF16>(options)) {
-stream.Printf("Summary Unavailable");
-return true;
-  }
+  constexpr auto ElemTraits = getElementTraits(ElemType);
+  valobj.GetValueAsCString(ElemTraits.second, value);
 
-  return true;
-}
+  if (!value.empty())
+stream.Printf("%s ", value.c_str());
 
-bool lldb_private::formatters::Char32StringSummaryProvider(
-ValueObject &valobj, Stream &stream, const TypeSummaryOptions &) {
-  ProcessSP process_sp = valobj.GetProcessSP();
-  if (!process_sp)
-return false;
+  options.SetData(std::move(data));
+  options.SetStream(&stream);
+  options.SetPrefixToken(ElemTraits.first);
+  options.SetQuote('\'');
+  options.SetSourceSize(1);
+  options.SetBinaryZeroIsTerminator(false);
 
-  lldb::addr_t valobj_addr = GetArrayAddressOrPointerValue(valobj);
-  if (valobj_addr == 0 || valobj_addr == LLDB_INVALID_ADDRESS)
-return false;
+  return StringPrinter::ReadBufferAndDumpToStream(options);
+}
 
-  StringPrinter::ReadStringAndDumpToStreamOptions options(valobj);
-  options.SetLocation(valobj_addr);
-  options.SetProcessSP(process_sp);
-  options.SetStream(&stream);
-  options.SetPrefixToken("U");
+bool lldb_private::formatters::Char8StringSummaryProvider(
+ValueObject &valobj, Stream &stream, const TypeSummaryOptions &) {
+  return CharStringSummaryProvider(valobj, stream);
+}
 
-  if (!StringPrinter::ReadStringAndDumpToStream<
-  StringPrinter::StringElementType::UTF32>(options)) {
-stream.Printf("Summary Unavailable");
-return true;
-  }
+bool lldb_

[Lldb-commits] [PATCH] D112658: [lldb] Refactor C/C++ string and char summary providers

2021-10-29 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

In D112658#3095656 , @labath wrote:

> Do you have commit access, or should I check this in for you (I can also fix 
> up the formatting in that case)?

Raphael tells me you don't, so I've committed this as rG5e31601 
.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112658

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


[Lldb-commits] [PATCH] D112212: [lldb/test] Print build commands in trace mode

2021-10-29 Thread Pavel Labath via Phabricator via lldb-commits
labath marked 2 inline comments as done.
labath added inline comments.



Comment at: lldb/test/API/test_utils/TestBaseTest.py:1
+"""
+Test TestBase test functions.

teemperor wrote:
> Could we move this file into `test_utils/build` or some other subdir? Then I 
> can also make the few other 'test'-tests their own subdir of `test_utils` 
> (which seems like a good place for all of this).
I've created a `base` folder for the `Base` class. It could either be a root of 
an additional hierarchy or we can shove all Base tests there. I'd hope it's the 
latter, as one can go quite far by just passing CXX_SOURCE to the make 
invocations, and these aren't particularly complex tests or inferiors.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112212

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


[Lldb-commits] [lldb] ac73f56 - [lldb] Remove forgotten FIXME on CPlusPlus formatters

2021-10-29 Thread Raphael Isemann via lldb-commits

Author: Luís Ferreira
Date: 2021-10-29T11:32:40+02:00
New Revision: ac73f567cffb663712e937051b0e81a82488698b

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

LOG: [lldb] Remove forgotten FIXME on CPlusPlus formatters

The patch [1] introduced this FIXME but ended up not being removed when fixed.

[1]: 
https://github.com/llvm/llvm-project/commit/f68df12fb039d5177e34f4541fa242b891949db6

Signed-off-by: Luís Ferreira 

Reviewed By: teemperor

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

Added: 


Modified: 
lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp

Removed: 




diff  --git a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp 
b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
index 875706edd77e..626c5a5a8282 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
@@ -1014,8 +1014,6 @@ static void LoadSystemFormatters(lldb::TypeCategoryImplSP 
cpp_category_sp) {
   .SetShowMembersOneLiner(false)
   .SetHideItemNames(false);
 
-  // FIXME because of a bug in the FormattersContainer we need to add a summary
-  // for both X* and const X* ()
   AddCXXSummary(
   cpp_category_sp, lldb_private::formatters::Char8StringSummaryProvider,
   "char8_t * summary provider", ConstString("char8_t *"), string_flags);



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


[Lldb-commits] [PATCH] D112586: [lldb] Remove forgotten FIXME on CPlusPlus formatters

2021-10-29 Thread Raphael Isemann via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGac73f567cffb: [lldb] Remove forgotten FIXME on CPlusPlus 
formatters (authored by ljmf00, committed by teemperor).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112586

Files:
  lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp


Index: lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
===
--- lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
+++ lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
@@ -1014,8 +1014,6 @@
   .SetShowMembersOneLiner(false)
   .SetHideItemNames(false);
 
-  // FIXME because of a bug in the FormattersContainer we need to add a summary
-  // for both X* and const X* ()
   AddCXXSummary(
   cpp_category_sp, lldb_private::formatters::Char8StringSummaryProvider,
   "char8_t * summary provider", ConstString("char8_t *"), string_flags);


Index: lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
===
--- lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
+++ lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
@@ -1014,8 +1014,6 @@
   .SetShowMembersOneLiner(false)
   .SetHideItemNames(false);
 
-  // FIXME because of a bug in the FormattersContainer we need to add a summary
-  // for both X* and const X* ()
   AddCXXSummary(
   cpp_category_sp, lldb_private::formatters::Char8StringSummaryProvider,
   "char8_t * summary provider", ConstString("char8_t *"), string_flags);
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] eee887e - [lldb/test] Print build commands in trace mode

2021-10-29 Thread Pavel Labath via lldb-commits

Author: Pavel Labath
Date: 2021-10-29T11:33:31+02:00
New Revision: eee887e03551685bc03657a61c2f36ff1b522919

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

LOG: [lldb/test] Print build commands in trace mode

Running tests with -t prints all lldb commands being run. It makes sense
to print all the build commands as well.

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

Added: 
lldb/test/API/test_utils/base/Makefile
lldb/test/API/test_utils/base/TestBaseTest.py
lldb/test/API/test_utils/base/return0.cpp

Modified: 
lldb/packages/Python/lldbsuite/test/builders/builder.py
lldb/packages/Python/lldbsuite/test/lldbtest.py
lldb/packages/Python/lldbsuite/test_event/build_exception.py

Removed: 




diff  --git a/lldb/packages/Python/lldbsuite/test/builders/builder.py 
b/lldb/packages/Python/lldbsuite/test/builders/builder.py
index 8b17b585ae6c8..98057066f3f3c 100644
--- a/lldb/packages/Python/lldbsuite/test/builders/builder.py
+++ b/lldb/packages/Python/lldbsuite/test/builders/builder.py
@@ -82,15 +82,6 @@ def setOrAppendVariable(k, v):
 
 return cmdline
 
-def runBuildCommands(self, commands):
-try:
-lldbtest.system(commands)
-except subprocess.CalledProcessError as called_process_error:
-# Convert to a build-specific error.
-# We don't do that in lldbtest.system() since that
-# is more general purpose.
-raise build_exception.BuildError(called_process_error)
-
 def getArchSpec(self, architecture):
 """
 Helper function to return the key-value string to specify the 
architecture
@@ -140,11 +131,11 @@ def _getDebugInfoArgs(self, debug_info):
 return ["MAKE_DSYM=NO", "MAKE_GMODULES=YES"]
 return None
 
-def build(self, debug_info, architecture=None, compiler=None,
+def getBuildCommand(self, debug_info, architecture=None, compiler=None,
 dictionary=None, testdir=None, testname=None):
 debug_info_args = self._getDebugInfoArgs(debug_info)
 if debug_info_args is None:
-return False
+return None
 
 command_parts = [
 self.getMake(testdir, testname), debug_info_args, ["all"],
@@ -154,8 +145,7 @@ def build(self, debug_info, architecture=None, 
compiler=None,
 self.getCmdLine(dictionary)]
 command = list(itertools.chain(*command_parts))
 
-self.runBuildCommands([command])
-return True
+return command
 
 def cleanup(self, dictionary=None):
 """Perform a platform-specific cleanup after the test."""

diff  --git a/lldb/packages/Python/lldbsuite/test/lldbtest.py 
b/lldb/packages/Python/lldbsuite/test/lldbtest.py
index d8940b996f8dc..92d7887e670ac 100644
--- a/lldb/packages/Python/lldbsuite/test/lldbtest.py
+++ b/lldb/packages/Python/lldbsuite/test/lldbtest.py
@@ -45,6 +45,7 @@
 import re
 import shutil
 import signal
+import shlex
 from subprocess import *
 import sys
 import time
@@ -68,6 +69,7 @@
 from lldbsuite.support import encoded_file
 from lldbsuite.support import funcutils
 from lldbsuite.test.builders import get_builder
+from lldbsuite.test_event import build_exception
 
 # See also dotest.parseOptionsAndInitTestdirs(), where the environment 
variables
 # LLDB_COMMAND_TRACE is set from '-t' option.
@@ -470,61 +472,6 @@ def launch(self, executable, args, extra_env):
 def terminate(self):
 lldb.remote_platform.Kill(self._pid)
 
-# From 2.7's subprocess.check_output() convenience function.
-# Return a tuple (stdoutdata, stderrdata).
-
-
-def system(commands, **kwargs):
-r"""Run an os command with arguments and return its output as a byte 
string.
-
-If the exit code was non-zero it raises a CalledProcessError.  The
-CalledProcessError object will have the return code in the returncode
-attribute and output in the output attribute.
-
-The arguments are the same as for the Popen constructor.  Example:
-
->>> check_output(["ls", "-l", "/dev/null"])
-'crw-rw-rw- 1 root root 1, 3 Oct 18  2007 /dev/null\n'
-
-The stdout argument is not allowed as it is used internally.
-To capture standard error in the result, use stderr=STDOUT.
-
->>> check_output(["/bin/sh", "-c",
-...   "ls -l non_existent_file ; exit 0"],
-...  stderr=STDOUT)
-'ls: non_existent_file: No such file or directory\n'
-"""
-
-output = ""
-error = ""
-for shellCommand in commands:
-if 'stdout' in kwargs:
-raise ValueError(
-'stdout argument not allowed, it will be overridden.')
-process = Popen(
-shellCommand,
-stdout=PIPE,
-stderr=STDOUT,
-**kwargs)
-  

[Lldb-commits] [PATCH] D112212: [lldb/test] Print build commands in trace mode

2021-10-29 Thread Pavel Labath via Phabricator via lldb-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
labath marked an inline comment as done.
Closed by commit rGeee887e03551: [lldb/test] Print build commands in trace mode 
(authored by labath).

Changed prior to commit:
  https://reviews.llvm.org/D112212?vs=381500&id=383269#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112212

Files:
  lldb/packages/Python/lldbsuite/test/builders/builder.py
  lldb/packages/Python/lldbsuite/test/lldbtest.py
  lldb/packages/Python/lldbsuite/test_event/build_exception.py
  lldb/test/API/test_utils/base/Makefile
  lldb/test/API/test_utils/base/TestBaseTest.py
  lldb/test/API/test_utils/base/return0.cpp

Index: lldb/test/API/test_utils/base/return0.cpp
===
--- /dev/null
+++ lldb/test/API/test_utils/base/return0.cpp
@@ -0,0 +1 @@
+int main() { return 0; }
Index: lldb/test/API/test_utils/base/TestBaseTest.py
===
--- /dev/null
+++ lldb/test/API/test_utils/base/TestBaseTest.py
@@ -0,0 +1,35 @@
+"""
+Test TestBase test functions.
+"""
+
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test_event import build_exception
+import six
+
+class TestBuildMethod(Base):
+
+mydir = TestBase.compute_mydir(__file__)
+
+def setUp(self):
+super().setUp()
+self._traces = []
+self.traceAlways = True
+
+# override the parent trace method
+def trace(self, *args, **kwargs):
+io = six.StringIO()
+print(*args, file=io, **kwargs)
+self._traces.append(io.getvalue())
+
+def test_build_fails_helpfully(self):
+try:
+self.build(dictionary={"CXX_SOURCES": "nonexisting-file.cpp"})
+except build_exception.BuildError as e:
+self.assertIn("nonexisting-file.cpp", str(e))
+else:
+self.fail("BuildError not raised!")
+
+def test_build_logs_traces(self):
+self.build(dictionary={"CXX_SOURCES": "return0.cpp"})
+self.assertIn("CXX_SOURCES", self._traces[0])
+self.assertIn("return0.o", self._traces[1])
Index: lldb/test/API/test_utils/base/Makefile
===
--- /dev/null
+++ lldb/test/API/test_utils/base/Makefile
@@ -0,0 +1 @@
+include Makefile.rules
Index: lldb/packages/Python/lldbsuite/test_event/build_exception.py
===
--- lldb/packages/Python/lldbsuite/test_event/build_exception.py
+++ lldb/packages/Python/lldbsuite/test_event/build_exception.py
@@ -1,10 +1,11 @@
+import shlex
+
 class BuildError(Exception):
 
 def __init__(self, called_process_error):
 super(BuildError, self).__init__("Error when building test subject")
-self.command = called_process_error.lldb_extensions.get(
-"command", "")
-self.build_error = called_process_error.lldb_extensions["combined_output"]
+self.command = shlex.join(called_process_error.cmd)
+self.build_error = called_process_error.output
 
 def __str__(self):
 return self.format_build_error(self.command, self.build_error)
@@ -12,4 +13,4 @@
 @staticmethod
 def format_build_error(command, command_output):
 return "Error when building test subject.\n\nBuild Command:\n{}\n\nBuild Command Output:\n{}".format(
-command, command_output.decode("utf-8", errors='ignore'))
+command, command_output)
Index: lldb/packages/Python/lldbsuite/test/lldbtest.py
===
--- lldb/packages/Python/lldbsuite/test/lldbtest.py
+++ lldb/packages/Python/lldbsuite/test/lldbtest.py
@@ -45,6 +45,7 @@
 import re
 import shutil
 import signal
+import shlex
 from subprocess import *
 import sys
 import time
@@ -68,6 +69,7 @@
 from lldbsuite.support import encoded_file
 from lldbsuite.support import funcutils
 from lldbsuite.test.builders import get_builder
+from lldbsuite.test_event import build_exception
 
 # See also dotest.parseOptionsAndInitTestdirs(), where the environment variables
 # LLDB_COMMAND_TRACE is set from '-t' option.
@@ -470,61 +472,6 @@
 def terminate(self):
 lldb.remote_platform.Kill(self._pid)
 
-# From 2.7's subprocess.check_output() convenience function.
-# Return a tuple (stdoutdata, stderrdata).
-
-
-def system(commands, **kwargs):
-r"""Run an os command with arguments and return its output as a byte string.
-
-If the exit code was non-zero it raises a CalledProcessError.  The
-CalledProcessError object will have the return code in the returncode
-attribute and output in the output attribute.
-
-The arguments are the same as for the Popen constructor.  Example:
-
->>> check_output(["ls", "-l", "/dev/null"])
-'crw-rw-rw- 1 roo

[Lldb-commits] [PATCH] D111899: LLDB tests modification for hardware breakpoints

2021-10-29 Thread Nikolay Chokoev via Phabricator via lldb-commits
georgiev updated this revision to Diff 383282.

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

https://reviews.llvm.org/D111899

Files:
  lldb/packages/Python/lldbsuite/test/lldbutil.py
  lldb/test/API/commands/apropos/with-process/TestAproposWithProcess.py
  lldb/test/API/commands/command/nested_alias/TestNestedAlias.py
  
lldb/test/API/functionalities/breakpoint/breakpoint_command/TestBreakpointCommand.py
  
lldb/test/API/functionalities/breakpoint/breakpoint_ignore_count/TestBreakpointIgnoreCount.py
  
lldb/test/API/functionalities/breakpoint/breakpoint_locations/TestBreakpointLocations.py
  lldb/test/API/functionalities/dead-strip/TestDeadStrip.py
  lldb/test/API/functionalities/load_unload/TestLoadUnload.py
  lldb/test/API/functionalities/memory/cache/TestMemoryCache.py
  lldb/test/API/functionalities/memory/find/TestMemoryFind.py
  lldb/test/API/functionalities/memory/read/TestMemoryRead.py
  lldb/test/API/lang/c/anonymous/TestAnonymous.py
  lldb/test/API/lang/c/array_types/TestArrayTypes.py
  lldb/test/API/lang/c/conflicting-symbol/TestConflictingSymbol.py
  lldb/test/API/lang/c/const_variables/TestConstVariables.py
  lldb/test/API/lang/c/enum_types/TestEnumTypes.py
  lldb/test/API/lang/c/forward/TestForwardDeclaration.py
  lldb/test/API/lang/c/function_types/TestFunctionTypes.py
  lldb/test/API/lang/c/global_variables/TestGlobalVariables.py
  lldb/test/API/lang/c/local_variables/TestLocalVariables.py
  lldb/test/API/lang/c/modules/TestCModules.py
  lldb/test/API/lang/c/register_variables/TestRegisterVariables.py
  lldb/test/API/lang/c/set_values/TestSetValues.py
  lldb/test/API/lang/c/shared_lib/TestSharedLib.py
  
lldb/test/API/lang/c/shared_lib_stripped_symbols/TestSharedLibStrippedSymbols.py
  lldb/test/API/lang/cpp/class_types/TestClassTypes.py
  lldb/test/API/lang/cpp/inlines/TestInlines.py
  lldb/test/API/lang/cpp/namespace_definitions/TestNamespaceDefinitions.py
  lldb/test/API/lang/cpp/signed_types/TestSignedTypes.py
  lldb/test/API/lang/objc/conflicting-definition/TestConflictingDefinition.py
  lldb/test/API/lang/objc/forward-decl/TestForwardDecl.py
  lldb/test/API/lang/objc/hidden-ivars/TestHiddenIvars.py
  lldb/test/API/lang/objc/modules-auto-import/TestModulesAutoImport.py
  lldb/test/API/lang/objc/modules-incomplete/TestIncompleteModules.py
  lldb/test/API/lang/objc/modules/TestObjCModules.py
  lldb/test/API/lang/objc/objc-new-syntax/ObjCNewSyntaxTest.py
  lldb/test/API/lang/objc/real-definition/TestRealDefinition.py
  
lldb/test/API/lang/objc/single-entry-dictionary/TestObjCSingleEntryDictionary.py

Index: lldb/test/API/lang/objc/single-entry-dictionary/TestObjCSingleEntryDictionary.py
===
--- lldb/test/API/lang/objc/single-entry-dictionary/TestObjCSingleEntryDictionary.py
+++ lldb/test/API/lang/objc/single-entry-dictionary/TestObjCSingleEntryDictionary.py
@@ -57,8 +57,7 @@
  'stop reason = breakpoint'])
 
 # The breakpoint should have a hit count of 1.
-self.expect("breakpoint list -f", BREAKPOINT_HIT_ONCE,
-substrs=[' resolved, hit count = 1'])
+lldbutil.check_breakpoint(self, bpno = 1, expected_hit_count = 1)
 
 d1 = self.frame().FindVariable("d1")
 d1.SetPreferSyntheticValue(True)
Index: lldb/test/API/lang/objc/real-definition/TestRealDefinition.py
===
--- lldb/test/API/lang/objc/real-definition/TestRealDefinition.py
+++ lldb/test/API/lang/objc/real-definition/TestRealDefinition.py
@@ -32,14 +32,12 @@
  'stop reason = breakpoint'])
 
 # Run and stop at Foo
-self.expect("breakpoint list -f", BREAKPOINT_HIT_ONCE,
-substrs=[' resolved, hit count = 1'])
+lldbutil.check_breakpoint(self, bpno = 1, expected_hit_count = 1)
 
 self.runCmd("continue", RUN_SUCCEEDED)
 
 # Run at stop at main
-self.expect("breakpoint list -f", BREAKPOINT_HIT_ONCE,
-substrs=[' resolved, hit count = 1'])
+lldbutil.check_breakpoint(self, bpno = 1, expected_hit_count = 1)
 
 # This should display correctly.
 self.expect(
@@ -69,14 +67,12 @@
  'stop reason = breakpoint'])
 
 # Run and stop at Foo
-self.expect("breakpoint list -f", BREAKPOINT_HIT_ONCE,
-substrs=[' resolved, hit count = 1'])
+lldbutil.check_breakpoint(self, bpno = 1, expected_hit_count = 1)
 
 self.runCmd("continue", RUN_SUCCEEDED)
 
 # Run at stop at main
-self.expect("breakpoint list -f", BREAKPOINT_HIT_ONCE,
-substrs=[' resolved, hit count = 1'])
+lldbutil.check_breakpoint(self, bpno = 1, expected_hit_count = 1)
 
 # This should display correctly.
 self.expect(
Index: lldb/test/API/lang/objc/objc-new-syntax/ObjCNewSyntaxTest.py

[Lldb-commits] [PATCH] D111899: LLDB tests modification for hardware breakpoints

2021-10-29 Thread Nikolay Chokoev via Phabricator via lldb-commits
georgiev updated this revision to Diff 383284.

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

https://reviews.llvm.org/D111899

Files:
  lldb/packages/Python/lldbsuite/test/lldbutil.py
  lldb/test/API/commands/apropos/with-process/TestAproposWithProcess.py
  lldb/test/API/commands/command/nested_alias/TestNestedAlias.py
  
lldb/test/API/functionalities/breakpoint/breakpoint_command/TestBreakpointCommand.py
  
lldb/test/API/functionalities/breakpoint/breakpoint_ignore_count/TestBreakpointIgnoreCount.py
  
lldb/test/API/functionalities/breakpoint/breakpoint_locations/TestBreakpointLocations.py
  lldb/test/API/functionalities/dead-strip/TestDeadStrip.py
  lldb/test/API/functionalities/load_unload/TestLoadUnload.py
  lldb/test/API/functionalities/memory/cache/TestMemoryCache.py
  lldb/test/API/functionalities/memory/find/TestMemoryFind.py
  lldb/test/API/functionalities/memory/read/TestMemoryRead.py
  lldb/test/API/lang/c/anonymous/TestAnonymous.py
  lldb/test/API/lang/c/array_types/TestArrayTypes.py
  lldb/test/API/lang/c/conflicting-symbol/TestConflictingSymbol.py
  lldb/test/API/lang/c/const_variables/TestConstVariables.py
  lldb/test/API/lang/c/enum_types/TestEnumTypes.py
  lldb/test/API/lang/c/forward/TestForwardDeclaration.py
  lldb/test/API/lang/c/function_types/TestFunctionTypes.py
  lldb/test/API/lang/c/global_variables/TestGlobalVariables.py
  lldb/test/API/lang/c/local_variables/TestLocalVariables.py
  lldb/test/API/lang/c/modules/TestCModules.py
  lldb/test/API/lang/c/register_variables/TestRegisterVariables.py
  lldb/test/API/lang/c/set_values/TestSetValues.py
  lldb/test/API/lang/c/shared_lib/TestSharedLib.py
  
lldb/test/API/lang/c/shared_lib_stripped_symbols/TestSharedLibStrippedSymbols.py
  lldb/test/API/lang/cpp/class_types/TestClassTypes.py
  lldb/test/API/lang/cpp/inlines/TestInlines.py
  lldb/test/API/lang/cpp/namespace_definitions/TestNamespaceDefinitions.py
  lldb/test/API/lang/cpp/signed_types/TestSignedTypes.py
  lldb/test/API/lang/objc/conflicting-definition/TestConflictingDefinition.py
  lldb/test/API/lang/objc/forward-decl/TestForwardDecl.py
  lldb/test/API/lang/objc/hidden-ivars/TestHiddenIvars.py
  lldb/test/API/lang/objc/modules-auto-import/TestModulesAutoImport.py
  lldb/test/API/lang/objc/modules-incomplete/TestIncompleteModules.py
  lldb/test/API/lang/objc/modules/TestObjCModules.py
  lldb/test/API/lang/objc/objc-new-syntax/ObjCNewSyntaxTest.py
  lldb/test/API/lang/objc/real-definition/TestRealDefinition.py
  
lldb/test/API/lang/objc/single-entry-dictionary/TestObjCSingleEntryDictionary.py

Index: lldb/test/API/lang/objc/single-entry-dictionary/TestObjCSingleEntryDictionary.py
===
--- lldb/test/API/lang/objc/single-entry-dictionary/TestObjCSingleEntryDictionary.py
+++ lldb/test/API/lang/objc/single-entry-dictionary/TestObjCSingleEntryDictionary.py
@@ -57,8 +57,7 @@
  'stop reason = breakpoint'])
 
 # The breakpoint should have a hit count of 1.
-self.expect("breakpoint list -f", BREAKPOINT_HIT_ONCE,
-substrs=[' resolved, hit count = 1'])
+lldbutil.check_breakpoint(self, bpno = 1, expected_hit_count = 1)
 
 d1 = self.frame().FindVariable("d1")
 d1.SetPreferSyntheticValue(True)
Index: lldb/test/API/lang/objc/real-definition/TestRealDefinition.py
===
--- lldb/test/API/lang/objc/real-definition/TestRealDefinition.py
+++ lldb/test/API/lang/objc/real-definition/TestRealDefinition.py
@@ -32,14 +32,12 @@
  'stop reason = breakpoint'])
 
 # Run and stop at Foo
-self.expect("breakpoint list -f", BREAKPOINT_HIT_ONCE,
-substrs=[' resolved, hit count = 1'])
+lldbutil.check_breakpoint(self, bpno = 1, expected_hit_count = 1)
 
 self.runCmd("continue", RUN_SUCCEEDED)
 
 # Run at stop at main
-self.expect("breakpoint list -f", BREAKPOINT_HIT_ONCE,
-substrs=[' resolved, hit count = 1'])
+lldbutil.check_breakpoint(self, bpno = 1, expected_hit_count = 1)
 
 # This should display correctly.
 self.expect(
@@ -69,14 +67,12 @@
  'stop reason = breakpoint'])
 
 # Run and stop at Foo
-self.expect("breakpoint list -f", BREAKPOINT_HIT_ONCE,
-substrs=[' resolved, hit count = 1'])
+lldbutil.check_breakpoint(self, bpno = 1, expected_hit_count = 1)
 
 self.runCmd("continue", RUN_SUCCEEDED)
 
 # Run at stop at main
-self.expect("breakpoint list -f", BREAKPOINT_HIT_ONCE,
-substrs=[' resolved, hit count = 1'])
+lldbutil.check_breakpoint(self, bpno = 1, expected_hit_count = 1)
 
 # This should display correctly.
 self.expect(
Index: lldb/test/API/lang/objc/objc-new-syntax/ObjCNewSyntaxTest.py

[Lldb-commits] [lldb] a394231 - [lldb] Remove ConstString from SymbolVendor, Trace, TraceExporter, UnwindAssembly, MemoryHistory and InstrumentationRuntime plugin names

2021-10-29 Thread Pavel Labath via lldb-commits

Author: Pavel Labath
Date: 2021-10-29T12:08:57+02:00
New Revision: a3942318198937a163deeb10f2e3378f3bc69844

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

LOG: [lldb] Remove ConstString from SymbolVendor, Trace, TraceExporter, 
UnwindAssembly, MemoryHistory and InstrumentationRuntime plugin names

Added: 


Modified: 
lldb/include/lldb/Core/PluginManager.h
lldb/source/Commands/CommandObjectThread.cpp
lldb/source/Core/PluginManager.cpp

lldb/source/Plugins/InstrumentationRuntime/ASan/InstrumentationRuntimeASan.cpp
lldb/source/Plugins/InstrumentationRuntime/ASan/InstrumentationRuntimeASan.h

lldb/source/Plugins/InstrumentationRuntime/MainThreadChecker/InstrumentationRuntimeMainThreadChecker.cpp

lldb/source/Plugins/InstrumentationRuntime/MainThreadChecker/InstrumentationRuntimeMainThreadChecker.h

lldb/source/Plugins/InstrumentationRuntime/TSan/InstrumentationRuntimeTSan.cpp
lldb/source/Plugins/InstrumentationRuntime/TSan/InstrumentationRuntimeTSan.h

lldb/source/Plugins/InstrumentationRuntime/UBSan/InstrumentationRuntimeUBSan.cpp

lldb/source/Plugins/InstrumentationRuntime/UBSan/InstrumentationRuntimeUBSan.h
lldb/source/Plugins/MemoryHistory/asan/MemoryHistoryASan.cpp
lldb/source/Plugins/MemoryHistory/asan/MemoryHistoryASan.h
lldb/source/Plugins/SymbolVendor/ELF/SymbolVendorELF.cpp
lldb/source/Plugins/SymbolVendor/ELF/SymbolVendorELF.h
lldb/source/Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.cpp
lldb/source/Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.h
lldb/source/Plugins/SymbolVendor/wasm/SymbolVendorWasm.cpp
lldb/source/Plugins/SymbolVendor/wasm/SymbolVendorWasm.h
lldb/source/Plugins/Trace/intel-pt/TraceIntelPT.cpp
lldb/source/Plugins/Trace/intel-pt/TraceIntelPT.h
lldb/source/Plugins/TraceExporter/ctf/TraceExporterCTF.cpp
lldb/source/Plugins/TraceExporter/ctf/TraceExporterCTF.h

lldb/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.cpp

lldb/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.h
lldb/source/Plugins/UnwindAssembly/x86/UnwindAssembly-x86.cpp
lldb/source/Plugins/UnwindAssembly/x86/UnwindAssembly-x86.h
lldb/source/Target/Trace.cpp
lldb/source/Target/TraceExporter.cpp

Removed: 




diff  --git a/lldb/include/lldb/Core/PluginManager.h 
b/lldb/include/lldb/Core/PluginManager.h
index dffceb93ebc63..cd720d5a9d0fc 100644
--- a/lldb/include/lldb/Core/PluginManager.h
+++ b/lldb/include/lldb/Core/PluginManager.h
@@ -324,7 +324,7 @@ class PluginManager {
   GetSymbolFileCreateCallbackAtIndex(uint32_t idx);
 
   // SymbolVendor
-  static bool RegisterPlugin(ConstString name, const char *description,
+  static bool RegisterPlugin(llvm::StringRef name, llvm::StringRef description,
  SymbolVendorCreateInstance create_callback);
 
   static bool UnregisterPlugin(SymbolVendorCreateInstance create_callback);
@@ -334,7 +334,7 @@ class PluginManager {
 
   // Trace
   static bool RegisterPlugin(
-  ConstString name, const char *description,
+  llvm::StringRef name, llvm::StringRef description,
   TraceCreateInstanceForSessionFile create_callback_for_session_file,
   TraceCreateInstanceForLiveProcess create_callback_for_live_process,
   llvm::StringRef schema);
@@ -343,10 +343,10 @@ class PluginManager {
   UnregisterPlugin(TraceCreateInstanceForSessionFile create_callback);
 
   static TraceCreateInstanceForSessionFile
-  GetTraceCreateCallback(ConstString plugin_name);
+  GetTraceCreateCallback(llvm::StringRef plugin_name);
 
   static TraceCreateInstanceForLiveProcess
-  GetTraceCreateCallbackForLiveProcess(ConstString plugin_name);
+  GetTraceCreateCallbackForLiveProcess(llvm::StringRef plugin_name);
 
   /// Get the JSON schema for a trace session file corresponding to the given
   /// plugin.
@@ -357,7 +357,7 @@ class PluginManager {
   /// \return
   /// An empty \a StringRef if no plugin was found with that plugin name,
   /// otherwise the actual schema is returned.
-  static llvm::StringRef GetTraceSchema(ConstString plugin_name);
+  static llvm::StringRef GetTraceSchema(llvm::StringRef plugin_name);
 
   /// Get the JSON schema for a trace session file corresponding to the plugin
   /// given by its index.
@@ -376,16 +376,16 @@ class PluginManager {
   /// This callback is used to create a CommandObject that will be listed
   /// under "thread trace export". Can be \b null.
   static bool RegisterPlugin(
-  ConstString name, const char *description,
+  llvm::StringRef name, llvm::StringRef description,
   TraceExporterCreateInstance create_callback,
   ThreadTraceExportCommandCreator create_thread_trace_export_command);
 
   static Tr

[Lldb-commits] [PATCH] D112802: [lldb/test] Replace shlex.join with shlex.quote

2021-10-29 Thread Pavel Labath via Phabricator via lldb-commits
labath created this revision.
labath added a reviewer: teemperor.
labath requested review of this revision.
Herald added a project: LLDB.

join is only available since python-3.8, but the all the interesting
magic happens in shlex.quote, which has been around since 3.3.

Use shlex.quote, and instead provide a home-grown helper function to
handle the joining.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D112802

Files:
  lldb/packages/Python/lldbsuite/support/seven.py
  lldb/packages/Python/lldbsuite/test/lldbtest.py
  lldb/packages/Python/lldbsuite/test_event/build_exception.py


Index: lldb/packages/Python/lldbsuite/test_event/build_exception.py
===
--- lldb/packages/Python/lldbsuite/test_event/build_exception.py
+++ lldb/packages/Python/lldbsuite/test_event/build_exception.py
@@ -1,10 +1,10 @@
-import shlex
+from lldbsuite.support import seven
 
 class BuildError(Exception):
 
 def __init__(self, called_process_error):
 super(BuildError, self).__init__("Error when building test subject")
-self.command = shlex.join(called_process_error.cmd)
+self.command = seven.join_for_shell(called_process_error.cmd)
 self.build_error = called_process_error.output
 
 def __str__(self):
Index: lldb/packages/Python/lldbsuite/test/lldbtest.py
===
--- lldb/packages/Python/lldbsuite/test/lldbtest.py
+++ lldb/packages/Python/lldbsuite/test/lldbtest.py
@@ -45,7 +45,6 @@
 import re
 import shutil
 import signal
-import shlex
 from subprocess import *
 import sys
 import time
@@ -68,6 +67,7 @@
 from . import test_categories
 from lldbsuite.support import encoded_file
 from lldbsuite.support import funcutils
+from lldbsuite.support import seven
 from lldbsuite.test.builders import get_builder
 from lldbsuite.test_event import build_exception
 
@@ -1423,7 +1423,7 @@
 self.runBuildCommand(command)
 
 def runBuildCommand(self, command):
-self.trace(shlex.join(command))
+self.trace(seven.join_for_shell(command))
 try:
 output = check_output(command, stderr=STDOUT, errors="replace")
 except CalledProcessError as cpe:
Index: lldb/packages/Python/lldbsuite/support/seven.py
===
--- lldb/packages/Python/lldbsuite/support/seven.py
+++ lldb/packages/Python/lldbsuite/support/seven.py
@@ -1,5 +1,6 @@
 import binascii
 import six
+import shlex
 
 if six.PY2:
 import commands
@@ -49,3 +50,6 @@
 def hexlify(data):
 """Hex-encode string data. The result if always a string."""
 return bitcast_to_string(binascii.hexlify(bitcast_to_bytes(data)))
+
+def join_for_shell(split_command):
+return " ".join([shlex.quote(part) for part in split_command])


Index: lldb/packages/Python/lldbsuite/test_event/build_exception.py
===
--- lldb/packages/Python/lldbsuite/test_event/build_exception.py
+++ lldb/packages/Python/lldbsuite/test_event/build_exception.py
@@ -1,10 +1,10 @@
-import shlex
+from lldbsuite.support import seven
 
 class BuildError(Exception):
 
 def __init__(self, called_process_error):
 super(BuildError, self).__init__("Error when building test subject")
-self.command = shlex.join(called_process_error.cmd)
+self.command = seven.join_for_shell(called_process_error.cmd)
 self.build_error = called_process_error.output
 
 def __str__(self):
Index: lldb/packages/Python/lldbsuite/test/lldbtest.py
===
--- lldb/packages/Python/lldbsuite/test/lldbtest.py
+++ lldb/packages/Python/lldbsuite/test/lldbtest.py
@@ -45,7 +45,6 @@
 import re
 import shutil
 import signal
-import shlex
 from subprocess import *
 import sys
 import time
@@ -68,6 +67,7 @@
 from . import test_categories
 from lldbsuite.support import encoded_file
 from lldbsuite.support import funcutils
+from lldbsuite.support import seven
 from lldbsuite.test.builders import get_builder
 from lldbsuite.test_event import build_exception
 
@@ -1423,7 +1423,7 @@
 self.runBuildCommand(command)
 
 def runBuildCommand(self, command):
-self.trace(shlex.join(command))
+self.trace(seven.join_for_shell(command))
 try:
 output = check_output(command, stderr=STDOUT, errors="replace")
 except CalledProcessError as cpe:
Index: lldb/packages/Python/lldbsuite/support/seven.py
===
--- lldb/packages/Python/lldbsuite/support/seven.py
+++ lldb/packages/Python/lldbsuite/support/seven.py
@@ -1,5 +1,6 @@
 import binascii
 import six
+import shlex
 
 if six.PY2:
 import commands
@@ -49,3 +50,6 @@
 def hexlify(data):
 """Hex-encode string data. The result if always a string."""
 return bitcast_to_string(binasci

[Lldb-commits] [PATCH] D112802: [lldb/test] Replace shlex.join with shlex.quote

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

Thanks!




Comment at: lldb/packages/Python/lldbsuite/support/seven.py:54
+
+def join_for_shell(split_command):
+return " ".join([shlex.quote(part) for part in split_command])

```
TODO: Replace this with `shlex.join` when minimum Python version is >= 3.8
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112802

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


[Lldb-commits] [lldb] b42d51b - [lldb/test] Replace shlex.join with shlex.quote

2021-10-29 Thread Pavel Labath via lldb-commits

Author: Pavel Labath
Date: 2021-10-29T13:42:06+02:00
New Revision: b42d51ba9ad1f85e6b6f3508e6c2c4ab5ee22ac1

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

LOG: [lldb/test] Replace shlex.join with shlex.quote

join is only available since python-3.8, but the all the interesting
magic happens in shlex.quote, which has been around since 3.3.

Use shlex.quote, and instead provide a home-grown helper function to
handle the joining.

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

Added: 


Modified: 
lldb/packages/Python/lldbsuite/support/seven.py
lldb/packages/Python/lldbsuite/test/lldbtest.py
lldb/packages/Python/lldbsuite/test_event/build_exception.py

Removed: 




diff  --git a/lldb/packages/Python/lldbsuite/support/seven.py 
b/lldb/packages/Python/lldbsuite/support/seven.py
index 9b23d94b021dc..969b61d005c58 100644
--- a/lldb/packages/Python/lldbsuite/support/seven.py
+++ b/lldb/packages/Python/lldbsuite/support/seven.py
@@ -1,5 +1,6 @@
 import binascii
 import six
+import shlex
 
 if six.PY2:
 import commands
@@ -49,3 +50,7 @@ def unhexlify(hexstr):
 def hexlify(data):
 """Hex-encode string data. The result if always a string."""
 return bitcast_to_string(binascii.hexlify(bitcast_to_bytes(data)))
+
+# TODO: Replace this with `shlex.join` when minimum Python version is >= 3.8
+def join_for_shell(split_command):
+return " ".join([shlex.quote(part) for part in split_command])

diff  --git a/lldb/packages/Python/lldbsuite/test/lldbtest.py 
b/lldb/packages/Python/lldbsuite/test/lldbtest.py
index 92d7887e670ac..7477905a131d0 100644
--- a/lldb/packages/Python/lldbsuite/test/lldbtest.py
+++ b/lldb/packages/Python/lldbsuite/test/lldbtest.py
@@ -45,7 +45,6 @@
 import re
 import shutil
 import signal
-import shlex
 from subprocess import *
 import sys
 import time
@@ -68,6 +67,7 @@
 from . import test_categories
 from lldbsuite.support import encoded_file
 from lldbsuite.support import funcutils
+from lldbsuite.support import seven
 from lldbsuite.test.builders import get_builder
 from lldbsuite.test_event import build_exception
 
@@ -1423,7 +1423,7 @@ def build(
 self.runBuildCommand(command)
 
 def runBuildCommand(self, command):
-self.trace(shlex.join(command))
+self.trace(seven.join_for_shell(command))
 try:
 output = check_output(command, stderr=STDOUT, errors="replace")
 except CalledProcessError as cpe:

diff  --git a/lldb/packages/Python/lldbsuite/test_event/build_exception.py 
b/lldb/packages/Python/lldbsuite/test_event/build_exception.py
index e1924ad86cde5..f960dca39067d 100644
--- a/lldb/packages/Python/lldbsuite/test_event/build_exception.py
+++ b/lldb/packages/Python/lldbsuite/test_event/build_exception.py
@@ -1,10 +1,10 @@
-import shlex
+from lldbsuite.support import seven
 
 class BuildError(Exception):
 
 def __init__(self, called_process_error):
 super(BuildError, self).__init__("Error when building test subject")
-self.command = shlex.join(called_process_error.cmd)
+self.command = seven.join_for_shell(called_process_error.cmd)
 self.build_error = called_process_error.output
 
 def __str__(self):



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


[Lldb-commits] [PATCH] D112802: [lldb/test] Replace shlex.join with shlex.quote

2021-10-29 Thread Pavel Labath via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGb42d51ba9ad1: [lldb/test] Replace shlex.join with 
shlex.quote (authored by labath).

Changed prior to commit:
  https://reviews.llvm.org/D112802?vs=383301&id=383302#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112802

Files:
  lldb/packages/Python/lldbsuite/support/seven.py
  lldb/packages/Python/lldbsuite/test/lldbtest.py
  lldb/packages/Python/lldbsuite/test_event/build_exception.py


Index: lldb/packages/Python/lldbsuite/test_event/build_exception.py
===
--- lldb/packages/Python/lldbsuite/test_event/build_exception.py
+++ lldb/packages/Python/lldbsuite/test_event/build_exception.py
@@ -1,10 +1,10 @@
-import shlex
+from lldbsuite.support import seven
 
 class BuildError(Exception):
 
 def __init__(self, called_process_error):
 super(BuildError, self).__init__("Error when building test subject")
-self.command = shlex.join(called_process_error.cmd)
+self.command = seven.join_for_shell(called_process_error.cmd)
 self.build_error = called_process_error.output
 
 def __str__(self):
Index: lldb/packages/Python/lldbsuite/test/lldbtest.py
===
--- lldb/packages/Python/lldbsuite/test/lldbtest.py
+++ lldb/packages/Python/lldbsuite/test/lldbtest.py
@@ -45,7 +45,6 @@
 import re
 import shutil
 import signal
-import shlex
 from subprocess import *
 import sys
 import time
@@ -68,6 +67,7 @@
 from . import test_categories
 from lldbsuite.support import encoded_file
 from lldbsuite.support import funcutils
+from lldbsuite.support import seven
 from lldbsuite.test.builders import get_builder
 from lldbsuite.test_event import build_exception
 
@@ -1423,7 +1423,7 @@
 self.runBuildCommand(command)
 
 def runBuildCommand(self, command):
-self.trace(shlex.join(command))
+self.trace(seven.join_for_shell(command))
 try:
 output = check_output(command, stderr=STDOUT, errors="replace")
 except CalledProcessError as cpe:
Index: lldb/packages/Python/lldbsuite/support/seven.py
===
--- lldb/packages/Python/lldbsuite/support/seven.py
+++ lldb/packages/Python/lldbsuite/support/seven.py
@@ -1,5 +1,6 @@
 import binascii
 import six
+import shlex
 
 if six.PY2:
 import commands
@@ -49,3 +50,7 @@
 def hexlify(data):
 """Hex-encode string data. The result if always a string."""
 return bitcast_to_string(binascii.hexlify(bitcast_to_bytes(data)))
+
+# TODO: Replace this with `shlex.join` when minimum Python version is >= 3.8
+def join_for_shell(split_command):
+return " ".join([shlex.quote(part) for part in split_command])


Index: lldb/packages/Python/lldbsuite/test_event/build_exception.py
===
--- lldb/packages/Python/lldbsuite/test_event/build_exception.py
+++ lldb/packages/Python/lldbsuite/test_event/build_exception.py
@@ -1,10 +1,10 @@
-import shlex
+from lldbsuite.support import seven
 
 class BuildError(Exception):
 
 def __init__(self, called_process_error):
 super(BuildError, self).__init__("Error when building test subject")
-self.command = shlex.join(called_process_error.cmd)
+self.command = seven.join_for_shell(called_process_error.cmd)
 self.build_error = called_process_error.output
 
 def __str__(self):
Index: lldb/packages/Python/lldbsuite/test/lldbtest.py
===
--- lldb/packages/Python/lldbsuite/test/lldbtest.py
+++ lldb/packages/Python/lldbsuite/test/lldbtest.py
@@ -45,7 +45,6 @@
 import re
 import shutil
 import signal
-import shlex
 from subprocess import *
 import sys
 import time
@@ -68,6 +67,7 @@
 from . import test_categories
 from lldbsuite.support import encoded_file
 from lldbsuite.support import funcutils
+from lldbsuite.support import seven
 from lldbsuite.test.builders import get_builder
 from lldbsuite.test_event import build_exception
 
@@ -1423,7 +1423,7 @@
 self.runBuildCommand(command)
 
 def runBuildCommand(self, command):
-self.trace(shlex.join(command))
+self.trace(seven.join_for_shell(command))
 try:
 output = check_output(command, stderr=STDOUT, errors="replace")
 except CalledProcessError as cpe:
Index: lldb/packages/Python/lldbsuite/support/seven.py
===
--- lldb/packages/Python/lldbsuite/support/seven.py
+++ lldb/packages/Python/lldbsuite/support/seven.py
@@ -1,5 +1,6 @@
 import binascii
 import six
+import shlex
 
 if six.PY2:
 import commands
@@ -49,3 +50,7 @@
 def hexlify(data):
 """Hex-encode string data. The result if always a st

[Lldb-commits] [lldb] 8e3de91 - [lldb/test] Fix TestFunctionStarts for eee887e0

2021-10-29 Thread Pavel Labath via lldb-commits

Author: Pavel Labath
Date: 2021-10-29T14:43:53+02:00
New Revision: 8e3de91c07ce1e70463e1db2f3f0d629f57239b7

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

LOG: [lldb/test] Fix TestFunctionStarts for eee887e0

Added: 


Modified: 
lldb/test/API/macosx/function-starts/TestFunctionStarts.py

Removed: 




diff  --git a/lldb/test/API/macosx/function-starts/TestFunctionStarts.py 
b/lldb/test/API/macosx/function-starts/TestFunctionStarts.py
index 5ef06f4ab568f..ce599851293c7 100644
--- a/lldb/test/API/macosx/function-starts/TestFunctionStarts.py
+++ b/lldb/test/API/macosx/function-starts/TestFunctionStarts.py
@@ -37,10 +37,7 @@ def do_function_starts(self, in_memory):
 
 exe = self.getBuildArtifact(exe_name)
 # Now strip the binary, but leave externals so we can break on 
dont_strip_me.
-try:
-fail_str = system([["strip", "-u", "-x", "-S", exe]])
-except CalledProcessError as cmd_error:
-self.fail("Strip failed: %d"%(cmd_error.returncode))
+self.runBuildCommand(["strip", "-u", "-x", "-S", exe])
 
 # Use a file as a synchronization point between test and inferior.
 pid_file_path = lldbutil.append_to_process_working_directory(self,



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


[Lldb-commits] [lldb] 5015f25 - [lldb/test] Fix TestSourceManager for eee887e0

2021-10-29 Thread Pavel Labath via lldb-commits

Author: Pavel Labath
Date: 2021-10-29T14:56:23+02:00
New Revision: 5015f250894d3d97917d858850fae7960923a4ae

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

LOG: [lldb/test] Fix TestSourceManager for eee887e0

I'm removing the extra trace commands as they're not compatible with
windows, and there's no immediate replacement available.

Added: 


Modified: 
lldb/test/API/source-manager/TestSourceManager.py

Removed: 




diff  --git a/lldb/test/API/source-manager/TestSourceManager.py 
b/lldb/test/API/source-manager/TestSourceManager.py
index fc91d3c445b9a..ba26e0e058ce6 100644
--- a/lldb/test/API/source-manager/TestSourceManager.py
+++ b/lldb/test/API/source-manager/TestSourceManager.py
@@ -146,10 +146,6 @@ def test_move_and_then_display_source(self):
 main_c_hidden = os.path.join(hidden, "main-copy.c")
 os.rename(self.file, main_c_hidden)
 
-if self.TraceOn():
-system([["ls"]])
-system([["ls", "hidden"]])
-
 # Set source remapping with invalid replace path and verify we get an
 # error
 self.expect(



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


[Lldb-commits] [PATCH] D112824: [lldb][AArch64] Add MakeTaggedRanges to MemoryTagManager

2021-10-29 Thread David Spickett via Phabricator via lldb-commits
DavidSpickett created this revision.
Herald added subscribers: mgrang, kristof.beyls.
DavidSpickett requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

This is to be used when you want to know what subranges
of a larger range have memory tagging.

Like MakeTaggedRange but memory without tags is skipped
and you get a list of ranges back.

Will be used later by DumpDataExtractor to show memory tags.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D112824

Files:
  lldb/include/lldb/Target/MemoryTagManager.h
  lldb/source/Plugins/Process/Utility/MemoryTagManagerAArch64MTE.cpp
  lldb/source/Plugins/Process/Utility/MemoryTagManagerAArch64MTE.h
  lldb/unittests/Process/Utility/MemoryTagManagerAArch64MTETest.cpp

Index: lldb/unittests/Process/Utility/MemoryTagManagerAArch64MTETest.cpp
===
--- lldb/unittests/Process/Utility/MemoryTagManagerAArch64MTETest.cpp
+++ lldb/unittests/Process/Utility/MemoryTagManagerAArch64MTETest.cpp
@@ -247,6 +247,101 @@
   ASSERT_EQ(*got, expected_range);
 }
 
+TEST(MemoryTagManagerAArch64MTETest, MakeTaggedRanges) {
+  MemoryTagManagerAArch64MTE manager;
+  MemoryRegionInfos memory_regions;
+
+  // Note that MakeTaggedRanges takes start/end address.
+  // Whereas TagRanges and regions take start address and size.
+
+  // Range must not be inverted
+  // (this is the only error situation)
+  ASSERT_THAT_EXPECTED(
+  manager.MakeTaggedRange(1, 0, memory_regions),
+  llvm::FailedWithMessage(
+  "End address (0x0) must be greater than the start address (0x1)"));
+
+  // No regions means no tagged regions, no ranges returned.
+  llvm::Expected> got =
+  manager.MakeTaggedRanges(0, 0x10, memory_regions);
+  ASSERT_THAT_EXPECTED(got, llvm::Succeeded());
+  ASSERT_EQ(*got, std::vector{});
+
+  // Cover whole range, untagged. No ranges returned.
+  memory_regions.push_back(MakeRegionInfo(0, 0x20, false));
+  got = manager.MakeTaggedRanges(0, 0x20, memory_regions);
+  ASSERT_THAT_EXPECTED(got, llvm::Succeeded());
+  ASSERT_EQ(*got, std::vector{});
+
+  // Make the region tagged and it'll be the one range returned.
+  memory_regions.back().SetMemoryTagged(MemoryRegionInfo::eYes);
+  got = manager.MakeTaggedRanges(0, 0x20, memory_regions);
+  ASSERT_THAT_EXPECTED(got, llvm::Succeeded());
+  ASSERT_EQ(*got, std::vector{
+  MemoryTagManager::TagRange(0, 0x20)});
+
+  // This region will be trimmed if it's larger than the whole range.
+  memory_regions.clear();
+  memory_regions.push_back(MakeRegionInfo(0, 0x40, true));
+  got = manager.MakeTaggedRanges(0x10, 0x30, memory_regions);
+  ASSERT_THAT_EXPECTED(got, llvm::Succeeded());
+  ASSERT_EQ(*got, std::vector{
+  MemoryTagManager::TagRange(0x10, 0x20)});
+
+  memory_regions.clear();
+
+  // Only start of range is tagged, only that is returned.
+  // Start the region just before the requested range to check
+  // we limit the result to the requested range.
+  memory_regions.push_back(MakeRegionInfo(0, 0x20, true));
+  got = manager.MakeTaggedRanges(0x10, 0x100, memory_regions);
+  ASSERT_THAT_EXPECTED(got, llvm::Succeeded());
+  ASSERT_EQ(*got, std::vector{
+  MemoryTagManager::TagRange(0x10, 0x10)});
+
+  // Add a tagged region at the end, now we get both
+  // and the middle is untagged.
+  // The range added here is deliberately over the end of the
+  // requested range to show that we trim the end.
+  memory_regions.push_back(MakeRegionInfo(0xE0, 0x40, true));
+  got = manager.MakeTaggedRanges(0x10, 0x110, memory_regions);
+  ASSERT_THAT_EXPECTED(got, llvm::Succeeded());
+
+  std::vector expected{
+  MemoryTagManager::TagRange(0x10, 0x10),
+  MemoryTagManager::TagRange(0xE0, 0x30)};
+  ASSERT_EQ(*got, expected);
+
+  // Now add a middle tagged region.
+  memory_regions.push_back(MakeRegionInfo(0x90, 0x20, true));
+  // MakeTaggedRanges will sort the regions it is given, so the output
+  // is always in ascending address order. So this goes in the middle
+  // of expected.
+  expected.insert(std::next(expected.begin()),
+  MemoryTagManager::TagRange(0x90, 0x20));
+  got = manager.MakeTaggedRanges(0x10, 0x110, memory_regions);
+  ASSERT_THAT_EXPECTED(got, llvm::Succeeded());
+  ASSERT_EQ(*got, expected);
+
+  // Then if we add untagged regions in between the tagged,
+  // the output should stay the same.
+  memory_regions.push_back(MakeRegionInfo(0x20, 0x30, false));
+  memory_regions.push_back(MakeRegionInfo(0xC0, 0x10, false));
+  got = manager.MakeTaggedRanges(0x10, 0x110, memory_regions);
+  ASSERT_THAT_EXPECTED(got, llvm::Succeeded());
+  ASSERT_EQ(*got, expected);
+
+  // Finally check that we handle only having the end of the range.
+  memory_regions.clear();
+  expected.clear();
+
+  memory_regions.push_back(MakeRegionInfo(0x100, 0x10, true));
+  expected.push_back(MemoryTagManager::TagRange(0x100, 0x10

[Lldb-commits] [PATCH] D112825: [lldb] Add MemoryTagMap class

2021-10-29 Thread David Spickett via Phabricator via lldb-commits
DavidSpickett created this revision.
Herald added a subscriber: mgorny.
DavidSpickett requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

The tag map holds a sparse set of memory tags and allows
you to query ranges for tags.

Granules that do not have tags will be set to llvm::None.
to keep the ordering intact. If there are no tags for the
requested range we'll just return an empty result so that
callers don't need to check that all values are llvm::None.

This will be combined with MemoryTagManager's MakeTaggedRanges:

- MakeTaggedRanges
- Read from all those ranges
- Insert the results into the tag map
- Give the tag map to whatever needs to print tags

Which in this case will be "memory read"/DumpDataExtractor.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D112825

Files:
  lldb/include/lldb/Utility/MemoryTagMap.h
  lldb/source/Utility/CMakeLists.txt
  lldb/source/Utility/MemoryTagMap.cpp
  lldb/unittests/Utility/CMakeLists.txt
  lldb/unittests/Utility/MemoryTagMapTest.cpp

Index: lldb/unittests/Utility/MemoryTagMapTest.cpp
===
--- /dev/null
+++ lldb/unittests/Utility/MemoryTagMapTest.cpp
@@ -0,0 +1,81 @@
+//===-- MemoryTagMapTest.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/Utility/MemoryTagMap.h"
+#include "Plugins/Process/Utility/MemoryTagManagerAArch64MTE.h"
+#include "gmock/gmock.h"
+#include "gtest/gtest.h"
+
+using namespace lldb_private;
+using namespace lldb;
+
+// In these tests we use the AArch64 MTE tag manager because it is the only
+// implementation of a memory tag manager. MemoryTagMap itself is generic.
+
+TEST(MemoryTagMapTest, EmptyTagMap) {
+  MemoryTagManagerAArch64MTE manager;
+  MemoryTagMap tag_map(&manager);
+
+  tag_map.InsertTags(0, {});
+  ASSERT_TRUE(tag_map.empty());
+  tag_map.InsertTags(0, {0});
+  ASSERT_FALSE(tag_map.empty());
+}
+
+TEST(MemoryTagMapTest, GetTags) {
+  using TagsVec = std::vector>;
+
+  MemoryTagManagerAArch64MTE manager;
+  MemoryTagMap tag_map(&manager);
+
+  // No tags for an address not in the map
+  ASSERT_TRUE(tag_map.GetTags(0, 16).empty());
+
+  tag_map.InsertTags(0, {0, 1});
+
+  // No tags if you read zero length
+  ASSERT_TRUE(tag_map.GetTags(0, 0).empty());
+
+  EXPECT_THAT(tag_map.GetTags(0, 16), ::testing::ContainerEq(TagsVec{0}));
+
+  EXPECT_THAT(tag_map.GetTags(0, 32), ::testing::ContainerEq(TagsVec{0, 1}));
+
+  // Last granule of the range is not tagged
+  EXPECT_THAT(tag_map.GetTags(0, 48),
+  ::testing::ContainerEq(TagsVec{0, 1, llvm::None}));
+
+  EXPECT_THAT(tag_map.GetTags(16, 32),
+  ::testing::ContainerEq(TagsVec{1, llvm::None}));
+
+  // Reading beyond that address gives you no tags at all
+  EXPECT_THAT(tag_map.GetTags(32, 16), ::testing::ContainerEq(TagsVec{}));
+
+  // Address is granule aligned for you
+  // The length here is set such that alignment doesn't produce a 2 granule
+  // range.
+  EXPECT_THAT(tag_map.GetTags(8, 8), ::testing::ContainerEq(TagsVec{0}));
+
+  EXPECT_THAT(tag_map.GetTags(30, 2), ::testing::ContainerEq(TagsVec{1}));
+
+  // Here the length pushes the range into the next granule. When aligned
+  // this produces 2 granules.
+  EXPECT_THAT(tag_map.GetTags(30, 4),
+  ::testing::ContainerEq(TagsVec{1, llvm::None}));
+
+  // A range can also have gaps at the beginning or in the middle.
+  // Add more tags, 1 granule away from the first range.
+  tag_map.InsertTags(48, {3, 4});
+
+  // Untagged first granule
+  EXPECT_THAT(tag_map.GetTags(32, 32),
+  ::testing::ContainerEq(TagsVec{llvm::None, 3}));
+
+  // Untagged middle granule
+  EXPECT_THAT(tag_map.GetTags(16, 48),
+  ::testing::ContainerEq(TagsVec{1, llvm::None, 3}));
+}
Index: lldb/unittests/Utility/CMakeLists.txt
===
--- lldb/unittests/Utility/CMakeLists.txt
+++ lldb/unittests/Utility/CMakeLists.txt
@@ -14,6 +14,7 @@
   ListenerTest.cpp
   LogTest.cpp
   NameMatchesTest.cpp
+  MemoryTagMapTest.cpp
   PredicateTest.cpp
   ProcessInfoTest.cpp
   ProcessInstanceInfoTest.cpp
@@ -46,6 +47,7 @@
   XcodeSDKTest.cpp
 
   LINK_LIBS
+  lldbPluginProcessUtility
   lldbUtility
   lldbUtilityHelpers
   LLVMTestingSupport
Index: lldb/source/Utility/MemoryTagMap.cpp
===
--- /dev/null
+++ lldb/source/Utility/MemoryTagMap.cpp
@@ -0,0 +1,64 @@
+//===-- MemoryTagMap.cpp --===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+//

[Lldb-commits] [PATCH] D107140: [lldb] Show memory tags in memory read output

2021-10-29 Thread David Spickett via Phabricator via lldb-commits
DavidSpickett updated this revision to Diff 383374.
DavidSpickett added a comment.
Herald added a subscriber: dang.

Added a command option for showing tags (off by default).

Split the patch into three (see parent revisions).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107140

Files:
  lldb/include/lldb/Core/DumpDataExtractor.h
  lldb/source/Commands/CommandObjectMemory.cpp
  lldb/source/Commands/Options.td
  lldb/source/Core/DumpDataExtractor.cpp
  
lldb/test/API/linux/aarch64/mte_tag_access/TestAArch64LinuxMTEMemoryTagAccess.py

Index: lldb/test/API/linux/aarch64/mte_tag_access/TestAArch64LinuxMTEMemoryTagAccess.py
===
--- lldb/test/API/linux/aarch64/mte_tag_access/TestAArch64LinuxMTEMemoryTagAccess.py
+++ lldb/test/API/linux/aarch64/mte_tag_access/TestAArch64LinuxMTEMemoryTagAccess.py
@@ -280,3 +280,128 @@
   "\[0x[0-9A-Fa-f]+10, 0x[0-9A-Fa-f]+20\): 0x3 \(mismatch\)\n"
   "\[0x[0-9A-Fa-f]+20, 0x[0-9A-Fa-f]+30\): 0x3 \(mismatch\)\n"
   "\[0x[0-9A-Fa-f]+30, 0x[0-9A-Fa-f]+40\): 0x0$"])
+
+@skipUnlessArch("aarch64")
+@skipUnlessPlatform(["linux"])
+@skipUnlessAArch64MTELinuxCompiler
+def test_mte_memory_read_tag_display(self):
+self.setup_mte_test()
+
+# Reading from an untagged range should not be any different
+self.expect("memory read non_mte_buf non_mte_buf+16",
+substrs=["tag"], matching=False)
+
+# show-tags option is required
+self.expect("memory read mte_buf mte_buf+32 -f \"x\" -l 1 -s 16",
+patterns=["tag"], matching=False)
+
+# Reading 16 bytes per line means 1 granule and so 1 tag per line
+self.expect("memory read mte_buf mte_buf+32 -f \"x\" -l 1 -s 16 --show-tags",
+patterns=[
+"0x[0-9A-fa-f]+00: 0x0+ \(tag: 0x0\)\n"
+"0x[0-9A-fa-f]+10: 0x0+ \(tag: 0x1\)"
+])
+
+# If bytes per line is > granule size then you get multiple tags
+# per line.
+self.expect("memory read mte_buf mte_buf+32 -f \"x\" -l 1 -s 32 --show-tags",
+patterns=[
+"0x[0-9A-fa-f]+00: 0x0+ \(tags: 0x0 0x1\)\n"
+])
+
+# Reading half a granule still shows you the tag for that granule
+self.expect("memory read mte_buf mte_buf+8 -f \"x\" -l 1 -s 8 --show-tags",
+patterns=[
+"0x[0-9A-fa-f]+00: 0x0+ \(tag: 0x0\)\n"
+])
+
+# We can read a whole number of granules but split them over more lines
+# than there are granules. Tags are shown repeated for each applicable line.
+self.expect("memory read mte_buf+32 mte_buf+64 -f \"x\" -l 1 -s 8 --show-tags",
+patterns=[
+"0x[0-9A-fa-f]+20: 0x0+ \(tag: 0x2\)\n"
+"0x[0-9A-fa-f]+28: 0x0+ \(tag: 0x2\)\n"
+"0x[0-9A-fa-f]+30: 0x0+ \(tag: 0x3\)\n"
+"0x[0-9A-fa-f]+38: 0x0+ \(tag: 0x3\)"
+])
+
+# Also works if we misalign the start address. Note the first tag is shown
+# only once here and we have a new tag on the last line.
+# (bytes per line == the misalignment here)
+self.expect("memory read mte_buf+32+8 mte_buf+64+8 -f \"x\" -l 1 -s 8 --show-tags",
+patterns=[
+"0x[0-9A-fa-f]+28: 0x0+ \(tag: 0x2\)\n"
+"0x[0-9A-fa-f]+30: 0x0+ \(tag: 0x3\)\n"
+"0x[0-9A-fa-f]+38: 0x0+ \(tag: 0x3\)\n"
+"0x[0-9A-fa-f]+40: 0x0+ \(tag: 0x4\)"
+])
+
+# We can do the same thing but where the misaligment isn't equal to
+# bytes per line. This time, some lines cover multiple granules and
+# so show multiple tags.
+self.expect("memory read mte_buf+32+4 mte_buf+64+4 -f \"x\" -l 1 -s 8 --show-tags",
+patterns=[
+"0x[0-9A-fa-f]+24: 0x0+ \(tag: 0x2\)\n"
+"0x[0-9A-fa-f]+2c: 0x0+ \(tags: 0x2 0x3\)\n"
+"0x[0-9A-fa-f]+34: 0x0+ \(tag: 0x3\)\n"
+"0x[0-9A-fa-f]+3c: 0x0+ \(tags: 0x3 0x4\)"
+])
+
+# If you read a range that includes non tagged areas those areas
+# simply aren't annotated.
+
+# Initial part of range is untagged
+self.expect("memory read mte_buf-16 mte_buf+32 -f \"x\" -l 1 -s 16 --show-tags",
+patterns=[
+"0x[0-9A-fa-f]+f0: 0x0+\n"
+"0x[0-9A-fa-f]+00: 0x0+ \(tag: 0x0\)\n"
+"0x[0-9A-fa-f]+10: 0x0+ \(tag: 0x1\)"
+])
+
+# End of range is untagged
+self.expect("memory read mte_buf+page_size-16 mte_buf+page_size+16 -

[Lldb-commits] [PATCH] D112834: [lldb-vscode] Fix coredump load source mapping for first file

2021-10-29 Thread Ted Woodward via Phabricator via lldb-commits
ted created this revision.
ted requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

SetSourceMapFromArguments is called after the core is loaded. This means
that the source file for the crashing code won't have the source map applied.
Move the call to SetSourceMapFromArguments in request_attach to just after
the call to RunInitCommands, matching request_launch behavior.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D112834

Files:
  lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/lldbvscode_testcase.py
  lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py
  lldb/test/API/tools/lldb-vscode/coreFile/TestVSCode_coreFile.py
  lldb/test/API/tools/lldb-vscode/coreFile/main.c
  lldb/tools/lldb-vscode/lldb-vscode.cpp


Index: lldb/tools/lldb-vscode/lldb-vscode.cpp
===
--- lldb/tools/lldb-vscode/lldb-vscode.cpp
+++ lldb/tools/lldb-vscode/lldb-vscode.cpp
@@ -616,6 +616,8 @@
   // Run any initialize LLDB commands the user specified in the launch.json
   g_vsc.RunInitCommands();
 
+  SetSourceMapFromArguments(*arguments);
+
   lldb::SBError status;
   g_vsc.SetTarget(g_vsc.CreateTargetFromArguments(*arguments, status));
   if (status.Fail()) {
@@ -657,8 +659,6 @@
 g_vsc.target = g_vsc.debugger.GetSelectedTarget();
   }
 
-  SetSourceMapFromArguments(*arguments);
-
   if (error.Success() && core_file.empty()) {
 auto attached_pid = g_vsc.target.GetProcess().GetProcessID();
 if (attached_pid == LLDB_INVALID_PROCESS_ID) {
Index: lldb/test/API/tools/lldb-vscode/coreFile/main.c
===
--- /dev/null
+++ lldb/test/API/tools/lldb-vscode/coreFile/main.c
@@ -0,0 +1 @@
+/* Fake source file for core dump source mapping test */
Index: lldb/test/API/tools/lldb-vscode/coreFile/TestVSCode_coreFile.py
===
--- lldb/test/API/tools/lldb-vscode/coreFile/TestVSCode_coreFile.py
+++ lldb/test/API/tools/lldb-vscode/coreFile/TestVSCode_coreFile.py
@@ -41,3 +41,18 @@
 
 self.vscode.request_next(threadId=32259)
 self.assertEquals(self.get_stackFrames(), expected_frames)
+
+@skipIfWindows
+@skipIfRemote
+def test_core_file_source_mapping(self):
+''' Test that sourceMap property is correctly applied when loading a 
core '''
+current_dir = os.path.dirname(os.path.realpath(__file__))
+exe_file = os.path.join(current_dir, "linux-x86_64.out")
+core_file = os.path.join(current_dir, "linux-x86_64.core")
+
+self.create_debug_adaptor()
+
+source_map = [["/home/labath/test", current_dir]]
+self.attach(exe_file, coreFile=core_file, sourceMap=source_map)
+
+self.assertTrue(current_dir in 
self.get_stackFrames()[0]['source']['path'])
Index: lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py
===
--- lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py
+++ lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py
@@ -506,7 +506,8 @@
initCommands=None, preRunCommands=None,
stopCommands=None, exitCommands=None,
attachCommands=None, terminateCommands=None,
-   coreFile=None, postRunCommands=None):
+   coreFile=None, postRunCommands=None,
+   sourceMap=None):
 args_dict = {}
 if pid is not None:
 args_dict['pid'] = pid
@@ -533,6 +534,8 @@
 args_dict['coreFile'] = coreFile
 if postRunCommands:
 args_dict['postRunCommands'] = postRunCommands
+if sourceMap:
+args_dict['sourceMap'] = sourceMap
 command_dict = {
 'command': 'attach',
 'type': 'request',
Index: 
lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/lldbvscode_testcase.py
===
--- lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/lldbvscode_testcase.py
+++ lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/lldbvscode_testcase.py
@@ -251,7 +251,7 @@
initCommands=None, preRunCommands=None, stopCommands=None,
exitCommands=None, attachCommands=None, coreFile=None,
disconnectAutomatically=True, terminateCommands=None,
-   postRunCommands=None):
+   postRunCommands=None, sourceMap=None):
 '''Build the default Makefile target, create the VSCode debug adaptor,
and attach to the process.
 '''
@@ -271,7 +271,8 @@
 initCommands=initCommands, preRunCommands=preRunCommands,
 stopCommands=stopCommands, exitCommands=exitCommands,
 attachCommands=attachCommands, terminateCommands=terminateCommands,
-  

[Lldb-commits] [PATCH] D112165: Cleanup a few more PR36048 skips

2021-10-29 Thread Adrian Prantl via Phabricator via lldb-commits
aprantl accepted this revision.
aprantl added a comment.
This revision is now accepted and ready to land.

Nice!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112165

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


[Lldb-commits] [PATCH] D112825: [lldb] Add MemoryTagMap class

2021-10-29 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere requested changes to this revision.
JDevlieghere added inline comments.
This revision now requires changes to proceed.



Comment at: lldb/include/lldb/Utility/MemoryTagMap.h:12
+
+#include "lldb/Target/MemoryTagManager.h"
+#include "lldb/lldb-private.h"

I found Utility an odd place for this class, but it certainly cannot depend on 
Target. This will introduce a cyclic dependency.



Comment at: lldb/include/lldb/Utility/MemoryTagMap.h:19-22
+// MemoryTagMap provides a way to give a sparse read result
+// when reading memory tags for a range. This is useful when
+// you want to annotate some large memory dump that might include
+// tagged memory but you don't know that it is all tagged.

These should be doxygen-style comments (which will be attached to the class 
below if you remove the newline). 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112825

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


[Lldb-commits] [PATCH] D112439: normalize file path when searching the source map

2021-10-29 Thread Adrian Prantl via Phabricator via lldb-commits
aprantl added inline comments.



Comment at: lldb/source/Target/PathMappingList.cpp:33
   // nomalized path pairs to ensure things match up.
   ConstString NormalizePath(ConstString path) {
 // If we use "path" to construct a FileSpec, it will normalize the path for

Why does this take a ConstString argument if it immediately calls GetStringRef 
on it?
Could you change this to take a StringRef here or in a follow-up NFC commit?



Comment at: lldb/source/Target/PathMappingList.cpp:33-37
   ConstString NormalizePath(ConstString path) {
 // If we use "path" to construct a FileSpec, it will normalize the path for
 // us. We then grab the string and turn it back into a ConstString.
 return ConstString(FileSpec(path.GetStringRef()).GetPath());
   }

xujuntwt95329 wrote:
> JDevlieghere wrote:
> > Can this function take a `StringRef` and return a `std::string` instead? 
> > The amount of roundtrips between `StringRef`s, `ConstString`s and 
> > `std::string`s is getting a bit out of hand.
> I agree with you. 
> However, if we change the signature of this function, then we need to do all 
> these conversion from the caller side, seems things are not going better.
> 
> For example
> 
> ```
> void PathMappingList::Append(ConstString path,
>  ConstString replacement, bool notify) {
>   ++m_mod_id;
>   m_pairs.emplace_back(pair(NormalizePath(path), NormalizePath(replacement)));
>   if (notify && m_callback)
> m_callback(*this, m_callback_baton);
> }
> ```
> 
> We need to convert `path` to StringRef, or we can change the type of 
> parameter `path`, but this will require more modification from the caller of 
> `Append`
IMO, the best solution would be change this too:
```
void PathMappingList::Append(StringRef path,
 StringRef replacement, bool notify) {
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112439

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


[Lldb-commits] [lldb] 16a816a - [lldb] [gdb-remote] Fix processing generic regnums

2021-10-29 Thread Michał Górny via lldb-commits

Author: Michał Górny
Date: 2021-10-29T21:37:46+02:00
New Revision: 16a816a19e2a8c65cf34dbf2ef9d7497b200c0b1

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

LOG: [lldb] [gdb-remote] Fix processing generic regnums

Fix regression in processing generic regnums that was introduced
in fa456505b80b0cf83647a1b26713e4d3b38eccc2 ("[lldb] [gdb-remote]
Refactor getting remote regs to use local vector").  Since then,
the "generic" field was wrongly interpreted as integer rather than
string constant.

Thanks to Ted Woodward for noticing and providing the correct code.

Added: 


Modified: 
lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp

Removed: 




diff  --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp 
b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
index a6f48b04d7db8..4f78ae428147c 100644
--- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
@@ -492,7 +492,7 @@ void ProcessGDBRemote::BuildDynamicRegisterInfo(bool force) 
{
   } else if (name.equals("dwarf")) {
 value.getAsInteger(0, reg_info.regnum_dwarf);
   } else if (name.equals("generic")) {
-value.getAsInteger(0, reg_info.regnum_generic);
+reg_info.regnum_generic = Args::StringToGenericRegister(value);
   } else if (name.equals("container-regs")) {
 SplitCommaSeparatedRegisterNumberString(value, 
reg_info.value_regs, 16);
   } else if (name.equals("invalidate-regs")) {



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


[Lldb-commits] [lldb] e6b3233 - Cleanup a few more PR36048 skips

2021-10-29 Thread David Blaikie via lldb-commits

Author: David Blaikie
Date: 2021-10-29T14:10:42-07:00
New Revision: e6b323379e3195ba98bacc9216fe38025bda6104

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

LOG: Cleanup a few more PR36048 skips

Hopefully these were also fixed bi r343545 /
7fd4513920d2fed533ad420976529ef43eb42a35

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

Added: 


Modified: 

lldb/test/API/functionalities/data-formatter/data-formatter-cpp/TestDataFormatterCpp.py

lldb/test/API/functionalities/data-formatter/data-formatter-globals/TestDataFormatterGlobals.py

lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/list/TestDataFormatterLibcxxList.py

Removed: 




diff  --git 
a/lldb/test/API/functionalities/data-formatter/data-formatter-cpp/TestDataFormatterCpp.py
 
b/lldb/test/API/functionalities/data-formatter/data-formatter-cpp/TestDataFormatterCpp.py
index 9d5c6ee262fee..bc681825d4a3b 100644
--- 
a/lldb/test/API/functionalities/data-formatter/data-formatter-cpp/TestDataFormatterCpp.py
+++ 
b/lldb/test/API/functionalities/data-formatter/data-formatter-cpp/TestDataFormatterCpp.py
@@ -20,8 +20,6 @@ def setUp(self):
 # Find the line number to break at.
 self.line = line_number('main.cpp', '// Set break point at this line.')
 
-@skipIf(debug_info="gmodules",
-bugnumber="https://bugs.llvm.org/show_bug.cgi?id=36048";)
 def test_with_run_command(self):
 """Test that that file and class static variables display correctly."""
 self.build()

diff  --git 
a/lldb/test/API/functionalities/data-formatter/data-formatter-globals/TestDataFormatterGlobals.py
 
b/lldb/test/API/functionalities/data-formatter/data-formatter-globals/TestDataFormatterGlobals.py
index 72fe2fb188528..fe9a17e4e61fd 100644
--- 
a/lldb/test/API/functionalities/data-formatter/data-formatter-globals/TestDataFormatterGlobals.py
+++ 
b/lldb/test/API/functionalities/data-formatter/data-formatter-globals/TestDataFormatterGlobals.py
@@ -20,8 +20,6 @@ def setUp(self):
 # Find the line number to break at.
 self.line = line_number('main.cpp', '// Set break point at this line.')
 
-@skipIf(debug_info="gmodules",
-bugnumber="https://bugs.llvm.org/show_bug.cgi?id=36048";)
 def test_with_run_command(self):
 """Test that that file and class static variables display correctly."""
 self.build()

diff  --git 
a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/list/TestDataFormatterLibcxxList.py
 
b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/list/TestDataFormatterLibcxxList.py
index 584eabd389587..8de749d74f035 100644
--- 
a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/list/TestDataFormatterLibcxxList.py
+++ 
b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/list/TestDataFormatterLibcxxList.py
@@ -27,8 +27,6 @@ def setUp(self):
  '// Set fourth break point at this line.')
 
 @add_test_categories(["libc++"])
-@skipIf(debug_info="gmodules",
-bugnumber="https://bugs.llvm.org/show_bug.cgi?id=36048";)
 def test_with_run_command(self):
 """Test that that file and class static variables display correctly."""
 self.build()



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


[Lldb-commits] [PATCH] D112165: Cleanup a few more PR36048 skips

2021-10-29 Thread David Blaikie via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGe6b323379e31: Cleanup a few more PR36048 skips (authored by 
dblaikie).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112165

Files:
  
lldb/test/API/functionalities/data-formatter/data-formatter-cpp/TestDataFormatterCpp.py
  
lldb/test/API/functionalities/data-formatter/data-formatter-globals/TestDataFormatterGlobals.py
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/list/TestDataFormatterLibcxxList.py


Index: 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/list/TestDataFormatterLibcxxList.py
===
--- 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/list/TestDataFormatterLibcxxList.py
+++ 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/list/TestDataFormatterLibcxxList.py
@@ -27,8 +27,6 @@
  '// Set fourth break point at this line.')
 
 @add_test_categories(["libc++"])
-@skipIf(debug_info="gmodules",
-bugnumber="https://bugs.llvm.org/show_bug.cgi?id=36048";)
 def test_with_run_command(self):
 """Test that that file and class static variables display correctly."""
 self.build()
Index: 
lldb/test/API/functionalities/data-formatter/data-formatter-globals/TestDataFormatterGlobals.py
===
--- 
lldb/test/API/functionalities/data-formatter/data-formatter-globals/TestDataFormatterGlobals.py
+++ 
lldb/test/API/functionalities/data-formatter/data-formatter-globals/TestDataFormatterGlobals.py
@@ -20,8 +20,6 @@
 # Find the line number to break at.
 self.line = line_number('main.cpp', '// Set break point at this line.')
 
-@skipIf(debug_info="gmodules",
-bugnumber="https://bugs.llvm.org/show_bug.cgi?id=36048";)
 def test_with_run_command(self):
 """Test that that file and class static variables display correctly."""
 self.build()
Index: 
lldb/test/API/functionalities/data-formatter/data-formatter-cpp/TestDataFormatterCpp.py
===
--- 
lldb/test/API/functionalities/data-formatter/data-formatter-cpp/TestDataFormatterCpp.py
+++ 
lldb/test/API/functionalities/data-formatter/data-formatter-cpp/TestDataFormatterCpp.py
@@ -20,8 +20,6 @@
 # Find the line number to break at.
 self.line = line_number('main.cpp', '// Set break point at this line.')
 
-@skipIf(debug_info="gmodules",
-bugnumber="https://bugs.llvm.org/show_bug.cgi?id=36048";)
 def test_with_run_command(self):
 """Test that that file and class static variables display correctly."""
 self.build()


Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/list/TestDataFormatterLibcxxList.py
===
--- lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/list/TestDataFormatterLibcxxList.py
+++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/list/TestDataFormatterLibcxxList.py
@@ -27,8 +27,6 @@
  '// Set fourth break point at this line.')
 
 @add_test_categories(["libc++"])
-@skipIf(debug_info="gmodules",
-bugnumber="https://bugs.llvm.org/show_bug.cgi?id=36048";)
 def test_with_run_command(self):
 """Test that that file and class static variables display correctly."""
 self.build()
Index: lldb/test/API/functionalities/data-formatter/data-formatter-globals/TestDataFormatterGlobals.py
===
--- lldb/test/API/functionalities/data-formatter/data-formatter-globals/TestDataFormatterGlobals.py
+++ lldb/test/API/functionalities/data-formatter/data-formatter-globals/TestDataFormatterGlobals.py
@@ -20,8 +20,6 @@
 # Find the line number to break at.
 self.line = line_number('main.cpp', '// Set break point at this line.')
 
-@skipIf(debug_info="gmodules",
-bugnumber="https://bugs.llvm.org/show_bug.cgi?id=36048";)
 def test_with_run_command(self):
 """Test that that file and class static variables display correctly."""
 self.build()
Index: lldb/test/API/functionalities/data-formatter/data-formatter-cpp/TestDataFormatterCpp.py
===
--- lldb/test/API/functionalities/data-formatter/data-formatter-cpp/TestDataFormatterCpp.py
+++ lldb/test/API/functionalities/data-formatter/data-formatter-cpp/TestDataFormatterCpp.py
@@ -20,8 +20,6 @@
 # Find the line number to break at.
 self.line = line_number('main.cpp', '// Set break point at this line.')
 
-@skipIf(debug_info="gmodules",

[Lldb-commits] [PATCH] D112834: [lldb-vscode] Fix coredump load source mapping for first file

2021-10-29 Thread Greg Clayton via Phabricator via lldb-commits
clayborg accepted this revision.
clayborg added a comment.
This revision is now accepted and ready to land.

This is how launch does it as well, so LGTM.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112834

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


[Lldb-commits] [PATCH] D112856: [lldb] Only specify LLVM_ENABLE_RUNTIMES in the libcxx error message.

2021-10-29 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere created this revision.
JDevlieghere added reviewers: teemperor, labath.
Herald added a subscriber: mgorny.
JDevlieghere requested review of this revision.

Now that passing `libcxx` via `LLVM_ENABLE_PROJECTS` has been deprecated, 
update the error message and recommend using `LLVM_ENABLE_RUNTIMES` instead. 
This patch also remove the error message for the old layout.


https://reviews.llvm.org/D112856

Files:
  lldb/test/CMakeLists.txt


Index: lldb/test/CMakeLists.txt
===
--- lldb/test/CMakeLists.txt
+++ lldb/test/CMakeLists.txt
@@ -117,23 +117,12 @@
   endif()
 else()
   # We require libcxx for the test suite, so if we aren't building it,
-  # try to provide a helpful error about how to resolve the situation.
+  # provide a helpful error about how to resolve the situation.
   if(NOT TARGET cxx AND NOT libcxx IN_LIST LLVM_ENABLE_RUNTIMES)
-if(LLVM_ENABLE_PROJECTS STREQUAL "")
-  # If `LLVM_ENABLE_PROJECTS` is not being used (implying that we are
-  # using the old layout), suggest checking it out.
-  message(FATAL_ERROR
-"LLDB test suite requires libc++, but it is currently disabled. "
-"Please checkout `libcxx` in `llvm/projects` or disable tests "
-"via `LLDB_INCLUDE_TESTS=OFF`.")
-else()
-  # If `LLVM_ENABLE_PROJECTS` is being used, suggest adding it.
-  message(FATAL_ERROR
-"LLDB test suite requires libc++, but it is currently disabled. "
-"Please add `libcxx` to `LLVM_ENABLE_PROJECTS` or "
-"`LLVM_ENABLE_RUNTIMES`, or disable tests via "
-"`LLDB_INCLUDE_TESTS=OFF`.")
-endif()
+message(FATAL_ERROR
+  "LLDB test suite requires libc++, but it is currently disabled. "
+  "Please add `libcxx` to `LLVM_ENABLE_RUNTIMES` or disable tests via "
+  "`LLDB_INCLUDE_TESTS=OFF`.")
   endif()
 endif()
   endif()


Index: lldb/test/CMakeLists.txt
===
--- lldb/test/CMakeLists.txt
+++ lldb/test/CMakeLists.txt
@@ -117,23 +117,12 @@
   endif()
 else()
   # We require libcxx for the test suite, so if we aren't building it,
-  # try to provide a helpful error about how to resolve the situation.
+  # provide a helpful error about how to resolve the situation.
   if(NOT TARGET cxx AND NOT libcxx IN_LIST LLVM_ENABLE_RUNTIMES)
-if(LLVM_ENABLE_PROJECTS STREQUAL "")
-  # If `LLVM_ENABLE_PROJECTS` is not being used (implying that we are
-  # using the old layout), suggest checking it out.
-  message(FATAL_ERROR
-"LLDB test suite requires libc++, but it is currently disabled. "
-"Please checkout `libcxx` in `llvm/projects` or disable tests "
-"via `LLDB_INCLUDE_TESTS=OFF`.")
-else()
-  # If `LLVM_ENABLE_PROJECTS` is being used, suggest adding it.
-  message(FATAL_ERROR
-"LLDB test suite requires libc++, but it is currently disabled. "
-"Please add `libcxx` to `LLVM_ENABLE_PROJECTS` or "
-"`LLVM_ENABLE_RUNTIMES`, or disable tests via "
-"`LLDB_INCLUDE_TESTS=OFF`.")
-endif()
+message(FATAL_ERROR
+  "LLDB test suite requires libc++, but it is currently disabled. "
+  "Please add `libcxx` to `LLVM_ENABLE_RUNTIMES` or disable tests via "
+  "`LLDB_INCLUDE_TESTS=OFF`.")
   endif()
 endif()
   endif()
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D112752: [formatters] Add a libstdcpp formatter for multimap and unify modify tests across stdlibs

2021-10-29 Thread walter erquinigo via Phabricator via lldb-commits
wallace requested changes to this revision.
wallace added a comment.
This revision now requires changes to proceed.

pretty good, just cosmetic changes and a comment update needed




Comment at: lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp:915
+  stl_deref_flags,
+  "lldb.formatters.cpp.gnu_libstdcpp.StdSetOrMapSynthProvider")));
   cpp_category_sp->GetRegexTypeSyntheticsContainer()->Add(

Now I don't like the name of the class. Let's rename it to 
MakeLikeSynthProvider, and update the comments mentioning that it supports any 
map-like structure like map, multimap, set and multiset.



Comment at: 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/multimap/TestDataFormatterGenericMultiMap.py:40
+children.append(ValueCheck(value=child.GetValue()))
+self.expect_var_path(var_name, type=self.getVariableType(var_name), 
children=children)
+

nice!!



Comment at: 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/multimap/TestDataFormatterGenericMultiMap.py:88-285
+self.check("ii",2)
 
 lldbutil.continue_to_breakpoint(self.process(), bkpt)
 
 self.expect('frame variable ii',
 substrs=[multimap, 'size=4',
  '[2] = ',

the general practice is to leave a space after each comma for readability, e.g.
  self.check("ss", 3)
instead of
  self.check("ss",3)

these little details matter as it help people more easily distinguish the end 
of each token



Comment at: 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/multimap/TestDataFormatterGenericMultiMap.py:320
+
+self.check("ss",0)
+

same here


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112752

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


[Lldb-commits] [PATCH] D112785: [formatters] Add a libstdcpp formatter for multiset and unify tests across stdlibs

2021-10-29 Thread walter erquinigo via Phabricator via lldb-commits
wallace requested changes to this revision.
wallace added a comment.
This revision now requires changes to proceed.

let's land https://reviews.llvm.org/D112752 first and then this one




Comment at: lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp:915
+  stl_deref_flags,
+  "lldb.formatters.cpp.gnu_libstdcpp.StdSetOrMapSynthProvider")));
   cpp_category_sp->GetRegexTypeSyntheticsContainer()->Add(

As mentioned in https://reviews.llvm.org/D112752, you should rename the class 
to MakeLikeSynthProvider



Comment at: 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/multiset/TestDataFormatterGenericMultiSet.py:160
+
+

remove this line


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112785

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


[Lldb-commits] [PATCH] D112439: normalize file path when searching the source map

2021-10-29 Thread Xu Jun via Phabricator via lldb-commits
xujuntwt95329 updated this revision to Diff 383553.
xujuntwt95329 added a comment.

rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112439

Files:
  lldb/source/Target/PathMappingList.cpp
  lldb/unittests/Target/CMakeLists.txt
  lldb/unittests/Target/FindFileTest.cpp

Index: lldb/unittests/Target/FindFileTest.cpp
===
--- /dev/null
+++ lldb/unittests/Target/FindFileTest.cpp
@@ -0,0 +1,97 @@
+//===-- FindFileTest.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 "TestingSupport/TestUtilities.h"
+#include "lldb/Host/FileSystem.h"
+#include "lldb/Host/HostInfo.h"
+#include "lldb/Target/PathMappingList.h"
+#include "lldb/Utility/FileSpec.h"
+#include "llvm/ADT/ArrayRef.h"
+#include "llvm/Support/FileSystem.h"
+#include "llvm/Support/FileUtilities.h"
+#include "gtest/gtest.h"
+#include 
+
+using namespace llvm;
+using namespace llvm::sys::fs;
+using namespace lldb_private;
+
+namespace {
+struct Matches {
+  FileSpec original;
+  llvm::StringRef remapped;
+  Matches(const char *o, const char *r) : original(o), remapped(r) {}
+  Matches(const char *o, llvm::sys::path::Style style, const char *r)
+  : original(o, style), remapped(r) {}
+};
+
+class FindFileTest : public testing::Test {
+public:
+  void SetUp() override {
+FileSystem::Initialize();
+HostInfo::Initialize();
+  }
+  void TearDown() override {
+HostInfo::Terminate();
+FileSystem::Terminate();
+  }
+};
+} // namespace
+
+static void TestFileFindings(const PathMappingList &map,
+ llvm::ArrayRef matches,
+ llvm::ArrayRef fails) {
+  for (const auto &fail : fails) {
+SCOPED_TRACE(fail.GetCString());
+EXPECT_FALSE(map.FindFile(fail));
+  }
+
+  for (const auto &match : matches) {
+SCOPED_TRACE(match.original.GetPath() + " -> " + match.remapped);
+llvm::Optional remapped;
+
+EXPECT_TRUE(bool(remapped = map.FindFile(match.original)));
+EXPECT_TRUE(FileSpec(remapped.getValue()).GetPath() ==
+ConstString(match.remapped).GetStringRef());
+  }
+}
+
+TEST_F(FindFileTest, FindFileTests) {
+  const auto *Info = testing::UnitTest::GetInstance()->current_test_info();
+  llvm::SmallString<128> DirName, FileName;
+  int fd;
+
+  ASSERT_NO_ERROR(createUniqueDirectory(Info->name(), DirName));
+
+  sys::path::append(FileName, Twine(DirName), Twine("test"));
+  ASSERT_NO_ERROR(openFile(FileName, fd, CD_CreateAlways, FA_Read, OF_None));
+
+  llvm::FileRemover dir_remover(DirName);
+  llvm::FileRemover file_remover(FileName);
+  PathMappingList map;
+
+  map.Append(ConstString("/old"), ConstString(DirName.str()), false);
+  map.Append(ConstString(R"(C:\foo)"), ConstString(DirName.str()), false);
+
+  Matches matches[] = {
+  {"/old", llvm::sys::path::Style::posix, DirName.c_str()},
+  {"/old/test", llvm::sys::path::Style::posix, FileName.c_str()},
+  {R"(C:\foo)", llvm::sys::path::Style::windows, DirName.c_str()},
+  {R"(C:\foo\test)", llvm::sys::path::Style::windows, FileName.c_str()}};
+
+  ArrayRef fails{
+  // path not mapped
+  FileSpec("/foo", llvm::sys::path::Style::posix),
+  FileSpec("/new", llvm::sys::path::Style::posix),
+  FileSpec(R"(C:\new)", llvm::sys::path::Style::windows),
+  // path mapped, but file not exist
+  FileSpec("/old/test1", llvm::sys::path::Style::posix),
+  FileSpec(R"(C:\foo\test2)", llvm::sys::path::Style::windows)};
+
+  TestFileFindings(map, matches, fails);
+}
Index: lldb/unittests/Target/CMakeLists.txt
===
--- lldb/unittests/Target/CMakeLists.txt
+++ lldb/unittests/Target/CMakeLists.txt
@@ -7,6 +7,7 @@
   PathMappingListTest.cpp
   RemoteAwarePlatformTest.cpp
   StackFrameRecognizerTest.cpp
+  FindFileTest.cpp
 
   LINK_LIBS
   lldbCore
Index: lldb/source/Target/PathMappingList.cpp
===
--- lldb/source/Target/PathMappingList.cpp
+++ lldb/source/Target/PathMappingList.cpp
@@ -218,7 +218,12 @@
 }
 
 llvm::Optional PathMappingList::FindFile(const FileSpec &orig_spec) const {
-  if (auto remapped = RemapPath(orig_spec.GetPath(), /*only_if_exists=*/true))
+  // We must normalize the orig_spec again using the host's path style,
+  // otherwise there will be mismatch between the host and remote platform
+  // if they use different path styles.
+  if (auto remapped = RemapPath(
+  NormalizePath(ConstString(orig_spec.GetCString())).GetStringRef(),
+  /*only_if_exists=*/true))
 ret

[Lldb-commits] [PATCH] D112863: [lldb][NFC] avoid unnecessary roundtrips between different string types

2021-10-29 Thread Xu Jun via Phabricator via lldb-commits
xujuntwt95329 created this revision.
xujuntwt95329 requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

The amount of roundtrips between StringRefs, ConstStrings and std::strings is 
getting a bit out of hand, this patch avoid the unnecessary roundtrips.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D112863

Files:
  lldb/include/lldb/Target/PathMappingList.h
  lldb/source/API/SBTarget.cpp
  lldb/source/Commands/CommandObjectTarget.cpp
  lldb/source/Core/Module.cpp
  lldb/source/Core/ModuleList.cpp
  lldb/source/Interpreter/OptionValuePathMappings.cpp
  lldb/source/Target/PathMappingList.cpp
  lldb/unittests/Target/FindFileTest.cpp
  lldb/unittests/Target/PathMappingListTest.cpp

Index: lldb/unittests/Target/PathMappingListTest.cpp
===
--- lldb/unittests/Target/PathMappingListTest.cpp
+++ lldb/unittests/Target/PathMappingListTest.cpp
@@ -66,16 +66,16 @@
 #endif
   };
   PathMappingList map;
-  map.Append(ConstString("."), ConstString("/tmp"), false);
+  map.Append(".", "/tmp", false);
   TestPathMappings(map, matches, fails);
   PathMappingList map2;
-  map2.Append(ConstString(""), ConstString("/tmp"), false);
+  map2.Append("", "/tmp", false);
   TestPathMappings(map, matches, fails);
 }
 
 TEST(PathMappingListTest, AbsoluteTests) {
   PathMappingList map;
-  map.Append(ConstString("/old"), ConstString("/new"), false);
+  map.Append("/old", "/new", false);
   Matches matches[] = {
 {"/old", "/new"},
 {"/old/", "/new"},
@@ -97,7 +97,7 @@
 
 TEST(PathMappingListTest, RemapRoot) {
   PathMappingList map;
-  map.Append(ConstString("/"), ConstString("/new"), false);
+  map.Append("/", "/new", false);
   Matches matches[] = {
 {"/old", "/new/old"},
 {"/old/", "/new/old"},
@@ -118,7 +118,7 @@
 #ifndef _WIN32
 TEST(PathMappingListTest, CrossPlatformTests) {
   PathMappingList map;
-  map.Append(ConstString(R"(C:\old)"), ConstString("/new"), false);
+  map.Append(R"(C:\old)", "/new", false);
   Matches matches[] = {
 {R"(C:\old)", llvm::sys::path::Style::windows, "/new"},
 {R"(C:\old\)", llvm::sys::path::Style::windows, "/new"},
Index: lldb/unittests/Target/FindFileTest.cpp
===
--- lldb/unittests/Target/FindFileTest.cpp
+++ lldb/unittests/Target/FindFileTest.cpp
@@ -75,8 +75,8 @@
   llvm::FileRemover file_remover(FileName);
   PathMappingList map;
 
-  map.Append(ConstString("/old"), ConstString(DirName.str()), false);
-  map.Append(ConstString(R"(C:\foo)"), ConstString(DirName.str()), false);
+  map.Append("/old", DirName.str(), false);
+  map.Append(R"(C:\foo)", DirName.str(), false);
 
   Matches matches[] = {
   {"/old", llvm::sys::path::Style::posix, DirName.c_str()},
Index: lldb/source/Target/PathMappingList.cpp
===
--- lldb/source/Target/PathMappingList.cpp
+++ lldb/source/Target/PathMappingList.cpp
@@ -30,11 +30,11 @@
   // with the raw path pair, which doesn't work anymore because the paths have
   // been normalized when the debug info was loaded. So we need to store
   // nomalized path pairs to ensure things match up.
-  ConstString NormalizePath(ConstString path) {
-// If we use "path" to construct a FileSpec, it will normalize the path for
-// us. We then grab the string and turn it back into a ConstString.
-return ConstString(FileSpec(path.GetStringRef()).GetPath());
-  }
+std::string NormalizePath(llvm::StringRef path) {
+  // If we use "path" to construct a FileSpec, it will normalize the path for
+  // us. We then grab the string and turn it back into a ConstString.
+  return FileSpec(path).GetPath();
+}
 }
 // PathMappingList constructor
 PathMappingList::PathMappingList() : m_pairs() {}
@@ -59,8 +59,8 @@
 
 PathMappingList::~PathMappingList() = default;
 
-void PathMappingList::Append(ConstString path,
- ConstString replacement, bool notify) {
+void PathMappingList::Append(llvm::StringRef path, llvm::StringRef replacement,
+ bool notify) {
   ++m_mod_id;
   m_pairs.emplace_back(pair(NormalizePath(path), NormalizePath(replacement)));
   if (notify && m_callback)
@@ -78,9 +78,8 @@
   }
 }
 
-void PathMappingList::Insert(ConstString path,
- ConstString replacement, uint32_t index,
- bool notify) {
+void PathMappingList::Insert(llvm::StringRef path, llvm::StringRef replacement,
+ uint32_t index, bool notify) {
   ++m_mod_id;
   iterator insert_iter;
   if (index >= m_pairs.size())
@@ -93,9 +92,8 @@
 m_callback(*this, m_callback_baton);
 }
 
-bool PathMappingList::Replace(ConstString path,
-  ConstString replacement, uint32_t index,
-  bool notify) {
+bool PathMappingList::Replace(llvm::StringRef path, 

[Lldb-commits] [PATCH] D112834: [lldb-vscode] Fix coredump load source mapping for first file

2021-10-29 Thread walter erquinigo via Phabricator via lldb-commits
wallace accepted this revision.
wallace added a comment.

thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112834

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


[Lldb-commits] [PATCH] D112863: [lldb][NFC] avoid unnecessary roundtrips between different string types

2021-10-29 Thread walter erquinigo via Phabricator via lldb-commits
wallace accepted this revision.
wallace added a comment.
This revision is now accepted and ready to land.

thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112863

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


[Lldb-commits] [PATCH] D112863: [lldb][NFC] avoid unnecessary roundtrips between different string types

2021-10-29 Thread David Blaikie via Phabricator via lldb-commits
dblaikie added inline comments.



Comment at: lldb/source/API/SBTarget.cpp:1589
 
-  const ConstString csFrom(from), csTo(to);
-  if (!csFrom)
+  llvm::StringRef srFrom(from), srTo(to);
+  if (srFrom.empty())

Aside (since the old code did this too): Generally code should prefer `=` 
initialization over `()` initialization - because the former can't invoke 
explicit conversions, so is easier to read because it limits the possible 
conversion to simpler/safer ones (for instance, with unique ptrs 
"std::unique_ptr p = x();" tells me `x()` returns a unique_ptr or 
equivalent, but `std::unique_ptr p(x());` could be that `x()` returns a 
raw pointer and then I have to wonder if it meant to transfer ownership or not 
- but I don't have to wonder that in the first example because the type system 
checks that for me).

Admittedly StringRef has no explicit ctors - but it's a good general style to 
use imho (would be happy to include this in the LLVM style guide if this seems 
contentious in any way & is worth some discussion/formalization - but I think 
it's just generally good C++ practice & hopefully can be accepted as such)



Comment at: lldb/source/Target/PathMappingList.cpp:35
+  // If we use "path" to construct a FileSpec, it will normalize the path for
+  // us. We then grab the string and turn it back into a ConstString.
+  return FileSpec(path).GetPath();

out of date comment - maybe this comment isn't pulling its weight? The content 
seems fairly simple/probably self explanatory?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112863

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


[Lldb-commits] [PATCH] D112863: [lldb][NFC] avoid unnecessary roundtrips between different string types

2021-10-29 Thread Xu Jun via Phabricator via lldb-commits
xujuntwt95329 updated this revision to Diff 383559.
xujuntwt95329 added a comment.

address dblaikie's comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112863

Files:
  lldb/include/lldb/Target/PathMappingList.h
  lldb/source/API/SBTarget.cpp
  lldb/source/Commands/CommandObjectTarget.cpp
  lldb/source/Core/Module.cpp
  lldb/source/Core/ModuleList.cpp
  lldb/source/Interpreter/OptionValuePathMappings.cpp
  lldb/source/Target/PathMappingList.cpp
  lldb/unittests/Target/FindFileTest.cpp
  lldb/unittests/Target/PathMappingListTest.cpp

Index: lldb/unittests/Target/PathMappingListTest.cpp
===
--- lldb/unittests/Target/PathMappingListTest.cpp
+++ lldb/unittests/Target/PathMappingListTest.cpp
@@ -66,16 +66,16 @@
 #endif
   };
   PathMappingList map;
-  map.Append(ConstString("."), ConstString("/tmp"), false);
+  map.Append(".", "/tmp", false);
   TestPathMappings(map, matches, fails);
   PathMappingList map2;
-  map2.Append(ConstString(""), ConstString("/tmp"), false);
+  map2.Append("", "/tmp", false);
   TestPathMappings(map, matches, fails);
 }
 
 TEST(PathMappingListTest, AbsoluteTests) {
   PathMappingList map;
-  map.Append(ConstString("/old"), ConstString("/new"), false);
+  map.Append("/old", "/new", false);
   Matches matches[] = {
 {"/old", "/new"},
 {"/old/", "/new"},
@@ -97,7 +97,7 @@
 
 TEST(PathMappingListTest, RemapRoot) {
   PathMappingList map;
-  map.Append(ConstString("/"), ConstString("/new"), false);
+  map.Append("/", "/new", false);
   Matches matches[] = {
 {"/old", "/new/old"},
 {"/old/", "/new/old"},
@@ -118,7 +118,7 @@
 #ifndef _WIN32
 TEST(PathMappingListTest, CrossPlatformTests) {
   PathMappingList map;
-  map.Append(ConstString(R"(C:\old)"), ConstString("/new"), false);
+  map.Append(R"(C:\old)", "/new", false);
   Matches matches[] = {
 {R"(C:\old)", llvm::sys::path::Style::windows, "/new"},
 {R"(C:\old\)", llvm::sys::path::Style::windows, "/new"},
Index: lldb/unittests/Target/FindFileTest.cpp
===
--- lldb/unittests/Target/FindFileTest.cpp
+++ lldb/unittests/Target/FindFileTest.cpp
@@ -75,8 +75,8 @@
   llvm::FileRemover file_remover(FileName);
   PathMappingList map;
 
-  map.Append(ConstString("/old"), ConstString(DirName.str()), false);
-  map.Append(ConstString(R"(C:\foo)"), ConstString(DirName.str()), false);
+  map.Append("/old", DirName.str(), false);
+  map.Append(R"(C:\foo)", DirName.str(), false);
 
   Matches matches[] = {
   {"/old", llvm::sys::path::Style::posix, DirName.c_str()},
Index: lldb/source/Target/PathMappingList.cpp
===
--- lldb/source/Target/PathMappingList.cpp
+++ lldb/source/Target/PathMappingList.cpp
@@ -30,11 +30,11 @@
   // with the raw path pair, which doesn't work anymore because the paths have
   // been normalized when the debug info was loaded. So we need to store
   // nomalized path pairs to ensure things match up.
-  ConstString NormalizePath(ConstString path) {
-// If we use "path" to construct a FileSpec, it will normalize the path for
-// us. We then grab the string and turn it back into a ConstString.
-return ConstString(FileSpec(path.GetStringRef()).GetPath());
-  }
+std::string NormalizePath(llvm::StringRef path) {
+  // If we use "path" to construct a FileSpec, it will normalize the path for
+  // us. We then grab the string.
+  return FileSpec(path).GetPath();
+}
 }
 // PathMappingList constructor
 PathMappingList::PathMappingList() : m_pairs() {}
@@ -59,8 +59,8 @@
 
 PathMappingList::~PathMappingList() = default;
 
-void PathMappingList::Append(ConstString path,
- ConstString replacement, bool notify) {
+void PathMappingList::Append(llvm::StringRef path, llvm::StringRef replacement,
+ bool notify) {
   ++m_mod_id;
   m_pairs.emplace_back(pair(NormalizePath(path), NormalizePath(replacement)));
   if (notify && m_callback)
@@ -78,9 +78,8 @@
   }
 }
 
-void PathMappingList::Insert(ConstString path,
- ConstString replacement, uint32_t index,
- bool notify) {
+void PathMappingList::Insert(llvm::StringRef path, llvm::StringRef replacement,
+ uint32_t index, bool notify) {
   ++m_mod_id;
   iterator insert_iter;
   if (index >= m_pairs.size())
@@ -93,9 +92,8 @@
 m_callback(*this, m_callback_baton);
 }
 
-bool PathMappingList::Replace(ConstString path,
-  ConstString replacement, uint32_t index,
-  bool notify) {
+bool PathMappingList::Replace(llvm::StringRef path, llvm::StringRef replacement,
+  uint32_t index, bool notify) {
   if (index >= m_pairs.size())
 return false;
   ++m_mod_id;
@@ -221,2

[Lldb-commits] [PATCH] D112863: [lldb][NFC] avoid unnecessary roundtrips between different string types

2021-10-29 Thread Xu Jun via Phabricator via lldb-commits
xujuntwt95329 marked 2 inline comments as done.
xujuntwt95329 added a comment.

@dblaikie Thanks for your detailed comments, I've uploaded the new patch-set


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112863

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


[Lldb-commits] [PATCH] D112439: normalize file path when searching the source map

2021-10-29 Thread Xu Jun via Phabricator via lldb-commits
xujuntwt95329 marked 2 inline comments as done.
xujuntwt95329 added a comment.

Hi, @aprantl

I've submitted a NFC patch here:
https://reviews.llvm.org/D112863

Seems that patch can't build by CI because it is based on this patch. In my 
understanding we need to merge this patch firstly and rebase that NFC patch to 
let CI work, right?

Please let me know if I misunderstand the workflow.

Thanks a lot!




Comment at: lldb/source/Target/PathMappingList.cpp:33
   // nomalized path pairs to ensure things match up.
   ConstString NormalizePath(ConstString path) {
 // If we use "path" to construct a FileSpec, it will normalize the path for

aprantl wrote:
> Why does this take a ConstString argument if it immediately calls 
> GetStringRef on it?
> Could you change this to take a StringRef here or in a follow-up NFC commit?
I've submitted a separate NFC patch:
https://reviews.llvm.org/D112863


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112439

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