CN112579470B - Compiling and linking method and system for debugging dynamic software library - Google Patents

Compiling and linking method and system for debugging dynamic software library Download PDF

Info

Publication number
CN112579470B
CN112579470B CN202011600048.8A CN202011600048A CN112579470B CN 112579470 B CN112579470 B CN 112579470B CN 202011600048 A CN202011600048 A CN 202011600048A CN 112579470 B CN112579470 B CN 112579470B
Authority
CN
China
Prior art keywords
library
linking
source code
compiling
dynamic
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
CN202011600048.8A
Other languages
Chinese (zh)
Other versions
CN112579470A (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.)
Computer Network Information Center of CAS
Original Assignee
Computer Network Information Center of CAS
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 Computer Network Information Center of CAS filed Critical Computer Network Information Center of CAS
Priority to CN202011600048.8A priority Critical patent/CN112579470B/en
Publication of CN112579470A publication Critical patent/CN112579470A/en
Application granted granted Critical
Publication of CN112579470B publication Critical patent/CN112579470B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

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/362Software debugging
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/41Compilation

Abstract

The invention belongs to the technical field of compiling and linking of software dynamic library debugging, and relates to a compiling and linking method and a compiling and linking system of software dynamic library debugging, wherein the method comprises the following steps: acquiring source code files needing to be repeatedly modified from the first group of source code files to form a second group of source code files; compiling and linking the first group of source code files to generate a first dynamic library link library; compiling and linking the second group of source code files to generate a second dynamic link library; and jointly linking the first dynamic link library and the second dynamic link library to generate the target executable program. The invention avoids the time-consuming process of generating a large-scale dynamic library, and finally improves the efficiency of the compiling and linking process of dynamic library debugging.

Description

