One, install secure shell, then the SSH Secure Shell client and SSH secure File Transfer client two shortcuts will appear.
You need the server's IP address, username and password to connect to the server.
Second, use SSH Secure file Transfer client to upload the source program files to be run.
Third, compile the source program
Use the command g++/home/olap/lyr/main.cpp-lpthread to compile the program.
Where/home/olap/lyr/main.cpp is the path to the source program main.cpp, this path can be obtained from the transfer client.
Four, run the program
Use the command./a.out
In this experiment, the number of threads needed to be passed in as parameters. So the Run command is./a.out 1
The number of 1-bit threads. A.out is the name of the program generated after compilation.
Five, the debugging of the program
1, generate debug information at compile time.
Using the command g++-G
Example: g++-g/home/olap/lyr/main.cpp-lpthread
2, enter the debug state.
Using the command GDB--args the parameters required by the program name
Example: GdB--args a.out 31
The following information appears:
3, run the program
After you see the (gdb) command prompt, enter R, and then enter. where r is the abbreviation for run, indicating that the program starts running.
The following message appears:
4, the last step after 2-3 seconds, not too long, that is, the program is still running, press CTRL + C, at this time, the program will stop
Displays the following:
Each time you press CTRL + C is actually a program that pauses at a random time, then the things that each thread executes at this moment are very representative,
Indicates that this thread may have been executing this for a long time.
5, and then enter info threads, the information for each thread is displayed. Which belt?? A thread that indicates that the thread is running in a problem. means that the thread is stuck in the operating system call.
6, for the problematic thread, using the command thread thread number, enter, and then input BT, the thread will display the call stack, look at the individual functions of the situation, to further discover the problem.
Note that the following last line of information appears after the thread's information is displayed, before the thread thread is entered, and if there are too many threads to display more than one screen:
At this point, enter Q at the (gdb) command prompt, enter the thread thread number to display the stack information for the relevant thread.
Use of SSH Secure Shell