当前位置: 首页 > news >正文

解决QTCreator在Debug时无法显示std::string类型的问题

环境:

操作系统:Ubuntu 20.04.6 LTS

QT版本:Qt Creator 4.11.0

问题:

Debug时,无法显示std::string类型的值,如下图:

解决方法:

修改/usr/share/qtcreator/debugger/stdtypes.py文件:

原代码:
def qdumpHelper_std__string(d, value, charType, format):if d.isQnxTarget():qdumpHelper__std__string__QNX(d, value, charType, format)returnif d.isMsvcTarget():qdumpHelper__std__string__MSVC(d, value, charType, format)returndata = value.extractPointer()# We can't lookup the std::string::_Rep type without crashing LLDB,# so hard-code assumption on member position# struct { size_type _M_length, size_type _M_capacity, int _M_refcount; }(size, alloc, refcount) = d.split("ppp", data - 3 * d.ptrSize())refcount = refcount & 0xffffffffd.check(refcount >= -1) # Can be -1 according to docs.d.check(0 <= size and size <= alloc and alloc <= 100*1000*1000)d.putCharArrayHelper(data, size, charType, format)修改为:
def qdumpHelper_std__string(d, value, charType, format):if d.isQnxTarget():qdumpHelper__std__string__QNX(d, value, charType, format)returnif d.isMsvcTarget():qdumpHelper__std__string__MSVC(d, value, charType, format)returndata = value.extractPointer()# We can't lookup the std::string::_Rep type without crashing LLDB,# so hard-code assumption on member position# struct { size_type _M_length, size_type _M_capacity, int _M_refcount; }(size, alloc, refcount) = d.split("ppp", value.address() + d.ptrSize())refcount = refcount & 0xffffffffd.check(refcount >= -1) # Can be -1 according to docs.if size > 4002:size = 4002d.putCharArrayHelper(data, size, charType, format)

保存后重新Debug,效果见下图:

http://www.lryc.cn/news/506230.html

相关文章:

  • leetcode 面试经典 150 题:无重复字符的最长子串
  • 0101多级nginx代理websocket配置-nginx-web服务器
  • 【前端】Jquery拍照,通过PHP将base64编码数据转换成PNG格式,并保存图像到本地
  • websocket再项目中的使用
  • ajax同步执行async:false无效的解决方法
  • 基于Qt的登陆界面设计
  • HarmonyOS 输入框组件:TextInput 和 TextArea 深度解析
  • 【Golang】 Go 语言中的 Struct、JSON 和 Map 互转:详细指南
  • Azure Function流式返回
  • 智能座舱进阶-应用框架层-Jetpack主要组件
  • GitLab分支管理策略和最佳实践
  • 【Unity】【VR开发】实现VR屏幕共享应用的几个重要插件和参考资料分享
  • 数据结构---------二叉树前序遍历中序遍历后序遍历
  • 浏览器引入elasticsearch-head插件
  • 【ELK】Filebeat采集Docker容器日志
  • 异步线程池与CountDownLatch
  • 在图像上显示掩码、框和点的通用函数
  • 基于Matlab的变压器仿真模型建模方法(11):三相三绕组换流变压器的建模仿真
  • 代码随想录算法训练营day46|动态规划part12
  • 【C语言】头文件
  • 蓝桥杯——竞赛省赛国赛题分享
  • 企业内训|阅读行业产品运营实战训练营-某运营商数字娱乐公司
  • 低空无人机产教融合技术详解
  • springboot中Controller内文件上传到本地以及阿里云
  • Chrome 132 版本开发者工具(DevTools)更新内容
  • 使用Python从阿里云物联网平台获取STM32温度数据
  • Spring Boot 声明式事务
  • websocket 局域网 webrtc 一对一 多对多 视频通话 的示例
  • uniapp-微信小程序调用摄像头
  • 鸿蒙学习笔记:用户登录界面