diff options
| author | Keith Packard <keithp@keithp.com> | 2017-12-03 19:47:03 -0800 | 
|---|---|---|
| committer | Keith Packard <keithp@keithp.com> | 2017-12-03 19:47:03 -0800 | 
| commit | ed6967cef5d82baacafe1c23229f44d58c838326 (patch) | |
| tree | 42a297a91356516df606d5a31002f6caa1df3b8a /src/lisp/ao_lisp_error.c | |
| parent | b9009b3916956db00b7b78bd06fb0df704690eb1 (diff) | |
altos/lisp: Split out read debug, add memory validation
Split read debug into a separate #define to reduce debug noise
Add some memory validation -- validate stash API, and validate
cons_free calls.
Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'src/lisp/ao_lisp_error.c')
| -rw-r--r-- | src/lisp/ao_lisp_error.c | 48 | 
1 files changed, 42 insertions, 6 deletions
| diff --git a/src/lisp/ao_lisp_error.c b/src/lisp/ao_lisp_error.c index ba135834..7f909487 100644 --- a/src/lisp/ao_lisp_error.c +++ b/src/lisp/ao_lisp_error.c @@ -82,6 +82,43 @@ ao_lisp_error_frame(int indent, char *name, struct ao_lisp_frame *frame)  		printf ("}\n");  } +void +ao_lisp_vprintf(char *format, va_list args) +{ +	char c; + +	while ((c = *format++) != '\0') { +		if (c == '%') { +			switch (c = *format++) { +			case 'v': +				ao_lisp_poly_write((ao_poly) va_arg(args, unsigned int)); +				break; +			case 'p': +				printf("%p", va_arg(args, void *)); +				break; +			case 'd': +				printf("%d", va_arg(args, int)); +				break; +			case 's': +				printf("%s", va_arg(args, char *)); +				break; +			default: +				putchar(c); +				break; +			} +		} else +			putchar(c); +	} +} + +void +ao_lisp_printf(char *format, ...) +{ +	va_list args; +	va_start(args, format); +	ao_lisp_vprintf(format, args); +	va_end(args); +}  ao_poly  ao_lisp_error(int error, char *format, ...) @@ -90,14 +127,13 @@ ao_lisp_error(int error, char *format, ...)  	ao_lisp_exception |= error;  	va_start(args, format); -	vprintf(format, args); +	ao_lisp_vprintf(format, args); +	putchar('\n');  	va_end(args); -	printf("\n"); -	printf("Value: "); ao_lisp_poly_write(ao_lisp_v); printf("\n"); +	ao_lisp_printf("Value:  %v\n", ao_lisp_v); +	ao_lisp_printf("Frame:  %v\n", ao_lisp_frame_poly(ao_lisp_frame_current));  	printf("Stack:\n");  	ao_lisp_stack_write(ao_lisp_stack_poly(ao_lisp_stack)); -	printf("Globals:\n\t"); -	ao_lisp_frame_write(ao_lisp_frame_poly(ao_lisp_frame_global)); -	printf("\n"); +	ao_lisp_printf("Globals: %v\n", ao_lisp_frame_poly(ao_lisp_frame_global));  	return AO_LISP_NIL;  } | 
