Skip to content

Commit

Permalink
Merge branch 'release/plcrashreporter-1.3' into feature/PLCR-570-refe…
Browse files Browse the repository at this point in the history
…rence-counting
  • Loading branch information
landonf committed Jul 7, 2015
2 parents c7a148b + ab84d52 commit e0a6e40
Show file tree
Hide file tree
Showing 93 changed files with 382 additions and 3,640 deletions.
25 changes: 23 additions & 2 deletions CrashReporter.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -2253,8 +2253,11 @@
034768DFFF38A50411DB9C8B /* Products */,
059670E30EEFADA6008A0601 /* Dependencies */,
);
indentWidth = 4;
name = CrashReporter;
sourceTree = "<group>";
tabWidth = 4;
usesTabs = 0;
};
0867D69AFE84028FC02AAC07 /* External Frameworks and Libraries */ = {
isa = PBXGroup;
Expand Down Expand Up @@ -4620,14 +4623,17 @@
isa = XCBuildConfiguration;
buildSettings = {
CLANG_CXX_LANGUAGE_STANDARD = "c++0x";
CURRENT_PROJECT_VERSION = 1.2.1;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CURRENT_PROJECT_VERSION = "1.2.1";
GCC_C_LANGUAGE_STANDARD = c99;
GCC_ENABLE_CPP_EXCEPTIONS = NO;
GCC_ENABLE_CPP_RTTI = NO;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PREFIX_HEADER = "$(SRCROOT)/Source/PLCrashNamespace.h";
GCC_PREPROCESSOR_DEFINITIONS = PLCR_PRIVATE;
GCC_WARN_ABOUT_MISSING_NEWLINE = YES;
GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES;
GCC_WARN_SHADOW = YES;
HEADER_SEARCH_PATHS = "\"$(SRCROOT)/Dependencies/protobuf-2.0.3/include\"";
MACOSX_DEPLOYMENT_TARGET = 10.5;
ONLY_ACTIVE_ARCH = NO;
Expand All @@ -4640,12 +4646,18 @@
PL_CATCH_CONFIG_FLAGS = CATCH_CONFIG_NO_CPP11;
PL_IOS_DEPLOYMENT_TARGET = 6.0;
PL_MIN_MACOSX_SDK = 1080;
PL_NEVER_WARN = "-Wno-objc-interface-ivars -Wno-c++98-compat-pedantic -Wno-padded -Wno-gnu-zero-variadic-macro-arguments -Wno-variadic-macros";
SDKROOT = macosx;
VALID_ARCHS = "i386 ppc armv7 armv7s armv6 x86_64 arm64";
WARNING_CFLAGS = (
"-Wall",
"-Werror",
"-Wno-shorten-64-to-32",
"-Wimport-preprocessor-directive-pedantic",
"-Wimplicit-fallthrough",
"-Wreceiver-forward-class",
"-Wshift-sign-overflow",
"$(PL_NEVER_WARN)",
);
};
name = Debug;
Expand All @@ -4654,14 +4666,17 @@
isa = XCBuildConfiguration;
buildSettings = {
CLANG_CXX_LANGUAGE_STANDARD = "c++0x";
CURRENT_PROJECT_VERSION = 1.2.1;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CURRENT_PROJECT_VERSION = "1.2.1";
GCC_C_LANGUAGE_STANDARD = c99;
GCC_ENABLE_CPP_EXCEPTIONS = NO;
GCC_ENABLE_CPP_RTTI = NO;
GCC_GENERATE_DEBUGGING_SYMBOLS = NO;
GCC_PREFIX_HEADER = "$(SRCROOT)/Source/PLCrashNamespace.h";
GCC_PREPROCESSOR_DEFINITIONS = PLCR_PRIVATE;
GCC_WARN_ABOUT_MISSING_NEWLINE = YES;
GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES;
GCC_WARN_SHADOW = YES;
HEADER_SEARCH_PATHS = (
"\"$(SRCROOT)/$(DERIVED_FILES_DIR)\"",
"\"$(SRCROOT)/Dependencies/protobuf-2.0.3/include\"",
Expand All @@ -4676,12 +4691,18 @@
PL_CATCH_CONFIG_FLAGS = CATCH_CONFIG_NO_CPP11;
PL_IOS_DEPLOYMENT_TARGET = 6.0;
PL_MIN_MACOSX_SDK = 1080;
PL_NEVER_WARN = "-Wno-objc-interface-ivars -Wno-c++98-compat-pedantic -Wno-padded -Wno-gnu-zero-variadic-macro-arguments -Wno-variadic-macros";
SDKROOT = macosx;
VALID_ARCHS = "i386 ppc armv7 armv7s armv6 x86_64 arm64";
WARNING_CFLAGS = (
"-Wall",
"-Werror",
"-Wno-shorten-64-to-32",
"-Wimport-preprocessor-directive-pedantic",
"-Wimplicit-fallthrough",
"-Wreceiver-forward-class",
"-Wshift-sign-overflow",
"$(PL_NEVER_WARN)",
);
};
name = Release;
Expand Down
4 changes: 2 additions & 2 deletions Source/Crash Demo/main.m
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,13 @@ - (BOOL) application: (UIApplication *) application didFinishLaunchingWithOption
#endif /* TARGET_OS_IPHONE */

/* A custom post-crash callback */
void post_crash_callback (siginfo_t *info, ucontext_t *uap, void *context) {
static void post_crash_callback (siginfo_t *info, ucontext_t *uap, void *context) {
// this is not async-safe, but this is a test implementation
NSLog(@"post crash callback: signo=%d, uap=%p, context=%p", info->si_signo, uap, context);
}


void stackFrame (void) {
__attribute__((noinline)) static void stackFrame (void) {
/* Trigger a crash */
((char *)NULL)[1] = 0;
}
Expand Down
2 changes: 1 addition & 1 deletion Source/DynamicLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ DynamicLoader::~DynamicLoader () {
* context.
*
* @param allocator The allocator to be used when instantiating the new ImageList instance.
* @param[out] loader On success, will be initialized with a pointer to a new ImageList instance. It is the caller's
* @param[out] imageList On success, will be initialized with a pointer to a new ImageList instance. It is the caller's
* responsibility to free this instance via `delete`.
* @param task The target task.
*
Expand Down
7 changes: 4 additions & 3 deletions Source/Libunwind Regression Tests/unwind_test_harness.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
*/


#include "unwind_test_harness.h"
#include <stddef.h>
#include <stdlib.h>
#include <stdio.h>
Expand Down Expand Up @@ -60,7 +61,7 @@ extern void *unwind_tester_list_arm64_frameless[];
extern int unwind_tester (void *test, void **sp);
extern void *unwind_tester_target_ip;

void uwind_to_main ();
void uwind_to_main (void);

plframe_cursor_frame_reader_t *frame_readers_frame[] = {
plframe_cursor_read_frame_ptr,
Expand Down Expand Up @@ -227,7 +228,7 @@ bool unwind_test_harness (void) {
} \
} while (0)

plcrash_error_t unwind_current_state (plcrash_async_thread_state_t *state, void *context) {
static plcrash_error_t unwind_current_state (plcrash_async_thread_state_t *state, void *context) {
plframe_cursor_t cursor;
plcrash_async_image_list_t *image_list;
plframe_cursor_frame_reader_t **readers = global_harness_state.test_case->frame_readers_dwarf;
Expand Down Expand Up @@ -340,7 +341,7 @@ plcrash_error_t unwind_current_state (plcrash_async_thread_state_t *state, void
// called by test function
// we unwind through the test function
// and resume at caller (unwind_tester)
void uwind_to_main () {
void uwind_to_main (void) {
/* Invoke our handler with our current thread state; we use this state to try to roll back the tests
* and verify that the expected registers are restored. */
if (plcrash_async_thread_state_current(unwind_current_state, NULL) != PLCRASH_ESUCCESS) {
Expand Down
2 changes: 2 additions & 0 deletions Source/Libunwind Regression Tests/unwind_test_harness.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
#ifndef PLCRASH_UNWIND_TEST_HARNESS_H
#define PLCRASH_UNWIND_TEST_HARNESS_H

#include <stdbool.h>

#ifdef __cplusplus
extern "C" {
#endif
Expand Down
44 changes: 8 additions & 36 deletions Source/PLCrashAsync.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@
* OTHER DEALINGS IN THE SOFTWARE.
*/

#import "PLCrashAsync.h"
#include "PLCrashAsync.h"

#import <stdint.h>
#import <errno.h>
#import <string.h>
#import <inttypes.h>
#include <stdint.h>
#include <errno.h>
#include <string.h>
#include <inttypes.h>

/**
* @internal
Expand Down Expand Up @@ -144,31 +144,6 @@ const char *plcrash_async_strerror (plcrash_error_t error) {
return "Unhandled error code";
}

/**
* (Safely) read len bytes from @a source, storing in @a dest.
*
* @param task The task from which data from address @a source will be read.
* @param source The address within @a task from which the data will be read.
* @param dest The destination address to which copied data will be written.
* @param len The number of bytes to be read.
*
* @return On success, returns KERN_SUCCESS. If the pages containing @a source + len are unmapped, KERN_INVALID_ADDRESS
* will be returned. If the pages can not be read due to access restrictions, KERN_PROTECTION_FAILURE will be returned.
*
* @warning Unlike all other plcrash_* functions, plcrash_async_read_addr returns a kern_return_t value.
* @deprecated New code should make use of plcrash_async_task_memcpy().
*/
kern_return_t plcrash_async_read_addr (mach_port_t task, pl_vm_address_t source, void *dest, pl_vm_size_t len) {
#ifdef PL_HAVE_MACH_VM
pl_vm_size_t read_size = len;
return mach_vm_read_overwrite(task, source, len, (pointer_t) dest, &read_size);
#else
vm_size_t read_size = len;
return vm_read_overwrite(task, source, len, (pointer_t) dest, &read_size);
#endif
}


/**
* Safely add @a offset to @a base_address, returning the result in @a result. If an overflow would occur, false is returned.
*
Expand Down Expand Up @@ -242,16 +217,13 @@ plcrash_error_t plcrash_async_task_memcpy (mach_port_t task, pl_vm_address_t add

case KERN_INVALID_ADDRESS:
return PLCRASH_ENOTFOUND;
break;

case KERN_PROTECTION_FAILURE:
return PLCRASH_EACCESS;
break;

default:
PLCF_DEBUG("Unexpected error from vm_read_overwrite: %d", kt);
return PLCRASH_EUNKNOWN;
break;
}
}

Expand Down Expand Up @@ -407,7 +379,7 @@ void *plcrash_async_memcpy (void *dest, const void *source, size_t n) {
* though in reality, it is.
*
* @param dest Destination.
* @param int Value to write to @a dest.
* @param value Value to write to @a dest.
* @param n Number of bytes to copy.
*/
void *plcrash_async_memset(void *dest, uint8_t value, size_t n) {
Expand All @@ -433,12 +405,12 @@ void *plcrash_async_memset(void *dest, uint8_t value, size_t n) {
* should be necessary
*/
ssize_t plcrash_async_writen (int fd, const void *data, size_t len) {
const void *p;
const uint8_t *p;
size_t left;
ssize_t written = 0;

/* Loop until all bytes are written */
p = data;
p = (const uint8_t *) data;
left = len;
while (left > 0) {
if ((written = write(fd, p, left)) <= 0) {
Expand Down
2 changes: 0 additions & 2 deletions Source/PLCrashAsync.h
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,6 @@ typedef enum {

const char *plcrash_async_strerror (plcrash_error_t error);

kern_return_t plcrash_async_read_addr (mach_port_t task, pl_vm_address_t source, void *dest, pl_vm_size_t len);

bool plcrash_async_address_apply_offset (pl_vm_address_t base_address, pl_vm_off_t offset, pl_vm_address_t *result);

thread_t pl_mach_thread_self (void);
Expand Down
2 changes: 1 addition & 1 deletion Source/PLCrashAsyncCompactUnwindEncoding.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
* @param reader The reader instance to initialize.
* @param mobj The memory object containing CFE data at the start address. This instance must survive for the lifetime
* of the reader.
* @param cpu_type The target architecture of the CFE data, encoded as a Mach-O CPU type. Interpreting CFE data is
* @param cputype The target architecture of the CFE data, encoded as a Mach-O CPU type. Interpreting CFE data is
* architecture-specific, and Apple has not defined encodings for all supported architectures.
*/
plcrash_error_t plcrash_async_cfe_reader_init (plcrash_async_cfe_reader_t *reader, plcrash_async_mobject_t *mobj, cpu_type_t cputype) {
Expand Down
16 changes: 8 additions & 8 deletions Source/PLCrashAsyncDwarfCFAStateEvaluation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -290,15 +290,15 @@ plcrash_error_t dwarf_cfa_state<machine_ptr, machine_ptr_s>::eval_program (plcra
}

case DW_CFA_def_cfa_expression: {
/* Fetch the DWARF_FORM_block length header; we need this to skip the over the DWARF expression. */
uint64_t length = dw_expr_read_uleb128();
/* Fetch the DW_FORM_block length header; we need this to skip the over the DWARF expression. */
uint64_t blockLength = dw_expr_read_uleb128();

/* Fetch the opstream position of the DWARF expression */
uintptr_t pos = opstream.get_position();

/* The returned sizes should always fit within the VM types in valid DWARF data; if they don't, how
* are we debugging the target? */
if (length > PL_VM_SIZE_MAX || length > PL_VM_OFF_MAX) {
if (blockLength > PL_VM_SIZE_MAX || blockLength > PL_VM_OFF_MAX) {
PLCF_DEBUG("DWARF expression length exceeds PL_VM_SIZE_MAX/PL_VM_OFF_MAX in DW_CFA_def_cfa_expression operand");
return PLCRASH_ENOTSUP;
}
Expand All @@ -324,10 +324,10 @@ plcrash_error_t dwarf_cfa_state<machine_ptr, machine_ptr_s>::eval_program (plcra
}

/* Save the position */
set_cfa_expression(abs_addr, length);
set_cfa_expression(abs_addr, blockLength);

/* Skip the expression opcodes */
opstream.skip(length);
opstream.skip(blockLength);
break;
}

Expand Down Expand Up @@ -368,8 +368,8 @@ plcrash_error_t dwarf_cfa_state<machine_ptr, machine_ptr_s>::eval_program (plcra
dwarf_cfa_state_regnum_t regnum = dw_expr_read_uleb128_regnum();
uintptr_t pos = opstream.get_position();

/* Fetch the DWARF_FORM_block length header; we need this to skip the over the DWARF expression. */
uint64_t length = dw_expr_read_uleb128();
/* Fetch the DW_FORM_BLOCK length header; we need this to skip the over the DWARF expression. */
uint64_t blockLength = dw_expr_read_uleb128();

/* Calculate the absolute address of the expression opcodes (including verifying that pos won't overflow when applying the offset). */
#pragma clang diagnostic push
Expand All @@ -396,7 +396,7 @@ plcrash_error_t dwarf_cfa_state<machine_ptr, machine_ptr_s>::eval_program (plcra
}

/* Skip the expression opcodes */
opstream.skip(length);
opstream.skip(blockLength);
break;
}

Expand Down
4 changes: 2 additions & 2 deletions Source/PLCrashAsyncDwarfCIE.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ using namespace plcrash::async;
*
* @param info The CIE info instance to initialize.
* @param mobj The memory object containing frame data (eh_frame or debug_frame) at the start address.
* @param byteoder The byte order of the data referenced by @a mobj.
* @param ptr_state The pointer state to be used when decoding GNU eh_frame pointer values.
* @param byteorder The byte order of the data referenced by @a mobj.
* @param ptr_reader The pointer reader to be used when decoding GNU eh_frame pointer values.
* @param address The task-relative address within @a mobj of the CIE to be decoded.
*/
template <typename machine_ptr>
Expand Down
3 changes: 0 additions & 3 deletions Source/PLCrashAsyncDwarfEncoding.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,6 @@ PLCR_CPP_BEGIN_ASYNC_NS
* @internal
*
* A DWARF frame reader. Performs DWARF eh_frame/debug_frame parsing from a backing memory object.
*
* @tparam machine_ptr The target machine's unsigned native pointer type.
* @tparam machine_ptr_s The target machine's signed native pointer type.
*/
class dwarf_frame_reader {
public:
Expand Down
Loading

0 comments on commit e0a6e40

Please sign in to comment.