[Lldb-commits] [PATCH] D129261: [lldb/test] Add Shell/Expr/TestStringLiteralExpr.test

2022-07-08 Thread serge via Phabricator via lldb-commits
serge-sans-paille added a comment.

I checked the test base and didn't find any similar test either.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129261

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


[Lldb-commits] [lldb] b042d15 - [lldb/test] Add Shell/Expr/TestStringLiteralExpr.test

2022-07-08 Thread via lldb-commits

Author: Jesus Checa Hidalgo
Date: 2022-07-08T10:01:07+02:00
New Revision: b042d15d2e39eea528c51a30fe637b9ea84250d3

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

LOG: [lldb/test] Add Shell/Expr/TestStringLiteralExpr.test

This test should exercise the usage of expressions containing
string literals and ensure that lldb doesn't crash.

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

Added: 
lldb/test/Shell/Expr/TestStringLiteralExpr.test

Modified: 


Removed: 




diff  --git a/lldb/test/Shell/Expr/TestStringLiteralExpr.test 
b/lldb/test/Shell/Expr/TestStringLiteralExpr.test
new file mode 100644
index 0..89570599f8f4f
--- /dev/null
+++ b/lldb/test/Shell/Expr/TestStringLiteralExpr.test
@@ -0,0 +1,11 @@
+# RUN: echo "int main() { return 0; }" | %clang_host -x c -o %t -
+# RUN: %lldb -s %s %t | FileCheck %s
+
+# Make sure that lldb doesn't crash when evaluating expressions with string 
literals
+b main
+run
+expr "hello there"
+expr printf("hello there")
+
+# CHECK: (const char[12]) $0 = "hello there"
+# CHECK: (int) $1 = 11



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


[Lldb-commits] [PATCH] D129261: [lldb/test] Add Shell/Expr/TestStringLiteralExpr.test

2022-07-08 Thread serge via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGb042d15d2e39: [lldb/test] Add 
Shell/Expr/TestStringLiteralExpr.test (authored by jchecahi, committed by 
serge-sans-paille).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129261

Files:
  lldb/test/Shell/Expr/TestStringLiteralExpr.test


Index: lldb/test/Shell/Expr/TestStringLiteralExpr.test
===
--- /dev/null
+++ lldb/test/Shell/Expr/TestStringLiteralExpr.test
@@ -0,0 +1,11 @@
+# RUN: echo "int main() { return 0; }" | %clang_host -x c -o %t -
+# RUN: %lldb -s %s %t | FileCheck %s
+
+# Make sure that lldb doesn't crash when evaluating expressions with string 
literals
+b main
+run
+expr "hello there"
+expr printf("hello there")
+
+# CHECK: (const char[12]) $0 = "hello there"
+# CHECK: (int) $1 = 11


Index: lldb/test/Shell/Expr/TestStringLiteralExpr.test
===
--- /dev/null
+++ lldb/test/Shell/Expr/TestStringLiteralExpr.test
@@ -0,0 +1,11 @@
+# RUN: echo "int main() { return 0; }" | %clang_host -x c -o %t -
+# RUN: %lldb -s %s %t | FileCheck %s
+
+# Make sure that lldb doesn't crash when evaluating expressions with string literals
+b main
+run
+expr "hello there"
+expr printf("hello there")
+
+# CHECK: (const char[12]) $0 = "hello there"
+# CHECK: (int) $1 = 11
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D128956: make debugserver able to inspect mach-o binaries present in memory, but not yet registered with dyld

2022-07-08 Thread David Spickett via Phabricator via lldb-commits
DavidSpickett accepted this revision.
DavidSpickett added a comment.
This revision is now accepted and ready to land.

Looks good from my perspective.




Comment at: lldb/test/API/macosx/unregistered-macho/main.c:48
+  memcpy(p, &uuid, sizeof(uuid));
+  p += sizeof(uuid);
+

jasonmolenda wrote:
> DavidSpickett wrote:
> > This is redundant (the test uses `macho_buf`).
> I needed to increment `p` so it points to the end of the mach-o image if I 
> want to write it to disk and try sending it through `otool` for testing.  
> You're right though, this has no effect to the program itself.
Got it, now I see it in the comments below. Fair enough.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128956

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


[Lldb-commits] [PATCH] D129338: Tell the user which pathname was invalid...

2022-07-08 Thread David Spickett via Phabricator via lldb-commits
DavidSpickett added inline comments.



Comment at: 
lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp:2640
   if (!pathname || !pathname[0]) {
-error.SetErrorString("invalid pathname");
+error.SetErrorString("empty path");
 return false;

Is this testable? Maybe not because the top level command always wants some 
string, unless `""` is accepted.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129338

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


[Lldb-commits] [lldb] 132d711 - [lldb/test] Disable TestStringLiteralExpr.test on Windows

2022-07-08 Thread via lldb-commits

Author: serge-sans-paille
Date: 2022-07-08T12:17:31+02:00
New Revision: 132d711554cbb3db0b0efd1e88d2acb9278b6be9

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

LOG: [lldb/test] Disable TestStringLiteralExpr.test on Windows

This test, introduced by b042d15d2e39eea528c51a30fe637b9ea84250d3, fails on
https://lab.llvm.org/buildbot/#/builders/83/builds/20933/steps/7/logs/stdio

but succeeds on other targets, see for instance
https://lab.llvm.org/buildbot/#/builders/68/builds/35462/steps/6/logs/stdio

This test is not be arch specific, just disabling it on Windows.

Added: 


Modified: 
lldb/test/Shell/Expr/TestStringLiteralExpr.test

Removed: 




diff  --git a/lldb/test/Shell/Expr/TestStringLiteralExpr.test 
b/lldb/test/Shell/Expr/TestStringLiteralExpr.test
index 89570599f8f4f..a33acb9ab0a66 100644
--- a/lldb/test/Shell/Expr/TestStringLiteralExpr.test
+++ b/lldb/test/Shell/Expr/TestStringLiteralExpr.test
@@ -1,3 +1,4 @@
+# UNSUPPORTED: system-windows
 # RUN: echo "int main() { return 0; }" | %clang_host -x c -o %t -
 # RUN: %lldb -s %s %t | FileCheck %s
 



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


[Lldb-commits] [PATCH] D129364: [LLDB][DataFormatter] Add data formatter for libcxx std::unordered_map iterator

2022-07-08 Thread Michael Buch via Phabricator via lldb-commits
Michael137 created this revision.
Michael137 added reviewers: aprantl, jingham.
Herald added a project: All.
Michael137 requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

This patch adds a formatter for libcxx's `std::unordered_map` iterators.
The implementation follows a similar appraoch to the `std::map` iterator
formatter. I was hesistant about coupling the two into a common
implementation since the libcxx layouts might change for one of the
the containers but not the other.

All `std::unordered_map` iterators are covered with this patch:

1. const/non-const key/value iterators
2. const/non-const bucket iterators

Note that, we currently don't have a formatter for `std::unordered_map`.
This patch doesn't change that, we merely add support for its iterators,
because that's what Xcode users requested. One can still see contents
of `std::unordered_map`, whereas with iterators it's less ergonomic.

**Testing**

- Added API test


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D129364

Files:
  lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
  lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp
  lldb/source/Plugins/Language/CPlusPlus/LibCxx.h
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/unordered_map/Makefile
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/unordered_map/TestDataFormatterLibccUnorderedMap.py
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/unordered_map/main.cpp

Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/unordered_map/main.cpp
===
--- /dev/null
+++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/unordered_map/main.cpp
@@ -0,0 +1,28 @@
+#include 
+#include 
+#include 
+
+using StringMapT = std::unordered_map;
+
+int main() {
+  StringMapT string_map;
+  {
+auto empty_iter = string_map.begin();
+auto const_empty_iter = string_map.cbegin();
+std::printf("Break here");
+  }
+  string_map["Foo"] = "Bar";
+  string_map["Baz"] = "Qux";
+
+  {
+auto foo = string_map.find("Foo");
+auto invalid = string_map.find("Invalid");
+
+StringMapT::const_iterator const_baz = string_map.find("Baz");
+auto bucket_it = string_map.begin(string_map.bucket("Baz"));
+auto const_bucket_it = string_map.cbegin(string_map.bucket("Baz"));
+std::printf("Break here");
+  }
+
+  return 0;
+}
Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/unordered_map/TestDataFormatterLibccUnorderedMap.py
===
--- /dev/null
+++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/unordered_map/TestDataFormatterLibccUnorderedMap.py
@@ -0,0 +1,53 @@
+"""
+Test formatting of std::unordered_map related structures.
+"""
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+class LibcxxUnorderedMapDataFormatterTestCase(TestBase):
+
+@add_test_categories(['libc++'])
+def test_with_run_command(self):
+"""Test that std::unordered_map related structures are formatted correctly when printed.
+   Currently only tests format of std::unordered_map iterators.
+"""
+self.build()
+(self.target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint(
+self, 'Break here', lldb.SBFileSpec('main.cpp', False))
+
+# Test empty iterators
+self.expect_expr('empty_iter', '')
+self.expect_expr('const_empty_iter', '')
+
+lldbutil.continue_to_breakpoint(process, bkpt)
+
+# Check that key/value is correctly formatted
+self.expect_expr('foo', result_children=[
+ ValueCheck(name='first', summary='"Foo"'),
+ ValueCheck(name='second', summary='"Bar"')
+])
+
+# Check invalid iterator is empty
+self.expect_expr('invalid', '')
+
+# Const key/val iterator
+self.expect_expr('const_baz', result_children=[
+ ValueCheck(name='first', summary='"Baz"'),
+ ValueCheck(name='second', summary='"Qux"')
+])
+
+# Bucket iterators
+# I.e., std::__hash_map_const_iterator>
+# and std::__hash_map_iterator>
+self.expect_expr('bucket_it', result_children=[
+ ValueCheck(name='first', summary='"Baz"'),
+ ValueCheck(name='second', summary='"Qux"')
+])
+
+self.expect_expr('bucket_it', result_children=[
+ ValueCheck(name='first', summary='"Baz"'),
+ ValueCheck(name='second', summary='"Qux"')
+])
Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/unordered_map/Makefile
==

[Lldb-commits] [PATCH] D129364: [LLDB][DataFormatter] Add data formatter for libcxx std::unordered_map iterator

2022-07-08 Thread Michael Buch via Phabricator via lldb-commits
Michael137 updated this revision to Diff 443212.
Michael137 added a comment.

- Fixed class documentation


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129364

Files:
  lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
  lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp
  lldb/source/Plugins/Language/CPlusPlus/LibCxx.h
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/unordered_map/Makefile
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/unordered_map/TestDataFormatterLibccUnorderedMap.py
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/unordered_map/main.cpp

Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/unordered_map/main.cpp
===
--- /dev/null
+++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/unordered_map/main.cpp
@@ -0,0 +1,28 @@
+#include 
+#include 
+#include 
+
+using StringMapT = std::unordered_map;
+
+int main() {
+  StringMapT string_map;
+  {
+auto empty_iter = string_map.begin();
+auto const_empty_iter = string_map.cbegin();
+std::printf("Break here");
+  }
+  string_map["Foo"] = "Bar";
+  string_map["Baz"] = "Qux";
+
+  {
+auto foo = string_map.find("Foo");
+auto invalid = string_map.find("Invalid");
+
+StringMapT::const_iterator const_baz = string_map.find("Baz");
+auto bucket_it = string_map.begin(string_map.bucket("Baz"));
+auto const_bucket_it = string_map.cbegin(string_map.bucket("Baz"));
+std::printf("Break here");
+  }
+
+  return 0;
+}
Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/unordered_map/TestDataFormatterLibccUnorderedMap.py
===
--- /dev/null
+++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/unordered_map/TestDataFormatterLibccUnorderedMap.py
@@ -0,0 +1,53 @@
+"""
+Test formatting of std::unordered_map related structures.
+"""
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+class LibcxxUnorderedMapDataFormatterTestCase(TestBase):
+
+@add_test_categories(['libc++'])
+def test_with_run_command(self):
+"""Test that std::unordered_map related structures are formatted correctly when printed.
+   Currently only tests format of std::unordered_map iterators.
+"""
+self.build()
+(self.target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint(
+self, 'Break here', lldb.SBFileSpec('main.cpp', False))
+
+# Test empty iterators
+self.expect_expr('empty_iter', '')
+self.expect_expr('const_empty_iter', '')
+
+lldbutil.continue_to_breakpoint(process, bkpt)
+
+# Check that key/value is correctly formatted
+self.expect_expr('foo', result_children=[
+ ValueCheck(name='first', summary='"Foo"'),
+ ValueCheck(name='second', summary='"Bar"')
+])
+
+# Check invalid iterator is empty
+self.expect_expr('invalid', '')
+
+# Const key/val iterator
+self.expect_expr('const_baz', result_children=[
+ ValueCheck(name='first', summary='"Baz"'),
+ ValueCheck(name='second', summary='"Qux"')
+])
+
+# Bucket iterators
+# I.e., std::__hash_map_const_iterator>
+# and std::__hash_map_iterator>
+self.expect_expr('bucket_it', result_children=[
+ ValueCheck(name='first', summary='"Baz"'),
+ ValueCheck(name='second', summary='"Qux"')
+])
+
+self.expect_expr('bucket_it', result_children=[
+ ValueCheck(name='first', summary='"Baz"'),
+ ValueCheck(name='second', summary='"Qux"')
+])
Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/unordered_map/Makefile
===
--- /dev/null
+++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/unordered_map/Makefile
@@ -0,0 +1,6 @@
+CXX_SOURCES := main.cpp
+
+USE_LIBCPP := 1
+
+CXXFLAGS_EXTRAS := -O0
+include Makefile.rules
Index: lldb/source/Plugins/Language/CPlusPlus/LibCxx.h
===
--- lldb/source/Plugins/Language/CPlusPlus/LibCxx.h
+++ lldb/source/Plugins/Language/CPlusPlus/LibCxx.h
@@ -103,6 +103,56 @@
 LibCxxMapIteratorSyntheticFrontEndCreator(CXXSyntheticChildren *,
   lldb::ValueObjectSP);
 
+/// Formats libcxx's std::unordered_map iterators
+///
+/// In raw form a std::unordered_map::iterator is represented as follows:
+///
+/// (lldb) var it --raw --ptr-depth 1
+/// (std::__1::__hash_map_

[Lldb-commits] [PATCH] D129367: [LLDB][ClangExpression] Remove unused StructVars::m_object_pointer_type

2022-07-08 Thread Michael Buch via Phabricator via lldb-commits
Michael137 created this revision.
Michael137 added reviewers: jingham, aprantl.
Herald added a project: All.
Michael137 requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

This member variable was removed a while ago in
443427357f539f5ac97e664a53aa9e50788abce9. It was previously used in
materialization code paths that have since been removed. Nowadays,
`m_object_pointer_type` gets set but not used anywhere.

This patch simply removes all remaining instances of it and any
supporting code.

**Testing**

- API tests pass


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D129367

Files:
  lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
  lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.h

Index: lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.h
===
--- lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.h
+++ lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.h
@@ -353,7 +353,7 @@
   /// The following values contain layout information for the materialized
   /// struct, but are not specific to a single materialization
   struct StructVars {
-StructVars() : m_result_name(), m_object_pointer_type(nullptr, nullptr) {}
+StructVars() : m_result_name() {}
 
 lldb::offset_t m_struct_alignment =
 0;///< The alignment of the struct in bytes.
@@ -364,8 +364,6 @@
/// added since).
 ConstString
 m_result_name; ///< The name of the result variable ($1, for example)
-TypeFromUser m_object_pointer_type; ///< The type of the "this" variable, if
-///one exists
   };
 
   std::unique_ptr m_struct_vars;
Index: lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
===
--- lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
+++ lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
@@ -772,10 +772,6 @@
   return;
 
 AddContextClassType(context, TypeFromUser(m_ctx_obj->GetCompilerType()));
-
-m_struct_vars->m_object_pointer_type =
-TypeFromUser(ctx_obj_ptr->GetCompilerType());
-
 return;
   }
 
@@ -810,18 +806,6 @@
  class_qual_type.getAsString());
 
 AddContextClassType(context, class_user_type);
-
-if (method_decl->isInstance()) {
-  // self is a pointer to the object
-
-  QualType class_pointer_type =
-  method_decl->getASTContext().getPointerType(class_qual_type);
-
-  TypeFromUser self_user_type(class_pointer_type.getAsOpaquePtr(),
-  function_decl_ctx.GetTypeSystem());
-
-  m_struct_vars->m_object_pointer_type = self_user_type;
-}
 return;
   }
 
@@ -852,8 +836,6 @@
  ClangUtil::GetQualType(pointee_type).getAsString());
 
 AddContextClassType(context, pointee_type);
-TypeFromUser this_user_type(this_type->GetFullCompilerType());
-m_struct_vars->m_object_pointer_type = this_user_type;
   }
 }
 
@@ -869,10 +851,6 @@
   return;
 
 AddOneType(context, TypeFromUser(m_ctx_obj->GetCompilerType()));
-
-m_struct_vars->m_object_pointer_type =
-TypeFromUser(ctx_obj_ptr->GetCompilerType());
-
 return;
   }
 
@@ -917,28 +895,6 @@
  ClangUtil::ToString(interface_type));
 
 AddOneType(context, class_user_type);
-
-if (method_decl->isInstanceMethod()) {
-  // self is a pointer to the object
-
-  QualType class_pointer_type =
-  method_decl->getASTContext().getObjCObjectPointerType(
-  QualType(interface_type, 0));
-
-  TypeFromUser self_user_type(class_pointer_type.getAsOpaquePtr(),
-  function_decl_ctx.GetTypeSystem());
-
-  m_struct_vars->m_object_pointer_type = self_user_type;
-} else {
-  // self is a Class pointer
-  QualType class_type = method_decl->getASTContext().getObjCClassType();
-
-  TypeFromUser self_user_type(class_type.getAsOpaquePtr(),
-  function_decl_ctx.GetTypeSystem());
-
-  m_struct_vars->m_object_pointer_type = self_user_type;
-}
-
 return;
   }
   // This branch will get hit if we are executing code in the context of
@@ -981,10 +937,6 @@
   TypeFromUser class_user_type(self_clang_type);
 
   AddOneType(context, class_user_type);
-
-  TypeFromUser self_user_type(self_type->GetFullCompilerType());
-
-  m_struct_vars->m_object_pointer_type = self_user_type;
 }
 
 void ClangExpressionDeclMap::LookupLocalVarNamespace(
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] d2e8686 - [libc++] Re-apply the use of ABI tags to provide per-TU insulation

2022-07-08 Thread Louis Dionne via lldb-commits

Author: Louis Dionne
Date: 2022-07-08T08:38:36-04:00
New Revision: d2e86866be0f17295c5f677333c2a9952e259dd7

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

LOG: [libc++] Re-apply the use of ABI tags to provide per-TU insulation

This commit re-applies 9ee97ce3b830, which was reverted by 61d417ce
because it broke the LLDB data formatter tests. It also re-applies
6148c79a (the manual GN change associated to it).

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

Added: 


Modified: 
libcxx/CMakeLists.txt
libcxx/cmake/caches/Apple.cmake
libcxx/docs/BuildingLibcxx.rst
libcxx/docs/DesignDocs/VisibilityMacros.rst
libcxx/docs/ReleaseNotes.rst
libcxx/include/__config
libcxx/include/__config_site.in
lldb/packages/Python/lldbsuite/test/make/Makefile.rules
llvm/utils/gn/secondary/libcxx/include/BUILD.gn

Removed: 
libcxx/test/libcxx/strings/basic.string/PR42676.sh.cpp



diff  --git a/libcxx/CMakeLists.txt b/libcxx/CMakeLists.txt
index b118007eacbca..3d63bb0c8fbf8 100644
--- a/libcxx/CMakeLists.txt
+++ b/libcxx/CMakeLists.txt
@@ -205,7 +205,6 @@ if (NOT ("${LIBCXX_TYPEINFO_COMPARISON_IMPLEMENTATION}" 
IN_LIST TYPEINFO_COMPARI
LIBCXX_TYPEINFO_COMPARISON_IMPLEMENTATION")
 endif()
 
-option(LIBCXX_HIDE_FROM_ABI_PER_TU_BY_DEFAULT "Enable per TU ABI insulation by 
default. To be used by vendors." OFF)
 set(LIBCXX_ABI_DEFINES "" CACHE STRING "A semicolon separated list of ABI 
macros to define in the site config header.")
 option(LIBCXX_EXTRA_SITE_DEFINES "Extra defines to add into __config_site")
 option(LIBCXX_USE_COMPILER_RT "Use compiler-rt instead of libgcc" OFF)
@@ -847,7 +846,6 @@ config_define(${LIBCXX_ABI_VERSION} _LIBCPP_ABI_VERSION)
 config_define(${LIBCXX_ABI_NAMESPACE} _LIBCPP_ABI_NAMESPACE)
 config_define_if(LIBCXX_ABI_FORCE_ITANIUM _LIBCPP_ABI_FORCE_ITANIUM)
 config_define_if(LIBCXX_ABI_FORCE_MICROSOFT _LIBCPP_ABI_FORCE_MICROSOFT)
-config_define_if(LIBCXX_HIDE_FROM_ABI_PER_TU_BY_DEFAULT 
_LIBCPP_HIDE_FROM_ABI_PER_TU_BY_DEFAULT)
 config_define_if_not(LIBCXX_ENABLE_THREADS _LIBCPP_HAS_NO_THREADS)
 config_define_if_not(LIBCXX_ENABLE_MONOTONIC_CLOCK 
_LIBCPP_HAS_NO_MONOTONIC_CLOCK)
 if (NOT LIBCXX_TYPEINFO_COMPARISON_IMPLEMENTATION STREQUAL "default")

diff  --git a/libcxx/cmake/caches/Apple.cmake b/libcxx/cmake/caches/Apple.cmake
index db567bd394b12..ea701a43f96a3 100644
--- a/libcxx/cmake/caches/Apple.cmake
+++ b/libcxx/cmake/caches/Apple.cmake
@@ -8,7 +8,6 @@ set(LIBCXX_ENABLE_EXPERIMENTAL_LIBRARY OFF CACHE BOOL "")
 set(LIBCXX_ENABLE_STATIC ON CACHE BOOL "")
 set(LIBCXX_ENABLE_SHARED ON CACHE BOOL "")
 set(LIBCXX_CXX_ABI libcxxabi CACHE STRING "")
-set(LIBCXX_HIDE_FROM_ABI_PER_TU_BY_DEFAULT ON CACHE BOOL "")
 set(LIBCXX_ENABLE_BACKWARDS_COMPATIBILITY_DEBUG_MODE_SYMBOLS OFF CACHE BOOL "")
 set(LIBCXX_ENABLE_VENDOR_AVAILABILITY_ANNOTATIONS ON CACHE BOOL "")
 set(LIBCXX_ENABLE_INCOMPLETE_FEATURES OFF CACHE BOOL "")

diff  --git a/libcxx/docs/BuildingLibcxx.rst b/libcxx/docs/BuildingLibcxx.rst
index 3f4e314382d82..5069c7fe06928 100644
--- a/libcxx/docs/BuildingLibcxx.rst
+++ b/libcxx/docs/BuildingLibcxx.rst
@@ -412,15 +412,6 @@ libc++ Feature Options
   Use the specified GCC toolchain and standard library when building the native
   stdlib benchmark tests.
 
-.. option:: LIBCXX_HIDE_FROM_ABI_PER_TU_BY_DEFAULT:BOOL
-
-  **Default**: ``OFF``
-
-  Pick the default for whether to constrain ABI-unstable symbols to
-  each individual translation unit. This setting controls whether
-  `_LIBCPP_HIDE_FROM_ABI_PER_TU_BY_DEFAULT` is defined by default --
-  see the documentation of that macro for details.
-
 
 libc++ ABI Feature Options
 --

diff  --git a/libcxx/docs/DesignDocs/VisibilityMacros.rst 
b/libcxx/docs/DesignDocs/VisibilityMacros.rst
index a165fc49afcf4..d1c162682b666 100644
--- a/libcxx/docs/DesignDocs/VisibilityMacros.rst
+++ b/libcxx/docs/DesignDocs/VisibilityMacros.rst
@@ -65,41 +65,6 @@ Visibility Macros
   ABI, we should create a new _LIBCPP_HIDE_FROM_ABI_AFTER_XXX macro, and we can
   use it to start removing symbols from the ABI after that stable version.
 
-**_LIBCPP_HIDE_FROM_ABI_PER_TU**
-  This macro controls whether symbols hidden from the ABI with 
`_LIBCPP_HIDE_FROM_ABI`
-  are local to each translation unit in addition to being local to each final
-  linked image. This macro is defined to either 0 or 1. When it is defined to
-  1, translation units compiled with 
diff erent versions of libc++ can be linked
-  together, since all non ABI-facing functions are local to each translation 
unit.
-  This allows static archives built with 
diff erent versions of libc++ to be linked
-  together. This also means that functions marked with `_LIBCPP_HIDE_FROM_ABI`
-  are not guaranteed to hav

[Lldb-commits] [PATCH] D129367: [LLDB][ClangExpression] Remove unused StructVars::m_object_pointer_type

2022-07-08 Thread Michael Buch via Phabricator via lldb-commits
Michael137 added a comment.

One potential functional change here would be the removal of 
`GetFullCompilerType` in the `$__lldb_objc_class` code path. Could probably 
just put it back since it's not immediately obvious how I'd test it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129367

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


[Lldb-commits] [PATCH] D129364: [LLDB][DataFormatter] Add data formatter for libcxx std::unordered_map iterator

2022-07-08 Thread Michael Buch via Phabricator via lldb-commits
Michael137 updated this revision to Diff 443227.
Michael137 added a comment.

- Cleaned up documentation further


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129364

Files:
  lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
  lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp
  lldb/source/Plugins/Language/CPlusPlus/LibCxx.h
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/unordered_map/Makefile
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/unordered_map/TestDataFormatterLibccUnorderedMap.py
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/unordered_map/main.cpp

Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/unordered_map/main.cpp
===
--- /dev/null
+++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/unordered_map/main.cpp
@@ -0,0 +1,28 @@
+#include 
+#include 
+#include 
+
+using StringMapT = std::unordered_map;
+
+int main() {
+  StringMapT string_map;
+  {
+auto empty_iter = string_map.begin();
+auto const_empty_iter = string_map.cbegin();
+std::printf("Break here");
+  }
+  string_map["Foo"] = "Bar";
+  string_map["Baz"] = "Qux";
+
+  {
+auto foo = string_map.find("Foo");
+auto invalid = string_map.find("Invalid");
+
+StringMapT::const_iterator const_baz = string_map.find("Baz");
+auto bucket_it = string_map.begin(string_map.bucket("Baz"));
+auto const_bucket_it = string_map.cbegin(string_map.bucket("Baz"));
+std::printf("Break here");
+  }
+
+  return 0;
+}
Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/unordered_map/TestDataFormatterLibccUnorderedMap.py
===
--- /dev/null
+++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/unordered_map/TestDataFormatterLibccUnorderedMap.py
@@ -0,0 +1,53 @@
+"""
+Test formatting of std::unordered_map related structures.
+"""
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+class LibcxxUnorderedMapDataFormatterTestCase(TestBase):
+
+@add_test_categories(['libc++'])
+def test_with_run_command(self):
+"""Test that std::unordered_map related structures are formatted correctly when printed.
+   Currently only tests format of std::unordered_map iterators.
+"""
+self.build()
+(self.target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint(
+self, 'Break here', lldb.SBFileSpec('main.cpp', False))
+
+# Test empty iterators
+self.expect_expr('empty_iter', '')
+self.expect_expr('const_empty_iter', '')
+
+lldbutil.continue_to_breakpoint(process, bkpt)
+
+# Check that key/value is correctly formatted
+self.expect_expr('foo', result_children=[
+ ValueCheck(name='first', summary='"Foo"'),
+ ValueCheck(name='second', summary='"Bar"')
+])
+
+# Check invalid iterator is empty
+self.expect_expr('invalid', '')
+
+# Const key/val iterator
+self.expect_expr('const_baz', result_children=[
+ ValueCheck(name='first', summary='"Baz"'),
+ ValueCheck(name='second', summary='"Qux"')
+])
+
+# Bucket iterators
+# I.e., std::__hash_map_const_iterator>
+# and std::__hash_map_iterator>
+self.expect_expr('bucket_it', result_children=[
+ ValueCheck(name='first', summary='"Baz"'),
+ ValueCheck(name='second', summary='"Qux"')
+])
+
+self.expect_expr('bucket_it', result_children=[
+ ValueCheck(name='first', summary='"Baz"'),
+ ValueCheck(name='second', summary='"Qux"')
+])
Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/unordered_map/Makefile
===
--- /dev/null
+++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/unordered_map/Makefile
@@ -0,0 +1,6 @@
+CXX_SOURCES := main.cpp
+
+USE_LIBCPP := 1
+
+CXXFLAGS_EXTRAS := -O0
+include Makefile.rules
Index: lldb/source/Plugins/Language/CPlusPlus/LibCxx.h
===
--- lldb/source/Plugins/Language/CPlusPlus/LibCxx.h
+++ lldb/source/Plugins/Language/CPlusPlus/LibCxx.h
@@ -103,6 +103,56 @@
 LibCxxMapIteratorSyntheticFrontEndCreator(CXXSyntheticChildren *,
   lldb::ValueObjectSP);
 
+/// Formats libcxx's std::unordered_map iterators
+///
+/// In raw form a std::unordered_map::iterator is represented as follows:
+///
+/// (lldb) var it --raw --ptr-depth 1
+/// (std::__1::__ha

[Lldb-commits] [PATCH] D129377: [lldb/Fuzzer] Add fuzzer for expression evaluator

2022-07-08 Thread Chelsea Cassanova via Phabricator via lldb-commits
cassanova created this revision.
cassanova added reviewers: JDevlieghere, mib.
cassanova added a project: LLDB.
Herald added a subscriber: mgorny.
Herald added a project: All.
cassanova requested review of this revision.
Herald added a subscriber: lldb-commits.

This commit adds a fuzzer for LLDB's expression evaluator.
The fuzzer takes a different approach than the current fuzzers
present, and uses an approach that is currently being used for
clang fuzzers.

Instead of fuzzing the evaluator with randomly mutated
characters, protobufs are used to generate a subset of C++. This
is then converted to valid C++ code and sent to the expression
evaluator. In addition, libprotobuf_mutator is used to mutate
the fuzzer's inputs from valid C++ code to valid C++ code, rather
than mutating from valid code to total nonsense.

In order to use libprotobuf_mutator, a CMake module is added to
LLDB's CMake modules.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D129377

Files:
  lldb/cmake/modules/ProtobufMutator.cmake
  lldb/tools/lldb-fuzzer/CMakeLists.txt
  lldb/tools/lldb-fuzzer/lldb-expression-fuzzer/CMakeLists.txt
  lldb/tools/lldb-fuzzer/lldb-expression-fuzzer/cxx_proto.proto
  lldb/tools/lldb-fuzzer/lldb-expression-fuzzer/lldb-expression-fuzzer.cpp

Index: lldb/tools/lldb-fuzzer/lldb-expression-fuzzer/lldb-expression-fuzzer.cpp
===
--- /dev/null
+++ lldb/tools/lldb-fuzzer/lldb-expression-fuzzer/lldb-expression-fuzzer.cpp
@@ -0,0 +1,73 @@
+//===-- lldb-expression-fuzzer.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
+//
+//===-===//
+//
+// \file
+// This file is a fuzzer for LLDB's expression evaluator. It uses protobufs
+// and the libprotobuf-mutator to create valid C-like inputs for the
+// expression evaluator.
+//
+//===-===//
+
+#include 
+
+#include "cxx_proto.pb.h"
+#include "handle-cxx/handle_cxx.h"
+#include "lldb/API/SBBreakpoint.h"
+#include "lldb/API/SBDebugger.h"
+#include "lldb/API/SBError.h"
+#include "lldb/API/SBLaunchInfo.h"
+#include "lldb/API/SBProcess.h"
+#include "lldb/API/SBTarget.h"
+#include "proto-to-cxx/proto_to_cxx.h"
+#include "src/libfuzzer/libfuzzer_macro.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/Support/Error.h"
+
+using namespace lldb;
+using namespace llvm;
+using namespace clang_fuzzer;
+
+char **originalargv;
+
+extern "C" int LLVMFuzzerInitialize(int *argc, char ***argv) {
+  SBDebugger::Initialize();
+
+  // The path for a simple compiled program is needed to create a
+  // target for the debugger and that path is passed in through argv
+  originalargv = *argv;
+  return 0;
+}
+
+DEFINE_BINARY_PROTO_FUZZER(const clang_fuzzer::Function &input) {
+  auto S = clang_fuzzer::FunctionToString(input);
+
+  // Get the second argument from argv and strip the '--' from it.
+  // This will be used as the path for the object file to create a target from
+  std::string rawpath = originalargv[2];
+  StringRef objpath = rawpath.erase(0, 2);
+
+  // Create a debugger and a target
+  SBDebugger debugger = SBDebugger::Create(false);
+  SBTarget target = debugger.CreateTarget(objpath.str().c_str());
+
+  // Create a breakpoint on the only line in the program
+  SBBreakpoint bp = target.BreakpointCreateByLocation(objpath.str().c_str(), 1);
+
+  // Create launch info and error for launching the process
+  SBLaunchInfo li = target.GetLaunchInfo();
+  SBError error;
+
+  // Launch the process and evaluate the fuzzer's input data
+  // as an expression
+  SBProcess process = target.Launch(li, error);
+  target.EvaluateExpression(S.c_str());
+
+  debugger.DeleteTarget(target);
+  SBDebugger::Destroy(debugger);
+  SBModule::GarbageCollectAllocatedModules();
+}
Index: lldb/tools/lldb-fuzzer/lldb-expression-fuzzer/cxx_proto.proto
===
--- /dev/null
+++ lldb/tools/lldb-fuzzer/lldb-expression-fuzzer/cxx_proto.proto
@@ -0,0 +1,92 @@
+//===-- cxx_proto.proto - Protobuf description of C++ -===//
+//
+// 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
+//
+//===--===//
+///
+/// \file
+/// This file describes a subset of C++ as a protobuf.  It is used to
+///  more easily find interesting inputs for fuzzing Clang.
+///
+//===--===//
+
+syntax = "proto2";
+
+message VarRef {
+  required int32 varnum = 1;
+}
+
+message 

[Lldb-commits] [PATCH] D128477: [trace] Add a flag to the decoder to output the instruction type

2022-07-08 Thread Sujin Park via Phabricator via lldb-commits
persona0220 updated this revision to Diff 443281.
persona0220 marked 4 inline comments as done.
persona0220 added a comment.
Herald added a subscriber: mgorny.

- Delete PTI_MAP enum and use opcode_len instead.
- Add a unit test
  - Divide existing Disassembler test into x86 / ARM subdirectory
  - Unittests/Disassembler/x86/TestGetControlFlowKindx86.cpp tests categorizing 
x86_64 instructions
- Modify GetControlFlowKind function to get ArchSpec instead of exe_ctx


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

https://reviews.llvm.org/D128477

Files:
  lldb/include/lldb/Core/Disassembler.h
  lldb/include/lldb/Target/TraceDumper.h
  lldb/include/lldb/lldb-enumerations.h
  lldb/source/API/SBInstruction.cpp
  lldb/source/API/SBInstructionList.cpp
  lldb/source/Commands/CommandObjectDisassemble.cpp
  lldb/source/Commands/CommandObjectDisassemble.h
  lldb/source/Commands/CommandObjectThread.cpp
  lldb/source/Commands/Options.td
  lldb/source/Core/Disassembler.cpp
  lldb/source/Core/DumpDataExtractor.cpp
  lldb/source/Expression/IRExecutionUnit.cpp
  lldb/source/Plugins/TraceExporter/common/TraceHTR.cpp
  
lldb/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.cpp
  lldb/source/Symbol/Function.cpp
  lldb/source/Symbol/Symbol.cpp
  lldb/source/Target/ThreadPlanTracer.cpp
  lldb/source/Target/TraceDumper.cpp
  lldb/unittests/Disassembler/ARM/CMakeLists.txt
  lldb/unittests/Disassembler/ARM/TestArm64Disassembly.cpp
  lldb/unittests/Disassembler/ARM/TestArmv7Disassembly.cpp
  lldb/unittests/Disassembler/CMakeLists.txt
  lldb/unittests/Disassembler/TestArm64Disassembly.cpp
  lldb/unittests/Disassembler/TestArmv7Disassembly.cpp
  lldb/unittests/Disassembler/x86/CMakeLists.txt
  lldb/unittests/Disassembler/x86/TestGetControlFlowKindx86.cpp

Index: lldb/unittests/Disassembler/x86/TestGetControlFlowKindx86.cpp
===
--- /dev/null
+++ lldb/unittests/Disassembler/x86/TestGetControlFlowKindx86.cpp
@@ -0,0 +1,147 @@
+//===-- TextX86GetControlFlowKind.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 "llvm/Support/TargetSelect.h"
+#include "gtest/gtest.h"
+
+#include "lldb/Core/Address.h"
+#include "lldb/Core/Disassembler.h"
+#include "lldb/Target/ExecutionContext.h"
+#include "lldb/Utility/ArchSpec.h"
+
+#include "Plugins/Disassembler/LLVMC/DisassemblerLLVMC.h"
+
+using namespace lldb;
+using namespace lldb_private;
+
+class TestGetControlFlowKindx86 : public testing::Test {
+public:
+  static void SetUpTestCase();
+  static void TearDownTestCase();
+
+  //  virtual void SetUp() override { }
+  //  virtual void TearDown() override { }
+
+protected:
+};
+
+void TestGetControlFlowKindx86::SetUpTestCase() {
+  llvm::InitializeAllTargets();
+  llvm::InitializeAllAsmPrinters();
+  llvm::InitializeAllTargetMCs();
+  llvm::InitializeAllDisassemblers();
+  DisassemblerLLVMC::Initialize();
+}
+
+void TestGetControlFlowKindx86::TearDownTestCase() {
+  DisassemblerLLVMC::Terminate();
+}
+
+TEST_F(TestGetControlFlowKindx86, TestX86_64Instruction) {
+  ArchSpec arch("x86_64-*-linux");
+
+  const unsigned num_of_instructions = 29;
+  uint8_t data[] = {
+  0x55,   // other -- pushq %rbp
+  0x48, 0x89, 0xe5,   // other -- movq %rsp, %rbp
+
+  0xe8, 0xfc, 0xfe, 0xff, 0xff,   // call -- callq 0x4004c0
+  0x41, 0xff, 0x14, 0xdc, // call -- callq *(%r12,%rbx,8)
+  0xff, 0x50, 0x18,   // call -- callq *0x18(%rax)
+  0xe8, 0x48, 0x0d, 0x00, 0x00,   // call -- callq 0x94fe0
+
+  0xc3,   // return -- retq
+
+  0xeb, 0xd3, // jump -- jmp 0x92dab
+  0xe9, 0x22, 0xff, 0xff, 0xff,   // jump -- jmp 0x933ae
+  0xff, 0xe0, // jump -- jmpq *%rax
+  0xf2, 0xff, 0x25, 0x75, 0xe7, 0x39, 0x00, // jump -- repne jmpq *0x39e775
+
+  0x73, 0xc2, // cond jump -- jae 0x9515c
+  0x74, 0x1f, // cond jump -- je 0x400626
+  0x75, 0xea, // cond jump -- jne 0x400610
+  0x76, 0x10, // cond jump -- jbe 0x94d10
+  0x77, 0x58, // cond jump -- ja 0x1208c8
+  0x7e, 0x67, // cond jump -- jle 0x92180
+  0x78, 0x0b, // cond jump -- js 0x92dc3
+  0x0f, 0x82, 0x17, 0x01, 0x00, 0x00, // cond jump -- jb 0x9c7b0
+  0x0f, 0x83, 0xa7, 0x00, 0x00, 0x00, // cond jump -- jae 0x895c8
+  0x0f, 0x84, 0x8c, 0x00, 0x00, 0x00, // cond jump -- je 0x941f0
+  0x0f, 0x85, 0x51, 0xff, 0

[Lldb-commits] [PATCH] D50304: [lldb] Fix thread step until to not set breakpoint(s) on incorrect line numbers

2022-07-08 Thread Venkata Ramanaiah Nalamothu via Phabricator via lldb-commits
RamNalamothu added a comment.

Ping.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D50304

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


[Lldb-commits] [PATCH] D128956: make debugserver able to inspect mach-o binaries present in memory, but not yet registered with dyld

2022-07-08 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere accepted this revision.
JDevlieghere added a comment.

LGTM




Comment at: lldb/tools/debugserver/source/MacOSX/MachProcess.mm:749
 
+static bool mach_header_validity_test (uint32_t magic, uint32_t cputype) {
+  if (magic != MH_MAGIC && magic != MH_CIGAM && magic != MH_MAGIC_64 &&

Seems like a slightly odd name. `is_valid_mach_header`?



Comment at: lldb/tools/debugserver/source/MacOSX/MachProcess.mm:1021-1022
 
-  First the image_infos array with (load addr, pathname, mod date)
-///tuples
-
-for (size_t i = 0; i < image_count; i++) {
-  struct binary_image_information info;
-  nub_addr_t pathname_address;
-  if (pointer_size == 4) {
-uint32_t load_address_32;
-uint32_t pathname_address_32;
-uint32_t mod_date_32;
-::memcpy(&load_address_32, image_info_buf + (i * 3 * pointer_size), 4);
-::memcpy(&pathname_address_32,
- image_info_buf + (i * 3 * pointer_size) + pointer_size, 4);
-::memcpy(&mod_date_32, image_info_buf + (i * 3 * pointer_size) +
-   pointer_size + pointer_size,
- 4);
-info.load_address = load_address_32;
-info.mod_date = mod_date_32;
-pathname_address = pathname_address_32;
-  } else {
-uint64_t load_address_64;
-uint64_t pathname_address_64;
-uint64_t mod_date_64;
-::memcpy(&load_address_64, image_info_buf + (i * 3 * pointer_size), 8);
-::memcpy(&pathname_address_64,
- image_info_buf + (i * 3 * pointer_size) + pointer_size, 8);
-::memcpy(&mod_date_64, image_info_buf + (i * 3 * pointer_size) +
-   pointer_size + pointer_size,
- 8);
-info.load_address = load_address_64;
-info.mod_date = mod_date_64;
-pathname_address = pathname_address_64;
-  }
-  char strbuf[17];
-  info.filename = "";
-  uint64_t pathname_ptr = pathname_address;
-  bool still_reading = true;
-  while (still_reading &&
- ReadMemory(pathname_ptr, sizeof(strbuf) - 1, strbuf) ==
- sizeof(strbuf) - 1) {
-strbuf[sizeof(strbuf) - 1] = '\0';
-info.filename += strbuf;
-pathname_ptr += sizeof(strbuf) - 1;
-// Stop if we found nul byte indicating the end of the string
-for (size_t i = 0; i < sizeof(strbuf) - 1; i++) {
-  if (strbuf[i] == '\0') {
-still_reading = false;
-break;
-  }
+    First the image_infos array with (load addr, pathname, mod date)
+  /// tuples
+

Nit: If you're touching this line this might be a good opportunity to fix up 
the weird quadruple/triple slash and additional space. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128956

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


[Lldb-commits] [PATCH] D128477: [trace] Add a flag to the decoder to output the instruction type

2022-07-08 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.

almost there! I like the tests btw :)




Comment at: lldb/source/Commands/Options.td:304
+  def disassemble_options_kind : Option<"kind", "k">,
+Desc<"Show instruction control flow kind. Refer enum "
+"`InstructionControlFlowKind` for a list of control flow kind. "





Comment at: lldb/source/Commands/Options.td:1159
+  def thread_trace_dump_instructions_show_kind : Option<"kind", "k">, Group<1>,
+Desc<"Show instruction control flow kind. Refer enum "
+"`InstructionControlFlowKind` for a list of control flow kind. "

same



Comment at: lldb/source/Core/Disassembler.cpp:578
+/// instruction, which are represented as the following parameters.
+/// Refer http://ref.x86asm.net/coder.html to see the full list of
+/// opcode and instruction set.





Comment at: lldb/source/Core/Disassembler.cpp:588
+/// \param[in] opcode_len
+///The length of opcode. Valid opcode lengths are 1, 2, or 3.
+///





Comment at: lldb/source/Core/Disassembler.cpp:592-594
+///   eInstructionControlFlowKindOther if the instruction is not interesting.
+///   i.e. a sequential instruction that doesn't affect the control flow of
+///   the program.





Comment at: lldb/source/Core/Disassembler.cpp:705
+/// Decode an instruction into opcode, modrm and opcode_len.
+/// Refer http://ref.x86asm.net/coder.html for the instruction bytes layout.
+/// Opcodes in x86 are generally the first byte of instruction, though two-byte





Comment at: lldb/source/Core/Disassembler.cpp:734-736
+bool InstructionLengthDecode(const uint8_t *inst_bytes, bool is_exec_mode_64b,
+ int bytes_len, uint8_t *primary_opcode,
+ uint8_t *modrm, uint8_t *opcode_len) {

We try not to use out parameters this way. Instead, create a new struct 
InstructionOpcodeAndModrm with the three values that are important to you. 
Then, change this function to return Optional, where 
the None case means that decoding failed



Comment at: lldb/unittests/Disassembler/x86/TestGetControlFlowKindx86.cpp:28-29
+
+  //  virtual void SetUp() override { }
+  //  virtual void TearDown() override { }
+

delete if not used


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

https://reviews.llvm.org/D128477

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


[Lldb-commits] [PATCH] D128069: [lldb] add SBSection.alignment to python bindings

2022-07-08 Thread David M. Lary via Phabricator via lldb-commits
dmlary marked 2 inline comments as done.
dmlary added a comment.

@JDevlieghere if I'm reading this right, yours is the last approval this review 
needs.  Is there anything else you would like to be updated in this diff?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128069

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


[Lldb-commits] [PATCH] D128956: make debugserver able to inspect mach-o binaries present in memory, but not yet registered with dyld

2022-07-08 Thread Jason Molenda via Phabricator via lldb-commits
jasonmolenda updated this revision to Diff 443345.
jasonmolenda added a comment.

Final small patch revision.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128956

Files:
  lldb/test/API/macosx/unregistered-macho/Makefile
  lldb/test/API/macosx/unregistered-macho/TestUnregisteredMacho.py
  lldb/test/API/macosx/unregistered-macho/main.c
  lldb/tools/debugserver/source/MacOSX/MachProcess.h
  lldb/tools/debugserver/source/MacOSX/MachProcess.mm

Index: lldb/tools/debugserver/source/MacOSX/MachProcess.mm
===
--- lldb/tools/debugserver/source/MacOSX/MachProcess.mm
+++ lldb/tools/debugserver/source/MacOSX/MachProcess.mm
@@ -746,6 +746,16 @@
   return nullptr;
 }
 
+static bool mach_header_validity_test (uint32_t magic, uint32_t cputype) {
+  if (magic != MH_MAGIC && magic != MH_CIGAM && magic != MH_MAGIC_64 &&
+  magic != MH_CIGAM_64)
+return false;
+  if (cputype != CPU_TYPE_X86_64 && cputype != CPU_TYPE_ARM &&
+  cputype != CPU_TYPE_ARM64 && cputype != CPU_TYPE_ARM64_32)
+return false;
+  return true;
+}
+
 // Given an address, read the mach-o header and load commands out of memory to
 // fill in
 // the mach_o_information "inf" object.
@@ -757,12 +767,16 @@
 uint32_t dyld_platform, nub_addr_t mach_o_header_addr, int wordsize,
 struct mach_o_information &inf) {
   uint64_t load_cmds_p;
+
   if (wordsize == 4) {
 struct mach_header header;
 if (ReadMemory(mach_o_header_addr, sizeof(struct mach_header), &header) !=
 sizeof(struct mach_header)) {
   return false;
 }
+if (!mach_header_validity_test(header.magic, header.cputype))
+  return false;
+
 load_cmds_p = mach_o_header_addr + sizeof(struct mach_header);
 inf.mach_header.magic = header.magic;
 inf.mach_header.cputype = header.cputype;
@@ -779,6 +793,8 @@
&header) != sizeof(struct mach_header_64)) {
   return false;
 }
+if (!mach_header_validity_test(header.magic, header.cputype))
+  return false;
 load_cmds_p = mach_o_header_addr + sizeof(struct mach_header_64);
 inf.mach_header.magic = header.magic;
 inf.mach_header.cputype = header.cputype;
@@ -896,6 +912,8 @@
   const size_t image_count = image_infos.size();
 
   for (size_t i = 0; i < image_count; i++) {
+if (!image_infos[i].is_valid_mach_header)
+  continue;
 JSONGenerator::DictionarySP image_info_dict_sp(
 new JSONGenerator::Dictionary());
 image_info_dict_sp->AddIntegerItem("load_address",
@@ -970,7 +988,6 @@
   }
 
   JSONGenerator::DictionarySP reply_sp(new JSONGenerator::Dictionary());
-  ;
   reply_sp->AddItem("images", image_infos_array_sp);
 
   return reply_sp;
@@ -985,8 +1002,8 @@
 // information.
 JSONGenerator::ObjectSP MachProcess::GetLoadedDynamicLibrariesInfos(
 nub_process_t pid, nub_addr_t image_list_address, nub_addr_t image_count) {
-  JSONGenerator::DictionarySP reply_sp;
 
+  JSONGenerator::ObjectSP empty_reply_sp(new JSONGenerator::Dictionary());
   int pointer_size = GetInferiorAddrSize(pid);
 
   std::vector image_infos;
@@ -994,91 +1011,89 @@
 
   uint8_t *image_info_buf = (uint8_t *)malloc(image_infos_size);
   if (image_info_buf == NULL) {
-return reply_sp;
+return empty_reply_sp;
+  }
+  if (ReadMemory(image_list_address, image_infos_size, image_info_buf) !=
+  image_infos_size) {
+return empty_reply_sp;
   }
-if (ReadMemory(image_list_address, image_infos_size, image_info_buf) !=
-image_infos_size) {
-  return reply_sp;
-}
 
-  First the image_infos array with (load addr, pathname, mod date)
-///tuples
-
-for (size_t i = 0; i < image_count; i++) {
-  struct binary_image_information info;
-  nub_addr_t pathname_address;
-  if (pointer_size == 4) {
-uint32_t load_address_32;
-uint32_t pathname_address_32;
-uint32_t mod_date_32;
-::memcpy(&load_address_32, image_info_buf + (i * 3 * pointer_size), 4);
-::memcpy(&pathname_address_32,
- image_info_buf + (i * 3 * pointer_size) + pointer_size, 4);
-::memcpy(&mod_date_32, image_info_buf + (i * 3 * pointer_size) +
-   pointer_size + pointer_size,
- 4);
-info.load_address = load_address_32;
-info.mod_date = mod_date_32;
-pathname_address = pathname_address_32;
-  } else {
-uint64_t load_address_64;
-uint64_t pathname_address_64;
-uint64_t mod_date_64;
-::memcpy(&load_address_64, image_info_buf + (i * 3 * pointer_size), 8);
-::memcpy(&pathname_address_64,
- image_info_buf + (i * 3 * pointer_size) + pointer_size, 8);
-::memcpy(&mod_date_64, image_info_buf + (i * 3 * pointer_size) +
-   pointer_size + pointer_size,
- 8);
-info.load

[Lldb-commits] [PATCH] D128477: [trace] Add a flag to the decoder to output the instruction type

2022-07-08 Thread Sujin Park via Phabricator via lldb-commits
persona0220 updated this revision to Diff 443360.
persona0220 marked 8 inline comments as done.
persona0220 added a comment.

Added a struct `InstructionOpcodeAndModrm`, which contains primary_opcode, 
opcode_len and modrm bytes decoded from `InstructionLengthDecode` function.


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

https://reviews.llvm.org/D128477

Files:
  lldb/include/lldb/Core/Disassembler.h
  lldb/include/lldb/Target/TraceDumper.h
  lldb/include/lldb/lldb-enumerations.h
  lldb/source/API/SBInstruction.cpp
  lldb/source/API/SBInstructionList.cpp
  lldb/source/Commands/CommandObjectDisassemble.cpp
  lldb/source/Commands/CommandObjectDisassemble.h
  lldb/source/Commands/CommandObjectThread.cpp
  lldb/source/Commands/Options.td
  lldb/source/Core/Disassembler.cpp
  lldb/source/Core/DumpDataExtractor.cpp
  lldb/source/Expression/IRExecutionUnit.cpp
  lldb/source/Plugins/TraceExporter/common/TraceHTR.cpp
  
lldb/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.cpp
  lldb/source/Symbol/Function.cpp
  lldb/source/Symbol/Symbol.cpp
  lldb/source/Target/ThreadPlanTracer.cpp
  lldb/source/Target/TraceDumper.cpp
  lldb/unittests/Disassembler/ARM/CMakeLists.txt
  lldb/unittests/Disassembler/ARM/TestArm64Disassembly.cpp
  lldb/unittests/Disassembler/ARM/TestArmv7Disassembly.cpp
  lldb/unittests/Disassembler/CMakeLists.txt
  lldb/unittests/Disassembler/TestArm64Disassembly.cpp
  lldb/unittests/Disassembler/TestArmv7Disassembly.cpp
  lldb/unittests/Disassembler/x86/CMakeLists.txt
  lldb/unittests/Disassembler/x86/TestGetControlFlowKindx86.cpp

Index: lldb/unittests/Disassembler/x86/TestGetControlFlowKindx86.cpp
===
--- /dev/null
+++ lldb/unittests/Disassembler/x86/TestGetControlFlowKindx86.cpp
@@ -0,0 +1,144 @@
+//===-- TextX86GetControlFlowKind.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 "llvm/Support/TargetSelect.h"
+#include "gtest/gtest.h"
+
+#include "lldb/Core/Address.h"
+#include "lldb/Core/Disassembler.h"
+#include "lldb/Target/ExecutionContext.h"
+#include "lldb/Utility/ArchSpec.h"
+
+#include "Plugins/Disassembler/LLVMC/DisassemblerLLVMC.h"
+
+using namespace lldb;
+using namespace lldb_private;
+
+class TestGetControlFlowKindx86 : public testing::Test {
+public:
+  static void SetUpTestCase();
+  static void TearDownTestCase();
+
+protected:
+};
+
+void TestGetControlFlowKindx86::SetUpTestCase() {
+  llvm::InitializeAllTargets();
+  llvm::InitializeAllAsmPrinters();
+  llvm::InitializeAllTargetMCs();
+  llvm::InitializeAllDisassemblers();
+  DisassemblerLLVMC::Initialize();
+}
+
+void TestGetControlFlowKindx86::TearDownTestCase() {
+  DisassemblerLLVMC::Terminate();
+}
+
+TEST_F(TestGetControlFlowKindx86, TestX86_64Instruction) {
+  ArchSpec arch("x86_64-*-linux");
+
+  const unsigned num_of_instructions = 29;
+  uint8_t data[] = {
+  0x55,   // other -- pushq %rbp
+  0x48, 0x89, 0xe5,   // other -- movq %rsp, %rbp
+
+  0xe8, 0xfc, 0xfe, 0xff, 0xff,   // call -- callq 0x4004c0
+  0x41, 0xff, 0x14, 0xdc, // call -- callq *(%r12,%rbx,8)
+  0xff, 0x50, 0x18,   // call -- callq *0x18(%rax)
+  0xe8, 0x48, 0x0d, 0x00, 0x00,   // call -- callq 0x94fe0
+
+  0xc3,   // return -- retq
+
+  0xeb, 0xd3, // jump -- jmp 0x92dab
+  0xe9, 0x22, 0xff, 0xff, 0xff,   // jump -- jmp 0x933ae
+  0xff, 0xe0, // jump -- jmpq *%rax
+  0xf2, 0xff, 0x25, 0x75, 0xe7, 0x39, 0x00, // jump -- repne jmpq *0x39e775
+
+  0x73, 0xc2, // cond jump -- jae 0x9515c
+  0x74, 0x1f, // cond jump -- je 0x400626
+  0x75, 0xea, // cond jump -- jne 0x400610
+  0x76, 0x10, // cond jump -- jbe 0x94d10
+  0x77, 0x58, // cond jump -- ja 0x1208c8
+  0x7e, 0x67, // cond jump -- jle 0x92180
+  0x78, 0x0b, // cond jump -- js 0x92dc3
+  0x0f, 0x82, 0x17, 0x01, 0x00, 0x00, // cond jump -- jb 0x9c7b0
+  0x0f, 0x83, 0xa7, 0x00, 0x00, 0x00, // cond jump -- jae 0x895c8
+  0x0f, 0x84, 0x8c, 0x00, 0x00, 0x00, // cond jump -- je 0x941f0
+  0x0f, 0x85, 0x51, 0xff, 0xff, 0xff, // cond jump -- jne 0x8952c
+  0x0f, 0x86, 0xa3, 0x02, 0x00, 0x00, // cond jump -- jbe 0x9ae10
+  0x0f, 0x87, 0xff, 0x00, 0x00, 0x00, // cond jump -- ja 0x9ab60
+  0x0f, 0x8e, 0x7e, 0x00, 0x00, 0x00, // cond jump -- jle 0x92dd8
+  0x0f, 0x86, 0xdf, 0

[Lldb-commits] [PATCH] D128069: [lldb] add SBSection.alignment to python bindings

2022-07-08 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere accepted this revision.
JDevlieghere added a comment.

LGTM!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128069

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


[Lldb-commits] [lldb] 77a38f6 - jGetLoadedDynamicLibrariesInfos can inspect machos not yet loaded

2022-07-08 Thread Jason Molenda via lldb-commits

Author: Jason Molenda
Date: 2022-07-08T15:13:49-07:00
New Revision: 77a38f6839980bfac61babb40d83772c51427011

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

LOG: jGetLoadedDynamicLibrariesInfos can inspect machos not yet loaded

jGetLoadedDynamicLibrariesInfos normally checks with dyld to find
the list of binaries loaded in the inferior, and getting the filepath,
before trying to parse the Mach-O binary in inferior memory.
This allows for debugserver to parse a Mach-O binary present in memory,
but not yet registered with dyld.  This patch also adds some simple
sanity checks that we're reading a Mach-O header before we begin
stepping through load commands, because we won't have the sanity check
of consulting dyld for the list of loaded binaries before parsing.
Also adds a testcase.

Differential Revision: https://reviews.llvm.org/D128956
rdar://95737734

Added: 
lldb/test/API/macosx/unregistered-macho/Makefile
lldb/test/API/macosx/unregistered-macho/TestUnregisteredMacho.py
lldb/test/API/macosx/unregistered-macho/main.c

Modified: 
lldb/tools/debugserver/source/MacOSX/MachProcess.h
lldb/tools/debugserver/source/MacOSX/MachProcess.mm

Removed: 




diff  --git a/lldb/test/API/macosx/unregistered-macho/Makefile 
b/lldb/test/API/macosx/unregistered-macho/Makefile
new file mode 100644
index 0..58c3a468659e3
--- /dev/null
+++ b/lldb/test/API/macosx/unregistered-macho/Makefile
@@ -0,0 +1,3 @@
+C_SOURCES = main.c
+
+include Makefile.rules

diff  --git a/lldb/test/API/macosx/unregistered-macho/TestUnregisteredMacho.py 
b/lldb/test/API/macosx/unregistered-macho/TestUnregisteredMacho.py
new file mode 100644
index 0..0c3bb50aec89a
--- /dev/null
+++ b/lldb/test/API/macosx/unregistered-macho/TestUnregisteredMacho.py
@@ -0,0 +1,47 @@
+"""Test that debugserver will parse a mach-o in inferior memory even if it's 
not loaded."""
+
+import os
+import re
+import subprocess
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+class TestUnregisteredMacho(TestBase):
+
+# newer debugserver required for jGetLoadedDynamicLibrariesInfos 
+# to support this
+@skipIfOutOfTreeDebugserver  
+@no_debug_info_test
+@skipUnlessDarwin
+def test(self):
+self.build()
+target, process, thread, bkpt = lldbutil.run_to_source_breakpoint(
+self, "// break here", lldb.SBFileSpec("main.c"))
+
+frame = thread.GetFrameAtIndex(0)
+macho_buf = frame.GetValueForVariablePath("macho_buf")
+macho_addr = macho_buf.GetValueAsUnsigned()
+invalid_macho_addr = macho_buf.GetValueAsUnsigned() + 4
+gdb_packet = "process plugin packet send 
'jGetLoadedDynamicLibrariesInfos:{\"solib_addresses\":[%d]}]'" % macho_addr
+
+# Send the jGetLoadedDynamicLibrariesInfos packet
+# to debugserver, asking it to parse the mach-o binary
+# at this address and give us the UUID etc, even though
+# dyld doesn't think there is a binary at that address.
+# We won't get a pathname for the binary (from dyld), but
+# we will get to the LC_UUID and include that.
+self.expect (gdb_packet, substrs=['"pathname":""', 
'"uuid":"1B4E28BA-2FA1-11D2-883F-B9A761BDE3FB"'])
+
+no_macho_gdb_packet = "process plugin packet send 
'jGetLoadedDynamicLibrariesInfos:{\"solib_addresses\":[%d]}]'" % 
invalid_macho_addr
+self.expect (no_macho_gdb_packet, substrs=['response: {"images":[]}'])
+
+# Test that we get back the information for the properly
+# formatted Mach-O binary in memory, but do not get an
+# entry for the invalid Mach-O address.
+both_gdb_packet = "process plugin packet send 
'jGetLoadedDynamicLibrariesInfos:{\"solib_addresses\":[%d,%d]}]'" % 
(macho_addr, invalid_macho_addr)
+self.expect (both_gdb_packet, substrs=['"load_address":%d,' % 
macho_addr])
+self.expect (both_gdb_packet, substrs=['"load_address":%d,' % 
invalid_macho_addr], matching=False)
+

diff  --git a/lldb/test/API/macosx/unregistered-macho/main.c 
b/lldb/test/API/macosx/unregistered-macho/main.c
new file mode 100644
index 0..5de4b5f642467
--- /dev/null
+++ b/lldb/test/API/macosx/unregistered-macho/main.c
@@ -0,0 +1,63 @@
+#include 
+#include 
+#include 
+#include 
+#include 
+
+int main() {
+  int size_of_load_cmds =
+  sizeof(struct segment_command_64) + sizeof(struct uuid_command);
+  uint8_t *macho_buf =
+  (uint8_t *)malloc(sizeof(struct mach_header_64) + size_of_load_cmds);
+  uint8_t *p = macho_buf;
+  struct mach_header_64 mh;
+  mh.magic = MH_MAGIC_64;
+  mh.cputype = CPU_TYPE_ARM64;
+  mh.cpusubtype = 0;
+  mh.filetype = MH_EXECUTE;
+  mh.ncmds =

[Lldb-commits] [PATCH] D128956: make debugserver able to inspect mach-o binaries present in memory, but not yet registered with dyld

2022-07-08 Thread Jason Molenda via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG77a38f683998: jGetLoadedDynamicLibrariesInfos can inspect 
machos not yet loaded (authored by jasonmolenda).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128956

Files:
  lldb/test/API/macosx/unregistered-macho/Makefile
  lldb/test/API/macosx/unregistered-macho/TestUnregisteredMacho.py
  lldb/test/API/macosx/unregistered-macho/main.c
  lldb/tools/debugserver/source/MacOSX/MachProcess.h
  lldb/tools/debugserver/source/MacOSX/MachProcess.mm

Index: lldb/tools/debugserver/source/MacOSX/MachProcess.mm
===
--- lldb/tools/debugserver/source/MacOSX/MachProcess.mm
+++ lldb/tools/debugserver/source/MacOSX/MachProcess.mm
@@ -746,6 +746,16 @@
   return nullptr;
 }
 
+static bool mach_header_validity_test (uint32_t magic, uint32_t cputype) {
+  if (magic != MH_MAGIC && magic != MH_CIGAM && magic != MH_MAGIC_64 &&
+  magic != MH_CIGAM_64)
+return false;
+  if (cputype != CPU_TYPE_X86_64 && cputype != CPU_TYPE_ARM &&
+  cputype != CPU_TYPE_ARM64 && cputype != CPU_TYPE_ARM64_32)
+return false;
+  return true;
+}
+
 // Given an address, read the mach-o header and load commands out of memory to
 // fill in
 // the mach_o_information "inf" object.
@@ -757,12 +767,16 @@
 uint32_t dyld_platform, nub_addr_t mach_o_header_addr, int wordsize,
 struct mach_o_information &inf) {
   uint64_t load_cmds_p;
+
   if (wordsize == 4) {
 struct mach_header header;
 if (ReadMemory(mach_o_header_addr, sizeof(struct mach_header), &header) !=
 sizeof(struct mach_header)) {
   return false;
 }
+if (!mach_header_validity_test(header.magic, header.cputype))
+  return false;
+
 load_cmds_p = mach_o_header_addr + sizeof(struct mach_header);
 inf.mach_header.magic = header.magic;
 inf.mach_header.cputype = header.cputype;
@@ -779,6 +793,8 @@
&header) != sizeof(struct mach_header_64)) {
   return false;
 }
+if (!mach_header_validity_test(header.magic, header.cputype))
+  return false;
 load_cmds_p = mach_o_header_addr + sizeof(struct mach_header_64);
 inf.mach_header.magic = header.magic;
 inf.mach_header.cputype = header.cputype;
@@ -896,6 +912,8 @@
   const size_t image_count = image_infos.size();
 
   for (size_t i = 0; i < image_count; i++) {
+if (!image_infos[i].is_valid_mach_header)
+  continue;
 JSONGenerator::DictionarySP image_info_dict_sp(
 new JSONGenerator::Dictionary());
 image_info_dict_sp->AddIntegerItem("load_address",
@@ -970,7 +988,6 @@
   }
 
   JSONGenerator::DictionarySP reply_sp(new JSONGenerator::Dictionary());
-  ;
   reply_sp->AddItem("images", image_infos_array_sp);
 
   return reply_sp;
@@ -985,8 +1002,8 @@
 // information.
 JSONGenerator::ObjectSP MachProcess::GetLoadedDynamicLibrariesInfos(
 nub_process_t pid, nub_addr_t image_list_address, nub_addr_t image_count) {
-  JSONGenerator::DictionarySP reply_sp;
 
+  JSONGenerator::ObjectSP empty_reply_sp(new JSONGenerator::Dictionary());
   int pointer_size = GetInferiorAddrSize(pid);
 
   std::vector image_infos;
@@ -994,91 +1011,89 @@
 
   uint8_t *image_info_buf = (uint8_t *)malloc(image_infos_size);
   if (image_info_buf == NULL) {
-return reply_sp;
+return empty_reply_sp;
+  }
+  if (ReadMemory(image_list_address, image_infos_size, image_info_buf) !=
+  image_infos_size) {
+return empty_reply_sp;
   }
-if (ReadMemory(image_list_address, image_infos_size, image_info_buf) !=
-image_infos_size) {
-  return reply_sp;
-}
 
-  First the image_infos array with (load addr, pathname, mod date)
-///tuples
-
-for (size_t i = 0; i < image_count; i++) {
-  struct binary_image_information info;
-  nub_addr_t pathname_address;
-  if (pointer_size == 4) {
-uint32_t load_address_32;
-uint32_t pathname_address_32;
-uint32_t mod_date_32;
-::memcpy(&load_address_32, image_info_buf + (i * 3 * pointer_size), 4);
-::memcpy(&pathname_address_32,
- image_info_buf + (i * 3 * pointer_size) + pointer_size, 4);
-::memcpy(&mod_date_32, image_info_buf + (i * 3 * pointer_size) +
-   pointer_size + pointer_size,
- 4);
-info.load_address = load_address_32;
-info.mod_date = mod_date_32;
-pathname_address = pathname_address_32;
-  } else {
-uint64_t load_address_64;
-uint64_t pathname_address_64;
-uint64_t mod_date_64;
-::memcpy(&load_address_64, image_info_buf + (i * 3 * pointer_size), 8);
-::memcpy(&pathname_address_64,
- image_info_buf + (i * 3 * pointer_size) + pointer_size, 8);
-::memcpy(&mod_date_64, image_info_buf + (i * 3 * pointer_size) +
- 

[Lldb-commits] [PATCH] D128250: [LLDB][RISCV]Add initial support for lldb-server.

2022-07-08 Thread Liao Chunyu via Phabricator via lldb-commits
liaolucy added a comment.

I try to build lldb with the patch, but fail:

The environment:

  cat /proc/cpuinfo 
  processor   : 0
  hart: 2
  isa : rv64imafdc
  mmu : sv39
  uarch   : sifive,u74-mc

llvm  commit: d1b098fc 


Command: cmake -DLLVM_TARGETS_TO_BUILD="RISCV" -DLLVM_ENABLE_PROJECTS="lldb"  
-DCMAKE_BUILD_TYPE="Release" -G Ninja ../llvm

Error:

  CMake Error at 
/home/liaochunyu/llvm-project/lldb/cmake/modules/LLDBConfig.cmake:289 (message):
Expected directory for clang-resource headers not found:
  Call Stack (most recent call first):
/home/liaochunyu/llvm-project/lldb/CMakeLists.txt:28 (include)
  
  
  -- Configuring incomplete, errors occurred!


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

https://reviews.llvm.org/D128250

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


[Lldb-commits] [PATCH] D128465: Zstandard as a second compression method to LLVM

2022-07-08 Thread Cole Kissane via Phabricator via lldb-commits
ckissane updated this revision to Diff 440747.
ckissane edited the summary of this revision.
ckissane added a comment.

make it the second stage


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

https://reviews.llvm.org/D128465

Files:
  clang-tools-extra/clangd/CMakeLists.txt
  clang-tools-extra/clangd/test/lit.site.cfg.py.in
  clang/test/CMakeLists.txt
  clang/test/lit.site.cfg.py.in
  compiler-rt/lib/sanitizer_common/symbolizer/scripts/build_symbolizer.sh
  compiler-rt/test/lit.common.configured.in
  flang/CMakeLists.txt
  lld/ELF/CMakeLists.txt
  lldb/source/Plugins/Process/gdb-remote/CMakeLists.txt
  llvm/CMakeLists.txt
  llvm/cmake/config-ix.cmake
  llvm/cmake/modules/FindZSTD.cmake
  llvm/cmake/modules/LLVMConfig.cmake.in
  llvm/include/llvm/Config/llvm-config.h.cmake
  llvm/include/llvm/Support/Compression.h
  llvm/lib/Support/Compression.cpp
  utils/bazel/llvm_configs/llvm-config.h.cmake

Index: utils/bazel/llvm_configs/llvm-config.h.cmake
===
--- utils/bazel/llvm_configs/llvm-config.h.cmake
+++ utils/bazel/llvm_configs/llvm-config.h.cmake
@@ -92,6 +92,9 @@
 /* Define if zlib compression is available */
 #cmakedefine01 LLVM_ENABLE_ZLIB
 
+/* Define if zstd compression is available */
+#cmakedefine01 LLVM_ENABLE_ZSTD
+
 /* Define if LLVM was built with a dependency to the libtensorflow dynamic library */
 #cmakedefine LLVM_HAVE_TF_API
 
Index: llvm/lib/Support/Compression.cpp
===
--- llvm/lib/Support/Compression.cpp
+++ llvm/lib/Support/Compression.cpp
@@ -20,6 +20,9 @@
 #if LLVM_ENABLE_ZLIB
 #include 
 #endif
+#if LLVM_ENABLE_ZSTD
+#include 
+#endif
 
 using namespace llvm;
 
@@ -102,3 +105,63 @@
   llvm_unreachable("zlib::uncompress is unavailable");
 }
 #endif
+
+#if LLVM_ENABLE_ZSTD
+
+bool zstd::isAvailable() { return true; }
+
+void zstd::compress(StringRef InputBuffer,
+SmallVectorImpl &CompressedBuffer, int Level) {
+  unsigned long CompressedBufferSize = ::ZSTD_compressBound(InputBuffer.size());
+  CompressedBuffer.resize_for_overwrite(CompressedBufferSize);
+  unsigned long CompressedSize = ::ZSTD_compress(
+  (Bytef *)CompressedBuffer.data(), CompressedBufferSize,
+  (const Bytef *)InputBuffer.data(), InputBuffer.size(), Level);
+  if (ZSTD_isError(CompressedSize))
+report_bad_alloc_error("Allocation failed");
+  // Tell MemorySanitizer that zstd output buffer is fully initialized.
+  // This avoids a false report when running LLVM with uninstrumented ZLib.
+  __msan_unpoison(CompressedBuffer.data(), CompressedSize);
+  CompressedBuffer.truncate(CompressedSize);
+}
+
+Error zstd::uncompress(StringRef InputBuffer, char *UncompressedBuffer,
+   size_t &UncompressedSize) {
+  unsigned long long const rSize = ZSTD_getFrameContentSize(
+  (const Bytef *)InputBuffer.data(), InputBuffer.size());
+  size_t const Res =
+  ::ZSTD_decompress((Bytef *)UncompressedBuffer, rSize,
+(const Bytef *)InputBuffer.data(), InputBuffer.size());
+  UncompressedSize = Res;
+  // Tell MemorySanitizer that zstd output buffer is fully initialized.
+  // This avoids a false report when running LLVM with uninstrumented ZLib.
+  __msan_unpoison(UncompressedBuffer, UncompressedSize);
+  return Res != rSize ? createError(ZSTD_getErrorName(Res)) : Error::success();
+}
+
+Error zstd::uncompress(StringRef InputBuffer,
+   SmallVectorImpl &UncompressedBuffer,
+   size_t UncompressedSize) {
+  UncompressedBuffer.resize_for_overwrite(UncompressedSize);
+  Error E = zstd::uncompress(InputBuffer, UncompressedBuffer.data(),
+ UncompressedSize);
+  UncompressedBuffer.truncate(UncompressedSize);
+  return E;
+}
+
+#else
+bool zstd::isAvailable() { return false; }
+void zstd::compress(StringRef InputBuffer,
+SmallVectorImpl &CompressedBuffer, int Level) {
+  llvm_unreachable("zstd::compress is unavailable");
+}
+Error zstd::uncompress(StringRef InputBuffer, char *UncompressedBuffer,
+   size_t &UncompressedSize) {
+  llvm_unreachable("zstd::uncompress is unavailable");
+}
+Error zstd::uncompress(StringRef InputBuffer,
+   SmallVectorImpl &UncompressedBuffer,
+   size_t UncompressedSize) {
+  llvm_unreachable("zstd::uncompress is unavailable");
+}
+#endif
\ No newline at end of file
Index: llvm/include/llvm/Support/Compression.h
===
--- llvm/include/llvm/Support/Compression.h
+++ llvm/include/llvm/Support/Compression.h
@@ -43,7 +43,32 @@
 
 } // End of namespace zlib
 
+namespace zstd {
+
+static constexpr int NoCompression = -5;
+static constexpr int BestSpeedCompression = 1;
+static constexpr int DefaultCompression = 5;
+static constexpr int BestSizeCompression = 12;
+
+bool isAvailable();
+
+voi

[Lldb-commits] [PATCH] D128250: [LLDB][RISCV]Add initial support for lldb-server.

2022-07-08 Thread David Spickett via Phabricator via lldb-commits
DavidSpickett added a comment.

FWIW I do get the same error in a clean directory without this patch applied:

  -- LLDB version: 15.0.0git
  CMake Error at 
/home/david.spickett/llvm-project/lldb/cmake/modules/LLDBConfig.cmake:289 
(message):
Expected directory for clang-resource headers not found:
  Call Stack (most recent call first):
/home/david.spickett/llvm-project/lldb/CMakeLists.txt:28 (include)

There's probably a better way to tell the user what to do but that's how it 
works at the moment. The "standard" set of projects to enable is lld, clang and 
lldb if you want to build and test lldb.
(there is a standalone build 
https://lldb.llvm.org/resources/build.html#standalone-builds but it works by 
having clang already built, so same thing with extra steps)


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

https://reviews.llvm.org/D128250

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


[Lldb-commits] [PATCH] D128612: RISC-V big-endian support implementation

2022-07-08 Thread James Henderson via Phabricator via lldb-commits
jhenderson added a comment.

Objcopy aspects look good, thanks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128612

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


[Lldb-commits] [PATCH] D128612: RISC-V big-endian support implementation

2022-07-08 Thread Fangrui Song via Phabricator via lldb-commits
MaskRay added a comment.

lld/ELF change should be dropped from this change. Don't use 
`config->endianness`.
I feel sad that for little-endian users who don't use big-endian, every write 
now is slightly slower due to a check ;-)




Comment at: clang/lib/Basic/Targets/RISCV.cpp:124
   Builder.defineMacro("__riscv");
-  bool Is64Bit = getTriple().getArch() == llvm::Triple::riscv64;
+  bool Is64Bit = (getTriple().getArch() == llvm::Triple::riscv64 ||
+  getTriple().getArch() == llvm::Triple::riscv64be);

The convention doesn't add `()` in such an assignment.



Comment at: clang/lib/Basic/Targets/RISCV.cpp:220
 
-  if (getTriple().getArch() == llvm::Triple::riscv64) {
+  if (getTriple().getArch() == llvm::Triple::riscv64 ||
+  getTriple().getArch() == llvm::Triple::riscv64be) {

This can be simplified with something like `isRISCV64()`



Comment at: clang/lib/Basic/Targets/RISCV.h:144
+
+StringRef LayoutEndianness = Triple.isLittleEndian() ? "e" : "E";
+

You may use a `char` and possibly fold this into the expression below.



Comment at: clang/lib/Basic/Targets/RISCV.h:145
+StringRef LayoutEndianness = Triple.isLittleEndian() ? "e" : "E";
+
+resetDataLayout(

delete blank line


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128612

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


[Lldb-commits] [PATCH] D128250: [LLDB][RISCV]Add initial support for lldb-server.

2022-07-08 Thread Emmmer S via Phabricator via lldb-commits
Emmmer added a comment.

In D128250#3617409 , @liaolucy wrote:

> I try to build lldb with the patch, but fail:
>
> The environment:
>
>   cat /proc/cpuinfo 
>   processor   : 0
>   hart: 2
>   isa : rv64imafdc
>   mmu : sv39
>   uarch   : sifive,u74-mc
>
> llvm  commit: d1b098fc 
> 
>
> Command: cmake -DLLVM_TARGETS_TO_BUILD="RISCV" -DLLVM_ENABLE_PROJECTS="lldb"  
> -DCMAKE_BUILD_TYPE="Release" -G Ninja ../llvm
>
> Error:
>
>   CMake Error at 
> /home/liaochunyu/llvm-project/lldb/cmake/modules/LLDBConfig.cmake:289 
> (message):
> Expected directory for clang-resource headers not found:
>   Call Stack (most recent call first):
> /home/liaochunyu/llvm-project/lldb/CMakeLists.txt:28 (include)
>   
>   
>   -- Configuring incomplete, errors occurred!

The most convenient way to handle clang dependencies is adding clang to 
LLVM_ENABLE_PROJECTS

`-DLLVM_ENABLE_PROJECTS="lldb;clang"`


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

https://reviews.llvm.org/D128250

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


[Lldb-commits] [PATCH] D128612: RISC-V big-endian support implementation

2022-07-08 Thread Guy Benyei via Phabricator via lldb-commits
gbenyei added a comment.

In D128612#3617906 , @jhenderson 
wrote:

> Objcopy aspects look good, thanks.

Thanks




Comment at: llvm/lib/ExecutionEngine/JITLink/ELF_riscv.cpp:554
 .buildGraph();
-  } else {
-assert((*ELFObj)->getArch() == Triple::riscv32 &&
-   "Invalid triple for RISCV ELF object file");
+  } else if ((*ELFObj)->getArch() == Triple::riscv64be) {
+auto &ELFObjFile = cast>(**ELFObj);

jrtc27 wrote:
> Why switch to this order when before you've used 32, 64, 32be, 64be as the 
> order
The order in the code before my changes is 64, 32. I guess for no good reason, 
but I prefer not to re-order code while implementing a feature - it trashes git 
history.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128612

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


[Lldb-commits] [PATCH] D128612: RISC-V big-endian support implementation

2022-07-08 Thread Guy Benyei via Phabricator via lldb-commits
gbenyei added a comment.

In D128612#3617955 , @MaskRay wrote:

> lld/ELF change should be dropped from this change. Don't use 
> `config->endianness`.
> I feel sad that for little-endian users who don't use big-endian, every write 
> now is slightly slower due to a check ;-)

Hi, I'm not sure I get it. How will we have a fully functional toolchain, if I 
don't implement the lld/ELF part?
In LLVM, unlike in GCC, target related decisions happen in runtime. I think 
it's a high level design decision. While I can understand the pain of LE 
developers getting a slightly slower linker due to endianness checking, I sure 
will feel the pain of a BE developer not having a linker...

Please explain why I shouldn't use `config->endianness`?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128612

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


[Lldb-commits] [PATCH] D128250: [LLDB][RISCV]Add initial support for lldb-server.

2022-07-08 Thread Liao Chunyu via Phabricator via lldb-commits
liaolucy added a comment.

In D128250#3617617 , @Emmmer wrote:

> In D128250#3617409 , @liaolucy 
> wrote:
>
>> I try to build lldb with the patch, but fail:
>>
>> The environment:
>>
>>   cat /proc/cpuinfo 
>>   processor   : 0
>>   hart: 2
>>   isa : rv64imafdc
>>   mmu : sv39
>>   uarch   : sifive,u74-mc
>>
>> llvm  commit: d1b098fc 
>> 
>>
>> Command: cmake -DLLVM_TARGETS_TO_BUILD="RISCV" -DLLVM_ENABLE_PROJECTS="lldb" 
>>  -DCMAKE_BUILD_TYPE="Release" -G Ninja ../llvm
>>
>> Error:
>>
>>   CMake Error at 
>> /home/liaochunyu/llvm-project/lldb/cmake/modules/LLDBConfig.cmake:289 
>> (message):
>> Expected directory for clang-resource headers not found:
>>   Call Stack (most recent call first):
>> /home/liaochunyu/llvm-project/lldb/CMakeLists.txt:28 (include)
>>   
>>   
>>   -- Configuring incomplete, errors occurred!
>
> The most convenient way to handle clang dependencies is adding clang to 
> LLVM_ENABLE_PROJECTS
>
> `-DLLVM_ENABLE_PROJECTS="lldb;clang"`

without the patch,  no error


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

https://reviews.llvm.org/D128250

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


[Lldb-commits] [PATCH] D128250: [LLDB][RISCV]Add initial support for lldb-server.

2022-07-08 Thread Liao Chunyu via Phabricator via lldb-commits
liaolucy added a comment.

Thanks all.

Command: -DLLVM_ENABLE_PROJECTS="clang;lldb;lld" , it works.


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

https://reviews.llvm.org/D128250

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


[Lldb-commits] [PATCH] D128465: Zstandard as a second compression method to LLVM

2022-07-08 Thread Cole Kissane via Phabricator via lldb-commits
ckissane updated this revision to Diff 441102.
ckissane added a comment.

add AlgorithmName to compression namespaces


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

https://reviews.llvm.org/D128465

Files:
  clang-tools-extra/clangd/CMakeLists.txt
  clang-tools-extra/clangd/test/lit.site.cfg.py.in
  clang/test/CMakeLists.txt
  clang/test/lit.site.cfg.py.in
  compiler-rt/lib/sanitizer_common/symbolizer/scripts/build_symbolizer.sh
  compiler-rt/test/lit.common.configured.in
  flang/CMakeLists.txt
  lld/ELF/CMakeLists.txt
  lldb/source/Plugins/Process/gdb-remote/CMakeLists.txt
  llvm/CMakeLists.txt
  llvm/cmake/config-ix.cmake
  llvm/cmake/modules/FindZSTD.cmake
  llvm/cmake/modules/LLVMConfig.cmake.in
  llvm/include/llvm/Config/llvm-config.h.cmake
  llvm/include/llvm/Support/Compression.h
  llvm/lib/Support/Compression.cpp
  utils/bazel/llvm_configs/llvm-config.h.cmake

Index: utils/bazel/llvm_configs/llvm-config.h.cmake
===
--- utils/bazel/llvm_configs/llvm-config.h.cmake
+++ utils/bazel/llvm_configs/llvm-config.h.cmake
@@ -92,6 +92,9 @@
 /* Define if zlib compression is available */
 #cmakedefine01 LLVM_ENABLE_ZLIB
 
+/* Define if zstd compression is available */
+#cmakedefine01 LLVM_ENABLE_ZSTD
+
 /* Define if LLVM was built with a dependency to the libtensorflow dynamic library */
 #cmakedefine LLVM_HAVE_TF_API
 
Index: llvm/lib/Support/Compression.cpp
===
--- llvm/lib/Support/Compression.cpp
+++ llvm/lib/Support/Compression.cpp
@@ -20,6 +20,9 @@
 #if LLVM_ENABLE_ZLIB
 #include 
 #endif
+#if LLVM_ENABLE_ZSTD
+#include 
+#endif
 
 using namespace llvm;
 
@@ -102,3 +105,63 @@
   llvm_unreachable("zlib::uncompress is unavailable");
 }
 #endif
+
+#if LLVM_ENABLE_ZSTD
+
+bool zstd::isAvailable() { return true; }
+
+void zstd::compress(StringRef InputBuffer,
+SmallVectorImpl &CompressedBuffer, int Level) {
+  unsigned long CompressedBufferSize = ::ZSTD_compressBound(InputBuffer.size());
+  CompressedBuffer.resize_for_overwrite(CompressedBufferSize);
+  unsigned long CompressedSize = ::ZSTD_compress(
+  (Bytef *)CompressedBuffer.data(), CompressedBufferSize,
+  (const Bytef *)InputBuffer.data(), InputBuffer.size(), Level);
+  if (ZSTD_isError(CompressedSize))
+report_bad_alloc_error("Allocation failed");
+  // Tell MemorySanitizer that zstd output buffer is fully initialized.
+  // This avoids a false report when running LLVM with uninstrumented ZLib.
+  __msan_unpoison(CompressedBuffer.data(), CompressedSize);
+  CompressedBuffer.truncate(CompressedSize);
+}
+
+Error zstd::uncompress(StringRef InputBuffer, char *UncompressedBuffer,
+   size_t &UncompressedSize) {
+  unsigned long long const rSize = ZSTD_getFrameContentSize(
+  (const Bytef *)InputBuffer.data(), InputBuffer.size());
+  size_t const Res =
+  ::ZSTD_decompress((Bytef *)UncompressedBuffer, rSize,
+(const Bytef *)InputBuffer.data(), InputBuffer.size());
+  UncompressedSize = Res;
+  // Tell MemorySanitizer that zstd output buffer is fully initialized.
+  // This avoids a false report when running LLVM with uninstrumented ZLib.
+  __msan_unpoison(UncompressedBuffer, UncompressedSize);
+  return Res != rSize ? createError(ZSTD_getErrorName(Res)) : Error::success();
+}
+
+Error zstd::uncompress(StringRef InputBuffer,
+   SmallVectorImpl &UncompressedBuffer,
+   size_t UncompressedSize) {
+  UncompressedBuffer.resize_for_overwrite(UncompressedSize);
+  Error E = zstd::uncompress(InputBuffer, UncompressedBuffer.data(),
+ UncompressedSize);
+  UncompressedBuffer.truncate(UncompressedSize);
+  return E;
+}
+
+#else
+bool zstd::isAvailable() { return false; }
+void zstd::compress(StringRef InputBuffer,
+SmallVectorImpl &CompressedBuffer, int Level) {
+  llvm_unreachable("zstd::compress is unavailable");
+}
+Error zstd::uncompress(StringRef InputBuffer, char *UncompressedBuffer,
+   size_t &UncompressedSize) {
+  llvm_unreachable("zstd::uncompress is unavailable");
+}
+Error zstd::uncompress(StringRef InputBuffer,
+   SmallVectorImpl &UncompressedBuffer,
+   size_t UncompressedSize) {
+  llvm_unreachable("zstd::uncompress is unavailable");
+}
+#endif
\ No newline at end of file
Index: llvm/include/llvm/Support/Compression.h
===
--- llvm/include/llvm/Support/Compression.h
+++ llvm/include/llvm/Support/Compression.h
@@ -44,7 +44,33 @@
 
 } // End of namespace zlib
 
+namespace zstd {
+
+static constexpr std::string AlgorithmName = "zstd";
+static constexpr int NoCompression = -5;
+static constexpr int BestSpeedCompression = 1;
+static constexpr int DefaultCompression = 5;
+static constexpr int BestSizeCompression = 12;
+

[Lldb-commits] [PATCH] D128612: RISC-V big-endian support implementation

2022-07-08 Thread Guy Benyei via Phabricator via lldb-commits
gbenyei marked 3 inline comments as done.
gbenyei added a comment.

In D128612#3620911 , @MaskRay wrote:

> In D128612#3618167 , @gbenyei wrote:
>
>> In D128612#3617955 , @MaskRay 
>> wrote:
>>
>>> lld/ELF change should be dropped from this change. Don't use 
>>> `config->endianness`.
>>> I feel sad that for little-endian users who don't use big-endian, every 
>>> write now is slightly slower due to a check ;-)
>>
>> Hi, I'm not sure I get it. How will we have a fully functional toolchain, if 
>> I don't implement the lld/ELF part?
>> In LLVM, unlike in GCC, target related decisions happen in runtime. I think 
>> it's a high level design decision. While I can understand the pain of LE 
>> developers getting a slightly slower linker due to endianness checking, I 
>> sure will feel the pain of a BE developer not having a linker...
>>
>> Please explain why I shouldn't use `config->endianness`?
>
> See PPC64.cpp. See D96188  how I added 
> aarch64_be support. A set of representative tests should be picked with be 
> tests.
> If llvm-project consensus is that we will add big-endian support, I can 
> handle lld/ELF part. I am mostly concerned with this scenarios that some 
> RISC-V folks click LGTM, and the change lands with no test in some areas, or 
> the code somewhat breaks local convention.
>
> Many of the changes in this patch probably should be split. llvm-objcopy and 
> JIT changes definitely needs appropriate tests and the suitable domain 
> reviewers.

Thanks, it makes more sense now. I'll split the LLD changes, and remove the JIT 
related stuff.




Comment at: clang/lib/Basic/Targets/RISCV.h:144
+
+StringRef LayoutEndianness = Triple.isLittleEndian() ? "e" : "E";
+

MaskRay wrote:
> You may use a `char` and possibly fold this into the expression below.
Concatenating a conditional char and a string literal might be tricky, I'm not 
sure there is a cleaner solution.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128612

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


[Lldb-commits] [PATCH] D128465: Zstandard as a second compression method to LLVM

2022-07-08 Thread Fangrui Song via Phabricator via lldb-commits
MaskRay added inline comments.



Comment at: llvm/cmake/modules/FindZSTD.cmake:1
+# Copyright (c) Meta Platforms, Inc. and affiliates.
+#

How did you derive this?

The file seems contributed by you (I don't think facebook/zstd has such a 
file). It should not have a Meta Platforms, Inc notice.



Comment at: llvm/cmake/modules/FindZSTD.cmake:3
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.

Search `SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception` from other 
`.cmake` files


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128465

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


[Lldb-commits] [PATCH] D128465: Zstandard as a second compression method to LLVM

2022-07-08 Thread Cole Kissane via Phabricator via lldb-commits
ckissane updated this revision to Diff 441114.
ckissane edited the summary of this revision.
ckissane added a comment.

- feat: add zstd compression
- Merge branch 'ckissane.refactor-compression-namespace' into 
ckissane.add-zstd-compression
- Merge branch 'ckissane.refactor-compression-namespace' into 
ckissane.add-zstd-compression


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128465

Files:
  clang-tools-extra/clangd/CMakeLists.txt
  clang-tools-extra/clangd/test/lit.site.cfg.py.in
  clang/test/CMakeLists.txt
  clang/test/lit.site.cfg.py.in
  compiler-rt/lib/sanitizer_common/symbolizer/scripts/build_symbolizer.sh
  compiler-rt/test/lit.common.configured.in
  flang/CMakeLists.txt
  lld/ELF/CMakeLists.txt
  lldb/source/Plugins/Process/gdb-remote/CMakeLists.txt
  llvm/CMakeLists.txt
  llvm/cmake/config-ix.cmake
  llvm/cmake/modules/FindZSTD.cmake
  llvm/cmake/modules/LLVMConfig.cmake.in
  llvm/include/llvm/Config/llvm-config.h.cmake
  llvm/include/llvm/Support/Compression.h
  llvm/lib/Support/Compression.cpp
  utils/bazel/llvm_configs/llvm-config.h.cmake

Index: utils/bazel/llvm_configs/llvm-config.h.cmake
===
--- utils/bazel/llvm_configs/llvm-config.h.cmake
+++ utils/bazel/llvm_configs/llvm-config.h.cmake
@@ -92,6 +92,9 @@
 /* Define if zlib compression is available */
 #cmakedefine01 LLVM_ENABLE_ZLIB
 
+/* Define if zstd compression is available */
+#cmakedefine01 LLVM_ENABLE_ZSTD
+
 /* Define if LLVM was built with a dependency to the libtensorflow dynamic library */
 #cmakedefine LLVM_HAVE_TF_API
 
Index: llvm/lib/Support/Compression.cpp
===
--- llvm/lib/Support/Compression.cpp
+++ llvm/lib/Support/Compression.cpp
@@ -20,6 +20,9 @@
 #if LLVM_ENABLE_ZLIB
 #include 
 #endif
+#if LLVM_ENABLE_ZSTD
+#include 
+#endif
 
 using namespace llvm;
 
@@ -102,3 +105,63 @@
   llvm_unreachable("zlib::uncompress is unavailable");
 }
 #endif
+
+#if LLVM_ENABLE_ZSTD
+
+bool zstd::isAvailable() { return true; }
+
+void zstd::compress(StringRef InputBuffer,
+SmallVectorImpl &CompressedBuffer, int Level) {
+  unsigned long CompressedBufferSize = ::ZSTD_compressBound(InputBuffer.size());
+  CompressedBuffer.resize_for_overwrite(CompressedBufferSize);
+  unsigned long CompressedSize = ::ZSTD_compress(
+  (Bytef *)CompressedBuffer.data(), CompressedBufferSize,
+  (const Bytef *)InputBuffer.data(), InputBuffer.size(), Level);
+  if (ZSTD_isError(CompressedSize))
+report_bad_alloc_error("Allocation failed");
+  // Tell MemorySanitizer that zstd output buffer is fully initialized.
+  // This avoids a false report when running LLVM with uninstrumented ZLib.
+  __msan_unpoison(CompressedBuffer.data(), CompressedSize);
+  CompressedBuffer.truncate(CompressedSize);
+}
+
+Error zstd::uncompress(StringRef InputBuffer, char *UncompressedBuffer,
+   size_t &UncompressedSize) {
+  unsigned long long const rSize = ZSTD_getFrameContentSize(
+  (const Bytef *)InputBuffer.data(), InputBuffer.size());
+  size_t const Res =
+  ::ZSTD_decompress((Bytef *)UncompressedBuffer, rSize,
+(const Bytef *)InputBuffer.data(), InputBuffer.size());
+  UncompressedSize = Res;
+  // Tell MemorySanitizer that zstd output buffer is fully initialized.
+  // This avoids a false report when running LLVM with uninstrumented ZLib.
+  __msan_unpoison(UncompressedBuffer, UncompressedSize);
+  return Res != rSize ? createError(ZSTD_getErrorName(Res)) : Error::success();
+}
+
+Error zstd::uncompress(StringRef InputBuffer,
+   SmallVectorImpl &UncompressedBuffer,
+   size_t UncompressedSize) {
+  UncompressedBuffer.resize_for_overwrite(UncompressedSize);
+  Error E = zstd::uncompress(InputBuffer, UncompressedBuffer.data(),
+ UncompressedSize);
+  UncompressedBuffer.truncate(UncompressedSize);
+  return E;
+}
+
+#else
+bool zstd::isAvailable() { return false; }
+void zstd::compress(StringRef InputBuffer,
+SmallVectorImpl &CompressedBuffer, int Level) {
+  llvm_unreachable("zstd::compress is unavailable");
+}
+Error zstd::uncompress(StringRef InputBuffer, char *UncompressedBuffer,
+   size_t &UncompressedSize) {
+  llvm_unreachable("zstd::uncompress is unavailable");
+}
+Error zstd::uncompress(StringRef InputBuffer,
+   SmallVectorImpl &UncompressedBuffer,
+   size_t UncompressedSize) {
+  llvm_unreachable("zstd::uncompress is unavailable");
+}
+#endif
\ No newline at end of file
Index: llvm/include/llvm/Support/Compression.h
===
--- llvm/include/llvm/Support/Compression.h
+++ llvm/include/llvm/Support/Compression.h
@@ -44,7 +44,33 @@
 
 } // End of namespace zlib
 
+nam

[Lldb-commits] [PATCH] D128250: [LLDB][RISCV]Add initial support for lldb-server.

2022-07-08 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

In D128250#3598291 , @Emmmer wrote:

> In D128250#3598223 , @DavidSpickett 
> wrote:
>
>> I'll give this a more thorough read later just one comment for now.
>>
>> In the meantime, what's your plan for testing this config going forward? 
>> This patch would be fine as the first of a series but I'd like to see the 
>> follow ups that make it usable.
>>
>> Will there be a build bot? You could at least enable building lldb on an 
>> existing riscv bot, while you iron out all the inevitable test suite issues.
>
> To use gdbserver by lldb requires the participation of lldb-server, so my 
> current plan is to allow lldb to co-op with gdbserver, then let lldb be able 
> to use lldb-server, pass the unit tests, and finally add riscv32 support.

We do have a separate test suite just for lldb-server, so you might be able to 
use that to gauge your progress without worrying about the lldb side too much.

I wouldn't say that the presence of a buildbot is an absolute requirement to 
get this off the ground, but I would strongly recommend setting up one, even if 
it's just building for now. We don't e.g. have a bot for SystemZ, and the 
overall effect of that is that nobody knows whether SystemZ debugging actually 
works.




Comment at: lldb/source/Plugins/Architecture/RISCV64/ArchitectureRISCV64.cpp:1
+//
+// Created by emmmer on 6/22/22.

same here



Comment at: lldb/source/Plugins/Architecture/RISCV64/ArchitectureRISCV64.h:1
+//
+// Created by emmmer on 6/22/22.

Please use the standard llvm header with licence info and stuff.


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

https://reviews.llvm.org/D128250

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


[Lldb-commits] [PATCH] D128612: RISC-V big-endian support implementation

2022-07-08 Thread Guy Benyei via Phabricator via lldb-commits
gbenyei updated this revision to Diff 441410.
gbenyei added a comment.

Removed LLD and JIT related parts - JIT is out of my scope, and LLD will be in 
an additional patch.
Fixed additional remarks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128612

Files:
  clang/include/clang/Basic/Attr.td
  clang/lib/Basic/Targets.cpp
  clang/lib/Basic/Targets/OSTargets.h
  clang/lib/Basic/Targets/RISCV.cpp
  clang/lib/Basic/Targets/RISCV.h
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/CodeGen/TargetInfo.cpp
  clang/lib/Driver/Driver.cpp
  clang/lib/Driver/ToolChains/Arch/RISCV.cpp
  clang/lib/Driver/ToolChains/BareMetal.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/lib/Driver/ToolChains/FreeBSD.cpp
  clang/lib/Driver/ToolChains/Gnu.cpp
  clang/lib/Driver/ToolChains/Linux.cpp
  clang/lib/Driver/ToolChains/RISCVToolchain.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  llvm/cmake/config.guess
  llvm/include/llvm/ADT/Triple.h
  llvm/include/llvm/Object/ELFObjectFile.h
  llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
  llvm/lib/Object/RelocationResolver.cpp
  llvm/lib/Support/Triple.cpp
  llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
  llvm/lib/Target/RISCV/Disassembler/RISCVDisassembler.cpp
  llvm/lib/Target/RISCV/MCTargetDesc/RISCVAsmBackend.cpp
  llvm/lib/Target/RISCV/MCTargetDesc/RISCVAsmBackend.h
  llvm/lib/Target/RISCV/MCTargetDesc/RISCVMCAsmInfo.cpp
  llvm/lib/Target/RISCV/MCTargetDesc/RISCVMCTargetDesc.cpp
  llvm/lib/Target/RISCV/RISCVAsmPrinter.cpp
  llvm/lib/Target/RISCV/RISCVTargetMachine.cpp
  llvm/lib/Target/RISCV/TargetInfo/RISCVTargetInfo.cpp
  llvm/lib/Target/RISCV/TargetInfo/RISCVTargetInfo.h
  llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
  llvm/test/tools/llvm-objcopy/ELF/binary-output-target.test
  llvm/tools/llvm-objcopy/ObjcopyOptions.cpp
  llvm/unittests/Object/ELFObjectFileTest.cpp

Index: llvm/unittests/Object/ELFObjectFileTest.cpp
===
--- llvm/unittests/Object/ELFObjectFileTest.cpp
+++ llvm/unittests/Object/ELFObjectFileTest.cpp
@@ -186,10 +186,10 @@
 }
 
 TEST(ELFObjectFileTest, MachineTestForRISCV) {
-  std::array Formats = {"elf32-littleriscv", "elf32-littleriscv",
-  "elf64-littleriscv", "elf64-littleriscv"};
-  std::array Archs = {Triple::riscv32, Triple::riscv32,
-   Triple::riscv64, Triple::riscv64};
+  std::array Formats = {"elf32-littleriscv", "elf32-bigriscv",
+  "elf64-littleriscv", "elf64-bigriscv"};
+  std::array Archs = {Triple::riscv32, Triple::riscv32be,
+   Triple::riscv64, Triple::riscv64be};
   size_t I = 0;
   for (const DataForTest &D : generateData(ELF::EM_RISCV)) {
 checkFormatAndArch(D, Formats[I], Archs[I]);
Index: llvm/tools/llvm-objcopy/ObjcopyOptions.cpp
===
--- llvm/tools/llvm-objcopy/ObjcopyOptions.cpp
+++ llvm/tools/llvm-objcopy/ObjcopyOptions.cpp
@@ -301,6 +301,8 @@
 // RISC-V
 {"elf32-littleriscv", {ELF::EM_RISCV, false, true}},
 {"elf64-littleriscv", {ELF::EM_RISCV, true, true}},
+{"elf32-bigriscv", {ELF::EM_RISCV, false, false}},
+{"elf64-bigriscv", {ELF::EM_RISCV, true, false}},
 // PowerPC
 {"elf32-powerpc", {ELF::EM_PPC, false, false}},
 {"elf32-powerpcle", {ELF::EM_PPC, false, true}},
Index: llvm/test/tools/llvm-objcopy/ELF/binary-output-target.test
===
--- llvm/test/tools/llvm-objcopy/ELF/binary-output-target.test
+++ llvm/test/tools/llvm-objcopy/ELF/binary-output-target.test
@@ -33,6 +33,12 @@
 # RUN: llvm-objcopy -I binary -O elf64-littleriscv %t.txt %t.rv64.o
 # RUN: llvm-readobj --file-headers %t.rv64.o | FileCheck %s --check-prefixes=CHECK,LE,RISCV64,64
 
+# RUN: llvm-objcopy -I binary -O elf32-bigriscv %t.txt %t.rv32.o
+# RUN: llvm-readobj --file-headers %t.rv32.o | FileCheck %s --check-prefixes=CHECK,BE,RISCV32,32
+
+# RUN: llvm-objcopy -I binary -O elf64-bigriscv %t.txt %t.rv64.o
+# RUN: llvm-readobj --file-headers %t.rv64.o | FileCheck %s --check-prefixes=CHECK,BE,RISCV64,64
+
 # RUN: llvm-objcopy -I binary -O elf32-sparc %t.txt %t.sparc.o
 # RUN: llvm-readobj --file-headers %t.sparc.o | FileCheck %s --check-prefixes=CHECK,BE,SPARC,32
 
Index: llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
===
--- llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
+++ llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
@@ -480,7 +480,8 @@
   bool IsMIPS64 = TargetTriple.isMIPS64();
   bool IsArmOrThumb = TargetTriple.isARM() || TargetTriple.isThumb();
   bool IsAArch64 = TargetTriple.getArc

[Lldb-commits] [PATCH] D128612: RISC-V big-endian support implementation

2022-07-08 Thread Fangrui Song via Phabricator via lldb-commits
MaskRay added inline comments.



Comment at: clang/lib/Basic/Targets/RISCV.h:144
+
+StringRef LayoutEndianness = Triple.isLittleEndian() ? "e" : "E";
+

gbenyei wrote:
> MaskRay wrote:
> > You may use a `char` and possibly fold this into the expression below.
> Concatenating a conditional char and a string literal might be tricky, I'm 
> not sure there is a cleaner solution.
There is a constructor `Twine(char)`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128612

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


[Lldb-commits] [PATCH] D128250: [LLDB][RISCV]Add initial support for lldb-server.

2022-07-08 Thread David Spickett via Phabricator via lldb-commits
DavidSpickett added a comment.

> I currently don't quite understand how to configure the build bot, and how to 
> set the test configuration, I went through this article but didn't find 
> useful information for me, could someone help me.

Start with https://llvm.org/docs/HowToAddABuilder.html instead. Though it may 
be better to propose adding the lldb-server build to an existing riscv 
buildbot, which would be a case of reaching out to the owner and/or proposing a 
change on https://github.com/llvm/llvm-zorg to add the build target to the 
bot's config.


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

https://reviews.llvm.org/D128250

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


[Lldb-commits] [PATCH] D128250: [LLDB][RISCV]Add initial support for lldb-server.

2022-07-08 Thread Emmmer S via Phabricator via lldb-commits
Emmmer marked 8 inline comments as done.
Emmmer added a comment.

> Minor thing but if you call this in the constructor it's one less place to = 
> false all the things.

It is a virtual function so I decided not to call it from the constructor.


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

https://reviews.llvm.org/D128250

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


[Lldb-commits] [PATCH] D128612: RISC-V big-endian support implementation

2022-07-08 Thread Fangrui Song via Phabricator via lldb-commits
MaskRay added a comment.

In D128612#3618167 , @gbenyei wrote:

> In D128612#3617955 , @MaskRay wrote:
>
>> lld/ELF change should be dropped from this change. Don't use 
>> `config->endianness`.
>> I feel sad that for little-endian users who don't use big-endian, every 
>> write now is slightly slower due to a check ;-)
>
> Hi, I'm not sure I get it. How will we have a fully functional toolchain, if 
> I don't implement the lld/ELF part?
> In LLVM, unlike in GCC, target related decisions happen in runtime. I think 
> it's a high level design decision. While I can understand the pain of LE 
> developers getting a slightly slower linker due to endianness checking, I 
> sure will feel the pain of a BE developer not having a linker...
>
> Please explain why I shouldn't use `config->endianness`?

See PPC64.cpp. See D96188  how I added 
aarch64_be support. A set of representative tests should be picked with be 
tests.
If llvm-project consensus is that we will add big-endian support, I can handle 
lld/ELF part. I am mostly concerned with this scenarios that some RISC-V folks 
click LGTM, and the change lands with no test in some areas.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128612

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


[Lldb-commits] [PATCH] D128612: RISC-V big-endian support implementation

2022-07-08 Thread Guy Benyei via Phabricator via lldb-commits
gbenyei marked 3 inline comments as done.
gbenyei added inline comments.



Comment at: llvm/lib/ExecutionEngine/JITLink/ELF_riscv.cpp:554
 .buildGraph();
-  } else {
-assert((*ELFObj)->getArch() == Triple::riscv32 &&
-   "Invalid triple for RISCV ELF object file");
+  } else if ((*ELFObj)->getArch() == Triple::riscv64be) {
+auto &ELFObjFile = cast>(**ELFObj);

gbenyei wrote:
> jrtc27 wrote:
> > Why switch to this order when before you've used 32, 64, 32be, 64be as the 
> > order
> The order in the code before my changes is 64, 32. I guess for no good 
> reason, but I prefer not to re-order code while implementing a feature - it 
> trashes git history.
Removed this part anyway - JIT is out of scope for this commit. Thanks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128612

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


[Lldb-commits] [PATCH] D128612: RISC-V big-endian support implementation

2022-07-08 Thread Alex Bradbury via Phabricator via lldb-commits
asb added a comment.

Thanks for this patch Guy. As just discussed in the RISC-V sync-up call, it 
would be helpful from a review perspective to write down at least a simple 
plain-text description of the changes to the psABI doc needed to reflect the BE 
ABI implemented by GCC (and soon LLVM), perhaps in an issue.

I think this patch is lacking some test coverage around things like fixup 
handling (e.g. the logic to swap fixups).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128612

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


[Lldb-commits] [PATCH] D128166: ManagedStatic: Destroy from destructor

2022-07-08 Thread Nicolai Hähnle via Phabricator via lldb-commits
nhaehnle added a comment.
Herald added a subscriber: anlunx.

Abandoning this in favor of removing ManagedStatic entirely via the stack of 
changes that ends in D129134 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128166

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


[Lldb-commits] [PATCH] D127741: [Disassembler] Add +all CPU feature to subtargetInfo and use it for disassembling AArch64

2022-07-08 Thread Denis via Phabricator via lldb-commits
treapster abandoned this revision.
treapster added a comment.

Abandoning because @MaskRay already implemented it in D128029 
 and D128030 
. Thanks for your time, @MaskRay!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127741

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


[Lldb-commits] [PATCH] D128250: [LLDB][RISCV]Add initial support for lldb-server.

2022-07-08 Thread Emmmer S via Phabricator via lldb-commits
Emmmer updated this revision to Diff 442006.
Emmmer added a comment.

- Format the standard llvm header.
- add `RegisterContextPOSIX_riscv64.cpp` and `RegisterContextPOSIX_riscv64.h`
- add Floating-Point Register support.

> I wouldn't say that the presence of a buildbot is an absolute requirement to 
> get this off the ground, but I would strongly recommend setting up one, even 
> if it's just building for now.

I currently don't quite understand how to configure the build bot, and how to 
set the test configuration, I went through this article 
 but didn't find useful information for 
me, could someone help me.


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

https://reviews.llvm.org/D128250

Files:
  lldb/source/Plugins/ABI/RISCV64/CMakeLists.txt
  lldb/source/Plugins/Architecture/CMakeLists.txt
  lldb/source/Plugins/Architecture/RISCV32/ArchitectureRISCV32.cpp
  lldb/source/Plugins/Architecture/RISCV32/ArchitectureRISCV32.h
  lldb/source/Plugins/Architecture/RISCV32/CMakeLists.txt
  lldb/source/Plugins/Architecture/RISCV64/ArchitectureRISCV64.cpp
  lldb/source/Plugins/Architecture/RISCV64/ArchitectureRISCV64.h
  lldb/source/Plugins/Architecture/RISCV64/CMakeLists.txt
  lldb/source/Plugins/Process/Linux/CMakeLists.txt
  lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_riscv64.cpp
  lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_riscv64.h
  lldb/source/Plugins/Process/Utility/CMakeLists.txt
  lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_riscv64.cpp
  lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_riscv64.h
  lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_riscv64.cpp
  lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_riscv64.h
  lldb/source/Plugins/Process/Utility/RegisterInfos_riscv64.h
  lldb/source/Utility/ArchSpec.cpp
  lldb/source/Utility/RISCV64_DWARF_Registers.h

Index: lldb/source/Utility/RISCV64_DWARF_Registers.h
===
--- /dev/null
+++ lldb/source/Utility/RISCV64_DWARF_Registers.h
@@ -0,0 +1,92 @@
+//===-- RISCV64_DWARF_Registers.h ---*- C++ -*-===//
+//
+// 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
+//
+//===--===//
+
+#ifndef LLDB_SOURCE_UTILITY_RISCV64_DWARF_REGISTERS_H
+#define LLDB_SOURCE_UTILITY_RISCV64_DWARF_REGISTERS_H
+
+#include "lldb/lldb-private.h"
+
+namespace riscv64_dwarf {
+
+enum {
+  x0 = 0,
+  x1,
+  x2,
+  x3,
+  x4,
+  x5,
+  x6,
+  x7,
+  x8,
+  x9,
+  x10,
+  x11,
+  x12,
+  x13,
+  x14,
+  x15,
+  x16,
+  x17,
+  x18,
+  x19,
+  x20,
+  x21,
+  x22,
+  x23,
+  x24,
+  x25,
+  x26,
+  x27,
+  x28,
+  x29,
+  x30,
+  x31,
+  ra = x1,
+  sp = x2,
+  fp = x8,
+
+  f0,
+  f1,
+  f2,
+  f3,
+  f4,
+  f5,
+  f6,
+  f7,
+  f8,
+  f9,
+  f10,
+  f11,
+  f12,
+  f13,
+  f14,
+  f15,
+  f16,
+  f17,
+  f18,
+  f19,
+  f20,
+  f21,
+  f22,
+  f23,
+  f24,
+  f25,
+  f26,
+  f27,
+  f28,
+  f29,
+  f30,
+  f31,
+
+  // Floating-Point Control and Status Register
+  fcsr,
+};
+
+} // namespace riscv64_dwarf
+
+#endif // LLDB_SOURCE_UTILITY_RISCV64_DWARF_REGISTERS_H
Index: lldb/source/Utility/ArchSpec.cpp
===
--- lldb/source/Utility/ArchSpec.cpp
+++ lldb/source/Utility/ArchSpec.cpp
@@ -724,6 +724,8 @@
   case llvm::Triple::systemz:
   case llvm::Triple::xcore:
   case llvm::Triple::arc:
+  case llvm::Triple::riscv32:
+  case llvm::Triple::riscv64:
 return false;
   }
 }
@@ -1376,6 +1378,20 @@
 }
 break;
 
+  case ArchSpec::eCore_riscv32:
+if (!enforce_exact_match) {
+  if (core2 == ArchSpec::eCore_riscv32)
+return true;
+}
+break;
+
+  case ArchSpec::eCore_riscv64:
+if (!enforce_exact_match) {
+  if (core2 == ArchSpec::eCore_riscv64)
+return true;
+}
+break;
+
   default:
 break;
   }
Index: lldb/source/Plugins/Process/Utility/RegisterInfos_riscv64.h
===
--- /dev/null
+++ lldb/source/Plugins/Process/Utility/RegisterInfos_riscv64.h
@@ -0,0 +1,262 @@
+//===-- RegisterInfos_riscv64.h -*- C++ -*-===//
+//
+// 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
+//
+//===--===//
+
+#ifdef DECLARE_REGISTER_INFOS_RISCV64_STRUCT
+
+#include 
+
+#include "lldb/lldb-defines.h"
+#include "lldb/lldb-enumerations.h"
+#include "lldb/lldb-private.h"
+
+#include "Utility/RISCV64_DWARF_Registers.h"
+
+#ifndef GPR_OFFSET
+#error GPR_OFFSET must b

[Lldb-commits] [PATCH] D128465: [llvm] cmake config groundwork to have ZSTD in LLVM

2022-07-08 Thread Leonard Chan via Phabricator via lldb-commits
leonardchan accepted this revision.
leonardchan added a comment.
This revision is now accepted and ready to land.

LGTM although I think I'd be more comfortable with Petr's +2 for cmake changes.

Would it be better instead to expose `LLVM_ENABLE_ZSTD` to subrepos like clangd 
or flang until they're needed there? Not sure in this case if this will need 
+2s from their respective owners.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128465

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


[Lldb-commits] [PATCH] D128465: Zstandard as a second compression method to LLVM

2022-07-08 Thread Cole Kissane via Phabricator via lldb-commits
ckissane updated this revision to Diff 443035.
ckissane added a comment.

start breaking this up further, this is now the add cmake config patch


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128465

Files:
  clang-tools-extra/clangd/CMakeLists.txt
  clang-tools-extra/clangd/test/lit.site.cfg.py.in
  clang/test/CMakeLists.txt
  clang/test/lit.site.cfg.py.in
  compiler-rt/lib/sanitizer_common/symbolizer/scripts/build_symbolizer.sh
  compiler-rt/test/lit.common.configured.in
  flang/CMakeLists.txt
  lld/ELF/CMakeLists.txt
  lldb/source/Plugins/Process/gdb-remote/CMakeLists.txt
  llvm/CMakeLists.txt
  llvm/cmake/config-ix.cmake
  llvm/cmake/modules/FindZSTD.cmake
  llvm/cmake/modules/LLVMConfig.cmake.in
  llvm/include/llvm/Config/llvm-config.h.cmake
  utils/bazel/llvm_configs/llvm-config.h.cmake

Index: utils/bazel/llvm_configs/llvm-config.h.cmake
===
--- utils/bazel/llvm_configs/llvm-config.h.cmake
+++ utils/bazel/llvm_configs/llvm-config.h.cmake
@@ -95,6 +95,9 @@
 /* Define if zlib compression is available */
 #cmakedefine01 LLVM_ENABLE_ZLIB
 
+/* Define if zstd compression is available */
+#cmakedefine01 LLVM_ENABLE_ZSTD
+
 /* Define if LLVM was built with a dependency to the libtensorflow dynamic library */
 #cmakedefine LLVM_HAVE_TF_API
 
Index: llvm/include/llvm/Config/llvm-config.h.cmake
===
--- llvm/include/llvm/Config/llvm-config.h.cmake
+++ llvm/include/llvm/Config/llvm-config.h.cmake
@@ -95,6 +95,9 @@
 /* Define if zlib compression is available */
 #cmakedefine01 LLVM_ENABLE_ZLIB
 
+/* Define if zstd compression is available */
+#cmakedefine01 LLVM_ENABLE_ZSTD
+
 /* Define if LLVM was built with a dependency to the libtensorflow dynamic library */
 #cmakedefine LLVM_HAVE_TF_API
 
Index: llvm/cmake/modules/LLVMConfig.cmake.in
===
--- llvm/cmake/modules/LLVMConfig.cmake.in
+++ llvm/cmake/modules/LLVMConfig.cmake.in
@@ -73,6 +73,12 @@
   find_package(ZLIB)
 endif()
 
+set(LLVM_ENABLE_ZSTD @LLVM_ENABLE_ZSTD@)
+if(LLVM_ENABLE_ZSTD)
+  set(ZSTD_ROOT @ZSTD_ROOT@)
+  find_package(ZSTD)
+endif()
+
 set(LLVM_ENABLE_LIBXML2 @LLVM_ENABLE_LIBXML2@)
 if(LLVM_ENABLE_LIBXML2)
   find_package(LibXml2)
Index: llvm/cmake/modules/FindZSTD.cmake
===
--- /dev/null
+++ llvm/cmake/modules/FindZSTD.cmake
@@ -0,0 +1,31 @@
+#
+#//===--===//
+#//
+#// 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
+#//
+#//===--===//
+#
+
+find_path(ZSTD_INCLUDE_DIR
+  NAMES zstd.h
+  HINTS ${ZSTD_ROOT_DIR}/include)
+
+find_library(ZSTD_LIBRARY
+  NAMES zstd
+  HINTS ${ZSTD_ROOT_DIR}/lib)
+
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(
+ZSTD DEFAULT_MSG
+ZSTD_LIBRARY ZSTD_INCLUDE_DIR)
+
+if(ZSTD_FOUND)
+set(ZSTD_LIBRARIES ${ZSTD_LIBRARY})
+set(ZSTD_INCLUDE_DIRS ${ZSTD_INCLUDE_DIR})
+endif()
+
+mark_as_advanced(
+  ZSTD_INCLUDE_DIR
+  ZSTD_LIBRARY)
Index: llvm/cmake/config-ix.cmake
===
--- llvm/cmake/config-ix.cmake
+++ llvm/cmake/config-ix.cmake
@@ -136,6 +136,27 @@
   set(LLVM_ENABLE_ZLIB "${HAVE_ZLIB}")
 endif()
 
+if(LLVM_ENABLE_ZSTD)
+  if(LLVM_ENABLE_ZSTD STREQUAL FORCE_ON)
+find_package(ZSTD REQUIRED)
+  elseif(NOT LLVM_USE_SANITIZER MATCHES "Memory.*")
+find_package(ZSTD)
+  endif()
+  if(ZSTD_FOUND)
+# Check if zstd we found is usable; for example, we may have found a 32-bit
+# library on a 64-bit system which would result in a link-time failure.
+cmake_push_check_state()
+list(APPEND CMAKE_REQUIRED_INCLUDES ${ZSTD_INCLUDE_DIR})
+list(APPEND CMAKE_REQUIRED_LIBRARIES ${ZSTD_LIBRARY})
+check_symbol_exists(ZSTD_compress zstd.h HAVE_ZSTD)
+cmake_pop_check_state()
+if(LLVM_ENABLE_ZSTD STREQUAL FORCE_ON AND NOT HAVE_ZSTD)
+  message(FATAL_ERROR "Failed to configure zstd")
+endif()
+  endif()
+  set(LLVM_ENABLE_ZSTD "${HAVE_ZSTD}")
+endif()
+
 if(LLVM_ENABLE_LIBXML2)
   if(LLVM_ENABLE_LIBXML2 STREQUAL FORCE_ON)
 find_package(LibXml2 REQUIRED)
Index: llvm/CMakeLists.txt
===
--- llvm/CMakeLists.txt
+++ llvm/CMakeLists.txt
@@ -438,6 +438,8 @@
 
 set(LLVM_ENABLE_ZLIB "ON" CACHE STRING "Use zlib for compression/decompression if available. Can be ON, OFF, or FORCE_ON")
 
+set(LLVM_ENABLE_ZSTD "ON" CACHE STRING "Use zstd for compression/decompression if available. Can be ON, OFF, or FORCE_ON")
+
 set(LLVM

[Lldb-commits] [PATCH] D129131: Remove uses of llvm_shutdown

2022-07-08 Thread Nicolai Hähnle via Phabricator via lldb-commits
nhaehnle created this revision.
nhaehnle added reviewers: efriedma, lattner.
Herald added a reviewer: bollu.
Herald added subscribers: anlunx, bzcheeseman, ayermolo, sdasgup3, wenzhicui, 
wrengr, dcaballe, cota, teijeong, rdzhabarov, tatianashp, msifontes, jurahul, 
Kayjukh, grosul1, jvesely, Joonsoo, liufengdb, aartbik, mgester, arpith-jacob, 
antiagainst, shauheen, rriddle, mehdi_amini, hiraditya.
Herald added a reviewer: rafauler.
Herald added a reviewer: Amir.
Herald added a reviewer: maksfb.
Herald added a project: All.
nhaehnle requested review of this revision.
Herald added subscribers: lldb-commits, cfe-commits, yota9, 
stephenneuendorffer, nicolasvasilache.
Herald added projects: clang, LLDB, MLIR, LLVM.

With the removal of ManagedStatic, llvm_shutdown will be removed as
well.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D129131

Files:
  bolt/tools/driver/llvm-bolt.cpp
  bolt/tools/merge-fdata/merge-fdata.cpp
  clang/include/clang/Frontend/CompilerInstance.h
  clang/tools/clang-repl/ClangRepl.cpp
  clang/unittests/Interpreter/ExceptionTests/InterpreterExceptionTest.cpp
  clang/unittests/Interpreter/InterpreterTest.cpp
  clang/utils/TableGen/TableGen.cpp
  libclc/utils/prepare-builtins.cpp
  lldb/tools/driver/Driver.cpp
  lldb/tools/lldb-test/lldb-test.cpp
  lldb/unittests/Utility/LogTest.cpp
  lldb/utils/TableGen/LLDBTableGen.cpp
  llvm/examples/BrainF/BrainFDriver.cpp
  llvm/examples/HowToUseJIT/HowToUseJIT.cpp
  llvm/include/llvm/PassRegistry.h
  llvm/include/llvm/Support/DynamicLibrary.h
  llvm/include/llvm/Support/InitLLVM.h
  llvm/lib/IR/Pass.cpp
  llvm/lib/Support/InitLLVM.cpp
  llvm/lib/Support/Unix/DynamicLibrary.inc
  llvm/lib/Support/Unix/Signals.inc
  llvm/lib/Support/Windows/DynamicLibrary.inc
  llvm/tools/gold/gold-plugin.cpp
  llvm/tools/llvm-gsymutil/llvm-gsymutil.cpp
  llvm/unittests/ExecutionEngine/ExecutionEngineTest.cpp
  llvm/unittests/Support/DynamicLibrary/DynamicLibraryTest.cpp
  llvm/utils/KillTheDoctor/KillTheDoctor.cpp
  mlir/tools/mlir-vulkan-runner/mlir-vulkan-runner.cpp
  polly/lib/External/isl/interface/extract_interface.cc

Index: polly/lib/External/isl/interface/extract_interface.cc
===
--- polly/lib/External/isl/interface/extract_interface.cc
+++ polly/lib/External/isl/interface/extract_interface.cc
@@ -48,7 +48,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -587,7 +586,6 @@
 
 	delete sema;
 	delete Clang;
-	llvm::llvm_shutdown();
 
 	if (Diags.hasErrorOccurred())
 		return EXIT_FAILURE;
Index: mlir/tools/mlir-vulkan-runner/mlir-vulkan-runner.cpp
===
--- mlir/tools/mlir-vulkan-runner/mlir-vulkan-runner.cpp
+++ mlir/tools/mlir-vulkan-runner/mlir-vulkan-runner.cpp
@@ -62,7 +62,6 @@
 }
 
 int main(int argc, char **argv) {
-  llvm::llvm_shutdown_obj x;
   registerPassManagerCLOptions();
 
   llvm::InitLLVM y(argc, argv);
Index: llvm/utils/KillTheDoctor/KillTheDoctor.cpp
===
--- llvm/utils/KillTheDoctor/KillTheDoctor.cpp
+++ llvm/utils/KillTheDoctor/KillTheDoctor.cpp
@@ -36,7 +36,6 @@
 #include "llvm/ADT/StringRef.h"
 #include "llvm/ADT/Twine.h"
 #include "llvm/Support/CommandLine.h"
-#include "llvm/Support/ManagedStatic.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/PrettyStackTrace.h"
 #include "llvm/Support/Signals.h"
@@ -297,7 +296,6 @@
   // Print a stack trace if we signal out.
   sys::PrintStackTraceOnErrorSignal(argv[0]);
   PrettyStackTraceProgram X(argc, argv);
-  llvm_shutdown_obj Y;  // Call llvm_shutdown() on exit.
 
   ToolName = argv[0];
 
Index: llvm/unittests/Support/DynamicLibrary/DynamicLibraryTest.cpp
===
--- llvm/unittests/Support/DynamicLibrary/DynamicLibraryTest.cpp
+++ llvm/unittests/Support/DynamicLibrary/DynamicLibraryTest.cpp
@@ -9,7 +9,6 @@
 #include "llvm/Support/DynamicLibrary.h"
 #include "llvm/Config/config.h"
 #include "llvm/Support/FileSystem.h"
-#include "llvm/Support/ManagedStatic.h"
 #include "llvm/Support/Path.h"
 #include "gtest/gtest.h"
 
@@ -59,7 +58,6 @@
 TEST(DynamicLibrary, Overload) {
   {
 std::string Err;
-llvm_shutdown_obj Shutdown;
 DynamicLibrary DL =
 DynamicLibrary::getPermanentLibrary(LibPath().c_str(), &Err);
 EXPECT_TRUE(DL.isValid());
@@ -109,9 +107,6 @@
   }
   EXPECT_TRUE(FuncPtr(DynamicLibrary::SearchForAddressOfSymbol(
   "TestA")) == nullptr);
-
-  // Check serach ordering is reset to default after call to llvm_shutdown
-  EXPECT_EQ(DynamicLibrary::SearchOrder, DynamicLibrary::SO_Linker);
 }
 
 TEST(DynamicLibrary, Shutdown) {
@@ -119,7 +114,6 @@
   std::vector Order;
   {
 std::string Err;
-llvm_shutdown_obj Shutdown;
 DynamicLibrary DL =
 DynamicLibrary::getPermanentLibrary(LibPath(A).c_str(), &Err);
 EXPECT_TRUE(DL.isVal

[Lldb-commits] [PATCH] D128465: [llvm] cmake config groundwork to have ZSTD in LLVM

2022-07-08 Thread Petr Hosek via Phabricator via lldb-commits
phosek added inline comments.



Comment at: llvm/cmake/modules/FindZSTD.cmake:1
+# Copyright (c) Meta Platforms, Inc. and affiliates.
+#

MaskRay wrote:
> How did you derive this?
> 
> The file seems contributed by you (I don't think facebook/zstd has such a 
> file). It should not have a Meta Platforms, Inc notice.
We usually don't include the copyright header in `.cmake` files at all.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128465

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


[Lldb-commits] [PATCH] D128465: [llvm] cmake config groundwork to have ZSTD in LLVM

2022-07-08 Thread Fangrui Song via Phabricator via lldb-commits
MaskRay added a comment.

Consider adding `have_zstd` to `compiler-rt/test/lit.common.cfg.py`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128465

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


[Lldb-commits] [PATCH] D128465: [llvm] cmake config groundwork to have ZSTD in LLVM

2022-07-08 Thread Cole Kissane via Phabricator via lldb-commits
ckissane marked 2 inline comments as done.
ckissane added a comment.

mark outdated comments done


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128465

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


[Lldb-commits] [PATCH] D125509: [LLDB][NFC] Decouple dwarf location table from DWARFExpression.

2022-07-08 Thread Zequan Wu via Phabricator via lldb-commits
zequanwu added a comment.

In D125509#3637271 , @dyung wrote:

> Hi @zequanwu, your change is causing a test failure in the cross-project-test 
> suite on the PS4 linux bot. Can you take a look and revert if you need time 
> to investigate?
>
> https://lab.llvm.org/buildbot/#/builders/217/builds/7945
>
>   aggregate-indirect-arg.cpp: nan/nan (nan) [Command '['/usr/bin/python3.8', 
> '/home/buildbot/buildbot-root/llvm-project/cross-project-tests/debuginfo-tests/dexter/dex/../dexter.py',
>  'run-debugger-internal-', 
> '/tmp/lit-tmp-cjxevz6m/dexter/tmp5dvb0g5o/tmpod7j5lgc', 
> '--working-directory=/tmp/lit-tmp-cjxevz6m/dexter/tmp5dvb0g5o', 
> '--unittest=off', '--indent-timer-level=3']' returned non-zero exit status 1.]
>
> If you need help debugging the dexter failure, @Orlando might be able to help 
> you.

Thanks, it should be fixed by 
https://reviews.llvm.org/rG562c3467a6738aa89203f72fc1d1343e5baadf3c


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125509

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


[Lldb-commits] [PATCH] D125509: [LLDB][NFC] Decouple dwarf location table from DWARFExpression.

2022-07-08 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere added a comment.

I went ahead and reverted your change to turn the bot green again:

  commit e4c5bca597a6f12e8f789a53e862387b9808ff48 (HEAD -> main, origin/main, 
origin/HEAD)
  Author: Jonas Devlieghere 
  Date:   Thu Jul 7 16:28:35 2022 -0700
  
  Revert "[LLDB][NFC] Decouple dwarf location table from DWARFExpression."
  
  This reverts commit 227dffd0b6d78154516ace45f6ed28259c7baa48 and its
  follow up 562c3467a6738aa89203f72fc1d1343e5baadf3c because it breaks a
  bunch of tests on GreenDragon:
  
  https://green.lab.llvm.org/green/view/LLDB/job/lldb-cmake/45155/


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125509

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


[Lldb-commits] [PATCH] D127444: [libc++] Use ABI tags instead of internal linkage to provide per-TU insulation

2022-07-08 Thread Louis Dionne via Phabricator via lldb-commits
ldionne updated this revision to Diff 443066.
ldionne added a comment.
Herald added projects: LLDB, LLVM.
Herald added subscribers: llvm-commits, lldb-commits.

Band-aid for the LLDB issue, and also include 6148c79a 
 in the 
commit.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127444

Files:
  libcxx/CMakeLists.txt
  libcxx/cmake/caches/Apple.cmake
  libcxx/docs/BuildingLibcxx.rst
  libcxx/docs/DesignDocs/VisibilityMacros.rst
  libcxx/docs/ReleaseNotes.rst
  libcxx/include/__config
  libcxx/include/__config_site.in
  libcxx/test/libcxx/strings/basic.string/PR42676.sh.cpp
  lldb/packages/Python/lldbsuite/test/make/Makefile.rules
  llvm/utils/gn/secondary/libcxx/include/BUILD.gn

Index: llvm/utils/gn/secondary/libcxx/include/BUILD.gn
===
--- llvm/utils/gn/secondary/libcxx/include/BUILD.gn
+++ llvm/utils/gn/secondary/libcxx/include/BUILD.gn
@@ -19,7 +19,6 @@
   "_LIBCPP_ABI_FORCE_ITANIUM=",
   "_LIBCPP_ABI_FORCE_MICROSOFT=",
   "_LIBCPP_EXTRA_SITE_DEFINES=",
-  "_LIBCPP_HIDE_FROM_ABI_PER_TU_BY_DEFAULT=",
   "_LIBCPP_HAS_NO_FILESYSTEM_LIBRARY=",
   "_LIBCPP_HAS_NO_INCOMPLETE_FORMAT=",
   "_LIBCPP_HAS_NO_INCOMPLETE_RANGES=",
Index: lldb/packages/Python/lldbsuite/test/make/Makefile.rules
===
--- lldb/packages/Python/lldbsuite/test/make/Makefile.rules
+++ lldb/packages/Python/lldbsuite/test/make/Makefile.rules
@@ -387,7 +387,8 @@
 endif
 
 ifeq (1,$(USE_LIBCPP))
-	CXXFLAGS += -DLLDB_USING_LIBCPP
+	# TODO: Teach LLDB to handle ABI tags in libc++ namespaces.
+	CXXFLAGS += -DLLDB_USING_LIBCPP -D_LIBCPP_NO_ABI_TAG
 	ifeq "$(OS)" "Android"
 		# Nothing to do, this is already handled in
 		# Android.rules.
Index: libcxx/test/libcxx/strings/basic.string/PR42676.sh.cpp
===
--- libcxx/test/libcxx/strings/basic.string/PR42676.sh.cpp
+++ /dev/null
@@ -1,22 +0,0 @@
-//===--===//
-//
-// 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
-//
-//===--===//
-
-// Regression test for PR42676.
-
-// RUN: %{cxx} %{flags} %s -o %t.exe %{compile_flags} %{link_flags} -D_LIBCPP_HIDE_FROM_ABI_PER_TU
-// RUN: %{run}
-
-#include 
-#include 
-
-int main(int, char**) {
-std::string s1(10u, '-', std::allocator()); (void)s1;
-std::string s2("hello", std::allocator()); (void)s2;
-std::string s3("hello"); (void)s3;
-return 0;
-}
Index: libcxx/include/__config_site.in
===
--- libcxx/include/__config_site.in
+++ libcxx/include/__config_site.in
@@ -13,7 +13,6 @@
 #cmakedefine _LIBCPP_ABI_NAMESPACE @_LIBCPP_ABI_NAMESPACE@
 #cmakedefine _LIBCPP_ABI_FORCE_ITANIUM
 #cmakedefine _LIBCPP_ABI_FORCE_MICROSOFT
-#cmakedefine _LIBCPP_HIDE_FROM_ABI_PER_TU_BY_DEFAULT
 #cmakedefine _LIBCPP_HAS_NO_THREADS
 #cmakedefine _LIBCPP_HAS_NO_MONOTONIC_CLOCK
 #cmakedefine _LIBCPP_HAS_MUSL_LIBC
Index: libcxx/include/__config
===
--- libcxx/include/__config
+++ libcxx/include/__config
@@ -26,6 +26,13 @@
 
 #  define _LIBCPP_VERSION 15000
 
+#  define _LIBCPP_CONCAT_IMPL(_X, _Y) _X##_Y
+#  define _LIBCPP_CONCAT(_X, _Y) _LIBCPP_CONCAT_IMPL(_X, _Y)
+
+// Valid C++ identifier that revs with every libc++ version. This can be used to
+// generate identifiers that must be unique for every released libc++ version.
+#  define _LIBCPP_VERSIONED_IDENTIFIER _LIBCPP_CONCAT(v, _LIBCPP_VERSION)
+
 #  if __STDC_HOSTED__ == 0
 #define _LIBCPP_FREESTANDING
 #  endif
@@ -568,12 +575,6 @@
 
 #  endif // defined(_LIBCPP_OBJECT_FORMAT_COFF)
 
-#  if __has_attribute(internal_linkage)
-#define _LIBCPP_INTERNAL_LINKAGE __attribute__((internal_linkage))
-#  else
-#define _LIBCPP_INTERNAL_LINKAGE _LIBCPP_ALWAYS_INLINE
-#  endif
-
 #  if __has_attribute(exclude_from_explicit_instantiation)
 #define _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION __attribute__((__exclude_from_explicit_instantiation__))
 #  else
@@ -583,20 +584,35 @@
 #define _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION _LIBCPP_ALWAYS_INLINE
 #  endif
 
-#  ifndef _LIBCPP_HIDE_FROM_ABI_PER_TU
-#ifndef _LIBCPP_HIDE_FROM_ABI_PER_TU_BY_DEFAULT
-#  define _LIBCPP_HIDE_FROM_ABI_PER_TU 0
-#else
-#  define _LIBCPP_HIDE_FROM_ABI_PER_TU 1
-#endif
-#  endif
-
-#  ifndef _LIBCPP_HIDE_FROM_ABI
-#if _LIBCPP_HIDE_FROM_ABI_PER_TU
-#  define _LIBCPP_HIDE_FROM_ABI _LIBCPP_HIDDEN _LIBCPP_INTERNAL_LINKAGE
-#else
-#

[Lldb-commits] [PATCH] D128465: [llvm] cmake config groundwork to have ZSTD in LLVM

2022-07-08 Thread Fangrui Song via Phabricator via lldb-commits
MaskRay accepted this revision.
MaskRay added a comment.

Please check both `LLVM_ENABLE_ZSTD={on,off}` work. Ideally, check that when 
zstd' cmake (`libzstd-dev` on Debian) is unavailable, `LLVM_ENABLE_ZSTD=on` 
works (there is no zstd functionality but the cmake invocation should succeed).




Comment at: llvm/cmake/modules/FindZSTD.cmake:3
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.

MaskRay wrote:
> Search `SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception` from other 
> `.cmake` files
Delete `//`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128465

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


[Lldb-commits] [PATCH] D128465: [llvm] cmake config groundwork to have ZSTD in LLVM

2022-07-08 Thread Cole Kissane via Phabricator via lldb-commits
ckissane updated this revision to Diff 443310.
ckissane added a comment.

- Merge remote-tracking branch 'origin/main' into ckissane.add-zstd.0-cmake


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128465

Files:
  clang-tools-extra/clangd/CMakeLists.txt
  clang-tools-extra/clangd/test/lit.cfg.py
  clang-tools-extra/clangd/test/lit.site.cfg.py.in
  clang/test/CMakeLists.txt
  clang/test/lit.site.cfg.py.in
  compiler-rt/lib/sanitizer_common/symbolizer/scripts/build_symbolizer.sh
  compiler-rt/test/lit.common.cfg.py
  compiler-rt/test/lit.common.configured.in
  flang/CMakeLists.txt
  lld/ELF/CMakeLists.txt
  lld/test/lit.site.cfg.py.in
  lldb/source/Plugins/Process/gdb-remote/CMakeLists.txt
  lldb/test/Shell/lit.site.cfg.py.in
  llvm/CMakeLists.txt
  llvm/cmake/config-ix.cmake
  llvm/cmake/modules/FindZSTD.cmake
  llvm/cmake/modules/LLVMConfig.cmake.in
  llvm/include/llvm/Config/llvm-config.h.cmake
  llvm/test/lit.site.cfg.py.in
  utils/bazel/llvm_configs/llvm-config.h.cmake

Index: utils/bazel/llvm_configs/llvm-config.h.cmake
===
--- utils/bazel/llvm_configs/llvm-config.h.cmake
+++ utils/bazel/llvm_configs/llvm-config.h.cmake
@@ -95,6 +95,9 @@
 /* Define if zlib compression is available */
 #cmakedefine01 LLVM_ENABLE_ZLIB
 
+/* Define if zstd compression is available */
+#cmakedefine01 LLVM_ENABLE_ZSTD
+
 /* Define if LLVM was built with a dependency to the libtensorflow dynamic library */
 #cmakedefine LLVM_HAVE_TF_API
 
Index: llvm/test/lit.site.cfg.py.in
===
--- llvm/test/lit.site.cfg.py.in
+++ llvm/test/lit.site.cfg.py.in
@@ -37,6 +37,7 @@
 config.llvm_use_intel_jitevents = @LLVM_USE_INTEL_JITEVENTS@
 config.llvm_use_sanitizer = "@LLVM_USE_SANITIZER@"
 config.have_zlib = @LLVM_ENABLE_ZLIB@
+config.have_zstd = @LLVM_ENABLE_ZSTD@
 config.have_libxar = @LLVM_HAVE_LIBXAR@
 config.have_libxml2 = @LLVM_ENABLE_LIBXML2@
 config.have_curl = @LLVM_ENABLE_CURL@
Index: llvm/include/llvm/Config/llvm-config.h.cmake
===
--- llvm/include/llvm/Config/llvm-config.h.cmake
+++ llvm/include/llvm/Config/llvm-config.h.cmake
@@ -95,6 +95,9 @@
 /* Define if zlib compression is available */
 #cmakedefine01 LLVM_ENABLE_ZLIB
 
+/* Define if zstd compression is available */
+#cmakedefine01 LLVM_ENABLE_ZSTD
+
 /* Define if LLVM was built with a dependency to the libtensorflow dynamic library */
 #cmakedefine LLVM_HAVE_TF_API
 
Index: llvm/cmake/modules/LLVMConfig.cmake.in
===
--- llvm/cmake/modules/LLVMConfig.cmake.in
+++ llvm/cmake/modules/LLVMConfig.cmake.in
@@ -73,6 +73,12 @@
   find_package(ZLIB)
 endif()
 
+set(LLVM_ENABLE_ZSTD @LLVM_ENABLE_ZSTD@)
+if(LLVM_ENABLE_ZSTD)
+  set(ZSTD_ROOT @ZSTD_ROOT@)
+  find_package(ZSTD)
+endif()
+
 set(LLVM_ENABLE_LIBXML2 @LLVM_ENABLE_LIBXML2@)
 if(LLVM_ENABLE_LIBXML2)
   find_package(LibXml2)
Index: llvm/cmake/modules/FindZSTD.cmake
===
--- /dev/null
+++ llvm/cmake/modules/FindZSTD.cmake
@@ -0,0 +1,21 @@
+find_path(ZSTD_INCLUDE_DIR
+  NAMES zstd.h
+  HINTS ${ZSTD_ROOT_DIR}/include)
+
+find_library(ZSTD_LIBRARY
+  NAMES zstd
+  HINTS ${ZSTD_ROOT_DIR}/lib)
+
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(
+ZSTD DEFAULT_MSG
+ZSTD_LIBRARY ZSTD_INCLUDE_DIR)
+
+if(ZSTD_FOUND)
+set(ZSTD_LIBRARIES ${ZSTD_LIBRARY})
+set(ZSTD_INCLUDE_DIRS ${ZSTD_INCLUDE_DIR})
+endif()
+
+mark_as_advanced(
+  ZSTD_INCLUDE_DIR
+  ZSTD_LIBRARY)
Index: llvm/cmake/config-ix.cmake
===
--- llvm/cmake/config-ix.cmake
+++ llvm/cmake/config-ix.cmake
@@ -136,6 +136,27 @@
   set(LLVM_ENABLE_ZLIB "${HAVE_ZLIB}")
 endif()
 
+if(LLVM_ENABLE_ZSTD)
+  if(LLVM_ENABLE_ZSTD STREQUAL FORCE_ON)
+find_package(ZSTD REQUIRED)
+  elseif(NOT LLVM_USE_SANITIZER MATCHES "Memory.*")
+find_package(ZSTD)
+  endif()
+  if(ZSTD_FOUND)
+# Check if zstd we found is usable; for example, we may have found a 32-bit
+# library on a 64-bit system which would result in a link-time failure.
+cmake_push_check_state()
+list(APPEND CMAKE_REQUIRED_INCLUDES ${ZSTD_INCLUDE_DIR})
+list(APPEND CMAKE_REQUIRED_LIBRARIES ${ZSTD_LIBRARY})
+check_symbol_exists(ZSTD_compress zstd.h HAVE_ZSTD)
+cmake_pop_check_state()
+if(LLVM_ENABLE_ZSTD STREQUAL FORCE_ON AND NOT HAVE_ZSTD)
+  message(FATAL_ERROR "Failed to configure zstd")
+endif()
+  endif()
+  set(LLVM_ENABLE_ZSTD "${HAVE_ZSTD}")
+endif()
+
 if(LLVM_ENABLE_LIBXML2)
   if(LLVM_ENABLE_LIBXML2 STREQUAL FORCE_ON)
 find_package(LibXml2 REQUIRED)
Index: llvm/CMakeLists.txt
===
--- llvm/CMakeLists.txt
+++ llvm/C

[Lldb-commits] [PATCH] D128465: [llvm] cmake config groundwork to have ZSTD in LLVM

2022-07-08 Thread Cole Kissane via Phabricator via lldb-commits
ckissane marked 2 inline comments as done.
ckissane added a comment.

marked fixed comments as done


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128465

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


[Lldb-commits] [PATCH] D128465: [llvm] cmake config groundwork to have ZSTD in LLVM

2022-07-08 Thread Cole Kissane via Phabricator via lldb-commits
ckissane updated this revision to Diff 443308.
ckissane added a comment.

- Merge remote-tracking branch 'origin/main' into ckissane.add-zstd.0-cmake
- added have_zstd to compiler-rt/test/lit.common.cfg.py, 
clang-tools-extra/clangd/test/lit.cfg.py and several lit.site.cfg.py.in files


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128465

Files:
  clang-tools-extra/clangd/CMakeLists.txt
  clang-tools-extra/clangd/index/Serialization.cpp
  clang-tools-extra/clangd/test/lit.cfg.py
  clang-tools-extra/clangd/test/lit.site.cfg.py.in
  clang-tools-extra/clangd/unittests/SerializationTests.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTWriter.cpp
  clang/test/CMakeLists.txt
  clang/test/lit.site.cfg.py.in
  compiler-rt/lib/sanitizer_common/symbolizer/scripts/build_symbolizer.sh
  compiler-rt/test/lit.common.cfg.py
  compiler-rt/test/lit.common.configured.in
  flang/CMakeLists.txt
  lld/ELF/CMakeLists.txt
  lld/ELF/Driver.cpp
  lld/ELF/InputSection.cpp
  lld/test/lit.site.cfg.py.in
  lldb/source/Plugins/Process/gdb-remote/CMakeLists.txt
  lldb/test/Shell/lit.site.cfg.py.in
  llvm/CMakeLists.txt
  llvm/cmake/config-ix.cmake
  llvm/cmake/modules/FindZSTD.cmake
  llvm/cmake/modules/LLVMConfig.cmake.in
  llvm/docs/ReleaseNotes.rst
  llvm/include/llvm/Config/llvm-config.h.cmake
  llvm/include/llvm/Support/Compression.h
  llvm/lib/MC/ELFObjectWriter.cpp
  llvm/lib/ObjCopy/ELF/ELFObject.cpp
  llvm/lib/Object/Decompressor.cpp
  llvm/lib/ProfileData/Coverage/CoverageMappingReader.cpp
  llvm/lib/ProfileData/Coverage/CoverageMappingWriter.cpp
  llvm/lib/ProfileData/InstrProf.cpp
  llvm/lib/ProfileData/SampleProfReader.cpp
  llvm/lib/ProfileData/SampleProfWriter.cpp
  llvm/lib/Support/Compression.cpp
  llvm/test/lit.site.cfg.py.in
  llvm/tools/llvm-mc/llvm-mc.cpp
  llvm/tools/llvm-objcopy/ObjcopyOptions.cpp
  llvm/unittests/ProfileData/InstrProfTest.cpp
  llvm/unittests/Support/CompressionTest.cpp
  utils/bazel/llvm_configs/llvm-config.h.cmake

Index: utils/bazel/llvm_configs/llvm-config.h.cmake
===
--- utils/bazel/llvm_configs/llvm-config.h.cmake
+++ utils/bazel/llvm_configs/llvm-config.h.cmake
@@ -95,6 +95,9 @@
 /* Define if zlib compression is available */
 #cmakedefine01 LLVM_ENABLE_ZLIB
 
+/* Define if zstd compression is available */
+#cmakedefine01 LLVM_ENABLE_ZSTD
+
 /* Define if LLVM was built with a dependency to the libtensorflow dynamic library */
 #cmakedefine LLVM_HAVE_TF_API
 
Index: llvm/unittests/Support/CompressionTest.cpp
===
--- llvm/unittests/Support/CompressionTest.cpp
+++ llvm/unittests/Support/CompressionTest.cpp
@@ -18,6 +18,7 @@
 #include "gtest/gtest.h"
 
 using namespace llvm;
+using namespace llvm::compression;
 
 namespace {
 
@@ -62,12 +63,6 @@
   TestZlibCompression(BinaryDataStr, zlib::DefaultCompression);
 }
 
-TEST(CompressionTest, ZlibCRC32) {
-  EXPECT_EQ(
-  0x414FA339U,
-  zlib::crc32(StringRef("The quick brown fox jumps over the lazy dog")));
-}
-
 #endif
 
 }
Index: llvm/unittests/ProfileData/InstrProfTest.cpp
===
--- llvm/unittests/ProfileData/InstrProfTest.cpp
+++ llvm/unittests/ProfileData/InstrProfTest.cpp
@@ -1147,14 +1147,16 @@
 // Compressing:
 std::string FuncNameStrings1;
 EXPECT_THAT_ERROR(collectPGOFuncNameStrings(
-  FuncNames1, (DoCompression && zlib::isAvailable()),
+  FuncNames1,
+  (DoCompression && compression::zlib::isAvailable()),
   FuncNameStrings1),
   Succeeded());
 
 // Compressing:
 std::string FuncNameStrings2;
 EXPECT_THAT_ERROR(collectPGOFuncNameStrings(
-  FuncNames2, (DoCompression && zlib::isAvailable()),
+  FuncNames2,
+  (DoCompression && compression::zlib::isAvailable()),
   FuncNameStrings2),
   Succeeded());
 
Index: llvm/tools/llvm-objcopy/ObjcopyOptions.cpp
===
--- llvm/tools/llvm-objcopy/ObjcopyOptions.cpp
+++ llvm/tools/llvm-objcopy/ObjcopyOptions.cpp
@@ -739,7 +739,7 @@
 .str()
 .c_str());
 }
-if (!zlib::isAvailable())
+if (!compression::zlib::isAvailable())
   return createStringError(
   errc::invalid_argument,
   "LLVM was not compiled with LLVM_ENABLE_ZLIB: can not compress");
@@ -998,7 +998,7 @@
 "--decompress-debug-sections");
   }
 
-  if (Config.DecompressDebugSections && !zlib::isAvailable())
+  if (Config.DecompressDebugSections && !compression::zlib::isAvailable())
 return createStringError(
   

[Lldb-commits] [PATCH] D125509: [LLDB][NFC] Decouple dwarf location table from DWARFExpression.

2022-07-08 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere added a comment.

This is breaking a bunch of tests on GreenDragon:

  lldb-api.functionalities/location-list-lookup.TestLocationListLookup.py
  
lldb-api.functionalities/param_entry_vals/basic_entry_values.TestBasicEntryValues.py
  lldb-api.functionalities/return-value.TestReturnValue.py
  lldb-api.lang/c/const_variables.TestConstVariables.py
  lldb-api.lang/c/local_variables.TestLocalVariables.py
  lldb-api.lang/c/vla.TestVLA.py
  lldb-api.lang/objc/objc-optimized.TestObjcOptimized.py

https://green.lab.llvm.org/green/view/LLDB/job/lldb-cmake/45155/


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125509

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


[Lldb-commits] [PATCH] D128465: [llvm] cmake config groundwork to have ZSTD in LLVM

2022-07-08 Thread Fangrui Song via Phabricator via lldb-commits
MaskRay added inline comments.



Comment at: lld/test/lit.site.cfg.py.in:21
 config.have_zlib = @LLVM_ENABLE_ZLIB@
+config.have_zstd = @LLVM_ENABLE_ZSTD@
 config.have_libxar = @LLVM_HAVE_LIBXAR@

This needs a change in lld/test/CMakeLists.txt

Looks like you haven't run `ninja check-lld` as I mentioned.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128465

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


[Lldb-commits] [PATCH] D128465: [llvm] cmake config groundwork to have ZSTD in LLVM

2022-07-08 Thread Louis Dionne via Phabricator via lldb-commits
ldionne added inline comments.



Comment at: llvm/CMakeLists.txt:441
 
+set(LLVM_ENABLE_ZSTD "ON" CACHE STRING "Use zstd for compression/decompression 
if available. Can be ON, OFF, or FORCE_ON")
+

This broke builds that do not specify `LLVM_ENABLE_ZSTD=OFF` explicitly on 
macOS, and I suspect on other platforms as well:

```
ld: library not found for -lzstd
clang: error: linker command failed with exit code 1 (use -v to see invocation)
```

It looks to me like the build should not require `zstd` to be installed by 
default.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128465

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


[Lldb-commits] [PATCH] D128465: [llvm] cmake config groundwork to have ZSTD in LLVM

2022-07-08 Thread Cole Kissane via Phabricator via lldb-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGf07caf20b9d3: [llvm] cmake config groundwork to have ZSTD in 
LLVM (authored by ckissane).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128465

Files:
  clang-tools-extra/clangd/CMakeLists.txt
  clang-tools-extra/clangd/test/lit.cfg.py
  clang-tools-extra/clangd/test/lit.site.cfg.py.in
  clang/test/CMakeLists.txt
  clang/test/lit.site.cfg.py.in
  compiler-rt/lib/sanitizer_common/symbolizer/scripts/build_symbolizer.sh
  compiler-rt/test/lit.common.cfg.py
  compiler-rt/test/lit.common.configured.in
  flang/CMakeLists.txt
  lld/ELF/CMakeLists.txt
  lld/test/lit.site.cfg.py.in
  lldb/source/Plugins/Process/gdb-remote/CMakeLists.txt
  lldb/test/Shell/lit.site.cfg.py.in
  llvm/CMakeLists.txt
  llvm/cmake/config-ix.cmake
  llvm/cmake/modules/FindZSTD.cmake
  llvm/cmake/modules/LLVMConfig.cmake.in
  llvm/include/llvm/Config/llvm-config.h.cmake
  llvm/test/lit.site.cfg.py.in
  utils/bazel/llvm_configs/llvm-config.h.cmake

Index: utils/bazel/llvm_configs/llvm-config.h.cmake
===
--- utils/bazel/llvm_configs/llvm-config.h.cmake
+++ utils/bazel/llvm_configs/llvm-config.h.cmake
@@ -95,6 +95,9 @@
 /* Define if zlib compression is available */
 #cmakedefine01 LLVM_ENABLE_ZLIB
 
+/* Define if zstd compression is available */
+#cmakedefine01 LLVM_ENABLE_ZSTD
+
 /* Define if LLVM was built with a dependency to the libtensorflow dynamic library */
 #cmakedefine LLVM_HAVE_TF_API
 
Index: llvm/test/lit.site.cfg.py.in
===
--- llvm/test/lit.site.cfg.py.in
+++ llvm/test/lit.site.cfg.py.in
@@ -37,6 +37,7 @@
 config.llvm_use_intel_jitevents = @LLVM_USE_INTEL_JITEVENTS@
 config.llvm_use_sanitizer = "@LLVM_USE_SANITIZER@"
 config.have_zlib = @LLVM_ENABLE_ZLIB@
+config.have_zstd = @LLVM_ENABLE_ZSTD@
 config.have_libxar = @LLVM_HAVE_LIBXAR@
 config.have_libxml2 = @LLVM_ENABLE_LIBXML2@
 config.have_curl = @LLVM_ENABLE_CURL@
Index: llvm/include/llvm/Config/llvm-config.h.cmake
===
--- llvm/include/llvm/Config/llvm-config.h.cmake
+++ llvm/include/llvm/Config/llvm-config.h.cmake
@@ -95,6 +95,9 @@
 /* Define if zlib compression is available */
 #cmakedefine01 LLVM_ENABLE_ZLIB
 
+/* Define if zstd compression is available */
+#cmakedefine01 LLVM_ENABLE_ZSTD
+
 /* Define if LLVM was built with a dependency to the libtensorflow dynamic library */
 #cmakedefine LLVM_HAVE_TF_API
 
Index: llvm/cmake/modules/LLVMConfig.cmake.in
===
--- llvm/cmake/modules/LLVMConfig.cmake.in
+++ llvm/cmake/modules/LLVMConfig.cmake.in
@@ -73,6 +73,12 @@
   find_package(ZLIB)
 endif()
 
+set(LLVM_ENABLE_ZSTD @LLVM_ENABLE_ZSTD@)
+if(LLVM_ENABLE_ZSTD)
+  set(ZSTD_ROOT @ZSTD_ROOT@)
+  find_package(ZSTD)
+endif()
+
 set(LLVM_ENABLE_LIBXML2 @LLVM_ENABLE_LIBXML2@)
 if(LLVM_ENABLE_LIBXML2)
   find_package(LibXml2)
Index: llvm/cmake/modules/FindZSTD.cmake
===
--- /dev/null
+++ llvm/cmake/modules/FindZSTD.cmake
@@ -0,0 +1,21 @@
+find_path(ZSTD_INCLUDE_DIR
+  NAMES zstd.h
+  HINTS ${ZSTD_ROOT_DIR}/include)
+
+find_library(ZSTD_LIBRARY
+  NAMES zstd
+  HINTS ${ZSTD_ROOT_DIR}/lib)
+
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(
+ZSTD DEFAULT_MSG
+ZSTD_LIBRARY ZSTD_INCLUDE_DIR)
+
+if(ZSTD_FOUND)
+set(ZSTD_LIBRARIES ${ZSTD_LIBRARY})
+set(ZSTD_INCLUDE_DIRS ${ZSTD_INCLUDE_DIR})
+endif()
+
+mark_as_advanced(
+  ZSTD_INCLUDE_DIR
+  ZSTD_LIBRARY)
Index: llvm/cmake/config-ix.cmake
===
--- llvm/cmake/config-ix.cmake
+++ llvm/cmake/config-ix.cmake
@@ -136,6 +136,27 @@
   set(LLVM_ENABLE_ZLIB "${HAVE_ZLIB}")
 endif()
 
+if(LLVM_ENABLE_ZSTD)
+  if(LLVM_ENABLE_ZSTD STREQUAL FORCE_ON)
+find_package(ZSTD REQUIRED)
+  elseif(NOT LLVM_USE_SANITIZER MATCHES "Memory.*")
+find_package(ZSTD)
+  endif()
+  if(ZSTD_FOUND)
+# Check if zstd we found is usable; for example, we may have found a 32-bit
+# library on a 64-bit system which would result in a link-time failure.
+cmake_push_check_state()
+list(APPEND CMAKE_REQUIRED_INCLUDES ${ZSTD_INCLUDE_DIR})
+list(APPEND CMAKE_REQUIRED_LIBRARIES ${ZSTD_LIBRARY})
+check_symbol_exists(ZSTD_compress zstd.h HAVE_ZSTD)
+cmake_pop_check_state()
+if(LLVM_ENABLE_ZSTD STREQUAL FORCE_ON AND NOT HAVE_ZSTD)
+  message(FATAL_ERROR "Failed to configure zstd")
+endif()
+  endif()
+  set(LLVM_ENABLE_ZSTD "${HAVE_ZSTD}")
+endif()
+
 if(LLVM_ENABLE_LIBXML2)
   if(LLVM_ENABLE_LIBXML2 STREQUAL FORCE_ON)
 find_package(LibXml2 REQUIRED)
Index: llvm/CMakeLists.txt
=

[Lldb-commits] [PATCH] D128465: [llvm] cmake config groundwork to have ZSTD in LLVM

2022-07-08 Thread Fangrui Song via Phabricator via lldb-commits
MaskRay reopened this revision.
MaskRay added a comment.
This revision is now accepted and ready to land.

This patch has changed a lot from what I have reviewed. The CMake change should 
be added along with `llvm::compression::zstd::*` functions.
Otherwise the change just introduces some CMake variables which cannot be 
tested.

Since you haven't touched flang, compiler-rt, etc. The patch should not updated 
their CMake files.

For lld/ELF, I've created D129406  to add the 
support. It will need to wait until you have landed these zstd changes.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128465

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


[Lldb-commits] [PATCH] D128465: [llvm] cmake config groundwork to have ZSTD in LLVM

2022-07-08 Thread Fangrui Song via Phabricator via lldb-commits
MaskRay added inline comments.



Comment at: lld/test/lit.site.cfg.py.in:21
 config.have_zlib = @LLVM_ENABLE_ZLIB@
+config.have_zstd = @LLVM_ENABLE_ZSTD@
 config.have_libxar = @LLVM_HAVE_LIBXAR@

MaskRay wrote:
> This needs a change in lld/test/CMakeLists.txt
> 
> Looks like you haven't run `ninja check-lld` as I mentioned.
Actually I am preparing a lld patch and you probably should drop have_zstd from 
lld/ for this patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128465

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


[Lldb-commits] [PATCH] D127444: [libc++] Use ABI tags instead of internal linkage to provide per-TU insulation

2022-07-08 Thread Louis Dionne via Phabricator via lldb-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGd2e86866be0f: [libc++] Re-apply the use of ABI tags to 
provide per-TU insulation (authored by ldionne).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127444

Files:
  libcxx/CMakeLists.txt
  libcxx/cmake/caches/Apple.cmake
  libcxx/docs/BuildingLibcxx.rst
  libcxx/docs/DesignDocs/VisibilityMacros.rst
  libcxx/docs/ReleaseNotes.rst
  libcxx/include/__config
  libcxx/include/__config_site.in
  libcxx/test/libcxx/strings/basic.string/PR42676.sh.cpp
  lldb/packages/Python/lldbsuite/test/make/Makefile.rules
  llvm/utils/gn/secondary/libcxx/include/BUILD.gn

Index: llvm/utils/gn/secondary/libcxx/include/BUILD.gn
===
--- llvm/utils/gn/secondary/libcxx/include/BUILD.gn
+++ llvm/utils/gn/secondary/libcxx/include/BUILD.gn
@@ -19,7 +19,6 @@
   "_LIBCPP_ABI_FORCE_ITANIUM=",
   "_LIBCPP_ABI_FORCE_MICROSOFT=",
   "_LIBCPP_EXTRA_SITE_DEFINES=",
-  "_LIBCPP_HIDE_FROM_ABI_PER_TU_BY_DEFAULT=",
   "_LIBCPP_HAS_NO_FILESYSTEM_LIBRARY=",
   "_LIBCPP_HAS_NO_INCOMPLETE_FORMAT=",
   "_LIBCPP_HAS_NO_INCOMPLETE_RANGES=",
Index: lldb/packages/Python/lldbsuite/test/make/Makefile.rules
===
--- lldb/packages/Python/lldbsuite/test/make/Makefile.rules
+++ lldb/packages/Python/lldbsuite/test/make/Makefile.rules
@@ -387,7 +387,8 @@
 endif
 
 ifeq (1,$(USE_LIBCPP))
-	CXXFLAGS += -DLLDB_USING_LIBCPP
+	# TODO: Teach LLDB to handle ABI tags in libc++ namespaces.
+	CXXFLAGS += -DLLDB_USING_LIBCPP -D_LIBCPP_NO_ABI_TAG
 	ifeq "$(OS)" "Android"
 		# Nothing to do, this is already handled in
 		# Android.rules.
Index: libcxx/test/libcxx/strings/basic.string/PR42676.sh.cpp
===
--- libcxx/test/libcxx/strings/basic.string/PR42676.sh.cpp
+++ /dev/null
@@ -1,22 +0,0 @@
-//===--===//
-//
-// 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
-//
-//===--===//
-
-// Regression test for PR42676.
-
-// RUN: %{cxx} %{flags} %s -o %t.exe %{compile_flags} %{link_flags} -D_LIBCPP_HIDE_FROM_ABI_PER_TU
-// RUN: %{run}
-
-#include 
-#include 
-
-int main(int, char**) {
-std::string s1(10u, '-', std::allocator()); (void)s1;
-std::string s2("hello", std::allocator()); (void)s2;
-std::string s3("hello"); (void)s3;
-return 0;
-}
Index: libcxx/include/__config_site.in
===
--- libcxx/include/__config_site.in
+++ libcxx/include/__config_site.in
@@ -13,7 +13,6 @@
 #cmakedefine _LIBCPP_ABI_NAMESPACE @_LIBCPP_ABI_NAMESPACE@
 #cmakedefine _LIBCPP_ABI_FORCE_ITANIUM
 #cmakedefine _LIBCPP_ABI_FORCE_MICROSOFT
-#cmakedefine _LIBCPP_HIDE_FROM_ABI_PER_TU_BY_DEFAULT
 #cmakedefine _LIBCPP_HAS_NO_THREADS
 #cmakedefine _LIBCPP_HAS_NO_MONOTONIC_CLOCK
 #cmakedefine _LIBCPP_HAS_MUSL_LIBC
Index: libcxx/include/__config
===
--- libcxx/include/__config
+++ libcxx/include/__config
@@ -26,6 +26,13 @@
 
 #  define _LIBCPP_VERSION 15000
 
+#  define _LIBCPP_CONCAT_IMPL(_X, _Y) _X##_Y
+#  define _LIBCPP_CONCAT(_X, _Y) _LIBCPP_CONCAT_IMPL(_X, _Y)
+
+// Valid C++ identifier that revs with every libc++ version. This can be used to
+// generate identifiers that must be unique for every released libc++ version.
+#  define _LIBCPP_VERSIONED_IDENTIFIER _LIBCPP_CONCAT(v, _LIBCPP_VERSION)
+
 #  if __STDC_HOSTED__ == 0
 #define _LIBCPP_FREESTANDING
 #  endif
@@ -568,12 +575,6 @@
 
 #  endif // defined(_LIBCPP_OBJECT_FORMAT_COFF)
 
-#  if __has_attribute(internal_linkage)
-#define _LIBCPP_INTERNAL_LINKAGE __attribute__((internal_linkage))
-#  else
-#define _LIBCPP_INTERNAL_LINKAGE _LIBCPP_ALWAYS_INLINE
-#  endif
-
 #  if __has_attribute(exclude_from_explicit_instantiation)
 #define _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION __attribute__((__exclude_from_explicit_instantiation__))
 #  else
@@ -583,20 +584,35 @@
 #define _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION _LIBCPP_ALWAYS_INLINE
 #  endif
 
-#  ifndef _LIBCPP_HIDE_FROM_ABI_PER_TU
-#ifndef _LIBCPP_HIDE_FROM_ABI_PER_TU_BY_DEFAULT
-#  define _LIBCPP_HIDE_FROM_ABI_PER_TU 0
-#else
-#  define _LIBCPP_HIDE_FROM_ABI_PER_TU 1
-#endif
-#  endif
-
-#  ifndef _LIBCPP_HIDE_FROM_ABI
-#if _LIBCPP_HIDE_FROM_ABI_PER_TU
-#  define _LIBCPP_HIDE_FROM_ABI _LIBCPP_HIDDEN _LIBCPP_INTERNAL_LINKAGE
-#else
-#  define _LIBCPP_HIDE_FROM_ABI _LIBCPP_HIDDEN 

[Lldb-commits] [PATCH] D129377: [lldb/Fuzzer] Add fuzzer for expression evaluator

2022-07-08 Thread Chelsea Cassanova via Phabricator via lldb-commits
cassanova updated this revision to Diff 443362.
cassanova edited the summary of this revision.
cassanova added a comment.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Building the expression evaluator fuzzer is now conditional on the 
CLANG_ENABLE_PROTO_FUZZER CMake variable being enabled.

Copying the source and header files from is no longer being done in the 
top-level CMake file, this is instead added to the subdirectories of the clang 
fuzzer.

The fuzzer uses Clang's CMake modules for libprotobuf_mutator instead of 
copying the module into LLDB.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129377

Files:
  clang/tools/clang-fuzzer/handle-cxx/CMakeLists.txt
  clang/tools/clang-fuzzer/proto-to-cxx/CMakeLists.txt
  lldb/tools/lldb-fuzzer/lldb-expression-fuzzer/CMakeLists.txt

Index: lldb/tools/lldb-fuzzer/lldb-expression-fuzzer/CMakeLists.txt
===
--- lldb/tools/lldb-fuzzer/lldb-expression-fuzzer/CMakeLists.txt
+++ lldb/tools/lldb-fuzzer/lldb-expression-fuzzer/CMakeLists.txt
@@ -1,89 +1,50 @@
-set(LLVM_LINK_COMPONENTS
-  Support
-  )
-
-add_llvm_fuzzer(lldb-expression-fuzzer
-  EXCLUDE_FROM_ALL
-  lldb-expression-fuzzer.cpp
-  )
-
-if(TARGET lldb-expression-fuzzer)
-  target_include_directories(lldb-expression-fuzzer PRIVATE ..)
-
-  # Generate the necessary source and header files for using protobufs
-  find_package(Protobuf REQUIRED)
-  add_definitions(-DGOOGLE_PROTOBUF_NO_RTTI)
-  include_directories(${PROTOBUF_INCLUDE_DIRS})
-  include_directories(${CMAKE_CURRENT_BINARY_DIR})
-  protobuf_generate_cpp(PROTO_SRCS PROTO_HDRS cxx_proto.proto)
-  protobuf_generate_cpp(LOOP_PROTO_SRCS LOOP_PROTO_HDRS cxx_loop_proto.proto)
-  set(LLVM_OPTIONAL_SOURCES ${LLVM_OPTIONAL_SOURCES} ${PROTO_SRCS})
-
-  # Place the source and header files into a library for use by LLDB's expression fuzzer
-  # FIXME: It would be better to use add_lldb_library, but using this will cause an error
-  # during cmake's file generation phase
-  add_library(lldbCXXProto
-${PROTO_SRCS}
-${PROTO_HDRS}
-)
-
-  # Build and include the libprotobuf-mutator repository
-  include(ProtobufMutator)
-  include_directories(${ProtobufMutator_INCLUDE_DIRS})
-
-  # Create a variable for the libraries generated by protobuf and protobuf mutator
-  set(COMMON_PROTO_FUZZ_LIBRARIES
-${ProtobufMutator_LIBRARIES}
-${PROTOBUF_LIBRARIES}
-)
-
-  # Link the protobuf libraries as well as the clang libraries used to
-  # convert protobufs to C/C++
-  target_link_libraries(lldb-expression-fuzzer
-PRIVATE
-${COMMON_PROTO_FUZZ_LIBRARIES}
-clangHandleCXX
-lldbCXXProto
-clangProtoToCXX
-liblldb
+if(CLANG_ENABLE_PROTO_FUZZER)
+  set(LLVM_LINK_COMPONENTS
+Support
 )
 
-  # The target for this fuzzer needs to depend on the protobuf mutator
-  # repository
-  add_dependencies(lldb-expression-fuzzer lldb_protobuf_mutator)
-
-  add_custom_command(TARGET lldb-expression-fuzzer PRE_BUILD
-
-# FIXME: Copying the source and header files is not the preferred way to implement these libraries
-# on the LLDB side. It would be preferable to have the libraries for protobuf fuzzers be located
-# in a more central location
-
-# Create directories to store the files for handle-cxx and proto-to-cxx since the protobuf mutator
-# depends on them
-COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/handle-cxx
-COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/proto-to-cxx
-
-# Copy the header and source files for handle-cxx from clang
-COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/../../../../clang/tools/clang-fuzzer/handle-cxx/handle_cxx.h ${CMAKE_CURRENT_BINARY_DIR}/handle-cxx
-COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/../../../../clang/tools/clang-fuzzer/handle-cxx/handle_cxx.cpp ${CMAKE_CURRENT_BINARY_DIR}/handle-cxx
-
-# Copy the header and source files for proto-to-cxx from clang
-COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/../../../../clang/tools/clang-fuzzer/proto-to-cxx/proto_to_cxx.h ${CMAKE_CURRENT_BINARY_DIR}/proto-to-cxx
-COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/../../../../clang/tools/clang-fuzzer/proto-to-cxx/proto_to_cxx.cpp ${CMAKE_CURRENT_BINARY_DIR}/proto-to-cxx
-COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/../../../../clang/tools/clang-fuzzer/proto-to-cxx/proto_to_cxx_main.cpp ${CMAKE_CURRENT_BINARY_DIR}/proto-to-cxx
-
-# Create and compile a simple C program using the command line. This is
-# needed because LLDB's expression evaluator needs a legitmate target
-# instead of a dummy target
-COMMAND echo 'int main (int argc, char** argv) { return 0\; }' | clang -o main.out -xc -
+  add_llvm_fuzzer(lldb-expression-fuzzer
+EXCLUDE_FROM_ALL
+l

[Lldb-commits] [PATCH] D125509: [LLDB][NFC] Decouple dwarf location table from DWARFExpression.

2022-07-08 Thread Douglas Yung via Phabricator via lldb-commits
dyung added subscribers: Orlando, dyung.
dyung added a comment.

Hi @zequanwu, your change is causing a test failure in the cross-project-test 
suite on the PS4 linux bot. Can you take a look and revert if you need time to 
investigate?

https://lab.llvm.org/buildbot/#/builders/217/builds/7945

  aggregate-indirect-arg.cpp: nan/nan (nan) [Command '['/usr/bin/python3.8', 
'/home/buildbot/buildbot-root/llvm-project/cross-project-tests/debuginfo-tests/dexter/dex/../dexter.py',
 'run-debugger-internal-', 
'/tmp/lit-tmp-cjxevz6m/dexter/tmp5dvb0g5o/tmpod7j5lgc', 
'--working-directory=/tmp/lit-tmp-cjxevz6m/dexter/tmp5dvb0g5o', 
'--unittest=off', '--indent-timer-level=3']' returned non-zero exit status 1.]

If you need help debugging the dexter failure, @Orlando might be able to help 
you.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125509

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