2 * Routines to try to provide more useful information in crash dumps.
6 * Wireshark - Network traffic analyzer
7 * By Gerald Combs <gerald@wireshark.org>
8 * Copyright 2006 Gerald Combs
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License
12 * as published by the Free Software Foundation; either version 2
13 * of the License, or (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
29 #include "crash_info.h"
33 * Copyright 2005-2012 Apple Inc. All rights reserved.
35 * IMPORTANT: This Apple software is supplied to you by Apple Computer,
36 * Inc. ("Apple") in consideration of your agreement to the following
37 * terms, and your use, installation, modification or redistribution of
38 * this Apple software constitutes acceptance of these terms. If you do
39 * not agree with these terms, please do not use, install, modify or
40 * redistribute this Apple software.
42 * In consideration of your agreement to abide by the following terms, and
43 * subject to these terms, Apple grants you a personal, non-exclusive
44 * license, under Apple's copyrights in this original Apple software (the
45 * "Apple Software"), to use, reproduce, modify and redistribute the Apple
46 * Software, with or without modifications, in source and/or binary forms;
47 * provided that if you redistribute the Apple Software in its entirety and
48 * without modifications, you must retain this notice and the following
49 * text and disclaimers in all such redistributions of the Apple Software.
50 * Neither the name, trademarks, service marks or logos of Apple Computer,
51 * Inc. may be used to endorse or promote products derived from the Apple
52 * Software without specific prior written permission from Apple. Except
53 * as expressly stated in this notice, no other rights or licenses, express
54 * or implied, are granted by Apple herein, including but not limited to
55 * any patent rights that may be infringed by your derivative works or by
56 * other works in which the Apple Software may be incorporated.
58 * The Apple Software is provided by Apple on an "AS IS" basis. APPLE
59 * MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION
60 * THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS
61 * FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND
62 * OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS.
64 * IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL
65 * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
66 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
67 * INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION,
68 * MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED
69 * AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE),
70 * STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE
71 * POSSIBILITY OF SUCH DAMAGE.
80 * This used to be the way to add an application-specific string to
83 * http://www.allocinit.net/blog/2008/01/04/application-specific-information-in-leopard-crash-reports/
85 * It still appears to work as of OS X 10.8 (Mountain Lion).
87 __private_extern__
char *__crashreporter_info__
= NULL
;
91 * And this appears to be the new way to do it, as of Lion.
92 * However, if we do both, we get the message twice, so we're
93 * not doing this one, for now.
95 * This code was lifted from SVN trunk CUPS.
97 #define _crc_make_getter(attr, type) (type)(gCRAnnotations.attr)
98 #define _crc_make_setter(attr, arg) (gCRAnnotations.attr = (uint64_t)(unsigned long)(arg))
99 #define CRASH_REPORTER_CLIENT_HIDDEN __attribute__((visibility("hidden")))
100 #define CRASHREPORTER_ANNOTATIONS_VERSION 4
101 #define CRASHREPORTER_ANNOTATIONS_SECTION "__crash_info"
104 * Yes, these are all 64-bit, even on 32-bit platforms.
106 * version is presumably the version of this structure.
108 * message and message2 are reported, one after the other,
109 * under "Application Specific Information".
111 * signature_string is reported under "Application Specific
114 * backtrace is reported under "Application Specific Backtrace".
116 * Dunno which versions are supported by which versions of OS X.
118 struct crashreporter_annotations_t
{
119 uint64_t version
; /* unsigned long */
120 uint64_t message
; /* char * */
121 uint64_t signature_string
; /* char * */
122 uint64_t backtrace
; /* char * */
123 uint64_t message2
; /* char * */
124 uint64_t thread
; /* uint64_t */
125 uint64_t dialog_mode
; /* unsigned int */
128 CRASH_REPORTER_CLIENT_HIDDEN
129 struct crashreporter_annotations_t gCRAnnotations
130 __attribute__((section("__DATA," CRASHREPORTER_ANNOTATIONS_SECTION
))) = {
131 CRASHREPORTER_ANNOTATIONS_VERSION
, /* version */
133 0, /* signature_string */
140 #define CRSetCrashLogMessage(m) _crc_make_setter(message, m)
144 ws_add_crash_info(const char *fmt
, ...)
147 char *m
, *old_info
, *new_info
;
150 m
= g_strdup_vprintf(fmt
, ap
);
152 if (__crashreporter_info__
== NULL
)
153 __crashreporter_info__
= m
;
155 old_info
= __crashreporter_info__
;
156 new_info
= g_strdup_printf("%s\n%s", old_info
, m
);
158 __crashreporter_info__
= new_info
;
163 #else /* __APPLE__ */
165 * Perhaps Google Breakpad (http://code.google.com/p/google-breakpad/) or
166 * other options listed at
167 * http://stackoverflow.com/questions/7631908/library-for-logging-call-stack-at-runtime-windows-linux
171 ws_add_crash_info(const char *fmt _U_
, ...)
174 #endif /* __APPLE__ */