1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/toolkit/crashreporter/google-breakpad/src/client/ios/Breakpad.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,219 @@ 1.4 +// Copyright (c) 2011, Google Inc. 1.5 +// All rights reserved. 1.6 +// 1.7 +// Redistribution and use in source and binary forms, with or without 1.8 +// modification, are permitted provided that the following conditions are 1.9 +// met: 1.10 +// 1.11 +// * Redistributions of source code must retain the above copyright 1.12 +// notice, this list of conditions and the following disclaimer. 1.13 +// * Redistributions in binary form must reproduce the above 1.14 +// copyright notice, this list of conditions and the following disclaimer 1.15 +// in the documentation and/or other materials provided with the 1.16 +// distribution. 1.17 +// * Neither the name of Google Inc. nor the names of its 1.18 +// contributors may be used to endorse or promote products derived from 1.19 +// this software without specific prior written permission. 1.20 +// 1.21 +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 1.22 +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 1.23 +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 1.24 +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 1.25 +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 1.26 +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 1.27 +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 1.28 +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 1.29 +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 1.30 +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 1.31 +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 1.32 + 1.33 +// Framework to provide a simple C API to crash reporting for 1.34 +// applications. By default, if any machine-level exception (e.g., 1.35 +// EXC_BAD_ACCESS) occurs, it will be handled by the BreakpadRef 1.36 +// object as follows: 1.37 +// 1.38 +// 1. Create a minidump file (see Breakpad for details) 1.39 +// 2. Create a config file. 1.40 +// 1.41 +// These files can then be uploaded to a server. 1.42 + 1.43 +typedef void *BreakpadRef; 1.44 + 1.45 +#ifdef __cplusplus 1.46 +extern "C" { 1.47 +#endif 1.48 + 1.49 +#include <Foundation/Foundation.h> 1.50 + 1.51 +#include <client/apple/Framework/BreakpadDefines.h> 1.52 + 1.53 +// The keys in the dictionary returned by |BreakpadGenerateReport|. 1.54 +#define BREAKPAD_OUTPUT_DUMP_FILE "BreakpadDumpFile" 1.55 +#define BREAKPAD_OUTPUT_CONFIG_FILE "BreakpadConfigFile" 1.56 + 1.57 +// Optional user-defined function to decide if we should handle this crash or 1.58 +// forward it along. 1.59 +// Return true if you want Breakpad to handle it. 1.60 +// Return false if you want Breakpad to skip it 1.61 +// The exception handler always returns false, as if SEND_AND_EXIT were false 1.62 +// (which means the next exception handler will take the exception) 1.63 +typedef bool (*BreakpadFilterCallback)(int exception_type, 1.64 + int exception_code, 1.65 + mach_port_t crashing_thread, 1.66 + void *context); 1.67 + 1.68 +// Create a new BreakpadRef object and install it as an exception 1.69 +// handler. The |parameters| will typically be the contents of your 1.70 +// bundle's Info.plist. 1.71 +// 1.72 +// You can also specify these additional keys for customizable behavior: 1.73 +// Key: Value: 1.74 +// BREAKPAD_PRODUCT Product name (e.g., "MyAwesomeProduct") 1.75 +// This one is used as the key to identify 1.76 +// the product when uploading. Falls back to 1.77 +// CFBundleName if not specified. 1.78 +// REQUIRED 1.79 +// 1.80 +// BREAKPAD_PRODUCT_DISPLAY This is the display name, e.g. a pretty 1.81 +// name for the product when the crash_sender 1.82 +// pops up UI for the user. Falls back first to 1.83 +// CFBundleDisplayName and then to 1.84 +// BREAKPAD_PRODUCT if not specified. 1.85 +// 1.86 +// BREAKPAD_VERSION Product version (e.g., 1.2.3), used 1.87 +// as metadata for crash report. Falls back to 1.88 +// CFBundleVersion if not specified. 1.89 +// REQUIRED 1.90 +// 1.91 +// BREAKPAD_VENDOR Vendor name, used in UI (e.g. "A report has 1.92 +// been created that you can send to <vendor>") 1.93 +// 1.94 +// BREAKPAD_URL URL destination for reporting 1.95 +// REQUIRED 1.96 +// 1.97 +// BREAKPAD_DUMP_DIRECTORY The directory to store crash-dumps 1.98 +// in. By default, we use 1.99 +// ~/Library/Cache/Breakpad/<BREAKPAD_PRODUCT> 1.100 +// The path you specify here is tilde-expanded. 1.101 +// 1.102 +// BREAKPAD_SERVER_TYPE A parameter that tells Breakpad how to 1.103 +// rewrite the upload parameters for a specific 1.104 +// server type. The currently valid values are 1.105 +// 'socorro' or 'google'. If you want to add 1.106 +// other types, see the function in 1.107 +// crash_report_sender.m that maps parameters to 1.108 +// URL parameters. Defaults to 'google'. 1.109 +// 1.110 +// BREAKPAD_SERVER_PARAMETER_DICT A plist dictionary of static 1.111 +// parameters that are uploaded to the 1.112 +// server. The parameters are sent as 1.113 +// is to the crash server. Their 1.114 +// content isn't added to the minidump 1.115 +// but pass as URL parameters when 1.116 +// uploading theminidump to the crash 1.117 +// server. 1.118 +//============================================================================= 1.119 +// The BREAKPAD_PRODUCT, BREAKPAD_VERSION and BREAKPAD_URL are 1.120 +// required to have non-NULL values. By default, the BREAKPAD_PRODUCT 1.121 +// will be the CFBundleName and the BREAKPAD_VERSION will be the 1.122 +// CFBundleVersion when these keys are present in the bundle's 1.123 +// Info.plist, which is usually passed in to BreakpadCreate() as an 1.124 +// NSDictionary (you could also pass in another dictionary that had 1.125 +// the same keys configured). If the BREAKPAD_PRODUCT or 1.126 +// BREAKPAD_VERSION are ultimately undefined, BreakpadCreate() will 1.127 +// fail. You have been warned. 1.128 +// 1.129 +// If you are running in a debugger, Breakpad will not install, unless the 1.130 +// BREAKPAD_IGNORE_DEBUGGER envionment variable is set and/or non-zero. 1.131 +// 1.132 +//============================================================================= 1.133 +// The following are NOT user-supplied but are documented here for 1.134 +// completeness. They are calculated by Breakpad during initialization & 1.135 +// crash-dump generation, or entered in by the user. 1.136 +// 1.137 +// BREAKPAD_PROCESS_START_TIME The time, in seconds since the Epoch, the 1.138 +// process started 1.139 +// 1.140 +// BREAKPAD_PROCESS_CRASH_TIME The time, in seconds since the Epoch, the 1.141 +// process crashed. 1.142 +// 1.143 +// BREAKPAD_PROCESS_UP_TIME The total time in milliseconds the process 1.144 +// has been running. This parameter is not 1.145 +// set until the crash-dump-generation phase. 1.146 +// 1.147 +// BREAKPAD_SERVER_PARAMETER_PREFIX This prefix is used by Breakpad 1.148 +// internally, because Breakpad uses 1.149 +// the same dictionary internally to 1.150 +// track both its internal 1.151 +// configuration parameters and 1.152 +// parameters meant to be uploaded 1.153 +// to the server. This string is 1.154 +// used internally by Breakpad to 1.155 +// prefix user-supplied parameter 1.156 +// names so those can be sent to the 1.157 +// server without leaking Breakpad's 1.158 +// internal values. 1.159 + 1.160 +// Returns a new BreakpadRef object on success, NULL otherwise. 1.161 +BreakpadRef BreakpadCreate(NSDictionary *parameters); 1.162 + 1.163 +// Uninstall and release the data associated with |ref|. 1.164 +void BreakpadRelease(BreakpadRef ref); 1.165 + 1.166 +// User defined key and value string storage. Generally this is used 1.167 +// to configure Breakpad's internal operation, such as whether the 1.168 +// crash_sender should prompt the user, or the filesystem location for 1.169 +// the minidump file. See Breakpad.h for some parameters that can be 1.170 +// set. Anything longer than 255 bytes will be truncated. Note that 1.171 +// the string is converted to UTF8 before truncation, so any multibyte 1.172 +// character that straddles the 255(256 - 1 for terminator) byte limit 1.173 +// will be mangled. 1.174 +// 1.175 +// A maximum number of 64 key/value pairs are supported. An assert() 1.176 +// will fire if more than this number are set. Unfortunately, right 1.177 +// now, the same dictionary is used for both Breakpad's parameters AND 1.178 +// the Upload parameters. 1.179 +// 1.180 +// TODO (nealsid): Investigate how necessary this is if we don't 1.181 +// automatically upload parameters to the server anymore. 1.182 +// TODO (nealsid): separate server parameter dictionary from the 1.183 +// dictionary used to configure Breakpad, and document limits for each 1.184 +// independently. 1.185 +void BreakpadSetKeyValue(BreakpadRef ref, NSString *key, NSString *value); 1.186 +NSString *BreakpadKeyValue(BreakpadRef ref, NSString *key); 1.187 +void BreakpadRemoveKeyValue(BreakpadRef ref, NSString *key); 1.188 + 1.189 +// You can use this method to specify parameters that will be uploaded 1.190 +// to the crash server. They will be automatically encoded as 1.191 +// necessary. Note that as mentioned above there are limits on both 1.192 +// the number of keys and their length. 1.193 +void BreakpadAddUploadParameter(BreakpadRef ref, NSString *key, 1.194 + NSString *value); 1.195 + 1.196 +// This method will remove a previously-added parameter from the 1.197 +// upload parameter set. 1.198 +void BreakpadRemoveUploadParameter(BreakpadRef ref, NSString *key); 1.199 + 1.200 +// Method to handle uploading data to the server 1.201 + 1.202 +// Returns if there is some report to send to the server. 1.203 +bool BreakpadHasCrashReportToUpload(BreakpadRef ref); 1.204 + 1.205 +// Upload next report to the server. 1.206 +void BreakpadUploadNextReport(BreakpadRef ref); 1.207 + 1.208 +// Upload a file to the server. |data| is the content of the file to sent. 1.209 +// |server_parameters| is additional server parameters to send. 1.210 +void BreakpadUploadData(BreakpadRef ref, NSData *data, NSString *name, 1.211 + NSDictionary *server_parameters); 1.212 + 1.213 +// Generate a breakpad minidump and configuration file in the dump directory. 1.214 +// The report will be available for uploading. The paths of the created files 1.215 +// are returned in the dictionary. |server_parameters| is additional server 1.216 +// parameters to add in the config file. 1.217 +NSDictionary *BreakpadGenerateReport(BreakpadRef ref, 1.218 + NSDictionary *server_parameters); 1.219 + 1.220 +#ifdef __cplusplus 1.221 +} 1.222 +#endif