mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-05 10:49:34 +02:00
GP-1288: convert options to objects
This commit is contained in:
parent
2c5b8d5863
commit
cd1b5f6592
8 changed files with 212 additions and 64 deletions
|
@ -114,6 +114,55 @@ public interface DebugControl extends DebugControlReentrant {
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static enum DebugFilterExecutionOption {
|
||||||
|
DEBUG_FILTER_BREAK(0, "Break"), //
|
||||||
|
DEBUG_FILTER_SECOND_CHANCE_BREAK(1, "Second-chance Break"), //
|
||||||
|
DEBUG_FILTER_OUTPUT(2, "Output-only"), //
|
||||||
|
DEBUG_FILTER_IGNORE(3, "Ignore"), //
|
||||||
|
DEBUG_FILTER_REMOVE(4, "Remove"), //
|
||||||
|
;
|
||||||
|
|
||||||
|
public static DebugFilterExecutionOption getByNumber(int val) {
|
||||||
|
for (DebugFilterExecutionOption m : DebugFilterExecutionOption.values()) {
|
||||||
|
if (m.val == val) {
|
||||||
|
return m;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
DebugFilterExecutionOption(int val, String description) {
|
||||||
|
this.val = val;
|
||||||
|
this.description = description;
|
||||||
|
}
|
||||||
|
|
||||||
|
public final int val;
|
||||||
|
public final String description;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static enum DebugFilterContinuationOption {
|
||||||
|
DEBUG_FILTER_GO_HANDLED(0, "Handled"), //
|
||||||
|
DEBUG_FILTER_GO_NOT_HANDLED(1, "Not Handled"), //
|
||||||
|
;
|
||||||
|
|
||||||
|
public static DebugFilterContinuationOption getByNumber(int val) {
|
||||||
|
for (DebugFilterContinuationOption m : DebugFilterContinuationOption.values()) {
|
||||||
|
if (m.val == val) {
|
||||||
|
return m;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
DebugFilterContinuationOption(int val, String description) {
|
||||||
|
this.val = val;
|
||||||
|
this.description = description;
|
||||||
|
}
|
||||||
|
|
||||||
|
public final int val;
|
||||||
|
public final String description;
|
||||||
|
}
|
||||||
|
|
||||||
boolean getInterrupt();
|
boolean getInterrupt();
|
||||||
|
|
||||||
int getInterruptTimeout();
|
int getInterruptTimeout();
|
||||||
|
|
|
@ -15,21 +15,9 @@
|
||||||
*/
|
*/
|
||||||
package agent.dbgeng.manager;
|
package agent.dbgeng.manager;
|
||||||
|
|
||||||
public interface DbgExceptionFilter {
|
public interface DbgExceptionFilter extends DbgEventFilter {
|
||||||
|
|
||||||
String getName();
|
|
||||||
|
|
||||||
String getCmd();
|
|
||||||
|
|
||||||
String getSecondCmd();
|
String getSecondCmd();
|
||||||
|
|
||||||
int getExecutionOption();
|
String getExceptionCode();
|
||||||
|
|
||||||
void setExecutionOption(int executionOption);
|
|
||||||
|
|
||||||
int getContinueOption();
|
|
||||||
|
|
||||||
void setContinueOption(int continueOption);
|
|
||||||
|
|
||||||
long getExceptionCode();
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,10 +18,10 @@ package agent.dbgeng.manager.impl;
|
||||||
import agent.dbgeng.manager.DbgEventFilter;
|
import agent.dbgeng.manager.DbgEventFilter;
|
||||||
|
|
||||||
public class DbgEventFilterImpl implements DbgEventFilter {
|
public class DbgEventFilterImpl implements DbgEventFilter {
|
||||||
private final String text;
|
protected final String text;
|
||||||
private final String cmd;
|
protected final String cmd;
|
||||||
private int executionOption;
|
protected int executionOption;
|
||||||
private int continueOption;
|
protected int continueOption;
|
||||||
|
|
||||||
public DbgEventFilterImpl(String text, String cmd, int executionOption, int continueOption) {
|
public DbgEventFilterImpl(String text, String cmd, int executionOption, int continueOption) {
|
||||||
this.text = text;
|
this.text = text;
|
||||||
|
|
|
@ -17,56 +17,24 @@ package agent.dbgeng.manager.impl;
|
||||||
|
|
||||||
import agent.dbgeng.manager.DbgExceptionFilter;
|
import agent.dbgeng.manager.DbgExceptionFilter;
|
||||||
|
|
||||||
public class DbgExceptionFilterImpl implements DbgExceptionFilter {
|
public class DbgExceptionFilterImpl extends DbgEventFilterImpl implements DbgExceptionFilter {
|
||||||
private final String text;
|
|
||||||
private final String cmd;
|
|
||||||
private final String cmd2;
|
private final String cmd2;
|
||||||
private int executionOption;
|
|
||||||
private int continueOption;
|
|
||||||
private long exceptionCode;
|
private long exceptionCode;
|
||||||
|
|
||||||
public DbgExceptionFilterImpl(String text, String cmd, String cmd2, int executionOption,
|
public DbgExceptionFilterImpl(String text, String cmd, String cmd2, int executionOption,
|
||||||
int continueOption, long exceptionCode) {
|
int continueOption, long exceptionCode) {
|
||||||
this.text = text;
|
super(text, cmd, executionOption, continueOption);
|
||||||
this.cmd = cmd;
|
|
||||||
this.cmd2 = cmd2;
|
this.cmd2 = cmd2;
|
||||||
this.setExecutionOption(executionOption);
|
|
||||||
this.setContinueOption(continueOption);
|
|
||||||
this.exceptionCode = exceptionCode;
|
this.exceptionCode = exceptionCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getName() {
|
|
||||||
return text;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getCmd() {
|
|
||||||
return cmd;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getSecondCmd() {
|
public String getSecondCmd() {
|
||||||
return cmd2;
|
return cmd2;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getExecutionOption() {
|
public String getExceptionCode() {
|
||||||
return executionOption;
|
return Long.toHexString(exceptionCode);
|
||||||
}
|
|
||||||
|
|
||||||
public void setExecutionOption(int executionOption) {
|
|
||||||
this.executionOption = executionOption;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getContinueOption() {
|
|
||||||
return continueOption;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setContinueOption(int continueOption) {
|
|
||||||
this.continueOption = continueOption;
|
|
||||||
}
|
|
||||||
|
|
||||||
public long getExceptionCode() {
|
|
||||||
return exceptionCode;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,27 @@
|
||||||
|
/* ###
|
||||||
|
* IP: GHIDRA
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
package agent.dbgeng.model.iface2;
|
||||||
|
|
||||||
|
import ghidra.dbg.target.TargetTogglable;
|
||||||
|
|
||||||
|
public interface DbgModelTargetEventOption extends DbgModelTargetObject, TargetTogglable {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public default String getDisplay() {
|
||||||
|
return getName();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -18,9 +18,10 @@ package agent.dbgeng.model.impl;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import agent.dbgeng.dbgeng.DebugControl.DebugFilterContinuationOption;
|
||||||
|
import agent.dbgeng.dbgeng.DebugControl.DebugFilterExecutionOption;
|
||||||
import agent.dbgeng.manager.DbgEventFilter;
|
import agent.dbgeng.manager.DbgEventFilter;
|
||||||
import agent.dbgeng.model.iface2.DbgModelTargetEvent;
|
import agent.dbgeng.model.iface2.*;
|
||||||
import agent.dbgeng.model.iface2.DbgModelTargetEventContainer;
|
|
||||||
import ghidra.dbg.target.schema.*;
|
import ghidra.dbg.target.schema.*;
|
||||||
import ghidra.dbg.util.PathUtils;
|
import ghidra.dbg.util.PathUtils;
|
||||||
|
|
||||||
|
@ -40,6 +41,9 @@ public class DbgModelTargetEventImpl extends DbgModelTargetObjectImpl
|
||||||
return PathUtils.makeKey(indexFilter(filter));
|
return PathUtils.makeKey(indexFilter(filter));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected DbgModelTargetEventOption execOption;
|
||||||
|
protected DbgModelTargetEventOption contOption;
|
||||||
|
|
||||||
private DbgEventFilter filter;
|
private DbgEventFilter filter;
|
||||||
|
|
||||||
public DbgModelTargetEventImpl(DbgModelTargetEventContainer events, DbgEventFilter filter) {
|
public DbgModelTargetEventImpl(DbgModelTargetEventContainer events, DbgEventFilter filter) {
|
||||||
|
@ -47,11 +51,18 @@ public class DbgModelTargetEventImpl extends DbgModelTargetObjectImpl
|
||||||
this.getModel().addModelObject(filter, this);
|
this.getModel().addModelObject(filter, this);
|
||||||
this.filter = filter;
|
this.filter = filter;
|
||||||
|
|
||||||
|
DebugFilterExecutionOption exec =
|
||||||
|
DebugFilterExecutionOption.getByNumber(filter.getExecutionOption());
|
||||||
|
DebugFilterContinuationOption cont =
|
||||||
|
DebugFilterContinuationOption.getByNumber(filter.getContinueOption());
|
||||||
|
execOption = new DbgModelTargetEventOptionImpl(this, exec);
|
||||||
|
contOption = new DbgModelTargetEventOptionImpl(this, cont);
|
||||||
|
|
||||||
changeAttributes(List.of(), List.of(), Map.of( //
|
changeAttributes(List.of(), List.of(), Map.of( //
|
||||||
DISPLAY_ATTRIBUTE_NAME, getIndex(), //
|
DISPLAY_ATTRIBUTE_NAME, getIndex(), //
|
||||||
"Command", filter.getCmd(), //
|
"Command", filter.getCmd(), //
|
||||||
"Execute", filter.getExecutionOption(), //
|
"Execute", execOption, //
|
||||||
"Continue", filter.getContinueOption() //
|
"Continue", contOption //
|
||||||
), "Initialized");
|
), "Initialized");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,94 @@
|
||||||
|
/* ###
|
||||||
|
* IP: GHIDRA
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
package agent.dbgeng.model.impl;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
|
import agent.dbgeng.dbgeng.DebugControl.DebugFilterContinuationOption;
|
||||||
|
import agent.dbgeng.dbgeng.DebugControl.DebugFilterExecutionOption;
|
||||||
|
import agent.dbgeng.model.iface2.*;
|
||||||
|
import ghidra.dbg.target.schema.*;
|
||||||
|
import ghidra.dbg.util.PathUtils;
|
||||||
|
|
||||||
|
@TargetObjectSchemaInfo(
|
||||||
|
name = "Event",
|
||||||
|
elements = {
|
||||||
|
@TargetElementType(type = Void.class) },
|
||||||
|
attributes = {
|
||||||
|
@TargetAttributeType(type = Object.class) })
|
||||||
|
public class DbgModelTargetEventOptionImpl extends DbgModelTargetObjectImpl
|
||||||
|
implements DbgModelTargetEventOption {
|
||||||
|
|
||||||
|
protected static String keyFilter(DebugFilterExecutionOption option) {
|
||||||
|
return PathUtils.makeKey(option.description);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected static String keyFilter(DebugFilterContinuationOption option) {
|
||||||
|
return PathUtils.makeKey(option.description);
|
||||||
|
}
|
||||||
|
|
||||||
|
private DebugFilterExecutionOption optionEx;
|
||||||
|
private DebugFilterContinuationOption optionCont;
|
||||||
|
|
||||||
|
public DbgModelTargetEventOptionImpl(DbgModelTargetEvent event,
|
||||||
|
DebugFilterExecutionOption option) {
|
||||||
|
super(event.getModel(), event, keyFilter(option), "EventFilter");
|
||||||
|
this.getModel().addModelObject(option, this);
|
||||||
|
this.optionEx = option;
|
||||||
|
}
|
||||||
|
|
||||||
|
public DbgModelTargetEventOptionImpl(DbgModelTargetEvent event,
|
||||||
|
DebugFilterContinuationOption option) {
|
||||||
|
super(event.getModel(), event, keyFilter(option), "EventFilter");
|
||||||
|
this.getModel().addModelObject(option, this);
|
||||||
|
this.optionCont = option;
|
||||||
|
}
|
||||||
|
|
||||||
|
public DbgModelTargetEventOptionImpl(DbgModelTargetException exc,
|
||||||
|
DebugFilterExecutionOption option) {
|
||||||
|
super(exc.getModel(), exc, keyFilter(option), "EventFilter");
|
||||||
|
this.getModel().addModelObject(option, this);
|
||||||
|
this.optionEx = option;
|
||||||
|
}
|
||||||
|
|
||||||
|
public DbgModelTargetEventOptionImpl(DbgModelTargetException exc,
|
||||||
|
DebugFilterContinuationOption option) {
|
||||||
|
super(exc.getModel(), exc, keyFilter(option), "EventFilter");
|
||||||
|
this.getModel().addModelObject(option, this);
|
||||||
|
this.optionCont = option;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CompletableFuture<Void> disable() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CompletableFuture<Void> enable() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAttributes() {
|
||||||
|
changeAttributes(List.of(), List.of(), Map.of( //
|
||||||
|
DISPLAY_ATTRIBUTE_NAME, getName() //
|
||||||
|
), "Initialized");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -18,9 +18,10 @@ package agent.dbgeng.model.impl;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import agent.dbgeng.dbgeng.DebugControl.DebugFilterContinuationOption;
|
||||||
|
import agent.dbgeng.dbgeng.DebugControl.DebugFilterExecutionOption;
|
||||||
import agent.dbgeng.manager.DbgExceptionFilter;
|
import agent.dbgeng.manager.DbgExceptionFilter;
|
||||||
import agent.dbgeng.model.iface2.DbgModelTargetException;
|
import agent.dbgeng.model.iface2.*;
|
||||||
import agent.dbgeng.model.iface2.DbgModelTargetExceptionContainer;
|
|
||||||
import ghidra.dbg.target.schema.*;
|
import ghidra.dbg.target.schema.*;
|
||||||
import ghidra.dbg.util.PathUtils;
|
import ghidra.dbg.util.PathUtils;
|
||||||
|
|
||||||
|
@ -40,6 +41,9 @@ public class DbgModelTargetExceptionImpl extends DbgModelTargetObjectImpl
|
||||||
return PathUtils.makeKey(indexFilter(filter));
|
return PathUtils.makeKey(indexFilter(filter));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected DbgModelTargetEventOption execOption;
|
||||||
|
protected DbgModelTargetEventOption contOption;
|
||||||
|
|
||||||
private DbgExceptionFilter filter;
|
private DbgExceptionFilter filter;
|
||||||
|
|
||||||
public DbgModelTargetExceptionImpl(DbgModelTargetExceptionContainer exceptions,
|
public DbgModelTargetExceptionImpl(DbgModelTargetExceptionContainer exceptions,
|
||||||
|
@ -48,13 +52,20 @@ public class DbgModelTargetExceptionImpl extends DbgModelTargetObjectImpl
|
||||||
this.getModel().addModelObject(filter, this);
|
this.getModel().addModelObject(filter, this);
|
||||||
this.filter = filter;
|
this.filter = filter;
|
||||||
|
|
||||||
|
DebugFilterExecutionOption exec =
|
||||||
|
DebugFilterExecutionOption.getByNumber(filter.getExecutionOption());
|
||||||
|
DebugFilterContinuationOption cont =
|
||||||
|
DebugFilterContinuationOption.getByNumber(filter.getContinueOption());
|
||||||
|
execOption = new DbgModelTargetEventOptionImpl(this, exec);
|
||||||
|
contOption = new DbgModelTargetEventOptionImpl(this, cont);
|
||||||
|
|
||||||
changeAttributes(List.of(), List.of(), Map.of( //
|
changeAttributes(List.of(), List.of(), Map.of( //
|
||||||
DISPLAY_ATTRIBUTE_NAME, getIndex(), //
|
DISPLAY_ATTRIBUTE_NAME, getIndex(), //
|
||||||
"Command", filter.getCmd(), //
|
"Command", filter.getCmd(), //
|
||||||
"SecondCmd", filter.getCmd(), //
|
"SecondCmd", filter.getCmd(), //
|
||||||
"Execute", filter.getExecutionOption(), //
|
"Execute", execOption, //
|
||||||
"Continue", filter.getContinueOption(), //
|
"Continue", contOption, //
|
||||||
"Exception", Long.toHexString(filter.getExceptionCode()) //
|
"Exception", filter.getExceptionCode() //
|
||||||
), "Initialized");
|
), "Initialized");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue