我一直在努力追查为什么在调试模式下调试我们的程序需要这么长时间.在使用xperf查看堆栈的外观后,显然我们在迭代器和STL容器中花费了大量的时间.我用谷歌搜索了一段时间,找到了选项
_HAS_ITERATOR_DEBUGGING=0
_SECURE_SCL=0
_SECURE_SCL_THROWS=0
Run Code Online (Sandbox Code Playgroud)
我用#define在代码中设置了所有这些
#define _HAS_ITERATOR_DEBUGGING 0
#define _SECURE_SCL 0
#define _SECURE_SCL_THROWS 0
Run Code Online (Sandbox Code Playgroud)
但这似乎不起作用,所以我尝试使用visual studio项目中的预处理器定义,但这似乎仍然没有帮助.
我已经尝试了几乎所有我能想到的排列,包括在标题中设置它们,以及所有包含之后,但无论我做什么,我都没有看到调试时性能提升.举个例子,当在发布模式下运行时,这一系列操作大约需要140秒.在调试模式下,它需要超过2,400秒.加工时间大约增加17-18倍.
一些额外的信息,托管这些C++ DLL的进程是一个C#.net 4进程,我启用了非托管代码调试.基本上所有进程都会为我们加载DLL.所有实际工作都是在c ++代码中完成的.
我在下面包含了完整的编译器命令行.
/I"..\CommonInclude" /Zi /nologo /W4 /WX /Od /Oy- /D "_CRT_SECURE_NO_WARNINGS" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_USRDLL" /D "ENGINE_EXPORTS" /D "_HAS_ITERATOR_DEBUGGING=0" /D "_SECURE_SCL=0" /D "_SECURE_SCL_THROWS=0" /D "_VC80_UPGRADE=0x0710" /D "_WINDLL" /D "_MBCS" /Gm- /EHa /MDd /GS /fp:precise /Zc:wchar_t- /Zc:forScope /GR /Yu"StdAfx.h" /Fp".\Debug/Foo.pch" /Fa".\Debug/" /Fo".\Debug/" /Fd".\Debug/" /Gd /analyze- /errorReport:queue /EHa -Zm350 /MP3
Run Code Online (Sandbox Code Playgroud)
任何想法为什么会这么慢?
当我尝试在与当前启动项目链接的静态库中查看某些变量时,我收到此错误:
CXX0017: Error: symbol not found
Run Code Online (Sandbox Code Playgroud)
我试图重建项目/关闭IDE,但我有同样的错误.我可以使用断点/步/其他功能.
你知道为什么会这样吗?也许是一些奇怪的编译器标志或者......
编辑:只能在调试器中查看某些变量!一般局部变量.
debugging visual-studio-2010 visual-studio visual-studio-debugging
我已经知道Debugger.IsAttached确定我的应用程序当前是否正在运行时进行调试.如何确定调试器本身的更多信息?
例如,如何区分从Visual Studio调试的应用程序和WinDbg调试的应用程序?
在我的方案中,应用程序不是从Visual Studio启动的.调试器可以附加到已经运行的进程.
有时,您实际上并不在乎变量的名称,因为它不会超出您的子范围。实际上,指定名称会增加一行代码。同样,您现在也要使用该名称,这可能会增加潜在的重构工作(如果您以后决定重命名)。看下面的代码:
Dim fileInfo As New FileInfo("filename.txt")
With New FileSystemWatcher
.Path = fileInfo.DirectoryName
.Filter = fileInfo.Name
.EnableRaisingEvents = True
AddHandler .Changed, AddressOf OnChanged
End With
Run Code Online (Sandbox Code Playgroud)
这是一个完全有效的VB.NET构造,看起来整洁干净。但是,在进行调试时,假设您在该With子句中放置了一个断点,则没有办法抓住它.Path来确保已正确设置它。
我在这里缺少任何内容吗,还是Visual Studio确实不为.Property语句内部的语法提供调试With?我正在使用2010。
显然,上面的代码中没有太多要调试的东西,但是有很多例子说明这种无名 With方法何时会派上用场。
顺便说一句,命名With子句有同样的问题,即如果我要写的话:
Dim fsw As New FileSystemWatcher
With fsw
.Path = fileInfo.DirectoryName
.Filter = fileInfo.Name
.EnableRaisingEvents = True
AddHandler .Changed, AddressOf OnChanged
End With
Run Code Online (Sandbox Code Playgroud)
我仍然无法提取的值.Path,而必须始终以为其前缀fsw。
当您将With子句彼此嵌套时,问题的规模会越来越大。
vb.net visual-studio-2010 with-statement visual-studio-debugging
从Visual Studio 2012中删除了群集调试选项.那么有没有办法在VS2012中调试MPI应用程序?
我保留的一些遗留代码卡在无限循环中(因此我自己似乎在一个); 但是,我无法弄清楚为什么/如何.
这是应用程序的入口点,它实例化主窗体(frmCentral):
代码展览A.
public static int Main(string [] args)
{
try
{
AppDomain currentDomain = AppDomain.CurrentDomain;
currentDomain.UnhandledException += new UnhandledExceptionEventHandler(GlobalExceptionHandler);
string name = Assembly.GetExecutingAssembly().GetName().Name;
MessageBox.Show(string.Format("Executing assembly is {0}", name)); // TODO: Remove after testing <= this one is seen
IntPtr mutexHandle = CreateMutex(IntPtr.Zero, true, name);
long error = GetLastError();
MessageBox.Show(string.Format("Last error int was {0}", error.ToString())); // TODO: Remove after testing <= this one is also seen
if (error == ERROR_ALREADY_EXISTS)
{
ReleaseMutex(mutexHandle);
IntPtr hWnd = FindWindow("#NETCF_AGL_BASE_", null);
if ((int) …Run Code Online (Sandbox Code Playgroud) c# messagebox infinite-loop mutual-recursion visual-studio-debugging
请问#ifdef _DEBUG在主要功能有任何意义,如果我在工作的Visual Studio 2013?
如果是,那是为了什么?
int _tmain(int argc, _TCHAR* argv[])
{
#ifdef _DEBUG
//creating some objects, using functions etc;
#endif
}
Run Code Online (Sandbox Code Playgroud) 如何在抛出异常时阻止调试器输入我的方法,而是在方法的调用站点上显示异常?
例如,如果一个代码导致从mscorlib抛出异常,则调试器(显然)不会将它们带入非用户代码以显示异常的源,只显示调用站点的异常.
换句话说,这是默认行为:
这是我想要的行为:
我试过添加[DebuggerNonUserCode]和[DebuggerStepThrough]属性到我的Fail()方法,但没有运气.
我目前正在开发Xamarin表单应用程序,并且它的iOS组件很难调试,因为每当我按下iPhone上的锁定按钮时,调试器就会分离。
此外,根据https://forums.xamarin.com/discussion/12020/attach-debugger-to-running-app,似乎没有办法将调试器附加到Xamarin iOS / Android进程
任何帮助将不胜感激。谢谢。
xamarin.ios visual-studio-debugging xamarin xamarin.forms visual-studio-mac
我正在尝试调试(命中断点)一个python脚本,它通过C#中的新进程执行.
我已经安装了Child Process Debugging Power工具,因为该工具据说允许人们这样做.
根据其文档,它需要两件事:
我的流程创建如下:
ProcessStartInfo startInfo = new ProcessStartInfo();
Process p = new Process();
startInfo.CreateNoWindow = true;
startInfo.UseShellExecute = false;
startInfo.RedirectStandardOutput = false;
startInfo.RedirectStandardError = true;
startInfo.RedirectStandardInput = false;
...
p.StartInfo = startInfo;
p.EnableRaisingEvents = true;
p.Start();
Run Code Online (Sandbox Code Playgroud)
据我所知,只要我使用
UseShellExecute = false;
Run Code Online (Sandbox Code Playgroud)
应该使用CreateProcess启动该过程.(要求2)
在我的项目中,我还启用了本机代码调试.(Req.1)
我还在我的符号列表中包含了python.pdb和python36.pdb.但似乎我找不到python3.pdb
'python.exe' (Win32): Loaded 'C:\...\Python36\python.exe'. Symbols loaded.
'python.exe' (Win32): Loaded 'C:\...\Python36\python36.dll'. Symbols loaded.
'python.exe' (Win32): Loaded 'C:\...\python3.dll'. Cannot find or open the PDB file.
Run Code Online (Sandbox Code Playgroud)
当我使用调试符号安装python时,这不包括在内,我似乎没有在其他任何地方找到它.
我正在使用2017年的视觉工作室,没有断点被击中.