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