lldb显示了wierd std :: strings(macOS)

时间:2018-01-13 14:24:26

标签: c++ macos debugging c++14 lldb

我遇到了一些麻烦 lldb在我的CEF FileHandler

中显示正确的字符串输出

当我调试用这个构建的应用程序时 clang-5.0.1(用brew安装llvm) 使用调试器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

来源是:

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

我只看到非常奇怪的输出,例如:

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@"

为什么会出现这种情况?或问题出在哪里,格式化程序错误?我很难弄清楚为什么我无法在我的应用程序中成功调试这些字符串。 上面的例子是通过从终端启动lldb完成的。在正常的main.cpp应用程序中,如here, 一切正常,字符串格式正常。

同时加载formatter code type summary add -P std::__1::string没有帮助!

真的欢迎任何帮助!

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 个答案:

答案 0 :(得分:0)

经过一些调试后我发现了这一点 -fsanitize=address导致此问题:没有这些问题,调试就像预期的那样。这是一种解决方法,我不明白如何使其与消毒剂一起使用......?