[Interest] Android: Debug.isDebuggerConnected() returns false when debugging

Rob Allan rob_allan at trimble.com
Thu Nov 25 02:45:37 CET 2021


I'm trying to use the Java function Debug.isDebuggerConnected() on Android.
(Our app has some global exception handling that I want to disable when
running under the debugger, so that any exceptions can be trapped by the
debugger in the usual way.)

When I debug our app using Qt Creator, Debug.isDebuggerConnected() always
returns false, even though the debugger clearly is connected.

My Java function looks like this:

    public static boolean isDebuggerConnected() {
        if (Debug.isDebuggerConnected()) {
            Log.d(TAG, "**** Debugger connnected");
        }
        else {
            Log.d(TAG, "**** Debugger NOT connnected");
        }

        return Debug.isDebuggerConnected();
    }

And the C++ code that calls this via JNI is as follows:

bool debug_IsDebuggerPresent()
{
    jboolean isDebuggerConnected =
QAndroidJniObject::callStaticMethod<jboolean>(
        "com/trimble/access/Device",
        "isDebuggerConnected");
    return isDebuggerConnected != JNI_FALSE;
}

The log statement in the Java code produces this output:

D Device  : **** Debugger NOT connnected

And the result of the C++ function is 'false'.

Even more puzzling is that, a little earlier in the debug output, there is
this message coming from the OS:

I System.out: Debugger has connected

Am I doing something wrong here? Can anyone suggest why this function seems
to be telling me the debugger is not connected, when it plainly is?

Thanks,

Rob Allan
Trimble Ltd
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20211125/8af22bef/attachment.html>


More information about the Interest mailing list