parameters: (linespec, frame, result)
return_statement: return addr_list
docstring: Handles a subset of GDB-style linespecs.  Specifically:
  
         number           - A line in the current file
         +offset          - The line /offset/ lines after this line
         -offset          - The line /offset/ lines before this line
         filename:number  - Line /number/ in file /filename/
         function         - The start of /function/
         *address         - The pointer target of /address/, which must be a literal (but see `` in LLDB)
  
         We explicitly do not handle filename:function because it is ambiguous in Objective-C.
  
         This function returns a list of addresses.
docstring_summary: Handles a subset of GDB-style linespecs.  Specifically:
docstring_tokens: Handles a subset of GDB - style linespecs . Specifically :
function: def parse_linespec(linespec, frame, result):
      """Handles a subset of GDB-style linespecs.  Specifically:
  
         number           - A line in the current file
         +offset          - The line /offset/ lines after this line
         -offset          - The line /offset/ lines before this line
         filename:number  - Line /number/ in file /filename/
         function         - The start of /function/
         *address         - The pointer target of /address/, which must be a literal (but see `` in LLDB)
  
         We explicitly do not handle filename:function because it is ambiguous in Objective-C.
  
         This function returns a list of addresses."""
  
      breakpoint = None
      target = frame.GetThread().GetProcess().GetTarget()
  
      matched = False
  
      if (not matched):
          mo = re.match("^([0-9]+)$", linespec)
          if (mo is not None):
              matched = True
              # print "Matched <linenum>"
              line_number = int(mo.group(1))
              line_entry = frame.GetLineEntry()
              if not line_entry.IsValid():
                  result.AppendMessage(
                      "Specified a line in the current file, but the current frame doesn't have line table information.")
                  return
              breakpoint = target.BreakpointCreateByLocation(
                  line_entry.GetFileSpec(), line_number)
  
      if (not matched):
          mo = re.match("^\+([0-9]+)$", linespec)
          if (mo is not None):
              matched = True
              # print "Matched +<count>"
              line_number = int(mo.group(1))
              line_entry = frame.GetLineEntry()
              if not line_entry.IsValid():
                  result.AppendMessage(
                      "Specified a line in the current file, but the current frame doesn't have line table information.")
                  return
              breakpoint = target.BreakpointCreateByLocation(
                  line_entry.GetFileSpec(), (line_entry.GetLine() + line_number))
  
      if (not matched):
          mo = re.match("^\-([0-9]+)$", linespec)
          if (mo is not None):
              matched = True
              # print "Matched -<count>"
              line_number = int(mo.group(1))
              line_entry = frame.GetLineEntry()
              if not line_entry.IsValid():
                  result.AppendMessage(
                      "Specified a line in the current file, but the current frame doesn't have line table information.")
                  return
              breakpoint = target.BreakpointCreateByLocation(
                  line_entry.GetFileSpec(), (line_entry.GetLine() - line_number))
  
      if (not matched):
          mo = re.match("^(.*):([0-9]+)$", linespec)
          if (mo is not None):
              matched = True
              # print "Matched <filename>:<linenum>"
              file_name = mo.group(1)
              line_number = int(mo.group(2))
              breakpoint = target.BreakpointCreateByLocation(
                  file_name, line_number)
  
      if (not matched):
          mo = re.match("\*((0x)?([0-9a-f]+))$", linespec)
          if (mo is not None):
              matched = True
              # print "Matched <address-expression>"
              address = int(mo.group(1), base=0)
              breakpoint = target.BreakpointCreateByAddress(address)
  
      if (not matched):
          # print "Trying <function-name>"
          breakpoint = target.BreakpointCreateByName(linespec)
  
      num_locations = breakpoint.GetNumLocations()
  
      if (num_locations == 0):
          result.AppendMessage(
              "The line specification provided doesn't resolve to any addresses.")
  
      addr_list = []
  
      for location_index in range(num_locations):
          location = breakpoint.GetLocationAtIndex(location_index)
          addr_list.append(location.GetAddress())
  
      target.BreakpointDelete(breakpoint.GetID())
  
      return addr_list
function_tokens: def parse_linespec ( linespec , frame , result ) : breakpoint = None target = frame . GetThread ( ) . GetProcess ( ) . GetTarget ( ) matched = False if ( not matched ) : mo = re . match ( "^([0-9]+)$" , linespec ) if ( mo is not None ) : matched = True # print "Matched <linenum>" line_number = int ( mo . group ( 1 ) ) line_entry = frame . GetLineEntry ( ) if not line_entry . IsValid ( ) : result . AppendMessage ( "Specified a line in the current file, but the current frame doesn't have line table information." ) return breakpoint = target . BreakpointCreateByLocation ( line_entry . GetFileSpec ( ) , line_number ) if ( not matched ) : mo = re . match ( "^\+([0-9]+)$" , linespec ) if ( mo is not None ) : matched = True # print "Matched +<count>" line_number = int ( mo . group ( 1 ) ) line_entry = frame . GetLineEntry ( ) if not line_entry . IsValid ( ) : result . AppendMessage ( "Specified a line in the current file, but the current frame doesn't have line table information." ) return breakpoint = target . BreakpointCreateByLocation ( line_entry . GetFileSpec ( ) , ( line_entry . GetLine ( ) + line_number ) ) if ( not matched ) : mo = re . match ( "^\-([0-9]+)$" , linespec ) if ( mo is not None ) : matched = True # print "Matched -<count>" line_number = int ( mo . group ( 1 ) ) line_entry = frame . GetLineEntry ( ) if not line_entry . IsValid ( ) : result . AppendMessage ( "Specified a line in the current file, but the current frame doesn't have line table information." ) return breakpoint = target . BreakpointCreateByLocation ( line_entry . GetFileSpec ( ) , ( line_entry . GetLine ( ) - line_number ) ) if ( not matched ) : mo = re . match ( "^(.*):([0-9]+)$" , linespec ) if ( mo is not None ) : matched = True # print "Matched <filename>:<linenum>" file_name = mo . group ( 1 ) line_number = int ( mo . group ( 2 ) ) breakpoint = target . BreakpointCreateByLocation ( file_name , line_number ) if ( not matched ) : mo = re . match ( "\*((0x)?([0-9a-f]+))$" , linespec ) if ( mo is not None ) : matched = True # print "Matched <address-expression>" address = int ( mo . group ( 1 ) , base = 0 ) breakpoint = target . BreakpointCreateByAddress ( address ) if ( not matched ) : # print "Trying <function-name>" breakpoint = target . BreakpointCreateByName ( linespec ) num_locations = breakpoint . GetNumLocations ( ) if ( num_locations == 0 ) : result . AppendMessage ( "The line specification provided doesn't resolve to any addresses." ) addr_list = [ ] for location_index in range ( num_locations ) : location = breakpoint . GetLocationAtIndex ( location_index ) addr_list . append ( location . GetAddress ( ) ) target . BreakpointDelete ( breakpoint . GetID ( ) ) return addr_list