[Lldb-commits] [PATCH] D134581: [lldb] Prevent re-adding a module that is already loaded

2022-10-21 Thread Martin Storsjö via Phabricator via lldb-commits
mstorsjo added a comment.

Was the consensus that we'd drop this patch?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134581

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


[Lldb-commits] [PATCH] D134581: [lldb] Prevent re-adding a module that is already loaded

2022-10-21 Thread Alvin Wong via Phabricator via lldb-commits
alvinhochun abandoned this revision.
alvinhochun added a comment.

Since the original issue was fixed in a different patch I don't think I will 
follow up on this anyway.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134581

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


[Lldb-commits] [PATCH] D136306: [lldb][CPlusPlus] Add abi_tag support to the CPlusPlusNameParser

2022-10-21 Thread Michael Buch via Phabricator via lldb-commits
Michael137 updated this revision to Diff 469553.
Michael137 added a comment.

- Docs fixes
- Add more test cases
- Handle operator overloads


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136306

Files:
  lldb/source/Plugins/Language/CPlusPlus/CPlusPlusNameParser.cpp
  lldb/source/Plugins/Language/CPlusPlus/CPlusPlusNameParser.h
  lldb/test/API/functionalities/step-avoids-regexp/TestStepAvoidsRegexp.py
  lldb/test/API/functionalities/step-avoids-regexp/main.cpp
  lldb/unittests/Language/CPlusPlus/CPlusPlusLanguageTest.cpp

Index: lldb/unittests/Language/CPlusPlus/CPlusPlusLanguageTest.cpp
===
--- lldb/unittests/Language/CPlusPlus/CPlusPlusLanguageTest.cpp
+++ lldb/unittests/Language/CPlusPlus/CPlusPlusLanguageTest.cpp
@@ -114,13 +114,74 @@
   {"llvm::Optional::operator*() const volatile &&",
"llvm::Optional", "operator*", "()",
"const volatile &&", "llvm::Optional::operator*"},
+  {"void foo>()", "", "foo>", "()", "",
+   "foo>"},
 
   // auto return type
   {"auto std::test_return_auto() const", "std",
"test_return_auto", "()", "const", "std::test_return_auto"},
   {"decltype(auto) std::test_return_auto(int) const", "std",
-   "test_return_auto", "(int)", "const",
-   "std::test_return_auto"}};
+   "test_return_auto", "(int)", "const", "std::test_return_auto"},
+
+  // abi_tag on class method
+  {"v1::v2::Dummy[abi:c1][abi:c2]> "
+   "v1::v2::Dummy[abi:c1][abi:c2]>"
+   "::method2>>(int, v1::v2::Dummy) const &&",
+   // Context
+   "v1::v2::Dummy[abi:c1][abi:c2]>",
+   // Basename
+   "method2>>",
+   // Args, qualifiers
+   "(int, v1::v2::Dummy)", "const &&",
+   // Full scope-qualified name without args
+   "v1::v2::Dummy[abi:c1][abi:c2]>"
+   "::method2>>"},
+
+  // abi_tag on free function and template argument
+  {"v1::v2::Dummy[abi:c1][abi:c2]> "
+   "v1::v2::with_tag_in_ns[abi:f1][abi:f2]>>(int, v1::v2::Dummy) const "
+   "&&",
+   // Context
+   "v1::v2",
+   // Basename
+   "with_tag_in_ns[abi:f1][abi:f2]>>",
+   // Args, qualifiers
+   "(int, v1::v2::Dummy)", "const &&",
+   // Full scope-qualified name without args
+   "v1::v2::with_tag_in_ns[abi:f1][abi:f2]>>"},
+
+  // abi_tag with special characters
+  {"auto ns::with_tag_in_ns[abi:special tag,0.0][abi:special "
+   "tag,1.0]>"
+   "(float) const &&",
+   // Context
+   "ns",
+   // Basename
+   "with_tag_in_ns[abi:special tag,0.0][abi:special tag,1.0]>",
+   // Args, qualifiers
+   "(float)", "const &&",
+   // Full scope-qualified name without args
+   "ns::with_tag_in_ns[abi:special tag,0.0][abi:special "
+   "tag,1.0]>"},
+
+  // abi_tag on operator overloads
+  {"std::__1::error_code::operator bool[abi:v16]() const",
+   "std::__1::error_code", "operator bool[abi:v16]", "()", "const",
+   "std::__1::error_code::operator bool[abi:v16]"},
+
+  {"auto ns::foo::operator[][abi:v16](size_t) const", "ns::foo",
+   "operator[][abi:v16]", "(size_t)", "const",
+   "ns::foo::operator[][abi:v16]"},
+
+  {"auto Foo[abi:abc]::operator<<>(int) &",
+   "Foo[abi:abc]", "operator<<>", "(int)", "&",
+   "Foo[abi:abc]::operator<<>"}};
 
   for (const auto &test : test_cases) {
 CPlusPlusLanguage::MethodName method(ConstString(test.input));
@@ -135,6 +196,30 @@
   }
 }
 
