CN112181857B - Cross-processor Linux software to be migrated positioning and evaluating method - Google Patents

Cross-processor Linux software to be migrated positioning and evaluating method Download PDF

Info

Publication number
CN112181857B
CN112181857B CN202011228686.1A CN202011228686A CN112181857B CN 112181857 B CN112181857 B CN 112181857B CN 202011228686 A CN202011228686 A CN 202011228686A CN 112181857 B CN112181857 B CN 112181857B
Authority
CN
China
Prior art keywords
software
migrated
file
list
source code
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202011228686.1A
Other languages
Chinese (zh)
Other versions
CN112181857A (en
Inventor
周威
姚建华
夏海平
李祖华
汤慧明
张磊
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Wuhan Deepin Technology Co ltd
Wuxi Jiangnan Computing Technology Institute
Original Assignee
Wuhan Deepin Technology Co ltd
Wuxi Jiangnan Computing Technology Institute
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Wuhan Deepin Technology Co ltd, Wuxi Jiangnan Computing Technology Institute filed Critical Wuhan Deepin Technology Co ltd
Priority to CN202011228686.1A priority Critical patent/CN112181857B/en
Publication of CN112181857A publication Critical patent/CN112181857A/en
Application granted granted Critical
Publication of CN112181857B publication Critical patent/CN112181857B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3604Software analysis for verifying properties of programs

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Software Systems (AREA)
  • Computer Hardware Design (AREA)
  • Quality & Reliability (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Devices For Executing Special Programs (AREA)

Abstract

The invention discloses a method for positioning and evaluating cross-processor Linux software to be migrated, which comprises the following steps: step one, collecting a migrated software list; step two, software in the dependent software package and software to be migrated are put into a software list to be migrated together; step three, analyzing the software in the software list to be migrated one by one; step four, obtaining a simplified list of software to be migrated; fifthly, determining the sequence of all software to be migrated; step six, acquiring compiling parameters and corresponding source code files to be compiled; step seven, if the source code file is an assembly file, recording the file name of the source code file into a file list to be migrated, wherein the range to be modified is the whole file; and step eight, if the source code file is a C/C + + file, processing aiming at the embedded assembly language, the conditional compilation macro and the platform related header file in the source code file. The method greatly improves the efficiency of cross-processor migration of the Linux software and reduces the serious dependence on manpower and experience.

Description

Cross-processor Linux software to be migrated positioning and evaluating method
Technical Field
The invention relates to the technical field of software migration, in particular to a method for positioning and evaluating cross-processor Linux software to be migrated.
Background
The existing software on the Linux operating system is mainly developed for the x86 and x86-64 instruction sets, but with the appearance of a plurality of domestic processor platforms, a large amount of software needs to be migrated from the x86-64 platform to other processor platforms. According to statistics, the line number of the source code of the Linux kernel exceeds 2700 ten thousand lines, and the line number of the source code of the chrome browser exceeds 1600 ten thousand lines; to migrate such a huge software, it is necessary to first locate which files and codes need to be migrated, and evaluate the corresponding specific code lines to be modified. Moreover, migration of one software to and from another software is involved, wherein some software also needs to be migrated.
In the existing environment, the software migration under the Linux operating system is mainly performed manually, and the general steps are as follows:
step 1, analyzing the dependency of software to obtain all the software (including the software itself) which depends on the software;
step 2, checking whether each software has been migrated on the target processor platform one by one, and deleting the software from the software list if the software has been migrated;
step 3, sequencing the software to be migrated according to the dependency, compiling the software one by one, modifying the source code of the software if an error occurs so that the software can be compiled and passed, trying to run the software after the compiling is passed, debugging the software if the error occurs in the running process, and repairing the error until the software finally runs and passes;
and (3) repeating the step 3 for each software until the target software can normally run finally.
There may be a repeated situation that some software passes the previous test, but the problem of the software is found again in the process of migrating other software, and the software needs to be repaired again.
The method has low working efficiency and high error rate, and is closely related to the experience abundance of workers: firstly, software dependency analysis is not automated, and manual analysis and inspection are needed one by one; secondly, each source code file is also lack of analysis in advance, errors need to be found in the compiling and running processes, then the errors are located according to the errors, and then the errors are repaired, so that the controllability of the whole software migration process is low, and the workload estimation depends on personal working experience seriously.
Disclosure of Invention
The invention aims to provide a method for positioning and evaluating cross-processor Linux software to be migrated, which greatly improves the efficiency of cross-processor Linux software migration and reduces the severe dependence on manpower and experience.
In order to achieve the purpose, the invention adopts the technical scheme that: a method for positioning and evaluating cross-processor Linux software to be migrated comprises the following steps:
step one, collecting and obtaining a software list which is migrated on a corresponding Linux operating system on a target processor platform by operating a dpkg-l command;
step two, for the software to be migrated, collecting a dependent software package corresponding to the software to be migrated on a Linux operating system on an x86-64 processor platform, putting the software in the obtained dependent software package and the software to be migrated into a software list to be migrated together, and recording the dependency relationship;
step three, adopting a breadth-first search algorithm or a depth-first search algorithm, and recursively using apt depends commands to analyze the software in the software list to be migrated one by one until no new software to be migrated is generated; at this time, the list of the software to be migrated includes all the software to be migrated and the dependency relationship between the software to be migrated;
step four, comparing the migrated software list obtained in the step one, deleting the software in the to-be-migrated software list and existing in the migrated software list, and deleting the dependency relationship related to the software to obtain a simplified to-be-migrated software list;
step five, determining the sequence of all the software to be migrated in the simplified software to be migrated list obtained in the step four by adopting a topological sorting algorithm for sequential analysis;
step six, aiming at each software to be migrated in the sorted software list to be migrated obtained in the step five, acquiring a source code packet of the software to be migrated by using an apt source command, and operating a simulation compiling command to acquire a compiling parameter and a source code file corresponding to the compiling parameter;
step seven, if the source code file is an assembly file, recording the file name of the source code file into a file list to be migrated, wherein the range to be modified is the whole file;
step eight, if the source code file is a C/C + + file, developing a parser based on the clang Preprocessor object, which is used for processing the embedded assembly language, the conditional compilation macro and the platform related header file in the source code file, and specifically comprises the following steps:
for the conditional compiling macro, if the conditional compiling macro contains x86 characters, judging whether the conditional compiling macro of the target processor platform exists correspondingly; if the corresponding conditional compilation macro exists and is not null, the code section is considered to support the target processor platform; if the corresponding conditional compiling macro does not exist, checking whether the tail of the corresponding conditional compiling macro has a # else conditional compiling macro; if the # else conditional compilation macro exists, the section of code is considered to support the target processor platform; if the source code file does not exist, adding the source code file into a file list to be migrated, and compiling codes corresponding to the macro by taking the range to be modified as the condition;
if the embedded assembly language codes still exist except the conditional compiling macro, adding the corresponding source code file into a file list to be migrated, wherein the range to be modified is the embedded assembly language codes;
if the header files include mmintrin. H, zmintrin. H or xmintrin. H except the conditional compiling macro, the corresponding source code files are added into the list of the files to be migrated, and the range to be modified is the code of the corresponding header file.
The further improved scheme in the technical scheme is as follows:
1. in the above scheme step, the dependent software package in step two filters dependeds in the output result by running the apt dependeds command, and obtains the dependeds in the beginning text line.
Due to the application of the technical scheme, compared with the prior art, the invention has the following advantages:
the invention discloses a method for positioning and evaluating cross-processor Linux software to be migrated, which realizes the automatic analysis comparison and sequencing of cross-processor software to be migrated on a Linux platform and the cross-processor migration syntactic analysis of a source code file, automatically analyzes the Linux software dependence and the code range to be migrated in a source file, greatly improves the cross-processor migration efficiency of the Linux software and reduces the serious dependence on manpower and experience.
Detailed Description
Example (b): the invention relates to a method for positioning and evaluating cross-processor Linux software to be migrated, which mainly aims at positioning and evaluating software migration in a Linux operating system;
more than one Linux operating system is provided, but the mainstream Linux operating system basically adopts a deb or rpm packet format, wherein the deb is more open, and the rpm is more closed; technically, the two are not essentially different. The method is mainly developed based on the deb packet format, but the technical principle is also suitable for other packet formats such as rpm and the like;
assuming that the target software is named as $ target-sw, automatically analyzing and positioning Linux software to be migrated and named as $ target-sw and dependent software thereof, and specifically comprising the following steps:
step one, collecting a software list which is migrated on a corresponding Linux operating system on a target processor platform by operating a dpkg-l command;
step two, collecting a dependency software package corresponding to $ target-sw on a Linux operating system on an x86-64 processor platform, putting software in the obtained dependency software package and $ target-sw into a software list to be migrated together, and recording a dependency relationship, wherein the dependency software package filters dependeds from an output result by running apt dependeds $ target-sw and obtains the dependeds from a beginning text line;
step three, adopting a breadth-first search algorithm or a depth-first search algorithm, and recursively using apt depends commands to analyze the software in the software list to be migrated until no new software to be migrated is generated; at this time, the list of the software to be migrated includes all the software to be migrated and the dependency relationship between the software to be migrated;
step four, comparing the migrated software list on the corresponding Linux operating system on the target processor platform, deleting the software in the to-be-migrated software list and existing in the migrated software list, and deleting the dependency relationship related to the software to obtain a simplified to-be-migrated software list;
step five, determining the sequence of all the software to be migrated in the simplified software to be migrated list obtained in the step four by adopting a topological sorting algorithm for analyzing in sequence;
step six, aiming at each software to be migrated in the sorted software list to be migrated obtained in the step five, acquiring a source code packet of the software to be migrated by using an apt source command, operating a simulation compiling command (make-n command), and acquiring compiling parameters and a source code file corresponding to the software to be compiled;
step seven, if the source code file is an assembly file, recording the file name of the source code file into a file list to be migrated, wherein the range to be modified is the whole file;
step eight, if the source code file is a C/C + + file, developing a parser based on the clang Preprocessor object, which is used for processing the embedded assembly language (marked as _asm _), the conditional compilation macro (# ifdef, etc.) and the platform related header file in the source code file, specifically as follows:
for the conditional compilation macro, if the conditional compilation macro contains x86 characters, judging whether the conditional compilation macro of the target processor platform exists correspondingly, for example, the corresponding macro of the Shenwei processor is SW64; if the corresponding conditional compilation macro exists and is not null, the section of code contained by the # if conditional compilation macro is considered to support the target processor platform; if the corresponding conditional compiling macro does not exist, checking whether a # else conditional compiling macro exists at the tail of the conditional compiling macro; if the # else conditional compilation macro exists, considering that the section of code contained in the # else conditional compilation macro supports the target processor platform; if the source code file does not exist, adding the source code file into a file list to be migrated, and compiling codes corresponding to the macro by taking the range to be modified as the condition;
if the embedded assembly language codes still exist except the conditional compiling macro, adding the corresponding source code file into a file list to be migrated, wherein the range to be modified is the embedded assembly language codes;
if the head files contained in the conditional compiling macro comprise mminrin.h, zmminrin.h or xmminrin.h besides the conditional compiling macro, the corresponding source code files are added into the file list to be migrated, and the range to be modified is the codes of the corresponding head files.
In the above steps, there are several points to be explained:
assembly codes are strongly related to an instruction set, so the assembly codes need to be modified and migrated manually;
conditional compiled code associated with processor architecture macros (e.g., x86, SW64, etc.) are strongly processor-dependent, typically requiring manual modification migration, but if there is a final # else conditional compiled macro, taking into account cross-processor architecture support issues, no additional processing (and possibly performance enhancement) may be required;
header files such as mmitrin.h, though appearing to be implemented in C language from the file name, are actually packages of SIMD instructions strongly related to the processor, which are strongly related to the processor, and thus require special processing.
To facilitate a better understanding of the invention, the terms used herein will be briefly explained as follows:
AST: abstract Syntax Tree, which refers to a Tree-shaped program structure obtained by lexical analysis and Syntax analysis of source codes;
and Deb: package formats used by the Debian release and Debian derivative release encapsulation software;
depends: a tool that can check which dll files an exe file or dll file needs to depend on;
clang: a lightweight compiler for C, C + +, and Objective-C languages.
By adopting the method for automatically positioning and evaluating the Linux software platform migration, the automatic dependence analysis comparison and sequencing of the cross-processor software to be migrated on the Linux platform and the cross-processor migration syntax analysis of the source code file are realized, the Linux software dependence and the code range to be migrated in the source file are automatically analyzed, the cross-processor migration efficiency of the Linux software is greatly improved, and the serious dependence on manpower and experience is reduced.
The above embodiments are merely illustrative of the technical ideas and features of the present invention, and the purpose thereof is to enable those skilled in the art to understand the contents of the present invention and implement the present invention, and not to limit the protection scope of the present invention. All equivalent changes and modifications made according to the spirit of the present invention should be covered in the protection scope of the present invention.

Claims (2)

1. A method for positioning and evaluating cross-processor Linux software to be migrated is characterized by comprising the following steps of:
step one, collecting and obtaining a software list which is migrated on a corresponding Linux operating system on a target processor platform by operating a dpkg-l command;
step two, for the software to be migrated, collecting a dependent software package corresponding to the software to be migrated on a Linux operating system on an x86-64 processor platform, putting the software in the obtained dependent software package and the software to be migrated into a software list to be migrated together, and recording the dependency relationship;
step three, adopting a breadth-first search algorithm or a depth-first search algorithm, and recursively using apt depends commands to analyze the software in the software list to be migrated one by one until no new software to be migrated is generated; at this time, the list of the software to be migrated includes all the software to be migrated and the dependency relationship between the software to be migrated;
step four, comparing the migrated software list obtained in the step one, deleting the software in the to-be-migrated software list and existing in the migrated software list, and deleting the dependency relationship related to the software to obtain a simplified to-be-migrated software list;
step five, determining the sequence of all the software to be migrated in the simplified software to be migrated list obtained in the step four by adopting a topological sorting algorithm for analyzing in sequence;
step six, aiming at each software to be migrated in the sorted software list to be migrated obtained in the step five, acquiring a source code packet of the software to be migrated by using an apt source command, and operating a simulation compiling command to acquire a compiling parameter and a source code file corresponding to the compiling parameter;
step seven, if the source code file is an assembly file, recording the file name of the source code file into a file list to be migrated, wherein the range to be modified is the whole file;
step eight, if the source code file is a C/C + + file, developing an analyzer for the Preprocessor object based on the clang, wherein the analyzer is used for processing the embedded assembly language, the conditional compilation macro and the platform-related header file in the source code file, and the analyzer is specifically as follows:
for the conditional compiling macro, if the conditional compiling macro contains x86 characters, judging whether the conditional compiling macro of the target processor platform exists correspondingly; if the corresponding conditional compilation macro exists and is not null, the code section is considered to support the target processor platform; if the corresponding conditional compiling macro does not exist, checking whether the tail of the corresponding conditional compiling macro has a # else conditional compiling macro; if the # else conditional compilation macro exists, the code section is considered to support the target processor platform; if the source code file does not exist, the source code file is added into a file list to be migrated, and the range to be modified is a code corresponding to the conditional compiling macro;
if the embedded assembly language codes still exist except the conditional compiling macro, adding the corresponding source code file into a file list to be migrated, wherein the range to be modified is the embedded assembly language codes;
if the head files contained in the conditional compiling macro comprise mminrin.h, zmminrin.h or xmminrin.h besides the conditional compiling macro, the corresponding source code files are added into the file list to be migrated, and the range to be modified is the codes of the corresponding head files.
2. The method for locating and evaluating the Linux to-be-migrated software across processors of claim 1, wherein: the dependent software package in step two filters dependeds in the output result by running the apt dependeds command, and gets it in the beginning text line.
CN202011228686.1A 2020-11-06 2020-11-06 Cross-processor Linux software to be migrated positioning and evaluating method Active CN112181857B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202011228686.1A CN112181857B (en) 2020-11-06 2020-11-06 Cross-processor Linux software to be migrated positioning and evaluating method

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202011228686.1A CN112181857B (en) 2020-11-06 2020-11-06 Cross-processor Linux software to be migrated positioning and evaluating method

Publications (2)

Publication Number Publication Date
CN112181857A CN112181857A (en) 2021-01-05
CN112181857B true CN112181857B (en) 2022-10-04

Family

ID=73917101

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202011228686.1A Active CN112181857B (en) 2020-11-06 2020-11-06 Cross-processor Linux software to be migrated positioning and evaluating method

Country Status (1)

Country Link
CN (1) CN112181857B (en)

Families Citing this family (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113238760B (en) * 2021-05-28 2024-06-04 统信软件技术有限公司 Software migration method, device, computing equipment and readable storage medium
CN114661439A (en) * 2022-03-24 2022-06-24 恒安嘉新(北京)科技股份公司 Method, device, equipment and storage medium for migrating system application configuration
CN115756601B (en) * 2022-10-28 2024-10-15 苏州棱镜七彩信息科技有限公司 Application migration method
CN117112730B (en) * 2023-08-23 2024-03-22 北京云枢创新软件技术有限公司 Target text searching method based on macro expansion text, electronic equipment and medium

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104572238A (en) * 2015-01-23 2015-04-29 烽火通信科技股份有限公司 Method and system for generating executable software package efficiently
US20150261766A1 (en) * 2012-10-10 2015-09-17 International Business Machines Corporation Method and apparatus for determining a range of files to be migrated

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20150261766A1 (en) * 2012-10-10 2015-09-17 International Business Machines Corporation Method and apparatus for determining a range of files to be migrated
CN104572238A (en) * 2015-01-23 2015-04-29 烽火通信科技股份有限公司 Method and system for generating executable software package efficiently

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
《ProfMig: A Framework for Flexible Migration of Program Profiles Across Software Versions》;Mingzhou Zhou 等;《Proceedings of the 2013 IEEE/ACM International Symposium on Code Generation and Optimization (CGO)》;20130227;全文 *
《基于Git 的跨版本迁移的软件评审设计与实现》;关婷婷 等;《现代计算机(专业版)》;20180731;全文 *

Also Published As

Publication number Publication date
CN112181857A (en) 2021-01-05

Similar Documents

Publication Publication Date Title
CN112181857B (en) Cross-processor Linux software to be migrated positioning and evaluating method
CN108710575B (en) Unit test method based on automatic generation of path coverage test case
CN110543421B (en) Unit test automatic execution method based on test case automatic generation algorithm
Harris et al. Practical analysis of stripped binary code
JP6287549B2 (en) Method and apparatus for porting source code
US8898647B2 (en) Method and apparatus for test coverage analysis
CN114036072B (en) Method and system supporting automatic detection of program defects
CN111752586A (en) Method and system for detecting unrepaired bugs of cross-architecture embedded equipment firmware
Hassan Tackling build failures in continuous integration
CN1299482A (en) Hybrid computer programming environment
US20150020051A1 (en) Method and apparatus for automated conversion of software applications
CN113935041A (en) Vulnerability detection system and method for real-time operating system equipment
CN110309656B (en) Implicit type conversion security detection method
JP2020129372A (en) Automated restoration of software program
JP2020129371A (en) Automated restoration of software program
CN111309301A (en) Program language conversion method, device and conversion equipment
CN115407997A (en) Agile development application method and system based on low codes
CN115098355A (en) Historical data drive-based JVM test program generation method
Wang et al. Bmat-a binary matching tool
US20150007139A1 (en) Optimizing error parsing in an integrated development environment
Kreutzer et al. Test Case Reduction: A Framework, Benchmark, and Comparative Study
Paltoglou et al. Automated refactoring of client-side JavaScript code to ES6 modules
Yuan et al. A method for detecting buffer overflow vulnerabilities
CN113282495A (en) Java software fault positioning method based on track monitoring
Martignano Static analysis for ada, c/c++ and python: Different languages, different needs

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant