Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to properly set a breakpoint in a nested class using JDB?

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 ?

like image 661
slaadvak Avatar asked Nov 20 '14 19:11

slaadvak


People also ask

What is the purpose of placing breakpoints in Java?

A breakpoint is a marker that you can set to specify where execution should pause when you are running your application in the IDE's debugger. Breakpoints are stored in the IDE (not in your application's code) and persist between debugging sessions and IDE sessions.

What is method breakpoint in Java?

A breakpoint is a signal that tells the debugger to temporarily suspend execution of your program at a certain point in the code. To define a breakpoint in your source code, right-click in the left margin in the Java editor and select Toggle Breakpoint.


1 Answers

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
like image 63
slaadvak Avatar answered Oct 03 '22 12:10

slaadvak