Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.

Bug 2082508

Summary: lldb don't print std::vector variables correctly
Product: Red Hat Enterprise Linux 8 Reporter: Jesus Checa <jchecahi>
Component: lldbAssignee: Timm Bäder <tbaeder>
Status: CLOSED ERRATA QA Contact: Jesus Checa <jchecahi>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 8.7CC: jchecahi, jistone, mprchlik, sipoyare, tbaeder, tstellar
Target Milestone: rcKeywords: Bugfix, Triaged
Target Release: ---Flags: pm-rhel: mirror+
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: llvm-toolset:rhel8:8070020220608151004:3b9f49c4 Doc Type: No Doc Update
Doc Text:
Story Points: ---
Clone Of: 2077932 Environment:
Last Closed: 2022-11-08 09:34:58 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On: 2077932    
Bug Blocks:    

Description Jesus Checa 2022-05-06 09:48:15 UTC
+++ This bug was initially created as a clone of Bug #2077932 +++

Description of problem:
lldb prints std::vector variables as if they had size 0. Given the  following reproducer:
// test.cpp
#include <stdio.h>
#include <vector>
int
main ()
{
  std::vector<int> v (1, 2);
  std::vector<int>::iterator it(v.begin());
  return 0;
}

When printing the variable "v" with lldb, it should show size=1 and the value of the elements inside the vector (in this case, "[0] = 2"). Instead, lldb prints a vector with size 0 and no elements.

Version-Release number of selected component (if applicable):
* llvm-toolset-14.0-lldb-14.0.0-1
* llvm-toolset-14.0-python3-lldb-14.0.0-1

How reproducible:
100%

Steps to Reproduce:
1. g++ -g test.cpp
2. lldb -b -o 'breakpoint set --file test.cpp --line 7' -o run -o 'p v' -- a.out

Actual results:
(lldb) p v
(std::vector<int, std::allocator<> >) $0 = size=0 {}

Expected results:
(lldb) p v
(std::vector<int, std::allocator<> >) $0 = size=1 {
  [0] = 2
}


Additional info:
Found by this testcase https://src.fedoraproject.org/rpms/lldb/blob/rawhide/f/tests/python-embedded-interpreter

Tested with llvm-toolset-13.0-lldb-13.0.1-1, using the same binary (no recompiled), in the same system/environment, and the issue does not reproduce.

Comment 1 Timm Bäder 2022-06-07 14:52:01 UTC
The output is actually using lldb's pretty printer for libstdc++, which says:

# C++ STL formatters for LLDB
# As there are many versions of the libstdc++, you are encouraged to look at the STL
# implementation for your platform before relying on these formatters to do the right
# thing for your setup

When compiling the reproducer with clang, dwarfdump reports results for _Vector_impl_data:

                          DW_AT_name                  _Vector_impl_data
                            DW_AT_name                  _Vector_impl_data
                            DW_AT_name                  _Vector_impl_data
                            DW_AT_linkage_name          _ZNSt12_Vector_baseIiSaIiEE17_Vector_impl_data12_M_copy_dataERKS2_
                            DW_AT_linkage_name          _ZNSt12_Vector_baseIiSaIiEE17_Vector_impl_data12_M_swap_dataERS2_
                      DW_AT_linkage_name          _ZNSt12_Vector_baseIiSaIiEE17_Vector_impl_dataC2Ev
name at offset 0x00000654, length   17 is '_Vector_impl_data'
name at offset 0x00000666, length   66 is '_ZNSt12_Vector_baseIiSaIiEE17_Vector_impl_data12_M_copy_dataERKS2_'
name at offset 0x000006b6, length   65 is '_ZNSt12_Vector_baseIiSaIiEE17_Vector_impl_data12_M_swap_dataERS2_'
name at offset 0x00001f56, length   50 is '_ZNSt12_Vector_baseIiSaIiEE17_Vector_impl_dataC2Ev'


but when it's compiled with g++, no such results are found.

I think this is just an incompatibility between the lldb pretty-printer and what libstdc++/gcc emit. Or maybe a bug in gcc 8.5,
since compiling it with clang yields the expected (by the pretty-printer) result.

Comment 3 Jesus Checa 2022-06-16 10:00:30 UTC
Tested with llvm-toolset:rhel8:8070020220608151004:3b9f49c4. After disabling the pretty printer, the output from lldb with the test.cpp file from the description is as follows:
===============================================================================
(lldb) target create "a.out"
Current executable set to '/var/tmp/tmt/run-139/tests/build-gating/discover/lldb-tests/tests/tests/python-embedded-interpreter/a.out' (s390x).
(lldb) breakpoint set --file test.cpp --line 7
Breakpoint 1: where = a.out`main + 94 at test.cpp:7:41, address = 0x0000000001000876
(lldb) run
Process 35430 stopped
* thread #1, name = 'a.out', stop reason = breakpoint 1.1
    frame #0: 0x0000000001000876 a.out`main at test.cpp:7:41
   4   	main ()
   5   	{
   6   	  std::vector<int> v (1, 2);
-> 7   	  std::vector<int>::iterator it(v.begin());
    	                                        ^
   8   	  return 0;
   9   	}
Process 35430 launched: '/var/tmp/tmt/run-139/tests/build-gating/discover/lldb-tests/tests/tests/python-embedded-interpreter/a.out' (s390x)
(lldb) p v
(std::vector<int, std::allocator<> >) $0 = error: summary string parsing error {
  std::_Vector_base<int, std::allocator<> > = {
    _M_impl = {
      _M_start = 0x0000000001015eb0
      _M_finish = 0x0000000001015eb4
      _M_end_of_storage = 0x0000000001015eb4
    }
  }
}
===============================================================================

Complete testing shows no regressions.

Comment 8 errata-xmlrpc 2022-11-08 09:34:58 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (llvm-toolset:rhel8 bug fix and enhancement update), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2022:7537