¿Cómo leer un file Xcode 6.1 Instruments .trace?

He estado tratando de leer un file .trace , que había generado utilizando una plantilla de instrumentos personalizados (instrumentos: Automatización , Asignaciones , Fugas ) utilizando Instrumentos .

La mejor ayuda que encontré en esta respuesta stackoverflow . Básicamente, el autor creó un progtwig personalizado Objective-C ( Traced ) para leer un tipo específico de file .trace de Apples (instrumento: OpenGL ES Driver ). Su respuesta está orientada hacia XCode 4.6 .

El código sigue funcionando con XCode 6.1 , pero parece que el file de seguimiento ha cambiado ligeramente. Tienes que search el file *.run.zip dentro del package .trace y descomprimirlo. En la carpeta extraída, ahora debe encontrar el file *.run . Hay varios files *.run.zip en un package .trace ; uno por instrumento usado.

Simplemente ejecutando el progtwig Traced obtuve una uncaught exception 'NSArchiverArchiveInconsistency', reason: '*** class error for 'XRObjectAllocRun' -error.

Este error fue inicialmente fácil de descifrar. Todo lo que tenía que hacer era implementar la class faltante XRObjectAllocRun ; paralelo a las XRRun ejemplo XRRun o XRVideoCardRun en XRRun.m .

Así es como llegué y me quedé atrapado:

 #import "XRObjectAllocRun.h" @implementation XRObjectAllocRun - (id)initWithCoder:(NSCoder *)decoder { if((self = [super init])) { NSObject *a = [decoder decodeObject]; NSObject *b = [decoder decodeObject]; NSObject *c = [decoder decodeObject]; NSObject *d = [decoder decodeObject]; NSObject *e = [decoder decodeObject]; NSObject *f = [decoder decodeObject]; NSObject *g = [decoder decodeObject]; NSObject *h = [decoder decodeObject]; NSObject *i = [decoder decodeObject]; // NSObject *j = [decoder decodeObject]; // NSObject *k = [decoder decodeObject]; NSLog(@"test"); } return self; } @end 

Básicamente estoy atrapado invirtiendo ingeniería en la class XRObjectAllocRun . Pero no importa cuántos o pequeños objects decode, siempre recibo la siguiente exception: uncaught exception 'NSArchiverArchiveInconsistency', reason: '*** NSUnarchiver: inconsistency between written and read data for object 0x100112750'

Si descomenta las últimas dos sentencias de decode , el progtwig se bloqueará con esta exception: uncaught exception 'NSArchiverArchiveInconsistency', reason: '*** file inconsistency: read 'i', expecting '@'' .

¿Alguien sabe la firma de la class XRObjectAllocRun de Apple? Esta class se utiliza para el instrumento de Asignaciones .

¡Cualquier ayuda sería genial!

Actualizar

