Development: LLDB as Debugger

From a debugging session with @htriem - will be updated.

Requirements

Debug Session with LLDB

https://www.mortens.dev/blog/lldb-debugging-smart-pointers/

Sleep Patch after UnixWorker Fork

We need to use a hack here with sleeping as long as we need to attach to the child process. lldb doesn’t allow to follow child forks like gdb.~

This is now an upstream PR and future debug build constant.

1st terminal

Extract the child PID.

$ icinga2 daemon -DInternal.DebugWorkerDelay=120
Closed FD 6 which we inherited from our parent process.
[2020-01-24 13:52:30 +0100] information/cli: Icinga application loader (version: v2.11.0-473-g18eb06e33; debug)
[2020-01-24 13:52:30 +0100] information/RunWorker: DEBUG: Current PID: 86683. Sleeping for 120 seconds to allow lldb/gdb -p <PID> attachment.

2nd terminal

Attach to the child PID

$ lldb -p <PID>

Set break point and continue as often as SIGSTOP/SIGUSR occur.

(lldb) b icinga::Checkable::Start
(lldb) c

Generate Backtraces

(lldb) bt
(lldb) bt all

Print current object

(lldb) p *this
(icinga::Checkable) $2 = {
  icinga::ObjectImpl<icinga::Checkable> = {
    icinga::CustomVarObject = {
      icinga::ObjectImpl<icinga::CustomVarObject> = {
        icinga::ConfigObject = {
          icinga::ObjectImpl<icinga::ConfigObject> = {
            icinga::ConfigObjectBase = {
              icinga::ObjectImpl<icinga::ConfigObjectBase> = {
                icinga::Object = {
                  m_References = 12
                  m_Mutex = {
                    __m_ = (__sig = 1297437784, __opaque = "")
                  }
                  m_LockOwner = {
                    __id_ = 0x0000000119e97dc0
                  }
                  m_LockCount = 1
                }
              }
              m_DebugInfo = {
                Path = (m_Data = "/usr/local/icinga/icinga2/etc/icinga2/tests/flatten.conf")
                FirstLine = 4
                FirstColumn = 1
                LastLine = 4
                LastColumn = 23
              }
            }
            m_Package = (m_Data = "_etc")
            m_ZoneName = (m_Data = "")
            m_ShortName = (m_Data = "")
            m_Name = (m_Data = "db-host01")
            m_Version = 0
            m_Templates = {
              px = 0x00007fda6b53aa40
            }
            m_Extensions = {
              px = 0x0000000000000000
            }
            m_OriginalAttributes = {
              px = 0x0000000000000000
            }
            m_HAMode = HARunOnce
            m_StopCalled = false
            m_PauseCalled = false
            m_ResumeCalled = false
            m_StartCalled = false
            m_Paused = true
            m_StateLoaded = true
            m_Active = true
          }
          m_Zone = {
            px = 0x0000000000000000
          }
        }
        m_Vars = {
          px = 0x00007fda6b539d20
        }
      }
    }
    m_CheckTimeout = {
      m_Value = {
        which_ = 0
        storage_ = {
          boost::detail::aligned_storage::aligned_storage_imp<24, 8> = {
            data_ = (buf = "", align_ = boost::type_with_alignment<8>::type @ 0x00007fe8fcc7c330)
          }
        }
      }
    }
    m_EventCommandRaw = (m_Data = "")
    m_CommandEndpointRaw = (m_Data = "")
    m_CheckCommandRaw = (m_Data = "dummy")
    m_CheckPeriodRaw = (m_Data = "")
    m_IconImageAlt = (m_Data = "")
    m_IconImage = (m_Data = "")
    m_ActionUrl = (m_Data = "")
    m_NotesUrl = (m_Data = "")
    m_Notes = (m_Data = "")
    m_RetryInterval = 60
    m_FlappingThreshold = 0
    m_FlappingThresholdLow = 25
    m_FlappingCurrent = 0
    m_FlappingThresholdHigh = 30
    m_CheckInterval = 300
    m_LastCheckResult = {
      px = 0x00007fda6b1a3450
    }
    m_MaxCheckAttempts = 3
    m_CheckAttempt = 1
    m_AcknowledgementRaw = 0
    m_FlappingBuffer = 0
    m_FlappingIndex = 11
    m_SuppressedNotifications = 0
    m_LastHardStateRaw = ServiceOK
    m_LastStateRaw = ServiceOK
    m_StateRaw = ServiceOK
    m_LastStateType = StateTypeHard
    m_StateType = StateTypeHard
    m_LastHardStateChange = 1562917469.9047461
    m_LastStateChange = 1562917469.9047461
    m_LastStateUnreachable = 0
    m_PreviousStateChange = 1562917469.9047461
    m_AcknowledgementExpiry = 0
    m_AcknowledgementLastChange = 0
    m_NextCheck = 1579870641.3820481
    m_FlappingLastChange = 0
    m_Volatile = false
    m_ForceNextCheck = false
    m_Flapping = false
    m_EnableActiveChecks = true
    m_EnablePassiveChecks = true
    m_ForceNextNotification = false
    m_EnableEventHandler = true
    m_EnableNotifications = true
    m_LastReachable = true
    m_EnableFlapping = false
    m_EnablePerfdata = true
    m_LastHardStatesRaw = 9999
    m_LastSoftStatesRaw = 9999
  }
  m_CheckableMutex = {
    m = (__sig = 1297437786, __opaque = "")
  }
  m_CheckRunning = false
  m_SchedulingOffset = 726071835
  m_Downtimes = size=0 {}
  m_DowntimeMutex = {
    m = (__sig = 1297437786, __opaque = "")
  }
  m_Comments = size=0 {}
  m_CommentMutex = {
    m = (__sig = 1297437786, __opaque = "")
  }
  m_Notifications = size=0 {}
  m_NotificationMutex = {
    m = (__sig = 1297437786, __opaque = "")
  }
  m_DependencyMutex = {
    m = (__sig = 1297437786, __opaque = "")
  }
  m_Dependencies = size=0 {}
  m_ReverseDependencies = size=0 {}
}

