断点将不会被命中。没有与此行关联的可执行代码 [英] Breakpoint will not currently be hit. No executable code associated with this line

查看:208
本文介绍了断点将不会被命中。没有与此行关联的可执行代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在.h文件中有一个类:

  class Blah 
{
public:
Blah(){}
virtual〜Blah(){}

void WriteMessage(bool MessageReceived)
{
if(MessageReceived)
{
cout<< Message Recieved\\\
;
}
}
};



我试图找出为什么我的代码不工作,所以我设置了断点上条件在 WriteMessage()函数内,但是一旦我在调试模式下开始运行项目,断点退出,它的工具提示说:


断点将不会被命中。

没有与此行相关联的可执行代码。


我不知道为什么会发生这种情况,因为对于其他类的所有其他成员函数在.h文件中实现时工作正常。是什么原因导致了这种情况?



编辑:按照要求,这里是一个精简版的真正的代码我使用: p>

VimbaBridgeAPI.h (.dll的头文件)

  #pragma once 

#ifdef VIMBABRIDGEAPI_EXPORTS
#define VIMBABRIDGEAPI_API __declspec(dllexport)
#else
#define VIMBABRIDGEAPI_API __declspec(dllimport)
#endif

#includeAlCamIncludes.h
#includeVimbaSystem.h

////////////// //////////////////////////////
//全局变量//////////// ///////////
/////////////////////////////////// /////////
extern HBITMAP hbit;
extern CEdit * global_filenamehandle;

////////////////////////////////////////// //
//全局标志///////////////////////////
///////// ///////////////////////////////////
extern bool imageReady;
extern bool take_picture;

使用命名空间AVT :: VmbAPI;

VIMBABRIDGEAPI_API void BridgedGetImage(FramePtr framepoint,VmbUchar_t ** imgDat);

VIMBABRIDGEAPI_API HBITMAP ExternalFrameRecieved(const FramePtr pFrame);

////////////////////////////////////////// ////////////////////////////////
////////// MyObserver类// /////////////////////////////////////////
///// ////////////////////////////////////////////////// ///////////////////
class VIMBABRIDGEAPI_API MyObserver:public IFrameObserver
{
private:
MyObserver(MyObserver&);

MyObserver& operator =(const MyObserver&);

//类成员变量
// BITMAPINFO * pbmi;
CEdit * m_filenameedit;

public:

MyObserver(CameraPtr pCamera):IFrameObserver(pCamera){}
virtual〜MyObserver(){}

FrameReceived(const FramePtr pFrame);
};

注意:IFrameObserver不是由我写的,但FrameReceived函数在IFrameObserver类中声明的纯虚拟。他们的文档说,FrameRecieved获得调用它们的API每当一帧进来,我不得不实现的功能。我已经测试了这个函数,它的工作,但只有当定义在类外面(我得到的错误,我现在得到)



