summaryrefslogtreecommitdiff
path: root/buildscripts/gdb
diff options
context:
space:
mode:
authorMathias Stearn <mathias@10gen.com>2017-03-10 11:57:13 -0500
committerMathias Stearn <mathias@10gen.com>2017-03-24 16:13:26 -0400
commit27ddad2221974798284ef62d3328a3c02a510220 (patch)
tree339c93da0dadcdc8cb34e28f762ea66363e64513 /buildscripts/gdb
parenta4ebe76b6d0c2b0a3d132da1536e29db92e00a08 (diff)
downloadmongo-27ddad2221974798284ef62d3328a3c02a510220.tar.gz
SERVER-27727 Hide idle threads in hang analyzer (core only)
Diffstat (limited to 'buildscripts/gdb')
-rw-r--r--buildscripts/gdb/mongo.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/buildscripts/gdb/mongo.py b/buildscripts/gdb/mongo.py
index f32d434f368..ee2227ea790 100644
--- a/buildscripts/gdb/mongo.py
+++ b/buildscripts/gdb/mongo.py
@@ -387,6 +387,25 @@ class MongoDBDumpLocks(gdb.Command):
# Register command
MongoDBDumpLocks()
+class BtIfActive(gdb.Command):
+ """Print stack trace or a short message if the current thread is idle"""
+
+ def __init__(self):
+ register_mongo_command(self, "mongodb-bt-if-active", gdb.COMMAND_DATA)
+
+ def invoke(self, arg, _from_tty):
+ try:
+ is_idle = gdb.parse_and_eval("mongo::for_debuggers::threadIsIdle")
+ except gdb.error:
+ is_idle = False # If unsure, print a stack trace.
+
+ if is_idle:
+ print("Thread is idle")
+ else:
+ gdb.execute("bt")
+
+# Register command
+BtIfActive()
class MongoDBUniqueStack(gdb.Command):
"""Print unique stack traces of all threads in current process"""