[Lldb-commits] [PATCH] D152210: [lldb][NFCI] Remove use of ConstString from OptionValueProperties

2023-06-08 Thread Felipe de Azevedo Piovezan via Phabricator via lldb-commits
fdeazeve accepted this revision.
fdeazeve added a comment.
This revision is now accepted and ready to land.

LGTM!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152210

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


[Lldb-commits] [PATCH] D152315: [lldb][NFCI] Refactor TypeSystemClang::GetBasicTypeEnumeration

2023-06-08 Thread Felipe de Azevedo Piovezan via Phabricator via lldb-commits
fdeazeve accepted this revision.
fdeazeve added a comment.

LGTM!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152315

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


[Lldb-commits] [PATCH] D152324: [lldb][NFCI] Change return type of PersistentExpressionState::GetNextPersistentVariableName

2023-06-08 Thread Felipe de Azevedo Piovezan via Phabricator via lldb-commits
fdeazeve accepted this revision.
fdeazeve added inline comments.



Comment at: 
lldb/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.cpp:129-134
   llvm::SmallString<64> name;
   {
 llvm::raw_svector_ostream os(name);
 os << GetPersistentVariablePrefix(is_error)
<< m_next_persistent_variable_id++;
   }

JDevlieghere wrote:
> If we're going to return a `std::string`, we might as well use a 
> `raw_string_ostream` and simplify this function. 
+1, we can avoid the conversion of SmallString->std::string (and enable copy 
elision) by declaring `name` as std::string

(we don't necessarily need to do it in this patch though, either way is fine 
IMO)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152324

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


[Lldb-commits] [PATCH] D152449: [lldb][NFC]Update debug (eh-frame) tests to preserve old behaviour.

2023-06-08 Thread Vy Nguyen via Phabricator via lldb-commits
oontvoo created this revision.
oontvoo added a reviewer: fdeazeve.
Herald added a project: All.
oontvoo requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

Details: D144999  potentially changes the 
debug format. Setting this new -femit-compact-unwind-non-canonical flag will 
preserve the old behaviour.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D152449

Files:
  lldb/test/Shell/Unwind/prefer-debug-over-eh-frame.test


Index: lldb/test/Shell/Unwind/prefer-debug-over-eh-frame.test
===
--- lldb/test/Shell/Unwind/prefer-debug-over-eh-frame.test
+++ lldb/test/Shell/Unwind/prefer-debug-over-eh-frame.test
@@ -8,7 +8,7 @@
 # XFAIL: system-darwin
 # REQUIRES: target-x86_64, native
 
-# RUN: %clang_host -g %p/Inputs/call-asm.c 
%p/Inputs/prefer-debug-over-eh-frame.s -o %t
+# RUN: %clang_host -femit-compact-unwind-non-canonical -g %p/Inputs/call-asm.c 
%p/Inputs/prefer-debug-over-eh-frame.s -o %t
 # RUN: %lldb %t -s %s -o exit | FileCheck %s
 
 breakpoint set -n bar


Index: lldb/test/Shell/Unwind/prefer-debug-over-eh-frame.test
===
--- lldb/test/Shell/Unwind/prefer-debug-over-eh-frame.test
+++ lldb/test/Shell/Unwind/prefer-debug-over-eh-frame.test
@@ -8,7 +8,7 @@
 # XFAIL: system-darwin
 # REQUIRES: target-x86_64, native
 
-# RUN: %clang_host -g %p/Inputs/call-asm.c %p/Inputs/prefer-debug-over-eh-frame.s -o %t
+# RUN: %clang_host -femit-compact-unwind-non-canonical -g %p/Inputs/call-asm.c %p/Inputs/prefer-debug-over-eh-frame.s -o %t
 # RUN: %lldb %t -s %s -o exit | FileCheck %s
 
 breakpoint set -n bar
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D151950: [lldb] Unconditionally increment depth when printing children

2023-06-08 Thread Adrian Prantl via Phabricator via lldb-commits
aprantl accepted this revision.
aprantl added inline comments.



Comment at: lldb/source/DataFormatters/ValueObjectPrinter.cpp:610
 
   if (child_sp.get()) {
 ValueObjectPrinter child_printer(

I would probably factor out:
```
if (does_consume_ptr_depth)
   --curr_ptr_depth;
```



Comment at: lldb/test/API/lang/cpp/frame-var-depth-and-elem-count/main.cpp:15
+  C *c = new C[5];
+  return 0; // break here
+}

Setting a breakpoint on the return is risky because there may not be any code 
associated with it. Something like
```
int puts(const char *s);

puts("break here");
```
is safer.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151950

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


[Lldb-commits] [PATCH] D152454: [lldb][test] LogTest: Fix stack overflow

2023-06-08 Thread Michael Buch via Phabricator via lldb-commits
Michael137 created this revision.
Herald added a project: All.
Michael137 requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

The expected function name requires 18 bytes of storage.

Caught by the public ASAN buildbot


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D152454

Files:
  lldb/unittests/Utility/LogTest.cpp


Index: lldb/unittests/Utility/LogTest.cpp
===
--- lldb/unittests/Utility/LogTest.cpp
+++ lldb/unittests/Utility/LogTest.cpp
@@ -309,7 +309,7 @@
   Err));
 llvm::StringRef Msg = logAndTakeOutputf("Hello World");
 char File[12];
-char Function[17];
+char Function[18];
 
 sscanf(Msg.str().c_str(),
"%[^:]:%s Hello World", File,


Index: lldb/unittests/Utility/LogTest.cpp
===
--- lldb/unittests/Utility/LogTest.cpp
+++ lldb/unittests/Utility/LogTest.cpp
@@ -309,7 +309,7 @@
   Err));
 llvm::StringRef Msg = logAndTakeOutputf("Hello World");
 char File[12];
-char Function[17];
+char Function[18];
 
 sscanf(Msg.str().c_str(),
"%[^:]:%s Hello World", File,
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D152454: [lldb][test] LogTest: Fix stack overflow

2023-06-08 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere accepted this revision.
JDevlieghere added a comment.
This revision is now accepted and ready to land.

Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152454

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


[Lldb-commits] [lldb] 9c4c67a - [lldb][test] LogTest: Fix stack overflow

2023-06-08 Thread Michael Buch via lldb-commits

Author: Michael Buch
Date: 2023-06-08T17:10:32+01:00
New Revision: 9c4c67a682f9d9b2cca183fcb9533bf709ffa723

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

LOG: [lldb][test] LogTest: Fix stack overflow

The expected function name requires 18 bytes of storage.

Caught by the public ASAN buildbot

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

Added: 


Modified: 
lldb/unittests/Utility/LogTest.cpp

Removed: 




diff  --git a/lldb/unittests/Utility/LogTest.cpp 
b/lldb/unittests/Utility/LogTest.cpp
index d3c878d3ea718..1dac19486a8f7 100644
--- a/lldb/unittests/Utility/LogTest.cpp
+++ b/lldb/unittests/Utility/LogTest.cpp
@@ -309,7 +309,7 @@ TEST_F(LogChannelEnabledTest, log_options) {
   Err));
 llvm::StringRef Msg = logAndTakeOutputf("Hello World");
 char File[12];
-char Function[17];
+char Function[18];
 
 sscanf(Msg.str().c_str(),
"%[^:]:%s Hello World", File,



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


[Lldb-commits] [PATCH] D152454: [lldb][test] LogTest: Fix stack overflow

2023-06-08 Thread Michael Buch via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG9c4c67a682f9: [lldb][test] LogTest: Fix stack overflow 
(authored by Michael137).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152454

Files:
  lldb/unittests/Utility/LogTest.cpp


Index: lldb/unittests/Utility/LogTest.cpp
===
--- lldb/unittests/Utility/LogTest.cpp
+++ lldb/unittests/Utility/LogTest.cpp
@@ -309,7 +309,7 @@
   Err));
 llvm::StringRef Msg = logAndTakeOutputf("Hello World");
 char File[12];
-char Function[17];
+char Function[18];
 
 sscanf(Msg.str().c_str(),
"%[^:]:%s Hello World", File,


Index: lldb/unittests/Utility/LogTest.cpp
===
--- lldb/unittests/Utility/LogTest.cpp
+++ lldb/unittests/Utility/LogTest.cpp
@@ -309,7 +309,7 @@
   Err));
 llvm::StringRef Msg = logAndTakeOutputf("Hello World");
 char File[12];
