#!/usr/bin/python2.4
#
# Copyright (c) 2009 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
#
# This generates symbol signatures with the same algorithm as
# src/breakpad/linux/minidump_writer.cc@17081

import sys
import struct

if len(sys.argv) != 2:
  sys.stderr.write("Error, no filename specified.\n")
  sys.exit(1)

bin = open(sys.argv[1])
data = bin.read(4096)
if len(data) != 4096:
  sys.stderr.write("Error, did not read first page of data.\n");
  sys.exit(1)
bin.close()

signature = [0] * 16
for i in range(0, 4096):
  signature[i % 16] ^= ord(data[i])

out = ('%08x%04x%04x%02x%02x%02x%02x%02x%02x%02x%02x0' %
      struct.unpack('I2H8B', struct.pack('16B', *signature)))
sys.stdout.write(out)

@@ -654,16 +654,86 @@
 ta%5Bi%5D)%0A%0A
+# Append a 0 at the end for the generation number (always 0 on Linux)%0A
 out = ('
@@ -739,49 +739,49 @@
 '%2508
-x%2504x%2504x%2502x%2502x%2502x%2502x%2502x%2502x%2502x%2502x
+X%2504X%2504X%2502X%2502X%2502X%2502X%2502X%2502X%2502X%2502X
 0' %25

Make symbol signatures upper-case. Review URL: http://codereview.chromium.org/132034