diff options
| author | Josh Gao <jmgao@google.com> | 2020-06-02 15:54:32 -0700 |
|---|---|---|
| committer | Josh Gao <jmgao@google.com> | 2020-06-02 16:06:55 -0700 |
| commit | 55b91af828efb77dd5b2d5a87990f16011599159 (patch) | |
| tree | 1ae92409ac2a403cb3a44df52e36c59e7c37abfc /libfdtrack | |
| parent | 700f753c50971a573bfd84cf7d64483b94fcfe2c (diff) | |
fdtrack: increase backtrace depth.
Bug: http://b/155136951
Bug: http://b/157789860
Test: treehugger
Change-Id: I1e575fdef7d520f5a896130844eefb1a1ba46694
Diffstat (limited to 'libfdtrack')
| -rw-r--r-- | libfdtrack/fdtrack.cpp | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/libfdtrack/fdtrack.cpp b/libfdtrack/fdtrack.cpp index d37157799..898bc43db 100644 --- a/libfdtrack/fdtrack.cpp +++ b/libfdtrack/fdtrack.cpp @@ -57,7 +57,10 @@ static void fd_hook(android_fdtrack_event* event); // Backtraces for the first 4k file descriptors ought to be enough to diagnose an fd leak. static constexpr size_t kFdTableSize = 4096; -static constexpr size_t kStackDepth = 10; + +// 32 frames, plus two to skip from fdtrack itself. +static constexpr size_t kStackDepth = 34; +static constexpr size_t kStackFrameSkip = 2; static bool installed = false; static std::array<FdEntry, kFdTableSize> stack_traces [[clang::no_destroy]]; @@ -134,15 +137,14 @@ void fdtrack_iterate(fdtrack_callback_t callback, void* arg) { continue; } - constexpr size_t frame_skip = 2; - for (size_t i = frame_skip; i < entry->backtrace.size(); ++i) { - size_t j = i - frame_skip; + for (size_t i = kStackFrameSkip; i < entry->backtrace.size(); ++i) { + size_t j = i - kStackFrameSkip; function_names[j] = entry->backtrace[i].function_name.c_str(); function_offsets[j] = entry->backtrace[i].function_offset; } - bool should_continue = - callback(fd, function_names, function_offsets, entry->backtrace.size() - frame_skip, arg); + bool should_continue = callback(fd, function_names, function_offsets, + entry->backtrace.size() - kStackFrameSkip, arg); entry->mutex.unlock(); |
