Visual Studio断点宏修改值? [英] Visual Studio Breakpoint Macro to modify a value?

查看:221
本文介绍了Visual Studio断点宏修改值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在调试一个应用程序(C ++),并且我在代码中找到了一个要改变一个值的点(通过调试器)。所以现在我已经有一个断点集,所以我做:




  • 调试器到达断点

  • 我修改我想改变的变量

  • 我点击F5继续运行

  • 泡沫,冲洗,重复



它打破了这个断点,所以我想自动化这个。我想设置Breakpoint来运行宏,并继续执行。



但是,我没有写VisualStudio宏的经验,所以我不知道修改执行程序的变量。我已经环顾四周了,但到目前为止,还没有发现任何有用的在线。

解决方案

我发现如何使用宏。最初,我尝试使用Ctrl-Shift-R来记录击键宏,但是当我执行Ctrl-Alt-Q时,它停止录制。但是我可以编辑宏来使其工作。所以这是我做的,万一有人想做类似的事情。




  • 工具 - >宏 - >宏浏览器

  • 右键单击 - >新宏

     公共模块RecordingModule 
    子setvalue )
    DTE.Debugger.ExecuteStatement(variable_name = 0)
    End Sub
    结束模块




此宏将执行赋值语句,设置我的变量(在这种情况下,使其变为空指针)。




  • 右键点击BreakPoint - >点击时

  • 检查运行宏

  • 选择 Macros.MyMacros.RecordingModule.setvalue

  • 检查继续执行

  • 单击确定



然后,我能够运行我的程序,自动调整指向NULL的指针。这对于测试非常有用,并且不需要重新编译。


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:

  • Debugger reaches breakpoint
  • I modify the variable I want to change
  • I hit F5 to continue running
  • lather, rinse, repeat

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.

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.

解决方案

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
    

This macro will execute the assignment statement, setting my variable (in this case, making it a NULL pointer).

  • Right Click on a BreakPoint -> When Hit...
  • Check "Run a macro"
  • Select Macros.MyMacros.RecordingModule.setvalue
  • Check "Continue execution"
  • Click OK

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断点宏修改值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