CN104239055A - Method for detecting complexity of software codes - Google Patents

Method for detecting complexity of software codes Download PDF

Info

Publication number
CN104239055A
CN104239055A CN201410470193.7A CN201410470193A CN104239055A CN 104239055 A CN104239055 A CN 104239055A CN 201410470193 A CN201410470193 A CN 201410470193A CN 104239055 A CN104239055 A CN 104239055A
Authority
CN
China
Prior art keywords
complexity
code
executable file
subfunction
software
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.)
Pending
Application number
CN201410470193.7A
Other languages
Chinese (zh)
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.)
Dalian Roiland Technology Co Ltd
Original Assignee
Dalian Roiland Technology Co Ltd
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 Dalian Roiland Technology Co Ltd filed Critical Dalian Roiland Technology Co Ltd
Priority to CN201410470193.7A priority Critical patent/CN104239055A/en
Publication of CN104239055A publication Critical patent/CN104239055A/en
Pending legal-status Critical Current

Links

Abstract

The invention relates to a method for detecting complexity of software codes. The method comprises the following steps: extracting a specified code segment which needs complexity measurement from a software system, editing the specified code segment into a subfunction, putting the subfunction into a new software engineering, and compiling to generate an executable file; performing reverse analysis by use of the obtained executable file, and disassembling the executable file with specified codes, thereby obtaining the time complexity or space complexity of the specified code segment of the software system.

Description

