@@ -16,14 +16,13 @@ use nix::sys::signal::{kill, Signal};
1616use stacktrace_parser:: CrashLog ;
1717#[ cfg( any( target_os = "linux" , target_family = "windows" ) ) ]
1818use stacktrace_parser:: StackEntry ;
19+ use std:: ffi:: OsStr ;
1920#[ cfg( target_os = "linux" ) ]
2021use std:: process:: Stdio ;
2122use std:: { collections:: HashMap , path:: Path , time:: Duration } ;
2223use tempfile:: tempdir;
2324
2425const DEFAULT_TIMEOUT : Duration = Duration :: from_secs ( 5 ) ;
25- #[ cfg( any( target_os = "linux" , target_family = "windows" ) ) ]
26- const CRASH_SITE_UNAVAILABLE : & str = "<crash site unavailable>" ;
2726
2827pub struct Tester < ' a > {
2928 setup_dir : & ' a Path ,
@@ -140,14 +139,14 @@ impl<'a> Tester<'a> {
140139 #[ cfg( target_family = "windows" ) ]
141140 async fn test_input_debugger (
142141 & self ,
143- argv : Vec < String > ,
144- env : HashMap < String , String > ,
142+ argv : & [ impl AsRef < OsStr > ] ,
143+ env : & HashMap < String , String > ,
145144 ) -> Result < Option < CrashLog > > {
146145 const IGNORE_FIRST_CHANCE_EXCEPTIONS : bool = true ;
147146 let report = input_tester:: crash_detector:: test_process (
148147 self . exe_path ,
149- & argv,
150- & env,
148+ argv,
149+ env,
151150 self . timeout ,
152151 IGNORE_FIRST_CHANCE_EXCEPTIONS ,
153152 ) ?;
@@ -182,18 +181,11 @@ impl<'a> Tester<'a> {
182181 } )
183182 . collect ( ) ;
184183
185- let crash_site = if let Some ( frame) = call_stack. get ( 0 ) {
186- frame. line . to_owned ( )
187- } else {
188- CRASH_SITE_UNAVAILABLE . to_owned ( )
189- } ;
190-
191184 let fault_type = exception. description . to_string ( ) ;
192185 let sanitizer = fault_type. to_string ( ) ;
193- let summary = crash_site;
194186
195187 Some ( CrashLog :: new (
196- None , summary , sanitizer, fault_type, None , None , call_stack,
188+ None , None , sanitizer, fault_type, None , None , call_stack,
197189 ) ?)
198190 } else {
199191 None
@@ -205,12 +197,12 @@ impl<'a> Tester<'a> {
205197 #[ cfg( target_os = "linux" ) ]
206198 async fn test_input_debugger (
207199 & self ,
208- args : Vec < String > ,
209- env : HashMap < String , String > ,
200+ args : & [ impl AsRef < OsStr > ] ,
201+ env : & HashMap < String , String > ,
210202 ) -> Result < Option < CrashLog > > {
211203 let mut cmd = std:: process:: Command :: new ( self . exe_path ) ;
212204 cmd. args ( args) . stdin ( Stdio :: null ( ) ) ;
213- cmd. envs ( & env) ;
205+ cmd. envs ( env) ;
214206
215207 let ( sender, receiver) = std:: sync:: mpsc:: channel ( ) ;
216208
@@ -265,19 +257,11 @@ impl<'a> Tester<'a> {
265257 . collect ( ) ;
266258
267259 let crash_type = crash. signal . to_string ( ) ;
268-
269- let crash_site = if let Some ( frame) = crash_thread. callstack . get ( 0 ) {
270- frame. to_string ( )
271- } else {
272- CRASH_SITE_UNAVAILABLE . to_owned ( )
273- } ;
274-
275- let summary = crash_site;
276260 let sanitizer = crash_type. clone ( ) ;
277261 let fault_type = crash_type;
278262
279263 Some ( CrashLog :: new (
280- None , summary , sanitizer, fault_type, None , None , call_stack,
264+ None , None , sanitizer, fault_type, None , None , call_stack,
281265 ) ?)
282266 } else {
283267 None
@@ -301,9 +285,7 @@ impl<'a> Tester<'a> {
301285 . target_exe ( self . exe_path )
302286 . target_options ( self . arguments )
303287 . setup_dir ( self . setup_dir )
304- . set_optional ( self . extra_dir . as_ref ( ) , |expand, extra_dir| {
305- expand. extra_dir ( extra_dir)
306- } ) ;
288+ . set_optional ( self . extra_dir , Expand :: extra_dir) ;
307289
308290 let argv = expand. evaluate ( self . arguments ) ?;
309291 let mut env: HashMap < String , String > = HashMap :: new ( ) ;
@@ -317,6 +299,7 @@ impl<'a> Tester<'a> {
317299 Some ( v) => update_path ( v. clone ( ) . into ( ) , setup_dir) ?,
318300 None => get_path_with_directory ( PATH , setup_dir) ?,
319301 } ;
302+
320303 env. insert ( PATH . to_string ( ) , new_path. to_string_lossy ( ) . to_string ( ) ) ;
321304 }
322305 if self . add_setup_to_ld_library_path {
@@ -343,7 +326,7 @@ impl<'a> Tester<'a> {
343326 let attempts = 1 + self . check_retry_count ;
344327 for _ in 0 ..attempts {
345328 let result = if self . check_debugger {
346- match self . test_input_debugger ( argv. clone ( ) , env. clone ( ) ) . await {
329+ match self . test_input_debugger ( & argv, & env) . await {
347330 Ok ( crash) => ( crash, None , None ) ,
348331 Err ( error) => ( None , Some ( error) , None ) ,
349332 }
0 commit comments