Added basic call history reporting

This commit is contained in:
Justin Ethier 2015-07-13 21:46:21 -04:00
parent a4c4ae94fc
commit 2d8c6ed5f3
3 changed files with 11 additions and 18 deletions

13
TODO
View file

@ -13,19 +13,6 @@ Working TODO list:
- self-hosting, there are a lot of accumulated TODO's that need to be addressed
- improved error handling:
(1) - code traces
could pass filename and define name (if applicable) to c-compile-exp,
and record it for each lambda. could then add code to each lambda to
write that info to a circular buffer when the function is called.
that would enable a primitive stack trace to be maintained at runtime.
ideally use an array of (char *) and a pointer incremented like (i = (i + 1) % size)
to treat it as a circular buffer
as a starting point, could encode lambda name and filename and get the
circular buffer and runtime reporting working. then come back and add
Scheme function names.
- type checking
ideally want to do this in a way that minimized performance impacts.
will probaby require extensive checks within apply() though, since that

View file

@ -80,9 +80,11 @@ void Cyc_st_init() {
}
void Cyc_st_add(char *frame) {
// TODO: do not add if (idx - 1) == frame, since that causes recursion to remove older frames
Cyc_Stack_Traces[Cyc_Stack_Trace_Idx] = frame;
Cyc_Stack_Trace_Idx = (Cyc_Stack_Trace_Idx + 1) % MAX_STACK_TRACES;
// Do not allow recursion to remove older frames
if (frame != Cyc_Stack_Traces[(Cyc_Stack_Trace_Idx - 1) % MAX_STACK_TRACES]) {
Cyc_Stack_Traces[Cyc_Stack_Trace_Idx] = frame;
Cyc_Stack_Trace_Idx = (Cyc_Stack_Trace_Idx + 1) % MAX_STACK_TRACES;
}
}
void Cyc_st_print(FILE *out) {

View file

@ -2,10 +2,14 @@
(scheme file)
(scheme write))
(map
(lambda (_)
(set! x 1)
(write x)
(write 'Cyc_procedure)
;(write x)
;(write 'Cyc_procedure)
(open-input-file "1.scm")
)
(list 1))
;;; TODO: C macros for funcall1, etc are not being generated even though entries are set
;;; in the vector. must be another problem inspecting the vector ???
;(write 'hello)