The latest ndk-gdb can not connect to my device - android-ndk

I just get trouble to use ndk-gdb to debug my native application. This is my environment:
OS X El Captain 10.11.5
NDK version r12
SDK version 24
Build tool version 24.0.0
Device Nexus 6P with Android N (NPD35K)
The issue:
When I was going to launch ndk-gdb it always fail with the message
Error: unable to connect to device.
Remote connection closed
However, the gdbserver instance has already been launched since my app is paused and I could see the gdbserver in adb shell ps list.
What I have tried:
Instead of start gdbserver by the ndk-gdb script, I launched the
gdbserver manually by adb run-as and make sure the gdbserver
keeps running
Make a socket forward by adb forward :5039 localfilesystem:/the_gdb_socket_path
Use netstat -na | grep 5309 to make sure the port is being listening
Use telnet localhost 5039 to test socket but get the error Connection closed by foreign host
Is there any better way to identify where the issue cause the remote gdb failed on connection?

In my case, I had to root the phone to fix that connection issue, see:
Does ndk-gdb work under macOS Sierra?

Related

Remote debugging nodejs app in Intellij with Docker - port already allocated

I want to start debugging node.js app using Intellij and node.js interpreter running on Docker. While running the app works, when I try to debug I get the error:
Error running 'index.js'
com.github.dockerjava.api.exception.InternalServerErrorException:
{"message":"driver failed programming external connectivity on
endpoint focused_poincare
(a17137973880d1be7c6a74fc142184fdda31e0dec8ebd539b09d9dbe4cf70014):
Error starting userland proxy: Bind for 0.0.0.0:55578 failed: port is
already allocated"}
Remote interpreter was configured acccording to the documentation. I have created a new Node.js Run/Debug configuration and entered the following data:
.
What might be the cause for debugging not working?
I use:
Intellij Idea Ultimate v. 2019.1.4 Preview
Intellij NodeJS plugin v. 191.7479.1, NodeJS remote interpreter plugin v. 191.6014.8 and Docker plugin v. 191.7141.44
Docker Desktop Community v. 2.0.0.3
EDIT: Adressing the comments:
Local debugging works. The file (index.js) that I am trying to run consists only of console.log('Hello world!') so I don't spawn any child processes on my own. My host system has Windows 10 Pro as OS, so for checking the open ports on host system I used netstat -an | find "55578", which returned nothing. Moreover, if I try to run docker manually from the command line, using docker run -it -p 55578:55578 node, everything runs and no error is given.
Also, each time I try remote debugging, the port number given by Intellij in an error message seems to be random high port number. I tried looking for open ports just after getting error message, but never found one that is open with a number reported by Intellij and those indeed appear in the output:
My Run/Debug configuration:
My Docker configuration (I had to check "Expose daemon on tcp://localhost:2375 without TLS" in Docker configuration to make Intellij and Docker play together):
EDIT: When I add --inspect-brk=0.0.0.0:55432 as "Node Parameters" in "Run/Debug Configurations" Intellij windows (per this bug report) the container nad program start, but debugging seems to be no-op (e.g. the program does not stop on breakpoints).
After updating to Intellij v. 2019.2 I was able to get the container debugging to work using the workaround already mentioned in my question.
I have added a parameter --inspect-brk=0.0.0.0:55432 to Node parameters option in Run/Debug configuration (see the picture below) and everything seems to be working, including the breakpoints.

Nox player isn't showing in android studio

I have an AMD A10 processor that doesn't support VT-x. I installed Nox player and enabled USB debugging but still Android studio cannot find the emulator. Any helpful and clear steps to install USB driver adb(Android Debug Bridge)
Connect a NOX device to Android Studio: By Abhijeet Pal
On CMD:
Route: cd C:\Program Files (x86)\Nox\bin
Connection: nox_adb.exe connect 127.0.0.1:62001
Not Connecting Fix
You need to find the correct port and use it. I faced the same problem so here is what I did.
Kill the server:
nox_adb.exe kill-server
Now try to connect on any port number, say, 62001:
C:\Program Files (x86)\Nox\bin>nox_adb.exe connect 127.0.0.1:62001
daemon not running. starting it now on port 5037
daemon started successfully
unable to connect to 127.0.0.1:62001:62001
Now try to use port 5037 as mentioned in the output above:
C:\Program Files (x86)\Nox\bin>nox_adb.exe kill-server
C:\Program Files (x86)\Nox\bin>nox_adb.exe connect 127.0.0.1:5037
daemon not running. starting it now on port 5037
daemon started successfully
connected to 127.0.0.1:5037
It should work fine then.
127.0.0.1:5037 Disconnected on Android Studio Solution
It should appear without any further customizations. I have used Nox Emulator for a while and you have to do a little trick to make it work for debugging:
Click the debug or run button on Android Studio2. Wait for the popup to open (the one where it lists the connected devices)3. Run Nox Emulator4. After Nox is ready and running, it should appear on your connected devices list.
This isn't of my authorship, that's why I attached all sources of problems that I've faced.
I made the mistake of starting the adb server before and then opening android studio. It didn't work.
Subsequently did this:
D:\Program Files\Nox\bin>nox_adb.exe connect 127.0.0.1:62001
adb server version (41) doesn't match this client (36); killing...
* daemon started successfully *
connected to 127.0.0.1:62001
Android studio immediately updated and showed the following:

Grails run-app fails on VM VirtualBox: hangs on build, can't access server

I'm new to Grails and attempting to implement the Hello World app described at grails.org's Getting Started guide.
I have installed Grails using SDKman on an Ubuntu Server 16.04 VM (VirtualBox, running as a service). My host machine is Windows 10.
I configured two network adapters in VirtualBox: the first a NAT with port forwarding (3022 host -> 22 guest, 8080 host -> 8080 guest), the second a Host-Only adapter.
I can SSH into my VM just fine from my Windows host (using Bash): ssh -p 3022 user#localhost
When I run python3 -m http.server 8080 from that SSH session, it successfully listens on both localhost:8080 and :8080. I can access both URLs from a browser on my host machine.
When I run grails run-app it hangs forever, and none of the above endpoints work from my host.
When I run grails run-app --verbose I see it compile without complaint through "Building 85% > :bootRun". I understand that this is expected behavior, but I never see "Application started" or any similar message. It never starts.
ONE TIME the following command succeeded in building and running the app, creating exactly the result I needed:
grails -Dserver.port=8080 -Dserver.host=0.0.0.0 run-app --verbose --stacktrace
However when I stopped the app and tried again, it failed as before.
I notice that VirtualBox > Settings > Network > Adapter #2 which I had set as "Host-Only Network" has multiple times reset itself to Bridged. I suspect that this reset may have caused my problem. But I don't know how to prevent the reset, or to restore that functionality I so briefly had.
Thanks, anyone who can help!
Resolved! Turns out run-app just takes a LONG time to finish compiling and building, upwards of 10 minutes. So I just needed to wait ~5+ minutes with no visual sign of action before the completion message would show and I could access my site. :)

