@@ -350,51 +350,48 @@ pub struct DebugOptions {
350350
351351
352352impl DebugOptions {
353- pub fn new ( debug_string : & str ) -> Result < DebugOptions , & str > {
354- let mut debug_options = DebugOptions :: default ( ) ;
355-
353+ pub fn extend ( & mut self , debug_string : String ) -> Result < ( ) , String > {
356354 for option in debug_string. split ( ',' ) {
357355 match option {
358- "help" => debug_options . help = true ,
359- "bubble-widths" => debug_options . bubble_widths = true ,
360- "disable-text-aa" => debug_options . disable_text_aa = true ,
361- "enable-subpixel-aa" => debug_options . enable_subpixel_aa = true ,
362- "disable-canvas-aa" => debug_options . disable_text_aa = true ,
363- "dump-style-tree" => debug_options . dump_style_tree = true ,
364- "dump-rule-tree" => debug_options . dump_rule_tree = true ,
365- "dump-flow-tree" => debug_options . dump_flow_tree = true ,
366- "dump-display-list" => debug_options . dump_display_list = true ,
367- "dump-display-list-json" => debug_options . dump_display_list_json = true ,
368- "dump-layer-tree" => debug_options . dump_layer_tree = true ,
369- "relayout-event" => debug_options . relayout_event = true ,
370- "profile-script-events" => debug_options . profile_script_events = true ,
371- "profile-heartbeats" => debug_options . profile_heartbeats = true ,
372- "show-compositor-borders" => debug_options . show_compositor_borders = true ,
373- "show-fragment-borders" => debug_options . show_fragment_borders = true ,
374- "show-parallel-paint" => debug_options . show_parallel_paint = true ,
375- "show-parallel-layout" => debug_options . show_parallel_layout = true ,
376- "paint-flashing" => debug_options . paint_flashing = true ,
377- "trace-layout" => debug_options . trace_layout = true ,
378- "disable-share-style-cache" => debug_options . disable_share_style_cache = true ,
379- "style-sharing-stats" => debug_options . style_sharing_stats = true ,
380- "convert-mouse-to-touch" => debug_options . convert_mouse_to_touch = true ,
381- "replace-surrogates" => debug_options . replace_surrogates = true ,
382- "gc-profile" => debug_options . gc_profile = true ,
383- "load-webfonts-synchronously" => debug_options . load_webfonts_synchronously = true ,
384- "disable-vsync" => debug_options . disable_vsync = true ,
385- "wr-stats" => debug_options . webrender_stats = true ,
386- "wr-debug" => debug_options . webrender_debug = true ,
387- "wr-record" => debug_options . webrender_record = true ,
388- "msaa" => debug_options . use_msaa = true ,
389- "full-backtraces" => debug_options . full_backtraces = true ,
390- "precache-shaders" => debug_options . precache_shaders = true ,
391- "signpost" => debug_options . signpost = true ,
356+ "help" => self . help = true ,
357+ "bubble-widths" => self . bubble_widths = true ,
358+ "disable-text-aa" => self . disable_text_aa = true ,
359+ "enable-subpixel-aa" => self . enable_subpixel_aa = true ,
360+ "disable-canvas-aa" => self . disable_text_aa = true ,
361+ "dump-style-tree" => self . dump_style_tree = true ,
362+ "dump-rule-tree" => self . dump_rule_tree = true ,
363+ "dump-flow-tree" => self . dump_flow_tree = true ,
364+ "dump-display-list" => self . dump_display_list = true ,
365+ "dump-display-list-json" => self . dump_display_list_json = true ,
366+ "dump-layer-tree" => self . dump_layer_tree = true ,
367+ "relayout-event" => self . relayout_event = true ,
368+ "profile-script-events" => self . profile_script_events = true ,
369+ "profile-heartbeats" => self . profile_heartbeats = true ,
370+ "show-compositor-borders" => self . show_compositor_borders = true ,
371+ "show-fragment-borders" => self . show_fragment_borders = true ,
372+ "show-parallel-paint" => self . show_parallel_paint = true ,
373+ "show-parallel-layout" => self . show_parallel_layout = true ,
374+ "paint-flashing" => self . paint_flashing = true ,
375+ "trace-layout" => self . trace_layout = true ,
376+ "disable-share-style-cache" => self . disable_share_style_cache = true ,
377+ "style-sharing-stats" => self . style_sharing_stats = true ,
378+ "convert-mouse-to-touch" => self . convert_mouse_to_touch = true ,
379+ "replace-surrogates" => self . replace_surrogates = true ,
380+ "gc-profile" => self . gc_profile = true ,
381+ "load-webfonts-synchronously" => self . load_webfonts_synchronously = true ,
382+ "disable-vsync" => self . disable_vsync = true ,
383+ "wr-stats" => self . webrender_stats = true ,
384+ "wr-debug" => self . webrender_debug = true ,
385+ "wr-record" => self . webrender_record = true ,
386+ "msaa" => self . use_msaa = true ,
387+ "full-backtraces" => self . full_backtraces = true ,
388+ "precache-shaders" => self . precache_shaders = true ,
389+ "signpost" => self . signpost = true ,
392390 "" => { } ,
393- _ => return Err ( option)
391+ _ => return Err ( String :: from ( option) ) ,
394392 } ;
395393 } ;
396-
397- Ok ( debug_options)
394+ Ok ( ( ) )
398395 }
399396}
400397
@@ -614,8 +611,8 @@ pub fn from_cmdline_args(args: &[String]) -> ArgumentParsingResult {
614611 "Probability of randomly closing a pipeline (for testing constellation hardening)." ,
615612 "0.0" ) ;
616613 opts. optopt ( "" , "random-pipeline-closure-seed" , "A fixed seed for repeatbility of random pipeline closure." , "" ) ;
617- opts. optopt ( "Z" , "debug" ,
618- "A comma-separated string of debug options. Pass help to show available options." , "" ) ;
614+ opts. optmulti ( "Z" , "debug" ,
615+ "A comma-separated string of debug options. Pass help to show available options." , "" ) ;
619616 opts. optflag ( "h" , "help" , "Print this message" ) ;
620617 opts. optopt ( "" , "resources-path" , "Path to find static resources" , "/home/servo/resources" ) ;
621618 opts. optopt ( "" , "content-process" , "Run as a content process and connect to the given pipe" ,
@@ -648,15 +645,13 @@ pub fn from_cmdline_args(args: &[String]) -> ArgumentParsingResult {
648645 return ArgumentParsingResult :: ContentProcess ( content_process) ;
649646 }
650647
651- let debug_string = match opt_match. opt_str ( "Z" ) {
652- Some ( string) => string,
653- None => String :: new ( )
654- } ;
648+ let mut debug_options = DebugOptions :: default ( ) ;
655649
656- let debug_options = match DebugOptions :: new ( & debug_string) {
657- Ok ( debug_options) => debug_options,
658- Err ( e) => args_fail ( & format ! ( "error: unrecognized debug option: {}" , e) ) ,
659- } ;
650+ for debug_string in opt_match. opt_strs ( "Z" ) {
651+ if let Err ( e) = debug_options. extend ( debug_string) {
652+ return args_fail ( & format ! ( "error: unrecognized debug option: {}" , e) ) ;
653+ }
654+ }
660655
661656 if debug_options. help {
662657 print_debug_usage ( app_name)
0 commit comments