Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(6389)

Unified Diff: components/crash/tools/dmp2minidump.py

Issue 1351923002: Revert of Turn components/crash into a layered component. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/crash/tools/crash_service.cc ('k') | components/crash/tools/generate_breakpad_symbols.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/crash/tools/dmp2minidump.py
diff --git a/components/crash/tools/dmp2minidump.py b/components/crash/tools/dmp2minidump.py
new file mode 100755
index 0000000000000000000000000000000000000000..7823d483681aeaf74dda9814389556f8cacb6c2a
--- /dev/null
+++ b/components/crash/tools/dmp2minidump.py
@@ -0,0 +1,51 @@
+#!/usr/bin/env python
+# Copyright 2013 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.
+
+"""A tool to extract minidumps from dmp crash dumps."""
+
+import os
+import sys
+from cgi import parse_multipart
+
+
+def ProcessDump(dump_file, minidump_file):
+ """Extracts the part of the dump file that minidump_stackwalk can read.
+
+ The dump files generated by the breakpad integration multi-part form data
+ that include the minidump as file attachment.
+
+ Args:
+ dump_file: the dump file that needs to be processed.
+ minidump_file: the file to write the minidump to.
+ """
+ try:
+ dump = open(dump_file, 'rb')
+ boundary = dump.readline().strip()[2:]
+ data = parse_multipart(dump, {'boundary': boundary})
+ except:
+ print 'Failed to read dmp file %s' % dump_file
+ return
+
+ if not 'upload_file_minidump' in data:
+ print 'Could not find minidump file in dump.'
+ return
+
+ f = open(minidump_file, 'w')
+ f.write("\r\n".join(data['upload_file_minidump']))
+ f.close()
+
+
+def main():
+ if len(sys.argv) != 3:
+ print 'Usage: %s [dmp file] [minidump]' % sys.argv[0]
+ print ''
+ print 'Extracts the minidump stored in the crash dump file'
+ return 1
+
+ ProcessDump(sys.argv[1], sys.argv[2])
+
+
+if '__main__' == __name__:
+ sys.exit(main())
« no previous file with comments | « components/crash/tools/crash_service.cc ('k') | components/crash/tools/generate_breakpad_symbols.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698