WO2019071535A1 - Computer storage medium, and program running monitoring method and device - Google Patents

Computer storage medium, and program running monitoring method and device Download PDF

Info

Publication number
WO2019071535A1
WO2019071535A1 PCT/CN2017/105899 CN2017105899W WO2019071535A1 WO 2019071535 A1 WO2019071535 A1 WO 2019071535A1 CN 2017105899 W CN2017105899 W CN 2017105899W WO 2019071535 A1 WO2019071535 A1 WO 2019071535A1
Authority
WO
WIPO (PCT)
Prior art keywords
monitored
function
running
statistical code
storage address
Prior art date
Application number
PCT/CN2017/105899
Other languages
French (fr)
Chinese (zh)
Inventor
曹岚健
刘金涛
Original Assignee
深圳市汇顶科技股份有限公司
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 深圳市汇顶科技股份有限公司 filed Critical 深圳市汇顶科技股份有限公司
Priority to PCT/CN2017/105899 priority Critical patent/WO2019071535A1/en
Priority to CN201780001861.3A priority patent/CN109923526A/en
Publication of WO2019071535A1 publication Critical patent/WO2019071535A1/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/30Monitoring
    • G06F11/34Recording or statistical evaluation of computer activity, e.g. of down time, of input/output operation ; Recording or statistical evaluation of user activity, e.g. usability assessment

