How to reset Instruments after Automation Instrument rejected command
Asked Answered
A

2

6

(Xcode 4.5)

When running instruments from the command line it works the first time but then it won't run again until after I reboot.

The verbose output from Instruments includes this:

Instruments : Loading template 'file://localhost/Applications/Xcode.app/Contents/Applications/Instruments.app/Contents/PlugIns/AutomationInstrument.bundle/Contents/Resources/Automation.tracetemplate'
Instruments : Setting Instrument Trace Command : Instrument Command (purpose:Idle; output destination:file://localhost/Users/xxxxx/instrumentscli0.trace)
Instruments : Trace Command Recognized
Instruments : Instrument 'Automation - MyProject' rejected command 'Instrument Command (purpose:Trace; output destination:file://localhost/Users/xxxxx/instrumentscli0.trace)' for target 'Executable (name:MyProject; arguments:)'
Instruments : Instruments Rejected Command
Instruments Trace Error : Failed to start trace.

The command line I'm using to run instruments is this (split onto multiple lines for clarity):

instruments -v -w <DeviceID>
-t /Applications/Xcode.app/Contents/Applications/Instruments.app/Contents/PlugIns/AutomationInstrument.bundle/Contents/Resources/Automation.tracetemplate
/Users/xxxxx/dev/MyProject/build/Debug-iphoneos/MyProject.app
-e UIASCRIPT /Users/xxxxx/dev/MyProject/UIAutoTests/some_test.js

I've tried comparing what processes were running before and after the first (successful) run using ps and what files/pipes were open before and after using lsof, but I can't find anything to suggest why it won't run more than once.

The error seems to suggest that the automation instrument within instruments is rejecting the purpose:Trace command, so I've tried deleting the output trace directory (in case the auto-incremented filename was causing a problem), I've tried running instruments with a different template between runs to see if this clears whatever is blocking it, but I can't get it to work more than once per reboot.

My suspicion is that there is some invalid state in the Automation instrument or in a shared library used by instruments. I need a way to reset this state from the command line so that I can run the automated tests reliably on a CI server.

Is there a way to compare what shared libraries are loaded before/after and unload them? Does anyone have any other ideas of what might be persisting and how to reset it?

Automatize answered 25/9, 2012 at 16:30 Comment(1)
I am still seeing this 3 months later. I even tried out 4.6p4. Do you have any new insights or hacks? This is frustrating for me because it's working perfectly on all iOS6 devices except one iPod touch with iOS5 (intentionally) on it. Related: lists.apple.com/archives/xcode-users/2012/Sep/msg00187.htmlFlex
F
1

Try downloading Xcode 4.4.1 (iOS dev center) and use its instruments 4.4 (4445). This version is working for all my devices.

FYI, when I use 4.5+, or even 4.6DP4, only iOS6 devices respond normally; others would fail with the same message as yours. Give it a try, maybe even 4.3.3 if 4.4 doesn't work well.

Flex answered 26/12, 2012 at 9:5 Comment(0)
M
0

For anyone else having this problem, I'll explain what worked for me and how I solved this.

I did the ps command to see which processes are running. I found that instruments was still running. I then did killall instruments and that killed the instruments process. I then did my instruments command and it worked perfect after that.

Mera answered 13/6, 2013 at 17:22 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.