调试器和可执行文件之间的命令行参数列表差异
今天晚上我在某个敏感部位被它咬伤了,希望得到一些澄清。正如 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我无法重现该错误。你如何在 gdb 提示符下运行它?
我猜你有
哪个是错误的。在 gdb 提示符中,应该是
这将与您的正常执行相一致。
I can't reproduce that error. How are you running it on the gdb prompt?
I'm guessing you have
which is wrong. In the gdb prompt, it's supposed to be
That will reconcile with your normal execution.