From 34b30d9b7f18a6e8a407d1ee3ef9b76355b21a7e Mon Sep 17 00:00:00 2001 From: batrick Date: Thu, 20 Aug 2009 00:36:49 +0000 Subject: [PATCH] [NSE] Patch to nse_main.lua to print out all active scripts (running & waiting) at debugging level 2 or higher and when a key is pressed. This is especially useful when we have a rare deadlock and we want to know which scripts are involved and where (a traceback is also printed). --- nse_main.lua | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/nse_main.lua b/nse_main.lua index eef80d8d4..6d3d1334a 100644 --- a/nse_main.lua +++ b/nse_main.lua @@ -544,6 +544,16 @@ local function run (threads) print_verbose(1, "Active NSE Script Threads: %d (%d waiting)\n", nr+nw, nw); progress("printStats", 1-(nr+nw)/total); + if debugging() >= 2 then + for co, thread in pairs(running) do + thread:d("Running: %THREAD\n\t%s", + (gsub(traceback(co), "\n", "\n\t"))); + end + for co, thread in pairs(waiting) do + thread:d("Waiting: %THREAD\n\t%s", + (gsub(traceback(co), "\n", "\n\t"))); + end + end elseif progress "mayBePrinted" then if verbosity() > 1 or debugging() > 0 then progress("printStats", 1-(nr+nw)/total);