@@ -593,3 +593,66 @@ COMMAND_BODY(RuntimeStatistics)
593593
594594 return ERROR ;
595595}
596+
597+
598+
599+ // ============================================================================
600+ //
601+ // Flight recorder control
602+ //
603+ // ============================================================================
604+
605+ static bool run_cstring_command (int (*fn)(cstring))
606+ // ----------------------------------------------------------------------------
607+ // Shared code to run a C function taking a null-terminated string as input
608+ // ----------------------------------------------------------------------------
609+ {
610+ if (object_p config = object::strip (rt.top ()))
611+ {
612+ if (text_p wanted = config->as <text>())
613+ {
614+ int result = fn (wanted->null_terminated_value ());
615+ integer_p rc = integer::make (result);
616+ return rc && rt.top (rc);
617+ }
618+ rt.type_error ();
619+ }
620+ return false ;
621+ }
622+
623+
624+ static inline bool run_cstring_command (uint (*fn)(cstring))
625+ // ----------------------------------------------------------------------------
626+ // We don't really care if function return unsigned
627+ // ----------------------------------------------------------------------------
628+ {
629+ return run_cstring_command ((int (*)(cstring)) fn);
630+ }
631+
632+
633+ COMMAND_BODY (FlightRecorderConfigure)
634+ // ----------------------------------------------------------------------------
635+ // Configure specific traces for the flight recorder
636+ // ----------------------------------------------------------------------------
637+ {
638+ return run_cstring_command (recorder_trace_set) ? OK : ERROR ;
639+ }
640+
641+
642+ COMMAND_BODY (FlightRecorderDump)
643+ // ----------------------------------------------------------------------------
644+ // Cause a flight recorder dump
645+ // ----------------------------------------------------------------------------
646+ {
647+ recorder_dump ();
648+ return OK ;
649+ }
650+
651+
652+ COMMAND_BODY (FlightRecorderDumpSome)
653+ // ----------------------------------------------------------------------------
654+ // Cause a partial flight recorder dump
655+ // ----------------------------------------------------------------------------
656+ {
657+ return run_cstring_command (recorder_dump_for) ? OK : ERROR ;
658+ }
0 commit comments