GDB再学习(5.4):常用指令介绍_ptype/whatis_查看程序符号表



1 指令说明

ptype和whatis都可以用来查看符号表。

2 代码准备

使用如下代码进行测试

#include <stdio.h>
#include <string.h>
#include <signal.h>
#include <stdlib.h>

int j = 0;

int test2()
{
    
    
	char* s8Buf = NULL;
	
	strcpy(s8Buf, "8888");
	
	return 0;
}

int main()
{
    
    
	int i  = 0;
	
	for (i = 0; i < 60; i++)
	{
    
    
		j++;
		printf("-------->index %d\n", i);
		sleep(1);
	}

	test2();
	
	return 0;
}

3 指令测试

3.1 ptype xxx

xxx可以是变量、函数名、结构体等。

(gdb) ptype test2
type = int ()
(gdb) ptype j
type = int
(gdb) 

3.2 whatis xxx

xxx可以是变量、函数名、结构体等。

(gdb) whatis test2
type = int ()
(gdb) whatis j
type = int
(gdb) 

猜你喜欢

转载自blog.csdn.net/u011003120/article/details/109815848