toolkit/crashreporter/google-breakpad/src/client/mac/Framework/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) 2006, 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. Prompt the user (using CFUserNotification)
michael@0 37 // 3. Invoke a command line reporting tool to send the minidump to a
michael@0 38 // server
michael@0 39 //
michael@0 40 // By specifying parameters to the BreakpadCreate function, you can
michael@0 41 // modify the default behavior to suit your needs and wants and
michael@0 42 // desires.
michael@0 43
michael@0 44 // A service name associated with the original bootstrap parent port, saved in
michael@0 45 // OnDemandServer and restored in Inspector.
michael@0 46 #define BREAKPAD_BOOTSTRAP_PARENT_PORT "com.Breakpad.BootstrapParent"
michael@0 47
michael@0 48 typedef void *BreakpadRef;
michael@0 49
michael@0 50 #ifdef __cplusplus
michael@0 51 extern "C" {
michael@0 52 #endif
michael@0 53
michael@0 54 #include <CoreFoundation/CoreFoundation.h>
michael@0 55 #include <Foundation/Foundation.h>
michael@0 56
michael@0 57 #include "BreakpadDefines.h"
michael@0 58
michael@0 59 // Optional user-defined function to dec to decide if we should handle
michael@0 60 // this crash or forward it along.
michael@0 61 // Return true if you want Breakpad to handle it.
michael@0 62 // Return false if you want Breakpad to skip it
michael@0 63 // The exception handler always returns false, as if SEND_AND_EXIT were false
michael@0 64 // (which means the next exception handler will take the exception)
michael@0 65 typedef bool (*BreakpadFilterCallback)(int exception_type,
michael@0 66 int exception_code,
michael@0 67 mach_port_t crashing_thread,
michael@0 68 void *context);
michael@0 69
michael@0 70 // Create a new BreakpadRef object and install it as an exception
michael@0 71 // handler. The |parameters| will typically be the contents of your
michael@0 72 // bundle's Info.plist.
michael@0 73 //
michael@0 74 // You can also specify these additional keys for customizable behavior:
michael@0 75 // Key: Value:
michael@0 76 // BREAKPAD_PRODUCT Product name (e.g., "MyAwesomeProduct")
michael@0 77 // This one is used as the key to identify
michael@0 78 // the product when uploading. Falls back to
michael@0 79 // CFBundleName if not specified.
michael@0 80 // REQUIRED
michael@0 81 //
michael@0 82 // BREAKPAD_PRODUCT_DISPLAY This is the display name, e.g. a pretty
michael@0 83 // name for the product when the crash_sender
michael@0 84 // pops up UI for the user. Falls back first to
michael@0 85 // CFBundleDisplayName and then to
michael@0 86 // BREAKPAD_PRODUCT if not specified.
michael@0 87 //
michael@0 88 // BREAKPAD_VERSION Product version (e.g., 1.2.3), used
michael@0 89 // as metadata for crash report. Falls back to
michael@0 90 // CFBundleVersion if not specified.
michael@0 91 // REQUIRED
michael@0 92 //
michael@0 93 // BREAKPAD_VENDOR Vendor name, used in UI (e.g. "A report has
michael@0 94 // been created that you can send to <vendor>")
michael@0 95 //
michael@0 96 // BREAKPAD_URL URL destination for reporting
michael@0 97 // REQUIRED
michael@0 98 //
michael@0 99 // BREAKPAD_REPORT_INTERVAL # of seconds between sending
michael@0 100 // reports. If an additional report is
michael@0 101 // generated within this time, it will
michael@0 102 // be ignored. Default: 3600sec.
michael@0 103 // Specify 0 to send all reports.
michael@0 104 //
michael@0 105 // BREAKPAD_SKIP_CONFIRM If true, the reporter will send the report
michael@0 106 // without any user intervention.
michael@0 107 // Defaults to NO
michael@0 108 //
michael@0 109 // BREAKPAD_CONFIRM_TIMEOUT Number of seconds before the upload
michael@0 110 // confirmation dialog will be automatically
michael@0 111 // dismissed (cancelling the upload).
michael@0 112 // Default: 300 seconds (min of 60).
michael@0 113 // Specify 0 to prevent timeout.
michael@0 114 //
michael@0 115 // BREAKPAD_SEND_AND_EXIT If true, the handler will exit after sending.
michael@0 116 // This will prevent any other handler (e.g.,
michael@0 117 // CrashReporter) from getting the crash.
michael@0 118 // Defaults TO YES
michael@0 119 //
michael@0 120 // BREAKPAD_DUMP_DIRECTORY The directory to store crash-dumps
michael@0 121 // in. By default, we use
michael@0 122 // ~/Library/Breakpad/<BREAKPAD_PRODUCT>
michael@0 123 // The path you specify here is tilde-expanded.
michael@0 124 //
michael@0 125 // BREAKPAD_INSPECTOR_LOCATION The full path to the Inspector executable.
michael@0 126 // Defaults to <Framework resources>/Inspector
michael@0 127 //
michael@0 128 // BREAKPAD_REPORTER_EXE_LOCATION The full path to the Reporter/sender
michael@0 129 // executable.
michael@0 130 // Default:
michael@0 131 // <Framework Resources>/crash_report_sender.app
michael@0 132 //
michael@0 133 // BREAKPAD_LOGFILES Indicates an array of log file paths that
michael@0 134 // should be uploaded at crash time.
michael@0 135 //
michael@0 136 // BREAKPAD_REQUEST_COMMENTS If true, the message dialog will have a
michael@0 137 // text box for the user to enter comments.
michael@0 138 // Default: NO
michael@0 139 //
michael@0 140 // BREAKPAD_REQUEST_EMAIL If true and BREAKPAD_REQUEST_COMMENTS is also
michael@0 141 // true, the message dialog will have a text
michael@0 142 // box for the user to enter their email address.
michael@0 143 // Default: NO
michael@0 144 //
michael@0 145 // BREAKPAD_SERVER_TYPE A parameter that tells Breakpad how to
michael@0 146 // rewrite the upload parameters for a specific
michael@0 147 // server type. The currently valid values are
michael@0 148 // 'socorro' or 'google'. If you want to add
michael@0 149 // other types, see the function in
michael@0 150 // crash_report_sender.m that maps parameters to
michael@0 151 // URL parameters. Defaults to 'google'.
michael@0 152 //
michael@0 153 // BREAKPAD_SERVER_PARAMETER_DICT A plist dictionary of static
michael@0 154 // parameters that are uploaded to the
michael@0 155 // server. The parameters are sent as
michael@0 156 // is to the crash server. Their
michael@0 157 // content isn't added to the minidump
michael@0 158 // but pass as URL parameters when
michael@0 159 // uploading theminidump to the crash
michael@0 160 // server.
michael@0 161 //=============================================================================
michael@0 162 // The BREAKPAD_PRODUCT, BREAKPAD_VERSION and BREAKPAD_URL are
michael@0 163 // required to have non-NULL values. By default, the BREAKPAD_PRODUCT
michael@0 164 // will be the CFBundleName and the BREAKPAD_VERSION will be the
michael@0 165 // CFBundleVersion when these keys are present in the bundle's
michael@0 166 // Info.plist, which is usually passed in to BreakpadCreate() as an
michael@0 167 // NSDictionary (you could also pass in another dictionary that had
michael@0 168 // the same keys configured). If the BREAKPAD_PRODUCT or
michael@0 169 // BREAKPAD_VERSION are ultimately undefined, BreakpadCreate() will
michael@0 170 // fail. You have been warned.
michael@0 171 //
michael@0 172 // If you are running in a debugger, Breakpad will not install, unless the
michael@0 173 // BREAKPAD_IGNORE_DEBUGGER envionment variable is set and/or non-zero.
michael@0 174 //
michael@0 175 // The BREAKPAD_SKIP_CONFIRM and BREAKPAD_SEND_AND_EXIT default
michael@0 176 // values are NO and YES. However, they can be controlled by setting their
michael@0 177 // values in a user or global plist.
michael@0 178 //
michael@0 179 // It's easiest to use Breakpad via the Framework, but if you're compiling the
michael@0 180 // code in directly, BREAKPAD_INSPECTOR_LOCATION and
michael@0 181 // BREAKPAD_REPORTER_EXE_LOCATION allow you to specify custom paths
michael@0 182 // to the helper executables.
michael@0 183 //
michael@0 184 //=============================================================================
michael@0 185 // The following are NOT user-supplied but are documented here for
michael@0 186 // completeness. They are calculated by Breakpad during initialization &
michael@0 187 // crash-dump generation, or entered in by the user.
michael@0 188 //
michael@0 189 // BREAKPAD_PROCESS_START_TIME The time, in seconds since the Epoch, the
michael@0 190 // process started
michael@0 191 //
michael@0 192 // BREAKPAD_PROCESS_CRASH_TIME The time, in seconds since the Epoch, the
michael@0 193 // process crashed.
michael@0 194 //
michael@0 195 // BREAKPAD_PROCESS_UP_TIME The total time in milliseconds the process
michael@0 196 // has been running. This parameter is not
michael@0 197 // set until the crash-dump-generation phase.
michael@0 198 //
michael@0 199 // BREAKPAD_LOGFILE_KEY_PREFIX Used to find out which parameters in the
michael@0 200 // parameter dictionary correspond to log
michael@0 201 // file paths.
michael@0 202 //
michael@0 203 // BREAKPAD_SERVER_PARAMETER_PREFIX This prefix is used by Breakpad
michael@0 204 // internally, because Breakpad uses
michael@0 205 // the same dictionary internally to
michael@0 206 // track both its internal
michael@0 207 // configuration parameters and
michael@0 208 // parameters meant to be uploaded
michael@0 209 // to the server. This string is
michael@0 210 // used internally by Breakpad to
michael@0 211 // prefix user-supplied parameter
michael@0 212 // names so those can be sent to the
michael@0 213 // server without leaking Breakpad's
michael@0 214 // internal values.
michael@0 215 //
michael@0 216 // BREAKPAD_ON_DEMAND Used internally to indicate to the
michael@0 217 // Reporter that we're sending on-demand,
michael@0 218 // not as result of a crash.
michael@0 219 //
michael@0 220 // BREAKPAD_COMMENTS The text the user provided as comments.
michael@0 221 // Only used in crash_report_sender.
michael@0 222
michael@0 223 // Returns a new BreakpadRef object on success, NULL otherwise.
michael@0 224 BreakpadRef BreakpadCreate(NSDictionary *parameters);
michael@0 225
michael@0 226 // Uninstall and release the data associated with |ref|.
michael@0 227 void BreakpadRelease(BreakpadRef ref);
michael@0 228
michael@0 229 // Clients may set an optional callback which gets called when a crash
michael@0 230 // occurs. The callback function should return |true| if we should
michael@0 231 // handle the crash, generate a crash report, etc. or |false| if we
michael@0 232 // should ignore it and forward the crash (normally to CrashReporter).
michael@0 233 // Context is a pointer to arbitrary data to make the callback with.
michael@0 234 void BreakpadSetFilterCallback(BreakpadRef ref,
michael@0 235 BreakpadFilterCallback callback,
michael@0 236 void *context);
michael@0 237
michael@0 238 // User defined key and value string storage. Generally this is used
michael@0 239 // to configure Breakpad's internal operation, such as whether the
michael@0 240 // crash_sender should prompt the user, or the filesystem location for
michael@0 241 // the minidump file. See Breakpad.h for some parameters that can be
michael@0 242 // set. Anything longer than 255 bytes will be truncated. Note that
michael@0 243 // the string is converted to UTF8 before truncation, so any multibyte
michael@0 244 // character that straddles the 255(256 - 1 for terminator) byte limit
michael@0 245 // will be mangled.
michael@0 246 //
michael@0 247 // A maximum number of 64 key/value pairs are supported. An assert()
michael@0 248 // will fire if more than this number are set. Unfortunately, right
michael@0 249 // now, the same dictionary is used for both Breakpad's parameters AND
michael@0 250 // the Upload parameters.
michael@0 251 //
michael@0 252 // TODO (nealsid): Investigate how necessary this is if we don't
michael@0 253 // automatically upload parameters to the server anymore.
michael@0 254 // TODO (nealsid): separate server parameter dictionary from the
michael@0 255 // dictionary used to configure Breakpad, and document limits for each
michael@0 256 // independently.
michael@0 257 void BreakpadSetKeyValue(BreakpadRef ref, NSString *key, NSString *value);
michael@0 258 NSString *BreakpadKeyValue(BreakpadRef ref, NSString *key);
michael@0 259 void BreakpadRemoveKeyValue(BreakpadRef ref, NSString *key);
michael@0 260
michael@0 261 // You can use this method to specify parameters that will be uploaded
michael@0 262 // to the crash server. They will be automatically encoded as
michael@0 263 // necessary. Note that as mentioned above there are limits on both
michael@0 264 // the number of keys and their length.
michael@0 265 void BreakpadAddUploadParameter(BreakpadRef ref, NSString *key,
michael@0 266 NSString *value);
michael@0 267
michael@0 268 // This method will remove a previously-added parameter from the
michael@0 269 // upload parameter set.
michael@0 270 void BreakpadRemoveUploadParameter(BreakpadRef ref, NSString *key);
michael@0 271
michael@0 272 // Add a log file for Breakpad to read and send upon crash dump
michael@0 273 void BreakpadAddLogFile(BreakpadRef ref, NSString *logPathname);
michael@0 274
michael@0 275 // Generate a minidump and send
michael@0 276 void BreakpadGenerateAndSendReport(BreakpadRef ref);
michael@0 277
michael@0 278 #ifdef __cplusplus
michael@0 279 }
michael@0 280 #endif

mercurial