Port SCOUNIX to Linux-general Linux technology-Linux programming and kernel information. The following is a detailed description. A recent project required to port a Cabinet system originally running on the sco unix operating system to the Red Hat Linux AS platform. Now there seems to be a trend. The financial industry's systems originally running under SCO are all ready to be migrated to LINUX.
The following is a brief summary of some experiences in the migration process.
I. Differences between SCO cc and LINUX gcc
In general, the gcc compiler in linux is much stricter than cc in sco. Through this transplantation, it is found that SCO's cc has little strict program requirements. For example, the strcpy () function should be two functions. If you give it three parameters, compilation can also pass. In addition, if a function parameter should be a value, you can send it an address, and cc will not report an error.
SCO cc and linux gcc have the most obvious difference in processing null pointers. For example, strcpy (), strncpy (), strcmp (), strncmp (), and fclose (). On SCO, if one of the parameters is a null pointer, the program will not use the core. But in LINUX, if one of these functions is a null pointer, the core will be used during the program running. During the porting process, we found that as long as the core occurs during the program running, it is a null pointer.
Therefore, the first step of porting is to encapsulate the preceding common string operation functions, and then replace the original functions with the encapsulated functions.
Ii. Use of gdb
Since I have not written a program in liunx before, I have never used the gdb debugging tool. This migration also learned some basic debugging steps of gdb.
Gdb executable program
B. set breakpoints
R running program
Run the program again after the c endpoint.
N. Execute the next statement.
S enters the function body for debugging (relative to n)
Attach PID debug a running program
Iii. core files
In SCO, a core file is usually generated in the executable directory of the program core. We can use dbx to check where the core file appears in the program.
In LINUX, the core file is not generated at the beginning. Later, we found that we needed to set the maximum value allowed by the core File manually. If this parameter is not set, the default value is 0, and the core file is not generated.
The setting method is as follows:
Run ulimit-c 102400. You can place this command in the user's logon shell, so that you do not need to reset it every time you log on.
You can use "gdb executable program name core File Name" to check where the program displays core.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.