Martin Prikryl 0 Posted September 11 When developing a GUI project in C++ Builder VCL (WinSCP SFTP/FTP client), I often need to debug VCL itself to understand why things do not work the way I expect. Now I'm upgrading my project to C++ Builder 11 and I've found that debugging VCL is broken. When stepping into some Pascal code from C++ project, the variables/parameters show incorrect values in debugger. (And my upgraded project fails deep in VCL, so I need to debug it.) I've encountered the problem with my licensed C++ Builder 11 Version 28.0.46141.0937. But I was able to reproduce the problem with a trial version of latest 12.1 too. In the screenshot below, you can see a callstack from a default unmodified Windows VCL Application project. In the callstack the this/Self "parameter" should have the same value in all top three levels. Yet it differs between C++ (this in TForm5::TForm5 and TForm::TForm) and Pascal (Self in TCustomForm::Create). Similarly, the top four levels should feature a pointer to the same Application object (Self in TApplication::CreateForm, AOwner in TCustomForm::Create – but also in TForm and TForm5 constructors, which shown strange __ctor_flag instead of expected AOwner). The screenshot is for the default (clang?) compiler. The same problem occurs however with the "classic" (bcc?) compiler – except the __ctor_flag problem does not occur. With 64-bit compiler, I'm not able to debug VCL at all (the debugger does not step into it). Correct are the values in C++ calls (I've verified that they point to the actual object data). The Pascal values are just rubbish. They even change as I step through the Pascal code (within the same method). Also the problem does not occur for all Pascal methods. But I wasn't able to identify, if there's any pattern so far (though virtual method might be a factor here). Note that this is not about the Self pointer only. The value of Self affects debugging all class fields. So once in the affected Pascal code, all fields values show garbage only. The code (though that's just the default project template, I haven't modified anything): Project?.cpp: //--------------------------------------------------------------------------- #include <vcl.h> #pragma hdrstop #include <tchar.h> //--------------------------------------------------------------------------- USEFORM("Unit5.cpp", Form5); //--------------------------------------------------------------------------- int WINAPI _tWinMain(HINSTANCE, HINSTANCE, LPTSTR, int) { try { Application->Initialize(); Application->MainFormOnTaskBar = true; Application->CreateForm(__classid(TForm5), &Form5); Application->Run(); } catch (Exception &exception) { Application->ShowException(&exception); } catch (...) { try { throw Exception(""); } catch (Exception &exception) { Application->ShowException(&exception); } } return 0; } //--------------------------------------------------------------------------- Unit5.cpp: //--------------------------------------------------------------------------- #include <vcl.h> #pragma hdrstop #include "Unit5.h" //--------------------------------------------------------------------------- #pragma package(smart_init) #pragma resource "*.dfm" TForm5 *Form5; //--------------------------------------------------------------------------- __fastcall TForm5::TForm5(TComponent* Owner) : TForm(Owner) { } //--------------------------------------------------------------------------- The screenshot and code is from 11.2. But I've tried 12 trial too and the same problem occurs. The following screenshot shows the expected and correct callstack from old C++ Builder XE6 for its own default VCL Forms Application project. Reproduction steps: I've created fresh Windows VM on AWS EC2 (Windows Server 2022 Base, c5.2xlarge) – Though the problem happens on any machine I've tried it on (VM or not) No modification in Windows Downloaded https://altd.embarcadero.com/download/radstudio/11.0/RADStudio_11_2_10937a.iso (11.2) or https://altd.embarcadero.com/download/radstudio/12.0/RADStudio_12_1_esd_61_7529b.exe (12.1) Executed installation Checked C++ Builder, unchecked Delphi, no other change Executed C++ Builder File > New > Windows VCL Application No modification to source code Turned off Link with Dynamic RTL and Link with Runtime Packages (to enable VCL debugging, as per for example C++ Builder XE2 - is it possible to debug vcl data library?) I've also tried turning on Delphi Compiler > Compiling > Use debug dcus (without any noticeable effect) Stepped into: _tWinMain Application->CreateForm(__classid(TForm5), &Form5); Instance.Create(Self); TForm(Owner) TCustomForm(AOwner) Resulting Call Stack window attached Is debugging VCL in C++ Builder 11/12 really broken? Can it be fixed with some settings? Or am I doing something wrong? I did submit RSS-903 on Embarcadero Quality Portal weeks ago. No response. But I cannot imagine that it really does not work at all. I wonder how others use C++ Builder 11/12. To me, it's useless without ability to debug VCL. I've also already asked this on Stack Overflow, unfortunately with little response (Except for Remy Lebeau, who seem to be an active member here too). C++ Builder does not seem to be a busy topic on Stack Overflow. I'm new here, with hope to find more active C++ Builder users 🙂 Thanks in advance for any help or experience with C++ Builder 12/13 debugging. Share this post Link to post
Lajos Juhász 293 Posted September 11 According to https://www.embarcadero.com/docs/rad-studio-feature-matrix.pdf version 12.2 should greatly improove the C++ side. Share this post Link to post
Roger Cigol 103 Posted September 11 This is related to the different debugger technology in use for Delphi and the different C++ compilers. This is unlikely to change between 12.1 and 12.2 (it would be a big change to change the debugger for a particular compiler - not one that would normally be done as as a same version upgrade). I am sure there is another posting on delphi-praxis covering exactly this issue - but I must admit I spent five minutes looking and couldn't find it. Share this post Link to post
Roger Cigol 103 Posted September 11 This page lists the different debuggers https://docwiki.embarcadero.com/RADStudio/Athens/en/Debugging_Multi-Device_Applications Have you tried selecting the "classic" compiler? - this will (I think) debug into the VCL. Share this post Link to post
Remy Lebeau 1416 Posted September 11 The Win32, Win64, and clang compilers use different debuggers. And as everything is slowly moving towards being entirely clang/LLVM, the old debuggers just don't keep up with the latest debugging info that is being generated, which causes weird side effects. Share this post Link to post
Martin Prikryl 0 Posted September 12 17 hours ago, Roger Cigol said: This page lists the different debuggers https://docwiki.embarcadero.com/RADStudio/Athens/en/Debugging_Multi-Device_Applications Have you tried selecting the "classic" compiler? - this will (I think) debug into the VCL. Thanks. Though as I've mentioned in my post, I've tried all. Classic/Modern, 32/64, none work. I really wonder, how people use VCL in C++ Builder 11/12 without being able to debug it. It seems useless to me for any advanced programming. Share this post Link to post
Martin Prikryl 0 Posted September 12 14 hours ago, Remy Lebeau said: The Win32, Win64, and clang compilers use different debuggers. And as everything is slowly moving towards being entirely clang/LLVM, the old debuggers just don't keep up with the latest debugging info that is being generated, which causes weird side effects. Thanks. So is there any combination/setup of compilers/linkers/libraries with which the debugging work in the current version of C++ Builder? Share this post Link to post
Roger Cigol 103 Posted September 13 21 hours ago, Martin Prikryl said: I really wonder, how people use VCL in C++ Builder 11/12 I've been using C++ with VCL since the early 1990s and still think it's the easiest way to write C++ GUI windows apps. 1 Share this post Link to post
stukelly1 0 Posted September 16 On 9/12/2024 at 11:44 AM, Martin Prikryl said: I really wonder, how people use VCL in C++ Builder 11/12 without being able to debug it. It seems useless to me for any advanced programming. I started using C++ Builder 6 at university in 2000. I recently helped upgrading two VCL based EPOS systems from BDS 2006 to Rad Studio 11. Share this post Link to post
Martin Prikryl 0 Posted September 16 (edited) I'm using C++ Builder myself since about 2000 too. Hence my question. From my experience, I need to debug VCL regularly. Both to solve bugs and to understand inner details of the library. And I'm not able to do that in 11/12. So far no one here mentioned if it is indeed broken, or if it is just me. Does no one need to debug VCL? Thanks. Edited September 17 by Martin Prikryl Share this post Link to post
Remy Lebeau 1416 Posted September 16 I started using C++Builder in the early 2000s with BCB v5, and then used v6 exclusively for ~15 years. But my day job doesn't use C++Builder anymore, so I haven't used it at all in recent years. Share this post Link to post