不会命中此断点
This breakpoint will not be hit
本文关键字:断点 更新时间:2023-10-16
我查看了许多关于这个问题的帖子,但没有一个适用于我的情况。 我在一个文件中有一个C++类,它有 3 个方法。我可以在一种方法中设置断点。但是,我不能在其他两种方法中的任何代码行上设置断点。此类是作为具有 DEBUG 集的库构建的。所有优化都将关闭。 下面是此类中两个问题方法的代码。
块引用
#include "pch.h"
#include <stdio.h>
#include <afxwin.h>
#include <cstring>
#include <io.h>
#include <iostream>
#include <string>
#include "Log.h"
CLog::CLog()
{
ptLog = NULL; // this is the file ptr
}
void CLog::Init()
{
int iFD;
DWORD iLength;
int iStat;
HMODULE hMod;
std::string sPath;
std::string sFile;
int i;
hMod = GetModuleHandle(NULL); // handle to this execuatble
std::cout << "Module = " << hMod;
if(hMod)
{
// Use two bytes ASCII (UNICODE) if set by compiler
char acFile[120];
// Full path name of exe file
GetModuleFileName(hMod, acFile, sizeof(acFile));
std::cout << "File Name = " << acFile<<"n";
// extract file name from full path and append .log
sPath = acFile;
i = sPath.find_last_of("\/");
sFile = sPath.substr(i + 1);
sFile.copy(acFile, 120);
std::cout << " File Name Trunc = " << sFile;
sFile.append(".log");
iStat = fopen_s(&ptLog, sFile.data(), "a+"); // append log data to file
std::cout << "fopen stat = " << iStat;
if (iStat != 0) // failed to open error log
{
return;
}
iFD = _fileno(ptLog);
iLength = _filelength(iFD);
// Check length. If too large rename and create new file.
if (iLength > MAX_LOG_SIZE)
{
fclose(ptLog);
char acBakFile[80];
strcpy_s(acBakFile, 80, acFile);
strcat_s(acBakFile, ".bak"); // new name of old log file
remove(acBakFile); // remove previous bak file if it exists
rename(acFile, acBakFile);
fopen_s(&ptLog, acFile, "a+"); // Create new log file
}
}// end if (hMod)
}
,,,
ptLog 被声明为文件 * 此类使用以下代码调用:
#include <iostream>
#include "..LogLog.h"
int main()
{
CLog Logger;
Logger.Init();
Logger.vLog((char *) "Hello n");
}
块引用 此代码也编译为调试。如果在"Loggger.Init(("上设置断点 调试器将命中断点。如果选择"步入",则不会进入 Init(( 方法中的代码。代码确实执行,因为我可以在控制台上看到文本。如果我在 Init(( 方法中的任何位置放置断点,它们不会中断。
我做了以下操作: 从链接器的输入中删除了 log.lib。 显然,链路由于未解析的外部而失败。 放回 log.lib 并重建。 关闭了"要求与原始版本完全匹配的源文件"选项 调试和断点有效。 已启用该选项。 重试调试,断点仍然有效。 是否进行了完全重建和断点工作。
我真的不明白,因为我已经进行了多次清洁和重建 以前。
我确实发现了另一个问题。我打开了"/clr"选项。 这适用于 .lib 的公共语言运行时支持。 链接到它的模块没有打开公共语言运行库。在这种情况下, 断点被忽略。当我关闭"/clr"时,断点 功能正常
相关文章:
- 无法删除指针,已触发断点
- 条件断点在不应该触发时触发
- GDB 断点在 Mac 上是不准确的
- 在 vscode 中运行时无法暂停或设置断点
- 不会命中此断点
- 当前不会命中断点。没有调试器目标代码类型的可执行代码与此文件关联
- 如何在进入动态打开的共享库时设置断点?
- 为什么断点显示数组的第二个值是一个大数字?额外学分工作
- 代码在 msvcrt .dll函数上设置断点失败
- 如何在引用上设置数据断点
- 无法在visual studio 2017(本机c++)中禁用数据断点
- 为什么在c++中使用Delete[]会出现跟踪/断点错误
- for循环的条件只有在遇到断点后才生效
- 项目名称.exe 已触发断点
- 视觉对象触发了断点 c++
- 实现在多线程代码中安全恢复的断点
- 如何在 gdb 中的所有构造函数上同时为 C++ 对象设置断点?
- C/C++ 经过的流程周期,不包括断点处
- 在 Visual Studio 2012 中未命中断点
- 无法在 XmlHttpRequest 模块上获取断点(Javascript 引擎/XHR 请求)