Proyectos de Subversion Iphone Microlearning

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1 efrain 1
// Copyright 2020 Google LLC
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
#import "Crashlytics/Crashlytics/Private/FIRStackFrame_Private.h"
16
 
17
@interface FIRStackFrame ()
18
 
19
@property(nonatomic, copy, nullable) NSString *symbol;
20
@property(nonatomic, copy, nullable) NSString *rawSymbol;
21
@property(nonatomic, copy, nullable) NSString *library;
22
@property(nonatomic, copy, nullable) NSString *fileName;
23
@property(nonatomic, assign) uint32_t lineNumber;
24
@property(nonatomic, assign) uint64_t offset;
25
@property(nonatomic, assign) uint64_t address;
26
 
27
@property(nonatomic, assign) BOOL isSymbolicated;
28
 
29
@end
30
 
31
@implementation FIRStackFrame
32
 
33
#pragma mark - Public Methods
34
 
35
- (instancetype)initWithSymbol:(NSString *)symbol file:(NSString *)file line:(NSInteger)line {
36
  self = [super init];
37
  if (!self) {
38
    return nil;
39
  }
40
 
41
  _symbol = [symbol copy];
42
  _fileName = [file copy];
43
  _lineNumber = (uint32_t)line;
44
 
45
  _isSymbolicated = true;
46
 
47
  return self;
48
}
49
 
50
+ (instancetype)stackFrameWithAddress:(NSUInteger)address {
51
  FIRStackFrame *frame = [self stackFrame];
52
 
53
  [frame setAddress:address];
54
 
55
  return frame;
56
}
57
 
58
+ (instancetype)stackFrameWithSymbol:(NSString *)symbol file:(NSString *)file line:(NSInteger)line {
59
  return [[FIRStackFrame alloc] initWithSymbol:symbol file:file line:line];
60
}
61
 
62
#pragma mark - Internal Methods
63
 
64
+ (instancetype)stackFrame {
65
  return [[self alloc] init];
66
}
67
 
68
+ (instancetype)stackFrameWithSymbol:(NSString *)symbol {
69
  FIRStackFrame *frame = [self stackFrame];
70
 
71
  frame.symbol = symbol;
72
  frame.rawSymbol = symbol;
73
 
74
  return frame;
75
}
76
 
77
#pragma mark - Overrides
78
 
79
- (NSString *)description {
80
  if (self.isSymbolicated) {
81
    return [NSString
82
        stringWithFormat:@"{%@ - %@:%u}", [self fileName], [self symbol], [self lineNumber]];
83
  }
84
 
85
  if (self.fileName) {
86
    return [NSString stringWithFormat:@"{[0x%llx] %@ - %@:%u}", [self address], [self fileName],
87
                                      [self symbol], [self lineNumber]];
88
  }
89
 
90
  return [NSString
91
      stringWithFormat:@"{[0x%llx + %u] %@}", [self address], [self lineNumber], [self symbol]];
92
}
93
 
94
@end