简体   繁体   English

在源方法中调试时无法检查 catch 子句中的变量

[英]Unable to inspect variables in catch clause when debugging inside a source method

While debugging in Android Studio 3.5.3 I usually don't have problems.在 Android Studio 3.5.3 中调试时,我通常没有问题。 However I stumbled onto a problem while debugging inside the Android source, specifically the file Sdk\\sources\\android-28\\android\\bluetooth\\BluetoothGatt.java但是我在 Android 源代码中调试时偶然发现了一个问题,特别是文件Sdk\\sources\\android-28\\android\\bluetooth\\BluetoothGatt.java

Once suspended at the breakpoint indicated below, the variable e is not listed in the Variables tab.一旦在下面指示的断点处挂起,变量e就不会列在“变量”选项卡中。 Am not sure if this is by design and if so, what is the cause of it?不确定这是否是设计使然,如果是,它的原因是什么? What causes some variables to be available, while some are not?是什么导致某些变量可用,而有些变量不可用? Various local variables are available, but not the e variable.可以使用各种局部变量,但不包括e变量。

My breakpoint is here, at line 1259:我的断点在这里,在第 1259 行:

    try {
        mService.writeDescriptor(mClientIf, device.getAddress(), descriptor.getInstanceId(),
                AUTHENTICATION_NONE, descriptor.getValue());
    } catch (RemoteException e) {
        Log.e(TAG, "", e); // <-- HERE (breakpoint)
        mDeviceBusy = false;
        return false;
    }

Systems used:使用的系统:

OS: Win 10操作系统:Win 10
Android Studio: 3.5.3安卓工作室:3.5.3
Build Tools: 29.0.2构建工具:29.0.2
SDK Tools: 26.1.1 SDK 工具:26.1.1
Platform Tools: 29.0.5平台工具:29.0.5
Gradle: 3.5.3等级:3.5.3

Devices tested:测试的设备:
Huawei P20 Pro (Android 9)华为 P20 Pro(安卓 9)
Huawei Mate 9 (Android 9)华为伴侣 9 (Android 9)

PS The Log.e statement should print the stacktrace contained in the e variable to LogCat, however it is nowhere to be found after thorough inspection. PS Log.e语句应该将 e 变量中包含的Log.e打印到 LogCat,但是经过彻底检查后无处可寻。 Therefore I am very interested in the contents of the exception variable.因此我对异常变量的内容很感兴趣。

Screenshot demonstrating the aforementioned issue with the debugger使用调试器演示上述问题的屏幕截图

As a commenter pointed out, the debugger was not actually suspending on the line it indicated.正如评论者指出的那样,调试器实际上并没有挂在它所指示的行上。 Based on this information and on the return value of the method it clicked: the method is very likely returning false on the mDeviceBusy check which happens earlier in that method.基于此信息和它单击的方法的返回值:该方法很可能在mDeviceBusy检查中返回 false,该检查在该方法中较早发生。

Moreover, the issues I was experiencing with the Bluetooth framework (BLE specifically) seem to be caused by calling API methods while an operation is still running.此外,我在蓝牙框架(特别是 BLE)中遇到的问题似乎是由在操作仍在运行时调用 API 方法引起的。 This can break the Android Bluetooth API, causing the mDeviceBusy field to remain true.这可能会破坏 Android 蓝牙 API,导致mDeviceBusy字段保持为真。

After I disabled some GATT/BLE operations which my app does right after connecting, the problem disappears.在我禁用了我的应用程序在连接后立即执行的一些 GATT/BLE 操作后,问题就消失了。 The solution is making sure only one command is active at a time, and possibly even adding additional time between commands.解决方案是确保一次只有一个命令处于活动状态,甚至可能在命令之间增加额外的时间。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM