summaryrefslogtreecommitdiffstats
path: root/build/linux/dump_signature.py
blob: 10bb2e068490d6a21444e9eb21f968a8323a12b6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/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)