Uploaded image for project: 'RHEL'
  1. RHEL
  2. RHEL-30148

GDB missing pretty-printers for swig-wrapped c++ library

    • Icon: Bug Bug
    • Resolution: Cannot Reproduce
    • Icon: Normal Normal
    • None
    • rhel-8.9.0
    • gdb
    • None
    • Low
    • rhel-sst-pt-perf-debug
    • ssg_platform_tools
    • 2
    • False
    • Hide

      None

      Show
      None
    • No
    • None
    • None
    • None
    • Unspecified Release Note Type - Unknown
    • x86_64
    • None

      What were you trying to do that didn't work?

      I was trying to debug a C++ library with the system tools (not a toolset).

      GDB only showed me the raw data for an STL container instead of the pretty-printed ones.

      A quick test with a 5 line program shows that it worked fine in that setting.

      My actual setting is a swig-wrapped c++ library.  I'm importing the library into python and stopping in the C++ code.  The pretty-printers were missing there.

      One more observation: if I start gdb on a simple test program and enter `info pretty-printers` before running the program, the pretty-printers aren't loaded.  They do appear to be loaded after the program starts running. 

      Is it possible that the hook to load the pretty-printers isn't triggered when the main debugged program is python instead of c++?

       

      Please provide the package NVR for which bug is seen:

      (watnlp) [jlquinn@bertdev01 engines]$ rpm -q gdb

      gdb-8.2-20.el8.x86_64

      How reproducible:

      It showed up for me debugging a python package swig-wrapped c++ library.  I had to manually import the pretty printers in .gdbinit.

      But it works fine with a standard c++ program on the command line.

      If I add the following to .gdbinit, then I get the pretty printers within the swig c++ library too:

      python
      import sys
      sys.path.insert(0, '/usr/share/gcc-8/python')
      from libstdcxx.v6.printers import register_libstdcxx_printers
      register_libstdcxx_printers (None)
      end

      Steps to reproduce

      1. Create a swig-wrapped c++ library
      2. Import into a conda python (I used 3.10.13)
      3. Run the python script in gdb
      4. break in the c++ library
      5. in gdb, print a vector<float>

      Expected results

      (gdb) p x
      $1 = std::vector of length 5, capacity 5 = {1, 2, 3, 4, 5}

      Actual results

      (gdb) p/r x
      $2 = {<std::Vector_base<float, std::allocator<float> >> = {_M_impl = {<std::allocator<float>> = {<_gnu_cxx::new_allocator<float>> =

      {<No data fields>}

      , <No data fields>}, 
            _M_start = 0x613eb0, _M_finish = 0x613ec4, _M_end_of_storage = 0x613ec4}}, <No data fields>}

       

      I used p/r here to duplicate it in a quick 5 line program.

              keiths@redhat.com Keith Seitz
              jlquinn Jerry Quinn (Inactive)
              Keith Seitz Keith Seitz
              qe-baseos-tools-bugs@redhat.com qe-baseos-tools-bugs@redhat.com qe-baseos-tools-bugs@redhat.com qe-baseos-tools-bugs@redhat.com
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

                Created:
                Updated:
                Resolved: