Tuesday, June 07, 2011
Using Lazarus as a GDB frontend
Did you know that you can use Lazarus to debug applications compiled with other languages than Pascal?. If not, I can tell you that yes, you can!.
Some times, I need to connect Delphi/FPC applications to C or C++ shared libraries compiled with gcc or g++, but its a pain to debug using command line gdb.
Lazarus to the rescue
One very interesting way to debug C++ code I use is to open one or more C++ source files in Lazarus, set breakpoints, then configure the host application and run. Magically the execution stops in the breakpoints I defined, and I can step and inspect symbols as I do usually on my Lazarus applications.
An example
I have a Delphi application that relies on a C++ Dll compiled with g++ (using the -g parameter to include debug information). Using Delphi, I can debug until the point an external function is called, but nothing further than that.
To be able to debug the dll source code, you can just follow this steps in Lazarus:
1) Project -> New -> Application.
2) File -> Open -> your_cpp_file
3) Define as many breakpoints (F5) as you need.
4) Run -> Run parameters -> Host application: c:\myapp\myapp.exe
5) Run -> Run parameters -> Working directory: c:\myapp
That's all, now just click on run (F9). This will open the host application, and when it calls the dll, the breakpoints you configured will be reached.
Some times, I need to connect Delphi/FPC applications to C or C++ shared libraries compiled with gcc or g++, but its a pain to debug using command line gdb.
Lazarus to the rescue
One very interesting way to debug C++ code I use is to open one or more C++ source files in Lazarus, set breakpoints, then configure the host application and run. Magically the execution stops in the breakpoints I defined, and I can step and inspect symbols as I do usually on my Lazarus applications.
An example
I have a Delphi application that relies on a C++ Dll compiled with g++ (using the -g parameter to include debug information). Using Delphi, I can debug until the point an external function is called, but nothing further than that.
To be able to debug the dll source code, you can just follow this steps in Lazarus:
1) Project -> New -> Application.
2) File -> Open -> your_cpp_file
3) Define as many breakpoints (F5) as you need.
4) Run -> Run parameters -> Host application: c:\myapp\myapp.exe
5) Run -> Run parameters -> Working directory: c:\myapp
That's all, now just click on run (F9). This will open the host application, and when it calls the dll, the breakpoints you configured will be reached.
Comments:
<< Home
hi
i have downloaded ta lib pro 2.5
but i dono ho w to install?
what are the requirements needed and how to install it?
do i need to install c++ to run tal lib excell add in sir?
kindly let me know
Post a Comment
i have downloaded ta lib pro 2.5
but i dono ho w to install?
what are the requirements needed and how to install it?
do i need to install c++ to run tal lib excell add in sir?
kindly let me know
<< Home