Definitions

  • the present invention relates to the field of computer software, and in particular, to a computer storage medium, a program running monitoring method and device.
  • a program is a sequence of coded instructions that can be executed by a device having information processing capabilities, such as a computer, in order to obtain a certain result, or a sequence of symbolized instructions or symbolic statements that can be automatically converted into a sequence of coded instructions.
  • a program may contain one or more source files. Further, each source file may also contain one or more functions.
  • it is usually necessary to track and monitor the running data of some functions in the program, for example, counting certain functions. Number of runs, run time, etc.
  • MCUs Microcontroller Units
  • Some Microcontroller Units need to provide hardware support, for example, provide a tracking port for program tracking alone to provide program tracking function, and an external dedicated program tracking device.
  • the program running process of the MCU is monitored in real time through the port, and the running data of the to-be-monitored function is tracked during the monitoring process.
  • the program tracking of the function to be monitored provided with the hardware port can be realized by the above prior art, but the program monitoring cannot be performed for the product without the hardware port support, and providing the corresponding hardware port for the product to be monitored may result in the product.
  • the cost is increased, and the above-described prior art operation process is also cumbersome.
  • the invention provides a computer storage medium, a program operation monitoring method and a device, which are used for solving the technical problem that the existing program monitoring and prevention relies on hardware support and the process is cumbersome.
  • a first aspect of the present invention is to provide a program operation monitoring method comprising: inserting a statistical code in a function to be monitored, wherein the statistical code is configured to store its operational data to a corresponding one when it is itself a storage address; the function to be monitored after the insertion of the statistical code, wherein the operation data of the function to be monitored is the operation data stored in a storage address corresponding to the statistical code.
  • a second aspect of the present invention is to provide a program operation monitoring apparatus, comprising: a compiling module for inserting a statistical code in a function to be monitored, wherein the statistical code is used to run a statistical code when it is itself The data is stored to the corresponding storage address; the execution module is configured to run the to-be-monitored function after inserting the statistical code, wherein the running data of the function to be monitored is a running stored in a storage address corresponding to the statistical code data.
  • a third aspect of the present invention is to provide a program operation monitoring apparatus including: at least one processor and a memory; the memory storage computer executing an instruction; the at least one processor executing the memory execution computer execution instruction to Perform the method as described above.
  • a fourth aspect of the present invention is to provide a computer storage medium having program instructions stored therein, the program instructions being executed by a processor to implement the method as described above.
  • the computer storage medium and the program operation monitoring method and device provided by the invention after inserting the statistical code in the function to be monitored, run the function to be monitored inserted with the statistical code, wherein when the statistical code is executed, the running of the data can be performed in real time. Data and store the run data to the corresponding storage address. Since the statistical code is set in the function to be monitored, the running data of the statistical code can accurately and truly reflect the running data of the function to be monitored.
  • the program needs to be monitored by the monitoring function, it only needs to run the function to be monitored inserted with the statistical code, without providing a special tracking device and no hardware support, the operation is simple, the result is accurate, and the cost is low.
  • FIGS. 1A-1C are schematic flowcharts of a method for monitoring program running according to Embodiment 1 of the present invention.
  • 1D is a diagram showing an example of code of a statistical code in an embodiment of the present invention.
  • FIGS. 2A-2C are schematic flowcharts of a program operation monitoring method according to Embodiment 2 of the present invention.
  • FIG. 3A is a schematic flowchart of a method for monitoring program running according to Embodiment 3 of the present invention.
  • FIG. 3B is a comparison diagram of the initial part of the function to be statistically and the function to be non-statistic
  • 3C is a comparison diagram of the end portion of the function to be statistically and the function to be non-statistic
  • 3D is a code example diagram of a function to be monitored inserted with a first statistical code and a second statistical code;
  • 3E is a schematic flowchart of another method for monitoring program running according to Embodiment 3 of the present invention.
  • FIGS. 4A-4D are schematic structural diagrams of a program operation monitoring apparatus according to Embodiment 4 of the present invention.
  • 5A-5C are schematic structural diagrams of a program operation monitoring apparatus according to Embodiment 5 of the present invention.
  • FIGS. 6A-6B are schematic diagrams showing the structure of a program operation monitoring apparatus according to Embodiment 6 of the present invention.
  • FIG. 1A is a schematic flowchart of a method for monitoring a program operation according to a first embodiment of the present invention.
  • the embodiment provides a program operation monitoring method, which is convenient, accurate, and low-cost.
  • the program tracking of the function to be monitored is implemented.
  • the monitoring method of the program operation includes:
  • the execution body of the program running monitoring method may be a program running monitoring device.
  • the program running monitoring device may be a medium storing related execution code, for example, a USB flash drive, etc.; or the program running monitoring device may also be a physical device integrated or installed with related execution code, for example, a chip, Intelligent terminals, computers, etc.
  • the function to be monitored can be a function in a source file under a certain program.
  • the statistical code in the solution can be pre-written by the program personnel.
  • the statistical code is run, a series of processes are executed correspondingly, and the running data of the statistical code itself can be stored to correspond to the statistical code based on the executed process. Stored in the address.
  • the position where the statistical code is inserted can be any position in the function as long as it does not affect the operation of the function itself.
  • the running data of the inserted statistical code can reflect the running data of the function it is in.
  • the operational data includes, but is not limited to, the number of operations, and the like.
  • each statistical code inserted in the function to be monitored corresponds to a storage address, which may be pre-specified by the programmer, or may be performed during the first run of the statistical code. Automatically specified in . After the storage address of a certain statistical code is specified, the statistical code can update the data stored in the corresponding storage address according to the current statistical data during the running process. For example, in the actual scenario, when it is necessary to perform program monitoring on a program, it may first determine which functions under the program need to run statistics on the running data, and correspondingly, insert statistical codes into these functions. Specifically, the process of inserting a statistical code in a function can be implemented by compiling the program in which the function is located.
  • FIG. 1B is a schematic flowchart of another method for monitoring program running according to Embodiment 1 of the present invention.
  • 101 may specifically include:
  • the unit for performing the statistical code insertion processing is a single source file.
  • set the trace compilation option for the source file where the function to be monitored is located. For example, suppose a certain program A includes source files A1, A2, and A3, wherein the source file A1 includes functions A11, A12, and A13, the source file A2 includes functions A21, A22, and A23, and the source file A3 includes functions A31 and A32. A33, currently need to run the statistics of the function A11 and A23, you can set the trace compile options for the source files A1 and A2, respectively.
  • the tracking compilation option is set in various manners, for example, the tracking compilation option. It can be explicit, for example, adding a checkbox " ⁇ " corresponding to the trace compile option under the compile options for each source file.
  • the trace compile option of the source file is set. The user selects the trace compile option to be implemented by clicking and other operations. Alternatively, you can directly add the identifier corresponding to the trace compile option to the source file to be monitored.
  • the source file to which the identifier is added is the source file with the trace compile option set.
  • each source file is set with a trace compile option
  • the setting state of the trace compile option is passed to the module for compiling the program to determine the function that needs to insert the statistical code when compiling the program.
  • the user can select the trace compilation option for the source file where the function to be traced is located to determine the range of functions that need to be counted.
  • all functions under the source file corresponding to the tracking compilation option are set as functions to be monitored, and then the running data of the functions to be monitored are counted.
  • the source file A1 includes functions A11, A12, A13
  • the source file A2 includes functions A21, A22, A23
  • the source file A3 includes functions A31, A32, A33, and current statistical functions A12 and A22 are required.
  • the running data can set the tracking compile option for the source file A1 and the source file A2.
  • the functions A11, A12, A13, A21, A22 and A23 are the functions to be monitored.
  • the entire program is compiled. Specifically, in the process of compiling the program, a statistical code is inserted into all the functions of the source file for the source file provided with the tracking compile option.
  • the function range of the running data statistics is determined by setting the tracking compile option, and the statistical code is inserted in the function that sets the tracking compiling option when the program is compiled, so that the function that needs to insert the statistical code is quickly and conveniently determined, and the processing is improved. s efficiency.
  • the operation function of the to-be-monitored function is the operation data stored in the storage address corresponding to the statistical code.
  • the function to be monitored can be run by running the program where the function to be monitored is located.
  • the function to be monitored can be run, and the running data of the function to be monitored is the running data of the statistical code.
  • the program running monitoring method may further include: acquiring a storage address corresponding to the statistical code inserted in the function to be monitored; and outputting the running data stored in the storage address as the running data of the function to be monitored.
  • FIG. 1C is a schematic flowchart of still another program running monitoring method according to Embodiment 1 of the present invention.
  • the running data includes a running number; correspondingly, 102 specifically may include:
  • the running operation is calculated into the running times. Specifically, the result of adding the running number stored in the storage address is calculated, and the storage address is The data is updated to the calculation result, that is, the effect of adding 1 to the running times stored in the storage address is realized, thereby conveniently counting and updating the running times.
  • the data in the storage address can be initialized, and the data in the storage address can be initialized to 0.
  • FIG. 1D is a diagram showing an example of code of a statistical code in an embodiment of the present invention.
  • the data t1 in the register is written back to the address 0x914 (the value stored in the address of 0x914 is updated to 3).
  • the program code in the figure is merely an exemplary implementation manner, and the specific implementation manner of the statistical code is not limited.
  • the statistics and storage of the running data can be automatically completed in the process of running the function, and no need to add any hardware, and the running data can be counted simply by running the program.
  • the solution of this embodiment is applicable to the field of embedded software, and is particularly applicable to the field of embedded software of a low-cost MCU.
  • it can be applied to any target machine and can count the program running data running on any target machine.
  • this solution realizes low-cost program running tracking method without the need to provide any tracking unit by the CPU, without any hardware support, can count the function running track in the program, and can customize the statistical range.
  • the statistical running data can be obtained in real time when the program is running, and the statistical running data can be obtained when the program runs paused, thereby improving the reliability of the program monitoring.
  • the program running monitoring method provided in this embodiment, after inserting the statistical code in the function to be monitored, running the function to be monitored inserted with the statistical code, wherein when the statistical code is executed, the running data of the self can be counted in real time, and the Run the data store to the corresponding storage address. Since the statistical code is set in the function to be monitored, the running data of the statistical code can accurately and truly reflect the running data of the function to be monitored.
  • the solution provided by this embodiment can be implemented by simply running a function to be monitored inserted with a statistical code when the program needs to be monitored. There is no need to provide a special tracking device and no hardware support, and the operation is simple, the result is accurate, and the cost is low. .
  • FIG. 2A is a schematic flowchart of a program operation monitoring method according to Embodiment 2 of the present invention.
  • the program running monitoring method further includes:
  • the storage address specified for the statistical code is used to store the operational data of the statistical code. It should be noted that the figure is only an exemplary implementation manner, and the order of execution of each step is not limited. For example, 201 may also be executed in the process of inserting the statistical code in 101.
  • FIG. 2B is a schematic flowchart of another method for monitoring program running according to Embodiment 2 of the present invention.
  • 201 may specifically include:
  • a preset offset in the code segment of the program where the function to be monitored is located, a corresponding storage address is specified for the statistical code, and the storage address is offset to an entry address of the function to be monitored.
  • the amount is the preset offset.
  • the storage address corresponding to the statistical code can be specified from the code segment of the program.
  • the code segment usually refers to a memory area used to store the program execution code.
  • the address in the code segment can be characterized and determined by defining the start address and the offset from the start address, so in order to save storage space, it can be pre- Set a uniform starting address to determine the storage address of the statistical code in each function by setting a uniform offset.
  • the entry address of the function can be used as the start address, and after the uniform offset is set, the statistical code in each function
  • the offset between the corresponding storage address and the entry address of the function is fixed, so that when the program is compiled, for the function to be monitored, the statistical code needs to be inserted in the function to be monitored, and the statistical code can be inserted at the same time.
  • Automatically addressing the entry address of the function to be monitored the address obtained by offsetting the entry address by a fixed offset, that is, the storage address corresponding to the statistical code inserted in the function to be monitored.
  • the starting address is defined as the entry address of the function, and the offset is set to 2
  • the function of the function that currently inserts the statistical code is automatically addressed, for example, the function is found.
  • the entry address is 0x904, and correspondingly, according to the preset offset, the storage address corresponding to the statistical code inserted in the function is 0x906.
  • the storage address corresponding to each inserted statistical code can be determined during the offset process.
  • the number of statistical codes inserted in each function to be monitored is multiple, different offsets may be set for the multiple statistical codes. For example, suppose that two statistical codes B11 and B12 are inserted in function A11, and two statistical codes B21 and B22 are inserted in function A12, then the starting address can be defined as the entry address of the function, which is inserted into each function.
  • the offset set by the first statistic code is 3, and the offset set for the second statistic code inserted into each function is 4, then for function A11, assuming its entry address is 0x804, then
  • the storage addresses corresponding to the statistical codes B11 and B12 are 0x807 and 0x808, respectively; for the function A12, assuming that the entry address is 0x904, the storage addresses corresponding to the statistical codes B21 and B22 are 0x907 and 0x908, respectively.
  • the storage address corresponding to the statistical code is set in the code segment of the program, and the storage address corresponding to each statistical code is determined by uniformly defining the starting address and the offset. According to the above embodiment, only one storage is needed.
  • the starting address and an offset can determine the storage address corresponding to each statistical code according to certain rules, thereby reducing data processing requirements and storage requirements.
  • FIG. 2C is a schematic flowchart of still another program running monitoring method according to Embodiment 2 of the present invention.
  • 201 may specifically include:
  • the storage address corresponding to the statistical code may also be specified from the data segment of the program.
  • the data segment usually refers to a memory area used to store the initialized global variables in the program. Setting the storage address in the data segment can improve the flexibility of the storage address setting.
  • the storage address corresponding to the statistical code is specified in the data segment, the memory space corresponding to the mapping relationship between the statistical code in each function to be monitored and the storage address corresponding to the statistical code needs to be planned, and the specific implementation is implemented.
  • a relationship table is maintained, the correspondence between the statistical code and the storage address in different functions to be monitored can be recorded, so that when the statistical code is inserted into the function to be monitored during the compilation process of the program, the maintenance can be performed according to the maintenance.
  • the mapping relationship finds the corresponding storage address.
  • the corresponding statistical storage address is specified in the data segment of the program for the statistical code C11 inserted in the function A11 and the statistical code C12 inserted in the A21, assuming 0x501 and 0x502, respectively. . Then, the correspondence between C11 and 0x501 in A11 and the correspondence between C12 and 0x502 in A21 are stored.
  • the storage address corresponding to any statistical code can be determined according to the mapping relationship.
  • the storage address corresponding to the statistical code is set in the data segment of the program, and the storage address corresponding to each statistical code is determined by maintaining the corresponding relationship between the statistical code inserted in each function and the storage address, based on In the above embodiment, the flexibility of address designation can be improved.
  • the program running monitoring method provided in this embodiment provides a plurality of implementation manners for specifying a storage address for a statistical code. Each implementation manner may be implemented separately or in combination. In actual applications, different designation manners may be determined according to different situations. Specify the corresponding storage address for the statistics code.
  • the number of statistical codes inserted therein may be one or more.
  • each statistical code corresponds to a storage address.
  • other data for example, the running time of the function to be monitored, may be further analyzed.
  • FIG. 3A is a schematic flowchart of a program running monitoring method according to Embodiment 3 of the present invention. As shown in FIG. 3A, based on any of the foregoing embodiments, 101 may specifically include:
  • the first statistical code inserted before the first instruction of the function to be monitored generates the running data and is saved in the storage address corresponding to the first statistical code.
  • the running data can be queried in real time while the program is running, and output to the user.
  • the program is suspended, the running data stored in the storage address can also be queried and output to the user.
  • the jump instruction may be added at the end of the first statistical code, that is, after the first statistical code is run, the first instruction of the main body of the function to be monitored is jumped to ensure the normal operation of the function to be monitored, and the program is improved. Reliability and stability of monitoring.
  • FIG. 3B is a comparison diagram of the initial part of the function to be statistically and the non-statistical function.
  • the function to be monitored is inserted into the function to be monitored, and the non-waiting function is a non-to-be-monitored function in which the statistical code is not inserted.
  • the first statistical code in the example is inserted before the first instruction of the function to be monitored, that is, “acquiring the statistical data address” to “jump to the first instruction of the function”, and the inserted first statistical code corresponds to
  • the storage address is located between the statistical code and the first instruction of the function to be monitored, that is, "the statistical data of this function prologue".
  • the second statistical code inserted before the last instruction of the function to be monitored also generates the running data and stores it in the storage address corresponding to the second statistical code.
  • the running data can be queried in real time while the program is running, and output to the user.
  • the running data stored in the storage address can also be queried and output to the user.
  • FIG. 3C is a comparison diagram of the end portion of the function to be statistically and the non-to-be-statistic function, wherein the function to be monitored is the function to be monitored inserted with the second statistical code, and the function to be monitored is not Insert a non-to-monitor function for the statistics code.
  • the second statistic code in the example Before inserting the last instruction of the function to be monitored, that is, “acquiring the statistical data address” to “modifying the statistical data writing back”, in combination with FIG. 3B, the storage address corresponding to the second statistical code is also located in the first statistical code and the function to be monitored. Between the first instructions, that is, "the statistics of this function epilogue" in Figure 3B.
  • FIG. 3D is a code example diagram of a function to be monitored inserted with a first statistical code and a second statistical code. Referring to the drawing, before executing the function body code instruction of the function to be monitored, the first execution is performed.
  • a statistical code namely "li t0, 0x914" to "jal 0x91C"; before the end of running the function to be monitored, the second statistical code, "li t0, 0x914" to "sw t1, (t0)", is executed. Therefore, the running data generated by the first statistical code and the second statistical code can accurately reflect the running times of the function to be monitored. And further, based on the running time of the first statistical code and the second statistical code, that is, the time when the data stored in the corresponding storage address changes, more abundant statistical data can be analyzed, for example, the running time of the function to be monitored .
  • FIG. 3E is a schematic flowchart of another method for monitoring program running according to Embodiment 3 of the present invention.
  • the method for monitoring the running of the program may further include:
  • an observation point may be set at a storage address corresponding to the first statistical code and the second statistical code, and used to record the changed time when the data stored in the address changes. Specifically, when the data in the storage address corresponding to the first statistical code changes, that is, when the first statistical code is running, Recording the current first moment, the first moment can reflect the initial running time of the function to be monitored where the first statistical code is located.
  • the current second time is recorded, and the second time can reflect the ending running time of the to-be-monitored function where the second statistical code is located.
  • the running time of the function to be monitored can be obtained according to the initial running time and the ending running time of the function to be monitored.
  • the program running monitoring method inserts a statistical code at the beginning and the end of the function to be monitored, records the time when the statistical code is running, and obtains the running time of the function to be monitored according to the time difference between the two times, and realizes the data.
  • the statistics are further expanded to enrich the data content.
  • the running code of the statistical code and the program to be monitored in the above embodiment are implemented by setting the insertion position of the statistical code.
  • the position of the statistical code may be flexibly set, and the execution order of the statistical code relative to the function to be monitored is determined by adding a jump instruction to the function.
  • the statistical code can be inserted at an address after the program to be monitored, and a jump instruction is inserted into the program to be monitored, and the jump instruction is used to indicate the address corresponding to the jump execution statistical code, so that the statistical code can also be implemented.
  • the operational data is consistent with the operational data of the function to be monitored. Therefore, the specific implementation is not limited to the specific implementation manner in the foregoing embodiments.
  • the program running monitoring method provided by the present application, after inserting the statistical code in the function to be monitored, runs the function to be monitored inserted with the statistical code, wherein when the statistical code is executed, the running data of the self can be counted in real time, and the running is performed. The data is stored to the corresponding storage address. Since the statistical code is set in the function to be monitored, the running data of the statistical code can accurately and truly reflect the running data of the function to be monitored.
  • the solution provided by this embodiment can be implemented by simply running a function to be monitored inserted with a statistical code when the program needs to be monitored. There is no need to provide a special tracking device and no hardware support, and the operation is simple, the result is accurate, and the cost is low. .
  • FIG. 4A is a schematic structural diagram of a program operation monitoring apparatus according to Embodiment 4 of the present invention; as can be seen from FIG. 4A, the program operation monitoring apparatus is used to conveniently and accurately implement program tracking of a function to be monitored.
  • the program operation monitoring device includes:
  • a compiling module 41 configured to insert a statistical code in the function to be monitored, wherein the statistical code is used to store its running data to a corresponding storage address when it is run by itself;
  • the execution module 42 is configured to run the to-be-monitored function after inserting the statistical code, where the running data of the function to be monitored is the running data stored in the storage address corresponding to the statistical code.
  • the program running monitoring device may be a medium storing an associated execution code, such as a USB flash drive, etc.; or the program running monitoring device may also be a physical device integrated or installed with related execution code, for example, a chip. , smart terminals, computers, etc.
  • the specific implementation form and structure of each module are not limited in this embodiment, and those skilled in the art can arbitrarily set them according to the functions they implement.
  • the compiling module 41 inserts statistical codes into the functions, and executes the module. 42 Run the function to be monitored after inserting the statistical code. It can be understood that the statistical code inserted in the function will also be run while running each function, so the running data of the statistical code can accurately reflect the running data of the function.
  • the program running monitoring apparatus may further include: an obtaining module 43, configured to acquire a storage address corresponding to the statistical code inserted in the function to be monitored; and the first output module 44.
  • the operating data stored in the storage address is used as the running data of the function to be monitored.
  • the compiling module 41 may specifically include:
  • the interaction unit 411 sets a tracking compile option for the source files to be monitored in the program
  • the processing unit 412 is configured to use all the functions in the source file set with the tracking compile option The function to be monitored;
  • the processing unit 412 is further configured to insert a statistical code in each of the to-be-monitored functions by compiling the program.
  • the interaction unit 411 sets a tracking compilation option for the source file where the function to be monitored is located, and the setting manner is various.
  • the processing unit 412 sets all the functions under the source file corresponding to the tracking compile option as functions to be monitored, and compiles the entire program. Specifically, in the process of compiling the program, the processing unit 412 inserts a statistical code into all the functions of the source file for the source file provided with the tracking compile option.
  • the function range of the running data statistics is determined by setting the tracking compile option, and the statistical code is inserted in the function that sets the tracking compiling option when the program is compiled, so that the function that needs to insert the statistical code is quickly and conveniently determined, and the processing is improved. s efficiency.
  • the running data includes a running number; and correspondingly, the executing module 42 includes:
  • the reading unit 421 is configured to acquire the currently stored running times in the storage address corresponding to the statistical code
  • the calculating unit 422 is configured to add 1 to the currently stored running times to obtain a calculation result
  • the updating unit 423 is configured to update the currently stored running times in the storage address to the calculation result
  • the processing unit 424 is configured to run the to-be-monitored function except the statistical code.
  • the reading unit 421 acquires the number of operations in the storage address
  • the calculating unit 422 calculates the result of adding 1 to the running number stored in the storage address
  • the updating unit 423 updates the data in the storage address to the calculation result
  • the processing unit 424 operates.
  • the statistics and storage of the running data can be automatically completed in the process of running the function, and no need to add any hardware, and the running data can be counted simply by running the program.
  • the program running monitoring device after inserting the statistical code in the function to be monitored, runs a function to be monitored inserted with a statistical code, wherein when the statistical code is executed, the running data of the self can be counted in real time, and the Run the data store to the corresponding storage address. Since the statistical code is set in the function to be monitored, the running data of the statistical code can accurately and truly reflect the running data of the function to be monitored.
  • the solution provided in this embodiment needs to be performed on the function to be monitored. In the case of sequence monitoring, it is only necessary to run the function to be monitored inserted with the statistical code, without providing a special tracking device and no hardware support, the operation is simple, the result is accurate, and the cost is low.
  • FIG. 5A is a schematic structural diagram of a program operation monitoring apparatus according to Embodiment 5 of the present invention.
  • the program operation monitoring apparatus further includes:
  • the specifying module 51 is configured to specify a corresponding storage address for the statistical code in the function to be monitored.
  • the storage address specified for the statistical code is used to store the operational data of the statistical code.
  • FIG. 5B is a schematic structural diagram of another program running monitoring apparatus according to Embodiment 5 of the present invention.
  • the specifying module 51 includes:
  • the offset unit 511 is configured to: in the code segment of the program where the function to be monitored is located, specify a corresponding storage address, where the storage address is to the function to be monitored, according to a preset offset
  • the offset of the entry address is the preset offset.
  • the offset unit 511 can specify a storage address corresponding to the statistical code from the code segment of the program.
  • the offset unit 511 uses the entry address of the function as the start address, and according to the offset, specifies the storage corresponding to the statistical code inserted in the function to be monitored. address.
  • the offset unit 511 may set different offsets for the plurality of statistical codes.
  • the storage address corresponding to the statistical code is set in the code segment of the program, and the storage address corresponding to each statistical code is determined by uniformly defining the starting address and the offset. According to the above embodiment, only one storage is needed.
  • the starting address and an offset can determine the storage address corresponding to each statistical code according to certain rules, thereby reducing data processing requirements and storage requirements.
  • FIG. 5C is a schematic structural diagram of still another program running monitoring apparatus according to Embodiment 5 of the present invention.
  • the specifying module 51 includes:
  • the allocating unit 512 is configured to: in the data segment of the program where the function to be monitored is located, specify a corresponding storage address for the statistical code in the to-be-monitored function;
  • the storage unit 513 is configured to store a correspondence between the storage address and the statistical code.
  • the specifying module 51 may also specify a storage address corresponding to the statistical code from the data segment of the program.
  • the allocating unit 512 specifies the storage address corresponding to the statistical code in the data segment, and the storage unit 513 plans a memory space corresponding to the mapping relationship between the statistical code in each function to be monitored and the storage address corresponding to the statistical code.
  • the storage address corresponding to the statistical code is set in the data segment of the program, and the storage address corresponding to each statistical code is determined by maintaining the corresponding relationship between the statistical code inserted in each function and the storage address, based on In the above embodiment, the flexibility of address designation can be improved.
  • the program running monitoring apparatus provided in this embodiment provides a plurality of implementation manners for specifying a storage address for a statistical code. Each implementation manner may be implemented separately or in combination. In actual applications, different designation manners may be determined according to different situations. Specify the corresponding storage address for the statistics code.
  • FIG. 6A is a schematic structural diagram of a program operation monitoring apparatus according to Embodiment 6 of the present invention. As shown in FIG. 6A, on the basis of any of the foregoing embodiments, the compiling module 41 includes:
  • a first compiling unit 413 configured to insert the first statistic code before the first instruction of the function to be monitored
  • the second compiling unit 414 is configured to insert the second statistic code before the last instruction of the function to be monitored.
  • the first statistical code inserted by the first compiling unit 413 before the first instruction of the function to be monitored generates the running data and is saved in the storage address corresponding to the first statistical code.
  • the second statistical code inserted by the second compiling unit 414 before the last instruction of the function to be monitored also generates the running data and stores it in the storage address corresponding to the second statistical code.
  • the processing unit 412 may specifically include the first compiling unit 413 and the second compiling unit 414. . That is, the process of the processing unit 412 inserting the execution code in each function to be monitored may refer to the embodiment shown in FIG. 6A, that is, the first statistical code and the second statistical code are both inserted.
  • the program operation monitoring device may further include:
  • the recording module 61 is configured to record the current first time when the running times of the storage addresses corresponding to the first statistical code change
  • the recording module 61 is further configured to: when the running times of the storage addresses corresponding to the second statistical code change, record the current second time;
  • the second output module 62 is configured to output a running time of the function to be monitored, where the running time is a difference between the first time and the second time.
  • the recording module 61 records the current first time, and the first time can reflect the initial running of the function to be monitored where the first statistical code is located. time.
  • the recording module 61 records the current second time, which can reflect the end running time of the to-be-monitored function where the second statistical code is located.
  • the second output module 62 can obtain the running time of the function to be monitored according to the initial running time and the ending running time of the function to be monitored.
  • the program running monitoring apparatus inserts a statistical code at the beginning and the end of the function to be monitored, records the time when the statistical code is running, and obtains the running time of the function to be monitored according to the time difference between the two times, and realizes the data.
  • the statistics are further expanded to enrich the data content.
  • the program running monitoring device provided by the application, after inserting the statistical code in the function to be monitored, runs the function to be monitored inserted with the statistical code, wherein when the statistical code is executed, the running data of the self can be counted in real time, and the running is performed. The data is stored to the corresponding storage address. Since the statistical code is set in the function to be monitored, the running data of the statistical code can accurately and truly reflect the running data of the function to be monitored.
  • the solution provided by this embodiment can be implemented by simply running a function to be monitored inserted with a statistical code when the program needs to be monitored. There is no need to provide a special tracking device and no hardware support, and the operation is simple, the result is accurate, and the cost is low. .
  • the seventh embodiment of the present invention further provides a computer storage medium, which may include: a U disk, a mobile hard disk, a read-only memory (ROM), and random access.
  • a medium for storing a program code such as a memory (RAM), a magnetic disk, or an optical disk.
  • the computer storage medium stores program instructions, and the program instructions are used in the program operation monitoring method in the above embodiment.
  • Embodiment 8 of the present invention provides a program operation monitoring device, which may be a terminal device installed with a program running system, such as a mobile phone, a computer, a PAD, or a smart watch, etc.
  • the program operation monitoring device includes at least one processor And a memory for storing computer execution instructions, the number of processors may be one or more, and may work separately or in cooperation, and the processor is configured to execute the computer-executed instructions of the memory storage to implement the above embodiment.
  • the program runs monitoring methods.
  • the related apparatus and method disclosed may be implemented in other manners.
  • the device embodiments described above are merely illustrative.
  • the division of the modules or units is only a logical function division.
  • there may be another division manner for example, multiple units or components may be used. Combinations can be integrated into another system, or some features can be ignored or not executed.
  • the mutual coupling or direct coupling or communication connection shown or discussed may be an indirect coupling or communication connection through some interface, device or unit, and may be in an electrical, mechanical or other form.
  • the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, may be located in one place, or may be distributed to multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of the embodiment.
  • each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.
  • the above integrated unit can be implemented in the form of hardware or in the 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 standalone product, may be stored in a computer readable storage medium.
  • a computer readable storage medium comprising instructions for causing a computer processor to perform all or part of the steps of the methods described in various embodiments of the present invention.
  • the foregoing storage medium includes: a U disk, a removable hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk, and the like, which can store program codes.

Landscapes

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

Abstract

The present application discloses a computer storage medium, and a program running monitoring method and device, said method comprising: inserting a statistic code into a function to be monitored, the statistic code being configured to store, when the statistic code is run, running data thereof into a corresponding storage address; and running, after the statistic code is inserted, the function to be monitored, the running data of the function, to be monitored, being the running data stored in the storage address corresponding to the statistic code. According to the technical solution provided by the present invention, when program monitoring needs to be performed on a function to be monitored, it only needs to run the function to be monitored, which has a statistic code inserted therein, without the need of providing a special tracking device or hardware support, simplifying the operation, providing an accurate result and having low cost.

Description

计算机存储介质、程序运行监测方法及装置Computer storage medium, program operation monitoring method and device 技术领域Technical field
本发明涉及计算机软件领域,尤其涉及一种计算机存储介质、程序运行监测方法及装置。The present invention relates to the field of computer software, and in particular, to a computer storage medium, a program running monitoring method and device.
背景技术Background technique
程序是指为了得到某种结果而可以由计算机等具有信息处理能力的装置执行的代码化指令序列,或者可以被自动转换成代码化指令序列的符号化指令序列或者符号化语句序列。通常的,一个程序可能包含一个或多个源文件,进一步的,每个源文件也可能包含一个或多个函数。实际应用中,为了能够准确统计程序运行时状态,例如,为了对跟踪统计目标机上程序的运行状态进行统计,通常需要对程序中某些函数的运行数据进行追踪监测,例如,统计某些函数的运行次数、运行时间等。A program is a sequence of coded instructions that can be executed by a device having information processing capabilities, such as a computer, in order to obtain a certain result, or a sequence of symbolized instructions or symbolic statements that can be automatically converted into a sequence of coded instructions. Typically, a program may contain one or more source files. Further, each source file may also contain one or more functions. In practical applications, in order to accurately calculate the running state of the program, for example, in order to track the running state of the program on the tracking target machine, it is usually necessary to track and monitor the running data of some functions in the program, for example, counting certain functions. Number of runs, run time, etc.
现有技术中,为了统计运行数据,一些微控制单元(Microcontroller Unit,简称MCU)需要提供硬件支持,例如,提供单独用于进行程序追踪的追踪端口来提供程序追踪功能,外部专门的程序追踪装置通过该端口实时监测该MCU的程序运行过程,并在监测过程中追踪统计待监测函数的运行数据。In the prior art, in order to statistically run data, some Microcontroller Units (MCUs) need to provide hardware support, for example, provide a tracking port for program tracking alone to provide program tracking function, and an external dedicated program tracking device. The program running process of the MCU is monitored in real time through the port, and the running data of the to-be-monitored function is tracked during the monitoring process.
通过上述现有技术能够实现对提供有硬件端口的待监测函数的程序追踪,但是,针对没有硬件端口支持的产品就无法进行程序监测,并且为待监测的产品提供相应的硬件端口会导致产品的成本提高,此外上述现有技术的操作过程也比较繁琐。The program tracking of the function to be monitored provided with the hardware port can be realized by the above prior art, but the program monitoring cannot be performed for the product without the hardware port support, and providing the corresponding hardware port for the product to be monitored may result in the product. The cost is increased, and the above-described prior art operation process is also cumbersome.
发明内容Summary of the invention
本发明提供了一种计算机存储介质、程序运行监测方法及装置,用于解决现有的程序监测防范依赖于硬件支持,且过程繁琐的技术问题。 The invention provides a computer storage medium, a program operation monitoring method and a device, which are used for solving the technical problem that the existing program monitoring and prevention relies on hardware support and the process is cumbersome.
本发明的第一方面是为了提供一种程序运行监测方法,包括:在待监测函数中插入统计代码,其中,所述统计代码用于当其自身被运行时,将其运行数据存储至对应的存储地址;运行插入所述统计代码后的所述待监测函数,其中,所述待监测函数的运行数据为所述统计代码对应的存储地址中存储的运行数据。A first aspect of the present invention is to provide a program operation monitoring method comprising: inserting a statistical code in a function to be monitored, wherein the statistical code is configured to store its operational data to a corresponding one when it is itself a storage address; the function to be monitored after the insertion of the statistical code, wherein the operation data of the function to be monitored is the operation data stored in a storage address corresponding to the statistical code.
本发明的第二方面是为了提供一种程序运行监测装置,包括:编译模块,用于在待监测函数中插入统计代码,其中,所述统计代码用于当其自身被运行时,将其运行数据存储至对应的存储地址;执行模块,用于运行插入所述统计代码后的所述待监测函数,其中,所述待监测函数的运行数据为所述统计代码对应的存储地址中存储的运行数据。A second aspect of the present invention is to provide a program operation monitoring apparatus, comprising: a compiling module for inserting a statistical code in a function to be monitored, wherein the statistical code is used to run a statistical code when it is itself The data is stored to the corresponding storage address; the execution module is configured to run the to-be-monitored function after inserting the statistical code, wherein the running data of the function to be monitored is a running stored in a storage address corresponding to the statistical code data.
本发明的第三方面是为了提供一种程序运行监测装置,包括:至少一个处理器和存储器;所述存储器存储计算机执行指令;所述至少一个处理器执行所述存储器存储的计算机执行指令,以执行如前所述的方法。A third aspect of the present invention is to provide a program operation monitoring apparatus including: at least one processor and a memory; the memory storage computer executing an instruction; the at least one processor executing the memory execution computer execution instruction to Perform the method as described above.
本发明的第四方面是为了提供一种计算机存储介质,该计算机存储介质中存储有程序指令,所述程序指令被处理器执行时实现如前所述的方法。A fourth aspect of the present invention is to provide a computer storage medium having program instructions stored therein, the program instructions being executed by a processor to implement the method as described above.
本发明提供的计算机存储介质、程序运行监测方法及装置,在待监测函数中插入统计代码后,运行插入有统计代码的待监测函数,其中该统计代码被执行时,可以实时统计其自身的运行数据,并将该运行数据存储至对应的存储地址。由于该统计代码设置在待监测函数中,因此,该统计代码的运行数据能够准确真实地反映待监测函数的运行数据。本方案当需要对待监测函数进行程序监测时,只需运行插入有统计代码的待监测函数即可实现,无需提供专门的追踪装置且无需硬件支持,操作简便、结果准确、成本低。The computer storage medium and the program operation monitoring method and device provided by the invention, after inserting the statistical code in the function to be monitored, run the function to be monitored inserted with the statistical code, wherein when the statistical code is executed, the running of the data can be performed in real time. Data and store the run data to the corresponding storage address. Since the statistical code is set in the function to be monitored, the running data of the statistical code can accurately and truly reflect the running data of the function to be monitored. When the program needs to be monitored by the monitoring function, it only needs to run the function to be monitored inserted with the statistical code, without providing a special tracking device and no hardware support, the operation is simple, the result is accurate, and the cost is low.
附图说明DRAWINGS
为了更清楚地说明本发明实施例中的技术方案,下面将对实施例描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本发明的一些实施例,对于本领域普通技术人员来讲,还可以根据这些附图获得其他的附图。In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings used in the description of the embodiments will be briefly described below. It is obvious that the drawings in the following description are only some embodiments of the present invention. Other figures may also be obtained from those of ordinary skill in the art in view of these figures.
图1A~图1C为本发明实施例一提供的程序运行监测方法的流程示意图;1A-1C are schematic flowcharts of a method for monitoring program running according to Embodiment 1 of the present invention;
图1D为本发明实施例中统计代码的代码示例图; 1D is a diagram showing an example of code of a statistical code in an embodiment of the present invention;
图2A~图2C为本发明实施例二提供的程序运行监测方法的流程示意图;2A-2C are schematic flowcharts of a program operation monitoring method according to Embodiment 2 of the present invention;
图3A为本发明实施例三提供的一种程序运行监测方法的流程示意图;3A is a schematic flowchart of a method for monitoring program running according to Embodiment 3 of the present invention;
图3B为待统计函数和非待统计函数的起始部分对比图;FIG. 3B is a comparison diagram of the initial part of the function to be statistically and the function to be non-statistic;
图3C为待统计函数和非待统计函数的结束部分对比图;3C is a comparison diagram of the end portion of the function to be statistically and the function to be non-statistic;
图3D为插入有第一统计代码和第二统计代码的待监测函数的代码示例图;3D is a code example diagram of a function to be monitored inserted with a first statistical code and a second statistical code;
图3E为本发明实施例三提供的另一种程序运行监测方法的流程示意图;3E is a schematic flowchart of another method for monitoring program running according to Embodiment 3 of the present invention;
图4A~图4D为本发明实施例四提供的程序运行监测装置的结构示意图;4A-4D are schematic structural diagrams of a program operation monitoring apparatus according to Embodiment 4 of the present invention;
图5A~图5C为本发明实施例五提供的程序运行监测装置的结构示意图;5A-5C are schematic structural diagrams of a program operation monitoring apparatus according to Embodiment 5 of the present invention;
图6A~图6B为本发明实施例六提供的程序运行监测装置的结构示意图。6A-6B are schematic diagrams showing the structure of a program operation monitoring apparatus according to Embodiment 6 of the present invention.
具体实施方式Detailed ways
为使本发明实施例的目的、技术方案和优点更加清楚,下面将结合本发明实施例中的附图,对本发明实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例是本发明一部分实施例,而不是全部的实施例。基于本发明中的实施例,本领域普通技术人员所获得的所有其他实施例,都属于本发明保护的范围。The technical solutions in the embodiments of the present invention will be clearly and completely described in conjunction with the drawings in the embodiments of the present invention. It is a partial embodiment of the invention, and not all of the embodiments. All other embodiments obtained by those of ordinary skill in the art based on the embodiments of the present invention are within the scope of the present invention.
除非另有定义,本文所使用的所有的技术和科学术语与属于本发明的技术领域的技术人员通常理解的含义相同。本文中在本发明的说明书中所使用的术语只是为了描述具体的实施例的目的,不是旨在于限制本发明。本文所使用的术语“及/或”包括一个或多个相关的所列项目的任意的和所有的组合。All technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this invention belongs, unless otherwise defined. The terminology used in the description of the present invention is for the purpose of describing particular embodiments and is not intended to limit the invention. The term "and/or" used herein includes any and all combinations of one or more of the associated listed items.
下面结合附图,对本发明的一些实施方式作详细说明。在不冲突的情况下,下述的实施例及实施例中的特征可以相互组合。Some embodiments of the present invention are described in detail below with reference to the accompanying drawings. The features of the embodiments and examples described below can be combined with each other without conflict.
图1A为本发明实施例一提供的一种程序运行监测方法的流程示意图;参考附图1A可知,本实施例提供了一种程序运行监测方法,该程序运行监测方法用于方便准确低成本地实现对待监测函数的程序追踪,具体的,该程序运行监测方法包括:1A is a schematic flowchart of a method for monitoring a program operation according to a first embodiment of the present invention. Referring to FIG. 1A, the embodiment provides a program operation monitoring method, which is convenient, accurate, and low-cost. The program tracking of the function to be monitored is implemented. Specifically, the monitoring method of the program operation includes:
101:在待监测函数中插入统计代码,其中,所述统计代码用于当其自身被运行时,将其运行数据存储至对应的存储地址。101: Insert a statistical code in the function to be monitored, wherein the statistical code is used to store its running data to a corresponding storage address when it is run by itself.
具体的,该程序运行监测方法的执行主体可以为程序运行监测装置。在 实际应用中,该程序运行监测装置可以为存储有相关执行代码的介质,例如,U盘等;或者,该程序运行监测装置还可以为集成或安装有相关执行代码的实体装置,例如,芯片、智能终端、计算机等。Specifically, the execution body of the program running monitoring method may be a program running monitoring device. In In practical applications, the program running monitoring device may be a medium storing related execution code, for example, a USB flash drive, etc.; or the program running monitoring device may also be a physical device integrated or installed with related execution code, for example, a chip, Intelligent terminals, computers, etc.
实际应用中,待监测函数可以为某程序下的某源文件中的函数。通过统计该函数的统计数据,可以实现对其所在程序的程序监测。本方案中的所述统计代码可以由程序人员预先编写,当该统计代码被运行时,会相应执行一系列流程,基于执行的流程可以将统计代码自身的运行数据存储至与该统计代码对应的存储地址中。进一步的,统计代码插入的位置可以为函数中的任一位置,只要不影响函数自身的运行。插入的统计代码的运行数据能够反映其所在函数的运行数据。所述运行数据包括但不限于运行次数等。In practical applications, the function to be monitored can be a function in a source file under a certain program. By counting the statistical data of the function, the program monitoring of the program in which it is located can be realized. The statistical code in the solution can be pre-written by the program personnel. When the statistical code is run, a series of processes are executed correspondingly, and the running data of the statistical code itself can be stored to correspond to the statistical code based on the executed process. Stored in the address. Further, the position where the statistical code is inserted can be any position in the function as long as it does not affect the operation of the function itself. The running data of the inserted statistical code can reflect the running data of the function it is in. The operational data includes, but is not limited to, the number of operations, and the like.
具体的,对于每个待监测函数来说,该待监测函数中插入的每个统计代码对应有存储地址,这个存储地址可以是由程序员预先指定的,或者,也可以在统计代码首次运行过程中自动指定。某个统计代码的存储地址指定完成后,该统计代码即可在运行过程中,根据当前自身的统计数据,对其对应的存储地址中存储的数据进行更新。以实际场景举例来说:当需要对某程序进行程序监测时,可以先确定需要对该程序下的哪些函数进行运行数据的统计,相应的,在这些函数中插入统计代码。具体的,在函数中插入统计代码的过程可以通过对该函数所在的程序进行编译实现。Specifically, for each function to be monitored, each statistical code inserted in the function to be monitored corresponds to a storage address, which may be pre-specified by the programmer, or may be performed during the first run of the statistical code. Automatically specified in . After the storage address of a certain statistical code is specified, the statistical code can update the data stored in the corresponding storage address according to the current statistical data during the running process. For example, in the actual scenario, when it is necessary to perform program monitoring on a program, it may first determine which functions under the program need to run statistics on the running data, and correspondingly, insert statistical codes into these functions. Specifically, the process of inserting a statistical code in a function can be implemented by compiling the program in which the function is located.
进一步的,对某个程序进行程序运行监测时,可以只选取部分函数的统计数据进行统计。相应的,如图1B所示,图1B为本发明实施例一提供的另一种程序运行监测方法的流程示意图,在实施例一的基础上,101具体可以包括:Further, when performing program monitoring on a certain program, only statistical data of some functions may be selected for statistics. Correspondingly, as shown in FIG. 1B, FIG. 1B is a schematic flowchart of another method for monitoring program running according to Embodiment 1 of the present invention. On the basis of Embodiment 1, 101 may specifically include:
1011:为程序中需要监测的源文件设置追踪编译选项。1011: Set trace compile options for source files that need to be monitored in the program.
本实施方式中,进行统计代码插入处理的单位为单个源文件。具体的,针对需要监测的函数所在的源文件设置追踪编译选项。举例来说,假设某程序A中包括源文件A1、A2和A3,其中,源文件A1包括函数A11、A12、A13,源文件A2包括函数A21、A22、A23,源文件A3包括函数A31、A32、A33,当前需要统计函数A11和A23的运行数据,则可分别为源文件A1和A2设置追踪编译选项。In the present embodiment, the unit for performing the statistical code insertion processing is a single source file. Specifically, set the trace compilation option for the source file where the function to be monitored is located. For example, suppose a certain program A includes source files A1, A2, and A3, wherein the source file A1 includes functions A11, A12, and A13, the source file A2 includes functions A21, A22, and A23, and the source file A3 includes functions A31 and A32. A33, currently need to run the statistics of the function A11 and A23, you can set the trace compile options for the source files A1 and A2, respectively.
可选的,所述追踪编译选项的设置方式有多种,例如,该追踪编译选项 可以是显式的,例如,在每个各源文件的编译选项下添加追踪编译选项对应的选框“□”。当某源文件的追踪编译选项对应的选框被用户选中时,即该源文件的追踪编译选项被设置。用户选中追踪编译选项可以通过点击等操作实现。或者,也可以直接为需要监测的源文件添加追踪编译选项对应的标识,相应的,添加有该标识的源文件即为设置有追踪编译选项的源文件。Optionally, the tracking compilation option is set in various manners, for example, the tracking compilation option. It can be explicit, for example, adding a checkbox "□" corresponding to the trace compile option under the compile options for each source file. When the checkbox corresponding to the trace compile option of a source file is selected by the user, the trace compile option of the source file is set. The user selects the trace compile option to be implemented by clicking and other operations. Alternatively, you can directly add the identifier corresponding to the trace compile option to the source file to be monitored. Correspondingly, the source file to which the identifier is added is the source file with the trace compile option set.
1012:将设置有追踪编译选项的源文件中的所有函数作为所述待监测函数。1012: All functions in the source file set with the tracking compile option are set as the function to be monitored.
根据各源文件是否设置有追踪编译选项,可以确定对哪些源文件中的函数进行运行数据的统计。具体的,对某些特定的源文件设置追踪追踪编译选项后,所述追踪编译选项的设置状态会传递给用于对程序进行编译的模块,以在对程序编译时确定需要插入统计代码的函数。实际应用中,用户可以对需要被追踪的函数所在的源文件选定追踪编译选项来确定需要统计的函数范围。Depending on whether each source file is set with a trace compile option, you can determine which of the source files have statistics on the running data. Specifically, after setting the trace tracking compile option for some specific source files, the setting state of the trace compile option is passed to the module for compiling the program to determine the function that needs to insert the statistical code when compiling the program. . In practice, the user can select the trace compilation option for the source file where the function to be traced is located to determine the range of functions that need to be counted.
本实施方式中,将设置有追踪编译选项对应的源文件下所有的函数作为待监测的函数,进而统计这些待监测函数的运行数据。仍结合前述举例来举例说明,假设源文件A1包括函数A11、A12、A13,源文件A2包括函数A21、A22、A23,源文件A3包括函数A31、A32、A33,当前若需要统计函数A12和A22的运行数据,则可以为源文件A1和源文件A2设置追踪编译选项,相应的,函数A11、A12、A13、A21、A22和A23为本次的待监测函数。In this embodiment, all functions under the source file corresponding to the tracking compilation option are set as functions to be monitored, and then the running data of the functions to be monitored are counted. Still exemplified in connection with the foregoing examples, it is assumed that the source file A1 includes functions A11, A12, A13, the source file A2 includes functions A21, A22, A23, and the source file A3 includes functions A31, A32, A33, and current statistical functions A12 and A22 are required. The running data can set the tracking compile option for the source file A1 and the source file A2. Correspondingly, the functions A11, A12, A13, A21, A22 and A23 are the functions to be monitored.
1013:通过对所述程序进行编译,在每个所述待监测函数中插入统计代码。1013: Insert a statistical code in each of the functions to be monitored by compiling the program.
具体的,为需要监测的源文件设置追踪编译选项后,对整个程序进行编译。具体的,在对程序进行编译的过程中,对设置有追踪编译选项的源文件,在该源文件的所有函数中插入统计代码。Specifically, after setting the trace compile option for the source file to be monitored, the entire program is compiled. Specifically, in the process of compiling the program, a statistical code is inserted into all the functions of the source file for the source file provided with the tracking compile option.
本实施方式,通过设置追踪编译选项确定需要进行运行数据统计的函数范围,在编译程序时在设置有追踪编译选项的函数中插入统计代码,从而快速便捷地确定需要插入统计代码的函数,提高处理的效率。In this embodiment, the function range of the running data statistics is determined by setting the tracking compile option, and the statistical code is inserted in the function that sets the tracking compiling option when the program is compiled, so that the function that needs to insert the statistical code is quickly and conveniently determined, and the processing is improved. s efficiency.
102:运行插入所述统计代码后的所述待监测函数,其中,所述待监测函数的运行数据为所述统计代码对应的存储地址中存储的运行数据。The operation function of the to-be-monitored function is the operation data stored in the storage address corresponding to the statistical code.
实际应用中,可以通过运行待监测函数所在的程序运行待监测函数。以 实际场景举例来说:参照前述步骤,为待监测函数插入统计代码后,即可运行待监测函数,该待监测函数的运行数据即为统计代码的运行数据。可以理解,在程序的编译阶段对每个需要进行统计的函数中插入了统计代码,相应在运行每个函数的同时,该函数中插入的统计代码同样会被运行,所以统计代码的运行数据能够准确反映函数的运行数据。后续,当用户需要查询函数的运行数据时,即可直接获得统计代码的运行数据输出给用户。相应的,该程序运行监测方法还可以包括:获取待监测函数中插入的统计代码对应的存储地址;将所述存储地址中存储的运行数据作为所述待监测函数的运行数据输出。In practical applications, the function to be monitored can be run by running the program where the function to be monitored is located. Take For example, the actual scenario is as follows: After the statistical code is inserted into the function to be monitored, the function to be monitored can be run, and the running data of the function to be monitored is the running data of the statistical code. It can be understood that in the compiling stage of the program, statistical code is inserted into each function that needs to be statistically calculated. Corresponding to the running of each function, the statistical code inserted in the function is also run, so the running data of the statistical code can be Accurately reflect the operational data of the function. Subsequently, when the user needs to query the running data of the function, the running data of the statistical code can be directly output to the user. Correspondingly, the program running monitoring method may further include: acquiring a storage address corresponding to the statistical code inserted in the function to be monitored; and outputting the running data stored in the storage address as the running data of the function to be monitored.
本方案中的统计代码运行时能够统计自身的运行数据并存储至相应地址。该统计代码运行时执行的流程可以通过多种方式实现。可选的,如图1C所示,图1C为本发明实施例一提供的又一种程序运行监测方法的流程示意图,在实施例一的基础上,所述运行数据包括运行次数;相应的,102具体可以包括:The statistical code in this scenario can count its own running data and store it to the corresponding address. The process performed by the stats code runtime can be implemented in a variety of ways. Optionally, as shown in FIG. 1C, FIG. 1C is a schematic flowchart of still another program running monitoring method according to Embodiment 1 of the present invention. On the basis of Embodiment 1, the running data includes a running number; correspondingly, 102 specifically may include:
1021、获取所述统计代码对应的存储地址中当前存储的运行次数;1011. Obtain a running number of times currently stored in a storage address corresponding to the statistical code.
1022、将当前存储的运行次数加1,获得计算结果;1022: Add 1 to the current stored running times to obtain a calculation result;
1023、将所述存储地址中当前存储的运行次数更新为所述计算结果;1023. Update the currently stored running times in the storage address to the calculation result.
1024:运行除所述统计代码外的所述待监测函数。1024: Run the to-be-monitored function except the statistical code.
需要说明的是,图中所示的各步骤之间的先后顺序仅为一种举例的可实施方式,在实际应用中,基于统计代码在函数中插入位置的不同,上述各步骤的执行顺序也可能不同。举例来说,假设将统计代码设置在待监测函数之前,则步骤1021至1023先于1024执行;假设将统计代码设置在待监测函数内,则步骤1021至1023在步骤1024执行的过程中执行。It should be noted that the sequence between the steps shown in the figure is only an exemplary implementation manner. In practical applications, based on the difference in the insertion position of the statistical code in the function, the execution order of the above steps is also May be different. For example, assuming that the statistical code is set before the function to be monitored, steps 1021 through 1023 are performed prior to 1024; assuming that the statistical code is set within the function to be monitored, steps 1021 through 1023 are performed during the execution of step 1024.
具体的,统计代码运行时获取相应存储地址中的运行次数后,将本次的运行计算进运行次数,具体的,计算存储地址中存储的运行次数加1后的结果,并将存储地址中的数据更新为计算结果,即实现存储地址中存储的运行次数加1的效果,从而便捷地实现对运行次数的统计和更新。实际应用中,进行程序监测前,可以对存储地址中的数据进行初始化,具体可以将存储地址中的数据初始化为0。Specifically, after the statistics code runs to obtain the running times in the corresponding storage address, the running operation is calculated into the running times. Specifically, the result of adding the running number stored in the storage address is calculated, and the storage address is The data is updated to the calculation result, that is, the effect of adding 1 to the running times stored in the storage address is realized, thereby conveniently counting and updating the running times. In practical applications, before the program is monitored, the data in the storage address can be initialized, and the data in the storage address can be initialized to 0.
举例来说,图1D为本发明实施例中统计代码的代码示例图。结合附图,0x914为统计代码对应的存储地址,每行代码执行的步骤依次如下:a.读取 0x914地址中存储的数据,即t0(假设t0的值为2);b.加载该数据t0至寄存器,寄存器中当前的数据为t1(此时t0=t1=2);c.在寄存器中进行t1=t1+1的运算(运算后t1的值为3);d.将寄存器中的数据t1写回至0x914地址中(此时0x914地址中存储的值更新为3)。需要说明的是,图中的程序代码仅仅为一种举例的可实施方式,其并未对统计代码的具体实现方式进行限定。For example, FIG. 1D is a diagram showing an example of code of a statistical code in an embodiment of the present invention. Referring to the drawings, 0x914 is the storage address corresponding to the statistical code, and the steps performed by each line of code are as follows: a. Read 0x914 The data stored in the address, ie t0 (assuming the value of t0 is 2); b. Load the data t0 to the register, the current data in the register is t1 (at this time t0=t1=2); c. in the register The operation of t1=t1+1 (the value of t1 after the operation is 3); d. The data t1 in the register is written back to the address 0x914 (the value stored in the address of 0x914 is updated to 3). It should be noted that the program code in the figure is merely an exemplary implementation manner, and the specific implementation manner of the statistical code is not limited.
通过上述实施方式,在函数运行的过程中即可自动完成运行数据的统计和存储,无需增加任何硬件,单纯通过程序的运行即可统计运行数据。Through the above implementation manner, the statistics and storage of the running data can be automatically completed in the process of running the function, and no need to add any hardware, and the running data can be counted simply by running the program.
需要说明的是,本实施例的方案适用于嵌入式软件领域,尤其适用于低成本MCU的嵌入式软件领域。此外,还可以适用于任何目标机,可以统计任何目标机上运行的程序运行数据。并且本方案在无需CPU提供任何的追踪单元,无需任何硬件支持的情况下,实现低成本的程序运行追踪方法,能够统计程序中的函数运行轨迹,并能够自定义统计范围。此外,基于本实施例的方案,既可以在程序运行时实时获得统计的运行数据,也能在程序运行暂停时获得统计的运行数据,提高程序监测的可靠性。It should be noted that the solution of this embodiment is applicable to the field of embedded software, and is particularly applicable to the field of embedded software of a low-cost MCU. In addition, it can be applied to any target machine and can count the program running data running on any target machine. And this solution realizes low-cost program running tracking method without the need to provide any tracking unit by the CPU, without any hardware support, can count the function running track in the program, and can customize the statistical range. In addition, based on the solution of the embodiment, the statistical running data can be obtained in real time when the program is running, and the statistical running data can be obtained when the program runs paused, thereby improving the reliability of the program monitoring.
本实施例提供的程序运行监测方法,在待监测函数中插入统计代码后,运行插入有统计代码的待监测函数,其中该统计代码被执行时,可以实时统计其自身的运行数据,并将该运行数据存储至对应的存储地址。由于该统计代码设置在待监测函数中,因此,该统计代码的运行数据能够准确真实地反映待监测函数的运行数据。本实施例提供的方案当需要对待监测函数进行程序监测时,只需运行插入有统计代码的待监测函数即可实现,无需提供专门的追踪装置且无需硬件支持,操作简便、结果准确、成本低。The program running monitoring method provided in this embodiment, after inserting the statistical code in the function to be monitored, running the function to be monitored inserted with the statistical code, wherein when the statistical code is executed, the running data of the self can be counted in real time, and the Run the data store to the corresponding storage address. Since the statistical code is set in the function to be monitored, the running data of the statistical code can accurately and truly reflect the running data of the function to be monitored. The solution provided by this embodiment can be implemented by simply running a function to be monitored inserted with a statistical code when the program needs to be monitored. There is no need to provide a special tracking device and no hardware support, and the operation is simple, the result is accurate, and the cost is low. .
为了在程序运行过程中记录运行数据,需要为统计代码指定存储地址。相应的,如图2A所示,图2A为本发明实施例二提供的一种程序运行监测方法的流程示意图;参考附图2A,在实施例一的基础上,该程序运行监测方法还包括:In order to record the running data during the running of the program, you need to specify the storage address for the statistical code. Correspondingly, as shown in FIG. 2A, FIG. 2A is a schematic flowchart of a program operation monitoring method according to Embodiment 2 of the present invention. Referring to FIG. 2A, the program running monitoring method further includes:
201:为所述待监测函数中的所述统计代码指定对应的存储地址。201: Specify a corresponding storage address for the statistical code in the to-be-monitored function.
具体的,为统计代码指定的存储地址用于存储该统计代码的运行数据。需要说明的是,图中只是一种举例的实施方式,其并未对各步骤的先后执行顺序进行限定,举例来说,201还可以在101中插入统计代码的过程中执行。 Specifically, the storage address specified for the statistical code is used to store the operational data of the statistical code. It should be noted that the figure is only an exemplary implementation manner, and the order of execution of each step is not limited. For example, 201 may also be executed in the process of inserting the statistical code in 101.
作为一种可实施的方式,所述存储地址可以位于程序的代码段。如图2B所示,图2B为本发明实施例二提供的另一种程序运行监测方法的流程示意图,在图2A所示实施方式的基础上,201具体可以包括:As an implementable manner, the storage address can be located in a code segment of the program. As shown in FIG. 2B, FIG. 2B is a schematic flowchart of another method for monitoring program running according to Embodiment 2 of the present invention. On the basis of the embodiment shown in FIG. 2A, 201 may specifically include:
2011:根据预设的偏移量,在所述待监测函数所在程序的代码段中,为所述统计代码指定对应的存储地址,所述存储地址至所述待监测函数的入口地址的偏移量为所述预设的偏移量。2011: According to a preset offset, in the code segment of the program where the function to be monitored is located, a corresponding storage address is specified for the statistical code, and the storage address is offset to an entry address of the function to be monitored. The amount is the preset offset.
具体的,可以从程序的代码段中指定统计代码对应的存储地址。代码段通常是指用来存放程序执行代码的一块内存区域,代码段中的地址可以通过定义起始地址和相对该起始地址的偏移量来表征和确定,故为了节约存储空间,可以预设设定统一的起始地址,从而通过设定统一的偏移量来确定每个函数中统计代码的存储地址。具体的,当存储地址位于程序的代码段时,针对程序中的每个函数,可以将该函数的入口地址作为起始地址,则设定好统一的偏移量之后,每个函数中统计代码对应的存储地址与该函数的入口地址之间的偏移量固定,这样在对程序进行编译时,针对待监测函数来说,需要在待监测函数中插入统计代码,在插入统计代码的同时可以自动寻址至待监测函数的入口地址,则自该入口地址偏移固定的偏移量得到的地址,即为待监测函数中插入的统计代码对应的存储地址。Specifically, the storage address corresponding to the statistical code can be specified from the code segment of the program. The code segment usually refers to a memory area used to store the program execution code. The address in the code segment can be characterized and determined by defining the start address and the offset from the start address, so in order to save storage space, it can be pre- Set a uniform starting address to determine the storage address of the statistical code in each function by setting a uniform offset. Specifically, when the storage address is located in the code segment of the program, for each function in the program, the entry address of the function can be used as the start address, and after the uniform offset is set, the statistical code in each function The offset between the corresponding storage address and the entry address of the function is fixed, so that when the program is compiled, for the function to be monitored, the statistical code needs to be inserted in the function to be monitored, and the statistical code can be inserted at the same time. Automatically addressing the entry address of the function to be monitored, the address obtained by offsetting the entry address by a fixed offset, that is, the storage address corresponding to the statistical code inserted in the function to be monitored.
举例来说,假设定义起始地址为函数的入口地址,设定偏移量为2,则对于当前插入统计代码的函数来说,自动寻址该函数的入口地址,例如,查找到该函数的入口地址为0x904,则相应的,根据预设的偏移量,该函数中插入的该统计代码对应的存储地址为0x906。以此类推,在偏移的过程中可以确定每个插入的统计代码对应的存储地址。For example, suppose that the starting address is defined as the entry address of the function, and the offset is set to 2, then the function of the function that currently inserts the statistical code is automatically addressed, for example, the function is found. The entry address is 0x904, and correspondingly, according to the preset offset, the storage address corresponding to the statistical code inserted in the function is 0x906. By analogy, the storage address corresponding to each inserted statistical code can be determined during the offset process.
可选的,当每个待监测函数中插入的统计代码数量为多个时,可以针对这多个统计代码设定不同的偏移量。举例来说,假设在函数A11中插入两个统计代码B11和B12,在函数A12中插入两个统计代码B21和B22,则可以定义起始地址为函数的入口地址,为插入每个函数中的第一个统计代码设定的偏移量为3,为插入每个函数中的第二个统计代码设定的偏移量为4,则对于函数A11来说,假定其入口地址为0x804,则统计代码B11和B12对应的存储地址分别为0x807和0x808;对于函数A12来说,假定其入口地址为0x904,则统计代码B21和B22对应的存储地址分别为0x907和0x908。 Optionally, when the number of statistical codes inserted in each function to be monitored is multiple, different offsets may be set for the multiple statistical codes. For example, suppose that two statistical codes B11 and B12 are inserted in function A11, and two statistical codes B21 and B22 are inserted in function A12, then the starting address can be defined as the entry address of the function, which is inserted into each function. The offset set by the first statistic code is 3, and the offset set for the second statistic code inserted into each function is 4, then for function A11, assuming its entry address is 0x804, then The storage addresses corresponding to the statistical codes B11 and B12 are 0x807 and 0x808, respectively; for the function A12, assuming that the entry address is 0x904, the storage addresses corresponding to the statistical codes B21 and B22 are 0x907 and 0x908, respectively.
通过上述实施方式,将统计代码对应的存储地址设置在程序的代码段中,通过统一定义起始地址和偏移量来确定每个统计代码对应的存储地址,基于上述实施方式,只需要存储一个起始地址和一个偏移量即可按照一定的规则确定各统计代码对应的存储地址,从而减少数据的处理要求和存储要求。Through the above embodiment, the storage address corresponding to the statistical code is set in the code segment of the program, and the storage address corresponding to each statistical code is determined by uniformly defining the starting address and the offset. According to the above embodiment, only one storage is needed. The starting address and an offset can determine the storage address corresponding to each statistical code according to certain rules, thereby reducing data processing requirements and storage requirements.
作为另一种可实施的方式,所述存储地址可以位于程序的数据段。如图2C所示,图2C为本发明实施例二提供的又一种程序运行监测方法的流程示意图,在图2A所示实施方式的基础上,201具体可以包括:As another implementable manner, the storage address may be located in a data segment of the program. As shown in FIG. 2C, FIG. 2C is a schematic flowchart of still another program running monitoring method according to Embodiment 2 of the present invention. On the basis of the embodiment shown in FIG. 2A, 201 may specifically include:
2012:在所述待监测函数所在程序的数据段中,为所述所述待监测函数中的所述统计代码指定对应的存储地址;2012: in the data segment of the program where the function to be monitored is located, specifying a corresponding storage address for the statistical code in the function to be monitored;
2013:存储所述存储地址与所述统计代码之间的对应关系。2013: Store a correspondence between the storage address and the statistical code.
具体的,还可以从程序的数据段中指定统计代码对应的存储地址。数据段通常是指用来存放程序中已初始化的全局变量的一块内存区域,在数据段中设置存储地址,可以提高存储地址设置的灵活性。相应的,在数据段中指定统计代码对应的存储地址的同时,需要规划相应用于存放各待监测函数中的统计代码与该统计代码对应的存储地址之间的映射关系的内存空间,具体实现时,可以通过维护一张关系表来记录不同待监测函数中的统计代码与存储地址之间的对应关系,以便在对程序进行编译过程中,向待监测函数中插入统计代码时,能够根据维护的映射关系,查找到相应的存储地址。Specifically, the storage address corresponding to the statistical code may also be specified from the data segment of the program. The data segment usually refers to a memory area used to store the initialized global variables in the program. Setting the storage address in the data segment can improve the flexibility of the storage address setting. Correspondingly, when the storage address corresponding to the statistical code is specified in the data segment, the memory space corresponding to the mapping relationship between the statistical code in each function to be monitored and the storage address corresponding to the statistical code needs to be planned, and the specific implementation is implemented. When a relationship table is maintained, the correspondence between the statistical code and the storage address in different functions to be monitored can be recorded, so that when the statistical code is inserted into the function to be monitored during the compilation process of the program, the maintenance can be performed according to the maintenance. The mapping relationship finds the corresponding storage address.
举例来说,假设函数A11和A21都需要插入统计代码,则在程序的数据段中为函数A11插入的统计代码C11和A21中插入的统计代码C12指定对应的存储地址,假定分别为0x501和0x502。则存储A11中C11和0x501的对应关系,以及A21中C12和0x502的对应关系。以此类推,建立每个统计代码与对应的存储地址之间的映射关系后,后续可以根据该映射关系确定任一统计代码对应的存储地址。For example, assuming that both functions A11 and A21 need to insert a statistical code, the corresponding statistical storage address is specified in the data segment of the program for the statistical code C11 inserted in the function A11 and the statistical code C12 inserted in the A21, assuming 0x501 and 0x502, respectively. . Then, the correspondence between C11 and 0x501 in A11 and the correspondence between C12 and 0x502 in A21 are stored. By analogy, after establishing the mapping relationship between each statistical code and the corresponding storage address, the storage address corresponding to any statistical code can be determined according to the mapping relationship.
通过上述实施方式,将统计代码对应的存储地址设置在程序的数据段中,通过维护各函数中插入的统计代码与存储地址之间的对应的关系来确定每个统计代码对应的存储地址,基于上述实施方式,能够提高地址指定的灵活性。Through the above implementation manner, the storage address corresponding to the statistical code is set in the data segment of the program, and the storage address corresponding to each statistical code is determined by maintaining the corresponding relationship between the statistical code inserted in each function and the storage address, based on In the above embodiment, the flexibility of address designation can be improved.
本实施例提供的程序运行监测方法,提供了多种为统计代码指定存储地址的实施方式,各实施方式可以分别单独实施也可以结合实施,实际应用中,可以根据不同情况确定采用不同的指定方式为统计代码指定对应的存储地址。 The program running monitoring method provided in this embodiment provides a plurality of implementation manners for specifying a storage address for a statistical code. Each implementation manner may be implemented separately or in combination. In actual applications, different designation manners may be determined according to different situations. Specify the corresponding storage address for the statistics code.
本方案中,对于单个待监测函数来说,其中插入的统计代码的数量可以为一个或多个。相应的,每个统计代码均对应有存储地址。当单个待监测函数中插入的统计代码为多个时,基于这多个统计代码的运行数据,可以进一步分析出其它数据,例如,待监测函数的运行时间。In this solution, for a single function to be monitored, the number of statistical codes inserted therein may be one or more. Correspondingly, each statistical code corresponds to a storage address. When there are multiple statistical codes inserted in a single function to be monitored, based on the running data of the plurality of statistical codes, other data, for example, the running time of the function to be monitored, may be further analyzed.
图3A为本发明实施例三提供的一种程序运行监测方法的流程示意图,如图3A所示,在前述任一实施例的基础上,101具体可以包括:FIG. 3A is a schematic flowchart of a program running monitoring method according to Embodiment 3 of the present invention. As shown in FIG. 3A, based on any of the foregoing embodiments, 101 may specifically include:
301:将第一统计代码插入所述待监测函数的第一条指令之前。301: Insert the first statistic code before the first instruction of the function to be monitored.
具体的,程序运行时,插入到待监测函数的第一条指令之前的第一统计代码会生成运行数据并保存在第一统计代码对应的存储地址中。通过访问存储地址中存储的数据能够在程序运行的时候实时查询运行数据,并输出给用户。并且在程序暂停运行时,也可以查询保存在存储地址中的运行数据,并输出给用户。优选地,还可以在第一统计代码的最后添加跳转指令,即运行完第一统计代码后,跳转执行待监测函数的主体第一条指令,以保证待监测函数的正常运行,提高程序监测的可靠性和稳定性。Specifically, when the program is running, the first statistical code inserted before the first instruction of the function to be monitored generates the running data and is saved in the storage address corresponding to the first statistical code. By accessing the data stored in the storage address, the running data can be queried in real time while the program is running, and output to the user. And when the program is suspended, the running data stored in the storage address can also be queried and output to the user. Preferably, the jump instruction may be added at the end of the first statistical code, that is, after the first statistical code is run, the first instruction of the main body of the function to be monitored is jumped to ensure the normal operation of the function to be monitored, and the program is improved. Reliability and stability of monitoring.
举例来说,如图3B所示,图3B为待统计函数和非待统计函数的起始部分对比图。其中待统计函数即插入有第一统计代码的待监测函数,非待统计函数即未插入统计代码的非待监测函数。可见,该举例中的第一统计代码插入至待监测函数的第一条指令之前,即“获取统计数据地址”至“跳转到函数第一条指令处”,并且插入的第一统计代码对应的存储地址位于统计代码和待监测函数的第一条指令之间,即“此函数prologue所属统计数据”。For example, as shown in FIG. 3B, FIG. 3B is a comparison diagram of the initial part of the function to be statistically and the non-statistical function. The function to be monitored is inserted into the function to be monitored, and the non-waiting function is a non-to-be-monitored function in which the statistical code is not inserted. It can be seen that the first statistical code in the example is inserted before the first instruction of the function to be monitored, that is, “acquiring the statistical data address” to “jump to the first instruction of the function”, and the inserted first statistical code corresponds to The storage address is located between the statistical code and the first instruction of the function to be monitored, that is, "the statistical data of this function prologue".
302:将第二统计代码插入所述待监测函数的最后一条指令之前。302: Insert the second statistic code before the last instruction of the function to be monitored.
具体的,程序运行时,插入到待监测函数的最后一条指令之前的第二统计代码同样会生成运行数据并保存在第二统计代码对应的存储地址中。通过访问存储地址中存储的数据能够在程序运行的时候实时查询运行数据,并输出给用户。并且在程序暂停运行时,也可以查询保存在存储地址中的运行数据,并输出给用户。Specifically, when the program is running, the second statistical code inserted before the last instruction of the function to be monitored also generates the running data and stores it in the storage address corresponding to the second statistical code. By accessing the data stored in the storage address, the running data can be queried in real time while the program is running, and output to the user. And when the program is suspended, the running data stored in the storage address can also be queried and output to the user.
仍举例来说,如图3C所示,图3C为待统计函数和非待统计函数的结束部分对比图,其中待统计函数即插入有第二统计代码的待监测函数,非待统计函数即未插入统计代码的非待监测函数。可见,该举例中的第二统计代码 插入至待监测函数的最后一条指令之前,即“获取统计数据地址”至“修改后统计数据写回”,结合图3B,第二统计代码对应的存储地址同样位于第一统计代码和待监测函数的第一条指令之间,即图3B中“此函数epilogue所属统计数据”。For example, as shown in FIG. 3C, FIG. 3C is a comparison diagram of the end portion of the function to be statistically and the non-to-be-statistic function, wherein the function to be monitored is the function to be monitored inserted with the second statistical code, and the function to be monitored is not Insert a non-to-monitor function for the statistics code. Visible, the second statistic code in the example Before inserting the last instruction of the function to be monitored, that is, “acquiring the statistical data address” to “modifying the statistical data writing back”, in combination with FIG. 3B, the storage address corresponding to the second statistical code is also located in the first statistical code and the function to be monitored. Between the first instructions, that is, "the statistics of this function epilogue" in Figure 3B.
可以理解,在待监测函数的第一条指令之前与待监测函数的最后一条指令之前分别插入第一统计代码和第二统计代码,相应在运行该待监测函数时,第一统计代码会先被执行,在即将结束运行该待监测函数时,第二统计代码会被执行。具体如图3D所示,图3D为插入有第一统计代码和第二统计代码的待监测函数的代码示例图,参照附图,在执行待监测函数的函数体代码指令之前,会先执行第一统计代码,即“li t0,0x914”至“jal 0x91C”;在结束运行待监测函数之前,会执行第二统计代码,即“li t0,0x914”至“sw t1,(t0)”。因此,第一统计代码和第二统计代码生成的运行数据都能够准确地反映待监测函数的运行次数。并且进一步的,基于第一统计代码和第二统计代码的运行时刻,即其对应的存储地址中存储的数据发生变化的时刻,能够分析出更加丰富的统计数据,例如,待监测函数的运行时间。It can be understood that the first statistical code and the second statistical code are respectively inserted before the last instruction of the function to be monitored and before the last instruction of the function to be monitored, and correspondingly, when the function to be monitored is run, the first statistical code is first Execution, the second statistical code will be executed when the function to be monitored is about to end. Specifically, as shown in FIG. 3D, FIG. 3D is a code example diagram of a function to be monitored inserted with a first statistical code and a second statistical code. Referring to the drawing, before executing the function body code instruction of the function to be monitored, the first execution is performed. A statistical code, namely "li t0, 0x914" to "jal 0x91C"; before the end of running the function to be monitored, the second statistical code, "li t0, 0x914" to "sw t1, (t0)", is executed. Therefore, the running data generated by the first statistical code and the second statistical code can accurately reflect the running times of the function to be monitored. And further, based on the running time of the first statistical code and the second statistical code, that is, the time when the data stored in the corresponding storage address changes, more abundant statistical data can be analyzed, for example, the running time of the function to be monitored .
进一步的,如图3E所示,图3E为本发明实施例三提供的另一种程序运行监测方法的流程示意图,在图3A所示实施方式的基础上,该程序运行监测方法还可以包括:Further, as shown in FIG. 3E, FIG. 3E is a schematic flowchart of another method for monitoring program running according to Embodiment 3 of the present invention. The method for monitoring the running of the program may further include:
303:当所述第一统计代码对应的存储地址中运行次数发生变化时,记录当前的第一时刻。303: Record the current first time when the running times of the storage addresses corresponding to the first statistical code change.
304:当所述第二统计代码对应的存储地址中运行次数发生变化时,记录当前的第二时刻。304: Record the current second time when the running times of the storage addresses corresponding to the second statistical code change.
305:输出所述待监测函数的运行时间,所述运行时间为所述第一时刻和所述第二时刻之差。305: Output a running time of the function to be monitored, where the running time is a difference between the first time and the second time.
程序运行时,在进入待监测函数时,会执行第一统计代码,从而自动修改第一统计代码对应的存储地址中的运行数据;在离开待监测函数前,会执行第二统计代码,从而自动修改第二统计代码对应的存储地址中的运行数据。基于上述原理,可以在第一统计代码和第二统计代码对应的存储地址设置观察点,用于当地址中存储的数据发生变化时,记录变化的时刻。具体的,当第一统计代码对应的存储地址中的数据发生变化,即第一统计代码运行时, 记录当前的第一时刻,该第一时刻能够反映第一统计代码所在的待监测函数的起始运行时刻。当第二统计代码对应的存储地址中的数据发生变化,即第二统计代码运行时,记录当前的第二时刻,该第二时刻能够反映第二统计代码所在的待监测函数的结束运行时刻。根据待监测函数的起始运行时刻和结束运行时刻即可获得待监测函数的运行时间。When the program is running, when entering the function to be monitored, the first statistical code is executed, thereby automatically modifying the running data in the storage address corresponding to the first statistical code; before leaving the function to be monitored, the second statistical code is executed, thereby automatically Modify the running data in the storage address corresponding to the second statistical code. Based on the above principle, an observation point may be set at a storage address corresponding to the first statistical code and the second statistical code, and used to record the changed time when the data stored in the address changes. Specifically, when the data in the storage address corresponding to the first statistical code changes, that is, when the first statistical code is running, Recording the current first moment, the first moment can reflect the initial running time of the function to be monitored where the first statistical code is located. When the data in the storage address corresponding to the second statistical code changes, that is, when the second statistical code is running, the current second time is recorded, and the second time can reflect the ending running time of the to-be-monitored function where the second statistical code is located. The running time of the function to be monitored can be obtained according to the initial running time and the ending running time of the function to be monitored.
本实施例提供的程序运行监测方法,在待监测函数的起始和结束处分别插入统计代码,记录统计代码运行的时刻,并根据两时刻之间的时差获得待监测函数的运行时间,实现数据统计的进一步扩展,丰富数据内容。The program running monitoring method provided in this embodiment inserts a statistical code at the beginning and the end of the function to be monitored, records the time when the statistical code is running, and obtains the running time of the function to be monitored according to the time difference between the two times, and realizes the data. The statistics are further expanded to enrich the data content.
总的来说,基于上述各实施例的方案,能够实现以下方案:In general, based on the solutions of the above embodiments, the following solutions can be implemented:
1)程序运行或暂停运行时,获取所有待监测函数中统计代码对应的存储地址。通过访问存储地址中的数据,输出待监测函数的运行次数等。1) When the program is running or paused, the storage address corresponding to the statistical code in all the functions to be monitored is obtained. By accessing the data in the storage address, the number of times the function to be monitored is run, and the like.
2)在待监测函数的起始和结束处插入统计代码。针对待监测函数中的这两个统计代码设置观察点,记录其对应的存储地址中数据变化的时刻,进而估算出待监测函数的运行时间。2) Insert a statistical code at the beginning and end of the function to be monitored. The observation points are set for the two statistical codes in the function to be monitored, and the time at which the data changes in the corresponding storage address is recorded, thereby estimating the running time of the function to be monitored.
可以理解,为了更清楚地理解本方案,上述实施例中统计代码和待监测程序的运行顺序均通过设定统计代码的插入位置实现。但在实际应用中,可以不限于上述方式,例如,统计代码的位置可以灵活设定,而通过在函数中加入跳转指令来确定统计代码相对待监测函数的执行顺序。例如,统计代码可以插入在待监测程序之后的某个地址,同时在待监测程序中插入一条跳转指令,该跳转指令用于指示跳转执行统计代码对应的地址,这样同样可以实现统计代码的运行数据与待监测函数的运行数据一致的效果,故本方案在具体实现时并不限于上述实施例中的具体实施方式。It can be understood that, in order to understand the solution more clearly, the running code of the statistical code and the program to be monitored in the above embodiment are implemented by setting the insertion position of the statistical code. However, in practical applications, it may not be limited to the above manner. For example, the position of the statistical code may be flexibly set, and the execution order of the statistical code relative to the function to be monitored is determined by adding a jump instruction to the function. For example, the statistical code can be inserted at an address after the program to be monitored, and a jump instruction is inserted into the program to be monitored, and the jump instruction is used to indicate the address corresponding to the jump execution statistical code, so that the statistical code can also be implemented. The operational data is consistent with the operational data of the function to be monitored. Therefore, the specific implementation is not limited to the specific implementation manner in the foregoing embodiments.
本申请提供的程序运行监测方法,在待监测函数中插入统计代码后,运行插入有统计代码的待监测函数,其中该统计代码被执行时,可以实时统计其自身的运行数据,并将该运行数据存储至对应的存储地址。由于该统计代码设置在待监测函数中,因此,该统计代码的运行数据能够准确真实地反映待监测函数的运行数据。本实施例提供的方案当需要对待监测函数进行程序监测时,只需运行插入有统计代码的待监测函数即可实现,无需提供专门的追踪装置且无需硬件支持,操作简便、结果准确、成本低。 The program running monitoring method provided by the present application, after inserting the statistical code in the function to be monitored, runs the function to be monitored inserted with the statistical code, wherein when the statistical code is executed, the running data of the self can be counted in real time, and the running is performed. The data is stored to the corresponding storage address. Since the statistical code is set in the function to be monitored, the running data of the statistical code can accurately and truly reflect the running data of the function to be monitored. The solution provided by this embodiment can be implemented by simply running a function to be monitored inserted with a statistical code when the program needs to be monitored. There is no need to provide a special tracking device and no hardware support, and the operation is simple, the result is accurate, and the cost is low. .
图4A为本发明实施例四提供的一种程序运行监测装置的结构示意图;参考附图4A可知,该程序运行监测装置用于方便准确低成本地实现对待监测函数的程序追踪,具体的,该程序运行监测装置包括:4A is a schematic structural diagram of a program operation monitoring apparatus according to Embodiment 4 of the present invention; as can be seen from FIG. 4A, the program operation monitoring apparatus is used to conveniently and accurately implement program tracking of a function to be monitored. Specifically, The program operation monitoring device includes:
编译模块41,用于在待监测函数中插入统计代码,其中,所述统计代码用于当其自身被运行时,将其运行数据存储至对应的存储地址;a compiling module 41, configured to insert a statistical code in the function to be monitored, wherein the statistical code is used to store its running data to a corresponding storage address when it is run by itself;
执行模块42,用于运行插入所述统计代码后的所述待监测函数,其中,所述待监测函数的运行数据为所述统计代码对应的存储地址中存储的运行数据。The execution module 42 is configured to run the to-be-monitored function after inserting the statistical code, where the running data of the function to be monitored is the running data stored in the storage address corresponding to the statistical code.
在实际应用中,该程序运行监测装置可以为存储有相关执行代码的介质,例如,U盘等;或者,该程序运行监测装置还可以为集成或安装有相关执行代码的实体装置,例如,芯片、智能终端、计算机等。本实施例对于各模块的具体实现形式和结构不做限定,本领域技术人员可以根据其实现的功能作用对其进行任意设置。In practical applications, the program running monitoring device may be a medium storing an associated execution code, such as a USB flash drive, etc.; or the program running monitoring device may also be a physical device integrated or installed with related execution code, for example, a chip. , smart terminals, computers, etc. The specific implementation form and structure of each module are not limited in this embodiment, and those skilled in the art can arbitrarily set them according to the functions they implement.
以实际场景举例来说:当需要对某程序进行程序监测时,可以先确定需要对该程序下的哪些函数进行运行数据的统计,相应的,编译模块41在这些函数中插入统计代码,执行模块42运行插入统计代码后的待监测函数。可以理解,在运行每个函数的同时,该函数中插入的统计代码同样会被运行,所以统计代码的运行数据能够准确反映函数的运行数据。For example, in the actual scenario, when it is necessary to perform program monitoring on a program, it may first determine which functions under the program need to run statistics on the running data. Accordingly, the compiling module 41 inserts statistical codes into the functions, and executes the module. 42 Run the function to be monitored after inserting the statistical code. It can be understood that the statistical code inserted in the function will also be run while running each function, so the running data of the statistical code can accurately reflect the running data of the function.
后续,当用户需要查询函数的运行数据时,可访问存储地址中的数据,获得运行数据输出给用户。相应的,如图4B所示,在实施例四的基础上,该程序运行监测装置还可以包括:获取模块43,用于获取待监测函数中插入的统计代码对应的存储地址;第一输出模块44,用于将所述存储地址中存储的运行数据作为所述待监测函数的运行数据输出。Subsequently, when the user needs to query the running data of the function, the data in the storage address can be accessed, and the running data is output to the user. Correspondingly, as shown in FIG. 4B, on the basis of the fourth embodiment, the program running monitoring apparatus may further include: an obtaining module 43, configured to acquire a storage address corresponding to the statistical code inserted in the function to be monitored; and the first output module 44. The operating data stored in the storage address is used as the running data of the function to be monitored.
进一步的,对某个程序进行程序运行监测时,可以只选取部分函数的统计数据进行统计。相应的,如图4C所示,在实施例四的基础上,编译模块41具体可以包括:Further, when performing program monitoring on a certain program, only statistical data of some functions may be selected for statistics. Correspondingly, as shown in FIG. 4C, on the basis of the fourth embodiment, the compiling module 41 may specifically include:
交互单元411,为程序中需要监测的源文件设置追踪编译选项;The interaction unit 411 sets a tracking compile option for the source files to be monitored in the program;
处理单元412,用于将设置有追踪编译选项的源文件中的所有函数作为 所述待监测函数;The processing unit 412 is configured to use all the functions in the source file set with the tracking compile option The function to be monitored;
处理单元412,还用于通过对所述程序进行编译,在每个所述待监测函数中插入统计代码。The processing unit 412 is further configured to insert a statistical code in each of the to-be-monitored functions by compiling the program.
具体的,交互单元411针对需要监测的函数所在的源文件设置追踪编译选项,设置方式有多种。处理单元412将设置有追踪编译选项对应的源文件下所有的函数作为待监测的函数,并对整个程序进行编译。具体的,处理单元412在对程序进行编译的过程中,对设置有追踪编译选项的源文件,在该源文件的所有函数中插入统计代码。Specifically, the interaction unit 411 sets a tracking compilation option for the source file where the function to be monitored is located, and the setting manner is various. The processing unit 412 sets all the functions under the source file corresponding to the tracking compile option as functions to be monitored, and compiles the entire program. Specifically, in the process of compiling the program, the processing unit 412 inserts a statistical code into all the functions of the source file for the source file provided with the tracking compile option.
本实施方式,通过设置追踪编译选项确定需要进行运行数据统计的函数范围,在编译程序时在设置有追踪编译选项的函数中插入统计代码,从而快速便捷地确定需要插入统计代码的函数,提高处理的效率。In this embodiment, the function range of the running data statistics is determined by setting the tracking compile option, and the statistical code is inserted in the function that sets the tracking compiling option when the program is compiled, so that the function that needs to insert the statistical code is quickly and conveniently determined, and the processing is improved. s efficiency.
另外,本方案中的统计代码运行时执行的流程可以通过多种方式实现。可选的,如图4D所示,在实施例四的基础上,所述运行数据包括运行次数;相应的,执行模块42包括:In addition, the flow of the statistical code runtime execution in this scenario can be implemented in a variety of ways. Optionally, as shown in FIG. 4D, on the basis of Embodiment 4, the running data includes a running number; and correspondingly, the executing module 42 includes:
读取单元421,用于获取所述统计代码对应的存储地址中当前存储的运行次数;The reading unit 421 is configured to acquire the currently stored running times in the storage address corresponding to the statistical code;
计算单元422,用于将当前存储的运行次数加1,获得计算结果;The calculating unit 422 is configured to add 1 to the currently stored running times to obtain a calculation result;
更新单元423,用于将所述存储地址中当前存储的运行次数更新为所述计算结果;The updating unit 423 is configured to update the currently stored running times in the storage address to the calculation result;
处理单元424,用于运行除所述统计代码外的所述待监测函数。The processing unit 424 is configured to run the to-be-monitored function except the statistical code.
具体的,读取单元421获取存储地址中的运行次数,计算单元422计算存储地址中存储的运行次数加1后的结果,更新单元423将存储地址中的数据更新为计算结果,处理单元424运行统计代码以外的待监测函数。Specifically, the reading unit 421 acquires the number of operations in the storage address, the calculating unit 422 calculates the result of adding 1 to the running number stored in the storage address, and the updating unit 423 updates the data in the storage address to the calculation result, and the processing unit 424 operates. The function to be monitored other than the statistical code.
通过上述实施方式,在函数运行的过程中即可自动完成运行数据的统计和存储,无需增加任何硬件,单纯通过程序的运行即可统计运行数据。Through the above implementation manner, the statistics and storage of the running data can be automatically completed in the process of running the function, and no need to add any hardware, and the running data can be counted simply by running the program.
本实施例提供的程序运行监测装置,在待监测函数中插入统计代码后,运行插入有统计代码的待监测函数,其中该统计代码被执行时,可以实时统计其自身的运行数据,并将该运行数据存储至对应的存储地址。由于该统计代码设置在待监测函数中,因此,该统计代码的运行数据能够准确真实地反映待监测函数的运行数据。本实施例提供的方案当需要对待监测函数进行程 序监测时,只需运行插入有统计代码的待监测函数即可实现,无需提供专门的追踪装置且无需硬件支持,操作简便、结果准确、成本低。The program running monitoring device provided by the embodiment, after inserting the statistical code in the function to be monitored, runs a function to be monitored inserted with a statistical code, wherein when the statistical code is executed, the running data of the self can be counted in real time, and the Run the data store to the corresponding storage address. Since the statistical code is set in the function to be monitored, the running data of the statistical code can accurately and truly reflect the running data of the function to be monitored. The solution provided in this embodiment needs to be performed on the function to be monitored. In the case of sequence monitoring, it is only necessary to run the function to be monitored inserted with the statistical code, without providing a special tracking device and no hardware support, the operation is simple, the result is accurate, and the cost is low.
为了在程序运行过程中记录运行数据,需要为统计代码指定存储地址。相应的,如图5A所示,图5A为本发明实施例五提供的一种程序运行监测装置的结构示意图;参考附图5A,在实施例四的基础上,该程序运行监测装置还包括:In order to record the running data during the running of the program, you need to specify the storage address for the statistical code. Correspondingly, as shown in FIG. 5A, FIG. 5A is a schematic structural diagram of a program operation monitoring apparatus according to Embodiment 5 of the present invention. Referring to FIG. 5A, the program operation monitoring apparatus further includes:
指定模块51,用于为所述待监测函数中的所述统计代码指定对应的存储地址。The specifying module 51 is configured to specify a corresponding storage address for the statistical code in the function to be monitored.
具体的,为统计代码指定的存储地址用于存储该统计代码的运行数据。Specifically, the storage address specified for the statistical code is used to store the operational data of the statistical code.
作为一种可实施的方式,所述存储地址可以位于程序的代码段。如图5B所示,图5B为本发明实施例五提供的另一种程序运行监测装置的结构示意图,在图5A所示实施方式的基础上,指定模块51包括:As an implementable manner, the storage address can be located in a code segment of the program. As shown in FIG. 5B, FIG. 5B is a schematic structural diagram of another program running monitoring apparatus according to Embodiment 5 of the present invention. On the basis of the embodiment shown in FIG. 5A, the specifying module 51 includes:
偏移单元511,用于根据预设的偏移量,在所述待监测函数所在程序的代码段中,为所述统计代码指定对应的存储地址,所述存储地址至所述待监测函数的入口地址的偏移量为所述预设的偏移量。The offset unit 511 is configured to: in the code segment of the program where the function to be monitored is located, specify a corresponding storage address, where the storage address is to the function to be monitored, according to a preset offset The offset of the entry address is the preset offset.
具体的,偏移单元511可以从程序的代码段中指定统计代码对应的存储地址。当存储地址位于程序的代码段时,针对程序中的每个函数,偏移单元511将该函数的入口地址作为起始地址,根据偏移量,指定待监测函数中插入的统计代码对应的存储地址。可选的,当每个待监测函数中插入的统计代码数量为多个时,偏移单元511可以针对这多个统计代码设定不同的偏移量。Specifically, the offset unit 511 can specify a storage address corresponding to the statistical code from the code segment of the program. When the storage address is located in the code segment of the program, for each function in the program, the offset unit 511 uses the entry address of the function as the start address, and according to the offset, specifies the storage corresponding to the statistical code inserted in the function to be monitored. address. Optionally, when the number of statistical codes inserted in each function to be monitored is multiple, the offset unit 511 may set different offsets for the plurality of statistical codes.
通过上述实施方式,将统计代码对应的存储地址设置在程序的代码段中,通过统一定义起始地址和偏移量来确定每个统计代码对应的存储地址,基于上述实施方式,只需要存储一个起始地址和一个偏移量即可按照一定的规则确定各统计代码对应的存储地址,从而减少数据的处理要求和存储要求。Through the above embodiment, the storage address corresponding to the statistical code is set in the code segment of the program, and the storage address corresponding to each statistical code is determined by uniformly defining the starting address and the offset. According to the above embodiment, only one storage is needed. The starting address and an offset can determine the storage address corresponding to each statistical code according to certain rules, thereby reducing data processing requirements and storage requirements.
作为另一种可实施的方式,所述存储地址可以位于程序的数据段。如图5C所示,图5C为本发明实施例五提供的又一种程序运行监测装置的结构示意图,在图5A所示实施方式的基础上,指定模块51包括:As another implementable manner, the storage address may be located in a data segment of the program. As shown in FIG. 5C, FIG. 5C is a schematic structural diagram of still another program running monitoring apparatus according to Embodiment 5 of the present invention. On the basis of the embodiment shown in FIG. 5A, the specifying module 51 includes:
分配单元512,用于在所述待监测函数所在程序的数据段中,为所述所述待监测函数中的所述统计代码指定对应的存储地址; The allocating unit 512 is configured to: in the data segment of the program where the function to be monitored is located, specify a corresponding storage address for the statistical code in the to-be-monitored function;
存储单元513,用于存储所述存储地址与所述统计代码之间的对应关系。The storage unit 513 is configured to store a correspondence between the storage address and the statistical code.
具体的,指定模块51还可以从程序的数据段中指定统计代码对应的存储地址。分配单元512在数据段中指定统计代码对应的存储地址的同时,存储单元513规划相应用于存放各待监测函数中的统计代码与该统计代码对应的存储地址之间的映射关系的内存空间。Specifically, the specifying module 51 may also specify a storage address corresponding to the statistical code from the data segment of the program. The allocating unit 512 specifies the storage address corresponding to the statistical code in the data segment, and the storage unit 513 plans a memory space corresponding to the mapping relationship between the statistical code in each function to be monitored and the storage address corresponding to the statistical code.
通过上述实施方式,将统计代码对应的存储地址设置在程序的数据段中,通过维护各函数中插入的统计代码与存储地址之间的对应的关系来确定每个统计代码对应的存储地址,基于上述实施方式,能够提高地址指定的灵活性。Through the above implementation manner, the storage address corresponding to the statistical code is set in the data segment of the program, and the storage address corresponding to each statistical code is determined by maintaining the corresponding relationship between the statistical code inserted in each function and the storage address, based on In the above embodiment, the flexibility of address designation can be improved.
本实施例提供的程序运行监测装置,提供了多种为统计代码指定存储地址的实施方式,各实施方式可以分别单独实施也可以结合实施,实际应用中,可以根据不同情况确定采用不同的指定方式为统计代码指定对应的存储地址。The program running monitoring apparatus provided in this embodiment provides a plurality of implementation manners for specifying a storage address for a statistical code. Each implementation manner may be implemented separately or in combination. In actual applications, different designation manners may be determined according to different situations. Specify the corresponding storage address for the statistics code.
本方案中,对于单个待监测函数来说,其中插入的统计代码的数量可以为一个或多个。图6A为本发明实施例六提供的一种程序运行监测装置的结构示意图,如图6A所示,在前述任一实施例的基础上,编译模块41包括:In this solution, for a single function to be monitored, the number of statistical codes inserted therein may be one or more. FIG. 6A is a schematic structural diagram of a program operation monitoring apparatus according to Embodiment 6 of the present invention. As shown in FIG. 6A, on the basis of any of the foregoing embodiments, the compiling module 41 includes:
第一编译单元413,用于将第一统计代码插入所述待监测函数的第一条指令之前;a first compiling unit 413, configured to insert the first statistic code before the first instruction of the function to be monitored;
第二编译单元414,用于将第二统计代码插入所述待监测函数的最后一条指令之前。The second compiling unit 414 is configured to insert the second statistic code before the last instruction of the function to be monitored.
具体的,程序运行时,第一编译单元413插入到待监测函数的第一条指令之前的第一统计代码会生成运行数据并保存在第一统计代码对应的存储地址中。第二编译单元414插入到待监测函数的最后一条指令之前的第二统计代码同样会生成运行数据并保存在第二统计代码对应的存储地址中。通过访问存储地址中存储的数据能够在程序运行或暂停运行时,查询保存在存储地址中的运行数据,并输出给用户。Specifically, when the program is running, the first statistical code inserted by the first compiling unit 413 before the first instruction of the function to be monitored generates the running data and is saved in the storage address corresponding to the first statistical code. The second statistical code inserted by the second compiling unit 414 before the last instruction of the function to be monitored also generates the running data and stores it in the storage address corresponding to the second statistical code. By accessing the data stored in the storage address, the running data stored in the storage address can be queried and output to the user when the program is running or paused.
实际应用中,本实施方式与前述实施例的方案结合实施时,例如在图4C所示实施方式的基础上结合实施时,处理单元412具体可以包括上述第一编译单元413和第二编译单元414。即处理单元412在每个待监测函数中插入执行代码的过程均可参照图6A所示的实施方式,即均插入第一统计代码和第二统计代码。 In the actual application, when the embodiment is implemented in combination with the solution of the foregoing embodiment, for example, when the implementation is performed on the basis of the embodiment shown in FIG. 4C, the processing unit 412 may specifically include the first compiling unit 413 and the second compiling unit 414. . That is, the process of the processing unit 412 inserting the execution code in each function to be monitored may refer to the embodiment shown in FIG. 6A, that is, the first statistical code and the second statistical code are both inserted.
进一步的,如图6B所示,在图6A所示实施方式的基础上,该程序运行监测装置还可以包括:Further, as shown in FIG. 6B, on the basis of the embodiment shown in FIG. 6A, the program operation monitoring device may further include:
记录模块61,用于当所述第一统计代码对应的存储地址中运行次数发生变化时,记录当前的第一时刻;The recording module 61 is configured to record the current first time when the running times of the storage addresses corresponding to the first statistical code change;
记录模块61,还用于当所述第二统计代码对应的存储地址中运行次数发生变化时,记录当前的第二时刻;The recording module 61 is further configured to: when the running times of the storage addresses corresponding to the second statistical code change, record the current second time;
第二输出模块62,用于输出所述待监测函数的运行时间,所述运行时间为所述第一时刻和所述第二时刻之差。The second output module 62 is configured to output a running time of the function to be monitored, where the running time is a difference between the first time and the second time.
程序运行过程中,当第一统计代码对应的存储地址中的数据发生变化时,记录模块61记录当前的第一时刻,该第一时刻能够反映第一统计代码所在的待监测函数的起始运行时刻。当第二统计代码对应的存储地址中的数据发生变化时,记录模块61记录当前的第二时刻,该第二时刻能够反映第二统计代码所在的待监测函数的结束运行时刻。第二输出模块62根据待监测函数的起始运行时刻和结束运行时刻即可获得待监测函数的运行时间。During the running of the program, when the data in the storage address corresponding to the first statistical code changes, the recording module 61 records the current first time, and the first time can reflect the initial running of the function to be monitored where the first statistical code is located. time. When the data in the storage address corresponding to the second statistical code changes, the recording module 61 records the current second time, which can reflect the end running time of the to-be-monitored function where the second statistical code is located. The second output module 62 can obtain the running time of the function to be monitored according to the initial running time and the ending running time of the function to be monitored.
本实施例提供的程序运行监测装置,在待监测函数的起始和结束处分别插入统计代码,记录统计代码运行的时刻,并根据两时刻之间的时差获得待监测函数的运行时间,实现数据统计的进一步扩展,丰富数据内容。The program running monitoring apparatus provided in this embodiment inserts a statistical code at the beginning and the end of the function to be monitored, records the time when the statistical code is running, and obtains the running time of the function to be monitored according to the time difference between the two times, and realizes the data. The statistics are further expanded to enrich the data content.
本实施例中各模块所实现方法步骤的具体实现过程以及实现效果与上述方法实施例中的具体实现过程以及实现效果相同,具体可参考前述方法实施例的内容。The specific implementation process and the implementation effect of the method steps implemented in each module in this embodiment are the same as the specific implementation process and the implementation effect in the foregoing method embodiments. For details, refer to the content of the foregoing method embodiments.
本申请提供的程序运行监测装置,在待监测函数中插入统计代码后,运行插入有统计代码的待监测函数,其中该统计代码被执行时,可以实时统计其自身的运行数据,并将该运行数据存储至对应的存储地址。由于该统计代码设置在待监测函数中,因此,该统计代码的运行数据能够准确真实地反映待监测函数的运行数据。本实施例提供的方案当需要对待监测函数进行程序监测时,只需运行插入有统计代码的待监测函数即可实现,无需提供专门的追踪装置且无需硬件支持,操作简便、结果准确、成本低。The program running monitoring device provided by the application, after inserting the statistical code in the function to be monitored, runs the function to be monitored inserted with the statistical code, wherein when the statistical code is executed, the running data of the self can be counted in real time, and the running is performed. The data is stored to the corresponding storage address. Since the statistical code is set in the function to be monitored, the running data of the statistical code can accurately and truly reflect the running data of the function to be monitored. The solution provided by this embodiment can be implemented by simply running a function to be monitored inserted with a statistical code when the program needs to be monitored. There is no need to provide a special tracking device and no hardware support, and the operation is simple, the result is accurate, and the cost is low. .
本发明实施例七还提供一种计算机存储介质,该计算机存储介质可以包括:U盘、移动硬盘、只读存储器(ROM,Read-Only Memory)、随机存取 存储器(RAM,Random Access Memory)、磁盘或者光盘等各种可以存储程序代码的介质,具体的,该计算机存储介质中存储有程序指令,程序指令用于上述实施例中的程序运行监测方法。The seventh embodiment of the present invention further provides a computer storage medium, which may include: a U disk, a mobile hard disk, a read-only memory (ROM), and random access. A medium for storing a program code, such as a memory (RAM), a magnetic disk, or an optical disk. Specifically, the computer storage medium stores program instructions, and the program instructions are used in the program operation monitoring method in the above embodiment.
本发明实施例八提供一种程序运行监测装置,该装置可以为安装有程序运行系统的终端设备,例如,手机、电脑、PAD、或者智能手表等等,该程序运行监测装置包括至少一个处理器和存储器,存储器用于存储计算机执行指令,处理器的个数可以为1个或多个,且可以单独或协同工作,处理器用于执行所述存储器存储的计算机执行指令,以实现上述实施例中的程序运行监测方法。Embodiment 8 of the present invention provides a program operation monitoring device, which may be a terminal device installed with a program running system, such as a mobile phone, a computer, a PAD, or a smart watch, etc., the program operation monitoring device includes at least one processor And a memory for storing computer execution instructions, the number of processors may be one or more, and may work separately or in cooperation, and the processor is configured to execute the computer-executed instructions of the memory storage to implement the above embodiment. The program runs monitoring methods.
以上各个实施例中的技术方案、技术特征在不相冲突的情况下均可以单独,或者进行组合,只要未超出本领域技术人员的认知范围,均属于本申请保护范围内的等同实施例。The technical solutions and the technical features in the above various embodiments may be used in the case of the present invention without departing from the scope of the present invention.
在本发明所提供的几个实施例中,应该理解到,所揭露的相关装置和方法,可以通过其它的方式实现。例如,以上所描述的装置实施例仅仅是示意性的,例如,所述模块或单元的划分,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式,例如多个单元或组件可以结合或者可以集成到另一个系统,或一些特征可以忽略,或不执行。另一点,所显示或讨论的相互之间的耦合或直接耦合或通信连接可以是通过一些接口,装置或单元的间接耦合或通信连接,可以是电性,机械或其它的形式。In the several embodiments provided by the present invention, it should be understood that the related apparatus and method disclosed may be implemented in other manners. For example, the device embodiments described above are merely illustrative. For example, the division of the modules or units is only a logical function division. In actual implementation, there may be another division manner, for example, multiple units or components may be used. Combinations can be integrated into another system, or some features can be ignored or not executed. In addition, the mutual coupling or direct coupling or communication connection shown or discussed may be an indirect coupling or communication connection through some interface, device or unit, and may be in an electrical, mechanical or other form.
所述作为分离部件说明的单元可以是或者也可以不是物理上分开的,作为单元显示的部件可以是或者也可以不是物理单元,即可以位于一个地方,或者也可以分布到多个网络单元上。可以根据实际的需要选择其中的部分或者全部单元来实现本实施例方案的目的。The units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, may be located in one place, or may be distributed to multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of the embodiment.
另外,在本发明各个实施例中的各功能单元可以集成在一个处理单元中,也可以是各个单元单独物理存在,也可以两个或两个以上单元集成在一个单元中。上述集成的单元既可以采用硬件的形式实现,也可以采用软件功能单元的形式实现。In addition, each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above integrated unit can be implemented in the form of hardware or in the form of a software functional unit.
所述集成的单元如果以软件功能单元的形式实现并作为独立的产品销售或使用时,可以存储在一个计算机可读取存储介质中。基于这样的理解,本发明的技术方案本质上或者说对现有技术做出贡献的部分或者该技术方案的 全部或部分可以以软件产品的形式体现出来,该计算机软件产品存储在一个存储介质中,包括若干指令用以使得计算机处理器(processor)执行本发明各个实施例所述方法的全部或部分步骤。而前述的存储介质包括:U盘、移动硬盘、只读存储器(ROM,Read-Only Memory)、随机存取存储器(RAM,Random Access Memory)、磁盘或者光盘等各种可以存储程序代码的介质。The integrated unit, if implemented in the form of a software functional unit and sold or used as a standalone product, may be stored in a computer readable storage medium. Based on such understanding, the technical solution of the present invention contributes in essence or to the prior art or the technical solution All or part of it may be embodied in the form of a software product stored in a storage medium comprising instructions for causing a computer processor to perform all or part of the steps of the methods described in various embodiments of the present invention. The foregoing storage medium includes: a U disk, a removable hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk, and the like, which can store program codes.
以上所述仅为本发明的实施例,并非因此限制本发明的专利范围,凡是利用本发明说明书及附图内容所作的等效结构或等效流程变换,或直接或间接运用在其他相关的技术领域,均同理包括在本发明的专利保护范围内。The above is only the embodiment of the present invention, and is not intended to limit the scope of the invention, and the equivalent structure or equivalent process transformation of the present invention and the contents of the drawings may be directly or indirectly applied to other related technologies. The fields are all included in the scope of patent protection of the present invention.
最后应说明的是:以上各实施例仅用以说明本发明的技术方案,而非对其限制;尽管参照前述各实施例对本发明进行了详细的说明,本领域的普通技术人员应当理解:其依然可以对前述各实施例所记载的技术方案进行修改,或者对其中部分或者全部技术特征进行等同替换;而这些修改或者替换,并不使相应技术方案的本质脱离本发明各实施例技术方案的范围。 Finally, it should be noted that the above embodiments are merely illustrative of the technical solutions of the present invention, and are not intended to be limiting; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art will understand that The technical solutions described in the foregoing embodiments may be modified, or some or all of the technical features may be equivalently replaced; and the modifications or substitutions do not deviate from the technical solutions of the embodiments of the present invention. range.

Claims (20)

  1. 一种程序运行监测方法,其特征在于,包括:A program operation monitoring method, comprising:
    在待监测函数中插入统计代码,其中,所述统计代码用于当其自身被运行时,将其运行数据存储至对应的存储地址;Inserting a statistical code into the function to be monitored, wherein the statistical code is used to store its running data to a corresponding storage address when it is run by itself;
    运行插入所述统计代码后的所述待监测函数,其中,所述待监测函数的运行数据为所述统计代码对应的存储地址中存储的运行数据。The function to be monitored after the insertion of the statistical code is executed, wherein the running data of the function to be monitored is the running data stored in the storage address corresponding to the statistical code.
  2. 根据权利要求1所述的方法,其特征在于,所述运行数据包括运行次数;所述运行插入所述统计代码后的所述待监测函数,包括:The method according to claim 1, wherein the running data includes a running number; the running to insert the statistical code to the monitored function comprises:
    获取所述统计代码对应的存储地址中当前存储的运行次数;Obtaining the currently stored running times in the storage address corresponding to the statistical code;
    将当前存储的运行次数加1,获得计算结果;Add 1 to the current stored running times to obtain the calculation result;
    将所述存储地址中当前存储的运行次数更新为所述计算结果;Updating the currently stored running times in the storage address to the calculation result;
    运行除所述统计代码外的所述待监测函数。The function to be monitored in addition to the statistical code is run.
  3. 根据权利要求1或2所述的方法,其特征在于,所述方法还包括:The method according to claim 1 or 2, wherein the method further comprises:
    为所述待监测函数中的所述统计代码指定对应的存储地址。Specifying a corresponding storage address for the statistical code in the function to be monitored.
  4. 根据权利要求3所述的方法,其特征在于,所述为所述待监测函数中的所述统计代码指定对应的存储地址,包括:The method according to claim 3, wherein the specifying a corresponding storage address for the statistical code in the function to be monitored comprises:
    根据预设的偏移量,在所述待监测函数所在程序的代码段中,为所述统计代码指定对应的存储地址,所述存储地址至所述待监测函数的入口地址的偏移量为所述预设的偏移量。Determining, according to a preset offset, a corresponding storage address for the statistical code in a code segment of the program where the function to be monitored is located, where the offset of the storage address to the entry address of the function to be monitored is The preset offset.
  5. 根据权利要求3所述的方法,其特征在于,所述为所述待监测函数中的所述统计代码指定对应的存储地址,包括:The method according to claim 3, wherein the specifying a corresponding storage address for the statistical code in the function to be monitored comprises:
    在所述待监测函数所在程序的数据段中,为所述所述待监测函数中的所述统计代码指定对应的存储地址;Specifying, in the data segment of the program where the function to be monitored is located, a corresponding storage address for the statistical code in the function to be monitored;
    存储所述存储地址与所述统计代码之间的对应关系。And storing a correspondence between the storage address and the statistical code.
  6. 根据权利要求1-5中任一项所述的方法,其特征在于,所述方法还包括:The method according to any one of claims 1 to 5, wherein the method further comprises:
    获取待监测函数中插入的统计代码对应的存储地址;Obtaining a storage address corresponding to the statistical code inserted in the function to be monitored;
    将所述存储地址中存储的运行数据作为所述待监测函数的运行数据输出。The operational data stored in the storage address is output as the operational data of the function to be monitored.
  7. 根据权利要求1-6中任一项所述的方法,其特征在于,所述在待监测 函数中插入统计代码,包括:Method according to any one of claims 1 to 6, wherein said to be monitored Insert statistical code into the function, including:
    将第一统计代码插入所述待监测函数的第一条指令之前;Inserting the first statistical code before the first instruction of the function to be monitored;
    将第二统计代码插入所述待监测函数的最后一条指令之前。Insert the second statistic code before the last instruction of the function to be monitored.
  8. 根据权利要求7所述的方法,其特征在于,所述方法还包括:The method of claim 7, wherein the method further comprises:
    当所述第一统计代码对应的存储地址中运行次数发生变化时,记录当前的第一时刻;When the number of times of running in the storage address corresponding to the first statistical code changes, the current first time is recorded;
    当所述第二统计代码对应的存储地址中运行次数发生变化时,记录当前的第二时刻;When the running times of the storage addresses corresponding to the second statistical code change, the current second time is recorded;
    输出所述待监测函数的运行时间,所述运行时间为所述第一时刻和所述第二时刻之差。And outputting a running time of the function to be monitored, where the running time is a difference between the first time and the second time.
  9. 根据权利要求1-8中任一项所述的方法,其特征在于,所述在待监测函数中插入统计代码,包括:The method according to any one of claims 1-8, wherein the inserting the statistical code in the function to be monitored comprises:
    为程序中需要监测的源文件设置追踪编译选项;Set trace compile options for source files that need to be monitored in the program;
    将设置有追踪编译选项的源文件中的所有函数作为所述待监测函数;All functions in the source file set with the trace compile option are set as the function to be monitored;
    通过对所述程序进行编译,在每个所述待监测函数中插入统计代码。A statistical code is inserted in each of the functions to be monitored by compiling the program.
  10. 一种程序运行监测装置,其特征在于,包括:A program operation monitoring device, comprising:
    编译模块,用于在待监测函数中插入统计代码,其中,所述统计代码用于当其自身被运行时,将其运行数据存储至对应的存储地址;a compiling module, configured to insert a statistical code in the function to be monitored, wherein the statistical code is used to store its running data to a corresponding storage address when it is run by itself;
    执行模块,用于运行插入所述统计代码后的所述待监测函数,其中,所述待监测函数的运行数据为所述统计代码对应的存储地址中存储的运行数据。An execution module, configured to run the to-be-monitored function after inserting the statistical code, where the running data of the function to be monitored is running data stored in a storage address corresponding to the statistical code.
  11. 根据权利要求10所述的装置,其特征在于,所述运行数据包括运行次数;所述执行模块包括:The device according to claim 10, wherein the running data comprises a running number; the executing module comprises:
    读取单元,用于获取所述统计代码对应的存储地址中当前存储的运行次数;a reading unit, configured to acquire a running time currently stored in a storage address corresponding to the statistical code;
    计算单元,用于将当前存储的运行次数加1,获得计算结果;a calculation unit, configured to add 1 to the currently stored running times to obtain a calculation result;
    更新单元,用于将所述存储地址中当前存储的运行次数更新为所述计算结果;An update unit, configured to update a current running number of times in the storage address to the calculation result;
    处理单元,用于运行除所述统计代码外的所述待监测函数。a processing unit, configured to run the to-be-monitored function in addition to the statistical code.
  12. 根据权利要求10或11所述的装置,其特征在于,所述装置还包括:The device according to claim 10 or 11, wherein the device further comprises:
    指定模块,用于为所述待监测函数中的所述统计代码指定对应的存储地 址。a specifying module, configured to specify a corresponding storage location for the statistical code in the function to be monitored site.
  13. 根据权利要求12所述的装置,其特征在于,所述指定模块包括:The apparatus according to claim 12, wherein said specifying module comprises:
    偏移单元,用于根据预设的偏移量,在所述待监测函数所在程序的代码段中,为所述统计代码指定对应的存储地址,所述存储地址至所述待监测函数的入口地址的偏移量为所述预设的偏移量。An offset unit, configured to specify, according to a preset offset, a corresponding storage address for the statistical code in a code segment of the program where the function to be monitored is located, where the storage address is to the entry of the function to be monitored The offset of the address is the preset offset.
  14. 根据权利要求12所述的装置,其特征在于,所述指定模块包括:The apparatus according to claim 12, wherein said specifying module comprises:
    分配单元,用于在所述待监测函数所在程序的数据段中,为所述所述待监测函数中的所述统计代码指定对应的存储地址;An allocating unit, configured to specify a corresponding storage address for the statistical code in the to-be-monitored function in a data segment of the program where the function to be monitored is located;
    存储单元,用于存储所述存储地址与所述统计代码之间的对应关系。a storage unit, configured to store a correspondence between the storage address and the statistical code.
  15. 根据权利要求10-14中任一项所述的装置,其特征在于,所述装置还包括:The device according to any one of claims 10 to 14, wherein the device further comprises:
    获取模块,用于获取待监测函数中插入的统计代码对应的存储地址;An obtaining module, configured to obtain a storage address corresponding to the statistical code inserted in the function to be monitored;
    第一输出模块,用于将所述存储地址中存储的运行数据作为所述待监测函数的运行数据输出。The first output module is configured to output the running data stored in the storage address as the running data of the function to be monitored.
  16. 根据权利要求10-15中任一项所述的装置,其特征在于,所述编译模块包括:The apparatus according to any one of claims 10-15, wherein the compiling module comprises:
    第一编译单元,用于将第一统计代码插入所述待监测函数的第一条指令之前;a first compiling unit, configured to insert the first statistical code before the first instruction of the function to be monitored;
    第二编译单元,用于将第二统计代码插入所述待监测函数的最后一条指令之前。a second compiling unit, configured to insert the second statistical code before the last instruction of the function to be monitored.
  17. 根据权利要求16所述的装置,其特征在于,所述装置还包括:The device according to claim 16, wherein the device further comprises:
    记录模块,用于当所述第一统计代码对应的存储地址中运行次数发生变化时,记录当前的第一时刻;a recording module, configured to record a current first time when a running time changes in a storage address corresponding to the first statistical code;
    所述记录模块,还用于当所述第二统计代码对应的存储地址中运行次数发生变化时,记录当前的第二时刻;The recording module is further configured to: when the number of times of running in the storage address corresponding to the second statistical code changes, record the current second time;
    第二输出模块,用于输出所述待监测函数的运行时间,所述运行时间为所述第一时刻和所述第二时刻之差。And a second output module, configured to output a running time of the function to be monitored, where the running time is a difference between the first time and the second time.
  18. 根据权利要求10-17中任一项所述的装置,其特征在于,所述编译模块包括:The apparatus according to any one of claims 10-17, wherein the compiling module comprises:
    交互单元,为程序中需要监测的源文件设置追踪编译选项; An interactive unit that sets trace compile options for source files that need to be monitored in the program;
    处理单元,用于将设置有追踪编译选项的源文件中的所有函数作为所述待监测函数;a processing unit, configured to use, as the function to be monitored, all functions in a source file set with a tracking compile option;
    所述处理单元,还用于通过对所述程序进行编译,在每个所述待监测函数中插入统计代码。The processing unit is further configured to insert a statistical code in each of the to-be-monitored functions by compiling the program.
  19. 一种程序运行监测装置,其特征在于,包括:至少一个处理器和存储器;A program operation monitoring device, comprising: at least one processor and a memory;
    所述存储器存储计算机执行指令;所述至少一个处理器执行所述存储器存储的计算机执行指令,以执行如权利要求1-9中任一项所述的方法。The memory storage computer executes instructions; the at least one processor executes the computer-executed instructions stored by the memory to perform the method of any of claims 1-9.
  20. 一种计算机存储介质,其特征在于,该计算机存储介质中存储有程序指令,所述程序指令被处理器执行时实现权利要求1-9中任一项所述的方法。 A computer storage medium, characterized in that the computer storage medium stores program instructions, the program instructions being executed by a processor to implement the method of any one of claims 1-9.
PCT/CN2017/105899 2017-10-12 2017-10-12 Computer storage medium, and program running monitoring method and device WO2019071535A1 (en)

Priority Applications (2)

Application Number Priority Date Filing Date Title
PCT/CN2017/105899 WO2019071535A1 (en) 2017-10-12 2017-10-12 Computer storage medium, and program running monitoring method and device
CN201780001861.3A CN109923526A (en) 2017-10-12 2017-10-12 Computer storage medium, program operational monitoring method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
PCT/CN2017/105899 WO2019071535A1 (en) 2017-10-12 2017-10-12 Computer storage medium, and program running monitoring method and device

Publications (1)

Publication Number Publication Date
WO2019071535A1 true WO2019071535A1 (en) 2019-04-18

Family

ID=66101140

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2017/105899 WO2019071535A1 (en) 2017-10-12 2017-10-12 Computer storage medium, and program running monitoring method and device

Country Status (2)

Country Link
CN (1) CN109923526A (en)
WO (1) WO2019071535A1 (en)

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112882912B (en) * 2021-02-01 2022-10-25 华东师范大学 Function runtime measurement method applied to parallel scientific computation program
CN115809172A (en) * 2021-09-13 2023-03-17 上海华为技术有限公司 Software monitoring method and related device
CN115576586B (en) * 2022-11-15 2023-04-07 四川蜀天信息技术有限公司 Method for intelligently operating and maintaining server-side program of server

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101477491A (en) * 2009-01-16 2009-07-08 杭州华三通信技术有限公司 Method and apparatus for function running state statistics
CN103473168A (en) * 2013-09-12 2013-12-25 中国科学院声学研究所 Statistical method for hotspot program
CN105740120A (en) * 2014-12-11 2016-07-06 中国科学院软件研究所 Shared memory based real-time monitoring and control method and system for software running process
CN107168857A (en) * 2017-03-31 2017-09-15 武汉斗鱼网络科技有限公司 The method and component of a kind of function call in statistics application program

Family Cites Families (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
EP3086233B1 (en) * 2015-04-23 2020-05-06 CODESYS Holding GmbH Method and system for measuring a runtime by means of watchpoints
EP3179371A1 (en) * 2015-12-08 2017-06-14 Gilwa GmbH embedded systems Method and device for non-intrusively collecting function trace data
CN106649063B (en) * 2016-11-22 2020-11-17 腾讯科技(深圳)有限公司 Method and system for monitoring time-consuming data during program operation

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101477491A (en) * 2009-01-16 2009-07-08 杭州华三通信技术有限公司 Method and apparatus for function running state statistics
CN103473168A (en) * 2013-09-12 2013-12-25 中国科学院声学研究所 Statistical method for hotspot program
CN105740120A (en) * 2014-12-11 2016-07-06 中国科学院软件研究所 Shared memory based real-time monitoring and control method and system for software running process
CN107168857A (en) * 2017-03-31 2017-09-15 武汉斗鱼网络科技有限公司 The method and component of a kind of function call in statistics application program

Also Published As

Publication number Publication date
CN109923526A (en) 2019-06-21

Similar Documents

Publication Publication Date Title
US10235273B2 (en) Indexing a trace by insertion of key frames for replay responsiveness
US9959194B1 (en) Indexing a trace by insertion of memory snapshots for replay responsiveness
ES2291278T3 (en) APPLIANCE AND METHOD FOR CATALOGING SYMBOLIC DATA FOR USE IN COMPUTER PROGRAM OPERATION ANALYSIS.
Gottschalk et al. Removing energy code smells with reengineering services
US20130086598A1 (en) Generating compiled code that indicates register liveness
US9626170B2 (en) Method and computer program product for disassembling a mixed machine code
US20110154299A1 (en) Apparatus and method for executing instrumentation code
CA3043127C (en) Data prefetching method, apparatus, and system
US9009679B2 (en) Determining snapshot placement
WO2019071535A1 (en) Computer storage medium, and program running monitoring method and device
WO2018040270A1 (en) Method and device for loading linux-system elf file in windows system
US20150269052A1 (en) Method and apparatus for supporting performance analysis
WO2020259163A1 (en) Device deployment method and apparatus, device running method, and electronic device
US20190139183A1 (en) Techniques for multi-mode graphics processing unit profiling
US20110029953A1 (en) System and Method for Scalable Handling of Debug Information
US20180196669A1 (en) Reduced save and restore instructions for call-clobbered registers
US9047403B2 (en) Debugger with previous version feature
CN113138922A (en) Method for parametrically reading Excel test data based on TestNG
KR20160098794A (en) Apparatus and method for skeleton code generation based on device program structure modeling
WO2020073200A1 (en) Program debugging method and system
CN112631949B (en) Debugging method and device, computer equipment and storage medium
CN108304294B (en) Real-time frame number monitoring method, storage medium, equipment and system for IOS application
US9489246B2 (en) Method and device for determining parallelism of tasks of a program
CN114579131A (en) Method, device and system for acquiring hardware performance data
CN112612477A (en) Service implementation method, device, equipment and storage medium

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 17928631

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 17928631

Country of ref document: EP

Kind code of ref document: A1