Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LLDB: reference to std::pmr::deque<> incorrectly shows size zero #68396

Open
ByunghoonKim opened this issue Oct 6, 2023 · 4 comments
Open

LLDB: reference to std::pmr::deque<> incorrectly shows size zero #68396

ByunghoonKim opened this issue Oct 6, 2023 · 4 comments
Labels

Comments

@ByunghoonKim
Copy link

Hi,
LLDB does not seem to recognize std::pmr::deque<>. The symptom is identical to what is described in #62153.
Tested on MacBook Pro M1 Pro,

lldb-1500.0.22.8
Apple Swift version 5.9 (swiftlang-5.9.0.128.108 clang-1500.0.40.1)
❯ cat testing.cxx
#include <cstdio>
#include <memory_resource>
#include <deque>
typedef std::pmr::deque<int> int_deq;

int main() {
  char buffer[1024];
  std::pmr::monotonic_buffer_resource buf{buffer, 1024};

  int_deq numbers{&buf};
  printf("break here");

  (numbers.push_back(1));
  printf("break here");

  (numbers.push_back(12));
  (numbers.push_back(123));
  (numbers.push_back(1234));
  (numbers.push_back(12345));
  (numbers.push_back(123456));
  (numbers.push_back(1234567));

  numbers.clear();
  printf("break here");

  return 0;
}
❯ lldb a.out
(lldb) target create "a.out"
Current executable set to '(**blurred**)/a.out' (arm64).
(lldb) breakpoint set --line 14
Breakpoint 1: where = a.out`main + 136 at testing.cxx:14:3, address = 0x0000000100003d38
(lldb) run
Process 56671 launched: '(**blurred**)/a.out' (arm64)
Process 56671 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 1.1
    frame #0: 0x0000000100003d38 a.out`main at testing.cxx:14:3
   11  	 printf("break here");
   12  	
   13  	 (numbers.push_back(1));
-> 14  	 printf("break here");
   15  	
   16  	 (numbers.push_back(12));
   17  	 (numbers.push_back(123));
Target 0: (a.out) stopped.
(lldb) expr numbers
(int_deq) $0 = size=0 {}
(lldb) expr numbers.size()
(std::deque<int, std::pmr::polymorphic_allocator<int> >::size_type) $1 = 1
(lldb) 
@llvmbot
Copy link
Collaborator

llvmbot commented Oct 7, 2023

@llvm/issue-subscribers-lldb

Hi, LLDB does not seem to recognize std::pmr::deque<>. The symptom is identical to what is described in #62153. Tested on MacBook Pro M1 Pro, ``` lldb-1500.0.22.8 Apple Swift version 5.9 (swiftlang-5.9.0.128.108 clang-1500.0.40.1) ``` ``` ❯ cat testing.cxx #include <cstdio> #include <memory_resource> #include <deque> typedef std::pmr::deque<int> int_deq;

int main() {
char buffer[1024];
std::pmr::monotonic_buffer_resource buf{buffer, 1024};

int_deq numbers{&buf};
printf("break here");

(numbers.push_back(1));
printf("break here");

(numbers.push_back(12));
(numbers.push_back(123));
(numbers.push_back(1234));
(numbers.push_back(12345));
(numbers.push_back(123456));
(numbers.push_back(1234567));

numbers.clear();
printf("break here");

return 0;
}
❯ lldb a.out
(lldb) target create "a.out"
Current executable set to '(blurred)/a.out' (arm64).
(lldb) breakpoint set --line 14
Breakpoint 1: where = a.out`main + 136 at testing.cxx:14:3, address = 0x0000000100003d38
(lldb) run
Process 56671 launched: '(blurred)/a.out' (arm64)
Process 56671 stopped

  • thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 1.1
    frame #0: 0x0000000100003d38 a.out`main at testing.cxx:14:3
    11 printf("break here");
    12
    13 (numbers.push_back(1));
    -> 14 printf("break here");
    15
    16 (numbers.push_back(12));
    17 (numbers.push_back(123));
    Target 0: (a.out) stopped.
    (lldb) expr numbers
    (int_deq) $0 = size=0 {}
    (lldb) expr numbers.size()
    (std::deque<int, std::pmr::polymorphic_allocator<int> >::size_type) $1 = 1
    (lldb)
</details>

@Michael137
Copy link
Member

Michael137 commented Oct 7, 2023

As with #62153, std::pmr::deque uses the python formatter in synthetic applied to (int_deq) numbers is: Python class lldb.formatters.cpp.libcxx.stddeque_SynthProvider.

Looks like _get_value_of_compressed_pair isn't implemented correctly for compressed pairs instantiated with a pmr allocator

@Michael137
Copy link
Member

Apparently the problem is that with the allocator we now have an extra __compressed_pair_elem base also with a __value_ member. So when we do TypeSystemClang::GetIndexOfChildMemberWithName, we fail to find the __value_ in one of the bases, and then throw all results away because we deem it an invalid query. Will have to check why one of the base path queries fails

@xgupta
Copy link
Contributor

xgupta commented May 29, 2024

It is working on linux -

(lldb) expr numbers
(int_deq) $2 = size=1 {
  [0] = 1
}
(lldb) expr numbers.size()
(size_type) $3 = 1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants