调试器和可执行文件之间的命令行参数列表差异

发布于 2024-11-05 04:19:26 字数 485 浏览 0 评论 0原文

今天晚上我在某个敏感部位被它咬伤了,希望得到一些澄清。正如 karlphillip 在这个问题中所说,可执行文件将参数列表视为

Consider: ./program file.txt

argv[0] is "program"
argv[1] is "file.txt"

然而,在gdb调试器中,对于程序./lc1 f1.txt,arglist显示为

arg[0] is "/home/jason/Project 6/lc1"
arg[1] is "lc1"
arg[2] is "f1.txt"

Why the diffrepancy between the两个参数列表?

I had this bite me in a certain sensitive spot this evening, and would like some clarification. As karlphillip said in this question, the executable sees the argument list as

Consider: ./program file.txt

argv[0] is "program"
argv[1] is "file.txt"

However, in the gdb debugger, for the program ./lc1 f1.txt, the arglist shows as

arg[0] is "/home/jason/Project 6/lc1"
arg[1] is "lc1"
arg[2] is "f1.txt"

Why the discrepancy between the two arglists?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

玩心态 2024-11-12 04:19:26

我无法重现该错误。你如何在 gdb 提示符下运行它?

我猜你有

(gdb) run lc1 f1.txt

哪个是错误的。在 gdb 提示符中,应该是

(gdb) run f1.txt

这将与您的正常执行相一致。

I can't reproduce that error. How are you running it on the gdb prompt?

I'm guessing you have

(gdb) run lc1 f1.txt

which is wrong. In the gdb prompt, it's supposed to be

(gdb) run f1.txt

That will reconcile with your normal execution.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文