Fix DDM recent allocations

A class may not have source file in which case ClassHelper::GetSourceFile
returns NULL. Adding the GetMethodSourceFile function helps us preventing
from dealing with null strings.

Bug: 14300208
Change-Id: I28707f883bacec4ee367ff703328d0f0240855f9
diff --git a/runtime/debugger.cc b/runtime/debugger.cc
index 9012f00..07d3a2a 100644
--- a/runtime/debugger.cc
+++ b/runtime/debugger.cc
@@ -4215,6 +4215,13 @@
   DISALLOW_COPY_AND_ASSIGN(StringTable);
 };
 
+static const char* GetMethodSourceFile(MethodHelper* mh)
+    SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
+  DCHECK(mh != nullptr);
+  const char* source_file = mh->GetDeclaringClassSourceFile();
+  return (source_file != nullptr) ? source_file : "";
+}
+
 /*
  * The data we send to DDMS contains everything we have recorded.
  *
@@ -4287,7 +4294,7 @@
           mh.ChangeMethod(m);
           class_names.Add(mh.GetDeclaringClassDescriptor());
           method_names.Add(mh.GetName());
-          filenames.Add(mh.GetDeclaringClassSourceFile());
+          filenames.Add(GetMethodSourceFile(&mh));
         }
       }
 
@@ -4349,7 +4356,7 @@
         mh.ChangeMethod(record->stack[stack_frame].method);
         size_t class_name_index = class_names.IndexOf(mh.GetDeclaringClassDescriptor());
         size_t method_name_index = method_names.IndexOf(mh.GetName());
-        size_t file_name_index = filenames.IndexOf(mh.GetDeclaringClassSourceFile());
+        size_t file_name_index = filenames.IndexOf(GetMethodSourceFile(&mh));
         JDWP::Append2BE(bytes, class_name_index);
         JDWP::Append2BE(bytes, method_name_index);
         JDWP::Append2BE(bytes, file_name_index);