Skip to content

Commit

Permalink
launchd crashreporter: Add image list to crash logs
Browse files Browse the repository at this point in the history
  • Loading branch information
opa334 committed Jul 26, 2024
1 parent 70e7ca3 commit 7b31769
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions BaseBin/launchdhook/src/crashreporter.m
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include <fcntl.h>
#include <sys/stat.h>
#include <CoreFoundation/CoreFoundation.h>
#include <mach-o/dyld.h>
extern CFStringRef CFCopySystemVersionString(void);

void abort_with_reason(uint32_t reason_namespace, uint64_t reason_code, const char *reason_string, uint64_t reason_flags);
Expand Down Expand Up @@ -244,6 +245,14 @@ void crashreporter_dump_mach(FILE *f, int code, int subcode, arm_thread_state64_
fprintf(f, "\n");
}

void crashreporter_dump_image_list(FILE *f)
{
fprintf(f, "Images:\n");
for (uint32_t i = 0; i < _dyld_image_count(); i++) {
fprintf(f, "%s: %p\n", _dyld_get_image_name(i), _dyld_get_image_header(i));
}
}

void crashreporter_catch_mach(exception_raise_request *request, exception_raise_reply *reply)
{
pthread_t pthread = pthread_from_mach_thread_np(request->thread.name);
Expand All @@ -268,6 +277,7 @@ void crashreporter_catch_mach(exception_raise_request *request, exception_raise_
FILE *f = crashreporter_open_outfile("launchd", &name);
if (f) {
crashreporter_dump_mach(f, request->code, request->subcode, threadState, exceptionState, bt);
crashreporter_dump_image_list(f);
crashreporter_save_outfile(f);
}

Expand Down Expand Up @@ -322,6 +332,7 @@ void crashreporter_catch_objc(NSException *e)
if (f) {
@try {
crashreporter_dump_objc(f, e);
crashreporter_dump_image_list(f);
}
@catch (NSException *e2) {
exit(187);
Expand Down

0 comments on commit 7b31769

Please sign in to comment.