[ VM / Observatory ] Fixed tests that were failing due to lack of sources in app_jitk mode

Change-Id: I74504cc5dea30a0b6841e0bf77d99c1cf3889269
Reviewed-on: https://dart-review.googlesource.com/c/84049
Commit-Queue: Ben Konyi <bkonyi@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
diff --git a/runtime/observatory/lib/src/service/object.dart b/runtime/observatory/lib/src/service/object.dart
index bbf5dbc..f296309 100644
--- a/runtime/observatory/lib/src/service/object.dart
+++ b/runtime/observatory/lib/src/service/object.dart
@@ -3717,7 +3717,7 @@
       UnresolvedSourceLocation loc = bpt.location;
       line = loc.line;
     }
-    getLine(line).addBreakpoint(bpt);
+    getLine(line)?.addBreakpoint(bpt);
   }
 
   void _removeBreakpoint(Breakpoint bpt) {
@@ -3729,7 +3729,7 @@
       line = loc.line;
     }
     if (line != null) {
-      getLine(line).removeBreakpoint(bpt);
+      getLine(line)?.removeBreakpoint(bpt);
     }
   }
 
diff --git a/runtime/observatory/tests/service/service_kernel.status b/runtime/observatory/tests/service/service_kernel.status
index 2de4997..303ba57 100644
--- a/runtime/observatory/tests/service/service_kernel.status
+++ b/runtime/observatory/tests/service/service_kernel.status
@@ -5,26 +5,13 @@
 [ $compiler == app_jitk ]
 add_breakpoint_rpc_test: RuntimeError
 async_generator_breakpoint_test: Skip # No incremental compiler available.
-async_next_regession_18877_test: RuntimeError
-async_next_test: RuntimeError
-async_scope_test: RuntimeError
 async_single_step_exception_test: RuntimeError
-async_single_step_into_test: RuntimeError
 async_single_step_out_test: RuntimeError
-async_star_single_step_into_test: RuntimeError
-async_star_step_out_test: RuntimeError
-async_step_out_test: RuntimeError
 bad_reload_test: RuntimeError
 break_on_activation_test: Skip # No incremental compiler available.
-break_on_function_test: RuntimeError
-breakpoint_in_parts_class_test: RuntimeError
-breakpoint_two_args_checked_test: RuntimeError
-code_test: RuntimeError # Issue 34143
 complex_reload_test: RuntimeError
 debugger_inspect_test: Skip # No incremental compiler available.
 debugger_location_second_test: RuntimeError
-debugging_inlined_finally_test: RuntimeError
-debugging_test: RuntimeError
 developer_service_get_isolate_id_test: Skip #  No incremental compiler available.
 eval_internal_class_test: Skip # No incremental compiler available.
 eval_regression_flutter20255_test: Skip # No incremental compiler available.
@@ -48,59 +35,15 @@
 get_vm_rpc_test: RuntimeError
 get_vm_timeline_rpc_test: RuntimeError
 instance_field_order_rpc_test: Skip # No incremental compiler available.
-issue_25465_test: RuntimeError
-issue_27238_test: RuntimeError
 local_variable_declaration_test: RuntimeError
-mixin_break_test: RuntimeError
-next_through_assign_call_test: RuntimeError
-next_through_assign_int_test: RuntimeError
-next_through_call_on_field_in_class_test: RuntimeError
-next_through_call_on_field_test: RuntimeError
-next_through_call_on_static_field_in_class_test: RuntimeError
-next_through_catch_test: RuntimeError
-next_through_closure_test: RuntimeError
-next_through_create_list_and_map_test: RuntimeError
-next_through_for_each_loop_test: RuntimeError
-next_through_for_loop_with_break_and_continue_test: RuntimeError
-next_through_function_expression_test: RuntimeError
-next_through_implicit_call_test: RuntimeError
-next_through_is_and_as_test: RuntimeError
-next_through_multi_catch_test: RuntimeError
-next_through_new_test: RuntimeError
-next_through_operator_bracket_on_super_test: RuntimeError
-next_through_operator_bracket_on_this_test: RuntimeError
-next_through_operator_bracket_test: RuntimeError
-next_through_simple_async_test: RuntimeError
-next_through_simple_async_with_returns_test: RuntimeError
-next_through_simple_linear_2_test: RuntimeError
-next_through_simple_linear_test: RuntimeError
 pause_on_exceptions_test: Skip # No incremental compiler available.
 positive_token_pos_test: RuntimeError
