Skip to content

Commit

Permalink
Bug 1464869 - Fix flake8/pep8 issue by hand in memory/ r=njn
Browse files Browse the repository at this point in the history
MozReview-Commit-ID: 8bkhAB4g6rv

--HG--
extra : rebase_source : 623f4ed95d601b47878c910859f3b91e87897011
  • Loading branch information
sylvestre committed May 26, 2018
1 parent 21f28e8 commit 3e84d30
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 22 deletions.
15 changes: 7 additions & 8 deletions memory/replace/dmd/block_analyzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,8 @@ def range_1_24(string):
help='maximum number of frames to consider in each trace')

parser.add_argument('-c', '--chain-reports', action='store_true',
help='if only one block is found to hold onto the object, report the next one, too')
help='if only one block is found to hold onto the object, report '
'the next one, too')


####
Expand Down Expand Up @@ -122,7 +123,7 @@ def print_trace_segment(args, stacks, block):

for l in traceTable[block.alloc_stack]:
# The 5: is to remove the bogus leading "#00: " from the stack frame.
print ' ', frameTable[l][5:args.max_stack_frame_length]
print(' ', frameTable[l][5:args.max_stack_frame_length])


def show_referrers(args, blocks, stacks, block):
Expand Down Expand Up @@ -171,7 +172,7 @@ def show_referrers(args, blocks, stacks, block):
break

if not anyFound:
print 'No referrers found.'
print('No referrers found.')


def show_block_info(args, blocks, stacks, block):
Expand Down Expand Up @@ -225,8 +226,6 @@ def loadGraph(options):
if j['version'] != outputVersion:
raise Exception("'version' property isn't '{:d}'".format(outputVersion))

invocation = j['invocation']

block_list = j['blockList']
blocks = {}

Expand All @@ -248,9 +247,9 @@ def analyzeLogs():

block = int(options.block, 16)

if not block in blocks:
print 'Object', block, 'not found in traces.'
print 'It could still be the target of some nodes.'
if block not in blocks:
print('Object', block, 'not found in traces.')
print('It could still be the target of some nodes.')
return

if options.info:
Expand Down
32 changes: 20 additions & 12 deletions memory/replace/dmd/dmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,17 @@
# we hit a non-matching frame, any subsequent frames won't be removed even if
# they do match.)
allocatorFns = [
# Matches malloc, replace_malloc, moz_xmalloc, vpx_malloc, js_malloc, pod_malloc, malloc_zone_*, g_malloc.
# Matches malloc, replace_malloc, moz_xmalloc, vpx_malloc, js_malloc,
# pod_malloc, malloc_zone_*, g_malloc.
'malloc',
# Matches calloc, replace_calloc, moz_xcalloc, vpx_calloc, js_calloc, pod_calloc, malloc_zone_calloc, pod_callocCanGC.
# Matches calloc, replace_calloc, moz_xcalloc, vpx_calloc, js_calloc,
# pod_calloc, malloc_zone_calloc, pod_callocCanGC.
'calloc',
# Matches realloc, replace_realloc, moz_xrealloc, vpx_realloc, js_realloc, pod_realloc, pod_reallocCanGC.
# Matches realloc, replace_realloc, moz_xrealloc, vpx_realloc, js_realloc,
# pod_realloc, pod_reallocCanGC.
'realloc',
# Matches memalign, posix_memalign, replace_memalign, replace_posix_memalign, moz_xmemalign, vpx_memalign, malloc_zone_memalign.
# Matches memalign, posix_memalign, replace_memalign, replace_posix_memalign,
# moz_xmemalign, vpx_memalign, malloc_zone_memalign.
'memalign',
'operator new(',
'operator new[](',
Expand Down Expand Up @@ -181,10 +185,12 @@ def range_1_24(string):
help='do not fix stacks')

p.add_argument('--clamp-contents', action='store_true',
help='for a scan mode log, clamp addresses to the start of live blocks, or zero if not in one')
help='for a scan mode log, clamp addresses to the start of live blocks, '
'or zero if not in one')

p.add_argument('--print-clamp-stats', action='store_true',
help='print information about the results of pointer clamping; mostly useful for debugging clamping')
help='print information about the results of pointer clamping; mostly '
'useful for debugging clamping')

p.add_argument('--filter-stacks-for-testing', action='store_true',
help='filter stack traces; only useful for testing purposes')
Expand Down Expand Up @@ -290,7 +296,7 @@ def getDigestFromFile(args, inputFile):
if mode == 'scan':
mode = 'live'

if not mode in ['live', 'dark-matter', 'cumulative']:
if mode not in ['live', 'dark-matter', 'cumulative']:
raise Exception("bad 'mode' property: '{:s}'".format(mode))

# Remove allocation functions at the start of traces.
Expand Down Expand Up @@ -426,7 +432,7 @@ def makeRecordKeyPart(traceKey):
record.reqSize += num * reqSize
record.slopSize += num * slopSize
record.usableSize += num * usableSize
if record.allocatedAtDesc == None:
if record.allocatedAtDesc is None:
record.allocatedAtDesc = \
buildTraceDescription(traceTable, frameTable,
allocatedAtTraceKey)
Expand Down Expand Up @@ -621,7 +627,7 @@ def abscmp((usableSize1, _1), (usableSize2, _2)): return \

def printInvocation(n, dmdEnvVar, mode):
out('Invocation{:} {{'.format(n))
if dmdEnvVar == None:
if dmdEnvVar is None:
out(' $DMD is undefined')
else:
out(' $DMD = \'' + dmdEnvVar + '\'')
Expand Down Expand Up @@ -778,10 +784,12 @@ def clampedNonBlockAddr(self):
def log(self):
sys.stderr.write('Results:\n')
sys.stderr.write(
' Number of pointers already pointing to start of blocks: ' + str(self.startBlockPtr) + '\n')
' Number of pointers already pointing to start of blocks: ' +
str(self.startBlockPtr) + '\n')
sys.stderr.write(' Number of pointers clamped to start of blocks: ' +
str(self.midBlockPtr) + '\n')
sys.stderr.write(' Number of non-null pointers not pointing into blocks clamped to null: ' +
sys.stderr.write(' Number of non-null pointers not pointing into blocks '
'clamped to null: ' +
str(self.nonNullNonBlockPtr) + '\n')
sys.stderr.write(' Number of null pointers: ' + str(self.nullPtr) + '\n')

Expand Down Expand Up @@ -844,7 +852,7 @@ def clampBlockList(args, inputFileName, isZipped, opener):

for block in blockList:
# Small blocks don't have any contents.
if not 'contents' in block:
if 'contents' not in block:
continue

cont = block['contents']
Expand Down
3 changes: 2 additions & 1 deletion memory/replace/dmd/test/scan-test.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ def parseCommandLine():
p = argparse.ArgumentParser(description=description)

p.add_argument('--clamp-contents', action='store_true',
help='expect that the contents of the JSON input file have had their addresses clamped')
help='expect that the contents of the JSON input file have had '
'their addresses clamped')

p.add_argument('input_file',
help='a file produced by DMD')
Expand Down
2 changes: 1 addition & 1 deletion memory/replace/logalloc/replay/logalloc_munge.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def split_log_line(line):
else:
tid = pid
return pid, tid, func, args, result
except:
except Exception:
raise Ignored('Malformed input')


Expand Down

0 comments on commit 3e84d30

Please sign in to comment.