DETAILED DESCRIPTION OF THE INVENTION

[0014] The present invention is directed to a method and apparatus that uses a software breakpoint function 100 , which may be a specially named void function, to implement a software breakpoint. Implementation of the present invention requires only minimal modification of the application program 102 into which software breakpoints are desired. Instead, the present invention relies on a debugging tool 104 that, in one preferred embodiment, includes a software breakpoint monitoring processor 106 , a software breakpoint action determinator 108 , and a software breakpoint action implementor 110 . Using the debugging tool 104 of the present invention offers portability between different types of CPUs and safe operation of the application program 102 when the debugging tool 104 is not running.

[0015] The term “function” is generally defined as a section of a program that performs a specific task. When a function call is executed, program control transfers to the section of the program where the function is located. After the function executes, program control returns to the next statement following the function call. Although the present invention has been discussed in terms of “functions,” it should be noted that any type of subprogram could be used to implement the invention as long as the particular programming language allowed for a void or empty subprogram to be called. Alternative exemplary subprograms include subroutines, procedures, macros, or any type of subprogram.

[0016] The term “void function” is used to describe any function that does nothing. For example, although the term “void function” as it is used in “C” is generally defined as a function that has no input or output arguments, if a C void function did nothing when it was run it would fall into the category of a void function for the present invention. If, however, a C void function did something (e.g. performed a step) it would not fall into the category of a void function for the present invention. In other words, for the preferred embodiment of the present invention, a void function preferably does nothing.

[0017] For the purpose of illustrating the present invention, the invention will be discussed in source code terms. However, in actual implementation, the debugging tool 104 would probably be executing and monitoring object code.

[0018] For the purpose of illustrating the present invention, several exemplary programs and functions will be used. Although the exemplary programs are written in ADA (or loosely based on the ADA programming language), the present invention could be applied to programs that were written in any programming language. “Function Code 1: function MAX” is an exemplary function that finds the larger of two integers. “Program Code 1: MAX_DEMO” is an exemplary program that uses function MAX to find the largest of three integers. 1 Function Code 1: function MAX function MAX (X,Y : INTEGER) return INTEGER is begin if X > Y then return X; else return Y; end if; end MAX; Program Code 1: MAX_DEMO with TEXT_IO, BASIC_NUM_IO; use TEXT_IO, BASIC_NUM_IO; procedure MAX_DEMO is A, B, C, M : INTEGER function MAX (X,Y : INTEGER) return INTEGER is begin if X > Y then return X; else return Y; end if; end MAX; begin loop PUT_LINE (“Enter three whole numbers”); Exit when END_OF_FILE; GET(A); GET(B); GET(C); M := MAX(A, B); M := MAX(M, C); PUT(“The biggest of them is “); PUT(M); NEW_LINE; end loop; end MAX_DEMO;

[0019] A software breakpoint function 100 of the present invention itself does not perform an operation. That is, the software breakpoint function 100 of the present invention is a void function. For example, one exemplary software breakpoint function 100 might be named “DEBUG TERMINATE.” As a second example, a software breakpoint function 100 might be named simply “SOFTWARE BREAKPOINT.” These are shown in “Function Code 2: function DEBUG TERMINATE” and “Function Code 3: function SOFTWARE BREAKPOINT.” 2 Function Code 2: function DEBUG TERMINATE function DEBUG TERMINATE ( ) is begin end DEBUG TERMINATE; Function Code 3: function SOFTWARE BREAKPOINT function SOFTWARE BREAKPOINT ( ) is begin end SOFTWARE BREAKPOINT;

[0020] “Program Code 2: MAX_DEMO_DEBUG” is a modified version of Program Code 2: MAX_DEMO that includes software breakpoint functions 100 “Function Code 2: function DEBUG TERMINATE” and “Function Code 3: function SOFTWARE BREAKPOINT.” If a programmer were to try to debug MAX_DEMO, then MAX_DEMO would be modified to look something like MAX_DEMO_DEBUG. 3 Program Code 2: MAX_DEMO_DEBUG with TEXT_IO, BASIC_NUM_IO; use TEXT_IO, BASIC_NUM_IO; procedure MAX_DEMO_DEBUG is A, B, C, M : INTEGER function DEBUG TERMINATE ( ) is begin end DEBUG TERMINATE; function SOFTWARE BREAKPOINT ( ) is begin end SOFTWARE BREAKPOINT; function MAX (X,Y : INTEGER) return INTEGER is begin if X > Y then return X; SOFTWARE BREAKPOINT; else return Y; end if; end MAX; begin loop PUT_LINE (“Enter three whole numbers”); Exit when END_OF_FILE; GET(A); GET(B); GET(C); SOFTWARE BREAKPOINT; M := MAX(A, B); M := MAX(M, C); SOFTWARE BREAKPOINT; PUT(“The biggest of them is “); PUT(M); NEW_LINE; DEBUG TERMINATE; end loop; end MAX_DEMO_DEBUG;

[0021] As shown in MAX_DEMO_DEBUG, multiple software breakpoint functions 100 and multiple types of software breakpoint functions 100 (e.g. SOFTWARE BREAKPOINT and DEBUG TERMINATE) may be inserted into each program. Further, software breakpoint functions may be inserted into subprograms (such as function MAX (X,Y: INTEGER) which includes the software breakpoint function SOFTWARE BREAKPOINT.

[0022] A programmer desiring to use the present invention to debug an application program would take his programming code (e.g. MAX_DEMO) and define one or more software breakpoint functions 100 as void functions (e.g. SOFTWARE BREAKPOINT and DEBUG TERMINATE). Alternatively, a programming language could include a library of predefined software breakpoint functions 100 .

[0023] In one preferred embodiment, the debugging tool 104 would recognize any predefined void functions having specific names as a software breakpoint function 100 . In another alternative preferred embodiment, the debugging tool 104 could be modified to accept user defined void functions as a software breakpoint function 100 . In yet another preferred embodiment, the debugging tool 104 would recognize any void function, and check to see if it is a software breakpoint function 100 . In still yet another alternative preferred embodiment, the debugging tool 100 could have a combination of the aforementioned possibilities.

[0024] The programmer would then insert at least one software breakpoint function (e.g. SOFTWARE BREAKPOINT and DEBUG TERMINATE) into the application program (e.g. MAX_DEMO) as is shown in MAX_DEMO_DEBUG.

[0025] The action performed by the debugging tool 104 may be any known debugging procedure, such as halting, pausing, terminating, or single-stepping program execution. In an interactive debugging system, a graphical user interface may be used to allow the programmer to monitor, control, and/or have input in the debugging process. In one preferred embodiment the software breakpoint functions 100 are given specific names that are associated with a desired breakpoint action. When the debugging tool 104 detects that the named software breakpoint function 100 has been called, the debugging tool 104 performs the desired breakpoint action. The action performed by the debugging tool 104 may be any known debugging procedure, such as halting, pausing, or single-stepping program execution. If the desired breakpoint action was halting, the function might be named SOFTWARE BREAKPOINT HALTING or just HALTING. Similarly, if the desired breakpoint action was single-stepping program execution, the function might be named SOFTWARE BREAKPOINT SINGLE or just SINGLE-STEPPING PROGRAM EXECUTION. Although for ease of understanding code these meaningful names would be preferable, for complicated programs or just for consistency, alternative non-meaningful names (e.g. codes or numbers) could be used.

[0026] Once the programmer has programmed his application program, the application program may be compiled (converting the source code to object code). Significantly, because the software breakpoint functions 100 are implemented as standard functions for a particular type of program, the compiler would compile the software breakpoint functions 100 as it would any other function. The compiled software breakpoint function 100 , however, would perform no action.

[0027] Although most compilers include a debugging tool 104 that runs substantially simultaneously with the compiler, for purposes of this invention the debugging tool 104 will be discussed as separate from the compiler. Alternative embodiments could include a combined compiler and debugging tool 104 .

[0028] Turing to FIG. 1 , the present invention is directed to a debugging tool 104 for debugging an application program 102 having at least one software breakpoint function 100 . The debugging tool 104 , in one preferred embodiment, includes a software breakpoint monitoring processor 106 , a software breakpoint action determinator 108 , and a software breakpoint action implementor 110 . The software breakpoint monitoring processor 106 monitors the application program 102 and recognizes the software breakpoint function 100 . As shown in FIG. 1 , the software breakpoint monitoring processor 106 monitors each line of code until the software breakpoint function 100 is detected. Using Program Code 2: MAX_DEMO_DEBUG as an example, the software breakpoint monitoring processor 106 of the debugging tool 104 would start monitoring as the main program (MAX_DEMO_DEBUG) began. Since the code line “loop” is not a software breakpoint function 100 , the application program 102 would execute that line of code. Since the code line “PUT_LINE (“Enter three whole numbers”);” is not a software breakpoint function 100 , the application program 102 would execute that line of code. Since the code line “Exit when END_OF_FILE;” is not a software breakpoint function 100 , the application program 102 would execute that line of code. Since the code line “GET(A); GET(B); GET(C);” is not a software breakpoint function 100 , the application program 102 would execute that line of code. However, when the software breakpoint monitoring processor 106 came to the code line “SOFTWARE BREAKPOINT;” the software breakpoint monitoring processor 106 would recognize it as a software breakpoint function 100 and call the software breakpoint action determinator 108 .

[0029] The software breakpoint action determinator 108 would then determine an action to be performed based on the software breakpoint function. For example, the software breakpoint action determinator 108 may determine that the software breakpoint function 100 is an instruction for halting, pausing, terminating, or single-stepping program execution. The software breakpoint action determinator 108 may be a table lookup in which the specially named function is used to look-up the appropriate action. Alternatively, the software breakpoint action determinator 108 may use the specially named function to call a function within the debugging tool 104 . Upon determining the action to be performed, the software breakpoint action determinator 108 provides instructions to the software breakpoint action implementor 110 .

[0030] The software breakpoint action implementor 110 , upon receiving the instructions from the software breakpoint action determinator 108 , implements the action. For example, if the software breakpoint action implementor 110 could perform any any known debugging procedure, such as halting, pausing, terminating, or single-stepping program execution.

[0031] It should be noted that in one preferred embodiment the software breakpoint monitoring processor 106 and the software breakpoint action determinator 108 are significantly interconnected and may be implemented by a single device or as a single step. For example, the software breakpoint monitoring processor 106 may use the a lookup table in the software breakpoint action determinator 108 to determine whether a particular line of code is a software breakpoint function 100 .

[0032] It should be noted that in one preferred embodiment the software breakpoint action determinator 108 and the software breakpoint action implementer 110 are implemented by a single device or as a single step. For example, in the embodiment in which the specially named function is used to call a function within the debugging tool 104 which is immediately executed, the software breakpoint action determinator 108 and the software breakpoint action implementer 110 would essentially be carried out simultaneously.

[0033] Turning to FIG. 2, a method according to the present invention begins with two optional steps: programming an application program 200 and inserting at least one software breakpoint function into the application program 202 . These steps, which are discussed above in detail, are optional because code may be used that has the software breakpoint functions preprogrammed. The next step is running the application program for the purpose of debugging 204 . As set forth above, this may include compiling and debugging either separately or in combination. While the application program is running, the software breakpoint monitoring processor is monitoring the application program for software breakpoint functions such as a specially named function 206 . Upon recognizing a software breakpoint function or specially named function, the next step is determining an action to be performed based on the software breakpoint function or specially named function 208 . The action prescribed by the software breakpoint function or specially named function is then implemented 210 . Finally, the debugging program returns to the application program 220 and continues the monitoring.

[0034] FIG. 3 shows the step-by-step process used by the debugging tool 104 to implement one preferred embodiment of the present invention. Specifically, the debugging process is started 300 and a first line of code of the running application program is monitored 302 . The debugging tool then determines whether the first line of code includes a software breakpoint function 304 . If the first line of code includes a software breakpoint function, the debugging tool determines what action is appropriate 306 , implements the action prescribed by the software breakpoint function 308 , and returns to the application program 310 . If the first line of code does not include a software breakpoint function or if the debugging tool returns to the application program, the debugging tool then looks to whether the line is the last line of code in the application program 312 . If it is, the debugging process ends 316 . If it is not the last line of code, then the process advances once line of code 314 and the monitoring processes begins for the new line of code 302 .

[0035] If the debugging tool 104 is not running, no operation is performed by the named software breakpoint function 100 , and program control returns to the next statement following the function call. This is one of the advantages of using a function to implement a software breakpoint. Specifically, the inadvertent failure of a programmer to remove a software breakpoint function 100 after debugging does not result in harmful consequences. As an example, if Program Code 2: MAX_DEMO_DEBUG were running and the debugging tool 104 was not turned on, the code lines “loop,” “PUT_LINE (“Enter three whole numbers”);,” “Exit when END_OF_FILE;,” and “GET(A); GET(B); GET(C);” would run normally. When the code line with the software breakpoint monitoring function 100 “SOFTWARE BREAKPOINT;” was encountered, the function SOFTWARE BREAKPOINT ( ) would be called. SOFTWARE BREAKPOINT ( ) would then run, but since it is a void function with no actions to execute, program control would return to the next line of code (“M:=MAX(A, B);”) following the function call.

[0036] The present invention may be implemented as a medium readable by a device such as a processor or other computing device. The medium may be any storage device including, but not limited to software, hardware, firmware, or any device capable of embodying a program of instructions for execution by the device to perform a method for debugging an application program. In one preferred embodiment of the present invention the medium has instructions thereon for receiving code having a software breakpoint function, running the code for the purpose of debugging, monitoring the code to detect the presence of the software breakpoint function, recognizing the software breakpoint function, determining an action to be performed based on the software breakpoint function, and implementing the action. The medium may have instructions thereon for returning to the code and continuing monitoring the code. Further, the medium may have instructions thereon for recognizing one software breakpoint function by the code to a list of known software breakpoint functions. Further, the medium may have instructions thereon for determining an action to be performed by comparing the software breakpoint function to a list of known software breakpoint functions with associated actions and using an associated action to a known software breakpoint function equivalent to the software breakpoint function as the action to be performed.

[0037] For purposes of illustration, the following example of an exemplary specific use of the present invention is provided. The present invention may be implemented as part of a self-contained ARM CPU based development board (“platform”) having a CPU, display, and several peripherals. Development tools such as a compiler, a linker, and a debugger are used to write programs that run on this platform in a preferably user-friendly environment. For example, in an IDE (Integrated Development Environment), Free Software Foundation (“GNU”) tools such as GCC (compiler), LD (linker), GDB (debugger) may be used. For purposes of this example, the development tools run on a standard PC. Programs to run on the platform are created on the PC and then loaded and executed on the platform. Compiler input is the source code of the program as written by a programmer and the compiler output (with linker cooperation) is the executable program image. The debugger enables the user to monitor (e.g. stop, peek, poke, etc.) the running program. The compiler and the linker can produce an image that contains information useful to the debugger, for example the machine code addresses of every source code line of the source code. Preferably debugger does not interfere with the running program, so that it can emulate exactly the same behavior from the running program regardless whether it is debugged or not. In other words, the running program is unaware that it is being debugged.

[0038] In this example, instead of placing a special instruction in the place of interest in the source code, a software call to a specially named function is issued. There is no other function of the same name in the code and the debugger always sets a breakpoint at the function of that name. Using an exemplary specially named function, _DebugBreak, what would happen would be the program would execute until it reaches the place where _DebugBreak would be called. The debugger would detect this. The name of the function, _DebugBreak, would be recognized. Then, the exemplary desired action would be to break the execution at the place where _DebugBreak returns. The net result would be that the programs breaks the execution and allows single stepping at exactly the place the programmer intended.

[0039] In this example, a similar mechanism is also used to detect the program termination. When the program “terminates,” it typically enters an endless loop, effectively continuing to run, doing nothing. As the program is unaware of being debugged, it cannot (and in any case does not know how to) signal to the debugger that it terminated. The debugger then keeps running until a human operator manually stops it. To terminate the debug session once the debugged program terminated, another specially named function _DebugTerminate, is added. When the function _DebugTerminate is called the debug session is terminated.

[0040] In this example, both of the functions _DebugBreak and _DebugTerminate are always present in the runtime libraries, so the programmer does not have to write them. They are quite minimalistic, as by themselves they don't perform any action; their purpose is simply to be called to signal something to the debugger.

[0041] In this example, the action of setting breakpoints at specially named functions is done automatically by the IDE every time the program is debugged. The actions to be performed when a specially named function call is detected are performed automatically by the IDE as well. To implement this exemplary method, none of the tools (e.g. compiler, linker, debugger) need to be modified.

[0042] It should be noted that the debugging tool 104 may be implemented as a software program, as hardware (or firmware), or as a single programmable integrated circuit chip.

[0043] The use of a software breakpoint function 100 is advantageous when developing an application running on a remote target (such as a development board or a cellular telephone) that communicates via a serial connection with a development environment running on a personal computer.

[0044] The terms and expressions that have been employed in the foregoing specification are used as terms of description and not of limitation, and are not intended to exclude equivalents of the features shown and described or portions of them. The scope of the invention is defined and limited only by the claims that follow.