Browse Source

[debug] Expose pause() and more() debugging functions

Include the pause() and more() debugging functions within the general
iPXE debugging framework, by introducing DBGxxx_PAUSE() and
DBGxxx_MORE() macros.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 14 years ago
parent
commit
7aa1d70e52
2 changed files with 88 additions and 28 deletions
  1. 12
    4
      src/core/debug.c
  2. 76
    24
      src/include/compiler.h

+ 12
- 4
src/core/debug.c View File

4
 #include <ipxe/io.h>
4
 #include <ipxe/io.h>
5
 #include <console.h>
5
 #include <console.h>
6
 
6
 
7
-void pause ( void ) {
8
-	printf ( "\nPress a key" );
7
+/**
8
+ * Pause until a key is pressed
9
+ *
10
+ */
11
+void dbg_pause ( void ) {
12
+	printf ( "\nPress a key..." );
9
 	getchar();
13
 	getchar();
10
-	printf ( "\r           \r" );
14
+	printf ( "\r              \r" );
11
 }
15
 }
12
 
16
 
13
-void more ( void ) {
17
+/**
18
+ * Indicate more data to follow and pause until a key is pressed
19
+ *
20
+ */
21
+void dbg_more ( void ) {
14
 	printf ( "---more---" );
22
 	printf ( "---more---" );
15
 	getchar();
23
 	getchar();
16
 	printf ( "\r          \r" );
24
 	printf ( "\r          \r" );

+ 76
- 24
src/include/compiler.h View File

257
 extern void dbg_decolourise ( void );
257
 extern void dbg_decolourise ( void );
258
 extern void dbg_hex_dump_da ( unsigned long dispaddr,
258
 extern void dbg_hex_dump_da ( unsigned long dispaddr,
259
 			      const void *data, unsigned long len );
259
 			      const void *data, unsigned long len );
260
+extern void dbg_pause ( void );
261
+extern void dbg_more ( void );
260
 
262
 
261
 #if DEBUG_SYMBOL
263
 #if DEBUG_SYMBOL
262
 #define DBGLVL_MAX DEBUG_SYMBOL
264
 #define DBGLVL_MAX DEBUG_SYMBOL
332
 		DBG_HDA_IF ( level, _data, _data, len );	\
334
 		DBG_HDA_IF ( level, _data, _data, len );	\
333
 	} while ( 0 )
335
 	} while ( 0 )
334
 
336
 
337
+/**
338
+ * Prompt for key press if we are at a certain debug level
339
+ *
340
+ * @v level		Debug level
341
+ */
342
+#define DBG_PAUSE_IF( level ) do {				\
343
+		if ( DBG_ ## level ) {				\
344
+			dbg_pause();				\
345
+		}						\
346
+	} while ( 0 )
347
+
348
+/**
349
+ * Prompt for more output data if we are at a certain debug level
350
+ *
351
+ * @v level		Debug level
352
+ */
353
+#define DBG_MORE_IF( level ) do {				\
354
+		if ( DBG_ ## level ) {				\
355
+			dbg_more();				\
356
+		}						\
357
+	} while ( 0 )
358
+
335
 /**
359
 /**
336
  * Select colour for debug messages if we are at a certain debug level
360
  * Select colour for debug messages if we are at a certain debug level
337
  *
361
  *
380
 		DBG_DC_IF ( level );				\
404
 		DBG_DC_IF ( level );				\
381
 	} while ( 0 )
405
 	} while ( 0 )
382
 
406
 
407
+#define DBGC_PAUSE_IF( level, id ) do {				\
408
+		DBG_AC_IF ( level, id );			\
409
+		DBG_PAUSE_IF ( level );				\
410
+		DBG_DC_IF ( level );				\
411
+	} while ( 0 )
412
+
413
+#define DBGC_MORE_IF( level, id ) do {				\
414
+		DBG_AC_IF ( level, id );			\
415
+		DBG_MORE_IF ( level );				\
416
+		DBG_DC_IF ( level );				\
417
+	} while ( 0 )
418
+
383
 /* Versions of the DBGxxx_IF() macros that imply DBGxxx_IF( LOG, ... )*/
419
 /* Versions of the DBGxxx_IF() macros that imply DBGxxx_IF( LOG, ... )*/
384
 
420
 
385
-#define DBG( ... )		DBG_IF		( LOG, __VA_ARGS__ )
386
-#define DBG_HDA( ... )		DBG_HDA_IF	( LOG, __VA_ARGS__ )
387
-#define DBG_HD( ... )		DBG_HD_IF	( LOG, __VA_ARGS__ )
388
-#define DBGC( ... )		DBGC_IF		( LOG, __VA_ARGS__ )
389
-#define DBGC_HDA( ... )		DBGC_HDA_IF	( LOG, __VA_ARGS__ )
390
-#define DBGC_HD( ... )		DBGC_HD_IF	( LOG, __VA_ARGS__ )
421
+#define DBG( ... )		DBG_IF		( LOG, ##__VA_ARGS__ )
422
+#define DBG_HDA( ... )		DBG_HDA_IF	( LOG, ##__VA_ARGS__ )
423
+#define DBG_HD( ... )		DBG_HD_IF	( LOG, ##__VA_ARGS__ )
424
+#define DBG_PAUSE( ... )	DBG_PAUSE_IF	( LOG, ##__VA_ARGS__ )
425
+#define DBG_MORE( ... )		DBG_MORE_IF	( LOG, ##__VA_ARGS__ )
426
+#define DBGC( ... )		DBGC_IF		( LOG, ##__VA_ARGS__ )
427
+#define DBGC_HDA( ... )		DBGC_HDA_IF	( LOG, ##__VA_ARGS__ )
428
+#define DBGC_HD( ... )		DBGC_HD_IF	( LOG, ##__VA_ARGS__ )
429
+#define DBGC_PAUSE( ... )	DBGC_PAUSE_IF	( LOG, ##__VA_ARGS__ )
430
+#define DBGC_MORE( ... )	DBGC_MORE_IF	( LOG, ##__VA_ARGS__ )
391
 
431
 
392
 /* Versions of the DBGxxx_IF() macros that imply DBGxxx_IF( EXTRA, ... )*/
432
 /* Versions of the DBGxxx_IF() macros that imply DBGxxx_IF( EXTRA, ... )*/
393
 
433
 
394
-#define DBG2( ... )		DBG_IF		( EXTRA, __VA_ARGS__ )
395
-#define DBG2_HDA( ... )		DBG_HDA_IF	( EXTRA, __VA_ARGS__ )
396
-#define DBG2_HD( ... )		DBG_HD_IF	( EXTRA, __VA_ARGS__ )
397
-#define DBGC2( ... )		DBGC_IF		( EXTRA, __VA_ARGS__ )
398
-#define DBGC2_HDA( ... )	DBGC_HDA_IF	( EXTRA, __VA_ARGS__ )
399
-#define DBGC2_HD( ... )		DBGC_HD_IF	( EXTRA, __VA_ARGS__ )
434
+#define DBG2( ... )		DBG_IF		( EXTRA, ##__VA_ARGS__ )
435
+#define DBG2_HDA( ... )		DBG_HDA_IF	( EXTRA, ##__VA_ARGS__ )
436
+#define DBG2_HD( ... )		DBG_HD_IF	( EXTRA, ##__VA_ARGS__ )
437
+#define DBG2_PAUSE( ... )	DBG_PAUSE_IF	( EXTRA, ##__VA_ARGS__ )
438
+#define DBG2_MORE( ... )	DBG_MORE_IF	( EXTRA, ##__VA_ARGS__ )
439
+#define DBGC2( ... )		DBGC_IF		( EXTRA, ##__VA_ARGS__ )
440
+#define DBGC2_HDA( ... )	DBGC_HDA_IF	( EXTRA, ##__VA_ARGS__ )
441
+#define DBGC2_HD( ... )		DBGC_HD_IF	( EXTRA, ##__VA_ARGS__ )
442
+#define DBGC2_PAUSE( ... )	DBGC_PAUSE_IF	( EXTRA, ##__VA_ARGS__ )
443
+#define DBGC2_MORE( ... )	DBGC_MORE_IF	( EXTRA, ##__VA_ARGS__ )
400
 
444
 
401
 /* Versions of the DBGxxx_IF() macros that imply DBGxxx_IF( PROFILE, ... )*/
445
 /* Versions of the DBGxxx_IF() macros that imply DBGxxx_IF( PROFILE, ... )*/
