CN116257457A - Function execution condition acquisition method and device, electronic equipment and readable storage medium - Google Patents
Function execution condition acquisition method and device, electronic equipment and readable storage medium Download PDFInfo
- Publication number
- CN116257457A CN116257457A CN202310541241.6A CN202310541241A CN116257457A CN 116257457 A CN116257457 A CN 116257457A CN 202310541241 A CN202310541241 A CN 202310541241A CN 116257457 A CN116257457 A CN 116257457A
- Authority
- CN
- China
- Prior art keywords
- function
- initial
- target program
- record
- functions
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
- 238000000034 method Methods 0.000 title claims abstract description 51
- 230000006870 function Effects 0.000 claims abstract description 381
- 238000004590 computer program Methods 0.000 claims description 17
- 230000008569 process Effects 0.000 claims description 14
- 230000009471 action Effects 0.000 claims description 10
- 238000012545 processing Methods 0.000 description 11
- 238000004891 communication Methods 0.000 description 7
- 238000010586 diagram Methods 0.000 description 5
- 230000004048 modification Effects 0.000 description 3
- 238000012986 modification Methods 0.000 description 3
- 238000011161 development Methods 0.000 description 2
- 230000004044 response Effects 0.000 description 2
- 230000003068 static effect Effects 0.000 description 2
- 239000011800 void material Substances 0.000 description 2
- 230000009286 beneficial effect Effects 0.000 description 1
- 238000005516 engineering process Methods 0.000 description 1
- 230000007613 environmental effect Effects 0.000 description 1
- 230000003287 optical effect Effects 0.000 description 1
- 239000013307 optical fiber Substances 0.000 description 1
- 230000008447 perception Effects 0.000 description 1
- 238000006467 substitution reaction Methods 0.000 description 1
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/36—Preventing errors by testing or debugging software
- G06F11/3604—Software analysis for verifying properties of programs
- G06F11/3612—Software analysis for verifying properties of programs by runtime analysis
-
- Y—GENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
- Y02—TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
- Y02D—CLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
- Y02D10/00—Energy efficient computing, e.g. low power processors, power management or thermal management
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Software Systems (AREA)
- Computer Hardware Design (AREA)
- Quality & Reliability (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Stored Programmes (AREA)
Abstract
The application relates to the technical field of program development, and provides a method and a device for acquiring function execution conditions, electronic equipment and a readable storage medium. The method comprises the following steps: when a compiling instruction of the target program is received, traversing and collecting all initial functions of the target program, inserting a first record function after a function entry identifier of each initial function, and inserting a second record function before a function exit identifier of each initial function; when an operation instruction for the target program is received, the target program is operated, and the first time recorded by all the first recording functions and the second time recorded by all the second recording functions are obtained; and analyzing the execution condition of the initial function in the target program according to the first moment and the second moment. According to the embodiment of the application, a third-party tool is not needed to participate, the environment is not required to be replaced in stages, the execution condition can be generated under the condition that a user does not feel, the operation is simple, flexible and efficient, and a large amount of time and labor cost are saved.
Description
Technical Field
The present invention relates to the field of program development technologies, and in particular, to a method and apparatus for acquiring a function execution condition, an electronic device, and a readable storage medium.
Background
In the current Android application program development process, developers need to observe and know the program execution process of the service running device during development. The traditional observation mode is that a function call stack observation tool of a third party such as a system trace, a trace view and the like is called to record a program running process, specifically, when the program runs, trace files are recorded through adb commands, and then the trace files are analyzed and read through specific software of a computer terminal. The recording and the reading of the mode can only be carried out in stages, the function call stack can not be recorded and the recorded file can not be output simultaneously in the same terminal or the same environment, the recording and the reading both need to set corresponding environment conditions for specific software or tools, the use requirement is high, and the user operation experience is poor.
Therefore, how to provide a solution to the above technical problem is a problem that needs to be solved by those skilled in the art.
Disclosure of Invention
In view of this, the embodiments of the present application provide a method, an apparatus, an electronic device, and a readable storage medium for acquiring a function execution condition, so as to solve the problems of complicated observation steps and high environmental requirements of program execution in the prior art.
In a first aspect of an embodiment of the present application, a method for acquiring a function execution condition is provided, including:
when a compiling instruction of the target program is received, traversing and collecting all initial functions of the target program, inserting a first record function after a function entry identifier of each initial function, and inserting a second record function before a function exit identifier of each initial function; the first recording function is used for recording a first moment when the first recording function is called, and the second recording function is used for recording a second moment when the second recording function is called;
when an operation instruction for the target program is received, the target program is operated, and the first time recorded by all the first recording functions and the second time recorded by all the second recording functions are obtained;
and analyzing the execution condition of the initial function in the target program according to the first moment and the second moment.
In a second aspect of the embodiments of the present application, there is provided a function execution situation obtaining apparatus, including:
the instrumentation module is used for traversing and collecting all initial functions of the target program when a compiling instruction of the target program is received, inserting a first record function after a function entry identifier of each initial function, and inserting a second record function before a function exit identifier of each initial function; the first recording function is used for recording a first moment when the first recording function is called, and the second recording function is used for recording a second moment when the second recording function is called;
the operation module is used for operating the target program when receiving an operation instruction of the target program, and acquiring first moments recorded by all the first recording functions and second moments recorded by all the second recording functions;
and the analysis module is used for analyzing the execution condition of the initial function in the target program according to the first moment and the second moment.
In a third aspect of the embodiments of the present application, there is provided an electronic device comprising a memory, a processor and a computer program stored in the memory and executable on the processor, the processor implementing the steps of the above method when executing the computer program.
In a fourth aspect of the embodiments of the present application, there is provided a readable storage medium storing a computer program which, when executed by a processor, implements the steps of the above method.
Compared with the prior art, the beneficial effects of the embodiment of the application at least comprise: according to the method and the device for processing the target program, the first recording function and the second recording function are inserted into the target program during compiling, the action time of each initial function during the running of the target program is directly recorded by the first recording function and the second recording function, and then the execution condition of each initial function is analyzed, the participation of a third party tool is not needed, the environment is not required to be replaced in stages, the execution condition can be generated under the condition that a user does not feel, the operation is simple, flexible and efficient, and a large amount of time and labor cost are saved.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present application, the following description will briefly introduce the drawings that are needed in the embodiments or the description of the prior art, it is obvious that the drawings in the following description are only some embodiments of the present application, and that other drawings may be obtained according to these drawings without inventive effort for a person skilled in the art.
Fig. 1 is a schematic view of an application scenario according to an embodiment of the present application;
FIG. 2 is a flowchart of a method for obtaining a function execution situation according to an embodiment of the present application;
FIG. 3 is a schematic sub-flowchart of a method for obtaining a function execution situation according to an embodiment of the present application;
FIG. 4 is a schematic diagram of the association logic of an initial function according to an embodiment of the present application;
FIG. 5 is a schematic structural diagram of a function execution situation obtaining device according to an embodiment of the present application;
fig. 6 is a schematic structural diagram of an electronic device according to an embodiment of the present application.
Detailed Description
In the following description, for purposes of explanation and not limitation, specific details are set forth, such as particular system configurations, techniques, etc. in order to provide a thorough understanding of the embodiments of the present application. It will be apparent, however, to one skilled in the art that the present application may be practiced in other embodiments that depart from these specific details. In other instances, detailed descriptions of well-known systems, devices, circuits, and methods are omitted so as not to obscure the description of the present application with unnecessary detail.
A method, an apparatus, an electronic device, and a readable storage medium for acquiring a function execution situation according to an embodiment of the present application will be described in detail below with reference to the accompanying drawings.
Fig. 1 is a schematic view of an application scenario according to an embodiment of the present application. The application scenario may include a first terminal device 101, a second terminal device 102, and a third terminal device 103, a server 104, and a network 105.
The first terminal device 101 may be hardware or software. When the first terminal device 101 is hardware, it may be various electronic devices having a display screen and supporting communication with the server 104, including but not limited to smartphones, tablets, laptop portable computers, desktop computers, and the like; when the first terminal apparatus 101 is software, it may be installed in the electronic apparatus as described above. The first terminal device 101 may be implemented as a plurality of software or software modules, or may be implemented as a single software or software module, which is not limited in this embodiment of the present application. Further, various applications, such as a data processing application, an instant messaging tool, social platform software, a search class application, a shopping class application, and the like, may be installed on the first terminal device 101.
The second terminal device 102 may be hardware or software. When the second terminal device 102 is hardware, it may be a variety of electronic devices having a display screen and supporting communication with the server 104, including but not limited to smartphones, tablets, laptop and desktop computers, and the like; when the second terminal device 102 is software, it may be installed in the electronic device as described above. The second terminal device 102 may be implemented as a plurality of software or software modules, or may be implemented as a single software or software module, which is not limited in this embodiment of the present application. Further, various applications may be installed on the second terminal device 102, such as a data processing application, an instant messaging tool, social platform software, a search class application, a shopping class application, and the like.
The third terminal device 103 may be hardware or software. When the third terminal device 103 is hardware, it may be various electronic devices having a display screen and supporting communication with the server 104, including but not limited to smartphones, tablets, laptop and desktop computers, etc.; when the third terminal device 103 is software, it may be installed in the electronic device as described above. The third terminal device 103 may be implemented as a plurality of software or software modules, or may be implemented as a single software or software module, which is not limited in this embodiment of the present application. Further, various applications, such as a data processing application, an instant messaging tool, social platform software, a search class application, a shopping class application, and the like, may be installed on the third terminal device 103.
The server 104 may be a server that provides various services, for example, a background server that receives a request transmitted from a terminal device with which communication connection is established, and the background server may perform processing such as receiving and analyzing the request transmitted from the terminal device and generate a processing result. The server 104 may be a server, a server cluster formed by a plurality of servers, or a cloud computing service center, which is not limited in this embodiment of the present application.
The server 104 may be hardware or software. When the server 104 is hardware, it may be various electronic devices that provide various services to the first terminal device 101, the second terminal device 102, and the third terminal device 103. When the server 104 is software, it may be a plurality of software or software modules providing various services to the first terminal device 101, the second terminal device 102, and the third terminal device 103, or may be a single software or software module providing various services to the first terminal device 101, the second terminal device 102, and the third terminal device 103, which is not limited in this embodiment of the present application.
The network 105 may be a wired network using coaxial cable, twisted pair and optical fiber connection, or may be a wireless network that can implement interconnection of various communication devices without wiring, for example, bluetooth (Bluetooth), near field communication (Near Field Communication, NFC), infrared (Infrared), etc., which is not limited in the embodiment of the present application.
It should be noted that the specific types, numbers and combinations of the first terminal device 101, the second terminal device 102, the third terminal device 103, the server 104 and the network 105 may be adjusted according to the actual requirements of the application scenario, which is not limited in the embodiment of the present application.
Fig. 2 is a flowchart of a method for obtaining a function execution situation according to an embodiment of the present application. The function execution acquisition method of fig. 2 may be executed by the first terminal device or the second terminal device or the third terminal device of fig. 1. As shown in fig. 2, the function execution acquisition method includes:
s201: when a compiling instruction of the target program is received, traversing and collecting all initial functions of the target program, inserting a first record function after a function entry identifier of each initial function, and inserting a second record function before a function exit identifier of each initial function; the first recording function is used for recording a first moment when the first recording function is called, and the second recording function is used for recording a second moment when the second recording function is called;
s202: when an operation instruction for the target program is received, the target program is operated, and the first time recorded by all the first recording functions and the second time recorded by all the second recording functions are obtained;
s203: and analyzing the execution condition of the initial function in the target program according to the first moment and the second moment.
According to the method and the device for processing the target program, the first recording function and the second recording function are inserted into the target program during compiling, the action time of each initial function during the running of the target program is directly recorded by the first recording function and the second recording function, and then the execution condition of each initial function is analyzed, the participation of a third party tool is not needed, the environment is not required to be replaced in stages, the execution condition can be generated under the condition that a user does not feel, the operation is simple, flexible and efficient, and a large amount of time and labor cost are saved.
In response to an operation of compiling an instruction, an initial source code is compiled through a virtual machine compiler to generate a byte code file, i.e. extended into a class file, so that a target program can be run according to the byte code file. After receiving the compiling instruction for the target program in step S201, the embodiment of the present application further traverses and collects all initial functions of the target program and inserts the first record function and the second record function into the target program, in addition to compiling the source code of the target program to generate the byte code file. And traversing and collecting the catalogs of the byte code files when traversing and collecting all initial functions of the target program, wherein the byte code files comprise all byte code files in Android Studio engineering and JAR packages, and the catalogs comprise the catalogs of local code compiling results and the catalogs in JAR packages, so that all initial functions in the target program can be collected. The byte code file of the target program is known to contain specific executable contents of all initial functions, the actions of inserting the first record function and the second record function are also executed on the byte code file, the operations of inserting the first record function and the second record function are completed by an ASM tool, and the ASM tool is a set of open source modification tools, so that byte code level content modification can be carried out on each byte code file.
Step S201 may thus comprise: when a compiling instruction of the target program is received, traversing and collecting all initial functions of the target program in a byte code file of the target program, and executing the following steps on the byte code file through an ASM tool: a first record function is inserted after the function entry identifier of each initial function and a second record function is inserted before the function exit identifier of each initial function.
In step S201, in response to the compiling instruction, the action executed on the bytecode file by the ASM tool may also be performed by calling a preset compiling plug-in, which is preconfigured in the programming software, taking the Android Studio as an example of the environment of the target program in this embodiment, and the preset compiling plug-in is preconfigured in the Android Studio engineering, and during the engineering compiling, the compiler may call the preset compiling plug-in to modify the bytecode file through an interface Transform API (Application Programming Interface ) provided in the architecture when responding to the compiling instruction.
Step S201 may thus comprise: when a compiling instruction of the target program is received, a preset compiling plug-in is called through a Transform API, so that the following actions are executed through the preset compiling plug-in: all initial functions of the collection target program are traversed, a first record function is inserted after the function entry identifier of each initial function, and a second record function is inserted before the function exit identifier of each initial function.
The first recording function and the second recording function inserted in step S201 may be called as the target program is run in step S202. Because of the setting in step S201, when the target program is executed in step S202, the first record function is executed before each initial function is executed, and the second record function is executed before each initial function is finished. The first record function and the second record function are used for recording the current time when the first record function is called, the calling time of the two record functions is known to be directly related to the position of the first record function, the first record function is located behind the function entry identifier of each initial function, the first time recorded when each first record function is called can represent the starting execution time of the corresponding initial function, the second record function is located in front of the function exit identifier of each initial function, and the second time recorded when each second record function is called can represent the ending execution time of the corresponding initial function.
Fig. 3 is a schematic sub-flowchart of step S201 of the function execution status acquisition method according to the embodiment of the present application. The complete program comprises a plurality of initial functions, and complex nesting, quoting and other association logic exists among the initial functions, so that in order to not miss any initial function, record the association logic among the initial functions, record the correspondence between the initial functions and the first record function and the second record function, ID marking can be carried out on the initial functions after traversing and collecting all the initial functions, namely: after receiving the compiling instruction of the target program and traversing and collecting all initial functions of the target program, inserting a first record function after the function entry identifier of each initial function and inserting a second record function before the function exit identifier of each initial function, and further comprising: each initial function is tagged with a unique function ID. The function ID may optionally be represented in a 4 byte int integer.
Accordingly, a process for inserting a first record function after a function entry identifier of each initial function and a second record function before a function exit identifier of each initial function, comprising: a first record function corresponding to the function ID of the initial function is inserted after the function entry identifier of each initial function, and a second record function corresponding to the function ID of the initial function is inserted before the function exit identifier of each initial function. The action of inserting the first record function corresponding to the function ID is that "static void in (int) is inserted after the function entry identifier of the initial function," wherein in is the function execution logic of the first record function and (int) is the function ID of the initial function in the current flow; similarly, the action of inserting the second record function corresponding to the function ID, namely inserting a' static void in (int) before the function exit identifier of each initial function, wherein out is the function execution logic of the second record function, and (int) is the function ID of the initial function in the current flow.
When the target program is executed in step S202, the bytecode files inserted into the first recording function and the second recording function are actually executed, and the first recording function and the second recording function are called and record the first time or the second time accordingly along with the execution of the target program. The first time and the second time are typically recorded in the call log buffer queue buffer, that is, the first log function is used to record a first time when itself is called in the call log buffer queue, and the second log function is used to record a second time when itself is called in the call log buffer queue.
When a developer pays attention to a certain code interval in a certain time period of program operation, the terminal equipment executing the method of the embodiment of the application receives an operation instruction taking the code interval as a target program, so as to operate the target program, and acquire first moments recorded by all first recording functions and second moments recorded by all second recording functions. Acquiring the first time recorded by all the first recording functions and the second time recorded by all the second recording functions in the process of operating the target program comprises the following steps: and entering a function call stack recording flow, and creating a long array object serving as a call record buffer queue, namely a buffer queue for short, wherein the long array object is used for storing the input information of the first record function and the second record function. Taking the initial function of the association logic of fig. 4 as an example, when the initial function a starts to execute, the first record function IN () interface is called and the function ID of the initial function a is transferred IN (id_a is assumed), at this time, the value of the function call information expressed IN long form (in_id_a: the IN/out flag+function id+call time) is stored IN the buffer queue, where the IN/out flag is 0 or 1, to distinguish the first time from the second time, the function ID is the last 20 bits intercepted from 32 bits of the function ID of the original int integer, the first time is the last 43 bits intercepted from the current time of the original long form, the value is 64 bits IN total, and the bit structure can be shown IN the following table 1:
table 1A bit structure of function Call information value
After a function call information value is stored, the buffer queue cursor is incremented by 1, and the initial function B, C can be executed by analogy, and in_id_b, in_id_c, out_id_c, out_id_b, out_id_a are sequentially stored.
After the execution of the target program is completed, the executing step S203 may take the value data out of the call record buffer queue and traverse each long type value according to the first time and the second time before analyzing the execution condition of the initial function in the target program, and analyze the first time and the second time corresponding to the specific function ID set by the bit structure of the value. The analyzing the execution condition of the initial function includes analyzing the execution time consumption of each initial function, that is, the step S203 includes the steps of: subtracting the second moment and the first moment of each initial function, and determining the execution time consumption of the initial functions. Further, the analysis of the execution condition can also consider the association logic between the initial functions, and deeply analyze the logic structure between the initial functions according to the association logic and each execution time.
The embodiment can locate the CPU overhead of the target program in running by utilizing the analysis of the execution condition at the first time and the second time, so that the setting can be further optimized according to different target programs or application environments and development purposes. For example, in step S203, the analyzed initial function may select a specified range, and specific step S203 includes: when an analysis instruction is received, determining a function to be analyzed corresponding to the analysis instruction from all initial functions of the target program; and analyzing the execution condition of each function to be analyzed according to the first moment and the second moment of each function to be analyzed.
The traditional observation mode of program execution can only acquire the record file through a command line, then analyze the record file by using a matched tool to analyze the function call flow, and in the embodiment of the application, the range selection of the target program, the compiling instruction and the receiving time of the running instruction can be set and operated by a user, and the flow of the steps S201-S203 is adopted, so that the method has the advantages of simple use, no perception of the user, strong expansibility and flexible application, and greatly saves the time cost for service developers.
Any combination of the above optional solutions may be adopted to form an optional embodiment of the present application, which is not described herein in detail. It should be understood that the sequence number of each step in the foregoing embodiment does not mean that the execution sequence of each process should be determined by the function and the internal logic of each process, and should not limit the implementation process of the embodiment of the present application in any way.
The following are device embodiments of the present application, which may be used to perform method embodiments of the present application. For details not disclosed in the device embodiments of the present application, please refer to the method embodiments of the present application.
Fig. 5 is a schematic diagram of a function execution situation obtaining device provided in an embodiment of the present application. As shown in fig. 5, the function execution situation acquisition means includes:
the instrumentation module 501 is configured to, when receiving a compiling instruction for a target program, traverse and collect all initial functions of the target program, insert a first record function after a function entry identifier of each initial function, and insert a second record function before a function exit identifier of each initial function; the first recording function is used for recording a first moment when the first recording function is called, and the second recording function is used for recording a second moment when the second recording function is called;
the operation module 502 is configured to operate the target program when an operation instruction for the target program is received, and obtain first moments recorded by all the first recording functions and second moments recorded by all the second recording functions;
and the analysis module 503 is configured to analyze the execution condition of the initial function in the target program according to the first time and the second time.
According to the method and the device for processing the target program, the first recording function and the second recording function are inserted into the target program during compiling, the action time of each initial function during the running of the target program is directly recorded by the first recording function and the second recording function, and then the execution condition of each initial function is analyzed, the participation of a third party tool is not needed, the environment is not required to be replaced in stages, the execution condition can be generated under the condition that a user does not feel, the operation is simple, flexible and efficient, and a large amount of time and labor cost are saved.
In some particular embodiments, stake pocket 501 is specifically configured to:
when a compiling instruction of the target program is received, traversing and collecting all initial functions of the target program in a byte code file of the target program, and executing the following steps on the byte code file through an ASM tool:
a first record function is inserted after the function entry identifier of each initial function and a second record function is inserted before the function exit identifier of each initial function.
In some specific embodiments, after receiving the compiling instruction for the target program and traversing all the initial functions of the collection target program, inserting a first record function after the function entry identifier of each initial function, and inserting a second record function before the function exit identifier of each initial function, the instrumentation module 501 is further configured to:
marking each initial function with a unique function ID;
accordingly, a process for inserting a first record function after a function entry identifier of each initial function and a second record function before a function exit identifier of each initial function, comprising:
a first record function corresponding to the function ID of the initial function is inserted after the function entry identifier of each initial function, and a second record function corresponding to the function ID of the initial function is inserted before the function exit identifier of each initial function.
In some particular embodiments, stake pocket 501 is specifically configured to
When a compiling instruction of the target program is received, a preset compiling plug-in is called through a Transform API, so that the following actions are executed through the preset compiling plug-in:
all initial functions of the collection target program are traversed, a first record function is inserted after the function entry identifier of each initial function, and a second record function is inserted before the function exit identifier of each initial function.
In some specific embodiments, the first logging function is configured to record a first time when itself is invoked in the call log cache queue, and the second logging function is configured to record a second time when itself is invoked in the call log cache queue.
In some specific embodiments, the analysis module 503 is specifically configured to:
when an analysis instruction is received, determining a function to be analyzed corresponding to the analysis instruction from all initial functions of the target program;
and analyzing the execution condition of each function to be analyzed according to the first moment and the second moment of each function to be analyzed.
In some specific embodiments, the analysis module 503 is specifically configured to:
subtracting the second moment and the first moment of each initial function, and determining the execution time consumption of the initial functions.
Fig. 6 is a schematic diagram of an electronic device 6 provided in an embodiment of the present application. As shown in fig. 6, the electronic device 6 of this embodiment includes: a processor 601, a memory 602 and a computer program 603 stored in the memory 602 and executable on the processor 601. The steps of the various method embodiments described above are implemented by the processor 601 when executing the computer program 603. Alternatively, the processor 601, when executing the computer program 603, performs the functions of the modules/units of the apparatus embodiments described above.
The electronic device 6 may be a desktop computer, a notebook computer, a palm computer, a cloud server, or the like. The electronic device 6 may include, but is not limited to, a processor 601 and a memory 602. It will be appreciated by those skilled in the art that fig. 6 is merely an example of the electronic device 6 and is not limiting of the electronic device 6 and may include more or fewer components than shown, or different components.
The processor 601 may be a central processing unit (Central Processing Unit, CPU) or other general purpose processor, digital signal processor (Digital Signal Processor, DSP), application specific integrated circuit (Application SpecificIntegrated Circuit, ASIC), field programmable gate array (Field-Programmable Gate Array, FPGA) or other programmable logic device, discrete gate or transistor logic device, discrete hardware components, or the like.
The memory 602 may be an internal storage unit of the electronic device 6, for example, a hard disk or a memory of the electronic device 6. The memory 602 may also be an external storage device of the electronic device 6, for example, a plug-in hard disk, a Smart Media Card (SMC), a Secure Digital (SD) Card, a Flash Card (Flash Card) or the like, which are provided on the electronic device 6. The memory 602 may also include both internal and external storage units of the electronic device 6. The memory 602 is used to store computer programs and other programs and data required by the electronic device.
It will be apparent to those skilled in the art that, for convenience and brevity of description, only the above-described division of the functional units and modules is illustrated, and in practical application, the above-described functional distribution may be performed by different functional units and modules according to needs, i.e. the internal structure of the apparatus is divided into different functional units or modules to perform all or part of the above-described functions. The functional units and modules in the embodiment may be integrated in one processing unit, or each unit may exist alone physically, or two or more units may be integrated in one unit, where the integrated units may be implemented in a form of hardware or a form of a software functional unit.
The integrated modules/units may be stored in a readable storage medium if implemented in the form of software functional units and sold or used as stand-alone products. Based on such understanding, the present application implements all or part of the flow in the method of the above embodiment, or may be implemented by a computer program to instruct related hardware, where the computer program may be stored in a readable storage medium, where the computer program may implement the steps of the method embodiments described above when executed by a processor. The computer program may comprise computer program code, which may be in source code form, object code form, executable file or in some intermediate form, etc. The readable storage medium may include: any entity or device capable of carrying computer program code, a recording medium, a U disk, a removable hard disk, a magnetic disk, an optical disk, a computer Memory, a Read-Only Memory (ROM), a random access Memory (Random Access Memory, RAM), an electrical carrier signal, a telecommunications signal, a software distribution medium, and so forth. It should be noted that the content of the readable storage medium may be appropriately scaled according to the requirements of jurisdictions in which such legislation and patent practice, for example, in some jurisdictions, the readable storage medium does not include electrical carrier signals and telecommunication signals according to the legislation and patent practice.
The above embodiments are only for illustrating the technical solution of the present application, and are not limiting thereof; although the present application has been described in detail with reference to the foregoing embodiments, it should be understood by those of ordinary skill in the art that: the technical scheme described in the foregoing embodiments can be modified or some technical features thereof can be replaced by equivalents; such modifications and substitutions do not depart from the spirit and scope of the technical solutions of the embodiments of the present application, and are intended to be included in the scope of the present application.
Claims (10)
1. A method for obtaining a function execution condition, comprising:
when a compiling instruction of a target program is received, traversing and collecting all initial functions of the target program, inserting a first record function after a function entry identifier of each initial function, and inserting a second record function before a function exit identifier of each initial function; the first recording function is used for recording a first moment when the first recording function is called, and the second recording function is used for recording a second moment when the second recording function is called;
when an operation instruction of the target program is received, the target program is operated, and the first moments recorded by all the first recording functions and the second moments recorded by all the second recording functions are obtained;
and analyzing the execution condition of the initial function in the target program according to the first moment and the second moment.
2. The method according to claim 1, wherein when a compiling instruction for a target program is received, traversing a process of collecting all initial functions of the target program, inserting a first record function after a function entry identifier of each of the initial functions, and inserting a second record function before a function exit identifier of each of the initial functions, comprising:
when a compiling instruction of a target program is received, traversing and collecting all initial functions of the target program in a byte code file of the target program, and executing the following steps on the byte code file through an ASM tool:
a first record function is inserted after the function entry identifier of each of said initial functions and a second record function is inserted before the function exit identifier of each of said initial functions.
3. The method according to claim 1, wherein after receiving a compiling instruction for a target program and traversing and collecting all initial functions of the target program, inserting a first record function after a function entry identifier of each of the initial functions and inserting a second record function before a function exit identifier of each of the initial functions, further comprising:
marking each initial function with a unique function ID;
accordingly, a process of inserting a first record function after a function entry identifier of each of said initial functions and a second record function before a function exit identifier of each of said initial functions, comprising:
a first record function corresponding to the function ID of each initial function is inserted after the function entry identifier of the initial function, and a second record function corresponding to the function ID of the initial function is inserted before the function exit identifier of each initial function.
4. The method according to claim 1, wherein when a compiling instruction for a target program is received, traversing a process of collecting all initial functions of the target program, inserting a first record function after a function entry identifier of each of the initial functions, and inserting a second record function before a function exit identifier of each of the initial functions, comprising:
when a compiling instruction for a target program is received, a preset compiling plug-in is called through a Transform API, so that the following actions are executed through the preset compiling plug-in:
all initial functions of the target program are collected through traversal, a first record function is inserted after the function entry identifier of each initial function, and a second record function is inserted before the function exit identifier of each initial function.
5. The method of claim 1, wherein the first record function is configured to record a first time when the record itself is invoked in a call record cache queue, and wherein the second record function is configured to record a second time when the record itself is invoked in the call record cache queue.
6. The method according to claim 1, wherein the process of analyzing the execution of the initial function in the target program according to the first time and the second time comprises:
when an analysis instruction is received, determining a function to be analyzed corresponding to the analysis instruction from all the initial functions of the target program;
and analyzing the execution condition of each function to be analyzed according to the first moment and the second moment of each function to be analyzed.
7. The method according to any one of claims 1 to 6, wherein the process of analyzing the execution of the initial function in the target program according to the first time and the second time comprises:
subtracting the first moment from the second moment of each initial function, and determining the execution time consumption of the initial functions.
8. A function execution situation acquisition apparatus, comprising:
the instrumentation module is used for traversing and collecting all initial functions of the target program when a compiling instruction of the target program is received, inserting a first record function after a function entry identifier of each initial function, and inserting a second record function before a function exit identifier of each initial function; the first recording function is used for recording a first moment when the first recording function is called, and the second recording function is used for recording a second moment when the second recording function is called;
the operation module is used for operating the target program when receiving an operation instruction of the target program, and acquiring the first moments recorded by all the first recording functions and the second moments recorded by all the second recording functions;
and the analysis module is used for analyzing the execution condition of the initial function in the target program according to the first moment and the second moment.
9. An electronic device comprising a memory, a processor and a computer program stored in the memory and executable on the processor, characterized in that the processor implements the steps of the method according to any of claims 1 to 7 when the computer program is executed.
10. A readable storage medium storing a computer program, characterized in that the computer program when executed by a processor implements the steps of the method according to any one of claims 1 to 7.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202310541241.6A CN116257457A (en) | 2023-05-15 | 2023-05-15 | Function execution condition acquisition method and device, electronic equipment and readable storage medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202310541241.6A CN116257457A (en) | 2023-05-15 | 2023-05-15 | Function execution condition acquisition method and device, electronic equipment and readable storage medium |
Publications (1)
Publication Number | Publication Date |
---|---|
CN116257457A true CN116257457A (en) | 2023-06-13 |
Family
ID=86682852
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202310541241.6A Pending CN116257457A (en) | 2023-05-15 | 2023-05-15 | Function execution condition acquisition method and device, electronic equipment and readable storage medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN116257457A (en) |
Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US7836438B1 (en) * | 2003-12-30 | 2010-11-16 | Sap Ag | Modified classfile registration with a dispatch unit that is responsible for dispatching invocations during runtime execution of modified bytecode |
CN103473168A (en) * | 2013-09-12 | 2013-12-25 | 中国科学院声学研究所 | Statistical method for hotspot program |
CN103853603A (en) * | 2012-12-07 | 2014-06-11 | 腾讯科技(深圳)有限公司 | Acquisition method and device for function calling relation |
CN104899016A (en) * | 2014-03-07 | 2015-09-09 | 腾讯科技(深圳)有限公司 | Call stack relationship obtaining method and call stack relationship obtaining device |
CN108959069A (en) * | 2018-06-11 | 2018-12-07 | 北京奇艺世纪科技有限公司 | A kind of method for tracing and device of function operation |
-
2023
- 2023-05-15 CN CN202310541241.6A patent/CN116257457A/en active Pending
Patent Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US7836438B1 (en) * | 2003-12-30 | 2010-11-16 | Sap Ag | Modified classfile registration with a dispatch unit that is responsible for dispatching invocations during runtime execution of modified bytecode |
CN103853603A (en) * | 2012-12-07 | 2014-06-11 | 腾讯科技(深圳)有限公司 | Acquisition method and device for function calling relation |
CN103473168A (en) * | 2013-09-12 | 2013-12-25 | 中国科学院声学研究所 | Statistical method for hotspot program |
CN104899016A (en) * | 2014-03-07 | 2015-09-09 | 腾讯科技(深圳)有限公司 | Call stack relationship obtaining method and call stack relationship obtaining device |
CN108959069A (en) * | 2018-06-11 | 2018-12-07 | 北京奇艺世纪科技有限公司 | A kind of method for tracing and device of function operation |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
WO2021184725A1 (en) | User interface test method and apparatus, storage medium, and computer device | |
CN103294598B (en) | A kind of source code inspection method and device | |
CN104246759A (en) | Application programming interface testing services | |
CN111666201A (en) | Regression testing method, device, medium and electronic equipment | |
CN111796865B (en) | Byte code file modification method, device, terminal equipment and medium | |
CN109241722A (en) | For obtaining method, electronic equipment and the computer-readable medium of information | |
CN112631924A (en) | Automatic testing method and device, computer equipment and storage medium | |
CN114138674A (en) | Automatic testing method and device and computer equipment | |
CN111563257A (en) | Data detection method and device, computer readable medium and terminal equipment | |
CN110659210A (en) | Information acquisition method and device, electronic equipment and storage medium | |
CN110045952B (en) | Code calling method and device | |
CN111506904A (en) | Method and device for online vulnerability repair | |
CN111124541A (en) | Configuration file generation method, device, equipment and medium | |
CN111046393B (en) | Vulnerability information uploading method and device, terminal equipment and storage medium | |
CN111488286B (en) | Method and device for independently developing Android modules | |
CN112860538A (en) | Method and device for performing interface regression test based on online log | |
CN110908882A (en) | Performance analysis method and device of application program, terminal equipment and medium | |
CN109542775A (en) | A kind of generation and execution method and device of test script | |
CN116257457A (en) | Function execution condition acquisition method and device, electronic equipment and readable storage medium | |
CN112379967B (en) | Simulator detection method, device, equipment and medium | |
CN113760291B (en) | Log output method and device | |
CN111222739B (en) | Nuclear power station task allocation method and nuclear power station task allocation system | |
CN111027196B (en) | Simulation analysis task processing method and device for power equipment and storage medium | |
CN114090514A (en) | Log retrieval method and device for distributed system | |
CN110471708B (en) | Method and device for acquiring configuration items based on reusable components |
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 | ||
RJ01 | Rejection of invention patent application after publication | ||
RJ01 | Rejection of invention patent application after publication |
Application publication date: 20230613 |