How to properly set a breakpoint in a nested class using JDB?
android, debugging, java, jdb
Solution
The wrangled method name is wrong.
In JDB, issue this command to inspect the `DcTrackerBase` class :
> class com.android.internal.telephony.dataconnection.DcTrackerBase
Class: com.android.internal.telephony.dataconnection.DcTrackerBase
extends: android.os.Handler
subclass: com.android.internal.telephony.dataconnection.DcTracker
nested: com.android.internal.telephony.dataconnection.DcTrackerBase$1
As we can see, the nested class `DcTrackerBase$1` could be our `BroadcastReceiver` class. To verify, issue the following command :
> class com.android.internal.telephony.dataconnection.DcTrackerBase$1
Class: com.android.internal.telephony.dataconnection.DcTrackerBase$1
extends: android.content.BroadcastReceiver
That's it ! To set the breakpoint properly, we type :
> stop in com.android.internal.telephony.dataconnection.DcTrackerBase$1.onReceive
Set breakpoint com.android.internal.telephony.dataconnection.DcTrackerBase$1.onReceive
Problem
``` package com.android.internal.telephony.dataconnection; public abstract class DcTrackerBase extends Handler { protected BroadcastReceiver mIntentReceiver = new BroadcastReceiver () { @Override public void onReceive(Context context, Intent intent) { String action = intent.getAction(); if (DBG) log("onReceive: action=" + action); [...] ``` In the above code, using `jdb`, I'd like to set a breakpoint on the `onReceive` method. I used the following command : ``` > stop in com.android.internal.telephony.dataconnection.DcTrackerBase$mIntentReceiver.onReceive ``` And I get this from `jdb` : ``` > Deferring breakpoint com.android.internal.telephony.dataconnection.DcTrackerBase$mIntentReceiver.onReceive. It will be set after the class is loaded. ``` I know that the class is already loaded, so I imagine that jdb is not finding the method I want. How should I set my breakpoint then ?