gcore: split code to open core file into helper
(cherry picked from commit c192228b7398df72e472128605338555e5aa2db9)