+ add_inferior_silent (corelow_pid);
+
+ /* Do this before acknowledging the inferior, so if
+ post_create_inferior throws (can happen easilly if you're loading
+ a core file with the wrong exec), we aren't left with threads
+ from the previous inferior. */
+ init_thread_list ();
+
+ /* Set INFERIOR_PTID early, so an upper layer can rely on it being
+ set while in the target_find_new_threads call below. */
+ inferior_ptid = pid_to_ptid (corelow_pid);
+
+ /* Assume ST --- Add a main task. We'll later detect when we go
+ from ST to MT. */
+ add_thread_silent (inferior_ptid);
+
+ /* Need to flush the register cache (and the frame cache) from a
+ previous debug session. If inferior_ptid ends up the same as the
+ last debug session --- e.g., b foo; run; gcore core1; step; gcore
+ core2; core core1; core core2 --- then there's potential for
+ get_current_regcache to return the cached regcache of the
+ previous session, and the frame cache being stale. */
+ registers_changed ();
+
+ /* Build up thread list from BFD sections, and possibly set the
+ current thread to the .reg/NN section matching the .reg
+ section. */
+ bfd_map_over_sections (core_bfd, add_to_thread_list,
+ bfd_get_section_by_name (core_bfd, ".reg"));
+
+ post_create_inferior (&core_ops, from_tty);
+
+ /* Now go through the target stack looking for threads since there
+ may be a thread_stratum target loaded on top of target core by
+ now. The layer above should claim threads found in the BFD
+ sections. */
+ target_find_new_threads ();