I have a c++ executable file named test .. To execute it in my terminal I run…..
./test
Although I want to run it in debug mode wherein it shows the exact command being used immediately after being executed
If you are wondering what exactly I mean by debug mode.. Just like how we use -x for shell scripts
sh -x test.sh OR bash -x test.sh
This shows every command immediately after its executed .
I want same thing for this test c++ executable file. I hope there would be some way.
Advertisement
Answer
To debug a c++ program you need to:
1. Compile the program with debug information.
You need to tell the compiler to include information about symbols in the executable to be able to debug it later (at least to debug it in an easy way). For example if you use g++, add the -g option)
2. Run the program with attached debugger
Since your question is tagged with linux, you may want to use gdb. There also exist tools that provide a gui.