mirror of
https://github.com/justinethier/cyclone.git
synced 2025-07-13 15:57:36 +02:00
Added stack trace functions
This commit is contained in:
parent
8dce2178d1
commit
af1cf74b3b
2 changed files with 24 additions and 5 deletions
25
runtime.c
25
runtime.c
|
@ -71,12 +71,20 @@ static symbol_type Cyc_void_symbol = {symbol_tag, "", nil};
|
||||||
const object quote_void = &Cyc_void_symbol;
|
const object quote_void = &Cyc_void_symbol;
|
||||||
|
|
||||||
/* Stack Traces */
|
/* Stack Traces */
|
||||||
const int MAX_STACK_TRACES = 10;
|
static const int MAX_STACK_TRACES = 10;
|
||||||
char **Cyc_Stack_Traces;
|
static char **Cyc_Stack_Traces;
|
||||||
int Cyc_Stack_Trace_Idx = 0;
|
static int Cyc_Stack_Trace_Idx = 0;
|
||||||
|
|
||||||
|
void Cyc_st_init() {
|
||||||
|
Cyc_Stack_Traces = calloc(MAX_STACK_TRACES, sizeof(char *));
|
||||||
|
}
|
||||||
|
|
||||||
|
void Cyc_st_add(char *frame) {
|
||||||
|
/* add to circ buf */
|
||||||
|
Cyc_Stack_Traces[Cyc_Stack_Trace_Idx] = frame;
|
||||||
|
Cyc_Stack_Trace_Idx = (Cyc_Stack_Trace_Idx + 1) % MAX_STACK_TRACES;
|
||||||
|
}
|
||||||
|
|
||||||
void Cyc_st_init() { /* calloc tbl */ }
|
|
||||||
void Cyc_st_add(char *frame) { /* add to circ buf */ }
|
|
||||||
void Cyc_st_print(FILE *out) {
|
void Cyc_st_print(FILE *out) {
|
||||||
/* print to stream, note it is possible that
|
/* print to stream, note it is possible that
|
||||||
some traces could be on the stack after a GC.
|
some traces could be on the stack after a GC.
|
||||||
|
@ -85,6 +93,13 @@ void Cyc_st_print(FILE *out) {
|
||||||
or, with the tbl being so small, maybe it will
|
or, with the tbl being so small, maybe it will
|
||||||
not be an issue in practice? a bit risky to ignore though
|
not be an issue in practice? a bit risky to ignore though
|
||||||
*/
|
*/
|
||||||
|
int i = (Cyc_Stack_Trace_Idx + 1) % MAX_STACK_TRACES;
|
||||||
|
while (i != Cyc_Stack_Trace_Idx) {
|
||||||
|
if (Cyc_Stack_Traces[i]) {
|
||||||
|
fprintf(out, "%s\n", Cyc_Stack_Traces[i]);
|
||||||
|
}
|
||||||
|
i = (i + 1) % MAX_STACK_TRACES;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
/* END Stack Traces section */
|
/* END Stack Traces section */
|
||||||
|
|
||||||
|
|
|
@ -156,6 +156,10 @@ object memqp(object,list);
|
||||||
char *transport(char *,int);
|
char *transport(char *,int);
|
||||||
void GC(closure,object*,int) never_returns;
|
void GC(closure,object*,int) never_returns;
|
||||||
|
|
||||||
|
void Cyc_st_init();
|
||||||
|
void Cyc_st_add(char *frame);
|
||||||
|
void Cyc_st_print(FILE *out);
|
||||||
|
|
||||||
char *_strdup (const char *s);
|
char *_strdup (const char *s);
|
||||||
object add_symbol(symbol_type *psym);
|
object add_symbol(symbol_type *psym);
|
||||||
object add_symbol_by_name(const char *name);
|
object add_symbol_by_name(const char *name);
|
||||||
|
|
Loading…
Add table
Reference in a new issue