1
2
3
4
5
6
7
8
9
10
11
12
13
// Author: QianChenglong <qian_cheng_long@163.com>
// Create: 2016-09-01 17:51:59

#include <iostream>

#define STR "Hello world!\n"

int main(int argc, char* argv[])
{

std::cout << STR;

return 0;
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
gcc main.cpp -ggdb3
gdb a.out
(gdb) list
1 // Author: QianChenglong <qian_cheng_long@163.com>
2 // Create: 2016-09-01 17:51:59
3
4 #include <iostream>
5
6 #define STR "Hello world!\n"
7
8 int main(int argc, char* argv[])
9 {
10 std::cout << STR;
(gdb) print STR
$1 = "Hello world!\n"
(gdb) macro expand STR
expands to: "Hello world!\n"

参考

  1. https://gcc.gnu.org/onlinedocs/gcc-6.2.0/gcc/Debugging-Options.html#Debugging-Options

留言

2016-09-02