+TEST(CPlusPlusLanguage, InvalidMethodNameParsing) {
+  // Tests that we correctly reject malformed function names
+
+  std::string test_cases[] = {
+  "int Foo::operator[]<[10>()",
+  "Foo::operator bool[10]()",
+  "auto A::operator<=>[abi:tag]()",
+  "auto A::operator<<<(int)",
+  "auto A::operator>>>(int)",
+  "auto A::operator<<(int)",
+  "auto A::operator<<>(int)",
+  "auto A::foo[(int)",
+  "auto A::foo[](int)",
+  "auto A::foo[bar](int)",
+  "auto A::foo[abi](int)",
+  "auto A::foo[abi:(int)",
+  };
+
+  for (const auto &name : test_cases) {
+CPlusPlusLanguage::MethodName method{ConstString(name)};
+EXPECT_FALSE(method.IsValid()) << name;
+  }
+}
+
 TEST(CPlusPlusLanguage, ContainsPath) {
   CPlusPlusLanguage::MethodName 
   reference_1(ConstString("int foo::bar::func01(int a, double b)"));
Index: lldb/test/API/functionalities/step-avoids-regexp/main.cpp
===
--- lldb/test/API/functionalities/step-avoids-regexp/main.cpp
+++ lldb/test/API/functionalities/step-avoids-regexp/main.cpp
@@ -1,4 +1,6 @@
 namespace ignore {
+struct Dummy {};
+
 template  auto auto_ret(T x) { return 0; }
 [[gnu::abi_tag("test")]] int with_tag() { return 0; }
 template  [[gnu::abi_tag("test")]] int with_tag_template() {
@@ -8,9 +10,15 @@
 template  decltype(auto) dec

[Lldb-commits] [PATCH] D136006: [LLDB][NativePDB] Improve ParseDeclsForContext time.

2022-10-21 Thread Pavel Labath via Phabricator via lldb-commits
labath accepted this revision.
labath added inline comments.



Comment at: lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp:1413-1414
   if (context.isTranslationUnit()) {
-ParseAllNamespacesPlusChildrenOf(llvm::None);
+ParseAllTypes();
+ParseAllFunctionsAndNonLocalVars();
 return;

zequanwu wrote:
> labath wrote:
> > I have a feeling this is still doing more work than it would be necessary. 
> > I haven't checked, but I'd expect that here it should be sufficient to 
> > parse only the top level namespace names (not their contents), and create 
> > forward declarations for the classes in the global namespace. I suspect 
> > this is doing much more than that.
> > (Of course, if PDB makes it hard to parse just this information, then it 
> > might actually be better to parse everything -- I just don't know)
> Yeah, we can do that. 
> Update to don't try to complete types at all in 
> `PdbAstBuilder::ParseDeclsForContext`. For a chrome crash report I'm looking 
> at, the time for evaluating a unknown identifier(which will have search scope 
> being a TU) drops from 287s -> 160s.
cool


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136006

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


[Lldb-commits] [lldb] 3cc9884 - [lldb][CPlusPlus] Add abi_tag support to the CPlusPlusNameParser

2022-10-21 Thread Michael Buch via lldb-commits

Author: Michael Buch
Date: 2022-10-21T14:00:50+01:00
New Revision: 3cc9884500ad53e878045bc1d119d8a6b326f274

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

LOG: [lldb][CPlusPlus] Add abi_tag support to the CPlusPlusNameParser

This patch teaches the `CPlusPlusNameParser` to parse the
demangled/prettified [[gnu::abi_tag(...)]] attribute. The demangled format
isn't standardized and the additions to the parser were mainly driven
using Clang (and the limited information on this from the official
Clang docs).

This change is motivated by multiple failures around step-in
behaviour for libcxx APIs (many of which have ABI tags as of recently).
LLDB determines whether the `step-avoid-regexp` matches the current
frame by parsing the scope-qualified name out of the demangled
function symbol. On failure, the `CPlusPlusNameParser` will simply
return the fully demangled name (which can include the return type)
to the caller, which in `FrameMatchesAvoidCriteria` means we will
not correctly decide whether we should stop at a frame or not if
the function has an abi_tag.

Ideally we wouldn't want to rely on the non-standard format
of demangled attributes. Alternatives would be:

1. Use the mangle tree API to do the parsing for us
2. Reconstruct the scope-qualified name from DWARF instead of parsing
   the demangled name

(1) isn't feasible without a significant refactor of `lldb_private::Mangled`,
if we want to do this efficiently.

(2) could be feasible in cases where debug-info for a frame is
available. But it does mean we certain operations (such as step-in regexp,
and frame function names) won't work with/won't show ABI tags.

**Testing**

* Un-XFAILed step-in API test
* Added parser unit-tests

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

Added: 


Modified: 
lldb/source/Plugins/Language/CPlusPlus/CPlusPlusNameParser.cpp
lldb/source/Plugins/Language/CPlusPlus/CPlusPlusNameParser.h
lldb/test/API/functionalities/step-avoids-regexp/TestStepAvoidsRegexp.py
lldb/test/API/functionalities/step-avoids-regexp/main.cpp
lldb/unittests/Language/CPlusPlus/CPlusPlusLanguageTest.cpp

Removed: 




diff  --git a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusNameParser.cpp 
b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusNameParser.cpp
index ac70226ca2a4d..427e5190846d0 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusNameParser.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusNameParser.cpp
@@ -226,9 +226,15 @@ bool CPlusPlusNameParser::ConsumeTemplateArgs() {
   Advance();
   break;
 case tok::l_square:
-  if (!ConsumeBrackets(tok::l_square, tok::r_square))
+  // Handle templates tagged with an ABI tag.
+  // An example demangled/prettified version is:
+  //   func[abi:tag1][abi:tag2](int)
+  if (ConsumeAbiTag())
+can_open_template = true;
+  else if (ConsumeBrackets(tok::l_square, tok::r_square))
+can_open_template = false;
+  else
 return false;
-  can_open_template = false;
   break;
 case tok::l_paren:
   if (!ConsumeArguments())
@@ -249,6 +255,32 @@ bool CPlusPlusNameParser::ConsumeTemplateArgs() {
   return true;
 }
 
+bool CPlusPlusNameParser::ConsumeAbiTag() {
+  Bookmark start_position = SetBookmark();
+  if (!ConsumeToken(tok::l_square))
+return false;
+
+  if (HasMoreTokens() && Peek().is(tok::raw_identifier) &&
+  Peek().getRawIdentifier() == "abi")
+Advance();
+  else
+return false;
+
+  if (!ConsumeToken(tok::colon))
+return false;
+
+  // Consume the actual tag string (and allow some special characters)
+  while (ConsumeToken(tok::raw_identifier, tok::comma, tok::period,
+  tok::numeric_constant))
+;
+
+  if (!ConsumeToken(tok::r_square))
+return false;
+
+  start_position.Remove();
+  return true;
+}
+
 bool CPlusPlusNameParser::ConsumeAnonymousNamespace() {
   Bookmark start_position = SetBookmark();
   if (!ConsumeToken(tok::l_paren)) {
@@ -519,6 +551,22 @@ CPlusPlusNameParser::ParseFullNameImpl() {
   Advance();
   state = State::AfterIdentifier;
   break;
+case tok::l_square: {
+  // Handles types or functions that were tagged
+  // with, e.g.,
+  //   [[gnu::abi_tag("tag1","tag2")]] func()
+  // and demangled/prettified into:
+  //   func[abi:tag1][abi:tag2]()
+
+  // ABI tags only appear after a method or type name
+  const bool valid_state =
+  state == State::AfterIdentifier || state == State::AfterOperator;
+  if (!valid_state || !ConsumeAbiTag()) {
+continue_parsing = false;
+  }
+
+  break;
+}
 case tok::l_paren: {
   if (state == State::Beginning || state == State::AfterTwoColons) {
 // (anonymous namespace)

[Lldb-commits] [PATCH] D136306: [lldb][CPlusPlus] Add abi_tag support to the CPlusPlusNameParser

2022-10-21 Thread Michael Buch via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG3cc9884500ad: [lldb][CPlusPlus] Add abi_tag support to the 
CPlusPlusNameParser (authored by Michael137).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136306

Files:
  lldb/source/Plugins/Language/CPlusPlus/CPlusPlusNameParser.cpp
  lldb/source/Plugins/Language/CPlusPlus/CPlusPlusNameParser.h
  lldb/test/API/functionalities/step-avoids-regexp/TestStepAvoidsRegexp.py
  lldb/test/API/functionalities/step-avoids-regexp/main.cpp
  lldb/unittests/Language/CPlusPlus/CPlusPlusLanguageTest.cpp

Index: lldb/unittests/Language/CPlusPlus/CPlusPlusLanguageTest.cpp
===
--- lldb/unittests/Language/CPlusPlus/CPlusPlusLanguageTest.cpp
+++ lldb/unittests/Language/CPlusPlus/CPlusPlusLanguageTest.cpp
@@ -114,13 +114,74 @@
   {"llvm::Optional::operator*() const volatile &&",
"llvm::Optional", "operator*", "()",
"const volatile &&", "llvm::Optional::operator*"},
+  {"void foo>()", "", "foo>", "()", "",
+   "foo>"},
 
   // auto return type
   {"auto std::test_return_auto() const", "std",
"test_return_auto", "()", "const", "std::test_return_auto"},
   {"decltype(auto) std::test_return_auto(int) const", "std",
-   "test_return_auto", "(int)", "const",
-   "std::test_return_auto"}};
+   "test_return_auto", "(int)", "const", "std::test_return_auto"},
+
+  // abi_tag on class method
+  {"v1::v2::Dummy[abi:c1][abi:c2]> "
+   "v1::v2::Dummy[abi:c1][abi:c2]>"
+   "::method2>>(int, v1::v2::Dummy) const &&",
+   // Context
+   "v1::v2::Dummy[abi:c1][abi:c2]>",
+   // Basename
+   "method2>>",
+   // Args, qualifiers
+   "(int, v1::v2::Dummy)", "const &&",
+   // Full scope-qualified name without args
+   "v1::v2::Dummy[abi:c1][abi:c2]>"
+   "::method2>>"},
+
+  // abi_tag on free function and template argument
+  {"v1::v2::Dummy[abi:c1][abi:c2]> "
+   "v1::v2::with_tag_in_ns[abi:f1][abi:f2]>>(int, v1::v2::Dummy) const "
+   "&&",
+   // Context
+   "v1::v2",
+   // Basename
+   "with_tag_in_ns[abi:f1][abi:f2]>>",
+   // Args, qualifiers
+   "(int, v1::v2::Dummy)", "const &&",
+   // Full scope-qualified name without args
+   "v1::v2::with_tag_in_ns[abi:f1][abi:f2]>>"},
+
+  // abi_tag with special characters
+  {"auto ns::with_tag_in_ns[abi:special tag,0.0][abi:special "
+   "tag,1.0]>"
+   "(float) const &&",
+   // Context
+   "ns",
+   // Basename
+   "with_tag_in_ns[abi:special tag,0.0][abi:special tag,1.0]>",
+   // Args, qualifiers
+   "(float)", "const &&",
+   // Full scope-qualified name without args
+   "ns::with_tag_in_ns[abi:special tag,0.0][abi:special "
+   "tag,1.0]>"},
+
+  // abi_tag on operator overloads
+  {"std::__1::error_code::operator bool[abi:v16]() const",
+   "std::__1::error_code", "operator bool[abi:v16]", "()", "const",
+   "std::__1::error_code::operator bool[abi:v16]"},
+
+  {"auto ns::foo::operator[][abi:v16](size_t) const", "ns::foo",
+   "operator[][abi:v16]", "(size_t)", "const",
+   "ns::foo::operator[][abi:v16]"},
+
+  {"auto Foo[abi:abc]::operator<<>(int) &",
+   "Foo[abi:abc]", "operator<<>", "(int)", "&",
+   "Foo[abi:abc]::operator<<>"}};
 
   for (const auto &test : test_cases) {
 CPlusPlusLanguage::MethodName method(ConstString(test.input));
@@ -135,6 +196,30 @@
   }
 }
 
+TEST(CPlusPlusLanguage, InvalidMethodNameParsing) {
+  // Tests that we correctly reject malformed function names
+
+  std::string test_cases[] = {
+  "int Foo::operator[]<[10>()",
+  "Foo::operator bool[10]()",
+  "auto A::operator<=>[abi:tag]()",
+  "auto A::operator<<<(int)",
+  "auto A::operator>>>(int)",
+  "auto A::operator<<(int)",
+  "auto A::operator<<>(int)",
+  "auto A::foo[(int)",
+  "auto A::foo[](int)",
+  "auto A::foo[bar](int)",
+  "auto A::foo[abi](int)",
+  "auto A::foo[abi:(int)",
+  };
+
+  for (const auto &name : test_cases) {
+CPlusPlusLanguage::MethodName method{ConstString(name)};
+EXPECT_FALSE(method.IsValid()) << name;
+  }
+}
+
 TEST(CPlusPlusLanguage, ContainsPath) {
   CPlusPlusLanguage::MethodName 
   reference_1(ConstString("int foo::bar::func01(int a, double b)"));
Index: lldb/test/API/functionalities/step-avoids-regexp/main.cpp
===
--- lldb/test/API/functionalities/step-avoids-regexp/main.cpp
+++ lldb/test/API/functionalities/step-avoids-regexp/main.cpp
@@ -1,4 +1,6 @@
 namespace ignore {
+struct Dummy {};
+
 template  auto auto_ret(T x) { return 0; }
 [[gnu::abi_tag("test")]] int with_tag() { return 0; }
 template  [[gnu::abi_tag("test")]] int with_tag_tem

[Lldb-commits] [PATCH] D136462: [LLDB] Add color to output text when searching for symbols

2022-10-21 Thread Varun Kumar E via Phabricator via lldb-commits
varunkumare99 created this revision.
varunkumare99 added a reviewer: DavidSpickett.
Herald added a project: All.
varunkumare99 requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

added support for colored output for the commands

1. image lookup -r -s 
2. image lookup -r -n 

For option (1) lookupSymbolInModule(CommandObjectTarget.cpp) is called. We 
first match the regex against the symbol names. Then update the
name(Symbol Demangled name) with colored matches. So that the symbol when 
displayed down the line(in SymbolContext.DumpStopContext) is printed
with colored text. Once the symbols are displayed, we restore the original 
symbols names.(Symbol Demangled name)

For option (2) lookupfunctionInModule(CommandObjectTarget.cpp) is called. As 
the symbol names are accessed in Module.cpp we repeat the
above process in it.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D136462

Files:
  lldb/include/lldb/Core/Module.h
  lldb/include/lldb/Symbol/Symbol.h
  lldb/include/lldb/Symbol/Symtab.h
  lldb/source/Commands/CommandObjectTarget.cpp
  lldb/source/Core/Module.cpp
  lldb/source/Symbol/Symbol.cpp
  lldb/source/Symbol/Symtab.cpp

Index: lldb/source/Symbol/Symtab.cpp
===
--- lldb/source/Symbol/Symtab.cpp
+++ lldb/source/Symbol/Symtab.cpp
@@ -742,6 +742,34 @@
   return indexes.size();
 }
 
+uint32_t Symtab::AppendSymbolIndexesMatchingRegExWithMatchesAndType(
+Stream &strm, const RegularExpression ®exp, SymbolType symbol_type,
+std::vector &indexes,
+llvm::SmallVector<
+std::pair>>
+&allMatches,
+Mangled::NamePreference name_preference) const {
+  std::lock_guard guard(m_mutex);
+  uint32_t prev_size = indexes.size();
+  uint32_t sym_end = m_symbols.size();
+
+  for (uint32_t i = 0; i < sym_end; i++) {
+llvm::SmallVector matches;
+if (symbol_type == eSymbolTypeAny ||
+m_symbols[i].GetType() == symbol_type) {
+  const char *name =
+  m_symbols[i].GetMangled().GetName(name_preference).AsCString();
+  if (name) {
+if (regexp.Execute(name, &matches)) {
+  allMatches.push_back(std::make_pair(name, matches));
+  indexes.push_back(i);
+}
+  }
+}
+  }
+  return indexes.size() - prev_size;
+}
+
 uint32_t Symtab::AppendSymbolIndexesMatchingRegExAndType(
 const RegularExpression ®exp, SymbolType symbol_type,
 std::vector &indexes, Mangled::NamePreference name_preference) {
@@ -764,6 +792,39 @@
   return indexes.size() - prev_size;
 }
 
+uint32_t Symtab::AppendSymbolIndexesMatchingRegExWithMatchesAndType(
+const RegularExpression ®exp, SymbolType symbol_type,
+Debug symbol_debug_type, Visibility symbol_visibility,
+std::vector &indexes,
+llvm::SmallVector<
+std::pair>>
+&allMatches,
+Mangled::NamePreference name_preference) {
+  std::lock_guard guard(m_mutex);
+
+  uint32_t prev_size = indexes.size();
+  uint32_t sym_end = m_symbols.size();
+
+  for (uint32_t i = 0; i < sym_end; i++) {
+llvm::SmallVector matches;
+if (symbol_type == eSymbolTypeAny ||
+m_symbols[i].GetType() == symbol_type) {
+  if (!CheckSymbolAtIndex(i, symbol_debug_type, symbol_visibility))
+continue;
+
+  const char *name =
+  m_symbols[i].GetMangled().GetName(name_preference).AsCString();
+  if (name) {
+if (regexp.Execute(name, &matches)) {
+  indexes.push_back(i);
+  allMatches.push_back(std::make_pair(name, matches));
+}
+  }
+}
+  }
+  return indexes.size() - prev_size;
+}
+
 uint32_t Symtab::AppendSymbolIndexesMatchingRegExAndType(
 const RegularExpression ®exp, SymbolType symbol_type,
 Debug symbol_debug_type, Visibility symbol_visibility,
Index: lldb/source/Symbol/Symbol.cpp
===
--- lldb/source/Symbol/Symbol.cpp
+++ lldb/source/Symbol/Symbol.cpp
@@ -122,6 +122,10 @@
   return GetMangled().GetDisplayDemangledName();
 }
 
+void Symbol::SetName(llvm::StringRef name) {
+  m_mangled.SetDemangledName(ConstString(name));
+}
+
 ConstString Symbol::GetReExportedSymbolName() const {
   if (m_type == eSymbolTypeReExported) {
 // For eSymbolTypeReExported, the "const char *" from a ConstString is used
Index: lldb/source/Core/Module.cpp
===
--- lldb/source/Core/Module.cpp
+++ lldb/source/Core/Module.cpp
@@ -38,6 +38,7 @@
 #include "lldb/Target/Language.h"
 #include "lldb/Target/Process.h"
 #include "lldb/Target/Target.h"
+#include "lldb/Utility/AnsiTerminal.h"
 #include "lldb/Utility/DataBufferHeap.h"
 #include "lldb/Utility/LLDBAssert.h"
 #include "lldb/Utility/LLDBLog.h"
@@ -856,6 +857,135 @@
   }
 }
 
+bool Module::isColor(size_t pos,
+ llvm::SmallVector> &positions) {
+  for (size_t i = 0; i < positions.size(); ++i) {
+if (pos >= po

[Lldb-commits] [PATCH] D136465: Make remote-android local ports configurable

2022-10-21 Thread Luka Markušić via Phabricator via lldb-commits
mark2185 created this revision.
Herald added a subscriber: danielkiss.
Herald added a project: All.
mark2185 requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

The local ports for `platform connect` and `attach` were always random, this 
allows the user to configure them.
This is useful for debugging a truly remote android (when the android in 
question is connected to a remote server).


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D136465

Files:
  lldb/docs/use/remote.rst
  lldb/source/Plugins/Platform/Android/PlatformAndroidRemoteGDBServer.cpp
  lldb/source/Plugins/Platform/Android/PlatformAndroidRemoteGDBServer.h

Index: lldb/source/Plugins/Platform/Android/PlatformAndroidRemoteGDBServer.h
===
--- lldb/source/Plugins/Platform/Android/PlatformAndroidRemoteGDBServer.h
+++ lldb/source/Plugins/Platform/Android/PlatformAndroidRemoteGDBServer.h
@@ -49,7 +49,8 @@
 
   void DeleteForwardPort(lldb::pid_t pid);
 
-  Status MakeConnectURL(const lldb::pid_t pid, const uint16_t remote_port,
+  Status MakeConnectURL(const lldb::pid_t pid, const uint16_t local_port,
+const uint16_t remote_port,
 llvm::StringRef remote_socket_name,
 std::string &connect_url);
 
Index: lldb/source/Plugins/Platform/Android/PlatformAndroidRemoteGDBServer.cpp
===
--- lldb/source/Plugins/Platform/Android/PlatformAndroidRemoteGDBServer.cpp
+++ lldb/source/Plugins/Platform/Android/PlatformAndroidRemoteGDBServer.cpp
@@ -90,8 +90,14 @@
 
   Log *log = GetLog(LLDBLog::Platform);
 
-  auto error =
-  MakeConnectURL(pid, remote_port, socket_name.c_str(), connect_url);
+  uint16_t local_port = 0;
+  const char *gdbstub_port = std::getenv("ANDROID_PLATFORM_LOCAL_GDB_PORT");
+  if (gdbstub_port) {
+local_port = std::stoi(gdbstub_port);
+  }
+
+  auto error = MakeConnectURL(pid, local_port, remote_port, socket_name.c_str(),
+  connect_url);
   if (error.Success() && log)
 LLDB_LOGF(log, "gdbserver connect URL: %s", connect_url.c_str());
 
@@ -126,10 +132,16 @@
   else if (parsed_url->scheme == "unix-abstract-connect")
 m_socket_namespace = AdbClient::UnixSocketNamespaceAbstract;
 
+  uint16_t local_port = 0;
+  const char *platform_local_port = std::getenv("ANDROID_PLATFORM_LOCAL_PORT");
+  if (platform_local_port) {
+local_port = std::stoi(platform_local_port);
+  }
+
   std::string connect_url;
-  auto error =
-  MakeConnectURL(g_remote_platform_pid, parsed_url->port.value_or(0),
- parsed_url->path, connect_url);
+  auto error = MakeConnectURL(g_remote_platform_pid, local_port,
+  parsed_url->port.value_or(0), parsed_url->path,
+  connect_url);
 
   if (error.Fail())
 return error;
@@ -170,11 +182,29 @@
 }
 
 Status PlatformAndroidRemoteGDBServer::MakeConnectURL(
-const lldb::pid_t pid, const uint16_t remote_port,
-llvm::StringRef remote_socket_name, std::string &connect_url) {
+const lldb::pid_t pid, const uint16_t local_port,
+const uint16_t remote_port, llvm::StringRef remote_socket_name,
+std::string &connect_url) {
   static const int kAttempsNum = 5;
 
   Status error;
+
+  auto forward = [&](const uint16_t local, const uint16_t remote) {
+error = ForwardPortWithAdb(local, remote, remote_socket_name,
+   m_socket_namespace, m_device_id);
+if (error.Success()) {
+  m_port_forwards[pid] = local;
+  std::ostringstream url_str;
+  url_str << "connect://127.0.0.1:" << local;
+  connect_url = url_str.str();
+}
+return error;
+  };
+
+  if (local_port != 0) {
+return forward(local_port, remote_port);
+  }
+
   // There is a race possibility that somebody will occupy a port while we're
   // in between FindUnusedPort and ForwardPortWithAdb - adding the loop to
   // mitigate such problem.
@@ -184,13 +214,7 @@
 if (error.Fail())
   return error;
 
-error = ForwardPortWithAdb(local_port, remote_port, remote_socket_name,
-   m_socket_namespace, m_device_id);
-if (error.Success()) {
-  m_port_forwards[pid] = local_port;
-  std::ostringstream url_str;
-  url_str << "connect://127.0.0.1:" << local_port;
-  connect_url = url_str.str();
+if (forward(local_port, remote_port).Success()) {
   break;
 }
   }
@@ -216,7 +240,7 @@
   }
 
   std::string new_connect_url;
-  error = MakeConnectURL(s_remote_gdbserver_fake_pid--,
+  error = MakeConnectURL(s_remote_gdbserver_fake_pid--, 0,
  parsed_url->port.value_or(0), parsed_url->path,
  new_connect_url);
   if (error.Fail())
Index: lldb/docs/use/remote.rst
=

[Lldb-commits] [PATCH] D135621: [lldb] Add an always-on log channel

2022-10-21 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere updated this revision to Diff 469677.
JDevlieghere added a comment.

- Address code review feedback


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

https://reviews.llvm.org/D135621

Files:
  lldb/include/lldb/Utility/Diagnostics.h
  lldb/include/lldb/Utility/Log.h
  lldb/source/Utility/Diagnostics.cpp
  lldb/source/Utility/Log.cpp
  lldb/test/Shell/Diagnostics/TestLogChannel.test

Index: lldb/test/Shell/Diagnostics/TestLogChannel.test
===
--- /dev/null
+++ lldb/test/Shell/Diagnostics/TestLogChannel.test
@@ -0,0 +1,2 @@
+# RUN: %lldb -o 'log list' 2>&1 | FileCheck %s
+# CHECK-NOT: Logging categories for 'diagnostics'
Index: lldb/source/Utility/Log.cpp
===
--- lldb/source/Utility/Log.cpp
+++ lldb/source/Utility/Log.cpp
@@ -283,8 +283,10 @@
 
 std::vector Log::ListChannels() {
   std::vector result;
-  for (const auto &channel : *g_channel_map)
-result.push_back(channel.first());
+  for (const auto &entry : *g_channel_map) {
+if (!entry.second.m_channel.internal)
+  result.push_back(entry.first());
+  }
   return result;
 }
 
@@ -294,8 +296,10 @@
 return;
   }
 
-  for (const auto &channel : *g_channel_map)
-ListCategories(stream, channel);
+  for (const auto &entry : *g_channel_map) {
+if (!entry.second.m_channel.internal)
+  ListCategories(stream, entry);
+  }
 }
 
 bool Log::GetVerbose() const {
Index: lldb/source/Utility/Diagnostics.cpp
===
--- lldb/source/Utility/Diagnostics.cpp
+++ lldb/source/Utility/Diagnostics.cpp
@@ -17,7 +17,27 @@
 using namespace lldb;
 using namespace llvm;
 
+static constexpr size_t g_num_log_messages = 100;
+
+static constexpr Log::Category g_categories[] = {
+{{"lldb"}, {"diagnostics log for lldb"}, DiagnosticsLog::LLDB},
+};
+
+static Log::Channel g_channel(g_categories, DiagnosticsLog::LLDB,
+  /*internal=*/true);
+
+template <> Log::Channel &lldb_private::LogChannelFor() {
+  return g_channel;
+}
+
+void LogChannelDiagnostics::Initialize() {
+  Log::Register("diagnostics", g_channel);
+}
+
+void LogChannelDiagnostics::Terminate() { Log::Unregister("diagnostics"); }
+
 void Diagnostics::Initialize() {
+  LogChannelDiagnostics::Initialize();
   lldbassert(!InstanceImpl() && "Already initialized.");
   InstanceImpl().emplace();
 }
@@ -25,6 +45,7 @@
 void Diagnostics::Terminate() {
   lldbassert(InstanceImpl() && "Already terminated.");
   InstanceImpl().reset();
+  LogChannelDiagnostics::Terminate();
 }
 
 Optional &Diagnostics::InstanceImpl() {
@@ -34,9 +55,18 @@
 
 Diagnostics &Diagnostics::Instance() { return *InstanceImpl(); }
 
-Diagnostics::Diagnostics() {}
+Diagnostics::Diagnostics()
+: m_always_on_log_handler(
+  std::make_shared(g_num_log_messages)) {
+  const uint32_t log_options = LLDB_LOG_OPTION_PREPEND_THREAD_NAME;
+  Log::EnableLogChannel(m_always_on_log_handler, log_options, "diagnostics",
+{"all"}, llvm::nulls());
+  AddCallback([&](const FileSpec &dir) { return DumpAlwaysOnLog(dir); });
+}
 
-Diagnostics::~Diagnostics() {}
+Diagnostics::~Diagnostics() {
+  Log::DisableLogChannel("diagnostics", {"all"}, llvm::nulls());
+}
 
 void Diagnostics::AddCallback(Callback callback) {
   std::lock_guard guard(m_callbacks_mutex);
@@ -66,9 +96,22 @@
 }
 
 Error Diagnostics::Create(const FileSpec &dir) {
+  LLDB_LOG(GetLog(DiagnosticsLog::LLDB), "Dumping {0} diagnostics to '{1}'",
+   m_callbacks.size(), dir.GetPath());
+
   for (Callback c : m_callbacks) {
 if (Error err = c(dir))
   return err;
   }
   return Error::success();
 }
+
+llvm::Error Diagnostics::DumpAlwaysOnLog(const FileSpec &dir) const {
+  FileSpec log_file = dir.CopyByAppendingPathComponent("always-on.log");
+  std::error_code ec;
+  llvm::raw_fd_ostream stream(log_file.GetPath(), ec, llvm::sys::fs::OF_None);
+  if (ec)
+return errorCodeToError(ec);
+  m_always_on_log_handler->Dump(stream);
+  return Error::success();
+}
Index: lldb/include/lldb/Utility/Log.h
===
--- lldb/include/lldb/Utility/Log.h
+++ lldb/include/lldb/Utility/Log.h
@@ -150,12 +150,13 @@
   public:
 const llvm::ArrayRef categories;
 const MaskType default_flags;
+const bool internal = false;
 
 template 
 constexpr Channel(llvm::ArrayRef categories,
-  Cat default_flags)
+  Cat default_flags, bool internal = false)
 : log_ptr(nullptr), categories(categories),
-  default_flags(MaskType(default_flags)) {
+  default_flags(MaskType(default_flags)), internal(internal) {
   static_assert(
   std::is_same>::value);
 }
@@ -341,6 +342,14 @@
   log_private->Format(__FILE__, __func__, __VA_ARGS__);\
   } while (0)
 
+#define LLDB

[Lldb-commits] [PATCH] D135621: [lldb] Add an always-on log channel

2022-10-21 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere added a comment.

In D135621#3850248 , @clayborg wrote:

> I am also questioning if the these even belong in the LLDB logging stuff? 
> Seems like it would be just as easy to create a diagnostic message by calling 
> Diagnostics::Report(...). Do we really want to modify the log channels here? 
> Seems like always on diagnostics should just a dedicated API.

I expect the majority of places where we want to log to the diagnostic log 
channel to be places where we already log today. It being a its own log channel 
complicates that somewhat, because unlike categories you can't do 
`GetLog(LLDB::Expression | Diagnostics::Expression)`. That's still pretty 
important to us, so I've added two more macros that allow you to specify 
multiple log channels to achieve a somewhat similar result:

  LOG_MULTI_PRINTF(GetLog(LLDBLog::Expression), GetLog(Diagnostics::Foo), "%s", 
foo)

Similarly, I also plan to change `LLDB_LOG_ERROR` to always log to the 
diagnostic channel. I didn't include it in this patch as it requires moving the 
macro in the diagnostics header and generates a lot of churn.


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

https://reviews.llvm.org/D135621

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


[Lldb-commits] [lldb] 9b809cc - [LLDB][NativePDB] Improve ParseDeclsForContext time.

2022-10-21 Thread Zequan Wu via lldb-commits

Author: Zequan Wu
Date: 2022-10-21T10:33:16-07:00
New Revision: 9b809cc5b69a45601910bf4c60a2ece2f5462a18

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

LOG: [LLDB][NativePDB] Improve ParseDeclsForContext time.

1. When we evaluating an expression multiple times and the searching scope is 
translation unit, ParseDeclsForContext iterates the type info and symbol info 
multiple times, though only the debug info is parsed once. Using 
llvm::call_once to make it only iterating and parsing once.

2. When evaluating an expression with identifier whose parent scope is a 
namespace, ParseDeclsForContext needs to search the entire type info to 
complete those records whose name is prefixed with the namespace's name and the 
entire symbol info to to parse functions and non-local variables. Caching 
parsed namespaces to avoid unnecessary searching.

Reviewed By: labath

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

Added: 


Modified: 
lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp
lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.h

Removed: 




diff  --git a/lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp 
b/lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp
index fb27d0ae05c3..90684cf56a1e 100644
--- a/lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp
+++ b/lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp
@@ -21,7 +21,6 @@
 #include "lldb/Core/Module.h"
 #include "lldb/Symbol/ObjectFile.h"
 #include "lldb/Utility/LLDBAssert.h"
-
 #include "PdbUtil.h"
 #include "UdtRecordCompleter.h"
 #include "SymbolFileNativePDB.h"
@@ -1232,8 +1231,11 @@ static bool isBlockDecl(clang::DeclContext &context) {
   return llvm::isa(&context);
 }
 
-void PdbAstBuilder::ParseAllNamespacesPlusChildrenOf(
-llvm::Optional parent) {
+void PdbAstBuilder::ParseNamespace(clang::DeclContext &context) {
+  clang::NamespaceDecl *ns = llvm::dyn_cast(&context);
+  if (m_parsed_namespaces.contains(ns))
+return;
+  std::string qname = ns->getQualifiedNameAsString();
   SymbolFileNativePDB *pdb = static_cast(
   m_clang.GetSymbolFile()->GetBackingSymbolFile());
   PdbIndex &index = pdb->GetIndex();
@@ -1247,12 +1249,6 @@ void PdbAstBuilder::ParseAllNamespacesPlusChildrenOf(
 
 CVTagRecord tag = CVTagRecord::create(cvt);
 
-if (!parent) {
-  clang::QualType qt = GetOrCreateType(tid);
-  CompleteType(qt);
-  continue;
-}
-
 // Call CreateDeclInfoForType unconditionally so that the namespace info
 // gets created.  But only call CreateRecordType if the namespace name
 // matches.
@@ -1263,41 +1259,68 @@ void PdbAstBuilder::ParseAllNamespacesPlusChildrenOf(
   continue;
 
 clang::NamespaceDecl *ns = llvm::cast(context);
-std::string actual_ns = ns->getQualifiedNameAsString();
-if (llvm::StringRef(actual_ns).startswith(*parent)) {
-  clang::QualType qt = GetOrCreateType(tid);
-  CompleteType(qt);
-  continue;
+llvm::StringRef ns_name = ns->getName();
+if (ns_name.startswith(qname)) {
+  ns_name = ns_name.drop_front(qname.size());
+  if (ns_name.startswith("::"))
+GetOrCreateType(tid);
 }
   }
+  ParseAllFunctionsAndNonLocalVars();
+  m_parsed_namespaces.insert(ns);
+}
 
-  uint32_t module_count = index.dbi().modules().getModuleCount();
-  for (uint16_t modi = 0; modi < module_count; ++modi) {
-CompilandIndexItem &cii = index.compilands().GetOrCreateCompiland(modi);
-const CVSymbolArray &symbols = cii.m_debug_stream.getSymbolArray();
-auto iter = symbols.begin();
-while (iter != symbols.end()) {
-  PdbCompilandSymId sym_id{modi, iter.offset()};
-
-  switch (iter->kind()) {
-  case S_GPROC32:
-  case S_LPROC32:
-GetOrCreateFunctionDecl(sym_id);
-iter = symbols.at(getScopeEndOffset(*iter));
-break;
-  case S_GDATA32:
-  case S_GTHREAD32:
-  case S_LDATA32:
-  case S_LTHREAD32:
-GetOrCreateVariableDecl(PdbCompilandSymId(modi, 0), sym_id);
-++iter;
-break;
-  default:
-++iter;
+void PdbAstBuilder::ParseAllTypes() {
+  llvm::call_once(m_parse_all_types, [this]() {
+SymbolFileNativePDB *pdb = static_cast(
+m_clang.GetSymbolFile()->GetBackingSymbolFile());
+PdbIndex &index = pdb->GetIndex();
+TypeIndex ti{index.tpi().TypeIndexBegin()};
+for (const CVType &cvt : index.tpi().typeArray()) {
+  PdbTypeSymId tid{ti};
+  ++ti;
+
+  if (!IsTagRecord(cvt))
 continue;
+
+  GetOrCreateType(tid);
+}
+  });
+}
+
+void PdbAstBuilder::ParseAllFunctionsAndNonLocalVars() {
+  llvm::call_once(m_parse_functions_and_non_local_vars, [this]() {
+SymbolFileNativePDB *pdb = static_cast(
+m_clang.GetSymbolFile()->Ge

[Lldb-commits] [PATCH] D136006: [LLDB][NativePDB] Improve ParseDeclsForContext time.

2022-10-21 Thread Zequan Wu via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG9b809cc5b69a: [LLDB][NativePDB] Improve ParseDeclsForContext 
time. (authored by zequanwu).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136006

Files:
  lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp
  lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.h

Index: lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.h
===
--- lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.h
+++ lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.h
@@ -11,6 +11,7 @@
 
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/StringRef.h"
+#include "llvm/Support/Threading.h"
 
 #include "Plugins/ExpressionParser/Clang/ClangASTImporter.h"
 
@@ -122,7 +123,9 @@
  TypeIndex func_ti, CompilerType func_ct,
  uint32_t param_count, clang::StorageClass func_storage,
  bool is_inline, clang::DeclContext *parent);
-  void ParseAllNamespacesPlusChildrenOf(llvm::Optional parent);
+  void ParseNamespace(clang::DeclContext &parent);
+  void ParseAllTypes();
+  void ParseAllFunctionsAndNonLocalVars();
   void ParseDeclsForSimpleContext(clang::DeclContext &context);
   void ParseBlockChildren(PdbCompilandSymId block_id);
 
@@ -135,7 +138,8 @@
   TypeSystemClang &m_clang;
 
   ClangASTImporter m_importer;
-
+  llvm::once_flag m_parse_functions_and_non_local_vars;
+  llvm::once_flag m_parse_all_types;
   llvm::DenseMap m_decl_to_status;
   llvm::DenseMap m_uid_to_decl;
   llvm::DenseMap m_uid_to_type;
@@ -145,6 +149,7 @@
   llvm::DenseMap, 8>>
   m_cxx_record_map;
+  llvm::DenseSet m_parsed_namespaces;
 };
 
 } // namespace npdb
Index: lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp
===
--- lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp
+++ lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp
@@ -21,7 +21,6 @@
 #include "lldb/Core/Module.h"
 #include "lldb/Symbol/ObjectFile.h"
 #include "lldb/Utility/LLDBAssert.h"
-
 #include "PdbUtil.h"
 #include "UdtRecordCompleter.h"
 #include "SymbolFileNativePDB.h"
@@ -1232,8 +1231,11 @@
   return llvm::isa(&context);
 }
 
-void PdbAstBuilder::ParseAllNamespacesPlusChildrenOf(
-llvm::Optional parent) {
+void PdbAstBuilder::ParseNamespace(clang::DeclContext &context) {
+  clang::NamespaceDecl *ns = llvm::dyn_cast(&context);
+  if (m_parsed_namespaces.contains(ns))
+return;
+  std::string qname = ns->getQualifiedNameAsString();
   SymbolFileNativePDB *pdb = static_cast(
   m_clang.GetSymbolFile()->GetBackingSymbolFile());
   PdbIndex &index = pdb->GetIndex();
@@ -1247,12 +1249,6 @@
 
 CVTagRecord tag = CVTagRecord::create(cvt);
 
-if (!parent) {
-  clang::QualType qt = GetOrCreateType(tid);
-  CompleteType(qt);
-  continue;
-}
-
 // Call CreateDeclInfoForType unconditionally so that the namespace info
 // gets created.  But only call CreateRecordType if the namespace name
 // matches.
@@ -1263,41 +1259,68 @@
   continue;
 
 clang::NamespaceDecl *ns = llvm::cast(context);
-std::string actual_ns = ns->getQualifiedNameAsString();
-if (llvm::StringRef(actual_ns).startswith(*parent)) {
-  clang::QualType qt = GetOrCreateType(tid);
-  CompleteType(qt);
-  continue;
+llvm::StringRef ns_name = ns->getName();
+if (ns_name.startswith(qname)) {
+  ns_name = ns_name.drop_front(qname.size());
+  if (ns_name.startswith("::"))
+GetOrCreateType(tid);
 }
   }
+  ParseAllFunctionsAndNonLocalVars();
+  m_parsed_namespaces.insert(ns);
+}
 
-  uint32_t module_count = index.dbi().modules().getModuleCount();
-  for (uint16_t modi = 0; modi < module_count; ++modi) {
-CompilandIndexItem &cii = index.compilands().GetOrCreateCompiland(modi);
-const CVSymbolArray &symbols = cii.m_debug_stream.getSymbolArray();
-auto iter = symbols.begin();
-while (iter != symbols.end()) {
-  PdbCompilandSymId sym_id{modi, iter.offset()};
-
-  switch (iter->kind()) {
-  case S_GPROC32:
-  case S_LPROC32:
-GetOrCreateFunctionDecl(sym_id);
-iter = symbols.at(getScopeEndOffset(*iter));
-break;
-  case S_GDATA32:
-  case S_GTHREAD32:
-  case S_LDATA32:
-  case S_LTHREAD32:
-GetOrCreateVariableDecl(PdbCompilandSymId(modi, 0), sym_id);
-++iter;
-break;
-  default:
-++iter;
+void PdbAstBuilder::ParseAllTypes() {
+  llvm::call_once(m_parse_all_types, [this]() {
+SymbolFileNativePDB *pdb = static_cast(
+m_clang.GetSymbolFile()->GetBackingSymbolFile());
+PdbIndex &index = pdb->GetIndex();
+TypeIndex ti{index.tpi().TypeIndexBegin()};
+for (const CVType &cvt : index.tpi().typeArray()) {
+  PdbTypeSymId tid{ti};

[Lldb-commits] [PATCH] D135621: [lldb] Add an always-on log channel

2022-10-21 Thread Dave Lee via Phabricator via lldb-commits
kastiglione accepted this revision.
kastiglione added a comment.
This revision is now accepted and ready to land.

> I expect the majority of places where we want to log to the diagnostic log 
> channel to be places where we already log today.

This is my expectation too. Some logs are helpful for diagnosing problems, and 
having them already saved makes it easier for users to include info in their 
reports.




Comment at: lldb/source/Utility/Diagnostics.cpp:23
+static constexpr Log::Category g_categories[] = {
+{{"lldb"}, {"diagnostics log for lldb"}, DiagnosticsLog::LLDB},
+};

To me, it's not ideal that there's an "lldb" channel, and this channel has an 
"lldb" category.

Do you have other categories in mind for later updates, that should be moved 
into this patch? For example, will there eventually be "warning" and "error" 
categories? If so, maybe start with those instead of "lldb".


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

https://reviews.llvm.org/D135621

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


[Lldb-commits] [lldb] c9885f7 - [trace][intel pt][simple] Fix TestTraceSave

2022-10-21 Thread Walter Erquinigo via lldb-commits

Author: Walter Erquinigo
Date: 2022-10-21T11:00:55-07:00
New Revision: c9885f74f45510d287ceca034c761f1787a201d9

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

LOG: [trace][intel pt][simple] Fix TestTraceSave

That test was failing due to a wrong else statement. Now it passes.

Added: 


Modified: 
lldb/source/Plugins/Trace/intel-pt/TraceIntelPT.cpp

Removed: 




diff  --git a/lldb/source/Plugins/Trace/intel-pt/TraceIntelPT.cpp 
b/lldb/source/Plugins/Trace/intel-pt/TraceIntelPT.cpp
index 1db34d8fe840d..a732d4df51b83 100644
--- a/lldb/source/Plugins/Trace/intel-pt/TraceIntelPT.cpp
+++ b/lldb/source/Plugins/Trace/intel-pt/TraceIntelPT.cpp
@@ -89,7 +89,7 @@ TraceIntelPTSP TraceIntelPT::CreateInstanceForPostmortemTrace(
   trace_sp->m_storage.tsc_conversion =
   bundle_description.tsc_perf_zero_conversion;
 
-  if (bundle_description.cpus && trace_mode == TraceMode::UserMode) {
+  if (bundle_description.cpus) {
 std::vector cpus;
 
 for (const JSONCpu &cpu : *bundle_description.cpus) {
@@ -102,8 +102,12 @@ TraceIntelPTSP 
TraceIntelPT::CreateInstanceForPostmortemTrace(
   cpus.push_back(cpu.id);
 }
 
-trace_sp->m_storage.multicpu_decoder.emplace(trace_sp);
-  } else {
+if (trace_mode == TraceMode::UserMode) {
+  trace_sp->m_storage.multicpu_decoder.emplace(trace_sp);
+}
+  }
+
+  if (!bundle_description.cpus || trace_mode == TraceMode::KernelMode) {
 for (const ThreadPostMortemTraceSP &thread : traced_threads) {
   trace_sp->m_storage.thread_decoders.try_emplace(
   thread->GetID(), std::make_unique(thread, *trace_sp));



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


[Lldb-commits] [PATCH] D135621: [lldb] Add an always-on log channel

2022-10-21 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere added inline comments.



Comment at: lldb/source/Utility/Diagnostics.cpp:23
+static constexpr Log::Category g_categories[] = {
+{{"lldb"}, {"diagnostics log for lldb"}, DiagnosticsLog::LLDB},
+};

kastiglione wrote:
> To me, it's not ideal that there's an "lldb" channel, and this channel has an 
> "lldb" category.
> 
> Do you have other categories in mind for later updates, that should be moved 
> into this patch? For example, will there eventually be "warning" and "error" 
> categories? If so, maybe start with those instead of "lldb".
Yes, for the errors I was going to add an error category. Maybe we can call 
this one general or something?


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

https://reviews.llvm.org/D135621

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


[Lldb-commits] [PATCH] D131858: [clang] Track the templated entity in type substitution.

2022-10-21 Thread Evgeny Eltsin via Phabricator via lldb-commits
eaeltsin added a comment.

Heads-up - I'm seeing the compilation failure that reduces to this commit. I 
didn't get a reproducer of the reasonable size yet :(

The problem occurs when using modules only.

The module has code like:

  template 
  class A {
   public:
T x;
template 
friend H Helper(H h, const A& a) {
  return H::foo(std::move(h), a.x);
}
  };

Then, when the module client uses `Helper`, we get an error:

  header.h:46:12: error: inline function 'Helper' is not defined 
[-Werror,-Wundefined-inline]

If I move `Helper` definition out of friend declaration:

  template 
  class A {
   public:
T x;
template 
friend H Helper(H h, const A& a);
  };
  
  template 
  H Helper(H h, const A& a) {
return H::foo(std::move(h), a.x);
  }

things compile ok.

Without modules, both versions compile ok.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131858

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