Page MenuHomePhabricator

Fix the ability to list iOS simulator processes.
Needs ReviewPublic

Authored by clayborg on Aug 14 2020, 11:53 AM.

Details

Summary

This can be done by doing:
(lldb) platform select ios-simulator
(lldb) platform process list

There was code that was trying to detect simulator processes but it had an error in the loop where each time it would check for a env var that starts with "SIMULATOR_UDID=" it would change the architecture to iOS if it found it and MacOSX if it didn't. This meant unless "SIMULATOR_UDID=" was the last environment variable, this loop would never set the OS correctly. We also weren't setting the environment to Simulator which means PlatformAppleSimulator::FindProcesses(...) would never return any valid processes even when there were many.

I don't know how I can test this as we don't want a test suite having to launch an iOS simulator, so there are no tests at the moment. If anyone has any ideas on how to test this, please let me know.

Diff Detail

Event Timeline

clayborg created this revision.Aug 14 2020, 11:53 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 14 2020, 11:53 AM
clayborg requested review of this revision.Aug 14 2020, 11:53 AM

We should have a few tests that launch a simulator. @aprantl revived them recently:

  • TestAppleSimulatorOSType.py
  • TestSimulatorPlatform.py
  • TestIOSSimulator.py
clayborg updated this revision to Diff 286151.Aug 17 2020, 2:36 PM

Added a "platform process list" test to each simulator test to test this functionality.

The tests all launch processes and the process should be stopped at a breakpoint, so listing the processes for "ios-simulator" is a great way to test this on all simulators.

Adrian: is there something I need to do to enable simulator tests? I added a test to TestSimulatorPlatform.py but if I run:

$ ../debug/bin/llvm-lit -sv lldb/test/API/macosx/simulator
llvm-lit: /Users/gclayton/Documents/src/lldb/mono/llvm-project/lldb/test/API/lit.cfg.py:147: warning: Could not set a default per-test timeout. Requires the Python psutil module but it could not be found. Try installing it via pip or via your operating system's package manager.

Testing Time: 19.61s
  Unsupported: 1

1 warning(s) in tests

It is unsupported? I am running this on a mac. Do I need to launch a simulator first? Extra arguments to the test suite?

Adrian: is there something I need to do to enable simulator tests? I added a test to TestSimulatorPlatform.py but if I run:

$ ../debug/bin/llvm-lit -sv lldb/test/API/macosx/simulator
llvm-lit: /Users/gclayton/Documents/src/lldb/mono/llvm-project/lldb/test/API/lit.cfg.py:147: warning: Could not set a default per-test timeout. Requires the Python psutil module but it could not be found. Try installing it via pip or via your operating system's package manager.

Testing Time: 19.61s
  Unsupported: 1

1 warning(s) in tests

It is unsupported? I am running this on a mac. Do I need to launch a simulator first? Extra arguments to the test suite?

No, the tests are supposed to run. Green dragon (which is running a consumer macOS + consumer Xcode) is running this test. I know because it sometimes fails because it couldn't launch the simulator :-(
The test was XFAILed a few weeks ago — is your LLVM up-to-date?

lldb/source/Host/macosx/objcxx/Host.mm
509

data.GetCStringRef()?
http://llvm.org/doxygen/classllvm_1_1DataExtractor.html

Not sure if we surface that through the LLDB dataextractor, but we probably should.

510
if (str.empty())
   return false;
528

same here (GetCStringRef)
Perhaps also use a fresh variable to avoid confusion?

Adrian: is there something I need to do to enable simulator tests? I added a test to TestSimulatorPlatform.py but if I run:

$ ../debug/bin/llvm-lit -sv lldb/test/API/macosx/simulator
llvm-lit: /Users/gclayton/Documents/src/lldb/mono/llvm-project/lldb/test/API/lit.cfg.py:147: warning: Could not set a default per-test timeout. Requires the Python psutil module but it could not be found. Try installing it via pip or via your operating system's package manager.

Testing Time: 19.61s
  Unsupported: 1

1 warning(s) in tests

It is unsupported? I am running this on a mac. Do I need to launch a simulator first? Extra arguments to the test suite?

No, the tests are supposed to run. Green dragon (which is running a consumer macOS + consumer Xcode) is running this test. I know because it sometimes fails because it couldn't launch the simulator :-(
The test was XFAILed a few weeks ago — is your LLVM up-to-date?

It was up to date. Can you run my invocation on your lldb?:

../debug/bin/llvm-lit -sv lldb/test/API/macosx/simulator

Adrian: is there something I need to do to enable simulator tests? I added a test to TestSimulatorPlatform.py but if I run:

$ ../debug/bin/llvm-lit -sv lldb/test/API/macosx/simulator
llvm-lit: /Users/gclayton/Documents/src/lldb/mono/llvm-project/lldb/test/API/lit.cfg.py:147: warning: Could not set a default per-test timeout. Requires the Python psutil module but it could not be found. Try installing it via pip or via your operating system's package manager.

Testing Time: 19.61s
  Unsupported: 1

1 warning(s) in tests

It is unsupported? I am running this on a mac. Do I need to launch a simulator first? Extra arguments to the test suite?

No, the tests are supposed to run. Green dragon (which is running a consumer macOS + consumer Xcode) is running this test. I know because it sometimes fails because it couldn't launch the simulator :-(
The test was XFAILed a few weeks ago — is your LLVM up-to-date?

It was up to date. Can you run my invocation on your lldb?:

../debug/bin/llvm-lit -sv lldb/test/API/macosx/simulator

That works for me, but it looks like you're using the standalone/Xcode build, so maybe that's borked somehow :(

Adrian: is there something I need to do to enable simulator tests? I added a test to TestSimulatorPlatform.py but if I run:

$ ../debug/bin/llvm-lit -sv lldb/test/API/macosx/simulator
llvm-lit: /Users/gclayton/Documents/src/lldb/mono/llvm-project/lldb/test/API/lit.cfg.py:147: warning: Could not set a default per-test timeout. Requires the Python psutil module but it could not be found. Try installing it via pip or via your operating system's package manager.

Testing Time: 19.61s
  Unsupported: 1

1 warning(s) in tests

It is unsupported? I am running this on a mac. Do I need to launch a simulator first? Extra arguments to the test suite?

No, the tests are supposed to run. Green dragon (which is running a consumer macOS + consumer Xcode) is running this test. I know because it sometimes fails because it couldn't launch the simulator :-(
The test was XFAILed a few weeks ago — is your LLVM up-to-date?

It was up to date. Can you run my invocation on your lldb?:

../debug/bin/llvm-lit -sv lldb/test/API/macosx/simulator

That works for me, but it looks like you're using the standalone/Xcode build, so maybe that's borked somehow :(

I am using the mono-repo build with cmake + ninja.