Skip to content

Commit 1cbff29

Browse files
committed
Merge branch 'hotfix-0.7.2'
2 parents 006c46b + 36127e7 commit 1cbff29

File tree

2 files changed

+67
-5
lines changed

2 files changed

+67
-5
lines changed

plugin/lighthouse/parsers/drcov.py

Lines changed: 64 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ def _parse_module_table_header(self, f):
156156
eg: 'Module Table: 11'
157157
158158
Format used in DynamoRIO v7.0.0-RC1 (and hopefully above)
159-
eg: 'Module Table: version 2, count 11'
159+
eg: 'Module Table: version X, count 11'
160160
161161
"""
162162

@@ -191,6 +191,8 @@ def _parse_module_table_header(self, f):
191191
data_name, version = version_data.split(" ")
192192
#assert data_name == "version"
193193
self.module_table_version = int(version)
194+
if not self.module_table_version in [2, 3, 4]:
195+
raise ValueError("Unsupported (new?) drcov log format...")
194196

195197
# parse module count in table from 'count Y'
196198
data_name, count = count_data.split(" ")
@@ -203,15 +205,27 @@ def _parse_module_table_columns(self, f):
203205
204206
-------------------------------------------------------------------
205207
206-
Format used in DynamoRIO v6.1.1 through 6.2.0
208+
DynamoRIO v6.1.1, table version 1:
207209
eg: (Not present)
208210
209-
Format used in DynamoRIO v7.0.0-RC1 (and hopefully above)
211+
DynamoRIO v7.0.0-RC1, table version 2:
210212
Windows:
211213
'Columns: id, base, end, entry, checksum, timestamp, path'
212214
Mac/Linux:
213215
'Columns: id, base, end, entry, path'
214216
217+
DynamoRIO v7.0.17594B, table version 3:
218+
Windows:
219+
'Columns: id, containing_id, start, end, entry, checksum, timestamp, path'
220+
Mac/Linux:
221+
'Columns: id, containing_id, start, end, entry, path'
222+
223+
DynamoRIO v7.0.17640, table version 4:
224+
Windows:
225+
'Columns: id, containing_id, start, end, entry, offset, checksum, timestamp, path'
226+
Mac/Linux:
227+
'Columns: id, containing_id, start, end, entry, offset, path'
228+
215229
"""
216230

217231
# NOTE/COMPAT: there is no 'Columns' line for the v1 table...
@@ -308,10 +322,20 @@ def __init__(self, module_data, version):
308322
self.timestamp = 0
309323
self.path = ""
310324
self.filename = ""
325+
self.containing_id = 0
311326

312327
# parse the module
313328
self._parse_module(module_data, version)
314329

330+
@property
331+
def start(self):
332+
"""
333+
Compatability alias for the module base.
334+
335+
DrCov table version 2 --> 3 changed this paramter name base --> start.
336+
"""
337+
return self.base
338+
315339
def _parse_module(self, module_line, version):
316340
"""
317341
Parse a module table entry.
@@ -323,6 +347,10 @@ def _parse_module(self, module_line, version):
323347
self._parse_module_v1(data)
324348
elif version == 2:
325349
self._parse_module_v2(data)
350+
elif version == 3:
351+
self._parse_module_v3(data)
352+
elif version == 4:
353+
self._parse_module_v4(data)
326354
else:
327355
raise ValueError("Unknown module format (v%u)" % version)
328356

@@ -350,6 +378,39 @@ def _parse_module_v2(self, data):
350378
self.size = self.end-self.base
351379
self.filename = os.path.basename(self.path)
352380

381+
def _parse_module_v3(self, data):
382+
"""
383+
Parse a module table v3 entry.
384+
"""
385+
self.id = int(data[0])
386+
self.containing_id = int(data[1])
387+
self.base = int(data[2], 16)
388+
self.end = int(data[3], 16)
389+
self.entry = int(data[4], 16)
390+
if len(data) == 7: # Windows Only
391+
self.checksum = int(data[5], 16)
392+
self.timestamp = int(data[6], 16)
393+
self.path = str(data[-1])
394+
self.size = self.end-self.base
395+
self.filename = os.path.basename(self.path)
396+
397+
def _parse_module_v4(self, data):
398+
"""
399+
Parse a module table v4 entry.
400+
"""
401+
self.id = int(data[0])
402+
self.containing_id = int(data[1])
403+
self.base = int(data[2], 16)
404+
self.end = int(data[3], 16)
405+
self.entry = int(data[4], 16)
406+
self.offset = int(data[5], 16)
407+
if len(data) == 7: # Windows Only
408+
self.checksum = int(data[6], 16)
409+
self.timestamp = int(data[7], 16)
410+
self.path = str(data[-1])
411+
self.size = self.end-self.base
412+
self.filename = os.path.basename(self.path)
413+
353414
#------------------------------------------------------------------------------
354415
# drcov basic block parser
355416
#------------------------------------------------------------------------------

plugin/lighthouse_plugin.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
# IDA Plugin
2121
#------------------------------------------------------------------------------
2222

23-
PLUGIN_VERSION = "0.7.1"
23+
PLUGIN_VERSION = "0.7.2"
2424
AUTHORS = "Markus Gaasedelen"
2525
DATE = "2017"
2626

@@ -684,7 +684,8 @@ def _load_coverage_files(self, filenames):
684684
# catch all for parse errors / bad input / malformed files
685685
except Exception as e:
686686
lmsg("Failed to load coverage %s" % filename)
687-
logger.exception("Error details:")
687+
lmsg(" - Error: %s" % str(e))
688+
logger.exception(" - Traceback:")
688689
continue
689690

690691
# save the loaded coverage data to the output list

0 commit comments

Comments
 (0)