VimbaBridgeAPI.cpp (代码隐藏自用户)

  void FrameRecieved(const FramePtr pFrame)
{
DbgMsg (LFrame Received \\\
);

////////////////////////////////////////// //////////////////////////////
//////////设置位图//// ////////////////////////////////////////////
// ////////////////////////////////////////////////// //////////////////////

//// FILEHEADER ////
BITMAPFILEHEADER * bf = new BITMAPFILEHEADER;
bf-> bfType = 0x4d42;
bf-> bfSize = 6054400 + 54 + sizeof(BITMAPINFO);
bf-> bfOffBits = 54;

//// INFOHEADER ////
BITMAPINFOHEADER * bih = new BITMAPINFOHEADER;
bih-> biSize = 40;
bih-> biWidth = 2752;
bih-> biHeight = -2200;
bih-> biPlanes = 1;
bih-> biBitCount = 32;
bih-> biCompression = 0;
// bi-> biSizeImage = 6054400; // not required
bih-> biXPelsPerMeter = 2835;
bih-> biYPelsPerMeter = 2835;
bih-> biClrUsed = 0;
bih-> biClrImportant = 0;

//// INFO ////
BITMAPINFO * pbmi =(BITMAPINFO *)alloca(sizeof(BITMAPINFOHEADER)+ sizeof(RGBQUAD)* 256)
pbmi-> bmiHeader.biSize = sizeof(pbmi-> bmiHeader);
pbmi-> bmiHeader.biWidth = 2752;
pbmi-> bmiHeader.biHeight = -2200;
pbmi-> bmiHeader.biPlanes = 1;
pbmi-> bmiHeader.biBitCount = 8;
pbmi-> bmiHeader.biCompression = BI_RGB;
pbmi-> bmiHeader.biSizeImage = 0;
pbmi-> bmiHeader.biXPelsPerMeter = 14173;
pbmi-> bmiHeader.biYPelsPerMeter = 14173;
pbmi-> bmiHeader.biClrUsed = 0;
pbmi-> bmiHeader.biClrImportant = 0;

//创建灰度调色板
for(int i = 0; i <256; i ++)
{
pbmi-> bmiColors [i] .rgbRed = BYTE(i);
pbmi-> bmiColors [i] .rgbGreen = BYTE(i);
pbmi-> bmiColors [i] .rgbBlue = BYTE(i);
pbmi-> bmiColors [i] .rgbReserved = BYTE(0);
}

////图像数据////
VmbUchar_t * imageData = NULL;
BridgedGetImage(pFrame,& imageData);

////////////////////////////////////////// ////////////////////////////////
//////创建打印到对话框/ ////////////////////////
//////////////////////// ////////////////////////////////////////////////// //
HDC hdc = :: GetDC(NULL);
hbit = CreateDIBitmap(hdc,bih,CBM_INIT,imageData,pbmi,DIB_RGB_COLORS);

//清理
DeleteObject(bf);
DeleteObject(bih);
DeleteObject(hdc);
}


解决方案

strong>删除输出文件:物理删除所有生成的DLL,PDB和EXE。然后再次编译(重建)生成文件。有时Visual Studio可能会丢失和忘记,以覆盖输出文件,当您构建您的解决方案。



这可能会由于几个其他原因:




  • 调试器使用的代码与应用程序正在运行的代码不同

  • pdb文件调试程序正在使用的代码与应用程序正在运行的代码不同

  • 应用程序正在运行的代码已优化,调试信息已被删除。

  • 您已设定断点的程式码尚未载入程序。


I have a class in a .h file:

class Blah
{
public:
    Blah(){}
    virtual ~Blah(){}

    void WriteMessage( bool MessageReceived )
    {
        if(MessageReceived)
        {
            cout << "Message Recieved\n";
        }
    }
};

I was trying to figure out why my code isn't working, so I set a breakpoint on the conditional inside the WriteMessage() funcition, but as soon as I started running the project in debug mode the breakpoint faded out and the tooltip for it said:

Breakpoint will not currently be hit.
No executable code associated with this line.

I have no idea why this is happening, because all of my other member functions for other classes work just fine when implemented in the .h file. What is causing this?

Edit: Okay as requested, here's a stripped down version of the real code I'm working with:

VimbaBridgeAPI.h (header file for .dll)

#pragma once

#ifdef VIMBABRIDGEAPI_EXPORTS
#define VIMBABRIDGEAPI_API __declspec(dllexport)
#else
#define VIMBABRIDGEAPI_API __declspec(dllimport)
#endif

#include "AlCamIncludes.h"
#include "VimbaSystem.h"

////////////////////////////////////////////
//  Global Variables ///////////////////////
////////////////////////////////////////////
extern HBITMAP hbit;
extern CEdit* global_filenamehandle;

////////////////////////////////////////////
//  Global Flags ///////////////////////////
////////////////////////////////////////////
extern bool imageReady;
extern bool take_picture;

using namespace AVT::VmbAPI;

VIMBABRIDGEAPI_API void BridgedGetImage(FramePtr framepoint, VmbUchar_t** imgDat);

VIMBABRIDGEAPI_API HBITMAP ExternalFrameRecieved( const FramePtr pFrame );

//////////////////////////////////////////////////////////////////////////
//////////  MyObserver class   ///////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
class VIMBABRIDGEAPI_API MyObserver : public IFrameObserver
{
private:
    MyObserver( MyObserver& );

    MyObserver& operator=( const MyObserver& );

    //class member variables
    //BITMAPINFO*             pbmi;
    CEdit*                  m_filenameedit;

public:

