Delphi 远程调试

 

转自:

http://www.cnblogs.com/sandman/archive/2010/12/05/1897063.html

 

自己的开发机器称为主机,运行程序的机器称为目标机;
一、在主机编译执行程序
1、project->options->linker中的EXE and DLL options选项组中的include remote debug symbols打上勾

这样就可以生成rsm为扩展名的文件,该文件名称于你的项目同名。

2、project->options->Debugging中的勾可以全部选上,这是在你的程序支持debug(正式发布产品时要去掉这些选项,Delphi默认设置是选则大部分的)
3、Tools->Environment Options->Preferences的Compling and running选择组中选上Show compiler progress(可选项,在编译或者运行时显示编译过程,建议使用)
二、拷贝Project1.exe和Project1.rsm到目标机器的运行目录(该目录可以是你的安装目录,也可以任意)
注意:主机的代码不需和目标机的exe和rsm文件一致,就是说在进行第一步后不能改动你的代码
三、目标机安装borland的远程调试工具rdebug,delphi7光盘中就有,或者google一下。
四、启动目标机的rdebug,启动后目标机的托盘图标中会出现一个小“虫子”debug的图标
注意:远程调试工具不需正常运行才能进行远程调试
五、主机的Delphi的远程调试设置
1、Delphi中选择Run->load process->Remote
2、Remote Path中输入目标机器的运行目录
3、Remote Host中输入目标机IP

4、Working Directory 中输入目标机器的运行目录
5、选择LOAd

六、主机按F9调试即可

 

补充:

delphi 2010的远程调试,需要下面几个文件:
bccide.dll,bordbk140.dll,bordbk140N.dll,comp32x.dll,DCC140.dll,rmtdbg140.exe

文件都在2010的bin目录下。

 

另一个介绍: 

Sometimes is good to debug directly on the client computer, because the development computer does not have the problem. Of course, in such cases is not appropriate (and often not even possible) to install Delphi on the client computer and for this cases Delphi offer the possibility of remote debugging. How to do?

I show remote debugging on Delphi 2010 (service pack 4 and 5 required - fixed some problems), but remote debugging is supported on old Delphi too - only difference is filenames (see below).

In first step install debugger support on target computer. You can download remote debugging support from Embarcadero or from Delphi directory copy this files (for Delphi 2010 - Delphi version 14, so for another version please use proper files - maybe can be stability problem with Delphi 2005 or 2006).

bccide.dll bordbk140.dll bordbk140N.dll comp32x.dll DCC140.dll rmtdbg140.exe 

Now register files with:

regsvr32 bordbk140.dll regsvr32 bordbk140n.dll 

Ok, so necessary tasks are done (this can be necessary only for first time) and start debugging.

On target computer start remote debugger (rmtdbg140.exe) - when started small icon is showed in tray (green bug).

Remote debugging tray

Now on project enable Remote debug symbols and Debug information. With first option compiler will create RSM files during compilation.

Remote options

Compiled binary file with rsm files copy on client computer. In menu Run select Load Process

Remote debugging start

… and in Remote tab fill fields (see screenshot - directories are from target computer).

Remote debugging

Now only click on Load and if everything is good, program will stop on first line of program (probably on first line in dpr file) and you can set breakpoints or everything like during normal debugging. And this is all.

When problems with communication try for example ping (and check firewall or stupid anti viruses and so on).

Update: simple demo - download

Update: maybe for some windows configuration remote debugging working only when everything is in same directory 

你可能感兴趣的:(Delphi)