Commit a60ad34c authored by Eddie Kohler's avatar Eddie Kohler

HZ, log_backtrace updates.

- Decrease HZ when sanitizers are enabled.
- Add a log_backtrace variant that takes rsp, rbp as arguments.
parent fff2e7e2
......@@ -196,11 +196,18 @@ bool lookup_symbol(uintptr_t addr, const char** name, uintptr_t* start) {
}
// log_backtrace(prefix)
// log_backtrace(prefix[, rsp, rbp])
// Print a backtrace to `log.txt`, each line prefixed by `prefix`.
void log_backtrace(const char* prefix) {
uintptr_t rsp = rdrsp(), rbp = rdrbp();
log_backtrace(prefix, rdrsp(), rdrbp());
}
void log_backtrace(const char* prefix, uintptr_t rsp, uintptr_t rbp) {
if (rsp != rbp && round_up(rsp, PAGESIZE) == round_down(rbp, PAGESIZE)) {
log_printf("%s warning: possible stack overflow (rsp %p, rbp %p)\n",
rsp, rbp);
}
uintptr_t stack_top = round_up(rsp, PAGESIZE);
int frame = 1;
while (rbp >= rsp && rbp < stack_top) {
......
......@@ -153,7 +153,17 @@ struct yieldstate {
// timekeeping
#define HZ 100 // number of ticks per second
// `HZ` defines the number of timer interrupts per second, or ticks.
// Real kernels typically use 100 or 1000; Chickadee typically uses 100.
// Exception: Sanitizers slow down the kernel so much that recursive timer
// interrupts can become a problem, so when sanitizers are on, we reduce the
// interrupt frequency to 10 per second.
#if HAVE_SANITIZERS
# define HZ 10
#else
# define HZ 100
#endif
extern volatile unsigned long ticks; // number of ticks since boot
......@@ -368,8 +378,10 @@ void log_vprintf(const char* format, va_list val) __attribute__((noinline));
// log_backtrace
// Print a backtrace to the host's `log.txt` file.
// Print a backtrace to the host's `log.txt` file, either for the current
// stack or for a given stack range.
void log_backtrace(const char* prefix = "");
void log_backtrace(const char* prefix, uintptr_t rsp, uintptr_t rbp);
#if HAVE_SANITIZERS
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment