CN109426504A - Processing method, device, electronic equipment and the storage medium of program - Google Patents

Processing method, device, electronic equipment and the storage medium of program Download PDF

Info

Publication number
CN109426504A
CN109426504A CN201710758336.8A CN201710758336A CN109426504A CN 109426504 A CN109426504 A CN 109426504A CN 201710758336 A CN201710758336 A CN 201710758336A CN 109426504 A CN109426504 A CN 109426504A
Authority
CN
China
Prior art keywords
information
program
jump instruction
compiler
calling
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN201710758336.8A
Other languages
Chinese (zh)
Other versions
CN109426504B (en
Inventor
余银
彭飞
黄文君
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Loongson Technology Corp Ltd
Original Assignee
Loongson Technology Corp Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Loongson Technology Corp Ltd filed Critical Loongson Technology Corp Ltd
Priority to CN201710758336.8A priority Critical patent/CN109426504B/en
Publication of CN109426504A publication Critical patent/CN109426504A/en
Application granted granted Critical
Publication of CN109426504B publication Critical patent/CN109426504B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/41Compilation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/362Software debugging
    • G06F11/3644Software debugging by instrumenting at runtime

Landscapes

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

Abstract

The embodiment of the invention provides a kind of processing method of program, device, electronic equipment and storage mediums, it is related to Just-In-Time technical field, this method comprises: in the compilation process of program, according to the jump instruction in described program, corresponding compiler recalls information is recorded, the compiler recalls information is used to determine the corresponding each call relation called between function of the jump instruction;During executing the jump instruction, corresponding execution stream information, the execution track for executing stream information and being used to determine the jump instruction are recorded;According to the compiler recalls information and the execution stream information, the Debugging message of described program is generated.Through the embodiment of the present invention, can program run failure when based on the Debugging message of program come finder Error Location, to promote the debugging efficiency of program.

Description

Program processing method, program processing device, electronic device and storage medium
Technical Field
The present invention relates to the field of just-in-time compilation technologies, and in particular, to a method and an apparatus for processing a program, an electronic device, and a storage medium.
Background
As Just-in-time (JIT) compilers are increasingly used, JS engines, Java virtual machines, and so on exist in more and more software.
In the early stage of development of the JIT compiler, the JIT compiler generator often fails to run the program, and a common error is that the JIT compiler generator accesses an illegal memory. Currently, the common processing method is to find an entry by experience and then perform single-step debugging on the JIT compiler-generated program, which is inefficient in debugging.
Disclosure of Invention
In view of the above problems, embodiments of the present invention are proposed to provide a processing method of a program that overcomes or at least partially solves the above problems.
Correspondingly, the embodiment of the invention also provides a program processing device, an electronic device and a storage medium, which are used for ensuring the realization and the application of the method.
In order to solve the above problem, an embodiment of the present invention discloses a processing method for a program, where the program is used to generate a just-in-time compiler, and the method includes:
in the compiling process of the program, recording corresponding compiler calling information according to a jump instruction in the program, wherein the compiler calling information is used for determining the calling relationship among calling functions corresponding to the jump instruction;
recording corresponding execution stream information in the process of executing the jump instruction, wherein the execution stream information is used for determining an execution track of the jump instruction;
and generating debugging information of the program according to the compiler calling information and the execution flow information.
Optionally, the recording, according to the jump instruction in the program, corresponding compiler invocation information includes: when a jump instruction is compiled, generating a function call instruction corresponding to the jump instruction, wherein a function parameter called by the function call instruction comprises identification information of the jump instruction; and acquiring compiler calling information corresponding to the jump instruction according to the identification information.
Optionally, in the process of executing the jump instruction, recording corresponding execution stream information, including: when each jump instruction in the program is executed, the current memory position of each jump instruction is respectively obtained; and recording corresponding execution stream information according to the memory position.
Optionally, the generating corresponding debugging information according to the compiler calling information and the execution flow information includes: determining a corresponding relation between the compiler calling information and the execution flow information based on the identification information; and generating corresponding debugging information based on the corresponding relation, wherein the debugging information is used for determining the error position of the program operation failure.
Optionally, the method further comprises: setting a memory area according to preset distribution information, wherein the memory area is used for storing data information, and the data information comprises at least one of the following: the compiler calling information, the execution flow information and the debugging information; and outputting based on the data information in the memory area after the program fails to run.
The embodiment of the invention also discloses a processing device of a program, wherein the program is used for generating the just-in-time compiler, and the device comprises:
the calling information recording module is used for recording corresponding compiler calling information according to a jump instruction in the program in the compiling process of the program, and the compiler calling information is used for determining the calling relationship among calling functions corresponding to the jump instruction;
the execution stream information recording module is used for recording corresponding execution stream information in the process of executing the jump instruction, and the execution stream information is used for determining the execution track of the jump instruction;
and the result information generating module is used for generating debugging information of the program according to the compiler calling information and the execution flow information.
Optionally, the calling information recording module includes:
the calling instruction generation submodule is used for generating a function calling instruction corresponding to the jump instruction when the jump instruction is compiled, and a function parameter called by the function calling instruction comprises identification information of the jump instruction;
and the information acquisition submodule is used for acquiring compiler calling information corresponding to the jump instruction according to the identification information.
Optionally, the execution stream information recording module includes:
the memory location acquisition submodule is used for respectively acquiring the memory location of each jump instruction when each jump instruction in the program is executed;
and the execution stream information recording submodule is used for recording corresponding execution stream information according to the memory position.
Optionally, the result information generating module includes:
the corresponding relation creating submodule is used for determining the corresponding relation between the compiler calling information and the execution flow information based on the identification information;
and the result information generation submodule is used for generating corresponding debugging information based on the corresponding relation, wherein the debugging information is used for determining the error position of the program operation failure.
Optionally, the apparatus further comprises: the memory area setting module is configured to set a memory area according to preset allocation information, where the memory area is used to store data information, and the data information includes at least one of the following: the compiler calling information, the execution flow information and the debugging information; and the data information printing module is used for printing based on the data information in the memory area after the program operation fails.
An embodiment of the present invention also discloses an electronic device comprising a memory, and one or more programs, wherein the one or more programs are stored in the memory and configured to be executed by the one or more processors, the one or more programs including instructions for: in the compiling process of the program, recording corresponding compiler calling information according to a jump instruction in the program, wherein the compiler calling information is used for determining the calling relationship among calling functions corresponding to the jump instruction; recording corresponding execution stream information in the process of executing the jump instruction, wherein the execution stream information is used for determining an execution track of the jump instruction; and generating debugging information of the program according to the compiler calling information and the execution flow information.
The embodiment of the invention also discloses a readable storage medium, and when instructions in the storage medium are executed by a processor of the electronic equipment, the electronic equipment can execute the processing method of one or more programs in the embodiment of the invention.
The embodiment of the invention has the following advantages:
the embodiment of the invention can record the corresponding compiler calling information aiming at the jump instruction in the program at the compiling stage of the instant compiler generating the program; and debugging information of the program can be generated according to the compiler calling information and the execution flow information when the jump instruction is executed, the debugging information can be used for determining the running track of the program, and then the error position of the program can be positioned based on the debugging information when the program fails to run, so that the error position when the program fails to run is conveniently positioned, and the debugging efficiency of the program is improved.
Drawings
FIG. 1 is a flow chart of the steps of one embodiment of a programmed method of the present invention;
FIG. 2 is a flow chart of the steps of an alternative embodiment of a method of processing a program of the present invention;
FIG. 3 is a block diagram of an embodiment of a processing device for a program according to the present invention;
FIG. 4 is a block diagram illustrating an electronic device for debugging of a program in accordance with an exemplary embodiment.
Detailed Description
In order to make the aforementioned objects, features and advantages of the present invention comprehensible, embodiments accompanied with figures are described in further detail below.
At present, an instruction generated by a just-in-time compiler lacks debugging information such as a file name, a line number and the like, and a jump instruction without stack information may be used in a running process of a just-in-time compiler generation program (program for short), for example, a return address is not pushed like a function call instruction when a relative or absolute jump instruction is used after a function is linked in, that is, a program running track cannot be obtained from the stack information. After the program fails to run, only one entry can be found by the experience of a program debugger, and the program is subjected to single-step debugging to determine the error position when the program runs. Obviously, when the existing just-in-time compiler generates a program and runs in error, the error position of the program is difficult to determine, and the debugging efficiency of the program is reduced.
One of the core concepts of the embodiment of the invention is that at the compiling stage of generating a program by an instant compiler, corresponding compiler calling information is recorded aiming at a jump instruction in the program; and recording corresponding execution flow information when the jump instruction runs, and further generating debugging information of the program according to compiler calling information and execution flow information so as to conveniently locate the error position when the program fails to run and improve the debugging efficiency of the program.
Referring to fig. 1, a flowchart illustrating steps of an embodiment of a processing method of a program according to the present invention is shown, and specifically may include the following steps:
step 101, in the compiling process of the program, recording corresponding compiler calling information according to a jump instruction compiled in the program.
The program in the embodiment of the invention refers to a just-in-time compiler generating program, and can be used for generating a just-in-time compiler. In the compiling process of the program, namely in the compiling stage of the just-in-time compiler generating program, the corresponding compiler call information can be recorded aiming at the jump instruction compiled in the just-in-time compiler generating program. The compiler calling information may be used to determine a calling relationship between calling functions corresponding to the jump instruction, for example, may include identification information of the calling functions. The identification information may be a unique identification of the calling function, for example, a random number that is not repeated and is automatically generated by the program, which is not limited in this embodiment of the present invention.
And 102, recording corresponding execution stream information in the process of executing the jump instruction, wherein the execution stream information is used for determining the running track of the jump instruction.
In a specific implementation, when a jump instruction in an instant compiler generation program runs, the jump instruction may be recorded to generate execution stream information of the jump instruction. The execution flow information may be used to determine an execution trajectory of the jump instruction. For example, in the program running process, a memory location where a pointer of the jump instruction is located in the running stage may be recorded for the jump instruction, and then execution stream information corresponding to the jump instruction may be formed based on the recorded memory location.
Step 103, generating debugging information of the program according to the compiler calling information and the execution flow information.
In the embodiment of the invention, the corresponding relation between the calling information of the compiler and the execution stream information can be established aiming at the jump instruction in the program, and then the corresponding debugging information can be generated based on the corresponding relation. The debug information may be used to determine the trace of the program, such as the jump instruction that may be executed several times last by the program and where and how the jump instruction was generated by the JIT compiler, which is not limited by the present invention.
To sum up, in the program compiling stage, according to the jump instruction compiled in the program, the embodiment of the present invention may record the corresponding compiler call information, and may record the corresponding execution flow information when the jump instruction runs, so as to generate the debugging information of the program according to the compiler call information and the execution flow information, where the debugging information may be used to determine the running track of the program, and further may locate the program error position based on the debugging information when the program fails to run, that is, the error position when the program fails to run is conveniently located, and the debugging efficiency of the program is improved.
In order that those skilled in the art will better understand the embodiments of the present invention, the following description is given with reference to the examples.
As an application example of the present invention, an additional function may be added to a function for generating a jump instruction for a just-in-time compiler in advance in a just-in-time compiler generating program, where the additional function includes: a) saving the file name and line number of the current function and the parameter information such as the function call stack of the current just-in-time compiler when the just-in-time compiler generates a jump instruction, and recording the compiler call information based on the saved parameter information; b) when the jump instruction generated by the instant compiler runs, the PC recording the jump instruction and the corresponding relation between the PC and the compiler calling information recorded in the a) are recorded.
Therefore, the execution flow information can be generated based on the recorded PC, the debugging information of the program can be generated based on the corresponding relation, and the program error position can be positioned based on the debugging information when the program operation fails, so that the error reason of the program can be conveniently found, and the debugging efficiency is improved.
It should be noted that the just-in-time compiler generator may include one or more functions, and the functions may include one or more instructions, etc. In this example, the function of the just-in-time compiler that generates the jump instruction may be used to generate the jump instruction, and the function of the just-in-time compiler that generates the jump instruction may contain or call one or more other functions; the PC may be used to characterize the memory location at which the jump instruction is executed.
In addition, a memory area can be opened up, and when the JIT compiler generation program runs, compiler calling information related to jump instructions compiled by the JIT compiler generation program and execution flow information corresponding to all executed jump instructions can be recorded. It should be noted that the size of the compiler call information recorded in the memory area may be fixed, for example, may be a fixed value, and the implementation of the present invention is not limited thereto. The recorded execution flow information may be used to determine a jump instruction execution trajectory, which may grow with program execution time. Alternatively, in order to prevent the memory shortage, the memory size for recording the execution flow information may be set by the user, and when the memory is full, the jump instruction execution trajectory may be overwritten from the head.
In an optional embodiment of the invention, the method may further comprise: setting a memory area according to preset distribution information, wherein the memory area is used for storing data information, and the data information comprises at least one of the following: the compiler calling information, the execution flow information and the debugging information; and outputting based on the data information in the memory area after the program fails to run.
In this embodiment of the present invention, the preset allocation information may be used to allocate a memory size of the memory area, and optionally, may be set by a user, which is not limited in this embodiment of the present invention.
Specifically, in the running stage of the instant compiler generating program, the execution flow information of the jump instruction and the corresponding relationship between the execution flow information and the compiler calling information may be written into the memory area. Therefore, after the program fails to run, the data information recorded in the memory area can be output so as to conveniently locate the position of the program error, for example, jump instructions executed for a plurality of times recently and the position and the generation of the jump instructions in the program generated by the JIT compiler can be determined, and the cause of the program running error can be found. The number of the most recently executed instructions of the jump instruction may be determined according to the size of the memory area, which is not limited in the embodiment of the present invention.
Optionally, if the error position cannot be found, if the calling hierarchy is found to be insufficient, the program may be rerun by increasing the memory area, so as to trace back more jump instructions forward to locate the error position of the program.
Referring to fig. 2, a flowchart illustrating steps of an alternative embodiment of a processing method of a program according to the present invention is shown, and specifically may include the following steps:
step 201, setting a memory area according to preset allocation information, wherein the memory area is used for storing data information.
Wherein the data information comprises at least one of: the compiler call information, the execution flow information, and the debug information.
Specifically, the memory area set in the embodiment of the present invention may include one or more areas, for example, the memory area may include a first area for storing compiler call information, a second area for storing execution flow information, and an association area, and the embodiment of the present invention is not limited thereto. The association area may be used to store a corresponding relationship between the compiler call information and the execution flow information, for example, may be used to store a corresponding relationship between the compiler call information and the execution flow information.
Step 202, recording corresponding compiler calling information according to a jump instruction compiled in a program.
Specifically, compiler call information corresponding to the jump instruction at the compiling stage may be recorded in the memory area, for example, in the process of generating the program compiling jump instruction by the just-in-time compiler, parameter information such as a file name, a line number, and a function call stack of the current just-in-time compiler may be acquired for the jump instruction, and the parameter information may be recorded, and compiler call information may be generated based on the recorded parameter information.
In an alternative embodiment of the present invention, the step 202 may include the following sub-steps:
substep 2021, when compiling the jump instruction, generating a function call instruction corresponding to the jump instruction, where a function parameter called by the function call instruction includes identification information of the jump instruction.
And a substep 2022 of obtaining compiler calling information corresponding to the jump instruction according to the identification information.
As an example of the present invention, in the compilation process of the JIT compiler-generated program, when a jump instruction is generated, a function call instruction may be generated at the same time to record compiler call information corresponding to the jump instruction by the function call instruction. The function parameter called by the function call instruction may be identification information of the jump instruction.
For example, the function call instruction may be a callFuncToSave function called in the jump instruction generation function genCallOrJump (). The callfuncttosave function can be used for storing the PC of the jump instruction into the second area of the memory according to the identification information of the jump instruction when the program runs, that is, storing the PC of the jump instruction into the memory area set in the step 201, and if the memory is found to be full, covering the original data; and the PC of the jump instruction may be associated with the identification information, so as to write the correspondence between the compiler call information and the execution stream information into the association area of the memory allocated in step 201.
Specifically, for each jump instruction in the program, the just-in-time compiler generating program may create a corresponding jump instruction generating function genCallOrJump (); the jump instruction generation function genCallOrJump () may store, based on a preset data structure struct debuglinfo, the corresponding troubleshooting information debuglinfo when the jump instruction is generated, as compiler call information in the embodiment of the present invention. For example, the jump instruction generating function genCallOrJump () may be configured to determine whether a program debugging function is activated, and when the program debugging function is activated, create a new data structure for the jump instruction, so as to record the debug information debugginfo corresponding to the jump instruction based on the newly created data structure.
Optionally, the troubleshooting information debuggelnfo may include: identification information, file name file, line number line, current instruction information, current function call information, and the like, which are not limited in this embodiment of the present invention.
The identification information can be a unique identification Id of each target jump instruction, and the target jump instruction can be used for representing a currently executed or compiled jump instruction in a program; the file name file can be used for representing the file where the current called function is located; the line number line can be used for representing the line number of the currently called function, for example, the number of lines of the currently called function in a file can be determined; the current instruction information can be a current PC (personal computer), and the PC can be used for representing the memory position of the current instruction; the current function call information may be used to determine a parent function corresponding to the current function, and may include: a pointer to the newly created data structure debugginfo for the jump instruction. Wherein, the pointer of the debugginfo pointing to the structure body can be identified as debugginfo parent.
In an optional example, the file name file and the line number line of the parent function called by the current function can be obtained according to symbol table information of the PC and the program; based on the same mode, the parent function of the parent function can be obtained, and by analogy, the debugginfo of the function call chain can be obtained by backtracking according to the mode. It should be noted that the depth of the backtracking stack may be specified by a user, and the embodiment of the present invention is not limited thereto.
For example, a program may start executing the function func1(), on line 10 of the file a.c; and function func1() called function func2a () on line 11 of file a.c and function func2b () on line 18 of file a.c; and function func2b () was executed starting at line 50 of file a.c and called function func3() at line 51 of file a.c.
Function func3() may start executing on line 10 of another file b.c and may call function func4() on line 11 of file b.c; this function func4() may start executing at line 21 of the file b.c and may call the function generateCallOrJump () at line 22; and may start executing at line 30 of the file b.c at the jump instruction generating function genCallOrJump (), which may generate a jump instruction __ j (target) at line 31 of the file b.c.
Based on the files a.c and b.c, when the program finally generates the jump instruction __ j (target), possible call relations include:
case 1) func1 → func2a → func3 → func4 → genCallOrJump; or,
case 2) func1 → func2b → func3 → func4 → genCallOrJump.
If the case 1 is adopted, a debug info linked list can be generated based on the calling relationship among the functions in the case 1, as shown in the following table 1:
TABLE 1
In this example, the parent function of the function func1 is not traced, so its parent is null.
In the example, association can be established through the parent field in the data structure struct DBUGInfo of each function and the Id of the parent function, so that a DebugInfo linked list is formed. The debugginfo linked list can be used for storing information of how a jump instruction is generated by a just-in-time compiler code, so that the information in the debugginfo linked list can be used as compiler calling information in the embodiment of the invention.
Optionally, for the same function call relationship, a record may be stored, for example, if the backtracking depth specified by the user is 4, if the parent function parent called when the backtracking depth is 2 is the same, and the parent function called when the backtracking depth is 3 is the same, and the parent function of the parent function called when the backtracking depth is 4 is also the same, the record may be regarded as the same call stack information, and a corresponding record may be stored in the debugginfo linked list, which is not specifically limited in this embodiment of the present invention.
Step 203, recording corresponding execution stream information in the process of executing the jump instruction.
In the embodiment of the present invention, optionally, when executing each jump instruction in the program, the memory location where each jump instruction is currently located is respectively obtained; according to the memory location, recording corresponding execution stream information, for example, the execution stream information may be stored in the memory area as data information in the memory area.
As an example of the present invention, in combination with the above example, in the running process, if the program fails to run after executing the jump instruction generating function genCallOrJump () three times, and the PCs executing the jump instruction generating function genCallOrJump () three times are 0x10000100, 0x10000200, and 0x10000300, respectively, the recorded execution flow information for the jump instruction may be: 0x10000100, 0x10000200, 0x 100003000.
The execution flow information recorded in the program execution stage may vary with the length of the program execution time and the size of the number of jump instructions experienced. When the memory is full, the data originally recorded in the memory area may be overwritten, for example, the execution flow information recorded before may be overwritten, so as to record the jump instruction executed recently.
And 204, generating corresponding debugging information according to the compiler calling information and the execution flow information.
In an alternative embodiment of the present invention, the step 204 may include the following sub-steps:
substep 2041, determining a correspondence between the compiler calling information and the execution flow information based on the identification information;
and a substep 2042 of generating corresponding debugging information based on the correspondence, wherein the debugging information is used for determining the error position when the program fails to run.
Specifically, the PC of the jump instruction may be associated with the identification information, thereby determining a correspondence between the execution stream information and the compiler call information; and the corresponding relation can be stored in the memory area, so that a corresponding relation table of the PC of the jump instruction and the ID in the compiler calling information can be formed and used as debugging information of the program. For example, after the program executes the jump instruction generation function genCallOrJump () three times, the identification information debuglinfo.id of the jump instruction __ j (target) generated three times may be 0x 000005. Further, a corresponding relationship table may be formed according to a corresponding relationship between the identification information debugginfo.id of the jump instruction __ j (target) and the memory location PC where the jump instruction is generated three times by the program, as shown in table 2 below:
TABLE 2
In step 205, after the program fails to run, the program is output based on the data information in the memory area.
In the embodiment of the present invention, after the program fails to run, the program may be output based on the data information recorded in the memory area, for example, the compiler call information recorded in the memory area may be output. The outputted compiler call information can be used for positioning the program operation error position, such as the execution flow information of all jump instructions several times before the program failure and the compiler call information generated by the JIT compiler when the program is compiled, etc.
As an example of the present invention, after the program fails to run, the data information in the memory area may be printed out. Specifically, complete symbol information may be obtained based on the compiler calling information determined in step 203 and the execution flow information determined in step 204, such as the information in the debugginfo linked list and the PC information in the correspondence table, and the symbol information may be used as data information to be printed. For example, in connection with the above example, after three generation instruction failures are experienced, the printed data information may be as shown in table 3 below:
TABLE 3
Based on the information in table 3, it can be determined that the program jumps from 0x10000100 to 0x10000200, and executes an error after continuously jumping to 0x 10000300; the jump instruction of 0x10000300 is generated from line 30 in the b.c file, and the function of line 30 in the b.c file is … … called from line 21 in the file, so that the error position in the source code can be located quickly, and then the error cause of the program operation can be further determined according to the context of the error position.
Of course, the data information in the memory area may also be output in other manners, for example, the data information may be output in manners of playing, displaying, and the like, which is not limited in this embodiment of the present invention.
To sum up, in the JIT code compiling process, the compiler call information corresponding to the compiled jump instruction may be recorded, for example, call stack information at the time of generation may be stored when the jump instruction is generated in the just-in-time compiler; and the corresponding execution flow information can be recorded when the jump instruction is executed, and then the debugging information of the just-in-time compiling program can be generated through the calling information and the execution flow information of the compiler, so that the running error position of the program can be conveniently positioned when the program runs and is identified, and the debugging efficiency of the program is improved.
It should be noted that for simplicity of description, the method embodiments are described as a series of acts or combination of acts, but those skilled in the art will recognize that the present invention is not limited by the illustrated order of acts, as some steps may occur in other orders or concurrently according to the present invention. Further, those skilled in the art will appreciate that the embodiments described in the specification are presently preferred and that no particular act is required to implement the invention.
Referring to fig. 3, a block diagram of an embodiment of a processing device of a program of the present invention is shown. The program is used for generating a just-in-time compiler, and the apparatus may specifically include the following modules:
the call information recording module 301 is configured to record, according to a jump instruction in a program, corresponding compiler call information in a compiling process of the program, where the compiler call information is used to determine a call relationship between call functions corresponding to the jump instruction;
an execution stream information recording module 302, configured to record corresponding execution stream information in a process of executing the jump instruction, where the execution stream information is used to determine an execution trajectory of the jump instruction;
a result information generating module 303, configured to generate debugging information of the program according to the compiler calling information and the execution flow information.
In an optional embodiment of the present invention, the calling information recording module 301 includes:
the calling instruction generation submodule is used for generating a function calling instruction corresponding to the jump instruction when the jump instruction is compiled, and a function parameter called by the function calling instruction comprises identification information of the jump instruction;
and the information acquisition submodule is used for acquiring compiler calling information corresponding to the jump instruction according to the identification information.
In an optional embodiment of the present invention, the execution stream information recording module 302 includes:
the memory location acquisition submodule is used for respectively acquiring the memory location of each jump instruction when each jump instruction in the program is executed;
and the execution stream information recording submodule is used for recording corresponding execution stream information according to the memory position.
In an optional embodiment of the present invention, the result information generating module 303 includes:
the corresponding relation creating submodule is used for determining the corresponding relation between the compiler calling information and the execution flow information based on the identification information;
and the result information generation submodule is used for generating corresponding debugging information based on the corresponding relation, wherein the debugging information is used for determining the error position of the program operation failure.
In an optional embodiment of the present invention, the apparatus may further include the following modules:
the memory area setting module is configured to set a memory area according to preset allocation information, where the memory area is used to store data information, and the data information includes at least one of the following: the compiler calling information, the execution flow information and the debugging information;
and the data information printing module is used for printing based on the data information in the memory area after the program operation fails.
For the device embodiment, since it is basically similar to the method embodiment, the description is simple, and for the relevant points, refer to the partial description of the method embodiment.
Fig. 4 is a block diagram illustrating an architecture of an electronic device 400 for processing of a program in accordance with an exemplary embodiment. For example, the electronic device 400 may be a mobile phone, a computer, a digital broadcast terminal, a messaging device, a game console, a tablet device, a medical device, an exercise device, a personal digital assistant, and the like.
Referring to fig. 4, electronic device 400 may include one or more of the following components: processing components 402, memory 404, power components 406, multimedia components 408, audio components 410, input/output (I/O) interfaces 412, sensor components 414, and communication components 416.
The processing component 402 generally controls overall operation of the electronic device 400, such as operations associated with display, telephone calls, data communications, camera operations, and recording operations. The processing component 402 may include one or more processors 420 to execute instructions to perform all or a portion of the steps of the methods described above. Further, the processing component 402 can include one or more modules that facilitate interaction between the processing component 402 and other components. For example, the processing component 402 can include a multimedia module to facilitate interaction between the multimedia component 408 and the processing component 402.
The memory 404 is configured to store various types of data to support operations at the device 400. Examples of such data include instructions for any application or method operating on the electronic device 400, contact data, phonebook data, messages, pictures, videos, and so forth. The memory 404 may be implemented by any type or combination of volatile or non-volatile memory devices such as Static Random Access Memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic or optical disks.
The power supply component 406 provides power to the various components of the electronic device 400. Power components 406 may include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power for electronic device 400.
The multimedia component 408 comprises a screen providing an output interface between the electronic device 400 and a user. In some embodiments, the screen may include a Liquid Crystal Display (LCD) and a Touch Panel (TP). If the screen includes a touch panel, the screen may be implemented as a touch screen to receive an input signal from a user. The touch panel includes one or more touch sensors to sense touch, slide, and gestures on the touch panel. The touch sensor may not only sense the boundary of a touch or slide action, but also detect the duration and pressure associated with the touch or slide operation. In some embodiments, the multimedia component 408 includes a front facing camera and/or a rear facing camera. The front camera and/or the rear camera may receive external multimedia data when the electronic device 400 is in an operating mode, such as a shooting mode or a video mode. Each front camera and rear camera may be a fixed optical lens system or have a focal length and optical zoom capability.
The audio component 410 is configured to output and/or input audio signals. For example, the audio component 410 includes a Microphone (MIC) configured to receive external audio signals when the electronic device 400 is in an operational mode, such as a call mode, a recording mode, and a voice recognition mode. The received audio signals may further be stored in the memory 404 or transmitted via the communication component 416. In some embodiments, audio component 410 also includes a speaker for outputting audio signals.
The I/O interface 412 provides an interface between the processing component 402 and peripheral interface modules, which may be keyboards, click wheels, buttons, etc. These buttons may include, but are not limited to: a home button, a volume button, a start button, and a lock button.
The sensor component 414 includes one or more sensors for providing various aspects of status assessment for the electronic device 400. For example, the sensor component 414 can detect an open/closed state of the device 400, the relative positioning of components, such as a display and keypad of the electronic device 400, the sensor component 414 can also detect a change in the position of the electronic device 400 or a component of the electronic device 400, the presence or absence of user contact with the electronic device 400, orientation or acceleration/deceleration of the electronic device 400, and a change in the temperature of the electronic device 400. The sensor assembly 414 may include a proximity sensor configured to detect the presence of a nearby object without any physical contact. The sensor assembly 414 may also include a light sensor, such as a CMOS or CCD image sensor, for use in imaging applications. In some embodiments, the sensor assembly 414 may also include an acceleration sensor, a gyroscope sensor, a magnetic sensor, a pressure sensor, or a temperature sensor.
The communication component 416 is configured to facilitate wired or wireless communication between the electronic device 400 and other devices. The electronic device 400 may access a wireless network based on a communication standard, such as WiFi, 2G or 3G, or a combination thereof. In an exemplary embodiment, the communication component 416 receives broadcast signals or broadcast related information from an external broadcast management system via a broadcast channel. In an exemplary embodiment, the communication component 416 further includes a Near Field Communication (NFC) module to facilitate short-range communications. For example, the NFC module may be implemented based on Radio Frequency Identification (RFID) technology, infrared data association (IrDA) technology, Ultra Wideband (UWB) technology, Bluetooth (BT) technology, and other technologies.
In an exemplary embodiment, the electronic device 400 may be implemented by one or more Application Specific Integrated Circuits (ASICs), Digital Signal Processors (DSPs), Digital Signal Processing Devices (DSPDs), Programmable Logic Devices (PLDs), Field Programmable Gate Arrays (FPGAs), controllers, micro-controllers, microprocessors or other electronic components for performing the above-described methods.
In an exemplary embodiment, a non-transitory computer-readable storage medium comprising instructions, such as the memory 404 comprising instructions, executable by the processor 420 of the electronic device 400 to perform the above-described method is also provided. For example, the non-transitory computer readable storage medium may be a ROM, a Random Access Memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, and the like.
A non-transitory computer readable storage medium in which instructions, when executed by a processor of a terminal, enable the terminal to perform a processing method of a program, the method comprising: in the compiling process of the program, recording corresponding compiler calling information according to a jump instruction in the program, wherein the compiler calling information is used for determining the calling relationship among calling functions corresponding to the jump instruction; recording corresponding execution stream information in the process of executing the jump instruction, wherein the execution stream information is used for determining an execution track of the jump instruction; and generating debugging information of the program according to the compiler calling information and the execution flow information. Wherein the program is used to generate a just-in-time compiler.
Optionally, the recording, according to the jump instruction in the program, corresponding compiler invocation information includes: when a jump instruction is compiled, generating a function call instruction corresponding to the jump instruction, wherein a function parameter called by the function call instruction comprises identification information of the jump instruction; and acquiring compiler calling information corresponding to the jump instruction according to the identification information.
Optionally, in the process of executing the jump instruction, recording corresponding execution stream information, including: when each jump instruction in the program is executed, the current memory position of each jump instruction is respectively obtained; and recording corresponding execution stream information according to the memory position.
Optionally, the generating corresponding debugging information according to the compiler calling information and the execution flow information includes: determining a corresponding relation between the compiler calling information and the execution flow information based on the identification information; and generating corresponding debugging information based on the corresponding relation, wherein the debugging information is used for determining the error position of the program operation failure.
Optionally, the method further comprises: setting a memory area according to preset distribution information, wherein the memory area is used for storing data information, and the data information comprises at least one of the following: the compiler calling information, the execution flow information and the debugging information; and outputting based on the data information in the memory area after the program fails to run.
The embodiments in the present specification are described in a progressive manner, each embodiment focuses on differences from other embodiments, and the same and similar parts among the embodiments are referred to each other.
As will be appreciated by one skilled in the art, embodiments of the present invention may be provided as a method, apparatus, or computer program product. Accordingly, embodiments of the present invention may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, embodiments of the present invention may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
Embodiments of the present invention are described with reference to flowchart illustrations and/or block diagrams of methods, terminal devices (systems), and computer program products according to embodiments of the invention. It will be understood that each flow and/or block of the flow diagrams and/or block diagrams, and combinations of flows and/or blocks in the flow diagrams and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing terminal to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing terminal, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing terminal to function in a predictive manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing terminal to cause a series of operational steps to be performed on the computer or other programmable terminal to produce a computer implemented process such that the instructions which execute on the computer or other programmable terminal provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
While preferred embodiments of the present invention have been described, additional variations and modifications of these embodiments may occur to those skilled in the art once they learn of the basic inventive concepts. Therefore, it is intended that the appended claims be interpreted as including preferred embodiments and all such alterations and modifications as fall within the scope of the embodiments of the invention.
Finally, it should also be noted that, herein, relational terms such as first and second, and the like may be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or terminal that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or terminal. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other like elements in a process, method, article, or terminal that comprises the element.
The above detailed description is provided for a program processing method and apparatus, an electronic device and a storage medium, and the principles and embodiments of the present invention are explained herein by using specific examples, and the descriptions of the above examples are only used to help understand the method and the core ideas of the present invention; meanwhile, for a person skilled in the art, according to the idea of the present invention, there may be variations in the specific embodiments and the application scope, and in summary, the content of the present specification should not be construed as a limitation to the present invention.

