@@ -278,7 +278,10 @@ pub fn parse_config(args: Vec<String>) -> Config {
278
278
}
279
279
}
280
280
281
- let ( gdb, gdb_version, gdb_native_rust) = analyze_gdb ( matches. opt_str ( "gdb" ) ) ;
281
+ let target = opt_str2 ( matches. opt_str ( "target" ) ) ;
282
+ let android_cross_path = opt_path ( matches, "android-cross-path" ) ;
283
+ let ( gdb, gdb_version, gdb_native_rust) = analyze_gdb ( matches. opt_str ( "gdb" ) , & target,
284
+ & android_cross_path) ;
282
285
283
286
let color = match matches. opt_str ( "color" ) . as_ref ( ) . map ( |x| & * * x) {
284
287
Some ( "auto" ) | None => ColorConfig :: AutoColor ,
@@ -318,15 +321,15 @@ pub fn parse_config(args: Vec<String>) -> Config {
318
321
runtool : matches. opt_str ( "runtool" ) ,
319
322
host_rustcflags : matches. opt_str ( "host-rustcflags" ) ,
320
323
target_rustcflags : matches. opt_str ( "target-rustcflags" ) ,
321
- target : opt_str2 ( matches . opt_str ( " target" ) ) ,
324
+ target : target,
322
325
host : opt_str2 ( matches. opt_str ( "host" ) ) ,
323
326
gdb,
324
327
gdb_version,
325
328
gdb_native_rust,
326
329
lldb_version : extract_lldb_version ( matches. opt_str ( "lldb-version" ) ) ,
327
330
llvm_version : matches. opt_str ( "llvm-version" ) ,
328
331
system_llvm : matches. opt_present ( "system-llvm" ) ,
329
- android_cross_path : opt_path ( matches , "android-cross-path" ) ,
332
+ android_cross_path : android_cross_path ,
330
333
adb_path : opt_str2 ( matches. opt_str ( "adb-path" ) ) ,
331
334
adb_test_dir : opt_str2 ( matches. opt_str ( "adb-test-dir" ) ) ,
332
335
adb_device_status : opt_str2 ( matches. opt_str ( "target" ) ) . contains ( "android" )
@@ -780,23 +783,46 @@ fn make_test_closure(
780
783
} ) )
781
784
}
782
785
786
+ /// Returns true if the given target is an Android target for the
787
+ /// purposes of GDB testing.
788
+ fn is_android_gdb_target ( target : & String ) -> bool {
789
+ match & target[ ..] {
790
+ "arm-linux-androideabi" | "armv7-linux-androideabi" | "aarch64-linux-android" => true ,
791
+ _ => false ,
792
+ }
793
+ }
794
+
783
795
/// Returns (Path to GDB, GDB Version, GDB has Rust Support)
784
- fn analyze_gdb ( gdb : Option < String > ) -> ( Option < String > , Option < u32 > , bool ) {
796
+ fn analyze_gdb ( gdb : Option < String > , target : & String , android_cross_path : & PathBuf )
797
+ -> ( Option < String > , Option < u32 > , bool ) {
785
798
#[ cfg( not( windows) ) ]
786
799
const GDB_FALLBACK : & str = "gdb" ;
787
800
#[ cfg( windows) ]
788
801
const GDB_FALLBACK : & str = "gdb.exe" ;
789
802
790
803
const MIN_GDB_WITH_RUST : u32 = 7011010 ;
791
804
805
+ let fallback_gdb = || {
806
+ if is_android_gdb_target ( target) {
807
+ let mut gdb_path = match android_cross_path. to_str ( ) {
808
+ Some ( x) => x. to_owned ( ) ,
809
+ None => panic ! ( "cannot find android cross path" ) ,
810
+ } ;
811
+ gdb_path. push_str ( "/bin/gdb" ) ;
812
+ gdb_path
813
+ } else {
814
+ GDB_FALLBACK . to_owned ( )
815
+ }
816
+ } ;
817
+
792
818
let gdb = match gdb {
793
- None => GDB_FALLBACK ,
794
- Some ( ref s) if s. is_empty ( ) => GDB_FALLBACK , // may be empty if configure found no gdb
795
- Some ( ref s) => s,
819
+ None => fallback_gdb ( ) ,
820
+ Some ( ref s) if s. is_empty ( ) => fallback_gdb ( ) , // may be empty if configure found no gdb
821
+ Some ( ref s) => s. to_owned ( ) ,
796
822
} ;
797
823
798
824
let mut version_line = None ;
799
- if let Ok ( output) = Command :: new ( gdb) . arg ( "--version" ) . output ( ) {
825
+ if let Ok ( output) = Command :: new ( & gdb) . arg ( "--version" ) . output ( ) {
800
826
if let Some ( first_line) = String :: from_utf8_lossy ( & output. stdout ) . lines ( ) . next ( ) {
801
827
version_line = Some ( first_line. to_string ( ) ) ;
802
828
}
@@ -809,7 +835,7 @@ fn analyze_gdb(gdb: Option<String>) -> (Option<String>, Option<u32>, bool) {
809
835
810
836
let gdb_native_rust = version. map_or ( false , |v| v >= MIN_GDB_WITH_RUST ) ;
811
837
812
- ( Some ( gdb. to_owned ( ) ) , version, gdb_native_rust)
838
+ ( Some ( gdb) , version, gdb_native_rust)
813
839
}
814
840
815
841
fn extract_gdb_version ( full_version_line : & str ) -> Option < u32 > {
0 commit comments