Solve the row number mismatch during GDB debugging-File Format Conversion

Source: Internet
Author: User
First speech: Design Model sentiment. If we recall and summarize the process of making ourselves into something, we will accumulate experience.

When a DOS file is transmitted to a UNIX system, it will end with an extra ^ m at the end of each line. Of course, it may not be visible, but the format of this file will be shown below in VI, for example, "dos.txt" [dos] 120l, 2532c indicates a [dos] format file. If it is a MAC system, it will display [Mac]. If it is displayed normally, it will80l, 2391c, no [], because the file format may sometimes cause errors in our UNIX program or shell program, you need to convert these DOS file formats to Unix format:

VI dos.txt
: Set fileformat = Unix
: W
In this way, the file will be converted to a UNIX file. This may happen if the file is written on a Windows machine and uploaded to Unix.
Use the command: Set ff?
You can see the DoS or Unix words.
Use: Set FF = UNIX to force it to Unix format
You can also use a tool like sed:
Sed's/^ m // 'filename> tmp_filename
^ M is simultaneously pressed by Ctrl + V + M, indicating the carriage return.

(1) in Linux, ^ m appears at the line feed.

Open the file with VI to see which file format is: Set ff and convert it to the corresponding file. If it is dos, convert it to Unix;

2) If the window system file appears at the line feed?

Use ultraedit to open the file and check the file format. If it is UNIX, call the corresponding options in the menu to convert UNIX to dos.

3) File Format

Differences in DOS and Unix format processing: DOS is carriage return + line feed, while in UNIX, only carriage return, no line feed!

Use scripts to determine the file format:

File filname | grep-QV ^ m & ECHO file is UNIX formart | ECHO file is dos formart

Iv) Experience summary:

Any line at the end of the line that appears similar to ^ m ,? The garbled characters are caused by incorrect file format. The file format in CVS checkout is dos in the window system and UNIX in the Unix system, (CVS automatically converts the file format based on platform differences by default.) Similarly, the MAC system should be in the Mac format, therefore, you must pay attention to the differences in file formats in several operating systems using FTP remote transmission tools. When you use CVS to manage source code, you are not allowed to use ftp to transmit source code files, first, FTP does not encrypt the file, which is not secure; second, it will cause confusion in the file format, leading to line feed errors, resulting in incorrect line numbers in GDB debugging.

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.