Skip to content

Commit

Permalink
Hotfix/0.5.x (#226)
Browse files Browse the repository at this point in the history
* fix trace build bug

* fix CheckedDatabaseListActivity 兼容性crash

* try catch OutOfMemoryError

* fix npe

* fix permission crash

* 1. style check  2. upload 0.5.2 to jcenter 3. add ‘armeabi’ back to abiFilters

* Dev (#208)

* fix trace build bug (#199)

* Hotfix/0.5.x (#200)

* fix trace build bug

* fix CheckedDatabaseListActivity 兼容性crash

* Hotfix/0.5.x to dev (#207)

* fix trace build bug

* fix CheckedDatabaseListActivity 兼容性crash

* try catch OutOfMemoryError

* fix npe

* fix permission crash

* 1. style check  2. upload 0.5.2 to jcenter 3. add ‘armeabi’ back to abiFilters

* fix(MemStat): USE_PRIVATE_API  access nil pointer

* fix(MemStat): do not “update_object_event” for g_matrix_block_monitor_dumping_thread_id

* fix(MemStat): do not log the oc’event of dumping thread

* fix(CrashBlock): free g_topStackAddressRepeatArray
  • Loading branch information
chzhij5 authored and txfelixzhou committed May 14, 2019
1 parent 8623c49 commit 6ca6869
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,21 +68,29 @@ - (id)init
return [self initWithCycleArrayCount:10];
}

- (void)freeMainThreadCycleArray
- (void)dealloc
{
for (uint32_t i = 0; i < m_cycleArrayCount; i++) {
if (g_mainThreadStackCycleArray[i] != NULL) {
free(g_mainThreadStackCycleArray[i]);
g_mainThreadStackCycleArray[i] = NULL;
}
}
free(g_mainThreadStackCycleArray);
g_mainThreadStackCycleArray = NULL;
}
- (void)dealloc
{
[self freeMainThreadCycleArray];
free(g_mainThreadStackCount);

if (g_mainThreadStackCycleArray != NULL) {
free(g_mainThreadStackCycleArray);
g_mainThreadStackCycleArray = NULL;
}

if (g_mainThreadStackCount != NULL) {
free(g_mainThreadStackCount);
g_mainThreadStackCount = NULL;
}

if (g_topStackAddressRepeatArray != NULL) {
free(g_topStackAddressRepeatArray);
g_topStackAddressRepeatArray = NULL;
}
}

- (void)addThreadStack:(uintptr_t *)stackArray andStackCount:(size_t)stackCount
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,14 @@
#import <objc/runtime.h>
#import "nsobject_hook.h"
#import "object_event_handler.h"
#include <pthread/pthread.h>

#if __has_feature(objc_arc)
#error This file must be compiled with MRR. Use -fno-objc-arc flag.
#endif

extern mach_port_t g_matrix_block_monitor_dumping_thread_id;

#pragma mark -
#pragma mark NSObject ObjectEventLogging

Expand All @@ -37,7 +40,10 @@ @implementation NSObject (ObjectEventLogging)
+ (id)event_logging_alloc
{
id object = [self event_logging_alloc];
nsobject_set_last_allocation_event_name(object, class_getName(self.class));
if (pthread_mach_thread_np(pthread_self()) == g_matrix_block_monitor_dumping_thread_id) {
return object;
}
nsobject_set_last_allocation_event_name(object, class_getName(self.class));
return object;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@
#pragma mark -
#pragma mark Types

#ifdef DEBUG
#define USE_PRIVATE_API
#endif

struct object_type {
uint32_t type;
char name[59];
Expand Down Expand Up @@ -385,9 +389,15 @@ bool prepare_object_event_logger(const char *log_dir)

void disable_object_event_logger()
{
*object_set_last_allocation_event_name_funcion = NULL;
*object_record_allocation_event_enable = false;
#ifdef USE_PRIVATE_API
if (object_set_last_allocation_event_name_funcion != NULL) {
*object_set_last_allocation_event_name_funcion = NULL;
}
if (object_record_allocation_event_enable != NULL) {
*object_record_allocation_event_enable = false;
}
//nsobject_hook_alloc_method();
#endif
}

object_type_file *open_object_type_file(const char *event_dir)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@
#include "dyld_image_info.h"
#include "stack_frames_db.h"

#ifdef DEBUG
#define USE_PRIVATE_API
#endif

#pragma mark -
#pragma mark Constants/Globals

Expand Down Expand Up @@ -202,7 +206,8 @@ void __memory_event_callback(uint32_t type_flags, uintptr_t zone_ptr, uintptr_t

void __update_object_event(uint64_t address, uint32_t new_type)
{
if (current_thread_id() == working_thread_id || !logging_is_enable) {
thread_id curr_thread = current_thread_id();
if (curr_thread == working_thread_id || curr_thread == g_matrix_block_monitor_dumping_thread_id || !logging_is_enable) {
return;
}

Expand Down Expand Up @@ -518,7 +523,11 @@ void disable_memory_logging(void)

disable_object_event_logger();
malloc_logger = NULL;
*syscall_logger = NULL;
#ifdef USE_PRIVATE_API
if (syscall_logger != NULL) {
*syscall_logger = NULL;
}
#endif
// avoid that after the memory monitoring stops, there are still some events being written.
reset_write_index(event_buffer);
// make current logging invalid
Expand Down

0 comments on commit 6ca6869

Please sign in to comment.