[VSCode] CMake Tools build integration broken for SITL targets in v1.14

Since upgrading from v1.13 to v1.14 I have been having a small issue with the CMake Tools extension in VSCode.

In v1.13, when I built a SITL target (say, px4_sitl gazebo) using the Build button in the CMake Tools ribbon (see picture), the build would run through, start pxh/gazebo, but then pxh would immediately automatically gracefully exit.

Since upgrading to tag v1.14-rc2, I have found that when doing the same build, that the CMake build does not exit pxh - the simulator runs, and can only be stopped by cancelling the build. The problem that this causes is that now the build process returns that it was cancelled by the user (i.e. the build dod not succeed), and so I cannot use the debugger since that requires the build to complete successfully.

It seems to me that this has been caused by the changes to platforms/posix/src/px4/common/px4_daemon/pxh.cpp in commit 714234ca90f116ead5ac4b8d2941d7d96a53b003 as part of #19800 .

void Pxh::run_pxh()
	while (!_should_exit) {

		int c = getchar();
		std::string add_string; // string to add at current cursor position
		bool update_prompt = true;

		switch (c) {
		case EOF:
			_should_exit = true; // <-- this line was removed in #19800

AFAIK, the CMake Tools build does not provide a STDIN stream, so this explains why removing this line is causing the behaviour I am seeing.

I tried putting this _should_exit = true line back into the code at v1.14-rc2, and my problem went away, and it didn’t seem to break the Mavlink shell (I used the Mavlink shell through QGC), which was the purpose of #19800.

Is there any idea why this change was made in #19800? Is there other reasons why we wouldn’t want the run_pxh() loop to finish if it gets to EOF?

I was the one that made this change to support the MAVLink shell on our POSIX targets. I’ll investigate a fix for the SITL target use case you mention above. When you made the EOF change were you running on a POSIX target or a NuttX target?

Sorry for introducing a bug into your use case.


When I put the _should_exit = true line back in, it was a POSIX target (px4_sitl_default) that I checked, and like I said the Mavlink shell still worked via QGC.