1. Peter Hosey
  2. Symbolicator

Commits

Peter Hosey  committed 180d202 Merge

Merged changes from jeromejtk and ernst.

  • Participants
  • Parent commits 0ee97ba, 8008be0
  • Branches default

Comments (0)

Files changed (1)

File symbolicator.py

View file
  • Ignore whitespace
 
 recognized_versions = [
 	6,
-	104
+	9,
+	104,
 ]
 
 log_search = False
 	if log_search:
 		print >>debug_log_file, 'Finding dSYM bundle for', bundle_ID
 	if bundle_ID in binary_images:
-		return find_dSYM_by_UUID(binary_images[bundle_ID])
+		return find_dSYM_by_UUID(binary_images[bundle_ID]['uuid'])
 	elif bundle_ID.startswith('...'):
 		bundle_ID_suffix = bundle_ID.lstrip('...')
 		for (bundle_ID_key, UUID) in binary_images.iteritems():
 			if bundle_ID_key.endswith(bundle_ID_suffix):
 				binary_images[bundle_ID] = UUID
-				return find_dSYM_by_UUID(UUID)
+				return find_dSYM_by_UUID(UUID['uuid'])
 		return None
 	else:
 		return None
 
 def parse_binary_image_line(line):
-	bundle_ID = ""
-	UUID = ""
+	elements = iter(line.split())
 
-	match = binary_image_line_exp.search(line)
-	line_at_bundle_start = match.group(1);
-#	pdb.set_trace()
-	for a_bundle_id in bundle_idents:
-		if line_at_bundle_start.startswith( a_bundle_id + " " ):
-			bundle_ID = a_bundle_id
-			match = binary_image_uuid_exp.match( line )
-			if not match:
-				UUID = ""
-			else:
-				UUID = match.group('uuid')
-			
-			break
+	start_address = elements.next()
+	elements.next() # Hyphen-minus
+	end_address = elements.next()
+	bundle_ID = elements.next()
+	short_version = elements.next()
+	test = elements.next() # Hyphen-minus, version 9
+	if test != '-':
+		bundle_version = test
+	else:
+		bundle_version = elements.next()
+	UUID_in_brackets = elements.next()
+	try:
+		binary_path = elements.next()
+		try:
+			while True:
+				binary_path += ' ' + elements.next()
+		except StopIteration:
+			pass
+	except StopIteration:
+		return (None, None, None)
 
-		elif a_bundle_id.startswith('...'):
-			a_bundle_id_suffix = a_bundle_id.lstrip('...')
-			index = line_at_bundle_start.find( a_bundle_id_suffix )
-			# Crash Reporter truncates at 30, so the index we find the stub at + 27 should equal the 
-			# entire length of the bundle ID
-			if index != -1:
-				bundle_ID = line_at_bundle_start[:index + 27]
-				match = binary_image_uuid_exp.match( line )
-				if not match:
-					UUID = ""
-				else:
-					UUID = match.group('uuid')
-				
-				break
-			
-	return( bundle_ID, UUID )
+	UUID = UUID_in_brackets.strip('<>')
+	# The main(?) executable has plus sign before its bundle ID. Strip this off.
+	bundle_ID = bundle_ID.lstrip('+')
 
+	return (bundle_ID, UUID, binary_path)
+
+def look_up_address_by_path(bundle_ID, address):
+	"""using atos looks up symbols"""
+	path = binary_images[bundle_ID]['path']
+	if not os.path.exists(path):
+		print >>sys.stderr, "Binary does not exist: ", path
+		return
+	atos = subprocess.Popen(['xcrun', 'atos', '-arch', architecture, '-o', path, address], stdout=subprocess.PIPE)
+	for line in atos.stdout:
+		line = line.strip()
+		return line
+	
 def look_up_address_by_bundle_ID(bundle_ID, address, slide):
 	dSYM_path = find_dSYM_by_bundle_ID(bundle_ID)
 	if dSYM_path:
 	global bundle_idents
 	bundle_idents = []
 	global architecture
+	global executable_bundle_id
+	executable_bundle_id = None
 	architecture = None
 	global binary_image_line_exp, binary_image_uuid_exp
 	global backtrace_exp
 		elif is_in_binary_images:
 			if line_stripped.strip():
 				binary_image_lines.append(line)
-				bundle_ID, UUID = parse_binary_image_line(line)
-				binary_images[bundle_ID] = UUID
+				bundle_ID, UUID, path = parse_binary_image_line(line_stripped)
+				if bundle_ID:
+					if executable_bundle_id == None: # first entry is executable
+						executable_bundle_id = bundle_ID
+					binary_images[bundle_ID] = {'uuid': UUID, 'path': path}
 			else:
 				# End of crash
 				flush_buffers()