如何以Visual Studio编程方式添加跟踪点? [英] How to programatically add a tracepoint for Visual Studio?

查看:452
本文介绍了如何以Visual Studio编程方式添加跟踪点?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一种方法来监视正在运行的程序,我有源代码。基本上,当用户运行它时,我需要知道什么函数和参数被顺序调用。

I am looking for a method to monitor a running program that I have the source code. Basically, when the user runs it, I need to know what functions and parameter is called sequentially.

我可以为所有函数写入跟踪输出代码来实现这一点。但是,我不允许修改源代码。
我发现Visual Studio 2005中的Tracepoint允许我这样做 - 输出日志信息而不修改源代码。但是我需要将它们添加到所有函数中。

I can write a trace output code to all functions to achieve this. However, I am not allowed to modify the source code. I found out that Tracepoint in Visual Studio 2005 allows me to do this - output log info without modifying the source. But I need to add them to all functions.

由于我有数千个文件和函数,我需要找到一种方式来编程。我发现可以添加断点的DTE.Debugger.Breakpoints.Add。但是,我找不到跟踪点的任何方式。或存储项目的断点信息在哪里?我找不到它在sln或vcproj。还是有办法通过程序方式将断点转换为跟踪点?我看到我可以通过更改当命中属性对话框手动更改它。

As I have thousands of files and functions, I need to find a way to programatically do this. I found out about DTE.Debugger.Breakpoints.Add that able to add a breakpoint. However, I couldnt find any way for tracepoint. Or where is the breakpoint info for a project stored? I couldnt find it in sln or vcproj. Or is there a way to convert breakpoint to tracepoint programatically? I see that I can change it manually by changing the "When Hit" property dialog.

谢谢!

推荐答案

您还可以查看Aspect Oriented coding 。根据我的理解,这将改变由属性控制的编译程序集,通常用于向所有方法/属性添加跟踪。

You could also look at Aspect Oriented coding. By my understanding this will change the compiled assembly controlled by attributes and is typically used to add tracing to all methods/properties.

如何在C#中的每个方法调用中添加一个Trace()? >

How can I add a Trace() to every method call in C#?

这篇关于如何以Visual Studio编程方式添加跟踪点?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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