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.
You cannot execute C++ source files. You have to first compile them into executables. Then you run the executable. C++ is not an interpreted scripting language.
To debug a c++ program you need to:
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)
Since your question is tagged with linux, you may want to use gdb. There also exist tools that provide a gui.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.