简介: CSDN博客专家,专注Android/Linux系统,分享多mic语音方案、音视频、编解码等技术,与大家一起成长!
优质专栏:Audio工程师进阶系列【原创干货持续更新中……】🚀
人生格言: 人生从来没有捷径,只有行动才是治疗恐惧和懒惰的唯一良药.
1.前言
本篇目的:GDB之修改字符串的值
2.调试实例
1 #include <cstdio>
2 #include <string>
3
4 int main(void){
5 std::string buf1 = "Hello";
6 std::string buf2 = "World";
7
8 printf("buf1 is %s, buf2 is %s\n", buf1.c_str(), buf2.c_str());
9 return 0;
10 }
调试过程
(gdb) r
Starting program: ~/test
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
Breakpoint 1, main () at test.cpp:4
4 int main(void){
(gdb) n
5 std::string buf1 = "Hello";
(gdb) call buf1
$1 = ""
(gdb) p buf1
$2 = ""
(gdb) n
6 std::string buf2 = "World";
(gdb) p buf1
$3 = "Hello"
(gdb) call buf1.assign("TOM CAT")
$4 = "TOM CAT"
(gdb) p buf1
$5 = "TOM CAT"
- 1.使用 call buf1.assign(“TOM CAT”)修改
- 2.使用 set main::count=123 (假如有此int变量)