Visual Studio Breakpoint Macro to modify a value?(Visual Studio断点宏来修改一个值?)
问题描述
我正在调试一个应用程序 (C++),并且我在代码中找到了一个我想要更改值的点(通过调试器).所以现在,我已经设置了一个断点,我这样做了:
I'm debugging an application (C++), and I've found a point in the code where I want to change a value (via the debugger). So right now, I've got a breakpoint set, whereupon I do:
- 调试器到达断点
- 我修改了我想改变的变量
- 我按 F5 继续跑步
- 起泡、冲洗、重复
它经常碰到这个断点,所以我想自动化它.我想设置断点来运行宏,然后继续执行.
It's hitting this breakpoint a lot, so I would like to automate this. I would like to set the Breakpoint to run a macro, and continue execution.
但是,我没有编写 VisualStudio 宏的经验,所以我不知道修改执行程序变量的命令.我环顾四周,但到目前为止还没有在网上找到任何有用的东西.
However, I have no experience writing VisualStudio macros, so I don't know the commands for modifying a variable of the executing program. I've looked around, but haven't found anything helpful online so far.
推荐答案
我找到了如何使用宏来做到这一点.最初,我尝试使用 Ctrl-Shift-R 录制击键宏,但是当我执行 Ctrl-Alt-Q 时它停止录制.但我能够编辑宏以使其工作.所以这就是我所做的,以防其他人想做类似的事情.
I found how to do this with a macro. Initially, I tried using Ctrl-Shift-R to record a macro of keystrokes, but it stopped recording when I did Ctrl-Alt-Q. But I was able to edit the macro to get it to work. So here's what I did, in case anyone else wants to do something similar.
- 工具 -> 宏 -> 宏浏览器
右键->新建宏
- Tools -> Macros -> Macro Explorer
Right Click -> New macro
Public Module RecordingModule
Sub setvalue()
DTE.Debugger.ExecuteStatement("variable_name=0")
End Sub
End Module
此宏将执行赋值语句,设置我的变量(在本例中,将其设为 NULL 指针).
This macro will execute the assignment statement, setting my variable (in this case, making it a NULL pointer).
- 右键单击断点 -> 击中时...
- 选中运行宏"
- 选择
Macros.MyMacros.RecordingModule.setvalue
- 勾选继续执行"
- 点击确定
然后,我能够运行我的程序,自动调整指向 NULL 的指针.这对于测试非常有用,并且不需要重新编译.
Then, I was able to run my program, automatically adjusting a pointer to NULL as it went. This was very useful for testing, and did not require recompiling.
这篇关于Visual Studio断点宏来修改一个值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:Visual Studio断点宏来修改一个值?
- C++ 协变模板 2021-01-01
- 从python回调到c++的选项 2022-11-16
- 使用/clr 时出现 LNK2022 错误 2022-01-01
- 一起使用 MPI 和 OpenCV 时出现分段错误 2022-01-01
- 静态初始化顺序失败 2022-01-01
- 近似搜索的工作原理 2021-01-01
- Stroustrup 的 Simple_window.h 2022-01-01
- 与 int by int 相比,为什么执行 float by float 矩阵乘法更快? 2021-01-01
- STL 中有 dereference_iterator 吗? 2022-01-01
- 如何对自定义类的向量使用std::find()? 2022-11-07