PageRenderTime 32ms CodeModel.GetById 24ms app.highlight 4ms RepoModel.GetById 1ms app.codeStats 0ms

/thirdparty/breakpad/common/mac/macho_utilities.h

http://github.com/tomahawk-player/tomahawk
C++ Header | 92 lines | 39 code | 15 blank | 38 comment | 0 complexity | 62dcb9a7858714ca59a6d89188f95499 MD5 | raw file
 1// Copyright (c) 2006, Google Inc.
 2// All rights reserved.
 3//
 4// Redistribution and use in source and binary forms, with or without
 5// modification, are permitted provided that the following conditions are
 6// met:
 7//
 8//     * Redistributions of source code must retain the above copyright
 9// notice, this list of conditions and the following disclaimer.
10//     * Redistributions in binary form must reproduce the above
11// copyright notice, this list of conditions and the following disclaimer
12// in the documentation and/or other materials provided with the
13// distribution.
14//     * Neither the name of Google Inc. nor the names of its
15// contributors may be used to endorse or promote products derived from
16// this software without specific prior written permission.
17//
18// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29
30// macho_utilities.h: Utilities for dealing with mach-o files
31//
32// Author: Dave Camp
33
34#ifndef COMMON_MAC_MACHO_UTILITIES_H__
35#define COMMON_MAC_MACHO_UTILITIES_H__
36
37#include <mach-o/loader.h>
38#include <mach/thread_status.h>
39
40/* Some #defines and structs that aren't defined in older SDKs */
41#ifndef CPU_ARCH_ABI64
42# define CPU_ARCH_ABI64    0x01000000
43#endif
44
45#ifndef CPU_TYPE_X86
46# define CPU_TYPE_X86 CPU_TYPE_I386
47#endif
48
49#ifndef CPU_TYPE_POWERPC64
50# define CPU_TYPE_POWERPC64 (CPU_TYPE_POWERPC | CPU_ARCH_ABI64)
51#endif
52
53#ifndef LC_UUID
54# define LC_UUID         0x1b    /* the uuid */
55#endif
56
57#if TARGET_CPU_X86
58# define BREAKPAD_MACHINE_THREAD_STATE i386_THREAD_STATE
59#elif TARGET_CPU_X86_64
60# define BREAKPAD_MACHINE_THREAD_STATE x86_THREAD_STATE64
61#else
62# define BREAKPAD_MACHINE_THREAD_STATE MACHINE_THREAD_STATE
63#endif
64
65// The uuid_command struct/swap routines were added during the 10.4 series.
66// Their presence isn't guaranteed.
67struct breakpad_uuid_command {
68  uint32_t    cmd;            /* LC_UUID */
69  uint32_t    cmdsize;        /* sizeof(struct uuid_command) */
70  uint8_t     uuid[16];       /* the 128-bit uuid */
71};
72
73void breakpad_swap_uuid_command(struct breakpad_uuid_command *uc,
74                                enum NXByteOrder target_byte_order);
75
76// Older SDKs defines thread_state_data_t as an int[] instead
77// of the natural_t[] it should be.
78typedef natural_t breakpad_thread_state_data_t[THREAD_STATE_MAX];
79
80// The 64-bit swap routines were added during the 10.4 series, their
81// presence isn't guaranteed.
82void breakpad_swap_segment_command_64(struct segment_command_64 *sg,
83                                      enum NXByteOrder target_byte_order);
84
85void breakpad_swap_mach_header_64(struct mach_header_64 *mh,
86                                  enum NXByteOrder target_byte_order);
87
88void breakpad_swap_section_64(struct section_64 *s,
89                              uint32_t nsects,
90                              enum NXByteOrder target_byte_order);
91
92#endif