首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >11 std显示wierd std::string (macOS)

11 std显示wierd std::string (macOS)
EN

Stack Overflow用户
提问于 2018-01-13 14:24:26
回答 1查看 330关注 0票数 0

要让lldb在CEF FileHandler中显示正确的字符串输出,我遇到了一些问题。

在调试此应用程序时,使用clang-5.0.1 (用brew语言安装)和调试器lldb构建:

代码语言:javascript
运行
复制
[ 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

消息来源是:

代码语言:javascript
运行
复制
std::string t = "client://executionGraph/index.html";
std::string temp = CefString(urlParts.path.str).ToString();

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

代码语言:javascript
运行
复制
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应用程序(如one 这里 )中,一切都正常工作,字符串也是正常格式化的。

另外,通过格式化程序代码加载type summary add -P std::__1::string也没有帮助!

任何帮助都是欢迎的!

fr v -R t输出

代码语言:javascript
运行
复制
(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
            }
          }
        }
      }
    }
  }
}
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2018-01-14 14:59:16

经过一些调试后,我发现是-fsanitize=address导致了这个问题:有了这些问题,调试就像预期的那样。这是个解决办法,我不知道怎么用消毒液.?

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/48240772

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档