Visual Studio 2010 调试 C++通过“附加到进程”的控制台应用程序
我想调试我的 C++ 应用程序。它需要一些命令行参数。我知道我可以在“项目属性”对话框中指定它们,但我正在考虑将调试器附加到我将用来运行程序的控制台进程。
这有可能吗?
当我尝试时,VS 不会加载符号(当前不会命中制动点。尚未为此文档加载任何符号。),即使我在 Debug->Options 中指定了符号目录并且设置。
活动配置是调试。使用 /ZI 编译并使用 /DEBUG 和 /ASSEMBLYDEBUG 链接。优化已禁用。
谢谢。
I would like to debug my C++ application. It takes a few command line arguments. I know I can specify them in the "Project Properties" dialogue, but I was thinking about attaching the debugger to a console process which I would use to run my program.
Is this possible at all?
When I try, VS does not load the symbols (The brakepoint will not currently be hit. No symbols have been loaded for this document.) even though I specify the symbol directory in Debug->Options and Settings.
Active configuration is Debug. Compiled with /ZI and linked with /DEBUG and /ASSEMBLYDEBUG. Optimization disabled.
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我认为你也可以动态地做到这一点。我分享 C++ 代码:
在开头附近的某个地方:
然后在主要部分的某个地方:
希望它会对某人有所帮助。
I think you can also do it dynamically. I share code for c++:
Somwhere near the beginning:
Then somhere in the main:
Hope it will help somebody.
“附加到进程”通常用于在程序运行后附加到程序。
听起来您正在尝试附加到将启动程序的命令提示符。这是一个不同的过程,当附加到 cmd.exe 时,您将收到各种警告,因为它不包含调试信息。
但是,如果启用了“同时调试子进程”选项,则一旦启动程序,调试器将在那时安装断点。
另请阅读:可以让 Visual Studio 进行调试吗像 WinDBG 这样的子进程?
"Attach to process" is usually used to attach to YOUR PROGRAM after it's already running.
It sounds like you are trying to attach to the command prompt which will launch your program. This is a different process, and when attaching to
cmd.exe
you will get all sorts of warnings because it does not include debug information.However, if you have the "also debug child processes" option enabled, once you start your program the debugger will install the breakpoints at that time.
Read also: Can Visual Studio be made to debug child processes like WinDBG?