@@ -20,6 +20,46 @@ pub struct SavedArtifacts {
2020 pub key_to_path : HashMap < String , PathBuf > ,
2121}
2222
23+ /// Save all artifacts (symbols, debug info, unwind data) from mounted modules and JIT data.
24+ pub fn save_artifacts (
25+ profile_folder : & Path ,
26+ mounted_modules_by_path : & HashMap < PathBuf , MountedModule > ,
27+ jit_unwind_data_by_pid : & HashMap < pid_t , Vec < ( UnwindData , ProcessUnwindData ) > > ,
28+ ) -> SavedArtifacts {
29+ let mut path_to_key = HashMap :: < PathBuf , String > :: new ( ) ;
30+
31+ register_paths ( & mut path_to_key, mounted_modules_by_path) ;
32+
33+ let symbol_pid_mappings_by_pid =
34+ save_symbols ( profile_folder, mounted_modules_by_path, & path_to_key) ;
35+
36+ let ( debug_info, debug_info_pid_mappings_by_pid) =
37+ save_debug_info ( mounted_modules_by_path, & mut path_to_key) ;
38+
39+ let unwind_data_pid_mappings_by_pid = save_unwind_data (
40+ profile_folder,
41+ mounted_modules_by_path,
42+ jit_unwind_data_by_pid,
43+ & mut path_to_key,
44+ ) ;
45+
46+ let ignored_modules = collect_ignored_modules ( mounted_modules_by_path) ;
47+
48+ let key_to_path = path_to_key
49+ . into_iter ( )
50+ . map ( |( path, key) | ( key, path) )
51+ . collect ( ) ;
52+
53+ SavedArtifacts {
54+ symbol_pid_mappings_by_pid,
55+ debug_info,
56+ debug_info_pid_mappings_by_pid,
57+ unwind_data_pid_mappings_by_pid,
58+ ignored_modules,
59+ key_to_path,
60+ }
61+ }
62+
2363/// Register a path in the map if absent, assigning a new unique key.
2464/// Returns the assigned key.
2565fn get_or_insert_key ( path_to_key : & mut HashMap < PathBuf , String > , path : & Path ) -> String {
@@ -238,43 +278,3 @@ fn collect_ignored_modules(
238278
239279 to_ignore
240280}
241-
242- /// Save all artifacts (symbols, debug info, unwind data) from mounted modules and JIT data.
243- pub fn save_artifacts (
244- profile_folder : & Path ,
245- mounted_modules_by_path : & HashMap < PathBuf , MountedModule > ,
246- jit_unwind_data_by_pid : & HashMap < pid_t , Vec < ( UnwindData , ProcessUnwindData ) > > ,
247- ) -> SavedArtifacts {
248- let mut path_to_key = HashMap :: < PathBuf , String > :: new ( ) ;
249-
250- register_paths ( & mut path_to_key, mounted_modules_by_path) ;
251-
252- let symbol_pid_mappings_by_pid =
253- save_symbols ( profile_folder, mounted_modules_by_path, & path_to_key) ;
254-
255- let ( debug_info, debug_info_pid_mappings_by_pid) =
256- save_debug_info ( mounted_modules_by_path, & mut path_to_key) ;
257-
258- let unwind_data_pid_mappings_by_pid = save_unwind_data (
259- profile_folder,
260- mounted_modules_by_path,
261- jit_unwind_data_by_pid,
262- & mut path_to_key,
263- ) ;
264-
265- let ignored_modules = collect_ignored_modules ( mounted_modules_by_path) ;
266-
267- let key_to_path = path_to_key
268- . into_iter ( )
269- . map ( |( path, key) | ( key, path) )
270- . collect ( ) ;
271-
272- SavedArtifacts {
273- symbol_pid_mappings_by_pid,
274- debug_info,
275- debug_info_pid_mappings_by_pid,
276- unwind_data_pid_mappings_by_pid,
277- ignored_modules,
278- key_to_path,
279- }
280- }
0 commit comments