CN104881274B - The method for identifying dead code - Google Patents

The method for identifying dead code Download PDF

Info

Publication number
CN104881274B
CN104881274B CN201410072475.1A CN201410072475A CN104881274B CN 104881274 B CN104881274 B CN 104881274B CN 201410072475 A CN201410072475 A CN 201410072475A CN 104881274 B CN104881274 B CN 104881274B
Authority
CN
China
Prior art keywords
symbol
image file
dead code
map files
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
CN201410072475.1A
Other languages
Chinese (zh)
Other versions
CN104881274A (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.)
Yuanzhiuniverse (Fujian) Technology Group Co.,Ltd.
Original Assignee
Shanghai Feixun Data Communication 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 Shanghai Feixun Data Communication Technology Co Ltd filed Critical Shanghai Feixun Data Communication Technology Co Ltd
Priority to CN201410072475.1A priority Critical patent/CN104881274B/en
Publication of CN104881274A publication Critical patent/CN104881274A/en
Application granted granted Critical
Publication of CN104881274B publication Critical patent/CN104881274B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Landscapes

  • Debugging And Monitoring (AREA)
  • Stored Programmes (AREA)

Abstract

The present invention proposes a kind of method for identifying dead code, comprises the following steps:To source file compiling, link generation image file;To image file compiling, link generation map files;Entrance function main is specified, then by carrying out dis-assembling parsing to image file, obtains entrance function main symbolic reference tree;The symbol that map files are listed is searched in the symbolic reference tree, search less than symbol be useless symbol.The present invention provides a kind of method for identifying dead code, identifies that dead code can be cleared up, so as to reduce software maintenance difficulty, reduces the hardware space of occupancy, finally reduces product cost, improves product competitiveness.

Description

The method for identifying dead code
Technical field
The present invention relates to a kind of method for identifying dead code.
Background technology
During software development and maintenance, always some useless codes are inadvertently left(That is, rubbish code), These dead codes accumulate over a long period, cumulative, take the ROM Space and memory source of preciousness.
The content of the invention
The technical problem that the present invention need to solve is to provide a kind of method for identifying dead code, identifies dead code Cleared up so as to reduce software maintenance difficulty and reduce required hardware space.
To solve above-mentioned technical problem, the present invention devises a kind of method for identifying dead code, it is characterised in that bag Include following steps:
Step 1:To source file compiling, link generation image file;
Step 2:To image file compiling, link generation map files, or to source file compiling, link generation map texts Part;
Step 3:Entrance function main is specified, then by carrying out dis-assembling parsing to image file, obtains entrance function Main symbolic reference tree;
Step 4:The symbol that map files are listed is searched in the symbolic reference tree, search less than symbol be nothing Use symbol.
Further improved as of the invention, the image file is executable file a.out.
The present invention provides a kind of method for identifying dead code, identifies that dead code can be cleared up, so as to drop Low software maintenance difficulty, the hardware space of occupancy is reduced, finally reduce product cost, improve product competitiveness.
Brief description of the drawings
Fig. 1 is the schematic flow sheet of the embodiment of the method for present invention identification dead code.
Embodiment
In order that relevant technical staff in the field more fully understands technical scheme, below in conjunction with of the invention real The accompanying drawing of mode is applied, the technical scheme in embodiment of the present invention is clearly and completely described, it is clear that described reality Apply mode only a part of embodiment of the present invention, rather than whole embodiments.
, can be by the dead code of source file the invention provides a kind of method for identifying dead code(That is rubbish code)Know Do not come out.Identify dead code, you can carry out the deletion of next step.Dead code is deleted, software maintenance hardly possible can be reduced Degree and the hardware space for reducing occupancy.
As shown in figure 1, it is specific embodiment of the present invention, source file includes many codes, including useless generation Code and useful code.
In order to identify dead code, including following four step:
Step 1:First, to source file compiling, link generation image file, in the present embodiment, the image file is Executable file a.out.
Step 2:The image file a.out is compiled again, links generation map files.In other realities of the present invention Apply in example, source file can be compiled, link generation map files, be i.e. map files can also be generated by source file direct compilation, link. The symbol and symbol address information of all codes of source file are contained in map files, that is, includes dead code The symbol of symbol and useful code.
Step 3:Entrance function main is specified, then by carrying out dis-assembling parsing to image file, obtains entrance function Main symbolic reference tree.Entrance function main is specified, that is, recalls the code that can be called, the code that can be called is useful generation Code, thus, what the symbolic reference tree included is the symbol of useful code.
Step 4:The symbol that map files are listed is searched in the symbolic reference tree, search less than symbol be nothing With the symbol of code.As embodiment is shown in Fig. 1, " main, test_2, test_1 " can accorded with the symbol in map files Number quote tree in find, be useful code symbol, and " test_3 " symbolic reference tree search less than, " test_3 " be it is useless The symbol of code.Thus, symbolic reference tree search less than symbol be to be considered as the symbol of dead code.
The present invention provides a kind of method for identifying dead code, identifies that dead code can be cleared up, so as to drop Low software maintenance difficulty, the hardware space of occupancy is reduced, finally reduce product cost, improve product competitiveness.
Only express one embodiment of the present invention above, its describe it is more specific and in detail, but can not therefore and It is interpreted as the limitation to the scope of the claims of the present invention.It should be pointed out that for the person of ordinary skill of the art, do not taking off On the premise of present inventive concept, various modifications and improvements can be made, these belong to protection scope of the present invention.Cause This, the protection domain of patent of the present invention should be determined by the appended claims.

Claims (1)

  1. A kind of 1. method for identifying dead code, it is characterised in that comprise the following steps:
    Step 1:To source file compiling, link generation image file, the image file is executable file a.out;
    Step 2:To image file compiling, link generation map files, or to source file compiling, link generation map files; The symbol and symbol address information of all codes of source file are contained in the map files;
    Step 3:Entrance function main is specified, then by carrying out dis-assembling parsing to image file, obtains entrance function main's Symbolic reference tree;
    Step 4:The symbol that map files are listed is searched in the symbolic reference tree, search less than symbol be useless symbol Number.
CN201410072475.1A 2014-02-28 2014-02-28 The method for identifying dead code Active CN104881274B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201410072475.1A CN104881274B (en) 2014-02-28 2014-02-28 The method for identifying dead code

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201410072475.1A CN104881274B (en) 2014-02-28 2014-02-28 The method for identifying dead code

Publications (2)

Publication Number Publication Date
CN104881274A CN104881274A (en) 2015-09-02
CN104881274B true CN104881274B (en) 2018-02-13

Family

ID=53948783

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201410072475.1A Active CN104881274B (en) 2014-02-28 2014-02-28 The method for identifying dead code

Country Status (1)

Country Link
CN (1) CN104881274B (en)

Families Citing this family (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106598828B (en) * 2015-10-14 2018-11-30 阿里巴巴集团控股有限公司 A kind of invalid class in source code determines method and device
CN105511934B (en) * 2015-12-08 2018-11-13 贵阳朗玛信息技术股份有限公司 Method for processing resource in application development and device
CN107358099B (en) * 2017-06-09 2020-05-05 南京邮电大学 Useless variable detection method based on LLVM intermediate representation program slicing technology
CN110389764A (en) * 2019-06-19 2019-10-29 平安普惠企业管理有限公司 Dead code method for cleaning, equipment, storage medium and device
CN110879709A (en) * 2019-11-29 2020-03-13 五八有限公司 Detection method and device of useless codes, terminal equipment and storage medium

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
EP2090983A1 (en) * 2008-02-15 2009-08-19 Siemens Aktiengesellschaft Determining an architecture for executing code in a multi architecture environment
CN103049304A (en) * 2013-01-21 2013-04-17 中国人民解放军国防科学技术大学 Method for accelerating operating speed of graphics processing unit (GPU) through dead code removal

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6925639B2 (en) * 2001-02-23 2005-08-02 Microsoft Corporation Method and system for register allocation

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
EP2090983A1 (en) * 2008-02-15 2009-08-19 Siemens Aktiengesellschaft Determining an architecture for executing code in a multi architecture environment
CN103049304A (en) * 2013-01-21 2013-04-17 中国人民解放军国防科学技术大学 Method for accelerating operating speed of graphics processing unit (GPU) through dead code removal

Also Published As

Publication number Publication date
CN104881274A (en) 2015-09-02

Similar Documents

Publication Publication Date Title
CN104881274B (en) The method for identifying dead code
CN106970820A (en) Code storage method and code storage
CN103942137A (en) Browser compatibility testing method and device
KR101617696B1 (en) Method and device for mining data regular expression
CN103020207B (en) Browser label page grouping management method and device
CN102741811A (en) Improving performance of template based JavaScript widgets
CN110737466A (en) Source code coding sequence representation method based on static program analysis
CN108563629B (en) Automatic log analysis rule generation method and device
CN103383691B (en) A kind of online editing method and apparatus of webpage
CN105183476B (en) A kind of construction method and device of cross-platform program
CN104092659A (en) General protocol data analysis method
CN106775824A (en) A kind of application file packaging system and method with channel information
CN104376061A (en) Webpage text extracting method
CN102968349A (en) Method and system for file completeness verification of remote sensing image data
CN103559202B (en) A kind of webpage content extraction apparatus and method
CN108153731B (en) Uncommon word processing method calculates equipment and computer storage medium
CN106326200A (en) Method and device for modifying data content
CN102916967A (en) Method and device for protocol resolution
CN104079450A (en) Method and device for generating characteristic pattern set
CN104460595B (en) A kind of method and apparatus of extended power monitoring system function
CN107133077A (en) A kind of page end calls the method and device of locally applied function
CN103166973B (en) The method and apparatus of protocol identification
CN104537128A (en) Webpage information extracting method and device
CN106933643A (en) A kind of code compiling method, equipment and system
CN102681830B (en) A kind of method and apparatus of comparison program text

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
EXSB Decision made by sipo to initiate substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant
TR01 Transfer of patent right

Effective date of registration: 20201113

Address after: Room 10242, No. 260, Jiangshu Road, Xixing street, Binjiang District, Hangzhou City, Zhejiang Province

Patentee after: Hangzhou Jiji Intellectual Property Operation Co.,Ltd.

Address before: 201616 Shanghai city Songjiang District Guangfulin road 4855 Lane 20, No. 90

Patentee before: Phicomm (Shanghai) Co.,Ltd.

TR01 Transfer of patent right
EE01 Entry into force of recordation of patent licensing contract
EE01 Entry into force of recordation of patent licensing contract

Application publication date: 20150902

Assignee: Hangzhou xiaobuzhixue Information Technology Co.,Ltd.

Assignor: Hangzhou Jiji Intellectual Property Operation Co.,Ltd.

Contract record no.: X2021330000454

Denomination of invention: Method for identifying useless code

Granted publication date: 20180213

License type: Common License

Record date: 20211019

EE01 Entry into force of recordation of patent licensing contract
EE01 Entry into force of recordation of patent licensing contract

Application publication date: 20150902

Assignee: Hangzhou national software industry base Co.,Ltd.

Assignor: Hangzhou Jiji Intellectual Property Operation Co.,Ltd.

Contract record no.: X2021330000669

Denomination of invention: Method for identifying useless code

Granted publication date: 20180213

License type: Common License

Record date: 20211103

TR01 Transfer of patent right
TR01 Transfer of patent right

Effective date of registration: 20230925

Address after: Room 1701-1706, Feili Center, No. 72 Daxing Street, Binhai Community, Donghai Street, Fengze District, Quanzhou City, Fujian Province, 362000

Patentee after: Yuanzhiuniverse (Fujian) Technology Group Co.,Ltd.

Address before: Room 10242, No. 260, Jiangshu Road, Xixing street, Binjiang District, Hangzhou City, Zhejiang Province

Patentee before: Hangzhou Jiji Intellectual Property Operation Co.,Ltd.