CN115809172A - Software monitoring method and related device - Google Patents

Software monitoring method and related device Download PDF

Info

Publication number
CN115809172A
CN115809172A CN202111071051.XA CN202111071051A CN115809172A CN 115809172 A CN115809172 A CN 115809172A CN 202111071051 A CN202111071051 A CN 202111071051A CN 115809172 A CN115809172 A CN 115809172A
Authority
CN
China
Prior art keywords
function
memory address
monitored
program
jumping
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202111071051.XA
Other languages
Chinese (zh)
Inventor
张俊
周剑宇
钱佳炎
王旭
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shanghai Huawei Technologies Co Ltd
Original Assignee
Shanghai Huawei Technologies Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Shanghai Huawei Technologies Co Ltd filed Critical Shanghai Huawei Technologies Co Ltd
Priority to CN202111071051.XA priority Critical patent/CN115809172A/en
Priority to PCT/CN2022/117011 priority patent/WO2023036076A1/en
Publication of CN115809172A publication Critical patent/CN115809172A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/30Monitoring
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Quality & Reliability (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Computer Hardware Design (AREA)
  • Debugging And Monitoring (AREA)

Abstract

The embodiment of the application provides a software monitoring method and a related device, which are used for dynamically monitoring program running data, so that a running software program does not need to be compiled repeatedly, and the software monitoring efficiency is improved. The method specifically comprises the following steps: acquiring a preset memory address of a first function and a preset memory address of a second function; when the program to be monitored runs to the function to be monitored, jumping to the first function according to the memory address of the first function and executing the first function; recording a first memory address of a function to be monitored and a second memory address of a program to be monitored; after the first function is executed, jumping to a function to be monitored according to the first memory address and executing the function to be monitored; after the execution of the function to be monitored is finished, jumping to the second function according to the memory address of the second function and executing the second function; after the second function is executed, jumping to a program to be monitored according to the second memory address; and determining the dimension measurement data of the function to be monitored according to the use information of the first function and the second function.

Description

Software monitoring method and related device
Technical Field
The present application relates to the field of computer technologies, and in particular, to a software monitoring method and a related apparatus.
Background
When monitoring the state and debugging the performance of a software program, it is often necessary to analyze each flow of software operation in detail to obtain data such as the internal state of a Central Processing Unit (CPU) during the operation process.
The extraction method of program operation data can be generally divided into three types, which are a pure hardware extraction mode, a pure software extraction mode and a software and hardware combined extraction mode respectively. Because the pure hardware mode usually adopts a sampling mode to obtain program operation data, some important signals are inevitably lost, and the analysis range is limited, a satisfactory test result is difficult to obtain in practical application. The pure software mode generally adopts a software instrumentation technology, namely, intrusive modification of software codes is adopted to carry out instrumentation processing on a software program.
Therefore, the software operation flow is influenced, so that the accuracy of monitoring data is influenced, the codes are required to be modified in a segmented mode according to the segmented acquisition state, and the codes are required to be recompiled and operated again every time, so that the efficiency is low.
Disclosure of Invention
The embodiment of the application provides a software monitoring method and a related device, which are used for dynamically monitoring program running data in the software running process, so that the running software program does not need to be repeatedly compiled, and the software monitoring efficiency is improved.
In a first aspect, an embodiment of the present application provides a software monitoring method, which specifically includes acquiring, by a software monitoring device, a preset memory address of a first function and a preset memory address of a second function; then when the program to be monitored runs to the function to be monitored, the software monitoring device jumps to the first function from the program to be monitored according to the memory address of the first function and executes the first function, wherein the function to be monitored is contained in the program to be monitored, namely the function to be monitored is a part of the program to be monitored; then the software monitoring device records a first memory address of the function to be monitored and returns a second memory address of the program to be monitored; after the first function is executed, the software monitoring device jumps to the function to be monitored according to the first memory address and executes the function to be monitored; after the execution of the function to be monitored is finished, the software monitoring device jumps to the second function according to the memory address of the second function and executes the second function; then the software monitoring device jumps to the program to be monitored according to the second memory address after the second function is executed; and finally, the software monitoring device determines the measurement data of the function to be monitored according to the use information of the first function and the second function.
In this embodiment, the program to be monitored is a main software program, and the function to be monitored is a part of the program to be monitored. It should be understood that the memory address of the first function and the memory address of the second function are not located between the memory addresses of the program to be monitored, i.e., the first function and the second function are not inserted into the program to be monitored. Meanwhile, the first function may be named as a start function, and the second function may be named as an end function, which is not limited herein.
In the technical solution provided in this embodiment, when the program to be monitored runs to the function to be monitored, jump to the first function and run the first function first, and then after the first function is run completely, run the function to be monitored normally; skipping to the second function after the function to be monitored is operated; and finally, jumping to the program to be monitored after the second function is operated, and determining the operation condition of the function to be monitored according to the use information of the first function and the second function. Therefore, when the software monitoring device monitors the program to be monitored, the software monitoring device does not need to insert piles in the program to be monitored, and only needs to carry out corresponding jump before and after the function to be monitored is operated, so that the software program does not need to be compiled and operated repeatedly, and the software monitoring efficiency is improved.
Optionally, when the software monitoring apparatus implements the jump from the function to be monitored to the first function and the second function, several possible implementation manners may be adopted as follows:
in one possible implementation manner, the software monitoring device obtains call points of all functions to be monitored in the program to be monitored, and records memory addresses of the call points; and then the software monitoring device modifies the memory address of the calling point of the function to be monitored into the memory address of the first function. Therefore, when the program to be monitored runs to the call point of the function to be monitored, the program to be monitored jumps to the first function according to the memory address of the first function.
On the basis of the scheme, because the software monitoring device records the second memory address returned by the function to be monitored, the software monitoring device can modify the second memory address into the memory address of the second function, so that the function to be monitored jumps to the second function according to the memory address of the second function after the function to be monitored is completely operated. After the second function is finished running, the software monitoring device restores the modified memory address from the memory address of the second function to the second memory address, and then jumps to the program to be monitored according to the second memory address.
In another possible implementation manner, the software monitoring device obtains call points of all functions to be monitored in the program to be monitored, inserts a No Operation (NOP) instruction before an initial memory address of the function to be monitored, and modifies the NOP instruction into a first instruction for jumping to the first function; then, when the program to be monitored jumps to the function to be monitored, the NOP instruction is executed first, that is, the first instruction is executed to jump to the first function.
On the basis of the scheme, when the function to be monitored is jumped to after the first function is finished running, in order to avoid repeatedly jumping to the first function, the first memory address jumped to the function to be monitored is indicated to be offset from the memory address behind the bytes occupied by the NOP instruction. For example, if the memory address of the function to be monitored from the NOP instruction is 96 and then the byte occupied by the NOP instruction is 4 bytes, after the first function finishes running, it jumps directly to the instruction with memory address 100.
Meanwhile, because the software monitoring device records the second memory address returned by the function to be monitored, the software monitoring device can modify the second memory address into the memory address of the second function, so that the function to be monitored jumps to the second function according to the memory address of the second function after the function to be monitored is completely operated. After the second function is finished running, the software monitoring device restores the modified memory address from the memory address of the second function to the second memory address, and then jumps to the program to be monitored according to the second memory address.
Optionally, the first memory address is an initial memory address of the function to be monitored, the second memory address is a return memory address when the function to be monitored jumps to the program to be monitored after the function to be monitored is completely run, and both the first memory address and the second memory address are stored in a Link Register (LR) Register. For example, when the program to be monitored runs to the memory address 8, the instruction indicated by the memory address 8 jumps to the function to be monitored, and the memory address occupied by the initial instruction of the function to be monitored is 100, then the first memory address is 100. After the function to be monitored is completely run, if the memory address when the program to be monitored is returned is 12, the second memory address is 12.
Optionally, the first function and the second function may be stored in a dynamic link library, and are in different storage areas from the program to be monitored.
In a second aspect, an embodiment of the present application provides a software monitoring apparatus, which has a function of implementing the behavior of the software monitoring apparatus in the first aspect. The function can be realized by hardware, and can also be realized by executing corresponding software by hardware. The hardware or software includes one or more modules corresponding to the functions described above.
In one possible implementation, the apparatus includes means or modules for performing the steps of the first aspect above. For example, the apparatus includes: the acquisition module is used for acquiring a preset memory address of a first function and a preset memory address of a second function; the execution module is used for jumping to the first function according to the memory address of the first function when the program to be monitored runs to the function to be monitored, and the function to be monitored is contained in the program to be monitored; executing the first function, and recording a first memory address of the function to be monitored and a second memory address of the program to be monitored; after the first function is executed, skipping to the program to be monitored according to the first memory address; after the function to be monitored is executed, skipping to the second function according to the memory address of the second function; after the second function is executed, skipping to the program to be monitored according to the second memory address; and the analysis module is used for determining the dimension measurement data of the function to be monitored according to the use information of the first function and the second function.
Optionally, the monitoring device further comprises a storage module for storing necessary program instructions and data of the software monitoring device.
In one possible implementation, the apparatus includes: a processor and a transceiver, the processor being configured to support the software monitoring apparatus to perform the respective functions of the method provided by the first aspect. The transceiver is used for instructing the software to monitor the communication between the device and other devices. Optionally, the device may further include a memory for coupling to the processor that stores program instructions and data necessary for the software monitoring device.
In a possible implementation, when the device is a chip in a software monitoring device, the chip includes: the processing module and the transceiver module, which may be, for example, an input/output interface, a pin, a circuit, or the like on the chip, acquire a memory address of a preset first function and a memory address of a preset second function through another chip or module coupled to the chip; the processing module may be, for example, a processor, where the processor is configured to jump to a first function according to a memory address of the first function when running a program to be monitored to the function to be monitored, where the function to be monitored is included in the program to be monitored; executing the first function, and recording a first memory address of the function to be monitored and a second memory address of the program to be monitored; after the first function is executed, skipping to the program to be monitored according to the first memory address; after the function to be monitored is executed, skipping to the second function according to the memory address of the second function; after the second function is executed, skipping to the program to be monitored according to the second memory address; and determining the dimension measurement data of the function to be monitored according to the use information of the first function and the second function. The processing module can execute computer-executable instructions stored in the storage unit to support the software monitoring device to perform the method provided by the first aspect. Alternatively, the storage unit may be a storage unit in the chip, such as a register, a cache, and the like, and the storage unit may also be a storage unit located outside the chip, such as a read-only memory (ROM) or another type of static storage device that can store static information and instructions, a Random Access Memory (RAM), and the like.
In one possible implementation manner, the apparatus includes a communication interface and a logic circuit, where the communication interface is configured to obtain a memory address of a first preset function and a memory address of a second preset function; the logic circuit is used for jumping to a first function according to the memory address of the first function when a program to be monitored runs to the function to be monitored, wherein the function to be monitored is contained in the program to be monitored; executing the first function, and recording a first memory address of the function to be monitored and a second memory address returned to the program to be monitored; after the first function is executed, skipping to the program to be monitored according to the first memory address; after the function to be monitored is executed, skipping to the second function according to the memory address of the second function; after the second function is executed, skipping to the program to be monitored according to the second memory address; and determining the dimension measurement data of the function to be monitored according to the use information of the first function and the second function.
The processor mentioned in any of the above may be a general Processing Unit (CPU), a microprocessor, an application-specific integrated circuit (ASIC), or one or more integrated circuits for controlling the execution of programs of the above-mentioned data transmission methods.
In a third aspect, the present application provides a computer-readable storage medium storing computer instructions for executing the method according to any possible implementation manner of any one of the above aspects.
In a fourth aspect, embodiments of the present application provide a computer program product comprising instructions which, when run on a computer, cause the computer to perform the method of any one of the above aspects.
In a fifth aspect, the present application provides a chip system comprising a processor for enabling a software monitoring apparatus to implement the functions referred to in the above aspects, such as generating or processing data and/or information referred to in the above methods. In one possible design, the system-on-chip further includes a memory for storing program instructions and data necessary for the software monitoring device to function in any of the above aspects. The chip system may be formed by a chip, and may also include a chip and other discrete devices.
In a sixth aspect, an embodiment of the present application provides a software monitoring system, which includes the software monitoring apparatus and a program to be monitored.
Drawings
FIG. 1 is a diagram of a calling function in a software program;
FIG. 2 is a schematic diagram of an embodiment of a software monitoring method in an embodiment of the present application;
FIG. 3 is a schematic diagram of an exemplary process for monitoring software in an embodiment of the present application;
FIG. 4 is a schematic diagram of another embodiment of the software monitoring method in the embodiment of the present application;
FIG. 5 is another exemplary flow chart of software monitoring in an embodiment of the present application;
FIG. 6 is a schematic diagram of another embodiment of a software monitoring method in the embodiment of the present application;
FIG. 7 is a schematic diagram of an embodiment of a software monitoring device in an embodiment of the present application;
fig. 8 is a schematic diagram of another embodiment of the software monitoring device in the embodiment of the present application.
Detailed Description
In order to make the objects, technical solutions and advantages of the present application more apparent, the embodiments of the present application are described below with reference to the accompanying drawings, and it is obvious that the described embodiments are only some embodiments of the present application, but not all embodiments. As can be known to those skilled in the art, with the advent of new application scenarios, the technical solution provided in the embodiments of the present application is also applicable to similar technical problems.
The terms "first," "second," and the like in the description and in the claims of the present application and in the above-described drawings are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order. It will be appreciated that the data so used may be interchanged under appropriate circumstances such that the embodiments described herein may be practiced otherwise than as specifically illustrated or described herein. Moreover, the terms "comprises," "comprising," and any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, system, article, or apparatus that comprises a list of steps or modules is not necessarily limited to those steps or modules explicitly listed, but may include other steps or modules not expressly listed or inherent to such process, method, article, or apparatus. The naming or numbering of the steps appearing in the present application does not mean that the steps in the method flow have to be executed in the chronological/logical order indicated by the naming or numbering, and the named or numbered process steps may be executed in a modified order depending on the technical purpose to be achieved, as long as the same or similar technical effects are achieved. The division of the units presented in this application is a logical division, and in practical applications, there may be another division, for example, multiple units may be combined or integrated into another system, or some features may be omitted, or not executed, and in addition, the shown or discussed coupling or direct coupling or communication connection between each other may be through some interfaces, and the indirect coupling or communication connection between the units may be in an electrical or other similar form, which is not limited in this application. Furthermore, the units or sub-units described as the separation component may or may not be physically separated, may or may not be physical units, or may be distributed in a plurality of circuit units, and a part or all of the units may be selected according to actual needs to achieve the purpose of the present application.
When monitoring the state and debugging the performance of a software program, each flow of software operation needs to be analyzed in detail to obtain data such as the internal state of a CPU during the operation process. An exemplary diagram of the program call function as shown in FIG. 1: taking the Caller program as an example, it includes Invoked function. The corresponding instruction of the caller is stored from the memory address 0. When the Caller program runs, reading instructions line by line according to memory addresses; when the instruction (i.e. BL Invoked) corresponding to the memory address 8 is executed, the Invoked function is called, i.e. the instruction corresponding to the memory address 100 is jumped to; then, the Invoked function is executed until the instruction (ret) corresponding to the memory address 112 is executed, the memory address 12 is jumped to according to the memory address 12 stored in the LR register, and the instruction corresponding to the memory address 12 is executed. By analogy, other calling programs in the Caller program also operate in the same manner. And if the Invoked function needs to be monitored, extracting the running data of the Invoked function. The extraction method of program operation data can be generally divided into three types, which are a pure hardware extraction mode, a pure software extraction mode and a software and hardware combined extraction mode respectively. Because the pure hardware mode usually adopts a sampling mode to obtain program operation data, some important signals are inevitably lost, and the analysis range is limited, a satisfactory test result is difficult to obtain in practical application. The pure software mode generally adopts a software instrumentation technology, namely, intrusive modification of software codes is adopted to carry out instrumentation processing on a software program. Therefore, the software operation flow is influenced, so that the accuracy of monitoring data is influenced, the codes are required to be modified in a segmented mode according to the segmented acquisition state, and the codes are required to be recompiled and operated again every time, so that the efficiency is low.
In order to solve the problem, an embodiment of the present application provides a software monitoring method, which specifically includes that a software monitoring device obtains a memory address of a preset first function and a memory address of a preset second function; then when the program to be monitored runs to the function to be monitored, the software monitoring device jumps to the first function from the program to be monitored according to the memory address of the first function and executes the first function, wherein the function to be monitored is contained in the program to be monitored, namely the function to be monitored is a part of the program to be monitored; then the software monitoring device records a first memory address of the function to be monitored and returns a second memory address of the program to be monitored; after the first function is executed, the software monitoring device jumps to the function to be monitored according to the first memory address and executes the function to be monitored; after the execution of the function to be monitored is finished, the software monitoring device jumps to the second function according to the memory address of the second function and executes the second function; then the software monitoring device jumps to the program to be monitored according to the second memory address after the second function is executed; and finally, the software monitoring device determines the measurement data of the function to be monitored according to the use information of the first function and the second function.
In the present application, a software monitoring method in the embodiment of the present application is described according to a difference in a method of jumping to the first function.
1. The software monitoring device modifies the memory address of the function to be monitored into the memory address of the first function, and the function of jumping to the first function is realized.
As shown in fig. 2, an embodiment of a software monitoring method in the embodiment of the present application includes:
201. the software monitoring device acquires a preset memory address of a first function and a preset memory address of a second function.
In this embodiment, when the software monitoring apparatus monitors a software program, the software monitoring apparatus may create the first function and the second function in a dynamic link library in advance, and store the first function and the second function at a memory address different from a memory address of the software program. For example, the memory addresses of the program to be monitored correspond to 0 to 188, wherein the memory addresses of the instructions of the Invoked function correspond to 100 to 112, the memory addresses of the instructions of the first function correspond to 200 to 212, and the memory addresses of the instructions of the second function correspond to 300 to 312.
202. The software monitoring device acquires a first memory address of a function to be monitored in a program to be monitored.
When the program to be monitored runs, there may be a plurality of functions to be monitored, and when the software monitoring device monitors the program to be monitored, first memory addresses of all the functions to be monitored need to be acquired. For example, the memory addresses corresponding to the program to be monitored in the memory addresses are 0 to 188, which include three Invoked functions, which in turn are: the memory address corresponding to the call instruction is 8, the memory address corresponding to the called function instruction is 64 to 76, the memory address corresponding to the call instruction is 20, the memory address corresponding to the called function instruction is 100 to 112, the memory address corresponding to the call instruction is 40, and the memory address corresponding to the called function instruction is 152 to 164.
203. The software monitoring device modifies the first memory address to the memory address of the first function.
The software monitoring device modifies the acquired first memory address of each function to be monitored into the memory address of the first function. Namely, the software monitoring device modifies the memory address indicated by the calling instruction from the memory address originally indicating the Invoked function to the memory address of the first function. For example, the software monitoring device modifies the memory address 64 indicated by the call instruction corresponding to the memory address 8 to 200; modifying the memory address 100 indicated by the call instruction corresponding to the memory address 20 to 200; the memory address 152 indicated by the call instruction corresponding to the memory address 40 is modified to 200.
204. When the program to be monitored runs to the function to be monitored, the software monitoring device realizes the jump from the program to be monitored to the first function according to the memory address of the first function, and runs the first function.
After the memory address indicated by the call instruction is modified, the software monitoring device runs the program to be monitored, and when the program to be monitored runs to the call instruction of the function to be monitored, the software monitoring device controls the program to be monitored to jump to the first function according to the modified memory address pointing to the first function; then the software monitoring device controls the first function to start running, and records the first memory address of the function to be monitored and the second memory address of the program to be monitored returned by the function to be monitored in an LR register. For example, the memory address when the Invoked function corresponding to the call instruction corresponding to the memory address 8 returns to the monitor program is 12, the memory address when the Invoked function corresponding to the call instruction corresponding to the memory address 20 returns to the monitor program is 24, and the memory address when the Invoked function corresponding to the call instruction corresponding to the memory address 40 returns to the monitor program is 44.
205. The software monitoring device modifies the second memory address into the memory address of the second function.
The software monitor modifies the second memory address in the LR register to a memory address of the second function. That is, after the function to be monitored is instructed to run, the software monitoring device controls the program to be monitored to jump to the second function according to the memory address of the second function in the LR register. For example, the software monitoring device modifies all 12, 24, and 44 of the LR register to 300.
206. After the first function is completely operated, the software monitoring device jumps to the function to be monitored according to the first memory address.
After the first function finishes running, the software monitoring device reads the first memory address of the LR register, controls the program to be monitored to jump to the function to be monitored according to the first memory address, and controls the function to be monitored to run. For example, the software monitoring device jumps to the Invoked function according to the memory address 100.
207. After the function to be monitored is completely operated, the software monitoring device jumps to the second function according to the memory address of the second function.
After the function to be monitored is completely operated, the software monitoring device reads the memory address of the second function of the LR register, controls the program to be monitored to jump to the second function according to the memory address of the second function, and controls the second function to start operating.
208. And the software monitoring device runs the second function and restores the memory address of the second function to the second memory address.
In the running process of the second function, the software monitoring device restores the memory address of the second function recorded by the LR register to the second memory address, that is, the software monitoring device restores the return memory address in the program to be monitored. For example, the memory address modified to 300 in step 205 is restored to 12, 24, and 44.
209. After the second function is finished running, the software monitoring device jumps to the program to be monitored according to the second memory address.
After the second function is finished, the software monitoring device reads the second memory address recorded in the LR register, and then controls the program to be monitored to return to the instruction indicated by the second memory address according to the second memory address.
210. The software monitoring device determines the measurement data of the function to be monitored according to the use information of the first function and the use information of the second function.
In this embodiment, the software monitoring device records usage information of the first function during operation and usage information of the second function during operation, and since the function to be monitored is located between the first function and the second function, the measurement data of the function to be monitored is obtained according to the usage information of the first function and the second function during operation. In this embodiment, the dimension data may be time, the number of times of accessing the memory, the number of operations, performance monitoring data, and the like. In a possible implementation manner, if the measured data is time, the software monitoring device may record the time when the first function runs and the time when the second function runs, and the running time of the function to be monitored can be obtained by subtracting the two times.
The embodiment shown in fig. 2 is described below with a specific application scenario, as shown in fig. 3, the program to be monitored is a Caller program, the function to be monitored is an Invoked function, the first function is a Start function, and the second function is an End function. The Caller program starts to store the corresponding instruction from memory address 0, the Invoked function has memory addresses of 100 to 112, the Start function has memory addresses of 200 to 212, and the End function has memory addresses of 300 to 312. The specific steps in monitoring the Caller program are as follows:
1. finding a calling point for calling the Invoked function. I.e. the instruction corresponding to the memory address 8 (i.e. BL Invoked) needs to be found. And then modifying the memory address corresponding to the instruction for calling the Invoked function as the memory address of the Start function. That is, the jump to memory address 100 indicated by the instruction (i.e., BL Invoked) corresponding to the memory address 8 is modified to be the jump to memory address 200.
2. When the Caller program runs to the instruction corresponding to the memory address 8, jumping to the Start function according to the memory address 200 indicated by the instruction corresponding to the memory address 8.
3. The Start function is run, and the memory address corresponding to the Invoked function is recorded, that is, the memory address 100 is recorded.
4. The LR register records the returned memory address after the Invoked function is executed. I.e. the memory address 12 is recorded in the LR register.
5. The memory address 12 of the LR register is modified to the memory address 300 of the end function.
6. After the Start function is finished running, jumping to the Invoked function according to the instruction BR Invoked instruction and the recorded memory address 100 of the Invoked function.
7. When the Invoked function runs to the instruction (ret) corresponding to the memory address 112 (i.e., the Invoked function is finished running), it jumps to the End function according to the memory address 300 stored in the LR register.
8. When the End function runs to the instruction (ret) corresponding to the memory address 312 (i.e., the End function runs completely), the call program is returned according to the memory address 12 and the instruction corresponding to the memory address 12 is executed.
In this embodiment, when the program to be monitored runs to the function to be monitored, the program to be monitored jumps to the first function and runs the first function, and then the function to be monitored runs normally after the first function is run; jumping to the second function after the function to be monitored is run; and finally, skipping to the program to be monitored after the second function is operated, and determining the operation condition of the function to be monitored according to the use information of the first function and the second function. Therefore, when the software monitoring device monitors the program to be monitored, the software monitoring device does not need to insert piles in the program to be monitored, and only needs to carry out corresponding jump before and after the function to be monitored is operated, so that the software program does not need to be compiled and operated repeatedly, and the software monitoring efficiency is improved.
2. The software monitoring device inserts an NOP instruction before the function to be monitored and modifies the NOP instruction into a first instruction which jumps to the first function.
As shown in fig. 4, another embodiment of the software monitoring method in the embodiment of the present application includes:
401. the software monitoring device acquires a preset memory address of a first function and a preset memory address of a second function.
In this embodiment, when the software monitoring apparatus monitors a software program, the software monitoring apparatus may create the first function and the second function in a dynamic link library in advance, and store the first function and the second function at a memory address different from a memory address of the software program. For example, the memory addresses of the program to be monitored correspond to 0 to 188, wherein the memory addresses of the instructions of the Invoked function correspond to 100 to 112, the memory addresses of the instructions of the first function correspond to 200 to 212, and the memory addresses of the instructions of the second function correspond to 300 to 312.
402. The software monitoring device inserts an NOP instruction in front of a function to be monitored in a program to be monitored.
When the program to be monitored runs, a plurality of functions to be monitored are possible, and when the software monitoring device monitors the program to be monitored, the compiler is used for recompiling the program to be monitored, so that an instruction for indicating no operation is inserted before the functions to be monitored, and the memory address of the function to be monitored starts from the NOP instruction. For example, the NOP instruction is inserted before the memory address 100 of the Invoked function, and if the memory address of the NOP instruction is 96, the memory address of the Invoked function is 96 to 112. Other Invoked functions are also modified accordingly.
It will be appreciated that the specific way in which the software monitoring device inserts NOP instructions before the function to be monitored may be to insert NOP instructions before all functions of the program to be monitored.
403. The software monitoring device modifies the NOP instruction to a first instruction that instructs a jump to the first function.
The software monitoring device modifies the NOP instruction to indicate an instruction for invoking the first function. For example, if the first function is a START function, the first instruction may be a BL START.
In this embodiment, if the software monitoring apparatus inserts the NOP instruction before all functions of the program to be monitored, after determining the function to be monitored, the NOP instruction inserted before the function to be monitored is modified to indicate a first instruction for calling the first function.
404. When the program to be monitored runs to the function to be monitored, the software monitoring device responds to the first instruction, jumps to the first function and runs the first function.
After the call instruction is modified, the software monitoring device runs the program to be monitored, when the program to be monitored runs to the call instruction of the function to be monitored, the software monitoring device jumps to the NOP instruction, then jumps again according to the instruction modified to be BL START, and jumps to the first function. The software monitoring device controls the first function to start running, and records a first memory address of the function to be monitored and a second memory address of the program to be monitored, which is returned by the function to be monitored, in an LR register. For example, the memory address of the function to be monitored is recorded as 96. Recording a memory address 12 when the Invoked function corresponding to the call instruction corresponding to the memory address 8 returns to the monitor program, a memory address 24 when the Invoked function corresponding to the call instruction corresponding to the memory address 20 returns to the monitor program, and a memory address 44 when the Invoked function corresponding to the call instruction corresponding to the memory address 40 returns to the monitor program.
It can be understood that, when the software monitoring device records the first memory address of the function to be monitored, the software monitoring device may directly record the memory address corresponding to the NOP instruction or may record the memory address after the NOP instruction. For example, the memory address 96 corresponding to the NOP instruction or the memory address 100 corresponding to the Invoked function is recorded.
405. The software monitoring device modifies the second memory address into the memory address of the second function.
The software monitor modifies the second memory address in the LR register to the memory address of the second function. That is, after the function to be monitored is instructed to run, the software monitoring device controls the program to be monitored to jump to the second function according to the memory address of the second function in the LR register. For example, the software monitoring device modifies all 12, 24, and 44 of the LR register to 300.
406. After the first function is completely operated, the software monitoring device jumps to the function to be monitored according to the first memory address.
After the first function finishes running, the software monitoring device reads the first memory address of the LR register, controls the program to be monitored to jump to the function to be monitored according to the first memory address, and controls the function to be monitored to run.
In this embodiment, if the software monitoring device records that the first memory address is the memory address corresponding to the NOP instruction, the software monitoring device needs to offset the memory address corresponding to the NOP instruction by the corresponding byte to obtain a third memory address, and then controls the memory address according to the third memory address
407. And after the function to be monitored is operated, the software monitoring device jumps to the second function according to the memory address of the second function.
After the function to be monitored is completely operated, the software monitoring device reads the memory address of the second function of the LR register, controls the program to be monitored to jump to the second function according to the memory address of the second function, and controls the second function to start operating.
408. And the software monitoring device runs the second function and restores the memory address of the second function to the second memory address.
In the running process of the second function, the software monitoring device restores the memory address of the second function recorded by the LR register to the second memory address, that is, the software monitoring device restores the return memory address in the program to be monitored. For example, the memory address modified to 300 in step 205 is restored to 12, 24, and 44.
409. After the second function is finished running, the software monitoring device jumps to the program to be monitored according to the second memory address.
After the second function is finished running, the software monitoring device reads the second memory address recorded in the LR register, and then controls the program to be monitored to return to the instruction indicated by the second memory address according to the second memory address.
410. The software monitoring device determines the measurement data of the function to be monitored according to the use information of the first function and the use information of the second function.
In this embodiment, the software monitoring device records usage information of the first function during operation and usage information of the second function during operation, and since the function to be monitored is located between the first function and the second function, the measurement data of the function to be monitored is obtained according to the usage information of the first function and the second function during operation. In this embodiment, the dimension data may be time, the number of times of accessing the memory, the number of operations, performance monitoring data, and the like. In a possible implementation manner, if the measured data is time, the software monitoring device may record the time when the first function runs and the time when the second function runs, and the running time of the function to be monitored can be obtained by subtracting the two times.
The embodiment shown in fig. 4 is described below with a specific application scenario, as shown in fig. 5, the program to be monitored is a Caller program, the function to be monitored is an Invoked function, the first function is a Start function, and the second function is an End function. The Caller program starts to store the instruction from the memory address 0, the Invoked function has memory addresses of 100 to 112, the Start function has memory addresses of 200 to 212, and the End function has memory addresses of 300 to 312. The specific steps in monitoring the Caller program are as follows:
1. a NOP instruction is inserted before the Invoked function and modified to be an instruction that calls the Start function. I.e., modify the NOP instruction to BL Start.
2. When the Caller program runs to the instruction corresponding to the memory address 8, the Invoked function is jumped to according to the memory address 96 indicated by the instruction corresponding to the memory address 8.
3. And running the Invoked function, and executing the modified NOP instruction, so as to jump to the Start function again and record the memory address corresponding to the Invoked function, namely record the memory address 96. It is understood that when recording the memory address of the Invoked function, the memory address 100 may also be recorded directly, so that when jumping from the Start function to the Invoked function, a jump may be made directly to the memory address 100.
4. The LR register records the returned memory address after the Invoked function is executed. I.e. the memory address 12 is recorded in the LR register.
5. The memory address 12 of the LR register is modified to the memory address 300 of the end function.
6. After the Start function is finished running, jumping to the address (i.e. the memory address 100 shown in fig. 5) after the offset of 4 bytes from the memory address 96 recorded in step 3 according to the BR Invoked instruction, so as to skip the NOP instruction and run the Invoked function.
7. When the Invoked function runs to the instruction (ret) corresponding to the memory address 112 (i.e., the Invoked function is finished running), it jumps to the End function according to the memory address 300 stored in the LR register.
8. When the End function runs to the instruction (ret) corresponding to the memory address 312 (i.e., the End function runs completely), the call program is returned according to the memory address 12 and the instruction corresponding to the memory address 12 is executed.
In this embodiment, when the program to be monitored runs to the function to be monitored, the program to be monitored jumps to the first function and runs the first function, and then the function to be monitored runs normally after the first function is run; jumping to the second function after the function to be monitored is run; and finally, jumping to the program to be monitored after the second function is operated, and determining the operation condition of the function to be monitored according to the use information of the first function and the second function. Therefore, when the software monitoring device monitors the program to be monitored, the software monitoring device does not need to insert piles in the program to be monitored, and only needs to carry out corresponding jump before and after the function to be monitored is operated, so that the software program does not need to be compiled and operated repeatedly, and the software monitoring efficiency is improved.
Specifically referring to fig. 6, another embodiment of the software monitoring method in the embodiment of the present application includes:
601. and acquiring a preset memory address of the first function and a preset memory address of the second function.
In this embodiment, a specific implementation manner may be the method described in any one of fig. 2 to fig. 5, and details are not described here.
602. And when the program to be monitored is operated to the function to be monitored, jumping to the first function according to the memory address of the first function, wherein the function to be monitored is contained in the program to be monitored.
In this embodiment, a specific implementation manner may be the method described in any one of fig. 2 to fig. 5, which is not described herein again.
603. And executing the first function, and recording a first memory address of the function to be monitored and a second memory address of the program to be monitored.
In this embodiment, a specific implementation manner may be the method described in any one of fig. 2 to fig. 5, and details are not described here.
604. And after the first function is executed, jumping to the function to be monitored according to the first memory address.
In this embodiment, a specific implementation manner may be the method described in any one of fig. 2 to fig. 5, and details are not described here.
605. And after the function to be monitored is executed, jumping to the second function according to the memory address of the second function.
In this embodiment, a specific implementation manner may be the method described in any one of fig. 2 to fig. 5, and details are not described here.
606. And after the second function is executed, jumping to the program to be monitored according to the second memory address.
In this embodiment, a specific implementation manner may be the method described in any one of fig. 2 to fig. 5, which is not described herein again.
607. And determining the dimension measurement data of the function to be monitored according to the use information of the first function and the second function.
In this embodiment, a specific implementation manner may be the method described in any one of fig. 2 to fig. 5, and details are not described here.
The software monitoring method in the embodiment of the present application is described above, and it is understood that, in order to implement the above functions, the software monitoring apparatus includes a hardware structure and/or a software module corresponding to the execution of each function. Those of skill in the art will readily appreciate that the various illustrative modules and algorithm steps described in connection with the embodiments disclosed herein may be implemented as hardware or combinations of hardware and computer software. Whether a function is performed as hardware or computer software drives hardware depends upon the particular application and design constraints imposed on the solution. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present application.
In the embodiment of the present application, the software monitoring apparatus may be divided into the functional modules according to the method example, for example, each functional module may be divided corresponding to each function, or two or more functions may be integrated into one processing module. The integrated module can be realized in a hardware mode, and can also be realized in a software functional module mode. It should be noted that, in the embodiment of the present application, the division of the module is schematic, and is only one logic function division, and there may be another division manner in actual implementation.
As described in detail below with respect to the software monitoring device of the present application, as shown in fig. 7, the software monitoring device includes at least a processor 704, a memory 703, and a transceiver 702, the memory 703 further being used for storing instructions 7031 and data 7032. Optionally, the software monitoring device may further include an antenna 706, an Input/Output (I/O) interface 710, and a bus 712. The transceiver 702 further includes a transmitter 7021 and a receiver 7022. Further, the processor 704, the transceiver 702, the memory 703 and the I/O interface 710 are communicatively coupled to each other via a bus 712, and the antenna 706 is coupled to the transceiver 702.
The processor 704 may be a general-purpose processor, such as, but not limited to, a Central Processing Unit (CPU), or a special-purpose processor, such as, but not limited to, a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field Programmable Gate Array (FPGA), etc. The processor 704 may also be a Neural Processing Unit (NPU). Further, processor 704 may be a combination of multiple processors. In particular, in the technical solution provided in the embodiment of the present application, the processor 704 may be configured to execute relevant steps of a method for generating an ethernet packet in a subsequent method embodiment. The processor 704 may be a processor specially designed for performing the above steps and/or operations, or may be a processor that performs the above steps and/or operations by reading and executing instructions 7031 stored in the memory 703, and the processor 704 may need to use data 7032 in the process of performing the above steps and/or operations.
The transceiver 702 includes a transmitter 7021 and a receiver 7022. In an alternative implementation, the transmitter 7021 is used to transmit signals via the antenna 706. The receiver 7022 is configured to receive signals via at least one of the antennas 706. In particular, in the technical solution provided in this embodiment of the application, the transmitter 7021 may be specifically configured to be executed by at least one antenna in the antennas 706, for example, when the software monitoring method is applied to a software monitoring apparatus in the subsequent method embodiment, the software monitoring apparatus performs an operation performed by a receiving module or a transceiver module in the software monitoring apparatus.
In the present embodiment, the transceiver 702 is used to support the software monitoring device to perform the receiving function and the transmitting function as described above. A processor having processing functionality is considered to be the processor 704. Receiver 7022 may also be referred to as an input port, receive circuitry, etc., and transmitter 7021 may be referred to as a transmitter or transmit circuitry, etc.
The processor 704 is operable to execute the instructions stored in the memory 703 to control the transceiver 702 to receive and/or transmit messages to perform the functions of the software monitoring apparatus in the embodiments of the method of the present application. As an implementation manner, the function of the transceiver 702 can be realized by a transceiver circuit or a dedicated chip for transceiving. In this embodiment, the transceiver 702 receiving a message may be understood as the transceiver 702 inputting a message, and the transceiver 702 sending a message may be understood as the transceiver 702 outputting a message.
The memory 703 may be various types of storage media, such as Random Access Memory (RAM), read Only Memory (ROM), non-volatile RAM (NVRAM), programmable ROM (PROM), erasable PROM (EPROM), electrically Erasable PROM (EEPROM), flash memory, optical memory, and registers. The memory 703 is specifically configured to store instructions 7031 and data 7032, and the processor 704 may execute the steps and/or operations in the method embodiments of the present application by reading and executing the instructions 7031 stored in the memory 703, where the data 7032 may be required in the process of executing the operations and/or steps in the method embodiments of the present application.
Optionally, the software monitoring apparatus may further include an I/O interface 710, where the I/O interface 710 is configured to receive instructions and/or data from a peripheral device and output instructions and/or data to the peripheral device.
Referring to fig. 8, fig. 8 is a schematic diagram of another embodiment of a software monitoring device according to an embodiment of the present application. In this embodiment, the software monitoring apparatus 800 includes: an obtaining module 801, configured to obtain a preset memory address of a first function and a preset memory address of a second function;
an execution module 802, configured to jump to a first function according to a memory address of the first function when a program to be monitored runs to the function to be monitored, where the function to be monitored is included in the program to be monitored; executing the first function, and recording a first memory address of the function to be monitored and a second memory address returned to the program to be monitored; after the first function is executed, skipping to the program to be monitored according to the first memory address; after the function to be monitored is executed, skipping to the second function according to the memory address of the second function; after the second function is executed, skipping to the program to be monitored according to the second memory address;
and the analysis module 803 is configured to determine the measurement data of the function to be monitored according to the usage information of the first function and the second function.
Optionally, the obtaining module 801 is further configured to obtain a memory address of the function to be monitored in the program to be monitored;
the execution module 802 is specifically configured to modify the initial memory address of the function to be monitored to be the memory address of the first function; and jumping to the first function from the function to be monitored according to the memory address of the first function.
Optionally, the execution module 802 is specifically configured to insert an no-operation NOP instruction before the function to be monitored, and modify the NOP instruction into a first instruction for jumping to the first function; and responding to the first instruction, and jumping to the first function according to the memory address of the first function.
Optionally, the execution module 802 is specifically configured to offset the first memory address by the byte occupied by the NOP instruction to obtain a third memory address, and jump to the function to be monitored, where the function to be monitored is indicated by the third memory address.
Optionally, the executing module 802 is specifically configured to modify the memory address of the second function into the second memory address; and skipping to the program to be monitored according to the second memory address.
Optionally, the executing module 802 is specifically configured to modify the memory address of the second function into the second memory address; and skipping to the program to be monitored according to the second memory address.
Optionally, the first memory address and the second memory address are stored in a link register.
Optionally, the first function and the second function are stored in a dynamic link library.
It should be understood that the processes executed between the modules of the software monitoring device in the corresponding embodiment of fig. 8 are similar to the processes executed by the software monitoring device in the corresponding method embodiments of fig. 2 to fig. 6, and detailed descriptions thereof are omitted here.
The software monitoring device in the above embodiments may be a chip applied in the software monitoring device or other combined devices, components, etc. that can implement the functions of the software monitoring device. The transceiver module in the software monitoring device may be a transceiver, and the processing module may be a processor, such as a chip. When the software monitoring apparatus is a chip system, the part of the transceiver module for receiving may be an input port of the chip system, the part of the transceiver module for transmitting may be an output interface of the chip system, and the processing module may be a processor of the chip system, for example: a Central Processing Unit (CPU).
In the embodiment of the present application, the software monitoring apparatus includes a memory mainly used for storing software programs and data, for example, storing the programs described in the above embodiments. The software monitoring device also has the following functions:
the transceiver is used for acquiring a memory address of a preset first function and a memory address of a preset second function;
the processor is used for jumping to the first function according to the memory address of the first function when a program to be monitored runs to the function to be monitored, and the function to be monitored is contained in the program to be monitored; executing the first function, and recording a first memory address of the function to be monitored and a second memory address returned to the program to be monitored; after the first function is executed, skipping to the program to be monitored according to the first memory address; after the function to be monitored is executed, skipping to the second function according to the memory address of the second function; after the second function is executed, skipping to the program to be monitored according to the second memory address; and determining the dimension measurement data of the function to be monitored according to the use information of the first function and the second function.
Optionally, the transceiver is specifically configured to obtain a memory address of the function to be monitored in the program to be monitored; the processor is specifically configured to modify an initial memory address of the function to be monitored to be a memory address of the first function; and jumping to the first function from the function to be monitored according to the memory address of the first function.
Optionally, the processor is specifically configured to insert an no-operation NOP instruction before the function to be monitored, and modify the NOP instruction into a first instruction to jump to the first function; and responding to the first instruction, and jumping to the first function according to the memory address of the first function.
Optionally, the processor is specifically configured to offset the first memory address by the byte occupied by the NOP instruction to obtain a third memory address, and jump to a function to be monitored indicated by the third memory address.
Optionally, the processor is specifically configured to modify a memory address of the second function into the second memory address; and skipping to the program to be monitored according to the second memory address.
Optionally, the processor is specifically configured to modify a memory address of the second function into the second memory address; and skipping to the program to be monitored according to the second memory address.
Optionally, the first memory address and the second memory address are stored in a link register.
Optionally, the first function and the second function are stored in a dynamic link library.
The embodiment of the application also provides a processing device. The processing device comprises a processor and an interface; the processor is used for executing the software monitoring method of any one of the method embodiments.
It should be understood that the processing device may be a chip, the processor may be implemented by hardware or software, and when implemented by hardware, the processor may be a logic circuit, an integrated circuit, or the like; when implemented in software, the processor may be a general-purpose processor implemented by reading software code stored in a memory, which may be integrated with the processor, located external to the processor, or stand-alone.
The term "implemented by hardware" means that the functions of the modules or units are implemented by a hardware processing circuit without a program instruction processing function, and the hardware processing circuit may be composed of discrete hardware components or may be an integrated circuit. In order to reduce power consumption and size, the integrated circuit is usually implemented. The hardware processing circuit may include an application-specific integrated circuit (ASIC), or a Programmable Logic Device (PLD); the PLD may include a Field Programmable Gate Array (FPGA), a Complex Programmable Logic Device (CPLD), and the like. These hardware processing circuits may be a semiconductor chip packaged separately (e.g., as an ASIC); for example, various hardware circuits and CPUs may be formed on a silicon substrate and packaged separately into a chip, which is also referred to as SoC, or circuits and CPUs for implementing FPGA functions may be formed on a silicon substrate and packaged separately into a chip, which is also referred to as system on a programmable chip (SoPC).
A computer-readable storage medium according to an embodiment of the present application includes instructions that, when executed on a computer, cause the computer to control a decision equalization apparatus to perform any one of the implementations shown in the foregoing method embodiments.
The embodiment of the present application further provides a computer program product, which includes computer program code, when the computer program code runs on a computer, the computer is caused to execute any implementation manner shown in the foregoing method embodiment.
The embodiment of the present application further provides a chip system, which includes a memory and a processor, where the memory is used to store a computer program, and the processor is used to call and run the computer program from the memory, so that the chip executes any implementation manner shown in the foregoing method embodiments.
An embodiment of the present application further provides a chip system, which includes a processor, where the processor is configured to call and run a computer program, so that the chip executes any implementation manner shown in the foregoing method embodiment.
The embodiment of the application further provides a software monitoring system, which comprises the software monitoring device and the program to be monitored in the embodiment.
It should be noted that the above-described embodiments of the apparatus are merely schematic, where the units described as separate parts may or may not be physically separate, and the parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of the present embodiment. In addition, in the drawings of the embodiments of the apparatus provided in the present application, the connection relationship between the modules indicates that there is a communication connection therebetween, and may be implemented as one or more communication buses or signal lines.
Through the above description of the embodiments, those skilled in the art will clearly understand that the present application can be implemented by software plus necessary general-purpose hardware, and certainly can also be implemented by special-purpose hardware including special-purpose integrated circuits, special-purpose CPUs, special-purpose memories, special-purpose components and the like. Generally, functions performed by computer programs can be easily implemented by corresponding hardware, and specific hardware structures for implementing the same functions may be various, such as analog circuits, digital circuits, or dedicated circuits. However, for the present application, the implementation of a software program is more preferable. Based on such understanding, the technical solutions of the present application may be substantially embodied in the form of a software product, which is stored in a readable storage medium, such as a floppy disk, a usb disk, a removable hard disk, a ROM, a RAM, a magnetic disk, or an optical disk of a computer, and includes several instructions for causing a computer device to execute the method according to the embodiments of the present application.
In the above embodiments, the implementation may be wholly or partially realized by software, hardware, firmware, or any combination thereof. When implemented in software, may be implemented in whole or in part in the form of a computer program product.
The computer program product includes one or more computer instructions. When loaded and executed on a computer, cause the processes or functions described in accordance with the embodiments of the application to occur, in whole or in part. The computer may be a general purpose computer, a special purpose computer, a network of computers, or other programmable device. The computer instructions may be stored in a computer readable storage medium or transmitted from one computer readable storage medium to another, for example, the computer instructions may be transmitted from one website, computer, first or second network device, computing device, or data center to another website, computer, first or second network device, computing device, or data center by wired (e.g., coaxial cable, fiber optic, digital Subscriber Line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) means. The computer readable storage medium can be any available medium that a computer can store or a data storage device, such as a data center, that includes one or more available media integrated first or second network devices. The usable medium may be a magnetic medium (e.g., floppy Disk, hard Disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium (e.g., solid State Disk (SSD)), among others.
It should be appreciated that reference throughout this specification to "one embodiment" or "an embodiment" means that a particular feature, structure or characteristic described in connection with the embodiment is included in at least one embodiment of the present application. Thus, the appearances of the phrases "in one embodiment" or "in an embodiment" in various places throughout this specification are not necessarily all referring to the same embodiment. Furthermore, the particular features, structures, or characteristics may be combined in any suitable manner in one or more embodiments. It should be understood that, in the various embodiments of the present application, the sequence numbers of the above-mentioned processes do not mean the execution sequence, and the execution sequence of each process should be determined by its function and inherent logic, and should not constitute any limitation to the implementation process of the embodiments of the present application.
Additionally, the terms "system" and "network" are often used interchangeably herein. It should be understood that in the embodiment of the present application, "B corresponding to a" means that B is associated with a, from which B can be determined. It should also be understood that determining B from a does not mean determining B from a alone, but may be determined from a and/or other information.
Those of ordinary skill in the art will appreciate that the elements and algorithm steps of the examples described in connection with the embodiments disclosed herein may be embodied in electronic hardware, computer software, or combinations of both, and that the components and steps of the examples have been described in a functional general in the foregoing description for the purpose of illustrating clearly the interchangeability of hardware and software. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the technical solution. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present application.
It is clear to those skilled in the art that, for convenience and brevity of description, the specific working processes of the above-described systems, apparatuses and units may refer to the corresponding processes in the foregoing method embodiments, and are not described herein again.
In the several embodiments provided in the present application, it should be understood that the disclosed system, apparatus and method may be implemented in other manners. For example, the above-described apparatus embodiments are merely illustrative, and for example, a division of a unit is merely a logical division, and an actual implementation may have another division, for example, a plurality of units or components may be combined or integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection through some interfaces, devices or units, and may be in an electrical, mechanical or other form.
The units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one position, or may be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
In addition, functional units in the embodiments of the present application may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit. The integrated unit can be realized in a form of hardware, and can also be realized in a form of a software functional unit.
The integrated unit, if implemented in the form of a software functional unit and sold or used as a separate product, may be stored in a computer readable storage medium. Based on such understanding, the technical solution of the present application may be substantially implemented or contributed to by the prior art, or all or part of the technical solution may be embodied in a software product, which is stored in a storage medium and includes instructions for causing a computer device (which may be a personal computer, a server, or a network device) to execute all or part of the steps of the method of the embodiments of the present application.
In short, the above description is only a preferred embodiment of the present disclosure, and is not intended to limit the scope of the present disclosure. Any modification, equivalent replacement, improvement and the like made within the principle of the present application shall be included in the protection scope of the present application.

Claims (18)

1. A method of monitoring software, comprising:
acquiring a preset memory address of a first function and a preset memory address of a second function;
when a program to be monitored is operated to a function to be monitored, skipping to the first function according to the memory address of the first function, wherein the function to be monitored is included in the program to be monitored;
executing the first function, and recording a first memory address of the function to be monitored and a second memory address returned to the program to be monitored;
after the first function is executed, skipping to the function to be monitored according to the first memory address;
after the function to be monitored is executed, skipping to the second function according to the memory address of the second function;
after the second function is executed, skipping to the program to be monitored according to the second memory address;
and determining the dimension measurement data of the function to be monitored according to the use information of the first function and the second function.
2. The method of claim 1, wherein jumping to the first function according to the memory address of the first function comprises:
acquiring a memory address of the function to be monitored in the program to be monitored;
modifying the initial memory address of the function to be monitored as the memory address of the first function;
and jumping to the first function from the function to be monitored according to the memory address of the first function.
3. The method of claim 1, wherein said jumping to the first function according to the memory address of the first function comprises:
inserting a no-operation NOP instruction in front of the function to be monitored, and modifying the NOP instruction into a first instruction for jumping to the first function;
and responding to the first instruction, and jumping to the first function according to the memory address of the first function.
4. The method as claimed in claim 3, wherein said jumping to the function to be monitored according to the first memory address comprises:
and offsetting the first memory address by the byte occupied by the NOP instruction to obtain a third memory address, and jumping to a function to be monitored indicated by the third memory address.
5. The method of any of claims 1 to 4, wherein said jumping to the second function according to the memory address of the second function comprises:
modifying the second memory address to be the memory address of the second function;
and jumping to the second function according to the memory address of the second function.
6. The method as claimed in claim 5, wherein said jumping to the program to be monitored according to the second memory address comprises:
modifying the memory address of the second function into the second memory address;
and skipping to the program to be monitored according to the second memory address.
7. The method of any of claims 1 to 6, wherein the first memory address and the second memory address are stored in a link register.
8. The method of any one of claims 1 to 7, wherein the first function and the second function are stored in a dynamically linked library.
9. A software monitoring device, comprising:
the acquisition module is used for acquiring a preset memory address of a first function and a preset memory address of a second function;
the execution module is used for jumping to the first function according to the memory address of the first function when the program to be monitored runs to the function to be monitored, and the function to be monitored is contained in the program to be monitored; executing the first function, and recording a first memory address of the function to be monitored and a second memory address returned to the program to be monitored; after the first function is executed, skipping to the program to be monitored according to the first memory address; after the function to be monitored is executed, skipping to the second function according to the memory address of the second function; after the second function is executed, skipping to the program to be monitored according to the second memory address;
and the analysis module is used for determining the dimension measurement data of the function to be monitored according to the use information of the first function and the second function.
10. The apparatus according to claim 9, wherein the obtaining module is further configured to obtain a memory address of the function to be monitored in the program to be monitored;
the execution module is specifically configured to modify the initial memory address of the function to be monitored to be the memory address of the first function; and jumping to the first function from the function to be monitored according to the memory address of the first function.
11. The apparatus of claim 9, wherein the execution module is specifically configured to insert a no-operation NOP instruction before the function to be monitored, and modify the NOP instruction into a first instruction to jump to the first function; and responding to the first instruction, and jumping to the first function according to the memory address of the first function.
12. The apparatus of claim 11, wherein the execution module is specifically configured to offset the first memory address by a byte occupied by the NOP instruction to obtain a third memory address, and jump to a function to be monitored indicated by the third memory address.
13. The apparatus according to any one of claims 9 to 12, wherein the execution module is specifically configured to modify the memory address of the second function to the second memory address; and skipping to the program to be monitored according to the second memory address.
14. The apparatus according to claim 13, wherein the execution module is specifically configured to modify the memory address of the second function to the second memory address; and skipping to the program to be monitored according to the second memory address.
15. A software monitoring device comprising a processor and a memory, the processor coupled to the memory,
the memory is used for storing programs;
the processor to execute a program in the memory to cause the software monitoring device to perform the method of any one of claims 1 to 8.
16. A computer program for causing a computer to perform the method of any one of claims 1 to 8 when the computer program runs on the computer.
17. A computer-readable storage medium, characterized by comprising a program which, when run on a computer, causes the computer to perform the method of any one of claims 1 to 8.
18. A chip system, comprising one or more processors and a memory, the memory having stored therein program instructions that, when executed in the one or more processors, cause the method of any of claims 1-8 to be performed.
CN202111071051.XA 2021-09-13 2021-09-13 Software monitoring method and related device Pending CN115809172A (en)

Priority Applications (2)

Application Number Priority Date Filing Date Title
CN202111071051.XA CN115809172A (en) 2021-09-13 2021-09-13 Software monitoring method and related device
PCT/CN2022/117011 WO2023036076A1 (en) 2021-09-13 2022-09-05 Software monitoring method and related apparatus

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202111071051.XA CN115809172A (en) 2021-09-13 2021-09-13 Software monitoring method and related device

Publications (1)

Publication Number Publication Date
CN115809172A true CN115809172A (en) 2023-03-17

Family

ID=85481271

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202111071051.XA Pending CN115809172A (en) 2021-09-13 2021-09-13 Software monitoring method and related device

Country Status (2)

Country Link
CN (1) CN115809172A (en)
WO (1) WO2023036076A1 (en)

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101477491B (en) * 2009-01-16 2011-06-08 杭州华三通信技术有限公司 Method and apparatus for function running state statistics
CN107038108B (en) * 2015-08-20 2020-11-03 腾讯科技(深圳)有限公司 Software testing method and device
WO2019071535A1 (en) * 2017-10-12 2019-04-18 深圳市汇顶科技股份有限公司 Computer storage medium, and program running monitoring method and device
CN110580219A (en) * 2019-07-16 2019-12-17 许昌许继软件技术有限公司 Embedded device function performance online test method and device and storage medium

Also Published As

Publication number Publication date
WO2023036076A1 (en) 2023-03-16

Similar Documents

Publication Publication Date Title
US7886198B2 (en) Method and system of identifying overlays used by a program
KR20010006188A (en) Trace cache for a microprocessor-based device
US7930165B2 (en) Procedure and device for emulating a programmable unit providing system integrity control
US20160378636A1 (en) Software-Initiated Trace Integrated with Hardware Trace
CN112597064B (en) Method for simulating program, electronic device and storage medium
EP3274839B1 (en) Technologies for root cause identification of use-after-free memory corruption bugs
WO2012171171A1 (en) Method, device and system for monitoring software
US9639451B2 (en) Debugger system, method and computer program product for utilizing hardware breakpoints for debugging instructions
CN111800490A (en) Method and device for acquiring network behavior data and terminal equipment
CN111989655B (en) SOC chip, method for determining hotspot function and terminal equipment
EP2735970B1 (en) Dynamic library profiling method
CN113127314B (en) Method and device for detecting program performance bottleneck and computer equipment
US11520682B2 (en) Code coverage method for embedded system on chip
US11422916B2 (en) Usage amount monitoring method and monitoring unit of electronic control unit for vehicle
CN115809172A (en) Software monitoring method and related device
CN111666102A (en) File format conversion method, chip verification method, related device and network chip
US11836084B2 (en) Embedding data in address streams
CN110597707A (en) Memory out-of-range fault detection method and terminal equipment
US20070094001A1 (en) Method and system for non-intrusive code coverage
CN109885402B (en) Method for testing function output data overflow, terminal equipment and storage medium
CN114116291B (en) Log detection method, log detection device, computer device and storage medium
US8027829B2 (en) System and method for integrated circuit emulation
CN118051907A (en) Vulnerability detection method and device, electronic equipment and storage medium
CN111966514A (en) Exception handling method, exception handling system, electronic equipment and storage medium
CN117917646A (en) Process management and control method and device, electronic equipment and storage 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