You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

x64架构下C++ EXE调用Delphi BPL调试断点失效问题

x64 C++ EXE调用Delphi BPL时断点失效问题

我维护一个由1个C++ EXE、若干C++ DLL和Delphi BPL组成的x64架构大型项目,调试Delphi BPL时出现断点失效的情况(断点显示为灰色,无法触发)。

为定位问题,我制作了最小复现示例,创建三个空白项目:C++ EXE、Delphi EXE、Delphi BPL,代码如下:

C++ EXE代码

#include <vcl.h>

#include "Unit2.hpp"

#pragma comment(lib, "Package1")

int WINAPI _tWinMain(HINSTANCE, HINSTANCE, LPTSTR, int)
{
    TComponent* cmp = nullptr;
    Unit2::TForm2* frm = new Unit2::TForm2(cmp);
    frm->Button1Click(nullptr);
    return 0;
}

Delphi EXE代码

unit Unit4;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Unit2;

type
  TForm4 = class(TForm)
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form4: TForm4;

implementation

{$R *.dfm}

procedure TForm4.FormCreate(Sender: TObject);
var
frm: TForm2;
begin
  frm := TForm2.Create(nil);
  frm.Button1Click(nil);
end;

end.

Delphi BPL代码

unit Unit2;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls;

type
  TForm2 = class(TForm)
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form2: TForm2;

implementation

{$R *.dfm}

procedure TForm2.Button1Click(Sender: TObject);
var
i: integer;
begin
   i := 678;
end;

end.

调试组合测试结果

  1. x86 C++ EXE + x86 Delphi BPL - 调试正常,断点可触发
  2. x86 Delphi EXE + x86 Delphi BPL - 调试正常,断点可触发
  3. x64 Delphi EXE + x64 Delphi BPL - 调试正常,断点可触发
  4. x64 C++ EXE + x64 Delphi BPL - 断点失效,无法触发

疑问

为什么唯独x64 C++ EXE与x64 Delphi BPL的组合无法正常调试BPL?该如何解决这个问题?

BPL项目调试设置

  • 调试器类型:本地Windows调试器
  • 主机应用程序:指定为编译后的x64 C++ EXE路径
  • 工作目录:设置为x64 C++ EXE所在目录
  • 调试选项:已勾选「启用调试」,配置了符号相关参数

环境信息

  • 操作系统:Windows 10 x64
  • IDE:Embarcadero RAD Studio 11.2

内容的提问来源于stack exchange,提问作者Range

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.05 01:20:46