本文介绍了如何让gdb跟随execv?尽管“follow-exec-mode"无法工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我写了两个简单的程序:

i've written two simple programs:

int main(int ac, char **argv ) {
    execv( "/home/me/Desktop/execvtest2", argv );
}

int main(int ac, char **argv ) {
    execv( "/home/me/Desktop/execvtest1", argv );
}

我已经编译了它们gcc -g 到相应的输出文件.我正在使用 gcc (Ubuntu/Linaro 4.4.4-14ubuntu5.1) 4.4.5 运行 Ubuntu 10.10.

I've compiled them withgcc -g to the according outputfiles.I'm running Ubuntu 10.10 using gcc (Ubuntu/Linaro 4.4.4-14ubuntu5.1) 4.4.5.

当我使用 GNU gdb (GDB) 7.2-ubuntu 调试第一个程序时,我可以单步执行到第一个 execv 语句,但是这两个文件继续运行.即使我将 follow-exec-mode 设置为 new,我也无法进入第二个程序.当我设置 catch exec 时,gdb 会在每次调用 execv 时停止(因为第二个程序没有链接源,我无法退出 gdb,因为它有点挂起!?),但我不能跳过调用进入新"(因为 exec 替换进程)劣质程序.

When I'm debuging the first program with GNU gdb (GDB) 7.2-ubuntu, I can step until the first execv statement, but then the two files just keep running. Even if I set the follow-exec-mode to new, I can't step into the second program.When I set catch exec, gdb stops at each call to execv (some how without linked source for the second program, and I'm not able to quit gdb, as it kind of hangs!?), but I'm not able to step over the call into the "new" (as exec replaces the process) inferior program.

那么如何做到这一点呢?一定有办法进入新流程吧?我做错了吗?

So how can this be done? There must be a way to step into the new process right? Am I doing something wrong?

干杯

推荐答案

你可以使用catch"命令.这将使您有机会设置一些断点执行后

you can use "catch" command.this will give you chance to put some break pointsafter you exec

这篇关于如何让gdb跟随execv?尽管“follow-exec-mode"无法工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-02 03:08