@@ -653,12 +653,31 @@ - (BOOL) enableCrashReporterAndReturnError: (NSError **) outError {
653
653
*
654
654
* @return Returns nil if the crash report data could not be generated.
655
655
*
656
- * @sa PLCrashReporter::generateLiveReportWithMachThread :error:
656
+ * @sa PLCrashReporter::generateLiveReportWithThread:exception :error:
657
657
*/
658
658
- (NSData *) generateLiveReportWithThread : (thread_t ) thread {
659
659
return [self generateLiveReportWithThread: thread error: NULL ];
660
660
}
661
661
662
+ /* *
663
+ * Generate a live crash report for a given @a thread, without triggering an actual crash condition.
664
+ * This may be used to log current process state without actually crashing. The crash report data will be
665
+ * returned on success.
666
+ *
667
+ * @param thread The thread which will be marked as the failing thread in the generated report.
668
+ * @param outError A pointer to an NSError object variable. If an error occurs, this pointer
669
+ * will contain an error object indicating why the crash report could not be generated or loaded. If no
670
+ * error occurs, this parameter will be left unmodified. You may specify nil for this parameter, and no
671
+ * error information will be provided.
672
+ *
673
+ * @return Returns nil if the crash report data could not be loaded.
674
+ *
675
+ * @sa PLCrashReporter::generateLiveReportWithThread:exception:error:
676
+ */
677
+ - (NSData *) generateLiveReportWithThread : (thread_t ) thread error : (NSError **) outError {
678
+ return [self generateLiveReportWithThread: thread exception: nil error: outError];
679
+ }
680
+
662
681
663
682
/* State and callback used by -generateLiveReportWithThread */
664
683
struct plcr_live_report_context {
@@ -678,6 +697,7 @@ static plcrash_error_t plcr_live_report_callback (plcrash_async_thread_state_t *
678
697
* returned on success.
679
698
*
680
699
* @param thread The thread which will be marked as the failing thread in the generated report.
700
+ * @param exception An exception to be included as the report's uncaught exception, or nil.
681
701
* @param outError A pointer to an NSError object variable. If an error occurs, this pointer
682
702
* will contain an error object indicating why the crash report could not be generated or loaded. If no
683
703
* error occurs, this parameter will be left unmodified. You may specify nil for this parameter, and no
@@ -687,7 +707,7 @@ static plcrash_error_t plcr_live_report_callback (plcrash_async_thread_state_t *
687
707
*
688
708
* @todo Implement in-memory, rather than requiring writing of the report to disk.
689
709
*/
690
- - (NSData *) generateLiveReportWithThread : (thread_t ) thread error : (NSError **) outError {
710
+ - (NSData *) generateLiveReportWithThread : (thread_t ) thread exception : ( NSException *) exception error : (NSError **) outError {
691
711
plcrash_log_writer_t writer;
692
712
plcrash_async_file_t file;
693
713
plcrash_error_t err;
@@ -713,6 +733,9 @@ - (NSData *) generateLiveReportWithThread: (thread_t) thread error: (NSError **)
713
733
plcrash_log_writer_set_custom_data (&writer, self.customData );
714
734
}
715
735
736
+ if (exception != nil )
737
+ plcrash_log_writer_set_exception (&writer, exception);
738
+
716
739
/* Mock up a SIGTRAP-based signal info */
717
740
plcrash_log_bsd_signal_info_t bsd_signal_info;
718
741
plcrash_log_signal_info_t signal_info;
@@ -797,10 +820,14 @@ - (NSData *) generateLiveReport {
797
820
* @return Returns nil if the crash report data could not be loaded.
798
821
*/
799
822
- (NSData *) generateLiveReportAndReturnError : (NSError **) outError {
800
- return [self generateLiveReportWithThread: pl_mach_thread_self () error: outError];
823
+ return [self generateLiveReportWithException: nil error: outError];
801
824
}
802
825
803
826
827
+ - (NSData *) generateLiveReportWithException : (NSException *)exception error : (NSError **) outError {
828
+ return [self generateLiveReportWithThread: pl_mach_thread_self () exception: exception error: outError];
829
+ }
830
+
804
831
/* *
805
832
* Set the callbacks that will be executed by the receiver after a crash has occured and been recorded by PLCrashReporter.
806
833
*
0 commit comments