Report full dex file size to libunwindstack (including shared data)

Include any shared data in the reported needed memory range.

Otherwise libunwindstack will refuse to load the dex file since it
appears truncated. Furthermore, it will keep retrying wasting CPU.

Bug: 314212435
Bug: 317075644
Test: atest HeapprofdCtsTest#DebuggableAppStartup
Change-Id: Ie488372ef6bf9101523d4e05b5a6f1364180ffce
diff --git a/runtime/jit/debugger_interface.cc b/runtime/jit/debugger_interface.cc
index 6d66de3..112746e 100644
--- a/runtime/jit/debugger_interface.cc
+++ b/runtime/jit/debugger_interface.cc
@@ -410,9 +410,13 @@
 void AddNativeDebugInfoForDex(Thread* self, const DexFile* dexfile) {
   MutexLock mu(self, g_dex_debug_lock);
   DCHECK(dexfile != nullptr);
-  // Compact dex files may store data past the size defined in the header.
-  const DexFile::Header& header = dexfile->GetHeader();
-  uint32_t size = std::max(header.file_size_, header.data_off_ + header.data_size_);
+  // Container dex files (v41) may store data past the size defined in the header.
+  uint32_t size = dexfile->SizeIncludingSharedData();
+  if (dexfile->IsCompactDexFile()) {
+    // Compact dex files may store data past the size defined in the header.
+    const DexFile::Header& header = dexfile->GetHeader();
+    size = std::max(size, header.data_off_ + header.data_size_);
+  }
   const ArrayRef<const uint8_t> symfile(dexfile->Begin(), size);
   CreateJITCodeEntryInternal<DexNativeInfo>(symfile);
 }