From a390e15cd57303482b845fc91787beb3a3373916 Mon Sep 17 00:00:00 2001
From: clc5q <clc5q@git.zephyr-software.com>
Date: Wed, 26 Aug 2015 01:28:27 +0000
Subject: [PATCH] Add delay loop for attaching gdb.

Former-commit-id: 173108a18f542a40fa9bcff060c5d493eda93a8b
---
 src/drivers/irdb/stars_driver.cpp | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)

diff --git a/src/drivers/irdb/stars_driver.cpp b/src/drivers/irdb/stars_driver.cpp
index 7030d597..cae2aa9b 100644
--- a/src/drivers/irdb/stars_driver.cpp
+++ b/src/drivers/irdb/stars_driver.cpp
@@ -1,3 +1,5 @@
+#include <ctime>
+
 #include <stdlib.h>
 #include <fstream>
 #include <libIRDB-core.hpp>
@@ -8,6 +10,8 @@ using namespace libIRDB;
 
 #include "stars_irdb.hpp"
 
+#define SMP_DEBUG_DELAY 0   // for setting an early breakpoint
+
 
 void usage(char* name)
 {
@@ -22,7 +26,20 @@ int main(int argc, char **argv)
                 exit(1);
         }
 
-        string programName(argv[0]);
+		// For debugging, we can add a delay loop so we have time to attach gdb to the
+		// running process and set a breakpoint.
+#if SMP_DEBUG_DELAY
+		time_t start;
+		time_t current;
+
+		time(&start);
+		cerr << "delay for 15 seconds." << endl;
+		do {
+			time(&current);
+		} while (difftime(current, start) < 15.0);
+#endif
+		
+		string programName(argv[0]);
         int variantID = atoi(argv[1]);
 
         VariantID_t *pidp=NULL;
-- 
GitLab