使用远程调式器追踪源码

   很多时候,程序在客户机或测试工程师机器上,运行会出现错误,但是换个环境就无法重现。delphi引入的Remote Debugger替我们很好地解决此问题。

Using the Remote Debugger with Delphi 2010 Edit

Delphi 2010 is not able to load debug informations from remote files by default. You need to apply updates 4 & 5 to fix this.

Take a look on the release notes for this issue : [[1]]

Using the Remote Debugger with Delphi 2007 and Delphi 2009 Edit

The following instructions have been tested in Delphi 2007 and Delphi 2009: A similar process is known to work in Delphi 7.0. Remote debugging is considered unusable in Delphi 2005 and 2006.

On the Target Machine Edit

Startup remote debug

First Time Only: You need to insert your Delphi 2007 or 2009 product DVD on the target machine, or copy the "Remote Debugger Installer" files onto your network, and run them from there. Once you have the target machine configured (remote debugger installeed), go to C:\Program Files\Remote Debugger and double click on rmtdbt105.exe (delphi 2007), or rmtdbg120.exe (delphi 2009). Later on, I recommend that you run with the "-listen" command line parameter. You could create a batch file (remotedebugger.cmd) containing the following line:

rmtdbg120.exe -listen


To get the EXE file that Delphi builds onto your target machine, so you can load it using the remote debugger, we suggest you share the Target computer's C Drive, using Windows File Sharing, then use the Windows Explorer "Tools ->Map as Network drive" command, on your developer box. For example, you could make the C: drive from your test machine map as Q: on your developer box.

When you share the C: drive on your target machine, be sure to make it writeable, for only your particular user account+password combination. Do not use the "Everyone" permission, unless you want to invite your IT department to come over and introduce you to their new security policy documents.

If your EXE file needs any configuration files, or some setup on the remote machine before you first run the software, you should do that step next. To configure any runtime environment (consider registry settings, COM/DCOM OLE or ActiveX object registrations, other configuration files, etc). For example, I often make a folder C:\Program Files\DebugApp, and copy all configuration and data files over there.

When the remote debugger is running, you should see something like the picture shown at the top of this section, on your Target machine: (the <-listen> part is very important!). If you have done everything in this section, move to the next section now.


On the Target Machine (Rad Studio 2009 ESD version) Edit

If you have a Rad Stuido 2009 ESD (download) edition, you don't have the remote debugger installer. However it is complete enough to do remote debugging:


Copy the follow files from your D2009 installation directory to the target machine:



  1. bccide.dll
  2. bordbk120.dll
  3. bordbk120N.dll
  4. comp32x.dll
  5. DCC120.dll
  6. rmtdbg120.exe

Then register the relevant DLLs by issueing

regsvr32 /s bordbk120.dll
regsvr32 /s bordbk120n.dll

on the cmdline , then use (like when using the installer)

rmtdbg120 -listen 8000

to start the remote debugging process

At least this worked on my Rad Studio 2009 ESD edition, repeated several times with various (XP,Vista,D2009) targets.

On your local Delphi developer machine Edit

In your Delphi Project Options dialog box, you can change your EXE output folder. This saves you lots of time manually copying the EXE file after you build it. If the target's C drive is mapped as drive Q: for your developer machine, change the options of your project to output to Q:\Program Files\DebugApp folder, so that after compilation, the EXE ends up right at the place the remote debugger will expect it to be, on the target machine.

Make sure the Remote Debug Symbols option is checked in the Linker options in the Project Options.

Delphi project options remote debug2


Rebuild the app so that the executable file is now built with the correct options and is now present on your your remote machine.

In Run menu, select select Load Process. Now click Remote (the second item in the Load Process listview on the left side of the load process dialog). Now fill out the two boxes called remote path, remote host, and optionally, working directory. All these are paths as seen on the remote machine. So for the remote machine's main hard drive, use C: as the path. The first item (remote path) is the name of the EXE file on the server. If you mapped your remote drive as Q above, and the path was Q:\FOO\BAR.EXE, you would type C:\FOO\BAR.EXE in this box. The second item (remote host) is an ip address or dns resolveable hostname, such as 192.168.0.xx or TARGETPC.ntdomain.company.com.

The remote path (and exe file name) must exist. The working directory also must exist.

Click Load button (leftmost button on bottom row of buttons in Load Process dialog). Run load process remote debugger


You are now debugging remotely. You should see the debugger highlighting the first source code line in the application initialization code. Assuming everything worked, and there's no firewalls, network problems, etc etc.

One Tip Edit

I also like to use VNC Client and VNC Server to remote-desktop into my target debug machine, from the host machine I'm debugging on, when remotely debugging a GUI program.


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值