CN114327491A - Source code instrumentation method, apparatus, computer device and storage medium - Google Patents

Source code instrumentation method, apparatus, computer device and storage medium Download PDF

Info

Publication number
CN114327491A
CN114327491A CN202210215163.6A CN202210215163A CN114327491A CN 114327491 A CN114327491 A CN 114327491A CN 202210215163 A CN202210215163 A CN 202210215163A CN 114327491 A CN114327491 A CN 114327491A
Authority
CN
China
Prior art keywords
source code
instrumentation
compiling
function
static library
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.)
Granted
Application number
CN202210215163.6A
Other languages
Chinese (zh)
Other versions
CN114327491B (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.)
Shenzhen Mainway Technology Co ltd
Seczone Technology Co Ltd
Original Assignee
Shenzhen Mainway Technology Co ltd
Seczone 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 Shenzhen Mainway Technology Co ltd, Seczone Technology Co Ltd filed Critical Shenzhen Mainway Technology Co ltd
Priority to CN202210215163.6A priority Critical patent/CN114327491B/en
Publication of CN114327491A publication Critical patent/CN114327491A/en
Application granted granted Critical
Publication of CN114327491B publication Critical patent/CN114327491B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Landscapes

  • Stored Programmes (AREA)

Abstract

The application relates to a source code instrumentation method, a source code instrumentation device, a computer device and a storage medium. The method comprises the following steps: compiling the user code according to the compiling command when receiving the user code to be compiled; when the instrumentation compiling parameters in the compiling command are read in the compiling process, performing instrumentation processing on the instrumentation source code to be instrumented to generate an updated source code after the instrumentation processing; the source code to be instrumented is a standard library source code on which the user code depends, and the updated source code is used for generating an executable program with a data flow tracking function. Based on the source code instrumentation method, when instrumentation compiling functions in the compiling commands are read in the compiling commands in the process of compiling the user codes by using the compiling commands, instrumentation processing is carried out on standard library source codes depended on by the user codes, and therefore updated source codes after the instrumentation processing are generated, intrusion modification of the user codes is not needed, the number of versions of the user codes is reduced, and version maintenance operations of the user codes are simplified.

Description

Source code instrumentation method, apparatus, computer device and storage medium
Technical Field
The present application relates to the field of computer technologies, and in particular, to a method and an apparatus for source code instrumentation, a computer device, and a storage medium.
Background
A programming language (programming language) can be understood simply as a language that can be recognized by both a computer and a human. A computer language allows programmers to accurately define the data that the computer needs to use and to accurately define the actions that should be taken under different circumstances.
In the prior art, a method for instrumentation of a programming language mainly directly modifies user-level source codes, and specifically, data stream tracking and analysis of specific functions are realized by modifying the user-level source codes and increasing the source codes. However, the method is invasive to the user source code, and the user code needs to be modified, which directly causes the user code to need to maintain two versions, one production version and one instrumentation version, thereby deriving the problem of maintaining various versions.
Disclosure of Invention
In order to solve the technical problem, the application provides a source code instrumentation method, a source code instrumentation device, a computer device and a storage medium.
In a first aspect, the present application provides a source code instrumentation method, including:
compiling the user code according to the compiling command when receiving the user code to be compiled;
when the instrumentation compiling parameters in the compiling command are read in the compiling process, performing instrumentation processing on the instrumentation source code to be instrumented to generate an updated source code after the instrumentation processing; the source code to be instrumented is a standard library source code on which the user code depends, and the updated source code is used for generating an executable program with a data flow tracking function.
In a second aspect, the present application provides a source code instrumentation apparatus comprising:
the determining module is used for compiling the user code according to the compiling command when the user code to be compiled is received;
the instrumentation module is used for performing instrumentation processing on instrumentation source codes to generate updated source codes after the instrumentation processing when instrumentation compiling parameters in the compiling command are read in the compiling process; the source code to be instrumented is a standard library source code on which the user code depends, and the updated source code is used for generating an executable program with a data flow tracking function.
In a third aspect, the present application provides a computer device comprising a memory, a processor, and a computer program stored on the memory and executable on the processor, the processor implementing the following steps when executing the computer program:
compiling the user code according to the compiling command when receiving the user code to be compiled;
when the instrumentation compiling parameters in the compiling command are read in the compiling process, performing instrumentation processing on the instrumentation source code to be instrumented to generate an updated source code after the instrumentation processing; the source code to be instrumented is a standard library source code on which the user code depends, and the updated source code is used for generating an executable program with a data flow tracking function.
In a fourth aspect, the present application provides a computer readable storage medium having stored thereon a computer program which, when executed by a processor, performs the steps of:
compiling the user code according to the compiling command when receiving the user code to be compiled;
when the instrumentation compiling parameters in the compiling command are read in the compiling process, performing instrumentation processing on the instrumentation source code to be instrumented to generate an updated source code after the instrumentation processing; the source code to be instrumented is a standard library source code on which the user code depends, and the updated source code is used for generating an executable program with a data flow tracking function.
The source code instrumentation method, apparatus, computer device and storage medium described above, the method comprising: compiling the user code according to the compiling command when receiving the user code to be compiled; when the instrumentation compiling parameters in the compiling command are read in the compiling process, performing instrumentation processing on the instrumentation source code to be instrumented to generate an updated source code after the instrumentation processing; the source code to be instrumented is a standard library source code on which the user code depends, and the updated source code is used for generating an executable program with a data flow tracking function. Based on the source code instrumentation method, when instrumentation compiling functions in compiling commands are read in the process of compiling user codes by using the compiling commands, instrumentation processing is required, and then instrumentation processing is carried out on standard library source codes depended on by the user codes, so that updated source codes after the instrumentation processing are generated, intrusion modification on the user codes is not required, the number of versions of the user codes is reduced, and version maintenance operations of the user codes are simplified.
Drawings
The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the invention and together with the description, serve to explain the principles of the invention.
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, and it is obvious for those skilled in the art that other drawings can be obtained according to the drawings without inventive exercise.
FIG. 1 is a flow diagram illustrating a method for source code instrumentation in one embodiment;
FIG. 2 is a block diagram of a program of a source code instrumentation device in one embodiment;
FIG. 3 is a block diagram of a computer device in one embodiment.
Detailed Description
In order to make the objects, technical solutions and advantages of the embodiments of the present application clearer, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are some embodiments of the present application, but not all embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
In an embodiment, fig. 1 is a flow chart illustrating a source code instrumentation method in an embodiment, and referring to fig. 1, a source code instrumentation method is provided. The embodiment is mainly exemplified by applying the method to a server, and the source code instrumentation method specifically includes the following steps:
and step S110, compiling the user code according to the compiling command when the user code to be compiled is received.
Specifically, the user code refers to a code generated by a user according to personal logic editing, the compiling command is used for compiling and converting the user code into a machine language which can be recognized by a computer, the standard library source code refers to a code which is edited in advance and can be used and modified, the standard library source code generally comprises a code which is used frequently or is more basic by a programmer, repeated manual writing is not needed for the code with high use frequency, and the standard library source code can be directly used for modification and adjustment, so that the code generation efficiency is accelerated. I.e. the compilation command is a code that is modified on the basis of standard library source code.
The user code and the standard library source code are both codes generated based on a programming language, the compiling command is also compiled by the programming language, the programming language can be specifically Java, C + +, PHP, Python, VB, GO, or the like, and the GO language is selected as the programming language in this embodiment.
And step S120, when the instrumentation compiling parameters in the compiling command are read in the compiling process, performing instrumentation processing on the instrumentation source code to generate an updated source code after the instrumentation processing.
The source code to be instrumented is a standard library source code on which the user code depends, and the updated source code is used for generating an executable program with a data flow tracking function.
Specifically, pile-inserting compiling parameters are read in the compiling command to indicate that pile-inserting compiling operation is required in the compiling process; and for the compiling command of which the instrumentation compiling parameter is not read, the compiling process does not need instrumentation compiling operation, and the compiling operation is carried out according to normal compiling operation. For a compiling command needing instrumentation, instrumentation is carried out on standard library source codes which are depended on by user codes in the compiling process, the user codes are not directly modified in an invasive way, but the corresponding standard library source codes are modified, so that production version codes and instrumentation version codes corresponding to the user codes are avoided, namely, the user codes are maintained only by maintaining the production version codes, the version number of the user codes is reduced, the version maintenance operation of the user codes is simplified, the instrumentation is carried out only on the standard library source codes, and the influence on the modification of other compiling tool source codes is avoided.
And after the standard library source code depended on by the user code is subjected to instrumentation, the generated updated source code is used for forming an executable program with a data flow tracking function, so that the data flow tracking and analysis of the executable program can be realized conveniently in the follow-up process.
In an embodiment, the performing instrumentation processing on the source code to be instrumented to generate an updated source code after the instrumentation processing includes: copying a storage directory corresponding to the source code to be inserted to a designated temporary directory, and modifying an environment variable value of the storage directory from a first value to a second value; and performing instrumentation processing on the source codes to be instrumented in the specified temporary directory to generate updated source codes after the instrumentation processing.
The second value is used for indicating the value of the environment variable of the designated temporary directory, the first value is the value of the original environment variable of the storage directory, and the value of the environment variable is used for indicating the position of the directory, namely, the corresponding directory can be found through the value of the environment variable.
Specifically, the storage directory is used for indicating an installation path of a source code to be instrumented, the storage directory is a GOROOT directory, the storage directory is copied to the designated temporary directory, and the instrumentation is performed in the designated temporary directory, so that the storage directory independent of the designated temporary directory is not affected. Because each directory corresponds to one environment variable value, after the storage directory is copied to the designated temporary directory, the environment variable value of the storage directory needs to be modified from a first value to a corresponding environment variable value of the designated temporary directory, namely, the first value is modified to a second value, so that the situation that different directories correspond to one environment variable value is avoided, and the situation that the positions of the directories cannot be accurately found when different directories correspond to the same environment variable value is prevented.
In an embodiment, the performing instrumentation processing on the source code to be instrumented in the specified temporary directory to generate an updated source code after the instrumentation processing includes: acquiring parameter values of static library variables; determining a corresponding pile function static library according to the parameter value of the static library variable; acquiring a target pile function corresponding to a pile function to be inserted in the source code to be inserted from the pile function static library based on a mapping relation table between the pile function to be inserted and a specified pile function; and adding the target stub function to the starting position and/or the ending position of the corresponding to-be-plugged function in the to-be-plugged source code to generate the updated source code.
Specifically, the parameter value of the static library variable is used for indicating an access port of a pile function static library, the pile function static library is a plug library, the pile function static library comprises a plurality of guidable pile functions, when a plurality of pile function static libraries exist, each pile function static library corresponds to one access port, namely, the parameter values corresponding to the corresponding static library variables of different pile function static libraries are different, and the corresponding pile function static library can be called according to the parameter value of the static library variable. When the pile function logic is changed, program codes do not need to be compiled again, and only the corresponding pile function static library needs to be replaced, so that the pile inserting efficiency is improved.
The to-be-inserted function is used for indicating a function to be inserted in the to-be-inserted source code, the specified pile function is used for indicating a function to be inserted in the to-be-inserted source code, the mapping relation table between the to-be-inserted function and the specified pile function comprises a plurality of function pairs, each function pair comprises a to-be-inserted function, a specified pile function and the mapping relation between the two pile functions, namely, the corresponding to-be-inserted function can only be inserted by using the specified pile function with the mapping relation, the pile inserting processing cannot be realized by the two pile functions without the mapping relation, the mapping relation between the to-be-inserted function and the specified pile function in the mapping relation table can be specifically one-to-one, one-to-many, many-to-one, or many-to-many, and the like, namely, one to-be-inserted function can correspond to one specified pile function or can correspond to a plurality of specified pile functions, one specified pile function can correspond to a plurality of to-be inserted functions, or, the plurality of designated stub functions correspond to the plurality of to-be-plugged stub functions.
Compatibility setting is carried out on the mapping relation table, so that the mapping relation in the mapping relation table only can be increased, and the condition of modification or deletion cannot occur, namely, the matching logic between the pile functions does not change, therefore, when later maintenance is carried out, only the existing mapping relation and the newly-added mapping relation in the mapping relation table need to be maintained, and the maintenance operation amount is simplified. Because the mapping relation between the pile functions is fixed, the pile inserting processing is automatically carried out on the source codes to be subjected to pile inserting based on the mapping relation table, manual matching is not needed, and the pile inserting efficiency is improved.
And when only one specified pile function which has a mapping relation with the pile function to be inserted exists in the pile function static library, taking the specified pile function as the target pile function, and adding the target pile function to the starting position and/or the ending position of the corresponding pile function to be inserted in the pile source code to be inserted, so that the follow-up data stream tracking of the pile function to be inserted is facilitated.
When a plurality of specified pile functions which have mapping relations with the to-be-plugged pile functions exist in the pile function static library, randomly selecting one of the specified pile functions as a target pile function, and adding the target pile function to the starting position and/or the ending position of the corresponding to-be-plugged pile function in the to-be-plugged pile source code; or two of the designated stub functions are randomly selected as target stub functions, one of the target stub functions is added to the beginning of the corresponding stub function to be inserted in the source code to be inserted, and the other target stub function is added to the end of the corresponding stub function to be inserted in the source code to be inserted.
In conclusion, the stub function is automatically added into the source code to be inserted according to the mapping relation table, manual writing is not needed, the pile inserting efficiency is improved, and meanwhile the situation that the manual writing is prone to cause the reference error of the stub function is avoided.
In one embodiment, the obtaining parameter values of the static library variables includes: reading a pile function static library parameter value in the compiling command; and assigning the pile function static library parameter values in the compiling command to the static library variables to serve as the parameter values of the static library variables.
Specifically, a static library variable is added to a source code to be instrumented, so that a corresponding instrumentation function static library is conveniently accessed according to a parameter value of the static library variable, at this time, a parameter value corresponding to the static library variable just after the static library variable is a null pointer value, that is, no instrumentation function static library is indicated, initialization processing needs to be performed on the static library variable, that is, a parameter value of the instrumentation function static library in a compilation command is assigned to the static library variable, and because the compilation command needs to be instrumented, the compilation command contains a corresponding access port of the static library of the instrumentation function required by the instrumentation processing, that is, the parameter value of the instrumentation function static library, so that in a subsequent instrumentation processing process, the required instrumentation function is obtained from the instrumentation function static library according to the parameter value of the static library variable.
Before obtaining the parameter values of the static library variables, a stub function needs to be written, and the stub function static library is generated by using the GO command and the written stub function.
In one embodiment, after the reading of the stub function static library parameter values in the compilation command, the method comprises: adding an automatic execution function in the source code to be inserted; assigning the static library parameter value of the stub function in the compiling command to the static library variable as the parameter value of the static library variable, wherein the assigning comprises: and when the automatic execution function is read, assigning the static library parameter value of the pile function in the compiling command to the static library variable as the parameter value of the static library variable.
Specifically, the automatic execution function is an init function, and the automatic execution function is added into the source code to be plugged, so that the static library variable can be automatically initialized when the automatic execution function is executed, manual operation initialization is not needed, and the plugging processing process is further optimized.
In one embodiment, after the generating the updated source code, the method further comprises: and modifying the environment variable value of the updated source code corresponding to the storage directory from the second value to the first value.
Specifically, after the update source code is generated, the environment variable value of the corresponding storage directory is modified from the second value to the first value, that is, the storage directory in the designated temporary directory is released to replace the storage directory which is independent of the designated temporary directory and has not undergone instrumentation, so that the corresponding execution command can be generated by using the update source code which has undergone instrumentation.
In an embodiment, before copying the storage directory corresponding to the source code to be instrumented to the specified temporary directory, the method further includes: randomly generating the designated temporary directory; adding a file lock to the specified temporary directory; and the designated temporary directory with the file lock is used for performing instrumentation processing on different source codes to be instrumented.
Specifically, the file locking mechanism is utilized to ensure that the specified temporary directory is only generated once, namely, the specified temporary directory is locked, each source code to be inserted, which needs to be subjected to the insertion processing, is sequentially copied into the specified temporary directory for the insertion processing, so that a temporary directory is prevented from being generated when each pair of source codes to be inserted is subjected to the insertion processing, and the memory space is saved.
In a specific embodiment, before the user code is compiled, if the data stream of the user code needs to be tracked and analyzed, instrumentation compilation parameters and instrumentation function static library parameters are added to the compilation command, so that in the process of compiling the user code by using the compilation command, the instrumentation compilation parameters are read in the compilation command, a standard library source code on which the user code depends is used as a source code to be instrumented, and instrumentation is performed on the standard library source code on which the user code depends, that is, the instrumentation is performed on the source code to be instrumented.
In the pile inserting process, a storage directory corresponding to a source code to be inserted is copied to an appointed temporary directory, an environment variable value of the storage directory is modified to be an environment variable value of the appointed temporary directory, an appointed temporary directory is generated through a file lock mechanism before the storage directory is used for providing an environment for pile inserting processing of different source codes to be inserted, and the original storage directory is prevented from being influenced by the pile inserting processing before copying. In the appointed temporary directory, adding static library variables and automatic execution functions to the source code to be inserted, so as to facilitate the automatic access of the corresponding stub function static library through the static library variables when the automatic execution function is executed in the subsequent compiling process, according to the mapping relation table between the function to be inserted and the appointed pile function, the target pile function corresponding to the function to be inserted is obtained from the pile function static library, the obtained target pile function is added to the initial position and/or the end position of the corresponding function to be inserted, so that the pile inserting operation is completed, after the instrumentation is finished, the environment variable of the storage directory is modified into the environment variable before the instrumentation so as to generate an updated source code, the updated source code after the instrumentation has a data flow tracking function, the tracking and analysis of the data flow can be automatically completed in the subsequent compiling process of the user code, and then a corresponding executable program is generated.
The source code instrumentation method utilizes the technical characteristics of the exclusive rights of the source code instrumentation method to carry out derivation, and achieves the beneficial effect of solving the technical problems in the background technology.
Fig. 1 is a flowchart illustrating a source code instrumentation method according to an embodiment. It should be understood that, although the steps in the flowchart of fig. 1 are shown in order as indicated by the arrows, the steps are not necessarily performed in order as indicated by the arrows. The steps are not performed in the exact order shown and described, and may be performed in other orders, unless explicitly stated otherwise. Moreover, at least a portion of the steps in fig. 1 may include multiple sub-steps or multiple stages that are not necessarily performed at the same time, but may be performed at different times, and the order of performance of the sub-steps or stages is not necessarily sequential, but may be performed in turn or alternately with other steps or at least a portion of the sub-steps or stages of other steps.
In one embodiment, as shown in fig. 2, there is provided a source code instrumentation comprising:
the determining module 210 is configured to compile a user code according to a compiling command when the user code to be compiled is received;
the instrumentation module 220 is configured to perform instrumentation processing on instrumentation source codes to be instrumented when instrumentation compiling parameters in the compiling command are read in the compiling process, and generate updated source codes after the instrumentation processing; the source code to be instrumented is a standard library source code on which the user code depends, and the updated source code is used for generating an executable program with a data flow tracking function.
In one embodiment, the stake module 220 is further configured to:
copying a storage directory corresponding to the source code to be inserted to a designated temporary directory, and modifying an environment variable value of the storage directory from a first value to a second value; wherein the second value is indicative of an environment variable value of the specified temporary directory;
and performing instrumentation processing on the source codes to be instrumented in the specified temporary directory to generate updated source codes after the instrumentation processing.
In one embodiment, the stake module 220 is further configured to:
acquiring parameter values of static library variables;
determining a corresponding pile function static library according to the parameter value of the static library variable;
acquiring a target pile function corresponding to a pile function to be inserted in the source code to be inserted from the pile function static library based on a mapping relation table between the pile function to be inserted and a specified pile function;
and adding the target stub function to the starting position and/or the ending position of the corresponding to-be-plugged function in the to-be-plugged source code to generate the updated source code.
In one embodiment, the stake module 220 is further configured to:
reading a pile function static library parameter value in the compiling command;
and assigning the pile function static library parameter values in the compiling command to the static library variables to serve as the parameter values of the static library variables.
In one embodiment, the stake module 220 is further configured to:
adding an automatic execution function in the source code to be inserted;
assigning the static library parameter value of the stub function in the compiling command to the static library variable as the parameter value of the static library variable, wherein the assigning comprises:
and when the automatic execution function is read, assigning the static library parameter value of the pile function in the compiling command to the static library variable as the parameter value of the static library variable.
In one embodiment, the stake module 220 is further configured to:
and modifying the environment variable value of the updated source code corresponding to the storage directory from the second value to the first value.
In one embodiment, the stake module 220 is further configured to:
randomly generating the designated temporary directory;
adding a file lock to the specified temporary directory; and the designated temporary directory with the file lock is used for performing instrumentation processing on different source codes to be instrumented.
FIG. 3 is a diagram illustrating an internal structure of a computer device in one embodiment. The computer device may specifically be a server. As shown in fig. 3, the computer apparatus includes a processor, a memory, a network interface, an input device, and a display screen connected through a system bus. Wherein the memory includes a non-volatile storage medium and an internal memory. The non-volatile storage medium of the computer device stores an operating system and may also store a computer program that, when executed by the processor, causes the processor to implement the source code instrumentation method. The internal memory may also have stored therein a computer program that, when executed by the processor, causes the processor to perform a source code instrumentation method. Those skilled in the art will appreciate that the architecture shown in fig. 3 is merely a block diagram of some of the structures associated with the disclosed aspects and is not intended to limit the computing devices to which the disclosed aspects apply, as particular computing devices may include more or less components than those shown, or may combine certain components, or have a different arrangement of components.
In one embodiment, the source code instrumentation provided herein may be implemented in the form of a computer program that is executable on a computer device such as that shown in fig. 3. The memory of the computer device may store various program modules constituting the source code instrumentation, such as the determination module 210 and the instrumentation module 220 shown in fig. 2. The computer program constituted by the respective program modules causes the processor to execute the steps in the source code instrumentation method of the respective embodiments of the present application described in the present specification.
The computer device shown in fig. 3 may compile the user code according to the compilation command when receiving the user code to be compiled, which may be performed by the determination module 210 in the source code instrumentation shown in fig. 2. The computer equipment can execute instrumentation processing on the instrumentation source code to be instrumented when instrumentation compiling parameters in the compiling command are read in the compiling process through the instrumentation module 220, and generates an updated source code after the instrumentation processing; the source code to be instrumented is a standard library source code on which the user code depends, and the updated source code is used for generating an executable program with a data flow tracking function.
In one embodiment, a computer device is provided, comprising a memory, a processor, and a computer program stored on the memory and executable on the processor, the processor implementing the method of any of the above embodiments when executing the computer program.
In an embodiment, a computer-readable storage medium is provided, on which a computer program is stored, which computer program, when being executed by a processor, carries out the method of any of the above embodiments.
It will be understood by those skilled in the art that all or part of the processes of the methods of the embodiments described above can be implemented by instructing the relevant hardware through a computer program, which can be stored in a non-volatile computer-readable storage medium, and when executed, can include the processes of the embodiments of the methods described above. Any reference to memory, storage, database, or other medium used in the embodiments provided herein may include non-volatile and/or volatile memory, among others. Non-volatile memory can include read-only memory (ROM), Programmable ROM (PROM), Electrically Programmable ROM (EPROM), Electrically Erasable Programmable ROM (EEPROM), or flash memory. Volatile memory can include Random Access Memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in a variety of forms such as Static RAM (SRAM), Dynamic RAM (DRAM), Synchronous DRAM (SDRAM), double-rate SDRAM (DDRSDRAM), Enhanced SDRAM (ESDRAM), synchronous Link (Synchlink) DRAM (SLDRAM), Rambus Direct RAM (RDRAM), direct bus dynamic RAM (DRDRAM), and bus dynamic RAM (RDRAM).
It is noted that, in this document, relational terms such as "first" and "second," and the like, may be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other identical elements in a process, method, article, or apparatus that comprises the element.
The foregoing are merely exemplary embodiments of the present invention, which enable those skilled in the art to understand or practice the present invention. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the generic principles defined herein may be applied to other embodiments without departing from the spirit or scope of the invention. Thus, the present invention is not intended to be limited to the embodiments shown herein but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.

Claims (10)

1. A method of source code instrumentation, the method comprising:
compiling the user code according to the compiling command when receiving the user code to be compiled;
when the instrumentation compiling parameters in the compiling command are read in the compiling process, performing instrumentation processing on the instrumentation source code to be instrumented to generate an updated source code after the instrumentation processing; the source code to be instrumented is a standard library source code on which the user code depends, and the updated source code is used for generating an executable program with a data flow tracking function.
2. The method according to claim 1, wherein the performing instrumentation on the source code to be instrumented to generate the updated source code after the instrumentation comprises:
copying a storage directory corresponding to the source code to be inserted to a designated temporary directory, and modifying an environment variable value of the storage directory from a first value to a second value; wherein the second value is indicative of an environment variable value of the specified temporary directory;
and performing instrumentation processing on the source codes to be instrumented in the specified temporary directory to generate updated source codes after the instrumentation processing.
3. The method according to claim 2, wherein the performing instrumentation on the source code to be instrumented in the specified temporary directory to generate an updated source code after the instrumentation includes:
acquiring parameter values of static library variables;
determining a corresponding pile function static library according to the parameter value of the static library variable;
acquiring a target pile function corresponding to a pile function to be inserted in the source code to be inserted from the pile function static library based on a mapping relation table between the pile function to be inserted and a specified pile function;
and adding the target stub function to the starting position and/or the ending position of the corresponding to-be-plugged function in the to-be-plugged source code to generate the updated source code.
4. The method of claim 3, wherein obtaining parameter values for static library variables comprises:
reading a pile function static library parameter value in the compiling command;
and assigning the pile function static library parameter values in the compiling command to the static library variables to serve as the parameter values of the static library variables.
5. The method of claim 4, wherein after reading stub function static library parameter values in the compilation command, the method comprises:
adding an automatic execution function in the source code to be inserted;
assigning the static library parameter value of the stub function in the compiling command to the static library variable as the parameter value of the static library variable, wherein the assigning comprises:
and when the automatic execution function is read, assigning the static library parameter value of the pile function in the compiling command to the static library variable as the parameter value of the static library variable.
6. The method of claim 3, wherein after the generating the updated source code, the method further comprises:
and modifying the environment variable value of the updated source code corresponding to the storage directory from the second value to the first value.
7. The method of claim 2, wherein before copying the storage directory corresponding to the source code to be instrumented to a specified temporary directory, the method further comprises:
randomly generating the designated temporary directory;
adding a file lock to the specified temporary directory; and the designated temporary directory with the file lock is used for performing instrumentation processing on different source codes to be instrumented.
8. A source code stake inserting apparatus, the apparatus comprising:
the determining module is used for compiling the user code according to the compiling command when the user code to be compiled is received;
the instrumentation module is used for performing instrumentation processing on instrumentation source codes to generate updated source codes after the instrumentation processing when instrumentation compiling parameters in the compiling command are read in the compiling process; the source code to be instrumented is a standard library source code on which the user code depends, and the updated source code is used for generating an executable program with a data flow tracking function.
9. A computer device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, characterized in that the steps of the method of any of claims 1 to 7 are implemented when the computer program is executed by the processor.
10. A computer-readable storage medium, on which a computer program is stored, which, when being executed by a processor, carries out the steps of the method according to any one of claims 1 to 7.
CN202210215163.6A 2022-03-07 2022-03-07 Source code instrumentation method, apparatus, computer device and storage medium Active CN114327491B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210215163.6A CN114327491B (en) 2022-03-07 2022-03-07 Source code instrumentation method, apparatus, computer device and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210215163.6A CN114327491B (en) 2022-03-07 2022-03-07 Source code instrumentation method, apparatus, computer device and storage medium

Publications (2)

Publication Number Publication Date
CN114327491A true CN114327491A (en) 2022-04-12
CN114327491B CN114327491B (en) 2022-06-21

Family

ID=81031604

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210215163.6A Active CN114327491B (en) 2022-03-07 2022-03-07 Source code instrumentation method, apparatus, computer device and storage medium

Country Status (1)

Country Link
CN (1) CN114327491B (en)

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114780958A (en) * 2022-04-14 2022-07-22 深圳开源互联网安全技术有限公司 Automatic embedded point pile inserting method and device and computer readable storage medium
CN115221051A (en) * 2022-07-12 2022-10-21 北京大学 Program instrumentation method and device for verifying data API execution process
CN116483734A (en) * 2023-06-16 2023-07-25 荣耀终端有限公司 Pile inserting method and system based on compiler and related electronic equipment
CN116775040A (en) * 2023-08-16 2023-09-19 北京安普诺信息技术有限公司 Pile inserting method for realizing code vaccine and application testing method based on code vaccine

Citations (12)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102243609A (en) * 2011-06-15 2011-11-16 惠州运通信息技术有限公司 Embedded software-based test analysis method and system
CN103970659A (en) * 2014-05-16 2014-08-06 刘玉光 Android application software automation testing method based on pile pitching technology
CN104598274A (en) * 2015-01-13 2015-05-06 北京京东尚科信息技术有限公司 Automatic instrumentation, compiling and installing method and system
CN105183642A (en) * 2015-08-18 2015-12-23 中国人民解放军信息工程大学 Instrumentation based program behavior acquisition and structural analysis method
KR20160021585A (en) * 2014-08-18 2016-02-26 슈어소프트테크주식회사 Method for measuring code coverage and computer readable recording medium having program the same
CN108021495A (en) * 2016-11-03 2018-05-11 北京计算机技术及应用研究所 Code debugging method based on playback
US20190354467A1 (en) * 2018-05-16 2019-11-21 Servicenow, Inc. Dependency Mapping Between Program Code and Tests to Rapidly Identify Error Sources
CN110941534A (en) * 2019-11-19 2020-03-31 深圳开源互联网安全技术有限公司 Method and system for detecting third-party code call of web application
CN111046396A (en) * 2020-03-13 2020-04-21 深圳开源互联网安全技术有限公司 Web application test data flow tracking method and system
CN111124937A (en) * 2020-03-31 2020-05-08 深圳开源互联网安全技术有限公司 Method and system for assisting in improving test case generation efficiency based on instrumentation function
CN111831316A (en) * 2020-07-21 2020-10-27 北京字节跳动网络技术有限公司 Software development kit updating method and device
CN113885885A (en) * 2021-10-21 2022-01-04 广州链安科技有限公司 Android installation package batch automatic unshelling platform based on dynamic execution of multi-point pile insertion

Patent Citations (12)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102243609A (en) * 2011-06-15 2011-11-16 惠州运通信息技术有限公司 Embedded software-based test analysis method and system
CN103970659A (en) * 2014-05-16 2014-08-06 刘玉光 Android application software automation testing method based on pile pitching technology
KR20160021585A (en) * 2014-08-18 2016-02-26 슈어소프트테크주식회사 Method for measuring code coverage and computer readable recording medium having program the same
CN104598274A (en) * 2015-01-13 2015-05-06 北京京东尚科信息技术有限公司 Automatic instrumentation, compiling and installing method and system
CN105183642A (en) * 2015-08-18 2015-12-23 中国人民解放军信息工程大学 Instrumentation based program behavior acquisition and structural analysis method
CN108021495A (en) * 2016-11-03 2018-05-11 北京计算机技术及应用研究所 Code debugging method based on playback
US20190354467A1 (en) * 2018-05-16 2019-11-21 Servicenow, Inc. Dependency Mapping Between Program Code and Tests to Rapidly Identify Error Sources
CN110941534A (en) * 2019-11-19 2020-03-31 深圳开源互联网安全技术有限公司 Method and system for detecting third-party code call of web application
CN111046396A (en) * 2020-03-13 2020-04-21 深圳开源互联网安全技术有限公司 Web application test data flow tracking method and system
CN111124937A (en) * 2020-03-31 2020-05-08 深圳开源互联网安全技术有限公司 Method and system for assisting in improving test case generation efficiency based on instrumentation function
CN111831316A (en) * 2020-07-21 2020-10-27 北京字节跳动网络技术有限公司 Software development kit updating method and device
CN113885885A (en) * 2021-10-21 2022-01-04 广州链安科技有限公司 Android installation package batch automatic unshelling platform based on dynamic execution of multi-point pile insertion

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
施冬梅: "基本路径覆盖测试探针插桩技术研究", 《计算机工程与设计》, no. 13, 16 July 2010 (2010-07-16), pages 93 - 96 *

Cited By (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114780958A (en) * 2022-04-14 2022-07-22 深圳开源互联网安全技术有限公司 Automatic embedded point pile inserting method and device and computer readable storage medium
CN115221051A (en) * 2022-07-12 2022-10-21 北京大学 Program instrumentation method and device for verifying data API execution process
CN116483734A (en) * 2023-06-16 2023-07-25 荣耀终端有限公司 Pile inserting method and system based on compiler and related electronic equipment
CN116483734B (en) * 2023-06-16 2024-03-19 荣耀终端有限公司 Pile inserting method and system based on compiler and related electronic equipment
CN116775040A (en) * 2023-08-16 2023-09-19 北京安普诺信息技术有限公司 Pile inserting method for realizing code vaccine and application testing method based on code vaccine
CN116775040B (en) * 2023-08-16 2023-11-17 北京安普诺信息技术有限公司 Pile inserting method for realizing code vaccine and application testing method based on code vaccine

Also Published As

Publication number Publication date
CN114327491B (en) 2022-06-21

Similar Documents

Publication Publication Date Title
CN114327491B (en) Source code instrumentation method, apparatus, computer device and storage medium
US10089080B2 (en) Automatically optimizing analytics database server
US8296535B2 (en) Generating incremental program updates
US8055096B2 (en) Method and system for incremental patching of binary files
US9619212B2 (en) Providing code, code generator and software development environment
JP4346316B2 (en) A method for aspect-oriented programming with multiple semantic levels
US8464236B2 (en) Data consistency in data processing systems
CN111984228B (en) Interface document processing method and device, computer equipment and storage medium
CN110032388B (en) Incremental file construction, publishing and downloading method and device
Barwell et al. Finding parallel functional pearls: Automatic parallel recursion scheme detection in Haskell functions via anti-unification
CN112711403A (en) Game development synchronization method and device, computer equipment and storage medium
EP1855197B1 (en) Method and system for incremental patching of binary files
CN113986741A (en) Component debugging method and device and computer equipment
CN111190584A (en) EHIS-DB system version release method and device, computer equipment and storage medium
US6275986B1 (en) Compile-time data dependency verification
Pombrio et al. Hygienic resugaring of compositional desugaring
CN109960510B (en) Method for reinforcing Android application dynamic link library and related equipment
CN112748905B (en) Method and device for initializing and calling basic library, electronic equipment and storage medium
CN109766125B (en) Identification method and device for leveling conflict among batches
US8448154B2 (en) Method, apparatus and software for processing software for use in a multithreaded processing environment
Jacobs et al. Solving the VerifyThis 2012 challenges with VeriFast
CN113407187A (en) Method, device and equipment for constructing file system and computer storage medium
JP2016099899A (en) Control system, support device of the same, and programmable control device
CN112527315A (en) Automatic conversion method, device, computer equipment and medium for programming language function
CN117075873A (en) Component conversion method, device, equipment and medium

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