简体   繁体   English

使用命令“s”时,GDB 不会进入函数

[英]GDB doesn't step into a function when use command “s”

I have a problem with GDB.我对 GDB 有问题。 When I use "s" to step into a function called from the main function, GDB jumps to another function without showing me the function that I need.当我使用“s”进入从main函数调用的函数时,GDB 跳转到另一个函数而不显示我需要的函数。

To be clear, I use step here:为了清楚起见,我在这里使用步骤:

In file main.c :在文件main.c 中

short c = get(a, b);

Now get has a 36 lines code and at line 27 it calls an other function "swap" here:现在 get 有一个 36 行代码,在第 27 行它在这里调用另一个函数“swap”:

In file get.s :在文件get.s 中

call _swap;

When I use step (s) with GDB on "get", it jumps all of the get function and it shows me the _swap function.当我在“get”上使用带有 GDB 的 step (s) 时,它会跳转所有get函数并向我显示_swap函数。 These are three different files: main.c , get.s , and *swap.c compiled in this way:这是三个不同的文件: main.cget.s和 *swap.c 以这种方式编译:

gcc -g -m32 main.c swap.c get.s -o IA-main

-m32 because get.s is IA-32 assembly. -m32 因为get.s是 IA-32 程序集。 Why does it jump the "get" function and show me only "_swap"?为什么它跳过“get”函数而只显示“_swap”?

I work on Mac OS X v10.12.6 (Sierra), so GDB is a little annoying.我在Mac OS X v10.12.6 (Sierra) 上工作,所以 GDB 有点烦人。

From Continuing and Stepping (emphasis mine)继续和步进(强调我的)

step

Continue running your program until control reaches a different source line, then stop it and return control to GDB.继续运行您的程序,直到控制权到达不同的源代码行,然后停止它并将控制权返回给 GDB。 This command is abbreviated s.该命令缩写为 s。

Warning: If you use the step command while control is within a function that was compiled without debugging information, execution proceeds until control reaches a function that does have debugging information.警告:如果在控制位于没有调试信息的情况下编译的函数内时使用 step 命令,则执行将继续进行,直到控制到达具有调试信息的函数。 Likewise, it will not step into a function which is compiled without debugging information.同样,它不会进入没有调试信息编译的函数。 To step through functions without debugging information, use the stepi command , described below.要在没有调试信息的情况下单步执行函数,请使用 stepi 命令,如下所述。

You can use the stepi command instead:您可以改用stepi命令:

stepi梯级

stepi arg梯级arg

si

Execute one machine instruction, then stop and return to the debugger.执行一条机器指令,然后停止并返回调试器。

It is often useful to do 'display/i $pc' when stepping by machine instructions.在按机器指令步进时执行 'display/i $pc' 通常很有用。 This makes GDB automatically display the next instruction to be executed, each time your program stops.这使得 GDB 在每次程序停止时自动显示下一条要执行的指令。 See Automatic Display.请参见自动显示。

An argument is a repeat count, as in step.参数是重复计数,如步骤。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM