Modified the symbolication.Image object to store its uuid as a uuid.UUID object and made an accessor for getting a normalized UUID value out of the image object.
Modified the crashlog darwin module to always create a uuid.UUID object when making the symbolication.Image objects. Also modified it to handle some more types of crash log files and improved the register reading for thread registers of crashed threads.
git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@156596 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/examples/python/crashlog.py b/examples/python/crashlog.py
index 35c1b14..7d65353 100755
--- a/examples/python/crashlog.py
+++ b/examples/python/crashlog.py
@@ -121,14 +121,15 @@
if self.resolved_path:
# Don't load a module twice...
return True
- print 'Getting symbols for %s %s...' % (self.uuid, self.path),
+ uuid_str = self.get_normalized_uuid_string()
+ print 'Getting symbols for %s %s...' % (uuid_str, self.path),
if os.path.exists(self.dsymForUUIDBinary):
- dsym_for_uuid_command = '%s %s' % (self.dsymForUUIDBinary, self.uuid)
+ dsym_for_uuid_command = '%s %s' % (self.dsymForUUIDBinary, uuid_str)
s = commands.getoutput(dsym_for_uuid_command)
if s:
plist_root = plistlib.readPlistFromString (s)
if plist_root:
- plist = plist_root[self.uuid]
+ plist = plist_root[uuid_str]
if plist:
if 'DBGArchitecture' in plist:
self.arch = plist['DBGArchitecture']
@@ -138,7 +139,7 @@
self.resolved_path = os.path.expanduser (plist['DBGSymbolRichExecutable'])
if not self.resolved_path and os.path.exists(self.path):
dwarfdump_cmd_output = commands.getoutput('dwarfdump --uuid "%s"' % self.path)
- self_uuid = uuid.UUID(self.uuid)
+ self_uuid = self.get_uuid()
for line in dwarfdump_cmd_output.splitlines():
match = self.dwarfdump_uuid_regex.search (line)
if match:
@@ -149,7 +150,7 @@
self.arch = match.group(2)
break;
if not self.resolved_path:
- print "error: file %s '%s' doesn't match the UUID in the installed file" % (self.uuid, self.path)
+ print "error: file %s '%s' doesn't match the UUID in the installed file" % (uuid_str, self.path)
return False
if (self.resolved_path and os.path.exists(self.resolved_path)) or (self.path and os.path.exists(self.path)):
print 'ok'
@@ -267,6 +268,8 @@
continue
self.info_lines.append(line.strip())
elif parse_mode == PARSE_MODE_THREAD:
+ if line.startswith ('Thread'):
+ continue
frame_match = self.frame_regex.search(line)
if frame_match:
ident = frame_match.group(2)
@@ -282,7 +285,7 @@
int(image_match.group(2),0),
image_match.group(3).strip(),
image_match.group(4).strip(),
- image_match.group(5),
+ uuid.UUID(image_match.group(5)),
image_match.group(6))
self.images.append (image)
else:
@@ -300,9 +303,12 @@
elif parse_mode == PARSE_MODE_THREGS:
stripped_line = line.strip()
- reg_values = stripped_line.split(' ')
+ reg_values = re.split(' +', stripped_line);
for reg_value in reg_values:
+ #print 'reg_value = "%s"' % reg_value
(reg, value) = reg_value.split(': ')
+ #print 'reg = "%s"' % reg
+ #print 'value = "%s"' % value
thread.registers[reg.strip()] = int(value, 0)
elif parse_mode == PARSE_MODE_SYSTEM:
self.system_profile.append(line)
@@ -398,24 +404,29 @@
except:
return
- for image_path in args:
- fullpath_search = image_path[0] == '/'
- for crash_log in self.crash_logs:
- matches_found = 0
- for (image_idx, image) in enumerate(crash_log.images):
- if fullpath_search:
- if image.get_resolved_path() == image_path:
- matches_found += 1
- print image
- else:
- image_basename = image.get_resolved_path_basename()
- if image_basename == image_path:
- matches_found += 1
- print image
- if matches_found == 0:
+ if args:
+ for image_path in args:
+ fullpath_search = image_path[0] == '/'
+ for crash_log in self.crash_logs:
+ matches_found = 0
for (image_idx, image) in enumerate(crash_log.images):
- if string.find(image.get_resolved_path(), image_path) >= 0:
- print image
+ if fullpath_search:
+ if image.get_resolved_path() == image_path:
+ matches_found += 1
+ print image
+ else:
+ image_basename = image.get_resolved_path_basename()
+ if image_basename == image_path:
+ matches_found += 1
+ print image
+ if matches_found == 0:
+ for (image_idx, image) in enumerate(crash_log.images):
+ if string.find(image.get_resolved_path(), image_path) >= 0:
+ print image
+ else:
+ for crash_log in self.crash_logs:
+ for (image_idx, image) in enumerate(crash_log.images):
+ print '[%u] %s' % (image_idx, image)
return False
diff --git a/examples/python/symbolication.py b/examples/python/symbolication.py
index aa5a404..2872d96 100755
--- a/examples/python/symbolication.py
+++ b/examples/python/symbolication.py
@@ -283,12 +283,13 @@
'''Add the Image described in this object to "target" and load the sections if "load" is True.'''
if target:
# Try and find using UUID only first so that paths need not match up
- if self.uuid:
- self.module = target.AddModule (None, None, str(self.uuid))
+ uuid_str = self.get_normalized_uuid_string()
+ if uuid_str:
+ self.module = target.AddModule (None, None, uuid_str)
if not self.module:
self.locate_module_and_debug_symbols ()
resolved_path = self.get_resolved_path()
- self.module = target.AddModule (resolved_path, self.arch, self.uuid)#, self.symfile)
+ self.module = target.AddModule (resolved_path, self.arch, uuid_str, self.symfile)
if not self.module:
return 'error: unable to get module for (%s) "%s"' % (self.arch, self.get_resolved_path())
if self.has_section_load_info():
@@ -308,10 +309,15 @@
return True
def get_uuid(self):
- if not self.uuid:
+ if not self.uuid and self.module:
self.uuid = uuid.UUID(self.module.GetUUIDString())
return self.uuid
+ def get_normalized_uuid_string(self):
+ if self.uuid:
+ return str(self.uuid).upper()
+ return None
+
def create_target(self):
'''Create a target using the information in this Image object.'''
if self.locate_module_and_debug_symbols ():