Deleted Added
full compact
backtrace.c (234010) backtrace.c (262706)
1/*
1/*
2 * Copyright (C) 2009 Internet Systems Consortium, Inc. ("ISC")
2 * Copyright (C) 2009, 2013 Internet Systems Consortium, Inc. ("ISC")
3 *
4 * Permission to use, copy, modify, and/or distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
7 *
8 * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
9 * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
10 * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,

--- 35 unchanged lines hidden (view full) ---

46 * the RBP register in such a case. If the backtrace function itself crashes
47 * due to this problem, the whole package should be rebuilt with
48 * --disable-backtrace.
49 */
50#ifdef HAVE_LIBCTRACE
51#define BACKTRACE_LIBC
52#elif defined(__GNUC__) && (defined(__x86_64__) || defined(__ia64__))
53#define BACKTRACE_GCC
3 *
4 * Permission to use, copy, modify, and/or distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
7 *
8 * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
9 * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
10 * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,

--- 35 unchanged lines hidden (view full) ---

46 * the RBP register in such a case. If the backtrace function itself crashes
47 * due to this problem, the whole package should be rebuilt with
48 * --disable-backtrace.
49 */
50#ifdef HAVE_LIBCTRACE
51#define BACKTRACE_LIBC
52#elif defined(__GNUC__) && (defined(__x86_64__) || defined(__ia64__))
53#define BACKTRACE_GCC
54#elif defined(WIN32)
55#define BACKTRACE_WIN32
54#elif defined(__x86_64__) || defined(__i386__)
55#define BACKTRACE_X86STACK
56#else
57#define BACKTRACE_DISABLED
58#endif /* HAVE_LIBCTRACE */
59#else /* !ISC_PLATFORM_USEBACKTRACE */
60#define BACKTRACE_DISABLED
61#endif /* ISC_PLATFORM_USEBACKTRACE */

--- 60 unchanged lines hidden (view full) ---

122 arg.max_depth = maxaddrs;
123 arg.count = 0;
124 _Unwind_Backtrace(btcallback, &arg);
125
126 *nframes = arg.count;
127
128 return (ISC_R_SUCCESS);
129}
56#elif defined(__x86_64__) || defined(__i386__)
57#define BACKTRACE_X86STACK
58#else
59#define BACKTRACE_DISABLED
60#endif /* HAVE_LIBCTRACE */
61#else /* !ISC_PLATFORM_USEBACKTRACE */
62#define BACKTRACE_DISABLED
63#endif /* ISC_PLATFORM_USEBACKTRACE */

--- 60 unchanged lines hidden (view full) ---

124 arg.max_depth = maxaddrs;
125 arg.count = 0;
126 _Unwind_Backtrace(btcallback, &arg);
127
128 *nframes = arg.count;
129
130 return (ISC_R_SUCCESS);
131}
132#elif defined(BACKTRACE_WIN32)
133isc_result_t
134isc_backtrace_gettrace(void **addrs, int maxaddrs, int *nframes) {
135 unsigned long ftc = (unsigned long)maxaddrs;
136
137 *nframes = (int)CaptureStackBackTrace(1, ftc, addrs, NULL);
138 return ISC_R_SUCCESS;
139}
130#elif defined(BACKTRACE_X86STACK)
131#ifdef __x86_64__
132static unsigned long
133getrbp() {
134 __asm("movq %rbp, %rax\n");
135}
136#endif
137

--- 135 unchanged lines hidden (view full) ---

273 * entry.addr <= addr < next_entry.addr.
274 */
275 found = bsearch(addr, isc__backtrace_symtable, isc__backtrace_nsymbols,
276 sizeof(isc__backtrace_symtable[0]), symtbl_compare);
277 if (found == NULL)
278 result = ISC_R_NOTFOUND;
279 else {
280 *symbolp = found->symbol;
140#elif defined(BACKTRACE_X86STACK)
141#ifdef __x86_64__
142static unsigned long
143getrbp() {
144 __asm("movq %rbp, %rax\n");
145}
146#endif
147

--- 135 unchanged lines hidden (view full) ---

283 * entry.addr <= addr < next_entry.addr.
284 */
285 found = bsearch(addr, isc__backtrace_symtable, isc__backtrace_nsymbols,
286 sizeof(isc__backtrace_symtable[0]), symtbl_compare);
287 if (found == NULL)
288 result = ISC_R_NOTFOUND;
289 else {
290 *symbolp = found->symbol;
281 *offsetp = (const char *)addr - (char *)found->addr;
291 *offsetp = (unsigned long) ((const char *)addr -
292 (char *)found->addr);
282 }
283
284 return (result);
285}
293 }
294
295 return (result);
296}