Print address from known type

Print an address where you know the type:

(lldb) p *(icinga::CheckResult*)0x00007fda6b1a3450
(icinga::CheckResult) $6 = {
  icinga::ObjectImpl<icinga::CheckResult> = {
    icinga::Object = {
      m_References = 1
      m_Mutex = {
        __m_ = (__sig = 1297437784, __opaque = "")
      }
      m_LockOwner = {
        __id_ = 0x0000000000000000
      }
      m_LockCount = 0
    }
    m_Command = {
      m_Value = {
        which_ = 3
        storage_ = {
          boost::detail::aligned_storage::aligned_storage_imp<24, 8> = {
            data_ = (buf = "\ndummy", align_ = boost::type_with_alignment<8>::type @ 0x00007fe9002a8bd8)
          }
        }
      }
    }
    m_Output = (m_Data = "Check was successful.")
    m_CheckSource = (m_Data = "mbpmif.int.netways.de")
    m_Ttl = 0
    m_PerformanceData = {
      px = 0x00007fda6b1a4150
    }
    m_VarsAfter = {
      px = 0x00007fda6b1a42b0
    }
    m_VarsBefore = {
      px = 0x00007fda6b1a4450
    }
    m_ExitStatus = 0
    m_State = ServiceOK
    m_ScheduleStart = 1578586446.4211965
    m_ExecutionEnd = 1578586516.0508389
    m_ExecutionStart = 1578586516.0508389
    m_ScheduleEnd = 1578586516.0508571
    m_Active = true
  }
}


(lldb) p *(icinga::Dictionary*)0x00007fda6b1a4450
(icinga::Dictionary) $7 = {
  icinga::Object = {
    m_References = 1
    m_Mutex = {
      __m_ = (__sig = 1297437784, __opaque = "")
    }
    m_LockOwner = {
      __id_ = 0x0000000000000000
    }
    m_LockCount = 0
  }
  m_Data = size=4 {
    [0] = {
      first = (m_Data = "attempt")
      second = {
        m_Value = {
          which_ = 1
          storage_ = {
            boost::detail::aligned_storage::aligned_storage_imp<24, 8> = {
              data_ = (buf = char [24] @ 0x00007fe8fec60e50, align_ = boost::type_with_alignment<8>::type @ 0x00007fe8fec60e50)
            }
          }
        }
      }
    }
    [1] = {
      first = (m_Data = "reachable")
      second = {
        m_Value = {
          which_ = 2
          storage_ = {
            boost::detail::aligned_storage::aligned_storage_imp<24, 8> = {
              data_ = (buf = char [24] @ 0x00007fe8fd5eb8b0, align_ = boost::type_with_alignment<8>::type @ 0x00007fe8fd5eb8b0)
            }
          }
        }
      }
    }
    [2] = {
      first = (m_Data = "state")
      second = {
        m_Value = {
          which_ = 1
          storage_ = {
            boost::detail::aligned_storage::aligned_storage_imp<24, 8> = {
              data_ = (buf = char [24] @ 0x00007fe8fd5eb670, align_ = boost::type_with_alignment<8>::type @ 0x00007fe8fd5eb670)
            }
          }
        }
      }
    }
    [3] = {
      first = (m_Data = "state_type")
      second = {
        m_Value = {
          which_ = 1
          storage_ = {
            boost::detail::aligned_storage::aligned_storage_imp<24, 8> = {
              data_ = (buf = char [24] @ 0x00007fe8fec61260, align_ = boost::type_with_alignment<8>::type @ 0x00007fe8fec61260)
            }
          }
        }
      }
    }
  }
  m_Frozen = false
}
(lldb) p *(icinga::Array*)0x00007fda6b1a4150
(icinga::Array) $9 = {
  icinga::Object = {
    m_References = 1
    m_Mutex = {
      __m_ = (__sig = 1297437784, __opaque = "")
    }
    m_LockOwner = {
      __id_ = 0x0000000000000000
    }
    m_LockCount = 0
  }
  m_Data = size=0 {}
  m_Frozen = false
}

Stepping

(lldb) n
Process 86683 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = step over
    frame #0: 0x00000001069686ba icinga2`icinga::Checkable::Start(this=0x00007fda6a80ac00, runtimeCreated=false) at checkable.cpp:66:6
   63  	{
   64  		double now = Utility::GetTime();
   65
-> 66  		if (GetNextCheck() < now + 60) {
   67  			double delta = std::min(GetCheckInterval(), 60.0);
   68  			delta *= (double)std::rand() / RAND_MAX;
   69  			SetNextCheck(now + delta);
Target 0: (icinga2) stopped.
(lldb)
Process 86683 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = step over
    frame #0: 0x00000001069686da icinga2`icinga::Checkable::Start(this=0x00007fda6a80ac00, runtimeCreated=false) at checkable.cpp:67:27
   64  		double now = Utility::GetTime();
   65
   66  		if (GetNextCheck() < now + 60) {
-> 67  			double delta = std::min(GetCheckInterval(), 60.0);
   68  			delta *= (double)std::rand() / RAND_MAX;
   69  			SetNextCheck(now + delta);
   70  		}
Target 0: (icinga2) stopped.
(lldb)
Process 86683 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = step over
    frame #0: 0x000000010696870a icinga2`icinga::Checkable::Start(this=0x00007fda6a80ac00, runtimeCreated=false) at checkable.cpp:68:20
   65
   66  		if (GetNextCheck() < now + 60) {
   67  			double delta = std::min(GetCheckInterval(), 60.0);
-> 68  			delta *= (double)std::rand() / RAND_MAX;
   69  			SetNextCheck(now + delta);
   70  		}
   71
Target 0: (icinga2) stopped.
(lldb) p delta
(double) $16 = 60
(lldb) n
Process 86683 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = step over
    frame #0: 0x0000000106968736 icinga2`icinga::Checkable::Start(this=0x00007fda6a80ac00, runtimeCreated=false) at checkable.cpp:69:16
   66  		if (GetNextCheck() < now + 60) {
   67  			double delta = std::min(GetCheckInterval(), 60.0);
   68  			delta *= (double)std::rand() / RAND_MAX;
-> 69  			SetNextCheck(now + delta);
   70  		}
   71
   72  		ObjectImpl<Checkable>::Start(runtimeCreated);
Target 0: (icinga2) stopped.

Step into function call

(lldb) s
Process 86683 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = step in
    frame #0: 0x000000010695dbff icinga2`icinga::ObjectImpl<icinga::Checkable>::SetNextCheck(this=0x00007fda6a80ac00, value=0x00007ffee9df7ad8, suppress_events=false, cookie=0x00000001079743b0) at checkable-ti.cpp:2195:16
   2192
   2193	void ObjectImpl<Checkable>::SetNextCheck(const Timestamp& value, bool suppress_events, const Value& cookie)
   2194	{
-> 2195		m_NextCheck = value;
   2196		if (!suppress_events)
   2197			NotifyNextCheck(cookie);
   2198	}
Target 0: (icinga2) stopped.
(lldb) [2020-01-24 14:12:30 +0100] information/WorkQueue: #8 (IdoMysqlConnection, ido-mysql) items: 0, rate:  0/s (0/min 0/5min 0/15min);
[2020-01-24 14:12:30 +0100] information/WorkQueue: #7 (ApiListener, SyncQueue) items: 0, rate:  0/s (0/min 0/5min 0/15min);
[2020-01-24 14:12:30 +0100] information/WorkQueue: #5 (IcingaDB) items: 0, rate:  0/s (0/min 0/5min 0/15min);
[2020-01-24 14:12:30 +0100] information/WorkQueue: #6 (ApiListener, RelayQueue) items: 0, rate:  0/s (0/min 0/5min 0/15min);

Process 86683 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = step in
    frame #0: 0x000000010695dc0f icinga2`icinga::ObjectImpl<icinga::Checkable>::SetNextCheck(this=0x00007fda6a80ac00, value=0x00007ffee9df7ad8, suppress_events=false, cookie=0x00000001079743b0) at checkable-ti.cpp:2196:6
   2193	void ObjectImpl<Checkable>::SetNextCheck(const Timestamp& value, bool suppress_events, const Value& cookie)
   2194	{
   2195		m_NextCheck = value;
-> 2196		if (!suppress_events)
   2197			NotifyNextCheck(cookie);
   2198	}
   2199
Target 0: (icinga2) stopped.
(lldb) n
Process 86683 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = step over
    frame #0: 0x000000010695dc1d icinga2`icinga::ObjectImpl<icinga::Checkable>::SetNextCheck(this=0x00007fda6a80ac00, value=0x00007ffee9df7ad8, suppress_events=false, cookie=0x00000001079743b0) at checkable-ti.cpp:2197:19
   2194	{
   2195		m_NextCheck = value;
   2196		if (!suppress_events)
-> 2197			NotifyNextCheck(cookie);
   2198	}
   2199
   2200	void ObjectImpl<Checkable>::SetLastCheck(const Timestamp& value, bool suppress_events, const Value& cookie)
Target 0: (icinga2) stopped.
(lldb) s
Process 86683 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = step in
    frame #0: 0x0000000106966074 icinga2`icinga::ObjectImpl<icinga::Checkable>::NotifyNextCheck(this=0x00007fda6a80ac00, cookie=0x00000001079743b0) at checkable-ti.cpp:2663:15
   2660
   2661	void ObjectImpl<Checkable>::NotifyNextCheck(const Value& cookie)
   2662	{
-> 2663		auto *dobj = dynamic_cast<ConfigObject *>(this);
   2664		if (!dobj || dobj->IsActive())
   2665			OnNextCheckChanged(static_cast<Checkable *>(this), cookie);
   2666	}
Target 0: (icinga2) stopped.
(lldb) n
Process 86683 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = step over
    frame #0: 0x000000010696607b icinga2`icinga::ObjectImpl<icinga::Checkable>::NotifyNextCheck(this=0x00007fda6a80ac00, cookie=0x00000001079743b0) at checkable-ti.cpp:2664:7
   2661	void ObjectImpl<Checkable>::NotifyNextCheck(const Value& cookie)
   2662	{
   2663		auto *dobj = dynamic_cast<ConfigObject *>(this);
-> 2664		if (!dobj || dobj->IsActive())
   2665			OnNextCheckChanged(static_cast<Checkable *>(this), cookie);
   2666	}
   2667
Target 0: (icinga2) stopped.

Print current object

(lldb) p dobj
(icinga::Host *) $17 = 0x00007fda6a80ac00
(lldb) p *(icinga::Host *)0x00007fda6a80ac00
(icinga::Host) $18 = {
  icinga::ObjectImpl<icinga::Host> = {
    icinga::Checkable = {
      icinga::ObjectImpl<icinga::Checkable> = {
        icinga::CustomVarObject = {
          icinga::ObjectImpl<icinga::CustomVarObject> = {
            icinga::ConfigObject = {
              icinga::ObjectImpl<icinga::ConfigObject> = {
                icinga::ConfigObjectBase = {
                  icinga::ObjectImpl<icinga::ConfigObjectBase> = {
                    icinga::Object = {
                      m_References = 12
                      m_Mutex = {
                        __m_ = (__sig = 1297437784, __opaque = "")
                      }
                      m_LockOwner = {
                        __id_ = 0x0000000119e97dc0
                      }
                      m_LockCount = 1
                    }
                  }
                  m_DebugInfo = {
                    Path = (m_Data = "/usr/local/icinga/icinga2/etc/icinga2/tests/flatten.conf")
                    FirstLine = 4
                    FirstColumn = 1
                    LastLine = 4
                    LastColumn = 23
                  }
                }
                m_Package = (m_Data = "_etc")
                m_ZoneName = (m_Data = "")
                m_ShortName = (m_Data = "")
                m_Name = (m_Data = "db-host01")
                m_Version = 0
                m_Templates = {
                  px = 0x00007fda6b53aa40
                }
                m_Extensions = {
                  px = 0x0000000000000000
                }
                m_OriginalAttributes = {
                  px = 0x0000000000000000
                }
                m_HAMode = HARunOnce
                m_StopCalled = false
                m_PauseCalled = false
                m_ResumeCalled = false
                m_StartCalled = false
                m_Paused = true
                m_StateLoaded = true
                m_Active = true
              }
              m_Zone = {
                px = 0x0000000000000000
              }
            }
            m_Vars = {
              px = 0x00007fda6b539d20
            }
          }
        }
        m_CheckTimeout = {
          m_Value = {
            which_ = 0
            storage_ = {
              boost::detail::aligned_storage::aligned_storage_imp<24, 8> = {
                data_ = (buf = "", align_ = boost::type_with_alignment<8>::type @ 0x00007fe8fe6bb930)
              }
            }
          }
        }
        m_EventCommandRaw = (m_Data = "")
        m_CommandEndpointRaw = (m_Data = "")
        m_CheckCommandRaw = (m_Data = "dummy")
        m_CheckPeriodRaw = (m_Data = "")
        m_IconImageAlt = (m_Data = "")
        m_IconImage = (m_Data = "")
        m_ActionUrl = (m_Data = "")
        m_NotesUrl = (m_Data = "")
        m_Notes = (m_Data = "")
        m_RetryInterval = 60
        m_FlappingThreshold = 0
        m_FlappingThresholdLow = 25
        m_FlappingCurrent = 0
        m_FlappingThresholdHigh = 30
        m_CheckInterval = 300
        m_LastCheckResult = {
          px = 0x00007fda6b1a3450
        }
        m_MaxCheckAttempts = 3
        m_CheckAttempt = 1
        m_AcknowledgementRaw = 0
        m_FlappingBuffer = 0
        m_FlappingIndex = 11
        m_SuppressedNotifications = 0
        m_LastHardStateRaw = ServiceOK
        m_LastStateRaw = ServiceOK
        m_StateRaw = ServiceOK
        m_LastStateType = StateTypeHard
        m_StateType = StateTypeHard
        m_LastHardStateChange = 1562917469.9047461
        m_LastStateChange = 1562917469.9047461
        m_LastStateUnreachable = 0
        m_PreviousStateChange = 1562917469.9047461
        m_AcknowledgementExpiry = 0
        m_AcknowledgementLastChange = 0
        m_NextCheck = 1579871494.0104492
        m_FlappingLastChange = 0
        m_Volatile = false
        m_ForceNextCheck = false
        m_Flapping = false
        m_EnableActiveChecks = true
        m_EnablePassiveChecks = true
        m_ForceNextNotification = false
        m_EnableEventHandler = true
        m_EnableNotifications = true
        m_LastReachable = true
        m_EnableFlapping = false
        m_EnablePerfdata = true
        m_LastHardStatesRaw = 9999
        m_LastSoftStatesRaw = 9999
      }
      m_CheckableMutex = {
        m = (__sig = 1297437786, __opaque = "")
      }
      m_CheckRunning = false
      m_SchedulingOffset = 726071835
      m_Downtimes = size=0 {}
      m_DowntimeMutex = {
        m = (__sig = 1297437786, __opaque = "")
      }
      m_Comments = size=0 {}
      m_CommentMutex = {
        m = (__sig = 1297437786, __opaque = "")
      }
      m_Notifications = size=0 {}
      m_NotificationMutex = {
        m = (__sig = 1297437786, __opaque = "")
      }
      m_DependencyMutex = {
        m = (__sig = 1297437786, __opaque = "")
      }
      m_Dependencies = size=0 {}
      m_ReverseDependencies = size=0 {}
    }
    m_DisplayName = (m_Data = "")
    m_Address = (m_Data = "")
    m_Address6 = (m_Data = "")
    m_Groups = {
      px = 0x00007fda6b53a400
    }
    m_LastStateUp = 1578586516.050884
    m_LastStateDown = 0
  }
  m_ServicesMutex = {
    m = (__sig = 1297437786, __opaque = "")
  }
  m_Services = size=4 {
    [0] = {
      first = (m_Data = "mysql-production-app1")
      second = {
        px = 0x00007fda6a817a00
      }
    }
    [1] = {
      first = (m_Data = "mysql-production-app2")
      second = {
        px = 0x00007fda6d00be00
      }
    }
    [2] = {
      first = (m_Data = "mysql-staging-app1")
      second = {
        px = 0x00007fda6c012400
      }
    }
    [3] = {
      first = (m_Data = "mysql-staging-app2")
      second = {
        px = 0x00007fda6c808200
      }
    }
  }
}

Catch Exceptions

(lldb) b __cxa_throw
Breakpoint 2: 2 locations.

* thread #33, stop reason = breakpoint 2.1
    frame #0: 0x0000000105fe16c7 icinga2`::__cxa_throw(obj=0x00007fda6b784480, pvtinfo=0x00000001078fc280, dest=(icinga2`boost::system::system_error::~system_error() at system_error.hpp:47))(void *)) at exception.cpp:95:46
   92  	extern "C"
   93  	void __cxa_throw(void *obj, TYPEINFO_TYPE *pvtinfo, void (*dest)(void *))
   94  	{
-> 95  		auto *tinfo = static_cast<std::type_info *>(pvtinfo);
   96
   97  		typedef void (*cxa_throw_fn)(void *, std::type_info *, void (*)(void *)) __attribute__((noreturn));
   98  		static cxa_throw_fn real_cxa_throw;
Target 0: (icinga2) stopped.
(lldb) [2020-01-24 14:22:31 +0100] information/WorkQueue: #6 (ApiListener, RelayQueue) items: 0, rate:  0/s (0/min 0/5min 0/15min);
[2020-01-24 14:22:31 +0100] information/WorkQueue: #8 (IdoMysqlConnection, ido-mysql) items: 0, rate:  0/s (0/min 0/5min 0/15min);
[2020-01-24 14:22:31 +0100] information/WorkQueue: #5 (IcingaDB) items: 0, rate:  0/s (0/min 0/5min 0/15min);
[2020-01-24 14:22:31 +0100] information/WorkQueue: #7 (ApiListener, SyncQueue) items: 0, rate:  0/s (0/min 0/5min 0/15min);
up
frame #1: 0x0000000106047a77 icinga2`boost::asio::detail::coro_async_result<boost::asio::executor_binder<void (*)(), boost::asio::executor>, void>::get(this=0x0000000113c80280) at spawn.hpp:212:28
   209
   210 	      if (--ready_ != 0)
   211 	        ca_();
-> 212 	      if (!out_ec_ && ec_) throw boost::system::system_error(ec_);
   213 	    }
   214
   215 	  private:
(lldb)
frame #2: 0x00000001064809bb icinga2`std::__1::enable_if<!(detail::async_result_has_initiate_memfn<boost::asio::basic_yield_context<boost::asio::executor_binder<void (*)(), boost::asio::executor> >&, void (boost::system::error_code)>::value), boost::asio::async_result<std::__1::decay<boost::asio::basic_yield_context<boost::asio::executor_binder<void (*)(), boost::asio::executor> >&>::type, void (boost::system::error_code)>::return_type>::type boost::asio::async_initiate<boost::asio::basic_yield_context<boost::asio::executor_binder<void (initiation=0x0000000113c802f8, token=0x0000000113c809f0, args=0x0000000113c803d0, args=0x0000000113c80318)(), boost::asio::executor> >&, void (boost::system::error_code), boost::asio::basic_socket<boost::asio::ip::tcp, boost::asio::executor>::initiate_async_connect, boost::asio::ip::basic_endpoint<boost::asio::ip::tcp> const&, boost::system::error_code&>(boost::asio::basic_socket<boost::asio::ip::tcp, boost::asio::executor>::initiate_async_connect&&, boost::asio::basic_yield_context<boost::asio::executor_binder<void (*)(), boost::asio::executor> >&, boost::asio::ip::basic_endpoint<boost::asio::ip::tcp> const&, boost::system::error_code&) at async_result.hpp:386:28
   383 	        Signature))(completion.completion_handler),
   384 	      BOOST_ASIO_MOVE_CAST(Args)(args)...);
   385
-> 386 	  return completion.result.get();
   387 	}
   388
   389 	#else // defined(BOOST_ASIO_HAS_VARIADIC_TEMPLATES)
(lldb)
frame #3: 0x000000010647e1d6 icinga2`boost::asio::async_result<std::__1::decay<boost::asio::basic_yield_context<boost::asio::executor_binder<void (*)(), boost::asio::executor> >&>::type, void (boost::system::error_code)>::return_type boost::asio::basic_socket<boost::asio::ip::tcp, boost::asio::executor>::async_connect<boost::asio::basic_yield_context<boost::asio::executor_binder<void (this=0x00007fda6b75fe08, peer_endpoint=0x0000000113c803d0, handler=0x0000000113c809f0)(), boost::asio::executor> >&>(boost::asio::ip::basic_endpoint<boost::asio::ip::tcp> const&, boost::asio::basic_yield_context<boost::asio::executor_binder<void (*)(), boost::asio::executor> >&) at basic_socket.hpp:959:12
   956 	      impl_.get_service().open(impl_.get_implementation(), protocol, open_ec);
   957 	    }
   958
-> 959 	    return async_initiate<ConnectHandler, void (boost::system::error_code)>(
   960 	        initiate_async_connect(this), handler, peer_endpoint, open_ec);
   961 	  }
   962
(lldb)
frame #4: 0x000000010769a847 icinga2`void icinga::Connect<boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::executor> >(socket=0x00007fda6b75fe08, node=0x00007fda6b49de78, service=0x0000000113c80a20, yc=boost::asio::yield_context @ 0x0000000113c809f0)(), boost::asio::executor> >) at tcpsocket.hpp:79:11
   76  			try {
   77  				socket.open(current->endpoint().protocol());
   78  				socket.set_option(tcp::socket::keep_alive(true));
-> 79  				socket.async_connect(current->endpoint(), yc);
   80
   81  				break;
   82  			} catch (const std::exception&) {
(lldb)
frame #5: 0x0000000107699f4e icinga2`icinga::RedisConnection::Connect(this=0x00007fda6b49de00, yc=0x0000000113c80d48)(), boost::asio::executor> >&) at redisconnection.cpp:221:5
   218 						<< "Trying to connect to Redis server (async) on host '" << m_Host << ":" << m_Port << "'";
   219
   220 					auto conn (Shared<TcpConn>::Make(m_Strand.context()));
-> 221 					icinga::Connect(conn->next_layer(), m_Host, Convert::ToString(m_Port), yc);
   222 					m_TcpConn = std::move(conn);
   223 				} else {
   224 					Log(LogInformation, "IcingaDB")

3 Likes

Made the delay hack an official dev feature in debug builds.