[vm,aot] Fix printing of exit frames in AOT/debug mode

This change fixes

  ../../runtime/vm/stack_frame.cc: 358: error: expected: code != Code::null()
  Aborting reentrant request for stack trace.

when printing crash stack traces in debug/AOT mode if assertion
failure happens inside a native method or runtime.

TEST=manually verified that stack trace is printed during assertion
     failure in AOT debug mode.

Change-Id: I12b36749feeda42e9700eedafc41cb6fa98c1e67
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/375382
Commit-Queue: Alexander Aprelev <aam@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
Auto-Submit: Alexander Markov <alexmarkov@google.com>
diff --git a/runtime/vm/stack_frame.cc b/runtime/vm/stack_frame.cc
index ae3b194..015fc91 100644
--- a/runtime/vm/stack_frame.cc
+++ b/runtime/vm/stack_frame.cc
@@ -352,6 +352,9 @@
 CodePtr StackFrame::GetCodeObject() const {
 #if defined(DART_PRECOMPILED_RUNTIME)
   if (FLAG_precompiled_mode) {
+    if (pc() == 0) {
+      return Code::null();
+    }
     NoSafepointScope no_safepoint;
     CodePtr code = ReversePc::Lookup(isolate_group(), pc(),
                                      /*is_return_address=*/true);