Refactor malloc debug.

Changes
- Refactor the code so that only guards require creating a special header
  for every pointer allocated.
- Store only a single copy of every backtrace. This saves memory so that
  turning on the backtrace option doesn't result in 10X memory usage.
- Added new option track_allocs that only verifies pointers are valid for
  free/malloc_usable_size/realloc.
- Remove suffix from test names.
- Add the TRACK_ALLOCS options to all guard options.
- Add new option verify_pointers that is a lightweight way to verify
  pointers that are passed to allocation routines.
- Do auto-formatting of the code.
- Updated documentation for all of these changes.

Bug: 74361929

Test: Ran unit tests.
Test: Ran libmemunreachable unit tests.
Test: Ran an app with backtrace enabled.

Change-Id: I3246c48ae4f9811f64622d90d0a9b4d9d818702c
(cherry picked from commit 4da2503d70dc4bc1444454876e3794b69227d90d)
diff --git a/libc/malloc_debug/DebugData.h b/libc/malloc_debug/DebugData.h
index 9aece0b..f7cf8ab 100644
--- a/libc/malloc_debug/DebugData.h
+++ b/libc/malloc_debug/DebugData.h
@@ -35,13 +35,11 @@
 
 #include <private/bionic_macros.h>
 
-#include "BacktraceData.h"
 #include "Config.h"
-#include "FreeTrackData.h"
 #include "GuardData.h"
-#include "malloc_debug.h"
+#include "PointerData.h"
 #include "RecordData.h"
-#include "TrackData.h"
+#include "malloc_debug.h"
 
 class DebugData {
  public:
@@ -62,11 +60,6 @@
     return reinterpret_cast<Header*>(value - pointer_offset_);
   }
 
-  BacktraceHeader* GetAllocBacktrace(const Header* header) {
-    uintptr_t value = reinterpret_cast<uintptr_t>(header);
-    return reinterpret_cast<BacktraceHeader*>(value + backtrace->alloc_offset());
-  }
-
   uint8_t* GetFrontGuard(const Header* header) {
     uintptr_t value = reinterpret_cast<uintptr_t>(header);
     return reinterpret_cast<uint8_t*>(value + front_guard->offset());
@@ -74,30 +67,30 @@
 
   uint8_t* GetRearGuard(const Header* header) {
     uintptr_t value = reinterpret_cast<uintptr_t>(GetPointer(header));
-    return reinterpret_cast<uint8_t*>(value + header->real_size());
+    return reinterpret_cast<uint8_t*>(value + header->size);
   }
 
   const Config& config() { return config_; }
   size_t pointer_offset() { return pointer_offset_; }
-  bool need_header() { return need_header_; }
   size_t extra_bytes() { return extra_bytes_; }
 
+  bool TrackPointers() { return config_.options() & TRACK_ALLOCS; }
+
+  bool HeaderEnabled() { return config_.options() & HEADER_OPTIONS; }
+
   void PrepareFork();
   void PostForkParent();
   void PostForkChild();
 
-  std::unique_ptr<BacktraceData> backtrace;
-  std::unique_ptr<TrackData> track;
   std::unique_ptr<FrontGuardData> front_guard;
+  std::unique_ptr<PointerData> pointer;
   std::unique_ptr<RearGuardData> rear_guard;
-  std::unique_ptr<FreeTrackData> free_track;
   std::unique_ptr<RecordData> record;
 
  private:
   size_t extra_bytes_ = 0;
 
   size_t pointer_offset_ = 0;
-  bool need_header_ = false;
 
   Config config_;