Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Smali debugger/Adb io read problems, proper socket closing, ... #1414

Merged
merged 4 commits into from
Mar 20, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
import jadx.gui.device.debugger.SmaliDebugger.RuntimeRegister;
import jadx.gui.device.debugger.SmaliDebugger.RuntimeValue;
import jadx.gui.device.debugger.SmaliDebugger.RuntimeVarInfo;
import jadx.gui.device.debugger.SmaliDebugger.SmaliDebuggerException;
import jadx.gui.device.debugger.smali.Smali;
import jadx.gui.device.debugger.smali.SmaliRegister;
import jadx.gui.treemodel.JClass;
Expand All @@ -42,8 +41,6 @@
import jadx.gui.ui.panel.JDebuggerPanel.IListElement;
import jadx.gui.ui.panel.JDebuggerPanel.ValueTreeNode;

import static jadx.gui.device.debugger.SmaliDebugger.RuntimeType;

public final class DebugController implements SmaliDebugger.SuspendListener, IDebugController {
private static final Logger LOG = LoggerFactory.getLogger(DebugController.class);

Expand Down Expand Up @@ -359,7 +356,7 @@ public void setStateListener(StateListener listener) {
}

@Override
public void onSuspendEvent(SmaliDebugger.SuspendInfo info) {
public void onSuspendEvent(SuspendInfo info) {
if (!isDebugging()) {
return;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
package jadx.gui.device.debugger;

import io.github.hqktech.JDWP.Event.Composite.BreakpointEvent;
import io.github.hqktech.JDWP.Event.Composite.ClassPrepareEvent;
import io.github.hqktech.JDWP.Event.Composite.ClassUnloadEvent;
import io.github.hqktech.JDWP.Event.Composite.ExceptionEvent;
import io.github.hqktech.JDWP.Event.Composite.FieldAccessEvent;
import io.github.hqktech.JDWP.Event.Composite.FieldModificationEvent;
import io.github.hqktech.JDWP.Event.Composite.MethodEntryEvent;
import io.github.hqktech.JDWP.Event.Composite.MethodExitEvent;
import io.github.hqktech.JDWP.Event.Composite.MethodExitWithReturnValueEvent;
import io.github.hqktech.JDWP.Event.Composite.MonitorContendedEnterEvent;
import io.github.hqktech.JDWP.Event.Composite.MonitorContendedEnteredEvent;
import io.github.hqktech.JDWP.Event.Composite.MonitorWaitEvent;
import io.github.hqktech.JDWP.Event.Composite.MonitorWaitedEvent;
import io.github.hqktech.JDWP.Event.Composite.SingleStepEvent;
import io.github.hqktech.JDWP.Event.Composite.ThreadDeathEvent;
import io.github.hqktech.JDWP.Event.Composite.ThreadStartEvent;
import io.github.hqktech.JDWP.Event.Composite.VMDeathEvent;
import io.github.hqktech.JDWP.Event.Composite.VMStartEvent;

abstract class EventListenerAdapter {
void onVMStart(VMStartEvent event) {
}

void onVMDeath(VMDeathEvent event) {
}

void onSingleStep(SingleStepEvent event) {
}

void onBreakpoint(BreakpointEvent event) {
}

void onMethodEntry(MethodEntryEvent event) {
}

void onMethodExit(MethodExitEvent event) {
}

void onMethodExitWithReturnValue(MethodExitWithReturnValueEvent event) {
}

void onMonitorContendedEnter(MonitorContendedEnterEvent event) {
}

void onMonitorContendedEntered(MonitorContendedEnteredEvent event) {
}

void onMonitorWait(MonitorWaitEvent event) {
}

void onMonitorWaited(MonitorWaitedEvent event) {
}

void onException(ExceptionEvent event) {
}

void onThreadStart(ThreadStartEvent event) {
}

void onThreadDeath(ThreadDeathEvent event) {
}

void onClassPrepare(ClassPrepareEvent event) {
}

void onClassUnload(ClassUnloadEvent event) {
}

void onFieldAccess(FieldAccessEvent event) {
}

void onFieldModification(FieldModificationEvent event) {
}
}
84 changes: 84 additions & 0 deletions jadx-gui/src/main/java/jadx/gui/device/debugger/RuntimeType.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
package jadx.gui.device.debugger;

import io.github.hqktech.JDWP;

public enum RuntimeType {
ARRAY(91, "[]"),
BYTE(66, "byte"),
CHAR(67, "char"),
OBJECT(76, "object"),
FLOAT(70, "float"),
DOUBLE(68, "double"),
INT(73, "int"),
LONG(74, "long"),
SHORT(83, "short"),
VOID(86, "void"),
BOOLEAN(90, "boolean"),
STRING(115, "string"),
THREAD(116, "thread"),
THREAD_GROUP(103, "thread_group"),
CLASS_LOADER(108, "class_loader"),
CLASS_OBJECT(99, "class_object");

private final int jdwpTag;
private final String desc;

RuntimeType(int tag, String desc) {
this.jdwpTag = tag;
this.desc = desc;
}

public int getTag() {
return jdwpTag;
}

public String getDesc() {
return this.desc;
}

/**
* Converts a <code>JDWP.Tag</code> to a {@link RuntimeType}
*
* @param tag
* @return
* @throws SmaliDebuggerException
*/
public static RuntimeType fromJdwpTag(int tag) throws SmaliDebuggerException {
switch (tag) {
case JDWP.Tag.ARRAY:
return RuntimeType.ARRAY;
case JDWP.Tag.BYTE:
return RuntimeType.BYTE;
case JDWP.Tag.CHAR:
return RuntimeType.CHAR;
case JDWP.Tag.OBJECT:
return RuntimeType.OBJECT;
case JDWP.Tag.FLOAT:
return RuntimeType.FLOAT;
case JDWP.Tag.DOUBLE:
return RuntimeType.DOUBLE;
case JDWP.Tag.INT:
return RuntimeType.INT;
case JDWP.Tag.LONG:
return RuntimeType.LONG;
case JDWP.Tag.SHORT:
return RuntimeType.SHORT;
case JDWP.Tag.VOID:
return RuntimeType.VOID;
case JDWP.Tag.BOOLEAN:
return RuntimeType.BOOLEAN;
case JDWP.Tag.STRING:
return RuntimeType.STRING;
case JDWP.Tag.THREAD:
return RuntimeType.THREAD;
case JDWP.Tag.THREAD_GROUP:
return RuntimeType.THREAD_GROUP;
case JDWP.Tag.CLASS_LOADER:
return RuntimeType.CLASS_LOADER;
case JDWP.Tag.CLASS_OBJECT:
return RuntimeType.CLASS_OBJECT;
default:
throw new SmaliDebuggerException("Unexpected value: " + tag);
}
}
}
Loading