toolkit/crashreporter/google-breakpad/src/client/ios/Breakpad.h

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 // Copyright (c) 2011, Google Inc.
michael@0 2 // All rights reserved.
michael@0 3 //
michael@0 4 // Redistribution and use in source and binary forms, with or without
michael@0 5 // modification, are permitted provided that the following conditions are
michael@0 6 // met:
michael@0 7 //
michael@0 8 // * Redistributions of source code must retain the above copyright
michael@0 9 // notice, this list of conditions and the following disclaimer.
michael@0 10 // * Redistributions in binary form must reproduce the above
michael@0 11 // copyright notice, this list of conditions and the following disclaimer
michael@0 12 // in the documentation and/or other materials provided with the
michael@0 13 // distribution.
michael@0 14 // * Neither the name of Google Inc. nor the names of its
michael@0 15 // contributors may be used to endorse or promote products derived from
michael@0 16 // this software without specific prior written permission.
michael@0 17 //
michael@0 18 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
michael@0 19 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
michael@0 20 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
michael@0 21 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
michael@0 22 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
michael@0 23 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
michael@0 24 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
michael@0 25 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
michael@0 26 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
michael@0 27 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
michael@0 28 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
michael@0 29
michael@0 30 // Framework to provide a simple C API to crash reporting for
michael@0 31 // applications. By default, if any machine-level exception (e.g.,
michael@0 32 // EXC_BAD_ACCESS) occurs, it will be handled by the BreakpadRef
michael@0 33 // object as follows:
michael@0 34 //
michael@0 35 // 1. Create a minidump file (see Breakpad for details)
michael@0 36 // 2. Create a config file.
michael@0 37 //
michael@0 38 // These files can then be uploaded to a server.
michael@0 39
michael@0 40 typedef void *BreakpadRef;
michael@0 41
michael@0 42 #ifdef __cplusplus
michael@0 43 extern "C" {
michael@0 44 #endif
michael@0 45
michael@0 46 #include <Foundation/Foundation.h>
michael@0 47
michael@0 48 #include <client/apple/Framework/BreakpadDefines.h>
michael@0 49
michael@0 50 // The keys in the dictionary returned by |BreakpadGenerateReport|.
michael@0 51 #define BREAKPAD_OUTPUT_DUMP_FILE "BreakpadDumpFile"
michael@0 52 #define BREAKPAD_OUTPUT_CONFIG_FILE "BreakpadConfigFile"
michael@0 53
michael@0 54 // Optional user-defined function to decide if we should handle this crash or
michael@0 55 // forward it along.
michael@0 56 // Return true if you want Breakpad to handle it.
michael@0 57 // Return false if you want Breakpad to skip it
michael@0 58 // The exception handler always returns false, as if SEND_AND_EXIT were false
michael@0 59 // (which means the next exception handler will take the exception)
michael@0 60 typedef bool (*BreakpadFilterCallback)(int exception_type,
michael@0 61 int exception_code,
michael@0 62 mach_port_t crashing_thread,
michael@0 63 void *context);
michael@0 64
michael@0 65 // Create a new BreakpadRef object and install it as an exception
michael@0 66 // handler. The |parameters| will typically be the contents of your
michael@0 67 // bundle's Info.plist.
michael@0 68 //
michael@0 69 // You can also specify these additional keys for customizable behavior:
michael@0 70 // Key: Value:
michael@0 71 // BREAKPAD_PRODUCT Product name (e.g., "MyAwesomeProduct")
michael@0 72 // This one is used as the key to identify
michael@0 73 // the product when uploading. Falls back to
michael@0 74 // CFBundleName if not specified.
michael@0 75 // REQUIRED
michael@0 76 //
michael@0 77 // BREAKPAD_PRODUCT_DISPLAY This is the display name, e.g. a pretty
michael@0 78 // name for the product when the crash_sender
michael@0 79 // pops up UI for the user. Falls back first to
michael@0 80 // CFBundleDisplayName and then to
michael@0 81 // BREAKPAD_PRODUCT if not specified.
michael@0 82 //
michael@0 83 // BREAKPAD_VERSION Product version (e.g., 1.2.3), used
michael@0 84 // as metadata for crash report. Falls back to
michael@0 85 // CFBundleVersion if not specified.
michael@0 86 // REQUIRED
michael@0 87 //
michael@0 88 // BREAKPAD_VENDOR Vendor name, used in UI (e.g. "A report has
michael@0 89 // been created that you can send to <vendor>")
michael@0 90 //
michael@0 91 // BREAKPAD_URL URL destination for reporting
michael@0 92 // REQUIRED
michael@0 93 //
michael@0 94 // BREAKPAD_DUMP_DIRECTORY The directory to store crash-dumps
michael@0 95 // in. By default, we use
michael@0 96 // ~/Library/Cache/Breakpad/<BREAKPAD_PRODUCT>
michael@0 97 // The path you specify here is tilde-expanded.
michael@0 98 //
michael@0 99 // BREAKPAD_SERVER_TYPE A parameter that tells Breakpad how to
michael@0 100 // rewrite the upload parameters for a specific
michael@0 101 // server type. The currently valid values are
michael@0 102 // 'socorro' or 'google'. If you want to add
michael@0 103 // other types, see the function in
michael@0 104 // crash_report_sender.m that maps parameters to
michael@0 105 // URL parameters. Defaults to 'google'.
michael@0 106 //
michael@0 107 // BREAKPAD_SERVER_PARAMETER_DICT A plist dictionary of static
michael@0 108 // parameters that are uploaded to the
michael@0 109 // server. The parameters are sent as
michael@0 110 // is to the crash server. Their
michael@0 111 // content isn't added to the minidump
michael@0 112 // but pass as URL parameters when
michael@0 113 // uploading theminidump to the crash
michael@0 114 // server.
michael@0 115 //=============================================================================
michael@0 116 // The BREAKPAD_PRODUCT, BREAKPAD_VERSION and BREAKPAD_URL are
michael@0 117 // required to have non-NULL values. By default, the BREAKPAD_PRODUCT
michael@0 118 // will be the CFBundleName and the BREAKPAD_VERSION will be the
michael@0 119 // CFBundleVersion when these keys are present in the bundle's
michael@0 120 // Info.plist, which is usually passed in to BreakpadCreate() as an
michael@0 121 // NSDictionary (you could also pass in another dictionary that had
michael@0 122 // the same keys configured). If the BREAKPAD_PRODUCT or
michael@0 123 // BREAKPAD_VERSION are ultimately undefined, BreakpadCreate() will
michael@0 124 // fail. You have been warned.
michael@0 125 //
michael@0 126 // If you are running in a debugger, Breakpad will not install, unless the
michael@0 127 // BREAKPAD_IGNORE_DEBUGGER envionment variable is set and/or non-zero.
michael@0 128 //
michael@0 129 //=============================================================================
michael@0 130 // The following are NOT user-supplied but are documented here for
michael@0 131 // completeness. They are calculated by Breakpad during initialization &
michael@0 132 // crash-dump generation, or entered in by the user.
michael@0 133 //
michael@0 134 // BREAKPAD_PROCESS_START_TIME The time, in seconds since the Epoch, the
michael@0 135 // process started
michael@0 136 //
michael@0 137 // BREAKPAD_PROCESS_CRASH_TIME The time, in seconds since the Epoch, the
michael@0 138 // process crashed.
michael@0 139 //
michael@0 140 // BREAKPAD_PROCESS_UP_TIME The total time in milliseconds the process
michael@0 141 // has been running. This parameter is not
michael@0 142 // set until the crash-dump-generation phase.
michael@0 143 //
michael@0 144 // BREAKPAD_SERVER_PARAMETER_PREFIX This prefix is used by Breakpad
michael@0 145 // internally, because Breakpad uses
michael@0 146 // the same dictionary internally to
michael@0 147 // track both its internal
michael@0 148 // configuration parameters and
michael@0 149 // parameters meant to be uploaded
michael@0 150 // to the server. This string is
michael@0 151 // used internally by Breakpad to
michael@0 152 // prefix user-supplied parameter
michael@0 153 // names so those can be sent to the
michael@0 154 // server without leaking Breakpad's
michael@0 155 // internal values.
michael@0 156
michael@0 157 // Returns a new BreakpadRef object on success, NULL otherwise.
michael@0 158 BreakpadRef BreakpadCreate(NSDictionary *parameters);
michael@0 159
michael@0 160 // Uninstall and release the data associated with |ref|.
michael@0 161 void BreakpadRelease(BreakpadRef ref);
michael@0 162
michael@0 163 // User defined key and value string storage. Generally this is used
michael@0 164 // to configure Breakpad's internal operation, such as whether the
michael@0 165 // crash_sender should prompt the user, or the filesystem location for
michael@0 166 // the minidump file. See Breakpad.h for some parameters that can be
michael@0 167 // set. Anything longer than 255 bytes will be truncated. Note that
michael@0 168 // the string is converted to UTF8 before truncation, so any multibyte
michael@0 169 // character that straddles the 255(256 - 1 for terminator) byte limit
michael@0 170 // will be mangled.
michael@0 171 //
michael@0 172 // A maximum number of 64 key/value pairs are supported. An assert()
michael@0 173 // will fire if more than this number are set. Unfortunately, right
michael@0 174 // now, the same dictionary is used for both Breakpad's parameters AND
michael@0 175 // the Upload parameters.
michael@0 176 //
michael@0 177 // TODO (nealsid): Investigate how necessary this is if we don't
michael@0 178 // automatically upload parameters to the server anymore.
michael@0 179 // TODO (nealsid): separate server parameter dictionary from the
michael@0 180 // dictionary used to configure Breakpad, and document limits for each
michael@0 181 // independently.
michael@0 182 void BreakpadSetKeyValue(BreakpadRef ref, NSString *key, NSString *value);
michael@0 183 NSString *BreakpadKeyValue(BreakpadRef ref, NSString *key);
michael@0 184 void BreakpadRemoveKeyValue(BreakpadRef ref, NSString *key);
michael@0 185
michael@0 186 // You can use this method to specify parameters that will be uploaded
michael@0 187 // to the crash server. They will be automatically encoded as
michael@0 188 // necessary. Note that as mentioned above there are limits on both
michael@0 189 // the number of keys and their length.
michael@0 190 void BreakpadAddUploadParameter(BreakpadRef ref, NSString *key,
michael@0 191 NSString *value);
michael@0 192
michael@0 193 // This method will remove a previously-added parameter from the
michael@0 194 // upload parameter set.
michael@0 195 void BreakpadRemoveUploadParameter(BreakpadRef ref, NSString *key);
michael@0 196
michael@0 197 // Method to handle uploading data to the server
michael@0 198
michael@0 199 // Returns if there is some report to send to the server.
michael@0 200 bool BreakpadHasCrashReportToUpload(BreakpadRef ref);
michael@0 201
michael@0 202 // Upload next report to the server.
michael@0 203 void BreakpadUploadNextReport(BreakpadRef ref);
michael@0 204
michael@0 205 // Upload a file to the server. |data| is the content of the file to sent.
michael@0 206 // |server_parameters| is additional server parameters to send.
michael@0 207 void BreakpadUploadData(BreakpadRef ref, NSData *data, NSString *name,
michael@0 208 NSDictionary *server_parameters);
michael@0 209
michael@0 210 // Generate a breakpad minidump and configuration file in the dump directory.
michael@0 211 // The report will be available for uploading. The paths of the created files
michael@0 212 // are returned in the dictionary. |server_parameters| is additional server
michael@0 213 // parameters to add in the config file.
michael@0 214 NSDictionary *BreakpadGenerateReport(BreakpadRef ref,
michael@0 215 NSDictionary *server_parameters);
michael@0 216
michael@0 217 #ifdef __cplusplus
michael@0 218 }
michael@0 219 #endif

mercurial