Tegra NSight Failed to attach: Failed to start gdbserver on the device

Let me set up the scenario.
I have two projects created identical in all facets except for Package Name and Application name. deploying to
NVIDIA SHIELD Tablet Android 7.0 (API 24)

The projects are a non altered "Android Application with Native Code – Nsight Tegra
No source or project configuration settings have been edited;

I’m running Visual Studio 2015 on Windows 10 with the latest Nsight Tegra. All SDK and NDK up to date as of today.

The scenario; I can create and run one project and deploy it successfully (AndroidNative1). When I create and run the second project AndroidNative2 (after closing fully AndroidNative1) it will build and the NVidia “Launching on Device” Dialog will appear. It will go through it’s dance of Launching Application … Done Pulling device files… Done. Starting GDB server … Error:
Cannot launch gdbserver: all options have failed.
Failed to attach: Failed to start gdbserver on the device.

Again these apk’s have two different package names and application names. There seems to still be some kind of collision between them however.
The behavior is a bit hard to understand. If I uninstall the applications and reverse the process sometimes I can get AndroidNative2 to launch and then the bad behavior is exhibited on AndroidNative1. Sometimes I get the bad behavior on Both.

If I only have one working then I can continue to uninstall it. or clean rebuild and deploy it. with no issues. but if I then go to the alternate application I get this error often not being able to return to the working one successfully.

Restarting the device has no effect on the behavior.

What am I missing?

Thanks

background;
I’m trying to learn the Tegra NSight for Visual Studio to see if it is a valid tool for some of our development.
Our development all has heavy native components and we are presently trying to evaluate tools the will help us migrate away from the command line tools.

I’ve got some added information; Still an issue but I think I’ve discovered a workaround.
note. I have a non-rooted device. That is to say it isn’t rooted.

This issue is in essence; when I run AnroidNative1 fresh from Visual Studio. It loads up and fires gdbserver.
When I terminate AndroidNative1 the /data/data/./lib/gdbserver is still running.

via shell: ps-Z|grep gdb
you will get
… … /data/data/./lib/gdbserver
clearly the gdbserver is still running even after all attempts to force stop the application.

So now when I try to run the second application there is a conflict with the still running gdbserver.

The workaround:
In the manifest for AndroidNative1 and AndroidNative2
add the permission

recompile and reload package.
in the adb shell
run-as .
then
am force-stop gdbserver
kill

this will kill the gdbserver and then you are free to run either AndroidNative app.

Clearly there is some issue with the gdbserver not exiting when the application exits.

Would love to know if there is something else I need to do to avoid this issue.

Hi intelzombi,

Nsight Tegra assumes that there would be one gdbserver running on the device when debugging. So before launching debugging, It would check and kill the previous one for the apk. It would fail to kill due to permission issues if you have one running gdbserver for another apk.

Victor

Thanks for the note Victor, Isn’t there a way for NSight to kill the gdbserver instance associated with debug apk at the time the debug instance is terminated. Basically what we have here is a orphaned gdbserver process at the end of a debug session. It’s not quite realistic to assume that developers wouldn’t toggle between applications. I’m surprised I’m the first one to have run across this. So the mistake NSight makes then from your description is that it waits for the debug session to start to check for the gdb server ‘isRunning’ instead of killing the gdb server at the end of the debug session when it still has permissions.

Android continues to intrigue with these little nuances.
Don’t take this as a criticism of your tools. I appreciate the developer plugin for Visual Studio. I’m new NSight Tegra plug in so I guess I just need to learn it’s quirks.

Hugh

Hi intelzombi,

Normally, gdbserver would exit as normal debugging session terminates. But on some occasions, for example, the USB cable is plug off during debugging. gdbserver would be an orphan. Pre-Check before debugging is avoiding this. But after plug off, you just began debugging another apk. The Pre-Check would fail due to permission deny. For this case, you have to manually kill the gdbserver.

Victor