script to filter out idle threads from gdb thtrad backtrace output
authorVictor Kirhenshtein <victor@netxms.org>
Mon, 25 Jan 2016 17:05:44 +0000 (19:05 +0200)
committerVictor Kirhenshtein <victor@netxms.org>
Mon, 25 Jan 2016 17:05:44 +0000 (19:05 +0200)
tools/analyze_threads.pl [new file with mode: 0755]

diff --git a/tools/analyze_threads.pl b/tools/analyze_threads.pl
new file mode 100755 (executable)
index 0000000..9010170
--- /dev/null
@@ -0,0 +1,43 @@
+#!/usr/bin/perl
+
+@skipnames = ("Queue::getOrBlock", "ConditionWait", "poll", "select", "accept");
+
+my %skiplist;
+@skiplist{@skipnames} = ();
+
+@data = ();
+$ignore = 1;
+
+while(<STDIN>)
+{
+   chomp;
+   $line = $_;
+
+   if ($line =~ /^(Thread .*)/)
+   {
+      if ($ignore == 0)
+      {
+         for($i = 0; $i < $index; $i++)
+         {
+            print $data[$i] . "\n";
+         }
+      }
+      $ignore = 0;
+      @data = ();
+      $index = 0;
+      $func = "";
+   }
+   elsif ($line =~ /^#[0-9]+\s+[0-9a-fx]+\s+in\s+([^ ]+)\s.*/)
+   {
+      $func = $1;
+   }
+   elsif ($line =~ /^#[0-9]+\s+([^ ]+)\s.*/)
+   {
+      $func = $1;
+   }
+   $data[$index++] = $line;
+   if (exists $skiplist{$func})
+   {
+      $ignore = 1;
+   }
+}