cannot kill adb.exe manually

After android studio running several hrs,suddenly the connected device shows as offline.And what's annoying is that it always show an offline device no matter connecting or not by usb.
As what we always do, I try to call adb kill-server or adb start-server.From the process list, it shows an new adb.exe was created while the former one wont disappear even i try to stop it from the list.
So far my only solution is restart pc, i mean, FORCE restart.Normal stop or restart will keep my pc in the stopping screen.
Hope someone facing the same issues can support a better solution.Thanks anyway.
Try to update your Android Studio to 2.2. After that you will be able to kill adb.exe if you need.
That helped me fix that bug, but still facing it in 2.1.1.
This is how I deal with my case which happens periodically.
Per the tip of this answer, I find the processes using port 5037 wit command netstat as following:
Microsoft Windows [Version 10.0.15063]
(c) 2017 Microsoft Corporation. All rights reserved.
C:\Users\Hong>netstat -a -n -o | find "5037"
TCP 127.0.0.1:5037 0.0.0.0:0 LISTENING 9232
TCP 127.0.0.1:5037 127.0.0.1:52034 ESTABLISHED 9232
TCP 127.0.0.1:52034 127.0.0.1:5037 ESTABLISHED 10824
In the above results, process 9232 is adb.exe and process 10824 is Visual Studio. I can kill adb.exe after closing the other process using port 5037 - Visual Studio

Remote debug with gdbServer

1) I start GDB on remote machine by gdb myAppName
2) Then i give run -p portNumber
3) Then i run java application which connect with it on above mentioned port.
Now when i am trying to remote debug via gdbserver then the scenario is
1) I run gdb server on remote machine
gdbserver host:port path to application
Now when i try to connect my java client application to the gdbserver port .It will not be able to connect.
So i am searching of alternative of run -p command of gdb in gdb server
What i was trying was remote debugging of C code via eclipse CDT
Any help would be highly appreciated.
gdbserver can be started attached to a pid on some systems according to the docs using the following syntax which is different than the normal invocation
gdbserver hostname : port --attach pid
or gdb can be started with a program that is subsequently started by the remote machine
gdbserver hostname : port program
and then you can attach to it from another remote gdb using
(gdb) target remote hostname: port
Eclipse would probably do the same thing so long at the remote gdbserver is invoked as above
and then start the remote program using a different port
(gdb) run -p someotherport
This 2nd invocation, from your comments above, I assume you have created some flag to your program that allows it to bind to someotherport

Resources