The 25 days of C++mas - December 9 - C++Builder 64-bit Debugging

By: David Intersimone

Abstract: David I provides links and information on debugging C++Builder 64-bit Windows applications

This is a copy of a blog post from David I's Sip from the Firehose blog. Click to blog post title below to see the original blog post and comments.

  The 25 days of C++mas - December 9 - C++Builder 64-bit Debugging

Debugging C++Builder XE3 64-bit Windows applications is similar to debugging C++Builder  32-bit Windows applications. You can find additional about debugging C++ (and Delphi) applications on the Embarcadero DocWiki (see links below). In C++Builder XE3 for 64-bit Windows, there are some differences in debugging using the IDE. These are also listed below.

Debugging in the IDE

The Embarcadero DocWiki has several articles about how to use the IDE debugger for both 32-bit and 64-bit applications.  The follow links contain an overview and additional debugging information:

C++Builder 64-bit Debugging

Some debugger features are not currently supported. Debugging of properties, closures, class methods and other Delphi language extensions is not currently supported. For example, on the Debug Inspector, the Methods and Properties tabs are not displayed for C++ 64-bit Windows applications.

Unicode, code pages, and localization are not fully supported. For example, Unicode is not supported in identifier names, and code pages are not supported by the C++ 64-bit Windows debugger.

When evaluating a 64-bit Windows register, the register name must be prefixed with $, such as $rax.
See Evaluate/Modify.

Function calls that throw exceptions are handled as follows:

  • If a function contains a try/except/catch block, and a C++ or OS/SEH exception is raised during execution, the function call finishes correctly, but the result is undefined or 0. In this case, the internal exception block is not executed because the exception is handled directly by the debugger.
  • If a function contains a try/except/catch block, and no language or OS/SEH exceptions are raised, the function call finishes fine and the result is correct, depending on the function.

Some values might be displayed differently in the 64-bit evaluator than in the 32-bit evaluator. For example, the call stack is displayed without function parameters and values.

The call stack typically contains two copies of each constructor and destructor. For example, the call stack might contain:

    :0000000000401244 ; MyClass::~MyClass
    :0000000000401229 ; MyClass::~MyClass
    :0000000000401187 ; main
    :000000000040ef90 ; _startup

Clang implements the Itanium ABI, which describes three constructors and three destructors that chain call each other. However, Clang implemented only two of the three constructors, and C++Builder added the third kind for Delphi-style classes. See the Itanium ABI doc (pdf file) or this post on Stack Overflow:

Evaluation for a function call such as strcmp(str, "ABC") could return an error as follows:

    int main()
    char *str = "ABC";
    return strcmp(str, "ABC");
    error: 'strcmp' has unknown return type; cast the call to its declared return type
    error: 1 errors parsing expression

In the Evaluate/Modify window, you need to cast the return type for strcmp():

    (int) strcmp(str, "ABC");

CodeRage 7 C++ Conference, December 10-12, 2012

The CodeRage 7 C++ conference starts next Monday, December 10, 2012 at 6am Pacific Standard Time (14:00 UTC).  There are 3 days of C++ sessions including my special live, online conversation with Bjarne Stroustrup at 8am PST (16:00 UTC) on Monday.  Some of the C++ sessions you won’t want to miss are included in my blog post on November 21 -

Happy C++mas!

During the first 25 days of December leading up to Christmas, I will blog about the upcoming release of the C++Builder 64-bit compiler for Microsoft Windows and C++Builder XE3support for building VCL and FireMonkey 2 applications.

Server Response from: ETNASC04