<s> import re <EOL> import sublime <EOL> import lldb <EOL> import lldbutil <EOL> from multiprocessing import Lock <EOL> from debug import debug , debugViews , debugSettings <EOL> from utilities import SettingsManager <EOL> from root_objects import lldb_register_view_name , lldb_disassembly_view_name , lldb_variable_view_name , driver_instance , add_lldb_view <EOL> class LLDBView ( object ) : <EOL> def __init__ ( self , view ) : <EOL> if view . __class__ . __name__ . startswith ( "<STR_LIT>" ) : <EOL> assert False <EOL> self . __view = view <EOL> self . __name = view . name ( ) <EOL> self . __file_name = view . file_name ( ) <EOL> add_lldb_view ( self ) <EOL> debug ( debugViews , "<STR_LIT>" % <EOL> str ( ( self . __class__ . __name__ , self . __view , self . __name , self . __file_name ) ) ) <EOL> def base_view ( self ) : <EOL> return self . __view <EOL> def name ( self ) : <EOL> return self . __name <EOL> def set_name ( self , name ) : <EOL> self . base_view ( ) . set_name ( name ) <EOL> self . __name = name <EOL> def file_name ( self ) : <EOL> return self . __file_name <EOL> def set_read_only ( self , is_ro = True ) : <EOL> self . __view . set_read_only ( is_ro ) <EOL> def set_scratch ( self , is_scratch = True ) : <EOL> self . __view . set_scratch ( is_scratch ) <EOL> def show ( self , point_or_region_or_region_set , show_surrounds = True ) : <EOL> self . __view . show ( point_or_region_or_region_set , show_surrounds ) <EOL> def full_update ( self ) : <EOL> """<STR_LIT>""" <EOL> self . pre_update ( ) <EOL> sublime . set_timeout ( self . update , <NUM_LIT:0> ) <EOL> def pre_update ( self ) : <EOL> """<STR_LIT>""" <EOL> pass <EOL> def update ( self ) : <EOL> """<STR_LIT>""" <EOL> assert False , "<STR_LIT>" % self . __class__ . __name__ <EOL> def stop ( self ) : <EOL> """<STR_LIT>""" <EOL> pass <EOL> class LLDBReadOnlyView ( LLDBView ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , view ) : <EOL> super ( LLDBReadOnlyView , self ) . __init__ ( view ) <EOL> self . __content = '<STR_LIT>' <EOL> def content ( self ) : <EOL> return self . __content <EOL> def updated_content ( self ) : <EOL> assert False , "<STR_LIT>" % self . __class__ . __name__ <EOL> def pre_update ( self ) : <EOL> self . __content = self . updated_content ( ) <EOL> def update ( self ) : <EOL> string = self . content ( ) <EOL> view = self . base_view ( ) <EOL> view . set_read_only ( False ) <EOL> edit = view . begin_edit ( view . name ( ) ) <EOL> region = sublime . Region ( <NUM_LIT:0> , view . size ( ) ) <EOL> view . erase ( edit , region ) <EOL> view . insert ( edit , <NUM_LIT:0> , string ) <EOL> view . end_edit ( edit ) <EOL> view . set_read_only ( True ) <EOL> self . epilogue ( ) <EOL> def epilogue ( self ) : <EOL> pass <EOL> class LLDBCodeView ( LLDBView ) : <EOL> eRegionPC = <NUM_LIT:1> << <NUM_LIT:0> <EOL> eRegionBreakpointEnabled = <NUM_LIT:1> << <NUM_LIT:1> <EOL> eRegionBreakpointDisabled = <NUM_LIT:1> << <NUM_LIT:2> <EOL> __pc_line = None <EOL> __bp_lock = Lock ( ) <EOL> settings_keys = [ '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' ] <EOL> __sm = SettingsManager . getSM ( ) <EOL> eMarkerPCName = __sm . get_default ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> eMarkerPCScope = __sm . get_default ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> eMarkerPCScopeCrashed = __sm . get_default ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> eMarkerPCIcon = __sm . get_default ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> eMarkerBreakpointEnabledName = __sm . get_default ( '<STR_LIT>' , <EOL> '<STR_LIT>' ) <EOL> eMarkerBreakpointEnabledScope = __sm . get_default ( '<STR_LIT>' , '<STR_LIT:string>' ) <EOL> eMarkerBreakpointEnabledIcon = __sm . get_default ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> eMarkerBreakpointDisabledName = __sm . get_default ( '<STR_LIT>' , <EOL> '<STR_LIT>' ) <EOL> eMarkerBreakpointDisabledScope = __sm . get_default ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> eMarkerBreakpointDisabledIcon = __sm . get_default ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> def __init__ ( self , view , driver ) : <EOL> super ( LLDBCodeView , self ) . __init__ ( view ) <EOL> self . __needs_update = False <EOL> self . __driver = driver <EOL> self . __enabled_bps = { } <EOL> self . __disabled_bps = { } <EOL> self . __populate_breakpoint_lists ( ) <EOL> if not view . is_loading ( ) : <EOL> self . __update_bps ( ) <EOL> self . pre_update ( ) <EOL> else : <EOL> debug ( debugViews , '<STR_LIT>' ) <EOL> self . pre_update ( ) <EOL> self . __needs_update = '<STR_LIT>' <EOL> for k in self . settings_keys : <EOL> self . __sm . add_observer ( k , self . setting_updated ) <EOL> def __del__ ( self ) : <EOL> self . __sm . del_observer ( self . settings_updated ) <EOL> def __repr__ ( self ) : <EOL> return '<STR_LIT>' % ( self . __class__ . __name__ , self . file_name ( ) , str ( self . _needs_update ) , <EOL> str ( self . __pc_line ) , str ( self . __enabled_bps ) , str ( self . __disabled_bps ) ) <EOL> def setting_updated ( self , key , old , new ) : <EOL> debug ( debugSettings | debugViews , '<STR_LIT>' % ( key , old , new , self ) ) <EOL> if key . startswith ( '<STR_LIT>' ) : <EOL> self . __mark_pc ( None ) <EOL> self . __class__ . eMarkerPCName = self . __sm . get_default ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . __class__ . eMarkerPCScope = self . __sm . get_default ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . __class__ . eMarkerPCScopeCrashed = self . __sm . get_default ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . __class__ . eMarkerPCIcon = self . __sm . get_default ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . __mark_pc ( self . __pc_line - <NUM_LIT:1> , False ) <EOL> elif key . startswith ( '<STR_LIT>' ) : <EOL> self . __mark_regions ( [ ] , self . eRegionBreakpointEnabled ) <EOL> self . __class__ . eMarkerBreakpointEnabledName = self . __sm . get_default ( '<STR_LIT>' , <EOL> '<STR_LIT>' ) <EOL> self . __class__ . eMarkerBreakpointEnabledScope = self . __sm . get_default ( '<STR_LIT>' , '<STR_LIT:string>' ) <EOL> self . __class__ . eMarkerBreakpointEnabledIcon = self . __sm . get_default ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> v = self . base_view ( ) <EOL> regions = map ( lambda line : v . line ( v . text_point ( line - <NUM_LIT:1> , <NUM_LIT:0> ) ) , self . __enabled_bps . keys ( ) ) <EOL> self . __mark_regions ( regions , self . eRegionBreakpointEnabled ) <EOL> elif key . startswith ( '<STR_LIT>' ) : <EOL> self . __mark_regions ( [ ] , self . eRegionBreakpointDisabled ) <EOL> self . __class__ . eMarkerBreakpointDisabledName = self . __sm . get_default ( '<STR_LIT>' , <EOL> '<STR_LIT>' ) <EOL> self . __class__ . eMarkerBreakpointDisabledScope = self . __sm . get_default ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . __class__ . eMarkerBreakpointDisabledIcon = self . __sm . get_default ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> v = self . base_view ( ) <EOL> regions = map ( lambda line : v . line ( v . text_point ( line - <NUM_LIT:1> , <NUM_LIT:0> ) ) , self . __disabled_bps . keys ( ) ) <EOL> self . __mark_regions ( regions , self . eRegionBreakpointDisabled ) <EOL> else : <EOL> raise Exception ( '<STR_LIT>' % key ) <EOL> @ property <EOL> def __needs_update ( self ) : <EOL> return self . _needs_update <EOL> @ __needs_update . setter <EOL> def __needs_update ( self , value ) : <EOL> self . _needs_update = value <EOL> def mark_bp ( self , line , is_enabled = True ) : <EOL> """<STR_LIT>""" <EOL> self . __add_bps ( [ line ] , is_enabled ) <EOL> v = self . base_view ( ) <EOL> if is_enabled : <EOL> regions = map ( lambda line : v . line ( v . text_point ( line - <NUM_LIT:1> , <NUM_LIT:0> ) ) , self . __enabled_bps . keys ( ) ) <EOL> self . __mark_regions ( regions , self . eRegionBreakpointEnabled ) <EOL> else : <EOL> regions = map ( lambda line : v . line ( v . text_point ( line - <NUM_LIT:1> , <NUM_LIT:0> ) ) , self . __disabled_bps . keys ( ) ) <EOL> self . __mark_regions ( regions , self . eRegionBreakpointDisabled ) <EOL> def change_bp ( self , line , is_enabled ) : <EOL> if is_enabled : <EOL> remove_from = self . __disabled_bps <EOL> add_to = self . __enabled_bps <EOL> else : <EOL> remove_from = self . __enabled_bps <EOL> add_to = self . __disabled_bps <EOL> with self . __bp_lock : <EOL> existing = remove_from [ line ] <EOL> if existing == <NUM_LIT:1> : <EOL> del remove_from [ line ] <EOL> else : <EOL> remove_from [ line ] = existing - <NUM_LIT:1> <EOL> if line in add_to : <EOL> existing = add_to [ line ] <EOL> else : <EOL> existing = <NUM_LIT:0> <EOL> add_to [ line ] = existing + <NUM_LIT:1> <EOL> v = self . base_view ( ) <EOL> regions = map ( lambda line : v . line ( v . text_point ( line - <NUM_LIT:1> , <NUM_LIT:0> ) ) , self . __enabled_bps . keys ( ) ) <EOL> self . __mark_regions ( regions , self . eRegionBreakpointEnabled ) <EOL> regions = map ( lambda line : v . line ( v . text_point ( line - <NUM_LIT:1> , <NUM_LIT:0> ) ) , self . __disabled_bps . keys ( ) ) <EOL> self . __mark_regions ( regions , self . eRegionBreakpointDisabled ) <EOL> def unmark_bp ( self , line , is_enabled = True ) : <EOL> """<STR_LIT>""" <EOL> self . __remove_bps ( [ line ] , is_enabled ) <EOL> v = self . base_view ( ) <EOL> if is_enabled : <EOL> regions = map ( lambda line : v . line ( v . text_point ( line - <NUM_LIT:1> , <NUM_LIT:0> ) ) , self . __enabled_bps . keys ( ) ) <EOL> self . __mark_regions ( regions , self . eRegionBreakpointEnabled ) <EOL> else : <EOL> regions = map ( lambda line : v . line ( v . text_point ( line - <NUM_LIT:1> , <NUM_LIT:0> ) ) , self . __disabled_bps . keys ( ) ) <EOL> self . __mark_regions ( regions , self . eRegionBreakpointDisabled ) <EOL> def pre_update ( self ) : <EOL> """<STR_LIT>""" <EOL> old_needs_update = self . __needs_update <EOL> self . __needs_update = False <EOL> old_pc_line = self . __pc_line <EOL> self . __pc_line = None <EOL> debug ( debugViews , '<STR_LIT>' % str ( old_pc_line ) ) <EOL> thread = self . __driver . current_thread ( ) <EOL> if not thread : <EOL> debug ( debugViews , '<STR_LIT>' % str ( self . __pc_line ) ) <EOL> if self . __pc_line != old_pc_line : <EOL> self . __needs_update = old_needs_update or True <EOL> return False <EOL> for frame in thread : <EOL> line_entry = frame . GetLineEntry ( ) <EOL> filespec = line_entry . GetFileSpec ( ) <EOL> if filespec : <EOL> filename = filespec . GetDirectory ( ) + '<STR_LIT:/>' + filespec . GetFilename ( ) <EOL> if filename == self . file_name ( ) : <EOL> self . __pc_line = line_entry . GetLine ( ) <EOL> debug ( debugViews , '<STR_LIT>' % str ( self . __pc_line ) ) <EOL> if self . __pc_line != old_pc_line or old_needs_update == '<STR_LIT>' : <EOL> self . __needs_update = old_needs_update or True <EOL> return True <EOL> debug ( debugViews , '<STR_LIT>' % str ( self . __pc_line ) ) <EOL> if self . __pc_line != old_pc_line or old_needs_update == '<STR_LIT>' : <EOL> self . __needs_update = old_needs_update or True <EOL> return False <EOL> def update ( self ) : <EOL> debug ( debugViews , '<STR_LIT>' % str ( self . __needs_update ) ) <EOL> if self . __needs_update and not self . base_view ( ) . is_loading ( ) : <EOL> if self . __needs_update == '<STR_LIT>' : <EOL> self . __update_bps ( ) <EOL> if self . __pc_line is not None : <EOL> self . __mark_pc ( self . __pc_line - <NUM_LIT:1> , True ) <EOL> else : <EOL> self . __mark_pc ( None ) <EOL> self . __needs_update = False <EOL> else : <EOL> debug ( debugViews , '<STR_LIT>' % repr ( self ) ) <EOL> def stop ( self ) : <EOL> self . pre_update ( ) <EOL> self . __enabled_bps = { } <EOL> self . __disabled_bps = { } <EOL> def to_ui ( ) : <EOL> debug ( debugViews , '<STR_LIT>' ) <EOL> self . update ( ) <EOL> self . __update_bps ( ) <EOL> sublime . set_timeout ( to_ui , <NUM_LIT:0> ) <EOL> def __mark_regions ( self , regions , type ) : <EOL> if type == self . eRegionPC : <EOL> self . __mark_or_delete_regions ( self . eMarkerPCName , regions , self . eMarkerPCScope , <EOL> self . eMarkerPCIcon , sublime . HIDDEN ) <EOL> elif type == self . eRegionBreakpointEnabled : <EOL> self . __mark_or_delete_regions ( self . eMarkerBreakpointEnabledName , regions , self . eMarkerBreakpointEnabledScope , <EOL> self . eMarkerBreakpointEnabledIcon , sublime . HIDDEN ) <EOL> elif type == self . eRegionBreakpointDisabled : <EOL> self . __mark_or_delete_regions ( self . eMarkerBreakpointDisabledName , regions , self . eMarkerBreakpointDisabledScope , <EOL> self . eMarkerBreakpointDisabledIcon , sublime . HIDDEN ) <EOL> def __mark_or_delete_regions ( self , name , regions , scope , icon , options ) : <EOL> if len ( regions ) > <NUM_LIT:0> : <EOL> debug ( debugViews , '<STR_LIT>' % ( self . file_name ( ) , ( name , regions , scope , icon , options ) ) ) <EOL> self . base_view ( ) . add_regions ( name , regions , scope , icon , options ) <EOL> else : <EOL> debug ( debugViews , '<STR_LIT>' % name ) <EOL> self . base_view ( ) . erase_regions ( name ) <EOL> def __mark_pc ( self , line , show = False ) : <EOL> debug ( debugViews , '<STR_LIT>' % repr ( self ) ) <EOL> v = self . base_view ( ) <EOL> if line is None : <EOL> to_mark = [ ] <EOL> else : <EOL> to_mark = [ v . line ( v . text_point ( line , <NUM_LIT:0> ) ) ] <EOL> self . __mark_regions ( to_mark , self . eRegionPC ) <EOL> if show and to_mark : <EOL> self . show ( to_mark [ <NUM_LIT:0> ] , True ) <EOL> def __populate_breakpoint_lists ( self ) : <EOL> file_bp_locs = self . __driver . get_breakpoint_locations_for_file ( self . file_name ( ) ) <EOL> def line_from_bp_loc ( bp_loc ) : <EOL> line_entry = bp_loc . GetAddress ( ) . GetLineEntry ( ) <EOL> return line_entry . GetLine ( ) <EOL> enabled_bp_lines = [ ] <EOL> disabled_bp_lines = [ ] <EOL> for bp_loc in file_bp_locs : <EOL> if bp_loc . IsEnabled ( ) : <EOL> enabled_bp_lines . append ( line_from_bp_loc ( bp_loc ) ) <EOL> else : <EOL> disabled_bp_lines . append ( line_from_bp_loc ( bp_loc ) ) <EOL> self . __add_bps ( enabled_bp_lines , True ) <EOL> self . __add_bps ( disabled_bp_lines , False ) <EOL> def __add_bps ( self , lines , are_enabled = True ) : <EOL> """<STR_LIT>""" <EOL> if len ( lines ) > <NUM_LIT:0> : <EOL> self . __needs_update = True <EOL> if are_enabled : <EOL> add_to = self . __enabled_bps <EOL> else : <EOL> add_to = self . __disabled_bps <EOL> with self . __bp_lock : <EOL> for line in lines : <EOL> if line in add_to : <EOL> existing = add_to [ line ] <EOL> else : <EOL> existing = <NUM_LIT:0> <EOL> add_to [ line ] = existing + <NUM_LIT:1> <EOL> def __remove_bps ( self , lines , are_enabled = True ) : <EOL> """<STR_LIT>""" <EOL> if len ( lines ) > <NUM_LIT:0> : <EOL> self . __needs_update = True <EOL> if are_enabled : <EOL> remove_from = self . __enabled_bps <EOL> else : <EOL> remove_from = self . __disabled_bps <EOL> with self . __bp_lock : <EOL> for line in lines : <EOL> existing = remove_from [ line ] <EOL> if existing == <NUM_LIT:1> : <EOL> del remove_from [ line ] <EOL> else : <EOL> remove_from [ line ] = existing - <NUM_LIT:1> <EOL> def __update_bps ( self ) : <EOL> v = self . base_view ( ) <EOL> regions = map ( lambda line : v . line ( v . text_point ( line - <NUM_LIT:1> , <NUM_LIT:0> ) ) , self . __enabled_bps . keys ( ) ) <EOL> self . __mark_regions ( regions , self . eRegionBreakpointEnabled ) <EOL> regions = map ( lambda line : v . line ( v . text_point ( line - <NUM_LIT:1> , <NUM_LIT:0> ) ) , self . __disabled_bps . keys ( ) ) <EOL> self . __mark_regions ( regions , self . eRegionBreakpointDisabled ) <EOL> class LLDBRegisterView ( LLDBReadOnlyView ) : <EOL> def __init__ ( self , view , thread ) : <EOL> self . __thread = thread <EOL> super ( LLDBRegisterView , self ) . __init__ ( view ) <EOL> self . set_name ( lldb_register_view_name ( thread ) ) <EOL> self . set_scratch ( ) <EOL> @ property <EOL> def thread ( self ) : <EOL> return self . __thread <EOL> def updated_content ( self ) : <EOL> thread = self . __thread <EOL> if not thread . IsValid ( ) : <EOL> return '<STR_LIT>' <EOL> target = thread . GetProcess ( ) . GetTarget ( ) <EOL> frame = thread . GetSelectedFrame ( ) <EOL> registerList = frame . GetRegisters ( ) <EOL> result = '<STR_LIT>' <EOL> for value in registerList : <EOL> result = result + ( '<STR_LIT>' % ( value . GetName ( ) , value . GetNumChildren ( ) ) ) <EOL> for child in value : <EOL> if child . GetValue ( ) is not None : <EOL> addr = lldb . SBAddress ( child . GetValueAsUnsigned ( ) , target ) <EOL> desc = lldbutil . get_description ( addr ) <EOL> if re . match ( '<STR_LIT>' , desc ) : <EOL> desc = '<STR_LIT>' <EOL> else : <EOL> desc = '<STR_LIT>' + desc <EOL> result = result + ( '<STR_LIT>' % ( child . GetName ( ) , child . GetValue ( ) , desc ) ) <EOL> return result <EOL> class LLDBThreadDisassemblyView ( LLDBReadOnlyView ) : <EOL> __pc_line = <NUM_LIT:0> <EOL> settings_keys = [ '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' ] <EOL> __sm = SettingsManager . getSM ( ) <EOL> eMarkerPCName = __sm . get_default ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> eMarkerPCScope = __sm . get_default ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> eMarkerPCScopeCrashed = __sm . get_default ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> eMarkerPCIcon = __sm . get_default ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> def __init__ ( self , view , thread ) : <EOL> self . __thread = thread <EOL> super ( LLDBThreadDisassemblyView , self ) . __init__ ( view ) <EOL> self . set_name ( lldb_disassembly_view_name ( thread . GetThreadID ( ) ) ) <EOL> self . set_scratch ( ) <EOL> for k in self . settings_keys : <EOL> self . __sm . add_observer ( k , self . setting_updated ) <EOL> def __repr__ ( self ) : <EOL> return '<STR_LIT>' % ( self . __class__ . __name__ , self . name ( ) , self . thread , self . pc_line , len ( self . content ( ) ) ) <EOL> @ property <EOL> def thread ( self ) : <EOL> return self . __thread <EOL> @ property <EOL> def pc_line ( self ) : <EOL> return self . __pc_line <EOL> def setting_updated ( self , key , old , new ) : <EOL> debug ( debugSettings | debugViews , '<STR_LIT>' % ( key , old , new , self ) ) <EOL> if key . startswith ( '<STR_LIT>' ) : <EOL> self . __mark_pc ( None ) <EOL> self . __class__ . eMarkerPCName = self . __sm . get_default ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . __class__ . eMarkerPCScope = self . __sm . get_default ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . __class__ . eMarkerPCScopeCrashed = self . __sm . get_default ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . __class__ . eMarkerPCIcon = self . __sm . get_default ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . __mark_pc ( self . __pc_line - <NUM_LIT:1> , False ) <EOL> else : <EOL> raise Exception ( '<STR_LIT>' % key ) <EOL> def epilogue ( self ) : <EOL> if self . pc_line != <NUM_LIT:0> : <EOL> debug ( debugViews , '<STR_LIT>' % repr ( self ) ) <EOL> v = self . base_view ( ) <EOL> r = v . text_point ( self . pc_line , <NUM_LIT:0> ) <EOL> to_mark = [ v . line ( r ) ] <EOL> debug ( debugViews , '<STR_LIT:(>' + self . name ( ) + '<STR_LIT>' + str ( ( self . eMarkerPCName , to_mark , self . eMarkerPCScope , self . eMarkerPCIcon , sublime . HIDDEN ) ) ) <EOL> self . base_view ( ) . add_regions ( self . eMarkerPCName , to_mark , self . eMarkerPCScope , self . eMarkerPCIcon , sublime . HIDDEN ) <EOL> self . show ( to_mark [ <NUM_LIT:0> ] , True ) <EOL> else : <EOL> debug ( debugViews , '<STR_LIT>' % self . eMarkerPCName ) <EOL> self . base_view ( ) . erase_regions ( self . eMarkerPCName ) <EOL> def updated_content ( self ) : <EOL> debug ( debugViews , '<STR_LIT>' % repr ( self ) ) <EOL> self . __pc_line = <NUM_LIT:0> <EOL> thread = self . __thread <EOL> if not thread . IsValid ( ) : <EOL> return '<STR_LIT>' <EOL> target = thread . GetProcess ( ) . GetTarget ( ) <EOL> pc = thread . GetSelectedFrame ( ) . GetPCAddress ( ) <EOL> function = pc . GetFunction ( ) <EOL> symbol = pc . GetSymbol ( ) <EOL> if function . IsValid ( ) : <EOL> name = function . GetName ( ) <EOL> start_addr = function . GetStartAddress ( ) . GetLoadAddress ( target ) <EOL> elif symbol . IsValid ( ) : <EOL> name = symbol . GetName ( ) <EOL> start_addr = symbol . GetStartAddress ( ) . GetLoadAddress ( target ) <EOL> else : <EOL> name = pc . GetModule ( ) . GetFileSpec ( ) . GetFilename ( ) <EOL> start_addr = pc . GetLoadAddress ( target ) <EOL> instrs = driver_instance ( ) . disassemble_frame ( thread . GetSelectedFrame ( ) ) <EOL> if not instrs : <EOL> return '<STR_LIT>' % thread . GetThreadID ( ) <EOL> pc = driver_instance ( ) . get_PC ( ) <EOL> def get_max_sizes ( accum , next ) : <EOL> return ( max ( accum [ <NUM_LIT:0> ] , len ( next [ <NUM_LIT:1> ] ) ) , max ( accum [ <NUM_LIT:1> ] , len ( next [ <NUM_LIT:2> ] ) ) ) <EOL> ( max_mnemonic , max_operands ) = reduce ( get_max_sizes , instrs , ( <NUM_LIT:0> , <NUM_LIT:0> ) ) <EOL> format_str = '<STR_LIT>' <EOL> max_mnemonic , max_operands = ( int ( max_mnemonic ) , int ( max_operands ) ) <EOL> result = '<STR_LIT>' % ( name , start_addr ) <EOL> n_instrs = <NUM_LIT:0> <EOL> for i in instrs : <EOL> n_instrs += <NUM_LIT:1> <EOL> if len ( i ) == <NUM_LIT:3> : <EOL> ( addr , mnemonic , ops ) = i <EOL> comment_str = '<STR_LIT>' <EOL> elif len ( i ) == <NUM_LIT:4> : <EOL> ( addr , mnemonic , ops , comment ) = i <EOL> comment_str = '<STR_LIT>' + comment <EOL> else : <EOL> assert False <EOL> if pc == addr : <EOL> self . __pc_line = n_instrs <EOL> result += format_str % ( hex ( addr ) , max_mnemonic , mnemonic , max_operands , ops , comment_str ) <EOL> return result <EOL> class LLDBVariableView ( LLDBReadOnlyView ) : <EOL> def __init__ ( self , view , thread ) : <EOL> self . __thread = thread <EOL> super ( LLDBVariableView , self ) . __init__ ( view ) <EOL> self . set_name ( lldb_variable_view_name ( thread ) ) <EOL> self . set_scratch ( ) <EOL> @ property <EOL> def thread ( self ) : <EOL> return self . __thread <EOL> def updated_content ( self ) : <EOL> thread = self . __thread <EOL> if not thread . IsValid ( ) : <EOL> return '<STR_LIT>' <EOL> frame = thread . GetSelectedFrame ( ) <EOL> variables = frame . GetVariables ( True , True , True , True ) <EOL> result = '<STR_LIT>' <EOL> for var in variables : <EOL> result = result + ( '<STR_LIT>' % self . __name_for ( var ) ) <EOL> if var . GetNumChildren ( ) == <NUM_LIT:0> : <EOL> result = result + self . __value_for ( var ) + '<STR_LIT:\n>' <EOL> else : <EOL> result = result + '<STR_LIT>' <EOL> for child in var : <EOL> typename = self . __typename_for ( child ) <EOL> name = self . __name_for ( child ) <EOL> value = self . __value_for ( child ) <EOL> result = result + ( '<STR_LIT>' % ( typename , name , value ) ) <EOL> result = result + '<STR_LIT>' <EOL> return result <EOL> def __typename_for ( self , value ) : <EOL> if value . IsValid ( ) : <EOL> return value . GetTypeName ( ) <EOL> else : <EOL> return "<STR_LIT>" <EOL> def __name_for ( self , value ) : <EOL> if value . IsValid ( ) : <EOL> return value . GetName ( ) <EOL> else : <EOL> return "<STR_LIT>" <EOL> def __value_for ( self , value ) : <EOL> if value . IsValid ( ) : <EOL> if not value . IsInScope ( ) : <EOL> return "<STR_LIT>" <EOL> return value . GetValue ( ) <EOL> else : <EOL> return "<STR_LIT>" </s>
