summaryrefslogtreecommitdiff
path: root/buildscripts/mongosymb_multithread.py
diff options
context:
space:
mode:
authorBilly Donahue <billy.donahue@mongodb.com>2020-01-15 17:48:54 -0500
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2020-01-30 17:42:02 +0000
commitbc68d8424d15a9f3eeab35730b0043459e289ad9 (patch)
treea1b2883cb3f807c8256cd846a64d59d838b5c3ad /buildscripts/mongosymb_multithread.py
parenta6d3529b264b8b2331faea6a0e645fcf9def8f7f (diff)
downloadmongo-bc68d8424d15a9f3eeab35730b0043459e289ad9.tar.gz
SERVER-45587 SIGUSR2 one thread per log line
- add mongosymb_multithread.py - mongosymb.py argparse and slight refactor for reuse. create mode 100755 buildscripts/mongosymb_multithread.py
Diffstat (limited to 'buildscripts/mongosymb_multithread.py')
-rwxr-xr-xbuildscripts/mongosymb_multithread.py66
1 files changed, 66 insertions, 0 deletions
diff --git a/buildscripts/mongosymb_multithread.py b/buildscripts/mongosymb_multithread.py
new file mode 100755
index 00000000000..adff70a1623
--- /dev/null
+++ b/buildscripts/mongosymb_multithread.py
@@ -0,0 +1,66 @@
+#!/usr/bin/env python3
+"""Script for symbolizing multithread MongoDB stack traces.
+
+Accepts mongod multithread stacktrace lines. These are produced by hitting mongod with SIGUSR2.
+Assembles json documents which are fed to the mongosymb library. See mongosymb.py.
+"""
+
+import argparse
+import json
+import re
+import subprocess
+import sys
+import mongosymb
+
+
+def main():
+ """Execute Main program."""
+
+ parent_parser = mongosymb.make_argument_parser(add_help=False)
+ parser = argparse.ArgumentParser(parents=[parent_parser], description=__doc__, add_help=True)
+ options = parser.parse_args()
+
+ # Remember the prologue between lines,
+ # Prologue defines the library ids referred to by each threadRecord line.
+ prologue = None
+
+ for line in sys.stdin:
+ try:
+ doc = json.JSONDecoder().raw_decode(line)[0]
+ if "attr" not in doc:
+ continue
+ attr = doc["attr"]
+
+ if "prologue" in attr:
+ prologue = attr["prologue"]
+
+ if "threadRecord" in attr:
+ thread_record = attr["threadRecord"]
+ merged = {**thread_record, **prologue}
+
+ output_fn = None
+ if options.output_format == 'json':
+ output_fn = json.dump
+ if options.output_format == 'classic':
+ output_fn = mongosymb.classic_output
+
+ resolver = None
+ if options.debug_file_resolver == 'path':
+ resolver = mongosymb.PathDbgFileResolver(options.path_to_executable)
+ elif options.debug_file_resolver == 's3':
+ resolver = mongosymb.S3BuildidDbgFileResolver(options.s3_cache_dir,
+ options.s3_bucket)
+
+ frames = mongosymb.symbolize_frames(merged, resolver, **vars(options))
+ print("\nthread {{name='{}', tid={}}}:".format(thread_record["name"],
+ thread_record["tid"]))
+
+ output_fn(frames, sys.stdout, indent=2)
+
+ except json.JSONDecodeError:
+ print("failed to parse line: `{}`".format(line), file=sys.stderr)
+
+
+if __name__ == '__main__':
+ main()
+ sys.exit(0)