@@ -535,6 +535,11 @@ fn run_debuginfo_lldb_test(config: &Config, props: &TestProps, testfile: &Path)
535
535
breakpoint_lines
536
536
} = parse_debugger_commands ( testfile, "lldb" ) ;
537
537
538
+ let rust_src_root = match find_rust_src_root ( config) {
539
+ Some ( path) => path,
540
+ None => fatal ( "Could not find Rust source root directory" )
541
+ } ;
542
+
538
543
// Write debugger script:
539
544
// We don't want to hang when calling `quit` while the process is still running
540
545
let mut script_str = String :: from_str ( "settings set auto-confirm true\n " ) ;
@@ -543,7 +548,13 @@ fn run_debuginfo_lldb_test(config: &Config, props: &TestProps, testfile: &Path)
543
548
script_str. push_str ( "version\n " ) ;
544
549
545
550
// Switch LLDB into "Rust mode"
546
- script_str. push_str ( "command script import ./src/etc/lldb_rust_formatters.py\n " ) ;
551
+ let rust_formatters_postfix = Path :: new ( "./src/etc/lldb_rust_formatters.py" ) ;
552
+ let lldb_rust_formatters = rust_src_root. join ( rust_formatters_postfix) ;
553
+
554
+ script_str. push_str ( "command script import " ) ;
555
+ script_str. push_str ( lldb_rust_formatters. as_str ( )
556
+ . expect ( "Could not convert lldb_rust_formatters path to UTF-8" ) ) ;
557
+ script_str. push_str ( "\n " ) ;
547
558
script_str. push_str ( "type summary add --no-value " ) ;
548
559
script_str. push_str ( "--python-function lldb_rust_formatters.print_val " ) ;
549
560
script_str. push_str ( "-x \" .*\" --category Rust\n " ) ;
@@ -573,18 +584,28 @@ fn run_debuginfo_lldb_test(config: &Config, props: &TestProps, testfile: &Path)
573
584
let debugger_script = make_out_name ( config, testfile, "debugger.script" ) ;
574
585
575
586
// Let LLDB execute the script via lldb_batchmode.py
576
- let debugger_run_result = run_lldb ( config, & exe_file, & debugger_script) ;
587
+ let lldb_batchmode_path = rust_src_root
588
+ . join ( Path :: new ( "./src/etc/lldb_batchmode.py" ) ) ;
589
+
590
+ let debugger_run_result = run_lldb ( config,
591
+ & lldb_batchmode_path,
592
+ & exe_file,
593
+ & debugger_script) ;
577
594
578
595
if !debugger_run_result. status . success ( ) {
579
596
fatal_proc_rec ( "Error while running LLDB" , & debugger_run_result) ;
580
597
}
581
598
582
599
check_debugger_output ( & debugger_run_result, check_lines. as_slice ( ) ) ;
583
600
584
- fn run_lldb ( config : & Config , test_executable : & Path , debugger_script : & Path ) -> ProcRes {
601
+ fn run_lldb ( config : & Config ,
602
+ lldb_batchmode : & Path ,
603
+ test_executable : & Path ,
604
+ debugger_script : & Path )
605
+ -> ProcRes {
585
606
// Prepare the lldb_batchmode which executes the debugger script
586
607
let mut cmd = Command :: new ( "python" ) ;
587
- cmd. arg ( "./src/etc/ lldb_batchmode.py" )
608
+ cmd. arg ( lldb_batchmode)
588
609
. arg ( test_executable)
589
610
. arg ( debugger_script)
590
611
. env_set_all ( [ ( "PYTHONPATH" , config. lldb_python_dir . clone ( ) . unwrap ( ) . as_slice ( ) ) ] ) ;
@@ -612,6 +633,19 @@ fn run_debuginfo_lldb_test(config: &Config, props: &TestProps, testfile: &Path)
612
633
cmdline : format ! ( "{}" , cmd)
613
634
} ;
614
635
}
636
+
637
+ fn find_rust_src_root ( config : & Config ) -> Option < Path > {
638
+ let mut path = config. src_base . clone ( ) ;
639
+ let path_postfix = Path :: new ( "src/etc/lldb_batchmode.py" ) ;
640
+
641
+ while path. pop ( ) {
642
+ if path. join ( path_postfix. clone ( ) ) . is_file ( ) {
643
+ return Some ( path) ;
644
+ }
645
+ }
646
+
647
+ return None ;
648
+ }
615
649
}
616
650
617
651
struct DebuggerCommands {
0 commit comments