lldb shows wierd std::strings (macOS)

感情迁移 提交于 2020-01-06 07:12:49

问题


I have some troubles getting lldb to show me a correct string output in my CEF FileHandler

When I debug this application built with clang-5.0.1 (llvm install with brew) with the debugger lldb:

[ 96%] Building CXX object gui/executionGraphGui/CMakeFiles/ExecutionGraphGUI.dir/cefapp/FileSchemeHandlerFactory.cpp.o
/usr/local/opt/llvm/bin/clang++   -I/Users/gabrielnuetzi/Desktop/ExecutionGraph/gui/executionGraphGui -I/Users/gabrielnuetzi/Desktop/ExecutionGraph/include -I/Users/gabrielnuetzi/Desktop/ExecutionGraph/build/include -I/usr/local/include/eigen3 -I/Users/gabrielnuetzi/Desktop/ExecutionGraph/build/src/meta/include -I/Users/gabrielnuetzi/Desktop/ExecutionGraph/build/external/args-src -I/Users/gabrielnuetzi/Desktop/ExecutionGraph/build/external/cefbinaries-src -I/Users/gabrielnuetzi/Desktop/ExecutionGraph/build/external/cefbinaries-src/include  -g -arch x86_64 -mmacosx-version-min=10.9   -std=c++14 -lc++experimental -ferror-limit=50 -Werror=return-type -g -g3 -fno-omit-frame-pointer -Weverything -Wpedantic -Wno-deprecated-register -Wno-documentation -Wno-old-style-cast -Wno-comment -Wno-float-equal -Wno-deprecated -Wno-c++98-compat-pedantic -Wno-undef -Wno-unused-macros -fsanitize=leak -fsanitize=address -o CMakeFiles/ExecutionGraphGUI.dir/cefapp/FileSchemeHandlerFactory.cpp.o -c /Users/gabrielnuetzi/Desktop/ExecutionGraph/gui/executionGraphGui/cefapp/FileSchemeHandlerFactory.cpp

The source is:

std::string t = "client://executionGraph/index.html";
std::string temp = CefString(urlParts.path.str).ToString();

I only see really weird output, such as:

Process 3741 stopped
* thread #22, name = 'Chrome_IOThread', stop reason = breakpoint 1.1
    frame #0: 0x000000010011eb09 ExecutionGraphGUI`FileSchemeHandlerFactory::Create(this=0x00006060000dc340, scheme_name=0x0000700007ac9c18, request=(ptr_ = 0x0000700007ac9c10)) at FileSchemeHandlerFactory.cpp:37
   34           ...
-> 37           std::string t = "client://executionGraph/index.html";
   38           ...

Process 3741 launched: '/Users/gabrielnuetzi/Desktop/ExecutionGraph/build/gui/executionGraphGui/Debug/ExecutionGraphGUI.app/Contents/MacOS/ExecutionGraphGUI' (x86_64)
(lldb) fr v t
(std::__1::string) t = "\x85\xac\a\0p\0\0\x10\x85\xac\a\0p\0\0�\a\0p\0\0\xa0\x83\xac\a\0p\0\0`\x83\xac\a\0p\0\0@"

Why this behavior?, or where could the problem be, wrong formatters? I have a really hard time to figure out why I cannot successfully debug theses strings in my application. The above example has been done by launching lldb from the terminal. In a normal main.cpp Application like the one here, everything works and the strings are formatted normally.

Also loading a formatter code by type summary add -P std::__1::string does not help!

Any help really welcome!

Output of fr v -R t:

(lldb) fr v -R t
(std::__1::string) t = {
  __r_ = {
    std::__1::__compressed_pair_elem<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::__rep, 0, false> = {
      __value_ = {
         = {
          __l = {
            __cap_ = 123145431056880
            __size_ = 123145431056816
            __data_ = 0x0000700007ac8080
          }
          __s = {
             = {
              __size_ = '\xf0'
              __lx = '\xf0'
            }
            __data_ = {
              [0] = '\x81'
              [1] = '\xac'
              [2] = '\a'
              [3] = '\0'
              [4] = 'p'
              [5] = '\0'
              [6] = '\0'
              [7] = '\xb0'
              [8] = '\x81'
              [9] = '\xac'
              [10] = '\a'
              [11] = '\0'
              [12] = 'p'
              [13] = '\0'
              [14] = '\0'
              [15] = '\x80'
              [16] = '\x80'
              [17] = '\xac'
              [18] = '\a'
              [19] = '\0'
              [20] = 'p'
              [21] = '\0'
              [22] = '\0'
            }
          }
          __r = {
            __words = {
              [0] = 123145431056880
              [1] = 123145431056816
              [2] = 123145431056512
            }
          }
        }
      }
    }
  }
}

回答1:


After some debugging I've found out that -fsanitize=address is causing this issue: With out these, the debugging is as expected. This is a workaround and I don't understand how to make it work with the sanitizers...?



来源:https://stackoverflow.com/questions/48240772/lldb-shows-wierd-stdstrings-macos

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!