402
 
446
 
403
-#define DBGP( ... )		DBG_IF		( PROFILE, __VA_ARGS__ )
404
-#define DBGP_HDA( ... )		DBG_HDA_IF	( PROFILE, __VA_ARGS__ )
405
-#define DBGP_HD( ... )		DBG_HD_IF	( PROFILE, __VA_ARGS__ )
406
-#define DBGCP( ... )		DBGC_IF		( PROFILE, __VA_ARGS__ )
407
-#define DBGCP_HDA( ... )	DBGC_HDA_IF	( PROFILE, __VA_ARGS__ )
408
-#define DBGCP_HD( ... )		DBGC_HD_IF	( PROFILE, __VA_ARGS__ )
447
+#define DBGP( ... )		DBG_IF		( PROFILE, ##__VA_ARGS__ )
448
+#define DBGP_HDA( ... )		DBG_HDA_IF	( PROFILE, ##__VA_ARGS__ )
449
+#define DBGP_HD( ... )		DBG_HD_IF	( PROFILE, ##__VA_ARGS__ )
450
+#define DBGP_PAUSE( ... )	DBG_PAUSE_IF	( PROFILE, ##__VA_ARGS__ )
451
+#define DBGP_MORE( ... )	DBG_MORE_IF	( PROFILE, ##__VA_ARGS__ )
452
+#define DBGCP( ... )		DBGC_IF		( PROFILE, ##__VA_ARGS__ )
453
+#define DBGCP_HDA( ... )	DBGC_HDA_IF	( PROFILE, ##__VA_ARGS__ )
454
+#define DBGCP_HD( ... )		DBGC_HD_IF	( PROFILE, ##__VA_ARGS__ )
455
+#define DBGCP_PAUSE( ... )	DBGC_PAUSE_IF	( PROFILE, ##__VA_ARGS__ )
456
+#define DBGCP_MORE( ... )	DBGC_MORE_IF	( PROFILE, ##__VA_ARGS__ )
409
 
457
 
410
 /* Versions of the DBGxxx_IF() macros that imply DBGxxx_IF( IO, ... )*/
458
 /* Versions of the DBGxxx_IF() macros that imply DBGxxx_IF( IO, ... )*/
411
 
459
 
412
-#define DBGIO( ... )		DBG_IF		( IO, __VA_ARGS__ )
413
-#define DBGIO_HDA( ... )	DBG_HDA_IF	( IO, __VA_ARGS__ )
414
-#define DBGIO_HD( ... )		DBG_HD_IF	( IO, __VA_ARGS__ )
415
-#define DBGCIO( ... )		DBGC_IF		( IO, __VA_ARGS__ )
416
-#define DBGCIO_HDA( ... )	DBGC_HDA_IF	( IO, __VA_ARGS__ )
417
-#define DBGCIO_HD( ... )	DBGC_HD_IF	( IO, __VA_ARGS__ )
460
+#define DBGIO( ... )		DBG_IF		( IO, ##__VA_ARGS__ )
461
+#define DBGIO_HDA( ... )	DBG_HDA_IF	( IO, ##__VA_ARGS__ )
462
+#define DBGIO_HD( ... )		DBG_HD_IF	( IO, ##__VA_ARGS__ )
463
+#define DBGIO_PAUSE( ... )	DBG_PAUSE_IF	( IO, ##__VA_ARGS__ )
464
+#define DBGIO_MORE( ... )	DBG_MORE_IF	( IO, ##__VA_ARGS__ )
465
+#define DBGCIO( ... )		DBGC_IF		( IO, ##__VA_ARGS__ )
466
+#define DBGCIO_HDA( ... )	DBGC_HDA_IF	( IO, ##__VA_ARGS__ )
467
+#define DBGCIO_HD( ... )	DBGC_HD_IF	( IO, ##__VA_ARGS__ )
468
+#define DBGCIO_PAUSE( ... )	DBGC_PAUSE_IF	( IO, ##__VA_ARGS__ )
469
+#define DBGCIO_MORE( ... )	DBGC_MORE_IF	( IO, ##__VA_ARGS__ )
418
 
470
 
419
 
471
 
420
 #if DEBUG_SYMBOL == 0
472
 #if DEBUG_SYMBOL == 0

Loading…
Cancel
Save