def processStack()

in crashes.py [0:0]


def processStack(frames):
  # Normalized function names we can consider the same in calculating
  # unique reports. We replace the regex match with the key using sub.
  coelesceFrameDict = {
    'RtlUserThreadStart': '[_]+RtlUserThreadStart'
    }

  # Functions we can replace with the normalized version, filters
  # out odd platform parameter differences.
  coelesceFunctionList = [
    'thread_start<'
    ]

  dataStack = list() # [idx] = { 'frame': '(frame)', 'srcUrl': '(url)' }

  for frame in frames:
    frameIndex = '?'
    try:
      frameIndex = frame['frame'] # zero based frame index
    except KeyError:
      continue
    except TypeError:
      #print("TypeError while indexing frame.");
      continue

    dataStack.insert(frameIndex, { 'index': frameIndex, 'frame': '', 'srcUrl': '', 'module': '' })

    functionCall = ''
    module = 'unknown'
    offset = 'unknown'

    try:
      offset = frame['module_offset']
    except:
      pass
    try:
      module = frame['module']
    except:
      pass


    try:
      functionCall = frame['function']
    except KeyError:
      dataStack[frameIndex]['frame'] = offset
      dataStack[frameIndex]['module'] = module
      continue
    except TypeError:
      print("TypeError while indexing function.");
      dataStack[frameIndex]['frame'] = "(missing function)"
      continue

    for k, v in coelesceFrameDict.items():
      functionCall = re.sub(v, k, functionCall, 1)
      break

    for v in coelesceFunctionList:
      if re.search(v, functionCall) != None:
        normalizedFunction = functionCall
        try:
          normalizedFunction = frame['normalized']
        except KeyError:
          pass
        except TypeError:
          pass
        functionCall = normalizedFunction
        break

    srcUrl = generateSourceLink(frame)

    dataStack[frameIndex]['srcUrl'] = srcUrl
    dataStack[frameIndex]['frame'] = functionCall
    dataStack[frameIndex]['module'] = module

  return dataStack