WinDbg环境变量
当使用WinDbg调试可执行文件时,有没有办法指定在调试开始之前运行的批处理脚本来为调试会话设置环境变量?
我正在尝试模拟将运行此可执行文件的自动化测试环境。这些变量包含诸如当前版本号、结果目录所在以及第 3 方工具目录所在位置等信息。我可以将它们硬编码到应用程序中以进行我自己的测试,但这很丑陋:)。
这当然是在 Windows 操作系统上,我宁愿不使用不同的调试器。
如果 WinDbg 不直接支持此功能,那么实现此功能的最佳方法是什么?
When using WinDbg to debug an executable, is there a way to specify a batch script to run before debugging starts to set up environmental variables for the debug session?
I'm attempting to mimic an automated test environment where this executable will run. The variables contain information like what the current build number is, where the results directory is and where the 3rd party tools directory is located. I could hard-code these into the application for my own testing, but that's ugly :).
This is of course on a Windows OS, and I would rather not use a different debugger.
If WinDbg doesn't support this directly, what is the best way to achieve this functionality?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
WinDbg 的
-o
选项使其自动附加到所有子进程,这对于调试从另一个程序启动的程序非常有用。如果您运行windbg -o cmd.exe /c myscript.bat
,WinDbg 将调试cmd.exe
(您可以跳过)以及由其生成的每个子进程cmd.exe
的实例。如果批处理文件在运行您要调试的命令之前运行许多其他命令,但sx*
命令(例如sxn ibp
; >sxe ld:mymodule) 应该能够减少烦恼。另一种方法是在每次启动 EXE 时使用
Image File Execution Options
注册表项附加 WinDbg(或 cdb/ntsd)。WinDbg's
-o
option causes it to automatically attach to all child processes, which is useful for debugging a program that is launched from another program. If you runwindbg -o cmd.exe /c myscript.bat
, WinDbg will debugcmd.exe
(which you can skip over) as well as every child process spawned by that instance ofcmd.exe
. This might be annoying if the batch file runs a lot of other commands before running the one that you want to debug, but thesx*
commands (e.g.sxn ibp
;sxe ld:mymodule
) ought to be able to reduce the annoyance.Another approach is to use the
Image File Execution Options
registry key to attach WinDbg (or cdb/ntsd) whenever your EXE is launched.