-char Function[17];
+char Function[18];
 
 sscanf(Msg.str().c_str(),
"%[^:]:%s Hello World", File,
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D152449: [lldb][NFC]Update debug (eh-frame) tests to preserve old behaviour.

2023-06-08 Thread Felipe de Azevedo Piovezan via Phabricator via lldb-commits
fdeazeve added a comment.

Thanks for looking into this! I think we should just remove the XFAIL instead, 
for the reasons you mentioned in the other patch!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152449

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


[Lldb-commits] [PATCH] D152449: [lldb][NFC]Update debug (eh-frame) tests to preserve old behaviour.

2023-06-08 Thread Vy Nguyen via Phabricator via lldb-commits
oontvoo updated this revision to Diff 529653.
oontvoo added a comment.

Removed XFAIL: system-darwin from test


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152449

Files:
  lldb/test/Shell/Unwind/prefer-debug-over-eh-frame.test


Index: lldb/test/Shell/Unwind/prefer-debug-over-eh-frame.test
===
--- lldb/test/Shell/Unwind/prefer-debug-over-eh-frame.test
+++ lldb/test/Shell/Unwind/prefer-debug-over-eh-frame.test
@@ -5,7 +5,6 @@
 # be thrown.
 
 # UNSUPPORTED: system-windows
-# XFAIL: system-darwin
 # REQUIRES: target-x86_64, native
 
 # RUN: %clang_host -g %p/Inputs/call-asm.c 
%p/Inputs/prefer-debug-over-eh-frame.s -o %t


Index: lldb/test/Shell/Unwind/prefer-debug-over-eh-frame.test
===
--- lldb/test/Shell/Unwind/prefer-debug-over-eh-frame.test
+++ lldb/test/Shell/Unwind/prefer-debug-over-eh-frame.test
@@ -5,7 +5,6 @@
 # be thrown.
 
 # UNSUPPORTED: system-windows
-# XFAIL: system-darwin
 # REQUIRES: target-x86_64, native
 
 # RUN: %clang_host -g %p/Inputs/call-asm.c %p/Inputs/prefer-debug-over-eh-frame.s -o %t
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D152449: [lldb][NFC]Update debug (eh-frame) tests to preserve old behaviour.

2023-06-08 Thread Vy Nguyen via Phabricator via lldb-commits
oontvoo updated this revision to Diff 529654.
oontvoo added a comment.

updated commit msg


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152449

Files:
  lldb/test/Shell/Unwind/prefer-debug-over-eh-frame.test


Index: lldb/test/Shell/Unwind/prefer-debug-over-eh-frame.test
===
--- lldb/test/Shell/Unwind/prefer-debug-over-eh-frame.test
+++ lldb/test/Shell/Unwind/prefer-debug-over-eh-frame.test
@@ -5,7 +5,6 @@
 # be thrown.
 
 # UNSUPPORTED: system-windows
-# XFAIL: system-darwin
 # REQUIRES: target-x86_64, native
 
 # RUN: %clang_host -g %p/Inputs/call-asm.c 
%p/Inputs/prefer-debug-over-eh-frame.s -o %t


Index: lldb/test/Shell/Unwind/prefer-debug-over-eh-frame.test
===
--- lldb/test/Shell/Unwind/prefer-debug-over-eh-frame.test
+++ lldb/test/Shell/Unwind/prefer-debug-over-eh-frame.test
@@ -5,7 +5,6 @@
 # be thrown.
 
 # UNSUPPORTED: system-windows
-# XFAIL: system-darwin
 # REQUIRES: target-x86_64, native
 
 # RUN: %clang_host -g %p/Inputs/call-asm.c %p/Inputs/prefer-debug-over-eh-frame.s -o %t
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D152449: [lldb][NFC]Update debug (eh-frame) tests to preserve old behaviour.

2023-06-08 Thread Felipe de Azevedo Piovezan via Phabricator via lldb-commits
fdeazeve accepted this revision.
fdeazeve added a comment.
This revision is now accepted and ready to land.

LGTM!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152449

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


[Lldb-commits] [lldb] 83cb212 - [lldb][NFC]Update debug (eh-frame) tests to work with new dwarwin MC changes

2023-06-08 Thread Vy Nguyen via lldb-commits

Author: Vy Nguyen
Date: 2023-06-08T13:11:34-04:00
New Revision: 83cb2123be487302070562c45e6eb4955b22c2b4

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

LOG: [lldb][NFC]Update debug (eh-frame) tests to work with new dwarwin MC 
changes

Details:

D144999 potentially changes the debug format (from compact-unwind to dwarf).
Updated this test to no longer prefer debug-frame over eh-frame to be 
compatible with the new behaviour

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

Added: 


Modified: 
lldb/test/Shell/Unwind/prefer-debug-over-eh-frame.test

Removed: 




diff  --git a/lldb/test/Shell/Unwind/prefer-debug-over-eh-frame.test 
b/lldb/test/Shell/Unwind/prefer-debug-over-eh-frame.test
index 19e3ae18c25f3..0d3f34ec86f56 100644
--- a/lldb/test/Shell/Unwind/prefer-debug-over-eh-frame.test
+++ b/lldb/test/Shell/Unwind/prefer-debug-over-eh-frame.test
@@ -5,7 +5,6 @@
 # be thrown.
 
 # UNSUPPORTED: system-windows
-# XFAIL: system-darwin
 # REQUIRES: target-x86_64, native
 
 # RUN: %clang_host -g %p/Inputs/call-asm.c 
%p/Inputs/prefer-debug-over-eh-frame.s -o %t



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


[Lldb-commits] [PATCH] D152449: [lldb][NFC]Update debug (eh-frame) tests to preserve old behaviour.

2023-06-08 Thread Vy Nguyen via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG83cb2123be48: [lldb][NFC]Update debug (eh-frame) tests to 
work with new dwarwin MC changes (authored by oontvoo).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152449

Files:
  lldb/test/Shell/Unwind/prefer-debug-over-eh-frame.test


Index: lldb/test/Shell/Unwind/prefer-debug-over-eh-frame.test
===
--- lldb/test/Shell/Unwind/prefer-debug-over-eh-frame.test
+++ lldb/test/Shell/Unwind/prefer-debug-over-eh-frame.test
@@ -5,7 +5,6 @@
 # be thrown.
 
 # UNSUPPORTED: system-windows
-# XFAIL: system-darwin
 # REQUIRES: target-x86_64, native
 
 # RUN: %clang_host -g %p/Inputs/call-asm.c 
%p/Inputs/prefer-debug-over-eh-frame.s -o %t


Index: lldb/test/Shell/Unwind/prefer-debug-over-eh-frame.test
===
--- lldb/test/Shell/Unwind/prefer-debug-over-eh-frame.test
+++ lldb/test/Shell/Unwind/prefer-debug-over-eh-frame.test
@@ -5,7 +5,6 @@
 # be thrown.
 
 # UNSUPPORTED: system-windows
-# XFAIL: system-darwin
 # REQUIRES: target-x86_64, native
 
 # RUN: %clang_host -g %p/Inputs/call-asm.c %p/Inputs/prefer-debug-over-eh-frame.s -o %t
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D152409: [lldb] Never print children if the max depth has been reached

2023-06-08 Thread Augusto Noronha via Phabricator via lldb-commits
augusto2112 updated this revision to Diff 529673.
augusto2112 added a comment.

Remove failure check


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152409

Files:
  lldb/include/lldb/DataFormatters/ValueObjectPrinter.h
  lldb/source/DataFormatters/ValueObjectPrinter.cpp

Index: lldb/source/DataFormatters/ValueObjectPrinter.cpp
===
--- lldb/source/DataFormatters/ValueObjectPrinter.cpp
+++ lldb/source/DataFormatters/ValueObjectPrinter.cpp
@@ -502,7 +502,6 @@
 }
 
 bool ValueObjectPrinter::ShouldPrintChildren(
-bool is_failed_description,
 DumpValueObjectOptions::PointerDepth &curr_ptr_depth) {
   const bool is_ref = IsRef();
   const bool is_ptr = IsPtr();
@@ -511,6 +510,10 @@
   if (is_uninit)
 return false;
 
+  // If we have reached the maximum depth we shouldn't print any more children.
+  if (HasReachedMaximumDepth())
+return false;
+
   // if the user has specified an element count, always print children as it is
   // explicit user demand being honored
   if (m_options.m_pointer_as_array)
@@ -523,37 +526,34 @@
   if (TypeSummaryImpl *type_summary = GetSummaryFormatter())
 print_children = type_summary->DoesPrintChildren(m_valobj);
 
-  if (is_failed_description || !HasReachedMaximumDepth()) {
-// We will show children for all concrete types. We won't show pointer
-// contents unless a pointer depth has been specified. We won't reference
-// contents unless the reference is the root object (depth of zero).
+  // We will show children for all concrete types. We won't show pointer
+  // contents unless a pointer depth has been specified. We won't reference
+  // contents unless the reference is the root object (depth of zero).
 
-// Use a new temporary pointer depth in case we override the current
-// pointer depth below...
+  // Use a new temporary pointer depth in case we override the current
+  // pointer depth below...
 
-if (is_ptr || is_ref) {
-  // We have a pointer or reference whose value is an address. Make sure
-  // that address is not NULL
-  AddressType ptr_address_type;
-  if (m_valobj->GetPointerValue(&ptr_address_type) == 0)
-return false;
+  if (is_ptr || is_ref) {
+// We have a pointer or reference whose value is an address. Make sure
+// that address is not NULL
+AddressType ptr_address_type;
+if (m_valobj->GetPointerValue(&ptr_address_type) == 0)
+  return false;
 
-  const bool is_root_level = m_curr_depth == 0;
+const bool is_root_level = m_curr_depth == 0;
 
-  if (is_ref && is_root_level && print_children) {
-// If this is the root object (depth is zero) that we are showing and
-// it is a reference, and no pointer depth has been supplied print out
-// what it references. Don't do this at deeper depths otherwise we can
-// end up with infinite recursion...
-return true;
-  }
-
-  return curr_ptr_depth.CanAllowExpansion();
+if (is_ref && is_root_level && print_children) {
+  // If this is the root object (depth is zero) that we are showing and
+  // it is a reference, and no pointer depth has been supplied print out
+  // what it references. Don't do this at deeper depths otherwise we can
+  // end up with infinite recursion...
+  return true;
 }
 
-return print_children || m_summary.empty();
+return curr_ptr_depth.CanAllowExpansion();
   }
-  return false;
+
+  return print_children || m_summary.empty();
 }
 
 bool ValueObjectPrinter::ShouldExpandEmptyAggregates() {
@@ -791,14 +791,10 @@
 
 void ValueObjectPrinter::PrintChildrenIfNeeded(bool value_printed,
bool summary_printed) {
-  // This flag controls whether we tried to display a description for this
-  // object and failed if that happens, we want to display the children if any.
-  bool is_failed_description =
-  !PrintObjectDescriptionIfNeeded(value_printed, summary_printed);
+  PrintObjectDescriptionIfNeeded(value_printed, summary_printed);
 
   DumpValueObjectOptions::PointerDepth curr_ptr_depth = m_ptr_depth;
-  const bool print_children =
-  ShouldPrintChildren(is_failed_description, curr_ptr_depth);
+  const bool print_children = ShouldPrintChildren(curr_ptr_depth);
   const bool print_oneline =
   (curr_ptr_depth.CanAllowExpansion() || m_options.m_show_types ||
!m_options.m_allow_oneliner_mode || m_options.m_flat_output ||
Index: lldb/include/lldb/DataFormatters/ValueObjectPrinter.h
===
--- lldb/include/lldb/DataFormatters/ValueObjectPrinter.h
+++ lldb/include/lldb/DataFormatters/ValueObjectPrinter.h
@@ -91,8 +91,7 @@
   bool PrintObjectDescriptionIfNeeded(bool value_printed, bool summary_printed);
 
   bool
-  ShouldPrintChildren(bool is_failed_description,
-

[Lldb-commits] [lldb] 4bae706 - [lldb][NFCI] DecodedThread::TraceItemStorage::error should own its own data

2023-06-08 Thread Alex Langford via lldb-commits

Author: Alex Langford
Date: 2023-06-08T12:19:14-07:00
New Revision: 4bae706682d5b621884ff2f7014ba4eb8cb636aa

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

LOG: [lldb][NFCI] DecodedThread::TraceItemStorage::error should own its own data

The way it works now, it stores a `const char *` that it does not
explicitly own. It's owned by the ConstString StringPool. This is purely
to manage its lifetime, we don't really benefit from deduplication (nor
should we try to, they are errors). We also don't really benefit from
quick comparisons.

This may make the size of TraceItemStorage larger, but you have to pay
the cost of owning the data somewhere. The ConstString StringPool is an
attractive choice but ultimately a poor one.

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

Added: 


Modified: 
lldb/include/lldb/Target/TraceCursor.h
lldb/source/Plugins/Trace/intel-pt/DecodedThread.cpp
lldb/source/Plugins/Trace/intel-pt/DecodedThread.h
lldb/source/Plugins/Trace/intel-pt/TraceCursorIntelPT.cpp
lldb/source/Plugins/Trace/intel-pt/TraceCursorIntelPT.h

Removed: 




diff  --git a/lldb/include/lldb/Target/TraceCursor.h 
b/lldb/include/lldb/Target/TraceCursor.h
index cfc25b0cedc90..f5546d8284d37 100644
--- a/lldb/include/lldb/Target/TraceCursor.h
+++ b/lldb/include/lldb/Target/TraceCursor.h
@@ -217,7 +217,7 @@ class TraceCursor {
 
   /// \return
   /// The error message the cursor is pointing at.
-  virtual const char *GetError() const = 0;
+  virtual llvm::StringRef GetError() const = 0;
 
   /// \return
   /// Whether the cursor points to an event or not.

diff  --git a/lldb/source/Plugins/Trace/intel-pt/DecodedThread.cpp 
b/lldb/source/Plugins/Trace/intel-pt/DecodedThread.cpp
index 58cd2290a8b71..17f8f51bdf0e0 100644
--- a/lldb/source/Plugins/Trace/intel-pt/DecodedThread.cpp
+++ b/lldb/source/Plugins/Trace/intel-pt/DecodedThread.cpp
@@ -186,14 +186,12 @@ void DecodedThread::AppendInstruction(const pt_insn 
&insn) {
 }
 
 void DecodedThread::AppendError(const IntelPTError &error) {
-  CreateNewTraceItem(lldb::eTraceItemKindError).error =
-  ConstString(error.message()).AsCString();
+  CreateNewTraceItem(lldb::eTraceItemKindError).error = error.message();
   m_error_stats.RecordError(/*fatal=*/false);
 }
 
 void DecodedThread::AppendCustomError(StringRef err, bool fatal) {
-  CreateNewTraceItem(lldb::eTraceItemKindError).error =
-  ConstString(err).AsCString();
+  CreateNewTraceItem(lldb::eTraceItemKindError).error = err.str();
   m_error_stats.RecordError(fatal);
 }
 
@@ -238,7 +236,9 @@ DecodedThread::GetItemKindByIndex(uint64_t item_index) 
const {
   return static_cast(m_item_kinds[item_index]);
 }
 
-const char *DecodedThread::GetErrorByIndex(uint64_t item_index) const {
+llvm::StringRef DecodedThread::GetErrorByIndex(uint64_t item_index) const {
+  if (item_index >= m_item_data.size())
+return llvm::StringRef();
   return m_item_data[item_index].error;
 }
 

diff  --git a/lldb/source/Plugins/Trace/intel-pt/DecodedThread.h 
b/lldb/source/Plugins/Trace/intel-pt/DecodedThread.h
index b2a674aca1826..5745cdb67ab68 100644
--- a/lldb/source/Plugins/Trace/intel-pt/DecodedThread.h
+++ b/lldb/source/Plugins/Trace/intel-pt/DecodedThread.h
@@ -159,7 +159,7 @@ class DecodedThread : public 
std::enable_shared_from_this {
 
   /// \return
   ///   The error associated with a given trace item.
-  const char *GetErrorByIndex(uint64_t item_index) const;
+  llvm::StringRef GetErrorByIndex(uint64_t item_index) const;
 
   /// \return
   ///   The trace item kind given an item index.
@@ -275,7 +275,7 @@ class DecodedThread : public 
std::enable_shared_from_this {
 lldb::TraceEvent event;
 
 /// The string message of this item if it's an error
-const char *error;
+std::string error;
   };
 
   /// Create a new trace item.

diff  --git a/lldb/source/Plugins/Trace/intel-pt/TraceCursorIntelPT.cpp 
b/lldb/source/Plugins/Trace/intel-pt/TraceCursorIntelPT.cpp
index 32e0bad0d19b9..66d342196cf10 100644
--- a/lldb/source/Plugins/Trace/intel-pt/TraceCursorIntelPT.cpp
+++ b/lldb/source/Plugins/Trace/intel-pt/TraceCursorIntelPT.cpp
@@ -95,7 +95,7 @@ lldb::TraceItemKind TraceCursorIntelPT::GetItemKind() const {
   return m_decoded_thread_sp->GetItemKindByIndex(m_pos);
 }
 
-const char *TraceCursorIntelPT::GetError() const {
+llvm::StringRef TraceCursorIntelPT::GetError() const {
   return m_decoded_thread_sp->GetErrorByIndex(m_pos);
 }
 

diff  --git a/lldb/source/Plugins/Trace/intel-pt/TraceCursorIntelPT.h 
b/lldb/source/Plugins/Trace/intel-pt/TraceCursorIntelPT.h
index 173426faacce1..14240d9d00285 100644
--- a/lldb/source/Plugins/Trace/intel-pt/TraceCursorIntelPT.h
+++ b/lldb/source/Plugins/Trace/intel-pt/TraceCursorIntelPT.h
@@ -28,7 +28,7 @@ class Trace

[Lldb-commits] [PATCH] D152326: [lldb][NFCI] DecodedThread::TraceItemStorage::error should own its own data

2023-06-08 Thread Alex Langford via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG4bae706682d5: [lldb][NFCI] 
DecodedThread::TraceItemStorage::error should own its own data (authored by 
bulbazord).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152326

Files:
  lldb/include/lldb/Target/TraceCursor.h
  lldb/source/Plugins/Trace/intel-pt/DecodedThread.cpp
  lldb/source/Plugins/Trace/intel-pt/DecodedThread.h
  lldb/source/Plugins/Trace/intel-pt/TraceCursorIntelPT.cpp
  lldb/source/Plugins/Trace/intel-pt/TraceCursorIntelPT.h


Index: lldb/source/Plugins/Trace/intel-pt/TraceCursorIntelPT.h
===
--- lldb/source/Plugins/Trace/intel-pt/TraceCursorIntelPT.h
+++ lldb/source/Plugins/Trace/intel-pt/TraceCursorIntelPT.h
@@ -28,7 +28,7 @@
 
   bool HasValue() const override;
 
-  const char *GetError() const override;
+  llvm::StringRef GetError() const override;
 
   lldb::addr_t GetLoadAddress() const override;
 
Index: lldb/source/Plugins/Trace/intel-pt/TraceCursorIntelPT.cpp
===
--- lldb/source/Plugins/Trace/intel-pt/TraceCursorIntelPT.cpp
+++ lldb/source/Plugins/Trace/intel-pt/TraceCursorIntelPT.cpp
@@ -95,7 +95,7 @@
   return m_decoded_thread_sp->GetItemKindByIndex(m_pos);
 }
 
-const char *TraceCursorIntelPT::GetError() const {
+llvm::StringRef TraceCursorIntelPT::GetError() const {
   return m_decoded_thread_sp->GetErrorByIndex(m_pos);
 }
 
Index: lldb/source/Plugins/Trace/intel-pt/DecodedThread.h
===
--- lldb/source/Plugins/Trace/intel-pt/DecodedThread.h
+++ lldb/source/Plugins/Trace/intel-pt/DecodedThread.h
@@ -159,7 +159,7 @@
 
   /// \return
   ///   The error associated with a given trace item.
-  const char *GetErrorByIndex(uint64_t item_index) const;
+  llvm::StringRef GetErrorByIndex(uint64_t item_index) const;
 
   /// \return
   ///   The trace item kind given an item index.
@@ -275,7 +275,7 @@
 lldb::TraceEvent event;
 
 /// The string message of this item if it's an error
-const char *error;
+std::string error;
   };
 
   /// Create a new trace item.
Index: lldb/source/Plugins/Trace/intel-pt/DecodedThread.cpp
===
--- lldb/source/Plugins/Trace/intel-pt/DecodedThread.cpp
+++ lldb/source/Plugins/Trace/intel-pt/DecodedThread.cpp
@@ -186,14 +186,12 @@
 }
 
 void DecodedThread::AppendError(const IntelPTError &error) {
-  CreateNewTraceItem(lldb::eTraceItemKindError).error =
-  ConstString(error.message()).AsCString();
+  CreateNewTraceItem(lldb::eTraceItemKindError).error = error.message();
   m_error_stats.RecordError(/*fatal=*/false);
 }
 
 void DecodedThread::AppendCustomError(StringRef err, bool fatal) {
-  CreateNewTraceItem(lldb::eTraceItemKindError).error =
-  ConstString(err).AsCString();
+  CreateNewTraceItem(lldb::eTraceItemKindError).error = err.str();
   m_error_stats.RecordError(fatal);
 }
 
@@ -238,7 +236,9 @@
   return static_cast(m_item_kinds[item_index]);
 }
 
-const char *DecodedThread::GetErrorByIndex(uint64_t item_index) const {
+llvm::StringRef DecodedThread::GetErrorByIndex(uint64_t item_index) const {
+  if (item_index >= m_item_data.size())
+return llvm::StringRef();
   return m_item_data[item_index].error;
 }
 
Index: lldb/include/lldb/Target/TraceCursor.h
===
--- lldb/include/lldb/Target/TraceCursor.h
+++ lldb/include/lldb/Target/TraceCursor.h
@@ -217,7 +217,7 @@
 
   /// \return
   /// The error message the cursor is pointing at.
-  virtual const char *GetError() const = 0;
+  virtual llvm::StringRef GetError() const = 0;
 
   /// \return
   /// Whether the cursor points to an event or not.


Index: lldb/source/Plugins/Trace/intel-pt/TraceCursorIntelPT.h
===
--- lldb/source/Plugins/Trace/intel-pt/TraceCursorIntelPT.h
+++ lldb/source/Plugins/Trace/intel-pt/TraceCursorIntelPT.h
@@ -28,7 +28,7 @@
 
   bool HasValue() const override;
 
-  const char *GetError() const override;
+  llvm::StringRef GetError() const override;
 
   lldb::addr_t GetLoadAddress() const override;
 
Index: lldb/source/Plugins/Trace/intel-pt/TraceCursorIntelPT.cpp
===
--- lldb/source/Plugins/Trace/intel-pt/TraceCursorIntelPT.cpp
+++ lldb/source/Plugins/Trace/intel-pt/TraceCursorIntelPT.cpp
@@ -95,7 +95,7 @@
   return m_decoded_thread_sp->GetItemKindByIndex(m_pos);
 }
 
-const char *TraceCursorIntelPT::GetError() const {
+llvm::StringRef TraceCursorIntelPT::GetError() const {
   return m_decoded_thread_sp->GetErrorByIndex(m_pos);
 }
 
Index: lldb/source/Plugins/Trace/intel-pt/DecodedThread.h
==

[Lldb-commits] [PATCH] D152210: [lldb][NFCI] Remove use of ConstString from OptionValueProperties

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

Cool


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152210

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


[Lldb-commits] [PATCH] D152364: [lldb] Rate limit progress reports -- different approach [WIP-ish]

2023-06-08 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere added a comment.

Continuing some of the discussion from D150805 
 here as it mostly relates to this patch:

In D150805#4402906 , @labath wrote:

> I agree that we should have a rate limiting mechanism very close to the 
> source, to avoid wasting work for events that aren't going to be used.

I'm not sure I (fully) agree with this statement. I may have misunderstood the 
motivation for D150805 , but my understanding 
was that it was the consumption of the progress events that was too costly, not 
the generation. Of course this will indirectly make that problem better because 
of the rate limiting, but as I said in the original review, that still seems 
like something the consumer should have control over.

I would have assumed that reporting the progress wouldn't be that expensive. 
Based on the description of this patch, it seems like it's non-trivial, but 
also not a dominating factor by any means.

> This is particularly important for debug info parsing, where we have multiple 
> threads working in parallel and taking a lock even just to check whether we 
> should report something could be a choke point.

Fair enough, but this could be achieved without the rate limiting: the 
reporting could be an async operation with the thread reporting every event.

> I like it because the act of reporting progress does block the reporting 
> thread in any way.

+1 but as I said above this could be orthogonal from rate limiting.

TL;DR I like the async reporting part, not (yet) convinced of the rate limiting 
"at the source".


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152364

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


[Lldb-commits] [PATCH] D151950: [lldb] Unconditionally increment depth when printing children

2023-06-08 Thread Augusto Noronha via Phabricator via lldb-commits
augusto2112 updated this revision to Diff 529709.
augusto2112 marked an inline comment as done.
augusto2112 added a comment.

Addressed comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151950

Files:
  lldb/include/lldb/DataFormatters/DumpValueObjectOptions.h
  lldb/source/DataFormatters/ValueObjectPrinter.cpp
  lldb/test/API/lang/cpp/frame-var-depth-and-elem-count/Makefile
  
lldb/test/API/lang/cpp/frame-var-depth-and-elem-count/TestFrameVarDepthAndElemCount.py
  lldb/test/API/lang/cpp/frame-var-depth-and-elem-count/main.cpp

Index: lldb/test/API/lang/cpp/frame-var-depth-and-elem-count/main.cpp
===
--- /dev/null
+++ lldb/test/API/lang/cpp/frame-var-depth-and-elem-count/main.cpp
@@ -0,0 +1,19 @@
+#include 
+
+struct A {
+  int i = 42;
+};
+
+struct B {
+  A a;
+};
+
+struct C {
+  B b;
+};
+
+int main() {
+  C *c = new C[5];
+  puts("break here");
+  return 0; // break here
+}
Index: lldb/test/API/lang/cpp/frame-var-depth-and-elem-count/TestFrameVarDepthAndElemCount.py
===
--- /dev/null
+++ lldb/test/API/lang/cpp/frame-var-depth-and-elem-count/TestFrameVarDepthAndElemCount.py
@@ -0,0 +1,27 @@
+"""
+Tests that frame variable --depth and --element-count options work correctly
+together
+"""
+import lldb
+from lldbsuite.test.lldbtest import *
+import lldbsuite.test.lldbutil as lldbutil
+
+
+class TestFrameVarDepthAndElemCount(TestBase):
+def test(self):
+"""Test that bool types work in the expression parser"""
+self.build()
+lldbutil.run_to_source_breakpoint(
+self, "// break here", lldb.SBFileSpec("main.cpp")
+)
+
+# Check that we print 5 elements but only 2 levels deep.
+self.expect('frame var --depth 2 --element-count 5 -- c', 
+substrs=[
+'[0] = {\nb ={...}\n  }',
+'[1] = {\nb ={...}\n  }',
+'[2] = {\nb ={...}\n  }',
+'[3] = {\nb ={...}\n  }',
+'[4] = {\nb ={...}\n  }',
+])
+
Index: lldb/test/API/lang/cpp/frame-var-depth-and-elem-count/Makefile
===
--- /dev/null
+++ lldb/test/API/lang/cpp/frame-var-depth-and-elem-count/Makefile
@@ -0,0 +1,3 @@
+CXX_SOURCES := main.cpp
+
+include Makefile.rules
Index: lldb/source/DataFormatters/ValueObjectPrinter.cpp
===
--- lldb/source/DataFormatters/ValueObjectPrinter.cpp
+++ lldb/source/DataFormatters/ValueObjectPrinter.cpp
@@ -590,7 +590,7 @@
 void ValueObjectPrinter::PrintChild(
 ValueObjectSP child_sp,
 const DumpValueObjectOptions::PointerDepth &curr_ptr_depth) {
-  const uint32_t consumed_depth = (!m_options.m_pointer_as_array) ? 1 : 0;
+  const uint32_t consumed_summary_depth = m_options.m_pointer_as_array ? 0 : 1;
   const bool does_consume_ptr_depth =
   ((IsPtr() && !m_options.m_pointer_as_array) || IsRef());
 
@@ -603,15 +603,18 @@
   .SetHideValue(m_options.m_hide_value)
   .SetOmitSummaryDepth(child_options.m_omit_summary_depth > 1
? child_options.m_omit_summary_depth -
- consumed_depth
+ consumed_summary_depth
: 0)
   .SetElementCount(0);
 
   if (child_sp.get()) {
-ValueObjectPrinter child_printer(
-child_sp.get(), m_stream, child_options,
-does_consume_ptr_depth ? --curr_ptr_depth : curr_ptr_depth,
-m_curr_depth + consumed_depth, m_printed_instance_pointers);
+auto ptr_depth = curr_ptr_depth;
+if (does_consume_ptr_depth)
+  ptr_depth = curr_ptr_depth.Decremented();
+
+ValueObjectPrinter child_printer(child_sp.get(), m_stream, child_options,
+ ptr_depth, m_curr_depth + 1,
+ m_printed_instance_pointers);
 child_printer.PrintValueObject();
   }
 }
Index: lldb/include/lldb/DataFormatters/DumpValueObjectOptions.h
===
--- lldb/include/lldb/DataFormatters/DumpValueObjectOptions.h
+++ lldb/include/lldb/DataFormatters/DumpValueObjectOptions.h
@@ -25,7 +25,7 @@
 enum class Mode { Always, Default, Never } m_mode;
 uint32_t m_count;
 
-PointerDepth operator--() const {
+PointerDepth Decremented() const {
   if (m_count > 0)
 return PointerDepth{m_mode, m_count - 1};
   return PointerDepth{m_mode, m_count};
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] b1ebfc5 - [lldb] Unconditionally increment depth when printing children

2023-06-08 Thread Augusto Noronha via lldb-commits

Author: Augusto Noronha
Date: 2023-06-08T13:30:30-07:00
New Revision: b1ebfc5de34ef4c91aa6f163989de600fb5227f8

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

LOG: [lldb] Unconditionally increment depth when printing children

The `target.max-children-depth` setting and `--depth` flag would be
ignored if treating pointer as arrays, fix that by always incrementing
the current depth when printing a new child.

rdar://109855463

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

Added: 
lldb/test/API/lang/cpp/frame-var-depth-and-elem-count/Makefile

lldb/test/API/lang/cpp/frame-var-depth-and-elem-count/TestFrameVarDepthAndElemCount.py
lldb/test/API/lang/cpp/frame-var-depth-and-elem-count/main.cpp

Modified: 
lldb/include/lldb/DataFormatters/DumpValueObjectOptions.h
lldb/source/DataFormatters/ValueObjectPrinter.cpp

Removed: 




diff  --git a/lldb/include/lldb/DataFormatters/DumpValueObjectOptions.h 
b/lldb/include/lldb/DataFormatters/DumpValueObjectOptions.h
index b622c34ec3e0f..c7f8116c4 100644
--- a/lldb/include/lldb/DataFormatters/DumpValueObjectOptions.h
+++ b/lldb/include/lldb/DataFormatters/DumpValueObjectOptions.h
@@ -25,7 +25,7 @@ class DumpValueObjectOptions {
 enum class Mode { Always, Default, Never } m_mode;
 uint32_t m_count;
 
-PointerDepth operator--() const {
+PointerDepth Decremented() const {
   if (m_count > 0)
 return PointerDepth{m_mode, m_count - 1};
   return PointerDepth{m_mode, m_count};

diff  --git a/lldb/source/DataFormatters/ValueObjectPrinter.cpp 
b/lldb/source/DataFormatters/ValueObjectPrinter.cpp
index fac319f67c805..16aeff13791c5 100644
--- a/lldb/source/DataFormatters/ValueObjectPrinter.cpp
+++ b/lldb/source/DataFormatters/ValueObjectPrinter.cpp
@@ -590,7 +590,7 @@ void ValueObjectPrinter::PrintChildrenPreamble(bool 
value_printed,
 void ValueObjectPrinter::PrintChild(
 ValueObjectSP child_sp,
 const DumpValueObjectOptions::PointerDepth &curr_ptr_depth) {
-  const uint32_t consumed_depth = (!m_options.m_pointer_as_array) ? 1 : 0;
+  const uint32_t consumed_summary_depth = m_options.m_pointer_as_array ? 0 : 1;
   const bool does_consume_ptr_depth =
   ((IsPtr() && !m_options.m_pointer_as_array) || IsRef());
 
@@ -603,15 +603,18 @@ void ValueObjectPrinter::PrintChild(
   .SetHideValue(m_options.m_hide_value)
   .SetOmitSummaryDepth(child_options.m_omit_summary_depth > 1
? child_options.m_omit_summary_depth -
- consumed_depth
+ consumed_summary_depth
: 0)
   .SetElementCount(0);
 
   if (child_sp.get()) {
-ValueObjectPrinter child_printer(
-child_sp.get(), m_stream, child_options,
-does_consume_ptr_depth ? --curr_ptr_depth : curr_ptr_depth,
-m_curr_depth + consumed_depth, m_printed_instance_pointers);
+auto ptr_depth = curr_ptr_depth;
+if (does_consume_ptr_depth)
+  ptr_depth = curr_ptr_depth.Decremented();
+
+ValueObjectPrinter child_printer(child_sp.get(), m_stream, child_options,
+ ptr_depth, m_curr_depth + 1,
+ m_printed_instance_pointers);
 child_printer.PrintValueObject();
   }
 }

diff  --git a/lldb/test/API/lang/cpp/frame-var-depth-and-elem-count/Makefile 
b/lldb/test/API/lang/cpp/frame-var-depth-and-elem-count/Makefile
new file mode 100644
index 0..8b20bcb05
--- /dev/null
+++ b/lldb/test/API/lang/cpp/frame-var-depth-and-elem-count/Makefile
@@ -0,0 +1,3 @@
+CXX_SOURCES := main.cpp
+
+include Makefile.rules

diff  --git 
a/lldb/test/API/lang/cpp/frame-var-depth-and-elem-count/TestFrameVarDepthAndElemCount.py
 
b/lldb/test/API/lang/cpp/frame-var-depth-and-elem-count/TestFrameVarDepthAndElemCount.py
new file mode 100644
index 0..e8fa95ef6469a
--- /dev/null
+++ 
b/lldb/test/API/lang/cpp/frame-var-depth-and-elem-count/TestFrameVarDepthAndElemCount.py
@@ -0,0 +1,27 @@
+"""
+Tests that frame variable --depth and --element-count options work correctly
+together
+"""
+import lldb
+from lldbsuite.test.lldbtest import *
+import lldbsuite.test.lldbutil as lldbutil
+
+
+class TestFrameVarDepthAndElemCount(TestBase):
+def test(self):
+"""Test that bool types work in the expression parser"""
+self.build()
+lldbutil.run_to_source_breakpoint(
+self, "// break here", lldb.SBFileSpec("main.cpp")
+)
+
+# Check that we print 5 elements but only 2 levels deep.
+self.expect('frame var --depth 2 --element-count 5 -- c', 
+substrs=[
+'[0] = {\nb ={...}\n  }',
+'[1] = {\nb ={...}\n  }',
+'[2] = {

[Lldb-commits] [PATCH] D151950: [lldb] Unconditionally increment depth when printing children

2023-06-08 Thread Augusto Noronha via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGb1ebfc5de34e: [lldb] Unconditionally increment depth when 
printing children (authored by augusto2112).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151950

Files:
  lldb/include/lldb/DataFormatters/DumpValueObjectOptions.h
  lldb/source/DataFormatters/ValueObjectPrinter.cpp
  lldb/test/API/lang/cpp/frame-var-depth-and-elem-count/Makefile
  
lldb/test/API/lang/cpp/frame-var-depth-and-elem-count/TestFrameVarDepthAndElemCount.py
  lldb/test/API/lang/cpp/frame-var-depth-and-elem-count/main.cpp

Index: lldb/test/API/lang/cpp/frame-var-depth-and-elem-count/main.cpp
===
--- /dev/null
+++ lldb/test/API/lang/cpp/frame-var-depth-and-elem-count/main.cpp
@@ -0,0 +1,19 @@
+#include 
+
+struct A {
+  int i = 42;
+};
+
+struct B {
+  A a;
+};
+
+struct C {
+  B b;
+};
+
+int main() {
+  C *c = new C[5];
+  puts("break here");
+  return 0; // break here
+}
Index: lldb/test/API/lang/cpp/frame-var-depth-and-elem-count/TestFrameVarDepthAndElemCount.py
===
--- /dev/null
+++ lldb/test/API/lang/cpp/frame-var-depth-and-elem-count/TestFrameVarDepthAndElemCount.py
@@ -0,0 +1,27 @@
+"""
+Tests that frame variable --depth and --element-count options work correctly
+together
+"""
+import lldb
+from lldbsuite.test.lldbtest import *
+import lldbsuite.test.lldbutil as lldbutil
+
+
+class TestFrameVarDepthAndElemCount(TestBase):
+def test(self):
+"""Test that bool types work in the expression parser"""
+self.build()
+lldbutil.run_to_source_breakpoint(
+self, "// break here", lldb.SBFileSpec("main.cpp")
+)
+
+# Check that we print 5 elements but only 2 levels deep.
+self.expect('frame var --depth 2 --element-count 5 -- c', 
+substrs=[
+'[0] = {\nb ={...}\n  }',
+'[1] = {\nb ={...}\n  }',
+'[2] = {\nb ={...}\n  }',
+'[3] = {\nb ={...}\n  }',
+'[4] = {\nb ={...}\n  }',
+])
+
Index: lldb/test/API/lang/cpp/frame-var-depth-and-elem-count/Makefile
===
--- /dev/null
+++ lldb/test/API/lang/cpp/frame-var-depth-and-elem-count/Makefile
@@ -0,0 +1,3 @@
+CXX_SOURCES := main.cpp
+
+include Makefile.rules
Index: lldb/source/DataFormatters/ValueObjectPrinter.cpp
===
--- lldb/source/DataFormatters/ValueObjectPrinter.cpp
+++ lldb/source/DataFormatters/ValueObjectPrinter.cpp
@@ -590,7 +590,7 @@
 void ValueObjectPrinter::PrintChild(
 ValueObjectSP child_sp,
 const DumpValueObjectOptions::PointerDepth &curr_ptr_depth) {
-  const uint32_t consumed_depth = (!m_options.m_pointer_as_array) ? 1 : 0;
+  const uint32_t consumed_summary_depth = m_options.m_pointer_as_array ? 0 : 1;
   const bool does_consume_ptr_depth =
   ((IsPtr() && !m_options.m_pointer_as_array) || IsRef());
 
@@ -603,15 +603,18 @@
   .SetHideValue(m_options.m_hide_value)
   .SetOmitSummaryDepth(child_options.m_omit_summary_depth > 1
? child_options.m_omit_summary_depth -
- consumed_depth
+ consumed_summary_depth
: 0)
   .SetElementCount(0);
 
   if (child_sp.get()) {
-ValueObjectPrinter child_printer(
-child_sp.get(), m_stream, child_options,
-does_consume_ptr_depth ? --curr_ptr_depth : curr_ptr_depth,
-m_curr_depth + consumed_depth, m_printed_instance_pointers);
+auto ptr_depth = curr_ptr_depth;
+if (does_consume_ptr_depth)
+  ptr_depth = curr_ptr_depth.Decremented();
+
+ValueObjectPrinter child_printer(child_sp.get(), m_stream, child_options,
+ ptr_depth, m_curr_depth + 1,
+ m_printed_instance_pointers);
 child_printer.PrintValueObject();
   }
 }
Index: lldb/include/lldb/DataFormatters/DumpValueObjectOptions.h
===
--- lldb/include/lldb/DataFormatters/DumpValueObjectOptions.h
+++ lldb/include/lldb/DataFormatters/DumpValueObjectOptions.h
@@ -25,7 +25,7 @@
 enum class Mode { Always, Default, Never } m_mode;
 uint32_t m_count;
 
-PointerDepth operator--() const {
+PointerDepth Decremented() const {
   if (m_count > 0)
 return PointerDepth{m_mode, m_count - 1};
   return PointerDepth{m_mode, m_count};
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D152364: [lldb] Rate limit progress reports -- different approach [WIP-ish]

2023-06-08 Thread Sterling Augustine via Phabricator via lldb-commits
saugustine added a comment.

What other progress reporting needs rate limiting?

To the best of my knowledge, we have only identified one location--this one. So 
I'm not sure a fully general solution is in order here under the YAGNI 
principle.

I favor rate limiting close to the source because generating events and 
throwing them away is pure waste and gives an overall sense to the user that 
lldb is slow.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152364

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


[Lldb-commits] [PATCH] D152364: [lldb] Rate limit progress reports -- different approach [WIP-ish]

2023-06-08 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere added a comment.

In D152364#4406704 , @saugustine 
wrote:

> What other progress reporting needs rate limiting?
>
> To the best of my knowledge, we have only identified one location--this one. 
> So I'm not sure a fully general solution is in order here under the YAGNI 
> principle.
>
> I favor rate limiting close to the source because generating events and 
> throwing them away is pure waste and gives an overall sense to the user that 
> lldb is slow.

While generality is part of why I favor doing the rate limiting in the 
listener, it also means that the listener can decide the rate. For example, 
VSCode could decide they don't need rate limiting (as is the case today) while 
the default event handler in LLDB could make a different decision (for example 
based on whether you're in a fast TTY).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152364

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


[Lldb-commits] [PATCH] D152310: [lldb][NFCI] Remove use of ConstString from OptionValueLanguage

2023-06-08 Thread Alex Langford via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGd29b5673822d: [lldb][NFCI] Remove use of ConstString from 
OptionValueLanguage (authored by bulbazord).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152310

Files:
  lldb/source/Interpreter/OptionValueLanguage.cpp


Index: lldb/source/Interpreter/OptionValueLanguage.cpp
===
--- lldb/source/Interpreter/OptionValueLanguage.cpp
+++ lldb/source/Interpreter/OptionValueLanguage.cpp
@@ -43,10 +43,8 @@
 
   case eVarSetOperationReplace:
   case eVarSetOperationAssign: {
-ConstString lang_name(value.trim());
 LanguageSet languages_for_types = 
Language::GetLanguagesSupportingTypeSystems();
-LanguageType new_type =
-Language::GetLanguageTypeFromString(lang_name.GetStringRef());
+LanguageType new_type = Language::GetLanguageTypeFromString(value.trim());
 if (new_type && languages_for_types[new_type]) {
   m_value_was_set = true;
   m_current_value = new_type;


Index: lldb/source/Interpreter/OptionValueLanguage.cpp
===
--- lldb/source/Interpreter/OptionValueLanguage.cpp
+++ lldb/source/Interpreter/OptionValueLanguage.cpp
@@ -43,10 +43,8 @@
 
   case eVarSetOperationReplace:
   case eVarSetOperationAssign: {
-ConstString lang_name(value.trim());
 LanguageSet languages_for_types = Language::GetLanguagesSupportingTypeSystems();
-LanguageType new_type =
-Language::GetLanguageTypeFromString(lang_name.GetStringRef());
+LanguageType new_type = Language::GetLanguageTypeFromString(value.trim());
 if (new_type && languages_for_types[new_type]) {
   m_value_was_set = true;
   m_current_value = new_type;
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] d29b567 - [lldb][NFCI] Remove use of ConstString from OptionValueLanguage

2023-06-08 Thread Alex Langford via lldb-commits

Author: Alex Langford
Date: 2023-06-08T15:11:22-07:00
New Revision: d29b5673822d2ce7be85c789fd9809f096ec5adc

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

LOG: [lldb][NFCI] Remove use of ConstString from OptionValueLanguage

ConstString is simply not needed here.

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

Added: 


Modified: 
lldb/source/Interpreter/OptionValueLanguage.cpp

Removed: 




diff  --git a/lldb/source/Interpreter/OptionValueLanguage.cpp 
b/lldb/source/Interpreter/OptionValueLanguage.cpp
index 1be8a5585bc4d..409fcf882bcbf 100644
--- a/lldb/source/Interpreter/OptionValueLanguage.cpp
+++ b/lldb/source/Interpreter/OptionValueLanguage.cpp
@@ -43,10 +43,8 @@ Status 
OptionValueLanguage::SetValueFromString(llvm::StringRef value,
 
   case eVarSetOperationReplace:
   case eVarSetOperationAssign: {
-ConstString lang_name(value.trim());
 LanguageSet languages_for_types = 
Language::GetLanguagesSupportingTypeSystems();
-LanguageType new_type =
-Language::GetLanguageTypeFromString(lang_name.GetStringRef());
+LanguageType new_type = Language::GetLanguageTypeFromString(value.trim());
 if (new_type && languages_for_types[new_type]) {
   m_value_was_set = true;
   m_current_value = new_type;



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


[Lldb-commits] [lldb] b1a7b7f - [lldb][NFCI] Refactor TypeSystemClang::GetBasicTypeEnumeration

2023-06-08 Thread Alex Langford via lldb-commits

Author: Alex Langford
Date: 2023-06-08T15:13:55-07:00
New Revision: b1a7b7f6d55ed33166008a4d23d598582237b69d

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

LOG: [lldb][NFCI] Refactor TypeSystemClang::GetBasicTypeEnumeration

`TypeSystemClang::GetBasicTypeEnumeration(ConstString)` builds up a
giant `UniqueCStringMap` which is effectively a vector whose 
elements
are (ConstString, lldb::BasicType). Once sorted, we get to have fairly
quick lookups (O(log n) on average). This is fine, but we can do better
on average with an llvm::StringMap.

This also allows us to simplify the initialization code for the lookup,
no more `once_flag`!

Additionally, I removed unused declarations of related functions from
CompilerType and TypeSystemClang

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

Added: 


Modified: 
lldb/include/lldb/Symbol/CompilerType.h
lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h

Removed: 




diff  --git a/lldb/include/lldb/Symbol/CompilerType.h 
b/lldb/include/lldb/Symbol/CompilerType.h
index 1d2244297cb0a..2d7092d2c93f8 100644
--- a/lldb/include/lldb/Symbol/CompilerType.h
+++ b/lldb/include/lldb/Symbol/CompilerType.h
@@ -344,8 +344,6 @@ class CompilerType {
 
   lldb::BasicType GetBasicTypeEnumeration() const;
 
-  static lldb::BasicType GetBasicTypeEnumeration(ConstString name);
-
   /// If this type is an enumeration, iterate through all of its enumerators
   /// using a callback. If the callback returns true, keep iterating, else 
abort
   /// the iteration.

diff  --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp 
b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
index b7ecde9790e05..6506f118f8c65 100644
--- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -864,70 +864,62 @@ 
TypeSystemClang::GetBuiltinTypeForEncodingAndBitSize(Encoding encoding,
   return CompilerType();
 }
 
-lldb::BasicType
-TypeSystemClang::GetBasicTypeEnumeration(ConstString name) {
-  if (name) {
-typedef UniqueCStringMap TypeNameToBasicTypeMap;
-static TypeNameToBasicTypeMap g_type_map;
-static llvm::once_flag g_once_flag;
-llvm::call_once(g_once_flag, []() {
+lldb::BasicType TypeSystemClang::GetBasicTypeEnumeration(llvm::StringRef name) 
{
+  static const llvm::StringMap g_type_map = {
   // "void"
-  g_type_map.Append(ConstString("void"), eBasicTypeVoid);
+  {"void", eBasicTypeVoid},
 
   // "char"
-  g_type_map.Append(ConstString("char"), eBasicTypeChar);
-  g_type_map.Append(ConstString("signed char"), eBasicTypeSignedChar);
-  g_type_map.Append(ConstString("unsigned char"), eBasicTypeUnsignedChar);
-  g_type_map.Append(ConstString("wchar_t"), eBasicTypeWChar);
-  g_type_map.Append(ConstString("signed wchar_t"), eBasicTypeSignedWChar);
-  g_type_map.Append(ConstString("unsigned wchar_t"),
-eBasicTypeUnsignedWChar);
+  {"char", eBasicTypeChar},
+  {"signed char", eBasicTypeSignedChar},
+  {"unsigned char", eBasicTypeUnsignedChar},
+  {"wchar_t", eBasicTypeWChar},
+  {"signed wchar_t", eBasicTypeSignedWChar},
+  {"unsigned wchar_t", eBasicTypeUnsignedWChar},
+
   // "short"
-  g_type_map.Append(ConstString("short"), eBasicTypeShort);
-  g_type_map.Append(ConstString("short int"), eBasicTypeShort);
-  g_type_map.Append(ConstString("unsigned short"), 
eBasicTypeUnsignedShort);
-  g_type_map.Append(ConstString("unsigned short int"),
-eBasicTypeUnsignedShort);
+  {"short", eBasicTypeShort},
+  {"short int", eBasicTypeShort},
+  {"unsigned short", eBasicTypeUnsignedShort},
+  {"unsigned short int", eBasicTypeUnsignedShort},
 
   // "int"
-  g_type_map.Append(ConstString("int"), eBasicTypeInt);
-  g_type_map.Append(ConstString("signed int"), eBasicTypeInt);
-  g_type_map.Append(ConstString("unsigned int"), eBasicTypeUnsignedInt);
-  g_type_map.Append(ConstString("unsigned"), eBasicTypeUnsignedInt);
+  {"int", eBasicTypeInt},
+  {"signed int", eBasicTypeInt},
+  {"unsigned int", eBasicTypeUnsignedInt},
+  {"unsigned", eBasicTypeUnsignedInt},
 
   // "long"
-  g_type_map.Append(ConstString("long"), eBasicTypeLong);
-  g_type_map.Append(ConstString("long int"), eBasicTypeLong);
-  g_type_map.Append(ConstString("unsigned long"), eBasicTypeUnsignedLong);
-  g_type_map.Append(ConstString("unsigned long int"),
-eBasicTypeUnsignedLong);
+  {"long", eBasicTypeLong},
+  {"long int", eBasicTypeLong},
+  {"unsigned long", eBasicTypeUnsignedLong},
+  {"unsigned long int",

[Lldb-commits] [PATCH] D152315: [lldb][NFCI] Refactor TypeSystemClang::GetBasicTypeEnumeration

2023-06-08 Thread Alex Langford via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGb1a7b7f6d55e: [lldb][NFCI] Refactor 
TypeSystemClang::GetBasicTypeEnumeration (authored by bulbazord).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152315

Files:
  lldb/include/lldb/Symbol/CompilerType.h
  lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
  lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h

Index: lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
===
--- lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
+++ lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
@@ -207,7 +207,7 @@
 
   CompilerType GetBasicType(lldb::BasicType type);
 
-  static lldb::BasicType GetBasicTypeEnumeration(ConstString name);
+  static lldb::BasicType GetBasicTypeEnumeration(llvm::StringRef name);
 
   CompilerType
   GetBuiltinTypeForDWARFEncodingAndBitSize(llvm::StringRef type_name,
@@ -834,10 +834,6 @@
   lldb::BasicType
   GetBasicTypeEnumeration(lldb::opaque_compiler_type_t type) override;
 
-  static lldb::BasicType
-  GetBasicTypeEnumeration(lldb::opaque_compiler_type_t type,
-  ConstString name);
-
   void ForEachEnumerator(
   lldb::opaque_compiler_type_t type,
   std::function TypeNameToBasicTypeMap;
-static TypeNameToBasicTypeMap g_type_map;
-static llvm::once_flag g_once_flag;
-llvm::call_once(g_once_flag, []() {
+lldb::BasicType TypeSystemClang::GetBasicTypeEnumeration(llvm::StringRef name) {
+  static const llvm::StringMap g_type_map = {
   // "void"
-  g_type_map.Append(ConstString("void"), eBasicTypeVoid);
+  {"void", eBasicTypeVoid},
 
   // "char"
-  g_type_map.Append(ConstString("char"), eBasicTypeChar);
-  g_type_map.Append(ConstString("signed char"), eBasicTypeSignedChar);
-  g_type_map.Append(ConstString("unsigned char"), eBasicTypeUnsignedChar);
-  g_type_map.Append(ConstString("wchar_t"), eBasicTypeWChar);
-  g_type_map.Append(ConstString("signed wchar_t"), eBasicTypeSignedWChar);
-  g_type_map.Append(ConstString("unsigned wchar_t"),
-eBasicTypeUnsignedWChar);
+  {"char", eBasicTypeChar},
+  {"signed char", eBasicTypeSignedChar},
+  {"unsigned char", eBasicTypeUnsignedChar},
+  {"wchar_t", eBasicTypeWChar},
+  {"signed wchar_t", eBasicTypeSignedWChar},
+  {"unsigned wchar_t", eBasicTypeUnsignedWChar},
+
   // "short"
-  g_type_map.Append(ConstString("short"), eBasicTypeShort);
-  g_type_map.Append(ConstString("short int"), eBasicTypeShort);
-  g_type_map.Append(ConstString("unsigned short"), eBasicTypeUnsignedShort);
-  g_type_map.Append(ConstString("unsigned short int"),
-eBasicTypeUnsignedShort);
+  {"short", eBasicTypeShort},
+  {"short int", eBasicTypeShort},
+  {"unsigned short", eBasicTypeUnsignedShort},
+  {"unsigned short int", eBasicTypeUnsignedShort},
 
   // "int"
-  g_type_map.Append(ConstString("int"), eBasicTypeInt);
-  g_type_map.Append(ConstString("signed int"), eBasicTypeInt);
-  g_type_map.Append(ConstString("unsigned int"), eBasicTypeUnsignedInt);
-  g_type_map.Append(ConstString("unsigned"), eBasicTypeUnsignedInt);
+  {"int", eBasicTypeInt},
+  {"signed int", eBasicTypeInt},
+  {"unsigned int", eBasicTypeUnsignedInt},
+  {"unsigned", eBasicTypeUnsignedInt},
 
   // "long"
-  g_type_map.Append(ConstString("long"), eBasicTypeLong);
-  g_type_map.Append(ConstString("long int"), eBasicTypeLong);
-  g_type_map.Append(ConstString("unsigned long"), eBasicTypeUnsignedLong);
-  g_type_map.Append(ConstString("unsigned long int"),
-eBasicTypeUnsignedLong);
+  {"long", eBasicTypeLong},
+  {"long int", eBasicTypeLong},
+  {"unsigned long", eBasicTypeUnsignedLong},
+  {"unsigned long int", eBasicTypeUnsignedLong},
 
   // "long long"
-  g_type_map.Append(ConstString("long long"), eBasicTypeLongLong);
-  g_type_map.Append(ConstString("long long int"), eBasicTypeLongLong);
-  g_type_map.Append(ConstString("unsigned long long"),
-eBasicTypeUnsignedLongLong);
-  g_type_map.Append(ConstString("unsigned long long int"),
-eBasicTypeUnsignedLongLong);
+  {"long long", eBasicTypeLongLong},
+  {"long long int", eBasicTypeLongLong},
+  {"unsigned long long", eBasicTypeUnsignedLongLong},
+  {"unsigned long long int", eBasicTypeUnsignedLongLong},
 
   // "int128"
-  g_type_map.Append(ConstString("__int128_t"), eBasicTypeInt128);
-  g_type_map.Append(ConstString("__uint128_t"), eBasicTypeUnsignedInt128);
+  {"__int128_t", eBasicTypeInt128},
+  {"__uint128_t", eBasicTypeUnsignedInt128},
 
   // Miscellaneous
-  g_type_map.Append(ConstString("

[Lldb-commits] [lldb] 643ba92 - [lldb][NFCI] Remove use of ConstString from OptionValueProperties

2023-06-08 Thread Alex Langford via lldb-commits

Author: Alex Langford
Date: 2023-06-08T15:19:27-07:00
New Revision: 643ba926c1f618401c86dc37e659df795db2e1a0

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

LOG: [lldb][NFCI] Remove use of ConstString from OptionValueProperties

In the interest of keeping the ConstString StringPool small, this patch
aims to remove the use of ConstString from OptionValueProperties.

We can maintain quick lookups by using an llvm::StringMap to find the
correct index by name.

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

Added: 


Modified: 
lldb/include/lldb/Interpreter/OptionValue.h
lldb/include/lldb/Interpreter/OptionValueProperties.h
lldb/source/Interpreter/OptionValueProperties.cpp

Removed: 




diff  --git a/lldb/include/lldb/Interpreter/OptionValue.h 
b/lldb/include/lldb/Interpreter/OptionValue.h
index cd587ed463b1d..b43715357a01c 100644
--- a/lldb/include/lldb/Interpreter/OptionValue.h
+++ b/lldb/include/lldb/Interpreter/OptionValue.h
@@ -125,7 +125,7 @@ class OptionValue {
 
   virtual bool IsAggregateValue() const { return false; }
 
-  virtual ConstString GetName() const { return ConstString(); }
+  virtual llvm::StringRef GetName() const { return llvm::StringRef(); }
 
   virtual bool DumpQualifiedName(Stream &strm) const;
 

diff  --git a/lldb/include/lldb/Interpreter/OptionValueProperties.h 
b/lldb/include/lldb/Interpreter/OptionValueProperties.h
index 3f40290f1e21d..6655c47937379 100644
--- a/lldb/include/lldb/Interpreter/OptionValueProperties.h
+++ b/lldb/include/lldb/Interpreter/OptionValueProperties.h
@@ -15,7 +15,6 @@
 #include "lldb/Core/UniqueCStringMap.h"
 #include "lldb/Interpreter/OptionValue.h"
 #include "lldb/Interpreter/Property.h"
-#include "lldb/Utility/ConstString.h"
 
 namespace lldb_private {
 class Properties;
@@ -26,7 +25,7 @@ class OptionValueProperties
 public:
   OptionValueProperties() = default;
 
-  OptionValueProperties(ConstString name);
+  OptionValueProperties(llvm::StringRef name);
 
   ~OptionValueProperties() override = default;
 
@@ -49,7 +48,7 @@ class OptionValueProperties
 
   llvm::json::Value ToJSON(const ExecutionContext *exe_ctx) override;
 
-  ConstString GetName() const override { return m_name; }
+  llvm::StringRef GetName() const override { return m_name; }
 
   virtual Status DumpPropertyValue(const ExecutionContext *exe_ctx,
Stream &strm, llvm::StringRef property_path,
@@ -68,13 +67,13 @@ class OptionValueProperties
   // Get the index of a property given its exact name in this property
   // collection, "name" can't be a path to a property path that refers to a
   // property within a property
-  virtual size_t GetPropertyIndex(ConstString name) const;
+  virtual size_t GetPropertyIndex(llvm::StringRef name) const;
 
   // Get a property by exact name exists in this property collection, name can
   // not be a path to a property path that refers to a property within a
   // property
   virtual const Property *
-  GetProperty(ConstString name,
+  GetProperty(llvm::StringRef name,
   const ExecutionContext *exe_ctx = nullptr) const;
 
   virtual const Property *
@@ -87,14 +86,13 @@ class OptionValueProperties
   // "target.process.extra-startup-command"
   virtual const Property *
   GetPropertyAtPath(const ExecutionContext *exe_ctx,
-
 llvm::StringRef property_path) const;
 
   virtual lldb::OptionValueSP
   GetPropertyValueAtIndex(size_t idx, const ExecutionContext *exe_ctx) const;
 
   virtual lldb::OptionValueSP GetValueForKey(const ExecutionContext *exe_ctx,
- ConstString key) const;
+ llvm::StringRef key) const;
 
   lldb::OptionValueSP GetSubValue(const ExecutionContext *exe_ctx,
   llvm::StringRef name,
@@ -131,11 +129,11 @@ class OptionValueProperties
   OptionValueFileSpecList *GetPropertyAtIndexAsOptionValueFileSpecList(
   size_t idx, const ExecutionContext *exe_ctx = nullptr) const;
 
-  void AppendProperty(ConstString name, llvm::StringRef desc, bool is_global,
-  const lldb::OptionValueSP &value_sp);
+  void AppendProperty(llvm::StringRef name, llvm::StringRef desc,
+  bool is_global, const lldb::OptionValueSP &value_sp);
 
   lldb::OptionValuePropertiesSP GetSubProperty(const ExecutionContext *exe_ctx,
-   ConstString name);
+   llvm::StringRef name);
 
   void SetValueChangedCallback(size_t property_idx,
std::function callback);
@@ -176,11 +174,9 @@ class OptionValueProperties
 return ((idx < m_properties.size()) ? &m_properties[idx] : nullptr);
   }

[Lldb-commits] [PATCH] D152210: [lldb][NFCI] Remove use of ConstString from OptionValueProperties

2023-06-08 Thread Alex Langford via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG643ba926c1f6: [lldb][NFCI] Remove use of ConstString from 
OptionValueProperties (authored by bulbazord).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152210

Files:
  lldb/include/lldb/Interpreter/OptionValue.h
  lldb/include/lldb/Interpreter/OptionValueProperties.h
  lldb/source/Interpreter/OptionValueProperties.cpp

Index: lldb/source/Interpreter/OptionValueProperties.cpp
===
--- lldb/source/Interpreter/OptionValueProperties.cpp
+++ lldb/source/Interpreter/OptionValueProperties.cpp
@@ -20,18 +20,17 @@
 using namespace lldb;
 using namespace lldb_private;
 
-OptionValueProperties::OptionValueProperties(ConstString name) : m_name(name) {}
+OptionValueProperties::OptionValueProperties(llvm::StringRef name)
+: m_name(name.str()) {}
 
 void OptionValueProperties::Initialize(const PropertyDefinitions &defs) {
   for (const auto &definition : defs) {
 Property property(definition);
 assert(property.IsValid());
-m_name_to_index.Append(ConstString(property.GetName()),
-   m_properties.size());
+m_name_to_index.insert({property.GetName(), m_properties.size()});
 property.GetValue()->SetParent(shared_from_this());
 m_properties.push_back(property);
   }
-  m_name_to_index.Sort();
 }
 
 void OptionValueProperties::SetValueChangedCallback(
@@ -41,24 +40,25 @@
 property->SetValueChangedCallback(std::move(callback));
 }
 
-void OptionValueProperties::AppendProperty(ConstString name,
+void OptionValueProperties::AppendProperty(llvm::StringRef name,
llvm::StringRef desc, bool is_global,
const OptionValueSP &value_sp) {
-  Property property(name.GetStringRef(), desc, is_global, value_sp);
-  m_name_to_index.Append(name, m_properties.size());
+  Property property(name, desc, is_global, value_sp);
+  m_name_to_index.insert({name, m_properties.size()});
   m_properties.push_back(property);
   value_sp->SetParent(shared_from_this());
-  m_name_to_index.Sort();
 }
 
 lldb::OptionValueSP
 OptionValueProperties::GetValueForKey(const ExecutionContext *exe_ctx,
-  ConstString key) const {
-  lldb::OptionValueSP value_sp;
-  size_t idx = m_name_to_index.Find(key, SIZE_MAX);
-  if (idx < m_properties.size())
-value_sp = GetPropertyAtIndex(idx, exe_ctx)->GetValue();
-  return value_sp;
+  llvm::StringRef key) const {
+  auto iter = m_name_to_index.find(key);
+  if (iter == m_name_to_index.end())
+return OptionValueSP();
+  const size_t idx = iter->second;
+  if (idx >= m_properties.size())
+return OptionValueSP();
+  return GetPropertyAtIndex(idx, exe_ctx)->GetValue();
 }
 
 lldb::OptionValueSP
@@ -69,13 +69,13 @@
 return OptionValueSP();
 
   llvm::StringRef sub_name;
-  ConstString key;
+  llvm::StringRef key;
   size_t key_len = name.find_first_of(".[{");
   if (key_len != llvm::StringRef::npos) {
-key.SetString(name.take_front(key_len));
+key = name.take_front(key_len);
 sub_name = name.drop_front(key_len);
   } else
-key.SetString(name);
+key = name;
 
   value_sp = GetValueForKey(exe_ctx, key);
   if (sub_name.empty() || !value_sp)
@@ -138,14 +138,20 @@
   return error;
 }
 
-size_t OptionValueProperties::GetPropertyIndex(ConstString name) const {
-  return m_name_to_index.Find(name, SIZE_MAX);
+size_t OptionValueProperties::GetPropertyIndex(llvm::StringRef name) const {
+  auto iter = m_name_to_index.find(name);
+  if (iter == m_name_to_index.end())
+return SIZE_MAX;
+  return iter->second;
 }
 
 const Property *
-OptionValueProperties::GetProperty(ConstString name,
+OptionValueProperties::GetProperty(llvm::StringRef name,
const ExecutionContext *exe_ctx) const {
-  return GetPropertyAtIndex(m_name_to_index.Find(name, SIZE_MAX), exe_ctx);
+  auto iter = m_name_to_index.find(name);
+  if (iter == m_name_to_index.end())
+return nullptr;
+  return GetPropertyAtIndex(iter->second, exe_ctx);
 }
 
 lldb::OptionValueSP OptionValueProperties::GetPropertyValueAtIndex(
@@ -399,18 +405,19 @@
 const Property *
 OptionValueProperties::GetPropertyAtPath(const ExecutionContext *exe_ctx,
  llvm::StringRef name) const {
-  const Property *property = nullptr;
   if (name.empty())
 return nullptr;
+
+  const Property *property = nullptr;
   llvm::StringRef sub_name;
-  ConstString key;
+  llvm::StringRef key;
   size_t key_len = name.find_first_of(".[{");
 
   if (key_len != llvm::StringRef::npos) {
-key.SetString(name.take_front(key_len));
+key = name.take_front(key_len);
 sub_name = name.drop_front(key_len);
   } else
-key.SetString(name);
+key = na

[Lldb-commits] [PATCH] D152476: [lldb] Remove lldb's DWARFAbbreviationDeclarationSet in favor of llvm's

2023-06-08 Thread Alex Langford via Phabricator via lldb-commits
bulbazord created this revision.
bulbazord added reviewers: JDevlieghere, aprantl, fdeazeve, rastogishubham, mib.
Herald added a project: All.
bulbazord requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

lldb's and llvm's implementations of DWARFAbbreviationDeclarationSet are
now close enough (almost the same, actually) to replace lldb's with
llvm's wholesale. llvm's is also tested against the same kinds of
scenarios that lldb's is tested against so we can remove lldb's tests
here. (see: llvm/unittests/DebugInfo/DWARF/DWARFDebugAbbrevTest.cpp).


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D152476

Files:
  lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugAbbrev.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugAbbrev.h
  lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
  lldb/unittests/SymbolFile/DWARF/SymbolFileDWARFTests.cpp

Index: lldb/unittests/SymbolFile/DWARF/SymbolFileDWARFTests.cpp
===
--- lldb/unittests/SymbolFile/DWARF/SymbolFileDWARFTests.cpp
+++ lldb/unittests/SymbolFile/DWARF/SymbolFileDWARFTests.cpp
@@ -16,7 +16,6 @@
 
 #include "Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.h"
 #include "Plugins/SymbolFile/DWARF/DWARFDataExtractor.h"
-#include "Plugins/SymbolFile/DWARF/DWARFDebugAbbrev.h"
 #include "Plugins/SymbolFile/DWARF/DWARFDebugArangeSet.h"
 #include "Plugins/SymbolFile/DWARF/DWARFDebugAranges.h"
 #include "Plugins/SymbolFile/DWARF/SymbolFileDWARF.h"
@@ -68,252 +67,6 @@
   EXPECT_EQ(expected_abilities, symfile->CalculateAbilities());
 }
 
-TEST_F(SymbolFileDWARFTests, TestAbbrevOrder1Start1) {
-  // Test that if we have a .debug_abbrev that contains ordered abbreviation
-  // codes that start at 1, that we get O(1) access.
-
-  const auto byte_order = eByteOrderLittle;
-  const uint8_t addr_size = 4;
-  StreamString encoder(Stream::eBinary, addr_size, byte_order);
-  encoder.PutULEB128(1); // Abbrev code 1
-  encoder.PutULEB128(DW_TAG_compile_unit);
-  encoder.PutHex8(DW_CHILDREN_yes);
-  encoder.PutULEB128(DW_AT_name);
-  encoder.PutULEB128(DW_FORM_strp);
-  encoder.PutULEB128(0);
-  encoder.PutULEB128(0);
-
-  encoder.PutULEB128(2); // Abbrev code 2
-  encoder.PutULEB128(DW_TAG_subprogram);
-  encoder.PutHex8(DW_CHILDREN_no);
-  encoder.PutULEB128(DW_AT_name);
-  encoder.PutULEB128(DW_FORM_strp);
-  encoder.PutULEB128(0);
-  encoder.PutULEB128(0);
-
-  encoder.PutULEB128(0); // Abbrev code 0 (termination)
-
-  DWARFDataExtractor data;
-  data.SetData(encoder.GetData(), encoder.GetSize(), byte_order);
-  DWARFAbbreviationDeclarationSet abbrev_set;
-  lldb::offset_t data_offset = 0;
-  llvm::Error error = abbrev_set.extract(data, &data_offset);
-  EXPECT_FALSE(bool(error));
-  // Make sure we have O(1) access to each abbreviation by making sure the
-  // index offset is 1 and not UINT32_MAX
-  EXPECT_EQ(abbrev_set.GetIndexOffset(), 1u);
-
-  auto abbrev1 = abbrev_set.GetAbbreviationDeclaration(1);
-  EXPECT_EQ(abbrev1->getTag(), DW_TAG_compile_unit);
-  EXPECT_TRUE(abbrev1->hasChildren());
-  EXPECT_EQ(abbrev1->getNumAttributes(), 1u);
-  auto abbrev2 = abbrev_set.GetAbbreviationDeclaration(2);
-  EXPECT_EQ(abbrev2->getTag(), DW_TAG_subprogram);
-  EXPECT_FALSE(abbrev2->hasChildren());
-  EXPECT_EQ(abbrev2->getNumAttributes(), 1u);
-}
-
-TEST_F(SymbolFileDWARFTests, TestAbbrevOrder1Start5) {
-  // Test that if we have a .debug_abbrev that contains ordered abbreviation
-  // codes that start at 5, that we get O(1) access.
-
-  const auto byte_order = eByteOrderLittle;
-  const uint8_t addr_size = 4;
-  StreamString encoder(Stream::eBinary, addr_size, byte_order);
-  encoder.PutULEB128(5); // Abbrev code 5
-  encoder.PutULEB128(DW_TAG_compile_unit);
-  encoder.PutHex8(DW_CHILDREN_yes);
-  encoder.PutULEB128(DW_AT_name);
-  encoder.PutULEB128(DW_FORM_strp);
-  encoder.PutULEB128(0);
-  encoder.PutULEB128(0);
-
-  encoder.PutULEB128(6); // Abbrev code 6
-  encoder.PutULEB128(DW_TAG_subprogram);
-  encoder.PutHex8(DW_CHILDREN_no);
-  encoder.PutULEB128(DW_AT_name);
-  encoder.PutULEB128(DW_FORM_strp);
-  encoder.PutULEB128(0);
-  encoder.PutULEB128(0);
-
-  encoder.PutULEB128(0); // Abbrev code 0 (termination)
-
-  DWARFDataExtractor data;
-  data.SetData(encoder.GetData(), encoder.GetSize(), byte_order);
-  DWARFAbbreviationDeclarationSet abbrev_set;
-  lldb::offset_t data_offset = 0;
-  llvm::Error error = abbrev_set.extract(data, &data_offset);
-  EXPECT_FALSE(bool(error));
-  // Make sure we have O(1) access to each abbreviation by making sure the
-  // index offset is 5 and not UINT32_MAX
-  EXPECT_EQ(abbrev_set.GetIndexOffset(), 5u);
-
-  auto abbrev1 = abbrev_set.GetAbbreviationDeclaration(5);
-  EXPECT_EQ(abbrev1->getTag(), DW_TAG_compile_unit);
-  EXPECT_TRUE(abbrev1->hasChildren());
-  EXPECT_EQ(abbrev1->getNumAttributes(),

[Lldb-commits] [PATCH] D151919: [lldb][NFCI] Apply IndexEntry to DWARFUnitHeader outside of extraction

2023-06-08 Thread Alex Langford via Phabricator via lldb-commits
bulbazord updated this revision to Diff 529769.
bulbazord added a comment.

Changed a bit of formatting to follow LLVM style more closely.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151919

Files:
  lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h

Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h
===
--- lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h
+++ lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h
@@ -75,6 +75,8 @@
   }
   uint32_t GetNextUnitOffset() const { return m_offset + m_length + 4; }
 
+  llvm::Error ApplyIndexEntry(const llvm::DWARFUnitIndex::Entry *index_entry);
+
   static llvm::Expected
   extract(const lldb_private::DWARFDataExtractor &data, DIERef::Section section,
   lldb_private::DWARFContext &dwarf_context,
Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
@@ -875,11 +875,37 @@
   return *m_func_aranges_up;
 }
 
-llvm::Expected
-DWARFUnitHeader::extract(const DWARFDataExtractor &data,
- DIERef::Section section,
- lldb_private::DWARFContext &context,
- lldb::offset_t *offset_ptr) {
+llvm::Error DWARFUnitHeader::ApplyIndexEntry(
+const llvm::DWARFUnitIndex::Entry *index_entry) {
+  // We should only be calling this function when the index entry is not set and
+  // we have a valid one to set it to.
+  assert(index_entry);
+  assert(!m_index_entry);
+
+  if (m_abbr_offset)
+return llvm::createStringError(
+llvm::inconvertibleErrorCode(),
+"Package unit with a non-zero abbreviation offset");
+
+  auto *unit_contrib = index_entry->getContribution();
+  if (!unit_contrib || unit_contrib->getLength32() != m_length + 4)
+return llvm::createStringError(llvm::inconvertibleErrorCode(),
+   "Inconsistent DWARF package unit index");
+
+  auto *abbr_entry = index_entry->getContribution(llvm::DW_SECT_ABBREV);
+  if (!abbr_entry)
+return llvm::createStringError(
+llvm::inconvertibleErrorCode(),
+"DWARF package index missing abbreviation column");
+
+  m_abbr_offset = abbr_entry->getOffset();
+  m_index_entry = index_entry;
+  return llvm::Error::success();
+}
+
+llvm::Expected DWARFUnitHeader::extract(
+const DWARFDataExtractor &data, DIERef::Section section,
+lldb_private::DWARFContext &context, lldb::offset_t *offset_ptr) {
   DWARFUnitHeader header;
   header.m_offset = *offset_ptr;
   header.m_length = data.GetDWARFInitialLength(offset_ptr);
@@ -903,42 +929,6 @@
 header.m_type_offset = data.GetDWARFOffset(offset_ptr);
   }
 
-  if (context.isDwo()) {
-const llvm::DWARFUnitIndex *Index;
-if (header.IsTypeUnit()) {
-  Index = &context.GetAsLLVM().getTUIndex();
-  if (*Index)
-header.m_index_entry = Index->getFromHash(header.m_type_hash);
-} else {
-  Index = &context.GetAsLLVM().getCUIndex();
-  if (*Index && header.m_version >= 5 && header.m_dwo_id)
-header.m_index_entry = Index->getFromHash(*header.m_dwo_id);
-}
-if (!header.m_index_entry)
-  header.m_index_entry = Index->getFromOffset(header.m_offset);
-  }
-
-  if (header.m_index_entry) {
-if (header.m_abbr_offset) {
-  return llvm::createStringError(
-  llvm::inconvertibleErrorCode(),
-  "Package unit with a non-zero abbreviation offset");
-}
-auto *unit_contrib = header.m_index_entry->getContribution();
-if (!unit_contrib || unit_contrib->getLength32() != header.m_length + 4) {
-  return llvm::createStringError(llvm::inconvertibleErrorCode(),
- "Inconsistent DWARF package unit index");
-}
-auto *abbr_entry =
-header.m_index_entry->getContribution(llvm::DW_SECT_ABBREV);
-if (!abbr_entry) {
-  return llvm::createStringError(
-  llvm::inconvertibleErrorCode(),
-  "DWARF package index missing abbreviation column");
-}
-header.m_abbr_offset = abbr_entry->getOffset();
-  }
-
   bool length_OK = data.ValidOffset(header.GetNextUnitOffset() - 1);
   bool version_OK = SymbolFileDWARF::SupportedVersion(header.m_version);
   bool addr_size_OK = (header.m_addr_size == 2) || (header.m_addr_size == 4) ||
@@ -968,11 +958,30 @@
DIERef::Section section, lldb::offset_t *offset_ptr) {
   assert(debug_info.ValidOffset(*offset_ptr));
 
-  auto expected_header = DWARFUnitHeader::extract(
-  debug_info, section, dwarf.GetDWARFContext(), offset_ptr);
+  DWARFContext &context = dwarf.GetDWARFContext();
+  auto expected_header =
+  DWARFUnitHeader::extract(debug_info, section, context, offset_ptr);
 

[Lldb-commits] [PATCH] D152494: [lldb][Android] Fix adb shell cat

2023-06-08 Thread Kazuki Sakamoto via Phabricator via lldb-commits
splhack created this revision.
splhack added a reviewer: clayborg.
Herald added a subscriber: danielkiss.
Herald added a project: All.
splhack edited the summary of this revision.
splhack added reviewers: labath, lanza.
splhack published this revision for review.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

When LLDB failed to pull a module file due to the security constraint,
it uses "adb shell cat" as a fallback for getting the file.
However when "adb pull path" fails, "adb shell cat path" also fails
with the same security reason.

Introduce ANDROID_PLATFORM_RUN_AS to grant permission to read the file
with "adb shell run-as package cat path" command line.
https://android.googlesource.com/platform/system/core.git/+/refs/heads/master/run-as/run-as.cpp#39


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D152494

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


Index: lldb/source/Plugins/Platform/Android/PlatformAndroid.cpp
===
--- lldb/source/Plugins/Platform/Android/PlatformAndroid.cpp
+++ lldb/source/Plugins/Platform/Android/PlatformAndroid.cpp
@@ -204,7 +204,11 @@
   AdbClient adb(m_device_id);
 
   char cmd[PATH_MAX];
-  snprintf(cmd, sizeof(cmd), "cat '%s'", source_file.c_str());
+  if (const char *run_as = std::getenv("ANDROID_PLATFORM_RUN_AS"))
+snprintf(cmd, sizeof(cmd), "run-as '%s' cat '%s'", run_as,
+ source_file.c_str());
+  else
+snprintf(cmd, sizeof(cmd), "cat '%s'", source_file.c_str());
 
   return adb.ShellToFile(cmd, minutes(1), destination);
 }
Index: lldb/docs/use/remote.rst
===
--- lldb/docs/use/remote.rst
+++ lldb/docs/use/remote.rst
@@ -140,6 +140,10 @@
 The client ports are configurable through the environment variables
 ANDROID_PLATFORM_LOCAL_PORT and ANDROID_PLATFORM_LOCAL_GDB_PORT, respectively.
 
+The "remote-android" platform requires ANDROID_PLATFORM_RUN_AS when target
+application install path is not accessible with "adb pull". LLDB will use
+"adb shell run-as $ANDROID_PLATFORM_RUN_AS cat path" to get module file.
+
 Launching a locally built process on the remote machine
 ---
 


Index: lldb/source/Plugins/Platform/Android/PlatformAndroid.cpp
===
--- lldb/source/Plugins/Platform/Android/PlatformAndroid.cpp
+++ lldb/source/Plugins/Platform/Android/PlatformAndroid.cpp
@@ -204,7 +204,11 @@
   AdbClient adb(m_device_id);
 
   char cmd[PATH_MAX];
-  snprintf(cmd, sizeof(cmd), "cat '%s'", source_file.c_str());
+  if (const char *run_as = std::getenv("ANDROID_PLATFORM_RUN_AS"))
+snprintf(cmd, sizeof(cmd), "run-as '%s' cat '%s'", run_as,
+ source_file.c_str());
+  else
+snprintf(cmd, sizeof(cmd), "cat '%s'", source_file.c_str());
 
   return adb.ShellToFile(cmd, minutes(1), destination);
 }
Index: lldb/docs/use/remote.rst
===
--- lldb/docs/use/remote.rst
+++ lldb/docs/use/remote.rst
@@ -140,6 +140,10 @@
 The client ports are configurable through the environment variables
 ANDROID_PLATFORM_LOCAL_PORT and ANDROID_PLATFORM_LOCAL_GDB_PORT, respectively.
 
+The "remote-android" platform requires ANDROID_PLATFORM_RUN_AS when target
+application install path is not accessible with "adb pull". LLDB will use
+"adb shell run-as $ANDROID_PLATFORM_RUN_AS cat path" to get module file.
+
 Launching a locally built process on the remote machine
 ---
 
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits