t_debug

These functions allow for textual debug mode. Hence, debug statements can stay with your code.
429 download
Aggiornato 22 nov 2010

Visualizza la licenza

This function T_DEBUG will turn textual debug mode 'on' or 'off'. This follows the philosophy described by Brian Kernighan and Rob Pike in "The Practice of Programming":

"... we find stepping through a program less productive than thinking harder and adding output statements and self-checking code at critical places. Clicking over statements takes longer than scanning the output of judiciously-placed displays. It takes less time to decide where to put print statements than to single-step to the critical section of code, even assuming we know where that is. More important, debugging statements stay with the program; debugging sessions are transient."

To allow for debugging statements that stay with the program and can be switched on and off, I wrote two very simple Matlab functions
(t_debug.m, print_debug.m). Here is how they work:

>> t_debug on
>> print_debug('t_debug is on');
DEBUG: t_debug is on

>> t_debug
DEBUG state: 1

>> t_debug off
>> print_debug('This should not print');

>> t_debug offff
Warning: USE: debug(mode) with mode='on', 'off', or a numeric value to set debugging to a certain level. You used 'offff'.
> In t_debug at 54

>> t_debug(10)
>> print_debug('t_debug prints up to level 10', 9)
DEBUG: (L=9) t_debug prints up to level 10
>> print_debug('t_debug prints up to level 10 (this won''t print)', 11)
>> print_debug('t_debug prints up to level 10')
DEBUG: t_debug prints up to level 10

>> t_debug
DEBUG state: 10

A test/example is included to demonstrate the functionality.

Cita come

Ronni Grapenthin (2026). t_debug (https://it.mathworks.com/matlabcentral/fileexchange/26666-t_debug), MATLAB Central File Exchange. Recuperato .

Compatibilità della release di MATLAB
Creato con R2008b
Compatibile con qualsiasi release
Compatibilità della piattaforma
Windows macOS Linux
Categorie
Scopri di più su Debugging and Analysis in Help Center e MATLAB Answers
Versione Pubblicato Note della release
1.3.0.0

Allows for fine grained debugging output by implementing numeric levels.
Includes example (t_debug_test.m) to test functionality and demonstrate use cases.
Uses of t_debug_config.mat for string constants used within t_debug.m and print_debug.m.

1.0.0.0