mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-05 19:42:36 +02:00
GP-1288: basic event/exc objects
This commit is contained in:
parent
7105c13681
commit
2f1f78dc97
12 changed files with 481 additions and 1 deletions
|
@ -0,0 +1,22 @@
|
|||
/* ###
|
||||
* 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.manager;
|
||||
|
||||
public interface DbgEventFilter {
|
||||
|
||||
String getName();
|
||||
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
/* ###
|
||||
* 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.manager;
|
||||
|
||||
public interface DbgExceptionFilter {
|
||||
|
||||
String getName();
|
||||
|
||||
}
|
|
@ -1585,4 +1585,12 @@ public class DbgManagerImpl implements DbgManager {
|
|||
return processCount;
|
||||
}
|
||||
|
||||
public CompletableFuture<Map<String, DbgEventFilter>> listEventFilters() {
|
||||
return CompletableFuture.completedFuture(new HashMap<String, DbgEventFilter>());
|
||||
}
|
||||
|
||||
public CompletableFuture<Map<String, DbgExceptionFilter>> listExceptionFilters() {
|
||||
return CompletableFuture.completedFuture(new HashMap<String, DbgExceptionFilter>());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
/* ###
|
||||
* 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 agent.dbgeng.manager.DbgEventFilter;
|
||||
|
||||
public interface DbgModelTargetEvent extends DbgModelTargetObject {
|
||||
|
||||
@Override
|
||||
public default String getDisplay() {
|
||||
return getName();
|
||||
}
|
||||
|
||||
public DbgEventFilter getFilter();
|
||||
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
/* ###
|
||||
* 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.TargetAggregate;
|
||||
import ghidra.dbg.target.schema.*;
|
||||
|
||||
@TargetObjectSchemaInfo(
|
||||
name = "EventContainer",
|
||||
elements = {
|
||||
@TargetElementType(type = DbgModelTargetEvent.class) },
|
||||
attributes = {
|
||||
@TargetAttributeType(type = Void.class) },
|
||||
canonicalContainer = true)
|
||||
public interface DbgModelTargetEventContainer extends DbgModelTargetObject, TargetAggregate {
|
||||
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
/* ###
|
||||
* 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 agent.dbgeng.manager.DbgExceptionFilter;
|
||||
|
||||
public interface DbgModelTargetException extends DbgModelTargetObject {
|
||||
|
||||
@Override
|
||||
public default String getDisplay() {
|
||||
return getName();
|
||||
}
|
||||
|
||||
public DbgExceptionFilter getFilter();
|
||||
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
/* ###
|
||||
* 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.TargetAggregate;
|
||||
import ghidra.dbg.target.schema.*;
|
||||
|
||||
@TargetObjectSchemaInfo(
|
||||
name = "EventContainer",
|
||||
elements = {
|
||||
@TargetElementType(type = DbgModelTargetException.class) },
|
||||
attributes = {
|
||||
@TargetAttributeType(type = Void.class) },
|
||||
canonicalContainer = true)
|
||||
public interface DbgModelTargetExceptionContainer extends DbgModelTargetObject, TargetAggregate {
|
||||
|
||||
}
|
|
@ -31,6 +31,16 @@ import ghidra.dbg.target.schema.TargetObjectSchemaInfo;
|
|||
type = DbgModelTargetBreakpointContainerImpl.class,
|
||||
required = true,
|
||||
fixed = true),
|
||||
@TargetAttributeType(
|
||||
name = "Events",
|
||||
type = DbgModelTargetEventContainerImpl.class,
|
||||
required = true,
|
||||
fixed = true),
|
||||
@TargetAttributeType(
|
||||
name = "Exceptions",
|
||||
type = DbgModelTargetEventContainerImpl.class,
|
||||
required = true,
|
||||
fixed = true),
|
||||
@TargetAttributeType(type = Void.class)
|
||||
},
|
||||
canonicalContainer = true)
|
||||
|
@ -38,6 +48,9 @@ public class DbgModelTargetDebugContainerImpl extends DbgModelTargetObjectImpl
|
|||
implements DbgModelTargetDebugContainer {
|
||||
|
||||
protected final DbgModelTargetBreakpointContainerImpl breakpoints;
|
||||
protected final DbgModelTargetEventContainerImpl events;
|
||||
protected final DbgModelTargetExceptionContainerImpl exceptions;
|
||||
|
||||
private DbgModelTargetProcess process;
|
||||
|
||||
public DbgModelTargetDebugContainerImpl(DbgModelTargetProcess process) {
|
||||
|
@ -45,9 +58,13 @@ public class DbgModelTargetDebugContainerImpl extends DbgModelTargetObjectImpl
|
|||
this.process = process;
|
||||
|
||||
this.breakpoints = new DbgModelTargetBreakpointContainerImpl(this);
|
||||
this.events = new DbgModelTargetEventContainerImpl(this);
|
||||
this.exceptions = new DbgModelTargetExceptionContainerImpl(this);
|
||||
|
||||
changeAttributes(List.of(), List.of( //
|
||||
breakpoints //
|
||||
breakpoints, //
|
||||
events, //
|
||||
exceptions //
|
||||
), Map.of(), "Initialized");
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,68 @@
|
|||
/* ###
|
||||
* 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 java.util.stream.Collectors;
|
||||
|
||||
import agent.dbgeng.manager.DbgEventFilter;
|
||||
import agent.dbgeng.manager.impl.DbgManagerImpl;
|
||||
import agent.dbgeng.model.iface2.*;
|
||||
import ghidra.dbg.target.TargetObject;
|
||||
import ghidra.dbg.target.schema.*;
|
||||
|
||||
@TargetObjectSchemaInfo(
|
||||
name = "EventContainer",
|
||||
elements = { //
|
||||
@TargetElementType(type = DbgModelTargetEvent.class) //
|
||||
},
|
||||
attributes = { //
|
||||
@TargetAttributeType(type = Void.class) //
|
||||
},
|
||||
canonicalContainer = true)
|
||||
public class DbgModelTargetEventContainerImpl extends DbgModelTargetObjectImpl
|
||||
implements DbgModelTargetEventContainer {
|
||||
|
||||
public DbgModelTargetEventContainerImpl(DbgModelTargetDebugContainer debug) {
|
||||
super(debug.getModel(), debug, "Events", "EventContainer");
|
||||
}
|
||||
|
||||
public DbgModelTargetEvent getTargetEvent(DbgEventFilter info) {
|
||||
DbgModelImpl impl = (DbgModelImpl) model;
|
||||
TargetObject modelObject = impl.getModelObject(info);
|
||||
if (modelObject != null) {
|
||||
return (DbgModelTargetEvent) modelObject;
|
||||
}
|
||||
return new DbgModelTargetEventImpl(this, info);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<Void> requestElements(boolean refresh) {
|
||||
DbgManagerImpl manager = getManager();
|
||||
return manager.listEventFilters().thenAccept(byName -> {
|
||||
List<TargetObject> filters;
|
||||
synchronized (this) {
|
||||
filters = byName.values()
|
||||
.stream()
|
||||
.map(this::getTargetEvent)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
setElements(filters, Map.of(), "Refreshed");
|
||||
});
|
||||
}
|
||||
}
|
|
@ -0,0 +1,78 @@
|
|||
/* ###
|
||||
* 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 agent.dbgeng.manager.DbgEventFilter;
|
||||
import agent.dbgeng.model.iface2.DbgModelTargetEvent;
|
||||
import agent.dbgeng.model.iface2.DbgModelTargetEventContainer;
|
||||
import ghidra.dbg.target.schema.*;
|
||||
import ghidra.dbg.util.PathUtils;
|
||||
import ghidra.program.model.address.Address;
|
||||
|
||||
@TargetObjectSchemaInfo(
|
||||
name = "Module",
|
||||
elements = {
|
||||
@TargetElementType(type = Void.class) },
|
||||
attributes = {
|
||||
@TargetAttributeType(
|
||||
name = "Symbols",
|
||||
type = DbgModelTargetSymbolContainerImpl.class,
|
||||
required = true,
|
||||
fixed = true),
|
||||
@TargetAttributeType(name = "BaseAddress", type = Address.class),
|
||||
@TargetAttributeType(name = "ImageName", type = String.class),
|
||||
@TargetAttributeType(name = "TimeStamp", type = Integer.class),
|
||||
@TargetAttributeType(name = "Len", type = String.class),
|
||||
@TargetAttributeType(type = Void.class) })
|
||||
public class DbgModelTargetEventImpl extends DbgModelTargetObjectImpl
|
||||
implements DbgModelTargetEvent {
|
||||
protected static String indexFilter(DbgEventFilter filter) {
|
||||
return filter.getName();
|
||||
}
|
||||
|
||||
protected static String keyFilter(DbgEventFilter filter) {
|
||||
return PathUtils.makeKey(indexFilter(filter));
|
||||
}
|
||||
|
||||
private DbgEventFilter filter;
|
||||
|
||||
public DbgModelTargetEventImpl(DbgModelTargetEventContainer events, DbgEventFilter filter) {
|
||||
super(events.getModel(), events, keyFilter(filter), "EventFilter");
|
||||
this.getModel().addModelObject(filter, this);
|
||||
this.filter = filter;
|
||||
|
||||
/*
|
||||
changeAttributes(List.of(), List.of( //
|
||||
symbols //
|
||||
// sections.getName(), sections, //
|
||||
), Map.of( //
|
||||
DISPLAY_ATTRIBUTE_NAME, getIndex(), //
|
||||
SHORT_DISPLAY_ATTRIBUTE_NAME, module.getName(), //
|
||||
MODULE_NAME_ATTRIBUTE_NAME, module.getImageName(), //
|
||||
"BaseAddress", space.getAddress(module.getKnownBase()), //
|
||||
"ImageName", module.getImageName(), //
|
||||
"TimeStamp", module.getTimeStamp(), //
|
||||
"Len", Integer.toHexString(module.getSize()) //
|
||||
), "Initialized");
|
||||
*/
|
||||
}
|
||||
|
||||
@Override
|
||||
public DbgEventFilter getFilter() {
|
||||
return filter;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,68 @@
|
|||
/* ###
|
||||
* 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 java.util.stream.Collectors;
|
||||
|
||||
import agent.dbgeng.manager.DbgExceptionFilter;
|
||||
import agent.dbgeng.manager.impl.DbgManagerImpl;
|
||||
import agent.dbgeng.model.iface2.*;
|
||||
import ghidra.dbg.target.TargetObject;
|
||||
import ghidra.dbg.target.schema.*;
|
||||
|
||||
@TargetObjectSchemaInfo(
|
||||
name = "ExceptionContainer",
|
||||
elements = { //
|
||||
@TargetElementType(type = DbgModelTargetEvent.class) //
|
||||
},
|
||||
attributes = { //
|
||||
@TargetAttributeType(type = Void.class) //
|
||||
},
|
||||
canonicalContainer = true)
|
||||
public class DbgModelTargetExceptionContainerImpl extends DbgModelTargetObjectImpl
|
||||
implements DbgModelTargetEventContainer {
|
||||
|
||||
public DbgModelTargetExceptionContainerImpl(DbgModelTargetDebugContainer debug) {
|
||||
super(debug.getModel(), debug, "Exceptions", "ExceptionContainer");
|
||||
}
|
||||
|
||||
public DbgModelTargetException getTargetException(DbgExceptionFilter info) {
|
||||
DbgModelImpl impl = (DbgModelImpl) model;
|
||||
TargetObject modelObject = impl.getModelObject(info);
|
||||
if (modelObject != null) {
|
||||
return (DbgModelTargetException) modelObject;
|
||||
}
|
||||
return new DbgModelTargetExceptionImpl(this, info);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<Void> requestElements(boolean refresh) {
|
||||
DbgManagerImpl manager = getManager();
|
||||
return manager.listExceptionFilters().thenAccept(byName -> {
|
||||
List<TargetObject> filters;
|
||||
synchronized (this) {
|
||||
filters = byName.values()
|
||||
.stream()
|
||||
.map(this::getTargetException)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
setElements(filters, Map.of(), "Refreshed");
|
||||
});
|
||||
}
|
||||
}
|
|
@ -0,0 +1,79 @@
|
|||
/* ###
|
||||
* 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 agent.dbgeng.manager.DbgExceptionFilter;
|
||||
import agent.dbgeng.model.iface2.DbgModelTargetEventContainer;
|
||||
import agent.dbgeng.model.iface2.DbgModelTargetException;
|
||||
import ghidra.dbg.target.schema.*;
|
||||
import ghidra.dbg.util.PathUtils;
|
||||
import ghidra.program.model.address.Address;
|
||||
|
||||
@TargetObjectSchemaInfo(
|
||||
name = "Module",
|
||||
elements = {
|
||||
@TargetElementType(type = Void.class) },
|
||||
attributes = {
|
||||
@TargetAttributeType(
|
||||
name = "Symbols",
|
||||
type = DbgModelTargetSymbolContainerImpl.class,
|
||||
required = true,
|
||||
fixed = true),
|
||||
@TargetAttributeType(name = "BaseAddress", type = Address.class),
|
||||
@TargetAttributeType(name = "ImageName", type = String.class),
|
||||
@TargetAttributeType(name = "TimeStamp", type = Integer.class),
|
||||
@TargetAttributeType(name = "Len", type = String.class),
|
||||
@TargetAttributeType(type = Void.class) })
|
||||
public class DbgModelTargetExceptionImpl extends DbgModelTargetObjectImpl
|
||||
implements DbgModelTargetException {
|
||||
protected static String indexFilter(DbgExceptionFilter filter) {
|
||||
return filter.getName();
|
||||
}
|
||||
|
||||
protected static String keyFilter(DbgExceptionFilter filter) {
|
||||
return PathUtils.makeKey(indexFilter(filter));
|
||||
}
|
||||
|
||||
private DbgExceptionFilter filter;
|
||||
|
||||
public DbgModelTargetExceptionImpl(DbgModelTargetEventContainer events,
|
||||
DbgExceptionFilter filter) {
|
||||
super(events.getModel(), events, keyFilter(filter), "ExceptionFilter");
|
||||
this.getModel().addModelObject(filter, this);
|
||||
this.filter = filter;
|
||||
|
||||
/*
|
||||
changeAttributes(List.of(), List.of( //
|
||||
symbols //
|
||||
// sections.getName(), sections, //
|
||||
), Map.of( //
|
||||
DISPLAY_ATTRIBUTE_NAME, getIndex(), //
|
||||
SHORT_DISPLAY_ATTRIBUTE_NAME, module.getName(), //
|
||||
MODULE_NAME_ATTRIBUTE_NAME, module.getImageName(), //
|
||||
"BaseAddress", space.getAddress(module.getKnownBase()), //
|
||||
"ImageName", module.getImageName(), //
|
||||
"TimeStamp", module.getTimeStamp(), //
|
||||
"Len", Integer.toHexString(module.getSize()) //
|
||||
), "Initialized");
|
||||
*/
|
||||
}
|
||||
|
||||
@Override
|
||||
public DbgExceptionFilter getFilter() {
|
||||
return filter;
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue