Provide method to dump backtrace heap data.
For non-zygote spawned processes, we might want to dump the backtrace
data. Provide a method to send a signal to a process and then dump the
data to a file.
Adds a method to dump the backtrace data on exit.
Update documentation and explain format of heap dump data.
Test: Ran unit tests, enabled new options and used them.
Change-Id: Ie2fa706694160731afe02c1382b037d06df1d069
diff --git a/libc/malloc_debug/Config.h b/libc/malloc_debug/Config.h
index d8a7069..349ad77 100644
--- a/libc/malloc_debug/Config.h
+++ b/libc/malloc_debug/Config.h
@@ -65,9 +65,12 @@
uint64_t options() const { return options_; }
int backtrace_signal() const { return backtrace_signal_; }
+ int backtrace_dump_signal() const { return backtrace_dump_signal_; }
size_t backtrace_frames() const { return backtrace_frames_; }
size_t backtrace_enabled() const { return backtrace_enabled_; }
size_t backtrace_enable_on_signal() const { return backtrace_enable_on_signal_; }
+ bool backtrace_dump_on_exit() const { return backtrace_dump_on_exit_; }
+ const std::string& backtrace_dump_prefix() const { return backtrace_dump_prefix_; }
size_t front_guard_bytes() const { return front_guard_bytes_; }
size_t rear_guard_bytes() const { return rear_guard_bytes_; }
@@ -110,6 +113,8 @@
bool SetBacktrace(const std::string& option, const std::string& value);
bool SetBacktraceEnableOnSignal(const std::string& option, const std::string& value);
+ bool SetBacktraceDumpOnExit(const std::string& option, const std::string& value);
+ bool SetBacktraceDumpPrefix(const std::string& option, const std::string& value);
bool SetExpandAlloc(const std::string& option, const std::string& value);
@@ -130,8 +135,11 @@
bool backtrace_enable_on_signal_ = false;
int backtrace_signal_ = 0;
+ int backtrace_dump_signal_ = 0;
bool backtrace_enabled_ = false;
size_t backtrace_frames_ = 0;
+ bool backtrace_dump_on_exit_ = false;
+ std::string backtrace_dump_prefix_;
size_t fill_on_alloc_bytes_ = 0;
size_t fill_on_free_bytes_ = 0;