@@ -2526,8 +2526,14 @@ namespace TTD
25262526
25272527 void EventLog::InnerLoopEmitLog (const TTDebuggerSourceLocation& writeLocation, const char * emitUri, size_t emitUriLength)
25282528 {
2529- NSLogEvents::TTDInnerLoopLogWriteEventLogEntry* evt = nullptr ;
2530- this ->RecordGetInitializedEvent <NSLogEvents::TTDInnerLoopLogWriteEventLogEntry, NSLogEvents::EventKind::TTDInnerLoopLogWriteTag>(&evt);
2529+ // Events are slab allocated with header immediately followed by payload -- we need to replicate this layout here so we allocate an array and explicitly layout.
2530+ // See definition of GetNextAvailableEntry and GetInlineEventDataAs for more detail.
2531+ byte buff[TTD_EVENT_PLUS_DATA_SIZE (NSLogEvents::TTDInnerLoopLogWriteEventLogEntry)];
2532+
2533+ NSLogEvents::EventLogEntry* entry = reinterpret_cast <NSLogEvents::EventLogEntry*>(buff);
2534+ NSLogEvents::EventLogEntry_Initialize<NSLogEvents::EventKind::TTDInnerLoopLogWriteTag>(entry, this ->m_eventTimeCtr );
2535+
2536+ NSLogEvents::TTDInnerLoopLogWriteEventLogEntry* evt = NSLogEvents::GetInlineEventDataAs<NSLogEvents::TTDInnerLoopLogWriteEventLogEntry, NSLogEvents::EventKind::TTDInnerLoopLogWriteTag>(entry);
25312537
25322538 evt->SourceScriptLogId = writeLocation.GetScriptLogTagId ();
25332539 evt->EventTime = writeLocation.GetRootEventTime ();
@@ -2541,10 +2547,23 @@ namespace TTD
25412547 evt->Line = writeLocation.GetSourceLine ();
25422548 evt->Column = writeLocation.GetSourceColumn ();
25432549
2544- this ->EmitLog (emitUri, emitUriLength);
2550+ this ->EmitLog (emitUri, emitUriLength, entry );
25452551 }
25462552
2547- void EventLog::EmitLog (const char * emitUri, size_t emitUriLength)
2553+ bool EventLog::CanWriteInnerLoopTrace () const
2554+ {
2555+ bool isInnerLoop = (this ->m_currentMode & (TTDMode::RecordDebuggerMode)) == TTDMode::RecordDebuggerMode;
2556+ bool isEnabled = (this ->m_currentMode & (TTDMode::CurrentlyEnabled)) == TTDMode::CurrentlyEnabled;
2557+
2558+ return isInnerLoop & isEnabled;
2559+ }
2560+
2561+ bool EventLog::SuppressDiagnosticTracesDuringInnerLoop () const
2562+ {
2563+ return (this ->m_currentMode & (TTDMode::DebuggerAttachedMode)) == TTDMode::DebuggerAttachedMode;
2564+ }
2565+
2566+ void EventLog::EmitLog (const char * emitUri, size_t emitUriLength, NSLogEvents::EventLogEntry* optInnerLoopEvent)
25482567 {
25492568#if ENABLE_BASIC_TRACE || ENABLE_FULL_BC_TRACE
25502569 this ->m_threadContext ->TTDExecutionInfo ->GetTraceLogger ()->ForceFlush ();
@@ -2604,7 +2623,7 @@ namespace TTD
26042623 writer.WriteUInt64 (NSTokens::Key::usedMemory, usedSpace, NSTokens::Separator::CommaSeparator);
26052624 writer.WriteUInt64 (NSTokens::Key::reservedMemory, reservedSpace, NSTokens::Separator::CommaSeparator);
26062625
2607- uint32 ecount = this ->m_eventList .Count ();
2626+ uint32 ecount = this ->m_eventList .Count () + (optInnerLoopEvent != nullptr ? 1 : 0 ) ;
26082627 writer.WriteLengthValue (ecount, NSTokens::Separator::CommaAndBigSpaceSeparator);
26092628
26102629#if ENABLE_TTD_INTERNAL_DIAGNOSTICS
@@ -2677,6 +2696,13 @@ namespace TTD
26772696 }
26782697#endif
26792698 }
2699+
2700+ if (optInnerLoopEvent != nullptr )
2701+ {
2702+ // Emit the special event that indicates we want to break at the end of the log (with a known breakpoint time)
2703+ NSLogEvents::EventLogEntry_Emit (optInnerLoopEvent, this ->m_eventListVTable, &writer, this ->m_threadContext, NSTokens::Separator::BigSpaceSeparator);
2704+ }
2705+
26802706 writer.AdjustIndent (-1 );
26812707 writer.WriteSequenceEnd (NSTokens::Separator::BigSpaceSeparator);
26822708
0 commit comments