    MyObserver(CameraPtr pCamera) : IFrameObserver(pCamera) {}
    virtual ~MyObserver() {}

    void FrameReceived ( const FramePtr pFrame );
};

NOTE: IFrameObserver is not written by me, but the FrameReceived function is a pure virtual declared in the IFrameObserver class. Their documentation says that FrameRecieved gets called by their API whenever a frame comes in, and I had to implement the function. I have tested this functions and it works, but only when defined outside the class (inside I get the error I'm getting now)

VimbaBridgeAPI.cpp (code hidden from user)

void FrameRecieved( const FramePtr pFrame )
{
    DbgMsg(L"Frame Received\n");

    ////////////////////////////////////////////////////////////////////////
    //////////  Setup Bitmap  ////////////////////////////////////////////////
    //////////////////////////////////////////////////////////////////////////

    //// FILEHEADER ////
    BITMAPFILEHEADER* bf = new BITMAPFILEHEADER;
    bf->bfType = 0x4d42;
    bf->bfSize = 6054400 + 54 + sizeof(BITMAPINFO);
    bf->bfOffBits = 54;

    //// INFOHEADER ////
    BITMAPINFOHEADER* bih = new BITMAPINFOHEADER;
    bih->biSize = 40;
    bih->biWidth = 2752;
    bih->biHeight = -2200;
    bih->biPlanes = 1;
    bih->biBitCount = 32;
    bih->biCompression = 0;
    //bi->biSizeImage = 6054400; //not required
    bih->biXPelsPerMeter = 2835;
    bih->biYPelsPerMeter = 2835;
    bih->biClrUsed = 0;
    bih->biClrImportant = 0;

    //// INFO ////
    BITMAPINFO* pbmi = (BITMAPINFO*)alloca( sizeof(BITMAPINFOHEADER) + sizeof(RGBQUAD)*256);
    pbmi->bmiHeader.biSize = sizeof (pbmi->bmiHeader);
    pbmi->bmiHeader.biWidth = 2752;
    pbmi->bmiHeader.biHeight = -2200;
    pbmi->bmiHeader.biPlanes = 1;
    pbmi->bmiHeader.biBitCount = 8;
    pbmi->bmiHeader.biCompression = BI_RGB;
    pbmi->bmiHeader.biSizeImage = 0;
    pbmi->bmiHeader.biXPelsPerMeter = 14173;
    pbmi->bmiHeader.biYPelsPerMeter = 14173;
    pbmi->bmiHeader.biClrUsed = 0;
    pbmi->bmiHeader.biClrImportant = 0;

    //create grayscale color palette
    for(int i=0; i<256; i++)
    {
        pbmi->bmiColors[i].rgbRed = BYTE(i);
        pbmi->bmiColors[i].rgbGreen = BYTE(i);
        pbmi->bmiColors[i].rgbBlue = BYTE(i);
        pbmi->bmiColors[i].rgbReserved = BYTE(0);
    }

    //// IMAGE DATA ////
    VmbUchar_t* imageData = NULL;
    BridgedGetImage(pFrame, &imageData);

    //////////////////////////////////////////////////////////////////////////
    ////// Create image that's printed to dialog box /////////////////////////
    //////////////////////////////////////////////////////////////////////////
    HDC hdc = ::GetDC(NULL);  
    hbit = CreateDIBitmap(hdc, bih, CBM_INIT, imageData, pbmi, DIB_RGB_COLORS);

    //clean up
    DeleteObject(bf);
    DeleteObject(bih);
    DeleteObject(hdc);
}

解决方案

I would suggest you firstly Delete the output files : Physically delete all generated DLLs, PDBs and EXEs. Then compile (rebuild) again to generate the files. Sometimes Visual Studio can "get lost" and "forget" to overwrite the output files when you build your solution.

This can happen for a few other reasons:

  • The code the debugger is using is different from the code that the application is running
  • The pdb file that the debugger is using is different from the code that the application is running
  • The code the application is running has been optimized and debug information has been stripped out.
  • The code in which you have breakpoints on hasn't been loaded into the process yet

这篇关于断点将不会被命中。没有与此行关联的可执行代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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