#include <debug.hpp>
Public Member Functions | |
| bool | update (void) const |
| Called from the start of the application event handler to determine if the user has requested to view the debug output. | |
| int | getLogLevel (void) const |
| Returns the current debugging log level. | |
| void | setLogLevel (int l) |
| Sets the current debugging log level. Legal values are in the range of 0 - 3. A value of 0 disables logging. A value less than 0 results in a log level of zero, and likewise, a log level greater than three results in a log level of three. | |
| bool | dbg_printf (const char *fmt,...) |
| Parses the format and stores the resulting string into a circular buffer. | |
| bool | debug (void) const |
| Tests user input using the trigger function. When the trigger function indicates to go into debug mode, this routine saves current state information, and then takes over the interrupt handler and the screens. The current debug information is displayed to the user until they indicate they would like to exit. Then the original state information is restored, and control returns to the application. | |
Static Public Member Functions | |
| Debug & | Inst (void) |
| Returns a reference to the one and only Debug instance. | |
| void | setTriggerFunc (triggerFunc trigger) |
| Allows the user to set the trigger test function. | |
Private Member Functions | |
| Debug () | |
| Private constructor to allow creation only by Inst. | |
| Debug (const Debug &) | |
| Private copy constructor to prevent copies of the class. | |
| Debug & | operator= (const Debug &) |
| Private operator= to prevent copies of the class. | |
The Debug class provides a mechanism to aid in debugging applications, yet easily turns off debugging to prepare releases to the public. The code is not changed, so as bug reports are processed, versions of the application can be built with debugging enabled for problem determination.
To use the Debug class in your application requires only a few steps.
Optionally:
Some example code to provide a better picture:
void interrupt_handler(void) { static int counter = 0; if (IF & IRQ_VBLANK) { if (!dbg_process_update) { ++counter; // normal interupt handler code. if ((counter % 1024) == 0) { dbg_printf2("counter = %d", counter); } } IF = IRQ_VBLANK; } }
When the user requests to view debugging information, the Debug class saves the current interrupt handler and interupt event requests, and changes it to an internal handler. Screen state information is saved as well. Then control returns back to the application. Then the Debug module takes control of the screen and displays the debug log. The user can use the up/down on the D-pad to scroll the display, and the A/B buttons function as a page-up/page-down.
Pressing the Select button causes the handler to restore the previous interrupt handler and interrupt request flags as well as restoring the screen. The handler then exits allowing control to return back to the application interrupt handler.
Barring the application's use of the real-time clock for timing, ideally, the application will continue running right where it left off without any ill effects or even noticing the delay between calls to the real interrupt handler.
Some effort has been made at robustness. The desire is that even if the application is having serious problems, as long as the interrupt handler is still basically functioning, that the application should be able to get to debug mode.
|
|
Called from the start of the application event handler to determine if the user has requested to view the debug output.
|
|
|
Sets the current debugging log level. Legal values are in the range of 0 - 3. A value of 0 disables logging. A value less than 0 results in a log level of zero, and likewise, a log level greater than three results in a log level of three.
|
|
||||||||||||
|
Parses the format and stores the resulting string into a circular buffer. Note that the maximum length of the result of parsing the format statement can be no longer than MAX_DEBUG_LINE_LENGTH.
|
|
|
Tests user input using the trigger function. When the trigger function indicates to go into debug mode, this routine saves current state information, and then takes over the interrupt handler and the screens. The current debug information is displayed to the user until they indicate they would like to exit. Then the original state information is restored, and control returns to the application.
|
1.3.6