Skip to content

Commit

Permalink
Merge branch 'next' into improve-thread-perf
Browse files Browse the repository at this point in the history
  • Loading branch information
tomlongridge committed Jun 30, 2020
2 parents a72ea48 + 551da1b commit ec806b0
Show file tree
Hide file tree
Showing 15 changed files with 344 additions and 647 deletions.
4 changes: 2 additions & 2 deletions Bugsnag.podspec.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Bugsnag",
"version": "6.0.0",
"version": "6.0.1",
"summary": "The Bugsnag crash reporting framework for Apple platforms.",
"homepage": "https://bugsnag.com",
"license": "MIT",
Expand All @@ -9,7 +9,7 @@
},
"source": {
"git": "https://github.com/bugsnag/bugsnag-cocoa.git",
"tag": "v6.0.0"
"tag": "v6.0.1"
},
"frameworks": [
"Foundation",
Expand Down
19 changes: 0 additions & 19 deletions Bugsnag/KSCrash/Source/KSCrash/Recording/BSG_KSCrash.m
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,12 @@

#import "BugsnagPlatformConditional.h"

#import <mach-o/dyld.h>
#import <execinfo.h>
#import "BSG_KSCrashAdvanced.h"

#import "BSG_KSCrashC.h"
#import "BSG_KSJSONCodecObjC.h"
#import "BSG_KSSingleton.h"
#import "BSG_KSMachHeaders.h"
#import "NSError+BSG_SimpleConstructor.h"

//#define BSG_KSLogger_LocalLevel TRACE
Expand Down Expand Up @@ -234,8 +232,6 @@ - (NSString *)stateFilePath {
}

- (BOOL)install {
// Maintain a cache of info about dynamically loaded binary images
[self listenForLoadedBinaries];

_handlingCrashTypes = bsg_kscrash_install(
[self.crashReportPath UTF8String], [self.recrashReportPath UTF8String],
Expand Down Expand Up @@ -271,21 +267,6 @@ - (BOOL)install {
return true;
}

/**
* Set up listeners for un/loaded frameworks. Maintaining our own list of framework Mach
* headers means that we avoid potential deadlock situations where we try and suspend
* lock-holding threads prior to loading mach headers as part of our normal event handling
* behaviour.
*/
- (void)listenForLoadedBinaries {
bsg_check_unfair_lock_support();
bsg_initialise_mach_binary_headers(BSG_INITIAL_MACH_BINARY_IMAGE_ARRAY_SIZE);

// Note: Access to DYLD's binary image store is guarded by locks.
_dyld_register_func_for_remove_image(&bsg_mach_binary_image_removed);
_dyld_register_func_for_add_image(&bsg_mach_binary_image_added);
}

- (void)sendAllReports {
[self.crashReportStore pruneFilesLeaving:self.maxStoredReports];

Expand Down
7 changes: 6 additions & 1 deletion Bugsnag/KSCrash/Source/KSCrash/Recording/BSG_KSCrashC.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include "BSG_KSCrashReport.h"
#include "BSG_KSCrashSentry_User.h"
#include "BSG_KSMach.h"
#include "BSG_KSMachHeaders.h"
#include "BSG_KSObjC.h"
#include "BSG_KSString.h"
#include "BSG_KSSystemInfoC.h"
Expand Down Expand Up @@ -97,7 +98,11 @@ BSG_KSCrashType bsg_kscrash_install(const char *const crashReportFilePath,
BSG_KSLOG_DEBUG("Installing crash reporter.");

BSG_KSCrash_Context *context = crashContext();


// Initialize local store of dynamically loaded libraries so that binary
// image information can be extracted for reports
bsg_mach_headers_initialize();

if (bsg_g_installed) {
BSG_KSLOG_DEBUG("Crash reporter already installed.");
return context->config.handlingCrashTypes;
Expand Down
29 changes: 13 additions & 16 deletions Bugsnag/KSCrash/Source/KSCrash/Recording/BSG_KSCrashReport.c
Original file line number Diff line number Diff line change
Expand Up @@ -1115,23 +1115,21 @@ int bsg_kscrw_i_threadIndex(const thread_t thread) {
*
* @param key The object key, if needed.
*
* @param index Cached info about the binary image.
* @param img Cached info about the binary image.
*/
void bsg_kscrw_i_writeBinaryImage(const BSG_KSCrashReportWriter *const writer,
const char *const key,
const uint32_t index)
const BSG_Mach_Header_Info *img)
{
BSG_Mach_Binary_Image_Info info = *bsg_dyld_get_image_info(index);

writer->beginObject(writer, key);
{
writer->addUIntegerElement(writer, BSG_KSCrashField_ImageAddress, (uintptr_t)info.header);
writer->addUIntegerElement(writer, BSG_KSCrashField_ImageVmAddress, info.imageVmAddr);
writer->addUIntegerElement(writer, BSG_KSCrashField_ImageSize, info.imageSize);
writer->addStringElement(writer, BSG_KSCrashField_Name, info.name);
writer->addUUIDElement(writer, BSG_KSCrashField_UUID, info.uuid);
writer->addIntegerElement(writer, BSG_KSCrashField_CPUType, info.header->cputype);
writer->addIntegerElement(writer, BSG_KSCrashField_CPUSubType, info.header->cpusubtype);
writer->addUIntegerElement(writer, BSG_KSCrashField_ImageAddress, (uintptr_t)img->header);
writer->addUIntegerElement(writer, BSG_KSCrashField_ImageVmAddress, img->imageVmAddr);
writer->addUIntegerElement(writer, BSG_KSCrashField_ImageSize, img->imageSize);
writer->addStringElement(writer, BSG_KSCrashField_Name, img->name);
writer->addUUIDElement(writer, BSG_KSCrashField_UUID, img->uuid);
writer->addIntegerElement(writer, BSG_KSCrashField_CPUType, img->header->cputype);
writer->addIntegerElement(writer, BSG_KSCrashField_CPUSubType, img->header->cpusubtype);
}
writer->endContainer(writer);
}
Expand All @@ -1145,13 +1143,12 @@ void bsg_kscrw_i_writeBinaryImage(const BSG_KSCrashReportWriter *const writer,
void bsg_kscrw_i_writeBinaryImages(const BSG_KSCrashReportWriter *const writer,
const char *const key)
{
const uint32_t imageCount = bsg_dyld_image_count();

writer->beginArray(writer, key);
{
for (uint32_t iImg = 0; iImg < imageCount; iImg++) {
// Threads are suspended at this point; no need to synchronise/lock
bsg_kscrw_i_writeBinaryImage(writer, NULL, iImg);
for (BSG_Mach_Header_Info *img = bsg_mach_headers_get_images(); img != NULL; img = img->next) {
if (!img->unloaded) {
bsg_kscrw_i_writeBinaryImage(writer, NULL, img);
}
}
}
writer->endContainer(writer);
Expand Down
3 changes: 2 additions & 1 deletion Bugsnag/KSCrash/Source/KSCrash/Recording/BSG_KSSystemInfo.m
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#import "BSG_KSSystemInfo.h"
#import "BSG_KSSystemInfoC.h"
#import "BSG_KSDynamicLinker.h"
#import "BSG_KSMachHeaders.h"
#import "BSG_KSJSONCodecObjC.h"
#import "BSG_KSMach.h"
#import "BSG_KSSysCtl.h"
Expand Down Expand Up @@ -259,7 +260,7 @@ + (NSString *)currentCPUArch {
* @return YES if the device is jailbroken.
*/
+ (BOOL)isJailbroken {
return bsg_ksdlimageNamed("MobileSubstrate", false) != UINT32_MAX;
return bsg_mach_headers_image_named("MobileSubstrate", false) != NULL;
}

/** Check if the current build is a debug build.
Expand Down
Loading

0 comments on commit ec806b0

Please sign in to comment.