lldb 显示奇怪 std::strings (macOS)

lldb shows wierd std::strings (macOS)

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

中显示正确的字符串输出

当我调试这个用 clang-5.0.1 (llvm 用 brew 安装) 使用调试器 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[=13=]p[=13=][=13=]\x10\x85\xac\a[=13=]p[=13=][=13=]�\a[=13=]p[=13=][=13=]\xa0\x83\xac\a[=13=]p[=13=][=13=]`\x83\xac\a[=13=]p[=13=][=13=]@"

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

同时加载 formatter code by 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] = '[=14=]'
              [4] = 'p'
              [5] = '[=14=]'
              [6] = '[=14=]'
              [7] = '\xb0'
              [8] = '\x81'
              [9] = '\xac'
              [10] = '\a'
              [11] = '[=14=]'
              [12] = 'p'
              [13] = '[=14=]'
              [14] = '[=14=]'
              [15] = '\x80'
              [16] = '\x80'
              [17] = '\xac'
              [18] = '\a'
              [19] = '[=14=]'
              [20] = 'p'
              [21] = '[=14=]'
              [22] = '[=14=]'
            }
          }
          __r = {
            __words = {
              [0] = 123145431056880
              [1] = 123145431056816
              [2] = 123145431056512
            }
          }
        }
      }
    }
  }
}

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