(1) Field of the Invention
The present invention relates to a compiling system for translating a source program written in a high-level language such as C language into a machine language program, a debugging system for verifying the machine language program, and a program development system including the compiling system and the debugging system.
(2) Description of the Related Art
Conventionally, a system which includes a compiling system and a debugging system has been proposed as a program development system for a machine language program to be executed on a computer. The compiling system is a system realized by executing, on a computer, a program which converts a source program written in a high-level language such as C language into a machine language instruction sequence. The debugging system is a system realized by executing, on a computer, a program which receives a machine language program as an input and verifies the validity of the machine language program through operation control, data reference, and the like performed when the machine language program is being executed.
In such a program development system, the compiling system generates debug information which indicates, for example, a corresponding relationship between line numbers of the source program and a machine language instruction, or a corresponding relationship between symbol names in the source program and machine language data. In other words, the debug information indicates a corresponding relationship between the source program and the machine language program. In addition, the debugging system realizes a mechanism that allows a user to designate the information at the source level by reading and utilizing the debug information and to perform debugging.
On the other hand, these days, various source program conversion/optimization methods for converting a source program once into another source program have been proposed as a response to demands for an optimization mechanisms at the intermediate code level, secured confidentiality and the like (for example, see Japanese Patent Publication No. 6-80490 and Japanese Laid-Open Patent Application No. 2003-280754).
A source program generated by the source program conversion/optimization method is inputted to the compiling system which is similar to the conventional system and is converted into a machine language program by the compiling system.
In the case where the source program conversion/optimization method is utilized, with the conventional program development system, the debug information is generated in the compiling system based on the source program which has been converted at the source level. Therefore, the user cannot perform debugging on the source program which is originally written by him/herself, at the source level. This is because the utilization of the source program conversion/optimization method causes shifts in line numbers of the source program, modifications in control mechanisms or in function names and variable names.
Accordingly, it is necessary for the user to perform debugging based on the source program generated automatically by the source program conversion/optimization method, or to perform debugging directly (at a machine language instruction level) on the generated machine language program. Consequently, debugging efficiency of the source program performed by the user is decreased.
Therefore, there is a problem that the user of system software needs to find data alignment and the like after much trial and error so that a large number of efforts are required for the system software development.
The present invention is conceived to solve the aforementioned problem and has an object to provide a compiling system, a debugging system and a program development system, which can maintain ease in debugging on software even when conversion/optimization is performed at the source level, and increase convenience and development efficiency of the software development.
In order to solve the aforementioned object, a compiling system according one aspect of the present invention is a compiling system for translating a source program into a machine language program, the system includes: a source program conversion unit which converts a first source program written in a high-level language into a second source program written in the high-level language, by optimizing the first source program at the source program level; a compiling unit which converts the second source program into a machine language program; and a debug information generation unit which generates first debug information which indicates a corresponding relationship between the first source program and the machine language program, by referring to a corresponding relationship between the first source program and the second source program and a corresponding relationship between the second source program and the machine language program.
With this configuration, at the time of debugging, debugging based on the first source program can be performed by utilizing the first debug information. Therefore, it is possible to provide a compiling system which can maintain ease in debugging even when conversion/optimization is performed at the source level, and increase convenience and development efficiency of the software development.
It is preferred that the compiling system further includes: a preprocessing unit which analyzes a directive included in the second source program and executes preprocessing on the second source program based on the result of the analysis; and a directive deletion unit which deletes, from the second source program, a line including the directive which is analyzed by the preprocessing unit and is added by the source program conversion unit.
With this configuration, a line added at the time of conversion from the first source program into the second source program is deleted from the second source program. Consequently, the misalignment of line numbers between the first source program and the second source program caused by the addition of lines is resolved, and the corresponding relationship between the line numbers of the first source program and the line numbers of the second source program can be maintained. Therefore, it is possible to maintain ease in debugging even when conversion/optimization is performed at the source level, and increase convenience and development efficiency of the software development.
More preferably, the source program conversion unit includes a line number retaining conversion unit which converts the first source program into the second source program, while retaining a corresponding relationship between line numbers of the first source program and line numbers of the second source program. The source program conversion unit further includes a source conversion debug information generation unit which generates source conversion debug information which collects modifications caused by the source program conversion performed by the line number retaining conversion unit. In addition, the source conversion debug information includes a statement which corresponds to a portion to be converted in the first source program and a statement which corresponds to a portion in the second source program in which the portion to be converted has been converted.
With this configuration, the user can perform debugging based on the first source program by utilizing the source conversion debug information at the time of debugging. Therefore, it is possible to maintain ease in debugging even when conversion/optimization is performed at the source level, and increase convenience and development efficiency of the software development.
The debugging system according to one of other aspects of the present invention is a debugging system for supporting debugging of a machine language program, the debugging system includes; a program execution unit which executes a machine language program which is obtained by compiling a second source program written in a high-level language, the second source program being obtained by optimizing a first source program written in the high-level language; and a debug support unit which receives first debug information which indicates a corresponding relationship between the first source program and the machine language program and second debug information which indicates a corresponding relationship between the second source program and the machine language program, by referring to a corresponding relationship between the first source program and the second source program and the corresponding relationship between the second source program and the machine language program, and supports debugging of the machine language program by a user based on the first debug information, the second debug information, and the result of the execution obtained by the program execution unit.
With this configuration, the user can perform debugging on the first source program based on the first debug information. It is therefore possible to provide a compiling system which can maintain ease in debugging even when conversion/optimization is performed at the source level, and increase convenience and development efficiency of the software development.
It is preferred that the debugging system further includes: a conversion portion display control unit which displays a statement which corresponds to a portion to be converted in the first source program and a statement which corresponds to a portion in the second source program in which the portion to be converted has been optimized; a selection receiving unit which receives a selection of one of the statement which corresponds to the portion to be converted and the statement which corresponds to the post-conversion portion; and a profile information generation unit which generates, as profile information, information received by the selection receiving unit, In addition, the profile information generation unit adds the number of execution cycles when the statement which corresponds to the portion to be converted or the statement which corresponds to the post-conversion portion is executed by the program execution unit.
With this configurations, the compiling system allows selecting one of a portion to be converted and the post-conversion portion with smaller execution cycles and to perform compiling. Therefore, a machine language program with small number of execution cycles can be created.
The program development system according to another one of other aspects of the present invention is a program development system for developing a machine language program from a source program, and includes the aforementioned compiling system and debugging system. The debugging system further includes an execution log output unit which outputs an execution log at the time of executing the machine language program by the program execution unit. The program development system further includes a profiling unit which analyzes the execution log outputted from the debugging system, and outputs profile information which gives a hint on optimization in the compiling system, and the source program conversion unit of the compiling system optimizes the first source program based on the profile information.
With this configuration, the compiling system is connected with the debugging system via the profiling unit so that a machine language program can be gradually updated while automatically activating these systems again and again. Therefore, the optimization of the machine language program can be automated so that an optimal machine language program is automatically selected and determined while restraining manpower required for the user to perform tuning on the machine language program at minimum. Therefore, it is possible to provide a compiling system which can maintain ease in debugging even when conversion/optimization is performed at the source level, and increase convenience and development efficiency of the software development.
It should be noted that the present invention is not realized as a compiling system, a debugging system and a program development system, which include above-identified characteristic units, but also as a compiling method, a debugging support method, and a program development program, which have, as steps, the characteristic units included in the compiling system, debugging system and program development system, and as a program for causing a computer to execute the characteristic steps included in the compiling method, debugging support method and program development method. In addition, it is obvious that such program can be distributed via a recording medium such as Compact Disc-Read Only Memory (CD-ROM) and a communication network such as the Internet. According to the present invention, it is possible to provide a compiling system, a debugging system, and a program development system, which can maintain ease in debugging even when conversion/optimization is performed at the source level, and increase convenience and development efficiency of the software development.
As further information about technical background to this application, the disclosure of Japanese Patent Application No. 2005-337648 filed on Nov. 22, 2005 including specification, drawings and claims is incorporated herein by reference in its entirety.
These and other objects, advantages and features of the invention will become apparent from the following description thereof taken in conjunction with the accompanying drawings that illustrate a specific embodiment of the invention. In the drawings:
Hereinafter, a program development system according to the embodiment of the present invention shall be described with reference to the drawings.
The program development system 11 is a system which generates a machine language program 104 from an inputted source program (not shown in the diagram) written in a high-level language such as C language, and includes a compiling system 1 and a debugging system 6.
The compiling system 1 is a system which reads a source program and profile information 131 and converts the source program into a machine language program 104. The detailed configuration of the compiling system 1 shall be described later.
The debugging system 6 reads the machine language program 104 generated in the compiling system 1, performs simulation and information display with respect to the machine language program 104, and supports analysis/debugging to be performed on the machine language program 104 and the source program. The debugging system 6 outputs profile information 131 which is information to be a hint on optimization in the compilling system 1 by executing the machine language program 104. The details of the debugging system 6 shall be described later
The compiling system 1 includes a driver 2, a source level optimizer 3, a preprocessor 4, and a compiler 5. Each constituent element of the compiling system 1 is realized as a program to be executed on a computer (not shown in the diagram).
The source level optimizer 3, the preprocessor 4 and the compiler 5 are respectively an example of a source program conversion unit, a preprocessing unit and a compiling unit disclosed in the scope of claims.
The driver 2 has a function of activating, as an appropriate option, the source level optimizer 3, the preprocessor 4 and the compiler 5, which are other constituent elements of the compiling system 1, as necessary according to a compile option designated by the user.
The source level optimizer 3 receives, as an input, the profile information 131 and the original source program 101 written by the user, optimizes the received program at the source level, and outputs, an optimized source program 102 which is an optimized source program. The optimization performed herein includes: parallel processing such as vectorization and multi-thread processing; profile information utilization optimization; and inter-file optimization. The source level optimizer 3 can also receive the profile information 131 as an input, and in the case where the profile information 131 is inputted, perform optimization and conversion utilizing the inputted profile information 131.
The preprocessor 4 receives the optimized source program 102 as an input, and analyzes a preprocessor directive such as “#define” included in the optimized source program 102 written in C language prior to compiling performed by the compiler 5. The preprocessor 4 performs pre-processing on the source program 102 based on the analysis result, and transmits the preprocessed source program 103, which is a source program on which preprocessing has been performed, to the compiler 5.
The compiler 5 converts the inputted preprocessed source program 103 into an internal intermediate expression written in an intermediate language, optimizes the expression, and generates the machine language program 104 for a target processor.
Hereinafter, it shall be described a detailed configuration and operation of each constituent element of the compiling system 1.
The driver 2 has a user designated option processing unit 21. The user designated option processing unit 21 transmits a user's option directive regarding final debug information 112 to be generated by the compiling system 1, to the compiler 5. Specifically, the user's option directive includes the following three directives:
(1) a directive which instructs generating debug information based on the original source program 101;
(2) a directive which instructs generating debug information based on the optimized source program 102;
(3) a directive which instructs generating both of debug information based on the original source program 101 and debug information based on the optimized source program 102.
In these three option directives, the directive (1) corresponds to “-orgsrcdbg” option, the directive (2) corresponds to “optsrcdbg” option, and the directive (3) corresponds to “-bothsrcdbg” option.
For example, it is assumed that a -file name of the original source program 101 is “test.c” and a command for activating the compiling system 1 is “cc”. In this case, in order to send the directive (1) to the compiling system 1, the user inputs a command of “cc -orgsrcdbg test.c” in a command line.
The source level optimizer 3 includes a line number retaining conversion unit 31, a source conversion debug information generation output unit 32, and a profile information utilization optimization unit 33.
The line number retaining conversion unit 31 and the source conversion debug information generation output unit 32 are respectively an example of a fine number retaining conversion unit and a source conversion debug information generation unit disclosed in the scope of claims.
The profile information utilization optimization unit 33 has a function of performing optimization in consideration of the input profile information 131. The operation of the profile information utilization optimization unit 33 shall be described later
The line number retaining conversion unit 31 has a function of converting the original source program 101 at the source level caused by optimizing the original source program 11, while retaining line numbers of respective statements in the original source program 101 so that the line numbers are not modified in the post-conversion optimized source program 102 in order to maintain ease for debugging.
The line number retaining conversion unit 31 divides a loop of the original source program 101 as shown in
The line number retaining conversion unit 31 performs vectorization on the inner most loop processing as shown in
Specifically, the line number retaining conversion unit 31 retains the line numbers to be the same in the original source program 101 and the optimized source program 102 by filling the second and fourth lines of the original source program 101 with blank lines.
The source conversion debug information generation output unit 32 has a function of outputting the line number table information 121 and the symbol table information 122 respectively as the source conversion debug information 111 in the case where the line numbers are modified between the original source program 101 and the optimized source program 102 or in the case where symbol names such as function names or variable names are changed due to the source level conversion of the original source program 101.
Accordingly, the source conversion debug information generation output unit 32 collects, in a table, corresponding relationships of respective portions in which line numbers of a source program are modified before and after the source level conversion. However, with respect to the items in which line numbers are adjusted by under-mentioned preprocessor 4 and compiler 5, the line numbers are adjusted without using the source conversion debug information 111. Therefore, necessary information is generated herein considering the adjustment.
The source conversion debug information generation output unit 32 further generates, as source conversion debug information 111, optimization support information 123 for supporting optimization in the compiler 5. Specifically, the source conversion debug information generation output unit 32 generates a combination of each portion of a source program before and after the conversion by the source level optimizer 3 or a corresponding relationship of conversion candidates, and the number of execution cycles for each source program. With respect to the number of execution cycles, a value is set only in the case where the value is designated in the profile information 131, and otherwise “0” is set. Here, information regarding the converted portions of the converted source program is not necessarily restricted to one, so that the information regarding the source program and the number of execution cycles can be outputted for plural conversion candidate patterns.
The source conversion debug information 111 is text information indicating the line number table information 121, the symbol table information 122 and the optimization support information 123, and is outputted as a comment attached at the end of the optimized source program 102 which is an output file.
That is to say, a portion of the “main” function corresponds to the optimized source program 102. Also, in the comment statement enclosed in the tags “/*” and “*/”, a portion between the tag <DebugInfo> and the tag </DebugInfo> corresponds to the source conversion debug information 111. The portion between the tag <LineInfo> and the tag </LineInfo> corresponds to the line number table information 121. The portion between the tag <SymbolInfo> and the tag </SymbolInfo> corresponds to the symbol table information 122. Furthermore, the portion between the tag <TransInfo> and </TransInfo> corresponds to the optimized support information 123.
The line number table information 121 is made up of three lines respectively enclosed in the tags <block> and </block>.
Here, the first line indicates that the seventh line of the original is source program 101 is deleted in the optimized source program 102. The second line indicates that the eighth to ninth lines of the original source program 101 are modified to the seventh to eleventh lines of the optimized source program 102. The third line indicates that a new line which does not exist in the original source program 101 is added to the twelfth line of the optimized source program 102.
The symbol table information 122 is made up of one line which is enclosed in the tags <symbol> and </symbol>, indicating that a symbol a in the original source program 101 corresponds to symbols a1, a2, and a3 in the optimized source program 102.
In the optimized support information 123, a character string “test.c” indicated in the portion between the tag <File>and the tag </File> shows a file name of the original source program 101 to be compiled. The value “23” indicated in the portion between the tag <Line>and the tag </Line>shows a head line number of the portion to be converted in the original source program 101. The portion between the tag <Pattern>and the tag </Pattern>indicates a conversion pattern after the conversion performed by the source level optimizer 3. Here, two types of conversion patterns are shown. An identifier is attached to each conversion pattern and is indicated in the portion enclosed in the tags <ID> and </ID>. Specifically, numbers “1” and “2” are attached as respective identifiers. Furthermore, each conversion pattern is indicated in the portion enclosed in the tags <Code>and </Code>. The number of cycles in which each conversion pattern is executed by being replaced to a machine language instruction is indicated in the portion enclosed in the tags <cycle> and </cycle>. Here, “0” is set as the number of cycles executing the conversion pattern with the identifier “1”. As described in the above, “0” indicates that the profile information 131 does not designate the number of execution cycles. On the other hand, “1500” is set as the number of cycles executing the conversion pattern with the identifier “2”. This indicates that the number of executing the conversion pattern with the identifier “2” is 1500 cycles. Furthermore, “<UserSelect>True</UserSelect>” indicates that the conversion pattern with the identifier “2” is selected by a user.
Next, it shall be described the preprocessor 4 shown in
In the conventional preprocessor processing, a preprocessor directive is analyzed and processing is performed based on the analysis. The preprocessor directive line is outputted as a blank line so that line numbers of respective statements of the original source program are kept to be the same. For example, when the conventional preprocessor receives a preprocessor directive of “#define AB”, replaces all A in the source program with B, and outputs, as a blank line, the line in which the preprocessor directive was indicated.
The line adjustment unit 41 of the preprocessor 4 according to the present invention inputs the optimized source program 102, recognizes a preprocessor directive such as “#pragma” inserted by the source level optimizer 3, performs processing corresponding to the directive, and then deletes the preprocessor directive inserted by the source level optimizer 3, Consequently, the misalignment of line numbers between the original source program 101 and the optimized source program 102 caused by the insertion of preprocessor directive performed by the source level optimizer 3, and therefore the corresponding relationship of line numbers between the original source program 101 and the preprocessed source program 103 is maintained regarding the target portion.
Next, it shall be described the compiler 5 shown in
The compiler 5 receives the preprocessed source program 103 as an input, analyzes each statement per line through lexical analysis and syntactic analysis usually by incrementing an internal line number counter, and associates each statement with a corresponding line number in order to generate line number information which is a part of the final debug information 112.
The line number adjustment unit 51 recognizes a compile directive such as “#pragma” inserted by the source level optimizer 3 in the preprocessed source program 103, and decrements the internal line number counter when a process based on the compile directive inserted by the source level optimizer 3 is performed after a processing corresponding to the directive is performed. The line number adjustment unit 51 thus generates line number information which ignores the compile directive inserted by the source level optimizer 3. Accordingly, the compiler 5 can internally deal with displacement of a line number between the original source program 101 and the preprocessed source program 103 caused by the insertion of the compile directive by the source level optimizer 3. With respect to the corresponding portion, the consistency in the corresponding relationship of statements and line numbers between the original source program 101 and inside the compiler 5 is secured.
Note that, the example of the compile directive which can be analyzed by the line number adjustment unit 51 is the same as the preprocessor directive which can be analyzed by the line adjustment unit 41 of the preprocessor 4. Specifically, the line number adjustment unit 51 holds a list which is similar to the list of the preprocessor directive which can be analyzed by the line adjustment unit 41 shown in
The final debug information selection generation unit 52 outputs one of the following information as the final debug information 112 so as to be included in the machine language program 104, in accordance with the directive of the compile option transmitted by the driver 2 and designated by the user.
(1) Debug information based on the original source program 101
(2) Debug information based on the optimized source program 102
(3) Debug information including the debug information based on the original source program 101 and the debug information based or the optimized source program 102
In particular, in the case where debug information based on the original source program 101 is required (in the above-identified cases of (1) and (2)), the final debug information selection generation unit 52 generates necessary information (for example, a corresponding relationship of line and symbols between the machine language instruction and the source code) from the preprocessed source program 103 and the source conversion debug information 111. Specifically, the final debug information selection generation unit 52 generates line information of the original source program 101 based on the line number table information 121, generates symbol information of the original source program 101 based on the symbol table information 122, and outputs the symbol information so as to be included in the final debug information 112.
Furthermore, the final debug information selection generation unit 52 also outputs the optimized support information 123 so as to be included in the final debug information 112.
Because the compiling system 1 is configured as described in the above, even in the case where the source optimizer 3 is adopted, the debug information (final debug information 112) can be generated based on the original source program 101. Accordingly, the user can perform source level debugging based on the original source program 101. Furthermore, by combining plural processes such as a line number retaining conversion process performed by the source level optimizer 3, a line adjustment process and the like performed by the preprocessor 4 and the compiler 5, the amount of additional information such as the source conversion debug information 111 which is not used in the conventional compiling system can be minimized.
The debugging system 6 is a development tool to support analysis/debugging of a program by receiving, as an input, the machine language program 104 generated in the compiling system 1 and performing simulation and information display of a program through an interactive interface with the user, and includes a simulator 7, a debug processor 8, a Graphical User Interface (GUI) processor 9, and a profiler 10.
The simulator 7 is an example of a program execution unit and an execution log output unit disclosed in the scope of claims. The debug processor 8 is an example of a debug support unit disclosed in the scope of claims. The GUI processor 9 is an example of a program display control unit disclosed in the scope of claims. The profiler 10 is an example of a profile information generation unit and a profiling unit disclosed in the scope of claims.
The simulator 7 has a function of analyzing a machine language instruction in the machine language program 104 and simulating the operation of the target processor. Furthermore, the simulator 7 has a function of outputting the execution log information 132 including a control flow and the number of cycles at the time of execution.
The debug processor 8 has a function of, with reference to the final debug information 112 in the machine language program 104, controlling simulation performed by the simulator 7 in accordance with the directive from the user, and performing a control so as to display necessary information by the GUI processor 9, and includes a debug information selection unit 81.
The debug information selection unit 81 selects, in accordance with an option designation by the user or a command directive, whether or not to provide a debugging function at the source level based on the original source program 101 or a debugging function at the source level based on the optimized source program 102. Specifically, the debug information selection unit 81 selects and refers to debug information based on the original source program 101 out of the final debug information 112 in the machine language program 104, in the case where “-orgsrc” option is designated is activated or “orgsrc” command directive is given when the debugging system 6 is activated, and provides a debug function based on the selected debug information. Furthermore, in the case where “-optsrc” option is designated or “optsrc” command directive is given, the debug information selection unit 81 selects and refers to debug information based on the optimized source program 102 out of the final debug information 112 in the machine language program 104, and provides a debug function based on the debug information.
For example, it is assumed that a file name of the machine language program 104 is “test.out” and a command for activating the debugging system 6 is “debug”. In this case, the user designates the “-orgsrc” option by inputting “debug -orgsrc test.out” on a command line.
The GUI processor 9 is a unit for providing a graphical user interface, has functions of receiving a designation from the user and displaying information relating to the program, and includes a source conversion information display unit 91. The source conversion information display unit 91 is an example of a conversion portion display control unit and a selection receiving unit disclosed in the scope of claims.
The source conversion information display unit 91 has a function of displaying information regarding the source portions before and after the optimization performed by the source level optimizer 3. Specifically, the source conversion information display unit 91, with reference to the final debug information 112, detects source portions in the original source program 101 and the optimized source program 102 corresponding to said portions or extracts information regarding said source portions from the optimized support information 123, and displays one or both of the source portions based on the directive from the user. Furthermore, the source conversion information display unit 91 is capable of displaying the number of execution cycles for each source portion and a selection status by the user. For the number of execution cycles, a valid value can be extracted from the final debug information 112 only in the case where the profile information 131, which is described later, is inputted to the compiling system 1.
Note that, the programs before and after the conversion by the source level optimizer 3, which are respectively displayed on the pop-up window 204 and the pop-up window 206, indicate the number of execution cycles by which the program is executed and a conversion pattern selected by the user. Specifically, on the pop-up window 204, “cycle: -” and “select: false” are described, indicating that the number of execution cycles is undetermined and that this conversion pattern is not selected by the user. On the other hand, on the pop-up window 206, “cycle: 1500” and “select: true” are described, indicating that the number of execution cycles is 1500 cycles and that this conversion pattern is selected by the user.
By viewing these displays on the screen, the user can recognize a conversion candidate for the source level optimizer 3 as well as the number of execution cycles in some cases, and therefore the user can select one of the patterns to be preferred for a source program.
The user can designate which one of the conversion pattern candidates is to be selected, through the GUI processor 9, Specifically, a message “Which do you select?” indicating a user to select one of the two types of conversion patterns is displayed as well as three types of buttons 208 to 212 on the display screen 200. When the user presses the button 208 using a mouse or the like, a first conversion pattern displayed on the pop-up window 204 is selected, while when the user presses the button 210, a second conversion pattern displayed on the pop-up window 206 is selected. Furthermore, when the user presses the button 212, it indicates that the user does not select any one of the conversion patterns. Therefore, in the case where the user does not select one conversion pattern, the compiler 5 selects a conversion pattern with the minimum number of cycles so as to generate a machine language program 104.
The selection result of the conversion pattern is outputted to the profiler 10. The profiler 10 can output the user's selection as profile information 131 in the end. Note that the profile information 131 shall be later described in detail.
The original source program 101 is displayed on the pre-conversion source program display window 304. Note that, line numbers of the original source program 101 are simultaneously displayed.
The optimized source program 102 is displayed on the post-conversion source program display window 306. Note that, line numbers of the optimized source program 102 are simultaneously displayed.
The assembler program obtained as the result of compiling the optimized source program 102 is displayed on the assembler program display window 302. Note that, line numbers or labels of the assembler program are simultaneously displayed.
The command input/output window 308 is a window for displaying the debugging result obtained by the debug processor 8 and inputting a command for debugging.
The result obtained when a machine language program corresponding to an assembler program displayed on the assembler program display window 302 is executed by the simulator 7, is displayed on the debug display screen 300. For example, as displayed on the command input/output window 308, at the 27-th line of the original source program 101, an error is indicated because a value of a loop counter i, which originally has to be a positive number, is “−1”. Note that, error portions are displayed in highlight on the assembler program display window 302, the pre-conversion source program display window 204 and a post-conversion source program display window 306. The user can display error portions of the assembler program, original source program 101 and optimized source program 102 so as to be corresponding relationship with each other, by inputting an instruction to perform debugging on the command input/output window 308 or by substituting a value for each variable.
The profiler 10 analyzes the execution log information 132 received from the simulator 7, calculates the number of cycles to be performed by the source level optimizer 3 for each source conversion portion, sets the number of cycles so as to be associated with the source portion included in the final debug information 112, and outputs the profile information 131 which becomes a hint on optimization by the compiling system 1. Furthermore, in the case where the user selects one of the source conversion candidates through the GUI processor 9, the information regarding the selection is also outputted as the profile information 131.
The profile information 131 corresponds to a portion enclosed in tags <ProfileInfo> and </ProfileInfo>. Note that, the portion enclosed in tags <TransInfo> and </TransInfo> indicates optimization support information which is support information for optimization performed at the time of compiling, The profile information 131 defines a value of the number of execution cycles based on the execution log analysis performed by the profiler 10 so that the value corresponds to each conversion pattern with respect to the optimization support information 123 in the source conversion debug information 111. Furthermore, it indicates a value showing a selection state which is one of “true” and “false” indicating whether or not the user has been selected a conversion pattern through the GUI processor 9. The optimization support information shown in
The profile information 131 is utilized by the profile information utilization optimization unit 33 included in the source level optimizer 3 in the compiling system 1.
The profile information utilization optimization unit 33, with 30 reference to the profile information 131, judges whether or not the information indicating that the user selects one of the candidate patterns has been set for each source conversion portion (which is the portion enclosed in tags <TransInfo> and </TransInfo>). Specifically, the profile information utilization optimization unit 33 judges whether or not there is a candidate pattern in which the portion enclosed in tags <UserSelect> and </UserSelect>indicates True.
In the case where it is set to select a candidate pattern (YES in S1), the profile information utilization optimization unit 33 determines a candidate pattern to be compiled, in accordance with a selection directive from the user (S2).
In the case where it is not set to select a candidate pattern (NO in S1), the profile information utilization optimization unit 33 judges, with respect to all the conversion candidates, whether or not the number of cycles has been set (S3). Specifically, the profile information utilization optimization unit 33 judges, for all the conversion candidates, whether or not a value other than “0” is set in the portion enclosed in tags <cycle> and </cycle>.
When judging that the number of cycles has been set for all of the conversion candidates (YES in 53), the profile information utilization optimization unit 33 selects a pattern with the minimum number of cycles out of the conversion candidate patterns as a candidate pattern to be compiled (S4).
In the case where there is a conversion candidate pattern in which the number of cycles has not been set (NO in S3), the profile information utilization optimization unit 33 arbitrary selects one of the conversion candidate patterns in which the number of cycles has not been determined, in order to cause the simulator 7 of the debugging system 6 to perform simulation for setting the number of cycles (S5). The selected conversion candidate pattern is a target to be compiled.
In the example shown in
According to the present embodiment, in the program development system 11, the machine language program 104 can be gradually updated by automatically activating the compiling system 1 and the debugging system 6 again and again through the machine language program 104 and the profile information 131. Specifically, a pattern with the minimum number of cycles can be automatically selected and determined with respect to multiple conversion candidates for source level conversion performed by the source level optimizer 3.
In the program development system 11, the user's time and efforts required for tuning are thus restrained at minimum and an optimum code can be generated.
Furthermore, even in the case where the source level optimizer 3 is adopted in the compiling system 1, the debug information (final debug information 112) can be generated based on the original source program 101. Therefore, the user can perform debugging at the source level based on the original source program 101. In addition, the amount of additional information such as the source conversion debug information 111 which does not exist in the conventional compiling systems can be reduced at best by utilizing as a combination of plural processes such as a line number retaining conversion process by the source level optimizer 3, a line adjustment process by the preprocessor 4 and the compiler 5, and the like.
Whereas the program development system according to the present invention and constituent elements thereof were described based on the above-identified embodiment, the present invention shall not be restricted to such embodiment. In other words, following modifications are assumed.
(1) Whereas a C language specification and a preprocessor directive specification are assumed in the above-identified embodiment, the present invention is not only restricted to the C language and thus remains significant even in the case of utilizing a different programming language.
(2) Whereas a corresponding relationship between pre-conversion line numbers and post-conversion line numbers is indicated as a table structure as the line number table information 121, the present invention is not restricted to this information specification. For example, the present invention remains significant even in the case where a group of only the modified points of the line numbers (modified lines) is indicated.
(3) Whereas a one-to-many corresponding relationship of modified symbols is indicated as a table structure as the symbol table information 122, the present invention is not restricted to this information specification. For example, the present invention maintains its significance even in the case where a table structure indicating a one-to-one corresponding relationship is used in accordance with a predetermined rule based on a debug specification such as adopting a final reference and the like when the pre-conversion symbol is divided into plural symbols.
(4) Whereas in the present embodiment, the source conversion debug information 111 is outputted as a comment in the post-conversion source program (optimized source program 102) as shown in
(5) Whereas in the present embodiment, the profiler 10, which outputs profile information for optimization in the compiling system 1, is placed in the debugging system 6, the present invention is not restricted to this configuration. For example, the effect of the present invention can be realized even in the case where the program development system is configured in that the profiler 10 is taken out as a profiler being an independent program as shown in
(6) Whereas in the present embodiment, hint information to the compiling system 1 is given as the profile information 131, the present invention is not restricted to this directive method. For example, the present invention may adopt a method of providing hint information as a compile option as a type of a directive to the compiling system 1 by the user.
(7) Whereas in the present embodiment, the source conversion information display unit 91 of the debugging system 6 displays two pre-conversion and post-conversion source portions as shown in
(8) Whereas in the present embodiment, the line adjustment unit 41 of the preprocessor 4 and the line number adjustment 51 of the compiler 5 recognize a pragma directive such as “#pragma” inserted by the source level optimizer 3, the present invention may adopt a configuration in which the directive for line adjustment is not restricted to the pragma directive and a specific build-in function is analyzed so as to recognize that the insertion of a built-in function is inserted by the source level optimizer.
Although only an exemplary embodiment of this invention has been described in detail above, those skilled in the art will readily appreciate that many modifications are possible in the exemplary embodiment without materially departing from the novel teachings and advantages of this invention. Accordingly, all such modifications are intended to be included within the scope of this invention.
The present invention is applicable to a program develop system and the like which includes a compiling system and a debugging system.
Number | Date | Country | Kind |
---|---|---|---|
2005/337648 | Nov 2005 | JP | national |