@@ -165,8 +165,12 @@ pub fn parse_config(args: Vec<String>) -> Config {
165165 let cdb = analyze_cdb ( matches. opt_str ( "cdb" ) , & target) ;
166166 let ( gdb, gdb_version, gdb_native_rust) =
167167 analyze_gdb ( matches. opt_str ( "gdb" ) , & target, & android_cross_path) ;
168- let ( lldb_version, lldb_native_rust) = extract_lldb_version ( matches. opt_str ( "lldb-version" ) ) ;
169-
168+ let ( lldb_version, lldb_native_rust) = matches
169+ . opt_str ( "lldb-version" )
170+ . as_deref ( )
171+ . and_then ( extract_lldb_version)
172+ . map ( |( v, b) | ( Some ( v) , b) )
173+ . unwrap_or ( ( None , false ) ) ;
170174 let color = match matches. opt_str ( "color" ) . as_ref ( ) . map ( |x| & * * x) {
171175 Some ( "auto" ) | None => ColorConfig :: AutoColor ,
172176 Some ( "always" ) => ColorConfig :: AlwaysColor ,
@@ -400,17 +404,14 @@ fn configure_lldb(config: &Config) -> Option<Config> {
400404 return None ;
401405 }
402406
403- if let Some ( lldb_version) = config. lldb_version . as_ref ( ) {
404- if lldb_version == "350" {
405- println ! (
406- "WARNING: The used version of LLDB ({}) has a \
407- known issue that breaks debuginfo tests. See \
408- issue #32520 for more information. Skipping all \
409- LLDB-based tests!",
410- lldb_version
411- ) ;
412- return None ;
413- }
407+ if let Some ( 350 ) = config. lldb_version {
408+ println ! (
409+ "WARNING: The used version of LLDB (350) has a \
410+ known issue that breaks debuginfo tests. See \
411+ issue #32520 for more information. Skipping all \
412+ LLDB-based tests!",
413+ ) ;
414+ return None ;
414415 }
415416
416417 // Some older versions of LLDB seem to have problems with multiple
@@ -908,7 +909,7 @@ fn extract_gdb_version(full_version_line: &str) -> Option<u32> {
908909}
909910
910911/// Returns (LLDB version, LLDB is rust-enabled)
911- fn extract_lldb_version ( full_version_line : Option < String > ) -> ( Option < String > , bool ) {
912+ fn extract_lldb_version ( full_version_line : & str ) -> Option < ( u32 , bool ) > {
912913 // Extract the major LLDB version from the given version string.
913914 // LLDB version strings are different for Apple and non-Apple platforms.
914915 // The Apple variant looks like this:
@@ -917,7 +918,7 @@ fn extract_lldb_version(full_version_line: Option<String>) -> (Option<String>, b
917918 // lldb-300.2.51 (new versions)
918919 //
919920 // We are only interested in the major version number, so this function
920- // will return `Some(" 179" )` and `Some(" 300" )` respectively.
921+ // will return `Some(179)` and `Some(300)` respectively.
921922 //
922923 // Upstream versions look like:
923924 // lldb version 6.0.1
@@ -929,53 +930,20 @@ fn extract_lldb_version(full_version_line: Option<String>) -> (Option<String>, b
929930 // normally fine because the only non-Apple version we test is
930931 // rust-enabled.
931932
932- if let Some ( ref full_version_line) = full_version_line {
933- if !full_version_line. trim ( ) . is_empty ( ) {
934- let full_version_line = full_version_line. trim ( ) ;
935-
936- for ( pos, l) in full_version_line. char_indices ( ) {
937- if l != 'l' && l != 'L' {
938- continue ;
939- }
940- if pos + 5 >= full_version_line. len ( ) {
941- continue ;
942- }
943- let l = full_version_line[ pos + 1 ..] . chars ( ) . next ( ) . unwrap ( ) ;
944- if l != 'l' && l != 'L' {
945- continue ;
946- }
947- let d = full_version_line[ pos + 2 ..] . chars ( ) . next ( ) . unwrap ( ) ;
948- if d != 'd' && d != 'D' {
949- continue ;
950- }
951- let b = full_version_line[ pos + 3 ..] . chars ( ) . next ( ) . unwrap ( ) ;
952- if b != 'b' && b != 'B' {
953- continue ;
954- }
955- let dash = full_version_line[ pos + 4 ..] . chars ( ) . next ( ) . unwrap ( ) ;
956- if dash != '-' {
957- continue ;
958- }
959-
960- let vers = full_version_line[ pos + 5 ..]
961- . chars ( )
962- . take_while ( |c| c. is_digit ( 10 ) )
963- . collect :: < String > ( ) ;
964- if !vers. is_empty ( ) {
965- return ( Some ( vers) , full_version_line. contains ( "rust-enabled" ) ) ;
966- }
967- }
933+ let full_version_line = full_version_line. trim ( ) ;
968934
969- if full_version_line. starts_with ( "lldb version " ) {
970- let vers = full_version_line[ 13 ..]
971- . chars ( )
972- . take_while ( |c| c. is_digit ( 10 ) )
973- . collect :: < String > ( ) ;
974- if !vers. is_empty ( ) {
975- return ( Some ( vers + "00" ) , full_version_line. contains ( "rust-enabled" ) ) ;
976- }
977- }
935+ if let Some ( apple_ver) =
936+ full_version_line. strip_prefix ( "LLDB-" ) . or_else ( || full_version_line. strip_prefix ( "lldb-" ) )
937+ {
938+ if let Some ( idx) = apple_ver. find ( |c : char | !c. is_digit ( 10 ) ) {
939+ let version: u32 = apple_ver[ ..idx] . parse ( ) . unwrap ( ) ;
940+ return Some ( ( version, full_version_line. contains ( "rust-enabled" ) ) ) ;
941+ }
942+ } else if let Some ( lldb_ver) = full_version_line. strip_prefix ( "lldb version " ) {
943+ if let Some ( idx) = lldb_ver. find ( |c : char | !c. is_digit ( 10 ) ) {
944+ let version: u32 = lldb_ver[ ..idx] . parse ( ) . unwrap ( ) ;
945+ return Some ( ( version * 100 , full_version_line. contains ( "rust-enabled" ) ) ) ;
978946 }
979947 }
980- ( None , false )
948+ None
981949}
0 commit comments