得之我幸 失之我命

when someone abandons you,it is him that gets loss because he lost someone who truly loves him but you just lost one who doesn’t love you.

gdb 打印变量类型和所在文件

1
2
3
4
5
6
7
8
9
10
11
12
struct child
{
char name[10];
};
struct child she = { "Jerry" };

int main()
{
static struct child she1 = { "Jerry1" };
struct child she2 = { "Jerry2" };
return 0;
}

查看变量的类型:

1
2
3
4
5
6
(gdb) whatis she
type = child
(gdb) whatis she1
type = child
(gdb) whatis she2
type = child

查看详细的类型信息:

1
2
3
4
5
6
7
8
9
10
11
12
(gdb) ptype she
type = struct child {
char name[10];
}
(gdb) ptype she1
type = struct child {
char name[10];
}
(gdb) ptype she2
type = struct child {
char name[10];
}

查看定义该变量的文件;gdb 会显示所有包含(匹配)该表达式的变量;info variables不会显示局部变量,即使是static的也没有太多的信息:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
(gdb) i variables she
All variables matching regular expression "she":

File 6.cpp:
8: child she;

File getusershell.c:
58: static char **curshell;
56: static const char *okshells[3];
58: static char **shells;

Non-debugging symbols:
0x0000555555558020 main::she1
(gdb) i variables she1
All variables matching regular expression "she1":

Non-debugging symbols:
0x0000555555558020 main::she1
(gdb) i variables she2
All variables matching regular expression "she2":

查看完全匹配给定名字的变量:

1
2
3
4
5
(gdb) i variables ^she$
All variables matching regular expression "^she$":

File 6.cpp:
8: child she;

be slow to promise and quick to perform.