Hello!
I want to run xctrace on an example swift package with one executable target that reads from stdin. The only code it contains is this:
I compile the package with swift build -c release and then experiment launching it through xctrace:
So, if I understood the man page correctly for xctrace, --target-stdin - should redirect xctrace's stdin to the profiling target's stdin, --target-stdout out.txt should write the target's stdout to the file out.txt, and --launch -- .build/release/example should launch that executable and profile it.
The problem is that xctrace only outputs this:
Starting recording with the Time Profiler template. Launching process: example. Ctrl-C to stop the recording
and gets stuck and my executable never actually finishes running. After stopping the recording I see that the out.txt file is empty but it did successfully record into a .trace file.
My assumption is that for some reason stdin just isn't getting redirected to my executable at all, and I have tried several different configurations, from piping and redirecting, to experimenting with changing the order of arguments, removing or adding them or just using different ones, but no change in behaviour.
I need help understanding if there is something I am doing wrong or if xctrace doesn't yet support profiling targets that read from stdin or if it is a bug. In the meantime I can use Intruments directly but with some very annoying acrobatics requiring adding a delay to the start of my program, running it, quickly switching from the terminal to Instruments and quickly selecting the running program and hit record.
Thank you.
I want to run xctrace on an example swift package with one executable target that reads from stdin. The only code it contains is this:
Code Block swift print("Before reading stdin") print(readLine()!) print("After reading stdin")
I compile the package with swift build -c release and then experiment launching it through xctrace:
Code Block zsh echo Hey | xcrun xctrace record --target-stdin - --target-stdout out.txt --template 'Time Profiler' --launch -- .build/release/example
So, if I understood the man page correctly for xctrace, --target-stdin - should redirect xctrace's stdin to the profiling target's stdin, --target-stdout out.txt should write the target's stdout to the file out.txt, and --launch -- .build/release/example should launch that executable and profile it.
The problem is that xctrace only outputs this:
Starting recording with the Time Profiler template. Launching process: example. Ctrl-C to stop the recording
and gets stuck and my executable never actually finishes running. After stopping the recording I see that the out.txt file is empty but it did successfully record into a .trace file.
My assumption is that for some reason stdin just isn't getting redirected to my executable at all, and I have tried several different configurations, from piping and redirecting, to experimenting with changing the order of arguments, removing or adding them or just using different ones, but no change in behaviour.
I need help understanding if there is something I am doing wrong or if xctrace doesn't yet support profiling targets that read from stdin or if it is a bug. In the meantime I can use Intruments directly but with some very annoying acrobatics requiring adding a delay to the start of my program, running it, quickly switching from the terminal to Instruments and quickly selecting the running program and hit record.
Thank you.