Proyectos de Subversion Iphone Microlearning

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
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
#include "Crashlytics/Crashlytics/Helpers/FIRCLSFeatures.h"
16
 
17
#pragma once
18
 
19
#if CLS_MACH_EXCEPTION_SUPPORTED
20
 
21
#include <mach/mach.h>
22
#include <pthread.h>
23
#include <stdbool.h>
24
 
25
// must be at least PTHREAD_STACK_MIN size
26
#define CLS_MACH_EXCEPTION_HANDLER_STACK_SIZE (256 * 1024)
27
 
28
#pragma mark Structures
29
#pragma pack(push, 4)
30
typedef struct {
31
  mach_msg_header_t head;
32
  /* start of the kernel processed data */
33
  mach_msg_body_t msgh_body;
34
  mach_msg_port_descriptor_t thread;
35
  mach_msg_port_descriptor_t task;
36
  /* end of the kernel processed data */
37
  NDR_record_t NDR;
38
  exception_type_t exception;
39
  mach_msg_type_number_t codeCnt;
40
  mach_exception_data_type_t code[EXCEPTION_CODE_MAX];
41
  mach_msg_trailer_t trailer;
42
} MachExceptionMessage;
43
 
44
typedef struct {
45
  mach_msg_header_t head;
46
  NDR_record_t NDR;
47
  kern_return_t retCode;
48
} MachExceptionReply;
49
#pragma pack(pop)
50
 
51
typedef struct {
52
  mach_msg_type_number_t count;
53
  exception_mask_t masks[EXC_TYPES_COUNT];
54
  exception_handler_t ports[EXC_TYPES_COUNT];
55
  exception_behavior_t behaviors[EXC_TYPES_COUNT];
56
  thread_state_flavor_t flavors[EXC_TYPES_COUNT];
57
} FIRCLSMachExceptionOriginalPorts;
58
 
59
typedef struct {
60
  mach_port_t port;
61
  pthread_t thread;
62
  const char* path;
63
 
64
  exception_mask_t mask;
65
  FIRCLSMachExceptionOriginalPorts originalPorts;
66
} FIRCLSMachExceptionReadContext;
67
 
68
#pragma mark - API
69
void FIRCLSMachExceptionInit(FIRCLSMachExceptionReadContext* context);
70
 
71
void FIRCLSMachExceptionCheckHandlers(void);
72
 
73
void FIRCLSMachExceptionNameLookup(exception_type_t number,
74
                                   mach_exception_data_type_t code,
75
                                   const char** name,
76
                                   const char** codeName);
77
#else
78
 
79
#define CLS_MACH_EXCEPTION_HANDLER_STACK_SIZE 0
80
 
81
#endif