FIRCLSMockSymbolResolver.m 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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. #import "Crashlytics/UnitTests/Mocks/FIRCLSMockSymbolResolver.h"
  15. #import "Crashlytics/Crashlytics/Private/FIRStackFrame_Private.h"
  16. @interface FIRCLSMockSymbolResolver () {
  17. NSMutableDictionary *_frames;
  18. }
  19. @end
  20. @implementation FIRCLSMockSymbolResolver
  21. - (instancetype)init {
  22. self = [super init];
  23. if (!self) {
  24. return nil;
  25. }
  26. _frames = [[NSMutableDictionary alloc] init];
  27. return self;
  28. }
  29. - (void)addMockFrame:(FIRStackFrame *)frame atAddress:(uint64_t)address {
  30. [_frames setObject:frame forKey:@(address)];
  31. }
  32. - (BOOL)updateStackFrame:(FIRStackFrame *)frame {
  33. FIRStackFrame *matchedFrame = [_frames objectForKey:@(frame.address)];
  34. if (!matchedFrame) {
  35. return NO;
  36. }
  37. [frame setSymbol:matchedFrame.symbol];
  38. [frame setLibrary:matchedFrame.library];
  39. [frame setOffset:matchedFrame.offset];
  40. return YES;
  41. }
  42. - (BOOL)loadBinaryImagesFromFile:(NSString *)path {
  43. // the mock doesn't need this
  44. return YES;
  45. }
  46. @end