在GDB 里调用函数时,如果是一个指针类型参数,可以 call malloc 申请一个内存,再把这个内存传入参数即可,看 这里,如果参数是二级指针呢,该怎么传入呢?有以下代码
#include <stdio.h>
#include <stdlib.h>
#define RET_ERROR 1
#define RET_OK 0
struct LabelInfos
{
int index;
int label;
int type;
};
int getLabelInfo(struct LabelInfos **info)
{
struct LabelInfos *pInfo = calloc(1, sizeof(struct LabelInfos));
if(NULL == pInfo)
{
return RET_ERROR;
}
pInfo->index = 10;
pInfo->label = 1110;
pInfo->type = 0;
*info = pInfo;
return RET_OK;
}
int main()
{
struct LabelInfos *info = NULL;
if(RET_OK != getLabelInfo(&info))
{
return RET_ERROR;
}
printf("index: %d, label = %d, type = %d\n", info->index, info->label, info->type);
free(info);
return 0;
}
在 GDB 里要 call getLabelInfo() 该怎么做呢?
或者这样