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 * SPDX-License-Identifier: GPL-2.0-or-later
13 #include "crash_info.h"
17 * Copyright 2005-2012 Apple Inc. All rights reserved.
19 * IMPORTANT: This Apple software is supplied to you by Apple Computer,
20 * Inc. ("Apple") in consideration of your agreement to the following
21 * terms, and your use, installation, modification or redistribution of
22 * this Apple software constitutes acceptance of these terms. If you do
23 * not agree with these terms, please do not use, install, modify or
24 * redistribute this Apple software.
26 * In consideration of your agreement to abide by the following terms, and
27 * subject to these terms, Apple grants you a personal, non-exclusive
28 * license, under Apple's copyrights in this original Apple software (the
29 * "Apple Software"), to use, reproduce, modify and redistribute the Apple
30 * Software, with or without modifications, in source and/or binary forms;
31 * provided that if you redistribute the Apple Software in its entirety and
32 * without modifications, you must retain this notice and the following
33 * text and disclaimers in all such redistributions of the Apple Software.
34 * Neither the name, trademarks, service marks or logos of Apple Computer,
35 * Inc. may be used to endorse or promote products derived from the Apple
36 * Software without specific prior written permission from Apple. Except
37 * as expressly stated in this notice, no other rights or licenses, express
38 * or implied, are granted by Apple herein, including but not limited to
39 * any patent rights that may be infringed by your derivative works or by
40 * other works in which the Apple Software may be incorporated.
42 * The Apple Software is provided by Apple on an "AS IS" basis. APPLE
43 * MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION
44 * THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS
45 * FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND
46 * OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS.
48 * IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL
49 * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
50 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
51 * INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION,
52 * MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED
53 * AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE),
54 * STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE
55 * POSSIBILITY OF SUCH DAMAGE.
64 * This used to be the way to add an application-specific string to
67 * http://www.allocinit.net/blog/2008/01/04/application-specific-information-in-leopard-crash-reports/
69 * It still appears to work as of OS X 10.8 (Mountain Lion).
71 __private_extern__
char *__crashreporter_info__
= NULL
;
75 * And this appears to be the new way to do it, as of Lion.
76 * However, if we do both, we get the message twice, so we're
77 * not doing this one, for now.
79 * This code was lifted from SVN trunk CUPS.
81 #define _crc_make_getter(attr, type) (type)(gCRAnnotations.attr)
82 #define _crc_make_setter(attr, arg) (gCRAnnotations.attr = (uint64_t)(unsigned long)(arg))
83 #define CRASH_REPORTER_CLIENT_HIDDEN __attribute__((visibility("hidden")))
84 #define CRASHREPORTER_ANNOTATIONS_VERSION 4
85 #define CRASHREPORTER_ANNOTATIONS_SECTION "__crash_info"
88 * Yes, these are all 64-bit, even on 32-bit platforms.
90 * version is presumably the version of this structure.
92 * message and message2 are reported, one after the other,
93 * under "Application Specific Information".
95 * signature_string is reported under "Application Specific
98 * backtrace is reported under "Application Specific Backtrace".
100 * Dunno which versions are supported by which versions of macOS.
102 struct crashreporter_annotations_t
{
103 uint64_t version
; /* unsigned long */
104 uint64_t message
; /* char * */
105 uint64_t signature_string
; /* char * */
106 uint64_t backtrace
; /* char * */
107 uint64_t message2
; /* char * */
108 uint64_t thread
; /* uint64_t */
109 uint64_t dialog_mode
; /* unsigned int */
112 CRASH_REPORTER_CLIENT_HIDDEN
113 struct crashreporter_annotations_t gCRAnnotations
114 __attribute__((section("__DATA," CRASHREPORTER_ANNOTATIONS_SECTION
))) = {
115 CRASHREPORTER_ANNOTATIONS_VERSION
, /* version */
117 0, /* signature_string */
124 #define CRSetCrashLogMessage(m) _crc_make_setter(message, m)
128 ws_vadd_crash_info(const char *fmt
, va_list ap
)
130 char *m
, *old_info
, *new_info
;
132 m
= ws_strdup_vprintf(fmt
, ap
);
133 if (__crashreporter_info__
== NULL
)
134 __crashreporter_info__
= m
;
136 old_info
= __crashreporter_info__
;
137 new_info
= ws_strdup_printf("%s\n%s", old_info
, m
);
139 __crashreporter_info__
= new_info
;
144 #else /* __APPLE__ */
146 * Perhaps Google Breakpad (http://code.google.com/p/google-breakpad/) or
147 * other options listed at
148 * http://stackoverflow.com/questions/7631908/library-for-logging-call-stack-at-runtime-windows-linux
152 ws_vadd_crash_info(const char *fmt _U_
, va_list ap _U_
)
155 #endif /* __APPLE__ */
158 ws_add_crash_info(const char *fmt
, ...)
163 ws_vadd_crash_info(fmt
, ap
);
168 * Editor modelines - https://www.wireshark.org/tools/modelines.html
173 * indent-tabs-mode: t
176 * vi: set shiftwidth=8 tabstop=8 noexpandtab:
177 * :indentSize=8:tabSize=8:noTabs=false: