Skip to content
This repository has been archived by the owner on Nov 28, 2020. It is now read-only.

✨ add vm tracker #32

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions TraceUtility/InstrumentsPrivateHeader.h
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,24 @@ BOOL XRAnalysisCoreReadCursorGetValue(XRAnalysisCoreReadCursor *cursor, UInt8 co
- (NSArray<XRContext *> *)_permittedContexts;
@end

@interface XRVMInstrument : XRInstrument
- (BOOL)_refreshDataSources;
@end

@interface XRVMRegion : NSObject
- (NSString *)displayType;
- (unsigned long long)pageSize;
- (unsigned long long)swappedSize;
- (unsigned long long)dirtySize;
- (unsigned long long)residentSize;
- (unsigned int)virtualPages;
- (unsigned long long)virtualSize;
- (unsigned long long)location;
@end

@interface XRVMCoalescedRegion : XRVMRegion
@end

@interface XRRawBacktrace : NSObject
@end

Expand Down
16 changes: 15 additions & 1 deletion TraceUtility/main.m
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,22 @@ int main(int argc, const char * argv[]) {
}
}];
}];
} if ([instrumentID isEqualToString:@"com.apple.xray.instrument-type.vmtrack"]) {
XRVMInstrument *vm = (XRVMInstrument *)instrument;
[vm _refreshDataSources];
NSArray *displayArray = [vm valueForKey:@"_displayArray"];
if (displayArray && displayArray.count > 0) {
TUPrint(@"Type Resident(byte) Dirty(byte) Swapped(byte) Virtual(byte) \n");
}
[displayArray enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
if ( [obj isKindOfClass:XRVMCoalescedRegion.class] ) {
XRVMCoalescedRegion *region = (XRVMCoalescedRegion *)obj;
TUPrint(@"\"%@\" %@ %@ %@ %@ \n", region.displayType ? region.displayType : [region valueForKey:@"_groupName"],
@(region.residentSize), @(region.dirtySize), @(region.swappedSize), @(region.virtualSize));
}
}];
} else {
TUPrint(@"Data processor has not been implemented for this type of instrument.\n");
TUPrint(@"Data processor has not been implemented for(%@) this type of instrument.\n", instrumentID);
}

// Common routine to cleanup after done.
Expand Down