File: MoreAddrToSym.h

package info (click to toggle)
openmpi 1.6.5-9.1%2Bdeb8u1
  • links: PTS, VCS
  • area: main
  • in suites: jessie
  • size: 91,628 kB
  • ctags: 44,305
  • sloc: ansic: 408,966; cpp: 44,454; sh: 27,828; makefile: 10,486; asm: 3,882; python: 1,239; lex: 805; perl: 549; csh: 253; fortran: 232; f90: 126; tcl: 12
file content (143 lines) | stat: -rw-r--r-- 5,541 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
/*
	File:		MoreAddrToSym.h

	Contains:	Code for mapping addresses to their symbolic names.

	Written by:	DTS

	Copyright:	Copyright (c) 2006 by Apple Computer, Inc., All Rights Reserved.

	Disclaimer:	IMPORTANT:  This Apple software is supplied to you by Apple Computer, Inc.
				("Apple") in consideration of your agreement to the following terms, and your
				use, installation, modification or redistribution of this Apple software
				constitutes acceptance of these terms.  If you do not agree with these terms,
				please do not use, install, modify or redistribute this Apple software.

				In consideration of your agreement to abide by the following terms, and subject
				to these terms, Apple grants you a personal, non-exclusive license, under Apples
				copyrights in this original Apple software (the "Apple Software"), to use,
				reproduce, modify and redistribute the Apple Software, with or without
				modifications, in source and/or binary forms; provided that if you redistribute
				the Apple Software in its entirety and without modifications, you must retain
				this notice and the following text and disclaimers in all such redistributions of
				the Apple Software.  Neither the name, trademarks, service marks or logos of
				Apple Computer, Inc. may be used to endorse or promote products derived from the
				Apple Software without specific prior written permission from Apple.  Except as
				expressly stated in this notice, no other rights or licenses, express or implied,
				are granted by Apple herein, including but not limited to any patent rights that
				may be infringed by your derivative works or by other works in which the Apple
				Software may be incorporated.

				The Apple Software is provided by Apple on an "AS IS" basis.  APPLE MAKES NO
				WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED
				WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
				PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN
				COMBINATION WITH YOUR PRODUCTS.

				IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR
				CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
				GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
				ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION
				OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT
				(INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN
				ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

	Change History (most recent first):

$Log: MoreAddrToSym.h,v $
Revision 1.2  2006/01/22 22:47:15  eskimo1
Significant rewrite to account for changes in MoreBacktrace.  Still not as functional as I'd like.

Revision 1.1  2003/04/04 15:03:00  eskimo1
First checked in.  This code still has bugs, but I've written enough code that checking in is a good idea.


*/

#pragma once

/////////////////////////////////////////////////////////////////

// MoreIsBetter Setup

#include "MoreSetup.h"

// Mac OS Interfaces

#include <stdint.h>
#include <stdlib.h>

/////////////////////////////////////////////////////////////////

#ifdef __cplusplus
extern "C" {
#endif

// IMPORTANT:
// This code is currently broken in two ways:
// 
// o If the binary has debugging symbols, you often get a debugging 
//   symbol rather than a real symbol.  I believe this is caused by 
//   handling of N_FUN in the GetFunctionName routine.  Furthermore, 
//   I believe that it did work previous but something changed in the 
//   Mach-O headers to break it.  This warrants serious investigation. 
//
//   You can work around this problem by removing the debug symbols 
//   using:
//
//   $ strip -S YourBinaryName
//
// o It doesn't handle 64-bit Mach-O binaries.  This is a simple 
//   limitation of the code, and it should be relatively easy to fix.
//
// I intend to fix both of these problems with a future rewrite.  
// Until then, I've decided to live with them.

typedef uint64_t MoreAToSAddr;
typedef uint64_t MoreAToSOffset;

enum MoreAToSSymbolType {
	kMoreAToSNoSymbol = 0,
	kMoreAToSDyldPubliSymbol,
	kMoreAToSDyldPrivateSymbol
};
typedef enum MoreAToSSymbolType MoreAToSSymbolType;

struct MoreAToSSymInfo {
	MoreAToSSymbolType	symbolType;
	const char *		symbolName;
	MoreAToSOffset		symbolOffset;
};
typedef struct MoreAToSSymInfo MoreAToSSymInfo;

extern int  MoreAToSCreate(size_t count, MoreAToSSymInfo *symbols[]);
	// Creates a blank MoreAToSSymInfo array with count entries.
	// You must dispose of it using MoreAToSDestroy.
	// 
	// symbols must not be NULL
	// *symbols must be NULL
	// Returns 0 on success, an errno-style error code otherwise
	// On success, *symbols will not be NULL
	// On error, *symbols will be NULL
	
extern void MoreAToSDestroy(size_t count, MoreAToSSymInfo symbols[]);
	// Destroys a MoreAToSDestroy array (blank or filled in) of 
	// count entries.

extern int MoreAToSCopySymbolNamesUsingDyld(
	size_t			count, 
	MoreAToSAddr 	addresses[],
	MoreAToSSymInfo symbols[]
);
	// Given count values in the addresses array, works out the symbolic 
	// information for those values and returns it in the symbols array. 
	//
	// Returns 0 on success, an errno-style error code otherwise
	//
	// Note that not being able to map an address to a symbol is not 
	// considered an error.  Rather, you get NULL back in the symbolName
	// field of the corresponding symbols array element.

#ifdef __cplusplus
}
#endif