Refactor Config from a struct to a class.
This should make it easier to add new options, and to add options that
are complex. For example, I want to modify the behavior of
record_allocs_file so that it also enables record_allocs to a default
state.
Test: All unit tests pass.
Test: Enable the backtrace option and restart.
Change-Id: Idf5cdeed06ade3bc2c8ae39d228734bf65209b4f
diff --git a/libc/malloc_debug/RecordData.cpp b/libc/malloc_debug/RecordData.cpp
index c0f3486..5a68deb 100644
--- a/libc/malloc_debug/RecordData.cpp
+++ b/libc/malloc_debug/RecordData.cpp
@@ -185,20 +185,20 @@
dump_act.sa_sigaction = RecordDump;
dump_act.sa_flags = SA_RESTART | SA_SIGINFO | SA_ONSTACK;
sigemptyset(&dump_act.sa_mask);
- if (sigaction(config.record_allocs_signal, &dump_act, nullptr) != 0) {
+ if (sigaction(config.record_allocs_signal(), &dump_act, nullptr) != 0) {
error_log("Unable to set up record dump signal function: %s", strerror(errno));
return false;
}
pthread_setspecific(key_, nullptr);
info_log("%s: Run: 'kill -%d %d' to dump the allocation records.", getprogname(),
- config.record_allocs_signal, getpid());
+ config.record_allocs_signal(), getpid());
- num_entries_ = config.record_allocs_num_entries;
+ num_entries_ = config.record_allocs_num_entries();
entries_ = new const RecordEntry*[num_entries_];
cur_index_ = 0;
dump_ = false;
- dump_file_ = config.record_allocs_file;
+ dump_file_ = config.record_allocs_file();
return true;
}