The method of inspection software code complexity
Technical field
The present invention relates to computer realm, particularly relate to a kind of method of inspection software code complexity.
Background technology
At present, nearly all adopt high level language to carry out code at software development process at present to write, and picture C, C++, the senior preamble such as JAVA cannot realize the accurate control to Time and place, so the debug phase does not have a kind of effective method to measure to the time complexity of code and space complexity.
Such as, in a kind of application scenarios, require that one period of code execution time is short as much as possible, the do-while of the use in the circulating cycle loop statement can only tried one's best at present, avoid using for statement.But use do-while by the time shorten of this section of code to how many, can lose how many spaces in this case, then be difficult to judge.
Because above-mentioned defect, the design people, actively in addition research and innovation, to founding a kind of method of inspection software code complexity, make it have more value in industry.
Summary of the invention
For solving the problems of the technologies described above, the object of this invention is to provide a kind of can the method for inspection software code complexity.
The method of inspection software code complexity of the present invention, comprising:
From software systems, extract the code segment of specifying needing to measure complexity, described code segment of specifying is compiled subfunction, puts into new soft project, compiling generates executable file, and wherein, described complexity comprises time complexity or space complexity;
Utilize the executable file obtained to carry out conversed analysis, dis-assembling is carried out to the executable file of appointment codes, obtains the appointment codes section complexity of described software systems.
Further, described subfunction is specially 16 signless rreturn values and does not have the function of input.
Further, described described code segment of specifying is compiled subfunction, put into new soft project, compiling generates executable file and is specially: the engineering of a newly-built support Microsoft Foundation class libraries MFC, by described code copies of specifying in the engineering of described support MFC, after compiling, generate executable program.
Further, the executable file that described utilization obtains carries out conversed analysis, carries out dis-assembling to the executable file of appointment codes, obtains the appointment codes section complexity of described software systems, specifically comprises:
Described executable file is imported in third party software, described executable file is carried out dis-assembling, obtain assembly code, search from all function code and obtain the subfunction that does not have distributing operation system interface function, analyze the complexity obtaining described subfunction.
By such scheme, the present invention at least has the following advantages:
The present invention passes through time complexity and the space complexity of the technology determination particular code segment of conversed analysis, the final code using this technology directly to generate towards compiler is analyzed, eliminate the impact of optimizational function on code of compiler, direct towards assembly language analysis in addition, can the time complexity of point-device analysis this section of code and space complexity.This analytical approach specific surface has the advantage of accuracy to high level language analysis, can draw accurate numerical value, is used for client or program developer reference.
Above-mentioned explanation is only the general introduction of technical solution of the present invention, in order to better understand technological means of the present invention, and can be implemented according to the content of instructions, coordinates accompanying drawing to be described in detail as follows below with preferred embodiment of the present invention.
Accompanying drawing explanation
Fig. 1 is the method flow diagram of inspection software code complexity of the present invention;
Fig. 2 is C++ instruction after the code write subfunction to be analyzed of the embodiment of the present invention;
Fig. 3 is the performed binary file of the generation of the embodiment of the present invention;
Fig. 4 is the interface of ejecting after the performed binary file of the embodiment of the present invention imports IDAPRO;
Fig. 5 is the code of the distributing operation system interface function of the embodiment of the present invention;
Fig. 6 is the assembly code that the machine code of the code compilation generation to be analyzed of the embodiment of the present invention generates after dis-assembling;
Fig. 7 is the graphic structure figure of the assembly code of the embodiment of the present invention.
Embodiment
Below in conjunction with drawings and Examples, the specific embodiment of the present invention is described in further detail.Following examples for illustration of the present invention, but are not used for limiting the scope of the invention.
Shown in Figure 1, a kind of method of inspection software code complexity, comprising:
Step 101: extract the code segment needing to measure complexity from whole software systems, compile subfunction, put into new software systems, compiling generates executable file, the object done like this finds the code of specifying in order to what be more prone in conversed analysis, and wherein complexity comprises time complexity or space complexity.
There is one section of code as shown in Figure 2, analyze time complexity and the space complexity of this section of code.First this section of Code Edit is become subfunction, as Fig. 2, subfunction has 16 signless rreturn values, not input, and subfunction name is called jiaoyan ().Observe this section of code, have the form of two 32 bytes, the circulation of 8 times.Select a compiler afterwards, the compiler that this example uses is VC++6.0, and a newly-built engineering supporting MFC, by code copies in engineering, generates the executable program that suffix is called exe after compiling connection.As shown in Figure 3, the file of generation is called t123456.exe, is the file of a 20K.Code in this file becomes machine code from C Plus Plus, so that computer CPU resolves execution when running.
After step 102, generation executable file, the executable file obtained is utilized to carry out conversed analysis.The code segment that this process utilizes the mode conversed analysis of static disassembly to specify, this mode utilizes third party software IDAPRO, by this third party software, dis-assembling is carried out to the executable file of appointment codes, thus hold the structure of appointment codes section on the whole, obtain appointment codes section time complexity or the space complexity of system software.
Detailed process: first import in third party software by executable file, clicks newly-built in third party software, there will be the interface of Fig. 4 after selecting the file t123456.exe just now generated, and directly puts OK just passable.Can see afterwards this software auxiliary under, above-mentioned executable file is become assembly code, and the process machine code that compiler generates being become assembly language is just called reverse.Because this file is very little, after reverse one-tenth assembly language, size of code is also very little, so be easy to the code finding Water demand.Can see in this example that code is from the 0x401000 of address, down looks for from this address, very fast assembly code after subfunction the jiaoyan () compiling that address 0x401320 finds us to analyze.
Location code from 0x401000 place, address, the code of distributing operation system interface function is had in nearly all function code, as Fig. 5, the random result having intercepted the conversed analysis of a function, namely SendMessageA and GetSystemMetrics of the inside be the interface function of the operating system called, then continue to look for downwards, until find a subfunction not having distributing operation system interface function, this subfunction is exactly the subfunction found.
The executable code that analyse compiler generates, the real executable code that the assembly code obtained generates after being every optimization process of removal compiler.
Then on the basis of assembly language, analyze appointment codes section further, is now assembly language, and the Time and place needed for code performs can point-devicely obtain.
Fig. 6 is a kind of display mode of the assembly code after subfunction the jiaoyan () compiling intercepted.Fig. 7 is another kind of display mode, being easy to see in this pictures has a circulation, with C++ code unlike, here can't see the vestige of 8 circulations, this just can find out compiler have impact on code, is also the basic reason that Direct Analysis C++ code can not obtain time complexity and space complexity accurately.
Next be exactly the concrete analysis to this paragraph assembly code, with regard to the space complexity of this section of code, this section of code has two values of tabling look-up, each table takies 32 byte data spaces, and this subfunction does not have local variable, all can take a small amount of stack address, are used for depositing function call information.The time complexity of this subfunction is the numerical value determined, because cycle index is fixing 8 times, the code quantity that each circulation performs also is identical.Obtain concrete machine cycle number, can by analyzing the machine cycle number that every bar assembly instruction takies, the time complexity that just can obtain whole subfunction added together.
The present invention is by mode that is static and dynamically dis-assembling, the code segment that conversed analysis is specified, analyze the executable file that compiler generates due to direct, the optimization process function can removing compiler, on the impact of code, more directly obtains final executable file.In addition, be assembly language due to what analyze, the Time and place that appointment codes section consumes can be analyzed very accurately.
Beneficial effect of the present invention is: the present invention passes through time complexity and the space complexity of the technology determination particular code segment of conversed analysis, the final code using this technology directly to generate towards compiler is analyzed, eliminate the impact of optimizational function on code of compiler, direct towards assembly language analysis in addition, can the time complexity of point-device analysis this section of code and space complexity.This analytical approach specific surface has the advantage of accuracy to high level language analysis, can draw accurate numerical value, is used for client or program developer reference.
The above is only the preferred embodiment of the present invention; be not limited to the present invention; should be understood that; for those skilled in the art; under the prerequisite not departing from the technology of the present invention principle; can also make some improvement and modification, these improve and modification also should be considered as protection scope of the present invention.

