GDBServer cannot attach

This is a known bug of Android gdbserver 7.x. On some devices it fails to attach to the app reporting the following error:

Cannot attach to lwp xxxx1: Operation not permitted (1)
Cannot attach to lwp xxxx2: Operation not permitted (1)
Cannot attach to lwp xxxxN: Operation not permitted (1)

There are 2 known solutions to this problem:

  1. Sometimes restarting debugging or resetting the device solves the problem.
  2. You can revert to the old gdbserver (6.6) by going to VisualGDB Project Properties and selecting "Use gdb 7.x and old gdbserver":

Please do not forget to rebuild your project after changing the gdbserver. If the problem still persists, the Android device failed to update the gdbserver due to an installer bug. Removing the app from the device and restarting it will resolve the problem.

Note that the old gdbserver does not support NEON registers. To debug NEON registers please use one of the modern Android devices that are compatible with the new gdbserver.