Compiling and linking method and system for debugging dynamic software library
Technical Field
The invention relates to a compiling and linking technology for debugging a software dynamic library, in particular to a compiling and linking method and a compiling and linking system for debugging the software dynamic library.
Background
In software compiling, the dynamic library linking method is to compile partial modules of the software into library forms (such as Linux, so file and Windows, dll file, etc.) separately, and each independent dynamic library module is linked into the final executable software program. The dynamic link design mode of the software program is beneficial to sharing of a dynamic library among different software, the dynamic library provides a standard and uniform function interface and isolates the design of software running on an upper layer, and the function body can have different implementation modes as long as the function of the dynamic library keeps a function calling interface unchanged, and the running of the upper layer software cannot be changed. Referring to fig. 1, each source code file is compiled by a compiler to generate an object file, a linker links each object file into a dynamic link library, and finally an executable program calls the dynamic library in a dynamic loading mode, and the dynamic link library and the executable program can be separately and independently designed.
The dynamic library is usually generated by linking all the involved object files (e.g., o file under Linux and obj file under Windows) to finally generate a dynamic library file with a format specification. The process of linking involves the consolidation of global code and data by executable code segments, data blocks, etc. in the object file. But when linking to create large dynamic libraries, hundreds or thousands of object files need to be relied upon, and the entire process can become lengthy, even over half an hour. The biggest problem is that when the dynamic library is debugged, every time the source code of one object file is debugged and modified, the link process needs to perform layout arrangement on all the object files again, and the compiling and linking process is time-consuming. For the condition that the source code of the object file needs to be frequently modified during debugging, the whole debugging and compiling process is long and low in efficiency. Therefore, the conventional dynamic library linking method is not suitable for debugging and compiling large-scale dynamic libraries.
Disclosure of Invention
The invention aims to solve the technical problems that the large-scale program compiling and linking process is long in time consumption and the compiling and linking process efficiency is low due to the fact that a source code dependent on a dynamic library is debugged (frequently modified) in the conventional compiling method for debugging the dynamic library program.
In order to achieve the above object, in one aspect, the present invention provides a method for compiling and linking dynamic library debugging of software, including the following steps:
acquiring a source code file needing to be repeatedly modified from the first group of source code files to form a second group of source code files;
compiling and linking the first group of source code files to generate a first dynamic link library; compiling and linking the second group of source code files to generate a second dynamic link library;
and jointly linking the first dynamic link library and the second dynamic link library to generate the target executable program.
In another aspect, the present invention provides a system for compiling and linking dynamic library debugging of software, including:
the first generation unit is used for acquiring source code files needing to be repeatedly modified from the first group of source code files to form a second group of source code files;
the second generation unit is used for compiling and linking the first group of source code files to generate a first dynamic library; compiling and linking the second group of source code files to generate a second dynamic link library;
and the third generation unit is used for jointly linking the first dynamic link library and the second dynamic link library to generate the target executable program.
The method has the advantages that a small amount of files needing debugging are independently compiled, the number of files involved in general debugging is small, the compiling processes of the debugging files are faster than that of the whole file compiling process, the generation of a new dynamic library does not involve the modification of an original dynamic library, the original dynamic library does not need to be generated again, and the time-consuming process of generating a large-scale dynamic library is avoided. And finally, the efficiency of the compiling and linking process of dynamic library debugging is improved.
Drawings
FIG. 1 is a diagram illustrating a structure of a compiled link for debugging a dynamic library of software in the prior art;
fig. 2 is a schematic flowchart of a compiling and linking method for debugging a dynamic library of software according to an embodiment of the present invention;
FIG. 3 is a diagram illustrating a structure of a compiled link for debugging the dynamic library of the software shown in FIG. 2;
fig. 4 is a schematic structural diagram of a compiling and linking system for debugging a software dynamic library according to an embodiment of the present invention.
Detailed Description
The present invention will be described in further detail with reference to the accompanying drawings and specific embodiments.
Fig. 2 is a flowchart illustrating a compiling and linking method for debugging a dynamic library of software according to an embodiment of the present invention. As shown in fig. 2, the method for compiling and linking software dynamic library debugging includes the following steps:
step S101, acquiring a source code file needing to be repeatedly modified from a first group of source code files to form a second group of source code files;
specifically, as shown in fig. 3, the source code files (1, 2, … …, n) are code contents of a program, and the source code files (1, 2, … …, n) are compiled to form object files (1, 2, … …, n). One or more object files may be linked in the form of dynamically linked libraries, one or more of which are linked as executable programs.
In fig. 3, the content outside the left side frame is the first dynamic library link library process (i.e. shown in fig. 1), and the embodiment of the present invention obtains the source code files that need to be repeatedly modified from the first set of source code files (1, 2, … …, n) to form the second set of source code files (debug files). The embodiment can acquire the source code file needing to be repeatedly modified in a copying mode.
Step S102, compiling and linking a first group of source code files to generate a first dynamic link library; compiling and linking the second group of source code files to generate a second dynamic link library (new dynamic link library);
specifically, the embodiment of the present invention compiles the first set of source code files into object files (with "+" symbol after numbering in fig. 3), respectively, and then links them into the second dynamically linked library.
Step S103, the first dynamic link library and the second dynamic link library are linked together to generate a target executable program.
Preferably, the second dynamically linked library pathname is placed before the first dynamically linked library pathname in a command line parameter of the linking target executable. The second dynamically linked library has a higher priority than the first dynamically linked library.
In the embodiment of the invention, in the process of selecting the independent debugging file as a compiling unit, the compiling unit can be assisted by a make compiling tool and a cmake compiling tool, so that the make compiling tool and the cmake compiling tool output the used compiling command lines, and the dependent relation of the debugging file can be found in the command lines. For example, adding VERBOSE ═ 1 option to make command will output the compiling and linking process of each file.
An example process command line for a dynamic library linking approach is as follows:
CXX=g++
and $ CXX a. cpp- -shared-fPIC-o liba. so// the first set of source code files are compiled into a first dynamic link library liba. so
So// a second set of source code files compiled as a second dynamic link library, so
The debugging function defined by $ { CXX } c.cpp-L. -lb-la-o c1ba// second dynamic link library libb. so has precedence over the first dynamic link library
$ CXX $ c. cpp libb. so liba. so-o c2ba// the second dynamically linked library takes precedence over the first dynamically linked library
./c1ba
./c2ba
In the above command line, the first set of source code files is a.cpp (usually multiple files), and is compiled into a first dynamic link library liba.so, and the debug file b.cpp is a copy modified version of the a.cpp, and the b.cpp generally defines only the debug function, and only contains part of the content in the a.cpp. The cpp is compiled as a second dynamic link library libb.so, and the main file c.cpp originally aims to call the debug function defined in the a.cpp, because the b.cpp also defines the debug function of the same interface, in an embodiment of the invention the debug function defined by the second dynamic link library libb.so (corresponding to b.cpp) is linked into the executable file generated by the c.cpp in preference to the first dynamic link library liba.so (corresponding to a.cpp), by placing libb.so before liba.so, or lb before la, in the command line parameters. In the embodiment of the invention, after the generated liba.so is generated once, the debugging process does not need to be modified, the modification is only carried out in b.cpp, and only the libb.so needs to be generated again. After debugging is completed, the modified content in the b.cpp can be merged into the a.cpp, so that the b.cpp and the libb.so are not needed any more, and the conventional compiling and linking mode is changed.
Fig. 4 is a schematic structural diagram of a compiling and linking system for debugging a software dynamic library according to an embodiment of the present invention. As shown in fig. 4, an embodiment of the present invention provides a system for compiling and linking dynamic library debugging of software, where the system includes: a first generation unit 41, a second generation unit 42, and a third generation unit 43.
A first generating unit 41, configured to obtain a source code file that needs to be repeatedly modified from a first group of source code files, and form a second group of source code files;
a second generating unit 42, configured to compile and link the first set of source code files, and generate a first dynamic library; compiling and linking the second group of source code files to generate a second dynamic link library;
a third generating unit 43, configured to link the first dynamic link library and the second dynamic link library together to generate a target executable program.
In the embodiment of the invention, individual source code files needing to be modified in debugging are independently compiled and linked into an independent new dynamic link library, and then the independent new dynamic link library and the original dynamic link library are linked together to generate the target executable program. When the two dynamic libraries are linked together, the key point is to ensure that the new dynamic link library covers a part of corresponding function interfaces in the source dynamic library, so that the executable file calls the realization function of the debugging function in the new dynamic library instead of the corresponding debugging function in the original dynamic library. The time-consuming process of generating the large-scale dynamic library is avoided, and the efficiency of the compiling and linking process of dynamic library debugging is finally improved.
It will be obvious that many variations of the invention described herein are possible without departing from the true spirit and scope of the invention. Accordingly, all changes which would be obvious to one skilled in the art are intended to be included within the scope of this invention as defined by the appended claims. The scope of the invention is only limited by the claims.

Claims (8)

1. A compiling and linking method for debugging a software dynamic library is characterized by comprising the following steps:
acquiring a source code file needing to be repeatedly modified from the first group of source code files in a copying and modifying mode to form a second group of source code files;
compiling and linking the first group of source code files to generate a first dynamic link library; compiling and linking the second group of source code files or the modified second group of source code files to generate a second dynamic link library;
and jointly linking the first dynamic link library and the second dynamic link library to generate the target executable program.
2. The method of claim 1, wherein the second dynamically linked library pathname is placed before the first dynamically linked library pathname in a command line parameter of a linking target executable program.
3. The method of claim 1, wherein the second dynamically linked library has a higher priority than the first dynamically linked library.
4. The method of claim 1, wherein the compilation tools make use of make and cmake to output the compilation command lines used to find the dependencies of the debug files.
5. A system for compiling and linking dynamic library debugging of software, comprising:
the first generation unit is used for acquiring a source code file needing to be repeatedly modified from the first group of source code files in a copying and modifying mode to form a second group of source code files;
the second generation unit is used for compiling and linking the first group of source code files to generate a first dynamic library; compiling and linking the second group of source code files or the modified second group of source code files to generate a second dynamic link library;
and the third generation unit is used for jointly linking the first dynamic link library and the second dynamic link library to generate the target executable program.
6. The system of claim 5, wherein the second dynamically linked library pathname is placed before the first dynamically linked library pathname in a command line parameter of a linking target executable program.
7. The system of claim 5, wherein the second dynamically linked library has a higher priority than the first dynamically linked library.
8. The system of claim 5, wherein the assistance of make and cmake compilation tools causes them to output the compilation command lines used, in which the dependencies of debug files can be found.
CN202011600048.8A 2020-12-29 2020-12-29 Compiling and linking method and system for debugging dynamic software library Active CN112579470B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202011600048.8A CN112579470B (en) 2020-12-29 2020-12-29 Compiling and linking method and system for debugging dynamic software library

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202011600048.8A CN112579470B (en) 2020-12-29 2020-12-29 Compiling and linking method and system for debugging dynamic software library

Publications (2)

Publication Number Publication Date
CN112579470A CN112579470A (en) 2021-03-30
CN112579470B true CN112579470B (en) 2022-08-30

Family

ID=75144135

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202011600048.8A Active CN112579470B (en) 2020-12-29 2020-12-29 Compiling and linking method and system for debugging dynamic software library

Country Status (1)

Country Link
CN (1) CN112579470B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116204429B (en) * 2023-02-21 2023-12-08 深圳市道旅旅游科技股份有限公司 Code organization and debugging method, system and storage medium thereof

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105144088A (en) * 2012-12-13 2015-12-09 微软技术许可有限责任公司 Association of metadata with source code and applications and services premised thereon
CN108037927A (en) * 2017-12-29 2018-05-15 有米科技股份有限公司 Kit packaging method, system, readable storage medium storing program for executing and computer equipment
CN110908666A (en) * 2019-10-31 2020-03-24 北京浪潮数据技术有限公司 Source code sharing management method, device, equipment and computer storage medium

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101826014B (en) * 2010-04-20 2013-05-08 北京邮电大学 Dividing method of source code in software engineering
CN104063258B (en) * 2013-03-21 2017-05-03 国际商业机器公司 Code dynamic switching method and system for debugging process
CN111061638B (en) * 2019-12-16 2023-06-30 上海钧正网络科技有限公司 iOS system debugging method, device and server
CN111723002A (en) * 2020-05-18 2020-09-29 五八有限公司 Code debugging method and device, electronic equipment and storage medium

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105144088A (en) * 2012-12-13 2015-12-09 微软技术许可有限责任公司 Association of metadata with source code and applications and services premised thereon
CN108037927A (en) * 2017-12-29 2018-05-15 有米科技股份有限公司 Kit packaging method, system, readable storage medium storing program for executing and computer equipment
CN110908666A (en) * 2019-10-31 2020-03-24 北京浪潮数据技术有限公司 Source code sharing management method, device, equipment and computer storage medium

Also Published As

Publication number Publication date
CN112579470A (en) 2021-03-30

Similar Documents

Publication Publication Date Title
US7971201B2 (en) Multiple operating device version software generating system and multiple operating device version software generation support program and method
US20070089090A1 (en) Method and system for protecting source code
US20110126179A1 (en) Method and System for Dynamic Patching Software Using Source Code
US20040210883A1 (en) Method and apparatus for building executable computer programs using compiled program libraries
CN112579470B (en) Compiling and linking method and system for debugging dynamic software library
CN113900704A (en) Method and device for issuing application program installation package, readable medium and electronic equipment
WO2009127476A2 (en) A method and a system for transforming an object model
US20010042138A1 (en) Method and system for parallel and procedural computing
CN114115859A (en) Compiling method, device and system of iOS program based on local static library
CN109144849A (en) A kind of embedded software adjusting, measuring method
CN103488519A (en) Implement method of interactive scripting language interpreter
CN111880803A (en) Software construction method and device applied to multiple platforms
Allan et al. Ccaffeine framework: composing and debugging applications iteratively and running them statically
WO2008015110A2 (en) Methods, apparatus and computer programs for modelling computer programs
CN111880796B (en) Multi-core model architecture implementation method and system
CN102902532B (en) Tool chain conversion and extension method in integrated development environment
US11714657B2 (en) Self optimizing application
WO2007144891A1 (en) A method for the distribution of software processes to a plurality of computers
JP2882876B2 (en) Program test method
CN114327396A (en) Method for developing Andriod system application by deviating from source code compiling environment
CN117270858A (en) Front-end solution method and device for parallel compiling of hardware description language
CN114035920A (en) Method and device for symmetric loading and running of DSP (digital Signal processor) program
CN117251206A (en) Cross-platform software development method of cellular communication module
CN101101561A (en) Construction and execution method of executable component dynamic link library
JPH1083328A (en) Pseudo input/output realizing system for single body test

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