Hello everyone! Welcome to my blog.
Today I will cover the topic of the debugger in the Haiku OS. When the programming (coding) journey begins, a various error comes. Some are easy to handle, some are not.
As a begging, we don’t know how to find our mistakes in the huge lines of code. It was very difficult to find. Yesterday I gain knowledge about debugger from my mentor. I never use debugger until now. Yesterday he told me to step by step and today I am able to find the error in a very easy way. 🙂 I want to share my knowledge with you all reading my blog. This blog is especially for beginners who are new to Haiku. 🙂
There is a tool that is called the debugger. Basically, what the debugger will do?
A debugger is a software program used to test and find bugs (errors) in the programs.
Let’s start with the debugger journey.
Step1. Go to the following directory:
Step2. Read the files that are marked in the above image:
There are two files UserBuildConfig.ReadMe and UserBuildConfig.sample.
UserBuildConfig.ReadMe: It contains documentation about how to use the debugger.
We can also read from there but, I was writing my blog to share my experience with the beginners.
UserBuildConfig.sample: It contains the sample of how we have to create the file to debug the application.
Step3. Now, Create the new file as same as the UserBuildConfig.a sample including the text “SetConfigVar DEBUG: HAIKU_TOP src preferences input: 1: global;” (where src preferences input are the path of the file which we have to debug.)
Here, we are declaring the value of DEBUG = 1 which means, to start the debugging of the application mentioned in the above line (input).
Step4. Run jam.
Now, while building it you will see that the paths change from “Haiku/generated/objects/haiku/x86_64/release/preferences/input/Input” to “Haiku/generated/objects/haiku/x86_64/debug_1/preferences/input/Input”. Now, you build your application in debug mode and its time to start source level debugging.
Step5. Use scp cmmand to tranfer the application from local machine to remote machine.
scp [OPTION] [user@]SRC_HOST:]file1 [user@]DEST_HOST:]file2
Step6. Example: Let the application crashes due to the error in the file. WHen you clcik on the application to run. The debug Window comes as shown below:
Step7. Click on the debug option and give the path to the file in the debugger window.. Now, you see in the variable block There is the name of the function which crashes the application. At the same time when you give the path to that file, you will able to see that which line of code crashes the applicatin.
The yellow color indicates the line which crashes the application.
Thank you to all for reading. I will also make a video on it and upload it on youtube soon. 🙂