我正在尝试调试一个C程序,gdb告诉我在某个函数的第329行发生了段错误。因此,我为该函数设置了断点,并试图逐步执行它。然而,每当我到达第68行时,gdb都会出现以下投诉:
(gdb) step
68 next_bb = (basic_block *)malloc(sizeof(basic_block));
(gdb) step
*__GI___libc_malloc (bytes=40) at malloc.c:3621
3621 malloc.c: No such file or directory.
in malloc.c
我不知道这是什么意思。程序在除了一个输入集之外的所有情况下都能完美运行,因此在程序的其他执行过程中,这个调用malloc显然是成功的。当然,我已经:
#include <stdlib.h>.
以下是源代码:
// Block currently being built.
basic_block *next_bb = NULL;
// Traverse the list of instructions in the procedure.
while (curr_instr != NULL)
{
simple_op opcode = curr_instr->opcode;
// If we are not currently building a basic_block then we must start a new one.
// A new block can be started with any kind of instruction.
if (!in_block)
{
// Create a new basic_block.
next_bb = (basic_block *)malloc(sizeof(basic_block));
malloc
函数的源代码在gdb
中怎么样?我们该如何做到这一点? - Paschalis