@@ -2526,8 +2526,14 @@ namespace TTD
2526
2526
2527
2527
void EventLog::InnerLoopEmitLog (const TTDebuggerSourceLocation& writeLocation, const char * emitUri, size_t emitUriLength)
2528
2528
{
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);
2531
2537
2532
2538
evt->SourceScriptLogId = writeLocation.GetScriptLogTagId ();
2533
2539
evt->EventTime = writeLocation.GetRootEventTime ();
@@ -2541,10 +2547,23 @@ namespace TTD
2541
2547
evt->Line = writeLocation.GetSourceLine ();
2542
2548
evt->Column = writeLocation.GetSourceColumn ();
2543
2549
2544
- this ->EmitLog (emitUri, emitUriLength);
2550
+ this ->EmitLog (emitUri, emitUriLength, entry );
2545
2551
}
2546
2552
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)
2548
2567
{
2549
2568
#if ENABLE_BASIC_TRACE || ENABLE_FULL_BC_TRACE
2550
2569
this ->m_threadContext ->TTDExecutionInfo ->GetTraceLogger ()->ForceFlush ();
@@ -2604,7 +2623,7 @@ namespace TTD
2604
2623
writer.WriteUInt64 (NSTokens::Key::usedMemory, usedSpace, NSTokens::Separator::CommaSeparator);
2605
2624
writer.WriteUInt64 (NSTokens::Key::reservedMemory, reservedSpace, NSTokens::Separator::CommaSeparator);
2606
2625
2607
- uint32 ecount = this ->m_eventList .Count ();
2626
+ uint32 ecount = this ->m_eventList .Count () + (optInnerLoopEvent != nullptr ? 1 : 0 ) ;
2608
2627
writer.WriteLengthValue (ecount, NSTokens::Separator::CommaAndBigSpaceSeparator);
2609
2628
2610
2629
#if ENABLE_TTD_INTERNAL_DIAGNOSTICS
@@ -2677,6 +2696,13 @@ namespace TTD
2677
2696
}
2678
2697
#endif
2679
2698
}
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
+
2680
2706
writer.AdjustIndent (-1 );
2681
2707
writer.WriteSequenceEnd (NSTokens::Separator::BigSpaceSeparator);
2682
2708
0 commit comments