this repo has no description
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

libcrashhandler, IOKit fixes for corebase bugs

+165 -3
+2
src/IOKit/bsd.cpp
··· 5 5 #include <sys/types.h> 6 6 #include <dirent.h> 7 7 #include "constants.h" 8 + extern "C" { 8 9 #include <CoreFoundation/CFString.h> 10 + } 9 11 10 12 std::string DarlingTranslateBSDName(const char* name); 11 13 bool DarlingFindBSDName(const char* name, char* path);
+2
src/IOKit/bsd.h
··· 1 1 #ifndef IOKIT_BSD_H 2 2 #define IOKIT_BSD_H 3 + extern "C" { 3 4 #include <CoreFoundation/CFDictionary.h> 5 + } 4 6 #include <string> 5 7 6 8 extern "C"
+2
src/IOKit/cfutil.h
··· 1 1 #ifndef IOKIT_CFUTIL_H 2 2 #define IOKIT_CFUTIL_H 3 + extern "C" { 3 4 #include <CoreFoundation/CFString.h> 4 5 #include <CoreFoundation/CFNumber.h> 6 + } 5 7 #include <cstdlib> 6 8 7 9 #define strCFEqual(cfs, cstr) (CFStringCompare(cfs, CFSTR(cstr), CFStringCompareFlags(0)) == 0)
+2
src/IOKit/io_device.h
··· 1 1 #ifndef IOKIT_IODEVICE_H 2 2 #define IOKIT_IODEVICE_H 3 + extern "C" { 3 4 #include <CoreFoundation/CFString.h> 4 5 #include <CoreFoundation/CFNumber.h> 6 + } 5 7 #include <libudev.h> 6 8 #include "io_object.h" 7 9
+6 -2
src/IOKit/service.h
··· 5 5 #endif 6 6 7 7 #include "io_object.h" 8 - #include "io_iterator.h" 8 + #include "io_device_iterator.h" 9 + extern "C" { 9 10 #include <CoreFoundation/CFDictionary.h> 11 + } 10 12 11 13 extern "C" const void* kIOMasterPortDefault; 12 14 ··· 16 18 extern "C" CFMutableDictionaryRef IOServiceNameMatching(const char* name); 17 19 extern "C" CFMutableDictionaryRef IOBSDNameMatching(void* iokitPort, unsigned int options, const char* bsdName); 18 20 19 - extern "C" int IOServiceGetMatchingServices(void* port, CFDictionaryRef rules, io_iterator_t* iter); 21 + extern "C" int IOServiceGetMatchingServices(void* port, CFDictionaryRef rules, io_device_iterator_t* iter); 20 22 21 23 extern "C" int IORegistryEntryGetParentEntry(io_object_t obj, void* planeName /* TODO */, io_object_t* parent); 22 24 extern "C" CFTypeRef IORegistryEntryCreateCFProperty(io_object_t obj, CFStringRef key, CFAllocatorRef allocator, int opts); 23 25 extern "C" int IORegistryEntryCreateCFProperties(io_object_t obj, CFMutableDictionaryRef* props, CFAllocatorRef allocator, int opts); 26 + 27 + extern "C" int IOMasterPort(void* bootstrapPort, void** masterPort); 24 28 25 29 #endif 26 30
+6
src/IOKit/service.mm
··· 29 29 return dict; 30 30 } 31 31 32 + int IOMasterPort(void* bootstrapPort, void** masterPort) 33 + { 34 + *masterPort = (void*) kIOMasterPortDefault; 35 + return 0; 36 + } 37 + 32 38 CFMutableDictionaryRef IOServiceMatching(const char* service) 33 39 { 34 40 static CFStringRef str = CFSTR(kIOProviderClassKey);
+20
src/libcrashhandler/CMakeLists.txt
··· 1 + project(crashhandler) 2 + 3 + cmake_minimum_required(VERSION 2.4.0) 4 + if(COMMAND cmake_policy) 5 + cmake_policy(SET CMP0003 NEW) 6 + endif(COMMAND cmake_policy) 7 + 8 + add_definitions(-fconstant-string-class=NSConstantString) 9 + 10 + set(crashhandler_src 11 + crashhandler.m 12 + ) 13 + 14 + set_source_files_properties(${crashhandler_src} PROPERTIES LANGUAGE C) # Stupid CMake thinks that ObjC is C++ 15 + 16 + add_library(crashhandler SHARED ${crashhandler_src}) 17 + target_link_libraries(crashhandler -lgnustep-gui -lgnustep-base) 18 + 19 + install(TARGETS crashhandler DESTINATION "lib${SUFFIX}/darling") 20 +
+124
src/libcrashhandler/crashhandler.m
··· 1 + #import <Foundation/NSXMLElement.h> 2 + #import <Foundation/NSXMLDocument.h> 3 + #import <Foundation/NSXMLNode.h> 4 + #import <Foundation/NSString.h> 5 + #import <Foundation/NSAutoreleasePool.h> 6 + #include <signal.h> 7 + #include <string.h> 8 + #include <stdlib.h> 9 + #include <unistd.h> 10 + #include <stdio.h> 11 + //#include "../../config.h" 12 + 13 + #ifndef TEST 14 + __attribute__((constructor)) 15 + #endif 16 + static void setSignalHandlers(); 17 + 18 + __attribute__((destructor)) static void freeMemory(); 19 + static void crashHandler(int signo, siginfo_t* info, void*); 20 + 21 + // Defined in Darling dyld 22 + extern char** g_argv; 23 + extern int g_argc; 24 + static char** g_argvCopy = NULL; // out private copy 25 + static char* g_originalCwd = NULL; 26 + 27 + void setSignalHandlers() 28 + { 29 + if (getenv("DARLING_NO_HANDLER") == NULL) 30 + { 31 + struct sigaction act; 32 + 33 + g_argvCopy = (char**) malloc(sizeof(char**) * (g_argc+1)); 34 + for (int i = 0; i < g_argc; i++) 35 + g_argvCopy[i] = strdup(g_argv[i]); 36 + g_argvCopy[g_argc] = NULL; 37 + 38 + g_originalCwd = getcwd(NULL, 0); 39 + 40 + memset(&act, 0, sizeof act); 41 + act.sa_sigaction = crashHandler; 42 + act.sa_flags = SA_SIGINFO; 43 + sigemptyset (&act.sa_mask); 44 + 45 + sigaction(SIGSEGV, &act, NULL); 46 + sigaction(SIGABRT, &act, NULL); 47 + sigaction(SIGILL, &act, NULL); 48 + sigaction(SIGFPE, &act, NULL); 49 + sigaction(SIGBUS, &act, NULL); 50 + } 51 + } 52 + 53 + void freeMemory() 54 + { 55 + if (g_argvCopy) 56 + { 57 + for (int i = 0; g_argvCopy[i] != NULL; i++) 58 + free(g_argvCopy[i]); 59 + free(g_argvCopy); 60 + g_argvCopy = NULL; 61 + } 62 + free(g_originalCwd); 63 + } 64 + 65 + void crashHandler(int signo, siginfo_t* info, void* p) 66 + { 67 + NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; 68 + // Generate a XML file with error description 69 + NSXMLElement *root = (NSXMLElement *)[NSXMLNode elementWithName:@"crash"]; 70 + NSXMLDocument *xmlDoc = [[NSXMLDocument alloc] initWithRootElement:root]; 71 + NSXMLElement* sroot; 72 + NSXMLElement* sub; 73 + 74 + [xmlDoc setVersion:@"1.0"]; 75 + [xmlDoc setCharacterEncoding:@"UTF-8"]; 76 + 77 + // Add runtime information 78 + sroot = (NSXMLElement *)[NSXMLNode elementWithName:@"application"]; 79 + sub = (NSXMLElement *) [NSXMLNode elementWithName: @"wd" stringValue:[NSString stringWithUTF8String: g_originalCwd]]; 80 + [sroot addChild:sub]; 81 + 82 + // Add arguments (to restart the app) 83 + sub = (NSXMLElement *)[NSXMLNode elementWithName:@"arguments"]; 84 + for (int i = 0; i < g_argc; i++) 85 + { 86 + NSXMLElement* value = (NSXMLElement *)[NSXMLNode elementWithName:@"argument" stringValue:[NSString stringWithUTF8String: g_argvCopy[i]]]; 87 + [sub addChild: value]; 88 + } 89 + [sroot addChild:sub]; 90 + [root addChild:sroot]; 91 + 92 + // Signal information 93 + sroot = (NSXMLElement *) [NSXMLNode elementWithName: @"signal" stringValue:[NSString stringWithFormat: @"%d", info->si_signo ]]; 94 + [root addChild:sroot]; 95 + 96 + // Save the file 97 + NSData *xmlData = [xmlDoc XMLDataWithOptions:NSXMLNodePreserveAll]; 98 + NSString* path = [NSString stringWithFormat: @"/tmp/crashinfo.%d.xml", getpid()]; 99 + [xmlData writeToFile:path atomically:YES]; 100 + 101 + NSLog(@"Crash info stored at %@\n", path); 102 + 103 + [pool release]; 104 + 105 + // Execute the crash dialog 106 + 107 + exit(signo); 108 + } 109 + 110 + #ifdef TEST 111 + int g_argc; 112 + char** g_argv; 113 + int main(int argc, char** argv) 114 + { 115 + g_argc = argc; 116 + g_argv = argv; 117 + 118 + setSignalHandlers(); 119 + *((volatile int*) NULL) = 0; 120 + 121 + return 0; 122 + } 123 + #endif 124 +
+1 -1
src/thin/CMakeLists.txt
··· 10 10 SET_TARGET_PROPERTIES(AppKit PROPERTIES LINKER_LANGUAGE C) 11 11 12 12 add_library(Cocoa SHARED) 13 - target_link_libraries(Cocoa -lgnustep-gui -lopal) 13 + target_link_libraries(Cocoa -lgnustep-gui -lopal crashhandler) 14 14 SET_TARGET_PROPERTIES(Cocoa PROPERTIES LINKER_LANGUAGE C) 15 15 16 16 install(TARGETS Cocoa AppKit DESTINATION "lib${SUFFIX}/darling")