-regress_28443_test: RuntimeError
-regress_28980_test: RuntimeError
 rewind_optimized_out_test: RuntimeError
 rewind_test: RuntimeError
 set_name_rpc_test: RuntimeError
 set_vm_name_rpc_test: RuntimeError
 simple_reload_test: RuntimeError
-steal_breakpoint_test: RuntimeError
-step_into_async_no_await_test: RuntimeError
-step_over_await_test: RuntimeError
-step_test: RuntimeError # Issue 34143
 step_through_arithmetic_test: RuntimeError
-step_through_constructor_calls_test: RuntimeError
-step_through_constructor_test: RuntimeError
-step_through_for_each_sync_star_2_test: RuntimeError
-step_through_for_each_sync_star_test: RuntimeError
-step_through_function_2_test: RuntimeError
-step_through_function_test: RuntimeError
-step_through_getter_test: RuntimeError
-step_through_mixin_from_sdk_test: RuntimeError
-step_through_property_get_test: RuntimeError
-step_through_property_set_test: RuntimeError
-step_through_setter_test: RuntimeError
-step_through_switch_test: RuntimeError
-step_through_switch_with_continue_test: RuntimeError
 unused_changes_in_last_reload_test: RuntimeError
 valid_source_locations_test: RuntimeError
 
@@ -155,10 +98,6 @@
 get_object_rpc_test: RuntimeError
 get_stack_rpc_test: RuntimeError
 
-[ $compiler == app_jitk && $mode == debug ]
-code_test: RuntimeError
-step_test: RuntimeError
-
 [ $compiler == dartk && $mode == debug ]
 isolate_lifecycle_test: Skip # Flaky.
 pause_idle_isolate_test: Skip # Flaky
diff --git a/runtime/vm/object.cc b/runtime/vm/object.cc
index 62b381f..a82b1f4 100644
--- a/runtime/vm/object.cc
+++ b/runtime/vm/object.cc
@@ -9814,17 +9814,26 @@
 
   if (kind() == RawScript::kKernelTag) {
     const TypedData& line_starts_data = TypedData::Handle(line_starts());
-    const String& source = String::Handle(Source());
-    if (line_starts_data.IsNull() || source.IsNull()) {
+    if (line_starts_data.IsNull()) {
       // Scripts in the AOT snapshot do not have a line starts array.
       *first_token_index = TokenPosition::kNoSource;
       *last_token_index = TokenPosition::kNoSource;
       return;
     }
 #if !defined(DART_PRECOMPILED_RUNTIME)
+    const String& source = String::Handle(Source());
+    intptr_t source_length;
+    if (source.IsNull()) {
+      Smi& value = Smi::Handle();
+      const Array& debug_positions_array = Array::Handle(debug_positions());
+      value ^= debug_positions_array.At(debug_positions_array.Length() - 1);
+      source_length = value.Value();
+    } else {
+      source_length = source.Length();
+    }
     kernel::KernelLineStartsReader line_starts_reader(
         line_starts_data, Thread::Current()->zone());
-    line_starts_reader.TokenRangeAtLine(source.Length(), line_number,
+    line_starts_reader.TokenRangeAtLine(source_length, line_number,
                                         first_token_index, last_token_index);
 #endif  // !defined(DART_PRECOMPILED_RUNTIME)
     return;