当该函数位于另一个文件夹中的另一个 c 程序中时,如何使用 gdb ddebugger 进入该函数?

How to step into a function with gdb ddebugger when that function is located in another c program that is located in another folder?

我有一个研究人员编写的 'c' 现有代码,我想对其进行调试。该项目是使用 MAkE 编译的。我正在尝试使用 gdb 调试器进行调试。 假设 'A' 文件夹包含“myproject.c”、“myproject”、MAKEFILE 和一些子文件夹 B、C、D 等。 现在我调试文件 gdb myproject.我在函数 1 处创建了断点。这个 function 1 位于文件夹 B 的文件 x.c 中。当我传递 step 命令时,它正在执行整个函数,但我想逐行查看它。

When I pass step command, it is executing the whole function but I want to see it line by line.

这意味着 x.c 编译时没有调试信息(没有 -g 标志)。

The Make File already has -g flag included

Makefile 有什么有点无关紧要。重要的是 make 构建编译 x.c.

的命令行

运行make clean all。那应该(假设 Makefile 正确)重建整个程序,重新编译 x.c。现在查看 用于编译x.c 的命令行。它不会有 -g 选项。您需要修改 Makefile 以使其生效。