Enabling logging for the RAD Studio debuggers

From RAD Studio
Jump to: navigation, search

Go Up to Debugging Applications Index


Debugger logs can help diagnose and understand unexpected behavior when debugging, such as helping isolate bugs in the debugger itself.

These logs are enabled by setting environment variables, but there are different debuggers for different platforms. This means different environment variables need to be set to generate the logs depending on the platform.

To generate logs follow these steps:

  1. Exit the IDE (and PAServer if you are remote debugging)
  2. Delete any existing logs beforehand (so that we only get one set of logs that represent the problem)
  3. Set all environment variables as specified below that apply to the platform (make sure all output directories specified exist and can be written to)
  4. Launch the IDE (and PAServer if you are remote debugging)
  5. Run the debugger and do only what is necessary to reproduce the bug
  6. Exit the IDE (and PAServer if you are remote debugging)
  7. Collect all debugger logs generated and attach them to your bug report or support request.
Notes:
  • Any output directories specified in the settings must exist before launching the IDE (and/or PAServer if remote debugging).
  • You must have write access to the output directories specified in the settings (if any) especially for Windows 10 and macOS.
  • You may need to exit the IDE before the logs can be viewed (depending on the platform).

DBK logs

Windows-hosted DBK logs (Win32 & Win64)

Note: The DBK debugger used for Win32 is supported for Delphi and C++, and Win64 is supported for Delphi only. For Win64 C++ debugging, please see the LLDB section below.

To get the debugger logs on a Windows machine:

  1. Launch bds.exe
  2. Open Tools>Options>IDE>Environment Variables
  3. In User System Overrides, click New... to add the following environment variable name/value pairs:
    1. DBK_DEBUG all
    2. DBK_DEBUG_OUTDIR d:\MyLogsDirectory


To disable the debugger logs in the next debug session:

  1. Open Tools>Options>IDE>Environment Variables
  2. Select the DBK_DEBUG variable and click Delete
  3. Select the DBK_DEBUG_OUTDIR variable and click Delete


For each run of the debugger:

  • On Win32, you will find DBK logs named dbk_<pid1>.log (for the debug server) and dbk_<pid2>_N.log (for the debugger) in MyLogDirectory.
  • On Win64, you will find DBK logs named dbk_<pid1>.log (for the Win32-hosted driver), dbk_<pid2>.log (for the debug server), and dbk_<pid3>_N.log (for the debugger) in MyLogsDirectory.
Tip: If the debugger won't start, try running the IDE as administrator and see if the log files were written to the bds bin directory.

LLDB logs

Windows-hosted LLDB logs (Win64, Android32, and Android64)

Note: Android32 and Android64 are supported for Delphi and C++, while Win64 is supported for C++ only.

To get the debugger logs on a Windows machine:

  1. Launch bds.exe
  2. Open Tools>Options>IDE>Environment Variables
  3. In User System Overrides, click New... to add the following environment variable name/value pairs:
    1. GDB_DEBUG 1
    2. GDB_OUTDIR d:\MyLogsDirectory


To disable the LLDB logs in the next debug session:

  1. Open Tools>Options>IDE>Environment Variables
  2. Select the GDB_DEBUG variable and click Delete
  3. Select the GDB_OUTDIR variable and click Delete


For each run of the debugger, you will find the IDE's log(s) named gdb_<pid>.log in MyLogsDirectory if GDB_OUTDIR is set. If it is not set, then the logs will be placed in the bds bin directory.

macOS-hosted LLDB logs (iOS64, iOS Simulator ARM64, macOS 64, and macOS ARM64)

To get the debugger logs on a Mac machine, first, open a terminal window. Go to the directory where PAServer is installed. Type the following command:

export GDB_DEBUG=1
export GDB_OUTDIR=~/MyLogDirectory
./paserver

You will find the IDE´s log(s) named lldb_<pid>.log in MyLogsDirectory if GDB_OUTDIR is set. If it is not set, then the logs will be placed in the same directory as the paserver's binary.

Known Issues & Workarounds

If the IDE cannot start a debug session for a Delphi application on Windows 64-bit platform due to the port conflict, do the following:

To set this DBK_DEBUG_PORT:

  1. Open Tools>Options>IDE>Environment Variables
  2. In User System Overrides, click New... to add the following environment variable name/value pairs:
    1. DBK_DEBUG_PORT 12345
  3. Relaunch the IDE

The Delphi application for Windows 64-bit platform debug session will use this new port number. To reset to the default one, delete this newly added env variable, and relaunch the IDE.