aboutsummaryrefslogtreecommitdiff
path: root/eval.h
diff options
context:
space:
mode:
authorDan Willemsen <dwillemsen@google.com>2017-10-09 11:23:32 -0700
committerDan Willemsen <dwillemsen@google.com>2017-10-13 13:21:27 -0700
commit36e5729db554afaea6fe9b23f3caa87b6c8cc80d (patch)
tree482b20ea2fcb0a6d5d112af75623eb690c12f9cb /eval.h
parentf2a0a72d1fd1ee7b6f37754eef8886dcaafa22d0 (diff)
downloadkati-36e5729db554afaea6fe9b23f3caa87b6c8cc80d.tar.gz
Keep track of stack usage, report line that used the most
This won't keep track of everything, but was useful in tracking down some recursive variables in the android build that shouldn't have been recursive (they were using 1MB+ of stack). Change-Id: I5e6b70480cffbebb09dfd72276017559480da948
Diffstat (limited to 'eval.h')
-rw-r--r--eval.h14
1 files changed, 14 insertions, 0 deletions
diff --git a/eval.h b/eval.h
index 97a2c23..2b62892 100644
--- a/eval.h
+++ b/eval.h
@@ -86,6 +86,15 @@ class Evaluator {
string GetShellFlag();
string GetShellAndFlag();
+ void CheckStack() {
+ void* addr = __builtin_frame_address(0);
+ if (__builtin_expect(addr < lowest_stack_ && addr >= stack_addr_, 0)) {
+ lowest_stack_ = addr;
+ lowest_loc_ = loc_;
+ }
+ }
+ void DumpStackStats() const;
+
private:
Var* EvalRHS(Symbol lhs,
Value* rhs,
@@ -119,6 +128,11 @@ class Evaluator {
Symbol posix_sym_;
bool is_posix_;
+ void* stack_addr_;
+ size_t stack_size_;
+ void* lowest_stack_;
+ Loc lowest_loc_;
+
static unordered_set<Symbol> used_undefined_vars_;
Symbol kati_readonly_;