Claims (4)

1. a method for inspection software code complexity, is characterized in that, comprising:
From software systems, extract the code segment of specifying needing to measure complexity, described code segment of specifying is compiled subfunction, puts into new soft project, compiling generates executable file, and wherein, described complexity comprises time complexity or space complexity;
Utilize the executable file obtained to carry out conversed analysis, dis-assembling is carried out to the executable file of appointment codes, obtains the appointment codes section complexity of described software systems.
2. the method for inspection software code complexity according to claim 1, is characterized in that, described subfunction is specially 16 signless rreturn values and does not have the function of input.
3. the method for inspection software code complexity according to claim 1, it is characterized in that, described described code segment of specifying is compiled subfunction, put into new soft project, compiling generates executable file and is specially: the engineering of a newly-built support Microsoft Foundation class libraries MFC, by described code copies of specifying in the engineering of described support MFC, after compiling, generate executable program.
4. the method for inspection software code complexity according to claim 1, it is characterized in that, the executable file that described utilization obtains carries out conversed analysis, carries out dis-assembling to the executable file of appointment codes, obtain the appointment codes section complexity of described software systems, specifically comprise:
Described executable file is imported in third party software, described executable file is carried out dis-assembling, obtain assembly code, search from all function code and obtain the subfunction that does not have distributing operation system interface function, analyze the complexity obtaining described subfunction.
CN201410470193.7A 2014-09-15 2014-09-15 Method for detecting complexity of software codes Pending CN104239055A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201410470193.7A CN104239055A (en) 2014-09-15 2014-09-15 Method for detecting complexity of software codes

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201410470193.7A CN104239055A (en) 2014-09-15 2014-09-15 Method for detecting complexity of software codes

Publications (1)

Publication Number Publication Date
CN104239055A true CN104239055A (en) 2014-12-24

Family

ID=52227197

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201410470193.7A Pending CN104239055A (en) 2014-09-15 2014-09-15 Method for detecting complexity of software codes

Country Status (1)

Country Link
CN (1) CN104239055A (en)

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107025109A (en) * 2015-12-26 2017-08-08 英特尔公司 The technology quoted using the native code of Binary analysis
CN111124424A (en) * 2019-12-27 2020-05-08 珠海金山网络游戏科技有限公司 Method and device for analyzing algorithm complexity
CN111190818A (en) * 2019-12-24 2020-05-22 中国平安财产保险股份有限公司 Front-end code analysis method and device, computer equipment and storage medium
CN113268242A (en) * 2020-02-17 2021-08-17 北京达佳互联信息技术有限公司 Code compiling time length determining method and device, electronic equipment and storage medium

Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1930552A (en) * 2004-01-14 2007-03-14 原子能源局 System for automatically generating optimised codes

Patent Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1930552A (en) * 2004-01-14 2007-03-14 原子能源局 System for automatically generating optimised codes

Non-Patent Citations (3)

* Cited by examiner, † Cited by third party
Title
HOODLUM1980: "对strlen汇编代码的解释", 《HTTP://WWW.CNBLOGS.COM/HOODLUM1980/ARCHIVE/2010/08/04/1792322.HTML》 *
VENTO: "利用IDA Pro反汇编程序", 《HTTP://WWW.CNBLOGS.COM/VENTO/ARCHIVE/2013/02/09/2909579.HTML》 *
沙梓杜等: "《iOS应用逆向工程-分析与实战》", 31 January 2014 *

Cited By (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107025109A (en) * 2015-12-26 2017-08-08 英特尔公司 The technology quoted using the native code of Binary analysis
CN111190818A (en) * 2019-12-24 2020-05-22 中国平安财产保险股份有限公司 Front-end code analysis method and device, computer equipment and storage medium
CN111190818B (en) * 2019-12-24 2023-07-21 中国平安财产保险股份有限公司 Front-end code analysis method, front-end code analysis device, computer equipment and storage medium
CN111124424A (en) * 2019-12-27 2020-05-08 珠海金山网络游戏科技有限公司 Method and device for analyzing algorithm complexity
CN111124424B (en) * 2019-12-27 2023-09-19 珠海金山数字网络科技有限公司 Method and device for analyzing algorithm complexity
CN113268242A (en) * 2020-02-17 2021-08-17 北京达佳互联信息技术有限公司 Code compiling time length determining method and device, electronic equipment and storage medium

Similar Documents

Publication Publication Date Title
Kwon et al. Mantis: Automatic performance prediction for smartphone applications
US9047399B2 (en) Generating visualization from running executable code
US7530056B1 (en) Method and system for detecting runtime defects in a program by comparing correct and incorrect runs
US10540262B2 (en) Using edit and continue to dynamically set and unset optimizations in source code while debugging
CN105183592B (en) Method and apparatus for supporting performance evaluation
US8875111B2 (en) Intermediate language representation and modification
US20110126179A1 (en) Method and System for Dynamic Patching Software Using Source Code
CN104239055A (en) Method for detecting complexity of software codes
WO2017128952A1 (en) Stack protection method and device
Buinevich et al. Method and prototype of utility for partial recovering source code for low-level and medium-level vulnerability search
KR20140033616A (en) Apparatus and method for detecting error and determining corresponding position in source code of mixed mode application program source code thereof
CN105204837B (en) Method and device for realizing logic programming
US7684971B1 (en) Method and system for improving simulation performance
US10303468B2 (en) Real-time quality of service monitoring apparatus and method
JP6357814B2 (en) Analysis of incomplete software
Kwon et al. Mantis: Efficient predictions of execution time, energy usage, memory usage and network usage on smart mobile devices
CN105550575A (en) Method and device for obtaining un-exported function address and data structure offset
EP2972880B1 (en) Kernel functionality checker
CN112016099A (en) Method and system for analyzing static taint among binary program processes
CN104063329A (en) 64-bit immediate operand processing method and device
Molitorisz Pattern-based refactoring process of sequential source code
US9606779B2 (en) Data processing system and data simulation method in the system
Dooley et al. Detecting and using critical paths at runtime in message driven parallel programs
CN108415836B (en) Method and system for detecting performance change of computer system by using application program
Linford et al. Performance analysis of openshmem applications with tau commander

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
AD01 Patent right deemed abandoned
AD01 Patent right deemed abandoned

Effective date of abandoning: 20181102