Claims (12)

1. A method of processing a program for generating a just-in-time compiler, the method comprising:
in the compiling process of the program, recording corresponding compiler calling information according to a jump instruction in the program, wherein the compiler calling information is used for determining the calling relationship among calling functions corresponding to the jump instruction;
recording corresponding execution stream information in the process of executing the jump instruction, wherein the execution stream information is used for determining an execution track of the jump instruction;
and generating debugging information of the program according to the compiler calling information and the execution flow information.
2. The method according to claim 1, wherein the recording corresponding compiler call information according to the jump instruction in the program comprises:
when a jump instruction is compiled, generating a function call instruction corresponding to the jump instruction, wherein a function parameter called by the function call instruction comprises identification information of the jump instruction;
and acquiring compiler calling information corresponding to the jump instruction according to the identification information.
3. The method according to claim 1, wherein recording corresponding execution flow information during executing the jump instruction comprises:
when each jump instruction in the program is executed, the current memory position of each jump instruction is respectively obtained;
and recording corresponding execution stream information according to the memory position.
4. The method of claim 2, wherein generating corresponding debug information from the compiler call information and the execution flow information comprises:
determining a corresponding relation between the compiler calling information and the execution flow information based on the identification information;
and generating corresponding debugging information based on the corresponding relation, wherein the debugging information is used for determining the error position of the program operation failure.
5. The method of any of claims 1 to 4, further comprising:
setting a memory area according to preset distribution information, wherein the memory area is used for storing data information, and the data information comprises at least one of the following: the compiler calling information, the execution flow information and the debugging information;
and outputting based on the data information in the memory area after the program fails to run.
6. A program processing apparatus for generating a just-in-time compiler, the apparatus comprising:
the calling information recording module is used for recording corresponding compiler calling information according to a jump instruction in the program in the compiling process of the program, and the compiler calling information is used for determining the calling relationship among calling functions corresponding to the jump instruction;
the execution stream information recording module is used for recording corresponding execution stream information in the process of executing the jump instruction, and the execution stream information is used for determining the execution track of the jump instruction;
and the result information generating module is used for generating debugging information of the program according to the compiler calling information and the execution flow information.
7. The apparatus of claim 6, wherein the calling information recording module comprises:
the calling instruction generation submodule is used for generating a function calling instruction corresponding to the jump instruction when the jump instruction is compiled, and a function parameter called by the function calling instruction comprises identification information of the jump instruction;
and the information acquisition submodule is used for acquiring compiler calling information corresponding to the jump instruction according to the identification information.
8. The apparatus of claim 6, wherein the execution flow information recording module comprises:
the memory location acquisition submodule is used for respectively acquiring the memory location of each jump instruction when each jump instruction in the program is executed;
and the execution stream information recording submodule is used for recording corresponding execution stream information according to the memory position.
9. The apparatus of claim 7, wherein the result information generating module comprises:
the corresponding relation creating submodule is used for determining the corresponding relation between the compiler calling information and the execution flow information based on the identification information;
and the result information generation submodule is used for generating corresponding debugging information based on the corresponding relation, wherein the debugging information is used for determining the error position of the program operation failure.
10. The apparatus of any of claims 6 to 9, further comprising:
the memory area setting module is configured to set a memory area according to preset allocation information, where the memory area is used to store data information, and the data information includes at least one of the following: the compiler calling information, the execution flow information and the debugging information;
and the data information printing module is used for printing based on the data information in the memory area after the program operation fails.
11. An electronic device comprising a memory, and one or more programs, wherein the one or more programs are stored in the memory and configured to be executed by one or more processors the one or more programs including instructions for:
in the compiling process of the program, recording corresponding compiler calling information according to a jump instruction in the program, wherein the compiler calling information is used for determining the calling relationship among calling functions corresponding to the jump instruction;
recording corresponding execution stream information in the process of executing the jump instruction, wherein the execution stream information is used for determining an execution track of the jump instruction;
and generating debugging information of the program according to the compiler calling information and the execution flow information.
12. A readable storage medium, characterized in that instructions in the storage medium, when executed by a processor of an electronic device, enable the electronic device to perform a processing method of a program according to one or more of method claims 1-5.
CN201710758336.8A 2017-08-29 2017-08-29 Program processing method, program processing device, electronic device and storage medium Active CN109426504B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201710758336.8A CN109426504B (en) 2017-08-29 2017-08-29 Program processing method, program processing device, electronic device and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201710758336.8A CN109426504B (en) 2017-08-29 2017-08-29 Program processing method, program processing device, electronic device and storage medium

Publications (2)

Publication Number Publication Date
CN109426504A true CN109426504A (en) 2019-03-05
CN109426504B CN109426504B (en) 2021-11-19

Family

ID=65503619

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201710758336.8A Active CN109426504B (en) 2017-08-29 2017-08-29 Program processing method, program processing device, electronic device and storage medium

Country Status (1)

Country Link
CN (1) CN109426504B (en)

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109918132A (en) * 2019-03-26 2019-06-21 龙芯中科技术有限公司 A kind of instruction installation method, device, electronic equipment and storage medium
CN111694571A (en) * 2019-03-15 2020-09-22 上海寒武纪信息科技有限公司 Compiling method and device
CN112445483A (en) * 2019-08-27 2021-03-05 龙芯中科技术股份有限公司 Instruction generation method and device, electronic equipment and storage medium
CN112445484A (en) * 2019-08-27 2021-03-05 龙芯中科技术股份有限公司 Register processing method and device, electronic equipment and storage medium

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101122881A (en) * 2007-09-20 2008-02-13 福建星网锐捷网络有限公司 CPU abnormal point positioning diagnosis method based MIPS structure
US20140289707A1 (en) * 2013-03-21 2014-09-25 International Business Machines Corporation Dynamic code switching in debugging process
US8910124B1 (en) * 2011-10-31 2014-12-09 Google Inc. Low-overhead method and apparatus for collecting function call trace data
CN104252402A (en) * 2014-09-05 2014-12-31 深圳创维数字技术有限公司 Program debugging method and device
CN104636256A (en) * 2015-02-17 2015-05-20 中国农业银行股份有限公司 Memory access abnormity detecting method and memory access abnormity detecting device
CN105893240A (en) * 2015-11-20 2016-08-24 乐视致新电子科技(天津)有限公司 Android program debugging method and apparatus

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101122881A (en) * 2007-09-20 2008-02-13 福建星网锐捷网络有限公司 CPU abnormal point positioning diagnosis method based MIPS structure
US8910124B1 (en) * 2011-10-31 2014-12-09 Google Inc. Low-overhead method and apparatus for collecting function call trace data
US20140289707A1 (en) * 2013-03-21 2014-09-25 International Business Machines Corporation Dynamic code switching in debugging process
CN104252402A (en) * 2014-09-05 2014-12-31 深圳创维数字技术有限公司 Program debugging method and device
CN104636256A (en) * 2015-02-17 2015-05-20 中国农业银行股份有限公司 Memory access abnormity detecting method and memory access abnormity detecting device
CN105893240A (en) * 2015-11-20 2016-08-24 乐视致新电子科技(天津)有限公司 Android program debugging method and apparatus

Cited By (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111694571A (en) * 2019-03-15 2020-09-22 上海寒武纪信息科技有限公司 Compiling method and device
CN111694571B (en) * 2019-03-15 2022-11-01 上海寒武纪信息科技有限公司 Compiling method and device
CN109918132A (en) * 2019-03-26 2019-06-21 龙芯中科技术有限公司 A kind of instruction installation method, device, electronic equipment and storage medium
CN112445483A (en) * 2019-08-27 2021-03-05 龙芯中科技术股份有限公司 Instruction generation method and device, electronic equipment and storage medium
CN112445484A (en) * 2019-08-27 2021-03-05 龙芯中科技术股份有限公司 Register processing method and device, electronic equipment and storage medium
CN112445483B (en) * 2019-08-27 2023-11-24 龙芯中科技术股份有限公司 Instruction generation method and device, electronic equipment and storage medium
CN112445484B (en) * 2019-08-27 2023-11-24 龙芯中科技术股份有限公司 Register processing method and device, electronic equipment and storage medium

Also Published As

Publication number Publication date
CN109426504B (en) 2021-11-19

Similar Documents

Publication Publication Date Title
CN105955765B (en) Application preloading method and device
JP6254751B2 (en) Communication module firmware, plug-in generation method, apparatus, program, and recording medium
CN109426504B (en) Program processing method, program processing device, electronic device and storage medium
CN107391218A (en) Compilation Method and device, electronic equipment and computer-readable recording medium
CN111736916A (en) Dynamic expansion method and device based on Java language, electronic equipment and storage medium
CN109344051B (en) Data processing method and device, electronic equipment and storage medium
CN112241361A (en) Test case generation method and device and problem scene automatic reproduction method and device
CN105468410A (en) System upgrading method and device
CN111538574B (en) Task stack management method, device, terminal and storage medium
CN113010157B (en) Code generation method and device
CN110795354A (en) Information processing method, device and storage medium
CN113377370A (en) File processing method and device, electronic equipment and storage medium
CN107885571B (en) Display page control method and device
CN116069612A (en) Abnormality positioning method and device and electronic equipment
CN106293683B (en) Project compiling method and device
CN110851370A (en) Program testing method and device, and storage medium
CN111209195A (en) Method and device for generating test case
CN112631695B (en) Data verification method and device, electronic equipment and storage medium
CN115658135A (en) Code analysis processing method and device and readable storage medium
CN112445484B (en) Register processing method and device, electronic equipment and storage medium
CN114661606A (en) Program debugging method and device, electronic equipment and storage medium
CN111240927B (en) Method, device and storage medium for detecting time consumption of method in program
CN114020694B (en) Header file address acquisition method and device, electronic equipment and storage medium
CN111596949B (en) Method and device for developing application program
CN114020693B (en) Header file address acquisition method and device, electronic equipment and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
CB02 Change of applicant information
CB02 Change of applicant information

Address after: 100095 Building 2, Longxin Industrial Park, Zhongguancun environmental protection technology demonstration park, Haidian District, Beijing

Applicant after: Loongson Zhongke Technology Co.,Ltd.

Address before: 100095 Building 2, Longxin Industrial Park, Zhongguancun environmental protection technology demonstration park, Haidian District, Beijing

Applicant before: LOONGSON TECHNOLOGY Corp.,Ltd.

GR01 Patent grant
GR01 Patent grant