1 |
efrain |
1 |
// Copyright 2019 Google
|
|
|
2 |
//
|
|
|
3 |
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
4 |
// you may not use this file except in compliance with the License.
|
|
|
5 |
// You may obtain a copy of the License at
|
|
|
6 |
//
|
|
|
7 |
// http://www.apache.org/licenses/LICENSE-2.0
|
|
|
8 |
//
|
|
|
9 |
// Unless required by applicable law or agreed to in writing, software
|
|
|
10 |
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
11 |
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
12 |
// See the License for the specific language governing permissions and
|
|
|
13 |
// limitations under the License.
|
|
|
14 |
|
|
|
15 |
#pragma once
|
|
|
16 |
|
|
|
17 |
#include <stdbool.h>
|
|
|
18 |
#include <stdint.h>
|
|
|
19 |
|
|
|
20 |
#include "Crashlytics/Crashlytics/Helpers/FIRCLSFeatures.h"
|
|
|
21 |
#include "Crashlytics/Crashlytics/Helpers/FIRCLSFile.h"
|
|
|
22 |
#include "Crashlytics/Shared/FIRCLSMachO/FIRCLSMachO.h"
|
|
|
23 |
|
|
|
24 |
__BEGIN_DECLS
|
|
|
25 |
|
|
|
26 |
// Typically, apps seem to have ~700 binary images loaded
|
|
|
27 |
#define CLS_BINARY_IMAGE_RUNTIME_NODE_COUNT (1024)
|
|
|
28 |
#define CLS_BINARY_IMAGE_RUNTIME_NODE_NAME_SIZE (32)
|
|
|
29 |
#define CLS_BINARY_IMAGE_RUNTIME_NODE_RECORD_NAME 0
|
|
|
30 |
|
|
|
31 |
#define FIRCLSUUIDStringLength (33)
|
|
|
32 |
|
|
|
33 |
typedef struct {
|
|
|
34 |
_Atomic(void*) volatile baseAddress;
|
|
|
35 |
uint64_t size;
|
|
|
36 |
#if CLS_DWARF_UNWINDING_SUPPORTED
|
|
|
37 |
const void* ehFrame;
|
|
|
38 |
#endif
|
|
|
39 |
#if CLS_COMPACT_UNWINDING_SUPPORTED
|
|
|
40 |
const void* unwindInfo;
|
|
|
41 |
#endif
|
|
|
42 |
const void* crashInfo;
|
|
|
43 |
#if CLS_BINARY_IMAGE_RUNTIME_NODE_RECORD_NAME
|
|
|
44 |
char name[CLS_BINARY_IMAGE_RUNTIME_NODE_NAME_SIZE];
|
|
|
45 |
#endif
|
|
|
46 |
} FIRCLSBinaryImageRuntimeNode;
|
|
|
47 |
|
|
|
48 |
typedef struct {
|
|
|
49 |
char uuidString[FIRCLSUUIDStringLength];
|
|
|
50 |
bool encrypted;
|
|
|
51 |
FIRCLSMachOVersion builtSDK;
|
|
|
52 |
FIRCLSMachOVersion minSDK;
|
|
|
53 |
FIRCLSBinaryImageRuntimeNode node;
|
|
|
54 |
struct FIRCLSMachOSlice slice;
|
|
|
55 |
intptr_t vmaddr_slide;
|
|
|
56 |
} FIRCLSBinaryImageDetails;
|
|
|
57 |
|
|
|
58 |
typedef struct {
|
|
|
59 |
const char* path;
|
|
|
60 |
} FIRCLSBinaryImageReadOnlyContext;
|
|
|
61 |
|
|
|
62 |
typedef struct {
|
|
|
63 |
FIRCLSFile file;
|
|
|
64 |
FIRCLSBinaryImageRuntimeNode nodes[CLS_BINARY_IMAGE_RUNTIME_NODE_COUNT];
|
|
|
65 |
} FIRCLSBinaryImageReadWriteContext;
|
|
|
66 |
|
|
|
67 |
void FIRCLSBinaryImageInit(FIRCLSBinaryImageReadOnlyContext* roContext,
|
|
|
68 |
FIRCLSBinaryImageReadWriteContext* rwContext);
|
|
|
69 |
|
|
|
70 |
#if CLS_COMPACT_UNWINDING_SUPPORTED
|
|
|
71 |
bool FIRCLSBinaryImageSafeFindImageForAddress(uintptr_t address,
|
|
|
72 |
FIRCLSBinaryImageRuntimeNode* image);
|
|
|
73 |
bool FIRCLSBinaryImageSafeHasUnwindInfo(FIRCLSBinaryImageRuntimeNode* image);
|
|
|
74 |
#endif
|
|
|
75 |
|
|
|
76 |
bool FIRCLSBinaryImageFindImageForUUID(const char* uuidString,
|
|
|
77 |
FIRCLSBinaryImageDetails* imageDetails);
|
|
|
78 |
|
|
|
79 |
bool FIRCLSBinaryImageRecordMainExecutable(FIRCLSFile* file);
|
|
|
80 |
|
|
|
81 |
__END_DECLS
|