Debug print std::string with gdb with Chrome under Chrome OS

314 views
Skip to first unread message

Kush Sinha

unread,
Feb 2, 2018, 10:02:06 AM2/2/18
to Chromium-dev, Chromium OS dev
I am trying to debug Chrome under Chrome OS (Simple Chrome) and following https://chromium.googlesource.com/chromiumos/docs/+/master/simple_chrome_workflow.md#Debugging 

When I try to print std::string in gdb:
(gdb) print primary_account_
I get:
$1 = {
  <std::__1::__basic_string_common<true>> = {<No data fields>}, 
  members of std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >: 
  __r_ = {
    <std::__1::__libcpp_compressed_pair_imp<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::__rep, std::__1::allocator<char>, 2>> = {
      <std::__1::allocator<char>> = {<No data fields>}, 
      members of std::__1::__libcpp_compressed_pair_imp<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::__rep, std::__1::allocator<char>, 2>: 
      __first_ = {
        {
          __l = {
            __cap_ = 0, 
            __size_ = 0, 
            __data_ = 0x0
          }, 
          __s = {
            {
              __size_ = 0 '\000', 
              __lx = 0 '\000'
            }, 
            __data_ = '\000' <repeats 22 times>
          }, 
          __r = {
            __words = {0, 0, 0}
          }
        }
      }
    }, <No data fields>}, 
  static npos = 18446744073709551615
}

When I do:
(gdb) print primary_account_.c_str()
I get:
Cannot evaluate function -- may be inlined


Relevant gn args:
is_debug = true                                                                 
is_component_build = false                                                      
is_official_build = false                                                       
remove_webcore_debug_symbols = true                                             
use_debug_fission = false

Also, from the instructions above, when I remotely connect to my Chromebook, I get warnings of the form of:
warning: .dynamic section for "[REDACTED]/chromium/.cros_cache/chrome-sdk/tarballs/sand+10333.0.0+sysroot_chromeos-base_chromeos-chrome.tar.xz/usr/lib64/libcups.so.2" is not at the expected address (wrong library or version mismatch?)

Has anyone run into this before?

sin...@chromium.org

unread,
Feb 5, 2018, 8:51:48 AM2/5/18
to Chromium OS dev, chromi...@chromium.org
Figured it out. I was trying to use libstdc++ pretty printers. Chromium uses libc++.

Here is a set of macros that work https://github.com/koutheir/libcxx-pretty-printers 
Reply all
Reply to author
Forward
0 new messages