MSVC 2008,调试过程,无法调试

MSVC 2008, debugging process, can't debug

我已经在这个项目上工作了一段时间,它是一个遗留的 DLL,我的职责是使其适应新版本的库。

我向属性/C/C++/预处理器/预处理器定义中定义的构建添加了一个定义

我添加的定义称为 CLSOPENLDV,该行如下所示:

    CLSOPENLDV;SP_DEBUG;WIN32;_WINDOWS;_USRDLL;

这用于工作,在我的代码中我使用定义来测试和切换进出代码:

    #pragma once

    #if defined(CLSOPENLDV) && !defined(CLSOPENLDV_H)
        #define CLSOPENLDV_H
        #pragma comment(lib, "ldv32")
        ...
    #endif

这一切都过去了,上周我不得不切换回原始版本,这是一个从属性中删除常量的简单案例,但现在我想回到原来的位置,出于某种原因我不能,即使常量返回到属性中,构建也无法识别预处理器,代码在上面的 #if defined 测试中呈灰色,我真的不确定为什么?

会不会和预编译头文件(pch)有关?

[编辑] 实际上这个问题并不是 CLSOPENLDV 独有的,另一个定义 SP_DEBUG 也没有进入构建,这个定义包含的调试语句的 none 是已启用。

[Edit2] 我已经在调试器中设置了断点,但它也没有到达这些断点,这一切都在工作,但从根本上被破坏或禁用了。

[Edit3] 这是一个比我最初认为的更根本的问题我根本无法调试项目...我附加到进程,但 none 我的断点曾经被击中。我在“输出”窗格中看到很多首次更改异常,但不知道在哪里查看,因为它只提供了地址。

[Edit4] 仍在尝试弄清楚发生了什么,下面是 运行 DLL 时的转储,我所做的唯一修改是调试/异常/C++ 异常,我选中了抛出复选框, 所以它现在停止并在第一个异常时出现异常对话框:

'Edwards.Scada.AgentService.exe': Loaded 'C:\Program Files\Edwards\Agent Service\Edwards.Scada.AgentService.exe', Binary was not built with debug information. 'Edwards.Scada.AgentService.exe': Loaded 'C:\Windows\System32\ntdll.dll' 'Edwards.Scada.AgentService.exe': Loaded 'C:\Windows\System32\mscoree.dll' 'Edwards.Scada.AgentService.exe': Loaded 'C:\Windows\System32\kernel32.dll' 'Edwards.Scada.AgentService.exe': Loaded 'C:\Windows\System32\KernelBase.dll' 'Edwards.Scada.AgentService.exe': Loaded 'C:\Windows\System32\apphelp.dll' 'Edwards.Scada.AgentService.exe': Loaded 'C:\Windows\apppatch\AcLayers.dll' 'Edwards.Scada.AgentService.exe': Loaded 'C:\Windows\System32\msvcrt.dll' 'Edwards.Scada.AgentService.exe': Loaded 'C:\Windows\System32\user32.dll' 'Edwards.Scada.AgentService.exe': Loaded 'C:\Windows\System32\gdi32.dll' 'Edwards.Scada.AgentService.exe': Loaded 'C:\Windows\System32\shell32.dll' 'Edwards.Scada.AgentService.exe': Loaded 'C:\Windows\System32\cfgmgr32.dll' 'Edwards.Scada.AgentService.exe': Loaded 'C:\Windows\System32\windows.storage.dll' 'Edwards.Scada.AgentService.exe': Loaded 'C:\Windows\System32\combase.dll' 'Edwards.Scada.AgentService.exe': Loaded 'C:\Windows\System32\rpcrt4.dll' 'Edwards.Scada.AgentService.exe': Loaded 'C:\Windows\System32\bcryptprimitives.dll' 'Edwards.Scada.AgentService.exe': Loaded 'C:\Windows\System32\advapi32.dll' 'Edwards.Scada.AgentService.exe': Loaded 'C:\Windows\System32\sechost.dll' 'Edwards.Scada.AgentService.exe': Loaded 'C:\Windows\System32\shlwapi.dll' 'Edwards.Scada.AgentService.exe': Loaded 'C:\Windows\System32\kernel.appcore.dll' 'Edwards.Scada.AgentService.exe': Loaded 'C:\Windows\System32\SHCore.dll' 'Edwards.Scada.AgentService.exe': Loaded 'C:\Windows\System32\powrprof.dll' 'Edwards.Scada.AgentService.exe': Loaded 'C:\Windows\System32\profapi.dll' 'Edwards.Scada.AgentService.exe': Loaded 'C:\Windows\System32\oleaut32.dll' 'Edwards.Scada.AgentService.exe': Loaded 'C:\Windows\System32\setupapi.dll' 'Edwards.Scada.AgentService.exe': Loaded 'C:\Windows\System32\mpr.dll' 'Edwards.Scada.AgentService.exe': Loaded 'C:\Windows\System32\sfc.dll' 'Edwards.Scada.AgentService.exe': Loaded 'C:\Windows\System32\winspool.drv' 'Edwards.Scada.AgentService.exe': Loaded 'C:\Windows\System32\bcrypt.dll' 'Edwards.Scada.AgentService.exe': Loaded 'C:\Windows\System32\sfc_os.dll' 'Edwards.Scada.AgentService.exe': Loaded 'C:\Windows\Microsoft.NET\Framework\v4.0.30319\mscoreei.dll' 'Edwards.Scada.AgentService.exe': Loaded 'C:\Windows\System32\version.dll' 'Edwards.Scada.AgentService.exe': Loaded 'C:\Windows\Microsoft.NET\Framework\v4.0.30319\clr.dll' 'Edwards.Scada.AgentService.exe': Loaded 'C:\Windows\System32\msvcr120_clr0400.dll' 'Edwards.Scada.AgentService.exe': Loaded 'C:\Windows\assembly\NativeImages_v4.0.30319_32\mscorlib57de2c799b00351885b50b15ee8582\mscorlib.ni.dll' 'Edwards.Scada.AgentService.exe': Loaded 'C:\Windows\System32\ole32.dll' 'Edwards.Scada.AgentService.exe': Loaded 'C:\Windows\assembly\NativeImages_v4.0.30319_32\System\d07dc4c7e25d0f1f688e96c3651ccbe3\System.ni.dll' 'Edwards.Scada.AgentService.exe': Loaded 'C:\Windows\assembly\NativeImages_v4.0.30319_32\System.Serv759bfb78#\a8b2254177d41e0ba6c21c1620ad7d05\System.ServiceProcess.ni.dll' 'Edwards.Scada.AgentService.exe': Loaded 'C:\Windows\Microsoft.NET\Framework\v4.0.30319\clrjit.dll' 'Edwards.Scada.AgentService.exe': Loaded 'C:\Windows\System32\cryptsp.dll' 'Edwards.Scada.AgentService.exe': Loaded 'C:\Windows\System32\rsaenh.dll' 'Edwards.Scada.AgentService.exe': Loaded 'C:\Windows\System32\cryptbase.dll' 'Edwards.Scada.AgentService.exe': Loaded 'C:\Windows\assembly\NativeImages_v4.0.30319_32\System.Core\c3edb3947295bb8762d800c029930c15\System.Core.ni.dll' 'Edwards.Scada.AgentService.exe': Loaded 'C:\Windows\assembly\NativeImages_v4.0.30319_32\System.Configuration17463703ac432e3bbf54586b3d6b8b\System.Configuration.ni.dll' 'Edwards.Scada.AgentService.exe': Loaded 'C:\Windows\assembly\NativeImages_v4.0.30319_32\System.Xmld354ba04e2414d763e9dea657f52fff\System.Xml.ni.dll' The thread 'Win32 Thread' (0x2084) has exited with code 0 (0x0). 'Edwards.Scada.AgentService.exe': Loaded 'ImageAtBase0x4890000', No symbols loaded. 'Edwards.Scada.AgentService.exe': Loaded 'ImageAtBase0x48b0000', No symbols loaded. 'Edwards.Scada.AgentService.exe': Unloaded 'ImageAtBase0x4890000' 'Edwards.Scada.AgentService.exe': Loaded 'C:\Windows\assembly\NativeImages_v4.0.30319_32\System.Data\e6902bef5b9f4110e975dc92ff87e71d\System.Data.ni.dll' 'Edwards.Scada.AgentService.exe': Loaded 'C:\Windows\Microsoft.NET\assembly\GAC_32\System.Data\v4.0_4.0.0.0__b77a5c561934e089\System.Data.dll' 'Edwards.Scada.AgentService.exe': Loaded 'C:\Windows\System32\ws2_32.dll' 'Edwards.Scada.AgentService.exe': Loaded 'C:\Windows\System32\crypt32.dll' 'Edwards.Scada.AgentService.exe': Loaded 'C:\Windows\System32\msasn1.dll' First-chance exception at 0x015e401a in Edwards.Scada.AgentService.exe: 0xC0000005: Access violation reading location 0x00000000. 'Edwards.Scada.AgentService.exe': Loaded 'ImageAtBase0x4950000', No symbols loaded. 'Edwards.Scada.AgentService.exe': Loaded 'ImageAtBase0x4960000', No symbols loaded. 'Edwards.Scada.AgentService.exe': Unloaded 'ImageAtBase0x4950000' The thread 'Win32 Thread' (0x25d4) has exited with code 0 (0x0). The thread 'Win32 Thread' (0x13d0) has exited with code 0 (0x0). 'Edwards.Scada.AgentService.exe': Loaded 'ImageAtBase0x50a0000', No symbols loaded. 'Edwards.Scada.AgentService.exe': Loaded 'ImageAtBase0x50f0000', No symbols loaded. 'Edwards.Scada.AgentService.exe': Unloaded 'ImageAtBase0x50a0000' 'Edwards.Scada.AgentService.exe': Loaded 'C:\Windows\assembly\NativeImages_v4.0.30319_32\System.ServiceModel\dab9738fa2ffd706ad918f4854011580\System.ServiceModel.ni.dll' 'Edwards.Scada.AgentService.exe': Loaded 'C:\Windows\assembly\NativeImages_v4.0.30319_32\System.Runt73a1fc9d#[=14=]03c5ec8500bfe2571ef6b3768e3327\System.Runtime.Remoting.ni.dll' 'Edwards.Scada.AgentService.exe': Loaded 'C:\Windows\System32\mswsock.dll' 'Edwards.Scada.AgentService.exe': Loaded 'C:\Windows\System32\NapiNSP.dll' 'Edwards.Scada.AgentService.exe': Loaded 'C:\Windows\System32\pnrpnsp.dll' 'Edwards.Scada.AgentService.exe': Loaded 'C:\Windows\System32\nlaapi.dll' 'Edwards.Scada.AgentService.exe': Loaded 'C:\Windows\System32\winrnr.dll' 'Edwards.Scada.AgentService.exe': Loaded 'C:\Windows\System32\dnsapi.dll' 'Edwards.Scada.AgentService.exe': Loaded 'C:\Windows\System32\nsi.dll' 'Edwards.Scada.AgentService.exe': Loaded 'C:\Windows\System32\rasadhlp.dll' 'Edwards.Scada.AgentService.exe': Loaded 'C:\Windows\System32\IPHLPAPI.DLL' 'Edwards.Scada.AgentService.exe': Loaded 'C:\Windows\System32\FWPUCLNT.DLL' 'Edwards.Scada.AgentService.exe': Loaded 'ImageAtBase0x4970000', No symbols loaded. 'Edwards.Scada.AgentService.exe': Loaded 'ImageAtBase0x50e0000', No symbols loaded. 'Edwards.Scada.AgentService.exe': Unloaded 'ImageAtBase0x4970000' 'Edwards.Scada.AgentService.exe': Loaded 'C:\Windows\assembly\NativeImages_v4.0.30319_32\SMDiagnostics15baffc9d9111d58c8fe05d4e50c8a\SMDiagnostics.ni.dll' 'Edwards.Scada.AgentService.exe': Loaded 'C:\Windows\assembly\NativeImages_v4.0.30319_32\System.Servd1dec626#634b20929e9a6ed53d7acbffa0b93d\System.ServiceModel.Internals.ni.dll' 'Edwards.Scada.AgentService.exe': Loaded 'ImageAtBase0x4970000', No symbols loaded. 'Edwards.Scada.AgentService.exe': Loaded 'ImageAtBase0x5220000', No symbols loaded. 'Edwards.Scada.AgentService.exe': Unloaded 'ImageAtBase0x4970000' 'Edwards.Scada.AgentService.exe': Loaded 'C:\Windows\assembly\NativeImages_v4.0.30319_32\System.Runteb92aa12#\dd6060246740eddfed31aeed179fb81f\System.Runtime.Serialization.ni.dll' 'Edwards.Scada.AgentService.exe': Loaded 'C:\Windows\assembly\NativeImages_v4.0.30319_32\System.Web.Services50e9c52ad5088258dafbd0fce2ae07\System.Web.Services.ni.dll' 'Edwards.Scada.AgentService.exe': Loaded 'ImageAtBase0x5230000', No symbols loaded. 'Edwards.Scada.AgentService.exe': Loaded 'ImageAtBase0x5280000', No symbols loaded. 'Edwards.Scada.AgentService.exe': Unloaded 'ImageAtBase0x5230000' 'Edwards.Scada.AgentService.exe': Loaded 'C:\Windows\assembly\NativeImages_v4.0.30319_32\System.Serv14259fd9#\f8ae5cc80236c0593f67d76495fccd46\System.ServiceModel.Activities.ni.dll' First-chance exception at 0x74372ea2 in Edwards.Scada.AgentService.exe: 0xE0434352: 0xe0434352. 'Edwards.Scada.AgentService.exe': Loaded 'C:\Windows\assembly\NativeImages_v4.0.30319_32\System.IdentityModel572b8748b627fcbeb032b3656f5810\System.IdentityModel.ni.dll' 'Edwards.Scada.AgentService.exe': Loaded 'C:\Windows\assembly\NativeImages_v4.0.30319_32\System.Net.Http\f37829993e81bb8c2121b954fda8e480\System.Net.Http.ni.dll' 'Edwards.Scada.AgentService.exe': Loaded 'C:\Windows\System32\httpapi.dll' 'Edwards.Scada.AgentService.exe': Loaded 'C:\Windows\System32\psapi.dll' First-chance exception at 0x74372ea2 in Edwards.Scada.AgentService.exe: Microsoft C++ exception: EEFileLoadException at memory location 0x053dc524..

第一行很混乱,我已经多次检查项目构建,它是为调试而构建的。

[另一个编辑] 我已经从 SVN 获取了昨天正在运行的项目并完全删除了现有项目,从 SVN 中提取了副本。我已经编译并测试了它,它现在在昨天工作的地方崩溃了,我重新安装了 MSVC,安装了服务包并采用了一个工作项目并构建了,但现在它没有调试和崩溃。

为什么? 我还能尝试什么?

这里是stdafx.h的内容:

#include "stdafx.h"

#ifdef _ATL_STATIC_REGISTRY
    #include <statreg.h>
    #include <statreg.cpp>
#endif

#include <atlimpl.cpp>

这是来自 C/C++ 的命令行:

    /Od 
    /I "..\..\..\Legacy Common Files" 
    /I "..\nodetalk2\include"
    /I "..\..\..\..\..\Include" 
    /D "CLSOPENLDV"
    /D "SP_DEBUG"
    /D "WIN32"
    /D "_WINDOWS"
    /D "_USRDLL"
    /D "_VC80_UPGRADE=0x0600"
    /D "_WINDLL" 
    /D "_MBCS"
    /FD /EHsc /MDd /Yc"stdafx.h" 
    /Fp".\Debug/FsLonPlayer.pch"
    /Fo".\Debug/" 
    /Fd".\Debug/" 
    /W4 /nologo /c /Wp64 /Zi /TP /errorReport:prompt

[Edit] 输出的第一行是一个转移注意力的问题,它实际上指的是这个 DLL 所属的 EXE,这个 DLL 是为了调试而编译的,但是话说回来它仍然没有解释为什么昨天它工作正常,我可以在调试器中看到源代码并在断点处停止,今天我不能。

需要将其移至格式的答案中。我认为@ZDF 建议您更换行:

#if defined(CLSOPENLDV) && !defined(CLSOPENLDV_H)

#if defined(CLSOPENLDV)

虽然我在做,但下一个建议可能不是一个长期的解决方案,但它应该提供一个数据点来帮助找出问题所在。创建一个新的头文件,其中只有这一行:

#define CLSOPENLDV

不要使用 #include 将其包含在任何地方,而是打开项目属性,进入 C/C++ -> Advanced 并在中输入新头文件的完整路径Forced Include File 字段。试一试,看看会发生什么。

另外,另一个(可能是愚蠢的)想法。你能从你的 SCM 存储库中提取一个版本的项目文件吗?就像一周半前你做这个的时候一样?

-- 编辑--

刚刚看到您对原始内容的编辑 post。您是否检查了实际 .cpp 文件的属性,您可以通过查看项目本身的属性、验证两个定义是否存在,然后只需单击 .cpp 文件来轻松完成此操作在解决方案资源管理器中。这会将您带到文件本身的同一 属性 页面。

我非常想知道那里展示了什么。

这个项目非常大,构建中有多个子项目,原来构建中的其他项目之一导致我的项目出现问题。从 SVN 中检查了一个更旧的树并构建了它,我们现在可以找出错误项目的位置并进行修复。