*.trace con Swift y *.trace todo el *.trace -reader – falla con exactamente el mismo error (s):

 import Foundation import Cocoa @objc(XRObjectAllocRun) class XRObjectAllocRun: NSObject { func initWithCoder(decoder:NSCoder){ var x = decoder.decodeObject() // this is where things start breaking... } } @objc(XRRun) class XRRun: NSObject { // to be implemented } @objc(XRTrackSegment) class XRTrackSegment: NSObject { func initWithCoder(decoder:NSCoder)->NSString{ var a = decoder.decodeObject()?.integerValue var b = decoder.decodeObject()?.integerValue var c = decoder.decodeObject()?.integerValue var d = decoder.decodeObject()?.integerValue var e = decoder.decodeObject() return "test" } } @objc(PFTTrackSegment) class PFTTrackSegment: NSObject { func initWithCoder(decoder:NSCoder){ var a = decoder.decodeObject()?.integerValue var b = decoder.decodeObject()?.integerValue var c = decoder.decodeObject()?.integerValue var d = decoder.decodeObject()?.integerValue var e = decoder.decodeObject()?.integerValue var f = decoder.decodeObject()?.integerValue } } // parse command line var traceFilePath = Process.arguments[1] println("input: \(traceFilePath)") var traceFile = NSURL(fileURLWithPath: traceFilePath) var error:NSError? // check if the file exists if (traceFile?.checkResourceIsReachableAndReturnError(&error) == false){ // file does not exist or cannot be accessed println("\(error)") exit(1) } var rawData = NSData(contentsOfURL: traceFile!) var data = NSUnarchiver(forReadingWithData: rawData!) var decodedObject: AnyObject? = data?.decodeObject() println("\(decodedObject)") 

Aquí está la firma de la class XRObjectAllocRun

 #import "XRRun.h" #import "SymbolAwareRun.h" #import "XRCallTreeDataSource.h" #import "XRSourceQuery.h" @class NSMutableArray, NSMutableDictionary, NSString, XRHeapGeneration, XROAEventSummary, XRObjectAllocRunShanetworkingData; @interface XRObjectAllocRun : XRRun <SymbolAwareRun, XRSourceQuery, XRCallTreeDataSource> { XRObjectAllocRunShanetworkingData *_shanetworkingData; NSMutableArray *_allStats; NSMutableDictionary *_statsForCategory; NSMutableDictionary *_categoryIDForName; XROAEventSummary *_scaleStats; NSMutableArray *_generations; struct XRTimeRange _filterTimeRange; unsigned int _filterMinEventID; unsigned int _filterMaxEventID; unsigned long long _nextGenNumber; NSMutableDictionary *_samplesByCategoryNumber; unsigned long long _catNumIndex; struct XRTimeRange _currentStatsFilterRange; int _lifecycleFilter; int _allocationTypeFilter; unsigned int *_quickEventCacheIds; id *_quickEventCache; XRHeapGeneration *_activeGeneration; } + (void)initialize; - (id)operation:(id)arg1 commentsForSymbol:(id)arg2 inSourceManager:(id)arg3 callTreeInformation:(id)arg4; - (id)provideCategories; - (id)backtracesForCategory:(id)arg1 timeRange:(struct XRTimeRange)arg2 savedIndex:(unsigned long long *)arg3; - (void)_configureCallTreeForAllocationType:(int)arg1; - (id)symbolsForEvent:(id)arg1 reverseOrder:(BOOL)arg2; - (id)backtraceRepository; - (BOOL)eventIsLiveInCurrentTimeRange:(id)arg1; - (unsigned int)uncategorizedCount; - (unsigned int)countOfObjectEventsForCategory:(unsigned int)arg1; - (void)enumerateObjectEventsForCategory:(unsigned int)arg1 skipToIndex:(unsigned int)arg2 withBlock:(CDUnknownBlockType)arg3; - (BOOL)_applyLifecycleFilterToEvent:(id)arg1; - (id)zombieEvent; - (id)eventForIdentifier:(unsigned int)arg1; - (BOOL)loadDTPerformanceSessionDataFromPaths:(id)arg1 error:(id *)arg2; - (void)updateGenerations; - (void)deleteGeneration:(id)arg1; - (void)moveGeneration:(id)arg1 toTime:(unsigned long long)arg2; - (void)setActiveGeneration:(id)arg1; - (id)generationAtTime:(unsigned long long)arg1; - (id)generations; - (id)nextGenerationIdentifier; - (void)createGenerationAtTime:(unsigned long long)arg1; - (void)removeFlag:(id)arg1; - (struct XRTimeRange)_displayTimeFilter; - (BOOL)_isTimeScoped; - (BOOL)useTypeFilteringRules:(id)arg1; - (void)setAllocationTypeFilter:(int)arg1; - (void)setLifecycleFilter:(int)arg1; - (struct XRTimeRange)selectedTimeRange; - (void)setSelectedTimeRange:(struct XRTimeRange)arg1; - (id)categoryNameForIdentifier:(unsigned int)arg1; - (id)globalStats; - (id)scalingStats; - (void)_clearStats; - (void)allowEventReuse; - (void)refreshStatsForActiveTimeFilter; - (void)_updateStatsWithEventIdentifier:(unsigned int)arg1 category:(unsigned int)arg2 type:(unsigned int)arg3 size:(int)arg4 pastEvent:(unsigned int)arg5 summaryMap:(id *)arg6 maxCat:(unsigned int)arg7; - (id)_statsObjectForCategoryID:(unsigned int)arg1; - (void)_changeStatsByTimestampRange:(struct XRTimeRange)arg1 overallRange:(struct XRTimeRange)arg2 startID:(unsigned int)arg3 endID:(unsigned int)arg4; - (id *)_createCategorySummaryMapWithMaximum:(unsigned int)arg1; - (void)_validateGlobalStatsForTimeRange:(struct XRTimeRange)arg1; - (void)_recomputeGlobalStats; - (BOOL)discardsLifeCycleComplete; - (unsigned long long)lastTimestamp; - (id)shanetworkingData; - (void)setRecordMode:(int)arg1; - (void)setDiscardsLifeCycleComplete:(BOOL)arg1; - (void)setTargetDevice:(id)arg1 pid:(int)arg2 repository:(id)arg3; - (id)initWithCoder:(id)arg1; - (void)encodeWithCoder:(id)arg1; - (void)dealloc; - (id)init; // Remaining properties @property(readonly, copy) NSString *debugDescription; @property(readonly, copy) NSString *description; @property(readonly) unsigned long long hash; @property(readonly) Class superclass; @end 

He cargado firmas de otras classs aquí si las necesitas.

En lugar de declarar las classs obligatorias en Swift, simplemente puede importar encabezados desde el file al encabezado de puenteo.

Lo hice funcionar Aquí está el proyecto git.