This application is based upon and claims the benefit of priority from the prior Japanese Patent Application No. 2007-309260 filed on Nov. 29, 2007; the entire contents of which are incorporated herein by this reference.
1. Field of the Invention
The present invention relates to a debugging device and a debugging method, and particularly to a debugging device and a debugging method which debug a program.
2. Description of the Related Art
Conventionally, in creating a program, debugging is performed using a debugging device in order to check whether or not the program operates correctly. The debugging device receives as input an object program generated by a compiling device, and displays a corresponding source code or assembly code on a graphical user interface (hereinafter referred to as GUI).
The debugging device has functions of performing break point setting, step execution, and the like. For example, a debugging operator performs step execution using the GUI, the debugging device executes one line of the source code or one instruction of the assembly code. Then, if there is a problematic code which leads to an error in a result of execution of the one instruction of the source code or assembly code, the debugging device highlights a problematic portion or displays an auxiliary code, message, or the like which represents details of the error. Accordingly, the debugging operator can easily find the problematic code.
Many debugging devices as described above have been proposed. For example, Japanese Patent Application No. 3107151 has proposed a debugging device which displays an auxiliary code, message, or the like in a source code or assembly code while a debugging operator performs debugging.
In this proposal, in a case where a debugging operator performs step execution at source level, if the execution sequence of the source code is changed due to optimization of a compiler, a message for alerting the debugging operator is displayed.
However, while conventional debugging devices can display an auxiliary message in the problematic code as described above, the conventional debugging devices cannot distinguish between information of a code that does not need to be debugged which is generated by optimization of the compiler during debugging and information of a code that needs to be debugged.
In addition, the conventional debugging devices can neither add a massage to a start position and an end position of the distinguished code that does not need to be debugged, nor hide the code itself.
According to one aspect of the present invention, a debugging device can be provided which debugs a program, the debugging device includes: an analysis section configured to analyze information of a code that does not need to be debugged in which a predetermined processing instruction is described, the code being generated by optimization of a compiler for a source code of the program; and an output section configured to output processing content information, a start address, and an end address of the code that does not need to be debugged which are obtained by analysis.
According to one aspect of the present invention, a debugging device can be provided which debugs a program, the debugging device includes: a display selecting section configured to select display or non-display of a code that does not need to be debugged in which a predetermined processing instruction is described, the code being generated by optimization of a compiler for a source code of the program; and a display processing section configured to, if the display of the code that does not need to be debugged is selected, display a first predetermined message indicating a start and an end of the code that does not need to be debugged immediately before and immediately after the code that does not need to be debugged respectively, and if the non-display of the code that does not need to be debugged is selected, hide the code that does not need to be debugged and display only a second predetermined message indicating that the code that does not need to be debugged is hidden.
Hereinafter, an embodiment of the present invention will be described in detail with reference to the drawings.
First, a debugging device according to an embodiment of the present invention will be described based on
A program generating device 100 is configured to include a main body device 101 having a central processing unit (CPU), a main memory, and the like, a storage device 102 storing various data, and a display device 103 displaying various data.
The main body device 101 is a main body of a computer device such as a personal computer, and is connected with a keyboard 104 and a mouse 105 as input devices. The main body device 101 executes various programs based on instructions from the input devices.
In the storage device 102, a compiler 106 having a program of a compiling function and a debugger 107 having a program of a debugging function are stored.
A user can obtain an object program by running the compiler 106 on the main body device 101 using a source program described in a programming language as an input. In other words, the compiling device is formed of the main body device 101 and the compiler 106.
In addition, the user can perform each debugging as described later by running the debugger 107 on the main body device 101 using an object program obtained by the compiling device as an input. In other words, the debugging device is formed of the main body device 101 and the debugger 107.
The debugging device as configured above according to the present embodiment will now be described.
A debugging device 1 is configured to include an implicitly generated code information analyzing section 11, a decoding section 12, a command executing section 13, and a display processing section 14.
The above described compiling device 2 outputs implicitly generated code information described later to the implicitly generated code information analyzing section 11, and also outputs a bitmap sequence of instruction, i.e., an object code to the decoding section 12. Although in
The decoding section 12 decodes the inputted object code to convert the object code to a machine instruction sequence, i.e., an assembly code, and outputs the assembly code to the display processing section 14.
A command for debugging is inputted from a user to the command executing section 13. The user operates a GUI displayed on the display device 103 so that the corresponding command for debugging is inputted to the command executing section 13. The command executing section 13 analyzes the inputted command for debugging, and outputs a command execution result to the display processing section 14. The command executing section 13 also analyzes the inputted analysis result of the implicitly generated code information, and performs processing to set a break point depending on display or non-display of the implicitly generated code as described later.
The display processing section 14 performs display processing based on the inputted assembly code, the analysis result of the implicitly generated code, and the command execution result, and outputs a result of the processing to the display device 103. The display processing section 14 performs processing of display or non-display of the implicitly generated code. The display processing section 14 configures a display selecting section configured to select display or non-display of the implicitly generated code. If the display of the implicitly generated code is selected, a message indicating a processing content and a start position of the implicitly generated code is displayed immediately before a start line of the implicitly generated code, and a message indicating the processing content and an end position of the implicitly generated code is displayed immediately after an end line of the implicitly generated code. If the non-display of the implicitly generated code is selected, a message indicating the processing content of the implicitly generated code and a fact that the implicitly generated code itself is hidden is displayed, and the implicitly generated code itself is hidden.
In addition, the display processing section 14 can switch processing of a step-related command depending on the display or non-display of the implicitly generated code. When the step-related command is executed, if the display of the implicitly generated code has been selected, a program proceeds step by step even in the implicitly generated code. When the step-related command is executed, if the non-display of the implicitly generated code has been selected, the program proceeds to the end of the implicitly generated code. Such a step-related command includes a step command and a stepi command. Hereinafter it is assumed that the step command executes one line of source code and the stepi command executes one instruction of assembly code.
Processing of the compiling device 2 will be described here.
First, the compiling device 2 reads source programs (step S1), and execute compilation (step S2). The execution of the compilation in step S2 includes optimization, addition of debug information, addition of implicitly generated code information as described later, and so on. Then, the compiling device 2 generates assembly codes (step S3), and outputs object programs (step S4). Finally, the compiling device 2 links the plural object programs generated by the above described processing (step S5) to generate one executable object program, i.e., an execution module.
When a function of optimization of a compiler is applied, an assembly code that is difficult to be debugged by a user or that does not need to be debugged may be generated. For example, automatic SIMD (Single Instruction Multiple Data) optimization, which is one of parallelization techniques, is performed, the following three assembly codes may be generated. The first is a code configured to dynamically determine whether SIMDization is allowed or not. The second is a SIMDized code, and the third is non-SIMDfied code.
When automatic SIMD optimization is performed and the above described three codes are generated, the code configured to dynamically determine whether SIMDization is allowed or not is executed first. If it is determined by the above code that SIMDization is allowed, the SIMDized code is executed, and if it is determined that SIMDization is not allowed, the non-SIMDized code is executed.
A point a user should note here is not the code configured to dynamically determine whether SIMDization is allowed or not, but is which code (i.e., the SIMDized code or non-SIMDized code) is to be executed. The SIMDized code or non-SIMDized code is a debug target code, and the code configured to dynamically determine whether SIMDization is allowed or not is a code that does not need to be debugged. The code that does not need to be debugged which is generated by optimization of the compiler is defined as an implicitly generated code.
While the code configured to dynamically determine whether SIMDization is allowed or not has been described as one example of the code that does not need to be debugged, the code that does not need to be debugged is a code generated implicitly by the compiling device in order to execute a program correctly. Therefore, if there is a problem in the code, the problem is highly likely to be due to the compiling device itself. Accordingly, it is assumed that a programmer has less need to care the code.
However, it should be noted that such a problem is not necessarily due to the compiling device, and a problem may be contained in an implicitly generated code as described above because of an interaction between a source code described by a programmer and the compiling device. For this reason, it is configured that a code that does not need to be debugged can be also displayed.
In the example of the automatic SIMD optimization, the code configured to dynamically determine whether SIMDization is allowed or not corresponds to the implicitly generated code. This implicitly generated code is a program configured to determine whether to perform processing of SIMD or processing of non-SIMD based on input data and the like. In other words, the implicitly generated code is a code which is generated inside the compiler when the compiler generates a plurality of execution instruction groups with respect to a source code.
For addition of implicitly generated code information, the implicitly generated code information is generated from implicitly generated code which is generated by optimization, and the generated implicitly generated code information is encrypted by a predetermined format and added in a predetermined area in an object program.
If an implicitly generated code generated by complier optimization which is not a debug target is displayed on the GUI, this display obstructs debugging and efficiency of the debugging is expected to decrease.
Therefore, in the present embodiment, implicitly generated code information is analyzed. Then, to an implicitly generated code that is not a debug target is added a message indicating a processing content, and so on of the implicitly generated code, or the implicitly generated code itself is hidden from a user. Thereby, efficiency of debugging is improved.
Processing of the implicitly generated code information analyzing section 11 will now be described.
Implicitly generated code information encrypted by a predetermined format is inputted to the implicitly generated code information analyzing section 11. The implicitly generated code information analyzing section 11 analyzes the implicitly generated code information and obtains an analysis result of the implicitly generated code information.
The analysis result of the implicitly generated code information obtained by the implicitly generated code information analyzing section 11 includes a processing content, a start address, and an end address of the implicitly generated code, and an address of instruction which can be executed after the end of the implicitly generated code. In the example of
The analysis result of the implicitly generated code information obtained by the implicitly generated code information analyzing section 11 is inputted to the command executing section 13 and the display processing section 14, and the command executing section 13 and the display processing section 14 perform the above described processing respectively based on the analysis result of the implicitly generated code information.
The implicitly generated code information analyzing section 11 may be configured to display the analysis result of the implicitly generated code information on the display device 103. The implicitly generated code information analyzing section 11 configures the output section configured to output the processing content information, start address, and end address of the implicitly generated code which are obtained by the analysis of the implicitly generated code information. As a result, a user can recognize a processing content, a start position, an end position, and so on of the implicitly generated code, which makes efficiency of debugging improve.
First, the command executing section 13 analyzes an inputted command and outputs a command execution result to the display processing section 14 (step S11). The display processing section 14 analyzes the command execution result and determines whether or not to display the implicitly generated code (step S12). If it is determined as YES that the implicitly generated code is to be displayed, a message indicating a processing content of the implicitly generated code and a start position or an end position of the implicitly generated code immediately before and immediately after the implicitly generated code (step S13).
The processing in step S13 is performed on an assembly code based on an analysis result of the implicitly generated code information. In addition to the command execution result, the analysis result of the implicitly generated code information from the implicitly generated code information analyzing section 11 and the assembly code from the decoding section 12 are inputted to the display processing section 14. The display processing section 14 analyzes the analysis result of the implicitly generated code information to obtain the above described start address, end address, and so on of the implicitly generated code, and adds the predetermined message to a corresponding address position of the assembly code. The assembly code processed in this way is outputted to the display device 103 and displayed on the display device 103.
On the other hand, if it is determined as NO that the implicitly generated code is not to be displayed, the implicitly generated code is hidden, and only a predetermined message indicating the processing content of the implicitly generated code and a fact that the implicitly generated code is hidden is displayed (S14). As in step S13, the processing in step S14 is performed on the assembly code based on the analysis result of the implicitly generated code information.
First, the command executing section 13 analyzes an inputted command and outputs a command execution result to the display processing section 14 (step S21). The display processing section 14 analyzes the command execution result as well as detecting whether or not the implicitly generated code is being displayed (step S22). If the implicitly generated code is being displayed (YES), the implicitly generated code is executed step by step (step S23). If the implicitly generated code is not being displayed (NO), the implicitly generated code is executed to the end (step S24).
The portion 21 surrounded by the dotted line is a support message indicating a start position and processing contents of the implicitly generated code, and the portion 22 surrounded by the dotted line is a support message indicating an end position and processing contents of the implicitly generated code. A program counter (hereinafter referred to as PC) is stopped at an address 0x891a60. A stop position of the PC is denoted by a triangular mark 30 in
The portion 23 surrounded by the dotted line is a support message indicating the processing contents of the implicitly generated code and a fact that the implicitly generated code itself is hidden. The PC is stopped at the address 0x891a60.
As described above, the debugging device 1 is configured to analyze implicitly generated code information stored in a predetermined area of an object file, and add, to an implicitly generated code that is not a debug target, a support message indicating a processing content and a start position or end position of an implicitly generated code. In addition, the debugging device 1 is configured to hide the implicitly generated code that is not a debug target, and add a support message indicating the processing content of the implicitly generated code and a fact that the implicitly generated code is hidden. As a result, a user can recognize the processing content, start position, and end position of the implicitly generated code that is not a debug target, or hide the implicitly generated code itself that is not a debug target.
As described above, by adding a message to a start position and an end position of an implicitly generated code, a user does not need to carefully read the implicitly generated code even if the implicitly generated code is displayed. In addition, by hiding an internally message itself from the user, an amount of assembly code to be read by the user can be reduced.
Thus, according to the debugging device of the present embodiment, information of a code that does not need to be debugged can be distinguished from information of a code that needs to be debugged. In addition, a message is added to a start position and an end position of the code that does not need to be debugged, or the code that does not need to be debugged itself is hidden, which makes efficiency of debugging improve.
Next, applications of the present embodiment will be described.
Although an implicitly generated code which is generated by the automatic SIMD optimization has been described in the above described embodiment, the embodiment may be applied to an implicitly generated code from other than the automatic SIMD optimization.
Although examples in which an implicitly generated code is displayed have been described in the applications, an implicitly generated code may not be displayed as in the above described embodiment. Further, as in the above described embodiment, processing of a step-related command can be switched based on a state of display or non-display of an implicitly generated code.
Each “section” as used herein is a conceptual section corresponding to a respective function of the embodiment, and does not necessarily corresponds to specific hardware or software routine on a one-for-one basis. Thus, in this specification, the embodiment has been described on the assumption of virtual circuit blocks (sections) each having a function of the embodiment. In addition, the above described steps in each flowchart may be executed in a different sequence even for each execution of the steps or some of the steps may be executed at the same time without departing from the nature of the steps.
A program to execute the above described operation is recorded or stored as a computer program product in a portable medium such as a flexible disk or a CD-ROM, a storage device such as a hard disk, or the like in whole or part. The program is read by a computer and a whole or part of the operation is executed. Alternatively, a whole or part of the program may be distributed or provided through a communication network. A user can download and install the program in a computer through the communication network or install the program from a recording medium into the computer, so that the debugging device of the present invention can be easily implemented.
The present invention is not limited to the above described embodiment, and various changes and modifications may be made without changing the principle of the present invention.
Number | Date | Country | Kind |
---|---|---|---|
2007-309260 | Nov 2007 | JP | national |